Skip to content

Commit 8480f32

Browse files
committed
add buildtests for ProcessLinesActions
1 parent 7cf655c commit 8480f32

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
fn main() {
22
println!("Hello, world!");
3+
println!("Hello, world again!");
34
}

tests/buildtest/mod.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use failure::Error;
22
use log::LevelFilter;
3-
use rustwide::cmd::SandboxBuilder;
3+
use rustwide::cmd::{ProcessLinesActions, SandboxBuilder};
44

55
#[macro_use]
66
mod runner;
@@ -17,6 +17,9 @@ fn test_hello_world() {
1717
})?;
1818

1919
assert!(storage.to_string().contains("[stdout] Hello, world!\n"));
20+
assert!(storage
21+
.to_string()
22+
.contains("[stdout] Hello, world again!\n"));
2023
Ok(())
2124
})?;
2225
Ok(())
@@ -32,9 +35,12 @@ fn test_process_lines() {
3235
rustwide::logging::capture(&storage, || -> Result<_, Error> {
3336
build
3437
.cargo()
35-
.process_lines(&mut |line: &str| {
36-
if line.contains("Hello, world!") {
38+
.process_lines(&mut |line: &str, actions: &mut ProcessLinesActions| {
39+
if line.contains("Hello, world again!") {
3740
ex = true;
41+
actions.replace_with_lines(line.split(","));
42+
} else if line.contains("Hello, world!") {
43+
actions.remove_line();
3844
}
3945
})
4046
.args(&["run"])
@@ -43,6 +49,9 @@ fn test_process_lines() {
4349
})?;
4450

4551
assert!(ex);
52+
assert!(!storage.to_string().contains("[stdout] Hello, world!\n"));
53+
assert!(storage.to_string().contains("[stdout] world again!\n"));
54+
assert!(storage.to_string().contains("[stdout] Hello\n"));
4655
Ok(())
4756
})?;
4857
Ok(())

0 commit comments

Comments
 (0)