From 9e2608ca233dc082dfefec647c5f2d933522cac2 Mon Sep 17 00:00:00 2001 From: Michael Santos Date: Sun, 16 Mar 2014 09:59:30 -0400 Subject: [PATCH] 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). --- test/alcove_tests.erl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/alcove_tests.erl b/test/alcove_tests.erl index 752f1b1..0057ec2 100644 --- a/test/alcove_tests.erl +++ b/test/alcove_tests.erl @@ -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) ].