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

Romain Lenglet romain.lenglet@REDACTED
Wed Dec 16 13:21:40 CET 2009


Unfortunately, init:stop/1 is relatively new, and older versions of OTP 
have only init:stop/0. To be compatible with older versions of OTP, you 
have only two choices:

- call halt/1, which does not flush the standard output (which is an 
important drawback in the case of EUnit, as the test's output is often 
essential for debugging and is often truncated when calling halt/1 just 
after a test);

- call init:stop/0, which always exits with code 0 but flushes the 
standard output; in that case, you have to transmit the result of the 
test through other means, e.g. by writing a result code into a file with 
file:write(), etc. and handle it in the calling script or Makefile.

I use the latter solution in the integration of EUnit into 
Autoconf/Autotest. You may want to use that solution:
http://www.berabera.info/en/node/194

BR,
--
Romain Lenglet

Angel Alvarez wrote:
> El Miércoles, 16 de Diciembre de 2009 02:06:35 Jeremy Raymond escribió:
>> 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?
>>
>>
>> Thanks,
>>
>> Jeremy
>>
> 
> Also
> 
> sinosuke@REDACTED:~/Tmp/kt> erl -noshell -eval "erlang:halt(0)" && echo Ok
> Ok
> 
> sinosuke@REDACTED:~/Tmp/kt> erl -noshell -eval "erlang:halt(1)" && echo Ok
> 
> 
> And using init:stop you allow apps to shutdown nicely...
> 
> 
> sinosuke@REDACTED:~/Tmp/kt> erl -noshell -eval "init:stop(0)" && echo Ok
> Ok
> 
> sinosuke@REDACTED:~/Tmp/kt> erl -noshell -eval "init:stop(1)" && echo Ok
> 
> 


More information about the erlang-questions mailing list