From 6e14ee92f4fd8cbe64276d539818cc354c0c1434 Mon Sep 17 00:00:00 2001 From: zerodegress Date: Fri, 5 Jul 2024 19:58:11 +0800 Subject: [PATCH 1/2] Fixed: Incorrect 'get_entry 'behaviour. --- include_dir/src/dir.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include_dir/src/dir.rs b/include_dir/src/dir.rs index da52cd0d71..b053a4cc3f 100644 --- a/include_dir/src/dir.rs +++ b/include_dir/src/dir.rs @@ -41,7 +41,7 @@ impl<'a> Dir<'a> { let path = path.as_ref(); for entry in self.entries() { - if entry.path() == path { + if entry.path() == self.path().join(path) { return Some(entry); } From d3cfc1c5d195608d5afe95b6c7fd5069ffaf35a7 Mon Sep 17 00:00:00 2001 From: zerodegress Date: Fri, 5 Jul 2024 19:58:50 +0800 Subject: [PATCH 2/2] Added: Test if 'get_entry' works properly. --- include_dir/tests/integration_test.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include_dir/tests/integration_test.rs b/include_dir/tests/integration_test.rs index bf95ba59df..515b3b5bcd 100644 --- a/include_dir/tests/integration_test.rs +++ b/include_dir/tests/integration_test.rs @@ -21,6 +21,14 @@ fn extract_all_files() { validate_extracted(&PARENT_DIR, root); } +#[test] +fn get_entry_works_properly() { + PARENT_DIR.get_dir("src") + .expect("is 'src' deleted? please fix this.") + .get_entry("lib.rs") + .expect("check if 'lib.rs' exists, or the behaviour is not expected."); +} + // Validates that all files on the filesystem exist in the inclusion fn validate_included(dir: &Dir<'_>, path: &Path, root: &Path) { for entry in path.read_dir().unwrap() {