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: fix test-sync-io-option · nodejs/node@43a82f8

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-sync-io-option.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/parallel/test-sync-io-option.js‎

Copy file name to clipboard
+14-26Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
'use strict';
22

33
const assert = require('assert');
4-
const spawn = require('child_process').spawn;
5-
4+
const execFile = require('child_process').execFile;
65

76
if (process.argv[2] === 'child') {
87
setImmediate(function() {
@@ -14,34 +13,23 @@ if (process.argv[2] === 'child') {
1413
(function runTest(flags) {
1514
var execArgv = [flags.pop()];
1615
var args = [__filename, 'child'];
17-
var child = spawn(process.execPath, execArgv.concat(args));
18-
var stderr = '';
19-
20-
child.stdout.on('data', function(chunk) {
21-
throw new Error('UNREACHABLE');
22-
});
23-
24-
child.stderr.on('data', function(chunk) {
25-
stderr += chunk.toString();
26-
});
27-
28-
child.on('close', function() {
29-
var cntr1 = (stderr.match(/WARNING/g) || []).length;
30-
var cntr2 = (stderr.match(/fs\.readFileSync/g) || []).length;
31-
assert.equal(cntr1, cntr2);
32-
if (execArgv[0] === '--trace-sync-io') {
33-
// Prints 4 WARNINGS for --trace-sync-io. 1 for each sync call
34-
// inside readFileSync
35-
assert.equal(cntr1, 4);
36-
} else if (execArgv[0] === ' ') {
37-
assert.equal(cntr1, 0);
16+
var cntr = 0;
17+
args = execArgv.concat(args);
18+
if (!args[0]) args.shift();
19+
execFile(process.execPath, args, function(err, stdout, stderr) {
20+
assert.equal(err, null);
21+
assert.equal(stdout, '');
22+
if (/^WARNING[\s\S]*fs\.readFileSync/.test(stderr))
23+
cntr++;
24+
if (args[0] === '--trace-sync-io') {
25+
assert.equal(cntr, 1);
26+
} else if (args[0] === __filename) {
27+
assert.equal(cntr, 0);
3828
} else {
3929
throw new Error('UNREACHABLE');
4030
}
41-
4231
if (flags.length > 0)
4332
setImmediate(runTest, flags);
4433
});
45-
}(['--trace-sync-io', ' ']));
34+
}(['--trace-sync-io', '']));
4635
}
47-

0 commit comments

Comments
0 (0)
You are visitor 01402775 — 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.