masaori335 commented on code in PR #13656:
URL: https://github.com/apache/trafficserver/pull/13656#discussion_r3975682570


##########
tools/hrw4u/tests/test_common.py:
##########
@@ -164,14 +164,21 @@ def test_ast_mode_tree_none_with_errors(self, capsys):
         out = capsys.readouterr().out
         assert "Parse tree not available" in out
 
-    def test_error_collector_exits_on_parse_failure(self, capsys):
-        """When tree is None and errors exist in non-AST mode, should 
exit(1)."""
+    def test_error_collector_reports_failure_to_caller(self, capsys):
+        """generate_output reports errors via its return value; run_main owns 
the exit status."""
         errors = ErrorCollector()
         errors.add_error(Hrw4uSyntaxError("<test>", 1, 0, "parse failed", 
"bad"))
         args = SimpleNamespace(ast=False, debug=False, no_comments=False)
-        with pytest.raises(SystemExit) as exc_info:
-            generate_output(None, None, HRW4UVisitor, "<test>", args, errors)
-        assert exc_info.value.code == 1
+
+        assert generate_output(None, None, HRW4UVisitor, "<test>", args, 
errors) is True
+
+    def test_clean_input_reports_no_failure(self, capsys):
+        """A clean parse must report False so a multi-file run keeps exit 
status 0."""
+        tree, parser_obj, errors = create_parse_tree(
+            'REMAP { no-op(); }', "<test>", hrw4uLexer, hrw4uParser, "hrw4u", 
collect_errors=True)
+        args = SimpleNamespace(ast=False, debug=False, no_comments=False)
+
+        assert generate_output(tree, parser_obj, HRW4UVisitor, "<test>", args, 
errors) is False

Review Comment:
   fixed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to