aboutsummaryrefslogtreecommitdiffstats
path: root/src/parse/test.rs
diff options
context:
space:
mode:
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"?")])])])
+ )
+}