Skip to content

Commit a1c39ef

Browse files
committed
Add using directive to vulpix for javac options
1 parent 7f410aa commit a1c39ef

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

compiler/test/dotty/tools/utils.scala

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,14 @@ def toolArgsFor(tool: ToolName, filename: Option[String])(lines: List[String]):
8181
// groups are (name, args)
8282
// note: ideally we would replace everything that requires this to use directive syntax, however scalajs: --skip has no directive equivalent yet.
8383
private val toolArg = raw"(?://|/\*| \*) ?(?i:(${ToolName.values.mkString("|")})):((?:[^*]|\*(?!/))*)".r.unanchored
84+
85+
// ================================================================================================
86+
// =================================== VULPIX DIRECTIVES ==========================================
87+
// ================================================================================================
88+
89+
/** Directive to specify to vulpix the options to pass to Dotty */
8490
private val directiveOptionsArg = raw"//> using options (.*)".r.unanchored
91+
private val directiveJavacOptions = raw"//> using javacOpt (.*)".r.unanchored
8592

8693
// Inspect the lines for compiler options of the form
8794
// `//> using options args`, `// scalajs: args`, `/* scalajs: args`, ` * scalajs: args` etc.
@@ -90,10 +97,15 @@ private val directiveOptionsArg = raw"//> using options (.*)".r.unanchored
9097
def toolArgsParse(lines: List[String], filename: Option[String]): List[(String,String)] =
9198
lines.flatMap {
9299
case toolArg("scalac", _) => sys.error(s"`// scalac: args` not supported. Please use `//> using options args`${filename.fold("")(f => s" in file $f")}")
100+
case toolArg("javac", _) => sys.error(s"`// javac: args` not supported. Please use `//> using javacOpt args`${filename.fold("")(f => s" in file $f")}")
93101
case toolArg(name, args) => List((name, args))
94102
case _ => Nil
95103
} ++
96-
lines.flatMap { case directiveOptionsArg(args) => List(("scalac", args)) case _ => Nil }
104+
lines.flatMap {
105+
case directiveOptionsArg(args) => List(("scalac", args))
106+
case directiveJavacOptions(args) => List(("javac", args))
107+
case _ => Nil
108+
}
97109

98110
import org.junit.Test
99111
import org.junit.Assert._

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
498498
case None => true
499499

500500
def scalacOptions = toolArgs.getOrElse(ToolName.Scalac, Nil)
501+
def javacOptions = toolArgs.getOrElse(ToolName.Javac, Nil)
501502

502503
val flags = flags0
503504
.and(scalacOptions*)
@@ -512,11 +513,10 @@ trait ParallelTesting extends RunnerOrchestration { self =>
512513

513514
def compileWithJavac(fs: Array[String]) = if (fs.nonEmpty) {
514515
val fullArgs = Array(
515-
"javac",
516516
"-encoding", StandardCharsets.UTF_8.name,
517-
) ++ flags.javacFlags ++ fs
517+
) ++ flags.javacFlags ++ javacOptions++ fs
518518

519-
val process = Runtime.getRuntime.exec(fullArgs)
519+
val process = Runtime.getRuntime.exec("javac" +: fullArgs)
520520
val output = Source.fromInputStream(process.getErrorStream).mkString
521521

522522
if waitForJudiciously(process) != 0 then Some(output)

0 commit comments

Comments
 (0)