cleanup compilation tests

This commit is contained in:
Mark Harrah 2012-05-12 23:12:29 -04:00
parent 864580aae1
commit 7bed381bec
4 changed files with 11 additions and 10 deletions

View File

@ -30,11 +30,16 @@ object CompileTest extends Specification
WithFiles( new File("Test.scala") -> "object Test" ) { sources =>
withTemporaryDirectory { temp =>
val callback = new xsbti.TestCallback
compiler(sources, Nil, temp, Nil, callback, 10, log)
compiler(sources, noChanges, Nil, temp, Nil, callback, 10, CompilerCache.fresh, log)
(callback.beganSources) must haveTheSameElementsAs(sources)
}
}
}
val noChanges = new xsbti.compile.DependencyChanges {
def isEmpty = true
def modifiedBinaries = Array()
def modifiedClasses = Array()
}
val UsingCompiler = "object Test { classOf[scala.tools.nsc.Global] }"

View File

@ -12,15 +12,12 @@ object TestCompile
/** Tests running the compiler interface with the analyzer plugin with a test callback. The test callback saves all information
* that the plugin sends it for post-compile analysis by the provided function.*/
def apply[T](scalaVersion: String, sources: Seq[File], outputDirectory: File, options: Seq[String])
(f: (TestCallback, ScalaInstance, Logger) => T): T =
(f: (TestCallback, xsbti.compile.ScalaInstance, Logger) => T): T =
{
val testCallback = new TestCallback
WithCompiler(scalaVersion) { (compiler, log) =>
compiler(sources, Nil, outputDirectory, options, testCallback, 5, log)
val result = f(testCallback, compiler.scalaInstance, log)
for( (file, src) <- testCallback.apis )
xsbt.api.APIUtil.verifyTypeParameters(src)
result
compiler(sources, CompileTest.noChanges, Nil, outputDirectory, options, testCallback, 5, CompilerCache.fresh, log)
f(testCallback, compiler.scalaInstance, log)
}
}
/** Tests running the compiler interface with the analyzer plugin. The provided function is given a ClassLoader that can
@ -32,7 +29,7 @@ object CallbackTest
{
def simple[T](scalaVersion: String, sources: Seq[File])(f: TestCallback => T): T =
full(scalaVersion, sources){ case (callback, _, _, _) => f(callback) }
def full[T](scalaVersion: String, sources: Seq[File])(f: (TestCallback, File, ScalaInstance, Logger) => T): T =
def full[T](scalaVersion: String, sources: Seq[File])(f: (TestCallback, File, xsbti.compile.ScalaInstance, Logger) => T): T =
withTemporaryDirectory { outputDir =>
TestCompile(scalaVersion, sources, outputDir, Nil) { case (callback, instance, log) => f(callback, outputDir, instance, log) }
}

View File

@ -20,5 +20,5 @@ class TestCallback extends AnalysisCallback
def endSource(source: File) { endedSources += source }
def api(source: File, sourceAPI: xsbti.api.SourceAPI) { apis += ((source, sourceAPI)) }
def problem(pos: xsbti.Position, message: String, severity: xsbti.Severity, reported: Boolean) {}
def problem(category: String, pos: xsbti.Position, message: String, severity: xsbti.Severity, reported: Boolean) {}
}

View File

@ -2,7 +2,6 @@ name := "test"
TaskKey[Unit]("check-same") <<= compile in Configurations.Compile map { analysis =>
analysis.apis.internal foreach { case (_, api) =>
assert( xsbt.api.APIUtil.verifyTypeParameters(api.api) )
assert( xsbt.api.SameAPI(api.api, api.api) )
}
}