Remove principal_parser() from yet more of the tests

This commit is contained in:
Peter Ammon
2024-06-19 17:13:13 -07:00
parent 077f439283
commit 0d7e8c22a6
4 changed files with 12 additions and 12 deletions

View File

@@ -4,7 +4,7 @@
use crate::tests::prelude::*;
fn run_one_test_test_mbracket(expected: i32, lst: &[&str], bracket: bool) -> bool {
let parser = Parser::principal_parser();
let parser = TestParser::new();
let mut argv = Vec::new();
if bracket {
argv.push(L!("[").to_owned());
@@ -25,7 +25,7 @@ fn run_one_test_test_mbracket(expected: i32, lst: &[&str], bracket: bool) -> boo
let io_chain = IoChain::new();
let mut streams = IoStreams::new(&mut out, &mut err, &io_chain);
let result: Option<i32> = builtin_test(parser, &mut streams, &mut argv);
let result: Option<i32> = builtin_test(&parser, &mut streams, &mut argv);
if result != Some(expected) {
let got = match result {
@@ -49,7 +49,7 @@ fn run_test_test(expected: i32, lst: &[&str]) -> bool {
fn test_test_brackets() {
// Ensure [ knows it needs a ].
let parser = Parser::principal_parser();
let parser = TestParser::new();
let mut out = OutputStream::Null;
let mut err = OutputStream::Null;
@@ -58,16 +58,16 @@ fn test_test_brackets() {
let args1 = &mut [L!("["), L!("foo")];
assert_eq!(
builtin_test(parser, &mut streams, args1),
builtin_test(&parser, &mut streams, args1),
STATUS_INVALID_ARGS
);
let args2 = &mut [L!("["), L!("foo"), L!("]")];
assert_eq!(builtin_test(parser, &mut streams, args2), STATUS_CMD_OK);
assert_eq!(builtin_test(&parser, &mut streams, args2), STATUS_CMD_OK);
let args3 = &mut [L!("["), L!("foo"), L!("]"), L!("bar")];
assert_eq!(
builtin_test(parser, &mut streams, args3),
builtin_test(&parser, &mut streams, args3),
STATUS_INVALID_ARGS
);
}

View File

@@ -6,7 +6,6 @@
use crate::common::ScopeGuard;
use crate::global_safety::RelaxedAtomicBool;
use crate::parser::Parser;
use crate::reader::{reader_pop, reader_push, Reader, ReaderConfig};
use crate::tests::prelude::*;
use crate::threads::{iothread_drain_all, iothread_service_main, Debounce};
@@ -16,6 +15,7 @@
#[serial]
fn test_debounce() {
let _cleanup = test_init();
let parser = TestParser::new();
// Run 8 functions using a condition variable.
// Only the first and last should run.
let db = Debounce::new(Duration::from_secs(0));
@@ -61,7 +61,7 @@ struct Context {
ctx.cv.notify_all();
// Wait until the last completion is done.
let mut reader = reader_push(Parser::principal_parser(), L!(""), ReaderConfig::default());
let mut reader = reader_push(&parser, L!(""), ReaderConfig::default());
let _pop = ScopeGuard::new((), |()| reader_pop());
while !ctx.completion_ran.last().unwrap().load() {
iothread_service_main(&mut reader);

View File

@@ -4,7 +4,6 @@
use crate::common::ENCODE_DIRECT_BASE;
use crate::env::{EnvVar, EnvVarFlags, VarTable};
use crate::env_universal_common::{CallbackDataList, EnvUniversal, UvarFormat};
use crate::parser::Parser;
use crate::reader::{reader_pop, reader_push, ReaderConfig};
use crate::tests::prelude::*;
use crate::threads::{iothread_drain_all, iothread_perform};
@@ -44,8 +43,9 @@ fn test_universal() {
let _cleanup = test_init();
let _ = std::fs::remove_dir_all("test/fish_uvars_test/");
std::fs::create_dir_all("test/fish_uvars_test/").unwrap();
let parser = TestParser::new();
let mut reader = reader_push(Parser::principal_parser(), L!(""), ReaderConfig::default());
let mut reader = reader_push(&parser, L!(""), ReaderConfig::default());
let _pop = ScopeGuard::new((), |()| reader_pop());
let threads = 1;

View File

@@ -359,13 +359,13 @@ fn test_expand_overflow() {
let vals: Vec<WString> = (1..=64).map(|i| i.to_wstring()).collect();
let expansion = WString::from_str(&str::repeat("$bigvar", 64));
let parser = Parser::principal_parser();
let parser = TestParser::new();
parser.vars().push(true);
let set = parser.vars().set(L!("bigvar"), EnvMode::LOCAL, vals);
assert_eq!(set, EnvStackSetResult::Ok);
let mut errors = ParseErrorList::new();
let ctx = OperationContext::foreground(parser, Box::new(no_cancel), EXPANSION_LIMIT_DEFAULT);
let ctx = OperationContext::foreground(&parser, Box::new(no_cancel), EXPANSION_LIMIT_DEFAULT);
// We accept only 1024 completions.
let mut output = CompletionReceiver::new(1024);