File: shell_harness

package info (click to toggle)
darcs 2.0.2-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 6,400 kB
  • ctags: 1,048
  • sloc: haskell: 24,937; perl: 9,736; sh: 3,369; ansic: 1,913; makefile: 17; xml: 14
file content (72 lines) | stat: -rw-r--r-- 1,686 bytes parent folder | download
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/perl -w

# Run each of the shell tests, capturing the output, and reporting passed 
# or failed.

use Cwd;

# Place to put test output to avoid cluttering test/
mkdir 'test_output', 0750;

# Override the users default .darcs settings
$ENV{HOME} = cwd();
mkdir '.darcs';
system 'echo ALL --ignore-times >> .darcs/defaults';
# Used for finding darcs, but may not be defined by the shell
$ENV{PWD} = cwd();

# Put the right darcs first in PATH
my $darcspath="$ENV{HOME}/..";
if ($ENV{DARCS}) {
  # User has asked for a particular darcs...
  my $actualdarcs=`which $ENV{DARCS}`;
  my $darcspath=`dirname "$actualdarcs"`;
}
$ENV{PATH} = "$darcspath:$ENV{PATH}";

# Some environment variables can act as defaults that we don't want
$ENV{EMAIL} = $ENV{DARCS_EMAIL} = 'tester';

# These two environment variables will turn off darcs' "Christmas mode".
# It will make the tests run a tad faster, and make darcs' output
# independent of the testing systems locale and environment.
$ENV{DARCS_DONT_COLOR} = 1;
$ENV{DARCS_DONT_ESCAPE_ANYTHING} = 1;

my $OK = 1;
my @Failures;
    
`which bash`;
if( $? != 0 ) {
    die "You need bash to run the shell tests!"
}

for my $test (@ARGV) {
    my $test_out = "test_output/$test.out";

    printf "Running %-40s", "$test ...";

    my $output = `bash $test 2>&1`;

    if( $? == 0 ) {
        print " passed.\n";
    }
    else {
        $OK = 0;
        push @Failures, $test;

        print " FAILED!\n";
        print "Output from failed $test:\n$output";
    }
}

if ($OK) {
    print "All tests successful!\n";
}
else {
    print "TESTS FAILED!\n";
    print "\t$_\n" for @Failures;
}

# Exit with non-zero if anything failed.
exit !$OK;