Add dists to .gitingore
[catagits/Test-NoTabs.git] / t / 13-badpod.t
CommitLineData
84f92d23 1use strict;
2
3use Test::More qw(no_plan);
4
5use File::Temp qw( tempdir tempfile );
6
7my $perl = $^X || 'perl';
8my $inc = join(' -I ', @INC) || '';
9$inc = "-I $inc" if $inc;
10
11# Test to check that bad Pod doesn't break subsequent files. Here the test is that
12# both files should be detected as containing tabs, when tested one after the
13# other.
14
15{
16 my $dir = tempdir();
17 make_bad_pod_file($dir);
18 make_bad_tab_file($dir);
19 my (undef, $outfile) = tempfile();
20 ok( `$perl $inc -MTest::NoTabs -e "all_perl_files_ok( '$dir' )" 2>&1 > $outfile` );
21 local $/ = undef;
22 open my $fh, '<', $outfile or die $!;
23 my $content = <$fh>;
24
25 # Filter the ok 1 line as we really don't care - it doesn't contain a tab anyway
26 $content =~ s{^ok 1[^\n]*\n}{}s;
27
28 like( $content, qr/^not ok 2 - No tabs in '[^']*' on line 4/m, 'tabs found in tmp file 2' );
29 unlink $outfile;
30 system("rm -rf $dir");
31}
32
33sub make_bad_pod_file {
34 my ($tmpdir) = @_;
35
36 # First file, template begins "a"
37 my ($fh, $filename) = tempfile( "a_badpod_XXXXXX", DIR => $tmpdir, SUFFIX => '.pL' );
38 print $fh <<"DUMMY";
39#!perl
40
41=head1
42
43Some unterminated Pod documentation follows, otherwise the file is OK
44
45DUMMY
46 close($fh);
47 return $filename;
48}
49sub make_bad_tab_file {
50 my ($tmpdir) = @_;
51
52 # Second file, template begins "b"
53 my ($fh, $filename) = tempfile( "b_badtab_podtest_XXXXXX", DIR => $tmpdir, SUFFIX => '.pL' );
54 print $fh <<"DUMMY";
55#!perl
56
57sub main {
58\tprint "Hello!\n";
59}
60
61DUMMY
62 close($fh);
63}
64