@@ -16,25 +16,37 @@ macro should_not_warn(expr)
16
16
end
17
17
18
18
"""
19
- check(f::Function; nowarn=[], kwargs...)
19
+ check(f::Function; nowarn=[], except=[], kwargs...)
20
20
21
21
Run Traceur on `f`, and throw an error if any warnings occur inside functions
22
- tagged with `@should_not_warn` or specified in `nowarn`. To throw an error
23
- if any warnings occur inside any functions, set `nowarn=:all`.
22
+ tagged with `@should_not_warn` or specified in `nowarn`.
23
+
24
+ To throw an error if any warnings occur inside any functions, set
25
+ `nowarn=:all`.
26
+
27
+ To throw an error if any warnings occur inside any functions EXCEPT for a
28
+ certain set of functions, list the exceptions in the `except` variable,
29
+ for example `except=[f,g,h]`
24
30
"""
25
- function check (f; nowarn= Any[], kwargs... )
26
- if nowarn isa Symbol
31
+ function check (f; nowarn= Any[], except= Any[], kwargs... )
32
+ if ! isempty (except) # if `except` is provided, we ignore the value of `nowarn`
33
+ _nowarn = Any[]
34
+ _nowarn_all = false
35
+ _nowarn_allexcept = true
36
+ elseif nowarn isa Symbol
27
37
_nowarn = Any[]
28
38
_nowarn_all = nowarn == :all
39
+ _nowarn_allexcept = false
29
40
else
30
41
_nowarn = nowarn
31
42
_nowarn_all = false
32
- end
43
+ _nowarn_allexcept = false
44
+ end
33
45
failed = false
34
46
wp = warning_printer ()
35
47
result = trace (f; kwargs... ) do warning
36
48
ix = findfirst (warning. stack) do call
37
- _nowarn_all || call. f in should_not_warn || call. f in _nowarn
49
+ _nowarn_all || call. f in should_not_warn || call. f in _nowarn || (_nowarn_allexcept && ! (call . f in except))
38
50
end
39
51
if ix != nothing
40
52
tagged_function = warning. stack[ix]. f
@@ -49,11 +61,17 @@ function check(f; nowarn=Any[], kwargs...)
49
61
end
50
62
51
63
"""
52
- @check fun(args...) nowarn=[] maxdepth=typemax(Int)
64
+ @check fun(args...) nowarn=[] except=[] maxdepth=typemax(Int)
53
65
54
66
Run Traceur on `fun`, and throw an error if any warnings occur inside functions
55
- tagged with `@should_not_warn` or specified in `nowarn`. To throw an error
56
- if any warnings occur inside any functions, set `nowarn=:all`.
67
+ tagged with `@should_not_warn` or specified in `nowarn`.
68
+
69
+ To throw an error if any warnings occur inside any functions, set
70
+ `nowarn=:all`.
71
+
72
+ To throw an error if any warnings occur inside any functions EXCEPT for a
73
+ certain set of functions, list the exceptions in the `except` variable,
74
+ for example `except=[f,g,h]`
57
75
"""
58
76
macro check (expr, args... )
59
77
quote
0 commit comments