Skip to content

Commit e9758e2

Browse files
committed
Hot patch vstest.console to not terminate processes
1 parent d0ff389 commit e9758e2

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

build/PatchVSTestConsole.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Replaces 'ldc.i4.s 100' with 'ldc.i4.m1, nop' to fix incorrect termination of the test host
2+
# https://github.com/Microsoft/vstest/issues/1900
3+
4+
$file = Join-Path $PSScriptRoot '..\Tools\dotnetcli\sdk\2.1.503\Microsoft.TestPlatform.CrossPlatEngine.dll';
5+
$bytes = [System.IO.File]::ReadAllBytes($file);
6+
If ($bytes[0xE259] -eq 0x15 -and $bytes[0xE25A] -eq 0x00) {
7+
# Already patched
8+
Exit 0
9+
}
10+
11+
If ($bytes[0xE259] -ne 0x1F -or $bytes[0xE25A] -ne 0x64) {
12+
# Unexpected file
13+
Exit 1
14+
}
15+
16+
$bytes[0xE259] = 0x15;
17+
$bytes[0xE25A] = 0x00;
18+
[System.IO.File]::WriteAllBytes($file, $bytes);

build/ci/phase-template.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ phases:
4040
- ${{ if eq(parameters.name, 'MacOS') }}:
4141
- script: brew update && brew install libomp mono-libgdiplus gettext && brew link gettext --force
4242
displayName: Install runtime dependencies
43+
- powershell: $(Build.SourcesDirectory)/build/PatchVSTestConsole.ps1
44+
displayName: Hot patch vstest.console
45+
condition: and(succeeded(), eq(variables._codeCoverage, 'true'))
4346
- script: $(_buildScript) -$(_configuration) -runtests -coverage=$(_codeCoverage)
4447
displayName: Run Tests.
4548
- script: $(Build.SourcesDirectory)/Tools/dotnetcli/dotnet msbuild build/Codecoverage.proj /p:CodeCovToken=$(CODECOV_TOKEN)

0 commit comments

Comments
 (0)