From af27ef024baa4479f1417fe9006da00d6b4a4c12 Mon Sep 17 00:00:00 2001 From: Alex A Date: Tue, 24 May 2022 12:37:21 +0200 Subject: [PATCH 1/4] make test fail --- test/tests/submodule.js | 57 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/test/tests/submodule.js b/test/tests/submodule.js index 2323fa56c..b54bce497 100644 --- a/test/tests/submodule.js +++ b/test/tests/submodule.js @@ -1,5 +1,6 @@ var assert = require("assert"); var path = require("path"); +var fse = require("fs-extra"); var local = path.join.bind(path, __dirname); describe("Submodule", function() { @@ -158,6 +159,62 @@ describe("Submodule", function() { }); }); + it.only("make remove repo fail", function(done) { + this.timeout(30000); + + var repo = this.repository; + var submodulePath = "nodegittest"; + var submoduleUrl = "https://github.com/nodegit/test.git"; + + var submodule; + var submoduleRepo; + + return NodeGit.Submodule.addSetup(repo, submoduleUrl, submodulePath, 0) + .then(function(_submodule) { + submodule = _submodule; + + return submodule.init(0); + }) + .then(function() { + return submodule.open(); + }) + .then(function(_submoduleRepo) { + submoduleRepo = _submoduleRepo; + return submoduleRepo.fetch("origin", null, null); + }) + .then(function() { + return submoduleRepo.getReference("origin/master"); + }) + .then(function(reference) { + return reference.peel(NodeGit.Object.TYPE.COMMIT); + }) + .then(function(commit) { + return submoduleRepo.createBranch("master", commit.id()); + }) + .then(function() { + return submodule.addFinalize(); + }) + .then(function() { + // check whether the submodule exists + return Submodule.lookup(repo, submodulePath); + }) + .then(function(submodule) { + assert.equal(submodule.name(), submodulePath); + // check whether .gitmodules and the submodule are in the index + return repo.refreshIndex(); + }) + .then(function(index) { + var entries = index.entries(); + assert.equal(entries.length, 2); + assert.equal(entries[0].path, ".gitmodules"); + assert.equal(entries[1].path, submodulePath); + return fse.remove(repoPath); + }) + .then(function() { + done(); + }); + }); + it("can run sync callback without deadlocking", function() { var repo = this.workdirRepository; var submodules = []; From 0e25ed0dfb5b5e61c25e737fbfbac8e0563e483d Mon Sep 17 00:00:00 2001 From: Alex A Date: Tue, 24 May 2022 14:06:46 +0200 Subject: [PATCH 2/4] t --- test/tests/submodule.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/tests/submodule.js b/test/tests/submodule.js index b54bce497..f78f9a5a4 100644 --- a/test/tests/submodule.js +++ b/test/tests/submodule.js @@ -159,7 +159,7 @@ describe("Submodule", function() { }); }); - it.only("make remove repo fail", function(done) { + it.only("make remove repo fail", function() { this.timeout(30000); var repo = this.repository; @@ -211,7 +211,7 @@ describe("Submodule", function() { return fse.remove(repoPath); }) .then(function() { - done(); + assert.ok(true); }); }); From 1ab6c1999f8f14975a26db1a41e3e80c53c5b038 Mon Sep 17 00:00:00 2001 From: Alex A Date: Tue, 24 May 2022 14:10:29 +0200 Subject: [PATCH 3/4] t2 --- test/tests/submodule.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/tests/submodule.js b/test/tests/submodule.js index f78f9a5a4..9065e55ac 100644 --- a/test/tests/submodule.js +++ b/test/tests/submodule.js @@ -212,6 +212,10 @@ describe("Submodule", function() { }) .then(function() { assert.ok(true); + }) + .catch(function(error) { + assert.ok(error instanceof Error); + console.log(error.message); }); }); From 70058007279c58ea874ac4a1d2e749d1456c651e Mon Sep 17 00:00:00 2001 From: Alex A Date: Tue, 24 May 2022 18:41:33 +0200 Subject: [PATCH 4/4] t3 --- test/tests/index.js | 11 ++++++ test/tests/submodule.js | 74 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 80 insertions(+), 5 deletions(-) diff --git a/test/tests/index.js b/test/tests/index.js index f3d29e7f7..9c5c794eb 100644 --- a/test/tests/index.js +++ b/test/tests/index.js @@ -29,6 +29,17 @@ describe("Index", function() { this.index.clear(); }); + // THIS TEST DOES NOT MAKE IT FAIL + it.skip("can remove repo's folder after accessing its index", function() { + var entries = this.index.entries(); + + assert.equal(entries[0].path, ".gitignore"); + return fse.remove(reposPath) + .then(function() { + assert.equal(false, fse.existsSync(reposPath)); + }); + }); + it("can get the index of a repo and examine entries", function() { var entries = this.index.entries(); diff --git a/test/tests/submodule.js b/test/tests/submodule.js index 9065e55ac..d500d52e2 100644 --- a/test/tests/submodule.js +++ b/test/tests/submodule.js @@ -159,7 +159,8 @@ describe("Submodule", function() { }); }); - it.only("make remove repo fail", function() { + // THIS TEST MAKES IT FAIL + it.skip("make remove repo fail 01", function() { this.timeout(30000); var repo = this.repository; @@ -211,14 +212,77 @@ describe("Submodule", function() { return fse.remove(repoPath); }) .then(function() { - assert.ok(true); + assert.equal(false, fse.existsSync(repoPath)); + }); + }); + + // THIS TEST MAKES IT FAIL + it.skip("make remove repo fail 02", function() { + this.timeout(30000); + + var repo = this.repository; + var submodulePath = "nodegittest"; + var submoduleUrl = "https://github.com/nodegit/test.git"; + + var submodule; + var submoduleRepo; + + return NodeGit.Submodule.addSetup(repo, submoduleUrl, submodulePath, 0) + .then(function(_submodule) { + submodule = _submodule; + + return submodule.init(0); + }) + .then(function() { + return submodule.open(); + }) + .then(function(_submoduleRepo) { + submoduleRepo = _submoduleRepo; + return submoduleRepo.fetch("origin", null, null); + }) + .then(function() { + return repo.refreshIndex(); + }) + .then(function(index) { + return fse.remove(repoPath); }) - .catch(function(error) { - assert.ok(error instanceof Error); - console.log(error.message); + .then(function() { + assert.equal(false, fse.existsSync(repoPath)); }); }); + // THIS TEST MAKES IT FAIL + it.only("make remove repo fail 03", function() { + this.timeout(30000); + + var repo = this.repository; + var submodulePath = "nodegittest"; + var submoduleUrl = "https://github.com/nodegit/test.git"; + + var submodule; + var submoduleRepo; + + return NodeGit.Submodule.addSetup(repo, submoduleUrl, submodulePath, 0) + .then(function(_submodule) { + submodule = _submodule; + + return submodule.init(0); + }) + .then(function() { + return submodule.open(); + }) + .then(function(_submoduleRepo) { + submoduleRepo = _submoduleRepo; + return submoduleRepo.fetch("origin", null, null); + }) + .then(function() { + return fse.remove(repoPath); + }) + .then(function() { + assert.equal(false, fse.existsSync(repoPath)); + }); + }); + it("can run sync callback without deadlocking", function() { var repo = this.workdirRepository; var submodules = [];