Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove duplicate tests #2

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}