[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Make test-mhical pass with BSD yacc.
From: |
Ralph Corderoy |
Subject: |
Re: [PATCH] Make test-mhical pass with BSD yacc. |
Date: |
Sun, 20 Sep 2020 11:04:39 +0100 |
Hi Eric,
> The easiest way to match the output of either Bison or yacc is with
> grep, so introduce a new test helper, check_grep, to facilitate.
...
> -cat >"$expected_err" <<'EOF'
> -mhical: syntax error, unexpected ICAL_COMMA, expecting ICAL_COLON after "
> this line is not folded"
> -EOF
> -
> set +e
> printf %s \
> "BEGIN:VCALENDAR
> @@ -975,7 +971,7 @@ END:VEVENT
> END:VCALENDAR" | TZ=UTC mhical >"$actual" 2>"$actual_err"
> set -e
> check "$expected" "$actual"
> -check "$expected_err" "$actual_err"
> +check_grep 'mhical: syntax error.* " this line is not folded"' "$actual_err"
This changes the test from checking there's exactly one line to checking
that one of the lines matches the regexp.
Given the ‘set -e’ in play,
http://git.savannah.nongnu.org/cgit/nmh.git/tree/test/mhical/test-mhical?id=be5ee307cc4ab5db4387fea8d5f6b8caf748ab31#n958
it could be like some of the other tests and grep directly. Something
like
check "$expected" "$actual"
re='mhical: syntax error.* " this line is not folded"'
grep -q "$re" "$actual_err"
grep -qv "$re" "$actual_err" | grep -q ^ && false
or
test `wc -l <"$actual_err"` -eq 1
But I don't really mind. I suspect check_grep will be little used and
add just another way to do something; more Perl than Python. :-)
Anyone here know why the printf a little earlier is wrapped in
set +e...set -e? Perhaps something to do with the lack of trailing LF?
--
Cheers, Ralph.