Skip to content
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 @@ -18,7 +18,9 @@ public ActiveIssueAttribute(int issueNumber, TestPlatforms platforms) { }
public ActiveIssueAttribute(string issue, TestPlatforms platforms) { }
public ActiveIssueAttribute(int issueNumber, TargetFrameworkMonikers framework) { }
public ActiveIssueAttribute(string issue, TargetFrameworkMonikers framework) { }
public ActiveIssueAttribute(int issueNumber, TestPlatforms platforms = TestPlatforms.Any, TargetFrameworkMonikers framework = (TargetFrameworkMonikers)0) { }
public ActiveIssueAttribute(string issue, TestPlatforms platforms = TestPlatforms.Any, TargetFrameworkMonikers framework = (TargetFrameworkMonikers)0) { }
public ActiveIssueAttribute(int issueNumber, TestRuntimes runtimes) { }
public ActiveIssueAttribute(string issue, TestRuntimes runtimes) { }
public ActiveIssueAttribute(int issueNumber, TestPlatforms platforms = TestPlatforms.Any, TargetFrameworkMonikers framework = (TargetFrameworkMonikers)0, TestRuntimes runtimes = TestRuntimes.Any) { }
public ActiveIssueAttribute(string issue, TestPlatforms platforms = TestPlatforms.Any, TargetFrameworkMonikers framework = (TargetFrameworkMonikers)0, TestRuntimes runtimes = TestRuntimes.Any) { }
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Microsoft.DotNet.XUnitExtensions
{
Expand Down
5 changes: 5 additions & 0 deletions src/Microsoft.DotNet.XUnitExtensions/src/DiscovererHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,10 @@ internal static bool TestPlatformApplies(TestPlatforms platforms) =>
(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));

internal static bool TestRuntimeApplies(TestRuntimes runtimes) =>
(runtimes.HasFlag(TestRuntimes.Mono) && SkipOnMonoDiscoverer.IsMonoRuntime) ||
(runtimes.HasFlag(TestRuntimes.CoreCLR) && !SkipOnMonoDiscoverer.IsMonoRuntime); // assume CoreCLR if it's not Mono

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitA
string issue = ctorArgs.First().ToString();
TestPlatforms platforms = TestPlatforms.Any;
TargetFrameworkMonikers frameworks = (TargetFrameworkMonikers)0;
TestRuntimes runtimes = TestRuntimes.Any;

foreach (object arg in ctorArgs.Skip(1)) // First argument is the issue number.
{
Expand All @@ -42,22 +43,20 @@ public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitA
{
frameworks = (TargetFrameworkMonikers)arg;
}
else if (arg is TestRuntimes)
{
runtimes = (TestRuntimes)arg;
}
}

if (DiscovererHelpers.TestPlatformApplies(platforms))
if (DiscovererHelpers.TestPlatformApplies(platforms) && DiscovererHelpers.TestRuntimeApplies(runtimes))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If no TFM is provided and the runtime applies, this will return the “activeissue” trait and I don’t believe we ignore that trait in all our scripts. Could we update the last yield return to return failing instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the activeissue trait for actually? We never catch that. Should we instead just always return failing if none else applies?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually since we default frameworks to 0 it would return failing, but I would instead always return failing as @ViktorHofer suggested.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never-mind, we just need to remove the whole yield return at the end that returns the activeissue trait.

{
if (frameworks.HasFlag(TargetFrameworkMonikers.Netcoreapp))
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNetcoreappTest);
if (frameworks.HasFlag(TargetFrameworkMonikers.NetFramework))
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNetfxTest);
if (frameworks.HasFlag(TargetFrameworkMonikers.Uap))
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonUapTest);
if (frameworks.HasFlag(TargetFrameworkMonikers.Mono))
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonMonoTest);
if (frameworks == (TargetFrameworkMonikers)0)
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 @@ -28,10 +28,6 @@ public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitA
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNetcoreappTest);
if (frameworks.HasFlag(TargetFrameworkMonikers.NetFramework))
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNetfxTest);
if (frameworks.HasFlag(TargetFrameworkMonikers.Uap))
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonUapTest);
if (frameworks.HasFlag(TargetFrameworkMonikers.Mono))
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonMonoTest);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// 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;
using System.Collections.Generic;
using System.Linq;
using Xunit.Abstractions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// 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;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ namespace Xunit
public enum TargetFrameworkMonikers
{
Netcoreapp = 0x1,
NetFramework = 0x2,
Uap = 0x4,
Mono = 0x8
NetFramework = 0x2
}
}
16 changes: 16 additions & 0 deletions src/Microsoft.DotNet.XUnitExtensions/src/TestRuntimes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 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 TestRuntimes
{
CoreCLR = 1,
Mono = 2,
Any = ~0
}
}
3 changes: 0 additions & 3 deletions src/Microsoft.DotNet.XUnitExtensions/src/XunitConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@ public struct XunitConstants

internal static string NonNetcoreappTest = "nonnetcoreapptests";
internal static string NonNetfxTest = "nonnetfxtests";
internal static string NonUapTest = "nonuaptests";
internal static string NonMonoTest = "nonmonotests";

internal const string Failing = "failing";
internal const string ActiveIssue = "activeissue";
internal const string OuterLoop = "outerloop";

public const string Category = "category";
Expand Down