@@ -641,13 +641,13 @@ trait ParallelTesting extends RunnerOrchestration { self =>
641641 }
642642
643643 reporter
644-
644+
645645 protected def compileFromBestEffortTasty (flags0 : TestFlags , suppressErrors : Boolean , targetDir : JFile ): TestReporter = {
646646 val classes = flattenFiles(targetDir).filter(isBestEffortTastyFile).map(_.toString)
647647 val flags = flags0 and " -from-tasty" and " -Ywith-best-effort-tasty"
648648 val reporter = mkReporter
649649 val driver = new Driver
650-
650+
651651 driver.process(flags.all ++ classes, reporter = reporter)
652652
653653 reporter
@@ -660,7 +660,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
660660 println((flags.all ++ files0.map(_.toString) ++ Array (bestEffortDir.toString)).mkString(" " ))
661661
662662 val args = Array (" -classpath" , flags.defaultClassPath + " :" + bestEffortDir.toString) ++ flags.options
663-
663+
664664 driver.process(args ++ files0.map(_.toString), reporter = reporter)
665665
666666 reporter
@@ -1271,20 +1271,6 @@ trait ParallelTesting extends RunnerOrchestration { self =>
12711271 targetDir
12721272 }
12731273
1274- private def createBestEffortDirForDir (d : JFile , sourceDir : JFile , outDir : String ): JFile = {
1275- val uniqueSubdir = s " ${d.getName}-best-effort "
1276- val bestEffortDir = new JFile (outDir + s " ${sourceDir.getName}${JFile .separatorChar}$uniqueSubdir" )
1277- bestEffortDir.mkdirs()
1278- bestEffortDir
1279- }
1280-
1281- private def createBestEffortDirForFile (file : JFile , sourceDir : JFile , outDir : String ): JFile = {
1282- val uniqueSubdir = s " ${file.getName.substring(0 , file.getName.lastIndexOf('.' ))}-best-effort "
1283- val bestEffortDir = new JFile (outDir + s " ${sourceDir.getName}${JFile .separatorChar}$uniqueSubdir" )
1284- bestEffortDir.mkdirs()
1285- bestEffortDir
1286- }
1287-
12881274 /** Make sure that directory string is as expected */
12891275 private def checkRequirements (f : String , sourceDir : JFile , outDir : String ): Unit = {
12901276 require(sourceDir.isDirectory && sourceDir.exists, " passed non-directory to `compileFilesInDir`: " + sourceDir)
@@ -1487,16 +1473,16 @@ trait ParallelTesting extends RunnerOrchestration { self =>
14871473 }
14881474
14891475 /** A two step compilation test for best effort compilation pickling and unpickling.
1490- *
1491- * First, erroring neg test files are compiled with the `-Ybest-effort-dir ` option
1492- * to a best effort directory. If successful, then the produced Best Effort TASTy is
1493- * re-compiled with '-Ywith-best-effort-tasty' to test the TastyReader for Best Effort TASTy.
1476+ *
1477+ * First, erroring neg test files are compiled with the `-Ybest-effort` option.
1478+ * If successful, then the produced Best Effort TASTy is re-compiled with
1479+ * '-Ywith-best-effort-tasty' to test the TastyReader for Best Effort TASTy.
14941480 */
14951481 def compileBestEffortTastyInDir (f : String , flags : TestFlags , picklingFilter : FileFilter , unpicklingFilter : FileFilter )(
14961482 implicit testGroup : TestGroup ): BestEffortCompilationTest = {
1497- val bestEffortFlag = " -Ybest-effort-dir "
1498- assert(! flags.options.contains(bestEffortFlag), " Best effort directory should not be added manually" )
1499-
1483+ val bestEffortFlag = " -Ybest-effort"
1484+ assert(! flags.options.contains(bestEffortFlag), " Best effort compilation flag should not be added manually" )
1485+
15001486 val outDir = defaultOutputDir + testGroup + JFile .separator
15011487 val sourceDir = new JFile (f)
15021488 checkRequirements(f, sourceDir, outDir)
@@ -1510,15 +1496,14 @@ trait ParallelTesting extends RunnerOrchestration { self =>
15101496 name : String ,
15111497 file : JFile ,
15121498 flags : TestFlags ,
1513- bestEffortDir : JFile ,
15141499 outputDir : JFile
1515- ) extends JointCompilationSource (name, Array (file), flags.and(bestEffortFlag).and(bestEffortDir.toString) , outputDir) {
1500+ ) extends JointCompilationSource (name, Array (file), flags.and(bestEffortFlag), outputDir) {
15161501 override def buildInstructions (errors : Int , warnings : Int ): String = {
15171502 s """ |
15181503 |Test ' $title' compiled with a compiler crash,
15191504 |the test can be reproduced by running:
15201505 |
1521- | sbt "scalac -Ybest-effort-dir $bestEffortDir $file"
1506+ | sbt "scalac -Ybest-effort $file"
15221507 |
15231508 |These tests can be disabled by adding ` ${file.getName}` to `compiler ${JFile .separator}test ${JFile .separator}dotc ${JFile .separator}neg-best-effort-pickling.blacklist`
15241509 | """ .stripMargin
@@ -1533,7 +1518,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
15331518 ) extends JointCompilationSource (name, Array (file), flags, bestEffortDir, fromTasty = FromBestEffortTasty ) {
15341519
15351520 override def buildInstructions (errors : Int , warnings : Int ): String = {
1536- def beTastyFiles (file : JFile ): Array [JFile ] =
1521+ def beTastyFiles (file : JFile ): Array [JFile ] =
15371522 file.listFiles.flatMap { innerFile =>
15381523 if (innerFile.isDirectory) beTastyFiles(innerFile)
15391524 else if (isBestEffortTastyFile(innerFile)) Array (innerFile)
@@ -1544,7 +1529,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
15441529 |Test ' $title' compiled with a compiler crash,
15451530 |the test can be reproduced by running:
15461531 |
1547- | sbt "scalac -Ybest-effort-dir $bestEffortDir $file"
1532+ | sbt "scalac -Ybest-effort $file"
15481533 | sbt "scalac --from-tasty -Ywith-best-effort-tasty $beTastyFilesString"
15491534 |
15501535 |These tests can be disabled by adding ` ${file.getName}` to `compiler ${JFile .separator}test ${JFile .separator}dotc ${JFile .separator}neg-best-effort-unpickling.blacklist`
@@ -1553,20 +1538,22 @@ trait ParallelTesting extends RunnerOrchestration { self =>
15531538 }
15541539 }
15551540
1556- val (bestEffortTargets, bestEffortDirs ) =
1541+ val (bestEffortTargets, targetAndBestEffortDirs ) =
15571542 filteredPicklingFiles.map { f =>
1558- val bestEffortDir = createBestEffortDirForFile(f, sourceDir, outDir)
15591543 val outputDir = createOutputDirsForFile(f, sourceDir, outDir)
1544+ val bestEffortDir = new JFile (outputDir, s " META-INF ${JFile .separator}best-effort " )
15601545 (
1561- BestEffortCompilation (testGroup.name, f, flags, bestEffortDir, outputDir),
1562- bestEffortDir
1546+ BestEffortCompilation (testGroup.name, f, flags, outputDir),
1547+ (f, bestEffortDir)
15631548 )
15641549 }.unzip
1550+ val (_, bestEffortDirs) = targetAndBestEffortDirs.unzip
1551+ val fileToBestEffortDirMap = targetAndBestEffortDirs.toMap
15651552
15661553 val picklingSet = filteredPicklingFiles.toSet
15671554 val fromTastyTargets =
15681555 filteredUnpicklingFiles.filter(picklingSet.contains(_)).map { f =>
1569- val bestEffortDir = createBestEffortDirForFile(f, sourceDir, outDir )
1556+ val bestEffortDir = fileToBestEffortDirMap(f )
15701557 new JointCompilationSourceFromBestEffortTasty (testGroup.name, f, flags, bestEffortDir)
15711558 }
15721559
@@ -1579,13 +1566,13 @@ trait ParallelTesting extends RunnerOrchestration { self =>
15791566 }
15801567
15811568 /** A two step integration test for best effort compilation.
1582- *
1583- * Directories found in the directory `f` represent separate tests and must contain
1569+ *
1570+ * Directories found in the directory `f` represent separate tests and must contain
15841571 * the 'err' and 'main' directories. First the (erroring) contents of the 'err'
1585- * directory are compiled with the `Ybest-effort-dir ` option with a best effort directory .
1572+ * directory are compiled with the `Ybest-effort` option.
15861573 * Then, are the contents of 'main' are compiled with the previous best effort directory
15871574 * on the classpath using the option `-Ywith-best-effort-tasty`.
1588- *
1575+ *
15891576 */
15901577 def compileBestEffortIntegration (f : String , flags : TestFlags )(implicit testGroup : TestGroup ) = {
15911578 val sourceDir = new JFile (f)
@@ -1599,24 +1586,23 @@ trait ParallelTesting extends RunnerOrchestration { self =>
15991586 val step1SourceFiles = step1SourceDir.listFiles
16001587 val step2SourceFiles = step2SourceDir.listFiles
16011588
1602- val outDir = defaultOutputDir + testGroup + JFile .separator
1589+ val outDir = defaultOutputDir + testGroup + JFile .separator + dir.getName().toString + JFile .separator
16031590
16041591 val step1OutDir = createOutputDirsForDir(step1SourceDir, step1SourceDir, outDir)
16051592 val step2OutDir = createOutputDirsForDir(step2SourceDir, step2SourceDir, outDir)
16061593
1607- val bestEffortDir = createBestEffortDirForDir(dir, sourceDir, outDir)
1608-
16091594 val step1Compilation = JointCompilationSource (
1610- testGroup.name, step1SourceFiles, flags.and(" -Ybest-effort-dir " ).and(bestEffortDir.toString ), step1OutDir, fromTasty = NotFromTasty
1595+ testGroup.name, step1SourceFiles, flags.and(" -Ybest-effort" ), step1OutDir, fromTasty = NotFromTasty
16111596 )
1597+
1598+ val bestEffortDir = new JFile (step1OutDir, s " META-INF ${JFile .separator}best-effort " )
1599+
16121600 val step2Compilation = JointCompilationSource (
1613- testGroup.name, step2SourceFiles, flags.and(" -Ywith-best-effort-tasty" ), step1OutDir , fromTasty = WithBestEffortTasty (bestEffortDir)
1601+ testGroup.name, step2SourceFiles, flags.and(" -Ywith-best-effort-tasty" ), step2OutDir , fromTasty = WithBestEffortTasty (bestEffortDir)
16141602 )
16151603 (step1Compilation, step2Compilation, bestEffortDir)
16161604 }.unzip3
1617- println(step1Targets)
1618- println(step2Targets)
1619-
1605+
16201606 BestEffortCompilationTest (
16211607 new CompilationTest (step1Targets).keepOutput,
16221608 new CompilationTest (step2Targets).keepOutput,
@@ -1653,7 +1639,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
16531639 }
16541640
16551641 class BestEffortCompilationTest (step1 : CompilationTest , step2 : CompilationTest , bestEffortDirs : List [JFile ], shouldDelete : Boolean )(implicit testGroup : TestGroup ) {
1656-
1642+
16571643 def checkNoCrash ()(implicit summaryReport : SummaryReporting ): this .type = {
16581644 step1.checkNoCrash() // Compile all files to generate the class files with best effort tasty
16591645 step2.checkNoCrash() // Compile with best effort tasty
@@ -1717,7 +1703,7 @@ object ParallelTesting {
17171703
17181704 def isTastyFile (f : JFile ): Boolean =
17191705 f.getName.endsWith(" .tasty" )
1720-
1706+
17211707 def isBestEffortTastyFile (f : JFile ): Boolean =
17221708 f.getName.endsWith(" .betasty" )
17231709
0 commit comments