Skip to content

Commit fa31b71

Browse files
committed
Updated testing logic.
1 parent 0aa99bf commit fa31b71

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"build": "clean && mvn -DskipTests",
2323
"build:fast": "mvn -DskipTests -pl externs/pom.xml,pom-main.xml,pom-main-shaded.xml",
2424
"clean": "yarn runtime_tests:clean && mvn clean",
25-
"runtime_tests:build": "$npm_package_config_runtime_tests_dir/build.sh",
25+
"runtime_tests:build": "$npm_package_config_runtime_tests_dir/utils/build.sh",
2626
"runtime_tests:clean": "rm -rf $npm_package_config_runtime_tests_dir/**/build/*",
2727
"runtime_tests:run": "jest --testRegex $npm_package_config_runtime_tests_dir/utils/test/* --verbose=true",
2828
"runtime_tests": "yarn runtime_tests:clean && yarn run --silent runtime_tests:build && yarn run --silent runtime_tests:run",

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ else
1919
COMPILATION_LEVEL=$1
2020
fi
2121

22+
# This directory.
23+
THIS_DIR=$(dirname $0)
24+
2225
# Location of project root.
23-
PROJECT_ROOT="../../../../../../.."
26+
PROJECT_ROOT=$(readlink -f $THIS_DIR/../../../../../../..)
2427

2528
# Get the location of the local compiler in this directory, if it exists.
2629
# If it doesn't, build it, then resume execution.
@@ -32,7 +35,7 @@ fi
3235
# Build tests from the $TEST_DIR directory, where files like
3336
# `array_pattern_test.js` are stored.
3437
echo -e "\nBuilding runtime tests..."
35-
TEST_DIR=".."
38+
TEST_DIR="$THIS_DIR/.."
3639

3740
# Get the absolute path of the test directory.
3841
ABS_PATH=$(readlink -f $TEST_DIR)
@@ -42,7 +45,7 @@ compileRuntimeTests(){
4245
local file
4346
for file in $@; do
4447

45-
# /path/to/file.ext -> /path/to/file
48+
# /path/to/file.js -> /path/to/file
4649
local file_base=$(echo $file | rev | cut -f 2- -d '.' | rev)
4750
# /path/to/file -> file
4851
local test_name=$(basename $file_base)

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,18 @@ const FutureEvent = require('future-event');
2929
const glob = require('glob');
3030
const path = require('path');
3131

32+
/**
33+
* The absolute path of test.com.google.javascript.jscomp.runtime_tests.
34+
*/
35+
const RUNTIME_DIR = path.resolve(__dirname, '../..');
36+
3237
/**
3338
* All test files in the test.com.google.javascript.jscomp.runtime_tests.build
3439
* directory.
3540
*/
36-
const TEST_FILES = glob.sync('../**/build/*_test.html');
41+
const TEST_FILES = glob.sync(
42+
`${RUNTIME_DIR}/**/build/*_test.html`,
43+
);
3744

3845
/**
3946
* Iterate over all found test files and execute them in JSDOM.
@@ -55,11 +62,11 @@ describe('Runtime tests', () => {
5562
/**
5663
* Highlight PASSED and FAILED in messages to help with accessibility.
5764
*/
58-
return (isPass || isFail) ?
59-
msg
65+
return !(isPass || isFail)
66+
? msg
67+
: msg
6068
.replace(passed, chalk.green('PASSED'))
61-
.replace(failed, chalk.red('FAILED')) :
62-
msg;
69+
.replace(failed, chalk.red('FAILED'));
6370
};
6471

6572
/**
@@ -73,8 +80,7 @@ describe('Runtime tests', () => {
7380
const testIsFinished = new FutureEvent();
7481

7582
/**
76-
* A virtual console which will receive messages from JSDOM's
77-
* `console.log`.
83+
* A virtual console which will receive messages from JSDOM's `console.log`.
7884
*/
7985
const virtualConsole = new VirtualConsole()
8086
.on('log', (msg) => {

0 commit comments

Comments
 (0)