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

Extend RunTests target condition to also check that there are no tests to run #14665

Merged
merged 1 commit into from
Mar 29, 2024

Conversation

carlossanlop
Copy link
Member

In the dotnet/maintenance-packages repo, the CI is failing unexpectedly attempting to execute .NET Framework unit tests in Unix, even though we properly set the SkipTests property to true. This is happening when using dotnet build -t:test. The error output looks like this:

/home/carlos/.nuget/packages/microsoft.dotnet.arcade.sdk/8.0.0-beta.24165.4/tools/VSTest.targets(46,5): error MSB3073: The command "echo === COMMAND LINE === >  [/home/carlos/maintenance-packages/src/System.Runtime.CompilerServices.Unsafe/tests/System.Runtime.CompilerServices.Unsafe.Tests.csproj]
/home/carlos/.nuget/packages/microsoft.dotnet.arcade.sdk/8.0.0-beta.24165.4/tools/VSTest.targets(46,5): error MSB3073:                    echo "/home/carlos/maintenance-packages/.dotnet/dotnet" test  --logger:"console;verbosity=normal" --logger:"trx;LogFileName=" --logger:"html;LogFileName=" "--ResultsDirectory:" "--Framework:,Version=" >> "" 2>&1 >> " exited with code 2. [/home/carlos/maintenance-packages/src/System.Runtime.CompilerServices.Unsafe/tests/System.Runtime.CompilerServices.Unsafe.Tests.csproj]

The unexpected error output comes from inside the RunTests targets, which depends on the TestToRun items that are being used in the Outputs attribute. They come all the way from the _InnerGetTestsToRun target which does not get evaluated because it also depends on SkipTests not being true.

By adding the extra condition to the RunTests target to execute when SkipTests is not true and the TestToRun item group is not empty, we prevent that error.

While this gets fixed, we will be using a workaround in Directory.Build.targets in maintenance-packages to achieve a similar result:

  <Target Name="_SetSkipTests" AfterTargets="_OuterGetTestsToRun">

    <PropertyGroup>
      <SkipTests Condition="'@(TestToRun)' == ''">true</SkipTests>
    </PropertyGroup>

  </Target>

@carlossanlop carlossanlop added the area-Infrastructure-libraries Area maintained by .NET libraries team: APICompat, AsmDiff, GenAPI, GenFacades, PkgProj, etc label Mar 28, 2024
@carlossanlop carlossanlop self-assigned this Mar 28, 2024
@carlossanlop carlossanlop merged commit 4345e14 into dotnet:main Mar 29, 2024
11 checks passed
@carlossanlop carlossanlop deleted the FixRunTestsCondition branch March 29, 2024 06:05
@ericstj
Copy link
Member

ericstj commented Mar 29, 2024

/backport to release/8.0

Copy link
Contributor

Started backporting to release/8.0: https://github.com/dotnet/arcade/actions/runs/8482496630

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Infrastructure-libraries Area maintained by .NET libraries team: APICompat, AsmDiff, GenAPI, GenFacades, PkgProj, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants