diff --git a/tasks/prettier_conformance/src/lib.rs b/tasks/prettier_conformance/src/lib.rs index bbb2897cdbaac..b7d9188eb4049 100644 --- a/tasks/prettier_conformance/src/lib.rs +++ b/tasks/prettier_conformance/src/lib.rs @@ -157,6 +157,11 @@ impl TestRunner { .collect(); self.spec.parse(&spec_path); + debug_assert!( + !self.spec.calls.is_empty(), + "There is no `runFormatTest()` in {}, please check if it is correct?", + spec_path.to_string_lossy() + ); total += inputs.len(); inputs.sort_unstable(); self.test_snapshot(dir, &spec_path, &inputs, &mut failed); @@ -201,7 +206,7 @@ impl TestRunner { expected.contains(&snapshot) }); - if !result { + if self.spec.calls.is_empty() || !result { let mut dir_info = String::new(); if write_dir_info { dir_info.push_str( diff --git a/tasks/prettier_conformance/src/spec.rs b/tasks/prettier_conformance/src/spec.rs index b201c5728bb08..ccc9065993628 100644 --- a/tasks/prettier_conformance/src/spec.rs +++ b/tasks/prettier_conformance/src/spec.rs @@ -32,6 +32,9 @@ impl SpecParser { impl VisitMut<'_> for SpecParser { fn visit_call_expression(&mut self, expr: &mut CallExpression<'_>) { let Some(ident) = expr.callee.get_identifier_reference() else { return }; + // The `runFormatTest` function used on prettier's test cases. We need to collect all `run_spec` calls + // And then parse the arguments to get the options and parsers + // Finally we use this information to generate the snapshot tests if ident.name != "runFormatTest" { return; }