Skip to content

Commit 23cce68

Browse files
committed
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]
1 parent 2119ba2 commit 23cce68

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

run-tests.php

+13-5
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ function show_usage(): void
9797
Do not delete 'all' files, 'php' test file, 'skip' or 'clean'
9898
file.
9999
100-
--set-timeout [n]
100+
--set-timeout <n>
101101
Set timeout for individual tests, where [n] is the number of
102102
seconds. The default value is 60 seconds, or 300 seconds when
103103
testing for memory leaks.
104104
105-
--context [n]
105+
--context <n>
106106
Sets the number of lines of surrounding context to print for diffs.
107107
The default value is 3.
108108
@@ -113,7 +113,7 @@ function show_usage(): void
113113
'mem'. The result types get written independent of the log format,
114114
however 'diff' only exists when a test fails.
115115
116-
--show-slow [n]
116+
--show-slow <n>
117117
Show all tests that took longer than [n] milliseconds to run.
118118
119119
--no-clean Do not execute clean section if any.
@@ -571,7 +571,11 @@ function main(): void
571571
$just_save_results = true;
572572
break;
573573
case '--set-timeout':
574-
$environment['TEST_TIMEOUT'] = $argv[++$i];
574+
$timeout = $argv[++$i] ?? '';
575+
if (!preg_match('/^\d+$/', $timeout)) {
576+
error("'$timeout' is not a valid number of seconds, try e.g. --set-timeout 60 for 1 minute");
577+
}
578+
$environment['TEST_TIMEOUT'] = intval($timeout, 10);
575579
break;
576580
case '--context':
577581
$context_line_count = $argv[++$i] ?? '';
@@ -586,7 +590,11 @@ function main(): void
586590
}
587591
break;
588592
case '--show-slow':
589-
$slow_min_ms = $argv[++$i];
593+
$slow_min_ms = $argv[++$i] ?? '';
594+
if (!preg_match('/^\d+$/', $slow_min_ms)) {
595+
error("'$slow_min_ms' is not a valid number of milliseconds, try e.g. --show-slow 1000 for 1 second");
596+
}
597+
$slow_min_ms = intval($slow_min_ms, 10);
590598
break;
591599
case '--temp-source':
592600
$temp_source = $argv[++$i];

0 commit comments

Comments
 (0)