run-tests.php: fix TypeError: Unsupported operand types: string * int <n> is mandatory for --show-slow and --set-timeout use <n> in help message instead of confusing [n]

This commit is contained in:
Remi Collet 2022-03-24 15:41:03 +01:00 committed by Remi Collet
parent 2119ba215a
commit 23cce68d24
No known key found for this signature in database
GPG key ID: DC9FF8D3EE5AF27F

View file

@ -97,12 +97,12 @@ Options:
Do not delete 'all' files, 'php' test file, 'skip' or 'clean' Do not delete 'all' files, 'php' test file, 'skip' or 'clean'
file. file.
--set-timeout [n] --set-timeout <n>
Set timeout for individual tests, where [n] is the number of Set timeout for individual tests, where [n] is the number of
seconds. The default value is 60 seconds, or 300 seconds when seconds. The default value is 60 seconds, or 300 seconds when
testing for memory leaks. testing for memory leaks.
--context [n] --context <n>
Sets the number of lines of surrounding context to print for diffs. Sets the number of lines of surrounding context to print for diffs.
The default value is 3. The default value is 3.
@ -113,7 +113,7 @@ Options:
'mem'. The result types get written independent of the log format, 'mem'. The result types get written independent of the log format,
however 'diff' only exists when a test fails. however 'diff' only exists when a test fails.
--show-slow [n] --show-slow <n>
Show all tests that took longer than [n] milliseconds to run. Show all tests that took longer than [n] milliseconds to run.
--no-clean Do not execute clean section if any. --no-clean Do not execute clean section if any.
@ -571,7 +571,11 @@ function main(): void
$just_save_results = true; $just_save_results = true;
break; break;
case '--set-timeout': 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; break;
case '--context': case '--context':
$context_line_count = $argv[++$i] ?? ''; $context_line_count = $argv[++$i] ?? '';
@ -586,7 +590,11 @@ function main(): void
} }
break; break;
case '--show-slow': 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; break;
case '--temp-source': case '--temp-source':
$temp_source = $argv[++$i]; $temp_source = $argv[++$i];