update readmes
[git-darcs-import.git] / tests / shell_harness
blob585af5c30db7fa504e00273fede9e146cd5238b6
1 #!/usr/bin/perl -w
3 # Run each of the shell tests, capturing the output, and reporting passed
4 # or failed.
6 use Cwd;
8 # Place to put test output to avoid cluttering test/
9 mkdir 'test_output', 0750;
11 # Override the users default .darcs settings
12 $ENV{HOME} = cwd();
13 mkdir '.darcs';
14 system 'echo ALL --ignore-times >> .darcs/defaults';
15 # Used for finding darcs, but may not be defined by the shell
16 $ENV{PWD} = cwd();
18 # Put the right darcs first in PATH
19 my $darcspath="$ENV{HOME}/..";
20 if ($ENV{DARCS}) {
21 # User has asked for a particular darcs...
22 my $actualdarcs=`which $ENV{DARCS}`;
23 my $darcspath=`dirname "$actualdarcs"`;
25 $ENV{PATH} = "$darcspath:$ENV{PATH}";
27 # Some environment variables can act as defaults that we don't want
28 $ENV{EMAIL} = $ENV{DARCS_EMAIL} = 'tester';
30 # These two environment variables will turn off darcs' "Christmas mode".
31 # It will make the tests run a tad faster, and make darcs' output
32 # independent of the testing systems locale and environment.
33 $ENV{DARCS_DONT_COLOR} = 1;
34 $ENV{DARCS_DONT_ESCAPE_ANYTHING} = 1;
36 my $OK = 1;
37 my @Failures;
39 for my $test (@ARGV) {
40 my $test_out = "test_output/$test.out";
42 printf "Running %-40s", "$test ...";
44 my $output = `bash $test 2>&1`;
46 if( $? == 0 ) {
47 print " passed.\n";
49 else {
50 $OK = 0;
51 push @Failures, $test;
53 print " FAILED!\n";
54 print "Output from failed $test:\n$output";
58 if ($OK) {
59 print "All tests successful!\n";
61 else {
62 print "TESTS FAILED!\n";
63 print "\t$_\n" for @Failures;
66 # Exit with non-zero if anything failed.
67 exit !$OK;