comparison tests/run-tests.py @ 8060:84d0fe34427b

run-tests: detect when hghave fails to check for a feature and fail test hghave exitcode != 0 might mean that hghave failed to check for feature avaibility. Detect those cases, and fail the test, instead of skipping it.
author Nicolas Dumazet <nicdumz.commits@gmail.com>
date Wed, 08 Apr 2009 02:38:23 +0900
parents 076401cf2b63
children e85cc856d2e1
comparison
equal deleted inserted replaced
8059:41a2c5cbcb6a 8060:84d0fe34427b
34 import time 34 import time
35 35
36 # reserved exit code to skip test (used by hghave) 36 # reserved exit code to skip test (used by hghave)
37 SKIPPED_STATUS = 80 37 SKIPPED_STATUS = 80
38 SKIPPED_PREFIX = 'skipped: ' 38 SKIPPED_PREFIX = 'skipped: '
39 FAILED_PREFIX = 'hghave check failed: '
39 40
40 required_tools = ["python", "diff", "grep", "unzip", "gunzip", "bunzip2", "sed"] 41 required_tools = ["python", "diff", "grep", "unzip", "gunzip", "bunzip2", "sed"]
41 42
42 defaults = { 43 defaults = {
43 'jobs': ('HGTEST_JOBS', 1), 44 'jobs': ('HGTEST_JOBS', 1),
127 lines.append(last) 128 lines.append(last)
128 return lines 129 return lines
129 lines.append(text[i:n+1]) 130 lines.append(text[i:n+1])
130 i = n + 1 131 i = n + 1
131 132
132 def extract_missing_features(lines): 133 def parse_hghave_output(lines):
133 '''Extract missing/unknown features log lines as a list''' 134 '''Parse hghave log lines.
135 Return tuple of lists (missing, failed):
136 * the missing/unknown features
137 * the features for which existence check failed'''
134 missing = [] 138 missing = []
139 failed = []
135 for line in lines: 140 for line in lines:
136 if not line.startswith(SKIPPED_PREFIX): 141 if line.startswith(SKIPPED_PREFIX):
137 continue 142 line = line.splitlines()[0]
138 line = line.splitlines()[0] 143 missing.append(line[len(SKIPPED_PREFIX):])
139 missing.append(line[len(SKIPPED_PREFIX):]) 144 elif line.startswith(FAILED_PREFIX):
140 145 line = line.splitlines()[0]
141 return missing 146 failed.append(line[len(FAILED_PREFIX):])
147
148 return missing, failed
142 149
143 def show_diff(expected, output): 150 def show_diff(expected, output):
144 for line in difflib.unified_diff(expected, output, 151 for line in difflib.unified_diff(expected, output,
145 "Expected output", "Test output"): 152 "Expected output", "Test output"):
146 sys.stdout.write(line) 153 sys.stdout.write(line)
406 f.close() 413 f.close()
407 else: 414 else:
408 ref_out = [] 415 ref_out = []
409 if skipped: 416 if skipped:
410 mark = 's' 417 mark = 's'
411 missing = extract_missing_features(out) 418 missing, failed = parse_hghave_output(out)
412 if not missing: 419 if not missing:
413 missing = ['irrelevant'] 420 missing = ['irrelevant']
414 skip(missing[-1]) 421 if failed:
422 fail("hghave failed checking for %s" % failed[-1])
423 skipped = False
424 else:
425 skip(missing[-1])
415 elif out != ref_out: 426 elif out != ref_out:
416 mark = '!' 427 mark = '!'
417 if ret: 428 if ret:
418 fail("output changed and returned error code %d" % ret) 429 fail("output changed and returned error code %d" % ret)
419 else: 430 else: