assert[Not]Contains can't match values that start with "-"
RangerRick opened this issue · comments
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)