Permalink
Browse files

Added async-task tests.

  • Loading branch information...
1 parent 434d81d commit 433bf722e5f4b610876483b7eb047b9bdbfbc4b7 @mde mde committed Dec 12, 2011
Showing with 58 additions and 7 deletions.
  1. +45 −6 tests/Jakefile
  2. +13 −1 tests/task_base.js
View
@@ -33,22 +33,61 @@ namespace('foo', function () {
console.log('foo:baz task');
});
- desc('The foo:qux task, calls foo:bar with args as a prerequisite.');
- task('qux', ['foo:bar[asdf,qwer]'], function () {
- console.log('foo:qux task');
- });
-
desc('The foo:qux task, calls foo:bar with cmdline args as a prerequisite.');
task('qux', ['foo:bar[asdf,qwer]'], function () {
console.log('foo:qux task');
});
desc('The foo:frang task, calls foo:bar with passed args as a prerequisite.');
task('frang', function () {
- jake.Task['foo:bar'].invoke('zxcv', 'uiop');
+ var task = jake.Task['foo:bar'];
+ // Do args pass-through
+ task.invoke.apply(task, arguments);
console.log('foo:frang task');
});
+ desc('The foo:zoobie task, has no prerequisites.');
+ task('zoobie', function () {
+ console.log('foo:zoobie task');
+ });
+
+ desc('The foo:voom task, has no prerequisites.');
+ task('voom', function () {
+ console.log('foo:voom task');
+ });
+
+});
+
+namespace('bar', function () {
+ desc('The bar:foo task, has no prerequisites, is async.');
+ task('foo', function () {
+ console.log('bar:foo task');
+ complete();
+ }, {async: true});
+
+ desc('The bar:bar task, has the async bar:foo task as a prerequisite.');
+ task('bar', ['bar:foo'], function () {
+ console.log('bar:bar task');
+ });
+
+});
+
+namespace('hoge', function () {
+ desc('The hoge:hoge task, has no prerequisites.');
+ task('hoge', function () {
+ console.log('hoge:hoge task');
+ });
+
+ desc('The hoge:piyo task, has no prerequisites.');
+ task('piyo', function () {
+ console.log('hoge:piyo task');
+ });
+
+ desc('The hoge:fuga task, has hoge:hoge and hoge:piyo as prerequisites.');
+ task('fuga', ['hoge:hoge', 'hoge:piyo'], function () {
+ console.log('hoge:fuga task');
+ });
+
});
/*
View
@@ -57,11 +57,23 @@ var tests = new (function () {
};
this.testPrereqWithArgsViaInvoke = function () {
- h.exec('../bin/cli.js foo:frang', function (out) {
+ h.exec('../bin/cli.js foo:frang[zxcv,uiop]', function (out) {
assert.equal('foo:bar[zxcv,uiop] task\nfoo:frang task', out);
});
};
+ this.testPrereqOrdering = function () {
+ h.exec('../bin/cli.js hoge:fuga', function (out) {
+ assert.equal('hoge:hoge task\nhoge:piyo task\nhoge:fuga task', out);
+ });
+ };
+
+ this.testAsync = function () {
+ h.exec('../bin/cli.js bar:bar', function (out) {
+ assert.equal('bar:foo task\nbar:bar task', out);
+ });
+ };
+
})();
for (var p in tests) {

0 comments on commit 433bf72

Please sign in to comment.