diff options
author | Brad Warren <bmw@eff.org> | 2017-09-30 03:11:10 +0300 |
---|---|---|
committer | Brad Warren <bmw@eff.org> | 2017-09-30 03:11:10 +0300 |
commit | 08ae6f4d06f9cd40a82747fce790b1566e372ed4 (patch) | |
tree | cf73b1e7ec3aa175d03d337c2fa42cc9b180dbb8 /tests | |
parent | cad7d4c8ed95d211ca5e4ebe7488e916d011882b (diff) |
Fix hook test.test-fix-hooks-test
Up until now, this test was written incorrectly. In addition, when it has
failed, it simply prints error messages rather than reporting that the test
failed. This fixes both of these problems.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/boulder-integration.sh | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/tests/boulder-integration.sh b/tests/boulder-integration.sh index 181dcc5fb..a0db749d2 100755 --- a/tests/boulder-integration.sh +++ b/tests/boulder-integration.sh @@ -48,32 +48,30 @@ common() { export HOOK_TEST="/tmp/hook$$" CheckHooks() { - EXPECTED="/tmp/expected$$" - if [ $(head -n1 $HOOK_TEST) = "wtf.pre" ]; then - echo "wtf.pre" > "$EXPECTED" - echo "wtf2.pre" >> "$EXPECTED" - echo "deploy" >> "$EXPECTED" - echo "deploy" >> "$EXPECTED" - echo "deploy" >> "$EXPECTED" - echo "deploy" >> "$EXPECTED" - echo "wtf.post" >> "$EXPECTED" - echo "wtf2.post" >> "$EXPECTED" + if [ $(head -n1 "$HOOK_TEST") = "wtf.pre" ]; then + expected="wtf.pre\ndeploy\n" + if [ $(sed '3q;d' "$HOOK_TEST") = "deploy" ]; then + expected=$expected"deploy\nwtf2.pre\n" + else + expected=$expected"wtf2.pre\ndeploy\n" + fi + expected=$expected"deploy\ndeploy\nwtf.post\nwtf2.post" else - echo "wtf2.pre" > "$EXPECTED" - echo "wtf.pre" >> "$EXPECTED" - echo "deploy" >> "$EXPECTED" - echo "deploy" >> "$EXPECTED" - echo "deploy" >> "$EXPECTED" - echo "deploy" >> "$EXPECTED" - echo "wtf2.post" >> "$EXPECTED" - echo "wtf.post" >> "$EXPECTED" + expected="wtf2.pre\ndeploy\n" + if [ $(sed '3q;d' "$HOOK_TEST") = "deploy" ]; then + expected=$expected"deploy\nwtf.pre\n" + else + expected=$expected"wtf.pre\ndeploy\n" + fi + expected=$expected"deploy\ndeploy\nwtf2.post\nwtf.post" fi - if ! cmp --quiet "$EXPECTED" "$HOOK_TEST" ; then + if ! cmp --quiet <(echo -e "$expected") "$HOOK_TEST" ; then echo Hooks did not run as expected\; got cat "$HOOK_TEST" - echo Expected - cat "$EXPECTED" + echo -e "Expected\n$expected" + rm "$HOOK_TEST" + exit 1 fi rm "$HOOK_TEST" } |