Skip to content

Commit a6a0804

Browse files
committed
tests: Read tool args in test files
1 parent 5567729 commit a6a0804

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,15 +441,17 @@ trait ParallelTesting extends RunnerOrchestration { self =>
441441
throw e
442442

443443
protected def compile(files0: Array[JFile], flags0: TestFlags, suppressErrors: Boolean, targetDir: JFile): TestReporter = {
444-
val flags = flags0.and("-d", targetDir.getPath)
445-
.withClasspath(targetDir.getPath)
446-
447444
def flattenFiles(f: JFile): Array[JFile] =
448445
if (f.isDirectory) f.listFiles.flatMap(flattenFiles)
449446
else Array(f)
450447

451448
val files: Array[JFile] = files0.flatMap(flattenFiles)
452449

450+
val flags = flags0
451+
.and(toolArgsFor(files.toList.map(_.toPath))(using getCodecFromEncodingOpt(flags0)): _*)
452+
.and("-d", targetDir.getPath)
453+
.withClasspath(targetDir.getPath)
454+
453455
def compileWithJavac(fs: Array[String]) = if (fs.nonEmpty) {
454456
val fullArgs = Array(
455457
"javac",
@@ -1358,6 +1360,11 @@ trait ParallelTesting extends RunnerOrchestration { self =>
13581360
// Create a CompilationTest and let the user decide whether to execute a pos or a neg test
13591361
new CompilationTest(targets)
13601362
}
1363+
1364+
private def getCodecFromEncodingOpt(flags: TestFlags) =
1365+
flags.options.sliding(2).collectFirst {
1366+
case Array("-encoding", encoding) => scala.io.Codec(encoding)
1367+
}.getOrElse(scala.io.Codec.UTF8)
13611368
}
13621369

13631370
object ParallelTesting {

tests/neg/literals.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ trait RejectedLiterals {
22
def missingHex: Int = { 0x } // error: invalid literal number
33
}
44
/*
5-
// scalac: -Ywarn-octal-literal -Xfatal-warnings -deprecation
5+
// nsc: -Ywarn-octal-literal -Xfatal-warnings -deprecation
66
trait RejectedLiterals {
77
88
def missingHex: Int = { 0x } // line 4: was: not reported, taken as zero

tests/run/1938-2.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
object ProdNonEmpty {
22
def _1: Int = 0
3-
def _2: String = "???" // Slight variation with scalac: this test passes
3+
def _2: String = "???" // Slight variation with nsc: this test passes
44
// with ??? here. I think dotty behavior is fine
55
// according to the spec given that methods involved
66
// in pattern matching should be pure.

0 commit comments

Comments
 (0)