Skip to content

Commit

Permalink
Use a more modern perl for coverage checking;
Browse files Browse the repository at this point in the history
re-jig show_types() tests so the code can be coverage-checked
  • Loading branch information
DrHyde committed Apr 18, 2024
1 parent 2fd90a5 commit 8fbfc2d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coveralls.yml
Expand Up @@ -7,7 +7,7 @@ jobs:
- uses: actions/checkout@v4
- uses: shogo82148/actions-setup-perl@v1
with:
perl-version: 5.32
perl-version: 5.38
- name: Run with coverage checking
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion lib/Test2/Tools/Type.pm
Expand Up @@ -31,7 +31,7 @@ sub import {
if(grep { $_ eq 'show_types' } @_) {
print "Supported types:\n";
print " ".substr($_, 3)."\n" foreach(sort grep { /^is_/ } @EXPORT);
exit;
return;
}
}
goto &Exporter::import;
Expand Down
52 changes: 26 additions & 26 deletions t/test2-tools-type.t
@@ -1,5 +1,5 @@
use Test2::V0;
use Test2::Tools::Type;
use Test2::Tools::Type; # NB no :extras!
use Test2::API qw/intercept/;

use Capture::Tiny qw(capture);
Expand All @@ -10,7 +10,31 @@ ok(
"extra functions aren't available unless asked for"
);

Test2::Tools::Type->import(':extras');
subtest "show supported types" => sub {
my $types_supported = capture {
Test2::Tools::Type->import(qw(show_types))
};
like
$types_supported,
match(qr/\n number\n/),
"default types";
like
$types_supported,
!match(qr/\n positive\n/),
"default types doesn't include the extras";

# this does *not* make extras available for the test of the tests
# because `show_types` aborts import() before it can do anything
$types_supported = capture {
Test2::Tools::Type->import(qw(show_types :extras))
};
like
$types_supported,
match(qr/\n positive\n/),
":extras makes extras visible";
};

Test2::Tools::Type->import(qw(:extras));

subtest "is_* tests" => sub {
my $events = intercept {
Expand Down Expand Up @@ -367,28 +391,4 @@ subtest "checks don't mess with types" => sub {
);
};

subtest "show supported types" => sub {
my $types_supported = capture { system(
$Config{perlpath}, (map { "-I$_" } (@INC)),
qw(-MTest2::Tools::Type=show_types -e0)
) };
like
$types_supported,
match(qr/\n number\n/),
"default types";
like
$types_supported,
!match(qr/\n positive\n/),
"default types doesn't include the extras";

$types_supported = capture { system(
$Config{perlpath}, (map { "-I$_" } (@INC)),
'-MTest2::Tools::Type=show_types,:extras'
) };
like
$types_supported,
match(qr/\n positive\n/),
":extras makes extras available";
};

done_testing;

0 comments on commit 8fbfc2d

Please sign in to comment.