@@ -34,11 +34,11 @@ possible to use `ReTest` features without changing a line, e.g. on Julia's
34
34
## Usage
35
35
36
36
The exported [ ` ReTest.@testset ` ] ( @ref ) macro can be used as a direct
37
- replacement for ` Test.@testset ` (with limitations, see below), and ` retest() `
38
- has to be called for the tests to be executed. See [ ` retest ` ] ( @ref ) 's
39
- docstrings for more details. Moreover, ` ReTest ` re-exports (almost) all
40
- exported symbols from ` Test ` , so there should not be any need to import ` Test `
41
- together with ` ReTest ` .
37
+ replacement for ` Test.@testset ` (with limitations, [ see below] ( @ ref Caveats)),
38
+ and ` retest() ` has to be called for the tests to be executed. See
39
+ [ ` retest ` ] ( @ref ) 's docstrings for more details. Moreover, ` ReTest ` re-exports
40
+ (almost) all exported symbols from ` Test ` , so there should not be any need to
41
+ import ` Test ` together with ` ReTest ` .
42
42
43
43
When using ` @testset ` "inline", i.e. within the source-code of a package, one
44
44
can use the ` InlineTest ` package instead of ` ReTest ` , which only defines the
@@ -47,9 +47,9 @@ if `ReTest` itself loads fast, it can be desirable to have an even lighter
47
47
dependency). But ` ReTest ` still has to be loaded (as a "test" dependency) in
48
48
order to call ` retest ` .
49
49
50
- Finally, for convenience, ` @testset ` also implicitly defines a ` runtests `
51
- function within the enclosing module, say ` M ` , such that ` M.runtests(...) ` is
52
- equivalent to calling ` retest(M, ...) ` .
50
+ Finally, for convenience, ` ReTest. @testset` also implicitly defines a
51
+ ` runtests ` function within the enclosing module, say ` M ` , such that
52
+ ` M.runtests(...) ` is equivalent to calling ` retest(M, ...) ` .
53
53
54
54
55
55
## ` retest ` and ` @testset `
@@ -66,27 +66,29 @@ retest
66
66
67
67
## Caveats
68
68
69
- ` ReTest.@testset ` comes with a couple of caveats/limitations:
69
+ ` ReTest.@testset ` comes with a couple of caveats/limitations, some of which
70
+ should be fixable:
70
71
71
72
* Toplevel testsets (which are not nested within other testsets), when run,
72
73
are ` eval ` ed at the toplevel of their parent module, which means that they
73
- can't depend on local variables for example. This is probably the only
74
- fundamental limitation compared to ` Test.@testset ` , and might not be
75
- fixable.
74
+ can't depend on local variables for example.
76
75
77
76
* "testsets-for" (` @testset "description" for ... ` ), when run, imply ` eval ` ing
78
- their loop variables at the toplevel of their parent module; moreover,
79
- "testsets-for" currently accept only "non-cartesian" looping (e.g. `for i=I,
80
- j=J` is not supported, PRs welcome :) ).
77
+ their loop variables at the toplevel of their parent module; this implies
78
+ that iteration expressions shouldn't depend on local variables (otherwise,
79
+ the testset subject usually can't be known statically and the testset can't
80
+ be filtered out with a ` Regex ` ).
81
81
82
- * Testsets can not be "custom testsets" (cf. ` Test ` documentation; this should
83
- be easy to support).
82
+ * "testsets-for" currently accept only "non-cartesian" looping (e.g. `for i=I,
83
+ j=J` is not supported, PRs welcome!)
84
+
85
+ * Testsets can not be "custom testsets" (cf. ` Test ` documentation).
84
86
85
87
* Nested testsets can't be "qualified" (i.e. written as ` ReTest.@testset ` ).
86
88
87
89
* Regex filtering logic might improve in future versions, which means that
88
90
with the same regex, less tests might be run (or more!). See
89
- [ ` retest ` ] ( @ref ) 's docstring to know what testsets are guaranteed to run.
91
+ [ ` retest ` ] ( @ref ) 's docstring to know which testsets are guaranteed to run.
90
92
91
93
* Descriptions of testsets must be unique within a module, otherwise they are
92
94
overwritten and a warning is issued, unless ` Revise ` is loaded; the reason
@@ -104,14 +106,16 @@ When used in a package `MyPackage`, the test code can be organized as follows:
104
106
` include("tests.jl"); MyPackageTests.runtests() `
105
107
106
108
This means that running "runtests.jl" will have the same net effect as before.
107
- The "tests.jl" file can now be ` include ` d in your REPL session (` include("tests.jl") ` ),
108
- and you can run all or some of its tests
109
- (e.g. ` MyPackageTests.runtests("addition") ` ).
110
- Wrapping the tests in ` MyPackageTests ` allows to not pollute ` Main ` , it keeps the tests
111
- of different packages separated, but more importantly, you can modify "tests.jl" and
112
- re-include it to have the corresponding tests updated (otherwise, without
113
- a ` MyPackageTests ` module, including the file a second time would add the new tests
114
- without removing the old ones).
109
+ The "tests.jl" file can now be ` include ` d in your REPL session
110
+ (` include("tests.jl") ` ), and you can run all or some of its tests (e.g.
111
+ ` MyPackageTests.runtests("addition") ` ).
112
+
113
+ Wrapping the tests in ` MyPackageTests ` allows to not pollute ` Main ` and keeps
114
+ the tests of different packages separated. Also, you can
115
+ modify "tests.jl" and re-include it to have the corresponding tests updated
116
+ (the ` MyPackageTests ` module is replaced in ` Main ` );
117
+ otherwise, without a ` MyPackageTests ` module, including the file a second
118
+ time currently triggers a warning for each overwritten toplevel testset.
115
119
116
120
117
121
## Filtering
@@ -135,6 +139,24 @@ instead of `@test true`, it could be useful to wrap it in its own testset, so th
135
139
it can be filtered out.
136
140
137
141
142
+ ## Running tests in parallel with ` Distributed `
143
+
144
+ Currently, the tests are automatically run in parallel whenever there are
145
+ multiple workers, which have to be set manually. The workflow looks like:
146
+ ``` julia
147
+ using Distributed
148
+ addprocs (2 )
149
+ @everywhere include (" test/tests.jl" )
150
+ MyPackageTests. runtests ()
151
+ ```
152
+
153
+ It should be relatively easy to support threaded execution of testsets (it was
154
+ actually implemented at one point). But it often happens that compiling
155
+ package code and testset code (which currently is not threaded) takes quite
156
+ more time than actually running the code, in which case using ` Distributed `
157
+ has more tangible benefits.
158
+
159
+
138
160
## Working with ` Revise `
139
161
140
162
When ` Revise ` is loaded and a testset is updated, ` ReTest ` will observe that a
169
191
## Working with test files which use ` Test `
170
192
171
193
It's sometimes possible to use ` ReTest ` features on a test code base which
172
- uses ` Test ` :
194
+ uses ` Test ` , without modifications :
173
195
174
196
- if you have a package ` Package ` , you can try ` ReTest.hijack(Package) ` , which
175
197
will define a ` PackageTests ` module when successful, on which you can call
0 commit comments