test: use a match for stderr

The stderr test on linux can return either

<<"nonexistent: not found\n">>

or:

<<"sh: ">>

Probably the shell is using 2 writes to produce the error message, which
may or may not be buffered into one read. Use a pattern match to avoid
the test failing.

Add a separate test for freebsd (untested).
This commit is contained in:
Michael Santos
2014-03-16 09:59:30 -04:00
parent d54bc3f07c
commit 9e2608ca23

View File

@@ -271,10 +271,17 @@ stdout({_, Port, Child}) ->
?_assertEqual(<<"0123456789\n">>, Stdout)
].
stderr({_, Port, Child}) ->
stderr({{unix,linux}, Port, Child}) ->
Reply = alcove:stdin(Port, [Child], "nonexistent 0123456789\n"),
Stderr = alcove:stderr(Port, [Child], 5000),
[
?_assertEqual(true, Reply),
?_assertEqual(<<"sh: nonexistent: not found\n">>, Stderr)
?_assertMatch(<<"sh: ", _/binary>>, Stderr)
];
stderr({{unix,freebsd}, Port, Child}) ->
Reply = alcove:stdin(Port, [Child], "nonexistent 0123456789\n"),
Stderr = alcove:stderr(Port, [Child], 5000),
[
?_assertEqual(true, Reply),
?_assertEqual(<<"nonexistent: not found\n">>, Stderr)
].