trying to fix async tests for exec()

This commit is contained in:
Artur Adib 2012-03-27 20:21:35 -04:00
parent 93ea251423
commit 94caeb20fd
2 changed files with 9 additions and 15 deletions

View File

@ -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);

View File

@ -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');