From d7c685b74bab99fd1b2e5f6d412abeaab2706bed Mon Sep 17 00:00:00 2001 From: boombatower Date: Thu, 9 Aug 2012 21:51:48 -0700 Subject: Issue #873496: Detect additional edge-cases in order to be sure when results are to be expected. --- review/simpletest/pifr_simpletest.client.inc | 28 +++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/review/simpletest/pifr_simpletest.client.inc b/review/simpletest/pifr_simpletest.client.inc index 9256f49..3368593 100644 --- a/review/simpletest/pifr_simpletest.client.inc +++ b/review/simpletest/pifr_simpletest.client.inc @@ -14,6 +14,8 @@ module_load_include('client.inc', 'pifr_drupal'); */ class pifr_client_review_pifr_simpletest extends pifr_client_review_pifr_drupal { + protected $skipped = FALSE; + /** * Add clone-db URL to list of files to be downloaded (if set). */ @@ -151,11 +153,20 @@ class pifr_client_review_pifr_simpletest extends pifr_client_review_pifr_drupal // '0 tests passed' false positive if (strpos($this->output, "PHP Fatal error") !== FALSE) { $this->set_error(array('@reason' => t('PHP Fatal error encountered during run_tests.sh. See review log for details.'))); + return; + } + // Since a blank file argument was not passed then an error was + // encountered since we were expecting tests. The valid case for this + // message being printed would be calling with "--file ". + if (strpos($this->output, 'ERROR: No valid tests were specified.') !== FALSE) { + $this->set_error(array('@reason' => t('run-tests.sh reported no tests were found. See review log for details.'))); + return; } } else { // Note in the review log that we didn't execute any tests. - $this->log("No Simpletest tests found. Skipping execution of run_tests.sh."); + $this->log('No test files found. Skipping execution of run_tests.sh.'); + $this->skipped = TRUE; } // Get test info for use by test_info_parse(). if (!$this->exec(PIFR_CLIENT_PHP . ' ./' . $run_tests . ' --php ' . PIFR_CLIENT_PHP . ' --url ' . $url . ' ' . $test_list . ' --list')) { @@ -384,8 +395,19 @@ class pifr_client_review_pifr_simpletest extends pifr_client_review_pifr_drupal // Remove class name keys. $result['data'] = array_values($result['data']); - // Assign the code based on the test results. - $result['code'] = $this->result_codes[$result['details']['@fail'] + $result['details']['@exception'] ? 'fail' : 'pass']; + // If no assertions were retreived from the database then set result to + // error since there should be at least one assertion. By this point the + // code in review() should have checked for any error or valid case that + // would return no results and either already exited or set $this->skipped + // to TRUE. + if (!$this->skipped && array_sum($result['details']) == 0) { + $result['code'] = $this->result_codes['review']; + $result['details']['@reason'] = 'Tests were executed, but no results were found.'; + } + else { + // Assign the code based on the test results. + $result['code'] = $this->result_codes[$result['details']['@fail'] + $result['details']['@exception'] ? 'fail' : 'pass']; + } } return $result; } -- 1.7.10.4