assert.sh icon indicating copy to clipboard operation
assert.sh copied to clipboard

Fixed race conditions

Open riquito opened this issue 12 years ago • 7 comments
trafficstars

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 avatar Jun 10 '13 12:06 riquito

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 avatar Jun 10 '13 16:06 riquito

The latest commit ( df02b94c5 ) should solve the newline problem

riquito avatar Jun 10 '13 16:06 riquito

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

lehmannro avatar Jun 12 '13 09:06 lehmannro

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.

riquito avatar Jun 12 '13 20:06 riquito

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.

mnothic avatar Nov 13 '13 09:11 mnothic

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.

lehmannro avatar Nov 13 '13 11:11 lehmannro

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.

mnothic avatar Nov 13 '13 17:11 mnothic