Skip to content

Commit 8e1e229

Browse files
authored
Wrap the arguments passed to test scalac task between " (#21322)
When running `scalac` in the sbt shell, the following task will invoke the compiler's main method and forward the arguments as a single string. If we do the following: ```sh sbt:scala3> scalac "test.scala" "-Wconf:msg=Given search preference:silent" ``` The compiiler will not correctly parse the provided arguments, resulting in the following behaviour: ```sh [info] running (fork) dotty.tools.dotc.Main -d <redacted>/scala3/compiler/../out/default-last-scalac-out.jar -classpath <redacted>/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.14/scala-library-2.13.14.jar:<redacted>/scala3/library/../out/bootstrap/scala3-library-bootstrapped/scala-3.6.0-RC1-bin-SNAPSHOT-nonbootstrapped/scala3-library_3-3.6.0-RC1-bin-SNAPSHOT.jar test.scala -Wconf:msg=Given search preference:silent source file not found: test.scala source file not found: search source file not found: preference:silent ``` This PR fixes the following discribed issue by wrapping each argument between `"` before calling the compiler's main method.
2 parents e90cf0d + b4dcf78 commit 8e1e229

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Diff for: project/Build.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,8 @@ object Build {
844844
extraClasspath ++= Seq(dottyCompiler, dottyInterfaces, asm, dottyStaging, dottyTastyInspector, tastyCore, compilerInterface)
845845
}
846846

847-
val fullArgs = main :: defaultOutputDirectory ::: (if (printTasty) args else insertClasspathInArgs(args, extraClasspath.mkString(File.pathSeparator)))
847+
val wrappedArgs = (if (printTasty) args else insertClasspathInArgs(args, extraClasspath.mkString(File.pathSeparator))).map(arg => "\""+ arg + "\"")
848+
val fullArgs = main :: defaultOutputDirectory ::: wrappedArgs
848849

849850
(Compile / runMain).toTask(fullArgs.mkString(" ", " ", ""))
850851
}.evaluated,

0 commit comments

Comments
 (0)