refactor: use our forked version of miette::Reporter for tests (#2266)

This commit is contained in:
Boshen 2024-02-02 16:15:31 +08:00 committed by GitHub
parent da2ffdf7a0
commit 650f6c942f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 7592 additions and 7589 deletions

View file

@ -4,8 +4,8 @@ use std::{
};
use oxc_allocator::Allocator;
use oxc_diagnostics::{miette::NamedSource, GraphicalReportHandler};
use oxc_diagnostics::{DiagnosticService, GraphicalTheme};
use oxc_diagnostics::miette::NamedSource;
use oxc_diagnostics::{DiagnosticService, GraphicalReportHandler, GraphicalTheme};
use serde_json::Value;
use crate::{

File diff suppressed because it is too large Load diff

View file

@ -2,13 +2,14 @@ parser_misc Summary:
AST Parsed : 10/10 (100.00%)
Positive Passed: 10/10 (100.00%)
Negative Passed: 6/6 (100.00%)
× Unexpected token
╭─[fail/oxc-169.js:1:1]
1 │ 1<(V=82<<t-j0<(V=$<LBI<(V=ut<I<(V=$<LBI<(V=uIV=82<<t-j0<(V=$<LBI<(V=ut<I<(V=$<LBI<(V<II>
╰────
× Unexpected token
╭─[fail/oxc-1942-1.ts:1:1]
╭─[fail/oxc-1942-1.ts:2:8]
1 │ class Foo {
2 │ get x: () => {
· ─
@ -16,7 +17,7 @@ Negative Passed: 6/6 (100.00%)
╰────
× Unexpected token
╭─[fail/oxc-1942-2.ts:1:1]
╭─[fail/oxc-1942-2.ts:2:8]
1 │ class Foo {
2 │ set x: (v: number) => {}
· ─
@ -24,14 +25,14 @@ Negative Passed: 6/6 (100.00%)
╰────
× Unexpected `?` operator
╭─[fail/oxc-2253.ts:1:1]
╭─[fail/oxc-2253.ts:1:8]
1 │ const a? = "A"
· ▲
2 │ const [b]? = ["B"]
╰────
× Unexpected `?` operator
╭─[fail/oxc-2253.ts:1:1]
╭─[fail/oxc-2253.ts:2:10]
1 │ const a? = "A"
2 │ const [b]? = ["B"]
· ▲
@ -39,7 +40,7 @@ Negative Passed: 6/6 (100.00%)
╰────
× Unexpected `?` operator
╭─[fail/oxc-2253.ts:2:1]
╭─[fail/oxc-2253.ts:3:12]
2 │ const [b]? = ["B"]
3 │ const { c }? = { c: "C" }
· ▲
@ -47,7 +48,7 @@ Negative Passed: 6/6 (100.00%)
╰────
× Unexpected `?` operator
╭─[fail/oxc-2253.ts:4:1]
╭─[fail/oxc-2253.ts:5:13]
4 │
5 │ const d ? = "A"
· ▲
@ -55,7 +56,7 @@ Negative Passed: 6/6 (100.00%)
╰────
× Unexpected `?` operator
╭─[fail/oxc-2253.ts:5:1]
╭─[fail/oxc-2253.ts:6:19]
5 │ const d ? = "A"
6 │ const [e, f] ? = ["B"]
· ▲
@ -63,14 +64,14 @@ Negative Passed: 6/6 (100.00%)
╰────
× Unexpected `?` operator
╭─[fail/oxc-2253.ts:6:1]
╭─[fail/oxc-2253.ts:7:22]
6 │ const [e, f] ? = ["B"]
7 │ const { g, h } ? = { c: "C" }
· ▲
╰────
× Empty parenthesized expression
╭─[fail/oxc-232.js:1:1]
╭─[fail/oxc-232.js:1:5]
1 │ x = (/* a */)
· ─────────
╰────
@ -83,9 +84,8 @@ Negative Passed: 6/6 (100.00%)
╰────
× The keyword 'let' is reserved
╭─[fail/oxc.js:1:1]
╭─[fail/oxc.js:2:1]
1 │ let.a = 1;
2 │ let()[a] = 1;
· ───
╰────

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -12,7 +12,7 @@ use encoding_rs::UTF_16LE;
use encoding_rs_io::DecodeReaderBytesBuilder;
use futures::future::join_all;
use oxc_allocator::Allocator;
use oxc_diagnostics::miette::{GraphicalReportHandler, GraphicalTheme, NamedSource};
use oxc_diagnostics::{miette::NamedSource, GraphicalReportHandler, GraphicalTheme};
use oxc_parser::Parser;
use oxc_semantic::SemanticBuilder;
use oxc_span::SourceType;
@ -331,7 +331,8 @@ pub trait Case: Sized + Sync + Send + UnwindSafe {
let result = if errors.is_empty() {
Ok(String::new())
} else {
let handler = GraphicalReportHandler::new_themed(GraphicalTheme::unicode_nocolor());
let handler =
GraphicalReportHandler::new().with_theme(GraphicalTheme::unicode_nocolor());
let mut output = String::new();
for error in errors {
let error = error.with_source_code(NamedSource::new(
@ -339,7 +340,6 @@ pub trait Case: Sized + Sync + Send + UnwindSafe {
source_text.to_string(),
));
handler.render_report(&mut output, error.as_ref()).unwrap();
output.push('\n');
}
Err(output)
};

View file

@ -6,7 +6,7 @@ use walkdir::WalkDir;
use oxc_allocator::Allocator;
use oxc_codegen::{Codegen, CodegenOptions};
use oxc_diagnostics::miette::{GraphicalReportHandler, GraphicalTheme, NamedSource};
use oxc_diagnostics::{miette::NamedSource, GraphicalReportHandler, GraphicalTheme};
use oxc_parser::Parser;
use oxc_semantic::SemanticBuilder;
use oxc_span::SourceType;
@ -104,7 +104,8 @@ impl TypeScriptFixtures {
let errors = parser_ret.errors.into_iter().chain(semantic_ret.errors).collect::<Vec<_>>();
if !errors.is_empty() {
let handler = GraphicalReportHandler::new_themed(GraphicalTheme::unicode_nocolor());
let handler =
GraphicalReportHandler::new().with_theme(GraphicalTheme::unicode_nocolor());
let mut output = String::new();
for error in errors {
let error = error.with_source_code(NamedSource::new(

View file

@ -1,7 +1,8 @@
# typescript/tests/cases/conformance/enums/awaitAndYield.ts
```error
× `await` is only allowed within async functions and at the top levels of modules
╭─[typescript/tests/cases/conformance/enums/awaitAndYield.ts:4:1]
╭─[typescript/tests/cases/conformance/enums/awaitAndYield.ts:5:15]
4 │ enum E {
5 │ foo = await x,
· ─────
@ -477,8 +478,9 @@ var E = (E => {
# typescript/tests/cases/conformance/enums/enumErrors.ts
```error
× Expected `,` but found `;`
╭─[typescript/tests/cases/conformance/enums/enumErrors.ts:47:1]
╭─[typescript/tests/cases/conformance/enums/enumErrors.ts:48:18]
47 │
48 │ postSemicolon;
· ┬