diff --git a/tests/golden/check-anchors/check-anchors.bats b/tests/golden/check-anchors/check-anchors.bats index ed9ee870..f7c1d8e0 100644 --- a/tests/golden/check-anchors/check-anchors.bats +++ b/tests/golden/check-anchors/check-anchors.bats @@ -10,72 +10,13 @@ load '../helpers/bats-file/load' load '../helpers' @test "We report ambiguous anchor references" { + golden_file=$(realpath expected1.gold) to_temp xrefcheck -r ambiguous-anchors -assert_diff - < https://commonmark.org - ^-- stopped before this one - -Invalid references dumped, 1 in total. -EOF + assert_diff } diff --git a/tests/golden/check-autolinks/expected.gold b/tests/golden/check-autolinks/expected.gold new file mode 100644 index 00000000..6c5d93b0 --- /dev/null +++ b/tests/golden/check-autolinks/expected.gold @@ -0,0 +1,26 @@ +=== Repository data === + + file-with-autolinks.md: + - references: + - reference (external): + - text: "https://www.google.com/doodles" + - link: https://www.google.com/doodles + - reference (external) at src:8:0-18: + - text: "www.commonmark.org" + - link: http://www.commonmark.org + - anchors: + none + +=== Invalid references found === + + ➥ In file file-with-autolinks.md + bad reference (external) at src:8:0-18: + - text: "www.commonmark.org" + - link: http://www.commonmark.org + + Permanent redirect found: + -| http://www.commonmark.org + -> https://commonmark.org + ^-- stopped before this one + +Invalid references dumped, 1 in total. diff --git a/tests/golden/check-backslash/check-backslash.bats b/tests/golden/check-backslash/check-backslash.bats index 41dd1aa5..5bec9c43 100644 --- a/tests/golden/check-backslash/check-backslash.bats +++ b/tests/golden/check-backslash/check-backslash.bats @@ -11,8 +11,9 @@ load '../helpers' @test "Checking files with backslash" { + golden_file=$(realpath expected.gold) + cp a.md $TEST_TEMP_DIR - cp expected.gold $TEST_TEMP_DIR touch "$TEST_TEMP_DIR/a\a.md" || \ return 0 # Cannot be tested on Windows @@ -29,5 +30,5 @@ EOF to_temp xrefcheck -v - assert_diff expected.gold + assert_diff } diff --git a/tests/golden/check-case-sensitivity-anchor/check-case-sensitivity-anchor.bats b/tests/golden/check-case-sensitivity-anchor/check-case-sensitivity-anchor.bats index cf7a4bf4..dba95e5c 100644 --- a/tests/golden/check-case-sensitivity-anchor/check-case-sensitivity-anchor.bats +++ b/tests/golden/check-case-sensitivity-anchor/check-case-sensitivity-anchor.bats @@ -11,13 +11,13 @@ load '../helpers' @test "GitHub anchors: check, ambiguous and similar detection is case-insensitive" { + golden_file=$(realpath expected1.gold) to_temp xrefcheck -c config-github.yaml - - assert_diff expected1.gold + assert_diff } @test "GitLab anchors: check and ambiguous detection is case-sensitive, but similar detection is not" { + golden_file=$(realpath expected2.gold) to_temp xrefcheck -c config-gitlab.yaml - - assert_diff expected2.gold + assert_diff } diff --git a/tests/golden/check-case-sensitivity-path/check-case-sensitivity-path.bats b/tests/golden/check-case-sensitivity-path/check-case-sensitivity-path.bats index cf03d52f..858c36a6 100644 --- a/tests/golden/check-case-sensitivity-path/check-case-sensitivity-path.bats +++ b/tests/golden/check-case-sensitivity-path/check-case-sensitivity-path.bats @@ -11,13 +11,13 @@ load '../helpers' @test "GitHub paths: case-sensitive" { + golden_file=$(realpath expected.gold) to_temp xrefcheck -v -c config-github.yaml - - assert_diff expected.gold + assert_diff } @test "GitLab paths: case-sensitive" { + golden_file=$(realpath expected.gold) to_temp xrefcheck -v -c config-gitlab.yaml - - assert_diff expected.gold + assert_diff } diff --git a/tests/golden/check-cli/check-cli.bats b/tests/golden/check-cli/check-cli.bats index 7ec02dbf..4e4db229 100644 --- a/tests/golden/check-cli/check-cli.bats +++ b/tests/golden/check-cli/check-cli.bats @@ -42,60 +42,21 @@ load '../helpers' } @test "Basic root, check errors report" { + golden_file=$(realpath expected1.gold) to_temp xrefcheck --root . - - assert_diff - < $output_file + assert_diff } @test "No color flag (not in CI)" { - CI=false xrefcheck -v --no-progress --no-color | diff - expected-no-color.gold + golden_file=$(realpath expected-no-color.gold) + output_file="$TEST_TEMP_DIR/temp_file.test" + CI=false xrefcheck -v --no-progress --no-color > $output_file + assert_diff } @test "No color default when pipe (not in CI)" { - CI=false xrefcheck -v --no-progress | diff - expected-no-color.gold + golden_file=$(realpath expected-no-color.gold) + output_file="$TEST_TEMP_DIR/temp_file.test" + CI=false xrefcheck -v --no-progress > $output_file + assert_diff } @test "Color default when CI" { - CI=true xrefcheck -v --no-progress | diff - expected-color.gold + golden_file=$(realpath expected-color.gold) + output_file="$TEST_TEMP_DIR/temp_file.test" + CI=true xrefcheck -v --no-progress > $output_file + assert_diff } @test "No color flag in CI" { - CI=true xrefcheck -v --no-progress --no-color | diff - expected-no-color.gold + golden_file=$(realpath expected-no-color.gold) + output_file="$TEST_TEMP_DIR/temp_file.test" + CI=true xrefcheck -v --no-progress --no-color > $output_file + assert_diff } diff --git a/tests/golden/check-dump-config/check-dump-config.bats b/tests/golden/check-dump-config/check-dump-config.bats index f2d09ab9..f9b3fb97 100644 --- a/tests/golden/check-dump-config/check-dump-config.bats +++ b/tests/golden/check-dump-config/check-dump-config.bats @@ -11,9 +11,9 @@ load '../helpers' @test "Dump config to stdout" { + golden_file=$(realpath ../../configs/github-config.yaml) to_temp xrefcheck dump-config --stdout -t GitHub - - assert_diff ../../configs/github-config.yaml + assert_diff } @test "Dump config to existent default file error" { diff --git a/tests/golden/check-footnotes/check-footnotes.bats b/tests/golden/check-footnotes/check-footnotes.bats index 939a8840..5ae90d58 100644 --- a/tests/golden/check-footnotes/check-footnotes.bats +++ b/tests/golden/check-footnotes/check-footnotes.bats @@ -11,9 +11,9 @@ load '../helpers' @test "We report broken links inside footnotes" { + golden_file=$(realpath expected.gold) to_temp xrefcheck -r broken-link-in-footnote - - assert_diff expected.gold + assert_diff } @test "We're not treating footnotes as 'shortcut reference links'" { diff --git a/tests/golden/check-git/check-git.bats b/tests/golden/check-git/check-git.bats index ee79d9b5..af504c2c 100644 --- a/tests/golden/check-git/check-git.bats +++ b/tests/golden/check-git/check-git.bats @@ -38,6 +38,8 @@ load '../helpers' } @test "Git: bad file not tracked, --include-untracked enabled, check failure" { + golden_file=$(realpath expected1.gold) + cd $TEST_TEMP_DIR git init @@ -46,23 +48,12 @@ load '../helpers' to_temp xrefcheck --include-untracked - assert_diff - <