[#206] Make bats tests space-sensitive

Problem: Right now, our bats tests ignore empty lines and
leading/trailing whitespace differences between the expected output and
the actual output.

However, this could lead to accidental bugs in xrefcheck's output.

Trailing whitespace isn't very concerning (except when it's excessive
and it causes the terminal to line-wrap), but additional/missing empty
lines and leading whitespace can lead to significant changes.

Solution: Let's make these tests sensitive to empty lines and leading
whitespace.
This commit is contained in:
Diogo Castro 2022-10-26 13:07:10 +01:00
parent 59cb36cb38
commit e93a21e18a
No known key found for this signature in database
GPG Key ID: 24CC151ACE03BA28
13 changed files with 34 additions and 15 deletions

View File

@ -33,7 +33,7 @@ load '../helpers'
assert_output --partial "All repository links are valid."
}
@test "Reduchant slashes in ignore" {
@test "Redundant slashes in ignore" {
run xrefcheck \
--ignore ./././././././//to-ignore/* \
--root .
@ -45,6 +45,8 @@ load '../helpers'
to_temp xrefcheck --root .
assert_diff - <<EOF
=== Invalid references found ===
➥ In file to-ignore/broken-link.md
@ -65,6 +67,8 @@ EOF
to_temp xrefcheck --root ././///././././//./
assert_diff - <<EOF
=== Invalid references found ===
➥ In file to-ignore/broken-link.md
@ -85,6 +89,8 @@ EOF
to_temp xrefcheck
assert_diff - <<EOF
=== Invalid references found ===
➥ In file to-ignore/broken-link.md

View File

@ -1,3 +1,5 @@
=== Invalid references found ===
➥ In file broken-link-in-footnote/file-with-footnote-with-broken-link.md

View File

@ -41,16 +41,18 @@ load '../helpers'
to_temp xrefcheck
assert_diff - <<EOF
=== Invalid references found ===
➥ In file git.md
bad reference (relative) at src:1:1-11:
- text: "a"
- link: ./a.md
- anchor: -
bad reference (relative) at src:1:1-11:
- text: "a"
- link: ./a.md
- anchor: -
⛀ File does not exist:
a.md
⛀ File does not exist:
a.md
Invalid references dumped, 1 in total.

View File

@ -41,10 +41,9 @@ load '../helpers'
=== Scan errors found ===
➥ In file to-ignore/inner-directory/broken_annotation.md
scan error at src:9:1-29:
⛀ Annotation "ignore all" must be at the top of markdown or right after comments at the top
scan error at src:9:1-29:
⛀ Annotation "ignore all" must be at the top of markdown or right after comments at the top
Scan errors dumped, 1 in total.

View File

@ -1,3 +1,5 @@
=== Scan errors found ===
➥ In file ./to-ignore/inner-directory/broken_annotation.md

View File

@ -1,3 +1,5 @@
=== Invalid references found ===
➥ In file check-ignoreExternalRefsTo.md

View File

@ -1,3 +1,5 @@
=== Invalid references found ===
➥ In file check-ignoreLocalRefsTo.md

View File

@ -32,6 +32,8 @@ load '../helpers'
to_temp xrefcheck -c config-directory.yaml
assert_diff - <<EOF
=== Invalid references found ===
➥ In file ignoreRefsFrom/inner-directory/bad-reference.md

View File

@ -1,3 +1,5 @@
=== Invalid references found ===
➥ In file dir1/dir2/d2f1.md

View File

@ -1,3 +1,5 @@
=== Invalid references found ===
➥ In file dir1/dir2/d2f1.md

View File

@ -1,3 +1,5 @@
=== Invalid references found ===
➥ In file dir1/dir2/d2f1.md

View File

@ -1,6 +1,5 @@
=== Scan errors found ===
➥ In file check-scan-errors.md
scan error at src:9:1-29:

View File

@ -67,9 +67,6 @@ assert_diff() {
: "{output_file?}"
diff $output_file $1 \
--ignore-space-change \
--ignore-tab-expansion \
--ignore-trailing-space \
--ignore-blank-lines \
--new-file # treat absent files as empty
--ignore-trailing-space
}