Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply LocalFact and LocalTheory attributes to racy tests (#6012)
* Add LocalTheoryAttribute * Apply LocalFact and LocalTheory attributes to racy tests * Fix XML-Doc warnings * Add LocalTheoryAttribute and WindowsFactAttribute * Convert skipped tests to LocalFact tests * Fix WindowsFactAttribute * Fix specs * Add missing racy fact * skip FlattenMerge * Skip some more racy tests
- Loading branch information
Showing
45 changed files
with
282 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/contrib/testkits/Akka.TestKit.Xunit2/Attributes/LocalTheoryAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// ----------------------------------------------------------------------- | ||
// <copyright file="LocalTheoryAttribute.cs" company="Akka.NET Project"> | ||
// Copyright (C) 2009-2022 Lightbend Inc. <http://www.lightbend.com> | ||
// Copyright (C) 2013-2022 .NET Foundation <https://github.com/akkadotnet/akka.net> | ||
// </copyright> | ||
// ----------------------------------------------------------------------- | ||
|
||
using System; | ||
using Xunit; | ||
using Xunit.Sdk; | ||
|
||
namespace Akka.TestKit.Xunit2.Attributes | ||
{ | ||
/// <summary> | ||
/// <para> | ||
/// This custom XUnit Fact attribute will skip unit tests if the environment variable | ||
/// "XUNIT_SKIP_LOCAL_THEORY" exists and is set to the string "true" | ||
/// </para> | ||
/// <para> | ||
/// Note that the original <see cref="Skip"/> property takes precedence over this attribute, | ||
/// any unit tests with <see cref="LocalTheoryAttribute"/> with its <see cref="Skip"/> property | ||
/// set will always be skipped, regardless of the environment variable content. | ||
/// </para> | ||
/// </summary> | ||
[XunitTestCaseDiscoverer("Xunit.Sdk.TheoryDiscoverer", "xunit.execution.{Platform}")] | ||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] | ||
public class LocalTheoryAttribute : TheoryAttribute | ||
{ | ||
private const string EnvironmentVariableName = "XUNIT_SKIP_LOCAL_THEORY"; | ||
|
||
private string _skip; | ||
|
||
/// <summary> | ||
/// Marks the test so that it will not be run, and gets or sets the skip reason | ||
/// </summary> | ||
public override string Skip | ||
{ | ||
get | ||
{ | ||
if (_skip != null) | ||
return _skip; | ||
|
||
var skipLocal = Environment.GetEnvironmentVariable(EnvironmentVariableName)? | ||
.ToLowerInvariant(); | ||
return skipLocal is "true" ? SkipLocal ?? "Local facts are being skipped" : null; | ||
} | ||
set => _skip = value; | ||
} | ||
|
||
/// <summary> | ||
/// The reason why this unit test is being skipped by the <see cref="LocalTheoryAttribute"/>. | ||
/// Note that the original <see cref="Skip"/> property takes precedence over this message. | ||
/// </summary> | ||
public string SkipLocal { get; set; } | ||
|
||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
src/contrib/testkits/Akka.TestKit.Xunit2/Attributes/WindowsFactAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// ----------------------------------------------------------------------- | ||
// <copyright file="WindowsFactAttribute.cs" company="Akka.NET Project"> | ||
// Copyright (C) 2009-2022 Lightbend Inc. <http://www.lightbend.com> | ||
// Copyright (C) 2013-2022 .NET Foundation <https://github.com/akkadotnet/akka.net> | ||
// </copyright> | ||
// ----------------------------------------------------------------------- | ||
|
||
using System; | ||
using Xunit; | ||
|
||
namespace Akka.TestKit.Xunit2.Attributes | ||
{ | ||
/// <summary> | ||
/// <para> | ||
/// This custom XUnit Fact attribute will skip unit tests if the run-time environment is not windows | ||
/// </para> | ||
/// <para> | ||
/// Note that the original <see cref="Skip"/> property takes precedence over this attribute, | ||
/// any unit tests with <see cref="WindowsFactAttribute"/> with its <see cref="Skip"/> property | ||
/// set will always be skipped, regardless of the environment variable content. | ||
/// </para> | ||
/// </summary> | ||
public class WindowsFactAttribute : FactAttribute | ||
{ | ||
private string _skip; | ||
|
||
/// <summary> | ||
/// Marks the test so that it will not be run, and gets or sets the skip reason | ||
/// </summary> | ||
public override string Skip | ||
{ | ||
get | ||
{ | ||
if (_skip != null) | ||
return _skip; | ||
|
||
var platform = Environment.OSVersion.Platform; | ||
var notWindows = platform == PlatformID.MacOSX | ||
|| platform == PlatformID.Unix | ||
|| platform == PlatformID.Xbox; | ||
return notWindows ? SkipUnix ?? "Skipped under Unix platforms" : null; | ||
} | ||
set => _skip = value; | ||
} | ||
|
||
/// <summary> | ||
/// The reason why this unit test is being skipped by the <see cref="WindowsFactAttribute"/>. | ||
/// Note that the original <see cref="Skip"/> property takes precedence over this message. | ||
/// </summary> | ||
public string SkipUnix { get; set; } | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.