Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix $@ vs $* in MATCH and similar functions #193

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions spread/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<ADDRESS>' || echo \"<ADDRESS $1>\"; }\n")
buf.WriteString("FATAL() { { set +xu; } 2> /dev/null; [ -z \"$1\" ] && echo '<FATAL>' || echo \"<FATAL $@>\"; exit 213; }\n")
buf.WriteString("ERROR() { { set +xu; } 2> /dev/null; [ -z \"$1\" ] && echo '<ERROR>' || echo \"<ERROR $@>\"; 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 '<FATAL>' || echo \"<FATAL $*>\"; exit 213; }\n")
buf.WriteString("ERROR() { { set +xu; } 2> /dev/null; [ -z \"$1\" ] && echo '<ERROR>' || echo \"<ERROR $*>\"; 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")
Expand Down
6 changes: 6 additions & 0 deletions tests/adhoc-fatal/fake/task/task.yaml
Original file line number Diff line number Diff line change
@@ -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"
15 changes: 15 additions & 0 deletions tests/adhoc-fatal/spread.yaml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions tests/adhoc-fatal/task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
summary: Test failure to allocate ad-hoc system

execute: |
spread | MATCH 'I cannot do that, Dave'