Skip to content

Commit ecc0a87

Browse files
gerardrochenikic
authored andcommitted
run-tests: extract usage message
Put the usage message near the top of the script, into a separate function. Closes GH-5558.
1 parent 10edee7 commit ecc0a87

File tree

1 file changed

+92
-86
lines changed

1 file changed

+92
-86
lines changed

run-tests.php

Lines changed: 92 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,97 @@
3131
* Minimum required PHP version: 7.0.0
3232
*/
3333

34+
function show_usage()
35+
{
36+
echo <<<HELP
37+
Synopsis:
38+
php run-tests.php [options] [files] [directories]
39+
40+
Options:
41+
-j<workers> Run up to <workers> simultaneous testing processes in parallel for
42+
quicker testing on systems with multiple logical processors.
43+
Note that this is experimental feature.
44+
45+
-l <file> Read the testfiles to be executed from <file>. After the test
46+
has finished all failed tests are written to the same <file>.
47+
If the list is empty and no further test is specified then
48+
all tests are executed (same as: -r <file> -w <file>).
49+
50+
-r <file> Read the testfiles to be executed from <file>.
51+
52+
-w <file> Write a list of all failed tests to <file>.
53+
54+
-a <file> Same as -w but append rather then truncating <file>.
55+
56+
-W <file> Write a list of all tests and their result status to <file>.
57+
58+
-c <file> Look for php.ini in directory <file> or use <file> as ini.
59+
60+
-n Pass -n option to the php binary (Do not use a php.ini).
61+
62+
-d foo=bar Pass -d option to the php binary (Define INI entry foo
63+
with value 'bar').
64+
65+
-g Comma separated list of groups to show during test run
66+
(possible values: PASS, FAIL, XFAIL, XLEAK, SKIP, BORK, WARN, LEAK, REDIRECT).
67+
68+
-m Test for memory leaks with Valgrind (equivalent to -M memcheck).
69+
70+
-M <tool> Test for errors with Valgrind tool.
71+
72+
-p <php> Specify PHP executable to run.
73+
74+
-P Use PHP_BINARY as PHP executable to run (default).
75+
76+
-q Quiet, no user interaction (same as environment NO_INTERACTION).
77+
78+
-s <file> Write output to <file>.
79+
80+
-x Sets 'SKIP_SLOW_TESTS' environmental variable.
81+
82+
--offline Sets 'SKIP_ONLINE_TESTS' environmental variable.
83+
84+
--verbose
85+
-v Verbose mode.
86+
87+
--help
88+
-h This Help.
89+
90+
--html <file> Generate HTML output.
91+
92+
--temp-source <sdir> --temp-target <tdir> [--temp-urlbase <url>]
93+
Write temporary files to <tdir> by replacing <sdir> from the
94+
filenames to generate with <tdir>. If --html is being used and
95+
<url> given then the generated links are relative and prefixed
96+
with the given url. In general you want to make <sdir> the path
97+
to your source files and <tdir> some patch in your web page
98+
hierarchy with <url> pointing to <tdir>.
99+
100+
--keep-[all|php|skip|clean]
101+
Do not delete 'all' files, 'php' test file, 'skip' or 'clean'
102+
file.
103+
104+
--set-timeout [n]
105+
Set timeout for individual tests, where [n] is the number of
106+
seconds. The default value is 60 seconds, or 300 seconds when
107+
testing for memory leaks.
108+
109+
--show-[all|php|skip|clean|exp|diff|out|mem]
110+
Show 'all' files, 'php' test file, 'skip' or 'clean' file. You
111+
can also use this to show the output 'out', the expected result
112+
'exp', the difference between them 'diff' or the valgrind log
113+
'mem'. The result types get written independent of the log format,
114+
however 'diff' only exists when a test fails.
115+
116+
--show-slow [n]
117+
Show all tests that took longer than [n] milliseconds to run.
118+
119+
--no-clean Do not execute clean section if any.
120+
121+
122+
HELP;
123+
}
124+
34125
/**
35126
* One function to rule them all, one function to find them, one function to
36127
* bring them all and in the darkness bind them.
@@ -530,92 +621,7 @@ function main()
530621
case 'h':
531622
case '-help':
532623
case '--help':
533-
echo <<<HELP
534-
Synopsis:
535-
php run-tests.php [options] [files] [directories]
536-
537-
Options:
538-
-j<workers> Run up to <workers> simultaneous testing processes in parallel for
539-
quicker testing on systems with multiple logical processors.
540-
Note that this is experimental feature.
541-
542-
-l <file> Read the testfiles to be executed from <file>. After the test
543-
has finished all failed tests are written to the same <file>.
544-
If the list is empty and no further test is specified then
545-
all tests are executed (same as: -r <file> -w <file>).
546-
547-
-r <file> Read the testfiles to be executed from <file>.
548-
549-
-w <file> Write a list of all failed tests to <file>.
550-
551-
-a <file> Same as -w but append rather then truncating <file>.
552-
553-
-W <file> Write a list of all tests and their result status to <file>.
554-
555-
-c <file> Look for php.ini in directory <file> or use <file> as ini.
556-
557-
-n Pass -n option to the php binary (Do not use a php.ini).
558-
559-
-d foo=bar Pass -d option to the php binary (Define INI entry foo
560-
with value 'bar').
561-
562-
-g Comma separated list of groups to show during test run
563-
(possible values: PASS, FAIL, XFAIL, XLEAK, SKIP, BORK, WARN, LEAK, REDIRECT).
564-
565-
-m Test for memory leaks with Valgrind (equivalent to -M memcheck).
566-
567-
-M <tool> Test for errors with Valgrind tool.
568-
569-
-p <php> Specify PHP executable to run.
570-
571-
-P Use PHP_BINARY as PHP executable to run (default).
572-
573-
-q Quiet, no user interaction (same as environment NO_INTERACTION).
574-
575-
-s <file> Write output to <file>.
576-
577-
-x Sets 'SKIP_SLOW_TESTS' environmental variable.
578-
579-
--offline Sets 'SKIP_ONLINE_TESTS' environmental variable.
580-
581-
--verbose
582-
-v Verbose mode.
583-
584-
--help
585-
-h This Help.
586-
587-
--html <file> Generate HTML output.
588-
589-
--temp-source <sdir> --temp-target <tdir> [--temp-urlbase <url>]
590-
Write temporary files to <tdir> by replacing <sdir> from the
591-
filenames to generate with <tdir>. If --html is being used and
592-
<url> given then the generated links are relative and prefixed
593-
with the given url. In general you want to make <sdir> the path
594-
to your source files and <tdir> some patch in your web page
595-
hierarchy with <url> pointing to <tdir>.
596-
597-
--keep-[all|php|skip|clean]
598-
Do not delete 'all' files, 'php' test file, 'skip' or 'clean'
599-
file.
600-
601-
--set-timeout [n]
602-
Set timeout for individual tests, where [n] is the number of
603-
seconds. The default value is 60 seconds, or 300 seconds when
604-
testing for memory leaks.
605-
606-
--show-[all|php|skip|clean|exp|diff|out|mem]
607-
Show 'all' files, 'php' test file, 'skip' or 'clean' file. You
608-
can also use this to show the output 'out', the expected result
609-
'exp', the difference between them 'diff' or the valgrind log
610-
'mem'. The result types get written independent of the log format,
611-
however 'diff' only exists when a test fails.
612-
613-
--show-slow [n]
614-
Show all tests that took longer than [n] milliseconds to run.
615-
616-
--no-clean Do not execute clean section if any.
617-
618-
HELP;
624+
show_usage();
619625
exit(1);
620626
}
621627
}

0 commit comments

Comments
 (0)