diff options
author | Paul Phillips <paulp@improving.org> | 2010-04-11 19:45:08 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-04-11 19:45:08 +0000 |
commit | ebe772d693c6957c041d1be58dfd6f7686c2645b (patch) | |
tree | 4a115b543a623c29801490be6bab605a2afdfa94 /src/partest | |
parent | 67b1041a8512a760749a6e3882113e5aee7ba321 (diff) | |
download | scala-ebe772d693c6957c041d1be58dfd6f7686c2645b.tar.gz scala-ebe772d693c6957c041d1be58dfd6f7686c2645b.tar.bz2 scala-ebe772d693c6957c041d1be58dfd6f7686c2645b.zip |
Added --update-check option to partest.
automatically update all the checkfiles with whatever output the tests
are producing. I suppose it goes without saying that this would be easy
to misuse, so let the record show that I accept no responsibility when
someone overwrites all the checkfiles in trunk with their shopping list
and checks it in.
Recommended usage: See some tests fail. Run
partest --failed --show-diff
Verify that all output differs in the expected fashion. Then run
partest --failed --update-check
Mission accomplished. No review.
Diffstat (limited to 'src/partest')
-rw-r--r-- | src/partest/scala/tools/partest/Actions.scala | 24 | ||||
-rw-r--r-- | src/partest/scala/tools/partest/PartestSpec.scala | 1 |
2 files changed, 15 insertions, 10 deletions
diff --git a/src/partest/scala/tools/partest/Actions.scala b/src/partest/scala/tools/partest/Actions.scala index 3e745714cb..48b80cface 100644 --- a/src/partest/scala/tools/partest/Actions.scala +++ b/src/partest/scala/tools/partest/Actions.scala @@ -136,7 +136,7 @@ trait Actions { /** The default cleanup normalizes paths relative to sourcesDir. */ - def diffCleanup(f: File) = safeLines(f) map normalizePaths mkString "\n" + def diffCleanup(f: File) = safeLines(f) map normalizePaths mkString ("", "\n", "\n") /** If optional is true, a missing check file is considered * a successful diff. Necessary since many categories use @@ -146,19 +146,23 @@ trait Actions { def arg1 = tracePath(check) def arg2 = tracePath(log) def noCheck = !check.exists && returning(true)(_ => trace("diff %s %s [unchecked]".format(arg1, arg2))) + def output = diffCleanup(log) + def matches = safeSlurp(check).trim == output.trim + + def traceMsg = + if (isDryRun) "diff %s %s".format(arg1, arg2) + else "diff %s %s [%s]".format(arg1, arg2, (if (matches) "passed" else "failed")) noCheck || { - def result = safeSlurp(check).trim == diffCleanup(log).trim - def msg = if (result) "passed" else "failed" + trace(traceMsg) - if (isDryRun) { - trace("diff %s %s".format(arg1, arg2)) + isDryRun || matches || (isUpdateCheck && { + normal("** diff %s %s failed:\n".format(arg1, arg2)) + normal(diffOutput()) + normal("** updating %s and marking as passed.\n".format(arg1)) + check writeAll output true - } - else { - trace("diff %s %s [%s]".format(arg1, arg2, msg)) - result - } + }) } } diff --git a/src/partest/scala/tools/partest/PartestSpec.scala b/src/partest/scala/tools/partest/PartestSpec.scala index e4259d70be..50c82fb783 100644 --- a/src/partest/scala/tools/partest/PartestSpec.scala +++ b/src/partest/scala/tools/partest/PartestSpec.scala @@ -77,6 +77,7 @@ trait PartestSpec extends Spec with Meta.StdOpts with Interpolation { val isNoCleanup = "nocleanup" / "do not delete any logfiles or object dirs" --? val isStats = "stats" / "collect and print statistics about the tests" --? val isValidate = "validate" / "examine test filesystem for inconsistencies" --? + val isUpdateCheck = "update-check" / "overwrite checkFile if diff fails" --? "version" / "print version" --> runAndExit(println(Properties.versionMsg)) |