Skip to content

Commit

Permalink
fix: correctly serialize ui values (#8338)
Browse files Browse the repository at this point in the history
### Description

Solves the issue reported here:
#8311 (comment)

The `biome` deserialization defaults to camel case, whereas the `serde`
serialization implementation doesn't.

### Testing Instructions

Added unit tests as well as updated the `prune` test fixture to include
`"ui": "stream"`
  • Loading branch information
chris-olszewski committed Jun 5, 2024
1 parent 92e7503 commit 8df02c6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
9 changes: 9 additions & 0 deletions crates/turborepo-lib/src/turbo_json/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ impl DerefMut for Pipeline {
}

#[derive(Serialize, Debug, Copy, Clone, Deserializable, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub enum UI {
Tui,
Stream,
Expand Down Expand Up @@ -1073,4 +1074,12 @@ mod tests {
let json = RawTurboJson::parse(json, AnchoredSystemPath::new("").unwrap()).unwrap();
assert_eq!(json.ui, expected);
}

#[test_case(r#"{ "ui": "tui" }"#, r#"{"ui":"tui"}"# ; "tui")]
#[test_case(r#"{ "ui": "stream" }"#, r#"{"ui":"stream"}"# ; "stream")]
fn test_ui_serialization(input: &str, expected: &str) {
let parsed = RawTurboJson::parse(input, AnchoredSystemPath::new("").unwrap()).unwrap();
let actual = serde_json::to_string(&parsed).unwrap();
assert_eq!(actual, expected);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"web#build": {
"dependsOn": ["web#gen"]
}
}
},
"ui": "stream"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Make sure we prune tasks that reference a pruned workspace
"build": {
"outputs": []
}
}
},
"ui": "stream"
}

Verify turbo can read the produced turbo.json
Expand Down

0 comments on commit 8df02c6

Please sign in to comment.