[PATCH] run-tests: add a -A/--accept-all option to accept all changed outputs
Denis Laxalde
denis at laxalde.org
Wed Oct 4 11:15:58 UTC 2017
# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1507115620 -7200
# Wed Oct 04 13:13:40 2017 +0200
# Node ID bd07ebae31e368211e47432b67efcb475332f821
# Parent 2fd06499dc8e6a5a784b1334b925c289d7b54e4e
# Available At http://hg.logilab.org/users/dlaxalde/hg
# hg pull http://hg.logilab.org/users/dlaxalde/hg -r bd07ebae31e3
# EXP-Topic run-tests-accept-all
run-tests: add a -A/--accept-all option to accept all changed outputs
Sometimes it's easier to have all tests updated non-interactively and
eventually not commit everything.
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -323,6 +323,8 @@ def getparser():
help="create an HTML report of the coverage of the files")
parser.add_option("-i", "--interactive", action="store_true",
help="prompt to accept changed output")
+ parser.add_option("-A", "--accept-all", action="store_true",
+ help="accept all changed outputs")
parser.add_option("-j", "--jobs", type="int",
help="number of jobs to run in parallel"
" (default: $%s or %d)" % defaults['jobs'])
@@ -1740,20 +1742,25 @@ class TestResult(unittest._TextTestResul
self.stream.flush()
# handle interactive prompt without releasing iolock
- if self._options.interactive:
+ if self._options.interactive or self._options.accept_all:
if test.readrefout() != expected:
self.stream.write(
'Reference output has changed (run again to prompt '
'changes)')
else:
- self.stream.write('Accept this change? [n] ')
- answer = sys.stdin.readline().strip()
- if answer.lower() in ('y', 'yes'):
+ accepted = False
+ if self._options.accept_all:
+ accepted = True
+ else:
+ self.stream.write('Accept this change? [n] ')
+ answer = sys.stdin.readline().strip()
+ if answer.lower() in ('y', 'yes'):
+ accepted = True
+ if accepted:
if test.path.endswith(b'.t'):
rename(test.errpath, test.path)
else:
rename(test.errpath, '%s.out' % test.path)
- accepted = True
if not accepted:
self.faildata[test.name] = b''.join(lines)
More information about the Mercurial-devel
mailing list