Skip to content

Commit f11bd3b

Browse files
test(e2e): pin what the line-match case can actually catch
Review found the case named "line match is dot-anchored (1.5 does not match v155.x)" does not test that: removing the `sed 's/\./\\./g'` escaping from latest_on_line leaves all ten cases green. Checked it, and the reason is narrower than the report. Over the tags stable_desc emits — `^v[0-9]+\.[0-9]+\.[0-9]+$` and nothing else — the escaping, the trailing `$` and the `^` are each unfalsifiable: such a tag carries exactly one `v` and it is at the front, so no fixture can be built that the escaped and unescaped patterns disagree about. v155.0.0 in particular matches neither reading, so the old fixture pinned nothing at all. One piece of the anchoring a fixture CAN reach is the leading `^v` pair. v11.5.0 ends in "1.5.0" and `sort -rV` puts it above v1.5.3, so a pattern that has lost that prefix resolves the wrong line entirely. Swap the fixture to it, rename the case to the property it now pins, and record in both files what is and is not falsifiable here, so the next reader does not have to redo the experiment. Verified non-vacuous: dropping `^v` from latest_on_line's pattern turns exactly this case red; the other ten stay green. Assisted-By: Claude <[email protected]> Signed-off-by: Myasnikov Daniil <[email protected]>
1 parent a9e39c9 commit f11bd3b

2 files changed

Lines changed: 24 additions & 4 deletions

File tree

‎hack/upgrade-prev-version.sh‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,14 @@ stable_desc() {
3535
all_tags | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -rV
3636
}
3737

38-
# Latest stable tag on the given "MAJOR.MINOR" line (empty if none). Dots in the
39-
# line are escaped so line "1.5" cannot spuriously match "v155.x".
38+
# Latest stable tag on the given "MAJOR.MINOR" line (empty if none). The leading
39+
# "^v" is what confines the match to one line: line "1.5" against a tag list
40+
# holding v11.5.0 selects it without that anchor, since the tag ends in "1.5.0"
41+
# and sorts above v1.5.3. The rest of the pattern is belt-and-braces: every tag
42+
# stable_desc emits is vX.Y.Z, and over that set the trailing "$" and the escaped
43+
# dots accept exactly what their unescaped, unanchored counterparts accept. Kept
44+
# for a reader's benefit, and because the set stable_desc admits is one grep away
45+
# from being widened.
4046
latest_on_line() {
4147
_line=$(printf '%s' "$1" | sed 's/\./\\./g')
4248
stable_desc | grep -E "^v${_line}\.[0-9]+$" | head -n1

‎hack/upgrade-prev-version_test.bats‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,25 @@ EOF
9292
rm -rf "$tmp"
9393
}
9494

95-
@test "line match is dot-anchored (1.5 does not match v155.x)" {
95+
# Line "1.5" selects from the v1.5 line and nowhere else, not merely the highest
96+
# stable tag that mentions those digits. v11.5.0 is the fixture that can catch
97+
# the difference: it ends in "1.5.0", and `sort -rV` puts it FIRST, so a pattern
98+
# that has lost its leading "^v" takes it and the case resolves v11.5.0.
99+
# Verified non-vacuous: dropping the "^v" from latest_on_line's pattern turns
100+
# exactly this case red.
101+
#
102+
# The earlier fixture here was v155.0.0, under the name "line match is
103+
# dot-anchored (1.5 does not match v155.x)", and it pinned nothing: no reading of
104+
# the pattern matches that tag, so the case stayed green with the dot escaping
105+
# removed. The narrower truth is that over the tags stable_desc emits — vX.Y.Z
106+
# and nothing else — the escaping, the trailing "$" and the "^" are each
107+
# unfalsifiable, because such a tag carries exactly one "v" and it is at the
108+
# front. The "^v" pair is the one piece of that anchoring a fixture can reach.
109+
@test "previous-minor walk never selects a higher major line" {
96110
tmp=$(mktemp -d)
97111
cat > "$tmp/tags" <<'EOF'
98112
v1.5.3
99-
v155.0.0
113+
v11.5.0
100114
v1.6.0-rc.1
101115
EOF
102116
output=$(hack/upgrade-prev-version.sh v1.6.0-rc.1 "$tmp/tags")

0 commit comments

Comments
 (0)