From 914dafc62a6bd260a536f051f3b4456af6ecdb3c Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Tue, 13 May 2014 23:25:27 -0400 Subject: [PATCH] `match' handler now defined in terms of output abstraction Consequently, now supports `on' clause. --- src/expect-core | 7 +++++-- test/test-expect-core | 8 ++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/expect-core b/src/expect-core index 8f7729b..368c5be 100644 --- a/src/expect-core +++ b/src/expect-core @@ -165,9 +165,12 @@ __expect--output-clause() # in regex(3)) _expect--match() { - shift "$2" - local -r pat="$1" + __expect--output-cmd '__expect--match-do' "$@" +} +__expect--match-do() +{ + local -r pat="$1" [[ "$(cat)" =~ $pat ]] } diff --git a/test/test-expect-core b/test/test-expect-core index 02185ea..bd06b78 100644 --- a/test/test-expect-core +++ b/test/test-expect-core @@ -119,6 +119,14 @@ describe match to succeed end + # by convention, stderr file passed as third argument + it can assert against stderr output + { + expect _expect--match 0 3 /dev/fd/3 "stderr" on stderr + to succeed + } 3< <( echo "test stderr" ) + end + it ignores exit code expect _expect--match 1 2 "foo" <<< "foo" to succeed