Permalink
Browse files

Changed tests to use nodeunit instead

  • Loading branch information...
1 parent 16010d3 commit 45fa80e4db9a2dc57a8e19b6d70542d39198f820 @christkv christkv committed May 25, 2011
View
@@ -60,7 +60,7 @@ var lazy_reader = function(repo, id, type, variable) {
//
// Returns array of commit and array of lines
Blob.blame = function(repo, commit, file, callback) {
- var Commit = require('git/commit').Commit;
+ var Commit = require('./commit').Commit;
repo.git.blame({'p':true}, commit, '--', file, function(err, data) {
if(err) return callback(err, data);
View
@@ -117,18 +117,22 @@ var actor = function(line) {
}
// Convert commit text to list of commits
-Commit.list_from_string = function(repo, text) {
+Commit.list_from_string = function(repo, text) {
// Split up the result
var lines = text.split("\n");
+
+ // require('util').debug("-------------------------------------------------- lines")
+ // require('util').debug(require('util').inspect(lines))
+ // require('util').debug("-------------------------------------------------- text end")
+
var linesshift = function() {
- var l = lines.shift();
- // console.log(l);
- return l;
+ return lines.shift();
};
var commits = [];
// Parse all commit messages
while(lines.length > 0) {
var id = linesshift().split(/ /).pop();
+ if(lines.length == 0) break;
var tree = new Tree(repo, linesshift().split(/ /).pop());
// Let's get the parents
View
@@ -1,6 +1,6 @@
{ "name" : "git"
, "description" : "A node.js library for git"
-, "version" : "0.1.1"
+, "version" : "0.1.2"
, "author" : "Christian Amor Kvalheim <christkv@gmail.com>"
, "contributors" : []
, "repository" : { "type" : "git"
@@ -14,7 +14,7 @@
, "directories" : { "lib" : "./lib/git" }
, "engines" : { "node" : ">=0.4.0" }
, "dependencies": { "compress" : ">=0.1.6" }
-, "devDependencies":{ "async_testing" : ">=0.3.2" }
+, "devDependencies":{ "nodeunit" : ">=0.5.1" }
, "licenses" : [ { "type" : "Apache License, Version 2.0"
, "url" : "http://www.apache.org/licenses/LICENSE-2.0" } ]
}
View
@@ -1,35 +1,39 @@
-
-TestSuite = require('async_testing').TestSuite,
- sys = require('sys'),
- Repo = require('git').Repo,
+var testCase = require('nodeunit').testCase,
+ Repo = require('../lib/git').Repo,
fs = require('fs'),
- Actor = require('git').Actor;
-
-var suite = exports.suite = new TestSuite("actor tests");
+ Actor = require('../lib/git').Actor;
var fixture = function(name, trim) {
return trim ? fs.readFileSync("./test/fixtures/" + name, 'ascii').trim() : fs.readFileSync("./test/fixtures/" + name, 'ascii');
}
-suite.addTests({
- "Should create actor from string seperating name and email":function(assert, finished) {
+module.exports = testCase({
+ setUp: function(callback) {
+ callback();
+ },
+
+ tearDown: function(callback) {
+ callback();
+ },
+
+ "Should create actor from string seperating name and email":function(assert) {
var actor = Actor.from_string("Tom Werner <tom@example.com>");
assert.equal("Tom Werner", actor.name);
assert.equal("tom@example.com", actor.email);
- finished();
+ assert.done();
},
- "Should create actor from string only containing name":function(assert, finished) {
+ "Should create actor from string only containing name":function(assert) {
var actor = Actor.from_string("Tom Werner");
assert.equal("Tom Werner", actor.name);
assert.equal(null, actor.email);
- finished();
+ assert.done();
},
- "Should correctly return name when calling toString()":function(assert, finished) {
+ "Should correctly return name when calling toString()":function(assert) {
var actor = Actor.from_string("Tom Werner <tom@example.com>");
assert.equal(actor.name, actor.toString());
- finished();
+ assert.done();
}
});
View
@@ -1,68 +0,0 @@
-require.paths.unshift("./lib", "./spec/lib", "./test");
-
-module.exports = {};
-
-var sys = require('sys');
-
-// patch
-var async_testing = require('async_testing');
-var TestSuite = async_testing.TestSuite = function (name) {
- this.name = name;
- this.obj = {};
-};
-TestSuite.prototype.addTests = function (obj) {
- this.obj = obj;
- for(key in obj) {
- if (!obj.hasOwnProperty(key)) continue;
- obj[key] = (function(fun) {
- return function (test) {
- return fun(test, test.finish);
- };
- })(obj[key]);
- }
-};
-
-TestSuite.prototype.runTests = function (callback) {
- module.exports[this.name] = function () {
- async_testing.runSuite(this.obj, {name:this.name, onSuitDone:callback});
- };
-};
-
-
-// Diff tests
-require('diff/test_diff').suite.runTests(function() {});
-
-// Set max listeners
-process.setMaxListeners(100);
-
-// Run all tests
-require('test_head').suite.runTests(function() {});
-require('test_diff').suite.runTests(function() {});
-require('test_file_index').suite.runTests(function() {});
-require('test_commit').suite.runTests(function() {});
-require('test_actor').suite.runTests(function() {});
-require('test_blame').suite.runTests(function() {});
-require('test_blame_tree').suite.runTests(function() {});
-require('test_blob').suite.runTests(function() {});
-require('test_commit_stats').suite.runTests(function() {});
-require('test_commit_write').suite.runTests(function() {});
-require('test_config').suite.runTests(function() {});
-require('test_git').suite.runTests(function() {});
-require('test_index_status').suite.runTests(function() {});
-require('test_merge').suite.runTests(function() {});
-require('test_raw').suite.runTests(function() {});
-require('test_remote').suite.runTests(function() {});
-require('test_repo').suite.runTests(function() {});
-require('test_git_basic').suite.runTests(function() {});
-require('test_git_alt').suite.runTests(function() {});
-// require('test_git_index').suite.runTests(function() {});
-require('test_git_iv2').suite.runTests(function() {});
-require('test_submodule').suite.runTests(function() {});
-require('test_tag').suite.runTests(function() {});
-require('test_tree').suite.runTests(function() {});
-
-
-if (module == require.main) {
- return require('async_testing').run(__filename, process.ARGV);
-}
-
View
@@ -1,18 +1,22 @@
-
-TestSuite = require('async_testing').TestSuite,
- sys = require('sys'),
- Repo = require('git').Repo,
+var testCase = require('nodeunit').testCase,
+ Repo = require('../lib/git').Repo,
fs = require('fs'),
- Actor = require('git').Actor;
-
-var suite = exports.suite = new TestSuite("blame tests");
+ Actor = require('../lib/git').Actor;
var fixture = function(name, trim) {
return trim ? fs.readFileSync("./test/fixtures/" + name, 'ascii').trim() : fs.readFileSync("./test/fixtures/" + name, 'ascii');
}
-suite.addTests({
- "Should correctly provide simple blame":function(assert, finished) {
+module.exports = testCase({
+ setUp: function(callback) {
+ callback();
+ },
+
+ tearDown: function(callback) {
+ callback();
+ },
+
+ "Should correctly provide simple blame":function(assert) {
new Repo("./test/dot_git", {is_bare:true}, function(err, repo) {
var commit = '2d3acf90f35989df8f262dc50beadc4ee3ae1560';
repo.blame('History.txt', commit, function(err, blame) {
@@ -24,12 +28,12 @@ suite.addTests({
assert.equal(3, line.lineno);
assert.equal(3, line.oldlineno);
assert.equal('634396b2f541a9f2d58b00be1a07f0c358b999b3', line.commit.id);
- finished();
+ assert.done();
})
});
},
- "Should correctly provide deep blame":function(assert, finished) {
+ "Should correctly provide deep blame":function(assert) {
new Repo("./test/dot_git", {is_bare:true}, function(err, repo) {
var commit = '2d3acf90f35989df8f262dc50beadc4ee3ae1560';
repo.blame('lib/grit.rb', commit, function(err, blame) {
@@ -42,7 +46,7 @@ suite.addTests({
assert.equal(25, line.lineno);
assert.equal(16, line.oldlineno);
assert.equal('46291865ba0f6e0c9818b11be799fe2db6964d56', line.commit.id);
- finished();
+ assert.done();
})
});
}
@@ -1,43 +1,47 @@
-
-TestSuite = require('async_testing').TestSuite,
- sys = require('sys'),
- Repo = require('git').Repo,
+var testCase = require('nodeunit').testCase,
+ Repo = require('../lib/git').Repo,
fs = require('fs'),
- Actor = require('git').Actor,
- Git = require('git').Git;
-
-var suite = exports.suite = new TestSuite("blame tree tests");
+ Actor = require('../lib/git').Actor,
+ Git = require('../lib/git').Git;
var fixture = function(name, trim) {
return trim ? fs.readFileSync("./test/fixtures/" + name, 'ascii').trim() : fs.readFileSync("./test/fixtures/" + name, 'ascii');
}
-suite.addTests({
- "Should correctly retrieve blame tree":function(assert, finished) {
+module.exports = testCase({
+ setUp: function(callback) {
+ callback();
+ },
+
+ tearDown: function(callback) {
+ callback();
+ },
+
+ "Should correctly retrieve blame tree":function(assert) {
var git = new Git("./test/dot_git");
var commit = '2d3acf90f35989df8f262dc50beadc4ee3ae1560';
git.blame_tree(commit, function(err, tree) {
assert.equal('7bcc0ee821cdd133d8a53e8e7173a334fef448aa', tree['History.txt']);
- finished();
+ assert.done();
});
},
- "Should correctly retrieve blame tree path":function(assert, finished) {
+ "Should correctly retrieve blame tree path":function(assert) {
var git = new Git("./test/dot_git");
var commit = '2d3acf90f35989df8f262dc50beadc4ee3ae1560';
git.blame_tree(commit, 'lib', function(err, tree) {
assert.equal('5a0943123f6872e75a9b1dd0b6519dd42a186fda', tree['lib/grit.rb']);
assert.equal('2d3acf90f35989df8f262dc50beadc4ee3ae1560', tree['lib/grit']);
- finished();
+ assert.done();
});
},
- "Should correctly retrieve blame tree for multiple paths":function(assert, finished) {
+ "Should correctly retrieve blame tree for multiple paths":function(assert) {
var git = new Git("./test/dot_git");
var commit = '2d3acf90f35989df8f262dc50beadc4ee3ae1560';
git.blame_tree(commit, 'lib/grit', function(err, tree) {
assert.equal('22825175e37f22c9418d756ca69b574d75602994', tree['lib/grit/diff.rb']);
- finished();
+ assert.done();
});
}
});
Oops, something went wrong.

0 comments on commit 45fa80e

Please sign in to comment.