@@ -641,13 +641,13 @@ trait ParallelTesting extends RunnerOrchestration { self =>
641
641
}
642
642
643
643
reporter
644
-
644
+
645
645
protected def compileFromBestEffortTasty (flags0 : TestFlags , suppressErrors : Boolean , targetDir : JFile ): TestReporter = {
646
646
val classes = flattenFiles(targetDir).filter(isBestEffortTastyFile).map(_.toString)
647
647
val flags = flags0 and " -from-tasty" and " -Ywith-best-effort-tasty"
648
648
val reporter = mkReporter
649
649
val driver = new Driver
650
-
650
+
651
651
driver.process(flags.all ++ classes, reporter = reporter)
652
652
653
653
reporter
@@ -660,7 +660,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
660
660
println((flags.all ++ files0.map(_.toString) ++ Array (bestEffortDir.toString)).mkString(" " ))
661
661
662
662
val args = Array (" -classpath" , flags.defaultClassPath + " :" + bestEffortDir.toString) ++ flags.options
663
-
663
+
664
664
driver.process(args ++ files0.map(_.toString), reporter = reporter)
665
665
666
666
reporter
@@ -1271,20 +1271,6 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1271
1271
targetDir
1272
1272
}
1273
1273
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
-
1288
1274
/** Make sure that directory string is as expected */
1289
1275
private def checkRequirements (f : String , sourceDir : JFile , outDir : String ): Unit = {
1290
1276
require(sourceDir.isDirectory && sourceDir.exists, " passed non-directory to `compileFilesInDir`: " + sourceDir)
@@ -1487,16 +1473,16 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1487
1473
}
1488
1474
1489
1475
/** 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.
1494
1480
*/
1495
1481
def compileBestEffortTastyInDir (f : String , flags : TestFlags , picklingFilter : FileFilter , unpicklingFilter : FileFilter )(
1496
1482
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
+
1500
1486
val outDir = defaultOutputDir + testGroup + JFile .separator
1501
1487
val sourceDir = new JFile (f)
1502
1488
checkRequirements(f, sourceDir, outDir)
@@ -1510,15 +1496,14 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1510
1496
name : String ,
1511
1497
file : JFile ,
1512
1498
flags : TestFlags ,
1513
- bestEffortDir : JFile ,
1514
1499
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) {
1516
1501
override def buildInstructions (errors : Int , warnings : Int ): String = {
1517
1502
s """ |
1518
1503
|Test ' $title' compiled with a compiler crash,
1519
1504
|the test can be reproduced by running:
1520
1505
|
1521
- | sbt "scalac -Ybest-effort-dir $bestEffortDir $file"
1506
+ | sbt "scalac -Ybest-effort $file"
1522
1507
|
1523
1508
|These tests can be disabled by adding ` ${file.getName}` to `compiler ${JFile .separator}test ${JFile .separator}dotc ${JFile .separator}neg-best-effort-pickling.blacklist`
1524
1509
| """ .stripMargin
@@ -1533,7 +1518,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1533
1518
) extends JointCompilationSource (name, Array (file), flags, bestEffortDir, fromTasty = FromBestEffortTasty ) {
1534
1519
1535
1520
override def buildInstructions (errors : Int , warnings : Int ): String = {
1536
- def beTastyFiles (file : JFile ): Array [JFile ] =
1521
+ def beTastyFiles (file : JFile ): Array [JFile ] =
1537
1522
file.listFiles.flatMap { innerFile =>
1538
1523
if (innerFile.isDirectory) beTastyFiles(innerFile)
1539
1524
else if (isBestEffortTastyFile(innerFile)) Array (innerFile)
@@ -1544,7 +1529,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1544
1529
|Test ' $title' compiled with a compiler crash,
1545
1530
|the test can be reproduced by running:
1546
1531
|
1547
- | sbt "scalac -Ybest-effort-dir $bestEffortDir $file"
1532
+ | sbt "scalac -Ybest-effort $file"
1548
1533
| sbt "scalac --from-tasty -Ywith-best-effort-tasty $beTastyFilesString"
1549
1534
|
1550
1535
|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 =>
1553
1538
}
1554
1539
}
1555
1540
1556
- val (bestEffortTargets, bestEffortDirs ) =
1541
+ val (bestEffortTargets, targetAndBestEffortDirs ) =
1557
1542
filteredPicklingFiles.map { f =>
1558
- val bestEffortDir = createBestEffortDirForFile(f, sourceDir, outDir)
1559
1543
val outputDir = createOutputDirsForFile(f, sourceDir, outDir)
1544
+ val bestEffortDir = new JFile (outputDir, s " META-INF ${JFile .separator}best-effort " )
1560
1545
(
1561
- BestEffortCompilation (testGroup.name, f, flags, bestEffortDir, outputDir),
1562
- bestEffortDir
1546
+ BestEffortCompilation (testGroup.name, f, flags, outputDir),
1547
+ (f, bestEffortDir)
1563
1548
)
1564
1549
}.unzip
1550
+ val (_, bestEffortDirs) = targetAndBestEffortDirs.unzip
1551
+ val fileToBestEffortDirMap = targetAndBestEffortDirs.toMap
1565
1552
1566
1553
val picklingSet = filteredPicklingFiles.toSet
1567
1554
val fromTastyTargets =
1568
1555
filteredUnpicklingFiles.filter(picklingSet.contains(_)).map { f =>
1569
- val bestEffortDir = createBestEffortDirForFile(f, sourceDir, outDir )
1556
+ val bestEffortDir = fileToBestEffortDirMap(f )
1570
1557
new JointCompilationSourceFromBestEffortTasty (testGroup.name, f, flags, bestEffortDir)
1571
1558
}
1572
1559
@@ -1579,13 +1566,13 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1579
1566
}
1580
1567
1581
1568
/** 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
1584
1571
* 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.
1586
1573
* Then, are the contents of 'main' are compiled with the previous best effort directory
1587
1574
* on the classpath using the option `-Ywith-best-effort-tasty`.
1588
- *
1575
+ *
1589
1576
*/
1590
1577
def compileBestEffortIntegration (f : String , flags : TestFlags )(implicit testGroup : TestGroup ) = {
1591
1578
val sourceDir = new JFile (f)
@@ -1599,24 +1586,23 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1599
1586
val step1SourceFiles = step1SourceDir.listFiles
1600
1587
val step2SourceFiles = step2SourceDir.listFiles
1601
1588
1602
- val outDir = defaultOutputDir + testGroup + JFile .separator
1589
+ val outDir = defaultOutputDir + testGroup + JFile .separator + dir.getName().toString + JFile .separator
1603
1590
1604
1591
val step1OutDir = createOutputDirsForDir(step1SourceDir, step1SourceDir, outDir)
1605
1592
val step2OutDir = createOutputDirsForDir(step2SourceDir, step2SourceDir, outDir)
1606
1593
1607
- val bestEffortDir = createBestEffortDirForDir(dir, sourceDir, outDir)
1608
-
1609
1594
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
1611
1596
)
1597
+
1598
+ val bestEffortDir = new JFile (step1OutDir, s " META-INF ${JFile .separator}best-effort " )
1599
+
1612
1600
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)
1614
1602
)
1615
1603
(step1Compilation, step2Compilation, bestEffortDir)
1616
1604
}.unzip3
1617
- println(step1Targets)
1618
- println(step2Targets)
1619
-
1605
+
1620
1606
BestEffortCompilationTest (
1621
1607
new CompilationTest (step1Targets).keepOutput,
1622
1608
new CompilationTest (step2Targets).keepOutput,
@@ -1653,7 +1639,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1653
1639
}
1654
1640
1655
1641
class BestEffortCompilationTest (step1 : CompilationTest , step2 : CompilationTest , bestEffortDirs : List [JFile ], shouldDelete : Boolean )(implicit testGroup : TestGroup ) {
1656
-
1642
+
1657
1643
def checkNoCrash ()(implicit summaryReport : SummaryReporting ): this .type = {
1658
1644
step1.checkNoCrash() // Compile all files to generate the class files with best effort tasty
1659
1645
step2.checkNoCrash() // Compile with best effort tasty
@@ -1717,7 +1703,7 @@ object ParallelTesting {
1717
1703
1718
1704
def isTastyFile (f : JFile ): Boolean =
1719
1705
f.getName.endsWith(" .tasty" )
1720
-
1706
+
1721
1707
def isBestEffortTastyFile (f : JFile ): Boolean =
1722
1708
f.getName.endsWith(" .betasty" )
1723
1709
0 commit comments