# HG changeset patch # User Christian Ebert # Date 1338852053 -3600 # Node ID 06fb629c6195b8e4cbe81d3bee1f5c1673b2c8ae # Parent 2ba350253f7671c3b9d5fd7e9b8242bda9e1a14b# Parent a2e8ccb652249a8ba0a0447894457833c7aeb799 Merge with stable diff -r 2ba350253f76 -r 06fb629c6195 tests/run-tests.py --- a/tests/run-tests.py Thu May 31 12:47:50 2012 +0200 +++ b/tests/run-tests.py Tue Jun 05 00:20:53 2012 +0100 @@ -594,6 +594,19 @@ # can generate the surrounding doctest magic inpython = False + # True or False when in a true or false conditional section + skipping = None + + def hghave(reqs): + # TODO: do something smarter when all other uses of hghave is gone + proc = Popen4('%s -c "%s/hghave %s"' % + (options.shell, TESTDIR, ' '.join(reqs)), TESTDIR, 0) + proc.communicate() + ret = proc.wait() + if wifexited(ret): + ret = os.WEXITSTATUS(ret) + return ret == 0 + f = open(test) t = f.readlines() f.close() @@ -606,7 +619,24 @@ for n, l in enumerate(t): if not l.endswith('\n'): l += '\n' - if l.startswith(' >>> '): # python inlines + if l.startswith('#if'): + if skipping is not None: + after.setdefault(pos, []).append(' !!! nested #if\n') + skipping = not hghave(l.split()[1:]) + after.setdefault(pos, []).append(l) + elif l.startswith('#else'): + if skipping is None: + after.setdefault(pos, []).append(' !!! missing #if\n') + skipping = not skipping + after.setdefault(pos, []).append(l) + elif l.startswith('#endif'): + if skipping is None: + after.setdefault(pos, []).append(' !!! missing #if\n') + skipping = None + after.setdefault(pos, []).append(l) + elif skipping: + after.setdefault(pos, []).append(l) + elif l.startswith(' >>> '): # python inlines after.setdefault(pos, []).append(l) prepos = pos pos = n @@ -617,7 +647,7 @@ script.append('%s -m heredoctest <