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
Modified revwalk test to only call done once
  • Loading branch information
tbranyen authored and John Haley committed Nov 24, 2014
commit 551fd42a7fc193487f74e0ed14d7397add96cb36
38 changes: 18 additions & 20 deletions test/tests/revwalk.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ describe("Revwalk", function() {
var Revwalk = require("../../lib/revwalk");
var Oid = require("../../lib/oid");

// Set a reasonable timeout here now that our repository has grown.
this.timeout(150000);

before(function(done) {
var test = this;
return Repository.open(reposPath).then(function(repository) {
Expand Down Expand Up @@ -81,34 +84,29 @@ describe("Revwalk", function() {
});
});

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

testGC("doesnt segfault when accessing .author() twice", function(done) {
this.timeout(10000);

return Repository.open(reposPath).then(function(repository) {
Repository.open(reposPath).then(function(repository) {
var walker = repository.createRevWalk();
return repository.getMasterCommit().then(function(firstCommitOnMaster) {
var did = false;
walker.walk(firstCommitOnMaster, function(error, commit) {

repository.getMasterCommit().then(function(firstCommitOnMaster) {
walker.walk(firstCommitOnMaster, function(err, commit) {
if (!err && !commit) {
return done();
}

for (var i = 0; i < 1000; i++) {
if (true) {
commit.author().name();
commit.author().email();
}
commit.author().name();
commit.author().email();

global.gc();
}
if (!did) {
done();
did = true;
}
});
});
}).then(function() {
global.gc();
});
});

});