Skip to content
Closed
Show file tree
Hide file tree
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
19 changes: 16 additions & 3 deletions cli/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,22 @@ pub fn gather_post_test_context<U: AsRef<Path>>(
)?;

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::<Vec<_>>()
.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());
Expand Down
8 changes: 8 additions & 0 deletions cli/tests/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
}
Expand Down
Loading