summaryrefslogtreecommitdiff
path: root/src/partest
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-02-23 21:16:51 +0000
committerPaul Phillips <paulp@improving.org>2010-02-23 21:16:51 +0000
commit3f9364fc49c537d4195b0f75a83442951b2a659a (patch)
tree3483910f90fd39a55e378485a7ed4238d0fc4332 /src/partest
parent303a4b33f827514e89572c87334606b64083944f (diff)
downloadscala-3f9364fc49c537d4195b0f75a83442951b2a659a.tar.gz
scala-3f9364fc49c537d4195b0f75a83442951b2a659a.tar.bz2
scala-3f9364fc49c537d4195b0f75a83442951b2a659a.zip
The initial results of running a basic cut and ...
The initial results of running a basic cut and paste detector over trunk and trying to undo some of it. I can live with history but if I see Cutty McPastington in new commits I will get all finger waggly. Don't make me cross that ocean. No review.
Diffstat (limited to 'src/partest')
-rw-r--r--src/partest/scala/tools/partest/nest/Worker.scala124
1 files changed, 59 insertions, 65 deletions
diff --git a/src/partest/scala/tools/partest/nest/Worker.scala b/src/partest/scala/tools/partest/nest/Worker.scala
index 658464e2a6..3185f8fcc7 100644
--- a/src/partest/scala/tools/partest/nest/Worker.scala
+++ b/src/partest/scala/tools/partest/nest/Worker.scala
@@ -398,89 +398,83 @@ class Worker(val fileManager: FileManager) extends Actor {
}
}
- def runJvmTest(file: File, kind: String): LogContext =
+ def runTestCommon(file: File, kind: String, expectFailure: Boolean)(onSuccess: (File, File) => Unit): LogContext =
runInContext(file, kind, (logFile: File, outDir: File) => {
+
if (file.isDirectory) {
- compileFilesIn(file, kind, logFile, outDir)
- } else if (!compileMgr.shouldCompile(List(file), kind, logFile)) {
- fail(file)
+ val f = if (expectFailure) failCompileFilesIn _ else compileFilesIn _
+ f(file, kind, logFile, outDir)
}
- if (succeeded) { // run test
- val fileBase = basename(file.getName)
- val dir = file.getParentFile
+ else {
+ val f: (List[File], String, File) => Boolean =
+ if (expectFailure) compileMgr.shouldFailCompile _
+ else compileMgr.shouldCompile _
- //TODO: detect whether we have to use Runtime.exec
- // val useRuntime = true
- //
- // if (useRuntime)
- // execTest(outDir, logFile, fileBase)
- // else
- // execTestObjectRunner(file, outDir, logFile)
- // // NestUI.verbose(this+" finished running "+fileBase)
- execTest(outDir, logFile, fileBase)
-
- diffCheck(compareOutput(dir, fileBase, kind, logFile))
+ if (!f(List(file), kind, logFile))
+ fail(file)
}
+
+ if (succeeded) // run test
+ onSuccess(logFile, outDir)
+ })
+
+ def runJvmTest(file: File, kind: String): LogContext =
+ runTestCommon(file, kind, expectFailure = false)((logFile, outDir) => {
+ val fileBase = basename(file.getName)
+ val dir = file.getParentFile
+
+ //TODO: detect whether we have to use Runtime.exec
+ // val useRuntime = true
+ //
+ // if (useRuntime)
+ // execTest(outDir, logFile, fileBase)
+ // else
+ // execTestObjectRunner(file, outDir, logFile)
+ // // NestUI.verbose(this+" finished running "+fileBase)
+ execTest(outDir, logFile, fileBase)
+
+ diffCheck(compareOutput(dir, fileBase, kind, logFile))
})
def processSingleFile(file: File): LogContext = kind match {
case "scalacheck" =>
- runInContext(file, kind, (logFile: File, outDir: File) => {
- if (file.isDirectory) {
- compileFilesIn(file, kind, logFile, outDir)
- } else if (!compileMgr.shouldCompile(List(file), kind, logFile)) {
- fail(file)
- }
- if (succeeded) {
- val consFM = new ConsoleFileManager
- import consFM.{ latestCompFile, latestLibFile, latestPartestFile }
-
- NestUI.verbose("compilation of "+file+" succeeded\n")
+ runTestCommon(file, kind, expectFailure = false)((logFile, outDir) => {
+ val consFM = new ConsoleFileManager
+ import consFM.{ latestCompFile, latestLibFile, latestPartestFile }
- val libs = new File(fileManager.LIB_DIR)
- val scalacheckURL = (new File(libs, "ScalaCheck.jar")).toURI.toURL
- val outURL = outDir.getCanonicalFile.toURI.toURL
- val classpath: List[URL] =
- List(outURL, scalacheckURL, latestCompFile.toURI.toURL, latestLibFile.toURI.toURL, latestPartestFile.toURI.toURL).distinct
+ NestUI.verbose("compilation of "+file+" succeeded\n")
- val logWriter = new PrintStream(new FileOutputStream(logFile))
+ val libs = new File(fileManager.LIB_DIR)
+ val scalacheckURL = (new File(libs, "ScalaCheck.jar")).toURI.toURL
+ val outURL = outDir.getCanonicalFile.toURI.toURL
+ val classpath: List[URL] =
+ List(outURL, scalacheckURL, latestCompFile.toURI.toURL, latestLibFile.toURI.toURL, latestPartestFile.toURI.toURL).distinct
- withOutputRedirected(logWriter) {
- ObjectRunner.run(classpath, "Test", Nil)
- }
+ val logWriter = new PrintStream(new FileOutputStream(logFile))
- NestUI.verbose(SFile(logFile).slurp())
- // obviously this must be improved upon
- succeeded = SFile(logFile).lines() forall (_ contains " OK")
+ withOutputRedirected(logWriter) {
+ ObjectRunner.run(classpath, "Test", Nil)
}
- })
+
+ NestUI.verbose(SFile(logFile).slurp())
+ // obviously this must be improved upon
+ succeeded = SFile(logFile).lines() forall (_ contains " OK")
+ })
case "pos" =>
- runInContext(file, kind, (logFile: File, outDir: File) => {
- if (file.isDirectory) {
- compileFilesIn(file, kind, logFile, outDir)
- } else if (!compileMgr.shouldCompile(List(file), kind, logFile)) {
- fail(file)
- }
- })
+ runTestCommon(file, kind, expectFailure = false)((_, _) => ())
case "neg" =>
- runInContext(file, kind, (logFile: File, outDir: File) => {
- if (file.isDirectory) {
- failCompileFilesIn(file, kind, logFile, outDir)
- } else if (!compileMgr.shouldFailCompile(List(file), kind, logFile)) {
- succeeded = false
- }
- if (succeeded) { // compare log file to check file
- val fileBase = basename(file.getName)
- val dir = file.getParentFile
-
- diffCheck(
- // diff is contents of logFile
- if (!existsCheckFile(dir, fileBase, kind)) file2String(logFile)
- else compareOutput(dir, fileBase, kind, logFile)
- )
- }
+ runTestCommon(file, kind, expectFailure = true)((logFile, outDir) => {
+ // compare log file to check file
+ val fileBase = basename(file.getName)
+ val dir = file.getParentFile
+
+ diffCheck(
+ // diff is contents of logFile
+ if (!existsCheckFile(dir, fileBase, kind)) file2String(logFile)
+ else compareOutput(dir, fileBase, kind, logFile)
+ )
})
case "run" | "jvm" =>