Test-More / Test-More/test-more
subtests ignore snapshotted contexts
Nobody has claimed this yet.
- Dominant language
- Perl
- Stars
- 149
- Forks
- 98
- PR merge metrics
- No merged PRs in 30d
Description
Given the following code which attempts to preserve the context at the line where test is invoked:
use Test2::V0;
use Test2::API qw( context_do run_subtest );
sub test {
context_do {
my $ctx = shift->snapshot;
sub { $ctx->do_in_context( sub { context_do { shift->alert('') ; pass} } ) };
}
};
my $subtest = test;
# this gives correct line no
$subtest->();
# this reports incorrect line no
run_subtest( 'foo', sub { $subtest->();}, { buffered => 1, inherit_trace => 1 } );
done_testing;
I would expect that the direct execution of $subtest->() and its execution within a subtest would result in similar stack frame output, but they differ:
% perl -Ilib context.pl
# Seeded srand with seed '20200513' from local date.
at context.pl line 11.
ok 1
at context.pl line 17.
ok 2 - foo {
ok 1
1..1
}
1..2
The direct execution outputs the expected result, namely where test was called, while the subtest output is from where run_subtests was called
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
Start by running the supplied context.pl reproduction with Test2::API's context_do and run_subtest, comparing the direct and subtest stack output. Trace how the snapshotted context is used inside run_subtest with buffered and inherit_trace enabled. Done means both executions report the call site where test was invoked, with the existing test output still passing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- perl
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100