Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit d3772d9

Browse files
authored
Windows CoreFX CI (#18365)
* Add test list CL switch * End-To-End Test Run on Windows * Cleanup * MAX_PATH Workaround * Set Execution directory for CoreFX tests * Add All CoreFX PR Tests * Add test dependencies * Add extra dependencies * Add parallel test execution * Disable OuterLoop tests and System.Data.SqlClient.* tests * Initialize maximum degree of parallelization to Environment.ProcessCount * Remove unnecessary cli option * Update Dependencies * Add "enabled" property to tests * Remove exclusions due to TestUtilities mismatch * Add capability to run all tests for running Helix test lists directly * Refactor build script to build testhost when skipping managed tests * Disable failing System.Threading.Tests.EventWaitHandleTests.Ctor_InvalidMode * Add switch to skip native test build * Add testing documentation * Don't run tests marked as "disabled" when running all available tests * Add switch to build only testhost and remove Core_Root_Stage * Clean up TopN.CoreFX.Windows.issues.json * Refactor build-test.cmd * PR feedback - build pipeline and documentation * PR Feedback - Test Helper headers and comments * Fix buildtesthost option for only building CoreFX test dependencies * Disable intermittently failing test DrawBezier_PointFs
1 parent eeb9e89 commit d3772d9

19 files changed

+2682
-27
lines changed

Documentation/building/testing-with-corefx.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Testing with CoreFX
33

44
It may be valuable to use CoreFX tests to validate your changes to CoreCLR or mscorlib.
55

6+
## Building CoreFX against CoreCLR
67
**NOTE:** The `BUILDTOOLS_OVERRIDE_RUNTIME` property no longer works.
78

89
To run CoreFX tests with an updated System.Private.Corelib.dll, [use these instructions](https://github.com/dotnet/corefx/blob/master/Documentation/project-docs/developer-guide.md#testing-with-private-coreclr-bits).
@@ -27,3 +28,74 @@ Use the following instructions to test a change to the dotnet/coreclr repo using
2728

2829
[run-corefx-tests.py](https://github.com/dotnet/coreclr/blob/master/tests/scripts/run-corefx-tests.py) will clone dotnet/corefx and run steps 2-4 above automatically. It is primarily intended to be run by the dotnet/coreclr CI system, but it might provide a useful reference or shortcut for individuals running the tests locally.
2930

31+
## Using the built CoreCLR testhost
32+
**These instructions are currently Windows only.**
33+
34+
Instead of copying CoreCLR binaries you can also test your changes with an existing CoreFX build or CoreCLR's CI assemblies
35+
36+
### Locally-built CoreFX
37+
Once you have finished steps 1, 2. and 4. above execute the following instructions to test your local CLR changes with the built-CoreFX changes.
38+
39+
1. From `<coreclr_root>` run `build-test.cmd <arch> <build_type> skipmanaged` to generate the test host.
40+
2. Navigate to `<corefx_root>\bin\tests\` and then the test you would like to run
41+
3. Run
42+
43+
```cmd
44+
<coreclr_root>\bin\<os>.<arch>.<build_type>\testhost\dotnet.exe <corefx_root>\bin\tests\<testname>\xunit.console.netcore.exe <testname>.dll
45+
```
46+
followed by any extra command-line arguments.
47+
48+
For example to run .NET Core Windows tests from System.Collections.Tests with an x64 Release build of CoreCLR.
49+
```
50+
pushd C:\corefx\bin\tests\System.Collections.Tests
51+
C:\coreclr\bin\tests\Windows_NT.x64.Release\testhost\dotnet.exe .\xunit.console.netcore.exe .\System.Collections.Tests.dll -notrait category=nonnetcoretests -notrait category=nonwindowstests
52+
```
53+
54+
### CI Script
55+
CoreCLR has an alternative way to run CoreFX tests, built for PR CI jobs. To run tests against pre-built binaries you can execute the following from the CoreCLR repo root:
56+
57+
1. `.\build.cmd <arch> <build_type>`
58+
2. `.\build-test.cmd <arch> <build_type> skipmanaged` - generates the test host
59+
3. `.\tests\runtest.cmd <arch> <build_type> corefxtests|corefxtestsall` - runs CoreFX tests
60+
61+
CoreFXTests - runs all tests defined in TopN.Windows.CoreFX.issues.json or the test list specified with the argument `CoreFXTestList`
62+
CoreFXTestsAll - runs all tests available in the test list found at the URL in `.\coreclr\tests\CoreFX\CoreFXTestListURL.txt`.
63+
64+
### Helix Testing
65+
To use Helix-built binaries, substitute the URL in `.\coreclr\tests\CoreFX\CoreFXTestListURL.txt` with one acquired from a Helix test run and run the commands above.
66+
67+
### Test List Format
68+
The tests defined in TopN.Windows.CoreFX.issues.json or the test list specified with the argument `CoreFXTestList` should conform to the following format -
69+
```json
70+
{
71+
"name": "<Fully Qualified Assembly Name>", //e.g. System.Collections.Concurrent.Tests
72+
"enabled": true|false, // Defines whether a test assembly should be run. If set to false any tests with the same name will not be run even if corefxtestsall is specified
73+
"exclusions": {
74+
"namespaces": // Can be null
75+
[
76+
{
77+
"name": "System.Collections.Concurrent.Tests", // All test methods under this namespace will be skipped
78+
"reason": "<Reason for exclusion>" // This should be a link to the GitHub issue describing the problem
79+
}
80+
]
81+
"classes": // Can be null
82+
[
83+
{
84+
"name": "System.Collections.Concurrent.Tests.ConcurrentDictionaryTests", // All test methods in this class will be skipped
85+
"reason": "<Reason for exclusion>"
86+
}
87+
]
88+
"methods": // Can be null
89+
[
90+
{
91+
"name": "System.Collections.Concurrent.Tests.ConcurrentDictionaryTests.TestAddNullValue_IDictionary_ReferenceType_null",
92+
"reason": "<Reason for exclusion>"
93+
},
94+
{
95+
"name": "System.Collections.Concurrent.Tests.ConcurrentDictionaryTests.TestAddNullValue_IDictionary_ValueType_null_add",
96+
"reason": "<Reason for exclusion>"
97+
}
98+
]
99+
}
100+
}
101+
```

build-test.cmd

Lines changed: 61 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ set processedArgs=
4646
set __unprocessedBuildArgs=
4747
set __RunArgs=
4848
set __BuildAgainstPackagesArg=
49+
set __SkipRestorePackages=
50+
set __SkipManaged=
51+
set __SkipNative=
4952
set __RuntimeId=
5053
set __ZipTests=
5154
set __TargetsWindows=1
@@ -74,8 +77,11 @@ if /i "%1" == "release" (set __BuildType=Release&set processedArgs
7477
if /i "%1" == "checked" (set __BuildType=Checked&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
7578

7679
if /i "%1" == "skipmanaged" (set __SkipManaged=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
80+
if /i "%1" == "skipnative" (set __SkipNative=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
81+
if /i "%1" == "buildtesthostonly" (set __SkipNative=1&set __SkipManaged=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
7782
if /i "%1" == "toolset_dir" (set __ToolsetDir=%2&set __PassThroughArgs=%__PassThroughArgs% %2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop)
7883
if /i "%1" == "buildagainstpackages" (set __ZipTests=1&set __BuildAgainstPackagesArg=-BuildTestsAgainstPackages&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
84+
if /i "%1" == "skiprestorepackages" (set __SkipRestorePackages=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
7985
if /i "%1" == "ziptests" (set __ZipTests=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
8086
if /i "%1" == "crossgen" (set __DoCrossgen=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
8187
if /i "%1" == "runtimeid" (set __RuntimeId=%2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop)
@@ -160,6 +166,8 @@ REM ============================================================================
160166
call "%__TestDir%\setup-stress-dependencies.cmd" /arch %__BuildArch% /outputdir %__BinDir%
161167
@if defined _echo @echo on
162168

169+
if defined __SkipNative goto skipnative
170+
163171
REM =========================================================================================
164172
REM ===
165173
REM === Native test build section
@@ -224,8 +232,7 @@ if errorlevel 1 (
224232
:skipnative
225233

226234
set "__TestWorkingDir=%__RootBinDir%\tests\%__BuildOS%.%__BuildArch%.%__BuildType%"
227-
228-
if not defined __BuildAgainstPackagesArg goto SkipRestoreProduct
235+
if "%__SkipRestorePackages%" == 1 goto SkipRestoreProduct
229236
REM =========================================================================================
230237
REM ===
231238
REM === Restore product binaries from packages
@@ -245,6 +252,7 @@ set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
245252

246253
call "%__ProjectDir%\run.cmd" build -Project=%__ProjectDir%\tests\build.proj -BatchRestorePackages -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %__unprocessedBuildArgs%
247254

255+
if not defined __BuildAgainstPackagesArg goto SkipRestoreProduct
248256
set __BuildLogRootName=Tests_GenerateRuntimeLayout
249257
set __BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log
250258
set __BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn
@@ -263,7 +271,7 @@ echo %__MsgPrefix% Restored CoreCLR product from packages
263271

264272
:SkipRestoreProduct
265273

266-
if defined __SkipManaged exit /b 0
274+
if defined __SkipManaged goto SkipManagedBuild
267275

268276
REM =========================================================================================
269277
REM ===
@@ -316,6 +324,7 @@ for /l %%G in (1, 1, %__BuildLoopCount%) do (
316324
set __AppendToLog=true
317325
)
318326

327+
:SkipManagedBuild
319328
REM Prepare the Test Drop
320329
REM Cleans any NI from the last run
321330
powershell -NoProfile "Get-ChildItem -path %__TestWorkingDir% -Include '*.ni.*' -Recurse -Force | Remove-Item -force"
@@ -344,46 +353,44 @@ if defined __BuildAgainstPackagesArg (
344353
)
345354
)
346355

347-
echo %__MsgPrefix%Creating test wrappers...
348-
349-
set RuntimeIdArg=
350-
set TargetsWindowsArg=
351-
352-
if defined __RuntimeId (
353-
set RuntimeIdArg=-RuntimeID="%__RuntimeId%"
354-
)
355-
356-
if "%__TargetsWindows%"=="1" (
357-
set TargetsWindowsArg=-TargetsWindows=true
358-
) else if "%__TargetsWindows%"=="0" (
359-
set TargetsWindowsArg=-TargetsWindows=false
360-
)
356+
REM =========================================================================================
357+
REM ===
358+
REM === Create the test overlay
359+
REM ===
360+
REM =========================================================================================
361+
echo %__MsgPrefix%Creating test overlay...
361362

362-
set __BuildLogRootName=Tests_XunitWrapper
363+
set __BuildLogRootName=Tests_Overlay_Managed
363364
set __BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log
364365
set __BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn
365366
set __BuildErr=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.err
366367
set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
367368
set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
368369
set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
369370

370-
call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\runtest.proj -BuildWrappers -MsBuildEventLogging=" " -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %TargetsWindowsArg% %__unprocessedBuildArgs%
371+
call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\runtest.proj -testOverlay -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %RuntimeIdArg% %__unprocessedBuildArgs%
371372
if errorlevel 1 (
372-
echo Xunit Wrapper build failed
373+
echo %__MsgPrefix%Error: build failed. Refer to the build log files for details:
374+
echo %__BuildLog%
375+
echo %__BuildWrn%
376+
echo %__BuildErr%
373377
exit /b 1
374378
)
375379

376-
echo %__MsgPrefix%Creating test overlay...
380+
xcopy /s /y "%CORE_ROOT_STAGE%" "%CORE_ROOT%"
377381

378-
set __BuildLogRootName=Tests_Overlay_Managed
382+
REM Create the test host necessary for running CoreFX tests
383+
REM The test host includes a dotnet executable, system libraries and CoreCLR assemblies found in CoreRoot
384+
385+
set __BuildLogRootName=Tests_CoreFX_Testhost
379386
set __BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log
380387
set __BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn
381388
set __BuildErr=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.err
382389
set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
383390
set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
384391
set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
385392

386-
call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\runtest.proj -testOverlay -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %RuntimeIdArg% %__unprocessedBuildArgs%
393+
call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\runtest.proj -testHost -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %RuntimeIdArg% %__unprocessedBuildArgs%
387394
if errorlevel 1 (
388395
echo %__MsgPrefix%Error: build failed. Refer to the build log files for details:
389396
echo %__BuildLog%
@@ -392,7 +399,37 @@ if errorlevel 1 (
392399
exit /b 1
393400
)
394401

395-
xcopy /s /y "%CORE_ROOT_STAGE%" "%CORE_ROOT%"
402+
if defined __SkipManaged goto SkipBuildingWrappers
403+
404+
echo %__MsgPrefix%Creating test wrappers...
405+
406+
set RuntimeIdArg=
407+
set TargetsWindowsArg=
408+
409+
if defined __RuntimeId (
410+
set RuntimeIdArg=-RuntimeID="%__RuntimeId%"
411+
)
412+
413+
if "%__TargetsWindows%"=="1" (
414+
set TargetsWindowsArg=-TargetsWindows=true
415+
) else if "%__TargetsWindows%"=="0" (
416+
set TargetsWindowsArg=-TargetsWindows=false
417+
)
418+
419+
set __BuildLogRootName=Tests_XunitWrapper
420+
set __BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log
421+
set __BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn
422+
set __BuildErr=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.err
423+
set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
424+
set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
425+
set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
426+
427+
call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\runtest.proj -BuildWrappers -MsBuildEventLogging=" " -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %TargetsWindowsArg% %__unprocessedBuildArgs%
428+
if errorlevel 1 (
429+
echo Xunit Wrapper build failed
430+
exit /b 1
431+
)
432+
:SkipBuildingWrappers
396433

397434
set __CrossgenArg = ""
398435
if defined __DoCrossgen (

config.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,12 @@
336336
"values": [],
337337
"defaultValue": ""
338338
},
339+
"CreateTestHost": {
340+
"description": "Place test dependencies in the /bin/testhost folder to be used to run CoreFX tests",
341+
"valueType": "target",
342+
"values": [],
343+
"defaultValue": ""
344+
},
339345
"Verbosity": {
340346
"description": "Sets build verbosity.",
341347
"valueType": "passThrough",
@@ -504,6 +510,12 @@
504510
"CreateTestOverlay": "default"
505511
}
506512
},
513+
"testHost": {
514+
"description": "Runs test host target, which creates a dotnet executable from the built CoreCLR repo to run pre-built CoreFX test assemblies",
515+
"settings": {
516+
"CreateTestHost": "default"
517+
}
518+
},
507519
"priority": {
508520
"description": "Sets CLRTestPriorityToBuild property.",
509521
"settings": {

dependencies.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<PgoDataPackageVersion>99.99.99-master-20180621-0050</PgoDataPackageVersion>
3737
<MicrosoftNETCoreRuntimeCoreCLRPackageVersion>2.2.0-preview1-26621-01</MicrosoftNETCoreRuntimeCoreCLRPackageVersion>
3838
<XunitPackageVersion>2.2.0-beta2-build3300</XunitPackageVersion>
39-
<XunitConsoleNetcorePackageVersion>1.0.2-prerelease-00177</XunitConsoleNetcorePackageVersion>
39+
<XunitConsoleNetcorePackageVersion>2.2.0-preview1-02830-02</XunitConsoleNetcorePackageVersion>
4040
<XunitPerformanceApiPackageVersion>1.0.0-beta-build0015</XunitPerformanceApiPackageVersion>
4141
<MicrosoftDiagnosticsTracingTraceEventPackageVersion>2.0.4</MicrosoftDiagnosticsTracingTraceEventPackageVersion>
4242
<CommandLineParserVersion>2.2.0</CommandLineParserVersion>
@@ -137,6 +137,7 @@
137137
<XUnitDependency Include="xunit"/>
138138
<XUnitDependency Include="xunit.assert"/>
139139
<XUnitDependency Include="xunit.core"/>
140+
<XUnitDependency Include="xunit.extensibility.core" />
140141
<XUnitDependency Include="xunit.runner.console"/>
141142
<XUnitDependency Include="xunit.runner.msbuild"/>
142143
<XUnitDependency Include="xunit.runner.utility"/>

tests/CoreFX/CoreFXTestListURL.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://cloudcijobs.blob.core.windows.net/coreclrci/CoreFXArchives/TestList.json
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://cloudcijobs.blob.core.windows.net/corertci/TestList_Linux.json
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://cloudcijobs.blob.core.windows.net/corertci/TestList_OSX.json
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// The expected format of this file can be found at https://github.com/dotnet/coreclr/blob/master/Documentation/building/testing-with-corefx.md
2+
[
3+
{
4+
"name": "System.Collections.Tests",
5+
"exclusions": {
6+
"namespaces": null,
7+
"classes": null,
8+
"methods": [
9+
{
10+
"name": "System.Collections.Tests.SortedList_Generic_Tests_string_string.ICollection_Generic_Remove_DefaultValueContainedInCollection",
11+
"reason": "Exclusion Sample"
12+
}
13+
]
14+
}
15+
},
16+
{
17+
"name": "System.Runtime.Extensions.Tests",
18+
"exclusions": {
19+
"namespaces": null,
20+
"classes": null,
21+
"methods": []
22+
}
23+
},
24+
{
25+
"name": "System.Runtime.Tests",
26+
"exclusions": {
27+
"namespaces": null,
28+
"classes": null,
29+
"methods": []
30+
}
31+
},
32+
{
33+
"name": "System.Threading.Tasks.Tests",
34+
"exclusions": {
35+
"namespaces": null,
36+
"classes": null,
37+
"methods": []
38+
}
39+
},
40+
{
41+
"name": "System.Threading.Tests",
42+
"exclusions": {
43+
"namespaces": null,
44+
"classes": null,
45+
"methods": []
46+
}
47+
}
48+
]

0 commit comments

Comments
 (0)