summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2011-01-17 15:18:03 +0000
committerAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2011-01-17 15:18:03 +0000
commitbe2778d50f1a73a941c6ffe6355f0ed401d6d8eb (patch)
tree54cd12023d74a8e172b68106911036c7e32a2321 /src
parentcf820b8907e60214df974a3b2a88ca0a7e877298 (diff)
downloadscala-be2778d50f1a73a941c6ffe6355f0ed401d6d8eb.tar.gz
scala-be2778d50f1a73a941c6ffe6355f0ed401d6d8eb.tar.bz2
scala-be2778d50f1a73a941c6ffe6355f0ed401d6d8eb.zip
Added 'specialized' tests.
Added a new test group - specialized. Modified partest to add a jar with instrumented classes to classpath when compiling and running tests. Added a primary version of the instrumented BoxesRuntime, and a script to produce a jar for it. Added the 'speclib' folder to partest files, which contains the jar with the instrumented classes. Review by dragos.
Diffstat (limited to 'src')
-rw-r--r--src/partest/scala/tools/partest/nest/CompileManager.scala15
-rw-r--r--src/partest/scala/tools/partest/nest/DirectRunner.scala2
-rw-r--r--src/partest/scala/tools/partest/nest/PathSettings.scala7
-rw-r--r--src/partest/scala/tools/partest/nest/TestFile.scala8
-rw-r--r--src/partest/scala/tools/partest/nest/Worker.scala18
5 files changed, 40 insertions, 10 deletions
diff --git a/src/partest/scala/tools/partest/nest/CompileManager.scala b/src/partest/scala/tools/partest/nest/CompileManager.scala
index 6a30aa32af..4010f1eadd 100644
--- a/src/partest/scala/tools/partest/nest/CompileManager.scala
+++ b/src/partest/scala/tools/partest/nest/CompileManager.scala
@@ -84,13 +84,14 @@ class DirectCompiler(val fileManager: FileManager) extends SimpleCompiler {
val testRep: ExtConsoleReporter = global.reporter.asInstanceOf[ExtConsoleReporter]
val testFileFn: (File, FileManager) => TestFile = kind match {
- case "pos" => PosTestFile.apply
- case "neg" => NegTestFile.apply
- case "run" => RunTestFile.apply
- case "jvm" => JvmTestFile.apply
- case "shootout" => ShootoutTestFile.apply
- case "scalap" => ScalapTestFile.apply
- case "scalacheck" => ScalaCheckTestFile.apply
+ case "pos" => PosTestFile.apply
+ case "neg" => NegTestFile.apply
+ case "run" => RunTestFile.apply
+ case "jvm" => JvmTestFile.apply
+ case "shootout" => ShootoutTestFile.apply
+ case "scalap" => ScalapTestFile.apply
+ case "scalacheck" => ScalaCheckTestFile.apply
+ case "specialized" => SpecializedTestFile.apply
}
val test: TestFile = testFileFn(files.head, fileManager)
test.defineSettings(command.settings, out.isEmpty)
diff --git a/src/partest/scala/tools/partest/nest/DirectRunner.scala b/src/partest/scala/tools/partest/nest/DirectRunner.scala
index ce35a830cb..2b0c55d4d7 100644
--- a/src/partest/scala/tools/partest/nest/DirectRunner.scala
+++ b/src/partest/scala/tools/partest/nest/DirectRunner.scala
@@ -61,7 +61,7 @@ trait DirectRunner {
}
def runTestsForFiles(_kindFiles: List[File], kind: String): immutable.Map[String, Int] = {
- /** NO DUPLICATES, or partest will blow the count and hang forever. **/
+ /** NO DUPLICATES, or partest will blow the count and hang forever. */
val kindFiles = _kindFiles.distinct
val groupSize = (kindFiles.length / numActors) + 1
diff --git a/src/partest/scala/tools/partest/nest/PathSettings.scala b/src/partest/scala/tools/partest/nest/PathSettings.scala
index 888df04dec..62341a908a 100644
--- a/src/partest/scala/tools/partest/nest/PathSettings.scala
+++ b/src/partest/scala/tools/partest/nest/PathSettings.scala
@@ -31,6 +31,13 @@ object PathSettings {
// Directory <root>/test/files/lib
lazy val srcLibDir = Directory(srcDir / "lib")
+ // Directory <root>/test/files/speclib
+ lazy val srcSpecLibDir = Directory(srcDir / "speclib")
+
+ lazy val srcSpecLib: File = srcSpecLibDir.files find (_.name startsWith "instrumented") getOrElse {
+ sys.error("No instrumented.jar found in %s".format(srcSpecLibDir))
+ }
+
// Directory <root>/build
lazy val buildDir: Directory = {
val bases = testRoot :: testRoot.parents
diff --git a/src/partest/scala/tools/partest/nest/TestFile.scala b/src/partest/scala/tools/partest/nest/TestFile.scala
index 741556fdd5..3eddb9da69 100644
--- a/src/partest/scala/tools/partest/nest/TestFile.scala
+++ b/src/partest/scala/tools/partest/nest/TestFile.scala
@@ -10,6 +10,7 @@ package nest
import java.io.{ File => JFile }
import scala.tools.nsc.Settings
+import scala.tools.nsc.util.ClassPath
import scala.tools.nsc.io._
abstract class TestFile(kind: String) {
@@ -47,3 +48,10 @@ case class ShootoutTestFile(file: JFile, fileManager: FileManager) extends TestF
case class ScalapTestFile(file: JFile, fileManager: FileManager) extends TestFile("scalap") {
override def setOutDirTo = file.parent
}
+case class SpecializedTestFile(file: JFile, fileManager: FileManager) extends TestFile("specialized") {
+ override def defineSettings(settings: Settings, setOutDir: Boolean) = {
+ super.defineSettings(settings, setOutDir)
+ // add the instrumented library version to classpath
+ settings.classpath.value = ClassPath.join(PathSettings.srcSpecLib.toString, settings.classpath.value)
+ }
+}
diff --git a/src/partest/scala/tools/partest/nest/Worker.scala b/src/partest/scala/tools/partest/nest/Worker.scala
index 73a09b4733..f6991b468b 100644
--- a/src/partest/scala/tools/partest/nest/Worker.scala
+++ b/src/partest/scala/tools/partest/nest/Worker.scala
@@ -273,7 +273,7 @@ class Worker(val fileManager: FileManager, params: TestRunParams) extends Actor
(command #> output !)
}
- def execTest(outDir: File, logFile: File, fileBase: String) {
+ def execTest(outDir: File, logFile: File, fileBase: String, classpathPrefix: String = "") {
// check whether there is a ".javaopts" file
val argsFile = new File(logFile.getParentFile, fileBase + ".javaopts")
val argString = file2String(argsFile)
@@ -299,12 +299,13 @@ class Worker(val fileManager: FileManager, params: TestRunParams) extends Actor
"-Duser.language=en -Duser.country=US"
) ++ extras
+ val classpath = if (classpathPrefix != "") join(classpathPrefix, CLASSPATH) else CLASSPATH
val cmd = (
List(
JAVACMD,
JAVA_OPTS,
argString,
- "-classpath " + join(outDir.toString, CLASSPATH)
+ "-classpath " + join(outDir.toString, classpath)
) ++ propertyOptions ++ List(
"scala.tools.nsc.MainGenericRunner",
"-usejavacp",
@@ -502,6 +503,16 @@ class Worker(val fileManager: FileManager, params: TestRunParams) extends Actor
diffCheck(compareOutput(dir, fileBase, kind, logFile))
})
+ def runSpecializedTest(file: File, kind: String): LogContext =
+ runTestCommon(file, kind, expectFailure = false)((logFile, outDir) => {
+ val fileBase = basename(file.getName)
+ val dir = file.getParentFile
+
+ // adding the instrumented library to the classpath
+ execTest(outDir, logFile, fileBase, PathSettings.srcSpecLib.toString)
+ diffCheck(compareOutput(dir, fileBase, kind, logFile))
+ })
+
def processSingleFile(file: File): LogContext = kind match {
case "scalacheck" =>
val succFn: (File, File) => Boolean = { (logFile, outDir) =>
@@ -555,6 +566,9 @@ class Worker(val fileManager: FileManager, params: TestRunParams) extends Actor
case "run" | "jvm" =>
runJvmTest(file, kind)
+ case "specialized" =>
+ runSpecializedTest(file, kind)
+
case "buildmanager" =>
val logFile = createLogFile(file, kind)
if (!fileManager.failed || logFile.canRead) {