diff --git a/dev/varka_generated_merge.py b/dev/varka_generated_merge.py index 45a83d790c4f..c7121f61c9a6 100755 --- a/dev/varka_generated_merge.py +++ b/dev/varka_generated_merge.py @@ -1242,14 +1242,20 @@ def merged(name, b, o, t): f"22: BLOCKS drifted from the tracked markers: {found}", ) - # The attributes patterns match the files git gives the attributes, and each names one. + # The attributes patterns match the files git gives the attributes, and each names one: a + # generated file, or for a rule of git's union driver alone (the skip list's) a tracked file, + # so that a misspelt attribute still fails here. tracked = subprocess.run( ["git", "ls-files", "-z"], cwd=root, capture_output=True, text=True ).stdout.split("\0")[:-1] by_git = git_generated(tracked, None, root) or set() rules = attribute_rules(lambda p: open(os.path.join(root, p), encoding="utf-8").read()) ours = {p for p in tracked if is_generated(p, rules)} - unused = [g for g, rx, _ in rules if not any(rx.match(p) for p in ours)] + unused = [ + g + for g, rx, attrs in rules + if not any(rx.match(p) for p in (tracked if attrs == ["merge=union"] else ours)) + ] expect( ours == by_git - {DOCS} and not unused, f"22: attributes read unlike git: {sorted(ours ^ (by_git - {DOCS}))[:5]}, {unused}", diff --git a/dev/varka_lint.py b/dev/varka_lint.py index 8543963c1dda..25abd7741ad9 100755 --- a/dev/varka_lint.py +++ b/dev/varka_lint.py @@ -416,7 +416,7 @@ def rule_skips_tsv(ch): if SKIPS not in ch.files: return options = option_names() - seen = {} + seen, keys = {}, {} for n, line in enumerate(read(SKIPS).splitlines(), 1): if not line.strip() or line.startswith("#"): continue @@ -424,6 +424,13 @@ def rule_skips_tsv(ch): yield f"{SKIPS}:{n}: skips-tsv: repeats line {seen[line]}" continue seen[line] = n + # Git merges the file by union, which keeps both the old and the new form of a line one + # side edited; the matrix acts on the first fails line for a test and ignores the rest. + key = tuple(line.split("\t")[:3]) + if key in keys: + yield f"{SKIPS}:{n}: skips-tsv: names the test of line {keys[key]} again" + continue + keys[key] = n if not ch.wrote(SKIPS, n): continue fields = line.split("\t") @@ -991,6 +998,17 @@ def case(name, files, expect_rule, expect): "skips-tsv:has no test named", True, ) + case( + "a skip line kept in its old and its edited form, as a union merge leaves it", + { + tables: split, + suite: lic + "class VarkaShapeSuite {}\n", + SKIPS: skip % "a name split across two lines" + + (skip % "a name split across two lines").replace("the reason", "another"), + }, + "skips-tsv:names the test of line", + True, + ) case( "'task 236' in a Varka file", {"sql/varka/plans/X.md": "Done in task 236.\n"}, diff --git a/sql/varka/.gitattributes b/sql/varka/.gitattributes index 67eba05cf184..3fc953fafb48 100644 --- a/sql/varka/.gitattributes +++ b/sql/varka/.gitattributes @@ -9,6 +9,10 @@ /plans/m8/census.tsv merge=varka-generated /plans/m8/casts.tsv merge=varka-generated /plans/m8/casts_fused.tsv merge=varka-generated +# The option matrix's skip list is hand-written and mostly appended to, so git's built-in union +# driver keeps both sides' lines and two branches adding skips never conflict; it needs no +# --install-hook. Union also keeps a line one side removed or edited next to the other's append. +/matrix/skips.tsv merge=union # Other files a tool writes (VARKA-554): the pull-request size check does not count them, and # GitHub folds them in a diff. Results files under results/ and benchmarks/ need no line here. /ci/step-budget.tsv linguist-generated diff --git a/sql/varka/AGENTS.md b/sql/varka/AGENTS.md index bfc0fbcd805f..e94a12f6a8c0 100644 --- a/sql/varka/AGENTS.md +++ b/sql/varka/AGENTS.md @@ -178,7 +178,13 @@ subject is the defaults' emitted structure takes the tag `PinsDefaults`; a test whose subject is what C2 makes of a kernel takes `C2Code`, which runs it only under a configuration that changes what C2 is given (`VarkaMatrixRuns.C2_OPTIONS`); and an answer test a configuration breaks by design gets a line in -`sql/varka/matrix/skips.tsv` with its reason. A Varka pull request's Build runs +`sql/varka/matrix/skips.tsv` with its reason. A local `git merge` or rebase, +on a branch that has the rule, merges that file with git's union driver, so two +branches appending skips do not conflict (GitHub's own merge check may not use +it). Union also keeps a line one side removed or edited next to the other's +append, so after such a merge run `dev/varka_lint.py sql/varka/matrix/skips.tsv`, +which reads every line and flags a test named twice. +A Varka pull request's Build runs the suites at the defaults only: its option configurations are checked by the `varka-option-matrix` workflow dispatched on its branch, which runs all of them, as the weekly run does. There a configuration