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
5 changes: 2 additions & 3 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,11 @@
/test/TemplateEngine @dotnet/templating-engine-maintainers
/template_feed @dotnet/templating-engine-maintainers

# ILLink and ReadyToRun targets and tasks owned by runtime team
# Area-ILLink Area-ReadyToRun
/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.ILLink.targets @dotnet/illink
/test/Microsoft.NET.Publish.Tests/GivenThatWeWantToRunILLink.cs @dotnet/illink
/test/Microsoft.NET.ILLink.Tests @dotnet/illink
# Publish.targets related to ILLink and ReadyToRun is own by both runtime and SDK team
/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets @dotnet/illink @dotnet/dotnet-cli

# Area-ClickOnce
/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.ClickOnce.targets @sujitnayak

Expand Down
32 changes: 26 additions & 6 deletions documentation/project-docs/pr-test-filtering.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ project(s) (e.g. TemplateEngine tests).

Individual test classes are excluded via `[TestCategory]` attributes and MSTest filter
expressions. The test project still runs on Helix, but specific classes are skipped.
This is useful when expensive tests (e.g. ILLink trimming tests) live in a shared test
assembly alongside cheaper tests. Not yet implemented.
This is useful when expensive tests live in a shared test assembly alongside cheaper
tests. Not yet implemented.

### Method-level filtering (future)

Expand Down Expand Up @@ -174,10 +174,30 @@ also trigger its tests. For example:
`src/Cli/Microsoft.DotNet.Cli.Definitions/**`.
- Shared infrastructure or utility projects that multiple features depend on may need to
appear in multiple scopes' trigger paths.
- Test assets (e.g. `test/TestAssets/TestPackages/`) that a test suite consumes at
runtime should also be included. These are easy to overlook because they are not
referenced via `ProjectReference`, but changes to them can cause test failures just
the same.
- Test assets (e.g. `test/TestAssets/TestProjects/`, `test/TestAssets/TestPackages/`)
that a test suite consumes at runtime should also be included. These are easy to
overlook because they are not referenced via `ProjectReference` — they are looked up
by name at test runtime via `TestAssetsManager.CopyTestAsset("AssetName")`. A change
to a test asset can silently break tests even when no source file in the scope's
`TriggerPaths` has changed.

**How to find them**: search the test files for string literals passed to
`CopyTestAsset`, `GetTestAsset`, or similar helpers. Any asset name found in
`test/TestAssets/TestProjects/` or `test/TestAssets/TestPackages/` that is unique to
(or primarily used by) this test suite should be added as an explicit trigger path
(e.g. `test/TestAssets/TestProjects/MyAsset/**`). For broadly shared assets
used across dozens of unrelated test suites (e.g. `HelloWorld`), use judgment
— whether to include them is a trade-off between trigger precision and the risk
that a shared asset change breaks this suite without activating any other scope
that would otherwise catch the regression.

**Runtime behavior vs. compile-time dependencies**: not all dependencies need to be in
trigger paths. Ask whether a change to that dependency could cause a test to silently
*pass when it should fail*. If yes, it is a runtime behavior dependency and belongs in
`TriggerPaths`. If a change would instead cause a *compilation failure* (e.g. a shared
constants file, a resx, a helper primarily used for test parameterization such as `[DynamicData]`),
it is a compile-time dependency and does not need to be listed — the build will fail
loudly before any tests run, making the gap immediately visible.

Use judgment here. If a feature has complex or far-reaching dependencies that make it
difficult to define a reliable set of trigger paths, it may not be a good candidate for
Expand Down
3 changes: 2 additions & 1 deletion sdk.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,9 @@
<Project Path="test/Microsoft.NET.Build.Containers.IntegrationTests/Microsoft.NET.Build.Containers.IntegrationTests.csproj" />
<Project Path="test/Microsoft.NET.Build.Containers.UnitTests/Microsoft.NET.Build.Containers.UnitTests.csproj" />
<Project Path="test/Microsoft.NET.Build.Tests/Microsoft.NET.Build.Tests.csproj" />
<Project Path="test/Microsoft.NET.Infrastructure.Tests/Microsoft.NET.Infrastructure.Tests.csproj" />
<Project Path="test/Microsoft.NET.Clean.Tests/Microsoft.NET.Clean.Tests.csproj" />
<Project Path="test/Microsoft.NET.ILLink.Tests/Microsoft.NET.ILLink.Tests.csproj" />
<Project Path="test/Microsoft.NET.Infrastructure.Tests/Microsoft.NET.Infrastructure.Tests.csproj" />
<Project Path="test/Microsoft.NET.Pack.Tests/Microsoft.NET.Pack.Tests.csproj" />
<Project Path="test/Microsoft.NET.Publish.Tests/Microsoft.NET.Publish.Tests.csproj" />
<Project Path="test/Microsoft.NET.Rebuild.Tests/Microsoft.NET.Rebuild.Tests.csproj" />
Expand Down
1 change: 1 addition & 0 deletions src/Tasks/Microsoft.NET.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"test\\Microsoft.Extensions.DotNetDeltaApplier.Tests\\Microsoft.Extensions.DotNetDeltaApplier.Tests.csproj",
"test\\Microsoft.NET.Build.Tests\\Microsoft.NET.Build.Tests.csproj",
"test\\Microsoft.NET.Clean.Tests\\Microsoft.NET.Clean.Tests.csproj",
"test\\Microsoft.NET.ILLink.Tests\\Microsoft.NET.ILLink.Tests.csproj",
"test\\Microsoft.NET.Pack.Tests\\Microsoft.NET.Pack.Tests.csproj",
"test\\Microsoft.NET.Publish.Tests\\Microsoft.NET.Publish.Tests.csproj",
"test\\Microsoft.NET.Rebuild.Tests\\Microsoft.NET.Rebuild.Tests.csproj",
Expand Down
12 changes: 12 additions & 0 deletions test/ConditionalTests.props
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@
<RunAlways>CI</RunAlways>
</ConditionalTestScope>

<ConditionalTestScope Include="ILLink">
<Mechanism>project</Mechanism>
<TestProjects>test/Microsoft.NET.ILLink.Tests/Microsoft.NET.ILLink.Tests.csproj</TestProjects>
<TriggerPaths>
src/Tasks/Microsoft.NET.Build.Tasks/**;
test/Microsoft.NET.ILLink.Tests/**;
test/TestAssets/TestProjects/TrimmableNetstandardLibrary/**;
test/TestAssets/TestProjects/TrimmedAppWithReferences/**
</TriggerPaths>
Comment thread
MichaelSimons marked this conversation as resolved.
Resolved
<RunAlways>CI</RunAlways>
</ConditionalTestScope>

<ConditionalTestScope Include="NetAnalyzers">
<Mechanism>project</Mechanism>
<TestProjects>src/Microsoft.CodeAnalysis.NetAnalyzers/tests/**/*.csproj</TestProjects>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
using Microsoft.DotNet.Cli.Utils;
using Microsoft.Extensions.DependencyModel;
using Microsoft.NET.Build.Tasks;
using Microsoft.NET.Publish.Tests;
using Newtonsoft.Json.Linq;
using static Microsoft.NET.ILLink.Tests.ILLinkTestUtils;
using static Microsoft.NET.Publish.Tests.PublishTestUtils;
using static Microsoft.NET.Publish.Tests.ILLinkTestUtils;

namespace Microsoft.NET.Publish.Tests
namespace Microsoft.NET.ILLink.Tests
{
// this test class is split up arbitrarily so Helix can run tests in multiple workitems
[TestClass]
Expand Down Expand Up @@ -184,10 +185,13 @@ public void PublishTrimmed_fails_for_unsupported_target_framework(string targetF
var testAsset = TestAssetsManager.CreateTestProject(testProject, identifier: targetFramework);
var publishCommand = new PublishCommand(testAsset);
var result = publishCommand.Execute($"/p:RuntimeIdentifier={rid}");
if (shouldFail) {
if (shouldFail)
{
result.Should().Fail()
.And.HaveStdOutContaining($"error {Strings.PublishTrimmedRequiresVersion30}");
} else {
}
else
{
result.Should().Pass()
.And.NotHaveStdOutContaining("warning");
}
Expand Down Expand Up @@ -223,13 +227,16 @@ public void IsTrimmable_warns_when_expected_for_not_correctly_multitargeted_libr
var buildCommand = new BuildCommand(testAsset);
var resultAssertion = buildCommand.Execute("/p:CheckEolTargetFramework=false")
.Should().Pass();
if (shouldWarn) {
if (shouldWarn)
{
resultAssertion
// Note: can't check for Strings.IsTrimmableUnsupported because each line of
// the message gets prefixed with a file path by MSBuild.
.And.HaveStdOutContaining($"warning NETSDK1212")
.And.HaveStdOutContaining($"<IsTrimmable Condition=\"$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))\">true</IsTrimmable>");
} else {
}
else
{
resultAssertion.And.NotHaveStdOutContaining($"warning");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
#nullable disable

using Microsoft.NET.Build.Tasks;
using Microsoft.NET.Publish.Tests;
using static Microsoft.NET.ILLink.Tests.ILLinkTestUtils;
using static Microsoft.NET.Publish.Tests.PublishTestUtils;
using static Microsoft.NET.Publish.Tests.ILLinkTestUtils;

namespace Microsoft.NET.Publish.Tests
namespace Microsoft.NET.ILLink.Tests
{
// this test class is split up arbitrarily so Helix can run tests in multiple workitems
[TestClass]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

#nullable disable

using Microsoft.NET.Publish.Tests;
using static Microsoft.NET.ILLink.Tests.ILLinkTestUtils;
using static Microsoft.NET.Publish.Tests.PublishTestUtils;
using static Microsoft.NET.Publish.Tests.ILLinkTestUtils;

namespace Microsoft.NET.Publish.Tests
namespace Microsoft.NET.ILLink.Tests
{
// this test class is split up arbitrarily so Helix can run tests in multiple workitems
[TestClass]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@

#nullable disable

using Microsoft.NET.Publish.Tests;
using Newtonsoft.Json.Linq;
using static Microsoft.NET.ILLink.Tests.ILLinkTestUtils;
using static Microsoft.NET.Publish.Tests.PublishTestUtils;
using static Microsoft.NET.Publish.Tests.ILLinkTestUtils;

namespace Microsoft.NET.Publish.Tests
namespace Microsoft.NET.ILLink.Tests
{
// this test class is split up arbitrarily so Helix can run tests in multiple workitems
[TestClass]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="MSTest.Sdk">

<PropertyGroup>
<EnableDefaultItems>false</EnableDefaultItems>
<OutDirName>Tests\$(MSBuildProjectName)</OutDirName>
<PackageId>testSdkILLink</PackageId>
<TargetFramework>$(SdkTargetFramework)</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Reflection.MetadataLoadContext" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Microsoft.NET.TestFramework.MSTest\Microsoft.NET.TestFramework.MSTest.csproj" />
<ProjectReference Include="..\TelemetryStdOutLogger\TelemetryStdOutLogger.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Include="**\*.cs" Exclude="$(GlobalExclude)" />
<Compile Include="..\Microsoft.NET.Publish.Tests\PublishTestUtils.cs" LinkBase="Shared" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="..\..\src\Tasks\Common\Resources\Strings.resx" LinkBase="Resources" GenerateSource="True" Namespace="Microsoft.NET.Build.Tasks" />
<PackageReference Include="Microsoft.DotNet.XliffTasks" Version="$(MicrosoftDotNetXliffTasksPackageVersion)" PrivateAssets="all" IsImplicitlyDefined="true" />
</ItemGroup>

</Project>
Loading