From bc29d468ca20ce84c3753d83116348d977604822 Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Tue, 19 Jun 2018 16:44:37 +0200 Subject: Fail the tests, if i3status actually crashes --- travis/run-tests.pl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/travis/run-tests.pl b/travis/run-tests.pl index 5936b7e..1b3af77 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,6 +29,11 @@ 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; -- cgit v1.2.3 From adc9348e80cd0e0b1b5614433e33d1ff63e0e19d Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Tue, 19 Jun 2018 16:56:48 +0200 Subject: Expose the testsuite in the Makefile --- .travis.yml | 2 +- Makefile | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) 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 diff --git a/Makefile b/Makefile index 86830ef..5ec5871 100644 --- a/Makefile +++ b/Makefile @@ -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 -- cgit v1.2.3 From a073acd40666019305e14da9c997537b15d825d5 Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Tue, 19 Jun 2018 16:58:15 +0200 Subject: Run all travis tests and expose the final result as exit code --- travis/run-tests.pl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/travis/run-tests.pl b/travis/run-tests.pl index 1b3af77..960af2e 100755 --- a/travis/run-tests.pl +++ b/travis/run-tests.pl @@ -44,14 +44,16 @@ sub TestCase { } 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; -- cgit v1.2.3 From bffc9ed96226dd45a820b57405a98ca0858c1fcd Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Tue, 19 Jun 2018 17:15:28 +0200 Subject: Show differing results, if testcase fails --- travis/run-tests.pl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/travis/run-tests.pl b/travis/run-tests.pl index 960af2e..c335ff3 100755 --- a/travis/run-tests.pl +++ b/travis/run-tests.pl @@ -39,6 +39,8 @@ sub TestCase { return 1; } else { say "Testing test case '", basename($dir), "'… ", BOLD, RED, "Failed!", RESET; + say "Expected: '$refres'"; + say "Got: '$testres'"; return 0; } } -- cgit v1.2.3