run sdk comparison tests in a separate pipeline
This commit is contained in:
parent
5a6560273b
commit
2715f10cc3
9 changed files with 231 additions and 15 deletions
|
@ -19,9 +19,9 @@ public class BasicScenarioTests : SmokeTests
|
|||
{
|
||||
public BasicScenarioTests(ITestOutputHelper outputHelper) : base(outputHelper) { }
|
||||
|
||||
[Theory]
|
||||
[SkippableTheory()]
|
||||
[MemberData(nameof(GetScenarioObjects))]
|
||||
public void VerifyScenario(TestScenario scenario) => scenario.Execute(DotNetHelper);
|
||||
public void VerifyBasicScenario(TestScenario scenario) => scenario.Execute(DotNetHelper);
|
||||
|
||||
private static IEnumerable<object[]> GetScenarioObjects() => GetScenarios().Select(scenario => new object[] { scenario });
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ internal static class Config
|
|||
{
|
||||
public const string DotNetDirectoryEnv = "SMOKE_TESTS_DOTNET_DIR";
|
||||
public const string ExcludeOmniSharpEnv = "SMOKE_TESTS_EXCLUDE_OMNISHARP";
|
||||
public const string IncludeTestsEnv = "SMOKE_TESTS_INCLUDE";
|
||||
public const string MsftSdkTarballPathEnv = "SMOKE_TESTS_MSFT_SDK_TARBALL_PATH";
|
||||
public const string PoisonReportPathEnv = "SMOKE_TESTS_POISON_REPORT_PATH";
|
||||
public const string PortableRidEnv = "SMOKE_TESTS_PORTABLE_RID";
|
||||
|
@ -45,4 +46,13 @@ internal static class Config
|
|||
// Indicates whether the tests are being run in the context of a CI pipeline
|
||||
public static bool RunningInCI { get; } =
|
||||
bool.TryParse(Environment.GetEnvironmentVariable(RunningInCIEnv), out bool runningInCI) && runningInCI;
|
||||
|
||||
public static string[] IncludedTests
|
||||
{
|
||||
get
|
||||
{
|
||||
var include = Environment.GetEnvironmentVariable(IncludeTestsEnv);
|
||||
return include == null ? Array.Empty<string>() : include.Split(',');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ public class DotNetWatchTests : SmokeTests
|
|||
{
|
||||
public DotNetWatchTests(ITestOutputHelper outputHelper) : base(outputHelper) { }
|
||||
|
||||
[Fact]
|
||||
[SkippableFact()]
|
||||
public void WatchTests()
|
||||
{
|
||||
string projectDirectory = DotNetHelper.ExecuteNew(DotNetTemplate.Console.GetName(), nameof(DotNetWatchTests));
|
||||
|
|
|
@ -34,7 +34,7 @@ public class OmniSharpTests : SmokeTests
|
|||
[InlineData(DotNetTemplate.WebApi)]
|
||||
[InlineData(DotNetTemplate.Worker)]
|
||||
[InlineData(DotNetTemplate.XUnit)]
|
||||
public async void VerifyScenario(DotNetTemplate template)
|
||||
public async void VerifyOmniSharpScenario(DotNetTemplate template)
|
||||
{
|
||||
await InitializeOmniSharp();
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.DotNet.SourceBuild.SmokeTests;
|
||||
|
@ -12,14 +14,29 @@ namespace Microsoft.DotNet.SourceBuild.SmokeTests;
|
|||
/// </summary>
|
||||
internal class SkippableFactAttribute : FactAttribute
|
||||
{
|
||||
public SkippableFactAttribute(string envName, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false) =>
|
||||
CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, envName);
|
||||
public SkippableFactAttribute([CallerMemberName] string name = "") =>
|
||||
CheckIncluded(name, (skip) => Skip = skip);
|
||||
|
||||
public SkippableFactAttribute(string[] envNames, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false) =>
|
||||
CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, envNames);
|
||||
public SkippableFactAttribute(string envName, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false, [CallerMemberName] string testName = "") =>
|
||||
CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, testName, envName);
|
||||
|
||||
public static void CheckEnvs(bool skipOnNullOrWhiteSpace, bool skipOnTrue, Action<string> setSkip, params string[] envNames)
|
||||
public SkippableFactAttribute(string[] envNames, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false, [CallerMemberName] string testName = "") =>
|
||||
CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, testName, envNames);
|
||||
|
||||
public static void CheckIncluded(string methodName, Action<string> setSkip)
|
||||
{
|
||||
var included = Config.IncludedTests;
|
||||
if (included.Length != 0 && !included.Contains(methodName))
|
||||
{
|
||||
setSkip($"Skipping because `{methodName}` is not included");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public static void CheckEnvs(bool skipOnNullOrWhiteSpace, bool skipOnTrue, Action<string> setSkip, string testName, params string[] envNames)
|
||||
{
|
||||
CheckIncluded(testName, setSkip);
|
||||
|
||||
foreach (string envName in envNames)
|
||||
{
|
||||
string? envValue = Environment.GetEnvironmentVariable(envName);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// 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.Runtime.CompilerServices;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.DotNet.SourceBuild.SmokeTests;
|
||||
|
@ -11,9 +12,12 @@ namespace Microsoft.DotNet.SourceBuild.SmokeTests;
|
|||
/// </summary>
|
||||
internal class SkippableTheoryAttribute : TheoryAttribute
|
||||
{
|
||||
public SkippableTheoryAttribute(string envName, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false) =>
|
||||
SkippableFactAttribute.CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, envName);
|
||||
public SkippableTheoryAttribute([CallerMemberName] string testName = "") =>
|
||||
SkippableFactAttribute.CheckIncluded(testName, (skip) => Skip = skip);
|
||||
|
||||
public SkippableTheoryAttribute(string[] envNames, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false) =>
|
||||
SkippableFactAttribute.CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, envNames);
|
||||
public SkippableTheoryAttribute(string envName, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false, [CallerMemberName] string testName = "") =>
|
||||
SkippableFactAttribute.CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, testName, envName);
|
||||
|
||||
public SkippableTheoryAttribute(string[] envNames, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false, [CallerMemberName] string testName = "") =>
|
||||
SkippableFactAttribute.CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, testName, envNames);
|
||||
}
|
||||
|
|
|
@ -18,9 +18,9 @@ public class WebScenarioTests : SmokeTests
|
|||
{
|
||||
public WebScenarioTests(ITestOutputHelper outputHelper) : base(outputHelper) { }
|
||||
|
||||
[Theory]
|
||||
[SkippableTheory()]
|
||||
[MemberData(nameof(GetScenarioObjects))]
|
||||
public void VerifyScenario(TestScenario scenario) => scenario.Execute(DotNetHelper);
|
||||
public void VerifyWebScenario(TestScenario scenario) => scenario.Execute(DotNetHelper);
|
||||
|
||||
private static IEnumerable<object[]> GetScenarioObjects() => GetScenarios().Select(scenario => new object[] { scenario });
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue