123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- #!/bin/bash
- #shellcheck disable=SC2016,SC1090
-
- . "$TF_DIR/include/subtest.sh"
- . "$TF_DIR/include/tools.sh"
-
- . "$(sfpath)" || tf_exit_error "failed to init shellfu"
- shellfu import jat || tf_exit_error "failed to import jat"
-
- tf_enum_subtests() {
- echo ylog_pass
- echo ylog_fail
- echo ylog_both
- }
-
- rndtoken() {
- head -c 100 /dev/urandom | md5sum | head -c 7
- }
-
- mkhacks() {
- echo '__JAT__SELF_VERSION=0.0.0+TESTED_VERSION'
- echo '__JAT__DETERMINISTIC=true'
- echo ''
- }
-
- mkhead() {
- echo '#!/bin/bash'
- echo ''
- echo '. "$(sfpath)" || exit 3'
- echo 'shellfu import jat'
- echo ''
- mkhacks
- echo ''
- echo "JAT__DIR=$PWD/result/$name/dir"
- echo "JAT__YLOG=$PWD/result/$name/ylog"
- echo ''
- echo 'jat__sinit'
- echo ''
- }
-
- mkbody() {
- #shellcheck disable=SC1003
- case $name in
- ylog_pass)
- echo ' jat__pstartt'
- echo ' jat__cmd -h "true is true" \'
- echo ' true'
- echo ' jat__cmd -h "false is false" -S 1 \'
- echo ' false'
- echo ' jat__pend'
- ;;
- ylog_fail)
- echo ' jat__pstartt'
- echo ' jat__cmd -h "true is false" -S 1 \'
- echo ' true'
- echo ' jat__cmd -h "false is true" -S 0 \'
- echo ' false'
- echo ' jat__pend'
- ;;
- ylog_both)
- echo ' jat__pstartt'
- echo ' jat__cmd -h "true is true" -S 0 \'
- echo ' true'
- echo ' jat__cmd -h "false is true" -S 0 \'
- echo ' false'
- echo ' jat__pend'
- ;;
- esac
- }
-
- mktail() {
- echo ''
- echo 'jat__sfinish'
- }
-
- unveil() {
- #
- # Remove arbitrary values
- #
- sed "
- s/^jat_version: .*$/jat_version: JAT_VERSION/
- "
- }
-
- runtest() {
- mkdir -p "test" "result/$name"
- {
- mkhead
- mkbody
- mktail
- } > "test/$name.sh"
- bash "test/$name.sh" 2>/dev/null
- < "result/$name/ylog" unveil
- }
-
-
- tf_do_subtest() {
- local name=$1
- local o_out=oracle/$name.stdout
- local o_err=oracle/$name.stderr
- tf_testflt -n "$name" -E "$o_err" -O "$o_out" runtest
- }
-
- tf_do_subtests
|