filter tests

This commit is contained in:
MilenaHristova 2023-03-03 10:59:00 +01:00
parent e944fdc2de
commit 55430a2b54
3 changed files with 11 additions and 32 deletions

View file

@ -102,9 +102,9 @@ jobs:
envArgs+=" -e SMOKE_TESTS_MSFT_SDK_TARBALL_PATH=$(Pipeline.Workspace)/Artifacts/$msftSdkTarballName"
envArgs+=" -e SMOKE_TESTS_SDK_TARBALL_PATH=$(Pipeline.Workspace)/Artifacts/$sdkTarballName"
envArgs+=" -e SMOKE_TESTS_SOURCEBUILT_ARTIFACTS_PATH= "
envArgs+=" -e SMOKE_TESTS_EXCLUDE_OMNISHARP=true -e SMOKE_TESTS_WARN_SDK_CONTENT_DIFFS=true -e SMOKE_TESTS_RUNNING_IN_CI=true -e SMOKE_TESTS_TARGET_RID=${{ parameters.targetRid }} -e SMOKE_TESTS_PORTABLE_RID=linux-x64 -e SMOKE_TESTS_CUSTOM_PACKAGES_PATH= -e SMOKE_TESTS_INCLUDE=CompareMsftToSb"
envArgs+=" -e SMOKE_TESTS_EXCLUDE_OMNISHARP=true -e SMOKE_TESTS_WARN_SDK_CONTENT_DIFFS=true -e SMOKE_TESTS_RUNNING_IN_CI=true -e SMOKE_TESTS_TARGET_RID=${{ parameters.targetRid }} -e SMOKE_TESTS_PORTABLE_RID=linux-x64 -e SMOKE_TESTS_CUSTOM_PACKAGES_PATH= "
.dotnet/dotnet test $(Build.SourcesDirectory)/src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/Microsoft.DotNet.SourceBuild.SmokeTests.csproj $envArgs --logger:'trx;LogFileName=$(Agent.JobName)_SDKComparisonTests.trx' --logger:'console;verbosity=detailed'
.dotnet/dotnet test $(Build.SourcesDirectory)/src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/Microsoft.DotNet.SourceBuild.SmokeTests.csproj --filter "FullyQualifiedName=Microsoft.DotNet.SourceBuild.SmokeTests.SdkContentTests.CompareMsftToSb" $envArgs --logger:'trx;LogFileName=$(Agent.JobName)_SDKComparisonTests.trx' --logger:'console;verbosity=detailed'
displayName: Run Tests
workingDirectory: $(Build.SourcesDirectory)

View file

@ -3,8 +3,6 @@
// 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;
@ -14,29 +12,14 @@ namespace Microsoft.DotNet.SourceBuild.SmokeTests;
/// </summary>
internal class SkippableFactAttribute : FactAttribute
{
public SkippableFactAttribute([CallerMemberName] string name = "") =>
CheckIncluded(name, (skip) => Skip = skip);
public SkippableFactAttribute(string envName, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false) =>
CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, envName);
public SkippableFactAttribute(string envName, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false, [CallerMemberName] string testName = "") =>
CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, testName, envName);
public SkippableFactAttribute(string[] envNames, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false) =>
CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, 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)
public static void CheckEnvs(bool skipOnNullOrWhiteSpace, bool skipOnTrue, Action<string> setSkip, params string[] envNames)
{
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);

View file

@ -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.Runtime.CompilerServices;
using Xunit;
namespace Microsoft.DotNet.SourceBuild.SmokeTests;
@ -12,12 +11,9 @@ namespace Microsoft.DotNet.SourceBuild.SmokeTests;
/// </summary>
internal class SkippableTheoryAttribute : TheoryAttribute
{
public SkippableTheoryAttribute([CallerMemberName] string testName = "") =>
SkippableFactAttribute.CheckIncluded(testName, (skip) => Skip = skip);
public SkippableTheoryAttribute(string envName, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false) =>
SkippableFactAttribute.CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, envName);
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);
public SkippableTheoryAttribute(string[] envNames, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false) =>
SkippableFactAttribute.CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, envNames);
}