lehmannro / assert.sh

bash unit testing framework
GNU Lesser General Public License v3.0
486 stars 57 forks source link

Fixed race conditions #4

Open riquito opened 11 years ago

riquito commented 11 years ago

assert.sh fail in a couple cases

1) using assert, if your tested command has as parameter a string with a space separated asterisk then the asterisk will be evaluated by the shell.

2) using assert, if your tested command has as parameter a string with characters that have a special meaning in printf, printf will output something unexpected

I suspect that in assert_raises (eval $1 <<< ${3:-}) > /dev/null 2>&1 should really be written as (eval "$1" <<< ${3:-}) > /dev/null 2>&1

but I can't produce a test case similar to 1)

p.s. I couldn't figure out the meaning of "x required to overwrite older results": is it still needed once printf is gone?

riquito commented 11 years ago

It still fails with assert "echo \"a\nb\"" "a\nb"

result is

test #10 "echo "a\nb"" failed: expected "a\nb" got "a\nb"

This happens with or without my pull request.

It's compairing the literal "a\nb" (4 letters) with "a b" (3 letters) (the error message doesn't help here)

riquito commented 11 years ago

The latest commit ( df02b94c5 ) should solve the newline problem

lehmannro commented 11 years ago

I don't see commit df02b94c5 in this pull request or your repository. Could you recheck if you've pushed it?

riquito commented 11 years ago

It's two days that I wait for github to update the page (via git I see it pushed). Alas, it has finally appeared, you should be able to see it.

mnothic commented 11 years ago

hi I have a problem with this assert bash test.sh test #24 "get_color red" failed: expected "\032[0;31m" got "\033[0;31m" 1 of 25 tests failed in 0.171s.

lehmannro commented 11 years ago

It looks like indeed your expected output and the result are different — one has \032, the other has \033.

For future problems, please also open a new ticket instead of amending an existing, unrelated issue.

mnothic commented 11 years ago

Sorry, my fault, but with the same string still failing

test #24 "get_color red" failed: expected "\033[0;31m" got "\033[0;31m" 1 of 25 tests failed in 0.086s.