Skip to content

Commit a3ce88b

Browse files
committed
add some tests
1 parent 216371d commit a3ce88b

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/main.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,40 @@ where
181181
Err(exit_status.code().unwrap_or(-1))
182182
}
183183
}
184+
185+
#[cfg(test)]
186+
mod tests {
187+
use super::*;
188+
189+
#[test]
190+
#[should_panic]
191+
fn fix_without_unstable() {
192+
let args = "cargo clippy --fix".split_whitespace().map(ToString::to_string);
193+
let _ = ClippyCmd::new(args);
194+
}
195+
196+
#[test]
197+
fn fix_unstable() {
198+
let args = "cargo clippy --fix -Zunstable-options".split_whitespace().map(ToString::to_string);
199+
let cmd = ClippyCmd::new(args);
200+
assert_eq!("fix", cmd.cmd);
201+
assert_eq!("RUSTC_WORKSPACE_WRAPPER", cmd.path_env());
202+
assert!(cmd.args.iter().find(|arg| arg.ends_with("unstable-options")).is_some());
203+
}
204+
205+
#[test]
206+
fn check() {
207+
let args = "cargo clippy".split_whitespace().map(ToString::to_string);
208+
let cmd = ClippyCmd::new(args);
209+
assert_eq!("check", cmd.cmd);
210+
assert_eq!("RUSTC_WRAPPER", cmd.path_env());
211+
}
212+
213+
#[test]
214+
fn check_unstable() {
215+
let args = "cargo clippy -Zunstable-options".split_whitespace().map(ToString::to_string);
216+
let cmd = ClippyCmd::new(args);
217+
assert_eq!("check", cmd.cmd);
218+
assert_eq!("RUSTC_WORKSPACE_WRAPPER", cmd.path_env());
219+
}
220+
}

0 commit comments

Comments
 (0)