Skip to content

Commit 0119980

Browse files
authored
Stop using ctest (#5169)
1 parent b85dd2c commit 0119980

File tree

7 files changed

+35
-66
lines changed

7 files changed

+35
-66
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ set(VCLIBS_DEBUG_OPTIONS "$<$<COMPILE_LANGUAGE:CXX>:/Od>")
118118
set(VCLIBS_RELEASE_OPTIONS "$<$<COMPILE_LANGUAGE:CXX>:/O2;/Os>")
119119

120120
if(BUILD_TESTING)
121-
enable_testing()
122121
add_subdirectory(tests)
123122
endif()
124123

README.md

Lines changed: 19 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -269,34 +269,33 @@ C:\Users\username\Desktop>dumpbin /DEPENDENTS .\example.exe | findstr msvcp
269269
* Otherwise, use [LLVM's installer][] and choose to add LLVM to your `PATH` during installation.
270270
4. Follow the instructions below.
271271

272-
## Running All The Tests
272+
## Running The Tests
273273

274-
After configuring and building the project, running `ctest` from the build output directory will run all the tests.
275-
CTest will only display the standard error output of tests that failed. In order to get more details from CTest's
276-
`lit` invocations, run the tests with `ctest -V`.
274+
Our tests are currently split across three test suites that are located at `tests\std`, `tests\tr1`, and
275+
`llvm-project\libcxx\test\std`. The test runner `${PROJECT_BINARY_DIR}\tests\utils\stl-lit\stl-lit.py` accepts paths to
276+
directories in the test suites and runs all tests located in the subtree rooted at those paths. This can mean executing
277+
the entirety of a single test suite, running all tests under a category in `libcxx`, or running a single test in `std`
278+
and `tr1`.
277279

278-
## Running A Subset Of The Tests
279-
280-
`${PROJECT_BINARY_DIR}\tests\utils\stl-lit\stl-lit.py` can be invoked on a subdirectory of a test suite and will execute
281-
all the tests under that subdirectory. This can mean executing the entirety of a single test suite, running all tests
282-
under a category in libcxx, or running a single test in `std` and `tr1`.
280+
Some useful `stl-lit.py` options:
281+
* `-v` (verbose) tells `stl-lit.py` to show us output from failed test cases.
282+
* `-Dnotags=ASAN` disables the "extra ASan configs" that we typically run only in CI. This is useful to limit runtime
283+
for full validation runs, but often omitted when running just a few test cases to enable the extra ASan coverage.
283284

284285
## Examples
285286

286287
These examples assume that your current directory is `C:\Dev\STL\out\x64`.
287288

288-
* This command will run all of the test suites with verbose output.
289-
+ `ctest -V`
290-
* This command will also run all of the test suites.
291-
+ `python tests\utils\stl-lit\stl-lit.py ..\..\llvm-project\libcxx\test ..\..\tests\std ..\..\tests\tr1`
292-
* This command will run all of the std test suite.
293-
+ `python tests\utils\stl-lit\stl-lit.py ..\..\tests\std`
289+
* This command will run all of the test suites:
290+
+ `python tests\utils\stl-lit\stl-lit.py -Dnotags=ASAN ..\..\llvm-project\libcxx\test ..\..\tests\std ..\..\tests\tr1`
291+
* This command will run only the std test suite.
292+
+ `python tests\utils\stl-lit\stl-lit.py -Dnotags=ASAN ..\..\tests\std`
294293
* If you want to run a subset of a test suite, you need to point it to the right place in the sources. The following
295-
will run the single test found under VSO_0000000_any_calling_conventions.
296-
+ `python tests\utils\stl-lit\stl-lit.py ..\..\tests\std\tests\VSO_0000000_any_calling_conventions`
294+
will run the single test found under `VSO_0000000_any_calling_conventions`.
295+
+ `python tests\utils\stl-lit\stl-lit.py -Dnotags=ASAN ..\..\tests\std\tests\VSO_0000000_any_calling_conventions`
297296
* You can invoke `stl-lit` with any arbitrary subdirectory of a test suite. In libcxx this allows you to have finer
298297
control over what category of tests you would like to run. The following will run all the libcxx map tests.
299-
+ `python tests\utils\stl-lit\stl-lit.py ..\..\llvm-project\libcxx\test\std\containers\associative\map`
298+
+ `python tests\utils\stl-lit\stl-lit.py -Dnotags=ASAN ..\..\llvm-project\libcxx\test\std\containers\associative\map`
300299
* You can also use the `--filter` option to include tests whose names match a regular expression. The following
301300
command will run tests with "atomic_wait" in their names in both the std and libcxx test suites.
302301
+ `python tests\utils\stl-lit\stl-lit.py ..\..\llvm-project\libcxx\test ..\..\tests\std --filter=atomic_wait`
@@ -305,31 +304,8 @@ control over what category of tests you would like to run. The following will ru
305304

306305
## Interpreting The Results Of Tests
307306

308-
### CTest
309-
310-
When running the tests via CTest, all of the test suites are considered to be a single test. If any single test in a
311-
test suite fails, CTest will simply report that the `stl` test failed.
312-
313-
Example:
314-
```
315-
0% tests passed, 1 tests failed out of 1
316-
317-
Total Test time (real) = 2441.55 sec
318-
319-
The following tests FAILED:
320-
1 - stl (Failed)
321-
```
322-
323-
The primary utility of CTest in this case is to conveniently invoke `stl-lit.py` with the correct set of arguments.
324-
325-
CTest will output everything that was sent to stderr for each of the failed test suites, which can be used to identify
326-
which individual test within the test suite failed. It can sometimes be helpful to run CTest with the `-V` option in
327-
order to see the stdout of the tests.
328-
329-
### stl-lit
330-
331-
When running the tests directly via the generated `stl-lit.py` script the result of each test will be printed. The
332-
format of each result is `{Result Code}: {Test Suite Name} :: {Test Name}:{Configuration Number}`.
307+
`stl-lit.py` prints the result of each test. The format of each result is
308+
`{Result Code}: {Test Suite Name} :: {Test Name}:{Configuration Number}`.
333309

334310
Example:
335311
```

azure-devops/asan-pipeline.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ stages:
2727
hostArch: x64
2828
targetArch: x64
2929
asanBuild: true
30-
ctestOptions: '--tests-regex stlasan'
30+
testTargets: STL-ASan-CI
3131

3232
- stage: Build_And_Test_x86
3333
displayName: 'Build and Test x86'
@@ -41,6 +41,6 @@ stages:
4141
hostArch: x86
4242
targetArch: x86
4343
asanBuild: true
44-
ctestOptions: '--tests-regex stlasan'
44+
testTargets: STL-ASan-CI
4545

4646
# no coverage for ARM and ARM64

azure-devops/build-and-test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ parameters:
1515
- name: buildBenchmarks
1616
type: boolean
1717
default: false
18-
- name: ctestOptions
18+
- name: testTargets
1919
type: string
20-
default: '--exclude-regex stlasan'
20+
default: 'STL-CI'
2121
- name: numShards
2222
type: number
2323
default: 8
@@ -61,5 +61,5 @@ jobs:
6161
parameters:
6262
hostArch: ${{ parameters.hostArch }}
6363
targetArch: ${{ parameters.targetArch }}
64-
ctestOptions: ${{ parameters.ctestOptions }}
64+
testTargets: ${{ parameters.testTargets }}
6565
skipTesting: ${{ parameters.skipTesting }}

azure-devops/run-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ parameters:
66
type: string
77
- name: targetArch
88
type: string
9-
- name: ctestOptions
9+
- name: testTargets
1010
type: string
1111
- name: skipTesting
1212
type: boolean
1313
steps:
1414
- script: |
1515
call "%ProgramFiles%\Microsoft Visual Studio\2022\Preview\Common7\Tools\VsDevCmd.bat" ^
1616
-host_arch=${{ parameters.hostArch }} -arch=${{ parameters.targetArch }} -no_logo
17-
ctest --verbose ${{ parameters.ctestOptions }}
17+
ninja --verbose -k 0 ${{ parameters.testTargets }}
1818
displayName: 'Build and Run Tests'
1919
timeoutInMinutes: 30
2020
condition: and(succeeded(), not(${{ parameters.skipTesting }}))

tests/CMakeLists.txt

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,11 @@ add_subdirectory(utils/stl-lit)
2626
find_package(Python "3.13" REQUIRED COMPONENTS Interpreter)
2727

2828
if(NOT DEFINED LIT_FLAGS)
29-
list(APPEND LIT_FLAGS "-o" "${CMAKE_CURRENT_BINARY_DIR}/test_results.json")
29+
set(LIT_FLAGS "-o" "${CMAKE_CURRENT_BINARY_DIR}/test_results.json")
3030
endif()
3131

32+
set(STL_LIT_COMMAND ${Python_EXECUTABLE} ${STL_LIT_OUTPUT} ${LIT_FLAGS})
3233
get_property(STL_LIT_TEST_DIRS GLOBAL PROPERTY STL_LIT_TEST_DIRS)
33-
list(APPEND STL_LIT_COMMAND "${STL_LIT_OUTPUT}"
34-
"${LIT_FLAGS}"
35-
"-D" "notags=ASAN"
36-
"${STL_LIT_TEST_DIRS}")
37-
list(APPEND STLASAN_LIT_COMMAND "${STL_LIT_OUTPUT}"
38-
"${LIT_FLAGS}"
39-
"-D" "tags=ASAN"
40-
"${STL_LIT_TEST_DIRS}")
41-
42-
add_test(NAME stl COMMAND ${Python_EXECUTABLE} ${STL_LIT_COMMAND} COMMAND_EXPAND_LISTS)
43-
add_test(NAME stlasan COMMAND ${Python_EXECUTABLE} ${STLASAN_LIT_COMMAND} COMMAND_EXPAND_LISTS)
44-
set_tests_properties(stl stlasan PROPERTIES RUN_SERIAL ON)
34+
35+
add_custom_target(STL-CI COMMAND ${STL_LIT_COMMAND} -Dnotags=ASAN ${STL_LIT_TEST_DIRS} USES_TERMINAL)
36+
add_custom_target(STL-ASan-CI COMMAND ${STL_LIT_COMMAND} -Dtags=ASAN ${STL_LIT_TEST_DIRS} USES_TERMINAL)

tests/utils/stl/test/params.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ def beNice(prio: str) -> list[ConfigAction]:
4949
}
5050
psutil.Process().nice(priority_map[prio])
5151
except ImportError:
52-
import sys
53-
print(f'NOTE: Module "psutil" is not installed, so the priority setting "{prio}" has no effect.', file=sys.stderr)
52+
if not hasattr(beNice, 'suppress'):
53+
import sys
54+
print(f'NOTE: Module "psutil" is not installed, so the priority setting "{prio}" has no effect.', file=sys.stderr)
55+
beNice.suppress = True
5456
return []
5557

5658

0 commit comments

Comments
 (0)