Skip to content
代码片段 群组 项目
未验证 提交 435867e8 编辑于 作者: Hao Kung's avatar Hao Kung 提交者: GitHub
浏览文件

Add ability to skip tests on specific helix queues (#8231)

上级 cdd6e319
No related branches found
No related tags found
无相关合并请求
set target=%1 set target=%1
set sdkVersion=%2 set sdkVersion=%2
set runtimeVersion=%3 set runtimeVersion=%3
set helixQueue=%4
set DOTNET_HOME=%HELIX_CORRELATION_PAYLOAD%\sdk set DOTNET_HOME=%HELIX_CORRELATION_PAYLOAD%\sdk
set DOTNET_ROOT=%DOTNET_HOME%\x64 set DOTNET_ROOT=%DOTNET_HOME%\x64
...@@ -13,7 +14,7 @@ set PATH=%DOTNET_ROOT%;%PATH% ...@@ -13,7 +14,7 @@ set PATH=%DOTNET_ROOT%;%PATH%
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%" 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%"
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%" 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%"
set HELIX=true set HELIX=%helixQueue%
%DOTNET_ROOT%\dotnet vstest %target% -lt >discovered.txt %DOTNET_ROOT%\dotnet vstest %target% -lt >discovered.txt
find /c "Exception thrown" discovered.txt find /c "Exception thrown" discovered.txt
......
...@@ -58,7 +58,7 @@ export DOTNET_MULTILEVEL_LOOKUP=0 ...@@ -58,7 +58,7 @@ export DOTNET_MULTILEVEL_LOOKUP=0
# Avoid contaminating userprofiles # Avoid contaminating userprofiles
export DOTNET_CLI_HOME="$HELIX_CORRELATION_PAYLOAD/home" export DOTNET_CLI_HOME="$HELIX_CORRELATION_PAYLOAD/home"
export helix="true" export helix="$4"
$DOTNET_ROOT/dotnet vstest $1 -lt >discovered.txt $DOTNET_ROOT/dotnet vstest $1 -lt >discovered.txt
if grep -q "Exception thrown" discovered.txt; then if grep -q "Exception thrown" discovered.txt; then
......
set target=%1 set target=%1
set helix=true set helix=%4
xunit.console.exe %target% -xml testResults.xml xunit.console.exe %target% -xml testResults.xml
...@@ -64,8 +64,8 @@ ...@@ -64,8 +64,8 @@
<TestAssembly>$(TargetFileName)</TestAssembly> <TestAssembly>$(TargetFileName)</TestAssembly>
<PreCommands>@(HelixPreCommand)</PreCommands> <PreCommands>@(HelixPreCommand)</PreCommands>
<PostCommands>@(HelixPostCommand)</PostCommands> <PostCommands>@(HelixPostCommand)</PostCommands>
<Command Condition="$(IsWindowsHelixQueue)">call runtests.cmd $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppPackageVersion)</Command> <Command Condition="$(IsWindowsHelixQueue)">call runtests.cmd $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppPackageVersion) $(HelixTargetQueue)</Command>
<Command Condition="!$(IsWindowsHelixQueue)">./runtests.sh $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppPackageVersion)</Command> <Command Condition="!$(IsWindowsHelixQueue)">./runtests.sh $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppPackageVersion) $(HelixTargetQueue)</Command>
<Timeout>$(HelixTimeout)</Timeout> <Timeout>$(HelixTimeout)</Timeout>
</HelixWorkItem> </HelixWorkItem>
</ItemGroup> </ItemGroup>
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
using System.Linq;
namespace Microsoft.AspNetCore.Testing.xunit namespace Microsoft.AspNetCore.Testing.xunit
{ {
/// <summary> /// <summary>
/// Skip test if a given environment variable is not enabled. To enable the test, set environment variable /// Skip test if running on helix (or a particular helix queue).
/// to "true" for the test process.
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false)] [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false)]
public class SkipOnHelixAttribute : Attribute, ITestCondition public class SkipOnHelixAttribute : Attribute, ITestCondition
...@@ -16,10 +16,14 @@ namespace Microsoft.AspNetCore.Testing.xunit ...@@ -16,10 +16,14 @@ namespace Microsoft.AspNetCore.Testing.xunit
{ {
get get
{ {
return !OnHelix(); var skip = OnHelix() && (Queues == null || Queues.ToLowerInvariant().Split(";").Contains(GetTargetHelixQueue().ToLowerInvariant()));
return !skip;
} }
} }
// Queues that should be skipped on, i.e. "Windows.10.Amd64.ClientRS4.VS2017.Open;OSX.1012.Amd64.Open"
public string Queues { get; set; }
public string SkipReason public string SkipReason
{ {
get get
...@@ -28,6 +32,8 @@ namespace Microsoft.AspNetCore.Testing.xunit ...@@ -28,6 +32,8 @@ namespace Microsoft.AspNetCore.Testing.xunit
} }
} }
public static bool OnHelix() => string.Equals(Environment.GetEnvironmentVariable("helix"), "true", StringComparison.OrdinalIgnoreCase); public static bool OnHelix() => !string.IsNullOrEmpty(GetTargetHelixQueue());
public static string GetTargetHelixQueue() => Environment.GetEnvironmentVariable("helix");
} }
} }
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册