##// END OF EJS Templates
run-tests: reduce global variables set by parse_args().
Greg Ward -
r8095:f5428d4f default
parent child Browse files
Show More
@@ -46,11 +46,7 b' defaults = {'
46 46 'port': ('HGTEST_PORT', 20059),
47 47 }
48 48
49 # globals set by parse_args() (ugh)
50 verbose = False
51 nodiff = False
52 coverage = False
53 python = None
49 python = sys.executable
54 50
55 51 def parse_args():
56 52 parser = optparse.OptionParser("%prog [options] [tests]")
@@ -98,11 +94,18 b' def parse_args():'
98 94 parser.set_defaults(**defaults)
99 95 (options, args) = parser.parse_args()
100 96
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
97 global vlog
98 options.anycoverage = (options.cover or
99 options.cover_stdlib or
100 options.annotate)
101
102 if options.verbose:
103 def vlog(*msg):
104 for m in msg:
105 print m,
106 print
107 else:
108 vlog = lambda *msg: None
106 109
107 110 if options.jobs < 1:
108 111 print >> sys.stderr, 'ERROR: -j/--jobs must be positive'
@@ -120,12 +123,6 b' def rename(src, dst):'
120 123 shutil.copy(src, dst)
121 124 os.remove(src)
122 125
123 def vlog(*msg):
124 if verbose:
125 for m in msg:
126 print m,
127 print
128
129 126 def splitnewlines(text):
130 127 '''like str.splitlines, but only split on newlines.
131 128 keep line endings.'''
@@ -185,7 +182,7 b' def check_required_tools():'
185 182
186 183 def cleanup_exit(options):
187 184 if not options.keep_tmpdir:
188 if verbose:
185 if options.verbose:
189 186 print "# Cleaning up HGTMP", HGTMP
190 187 shutil.rmtree(HGTMP, True)
191 188
@@ -220,7 +217,7 b' def install_hg(options):'
220 217 % (sys.executable, pure, INST, PYTHONDIR, BINDIR, installerrs))
221 218 vlog("# Running", cmd)
222 219 if os.system(cmd) == 0:
223 if not verbose:
220 if not options.verbose:
224 221 os.remove(installerrs)
225 222 else:
226 223 f = open(installerrs)
@@ -256,7 +253,7 b' def install_hg(options):'
256 253 f.close()
257 254 os.chmod(os.path.join(BINDIR, 'diffstat'), 0700)
258 255
259 if coverage:
256 if options.anycoverage:
260 257 vlog("# Installing coverage wrapper")
261 258 os.environ['COVERAGE_FILE'] = COVERAGE_FILE
262 259 if os.path.exists(COVERAGE_FILE):
@@ -346,7 +343,7 b' def run_one(options, test, skips, fails)'
346 343 False -> failed'''
347 344
348 345 def skip(msg):
349 if not verbose:
346 if not options.verbose:
350 347 skips.append((test, msg))
351 348 else:
352 349 print "\nSkipping %s: %s" % (test, msg)
@@ -354,7 +351,7 b' def run_one(options, test, skips, fails)'
354 351
355 352 def fail(msg):
356 353 fails.append((test, msg))
357 if not nodiff:
354 if not options.nodiff:
358 355 print "\nERROR: %s %s" % (test, msg)
359 356 return None
360 357
@@ -447,14 +444,14 b' def run_one(options, test, skips, fails)'
447 444 fail("output changed and returned error code %d" % ret)
448 445 else:
449 446 fail("output changed")
450 if not nodiff:
447 if not options.nodiff:
451 448 show_diff(ref_out, out)
452 449 ret = 1
453 450 elif ret:
454 451 mark = '!'
455 452 fail("returned error code %d" % ret)
456 453
457 if not verbose:
454 if not options.verbose:
458 455 sys.stdout.write(mark)
459 456 sys.stdout.flush()
460 457
@@ -638,7 +635,7 b' def run_tests(options, expecthg, tests):'
638 635 print "# Ran %d tests, %d skipped, %d failed." % (
639 636 tested, skipped, failed)
640 637
641 if coverage:
638 if options.anycoverage:
642 639 output_coverage(options)
643 640 except KeyboardInterrupt:
644 641 failed = True
General Comments 0
You need to be logged in to leave comments. Login now