Skip to content

Commit 162867f

Browse files
committed
Shorten code with TestGroups
1 parent e465f26 commit 162867f

File tree

4 files changed

+21
-17
lines changed

4 files changed

+21
-17
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,9 @@ class CompilationTests extends ParallelTesting {
247247

248248
val opt = TestFlags(
249249
// compile with bootstrapped library on cp:
250-
defaultOutputDir + libGroup.name + "/src/:" +
250+
defaultOutputDir + libGroup + "/src/:" +
251251
// as well as bootstrapped compiler:
252-
defaultOutputDir + dotty1Group.name + "/dotty/:" +
252+
defaultOutputDir + dotty1Group + "/dotty/:" +
253253
Jars.dottyInterfaces,
254254
Array("-Ycheck-reentrant")
255255
)
@@ -297,9 +297,9 @@ class CompilationTests extends ParallelTesting {
297297
}.keepOutput :: Nil
298298
}.map(_.checkCompile())
299299

300-
assert(new java.io.File(s"../out/${dotty1Group.name}/dotty/").exists)
301-
assert(new java.io.File(s"../out/${dotty2Group.name}/dotty/").exists)
302-
assert(new java.io.File(s"../out/${libGroup.name}/src/").exists)
300+
assert(new java.io.File(s"../out/$dotty1Group/dotty/").exists)
301+
assert(new java.io.File(s"../out/$dotty2Group/dotty/").exists)
302+
assert(new java.io.File(s"../out/$libGroup/src/").exists)
303303
compileList("idempotency", List("../tests/idempotency/BootstrapChecker.scala", "../tests/idempotency/IdempotencyCheck.scala"), defaultOptions).checkRuns()
304304

305305
tests.foreach(_.delete())

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ class LinkOptimiseTests extends ParallelTesting {
2929
@Test def linkOptimise: Unit = {
3030
// Setup and compile libraries
3131
val strawmanLibGroup = TestGroup("strawmanLibrary")
32-
val strawmanLibTestGroup = TestGroup(strawmanLibGroup.name + "/tests")
32+
val strawmanLibTestGroup = TestGroup(strawmanLibGroup + "/tests")
3333

3434
val linkCustomLibGroup = TestGroup("linkCustomLib")
35-
val linkCustomLibTestGroup = TestGroup(linkCustomLibGroup.name + "/tests")
35+
val linkCustomLibTestGroup = TestGroup(linkCustomLibGroup + "/tests")
3636

3737
val strawmanLibrary = compileDir("../collection-strawman/collections/src/main", defaultOptions)(strawmanLibGroup)
3838
val linkCustomLib = compileDir("../tests/link/custom-lib", defaultOptions)(linkCustomLibGroup)
@@ -45,8 +45,8 @@ class LinkOptimiseTests extends ParallelTesting {
4545
// Setup class paths
4646
def mkLinkClassFlags(libPath: String) =
4747
TestFlags(mkClassPath(libPath :: Jars.dottyTestDeps), mkClassPath(Jars.dottyTestDeps), basicDefaultOptions :+ "-Xlink-optimise")
48-
val strawmanClassPath = mkLinkClassFlags(defaultOutputDir + strawmanLibGroup.name + "/main/")
49-
val customLibClassFlags = mkLinkClassFlags(defaultOutputDir + linkCustomLibGroup.name + "/custom-lib")
48+
val strawmanClassPath = mkLinkClassFlags(defaultOutputDir + strawmanLibGroup + "/main/")
49+
val customLibClassFlags = mkLinkClassFlags(defaultOutputDir + linkCustomLibGroup + "/custom-lib")
5050

5151
// Link tests
5252
val linkDir = "../tests/link"

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
10381038
val sourceFile = new JFile(f)
10391039
val parent = sourceFile.getParentFile
10401040
val outDir =
1041-
outDirectory + testGroup.name + "/" +
1041+
outDirectory + testGroup + "/" +
10421042
sourceFile.getName.substring(0, sourceFile.getName.lastIndexOf('.')) + "/"
10431043

10441044
require(
@@ -1064,7 +1064,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
10641064
* can be used for randomization.
10651065
*/
10661066
def compileDir(f: String, flags: TestFlags, randomOrder: Option[Int] = None, outDirectory: String = defaultOutputDir)(implicit testGroup: TestGroup): CompilationTest = {
1067-
val outDir = outDirectory + testGroup.name + "/"
1067+
val outDir = outDirectory + testGroup + "/"
10681068
val sourceDir = new JFile(f)
10691069
checkRequirements(f, sourceDir, outDir)
10701070

@@ -1083,7 +1083,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
10831083
val targetDir = new JFile(outDir + "/" + sourceDir.getName + "/")
10841084
targetDir.mkdirs()
10851085

1086-
val target = JointCompilationSource(s"compiling '$f' in test '${testGroup.name}'", randomized, flags, targetDir)
1086+
val target = JointCompilationSource(s"compiling '$f' in test '$testGroup'", randomized, flags, targetDir)
10871087
new CompilationTest(target)
10881088
}
10891089

@@ -1092,14 +1092,14 @@ trait ParallelTesting extends RunnerOrchestration { self =>
10921092
* dissociated
10931093
*/
10941094
def compileList(testName: String, files: List[String], flags: TestFlags, outDirectory: String = defaultOutputDir)(implicit testGroup: TestGroup): CompilationTest = {
1095-
val outDir = outDirectory + testGroup.name + "/" + testName + "/"
1095+
val outDir = outDirectory + testGroup + "/" + testName + "/"
10961096

10971097
// Directories in which to compile all containing files with `flags`:
10981098
val targetDir = new JFile(outDir)
10991099
targetDir.mkdirs()
11001100
assert(targetDir.exists, s"couldn't create target directory: $targetDir")
11011101

1102-
val target = JointCompilationSource(s"$testName from ${testGroup.name}", files.map(new JFile(_)).toArray, flags, targetDir)
1102+
val target = JointCompilationSource(s"$testName from $testGroup", files.map(new JFile(_)).toArray, flags, targetDir)
11031103

11041104
// Create a CompilationTest and let the user decide whether to execute a pos or a neg test
11051105
new CompilationTest(target)
@@ -1123,7 +1123,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
11231123
* the same name as the directory (with the file extension `.check`)
11241124
*/
11251125
def compileFilesInDir(f: String, flags: TestFlags, outDirectory: String = defaultOutputDir)(implicit testGroup: TestGroup): CompilationTest = {
1126-
val outDir = outDirectory + testGroup.name + "/"
1126+
val outDir = outDirectory + testGroup + "/"
11271127
val sourceDir = new JFile(f)
11281128
checkRequirements(f, sourceDir, outDir)
11291129

@@ -1142,7 +1142,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
11421142
* tests.
11431143
*/
11441144
def compileShallowFilesInDir(f: String, flags: TestFlags, outDirectory: String = defaultOutputDir)(implicit testGroup: TestGroup): CompilationTest = {
1145-
val outDir = outDirectory + testGroup.name + "/"
1145+
val outDir = outDirectory + testGroup + "/"
11461146
val sourceDir = new JFile(f)
11471147
checkRequirements(f, sourceDir, outDir)
11481148

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package dotty.tools.vulpix
22

3-
case class TestGroup(name: String) extends AnyVal {
3+
class TestGroup(val name: String) extends AnyVal {
44
override def toString: String = name
55
}
6+
7+
object TestGroup {
8+
def apply(name: String): TestGroup = new TestGroup(name)
9+
}

0 commit comments

Comments
 (0)