From 37db397e58105fcc9f5fe0c356cd03f966715bff Mon Sep 17 00:00:00 2001 From: Jonas Maier Date: Wed, 18 Mar 2026 13:13:11 +0100 Subject: parsing works again --- src/parse/test.rs | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src/parse/test.rs') diff --git a/src/parse/test.rs b/src/parse/test.rs index d221341..3513c3f 100644 --- a/src/parse/test.rs +++ b/src/parse/test.rs @@ -1,7 +1,9 @@ use super::*; fn parse(x: &[u8]) -> Ast { - do_parse(x).unwrap() + do_parse(x) + .map_err(|(err, rest)| (err, String::from_utf8_lossy(&rest))) + .unwrap() } const TIMEOUT_MS: u64 = 100; @@ -268,7 +270,10 @@ $var line 3 """"# ), - pipes([cmd([estr(b"echo"), str([plain(b"line 1\n"),var(b"var"),plain(b"\nline 3\n")])]),]) + pipes([cmd([ + estr(b"echo"), + str([plain(b"line 1\n"), var(b"var"), plain(b"\nline 3\n")]) + ]),]) ); } @@ -300,3 +305,19 @@ more text pipes([cmd([estr(b"echo"), estr(b"text\n\"\"\"\nmore text\n")]),]) ); } + +#[test] +fn exit_code() { + parse_test!( + parse(b"echo $?"), + pipes([cmd([estr(b"echo"), str([var(b"?")])])]) + ) +} + +#[test] +fn exit_code_2() { + parse_test!( + parse(b"echo \"$?\""), + pipes([cmd([estr(b"echo"), str([var(b"?")])])]) + ) +} -- cgit v1.2.3