Last active
October 28, 2018 08:35
-
-
Save photonxp/0ecb2fa47801b1055f940d52c6d06dc7 to your computer and use it in GitHub Desktop.
demo unit test for bash, just personal usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# ####test_testf.bash | |
# #!/bin/bash | |
# | |
# source ./testf.bash | |
# | |
# test1(){ | |
# echo "hello" | |
# } | |
# | |
# test2(){ | |
# echo "world" | |
# } | |
# | |
# run_tests "test1" "test2" | |
init_time_log(){ | |
fpath_log=./time.log | |
if [ -f $fpath_log ] | |
then | |
rm $fpath_log | |
fi | |
touch $fpath_log | |
} | |
log_datetime(){ | |
datef=`date '+%Y%m%d.%H%M%S'` | |
echo "$1$datef" >> $fpath_log | |
} | |
init_script(){ | |
echo_start "Start script $0" | |
init_time_log | |
log_datetime "Start script $0 : " | |
} | |
finish_script(){ | |
echo_start "Finish script $0" | |
log_datetime "Finish script $0 : " | |
} | |
echo_start(){ | |
echo "$1 =============================" | |
} | |
init_test(){ | |
echo_start "Start $1 : " | |
log_datetime "Start $1 : " | |
} | |
finish_test(){ | |
log_datetime "Finish $1 : " | |
} | |
run_tests(){ | |
init_script | |
for test in "$@" | |
do | |
init_test "$test" | |
$test | |
finish_test "$test" | |
done | |
finish_script | |
} | |
test1(){ | |
# call the tested script | |
: | |
} | |
#run_tests "test1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment