##// END OF EJS Templates
hghave: use print function...
Gregory Szorc -
r28283:54444499 default
parent child Browse files
Show More
@@ -1,64 +1,67 b''
1 1 #!/usr/bin/env python
2 2 """Test the running system for features availability. Exit with zero
3 3 if all features are there, non-zero otherwise. If a feature name is
4 4 prefixed with "no-", the absence of feature is tested.
5 5 """
6
7 from __future__ import print_function
8
6 9 import optparse
7 10 import os, sys
8 11 import hghave
9 12
10 13 checks = hghave.checks
11 14
12 15 def list_features():
13 16 for name, feature in sorted(checks.iteritems()):
14 17 desc = feature[1]
15 print name + ':', desc
18 print(name + ':', desc)
16 19
17 20 def test_features():
18 21 failed = 0
19 22 for name, feature in checks.iteritems():
20 23 check, _ = feature
21 24 try:
22 25 check()
23 26 except Exception as e:
24 print "feature %s failed: %s" % (name, e)
27 print("feature %s failed: %s" % (name, e))
25 28 failed += 1
26 29 return failed
27 30
28 31 parser = optparse.OptionParser("%prog [options] [features]")
29 32 parser.add_option("--test-features", action="store_true",
30 33 help="test available features")
31 34 parser.add_option("--list-features", action="store_true",
32 35 help="list available features")
33 36
34 37 def _loadaddon():
35 38 if 'TESTDIR' in os.environ:
36 39 # loading from '.' isn't needed, because `hghave` should be
37 40 # running at TESTTMP in this case
38 41 path = os.environ['TESTDIR']
39 42 else:
40 43 path = '.'
41 44
42 45 if not os.path.exists(os.path.join(path, 'hghaveaddon.py')):
43 46 return
44 47
45 48 sys.path.insert(0, path)
46 49 try:
47 50 import hghaveaddon
48 51 except BaseException as inst:
49 52 sys.stderr.write('failed to import hghaveaddon.py from %r: %s\n'
50 53 % (path, inst))
51 54 sys.exit(2)
52 55 sys.path.pop(0)
53 56
54 57 if __name__ == '__main__':
55 58 options, args = parser.parse_args()
56 59 _loadaddon()
57 60 if options.list_features:
58 61 list_features()
59 62 sys.exit(0)
60 63
61 64 if options.test_features:
62 65 sys.exit(test_features())
63 66
64 67 hghave.require(args)
General Comments 0
You need to be logged in to leave comments. Login now