Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10164 from som-snytt/dev/814-redux-args-file
- Loading branch information
Showing
9 changed files
with
96 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Compiler arguments written to: argfile-run.obj/print-args.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
import java.nio.file.Files | ||
|
||
import scala.jdk.CollectionConverters._ | ||
import scala.reflect.internal.util._ | ||
import scala.tools.nsc.{CompilerCommand, Settings} | ||
import scala.tools.partest.DirectTest | ||
import scala.util.chaining._ | ||
|
||
object Test extends DirectTest { | ||
var count = 0 | ||
lazy val argfile = testOutput.jfile.toPath().resolve("print-args.txt") | ||
lazy val goodarg = testOutput.jfile.toPath().resolve("print-args2.txt") | ||
override def extraSettings = | ||
if (count == 0) s"""${super.extraSettings} -Xsource:3 -Vprint-args $argfile "-Wconf:cat=unused-nowarn&msg=does not suppress&site=C:s"""" | ||
else s"@$goodarg" | ||
|
||
// Use CompilerCommand for expanding the args file. | ||
override def newSettings(args: List[String]) = (new Settings).tap { s => | ||
val cc = new CompilerCommand(args, s) | ||
assert(cc.ok) | ||
assert(cc.files.isEmpty) | ||
} | ||
def code = | ||
sm""" | ||
|@annotation.nowarn | ||
|final class C { | ||
| def f: Int = "42".toInt | ||
|} | ||
""" | ||
def show() = { | ||
assert(compile()) | ||
// drop "-Vprint-args .../print-args.txt newSource1.scala" | ||
val args = Files.readAllLines(argfile).asScala.toList.dropRight(3) | ||
Files.write(goodarg, args.asJava) | ||
count += 1 | ||
assert(compile()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Compiler arguments written to: print-args-run.obj/print-args.txt | ||
newSource1.scala:3: error: type mismatch; | ||
found : String("42") | ||
required: Int | ||
def f: Int = "42" | ||
^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
import java.nio.file.Files | ||
|
||
import scala.jdk.CollectionConverters._ | ||
import scala.reflect.internal.util._ | ||
import scala.tools.partest.DirectTest | ||
|
||
object Test extends DirectTest { | ||
lazy val argfile = testOutput.jfile.toPath().resolve("print-args.txt") | ||
override def extraSettings = s"${super.extraSettings} -Xsource:3 -Vprint-args ${argfile}" | ||
def expected = | ||
sm""" | ||
|-usejavacp | ||
|-d | ||
|${testOutput.jfile.toPath()} | ||
|-Xsource:3.0.0 | ||
|-Vprint-args | ||
|${testOutput.jfile.toPath().resolve(argfile)} | ||
|newSource1.scala | ||
""" | ||
def code = | ||
sm""" | ||
|class C { | ||
| def f: Int = "42" | ||
|} | ||
""" | ||
def show() = { | ||
assert(!compile()) | ||
assert(expected.linesIterator.toList.tail.init.sameElements(Files.readAllLines(argfile).asScala)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters