docs/workflow/ci/disabling-tests.md
This document describes how to disable a test from running in the continuous integration (CI) test system.
Tests are either disabled permanently or temporarily:
There are two main sets of tests in the repo: runtime tests in the src/tests tree, and libraries tests which are spread amongst the libraries in the src/libraries tree. (There are also PAL tests in src/coreclr/pal/tests, which are ignored here.)
The two types have similar mechanisms for disabling, but the runtime tests have more options given how they build and execute.
You need to determine under which configuration you wish to disable the test:
Generally, you should disable a test under the most specific condition that is causing the test failure. Thus, if the test only fails on arm64, don't disable it for all architectures. If the test only fails on macOS, don't disable it for Windows or Linux.
If it is unclear the full set configurations where the test is failing, it is sometimes necessary and expedient to disable the test more broadly than possibly required.
The runtime tests use an XUnit-based model for test execution. There are a number of attributes provided for filtering based on different test modes. Here are some examples of attributes that can be applied to tests to prevent them from running in certain configurations:
[SkipOnMono][SkipOnCoreClr][ConditionalFact("", typeof(TestLibrary.Utilities), nameof(Utilities.IsNotNativeAot))] instead of [Fact][SkipOnCoreClr("Reason", RuntimeTestModes.AnyGCStress)][SkipOnCoreClr("Reason", RuntimeTestModes.HeapVerify)][SkipOnCoreClr("Reason", RuntimeTestModes.AnyJitStress)]Additionally, the ConditionalFact, ConditionalTheory, PlatformSpecific, and ActiveIssue attributes are available for usage to disable or enable tests only on specific platforms or configurations.
Some test modes are processed at the assembly level. For these tests, you should mark the tests as <RequiresProcessIsolation>true</RequiresProcessIsolation> and set one of the attributes in the following section.
Generally, tests should be diabled via xunit attributes unless it is not possible to do so. There are a few scenarios where this might occur, all in cases where the test project is marked with <RequiresProcessIsolation>true</RequiresProcessIsolation>:
Main method and not use the XUnitWrapperGenerator. In this case, the XUnit attributes will not apply.<RequiresProcessIsolation>true</RequiresProcessIsolation> for another reason. In this case, there is no generator.In this case, the test should be disabled by setting the CLRTestTargetUnsupported property in its project file with a relevant condition and a comment with the issue link or reason.
Some test configurations must be disabled by editing the .csproj or .ilproj file for the test,
and inserting a property in a <PropertyGroup>, as follows:
<UnloadabilityIncompatible>true</UnloadabilityIncompatible><IlasmRoundTripIncompatible>true</IlasmRoundTripIncompatible><MonoAotIncompatible>true</MonoAotIncompatible><CrossGenTest>false</CrossGenTest><NativeAotIncompatible>true</NativeAotIncompatible>When one of the following settings is already required for a given test, the following settings can also be set in the project file instead of via XUnit attributes. They should not be the only reason a test is marked as <RequiresProcessIsolation>true</RequiresProcessIsolation>, however.
<GCStressIncompatible>true</GCStressIncompatible><JitOptimizationSensitive>true</JitOptimizationSensitive><HeapVerifyIncompatible>true</HeapVerifyIncompatible>Note that these properties can be conditional, e.g.:
<GCStressIncompatible Condition="'$(TargetArchitecture)' == 'arm64' and '$(TargetOS)' == 'osx'">true</GCStressIncompatible>
(REVIEW: I'm not clear which conditions are allowed, and respected.)
More information about writing/adding tests to src/tests can be found here.
Information on disabling libraries tests is found here.
In particular, look at ActiveIssueAttribute, SkipOnCoreClrAttribute, and SkipOnMonoAttribute.