summaryrefslogtreecommitdiff
path: root/src/partest
diff options
context:
space:
mode:
authorPhilipp Haller <hallerp@gmail.com>2008-09-15 17:43:28 +0000
committerPhilipp Haller <hallerp@gmail.com>2008-09-15 17:43:28 +0000
commited1c45477fb4ba2ad98fcc9418d2258cbaf410f9 (patch)
tree400c6e3bd45830fedf6b73a52d27a5db963d1b00 /src/partest
parentc3d3f0d3ddef1e2557be7a6d30e6560601243052 (diff)
downloadscala-ed1c45477fb4ba2ad98fcc9418d2258cbaf410f9.tar.gz
scala-ed1c45477fb4ba2ad98fcc9418d2258cbaf410f9.tar.bz2
scala-ed1c45477fb4ba2ad98fcc9418d2258cbaf410f9.zip
Added option to select test source dir.
Diffstat (limited to 'src/partest')
-rw-r--r--src/partest/scala/tools/partest/nest/ConsoleFileManager.scala34
-rw-r--r--src/partest/scala/tools/partest/nest/ConsoleRunner.scala13
-rw-r--r--src/partest/scala/tools/partest/nest/NestUI.scala5
-rw-r--r--src/partest/scala/tools/partest/nest/Worker.scala17
4 files changed, 41 insertions, 28 deletions
diff --git a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala
index 224bbc5aa9..85bd103b09 100644
--- a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala
+++ b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala
@@ -86,10 +86,31 @@ else
}
val TESTROOT = testRootFile.getAbsolutePath
+ var srcDirName: String = ""
+
+ val srcDir: File = {
+ val srcDirProp = System.getProperty("partest.srcdir")
+ val src =
+ if (srcDirProp != null) {
+ srcDirName = srcDirProp
+ new File(testRootFile, srcDirName)
+ } else {
+ srcDirName = "files"
+ new File(testRootFile, srcDirName)
+ }
+ if (src.isDirectory)
+ src.getCanonicalFile
+ else {
+ val path = TESTROOT + File.separator + "files"
+ NestUI.failure("Source directory \"" + path + "\" not found")
+ exit(1)
+ }
+ }
+
LIB_DIR = (new File(testRootFile.getParentFile, "lib")).getCanonicalFile.getAbsolutePath
CLASSPATH = CLASSPATH + File.pathSeparator + {
- val libs = new File(TESTROOT, "files/lib")
+ val libs = new File(srcDir, "lib")
// add all jars in libs
(libs.listFiles(new FilenameFilter {
def accept(dir: File, name: String) = name endsWith ".jar"
@@ -249,17 +270,6 @@ else
// initialize above fields
findLatest()
- val srcDir: File = {
- val src = new File(TESTROOT, "files")
- if (src.isDirectory)
- src.getCanonicalFile
- else {
- val path = TESTROOT + File.separator + "files"
- NestUI.failure("Source directory \"" + path + "\" not found")
- exit(1)
- }
- }
-
var testFiles: List[File] = List()
def getFiles(kind: String, doCheck: Boolean, filter: Option[(String, Boolean)]): List[File] = {
diff --git a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala
index 5f89e029a4..efea481609 100644
--- a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala
+++ b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala
@@ -64,7 +64,11 @@ class ConsoleRunner extends DirectRunner with RunnerUtils {
// find out which build to test
val (buildPath, args1) = searchAndRemovePath("--buildpath", args)
val (classPath, args2) = searchAndRemovePath("--classpath", args1)
- args = args2
+ val (srcPath, args3) = searchAndRemovePath("--srcpath", args2)
+ args = args3
+
+ if (!srcPath.isEmpty)
+ System.setProperty("partest.srcdir", srcPath.get)
fileManager =
if (!buildPath.isEmpty)
@@ -204,14 +208,15 @@ class ConsoleRunner extends DirectRunner with RunnerUtils {
def kindOf(f: File): String = {
val firstName = absName(f)
- val filesPos = firstName.indexOf("files")
+ val len = fileManager.srcDirName.length
+ val filesPos = firstName.indexOf(fileManager.srcDirName)
if (filesPos == -1) {
NestUI.failure("invalid test file: "+firstName+"\n")
Predef.exit(1)
} else {
- val k = firstName.substring(filesPos+6, filesPos+6+3)
+ val k = firstName.substring(filesPos+len+1, filesPos+len+1+3)
val short = if (k == "jvm") {
- if (firstName.substring(filesPos+6, filesPos+6+4) == "jvm5") "jvm5"
+ if (firstName.substring(filesPos+len+1, filesPos+len+1+4) == "jvm5") "jvm5"
else k
} else k
val shortKinds = List("pos", "neg", "run", "jvm", "jvm5", "res")
diff --git a/src/partest/scala/tools/partest/nest/NestUI.scala b/src/partest/scala/tools/partest/nest/NestUI.scala
index 85147ae880..ecddd8d946 100644
--- a/src/partest/scala/tools/partest/nest/NestUI.scala
+++ b/src/partest/scala/tools/partest/nest/NestUI.scala
@@ -86,9 +86,12 @@ object NestUI {
println(" --failed run only those tests that failed during the last run")
println(" --verbose show progress information")
println(" --buildpath set (relative) path to build jars")
+ println(" ex.: --buildpath build/pack")
println(" --classpath set (absolute) path to build classes")
+ println(" --srcpath set (relative) path to test source files")
+ println(" ex.: --srcpath pending")
println
- println("version 0.9.1")
+ println("version 0.9.2")
println("maintained by Philipp Haller (EPFL)")
exit(1)
}
diff --git a/src/partest/scala/tools/partest/nest/Worker.scala b/src/partest/scala/tools/partest/nest/Worker.scala
index d0a11b0654..feda0ea79f 100644
--- a/src/partest/scala/tools/partest/nest/Worker.scala
+++ b/src/partest/scala/tools/partest/nest/Worker.scala
@@ -346,17 +346,15 @@ class Worker(val fileManager: FileManager) extends Actor {
def compileFilesIn(dir: File, kind: String, logFile: File, outDir: File) {
val testFiles = dir.listFiles.toList
- // 1. compile all '.java' files using javac
val javaFiles = testFiles.filter(_.getName.endsWith(".java"))
- if (!javaFiles.isEmpty)
- javac(outDir, javaFiles, logFile)
- // 2. compile all '.scala' files together
val scalaFiles = testFiles.filter(_.getName.endsWith(".scala"))
- if (!scalaFiles.isEmpty && !compileMgr.shouldCompile(outDir, scalaFiles, kind, logFile)) {
+ if (!(scalaFiles.isEmpty && javaFiles.isEmpty) &&
+ !compileMgr.shouldCompile(outDir, javaFiles ::: scalaFiles, kind, logFile)) {
NestUI.verbose("compilation of "+scalaFiles+" failed\n")
succeeded = false
} else
- // 3. compile each '.scala' file separately
+ if (!javaFiles.isEmpty)
+ javac(outDir, javaFiles, logFile)
scalaFiles foreach { scalaFile =>
if (!compileMgr.shouldCompile(outDir, List(scalaFile), kind, logFile)) {
NestUI.verbose("compilation of "+scalaFile+" failed\n")
@@ -367,13 +365,10 @@ class Worker(val fileManager: FileManager) extends Actor {
def failCompileFilesIn(dir: File, kind: String, logFile: File, outDir: File) {
val testFiles = dir.listFiles.toList
- // 1. compile all '.java' files using javac
val javaFiles = testFiles.filter(_.getName.endsWith(".java"))
- if (!javaFiles.isEmpty)
- javac(outDir, javaFiles, logFile)
- // 2. compile all '.scala' files together
val scalaFiles = testFiles.filter(_.getName.endsWith(".scala"))
- if (!scalaFiles.isEmpty && !compileMgr.shouldFailCompile(outDir, scalaFiles, kind, logFile)) {
+ if (!(scalaFiles.isEmpty && javaFiles.isEmpty) &&
+ !compileMgr.shouldFailCompile(outDir, javaFiles ::: scalaFiles, kind, logFile)) {
NestUI.verbose("compilation of "+scalaFiles+" failed\n")
succeeded = false
}