[2020- 02][debugger] Implementing step through multithreaded code. (#19343)
[mono-project.git] / netcore / run-tests-corefx.ps1
blob91e79452cd2f94d65a438d17e4963f42c3c5a9a8
1 [CmdletBinding(PositionalBinding=$false)]
2 Param(
3 [string]$fxversion,
4 [int]$timeout = -1,
5 [string]$corefxtests = "*",
6 [switch][Alias('h')]$help
9 function Print-Usage() {
10 Write-Host "Common settings:"
11 Write-Host " -fxversion Version passed to dotnet.exe"
12 Write-Host " -timeout Individual test timeout (default -1)"
13 Write-Host " -corefxtests CoreFx test to run, all or individual (defaul *)"
14 Write-Host " -help Print help and exit (short: -h)"
15 Write-Host ""
17 Write-Host "The above arguments can be shortened as much as to be unambiguous."
20 function RunCoreFxTest($_netcore_version, $_timeout, $_testname, $_counter, $_tests_count) {
22 Write-Host ""
23 Write-Host "***************** $($_testname) $($_counter) / $($_tests_count) *********************"
24 Copy-Item -Path "$PSScriptRoot\corefx\restore\corefx-restore.deps.json" -Destination "$PSScriptRoot\corefx\tests\extracted\$_testname\$_testname.deps.json" -Force
25 Copy-Item -Path "$PSScriptRoot\corefx\restore\corefx-restore.runtimeconfig.dev.json" -Destination "$PSScriptRoot\corefx\tests\extracted\$_testname\$_testname.runtimeconfig.dev.json" -Force
26 Copy-Item -Path "$PSScriptRoot\corefx\restore\corefx-restore.dll" -Destination "$PSScriptRoot\corefx\tests\extracted\$_testname\corefx-restore.dll" -Force
27 (Get-Content "$PSScriptRoot\corefx\tests\extracted\$_testname\$_testname.runtimeconfig.json").replace("""5.0.0""", """$_netcore_version""") | Set-Content "$PSScriptRoot\corefx\tests\extracted\$_testname\$_testname.runtimeconfig.json"
29 if ((Test-Path "$PSScriptRoot\corefx\tests\TestResult-$_testname.html" -PathType Leaf)) {
30 Remove-Item -Path "$PSScriptRoot\corefx\tests\TestResult-$_testname.html" -Force
33 if ((Test-Path "$PSScriptRoot\corefx\tests\TestResult-$_testname-netcore-xunit.xml" -PathType Leaf)) {
34 Remove-Item -Path "$PSScriptRoot\corefx\tests\TestResult-$_testname-netcore-xunit.xml" -Force
37 $_process_path = "$PSScriptRoot\dotnet.exe"
38 $_argument_list = "exec"
39 $_argument_list = $_argument_list + " --runtimeconfig $_testname.runtimeconfig.json"
40 $_argument_list = $_argument_list + " --additional-deps $_testname.deps.json"
41 $_argument_list = $_argument_list + " --fx-version ""$_netcore_version"""
42 $_argument_list = $_argument_list + " xunit.console.dll $_testname.dll"
43 $_argument_list = $_argument_list + " -html ""$PSScriptRoot\corefx\tests\TestResult-$_testname.html"""
44 $_argument_list = $_argument_list + " -xml ""$PSScriptRoot\corefx\tests\TestResult-$_testname-netcore-xunit.xml"""
45 $_argument_list = $_argument_list + " -notrait category=nonwindowstests ""@$PSScriptRoot\CoreFX.issues_windows.rsp"" ""@$PSScriptRoot\CoreFX.issues.rsp"""
47 $_process = Start-Process -filePath $_process_path -ArgumentList $_argument_list -workingdirectory "$PSScriptRoot\corefx\tests\extracted\$_testname" -PassThru -NoNewWindow
48 if ($_timeout -eq -1) {
49 Wait-Process -InputObject $_process
50 } else {
51 Wait-Process -InputObject $_process -Timeout $_timeout -ErrorAction SilentlyContinue -ErrorVariable _process_error
53 if ($_process_error) {
54 $_process | kill
55 Write-Host "Error running $_testname, timeout"
56 return 1
60 $_process_exit = $_process.ExitCode
61 if ($_process_exit -ne 0) {
62 Write-Host "Error running $_testname, ExitCode=$($_process_exit)"
63 return $_process_exit
66 # Check for xunit XML file, if missing, treat as failure.
67 if (-Not (Test-Path "$PSScriptRoot\corefx\tests\TestResult-$_testname-netcore-xunit.xml" -PathType Leaf)) {
68 Write-Host "Error running $_testname, missing xunit XML file"
69 return 1
72 return 0
75 $exit_code = 0
76 if ($help) {
77 Print-Usage
78 exit $exit_code
81 if ($corefxtests -eq "*") {
82 if ((Test-Path "$PSScriptRoot\.failures" -PathType Leaf)) {
83 Remove-Item -Path "$PSScriptRoot\.failures" -Force
86 $tests = Get-ChildItem "$PSScriptRoot\corefx\tests\extracted\"
87 $tests_count = $tests.Count
88 $counter = 0
89 for ($i=0; $i -lt $tests_count; $i++) {
90 $counter=$counter + 1
91 $testname=$tests[$i].Name
93 $result = RunCoreFxTest $fxversion $timeout $testname $counter $tests_count
94 if ($result -ne 0) {
95 Add-Content -Path "$PSScriptRoot\.failures" -Value "$testname"
96 $exit_code = 1
99 if (Get-Command "python.exe" -ErrorAction SilentlyContinue) {
100 python.exe "$PSScriptRoot\xunit-summary.py" "$PSScriptRoot\corefx\tests"
101 } else {
102 Write-Host "Couldn't locate python.exe, skiping xunit-summary.py"
104 if ((Test-Path "$PSScriptRoot\.failures" -PathType Leaf)) {
105 Write-Host ""
106 Write-Host "Failures in test suites:"
107 type "$PSScriptRoot\.failures"
108 Write-Host ""
109 $exit_code = 1
111 } else {
112 if (-Not (Test-Path "$PSScriptRoot\corefx\tests\extracted\$corefxtests" -PathType Container)) {
113 Write-Host "Uknown test: $corefxtests"
114 $exit_code = 1
115 } else {
116 $exit_code = RunCoreFxTest $fxversion $timeout $corefxtests 1 1
120 exit $exit_code