Skip to content

Commit e0009b5

Browse files
committed
tools/test: Simplify handling of suites list
This makes for a bit less duplication in the code; fewer places to have to update when adding a new suite. The CLI-parsing logic also gets a bit simpler. I think this also makes the usage message a bit simpler to understand. Like the existing version, it's a bit awkward as long as there are no non-default suites; but we'll be adding one of those shortly.
1 parent e785388 commit e0009b5

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

tools/test

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,23 @@ this_dir=${BASH_SOURCE[0]%/*}
2222

2323
## CLI PARSING
2424

25+
default_suites=(native flow lint jest prettier deps tsflower)
26+
extra_suites=()
27+
2528
usage() {
2629
cat >&2 <<EOF
2730
usage: tools/test [OPTION]... [SUITE]...
2831
2932
Run our tests.
3033
31-
By default, run all suites except any noted under "Suites:" below, but only
32-
on files changed in this branch as found by
34+
By default, run only on files changed in this branch as found by
3335
\`tools/git changed-files \$(tools/git base)\`.
3436
37+
By default, run ${#default_suites[@]} suite(s):
38+
${default_suites[*]}
39+
and skip ${#extra_suites[@]} suite(s):
40+
${extra_suites[*]}
41+
3542
What tests to run:
3643
--all-files
3744
Run on all files, not only changed files.
@@ -57,32 +64,15 @@ Extra things to do:
5764
--coverage Collect test-coverage information. Only meaningful
5865
with --all.
5966
--fix Fix issues found, where possible.
60-
61-
Suites:
62-
native
63-
flow
64-
lint
65-
jest
66-
prettier
67-
deps
68-
tsflower
6967
EOF
7068
exit 2
7169
}
7270

73-
# The complete list of suites.
74-
all_suites=(native flow lint jest prettier deps tsflower)
75-
7671
opt_coverage=
7772
opt_files=branch
7873
opt_platform=sloppy
74+
opt_all=
7975
opt_fix=
80-
81-
# The suites to run if none are given as arguments. Unless --all is
82-
# specified, this doesn't have to be the complete list; just be sure to
83-
# document in the usage message when a suite gets skipped.
84-
opt_default_suites=(native flow lint jest prettier deps tsflower)
85-
8676
opt_suites=()
8777
while (( $# )); do
8878
case "$1" in
@@ -97,7 +87,7 @@ while (( $# )); do
9787
esac
9888
shift
9989
;;
100-
--all) opt_files=all; opt_platform=both; opt_default_suites=( "${all_suites[@]}" ); shift;;
90+
--all) opt_files=all; opt_platform=both; opt_all=1; shift;;
10191
--fix) opt_fix=1; shift;;
10292
native|flow|lint|jest|prettier|deps|tsflower)
10393
opt_suites+=("$1"); shift;;
@@ -106,7 +96,11 @@ while (( $# )); do
10696
done
10797

10898
if [ -z "$opt_suites" ]; then
109-
opt_suites=( "${opt_default_suites[@]}" )
99+
if [ -n "${opt_all}" ]; then
100+
opt_suites=( "${default_suites[@]}" "${extra_suites[@]}" )
101+
else
102+
opt_suites=( "${default_suites[@]}" )
103+
fi
110104
fi
111105

112106
files_base_commit=

0 commit comments

Comments
 (0)