1

I am trying to get jenkins to run dialyzer on erlang code but I am having a problem. As we are introducing this into an existing project there are a number of existing errors that we don't want to flag, which we have in the file dialyzer-ignore-warnings

I have this in my makefile, but what I really want it to do is to return 0 if the grep returns an empty document and a value if there are new errors. But my script-fu is just not up to it

(DEPS_PLT): compile
    @echo Building local plt at $(DEPS_PLT)
    @echo 
    @(echo "Using Dialyzer in `which dialyzer`"; dialyzer --output_plt $(DEPS_PLT) --build_plt --apps  $(DEPS))


dialyzer: compile $(DEPS_PLT)
    @(echo "Using Dialyzer in `which dialyzer`"; dialyzer --fullpath --plt $(DEPS_PLT) -Wrace_conditions -r ./ebin)|\
    fgrep -v -f ./dialyzer-ignore-warnings
Zachary K
  • 3,205
  • 1
  • 29
  • 36
  • `grep` returns zero if any lines are printed out and non-zero if no lines are printed out. Is that not what you want? – Etan Reisner Jan 13 '15 at 14:15

2 Answers2

2

Something like this, perhaps:

dialyzer: compile $(DEPS_PLT)
    @echo "Using Dialyzer in `which dialyzer`"
    @(dialyzer --fullpath --plt $(DEPS_PLT) -Wrace_conditions -r ./ebin)|\
    fgrep -v -f ./dialyzer-ignore-warnings; test "$$?" != 0

That is, ensure that the exit code from fgrep is not zero.

legoscia
  • 39,593
  • 22
  • 116
  • 167
1

Here is a similar solution from rebar's repository:

Makefile contains:

dialyzer: dialyzer_warnings
    @diff -U0 dialyzer_reference dialyzer_warnings

dialyzer_warnings:
    -@dialyzer -q -nn -n ebin -Wunmatched_returns -Werror_handling \
        -Wrace_conditions > dialyzer_warnings

Reference file contains:

rebar_eunit.erl:388: Call to missing or unexported function eunit_test:function_wrapper/2
rebar_utils.erl:163: Call to missing or unexported function escript:foldl/3
aronisstav
  • 7,755
  • 5
  • 23
  • 48