Skip to content

Commit 0149a7e

Browse files
committed
test(linter): set CWD for tests
1 parent b794af1 commit 0149a7e

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

apps/oxlint/src/lint.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -903,10 +903,12 @@ mod test {
903903
#[test]
904904
fn test_tsconfig_option() {
905905
// passed
906-
Tester::new().test(&["--tsconfig", "fixtures/tsconfig/tsconfig.json"]);
906+
Tester::new().with_cwd("fixtures".into()).test(&["--tsconfig", "tsconfig/tsconfig.json"]);
907907

908908
// failed
909-
Tester::new().test_and_snapshot(&["--tsconfig", "oxc/tsconfig.json"]);
909+
Tester::new()
910+
.with_cwd("fixtures".into())
911+
.test_and_snapshot(&["--tsconfig", "oxc/tsconfig.json"]);
910912
}
911913

912914
#[test]
@@ -953,7 +955,7 @@ mod test {
953955
#[test]
954956
fn test_print_config_ban_all_rules() {
955957
let args = &["-A", "all", "--print-config"];
956-
Tester::new().test_and_snapshot(args);
958+
Tester::new().with_cwd("fixtures".into()).test_and_snapshot(args);
957959
}
958960

959961
#[test]
@@ -975,7 +977,7 @@ mod test {
975977
assert!(!fs::exists(LintRunner::DEFAULT_OXLINTRC).unwrap());
976978

977979
let args = &["--init"];
978-
Tester::new().test(args);
980+
Tester::new().with_cwd("fixtures".into()).test(args);
979981

980982
assert!(fs::exists(LintRunner::DEFAULT_OXLINTRC).unwrap());
981983

apps/oxlint/src/snapshots/_--tsconfig oxc__tsconfig.json@oxlint.snap renamed to apps/oxlint/src/snapshots/fixtures_--tsconfig oxc__tsconfig.json@oxlint.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ source: apps/oxlint/src/tester.rs
33
---
44
##########
55
arguments: --tsconfig oxc/tsconfig.json
6-
working directory:
6+
working directory: fixtures
77
----------
8-
The tsconfig file "<cwd>/oxc/tsconfig.json" does not exist, Please provide a valid tsconfig file.
8+
The tsconfig file "<cwd>/fixtures/oxc/tsconfig.json" does not exist, Please provide a valid tsconfig file.
99
----------
1010
CLI result: InvalidOptionTsConfig
1111
----------

apps/oxlint/src/snapshots/_-A all --print-config@oxlint.snap renamed to apps/oxlint/src/snapshots/fixtures_-A all --print-config@oxlint.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ source: apps/oxlint/src/tester.rs
33
---
44
##########
55
arguments: -A all --print-config
6-
working directory:
6+
working directory: fixtures
77
----------
88
{
99
"plugins": [

0 commit comments

Comments
 (0)