Skip to content

Commit 435867e

Browse files
authored
Add ability to skip tests on specific helix queues (#8231)
1 parent cdd6e31 commit 435867e

File tree

5 files changed

+16
-9
lines changed

5 files changed

+16
-9
lines changed

eng/helix/vstest/runtests.cmd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
set target=%1
22
set sdkVersion=%2
33
set runtimeVersion=%3
4+
set helixQueue=%4
45

56
set DOTNET_HOME=%HELIX_CORRELATION_PAYLOAD%\sdk
67
set DOTNET_ROOT=%DOTNET_HOME%\x64
@@ -13,7 +14,7 @@ set PATH=%DOTNET_ROOT%;%PATH%
1314
powershell.exe -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -useb 'https://dot.net/v1/dotnet-install.ps1'))) -Architecture x64 -Version %sdkVersion% -InstallDir %DOTNET_ROOT%"
1415
powershell.exe -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -useb 'https://dot.net/v1/dotnet-install.ps1'))) -Architecture x64 -Runtime dotnet -Version %runtimeVersion% -InstallDir %DOTNET_ROOT%"
1516

16-
set HELIX=true
17+
set HELIX=%helixQueue%
1718

1819
%DOTNET_ROOT%\dotnet vstest %target% -lt >discovered.txt
1920
find /c "Exception thrown" discovered.txt

eng/helix/vstest/runtests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export DOTNET_MULTILEVEL_LOOKUP=0
5858
# Avoid contaminating userprofiles
5959
export DOTNET_CLI_HOME="$HELIX_CORRELATION_PAYLOAD/home"
6060

61-
export helix="true"
61+
export helix="$4"
6262

6363
$DOTNET_ROOT/dotnet vstest $1 -lt >discovered.txt
6464
if grep -q "Exception thrown" discovered.txt; then

eng/helix/xunit/runtests.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
set target=%1
2-
set helix=true
2+
set helix=%4
33
xunit.console.exe %target% -xml testResults.xml

eng/targets/Helix.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@
6464
<TestAssembly>$(TargetFileName)</TestAssembly>
6565
<PreCommands>@(HelixPreCommand)</PreCommands>
6666
<PostCommands>@(HelixPostCommand)</PostCommands>
67-
<Command Condition="$(IsWindowsHelixQueue)">call runtests.cmd $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppPackageVersion)</Command>
68-
<Command Condition="!$(IsWindowsHelixQueue)">./runtests.sh $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppPackageVersion)</Command>
67+
<Command Condition="$(IsWindowsHelixQueue)">call runtests.cmd $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppPackageVersion) $(HelixTargetQueue)</Command>
68+
<Command Condition="!$(IsWindowsHelixQueue)">./runtests.sh $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppPackageVersion) $(HelixTargetQueue)</Command>
6969
<Timeout>$(HelixTimeout)</Timeout>
7070
</HelixWorkItem>
7171
</ItemGroup>

src/Shared/test/SkipOnHelixAttribute.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
5+
using System.Linq;
56

67
namespace Microsoft.AspNetCore.Testing.xunit
78
{
89
/// <summary>
9-
/// Skip test if a given environment variable is not enabled. To enable the test, set environment variable
10-
/// to "true" for the test process.
10+
/// Skip test if running on helix (or a particular helix queue).
1111
/// </summary>
1212
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false)]
1313
public class SkipOnHelixAttribute : Attribute, ITestCondition
@@ -16,10 +16,14 @@ public bool IsMet
1616
{
1717
get
1818
{
19-
return !OnHelix();
19+
var skip = OnHelix() && (Queues == null || Queues.ToLowerInvariant().Split(";").Contains(GetTargetHelixQueue().ToLowerInvariant()));
20+
return !skip;
2021
}
2122
}
2223

24+
// Queues that should be skipped on, i.e. "Windows.10.Amd64.ClientRS4.VS2017.Open;OSX.1012.Amd64.Open"
25+
public string Queues { get; set; }
26+
2327
public string SkipReason
2428
{
2529
get
@@ -28,6 +32,8 @@ public string SkipReason
2832
}
2933
}
3034

31-
public static bool OnHelix() => string.Equals(Environment.GetEnvironmentVariable("helix"), "true", StringComparison.OrdinalIgnoreCase);
35+
public static bool OnHelix() => !string.IsNullOrEmpty(GetTargetHelixQueue());
36+
37+
public static string GetTargetHelixQueue() => Environment.GetEnvironmentVariable("helix");
3238
}
3339
}

0 commit comments

Comments
 (0)