2016-11-14 08:13:44 +00:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
|
|
|
use v5.10;
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
2017-08-29 17:01:30 +00:00
|
|
|
use English;
|
2016-11-14 08:13:44 +00:00
|
|
|
use Term::ANSIColor qw(:constants);
|
|
|
|
use File::Basename;
|
|
|
|
|
|
|
|
sub TestCase {
|
|
|
|
my ($dir) = @_;
|
2017-08-29 17:01:30 +00:00
|
|
|
|
|
|
|
if ( -f "@_/setup.pl") {
|
|
|
|
system($EXECUTABLE_NAME, "@_/setup.pl", ($dir));
|
|
|
|
}
|
|
|
|
|
2016-11-14 08:13:44 +00:00
|
|
|
my $conf = "$dir/i3status.conf";
|
2019-01-23 07:56:40 +00:00
|
|
|
my $testres = `cd @abs_top_srcdir@ && LC_ALL=C @abs_top_builddir@/i3status --run-once -c $conf`;
|
2018-06-19 14:44:37 +00:00
|
|
|
my $exitcode = $?;
|
2016-11-14 08:13:44 +00:00
|
|
|
my $refres = "";
|
|
|
|
|
|
|
|
if ( -f "@_/expected_output.txt") {
|
|
|
|
$refres = `cat "@_/expected_output.txt"`;
|
2017-08-29 17:01:30 +00:00
|
|
|
} elsif ( -f "@_/expected_output.pl") {
|
|
|
|
$refres = `$EXECUTABLE_NAME @_/expected_output.pl`;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( -f "@_/cleanup.pl") {
|
|
|
|
system($EXECUTABLE_NAME, "@_/cleanup.pl", ($dir));
|
2016-11-14 08:13:44 +00:00
|
|
|
}
|
|
|
|
|
2018-06-19 14:44:37 +00:00
|
|
|
if ( $exitcode != 0 ) {
|
|
|
|
say "Testing test case '", basename($dir), "'… ", BOLD, RED, "Crash!", RESET;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-11-14 08:13:44 +00:00
|
|
|
if ( "$testres" eq "$refres" ) {
|
|
|
|
say "Testing test case '", basename($dir), "'… ", BOLD, GREEN, "OK", RESET;
|
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
say "Testing test case '", basename($dir), "'… ", BOLD, RED, "Failed!", RESET;
|
2018-06-19 15:15:28 +00:00
|
|
|
say "Expected: '$refres'";
|
|
|
|
say "Got: '$testres'";
|
2016-11-14 08:13:44 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-23 07:56:40 +00:00
|
|
|
my $testcases = '@abs_top_srcdir@/testcases';
|
2018-06-19 14:58:15 +00:00
|
|
|
my $testresults = 0;
|
2016-11-14 08:13:44 +00:00
|
|
|
|
|
|
|
opendir(my $dir, $testcases) or die "Could not open directory $testcases: $!";
|
|
|
|
|
|
|
|
while (my $entry = readdir($dir)) {
|
|
|
|
next unless (-d "$testcases/$entry");
|
|
|
|
next if ($entry =~ m/^\./);
|
2018-06-19 14:58:15 +00:00
|
|
|
if (not TestCase("$testcases/$entry") ) {
|
|
|
|
$testresults = 1;
|
|
|
|
}
|
2016-11-14 08:13:44 +00:00
|
|
|
}
|
|
|
|
closedir($dir);
|
2018-06-19 14:58:15 +00:00
|
|
|
exit $testresults;
|