GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: decrease duration of test-cli-syntax · nodejs/node@a4e2ced

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-cli-syntax.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/parallel/test-cli-syntax.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-cli-syntax.js
+27-20Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
22

3-
require('../common');
3+
const common = require('../common');
44
const assert = require('assert');
5-
const spawnSync = require('child_process').spawnSync;
65
const fixtures = require('../common/fixtures');
6+
const exec = require('child_process').exec;
77

88
const node = process.execPath;
99

@@ -29,12 +29,13 @@ const notFoundRE = /^Error: Cannot find module/m;
2929
// loop each possible option, `-c` or `--check`
3030
syntaxArgs.forEach(function(args) {
3131
const _args = args.concat(file);
32-
const c = spawnSync(node, _args, {encoding: 'utf8'});
3332

34-
// no output should be produced
35-
assert.strictEqual(c.stdout, '', 'stdout produced');
36-
assert.strictEqual(c.stderr, '', 'stderr produced');
37-
assert.strictEqual(c.status, 0, `code == ${c.status}`);
33+
const cmd = [node, ..._args].join(' ');
34+
exec(cmd, common.mustCall((err, stdout, stderr) => {
35+
assert.ifError(err);
36+
assert.strictEqual(stdout, '', 'stdout produced');
37+
assert.strictEqual(stderr, '', 'stderr produced');
38+
}));
3839
});
3940
});
4041

@@ -50,15 +51,20 @@ const notFoundRE = /^Error: Cannot find module/m;
5051
// loop each possible option, `-c` or `--check`
5152
syntaxArgs.forEach(function(args) {
5253
const _args = args.concat(file);
53-
const c = spawnSync(node, _args, {encoding: 'utf8'});
54+
const cmd = [node, ..._args].join(' ');
55+
exec(cmd, common.mustCall((err, stdout, stderr) => {
56+
assert.strictEqual(err instanceof Error, true);
57+
assert.strictEqual(err.code, 1, `code === ${err.code}`);
5458

55-
// no stdout should be produced
56-
assert.strictEqual(c.stdout, '', 'stdout produced');
59+
// no stdout should be produced
60+
assert.strictEqual(stdout, '', 'stdout produced');
5761

58-
// stderr should have a syntax error message
59-
assert(syntaxErrorRE.test(c.stderr), 'stderr incorrect');
62+
// stderr should have a syntax error message
63+
assert(syntaxErrorRE.test(stderr), 'stderr incorrect');
6064

61-
assert.strictEqual(c.status, 1, `code == ${c.status}`);
65+
// stderr should include the filename
66+
assert(stderr.startsWith(file), "stderr doesn't start with the filename");
67+
}));
6268
});
6369
});
6470

@@ -72,14 +78,15 @@ const notFoundRE = /^Error: Cannot find module/m;
7278
// loop each possible option, `-c` or `--check`
7379
syntaxArgs.forEach(function(args) {
7480
const _args = args.concat(file);
75-
const c = spawnSync(node, _args, {encoding: 'utf8'});
81+
const cmd = [node, ..._args].join(' ');
82+
exec(cmd, common.mustCall((err, stdout, stderr) => {
83+
// no stdout should be produced
84+
assert.strictEqual(stdout, '', 'stdout produced');
7685

77-
// no stdout should be produced
78-
assert.strictEqual(c.stdout, '', 'stdout produced');
86+
// stderr should have a module not found error message
87+
assert(notFoundRE.test(stderr), 'stderr incorrect');
7988

80-
// stderr should have a module not found error message
81-
assert(notFoundRE.test(c.stderr), 'stderr incorrect');
82-
83-
assert.strictEqual(c.status, 1, `code == ${c.status}`);
89+
assert.strictEqual(err.code, 1, `code === ${err.code}`);
90+
}));
8491
});
8592
});

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.