on master help sign in
Make test script stack aware.
2f2a225Jan de Muijnck-Hughes
test/runtest.pl+35
@@ -8,18 +8,46 @@ use Env;
8my $exitstatus = 0;
8my $exitstatus = 0;
9my @idrOpts = ();
9my @idrOpts = ();
10
10
11+
12+# Determines how idris was built locally, returning a PATH modifier.
13+#
14+# Order of checking is:
15+#
16+# 1. Cabal Sandboxing
17+# 2. Stack
18+# 3. Pure cabal.
19+#
11sub sandbox_path {
20sub sandbox_path {
12 my ($test_dir,) = @_;
21 my ($test_dir,) = @_;
13 my $sandbox = "$test_dir/../../.cabal-sandbox/bin";
22 my $sandbox = "$test_dir/../../.cabal-sandbox/bin";
14
23
24+ my $stack_bin_path = `stack path --dist-dir`;
25+ $stack_bin_path =~ s/\n//g;
26+ my $stack_work_dir = "$test_dir/../../$stack_bin_path/build/idris";
27+
15 if ( -d $sandbox ) {
28 if ( -d $sandbox ) {
29+
16 my $sandbox_abs = abs_path($sandbox);
30 my $sandbox_abs = abs_path($sandbox);
31+ print "Using Cabal Sandbox\n";
32+ printf("Sandbox located at: %s\n", $sandbox_abs);
17 return "PATH=\"$sandbox_abs:$PATH\"";
33 return "PATH=\"$sandbox_abs:$PATH\"";
34+
35+ } elsif ( -d $stack_work_dir ) {
36+
37+ my $stack_work_abs = abs_path($stack_work_dir);
38+ print "Using Stack Work\n";
39+ printf("Stack work located at: %s\n", $stack_work_abs);
40+ return "PATH=\"$stack_work_abs:$PATH\"";
41+
18 } else {
42 } else {
43+ print "Using Default Cabal.\n";
19 return "";
44 return "";
20 }
45 }
21}
46}
22
47
48+# Run an individual test, and compare expected output with given
49+# output and report results.
50+#
23sub runtest {
51sub runtest {
24 my ($test, $update) = @_;
52 my ($test, $update) = @_;
25
53
@@ -73,8 +101,13 @@ sub runtest {
73 chdir "..";
101 chdir "..";
74}
102}
75
103
104+# Main test running program to sort test input, and execute individual
105+# tests.
106+#
107+
76my ( @without, @args, @tests, @opts );
108my ( @without, @args, @tests, @opts );
77
109
110+# Deal with the Args.
78if ($#ARGV>=0) {
111if ($#ARGV>=0) {
79 my $test = shift @ARGV;
112 my $test = shift @ARGV;
80 if ($test eq "all") {
113 if ($test eq "all") {
@@ -120,6 +153,8 @@ else {
120 exit;
153 exit;
121}
154}
122
155
156+# Run the tests.
157+
123my $update = 0;
158my $update = 0;
124my $diff = 0;
159my $diff = 0;
125my $show = 0;
160my $show = 0;