summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSom Snytt <som.snytt@gmail.com>2014-02-14 13:58:58 -0800
committerSom Snytt <som.snytt@gmail.com>2014-02-14 13:58:58 -0800
commit1dceb39bdf9d95e9f3f0887b643c7fcca6464f9e (patch)
tree8871b86d49a74c412efd90115fb1b659ae0a584f
parent37f822eb66dc18a2b3bfdaa672081b6f08ef5688 (diff)
downloadscala-1dceb39bdf9d95e9f3f0887b643c7fcca6464f9e.tar.gz
scala-1dceb39bdf9d95e9f3f0887b643c7fcca6464f9e.tar.bz2
scala-1dceb39bdf9d95e9f3f0887b643c7fcca6464f9e.zip
SI-7711 Test for args in script
Compiles with -Xlint to ensure there are no lurkers. Updates `ScriptTest` to pass args to the script. It's called `argv` partly as homage, partly because `args` is an `Array`.
-rw-r--r--src/partest-extras/scala/tools/partest/ScriptTest.scala3
-rw-r--r--test/files/run/t7711-script-args.check2
-rw-r--r--test/files/run/t7711-script-args.scala7
-rw-r--r--test/files/run/t7711-script-args.script12
4 files changed, 23 insertions, 1 deletions
diff --git a/src/partest-extras/scala/tools/partest/ScriptTest.scala b/src/partest-extras/scala/tools/partest/ScriptTest.scala
index 24a4121b54..3000d751e1 100644
--- a/src/partest-extras/scala/tools/partest/ScriptTest.scala
+++ b/src/partest-extras/scala/tools/partest/ScriptTest.scala
@@ -14,8 +14,9 @@ abstract class ScriptTest extends DirectTest {
override def extraSettings = s"-usejavacp -Xscript $testmain"
def scriptPath = testPath changeExtension "script"
def code = scriptPath.toFile.slurp
+ def argv = Seq.empty[String]
def show() = {
compile()
- ScalaClassLoader(getClass.getClassLoader).run(testmain, Seq.empty[String])
+ ScalaClassLoader(getClass.getClassLoader).run(testmain, argv)
}
}
diff --git a/test/files/run/t7711-script-args.check b/test/files/run/t7711-script-args.check
new file mode 100644
index 0000000000..d107590a8a
--- /dev/null
+++ b/test/files/run/t7711-script-args.check
@@ -0,0 +1,2 @@
+Hello, scripted test!
+What good news have you for me today?
diff --git a/test/files/run/t7711-script-args.scala b/test/files/run/t7711-script-args.scala
new file mode 100644
index 0000000000..02535aa954
--- /dev/null
+++ b/test/files/run/t7711-script-args.scala
@@ -0,0 +1,7 @@
+
+import scala.tools.partest.ScriptTest
+
+object Test extends ScriptTest {
+ override def extraSettings = s"${super.extraSettings} -Xlint"
+ override def argv = Seq("good", "news")
+}
diff --git a/test/files/run/t7711-script-args.script b/test/files/run/t7711-script-args.script
new file mode 100644
index 0000000000..19b7a74924
--- /dev/null
+++ b/test/files/run/t7711-script-args.script
@@ -0,0 +1,12 @@
+#!/bin/bash
+exec ${SCALA_HOME}/bin/scala "$0" "$@" 2>&1
+!#
+
+Console println s"Hello, scripted test!"
+Console println s"What ${args mkString " "} have you for me today?"
+
+//def unused = 88
+//newSource1.scala:8: warning: private method in <$anon: AnyRef> is never used
+//Console println s"Hello, $argv, are you still here?"
+//newSource1.scala:9: error: not found: value argv
+