Permalink
Browse files

Fix: fail tests succeed on env failure

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
  • Loading branch information...
mjeanson committed Oct 17, 2017
1 parent 6092c84 commit 60522cafcb9a4df4c017f0ac9ade6066932ec394
View

This file was deleted.

Oops, something went wrong.
View
@@ -20,15 +20,53 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
barectf_assert_file_exists() {
if [ ! -f "$1" ]; then
echo "FATAL: "$1" does not exist" 1>&2
return 1
fi
if ! which barectf > /dev/null; then
echo "FATAL: cannot find barectf tool" 1>&2
return 1
fi
}
barectf_config_check_success() {
pushd "$BATS_TEST_DIRNAME" >/dev/null
if ! barectf_assert_file_exists "$1"; then
popd >/dev/null
return 1
fi
run barectf "$1"
popd >/dev/null
if [ "$status" -ne 0 ]; then
echo "Fail: exit code is $status" 1>&2
return 1
fi
}
barectf_config_check_fail() {
if [ $status -eq 0 ]; then
pushd "$BATS_TEST_DIRNAME" >/dev/null
if ! barectf_assert_file_exists "$1"; then
popd >/dev/null
return 1
fi
run barectf "$1"
if [ "$status" -eq 0 ]; then
echo "Fail: exit code is 0" 1>&2
popd >/dev/null
return 1
fi
pushd "$BATS_TEST_DIRNAME"
local find_output="$(find -iname '*.c' -o -iname '*.h' -o -iname metadata)"
popd
popd >/dev/null
if [ -n "$find_output" ]; then
echo "Fail: barectf generated files" 1>&2
@@ -22,90 +22,72 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
load ../../../common
load ../../common
@test 'unknown property in clock object makes barectf fail' {
barectf_assert_file_exists unknown-prop.yaml
barectf_config_check_fail
barectf_config_check_fail unknown-prop.yaml
}
@test 'wrong "freq" property type in clock object makes barectf fail' {
barectf_assert_file_exists freq-invalid-type.yaml
barectf_config_check_fail
barectf_config_check_fail freq-invalid-type.yaml
}
@test 'invalid "freq" property (0) in clock object makes barectf fail' {
barectf_assert_file_exists freq-0.yaml
barectf_config_check_fail
barectf_config_check_fail freq-0.yaml
}
@test 'invalid "freq" property (negative) in clock object makes barectf fail' {
barectf_assert_file_exists freq-neg.yaml
barectf_config_check_fail
barectf_config_check_fail freq-neg.yaml
}
@test 'wrong "description" property type in clock object makes barectf fail' {
barectf_assert_file_exists description-invalid-type.yaml
barectf_config_check_fail
barectf_config_check_fail description-invalid-type.yaml
}
@test 'wrong "uuid" property type in clock object makes barectf fail' {
barectf_assert_file_exists uuid-invalid-type.yaml
barectf_config_check_fail
barectf_config_check_fail uuid-invalid-type.yaml
}
@test 'invalid "uuid" property in clock object makes barectf fail' {
barectf_assert_file_exists uuid-invalid.yaml
barectf_config_check_fail
barectf_config_check_fail uuid-invalid.yaml
}
@test 'wrong "error-cycles" property type in clock object makes barectf fail' {
barectf_assert_file_exists ec-invalid-type.yaml
barectf_config_check_fail
barectf_config_check_fail ec-invalid-type.yaml
}
@test 'invalid "error-cycles" property in clock object makes barectf fail' {
barectf_assert_file_exists ec-invalid.yaml
barectf_config_check_fail
barectf_config_check_fail ec-invalid.yaml
}
@test 'wrong "offset" property type in clock object makes barectf fail' {
barectf_assert_file_exists offset-invalid-type.yaml
barectf_config_check_fail
barectf_config_check_fail offset-invalid-type.yaml
}
@test 'wrong "absolute" property type in clock object makes barectf fail' {
barectf_assert_file_exists absolute-invalid-type.yaml
barectf_config_check_fail
barectf_config_check_fail absolute-invalid-type.yaml
}
@test 'unknown property in clock offset object makes barectf fail' {
barectf_assert_file_exists offset-unknown-prop.yaml
barectf_config_check_fail
barectf_config_check_fail offset-unknown-prop.yaml
}
@test 'wrong "seconds" property type in clock offset object makes barectf fail' {
barectf_assert_file_exists offset-seconds-invalid-type.yaml
barectf_config_check_fail
barectf_config_check_fail offset-seconds-invalid-type.yaml
}
@test 'invalid "seconds" property in clock offset object makes barectf fail' {
barectf_assert_file_exists offset-seconds-neg.yaml
barectf_config_check_fail
barectf_config_check_fail offset-seconds-neg.yaml
}
@test 'wrong "cycles" property type in clock offset object makes barectf fail' {
barectf_assert_file_exists offset-cycles-invalid-type.yaml
barectf_config_check_fail
barectf_config_check_fail offset-cycles-invalid-type.yaml
}
@test 'invalid "cycles" property in clock offset object makes barectf fail' {
barectf_assert_file_exists offset-cycles-neg.yaml
barectf_config_check_fail
barectf_config_check_fail offset-cycles-neg.yaml
}
@test 'wrong "$return-ctype" property type in clock object makes barectf fail' {
barectf_assert_file_exists rct-invalid-type.yaml
barectf_config_check_fail
barectf_config_check_fail rct-invalid-type.yaml
}
@@ -22,65 +22,52 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
load ../../../common
load ../../common
@test 'unknown property in config object makes barectf fail' {
barectf_assert_file_exists unknown-prop.yaml
barectf_config_check_fail
barectf_config_check_fail unknown-prop.yaml
}
@test 'no "version" property in config object makes barectf fail' {
barectf_assert_file_exists version-no.yaml
barectf_config_check_fail
barectf_config_check_fail version-no.yaml
}
@test 'wrong "version" property type in config object makes barectf fail' {
barectf_assert_file_exists version-invalid-type.yaml
barectf_config_check_fail
barectf_config_check_fail version-invalid-type.yaml
}
@test 'invalid "version" property (1.9) in config object makes barectf fail' {
barectf_assert_file_exists version-invalid-19.yaml
barectf_config_check_fail
barectf_config_check_fail version-invalid-19.yaml
}
@test 'invalid "version" property (2.3) in config object makes barectf fail' {
barectf_assert_file_exists version-invalid-23.yaml
barectf_config_check_fail
barectf_config_check_fail version-invalid-23.yaml
}
@test 'wrong "prefix" property type in config object makes barectf fail' {
barectf_assert_file_exists prefix-invalid-type.yaml
barectf_config_check_fail
barectf_config_check_fail prefix-invalid-type.yaml
}
@test 'no valid C identifier in "prefix" property type in config object makes barectf fail' {
barectf_assert_file_exists prefix-invalid-identifier.yaml
barectf_config_check_fail
barectf_config_check_fail prefix-invalid-identifier.yaml
}
@test 'no "metadata" property in config object makes barectf fail' {
barectf_assert_file_exists metadata-no.yaml
barectf_config_check_fail
barectf_config_check_fail metadata-no.yaml
}
@test 'wrong "metadata" property type in config object makes barectf fail' {
barectf_assert_file_exists metadata-invalid-type.yaml
barectf_config_check_fail
barectf_config_check_fail metadata-invalid-type.yaml
}
@test 'wrong "options" property type in config object makes barectf fail' {
barectf_assert_file_exists options-invalid-type.yaml
barectf_config_check_fail
barectf_config_check_fail options-invalid-type.yaml
}
@test 'wrong "gen-prefix-def" property type in config options object makes barectf fail' {
barectf_assert_file_exists options-gen-prefix-def-invalid-type.yaml
barectf_config_check_fail
barectf_config_check_fail options-gen-prefix-def-invalid-type.yaml
}
@test 'wrong "gen-default-stream-def" property type in config options object makes barectf fail' {
barectf_assert_file_exists options-gen-default-stream-def-invalid-type.yaml
barectf_config_check_fail
barectf_config_check_fail options-gen-default-stream-def-invalid-type.yaml
}
@@ -22,45 +22,36 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
load ../../../common
load ../../common
@test 'unknown property in event object makes barectf fail' {
barectf_assert_file_exists unknown-prop.yaml
barectf_config_check_fail
barectf_config_check_fail unknown-prop.yaml
}
@test 'wrong "log-level" property type in event object makes barectf fail' {
barectf_assert_file_exists ll-invalid-type.yaml
barectf_config_check_fail
barectf_config_check_fail ll-invalid-type.yaml
}
@test 'non existing log level name as "log-level" property value in event object makes barectf fail' {
barectf_assert_file_exists ll-non-existing.yaml
barectf_config_check_fail
barectf_config_check_fail ll-non-existing.yaml
}
@test 'wrong "context-type" property type in event object makes barectf fail' {
barectf_assert_file_exists ct-invalid-type.yaml
barectf_config_check_fail
barectf_config_check_fail ct-invalid-type.yaml
}
@test 'invalid "context-type" property field type (not a structure) in event object makes barectf fail' {
barectf_assert_file_exists ct-not-struct.yaml
barectf_config_check_fail
barectf_config_check_fail ct-not-struct.yaml
}
@test 'wrong "payload-type" property type in event object makes barectf fail' {
barectf_assert_file_exists pt-invalid-type.yaml
barectf_config_check_fail
barectf_config_check_fail pt-invalid-type.yaml
}
@test 'invalid "payload-type" property field type (not a structure) in event object makes barectf fail' {
barectf_assert_file_exists pt-not-struct.yaml
barectf_config_check_fail
barectf_config_check_fail pt-not-struct.yaml
}
@test 'empty event object makes barectf fail' {
barectf_assert_file_exists no-fields-at-all.yaml
barectf_config_check_fail
barectf_config_check_fail no-fields-at-all.yaml
}
@@ -22,43 +22,35 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
load ../../../common
load ../../common
@test 'wrong "$include" property type makes barectf fail' {
barectf_assert_file_exists invalid-type.yaml
barectf_config_check_fail
barectf_config_check_fail invalid-type.yaml
}
@test 'non-existing file in "$include" property (string) makes barectf fail' {
barectf_assert_file_exists file-not-found.yaml
barectf_config_check_fail
barectf_config_check_fail file-not-found.yaml
}
@test 'non-existing absolute file in "$include" property (string) makes barectf fail' {
barectf_assert_file_exists file-not-found-abs.yaml
barectf_config_check_fail
barectf_config_check_fail file-not-found-abs.yaml
}
@test 'non-existing file in "$include" property (array) makes barectf fail' {
barectf_assert_file_exists file-not-found-in-array.yaml
barectf_config_check_fail
barectf_config_check_fail file-not-found-in-array.yaml
}
@test 'non-existing file in "$include" property (recursive) makes barectf fail' {
barectf_assert_file_exists file-not-found-recursive.yaml
barectf_config_check_fail
barectf_config_check_fail file-not-found-recursive.yaml
}
@test 'cycle in include graph makes barectf fail' {
barectf_assert_file_exists cycle.yaml
barectf_config_check_fail
barectf_config_check_fail cycle.yaml
}
@test 'cycle in include graph (with a symbolic link) makes barectf fail' {
local symlink="$BATS_TEST_DIRNAME/inc-recursive-sym3.yaml"
ln -fs inc-recursive-sym1.yaml "$symlink"
barectf_assert_file_exists cycle-sym.yaml
barectf_config_check_fail
barectf_config_check_fail cycle-sym.yaml
rm -f "$symlink"
}
Oops, something went wrong.

0 comments on commit 60522ca

Please sign in to comment.