# HG changeset patch # User Jun Wu # Date 2017-02-17 09:21:15 # Node ID 01eebb65a61d9edcad1665ed747c7092f1ddb8b9 # Parent 09ec648cd2a9047b554456c8b20af7d00888ae66 runtests: add an IPv6 command line flag Now we have all IPv6 related issues fixed, add a command line flag so people could actually run tests with IPv6. diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -137,8 +137,8 @@ def checksocketfamily(name, port=20058): else: return False -# IPv6 is used if IPv4 is not available and IPv6 is available. -useipv6 = (not checksocketfamily('AF_INET')) and checksocketfamily('AF_INET6') +# useipv6 will be set by parseargs +useipv6 = None def checkportisavailable(port): """return true if a port seems free to bind on localhost""" @@ -302,6 +302,8 @@ def getparser(): help="install and use chg wrapper in place of hg") parser.add_option("--with-chg", metavar="CHG", help="use specified chg wrapper in place of hg") + parser.add_option("--ipv6", action="store_true", + help="prefer IPv6 to IPv4 for network related tests") parser.add_option("-3", "--py3k-warnings", action="store_true", help="enable Py3k warnings on Python 2.6+") # This option should be deleted once test-check-py3-compat.t and other @@ -371,6 +373,14 @@ def parseargs(args, parser): parser.error('--chg does not work when --with-hg is specified ' '(use --with-chg instead)') + global useipv6 + if options.ipv6: + useipv6 = checksocketfamily('AF_INET6') + else: + # only use IPv6 if IPv4 is unavailable and IPv6 is available + useipv6 = ((not checksocketfamily('AF_INET')) + and checksocketfamily('AF_INET6')) + options.anycoverage = options.cover or options.annotate or options.htmlcov if options.anycoverage: try: