summaryrefslogtreecommitdiff
path: root/project
diff options
context:
space:
mode:
authormoix <moix@epfl.ch>2010-09-07 09:38:32 +0000
committermoix <moix@epfl.ch>2010-09-07 09:38:32 +0000
commit4dcc11418333491b4cb2ed8429e723c42034699d (patch)
treed8c37411a391b5045b36ad2be2ae86e0929c3551 /project
parent441956b5230a8e9389cdc4a78362c842ba9731ea (diff)
downloadscala-4dcc11418333491b4cb2ed8429e723c42034699d.tar.gz
scala-4dcc11418333491b4cb2ed8429e723c42034699d.tar.bz2
scala-4dcc11418333491b4cb2ed8429e723c42034699d.zip
Stability testing task added.
Diffstat (limited to 'project')
-rw-r--r--project/build/AdditionalResources.scala16
-rw-r--r--project/build/BasicLayer.scala26
-rw-r--r--project/build/Comparator.scala72
-rw-r--r--project/build/Packer.scala2
-rw-r--r--project/build/SVN.scala9
-rw-r--r--project/build/ScalaSBTBuilder.scala84
6 files changed, 144 insertions, 65 deletions
diff --git a/project/build/AdditionalResources.scala b/project/build/AdditionalResources.scala
index bf1baf3e6b..b9be967fa6 100644
--- a/project/build/AdditionalResources.scala
+++ b/project/build/AdditionalResources.scala
@@ -10,19 +10,6 @@ import AdditionalResources._
trait AdditionalResources {
self : BasicLayer =>
- /* lazy val copyAdditionalFiles = task {
- def copy0(steps:List[Step]):Option[String]= steps match{
- case x::xs => x match{
- case c:ResourcesToCopy => {
- c.copy orElse copy0(xs)
- }
- case _ => copy0(xs)
- }
- case Nil => None
- }
- copy0(allSteps.topologicalSort)
- }.dependsOn(externalCompilation)*/
-
def writeProperties: Option[String] = {
def write0(steps:List[Step]):Option[String]= steps match{
case x::xs => x match{
@@ -35,9 +22,6 @@ trait AdditionalResources {
}
write0(allSteps.topologicalSort)
}
-
-
-
}
object AdditionalResources {
diff --git a/project/build/BasicLayer.scala b/project/build/BasicLayer.scala
index b315f8e0ef..ee2f5dc681 100644
--- a/project/build/BasicLayer.scala
+++ b/project/build/BasicLayer.scala
@@ -18,18 +18,22 @@ 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
-
+ // Support of triggered execution at project level
+ override def watchPaths = info.projectPath / "src" ** ("*.scala" || "*.java"|| AdditionalResources.basicFilter)
override def dependencies = info.dependencies
lazy val copyright = property[String]
lazy val partestVersionNumber = property[Version]
lazy val nextLayer:Option[BasicLayer]=None
+ def packingDestination :Path = layerOutput / "pack"
lazy val libsDestination=packingDestination/"lib"
lazy val packedStarrOutput=outputRootPath / "pasta"
lazy val requiredPluginsDirForCompilation = layerOutput / "misc" / "scala-devel" / "plugins"
+ def compilerAdditionalJars: List[Path] = Nil
+ def libraryAdditionalJars: List[Path] = Nil
+
// TASKS
@@ -268,25 +272,11 @@ abstract class BasicLayer(val info:ProjectInfo,val versionNumber:String, previou
// Grouping compilation steps
- def minimalCompilation = false // It must be true for locker because we do not nedd to compile everything
+ def minimalCompilation = false // It must be true for locker because we do not need to compile everything
def libraryWS:WrapperStep with Packaging
def toolsWS:WrapperStep
lazy val pluginsWS = new WrapperStep(continuationPluginConfig::continuationLibraryConfig::Nil)
lazy val allSteps = new WrapperStep(libraryWS::compilerConfig::pluginsWS::toolsWS::Nil)
-
-
-
-
- //Paths location that must be defined layer by layer
- /*
- * We must define which are the libraries used to instantiate the compiler
- * that will be used to compile this layer.
- */
- def packingDestination :Path = layerOutput / "pack"
- def compilerAdditionalJars: List[Path] = Nil
- def libraryAdditionalJars: List[Path] = Nil
-
-
- }
+}
diff --git a/project/build/Comparator.scala b/project/build/Comparator.scala
new file mode 100644
index 0000000000..8b5d65d157
--- /dev/null
+++ b/project/build/Comparator.scala
@@ -0,0 +1,72 @@
+import sbt._
+import java.io.{File,FileInputStream}
+
+// Based on scala.tools.ant.Same
+object Comparator {
+
+ private def getMappedPath(path:Path,baseDirectory:Path):Path= {
+ Path.fromString(baseDirectory,path.relativePath)
+ }
+
+
+ def compare(origin:Path,dest:Path,filter:Path=>PathFinder,log:Logger):Option[String] = {
+ log.info("Comparing the contents of "+origin.absolutePath+ " with "+dest.absolutePath)
+ var allEqualNow = true
+
+ def reportDiff(f1: File, f2: File) = {
+ allEqualNow = false
+ log.error("File '" + f1 + "' is different from correspondant.")
+ }
+
+ def reportMissing(f1: File) = {
+ allEqualNow = false
+ log.error("File '" + f1 + "' has no correspondant.")
+ }
+
+
+
+ val originPaths = filter(origin).get
+
+ val bufferSize = 1024
+ val originBuffer = new Array[Byte](bufferSize)
+ val destBuffer = new Array[Byte](bufferSize)
+
+ for (originPath <- originPaths.filter(! _.isDirectory)){
+ log.debug("origin :" + originPath.absolutePath)
+ val destPath = getMappedPath(originPath,dest)
+ log.debug("dest :" + destPath.absolutePath)
+ var equalNow = true
+ val originFile = originPath.asFile
+ val destFile = destPath.asFile
+
+ if (originFile.canRead && destFile.canRead) {
+
+ val originStream = new FileInputStream(originFile)
+ val destStream = new FileInputStream(destFile)
+ var originRemaining = originStream.read(originBuffer)
+ var destRemaining = destStream.read(destBuffer)
+ while (originRemaining > 0 && equalNow) {
+ if (originRemaining == destRemaining)
+ for (idx <- 0 until originRemaining) {
+ equalNow = equalNow && (originBuffer(idx) == destBuffer(idx))}
+ else
+ equalNow = false
+ originRemaining = originStream.read(originBuffer)
+ destRemaining = destStream.read(destBuffer)
+ }
+ if (destRemaining > 0) equalNow = false
+
+ if (!equalNow) reportDiff(originFile, destFile)
+
+ originStream.close
+ destStream.close
+
+ }
+ else reportMissing(originFile)
+
+ }
+ if(allEqualNow) None else Some("There were differences between "+origin.absolutePath+ " and "+ dest.absolutePath)
+ }
+
+
+}
diff --git a/project/build/Packer.scala b/project/build/Packer.scala
index 196056ca38..92df80299b 100644
--- a/project/build/Packer.scala
+++ b/project/build/Packer.scala
@@ -83,6 +83,8 @@ trait Packer {
}
lazy val pack=task{packF}.dependsOn(finishLayer)
}
+
+
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)
diff --git a/project/build/SVN.scala b/project/build/SVN.scala
index e05c949587..2d9fb9259b 100644
--- a/project/build/SVN.scala
+++ b/project/build/SVN.scala
@@ -12,11 +12,10 @@ class SVN(root: Path) {
/**
* Gets the revision number of the repository given through the constructor of the class
- * It assumes that svn is installed on the running computer.
+ * It assumes that svn or git is installed on the running computer. Return 0 if it was not
+ * able to found the revision number
*/
- def getRevisionNumber: Int = getSvn orElse getGit getOrElse {
- throw new UnableToGetRevisionNumberException
- }
+ def getRevisionNumber: Int = getSvn orElse getGit getOrElse 0
def getSvn: Option[Int] = {
val svnInfo = Process("svn info", root)
val out = new ByteArrayOutputStream
@@ -36,5 +35,3 @@ class SVN(root: Path) {
try { Some(Process(GitSvnRevTool.toString, root).!!.trim.toInt) }
catch { case _: Exception => None }
}
-
-class UnableToGetRevisionNumberException extends RuntimeException \ No newline at end of file
diff --git a/project/build/ScalaSBTBuilder.scala b/project/build/ScalaSBTBuilder.scala
index 1d04c69052..530a1ca538 100644
--- a/project/build/ScalaSBTBuilder.scala
+++ b/project/build/ScalaSBTBuilder.scala
@@ -1,5 +1,6 @@
import sbt._
import ScalaBuildProject._
+import ScalaSBTBuilder._
/**
* This class is the entry point for building scala with SBT.
@@ -11,22 +12,22 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectivePro
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
- lazy val docs = quick.scaladoc
- lazy val palo = locker.pack
- lazy val pasta = quick.pasta
- lazy val newStarr = quick.newStarr
- lazy val newLocker=locker.newLocker
- lazy val buildForkjoin=libs.buildForkjoin
- lazy val newForkjoin = libs.newForkjoin
- lazy val buildFjbg = libs.buildFjbg
- lazy val newFjbg = libs.newFjbg
- lazy val buildMsil = libs.buildMsil
- lazy val newMsil = libs.newMsil
- lazy val partest = quick.externalPartest
-
-
+ lazy val build = task{None}.dependsOn(quick.binPack,quick.binQuick).describedAs(buildTaskDescription)
+ lazy val clean = quick.clean.dependsOn(libs.clean).describedAs(cleanTaskDescription)
+ lazy val cleanAll = locker.clean.dependsOn(libs.clean).describedAs(cleanAllTaskDescription)
+ lazy val docs = quick.scaladoc.describedAs(docsTaskDescription)
+ lazy val palo = locker.pack.describedAs(paloTaskDescription)
+ lazy val pasta = quick.pasta.describedAs(pastaTaskDescription)
+ lazy val newStarr = quick.newStarr.describedAs(newStarrTaskDescription)
+ lazy val newLocker=locker.newLocker.describedAs(newLockerTaskDescription)
+ lazy val buildForkjoin=libs.buildForkjoin.describedAs(buildForkjoinTaskDescription)
+ lazy val newForkjoin = libs.newForkjoin.describedAs(newForkjoinTaskDescription)
+ lazy val buildFjbg = libs.buildFjbg.describedAs(buildFjbgTaskDescription)
+ lazy val newFjbg = libs.newFjbg.describedAs(newFjbgTaskDescription)
+ lazy val buildMsil = libs.buildMsil.describedAs(buildMislTaskDescription)
+ lazy val newMsil = libs.newMsil.describedAs(newMsilTaskDescription)
+ lazy val partest = quick.externalPartest.describedAs(partestTaskDescription)
+ lazy val stabilityTest = strap.stabilityTest.describedAs(stabilityTestTaskDescription)
// Top level variables
@@ -40,8 +41,9 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectivePro
import java.util.Calendar;
import java.text.SimpleDateFormat;
val formatString = "yyyyMMddHHmmss"
- new SimpleDateFormat(formatString) format( Calendar.getInstance.getTime)
+ new SimpleDateFormat(formatString) format(Calendar.getInstance.getTime)
}
+
def getVersion:String ={
val version:String = projectVersion.value.toString
val stopIndex = version.lastIndexOf('-')
@@ -50,6 +52,7 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectivePro
case i => version substring(0,i)
}
}
+
def getRevision:Int = {
new SVN(info.projectPath).getRevisionNumber
}
@@ -138,11 +141,7 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectivePro
override lazy val packingDestination:Path = outputRootPath /"palo"
- /**
- * We must override the compilation steps as we only want to compile
- * the core library (and not actors,dbc, scalap, partest)
- */
- override lazy val libraryWS = {
+ override lazy val libraryWS = {
new WrapperStep(libraryConfig::Nil) with WrapperPackaging{
lazy val packagingConfig = new PackagingConfiguration(libsDestination/libraryJarName, jarContent)
}
@@ -173,6 +172,7 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectivePro
override def compilerAdditionalJars = msilJar::fjbgJar::Nil
override def libraryAdditionalJars = forkJoinJar::Nil
+ override def cleaningList = packedStarrOutput::super.cleaningList
override lazy val libraryWS = new WrapperStep(libraryConfig::actorsConfig::dbcConfig::swingConfig::Nil) with Packaging{
@@ -247,6 +247,17 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectivePro
override lazy val toolsWS= new WrapperStep(scalacheckConfig::scalapConfig::partestConfig::Nil)
+ def compare = {
+ import PathConfig.classes
+ def filter(path:Path)= path.descendentsExcept(AllPassFilter, HiddenFileFilter || "*.properties")
+ Comparator.compare(quick.pathLayout.outputDir/classes ##,this.pathLayout.outputDir/classes ##, filter _ ,log)
+ }
+
+ lazy val stabilityTest=task{
+ log.warn("Stability test must be runned on a clean build in order to yield correct results.")
+ compare
+ }.dependsOn(finishLayer)
+
}
@@ -298,8 +309,6 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectivePro
def options = Seq()
override def javaOptions = Seq("-target","1.5","-source","1.5","-g")
lazy val packagingConfig = new PackagingConfiguration(libsDestination/forkjoinJarName,List(outputDirectory ##))
-
- // TODO Verify java options
}
lazy val fjbgConfig = new CompilationStep("fjbg",pathLayout,log) with Packaging{
@@ -322,5 +331,30 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectivePro
lazy val packagingConfig = new PackagingConfiguration(libsDestination/msilJarName,List(outputDirectory ##))
}
+
+ def cleaningList=layerOutput::layerEnvironment.envBackingPath::Nil
+
+ def cleanFiles = FileUtilities.clean(cleaningList,true,log)
+
+ lazy val clean:Task = task{cleanFiles}// We use super.task, so cleaning is done in every case, even when locked
+
}
- }
+}
+object ScalaSBTBuilder {
+ val buildTaskDescription = "build locker, lock it, build quick and create pack. It is the equivalent command to 'ant build'."
+ val cleanTaskDescription = "clean the outputs of quick and strap. locker remains untouched."
+ val cleanAllTaskDescription = "same as clean, but in addition clean locker too."
+ val docsTaskDescription = "generate the scaladoc"
+ val partestTaskDescription = "run partest"
+ val stabilityTestTaskDescription = "run stability testing. It is required to use a clean build (for example, execute the clean-all action) in order to ensure correctness of the result."
+ val paloTaskDescription = "create palo"
+ val pastaTaskDescription = "create all the jar needed to make a new starr from quick (pasta = packed starr). It does not replace the current library and compiler jars in the libs folder, but the products of the task are instead located in target/pasta"
+ val newStarrTaskDescription = "create a new starr and replace the library and compiler jars in the libs folder. It will keep locker locker locked, meaning that if you want to update locker after updating starr, you must run the 'new-locker' command. It will not automatically run partest and stability testing before replacing."
+ val newLockerTaskDescription = "replace locker. It will build a new locker. It does not automatically rebuild quick."
+ val buildForkjoinTaskDescription = "create all the jar needed to make a new forkjoin. It does not replace the current library and compiler jars in the libs folder, but the products of the task are instead located in target/libs."
+ val newForkjoinTaskDescription = "create a new forkjoin and replace the corresponding jar in the libs folder."
+ val buildFjbgTaskDescription = "create all the jar needed to make a new fjbg. It does not replace the current library and compiler jars in the libs folder, but the products of the task are instead located in target/libs."
+ val newFjbgTaskDescription = "create a new fjbg and replace the corresponding jar in the libs folder."
+ val buildMislTaskDescription = "create all the jar needed to make a new msil. It does not replace the current library and compiler jars in the libs folder, but the products of the task are instead located in target/libs."
+ val newMsilTaskDescription = "create a msil and replace the corresponding jar in the libs folder."
+}