Repository navigation
Conversation
add_repl registers a plain substring match, so a short ID can cut into a longer token in test output: a deployment ID inside an embedded commit hash hid the CLI version cleanup pattern in a real DMS run. A literal whose first or last byte is an ASCII letter or digit now matches only where its neighbour on that side is not an ASCII letter or digit. The Go harness (libs/testdiff) and acceptance/bin/repls.py apply the same rule. Harness-set literals (Set) keep plain substring matching. Co-authored-by: Isaac <no-reply@databricks.com>
|
Commit: Regression test reportSelected 1 changed tests (limit=20, 0 not selected) 3 tests: regression=0 unreleased=0 coverage=3 failing=0
|
✅ Integration test reportCommit: 6cb522f
Top 6 slowest tests (at least 2 minutes):
|
cloud: TestAccept/bundle/dms/no-drift TestAccept/bundle/dms/depends-on Co-authored-by: Isaac <no-reply@databricks.com>
There was a problem hiding this comment.
Automated review at 6cb522f. Each finding was verified against the code.
No blocking issues found. 3 non-blocking comment(s) and 1 question(s) below.
This PR makes add_repl literals match only as whole alphanumeric runs, in both the Go harness (replaceWholeWord) and repls.py, so a short script-registered ID no longer cuts into a commit hash or a longer ID. I didn't find a bug in the Go or Python matching logic, and the two apply the same rule. The new selftest doesn't actually check the Python path it says it covers, and it doesn't follow two of the testing rules.
Questions
- This changes matching for every
add_repl,replace_ids.pyandread_id.pyliteral in the suite, and the description says the full acceptance run is still in progress. A golden where a registered value sits directly next to a letter or digit would silently stop being replaced. Can you post which goldens change, or confirm that none do, before merging? (non-blocking)
| echo "job $job_id, commit 33939489e027, number 3390" | ||
| echo "job_$job_id deploy-$job_id /$job_id/ $job_id,$job_id" | ||
|
|
||
| # diff.py applies the same replacements in Python. The files are equal only if the ID is |
There was a problem hiding this comment.
[nice to have] This check passes even if literal_pattern goes back to re.escape(value). Both files contain 33939489e027, so the old rule turns both lines into job [SHORT_ID] commit [SHORT_ID]39489e027. They still compare equal and the golden still only shows diff done, which also makes the comment above wrong. Can you make the Python result visible? For example, put the hash only in a.txt and write the old mangled form [SHORT_ID]39489e027 in b.txt, so the old rule prints no diff and the new rule prints one. Or make the files differ elsewhere, so diff.py prints already-replaced lines into the golden.
|
|
||
| # diff.py applies the same replacements in Python. The files are equal only if the ID is | ||
| # not replaced inside the commit hash. | ||
| echo "job 339 commit 33939489e027" > a.txt |
There was a problem hiding this comment.
[nit] a.txt and b.txt have fixed contents, and .agents/rules/testing.md says to commit static test inputs into the test directory rather than create them in script. Can you commit them and drop the echo > lines and the rm on line 13?
| @@ -0,0 +1,14 @@ | |||
| job_id=339 | |||
There was a problem hiding this comment.
[nit] acceptance/selftest/add_repl/ already tests add_repl replacement of a job ID. .agents/rules/testing.md asks to extend the existing acceptance directory when coverage overlaps. Could these whole-word cases go there instead of a new add_repl_word/?
Changes
add_replliterals now match only as whole alphanumeric runs. A literal whose first or last byte is an ASCII letter or digit must have a non-alphanumeric neighbour on that side (or the start or end of the text). Other characters, including_,-,/,.and:, are separators. Sides that start or end with a non-alphanumeric character keep the old behaviour.The Go harness (
libs/testdiff,loadScriptReplacements) andacceptance/bin/repls.pyapply the same rule. Literals set by the harness throughSetkeep plain substring matching, so paths and versions are unchanged.Why
Scripts register IDs with
add_repl, and those replacements are applied before the harness patterns. Because the match was a plain substring, a short ID could also match inside another token. In a real DMS run, a deployment ID was a substring of the CLI's embedded commit hash, so the[CLI_VERSION]+<hash>cleanup no longer matched and the output showed a mangled version. The same class of collision came up for a dependency-test ID inside another ID. Test servers can avoid this by using long IDs, but real DMS and cloud IDs are not under our control.Tests
libs/testdiff/replacement_test.gocover: inside a hex string, standalone,job_<id>,deploy-<id>,/<id>/, adjacent<id>,<id>, values starting or ending with a non-alphanumeric character, a rejected match that does not hide a later one, and the JSON-encoded variant. A test also checks that harnessSetliterals still match inside longer strings.repls.pydoctests cover the same rule (python3 -m doctest acceptance/bin/repls.py).acceptance/selftest/add_repl_wordregisters an ID and checks it inside a hex string, next to_,-,/and,separators, and compares two files withdiff.py, which runs the Python path.This pull request and its description were written by Isaac.