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); } 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() {