@@ -64,20 +64,30 @@ object DottyBuild extends Build {
64
64
// enable verbose exception messages for JUnit
65
65
testOptions in Test += Tests .Argument (TestFrameworks .JUnit , " -a" , " -v" , " --run-listener=test.ContextEscapeDetector" ),
66
66
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.
69
73
lockPartestFile := {
70
74
val partestLockFile = " ." + File .separator + " tests" + File .separator + " partest.lock"
71
75
try {
72
76
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." )
73
79
} 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." )
75
84
}
76
85
},
77
86
runPartestRunner <<= Def .taskDyn {
78
87
val jars = Seq ((packageBin in Compile ).value.getAbsolutePath) ++
79
88
getJarPaths(partestDeps.value, ivyPaths.value.ivyHome)
80
89
val dottyJars = " -dottyJars " + jars.length + " " + jars.mkString(" " )
90
+ // Provide the jars required on the classpath of run tests
81
91
runTask(Test , " dotty.partest.DPConsoleRunner" , dottyJars)
82
92
},
83
93
0 commit comments