2018-12-09 09:44:44 -08:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
require('../common');
|
|
|
|
const assert = require('assert');
|
|
|
|
const { spawnSync } = require('child_process');
|
|
|
|
|
|
|
|
const node = process.execPath;
|
|
|
|
|
2019-01-21 01:22:27 +01:00
|
|
|
// Test both sets of arguments that check syntax
|
2018-12-09 09:44:44 -08:00
|
|
|
const syntaxArgs = [
|
|
|
|
['-c'],
|
|
|
|
['--check']
|
|
|
|
];
|
|
|
|
|
2018-12-10 13:27:32 +01:00
|
|
|
// Should not execute code piped from stdin with --check.
|
|
|
|
// Loop each possible option, `-c` or `--check`.
|
2018-12-09 09:44:44 -08:00
|
|
|
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);
|
|
|
|
});
|