on master help sign in
Make tests work with sandboxes
3078c0bMattias Lundell
test/runtest.pl+17−1
@@ -2,17 +2,32 @@
2
2
3use strict;
3use strict;
4use Cwd;
4use Cwd;
5+use Cwd 'abs_path';
6+use Env;
5
7
6my $exitstatus = 0;
8my $exitstatus = 0;
7my @idrOpts = ();
9my @idrOpts = ();
8
10
11+sub sandbox_path {
12+ my ($test_dir,) = @_;
13+ my $sandbox = abs_path("$test_dir/../../.cabal-sandbox/bin");
14+
15+ if ( -d $sandbox ) {
16+ return "PATH=$sandbox:$PATH";
17+ } else {
18+ return "";
19+ }
20+}
21+
9sub runtest {
22sub runtest {
10 my ($test, $update) = @_;
23 my ($test, $update) = @_;
11
24
25+ my $sandbox = sandbox_path($test);
26+
12 chdir($test);
27 chdir($test);
13
28
14 print "Running $test...\n";
29 print "Running $test...\n";
15− my $got = `./run @idrOpts`;
30+ my $got = `$sandbox ./run @idrOpts`;
16 my $exp = `cat expected`;
31 my $exp = `cat expected`;
17
32
18 open my $out, '>', 'output';
33 open my $out, '>', 'output';
@@ -62,6 +77,7 @@ if ($#ARGV>=0) {
62 }
77 }
63 }
78 }
64 @tests = sort @tests;
79 @tests = sort @tests;
80+
65 } elsif ($test eq "without") {
81 } elsif ($test eq "without") {
66 @args = @ARGV;
82 @args = @ARGV;
67 foreach my $file (@args) {
83 foreach my $file (@args) {