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

Unified Diff: Tools/Scripts/webkitpy/layout_tests/testharness/testharness_results_checker.py

Issue 332583002: Add PRESUBMIT checks for not required testharness expected files. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: ignore deleted files Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: Tools/Scripts/webkitpy/layout_tests/testharness/testharness_results_checker.py
diff --git a/Tools/Scripts/webkitpy/layout_tests/testharness/testharness_results_checker.py b/Tools/Scripts/webkitpy/layout_tests/testharness/testharness_results_checker.py
new file mode 100644
index 0000000000000000000000000000000000000000..511431a59136ff501e0c6e84593035dc24d22a00
--- /dev/null
+++ b/Tools/Scripts/webkitpy/layout_tests/testharness/testharness_results_checker.py
@@ -0,0 +1,76 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Utility module for testharness."""
+
+
+# const definitions
+TESTHARNESSREPORT_HEADER = 'This is a testharness.js-based test.'
+TESTHARNESSREPORT_FOOTER = 'Harness: the test ran to completion.'
+
+
+def is_testharness_output(content_text):
+ """Returns whether the content_text in parameter is a testharness output.
+
+ Returns:
+ True if content_text is a valid testharness output. False otherwise.
+ """
+
+ # Leading and trailing white spaces are accepted.
+ lines = content_text.strip().splitlines()
+ lines = [line.strip() for line in lines]
+
+ # A testharness output is defined as containing the header and the footer.
+ found_header = False
+ found_footer = False
+ for line in lines:
+ if line == TESTHARNESSREPORT_HEADER:
+ found_header = True
+ elif line == TESTHARNESSREPORT_FOOTER:
+ found_footer = True
+
+ return found_header and found_footer
+
+
+def is_testharness_output_passing(content_text):
Dirk Pranke 2014/06/13 22:27:07 Can you rewrite this as: def is_testharness_outpu
mlamouri (slow - plz ping) 2014/06/15 12:12:41 The only reason why I'm checking the format here i
+ """Returns whether the content_text in parameter is a passing testharness output.
+
+ Note:
+ It is expected that the |content_text| is a testharness output.
+
+ Returns:
+ True if content_text is a passing testharness output. False otherwise.
+ """
+
+ # Leading and trailing white spaces are accepted.
+ lines = content_text.strip().splitlines()
+ lines = [line.strip() for line in lines]
+
+ # The check is very conservative and reject any unexpected content in the output.
+ for line in lines:
+ # There should be no empty lines.
+ if len(line) == 0:
+ return False
+
+ # Those lines are expected to be exactly equivalent.
+ if line == TESTHARNESSREPORT_HEADER or \
+ line == TESTHARNESSREPORT_FOOTER:
+ continue
+
+ # Those are expected passing output.
+ if line.startswith('CONSOLE') or \
+ line.startswith('PASS'):
+ continue
+
+ # Those are expected failing outpu.
+ if line.startswith('FAIL') or \
+ line.startswith('TIMEOUT') or \
+ line.startswith('NOTRUN') or \
+ line.startswith('Harness Error. harness_status = '):
+ return False
+
+ # Unexpected output should be considered as a failure.
+ return False
+
+ return True

Powered by Google App Engine
This is Rietveld 408576698