From: Constantine Plotnikov <constantine.plotnikov@gmail.com>
To: git@vger.kernel.org
Cc: Constantine Plotnikov <constantine.plotnikov@gmail.com>
Subject: [JGIT PATCH] Fixed RefUpdateTest.tryRenameWhenLocked() family of tests
Date: Thu, 25 Jun 2009 17:38:07 +0400 [thread overview]
Message-ID: <1245937087-5144-1-git-send-email-constantine.plotnikov@gmail.com> (raw)
If file is left locked after the test, the cleanup does
not work on Windows since locked files cannot be deleted.
The patch adds unlock for the aquired lock, so the cleanup
now works.
Signed-off-by: Constantine Plotnikov <constantine.plotnikov@gmail.com>
---
This is a second time the problem occurs. Please release all locks
that are being acquired, otherwise the tests will fail on Windows.
.../tst/org/spearce/jgit/lib/RefUpdateTest.java | 51 +++++++++++---------
1 files changed, 28 insertions(+), 23 deletions(-)
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RefUpdateTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RefUpdateTest.java
index 83eb4ed..ec00fac 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RefUpdateTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RefUpdateTest.java
@@ -463,29 +463,34 @@ assertTrue("internal check, we have a log", new File(db.getDirectory(),
"logs/" + fromName).exists());
// "someone" has branch X locked
- assertTrue(new LockFile(new File(db.getDirectory(), toLock)).lock());
-
- // Now this is our test
- RefRename renameRef = db.renameRef(fromName, toName);
- Result result = renameRef.rename();
- assertEquals(Result.LOCK_FAILURE, result);
-
- // Check that the involved refs are the same despite the failure
- assertExists(false, toName);
- if (!toLock.equals(toName))
- assertExists(false, toName + ".lock");
- assertExists(true, toLock + ".lock");
- if (!toLock.equals(fromName))
- assertExists(false, "logs/" + fromName + ".lock");
- assertExists(false, "logs/" + toName + ".lock");
- assertEquals(oldHeadId, db.resolve(Constants.HEAD));
- assertEquals(oldfromId, db.resolve(fromName));
- assertNull(db.resolve(toName));
- assertEquals(oldFromLog.toString(), db.getReflogReader(fromName)
- .getReverseEntries().toString());
- if (oldHeadId != null)
- assertEquals(oldHeadLog, db.getReflogReader(Constants.HEAD)
- .getReverseEntries());
+ LockFile lockFile = new LockFile(new File(db.getDirectory(), toLock));
+ try {
+ assertTrue(lockFile.lock());
+
+ // Now this is our test
+ RefRename renameRef = db.renameRef(fromName, toName);
+ Result result = renameRef.rename();
+ assertEquals(Result.LOCK_FAILURE, result);
+
+ // Check that the involved refs are the same despite the failure
+ assertExists(false, toName);
+ if (!toLock.equals(toName))
+ assertExists(false, toName + ".lock");
+ assertExists(true, toLock + ".lock");
+ if (!toLock.equals(fromName))
+ assertExists(false, "logs/" + fromName + ".lock");
+ assertExists(false, "logs/" + toName + ".lock");
+ assertEquals(oldHeadId, db.resolve(Constants.HEAD));
+ assertEquals(oldfromId, db.resolve(fromName));
+ assertNull(db.resolve(toName));
+ assertEquals(oldFromLog.toString(), db.getReflogReader(fromName)
+ .getReverseEntries().toString());
+ if (oldHeadId != null)
+ assertEquals(oldHeadLog, db.getReflogReader(Constants.HEAD)
+ .getReverseEntries());
+ } finally {
+ lockFile.unlock();
+ }
}
private void assertExists(boolean positive, String toName) {
--
1.6.1.2
reply other threads:[~2009-06-25 13:38 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1245937087-5144-1-git-send-email-constantine.plotnikov@gmail.com \
--to=constantine.plotnikov@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).