Skip to content

Commit

Permalink
remove duplicate tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lijunchen committed Jul 9, 2024
1 parent 84b8414 commit 6f94653
Showing 1 changed file with 0 additions and 65 deletions.
65 changes: 0 additions & 65 deletions crates/moonbuild/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,68 +84,3 @@ fn run(command: &str, path: &Path, target_dir: &Path) -> anyhow::Result<TestStat
bail!("Failed to run the test");
}
}

#[test]
fn test_handle_output() {
let out = "abcde
---begin---
text
---end---
fghij";
let expected_out = "abcde
fghij";
let mut capture = SectionCapture::new("---begin---", "---end---", false);
let mut buf = String::new();
let mut captures = [&mut capture];
handle_stdout(
&mut std::io::BufReader::new(out.as_bytes()),
&mut captures,
|line| buf.push_str(line),
)
.unwrap();
assert_eq!(buf, expected_out);
assert_eq!(capture.finish().unwrap(), "text\n");
}

#[test]
fn test_handle_intermixed_output() {
let out = "abcde
blahblah---begin---
text
---end---blahblah
fghij";
let expected_out = "abcde
blahblahblahblah
fghij";
let mut capture = SectionCapture::new("---begin---", "---end---", false);
let mut buf = String::new();
let mut captures = [&mut capture];
handle_stdout(
&mut std::io::BufReader::new(out.as_bytes()),
&mut captures,
|line| buf.push_str(line),
)
.unwrap();
assert_eq!(buf, expected_out);
assert_eq!(capture.finish().unwrap(), "text\n");
}
#[test]
fn test_handle_wrong_output() {
let out = "abcde
blahblah---begin--
text
---end---blahblah
fghij";

let mut capture = SectionCapture::new("---begin---", "---end---", false);
let mut buf = String::new();
let mut captures = [&mut capture];
handle_stdout(
&mut std::io::BufReader::new(out.as_bytes()),
&mut captures,
|line| buf.push_str(line),
)
.unwrap();
assert_eq!(buf, out);
assert!(capture.finish().is_none());
}

0 comments on commit 6f94653

Please sign in to comment.