Skip to content

Commit 2270c1a

Browse files
committed
Some fixes and move information from README to the docs
1 parent c1ed9b9 commit 2270c1a

File tree

3 files changed

+87
-109
lines changed

3 files changed

+87
-109
lines changed

README.md

Lines changed: 5 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# ParallelTestRunner.jl
22

3+
[![Stable Documentation](https://img.shields.io/badge/docs-stable-blue.svg)](https://juliatesting.github.io/ParallelTestRunner.jl/)
4+
[![Latest Documentation](https://img.shields.io/badge/docs-latest-blue.svg)](https://juliatesting.github.io/ParallelTestRunner.jl/dev)
5+
36
Simple parallel test runner for Julia tests with autodiscovery.
47

58
## Usage
@@ -40,102 +43,9 @@ using ParallelTestRunner
4043
runtests(MyModule, ARGS)
4144
```
4245

43-
### Customizing the test suite
44-
45-
By default, `runtests` automatically discovers all `.jl` files in your `test/` directory (excluding `runtests.jl` itself) using the `find_tests` function. You can customize which tests to run by providing a custom `testsuite` dictionary:
46-
47-
```julia
48-
# Manually define your test suite
49-
testsuite = Dict(
50-
"basic" => quote
51-
include("basic.jl")
52-
end,
53-
"advanced" => quote
54-
include("advanced.jl")
55-
end
56-
)
57-
58-
runtests(MyModule, ARGS; testsuite)
59-
```
60-
61-
You can also use `find_tests` to automatically discover tests and then filter or modify them. This requires manually parsing arguments so that filtering is only applied when the user did not request specific tests to run:
62-
63-
```julia
64-
# Start with autodiscovered tests
65-
testsuite = find_tests(pwd())
66-
67-
# Parse arguments
68-
args = parse_args(ARGS)
69-
70-
if filter_tests!(testsuite, args)
71-
# Remove tests that shouldn't run on Windows
72-
if Sys.iswindows()
73-
delete!(testsuite, "ext/specialfunctions")
74-
end
75-
end
76-
77-
runtests(MyModule, args; testsuite)
78-
```
79-
80-
### Provide defaults
81-
82-
`runtests` takes a keyword argument that one can use to provide default definitions to be loaded before each testfile.
83-
As an example one could always load `Test` and the package under test.
84-
85-
```julia
86-
const init_code = quote
87-
using Test
88-
using MyPackage
89-
end
90-
91-
runtests(MyModule, ARGS; init_code)
92-
```
93-
94-
### Interactive use
95-
96-
Arguments can also be passed via the standard `Pkg.test` interface for interactive control. For example, here is how we could run the subset of tests that start with the testset name "MyTestsetA" in i) verbose mode, and ii) with default threading enabled:
97-
98-
```julia-repl
99-
# In an environment where `MyPackage.jl` is available
100-
julia --proj
101-
102-
julia> using Pkg
103-
104-
# No need to start a fresh session to change threading
105-
julia> Pkg.test("MyModule"; test_args=`--verbose MyTestsetA`, julia_args=`--threads=auto`);
106-
```
107-
Alternatively, arguments can be passed directly from the command line with a shell alias like the one below:
108-
109-
```julia-repl
110-
jltest --threads=auto -- --verbose MyTestsetA
111-
```
112-
113-
<details><summary>Shell alias</summary>
114-
115-
```shell
116-
function jltest {
117-
julia=(julia)
118-
119-
# certain arguments (like those beginnning with a +) need to come first
120-
if [[ $# -gt 0 && "$1" = +* ]]; then
121-
julia+=("$1")
122-
shift
123-
fi
124-
125-
"${julia[@]}" --startup-file=no --project -e "using Pkg; Pkg.API.test(; test_args=ARGS)" "$@"
126-
}
127-
```
128-
129-
</details>
130-
131-
## Packages using ParallelTestRunner.jl
132-
133-
There are a few packages already using `ParallelTestRunner.jl` to parallelize their tests, you can look at their setups if you need inspiration to move your packages as well:
46+
## Documentation
13447

135-
* [`Enzyme.jl`](https://github.com/EnzymeAD/Enzyme.jl/blob/main/test/runtests.jl)
136-
* [`GPUArrays.jl`](https://github.com/JuliaGPU/GPUArrays.jl/blob/master/test/runtests.jl)
137-
* [`GPUCompiler.jl`](https://github.com/JuliaGPU/GPUCompiler.jl/blob/master/test/runtests.jl)
138-
* [`Metal.jl`](https://github.com/JuliaGPU/Metal.jl/blob/main/test/runtests.jl)
48+
For more details about the use of this package, read the [documentation](https://juliatesting.github.io/ParallelTestRunner.jl/).
13949

14050
## Inspiration
14151
Based on [@maleadt](https://github.com/maleadt) test infrastructure for [CUDA.jl](https://github.com/JuliaGPU/CUDA.jl).

docs/src/advanced.md

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ end
99

1010
This page covers advanced features of `ParallelTestRunner` for customizing test execution.
1111

12-
## Custom Test Suites
12+
## Customizing the test suite
1313

14-
By default, `runtests` automatically discovers all `.jl` files in your test directory. You can provide a custom test suite dictionary to have full control over which tests run:
14+
By default, [`runtests`](@ref) automatically discovers all `.jl` files in your `test/` directory (excluding `runtests.jl` itself) using the `find_tests` function.
15+
You can customize which tests to run by providing a custom `testsuite` dictionary:
1516

1617
```julia
17-
using ParallelTestRunner
18-
1918
# Manually define your test suite
2019
testsuite = Dict(
2120
"basic" => quote
@@ -26,14 +25,32 @@ testsuite = Dict(
2625
end
2726
)
2827

29-
runtests(MyPackage, ARGS; testsuite)
28+
runtests(MyModule, ARGS; testsuite)
3029
```
3130

32-
Each value in the dictionary should be an expression (use `quote...end`) that executes the test code.
31+
You can also use [`find_tests`](@ref) to automatically discover tests and then filter or modify them.
32+
This requires manually parsing arguments so that filtering is only applied when the user did not request specific tests to run:
33+
34+
```julia
35+
# Start with autodiscovered tests
36+
testsuite = find_tests(pwd())
37+
38+
# Parse arguments
39+
args = parse_args(ARGS)
40+
41+
if filter_tests!(testsuite, args)
42+
# Remove tests that shouldn't run on Windows
43+
if Sys.iswindows()
44+
delete!(testsuite, "ext/specialfunctions")
45+
end
46+
end
47+
48+
runtests(MyModule, args; testsuite)
49+
```
3350

34-
## Filtering Tests
51+
## Filtering Test Files
3552

36-
You can use `find_tests` to automatically discover tests and then filter or modify them:
53+
You can use `find_tests` to automatically discover test files and then filter or modify them:
3754

3855
```julia
3956
using ParallelTestRunner
@@ -60,9 +77,10 @@ The `filter_tests!` function returns `true` if no positional arguments were prov
6077

6178
## Initialization Code
6279

63-
Use the `init_code` keyword argument to provide code that runs before each test file. This is useful for:
80+
Use the `init_code` keyword argument to [`runtests`](@ref) to provide code that runs before each test file.
81+
This is useful for:
6482
- Importing packages
65-
- Defining constants or helper functions
83+
- Defining constants, defaults or helper functions
6684
- Setting up test infrastructure
6785

6886
```julia
@@ -180,6 +198,41 @@ workers = addworkers(4; env = ["THREADS" => "1"])
180198

181199
Workers created this way can be used with the `test_worker` function or for other distributed computing tasks.
182200

201+
### Interactive use
202+
203+
Arguments can also be passed via the standard `Pkg.test` interface for interactive control. For example, here is how we could run the subset of tests that start with the testset name "MyTestsetA" in i) verbose mode, and ii) with default threading enabled:
204+
205+
```julia-repl
206+
# In an environment where `MyPackage.jl` is available
207+
julia --proj
208+
209+
julia> using Pkg
210+
211+
# No need to start a fresh session to change threading
212+
julia> Pkg.test("MyModule"; test_args=`--verbose MyTestsetA`, julia_args=`--threads=auto`);
213+
```
214+
Alternatively, arguments can be passed directly from the command line with a shell alias like the one below:
215+
216+
```julia-repl
217+
jltest --threads=auto -- --verbose MyTestsetA
218+
```
219+
220+
Shell alias:
221+
222+
```shell
223+
function jltest {
224+
julia=(julia)
225+
226+
# certain arguments (like those beginnning with a +) need to come first
227+
if [[ $# -gt 0 && "$1" = +* ]]; then
228+
julia+=("$1")
229+
shift
230+
fi
231+
232+
"${julia[@]}" --startup-file=no --project -e "using Pkg; Pkg.API.test(; test_args=ARGS)" "$@"
233+
}
234+
```
235+
183236
## Best Practices
184237

185238
1. **Keep tests isolated**: Each test file runs in its own module, so avoid relying on global state between tests.

docs/src/index.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ Example output:
115115

116116
```
117117
Test | Time (s) | GC (s) | GC % | Alloc (MB) | RSS (MB) |
118-
basic (1) | 0.12 | 0.01 | 8.3 | 5.23 | 125.45 |
119-
integration (2) | 2.45 | 0.15 | 6.1 | 45.67 | 234.12 |
118+
basic (1) | 0.12 | 0.01 | 8.3 | 5.23 | 125.45 |
119+
integration (2) | 2.45 | 0.15 | 6.1 | 45.67 | 234.12 |
120120
```
121121

122122
### Graceful Interruption
@@ -126,8 +126,6 @@ Press `Ctrl+C` to interrupt the test run. The framework will:
126126
- Display a summary of completed tests
127127
- Exit gracefully
128128

129-
You can also press `?` during execution to see which tests are currently running.
130-
131129
## Test File Structure
132130

133131
Your test files should be standard Julia test files using the `Test` standard library:
@@ -143,3 +141,20 @@ end
143141
```
144142

145143
Each test file runs in its own isolated module, so you don't need to worry about test pollution between files.
144+
145+
## Packages using ParallelTestRunner.jl
146+
147+
There are a few packages already [using `ParallelTestRunner.jl`](https://github.com/search?q=%22using+ParallelTestRunner%22+language%3AJulia++NOT+is%3Aarchived+NOT+is%3Afork&type=code) to parallelize their tests, you can look at their setups if you need inspiration to move your packages as well:
148+
149+
* [`ApproxFun.jl`](https://github.com/JuliaApproximation/ApproxFun.jl/blob/master/test/runtests.jl)
150+
* [`BlockArrays.jl`](https://github.com/JuliaArrays/BlockArrays.jl/blob/master/test/runtests.jl)
151+
* [`CuNESSie.jl`](https://github.com/tkemmer/CuNESSie.jl/blob/master/test/runtests.jl)
152+
* [`Enzyme.jl`](https://github.com/EnzymeAD/Enzyme.jl/blob/main/test/runtests.jl)
153+
* [`GPUArrays.jl`](https://github.com/JuliaGPU/GPUArrays.jl/blob/master/test/runtests.jl)
154+
* [`GPUCompiler.jl`](https://github.com/JuliaGPU/GPUCompiler.jl/blob/master/test/runtests.jl)
155+
* [`HyperHessians.jl`](https://github.com/KristofferC/HyperHessians.jl/blob/master/test/runtests.jl)
156+
* [`Metal.jl`](https://github.com/JuliaGPU/Metal.jl/blob/main/test/runtests.jl)
157+
* [`WCS.jl`](https://github.com/JuliaAstro/WCS.jl/blob/master/test/runtests.jl)
158+
159+
## Inspiration
160+
Based on [@maleadt](https://github.com/maleadt) test infrastructure for [CUDA.jl](https://github.com/JuliaGPU/CUDA.jl).

0 commit comments

Comments
 (0)