comparison contrib/check-code.py @ 19422:d9e86d656017

check-code: automatically preppend "warning: " to all warning messages Some warnings had "warning: " at the beginning of their message. Now this is done consistent for all messages. Especially in test-check-code-hg.t it is an advantage to see warnings at once because only exceptions to them are tolerated. It is (almost) as obvious as before a6180647ea. The prefix will not remain when a warning is changed to a failure. A change like a91387a37f will not be necessary anymore.
author Simon Heimberg <simohe@besonet.ch>
date Tue, 16 Jul 2013 01:29:14 +0200
parents 5aeb03b48ab4
children 3119dc155ac2
comparison
equal deleted inserted replaced
19421:b2b08be5f556 19422:d9e86d656017
135 winglobmsg, '\$TESTTMP/unix-repo$'), 135 winglobmsg, '\$TESTTMP/unix-repo$'),
136 ], 136 ],
137 # warnings 137 # warnings
138 [ 138 [
139 (r'^ [^*?/\n]* \(glob\)$', 139 (r'^ [^*?/\n]* \(glob\)$',
140 "warning: glob match with no glob character (?*/)"), 140 "glob match with no glob character (?*/)"),
141 ] 141 ]
142 ] 142 ]
143 143
144 for i in [0, 1]: 144 for i in [0, 1]:
145 for p, m in testpats[i]: 145 for p, m in testpats[i]:
415 print "Skipping %s for %s it has no-" " check-code" % ( 415 print "Skipping %s for %s it has no-" " check-code" % (
416 name, f) 416 name, f)
417 break 417 break
418 for p, r in filters: 418 for p, r in filters:
419 post = re.sub(p, r, post) 419 post = re.sub(p, r, post)
420 nerrs = len(pats[0]) # nerr elements are errors
420 if warnings: 421 if warnings:
421 pats = pats[0] + pats[1] 422 pats = pats[0] + pats[1]
422 else: 423 else:
423 pats = pats[0] 424 pats = pats[0]
424 # print post # uncomment to show filtered version 425 # print post # uncomment to show filtered version
426 if debug: 427 if debug:
427 print "Checking %s for %s" % (name, f) 428 print "Checking %s for %s" % (name, f)
428 429
429 prelines = None 430 prelines = None
430 errors = [] 431 errors = []
431 for pat in pats: 432 for i, pat in enumerate(pats):
432 if len(pat) == 3: 433 if len(pat) == 3:
433 p, msg, ignore = pat 434 p, msg, ignore = pat
434 else: 435 else:
435 p, msg = pat 436 p, msg = pat
436 ignore = None 437 ignore = None
465 blamecache = getblame(f) 466 blamecache = getblame(f)
466 if n < len(blamecache): 467 if n < len(blamecache):
467 bl, bu, br = blamecache[n] 468 bl, bu, br = blamecache[n]
468 if bl == l: 469 if bl == l:
469 bd = '%s@%s' % (bu, br) 470 bd = '%s@%s' % (bu, br)
471 if i >= nerrs:
472 msg = "warning: " + msg
470 errors.append((f, lineno and n + 1, l, msg, bd)) 473 errors.append((f, lineno and n + 1, l, msg, bd))
471 result = False 474 result = False
472 475
473 errors.sort() 476 errors.sort()
474 for e in errors: 477 for e in errors: