Skip to content

Commit b48b221

Browse files
Use PATH environment variable for testing
The tests were failing on windows because the `HOME` env variable doesn't exist on it so using the `PATH` variable to test instead.
1 parent a3a1587 commit b48b221

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

tests/ui/option_env_unwrap.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ macro_rules! option_env_unwrap {
1414
}
1515

1616
fn main() {
17-
let _ = option_env!("HOME").unwrap();
18-
let _ = option_env!("HOME").expect("environment variable HOME isn't set");
19-
let _ = option_env_unwrap!("HOME");
20-
let _ = option_env_unwrap!("HOME", "environment variable HOME isn't set");
21-
let _ = option_env_unwrap_external!("HOME");
22-
let _ = option_env_unwrap_external!("HOME", "environment variable HOME isn't set");
17+
let _ = option_env!("PATH").unwrap();
18+
let _ = option_env!("PATH").expect("environment variable PATH isn't set");
19+
let _ = option_env_unwrap!("PATH");
20+
let _ = option_env_unwrap!("PATH", "environment variable PATH isn't set");
21+
let _ = option_env_unwrap_external!("PATH");
22+
let _ = option_env_unwrap_external!("PATH", "environment variable PATH isn't set");
2323
}

tests/ui/option_env_unwrap.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
error: this will panic at run-time if the environment variable doesn't exist at compile-time
22
--> $DIR/option_env_unwrap.rs:17:13
33
|
4-
LL | let _ = option_env!("HOME").unwrap();
4+
LL | let _ = option_env!("PATH").unwrap();
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `-D clippy::option-env-unwrap` implied by `-D warnings`
@@ -10,7 +10,7 @@ LL | let _ = option_env!("HOME").unwrap();
1010
error: this will panic at run-time if the environment variable doesn't exist at compile-time
1111
--> $DIR/option_env_unwrap.rs:18:13
1212
|
13-
LL | let _ = option_env!("HOME").expect("environment variable HOME isn't set");
13+
LL | let _ = option_env!("PATH").expect("environment variable PATH isn't set");
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1515
|
1616
= help: consider using the `env!` macro instead
@@ -21,7 +21,7 @@ error: this will panic at run-time if the environment variable doesn't exist at
2121
LL | option_env!($env).unwrap()
2222
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
2323
...
24-
LL | let _ = option_env_unwrap!("HOME");
24+
LL | let _ = option_env_unwrap!("PATH");
2525
| -------------------------- in this macro invocation
2626
|
2727
= help: consider using the `env!` macro instead
@@ -33,7 +33,7 @@ error: this will panic at run-time if the environment variable doesn't exist at
3333
LL | option_env!($env).expect($message)
3434
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3535
...
36-
LL | let _ = option_env_unwrap!("HOME", "environment variable HOME isn't set");
36+
LL | let _ = option_env_unwrap!("PATH", "environment variable PATH isn't set");
3737
| ----------------------------------------------------------------- in this macro invocation
3838
|
3939
= help: consider using the `env!` macro instead
@@ -42,7 +42,7 @@ LL | let _ = option_env_unwrap!("HOME", "environment variable HOME isn't set
4242
error: this will panic at run-time if the environment variable doesn't exist at compile-time
4343
--> $DIR/option_env_unwrap.rs:21:13
4444
|
45-
LL | let _ = option_env_unwrap_external!("HOME");
45+
LL | let _ = option_env_unwrap_external!("PATH");
4646
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4747
|
4848
= help: consider using the `env!` macro instead
@@ -51,7 +51,7 @@ LL | let _ = option_env_unwrap_external!("HOME");
5151
error: this will panic at run-time if the environment variable doesn't exist at compile-time
5252
--> $DIR/option_env_unwrap.rs:22:13
5353
|
54-
LL | let _ = option_env_unwrap_external!("HOME", "environment variable HOME isn't set");
54+
LL | let _ = option_env_unwrap_external!("PATH", "environment variable PATH isn't set");
5555
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5656
|
5757
= help: consider using the `env!` macro instead

0 commit comments

Comments
 (0)