Run dialyzer over the tests of a library, with macros?

I am trying to fix dialyzer warnings that occur when using OK

The core library code has several macros that are not expanded within the context of the library.
I would like to run dialyzer over the tests, where the macros are expanded, so I can check the generated code doesn’t create compiler warning.

Is this a sensible way to check a library doesn’t generate compiler warnings?

1 Like

As tests usually are exs files they don’t produce BEAM files.but dialyzer needs those to analyze. So I’m not sure if that’s easily possible at all…

Phoenix adds test/support to elixirc_paths for test assets that need to be compiled - so that may be an avenue worth exploring.

1 Like

I still have not tried it, but there is an article about how to do this.

I’d like to figure out a good way to provide first-class support for this in dialyxir. I think one of the largest remaining issues with using dialyzer in Elixir is that so many libraries do not have good coverage of their own specs, because they do not consume their own specs anywhere except for in tests, which are not dialyzed. I get lots of issues opened that are due to broken specs in various libraries.

3 Likes