Skip to content

test(script): the go-to-error tests name the cursor offset and remove their temp file even when an assert fails (#2938) - #2974

Merged
jgregoriorincon merged 3 commits into
opengeos:mainfrom
jgregoriorincon:test/2938-go-to-error-tests
Nov 25, 2026
Merged

jgregoriorincon merged 3 commits into
opengeos:mainfrom
jgregoriorincon:test/2938-go-to-error-tests

Conversation

@jgregoriorincon

@jgregoriorincon jgregoriorincon commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #2938. Two follow-ups of #2820, in tests only (no code outside #[cfg(test)] changes):

  • a_stopped_run_marks_its_line_and_its_error_goes_there (crates/ui-egui/src/analysispane.rs) wrote the expected cursor three times as 7 + 13 + 23. It is now one named value, error_at, built from the script's own parts: the characters of the two lines before the error (first and second, each with its line break) plus its column minus one. The script is built from the same first, second and column, which the mark's assert uses too, so the three numbers can't drift apart.
  • a_scripts_error_says_where_it_stopped (crates/engine/src/tests.rs) removed the file its streamed case writes after the assert, so a failing test left it behind. The issue proposed taking the result, removing the file and asserting after; but stop asserts inside (e.starts_with(starts)), before it returns, so that would still leave the file when that assert fails. The file is now held by a small Drop guard local to the test, which removes it however the test ends.

Reaches: nothing a user sees (tests); the desktop, the browser, the command line, Python, MCP and plugins are not touched.

Not in this PR: the cases the issue doesn't name (NOT_AHEAD, the non-native refusal and check_prepared_prefix are still not pinned by this test, as #2962 says).

Testing

UI evidence

No visible UI change.

Related issue

Closes #2938.

Summary by CodeRabbit

  • Tests
    • Improved test cleanup so temporary files are removed when test scopes end, including when assertions fail.
    • Updated cursor-navigation test expectations to calculate positions from the script’s line lengths and reported error column, rather than relying on fixed offsets. This keeps the test aligned with the script’s actual line and column positions.

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Two tests now derive a script cursor index from line lengths and the reported error column, and remove a streamed test file when the test scope ends.

Changes: Test updates

Layer / File(s) Summary
Derive the cursor index from script lines
crates/ui-egui/src/analysispane.rs
The stopped-script test calculates the expected cursor index from the script lines and error column, then uses it in mouse- and keyboard-navigation assertions.
Remove the streamed test file on scope exit
crates/engine/src/tests.rs
A drop guard removes the streamed test file when the test scope ends, replacing explicit cleanup after the assertion.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other · Severity of issue fixed: Low

Suggested reviewers: giswqs, elpidioassinaturas, mavrick-f

Merge Risk: Minimal · up to c0ab3

This is a test-only cleanup with no user-facing behavior change. It carries no actionable merge risk.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the two main changes: the go-to-error test cursor offset is now named, and the temp file is removed even when an assert fails. It matches the objectives and the changeset. It is long (…
Description check Passed The description follows the template sections: Summary, Testing, UI evidence, and Related issue. The UI evidence section states 'No visible UI change,' which the template allows. The Summary explains …
Linked Issues check Passed Issue #2938 has two coding requirements. Both are test-only.

(1) [#2938] In crates/ui-egui/src/analysispane.rs, the expected cursor in a_stopped_run_marks_its_line_and_its_error_goes_there must be on…
Out of Scope Changes check Passed The PR changes two test areas named in #2938: the cursor assertions in a_stopped_run_marks_its_line_and_its_error_goes_there (crates/ui-egui/src/analysispane.rs) and the streamed-case cleanup in a_scr…
Full details: Title check

Explanation

The title names the two main changes: the go-to-error test cursor offset is now named, and the temp file is removed even when an assert fails. It matches the objectives and the changeset. It is long (119 characters) and includes an issue number, but it is specific and accurate.

Full details: Description check

Explanation

The description follows the template sections: Summary, Testing, UI evidence, and Related issue. The UI evidence section states 'No visible UI change,' which the template allows. The Summary explains both test changes and the reason for the Drop guard. The Testing section gives verification steps and results. The Related issue section lists Closes #2938. The template comment asks for an explanation of the change, and the description provides one. No required section is missing.

Full details: Linked Issues check

Explanation

Issue #2938 has two coding requirements. Both are test-only.

(1) [#2938] In crates/ui-egui/src/analysispane.rs, the expected cursor in a_stopped_run_marks_its_line_and_its_error_goes_there must be one named value built from the script's parts, not the repeated 7 + 13 + 23. The PR description and the AI summary both report a named error_at. It is built from the character counts of the two preceding lines (first, second, each with its line break) plus the error column minus one. The script and the asserts use the same first, second and column values. The summary reports the mouse and keyboard navigation asserts now use this value.

(2) [#2938] In crates/engine/src/tests.rs, a_scripts_error_says_where_it_stopped must not leave its streamed-case file behind when an assert fails. The PR removes the explicit removal after the assert and adds a local RemoveOnDrop guard. The AI summary states that the guard is declared before streamed, so streamed drops first and releases the file before removal. That order matches Rust drop order. The issue proposed remove-then-assert. The PR explains that stop asserts internally before it returns, so that order would not cover that failure. The Drop guard meets the issue goal.

Limits: the whole-PR diff could not be read (changed blobs unavailable in the checkout). This verdict relies on the PR description and the AI summaries, which agree on both changes. The tests.rs summary now reports +11/-3, while the prior review recorded +9/-3. This difference is unexplained and does not change the described behavior. The author reports a manual check that a failing run removes the file. Non-coding items are not assessed. The NOT_AHEAD, non-native refusal and check_prepared_prefix cases are not named in #2938 and are not required here.

Full details: Out of Scope Changes check

Explanation

The PR changes two test areas named in #2938: the cursor assertions in a_stopped_run_marks_its_line_and_its_error_goes_there (crates/ui-egui/src/analysispane.rs) and the streamed-case cleanup in a_scripts_error_says_where_it_stopped (crates/engine/src/tests.rs). The PR description and both AI summaries report changes only in #[cfg(test)] code, with no alterations to declarations of exported or public entities. The error_at value and the RemoveOnDrop guard implement the linked objectives directly, so they are not out of scope. The summaries show no other files changed. Limit: the diff could not be read directly, so file-level scope rests on the PR description and the AI summaries, which agree. The tests.rs line count differs from the prior review (+11/-3 now, +9/-3 before). This does not show an unrelated change.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit counts each line with care,
And finds the cursor waiting there.
A streamed file gets one last ride,
Then drops away with nothing left beside.
The tests run on, their paths now clear,
While floppy ears give one small cheer.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 6f53808f-6e80-47ab-baeb-23441ad65005
Commits

Reviewing files that changed from the base of the PR and between d8a5519 and c0ab3b9.

Files selected for processing: 1

  • crates/engine/src/tests.rs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 3 remain after this review.

Comment thread crates/engine/src/tests.rs Resolved
Comment thread crates/ui-egui/src/analysispane.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I reviewed the two-file diff against pr-context/AGENTS.md. The PR changes tests only, and no non-test code changes. I found no bugs, security issues, or performance problems. Two quality points are posted inline.

Bugs

  • None found. I checked the cursor arithmetic in error_at against stopped_index in analysispane.rs, and the column value of 24 against the literal layer.rename {"layer": }, where the closing } is the 24th character. Both are correct. The RemoveOnDrop guard is declared after path, so streamed drops first and the file is removed after the session releases it. That also holds on Windows.

Security

  • None found.

Performance

  • None found.

Quality

  • crates/engine/src/tests.rs:3463 (confidence: high): The new RemoveOnDrop struct sits between the comment "An edit to a layer read in place." and the code it describes. Moving the struct above the comment keeps the comment next to its code. Suggestion included.
  • crates/ui-egui/src/analysispane.rs:3127 (confidence: medium): The PR says the three cursor numbers "can't drift apart", but the script's tail layer.rename {"layer": } is still a separate literal and column is hand-typed to match it. A tail edit would fail the at(&app) assert, so nothing is silently missed. Deriving column from the tail removes the hand-typed number. Suggestion included, and the value stays 24.

AGENTS.md

  • None found. The changes are test-only, so no command surface, expression vocabulary, tl! strings, or schema rules apply.

Prior concerns

  • No review threads existed on this PR (prior-reviews.json is empty), so I left none alone.

Change size

Compared with the base branch (main, merge base 77c573c to PR head 07e80a5).

Measure Value
Files changed 2 (0 added, 2 modified, 0 removed, 0 renamed)
Size before 3.75 MB
Size after 3.75 MB
Total size change +517 B
Path Before After Change
crates/engine/src/tests.rs 3.57 MB 3.57 MB +251 B
crates/ui-egui/src/analysispane.rs 186.0 KB 186.3 KB +266 B

Comment thread crates/engine/src/tests.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

PR #2974 is test-only: two files, no production code changed. I checked the new test logic against the helper signatures and the cursor and column arithmetic, and found no bugs or security issues.

Bugs

None found. I checked:

  • error_at = 7 + 13 + 23 = 43, which is the index of the closing } (column 24). This matches the old literal.
  • column = third.chars().count() = 24, so the at(&app) assert still holds.
  • grid_fgb returns PathBuf and with_streamed takes &Path, so &path.0 type-checks.
  • streamed is declared after path, so it drops first and the file is removed after the session releases it.
  • No unwrap, expect, unsafe or panic! is added in non-test code. The changes are inside #[cfg(test)].

Security

None found.

Performance

None found.

Quality

  • Drop-order dependency is undocumented (confidence: medium, nit). The guard works on Windows only because streamed drops before path. That is posted inline on crates/engine/src/tests.rs:3471.

AGENTS.md

None found. The changes stay inside test code, the test-hygiene rules hold (no same-token assert_eq!, no new timer waits), and no command surface, saved file or schema changes.

Prior review threads

Two earlier threads were raised, and both are resolved and outdated. Both were addressed in d8a5519 (the guard was moved above its comment, and column is now derived from the tail). I re-checked the current code and did not raise them again. Two earlier concerns were left alone.

Change size

Compared with the base branch (merge base 77c573c to PR head d8a5519).

Metric Value
Files changed 2 (0 added, 2 modified, 0 removed, 0 renamed)
Size before 3.75 MB
Size after 3.75 MB
Total size change +649 B
Path Before After Change
crates/ui-egui/src/analysispane.rs 186.0 KB 186.4 KB +398 B
crates/engine/src/tests.rs 3.57 MB 3.57 MB +251 B

@github-actions

Copy link
Copy Markdown
Contributor

Code review

I found no bugs, security issues, performance problems or AGENTS.md violations. I did not post any inline comments. I could not compile or run the tests here (no shell), so this review rests on reading the diff and the code around it.

What I checked

  • Drop order in crates/engine/src/tests.rs: streamed is declared after path, so it drops first and releases the file before RemoveOnDrop removes it. This holds on the panic path too. The stop helper's asserts run before the function returns, so the guard covers them.
  • Column arithmetic in crates/ui-egui/src/analysispane.rs: "layer.rename {\"layer\": }" is 24 characters, so column is 24 and error_at is 7 + 13 + 23 = 43, the same value the old literal asserted. CCursor indexes characters, so chars().count() is the right unit. The format! script is byte-identical to the old literal.
  • Types: at(&app) returns the (line, column) pair from stopped_at, so Some(column) matches the usize column it compares against. The assert message {column} is an inline capture, which compiles on the edition in use.
  • Test hygiene: no assert_eq! has identical sides, and no timer waits or ignored tests were added.
  • Prior art: the same temp-file guard pattern exists in crates/data/src/mbtiles.rs and crates/data/src/raster/zarr.rs. Reusing one shared helper would be a possible tidy-up, but it is not worth a change here.

Prior review threads: 3 left alone

  • The drop-order note (unresolved, not outdated): the note now sits in the code at the let path line, so the concern is addressed and I did not repeat it.
  • The guard's placement relative to its comment (outdated, answered): fixed in d8a5519.
  • Deriving column from the third line (outdated, answered): fixed.

Confidence: high that the change is correct as written. The one thing I could not confirm by reading is that the compiler and the clippy run pass, which CI will show.

Change size

Compared with the base branch (merge base 77c573c to PR head c0ab3b9), the whole PR.

Measure Value
Files changed 2 (0 added, 2 modified, 0 removed, 0 renamed)
Size before 3.75 MB (3,935,239 B)
Size after 3.75 MB (3,936,066 B)
Total size change +827 B
Path Before After Change
crates/engine/src/tests.rs 3.57 MB 3.57 MB +429 B
crates/ui-egui/src/analysispane.rs 186.0 KB 186.4 KB +398 B

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-2974/
Web app https://preview.rustgis.app/pr-2974/app/
Commit c0ab3b9

GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the preview label (once per commit).

@jgregoriorincon
jgregoriorincon added this pull request to the merge queue Nov 25, 2026
Merged via the queue into opengeos:main with commit 0c6cbe2 Nov 25, 2026
30 checks passed
@jgregoriorincon
jgregoriorincon deleted the test/2938-go-to-error-tests branch November 25, 2026 22:04
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.

[Feature]: Script pane go-to-error tests: name the cursor offset, and remove the temp file even when an assert fails

1 participant