mirror of
https://github.com/shelljs/shelljs.git
synced 2026-01-25 16:07:37 +00:00
trying to fix async tests for exec()
This commit is contained in:
parent
93ea251423
commit
94caeb20fd
18
test/exec.js
18
test/exec.js
@ -65,6 +65,10 @@ shell.cd('../..');
|
||||
// async
|
||||
//
|
||||
|
||||
// no callback (no need for asyncFlags)
|
||||
shell.exec('node -e \"console.log(1234)\"', {async:true});
|
||||
assert.equal(shell.error(), null);
|
||||
|
||||
var asyncFlags = [];
|
||||
|
||||
//
|
||||
@ -118,20 +122,10 @@ shell.exec('node -e \"console.log(5678);\"', {async:true}, function(code, output
|
||||
child.exec('node '+file, function(err, stdout, stderr) {
|
||||
assert.ok(stdout === '222\n' || stdout === '222\nundefined\n'); // 'undefined' for v0.4
|
||||
asyncFlags[3] = true;
|
||||
|
||||
shell.exit(123);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
assert.equal(shell.error(), null);
|
||||
|
||||
// no callback (no need for asyncFlags)
|
||||
shell.exec('node -e \"console.log(1234)\"', {async:true});
|
||||
assert.equal(shell.error(), null);
|
||||
|
||||
setTimeout(function() {
|
||||
asyncFlags.forEach(function(flag) {
|
||||
assert.equal(flag, true);
|
||||
});
|
||||
|
||||
shell.exit(123);
|
||||
}, 2000);
|
||||
|
||||
@ -20,18 +20,18 @@ shell.mkdir('tmp')
|
||||
// Invalids
|
||||
//
|
||||
|
||||
shell.echo('hello world').to();
|
||||
'hello world'.to();
|
||||
assert.ok(shell.error());
|
||||
|
||||
assert.equal(fs.existsSync('/asdfasdf'), false); // sanity check
|
||||
shell.echo('hello world').to('/asdfasdf/file');
|
||||
'hello world'.to('/asdfasdf/file');
|
||||
assert.ok(shell.error());
|
||||
|
||||
//
|
||||
// Valids
|
||||
//
|
||||
|
||||
shell.echo('hello world').to('tmp/to1');
|
||||
'hello world'.to('tmp/to1');
|
||||
var result = shell.cat('tmp/to1');
|
||||
assert.equal(shell.error(), null);
|
||||
assert.equal(result, 'hello world');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user