Skip to content

Commit

Permalink
Buck2 test: Add TestSkipped enum for TestError
Browse files Browse the repository at this point in the history
Summary: Comment in code basically explains it, but it seems like `Skipped` tests are also considered failed tests. Tag it so we can look for it easily in the future, but I will try to take a closer look once I get a block of time since this doesn't seem like it should be the right behavior to me

Reviewed By: christolliday

Differential Revision: D68731848

fbshipit-source-id: 74c284da64f197a3933e1490c5efbf2c567010f2
  • Loading branch information
Will-MingLun-Li authored and facebook-github-bot committed Jan 31, 2025
1 parent 5ace635 commit a61c42c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/buck2_test/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,13 @@ use crate::translations::build_configured_target_handle;
#[buck2(tag = TestExecutor)]
enum TestError {
#[error("Test execution completed but the tests failed")]
#[buck2(tag = Input)]
TestFailed,
#[error("Test execution completed but tests were skipped")]
#[buck2(tag = Input)]
TestSkipped,
#[error("Test listing failed")]
#[buck2(tag = Input)]
ListingFailed,
#[error("Fatal error encountered during test execution")]
Fatal,
Expand Down Expand Up @@ -566,6 +571,15 @@ fn error_report_for_test_errors(
)));
}
}
// If a test was skipped due to condition not being met a non-zero exit code will be returned,
// this doesn't seem quite right, but for now just tag it with TestSkipped to track occurrence.
if let Some(skipped) = &status.skipped {
if skipped.count > 0 && exit_code.is_none_or(|code| code != 0) {
errors.push(create_error_report(&buck2_error::Error::from(
TestError::TestSkipped,
)));
}
}

if let Some(code) = exit_code {
if errors.is_empty() && code != 0 {
Expand Down

0 comments on commit a61c42c

Please sign in to comment.