Skip to content
This repository was archived by the owner on Nov 19, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions build-scripts/jasmine.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
# Run the test commands and fail the script if any of them failed
EXIT_STATUS=0
./packages/google-closure-compiler/test/support/jasmine-launcher.js "$@" || EXIT_STATUS=$?
exit $EXIT_STATUS
3 changes: 1 addition & 2 deletions build-scripts/test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env bash
# Run the test commands and fail the script if any of them failed
EXIT_STATUS=0
yarn workspaces run test "$@" || EXIT_STATUS=$?
jasmine --reporter=jasmine-console-reporter test/*.js "$@" || EXIT_STATUS=$?
./packages/google-closure-compiler/test/support/jasmine-launcher.js "$@" || EXIT_STATUS=$?
exit $EXIT_STATUS
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"scripts": {
"build": "./build-scripts/build.sh",
"test": "./build-scripts/test.sh",
"test:root": "jasmine --reporter=jasmine-console-reporter test/*.js",
"test:root": "./build-scripts/jasmine.sh --reporter=jasmine-console-reporter test/*.js",
"clean": "./build-scripts/clean.sh",
"version": "./build-scripts/version-packages.js",
"publish-packages": "./build-scripts/publish.js"
Expand Down
2 changes: 1 addition & 1 deletion packages/google-closure-compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
},
"scripts": {
"build": "echo \"google-closure-compiler build\"",
"test": "jasmine --reporter=jasmine-console-reporter test/*.js --"
"test": "./test/support/jasmine.sh --reporter=jasmine-console-reporter 'test/*.js'"
},
"engines": {
"node": ">=18"
Expand Down
90 changes: 90 additions & 0 deletions packages/google-closure-compiler/test/support/jasmine-launcher.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/usr/bin/env node
/*
* Copyright 2025 The Closure Compiler Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview
*
* Execute jasmine with the arguments in the correct order.
* Extra arguments passed to test specs must be preceded by an '--' argument.
* We want to keep the arguments in the same order, but arguments for the jasmine runner itself must
* come first followed by a '--' argument and then finally by any extra arguments.
*/

import {spawn} from 'node:child_process';
import parseArgs from 'minimist';

const supportedJasmineFlags = new Set([
'parallel',
'no-color',
'color',
'filter',
'helper',
'require',
'fail-fast',
'config',
'reporter',
'verbose',
]);

const cliFlags = parseArgs(process.argv.slice(2));
const jasmineFlags = [];
const extraFlags = [];
for (const [name, value] of Object.entries(cliFlags)) {
const normalizedValues = Array.isArray(value) ? value : [value];
if (name === '_') {
jasmineFlags.push(...value);
} else if (supportedJasmineFlags.has(name)) {
for (const normalizedValue of normalizedValues) {
jasmineFlags.push(`--${name}${typeof normalizedValue === 'boolean' ? '' : `=${normalizedValue}`}`);
}
} else {
for (const normalizedValue of normalizedValues) {
extraFlags.push(`--${name}${typeof normalizedValue === 'boolean' ? '' : `=${normalizedValue}`}`);
}
}
}

const flagName = (flag) => {
if (flag.startsWith('--')) {
const valStart = flag.indexOf('=', 2);
return flag.slice(0, valStart > 0 ? valStart : flag.length);
}
return flag;
}
const flagSorter = (a, b) => {
const aFlagName = flagName(a);
const bFlagName = flagName(b);
const aIndex = process.argv.findIndex((arg) => arg === aFlagName || arg.startsWith(`${aFlagName}=`));
const bIndex = process.argv.findIndex((arg) => arg === bFlagName || arg.startsWith(`${bFlagName}=`));
return aIndex - bIndex;
};
jasmineFlags.sort(flagSorter);
extraFlags.sort(flagSorter);
if (extraFlags.length > 0) {
jasmineFlags.push('--', ...extraFlags);
}

const jasmineProcess = spawn(
'jasmine',
jasmineFlags,
{
stdio: 'inherit',
},
);

jasmineProcess.on('close', (exitCode) => {
process.exitCode = exitCode;
});
5 changes: 5 additions & 0 deletions packages/google-closure-compiler/test/support/jasmine.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
# Run the test commands and fail the script if any of them failed
EXIT_STATUS=0
./test/support/jasmine-launcher.js "$@" || EXIT_STATUS=$?
exit $EXIT_STATUS
Loading