<!-- CURSOR_AGENT_PR_BODY_BEGIN --> ## Summary Improves reliability and correctness of `bin/` maintenance scripts used for local development and CI. ## Behavioral fixes - **Exit codes**: `test_integration.js` exits with code 1 when `--suite` names an unknown suite; `test_unit.js` uses a non-zero fallback (`-1`) when the coverage or mocha child process has no status; `esbuild_all.mjs` exits non-zero if any parallel esbuild child fails. - **Repo root**: `setup-full.mjs` resolves the repository root one directory above `bin/` (was incorrectly using `bin/` as root). - **esbuild_all**: Propagates child build failures instead of always exiting 0. - **Integration suites**: When `--suite` is omitted, all configured Playwright suites (core + addons) run; when provided, only the matching suite runs. - **test_unit.js**: Declares the `files` filter variable so file arguments from `npm run test-unit` work without a ReferenceError. - **test_mousemodes.js**: Uses the correct cursor-home CSI (`ESC [ H`) when clearing the menu screen. - **Cleanup**: Removes debug logging from the test-unit coverage path; adds a missing semicolon after the suite regex match. ## Affected scripts - `bin/test_integration.js` - `bin/test_unit.js` - `bin/esbuild_all.mjs` - `bin/setup-full.mjs` - `bin/test_mousemodes.js` ## Testing - Syntax-checked affected scripts with `node --check` - Verified `node bin/test_integration.js --suite=unknown` exits 1 with an error message - `npm run lint-changes` (no TypeScript files changed) <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-94b28f5d-740c-4cb6-8cd9-40f35bc6086c"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/background-agent?bcId=bc-94b28f5d-740c-4cb6-8cd9-40f35bc6086c"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div>
74 lines
1.7 KiB
JavaScript
74 lines
1.7 KiB
JavaScript
/**
|
|
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
|
|
* @license MIT
|
|
*/
|
|
|
|
const cp = require('child_process');
|
|
const path = require('path');
|
|
|
|
const COVERAGE_LINES_THRESHOLD = 40;
|
|
|
|
// Add `out-esbuild` to NODE_PATH so addon path-mapped imports (common/*, browser/*) resolve.
|
|
const env = { ...process.env };
|
|
env.NODE_PATH = path.resolve(__dirname, '../out-esbuild');
|
|
|
|
let testFiles = ['**/out-esbuild/**/*.test.js'];
|
|
|
|
let flagArgs = [];
|
|
|
|
if (process.argv.length > 2) {
|
|
const args = process.argv.slice(2);
|
|
flagArgs = args.filter(e => e.startsWith('--'));
|
|
// ability to inject particular test files via
|
|
// npm run test [testFileA testFileB ...]
|
|
const files = args.filter(e => !e.startsWith('--'));
|
|
if (files.length) {
|
|
testFiles = files;
|
|
}
|
|
}
|
|
|
|
const checkCoverage = flagArgs.indexOf('--coverage') >= 0;
|
|
if (checkCoverage) {
|
|
flagArgs.splice(flagArgs.indexOf('--coverage'), 1);
|
|
const executable = npmBinScript('nyc');
|
|
const args = [
|
|
'--check-coverage',
|
|
`--lines=${COVERAGE_LINES_THRESHOLD}`,
|
|
'--exclude=out-esbuild/vs/**',
|
|
npmBinScript('mocha'),
|
|
...testFiles,
|
|
...flagArgs
|
|
];
|
|
const run = cp.spawnSync(
|
|
executable,
|
|
args,
|
|
{
|
|
cwd: path.resolve(__dirname, '..'),
|
|
env,
|
|
shell: true,
|
|
stdio: 'inherit'
|
|
}
|
|
);
|
|
process.exit(run.status ?? -1);
|
|
}
|
|
|
|
const run = cp.spawnSync(
|
|
npmBinScript('mocha'),
|
|
[...testFiles, ...flagArgs],
|
|
{
|
|
cwd: path.resolve(__dirname, '..'),
|
|
env,
|
|
shell: true,
|
|
stdio: 'inherit'
|
|
}
|
|
);
|
|
|
|
function npmBinScript(script) {
|
|
return path.resolve(__dirname, `../node_modules/.bin/` + (process.platform === 'win32' ? `${script}.cmd` : script));
|
|
}
|
|
|
|
if (run.error) {
|
|
console.error(run.error);
|
|
}
|
|
process.exit(run.status ?? -1);
|