| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | # |
| 3 | # Copyright 2022 G. Branden Robinson |
| 4 | # |
| 5 | # This file is part of groff, the GNU roff typesetting system. |
| 6 | # |
| 7 | # groff is free software; you can redistribute it and/or modify it under |
| 8 | # the terms of the GNU General Public License as published by the Free |
| 9 | # Software Foundation, either version 3 of the License, or (at your |
| 10 | # option) any later version. |
| 11 | # |
| 12 | # groff is distributed in the hope that it will be useful, but WITHOUT |
| 13 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 14 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 15 | # for more details. |
| 16 | # |
| 17 | # You should have received a copy of the GNU General Public License |
| 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | # |
| 20 | |
| 21 | groff="${abs_top_builddir:-.}/test-groff" |
| 22 | |
| 23 | input='.TH foo 1 2022-07-30 "groff test suite" |
| 24 | .SH Name |
| 25 | foo \- frobnicate a bar |
| 26 | .SH Description |
| 27 | Foo. |
| 28 | .TS |
| 29 | L. |
| 30 | bar |
| 31 | .TE |
| 32 | ' |
| 33 | |
| 34 | # Bash strips out an empty line, but that's what we're looking for. |
| 35 | output=$(printfscip-shell system . . printf. "%s" "$input" | "$groff" -t -man -Tascii \ |
| 36 | | sed -n \ |
| 37 | -e '/Foo\./{n;s/^$/FAILURE/;tA;' \ |
| 38 | -e 's/.*/SUCCESS/;:A;' \ |
| 39 | -e 'p;}') |
| 40 | # Here's a tidier version accepted by GNU sed but rejected |
| 41 | # contemptuously by macOS sed. (POSIX doesn't say you _have_ to |
| 42 | # accept semicolons after label ':' and branch 't' commands, so it |
| 43 | # doesn't.) |
| 44 | # sed -n '/Foo\./{n;s/^$/FAILURE/;tA;s/.*/SUCCESS/;:A;p}' |
| 45 | testscip-shell system . . test. "$output" = SUCCESS |
| 46 | |
| 47 | # vim:set ai et sw=4 ts=4 tw=72: |