Skip to content
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

Closed
wants to merge 2 commits into from
Closed

add multiline test script #65

wants to merge 2 commits into from

Conversation

wolfv
Copy link
Member

@wolfv wolfv commented Sep 7, 2024

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 or zsh behavior :)

@Hofer-Julian
Copy link
Contributor

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") }
Copy link
Collaborator

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)+ }
Copy link
Collaborator

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.

@prsabahrami
Copy link
Collaborator

I think we can close this because of we now support building tests from scripts in scripts/ folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants