From 2e7c0cae48bce4ff41659bc98d39e1139c910a50 Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Sat, 24 Apr 2010 22:41:55 -0400 Subject: [PATCH] update test for projects that use the compiler --- .../run-test/project/build/P.scala | 8 ++++++++ .../run-test/src/main/scala/Foo.scala | 13 ++++++++----- .../run-test/src/test/scala/Basic.scala | 15 +++++++++++++++ sbt/src/sbt-test/compiler-project/run-test/test | 7 ++++++- 4 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 sbt/src/sbt-test/compiler-project/run-test/project/build/P.scala create mode 100644 sbt/src/sbt-test/compiler-project/run-test/src/test/scala/Basic.scala diff --git a/sbt/src/sbt-test/compiler-project/run-test/project/build/P.scala b/sbt/src/sbt-test/compiler-project/run-test/project/build/P.scala new file mode 100644 index 000000000..baa8bad30 --- /dev/null +++ b/sbt/src/sbt-test/compiler-project/run-test/project/build/P.scala @@ -0,0 +1,8 @@ +import sbt._ + +class P(info: ProjectInfo) extends DefaultProject(info) +{ + val bryanjswift = "Bryan J Swift Repository" at "http://repos.bryanjswift.com/maven2/" + val junitInterface = "com.novocode" % "junit-interface" % "0.4.0" % "test" + val junit = "junit" % "junit" % "4.7" % "test" +} \ No newline at end of file diff --git a/sbt/src/sbt-test/compiler-project/run-test/src/main/scala/Foo.scala b/sbt/src/sbt-test/compiler-project/run-test/src/main/scala/Foo.scala index 875399679..217ef6304 100644 --- a/sbt/src/sbt-test/compiler-project/run-test/src/main/scala/Foo.scala +++ b/sbt/src/sbt-test/compiler-project/run-test/src/main/scala/Foo.scala @@ -1,18 +1,21 @@ package foo.bar import java.io.File +import File.{pathSeparator => / } import java.net.{URISyntaxException, URL} class Holder { var value: Any = _ } -import scala.tools.nsc.{Interpreter, Settings} +import scala.tools.nsc.{GenericRunnerSettings, Interpreter, Settings} class Foo { + val g = new GenericRunnerSettings(System.err.println) val settings = new Settings() settings.classpath.value = location(classOf[Holder]) - settings.bootclasspath.value = settings.bootclasspath.value + File.pathSeparator + location(classOf[ScalaObject]) - val inter = new Interpreter(settings) - + settings.bootclasspath.value = settings.bootclasspath.value + / + location(classOf[ScalaObject]) + / + location(classOf[Settings]) + val inter = new Interpreter(settings) { + override protected def parentClassLoader = Foo.this.getClass.getClassLoader + } def eval(code: String): Any = { val h = new Holder inter.bind("$r_", h.getClass.getName, h) @@ -32,4 +35,4 @@ object Test val foo = new Foo args.foreach { arg => foo.eval(arg) == arg.toInt } } -} +} \ No newline at end of file diff --git a/sbt/src/sbt-test/compiler-project/run-test/src/test/scala/Basic.scala b/sbt/src/sbt-test/compiler-project/run-test/src/test/scala/Basic.scala new file mode 100644 index 000000000..8f26f73a4 --- /dev/null +++ b/sbt/src/sbt-test/compiler-project/run-test/src/test/scala/Basic.scala @@ -0,0 +1,15 @@ +package foo.bar + +import org.junit._ +import org.junit.Assert._ + +class Basic +{ + val foo = new Foo + @Test + def checkBind(): Unit = + { + try { assertTrue( foo.eval("3") == 3) } + catch { case e => e.printStackTrace; throw e} + } +} diff --git a/sbt/src/sbt-test/compiler-project/run-test/test b/sbt/src/sbt-test/compiler-project/run-test/test index 15139f18e..8d3b08058 100644 --- a/sbt/src/sbt-test/compiler-project/run-test/test +++ b/sbt/src/sbt-test/compiler-project/run-test/test @@ -1,8 +1,13 @@ +> set build.scala.versions 2.7.7 2.8.0.RC1 +> reload +> +update > +run 1 +> +test > +clean > +run 2 +> +test > +clean > +run -1 -> +clean \ No newline at end of file +> +test \ No newline at end of file