Show More
@@ -46,61 +46,72 b' defaults = {' | |||
|
46 | 46 | 'port': ('HGTEST_PORT', 20059), |
|
47 | 47 | } |
|
48 | 48 | |
|
49 | parser = optparse.OptionParser("%prog [options] [tests]") | |
|
50 | parser.add_option("-C", "--annotate", action="store_true", | |
|
51 | help="output files annotated with coverage") | |
|
52 | parser.add_option("--child", type="int", | |
|
53 | help="run as child process, summary to given fd") | |
|
54 | parser.add_option("-c", "--cover", action="store_true", | |
|
55 | help="print a test coverage report") | |
|
56 | parser.add_option("-f", "--first", action="store_true", | |
|
57 | help="exit on the first test failure") | |
|
58 | parser.add_option("-i", "--interactive", action="store_true", | |
|
59 | help="prompt to accept changed output") | |
|
60 | parser.add_option("-j", "--jobs", type="int", | |
|
61 | help="number of jobs to run in parallel" | |
|
62 | " (default: $%s or %d)" % defaults['jobs']) | |
|
63 | parser.add_option("--keep-tmpdir", action="store_true", | |
|
64 | help="keep temporary directory after running tests" | |
|
65 | " (best used with --tmpdir)") | |
|
66 | parser.add_option("-R", "--restart", action="store_true", | |
|
67 | help="restart at last error") | |
|
68 | parser.add_option("-p", "--port", type="int", | |
|
69 | help="port on which servers should listen" | |
|
70 | " (default: $%s or %d)" % defaults['port']) | |
|
71 | parser.add_option("-r", "--retest", action="store_true", | |
|
72 | help="retest failed tests") | |
|
73 | parser.add_option("-s", "--cover_stdlib", action="store_true", | |
|
74 | help="print a test coverage report inc. standard libraries") | |
|
75 | parser.add_option("-t", "--timeout", type="int", | |
|
76 | help="kill errant tests after TIMEOUT seconds" | |
|
77 | " (default: $%s or %d)" % defaults['timeout']) | |
|
78 | parser.add_option("--tmpdir", type="string", | |
|
79 | help="run tests in the given temporary directory") | |
|
80 | parser.add_option("-v", "--verbose", action="store_true", | |
|
81 | help="output verbose messages") | |
|
82 | parser.add_option("-n", "--nodiff", action="store_true", | |
|
83 | help="skip showing test changes") | |
|
84 | parser.add_option("--with-hg", type="string", | |
|
85 | help="test existing install at given location") | |
|
86 | parser.add_option("--pure", action="store_true", | |
|
87 | help="use pure Python code instead of C extensions") | |
|
49 | # globals set by parse_args() (ugh) | |
|
50 | verbose = False | |
|
51 | nodiff = False | |
|
52 | coverage = False | |
|
53 | python = None | |
|
88 | 54 | |
|
89 | for option, default in defaults.items(): | |
|
90 | defaults[option] = int(os.environ.get(*default)) | |
|
91 | parser.set_defaults(**defaults) | |
|
92 | (options, args) = parser.parse_args() | |
|
93 | verbose = options.verbose | |
|
94 | nodiff = options.nodiff | |
|
95 | coverage = options.cover or options.cover_stdlib or options.annotate | |
|
96 | python = sys.executable | |
|
55 | def parse_args(): | |
|
56 | parser = optparse.OptionParser("%prog [options] [tests]") | |
|
57 | parser.add_option("-C", "--annotate", action="store_true", | |
|
58 | help="output files annotated with coverage") | |
|
59 | parser.add_option("--child", type="int", | |
|
60 | help="run as child process, summary to given fd") | |
|
61 | parser.add_option("-c", "--cover", action="store_true", | |
|
62 | help="print a test coverage report") | |
|
63 | parser.add_option("-f", "--first", action="store_true", | |
|
64 | help="exit on the first test failure") | |
|
65 | parser.add_option("-i", "--interactive", action="store_true", | |
|
66 | help="prompt to accept changed output") | |
|
67 | parser.add_option("-j", "--jobs", type="int", | |
|
68 | help="number of jobs to run in parallel" | |
|
69 | " (default: $%s or %d)" % defaults['jobs']) | |
|
70 | parser.add_option("--keep-tmpdir", action="store_true", | |
|
71 | help="keep temporary directory after running tests" | |
|
72 | " (best used with --tmpdir)") | |
|
73 | parser.add_option("-R", "--restart", action="store_true", | |
|
74 | help="restart at last error") | |
|
75 | parser.add_option("-p", "--port", type="int", | |
|
76 | help="port on which servers should listen" | |
|
77 | " (default: $%s or %d)" % defaults['port']) | |
|
78 | parser.add_option("-r", "--retest", action="store_true", | |
|
79 | help="retest failed tests") | |
|
80 | parser.add_option("-s", "--cover_stdlib", action="store_true", | |
|
81 | help="print a test coverage report inc. standard libraries") | |
|
82 | parser.add_option("-t", "--timeout", type="int", | |
|
83 | help="kill errant tests after TIMEOUT seconds" | |
|
84 | " (default: $%s or %d)" % defaults['timeout']) | |
|
85 | parser.add_option("--tmpdir", type="string", | |
|
86 | help="run tests in the given temporary directory") | |
|
87 | parser.add_option("-v", "--verbose", action="store_true", | |
|
88 | help="output verbose messages") | |
|
89 | parser.add_option("-n", "--nodiff", action="store_true", | |
|
90 | help="skip showing test changes") | |
|
91 | parser.add_option("--with-hg", type="string", | |
|
92 | help="test existing install at given location") | |
|
93 | parser.add_option("--pure", action="store_true", | |
|
94 | help="use pure Python code instead of C extensions") | |
|
97 | 95 | |
|
98 | if options.jobs < 1: | |
|
99 | print >> sys.stderr, 'ERROR: -j/--jobs must be positive' | |
|
100 | sys.exit(1) | |
|
101 | if options.interactive and options.jobs > 1: | |
|
102 | print '(--interactive overrides --jobs)' | |
|
103 | options.jobs = 1 | |
|
96 | for option, default in defaults.items(): | |
|
97 | defaults[option] = int(os.environ.get(*default)) | |
|
98 | parser.set_defaults(**defaults) | |
|
99 | (options, args) = parser.parse_args() | |
|
100 | ||
|
101 | global verbose, nodiff, coverage, python | |
|
102 | verbose = options.verbose | |
|
103 | nodiff = options.nodiff | |
|
104 | coverage = options.cover or options.cover_stdlib or options.annotate | |
|
105 | python = sys.executable | |
|
106 | ||
|
107 | if options.jobs < 1: | |
|
108 | print >> sys.stderr, 'ERROR: -j/--jobs must be positive' | |
|
109 | sys.exit(1) | |
|
110 | if options.interactive and options.jobs > 1: | |
|
111 | print '(--interactive overrides --jobs)' | |
|
112 | options.jobs = 1 | |
|
113 | ||
|
114 | return (options, args) | |
|
104 | 115 | |
|
105 | 116 | def rename(src, dst): |
|
106 | 117 | """Like os.rename(), trade atomicity and opened files friendliness |
@@ -478,6 +489,7 b' def run_one(test, skips, fails):' | |||
|
478 | 489 | return None |
|
479 | 490 | return ret == 0 |
|
480 | 491 | |
|
492 | (options, args) = parse_args() | |
|
481 | 493 | if not options.child: |
|
482 | 494 | os.umask(022) |
|
483 | 495 |
General Comments 0
You need to be logged in to leave comments.
Login now