diff options
author | Som Snytt <som.snytt@gmail.com> | 2014-10-18 07:57:18 -0700 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2014-10-28 01:11:08 -0700 |
commit | be505f6066f9d69c8cd8bbff0439a8867d32395e (patch) | |
tree | 8fb6928c95886949327671d8911c73c340651d13 | |
parent | bdae51d6a8f18a5456a32c350cb551d42a3cb6c6 (diff) | |
download | scala-be505f6066f9d69c8cd8bbff0439a8867d32395e.tar.gz scala-be505f6066f9d69c8cd8bbff0439a8867d32395e.tar.bz2 scala-be505f6066f9d69c8cd8bbff0439a8867d32395e.zip |
Make global-showdef a DirectTest
The test test/files/run/global-showdef.scala was outputting
to the cwd instead of the test output dir.
Good behavior is now inherited from DirectTest.
Test frameworks, of any ilk or capability, rock.
-rw-r--r-- | test/files/run/global-showdef.scala | 50 |
1 files changed, 18 insertions, 32 deletions
diff --git a/test/files/run/global-showdef.scala b/test/files/run/global-showdef.scala index 1d4891fd1f..bbad123d01 100644 --- a/test/files/run/global-showdef.scala +++ b/test/files/run/global-showdef.scala @@ -1,11 +1,10 @@ -import scala.tools.nsc._ -import scala.reflect.io.AbstractFile +import scala.tools.partest.DirectTest import scala.tools.nsc.util.stringFromStream -import scala.reflect.internal.util.{ SourceFile, BatchSourceFile } -import scala.tools.nsc.reporters.ConsoleReporter -object Test { - val src: SourceFile = new BatchSourceFile("src", """ +object Test extends DirectTest { + override def extraSettings: String = "-usejavacp -Yshow:typer" + + override def code = """ package foo.bar class Bippy { @@ -32,39 +31,26 @@ object Bippy { def showdefTestMemberObject2 = "abc" } - """) + """ + + override def show(): Unit = { + val classes = List("Bippy", "Bippy#BippyType", "Bippy.BippyType", "Bippy#Boppity", "Bippy#Boppity#Boo") + val objects = List("Bippy", "Bippy#Boppity#Boo") + + def interesting(line: String) = (line contains "def showdefTestMember") || (line startsWith "<<-- ") - def mkCompiler(args: String*) = { - val settings = new Settings() - val command = new CompilerCommand("-usejavacp" :: args.toList, settings) + def run(args: String*) = slurp(args: _*).lines filter interesting foreach println - new Global(settings) + classes foreach (x => run("-Xshow-class", x)) + objects foreach (x => run("-Xshow-object", x)) } - def slurp(body: => Unit): String = stringFromStream { stream => + // slurp the compilation result + def slurp(args: String*): String = stringFromStream { stream => Console.withOut(stream) { Console.withErr(stream) { - body + compile(args: _*) } } } - def lines(args: String*): List[String] = { - val output = slurp { - val compiler = mkCompiler(args: _*) - val run = new compiler.Run() - run.compileSources(List(src)) - } - output.lines.toList - } - def showClass(name: String) = lines("-Yshow:typer", "-Xshow-class", name) - def showObject(name: String) = lines("-Yshow:typer", "-Xshow-object", name) - - def show(xs: List[String]) = { - xs filter (x => (x contains "def showdefTestMember") || (x startsWith "<<-- ")) foreach println - } - - def main(args: Array[String]) { - show(List("Bippy", "Bippy#BippyType", "Bippy.BippyType", "Bippy#Boppity", "Bippy#Boppity#Boo") flatMap showClass) - show(List("Bippy", "Bippy#Boppity#Boo") flatMap showObject) - } } |