diff options
-rw-r--r-- | src/partest/scala/tools/partest/nest/Runner.scala | 68 | ||||
-rw-r--r-- | test/files/run/repl-javap-app.check | 9 | ||||
-rw-r--r-- | test/files/run/stream_length.check | 1 | ||||
-rw-r--r-- | test/files/run/tailcalls.check | 3 |
4 files changed, 36 insertions, 45 deletions
diff --git a/src/partest/scala/tools/partest/nest/Runner.scala b/src/partest/scala/tools/partest/nest/Runner.scala index d7d87bdcf5..d9a6234949 100644 --- a/src/partest/scala/tools/partest/nest/Runner.scala +++ b/src/partest/scala/tools/partest/nest/Runner.scala @@ -270,60 +270,54 @@ class Runner(val testFile: File, fileManager: FileManager, val testRunParams: Te false } - /** Filter the diff for conditional blocks. + /** Filter the check file 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. + * If the flag tests true, succeeding lines are retained + * (removed on false) until the next #partest flag. + * A missing flag evaluates the same as true. */ - def diffilter(d: String) = { + def filteredCheck: Seq[String] = { import scala.util.Properties.{javaVersion, isAvian} - val prefix = "#partest" - val margin = "> " - val leader = margin + prefix // use lines in block so labeled? Default to sorry, Charlie. - def retainOn(f: String) = { + def retainOn(expr: String) = { + val f = expr.trim + def flagWasSet(f: String) = fileManager.SCALAC_OPTS contains f val (invert, token) = if (f startsWith "!") (true, f drop 1) else (false, f) - val cond = token match { + val cond = token.trim match { case "java7" => javaVersion startsWith "1.7" case "java6" => javaVersion startsWith "1.6" case "avian" => isAvian case "true" => true - case _ => false + case "-optimise" | "-optimize" + => flagWasSet("-optimise") || flagWasSet("-optimize") + case flag if flag startsWith "-" + => flagWasSet(flag) + case rest => rest.isEmpty } if (invert) !cond else cond } - 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 + val prefix = "#partest" + val b = new ListBuffer[String]() + var on = true + for (line <- file2String(checkFile).lines) { + if (line startsWith prefix) { + on = retainOn(line stripPrefix prefix) + } else if (on) { + b += line + } + } + b.toList } - def currentDiff = ( - if (checkFile.canRead) diffilter(compareFiles(logFile, checkFile)) - else compareContents(augmentString(file2String(logFile)).lines.toList, Nil) - ) + def currentDiff = { + val logged = augmentString(file2String(logFile)).lines.toList + val (other, othername) = + if (checkFile.canRead) (filteredCheck, checkFile.getName) else (Nil, "empty") + compareContents(logged, other, logFile.getName, othername) + } val gitRunner = List("/usr/local/bin/git", "/usr/bin/git") map (f => new java.io.File(f)) find (_.canRead) val gitDiffOptions = "--ignore-space-at-eol --no-index " + propOrEmpty("partest.git_diff_options") diff --git a/test/files/run/repl-javap-app.check b/test/files/run/repl-javap-app.check index db1f09b977..490860585c 100644 --- a/test/files/run/repl-javap-app.check +++ b/test/files/run/repl-javap-app.check @@ -6,14 +6,13 @@ scala> :javap -app MyApp$ public final void delayedEndpoint$MyApp$1(); Code: Stack=2, Locals=1, Args_size=1 - 0: getstatic #61; //Field scala/Console$.MODULE$:Lscala/Console$; - 3: ldc #63; //String Hello, delayed world. - 5: invokevirtual #67; //Method scala/Console$.println:(Ljava/lang/Object;)V - 8: return + 0: getstatic #61; //Field scala/Console$.MODULE$:Lscala/Console$; + 3: ldc #63; //String Hello, delayed world. + 5: invokevirtual #67; //Method scala/Console$.println:(Ljava/lang/Object;)V + 8: return LocalVariableTable: Start Length Slot Name Signature 0 9 0 this LMyApp$; -} scala> #partest !java6 diff --git a/test/files/run/stream_length.check b/test/files/run/stream_length.check index d1068f3247..e4350aa741 100644 --- a/test/files/run/stream_length.check +++ b/test/files/run/stream_length.check @@ -1,6 +1,5 @@ #partest !avian Length: 970299 - #partest avian !!!TEST SKIPPED!!! See SI-7600 for further information. diff --git a/test/files/run/tailcalls.check b/test/files/run/tailcalls.check index 10384ac46e..ab54d528ab 100644 --- a/test/files/run/tailcalls.check +++ b/test/files/run/tailcalls.check @@ -52,7 +52,6 @@ test TailCall.b2 was successful test FancyTailCalls.tcTryLocal was successful test FancyTailCalls.differentInstance was successful test PolyObject.tramp was successful - #partest avian test Object .f was successful test Final .f was successful @@ -106,4 +105,4 @@ test TailCall.b1 was successful test TailCall.b2 was successful test FancyTailCalls.tcTryLocal was successful test FancyTailCalls.differentInstance was successful -test PolyObject.tramp was successful
\ No newline at end of file +test PolyObject.tramp was successful |