From daeb5067044befb21155414acccc6d4064d2d4b9 Mon Sep 17 00:00:00 2001 From: owjs3901 Date: Wed, 30 Sep 2026 15:39:41 +0900 Subject: [PATCH] test: serialize every test touching global theme, class and file state Tests writing the process-global theme tokens, class map, prefix or shorthands ran unserialized next to #[serial] tests reading them, which made test_conditional_typography_pipeline flaky. Refs #683. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- libs/css/src/lib.rs | 1 + libs/css/src/theme_tokens.rs | 4 ++ .../src/extract_style/extract_style_value.rs | 2 + libs/extractor/src/gen_style.rs | 4 ++ libs/extractor/tests/vanilla_extract.rs | 4 ++ libs/sheet/src/lib.rs | 42 +++++++++++++++++++ 6 files changed, 57 insertions(+) diff --git a/libs/css/src/lib.rs b/libs/css/src/lib.rs index bdd33131e..576ba53b9 100644 --- a/libs/css/src/lib.rs +++ b/libs/css/src/lib.rs @@ -1343,6 +1343,7 @@ mod tests { } #[test] + #[serial] fn test_disassemble_property_size_hint() { // Mapped arm: the hint comes straight from the borrowed slice iterator. let mapped = disassemble_property("bg"); diff --git a/libs/css/src/theme_tokens.rs b/libs/css/src/theme_tokens.rs index d98859d87..d8d8fb021 100644 --- a/libs/css/src/theme_tokens.rs +++ b/libs/css/src/theme_tokens.rs @@ -78,8 +78,10 @@ pub fn is_responsive_theme_token(value: &str) -> bool { #[cfg(test)] mod tests { use super::*; + use serial_test::serial; #[test] + #[serial] fn test_get_responsive_theme_token() { let mut length = BTreeMap::new(); length.insert("containerX".to_string(), vec![0, 2]); @@ -94,6 +96,7 @@ mod tests { } #[test] + #[serial] fn test_is_responsive_theme_token() { let mut length = BTreeMap::new(); length.insert("containerX".to_string(), vec![0, 2]); @@ -111,6 +114,7 @@ mod tests { } #[test] + #[serial] fn test_typography_keys() { set_typography_keys(vec!["body".to_string(), "title".to_string()]); assert_eq!(get_typography_keys(), vec!["body", "title"]); diff --git a/libs/extractor/src/extract_style/extract_style_value.rs b/libs/extractor/src/extract_style/extract_style_value.rs index 86dab6156..588057752 100644 --- a/libs/extractor/src/extract_style/extract_style_value.rs +++ b/libs/extractor/src/extract_style/extract_style_value.rs @@ -50,6 +50,7 @@ impl ExtractStyleValue { #[cfg(test)] mod tests { use super::*; + use serial_test::serial; #[test] fn test_style_order() { @@ -67,6 +68,7 @@ mod tests { } } #[test] + #[serial] fn test_extract() { let style = ExtractStaticStyle::new("margin", "10px", 0, None); let value = ExtractStyleValue::Static(style); diff --git a/libs/extractor/src/gen_style.rs b/libs/extractor/src/gen_style.rs index e054df3c1..85b2f086d 100644 --- a/libs/extractor/src/gen_style.rs +++ b/libs/extractor/src/gen_style.rs @@ -333,6 +333,7 @@ mod tests { }; use crate::utils::expression_to_code; use oxc_allocator::Allocator; + use serial_test::serial; fn dynamic_style<'a>(property: &str, identifier: &str) -> ExtractStyleProp<'a> { ExtractStyleProp::Static(ExtractStyleValue::Dynamic(ExtractDynamicStyle::new( @@ -341,6 +342,7 @@ mod tests { } #[test] + #[serial] fn test_gen_styles_for_alternate_only_conditional() { let allocator = Allocator::default(); let builder = AstBuilder::new(&allocator); @@ -357,6 +359,7 @@ mod tests { } #[test] + #[serial] fn test_gen_styles_for_dynamic_member_expression() { let allocator = Allocator::default(); let builder = AstBuilder::new(&allocator); @@ -383,6 +386,7 @@ mod tests { } #[test] + #[serial] fn test_gen_styles_for_conditional_with_distinct_properties() { let allocator = Allocator::default(); let builder = AstBuilder::new(&allocator); diff --git a/libs/extractor/tests/vanilla_extract.rs b/libs/extractor/tests/vanilla_extract.rs index 3048c162b..a3c938b86 100644 --- a/libs/extractor/tests/vanilla_extract.rs +++ b/libs/extractor/tests/vanilla_extract.rs @@ -3,6 +3,7 @@ use std::collections::HashMap; use extractor::{ExtractOption, extract}; +use serial_test::serial; fn extract_stylesheet(code: &str) -> String { let output = extract( @@ -23,6 +24,7 @@ fn extract_stylesheet(code: &str) -> String { // The library build other targets link is a separate copy from the unit-test // build; these run every vanilla-extract API through it. #[test] +#[serial] fn font_faces_extract_through_the_library() { let output = extract_stylesheet( r"const body = fontFace({ src: 'local(a)' }, 'Body') @@ -38,6 +40,7 @@ export const text = style({ fontFamily: body, content: icons })", } #[test] +#[serial] fn an_unreadable_var_declaration_is_reported() { let code = "import { createVar } from '@devup-ui/react'\nexport const v = createVar({ syntax: Symbol() })"; let error = extract( @@ -58,6 +61,7 @@ fn an_unreadable_var_declaration_is_reported() { } #[test] +#[serial] fn vars_themes_and_layers_extract_through_the_library() { let output = extract_stylesheet( r"const plain = createVar() diff --git a/libs/sheet/src/lib.rs b/libs/sheet/src/lib.rs index 511b4af2a..0866be5e9 100644 --- a/libs/sheet/src/lib.rs +++ b/libs/sheet/src/lib.rs @@ -1388,6 +1388,7 @@ mod tests { use serial_test::serial; #[rstest] + #[serial] #[case("1px", "1px")] #[case("$var", "var(--var)")] #[case("$var $var", "var(--var) var(--var)")] @@ -1405,6 +1406,7 @@ mod tests { } #[test] + #[serial] fn test_create_css_sort_test() { let mut sheet = StyleSheet::default(); sheet.add_property("test", "background-color", 1, "red", None, None, None); @@ -1638,6 +1640,7 @@ mod tests { // client compilations) registers the SAME @font-face under multiple file // keys. The emitted CSS must contain each distinct @font-face only ONCE. #[test] + #[serial] fn font_faces_deduplicated_across_file_keys() { let props = BTreeMap::from([ ("font-family".to_string(), "Roboto".to_string()), @@ -1658,6 +1661,7 @@ mod tests { // extraction (HMR). It must also drop the file's @import rules, otherwise an // @import removed from source lingers until restart. #[test] + #[serial] fn rm_global_css_clears_imports() { let mut sheet = StyleSheet::default(); sheet.add_import("a.tsx", "\"https://example.com/stale.css\""); @@ -1670,6 +1674,7 @@ mod tests { ); } #[test] + #[serial] fn test_create_css_with_selector_sort_test() { let mut sheet = StyleSheet::default(); sheet.add_property( @@ -1703,6 +1708,7 @@ mod tests { assert_debug_snapshot!(sheet.create_css(None, false).split("*/").nth(1).unwrap()); } #[test] + #[serial] fn test_create_css_with_basic_sort_test() { let mut sheet = StyleSheet::default(); sheet.add_property("test", "background-color", 1, "red", None, Some(0), None); @@ -1721,6 +1727,7 @@ mod tests { } #[test] + #[serial] fn test_create_css_with_selector_and_basic_sort_test() { let mut sheet = StyleSheet::default(); sheet.add_property( @@ -1743,6 +1750,7 @@ mod tests { } #[test] + #[serial] fn test_import_css() { let sheet = StyleSheet::default(); assert_debug_snapshot!( @@ -1755,6 +1763,7 @@ mod tests { } #[test] + #[serial] fn test_create_css() { let mut sheet = StyleSheet::default(); sheet.add_property("test", "margin", 1, "40px", None, None, None); @@ -1914,6 +1923,7 @@ mod tests { } #[test] + #[serial] fn test_reset_global_css() { let mut sheet = StyleSheet::default(); sheet.add_css("test.tsx", "div {display:flex;}"); @@ -1930,6 +1940,7 @@ mod tests { } #[test] + #[serial] fn test_style_order_create_css() { let mut sheet = StyleSheet::default(); sheet.add_property("test", "margin-left", 0, "40px", None, Some(1), None); @@ -1958,6 +1969,7 @@ mod tests { } #[test] + #[serial] fn wrong_breakpoint() { let mut sheet = StyleSheet::default(); sheet.add_property("test", "margin-left", 10, "40px", None, None, None); @@ -1966,6 +1978,7 @@ mod tests { } #[test] + #[serial] fn test_selector_with_prefix() { let mut sheet = StyleSheet::default(); sheet.add_property( @@ -2008,6 +2021,7 @@ mod tests { } #[test] + #[serial] fn test_theme_selector() { let mut sheet = StyleSheet::default(); sheet.add_property( @@ -2150,6 +2164,7 @@ mod tests { } #[test] + #[serial] fn test_print_selector() { let mut sheet = StyleSheet::default(); sheet.add_property( @@ -2253,6 +2268,7 @@ mod tests { } #[test] + #[serial] fn test_screen_selector() { let mut sheet = StyleSheet::default(); sheet.add_property( @@ -2269,6 +2285,7 @@ mod tests { } #[test] + #[serial] fn test_motion_reduce_selector() { let mut sheet = StyleSheet::default(); sheet.add_property( @@ -2285,6 +2302,7 @@ mod tests { } #[test] + #[serial] fn test_all_media_selector() { let mut sheet = StyleSheet::default(); sheet.add_property( @@ -2301,6 +2319,7 @@ mod tests { } #[test] + #[serial] fn test_selector_with_query() { let mut sheet = StyleSheet::default(); sheet.add_property( @@ -2338,6 +2357,7 @@ mod tests { } #[test] + #[serial] fn test_selector_with_supports() { let mut sheet = StyleSheet::default(); sheet.add_property( @@ -2360,6 +2380,7 @@ mod tests { } #[test] + #[serial] fn test_selector_with_container() { let mut sheet = StyleSheet::default(); sheet.add_property( @@ -2382,6 +2403,7 @@ mod tests { } #[test] + #[serial] fn test_deserialize() { { let sheet: StyleSheet = serde_json::from_str( @@ -2456,6 +2478,7 @@ mod tests { } #[test] + #[serial] fn test_create_css_with_global_selector() { let mut sheet = StyleSheet::default(); sheet.add_property( @@ -2631,6 +2654,7 @@ mod tests { } #[test] + #[serial] fn test_create_css_with_imports() { { let mut sheet = StyleSheet::default(); @@ -2661,6 +2685,7 @@ mod tests { } #[test] + #[serial] fn test_get_theme_interface() { let sheet = StyleSheet::default(); assert_eq!( @@ -2803,6 +2828,7 @@ mod tests { } #[test] + #[serial] fn test_keyframes() { let mut sheet = StyleSheet::default(); let mut keyframes: BTreeMap> = BTreeMap::new(); @@ -2840,6 +2866,7 @@ mod tests { } #[test] + #[serial] fn test_font_face() { let mut sheet = StyleSheet::default(); let mut font_face_props = BTreeMap::new(); @@ -2883,6 +2910,7 @@ mod tests { } #[test] + #[serial] fn test_update_styles_with_typography() { use extractor::extract_style::extract_style_value::ExtractStyleValue; @@ -2896,6 +2924,7 @@ mod tests { } #[test] + #[serial] fn test_global_styles_with_custom_layer() { let mut sheet = StyleSheet::default(); // Add global style with layer @@ -2948,6 +2977,7 @@ mod tests { } #[test] + #[serial] fn test_custom_layer_keeps_selector_order() { let mut sheet = StyleSheet::default(); for (selector, value) in [("a:active", "blue"), ("a:hover", "red"), ("a", "black")] { @@ -2973,6 +3003,7 @@ mod tests { } #[test] + #[serial] fn test_at_rules_with_breakpoints() { let mut sheet = StyleSheet::default(); // Add @supports with breakpoint (level 1) @@ -2998,6 +3029,7 @@ mod tests { } #[test] + #[serial] fn test_container_with_breakpoints() { let mut sheet = StyleSheet::default(); // Add @container with breakpoint (level 1) @@ -3023,6 +3055,7 @@ mod tests { } #[test] + #[serial] fn test_theme_layer_in_css() { let mut sheet = StyleSheet::default(); let mut theme = Theme::default(); @@ -3041,6 +3074,7 @@ mod tests { } #[test] + #[serial] fn test_layer_with_breakpoints() { let mut sheet = StyleSheet::default(); // Add @layer with breakpoint (level 1) @@ -3066,6 +3100,7 @@ mod tests { } #[test] + #[serial] fn test_stylesheet_css_struct() { let css_entry = StyleSheetCss { css: "div{display:flex}".to_string(), @@ -3077,6 +3112,7 @@ mod tests { } #[test] + #[serial] fn test_stylesheet_property_ord_no_selectors() { // Both sides without selectors: branches on property then value. let make = |property: &str, value: &str| StyleSheetProperty { @@ -3094,6 +3130,7 @@ mod tests { } #[test] + #[serial] fn test_stylesheet_property_ord_with_selectors() { let make = |selector: Option, property: &str, value: &str| StyleSheetProperty { @@ -3120,6 +3157,7 @@ mod tests { } #[test] + #[serial] fn test_global_selector_group() { assert_eq!(global_selector_group("body"), (false, 0)); assert_eq!(global_selector_group("a:hover"), (true, 0)); @@ -3128,6 +3166,7 @@ mod tests { } #[test] + #[serial] fn test_existing_collection_buckets_are_reused() { let mut sheet = StyleSheet::default(); assert!(sheet.add_property("a", "color", 0, "red", None, None, Some("test.tsx"))); @@ -3151,6 +3190,7 @@ mod tests { } #[test] + #[serial] fn test_compute_hoisted_atoms_skips_base_style_order() { let mut sheet = StyleSheet::default(); sheet.add_property("base", "color", 0, "red", None, Some(0), Some("test.tsx")); @@ -3159,6 +3199,7 @@ mod tests { } #[test] + #[serial] fn test_keyframes_multi_property() { let mut sheet = StyleSheet::default(); let mut keyframes: BTreeMap> = BTreeMap::new(); @@ -3270,6 +3311,7 @@ mod tests { } #[test] + #[serial] fn test_important_in_css_via_add_property() { // Verify that !important in the value is preserved in the final CSS output let mut sheet = StyleSheet::default();