Skip to content
This repository was archived by the owner on Jan 11, 2024. It is now read-only.
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ namespace Xunit
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public class ActiveIssueAttribute : Attribute, ITraitAttribute
{
public ActiveIssueAttribute(int issueNumber, PlatformID platforms = PlatformID.Any) { }
public ActiveIssueAttribute(string issue, PlatformID platforms = PlatformID.Any) { }
public ActiveIssueAttribute(int issueNumber, TestPlatforms platforms = TestPlatforms.Any) { }
public ActiveIssueAttribute(string issue, TestPlatforms platforms = TestPlatforms.Any) { }

// TODO #999: Remove PlatformID when all uses have transitioned to TestPlatforms.
public ActiveIssueAttribute(int issueNumber, PlatformID platforms) { }
public ActiveIssueAttribute(string issue, PlatformID platforms) { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ namespace Xunit
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false)]
public class PlatformSpecificAttribute : Attribute, ITraitAttribute
{
public PlatformSpecificAttribute(TestPlatforms platforms) { }

// TODO #999: Remove PlatformID when all uses have transitioned to TestPlatforms.
public PlatformSpecificAttribute(PlatformID platform) { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitA
Debug.Assert(ctorArgs.Count() >= 2);

string issue = ctorArgs.First().ToString();
PlatformID platforms = (PlatformID)ctorArgs.Last();
if ((platforms.HasFlag(PlatformID.FreeBSD) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD"))) ||
(platforms.HasFlag(PlatformID.Linux) && RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) ||
(platforms.HasFlag(PlatformID.NetBSD) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("NETBSD"))) ||
(platforms.HasFlag(PlatformID.OSX) && RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) ||
(platforms.HasFlag(PlatformID.Windows) && RuntimeInformation.IsOSPlatform(OSPlatform.Windows)))
TestPlatforms platforms = (TestPlatforms)ctorArgs.Last();

This comment was marked as spam.

if ((platforms.HasFlag(TestPlatforms.FreeBSD) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD"))) ||
(platforms.HasFlag(TestPlatforms.Linux) && RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) ||
(platforms.HasFlag(TestPlatforms.NetBSD) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("NETBSD"))) ||
(platforms.HasFlag(TestPlatforms.OSX) && RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) ||
(platforms.HasFlag(TestPlatforms.Windows) && RuntimeInformation.IsOSPlatform(OSPlatform.Windows)))
{
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.Failing);
yield return new KeyValuePair<string, string>(XunitConstants.ActiveIssue, issue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ public class PlatformSpecificDiscoverer : ITraitDiscoverer
/// <returns>The trait values.</returns>
public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
{
PlatformID platform = (PlatformID)traitAttribute.GetConstructorArguments().First();
if (!platform.HasFlag(PlatformID.Windows))
TestPlatforms platforms = (TestPlatforms)traitAttribute.GetConstructorArguments().First();

This comment was marked as spam.

if (!platforms.HasFlag(TestPlatforms.Windows))
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonWindowsTest);
if (!platform.HasFlag(PlatformID.Linux))
if (!platforms.HasFlag(TestPlatforms.Linux))
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonLinuxTest);
if (!platform.HasFlag(PlatformID.OSX))
if (!platforms.HasFlag(TestPlatforms.OSX))
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonOSXTest);
if (!platform.HasFlag(PlatformID.FreeBSD))
if (!platforms.HasFlag(TestPlatforms.FreeBSD))
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonFreeBSDTest);
if (!platform.HasFlag(PlatformID.NetBSD))
if (!platforms.HasFlag(TestPlatforms.NetBSD))
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNetBSDTest);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/xunit.netcore.extensions/PlatformID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Xunit
{
// TODO #999: Remove PlatformID when all uses have transitioned to TestPlatforms.
[Flags]
public enum PlatformID
{
Expand Down
20 changes: 20 additions & 0 deletions src/xunit.netcore.extensions/TestPlatforms.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;

namespace Xunit
{
[Flags]
public enum TestPlatforms
{
Windows = 1,
Linux = 2,
OSX = 4,
FreeBSD = 8,
NetBSD = 16,
AnyUnix = FreeBSD | Linux | NetBSD | OSX,
Any = ~0
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<Compile Include="PlatformID.cs" />
<Compile Include="SkippedTestCase.cs" />
<Compile Include="TargetFrameworkMonikers.cs" />
<Compile Include="TestPlatforms.cs" />
<Compile Include="XunitConstants.cs" />
</ItemGroup>
<ItemGroup>
Expand Down