From 161b10d0d0021071083f63425a68da22c6ea9251 Mon Sep 17 00:00:00 2001 From: jonsequitur Date: Tue, 7 Feb 2017 10:08:14 -0800 Subject: [PATCH] WIP --- .../ArgumentForwardingTests.cs | 14 ++------- .../NonWindowsOnlyFactAttribute.cs | 16 ++++++++++ .../WindowsOnlyFactAttribute.cs | 13 +-------- .../WindowsOnlyTheoryAttribute.cs | 16 ++++++++++ test/dotnet.Tests/PackagedCommandTests.cs | 29 ++++++------------- 5 files changed, 44 insertions(+), 44 deletions(-) create mode 100644 test/Microsoft.DotNet.Tools.Tests.Utilities/NonWindowsOnlyFactAttribute.cs create mode 100644 test/Microsoft.DotNet.Tools.Tests.Utilities/WindowsOnlyTheoryAttribute.cs diff --git a/test/ArgumentForwardingTests/ArgumentForwardingTests.cs b/test/ArgumentForwardingTests/ArgumentForwardingTests.cs index ff74d9813..d9cc2c6c0 100644 --- a/test/ArgumentForwardingTests/ArgumentForwardingTests.cs +++ b/test/ArgumentForwardingTests/ArgumentForwardingTests.cs @@ -87,7 +87,7 @@ namespace Microsoft.DotNet.Tests.ArgumentForwarding /// This is a critical scenario for the driver. /// /// - [Theory] + [WindowsOnlyTheory] [InlineData(@"""abc"" d e")] [InlineData(@"""abc"" d e")] [InlineData("\"abc\"\t\td\te")] @@ -101,11 +101,6 @@ namespace Microsoft.DotNet.Tests.ArgumentForwarding [InlineData(@"a b c""def")] public void TestArgumentForwardingCmd(string testUserArgument) { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - return; - } - // Get Baseline Argument Evaluation via Reflector // This does not need to be different for cmd because // it only establishes what the string[] args should be @@ -148,18 +143,13 @@ namespace Microsoft.DotNet.Tests.ArgumentForwarding } } - [Theory] + [WindowsOnlyTheory] [InlineData(@"a\""b c d")] [InlineData(@"a\\\""b c d")] [InlineData(@"""\a\"" \\""\\\ b c")] [InlineData(@"a\""b \\ cd ""\e f\"" \\""\\\")] public void TestArgumentForwardingCmdFailsWithUnbalancedQuote(string testArgString) { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - return; - } - // Get Baseline Argument Evaluation via Reflector // This does not need to be different for cmd because // it only establishes what the string[] args should be diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/NonWindowsOnlyFactAttribute.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/NonWindowsOnlyFactAttribute.cs new file mode 100644 index 000000000..d50d0a89e --- /dev/null +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/NonWindowsOnlyFactAttribute.cs @@ -0,0 +1,16 @@ +using Microsoft.DotNet.PlatformAbstractions; +using Xunit; + +namespace Microsoft.DotNet.Tools.Test.Utilities +{ + public class NonWindowsOnlyFactAttribute : FactAttribute + { + public NonWindowsOnlyFactAttribute() + { + if (RuntimeEnvironment.OperatingSystemPlatform == Platform.Windows) + { + this.Skip = "This test requires windows to run"; + } + } + } +} diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/WindowsOnlyFactAttribute.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/WindowsOnlyFactAttribute.cs index 2b88b18b4..74318bb9e 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/WindowsOnlyFactAttribute.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/WindowsOnlyFactAttribute.cs @@ -16,15 +16,4 @@ namespace Microsoft.DotNet.Tools.Test.Utilities } } } - - public class WindowsOnlyTheoryAttribute : TheoryAttribute - { - public WindowsOnlyTheoryAttribute() - { - if (RuntimeEnvironment.OperatingSystemPlatform != Platform.Windows) - { - this.Skip = "This test requires windows to run"; - } - } - } -} \ No newline at end of file +} diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/WindowsOnlyTheoryAttribute.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/WindowsOnlyTheoryAttribute.cs new file mode 100644 index 000000000..d1e16f025 --- /dev/null +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/WindowsOnlyTheoryAttribute.cs @@ -0,0 +1,16 @@ +using Microsoft.DotNet.PlatformAbstractions; +using Xunit; + +namespace Microsoft.DotNet.Tools.Test.Utilities +{ + public class WindowsOnlyTheoryAttribute : TheoryAttribute + { + public WindowsOnlyTheoryAttribute() + { + if (RuntimeEnvironment.OperatingSystemPlatform != Platform.Windows) + { + this.Skip = "This test requires windows to run"; + } + } + } +} diff --git a/test/dotnet.Tests/PackagedCommandTests.cs b/test/dotnet.Tests/PackagedCommandTests.cs index e4a0a3cc1..3cc67a22e 100644 --- a/test/dotnet.Tests/PackagedCommandTests.cs +++ b/test/dotnet.Tests/PackagedCommandTests.cs @@ -36,8 +36,8 @@ namespace Microsoft.DotNet.Tests var projectOutputPath = $"AppWithProjTool2Fx\\bin\\Debug\\net451\\{rid}\\dotnet-desktop-and-portable.exe"; return new[] { - new object[] { "CoreFX", ".NETCoreApp,Version=v1.0", "lib\\netcoreapp1.0\\dotnet-desktop-and-portable.dll", true }, - new object[] { "NetFX", ".NETFramework,Version=v4.5.1", projectOutputPath, true } + new object[] { "CoreFX", ".NETCoreApp,Version=v1.0", "lib\\netcoreapp1.0\\dotnet-desktop-and-portable.dll" }, + new object[] { "NetFX", ".NETFramework,Version=v4.5.1", projectOutputPath } }; } } @@ -52,8 +52,8 @@ namespace Microsoft.DotNet.Tests return new[] { - new object[] { "CoreFX", ".NETStandard,Version=v1.6", "lib\\netstandard1.6\\dotnet-desktop-and-portable.dll", true }, - new object[] { "NetFX", ".NETFramework,Version=v4.5.1", projectOutputPath, true } + new object[] { "CoreFX", ".NETStandard,Version=v1.6", "lib\\netstandard1.6\\dotnet-desktop-and-portable.dll" }, + new object[] { "NetFX", ".NETFramework,Version=v4.5.1", projectOutputPath } }; } } @@ -197,16 +197,10 @@ namespace Microsoft.DotNet.Tests .And.NotHaveStdErr(); } - // need conditional theories so we can skip on non-Windows - //[Theory(Skip="https://github.com/dotnet/cli/issues/4514")] - //[MemberData("DependencyToolArguments")] - public void TestFrameworkSpecificDependencyToolsCanBeInvoked(string identifier, string framework, string expectedDependencyToolPath, bool windowsOnly) + [WindowsOnlyTheory(Skip="https://github.com/dotnet/cli/issues/4514")] + [MemberData("DependencyToolArguments")] + public void TestFrameworkSpecificDependencyToolsCanBeInvoked(string identifier, string framework, string expectedDependencyToolPath) { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && windowsOnly) - { - return; - } - var testInstance = TestAssets.Get(TestAssetKinds.DesktopTestProjects, "AppWithProjTool2Fx") .CreateInstance(identifier: identifier) .WithSourceFiles() @@ -228,15 +222,10 @@ namespace Microsoft.DotNet.Tests .And.Pass(); } - [Theory] + [WindowsOnlyTheory] [MemberData("LibraryDependencyToolArguments")] - public void TestFrameworkSpecificLibraryDependencyToolsCannotBeInvoked(string identifier, string framework, string expectedDependencyToolPath, bool windowsOnly) + public void TestFrameworkSpecificLibraryDependencyToolsCannotBeInvoked(string identifier, string framework, string expectedDependencyToolPath) { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && windowsOnly) - { - return; - } - var testInstance = TestAssets.Get(TestAssetKinds.DesktopTestProjects, "LibWithProjTool2Fx") .CreateInstance(identifier: identifier) .WithSourceFiles()