@@ -1,242 +0,0 @@
1−#!/usr/bin/env perl
2−
3−use strict;
4−use Cwd;
5−use Cwd 'abs_path';
6−use Env;
7−
8−my $exitstatus = 0;
9−my @idrOpts = ();
10−my $quiet = 0;
11−
12−
13−# Sets the PATH if there's a sandbox or stack present
14−#
15−# Order of checking is:
16−#
17−# 1. Cabal Sandboxing
18−# 2. Stack
19−#
20−sub set_path {
21− my $sandbox = "../.cabal-sandbox/bin";
22−
23− my $stack_bin_path = `stack path --dist-dir`;
24− $stack_bin_path =~ s/\n//g;
25− my $stack_work_dir = "../$stack_bin_path/build/idris";
26− my $path = $ENV{PATH};
27−
28− if ( -d $sandbox ) {
29− my $sandbox_abs = abs_path($sandbox);
30− print "Using Cabal Sandbox\n" unless $quiet;
31− printf("Sandbox located at: %s\n", $sandbox_abs) unless $quiet;
32− $ENV{PATH} = $sandbox_abs . ":" . $path;
33−
34− } elsif ( -d $stack_work_dir ) {
35−
36− my $stack_work_abs = abs_path($stack_work_dir);
37− print "Using Stack Work\n" unless $quiet;
38− printf("Stack work located at: %s\n", $stack_work_abs) unless $quiet;
39− $ENV{PATH} = $stack_work_abs . ":" . $path;
40−
41− }
42−}
43−
44−# Run an individual test, and compare expected output with given
45−# output and report results.
46−#
47−sub runtest {
48− my ($test, $update, $showTime, $failedref, $statsref) = @_;
49−
50− chdir($test);
51−
52− my $startTime = time();
53− my $got = `./run @idrOpts`;
54− my $exp = `cat expected`;
55−
56− my $endTime = time();
57− my $elapsedTime = $endTime - $startTime;
58−
59− if ($showTime == 1 ){
60− printf("Duration of $test was %d\n", $elapsedTime);
61− }
62−
63− # Allow for variant expected output for tests by overriding expected
64− # when there is an expected.<os> file in the test.
65− # This should be the exception but there are sometimes valid reasons
66− # for os-dependent output.
67− # The endings are msys for windows, darwin for osx and linux for linux
68− if ( -e "expected.$^O") {
69− $exp = `cat expected.$^O`;
70− }
71− open my $out, '>', 'output';
72− print $out $got;
73− close $out;
74−
75− # $ok = system("diff output expected &> /dev/null");
76− # Mangle newlines in $got and $exp
77− $got =~ s/\r\n/\n/g;
78− $exp =~ s/\r\n/\n/g;
79−
80− # Normalize paths in $got and $exp, so the expected outcomes don't
81− # change between platforms
82− while($got =~ /(^|.*?\n)(.*?)\\(.*?):(\d+):(.*)/ms) {
83− $got = "$1$2/$3:$4:$5";
84− }
85− while($exp =~ /(^|.*?\n)(.*?)\\(.*?):(\d+):(.*)/ms) {
86− $exp = "$1$2/$3:$4:$5";
87− }
88−
89− if ($got eq $exp) {
90− print "$test finished...success\n";
91− $statsref->{'succeeded'}++;
92− }
93− else {
94− if ($update == 0) {
95− $exitstatus = 1;
96− print "$test finished...FAILURE\n";
97− system "diff output expected";
98− push @$failedref, $test;
99− $statsref->{'failed'}++;
100− } else {
101− system("cp output expected");
102− print "$test finished...UPDATED\n";
103− $statsref->{'updated'}++;
104− }
105− }
106− chdir "..";
107−}
108−
109−# Main test running program to sort test input, and execute individual
110−# tests.
111−#
112−
113−my ( @without, @args, @tests, @opts );
114−
115−# Deal with the Args.
116−if ($#ARGV>=0) {
117− my $test = shift @ARGV;
118− if ($test eq "all") {
119− opendir my $dir, ".";
120− my @list = readdir $dir;
121− foreach my $file (@list) {
122− if ($file =~ /[0-9][0-9][0-9]$/) {
123− push @tests, $file;
124− }
125− }
126− @tests = sort @tests;
127−
128− } elsif ($test eq "without") {
129− @args = @ARGV;
130− foreach my $file (@args) {
131− last if ($file =~ /--/);
132− push @without, shift @ARGV;
133− }
134−
135− opendir my $dir, ".";
136− my @list = readdir $dir;
137− foreach my $file (@list) {
138− if ($file =~ /[0-9][0-9][0-9]$/) {
139− if (!(grep ($_ eq $file, @without))) {
140− push @tests, $file;
141− }
142− else {
143− print "Omitting $file\n";
144− }
145− }
146− }
147− @tests = sort @tests;
148− }
149− else {
150− if ($test =~ /[0-9][0-9][0-9]$/) {
151− push @tests, $test;
152− }
153− }
154− @opts = @ARGV;
155−}
156−else {
157− print "Give a test name, or 'all' to run all.\n";
158− exit;
159−}
160−
161−# Run the tests.
162−
163−my $update = 0;
164−my $diff = 0;
165−my $show = 0;
166−my $usejava = 0;
167−my $showTime = 0;
168−
169−my @failed;
170−my %stats = (
171− total => 0,
172− succeeded => 0,
173− failed => 0,
174− updated => 0
175−);
176−
177−while (my $opt = shift @opts) {
178− if ($opt eq "-u") { $update = 1; }
179− elsif ($opt eq "-d") { $diff = 1; }
180− elsif ($opt eq "-s") { $show = 1; }
181− elsif ($opt eq "-t") { $showTime = 1; }
182− elsif ($opt eq "-q") { $quiet = 1; }
183− else { push(@idrOpts, $opt); }
184−}
185−
186−my $idris = $ENV{IDRIS};
187−
188−if (defined $ENV{IDRIS} && -e $idris ) {
189− $ENV{IDRIS} = abs_path($idris);
190− print "Using $idris\n" unless $quiet;
191−} else {
192− delete $ENV{IDRIS};
193− set_path();
194−}
195−
196−my $startTime = time();
197−
198−foreach my $test (@tests) {
199− if ($diff == 0 && $show == 0) {
200− ++$stats{'total'};
201− runtest($test,$update,$showTime, \@failed, \%stats);
202− }
203− else {
204− chdir $test;
205−
206− if ($show == 1) {
207− system "cat output";
208− }
209− if ($diff == 1) {
210− print "Differences in $test:\n";
211− my $ok = system "diff output expected";
212− if ($ok == 0) {
213− print "No differences found.\n";
214− }
215− }
216− chdir "..";
217− }
218−}
219−
220−my $endTime = time();
221−my $elapsedTime = $endTime - $startTime;
222−
223−
224−if(!$quiet) {
225− print "----\n";
226− printf("%d tests run: %d succeeded, %d failed, %d updated.\n\n",
227− $stats{'total'}, $stats{'succeeded'}, $stats{'failed'}, $stats{'updated'} );
228−
229− if (@failed) {
230− print "Failed tests:\n";
231− foreach my $failure (@failed) {
232− print "$failure\n";
233− }
234− }
235−}
236−
237−
238−if ($showTime == 1) {
239− printf("Duration of Entire Test Suite was %d\n", $elapsedTime);
240−}
241−
242−exit $exitstatus;