Skip to content

Commit

Permalink
Fixeeesss
Browse files Browse the repository at this point in the history
  • Loading branch information
Evangelink committed Jul 25, 2022
1 parent 2ab1009 commit fb0660d
Show file tree
Hide file tree
Showing 8 changed files with 281 additions and 280 deletions.
36 changes: 15 additions & 21 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ function Invoke-CompatibilityTestAssetsBuild {
}

if ($rebuild) {
if (Test-Path $generated) {
if (Test-Path $generated) {
Remove-Item $generated -Recurse -Force
}

Expand All @@ -279,7 +279,7 @@ function Invoke-CompatibilityTestAssetsBuild {

Invoke-Exe $dotnetExe -Arguments "new sln --name CompatibilityTestAssets --output ""$generated"""

Write-Log ".. .. Build: Source: $generatedSln"
Write-Log ".. .. Build: Source: $generatedSln"
try {
$projectsToAdd = @()
$nugetConfigSource = Join-Path $TPB_TestAssets "NuGet.config"
Expand Down Expand Up @@ -326,7 +326,7 @@ function Invoke-CompatibilityTestAssetsBuild {
$dirMSTestPropertyName = $propertyName -replace "Framework" -replace "Version"

# Do not make this a folder structure, it will break the relative reference to scripts\build\TestAssets.props that we have in the project,
# because the relative path will be different.
# because the relative path will be different.
#
# It would be nice to use fully descriptive name but it is too long, hash the versions instead.
# $compatibilityProjectDir = "$generated/$projectBaseName--$dirNetTestSdkPropertyName-$dirNetTestSdkVersion--$dirMSTestPropertyName-$dirMSTestVersion"
Expand All @@ -336,7 +336,7 @@ function Invoke-CompatibilityTestAssetsBuild {
$projectShortName = "$projectBaseName--" + $hash
$compatibilityProjectDir = "$generated/$projectShortName"

if (Test-path $compatibilityProjectDir) {
if (Test-path $compatibilityProjectDir) {
throw "Path '$compatibilityProjectDir' does not exist"
}
New-Item -ItemType Directory -Path $compatibilityProjectDir | Out-Null
Expand Down Expand Up @@ -426,7 +426,7 @@ function Publish-Package {
$netstandard13PackageDir = $(Join-Path $env:TP_OUT_DIR "$TPB_Configuration\$TPB_TargetFrameworkNS13");
$netstandard20PackageDir = $(Join-Path $env:TP_OUT_DIR "$TPB_Configuration\$TPB_TargetFrameworkNS20");
$coreCLR31PackageDir = Get-CoreCLR31PackageDirectory
$coreCLR31TestHostPackageDir = Get-CoreCLR31TestHostPackageDirectory
$coreClrNetFrameworkTestHostDir = Join-Path $coreCLR31PackageDir "TestHostNetFramework"
$packageProject = Join-Path $env:TP_PACKAGE_PROJ_DIR "package\package.csproj"
$testHostProject = Join-Path $env:TP_ROOT_DIR "src\testhost\testhost.csproj"
$testHostx86Project = Join-Path $env:TP_ROOT_DIR "src\testhost.x86\testhost.x86.csproj"
Expand Down Expand Up @@ -515,14 +515,12 @@ function Publish-Package {
Copy-Item $testhostCore31PackageTempARM64Dir\Microsoft.TestPlatform.PlatformAbstractions.dll $testhostCore31PackageARM64Dir -Force

# Copy over the Full CLR built testhost package assemblies to the Core CLR and Full CLR package folder.
$coreCLRFull_Dir = "TestHost"
$fullDestDir = Join-Path $coreCLR31PackageDir $coreCLRFull_Dir
New-Item -ItemType directory -Path $fullDestDir -Force | Out-Null
Copy-Item $testhostFullPackageDir\* $fullDestDir -Force -Recurse
New-Item -ItemType directory -Path $coreClrNetFrameworkTestHostDir -Force | Out-Null
Copy-Item $testhostFullPackageDir\* $coreClrNetFrameworkTestHostDir -Force -Recurse

# Copy over the Full CLR built datacollector package assemblies to the Core CLR package folder along with testhost
Publish-PackageWithRuntimeInternal $dataCollectorProject $TPB_TargetFramework472 $TPB_ARM64_Runtime false $fullDestDir
Publish-PackageWithRuntimeInternal $dataCollectorProject $TPB_TargetFramework472 $TPB_X64_Runtime false $fullDestDir
Publish-PackageWithRuntimeInternal $dataCollectorProject $TPB_TargetFramework472 $TPB_ARM64_Runtime false $coreClrNetFrameworkTestHostDir
Publish-PackageWithRuntimeInternal $dataCollectorProject $TPB_TargetFramework472 $TPB_X64_Runtime false $coreClrNetFrameworkTestHostDir

New-Item -ItemType directory -Path $net462PackageDir -Force | Out-Null
Copy-Item $testhostFullPackageDir\* $net462PackageDir -Force -Recurse
Expand Down Expand Up @@ -604,7 +602,7 @@ function Publish-Package {
Copy-Item -Recurse $comComponentsDirectory\* $testhostCore31PackageDir -Force
Copy-Item -Recurse $comComponentsDirectory\* $testhostFullPackageDir -Force
Copy-Item -Recurse $comComponentsDirectory\* $testhostUapPackageDir -Force
Copy-Item -Recurse $comComponentsDirectory\* $coreCLR31TestHostPackageDir -Force
Copy-Item -Recurse $comComponentsDirectory\* $coreClrNetFrameworkTestHostDir -Force

# Copy over the logger assemblies to the Extensions folder.
$extensions_Dir = "Extensions"
Expand Down Expand Up @@ -735,13 +733,13 @@ function Publish-Package {
Copy-Item $newtonsoft $coreCLR31PackageDir -Force

# Copy .NET Standard CPP Test adapter
New-Item "$net462PackageDir\TestHost" -ItemType Directory -Force | Out-Null
$fullCLRTestHostDir = "$net462PackageDir\TestHost"
$fullClrNetTestHostDir = "$net462PackageDir\TestHostNet"
New-Item $fullClrNetTestHostDir -ItemType Directory -Force | Out-Null

$testPlatformRemoteExternalsVersion = ([xml](Get-Content "$env:TP_ROOT_DIR\scripts\build\TestPlatform.Dependencies.props")).Project.PropertyGroup.TestPlatformRemoteExternalsVersion
$testPlatformRemoteExternalsSourceDirectory = Join-Path $env:TP_PACKAGES_DIR "Microsoft.Internal.TestPlatform.Remote\$testPlatformRemoteExternalsVersion\tools\netstandard\Extensions\*"
Copy-Item $testPlatformRemoteExternalsSourceDirectory $coreCLR31PackageDir -Force -Recurse
Copy-Item $testPlatformRemoteExternalsSourceDirectory $fullCLRTestHostDir -Force -Recurse
Copy-Item $testPlatformRemoteExternalsSourceDirectory $fullClrNetTestHostDir -Force -Recurse

# Copy standalone testhost
$standaloneTesthost = Join-Path $env:TP_ROOT_DIR "temp\testhost\*"
Expand All @@ -751,8 +749,8 @@ function Publish-Package {

Get-Item "$testhostCore31PackageDir\*" |
Where-Object { $_.Name -notin ("x64", "x86", "win7-x64", "win7-x86", "testhost.deps.json", "testhost.runtimeconfig.json") } |
Copy-Item -Recurse -Destination $fullCLRTestHostDir -Force
Copy-Item $standaloneTesthost $fullCLRTestHostDir -Force
Copy-Item -Recurse -Destination $fullClrNetTestHostDir -Force
Copy-Item $standaloneTesthost $fullClrNetTestHostDir -Force

# For libraries that are externally published, copy the output into artifacts. These will be signed and packaged independently.
Copy-PackageItems "Microsoft.TestPlatform.Build"
Expand Down Expand Up @@ -1179,10 +1177,6 @@ function Get-CoreCLR31PackageDirectory {
return $(Join-Path $env:TP_OUT_DIR "$TPB_Configuration\$TPB_TargetFrameworkCore31")
}

function Get-CoreCLR31TestHostPackageDirectory {
return $(Join-Path $env:TP_OUT_DIR "$TPB_Configuration\$TPB_TargetFrameworkCore31\TestHost")
}

function Locate-MSBuildPath {
$vsInstallPath = Locate-VsInstallPath
$msbuildPath = Get-ChildItem (Join-Path -path $vsInstallPath -childPath "MSBuild\*\Bin\MSBuild.exe")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ public override int LaunchDataCollector(IDictionary<string, string?>? environmen
TPDebug.Assert(currentProcessPath is not null, "currentProcessPath is not null");

// If current process is dotnet/dotnet.exe and you are here, datacollector.exe/datacollector.arm64.exe is present in TestHost folder.
string dataCollectorProcessName = _processHelper.GetCurrentProcessArchitecture() == PlatformArchitecture.ARM64 ? DataCollectorProcessNameArm64 : DataCollectorProcessName;
string dataCollectorProcessName = _processHelper.GetCurrentProcessArchitecture() == PlatformArchitecture.ARM64
? DataCollectorProcessNameArm64
: DataCollectorProcessName;
string dataCollectorProcessPath = currentProcessPath.EndsWith("dotnet", StringComparison.OrdinalIgnoreCase)
|| currentProcessPath.EndsWith("dotnet.exe", StringComparison.OrdinalIgnoreCase)
? Path.Combine(dataCollectorDirectory, "TestHost", dataCollectorProcessName)
? Path.Combine(dataCollectorDirectory, "TestHostNetFramework", dataCollectorProcessName)
: Path.Combine(dataCollectorDirectory, dataCollectorProcessName);

var argumentsString = string.Join(" ", commandLineArguments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,13 @@ public virtual TestProcessStartInfo GetTestHostProcessStartInfo(
var testhostProcessPath = Path.Combine(currentWorkingDirectory, testHostProcessName);

var originalTestHostProcessName = testHostProcessName;

if (!_fileHelper.Exists(testhostProcessPath))
{
// "TestHost" is the name of the folder which contain Full CLR built testhost package assemblies, in dotnet SDK.
testHostProcessName = Path.Combine("TestHost", originalTestHostProcessName);
// We assume that we could not find testhost.exe in the root folder so we are going to lookup in the
// TestHostNetFramework folder (assuming we are currently running under netcoreapp3.1) or in dotnet SDK
// context.
testHostProcessName = Path.Combine("TestHostNetFramework", originalTestHostProcessName);
testhostProcessPath = Path.Combine(currentWorkingDirectory, "..", testHostProcessName);
}

Expand All @@ -187,7 +190,7 @@ public virtual TestProcessStartInfo GetTestHostProcessStartInfo(
argumentsString += " --testsourcepath " + sources.FirstOrDefault()?.AddDoubleQuote();
}

EqtTrace.Verbose("DefaultTestHostmanager: Full path of {0} is {1}", testHostProcessName, testhostProcessPath);
EqtTrace.Verbose("DefaultTestHostmanager.GetTestHostProcessStartInfo: Trying to use {0} from {1}", originalTestHostProcessName, testhostProcessPath);

var launcherPath = testhostProcessPath;
var processName = _processHelper.GetCurrentProcessFileName();
Expand All @@ -208,6 +211,7 @@ public virtual TestProcessStartInfo GetTestHostProcessStartInfo(
&& !File.Exists(testhostProcessPath))
{
testhostProcessPath = Path.Combine(currentWorkingDirectory, "..", originalTestHostProcessName);
EqtTrace.Verbose("DefaultTestHostmanager.GetTestHostProcessStartInfo: Could not find {0} in previous location, now using {1}", originalTestHostProcessName, testhostProcessPath);
launcherPath = testhostProcessPath;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,9 @@ public virtual TestProcessStartInfo GetTestHostProcessStartInfo(

if (testHostPath.IsNullOrEmpty())
{
// We still did not find testhost.dll. Try finding it next to vstest.console, (or in next to vstest.console ./TestHost for .NET Framework)
// We still did not find testhost.dll. Try finding it next to vstest.console, (or in next to vstest.console ./TestHostNet for .NET Framework)
#if NETFRAMEWORK
var testHostNextToRunner = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location)!, "TestHost", "testhost.dll");
var testHostNextToRunner = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location)!, "TestHostNet", "testhost.dll");
#else
var testHostNextToRunner = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location)!, "testhost.dll");
#endif
Expand Down
Loading

0 comments on commit fb0660d

Please sign in to comment.