Skip to content

Commit a96cc31

Browse 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 <[email protected]>
1 parent d2ffecb commit a96cc31

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

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

+3-14
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)