@@ -64,20 +64,30 @@ object DottyBuild extends Build {
6464 // enable verbose exception messages for JUnit
6565 testOptions in Test += Tests .Argument (TestFrameworks .JUnit , " -a" , " -v" , " --run-listener=test.ContextEscapeDetector" ),
6666 testOptions in Test += Tests .Cleanup ({ () => if (partestLock != null ) partestLock.release }),
67- // when this file is locked, running test generates the files for partest
68- // otherwise it just executes the tests directly
67+ // When this file is locked, running test generates the files for partest.
68+ // Otherwise it just executes the tests directly. So running two separate
69+ // sbt instances might result in unexpected behavior if one does partest
70+ // and the other test, since the second still sees the locked file and thus
71+ // generates partest files instead of running JUnit tests, but doesn't
72+ // partest them.
6973 lockPartestFile := {
7074 val partestLockFile = " ." + File .separator + " tests" + File .separator + " partest.lock"
7175 try {
7276 partestLock = new RandomAccessFile (partestLockFile, " rw" ).getChannel.tryLock
77+ if (partestLock == null )
78+ throw new RuntimeException (" ERROR: sbt partest: file is locked already. Bad things happen when trying to mix test/partest in two concurrent sbt instances." )
7379 } catch {
74- case ex : java.nio.channels.OverlappingFileLockException => // locked already
80+ case ex : java.nio.channels.OverlappingFileLockException => // locked already, Tests.Cleanup didn't run
81+ if (partestLock != null )
82+ partestLock.release
83+ throw new RuntimeException (" ERROR: sbt partest: file was still locked, please try again or restart sbt." )
7584 }
7685 },
7786 runPartestRunner <<= Def .taskDyn {
7887 val jars = Seq ((packageBin in Compile ).value.getAbsolutePath) ++
7988 getJarPaths(partestDeps.value, ivyPaths.value.ivyHome)
8089 val dottyJars = " -dottyJars " + jars.length + " " + jars.mkString(" " )
90+ // Provide the jars required on the classpath of run tests
8191 runTask(Test , " dotty.partest.DPConsoleRunner" , dottyJars)
8292 },
8393
0 commit comments