mirror of https://github.com/sbt/sbt.git
Setup interface project for testing
This commit is contained in:
parent
1864c12f74
commit
165d1df52c
|
|
@ -0,0 +1,11 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2009 Mark Harrah
|
||||
*/
|
||||
package xsbti;
|
||||
|
||||
public interface Versions
|
||||
{
|
||||
public static final String Sbt = "0.7";
|
||||
public static final int Interface = 1;
|
||||
public static final int BootInterface = 1;
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package xsbti
|
||||
|
||||
object f0
|
||||
{
|
||||
def apply[T](s: => T) = new F0[T] { def apply = s }
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package xsbti
|
||||
|
||||
import java.io.File
|
||||
import scala.collection.mutable.ArrayBuffer
|
||||
|
||||
class TestCallback(val superclassNames: Array[String]) extends AnalysisCallback
|
||||
{
|
||||
val invalidSuperclasses = new ArrayBuffer[String]
|
||||
val beganSources = new ArrayBuffer[File]
|
||||
val endedSources = new ArrayBuffer[File]
|
||||
val foundSubclasses = new ArrayBuffer[(File, String, String, Boolean)]
|
||||
val sourceDependencies = new ArrayBuffer[(File, File)]
|
||||
val jarDependencies = new ArrayBuffer[(File, File)]
|
||||
val classDependencies = new ArrayBuffer[(File, File)]
|
||||
val products = new ArrayBuffer[(File, File)]
|
||||
val applications = new ArrayBuffer[(File, String)]
|
||||
|
||||
def superclassNotFound(superclassName: String) { invalidSuperclasses += superclassName }
|
||||
def beginSource(source: File) { beganSources += source }
|
||||
def foundSubclass(source: File, subclassName: String, superclassName: String, isModule: Boolean): Unit =
|
||||
foundSubclasses += ((source, subclassName, superclassName, isModule))
|
||||
def sourceDependency(dependsOn: File, source: File) { sourceDependencies += ((dependsOn, source)) }
|
||||
def jarDependency(jar: File, source: File) { jarDependencies += ((jar, source)) }
|
||||
def classDependency(clazz: File, source: File) { classDependencies += ((clazz, source)) }
|
||||
def generatedClass(source: File, module: File) { products += ((source, module)) }
|
||||
def endSource(source: File) { endedSources += source }
|
||||
def foundApplication(source: File, className: String) { applications += ((source, className)) }
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package xsbti
|
||||
|
||||
class TestLogger extends Logger
|
||||
{
|
||||
private val buffer = new scala.collection.mutable.ArrayBuffer[F0[Unit]]
|
||||
def info(msg: F0[String]) = buffer("[info] ", msg)
|
||||
def warn(msg: F0[String]) = buffer("[warn] ", msg)
|
||||
def debug(msg: F0[String]) = buffer("[debug] ", msg)
|
||||
def error(msg: F0[String]) = buffer("[error] ", msg)
|
||||
def verbose(msg: F0[String]) = buffer("[verbose] ", msg)
|
||||
def show() { buffer.foreach(_()) }
|
||||
def clear() { buffer.clear() }
|
||||
def trace(t: F0[Throwable]) { buffer += f0(t().printStackTrace) }
|
||||
private def buffer(s: String, msg: F0[String]) { buffer += f0(println(s + msg())) }
|
||||
}
|
||||
object TestLogger
|
||||
{
|
||||
def apply[T](f: Logger => T): T =
|
||||
{
|
||||
val log = new TestLogger
|
||||
try { f(log) }
|
||||
catch { case e: Exception => log.show(); throw e }
|
||||
finally { log.clear() }
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue