Files
node/test/embedding/test-embedding.js
T
Anna HenningsenandJoyee Cheung 2061c33670 test: add extended embedder cctest
Add an embedder cctest that also covers a multi-Environment situation,
including worker_threads-style inspector support.

Co-authored-by: Joyee Cheung <joyeec9h3@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/30467
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2020-03-21 10:58:28 +01:00

34 lines
907 B
JavaScript

'use strict';
const common = require('../common');
const fixtures = require('../common/fixtures');
const assert = require('assert');
const child_process = require('child_process');
const path = require('path');
common.allowGlobals(global.require);
let binary = process.features.debug ?
'out/Debug/embedtest' : 'out/Release/embedtest';
if (common.isWindows) {
binary += '.exe';
}
binary = path.resolve(__dirname, '..', '..', binary);
assert.strictEqual(
child_process.spawnSync(binary, ['console.log(42)'])
.stdout.toString().trim(),
'42');
assert.strictEqual(
child_process.spawnSync(binary, ['throw new Error()']).status,
1);
assert.strictEqual(
child_process.spawnSync(binary, ['process.exitCode = 8']).status,
8);
const fixturePath = JSON.stringify(fixtures.path('exit.js'));
assert.strictEqual(
child_process.spawnSync(binary, [`require(${fixturePath})`, 92]).status,
92);