2020-07-16 09:27:53 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
const assert = require('assert');
|
|
|
|
const { exec } = require('child_process');
|
2025-01-22 14:19:38 -08:00
|
|
|
const { isMainThread } = require('worker_threads');
|
2020-07-16 09:27:53 +02:00
|
|
|
|
|
|
|
const nodeBinary = process.argv[0];
|
|
|
|
|
2025-01-22 14:19:38 -08:00
|
|
|
if (!isMainThread) {
|
2020-07-16 09:27:53 +02:00
|
|
|
common.skip('process.chdir is not available in Workers');
|
2025-01-22 14:19:38 -08:00
|
|
|
}
|
2020-07-16 09:27:53 +02:00
|
|
|
|
|
|
|
const selfRefModule = fixtures.path('self_ref_module');
|
|
|
|
const fixtureA = fixtures.path('printA.js');
|
|
|
|
|
2024-09-29 22:44:52 +02:00
|
|
|
const [cmd, opts] = common.escapePOSIXShell`"${nodeBinary}" -r self_ref "${fixtureA}"`;
|
|
|
|
exec(cmd, { ...opts, cwd: selfRefModule },
|
|
|
|
common.mustSucceed((stdout, stderr) => {
|
2020-07-16 09:27:53 +02:00
|
|
|
assert.strictEqual(stdout, 'A\n');
|
2024-09-29 22:44:52 +02:00
|
|
|
}));
|