Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Don't fail if no tests and the user didn't provide a pattern #3864

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading