From a32c9ac4cf33b7628acd86639cbabb13661db729 Mon Sep 17 00:00:00 2001 From: Penn Bauman Date: Thu, 22 Jun 2023 00:56:26 -0400 Subject: [PATCH] fixed/improved integration tests --- include_dir/Cargo.toml | 2 +- include_dir/tests/integration_test.rs | 14 +++++++------- include_dir/tests/tree/a/i/x | 0 include_dir/tests/tree/a/i/y | 0 include_dir/tests/tree/a/i/z | 0 include_dir/tests/tree/a/j | 0 include_dir/tests/tree/a/k | 0 include_dir/tests/tree/b | 0 include_dir/tests/tree/c | 0 9 files changed, 8 insertions(+), 8 deletions(-) create mode 100644 include_dir/tests/tree/a/i/x create mode 100644 include_dir/tests/tree/a/i/y create mode 100644 include_dir/tests/tree/a/i/z create mode 100644 include_dir/tests/tree/a/j create mode 100644 include_dir/tests/tree/a/k create mode 100644 include_dir/tests/tree/b create mode 100644 include_dir/tests/tree/c diff --git a/include_dir/Cargo.toml b/include_dir/Cargo.toml index fc09154a0a..b4b00fea0c 100644 --- a/include_dir/Cargo.toml +++ b/include_dir/Cargo.toml @@ -1,7 +1,7 @@ [package] authors = ["Michael Bryan "] name = "include_dir" -version = "0.7.3" +version = "0.7.4" description = "Embed the contents of a directory in your binary" license = "MIT" readme = "README.md" diff --git a/include_dir/tests/integration_test.rs b/include_dir/tests/integration_test.rs index 3370a8793e..f7302b681b 100644 --- a/include_dir/tests/integration_test.rs +++ b/include_dir/tests/integration_test.rs @@ -2,14 +2,14 @@ use include_dir::{include_dir, Dir}; use std::path::Path; use tempfile::TempDir; -static PARENT_DIR: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR"); +static PARENT_DIR: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/tests/tree"); #[test] fn included_all_files_in_the_include_dir_crate() { - let root = Path::new(env!("CARGO_MANIFEST_DIR")); + let root = &Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/tree"); validate_included(&PARENT_DIR, root, root); - assert!(PARENT_DIR.contains("src/lib.rs")); + assert!(PARENT_DIR.contains("a/i/x")); } #[test] @@ -46,14 +46,14 @@ fn validate_included(dir: &Dir<'_>, path: &Path, root: &Path) { fn validate_extracted(dir: &Dir, path: &Path) { // Check if all the subdirectories exist, recursing on each for subdir in dir.dirs() { - let subdir_path = path.join(dir.path()); - assert!(subdir_path.exists()); - validate_extracted(subdir, &subdir_path); + let subdir_path = path.join(subdir.path()); + assert!(subdir_path.exists(), "Can't find {}", subdir_path.display()); + validate_extracted(subdir, path); } // Check if the files at the root of this directory exist for file in dir.files() { let file_path = path.join(file.path()); - assert!(file_path.exists()); + assert!(file_path.exists(), "Can't find {}", file_path.display()); } } diff --git a/include_dir/tests/tree/a/i/x b/include_dir/tests/tree/a/i/x new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include_dir/tests/tree/a/i/y b/include_dir/tests/tree/a/i/y new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include_dir/tests/tree/a/i/z b/include_dir/tests/tree/a/i/z new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include_dir/tests/tree/a/j b/include_dir/tests/tree/a/j new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include_dir/tests/tree/a/k b/include_dir/tests/tree/a/k new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include_dir/tests/tree/b b/include_dir/tests/tree/b new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include_dir/tests/tree/c b/include_dir/tests/tree/c new file mode 100644 index 0000000000..e69de29bb2