Skip to content

Commit 52fb95f

Browse files
committed
Fixed CONST_CASE and argument errors
1 parent 58d6180 commit 52fb95f

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

utils/build_runtime_tests.sh

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,51 +13,54 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
#!/bin/bash
17-
1816
if [ -z $1 ]; then
1917
COMPILATION_LEVEL="SIMPLE"
2018
else
2119
COMPILATION_LEVEL=$1
2220
fi
2321

24-
# to translate from relative dir
25-
abs_dirname() {
26-
echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
27-
}
28-
29-
LOCAL_COMPILER=$(dirname ..)/target/closure-compiler-1.0-SNAPSHOT.jar
22+
# Get the location of the local compiler in this directory, if it exists.
23+
# If it doesn't, build it, then resume execution.
24+
LOCAL_COMPILER="$(dirname ..)/target/closure-compiler-1.0-SNAPSHOT.jar"
3025
if [ ! -f "$LOCAL_COMPILER" ]; then
3126
echo -e "\nCompiler JAR not built. Building...\n" && yarn build:fast
3227
fi
3328

29+
# Translate a relative filepath to an absolute one.
30+
abs_dirname() {
31+
echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
32+
}
33+
34+
# Begin building runtime tests in the $TEST_DIR directory.
3435
echo -e "\nBuilding runtime tests..."
3536
TEST_DIR="test/com/google/javascript/jscomp/runtime_tests"
3637

37-
if [ -z $1 ]; then
38-
ABS_PATH=$(abs_dirname "./$TEST_DIR")
39-
else
40-
ABS_PATH=$(abs_dirname "$1")
41-
fi
38+
# Get the absolute path of the test directory.
39+
ABS_PATH=$(abs_dirname "./$TEST_DIR")
4240

43-
i=0
4441
compileRuntimeTests(){
45-
for FILE in $@; do
42+
local -i i=0
43+
for file in $@; do
4644

47-
FILE_BASE=$(echo $FILE | rev | cut -f 2- -d '.' | rev)
48-
TEST_NAME=$(basename $FILE_BASE)
49-
TEST_LOC=$(dirname $FILE)
45+
# /path/to/file.ext -> /path/to/file
46+
local file_base=$(echo $file | rev | cut -f 2- -d '.' | rev)
47+
# /path/to/file -> file
48+
local test_name=$(basename $file_base)
49+
# /path/to/file.ext -> /path/to
50+
local test_loc=$(dirname $file)
5051

51-
# make build dir
52-
mkdir -p $TEST_LOC/build
52+
# Make sure the build directory exists.
53+
mkdir -p $test_loc/build
5354

55+
# Echo a percentage progress indicator.
5456
((i += 1))
55-
echo " $((100 * $i / $#))% | $TEST_NAME"
57+
echo " $((100 * $i / $#))% | $test_name"
5658

59+
# Output the test file, which will be executed in JSDOM.
5760
echo "
5861
<html>
5962
<head>
60-
<title>$TEST_NAME</title>
63+
<title>$test_name</title>
6164
<script defer>
6265
$(
6366
java -server -XX:+TieredCompilation \
@@ -70,11 +73,11 @@ $(
7073
--dependency_mode PRUNE \
7174
--js node_modules/google-closure-library/ \
7275
--js $ABS_PATH/ \
73-
--entry_point $FILE
76+
--entry_point $file
7477
)
7578
</script>
7679
</head>
77-
</html>" > $TEST_LOC/build/$TEST_NAME.html
80+
</html>" > $test_loc/build/$test_name.html
7881

7982
done
8083
}

0 commit comments

Comments
 (0)