Remove principal_parser() from yet more of the tests

This commit is contained in:
Peter Ammon 2024-06-19 17:35:29 -07:00
parent 0d7e8c22a6
commit 2bd3bcf7fc
No known key found for this signature in database
3 changed files with 11 additions and 17 deletions

View file

@ -6,7 +6,6 @@ use crate::env::{EnvMode, EnvStackSetResult};
use crate::expand::{expand_to_receiver, ExpandResultCode};
use crate::operation_context::{no_cancel, EXPANSION_LIMIT_DEFAULT};
use crate::parse_constants::ParseErrorList;
use crate::parser::Parser;
use crate::tests::prelude::*;
use crate::wildcard::ANY_STRING;
use crate::{
@ -23,14 +22,11 @@ fn expand_test_impl(
expected: Vec<WString>,
error_message: Option<&str>,
) {
let parser = TestParser::new();
let mut output = CompletionList::new();
let mut errors = ParseErrorList::new();
let pwd = PwdEnvironment::default();
let ctx = OperationContext::test_only_foreground(
Parser::principal_parser(),
&pwd,
Box::new(no_cancel),
);
let ctx = OperationContext::test_only_foreground(&parser, &pwd, Box::new(no_cancel));
if expand_string(
input.to_owned(),

View file

@ -610,9 +610,8 @@ fn test_new_parser_errors() {
#[serial]
fn test_eval_recursion_detection() {
let _cleanup = test_init();
// Ensure that we don't crash on infinite self recursion and mutual recursion. These must use
// the principal parser because we cannot yet execute jobs on other parsers.
let parser = Parser::principal_parser();
// Ensure that we don't crash on infinite self recursion and mutual recursion.
let parser = TestParser::new();
parser.eval(
L!("function recursive ; recursive ; end ; recursive; "),
&IoChain::new(),
@ -663,7 +662,7 @@ fn test_eval_illegal_exit_code() {
#[serial]
fn test_eval_empty_function_name() {
let _cleanup = test_init();
let parser = Parser::principal_parser();
let parser = TestParser::new();
parser.eval(
L!("function '' ; echo fail; exit 42 ; end ; ''"),
&IoChain::new(),
@ -674,7 +673,7 @@ fn test_eval_empty_function_name() {
#[serial]
fn test_expand_argument_list() {
let _cleanup = test_init();
let parser = Parser::principal_parser();
let parser = TestParser::new();
let comps: Vec<WString> = Parser::expand_argument_list(
L!("alpha 'beta gamma' delta"),
ExpandFlags::default(),

View file

@ -1,5 +1,4 @@
use crate::env::{EnvMode, Environment};
use crate::parser::Parser;
use crate::termsize::*;
use crate::tests::prelude::*;
use crate::wchar::prelude::*;
@ -11,7 +10,7 @@ use std::sync::Mutex;
fn test_termsize() {
let _cleanup = test_init();
let env_global = EnvMode::GLOBAL;
let parser = Parser::principal_parser();
let parser = TestParser::new();
let vars = parser.vars();
// Use a static variable so we can pretend we're the kernel exposing a terminal size.
@ -40,7 +39,7 @@ fn test_termsize() {
assert_eq!(ts.last(), Termsize::defaults());
// Ok now we tell it to update.
ts.updating(parser);
ts.updating(&parser);
assert_eq!(ts.last(), Termsize::new(42, 84));
assert_eq!(vars.get(L!("COLUMNS")).unwrap().as_string(), "42");
assert_eq!(vars.get(L!("LINES")).unwrap().as_string(), "84");
@ -61,7 +60,7 @@ fn test_termsize() {
// Oh it got SIGWINCH, now the tty matters again.
TermsizeContainer::handle_winch();
assert_eq!(ts.last(), Termsize::new(33, 150));
assert_eq!(ts.updating(parser), stubby_termsize().unwrap());
assert_eq!(ts.updating(&parser), stubby_termsize().unwrap());
assert_eq!(vars.get(L!("COLUMNS")).unwrap().as_string(), "42");
assert_eq!(vars.get(L!("LINES")).unwrap().as_string(), "84");
@ -78,8 +77,8 @@ fn test_termsize() {
tty_size_reader: stubby_termsize,
};
ts.initialize(parser.vars());
ts2.updating(parser);
ts2.updating(&parser);
assert_eq!(ts.last(), Termsize::new(83, 38));
TermsizeContainer::handle_winch();
assert_eq!(ts2.updating(parser), stubby_termsize().unwrap());
assert_eq!(ts2.updating(&parser), stubby_termsize().unwrap());
}