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:
Joachim Wiberg committed 2022-04-02 10:45:30 +02:00
1 parent 879721839e
commit 6f802a7ff1
8 files changed
+51 -22

No files matched your search

@@ -7,7 +7,8 @@ TEST_DIR=$(dirname "$0")
# shellcheck source=/dev/null # shellcheck source=/dev/null
. "$TEST_DIR/tenv/lib.sh" . "$TEST_DIR/tenv/lib.sh"
test_teardown() { test_teardown()
{
say "Test done $(date)" say "Test done $(date)"
say "Running test teardown." say "Running test teardown."
+2 -1
View File
@@ -7,7 +7,8 @@ TEST_DIR=$(dirname "$0")
# shellcheck source=/dev/null # shellcheck source=/dev/null
. "$TEST_DIR/tenv/lib.sh" . "$TEST_DIR/tenv/lib.sh"
test_teardown() { test_teardown()
{
say "Test done $(date)" say "Test done $(date)"
say "Running test teardown." say "Running test teardown."
+12 -4
View File
@@ -4,31 +4,38 @@
DAEMON="/test_assets/service.sh" DAEMON="/test_assets/service.sh"
PIDFILE="/var/run/service.pid" PIDFILE="/var/run/service.pid"
start() { start()
{
printf 'Starting %s: ' "$DAEMON" printf 'Starting %s: ' "$DAEMON"
start-stop-daemon -S -b -q -p "$PIDFILE" -x "$DAEMON" start-stop-daemon -S -b -q -p "$PIDFILE" -x "$DAEMON"
status=$? status=$?
if [ "$status" -eq 0 ]; then if [ "$status" -eq 0 ]; then
echo "OK" echo "OK"
else else
echo "FAIL" echo "FAIL"
fi fi
return "$status" return "$status"
} }
stop() { stop()
{
printf 'Stopping %s: ' "$DAEMON" printf 'Stopping %s: ' "$DAEMON"
start-stop-daemon -K -q -p "$PIDFILE" start-stop-daemon -K -q -p "$PIDFILE"
status=$? status=$?
if [ "$status" -eq 0 ]; then if [ "$status" -eq 0 ]; then
echo "OK" echo "OK"
else else
echo "FAIL" echo "FAIL"
fi fi
return "$status" return "$status"
} }
restart() { restart()
{
stop stop
sleep 1 sleep 1
start start
@@ -36,7 +43,8 @@ restart() {
case "$1" in case "$1" in
start|stop|restart) start|stop|restart)
"$1";; "$1"
;;
*) *)
echo "Usage: $0 {start|stop|restart}, got $0 $1" echo "Usage: $0 {start|stop|restart}, got $0 $1"
exit 1 exit 1
+2 -1
View File
@@ -8,7 +8,8 @@ TEST_DIR=$(dirname "$0")
# shellcheck source=/dev/null # shellcheck source=/dev/null
. "$TEST_DIR/tenv/lib.sh" . "$TEST_DIR/tenv/lib.sh"
test_teardown() { test_teardown()
{
say "Test done $(date)" say "Test done $(date)"
say "Running test teardown." say "Running test teardown."
+2 -1
View File
@@ -9,7 +9,8 @@ TEST_DIR=$(dirname "$0")
# shellcheck source=/dev/null # shellcheck source=/dev/null
. "$TEST_DIR/tenv/lib.sh" . "$TEST_DIR/tenv/lib.sh"
test_teardown() { test_teardown()
{
say "Test done $(date)" say "Test done $(date)"
say "Running test teardown." say "Running test teardown."
+2 -1
View File
@@ -7,7 +7,8 @@ TEST_DIR=$(dirname "$0")
# shellcheck source=/dev/null # shellcheck source=/dev/null
. "$TEST_DIR/tenv/lib.sh" . "$TEST_DIR/tenv/lib.sh"
test_teardown() { test_teardown()
{
say "Test done $(date)" say "Test done $(date)"
say "Running test teardown." say "Running test teardown."
+2 -1
View File
@@ -7,7 +7,8 @@ TEST_DIR=$(dirname "$0")
# shellcheck source=/dev/null # shellcheck source=/dev/null
. "$TEST_DIR/tenv/lib.sh" . "$TEST_DIR/tenv/lib.sh"
test_teardown() { test_teardown()
{
say "Test done $(date)" say "Test done $(date)"
say "Running test teardown." say "Running test teardown."
+27 -12
View File
@@ -21,26 +21,31 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE. # THE SOFTWARE.
assert_num_children() { assert_num_children()
{
assert "$1 services are running" "$(texec pgrep -P 1 "$2" | wc -l)" -eq "$1" assert "$1 services are running" "$(texec pgrep -P 1 "$2" | wc -l)" -eq "$1"
} }
assert_new_pid() { # shellcheck disable=SC2086
# shellcheck disable=SC2086 assert_new_pid()
{
assert "Finit has registered new PID" "$(texec initctl |grep $1 |awk '{print $1}')" -eq "$(texec cat $2)" assert "Finit has registered new PID" "$(texec initctl |grep $1 |awk '{print $1}')" -eq "$(texec cat $2)"
} }
texec() { # shellcheck disable=SC2154
# shellcheck disable=SC2154 texec()
{
"$TEST_DIR/tenv/exec.sh" "$finit_pid" "$@" "$TEST_DIR/tenv/exec.sh" "$finit_pid" "$@"
} }
pause() { pause()
{
echo "Press any key to continue... " echo "Press any key to continue... "
read -r REPLY read -r REPLY
} }
toggle_finit_debug() { toggle_finit_debug()
{
say 'Toggle finit debug' say 'Toggle finit debug'
texec initctl debug texec initctl debug
sleep 0.5 sleep 0.5
@@ -50,24 +55,30 @@ color_reset='\e[0m'
fg_red='\e[1;31m' fg_red='\e[1;31m'
fg_green='\e[1;32m' fg_green='\e[1;32m'
fg_yellow='\e[1;33m' fg_yellow='\e[1;33m'
log() { log()
{
test=$(basename "$0" ".sh") test=$(basename "$0" ".sh")
printf "\e[2m[%s]\e[0m %b%b%b %s\n" "$test" "$1" "$2" "$color_reset" "$3" printf "\e[2m[%s]\e[0m %b%b%b %s\n" "$test" "$1" "$2" "$color_reset" "$3"
} }
assert() { assert()
{
__assert_msg=$1 __assert_msg=$1
shift shift
if [ ! "$@" ]; then if [ ! "$@" ]; then
log "$fg_red" ✘ "$__assert_msg ($*)" log "$fg_red" ✘ "$__assert_msg ($*)"
return 1 return 1
fi fi
log "$fg_green" ✔ "$__assert_msg" log "$fg_green" ✔ "$__assert_msg"
} }
retry() { retry()
{
__retry_cmd=$1 __retry_cmd=$1
shift shift
case "$#" in case "$#" in
2) 2)
__retry_n=$1 __retry_n=$1
@@ -89,16 +100,20 @@ retry() {
echo "$__retry_cmd_out" && \ echo "$__retry_cmd_out" && \
return 0 return 0
done done
__retry_cmd_exit="$?" __retry_cmd_exit="$?"
echo "$__retry_cmd_out" echo "$__retry_cmd_out"
return "$__retry_cmd_exit" return "$__retry_cmd_exit"
} }
say() { say()
{
log "$fg_yellow" • "$@" log "$fg_yellow" • "$@"
} }
teardown() { teardown()
{
test_status="$?" test_status="$?"
if type test_teardown > /dev/null 2>&1 ; then if type test_teardown > /dev/null 2>&1 ; then