summaryrefslogtreecommitdiff
path: root/tests/src/tests.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-01-31 15:05:42 +0100
committerLaurenz <laurmaedje@gmail.com>2023-01-31 15:05:42 +0100
commitec05ed7e0646d1e8ff76677d0332ddf93ed57b69 (patch)
tree75f57cbc2380591ef6c4f30d71e018e3cd001e19 /tests/src/tests.rs
parent9a99beec94a5b02aa91a363b299d4795ef52c0fa (diff)
Move assets
Diffstat (limited to 'tests/src/tests.rs')
-rw-r--r--tests/src/tests.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/tests/src/tests.rs b/tests/src/tests.rs
index 7cb1041f..b90abcee 100644
--- a/tests/src/tests.rs
+++ b/tests/src/tests.rs
@@ -28,7 +28,8 @@ const TYP_DIR: &str = "typ";
const REF_DIR: &str = "ref";
const PNG_DIR: &str = "png";
const PDF_DIR: &str = "pdf";
-const FONT_DIR: &str = "fonts";
+const FONT_DIR: &str = "../assets/fonts";
+const FILE_DIR: &str = "../assets/files";
fn main() {
let args = Args::new(env::args().skip(1));
@@ -240,7 +241,7 @@ impl TestWorld {
impl World for TestWorld {
fn root(&self) -> &Path {
- Path::new("")
+ Path::new(FILE_DIR)
}
fn library(&self) -> &Prehashed<Library> {
@@ -306,10 +307,15 @@ impl TestWorld {
}
}
-/// Read a file.
+/// Read as file.
fn read(path: &Path) -> FileResult<Vec<u8>> {
- let f = |e| FileError::from_io(e, path);
- let mut file = File::open(path).map_err(f)?;
+ let suffix = path
+ .strip_prefix(FILE_DIR)
+ .map(|suffix| Path::new("/").join(suffix))
+ .unwrap_or_else(|_| path.into());
+
+ let f = |e| FileError::from_io(e, &suffix);
+ let mut file = File::open(&path).map_err(f)?;
if file.metadata().map_err(f)?.is_file() {
let mut data = vec![];
file.read_to_end(&mut data).map_err(f)?;