Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#165] [#192] Add tests for specific cases of local references #194

Merged
merged 2 commits into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ verification:
- ../d0f1.md
- ../../a.md
- b/../../*
- DIR2/

scanners:
markdown:
Expand Down
20 changes: 17 additions & 3 deletions tests/golden/check-local-refs/dir1/dir2/d2f1.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,43 @@
[bad-cf-ref](#bad)

# Relative links
[existing-file-rel](d2f2.md)
[existing-file-rel](./d2f2.md)
[existing-file-rel](../dir2/.././d1f1.md)
[existing-file-rel-1](d2f2.md)
[existing-file-rel-2](./d2f2.md)
[existing-file-rel-3](../dir2/.././d1f1.md)
[existing-file-rel-4](d2f3.yaml)

Currently our behavior is wrong, see https://github.com/serokell/xrefcheck/issues/195
[slash-file-rel](d2f2.md/)



[existing-dir-rel-1](..)
[existing-dir-rel-2](../dir2)
[existing-dir-rel-3](../dir2/)

[existing-anchor-rel-1](d2f2.md#existing-anchor-d2f2)
[existing-anchor-rel-2](./d2f2.md#existing-anchor-d2f2)
[existing-anchor-rel-3](../dir2/../d1f1.md#existing-anchor-d1f1)

[bad-file-rel](../a/b/c/unexisting-file.md)
[bad-casing-file-rel](D2F2.md/)
[bad-casing-folder-rel](../DIR2)

[bad-anchor-rel-1](d2f2.md#bad-anchor)
[bad-anchor-rel-2](unexisting-file.md#bad-anchor)

# Absolute links
Should be correct when root is `/tests/golden/check-local-refs`:
[file-abs-1](/dir1/./d1f1.md)
dcastro marked this conversation as resolved.
Show resolved Hide resolved
[folder-abs-1](/dir1)
[folder-abs-2](/dir1/dir2/../)
[anchor-abs-1](/dir1/../dir1/d1f1.md#existing-anchor-d1f1)
[anchor-abs-2](/dir1/dir2/../../dir1/./dir2/d2f2.md#existing-anchor-d2f2)
Should be correct when root is `/tests/golden/check-local-refs/dir1`:
[file-abs-2](/d1f1.md)
[file-abs-3](/dir2/d2f2.md)
[file-abs-4](/./dir2/../d1f1.md)
[file-abs-slash](/./dir2/../d1f1.md/)
[anchor-abs-3](/./dir2/../d1f1.md#existing-anchor-d1f1)

# Test references outside repo
Expand Down
4 changes: 4 additions & 0 deletions tests/golden/check-local-refs/dir1/dir2/d2f3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# SPDX-FileCopyrightText: 2022 Serokell <https://serokell.io>
#
# SPDX-License-Identifier: Unlicense
p: q
60 changes: 50 additions & 10 deletions tests/golden/check-local-refs/expected1.gold
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@


➥ In file dir1/dir2/d2f1.md
bad reference (relative) at src:21:1-43:
bad reference (relative) at src:18:1-26:
- text: "slash-file-rel"
- link: d2f2.md/
- anchor: -

⛀ File does not exist:
dir1/dir2/d2f2.md/


➥ In file dir1/dir2/d2f1.md
bad reference (relative) at src:30:1-43:
- text: "bad-file-rel"
- link: ../a/b/c/unexisting-file.md
- anchor: -
Expand All @@ -20,7 +30,27 @@


➥ In file dir1/dir2/d2f1.md
bad reference (relative) at src:23:1-38:
bad reference (relative) at src:31:1-31:
- text: "bad-casing-file-rel"
- link: D2F2.md/
- anchor: -

⛀ File does not exist:
dir1/dir2/D2F2.md/


➥ In file dir1/dir2/d2f1.md
bad reference (relative) at src:32:1-32:
- text: "bad-casing-folder-rel"
- link: ../DIR2
- anchor: -

⛀ File does not exist:
dir1/dir2/../DIR2


➥ In file dir1/dir2/d2f1.md
bad reference (relative) at src:34:1-38:
- text: "bad-anchor-rel-1"
- link: d2f2.md
- anchor: bad-anchor
Expand All @@ -29,7 +59,7 @@


➥ In file dir1/dir2/d2f1.md
bad reference (relative) at src:24:1-49:
bad reference (relative) at src:35:1-49:
- text: "bad-anchor-rel-2"
- link: unexisting-file.md
- anchor: bad-anchor
Expand All @@ -39,7 +69,7 @@


➥ In file dir1/dir2/d2f1.md
bad reference (absolute) at src:32:1-22:
bad reference (absolute) at src:45:1-22:
- text: "file-abs-2"
- link: /d1f1.md
- anchor: -
Expand All @@ -49,7 +79,7 @@


➥ In file dir1/dir2/d2f1.md
bad reference (absolute) at src:33:1-27:
bad reference (absolute) at src:46:1-27:
- text: "file-abs-3"
- link: /dir2/d2f2.md
- anchor: -
Expand All @@ -59,7 +89,7 @@


➥ In file dir1/dir2/d2f1.md
bad reference (absolute) at src:34:1-32:
bad reference (absolute) at src:47:1-32:
- text: "file-abs-4"
- link: /./dir2/../d1f1.md
- anchor: -
Expand All @@ -69,7 +99,17 @@


➥ In file dir1/dir2/d2f1.md
bad reference (absolute) at src:35:1-55:
bad reference (absolute) at src:48:1-37:
- text: "file-abs-slash"
- link: /./dir2/../d1f1.md/
- anchor: -

⛀ File does not exist:
././dir2/../d1f1.md/


➥ In file dir1/dir2/d2f1.md
bad reference (absolute) at src:49:1-55:
- text: "anchor-abs-3"
- link: /./dir2/../d1f1.md
- anchor: existing-anchor-d1f1
Expand All @@ -79,7 +119,7 @@


➥ In file dir1/dir2/d2f1.md
bad reference (absolute) at src:46:1-16:
bad reference (absolute) at src:60:1-16:
- text: "A"
- link: /../../a.md
- anchor: -
Expand All @@ -89,7 +129,7 @@


➥ In file dir1/dir2/d2f1.md
bad reference (absolute) at src:47:1-18:
bad reference (absolute) at src:61:1-18:
- text: "B"
- link: /b/../../b.md
- anchor: -
Expand All @@ -98,4 +138,4 @@
./b/../../b.md


Invalid references dumped, 10 in total.
Invalid references dumped, 14 in total.
84 changes: 72 additions & 12 deletions tests/golden/check-local-refs/expected2.gold
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@


➥ In file dir1/dir2/d2f1.md
bad reference (relative) at src:21:1-43:
bad reference (relative) at src:18:1-26:
- text: "slash-file-rel"
- link: d2f2.md/
- anchor: -

⛀ File does not exist:
dir1/dir2/d2f2.md/


➥ In file dir1/dir2/d2f1.md
bad reference (relative) at src:30:1-43:
- text: "bad-file-rel"
- link: ../a/b/c/unexisting-file.md
- anchor: -
Expand All @@ -20,7 +30,27 @@


➥ In file dir1/dir2/d2f1.md
bad reference (relative) at src:23:1-38:
bad reference (relative) at src:31:1-31:
- text: "bad-casing-file-rel"
- link: D2F2.md/
- anchor: -

⛀ File does not exist:
dir1/dir2/D2F2.md/


➥ In file dir1/dir2/d2f1.md
bad reference (relative) at src:32:1-32:
- text: "bad-casing-folder-rel"
- link: ../DIR2
- anchor: -

⛀ File does not exist:
dir1/dir2/../DIR2


➥ In file dir1/dir2/d2f1.md
bad reference (relative) at src:34:1-38:
- text: "bad-anchor-rel-1"
- link: d2f2.md
- anchor: bad-anchor
Expand All @@ -29,7 +59,7 @@


➥ In file dir1/dir2/d2f1.md
bad reference (relative) at src:24:1-49:
bad reference (relative) at src:35:1-49:
- text: "bad-anchor-rel-2"
- link: unexisting-file.md
- anchor: bad-anchor
Expand All @@ -39,7 +69,7 @@


➥ In file dir1/dir2/d2f1.md
bad reference (absolute) at src:28:1-29:
bad reference (absolute) at src:39:1-29:
- text: "file-abs-1"
- link: /dir1/./d1f1.md
- anchor: -
Expand All @@ -49,7 +79,27 @@


➥ In file dir1/dir2/d2f1.md
bad reference (absolute) at src:29:1-58:
bad reference (absolute) at src:40:1-21:
- text: "folder-abs-1"
- link: /dir1
- anchor: -

⛀ File does not exist:
dir1/dir1


➥ In file dir1/dir2/d2f1.md
bad reference (absolute) at src:41:1-30:
- text: "folder-abs-2"
- link: /dir1/dir2/../
- anchor: -

⛀ File does not exist:
dir1/dir1/dir2/../


➥ In file dir1/dir2/d2f1.md
bad reference (absolute) at src:42:1-58:
- text: "anchor-abs-1"
- link: /dir1/../dir1/d1f1.md
- anchor: existing-anchor-d1f1
Expand All @@ -59,7 +109,7 @@


➥ In file dir1/dir2/d2f1.md
bad reference (absolute) at src:30:1-73:
bad reference (absolute) at src:43:1-73:
- text: "anchor-abs-2"
- link: /dir1/dir2/../../dir1/./dir2/d2f2.md
- anchor: existing-anchor-d2f2
Expand All @@ -69,7 +119,17 @@


➥ In file dir1/dir2/d2f1.md
bad reference (relative) at src:40:1-42:
bad reference (absolute) at src:48:1-37:
- text: "file-abs-slash"
- link: /./dir2/../d1f1.md/
- anchor: -

⛀ File does not exist:
dir1/./dir2/../d1f1.md/


➥ In file dir1/dir2/d2f1.md
bad reference (relative) at src:54:1-42:
- text: "path-through-top-dir"
- link: ../../dir1/d1f1.md
- anchor: -
Expand All @@ -79,7 +139,7 @@


➥ In file dir1/dir2/d2f1.md
bad reference (relative) at src:41:1-75:
bad reference (relative) at src:55:1-75:
- text: "path-through-top-dir-with-anchor"
- link: ../../dir1/d1f1.md
- anchor: existing-anchor-d1f1
Expand All @@ -89,7 +149,7 @@


➥ In file dir1/dir2/d2f1.md
bad reference (relative) at src:42:1-26:
bad reference (relative) at src:56:1-26:
- text: "ref-to-d0"
- link: ../../d0f1.md
- anchor: -
Expand All @@ -99,7 +159,7 @@


➥ In file dir1/dir2/d2f1.md
bad reference (absolute) at src:46:1-16:
bad reference (absolute) at src:60:1-16:
- text: "A"
- link: /../../a.md
- anchor: -
Expand All @@ -109,7 +169,7 @@


➥ In file dir1/dir2/d2f1.md
bad reference (absolute) at src:47:1-18:
bad reference (absolute) at src:61:1-18:
- text: "B"
- link: /b/../../b.md
- anchor: -
Expand All @@ -118,4 +178,4 @@
dir1/b/../../b.md


Invalid references dumped, 12 in total.
Invalid references dumped, 18 in total.
Loading