Permalink
Browse files

Reformat tests for nicer output of names

  • Loading branch information...
1 parent 9df8242 commit 6bd2319c0da5d1145a37b02e4f0f88efb4d957a6 mde committed Jun 9, 2012
Showing with 64 additions and 69 deletions.
  1. +12 −12 tests/exec.js
  2. +13 −21 tests/file_task.js
  3. +9 −6 tests/file_utils.js
  4. +30 −30 tests/task_base.js
View
@@ -7,8 +7,8 @@ utils.mixin(jake, utils);
process.chdir('./tests');
-var tests = new (function () {
- this.testBasicExec = function () {
+var tests = {
+ 'test basic exec': function () {
var ex = jake.createExec('ls', function () {})
, evts = { // Events should fire in this order
cmdStart: [0, null]
@@ -35,36 +35,36 @@ var tests = new (function () {
});
h.next();
- };
+ }
- this.testExecFailure = function () {
+, 'test an exec failure': function () {
var ex = jake.createExec('false', function () {});
ex.addListener('error', function (msg, code) {
assert.equal(1, code);
});
ex.run();
h.next();
- };
+ }
- this.testStdout = function () {
+, 'test exec stdout events': function () {
var ex = jake.createExec('echo "foo"', function () {});
ex.addListener('stdout', function (data) {
assert.equal("foo", h.trim(data.toString()));
});
ex.run();
h.next();
- };
+ }
- this.testStderr = function () {
+, 'test exec stderr events': function () {
var ex = jake.createExec('echo "foo" 1>&2', function () {});
ex.addListener('stderr', function (data) {
assert.equal("foo", h.trim(data.toString()));
});
ex.run();
h.next();
- };
+ }
- this.testPipe = function () {
+, 'test piping results into next command': function () {
var ex = jake.createExec('ls', function () {})
, data
, appended = false;
@@ -99,9 +99,9 @@ var tests = new (function () {
});
ex.run();
h.next();
- };
+ }
-})();
+};
h.run(tests, function () {
process.chdir('../');
View
@@ -15,8 +15,9 @@ var cleanUpAndNext = function () {
});
};
-var tests = new (function () {
- this.testConcatTwoFiles = function () {
+var tests = {
+
+ 'test concating two files': function () {
h.exec('../bin/cli.js fileTest:foo/concat.txt', function (out) {
var data;
assert.equal('fileTest:foo/src1.txt task\ndefault task\nfileTest:foo/src2.txt task\n' +
@@ -26,9 +27,9 @@ var tests = new (function () {
assert.equal('src1src2', data.toString());
cleanUpAndNext();
});
- };
+ }
- this.testNoPrereqChange = function () {
+, 'test where a file-task prereq does not change': function () {
h.exec('../bin/cli.js fileTest:foo/from-src1.txt', function (out) {
assert.equal('fileTest:foo/src1.txt task\nfileTest:foo/from-src1.txt task', out);
h.exec('../bin/cli.js fileTest:foo/from-src1.txt', function (out) {
@@ -37,9 +38,9 @@ var tests = new (function () {
cleanUpAndNext();
});
});
- };
+ }
- this.testNoPrereqChangeAlwaysMake = function () {
+, 'test where a file-task prereq does not change with --always-make': function () {
h.exec('../bin/cli.js fileTest:foo/from-src1.txt', function (out) {
assert.equal('fileTest:foo/src1.txt task\nfileTest:foo/from-src1.txt task',
out);
@@ -49,9 +50,9 @@ var tests = new (function () {
cleanUpAndNext();
});
});
- };
+ }
- this.testPreexistingFile = function () {
+, 'test a preexisting file': function () {
var prereqData = 'howdy';
h.exec('mkdir -p foo', function (out) {
fs.writeFileSync('foo/prereq.txt', prereqData);
@@ -64,21 +65,12 @@ var tests = new (function () {
// Second time should be a no-op
assert.equal('', out);
cleanUpAndNext();
- /*
- h.exec('../bin/cli.js fileTest:touch-prereq', function () {
- h.exec('../bin/cli.js fileTest:foo/from-prereq.txt', function (out) {
- // Third time should update the target file
- assert.equal('fileTest:foo/from-prereq.txt task', out);
- cleanUpAndNext();
- });
- });
- */
});
});
});
- };
+ }
- this.testPreexistingFileAlwaysMake = function () {
+, 'test a preexisting file with --always-make flag': function () {
var prereqData = 'howdy';
h.exec('mkdir -p foo', function (out) {
fs.writeFileSync('foo/prereq.txt', prereqData);
@@ -93,9 +85,9 @@ var tests = new (function () {
});
});
});
- };
+ }
-})();
+};
h.run(tests, function () {
process.chdir('../');
View
@@ -5,8 +5,9 @@ var assert = require('assert')
process.chdir('./tests');
-var tests = new (function () {
- this.mkdirP = function () {
+var tests = {
+
+ 'test mkdirP': function () {
var expected = [
'foo'
, 'foo/bar'
@@ -21,17 +22,19 @@ var tests = new (function () {
}
fileUtils.rmRf('foo');
h.next();
- };
+ }
- this.rmRf = function () {
+, 'test rmRf': function () {
fileUtils.mkdirP('foo/bar/baz/qux');
fileUtils.rmRf('foo/bar');
res = fileUtils.readdirR('foo');
assert.equal(1, res.length);
assert.equal('foo', res[0]);
fs.rmdirSync('foo');
- };
-})();
+ h.next();
+ }
+
+};
h.run(tests, function () {
View
@@ -3,8 +3,8 @@ var assert = require('assert')
process.chdir('./tests');
-var tests = new (function () {
- this.testDefault = function () {
+var tests = {
+ 'test default task': function () {
h.exec('../bin/cli.js', function (out) {
assert.equal('default task', out);
});
@@ -13,41 +13,41 @@ var tests = new (function () {
assert.equal('default task', out);
});
h.next();
- };
+ }
- this.testNoAction = function () {
+, 'test task with no action': function () {
h.exec('../bin/cli.js noAction', function (out) {
assert.equal('default task', out);
});
h.next();
- };
+ }
- this.testNoActionNoPrereqs = function () {
+, 'test a task with no action and no prereqs': function () {
h.exec('../bin/cli.js noActionNoPrereqs', function () {});
h.next();
- };
+ }
- this.testWithArgs = function () {
+, 'test passing args to a task': function () {
h.exec('../bin/cli.js argsEnvVars[foo,bar]', function (out) {
var parsed = h.parse(out)
, args = parsed.args;
assert.equal(args[0], 'foo');
assert.equal(args[1], 'bar');
});
h.next();
- };
+ }
- this.testWithEnvVars = function () {
+, 'test a task with environment vars': function () {
h.exec('../bin/cli.js argsEnvVars foo=bar baz=qux', function (out) {
var parsed = h.parse(out)
, env = parsed.env;
assert.equal(env.foo, 'bar');
assert.equal(env.baz, 'qux');
});
h.next();
- };
+ }
- this.testWithArgsAndEnvVars = function () {
+, 'test passing args and using environment vars': function () {
h.exec('../bin/cli.js argsEnvVars[foo,bar] foo=bar baz=qux', function (out) {
var parsed = h.parse(out)
, args = parsed.args
@@ -58,66 +58,66 @@ var tests = new (function () {
assert.equal(env.baz, 'qux');
});
h.next();
- };
+ }
- this.testPrereq = function () {
+, 'test a simple prereq': function () {
h.exec('../bin/cli.js foo:baz', function (out) {
assert.equal('foo:bar task\nfoo:baz task', out);
});
h.next();
- };
+ }
- this.testSamePrereqTwice = function () {
+, 'test a duplicate prereq only runs once': function () {
h.exec('../bin/cli.js foo:asdf', function (out) {
assert.equal('foo:bar task\nfoo:baz task\nfoo:asdf task', out);
});
h.next();
- };
+ }
- this.testPrereqWithCmdlineArgs = function () {
+, 'test a prereq with command-line args': function () {
h.exec('../bin/cli.js foo:qux', function (out) {
assert.equal('foo:bar[asdf,qwer] task\nfoo:qux task', out);
});
h.next();
- };
+ }
- this.testPrereqWithArgsViaInvoke = function () {
+, 'test a prereq with args via invoke': function () {
h.exec('../bin/cli.js foo:frang[zxcv,uiop]', function (out) {
assert.equal('foo:bar[zxcv,uiop] task\nfoo:frang task', out);
});
h.next();
- };
+ }
- this.testPrereqOrdering = function () {
+, 'test prereq execution-order': function () {
h.exec('../bin/cli.js hoge:fuga', function (out) {
assert.equal('hoge:hoge task\nhoge:piyo task\nhoge:fuga task', out);
});
h.next();
- };
+ }
- this.testAsync = function () {
+, 'test basic async task': function () {
h.exec('../bin/cli.js bar:bar', function (out) {
assert.equal('bar:foo task\nbar:bar task', out);
});
h.next();
- };
+ }
- this.testPrereqIndexReset = function () {
+, 'test that current-prereq index gets reset': function () {
h.exec('../bin/cli.js hoge:kira', function (out) {
assert.equal('hoge:hoge task\nhoge:piyo task\nhoge:fuga task\n' +
'hoge:charan task\nhoge:gero task\nhoge:kira task', out);
});
h.next();
- };
+ }
- this.modifyTaskAddPrereq = function () {
+, 'test modifying a task by adding prereq during execution': function () {
h.exec('../bin/cli.js voom', function (out) {
assert.equal(2, out);
});
h.next();
- };
+ }
-})();
+};
h.run(tests, function () {
process.chdir('../');

0 comments on commit 6bd2319

Please sign in to comment.