Fix compiler interface tests for 2.8

This commit is contained in:
Mark Harrah 2010-02-08 18:34:43 -05:00
parent 04198061bc
commit e18f8101d7
2 changed files with 8 additions and 12 deletions

View File

@ -116,9 +116,7 @@ object ApplicationsTest extends Specification
}
private def testRun(loader: ClassLoader, className: String)
{
val obj = Class.forName(className+"$", true, loader)
val singletonField = obj.getField("MODULE$")
val singleton = singletonField.get(null)
singleton.asInstanceOf[{def main(args: Array[String]): Unit}].main(Array[String]())
val obj = Class.forName(className, true, loader)
obj.getMethod("main", classOf[Array[String]]).invoke(null, new Array[String](0))
}
}

View File

@ -43,22 +43,20 @@ object WithCompiler
val manager = new ComponentManager(xsbt.boot.Locks, new boot.ComponentProvider(componentDirectory), log)
val compiler = new AnalyzingCompiler(ScalaInstance(scalaVersion, launch), manager)
compiler.newComponentCompiler(log).clearCache(ComponentCompiler.compilerInterfaceID)
prepare(manager, ComponentCompiler.compilerInterfaceSrcID, "CompilerInterface.scala")
prepare(manager, ComponentCompiler.xsbtiID, classOf[xsbti.AnalysisCallback])
define(manager, ComponentCompiler.compilerInterfaceSrcID, getResource("CompilerInterface.scala"), getClassResource(classOf[jline.Completor]))
define(manager, ComponentCompiler.xsbtiID, getClassResource(classOf[xsbti.AnalysisCallback]))
f(compiler, log)
}
}
}
}
def prepare(manager: ComponentManager, id: String, resource: Class[_]): Unit = define(manager, id, FileUtilities.classLocationFile(resource) :: Nil)
def prepare(manager: ComponentManager, id: String, resource: String)
def getClassResource(resource: Class[_]): File = FileUtilities.classLocationFile(resource)
def getResource(resource: String): File =
{
val src = getClass.getClassLoader.getResource(resource)
if(src eq null)
error("Resource not found: " + resource)
define(manager, id, FileUtilities.asFile(src) :: Nil)
if(src ne null) FileUtilities.asFile(src) else error("Resource not found: " + resource)
}
def define(manager: ComponentManager, id: String, files: List[File])
def define(manager: ComponentManager, id: String, files: File*)
{
manager.clearCache(id)
manager.define(id, files)