refactor(tests): use expect-test rather than insta

insta doesn't support having a single check function with all the
duplicated code.

Acked-by: ElKowar
Signed-off-by: Charlotte Meyer <dev@buffet.sh>
This commit is contained in:
buffet 2022-10-26 19:31:39 +00:00
parent fbba44312f
commit a88a163273
94 changed files with 2674 additions and 3084 deletions

165
Cargo.lock generated
View file

@ -20,19 +20,6 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "console"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a28b32d32ca44b70c3e4acd7db1babf555fa026e385fb95f18028f88848b3c31"
dependencies = [
"encode_unicode",
"libc",
"once_cell",
"terminal_size",
"winapi",
]
[[package]] [[package]]
name = "darling" name = "darling"
version = "0.14.1" version = "0.14.1"
@ -69,10 +56,20 @@ dependencies = [
] ]
[[package]] [[package]]
name = "encode_unicode" name = "dissimilar"
version = "0.3.6" version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" checksum = "8c97b9233581d84b8e1e689cdd3a47b6f69770084fc246e86a7f78b0d9c1d4a5"
[[package]]
name = "expect-test"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d4661aca38d826eb7c72fe128e4238220616de4c0cc00db7bfc38e2e1364dd3"
dependencies = [
"dissimilar",
"once_cell",
]
[[package]] [[package]]
name = "fnv" name = "fnv"
@ -80,60 +77,18 @@ version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "hashbrown"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]] [[package]]
name = "ident_case" name = "ident_case"
version = "1.0.1" version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]]
name = "indexmap"
version = "1.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e"
dependencies = [
"autocfg",
"hashbrown",
]
[[package]]
name = "insta"
version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4126dd76ebfe2561486a1bd6738a33d2029ffb068a99ac446b7f8c77b2e58dbc"
dependencies = [
"console",
"once_cell",
"serde",
"serde_json",
"serde_yaml",
"similar",
]
[[package]]
name = "itoa"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.132" version = "0.2.132"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5" checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5"
[[package]]
name = "linked-hash-map"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
[[package]] [[package]]
name = "nix" name = "nix"
version = "0.25.0" version = "0.25.0"
@ -181,7 +136,7 @@ version = "0.0.0"
name = "oyster_parser" name = "oyster_parser"
version = "0.0.0" version = "0.0.0"
dependencies = [ dependencies = [
"insta", "expect-test",
"thiserror", "thiserror",
] ]
@ -189,7 +144,7 @@ dependencies = [
name = "oyster_runtime" name = "oyster_runtime"
version = "0.0.0" version = "0.0.0"
dependencies = [ dependencies = [
"insta", "expect-test",
"nix", "nix",
"oyster_builtin_proc", "oyster_builtin_proc",
"oyster_parser", "oyster_parser",
@ -225,60 +180,11 @@ dependencies = [
"proc-macro2", "proc-macro2",
] ]
[[package]]
name = "ryu"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.139" version = "1.0.139"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0171ebb889e45aa68b44aee0859b3eede84c6f5f5c228e6f140c0b2a0a46cad6" checksum = "0171ebb889e45aa68b44aee0859b3eede84c6f5f5c228e6f140c0b2a0a46cad6"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.139"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc1d3230c1de7932af58ad8ffbe1d784bd55efd5a9d84ac24f69c72d83543dfb"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_json"
version = "1.0.82"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "82c2c1fdcd807d1098552c5b9a36e425e42e9fbd7c6a37a8425f390f781f7fa7"
dependencies = [
"itoa",
"ryu",
"serde",
]
[[package]]
name = "serde_yaml"
version = "0.8.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ec0091e1f5aa338283ce049bd9dfefd55e1f168ac233e85c1ffe0038fb48cbe"
dependencies = [
"indexmap",
"ryu",
"serde",
"yaml-rust",
]
[[package]]
name = "similar"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e24979f63a11545f5f2c60141afe249d4f19f84581ea2138065e400941d83d3"
[[package]] [[package]]
name = "strsim" name = "strsim"
@ -297,16 +203,6 @@ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]]
name = "terminal_size"
version = "0.1.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df"
dependencies = [
"libc",
"winapi",
]
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.35" version = "1.0.35"
@ -341,34 +237,3 @@ name = "unicode-ident"
version = "1.0.1" version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c"
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "yaml-rust"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85"
dependencies = [
"linked-hash-map",
]

View file

@ -11,4 +11,4 @@ doctest = false
thiserror = "^1.0.35" thiserror = "^1.0.35"
[dev-dependencies] [dev-dependencies]
insta = "^1.15.0" expect-test = "^1.4.0"

View file

@ -1,62 +1,219 @@
use insta::assert_debug_snapshot as assert_snapshot; use expect_test::{expect, Expect};
use oyster_parser::{ast, ParseError}; use oyster_parser::ast;
fn parse(s: &str) -> Result<ast::Code, ParseError> { fn check(s: &str, expect: Expect) {
ast::Code::try_from(s) let actual = ast::Code::try_from(s);
expect.assert_debug_eq(&actual);
} }
#[test] #[test]
fn empty() { fn empty() {
let source = ""; check(
"",
let actual = parse(source); expect![[r#"
Ok(
assert_snapshot!(actual); Code(
[],
),
)
"#]],
);
} }
#[test] #[test]
fn word() { fn word() {
let source = "word"; check(
"word",
let actual = parse(source); expect![[r#"
Ok(
assert_snapshot!(actual); Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"word",
),
],
),
],
None,
),
],
),
),
],
),
)
"#]],
);
} }
#[test] #[test]
fn word_with_escape() { fn word_with_escape() {
let source = r"hello\#world"; check(
r"hello\#world",
let actual = parse(source); expect![[r##"
Ok(
assert_snapshot!(actual); Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"hello",
),
Text(
"#",
),
Text(
"world",
),
],
),
],
None,
),
],
),
),
],
),
)
"##]],
);
} }
#[test] #[test]
fn unicode() { fn unicode() {
let source = "谚语"; check(
"谚语",
let actual = parse(source); expect![[r#"
Ok(
assert_snapshot!(actual); Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"谚语",
),
],
),
],
None,
),
],
),
),
],
),
)
"#]],
);
} }
#[test] #[test]
fn simple_command() { fn simple_command() {
let source = "echo hi"; check(
"echo hi",
let actual = parse(source); expect![[r#"
Ok(
assert_snapshot!(actual); Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"echo",
),
],
),
Word(
[
Text(
"hi",
),
],
),
],
None,
),
],
),
),
],
),
)
"#]],
);
} }
#[test] #[test]
fn semicolon() { fn semicolon() {
let source = "hello; hi"; check(
"hello; hi",
let actual = parse(source); expect![[r#"
Ok(
assert_snapshot!(actual); Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"hello",
),
],
),
],
None,
),
],
),
),
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"hi",
),
],
),
],
None,
),
],
),
),
],
),
)
"#]],
);
} }
#[test] #[test]
@ -64,27 +221,94 @@ fn comment() {
let source = r"# a let source = r"# a
# b"; # b";
let actual = parse(source); check(
source,
assert_snapshot!(actual); expect![[r#"
Ok(
Code(
[],
),
)
"#]],
);
} }
#[test] #[test]
fn inline_comment() { fn inline_comment() {
let source = "whoami # hello"; check(
"whoami # hello",
let actual = parse(source); expect![[r#"
Ok(
assert_snapshot!(actual); Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"whoami",
),
],
),
],
None,
),
],
),
),
],
),
)
"#]],
);
} }
#[test] #[test]
fn pipeline() { fn pipeline() {
let source = "whoami | cat"; check(
"whoami | cat",
let actual = parse(source); expect![[r#"
Ok(
assert_snapshot!(actual); Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"whoami",
),
],
),
],
Stdout,
),
Command(
[
Word(
[
Text(
"cat",
),
],
),
],
None,
),
],
),
),
],
),
)
"#]],
);
} }
#[test] #[test]
@ -92,9 +316,54 @@ fn multiline_pipeline() {
let source = r"whoami | let source = r"whoami |
wc -l"; wc -l";
let actual = parse(source); check(
source,
assert_snapshot!(actual); expect![[r#"
Ok(
Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"whoami",
),
],
),
],
Stdout,
),
Command(
[
Word(
[
Text(
"wc",
),
],
),
Word(
[
Text(
"-l",
),
],
),
],
None,
),
],
),
),
],
),
)
"#]],
);
} }
#[test] #[test]
@ -102,9 +371,54 @@ fn comment_in_pipeline() {
let source = r"whoami | # comment let source = r"whoami | # comment
wc -l"; wc -l";
let actual = parse(source); check(
source,
assert_snapshot!(actual); expect![[r#"
Ok(
Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"whoami",
),
],
),
],
Stdout,
),
Command(
[
Word(
[
Text(
"wc",
),
],
),
Word(
[
Text(
"-l",
),
],
),
],
None,
),
],
),
),
],
),
)
"#]],
);
} }
#[test] #[test]
@ -112,72 +426,197 @@ fn reject_leading_pipe() {
let source = r"whoami let source = r"whoami
| cat"; | cat";
let actual = parse(source); check(
source,
assert_snapshot!(actual); expect![[r#"
Err(
UnexpectedPipe,
)
"#]],
);
} }
#[test] #[test]
fn reject_trailing_pipe() { fn reject_trailing_pipe() {
let source = "whoami |"; check(
"whoami |",
let actual = parse(source); expect![[r#"
Err(
assert_snapshot!(actual); UnexpectedEof,
)
"#]],
);
} }
#[test] #[test]
fn reject_pipe_semicolon() { fn reject_pipe_semicolon() {
let source = "whoami | ; cat"; let source = "whoami | ; cat";
let actual = parse(source); check(
source,
assert_snapshot!(actual); expect![[r#"
Err(
UnexpectedSemicolon,
)
"#]],
);
} }
#[test] #[test]
fn reject_double_pipe() { fn reject_double_pipe() {
let source = "whoami | | cat"; check(
"whoami | | cat",
let actual = parse(source); expect![[r#"
Err(
assert_snapshot!(actual); UnexpectedPipe,
)
"#]],
);
} }
#[test] #[test]
fn double_quote_string() { fn double_quote_string() {
let source = r#""hello world""#; check(
r#""hello world""#,
let actual = parse(source); expect![[r#"
Ok(
assert_snapshot!(actual); Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"hello world",
),
],
),
],
None,
),
],
),
),
],
),
)
"#]],
);
} }
#[test] #[test]
fn escaped_char_in_double_quotes() { fn escaped_char_in_double_quotes() {
let source = r#""hello \" world""#; check(
r#""hello \" world""#,
let actual = parse(source); expect![[r#"
Ok(
assert_snapshot!(actual); Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"hello ",
),
Text(
"\"",
),
Text(
" world",
),
],
),
],
None,
),
],
),
),
],
),
)
"#]],
);
} }
#[test] #[test]
fn unterminated_double_quotes() { fn unterminated_double_quotes() {
let source = r#""hello world"#; check(
r#""hello world"#,
let actual = parse(source); expect![[r#"
Err(
assert_snapshot!(actual); UnexpectedEof,
)
"#]],
);
} }
#[test] #[test]
fn command_substitution() { fn command_substitution() {
let source = r#"echo (whoami)"#; check(
r#"echo (whoami)"#,
let actual = parse(source); expect![[r#"
Ok(
assert_snapshot!(actual); Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"echo",
),
],
),
Word(
[
CommandSubstitution(
Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"whoami",
),
],
),
],
None,
),
],
),
),
],
),
),
],
),
],
None,
),
],
),
),
],
),
)
"#]],
);
} }
#[test] #[test]
@ -185,7 +624,64 @@ fn quoted_command_substitution() {
let source = r#"echo "(whoami) let source = r#"echo "(whoami)
""#; ""#;
let actual = parse(source); check(
source,
assert_snapshot!(actual); expect![[r#"
Ok(
Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"echo",
),
],
),
Word(
[
CommandSubstitution(
Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"whoami",
),
],
),
],
None,
),
],
),
),
],
),
),
Text(
"\n ",
),
],
),
],
None,
),
],
),
),
],
),
)
"#]],
);
} }

File diff suppressed because it is too large Load diff

View file

@ -1,155 +1,240 @@
use insta::assert_debug_snapshot as assert_snapshot; use expect_test::expect;
use oyster_parser::Lexer; use oyster_parser::Lexer;
macro_rules! check {
($s:expr, $expect:expr, Command) => {{
let actual = Lexer::new($s).next_command_token();
$expect.assert_debug_eq(&actual);
}};
($s:expr, $expect:expr, String) => {{
let actual = Lexer::new($s).next_string_token();
let actual = format!("{:?}", actual);
$expect.assert_debug_eq(&actual);
}};
}
#[test] #[test]
fn eof() { fn eof() {
let source = ""; check!(
"",
let actual = Lexer::new(source).next_command_token(); expect![[r#"
Token {
assert_snapshot!(actual); kind: Eof,
len: 0,
}
"#]],
Command
);
} }
#[test] #[test]
fn whitespace() { fn whitespace() {
let source = " \t \t\t"; check!(
" \t \t\t",
let actual = Lexer::new(source).next_command_token(); expect![[r#"
Token {
assert_snapshot!(actual); kind: Whitespace,
len: 6,
}
"#]],
Command
);
} }
#[test] #[test]
fn newlines() { fn newlines() {
let source = "\n\n\n"; check!(
"\n\n\n",
let actual = Lexer::new(source).next_command_token(); expect![[r#"
Token {
assert_snapshot!(actual); kind: Newlines,
len: 3,
}
"#]],
Command
);
} }
#[test] #[test]
fn semicolon() { fn semicolon() {
let source = ";"; check!(
";",
let actual = Lexer::new(source).next_command_token(); expect![[r#"
Token {
assert_snapshot!(actual); kind: Semicolon,
len: 1,
}
"#]],
Command
);
} }
#[test] #[test]
fn pipe() { fn pipe() {
let source = "|"; check!(
"|",
let actual = Lexer::new(source).next_command_token(); expect![[r#"
Token {
assert_snapshot!(actual); kind: Pipe,
len: 1,
}
"#]],
Command
);
} }
#[test] #[test]
fn plain_word() { fn plain_word() {
let source = "whoami"; check!(
"whoami",
let actual = Lexer::new(source).next_command_token(); expect![[r#"
Token {
assert_snapshot!(actual); kind: PlainText,
len: 6,
}
"#]],
Command
);
} }
#[test] #[test]
fn word_with_hash() { fn word_with_hash() {
let source = "nixpkgs#hello"; check!(
"nixpkgs#hello",
let actual = Lexer::new(source).next_command_token(); expect![[r#"
Token {
assert_snapshot!(actual); kind: PlainText,
len: 13,
}
"#]],
Command
);
} }
#[test] #[test]
fn escaped_hash() { fn escaped_hash() {
let source = r"\#"; check!(
r"\#",
let actual = Lexer::new(source).next_command_token(); expect![[r#"
Token {
assert_snapshot!(actual); kind: EscapedChar,
len: 2,
}
"#]],
Command
);
} }
#[test] #[test]
fn comment() { fn comment() {
let source = "# hey"; check!(
"# hey",
let actual = Lexer::new(source).next_command_token(); expect![[r#"
Token {
assert_snapshot!(actual); kind: Comment,
len: 5,
}
"#]],
Command
);
} }
#[test] #[test]
fn double_quotes_in_command() { fn double_quotes_in_command() {
let source = r#"""#; check!(
r#"""#,
let actual = Lexer::new(source).next_command_token(); expect![[r#"
Token {
assert_snapshot!(actual); kind: DoubleQuote,
len: 1,
}
"#]],
Command
);
} }
#[test] #[test]
fn double_quotes_in_string() { fn double_quotes_in_string() {
let source = r#"""#; check!(
r#"""#,
let actual = Lexer::new(source).next_string_token(); expect![[r#"
"Token { kind: DoubleQuote, len: 1 }"
assert_snapshot!(actual); "#]],
String
);
} }
#[test] #[test]
fn escaped_quotes_in_string() { fn escaped_quotes_in_string() {
let source = r#"\""#; check!(
r#"\""#,
let actual = Lexer::new(source).next_string_token(); expect![[r#"
"Token { kind: EscapedChar, len: 2 }"
assert_snapshot!(actual); "#]],
String
);
} }
#[test] #[test]
fn opening_parenthesis_command_mode() { fn opening_parenthesis_command_mode() {
let source = r"("; check!(
r"(",
let actual = Lexer::new(source).next_command_token(); expect![[r#"
Token {
assert_snapshot!(actual); kind: OpeningParenthesis,
len: 1,
}
"#]],
Command
);
} }
#[test] #[test]
fn closing_parenthesis_command_mode() { fn closing_parenthesis_command_mode() {
let source = r")"; check!(
r")",
let actual = Lexer::new(source).next_command_token(); expect![[r#"
Token {
assert_snapshot!(actual); kind: ClosingParenthesis,
len: 1,
}
"#]],
Command
);
} }
#[test] #[test]
fn opening_parenthesis_string_mode() { fn opening_parenthesis_string_mode() {
let source = r"("; check!(
r"(",
let actual = Lexer::new(source).next_string_token(); expect![[r#"
"Token { kind: OpeningParenthesis, len: 1 }"
assert_snapshot!(actual); "#]],
String
);
} }
#[test] #[test]
fn closing_parenthesis_string_mode() { fn closing_parenthesis_string_mode() {
let source = r")"; check!(
r")",
let actual = Lexer::new(source).next_string_token(); expect![[r#"
"Token { kind: ClosingParenthesis, len: 1 }"
assert_snapshot!(actual); "#]],
String
);
} }
#[test] #[test]
fn escape_newline() { fn escape_newline() {
let source = "\\\n"; check!(
"\\\n",
let actual = Lexer::new(source).next_command_token(); expect![[r#"
Token {
assert_snapshot!(actual); kind: Whitespace,
len: 2,
}
"#]],
Command
);
} }

File diff suppressed because it is too large Load diff

View file

@ -1,56 +0,0 @@
---
source: crates/oyster_parser/tests/it/ast.rs
expression: actual
---
Ok(
Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"echo",
),
],
),
Word(
[
CommandSubstitution(
Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"whoami",
),
],
),
],
None,
),
],
),
),
],
),
),
],
),
],
None,
),
],
),
),
],
),
)

View file

@ -1,9 +0,0 @@
---
source: crates/oyster_parser/tests/it/ast.rs
expression: actual
---
Ok(
Code(
[],
),
)

View file

@ -1,47 +0,0 @@
---
source: crates/oyster_parser/tests/it/ast.rs
expression: actual
---
Ok(
Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"whoami",
),
],
),
],
Stdout,
),
Command(
[
Word(
[
Text(
"wc",
),
],
),
Word(
[
Text(
"-l",
),
],
),
],
None,
),
],
),
),
],
),
)

View file

@ -1,28 +0,0 @@
---
source: crates/oyster_parser/tests/it/ast.rs
expression: actual
---
Ok(
Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"hello world",
),
],
),
],
None,
),
],
),
),
],
),
)

View file

@ -1,9 +0,0 @@
---
source: crates/oyster_parser/tests/it/ast.rs
expression: actual
---
Ok(
Code(
[],
),
)

View file

@ -1,34 +0,0 @@
---
source: crates/oyster_parser/tests/it/ast.rs
expression: actual
---
Ok(
Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"hello ",
),
Text(
"\"",
),
Text(
" world",
),
],
),
],
None,
),
],
),
),
],
),
)

View file

@ -1,28 +0,0 @@
---
source: crates/oyster_parser/tests/it/ast.rs
expression: actual
---
Ok(
Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"whoami",
),
],
),
],
None,
),
],
),
),
],
),
)

View file

@ -1,47 +0,0 @@
---
source: crates/oyster_parser/tests/it/ast.rs
expression: actual
---
Ok(
Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"whoami",
),
],
),
],
Stdout,
),
Command(
[
Word(
[
Text(
"wc",
),
],
),
Word(
[
Text(
"-l",
),
],
),
],
None,
),
],
),
),
],
),
)

View file

@ -1,40 +0,0 @@
---
source: crates/oyster_parser/tests/it/ast.rs
expression: actual
---
Ok(
Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"whoami",
),
],
),
],
Stdout,
),
Command(
[
Word(
[
Text(
"cat",
),
],
),
],
None,
),
],
),
),
],
),
)

View file

@ -1,59 +0,0 @@
---
source: crates/oyster_parser/tests/it/ast.rs
expression: actual
---
Ok(
Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"echo",
),
],
),
Word(
[
CommandSubstitution(
Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"whoami",
),
],
),
],
None,
),
],
),
),
],
),
),
Text(
"\n ",
),
],
),
],
None,
),
],
),
),
],
),
)

View file

@ -1,7 +0,0 @@
---
source: crates/oyster_parser/tests/it/ast.rs
expression: actual
---
Err(
UnexpectedPipe,
)

View file

@ -1,7 +0,0 @@
---
source: crates/oyster_parser/tests/it/ast.rs
expression: actual
---
Err(
UnexpectedPipe,
)

View file

@ -1,7 +0,0 @@
---
source: crates/oyster_parser/tests/it/ast.rs
expression: actual
---
Err(
UnexpectedSemicolon,
)

View file

@ -1,7 +0,0 @@
---
source: crates/oyster_parser/tests/it/ast.rs
expression: actual
---
Err(
UnexpectedEof,
)

View file

@ -1,46 +0,0 @@
---
source: crates/oyster_parser/tests/it/ast.rs
expression: actual
---
Ok(
Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"hello",
),
],
),
],
None,
),
],
),
),
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"hi",
),
],
),
],
None,
),
],
),
),
],
),
)

View file

@ -1,35 +0,0 @@
---
source: crates/oyster_parser/tests/it/ast.rs
expression: actual
---
Ok(
Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"echo",
),
],
),
Word(
[
Text(
"hi",
),
],
),
],
None,
),
],
),
),
],
),
)

View file

@ -1,28 +0,0 @@
---
source: crates/oyster_parser/tests/it/ast.rs
expression: actual
---
Ok(
Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"谚语",
),
],
),
],
None,
),
],
),
),
],
),
)

View file

@ -1,7 +0,0 @@
---
source: crates/oyster_parser/tests/it/ast.rs
expression: actual
---
Err(
UnexpectedEof,
)

View file

@ -1,28 +0,0 @@
---
source: crates/oyster_parser/tests/it/ast.rs
expression: actual
---
Ok(
Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"word",
),
],
),
],
None,
),
],
),
),
],
),
)

View file

@ -1,34 +0,0 @@
---
source: crates/oyster_parser/tests/it/ast.rs
expression: actual
---
Ok(
Code(
[
Pipeline(
Pipeline(
[
Command(
[
Word(
[
Text(
"hello",
),
Text(
"#",
),
Text(
"world",
),
],
),
],
None,
),
],
),
),
],
),
)

View file

@ -1,69 +0,0 @@
---
source: crates/oyster_parser/tests/it/cst.rs
expression: actual
---
Tree {
kind: Program,
children: [
Tree {
kind: Pipeline,
children: [
Tree {
kind: Command,
children: [
Tree {
kind: Word,
children: [
Leaf {
kind: PlainText,
len: 4,
},
],
},
Leaf {
kind: Whitespace,
len: 1,
},
Tree {
kind: Word,
children: [
Tree {
kind: CommandSubstitution,
children: [
Leaf {
kind: OpeningParenthesis,
len: 1,
},
Tree {
kind: Pipeline,
children: [
Tree {
kind: Command,
children: [
Tree {
kind: Word,
children: [
Leaf {
kind: PlainText,
len: 6,
},
],
},
],
},
],
},
Leaf {
kind: ClosingParenthesis,
len: 1,
},
],
},
],
},
],
},
],
},
],
}

View file

@ -1,21 +0,0 @@
---
source: crates/oyster_parser/tests/it/cst.rs
expression: actual
---
Tree {
kind: Program,
children: [
Leaf {
kind: Comment,
len: 3,
},
Leaf {
kind: Newlines,
len: 1,
},
Leaf {
kind: Comment,
len: 3,
},
],
}

View file

@ -1,75 +0,0 @@
---
source: crates/oyster_parser/tests/it/cst.rs
expression: actual
---
Tree {
kind: Program,
children: [
Tree {
kind: Pipeline,
children: [
Tree {
kind: Command,
children: [
Tree {
kind: Word,
children: [
Leaf {
kind: PlainText,
len: 6,
},
],
},
Leaf {
kind: Whitespace,
len: 1,
},
],
},
Leaf {
kind: Pipe,
len: 1,
},
Leaf {
kind: Whitespace,
len: 1,
},
Leaf {
kind: Comment,
len: 9,
},
Leaf {
kind: Newlines,
len: 1,
},
Tree {
kind: Command,
children: [
Tree {
kind: Word,
children: [
Leaf {
kind: PlainText,
len: 2,
},
],
},
Leaf {
kind: Whitespace,
len: 1,
},
Tree {
kind: Word,
children: [
Leaf {
kind: PlainText,
len: 2,
},
],
},
],
},
],
},
],
}

View file

@ -1,41 +0,0 @@
---
source: crates/oyster_parser/tests/it/cst.rs
expression: actual
---
Tree {
kind: Program,
children: [
Tree {
kind: Pipeline,
children: [
Tree {
kind: Command,
children: [
Tree {
kind: Word,
children: [
Tree {
kind: DQuotedString,
children: [
Leaf {
kind: DoubleQuote,
len: 1,
},
Leaf {
kind: PlainText,
len: 11,
},
Leaf {
kind: DoubleQuote,
len: 1,
},
],
},
],
},
],
},
],
},
],
}

View file

@ -1,8 +0,0 @@
---
source: crates/oyster_parser/tests/it/cst.rs
expression: actual
---
Tree {
kind: Program,
children: [],
}

View file

@ -1,49 +0,0 @@
---
source: crates/oyster_parser/tests/it/cst.rs
expression: actual
---
Tree {
kind: Program,
children: [
Tree {
kind: Pipeline,
children: [
Tree {
kind: Command,
children: [
Tree {
kind: Word,
children: [
Tree {
kind: DQuotedString,
children: [
Leaf {
kind: DoubleQuote,
len: 1,
},
Leaf {
kind: PlainText,
len: 6,
},
Leaf {
kind: EscapedChar,
len: 2,
},
Leaf {
kind: PlainText,
len: 6,
},
Leaf {
kind: DoubleQuote,
len: 1,
},
],
},
],
},
],
},
],
},
],
}

View file

@ -1,36 +0,0 @@
---
source: crates/oyster_parser/tests/it/cst.rs
expression: actual
---
Tree {
kind: Program,
children: [
Tree {
kind: Pipeline,
children: [
Tree {
kind: Command,
children: [
Tree {
kind: Word,
children: [
Leaf {
kind: PlainText,
len: 6,
},
],
},
Leaf {
kind: Whitespace,
len: 1,
},
Leaf {
kind: Comment,
len: 7,
},
],
},
],
},
],
}

View file

@ -1,67 +0,0 @@
---
source: crates/oyster_parser/tests/it/cst.rs
expression: actual
---
Tree {
kind: Program,
children: [
Tree {
kind: Pipeline,
children: [
Tree {
kind: Command,
children: [
Tree {
kind: Word,
children: [
Leaf {
kind: PlainText,
len: 6,
},
],
},
Leaf {
kind: Whitespace,
len: 1,
},
],
},
Leaf {
kind: Pipe,
len: 1,
},
Leaf {
kind: Newlines,
len: 1,
},
Tree {
kind: Command,
children: [
Tree {
kind: Word,
children: [
Leaf {
kind: PlainText,
len: 2,
},
],
},
Leaf {
kind: Whitespace,
len: 1,
},
Tree {
kind: Word,
children: [
Leaf {
kind: PlainText,
len: 2,
},
],
},
],
},
],
},
],
}

View file

@ -1,54 +0,0 @@
---
source: crates/oyster_parser/tests/it/cst.rs
expression: actual
---
Tree {
kind: Program,
children: [
Tree {
kind: Pipeline,
children: [
Tree {
kind: Command,
children: [
Tree {
kind: Word,
children: [
Leaf {
kind: PlainText,
len: 6,
},
],
},
Leaf {
kind: Whitespace,
len: 1,
},
],
},
Leaf {
kind: Pipe,
len: 1,
},
Leaf {
kind: Whitespace,
len: 1,
},
Tree {
kind: Command,
children: [
Tree {
kind: Word,
children: [
Leaf {
kind: PlainText,
len: 3,
},
],
},
],
},
],
},
],
}

View file

@ -1,86 +0,0 @@
---
source: crates/oyster_parser/tests/it/cst.rs
expression: actual
---
Tree {
kind: Program,
children: [
Tree {
kind: Pipeline,
children: [
Tree {
kind: Command,
children: [
Tree {
kind: Word,
children: [
Leaf {
kind: PlainText,
len: 4,
},
],
},
Leaf {
kind: Whitespace,
len: 1,
},
Tree {
kind: Word,
children: [
Tree {
kind: DQuotedString,
children: [
Leaf {
kind: DoubleQuote,
len: 1,
},
Tree {
kind: CommandSubstitution,
children: [
Leaf {
kind: OpeningParenthesis,
len: 1,
},
Tree {
kind: Pipeline,
children: [
Tree {
kind: Command,
children: [
Tree {
kind: Word,
children: [
Leaf {
kind: PlainText,
len: 6,
},
],
},
],
},
],
},
Leaf {
kind: ClosingParenthesis,
len: 1,
},
],
},
Leaf {
kind: PlainText,
len: 9,
},
Leaf {
kind: DoubleQuote,
len: 1,
},
],
},
],
},
],
},
],
},
],
}

View file

@ -1,62 +0,0 @@
---
source: crates/oyster_parser/tests/it/cst.rs
expression: actual
---
Tree {
kind: Program,
children: [
Tree {
kind: Pipeline,
children: [
Tree {
kind: Command,
children: [
Tree {
kind: Word,
children: [
Leaf {
kind: PlainText,
len: 6,
},
],
},
Leaf {
kind: Whitespace,
len: 1,
},
],
},
Leaf {
kind: Pipe,
len: 1,
},
Leaf {
kind: Whitespace,
len: 1,
},
Error {
kind: UnexpectedPipe,
len: 1,
},
Leaf {
kind: Whitespace,
len: 1,
},
Tree {
kind: Command,
children: [
Tree {
kind: Word,
children: [
Leaf {
kind: PlainText,
len: 3,
},
],
},
],
},
],
},
],
}

View file

@ -1,59 +0,0 @@
---
source: crates/oyster_parser/tests/it/cst.rs
expression: actual
---
Tree {
kind: Program,
children: [
Tree {
kind: Pipeline,
children: [
Tree {
kind: Command,
children: [
Tree {
kind: Word,
children: [
Leaf {
kind: PlainText,
len: 6,
},
],
},
],
},
],
},
Leaf {
kind: Newlines,
len: 1,
},
Error {
kind: UnexpectedPipe,
len: 1,
},
Leaf {
kind: Whitespace,
len: 1,
},
Tree {
kind: Pipeline,
children: [
Tree {
kind: Command,
children: [
Tree {
kind: Word,
children: [
Leaf {
kind: PlainText,
len: 3,
},
],
},
],
},
],
},
],
}

View file

@ -1,67 +0,0 @@
---
source: crates/oyster_parser/tests/it/cst.rs
expression: actual
---
Tree {
kind: Program,
children: [
Tree {
kind: Pipeline,
children: [
Tree {
kind: Command,
children: [
Tree {
kind: Word,
children: [
Leaf {
kind: PlainText,
len: 6,
},
],
},
Leaf {
kind: Whitespace,
len: 1,
},
],
},
Leaf {
kind: Pipe,
len: 1,
},
Leaf {
kind: Whitespace,
len: 1,
},
Error {
kind: UnexpectedSemicolon,
len: 1,
},
],
},
Leaf {
kind: Whitespace,
len: 1,
},
Tree {
kind: Pipeline,
children: [
Tree {
kind: Command,
children: [
Tree {
kind: Word,
children: [
Leaf {
kind: PlainText,
len: 3,
},
],
},
],
},
],
},
],
}

View file

@ -1,40 +0,0 @@
---
source: crates/oyster_parser/tests/it/cst.rs
expression: actual
---
Tree {
kind: Program,
children: [
Tree {
kind: Pipeline,
children: [
Tree {
kind: Command,
children: [
Tree {
kind: Word,
children: [
Leaf {
kind: PlainText,
len: 6,
},
],
},
Leaf {
kind: Whitespace,
len: 1,
},
],
},
Leaf {
kind: Pipe,
len: 1,
},
Error {
kind: UnexpectedEof,
len: 0,
},
],
},
],
}

View file

@ -1,55 +0,0 @@
---
source: crates/oyster_parser/tests/it/cst.rs
expression: actual
---
Tree {
kind: Program,
children: [
Tree {
kind: Pipeline,
children: [
Tree {
kind: Command,
children: [
Tree {
kind: Word,
children: [
Leaf {
kind: PlainText,
len: 5,
},
],
},
],
},
],
},
Leaf {
kind: Semicolon,
len: 1,
},
Leaf {
kind: Whitespace,
len: 1,
},
Tree {
kind: Pipeline,
children: [
Tree {
kind: Command,
children: [
Tree {
kind: Word,
children: [
Leaf {
kind: PlainText,
len: 2,
},
],
},
],
},
],
},
],
}

View file

@ -1,41 +0,0 @@
---
source: crates/oyster_parser/tests/it/cst.rs
expression: actual
---
Tree {
kind: Program,
children: [
Tree {
kind: Pipeline,
children: [
Tree {
kind: Command,
children: [
Tree {
kind: Word,
children: [
Leaf {
kind: PlainText,
len: 4,
},
],
},
Leaf {
kind: Whitespace,
len: 1,
},
Tree {
kind: Word,
children: [
Leaf {
kind: PlainText,
len: 2,
},
],
},
],
},
],
},
],
}

View file

@ -1,28 +0,0 @@
---
source: crates/oyster_parser/tests/it/cst.rs
expression: actual
---
Tree {
kind: Program,
children: [
Tree {
kind: Pipeline,
children: [
Tree {
kind: Command,
children: [
Tree {
kind: Word,
children: [
Leaf {
kind: PlainText,
len: 6,
},
],
},
],
},
],
},
],
}

View file

@ -1,41 +0,0 @@
---
source: crates/oyster_parser/tests/it/cst.rs
expression: actual
---
Tree {
kind: Program,
children: [
Tree {
kind: Pipeline,
children: [
Tree {
kind: Command,
children: [
Tree {
kind: Word,
children: [
Tree {
kind: DQuotedString,
children: [
Leaf {
kind: DoubleQuote,
len: 1,
},
Leaf {
kind: PlainText,
len: 11,
},
Error {
kind: UnexpectedEof,
len: 0,
},
],
},
],
},
],
},
],
},
],
}

View file

@ -1,28 +0,0 @@
---
source: crates/oyster_parser/tests/it/cst.rs
expression: actual
---
Tree {
kind: Program,
children: [
Tree {
kind: Pipeline,
children: [
Tree {
kind: Command,
children: [
Tree {
kind: Word,
children: [
Leaf {
kind: PlainText,
len: 4,
},
],
},
],
},
],
},
],
}

View file

@ -1,36 +0,0 @@
---
source: crates/oyster_parser/tests/it/cst.rs
expression: actual
---
Tree {
kind: Program,
children: [
Tree {
kind: Pipeline,
children: [
Tree {
kind: Command,
children: [
Tree {
kind: Word,
children: [
Leaf {
kind: PlainText,
len: 5,
},
Leaf {
kind: EscapedChar,
len: 2,
},
Leaf {
kind: PlainText,
len: 5,
},
],
},
],
},
],
},
],
}

View file

@ -1,8 +0,0 @@
---
source: crates/oyster_parser/tests/it/lexer.rs
expression: actual
---
Token {
kind: ClosingParenthesis,
len: 1,
}

View file

@ -1,8 +0,0 @@
---
source: crates/oyster_parser/tests/it/lexer.rs
expression: actual
---
Token {
kind: ClosingParenthesis,
len: 1,
}

View file

@ -1,8 +0,0 @@
---
source: crates/oyster_parser/tests/it/lexer.rs
expression: actual
---
Token {
kind: Comment,
len: 5,
}

View file

@ -1,8 +0,0 @@
---
source: crates/oyster_parser/tests/it/lexer.rs
expression: actual
---
Token {
kind: DoubleQuote,
len: 1,
}

View file

@ -1,8 +0,0 @@
---
source: crates/oyster_parser/tests/it/lexer.rs
expression: actual
---
Token {
kind: DoubleQuote,
len: 1,
}

View file

@ -1,8 +0,0 @@
---
source: crates/oyster_parser/tests/it/lexer.rs
expression: actual
---
Token {
kind: Eof,
len: 0,
}

View file

@ -1,8 +0,0 @@
---
source: crates/oyster_parser/tests/it/lexer.rs
expression: actual
---
Token {
kind: Whitespace,
len: 2,
}

View file

@ -1,8 +0,0 @@
---
source: crates/oyster_parser/tests/it/lexer.rs
expression: actual
---
Token {
kind: EscapedChar,
len: 2,
}

View file

@ -1,8 +0,0 @@
---
source: crates/oyster_parser/tests/it/lexer.rs
expression: actual
---
Token {
kind: EscapedChar,
len: 2,
}

View file

@ -1,8 +0,0 @@
---
source: crates/oyster_parser/tests/it/lexer.rs
expression: actual
---
Token {
kind: Newlines,
len: 3,
}

View file

@ -1,8 +0,0 @@
---
source: crates/oyster_parser/tests/it/lexer.rs
expression: actual
---
Token {
kind: OpeningParenthesis,
len: 1,
}

View file

@ -1,8 +0,0 @@
---
source: crates/oyster_parser/tests/it/lexer.rs
expression: actual
---
Token {
kind: OpeningParenthesis,
len: 1,
}

View file

@ -1,8 +0,0 @@
---
source: crates/oyster_parser/tests/it/lexer.rs
expression: actual
---
Token {
kind: Pipe,
len: 1,
}

View file

@ -1,8 +0,0 @@
---
source: crates/oyster_parser/tests/it/lexer.rs
expression: actual
---
Token {
kind: PlainText,
len: 6,
}

View file

@ -1,8 +0,0 @@
---
source: crates/oyster_parser/tests/it/lexer.rs
expression: actual
---
Token {
kind: Semicolon,
len: 1,
}

View file

@ -1,8 +0,0 @@
---
source: crates/oyster_parser/tests/it/lexer.rs
expression: actual
---
Token {
kind: Whitespace,
len: 6,
}

View file

@ -1,8 +0,0 @@
---
source: crates/oyster_parser/tests/it/lexer.rs
expression: actual
---
Token {
kind: PlainText,
len: 13,
}

View file

@ -1,58 +0,0 @@
---
source: crates/oyster_parser/tests/it/parser.rs
expression: actual
---
[
StartNode(
Pipeline,
),
StartNode(
Command,
),
StartNode(
Word,
),
NewLeaf(
PlainText,
4,
),
EndNode,
NewLeaf(
Whitespace,
1,
),
StartNode(
Word,
),
StartNode(
CommandSubstitution,
),
NewLeaf(
OpeningParenthesis,
1,
),
StartNode(
Pipeline,
),
StartNode(
Command,
),
StartNode(
Word,
),
NewLeaf(
PlainText,
6,
),
EndNode,
EndNode,
EndNode,
NewLeaf(
ClosingParenthesis,
1,
),
EndNode,
EndNode,
EndNode,
EndNode,
]

View file

@ -1,18 +0,0 @@
---
source: crates/oyster_parser/tests/it/parser.rs
expression: actual
---
[
NewLeaf(
Comment,
3,
),
NewLeaf(
Newlines,
1,
),
NewLeaf(
Comment,
3,
),
]

View file

@ -1,66 +0,0 @@
---
source: crates/oyster_parser/tests/it/parser.rs
expression: actual
---
[
StartNode(
Pipeline,
),
StartNode(
Command,
),
StartNode(
Word,
),
NewLeaf(
PlainText,
6,
),
EndNode,
NewLeaf(
Whitespace,
1,
),
EndNode,
NewLeaf(
Pipe,
1,
),
NewLeaf(
Whitespace,
1,
),
NewLeaf(
Comment,
9,
),
NewLeaf(
Newlines,
1,
),
StartNode(
Command,
),
StartNode(
Word,
),
NewLeaf(
PlainText,
2,
),
EndNode,
NewLeaf(
Whitespace,
1,
),
StartNode(
Word,
),
NewLeaf(
PlainText,
2,
),
EndNode,
EndNode,
EndNode,
]

View file

@ -1,34 +0,0 @@
---
source: crates/oyster_parser/tests/it/parser.rs
expression: actual
---
[
StartNode(
Pipeline,
),
StartNode(
Command,
),
StartNode(
Word,
),
StartNode(
DQuotedString,
),
NewLeaf(
DoubleQuote,
1,
),
NewLeaf(
PlainText,
11,
),
NewLeaf(
DoubleQuote,
1,
),
EndNode,
EndNode,
EndNode,
EndNode,
]

View file

@ -1,5 +0,0 @@
---
source: crates/oyster_parser/tests/it/parser.rs
expression: actual
---
[]

View file

@ -1,42 +0,0 @@
---
source: crates/oyster_parser/tests/it/parser.rs
expression: actual
---
[
StartNode(
Pipeline,
),
StartNode(
Command,
),
StartNode(
Word,
),
StartNode(
DQuotedString,
),
NewLeaf(
DoubleQuote,
1,
),
NewLeaf(
PlainText,
6,
),
NewLeaf(
EscapedChar,
2,
),
NewLeaf(
PlainText,
6,
),
NewLeaf(
DoubleQuote,
1,
),
EndNode,
EndNode,
EndNode,
EndNode,
]

View file

@ -1,30 +0,0 @@
---
source: crates/oyster_parser/tests/it/parser.rs
expression: actual
---
[
StartNode(
Pipeline,
),
StartNode(
Command,
),
StartNode(
Word,
),
NewLeaf(
PlainText,
6,
),
EndNode,
NewLeaf(
Whitespace,
1,
),
NewLeaf(
Comment,
7,
),
EndNode,
EndNode,
]

View file

@ -1,58 +0,0 @@
---
source: crates/oyster_parser/tests/it/parser.rs
expression: actual
---
[
StartNode(
Pipeline,
),
StartNode(
Command,
),
StartNode(
Word,
),
NewLeaf(
PlainText,
6,
),
EndNode,
NewLeaf(
Whitespace,
1,
),
EndNode,
NewLeaf(
Pipe,
1,
),
NewLeaf(
Newlines,
1,
),
StartNode(
Command,
),
StartNode(
Word,
),
NewLeaf(
PlainText,
2,
),
EndNode,
NewLeaf(
Whitespace,
1,
),
StartNode(
Word,
),
NewLeaf(
PlainText,
2,
),
EndNode,
EndNode,
EndNode,
]

View file

@ -1,46 +0,0 @@
---
source: crates/oyster_parser/tests/it/parser.rs
expression: actual
---
[
StartNode(
Pipeline,
),
StartNode(
Command,
),
StartNode(
Word,
),
NewLeaf(
PlainText,
6,
),
EndNode,
NewLeaf(
Whitespace,
1,
),
EndNode,
NewLeaf(
Pipe,
1,
),
NewLeaf(
Whitespace,
1,
),
StartNode(
Command,
),
StartNode(
Word,
),
NewLeaf(
PlainText,
3,
),
EndNode,
EndNode,
EndNode,
]

View file

@ -1,74 +0,0 @@
---
source: crates/oyster_parser/tests/it/parser.rs
expression: actual
---
[
StartNode(
Pipeline,
),
StartNode(
Command,
),
StartNode(
Word,
),
NewLeaf(
PlainText,
4,
),
EndNode,
NewLeaf(
Whitespace,
1,
),
StartNode(
Word,
),
StartNode(
DQuotedString,
),
NewLeaf(
DoubleQuote,
1,
),
StartNode(
CommandSubstitution,
),
NewLeaf(
OpeningParenthesis,
1,
),
StartNode(
Pipeline,
),
StartNode(
Command,
),
StartNode(
Word,
),
NewLeaf(
PlainText,
6,
),
EndNode,
EndNode,
EndNode,
NewLeaf(
ClosingParenthesis,
1,
),
EndNode,
NewLeaf(
PlainText,
9,
),
NewLeaf(
DoubleQuote,
1,
),
EndNode,
EndNode,
EndNode,
EndNode,
]

View file

@ -1,54 +0,0 @@
---
source: crates/oyster_parser/tests/it/parser.rs
expression: actual
---
[
StartNode(
Pipeline,
),
StartNode(
Command,
),
StartNode(
Word,
),
NewLeaf(
PlainText,
6,
),
EndNode,
NewLeaf(
Whitespace,
1,
),
EndNode,
NewLeaf(
Pipe,
1,
),
NewLeaf(
Whitespace,
1,
),
Error(
UnexpectedPipe,
1,
),
NewLeaf(
Whitespace,
1,
),
StartNode(
Command,
),
StartNode(
Word,
),
NewLeaf(
PlainText,
3,
),
EndNode,
EndNode,
EndNode,
]

View file

@ -1,50 +0,0 @@
---
source: crates/oyster_parser/tests/it/parser.rs
expression: actual
---
[
StartNode(
Pipeline,
),
StartNode(
Command,
),
StartNode(
Word,
),
NewLeaf(
PlainText,
6,
),
EndNode,
EndNode,
EndNode,
NewLeaf(
Newlines,
1,
),
Error(
UnexpectedPipe,
1,
),
NewLeaf(
Whitespace,
1,
),
StartNode(
Pipeline,
),
StartNode(
Command,
),
StartNode(
Word,
),
NewLeaf(
PlainText,
3,
),
EndNode,
EndNode,
EndNode,
]

View file

@ -1,58 +0,0 @@
---
source: crates/oyster_parser/tests/it/parser.rs
expression: actual
---
[
StartNode(
Pipeline,
),
StartNode(
Command,
),
StartNode(
Word,
),
NewLeaf(
PlainText,
6,
),
EndNode,
NewLeaf(
Whitespace,
1,
),
EndNode,
NewLeaf(
Pipe,
1,
),
NewLeaf(
Whitespace,
1,
),
Error(
UnexpectedSemicolon,
1,
),
EndNode,
NewLeaf(
Whitespace,
1,
),
StartNode(
Pipeline,
),
StartNode(
Command,
),
StartNode(
Word,
),
NewLeaf(
PlainText,
3,
),
EndNode,
EndNode,
EndNode,
]

View file

@ -1,34 +0,0 @@
---
source: crates/oyster_parser/tests/it/parser.rs
expression: actual
---
[
StartNode(
Pipeline,
),
StartNode(
Command,
),
StartNode(
Word,
),
NewLeaf(
PlainText,
6,
),
EndNode,
NewLeaf(
Whitespace,
1,
),
EndNode,
NewLeaf(
Pipe,
1,
),
Error(
UnexpectedEof,
0,
),
EndNode,
]

View file

@ -1,46 +0,0 @@
---
source: crates/oyster_parser/tests/it/parser.rs
expression: actual
---
[
StartNode(
Pipeline,
),
StartNode(
Command,
),
StartNode(
Word,
),
NewLeaf(
PlainText,
5,
),
EndNode,
EndNode,
EndNode,
NewLeaf(
Semicolon,
1,
),
NewLeaf(
Whitespace,
1,
),
StartNode(
Pipeline,
),
StartNode(
Command,
),
StartNode(
Word,
),
NewLeaf(
PlainText,
2,
),
EndNode,
EndNode,
EndNode,
]

View file

@ -1,34 +0,0 @@
---
source: crates/oyster_parser/tests/it/parser.rs
expression: actual
---
[
StartNode(
Pipeline,
),
StartNode(
Command,
),
StartNode(
Word,
),
NewLeaf(
PlainText,
4,
),
EndNode,
NewLeaf(
Whitespace,
1,
),
StartNode(
Word,
),
NewLeaf(
PlainText,
2,
),
EndNode,
EndNode,
EndNode,
]

View file

@ -1,22 +0,0 @@
---
source: crates/oyster_parser/tests/it/parser.rs
expression: actual
---
[
StartNode(
Pipeline,
),
StartNode(
Command,
),
StartNode(
Word,
),
NewLeaf(
PlainText,
6,
),
EndNode,
EndNode,
EndNode,
]

View file

@ -1,34 +0,0 @@
---
source: crates/oyster_parser/tests/it/parser.rs
expression: actual
---
[
StartNode(
Pipeline,
),
StartNode(
Command,
),
StartNode(
Word,
),
StartNode(
DQuotedString,
),
NewLeaf(
DoubleQuote,
1,
),
NewLeaf(
PlainText,
11,
),
Error(
UnexpectedEof,
0,
),
EndNode,
EndNode,
EndNode,
EndNode,
]

View file

@ -1,22 +0,0 @@
---
source: crates/oyster_parser/tests/it/parser.rs
expression: actual
---
[
StartNode(
Pipeline,
),
StartNode(
Command,
),
StartNode(
Word,
),
NewLeaf(
PlainText,
4,
),
EndNode,
EndNode,
EndNode,
]

View file

@ -1,30 +0,0 @@
---
source: crates/oyster_parser/tests/it/parser.rs
expression: actual
---
[
StartNode(
Pipeline,
),
StartNode(
Command,
),
StartNode(
Word,
),
NewLeaf(
PlainText,
5,
),
NewLeaf(
EscapedChar,
2,
),
NewLeaf(
PlainText,
4,
),
EndNode,
EndNode,
EndNode,
]

View file

@ -18,4 +18,4 @@ default-features = false
features = [ "fs", "ioctl", "process", "signal", "term" ] features = [ "fs", "ioctl", "process", "signal", "term" ]
[dev-dependencies] [dev-dependencies]
insta = "^1.15.0" expect-test = "^1.4.0"

View file

@ -1,6 +1,5 @@
use std::{ use std::{
borrow::Cow, borrow::Cow,
env,
ffi::{OsStr, OsString}, ffi::{OsStr, OsString},
fs::File, fs::File,
io::{BufRead, BufReader, Write}, io::{BufRead, BufReader, Write},
@ -8,7 +7,7 @@ use std::{
process, process,
}; };
use insta::assert_debug_snapshot as assert_snapshot; use expect_test::{expect, Expect};
use nix::{ use nix::{
ioctl_write_int_bad, libc, ioctl_write_int_bad, libc,
pty::{self, OpenptyResult}, pty::{self, OpenptyResult},
@ -16,6 +15,7 @@ use nix::{
unistd::{self, ForkResult}, unistd::{self, ForkResult},
}; };
use oyster_builtin_proc::builtin; use oyster_builtin_proc::builtin;
use oyster_parser::ast;
use oyster_runtime::Shell; use oyster_runtime::Shell;
// TODO: test signal return codes // TODO: test signal return codes
@ -68,6 +68,23 @@ where
OsString::from_vec(buf[..buf.len() - 1].to_vec()) OsString::from_vec(buf[..buf.len() - 1].to_vec())
} }
fn check_collect(ast: &ast::Code, expect: Expect) {
let actual = collect_output(|| {
let mut shell = Shell::new().unwrap();
shell.run(ast).unwrap();
});
expect.assert_debug_eq(&actual);
}
fn check_builtin(ast: &ast::Code, expect: Expect) {
let actual = collect_output(|| {
let mut shell = Shell::new().unwrap();
shell.builtins_mut().add(test_builtin);
shell.run(ast).unwrap();
});
expect.assert_debug_eq(&actual);
}
#[test] #[test]
fn simple_command() { fn simple_command() {
let ast = { let ast = {
@ -82,12 +99,12 @@ fn simple_command() {
)]))]) )]))])
}; };
let actual = collect_output(|| { check_collect(
let mut shell = Shell::new().unwrap(); &ast,
shell.run(&ast).unwrap(); expect![[r#"
}); "hi\r\n"
"#]],
assert_snapshot!(actual); );
} }
#[test] #[test]
@ -113,12 +130,12 @@ fn pipeline() {
]))]) ]))])
}; };
let actual = collect_output(|| { check_collect(
let mut shell = Shell::new().unwrap(); &ast,
shell.run(&ast).unwrap(); expect![[r#"
}); "3\r\n"
"#]],
assert_snapshot!(actual); );
} }
#[test] #[test]
@ -136,7 +153,14 @@ fn command_not_found() {
let mut shell = Shell::new().unwrap(); let mut shell = Shell::new().unwrap();
let actual = shell.run(&ast); let actual = shell.run(&ast);
assert_snapshot!(actual); let expect = expect![[r#"
Err(
CommandNotFound(
"this_command_doesnt_exist",
),
)
"#]];
expect.assert_debug_eq(&actual);
} }
#[test] #[test]
@ -153,7 +177,14 @@ fn permission_denied() {
let mut shell = Shell::new().unwrap(); let mut shell = Shell::new().unwrap();
let actual = shell.run(&ast); let actual = shell.run(&ast);
assert_snapshot!(actual); let expect = expect![[r#"
Err(
PermissionDenied(
"/",
),
)
"#]];
expect.assert_debug_eq(&actual);
} }
#[test] #[test]
@ -170,12 +201,12 @@ fn multipart_word() {
)]))]) )]))])
}; };
let actual = collect_output(|| { check_collect(
let mut shell = Shell::new().unwrap(); &ast,
shell.run(&ast).unwrap(); expect![[r#"
}); "hello\r\n"
"#]],
assert_snapshot!(actual); );
} }
#[test] #[test]
@ -189,13 +220,12 @@ fn simple_builtin() {
)]))]) )]))])
}; };
let actual = collect_output(|| { check_builtin(
let mut shell = Shell::new().unwrap(); &ast,
shell.builtins_mut().add(test_builtin); expect![[r#"
shell.run(&ast).unwrap(); "this is a test\r\n"
}); "#]],
);
assert_snapshot!(actual);
} }
#[test] #[test]
@ -218,13 +248,12 @@ fn builtin_redirection() {
]))]) ]))])
}; };
let actual = collect_output(|| { check_builtin(
let mut shell = Shell::new().unwrap(); &ast,
shell.builtins_mut().add(test_builtin); expect![[r#"
shell.run(&ast).unwrap(); "15\r\n"
}); "#]],
);
assert_snapshot!(actual);
} }
#[test] #[test]
@ -249,11 +278,10 @@ fn command_substitution() {
)]))]) )]))])
}; };
let actual = collect_output(|| { check_builtin(
let mut shell = Shell::new().unwrap(); &ast,
shell.builtins_mut().add(test_builtin); expect![[r#"
shell.run(&ast).unwrap(); "hello\r\n"
}); "#]],
);
assert_snapshot!(actual);
} }

View file

@ -1,5 +0,0 @@
---
source: crates/oyster_runtime/tests/it/pipeline.rs
expression: actual
---
"15\r\n"

View file

@ -1,9 +0,0 @@
---
source: crates/oyster_runtime/tests/it/pipeline.rs
expression: actual
---
Err(
CommandNotFound(
"this_command_doesnt_exist",
),
)

View file

@ -1,5 +0,0 @@
---
source: crates/oyster_runtime/tests/it/pipeline.rs
expression: actual
---
"hello\r\n"

View file

@ -1,5 +0,0 @@
---
source: crates/oyster_runtime/tests/it/pipeline.rs
expression: actual
---
"hello\r\n"

View file

@ -1,9 +0,0 @@
---
source: crates/oyster_runtime/tests/it/pipeline.rs
expression: actual
---
Err(
PermissionDenied(
"/",
),
)

View file

@ -1,5 +0,0 @@
---
source: crates/oyster_runtime/tests/it/pipeline.rs
expression: actual
---
"3\r\n"

View file

@ -1,5 +0,0 @@
---
source: crates/oyster_runtime/tests/it/pipeline.rs
expression: actual
---
"this is a test\r\n"

View file

@ -1,5 +0,0 @@
---
source: crates/oyster_runtime/tests/it/pipeline.rs
expression: actual
---
"hi\r\n"

View file

@ -47,7 +47,6 @@
devShell = pkgs.mkShell { devShell = pkgs.mkShell {
nativeBuildInputs = with pkgs; [ nativeBuildInputs = with pkgs; [
cargo-insta
toolchain toolchain
]; ];
}; };