Skip to content
Closed
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
3 changes: 0 additions & 3 deletions .mocharc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

const path = require('path');

const config = {
"enable-source-maps": true,
"throw-deprecation": true,
Expand All @@ -28,7 +26,6 @@ if (process.env.MOCHA_PARALLEL === 'false' || typeof Bun !== 'undefined') {
config.parallel = false;
}
if (typeof Bun !== 'undefined') {
config.require = [path.resolve(__dirname, 'bin/proxyquire-bun-shim.cjs')];
config.exit = true;
}
if (process.env.MOCHA_REPORTER) {
Expand Down
189 changes: 0 additions & 189 deletions bin/proxyquire-bun-shim.cjs

This file was deleted.

39 changes: 4 additions & 35 deletions bin/run-test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
// coverage and Mocha worker-thread parallelism (`parallel: true`).
// - Under Bun (`typeof Bun !== 'undefined'` or `JS_RUNTIME === 'bun'`):
// Skips `c8` (which relies on Node's `NODE_V8_COVERAGE`), disables Mocha
// worker-thread parallelism (`--no-parallel`), preloads the Bun `proxyquire`
// shim (`bin/proxyquire-bun-shim.cjs`) when `--proxyquire-shim` is passed,
// and loads `mocha/bin/mocha.js` directly in-process so `#!/usr/bin/env node`
// shebangs never switch back to Node.js.
// worker-thread parallelism (`--no-parallel`), and loads `mocha/bin/mocha.js`
// directly in-process so `#!/usr/bin/env node` shebangs never switch back to
// Node.js.
'use strict';

const {spawnSync} = require('child_process');
Expand All @@ -32,26 +31,7 @@ const fs = require('fs');

const rawArgs = process.argv.slice(2);
const noC8 = rawArgs.includes('--no-c8');

const SHIM_FLAGS = [
{
flag: '--proxyquire-shim',
envIn: 'BUN_PROXYQUIRE_SHIM',
envOut: 'BUN_ENABLE_PROXYQUIRE_SHIM',
},
];

const shimFlagSet = new Set(SHIM_FLAGS.map(s => s.flag));
const shimEnvVars = {};
for (const {flag, envIn, envOut} of SHIM_FLAGS) {
const enabled =
rawArgs.includes(flag) ||
process.env[envIn] === 'true' ||
process.env[envOut] === 'true';
shimEnvVars[envOut] = enabled ? 'true' : 'false';
}

const args = rawArgs.filter(a => a !== '--no-c8' && !shimFlagSet.has(a));
const args = rawArgs.filter(a => a !== '--no-c8');

const isBunRuntime = typeof Bun !== 'undefined';
const isBunUserAgent = /^bun\//i.test(process.env.npm_config_user_agent || '');
Expand Down Expand Up @@ -650,7 +630,6 @@ if (require.main === module) {

if (wantsBunRuntime) {
process.env.MOCHA_PARALLEL = 'false';
Object.assign(process.env, shimEnvVars);

// If Bun was requested (via JS_RUNTIME=bun or `bun run test`) but this
// script was launched via Node.js, re-exec under the `bun` binary.
Expand All @@ -660,7 +639,6 @@ if (require.main === module) {
env: {
...process.env,
MOCHA_PARALLEL: 'false',
...shimEnvVars,
},
});
if (res.error) {
Expand All @@ -678,15 +656,6 @@ if (require.main === module) {
mochaArgs.unshift('--no-parallel');
}

// Only preload the proxyquire shim when `--proxyquire-shim` is requested.
if (shimEnvVars.BUN_ENABLE_PROXYQUIRE_SHIM === 'true') {
const shimPath = path.resolve(__dirname, 'proxyquire-bun-shim.cjs');
require(shimPath);
if (!mochaArgs.includes(shimPath)) {
mochaArgs.unshift('--require', shimPath);
}
}

if (!mochaArgs.includes('--exit')) {
mochaArgs.unshift('--exit');
}
Expand Down
2 changes: 1 addition & 1 deletion core/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
],
"scripts": {
"docs": "jsdoc -c .jsdoc.js",
"test": "node ../../bin/run-test.cjs --proxyquire-shim build/test",
"test": "node ../../bin/run-test.cjs build/test",
"prepare": "npm run compile",
"pretest": "npm run compile",
"compile": "tsc -p .",
Expand Down
Loading
Loading