Skip to content

Commit

Permalink
fix(tasks/transform-conformance) when the output file does not exist,…
Browse files Browse the repository at this point in the history
… the output content should be empty (oxc-project#2808)

oxc-project#2795 (comment)
  • Loading branch information
Dunqing authored and charnog committed Mar 26, 2024
1 parent 2eb2e24 commit 3e595dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
6 changes: 4 additions & 2 deletions tasks/transform_conformance/babel.snap.md
@@ -1,7 +1,6 @@
Passed: 352/1369
Passed: 351/1369

# All Passed:
* babel-plugin-transform-numeric-separator
* babel-plugin-transform-optional-catch-binding
* babel-plugin-transform-json-strings
* babel-plugin-transform-shorthand-properties
Expand Down Expand Up @@ -515,6 +514,9 @@ Passed: 352/1369
# babel-plugin-transform-logical-assignment-operators (5/6)
* logical-assignment/null-coalescing/input.js

# babel-plugin-transform-numeric-separator (1/2)
* used-with-transform-es2015-literals/input.js

# babel-plugin-transform-export-namespace-from (0/4)
* export-namespace/namespace-default/input.mjs
* export-namespace/namespace-es6/input.mjs
Expand Down
9 changes: 3 additions & 6 deletions tasks/transform_conformance/src/test_case.rs
Expand Up @@ -268,11 +268,7 @@ impl TestCase for ConformanceTestCase {
if let Some(throws) = &babel_options.throws {
return throws.to_string();
}
// The transformation should be equal to input.js If output.js does not exist.
let program = Parser::new(&allocator, &input, source_type).parse().program;
Codegen::<false>::new("", &input, codegen_options.clone())
.build(&program)
.source_text
String::default()
},
|output| {
// Get expected code by parsing the source text, so we can get the same code generated result.
Expand All @@ -283,7 +279,8 @@ impl TestCase for ConformanceTestCase {
},
);

let passed = transformed_code == output || actual_errors.contains(&output);
let passed =
transformed_code == output || (!output.is_empty() && actual_errors.contains(&output));
if filtered {
println!("Input:\n");
println!("{input}\n");
Expand Down

0 comments on commit 3e595dd

Please sign in to comment.