aboutsummaryrefslogtreecommitdiff
path: root/test/test/CompilerTest.scala
diff options
context:
space:
mode:
authorvsalvis <salvisbergvera@gmail.com>2015-04-20 11:18:32 +0200
committervsalvis <salvisbergvera@gmail.com>2015-04-20 11:18:32 +0200
commitfb98e832439819b11649a878320d30938fc30abb (patch)
tree0f8237baa4c4f594c8efc788ac737fe5fb58aac2 /test/test/CompilerTest.scala
parent346ad4ff58f32397ec943353bf5ebe54aca5a3c8 (diff)
downloaddotty-fb98e832439819b11649a878320d30938fc30abb.tar.gz
dotty-fb98e832439819b11649a878320d30938fc30abb.tar.bz2
dotty-fb98e832439819b11649a878320d30938fc30abb.zip
Robuster FileLock test to prevent exception if fork in Test is ever disabled
Diffstat (limited to 'test/test/CompilerTest.scala')
-rw-r--r--test/test/CompilerTest.scala16
1 files changed, 11 insertions, 5 deletions
diff --git a/test/test/CompilerTest.scala b/test/test/CompilerTest.scala
index 1dd65b6e0..f404c79ba 100644
--- a/test/test/CompilerTest.scala
+++ b/test/test/CompilerTest.scala
@@ -42,11 +42,17 @@ abstract class CompilerTest extends DottyTest {
val generatePartestFiles = {
val partestLockFile = "." + JFile.separator + "tests" + JFile.separator + "partest.lock"
- val partestLock = new RandomAccessFile(partestLockFile, "rw").getChannel.tryLock
- if (partestLock != null) { // file not locked by sbt -> don't generate partest
- partestLock.release
- false
- } else true
+ try {
+ val partestLock = new RandomAccessFile(partestLockFile, "rw").getChannel.tryLock
+ if (partestLock != null) { // file not locked by sbt -> don't generate partest
+ partestLock.release
+ false
+ } else true
+ } catch {
+ // if sbt doesn't fork in Test, the tryLock request will throw instead of
+ // returning null, because locks are per JVM, not per thread
+ case ex: java.nio.channels.OverlappingFileLockException => true
+ }
}
// Delete generated files from previous run