| 1 |
use Test2::V0; |
| 2 |
use Test2::Plugin::Cover; |
| 3 |
use Path::Tiny; |
| 4 |
|
| 5 |
use Test2::Harness::Util::JSON qw/encode_json/; |
| 6 |
|
| 7 |
STDIN->blocking(0); |
| 8 |
|
| 9 |
print "INPUT ${ \__FILE__ }: " . encode_json({ |
| 10 |
env => {map { ($_ => $ENV{$_}) } grep { m/^COVER_TEST_/ } keys %ENV}, |
| 11 |
argv => [@ARGV], |
| 12 |
stdin => join('' => <STDIN>), |
| 13 |
}) . "\n"; |
| 14 |
|
| 15 |
use Ax; |
| 16 |
use Bx; |
| 17 |
use Cx; |
| 18 |
|
| 19 |
Test2::Plugin::Cover->set_from_manager('Manager'); |
| 20 |
Test2::Plugin::Cover->set_root(path('t/integration/coverage/lib')->realpath); |
| 21 |
|
| 22 |
is(Cx->c, 'c', "Got c"); |
| 23 |
|
| 24 |
subtest a => sub { |
| 25 |
Test2::Plugin::Cover->set_from({subtest => 'a'}); |
| 26 |
is(Ax->a, 'a', "Got a"); |
| 27 |
is(Ax->aa, 'aa', "Got aa"); |
| 28 |
Test2::Plugin::Cover->clear_from(); |
| 29 |
}; |
| 30 |
|
| 31 |
subtest b => sub { |
| 32 |
Test2::Plugin::Cover->set_from({subtest => 'b'}); |
| 33 |
is(Ax->a, 'a', "Got a"); |
| 34 |
is(Bx->b, 'b', "Got b"); |
| 35 |
Test2::Plugin::Cover->clear_from(); |
| 36 |
}; |
| 37 |
|
| 38 |
subtest c => sub { |
| 39 |
Test2::Plugin::Cover->set_from({subtest => 'c'}); |
| 40 |
is(Ax->a, 'a', "Got a"); |
| 41 |
is(Bx->b, 'b', "Got b"); |
| 42 |
is(Cx->c, 'c', "Got c"); |
| 43 |
Test2::Plugin::Cover->clear_from(); |
| 44 |
}; |
| 45 |
|
| 46 |
done_testing; |