diff --git a/spread/client.go b/spread/client.go index 8f5d1ab6..b37e6d2b 100644 --- a/spread/client.go +++ b/spread/client.go @@ -785,10 +785,10 @@ func (s *localScript) run() (stdout, stderr []byte, err error) { var buf bytes.Buffer buf.WriteString("set -eu\n") buf.WriteString("ADDRESS() { { set +xu; } 2> /dev/null; [ -z \"$1\" ] && echo '
' || echo \"
\"; }\n") - buf.WriteString("FATAL() { { set +xu; } 2> /dev/null; [ -z \"$1\" ] && echo '' || echo \"\"; exit 213; }\n") - buf.WriteString("ERROR() { { set +xu; } 2> /dev/null; [ -z \"$1\" ] && echo '' || echo \"\"; exit 213; }\n") - buf.WriteString("MATCH() { { set +xu; } 2> /dev/null; local stdin=$(cat); echo $stdin | grep -q -E \"$@\" || { echo \"error: pattern not found on stdin:\\n$stdin\">&2; return 1; }; }\n") - buf.WriteString("NOMATCH() { { set +xu; } 2> /dev/null; local stdin=$(cat); if echo $stdin | grep -q -E \"$@\"; then echo \"NOMATCH pattern='$@' found in:\n$stdin\">&2; return 1; fi }\n") + buf.WriteString("FATAL() { { set +xu; } 2> /dev/null; [ -z \"$1\" ] && echo '' || echo \"\"; exit 213; }\n") + buf.WriteString("ERROR() { { set +xu; } 2> /dev/null; [ -z \"$1\" ] && echo '' || echo \"\"; exit 213; }\n") + buf.WriteString("MATCH() { { set +xu; } 2> /dev/null; local stdin=$(cat); echo $stdin | grep -q -E \"$*\" || { echo \"error: pattern not found on stdin:\\n$stdin\">&2; return 1; }; }\n") + buf.WriteString("NOMATCH() { { set +xu; } 2> /dev/null; local stdin=$(cat); if echo $stdin | grep -q -E \"$*\"; then echo \"NOMATCH pattern='$*' found in:\n$stdin\">&2; return 1; fi }\n") buf.WriteString("export DEBIAN_FRONTEND=noninteractive\n") buf.WriteString("export DEBIAN_PRIORITY=critical\n") buf.WriteString("export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin\n") diff --git a/tests/adhoc-fatal/fake/task/task.yaml b/tests/adhoc-fatal/fake/task/task.yaml new file mode 100644 index 00000000..bd2e209a --- /dev/null +++ b/tests/adhoc-fatal/fake/task/task.yaml @@ -0,0 +1,6 @@ +summary: fake task +details: | + This task will never execute because the allocation + of the ad-hoc system always fail. +execute: | + echo "Should not be reached" diff --git a/tests/adhoc-fatal/spread.yaml b/tests/adhoc-fatal/spread.yaml new file mode 100644 index 00000000..60ecd1b5 --- /dev/null +++ b/tests/adhoc-fatal/spread.yaml @@ -0,0 +1,15 @@ +project: spread +backends: + adhoc: + allocate: | + FATAL "I cannot do that, Dave" + systems: + - ubuntu-16.04: + +path: /home/adhoc +restore: +suites: + fake/: + summary: Fake test suite + +# vim:ts=4:sw=4:et diff --git a/tests/adhoc-fatal/task.yaml b/tests/adhoc-fatal/task.yaml new file mode 100644 index 00000000..4c162486 --- /dev/null +++ b/tests/adhoc-fatal/task.yaml @@ -0,0 +1,4 @@ +summary: Test failure to allocate ad-hoc system + +execute: | + spread | MATCH 'I cannot do that, Dave'