From b1b72a8a4943f9c40e253f243f9b77abf67b3faf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 28 Aug 2024 01:19:29 +0100 Subject: [PATCH] test: add supporting for ignoring spec tests (#25242) You can now specify `"ignore": true` for either the whole file, concrete test, or concrete step. --- tests/specs/mod.rs | 14 +++++++++++++- tests/specs/schema.json | 9 +++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/specs/mod.rs b/tests/specs/mod.rs index 7a3572a942..9565aa71ff 100644 --- a/tests/specs/mod.rs +++ b/tests/specs/mod.rs @@ -56,6 +56,8 @@ struct MultiTestMetaData { pub cwd: Option, #[serde(default)] pub tests: BTreeMap, + #[serde(default)] + pub ignore: bool, } impl MultiTestMetaData { @@ -90,6 +92,9 @@ impl MultiTestMetaData { } } } + if multi_test_meta_data.ignore && !value.contains_key("ignore") { + value.insert("ignore".to_string(), true.into()); + } } let mut collected_tests = Vec::with_capacity(self.tests.len()); @@ -125,6 +130,8 @@ struct MultiStepMetaData { pub repeat: Option, #[serde(default)] pub steps: Vec, + #[serde(default)] + pub ignore: bool, } #[derive(Clone, Deserialize)] @@ -138,6 +145,8 @@ struct SingleTestMetaData { pub repeat: Option, #[serde(flatten)] pub step: StepMetaData, + #[serde(default)] + pub ignore: bool, } impl SingleTestMetaData { @@ -149,6 +158,7 @@ impl SingleTestMetaData { repeat: self.repeat, envs: Default::default(), steps: vec![self.step], + ignore: self.ignore, } } } @@ -236,7 +246,9 @@ fn run_test(test: &CollectedTest) -> TestResult { let diagnostic_logger = Rc::new(RefCell::new(Vec::::new())); let result = TestResult::from_maybe_panic_or_result(AssertUnwindSafe(|| { let metadata = deserialize_value(metadata_value); - if let Some(repeat) = metadata.repeat { + if metadata.ignore { + TestResult::Ignored + } else if let Some(repeat) = metadata.repeat { TestResult::SubTests( (0..repeat) .map(|i| { diff --git a/tests/specs/schema.json b/tests/specs/schema.json index bf57b4826a..8f3953ee44 100644 --- a/tests/specs/schema.json +++ b/tests/specs/schema.json @@ -50,6 +50,9 @@ }, "exitCode": { "type": "integer" + }, + "ignore": { + "type": "boolean" } } }, @@ -77,6 +80,9 @@ "items": { "$ref": "#/definitions/single_test" } + }, + "ignore": { + "type": "boolean" } } }, { @@ -126,6 +132,9 @@ "additionalProperties": { "$ref": "#/definitions/single_or_multi_step_test" } + }, + "ignore": { + "type": "boolean" } } }