mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
330f25ef82
Make changes so that tests will pass when the comma-dangle settings applied to the rest of the code base are also applied to tests. PR-URL: https://github.com/nodejs/node/pull/37930 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Derek Lewis <DerekNonGeneric@inf.is>
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
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(arg) {
|
|
const stdin = 'throw new Error("should not get run");';
|
|
const c = spawnSync(node, [arg], { encoding: 'utf8', input: stdin });
|
|
|
|
// No stdout or stderr should be produced
|
|
assert.strictEqual(c.stdout, '');
|
|
assert.strictEqual(c.stderr, '');
|
|
|
|
assert.strictEqual(c.status, 0);
|
|
});
|
|
|
|
// Check --input-type=module
|
|
syntaxArgs.forEach(function(arg) {
|
|
const stdin = 'export var p = 5; throw new Error("should not get run");';
|
|
const c = spawnSync(
|
|
node,
|
|
['--no-warnings', '--input-type=module', arg],
|
|
{ encoding: 'utf8', input: stdin }
|
|
);
|
|
|
|
// No stdout or stderr should be produced
|
|
assert.strictEqual(c.stdout, '');
|
|
assert.strictEqual(c.stderr, '');
|
|
|
|
assert.strictEqual(c.status, 0);
|
|
});
|