2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2015-10-12 21:26:50 -07:00
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
2014-02-10 21:40:48 +01:00
|
|
|
|
2015-10-12 21:26:50 -07:00
|
|
|
const spawnSync = require('child_process').spawnSync;
|
2014-02-10 21:40:48 +01:00
|
|
|
|
2015-08-25 09:45:42 -07:00
|
|
|
// Echo does different things on Windows and Unix, but in both cases, it does
|
|
|
|
// more-or-less nothing if there are no parameters
|
2015-10-12 21:26:50 -07:00
|
|
|
const ret = spawnSync('sleep', ['0']);
|
2014-05-13 14:49:59 -07:00
|
|
|
assert.strictEqual(ret.status, 0, 'exit status should be zero');
|
2014-02-10 21:40:48 +01:00
|
|
|
|
2014-04-22 01:26:11 +09:00
|
|
|
// Error test when command does not exist
|
2015-10-12 21:26:50 -07:00
|
|
|
const ret_err = spawnSync('command_does_not_exist', ['bar']).error;
|
2015-02-13 16:39:24 -05:00
|
|
|
|
|
|
|
assert.strictEqual(ret_err.code, 'ENOENT');
|
|
|
|
assert.strictEqual(ret_err.errno, 'ENOENT');
|
|
|
|
assert.strictEqual(ret_err.syscall, 'spawnSync command_does_not_exist');
|
|
|
|
assert.strictEqual(ret_err.path, 'command_does_not_exist');
|
|
|
|
assert.deepEqual(ret_err.spawnargs, ['bar']);
|
2014-06-24 23:18:00 -04:00
|
|
|
|
|
|
|
// Verify that the cwd option works - GH #7824
|
|
|
|
(function() {
|
|
|
|
var response;
|
|
|
|
var cwd;
|
|
|
|
|
2015-07-29 17:18:04 +05:30
|
|
|
if (common.isWindows) {
|
2014-06-24 23:18:00 -04:00
|
|
|
cwd = 'c:\\';
|
|
|
|
response = spawnSync('cmd.exe', ['/c', 'cd'], {cwd: cwd});
|
|
|
|
} else {
|
|
|
|
cwd = '/';
|
|
|
|
response = spawnSync('pwd', [], {cwd: cwd});
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.strictEqual(response.stdout.toString().trim(), cwd);
|
|
|
|
})();
|