From a2686c31b25d55678a05a94cbbba31e04382acd9 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 22 May 2024 13:40:01 +0200 Subject: [PATCH] refact: Distribute unwrap() This gives us better error messages in case it does go wrong. (cherry picked from commit 0fec573d82b6c51e72183ae5a19c922a53863d5b) --- rust/nix-expr/src/eval_state.rs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/rust/nix-expr/src/eval_state.rs b/rust/nix-expr/src/eval_state.rs index e558f1b..c929278 100644 --- a/rust/nix-expr/src/eval_state.rs +++ b/rust/nix-expr/src/eval_state.rs @@ -248,20 +248,17 @@ mod tests { #[ctor] fn setup() { - (|| -> Result<()> { - init()?; - // During development, we encountered a problem where the build hook - // would cause the test suite to reinvokes itself, causing an infinite loop. - // While _NIX_TEST_NO_SANDBOX=1 should prevent this, we may also set the - // build hook to "" to prevent this. - // settings::set("build-hook", "")?; + init().unwrap(); - // When testing in the sandbox, the default build dir would be a parent of the storeDir, - // which causes an error. So we set a custom build dir here. - settings::set("sandbox-build-dir", "/custom-build-dir-for-test")?; - Ok(()) - })() - .unwrap(); + // During development, we encountered a problem where the build hook + // would cause the test suite to reinvokes itself, causing an infinite loop. + // While _NIX_TEST_NO_SANDBOX=1 should prevent this, we may also set the + // build hook to "" to prevent this. + // settings::set("build-hook", "")?; + + // When testing in the sandbox, the default build dir would be a parent of the storeDir, + // which causes an error. So we set a custom build dir here. + settings::set("sandbox-build-dir", "/custom-build-dir-for-test").unwrap(); std::env::set_var("_NIX_TEST_NO_SANDBOX", "1"); }