Skip to content

Commit

Permalink
feat(tasks/prettier): add some information for debug no spec calls (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunqing authored Feb 7, 2024
1 parent 0f28dc8 commit 3268d7d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tasks/prettier_conformance/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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(
Expand Down
3 changes: 3 additions & 0 deletions tasks/prettier_conformance/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 3268d7d

Please sign in to comment.