-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
4 changed files
with
126 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters