diff --git a/.reuse/dep5 b/.reuse/dep5 index 7197762..637b282 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -11,3 +11,7 @@ License: Unlicense Files: tests/configs/github-config.yaml Copyright: 2019-2021 Serokell License: Unlicense + +Files: tests/golden/**/*.gold +Copyright: 2022 Serokell +License: Unlicense diff --git a/CHANGES.md b/CHANGES.md index 08ade5d..60723db 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -33,6 +33,8 @@ Unreleased + Add support for the `id` attribute in anchors. * [#116](https://github.com/serokell/xrefcheck/pull/116) + Allow certain reserved characters to be present in the query strings of the URLs. +* [#130](https://github.com/serokell/xrefcheck/pull/130) + + Fixed bug with ignoring checks for relative anchors. 0.2.1 ========== diff --git a/src/Xrefcheck/Verify.hs b/src/Xrefcheck/Verify.hs index 9ff13ed..0e97d1e 100644 --- a/src/Xrefcheck/Verify.hs +++ b/src/Xrefcheck/Verify.hs @@ -308,7 +308,7 @@ verifyReference then case locType of LocalLoc -> checkRef rAnchor fileWithReference RelativeLoc -> checkRef rAnchor - (takeDirectory fileWithReference + (normalise $ takeDirectory fileWithReference toString (canonizeLocalRef rLink)) AbsoluteLoc -> checkRef rAnchor (root <> toString rLink) ExternalLoc -> checkExternalResource config rLink diff --git a/tests/golden/check-anchors/check-anchors.bats b/tests/golden/check-anchors/check-anchors.bats new file mode 100644 index 0000000..8a2a82c --- /dev/null +++ b/tests/golden/check-anchors/check-anchors.bats @@ -0,0 +1,21 @@ +#!/usr/bin/env bats + +# SPDX-FileCopyrightText: 2022 Serokell +# +# SPDX-License-Identifier: MPL-2.0 + +load '../helpers/bats-support/load' +load '../helpers/bats-assert/load' +load '../helpers' + + +@test "Relative anchor, check error report" { + xrefcheck | prepare > /tmp/check-anchors.test || true + + diff /tmp/check-anchors.test expected.gold \ + --ignore-space-change \ + --ignore-blank-lines \ + --new-file # treat absent files as empty + + rm /tmp/check-anchors.test +} diff --git a/tests/golden/check-anchors/check-relative-anchor.md b/tests/golden/check-anchors/check-relative-anchor.md new file mode 100644 index 0000000..7845524 --- /dev/null +++ b/tests/golden/check-anchors/check-relative-anchor.md @@ -0,0 +1,7 @@ + + +[no-anchor](no-anchor.md#invalid-anchor) diff --git a/tests/golden/check-anchors/expected.gold b/tests/golden/check-anchors/expected.gold new file mode 100644 index 0000000..29cde14 --- /dev/null +++ b/tests/golden/check-anchors/expected.gold @@ -0,0 +1,12 @@ +=== Invalid references found === + + ➥ In file check-relative-anchor.md + bad reference (relative) at src:7:1-40: + - text: "no-anchor" + - link: no-anchor.md + - anchor: invalid-anchor + + ⛀ Anchor 'invalid-anchor' is not present + + +Invalid references dumped, 1 in total. diff --git a/tests/golden/check-anchors/no-anchor.md b/tests/golden/check-anchors/no-anchor.md new file mode 100644 index 0000000..b05b4ed --- /dev/null +++ b/tests/golden/check-anchors/no-anchor.md @@ -0,0 +1,7 @@ + + + # File with no anchors diff --git a/tests/golden/check-cli/expected.gold.license b/tests/golden/check-cli/expected.gold.license deleted file mode 100644 index ce507bb..0000000 --- a/tests/golden/check-cli/expected.gold.license +++ /dev/null @@ -1,2 +0,0 @@ -# SPDX-FileCopyrightText: 2022 Serokell -# SPDX-License-Identifier: Unlicense diff --git a/tests/golden/check-localhost/expected.gold.license b/tests/golden/check-localhost/expected.gold.license deleted file mode 100644 index b2fc740..0000000 --- a/tests/golden/check-localhost/expected.gold.license +++ /dev/null @@ -1,2 +0,0 @@ -# SPDX-FileCopyrightText: 2021 Serokell -# SPDX-License-Identifier: Unlicense