Update in tests/ too the PathBuf in FileError

This commit is contained in:
Neven Villani 2025-06-12 15:53:36 +02:00
parent 3846955ce6
commit ddaec8aa85
2 changed files with 6 additions and 16 deletions

View File

@ -172,7 +172,9 @@ pub(crate) fn system_path(id: FileId) -> FileResult<PathBuf> {
None => PathBuf::new(), None => PathBuf::new(),
}; };
id.vpath().resolve(&root).ok_or(FileError::AccessDenied) id.vpath()
.resolve(&root)
.ok_or_else(|| FileError::AccessDenied(id.vpath().as_rootless_path().into()))
} }
/// Read a file. /// Read a file.
@ -186,7 +188,7 @@ pub(crate) fn read(path: &Path) -> FileResult<Cow<'static, [u8]>> {
let f = |e| FileError::from_io(e, path); let f = |e| FileError::from_io(e, path);
if fs::metadata(path).map_err(f)?.is_dir() { if fs::metadata(path).map_err(f)?.is_dir() {
Err(FileError::IsDirectory) Err(FileError::IsDirectory(path.into()))
} else { } else {
fs::read(path).map(Cow::Owned).map_err(f) fs::read(path).map(Cow::Owned).map_err(f)
} }

View File

@ -302,11 +302,11 @@
#import 5 as x #import 5 as x
--- import-from-string-invalid --- --- import-from-string-invalid ---
// Error: 9-11 failed to load file (is a directory) // Error: 9-11 failed to load file tests/suite/scripting (is a directory)
#import "": name #import "": name
--- import-from-string-renamed-invalid --- --- import-from-string-renamed-invalid ---
// Error: 9-11 failed to load file (is a directory) // Error: 9-11 failed to load file tests/suite/scripting (is a directory)
#import "" as x #import "" as x
--- import-file-not-found-invalid --- --- import-file-not-found-invalid ---
@ -484,15 +484,3 @@ This is never reached.
// Error: 9-28 file not found (searched at tests/suite/scripting/#test/mypkg:1.0.0) // Error: 9-28 file not found (searched at tests/suite/scripting/#test/mypkg:1.0.0)
#import "#test/mypkg:1.0.0": * #import "#test/mypkg:1.0.0": *
--- import-from-package-namespace-not-found ---
// Error: 9-33 package not found
#import "@missingdir/test:0.0.0": *
--- import-from-package-not-found ---
// Error: 9-33 package not found
#import "@test/missingpkg:0.0.0": *
--- import-from-package-version-not-found ---
// Error: 9-28 package not found
#import "@test/mypkg:5.0.0": *