5e1f8a8480
## Proposed Changes Lots of lint updates related to `flat_map`, `unwrap_or_else` and string patterns. I did a little more creative refactoring in the op pool, but otherwise followed Clippy's suggestions. ## Additional Info We need this PR to unblock CI.
52 lines
1.4 KiB
Rust
52 lines
1.4 KiB
Rust
use std::env;
|
|
use std::process::Command;
|
|
use std::process::Output;
|
|
|
|
fn run_cmd(cmd_line: &str) -> Result<Output, std::io::Error> {
|
|
if cfg!(target_os = "windows") {
|
|
Command::new(r#"cmd"#).args(["/C", cmd_line]).output()
|
|
} else {
|
|
Command::new(r#"sh"#).args(["-c", cmd_line]).output()
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn test_test_logger_with_feature_test_logger() {
|
|
let cur_dir = env::current_dir().unwrap();
|
|
let test_dir = cur_dir
|
|
.join("..")
|
|
.join("..")
|
|
.join("testing")
|
|
.join("test-test_logger");
|
|
let cmd_line = format!(
|
|
"cd {} && cargo test --features logging/test_logger",
|
|
test_dir.to_str().unwrap()
|
|
);
|
|
|
|
let output = run_cmd(&cmd_line);
|
|
|
|
// Assert output data DOES contain "INFO hi, "
|
|
let data = String::from_utf8(output.unwrap().stderr).unwrap();
|
|
println!("data={}", data);
|
|
assert!(data.contains("INFO hi, "));
|
|
}
|
|
|
|
#[test]
|
|
fn test_test_logger_no_features() {
|
|
// Test without features
|
|
let cur_dir = env::current_dir().unwrap();
|
|
let test_dir = cur_dir
|
|
.join("..")
|
|
.join("..")
|
|
.join("testing")
|
|
.join("test-test_logger");
|
|
let cmd_line = format!("cd {} && cargo test", test_dir.to_str().unwrap());
|
|
|
|
let output = run_cmd(&cmd_line);
|
|
|
|
// Assert output data DOES contain "INFO hi, "
|
|
let data = String::from_utf8(output.unwrap().stderr).unwrap();
|
|
println!("data={}", data);
|
|
assert!(!data.contains("INFO hi, "));
|
|
}
|