Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
/vendor/libssh2/
/vendor/http_parser/
/build/
/coverage/
/test/coverage/
/test/repos/
/test/test/repos/
/src/
/include/
/lib/enums.js
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ before_install:
export CXX='g++-4.8';
fi
- "export JOBS=4"
- npm install
- BUILD_ONLY=true npm install
# This is a random private key used purely for testing.
before_script:
- echo -e "Host *\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
Expand All @@ -31,7 +31,7 @@ branches:
os:
- linux
- osx
script: npm --expose-gc test
script: npm test
notifications:
slack:
secure: KglNSqZiid9YudCwkPFDh+sZfW5BwFlM70y67E4peHwwlbbV1sSBPHcs74ZHP/lqgEZ4hMv4N2NI58oYFD5/1a+tKIQP1TkdIMuq4j2LXheuirA2HDcydOVrsC8kRx5XFGKdVRg/uyX2dlRHcOWFhxrS6yc6IxtxYWlRTD2SmEc=
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ install:
- cmd: SET PATH=C:\Program Files (x86)\MSBuild\12.0\bin\;%PATH%
- cmd: SET PATH=c:\python27;%PATH%
- cmd: SET JOBS=4
- cmd: SET BUILD_ONLY=true
- cmd: SET GIT_SSH=c:\projects\nodegit\vendor\plink.exe
- ps: Start-Process c:\projects\nodegit\vendor\pageant.exe c:\projects\nodegit\vendor\private.ppk
- cmd: npm install -g node-gyp
Expand Down
4 changes: 3 additions & 1 deletion generate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ fse.remove(path.resolve(__dirname, "../src")).then(function() {
}
}
catch (e) {
console.log(e);
if (process.env.BUILD_ONLY) {
console.log(e);
}
}
});

Expand Down
12 changes: 8 additions & 4 deletions generate/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,16 @@ libgit2.types.forEach(function(current) {
var previous = "";
enums = _(enums).sortBy("name").reduce(function(enumMemo, enumerable) {
if (previous == enumerable.typeName) {
console.log('WARNING: duplicate definition for enum ' + enumerable.typeName +
". skipped.");
if (process.env.BUILD_ONLY) {
console.warn('Duplicate definition for enum ' + enumerable.typeName +
". skipped.");
}
}
else if (!enumerable.fields) {
console.log('WARNING: incomplete definition for enum ' + enumerable.typeName +
". skipped.");
if (process.env.BUILD_ONLY) {
console.warn('Incomplete definition for enum ' + enumerable.typeName +
". skipped.");
}
}
else {
enumMemo[enumerable.typeName] = {
Expand Down
4 changes: 3 additions & 1 deletion generate/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ var Utils = {
_.merge(field, callbackDefs[field.type]);
}
else {
console.log("WARNING: Couldn't find callback definition for " + field.type);
if (process.env.BUILD_ONLY) {
console.warn("Couldn't find callback definition for " + field.type);
}
}
},

Expand Down
57 changes: 31 additions & 26 deletions install.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ var which = require("which");
var rimraf = require("rimraf");
var NODE_VERSION = Number(process.version.match(/^v(\d+\.\d+)/)[1]);

// If the build only flag is set.
var buildOnly = process.env.BUILD_ONLY;

// This will take in an object and find any matching keys in the environment
// to use as overrides.
//
Expand Down Expand Up @@ -63,13 +66,34 @@ if (NODE_VERSION === 0.1) {
pkg.http_parser = pkg.http_parser["0.10"];
}

// Ensure all dependencies are available.
var dependencies = Q.allSettled([
// This will prioritize `python2` over `python`, because we always want to
// work with Python 2.* if it"s available.
Q.nfcall(which, "python2"),
Q.nfcall(which, "python")
])
// Attempt to fallback on a prebuilt binary.
function fetchPrebuilt() {
if (!buildOnly) {
console.info("[nodegit] Fetching binary from S3.");

// Using the node-pre-gyp module, attempt to fetch a compatible build.
return Q.nfcall(exec, "node-pre-gyp install");
}

throw new Error("Build only");
}

// Attempt to fetch prebuilt binary.
Q.ninvoke(fs, "mkdir", paths.release).then(fetchPrebuilt, fetchPrebuilt)

.fail(function() {
if (!buildOnly) {
console.info("[nodegit] Failed to install prebuilt, attempting compile.");
}

// Ensure all dependencies are available.
return Q.allSettled([
// This will prioritize `python2` over `python`, because we always want to
// work with Python 2.* if it"s available.
Q.nfcall(which, "python2"),
Q.nfcall(which, "python")
])
})

// Determine if all the dependency requirements are met.
.then(function(results) {
Expand Down Expand Up @@ -218,25 +242,6 @@ var dependencies = Q.allSettled([
});
})

// Attempt to fallback on a prebuilt binary.
.fail(function(message) {
console.info("[nodegit] Failed to build nodegit.");
console.info("[nodegit] Attempting to fallback on a prebuilt binary.");

console.log(message.stack);

function fetchPrebuilt() {
console.info("[nodegit] Fetching binary from S3.");

// Using the node-pre-gyp module, attempt to fetch a compatible build.
return Q.nfcall(exec, "node-pre-gyp install");
}

// Attempt to fetch prebuilt binary.
return Q.ninvoke(fs, "mkdir", paths.release)
.then(fetchPrebuilt, fetchPrebuilt);
})

// Display a warning message about failing to build native node module.
.fail(function(message) {
console.info("[nodegit] Failed to build and install nodegit.");
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@
},
"scripts": {
"lint": "jshint lib test/tests",
"cov": "istanbul cover node_modules/mocha/bin/_mocha -- test/runner test/tests --report=lcov",
"cov": "node test",
"mocha": "mocha test/runner test/tests",
"test": "npm run lint && npm run cov",
"missing-tests": "node generate/missing-tests",
"publish": "node-pre-gyp package && node-pre-gyp publish",
"generate": "node generate/setup && node generate",
"install": "npm run generate && node install",
"rebuild": "npm run generate && node-gyp configure build"
"rebuild": "BUILD_ONLY=true npm run generate && node-gyp configure build"
}
}
13 changes: 13 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
var args = [
"cover",
process.platform != "win32" ? "_mocha" : "../node_modules/mocha/bin/_mocha",
"--",
"runner",
"tests",
"--report=lcov",
"--expose-gc"
];

require("child_process").fork("../node_modules/istanbul/lib/cli.js", args, {
cwd: __dirname
});
2 changes: 1 addition & 1 deletion test/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var exec = promisify(function(command, opts, callback) {
});

before(function(done) {
this.timeout(150000);
this.timeout(350000);

var url = "https://github.com/nodegit/test";
var done = done.bind(null, null);
Expand Down
39 changes: 21 additions & 18 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(60000);

before(function(done) {
var test = this;
return Repository.open(reposPath).then(function(repository) {
Expand Down Expand Up @@ -81,31 +84,31 @@ 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) {
for (var i = 0; i < 1000; i++) {
if (true) {
commit.author().name();
commit.author().email();
}
global.gc();

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

for (var i = 0; i < 500; i++) {
commit.author().name();
commit.author().email();

if ( i % 250 === 0) {
global.gc();
}
}
});
});
});
});

});