From: Constantine Plotnikov <constantine.plotnikov@gmail.com>
To: git@vger.kernel.org
Cc: Constantine Plotnikov <constantine.plotnikov@gmail.com>
Subject: [JGIT PATCH] Fixed the test testUpdateRefLockFailureLocked broken on the Windows platform
Date: Tue, 23 Jun 2009 16:01:35 +0400 [thread overview]
Message-ID: <1245758495-2212-1-git-send-email-constantine.plotnikov@gmail.com> (raw)
On Windows the lock is aquired in the test testUpdateRefLockFailureLocked
(RefUpdateTest) for the file but it never released. This causes test
failure during resource cleanup, since locked file could not be deleted
on Windows. This commits adds unlock operation in the finally block,
so there is no more cleanup problem.
Signed-off-by: Constantine Plotnikov <constantine.plotnikov@gmail.com>
---
.../tst/org/spearce/jgit/lib/RefUpdateTest.java | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 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 6b1975a..b14f19a 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
@@ -255,12 +255,16 @@ public void testUpdateRefLockFailureLocked() throws IOException {
RefUpdate updateRef = db.updateRef("refs/heads/master");
updateRef.setNewObjectId(pid);
LockFile lockFile1 = new LockFile(new File(db.getDirectory(),"refs/heads/master"));
- assertTrue(lockFile1.lock()); // precondition to test
- Result update = updateRef.update();
- assertEquals(Result.LOCK_FAILURE, update);
- assertEquals(opid, db.resolve("refs/heads/master"));
- LockFile lockFile2 = new LockFile(new File(db.getDirectory(),"refs/heads/master"));
- assertFalse(lockFile2.lock()); // was locked, still is
+ try {
+ assertTrue(lockFile1.lock()); // precondition to test
+ Result update = updateRef.update();
+ assertEquals(Result.LOCK_FAILURE, update);
+ assertEquals(opid, db.resolve("refs/heads/master"));
+ LockFile lockFile2 = new LockFile(new File(db.getDirectory(),"refs/heads/master"));
+ assertFalse(lockFile2.lock()); // was locked, still is
+ } finally {
+ lockFile1.unlock();
+ }
}
/**
--
1.6.1.2
reply other threads:[~2009-06-23 12:08 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=1245758495-2212-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).