Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing traits used to skip certain test cases with custom Theory and Fact attributes #8348

Merged
merged 8 commits into from
Jan 31, 2023
16 changes: 6 additions & 10 deletions src/Build.OM.UnitTests/Construction/ProjectRootElement_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using Shouldly;
using Xunit;
using Microsoft.Build.Framework;
using Xunit.NetCore.Extensions;

#nullable disable

Expand Down Expand Up @@ -883,11 +884,9 @@ public void ItemsEnumerator()

#if FEATURE_SECURITY_PRINCIPAL_WINDOWS
/// <summary>
/// Build a solution file that can't be accessed
/// Build a solution file that can't be accessed.
/// </summary>
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // Security classes are not supported on Unix

[WindowsOnlyFact(additionalMessage: "Security classes are not supported on Unix.")]
public void SolutionCanNotBeOpened()
{
Assert.Throws<InvalidProjectFileException>(() =>
Expand Down Expand Up @@ -930,11 +929,9 @@ public void SolutionCanNotBeOpened()
}

/// <summary>
/// Build a project file that can't be accessed
/// Build a project file that can't be accessed.
/// </summary>
[Fact]
[PlatformSpecific(TestPlatforms.Windows)]
// FileSecurity class is not supported on Unix
[WindowsOnlyFact(additionalMessage: "FileSecurity class is not supported on Unix.")]
public void ProjectCanNotBeOpened()
{
Assert.Throws<InvalidProjectFileException>(() =>
Expand Down Expand Up @@ -1005,8 +1002,7 @@ public void SolutionCorrupt()
/// <summary>
/// Open lots of projects concurrently to try to trigger problems
/// </summary>
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // This test is platform specific for Windows
[WindowsOnlyFact]
public void ConcurrentProjectOpenAndCloseThroughProject()
{
int iterations = 500;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,6 @@ public void DefaultToolsVersion()
#else
[Fact(Skip = "https://github.com/dotnet/msbuild/issues/276")]
#endif
[Trait("Category", "mono-osx-failing")]
public void DefaultToolsVersion2()
{
if (ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version20) != null)
Expand Down
16 changes: 6 additions & 10 deletions src/Build.OM.UnitTests/Definition/ProjectItem_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Shouldly;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
using Xunit;
using Xunit.NetCore.Extensions;

#nullable disable

Expand Down Expand Up @@ -703,8 +704,7 @@ public void ExcludeAndIncludeConsideredAsLiteralsWhenFilespecIsIllegal(string pr
TestIncludeExclude(projectContents, inputFiles, expectedInclude, includeString, excludeString, normalizeSlashes: true);
}

[Theory]
[PlatformSpecific(TestPlatforms.Windows)]
[WindowsOnlyTheory]
[InlineData(ItemWithIncludeAndExclude,
@"src/**/*.cs",
new[]
Expand Down Expand Up @@ -793,8 +793,7 @@ public void ProjectGetterResultsInDriveEnumerationException(string unevaluatedIn
/// Project getter that renames an item to a drive enumerating wildcard that results in a logged warning.
/// </summary>
[ActiveIssue("https://github.com/dotnet/msbuild/issues/7330")]
[PlatformSpecific(TestPlatforms.Windows)]
[Theory]
[WindowsOnlyTheory]
[InlineData(@"z:\**\*.log")]
[InlineData(@"z:$(empty)\**\*.log")]
[InlineData(@"z:\**")]
Expand All @@ -807,8 +806,7 @@ public void ProjectGetterResultsInWindowsDriveEnumerationWarning(string unevalua
}

[ActiveIssue("https://github.com/dotnet/msbuild/issues/7330")]
[PlatformSpecific(TestPlatforms.AnyUnix)]
[Theory]
[UnixOnlyTheory]
[InlineData(@"/**/*.log")]
[InlineData(@"$(empty)/**/*.log")]
[InlineData(@"/$(empty)**/*.log")]
Expand Down Expand Up @@ -878,8 +876,7 @@ public void ThrowExceptionUponProjectInstanceCreationFromDriveEnumeratingContent
/// Project instance created from a file that contains a drive enumerating wildcard results in a logged warning on the Windows platform.
/// </summary>
[ActiveIssue("https://github.com/dotnet/msbuild/issues/7330")]
[PlatformSpecific(TestPlatforms.Windows)]
[Theory]
[WindowsOnlyTheory]
[InlineData(
ImportProjectElement,
@"z:\**\*.targets",
Expand All @@ -903,8 +900,7 @@ public void LogWindowsWarningUponProjectInstanceCreationFromDriveEnumeratingCont
}

[ActiveIssue("https://github.com/dotnet/msbuild/issues/7330")]
[PlatformSpecific(TestPlatforms.AnyUnix)]
[Theory]
[UnixOnlyTheory]
[InlineData(
ImportProjectElement,
@"\**\*.targets",
Expand Down
8 changes: 0 additions & 8 deletions src/Build.OM.UnitTests/Definition/Project_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,6 @@ public void ChangeGlobalPropertiesPreexisting()
#else
[Fact(Skip = "https://github.com/dotnet/msbuild/issues/276")]
#endif
[Trait("Category", "mono-osx-failing")]
public void ChangeGlobalPropertiesInitiallyFromProjectCollection()
{
Dictionary<string, string> initial = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
Expand Down Expand Up @@ -1243,7 +1242,6 @@ public void GetSubToolsetVersion()
/// environment
/// </summary>
[Fact]
[Trait("Category", "mono-osx-failing")]
public void GetSubToolsetVersion_FromEnvironment()
{
string originalVisualStudioVersion = Environment.GetEnvironmentVariable("VisualStudioVersion");
Expand Down Expand Up @@ -3855,8 +3853,6 @@ public void ProjectInstanceShouldInitiallyHaveSameEvaluationIdAsTheProjectItCame
[Fact]
[Trait("Category", "netcore-osx-failing")] // https://github.com/dotnet/msbuild/issues/2226
[Trait("Category", "netcore-linux-failing")] // https://github.com/dotnet/msbuild/issues/2226
[Trait("Category", "mono-osx-failing")] // https://github.com/dotnet/msbuild/issues/2226
[Trait("Category", "mono-linux-failing")] // https://github.com/dotnet/msbuild/issues/2226
public void ProjectImportedEventFalseCondition()
{
using (var env = TestEnvironment.Create(_output))
Expand Down Expand Up @@ -3900,8 +3896,6 @@ public void ProjectImportedEventFalseCondition()
[Fact]
[Trait("Category", "netcore-osx-failing")] // https://github.com/dotnet/msbuild/issues/2226
[Trait("Category", "netcore-linux-failing")] // https://github.com/dotnet/msbuild/issues/2226
[Trait("Category", "mono-osx-failing")] // https://github.com/dotnet/msbuild/issues/2226
[Trait("Category", "mono-linux-failing")] // https://github.com/dotnet/msbuild/issues/2226
public void ProjectImportedEventNoMatchingFiles()
{
using (var env = TestEnvironment.Create(_output))
Expand Down Expand Up @@ -4161,8 +4155,6 @@ public void ProjectImportedEventMissingFileNoGlobMatch()
[Fact]
[Trait("Category", "netcore-osx-failing")] // https://github.com/dotnet/msbuild/issues/2226
[Trait("Category", "netcore-linux-failing")] // https://github.com/dotnet/msbuild/issues/2226
[Trait("Category", "mono-osx-failing")] // https://github.com/dotnet/msbuild/issues/2226
[Trait("Category", "mono-linux-failing")] // https://github.com/dotnet/msbuild/issues/2226
public void ProjectImportEvent()
{
using (var env = TestEnvironment.Create(_output))
Expand Down
10 changes: 4 additions & 6 deletions src/Build.OM.UnitTests/Instance/ProjectItemInstance_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Xunit;
using Shouldly;
using System.Linq;
using Xunit.NetCore.Extensions;

#nullable disable

Expand Down Expand Up @@ -908,8 +909,7 @@ public void ThrowExceptionUponBuildingProjectWithDriveEnumeration(string content
/// Log warning for drive enumerating wildcards that exist in projects on Windows platform.
/// </summary>
[ActiveIssue("https://github.com/dotnet/msbuild/issues/7330")]
[PlatformSpecific(TestPlatforms.Windows)]
[Theory]
[WindowsOnlyTheory]
[InlineData(
TargetItemWithIncludeAndExclude,
@"z:$(Microsoft_WindowsAzure_EngSys)\**\*",
Expand Down Expand Up @@ -950,8 +950,7 @@ public void LogWindowsWarningUponBuildingProjectWithDriveEnumeration(string cont
/// Log warning for drive enumerating wildcards that exist in projects on Unix platform.
/// </summary>
[ActiveIssue("https://github.com/dotnet/msbuild/issues/7330")]
[PlatformSpecific(TestPlatforms.AnyUnix)]
[Theory]
[UnixOnlyTheory]
[InlineData(
TargetWithDefinedPropertyAndItemWithInclude,
@"$(Microsoft_WindowsAzure_EngSys)**",
Expand Down Expand Up @@ -981,8 +980,7 @@ public void LogUnixWarningUponBuildingProjectWithDriveEnumeration(string content
/// <summary>
/// Tests target item evaluation resulting in no build failures.
/// </summary>
[PlatformSpecific(TestPlatforms.Windows)]
[Theory]
[WindowsOnlyTheory]
[InlineData(
TargetWithDefinedPropertyAndItemWithInclude,
@"$(Microsoft_WindowsAzure_EngSys)*.cs",
Expand Down
4 changes: 2 additions & 2 deletions src/Build.OM.UnitTests/NugetRestoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Xunit;
#endif
using Xunit.Abstractions;
using Xunit.NetCore.Extensions;

namespace Microsoft.Build.Engine.OM.UnitTests
{
Expand All @@ -23,8 +24,7 @@ public NugetRestoreTests(ITestOutputHelper output)
// This NuGet version cannot locate other assemblies when parsing solutions at restore time. This includes localized strings required in debug mode.
// NuGet version 4.1.0 was somewhat arbitrarily chosen. 3.5 breaks with an unrelated error, and 4.8.2 does not fail when a new dependency is introduced. This is a safe middle point.
#if !DEBUG
[SkipOnTargetFramework(TargetFrameworkMonikers.Netcoreapp)]
[Fact]
[WindowsFullFrameworkOnlyFact]
public void TestOldNuget()
{
string msbuildExePath = Path.GetDirectoryName(RunnerUtilities.PathToCurrentlyRunningMsBuildExe)!;
Expand Down
6 changes: 0 additions & 6 deletions src/Build.UnitTests/BackEnd/AssemblyTaskFactory_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,6 @@ public void VerifyMatchingParametersDontLaunchTaskHost()
/// parameters that explicitly do not match the current process.
/// </summary>
[Fact]
[Trait("Category", "mono-osx-failing")]
public void VerifyNonmatchingUsingTaskParametersLaunchTaskHost()
{
ITask createdTask = null;
Expand Down Expand Up @@ -464,7 +463,6 @@ public void VerifyNonmatchingUsingTaskParametersLaunchTaskHost()
/// parameters that explicitly do not match the current process.
/// </summary>
[Fact]
[Trait("Category", "mono-osx-failing")]
public void VerifyNonmatchingTaskParametersLaunchTaskHost()
{
ITask createdTask = null;
Expand Down Expand Up @@ -496,7 +494,6 @@ public void VerifyNonmatchingTaskParametersLaunchTaskHost()
/// parameters that explicitly do not match the current process.
/// </summary>
[Fact]
[Trait("Category", "mono-osx-failing")]
public void VerifyNonmatchingParametersLaunchTaskHost()
{
ITask createdTask = null;
Expand Down Expand Up @@ -561,7 +558,6 @@ public void VerifyExplicitlyLaunchTaskHost()
/// explicitly instructed to launch the task host.
/// </summary>
[Fact]
[Trait("Category", "mono-osx-failing")]
public void VerifyExplicitlyLaunchTaskHostEvenIfParametersMatch1()
{
ITask createdTask = null;
Expand Down Expand Up @@ -595,7 +591,6 @@ public void VerifyExplicitlyLaunchTaskHostEvenIfParametersMatch1()
/// explicitly instructed to launch the task host.
/// </summary>
[Fact]
[Trait("Category", "mono-osx-failing")]
public void VerifyExplicitlyLaunchTaskHostEvenIfParametersMatch2()
{
ITask createdTask = null;
Expand Down Expand Up @@ -629,7 +624,6 @@ public void VerifyExplicitlyLaunchTaskHostEvenIfParametersMatch2()
/// explicitly instructed to launch the task host.
/// </summary>
[Fact]
[Trait("Category", "mono-osx-failing")]
public void VerifySameFactoryCanGenerateDifferentTaskInstances()
{
ITask createdTask = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Microsoft.Build.BackEnd.Logging;
using Microsoft.Build.Shared;
using Xunit;
using Xunit.NetCore.Extensions;

#nullable disable

Expand Down Expand Up @@ -123,9 +124,7 @@ void TransportDelegate(INodePacket packet)
/// <summary>
/// Make sure shutdown will correctly null out the send data delegate
/// </summary>
[Fact]
[Trait("Category", "mono-osx-failing")]
[SkipOnTargetFramework(TargetFrameworkMonikers.Netcoreapp, "https://github.com/dotnet/msbuild/issues/282")]
[WindowsFullFrameworkOnlyFact("https://github.com/dotnet/msbuild/issues/282")]
public void TestShutDown()
{
SendDataDelegate transportDelegate = new(PacketProcessor);
Expand Down
2 changes: 0 additions & 2 deletions src/Build.UnitTests/BackEnd/BuildManager_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2303,7 +2303,6 @@ public void ProjectInstanceLimitedTransferToOOPNode()
[Fact]
[Trait("Category", "netcore-osx-failing")]
[Trait("Category", "netcore-linux-failing")]
[Trait("Category", "mono-osx-failing")]
public void CacheLifetime()
{
FileUtilities.ClearCacheDirectory();
Expand Down Expand Up @@ -3966,7 +3965,6 @@ public void OutOfProcEvaluationIdsUnique()
/// Regression test for https://github.com/dotnet/msbuild/issues/3047
/// </summary>
[Fact]
[SkipOnMono("out-of-proc nodes not working on mono yet")]
public void MultiProcReentrantProjectWithCallTargetDoesNotFail()
{
var a =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,6 @@ public void TestCache()
[Fact]
[Trait("Category", "netcore-osx-failing")]
[Trait("Category", "netcore-linux-failing")]
[Trait("Category", "mono-osx-failing")]
public void WorksCorrectlyWithCurlyBraces()
{
string projectBody = ObjectModelHelpers.CleanupFileContents(@"
Expand Down
4 changes: 2 additions & 2 deletions src/Build.UnitTests/BackEnd/BuildRequest_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.Build.Framework;
using Shouldly;
using Xunit;
using Xunit.NetCore.Extensions;

#nullable disable

Expand Down Expand Up @@ -136,8 +137,7 @@ public void TestTranslation()
}
}

[Fact]
[PlatformSpecific(TestPlatforms.Windows)]
[WindowsOnlyFact]
[SupportedOSPlatform("windows")]
public void TestTranslationRemoteHostObjects()
{
Expand Down
1 change: 0 additions & 1 deletion src/Build.UnitTests/BackEnd/IntrinsicTask_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3255,7 +3255,6 @@ public void IncludeCheckOnMetadata2()
[Fact]
[Trait("Category", "netcore-osx-failing")]
[Trait("Category", "netcore-linux-failing")]
[Trait("Category", "mono-osx-failing")]
public void IncludeCheckOnMetadata_3()
{
MockLogger logger = new MockLogger();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,6 @@ public void LogBuildStarted()
[Fact(Skip = "https://github.com/dotnet/msbuild/issues/437")]
[Trait("Category", "netcore-osx-failing")]
[Trait("Category", "netcore-linux-failing")]
[Trait("Category", "mono-osx-failing")]
public void LogBuildStartedCriticalOnly()
{
ProcessBuildEventHelper service =
Expand Down
1 change: 0 additions & 1 deletion src/Build.UnitTests/BackEnd/MSBuild_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,6 @@ public void StopOnFirstFailureandBuildInParallelSingleNode()
/// Verify stopOnFirstFailure with BuildInParallel override message are correctly logged when there are multiple nodes
/// </summary>
[Fact]
[Trait("Category", "mono-osx-failing")]
public void StopOnFirstFailureandBuildInParallelMultipleNode()
{
string project1 = ObjectModelHelpers.CreateTempFileOnDisk(@"
Expand Down
1 change: 0 additions & 1 deletion src/Build.UnitTests/BackEnd/OnError_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public void Basic()
/// Then these items and properties should be visible to the onerror targets.
/// </summary>
[Fact]
[Trait("Category", "mono-osx-failing")]
public void FailingTaskStillPublishesOutputs()
{
MockLogger l = new MockLogger();
Expand Down
Loading