Copilot commented on code in PR #13656:
URL: https://github.com/apache/trafficserver/pull/13656#discussion_r3975755426
##########
doc/admin-guide/configuration/hrw4u.en.rst:
##########
@@ -115,6 +115,21 @@ This is particularly useful for build systems or when
processing many configurat
files at once. All files are processed in a single invocation, improving
performance
for large batches of files.
+Exit Status
+^^^^^^^^^^^
+
+======
==========================================================================
+Status Meaning
+======
==========================================================================
+0 Every input compiled. Warnings may still have been reported.
+1 At least one input had an error, or the command line was invalid.
+======
==========================================================================
+
+Every input is processed before the status is decided, so one bad file in a
+multi-file or bulk run does not stop the files after it. A failing compile
+still writes its partial output; the exit status is what marks that output
+untrustworthy.
Review Comment:
The new text says the run processes "every input" before deciding the exit
status, but `run_main()` still terminates immediately on fatal argument/I/O
problems (e.g., missing input files) via
`emit_fatal_message()`/`emit_fatal_error()`. Consider tightening the wording to
specifically describe the collect-all behavior for compile diagnostics
(syntax/semantic errors).
##########
tools/hrw4u/tests/test_cli.py:
##########
@@ -244,3 +244,53 @@ def test_cli_help_lists_error_format_flag() -> None:
assert "--error-format" in result.stdout
for choice in ("plain", "json", "markdown"):
assert choice in result.stdout
+
+
+#
+# Exit-code contract: a compile error must fail the build.
+#
+
+
+def test_cli_exits_nonzero_on_syntax_error(tmp_path: Path) -> None:
+ """A syntax error must exit non-zero even though ANTLR recovers and yields
a tree."""
+ bad = tmp_path / "bad.hrw4u"
+ bad.write_text("REMAP {\n inbound.req.X-Foo = \n}\n")
+
+ result = run_hrw4u([str(bad)])
+
+ assert result.returncode != 0
+ assert ": error:" in result.stderr
+
Review Comment:
The issue and PR description note that this exit-code fix applies to `u4wrh`
as well, but the new regression tests here only exercise `hrw4u`. Adding a
`u4wrh` negative test would better protect the shared `run_main()` exit-status
contract from regressions.
--
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]