diff --git a/run-tests.php b/run-tests.php index 36ed068d0ea..307fcf71e71 100755 --- a/run-tests.php +++ b/run-tests.php @@ -103,12 +103,12 @@ Options: Do not delete 'all' files, 'php' test file, 'skip' or 'clean' file. - --set-timeout [n] + --set-timeout Set timeout for individual tests, where [n] is the number of seconds. The default value is 60 seconds, or 300 seconds when testing for memory leaks. - --context [n] + --context Sets the number of lines of surrounding context to print for diffs. The default value is 3. @@ -119,7 +119,7 @@ Options: 'mem'. The result types get written independent of the log format, however 'diff' only exists when a test fails. - --show-slow [n] + --show-slow Show all tests that took longer than [n] milliseconds to run. --no-clean Do not execute clean section if any. @@ -530,7 +530,11 @@ function main(): void $just_save_results = true; break; case '--set-timeout': - $environment['TEST_TIMEOUT'] = $argv[++$i]; + $timeout = $argv[++$i] ?? ''; + if (!preg_match('/^\d+$/', $timeout)) { + error("'$timeout' is not a valid number of seconds, try e.g. --set-timeout 60 for 1 minute"); + } + $environment['TEST_TIMEOUT'] = intval($timeout, 10); break; case '--context': $context_line_count = $argv[++$i] ?? ''; @@ -545,7 +549,11 @@ function main(): void } break; case '--show-slow': - $slow_min_ms = $argv[++$i]; + $slow_min_ms = $argv[++$i] ?? ''; + if (!preg_match('/^\d+$/', $slow_min_ms)) { + error("'$slow_min_ms' is not a valid number of milliseconds, try e.g. --show-slow 1000 for 1 second"); + } + $slow_min_ms = intval($slow_min_ms, 10); break; case '--temp-source': $temp_source = $argv[++$i];