From 4ed92b9121fea03e5b24b6aeb6eb2e5f10391be4 Mon Sep 17 00:00:00 2001 From: Tim Branyen Date: Tue, 24 Feb 2015 16:14:20 -0800 Subject: [PATCH 1/3] Attempt to fix Windows file locking bug --- generate/input/descriptor.json | 3 --- generate/scripts/helpers.js | 4 ++-- test/tests/clone.js | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/generate/input/descriptor.json b/generate/input/descriptor.json index 768a9b5a6..6c4da260c 100644 --- a/generate/input/descriptor.json +++ b/generate/input/descriptor.json @@ -1431,9 +1431,6 @@ "git_repository_fetchhead_foreach": { "ignore": true }, - "git_repository_free": { - "ignore": true - }, "git_repository_hashfile": { "ignore": true }, diff --git a/generate/scripts/helpers.js b/generate/scripts/helpers.js index 49cf3be44..733e546a6 100644 --- a/generate/scripts/helpers.js +++ b/generate/scripts/helpers.js @@ -288,8 +288,8 @@ var Helpers = { // available if (key == typeDef.cType + "_free") { typeDef.freeFunctionName = key; - fnDef.ignore = true; - return; + //fnDef.ignore = true; + //return; } fnDef.cppFunctionName = Helpers.cTypeToCppName(key, "git_" + typeDef.typeName); diff --git a/test/tests/clone.js b/test/tests/clone.js index 6f485672e..987e25687 100644 --- a/test/tests/clone.js +++ b/test/tests/clone.js @@ -28,7 +28,9 @@ describe("Clone", function() { fse.remove(ssh), fse.remove(git), fse.remove(file) - ]).catch(function unhandledFunction() {}); + ]).catch(function unhandledFunction(ex) { + console.log(ex.message); + }); }); it.skip("can clone with http", function() { @@ -43,6 +45,7 @@ describe("Clone", function() { return Clone.clone(url, http, opts).then(function(repo) { assert.ok(repo instanceof Repository); + repo.free(); }); }); @@ -58,6 +61,8 @@ describe("Clone", function() { return Clone.clone(url, https, opts).then(function(repo) { assert.ok(repo instanceof Repository); + repo.stateCleanup(); + repo.free(); }); }); @@ -76,6 +81,8 @@ describe("Clone", function() { return Clone.clone(url, ssh, opts).then(function(repo) { assert.ok(repo instanceof Repository); + repo.stateCleanup(); + repo.free(); }); }); @@ -98,6 +105,8 @@ describe("Clone", function() { return Clone.clone(url, ssh, opts).then(function(repo) { assert.ok(repo instanceof Repository); + repo.stateCleanup(); + repo.free(); }); }); @@ -113,6 +122,8 @@ describe("Clone", function() { return Clone.clone(url, git, opts).then(function(repo) { assert.ok(repo instanceof Repository); + repo.stateCleanup(); + repo.free(); }); }); @@ -122,6 +133,8 @@ describe("Clone", function() { return Clone.clone(url, file).then(function(repo) { assert.ok(repo instanceof Repository); + repo.stateCleanup(); + repo.free(); }); }); From 3ec2b6c0bad41b2a15d7de249653007ee6cba95c Mon Sep 17 00:00:00 2001 From: Tim Branyen Date: Wed, 25 Feb 2015 09:33:59 -0800 Subject: [PATCH 2/3] Test 2 --- test/tests/clone.js | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/test/tests/clone.js b/test/tests/clone.js index 987e25687..5c44f5f4c 100644 --- a/test/tests/clone.js +++ b/test/tests/clone.js @@ -9,11 +9,7 @@ describe("Clone", function() { var Clone = require(local("../../lib/clone")); var NodeGit = require(local("../../")); - var http = local("../repos/http"); - var https = local("../repos/https"); - var ssh = local("../repos/ssh"); - var git = local("../repos/git"); - var file = local("../repos/file"); + var clonePath = local("../repos/clone"); var sshPublicKey = local("../id_rsa.pub"); var sshPrivateKey = local("../id_rsa"); @@ -23,11 +19,7 @@ describe("Clone", function() { beforeEach(function() { return NodeGit.Promise.all([ - fse.remove(http), - fse.remove(https), - fse.remove(ssh), - fse.remove(git), - fse.remove(file) + fse.remove(clonePath), ]).catch(function unhandledFunction(ex) { console.log(ex.message); }); @@ -43,7 +35,7 @@ describe("Clone", function() { } }; - return Clone.clone(url, http, opts).then(function(repo) { + return Clone.clone(url, clonePath, opts).then(function(repo) { assert.ok(repo instanceof Repository); repo.free(); }); @@ -59,7 +51,7 @@ describe("Clone", function() { } }; - return Clone.clone(url, https, opts).then(function(repo) { + return Clone.clone(url, clonePath, opts).then(function(repo) { assert.ok(repo instanceof Repository); repo.stateCleanup(); repo.free(); @@ -79,7 +71,7 @@ describe("Clone", function() { } }; - return Clone.clone(url, ssh, opts).then(function(repo) { + return Clone.clone(url, clonePath, opts).then(function(repo) { assert.ok(repo instanceof Repository); repo.stateCleanup(); repo.free(); @@ -103,7 +95,7 @@ describe("Clone", function() { } }; - return Clone.clone(url, ssh, opts).then(function(repo) { + return Clone.clone(url, clonePath, opts).then(function(repo) { assert.ok(repo instanceof Repository); repo.stateCleanup(); repo.free(); @@ -120,7 +112,7 @@ describe("Clone", function() { } }; - return Clone.clone(url, git, opts).then(function(repo) { + return Clone.clone(url, clonePath, opts).then(function(repo) { assert.ok(repo instanceof Repository); repo.stateCleanup(); repo.free(); @@ -131,7 +123,7 @@ describe("Clone", function() { var prefix = process.platform === "win32" ? "" : "file://"; var url = prefix + local("../repos/empty"); - return Clone.clone(url, file).then(function(repo) { + return Clone.clone(url, clonePath).then(function(repo) { assert.ok(repo instanceof Repository); repo.stateCleanup(); repo.free(); @@ -141,7 +133,7 @@ describe("Clone", function() { it("will not segfault when accessing a url without username", function() { var url = "https://github.com/nodegit/private"; - return Clone.clone(url, git, { + return Clone.clone(url, clonePath, { remoteCallbacks: { certificateCheck: function() { return 1; From 1558da6a4ed19dd467671a3ad3076c2965a68a48 Mon Sep 17 00:00:00 2001 From: Tim Branyen Date: Wed, 25 Feb 2015 10:22:06 -0800 Subject: [PATCH 3/3] Always cleanup repositories --- test/runner.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/runner.js b/test/runner.js index 3f78715f4..8f59382ed 100644 --- a/test/runner.js +++ b/test/runner.js @@ -45,3 +45,15 @@ beforeEach(function() { return exec("git reset --hard", {cwd: workdirPath}); }); }); + +afterEach(function() { + if (this.repository) { + this.repository.free(); + delete this.repository; + } + + else if (this.repo) { + this.repo.free(); + delete this.repo; + } +});