summaryrefslogtreecommitdiff
path: root/project/build
diff options
context:
space:
mode:
authormoix <moix@epfl.ch>2010-08-31 06:49:57 +0000
committermoix <moix@epfl.ch>2010-08-31 06:49:57 +0000
commitfaed687d92849859157ea264bcac57b4ec72e9b7 (patch)
treed9ceb5cb0db5c9bd0ccb2e352d374e22ceaa4378 /project/build
parent8964f6f1bcc8500f1bc6a2808ef70d8852d208ec (diff)
downloadscala-faed687d92849859157ea264bcac57b4ec72e9b7.tar.gz
scala-faed687d92849859157ea264bcac57b4ec72e9b7.tar.bz2
scala-faed687d92849859157ea264bcac57b4ec72e9b7.zip
Partest support for sbt (with failed only and s...
Partest support for sbt (with failed only and specific files only options) Support for triggered execution
Diffstat (limited to 'project/build')
-rw-r--r--project/build/AdditionalResources.scala4
-rw-r--r--project/build/BasicLayer.scala23
-rw-r--r--project/build/Compilation.scala2
-rw-r--r--project/build/CompilationStep.scala2
-rw-r--r--project/build/ExternalTaskRunner.scala6
-rw-r--r--project/build/Packer.scala17
-rwxr-xr-xproject/build/Partest.scala321
-rw-r--r--project/build/ScalaSBTBuilder.scala29
-rw-r--r--project/build/Scaladoc.scala2
9 files changed, 277 insertions, 129 deletions
diff --git a/project/build/AdditionalResources.scala b/project/build/AdditionalResources.scala
index b1f727df6b..bf1baf3e6b 100644
--- a/project/build/AdditionalResources.scala
+++ b/project/build/AdditionalResources.scala
@@ -40,14 +40,12 @@ trait AdditionalResources {
}
-import sbt._
-import BasicLayer._
object AdditionalResources {
/**
* A FileFilter that defines what are the files that will be copied
*/
lazy val basicFilter = "*.tmpl" | "*.xml"| "*.js"| "*.css" | "*.properties" | "*.swf" | "*.png"
-
+ implicit def stringToGlob(s:String):NameFilter=GlobFilter(s)
}
trait ResourcesToCopy {
diff --git a/project/build/BasicLayer.scala b/project/build/BasicLayer.scala
index 084fcf3072..b8f66c12eb 100644
--- a/project/build/BasicLayer.scala
+++ b/project/build/BasicLayer.scala
@@ -1,6 +1,5 @@
import sbt._
import xsbt.{ScalaInstance}
-import BasicLayer._
import ScalaBuildProject._
import scala.collection.immutable.{EmptyMap}
@@ -19,6 +18,7 @@ abstract class BasicLayer(val info:ProjectInfo,val versionNumber:String, previou
def buildInfoEnvironmentLocation:Path=outputRootPath / ("build-"+name+".properties")
+ override def watchPaths = info.projectPath / "src" ** ("*.scala" || "*.java"|| AdditionalResources.basicFilter) // Support of triggered execution at project level
override def dependencies = info.dependencies
@@ -66,7 +66,7 @@ abstract class BasicLayer(val info:ProjectInfo,val versionNumber:String, previou
def cleaningList=layerOutput::layerEnvironment.envBackingPath::packingDestination::Nil
- lazy val cleanFiles = FileUtilities.clean(cleaningList,true,log)
+ def cleanFiles = FileUtilities.clean(cleaningList,true,log)
lazy val clean:Task = nextLayer match {
case None => super.task{ cleanFiles}// We use super.task, so cleaning is done in every case, even when locked
@@ -74,6 +74,11 @@ abstract class BasicLayer(val info:ProjectInfo,val versionNumber:String, previou
}
+ lazy val cleanBuild = task{
+ cleanFiles orElse buildLayer
+ }.dependsOn(startLayer)
+
+
@@ -263,13 +268,6 @@ abstract class BasicLayer(val info:ProjectInfo,val versionNumber:String, previou
-
- //Needed Libraries
- //TODO Check if not possible to manage some of them with the sbt dependency management (ivy)
-
-
-
-
//Paths location that must be defined layer by layer
/*
* We must define which are the libraries used to instantiate the compiler
@@ -281,10 +279,3 @@ abstract class BasicLayer(val info:ProjectInfo,val versionNumber:String, previou
}
-
-object BasicLayer{
- implicit def stringToGlob(s:String):NameFilter=GlobFilter(s)
-
-
-
-}
diff --git a/project/build/Compilation.scala b/project/build/Compilation.scala
index f634cbc287..2b67f3e5a0 100644
--- a/project/build/Compilation.scala
+++ b/project/build/Compilation.scala
@@ -106,7 +106,7 @@ trait LayerCompilation extends Compilation{
lazy val compilation = task{compile(allSteps,cleanCompilation _)}
def externalCompilation:Option[String] = {
- val runner = new ExternalTaskRunner(projectRoot,this.name,compilation.name, log)
+ val runner = new ExternalTaskRunner(projectRoot,this.name,compilation.name,"Error during external compilation", log)
runner.runTask
}
diff --git a/project/build/CompilationStep.scala b/project/build/CompilationStep.scala
index be587de564..f9602b2718 100644
--- a/project/build/CompilationStep.scala
+++ b/project/build/CompilationStep.scala
@@ -1,5 +1,5 @@
import sbt._
-import BasicLayer._
+import AdditionalResources._
trait Step extends Dag[Step] {
def dependencies:Iterable[Step]
diff --git a/project/build/ExternalTaskRunner.scala b/project/build/ExternalTaskRunner.scala
index c9ad97b970..b99af1b003 100644
--- a/project/build/ExternalTaskRunner.scala
+++ b/project/build/ExternalTaskRunner.scala
@@ -7,7 +7,7 @@ import ExternalTaskRunner._
* performance issue) and that in order to keep incremental compilation, we allow to launch a task from a
* specific project / sub-project in a different instance of sbt that disappear once the task has finished.
*/
-class ExternalTaskRunner(root:Path,projectName:String, taskName :String, log: Logger ){
+class ExternalTaskRunner(root:Path,projectName:String, taskName :String,errorMessage:String, log: Logger ){
def runTask:Option[String] ={
@@ -16,7 +16,7 @@ class ExternalTaskRunner(root:Path,projectName:String, taskName :String, log: Lo
log.info("Launching task ["+taskName+"] of project ["+projectName+"] in new sbt instance")
externalSbt.! match{
case 0 => None
- case _ => Some("External Task Failed")
+ case _ => Some(errorMessage)
}
}
@@ -31,4 +31,4 @@ object ExternalTaskRunner{
-} \ No newline at end of file
+}
diff --git a/project/build/Packer.scala b/project/build/Packer.scala
index 8450f212fb..196056ca38 100644
--- a/project/build/Packer.scala
+++ b/project/build/Packer.scala
@@ -1,7 +1,7 @@
import sbt._
import java.io.{File,FileInputStream}
import java.util.jar.Manifest
-import BasicLayer._
+import AdditionalResources._
import FileUtilities._
@@ -86,23 +86,10 @@ trait Packer {
class PackagingConfiguration(val jarDestination:Path, val content:Iterable[Path],val manifest:Manifest,val jarsToInclude:List[Path]){
def this(jarDestination:Path,content:Iterable[Path])=this(jarDestination,content, new Manifest,Nil)
def this(jarDestination:Path,content:Iterable[Path],jarsToInclude:List[Path])=this(jarDestination,content,new Manifest, jarsToInclude)
- //def this(jarName:String,destinationFunction:(String)=>Path,content:Iterable[Path],manifest:Manifest,jarsToInclude:List[Path]) =
- // this(destinationFunction(jarName),content,manifest,jarsToInclude)
- //def this(jarName:String,destinationFunction:(String)=>Path,content:Iterable[Path]) =
- // this(jarName,destinationFunction,content, new Manifest, Nil)
}
trait Packaging extends Step{
- //def manifest = new Manifest
- //final def simplePath = packagingDestination / jarName
- //final def libPath = packagingDestination /"lib" / jarName
- //def jarDestination:Path = libPath
- //def packagingDestination:Path
- //def jarName:String
- //def jarsToInclude:List[Path] = Nil
- //def jarContent:Iterable[Path]
- def packagingConfig:PackagingConfiguration
-
+ def packagingConfig:PackagingConfiguration
}
trait WrapperPackaging extends Packaging {
diff --git a/project/build/Partest.scala b/project/build/Partest.scala
index b971c668d9..5a6cdc2506 100755
--- a/project/build/Partest.scala
+++ b/project/build/Partest.scala
@@ -1,160 +1,313 @@
-/*
import sbt._
import java.io.File
import java.net.URLClassLoader
+import TestSet.{filter}
+
+class TestSet(val SType:TestSetType.Value,val kind:String, val description:String,val files:Array[File]){
+ /**
+ * @param a list of file that we want to know wheter they are members of the test set or not
+ * @return two lists : the first contains files that are member of the test set, the second contains the files that aren't
+ */
+ def splitContent(f:List[File]):(List[File],List[File]) = {
+ f.partition((f:File) => files.elements.exists((e:File)=> f==e))
+ }
+}
+
+object TestSet {
+ def apply(sType:TestSetType.Value,kind:String,description:String,files:PathFinder)= new TestSet(sType,kind,description,filter(files))
+ def filter(p:PathFinder):Array[File]=( p --- p **(HiddenFileFilter || GlobFilter("*.obj")||GlobFilter("*.log"))).getFiles.toArray
+}
+
+object TestSetType extends Enumeration {
+ val Std,Continuations = Value
+}
+
+class TestConfiguration(val library:Path, val classpath:Iterable[Path], val testRoot:Path,
+ val tests:List[TestSet],val junitReportDir:Option[Path]){
+}
trait PartestRunner{
self: BasicLayer with Packer =>
- import Partest._
+
+ import Partest.{runTest}
+ import TestSetType._
+
+
lazy val testRoot = projectRoot / "test"
- lazy val testFiles = testRoot / "files"
+ lazy val testFiles = testRoot / "files" ##
lazy val testLibs = testFiles / "lib"
- lazy val testSuite= task{
+
+ lazy val posFilesTest = TestSet(Std,"pos", "Compiling files that are expected to build", testFiles / "pos" * ("*.scala" || DirectoryFilter))
+ lazy val negFilesTest = TestSet(Std,"neg", "Compiling files that are expected to fail", testFiles / "neg" * ("*.scala" || DirectoryFilter))
+ lazy val runFilesTest = TestSet(Std,"run", "Compiling and running files", testFiles / "run" ** ("*.scala" ))
+ lazy val jvmFilesTest = TestSet(Std,"jvm", "Compiling and running files", testFiles / "jvm" *("*.scala" || DirectoryFilter))
+ lazy val resFilesTest = TestSet(Std,"res", "Running resident compiler scenarii", testFiles / "res" * ("*.res"))
+ lazy val buildmanagerFilesTest = TestSet(Std,"buildmanager", "Running Build Manager scenarii", testFiles / "buildmanager" * DirectoryFilter)
+ lazy val scalacheckFilesTest = TestSet(Std,"scalacheck", "Running scalacheck tests", testFiles / "scalacheck" ** ("*.scala"))
+ lazy val scriptFilesTest = TestSet(Std,"script", "Running script files", testFiles / "script" * ("*.scala"))
+ lazy val shootoutFilesTest = TestSet(Std,"shootout", "Running shootout tests", testFiles / "shootout" * ("*.scala"))
+ lazy val scalapFilesTest = TestSet(Std,"scalap", "Running scalap tests", testFiles / "scalap" ** ("*.scala"))
+
+ lazy val negContinuationTest = TestSet(Continuations,"neg", "Compiling continuations files that are expected to fail", testFiles / "continuations-neg" * ("*.scala" || DirectoryFilter))
+ lazy val runContinuationTest = TestSet(Continuations,"run", "Compiling and running continuations files", testFiles / "continuations-run" ** ("*.scala" ))
+
+ lazy val continuationScalaOpts = "-Xpluginsdir "+continuationPluginConfig.packagingConfig.jarDestination.asFile.getParent+" -Xplugin-require:continuations -P:continuations:enable"
+
+ lazy val testSuiteFiles:List[TestSet] = List(posFilesTest,negFilesTest,runFilesTest,jvmFilesTest,resFilesTest,buildmanagerFilesTest,scalacheckFilesTest,shootoutFilesTest,scalapFilesTest)
+ lazy val testSuiteContinuation:List[TestSet]=List(negContinuationTest,runContinuationTest)
+
+ private lazy val filesTestMap:Map[String,TestSet] =
+ Map(testSuiteFiles.map(s=> (s.kind,s) ):_*)+ (("continuations-neg",negContinuationTest),("continuations-run",runContinuationTest))
+
+ private lazy val partestOptions = List("-failed")
+
+ private lazy val partestCompletionList = filesTestMap.keys.toList:::partestOptions:::filesTestMap.values.toList.flatMap{_.files.map(_.toString.substring(testFiles.asFile.toString.length+1))}
+
+ private def runPartest(tests:List[TestSet],scalacOpts:Option[String], failedOnly:Boolean) = {
+
val config = new TestConfiguration(
outputLibraryJar,
- (outputLibraryJar +++ outputCompilerJar +++ outputPartestJar +++ outputScalapJar +++ antJar +++ jlineJar +++ (testLibs * "*.jar")).get,
- (testFiles /"pos") * "*.scala",
- (testFiles /"neg") * "*.scala",
- (testFiles / "run") ** "*.scala",
- (testFiles /"jvm") * "*.scala",
- (testFiles / "res") * "*.res",
- (testFiles / "buildmanager"),
- Path.emptyPathFinder,
- (testFiles/ "shootout") * "*.scala",
- (testFiles /"scalap") ** "*.scala"
- )
+ (outputLibraryJar +++ outputCompilerJar +++ outputPartestJar +++ outputScalapJar +++ antJar +++ jlineJar +++ (testLibs * "*.jar")).get,
+ testRoot,
+ tests,
+ None
+ )
+
val javaHome = Path.fromFile(new File(System.getProperty("java.home")))
val java = javaHome / "bin" / "java"
- val javac = javaHome / "bin" / "javac"
-
- runTest(config,Some(java.asFile),Some(javac.asFile),None,Some("2400000"), false,true,false,true,false,log)
+ val javac = javaHome/"bin"/"javac"
+ log.debug("Ready to run tests")
+ if (tests.isEmpty){
+ log.debug("Empty test list")
+ None
+ }else
+ runTest(info.launcher.topLoader,config,Some(java.asFile),Some(javac.asFile),scalacOpts,Some("2400000"), true,true,failedOnly,true,false,log)
}
-}
+ lazy val externalPartest = task {args => task {
+ val runner = new ExternalTaskRunner(projectRoot,this.name, "partest " + args.mkString(" "),"Some tests have failed", log)
+ runner.runTask
+ }.dependsOn(pack)
+ }.completeWith(partestCompletionList)
-class TestConfiguration(val library:Path, val classpath:Iterable[Path],
- posFiles:PathFinder,negFiles:PathFinder,runFiles:PathFinder, jvmFiles:PathFinder,
- residentFiles:PathFinder,buildManagerFiles:PathFinder,scriptFiles:PathFinder,
- shootoutFiles:PathFinder,scalapFiles:PathFinder){
+ lazy val partest = task{
+ args =>
+ var failedOnly = false
- private def getFilesAndDirs(path:PathFinder):Array[File]={
- ( path * AllPassFilter --- (path * ((new ExactFilter(".svn")) || GlobFilter("*.obj")))).getFiles.toArray
- }
+ def setOptions(options:List[String],acc:List[String]):List[String]= options match{
+ case x::xs => x match{
+ case "-failed" => {failedOnly= true; log.info("Only tests that failed previously will be run"); setOptions(xs,acc)}
+ case _ => setOptions(xs,x::acc)
+
+ }
+ case Nil => acc
+ }
- private def getPosFiles = getFilesAndDirs(posFiles)
- private def getNegFiles = getFilesAndDirs(negFiles)
- private def getRunFiles = getFilesAndDirs(runFiles)
- private def getJvmFiles = getFilesAndDirs(jvmFiles)
- private def getResidentFiles = getFilesAndDirs(residentFiles)
- private def getBuildManagerFiles = getFilesAndDirs(buildManagerFiles)
- private def getScriptFiles = getFilesAndDirs(scriptFiles)
- private def getShootoutFiles = getFilesAndDirs(shootoutFiles)
- private def getScalapFiles = getFilesAndDirs(scalapFiles)
-
- lazy val testFileSets = List(
- (getPosFiles, "pos", "Compiling files that are expected to build"),
- (getNegFiles, "neg", "Compiling files that are expected to fail"),
- (getRunFiles, "run", "Compiling and running files"),
- (getJvmFiles, "jvm", "Compiling and running files"),
- (getResidentFiles, "res", "Running resident compiler scenarii"),
- (getBuildManagerFiles, "buildmanager", "Running Build Manager scenarii"),
- (getScriptFiles, "script", "Running script files"),
- (getShootoutFiles, "shootout", "Running shootout tests"),
- (getScalapFiles, "scalap", "Running scalap tests")
- )
+ def resolveSets(l:List[String],rem:List[String],acc:List[TestSet]):(List[String],List[TestSet]) = {
+ def searchSet(arg:String):Option[TestSet] = {
+ filesTestMap.get(arg)
+ }
+ l match{
+ case x::xs => searchSet(x) match{
+ case Some(s)=> resolveSets(xs,rem,s::acc)
+ case None => resolveSets(xs,x::rem,acc)
+ }
+ case Nil => (rem,acc)
+ }
+ }
+
+ def resolveFiles(l:List[String],sets:List[TestSet]):(List[String],List[TestSet]) = {
+ def resolve0(filesToResolve:List[File],setsToSearchIn:List[TestSet],setAcc:List[TestSet]):(List[String],List[TestSet])= {
+ filesToResolve match {
+ case Nil => (Nil,setAcc) // If we have no files left to resolve, we can return the list of the set we have
+ case list => {
+ setsToSearchIn match {
+ case Nil => (list.map(_.toString),setAcc)// If we already had search all sets to find a match, we return the list of the files that where problematic and the set we have
+ case x::xs => {
+ val (found, notFound)=x.splitContent(list)
+ if(!found.isEmpty){
+ val newSet = new TestSet(x.SType,x.kind,x.description,found.toArray)
+ resolve0(notFound,xs,newSet::setAcc)
+ }else{
+ resolve0(notFound,xs,setAcc)
+ }
+ }
+ }
+ }
+ }
+
+ }
+
+
+ resolve0(l.map(Path.fromString(testFiles,_).asFile),filesTestMap.values.toList,sets)
+ }
+
+ val keys = setOptions(args.toList,Nil)
+
+ if (keys.length == 0) task{runPartest(testSuiteFiles,None,failedOnly) orElse runPartest(testSuiteContinuation,None,failedOnly)} // this is the case where there were only config options, we will run the standard test suite
+ else {
+ val (fileNames, sets) =resolveSets(keys,Nil,Nil)
+ val (notFound,allSets)=resolveFiles(fileNames,sets)
+ if (!notFound.isEmpty) log.info("Don't know what to do with : \n"+notFound.mkString("\n"))
+
+ val (std, continuations) = allSets.partition(_.SType == TestSetType.Std)
+ task{runPartest(std,None,failedOnly) orElse runPartest(continuations,Some(continuationScalaOpts),failedOnly)}
+ }
+
+ }.completeWith(partestCompletionList)
+
}
-*/
-/**
- * Based on scala.tools.partest.PartestTask
- */
-/*
-object Partest{
-
- def runTest(config:TestConfiguration,javacmd:Option[File],javaccmd:Option[File],scalacOpts:Option[String],timeout:Option[String],
+
+object Partest {
+ def runTest(parentLoader:ClassLoader, config:TestConfiguration,javacmd:Option[File],javaccmd:Option[File],scalacOpts:Option[String],timeout:Option[String],
showDiff:Boolean,showLog:Boolean,runFailed:Boolean,errorOnFailed:Boolean,debug:Boolean,log:Logger):Option[String] = {
+
if (debug)
System.setProperty("partest.debug", "true")
if (config.classpath.isEmpty)
return Some("The classpath is empty")
+ log.debug("Classpath is "+ config.classpath)
- val classloader = new URLClassLoader(Array(config.classpath.toSeq.map(_.asURL):_*))
-
- val antRunner: AnyRef =
- classloader.loadClass("scala.tools.partest.nest.AntRunner").newInstance().asInstanceOf[AnyRef]
- val antFileManager: AnyRef =
- antRunner.getClass.getMethod("fileManager", Array[Class[_]](): _*).invoke(antRunner, Array[Object](): _*)
+ val classloader = new URLClassLoader(Array(config.classpath.toSeq.map(_.asURL):_*),ClassLoader.getSystemClassLoader.getParent)
+ val runner: AnyRef =
+ classloader.loadClass("scala.tools.partest.nest.SBTRunner").newInstance().asInstanceOf[AnyRef]
+ val fileManager: AnyRef =
+ runner.getClass.getMethod("fileManager", Array[Class[_]](): _*).invoke(runner, Array[Object](): _*)
val runMethod =
- antRunner.getClass.getMethod("reflectiveRunTestsForFiles", Array(classOf[Array[File]], classOf[String]): _*)
+ runner.getClass.getMethod("reflectiveRunTestsForFiles", Array(classOf[Array[File]], classOf[String]): _*)
- def runTestsForFiles(kindFiles: Array[File], kind: String): (Int, Int) = {
- val result = runMethod.invoke(antRunner, Array(kindFiles, kind): _*).asInstanceOf[Int]
- (result >> 16, result & 0x00FF)
+ def runTestsForFiles(kindFiles: Array[File], kind: String) = {
+ val result = runMethod.invoke(runner, Array(kindFiles, kind): _*).asInstanceOf[java.util.HashMap[String,Int]]
+ scala.collection.jcl.Conversions.convertMap(result)
}
def setFileManagerBooleanProperty(name: String, value: Boolean) {
+ log.debug("Setting partest property :"+name+" to :"+value)
val setMethod =
- antFileManager.getClass.getMethod(name+"_$eq", Array(classOf[Boolean]): _*)
- setMethod.invoke(antFileManager, Array(java.lang.Boolean.valueOf(value)).asInstanceOf[Array[Object]]: _*)
+ fileManager.getClass.getMethod(name+"_$eq", Array(classOf[Boolean]): _*)
+ setMethod.invoke(fileManager, Array(java.lang.Boolean.valueOf(value)).asInstanceOf[Array[Object]]: _*)
}
def setFileManagerStringProperty(name: String, value: String) {
+ log.debug("Setting partest property :"+name+" to :"+value)
val setMethod =
- antFileManager.getClass.getMethod(name+"_$eq", Array(classOf[String]): _*)
- setMethod.invoke(antFileManager, Array(value).asInstanceOf[Array[Object]]: _*)
+ fileManager.getClass.getMethod(name+"_$eq", Array(classOf[String]): _*)
+ setMethod.invoke(fileManager, Array(value).asInstanceOf[Array[Object]]: _*)
}
+ System.setProperty("partest.srcdir",config.testRoot.absolutePath)
+
setFileManagerBooleanProperty("showDiff", showDiff)
setFileManagerBooleanProperty("showLog", showLog)
setFileManagerBooleanProperty("failed", runFailed)
if (!javacmd.isEmpty)
setFileManagerStringProperty("JAVACMD", javacmd.get.getAbsolutePath)
if (!javaccmd.isEmpty)
- setFileManagerStringProperty("JAVAC_CMD", javaccmd.get.getAbsolutePath)
- setFileManagerStringProperty("CLASSPATH", config.classpath.mkString(File.pathSeparator))
+ setFileManagerStringProperty("JAVAC_CMD", "javac")
+ setFileManagerStringProperty("CLASSPATH",(config.classpath.map(_.absolutePath).mkString(File.pathSeparator)))
setFileManagerStringProperty("LATEST_LIB", config.library.absolutePath)
- if (!scalacOpts.isEmpty)
- setFileManagerStringProperty("SCALAC_OPTS", scalacOpts.get)
+ scalacOpts match {
+ case None => setFileManagerStringProperty("SCALAC_OPTS","")
+ case Some(options) => setFileManagerStringProperty("SCALAC_OPTS",options)
+ }
if (!timeout.isEmpty)
setFileManagerStringProperty("timeout", timeout.get)
type TFSet = (Array[File], String, String)
- val testFileSets = config.testFileSets
+ val testFileSets = config.tests
+
+ def resultsToStatistics(results: Iterable[(_, Int)]): (Int, Int) = {
+ val (files, failures) = results map (_._2 == 0) partition (_ == true)
+ def count(i:Iterable[_]):Int={
+ var c = 0
+ for (elem <-i) yield{
+ c=c+1
+ }
+ c
+ }
+ (count(files), count(failures))
+ }
+
- def runSet(set: TFSet): (Int, Int) = {
- val (files, name, msg) = set
- if (files.isEmpty) (0, 0)
+ def runSet(set: TestSet): (Int, Int,Iterable[String]) = {
+ val (files, name, msg) = (set.files, set.kind, set.description)
+ log.debug("["+name+"] "+ msg+files.mkString(", files :\n","\n",""))
+ if (files.isEmpty) {
+ log.debug("No files !")
+ (0, 0, List())
+ }
else {
- log.info(msg)
- runTestsForFiles(files, name)
+ log.info(name +" : "+ msg)
+ val results: Iterable[(String, Int)] = runTestsForFiles(files, name)
+ val (succs, fails) = resultsToStatistics(results)
+
+ val failed: Iterable[String] = results.filter( _._2!=0) map(_ match {
+ case (path, 1) => path + " [FAILED]"
+ case (path, 2) => path + " [TIMOUT]"
+ })
+
+ val r=(succs, fails, failed)
+
+ config.junitReportDir match{
+ case Some(d)=> {
+ val report = testReport(name, results, succs, fails)
+ scala.xml.XML.save(d/name+".xml", report)
+ }
+ case None =>
+ }
+
+ r
}
}
val _results = testFileSets map runSet
- val allSuccesses = (_results map (_._1)).foldLeft(0)(_+_)
- val allFailures = (_results map (_._2)).foldLeft(0)(_+_)
+ val allSuccesses = _results.map (_._1).foldLeft(0)( _ + _ )
+ val allFailures = _results.map (_._2).foldLeft(0)( _ + _ )
+ val allFailedPaths = _results flatMap (_._3)
+
def f(msg:String):Option[String] =
- if (errorOnFailed && allFailures > 0) Some(msg)
+ if (errorOnFailed && allFailures > 0) {
+ Some(msg)
+ }
else {
log.info(msg)
None
}
def s = if (allFailures > 1) "s" else ""
val msg =
- if (allFailures > 0) "Test suite finished with %d case%s failing.".format(allFailures, s)
+ if (allFailures > 0) "Test suite finished with %d case%s failing.\n".format(allFailures, s)+ allFailedPaths.mkString("\n")
else if (allSuccesses == 0) "There were no tests to run."
else "Test suite finished with no failures."
f(msg)
+
}
+ private def oneResult(res: (String, Int)) =
+ <testcase name={res._1}>{
+ res._2 match {
+ case 0 => scala.xml.NodeSeq.Empty
+ case 1 => <failure message="Test failed"/>
+ case 2 => <failure message="Test timed out"/>
+ }
+ }</testcase>
-}*/
+ private def testReport(kind: String, results: Iterable[(String, Int)], succs: Int, fails: Int) =
+ <testsuite name={kind} tests={(succs + fails).toString} failures={fails.toString}>
+ <properties/>
+ {
+ results.map(oneResult(_))
+ }
+ </testsuite>
+
+
+}
diff --git a/project/build/ScalaSBTBuilder.scala b/project/build/ScalaSBTBuilder.scala
index 2720e82c82..c741f3710c 100644
--- a/project/build/ScalaSBTBuilder.scala
+++ b/project/build/ScalaSBTBuilder.scala
@@ -9,6 +9,7 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectivePro
override def dependencies: Iterable[Project] = info.dependencies ++ locker.dependencies ++ quick.dependencies ++ strap.dependencies ++ libs.dependencies
override def shouldCheckOutputDirectories = false
+ override def watchPaths = info.projectPath / "src" ** ("*.scala" || "*.java"||AdditionalResources.basicFilter) // Support of triggered execution at top level
// Top Level Tasks
lazy val build = task{None}.dependsOn(quick.binPack,quick.binQuick)
lazy val clean = locker.clean
@@ -23,6 +24,8 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectivePro
lazy val newFjbg = libs.newFjbg
lazy val buildMsil = libs.buildMsil
lazy val newMsil = libs.newMsil
+ lazy val partest = quick.externalPartest
+ lazy val testSuite = strap.testSuite
@@ -155,7 +158,7 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectivePro
* Definition of what is specific to the quick layer. It implements Packer in order to create pack, ScalaTools
* for creating the binaries and Scaladoc to generate the documentation
*/
- class QuickLayer(info:ProjectInfo, previous:BasicLayer) extends BasicLayer(info,versionNumber,Some(previous))
+ class QuickLayer(info:ProjectInfo, previous:BasicLayer) extends BasicLayer(info,versionNumber,Some(previous)) with PartestRunner
with Packer with ScalaTools with Scaladoc{
override lazy val nextLayer=Some(strap)
@@ -173,7 +176,7 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectivePro
- override lazy val libraryWS = new WrapperStep(libraryConfig::actorsConfig::dbcConfig::swingConfig::Nil)with Packaging{
+ override lazy val libraryWS = new WrapperStep(libraryConfig::actorsConfig::dbcConfig::swingConfig::Nil) with Packaging{
def jarContent = List(libraryConfig , actorsConfig, continuationLibraryConfig).map(_.outputDirectory ##)
lazy val starrJarContent=List(libraryConfig , actorsConfig,dbcConfig,swingConfig, continuationLibraryConfig).map(_.outputDirectory ##)
lazy val packagingConfig = new PackagingConfiguration(libsDestination/libraryJarName,jarContent,libraryAdditionalJars)
@@ -189,7 +192,7 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectivePro
compile(libraryConfig, cleanCompilation _)
}
lazy val externalCompileLibraryOnly = task{
- val runner = new ExternalTaskRunner(projectRoot,this.name,compileLibraryOnly.name, log)
+ val runner = new ExternalTaskRunner(projectRoot,this.name,compileLibraryOnly.name,"Error during external compilation", log)
runner.runTask
}.dependsOn(startLayer)
@@ -215,6 +218,7 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectivePro
+
/*
* Defining here the creation of the binaries for quick and pack
*/
@@ -234,6 +238,7 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectivePro
lazy val instantiationCompilerJar = previous.compilerOutput
lazy val instantiationLibraryJar = previous.libraryOutput
+ private val quick = previous
override lazy val libraryWS = new WrapperStep(libraryConfig::actorsConfig::dbcConfig::swingConfig::Nil) with WrapperPackaging{
lazy val packagingConfig = new PackagingConfiguration(libsDestination/libraryJarName,Set())
@@ -242,6 +247,18 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectivePro
override lazy val toolsWS= new WrapperStep(scalapConfig::partestConfig::Nil)
+
+
+ def compare = {
+ import PathConfig.classes
+ def filter(path:Path)= path.descendentsExcept(AllPassFilter, HiddenFileFilter || "*.properties")
+ Comparator.compare(this.pathLayout.outputDir/classes ##,quick.pathLayout.outputDir/classes ##, filter _ ,log)
+ }
+
+ lazy val testSuite=task{
+ compare
+ }
+
}
@@ -251,6 +268,8 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectivePro
*/
class LibsBuilder(val info:ProjectInfo) extends ScalaBuildProject with ReflectiveProject with Compilation with BuildInfoEnvironment {
override def dependencies = info.dependencies
+ override def watchPaths = info.projectPath / "src" ** ("*.scala" || "*.java"||AdditionalResources.basicFilter) // Support of triggered execution at project level
+
def buildInfoEnvironmentLocation:Path=outputRootPath / ("build-"+name+".properties")
@@ -260,8 +279,8 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectivePro
def libsDestination = layerOutput
lazy val checkJavaVersion = task{
- val version = System.getProperty("java.specification.version")
- log.debug("java.specification.version="+version)
+ val version = System.getProperty("java.version")
+ log.debug("java.version="+version)
val required = "1.6"
if (version.startsWith(required)) None else Some("Incompatible java version : required "+required)
}
diff --git a/project/build/Scaladoc.scala b/project/build/Scaladoc.scala
index d96fd4e3ae..fc64e43c17 100644
--- a/project/build/Scaladoc.scala
+++ b/project/build/Scaladoc.scala
@@ -35,7 +35,7 @@ trait Scaladoc{
}
lazy val scaladoc = task{
- val externalSbt = new ExternalTaskRunner(projectRoot,this.name,generateScaladoc.name,log)
+ val externalSbt = new ExternalTaskRunner(projectRoot,this.name,generateScaladoc.name,"Error generating the scaladoc",log)
externalSbt.runTask
}.dependsOn(pack)