--- run-tests.php.bak Fri Feb 17 13:52:36 2006 +++ run-tests.php Fri Feb 17 15:36:49 2006 @@ -170,7 +170,7 @@ // Get info from php $info_file = realpath(dirname(__FILE__)) . '/run-test-info.php'; - @unlink($info_file); + if (file_exists($info_file)) @unlink($info_file); $php_info = ' + Do not prompt for user interaction, and send the test results, + from the specified email address. + HELP; exit(1); } @@ -526,7 +535,7 @@ $test_dirs = array('tests', 'ext'); $optionals = array('Zend', 'ZendEngine2'); foreach($optionals as $dir) { - if (@filetype($dir) == 'dir') { + if (is_dir($dir)) { $test_dirs[] = $dir; } } @@ -635,8 +644,8 @@ define('PHP_QA_EMAIL', 'qa-reports@lists.php.net'); define('QA_SUBMISSION_PAGE', 'http://qa.php.net/buildtest-process.php'); -/* We got failed Tests, offer the user to send an e-mail to QA team, unless NO_INTERACTION is set */ -if (!getenv('NO_INTERACTION')) { +/* We got failed Tests, offer the user to send an e-mail to QA team, unless NO_INTERACTION is set, or we already have an email address. */ +if (!getenv('NO_INTERACTION') && !isset($user_email)) { $fp = fopen("php://stdin", "r+"); echo "\nYou may have found a problem in PHP.\nWe would like to send this report automatically to the\n"; echo "PHP QA team, to give us a better understanding of how\nthe test cases are doing. If you don't want to send it\n"; @@ -646,6 +655,13 @@ $user_input = fgets($fp, 10); $just_save_results = (strtolower($user_input[0]) == 's'); } + +/* If the user has already supplied their email address, then we can assume they are happy for the results to be sent to the QA team */ +if (isset($user_email)) { + $just_save_results = false; + $user_input = "Y"; +} + if ($just_save_results || !getenv('NO_INTERACTION')) { if ($just_save_results || strlen(trim($user_input)) == 0 || strtolower($user_input[0]) == 'y') { /* @@ -660,9 +676,11 @@ } /* Ask the user to provide an email address, so that QA team can contact the user */ if (!strncasecmp($user_input, 'y', 1) || strlen(trim($user_input)) == 0) { + if (!isset($user_email)) { echo "\nPlease enter your email address.\n(Your address will be mangled so that it will not go out on any\nmailinglist in plain text): "; flush(); $user_email = trim(fgets($fp, 1024)); + } $user_email = str_replace("@", " at ", str_replace(".", " dot ", $user_email)); } @@ -968,7 +986,7 @@ // the redirect section allows a set of tests to be reused outside of // a given test dir - if (@count($section_text['REDIRECTTEST']) == 1) { + if (isset($section_text['REDIRECTTEST']) && @count($section_text['REDIRECTTEST']) == 1) { if ($IN_REDIRECT) { $borked = true; $bork_info = "Can't redirect a test from within a redirected test"; @@ -976,15 +994,17 @@ $borked = false; } } else { - if (@count($section_text['FILE']) + @count($section_text['FILEEOF']) != 1) { + if (@count($section_text['FILE']) + (isset($section_text['FILEEOF']) ? @count($section_text['FILEEOF']) : 0) != 1) { $bork_info = "missing section --FILE--"; $borked = true; } - if (@count($section_text['FILEEOF']) == 1) { + if (isset($section_text['FILEEOF']) && @count($section_text['FILEEOF']) == 1) { $section_text['FILE'] = preg_replace("/[\r\n]+$/", '', $section_text['FILEEOF']); unset($section_text['FILEEOF']); } - if ((@count($section_text['EXPECT']) + @count($section_text['EXPECTF']) + @count($section_text['EXPECTREGEX'])) != 1) { + if ( ( (isset($section_text['EXPECT']) ? @count($section_text['EXPECT']) : 0) + + (isset($section_text['EXPECTF']) ? @count($section_text['EXPECTF']) : 0) + + (isset($section_text['EXPECTREGEX']) ? @count($section_text['EXPECTREGEX']): 0) ) != 1) { $bork_info = "missing section --EXPECT--, --EXPECTF-- or --EXPECTREGEX--"; $borked = true; } @@ -1079,18 +1099,18 @@ } // unlink old test results - @unlink($diff_filename); - @unlink($log_filename); - @unlink($exp_filename); - @unlink($output_filename); - @unlink($memcheck_filename); - @unlink($temp_file); - @unlink($test_file); - @unlink($temp_skipif); - @unlink($test_skipif); - @unlink($tmp_post); - @unlink($temp_clean); - @unlink($test_clean); + if (file_exists($diff_filename)) @unlink($diff_filename); + if (file_exists($log_filename)) @unlink($log_filename); + if (file_exists($exp_filename)) @unlink($exp_filename); + if (file_exists($output_filename)) @unlink($output_filename); + if (file_exists($memcheck_filename)) @unlink($memcheck_filename); + if (file_exists($temp_file)) @unlink($temp_file); + if (file_exists($test_file)) @unlink($test_file); + if (file_exists($temp_skipif)) @unlink($temp_skipif); + if (file_exists($test_skipif)) @unlink($test_skipif); + if (file_exists($tmp_post)) @unlink($tmp_post); + if (file_exists($temp_clean)) @unlink($temp_clean); + if (file_exists($test_clean)) @unlink($test_clean); // Reset environment from any previous test. $env['REDIRECT_STATUS']=''; @@ -1173,7 +1193,7 @@ } } - if (@count($section_text['REDIRECTTEST']) == 1) { + if (isset($section_text['REDIRECTTEST']) && @count($section_text['REDIRECTTEST']) == 1) { $test_files = array(); $IN_REDIRECT = eval($section_text['REDIRECTTEST']); @@ -1208,7 +1228,7 @@ return 'REDIR'; } } - if (is_array($org_file) || @count($section_text['REDIRECTTEST']) == 1) { + if (is_array($org_file) || (isset($section_text['REDIRECTTEST']) && @count($section_text['REDIRECTTEST']) == 1)) { if (is_array($org_file)) $file = $org_file[0]; $bork_info = "Redirected test did not contain redirection info"; show_result("BORK", $bork_info, '', $temp_filenames); @@ -1304,7 +1324,7 @@ } } - @unlink($tmp_post); + if (file_exists($tmp_post)) @unlink($tmp_post); $leaked = false; $passed = false;