Re-apply test_only_suppress_stderr

Fix some obnoxious output during certain tests.
This commit is contained in:
Peter Ammon
2026-05-23 18:20:19 -07:00
parent 068fa42202
commit a2bfd93451
2 changed files with 9 additions and 3 deletions

View File

@@ -2101,7 +2101,7 @@ macro_rules! validate {
fn test_eval_recursion_detection() {
test_init();
// Ensure that we don't crash on infinite self recursion and mutual recursion.
let parser = &mut TestParser::new();
let parser = &mut TestParser::new().suppressing_stderr();
parser.eval(
L!("function recursive ; recursive ; end ; recursive; "),
&IoChain::new(),
@@ -2123,7 +2123,7 @@ fn test_eval_illegal_exit_code() {
let TestParser {
ref mut parser,
ref mut pushed_dirs,
} = TestParser::new();
} = TestParser::new().suppressing_stderr();
macro_rules! validate {
($cmd:expr, $result:expr) => {
parser.eval($cmd, &IoChain::new());
@@ -2149,7 +2149,7 @@ macro_rules! validate {
#[serial]
fn test_eval_empty_function_name() {
test_init();
let parser = &mut TestParser::new();
let parser = &mut TestParser::new().suppressing_stderr();
parser.eval(
L!("function '' ; echo fail; exit 42 ; end ; ''"),
&IoChain::new(),

View File

@@ -103,6 +103,12 @@ pub fn new() -> TestParser {
pushed_dirs: Vec::new(),
}
}
// Mark that we expect noisy errors to be printed and that these should be suppressed.
pub fn suppressing_stderr(mut self) -> TestParser {
self.parser.test_only_suppress_stderr = true;
self
}
}
pub trait ParserExt {