Skip to content

Commit ec50c12

Browse files
committed
Revert "Add clear separation between flags and classpath in tests"
This reverts commit 1ce86d4.
1 parent 1ce86d4 commit ec50c12

File tree

8 files changed

+75
-62
lines changed

8 files changed

+75
-62
lines changed

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ class ScalaSettings extends Settings.SettingGroup {
102102
val YcheckAllPatmat = BooleanSetting("-Ycheck-all-patmat", "Check exhaustivity and redundancy of all pattern matching (used for testing the algorithm)")
103103
val YretainTrees = BooleanSetting("-Yretain-trees", "Retain trees for top-level classes, accessible from ClassSymbol#tree")
104104
val YshowTreeIds = BooleanSetting("-Yshow-tree-ids", "Uniquely tag all tree nodes in debugging output.")
105+
val YRunClasspath = PathSetting("-YRunClasspath", "Specify where to find user class files while executing run tests.", defaultClasspath)
105106

106107
/** Area-specific debug output */
107108
val Yexplainlowlevel = BooleanSetting("-Yexplain-lowlevel", "When explaining type errors, show types at a lower level.")

compiler/test/dotc/comptest.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package dotc
22

3-
import dotty.tools.vulpix.{ParallelTesting, TestFlags}
3+
import dotty.tools.vulpix.ParallelTesting
44

55
import scala.concurrent.duration._
66

@@ -26,6 +26,9 @@ object comptest extends ParallelTesting {
2626
dotcDir + "tools/dotc/core/Types.scala",
2727
dotcDir + "tools/dotc/ast/Trees.scala"
2828
),
29-
TestFlags("", Array("-Ylog:frontend", "-Xprompt"))
29+
Array(
30+
"-Ylog:frontend",
31+
"-Xprompt"
32+
)
3033
)
3134
}

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import java.util.stream.{ Stream => JStream }
1010
import scala.collection.JavaConverters._
1111
import scala.util.matching.Regex
1212
import scala.concurrent.duration._
13-
import vulpix._
13+
14+
import vulpix.{ ParallelTesting, SummaryReport, SummaryReporting, TestConfiguration }
1415
import dotty.tools.io.JFile
1516

1617

@@ -40,7 +41,7 @@ class CompilationTests extends ParallelTesting {
4041
compileDir("../compiler/src/dotty/tools/dotc/typer", defaultOptions) +
4142
compileDir("../compiler/src/dotty/tools/dotc/util", defaultOptions) +
4243
compileDir("../compiler/src/dotty/tools/io", defaultOptions) +
43-
compileDir("../compiler/src/dotty/tools/dotc/core", TestFlags(classPath, noCheckOptions)) +
44+
compileDir("../compiler/src/dotty/tools/dotc/core", noCheckOptions ++ classPath) +
4445
compileFile("../tests/pos/nullarify.scala", defaultOptions.and("-Ycheck:nullarify")) +
4546
compileFile("../tests/pos-scala2/rewrites.scala", scala2Mode.and("-rewrite")).copyToTarget() +
4647
compileFile("../tests/pos-special/t8146a.scala", allowDeepSubtypes) +
@@ -222,13 +223,14 @@ class CompilationTests extends ParallelTesting {
222223
* version of Dotty
223224
*/
224225
@Test def tastyBootstrap: Unit = {
225-
val opt = TestFlags(
226+
val opt = Array(
227+
"-classpath",
226228
// compile with bootstrapped library on cp:
227229
defaultOutputDir + "lib/src/:" +
228230
// as well as bootstrapped compiler:
229231
defaultOutputDir + "dotty1/dotty/:" +
230232
Jars.dottyInterfaces,
231-
Array("-Ycheck-reentrant")
233+
"-Ycheck-reentrant"
232234
)
233235

234236
def lib =

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import java.nio.file.{Files, Path, Paths}
77

88
import org.junit.{AfterClass, Test}
99
import org.junit.Assert._
10-
import vulpix._
10+
import vulpix.{ParallelTesting, SummaryReport, SummaryReporting, TestConfiguration}
1111

1212
import scala.concurrent.duration._
1313
import scala.collection.JavaConverters._
@@ -38,17 +38,17 @@ class LinkOptimiseTests extends ParallelTesting {
3838
}.keepOutput.checkCompile()
3939

4040
// Setup class paths
41-
def mkLinkClassFlags(libPath: String) =
42-
TestFlags(mkClassPath(libPath :: Jars.dottyTestDeps), mkClassPath(Jars.dottyTestDeps), basicDefaultOptions :+ "-Xlink-optimise")
43-
val strawmanClassPath = mkLinkClassFlags(defaultOutputDir + "strawmanLibrary/main/")
44-
val customLibClassFlags = mkLinkClassFlags(defaultOutputDir + "linkCustomLib/custom-lib")
41+
def mkLinkClassPath(libPath: String) =
42+
mkClassPath(libPath :: Jars.dottyTestDeps) ++ mkClassPath(Jars.dottyTestDeps, "-YRunClasspath")
43+
val strawmanClassPath = mkLinkClassPath(defaultOutputDir + "strawmanLibrary/main/")
44+
val customLibClassPath = mkLinkClassPath(defaultOutputDir + "linkCustomLib/custom-lib")
4545

4646
// Link tests
4747
val linkDir = "../tests/link"
4848
val linkStramanDir = linkDir + "/strawman"
4949
val linkCustomLibDir = linkDir + "/on-custom-lib"
50-
def linkStrawmanTest = compileFilesInDir(linkStramanDir, strawmanClassPath)
51-
def linkCustomLibTest = compileFilesInDir(linkCustomLibDir, customLibClassFlags)
50+
def linkStrawmanTest = compileFilesInDir(linkStramanDir, basicLinkOptimise ++ strawmanClassPath)
51+
def linkCustomLibTest = compileFilesInDir(linkCustomLibDir, basicLinkOptimise ++ customLibClassPath)
5252

5353
def classFileChecks(sourceDir: String, testName: String) = {
5454
val checkExt = ".classcheck"

compiler/test/dotty/tools/dotc/transform/PatmatExhaustivityTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import vulpix.TestConfiguration
1414
class PatmatExhaustivityTest {
1515
val testsDir = "../tests/patmat"
1616
// stop-after: patmatexhaust-huge.scala crash compiler
17-
val options = List("-color:never", "-Ystop-after:splitter", "-Ycheck-all-patmat", "-classpath", TestConfiguration.classPath)
17+
val options = List("-color:never", "-Ystop-after:splitter", "-Ycheck-all-patmat") ++ TestConfiguration.classPath
1818

1919
private def compileFile(file: File) = {
2020
val stringBuffer = new StringWriter()

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

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,25 @@ trait ParallelTesting extends RunnerOrchestration { self =>
5050
private sealed trait TestSource { self =>
5151
def name: String
5252
def outDir: JFile
53-
def flags: TestFlags
53+
def flags: Array[String]
54+
55+
def classPath: String =
56+
outDir.getAbsolutePath +
57+
flags
58+
.dropWhile(_ != "-classpath")
59+
.drop(1)
60+
.headOption
61+
.map(":" + _)
62+
.getOrElse("")
5463

55-
def runClassPath: String = outDir.getAbsolutePath + ":" + flags.runClassPath
64+
def runClassPath = {
65+
flags
66+
.dropWhile(_ != "-YRunClasspath")
67+
.drop(1)
68+
.headOption
69+
.map(outDir.getAbsolutePath + ":" + _)
70+
.getOrElse(classPath)
71+
}
5672

5773
def title: String = self match {
5874
case self: JointCompilationSource =>
@@ -66,11 +82,11 @@ trait ParallelTesting extends RunnerOrchestration { self =>
6682
/** Adds the flags specified in `newFlags0` if they do not already exist */
6783
def withFlags(newFlags0: String*) = {
6884
val newFlags = newFlags0.toArray
69-
if (!flags.options.containsSlice(newFlags)) self match {
85+
if (!flags.containsSlice(newFlags)) self match {
7086
case self: JointCompilationSource =>
71-
self.copy(flags = flags.and(newFlags:_*))
87+
self.copy(flags = flags ++ newFlags)
7288
case self: SeparateCompilationSource =>
73-
self.copy(flags = flags.and(newFlags:_*))
89+
self.copy(flags = flags ++ newFlags)
7490
}
7591
else self
7692
}
@@ -87,7 +103,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
87103
|the test can be reproduced by running:""".stripMargin
88104
)
89105
sb.append("\n\n./bin/dotc ")
90-
flags.all.foreach { arg =>
106+
flags.foreach { arg =>
91107
if (lineLen > maxLen) {
92108
sb.append(" \\\n ")
93109
lineLen = 4
@@ -131,7 +147,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
131147
private final case class JointCompilationSource(
132148
name: String,
133149
files: Array[JFile],
134-
flags: TestFlags,
150+
flags: Array[String],
135151
outDir: JFile
136152
) extends TestSource {
137153
def sourceFiles: Array[JFile] = files.filter(isSourceFile)
@@ -145,7 +161,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
145161
private final case class SeparateCompilationSource(
146162
name: String,
147163
dir: JFile,
148-
flags: TestFlags,
164+
flags: Array[String],
149165
outDir: JFile
150166
) extends TestSource {
151167

@@ -326,9 +342,9 @@ trait ParallelTesting extends RunnerOrchestration { self =>
326342
}
327343
}
328344

329-
protected def compile(files0: Array[JFile], flags0: TestFlags, suppressErrors: Boolean, targetDir: JFile): TestReporter = {
345+
protected def compile(files0: Array[JFile], flags0: Array[String], suppressErrors: Boolean, targetDir: JFile): TestReporter = {
330346

331-
val flags = flags0 and ("-d", targetDir.getAbsolutePath)
347+
val flags = flags0 ++ Array("-d", targetDir.getAbsolutePath)
332348

333349
def flattenFiles(f: JFile): Array[JFile] =
334350
if (f.isDirectory) f.listFiles.flatMap(flattenFiles)
@@ -351,7 +367,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
351367
"-encoding", "UTF-8",
352368
"-classpath",
353369
s".:${Jars.scalaLibrary}:${targetDir.getAbsolutePath}"
354-
) ++ flags.all.takeRight(2) ++ fs
370+
) ++ flags.takeRight(2) ++ fs
355371

356372
val process = Runtime.getRuntime.exec(fullArgs)
357373
val output = Source.fromInputStream(process.getErrorStream).mkString
@@ -379,7 +395,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
379395
}
380396
}
381397

382-
val allArgs = addOutDir(flags.all)
398+
val allArgs = addOutDir(flags)
383399

384400
// Compile with a try to catch any StackTrace generated by the compiler:
385401
try {
@@ -1057,7 +1073,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
10571073
}
10581074

10591075
/** Compiles a single file from the string path `f` using the supplied flags */
1060-
def compileFile(f: String, flags: TestFlags)(implicit outDirectory: String): CompilationTest = {
1076+
def compileFile(f: String, flags: Array[String])(implicit outDirectory: String): CompilationTest = {
10611077
val callingMethod = getCallingMethod()
10621078
val sourceFile = new JFile(f)
10631079
val parent = sourceFile.getParentFile
@@ -1087,7 +1103,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
10871103
* By default, files are compiled in alphabetical order. An optional seed
10881104
* can be used for randomization.
10891105
*/
1090-
def compileDir(f: String, flags: TestFlags, randomOrder: Option[Int] = None)(implicit outDirectory: String): CompilationTest = {
1106+
def compileDir(f: String, flags: Array[String], randomOrder: Option[Int] = None)(implicit outDirectory: String): CompilationTest = {
10911107
val callingMethod = getCallingMethod()
10921108
val outDir = outDirectory + callingMethod + "/"
10931109
val sourceDir = new JFile(f)
@@ -1116,7 +1132,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
11161132
* `testName` since files can be in separate directories and or be otherwise
11171133
* dissociated
11181134
*/
1119-
def compileList(testName: String, files: List[String], flags: TestFlags, callingMethod: String = getCallingMethod())(implicit outDirectory: String): CompilationTest = {
1135+
def compileList(testName: String, files: List[String], flags: Array[String], callingMethod: String = getCallingMethod())(implicit outDirectory: String): CompilationTest = {
11201136
val outDir = outDirectory + callingMethod + "/" + testName + "/"
11211137

11221138
// Directories in which to compile all containing files with `flags`:
@@ -1147,7 +1163,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
11471163
* - Directories can have an associated check-file, where the check file has
11481164
* the same name as the directory (with the file extension `.check`)
11491165
*/
1150-
def compileFilesInDir(f: String, flags: TestFlags)(implicit outDirectory: String): CompilationTest = {
1166+
def compileFilesInDir(f: String, flags: Array[String])(implicit outDirectory: String): CompilationTest = {
11511167
val callingMethod = getCallingMethod()
11521168
val outDir = outDirectory + callingMethod + "/"
11531169
val sourceDir = new JFile(f)
@@ -1167,7 +1183,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
11671183
* sub-directories and as such, does **not** perform separate compilation
11681184
* tests.
11691185
*/
1170-
def compileShallowFilesInDir(f: String, flags: TestFlags)(implicit outDirectory: String): CompilationTest = {
1186+
def compileShallowFilesInDir(f: String, flags: Array[String])(implicit outDirectory: String): CompilationTest = {
11711187
val callingMethod = getCallingMethod()
11721188
val outDir = outDirectory + callingMethod + "/"
11731189
val sourceDir = new JFile(f)

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

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ package vulpix
55
object TestConfiguration {
66
implicit val defaultOutputDir: String = "../out/"
77

8+
implicit class RichStringArray(val xs: Array[String]) extends AnyVal {
9+
def and(args: String*): Array[String] = {
10+
val argsArr: Array[String] = args.toArray
11+
xs ++ argsArr
12+
}
13+
}
14+
815
val noCheckOptions = Array(
916
"-pagewidth", "120",
1017
"-color:never"
@@ -18,8 +25,8 @@ object TestConfiguration {
1825

1926
val classPath = mkClassPath(Jars.dottyTestDeps)
2027

21-
def mkClassPath(classPaths: List[String]): String = {
22-
classPaths map { p =>
28+
def mkClassPath(classPaths: List[String], classPathFlag: String = "-classpath"): Array[String] = {
29+
val paths = classPaths map { p =>
2330
val file = new java.io.File(p)
2431
assert(
2532
file.exists,
@@ -40,23 +47,26 @@ object TestConfiguration {
4047
|it in extras."""
4148
)
4249
file.getAbsolutePath
43-
} mkString(":")
50+
} mkString (":")
51+
52+
Array(classPathFlag, paths)
4453
}
4554

4655
private val yCheckOptions = Array("-Ycheck:tailrec,resolveSuper,erasure,mixin,getClass,restoreScopes,labelDef")
4756

48-
val basicDefaultOptions = checkOptions ++ noCheckOptions ++ yCheckOptions
49-
val defaultUnoptimised = TestFlags(classPath, basicDefaultOptions)
50-
val defaultOptimised = defaultUnoptimised and "-optimise"
57+
val basicDefaultOptions = noCheckOptions ++ checkOptions ++ yCheckOptions
58+
val defaultUnoptimised = basicDefaultOptions ++ classPath
59+
val defaultOptimised = defaultUnoptimised :+ "-optimise"
5160
val defaultOptions = defaultUnoptimised
52-
val allowDeepSubtypes = defaultOptions without "-Yno-deep-subtypes"
53-
val allowDoubleBindings = defaultOptions without "-Yno-double-bindings"
54-
val picklingOptions = defaultUnoptimised and (
61+
val allowDeepSubtypes = defaultOptions diff Array("-Yno-deep-subtypes")
62+
val allowDoubleBindings = defaultOptions diff Array("-Yno-double-bindings")
63+
val picklingOptions = defaultUnoptimised ++ Array(
5564
"-Xprint-types",
5665
"-Ytest-pickler",
5766
"-Yprintpos"
5867
)
59-
val scala2Mode = defaultOptions and "-language:Scala2"
60-
val explicitUTF8 = defaultOptions and ("-encoding", "UTF8")
61-
val explicitUTF16 = defaultOptions and ("-encoding", "UTF16")
68+
val scala2Mode = defaultOptions ++ Array("-language:Scala2")
69+
val explicitUTF8 = defaultOptions ++ Array("-encoding", "UTF8")
70+
val explicitUTF16 = defaultOptions ++ Array("-encoding", "UTF16")
71+
val basicLinkOptimise = basicDefaultOptions ++ Array("-Xlink-optimise")
6272
}

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

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)