Skip to content

Commit 6c5391e

Browse files
gnpricechrisbobbe
authored andcommitted
tools/test: Fix name collision on "files", saying "opt_files"
We've had the name "files" for both a global representing the user's choice of which files to operate on, and a local inside the run_lint function. This collision was there for a long time without causing a live problem, and then started doing so with f3aad7e where we moved a function call that consulted the global so that it occurred inside run_lint, with the local active. (Bash "local" variables are only sort of local -- they're dynamically scoped, rather than lexically scoped.) The effect of the issue is that the "lint" suite would always succeed without checking anything, because `files_js` would always produce no output. Fix it by giving the global a longer, more explicit name.
1 parent cbdc035 commit 6c5391e

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

tools/test

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ EOF
6969
}
7070

7171
coverage=
72-
files=branch
72+
opt_files=branch
7373
platform=sloppy
7474
fix=
7575
suites=()
7676
while (( $# )); do
7777
case "$1" in
7878
--coverage) coverage=1; shift;;
79-
--diff) shift; files=diff:"$1"; shift;;
80-
--all-files) files=all; shift;;
79+
--diff) shift; opt_files=diff:"$1"; shift;;
80+
--all-files) opt_files=all; shift;;
8181
--platform)
8282
shift;
8383
case "$1" in
@@ -86,7 +86,7 @@ while (( $# )); do
8686
esac
8787
shift
8888
;;
89-
--all) files=all; platform=both; shift;;
89+
--all) opt_files=all; platform=both; shift;;
9090
--fix) fix=1; shift;;
9191
native|flow|lint|jest|prettier|deps|tsflower)
9292
suites+=("$1"); shift;;
@@ -101,10 +101,10 @@ if [ -z "$suites" ]; then
101101
fi
102102

103103
files_base_commit=
104-
case "$files" in
104+
case "$opt_files" in
105105
all) ;;
106106
branch) files_base_commit="$(tools/git base)";;
107-
diff:*) files_base_commit="${files#diff:}";;
107+
diff:*) files_base_commit="${opt_files#diff:}";;
108108
esac
109109

110110

@@ -115,12 +115,12 @@ cd "$rootdir"
115115

116116
PATH=node_modules/.bin:"$PATH"
117117

118-
# Intersect $files with the set of our JS files in src/.
118+
# Intersect $opt_files with the set of our JS files in src/.
119119
#
120120
# Prints a list of newline-terminated paths; either files, or
121121
# directories meaning their whole subtrees.
122122
files_js() {
123-
case "$files" in
123+
case "$opt_files" in
124124
all)
125125
echo src/
126126
;;
@@ -132,7 +132,7 @@ files_js() {
132132

133133
# True just if $files intersects the given set of paths.
134134
files_check() {
135-
case "$files" in
135+
case "$opt_files" in
136136
all)
137137
;;
138138
branch | diff:*)
@@ -189,9 +189,9 @@ run_lint() {
189189
}
190190

191191
run_jest() {
192-
# Unlike some others, this inspects "$files" for itself.
192+
# Unlike some others, this inspects "$opt_files" for itself.
193193
local jest_args=()
194-
case "$files" in
194+
case "$opt_files" in
195195
all)
196196
if [ -n "$coverage" ]; then
197197
jest_args+=( --coverage )
@@ -225,7 +225,7 @@ run_jest() {
225225

226226
run_prettier() {
227227
local patterns
228-
case "$files" in
228+
case "$opt_files" in
229229
all)
230230
# The prettier-eslint CLI won't take directories;
231231
# but it's happy to take glob patterns, and supports `**`.

0 commit comments

Comments
 (0)