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

Unified Diff: recipe_engine/third_party/expect_tests/handle_test.py

Issue 2387763003: Add initial postprocess unit test thingy. (Closed)
Patch Set: Created 4 years, 2 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: recipe_engine/third_party/expect_tests/handle_test.py
diff --git a/recipe_engine/third_party/expect_tests/handle_test.py b/recipe_engine/third_party/expect_tests/handle_test.py
index 4338c7df815846526bd94f7f0223b71a1b89956e..8b1a8e912284dceed77eab747782a9ba3e99a5a4 100644
--- a/recipe_engine/third_party/expect_tests/handle_test.py
+++ b/recipe_engine/third_party/expect_tests/handle_test.py
@@ -6,6 +6,7 @@ import collections
import os
import sys
import time
+import textwrap
martiniss 2016/10/03 19:14:19 unused
iannucci 2016/10/06 22:47:11 Done.
from cStringIO import StringIO
@@ -18,6 +19,11 @@ Fail = collections.namedtuple('Fail', 'test diff log_lines')
Pass = collections.namedtuple('Pass', 'test')
+class FailChecks(collections.namedtuple('FailChecks', 'test checks')):
dnj 2016/10/04 16:42:35 nit: use a tuple of single strings instead of a sp
iannucci 2016/10/06 22:47:11 I usually do the space delimited string because na
+ def format(self, indent):
+ return (' '*indent+'\n').join([c.format(indent+2) for c in self.checks])
+
+
class TestHandler(Handler):
"""Run the tests."""
@@ -41,7 +47,11 @@ class TestHandler(Handler):
else:
diff = DiffData(current, result.data)
if not diff:
- put_next_stage(Pass(test))
+ failed_checks = [check for check in result.checks if not check.passed]
+ if failed_checks:
+ put_next_stage(FailChecks(test, failed_checks))
+ else:
+ put_next_stage(Pass(test))
else:
put_next_stage(Fail(test, diff, log_lines))
@@ -87,6 +97,12 @@ class TestHandler(Handler):
head, tail = os.path.split(test.expect_path())
self.files_expected[head].add(tail)
+ def handle_FailChecks(self, fc):
+ self._handle_record(fc.test)
+ self._emit('C', fc.test, 'womba')
martiniss 2016/10/03 19:14:19 womba??
iannucci 2016/10/06 22:47:11 er, oops.
+ self._add_result(fc.format(2), fc.test, 'FAIL CHECK', 'failed checks')
+ return Failure()
+
def handle_Pass(self, p):
self._handle_record(p.test)
if not self.opts.quiet:

Powered by Google App Engine
This is Rietveld 408576698