Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template verifier adoption in CommonTemplateTests #28707

Merged
merged 30 commits into from
Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5530578
Adopt TemplateEngine.Authoring.TemplateVerifier in CommonTestTemplates
JanKrivanek Oct 19, 2022
eeb5585
Convert TopLevelProgramSupport test
JanKrivanek Oct 19, 2022
acabaa3
Covert remaining unit tests in CommonTemplatesTests
JanKrivanek Oct 21, 2022
77e5fde
Udpate dotnet-new.IntegrationTests.csproj to use internal feed package
JanKrivanek Oct 21, 2022
939ee0a
Merge remote-tracking branch 'upstream/main' into template-verifier
JanKrivanek Oct 21, 2022
d360677
Fix version mismatches
JanKrivanek Oct 21, 2022
fdc5cb2
Adjust snapshots build exclusion
JanKrivanek Oct 25, 2022
0924684
Merge remote-tracking branch 'upstream/main' into template-verifier
Nov 8, 2022
3b04a69
Update tests
JanKrivanek Nov 8, 2022
1b7a2dd
Inject test environment
JanKrivanek Nov 8, 2022
c0a3f32
Bugfix
JanKrivanek Nov 8, 2022
b5b7e0b
Fix Verify change in handling newlines
JanKrivanek Nov 9, 2022
be0236d
Consolidate integration tests
JanKrivanek Nov 10, 2022
d5959c2
Consolidate tests further
JanKrivanek Nov 10, 2022
ddd24ab
Add directory separators unixification
JanKrivanek Nov 11, 2022
9909a94
Fix issues in consolidated tests
JanKrivanek Nov 11, 2022
66fbd7a
Build fix
JanKrivanek Nov 11, 2022
ddd9510
Test fix
JanKrivanek Nov 11, 2022
fd264d2
Test fix 2
JanKrivanek Nov 11, 2022
3ff162c
Workaround Verify limitation with .config files
JanKrivanek Nov 11, 2022
7be7c25
Upgrade EmptyFiles
JanKrivanek Nov 21, 2022
23b8c80
Reflect PR comments
JanKrivanek Nov 23, 2022
000c28f
Adjust item test to net8 changes
JanKrivanek Nov 23, 2022
12026d3
Testfix - snapshots update
JanKrivanek Nov 23, 2022
ed7874c
Merge remote-tracking branch 'upstream/main' into template-verifier
JanKrivanek Nov 23, 2022
8854670
Update default TFM to net8.0
JanKrivanek Nov 23, 2022
3ccb7ba
Add and modify test scenarios for net8
JanKrivanek Nov 24, 2022
b2a3c66
Remove net6 templates from test matrix for now, to workaround issues …
JanKrivanek Nov 24, 2022
c5fa669
Update test to reflect 5.0 EOL
JanKrivanek Nov 24, 2022
2b1b74a
Readd net6.0 to test matrix, skipping buggy cases
JanKrivanek Nov 25, 2022
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
1 change: 1 addition & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
<!-- test dependencies -->
<MicrosoftTemplateEngineMocksPackageVersion>$(MicrosoftTemplateEngineAbstractionsPackageVersion)</MicrosoftTemplateEngineMocksPackageVersion>
<MicrosoftTemplateEngineTestHelperPackageVersion>$(MicrosoftTemplateEngineAbstractionsPackageVersion)</MicrosoftTemplateEngineTestHelperPackageVersion>
<MicrosoftTemplateEngineAuthoringTemplateVerifierVersion>$(MicrosoftTemplateEngineAbstractionsPackageVersion)</MicrosoftTemplateEngineAuthoringTemplateVerifierVersion>
</PropertyGroup>
<PropertyGroup>
<!-- Dependencies from https://github.com/Microsoft/visualfsharp -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class Class1
{
FileName = exePath
};
TestContext.Current.AddTestEnvironmentVariables(toolCommandSpec);
TestContext.Current.AddTestEnvironmentVariables(toolCommandSpec.Environment);

ICommand toolCommand = toolCommandSpec.ToCommand().CaptureStdOut();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ private CommandResult GenerateDepsAndRunTool(TestProject toolProject, [CallerMem
FileName = TestContext.Current.ToolsetUnderTest.DotNetHostPath,
Arguments = dotnetArgs
};
TestContext.Current.AddTestEnvironmentVariables(toolCommandSpec);
TestContext.Current.AddTestEnvironmentVariables(toolCommandSpec.Environment);

ICommand toolCommand = toolCommandSpec.ToCommand().CaptureStdOut();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected override SdkCommandSpec CreateCommand(IEnumerable<string> args)
Arguments = args.ToList(),
WorkingDirectory = WorkingDirectory
};
TestContext.Current.AddTestEnvironmentVariables(sdkCommandSpec);
TestContext.Current.AddTestEnvironmentVariables(sdkCommandSpec.Environment);
return sdkCommandSpec;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected override SdkCommandSpec CreateCommand(IEnumerable<string> args)
Arguments = newArgs
};

TestContext.Current.AddTestEnvironmentVariables(ret);
TestContext.Current.AddTestEnvironmentVariables(ret.Environment);

return ret;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected override SdkCommandSpec CreateCommand(IEnumerable<string> args)
Arguments = args.ToList(),
WorkingDirectory = WorkingDirectory,
};
TestContext.Current.AddTestEnvironmentVariables(sdkCommandSpec);
TestContext.Current.AddTestEnvironmentVariables(sdkCommandSpec.Environment);
return sdkCommandSpec;
}
}
Expand Down
15 changes: 8 additions & 7 deletions src/Tests/Microsoft.NET.TestFramework/TestContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Microsoft.DotNet.Cli.Utils;
using Microsoft.NET.TestFramework.Commands;
using System.Globalization;
using System.Collections.Generic;

namespace Microsoft.NET.TestFramework
{
Expand Down Expand Up @@ -51,20 +52,20 @@ public static TestContext Current

public const string LatestRuntimePatchForNetCoreApp2_0 = "2.0.9";

public void AddTestEnvironmentVariables(SdkCommandSpec command)
public void AddTestEnvironmentVariables(IDictionary<string, string> environment)
{
command.Environment["DOTNET_MULTILEVEL_LOOKUP"] = "0";
environment["DOTNET_MULTILEVEL_LOOKUP"] = "0";

// Set NUGET_PACKAGES environment variable to match value from build.ps1
command.Environment["NUGET_PACKAGES"] = NuGetCachePath;
environment["NUGET_PACKAGES"] = NuGetCachePath;

command.Environment["GenerateResourceMSBuildArchitecture"] = "CurrentArchitecture";
command.Environment["GenerateResourceMSBuildRuntime"] = "CurrentRuntime";
environment["GenerateResourceMSBuildArchitecture"] = "CurrentArchitecture";
environment["GenerateResourceMSBuildRuntime"] = "CurrentRuntime";

// Prevent test MSBuild nodes from persisting
command.Environment["MSBUILDDISABLENODEREUSE"] = "1";
environment["MSBUILDDISABLENODEREUSE"] = "1";

ToolsetUnderTest.AddTestEnvironmentVariables(command);
ToolsetUnderTest.AddTestEnvironmentVariables(environment);
}


Expand Down
22 changes: 11 additions & 11 deletions src/Tests/Microsoft.NET.TestFramework/ToolsetInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,29 +154,29 @@ public string GetMicrosoftNETBuildExtensionsPath()
}
}

public void AddTestEnvironmentVariables(SdkCommandSpec command)
public void AddTestEnvironmentVariables(IDictionary<string, string> environment)
{
if (ShouldUseFullFrameworkMSBuild)
{
string sdksPath = Path.Combine(DotNetRoot, "sdk", SdkVersion, "Sdks");

// Use stage 2 MSBuild SDK resolver
command.Environment["MSBUILDADDITIONALSDKRESOLVERSFOLDER"] = SdkResolverPath;
environment["MSBUILDADDITIONALSDKRESOLVERSFOLDER"] = SdkResolverPath;

// Avoid using stage 0 dotnet install dir
command.Environment["DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR"] = "";
environment["DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR"] = "";

// Put stage 2 on the Path (this is how the MSBuild SDK resolver finds dotnet)
command.Environment["Path"] = DotNetRoot + ";" + Environment.GetEnvironmentVariable("Path");
environment["Path"] = DotNetRoot + ";" + Environment.GetEnvironmentVariable("Path");

if (!string.IsNullOrEmpty(MicrosoftNETBuildExtensionsPathOverride))
{
var microsoftNETBuildExtensionsPath = GetMicrosoftNETBuildExtensionsPath();
command.Environment["MicrosoftNETBuildExtensionsTargets"] = Path.Combine(microsoftNETBuildExtensionsPath, "Microsoft.NET.Build.Extensions.targets");
environment["MicrosoftNETBuildExtensionsTargets"] = Path.Combine(microsoftNETBuildExtensionsPath, "Microsoft.NET.Build.Extensions.targets");

if (UsingFullMSBuildWithoutExtensionsTargets())
{
command.Environment["CustomAfterMicrosoftCommonTargets"] = Path.Combine(sdksPath, "Microsoft.NET.Build.Extensions",
environment["CustomAfterMicrosoftCommonTargets"] = Path.Combine(sdksPath, "Microsoft.NET.Build.Extensions",
"msbuildExtensions-ver", "Microsoft.Common.targets", "ImportAfter", "Microsoft.NET.Build.Extensions.targets");
}
}
Expand All @@ -185,21 +185,21 @@ public void AddTestEnvironmentVariables(SdkCommandSpec command)

if (Environment.Is64BitProcess)
{
command.Environment.Add("DOTNET_ROOT", DotNetRoot);
environment.Add("DOTNET_ROOT", DotNetRoot);
}
else
{
command.Environment.Add("DOTNET_ROOT(x86)", DotNetRoot);
environment.Add("DOTNET_ROOT(x86)", DotNetRoot);
}

if (!string.IsNullOrEmpty(CliHomePath))
{
command.Environment.Add("DOTNET_CLI_HOME", CliHomePath);
environment.Add("DOTNET_CLI_HOME", CliHomePath);
}

// We set this environment variable for in-process tests, but we don't want it to flow to out of process tests
// (especially if we're trying to run on full Framework MSBuild)
command.Environment[DotNet.Cli.Utils.Constants.MSBUILD_EXE_PATH] = "";
environment[DotNet.Cli.Utils.Constants.MSBUILD_EXE_PATH] = "";

}

Expand Down Expand Up @@ -236,7 +236,7 @@ private SdkCommandSpec CreateCommand(params string[] args)
ret.Arguments = newArgs;
}

TestContext.Current.AddTestEnvironmentVariables(ret);
TestContext.Current.AddTestEnvironmentVariables(ret.Environment);

return ret;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"version": 1,
"isRoot": true,
"tools": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The template "%TEMPLATE_NAME%" was created successfully.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
root = true

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The template "%TEMPLATE_NAME%" was created successfully.
Loading