25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-24 17:29:28 +01:00

Add logger macro to help troubleshooting Elixir tests

This commit is contained in:
Mickael Remond 2016-04-01 11:11:42 +02:00
parent 97d345d287
commit a8f92ae767
2 changed files with 40 additions and 0 deletions

View File

@ -34,3 +34,10 @@
-define(CRITICAL_MSG(Format, Args),
lager:critical(Format, Args)).
%% Use only when trying to troubleshoot test problem with ExUnit
-define(EXUNIT_LOG(Format, Args),
case lists:keyfind(logger, 1, application:loaded_applications()) of
false -> ok;
_ -> 'Elixir.Logger':bare_log(error, io_lib:format(Format, Args), [?MODULE])
end).

33
test/README-quicktest.md Normal file
View File

@ -0,0 +1,33 @@
# Elixir unit tests
## Running Elixir unit tests
You can run Elixir unit tests with command:
make quicktest
You need to have ejabberd compile with Elixir and tools enabled.
## Troubleshooting test
To help with troubleshooting Elixir tests, we have added a special macro in ejabberd `logger.hrl` include file: ?EXUNIT_LOG
To use this, in test file:
1. in `setup_all, add:
```
Application.start(:logger)
```
2. Enable log capture for the test you want to analyse by adding
`capture_log` tag before test implementation:
```
@tag capture_log: true
```
In the ejabberd code, if `logger.hrl` is included, you can code adds a
EXUNIT_LOG macro:
?EXUNIT_LOG("My debug log:~p ~p", [Arg1, Arg2])