Skip to content

Commit b125c76

Browse files
Fix watch tests again (#19155)
1 parent 3787d7e commit b125c76

File tree

5 files changed

+27
-28
lines changed

5 files changed

+27
-28
lines changed

eng/helix/content/runtests.cmd

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,28 @@
22
REM Disable "!Foo!" expansions because they break the filter syntax
33
setlocal disableextensions
44

5-
set target=%1
6-
set targetFrameworkIdentifier=%2
7-
set sdkVersion=%3
8-
set runtimeVersion=%4
9-
set helixQueue=%5
10-
set arch=%6
11-
set quarantined=%7
5+
REM Use '$' as a variable name prefix to avoid MSBuild variable collisions with these variables
6+
set $target=%1
7+
set $sdkVersion=%2
8+
set $runtimeVersion=%3
9+
set $helixQueue=%4
10+
set $arch=%5
11+
set $quarantined=%6
1212

1313
set DOTNET_HOME=%HELIX_CORRELATION_PAYLOAD%\sdk
14-
set DOTNET_ROOT=%DOTNET_HOME%\%arch%
14+
set DOTNET_ROOT=%DOTNET_HOME%\%$arch%
1515
set DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
1616
set DOTNET_MULTILEVEL_LOOKUP=0
1717
set DOTNET_CLI_HOME=%HELIX_CORRELATION_PAYLOAD%\home
1818

1919
set PATH=%DOTNET_ROOT%;%PATH%;%HELIX_CORRELATION_PAYLOAD%\node\bin
2020

21-
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%"
22-
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%"
21+
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%"
22+
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%"
2323

24-
set HELIX=%helixQueue%
24+
set HELIX=%$helixQueue%
2525

26-
%DOTNET_ROOT%\dotnet vstest %target% -lt >discovered.txt
26+
%DOTNET_ROOT%\dotnet vstest %$target% -lt >discovered.txt
2727
find /c "Exception thrown" discovered.txt
2828
REM "ERRORLEVEL is not %ERRORLEVEL%" https://blogs.msdn.microsoft.com/oldnewthing/20080926-00/?p=20743/
2929
if not errorlevel 1 (
@@ -34,11 +34,15 @@ if not errorlevel 1 (
3434

3535
set exit_code=0
3636

37+
if %$quarantined%==True (
38+
set %$quarantined=true
39+
)
40+
3741
set NONQUARANTINE_FILTER="Flaky:All!=true&Flaky:Helix:All!=true&Flaky:Helix:Queue:All!=true&Flaky:Helix:Queue:%HELIX%!=true"
3842
set QUARANTINE_FILTER="Flaky:All=true|Flaky:Helix:All=true|Flaky:Helix:Queue:All=true|Flaky:Helix:Queue:%HELIX%=true"
39-
if %quarantined%==true (
43+
if %$quarantined%==true (
4044
echo Running quarantined tests.
41-
%DOTNET_ROOT%\dotnet vstest %target% --logger:xunit --TestCaseFilter:%QUARANTINE_FILTER%
45+
%DOTNET_ROOT%\dotnet vstest %$target% --logger:xunit --TestCaseFilter:%QUARANTINE_FILTER%
4246
if errorlevel 1 (
4347
echo Failure in flaky test 1>&2
4448
REM DO NOT EXIT and DO NOT SET EXIT_CODE to 1
@@ -48,7 +52,7 @@ if %quarantined%==true (
4852
REM only puts the explicit filter traits the user provided in
4953
REM Filter syntax: https://github.com/Microsoft/vstest-docs/blob/master/docs/filter.md
5054
echo Running non-quarantined tests.
51-
%DOTNET_ROOT%\dotnet vstest %target% --logger:xunit --TestCaseFilter:%NONQUARANTINE_FILTER%
55+
%DOTNET_ROOT%\dotnet vstest %$target% --logger:xunit --TestCaseFilter:%NONQUARANTINE_FILTER%
5256
if errorlevel 1 (
5357
echo Failure in non-flaky test 1>&2
5458
set exit_code=1

eng/targets/Helix.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Usage: dotnet msbuild /t:Helix src/MyTestProject.csproj
106106
<TestAssembly>$(TargetFileName)</TestAssembly>
107107
<PreCommands>@(HelixPreCommand)</PreCommands>
108108
<PostCommands>@(HelixPostCommand)</PostCommands>
109-
<Command Condition="$(IsWindowsHelixQueue)">call runtests.cmd $(TargetFileName) $(TargetFrameworkIdentifier) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppRuntimeVersion) $(_HelixFriendlyNameTargetQueue) $(TargetArchitecture) $(RunQuarantinedTests)</Command>
109+
<Command Condition="$(IsWindowsHelixQueue)">call runtests.cmd $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppRuntimeVersion) $(_HelixFriendlyNameTargetQueue) $(TargetArchitecture) $(RunQuarantinedTests)</Command>
110110
<Command Condition="!$(IsWindowsHelixQueue)">./runtests.sh $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppRuntimeVersion) $(_HelixFriendlyNameTargetQueue) $(TargetArchitecture) $(RunQuarantinedTests)</Command>
111111
<Command Condition="$(HelixCommand) != ''">$(HelixCommand)</Command>
112112
<Timeout>$(HelixTimeout)</Timeout>

src/Tools/dotnet-watch/test/AwaitableProcess.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,12 @@ public void Start()
7272
_process.ErrorDataReceived += OnData;
7373
_process.Exited += OnExit;
7474

75+
_logger.WriteLine($"{DateTime.Now}: starting process: '{_process.StartInfo.FileName} {_process.StartInfo.Arguments}'");
7576
_process.Start();
7677
_started = true;
7778
_process.BeginErrorReadLine();
7879
_process.BeginOutputReadLine();
79-
_logger.WriteLine($"{DateTime.Now}: process start: '{_process.StartInfo.FileName} {_process.StartInfo.Arguments}'");
80+
_logger.WriteLine($"{DateTime.Now}: process started: '{_process.StartInfo.FileName} {_process.StartInfo.Arguments}'");
8081
}
8182

8283
public async Task<string> GetOutputLineAsync(string message, TimeSpan timeout)

src/Tools/dotnet-watch/test/Scenario/ProjectToolScenario.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,6 @@ private void CreateTestDirectory()
149149
File.WriteAllText(Path.Combine(WorkFolder, "Directory.Build.targets"), "<Project />");
150150
}
151151

152-
private string GetMetadata(string key)
153-
{
154-
return typeof(ProjectToolScenario)
155-
.Assembly
156-
.GetCustomAttributes<AssemblyMetadataAttribute>()
157-
.First(a => string.Equals(a.Key, key, StringComparison.Ordinal))
158-
.Value;
159-
}
160-
161152
public void Dispose()
162153
{
163154
try

src/Tools/dotnet-watch/test/Scenario/WatchableApp.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,15 @@ public void Start(IEnumerable<string> arguments, [CallerMemberName] string name
104104
WorkingDirectory = SourceDirectory,
105105
EnvironmentVariables =
106106
{
107-
["DOTNET_CLI_CONTEXT_VERBOSE"] = bool.TrueString,
108107
["DOTNET_USE_POLLING_FILE_WATCHER"] = UsePollingWatcher.ToString(),
109-
["DOTNET_ROOT"] = Directory.GetParent(dotnetPath).FullName,
110108
},
111109
};
112110

111+
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("helix")))
112+
{
113+
spec.EnvironmentVariables["DOTNET_ROOT"] = Directory.GetParent(dotnetPath).FullName;
114+
}
115+
113116
Process = new AwaitableProcess(spec, _logger);
114117
Process.Start();
115118
}

0 commit comments

Comments
 (0)