Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a96cc31

Browse filesBrowse files
Trottrvagg
authored andcommitted
test: speed up test-child-process-spawnsync.js
There's a bunch of stuff in test-child-process-spawnsync.js that seems designed to test that it is in fact blocking/synchronous. However, that code really just tests the OS sleep command. Change `sleep 1` to `sleep 0` and shave about one second off the test run.` We check the return status to confirm the command is successful. The tests in this file in general would not work if spawnSync() were asynchronous. That includes this one, as a return status would not be available if the command where asynchronous. PR-URL: #2542 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent d2ffecb commit a96cc31
Copy full SHA for a96cc31

File tree

Expand file treeCollapse file tree

1 file changed

+3
-14
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-14
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-child-process-spawnsync.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-child-process-spawnsync.js
+3-14Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,10 @@ var assert = require('assert');
44

55
var spawnSync = require('child_process').spawnSync;
66

7-
var TIMER = 100;
8-
var SLEEP = 1000;
9-
10-
setTimeout(function() {
11-
assert.ok(stop, 'timer should not fire before process exits');
12-
}, TIMER);
13-
14-
console.log('sleep started');
15-
var start = process.hrtime();
16-
var ret = spawnSync('sleep', ['1']);
17-
var stop = process.hrtime(start);
7+
// Echo does different things on Windows and Unix, but in both cases, it does
8+
// more-or-less nothing if there are no parameters
9+
var ret = spawnSync('sleep', ['0']);
1810
assert.strictEqual(ret.status, 0, 'exit status should be zero');
19-
console.log('sleep exited', stop);
20-
assert.strictEqual(stop[0], 1,
21-
'sleep should not take longer or less than 1 second');
2211

2312
// Error test when command does not exist
2413
var ret_err = spawnSync('command_does_not_exist', ['bar']).error;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.