use separate ivy home directories in component provider test so tests can run concurrently

This commit is contained in:
Mark Harrah 2013-03-18 09:52:57 -04:00
parent 6327e11a59
commit e69df1ae9c
1 changed files with 19 additions and 9 deletions

View File

@ -50,16 +50,18 @@ object ComponentManagerTest extends Specification
} }
"properly cache a file and then retrieve it to an unresolved component" in { "properly cache a file and then retrieve it to an unresolved component" in {
withManager { definingManager => withTemporaryDirectory { ivyHome =>
val hash = defineFile(definingManager, TestID, "a") withManagerHome(ivyHome) { definingManager =>
try val hash = defineFile(definingManager, TestID, "a")
{ try
definingManager.cache(TestID) {
withManager { usingManager => definingManager.cache(TestID)
checksum(usingManager.file(TestID)(Fail)) must beEqualTo(hash) withManagerHome(ivyHome) { usingManager =>
checksum(usingManager.file(TestID)(Fail)) must beEqualTo(hash)
}
} }
finally { definingManager.clearCache(TestID) }
} }
finally { definingManager.clearCache(TestID) }
} }
} }
} }
@ -78,5 +80,13 @@ object ComponentManagerTest extends Specification
private def writeRandomContent(file: File) = IO.write(file, randomString) private def writeRandomContent(file: File) = IO.write(file, randomString)
private def randomString = "asdf" private def randomString = "asdf"
private def withManager[T](f: ComponentManager => T): T = private def withManager[T](f: ComponentManager => T): T =
TestLogger( logger => withTemporaryDirectory { temp => f(new ComponentManager(xsbt.boot.Locks, new xsbt.boot.ComponentProvider(temp, true), None, logger)) } ) withTemporaryDirectory { ivyHome => withManagerHome(ivyHome)(f) }
private def withManagerHome[T](ivyHome: File)(f: ComponentManager => T): T =
TestLogger { logger =>
withTemporaryDirectory { temp =>
val mgr = new ComponentManager(xsbt.boot.Locks, new xsbt.boot.ComponentProvider(temp, true), Some(ivyHome), logger)
f(mgr)
}
}
} }