Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix runner so it always inits repos as needed
  • Loading branch information
maxkorp committed Oct 27, 2014
commit 78ae3f22bd8d2382f482f5b08935b080f617303c
27 changes: 17 additions & 10 deletions test/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ var promisify = require("promisify-node");
var fs = promisify("fs");

// Have to wrap exec, since it has a weird callback signature.
var exec = promisify(function(command, callback) {
return require("child_process").exec(command, callback);
var exec = promisify(function(command, opts, callback) {
return require("child_process").exec(command, opts, callback);
});

before(function(done) {
Expand All @@ -12,17 +12,24 @@ before(function(done) {
var url = "https://github.com/nodegit/test";
var done = done.bind(null, null);

fs.exists("test/repos").then(function() {
return fs.mkdir("test/repos").then(function() {
return exec("git init test/repos/empty");
}).then(function() {
function initEmpty() {
return exec("git init test/repos/empty");
}

fs.mkdir("test/repos").then(initEmpty, initEmpty)
.then(function() {
return exec("git clone " + url + " test/repos/workdir");
}).then(function() {
return exec("git checkout rev-walk", {cwd: "test/repos/workdir"})
}).then(function() {
return exec("git checkout master", {cwd: "test/repos/workdir"})
}).then(function() {
var nonrepo = "test/repos/nonrepo";

return fs.mkdir(nonrepo).then(function() {
function writeBogus() {
return fs.writeFile(nonrepo + "/file.txt", "This is a bogus file");
});
})
}).then(done, done);
}

return fs.mkdir(nonrepo).then(writeBogus, writeBogus);
}).then(done, done);
});