|
13 | 13 | # See the License for the specific language governing permissions and
|
14 | 14 | # limitations under the License.
|
15 | 15 |
|
16 |
| -#!/bin/bash |
17 |
| - |
18 | 16 | if [ -z $1 ]; then
|
19 | 17 | COMPILATION_LEVEL="SIMPLE"
|
20 | 18 | else
|
21 | 19 | COMPILATION_LEVEL=$1
|
22 | 20 | fi
|
23 | 21 |
|
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" |
30 | 25 | if [ ! -f "$LOCAL_COMPILER" ]; then
|
31 | 26 | echo -e "\nCompiler JAR not built. Building...\n" && yarn build:fast
|
32 | 27 | fi
|
33 | 28 |
|
| 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. |
34 | 35 | echo -e "\nBuilding runtime tests..."
|
35 | 36 | TEST_DIR="test/com/google/javascript/jscomp/runtime_tests"
|
36 | 37 |
|
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") |
42 | 40 |
|
43 |
| -i=0 |
44 | 41 | compileRuntimeTests(){
|
45 |
| - for FILE in $@; do |
| 42 | + local -i i=0 |
| 43 | + for file in $@; do |
46 | 44 |
|
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) |
50 | 51 |
|
51 |
| - # make build dir |
52 |
| - mkdir -p $TEST_LOC/build |
| 52 | + # Make sure the build directory exists. |
| 53 | + mkdir -p $test_loc/build |
53 | 54 |
|
| 55 | + # Echo a percentage progress indicator. |
54 | 56 | ((i += 1))
|
55 |
| - echo " $((100 * $i / $#))% | $TEST_NAME" |
| 57 | + echo " $((100 * $i / $#))% | $test_name" |
56 | 58 |
|
| 59 | + # Output the test file, which will be executed in JSDOM. |
57 | 60 | echo "
|
58 | 61 | <html>
|
59 | 62 | <head>
|
60 |
| -<title>$TEST_NAME</title> |
| 63 | +<title>$test_name</title> |
61 | 64 | <script defer>
|
62 | 65 | $(
|
63 | 66 | java -server -XX:+TieredCompilation \
|
|
70 | 73 | --dependency_mode PRUNE \
|
71 | 74 | --js node_modules/google-closure-library/ \
|
72 | 75 | --js $ABS_PATH/ \
|
73 |
| - --entry_point $FILE |
| 76 | + --entry_point $file |
74 | 77 | )
|
75 | 78 | </script>
|
76 | 79 | </head>
|
77 |
| -</html>" > $TEST_LOC/build/$TEST_NAME.html |
| 80 | +</html>" > $test_loc/build/$test_name.html |
78 | 81 |
|
79 | 82 | done
|
80 | 83 | }
|
|
0 commit comments