From d33861ccb44896de57f4722582cd4011b9c55b8b Mon Sep 17 00:00:00 2001 From: Johan Bloemberg Date: Fri, 16 Feb 2018 13:46:08 +0100 Subject: [PATCH] test: Fix augeas test for macOS, improve test debuggability - resolve a discrepancy in augeas behaviour on macOS - on macOS `sed` requires an argument for `-i`. - made the test fail as early as it can - provide information about why the test is failing --- test/shell/augeas-1.sh | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/test/shell/augeas-1.sh b/test/shell/augeas-1.sh index 321d1516..e92bddfa 100755 --- a/test/shell/augeas-1.sh +++ b/test/shell/augeas-1.sh @@ -12,19 +12,34 @@ mkdir -p "${MGMT_TMPDIR}" # run empty graph, with prometheus support $timeout --kill-after=60s 55s "$MGMT" run --tmp-prefix --yaml=augeas-1.yaml & pid=$! + +# kill server on error +trap 'kill -SIGINT "$pid"' EXIT + sleep 10s # let it converge -grep "X11Forwarding no" "${MGMT_TMPDIR}"sshd_config +# make an exception on macOS as augeas behaves differently +if [[ $(uname) == "Darwin" ]] ; then + value=false +else + value=no +fi -sed -i "s/no/yes/" "${MGMT_TMPDIR}"sshd_config +# make it easier to see why the test failed +set -x +cat "${MGMT_TMPDIR}"sshd_config + +grep "X11Forwarding ${value}" "${MGMT_TMPDIR}"sshd_config + +sed -i '' "s/${value}/yes/" "${MGMT_TMPDIR}"sshd_config grep "X11Forwarding yes" "${MGMT_TMPDIR}"sshd_config sleep 10s # Augeas is slow -grep "X11Forwarding no" "${MGMT_TMPDIR}"sshd_config - +grep "X11Forwarding ${value}" "${MGMT_TMPDIR}"sshd_config +trap '' EXIT killall -SIGINT mgmt # send ^C to exit mgmt wait $pid # get exit status exit $?