[erlang-questions] Failing Makefile build on EUnit test failures

Andrew Thompson <>
Wed Dec 16 02:29:53 CET 2009


On Tue, Dec 15, 2009 at 08:06:35PM -0500, Jeremy Raymond wrote:
> Hello,
> 
> I have a make file that runs my EUnit tests like this:
> 
> eunit: ${EUNIT_OBJ}
>     erl -noshell -pa ebin -eval 'eunit:test(${TEST_MODULES}, [verbose])' -s
> init stop
> 
> What I'd like to happen is have my build fail if any of the eunit tests fail
> however even if tests fail the build suceeds (the command to run the tests
> returns 0?). How can I make my build fail if the tests fail, and pass if the
>tests pass?

Try something like:

erl -noshell -pa ebin -eval 'halt(case eunit:test([module], [verbose]) of ok -> 0; _ -> 1 end).'

Instead? eunit:test() returns ok or error, so we have to map those to
error codes we pass to halt().

Andrew


More information about the erlang-questions mailing list