Mercurial > hg
comparison tests/hghave.py @ 29140:47eab0cb72e3
hghave: matchoutput needs to use bytes for regexp
file output is bytes in py3, so we need each regexp to be bytes
author | timeless <timeless@mozdev.org> |
---|---|
date | Thu, 05 May 2016 09:07:01 +0000 |
parents | c8fbfb9163ce |
children | 5caa415aa48b |
comparison
equal
deleted
inserted
replaced
29139:64c1955a0461 | 29140:47eab0cb72e3 |
---|---|
102 s = p.stdout.read() | 102 s = p.stdout.read() |
103 return (ignorestatus or not ret) and r.search(s) | 103 return (ignorestatus or not ret) and r.search(s) |
104 | 104 |
105 @check("baz", "GNU Arch baz client") | 105 @check("baz", "GNU Arch baz client") |
106 def has_baz(): | 106 def has_baz(): |
107 return matchoutput('baz --version 2>&1', r'baz Bazaar version') | 107 return matchoutput('baz --version 2>&1', br'baz Bazaar version') |
108 | 108 |
109 @check("bzr", "Canonical's Bazaar client") | 109 @check("bzr", "Canonical's Bazaar client") |
110 def has_bzr(): | 110 def has_bzr(): |
111 try: | 111 try: |
112 import bzrlib | 112 import bzrlib |
128 def has_chg(): | 128 def has_chg(): |
129 return 'CHGHG' in os.environ | 129 return 'CHGHG' in os.environ |
130 | 130 |
131 @check("cvs", "cvs client/server") | 131 @check("cvs", "cvs client/server") |
132 def has_cvs(): | 132 def has_cvs(): |
133 re = r'Concurrent Versions System.*?server' | 133 re = br'Concurrent Versions System.*?server' |
134 return matchoutput('cvs --version 2>&1', re) and not has_msys() | 134 return matchoutput('cvs --version 2>&1', re) and not has_msys() |
135 | 135 |
136 @check("cvs112", "cvs client/server 1.12.* (not cvsnt)") | 136 @check("cvs112", "cvs client/server 1.12.* (not cvsnt)") |
137 def has_cvs112(): | 137 def has_cvs112(): |
138 re = r'Concurrent Versions System \(CVS\) 1.12.*?server' | 138 re = br'Concurrent Versions System \(CVS\) 1.12.*?server' |
139 return matchoutput('cvs --version 2>&1', re) and not has_msys() | 139 return matchoutput('cvs --version 2>&1', re) and not has_msys() |
140 | 140 |
141 @check("cvsnt", "cvsnt client/server") | 141 @check("cvsnt", "cvsnt client/server") |
142 def has_cvsnt(): | 142 def has_cvsnt(): |
143 re = r'Concurrent Versions System \(CVSNT\) (\d+).(\d+).*\(client/server\)' | 143 re = br'Concurrent Versions System \(CVSNT\) (\d+).(\d+).*\(client/server\)' |
144 return matchoutput('cvsnt --version 2>&1', re) | 144 return matchoutput('cvsnt --version 2>&1', re) |
145 | 145 |
146 @check("darcs", "darcs client") | 146 @check("darcs", "darcs client") |
147 def has_darcs(): | 147 def has_darcs(): |
148 return matchoutput('darcs --version', r'2\.[2-9]', True) | 148 return matchoutput('darcs --version', br'2\.[2-9]', True) |
149 | 149 |
150 @check("mtn", "monotone client (>= 1.0)") | 150 @check("mtn", "monotone client (>= 1.0)") |
151 def has_mtn(): | 151 def has_mtn(): |
152 return matchoutput('mtn --version', r'monotone', True) and not matchoutput( | 152 return matchoutput('mtn --version', br'monotone', True) and not matchoutput( |
153 'mtn --version', r'monotone 0\.', True) | 153 'mtn --version', br'monotone 0\.', True) |
154 | 154 |
155 @check("eol-in-paths", "end-of-lines in paths") | 155 @check("eol-in-paths", "end-of-lines in paths") |
156 def has_eol_in_paths(): | 156 def has_eol_in_paths(): |
157 try: | 157 try: |
158 fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix, suffix='\n\r') | 158 fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix, suffix='\n\r') |
234 return True | 234 return True |
235 except ImportError: | 235 except ImportError: |
236 return False | 236 return False |
237 | 237 |
238 def gethgversion(): | 238 def gethgversion(): |
239 m = matchoutput('hg --version --quiet 2>&1', r'(\d+)\.(\d+)') | 239 m = matchoutput('hg --version --quiet 2>&1', br'(\d+)\.(\d+)') |
240 if not m: | 240 if not m: |
241 return (0, 0) | 241 return (0, 0) |
242 return (int(m.group(1)), int(m.group(2))) | 242 return (int(m.group(1)), int(m.group(2))) |
243 | 243 |
244 @checkvers("hg", "Mercurial >= %s", | 244 @checkvers("hg", "Mercurial >= %s", |
265 return True | 265 return True |
266 return matchoutput('hg --version --quiet 2>&1', 'Mercurial version') | 266 return matchoutput('hg --version --quiet 2>&1', 'Mercurial version') |
267 | 267 |
268 @check("gettext", "GNU Gettext (msgfmt)") | 268 @check("gettext", "GNU Gettext (msgfmt)") |
269 def has_gettext(): | 269 def has_gettext(): |
270 return matchoutput('msgfmt --version', 'GNU gettext-tools') | 270 return matchoutput('msgfmt --version', br'GNU gettext-tools') |
271 | 271 |
272 @check("git", "git command line client") | 272 @check("git", "git command line client") |
273 def has_git(): | 273 def has_git(): |
274 return matchoutput('git --version 2>&1', r'^git version') | 274 return matchoutput('git --version 2>&1', br'^git version') |
275 | 275 |
276 @check("docutils", "Docutils text processing library") | 276 @check("docutils", "Docutils text processing library") |
277 def has_docutils(): | 277 def has_docutils(): |
278 try: | 278 try: |
279 import docutils.core | 279 import docutils.core |
281 return True | 281 return True |
282 except ImportError: | 282 except ImportError: |
283 return False | 283 return False |
284 | 284 |
285 def getsvnversion(): | 285 def getsvnversion(): |
286 m = matchoutput('svn --version --quiet 2>&1', r'^(\d+)\.(\d+)') | 286 m = matchoutput('svn --version --quiet 2>&1', br'^(\d+)\.(\d+)') |
287 if not m: | 287 if not m: |
288 return (0, 0) | 288 return (0, 0) |
289 return (int(m.group(1)), int(m.group(2))) | 289 return (int(m.group(1)), int(m.group(2))) |
290 | 290 |
291 @checkvers("svn", "subversion client and admin tools >= %s", (1.3, 1.5)) | 291 @checkvers("svn", "subversion client and admin tools >= %s", (1.3, 1.5)) |
293 major, minor = v.split('.')[0:2] | 293 major, minor = v.split('.')[0:2] |
294 return getsvnversion() >= (int(major), int(minor)) | 294 return getsvnversion() >= (int(major), int(minor)) |
295 | 295 |
296 @check("svn", "subversion client and admin tools") | 296 @check("svn", "subversion client and admin tools") |
297 def has_svn(): | 297 def has_svn(): |
298 return matchoutput('svn --version 2>&1', r'^svn, version') and \ | 298 return matchoutput('svn --version 2>&1', br'^svn, version') and \ |
299 matchoutput('svnadmin --version 2>&1', r'^svnadmin, version') | 299 matchoutput('svnadmin --version 2>&1', br'^svnadmin, version') |
300 | 300 |
301 @check("svn-bindings", "subversion python bindings") | 301 @check("svn-bindings", "subversion python bindings") |
302 def has_svn_bindings(): | 302 def has_svn_bindings(): |
303 try: | 303 try: |
304 import svn.core | 304 import svn.core |
309 except ImportError: | 309 except ImportError: |
310 return False | 310 return False |
311 | 311 |
312 @check("p4", "Perforce server and client") | 312 @check("p4", "Perforce server and client") |
313 def has_p4(): | 313 def has_p4(): |
314 return (matchoutput('p4 -V', r'Rev\. P4/') and | 314 return (matchoutput('p4 -V', br'Rev\. P4/') and |
315 matchoutput('p4d -V', r'Rev\. P4D/')) | 315 matchoutput('p4d -V', br'Rev\. P4D/')) |
316 | 316 |
317 @check("symlink", "symbolic links") | 317 @check("symlink", "symbolic links") |
318 def has_symlink(): | 318 def has_symlink(): |
319 if getattr(os, "symlink", None) is None: | 319 if getattr(os, "symlink", None) is None: |
320 return False | 320 return False |
341 finally: | 341 finally: |
342 os.unlink(fn) | 342 os.unlink(fn) |
343 | 343 |
344 @check("tla", "GNU Arch tla client") | 344 @check("tla", "GNU Arch tla client") |
345 def has_tla(): | 345 def has_tla(): |
346 return matchoutput('tla --version 2>&1', r'The GNU Arch Revision') | 346 return matchoutput('tla --version 2>&1', br'The GNU Arch Revision') |
347 | 347 |
348 @check("gpg", "gpg client") | 348 @check("gpg", "gpg client") |
349 def has_gpg(): | 349 def has_gpg(): |
350 return matchoutput('gpg --version 2>&1', r'GnuPG') | 350 return matchoutput('gpg --version 2>&1', br'GnuPG') |
351 | 351 |
352 @check("unix-permissions", "unix-style permissions") | 352 @check("unix-permissions", "unix-style permissions") |
353 def has_unix_permissions(): | 353 def has_unix_permissions(): |
354 d = tempfile.mkdtemp(dir='.', prefix=tempprefix) | 354 d = tempfile.mkdtemp(dir='.', prefix=tempprefix) |
355 try: | 355 try: |
375 return getattr(os, 'geteuid', None) and os.geteuid() == 0 | 375 return getattr(os, 'geteuid', None) and os.geteuid() == 0 |
376 | 376 |
377 @check("pyflakes", "Pyflakes python linter") | 377 @check("pyflakes", "Pyflakes python linter") |
378 def has_pyflakes(): | 378 def has_pyflakes(): |
379 return matchoutput("sh -c \"echo 'import re' 2>&1 | pyflakes\"", | 379 return matchoutput("sh -c \"echo 'import re' 2>&1 | pyflakes\"", |
380 r"<stdin>:1: 're' imported but unused", | 380 br"<stdin>:1: 're' imported but unused", |
381 True) | 381 True) |
382 | 382 |
383 @check("pygments", "Pygments source highlighting library") | 383 @check("pygments", "Pygments source highlighting library") |
384 def has_pygments(): | 384 def has_pygments(): |
385 try: | 385 try: |
391 | 391 |
392 @check("outer-repo", "outer repo") | 392 @check("outer-repo", "outer repo") |
393 def has_outer_repo(): | 393 def has_outer_repo(): |
394 # failing for other reasons than 'no repo' imply that there is a repo | 394 # failing for other reasons than 'no repo' imply that there is a repo |
395 return not matchoutput('hg root 2>&1', | 395 return not matchoutput('hg root 2>&1', |
396 r'abort: no repository found', True) | 396 br'abort: no repository found', True) |
397 | 397 |
398 @check("ssl", "ssl module available") | 398 @check("ssl", "ssl module available") |
399 def has_ssl(): | 399 def has_ssl(): |
400 try: | 400 try: |
401 import ssl | 401 import ssl |
438 @check("tic", "terminfo compiler and curses module") | 438 @check("tic", "terminfo compiler and curses module") |
439 def has_tic(): | 439 def has_tic(): |
440 try: | 440 try: |
441 import curses | 441 import curses |
442 curses.COLOR_BLUE | 442 curses.COLOR_BLUE |
443 return matchoutput('test -x "`which tic`"', '') | 443 return matchoutput('test -x "`which tic`"', br'') |
444 except ImportError: | 444 except ImportError: |
445 return False | 445 return False |
446 | 446 |
447 @check("msys", "Windows with MSYS") | 447 @check("msys", "Windows with MSYS") |
448 def has_msys(): | 448 def has_msys(): |
457 return sys.platform == 'darwin' | 457 return sys.platform == 'darwin' |
458 | 458 |
459 @check("osxpackaging", "OS X packaging tools") | 459 @check("osxpackaging", "OS X packaging tools") |
460 def has_osxpackaging(): | 460 def has_osxpackaging(): |
461 try: | 461 try: |
462 return (matchoutput('pkgbuild', 'Usage: pkgbuild ', ignorestatus=1) | 462 return (matchoutput('pkgbuild', br'Usage: pkgbuild ', ignorestatus=1) |
463 and matchoutput( | 463 and matchoutput( |
464 'productbuild', 'Usage: productbuild ', | 464 'productbuild', br'Usage: productbuild ', |
465 ignorestatus=1) | 465 ignorestatus=1) |
466 and matchoutput('lsbom', 'Usage: lsbom', ignorestatus=1) | 466 and matchoutput('lsbom', br'Usage: lsbom', ignorestatus=1) |
467 and matchoutput( | 467 and matchoutput( |
468 'xar --help', 'Usage: xar', ignorestatus=1)) | 468 'xar --help', br'Usage: xar', ignorestatus=1)) |
469 except ImportError: | 469 except ImportError: |
470 return False | 470 return False |
471 | 471 |
472 @check("docker", "docker support") | 472 @check("docker", "docker support") |
473 def has_docker(): | 473 def has_docker(): |
474 pat = r'A self-sufficient runtime for' | 474 pat = br'A self-sufficient runtime for' |
475 if matchoutput('docker --help', pat): | 475 if matchoutput('docker --help', pat): |
476 if 'linux' not in sys.platform: | 476 if 'linux' not in sys.platform: |
477 # TODO: in theory we should be able to test docker-based | 477 # TODO: in theory we should be able to test docker-based |
478 # package creation on non-linux using boot2docker, but in | 478 # package creation on non-linux using boot2docker, but in |
479 # practice that requires extra coordination to make sure | 479 # practice that requires extra coordination to make sure |
487 return False | 487 return False |
488 | 488 |
489 @check("debhelper", "debian packaging tools") | 489 @check("debhelper", "debian packaging tools") |
490 def has_debhelper(): | 490 def has_debhelper(): |
491 dpkg = matchoutput('dpkg --version', | 491 dpkg = matchoutput('dpkg --version', |
492 "Debian `dpkg' package management program") | 492 br"Debian `dpkg' package management program") |
493 dh = matchoutput('dh --help', | 493 dh = matchoutput('dh --help', |
494 'dh is a part of debhelper.', ignorestatus=True) | 494 br'dh is a part of debhelper.', ignorestatus=True) |
495 dh_py2 = matchoutput('dh_python2 --help', | 495 dh_py2 = matchoutput('dh_python2 --help', |
496 'other supported Python versions') | 496 br'other supported Python versions') |
497 return dpkg and dh and dh_py2 | 497 return dpkg and dh and dh_py2 |
498 | 498 |
499 @check("absimport", "absolute_import in __future__") | 499 @check("absimport", "absolute_import in __future__") |
500 def has_absimport(): | 500 def has_absimport(): |
501 import __future__ | 501 import __future__ |