-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add multiline test script #65
Conversation
Would be good to tackle #50, so that this is actually checked in CI |
)* } | ||
|
||
UNQUOTED_ESCAPE_CHAR = ${ ("\\" ~ "$" | "$" ~ !"(" ~ !VARIABLE) | "\\" ~ (" " | "`" | "\"" | "(" | ")")* } | ||
QUOTED_ESCAPE_CHAR = ${ "\\" ~ "$" | "$" ~ !"(" ~ !VARIABLE | "\\" ~ ("`" | "\"" | "(" | ")" | "'")* } | ||
QUOTED_ESCAPE_CHAR = @{ "\\" ~ ("$" | "`" | "\"" | "(" | ")" | "'" | "\n" | "\r\n") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason behind adding "$" ~ !"(" ~ !VARIABLE
to QUOTED_ESCAPE_CHAR
was since bash parses $
as is when not followed by a variable, subcommand or brace_group - we need to add support for brace_groups later as well.
For example:
echo "$"
prints the same value as echo \$
"
@@ -203,8 +202,8 @@ filename = _{ FILE_NAME_PENDING_WORD } | |||
io_here = !{ (DLESS | DLESSDASH) ~ here_end } | |||
here_end = @{ ("\"" ~ UNQUOTED_PENDING_WORD ~ "\"") | UNQUOTED_PENDING_WORD } | |||
|
|||
newline_list = _{ NEWLINE+ } | |||
linebreak = _{ NEWLINE* } | |||
newline_list = _{ (NEWLINE | ESCAPED_NEWLINE)+ } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pest automatically parses WHITESPACE
between every ~
or repetition of +
or *
. Since ESCAPED_NEWLINE
is being checked in WHITESPACE
, I don't think it is necessary to check ESCAPED_NEWLINE
here once more.
Same goes for the line below.
I think we can close this because of we now support building tests from scripts in |
I added a test script that currently also does not parse completely right.
When we have open quotes, we should continue parsing things (and add the
\n
into the string.When we have a
\
escape, then the\n
should not be part of the string.Luckily it's easy to test this against
bash
orzsh
behavior :)