From eadcc0abb96f2687b3c4cfd0067689a5ae572eea Mon Sep 17 00:00:00 2001 From: Max Korp Date: Mon, 27 Oct 2014 10:13:48 -0700 Subject: [PATCH 1/9] point tests to use test repo now --- test/runner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/runner.js b/test/runner.js index bd4cbbf81..4273828ce 100644 --- a/test/runner.js +++ b/test/runner.js @@ -9,7 +9,7 @@ var exec = promisify(function(command, callback) { before(function(done) { this.timeout(150000); - var url = "https://github.com/nodegit/nodegit"; + var url = "https://github.com/nodegit/test"; var done = done.bind(null, null); fs.exists("test/repos").then(function() { From fbddf34e37bcfe8d0dcf0f5a33c37ffa2852d7b0 Mon Sep 17 00:00:00 2001 From: Max Korp Date: Mon, 27 Oct 2014 10:14:16 -0700 Subject: [PATCH 2/9] stop using masterfor revwalk tests --- test/tests/revwalk.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/test/tests/revwalk.js b/test/tests/revwalk.js index ff8f370ca..1137bacd9 100644 --- a/test/tests/revwalk.js +++ b/test/tests/revwalk.js @@ -15,9 +15,9 @@ describe("Revwalk", function() { test.repository = repository; test.walker = repository.createRevWalk(); - return test.repository.getMaster().then(function(master) { - test.master = master; - test.walker.push(test.master.id()); + return test.repository.getBranch('rev-walk').then(function(branch) { + test.branch = branch; + test.walker.push(test.branch.id()); }); }); }); @@ -27,20 +27,22 @@ describe("Revwalk", function() { }); it("can push an object", function() { - var sha = this.master.sha(); + var sha = this.branch.sha(); return this.walker.next().then(function(commit) { assert.equal(sha, commit); }); }); - it.skip("can hide an object", function() { + it("can hide an object", function() { var test = this; this.walker.hide(Oid.fromstr("a03e044fcb45c654d4e15a4e495a6a0c6e632854")); return test.walker.next().then(function(commit) { + console.dir(commit); return test.walker.next().then(function(commit) { + console.dir(commit); assert.equal(commit, "1efa3354299ede235f90880383176fb5d48aaa89"); }); }); From 9451ae2b826870bdf69912e6d0571abf0e01f1e3 Mon Sep 17 00:00:00 2001 From: Max Korp Date: Mon, 27 Oct 2014 10:29:34 -0700 Subject: [PATCH 3/9] point remote test to expect test repo --- test/tests/remote.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tests/remote.js b/test/tests/remote.js index a830f783a..21108bea2 100644 --- a/test/tests/remote.js +++ b/test/tests/remote.js @@ -32,7 +32,7 @@ describe("Remote", function() { it("can read the remote url", function() { assert.equal( this.remote.url().replace(".git", ""), - "https://github.com/nodegit/nodegit"); + "https://github.com/nodegit/test"); }); it("can read the remote name", function() { From fd9ddb7a481ad16a0f827b97baf5120b1ca710f8 Mon Sep 17 00:00:00 2001 From: Max Korp Date: Mon, 27 Oct 2014 10:30:59 -0700 Subject: [PATCH 4/9] point other remote tests to expect test repo --- test/tests/remote.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/tests/remote.js b/test/tests/remote.js index 21108bea2..ee63628f9 100644 --- a/test/tests/remote.js +++ b/test/tests/remote.js @@ -41,18 +41,18 @@ describe("Remote", function() { it("can create a new remote", function() { var repository = this.repository; - var url = "https://github.com/nodegit/nodegit"; + var url = "https://github.com/nodegit/test"; return Remote.create(repository, "origin2", url).then(function() { return Remote.load(repository, "origin2").then(function(remote) { - assert(remote.url(), "https://github.com/nodegit/nodegit"); + assert(remote.url(), "https://github.com/nodegit/test"); }); }); }); it("can delete a remote", function() { var repository = this.repository; - var url = "https://github.com/nodegit/nodegit"; + var url = "https://github.com/nodegit/test"; return Remote.create(repository, "origin3", url).then(function() { return Remote.load(repository, "origin3").then(function(remote) { From b2476439afed735dbaff9f290125e2fd0cf45452 Mon Sep 17 00:00:00 2001 From: Max Korp Date: Mon, 27 Oct 2014 12:43:41 -0700 Subject: [PATCH 5/9] fix simplify test --- test/tests/revwalk.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/test/tests/revwalk.js b/test/tests/revwalk.js index 1137bacd9..fd10f0f2e 100644 --- a/test/tests/revwalk.js +++ b/test/tests/revwalk.js @@ -8,7 +8,7 @@ describe("Revwalk", function() { var Revwalk = require("../../lib/revwalk"); var Oid = require("../../lib/oid"); - before(function() { + beforeEach(function(done) { var test = this; return Repository.open(reposPath).then(function(repository) { @@ -18,6 +18,7 @@ describe("Revwalk", function() { return test.repository.getBranch('rev-walk').then(function(branch) { test.branch = branch; test.walker.push(test.branch.id()); + done(); }); }); }); @@ -37,25 +38,31 @@ describe("Revwalk", function() { it("can hide an object", function() { var test = this; - this.walker.hide(Oid.fromstr("a03e044fcb45c654d4e15a4e495a6a0c6e632854")); + //this.walker.hide(Oid.fromstr("95f695136203a372751c19b6353aeb5ae32ea40e")); return test.walker.next().then(function(commit) { - console.dir(commit); + console.log(commit.toString()); return test.walker.next().then(function(commit) { - console.dir(commit); - assert.equal(commit, "1efa3354299ede235f90880383176fb5d48aaa89"); + console.log(commit.toString()); + return test.walker.next().then(function(commit) { + console.log(commit.toString()); + assert.equal(commit.toString(), + "b8a94aefb22d0534cc0e5acf533989c13d8725dc"); + }); }); }); }); - it.skip("can simplify to first parent", function() { + it("can simplify to first parent", function() { var test = this; test.walker.simplifyFirstParent(); - return test.walker.next().then(function(commit) { return test.walker.next().then(function(commit) { - assert.equal(commit, "231c550f3ec28874b4c426fc9eebad9a742e1332"); + return test.walker.next().then(function(commit) { + assert.equal(commit.toString(), + "b8a94aefb22d0534cc0e5acf533989c13d8725dc"); + }); }); }); }); From 3b46bbfac289555d90c1a9aff6c85ca4a5cd1011 Mon Sep 17 00:00:00 2001 From: Max Korp Date: Mon, 27 Oct 2014 12:53:52 -0700 Subject: [PATCH 6/9] fix hiding --- test/tests/revwalk.js | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/test/tests/revwalk.js b/test/tests/revwalk.js index fd10f0f2e..7826852f7 100644 --- a/test/tests/revwalk.js +++ b/test/tests/revwalk.js @@ -15,7 +15,7 @@ describe("Revwalk", function() { test.repository = repository; test.walker = repository.createRevWalk(); - return test.repository.getBranch('rev-walk').then(function(branch) { + return test.repository.getBranch("rev-walk").then(function(branch) { test.branch = branch; test.walker.push(test.branch.id()); done(); @@ -38,16 +38,29 @@ describe("Revwalk", function() { it("can hide an object", function() { var test = this; - //this.walker.hide(Oid.fromstr("95f695136203a372751c19b6353aeb5ae32ea40e")); - return test.walker.next().then(function(commit) { - console.log(commit.toString()); return test.walker.next().then(function(commit) { - console.log(commit.toString()); return test.walker.next().then(function(commit) { - console.log(commit.toString()); - assert.equal(commit.toString(), - "b8a94aefb22d0534cc0e5acf533989c13d8725dc"); + return test.walker.next().then(function(commit) { + assert.equal(commit.toString(), + "b8a94aefb22d0534cc0e5acf533989c13d8725dc"); + test.walker = test.repository.createRevWalk(); + test.walker.push(test.branch.id()); + test.walker.hide( + Oid.fromstr("b8a94aefb22d0534cc0e5acf533989c13d8725dc")); + + return test.walker.next().then(function(commit) { + return test.walker.next().then(function(commit) { + return test.walker.next().then(function(commit) { + assert.equal(commit.toString(), + "95f695136203a372751c19b6353aeb5ae32ea40e"); + return test.walker.next().then(function(commit) { + assert.equal(commit, undefined); + }); + }); + }); + }); + }); }); }); }); From 78ae3f22bd8d2382f482f5b08935b080f617303c Mon Sep 17 00:00:00 2001 From: Max Korp Date: Mon, 27 Oct 2014 13:17:03 -0700 Subject: [PATCH 7/9] fix runner so it always inits repos as needed --- test/runner.js | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/test/runner.js b/test/runner.js index 4273828ce..eae6cc80c 100644 --- a/test/runner.js +++ b/test/runner.js @@ -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) { @@ -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); }); From 742742aa89c51540ec182cd0c5d06c17e01954e4 Mon Sep 17 00:00:00 2001 From: Max Korp Date: Mon, 27 Oct 2014 13:21:58 -0700 Subject: [PATCH 8/9] up timeout on prep for revwalk tests --- test/tests/revwalk.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/tests/revwalk.js b/test/tests/revwalk.js index 7826852f7..7fd287183 100644 --- a/test/tests/revwalk.js +++ b/test/tests/revwalk.js @@ -9,6 +9,8 @@ describe("Revwalk", function() { var Oid = require("../../lib/oid"); beforeEach(function(done) { + // These inits run extremely fast locally but time out on travis + this.timeout(4000); var test = this; return Repository.open(reposPath).then(function(repository) { From 81757580218872e895ff3bfc0033f663de29bf36 Mon Sep 17 00:00:00 2001 From: Max Korp Date: Mon, 27 Oct 2014 13:31:22 -0700 Subject: [PATCH 9/9] speed up test prep for revwalk --- test/tests/revwalk.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/tests/revwalk.js b/test/tests/revwalk.js index 7fd287183..566903590 100644 --- a/test/tests/revwalk.js +++ b/test/tests/revwalk.js @@ -8,23 +8,22 @@ describe("Revwalk", function() { var Revwalk = require("../../lib/revwalk"); var Oid = require("../../lib/oid"); - beforeEach(function(done) { - // These inits run extremely fast locally but time out on travis - this.timeout(4000); + before(function(done) { var test = this; - return Repository.open(reposPath).then(function(repository) { test.repository = repository; - test.walker = repository.createRevWalk(); - return test.repository.getBranch("rev-walk").then(function(branch) { test.branch = branch; - test.walker.push(test.branch.id()); done(); }); }); }); + beforeEach(function() { + this.walker = this.repository.createRevWalk(); + this.walker.push(this.branch.id()); + }); + it("can create a walker", function() { assert.ok(this.walker instanceof Revwalk); });