Mercurial > hg
comparison tests/hghave @ 26067:8107c308ff22
hghave: move feature checking into hghave.py
Upcoming patches will kill hghave (the script - not hghave.py) and
will move to a model where requirements checking is performed as
a function call.
Start diminishing the utility of hghave by moving some code to
hghave.py.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 22 Aug 2015 10:28:34 -0700 |
parents | b94df10cc3b5 |
children | 05e7f57c74ac |
comparison
equal
deleted
inserted
replaced
26066:89872688893f | 26067:8107c308ff22 |
---|---|
62 sys.exit(0) | 62 sys.exit(0) |
63 | 63 |
64 if options.test_features: | 64 if options.test_features: |
65 sys.exit(test_features()) | 65 sys.exit(test_features()) |
66 | 66 |
67 quiet = options.quiet | 67 hghave.require(args, options.quiet) |
68 | |
69 failures = 0 | |
70 | |
71 def error(msg): | |
72 global failures | |
73 if not quiet: | |
74 sys.stderr.write(msg + '\n') | |
75 failures += 1 | |
76 | |
77 for feature in args: | |
78 negate = feature.startswith('no-') | |
79 if negate: | |
80 feature = feature[3:] | |
81 | |
82 if feature not in checks: | |
83 error('skipped: unknown feature: ' + feature) | |
84 sys.exit(2) | |
85 | |
86 check, desc = checks[feature] | |
87 try: | |
88 available = check() | |
89 except Exception, e: | |
90 error('hghave check failed: ' + feature) | |
91 continue | |
92 | |
93 if not negate and not available: | |
94 error('skipped: missing feature: ' + desc) | |
95 elif negate and available: | |
96 error('skipped: system supports %s' % desc) | |
97 | |
98 if failures != 0: | |
99 sys.exit(1) |