-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#165] Add tests for local references
Problem: We want all cases of local references to be covered by bats tests (e.g. cause we want to be sure that all this works well on Windows), but there was only one case covered in `check-anchors` Solution: make a `check-local-refs` folder and test different types of links with different roots
- Loading branch information
1 parent
12003cc
commit 9b70282
Showing
7 changed files
with
222 additions
and
32 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env bats | ||
|
||
# SPDX-FileCopyrightText: 2022 Serokell <https://serokell.io> | ||
# | ||
# SPDX-License-Identifier: MPL-2.0 | ||
|
||
load '../helpers/bats-support/load' | ||
load '../helpers/bats-assert/load' | ||
load '../helpers/bats-file/load' | ||
load '../helpers' | ||
|
||
|
||
@test "Checking local references, root = \".\"" { | ||
to_temp xrefcheck | ||
|
||
assert_diff expected1.gold | ||
} | ||
|
||
@test "Checking local references, root = \"dir1\"" { | ||
to_temp xrefcheck -r dir1 | ||
|
||
assert_diff expected2.gold | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ | |
- SPDX-License-Identifier: MPL-2.0 | ||
--> | ||
|
||
# File with no anchors | ||
# Existing anchor d1f1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!-- | ||
- SPDX-FileCopyrightText: 2022 Serokell <https://serokell.io> | ||
- | ||
- SPDX-License-Identifier: MPL-2.0 | ||
--> | ||
|
||
# Current file links | ||
[existing-cf-ref](#current-file-links) | ||
[bad-cf-ref](#bad) | ||
|
||
# Relative links | ||
[existing-file-rel](d2f2.md) | ||
[existing-file-rel](./d2f2.md) | ||
[existing-file-rel](../dir2/.././d1f1.md) | ||
|
||
|
||
[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-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) | ||
[anchor-abs-1](/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) | ||
[anchor-abs-3](/./dir2/../d1f1.md#existing-anchor-d1f1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ | |
- SPDX-License-Identifier: MPL-2.0 | ||
--> | ||
|
||
[no-anchor](no-anchor.md#invalid-anchor) | ||
# Existing anchor d2f2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
=== Invalid references found === | ||
|
||
➥ In file dir1/dir2/d2f1.md | ||
bad reference (current file) at src:9:1-18: | ||
- text: "bad-cf-ref" | ||
- link: | ||
- anchor: bad | ||
|
||
⛀ Anchor 'bad' is not present | ||
|
||
|
||
➥ In file dir1/dir2/d2f1.md | ||
bad reference (relative) at src:21:1-43: | ||
- text: "bad-file-rel" | ||
- link: ../a/b/c/unexisting-file.md | ||
- anchor: - | ||
|
||
⛀ File does not exist: | ||
dir1/dir2/../a/b/c/unexisting-file.md | ||
|
||
|
||
➥ In file dir1/dir2/d2f1.md | ||
bad reference (relative) at src:23:1-38: | ||
- text: "bad-anchor-rel-1" | ||
- link: d2f2.md | ||
- anchor: bad-anchor | ||
|
||
⛀ Anchor 'bad-anchor' is not present | ||
|
||
|
||
➥ In file dir1/dir2/d2f1.md | ||
bad reference (relative) at src:24:1-49: | ||
- text: "bad-anchor-rel-2" | ||
- link: unexisting-file.md | ||
- anchor: bad-anchor | ||
|
||
⛀ File does not exist: | ||
dir1/dir2/unexisting-file.md | ||
|
||
|
||
➥ In file dir1/dir2/d2f1.md | ||
bad reference (absolute) at src:29:1-55: | ||
- text: "anchor-abs-1" | ||
- link: /dir1/.././d1f1.md | ||
- anchor: existing-anchor-d1f1 | ||
|
||
⛀ File does not exist: | ||
./dir1/.././d1f1.md | ||
|
||
|
||
➥ In file dir1/dir2/d2f1.md | ||
bad reference (absolute) at src:32:1-22: | ||
- text: "file-abs-2" | ||
- link: /d1f1.md | ||
- anchor: - | ||
|
||
⛀ File does not exist: | ||
./d1f1.md | ||
|
||
|
||
➥ In file dir1/dir2/d2f1.md | ||
bad reference (absolute) at src:33:1-27: | ||
- text: "file-abs-3" | ||
- link: /dir2/d2f2.md | ||
- anchor: - | ||
|
||
⛀ File does not exist: | ||
./dir2/d2f2.md | ||
|
||
|
||
➥ In file dir1/dir2/d2f1.md | ||
bad reference (absolute) at src:34:1-32: | ||
- text: "file-abs-4" | ||
- link: /./dir2/../d1f1.md | ||
- anchor: - | ||
|
||
⛀ File does not exist: | ||
././dir2/../d1f1.md | ||
|
||
|
||
➥ In file dir1/dir2/d2f1.md | ||
bad reference (absolute) at src:35:1-55: | ||
- text: "anchor-abs-3" | ||
- link: /./dir2/../d1f1.md | ||
- anchor: existing-anchor-d1f1 | ||
|
||
⛀ File does not exist: | ||
././dir2/../d1f1.md | ||
|
||
|
||
Invalid references dumped, 9 in total. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
=== Invalid references found === | ||
|
||
➥ In file dir1/dir2/d2f1.md | ||
bad reference (current file) at src:9:1-18: | ||
- text: "bad-cf-ref" | ||
- link: | ||
- anchor: bad | ||
|
||
⛀ Anchor 'bad' is not present | ||
|
||
|
||
➥ In file dir1/dir2/d2f1.md | ||
bad reference (relative) at src:21:1-43: | ||
- text: "bad-file-rel" | ||
- link: ../a/b/c/unexisting-file.md | ||
- anchor: - | ||
|
||
⛀ File does not exist: | ||
dir1/dir2/../a/b/c/unexisting-file.md | ||
|
||
|
||
➥ In file dir1/dir2/d2f1.md | ||
bad reference (relative) at src:23:1-38: | ||
- text: "bad-anchor-rel-1" | ||
- link: d2f2.md | ||
- anchor: bad-anchor | ||
|
||
⛀ Anchor 'bad-anchor' is not present | ||
|
||
|
||
➥ In file dir1/dir2/d2f1.md | ||
bad reference (relative) at src:24:1-49: | ||
- text: "bad-anchor-rel-2" | ||
- link: unexisting-file.md | ||
- anchor: bad-anchor | ||
|
||
⛀ File does not exist: | ||
dir1/dir2/unexisting-file.md | ||
|
||
|
||
➥ In file dir1/dir2/d2f1.md | ||
bad reference (absolute) at src:28:1-29: | ||
- text: "file-abs-1" | ||
- link: /dir1/./d1f1.md | ||
- anchor: - | ||
|
||
⛀ File does not exist: | ||
dir1/dir1/./d1f1.md | ||
|
||
|
||
➥ In file dir1/dir2/d2f1.md | ||
bad reference (absolute) at src:29:1-55: | ||
- text: "anchor-abs-1" | ||
- link: /dir1/.././d1f1.md | ||
- anchor: existing-anchor-d1f1 | ||
|
||
⛀ File does not exist: | ||
dir1/dir1/.././d1f1.md | ||
|
||
|
||
➥ In file dir1/dir2/d2f1.md | ||
bad reference (absolute) at src:30:1-73: | ||
- text: "anchor-abs-2" | ||
- link: /dir1/dir2/../../dir1/./dir2/d2f2.md | ||
- anchor: existing-anchor-d2f2 | ||
|
||
⛀ File does not exist: | ||
dir1/dir1/dir2/../../dir1/./dir2/d2f2.md | ||
|
||
|
||
Invalid references dumped, 7 in total. |