Skip to content

Commit

Permalink
Check that tests use strict and warnings
Browse files Browse the repository at this point in the history
t/repo.pl wasn't using strict/warnings, causing me to miss some issues
with cleanup.
  • Loading branch information
torbiak committed Jan 7, 2024
1 parent 28761e9 commit d759b89
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions xt/strict.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/perl

# Check that test files and test libs are using string and warnings.

use strict;
use warnings FATAL => 'all';

use Test::More;

sub is_strict_and_warn {
my $filename = shift;
my ($is_strict, $is_warn);
open my $fh, '<', $filename or die "check $filename: $!";
for (<$fh>) {
m/^use strict;/ and $is_strict = 1;
m/^use warnings/ and $is_warn = 1;
if ($is_strict && $is_warn) {
return 1;
}
}
return 0;
}

my @filenames = glob('t/*.t t/*.pl xt/*.t xt/*.pl');
plan tests => scalar(@filenames);
for my $fn (@filenames) {
ok(is_strict_and_warn($fn), "$fn is using strict and warnings");
}

0 comments on commit d759b89

Please sign in to comment.