Skip to content
Draft
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 @@ -655,7 +635,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 @@ -665,7 +644,6 @@ if (require.main === module) {
env: {
...process.env,
MOCHA_PARALLEL: 'false',
...shimEnvVars,
},
});
if (res.error) {
Expand All @@ -683,15 +661,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
4 changes: 0 additions & 4 deletions core/packages/gapic-node-processing/.mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
// 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.
const path = require('path');
const config = {
"enable-source-maps": true,
"throw-deprecation": true,
Expand All @@ -24,9 +23,6 @@ if (process.env.MOCHA_THROW_DEPRECATION === 'false') {
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')];
}
if (process.env.MOCHA_REPORTER) {
config.reporter = process.env.MOCHA_REPORTER;
}
Expand Down
5 changes: 0 additions & 5 deletions core/packages/gax/.mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
// 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.
const path = require('path');
const config = {
"enable-source-maps": true,
"throw-deprecation": true,
Expand All @@ -24,10 +23,6 @@ if (process.env.MOCHA_THROW_DEPRECATION === 'false') {
if (process.env.MOCHA_PARALLEL === 'false' || typeof Bun !== 'undefined') {
config.parallel = false;
}
if (typeof Bun !== 'undefined') {
// Preload Bun compatibility shim for proxyquire and nock when running under Bun
config.require = [path.resolve(__dirname, '../../../bin/proxyquire-bun-shim.cjs')];
}
if (process.env.MOCHA_REPORTER) {
config.reporter = process.env.MOCHA_REPORTER;
}
Expand Down
4 changes: 0 additions & 4 deletions core/packages/gaxios/.mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
// 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.
const path = require('path');
const config = {
"enable-source-maps": true,
"throw-deprecation": true,
Expand All @@ -24,9 +23,6 @@ if (process.env.MOCHA_THROW_DEPRECATION === 'false') {
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')];
}
if (process.env.MOCHA_REPORTER) {
config.reporter = process.env.MOCHA_REPORTER;
}
Expand Down
4 changes: 0 additions & 4 deletions core/packages/gcp-metadata/.mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
// 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.
const path = require('path');
const config = {
"enable-source-maps": true,
"throw-deprecation": true,
Expand All @@ -24,9 +23,6 @@ if (process.env.MOCHA_THROW_DEPRECATION === 'false') {
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')];
}
if (process.env.MOCHA_REPORTER) {
config.reporter = process.env.MOCHA_REPORTER;
}
Expand Down
4 changes: 0 additions & 4 deletions core/packages/google-auth-library-nodejs/.mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
// 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.
const path = require('path');
const config = {
"enable-source-maps": true,
"throw-deprecation": true,
Expand All @@ -24,9 +23,6 @@ if (process.env.MOCHA_THROW_DEPRECATION === 'false') {
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')];
}
if (process.env.MOCHA_REPORTER) {
config.reporter = process.env.MOCHA_REPORTER;
}
Expand Down
4 changes: 0 additions & 4 deletions core/packages/nodejs-googleapis-common/.mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
// 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.
const path = require('path');
const config = {
"enable-source-maps": true,
"throw-deprecation": true,
Expand All @@ -24,9 +23,6 @@ if (process.env.MOCHA_THROW_DEPRECATION === 'false') {
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')];
}
if (process.env.MOCHA_REPORTER) {
config.reporter = process.env.MOCHA_REPORTER;
}
Expand Down
Loading
Loading