Skip to content

Commit 0aa99bf

Browse files
committed
Moved to runtime_tests to relevant directory.
1 parent 61ff3a0 commit 0aa99bf

File tree

3 files changed

+32
-37
lines changed

3 files changed

+32
-37
lines changed

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"name": "closure-compiler",
3+
"config": {
4+
"runtime_tests_dir": "./test/com/google/javascript/jscomp/runtime_tests"
5+
},
36
"version": "1.0.0",
47
"repository": "[email protected]:google/closure-compiler.git",
58
"license": "Apache-2",
@@ -19,9 +22,9 @@
1922
"build": "clean && mvn -DskipTests",
2023
"build:fast": "mvn -DskipTests -pl externs/pom.xml,pom-main.xml,pom-main-shaded.xml",
2124
"clean": "yarn runtime_tests:clean && mvn clean",
22-
"runtime_tests:build": "./runtime_tests/build.sh",
23-
"runtime_tests:clean": "rm -rf test/com/google/javascript/jscomp/runtime_tests/build/*",
24-
"runtime_tests:run": "jest --testRegex runtime_tests/* --verbose=true",
25+
"runtime_tests:build": "$npm_package_config_runtime_tests_dir/build.sh",
26+
"runtime_tests:clean": "rm -rf $npm_package_config_runtime_tests_dir/**/build/*",
27+
"runtime_tests:run": "jest --testRegex $npm_package_config_runtime_tests_dir/utils/test/* --verbose=true",
2528
"runtime_tests": "yarn runtime_tests:clean && yarn run --silent runtime_tests:build && yarn run --silent runtime_tests:run",
2629
"test": "mvn test"
2730
}

runtime_tests/build.sh renamed to test/com/google/javascript/jscomp/runtime_tests/utils/build.sh

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,23 @@ else
1919
COMPILATION_LEVEL=$1
2020
fi
2121

22+
# Location of project root.
23+
PROJECT_ROOT="../../../../../../.."
24+
2225
# Get the location of the local compiler in this directory, if it exists.
2326
# If it doesn't, build it, then resume execution.
24-
LOCAL_COMPILER="$(dirname ..)/target/closure-compiler-1.0-SNAPSHOT.jar"
27+
LOCAL_COMPILER="$PROJECT_ROOT/target/closure-compiler-1.0-SNAPSHOT.jar"
2528
if [ ! -f "$LOCAL_COMPILER" ]; then
2629
echo -e "\nCompiler JAR not built. Building...\n" && yarn build:fast
2730
fi
2831

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.
32+
# Build tests from the $TEST_DIR directory, where files like
33+
# `array_pattern_test.js` are stored.
3534
echo -e "\nBuilding runtime tests..."
36-
TEST_DIR="test/com/google/javascript/jscomp/runtime_tests"
35+
TEST_DIR=".."
3736

3837
# Get the absolute path of the test directory.
39-
ABS_PATH=$(abs_dirname "./$TEST_DIR")
38+
ABS_PATH=$(readlink -f $TEST_DIR)
4039

4140
compileRuntimeTests(){
4241
local -i i=0
@@ -72,7 +71,7 @@ $(
7271
--process_common_js_modules \
7372
--module_resolution NODE \
7473
--dependency_mode PRUNE \
75-
--js node_modules/google-closure-library/ \
74+
--js $PROJECT_ROOT/node_modules/google-closure-library/ \
7675
--js $ABS_PATH/ \
7776
--entry_point $file
7877
)

runtime_tests/test/runAll.js renamed to test/com/google/javascript/jscomp/runtime_tests/utils/test/runAll.js

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
/**
2-
* @license Apache-2.0
2+
* @license MIT
3+
*
34
* Copyright 2020 The Closure Compiler Authors.
45
*
5-
* Licensed under the Apache License, Version 2.0 (the "License");
6-
* you may not use this file except in compliance with the License.
7-
* You may obtain a copy of the License at
6+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
7+
* use this file except in compliance with the License. You may obtain a copy of
8+
* the License at
89
*
910
* http://www.apache.org/licenses/LICENSE-2.0
1011
*
1112
* Unless required by applicable law or agreed to in writing, software
12-
* distributed under the License is distributed on an "AS IS" BASIS,
13-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* See the License for the specific language governing permissions and
15-
* limitations under the License.
13+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15+
* License for the specific language governing permissions and limitations under
16+
* the License.
1617
*/
1718
/**
1819
* @fileoverview
19-
* Crawl over all test/com/google/.../runtime_tests/*_test.html files and
20-
* execute them in a JSDOM context, fail the test if any do not succeed.
20+
* Crawl over all ../*_test.html files and execute them in a JSDOM context,
21+
* fail the test if any do not succeed.
2122
*/
2223

2324
const { JSDOM, VirtualConsole } = require('jsdom');
@@ -32,11 +33,7 @@ const path = require('path');
3233
* All test files in the test.com.google.javascript.jscomp.runtime_tests.build
3334
* directory.
3435
*/
35-
const TEST_FILES = glob.sync(path.resolve(
36-
__dirname,
37-
'../../test/com/google/javascript/jscomp/'
38-
+ 'runtime_tests/**/build/*_test.html',
39-
));
36+
const TEST_FILES = glob.sync('../**/build/*_test.html');
4037

4138
/**
4239
* Iterate over all found test files and execute them in JSDOM.
@@ -58,11 +55,11 @@ describe('Runtime tests', () => {
5855
/**
5956
* Highlight PASSED and FAILED in messages to help with accessibility.
6057
*/
61-
return (isPass || isFail)
62-
? msg
58+
return (isPass || isFail) ?
59+
msg
6360
.replace(passed, chalk.green('PASSED'))
64-
.replace(failed, chalk.red('FAILED'))
65-
: msg;
61+
.replace(failed, chalk.red('FAILED')) :
62+
msg;
6663
};
6764

6865
/**
@@ -91,11 +88,7 @@ describe('Runtime tests', () => {
9188
* This will be a raw HTML document.
9289
*/
9390
const testDocument = fs.readFileSync(
94-
path.resolve(
95-
__dirname,
96-
'../../',
97-
testFile,
98-
),
91+
path.resolve(testFile),
9992
'utf-8',
10093
);
10194

0 commit comments

Comments
 (0)