-
Notifications
You must be signed in to change notification settings - Fork 23
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
"No Arguments" descriptor is annoying to use #9
Comments
Hi, thank you for this issue. Yes, the name can be a bit confusing, but it is mainly used within Bach. A better name for this sign would be "empty argument" or "empty string" It happens when we pass an empty string to a command
Another case is we want to assign output from a command to a variable, but we forgot to mock that command
|
I think I get your point. Yes, when people see this strange sign they have no idea what it is. It actually is just an empty string.
Because there is no way to display an empty string on terminal, so I choose this sign to indicate an empty string.
To pass the three failed tests, In addition to mock pipeline commands, just put an empty sting inside assert functions
```
test-pass-an-empty-string() {
foobar ""
}
test-pass-an-empty-string-assert() {
foobar "" # the only argument is an empty string
}
test-forgot-to-mock-a-pipeline-command() {
@mock do-somting
@mock forgot-to-mock-this-command param1 param2
# we must mock all pipeline commands
foobar "$(do-something | forgot-to-mock-this-command param1 param2)"
}
test-forgot-to-mock-a-pipeline-command-assert() {
do-something # Must explicitly verify all commands in the pipeline except for the last one
foobar "" # The last command of the pipeline outputs nothing, just an empty string
}
test-forgot-to-mock-a-command() {
@mock forgot-to-mock-this-command param1 param2 === @stdout ""
foobar "$(forgot-to-mock-this-command param1 param2)"
}
test-forgot-to-mock-a-command-assert() {
foobar ""
}
```
If we forgot to use double quotes, the following test case will pass. But this may involve bugs unless we explicitly know why we don't use double quotes
```
test-forgot-to-mock-a-command-and-without-double-quotes() {
foobar $(forgot-to-mock-this-command param1 param2) # WARNING: no double quotes here
}
test-forgot-to-mock-a-command-and-without-double-quotes-assert() {
forgot-to-mock-this-command param1 param2
foobar
}
```
… On Apr 22, 2022, at 15:14, hanneskaeufler-bmw ***@***.***> wrote:
Hi, thanks for your quick response. Your example is a perfect example of the issue, this happens if you run it:
but it is mainly used within Bach
So that's not true, it immediately bubbles to the end-user, who then has to find an ugly workaround.
Greetings!
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.
|
Aahh thanks again, yeah, so the |
Since 447edb6
there is a visualization for "no arguments passed".
Some tests written against this library before this commit now fail with things like:
Making those tests pass again is annoying, because the descriptor that is to be pushed
into the verification is using a lot of escape sequences.
The only way I found to make those test pass is to
Maybe I'm missing something, but this I don't find ergonomic. Copy&pasting the
sign from terminal into the editor did not work due to the "red" escape sequence
not being copied.
The text was updated successfully, but these errors were encountered: