Test-More / Test-More/test-more
Report line number in active file handle for test failures
Nobody has claimed this yet.
- Dominant language
- Perl
- Stars
- 149
- Forks
- 98
- PR merge metrics
- No merged PRs in 30d
Description
I often use the DATA block for storing test data and process that in a loop. I just realized that warn() and die() report the line number of the current file handle but tests don’t. But that would be very handy for test statements repeated in a loop.
I think it should be possible to do so. Do you agree it’s desirable?
use Test2::V0;
is <DATA> => 'foo';
warn 'warns';
die 'dies';
__DATA__
bar
$ perl test.t
# Seeded srand with seed '20221020' from local date.
not ok 1
# Failed test at test.t line 3.
# +-------+----+-------+
# | GOT | OP | CHECK |
# +-------+----+-------+
# | bar\n | eq | foo |
# +-------+----+-------+
warns at test.t line 4, <DATA> line 1.
dies at test.t line 5, <DATA> line 1.
# Tests were run but no plan was declared and done_testing() was not seen.
# Looks like your test exited with 255 after test #1.
I suggest the output should look like:
not ok 1
# Failed test at test.t line 3, <DATA> line 1.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the DATA-block example from the issue and inspect the test-failure reporting path that emits the “Failed test” location. Compare it with the warn() and die() output, then verify that failures include the active file handle and line, as in the proposed output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- perl
- Domain
- testing-qa
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100