|
16 | 16 | runtests(MyPackage, ARGS; testsuite)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">Running 2 tests in parallel. If this is too many, specify the `--jobs=N` argument to the tests, or set the `JULIA_CPU_THREADS` environment variable. |
17 | 17 | │ <span class="sgr37"> │ ──────────────── CPU ──────────────── │</span> |
18 | 18 | <span class="sgr37">Test (Worker) │ Time (s) │ GC (s) │ GC % │ Alloc (MB) │ RSS (MB) │</span> |
19 | | -<span class="sgr37">basic (1) │ 0.18 │ 0.00 │ 0.0 │ 5.67 │ 564.60 │</span> |
20 | | -<span class="sgr37">advanced (2) │ 0.12 │ 0.00 │ 0.0 │ 5.86 │ 566.61 │</span> |
| 19 | +<span class="sgr37">advanced (1) │ 0.12 │ 0.00 │ 0.0 │ 5.86 │ 563.07 │</span> |
| 20 | +<span class="sgr37">basic (2) │ 0.17 │ 0.00 │ 0.0 │ 5.67 │ 565.08 │</span> |
21 | 21 |
|
22 | 22 | <span class="sgr1">Test Summary: | <span class="sgr32">Pass </span><span class="sgr36">Total </span>Time</span> |
23 | | - Overall | <span class="sgr32"> 3 </span><span class="sgr36"> 3 </span>8.1s |
| 23 | + Overall | <span class="sgr32"> 3 </span><span class="sgr36"> 3 </span>7.9s |
24 | 24 | <span class="sgr32"><span class="sgr1">SUCCESS</span></span></code></pre><h2 id="Filtering-Test-Files"><a class="docs-heading-anchor" href="#Filtering-Test-Files">Filtering Test Files</a><a id="Filtering-Test-Files-1"></a><a class="docs-heading-anchor-permalink" href="#Filtering-Test-Files" title="Permalink"></a></h2><p>You can also use <a href="../api/#ParallelTestRunner.find_tests"><code>find_tests</code></a> to automatically discover test files 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:</p><pre><code class="language-julia hljs">using ParallelTestRunner |
25 | 25 | using MyPackage |
26 | 26 |
|
|
40 | 40 | runtests(MyPackage, args; testsuite)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">Running 1 tests in parallel. If this is too many, specify the `--jobs=N` argument to the tests, or set the `JULIA_CPU_THREADS` environment variable. |
41 | 41 | │ <span class="sgr37"> │ ──────────────── CPU ──────────────── │</span> |
42 | 42 | <span class="sgr37">Test (Worker) │ Time (s) │ GC (s) │ GC % │ Alloc (MB) │ RSS (MB) │</span> |
43 | | -<span class="sgr37">basic (3) │ 0.18 │ 0.00 │ 0.0 │ 5.67 │ 597.96 │</span> |
| 43 | +<span class="sgr37">basic (3) │ 0.17 │ 0.00 │ 0.0 │ 5.67 │ 591.93 │</span> |
44 | 44 |
|
45 | 45 | <span class="sgr1">Test Summary: | <span class="sgr32">Pass </span><span class="sgr36">Total </span>Time</span> |
46 | 46 | Overall | <span class="sgr32"> 1 </span><span class="sgr36"> 1 </span>4.0s |
|
57 | 57 | runtests(MyPackage, ARGS; init_code)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">Running 2 tests in parallel. If this is too many, specify the `--jobs=N` argument to the tests, or set the `JULIA_CPU_THREADS` environment variable. |
58 | 58 | │ <span class="sgr37"> │ ──────────────── CPU ──────────────── │</span> |
59 | 59 | <span class="sgr37">Test (Worker) │ Time (s) │ GC (s) │ GC % │ Alloc (MB) │ RSS (MB) │</span> |
60 | | -<span class="sgr37">advanced (5) │ 0.19 │ 0.00 │ 0.0 │ 5.67 │ 604.03 │</span> |
61 | | -<span class="sgr37">basic (4) │ 0.19 │ 0.00 │ 0.0 │ 5.67 │ 606.11 │</span> |
| 60 | +<span class="sgr37">advanced (4) │ 0.17 │ 0.00 │ 0.0 │ 5.67 │ 598.22 │</span> |
| 61 | +<span class="sgr37">basic (5) │ 0.17 │ 0.00 │ 0.0 │ 5.67 │ 600.26 │</span> |
62 | 62 |
|
63 | 63 | <span class="sgr1">Test Summary: | <span class="sgr32">Pass </span><span class="sgr36">Total </span>Time</span> |
64 | 64 | Overall | <span class="sgr32"> 2 </span><span class="sgr36"> 2 </span>4.0s |
|
92 | 92 | runtests(MyPackage, ARGS; test_worker, testsuite)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">Running 3 tests in parallel. If this is too many, specify the `--jobs=N` argument to the tests, or set the `JULIA_CPU_THREADS` environment variable. |
93 | 93 | │ <span class="sgr37"> │ ──────────────── CPU ──────────────── │</span> |
94 | 94 | <span class="sgr37">Test (Worker) │ Time (s) │ GC (s) │ GC % │ Alloc (MB) │ RSS (MB) │</span> |
95 | | -<span class="sgr37">needs_threads (6) │ 0.11 │ 0.00 │ 0.0 │ 5.38 │ 628.62 │</span> |
96 | | -<span class="sgr37">needs_env_var (7) │ 0.11 │ 0.00 │ 0.0 │ 5.38 │ 628.62 │</span> |
97 | | -<span class="sgr37">normal_test (8) │ 0.12 │ 0.00 │ 0.0 │ 5.38 │ 630.70 │</span> |
| 95 | +<span class="sgr37">needs_env_var (6) │ 0.11 │ 0.00 │ 0.0 │ 5.38 │ 623.15 │</span> |
| 96 | +<span class="sgr37">needs_threads (7) │ 0.12 │ 0.00 │ 0.0 │ 5.38 │ 625.25 │</span> |
| 97 | +<span class="sgr37">normal_test (8) │ 0.11 │ 0.00 │ 0.0 │ 5.38 │ 623.15 │</span> |
98 | 98 |
|
99 | 99 | <span class="sgr1">Test Summary: | <span class="sgr32">Pass </span><span class="sgr36">Total </span>Time</span> |
100 | 100 | Overall | <span class="sgr32"> 3 </span><span class="sgr36"> 3 </span>5.1s |
|
113 | 113 | runtests(MyPackage, args)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">Running 2 tests in parallel. If this is too many, specify the `--jobs=N` argument to the tests, or set the `JULIA_CPU_THREADS` environment variable. |
114 | 114 | │ <span class="sgr37"> │ ──────────────── CPU ──────────────── │</span> |
115 | 115 | <span class="sgr37">Test (Worker) │ Time (s) │ GC (s) │ GC % │ Alloc (MB) │ RSS (MB) │</span> |
116 | | -<span class="sgr37">advanced (9) │ 0.18 │ 0.00 │ 0.0 │ 5.67 │ 654.71 │</span> |
117 | | -<span class="sgr37">basic (10) │ 0.18 │ 0.00 │ 0.0 │ 5.67 │ 654.71 │</span> |
| 116 | +<span class="sgr37">advanced (9) │ 0.18 │ 0.00 │ 0.0 │ 5.67 │ 649.27 │</span> |
| 117 | +<span class="sgr37">basic (10) │ 0.18 │ 0.00 │ 0.0 │ 5.67 │ 649.27 │</span> |
118 | 118 |
|
119 | 119 | <span class="sgr1">Test Summary: | <span class="sgr32">Pass </span><span class="sgr36">Total </span>Time</span> |
120 | 120 | Overall | <span class="sgr32"> 2 </span><span class="sgr36"> 2 </span>4.0s |
121 | 121 | <span class="sgr32"><span class="sgr1">SUCCESS</span></span></code></pre><p>Custom flags are stored in the <code>custom</code> field of the <a href="../api/#ParallelTestRunner.ParsedArgs"><code>ParsedArgs</code></a> object, with values of <code>nothing</code> (not set) or <code>Some(value)</code> (set, with optional value).</p><h2 id="Interactive-use"><a class="docs-heading-anchor" href="#Interactive-use">Interactive use</a><a id="Interactive-use-1"></a><a class="docs-heading-anchor-permalink" href="#Interactive-use" title="Permalink"></a></h2><p>Arguments can also be passed via the standard <a href="https://pkgdocs.julialang.org/v1/api/#Pkg.test"><code>Pkg.test</code></a> interface for interactive control. For example, here is how we could run the subset of test files that start with the name <code>test_cool_feature</code> in i) verbose mode, and ii) with a specific number of Julia threads enabled:</p><pre><code class="language-bash hljs"># Start julia in an environment where `MyPackage.jl` is available |
122 | 122 | julia --project</code></pre><pre><code class="language-julia-repl hljs" style="display:block;">julia> using Pkg</code><br/><code class="language-julia-repl hljs" style="display:block;">julia> # No need to start a fresh session to change threading |
123 | 123 | Pkg.test("MyPackage"; test_args=`--verbose advanced`, julia_args=`--threads=auto`);</code><code class="nohighlight hljs ansi" style="display:block;"><span class="sgr32"><span class="sgr1"> Testing</span></span> MyPackage |
124 | | -<span class="sgr32"><span class="sgr1"> Status</span></span> `/tmp/jl_TPIqjF/Project.toml` |
| 124 | +<span class="sgr32"><span class="sgr1"> Status</span></span> `/tmp/jl_SWhsGi/Project.toml` |
125 | 125 | <span class="sgr90">[0b48ad8b] </span>MyPackage v0.0.0 `~/work/ParallelTestRunner.jl/ParallelTestRunner.jl/docs/MyPackage` |
126 | 126 | <span class="sgr90">[d3525ed8] </span>ParallelTestRunner v2.0.2 `~/work/ParallelTestRunner.jl/ParallelTestRunner.jl` |
127 | 127 | <span class="sgr90">[8dfed614] </span>Test v1.11.0 |
128 | | -<span class="sgr32"><span class="sgr1"> Status</span></span> `/tmp/jl_TPIqjF/Manifest.toml` |
| 128 | +<span class="sgr32"><span class="sgr1"> Status</span></span> `/tmp/jl_SWhsGi/Manifest.toml` |
129 | 129 | <span class="sgr90">[b5f81e59] </span>IOCapture v1.0.0 |
130 | 130 | <span class="sgr90">[36869731] </span>Malt v1.4.0 `https://github.com/giordano/Malt.jl.git#mg/worker-stdout-stderr` |
131 | 131 | <span class="sgr90">[0b48ad8b] </span>MyPackage v0.0.0 `~/work/ParallelTestRunner.jl/ParallelTestRunner.jl/docs/MyPackage` |
|
158 | 158 | Running 1 tests in parallel. If this is too many, specify the `--jobs=N` argument to the tests, or set the `JULIA_CPU_THREADS` environment variable. |
159 | 159 | │ <span class="sgr37"> │ ──────────────── CPU ──────────────── │</span> |
160 | 160 | <span class="sgr37">Test (Worker) │ Time (s) │ GC (s) │ GC % │ Alloc (MB) │ RSS (MB) │</span> |
161 | | -<span class="sgr37">advanced (1) │</span><span class="sgr90"> started at 2026-01-19T17:16:47.153</span> |
162 | | -<span class="sgr37">advanced (1) │ 0.17 │ 0.00 │ 0.0 │ 5.67 │ 420.38 │</span> |
| 161 | +<span class="sgr37">advanced (1) │</span><span class="sgr90"> started at 2026-01-19T17:40:24.508</span> |
| 162 | +<span class="sgr37">advanced (1) │ 0.17 │ 0.00 │ 0.0 │ 5.67 │ 417.18 │</span> |
163 | 163 |
|
164 | 164 | <span class="sgr1">Test Summary: | <span class="sgr32">Pass </span><span class="sgr36">Total </span>Time</span> |
165 | | - Overall | <span class="sgr32"> 1 </span><span class="sgr36"> 1 </span>7.0s |
| 165 | + Overall | <span class="sgr32"> 1 </span><span class="sgr36"> 1 </span>6.9s |
166 | 166 | advanced | <span class="sgr32"> 1 </span><span class="sgr36"> 1 </span>0.1s |
167 | 167 | <span class="sgr32"><span class="sgr1">SUCCESS</span></span> |
168 | 168 | <span class="sgr32"><span class="sgr1"> Testing</span></span> MyPackage tests passed</code></pre><p>Alternatively, arguments can be passed directly from the command line with a shell alias like the one below:</p><pre><code class="language-julia-repl hljs">jltest --threads=auto -- --verbose test_cool_feature</code></pre><p>Shell alias:</p><pre><code class="language-bash hljs">function jltest { |
|
178 | 178 | }</code></pre><h2 id="Best-Practices"><a class="docs-heading-anchor" href="#Best-Practices">Best Practices</a><a id="Best-Practices-1"></a><a class="docs-heading-anchor-permalink" href="#Best-Practices" title="Permalink"></a></h2><ol><li><p><strong>Keep tests isolated</strong>: Each test file runs in its own module, so avoid relying on global state between tests.</p></li><li><p><strong>Use <code>init_code</code> for common setup</strong>: Instead of duplicating setup code in each test file, use <code>init_code</code> to share common initialization.</p></li><li><p><strong>Filter tests appropriately</strong>: Use <a href="../api/#ParallelTestRunner.filter_tests!"><code>filter_tests!</code></a> to respect user-specified test filters while allowing additional programmatic filtering.</p></li><li><p><strong>Handle platform differences</strong>: Use conditional logic in your test suite setup to handle platform-specific tests:</p><pre><code class="language-julia hljs">testsuite = find_tests(pwd()) |
179 | 179 | if Sys.iswindows() |
180 | 180 | delete!(testsuite, "unix_specific_test") |
181 | | -end</code></pre></li><li><p><strong>Load balance the test files</strong>: <code>ParallelTestRunner</code> runs the tests files in parallel, ideally all test files should run for <em>roughly</em> the same time for better performance. Having few long-running test files and other short-running ones hinders scalability.</p></li><li><p><strong>Use custom workers sparingly</strong>: Custom workers add overhead. Only use them when tests genuinely require different configurations.</p></li></ol></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../">« Home</a><a class="docs-footer-nextpage" href="../api/">API Reference »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.16.1 on <span class="colophon-date" title="Monday 19 January 2026 17:17">Monday 19 January 2026</span>. Using Julia version 1.12.4.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html> |
| 181 | +end</code></pre></li><li><p><strong>Load balance the test files</strong>: <code>ParallelTestRunner</code> runs the tests files in parallel, ideally all test files should run for <em>roughly</em> the same time for better performance. Having few long-running test files and other short-running ones hinders scalability.</p></li><li><p><strong>Use custom workers sparingly</strong>: Custom workers add overhead. Only use them when tests genuinely require different configurations.</p></li></ol></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../">« Home</a><a class="docs-footer-nextpage" href="../api/">API Reference »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.16.1 on <span class="colophon-date" title="Monday 19 January 2026 17:40">Monday 19 January 2026</span>. Using Julia version 1.12.4.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html> |
0 commit comments