Mercurial > hg-git
comparison tests/hghave @ 565:8c6dc6a6f5d8
tests: pull in hghave
Previously, the hghave checks that were commented out in the tests were broken
if uncommented. One cause was that it was expecting hghave in the testdir,
while our testdir didn't contain hghave. Now it does.
The hghave was pulled unmodified from Mercurial 2.3, to match the version of
run-tests.py in use.
author | David M. Carr <david@carrclan.us> |
---|---|
date | Sun, 28 Oct 2012 21:05:51 -0400 |
parents | |
children | cca56bbea143 |
comparison
equal
deleted
inserted
replaced
564:b3881fda3ce9 | 565:8c6dc6a6f5d8 |
---|---|
1 #!/usr/bin/env python | |
2 """Test the running system for features availability. Exit with zero | |
3 if all features are there, non-zero otherwise. If a feature name is | |
4 prefixed with "no-", the absence of feature is tested. | |
5 """ | |
6 import optparse | |
7 import sys | |
8 import hghave | |
9 | |
10 checks = hghave.checks | |
11 | |
12 def list_features(): | |
13 for name, feature in checks.iteritems(): | |
14 desc = feature[1] | |
15 print name + ':', desc | |
16 | |
17 def test_features(): | |
18 failed = 0 | |
19 for name, feature in checks.iteritems(): | |
20 check, _ = feature | |
21 try: | |
22 check() | |
23 except Exception, e: | |
24 print "feature %s failed: %s" % (name, e) | |
25 failed += 1 | |
26 return failed | |
27 | |
28 parser = optparse.OptionParser("%prog [options] [features]") | |
29 parser.add_option("--test-features", action="store_true", | |
30 help="test available features") | |
31 parser.add_option("--list-features", action="store_true", | |
32 help="list available features") | |
33 parser.add_option("-q", "--quiet", action="store_true", | |
34 help="check features silently") | |
35 | |
36 if __name__ == '__main__': | |
37 options, args = parser.parse_args() | |
38 if options.list_features: | |
39 list_features() | |
40 sys.exit(0) | |
41 | |
42 if options.test_features: | |
43 sys.exit(test_features()) | |
44 | |
45 quiet = options.quiet | |
46 | |
47 failures = 0 | |
48 | |
49 def error(msg): | |
50 global failures | |
51 if not quiet: | |
52 sys.stderr.write(msg + '\n') | |
53 failures += 1 | |
54 | |
55 for feature in args: | |
56 negate = feature.startswith('no-') | |
57 if negate: | |
58 feature = feature[3:] | |
59 | |
60 if feature not in checks: | |
61 error('skipped: unknown feature: ' + feature) | |
62 continue | |
63 | |
64 check, desc = checks[feature] | |
65 try: | |
66 available = check() | |
67 except Exception, e: | |
68 error('hghave check failed: ' + feature) | |
69 continue | |
70 | |
71 if not negate and not available: | |
72 error('skipped: missing feature: ' + desc) | |
73 elif negate and available: | |
74 error('skipped: system supports %s' % desc) | |
75 | |
76 if failures != 0: | |
77 sys.exit(1) |