summaryrefslogtreecommitdiff
path: root/src/partest-alternative
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-01-19 22:38:16 +0000
committerPaul Phillips <paulp@improving.org>2011-01-19 22:38:16 +0000
commitc28a86006bcb7816f212da84005bd0bde4ce334b (patch)
treecaebd0744d9b819575cfcb723d0bf7f7b3f444b0 /src/partest-alternative
parentf3711ed324ddea02873cd3aa4c9eb8d306257662 (diff)
downloadscala-c28a86006bcb7816f212da84005bd0bde4ce334b.tar.gz
scala-c28a86006bcb7816f212da84005bd0bde4ce334b.tar.bz2
scala-c28a86006bcb7816f212da84005bd0bde4ce334b.zip
More on partest.
multiple-reporting-of-failures bug. No review.
Diffstat (limited to 'src/partest-alternative')
-rw-r--r--src/partest-alternative/scala/tools/partest/Actions.scala46
-rw-r--r--src/partest-alternative/scala/tools/partest/Config.scala14
-rw-r--r--src/partest-alternative/scala/tools/partest/nest/StreamAppender.scala94
3 files changed, 2 insertions, 152 deletions
diff --git a/src/partest-alternative/scala/tools/partest/Actions.scala b/src/partest-alternative/scala/tools/partest/Actions.scala
index cb60152b71..30a338c68b 100644
--- a/src/partest-alternative/scala/tools/partest/Actions.scala
+++ b/src/partest-alternative/scala/tools/partest/Actions.scala
@@ -11,6 +11,7 @@ package partest
import util._
import nsc.io._
+import scala.sys.process._
trait Actions {
partest: Universe =>
@@ -43,53 +44,10 @@ trait Actions {
isDryRun || execAndLog(cmd)
}
- /** Runs <code>command</code> redirecting standard out and
- * error out to <code>output</code> file.
- */
- private def runCommandOld(command: String, output: java.io.File): Int = {
- import java.io._
- import nest.StreamAppender
-
- // NestUI.verbose("running command:\n"+command)
- val proc = Runtime.getRuntime.exec(command)
- val in = proc.getInputStream
- val err = proc.getErrorStream
- val writer = new PrintWriter(new FileWriter(output), true)
- val inApp = StreamAppender(in, writer)
- val errApp = StreamAppender(err, writer)
- val async = new Thread(errApp)
- async.start()
- inApp.run()
- async.join()
- writer.close()
-
- try proc.exitValue()
- catch { case _: IllegalThreadStateException => 0 }
- }
-
/** Exec a process to run a command. Assumes 0 exit value is success.
* Of necessity, also treats no available exit value as success.
*/
- protected def execAndLog(cmd: String): Boolean = {
- runCommandOld(cmd, logFile.jfile) == 0
-
- // var proc: Process = null
- //
- // val result = interruptMeIn(cmd, testTimeout) {
- // loggingResult {
- // proc = Process.exec(toArgs(cmd), execEnv, execCwd.orNull, true)
- // proc.slurp()
- // }
- // proc != null && (proc.waitFor() == 0)
- // }
- // result getOrElse {
- // warning("Process never terminated: '%s'" format cmd)
- // if (proc != null)
- // proc.destroy()
- //
- // false
- // }
- }
+ protected def execAndLog(cmd: String) = (cmd #> logFile.jfile !) == 0
}
trait ScriptableTest {
diff --git a/src/partest-alternative/scala/tools/partest/Config.scala b/src/partest-alternative/scala/tools/partest/Config.scala
index 288a3034e9..d0b94dffae 100644
--- a/src/partest-alternative/scala/tools/partest/Config.scala
+++ b/src/partest-alternative/scala/tools/partest/Config.scala
@@ -71,20 +71,6 @@ trait Config {
/** Internal **/
private def repo = partestDir.parent.normalize
- // XXX - is this needed? Where?
- //
- // private val pluginOptionString = "-Xplugin:"
- // private def updatedPluginPath(options: String): String = {
- // val (pluginArgs, rest) = toArgs(options) partition (_ startsWith pluginOptionString)
- // // join all plugin paths as one classpath
- // val pluginPaths = ClassPath.join(pluginArgs map (_ stripPrefix pluginOptionString): _*)
- // // map all paths to absolute
- // val newPath = ClassPath.map(pluginPaths, x => absolutize(x).path)
- // // recreate option
- // val pluginOption = if (newPath == "") None else Some(pluginOptionString + newPath)
- //
- // fromArgs(rest ::: pluginOption.toList)
- // }
private def pathForComponent(what: String, jarFormat: String = "scala-%s.jar"): Path = {
def asDir = testBuildDir / "classes" / what
diff --git a/src/partest-alternative/scala/tools/partest/nest/StreamAppender.scala b/src/partest-alternative/scala/tools/partest/nest/StreamAppender.scala
deleted file mode 100644
index 3d1cee95c6..0000000000
--- a/src/partest-alternative/scala/tools/partest/nest/StreamAppender.scala
+++ /dev/null
@@ -1,94 +0,0 @@
-/* NEST (New Scala Test)
- * Copyright 2007-2010 LAMP/EPFL
- * @author Philipp Haller
- */
-
-// $Id$
-
-package scala.tools.partest
-package nest
-
-import java.io._
-
-object StreamAppender {
- def wrapIn(in: InputStream): BufferedReader = new BufferedReader(new InputStreamReader(in))
- def wrapIn(reader: Reader): BufferedReader = new BufferedReader(reader)
- def wrapIn(str: String): BufferedReader = new BufferedReader(new StringReader(str))
-
- def wrapOut(out: OutputStream): PrintWriter = new PrintWriter(new OutputStreamWriter(out), true)
- def wrapOut(writer: Writer): PrintWriter = new PrintWriter(writer, true)
- def wrapOut(): PrintWriter = wrapOut(new StringWriter)
-
- def apply(reader: BufferedReader, writer: Writer): StreamAppender =
- new StreamAppender(reader, wrapOut(writer))
-
- def apply(reader: Reader, writer: Writer): StreamAppender =
- apply(wrapIn(reader), writer)
-
- def apply(in: InputStream, writer: Writer): StreamAppender =
- apply(wrapIn(in), writer)
-
- def apply(str: String, writer: Writer): StreamAppender =
- apply(wrapIn(str), writer)
-
- def apply(in: File, out: File): StreamAppender =
- apply(new FileReader(in), new FileWriter(out))
-
- def appendToString(in1: InputStream, in2: InputStream): String = {
- val swriter1 = new StringWriter
- val swriter2 = new StringWriter
- val app1 = StreamAppender(wrapIn(in1), swriter1)
- val app2 = StreamAppender(wrapIn(in2), swriter2)
-
- val async = new Thread(app2)
- async.start()
- app1.run()
- async.join()
- swriter1.toString + swriter2.toString
- }
-/*
- private def inParallel(t1: Runnable, t2: Runnable, t3: Runnable) {
- val thr1 = new Thread(t1)
- val thr2 = new Thread(t2)
- thr1.start()
- thr2.start()
- t3.run()
- thr1.join()
- thr2.join()
- }
-*/
- private def inParallel(t1: Runnable, t2: Runnable) {
- val thr = new Thread(t2)
- thr.start()
- t1.run()
- thr.join()
- }
-
- def concat(in: InputStream, err: InputStream, out: OutputStream) = new Runnable {
- override def run() {
- val outWriter = wrapOut(out)
- val inApp = StreamAppender(in, outWriter)
-
- val errStringWriter = new StringWriter
- val errApp = StreamAppender(wrapIn(err), errStringWriter)
-
- inParallel(inApp, errApp)
-
- // append error string to out
- StreamAppender(errStringWriter.toString, outWriter).run()
- }
- }
-}
-
-class StreamAppender(reader: BufferedReader, writer: PrintWriter) extends Runnable {
- override def run() = runAndMap(identity)
- private def lines() = Iterator continually reader.readLine() takeWhile (_ != null)
-
- def runAndMap(f: String => String) =
- try lines() map f foreach (writer println _)
- catch { case e: IOException => e.printStackTrace() }
- finally {
- reader.close()
- writer.close()
- }
-}