Fix watch tests again (#19155)

This commit is contained in:
Brennan 2020-02-20 16:03:48 -08:00 committed by GitHub
parent 3787d7e7f0
commit b125c76d5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 28 deletions

View File

@ -2,28 +2,28 @@
REM Disable "!Foo!" expansions because they break the filter syntax REM Disable "!Foo!" expansions because they break the filter syntax
setlocal disableextensions setlocal disableextensions
set target=%1 REM Use '$' as a variable name prefix to avoid MSBuild variable collisions with these variables
set targetFrameworkIdentifier=%2 set $target=%1
set sdkVersion=%3 set $sdkVersion=%2
set runtimeVersion=%4 set $runtimeVersion=%3
set helixQueue=%5 set $helixQueue=%4
set arch=%6 set $arch=%5
set quarantined=%7 set $quarantined=%6
set DOTNET_HOME=%HELIX_CORRELATION_PAYLOAD%\sdk set DOTNET_HOME=%HELIX_CORRELATION_PAYLOAD%\sdk
set DOTNET_ROOT=%DOTNET_HOME%\%arch% set DOTNET_ROOT=%DOTNET_HOME%\%$arch%
set DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 set DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
set DOTNET_MULTILEVEL_LOOKUP=0 set DOTNET_MULTILEVEL_LOOKUP=0
set DOTNET_CLI_HOME=%HELIX_CORRELATION_PAYLOAD%\home set DOTNET_CLI_HOME=%HELIX_CORRELATION_PAYLOAD%\home
set PATH=%DOTNET_ROOT%;%PATH%;%HELIX_CORRELATION_PAYLOAD%\node\bin set PATH=%DOTNET_ROOT%;%PATH%;%HELIX_CORRELATION_PAYLOAD%\node\bin
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 %arch% -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 %$arch% -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 %arch% -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 %$arch% -Runtime dotnet -Version %$runtimeVersion% -InstallDir %DOTNET_ROOT%"
set HELIX=%helixQueue% 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
REM "ERRORLEVEL is not %ERRORLEVEL%" https://blogs.msdn.microsoft.com/oldnewthing/20080926-00/?p=20743/ REM "ERRORLEVEL is not %ERRORLEVEL%" https://blogs.msdn.microsoft.com/oldnewthing/20080926-00/?p=20743/
if not errorlevel 1 ( if not errorlevel 1 (
@ -34,11 +34,15 @@ if not errorlevel 1 (
set exit_code=0 set exit_code=0
if %$quarantined%==True (
set %$quarantined=true
)
set NONQUARANTINE_FILTER="Flaky:All!=true&Flaky:Helix:All!=true&Flaky:Helix:Queue:All!=true&Flaky:Helix:Queue:%HELIX%!=true" set NONQUARANTINE_FILTER="Flaky:All!=true&Flaky:Helix:All!=true&Flaky:Helix:Queue:All!=true&Flaky:Helix:Queue:%HELIX%!=true"
set QUARANTINE_FILTER="Flaky:All=true|Flaky:Helix:All=true|Flaky:Helix:Queue:All=true|Flaky:Helix:Queue:%HELIX%=true" set QUARANTINE_FILTER="Flaky:All=true|Flaky:Helix:All=true|Flaky:Helix:Queue:All=true|Flaky:Helix:Queue:%HELIX%=true"
if %quarantined%==true ( if %$quarantined%==true (
echo Running quarantined tests. echo Running quarantined tests.
%DOTNET_ROOT%\dotnet vstest %target% --logger:xunit --TestCaseFilter:%QUARANTINE_FILTER% %DOTNET_ROOT%\dotnet vstest %$target% --logger:xunit --TestCaseFilter:%QUARANTINE_FILTER%
if errorlevel 1 ( if errorlevel 1 (
echo Failure in flaky test 1>&2 echo Failure in flaky test 1>&2
REM DO NOT EXIT and DO NOT SET EXIT_CODE to 1 REM DO NOT EXIT and DO NOT SET EXIT_CODE to 1
@ -48,7 +52,7 @@ if %quarantined%==true (
REM only puts the explicit filter traits the user provided in REM only puts the explicit filter traits the user provided in
REM Filter syntax: https://github.com/Microsoft/vstest-docs/blob/master/docs/filter.md REM Filter syntax: https://github.com/Microsoft/vstest-docs/blob/master/docs/filter.md
echo Running non-quarantined tests. echo Running non-quarantined tests.
%DOTNET_ROOT%\dotnet vstest %target% --logger:xunit --TestCaseFilter:%NONQUARANTINE_FILTER% %DOTNET_ROOT%\dotnet vstest %$target% --logger:xunit --TestCaseFilter:%NONQUARANTINE_FILTER%
if errorlevel 1 ( if errorlevel 1 (
echo Failure in non-flaky test 1>&2 echo Failure in non-flaky test 1>&2
set exit_code=1 set exit_code=1

View File

@ -106,7 +106,7 @@ Usage: dotnet msbuild /t:Helix src/MyTestProject.csproj
<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) $(TargetFrameworkIdentifier) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppRuntimeVersion) $(_HelixFriendlyNameTargetQueue) $(TargetArchitecture) $(RunQuarantinedTests)</Command> <Command Condition="$(IsWindowsHelixQueue)">call runtests.cmd $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppRuntimeVersion) $(_HelixFriendlyNameTargetQueue) $(TargetArchitecture) $(RunQuarantinedTests)</Command>
<Command Condition="!$(IsWindowsHelixQueue)">./runtests.sh $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppRuntimeVersion) $(_HelixFriendlyNameTargetQueue) $(TargetArchitecture) $(RunQuarantinedTests)</Command> <Command Condition="!$(IsWindowsHelixQueue)">./runtests.sh $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppRuntimeVersion) $(_HelixFriendlyNameTargetQueue) $(TargetArchitecture) $(RunQuarantinedTests)</Command>
<Command Condition="$(HelixCommand) != ''">$(HelixCommand)</Command> <Command Condition="$(HelixCommand) != ''">$(HelixCommand)</Command>
<Timeout>$(HelixTimeout)</Timeout> <Timeout>$(HelixTimeout)</Timeout>

View File

@ -72,11 +72,12 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests
_process.ErrorDataReceived += OnData; _process.ErrorDataReceived += OnData;
_process.Exited += OnExit; _process.Exited += OnExit;
_logger.WriteLine($"{DateTime.Now}: starting process: '{_process.StartInfo.FileName} {_process.StartInfo.Arguments}'");
_process.Start(); _process.Start();
_started = true; _started = true;
_process.BeginErrorReadLine(); _process.BeginErrorReadLine();
_process.BeginOutputReadLine(); _process.BeginOutputReadLine();
_logger.WriteLine($"{DateTime.Now}: process start: '{_process.StartInfo.FileName} {_process.StartInfo.Arguments}'"); _logger.WriteLine($"{DateTime.Now}: process started: '{_process.StartInfo.FileName} {_process.StartInfo.Arguments}'");
} }
public async Task<string> GetOutputLineAsync(string message, TimeSpan timeout) public async Task<string> GetOutputLineAsync(string message, TimeSpan timeout)

View File

@ -149,15 +149,6 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests
File.WriteAllText(Path.Combine(WorkFolder, "Directory.Build.targets"), "<Project />"); File.WriteAllText(Path.Combine(WorkFolder, "Directory.Build.targets"), "<Project />");
} }
private string GetMetadata(string key)
{
return typeof(ProjectToolScenario)
.Assembly
.GetCustomAttributes<AssemblyMetadataAttribute>()
.First(a => string.Equals(a.Key, key, StringComparison.Ordinal))
.Value;
}
public void Dispose() public void Dispose()
{ {
try try

View File

@ -104,12 +104,15 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests
WorkingDirectory = SourceDirectory, WorkingDirectory = SourceDirectory,
EnvironmentVariables = EnvironmentVariables =
{ {
["DOTNET_CLI_CONTEXT_VERBOSE"] = bool.TrueString,
["DOTNET_USE_POLLING_FILE_WATCHER"] = UsePollingWatcher.ToString(), ["DOTNET_USE_POLLING_FILE_WATCHER"] = UsePollingWatcher.ToString(),
["DOTNET_ROOT"] = Directory.GetParent(dotnetPath).FullName,
}, },
}; };
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("helix")))
{
spec.EnvironmentVariables["DOTNET_ROOT"] = Directory.GetParent(dotnetPath).FullName;
}
Process = new AwaitableProcess(spec, _logger); Process = new AwaitableProcess(spec, _logger);
Process.Start(); Process.Start();
} }