diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-08-12 16:15:00 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-08-12 16:15:00 -0700 |
commit | 8659c2f51b007a701a27084f160ecc41fe30829a (patch) | |
tree | 40e1526a823757fc9dc4c24a1e42565938ec0981 | |
parent | 651e1988fa1e0f8efeb4eeca9e83d833c1895da3 (diff) | |
parent | 593024d9b31e9d693de2303f41ceb4783a56abc9 (diff) | |
download | scala-8659c2f51b007a701a27084f160ecc41fe30829a.tar.gz scala-8659c2f51b007a701a27084f160ecc41fe30829a.tar.bz2 scala-8659c2f51b007a701a27084f160ecc41fe30829a.zip |
Merge pull request #2807 from som-snytt/issue/partest-dir
SI-7729 Does Par-Test work? Absolutely!
-rw-r--r-- | src/partest/scala/tools/partest/nest/ConsoleRunner.scala | 4 | ||||
-rw-r--r-- | src/partest/scala/tools/partest/nest/FileManager.scala | 2 | ||||
-rw-r--r-- | src/partest/scala/tools/partest/nest/Runner.scala | 73 | ||||
-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 | ||||
-rwxr-xr-x | test/partest | 30 |
7 files changed, 55 insertions, 67 deletions
diff --git a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala index 332131ca3a..3e28d4e4ad 100644 --- a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala +++ b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala @@ -138,7 +138,7 @@ class ConsoleRunner(argstr: String) extends { val rerunTests = if (isRerun) TestKinds.failedTests else Nil def miscTests = partestTests ++ individualTests ++ greppedTests ++ rerunTests - val givenKinds = standardKinds filter parsed.isSet + val givenKinds = standardKinds filter (parsed isSet "--" + _) val kinds = ( if (optAll) standardKinds else if (givenKinds.nonEmpty) givenKinds @@ -197,7 +197,7 @@ class ConsoleRunner(argstr: String) extends { val num = paths.size val ss = if (num == 1) "" else "s" comment(s"starting $num test$ss in $kind") - val results = runTestsForFiles(paths map (_.jfile), kind) + val results = runTestsForFiles(paths map (_.jfile.getAbsoluteFile), kind) val (passed, failed) = results partition (_.isOk) passedTests ++= passed diff --git a/src/partest/scala/tools/partest/nest/FileManager.scala b/src/partest/scala/tools/partest/nest/FileManager.scala index 7bfa8c6e77..208418047c 100644 --- a/src/partest/scala/tools/partest/nest/FileManager.scala +++ b/src/partest/scala/tools/partest/nest/FileManager.scala @@ -148,7 +148,7 @@ trait FileManager extends FileUtil { val srcpath = Path(srcdir.path) val pd = (srcpath / plugxml).toFile if (pd.exists) pd copyTo (pout / plugxml) - pout + pout.toAbsolute } else Path(p) def absolutize(path: String) = pathOrCwd(path) match { case x if x.isAbsolute => x.path diff --git a/src/partest/scala/tools/partest/nest/Runner.scala b/src/partest/scala/tools/partest/nest/Runner.scala index d7d87bdcf5..1d41095fce 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") @@ -721,6 +715,9 @@ class Runner(val testFile: File, fileManager: FileManager, val testRunParams: Te } def run(): TestState = { + // javac runner, for one, would merely append to an existing log file, so just delete it before we start + logFile.delete() + if (kind == "neg" || (kind endsWith "-neg")) runNegTest() else kind match { case "pos" => runTestCommon(true) @@ -786,7 +783,7 @@ trait DirectRunner { //val parentClassLoader = ScalaClassLoader fromURLs (List(scalaCheck.toURL), getClass().getClassLoader) val pool = Executors newFixedThreadPool numThreads val manager = new RunnerManager(kind, fileManager, TestRunParams(parentClassLoader)) - val futures = kindFiles map (f => pool submit callable(manager runTest f)) + val futures = kindFiles map (f => pool submit callable(manager runTest f.getAbsoluteFile)) pool.shutdown() Try (pool.awaitTermination(waitTime) { 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 diff --git a/test/partest b/test/partest index 0259cdb791..b74e04a208 100755 --- a/test/partest +++ b/test/partest @@ -1,6 +1,5 @@ #!/usr/bin/env bash # - ############################################################################## # Scala test runner 2.10.0 ############################################################################## @@ -11,6 +10,17 @@ # PARTICULAR PURPOSE. ############################################################################## +findScalaHome () { + # see SI-2092 and SI-5792 + local source="${BASH_SOURCE[0]}" + while [ -h "$source" ] ; do + local linked="$(readlink "$source")" + local dir="$( cd -P $(dirname "$source") && cd -P $(dirname "$linked") && pwd )" + source="$dir/$(basename "$linked")" + done + ( ( cd -P "$(dirname "$source")/.." > /dev/null ) && pwd ) +} + # Use tput to detect color-capable terminal. term_colors=$(tput colors 2>/dev/null) if [[ $? == 0 ]] && [[ $term_colors -gt 2 ]]; then @@ -29,23 +39,7 @@ case "`uname`" in esac # Finding the root folder for this Scala distribution -SOURCE=$0; -SCRIPT=`basename "$SOURCE"`; -while [ -h "$SOURCE" ]; do - SCRIPT=`basename "$SOURCE"`; - LOOKUP=`ls -ld "$SOURCE"`; - TARGET=`expr "$LOOKUP" : '.*-> \(.*\)$'`; - if expr "${TARGET:-.}/" : '/.*/$' > /dev/null; then - SOURCE=${TARGET:-.}; - else - SOURCE=`dirname "$SOURCE"`/${TARGET:-.}; - fi; -done; - -# see #2092 -SCALA_HOME=`dirname "$SOURCE"` -SCALA_HOME=`cd "$SCALA_HOME"; pwd -P` -SCALA_HOME=`cd "$SCALA_HOME"/..; pwd` +SCALA_HOME="$(findScalaHome)" if $cygwin; then SCALA_HOME=`cygpath --windows --short-name "$SCALA_HOME"` |