updating tests to use newer Scala versions

This commit is contained in:
Mark Harrah 2011-04-08 19:19:08 -04:00
parent 3e63a082bd
commit 14c6ee4b2a
9 changed files with 39 additions and 35 deletions

View File

@ -7,7 +7,7 @@ package compiler
object CheckBasic extends Specification
{
val basicName = new File("Basic.scala")
val basicSource = "package org.example { object Basic }"
val basicSource = "package org.example { /** A comment */ object Basic }"
"Compiling basic file should succeed" in {
WithFiles(basicName -> basicSource){ files =>

View File

@ -9,8 +9,6 @@ object CompileTest extends Specification
{
"Analysis compiler" should {
"compile basic sources" in {
WithCompiler( "2.7.2" )(testCompileAnalysis)
WithCompiler( "2.7.3" )(testCompileAnalysis)
WithCompiler( "2.7.4" )(testCompileAnalysis)
WithCompiler( "2.7.5" )(testCompileAnalysis)
WithCompiler( "2.7.7" )(testCompileAnalysis)
@ -21,7 +19,7 @@ object CompileTest extends Specification
"Raw compiler" should {
"Properly handle classpaths" in {
testClasspath("2.7.2")
testClasspath("2.7.4")
testClasspath("2.7.7")
testClasspath("2.8.0")
testClasspath("2.8.1")
@ -53,6 +51,9 @@ object CompileTest extends Specification
case t if isMissingRequirementError(t) => true
case _ => false
}
private def shouldSucceed(act: => Unit) =
try { act } catch { case c: xsbti.CompileFailed => error(c.toString) }
private def isMissingRequirementError(t: Throwable) = t.getClass.getName == "scala.tools.nsc.MissingRequirementError"
private def testClasspath(scalaVersion: String) =
WithCompiler.launcher { (launch, log) =>
@ -67,26 +68,25 @@ object CompileTest extends Specification
val fullBoot = "-bootclasspath" :: fullExplicit.compilerArguments.createBootClasspath :: Nil
val withCompiler = noCompiler.scalaInstance.compilerJar :: Nil
val withLibrary = noCompiler.scalaInstance.libraryJar :: Nil
val withLibraryCompiler = withLibrary ++ withCompiler
WithFiles( new File("Test.scala") -> "object Test", new File("Test2.scala") -> UsingCompiler ) { case Seq(plain, useCompiler) =>
val plainSrcs = Seq[File](plain)
val compSrcs = Seq[File](useCompiler)
withTemporaryDirectory { out =>
standard(plainSrcs, Nil, out, Nil) //success
standard(compSrcs, Nil, out, Nil) //success
shouldSucceed( standard(plainSrcs, Nil, out, Nil) )//success
shouldSucceed( standard(compSrcs, Nil, out, Nil) )//success
noCompiler(plainSrcs, Nil, out, Nil) //success
shouldSucceed( noCompiler(plainSrcs, Nil, out, Nil) )//success
shouldFail( noCompiler(compSrcs, Nil, out, Nil) )
noCompiler(compSrcs, withCompiler, out, Nil) //success
shouldSucceed( noCompiler(compSrcs, withCompiler, out, Nil) )//success
shouldFail( fullExplicit(plainSrcs, Nil, out, Nil) )// failure
shouldFail( fullExplicit(compSrcs, Nil, out, Nil) )// failure
fullExplicit(plainSrcs, Nil, out, fullBoot) // success
fullExplicit(compSrcs, withCompiler, out, fullBoot) // success
// specs now marks something as skipped if there are no matchers
// this test throws exceptions on failure, so use a dummy check here
true must be equalTo(true)
shouldSucceed( fullExplicit(plainSrcs, withLibrary, out, fullBoot) )// success
shouldSucceed( fullExplicit(compSrcs, withLibraryCompiler, out, fullBoot) )// success
true must beTrue
}
}
}

View File

@ -8,8 +8,7 @@ package compiler
object TestCompile
{
// skip 2.7.3 and 2.7.4 for speed
def allVersions = List("2.8.0")//List("2.7.2", "2.7.5", "2.7.7", "2.8.0", "2.8.1.RC1")
def allVersions = List("2.7.4", "2.8.1", "2.9.0.RC1")//List("2.7.4", "2.7.7", "2.8.0", "2.8.1", "2.9.0.RC1")
/** 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])

View File

@ -29,6 +29,7 @@ private object BootConfiguration
/** The Ivy pattern used for the local Ivy repository.*/
def LocalIvyPattern = LocalPattern
val FjbgPackage = "ch.epfl.lamp.fjbg."
/** The class name prefix used to hide the Scala classes used by this loader from the application */
val ScalaPackage = "scala."
/** The class name prefix used to hide the Ivy classes used by this loader from the application*/

View File

@ -3,7 +3,7 @@
*/
package xsbt.boot
import BootConfiguration.{IvyPackage, JLinePackagePath, SbtBootPackage, ScalaPackage}
import BootConfiguration.{FjbgPackage, IvyPackage, JLinePackagePath, SbtBootPackage, ScalaPackage}
import scala.collection.immutable.Stream
/** A custom class loader to ensure the main part of sbt doesn't load any Scala or
@ -14,7 +14,7 @@ private[boot] final class BootFilteredLoader(parent: ClassLoader) extends ClassL
override final def loadClass(className: String, resolve: Boolean): Class[_] =
{
// note that we allow xsbti.* and jline.*
if(className.startsWith(ScalaPackage) || className.startsWith(IvyPackage) || className.startsWith(SbtBootPackage))
if(className.startsWith(ScalaPackage) || className.startsWith(IvyPackage) || className.startsWith(SbtBootPackage) || className.startsWith(FjbgPackage))
throw new ClassNotFoundException(className)
else
super.loadClass(className, resolve)

View File

@ -25,12 +25,16 @@ object Locks extends xsbti.GlobalLock
{
private[this] val locks = new Cache[File, GlobalLock](new GlobalLock(_))
def apply[T](file: File, action: Callable[T]): T =
synchronized
{
file.getParentFile.mkdirs()
file.createNewFile()
locks(file.getCanonicalFile).withLock(action)
}
{
val lock =
synchronized
{
file.getParentFile.mkdirs()
file.createNewFile()
locks(file.getCanonicalFile)
}
lock.withLock(action)
}
private[this] class GlobalLock(file: File)
{

View File

@ -11,12 +11,12 @@ object ScalaProviderTest extends Specification
{
def provide = addToSusVerb("provide")
"Launch" should provide {
"ClassLoader for Scala 2.7.2" in { checkScalaLoader("2.7.2") }
"ClassLoader for Scala 2.7.3" in { checkScalaLoader("2.7.3") }
"ClassLoader for Scala 2.7.4" in { checkScalaLoader("2.7.4") }
"ClassLoader for Scala 2.7.5" in { checkScalaLoader("2.7.5") }
"ClassLoader for Scala 2.7.6" in { checkScalaLoader("2.7.6") }
"ClassLoader for Scala 2.7.7" in { checkScalaLoader("2.7.7") }
"ClassLoader for Scala 2.8.0" in { checkScalaLoader("2.8.0") }
"ClassLoader for Scala 2.8.1" in { checkScalaLoader("2.8.1") }
}
"Launch" should {
@ -74,7 +74,7 @@ object LaunchTest
def mapScalaVersion(versionNumber: String) = scalaVersionMap.find(_._2 == versionNumber).getOrElse {
error("Scala version number " + versionNumber + " from library.properties has no mapping")}._1
val scalaVersionMap = List("2.7.2", "2.8.0.RC4").map(x => (x,x)).toMap ++ List("2.7.3", "2.7.4", "2.7.5", "2.7.6", "2.7.7").map(v => (v, v + ".final"))
val scalaVersionMap = List("2.8.0", "2.8.1", "2.9.0.RC1").map(x => (x,x)).toMap ++ List("2.7.4", "2.7.5", "2.7.6", "2.7.7").map(v => (v, v + ".final"))
def getScalaVersion: String = getScalaVersion(getClass.getClassLoader)
def getScalaVersion(loader: ClassLoader): String = loadProperties(loader, "library.properties").getProperty("version.number")
lazy val AppVersion = loadProperties(getClass.getClassLoader, "xsbt.version.properties").getProperty("version")

View File

@ -120,10 +120,10 @@ object CompatibilityLevel extends Enumeration
def defaultVersions(level: Value) =
level match
{
case Full => "2.7.2 2.7.3 2.7.5 2.7.7 2.8.0.Beta1 2.8.0.RC1 2.8.0.RC2 2.8.0-SNAPSHOT"
case Basic => "2.7.7 2.7.2 2.8.0.RC2"
case Minimal => "2.7.7 2.8.0.RC2"
case Full => "2.7.4 2.7.7 2.8.0 2.8.1 2.9.0.RC1"
case Basic => "2.7.7 2.7.4 2.8.1"
case Minimal => "2.7.7 2.8.1"
case Minimal27 => "2.7.7"
case Minimal28 => "2.8.0.RC2"
case Minimal28 => "2.8.1"
}
}

View File

@ -164,10 +164,10 @@ object CompatibilityLevel extends Enumeration
def defaultVersions(level: Value) =
level match
{
case Full => "2.7.2 2.7.3 2.7.5 2.7.7 2.8.0.Beta1 2.8.0.RC1 2.8.0.RC2 2.8.0-SNAPSHOT"
case Basic => "2.7.7 2.7.2 2.8.0.RC2"
case Minimal => "2.7.7 2.8.0.RC2"
case Full => "2.7.4 2.7.7 2.9.0.RC1 2.8.0 2.8.1"
case Basic => "2.7.7 2.7.4 2.8.1 2.8.0"
case Minimal => "2.7.7 2.8.1"
case Minimal27 => "2.7.7"
case Minimal28 => "2.8.0.RC2"
case Minimal28 => "2.8.1"
}
}