From 5567ad878983fbdb69712b154473a7172ef5b73e Mon Sep 17 00:00:00 2001 From: Tobias Brumhard Date: Wed, 3 May 2023 03:17:47 +0200 Subject: [PATCH] Improve error message for invalid executors (#99) * Improve error message for invalid executors * Add test for custom error --- mask/src/executor.rs | 17 ++++++++++++++++- mask/tests/supported_runtimes_test.rs | 22 ++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/mask/src/executor.rs b/mask/src/executor.rs index e0d7617..10d26b6 100644 --- a/mask/src/executor.rs +++ b/mask/src/executor.rs @@ -18,7 +18,22 @@ pub fn execute_command(cmd: Command, maskfile_path: String) -> Result process::Command { diff --git a/mask/tests/supported_runtimes_test.rs b/mask/tests/supported_runtimes_test.rs index 8a3cae1..26195f1 100644 --- a/mask/tests/supported_runtimes_test.rs +++ b/mask/tests/supported_runtimes_test.rs @@ -26,6 +26,28 @@ echo "this won't do anything..." .failure(); } +#[test] +fn custom_not_found_error_if_program_not_found() { + let (_temp, maskfile_path) = common::maskfile( + r#" +## missing +~~~notfound +echo "this won't do anything..." +~~~ +"#, + ); + + common::run_mask(&maskfile_path) + .command("missing") + .assert() + .code(1) + .stderr(contains(format!( + "{} program 'notfound' for executor 'notfound' not in PATH", + "ERROR:".red() + ))) + .failure(); +} + #[cfg(windows)] #[test] fn powershell() {