Skip to content
Merged
9 changes: 6 additions & 3 deletions global.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
"runtimes": {
"dotnet": [
"8.0.18",
"9.0.7"
"9.0.7",
"10.0.0"
],
"dotnet/x86": [
"9.0.7"
"9.0.7",
"10.0.0"
],
"aspnetcore": [
"9.0.7"
"9.0.7",
"10.0.0"
]
},
"vs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ public async Task RunTests_With_VSTest(string multiTfm, BuildConfiguration build
DotnetMuxerResult compilationResult = await DotnetCli.RunAsync($"test -c {buildConfiguration} {testAsset.TargetAssetPath}", AcceptanceFixture.NuGetGlobalPackagesFolder.Path, workingDirectory: testAsset.TargetAssetPath, cancellationToken: TestContext.CancellationToken);
compilationResult.AssertExitCodeIs(0);

compilationResult.AssertOutputMatchesRegex(@"Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1, Duration: .* [m]?s - MSTestSdk.dll \(net9\.0\)");
compilationResult.AssertOutputMatchesRegex(@"Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1, Duration: .* [m]?s - MSTestSdk.dll \(net10\.0\)");
#if !SKIP_INTERMEDIATE_TARGET_FRAMEWORKS
compilationResult.AssertOutputMatchesRegex(@"Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1, Duration: .* [m]?s - MSTestSdk.dll \(net9\.0\)");
compilationResult.AssertOutputMatchesRegex(@"Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1, Duration: .* [m]?s - MSTestSdk.dll \(net8\.0\)");
#endif

Expand All @@ -98,8 +99,9 @@ public async Task RunTests_With_MSTestRunner_DotnetTest(string multiTfm, BuildCo
DotnetMuxerResult compilationResult = await DotnetCli.RunAsync($"test -c {buildConfiguration} --project {testAsset.TargetAssetPath} --no-progress --no-ansi", AcceptanceFixture.NuGetGlobalPackagesFolder.Path, workingDirectory: testAsset.TargetAssetPath, cancellationToken: TestContext.CancellationToken);
compilationResult.AssertExitCodeIs(0);

compilationResult.AssertOutputMatchesRegex(@"MSTestSdk.*? \(net9\.0\|x64\) passed");
compilationResult.AssertOutputMatchesRegex(@"MSTestSdk.*? \(net10\.0\|x64\) passed");
#if !SKIP_INTERMEDIATE_TARGET_FRAMEWORKS
compilationResult.AssertOutputMatchesRegex(@"MSTestSdk.*? \(net9\.0\|x64\) passed");
compilationResult.AssertOutputMatchesRegex(@"MSTestSdk.*? \(net8\.0\|x64\) passed");
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,27 +136,39 @@ private async Task GenerateAndVerifyLanguageSpecificEntryPointAsync(string asset
await DotnetCli.RunAsync($"restore -r {RID} {testAsset.TargetAssetPath}{Path.DirectorySeparatorChar}MSBuildTests.{languageFileExtension}proj", AcceptanceFixture.NuGetGlobalPackagesFolder.Path, cancellationToken: TestContext.CancellationToken);
DotnetMuxerResult buildResult = await DotnetCli.RunAsync($"{(verb == Verb.publish ? $"publish -f {tfm}" : "build")} -c {compilationMode} -r {RID} -nodeReuse:false {testAsset.TargetAssetPath} -v:n", AcceptanceFixture.NuGetGlobalPackagesFolder.Path, cancellationToken: TestContext.CancellationToken);
SL.Build binLog = SL.Serialization.Read(buildResult.BinlogPath!);
SL.Target generateTestingPlatformEntryPoint = binLog.FindChildrenRecursive<SL.Target>().Single(t => t.Name == "_GenerateTestingPlatformEntryPoint");
SL.Task testingPlatformEntryPoint = generateTestingPlatformEntryPoint.FindChildrenRecursive<SL.Task>().Single(t => t.Name == "TestingPlatformEntryPointTask");
SL.Message generatedSource = testingPlatformEntryPoint.FindChildrenRecursive<SL.Message>().Single(m => m.Text.Contains("Entrypoint source:"));
Assert.AreEqual(expectedEntryPoint.ReplaceLineEndings(), generatedSource.Text.ReplaceLineEndings());
SL.Target[] generateTestingPlatformEntryPointTargets = binLog.FindChildrenRecursive<SL.Target>().Where(t => t.Name == "_GenerateTestingPlatformEntryPoint").ToArray();
Assert.HasCount(1, generateTestingPlatformEntryPointTargets, "Expected exactly one _GenerateTestingPlatformEntryPoint target");
SL.Task[] testingPlatformEntryPointTasks = generateTestingPlatformEntryPointTargets[0].FindChildrenRecursive<SL.Task>().Where(t => t.Name == "TestingPlatformEntryPointTask").ToArray();
Assert.HasCount(1, testingPlatformEntryPointTasks, "Expected exactly one TestingPlatformEntryPointTask task");
SL.Message[] generatedSourceMessages = testingPlatformEntryPointTasks[0].FindChildrenRecursive<SL.Message>().Where(m => m.Text.Contains("Entrypoint source:")).ToArray();
Assert.HasCount(1, generatedSourceMessages, "Expected exactly one message containing 'Entrypoint source:'");
Assert.AreEqual(expectedEntryPoint.ReplaceLineEndings(), generatedSourceMessages[0].Text.ReplaceLineEndings());

var testHost = TestInfrastructure.TestHost.LocateFrom(testAsset.TargetAssetPath, AssetName, tfm, rid: RID, verb: verb, buildConfiguration: compilationMode);
TestHostResult testHostResult = await testHost.ExecuteAsync(cancellationToken: TestContext.CancellationToken);
testHostResult.AssertExitCodeIs(ExitCodes.Success);
Assert.Contains("Passed!", testHostResult.StandardOutput);

SL.Target coreCompile = binLog.FindChildrenRecursive<SL.Target>().Single(t => t.Name == "CoreCompile" && t.Children.Count > 0);
SL.Task csc = coreCompile.FindChildrenRecursive<SL.Task>(t => t.Name == cscProcessName).Single();
SL.Parameter sources = csc.FindChildrenRecursive<SL.Parameter>(t => t.Name == "Sources").Single();
SL.Target[] coreCompileTargets = binLog.FindChildrenRecursive<SL.Target>().Where(t => t.Name == "CoreCompile" && t.Children.Count > 0).ToArray();
Assert.HasCount(1, coreCompileTargets, "Expected exactly one CoreCompile target with children");
SL.Target coreCompile = coreCompileTargets[0];
SL.Task[] cscTasks = coreCompile.FindChildrenRecursive<SL.Task>(t => t.Name == cscProcessName).ToArray();
Assert.HasCount(1, cscTasks, $"Expected exactly one {cscProcessName} task");
SL.Task csc = cscTasks[0];
SL.Parameter[] sourcesParameters = csc.FindChildrenRecursive<SL.Parameter>(t => t.Name == "Sources").ToArray();
Assert.HasCount(1, sourcesParameters, "Expected exactly one Sources parameter");
SL.Parameter sources = sourcesParameters[0];
string? sourceFilePathInObj = sources.FindChildrenRecursive<SL.Item>(i => i.Text.EndsWith($"MicrosoftTestingPlatformEntryPoint.{languageFileExtension}", StringComparison.OrdinalIgnoreCase)).SingleOrDefault()?.Text;
Assert.IsNotNull(sourceFilePathInObj);

File.Delete(buildResult.BinlogPath!);
buildResult = await DotnetCli.RunAsync($"{(verb == Verb.publish ? $"publish -f {tfm}" : "build")} -c {compilationMode} -r {RID} -nodeReuse:false {testAsset.TargetAssetPath} -v:n", AcceptanceFixture.NuGetGlobalPackagesFolder.Path, cancellationToken: TestContext.CancellationToken);
binLog = SL.Serialization.Read(buildResult.BinlogPath!);
generateTestingPlatformEntryPoint = binLog.FindChildrenRecursive<SL.Target>(t => t.Name == "_GenerateTestingPlatformEntryPoint" && t.Children.Count > 0).Single();
Assert.IsNotNull(generateTestingPlatformEntryPoint.FindChildrenRecursive<SL.Message>(m => m.Text.Contains("Skipping target \"_GenerateTestingPlatformEntryPoint\" because all output files are up-to-date with respect to the input files.", StringComparison.OrdinalIgnoreCase)).Single());
generateTestingPlatformEntryPointTargets = binLog.FindChildrenRecursive<SL.Target>().Where(t => t.Name == "_GenerateTestingPlatformEntryPoint" && t.Children.Count > 0).ToArray();
Assert.HasCount(1, generateTestingPlatformEntryPointTargets, "Expected exactly one _GenerateTestingPlatformEntryPoint target with children on rebuild");
SL.Message[] skipMessages = generateTestingPlatformEntryPointTargets[0].FindChildrenRecursive<SL.Message>().Where(m => m.Text.Contains("Skipping target \"_GenerateTestingPlatformEntryPoint\" because all output files are up-to-date with respect to the input files.", StringComparison.OrdinalIgnoreCase)).ToArray();
Assert.HasCount(1, skipMessages, "Expected exactly one skip message for up-to-date check");
Assert.IsNotNull(skipMessages[0]);

testHost = TestInfrastructure.TestHost.LocateFrom(testAsset.TargetAssetPath, AssetName, tfm, rid: RID, verb: verb, buildConfiguration: compilationMode);
testHostResult = await testHost.ExecuteAsync(cancellationToken: TestContext.CancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ await DotnetCli.RunAsync(
failIfReturnValueIsNotZero: false,
cancellationToken: TestContext.CancellationToken);

string outputFileLog = Directory.GetFiles(testAsset.TargetAssetPath, "MSBuild Tests_net9.0_x86.log", SearchOption.AllDirectories).Single();
Assert.IsTrue(File.Exists(outputFileLog), $"Expected file '{outputFileLog}'");
string logFileContent = File.ReadAllText(outputFileLog);
string[] outputLogFiles = Directory.GetFiles(testAsset.TargetAssetPath, $"MSBuild Tests_{TargetFrameworks.NetCurrent}_x86.log", SearchOption.AllDirectories);
Assert.ContainsSingle(outputLogFiles, $"Was expecting to find a single log file but found {outputLogFiles.Length}");
string logFileContent = File.ReadAllText(outputLogFiles[0]);
Assert.IsTrue(Regex.IsMatch(logFileContent, ".*win-x86.*"), logFileContent);

// This is the architecture part that's written by TerminalOutputDevice when there is no banner specified.
Expand Down Expand Up @@ -237,9 +237,9 @@ await DotnetCli.RunAsync(
failIfReturnValueIsNotZero: false,
cancellationToken: TestContext.CancellationToken);

string outputFileLog = Directory.GetFiles(testAsset.TargetAssetPath, "MSBuild Tests_net9.0_x64.log", SearchOption.AllDirectories).Single();
Assert.IsTrue(File.Exists(outputFileLog), $"Expected file '{outputFileLog}'");
string logFileContent = File.ReadAllText(outputFileLog);
string[] outputLogFiles = Directory.GetFiles(testAsset.TargetAssetPath, $"MSBuild Tests_{TargetFrameworks.NetCurrent}_x64.log", SearchOption.AllDirectories);
Assert.ContainsSingle(outputLogFiles, $"Was expecting to find a single log file but found {outputLogFiles.Length}");
string logFileContent = File.ReadAllText(outputLogFiles[0]);
// This is the architecture part that's written by TerminalOutputDevice when there is no banner specified.
Assert.Contains($"[win-x64 - {TargetFrameworks.NetCurrent}]", logFileContent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ public static class TargetFrameworks
{
public static string[] Net { get; } =
[
"net9.0",
"net10.0",
#if !SKIP_INTERMEDIATE_TARGET_FRAMEWORKS
"net9.0",
"net8.0",
#endif
];
Expand Down