Skip to content

Commit 1ee7e1a

Browse files
authored
chore: normalize URLs to the language reference in test results (leanprover#7782)
Links to the language reference include a version slug, either `latest` or `v4.X.0`. These are included in hovers, which then get tested. To avoid test breakages, in the testing framework we normalize all such URL prefixes back to `REFERENCE`.
1 parent 85f94ab commit 1ee7e1a

3 files changed

Lines changed: 15 additions & 11 deletions

File tree

tests/common.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,13 @@ function exec_capture_raw {
4848
function exec_capture {
4949
# backtraces are system-specific, strip them
5050
# mvar suffixes like in `?m.123` are deterministic but prone to change on minor changes, so strip them
51-
LEAN_BACKTRACE=0 "$@" 2>&1 | perl -pe 's/(\?(\w|_\w+))\.[0-9]+/\1/g' > "$f.produced.out"
51+
# similarly, links to the language reference may have URL components depending on the toolchain, so normalize those
52+
LEAN_BACKTRACE=0 "$@" 2>&1 \
53+
| perl -pe 's/(\?(\w|_\w+))\.[0-9]+/\1/g' \
54+
| perl -pe 's/https:\/\/lean-lang\.org\/doc\/reference\/(v?[0-9.]+(-rc[0-9]+)?|latest)/REFERENCE/g' > "$f.produced.out"
5255
}
5356

57+
5458
# Remark: `${var+x}` is a parameter expansion which evaluates to nothing if `var` is unset, and substitutes the string `x` otherwise.
5559
function check_ret {
5660
[ -n "${expected_ret+x}" ] || expected_ret=0

tests/lean/interactive/hover.lean.expected.out

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
{"start": {"line": 12, "character": 4}, "end": {"line": 12, "character": 12}},
2121
"contents":
2222
{"value":
23-
"```lean\nNat.zero : Nat\n```\n***\nZero, the smallest natural number.\n\nUsing `Nat.zero` explicitly should usually be avoided in favor of the literal `0`, which is the\n[simp normal form](https://lean-lang.org/doc/reference/latest/find/?domain=Verso.Genre.Manual.section&name=simp-normal-forms).\n\n***\n*import Init.Prelude*",
23+
"```lean\nNat.zero : Nat\n```\n***\nZero, the smallest natural number.\n\nUsing `Nat.zero` explicitly should usually be avoided in favor of the literal `0`, which is the\n[simp normal form](REFERENCE/find/?domain=Verso.Genre.Manual.section&name=simp-normal-forms).\n\n***\n*import Init.Prelude*",
2424
"kind": "markdown"}}
2525
{"textDocument": {"uri": "file:///hover.lean"},
2626
"position": {"line": 21, "character": 2}}
@@ -521,7 +521,7 @@
521521
{"start": {"line": 257, "character": 4}, "end": {"line": 257, "character": 9}},
522522
"contents":
523523
{"value":
524-
"```lean\nNat.zero : ℕ\n```\n***\nZero, the smallest natural number.\n\nUsing `Nat.zero` explicitly should usually be avoided in favor of the literal `0`, which is the\n[simp normal form](https://lean-lang.org/doc/reference/latest/find/?domain=Verso.Genre.Manual.section&name=simp-normal-forms).\n\n***\n*import Init.Prelude*",
524+
"```lean\nNat.zero : ℕ\n```\n***\nZero, the smallest natural number.\n\nUsing `Nat.zero` explicitly should usually be avoided in favor of the literal `0`, which is the\n[simp normal form](REFERENCE/find/?domain=Verso.Genre.Manual.section&name=simp-normal-forms).\n\n***\n*import Init.Prelude*",
525525
"kind": "markdown"}}
526526
{"textDocument": {"uri": "file:///hover.lean"},
527527
"position": {"line": 257, "character": 15}}
@@ -530,15 +530,15 @@
530530
"end": {"line": 257, "character": 18}},
531531
"contents":
532532
{"value":
533-
"```lean\nNat.zero : ℕ\n```\n***\nZero, the smallest natural number.\n\nUsing `Nat.zero` explicitly should usually be avoided in favor of the literal `0`, which is the\n[simp normal form](https://lean-lang.org/doc/reference/latest/find/?domain=Verso.Genre.Manual.section&name=simp-normal-forms).\n\n***\n*import Init.Prelude*",
533+
"```lean\nNat.zero : ℕ\n```\n***\nZero, the smallest natural number.\n\nUsing `Nat.zero` explicitly should usually be avoided in favor of the literal `0`, which is the\n[simp normal form](REFERENCE/find/?domain=Verso.Genre.Manual.section&name=simp-normal-forms).\n\n***\n*import Init.Prelude*",
534534
"kind": "markdown"}}
535535
{"textDocument": {"uri": "file:///hover.lean"},
536536
"position": {"line": 260, "character": 6}}
537537
{"range":
538538
{"start": {"line": 260, "character": 4}, "end": {"line": 260, "character": 9}},
539539
"contents":
540540
{"value":
541-
"```lean\nNat.succ (n : ℕ) : ℕ\n```\n***\nThe successor of a natural number `n`.\n\nUsing `Nat.succ n` should usually be avoided in favor of `n + 1`, which is the [simp normal\nform](https://lean-lang.org/doc/reference/latest/find/?domain=Verso.Genre.Manual.section&name=simp-normal-forms).\n\n***\n*import Init.Prelude*",
541+
"```lean\nNat.succ (n : ℕ) : ℕ\n```\n***\nThe successor of a natural number `n`.\n\nUsing `Nat.succ n` should usually be avoided in favor of `n + 1`, which is the [simp normal\nform](REFERENCE/find/?domain=Verso.Genre.Manual.section&name=simp-normal-forms).\n\n***\n*import Init.Prelude*",
542542
"kind": "markdown"}}
543543
{"textDocument": {"uri": "file:///hover.lean"},
544544
"position": {"line": 260, "character": 17}}
@@ -547,7 +547,7 @@
547547
"end": {"line": 260, "character": 20}},
548548
"contents":
549549
{"value":
550-
"```lean\nNat.succ (n : ℕ) : ℕ\n```\n***\nThe successor of a natural number `n`.\n\nUsing `Nat.succ n` should usually be avoided in favor of `n + 1`, which is the [simp normal\nform](https://lean-lang.org/doc/reference/latest/find/?domain=Verso.Genre.Manual.section&name=simp-normal-forms).\n\n***\n*import Init.Prelude*",
550+
"```lean\nNat.succ (n : ℕ) : ℕ\n```\n***\nThe successor of a natural number `n`.\n\nUsing `Nat.succ n` should usually be avoided in favor of `n + 1`, which is the [simp normal\nform](REFERENCE/find/?domain=Verso.Genre.Manual.section&name=simp-normal-forms).\n\n***\n*import Init.Prelude*",
551551
"kind": "markdown"}}
552552
{"textDocument": {"uri": "file:///hover.lean"},
553553
"position": {"line": 263, "character": 27}}
@@ -565,7 +565,7 @@
565565
"end": {"line": 263, "character": 36}},
566566
"contents":
567567
{"value":
568-
"```lean\nNat.zero : ℕ\n```\n***\nZero, the smallest natural number.\n\nUsing `Nat.zero` explicitly should usually be avoided in favor of the literal `0`, which is the\n[simp normal form](https://lean-lang.org/doc/reference/latest/find/?domain=Verso.Genre.Manual.section&name=simp-normal-forms).\n\n***\n*import Init.Prelude*",
568+
"```lean\nNat.zero : ℕ\n```\n***\nZero, the smallest natural number.\n\nUsing `Nat.zero` explicitly should usually be avoided in favor of the literal `0`, which is the\n[simp normal form](REFERENCE/find/?domain=Verso.Genre.Manual.section&name=simp-normal-forms).\n\n***\n*import Init.Prelude*",
569569
"kind": "markdown"}}
570570
{"textDocument": {"uri": "file:///hover.lean"},
571571
"position": {"line": 269, "character": 2}}

tests/lean/interactive/hoverDot.lean.expected.out

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
{"start": {"line": 12, "character": 14}, "end": {"line": 12, "character": 18}},
2121
"contents":
2222
{"value":
23-
"```lean\nNat.succ (n : Nat) : Nat\n```\n***\nThe successor of a natural number `n`.\n\nUsing `Nat.succ n` should usually be avoided in favor of `n + 1`, which is the [simp normal\nform](https://lean-lang.org/doc/reference/latest/find/?domain=Verso.Genre.Manual.section&name=simp-normal-forms).\n\n***\n*import Init.Prelude*",
23+
"```lean\nNat.succ (n : Nat) : Nat\n```\n***\nThe successor of a natural number `n`.\n\nUsing `Nat.succ n` should usually be avoided in favor of `n + 1`, which is the [simp normal\nform](REFERENCE/find/?domain=Verso.Genre.Manual.section&name=simp-normal-forms).\n\n***\n*import Init.Prelude*",
2424
"kind": "markdown"}}
2525
{"textDocument": {"uri": "file:///hoverDot.lean"},
2626
"position": {"line": 16, "character": 11}}
@@ -34,7 +34,7 @@
3434
{"start": {"line": 16, "character": 14}, "end": {"line": 16, "character": 18}},
3535
"contents":
3636
{"value":
37-
"```lean\nNat.succ (n : Nat) : Nat\n```\n***\nThe successor of a natural number `n`.\n\nUsing `Nat.succ n` should usually be avoided in favor of `n + 1`, which is the [simp normal\nform](https://lean-lang.org/doc/reference/latest/find/?domain=Verso.Genre.Manual.section&name=simp-normal-forms).\n\n***\n*import Init.Prelude*",
37+
"```lean\nNat.succ (n : Nat) : Nat\n```\n***\nThe successor of a natural number `n`.\n\nUsing `Nat.succ n` should usually be avoided in favor of `n + 1`, which is the [simp normal\nform](REFERENCE/find/?domain=Verso.Genre.Manual.section&name=simp-normal-forms).\n\n***\n*import Init.Prelude*",
3838
"kind": "markdown"}}
3939
{"textDocument": {"uri": "file:///hoverDot.lean"},
4040
"position": {"line": 19, "character": 13}}
@@ -48,7 +48,7 @@
4848
{"start": {"line": 19, "character": 16}, "end": {"line": 19, "character": 20}},
4949
"contents":
5050
{"value":
51-
"```lean\nNat.succ (n : Nat) : Nat\n```\n***\nThe successor of a natural number `n`.\n\nUsing `Nat.succ n` should usually be avoided in favor of `n + 1`, which is the [simp normal\nform](https://lean-lang.org/doc/reference/latest/find/?domain=Verso.Genre.Manual.section&name=simp-normal-forms).\n\n***\n*import Init.Prelude*",
51+
"```lean\nNat.succ (n : Nat) : Nat\n```\n***\nThe successor of a natural number `n`.\n\nUsing `Nat.succ n` should usually be avoided in favor of `n + 1`, which is the [simp normal\nform](REFERENCE/find/?domain=Verso.Genre.Manual.section&name=simp-normal-forms).\n\n***\n*import Init.Prelude*",
5252
"kind": "markdown"}}
5353
{"textDocument": {"uri": "file:///hoverDot.lean"},
5454
"position": {"line": 22, "character": 14}}
@@ -62,5 +62,5 @@
6262
{"start": {"line": 22, "character": 17}, "end": {"line": 22, "character": 21}},
6363
"contents":
6464
{"value":
65-
"```lean\nNat.succ (n : Nat) : Nat\n```\n***\nThe successor of a natural number `n`.\n\nUsing `Nat.succ n` should usually be avoided in favor of `n + 1`, which is the [simp normal\nform](https://lean-lang.org/doc/reference/latest/find/?domain=Verso.Genre.Manual.section&name=simp-normal-forms).\n\n***\n*import Init.Prelude*",
65+
"```lean\nNat.succ (n : Nat) : Nat\n```\n***\nThe successor of a natural number `n`.\n\nUsing `Nat.succ n` should usually be avoided in favor of `n + 1`, which is the [simp normal\nform](REFERENCE/find/?domain=Verso.Genre.Manual.section&name=simp-normal-forms).\n\n***\n*import Init.Prelude*",
6666
"kind": "markdown"}}

0 commit comments

Comments
 (0)