Skip to content

Commit

Permalink
fix: Don't fail if no tests and the user didn't provide a pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
sirasistant committed Dec 19, 2023
1 parent 698d5fd commit afaa0b0
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions tooling/nargo_cli/src/cli/test_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,21 @@ fn run_tests<S: BlackBoxFunctionSolver>(
let test_functions = context.get_all_test_functions_in_crate_matching(&crate_id, fn_name);
let count_all = test_functions.len();
if count_all == 0 {
return match &fn_name {
FunctionNameMatch::Anything => {
Err(CliError::Generic(format!("[{}] Found 0 tests.", package.name)))
match &fn_name {
FunctionNameMatch::Exact(pattern) => {
return Err(CliError::Generic(format!(
"[{}] Found 0 tests matching input '{pattern}'.",
package.name
)))
}
FunctionNameMatch::Exact(pattern) => Err(CliError::Generic(format!(
"[{}] Found 0 tests matching input '{pattern}'.",
package.name
))),
FunctionNameMatch::Contains(pattern) => Err(CliError::Generic(format!(
"[{}] Found 0 tests containing '{pattern}'.",
package.name
))),
FunctionNameMatch::Contains(pattern) => {
return Err(CliError::Generic(format!(
"[{}] Found 0 tests containing '{pattern}'.",
package.name
)))
}
// If we are running all tests in a crate, having none is not an error
FunctionNameMatch::Anything => {}
};
}

Expand Down

0 comments on commit afaa0b0

Please sign in to comment.