I want to use Test.@testset with option failfast=true
in my unit testing. But this feature requires at least Julia 1.9 and I’m testing on both newer and older versions of Julia.
I would like to define a macro or function that checks the Julia version and only sets failfast
if the version is above 1.9.
My best guess so far:
using Test
macro failfast()
@static if Base.VERSION ≥ v"1.9"
:( failfast=true )
end
end
@testset verbose=false @failfast "MyTest" begin
@test true
end
How do I prevent that the macro expression is executed immediately?
I also tried the use of code generation with @eval
, but without success.