From 462033a294c46dc365f0bcdce6a1199a66c7fd95 Mon Sep 17 00:00:00 2001 From: Thomas Zahner Date: Fri, 20 Sep 2024 15:07:39 +0200 Subject: [PATCH] Test ignored files --- fixtures/hidden/visible/file.md | 1 - fixtures/ignore/.ignore | 1 + fixtures/ignore/ignored-file.md | 1 + .../{ignore => lycheeignore}/.lycheeignore | 0 fixtures/{ignore => lycheeignore}/TEST.md | 0 .../normal-exclude-file | 0 lychee-bin/tests/cli.rs | 27 ++++++++++++++++--- 7 files changed, 25 insertions(+), 5 deletions(-) delete mode 100644 fixtures/hidden/visible/file.md create mode 100644 fixtures/ignore/.ignore create mode 100644 fixtures/ignore/ignored-file.md rename fixtures/{ignore => lycheeignore}/.lycheeignore (100%) rename fixtures/{ignore => lycheeignore}/TEST.md (100%) rename fixtures/{ignore => lycheeignore}/normal-exclude-file (100%) diff --git a/fixtures/hidden/visible/file.md b/fixtures/hidden/visible/file.md deleted file mode 100644 index 0c0f933..0000000 --- a/fixtures/hidden/visible/file.md +++ /dev/null @@ -1 +0,0 @@ -https://wikipedia.org diff --git a/fixtures/ignore/.ignore b/fixtures/ignore/.ignore new file mode 100644 index 0000000..54bff1b --- /dev/null +++ b/fixtures/ignore/.ignore @@ -0,0 +1 @@ +ignored-file.md diff --git a/fixtures/ignore/ignored-file.md b/fixtures/ignore/ignored-file.md new file mode 100644 index 0000000..23af390 --- /dev/null +++ b/fixtures/ignore/ignored-file.md @@ -0,0 +1 @@ +https://archlinux.org diff --git a/fixtures/ignore/.lycheeignore b/fixtures/lycheeignore/.lycheeignore similarity index 100% rename from fixtures/ignore/.lycheeignore rename to fixtures/lycheeignore/.lycheeignore diff --git a/fixtures/ignore/TEST.md b/fixtures/lycheeignore/TEST.md similarity index 100% rename from fixtures/ignore/TEST.md rename to fixtures/lycheeignore/TEST.md diff --git a/fixtures/ignore/normal-exclude-file b/fixtures/lycheeignore/normal-exclude-file similarity index 100% rename from fixtures/ignore/normal-exclude-file rename to fixtures/lycheeignore/normal-exclude-file diff --git a/lychee-bin/tests/cli.rs b/lychee-bin/tests/cli.rs index 3338d9c..9b07ec2 100644 --- a/lychee-bin/tests/cli.rs +++ b/lychee-bin/tests/cli.rs @@ -473,7 +473,7 @@ mod cli { .arg(fixtures_path().join("hidden/")) .assert() .success() - .stdout(contains("1 OK")); + .stdout(contains("0 Total")); } #[test] @@ -483,7 +483,26 @@ mod cli { .arg("--hidden") .assert() .success() - .stdout(contains("2 OK")); + .stdout(contains("1 Total")); + } + + #[test] + fn test_skips_ignored_files_by_default() { + main_command() + .arg(fixtures_path().join("ignore/")) + .assert() + .success() + .stdout(contains("0 Total")); + } + + #[test] + fn test_include_ignored_file() { + main_command() + .arg(fixtures_path().join("ignore/")) + .arg("--no-ignore") + .assert() + .success() + .stdout(contains("1 Total")); } #[tokio::test] @@ -774,7 +793,7 @@ mod cli { #[test] fn test_lycheeignore_file() -> Result<()> { let mut cmd = main_command(); - let test_path = fixtures_path().join("ignore"); + let test_path = fixtures_path().join("lycheeignore"); let cmd = cmd .current_dir(test_path) @@ -795,7 +814,7 @@ mod cli { #[test] fn test_lycheeignore_and_exclude_file() -> Result<()> { let mut cmd = main_command(); - let test_path = fixtures_path().join("ignore"); + let test_path = fixtures_path().join("lycheeignore"); let excludes_path = test_path.join("normal-exclude-file"); cmd.current_dir(test_path)