Skip to content

Commit

Permalink
Fix failure locations for panic tests
Browse files Browse the repository at this point in the history
A failing panic test would produce a failure location pointing to
std.test, instead of one that points to the unit test that defined the
test. This test fixes this by reusing the location the test is defined
on.

Changelog: fixed
  • Loading branch information
yorickpeterse committed Aug 3, 2023
1 parent c36952b commit bb541de
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions std/src/std/test.inko
Original file line number Diff line number Diff line change
Expand Up @@ -539,10 +539,17 @@ class pub Tests {

if code == 101 { return }

test.failures.push(Failure.new(
"the process exited with status {code}",
'the process to panic with exit status 101'
))
# These tests run in a separate OS process, and `debug.stacktrace` won't
# include any frames pointing to the unit tests's source file. To work
# around that, we reuse the test's location.
let failure = Failure {
@got = "the process exited with status {code}",
@expected = 'the process to panic with exit status 101',
@path = test.path.clone,
@line = test.line,
}

test.failures.push(failure)
}
}

Expand Down

0 comments on commit bb541de

Please sign in to comment.