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.
This commit is contained in:
Krishna Sai Veera Reddy 2020-02-09 14:12:40 -08:00
parent a3a1587a1c
commit b48b221f80
2 changed files with 12 additions and 12 deletions

View File

@ -14,10 +14,10 @@ macro_rules! option_env_unwrap {
}
fn main() {
let _ = option_env!("HOME").unwrap();
let _ = option_env!("HOME").expect("environment variable HOME isn't set");
let _ = option_env_unwrap!("HOME");
let _ = option_env_unwrap!("HOME", "environment variable HOME isn't set");
let _ = option_env_unwrap_external!("HOME");
let _ = option_env_unwrap_external!("HOME", "environment variable HOME isn't set");
let _ = option_env!("PATH").unwrap();
let _ = option_env!("PATH").expect("environment variable PATH isn't set");
let _ = option_env_unwrap!("PATH");
let _ = option_env_unwrap!("PATH", "environment variable PATH isn't set");
let _ = option_env_unwrap_external!("PATH");
let _ = option_env_unwrap_external!("PATH", "environment variable PATH isn't set");
}

View File

@ -1,7 +1,7 @@
error: this will panic at run-time if the environment variable doesn't exist at compile-time
--> $DIR/option_env_unwrap.rs:17:13
|
LL | let _ = option_env!("HOME").unwrap();
LL | let _ = option_env!("PATH").unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D clippy::option-env-unwrap` implied by `-D warnings`
@ -10,7 +10,7 @@ LL | let _ = option_env!("HOME").unwrap();
error: this will panic at run-time if the environment variable doesn't exist at compile-time
--> $DIR/option_env_unwrap.rs:18:13
|
LL | let _ = option_env!("HOME").expect("environment variable HOME isn't set");
LL | let _ = option_env!("PATH").expect("environment variable PATH isn't set");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= 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
LL | option_env!($env).unwrap()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
...
LL | let _ = option_env_unwrap!("HOME");
LL | let _ = option_env_unwrap!("PATH");
| -------------------------- in this macro invocation
|
= 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
LL | option_env!($env).expect($message)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
LL | let _ = option_env_unwrap!("HOME", "environment variable HOME isn't set");
LL | let _ = option_env_unwrap!("PATH", "environment variable PATH isn't set");
| ----------------------------------------------------------------- in this macro invocation
|
= help: consider using the `env!` macro instead
@ -42,7 +42,7 @@ LL | let _ = option_env_unwrap!("HOME", "environment variable HOME isn't set
error: this will panic at run-time if the environment variable doesn't exist at compile-time
--> $DIR/option_env_unwrap.rs:21:13
|
LL | let _ = option_env_unwrap_external!("HOME");
LL | let _ = option_env_unwrap_external!("PATH");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: consider using the `env!` macro instead
@ -51,7 +51,7 @@ LL | let _ = option_env_unwrap_external!("HOME");
error: this will panic at run-time if the environment variable doesn't exist at compile-time
--> $DIR/option_env_unwrap.rs:22:13
|
LL | let _ = option_env_unwrap_external!("HOME", "environment variable HOME isn't set");
LL | let _ = option_env_unwrap_external!("PATH", "environment variable PATH isn't set");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: consider using the `env!` macro instead