diff --git a/cli/src/context.rs b/cli/src/context.rs index 0e16ab01..8425abb4 100644 --- a/cli/src/context.rs +++ b/cli/src/context.rs @@ -265,9 +265,22 @@ pub fn gather_post_test_context>( )?; if !allow_empty_test_results && file_set_builder.no_files_found() { - return Err(anyhow::anyhow!(InterruptingError::new( - "No test output files found to upload." - ))); + let searched = junit_path_wrappers + .iter() + .map(|j| j.junit_path.as_str()) + .collect::>() + .join(", "); + // Both spellings, since clap can't tell which was passed and the GitHub Action passes the alias. + return Err(anyhow::anyhow!(InterruptingError::new(format!( + "No test results found to upload{}. Failing because --allow-empty-test-results \ + (or its alias --allow-missing-junit-files) is false; set it to true to continue \ + without test results.", + if searched.is_empty() { + String::new() + } else { + format!(" in: <{searched}>") + } + )))); } tracing::info!("Total files pack and upload: {}", file_set_builder.count()); diff --git a/cli/tests/upload.rs b/cli/tests/upload.rs index b2d8ca91..eed94abe 100644 --- a/cli/tests/upload.rs +++ b/cli/tests/upload.rs @@ -1475,6 +1475,14 @@ async fn upload_bundle_no_files_allow_missing_junit_files() { assert.stderr(predicate_fn.not()) }; + if matches!(flag, Flag::OffWithEquals | Flag::OffAliasWithEquals) { + assert = assert.code(70).stderr(predicate::str::contains( + "No test results found to upload in: <./*>. Failing because \ + --allow-empty-test-results (or its alias --allow-missing-junit-files) is false; \ + set it to true to continue without test results.", + )); + } + // HINT: View CLI output with `cargo test -- --nocapture` println!("{assert}"); }