Scripted test for a macro def in a source file.

Needed to increase MaxPermSize, otherwise I was unable to run this test on Java 1.6.0_29 64bit Server on Mac OS.
This commit is contained in:
Jason Zaugg 2012-03-04 22:51:57 +01:00
parent 17eeec6876
commit d422b5cb8f
6 changed files with 59 additions and 1 deletions

View File

@ -143,7 +143,8 @@ object Sbt extends Build
val loader = classpath.ClasspathUtilities.toLoader(scriptedSbtClasspath.files, scriptedSbtInstance.loader)
val m = ModuleUtilities.getObject("sbt.test.ScriptedTests", loader)
val r = m.getClass.getMethod("run", classOf[File], classOf[Boolean], classOf[String], classOf[String], classOf[String], classOf[Array[String]], classOf[File], classOf[Array[String]])
try { r.invoke(m, sourcePath, true: java.lang.Boolean, v, sv, ssv, args.toArray[String], launcher, Array[String]()) }
val launcherVmOptions = Array("-XX:MaxPermSize=256M") // increased after a failure in scripted source-dependencies/macro
try { r.invoke(m, sourcePath, true: java.lang.Boolean, v, sv, ssv, args.toArray[String], launcher, launcherVmOptions) }
catch { case ite: java.lang.reflect.InvocationTargetException => throw ite.getCause }
}
}

View File

@ -0,0 +1,5 @@
package macro
object Client {
Provider.tree(0)
}

View File

@ -0,0 +1,5 @@
package macro
object Provider {
def macro tree(args: Any) = reify(args)
}

View File

@ -0,0 +1,5 @@
package macro
object Provider {
def macro tree(args: Any) = sys.error("no macro for you!")
}

View File

@ -0,0 +1,29 @@
import sbt._
import Keys._
object build extends Build {
val defaultSettings = Seq(
scalaVersion := "2.10.0-M2",
scalacOptions += "-Xmacros"
)
lazy val root = Project(
base = file("."),
id = "macro",
aggregate = Seq(macroProvider, macroClient),
settings = Defaults.defaultSettings ++ defaultSettings
)
lazy val macroProvider = Project(
base = file("macro-provider"),
id = "macro-provider",
settings = Defaults.defaultSettings ++ defaultSettings
)
lazy val macroClient = Project(
base = file("macro-client"),
id = "macro-client",
dependencies = Seq(macroProvider),
settings = Defaults.defaultSettings ++ defaultSettings
)
}

View File

@ -0,0 +1,13 @@
> compile
# replace macro with one that throws an error
$ copy-file macro-provider/changes/Provider.scala macro-provider/Provider.scala
> macro-provider/compile
-> macro-client/compile
> clean
-> compile