mirror of
https://github.com/troglobit/finit.git
synced 2026-10-27 12:20:54 +00:00
test: whitespace changes only
Coding style for shell scripts: - Tabs for indent (change in Emacs needed) - Braces on their own line, like C functions Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
879721839e
commit
6f802a7ff1
14 files changed
+216
-187
No files matched your search
+86
-71
@@ -21,103 +21,118 @@
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
|
||||
assert_num_children() {
|
||||
assert "$1 services are running" "$(texec pgrep -P 1 "$2" | wc -l)" -eq "$1"
|
||||
assert_num_children()
|
||||
{
|
||||
assert "$1 services are running" "$(texec pgrep -P 1 "$2" | wc -l)" -eq "$1"
|
||||
}
|
||||
|
||||
assert_new_pid() {
|
||||
# shellcheck disable=SC2086
|
||||
assert "Finit has registered new PID" "$(texec initctl |grep $1 |awk '{print $1}')" -eq "$(texec cat $2)"
|
||||
# shellcheck disable=SC2086
|
||||
assert_new_pid()
|
||||
{
|
||||
assert "Finit has registered new PID" "$(texec initctl |grep $1 |awk '{print $1}')" -eq "$(texec cat $2)"
|
||||
}
|
||||
|
||||
texec() {
|
||||
# shellcheck disable=SC2154
|
||||
"$TEST_DIR/tenv/exec.sh" "$finit_pid" "$@"
|
||||
# shellcheck disable=SC2154
|
||||
texec()
|
||||
{
|
||||
"$TEST_DIR/tenv/exec.sh" "$finit_pid" "$@"
|
||||
}
|
||||
|
||||
pause() {
|
||||
echo "Press any key to continue... "
|
||||
read -r REPLY
|
||||
pause()
|
||||
{
|
||||
echo "Press any key to continue... "
|
||||
read -r REPLY
|
||||
}
|
||||
|
||||
toggle_finit_debug() {
|
||||
say 'Toggle finit debug'
|
||||
texec initctl debug
|
||||
sleep 0.5
|
||||
toggle_finit_debug()
|
||||
{
|
||||
say 'Toggle finit debug'
|
||||
texec initctl debug
|
||||
sleep 0.5
|
||||
}
|
||||
|
||||
color_reset='\e[0m'
|
||||
fg_red='\e[1;31m'
|
||||
fg_green='\e[1;32m'
|
||||
fg_yellow='\e[1;33m'
|
||||
log() {
|
||||
test=$(basename "$0" ".sh")
|
||||
printf "\e[2m[%s]\e[0m %b%b%b %s\n" "$test" "$1" "$2" "$color_reset" "$3"
|
||||
log()
|
||||
{
|
||||
test=$(basename "$0" ".sh")
|
||||
printf "\e[2m[%s]\e[0m %b%b%b %s\n" "$test" "$1" "$2" "$color_reset" "$3"
|
||||
}
|
||||
|
||||
assert() {
|
||||
__assert_msg=$1
|
||||
shift
|
||||
if [ ! "$@" ]; then
|
||||
log "$fg_red" ✘ "$__assert_msg ($*)"
|
||||
return 1
|
||||
fi
|
||||
log "$fg_green" ✔ "$__assert_msg"
|
||||
assert()
|
||||
{
|
||||
__assert_msg=$1
|
||||
shift
|
||||
|
||||
if [ ! "$@" ]; then
|
||||
log "$fg_red" ✘ "$__assert_msg ($*)"
|
||||
return 1
|
||||
fi
|
||||
|
||||
log "$fg_green" ✔ "$__assert_msg"
|
||||
}
|
||||
|
||||
retry() {
|
||||
__retry_cmd=$1
|
||||
shift
|
||||
case "$#" in
|
||||
2)
|
||||
__retry_n=$1
|
||||
__retry_sleep=$2
|
||||
;;
|
||||
1)
|
||||
__retry_n=$1
|
||||
__retry_sleep=0.1
|
||||
;;
|
||||
*)
|
||||
__retry_n=50
|
||||
__retry_sleep=0.1
|
||||
;;
|
||||
esac
|
||||
retry()
|
||||
{
|
||||
__retry_cmd=$1
|
||||
shift
|
||||
|
||||
for _ in $(seq 1 "$__retry_n"); do
|
||||
sleep "$__retry_sleep"
|
||||
__retry_cmd_out=$(eval "$__retry_cmd") && \
|
||||
echo "$__retry_cmd_out" && \
|
||||
return 0
|
||||
done
|
||||
__retry_cmd_exit="$?"
|
||||
echo "$__retry_cmd_out"
|
||||
return "$__retry_cmd_exit"
|
||||
case "$#" in
|
||||
2)
|
||||
__retry_n=$1
|
||||
__retry_sleep=$2
|
||||
;;
|
||||
1)
|
||||
__retry_n=$1
|
||||
__retry_sleep=0.1
|
||||
;;
|
||||
*)
|
||||
__retry_n=50
|
||||
__retry_sleep=0.1
|
||||
;;
|
||||
esac
|
||||
|
||||
for _ in $(seq 1 "$__retry_n"); do
|
||||
sleep "$__retry_sleep"
|
||||
__retry_cmd_out=$(eval "$__retry_cmd") && \
|
||||
echo "$__retry_cmd_out" && \
|
||||
return 0
|
||||
done
|
||||
|
||||
__retry_cmd_exit="$?"
|
||||
echo "$__retry_cmd_out"
|
||||
|
||||
return "$__retry_cmd_exit"
|
||||
}
|
||||
|
||||
say() {
|
||||
log "$fg_yellow" • "$@"
|
||||
say()
|
||||
{
|
||||
log "$fg_yellow" • "$@"
|
||||
}
|
||||
|
||||
teardown() {
|
||||
test_status="$?"
|
||||
teardown()
|
||||
{
|
||||
test_status="$?"
|
||||
|
||||
if type test_teardown > /dev/null 2>&1 ; then
|
||||
test_teardown
|
||||
fi
|
||||
if type test_teardown > /dev/null 2>&1 ; then
|
||||
test_teardown
|
||||
fi
|
||||
|
||||
log "$color_reset" '--' ''
|
||||
if [ "$test_status" -eq 0 ]; then
|
||||
log "$fg_green" 'TEST PASS' ''
|
||||
else
|
||||
log "$fg_red" 'TEST FAIL' ''
|
||||
fi
|
||||
if [ -n "${finit_pid+x}" ]; then
|
||||
texec kill -SIGUSR2 1
|
||||
fi
|
||||
log "$color_reset" '--' ''
|
||||
if [ "$test_status" -eq 0 ]; then
|
||||
log "$fg_green" 'TEST PASS' ''
|
||||
else
|
||||
log "$fg_red" 'TEST FAIL' ''
|
||||
fi
|
||||
if [ -n "${finit_pid+x}" ]; then
|
||||
texec kill -SIGUSR2 1
|
||||
fi
|
||||
|
||||
wait
|
||||
wait
|
||||
|
||||
rm -f "$TENV_ROOT"/running_test.pid
|
||||
rm -f "$TENV_ROOT"/running_test.pid
|
||||
}
|
||||
|
||||
trap teardown EXIT
|
||||
@@ -130,7 +145,7 @@ export TENV_ROOT
|
||||
|
||||
# Setup test environment
|
||||
if [ -n "${DEBUG:-}" ]; then
|
||||
FINIT_ARGS="${FINIT_ARGS:-} finit.debug=on"
|
||||
FINIT_ARGS="${FINIT_ARGS:-} finit.debug=on"
|
||||
fi
|
||||
# shellcheck disable=2086
|
||||
"$TEST_DIR/tenv/start.sh" finit ${FINIT_ARGS:-} &
|
||||
|
||||
Reference in new issue
Block a user