julia
ff1b563e - Print more context for complex test conditions (#46138)

Commit
3 years ago
Print more context for complex test conditions (#46138) On some failures, e.g. in the cmdlineargs failure in [1], printing the failing expression doesn't give us very much information, because what we're doing is just testing a small part of a larger structure, but to really diagnose the failure, we'd really want to see the whole structure (in this case the stderr output, not just the failure bool). This introduces an additional `@testset` feature that lets failures optionally include a context variable that gets printed on failure. Example: ``` julia> @testset let v=(1,2,3) @test v[1] == 1 @test v[2] == 3 end Test Failed at REPL[8]:3 Expression: v[2] == 3 Evaluated: 2 == 3 Context: v = (1, 2, 3) ERROR: There was an error during testing ``` The syntax here is `@testset let`, which was previously unused. The testset is transparent and failures/successes are passed through directly to the parent testset. In particular, using this kind of testset does not cause additional nesting in the default testset print. [1] https://buildkite.com/julialang/julia-master/builds/14160#01822311-84f0-467a-a8af-a5d751f2c6ab/448-728
Author
Parents
Loading