##// END OF EJS Templates
tests: use jshint when available to check .js files
av6 -
r35034:5d436907 default
parent child Browse files
Show More
@@ -0,0 +1,12
1 #require test-repo jshint hg10
2
3 $ . "$TESTDIR/helpers-testrepo.sh"
4
5 run jshint on all tracked files ending in .js except vendored dependencies
6
7 $ cd "`dirname "$TESTDIR"`"
8
9 $ testrepohg locate 'set:**.js' \
10 > -X mercurial/templates/static/excanvas.js \
11 > 2>/dev/null \
12 > | xargs jshint
@@ -1,687 +1,691
1 1 from __future__ import absolute_import
2 2
3 3 import errno
4 4 import os
5 5 import re
6 6 import socket
7 7 import stat
8 8 import subprocess
9 9 import sys
10 10 import tempfile
11 11
12 12 tempprefix = 'hg-hghave-'
13 13
14 14 checks = {
15 15 "true": (lambda: True, "yak shaving"),
16 16 "false": (lambda: False, "nail clipper"),
17 17 }
18 18
19 19 def check(name, desc):
20 20 """Registers a check function for a feature."""
21 21 def decorator(func):
22 22 checks[name] = (func, desc)
23 23 return func
24 24 return decorator
25 25
26 26 def checkvers(name, desc, vers):
27 27 """Registers a check function for each of a series of versions.
28 28
29 29 vers can be a list or an iterator"""
30 30 def decorator(func):
31 31 def funcv(v):
32 32 def f():
33 33 return func(v)
34 34 return f
35 35 for v in vers:
36 36 v = str(v)
37 37 f = funcv(v)
38 38 checks['%s%s' % (name, v.replace('.', ''))] = (f, desc % v)
39 39 return func
40 40 return decorator
41 41
42 42 def checkfeatures(features):
43 43 result = {
44 44 'error': [],
45 45 'missing': [],
46 46 'skipped': [],
47 47 }
48 48
49 49 for feature in features:
50 50 negate = feature.startswith('no-')
51 51 if negate:
52 52 feature = feature[3:]
53 53
54 54 if feature not in checks:
55 55 result['missing'].append(feature)
56 56 continue
57 57
58 58 check, desc = checks[feature]
59 59 try:
60 60 available = check()
61 61 except Exception:
62 62 result['error'].append('hghave check failed: %s' % feature)
63 63 continue
64 64
65 65 if not negate and not available:
66 66 result['skipped'].append('missing feature: %s' % desc)
67 67 elif negate and available:
68 68 result['skipped'].append('system supports %s' % desc)
69 69
70 70 return result
71 71
72 72 def require(features):
73 73 """Require that features are available, exiting if not."""
74 74 result = checkfeatures(features)
75 75
76 76 for missing in result['missing']:
77 77 sys.stderr.write('skipped: unknown feature: %s\n' % missing)
78 78 for msg in result['skipped']:
79 79 sys.stderr.write('skipped: %s\n' % msg)
80 80 for msg in result['error']:
81 81 sys.stderr.write('%s\n' % msg)
82 82
83 83 if result['missing']:
84 84 sys.exit(2)
85 85
86 86 if result['skipped'] or result['error']:
87 87 sys.exit(1)
88 88
89 89 def matchoutput(cmd, regexp, ignorestatus=False):
90 90 """Return the match object if cmd executes successfully and its output
91 91 is matched by the supplied regular expression.
92 92 """
93 93 r = re.compile(regexp)
94 94 try:
95 95 p = subprocess.Popen(
96 96 cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
97 97 except OSError as e:
98 98 if e.errno != errno.ENOENT:
99 99 raise
100 100 ret = -1
101 101 ret = p.wait()
102 102 s = p.stdout.read()
103 103 return (ignorestatus or not ret) and r.search(s)
104 104
105 105 @check("baz", "GNU Arch baz client")
106 106 def has_baz():
107 107 return matchoutput('baz --version 2>&1', br'baz Bazaar version')
108 108
109 109 @check("bzr", "Canonical's Bazaar client")
110 110 def has_bzr():
111 111 try:
112 112 import bzrlib
113 113 import bzrlib.bzrdir
114 114 import bzrlib.errors
115 115 import bzrlib.revision
116 116 import bzrlib.revisionspec
117 117 bzrlib.revisionspec.RevisionSpec
118 118 return bzrlib.__doc__ is not None
119 119 except (AttributeError, ImportError):
120 120 return False
121 121
122 122 @checkvers("bzr", "Canonical's Bazaar client >= %s", (1.14,))
123 123 def has_bzr_range(v):
124 124 major, minor = v.split('.')[0:2]
125 125 try:
126 126 import bzrlib
127 127 return (bzrlib.__doc__ is not None
128 128 and bzrlib.version_info[:2] >= (int(major), int(minor)))
129 129 except ImportError:
130 130 return False
131 131
132 132 @check("chg", "running with chg")
133 133 def has_chg():
134 134 return 'CHGHG' in os.environ
135 135
136 136 @check("cvs", "cvs client/server")
137 137 def has_cvs():
138 138 re = br'Concurrent Versions System.*?server'
139 139 return matchoutput('cvs --version 2>&1', re) and not has_msys()
140 140
141 141 @check("cvs112", "cvs client/server 1.12.* (not cvsnt)")
142 142 def has_cvs112():
143 143 re = br'Concurrent Versions System \(CVS\) 1.12.*?server'
144 144 return matchoutput('cvs --version 2>&1', re) and not has_msys()
145 145
146 146 @check("cvsnt", "cvsnt client/server")
147 147 def has_cvsnt():
148 148 re = br'Concurrent Versions System \(CVSNT\) (\d+).(\d+).*\(client/server\)'
149 149 return matchoutput('cvsnt --version 2>&1', re)
150 150
151 151 @check("darcs", "darcs client")
152 152 def has_darcs():
153 153 return matchoutput('darcs --version', br'\b2\.([2-9]|\d{2})', True)
154 154
155 155 @check("mtn", "monotone client (>= 1.0)")
156 156 def has_mtn():
157 157 return matchoutput('mtn --version', br'monotone', True) and not matchoutput(
158 158 'mtn --version', br'monotone 0\.', True)
159 159
160 160 @check("eol-in-paths", "end-of-lines in paths")
161 161 def has_eol_in_paths():
162 162 try:
163 163 fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix, suffix='\n\r')
164 164 os.close(fd)
165 165 os.remove(path)
166 166 return True
167 167 except (IOError, OSError):
168 168 return False
169 169
170 170 @check("execbit", "executable bit")
171 171 def has_executablebit():
172 172 try:
173 173 EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
174 174 fh, fn = tempfile.mkstemp(dir='.', prefix=tempprefix)
175 175 try:
176 176 os.close(fh)
177 177 m = os.stat(fn).st_mode & 0o777
178 178 new_file_has_exec = m & EXECFLAGS
179 179 os.chmod(fn, m ^ EXECFLAGS)
180 180 exec_flags_cannot_flip = ((os.stat(fn).st_mode & 0o777) == m)
181 181 finally:
182 182 os.unlink(fn)
183 183 except (IOError, OSError):
184 184 # we don't care, the user probably won't be able to commit anyway
185 185 return False
186 186 return not (new_file_has_exec or exec_flags_cannot_flip)
187 187
188 188 @check("icasefs", "case insensitive file system")
189 189 def has_icasefs():
190 190 # Stolen from mercurial.util
191 191 fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix)
192 192 os.close(fd)
193 193 try:
194 194 s1 = os.stat(path)
195 195 d, b = os.path.split(path)
196 196 p2 = os.path.join(d, b.upper())
197 197 if path == p2:
198 198 p2 = os.path.join(d, b.lower())
199 199 try:
200 200 s2 = os.stat(p2)
201 201 return s2 == s1
202 202 except OSError:
203 203 return False
204 204 finally:
205 205 os.remove(path)
206 206
207 207 @check("fifo", "named pipes")
208 208 def has_fifo():
209 209 if getattr(os, "mkfifo", None) is None:
210 210 return False
211 211 name = tempfile.mktemp(dir='.', prefix=tempprefix)
212 212 try:
213 213 os.mkfifo(name)
214 214 os.unlink(name)
215 215 return True
216 216 except OSError:
217 217 return False
218 218
219 219 @check("killdaemons", 'killdaemons.py support')
220 220 def has_killdaemons():
221 221 return True
222 222
223 223 @check("cacheable", "cacheable filesystem")
224 224 def has_cacheable_fs():
225 225 from mercurial import util
226 226
227 227 fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix)
228 228 os.close(fd)
229 229 try:
230 230 return util.cachestat(path).cacheable()
231 231 finally:
232 232 os.remove(path)
233 233
234 234 @check("lsprof", "python lsprof module")
235 235 def has_lsprof():
236 236 try:
237 237 import _lsprof
238 238 _lsprof.Profiler # silence unused import warning
239 239 return True
240 240 except ImportError:
241 241 return False
242 242
243 243 def gethgversion():
244 244 m = matchoutput('hg --version --quiet 2>&1', br'(\d+)\.(\d+)')
245 245 if not m:
246 246 return (0, 0)
247 247 return (int(m.group(1)), int(m.group(2)))
248 248
249 249 @checkvers("hg", "Mercurial >= %s",
250 250 list([(1.0 * x) / 10 for x in range(9, 99)]))
251 251 def has_hg_range(v):
252 252 major, minor = v.split('.')[0:2]
253 253 return gethgversion() >= (int(major), int(minor))
254 254
255 255 @check("hg08", "Mercurial >= 0.8")
256 256 def has_hg08():
257 257 if checks["hg09"][0]():
258 258 return True
259 259 return matchoutput('hg help annotate 2>&1', '--date')
260 260
261 261 @check("hg07", "Mercurial >= 0.7")
262 262 def has_hg07():
263 263 if checks["hg08"][0]():
264 264 return True
265 265 return matchoutput('hg --version --quiet 2>&1', 'Mercurial Distributed SCM')
266 266
267 267 @check("hg06", "Mercurial >= 0.6")
268 268 def has_hg06():
269 269 if checks["hg07"][0]():
270 270 return True
271 271 return matchoutput('hg --version --quiet 2>&1', 'Mercurial version')
272 272
273 273 @check("gettext", "GNU Gettext (msgfmt)")
274 274 def has_gettext():
275 275 return matchoutput('msgfmt --version', br'GNU gettext-tools')
276 276
277 277 @check("git", "git command line client")
278 278 def has_git():
279 279 return matchoutput('git --version 2>&1', br'^git version')
280 280
281 281 def getgitversion():
282 282 m = matchoutput('git --version 2>&1', br'git version (\d+)\.(\d+)')
283 283 if not m:
284 284 return (0, 0)
285 285 return (int(m.group(1)), int(m.group(2)))
286 286
287 287 @checkvers("git", "git client (with ext::sh support) version >= %s", (1.9,))
288 288 def has_git_range(v):
289 289 major, minor = v.split('.')[0:2]
290 290 return getgitversion() >= (int(major), int(minor))
291 291
292 292 @check("docutils", "Docutils text processing library")
293 293 def has_docutils():
294 294 try:
295 295 import docutils.core
296 296 docutils.core.publish_cmdline # silence unused import
297 297 return True
298 298 except ImportError:
299 299 return False
300 300
301 301 def getsvnversion():
302 302 m = matchoutput('svn --version --quiet 2>&1', br'^(\d+)\.(\d+)')
303 303 if not m:
304 304 return (0, 0)
305 305 return (int(m.group(1)), int(m.group(2)))
306 306
307 307 @checkvers("svn", "subversion client and admin tools >= %s", (1.3, 1.5))
308 308 def has_svn_range(v):
309 309 major, minor = v.split('.')[0:2]
310 310 return getsvnversion() >= (int(major), int(minor))
311 311
312 312 @check("svn", "subversion client and admin tools")
313 313 def has_svn():
314 314 return matchoutput('svn --version 2>&1', br'^svn, version') and \
315 315 matchoutput('svnadmin --version 2>&1', br'^svnadmin, version')
316 316
317 317 @check("svn-bindings", "subversion python bindings")
318 318 def has_svn_bindings():
319 319 try:
320 320 import svn.core
321 321 version = svn.core.SVN_VER_MAJOR, svn.core.SVN_VER_MINOR
322 322 if version < (1, 4):
323 323 return False
324 324 return True
325 325 except ImportError:
326 326 return False
327 327
328 328 @check("p4", "Perforce server and client")
329 329 def has_p4():
330 330 return (matchoutput('p4 -V', br'Rev\. P4/') and
331 331 matchoutput('p4d -V', br'Rev\. P4D/'))
332 332
333 333 @check("symlink", "symbolic links")
334 334 def has_symlink():
335 335 if getattr(os, "symlink", None) is None:
336 336 return False
337 337 name = tempfile.mktemp(dir='.', prefix=tempprefix)
338 338 try:
339 339 os.symlink(".", name)
340 340 os.unlink(name)
341 341 return True
342 342 except (OSError, AttributeError):
343 343 return False
344 344
345 345 @check("hardlink", "hardlinks")
346 346 def has_hardlink():
347 347 from mercurial import util
348 348 fh, fn = tempfile.mkstemp(dir='.', prefix=tempprefix)
349 349 os.close(fh)
350 350 name = tempfile.mktemp(dir='.', prefix=tempprefix)
351 351 try:
352 352 util.oslink(fn, name)
353 353 os.unlink(name)
354 354 return True
355 355 except OSError:
356 356 return False
357 357 finally:
358 358 os.unlink(fn)
359 359
360 360 @check("hardlink-whitelisted", "hardlinks on whitelisted filesystems")
361 361 def has_hardlink_whitelisted():
362 362 from mercurial import util
363 363 try:
364 364 fstype = util.getfstype('.')
365 365 except OSError:
366 366 return False
367 367 return fstype in util._hardlinkfswhitelist
368 368
369 369 @check("rmcwd", "can remove current working directory")
370 370 def has_rmcwd():
371 371 ocwd = os.getcwd()
372 372 temp = tempfile.mkdtemp(dir='.', prefix=tempprefix)
373 373 try:
374 374 os.chdir(temp)
375 375 # On Linux, 'rmdir .' isn't allowed, but the other names are okay.
376 376 # On Solaris and Windows, the cwd can't be removed by any names.
377 377 os.rmdir(os.getcwd())
378 378 return True
379 379 except OSError:
380 380 return False
381 381 finally:
382 382 os.chdir(ocwd)
383 383 # clean up temp dir on platforms where cwd can't be removed
384 384 try:
385 385 os.rmdir(temp)
386 386 except OSError:
387 387 pass
388 388
389 389 @check("tla", "GNU Arch tla client")
390 390 def has_tla():
391 391 return matchoutput('tla --version 2>&1', br'The GNU Arch Revision')
392 392
393 393 @check("gpg", "gpg client")
394 394 def has_gpg():
395 395 return matchoutput('gpg --version 2>&1', br'GnuPG')
396 396
397 397 @check("gpg2", "gpg client v2")
398 398 def has_gpg2():
399 399 return matchoutput('gpg --version 2>&1', br'GnuPG[^0-9]+2\.')
400 400
401 401 @check("gpg21", "gpg client v2.1+")
402 402 def has_gpg21():
403 403 return matchoutput('gpg --version 2>&1', br'GnuPG[^0-9]+2\.(?!0)')
404 404
405 405 @check("unix-permissions", "unix-style permissions")
406 406 def has_unix_permissions():
407 407 d = tempfile.mkdtemp(dir='.', prefix=tempprefix)
408 408 try:
409 409 fname = os.path.join(d, 'foo')
410 410 for umask in (0o77, 0o07, 0o22):
411 411 os.umask(umask)
412 412 f = open(fname, 'w')
413 413 f.close()
414 414 mode = os.stat(fname).st_mode
415 415 os.unlink(fname)
416 416 if mode & 0o777 != ~umask & 0o666:
417 417 return False
418 418 return True
419 419 finally:
420 420 os.rmdir(d)
421 421
422 422 @check("unix-socket", "AF_UNIX socket family")
423 423 def has_unix_socket():
424 424 return getattr(socket, 'AF_UNIX', None) is not None
425 425
426 426 @check("root", "root permissions")
427 427 def has_root():
428 428 return getattr(os, 'geteuid', None) and os.geteuid() == 0
429 429
430 430 @check("pyflakes", "Pyflakes python linter")
431 431 def has_pyflakes():
432 432 return matchoutput("sh -c \"echo 'import re' 2>&1 | pyflakes\"",
433 433 br"<stdin>:1: 're' imported but unused",
434 434 True)
435 435
436 436 @check("pylint", "Pylint python linter")
437 437 def has_pylint():
438 438 return matchoutput("pylint --help",
439 439 br"Usage: pylint",
440 440 True)
441 441
442 442 @check("clang-format", "clang-format C code formatter")
443 443 def has_clang_format():
444 444 return matchoutput("clang-format --help",
445 445 br"^OVERVIEW: A tool to format C/C\+\+[^ ]+ code.")
446 446
447 @check("jshint", "JSHint static code analysis tool")
448 def has_jshint():
449 return matchoutput("jshint --version 2>&1", br"jshint v")
450
447 451 @check("pygments", "Pygments source highlighting library")
448 452 def has_pygments():
449 453 try:
450 454 import pygments
451 455 pygments.highlight # silence unused import warning
452 456 return True
453 457 except ImportError:
454 458 return False
455 459
456 460 @check("outer-repo", "outer repo")
457 461 def has_outer_repo():
458 462 # failing for other reasons than 'no repo' imply that there is a repo
459 463 return not matchoutput('hg root 2>&1',
460 464 br'abort: no repository found', True)
461 465
462 466 @check("ssl", "ssl module available")
463 467 def has_ssl():
464 468 try:
465 469 import ssl
466 470 ssl.CERT_NONE
467 471 return True
468 472 except ImportError:
469 473 return False
470 474
471 475 @check("sslcontext", "python >= 2.7.9 ssl")
472 476 def has_sslcontext():
473 477 try:
474 478 import ssl
475 479 ssl.SSLContext
476 480 return True
477 481 except (ImportError, AttributeError):
478 482 return False
479 483
480 484 @check("defaultcacerts", "can verify SSL certs by system's CA certs store")
481 485 def has_defaultcacerts():
482 486 from mercurial import sslutil, ui as uimod
483 487 ui = uimod.ui.load()
484 488 return sslutil._defaultcacerts(ui) or sslutil._canloaddefaultcerts
485 489
486 490 @check("defaultcacertsloaded", "detected presence of loaded system CA certs")
487 491 def has_defaultcacertsloaded():
488 492 import ssl
489 493 from mercurial import sslutil, ui as uimod
490 494
491 495 if not has_defaultcacerts():
492 496 return False
493 497 if not has_sslcontext():
494 498 return False
495 499
496 500 ui = uimod.ui.load()
497 501 cafile = sslutil._defaultcacerts(ui)
498 502 ctx = ssl.create_default_context()
499 503 if cafile:
500 504 ctx.load_verify_locations(cafile=cafile)
501 505 else:
502 506 ctx.load_default_certs()
503 507
504 508 return len(ctx.get_ca_certs()) > 0
505 509
506 510 @check("tls1.2", "TLS 1.2 protocol support")
507 511 def has_tls1_2():
508 512 from mercurial import sslutil
509 513 return 'tls1.2' in sslutil.supportedprotocols
510 514
511 515 @check("windows", "Windows")
512 516 def has_windows():
513 517 return os.name == 'nt'
514 518
515 519 @check("system-sh", "system() uses sh")
516 520 def has_system_sh():
517 521 return os.name != 'nt'
518 522
519 523 @check("serve", "platform and python can manage 'hg serve -d'")
520 524 def has_serve():
521 525 return True
522 526
523 527 @check("test-repo", "running tests from repository")
524 528 def has_test_repo():
525 529 t = os.environ["TESTDIR"]
526 530 return os.path.isdir(os.path.join(t, "..", ".hg"))
527 531
528 532 @check("tic", "terminfo compiler and curses module")
529 533 def has_tic():
530 534 try:
531 535 import curses
532 536 curses.COLOR_BLUE
533 537 return matchoutput('test -x "`which tic`"', br'')
534 538 except ImportError:
535 539 return False
536 540
537 541 @check("msys", "Windows with MSYS")
538 542 def has_msys():
539 543 return os.getenv('MSYSTEM')
540 544
541 545 @check("aix", "AIX")
542 546 def has_aix():
543 547 return sys.platform.startswith("aix")
544 548
545 549 @check("osx", "OS X")
546 550 def has_osx():
547 551 return sys.platform == 'darwin'
548 552
549 553 @check("osxpackaging", "OS X packaging tools")
550 554 def has_osxpackaging():
551 555 try:
552 556 return (matchoutput('pkgbuild', br'Usage: pkgbuild ', ignorestatus=1)
553 557 and matchoutput(
554 558 'productbuild', br'Usage: productbuild ',
555 559 ignorestatus=1)
556 560 and matchoutput('lsbom', br'Usage: lsbom', ignorestatus=1)
557 561 and matchoutput(
558 562 'xar --help', br'Usage: xar', ignorestatus=1))
559 563 except ImportError:
560 564 return False
561 565
562 566 @check('linuxormacos', 'Linux or MacOS')
563 567 def has_linuxormacos():
564 568 # This isn't a perfect test for MacOS. But it is sufficient for our needs.
565 569 return sys.platform.startswith(('linux', 'darwin'))
566 570
567 571 @check("docker", "docker support")
568 572 def has_docker():
569 573 pat = br'A self-sufficient runtime for'
570 574 if matchoutput('docker --help', pat):
571 575 if 'linux' not in sys.platform:
572 576 # TODO: in theory we should be able to test docker-based
573 577 # package creation on non-linux using boot2docker, but in
574 578 # practice that requires extra coordination to make sure
575 579 # $TESTTEMP is going to be visible at the same path to the
576 580 # boot2docker VM. If we figure out how to verify that, we
577 581 # can use the following instead of just saying False:
578 582 # return 'DOCKER_HOST' in os.environ
579 583 return False
580 584
581 585 return True
582 586 return False
583 587
584 588 @check("debhelper", "debian packaging tools")
585 589 def has_debhelper():
586 590 # Some versions of dpkg say `dpkg', some say 'dpkg' (` vs ' on the first
587 591 # quote), so just accept anything in that spot.
588 592 dpkg = matchoutput('dpkg --version',
589 593 br"Debian .dpkg' package management program")
590 594 dh = matchoutput('dh --help',
591 595 br'dh is a part of debhelper.', ignorestatus=True)
592 596 dh_py2 = matchoutput('dh_python2 --help',
593 597 br'other supported Python versions')
594 598 # debuild comes from the 'devscripts' package, though you might want
595 599 # the 'build-debs' package instead, which has a dependency on devscripts.
596 600 debuild = matchoutput('debuild --help',
597 601 br'to run debian/rules with given parameter')
598 602 return dpkg and dh and dh_py2 and debuild
599 603
600 604 @check("debdeps",
601 605 "debian build dependencies (run dpkg-checkbuilddeps in contrib/)")
602 606 def has_debdeps():
603 607 # just check exit status (ignoring output)
604 608 path = '%s/../contrib/debian/control' % os.environ['TESTDIR']
605 609 return matchoutput('dpkg-checkbuilddeps %s' % path, br'')
606 610
607 611 @check("demandimport", "demandimport enabled")
608 612 def has_demandimport():
609 613 # chg disables demandimport intentionally for performance wins.
610 614 return ((not has_chg()) and os.environ.get('HGDEMANDIMPORT') != 'disable')
611 615
612 616 @check("py3k", "running with Python 3.x")
613 617 def has_py3k():
614 618 return 3 == sys.version_info[0]
615 619
616 620 @check("py3exe", "a Python 3.x interpreter is available")
617 621 def has_python3exe():
618 622 return 'PYTHON3' in os.environ
619 623
620 624 @check("py3pygments", "Pygments available on Python 3.x")
621 625 def has_py3pygments():
622 626 if has_py3k():
623 627 return has_pygments()
624 628 elif has_python3exe():
625 629 # just check exit status (ignoring output)
626 630 py3 = os.environ['PYTHON3']
627 631 return matchoutput('%s -c "import pygments"' % py3, br'')
628 632 return False
629 633
630 634 @check("pure", "running with pure Python code")
631 635 def has_pure():
632 636 return any([
633 637 os.environ.get("HGMODULEPOLICY") == "py",
634 638 os.environ.get("HGTEST_RUN_TESTS_PURE") == "--pure",
635 639 ])
636 640
637 641 @check("slow", "allow slow tests (use --allow-slow-tests)")
638 642 def has_slow():
639 643 return os.environ.get('HGTEST_SLOW') == 'slow'
640 644
641 645 @check("hypothesis", "Hypothesis automated test generation")
642 646 def has_hypothesis():
643 647 try:
644 648 import hypothesis
645 649 hypothesis.given
646 650 return True
647 651 except ImportError:
648 652 return False
649 653
650 654 @check("unziplinks", "unzip(1) understands and extracts symlinks")
651 655 def unzip_understands_symlinks():
652 656 return matchoutput('unzip --help', br'Info-ZIP')
653 657
654 658 @check("zstd", "zstd Python module available")
655 659 def has_zstd():
656 660 try:
657 661 import mercurial.zstd
658 662 mercurial.zstd.__version__
659 663 return True
660 664 except ImportError:
661 665 return False
662 666
663 667 @check("devfull", "/dev/full special file")
664 668 def has_dev_full():
665 669 return os.path.exists('/dev/full')
666 670
667 671 @check("virtualenv", "Python virtualenv support")
668 672 def has_virtualenv():
669 673 try:
670 674 import virtualenv
671 675 virtualenv.ACTIVATE_SH
672 676 return True
673 677 except ImportError:
674 678 return False
675 679
676 680 @check("fsmonitor", "running tests with fsmonitor")
677 681 def has_fsmonitor():
678 682 return 'HGFSMONITOR_TESTS' in os.environ
679 683
680 684 @check("fuzzywuzzy", "Fuzzy string matching library")
681 685 def has_fuzzywuzzy():
682 686 try:
683 687 import fuzzywuzzy
684 688 fuzzywuzzy.__version__
685 689 return True
686 690 except ImportError:
687 691 return False
General Comments 0
You need to be logged in to leave comments. Login now