From e037c9a3c12e21104a5aaf15d2bf27779cc3fd12 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Sat, 25 May 2013 15:09:35 -0700 Subject: SI-7198 Par-Test uses filters files Partest will also read files/filters and files/kind/filters for filter expressions (one per line, trimmed, leading #comments) which are taken as regexes. A test/files/filters is provided which attempts to quell HotSpot warnings; the test for this commit requires it. The elided lines can be revealed using the lemon juice of verbosity: apm@mara:~/projects/snytt/test$ ./partest --verbose --show-diff files/run/t7198.scala [snip] >>>>> Transcripts from failed tests >>>>> > partest files/run/t7198.scala % scalac t7198.scala [snip] % filtering t7198-run.log --Over the moon --Java HotSpot(TM) 64-Bit Server VM warning: Failed to reserve shared memory (errno = 28). The filtering operation is part of the transcript, which is printed on failure. No attempt is made to be clever about not slurping the filters file a thousand times. Previous literal patterns had to be updated because there's parens in them thar strings. Future feature: pattern aliases, define once globally and invoke in test filters. --- src/partest/scala/tools/partest/nest/Runner.scala | 21 +++++++++++++++++++-- test/files/filters | 3 +++ test/files/run/colltest1.scala | 2 +- test/files/run/compiler-asSeenFrom.scala | 2 +- test/files/run/existentials-in-compiler.scala | 2 +- test/files/run/is-valid-num.scala | 2 +- test/files/run/iterator-from.scala | 2 +- test/files/run/json.scala | 2 +- test/files/run/mapConserve.scala | 2 +- test/files/run/pc-conversions.scala | 2 +- test/files/run/stringinterpolation_macro-run.scala | 2 +- test/files/run/t7096.scala | 2 +- test/files/run/t7198.check | 2 ++ test/files/run/t7198.scala | 9 +++++++++ 14 files changed, 43 insertions(+), 12 deletions(-) create mode 100644 test/files/filters create mode 100644 test/files/run/t7198.check create mode 100644 test/files/run/t7198.scala diff --git a/src/partest/scala/tools/partest/nest/Runner.scala b/src/partest/scala/tools/partest/nest/Runner.scala index b7cc42322b..1034d724d2 100644 --- a/src/partest/scala/tools/partest/nest/Runner.scala +++ b/src/partest/scala/tools/partest/nest/Runner.scala @@ -368,10 +368,27 @@ class Runner(val testFile: File, fileManager: FileManager, val testRunParams: Te pathFinder replaceAllIn (s, m => ellipsis + squashSlashes(m group 1)) ) - val filters = toolArgs("filter", split = false) - def lineFilter(s: String): Boolean = !(filters exists (s contains _)) + def masters = { + val files = List(new File(parentFile, "filters"), new File(PathSettings.srcDir.path, "filters")) + files filter (_.exists) flatMap (_.fileLines) map (_.trim) filter (s => !(s startsWith "#")) + } + val filters = toolArgs("filter", split = false) ++ masters + val elisions = ListBuffer[String]() + //def lineFilter(s: String): Boolean = !(filters exists (s contains _)) + def lineFilter(s: String): Boolean = ( + filters map (_.r) forall { r => + val res = (r findFirstIn s).isEmpty + if (!res) elisions += s + res + } + ) logFile.mapInPlace(canonicalize)(lineFilter) + if (isPartestVerbose && elisions.nonEmpty) { + import NestUI.color._ + val emdash = bold(yellow("--")) + pushTranscript(s"filtering ${logFile.getName}$EOL${elisions mkString (emdash, EOL + emdash, EOL)}") + } } def diffIsOk: Boolean = { diff --git a/test/files/filters b/test/files/filters new file mode 100644 index 0000000000..9a9b439784 --- /dev/null +++ b/test/files/filters @@ -0,0 +1,3 @@ +# +#Java HotSpot(TM) 64-Bit Server VM warning: Failed to reserve shared memory (errno = 28). +Java HotSpot\(TM\) .* warning: diff --git a/test/files/run/colltest1.scala b/test/files/run/colltest1.scala index 87d3ef618b..9d77fc413a 100644 --- a/test/files/run/colltest1.scala +++ b/test/files/run/colltest1.scala @@ -1,5 +1,5 @@ /* - * filter: inliner warning(s); re-run with -Yinline-warnings for details + * filter: inliner warning\(s\); re-run with -Yinline-warnings for details */ import scala.collection._ import scala.language.postfixOps diff --git a/test/files/run/compiler-asSeenFrom.scala b/test/files/run/compiler-asSeenFrom.scala index 2952f85f01..bd3db0bf66 100644 --- a/test/files/run/compiler-asSeenFrom.scala +++ b/test/files/run/compiler-asSeenFrom.scala @@ -1,5 +1,5 @@ /* - * filter: inliner warning(s); re-run with -Yinline-warnings for details + * filter: inliner warning\(s\); re-run with -Yinline-warnings for details */ import scala.tools.nsc._ import scala.tools.partest.CompilerTest diff --git a/test/files/run/existentials-in-compiler.scala b/test/files/run/existentials-in-compiler.scala index 5ff40578c5..f5a0aa98d0 100644 --- a/test/files/run/existentials-in-compiler.scala +++ b/test/files/run/existentials-in-compiler.scala @@ -1,5 +1,5 @@ /* - * filter: inliner warning(s); re-run with -Yinline-warnings for details + * filter: inliner warning\(s\); re-run with -Yinline-warnings for details */ import scala.tools.nsc._ import scala.tools.partest.CompilerTest diff --git a/test/files/run/is-valid-num.scala b/test/files/run/is-valid-num.scala index 6d281d625f..19a3b9c7c0 100644 --- a/test/files/run/is-valid-num.scala +++ b/test/files/run/is-valid-num.scala @@ -1,5 +1,5 @@ /* - * filter: inliner warning(s); re-run with -Yinline-warnings for details + * filter: inliner warning\(s\); re-run with -Yinline-warnings for details */ object Test { def x = BigInt("10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") diff --git a/test/files/run/iterator-from.scala b/test/files/run/iterator-from.scala index c8efa01b77..fb33f6b5ed 100644 --- a/test/files/run/iterator-from.scala +++ b/test/files/run/iterator-from.scala @@ -1,5 +1,5 @@ /* This file tests iteratorFrom, keysIteratorFrom, and valueIteratorFrom on various sorted sets and maps - * filter: inliner warning(s); re-run with -Yinline-warnings for details + * filter: inliner warning\(s\); re-run with -Yinline-warnings for details */ import scala.util.{Random => R} diff --git a/test/files/run/json.scala b/test/files/run/json.scala index d9d28ba1ca..36e86ac5bb 100644 --- a/test/files/run/json.scala +++ b/test/files/run/json.scala @@ -1,5 +1,5 @@ /* - * filter: inliner warning(s); re-run with -Yinline-warnings for details + * filter: inliner warning\(s\); re-run with -Yinline-warnings for details */ import scala.util.parsing.json._ import scala.collection.immutable.TreeMap diff --git a/test/files/run/mapConserve.scala b/test/files/run/mapConserve.scala index ffd9106fa9..330fb34ca1 100644 --- a/test/files/run/mapConserve.scala +++ b/test/files/run/mapConserve.scala @@ -1,5 +1,5 @@ /* - * filter: inliner warning(s); re-run with -Yinline-warnings for details + * filter: inliner warning\(s\); re-run with -Yinline-warnings for details */ import scala.annotation.tailrec import scala.collection.mutable.ListBuffer diff --git a/test/files/run/pc-conversions.scala b/test/files/run/pc-conversions.scala index 0a51d312e1..b1ef3d963e 100644 --- a/test/files/run/pc-conversions.scala +++ b/test/files/run/pc-conversions.scala @@ -1,5 +1,5 @@ /* - * filter: inliner warning(s); re-run with -Yinline-warnings for details + * filter: inliner warning\(s\); re-run with -Yinline-warnings for details */ import collection._ diff --git a/test/files/run/stringinterpolation_macro-run.scala b/test/files/run/stringinterpolation_macro-run.scala index 4c43f2059e..1138cd0860 100644 --- a/test/files/run/stringinterpolation_macro-run.scala +++ b/test/files/run/stringinterpolation_macro-run.scala @@ -1,5 +1,5 @@ /* - * filter: inliner warning(s); re-run with -Yinline-warnings for details + * filter: inliner warning\(s\); re-run with -Yinline-warnings for details */ object Test extends App { diff --git a/test/files/run/t7096.scala b/test/files/run/t7096.scala index 437f7a086d..2495102899 100644 --- a/test/files/run/t7096.scala +++ b/test/files/run/t7096.scala @@ -1,5 +1,5 @@ /* - * filter: inliner warning(s); re-run with -Yinline-warnings for details + * filter: inliner warning\(s\); re-run with -Yinline-warnings for details */ import scala.tools.partest._ import scala.tools.nsc._ diff --git a/test/files/run/t7198.check b/test/files/run/t7198.check new file mode 100644 index 0000000000..6dad496f49 --- /dev/null +++ b/test/files/run/t7198.check @@ -0,0 +1,2 @@ +The quick brown fox jumped +And ran away with the vixen. diff --git a/test/files/run/t7198.scala b/test/files/run/t7198.scala new file mode 100644 index 0000000000..26e1d8805a --- /dev/null +++ b/test/files/run/t7198.scala @@ -0,0 +1,9 @@ +/* spew a few lines + * filter: Over the moon + */ +object Test extends App { + Console println "The quick brown fox jumped" + Console println "Over the moon" + Console println "And ran away with the vixen." + Console println "Java HotSpot(TM) 64-Bit Server VM warning: Failed to reserve shared memory (errno = 28)." +} -- cgit v1.2.3