summaryrefslogtreecommitdiff
path: root/src/partest
diff options
context:
space:
mode:
authorSom Snytt <som.snytt@gmail.com>2013-03-27 16:36:17 -0700
committerAdriaan Moors <adriaan.moors@typesafe.com>2013-04-04 10:57:42 -0700
commit0d954431ea8a75abfadbe198232fd39fff3ceeac (patch)
treef4a15ae405c2eec3b500ff2b0905073903f7151e /src/partest
parentc6ce61796f66770ca1b4d63fc0a569f064436433 (diff)
downloadscala-0d954431ea8a75abfadbe198232fd39fff3ceeac.tar.gz
scala-0d954431ea8a75abfadbe198232fd39fff3ceeac.tar.bz2
scala-0d954431ea8a75abfadbe198232fd39fff3ceeac.zip
SI-6289 Paulptest demonstrating javac errors
This is Paul's test demonstrating that Javac errors are correctly transcribed in the test transcript. A gratuitous Scala class is added to a later round to show that the test halts after the first error. The runner must supply absolute paths to javac so that absolute paths are reported in errors and stripped away by partest. The check file is differentiated for Java 6 and 7, and partest's runner will now post-process the `diff log check` to strip the diff which does not apply.
Diffstat (limited to 'src/partest')
-rw-r--r--src/partest/scala/tools/partest/nest/Runner.scala50
1 files changed, 47 insertions, 3 deletions
diff --git a/src/partest/scala/tools/partest/nest/Runner.scala b/src/partest/scala/tools/partest/nest/Runner.scala
index 95b304a56d..fc56818bfc 100644
--- a/src/partest/scala/tools/partest/nest/Runner.scala
+++ b/src/partest/scala/tools/partest/nest/Runner.scala
@@ -16,7 +16,7 @@ import scala.tools.nsc.util.{ ClassPath, FakePos, ScalaClassLoader, stackTraceSt
import ClassPath.{ join, split }
import scala.tools.scalap.scalax.rules.scalasig.ByteCode
import scala.collection.{ mutable, immutable }
-import scala.sys.process._
+import scala.sys.process.Process
import java.util.concurrent.{ Executors, TimeUnit, TimeoutException }
import PartestDefaults.{ javaCmd, javacCmd }
import scala.tools.scalap.Main.decompileScala
@@ -136,7 +136,7 @@ class Runner(val testFile: File, fileManager: FileManager) {
outDir.getAbsolutePath,
"-classpath",
join(outDir.toString, CLASSPATH)
- ) ++ files.map("" + _)
+ ) ++ files.map(_.getAbsolutePath)
pushTranscript(args mkString " ")
val captured = StreamCapture(runCommand(args, logFile))
@@ -240,8 +240,51 @@ class Runner(val testFile: File, fileManager: FileManager) {
false
}
+ /** Filter the diff for conditional blocks.
+ * The check file can contain lines of the form:
+ * `#partest java7`
+ * where the line contains a conventional flag name.
+ * In the diff output, these lines have the form:
+ * `> #partest java7`
+ * Blocks which don't apply are filtered out,
+ * and what remains is the desired diff.
+ * Line edit commands such as `0a1,6` don't count
+ * as diff, so return a nonempty diff only if
+ * material diff output was seen.
+ * Filtering the diff output (instead of every check
+ * file) means that we only post-process a test that
+ * might be failing, in the normal case.
+ */
+ def diffilter(d: String) = {
+ import scala.util.Properties.javaVersion
+ val prefix = "#partest"
+ val margin = "> "
+ val leader = margin + prefix
+ // use lines in block so labeled? Default to sure, go ahead.
+ def retainOn(f: String) = f match {
+ case "java7" => javaVersion startsWith "1.7"
+ case "java6" => javaVersion startsWith "1.6"
+ case _ => true
+ }
+ if (d contains prefix) {
+ val sb = new StringBuilder
+ var retain = true // use the current line
+ var material = false // saw a line of diff
+ for (line <- d.lines)
+ if (line startsWith leader) {
+ val rest = (line stripPrefix leader).trim
+ retain = retainOn(rest)
+ } else if (retain) {
+ if (line startsWith margin) material = true
+ sb ++= line
+ sb ++= EOL
+ }
+ if (material) sb.toString else ""
+ } else d
+ }
+
def currentDiff = (
- if (checkFile.canRead) compareFiles(logFile, checkFile)
+ if (checkFile.canRead) diffilter(compareFiles(logFile, checkFile))
else compareContents(augmentString(file2String(logFile)).lines.toList, Nil)
)
@@ -566,6 +609,7 @@ class Runner(val testFile: File, fileManager: FileManager) {
diffIsOk
}
def runScriptTest() = {
+ import scala.sys.process._
val (swr, wr) = newTestWriters()
val args = file2String(testFile changeExtension "args")