@@ -8,18 +8,46 @@ use Env;
88my $exitstatus = 0;
99my @idrOpts = ();
1010
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+#
1120sub sandbox_path {
1221 my ($test_dir,) = @_;
1322 my $sandbox = "$test_dir/../../.cabal-sandbox/bin";
1423
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+
1528 if ( -d $sandbox ) {
29+
1630 my $sandbox_abs = abs_path($sandbox);
31+ print "Using Cabal Sandbox\n";
32+ printf("Sandbox located at: %s\n", $sandbox_abs);
1733 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+
1842 } else {
43+ print "Using Default Cabal.\n";
1944 return "";
2045 }
2146}
2247
48+# Run an individual test, and compare expected output with given
49+# output and report results.
50+#
2351sub runtest {
2452 my ($test, $update) = @_;
2553
@@ -73,8 +101,13 @@ sub runtest {
73101 chdir "..";
74102}
75103
104+# Main test running program to sort test input, and execute individual
105+# tests.
106+#
107+
76108my ( @without, @args, @tests, @opts );
77109
110+# Deal with the Args.
78111if ($#ARGV>=0) {
79112 my $test = shift @ARGV;
80113 if ($test eq "all") {
@@ -120,6 +153,8 @@ else {
120153 exit;
121154}
122155
156+# Run the tests.
157+
123158my $update = 0;
124159my $diff = 0;
125160my $show = 0;