Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void MSBuildLoggerCanBeEnabledByBuildPropertyAndDoesNotEatSpecialChars(Ru
{
SetTestEnvironment(_testEnvironment, runnerInfo);

var projectPath = GetIsolatedTestAsset("TerminalLoggerTestProject.csproj");
var projectPath = GetIsolatedTestAsset("TerminalLoggerTestProject.csproj", runnerInfo.TargetFramework);
// Forcing terminal logger so we can see the output when it is redirected
InvokeDotnetTest($@"{projectPath} -tl:on -nodereuse:false /p:PackageVersion={IntegrationTestEnvironment.LatestLocallyBuiltNugetVersion}", workingDirectory: Path.GetDirectoryName(projectPath));

Expand Down Expand Up @@ -53,7 +53,7 @@ public void MSBuildLoggerCanBeDisabledByBuildProperty(RunnerInfo runnerInfo)
{
SetTestEnvironment(_testEnvironment, runnerInfo);

var projectPath = GetIsolatedTestAsset("TerminalLoggerTestProject.csproj");
var projectPath = GetIsolatedTestAsset("TerminalLoggerTestProject.csproj", runnerInfo.TargetFramework);
InvokeDotnetTest($@"{projectPath} -nodereuse:false /p:VsTestUseMSBuildOutput=false /p:PackageVersion={IntegrationTestEnvironment.LatestLocallyBuiltNugetVersion}", workingDirectory: Path.GetDirectoryName(projectPath));

// Check that we see the summary that is printed from the console logger, meaning the new output is disabled.
Expand All @@ -73,7 +73,7 @@ public void MSBuildLoggerCanBeDisabledByEnvironmentVariableProperty(RunnerInfo r
{
SetTestEnvironment(_testEnvironment, runnerInfo);

var projectPath = GetIsolatedTestAsset("TerminalLoggerTestProject.csproj");
var projectPath = GetIsolatedTestAsset("TerminalLoggerTestProject.csproj", runnerInfo.TargetFramework);
InvokeDotnetTest($@"{projectPath} -nodereuse:false /p:PackageVersion={IntegrationTestEnvironment.LatestLocallyBuiltNugetVersion}", environmentVariables: new Dictionary<string, string?> { ["MSBUILDENSURESTDOUTFORTASKPROCESSES"] = "1" }, workingDirectory: Path.GetDirectoryName(projectPath));

// Check that we see the summary that is printed from the console logger, meaning the new output is disabled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void RunDotnetTestWithCsproj(RunnerInfo runnerInfo)
{
SetTestEnvironment(_testEnvironment, runnerInfo);

var projectPath = GetIsolatedTestAsset("SimpleTestProject.csproj");
var projectPath = GetIsolatedTestAsset("SimpleTestProject.csproj", runnerInfo.TargetFramework);
InvokeDotnetTest($@"{projectPath} -tl:off /p:VSTestNoLogo=false --logger:""Console;Verbosity=normal"" /p:PackageVersion={IntegrationTestEnvironment.LatestLocallyBuiltNugetVersion}", workingDirectory: Path.GetDirectoryName(projectPath));

// ensure our dev version is used
Expand Down Expand Up @@ -60,7 +60,7 @@ public void RunDotnetTestWithCsprojPassInlineSettings(RunnerInfo runnerInfo)
{
SetTestEnvironment(_testEnvironment, runnerInfo);

var projectPath = GetIsolatedTestAsset("ParametrizedTestProject.csproj");
var projectPath = GetIsolatedTestAsset("ParametrizedTestProject.csproj", runnerInfo.TargetFramework);
InvokeDotnetTest($@"{projectPath} --logger:""Console;Verbosity=normal"" -tl:off /p:VSTestNoLogo=false /p:PackageVersion={IntegrationTestEnvironment.LatestLocallyBuiltNugetVersion} -- TestRunParameters.Parameter(name =\""weburl\"", value=\""http://localhost//def\"")", workingDirectory: Path.GetDirectoryName(projectPath));

// ensure our dev version is used
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ public void RunSettingsAreLoadedFromProject(RunnerInfo runnerInfo)
SetTestEnvironment(_testEnvironment, runnerInfo);

var projectName = "ProjectFileRunSettingsTestProject.csproj";
var projectPath = GetIsolatedTestAsset(projectName);
var projectPath = GetIsolatedTestAsset(projectName, runnerInfo.TargetFramework);
InvokeDotnetTest($@"{projectPath} /p:VSTestUseMSBuildOutput=false --logger:""Console;Verbosity=normal"" /p:PackageVersion={IntegrationTestEnvironment.LatestLocallyBuiltNugetVersion}", workingDirectory: Path.GetDirectoryName(projectPath));
ValidateSummaryStatus(0, 1, 0);

Expand Down
10 changes: 9 additions & 1 deletion test/Microsoft.TestPlatform.TestUtilities/AcceptanceTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;

namespace Microsoft.TestPlatform.TestUtilities;

Expand Down Expand Up @@ -137,7 +138,7 @@ public static string GetRunSettingsWithTargetFramework(string targetFramework)
return runSettingsXml;
}

protected string GetIsolatedTestAsset(string assetName)
protected string GetIsolatedTestAsset(string assetName, string targetFramework)
{
var projectPath = GetProjectFullPath(assetName);
Comment thread
nohwnd marked this conversation as resolved.

Expand All @@ -147,6 +148,13 @@ protected string GetIsolatedTestAsset(string assetName)

if (file.Extension.Equals(".csproj", StringComparison.OrdinalIgnoreCase))
{
// Build just for the given tfm
var projFile = Path.Combine(TempDirectory.Path, Path.GetFileName(file.FullName));
var csprojContent = File.ReadAllText(projFile);
csprojContent = Regex.Replace(csprojContent, "<TargetFramework>.*?</TargetFramework>", $"<TargetFramework>{targetFramework}</TargetFramework>");
csprojContent = Regex.Replace(csprojContent, "<TargetFrameworks>.*?</TargetFrameworks>", $"<TargetFramework>{targetFramework}</TargetFramework>");
Comment thread
nohwnd marked this conversation as resolved.
File.WriteAllText(projFile, csprojContent);
Comment thread
nohwnd marked this conversation as resolved.

string root = IntegrationTestEnvironment.RepoRootDirectory;
var testAssetsRoot = Path.GetFullPath(Path.Combine(root, "test", "TestAssets"));

Expand Down