From fac81d705ff0bfdeb3320fd9e46b6d3d34e47ddf Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Thu, 25 Jun 2015 10:16:58 -0700 Subject: SI-9206 De-perk the welcome message The welcome message defaults to a sober header followed by one line of instructions. --- test/files/run/repl-javap-app.check | 9 ++-- test/files/run/repl-trim-stack-trace.scala | 3 +- test/files/run/t6502.scala | 76 +++++++++++++++++++++--------- test/files/run/t7805-repl-i.check | 3 +- 4 files changed, 59 insertions(+), 32 deletions(-) (limited to 'test/files/run') diff --git a/test/files/run/repl-javap-app.check b/test/files/run/repl-javap-app.check index d29682cca5..bace9534da 100644 --- a/test/files/run/repl-javap-app.check +++ b/test/files/run/repl-javap-app.check @@ -1,6 +1,5 @@ #partest java6 -Welcome to Scala! -version +Welcome to Scala Type in expressions for evaluation. Or try :help. scala> :javap -app MyApp$ @@ -17,8 +16,7 @@ public final void delayedEndpoint$MyApp$1(); scala> :quit #partest java7 -Welcome to Scala! -version +Welcome to Scala Type in expressions for evaluation. Or try :help. scala> :javap -app MyApp$ @@ -39,8 +37,7 @@ scala> :javap -app MyApp$ scala> :quit #partest java8 -Welcome to Scala! -version +Welcome to Scala Type in expressions for evaluation. Or try :help. scala> :javap -app MyApp$ diff --git a/test/files/run/repl-trim-stack-trace.scala b/test/files/run/repl-trim-stack-trace.scala index d128d4c39a..ea91e32239 100644 --- a/test/files/run/repl-trim-stack-trace.scala +++ b/test/files/run/repl-trim-stack-trace.scala @@ -4,8 +4,7 @@ import scala.tools.partest.{ SessionTest, Welcoming } // SI-7740 object Test extends SessionTest with Welcoming { def session = -"""Welcome to Scala! -version +"""Welcome to Scala Type in expressions for evaluation. Or try :help. scala> def f = throw new Exception("Uh-oh") diff --git a/test/files/run/t6502.scala b/test/files/run/t6502.scala index d6b15a0189..f4fc39a03d 100644 --- a/test/files/run/t6502.scala +++ b/test/files/run/t6502.scala @@ -1,11 +1,14 @@ import scala.tools.nsc.Settings -import scala.tools.nsc.interpreter.ILoop +import scala.tools.nsc.interpreter.{ ILoop, replProps } import scala.tools.nsc.settings.ClassPathRepresentationType import scala.tools.partest._ object Test extends StoreReporterDirectTest { def code = ??? + lazy val headerLength = replProps.welcome.lines.size + lazy val promptLength = replProps.prompt.lines.size - 1 // extra newlines + def compileCode(code: String, jarFileName: String) = { val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator") compileString(newCompiler("-cp", classpath, "-d", s"${testOutput.path}/$jarFileName"))(code) @@ -56,14 +59,21 @@ object Test extends StoreReporterDirectTest { val jar = "test1.jar" compileCode(app1, jar) - val codeToRun = toCodeInSeparateLines(s":require ${testOutput.path}/$jar", "test.Test.test()") + val codeToRun = s""" + |:require ${testOutput.path}/$jar + |test.Test.test() + |""".stripMargin.trim val output = ILoop.run(codeToRun, settings) - val lines = output.split("\n") - assert { - lines(4).contains("Added") && lines(4).contains("test1.jar") - } + var lines = output.lines.drop(headerLength) + lines = lines drop promptLength + val added = lines.next + assert ( + added.contains("Added") && added.contains("test1.jar"), + s"[${added}] in [${output.lines.mkString("/")}]" + ) + lines = lines drop promptLength assert { - lines(lines.length-3).contains("testing...") + lines.next.contains("testing...") } } @@ -73,14 +83,21 @@ object Test extends StoreReporterDirectTest { val jar2 = "test2.jar" compileCode(app2, jar2) - val codeToRun = toCodeInSeparateLines(s":require ${testOutput.path}/$jar1", s":require ${testOutput.path}/$jar2") + val codeToRun = s""" + |:require ${testOutput.path}/$jar1 + |:require ${testOutput.path}/$jar2 + |""".stripMargin.trim val output = ILoop.run(codeToRun, settings) - val lines = output.split("\n") + var lines = output.lines.drop(headerLength) + lines = lines drop promptLength + val added = lines.next assert { - lines(4).contains("Added") && lines(4).contains("test1.jar") + added.contains("Added") && added.contains("test1.jar") } + lines = lines drop promptLength + val msg = lines.next assert { - lines(lines.length-3).contains("test2.jar") && lines(lines.length-3).contains("existing classpath entries conflict") + msg.contains("test2.jar") && msg.contains("existing classpath entries conflict") } } @@ -90,28 +107,42 @@ object Test extends StoreReporterDirectTest { val jar3 = "test3.jar" compileCode(app3, jar3) - val codeToRun = toCodeInSeparateLines(s":require ${testOutput.path}/$jar1", s":require ${testOutput.path}/$jar3", "test.Test3.test()") + val codeToRun = s""" + |:require ${testOutput.path}/$jar1 + |:require ${testOutput.path}/$jar3 + |test.Test3.test() + |""".stripMargin.trim val output = ILoop.run(codeToRun, settings) - val lines = output.split("\n") + var lines = output.lines.drop(headerLength) + lines = lines drop promptLength + val added = lines.next assert { - lines(4).contains("Added") && lines(4).contains("test1.jar") + added.contains("Added") && added.contains("test1.jar") } + lines = lines drop (2 * promptLength + 1) assert { - lines(lines.length-3).contains("new object in existing package") + lines.next.contains("new object in existing package") } } def test4(): Unit = { // twice the same jar should be rejected val jar1 = "test1.jar" - val codeToRun = toCodeInSeparateLines(s":require ${testOutput.path}/$jar1", s":require ${testOutput.path}/$jar1") + val codeToRun = s""" + |:require ${testOutput.path}/$jar1 + |:require ${testOutput.path}/$jar1 + |""".stripMargin.trim val output = ILoop.run(codeToRun, settings) - val lines = output.split("\n") + var lines = output.lines.drop(headerLength) + lines = lines drop promptLength + val added = lines.next assert { - lines(4).contains("Added") && lines(4).contains("test1.jar") + added.contains("Added") && added.contains("test1.jar") } + lines = lines drop promptLength + val msg = lines.next assert { - lines(lines.length-3).contains("test1.jar") && lines(lines.length-3).contains("existing classpath entries conflict") + msg.contains("test1.jar") && msg.contains("existing classpath entries conflict") } } @@ -127,7 +158,10 @@ object Test extends StoreReporterDirectTest { // classloader to parse .class files in order to read their names. val jar = "test6.jar" compileCode(app6, jar) - val codeToRun = toCodeInSeparateLines(s":require ${testOutput.path}/$jar", "import test6._; new A; new Z") + val codeToRun = s""" + |:require ${testOutput.path}/$jar + |import test6._; new A; new Z + |""".stripMargin.trim val output = ILoop.run(codeToRun, settings) assert(output.contains("created test6.A"), output) assert(output.contains("created test6.Z"), output) @@ -141,6 +175,4 @@ object Test extends StoreReporterDirectTest { test5() test6() } - - def toCodeInSeparateLines(lines: String*): String = lines mkString "\n" } diff --git a/test/files/run/t7805-repl-i.check b/test/files/run/t7805-repl-i.check index 977de0b047..24512c0067 100644 --- a/test/files/run/t7805-repl-i.check +++ b/test/files/run/t7805-repl-i.check @@ -1,8 +1,7 @@ Loading t7805-repl-i.script... import util._ -Welcome to Scala! -version +Welcome to Scala Type in expressions for evaluation. Or try :help. scala> Console println Try(8) -- cgit v1.2.3