Elixir 1.5.3: "mix xref callers" does not include tests

I am lately deprecating a legacy module in a project and obviously want all the tooling help I could get.

In the umbrella app I am calling mix xref callers Module.function/1 and it correctly lists the users of the function… except for the several tests that also use it. I tried in dev and test environments, results are the same (I suspect this is highly irrelevant but I tried anyway). I also tried running the command directly inside each of the apps – output still doesn’t include tests.

Is this the intended behavior? Right now I can’t justify using mix xref callers as opposed to a well-crafted grep query.

Apologies if I am missing something very obvious. The official docs do not give me anything extra to work with though. Are there options to include extra directories and/or environments to mix xref?

1 Like

The problem is that mix xref works on compiled modules and tests are not compiled. I’m not sure how this could be solved, though.

1 Like

Makes sense, and ouch. Unit tests are very active users of the modules I want deprecated and evolved – and we absolutely need the tests shown so as to make a safe transition.

1 Like

This might not be the desired answer, but what’s the problem with ignoring the tests and letting them fail when you remove the module? You can just refactor the red ones when the time comes.

1 Like

I guess that can work. Not my way of doing things but the result would be the same.

Only argument against I can think of is that I don’t want to remove the legacy modules immediately. They are slightly complex and I might have missed some of their quirks while refactoring them into the next gen modules. So they have to be around for a while. But nothing stops me from renaming them and still have the tests fail so I can refactor them.

1 Like

Accepting your answer. There’s no other way anyway.