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

assert[Not]Contains can't match values that start with "-" #109

Closed
RangerRick opened this issue Feb 7, 2019 · 0 comments · Fixed by #110
Closed

assert[Not]Contains can't match values that start with "-" #109

RangerRick opened this issue Feb 7, 2019 · 0 comments · Fixed by #110
Milestone

Comments

@RangerRick
Copy link
Contributor

the assertContains and assertNotContains macros both use grep in such a way that the content argument may not start with a - because it is interpreted as an option to grep.

You can reproduce this easily by doing:

#!/bin/sh

testAssertContainsX() {
  assertContains "this should pass but it doesn't" "java -Xmx1g" "-Xmx1g"
}

testAssertContainsD() {
  assertContains "this should pass but it doesn't" "java -Dproperty=true" "-Dproperty=true"
}

. ./shunit2

The output currently is this:

testAssertContainsX
grep: Invalid argument
ASSERT:this should pass but it doesn't Not found:<-Xmx1g>
shunit2:ERROR testAssertContainsX() returned non-zero return code.
testAssertContainsD
grep: unknown --devices option
ASSERT:this should pass but it doesn't Not found:<-Dproperty=true>
shunit2:ERROR testAssertContainsD() returned non-zero return code.

Ran 2 tests.

FAILED (failures=4)
RangerRick pushed a commit to RangerRick/shunit2 that referenced this issue Feb 7, 2019
@kward kward closed this as completed in #110 Feb 9, 2019
kward added a commit that referenced this issue Feb 9, 2019
@kward kward added this to the 2.1.8 milestone Feb 9, 2019
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 a pull request may close this issue.

2 participants