Skip to content

Commit

Permalink
Merge branch 'v0.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
mde committed Sep 18, 2013
2 parents ba86522 + 472985a commit eaf0841
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 45 deletions.
11 changes: 4 additions & 7 deletions test/Jakefile.rule
@@ -1,6 +1,7 @@
var exec = require('child_process').exec
, fs = require('fs')
, util = require('util')
, utils = require('utilities');


task('default', ['tmp']);
Expand Down Expand Up @@ -241,11 +242,7 @@ namespace('sourceFunction', function () {
});

////////////////////////////////////////////////////////////
task('clean', function() {
exec('rm -fr ./foo ./tmp*', function (err, stdout, stderr) {
if (err) { throw err }
if (stderr || stdout) {
console.log (stderr || stdout);
}
});
task('clean', function () {
utils.file.rmRf('./foo');
utils.file.rmRf('./tmp');
});
56 changes: 26 additions & 30 deletions test/file_task.js
Expand Up @@ -2,16 +2,14 @@ var assert = require('assert')
, fs = require('fs')
, path = require('path')
, exec = require('child_process').exec
, h = require('./helpers');
, h = require('./helpers')
, utils = require('utilities');

var cleanUpAndNext = function (callback) {
exec('rm -fr ./foo', function (err, stdout, stderr) {
if (err) { throw err; }
if (stderr || stdout) {
console.log (stderr || stdout);
}
callback();
utils.file.rmRf('./foo', {
silent: true
});
callback();
};

var tests = {
Expand Down Expand Up @@ -50,7 +48,7 @@ var tests = {

, 'file-task where prereq file is modified': function (next) {
setTimeout(function () {
exec('touch ./foo/src1.txt', function (err, data) {
fs.writeFile('./foo/src1.txt', '', function (err, data) {
if (err) {
throw err;
}
Expand All @@ -59,7 +57,7 @@ var tests = {
cleanUpAndNext(next);
});
});
}, 1000); // Wait to do the touch to ensure mod-time is different
}, 1000); // Wait to do the mod to ensure mod-time is different
}

, 'test where a file-task prereq does not change with --always-make': function (next) {
Expand All @@ -76,35 +74,33 @@ var tests = {

, 'test a preexisting file': function (next) {
var prereqData = 'howdy';
h.exec('mkdir -p foo', function (out) {
fs.writeFileSync('foo/prereq.txt', prereqData);
utils.file.mkdirP('foo');
fs.writeFileSync('foo/prereq.txt', prereqData);
h.exec('../bin/cli.js fileTest:foo/from-prereq.txt', function (out) {
var data;
assert.equal('fileTest:foo/from-prereq.txt task', out);
data = fs.readFileSync(process.cwd() + '/foo/from-prereq.txt');
assert.equal(prereqData, data.toString());
h.exec('../bin/cli.js fileTest:foo/from-prereq.txt', function (out) {
var data;
assert.equal('fileTest:foo/from-prereq.txt task', out);
data = fs.readFileSync(process.cwd() + '/foo/from-prereq.txt');
assert.equal(prereqData, data.toString());
h.exec('../bin/cli.js fileTest:foo/from-prereq.txt', function (out) {
// Second time should be a no-op
assert.equal('', out);
cleanUpAndNext(next);
});
// Second time should be a no-op
assert.equal('', out);
cleanUpAndNext(next);
});
});
}

, 'test a preexisting file with --always-make flag': function (next) {
var prereqData = 'howdy';
h.exec('mkdir -p foo', function (out) {
fs.writeFileSync('foo/prereq.txt', prereqData);
h.exec('../bin/cli.js fileTest:foo/from-prereq.txt', function (out) {
var data;
utils.file.mkdirP('foo');
fs.writeFileSync('foo/prereq.txt', prereqData);
h.exec('../bin/cli.js fileTest:foo/from-prereq.txt', function (out) {
var data;
assert.equal('fileTest:foo/from-prereq.txt task', out);
data = fs.readFileSync(process.cwd() + '/foo/from-prereq.txt');
assert.equal(prereqData, data.toString());
h.exec('../bin/cli.js -B fileTest:foo/from-prereq.txt', function (out) {
assert.equal('fileTest:foo/from-prereq.txt task', out);
data = fs.readFileSync(process.cwd() + '/foo/from-prereq.txt');
assert.equal(prereqData, data.toString());
h.exec('../bin/cli.js -B fileTest:foo/from-prereq.txt', function (out) {
assert.equal('fileTest:foo/from-prereq.txt task', out);
cleanUpAndNext(next);
});
cleanUpAndNext(next);
});
});
}
Expand Down
34 changes: 26 additions & 8 deletions test/rule.js
Expand Up @@ -4,16 +4,33 @@ var assert = require('assert')
, exec = require('child_process').exec
, h = require('./helpers')
, Matcher = require('../lib/rule').Matcher
, utils = require('../lib/utils');
, utils = require('utilities');

var cleanUpAndNext = function (callback) {
exec('rm -fr ./foo ./tmp*', function (err, stdout, stderr) {
if (err) { throw err; }
if (stderr || stdout) {
console.log (stderr || stdout);
}
callback();
// Gotta add globbing to file utils rmRf
var tmpFiles = [
'tmp'
, 'tmp_ns'
, 'tmp_cr'
, 'tmp_p'
, 'tmp_pf'
, 'tmpbin'
, 'tmpsrc'
, 'tmp_dep1.c'
, 'tmp_dep1.o'
, 'tmp_dep1.oo'
, 'tmp_dep2.c'
, 'tmp_dep2.o'
, 'tmp_dep2.oo'
, 'foo'
, 'foo.html'
];
tmpFiles.forEach(function (f) {
utils.file.rmRf(f, {
silent: true
});
});
callback();
};

var tests = {
Expand Down Expand Up @@ -166,7 +183,7 @@ var tests = {

tests['test rule with source file modified (' + key + ')'] = function (next) {
setTimeout(function () {
exec('touch foo.txt', function (err, data) {
fs.writeFile('foo.txt', '', function (err, data) {
if (err) {
throw err;
}
Expand All @@ -187,6 +204,7 @@ var tests = {
tests['test rule with existing objective file and no source ' +
' (should be normal file-task) (' + key + ')'] = function (next) {
// Remove just the source file
fs.writeFileSync('foo.html', '');
utils.file.rmRf('foo.txt', {silent: true});
h.exec('../bin/cli.js -f Jakefile.rule ' + key + ':test', function (out) {
// Should treat existing objective file as plain file-task,
Expand Down

0 comments on commit eaf0841

Please sign in to comment.