Repository navigation
Conversation
spark-test
left a comment
There was a problem hiding this comment.
Review summary
The latest commit addresses all six comments from the previous review. run_prmerge_tests() now resolves the script's real path, so a launch through a symlink finds the suite, and both update commands use git checkout --no-overlay, so files that master deleted are removed. New tests cover each refusal of the startup check and the exit before main(). The prepare_merge_title tests again assert the captured errors and the exact output, the missing-reopen-transition test again asserts that no transition is applied, and the _wrapped docstring now matches the summary the helper returns.
Three smaller gaps remain in the new startup check. A dev/prmerge/tests directory that exists without init.py, such as one left holding only pycache after its tracked files were removed, passes the isdir() guard, so unittest's discover() raises an uncaught ImportError instead of the check printing the not-found notice and the update command. The update command uses pathspecs relative to the repository root, so it fails when run from dev/, where the script's usage line launches it, or from any other subdirectory. The new refusal tests check only the hint line that every refusal shares, so no test fails if a refusal stops printing the failing test's report or prints the not-found notice in the wrong case.
The review also covered the doctest scenarios ported into the new test modules and the dev/prmerge entries added to .github/labeler.yml and dev/sparktestsupport/modules.py, with no finding there.
Cross-cutting observations
-
The new startup check in dev/merge_spark_pr.py refuses safely in every state this review traced: whether the script is launched directly or through a symlink, a missing, empty, failing, or unimportable dev/prmerge/tests stops it before main() runs, so no merge can start without a passing suite. The three findings listed below are about what a refused committer is told and how they recover, not about whether the check refuses.
None of the three lets a merge start untested, so each is a non-blocking fix to what the refusal prints or to the tests that check it.
Related:
- Refusal tests don't check the failure report or the not-found notice
- Printed update command works only from the repository root
- Tests directory without init.py gets a traceback, not the update hint
Findings
3 total: 0 P0, 0 P1, 0 P2, 3 P3.
Nit (P3)
- Tests directory without init.py gets a traceback, not the update hint —
dev/merge_spark_pr.py:4252-4253— see inline. - Printed update command works only from the repository root —
dev/merge_spark_pr.py:4250— see inline. - Refusal tests don't check the failure report or the not-found notice —
dev/prmerge/tests/test_entrypoint.py:173— see inline.
Re-review status
Prior AI findings: 6 no longer raised, 0 still raised; additional unresolved findings in this review: 3.
Of these: 1 in code changed since the previous review; 2 in code the previous review already covered.
Generated by Omnigent on Databricks
| "If dev/prmerge/ is behind master, update it with the script:\n" | ||
| f" git fetch {PUSH_REMOTE_NAME} master && " | ||
| f"git checkout --no-overlay {PUSH_REMOTE_NAME}/master -- " | ||
| "dev/merge_spark_pr.py dev/prmerge\n" |
There was a problem hiding this comment.
Nit (P3): Git resolves these pathspecs against the current directory, and the hint is printed before main() runs, so the committer runs it from wherever they launched the script. From dev/, the directory the usage line ./merge_spark_pr.py assumes, or from any other subdirectory, the checkout fails with error: pathspec 'dev/merge_spark_pr.py' did not match any file(s) known to git (and the same for dev/prmerge) and updates nothing, so the committer has to work out that the paths are relative to the repository root. maybe_compile_check handles the dev/ working directory for the same reason (dev/merge_spark_pr.py:1352-1354). Top-anchored pathspecs work from any directory of the checkout:
| "dev/merge_spark_pr.py dev/prmerge\n" | |
| ":/dev/merge_spark_pr.py :/dev/prmerge\n" |
To keep one update command, print :/%s :/dev/prmerge in the out-of-date message at dev/merge_spark_pr.py:3965 as well. Add the prefix only in the message text: MERGE_SCRIPT_REPO_PATH also builds the GitHub commits query at dev/merge_spark_pr.py:3934, and the check treats a query that returns no commits as up to date.
Verification:
- Regression: In a throwaway repository, run the update command the startup refusal prints from the repository root, from dev/, and from another subdirectory, in a checkout that predates dev/prmerge and in one that tracks a test module master has since deleted: every run exits 0, updates the script, and brings dev/prmerge to master's state, which removes the deleted module from the second checkout.
- Inspection: The startup refusal and the out-of-date message print the same update command, neither one passes git a pathspec that resolves against the current directory, and the GitHub commits query still uses the unprefixed script path.
What changes were proposed in this pull request?
Move the doctests captured in
__test__out ofdev/merge_spark_pr.pyand into proper unit tests underdev/prmerge/tests/. These tests cover the abort path, the title prompts, JIRA updates, andmain().Before a merge,
dev/merge_spark_pr.pystill runs all of its own tests and stops if they fail. It also correctly instructs users on how to update the script and tests if they are stale.Committers still run
dev/merge_spark_pr.py. The merge itself is unchanged. Outside the tests, the only changes to the script are how it runs them at startup and the update command it suggests when it's out of date.This change overlaps with #60472. Happy to help rebase whichever PR gets merged second.
Why are the changes needed?
__test__is a single, massive text blob of doctests, about 1,000 lines long. Formatting these tests is brittle and failures are annoying to match to the source test as they show up without a line number:Split out into proper unit tests, these tests are much easier to read, change, and maintain over time.
Moreover, this is the first step towards breaking up the merge script into a proper library under
dev/prmergewith topic-specific modules and reusable tools. SPARK-62147 tracks the larger effort.Does this PR introduce any user-facing change?
No.
For committers, the interface to and behavior of
dev/merge_spark_pr.pyis unchanged. It takes the same arguments and does the same merge.A passing startup check is still quiet. If the unit tests fail, or
dev/prmerge/tests/is missing, the script prints a hint to updatedev/merge_spark_pr.pyanddev/prmerge/together.How was this patch tested?
I ran the unit tests directly, and I ran the script so it would execute both the doctests and the suite before printing help. I also ran it with a failing test and with
dev/prmerge/removed. Both stopped before the merge and printed the update hint. I also launched the script through a symlink from another directory, and it found the suite.New tests cover the startup check's refusals (missing, failing, or empty suite), a passing suite staying quiet, the symlink case, and the entrypoint exiting with
-1beforemain()when the suite fails.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Cursor Grok 4.7
Generated-by: Cursor Claude Opus 5.5