summaryrefslogtreecommitdiff
path: root/t/01-basic.t
blob: c687dcae93fe09274bf7830350865e5c25481621 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env perl
# -*-mode:cperl; indent-tabs-mode: nil-*-

## Basic tests of Things That Should Always Work
## Any failures of important files immediately call BAIL_OUT

use strict;
use warnings;
use Data::Dumper;
use lib 't','.';
use Test::More;
use BucardoTesting;

my @important_files = qw{Bucardo.pm bucardo };

opendir my $dh, 't' or die qq{Could not open the 't' directory: are you running this from the right place?\n};
my @test_files = grep { /\.t$/ } readdir $dh;
closedir $dh or warn qq{Could not close the 't' directory: $!\n};

opendir $dh, 'scripts' or die qq{Could not open the 'scripts' directory};
my @script_files = grep { /^[a-z]/ } readdir $dh;
closedir $dh or warn qq{Could not close the 'scripts' directory: $!\n};

if (! eval { require CGI; } ) {
    @script_files = grep { ! /bucardo-report/ } @script_files;
}

plan tests => @important_files + @test_files + @script_files;

for my $file (@important_files) {
    my $t=qq{File $file compiles without errors};
    eval {
        require $file;
    };
    is($@, q{}, $t);
    $@ and BAIL_OUT qq{Cannot continue until $file compiles cleanly\n};
}

for my $file (@test_files) {
    my $t=qq{File $file compiles without errors};
    my $com = "perl -c t/$file 2>&1";
    my $res = qx{$com};
    chomp $res;
    is($res, qq{t/$file syntax OK}, $t);
}

for my $file (@script_files) {
    my $t=qq{File $file compiles without errors};
    my $com = "perl -c scripts/$file 2>&1";
    my $res = qx{$com};
    chomp $res;
    is($res, qq{scripts/$file syntax OK}, $t);
}

exit;