oxc/tasks/prettier_conformance/src/main.rs
Yuji Sugiura 8e3eed7562
refactor(prettier): Update tasks/prettier to correctly handle snapshots (#8337)
I refactored the code in `tasks/prettier_conformance` primarily to make
the output more readable when using `--filter`.

But I also discovered that our previous implementation did not correctly
handle Prettier's behavior of adding a blank line at the EOF.

In addition, I resolved a problem where test specs that used patterns
like `runFormatTest(_, parsers)` were unable to locate the correct
snapshot output.

As a result, compatibility has also improved slightly. 😉

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-01-08 17:10:30 +08:00

24 lines
882 B
Rust

use pico_args::Arguments;
use oxc_prettier_conformance::{
options::{TestLanguage, TestRunnerOptions},
TestRunner,
};
/// This CLI runs in 2 modes:
/// - `cargo run`: Run all tests and generate coverage reports
/// - `cargo run -- --filter <filter>`: Debug a specific test, not generating coverage reports
fn main() {
let mut args = Arguments::from_env();
let filter = args.opt_value_from_str("--filter").unwrap();
TestRunner::new(TestRunnerOptions { filter: filter.clone(), language: TestLanguage::Js }).run();
TestRunner::new(TestRunnerOptions { filter: filter.clone(), language: TestLanguage::Ts }).run();
}
#[test]
#[cfg(any(coverage, coverage_nightly))]
fn test() {
TestRunner::new(TestRunnerOptions { filter: None, language: TestLanguage::Js }).run();
TestRunner::new(TestRunnerOptions { filter: None, language: TestLanguage::Ts }).run();
}