From 0bbaf09fe564e679e9ca00983b57f69e9ef6d386 Mon Sep 17 00:00:00 2001 From: David Schoen Date: Sat, 27 Apr 2013 10:00:03 +1000 Subject: [PATCH] Ensure Runner::run returns valid status A recent refactor broke the return value resulting in run() and run_tests() always returning true (at least under Ubuntu). This fixes: https://github.com/Maher4Ever/guard-phpunit/issues/13 --- lib/guard/phpunit/runner.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/guard/phpunit/runner.rb b/lib/guard/phpunit/runner.rb index fa3e617..f37a884 100644 --- a/lib/guard/phpunit/runner.rb +++ b/lib/guard/phpunit/runner.rb @@ -77,13 +77,16 @@ def run_tests(paths, options) # return false in case the system call fails with no status! return false if $?.nil? - if $?.success? or tests_contain_failures? or tests_contain_errors? + # capture success so that if notifications alter the status stored in $? we still return the correct value + success = $?.success? + + if success or tests_contain_failures? or tests_contain_errors? notify_results(output, options) else notify_failure(options) end - $?.success? + success end # Displays the start testing notification. @@ -194,4 +197,4 @@ def execute_command(command) end end end -end \ No newline at end of file +end