Skip to content

Commit bc9f00c

Browse files
authored
Cleanup PlatformSpecific/SkipOnMono attributes that skip a platform (#50907)
We have a bunch of test assemblies that don't make sense on some platforms, e.g. Browser. Right now we're skipping them via `[SkipOnMono("reason", TestPlatforms.Browser)]` but there's nothing that inherently ties this to Mono other than the current implementation. The more generic `SkipOnPlatform` attribute can be used instead. We can also use it in places where we do `[PlatformSpecific(~TestPlatforms....)]` to avoid the double inversion.
1 parent 6902c5a commit bc9f00c

File tree

198 files changed

+372
-348
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

198 files changed

+372
-348
lines changed

docs/workflow/testing/libraries/filtering-tests.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,24 @@ This attribute returns the 'failing' category, which is disabled by default.
6868
```
6969
Use this attribute over test methods to skip failing tests only on the specific platforms and the specific target frameworks.
7070

71+
#### SkipOnPlatformAttribute
72+
This attribute is intended to disable a test permanently on a platform where an API is not available or there is an intentional difference in behavior in between the tested platform and the skipped platform.
73+
74+
This attribute can be applied either to a test assembly/class (will disable all the tests in that assembly/class) or to a test method. It allows multiple usages on the same member.
75+
76+
```cs
77+
[SkipOnPlatform(TestPlatforms platforms, string reason)]
78+
```
79+
80+
Use this attribute over test methods to skip tests only on the specific target platforms. The reason parameter doesn't affect the traits but we rather always use it so that when we see this attribute we know why it is being skipped on that platform.
81+
82+
If it needs to be skipped in multiple platforms and the reasons are different please use two attributes on the same test so that you can specify different reasons for each platform.
83+
84+
When you add the attribute on the whole test assembly it's a good idea to also add `<IgnoreForCI Condition="'$(TargetOS)' == '...'">true</IgnoreForCI>` to the test .csproj.
85+
That allows the CI build to skip sending this test assembly to Helix completely since it'd run zero tests anyway.
86+
87+
**Currently these are the [Test Platforms](https://github.com/dotnet/arcade/blob/master/src/Microsoft.DotNet.XUnitExtensions/src/TestPlatforms.cs) that we support through our test execution infrastructure**
88+
7189
#### SkipOnTargetFrameworkAttribute
7290
This attribute is intended to disable a test permanently on a framework where an API is not available or there is an intentional difference in behavior in between the tested framework and the skipped framework.
7391

@@ -80,7 +98,7 @@ Use this attribute over test methods to skip tests only on the specific target f
8098

8199
If it needs to be skipped in multiple frameworks and the reasons are different please use two attributes on the same test so that you can specify different reasons for each framework.
82100

83-
**Currently this are the [Framework Monikers](https://github.com/dotnet/arcade/blob/master/src/Microsoft.DotNet.XUnitExtensions/src/TargetFrameworkMonikers.cs#L23-L26) that we support through our test execution infrastructure**
101+
**Currently these are the [Framework Monikers](https://github.com/dotnet/arcade/blob/master/src/Microsoft.DotNet.XUnitExtensions/src/TargetFrameworkMonikers.cs#L23-L26) that we support through our test execution infrastructure**
84102

85103
#### ConditionalFactAttribute
86104
Use this attribute to run the test only when a condition is `true`. This attribute is used when `ActiveIssueAttribute` or `SkipOnTargetFrameworkAttribute` are not flexible enough due to needing to run a custom logic at test time. This test behaves as a `[Fact]` test that has no test data passed in as a parameter.

src/libraries/Common/tests/StreamConformanceTests/System/IO/StreamConformanceTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
namespace System.IO.Tests
1919
{
2020
/// <summary>Base class providing tests for any Stream-derived type.</summary>
21-
[PlatformSpecific(~TestPlatforms.Browser)] // lots of operations aren't supported on browser
21+
[SkipOnPlatform(TestPlatforms.Browser, "lots of operations aren't supported on browser")]
2222
public abstract class StreamConformanceTests : FileCleanupTestBase
2323
{
2424
/// <summary>Gets the name of the byte[] argument to Read/Write methods.</summary>

src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/AES/AesCipherTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace System.Security.Cryptography.Encryption.Aes.Tests
1111
{
1212
using Aes = System.Security.Cryptography.Aes;
1313

14-
[SkipOnMono("Not supported on Browser", TestPlatforms.Browser)]
14+
[SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
1515
public partial class AesCipherTests
1616
{
1717
[Fact]

src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/AES/AesContractTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace System.Security.Cryptography.Encryption.Aes.Tests
77
{
88
using Aes = System.Security.Cryptography.Aes;
99

10-
[SkipOnMono("Not supported on Browser", TestPlatforms.Browser)]
10+
[SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
1111
public class AesContractTests
1212
{
1313
[Fact]

src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/AES/AesCornerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace System.Security.Cryptography.Encryption.Aes.Tests
1212
{
1313
using Aes = System.Security.Cryptography.Aes;
1414

15-
[SkipOnMono("Not supported on Browser", TestPlatforms.Browser)]
15+
[SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
1616
public static class AesCornerTests
1717
{
1818
[Fact]

src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/AES/AesModeTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace System.Security.Cryptography.Encryption.Aes.Tests
77
{
88
using Aes = System.Security.Cryptography.Aes;
99

10-
[SkipOnMono("Not supported on Browser", TestPlatforms.Browser)]
10+
[SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
1111
public class AesModeTests
1212
{
1313
[Fact]

src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/AES/DecryptorReusability.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace System.Security.Cryptography.Encryption.Aes.Tests
77
{
88
using Aes = System.Security.Cryptography.Aes;
99

10-
[SkipOnMono("Not supported on Browser", TestPlatforms.Browser)]
10+
[SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
1111
public static class DecryptorReusabilty
1212
{
1313
// See https://github.com/dotnet/runtime/issues/21354 for details

src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DES/DESCipherTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace System.Security.Cryptography.Encryption.Des.Tests
1111
{
12-
[SkipOnMono("Not supported on Browser", TestPlatforms.Browser)]
12+
[SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
1313
public static class DesCipherTests
1414
{
1515
// These are the expected output of many decryptions. Changing these values requires re-generating test input.

src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DES/DESContractTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace System.Security.Cryptography.Encryption.Des.Tests
1111
{
12-
[SkipOnMono("Not supported on Browser", TestPlatforms.Browser)]
12+
[SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
1313
public static class DesContractTests
1414
{
1515
// cfb not available on windows 7

src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/DES/DesTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace System.Security.Cryptography.Encryption.Des.Tests
99
{
10-
[SkipOnMono("Not supported on Browser", TestPlatforms.Browser)]
10+
[SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
1111
public static partial class DesTests
1212
{
1313
private static readonly byte[] KnownWeakKey = "e0e0e0e0f1f1f1f1".HexToByteArray();

0 commit comments

Comments
 (0)