| 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 |
Test2::Plugin::Cover->set_from_manager('Manager'); |
| 8 |
Test2::Plugin::Cover->set_root(path('t/integration/coverage/lib')->realpath); |
| 9 |
|
| 10 |
STDIN->blocking(0); |
| 11 |
|
| 12 |
print "INPUT ${ \__FILE__ }: " . encode_json({ |
| 13 |
env => {map { ($_ => $ENV{$_}) } grep { m/^COVER_TEST_/ } keys %ENV}, |
| 14 |
argv => [@ARGV], |
| 15 |
stdin => join('' => <STDIN>), |
| 16 |
}) . "\n"; |
| 17 |
|
| 18 |
subtest a => sub { |
| 19 |
Test2::Plugin::Cover->set_from({subtest => 'a'}); |
| 20 |
require Ax; |
| 21 |
is(Ax->a, 'a', "Got a"); |
| 22 |
Test2::Plugin::Cover->clear_from(); |
| 23 |
}; |
| 24 |
|
| 25 |
subtest c => sub { |
| 26 |
Test2::Plugin::Cover->set_from({subtest => 'c'}); |
| 27 |
require Ax; |
| 28 |
require Cx; |
| 29 |
is(Ax->a, 'a', "Got a"); |
| 30 |
is(Cx->c, 'c', "Got c"); |
| 31 |
Test2::Plugin::Cover->clear_from(); |
| 32 |
}; |
| 33 |
|
| 34 |
done_testing; |