|
18 | 18 |
|
19 | 19 |
|
20 | 20 | import difflib |
21 | | -import optparse |
| 21 | +import argparse |
22 | 22 | import os.path |
23 | 23 | import sys |
24 | 24 | import subprocess |
@@ -112,39 +112,41 @@ def main(): |
112 | 112 |
|
113 | 113 | test_dir = os.path.dirname(os.path.abspath(__file__)) |
114 | 114 |
|
115 | | - optparser = optparse.OptionParser( |
116 | | - usage="\n\t%prog [options] [format] ...") |
117 | | - optparser.add_option( |
| 115 | + argparser = argparse.ArgumentParser( |
| 116 | + usage="\n\t%(prog)s [options] [format] ...") |
| 117 | + argparser.add_argument( |
118 | 118 | '-p', '--python', metavar='PATH', |
119 | | - type="string", dest="python", default=sys.executable, |
| 119 | + dest="python", default=sys.executable, |
120 | 120 | help="path to python executable [default: %default]") |
121 | | - optparser.add_option( |
| 121 | + argparser.add_argument( |
122 | 122 | '-g', '--gprof2dot', metavar='PATH', |
123 | | - type="string", dest="gprof2dot", default=os.path.abspath(os.path.join(test_dir, os.path.pardir, 'gprof2dot.py')), |
| 123 | + dest="gprof2dot", default=os.path.abspath(os.path.join(test_dir, os.path.pardir, 'gprof2dot.py')), |
124 | 124 | help="path to gprof2dot.py script [default: %default]") |
125 | | - optparser.add_option( |
| 125 | + argparser.add_argument( |
126 | 126 | '-f', '--force', |
127 | 127 | action="store_true", |
128 | 128 | dest="force", default=False, |
129 | 129 | help="force reference generation") |
130 | | - optparser.add_option( |
| 130 | + argparser.add_argument( |
131 | 131 | '-c', '--coverage', |
132 | 132 | action="store_true", |
133 | 133 | dest="coverage", default=False, |
134 | 134 | help="code coverage") |
135 | 135 |
|
136 | 136 | # Added this to avoid failing the test when a (hopefully small) number of formats |
137 | 137 | # result in error. This allows some flexibility in CI testing. |
138 | | - optparser.add_option( |
| 138 | + argparser.add_argument( |
139 | 139 | '--max-acceptable', |
140 | 140 | type=int, |
141 | 141 | dest="max_acceptable", |
142 | 142 | help="max acceptable errors before we return an errcode and fail the test") |
143 | 143 |
|
144 | | - (options, args) = optparser.parse_args(sys.argv[1:]) |
| 144 | + options = argparser.add_argument('formats', nargs='*') |
145 | 145 |
|
146 | | - if len(args): |
147 | | - formats = args |
| 146 | + options = argparser.parse_args(sys.argv[1:]) |
| 147 | + |
| 148 | + if len(options.formats): |
| 149 | + formats = options.formats |
148 | 150 |
|
149 | 151 | for format in formats: |
150 | 152 | test_subdir = os.path.join(test_dir, format) |
|
0 commit comments