4
4
5
5
This package allows:
6
6
7
- 1 . defining tests in source files, whose execution is deferred and triggered on demand.
7
+ 1 . Defining tests in source files, whose execution is deferred and triggered on demand.
8
8
9
9
This is useful when one likes to have definitions of methods and
10
10
corresponding tests close to each other. This is also useful for code which
11
11
is not (yet) organized as a package, and where one doesn't want to maintain a
12
12
separate set of files for tests.
13
13
14
- 2 . filtering run testsets with a ` Regex ` , which is matched against the
14
+ 2 . Filtering run testsets with a ` Regex ` , which is matched against the
15
15
descriptions of testsets.
16
16
17
17
This is useful for running only part of the test suite of a package. For
18
18
example, if you made a change related to addition, and included "addition" in
19
- the description of the corresponding tetstsets , you can easily run only these
19
+ the description of the corresponding testsets , you can easily run only these
20
20
tests.
21
21
22
22
Note that a [ pull request] ( https://github.com/JuliaLang/julia/pull/33672 )
23
23
exists in the Julia repository to implement regex-filtering for
24
24
` Test.@testset ` .
25
25
26
26
The exported ` ReTest.@testset ` macro can be used as a direct replacement for
27
- ` Test.@testset ` , and ` runtests() ` has to be called for the tests to be executed.
28
- See the docstrings (reproduced below) for more details. Moreover, ` ReTest `
29
- re-exports (almost) all exported symbols from ` Test ` , so there should not be any
30
- need to import ` Test ` together with ` ReTest ` .
27
+ ` Test.@testset ` (with limitations, see below), and ` runtests() ` has to be called
28
+ for the tests to be executed. See the docstrings (reproduced below) for more
29
+ details. Moreover, ` ReTest ` re-exports (almost) all exported symbols from
30
+ ` Test ` , so there should not be any need to import ` Test ` together with ` ReTest ` .
31
31
32
32
### ` runtests ` docstring
33
33
@@ -58,7 +58,9 @@ matched by `pattern`) and its subject matches `pattern`.
58
58
59
59
If the passed ` pattern ` is a string, then it is wrapped in a ` Regex ` prefixed with
60
60
` ".*" ` , and must match literally the subjects.
61
- This means for example that ` "a|b" ` will match a subject like ` "a|b" ` but not like ` "a" ` .
61
+ This means for example that ` "a|b" ` will match a subject like ` "a|b" ` but not like ` "a" `
62
+ (only in Julia versions >= 1.3; in older versions, the regex is simply created as
63
+ ` Regex(".*" * pattern) ` ).
62
64
The ` ".*" ` prefix is intended to allow matching subjects of nested testsets,
63
65
e.g. in the example above, ` r".*b" ` partially matches the subject ` "/a" ` and
64
66
matches the subject ` "/a/b" ` (so the corresponding nested testset is run),
@@ -83,8 +85,8 @@ module in which it was written (e.g. `m`, when specified).
83
85
j=J` is not supported). Both problems should be fixable.
84
86
85
87
Related to the previous point: in future versions, nested testsets-for might
86
- have their "iterator" (giving the values their loop variables) ` eval ` ed at the
87
- module's toplevel (for efficiency).
88
+ have their "iterator" (giving the values to their loop variables) ` eval ` ed at
89
+ the module's toplevel (for efficiency).
88
90
89
91
* Testsets can not be "custom testsets" (cf. ` Test ` documentation; this should
90
92
be easy to support).
@@ -122,7 +124,7 @@ filter them out (if a filtering pattern is given to `runtests`) "statically",
122
124
i.e. by introspection, we can figure out whether they should be run before
123
125
having to ` eval ` the corresponding code. This is a big win, in particular for
124
126
` testsets-for ` , which are expensive to compile. This allows ` ReTest ` to
125
- compete with the good-old manual way of copy-pasting the wanted ` @testset ` into
127
+ compete with the good ol' manual way of copy-pasting the wanted ` @testset ` into
126
128
the REPL (without this trick, all the testsets would have to be ` eval ` ed, even
127
129
when they don't run any code, and this can take some time for large test
128
130
codebases.
@@ -176,5 +178,5 @@ Note also that partial matching often gives a false positive, e.g. running
176
178
` runtests(M, "d") ` will currently instantiate ` @testset "a" ` because it might
177
179
contain a sub-testset ` "d" ` , so ` @test true ` above will be run, even if
178
180
eventually no testset matches ` "d" ` . So it's recommended to put expensive tests
179
- withing "final" testsets (those which don't have nested testsets), such that
181
+ within "final" testsets (those which don't have nested testsets), such that
180
182
"full matching" is used instead of partial matching.
0 commit comments