aboutsummaryrefslogtreecommitdiffstats
path: root/src/parse/test.rs
diff options
context:
space:
mode:
authorJonas Maier <jonas@x77.dev>2026-03-18 13:13:11 +0100
committerJonas Maier <jonas@x77.dev>2026-03-18 13:13:11 +0100
commit37db397e58105fcc9f5fe0c356cd03f966715bff (patch)
tree8c407f3cfabd6b27c74a55c766c1994e39a9c3b2 /src/parse/test.rs
parent6d5d57d9dd4a558b8e1d6501f6e4ffc0f340c283 (diff)
downloadpish-37db397e58105fcc9f5fe0c356cd03f966715bff.tar.gz
parsing works again
Diffstat (limited to 'src/parse/test.rs')
-rw-r--r--src/parse/test.rs25
1 files changed, 23 insertions, 2 deletions
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<PreExpansion> {
- 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"?")])])])
+ )
+}