Subject: TAP driver fails with DOS line endings

From: Nick Bowler <[email-masked]>
Date: Wed, 29 Jan 2014 11:41:52 -0500

Hi,

I'm using Automake's TAP support for one of my test suites.  One of my
test cases is a TAP producer written in C.  This is causing me troubles
because, when building for a DOS-based system such as w32, the test case
produces ASCII CR+LF line endings.  Automake's TAP driver complains that
there is no plan, even though there is one on the first line -- curiously,
it does print the PASS results.

In case it matters, I am cross-building the test case from a GNU
system using i486-pc-mingw32-gcc and the test suite runs the resulting
program in wine.  So in this case Automake's TAP driver is running on
the build (GNU) system.

I have not been able to find a formal specification[1] of TAP, so I'm
unsure how line endings are supposed to be treated.  Nevertheless, the
"prove" utility included with perl works fine with DOS line endings.

So it would be nice if the tests passed when TAP producers emit DOS line
endings.

Here's an example which can be run on a POSIX-ey system:

  % cat >test.tap <<'EOF'
printf '1..1\xd\xaok 1\xd\xa'
EOF

  % prove --exec /bin/sh test.tap
test.tap .. ok   
All tests successful.
Files=1, Tests=1,  0 wallclock secs ( 0.03 usr +  0.00 sys =  0.03 CPU)
Result: PASS

  % automake/lib/tap-driver.sh --test-name test.tap --log-file test.log --trs-file test.trs -- /bin/sh test.tap
PASS: test.tap 1 
ERROR: test.tap - missing test plan

[1] There's a section[2] in the Automake manual "Links and external
    resources on TAP" but most of the relevant-looking links don't
    appear to work anymore.  In particular http://testanything.org
    has been down for maintenance until "tomorrow" for some time
    now.

[2] https://gnu.org/software/automake/manual/automake.html#Links-and-external-resources-on-TAP

Cheers,
-- 
Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)