From e1128fe55d91ca60086de45c911b4568d2eec9ee Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Wed, 31 Mar 2021 13:43:46 -0600 Subject: awolnation voice BAIL --- src/makefile/functions.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/makefile/functions.rs') 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( -- cgit v1.2.3