Mercurial > hg
comparison tests/run-tests.py @ 31011:01eebb65a61d
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.
author | Jun Wu <quark@fb.com> |
---|---|
date | Fri, 17 Feb 2017 01:21:15 -0800 |
parents | 09ec648cd2a9 |
children | 23bcfdd76f96 |
comparison
equal
deleted
inserted
replaced
31010:09ec648cd2a9 | 31011:01eebb65a61d |
---|---|
135 else: | 135 else: |
136 raise | 136 raise |
137 else: | 137 else: |
138 return False | 138 return False |
139 | 139 |
140 # IPv6 is used if IPv4 is not available and IPv6 is available. | 140 # useipv6 will be set by parseargs |
141 useipv6 = (not checksocketfamily('AF_INET')) and checksocketfamily('AF_INET6') | 141 useipv6 = None |
142 | 142 |
143 def checkportisavailable(port): | 143 def checkportisavailable(port): |
144 """return true if a port seems free to bind on localhost""" | 144 """return true if a port seems free to bind on localhost""" |
145 if useipv6: | 145 if useipv6: |
146 family = socket.AF_INET6 | 146 family = socket.AF_INET6 |
300 "temporary installation") | 300 "temporary installation") |
301 parser.add_option("--chg", action="store_true", | 301 parser.add_option("--chg", action="store_true", |
302 help="install and use chg wrapper in place of hg") | 302 help="install and use chg wrapper in place of hg") |
303 parser.add_option("--with-chg", metavar="CHG", | 303 parser.add_option("--with-chg", metavar="CHG", |
304 help="use specified chg wrapper in place of hg") | 304 help="use specified chg wrapper in place of hg") |
305 parser.add_option("--ipv6", action="store_true", | |
306 help="prefer IPv6 to IPv4 for network related tests") | |
305 parser.add_option("-3", "--py3k-warnings", action="store_true", | 307 parser.add_option("-3", "--py3k-warnings", action="store_true", |
306 help="enable Py3k warnings on Python 2.6+") | 308 help="enable Py3k warnings on Python 2.6+") |
307 # This option should be deleted once test-check-py3-compat.t and other | 309 # This option should be deleted once test-check-py3-compat.t and other |
308 # Python 3 tests run with Python 3. | 310 # Python 3 tests run with Python 3. |
309 parser.add_option("--with-python3", metavar="PYTHON3", | 311 parser.add_option("--with-python3", metavar="PYTHON3", |
368 parser.error('--with-chg must specify a chg executable') | 370 parser.error('--with-chg must specify a chg executable') |
369 if options.chg and options.with_hg: | 371 if options.chg and options.with_hg: |
370 # chg shares installation location with hg | 372 # chg shares installation location with hg |
371 parser.error('--chg does not work when --with-hg is specified ' | 373 parser.error('--chg does not work when --with-hg is specified ' |
372 '(use --with-chg instead)') | 374 '(use --with-chg instead)') |
375 | |
376 global useipv6 | |
377 if options.ipv6: | |
378 useipv6 = checksocketfamily('AF_INET6') | |
379 else: | |
380 # only use IPv6 if IPv4 is unavailable and IPv6 is available | |
381 useipv6 = ((not checksocketfamily('AF_INET')) | |
382 and checksocketfamily('AF_INET6')) | |
373 | 383 |
374 options.anycoverage = options.cover or options.annotate or options.htmlcov | 384 options.anycoverage = options.cover or options.annotate or options.htmlcov |
375 if options.anycoverage: | 385 if options.anycoverage: |
376 try: | 386 try: |
377 import coverage | 387 import coverage |