Skip to content

Commit

Permalink
test(oxlint): fix InvalidOptionTsConfig tests for windows (#8791)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Sysix and Sysix authored Jan 31, 2025
1 parent 3e3fbef commit 45648e7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apps/oxlint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
4 changes: 3 additions & 1 deletion apps/oxlint/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::{
time::Instant,
};

use cow_utils::CowUtils;
use ignore::gitignore::Gitignore;
use oxc_diagnostics::{DiagnosticService, GraphicalReportHandler};
use oxc_linter::{
Expand Down Expand Up @@ -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();

Expand Down
11 changes: 5 additions & 6 deletions apps/oxlint/src/tester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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(" ");
Expand All @@ -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);
});
Expand Down

0 comments on commit 45648e7

Please sign in to comment.