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 1 commit
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
15 changes: 12 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,23 +9,32 @@
[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)

[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-slash-file-rel](d2f2.md/)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link should be valid, both github and gitlab correctly link to [a](./README.md/). I'll create an issue for this.

Copy link
Contributor Author

@Sorokin-Anton Sorokin-Anton Oct 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I left this untouched (with a comment referencing issue)

[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`:
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
50 changes: 40 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,7 @@


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


➥ In file dir1/dir2/d2f1.md
bad reference (relative) at src:23:1-38:
bad reference (relative) at src:26:1-30:
- text: "bad-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:27: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:28: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:30: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:31: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:41: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:42: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:43:1-32:
- text: "file-abs-4"
- link: /./dir2/../d1f1.md
- anchor: -
Expand All @@ -69,7 +99,7 @@


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


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


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


Invalid references dumped, 10 in total.
Invalid references dumped, 13 in total.
74 changes: 62 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,7 @@


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


➥ In file dir1/dir2/d2f1.md
bad reference (relative) at src:23:1-38:
bad reference (relative) at src:26:1-30:
- text: "bad-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:27: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:28: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:30: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:31: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:35: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:36: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:37: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:38: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:39:1-73:
- text: "anchor-abs-2"
- link: /dir1/dir2/../../dir1/./dir2/d2f2.md
- anchor: existing-anchor-d2f2
Expand All @@ -69,7 +119,7 @@


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


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


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


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


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


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