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