From 4e1908820d99bdf7788233b7515d5031fbdfcaba Mon Sep 17 00:00:00 2001 From: Swapnali911 Date: Mon, 28 Aug 2023 20:02:11 +0530 Subject: [PATCH] Skip Omnisharp test cases for ppc64le and s390x (#17263) Co-authored-by: Michael Simons --- .../DotNetFormatTests.cs | 2 +- .../OmniSharpTests.cs | 2 +- .../PoisonTests.cs | 2 +- .../SdkContentTests.cs | 4 ++-- .../SkippableFactAttribute.cs | 23 +++++++++++++------ .../SkippableTheoryAttribute.cs | 8 +++---- 6 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/DotNetFormatTests.cs b/src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/DotNetFormatTests.cs index 0ad77dbd0..602f72f27 100644 --- a/src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/DotNetFormatTests.cs +++ b/src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/DotNetFormatTests.cs @@ -19,7 +19,7 @@ public class DotNetFormatTests : SmokeTests /// /// Format an unformatted project and verify that the output matches the pre-computed solution. /// - [SkippableFact(Config.ExcludeDotnetFormatEnv, skipOnTrue: true)] + [SkippableFact(Config.ExcludeDotnetFormatEnv, skipOnTrueEnv: true)] public void FormatProject() { string unformattedCsFilePath = Path.Combine(BaselineHelper.GetAssetsDirectory(), UnformattedFileName); diff --git a/src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/OmniSharpTests.cs b/src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/OmniSharpTests.cs index 60b444136..391d1f9db 100644 --- a/src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/OmniSharpTests.cs +++ b/src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/OmniSharpTests.cs @@ -25,7 +25,7 @@ public class OmniSharpTests : SmokeTests public OmniSharpTests(ITestOutputHelper outputHelper) : base(outputHelper) { } - [SkippableTheory(Config.ExcludeOmniSharpEnv, skipOnTrue: true)] + [SkippableTheory(Config.ExcludeOmniSharpEnv, skipOnTrueEnv: true, skipArchitectures: new[] { "ppc64le", "s390x" })] [InlineData(DotNetTemplate.BlazorWasm)] [InlineData(DotNetTemplate.ClassLib)] [InlineData(DotNetTemplate.Console)] diff --git a/src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/PoisonTests.cs b/src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/PoisonTests.cs index 01d36b34c..6eb8203f5 100644 --- a/src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/PoisonTests.cs +++ b/src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/PoisonTests.cs @@ -13,7 +13,7 @@ namespace Microsoft.DotNet.SourceBuild.SmokeTests { public PoisonTests(ITestOutputHelper outputHelper) : base(outputHelper) { } - [SkippableFact(Config.PoisonReportPathEnv, skipOnNullOrWhiteSpace: true)] + [SkippableFact(Config.PoisonReportPathEnv, skipOnNullOrWhiteSpaceEnv: true)] public void VerifyUsage() { if (!File.Exists(Config.PoisonReportPath)) diff --git a/src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/SdkContentTests.cs b/src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/SdkContentTests.cs index 9f8422f19..d3b0c8a26 100644 --- a/src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/SdkContentTests.cs +++ b/src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/SdkContentTests.cs @@ -31,7 +31,7 @@ public class SdkContentTests : SmokeTests /// This makes the baseline durable between releases. This does mean however, entries /// in the baseline may appear identical if the diff is version specific. /// - [SkippableFact(new[] { Config.MsftSdkTarballPathEnv, Config.SdkTarballPathEnv }, skipOnNullOrWhiteSpace: true)] + [SkippableFact(new[] { Config.MsftSdkTarballPathEnv, Config.SdkTarballPathEnv }, skipOnNullOrWhiteSpaceEnv: true)] public void CompareMsftToSbFileList() { const string msftFileListingFileName = "msftSdkFiles.txt"; @@ -44,7 +44,7 @@ public class SdkContentTests : SmokeTests BaselineHelper.CompareBaselineContents("MsftToSbSdkFiles.diff", diff, OutputHelper, Config.WarnOnSdkContentDiffs); } - [SkippableFact(new[] { Config.MsftSdkTarballPathEnv, Config.SdkTarballPathEnv }, skipOnNullOrWhiteSpace: true)] + [SkippableFact(new[] { Config.MsftSdkTarballPathEnv, Config.SdkTarballPathEnv }, skipOnNullOrWhiteSpaceEnv: true)] public void CompareMsftToSbAssemblyVersions() { Assert.NotNull(Config.MsftSdkTarballPath); diff --git a/src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/SkippableFactAttribute.cs b/src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/SkippableFactAttribute.cs index 867bb77a5..47b31214a 100644 --- a/src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/SkippableFactAttribute.cs +++ b/src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/SkippableFactAttribute.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Linq; using Xunit; namespace Microsoft.DotNet.SourceBuild.SmokeTests; @@ -12,28 +13,36 @@ namespace Microsoft.DotNet.SourceBuild.SmokeTests; /// internal class SkippableFactAttribute : FactAttribute { - public SkippableFactAttribute(string envName, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false) => - CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, envName); + public SkippableFactAttribute(string envName, bool skipOnNullOrWhiteSpaceEnv = false, bool skipOnTrueEnv = false, string[] skipArchitectures = null) => + EvaluateSkips(skipOnNullOrWhiteSpaceEnv, skipOnTrueEnv, skipArchitectures, (skip) => Skip = skip, envName); - public SkippableFactAttribute(string[] envNames, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false) => - CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, envNames); + public SkippableFactAttribute(string[] envNames, bool skipOnNullOrWhiteSpaceEnv = false, bool skipOnTrueEnv = false, string[] skipArchitectures = null) => + EvaluateSkips(skipOnNullOrWhiteSpaceEnv, skipOnTrueEnv, skipArchitectures, (skip) => Skip = skip, envNames); - public static void CheckEnvs(bool skipOnNullOrWhiteSpace, bool skipOnTrue, Action setSkip, params string[] envNames) + public static void EvaluateSkips(bool skipOnNullOrWhiteSpaceEnv, bool skipOnTrueEnv, string[] skipArchitectures, Action setSkip, params string[] envNames) { foreach (string envName in envNames) { string? envValue = Environment.GetEnvironmentVariable(envName); - if (skipOnNullOrWhiteSpace && string.IsNullOrWhiteSpace(envValue)) + if (skipOnNullOrWhiteSpaceEnv && string.IsNullOrWhiteSpace(envValue)) { setSkip($"Skipping because `{envName}` is null or whitespace"); break; } - else if (skipOnTrue && bool.TryParse(envValue, out bool boolValue) && boolValue) + else if (skipOnTrueEnv && bool.TryParse(envValue, out bool boolValue) && boolValue) { setSkip($"Skipping because `{envName}` is set to True"); break; } } + + if (skipArchitectures != null) { + string? arch = Config.TargetArchitecture; + if (skipArchitectures.Contains(arch)) + { + setSkip($"Skipping because arch is `{arch}`"); + } + } } } diff --git a/src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/SkippableTheoryAttribute.cs b/src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/SkippableTheoryAttribute.cs index 32a7179a1..6dd15c5e7 100644 --- a/src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/SkippableTheoryAttribute.cs +++ b/src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/SkippableTheoryAttribute.cs @@ -11,9 +11,9 @@ namespace Microsoft.DotNet.SourceBuild.SmokeTests; /// internal class SkippableTheoryAttribute : TheoryAttribute { - public SkippableTheoryAttribute(string envName, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false) => - SkippableFactAttribute.CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, envName); + public SkippableTheoryAttribute(string envName, bool skipOnNullOrWhiteSpaceEnv = false, bool skipOnTrueEnv = false, string[] skipArchitectures = null) => + SkippableFactAttribute.EvaluateSkips(skipOnNullOrWhiteSpaceEnv, skipOnTrueEnv, skipArchitectures, (skip) => Skip = skip, envName); - public SkippableTheoryAttribute(string[] envNames, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false) => - SkippableFactAttribute.CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, envNames); + public SkippableTheoryAttribute(string[] envNames, bool skipOnNullOrWhiteSpaceEnv = false, bool skipOnTrueEnv = false, string[] skipArchitectures = null) => + SkippableFactAttribute.EvaluateSkips(skipOnNullOrWhiteSpaceEnv, skipOnTrueEnv, skipArchitectures, (skip) => Skip = skip, envNames); }