Skip to content

hrw4u: no non-zero exit status on errors unless --stop-on-error is given #13618

Description

@zwoop

While reviewing #13204, we realized that hrw4u generally doesn't exit with a status code on errors, unless --stop-on-error is given. This applies to u4wrh as well.

In the default error-collecting mode, every input error — syntax and semantic — is reported on stderr, partial output still goes to stdout, and the process exits 0:

$ uv run ./scripts/hrw4u /tmp/foo.hrw4u
cond %{TXN_CLOSE_HOOK} [AND]
/tmp/foo.hrw4u:2:4: error: Unknown statement function: 'counters'
   2 |     counters("my.stat");
     |     ^
$ echo $?
0

generate_output() gates sys.exit(1) on tree is None (tools/hrw4u/src/common.py:281), which with DefaultErrorStrategy never happens — the parser recovers and returns a tree. Only --stop-on-error (bail strategy) and I/O failures exit non-zero.

So nothing can wrap either tool: CI steps, Makefiles, and u4wrh in.hrw > out.hrw4u && hrw4u out.hrw4u all see success on a failed compile. In bulk in:out mode a broken artifact is left on disk under a name that looks converted.

Suggested fix, keeping collect-all behavior (the flag should control when we stop, not whether the run failed): return a failure flag from generate_output(), OR it across all inputs at the three call sites (common.py:366, :401, :429), and sys.exit(1) at the end of run_main(). Also skip the print at common.py:265 — or in in:out mode, don't write the output file at all — when errors were collected.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions