Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ fn main() {
let exit_code = match n2::run::run() {
Ok(code) => code,
Err(err) => {
println!("n2: error: {}", err);
eprintln!("n2: error: {}", err);
1
}
};
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ build out: my_rule
)?;

let out = space.run(&mut n2_command(vec!["out"]))?;
assert_output_contains(&out, "unexpected variable \"my_var\"");
assert_stderr_contains(&out, "unexpected variable \"my_var\"");
Ok(())
}

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/missing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn missing_input() -> anyhow::Result<()> {
)?;

let out = space.run(&mut n2_command(vec!["out"]))?;
assert_output_contains(&out, "input in missing");
assert_stderr_contains(&out, "input in missing");

Ok(())
}
Expand Down
10 changes: 10 additions & 0 deletions tests/e2e/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ pub fn assert_output_contains(out: &std::process::Output, text: &str) {
}
}

pub fn assert_stderr_contains(out: &std::process::Output, text: &str) {
let out = std::str::from_utf8(&out.stderr).unwrap();
if !out.contains(text) {
panic!(
"assertion failed; expected stderr to contain {:?} but got:\n{}",
text, out
);
}
}

pub fn assert_output_not_contains(out: &std::process::Output, text: &str) {
let out = std::str::from_utf8(&out.stdout).unwrap();
if out.contains(text) {
Expand Down
Loading