|
1 | 1 | # ParallelTestRunner.jl |
2 | 2 |
|
| 3 | +[](https://juliatesting.github.io/ParallelTestRunner.jl/) |
| 4 | +[](https://juliatesting.github.io/ParallelTestRunner.jl/dev) |
| 5 | + |
3 | 6 | Simple parallel test runner for Julia tests with autodiscovery. |
4 | 7 |
|
5 | 8 | ## Usage |
@@ -40,102 +43,9 @@ using ParallelTestRunner |
40 | 43 | runtests(MyModule, ARGS) |
41 | 44 | ``` |
42 | 45 |
|
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 |
134 | 47 |
|
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/). |
139 | 49 |
|
140 | 50 | ## Inspiration |
141 | 51 | Based on [@maleadt](https://github.com/maleadt) test infrastructure for [CUDA.jl](https://github.com/JuliaGPU/CUDA.jl). |
0 commit comments