Skip to content

Commit bcfc2b7

Browse files
committed
Create TastyCompilationTest
1 parent 8bfc4ec commit bcfc2b7

File tree

2 files changed

+54
-39
lines changed

2 files changed

+54
-39
lines changed

compiler/test/dotty/tools/dotc/FromTastyTests.scala

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class FromTastyTests extends ParallelTesting {
2626
// > dotc -Ythrough-tasty -Ycheck:all <source>
2727

2828
implicit val testGroup: TestGroup = TestGroup("posTestFromTasty")
29-
val (step1, step2, step3, decompilationDir) = compileTastyInDir("tests/pos", defaultOptions,
29+
compileTastyInDir("tests/pos", defaultOptions,
3030
blacklist = Set(
3131
// Wrong number of arguments (only on bootstrapped)
3232
"i3130b.scala",
@@ -36,20 +36,11 @@ class FromTastyTests extends ParallelTesting {
3636

3737
// MatchError in SymDenotation.sourceModule on a ThisType
3838
"t3612.scala",
39-
)
40-
)
41-
step1.checkCompile() // Compile all files to generate the class files with tasty
42-
step2.checkCompile() // Compile from tasty
43-
step3.checkCompile() // Decompile from tasty
44-
45-
val step4 = compileFilesInDir(decompilationDir, defaultOptions,
46-
blacklist = Set(
39+
),
40+
recompilationBlacklist = Set(
4741
"simpleCaseObject"
4842
)
49-
).keepOutput
50-
step4.checkCompile() // Recompile decompiled code
51-
52-
(step1 + step2 + step3 + step4).delete()
43+
).checkCompile()
5344
}
5445

5546
@Test def runTestFromTasty: Unit = {
@@ -59,25 +50,13 @@ class FromTastyTests extends ParallelTesting {
5950
// > dotr Test
6051

6152
implicit val testGroup: TestGroup = TestGroup("runTestFromTasty")
62-
val (step1, step2, step3, decompilationDir) = compileTastyInDir("tests/run", defaultOptions,
53+
compileTastyInDir("tests/run", defaultOptions,
6354
blacklist = Set(
6455
// Closure type miss match
6556
"eff-dependent.scala",
66-
)
67-
)
68-
step1.checkCompile() // Compile all files to generate the class files with tasty
69-
step2.checkRuns() // Compile from tasty and run the result
70-
step3.checkCompile() // Decompile from tasty
71-
72-
val step4 = compileFilesInDir(decompilationDir, defaultOptions, blacklist = Set()).keepOutput
73-
step4.checkRuns() // Recompile and run decompiled code
74-
75-
(step1 + step2 + step3 + step4).delete()
76-
}
77-
78-
private implicit class tastyCompilationTuples(tup: (CompilationTest, CompilationTest)) {
79-
def +(that: (CompilationTest, CompilationTest)): (CompilationTest, CompilationTest) =
80-
(tup._1 + that._1, tup._2 + that._2)
57+
),
58+
recompilationBlacklist = Set()
59+
).checkRuns()
8160
}
8261
}
8362

compiler/test/dotty/tools/vulpix/ParallelTesting.scala

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@ package dotty
22
package tools
33
package vulpix
44

5-
import java.io.{ File => JFile }
5+
import java.io.{File => JFile}
66
import java.text.SimpleDateFormat
77
import java.util.HashMap
88
import java.nio.file.StandardCopyOption.REPLACE_EXISTING
9-
import java.nio.file.{ Files, Path, Paths, NoSuchFileException }
10-
import java.util.concurrent.{ Executors => JExecutors, TimeUnit, TimeoutException }
9+
import java.nio.file.{Files, NoSuchFileException, Path, Paths}
10+
import java.util.concurrent.{TimeUnit, TimeoutException, Executors => JExecutors}
1111

1212
import scala.io.Source
1313
import scala.util.control.NonFatal
1414
import scala.util.Try
1515
import scala.collection.mutable
1616
import scala.util.matching.Regex
1717
import scala.util.Random
18-
1918
import dotc.core.Contexts._
20-
import dotc.reporting.{ Reporter, TestReporter }
19+
import dotc.reporting.{Reporter, TestReporter}
2120
import dotc.reporting.diagnostic.MessageContainer
2221
import dotc.interfaces.Diagnostic.ERROR
2322
import dotc.util.DiffUtil
24-
import dotc.{ Driver, Compiler }
23+
import dotc.{Compiler, Driver}
2524
import dotc.decompiler
25+
import dotty.tools.vulpix.TestConfiguration.defaultOptions
2626

2727
/** A parallel testing suite whose goal is to integrate nicely with JUnit
2828
*
@@ -1258,8 +1258,8 @@ trait ParallelTesting extends RunnerOrchestration { self =>
12581258
* Tests in the first part of the tuple must be executed before the second.
12591259
* Both testsRequires explicit delete().
12601260
*/
1261-
def compileTastyInDir(f: String, flags0: TestFlags, blacklist: Set[String])(
1262-
implicit testGroup: TestGroup): (CompilationTest, CompilationTest, CompilationTest, String) = {
1261+
def compileTastyInDir(f: String, flags0: TestFlags, blacklist: Set[String], recompilationBlacklist: Set[String])(
1262+
implicit testGroup: TestGroup): TastyCompilationTest = {
12631263
val outDir = defaultOutputDir + testGroup + "/"
12641264
val flags = flags0 and "-Yretain-trees"
12651265
val sourceDir = new JFile(f)
@@ -1287,14 +1287,50 @@ trait ParallelTesting extends RunnerOrchestration { self =>
12871287

12881288
val decompilationDir = outDir + sourceDir.getName + "_decompiled"
12891289

1290-
(
1290+
new TastyCompilationTest(
12911291
generateClassFiles.keepOutput,
12921292
new CompilationTest(targets).keepOutput,
12931293
new CompilationTest(targets2).keepOutput,
1294-
decompilationDir
1294+
recompilationBlacklist,
1295+
decompilationDir,
1296+
shouldDelete = true
12951297
)
12961298
}
12971299

1300+
class TastyCompilationTest(step1: CompilationTest, step2: CompilationTest, step3: CompilationTest,
1301+
recompilationBlacklist: Set[String], decompilationDir: String, shouldDelete: Boolean)(implicit testGroup: TestGroup) {
1302+
1303+
def keepOutput: TastyCompilationTest =
1304+
new TastyCompilationTest(step1, step2, step3, recompilationBlacklist, decompilationDir, shouldDelete)
1305+
1306+
def checkCompile()(implicit summaryReport: SummaryReporting): this.type = {
1307+
step1.checkCompile() // Compile all files to generate the class files with tasty
1308+
step2.checkCompile() // Compile from tasty
1309+
step3.checkCompile() // Decompile from tasty
1310+
1311+
val step4 = compileFilesInDir(decompilationDir, defaultOptions, recompilationBlacklist).keepOutput
1312+
step4.checkCompile() // Recompile decompiled code
1313+
1314+
if (shouldDelete)
1315+
(step1 + step2 + step3 + step4).delete()
1316+
1317+
this
1318+
}
1319+
1320+
def checkRuns()(implicit summaryReport: SummaryReporting): this.type = {
1321+
step1.checkCompile() // Compile all files to generate the class files with tasty
1322+
step2.checkRuns() // Compile from tasty
1323+
step3.checkCompile() // Decompile from tasty
1324+
1325+
val step4 = compileFilesInDir(decompilationDir, defaultOptions, recompilationBlacklist).keepOutput
1326+
step4.checkRuns() // Recompile decompiled code
1327+
1328+
if (shouldDelete)
1329+
(step1 + step2 + step3 + step4).delete()
1330+
1331+
this
1332+
}
1333+
}
12981334

12991335
/** This function behaves similar to `compileFilesInDir` but it ignores
13001336
* sub-directories and as such, does **not** perform separate compilation

0 commit comments

Comments
 (0)