提交 490c8859 作者: Konstantin Koroviev 提交者: Juan Batiz-Benet

t0030-mount.sh: improve stdout stderr fail tests

上级 178a64d6
...@@ -276,3 +276,22 @@ test_curl_resp_http_code() { ...@@ -276,3 +276,22 @@ test_curl_resp_http_code() {
cat curl_output cat curl_output
return 1 return 1
} }
test_must_be_empty() {
if test -s "$1"
then
echo "'$1' is not empty, it contains:"
cat "$1"
return 1
fi
}
test_should_contain() {
test "$#" = 2 || error "bug in the test script: not 2 parameters to test_should_contain"
if ! grep -q "$1" "$2"
then
echo "'$2' does not contain '$1', it contains:"
cat "$2"
return 1
fi
}
...@@ -20,14 +20,13 @@ test_launch_ipfs_daemon ...@@ -20,14 +20,13 @@ test_launch_ipfs_daemon
# test mount failure before mounting properly. # test mount failure before mounting properly.
test_expect_success "'ipfs mount' fails when no mount dir" ' test_expect_success "'ipfs mount' fails when there is no mount dir" '
test_must_fail ipfs mount -f=not_ipfs -n=not_ipns >actual test_must_fail ipfs mount -f=not_ipfs -n=not_ipns >output 2>output.err
' '
test_expect_success "'ipfs mount' output looks good when it fails" ' test_expect_success "'ipfs mount' output looks good" '
! grep "IPFS mounted at: $(pwd)/ipfs" actual >/dev/null && test_must_be_empty output &&
! grep "IPNS mounted at: $(pwd)/ipns" actual >/dev/null || test_should_contain "not_ipns\|not_ipfs" output.err
test_fsh cat actual
' '
# now mount properly, and keep going # now mount properly, and keep going
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论