* [JGIT PATCH] Fixed the test testUpdateRefLockFailureLocked broken on the Windows platform
@ 2009-06-23 12:01 Constantine Plotnikov
0 siblings, 0 replies; only message in thread
From: Constantine Plotnikov @ 2009-06-23 12:01 UTC (permalink / raw)
To: git; +Cc: Constantine Plotnikov
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2009-06-23 12:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-23 12:01 [JGIT PATCH] Fixed the test testUpdateRefLockFailureLocked broken on the Windows platform Constantine Plotnikov
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).