diff options
-rw-r--r-- | project/Build.scala | 3 | ||||
-rw-r--r-- | test/test/CompilerTest.scala | 16 |
2 files changed, 13 insertions, 6 deletions
diff --git a/project/Build.scala b/project/Build.scala index 61a7e4826..4dd86fa01 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -1,7 +1,8 @@ import sbt.Keys._ import sbt._ import java.io.{ RandomAccessFile, File } -import java.nio.channels.{ FileLock, OverlappingFileLockException } +import java.nio.channels.FileLock + object DottyBuild extends Build { val TRAVIS_BUILD = "dotty.travis.build" 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 |