Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e14cfd6

Browse files
committed
test(linter): fix InvalidOptionTsConfig tests for windows
1 parent 3702288 commit e14cfd6

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/oxlint/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ oxc_linter = { workspace = true }
3636
oxc_span = { workspace = true }
3737

3838
bpaf = { workspace = true, features = ["autocomplete", "bright-color", "derive"] }
39+
cow-utils = { workspace = true }
3940
ignore = { workspace = true, features = ["simd-accel"] }
4041
miette = { workspace = true }
4142
rayon = { workspace = true }

apps/oxlint/src/lint.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::{
55
time::Instant,
66
};
77

8+
use cow_utils::CowUtils;
89
use ignore::gitignore::Gitignore;
910
use oxc_diagnostics::{DiagnosticService, GraphicalReportHandler};
1011
use oxc_linter::{
@@ -209,7 +210,8 @@ impl Runner for LintRunner {
209210
} else {
210211
let path = if path.is_relative() { options.cwd().join(path) } else { path.clone() };
211212
stdout.write_all(format!(
212-
"The tsconfig file {path:?} does not exist, Please provide a valid tsconfig file.\n",
213+
"The tsconfig file {:?} does not exist, Please provide a valid tsconfig file.\n",
214+
path.to_string_lossy().cow_replace('\\', "/")
213215
).as_bytes()).or_else(Self::check_for_writer_error).unwrap();
214216
stdout.flush().unwrap();
215217

apps/oxlint/src/tester.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ use crate::cli::{lint_command, LintRunner};
33
#[cfg(test)]
44
use crate::runner::Runner;
55
#[cfg(test)]
6+
use cow_utils::CowUtils;
7+
#[cfg(test)]
68
use regex::Regex;
79
#[cfg(test)]
810
use std::{env, path::PathBuf};
@@ -78,10 +80,8 @@ impl Tester {
7880

7981
// do not output the current working directory, each machine has a different one
8082
let cwd_string = current_cwd.to_str().unwrap();
81-
#[allow(clippy::disallowed_methods)]
82-
let cwd_string = cwd_string.replace('\\', "/");
83-
#[allow(clippy::disallowed_methods)]
84-
let output_string = output_string.replace(&cwd_string, "<cwd>");
83+
let cwd_string = cwd_string.cow_replace('\\', "/").to_string(); // for windows
84+
let output_string = output_string.cow_replace(&cwd_string, "<cwd>");
8585

8686
let full_args_list =
8787
multiple_args.iter().map(|args| args.join(" ")).collect::<Vec<String>>().join(" ");
@@ -90,8 +90,7 @@ impl Tester {
9090

9191
// windows can not handle filenames with *
9292
// allow replace instead of cow_replace. It only test
93-
#[allow(clippy::disallowed_methods)]
94-
let snapshot_file_name = snapshot_file_name.replace('*', "_");
93+
let snapshot_file_name = snapshot_file_name.cow_replace('*', "_").to_string();
9594
settings.bind(|| {
9695
insta::assert_snapshot!(snapshot_file_name, output_string);
9796
});

0 commit comments

Comments
 (0)