Skip to content

Commit 9be3653

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

File tree

3 files changed

+75
-120
lines changed

3 files changed

+75
-120
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: 51 additions & 21 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,43 +25,39 @@ 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.
33-
34-
## Filtering Tests
31+
## Filtering Test Files
3532

36-
You can use `find_tests` to automatically discover tests and then filter or modify them:
33+
You can also use [`find_tests`](@ref) to automatically discover tests and then filter or modify them.
34+
This requires manually parsing arguments so that filtering is only applied when the user did not request specific tests to run:
3735

3836
```julia
39-
using ParallelTestRunner
40-
4137
# Start with autodiscovered tests
4238
testsuite = find_tests(pwd())
4339

44-
# Parse arguments manually
40+
# Parse arguments
4541
args = parse_args(ARGS)
4642

47-
# Filter based on arguments
4843
if filter_tests!(testsuite, args)
49-
# Additional filtering is allowed
50-
# For example, remove platform-specific tests
44+
# Remove tests that shouldn't run on Windows
5145
if Sys.iswindows()
52-
delete!(testsuite, "unix_only_test")
46+
delete!(testsuite, "ext/specialfunctions")
5347
end
5448
end
5549

56-
runtests(MyPackage, args; testsuite)
50+
runtests(MyModule, args; testsuite)
5751
```
5852

59-
The `filter_tests!` function returns `true` if no positional arguments were provided (allowing additional filtering) and `false` if the user specified specific tests (preventing further filtering).
53+
The [`filter_tests!`](@ref) function returns `true` if no positional arguments were provided (allowing additional filtering) and `false` if the user specified specific tests (preventing further filtering).
6054

6155
## Initialization Code
6256

63-
Use the `init_code` keyword argument to provide code that runs before each test file. This is useful for:
57+
Use the `init_code` keyword argument to [`runtests`](@ref) to provide code that runs before each test file.
58+
This is useful for:
6459
- Importing packages
65-
- Defining constants or helper functions
60+
- Defining constants, defaults or helper functions
6661
- Setting up test infrastructure
6762

6863
```julia
@@ -118,7 +113,7 @@ runtests(MyPackage, ARGS; test_worker, testsuite)
118113
```
119114

120115
The `test_worker` function receives the test name and should return either:
121-
- A worker object (from `addworker`) for tests that need special configuration
116+
- A worker object (from [`addworker`](@ref) for tests that need special configuration
122117
- `nothing` to use the default worker pool
123118

124119
## Custom Output Streams
@@ -180,6 +175,41 @@ workers = addworkers(4; env = ["THREADS" => "1"])
180175

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

178+
### Interactive use
179+
180+
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:
181+
182+
```julia-repl
183+
# In an environment where `MyPackage.jl` is available
184+
julia --proj
185+
186+
julia> using Pkg
187+
188+
# No need to start a fresh session to change threading
189+
julia> Pkg.test("MyModule"; test_args=`--verbose MyTestsetA`, julia_args=`--threads=auto`);
190+
```
191+
Alternatively, arguments can be passed directly from the command line with a shell alias like the one below:
192+
193+
```julia-repl
194+
jltest --threads=auto -- --verbose MyTestsetA
195+
```
196+
197+
Shell alias:
198+
199+
```shell
200+
function jltest {
201+
julia=(julia)
202+
203+
# certain arguments (like those beginnning with a +) need to come first
204+
if [[ $# -gt 0 && "$1" = +* ]]; then
205+
julia+=("$1")
206+
shift
207+
fi
208+
209+
"${julia[@]}" --startup-file=no --project -e "using Pkg; Pkg.API.test(; test_args=ARGS)" "$@"
210+
}
211+
```
212+
183213
## Best Practices
184214

185215
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)