Skip to content

fix: add trailing newline to ps_oracle.py --json output (BUILD-1348) - #4673

Open
MichaelL401 wants to merge 2 commits into
ItsNotRexed:mainfrom
MichaelL401:build-1348-ps-oracle-newline
Open

MichaelL401 wants to merge 2 commits into
ItsNotRexed:mainfrom
MichaelL401:build-1348-ps-oracle-newline

Conversation

@MichaelL401

Copy link
Copy Markdown
Contributor

BUILD-1348: ps_oracle.py --json missing trailing newline

Problem

tools/ps_oracle.py --json writes the report with json.dump() but does not add a trailing newline. Text files should end with \n per convention.

Fix

Add f.write("\n") after json.dump() in the --json output block.

Tests

  • python -m compileall -q tools/ps_oracle.py → no syntax errors
  • python -I tests/test_ps_oracle.py → 20 tests OK (1 skipped — no GPU)

Environment

  • Windows 11, Python (standard library only)
  • No GPU or game files needed for this fix

AI assistance

This PR was AI-assisted. The fix was implemented with guidance from an AI agent.


Depends on: none

@kapitche

kapitche commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Tested ed3a861 merged with main 0db7fed on WSL2 Ubuntu, Python 3.12.16: fail, for the same reason as #4660 (this PR contains that PR's crosslane_fuzz commit e7023cf).

Windows 11 (Python 3.13.1, .NET SDK 10.0.403 building the net8.0 Release DLL): the rpf9dump part passes: RPF9DUMP_DLL=<dll> python -I tests/test_rpf9dump_exit_codes.py 3 tests OK, and with main's Program.cs the new test fails 2 subtests.

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran this at ed3a86187 on Windows 11: pytest tests/test_ps_oracle.py -q -> 19 passed, 1 skipped, 35 subtests passed; git diff --check clean.

The JSON output now ends with a newline, so jq/cat and the oracle's text tools see a terminated line. Stacking note: this branch also carries cace4a085 (the rpf9dump missing-source guard, #4636) and e7023cf6a (the --wave 32/64 default-mode fix, #4637's change). Both of those PRs are open separately, so merging this one lands their changes too; one of the copies should be dropped.

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The branch carries e7023cf6a (the crosslane --wave fix) without #4637's test update, so its tree fails tests/test_crosslane_fuzz.py: 2 failed, 52 passed (test_emulate_with_wave32_is_a_usage_error and test_wave64_native_without_w64_native_is_a_usage_error). If this PR merges as-is it will turn that suite red on main; #4637 (9e5cd1f8) is the complete fix (55 passed, 2 skipped). Please rebase onto #4637 or drop the carried commit. tests/test_ps_oracle.py is green (19 passed, 35 subtests).

@tupacfan04

Copy link
Copy Markdown
Contributor

Request changes - the one-line fix is right but nothing tests it, and the branch drags in an unrelated regression.

  • tools/ps_oracle.py:791 is inside the newline="\n" writer and correct, but tests/test_ps_oracle.py has zero json references. Negative control: swapping in origin/main's tool still gives 20 OK / 1 skip, identical, so no test bites.
  • Scope: the branch is stacked on cace4a08 (rpf9dump) and e7023cf6 (fix: allow --wave 32 and --wave 64 in crosslane_fuzz.py (BUILD-1338) #4660, itself under request-changes), and it drags that PR's regression in - tests/test_crosslane_fuzz.py fails 2 (:319 and :330, 1 != 2), while main gives OK (skipped=2).

Good: compileall clean, merge-tree vs main clean, 20 ps_oracle tests pass.

Add a test that reads the JSON back and asserts the trailing newline byte, and rebase onto main without the two stacked commits.

AI-assisted review, no game files, no GPU.

@MichaelL401
MichaelL401 force-pushed the build-1348-ps-oracle-newline branch from ed3a861 to 6293c91 Compare November 23, 2026 04:37
@MichaelL401

Copy link
Copy Markdown
Contributor Author

Rebased onto main, removing the two stacked commits (#4636's rpf9dump change and #4660's crosslane_fuzz change). This PR now contains only the BUILD-1348 fix: one .write(\n) after json.dump() in ools/ps_oracle.py.

  • python -I tests/test_ps_oracle.py: 20 OK (1 skipped)
  • python -m compileall -q: clean
  • git diff --check: clean

Previous reviewers (kapitche, tupacfan04, Kam471): the scope issues you flagged are resolved.

@tupacfan04

Copy link
Copy Markdown
Contributor

Re-checked at 6293c911: the rebase part is fixed, the test part is not.

  • FIXED: the branch is now one commit directly on d0835dd9 (an ancestor of main), the diff is only tools/ps_oracle.py (+1), and merge-tree against origin/main is clean. No rpf9dump or fix: allow --wave 32 and --wave 64 in crosslane_fuzz.py (BUILD-1338) #4660 commits remain.
  • NOT FIXED: no test. tests/test_ps_oracle.py still has no --json case (the Cli tests at :258-266 only cover usage/no-harness). The unchanged test file (cdc3494, same as main) passes 20 tests against main's tool, which lacks the newline, so nothing bites.

compileall clean. Add one test that runs --json, reads the file back, and asserts the final byte is \n; it should fail on main's tool.

AI-assisted review, no game files, no GPU.

@kapitche

Copy link
Copy Markdown
Contributor

Tested c92301a merged with main 98fa503 on WSL2 Ubuntu (Python 3.12.16) and Windows 11 (Python 3.13.1): pass. Re-check of my earlier fail on ed3a861: resolved.

  • Branch scope: the diff against main is now only tools/ps_oracle.py (+1, f.write("\n") after json.dump) and tests/test_ps_oracle.py (+41). The stacked rpf9dump and crosslane_fuzz commits are gone. tests/test_crosslane_fuzz.py on the merged tree: OK (skipped=2), so the earlier 2 failures no longer occur.
  • Test (tupacfan04's point): the new test_json_output_ends_with_trailing_newline runs main(["--json", ...]) with a faked harness, reads the file back, asserts it ends with \n and that it still parses with json.loads.
  • tests/test_ps_oracle.py: Linux 21 tests OK (1 skipped); Windows 21 tests OK (1 skipped).
  • Negative control: with main's tools/ps_oracle.py restored, the new test fails on both Linux and Windows ("JSON output must end with a trailing newline"), 21 run, 1 failure, 1 skipped.
  • No issues found.

@memorypressure

memorypressure commented Nov 23, 2026 •

Copy link
Copy Markdown

Verified on Linux: both commits apply on current main (which lacks the newline), and tests/test_ps_oracle passes 21 with the new trailing-newline test — which fails without the fix commit and passes with it, so the assertion has teeth. The write stays inside the newline-pinned open. CPU-only throughout (harness and assembler mocked). No CI checks were scheduled on this branch. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

Correction (2026-11-23): stack-only claim withdrawn — d3d12_indirect_dispatch_count_test.cpp is on current main and the head merge-trees cleanly. The unverifiable-on-WARP note stands.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants