nodejs/test/parallel/test-cli-syntax-piped-good.js
Rich Trott a3801e9683 test: split test-cli-syntax into multiple tests
Split test-cli-syntax into multiple files to improve reliability and/or
isolate unreliable test cases.

Move test cases back to parallel as appropriate.

PR-URL: https://github.com/nodejs/node/pull/24922
Reviewed-By: Bryan English <bryan@bryanenglish.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
2018-12-12 21:06:06 -08:00

27 lines
677 B
JavaScript

'use strict';
require('../common');
const assert = require('assert');
const { spawnSync } = require('child_process');
const node = process.execPath;
// test both sets of arguments that check syntax
const syntaxArgs = [
['-c'],
['--check']
];
// should not execute code piped from stdin with --check
// loop each possible option, `-c` or `--check`
syntaxArgs.forEach(function(args) {
const stdin = 'throw new Error("should not get run");';
const c = spawnSync(node, args, { encoding: 'utf8', input: stdin });
// no stdout or stderr should be produced
assert.strictEqual(c.stdout, '');
assert.strictEqual(c.stderr, '');
assert.strictEqual(c.status, 0);
});