Skip to content

Commit ed61974

Browse files
committed
Fix infer_dot_star test
1 parent 65f43b0 commit ed61974

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

tests/cli_tests.rs

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use anyhow::Result;
66
use assert_cmd::prelude::*; // Add methods on commands
77
use predicates::prelude::*; // Used for writing assertions
8+
use std::fs;
89
use std::path::Path;
910
use std::process::Command; // Run programs
1011
// use std::fs::File;
@@ -17,9 +18,9 @@ mod tests {
1718
fn simple_help_print_check() -> Result<()> {
1819
let mut cmd = Command::cargo_bin("morty")?;
1920
cmd.arg("-h");
20-
cmd.assert()
21-
.success()
22-
.stdout(predicate::str::contains("A SystemVerilog source file pickler.\n"));
21+
cmd.assert().success().stdout(predicate::str::contains(
22+
"A SystemVerilog source file pickler.\n",
23+
));
2324

2425
Ok(())
2526
}
@@ -85,23 +86,23 @@ mod tests {
8586

8687
Ok(())
8788
}
88-
}
8989

90-
#[test]
91-
fn test_infer_dot_star() -> Result<(), Box<dyn std::error::Error>> {
92-
let expected_output = fs::read_to_string("test/infer_dot_star/expected/expected.sv")?;
93-
let mut cmd = Command::cargo_bin("morty")?;
94-
cmd.arg("--infer_dot_star")
95-
.arg(Path::new("test/infer_dot_star/top.sv").as_os_str())
96-
.arg(Path::new("test/infer_dot_star/submodule.sv").as_os_str());
97-
let binding = cmd.assert().success();
98-
// we have to do it this complex such that windows tests are passing
99-
// windows has a different output format and injects \r into the output
100-
let output = &binding.get_output().stdout;
101-
let output_str = String::from_utf8(output.clone()).unwrap();
102-
let expected_output_stripped = expected_output.replace(&['\r'][..], "");
103-
let output_str_stripped = output_str.replace(&['\r'][..], "");
104-
let compare_fn = predicate::str::contains(expected_output_stripped);
105-
assert_eq!(compare_fn.eval(&output_str_stripped), true);
106-
Ok(())
90+
#[test]
91+
fn test_infer_dot_star() -> Result<(), Box<dyn std::error::Error>> {
92+
let expected_output = fs::read_to_string("test/infer_dot_star/expected/expected.sv")?;
93+
let mut cmd = Command::cargo_bin("morty")?;
94+
cmd.arg("--infer_dot_star")
95+
.arg(Path::new("test/infer_dot_star/top.sv").as_os_str())
96+
.arg(Path::new("test/infer_dot_star/submodule.sv").as_os_str());
97+
let binding = cmd.assert().success();
98+
// we have to do it this complex such that windows tests are passing
99+
// windows has a different output format and injects \r into the output
100+
let output = &binding.get_output().stdout;
101+
let output_str = String::from_utf8(output.clone()).unwrap();
102+
let expected_output_stripped = expected_output.replace(&['\r'][..], "");
103+
let output_str_stripped = output_str.replace(&['\r'][..], "");
104+
let compare_fn = predicate::str::contains(expected_output_stripped);
105+
assert_eq!(compare_fn.eval(&output_str_stripped), true);
106+
Ok(())
107+
}
107108
}

0 commit comments

Comments
 (0)