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: use correct enum values for task output mode #5607

Merged
merged 2 commits into from
Jul 25, 2023
Merged
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
24 changes: 24 additions & 0 deletions crates/turborepo-lib/src/config/turbo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -790,4 +790,28 @@ mod tests {

assert_eq!(pruned_json, expected);
}

#[test_case("full", Some(TaskOutputMode::Full) ; "full")]
#[test_case("hash-only", Some(TaskOutputMode::HashOnly) ; "hash-only")]
#[test_case("new-only", Some(TaskOutputMode::NewOnly) ; "new-only")]
#[test_case("errors-only", Some(TaskOutputMode::ErrorsOnly) ; "errors-only")]
#[test_case("none", Some(TaskOutputMode::None) ; "none")]
#[test_case("junk", None ; "invalid value")]
fn test_parsing_output_mode(output_mode: &str, expected: Option<TaskOutputMode>) {
let json: Result<RawTurboJSON, _> = serde_json::from_value(serde_json::json!({
"pipeline": {
"build": {
"outputMode": output_mode,
}
}
}));

let actual = json
.as_ref()
.ok()
.and_then(|j| j.pipeline.as_ref())
.and_then(|pipeline| pipeline.0.get("build"))
.and_then(|build| build.output_mode);
assert_eq!(actual, expected);
}
}
10 changes: 5 additions & 5 deletions crates/turborepo-lib/src/task_graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ pub struct TaskOutputs {
}

// TaskOutputMode defines the ways turbo can display task output during a run
#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]
#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "kebab-case")]
pub enum TaskOutputMode {
// FullTaskOutput will show all task output
#[default]
Full,
// None will hide all task output
None,
// Hash will display turbo-computed task hashes
Hash,
HashOnly,
// New will show all new task output and turbo-computed task hashes for cached
// output
New,
NewOnly,
// Error will show task output for failures only; no cache miss/hit messages are
// emitted
Error,
ErrorsOnly,
}

// taskDefinitionHashable exists as a definition for PristinePipeline, which is
Expand Down
Loading