Skip to content

Commit

Permalink
Fix .NET Framework test helix submission (#44481)
Browse files Browse the repository at this point in the history
  • Loading branch information
ViktorHofer authored Oct 29, 2024
1 parent 1b67c37 commit 3b653cc
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public CompatibleFrameworkInPackageValidatorIntegrationTests(ITestOutputHelper l
return (log, validator);
}

[Fact]
[RequiresMSBuildVersionFact("17.12", Reason = "Needs System.Text.Json 8.0.5")]
public void CompatibleFrameworksInPackage()
{
string name = Path.GetFileNameWithoutExtension(Path.GetTempFileName());
Expand Down Expand Up @@ -67,7 +67,7 @@ public void test(string test) { }
Assert.Contains($"CP0002 Member 'void PackageValidationTests.First.test(string)' exists on lib/netstandard2.0/{assemblyName} but not on lib/{ToolsetInfo.CurrentTargetFramework}/{assemblyName}", log.errors);
}

[Fact]
[RequiresMSBuildVersionFact("17.12", Reason = "Needs System.Text.Json 8.0.5")]
public void MultipleCompatibleFrameworksInPackage()
{
string name = Path.GetFileNameWithoutExtension(Path.GetTempFileName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void ValidatePackageTargetWithIncorrectBaselinePackagePath()
Assert.Equal(0, result.ExitCode);
}

[RequiresMSBuildVersionFact("17.0.0.32901")]
[RequiresMSBuildVersionFact("17.12", Reason = "Needs System.Text.Json 8.0.5")]
public void ValidatePackageWithReferences()
{
string testDependencySource = @"namespace PackageValidationTests { public class ItermediateBaseClass
Expand Down Expand Up @@ -184,7 +184,7 @@ public void ValidatePackageWithReferences()
Assert.Contains($"CP0008 Type 'PackageValidationTests.First' does not implement interface 'PackageValidationTests.IBaseInterface' on lib/{ToolsetInfo.CurrentTargetFramework}/{asset.TestProject.Name}.dll but it does on lib/netstandard2.0/{asset.TestProject.Name}.dll", log.errors);
}

[RequiresMSBuildVersionTheory("17.0.0.32901")]
[RequiresMSBuildVersionTheory("17.12")]
[InlineData(false, true, false)]
[InlineData(false, false, false)]
[InlineData(true, false, false)]
Expand Down Expand Up @@ -224,7 +224,7 @@ public void ValidateOnlyErrorWhenAReferenceIsRequired(bool createDependencyToDum
Assert.DoesNotContain($"CP1002 Could not find matching assembly: '{testDummyDependency.Name}.dll' in any of the search directories.", log.errors);
}

[RequiresMSBuildVersionTheory("17.0.0.32901")]
[RequiresMSBuildVersionTheory("17.12")]
[InlineData(false, true, false, false)]
[InlineData(true, false, false, false)]
[InlineData(true, true, true, true)]
Expand Down Expand Up @@ -270,7 +270,7 @@ namespace PackageValidationTests { public class MyForwardedType : ISomeInterface
Assert.Contains($"CP1002 Could not find matching assembly: '{dependency.Name}.dll' in any of the search directories.", log.errors);
}

[RequiresMSBuildVersionFact("17.0.0.32901")]
[RequiresMSBuildVersionFact("17.12", Reason = "Needs System.Text.Json 8.0.5")]
public void EnsureOnlyOneAssemblyLoadErrorIsLoggedPerMissingAssembly()
{
string dependencySourceCode = @"namespace PackageValidationTests { public interface ISomeInterface { }
Expand Down Expand Up @@ -310,7 +310,7 @@ namespace PackageValidationTests { public class MyForwardedType : ISomeInterface
Assert.Single(log.errors, e => e.Contains("CP1002"));
}

[RequiresMSBuildVersionTheory("17.0.0.32901")]
[RequiresMSBuildVersionTheory("17.12")]
[InlineData(true)]
[InlineData(false)]
public void ValidateMissingReferencesIsOnlyLoggedWhenRunningWithReferences(bool useReferences)
Expand Down
67 changes: 34 additions & 33 deletions test/UnitTests.proj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.DotNet.Helix.Sdk">
<Project Sdk="Microsoft.DotNet.Helix.Sdk">

<PropertyGroup>
<HelixType>test/product/</HelixType>
Expand All @@ -12,44 +12,45 @@
</PropertyGroup>

<ItemGroup>
<SDKCustomXUnitProject Condition="'$(RunAoTTests)' != 'true'" Include="**\*.Tests.csproj" Exclude="**\*.AoT.Tests.csproj;TestAssets\**\*.Tests.csproj" />
<SDKCustomXUnitProject Include="**\*.Tests.csproj" Exclude="**\*.AoT.Tests.csproj;TestAssets\**\*.Tests.csproj" />

<!--containers tests end with UnitTests and IntegrationTests, therefore included manually -->
<SDKCustomXUnitProject Condition="'$(RunAoTTests)' != 'true'" Include="containerize.UnitTests\containerize.UnitTests.csproj" />
<SDKCustomXUnitProject Condition="'$(RunAoTTests)' != 'true' And $(_AGENTOSNAME) != 'Windows_NT_FullFramework'" Include="Microsoft.NET.Build.Containers.IntegrationTests\Microsoft.NET.Build.Containers.IntegrationTests.csproj" />
<!-- on Windows_NT_FullFramework leg, net472 tests should be run -->
<SDKCustomXUnitProject Condition="'$(RunAoTTests)' != 'true' And $(_AGENTOSNAME) == 'Windows_NT_FullFramework'" Include="Microsoft.NET.Build.Containers.IntegrationTests\Microsoft.NET.Build.Containers.IntegrationTests.csproj">
<TargetFramework>net472</TargetFramework>
<RuntimeTargetFramework>net472</RuntimeTargetFramework>
</SDKCustomXUnitProject>
<SDKCustomXUnitProject Condition="'$(RunAoTTests)' != 'true'" Include="Microsoft.NET.Build.Containers.UnitTests\Microsoft.NET.Build.Containers.UnitTests.csproj" />
<SDKCustomXUnitProject Condition="'$(RunAoTTests)' != 'true'" Include="..\src\Tasks\Microsoft.NET.Build.Extensions.Tasks.UnitTests\Microsoft.NET.Build.Extensions.Tasks.UnitTests.csproj">
<ExcludeAdditionalParameters>true</ExcludeAdditionalParameters>
</SDKCustomXUnitProject>
<SDKCustomXUnitProject Condition="'$(RunAoTTests)' != 'true'" Include="..\src\Tasks\Microsoft.NET.Build.Tasks.UnitTests\Microsoft.NET.Build.Tasks.UnitTests.csproj">
<ExcludeAdditionalParameters>true</ExcludeAdditionalParameters>
</SDKCustomXUnitProject>
<SDKCustomXUnitProject Condition="'$(RunAoTTests)' == 'true'" Include="**\*.AoT.Tests.csproj" />
<SDKCustomXUnitProject Condition="'$(RunAoTTests)' != 'true' And $(_AGENTOSNAME) == 'Windows_NT_FullFramework'" Include="Microsoft.DotNet.MSBuildSdkResolver.Tests\Microsoft.DotNet.MSBuildSdkResolver.Tests.csproj">
<TargetFramework>net472</TargetFramework>
<RuntimeTargetFramework>net472</RuntimeTargetFramework>
</SDKCustomXUnitProject>
<SDKCustomXUnitProject Condition="'$(RunAoTTests)' != 'true' And $(_AGENTOSNAME) == 'Windows_NT_FullFramework'" Include="Microsoft.DotNet.ApiCompat.IntegrationTests\Microsoft.DotNet.ApiCompat.IntegrationTests.csproj">
<TargetFramework>net472</TargetFramework>
<RuntimeTargetFramework>net472</RuntimeTargetFramework>
</SDKCustomXUnitProject>
<SDKCustomXUnitProject Condition="'$(RunAoTTests)' != 'true' And $(_AGENTOSNAME) == 'Windows_NT_FullFramework'" Include="Microsoft.DotNet.PackageValidation.Tests\Microsoft.DotNet.PackageValidation.Tests.csproj">
<TargetFramework>net472</TargetFramework>
<RuntimeTargetFramework>net472</RuntimeTargetFramework>
</SDKCustomXUnitProject>
<SDKCustomXUnitProject Condition="'$(RunAoTTests)' != 'true' And $(_AGENTOSNAME) == 'Windows_NT_FullFramework'" Include="Microsoft.NET.Sdk.Publish.Tasks.Tests\Microsoft.NET.Sdk.Publish.Tasks.Tests.csproj">
<TargetFramework>net472</TargetFramework>
<RuntimeTargetFramework>net472</RuntimeTargetFramework>
</SDKCustomXUnitProject>
<SDKCustomXUnitProject Include="containerize.UnitTests\containerize.UnitTests.csproj" />
<SDKCustomXUnitProject Include="Microsoft.NET.Build.Containers.IntegrationTests\Microsoft.NET.Build.Containers.IntegrationTests.csproj" />

<SDKCustomXUnitProject Include="Microsoft.NET.Build.Containers.UnitTests\Microsoft.NET.Build.Containers.UnitTests.csproj" />
<SDKCustomXUnitProject Include="..\src\Tasks\Microsoft.NET.Build.Extensions.Tasks.UnitTests\Microsoft.NET.Build.Extensions.Tasks.UnitTests.csproj" ExcludeAdditionalParameters="true" />
<SDKCustomXUnitProject Include="..\src\Tasks\Microsoft.NET.Build.Tasks.UnitTests\Microsoft.NET.Build.Tasks.UnitTests.csproj" ExcludeAdditionalParameters="true" />

<!-- Don't run MSI installation tests in Helix / CI -->
<SdkCustomXUnitProject Remove="dotnet-MsiInstallation.Tests\**\*" />
</ItemGroup>

<!-- When TestFullMSBuild=true, include the .NET Framework tests. .NETCoreApp tests are also executed
as that validates running tests with desktop msbuild. -->
<ItemGroup Condition="'$(TestFullMSBuild)' == 'true'">
<SDKCustomXUnitProject Include="
core-sdk-tasks.Tests\core-sdk-tasks.Tests.csproj;
Microsoft.DotNet.ApiCompat.IntegrationTests\Microsoft.DotNet.ApiCompat.IntegrationTests.csproj;
Microsoft.DotNet.ApiCompat.Tests\Microsoft.DotNet.ApiCompat.Tests.csproj;
Microsoft.DotNet.ApiCompatibility.Tests\Microsoft.DotNet.ApiCompatibility.Tests.csproj;
Microsoft.DotNet.ApiSymbolExtensions.Tests\Microsoft.DotNet.ApiSymbolExtensions.Tests.csproj;
Microsoft.DotNet.MSBuildSdkResolver.Tests\Microsoft.DotNet.MSBuildSdkResolver.Tests.csproj;
Microsoft.DotNet.PackageValidation.Tests\Microsoft.DotNet.PackageValidation.Tests.csproj;
Microsoft.DotNet.TemplateLocator.Tests\Microsoft.DotNet.TemplateLocator.Tests.csproj;
Microsoft.NET.Build.Containers.IntegrationTests\Microsoft.NET.Build.Containers.IntegrationTests.csproj;
Microsoft.NET.Sdk.Publish.Tasks.Tests\Microsoft.NET.Sdk.Publish.Tasks.Tests.csproj;
Microsoft.NET.Sdk.WorkloadManifestReader.Tests\Microsoft.NET.Sdk.WorkloadManifestReader.Tests.csproj;
Microsoft.Win32.Msi.Tests\Microsoft.Win32.Msi.Tests.csproj"
TargetFramework="net472"
RuntimeTargetFramework="net472" />
</ItemGroup>

<ItemGroup Condition="'$(RunAoTTests)' == 'true'">
<SDKCustomXUnitProject Remove="@(SDKCustomXUnitProject)" />
<SDKCustomXUnitProject Include="**\*.AoT.Tests.csproj" />
</ItemGroup>

<ItemGroup Condition=" '$(CustomHelixTargetQueue)' != '' ">
<HelixTargetQueue Include="$(CustomHelixTargetQueue)" />
</ItemGroup>
Expand Down

0 comments on commit 3b653cc

Please sign in to comment.