fix(es/transforms/testing): Fix test_fixture (#2400)

swc_ecma_transforms_testing:
 - Make logic depends on `NormalizedOutput::compare_to_file`.
This commit is contained in:
Donny/강동윤 2021-10-11 14:03:57 +09:00 committed by GitHub
parent d7f570ff7c
commit f5607891e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 23 deletions

2
Cargo.lock generated
View File

@ -2932,7 +2932,7 @@ dependencies = [
[[package]]
name = "swc_ecma_transforms_testing"
version = "0.38.0"
version = "0.38.1"
dependencies = [
"ansi_term 0.12.1",
"anyhow",

View File

@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_transforms_testing"
repository = "https://github.com/swc-project/swc.git"
version = "0.38.0"
version = "0.38.1"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -26,7 +26,7 @@ use swc_ecma_transforms_base::{
use swc_ecma_utils::{quote_ident, quote_str, DropSpan, ExprFactory, HANDLER};
use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, FoldWith, VisitMut, VisitMutWith};
use tempfile::tempdir_in;
use testing::{assert_eq, find_executable, DebugUsingDisplay, NormalizedOutput};
use testing::{assert_eq, find_executable, NormalizedOutput};
pub struct Tester<'a> {
pub cm: Lrc<SourceMap>,
@ -698,8 +698,6 @@ fn test_fixture_inner<P>(
Ok(actual_src)
});
let mut results = vec![];
if allow_error {
NormalizedOutput::from(stderr)
.compare_to_file(output.with_extension("stderr"))
@ -719,25 +717,10 @@ fn test_fixture_inner<P>(
return;
}
if let Ok("1") = env::var("UPDATE").as_deref() {
results.push(NormalizedOutput::from(actual_src.clone()).compare_to_file(output));
}
if NormalizedOutput::from(actual_src.clone())
== NormalizedOutput::from(expected_src.clone())
{
return;
}
assert_eq!(
DebugUsingDisplay(&actual_src),
DebugUsingDisplay(&expected_src)
);
NormalizedOutput::from(actual_src.clone())
.compare_to_file(output)
.unwrap();
}
_ => {}
}
for result in results {
result.unwrap();
}
}