[PATCH stable?] run-tests: don't add python lines to expected dict

Adrian Buehlmann adrian at cadifra.com
Wed May 30 07:33:33 CDT 2012


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1338380937 -7200
# Node ID 273ca42c112fd660527281ae0c0cd2f3f741752e
# Parent  b10ce8f122205e4e6137f59b8f412967e8103934
run-tests: don't add python lines to expected dict

For test input lines of *.t files starting with '  >>> ', the code block for
'  >>> '

609:        if l.startswith('  >>> '): # python inlines
610:            after.setdefault(pos, []).append(l)

was (unsurprisingly) executed, but because there was an "if" instead of an
"elif" on the condition "l.startswith('  ... ')", program execution proceeded
to line 636

635:        elif l.startswith('  '): # results
636:            # queue up a list of expected results
637:            expected.setdefault(pos, []).append(l[2:])

due to the fact that if l starts with '  >>> ' it also starts with '  '.

The net effect was that python command lines in *.t files were (surprisingly)
also added to the "expected" dict.

This caused no externally observable bad behavior, as the "expected" dict was
not consulted for these lines.

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -617,7 +617,7 @@
                 script.append('%s -m heredoctest <<EOF\n' % PYTHON)
             addsalt(n, True)
             script.append(l[2:])
-        if l.startswith('  ... '): # python inlines
+        elif l.startswith('  ... '): # python inlines
             after.setdefault(prepos, []).append(l)
             script.append(l[2:])
         elif l.startswith('  $ '): # commands


More information about the Mercurial-devel mailing list