[automated] Merge branch 'release/7.0.3xx' => 'main' (#15553)

This commit is contained in:
v-wuzhai 2023-02-16 15:04:57 +08:00 committed by GitHub
commit dcbb0bffd2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 93 additions and 12 deletions

View file

@ -2,6 +2,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
@ -242,6 +243,47 @@ namespace EndToEnd.Tests
}
}
[Theory]
// microsoft.dotnet.common.itemtemplates templates
[InlineData("class")]
[InlineData("struct")]
[InlineData("enum")]
[InlineData("record")]
[InlineData("interface")]
[InlineData("class", "C#")]
[InlineData("class", "VB")]
[InlineData("struct", "VB")]
[InlineData("enum", "VB")]
[InlineData("interface", "VB")]
public void ItCanCreateItemTemplateWithProjectRestriction(string templateName, string language = "")
{
var languageExtensionMap = new Dictionary<string, string>()
{
{ "", ".cs" },
{ "C#", ".cs" },
{ "VB", ".vb" }
};
DirectoryInfo directory = InstantiateProjectTemplate("classlib", language, withNoRestore: false);
string projectDirectory = directory.FullName;
string expectedItemName = $"TestItem_{templateName}";
string newArgs = $"{templateName} --name {expectedItemName} --debug:ephemeral-hive";
if (!string.IsNullOrWhiteSpace(language))
{
newArgs += $" --language {language}";
}
new NewCommandShim()
.WithWorkingDirectory(projectDirectory)
.Execute(newArgs)
.Should().Pass();
//check if the template created files
Assert.True(directory.Exists);
Assert.True(directory.EnumerateFileSystemInfos().Any());
Assert.True(directory.GetFile($"{expectedItemName}.{languageExtensionMap[language]}") != null);
}
[WindowsOnlyTheory]
[InlineData("wpf")]
[InlineData("winforms")]
@ -396,20 +438,9 @@ namespace EndToEnd.Tests
private static void TestTemplateCreateAndBuild(string templateName, bool build = true, bool selfContained = false, string language = "", string framework = "", bool deleteTestDirectory = false)
{
DirectoryInfo directory = TestAssets.CreateTestDirectory(identifier: string.IsNullOrWhiteSpace(language) ? templateName : $"{templateName}[{language}]");
DirectoryInfo directory = InstantiateProjectTemplate(templateName, language);
string projectDirectory = directory.FullName;
string newArgs = $"{templateName} --no-restore";
if (!string.IsNullOrWhiteSpace(language))
{
newArgs += $" --language {language}";
}
new NewCommandShim()
.WithWorkingDirectory(projectDirectory)
.Execute(newArgs)
.Should().Pass();
if (!string.IsNullOrWhiteSpace(framework))
{
//check if MSBuild TargetFramework property for *proj is set to expected framework
@ -454,5 +485,27 @@ namespace EndToEnd.Tests
directory.Delete(true);
}
}
private static DirectoryInfo InstantiateProjectTemplate(string templateName, string language = "", bool withNoRestore = true)
{
DirectoryInfo directory = TestAssets.CreateTestDirectory(
identifier: string.IsNullOrWhiteSpace(language)
? templateName
: $"{templateName}[{language}]");
string projectDirectory = directory.FullName;
string newArgs = $"{templateName} --debug:ephemeral-hive {(withNoRestore ? "--no-restore" : "")}";
if (!string.IsNullOrWhiteSpace(language))
{
newArgs += $" --language {language}";
}
new NewCommandShim()
.WithWorkingDirectory(projectDirectory)
.Execute(newArgs)
.Should().Pass();
return directory;
}
}
}

View file

@ -226,6 +226,11 @@
<TestArgs>$(TestArgs) -testConfigFile "$(MSBuildThisFileDirectory)TestsToSkipPortableLinux.xml"</TestArgs>
</PropertyGroup>
<PropertyGroup Condition=" $([MSBuild]::IsOSPlatform('OSX')) ">
<!-- Add list of tests to skip on Linux Portable -->
<TestArgs>$(TestArgs) -testConfigFile "$(MSBuildThisFileDirectory)TestsToSkipOSX.xml"</TestArgs>
</PropertyGroup>
<Exec Command="$(ToolRunPrefix)$(RedistLayoutPath)dotnet tool run $(ToolCommandName) -- $(TestArgs)"
WorkingDirectory="$(TestLocalToolFolder)"
EnvironmentVariables="DOTNET_CLI_HOME=$(DOTNET_CLI_HOME)"/>

View file

@ -0,0 +1,23 @@
<Tests>
<SkippedTests>
<Method Name="Microsoft.NET.Publish.Tests.GivenThatWeWantToPublishAHelloWorldProject.It_publishes_self_contained_apps_to_the_publish_folder_and_the_app_should_run"
Skip="true"
Reason="SupportsTargetFramework crashes on Mac, probably fixed with https://github.com/dotnet/sdk/pull/29083"/>
<Method Name="Microsoft.NET.Publish.Tests.GivenThatWeWantToPublishAFrameworkDependentApp.It_publishes_with_or_without_apphost"
Skip="true"
Reason="Test assumes test process architecture is the same as architecture under test"/>
<Method Name="Microsoft.NET.Build.Tests.GivenThatWeWantToBuildANetCoreApp.It_runs_a_rid_specific_app_with_conflicts_from_the_output_folder"
Skip="true"
Reason="Test assumes test process architecture is the same as architecture under test"/>
<Method Name="Microsoft.NET.Build.Tests.GivenThatWeWantToBuildANetCoreApp.It_runs_a_rid_specific_app_from_the_output_folder"
Skip="true"
Reason="Test assumes test process architecture is the same as architecture under test"/>
<Method Name="Microsoft.NET.Build.Tests.AppHostTests.It_builds_a_runnable_apphost_by_default"
Skip="true"
Reason="Test assumes test process architecture is the same as architecture under test"/>
</SkippedTests>
</Tests>