aboutsummaryrefslogtreecommitdiff
path: root/src/makefile/functions.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/makefile/functions.rs')
-rw-r--r--src/makefile/functions.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/makefile/functions.rs b/src/makefile/functions.rs
index 005f906..97f05b6 100644
--- a/src/makefile/functions.rs
+++ b/src/makefile/functions.rs
@@ -53,7 +53,7 @@ pub fn expand_call(name: &str, args: &[TokenString], macros: &MacroSet) -> anyho
"shell" => todo!(),
// fallback
- _ => panic!("function not implemented: {}", name),
+ _ => anyhow::bail!("function not implemented: {}", name),
}
}
@@ -310,23 +310,23 @@ mod test {
use std::fs::write;
use std::path::MAIN_SEPARATOR;
- let tempdir = tempfile::tempdir().unwrap();
+ let tempdir = tempfile::tempdir()?;
- write(tempdir.path().join("foo.c"), "").unwrap();
- write(tempdir.path().join("bar.h"), "").unwrap();
- write(tempdir.path().join("baz.txt"), "").unwrap();
- write(tempdir.path().join("acab.c"), "ACAB").unwrap();
- write(tempdir.path().join("based.txt"), "☭").unwrap();
+ write(tempdir.path().join("foo.c"), "")?;
+ write(tempdir.path().join("bar.h"), "")?;
+ write(tempdir.path().join("baz.txt"), "")?;
+ write(tempdir.path().join("acab.c"), "ACAB")?;
+ write(tempdir.path().join("based.txt"), "☭")?;
- set_current_dir(tempdir.path()).unwrap();
- set_var("HOME", tempdir.path().to_str().unwrap());
+ set_current_dir(tempdir.path())?;
+ set_var("HOME", tempdir.path());
let sort = |x: String| call("sort", &[TokenString::text(&x)], &MacroSet::new());
assert_eq!(sort(call!(wildcard "*.c"))?, "acab.c foo.c");
assert_eq!(
sort(call!(wildcard "~/ba?.*"))?,
format!(
"{0}{1}bar.h {0}{1}baz.txt",
- tempdir.path().to_str().unwrap(),
+ tempdir.path().display(),
MAIN_SEPARATOR
)
);
@@ -339,7 +339,7 @@ mod test {
macros.set(
"test".to_owned(),
MacroSource::File,
- "worked for $(item).".parse().unwrap(),
+ "worked for $(item).".parse()?,
);
assert_eq!(
call(
@@ -362,7 +362,7 @@ mod test {
macros.set(
"reverse".to_owned(),
MacroSource::File,
- "$(2) $(1)".parse().unwrap(),
+ "$(2) $(1)".parse()?,
);
assert_eq!(
call(