`match' handler now defined in terms of output abstraction

Consequently, now supports `on' clause.
env
Mike Gerwitz 2014-05-13 23:25:27 -04:00
parent 8858a8dce3
commit 914dafc62a
2 changed files with 13 additions and 2 deletions

View File

@ -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 ]]
}

View File

@ -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