Mercurial > hg > mercurial-crew-with-dirclash
comparison tests/run-tests.py @ 3044:fcadf7a32425
Merge with mpm
author | Josef "Jeff" Sipek <jeffpc@josefsipek.net> |
---|---|
date | Sun, 03 Sep 2006 06:06:02 -0400 |
parents | e475fe2a6029 |
children | 3091b1153e2c |
comparison
equal
deleted
inserted
replaced
3043:2a4d4aecb2b4 | 3044:fcadf7a32425 |
---|---|
199 if ret == 0: | 199 if ret == 0: |
200 ret = signal.SIGTERM << 8 | 200 ret = signal.SIGTERM << 8 |
201 return ret, splitnewlines(output) | 201 return ret, splitnewlines(output) |
202 | 202 |
203 def run_one(test): | 203 def run_one(test): |
204 '''tristate output: | |
205 None -> skipped | |
206 True -> passed | |
207 False -> failed''' | |
208 | |
204 vlog("# Test", test) | 209 vlog("# Test", test) |
205 if not verbose: | 210 if not verbose: |
206 sys.stdout.write('.') | 211 sys.stdout.write('.') |
207 sys.stdout.flush() | 212 sys.stdout.flush() |
208 | 213 |
215 # Make a tmp subdirectory to work in | 220 # Make a tmp subdirectory to work in |
216 tmpd = os.path.join(HGTMP, test) | 221 tmpd = os.path.join(HGTMP, test) |
217 os.mkdir(tmpd) | 222 os.mkdir(tmpd) |
218 os.chdir(tmpd) | 223 os.chdir(tmpd) |
219 | 224 |
220 if test.endswith(".py"): | 225 lctest = test.lower() |
226 | |
227 if lctest.endswith('.py'): | |
221 cmd = '%s "%s"' % (sys.executable, os.path.join(TESTDIR, test)) | 228 cmd = '%s "%s"' % (sys.executable, os.path.join(TESTDIR, test)) |
229 elif lctest.endswith('.bat'): | |
230 # do not run batch scripts on non-windows | |
231 if os.name != 'nt': | |
232 print '\nSkipping %s: batch script' % test | |
233 return None | |
234 # To reliably get the error code from batch files on WinXP, | |
235 # the "cmd /c call" prefix is needed. Grrr | |
236 cmd = 'cmd /c call "%s"' % (os.path.join(TESTDIR, test)) | |
222 else: | 237 else: |
238 # do not run shell scripts on windows | |
239 if os.name == 'nt': | |
240 print '\nSkipping %s: shell script' % test | |
241 return None | |
242 # do not try to run non-executable programs | |
243 if not os.access(os.path.join(TESTDIR, test), os.X_OK): | |
244 print '\nSkipping %s: not executable' % test | |
245 return None | |
223 cmd = '"%s"' % (os.path.join(TESTDIR, test)) | 246 cmd = '"%s"' % (os.path.join(TESTDIR, test)) |
224 | |
225 # To reliably get the error code from batch files on WinXP, | |
226 # the "cmd /c call" prefix is needed. Grrr | |
227 if os.name == 'nt' and test.endswith(".bat"): | |
228 cmd = 'cmd /c call "%s"' % (os.path.join(TESTDIR, test)) | |
229 | 247 |
230 if options.timeout > 0: | 248 if options.timeout > 0: |
231 signal.alarm(options.timeout) | 249 signal.alarm(options.timeout) |
232 | 250 |
233 vlog("# Running", cmd) | 251 vlog("# Running", cmd) |
242 if os.path.exists(ref): | 260 if os.path.exists(ref): |
243 f = open(ref, "r") | 261 f = open(ref, "r") |
244 ref_out = splitnewlines(f.read()) | 262 ref_out = splitnewlines(f.read()) |
245 f.close() | 263 f.close() |
246 else: | 264 else: |
247 ref_out = [''] | 265 ref_out = [] |
248 if out != ref_out: | 266 if out != ref_out: |
249 diffret = 1 | 267 diffret = 1 |
250 print "\nERROR: %s output changed" % (test) | 268 print "\nERROR: %s output changed" % (test) |
251 show_diff(ref_out, out) | 269 show_diff(ref_out, out) |
252 if ret: | 270 if ret: |
328 print 'WARNING: cannot run tests with timeouts' | 346 print 'WARNING: cannot run tests with timeouts' |
329 options.timeout = 0 | 347 options.timeout = 0 |
330 | 348 |
331 tests = 0 | 349 tests = 0 |
332 failed = 0 | 350 failed = 0 |
351 skipped = 0 | |
333 | 352 |
334 if len(args) == 0: | 353 if len(args) == 0: |
335 args = os.listdir(".") | 354 args = os.listdir(".") |
336 for test in args: | 355 for test in args: |
337 if test.startswith("test-") and not '~' in test and not '.' in test: | 356 if (test.startswith("test-") and '~' not in test and |
338 if not run_one(test): | 357 ('.' not in test or test.endswith('.py') or |
358 test.endswith('.bat'))): | |
359 ret = run_one(test) | |
360 if ret is None: | |
361 skipped += 1 | |
362 elif not ret: | |
339 failed += 1 | 363 failed += 1 |
340 tests += 1 | 364 tests += 1 |
341 | 365 |
342 print "\n# Ran %d tests, %d failed." % (tests, failed) | 366 print "\n# Ran %d tests, %d skipped, %d failed." % (tests, skipped, |
367 failed) | |
343 if coverage: | 368 if coverage: |
344 output_coverage() | 369 output_coverage() |
345 except KeyboardInterrupt: | 370 except KeyboardInterrupt: |
346 failed = True | 371 failed = True |
347 print "\ninterrupted!" | 372 print "\ninterrupted!" |