@@ -162,7 +162,7 @@ trait ParallelTesting extends RunnerOrchestration with CoverageSupport:
162162
163163 final override def toString : String = sourceFiles match {
164164 case Array (f) => f.getPath
165- case _ => outDir.getPath.stripPrefix(defaultOutputDir ).stripPrefix(name).stripPrefix(" /" )
165+ case _ => outDir.getPath.stripPrefix(defaultOutputDirName ).stripPrefix(name).stripPrefix(" /" )
166166 }
167167 }
168168
@@ -507,11 +507,16 @@ trait ParallelTesting extends RunnerOrchestration with CoverageSupport:
507507 def scalacOptions = toolArgs.getOrElse(ToolName .Scalac , Nil )
508508 def javacOptions = toolArgs.getOrElse(ToolName .Javac , Nil )
509509
510- val flags = flags0
510+ var flags = flags0
511511 .and(scalacOptions* )
512512 .and(" -d" , targetDir.getPath)
513513 .withClasspath(targetDir.getPath)
514514
515+ // We must set -sourceroot for SemanticDB extraction to work properly inside an IDE,
516+ // but we have many existing coverage tests that assume it is not set, so as a workaround:
517+ if ! flags.all.contains(" -coverage-out" ) then
518+ flags = flags.and(" -sourceroot" , TestSources .rootPath().toAbsolutePath.toString)
519+
515520 def compileWithJavac (fs : Array [String ]) = if (fs.nonEmpty) {
516521 val fullArgs = Array (
517522 " -encoding" , StandardCharsets .UTF_8 .name,
@@ -1409,24 +1414,23 @@ trait ParallelTesting extends RunnerOrchestration with CoverageSupport:
14091414 end CompilationTest
14101415
14111416 /** Create out directory for directory `d` */
1412- def createOutputDirsForDir (d : JFile , sourceDir : JFile , outDir : String ): JFile = {
1413- val targetDir = new JFile (outDir + s " ${sourceDir.getName}/ ${d.getName}" )
1417+ def createOutputDirsForDir (d : JFile , sourceDir : JFile , outDir : JFile ): JFile = {
1418+ val targetDir = new JFile (outDir, s " ${sourceDir.getName}/ ${d.getName}" )
14141419 targetDir.mkdirs()
14151420 targetDir
14161421 }
14171422
14181423 /** Create out directory for `file` */
1419- private def createOutputDirsForFile (file : JFile , sourceDir : JFile , outDir : String ): JFile = {
1424+ private def createOutputDirsForFile (file : JFile , sourceDir : JFile , outDir : JFile ): JFile = {
14201425 val uniqueSubdir = file.getName.substring(0 , file.getName.lastIndexOf('.' ))
1421- val targetDir = new JFile (outDir + s " ${sourceDir.getName}${JFile .separatorChar}$uniqueSubdir" )
1426+ val targetDir = new JFile (outDir, s " ${sourceDir.getName}${JFile .separatorChar}$uniqueSubdir" )
14221427 targetDir.mkdirs()
14231428 targetDir
14241429 }
14251430
14261431 /** Make sure that directory string is as expected */
1427- private def checkRequirements (f : String , sourceDir : JFile , outDir : String ): Unit = {
1432+ private def checkRequirements (f : String , sourceDir : JFile , outDir : JFile ): Unit = {
14281433 require(sourceDir.isDirectory && sourceDir.exists, " passed non-directory to `compileFilesInDir`: " + sourceDir)
1429- require(outDir.last == JFile .separatorChar, " please specify an `outDir` with a trailing file separator" )
14301434 }
14311435
14321436 /** Separates directories from files and returns them as `(dirs, files)` */
@@ -1440,11 +1444,10 @@ trait ParallelTesting extends RunnerOrchestration with CoverageSupport:
14401444
14411445 /** Compiles a single file from the string path `f` using the supplied flags */
14421446 def compileFile (f : String , flags : TestFlags )(implicit testGroup : TestGroup ): CompilationTest = {
1443- val sourceFile = new JFile (f)
1447+ val sourceFile = TestSources .getPath (f).toFile
14441448 val parent = sourceFile.getParentFile
14451449 val outDir =
1446- defaultOutputDir + testGroup + JFile .separator +
1447- sourceFile.getName.substring(0 , sourceFile.getName.lastIndexOf('.' )) + JFile .separator
1450+ new JFile (new JFile (defaultOutputDir, testGroup.name), sourceFile.getName.substring(0 , sourceFile.getName.lastIndexOf('.' )))
14481451
14491452 require(
14501453 sourceFile.exists && ! sourceFile.isDirectory &&
@@ -1469,8 +1472,8 @@ trait ParallelTesting extends RunnerOrchestration with CoverageSupport:
14691472 * can be used for randomization.
14701473 */
14711474 def compileDir (f : String , flags : TestFlags , randomOrder : Option [Int ] = None , recursive : Boolean = true )(using testGroup : TestGroup ): CompilationTest = {
1472- val outDir = defaultOutputDir + testGroup + JFile .separator
1473- val sourceDir = new JFile (f)
1475+ val outDir = new JFile ( defaultOutputDir, testGroup.name)
1476+ val sourceDir = TestSources .getPath (f).toFile
14741477 checkRequirements(f, sourceDir, outDir)
14751478
14761479 def flatten (f : JFile ): Array [JFile ] =
@@ -1488,7 +1491,7 @@ trait ParallelTesting extends RunnerOrchestration with CoverageSupport:
14881491 }
14891492
14901493 // Directories in which to compile all containing files with `flags`:
1491- val targetDir = new JFile (outDir + JFile .separator + sourceDir.getName + JFile .separator )
1494+ val targetDir = new JFile (outDir, sourceDir.getName)
14921495 targetDir.mkdirs()
14931496
14941497 val target = JointCompilationSource (s " compiling ' $f' in test ' $testGroup' " , randomized, flags, targetDir)
@@ -1500,10 +1503,8 @@ trait ParallelTesting extends RunnerOrchestration with CoverageSupport:
15001503 * dissociated
15011504 */
15021505 def compileList (testName : String , files : List [String ], flags : TestFlags )(implicit testGroup : TestGroup ): CompilationTest = {
1503- val outDir = defaultOutputDir + testGroup + JFile .separator + testName + JFile .separator
1504-
15051506 // Directories in which to compile all containing files with `flags`:
1506- val targetDir = new JFile (outDir )
1507+ val targetDir = new JFile (new JFile (defaultOutputDir, testGroup.name), testName )
15071508 targetDir.mkdirs()
15081509 assert(targetDir.exists, s " couldn't create target directory: $targetDir" )
15091510
@@ -1531,8 +1532,8 @@ trait ParallelTesting extends RunnerOrchestration with CoverageSupport:
15311532 * the same name as the directory (with the file extension `.check`)
15321533 */
15331534 def compileFilesInDir (f : String , flags : TestFlags , fileFilter : FileFilter = FileFilter .NoFilter )(implicit testGroup : TestGroup ): CompilationTest = {
1534- val outDir = defaultOutputDir + testGroup + JFile .separator
1535- val sourceDir = new JFile (f)
1535+ val outDir = new JFile ( defaultOutputDir, testGroup.name)
1536+ val sourceDir = TestSources .getPath (f).toFile
15361537 checkRequirements(f, sourceDir, outDir)
15371538
15381539 val (dirs, files) = compilationTargets(sourceDir, fileFilter)
@@ -1571,9 +1572,8 @@ trait ParallelTesting extends RunnerOrchestration with CoverageSupport:
15711572 * Tests in the first part of the tuple must be executed before the second.
15721573 * Both testsRequires explicit delete().
15731574 */
1574- def compileTastyInDir (f : String , flags0 : TestFlags , fromTastyFilter : FileFilter )(
1575- implicit testGroup : TestGroup ): TastyCompilationTest = {
1576- val outDir = defaultOutputDir + testGroup + JFile .separator
1575+ def compileTastyInDir (f : String , flags0 : TestFlags , fromTastyFilter : FileFilter )(implicit testGroup : TestGroup ): TastyCompilationTest = {
1576+ val outDir = new JFile (defaultOutputDir, testGroup.name)
15771577 val flags = flags0 `and` " -Yretain-trees"
15781578 val sourceDir = new JFile (f)
15791579 checkRequirements(f, sourceDir, outDir)
@@ -1636,7 +1636,7 @@ trait ParallelTesting extends RunnerOrchestration with CoverageSupport:
16361636 val semanticDbFlag = " -Xsemanticdb"
16371637 assert(! flags.options.contains(bestEffortFlag), " Best effort compilation flag should not be added manually" )
16381638
1639- val outDir = defaultOutputDir + testGroup + JFile .separator
1639+ val outDir = new JFile ( defaultOutputDir, testGroup.name)
16401640 val sourceDir = new JFile (f)
16411641 checkRequirements(f, sourceDir, outDir)
16421642
@@ -1739,7 +1739,7 @@ trait ParallelTesting extends RunnerOrchestration with CoverageSupport:
17391739 val step1SourceFiles = step1SourceDir.listFiles
17401740 val step2SourceFiles = step2SourceDir.listFiles
17411741
1742- val outDir = defaultOutputDir + testGroup + JFile .separator + dir.getName().toString + JFile .separator
1742+ val outDir = new JFile ( new JFile (defaultOutputDir, testGroup.name), dir.getName)
17431743
17441744 val step1OutDir = createOutputDirsForDir(step1SourceDir, step1SourceDir, outDir)
17451745 val step2OutDir = createOutputDirsForDir(step2SourceDir, step2SourceDir, outDir)
@@ -1825,7 +1825,7 @@ trait ParallelTesting extends RunnerOrchestration with CoverageSupport:
18251825 * tests.
18261826 */
18271827 def compileShallowFilesInDir (f : String , flags : TestFlags )(implicit testGroup : TestGroup ): CompilationTest = {
1828- val outDir = defaultOutputDir + testGroup + JFile .separator
1828+ val outDir = new JFile ( defaultOutputDir, testGroup.name)
18291829 val sourceDir = new JFile (f)
18301830 checkRequirements(f, sourceDir, outDir)
18311831
@@ -1851,7 +1851,8 @@ trait ParallelTesting extends RunnerOrchestration with CoverageSupport:
18511851
18521852object ParallelTesting :
18531853
1854- def defaultOutputDir : String = " out" + JFile .separator
1854+ def defaultOutputDirName : String = " out" + JFile .separator
1855+ def defaultOutputDir : JFile = TestSources .getPath(defaultOutputDirName).toFile
18551856
18561857 def isSourceFile (f : JFile ): Boolean = {
18571858 val name = f.getName
0 commit comments