test(oxlint): fix InvalidOptionTsConfig tests for windows (#8791)

because of:
https://github.com/oxc-project/oxc/actions/runs/13058657372/job/36435970934
> The tsconfig file "E:\\oxc\\apps\\oxlint\\oxc/tsconfig.json"

now I know the reason why eslint is printing it in POSIX style

---------

Co-authored-by: Sysix <alexander.schlegel@clicksports.de>
This commit is contained in:
Alexander S. 2025-01-31 04:49:00 +01:00 committed by GitHub
parent 3e3fbefecc
commit 45648e794a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 10 additions and 7 deletions

1
Cargo.lock generated
View file

@ -2271,6 +2271,7 @@ name = "oxlint"
version = "0.15.8"
dependencies = [
"bpaf",
"cow-utils",
"ignore",
"insta",
"jemallocator",

View file

@ -36,6 +36,7 @@ oxc_linter = { workspace = true }
oxc_span = { workspace = true }
bpaf = { workspace = true, features = ["autocomplete", "bright-color", "derive"] }
cow-utils = { workspace = true }
ignore = { workspace = true, features = ["simd-accel"] }
miette = { workspace = true }
rayon = { workspace = true }

View file

@ -5,6 +5,7 @@ use std::{
time::Instant,
};
use cow_utils::CowUtils;
use ignore::gitignore::Gitignore;
use oxc_diagnostics::{DiagnosticService, GraphicalReportHandler};
use oxc_linter::{
@ -209,7 +210,8 @@ impl Runner for LintRunner {
} else {
let path = if path.is_relative() { options.cwd().join(path) } else { path.clone() };
stdout.write_all(format!(
"The tsconfig file {path:?} does not exist, Please provide a valid tsconfig file.\n",
"The tsconfig file {:?} does not exist, Please provide a valid tsconfig file.\n",
path.to_string_lossy().cow_replace('\\', "/")
).as_bytes()).or_else(Self::check_for_writer_error).unwrap();
stdout.flush().unwrap();

View file

@ -3,6 +3,8 @@ use crate::cli::{lint_command, LintRunner};
#[cfg(test)]
use crate::runner::Runner;
#[cfg(test)]
use cow_utils::CowUtils;
#[cfg(test)]
use regex::Regex;
#[cfg(test)]
use std::{env, path::PathBuf};
@ -78,10 +80,8 @@ impl Tester {
// do not output the current working directory, each machine has a different one
let cwd_string = current_cwd.to_str().unwrap();
#[allow(clippy::disallowed_methods)]
let cwd_string = cwd_string.replace('\\', "/");
#[allow(clippy::disallowed_methods)]
let output_string = output_string.replace(&cwd_string, "<cwd>");
let cwd_string = cwd_string.cow_replace('\\', "/").to_string(); // for windows
let output_string = output_string.cow_replace(&cwd_string, "<cwd>");
let full_args_list =
multiple_args.iter().map(|args| args.join(" ")).collect::<Vec<String>>().join(" ");
@ -90,8 +90,7 @@ impl Tester {
// windows can not handle filenames with *
// allow replace instead of cow_replace. It only test
#[allow(clippy::disallowed_methods)]
let snapshot_file_name = snapshot_file_name.replace('*', "_");
let snapshot_file_name = snapshot_file_name.cow_replace('*', "_").to_string();
settings.bind(|| {
insta::assert_snapshot!(snapshot_file_name, output_string);
});