diff options
author | Ingo Bürk <admin@airblader.de> | 2018-06-20 08:39:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-20 08:39:59 +0200 |
commit | 64fd6e10478cabd0e2f9b554b71971a865c02d60 (patch) | |
tree | c48c1066a50479255cc5fae61eb2143a83ec5277 | |
parent | f300f6e466d1ac7164b15aab9ec2f633a3a6f958 (diff) | |
parent | bffc9ed96226dd45a820b57405a98ca0858c1fcd (diff) |
Merge pull request #289 from bebehei/testsuite
Testsuite
-rw-r--r-- | .travis.yml | 2 | ||||
-rw-r--r-- | Makefile | 3 | ||||
-rwxr-xr-x | travis/run-tests.pl | 16 |
3 files changed, 17 insertions, 4 deletions
diff --git a/.travis.yml b/.travis.yml index fc58769..71bc279 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,4 +22,4 @@ addons: script: - make -j - clang-format-3.5 -i $(find . -name "*.[ch]" | tr '\n' ' ') && git diff --exit-code || (echo 'Code was not formatted using clang-format!'; false) - - ./travis/run-tests.pl + - make test @@ -99,6 +99,9 @@ i3status: ${OBJS} $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) @echo " LD $@" +test: i3status + LC_ALL=C ./travis/run-tests.pl + clean: rm -f *.o src/*.o diff --git a/travis/run-tests.pl b/travis/run-tests.pl index 5936b7e..c335ff3 100755 --- a/travis/run-tests.pl +++ b/travis/run-tests.pl @@ -16,6 +16,7 @@ sub TestCase { my $conf = "$dir/i3status.conf"; my $testres = `./i3status --run-once -c $conf`; + my $exitcode = $?; my $refres = ""; if ( -f "@_/expected_output.txt") { @@ -28,24 +29,33 @@ sub TestCase { system($EXECUTABLE_NAME, "@_/cleanup.pl", ($dir)); } + if ( $exitcode != 0 ) { + say "Testing test case '", basename($dir), "'… ", BOLD, RED, "Crash!", RESET; + return 0; + } + 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; + say "Expected: '$refres'"; + say "Got: '$testres'"; return 0; } } my $testcases = 'testcases'; -my $testresults = 1; +my $testresults = 0; 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/^\./); - $testresults = $testresults && TestCase("$testcases/$entry"); + if (not TestCase("$testcases/$entry") ) { + $testresults = 1; + } } closedir($dir); -exit 0; +exit $testresults; |