diff options
-rw-r--r-- | src/partest/scala/tools/partest/nest/Runner.scala | 50 | ||||
-rw-r--r-- | test/files/neg/javac-error.check | 10 | ||||
-rw-r--r-- | test/files/neg/javac-error.flags | 1 | ||||
-rw-r--r-- | test/files/neg/javac-error/J.java | 5 | ||||
-rw-r--r-- | test/files/neg/javac-error/SUT_5.scala | 5 |
5 files changed, 68 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") diff --git a/test/files/neg/javac-error.check b/test/files/neg/javac-error.check new file mode 100644 index 0000000000..e7d1ccc1a1 --- /dev/null +++ b/test/files/neg/javac-error.check @@ -0,0 +1,10 @@ +#partest java6 +javac-error/J.java:2: method does not override or implement a method from a supertype + @Override public void foo() { } + ^ +1 error +#partest java7 +javac-error/J.java:2: error: method does not override or implement a method from a supertype + @Override public void foo() { } + ^ +1 error diff --git a/test/files/neg/javac-error.flags b/test/files/neg/javac-error.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/javac-error.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/javac-error/J.java b/test/files/neg/javac-error/J.java new file mode 100644 index 0000000000..83f50c9ae2 --- /dev/null +++ b/test/files/neg/javac-error/J.java @@ -0,0 +1,5 @@ +public class J { + @Override public void foo() { } + + public void bar() { foo(); } +} diff --git a/test/files/neg/javac-error/SUT_5.scala b/test/files/neg/javac-error/SUT_5.scala new file mode 100644 index 0000000000..0a996352c0 --- /dev/null +++ b/test/files/neg/javac-error/SUT_5.scala @@ -0,0 +1,5 @@ + +/** The System Under Test. + * We bail on the earlier round that generates the first error. + */ +class SUT extends J |