Index: tools/presubmit.py |
diff --git a/tools/presubmit.py b/tools/presubmit.py |
index 51ca99165685ce6b21cf8a897f10d36f9d9ff8ad..9e9394560bfd2192992adb957d1d5584de0994a4 100755 |
--- a/tools/presubmit.py |
+++ b/tools/presubmit.py |
@@ -69,6 +69,10 @@ LINT_RULES = """ |
LINT_OUTPUT_PATTERN = re.compile(r'^.+[:(]\d+[:)]|^Done processing') |
FLAGS_LINE = re.compile("//\s*Flags:.*--([A-z0-9-])+_[A-z0-9].*\n") |
+ASSERT_OPTIMIZED_PATTERN = re.compile("assertOptimized") |
+FLAGS_ENABLE_OPT = re.compile("//\s*Flags:.*--(crankshaft|turbo)[^-].*\n") |
+ASSERT_UNOPTIMIZED_PATTERN = re.compile("assertUnoptimized") |
+FLAGS_NO_ALWAYS_OPT = re.compile("//\s*Flags:.*--no-?always-opt.*\n") |
TOOLS_PATH = dirname(abspath(__file__)) |
@@ -401,11 +405,22 @@ class SourceProcessor(SourceFileProcessor): |
print "%s does not end with a single new line." % name |
result = False |
# Sanitize flags for fuzzer. |
- if "mjsunit" in name: |
+ if "mjsunit" in name or "debugger" in name: |
match = FLAGS_LINE.search(contents) |
if match: |
print "%s Flags should use '-' (not '_')" % name |
result = False |
+ if not "mjsunit/mjsunit.js" in name: |
+ if ASSERT_OPTIMIZED_PATTERN.search(contents) and \ |
+ not FLAGS_ENABLE_OPT.search(contents): |
+ print "%s Flag --crankshaft or --turbo should be set " \ |
+ "if assertOptimized() is used" % name |
+ result = False |
+ if ASSERT_UNOPTIMIZED_PATTERN.search(contents) and \ |
+ not FLAGS_NO_ALWAYS_OPT.search(contents): |
+ print "%s Flag --no-always-opt should be set if " \ |
+ "assertUnoptimized() is used" % name |
+ result = False |
return result |
def ProcessFiles(self, files): |