Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(321)

Side by Side Diff: tools/presubmit.py

Issue 2653753007: [tests] Cleanup tests that use assertOptimized()/assertUnoptimized(). (Closed)
Patch Set: Addressing comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/mjsunit/unary-minus-deopt.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2012 the V8 project authors. All rights reserved. 3 # Copyright 2012 the V8 project authors. All rights reserved.
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 -build/include_what_you_use 62 -build/include_what_you_use
63 -build/namespaces 63 -build/namespaces
64 -readability/check 64 -readability/check
65 -readability/fn_size 65 -readability/fn_size
66 +readability/streams 66 +readability/streams
67 -runtime/references 67 -runtime/references
68 """.split() 68 """.split()
69 69
70 LINT_OUTPUT_PATTERN = re.compile(r'^.+[:(]\d+[:)]|^Done processing') 70 LINT_OUTPUT_PATTERN = re.compile(r'^.+[:(]\d+[:)]|^Done processing')
71 FLAGS_LINE = re.compile("//\s*Flags:.*--([A-z0-9-])+_[A-z0-9].*\n") 71 FLAGS_LINE = re.compile("//\s*Flags:.*--([A-z0-9-])+_[A-z0-9].*\n")
72 ASSERT_OPTIMIZED_PATTERN = re.compile("assertOptimized")
73 FLAGS_ENABLE_OPT = re.compile("//\s*Flags:.*--(crankshaft|turbo)[^-].*\n")
74 ASSERT_UNOPTIMIZED_PATTERN = re.compile("assertUnoptimized")
75 FLAGS_NO_ALWAYS_OPT = re.compile("//\s*Flags:.*--no-?always-opt.*\n")
72 76
73 TOOLS_PATH = dirname(abspath(__file__)) 77 TOOLS_PATH = dirname(abspath(__file__))
74 78
75 def CppLintWorker(command): 79 def CppLintWorker(command):
76 try: 80 try:
77 process = subprocess.Popen(command, stderr=subprocess.PIPE) 81 process = subprocess.Popen(command, stderr=subprocess.PIPE)
78 process.wait() 82 process.wait()
79 out_lines = "" 83 out_lines = ""
80 error_count = -1 84 error_count = -1
81 while True: 85 while True:
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 linenumbers = ', '.join(lines) 398 linenumbers = ', '.join(lines)
395 if len(lines) > 1: 399 if len(lines) > 1:
396 print "%s has trailing whitespaces in lines %s." % (name, linenumbers) 400 print "%s has trailing whitespaces in lines %s." % (name, linenumbers)
397 else: 401 else:
398 print "%s has trailing whitespaces in line %s." % (name, linenumbers) 402 print "%s has trailing whitespaces in line %s." % (name, linenumbers)
399 result = False 403 result = False
400 if not contents.endswith('\n') or contents.endswith('\n\n'): 404 if not contents.endswith('\n') or contents.endswith('\n\n'):
401 print "%s does not end with a single new line." % name 405 print "%s does not end with a single new line." % name
402 result = False 406 result = False
403 # Sanitize flags for fuzzer. 407 # Sanitize flags for fuzzer.
404 if "mjsunit" in name: 408 if "mjsunit" in name or "debugger" in name:
405 match = FLAGS_LINE.search(contents) 409 match = FLAGS_LINE.search(contents)
406 if match: 410 if match:
407 print "%s Flags should use '-' (not '_')" % name 411 print "%s Flags should use '-' (not '_')" % name
408 result = False 412 result = False
413 if not "mjsunit/mjsunit.js" in name:
414 if ASSERT_OPTIMIZED_PATTERN.search(contents) and \
415 not FLAGS_ENABLE_OPT.search(contents):
416 print "%s Flag --crankshaft or --turbo should be set " \
417 "if assertOptimized() is used" % name
418 result = False
419 if ASSERT_UNOPTIMIZED_PATTERN.search(contents) and \
420 not FLAGS_NO_ALWAYS_OPT.search(contents):
421 print "%s Flag --no-always-opt should be set if " \
422 "assertUnoptimized() is used" % name
423 result = False
409 return result 424 return result
410 425
411 def ProcessFiles(self, files): 426 def ProcessFiles(self, files):
412 success = True 427 success = True
413 violations = 0 428 violations = 0
414 for file in files: 429 for file in files:
415 try: 430 try:
416 handle = open(file) 431 handle = open(file)
417 contents = handle.read() 432 contents = handle.read()
418 if not self.ProcessContents(file, contents): 433 if not self.ProcessContents(file, contents):
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 print "Running status-files check..." 519 print "Running status-files check..."
505 success &= StatusFilesProcessor().RunOnPath(workspace) 520 success &= StatusFilesProcessor().RunOnPath(workspace)
506 if success: 521 if success:
507 return 0 522 return 0
508 else: 523 else:
509 return 1 524 return 1
510 525
511 526
512 if __name__ == '__main__': 527 if __name__ == '__main__':
513 sys.exit(Main()) 528 sys.exit(Main())
OLDNEW
« no previous file with comments | « test/mjsunit/unary-minus-deopt.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698