diff options
| author | Jane Lusby <jlusby@yaah.dev> | 2020-04-15 09:20:41 -0700 |
|---|---|---|
| committer | Jane Lusby <jlusby@yaah.dev> | 2020-04-15 09:20:41 -0700 |
| commit | a3ce88b4d71ebee0a4aa991420906ec5c5edf0ad (patch) | |
| tree | af79dbaf92bbe58eccd5213254a2dbd4a47884c8 | |
| parent | 216371d42412192ebee5bb94106b40d5ad77fc70 (diff) | |
| download | rust-a3ce88b4d71ebee0a4aa991420906ec5c5edf0ad.tar.gz rust-a3ce88b4d71ebee0a4aa991420906ec5c5edf0ad.zip | |
add some tests
| -rw-r--r-- | src/main.rs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index 6a06ef7437c..3e29c02e4b2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -181,3 +181,40 @@ where Err(exit_status.code().unwrap_or(-1)) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + #[should_panic] + fn fix_without_unstable() { + let args = "cargo clippy --fix".split_whitespace().map(ToString::to_string); + let _ = ClippyCmd::new(args); + } + + #[test] + fn fix_unstable() { + let args = "cargo clippy --fix -Zunstable-options".split_whitespace().map(ToString::to_string); + let cmd = ClippyCmd::new(args); + assert_eq!("fix", cmd.cmd); + assert_eq!("RUSTC_WORKSPACE_WRAPPER", cmd.path_env()); + assert!(cmd.args.iter().find(|arg| arg.ends_with("unstable-options")).is_some()); + } + + #[test] + fn check() { + let args = "cargo clippy".split_whitespace().map(ToString::to_string); + let cmd = ClippyCmd::new(args); + assert_eq!("check", cmd.cmd); + assert_eq!("RUSTC_WRAPPER", cmd.path_env()); + } + + #[test] + fn check_unstable() { + let args = "cargo clippy -Zunstable-options".split_whitespace().map(ToString::to_string); + let cmd = ClippyCmd::new(args); + assert_eq!("check", cmd.cmd); + assert_eq!("RUSTC_WORKSPACE_WRAPPER", cmd.path_env()); + } +} |
