Skip to content

Commit 551fd42

Browse files
tbranyenJohn Haley
authored andcommitted
Modified revwalk test to only call done once
1 parent 8340770 commit 551fd42

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

test/tests/revwalk.js

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ describe("Revwalk", function() {
88
var Revwalk = require("../../lib/revwalk");
99
var Oid = require("../../lib/oid");
1010

11+
// Set a reasonable timeout here now that our repository has grown.
12+
this.timeout(150000);
13+
1114
before(function(done) {
1215
var test = this;
1316
return Repository.open(reposPath).then(function(repository) {
@@ -81,34 +84,29 @@ describe("Revwalk", function() {
8184
});
8285
});
8386

84-
// This test requires forcing garbage collection, so mocha needs to be run via
85-
// node rather than npm, with a la `node --expose-gc [pathtohmoca] [testglob]`
86-
var testGC = (global.gc ? it : it.skip);
87+
// This test requires forcing garbage collection, so mocha needs to be run
88+
// via node rather than npm, with a la `node --expose-gc [pathtohmoca]
89+
// [testglob]`
90+
var testGC = global.gc ? it : it.skip;
8791

8892
testGC("doesnt segfault when accessing .author() twice", function(done) {
89-
this.timeout(10000);
90-
91-
return Repository.open(reposPath).then(function(repository) {
93+
Repository.open(reposPath).then(function(repository) {
9294
var walker = repository.createRevWalk();
93-
return repository.getMasterCommit().then(function(firstCommitOnMaster) {
94-
var did = false;
95-
walker.walk(firstCommitOnMaster, function(error, commit) {
95+
96+
repository.getMasterCommit().then(function(firstCommitOnMaster) {
97+
walker.walk(firstCommitOnMaster, function(err, commit) {
98+
if (!err && !commit) {
99+
return done();
100+
}
101+
96102
for (var i = 0; i < 1000; i++) {
97-
if (true) {
98-
commit.author().name();
99-
commit.author().email();
100-
}
103+
commit.author().name();
104+
commit.author().email();
105+
101106
global.gc();
102107
}
103-
if (!did) {
104-
done();
105-
did = true;
106-
}
107108
});
108109
});
109-
}).then(function() {
110-
global.gc();
111110
});
112111
});
113-
114112
});

0 commit comments

Comments
 (0)