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

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

Issue 2387763003: Add initial postprocess unit test thingy. (Closed)
Patch Set: rewrite parser code 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..d829c95ad1dca0f5568225e35b85d90d5c543784 100644
--- a/recipe_engine/third_party/expect_tests/handle_test.py
+++ b/recipe_engine/third_party/expect_tests/handle_test.py
@@ -18,6 +18,11 @@ Fail = collections.namedtuple('Fail', 'test diff log_lines')
Pass = collections.namedtuple('Pass', 'test')
+class FailChecks(collections.namedtuple('FailChecks', 'test checks')):
+ 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 +46,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 +96,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, 'FAIL CHECK')
+ 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