comparison tests/run-tests.py @ 7343:e47dab64be8d

run-tests: allow turning off diff display
author Matt Mackall <mpm@selenic.com>
date Fri, 07 Nov 2008 16:28:52 -0600
parents 0e8a9530d323
children 7900d240c3d8
comparison
equal deleted inserted replaced
7342:1dcd2cc6878b 7343:e47dab64be8d
61 " (default: $%s or %d)" % defaults['timeout']) 61 " (default: $%s or %d)" % defaults['timeout'])
62 parser.add_option("--tmpdir", type="string", 62 parser.add_option("--tmpdir", type="string",
63 help="run tests in the given temporary directory") 63 help="run tests in the given temporary directory")
64 parser.add_option("-v", "--verbose", action="store_true", 64 parser.add_option("-v", "--verbose", action="store_true",
65 help="output verbose messages") 65 help="output verbose messages")
66 parser.add_option("-n", "--nodiff", action="store_true",
67 help="skip showing test changes")
66 parser.add_option("--with-hg", type="string", 68 parser.add_option("--with-hg", type="string",
67 help="test existing install at given location") 69 help="test existing install at given location")
68 70
69 for option, default in defaults.items(): 71 for option, default in defaults.items():
70 defaults[option] = int(os.environ.get(*default)) 72 defaults[option] = int(os.environ.get(*default))
71 parser.set_defaults(**defaults) 73 parser.set_defaults(**defaults)
72 (options, args) = parser.parse_args() 74 (options, args) = parser.parse_args()
73 verbose = options.verbose 75 verbose = options.verbose
76 nodiff = options.nodiff
74 coverage = options.cover or options.cover_stdlib or options.annotate 77 coverage = options.cover or options.cover_stdlib or options.annotate
75 python = sys.executable 78 python = sys.executable
76 79
77 if options.jobs < 1: 80 if options.jobs < 1:
78 print >> sys.stderr, 'ERROR: -j/--jobs must be positive' 81 print >> sys.stderr, 'ERROR: -j/--jobs must be positive'
306 print "\nSkipping %s: %s" % (test, msg) 309 print "\nSkipping %s: %s" % (test, msg)
307 return None 310 return None
308 311
309 def fail(msg): 312 def fail(msg):
310 fails.append((test, msg)) 313 fails.append((test, msg))
311 print "\nERROR: %s %s" % (test, msg) 314 if not nodiff:
315 print "\nERROR: %s %s" % (test, msg)
312 return None 316 return None
313 317
314 vlog("# Test", test) 318 vlog("# Test", test)
315 319
316 # create a fresh hgrc 320 # create a fresh hgrc
372 vlog("# Ret was:", ret) 376 vlog("# Ret was:", ret)
373 377
374 if options.timeout > 0: 378 if options.timeout > 0:
375 signal.alarm(0) 379 signal.alarm(0)
376 380
381 mark = '.'
382
377 skipped = (ret == SKIPPED_STATUS) 383 skipped = (ret == SKIPPED_STATUS)
378 # If reference output file exists, check test output against it 384 # If reference output file exists, check test output against it
379 if os.path.exists(ref): 385 if os.path.exists(ref):
380 f = open(ref, "r") 386 f = open(ref, "r")
381 ref_out = splitnewlines(f.read()) 387 ref_out = splitnewlines(f.read())
382 f.close() 388 f.close()
383 else: 389 else:
384 ref_out = [] 390 ref_out = []
385 if skipped: 391 if skipped:
392 mark = 's'
386 missing = extract_missing_features(out) 393 missing = extract_missing_features(out)
387 if not missing: 394 if not missing:
388 missing = ['irrelevant'] 395 missing = ['irrelevant']
389 skip(missing[-1]) 396 skip(missing[-1])
390 elif out != ref_out: 397 elif out != ref_out:
398 mark = '!'
391 if ret: 399 if ret:
392 fail("output changed and returned error code %d" % ret) 400 fail("output changed and returned error code %d" % ret)
393 else: 401 else:
394 fail("output changed") 402 fail("output changed")
395 show_diff(ref_out, out) 403 if not nodiff:
404 show_diff(ref_out, out)
396 ret = 1 405 ret = 1
397 elif ret: 406 elif ret:
407 mark = '!'
398 fail("returned error code %d" % ret) 408 fail("returned error code %d" % ret)
399 409
400 if not verbose: 410 if not verbose:
401 sys.stdout.write(skipped and 's' or '.') 411 sys.stdout.write(mark)
402 sys.stdout.flush() 412 sys.stdout.flush()
403 413
404 if ret != 0 and not skipped: 414 if ret != 0 and not skipped:
405 # Save errors to a file for diagnosis 415 # Save errors to a file for diagnosis
406 f = open(err, "wb") 416 f = open(err, "wb")