Show More
@@ -39,7 +39,7 b" SKIPPED_PREFIX = 'skipped: '" | |||
|
39 | 39 | FAILED_PREFIX = 'hghave check failed: ' |
|
40 | 40 | PYTHON = sys.executable |
|
41 | 41 | |
|
42 |
required |
|
|
42 | requiredtools = ["python", "diff", "grep", "unzip", "gunzip", "bunzip2", "sed"] | |
|
43 | 43 | |
|
44 | 44 | defaults = { |
|
45 | 45 | 'jobs': ('HGTEST_JOBS', 1), |
@@ -47,7 +47,7 b' defaults = {' | |||
|
47 | 47 | 'port': ('HGTEST_PORT', 20059), |
|
48 | 48 | } |
|
49 | 49 | |
|
50 |
def parse |
|
|
50 | def parseargs(): | |
|
51 | 51 | parser = optparse.OptionParser("%prog [options] [tests]") |
|
52 | 52 | parser.add_option("-C", "--annotate", action="store_true", |
|
53 | 53 | help="output files annotated with coverage") |
@@ -137,7 +137,7 b' def splitnewlines(text):' | |||
|
137 | 137 | lines.append(text[i:n+1]) |
|
138 | 138 | i = n + 1 |
|
139 | 139 | |
|
140 |
def parse |
|
|
140 | def parsehghaveoutput(lines): | |
|
141 | 141 | '''Parse hghave log lines. |
|
142 | 142 | Return tuple of lists (missing, failed): |
|
143 | 143 | * the missing/unknown features |
@@ -154,12 +154,12 b' def parse_hghave_output(lines):' | |||
|
154 | 154 | |
|
155 | 155 | return missing, failed |
|
156 | 156 | |
|
157 |
def show |
|
|
157 | def showdiff(expected, output): | |
|
158 | 158 | for line in difflib.unified_diff(expected, output, |
|
159 | 159 | "Expected output", "Test output"): |
|
160 | 160 | sys.stdout.write(line) |
|
161 | 161 | |
|
162 |
def find |
|
|
162 | def findprogram(program): | |
|
163 | 163 | """Search PATH for a executable program""" |
|
164 | 164 | for p in os.environ.get('PATH', os.defpath).split(os.pathsep): |
|
165 | 165 | name = os.path.join(p, program) |
@@ -167,42 +167,42 b' def find_program(program):' | |||
|
167 | 167 | return name |
|
168 | 168 | return None |
|
169 | 169 | |
|
170 |
def check |
|
|
170 | def checktools(): | |
|
171 | 171 | # Before we go any further, check for pre-requisite tools |
|
172 | 172 | # stuff from coreutils (cat, rm, etc) are not tested |
|
173 |
for p in required |
|
|
173 | for p in requiredtools: | |
|
174 | 174 | if os.name == 'nt': |
|
175 | 175 | p += '.exe' |
|
176 |
found = find |
|
|
176 | found = findprogram(p) | |
|
177 | 177 | if found: |
|
178 | 178 | vlog("# Found prerequisite", p, "at", found) |
|
179 | 179 | else: |
|
180 | 180 | print "WARNING: Did not find prerequisite tool: "+p |
|
181 | 181 | |
|
182 |
def cleanup |
|
|
182 | def cleanup(options): | |
|
183 | 183 | if not options.keep_tmpdir: |
|
184 | 184 | if options.verbose: |
|
185 | 185 | print "# Cleaning up HGTMP", HGTMP |
|
186 | 186 | shutil.rmtree(HGTMP, True) |
|
187 | 187 | |
|
188 |
def use |
|
|
188 | def usecorrectpython(): | |
|
189 | 189 | # some tests run python interpreter. they must use same |
|
190 | 190 | # interpreter we use or bad things will happen. |
|
191 | 191 | exedir, exename = os.path.split(sys.executable) |
|
192 | 192 | if exename == 'python': |
|
193 |
path = find |
|
|
193 | path = findprogram('python') | |
|
194 | 194 | if os.path.dirname(path) == exedir: |
|
195 | 195 | return |
|
196 | 196 | vlog('# Making python executable in test path use correct Python') |
|
197 |
my |
|
|
197 | mypython = os.path.join(BINDIR, 'python') | |
|
198 | 198 | try: |
|
199 |
os.symlink(sys.executable, my |
|
|
199 | os.symlink(sys.executable, mypython) | |
|
200 | 200 | except AttributeError: |
|
201 | 201 | # windows fallback |
|
202 |
shutil.copyfile(sys.executable, my |
|
|
203 |
shutil.copymode(sys.executable, my |
|
|
202 | shutil.copyfile(sys.executable, mypython) | |
|
203 | shutil.copymode(sys.executable, mypython) | |
|
204 | 204 | |
|
205 |
def install |
|
|
205 | def installhg(options): | |
|
206 | 206 | global PYTHON |
|
207 | 207 | vlog("# Performing temporary installation of HG") |
|
208 | 208 | installerrs = os.path.join("tests", "install.err") |
@@ -236,7 +236,7 b' def install_hg(options):' | |||
|
236 | 236 | pythonpath = pydir |
|
237 | 237 | os.environ["PYTHONPATH"] = pythonpath |
|
238 | 238 | |
|
239 |
use |
|
|
239 | usecorrectpython() | |
|
240 | 240 | global hgpkg |
|
241 | 241 | hgpkg = _hgpath() |
|
242 | 242 | |
@@ -277,7 +277,7 b' def _hgpath():' | |||
|
277 | 277 | hgpath.close() |
|
278 | 278 | return path |
|
279 | 279 | |
|
280 |
def output |
|
|
280 | def outputcoverage(options): | |
|
281 | 281 | vlog("# Producing coverage report") |
|
282 | 282 | omit = [BINDIR, TESTDIR, PYTHONDIR] |
|
283 | 283 | if not options.cover_stdlib: |
@@ -335,7 +335,7 b' def run(cmd):' | |||
|
335 | 335 | % options.timeout) |
|
336 | 336 | return ret, splitnewlines(output) |
|
337 | 337 | |
|
338 |
def run |
|
|
338 | def runone(options, test, skips, fails): | |
|
339 | 339 | '''tristate output: |
|
340 | 340 | None -> skipped |
|
341 | 341 | True -> passed |
@@ -423,13 +423,13 b' def run_one(options, test, skips, fails)' | |||
|
423 | 423 | # If reference output file exists, check test output against it |
|
424 | 424 | if os.path.exists(ref): |
|
425 | 425 | f = open(ref, "r") |
|
426 |
ref |
|
|
426 | refout = splitnewlines(f.read()) | |
|
427 | 427 | f.close() |
|
428 | 428 | else: |
|
429 |
ref |
|
|
429 | refout = [] | |
|
430 | 430 | if skipped: |
|
431 | 431 | mark = 's' |
|
432 |
missing, failed = parse |
|
|
432 | missing, failed = parsehghaveoutput(out) | |
|
433 | 433 | if not missing: |
|
434 | 434 | missing = ['irrelevant'] |
|
435 | 435 | if failed: |
@@ -437,14 +437,14 b' def run_one(options, test, skips, fails)' | |||
|
437 | 437 | skipped = False |
|
438 | 438 | else: |
|
439 | 439 | skip(missing[-1]) |
|
440 |
elif out != ref |
|
|
440 | elif out != refout: | |
|
441 | 441 | mark = '!' |
|
442 | 442 | if ret: |
|
443 | 443 | fail("output changed and returned error code %d" % ret) |
|
444 | 444 | else: |
|
445 | 445 | fail("output changed") |
|
446 | 446 | if not options.nodiff: |
|
447 |
show |
|
|
447 | showdiff(refout, out) | |
|
448 | 448 | ret = 1 |
|
449 | 449 | elif ret: |
|
450 | 450 | mark = '!' |
@@ -492,9 +492,9 b' def run_one(options, test, skips, fails)' | |||
|
492 | 492 | return None |
|
493 | 493 | return ret == 0 |
|
494 | 494 | |
|
495 |
def run |
|
|
495 | def runchildren(options, expecthg, tests): | |
|
496 | 496 | if not options.with_hg: |
|
497 |
install |
|
|
497 | installhg() | |
|
498 | 498 | if hgpkg != expecthg: |
|
499 | 499 | print '# Testing unexpected mercurial: %s' % hgpkg |
|
500 | 500 | |
@@ -557,14 +557,14 b' def run_children(options, expecthg, test' | |||
|
557 | 557 | tested, skipped, failed) |
|
558 | 558 | sys.exit(failures != 0) |
|
559 | 559 | |
|
560 |
def run |
|
|
560 | def runtests(options, expecthg, tests): | |
|
561 | 561 | global DAEMON_PIDS, HGRCPATH |
|
562 | 562 | DAEMON_PIDS = os.environ["DAEMON_PIDS"] = os.path.join(HGTMP, 'daemon.pids') |
|
563 | 563 | HGRCPATH = os.environ["HGRCPATH"] = os.path.join(HGTMP, '.hgrc') |
|
564 | 564 | |
|
565 | 565 | try: |
|
566 | 566 | if not options.with_hg: |
|
567 |
install |
|
|
567 | installhg(options) | |
|
568 | 568 | |
|
569 | 569 | if hgpkg != expecthg: |
|
570 | 570 | print '# Testing unexpected mercurial: %s' % hgpkg |
@@ -598,7 +598,7 b' def run_tests(options, expecthg, tests):' | |||
|
598 | 598 | if options.retest and not os.path.exists(test + ".err"): |
|
599 | 599 | skipped += 1 |
|
600 | 600 | continue |
|
601 |
ret = run |
|
|
601 | ret = runone(options, test, skips, fails) | |
|
602 | 602 | if ret is None: |
|
603 | 603 | skipped += 1 |
|
604 | 604 | elif not ret: |
@@ -635,7 +635,7 b' def run_tests(options, expecthg, tests):' | |||
|
635 | 635 | tested, skipped, failed) |
|
636 | 636 | |
|
637 | 637 | if options.anycoverage: |
|
638 |
output |
|
|
638 | outputcoverage(options) | |
|
639 | 639 | except KeyboardInterrupt: |
|
640 | 640 | failed = True |
|
641 | 641 | print "\ninterrupted!" |
@@ -644,11 +644,11 b' def run_tests(options, expecthg, tests):' | |||
|
644 | 644 | sys.exit(1) |
|
645 | 645 | |
|
646 | 646 | def main(): |
|
647 |
(options, args) = parse |
|
|
647 | (options, args) = parseargs() | |
|
648 | 648 | if not options.child: |
|
649 | 649 | os.umask(022) |
|
650 | 650 | |
|
651 |
check |
|
|
651 | checktools() | |
|
652 | 652 | |
|
653 | 653 | # Reset some environment variables to well-known values so that |
|
654 | 654 | # the tests produce repeatable output. |
@@ -700,10 +700,10 b' def main():' | |||
|
700 | 700 | |
|
701 | 701 | try: |
|
702 | 702 | if len(tests) > 1 and options.jobs > 1: |
|
703 |
run |
|
|
703 | runchildren(options, expecthg, tests) | |
|
704 | 704 | else: |
|
705 |
run |
|
|
705 | runtests(options, expecthg, tests) | |
|
706 | 706 | finally: |
|
707 |
cleanup |
|
|
707 | cleanup(options) | |
|
708 | 708 | |
|
709 | 709 | main() |
General Comments 0
You need to be logged in to leave comments.
Login now