Add MixUnused.Analyzer test for app: nil branch

This commit is contained in:
Graham McIntire 2026-05-08 17:18:28 -05:00
parent 4560dc0c6f
commit 2b1a06a6cd
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59

View file

@ -104,6 +104,21 @@ defmodule MixUnused.AnalyzerTest do
assert result == []
end
test ":app=nil hits in_app?(_, nil) → true (no filtering)" do
# When app is nil, in_app? returns true for every module — so the
# analyzer scans everything in the compile path, not just the project.
# This exercises line 86 (defp in_app?(_module, nil), do: true).
tmp = Path.join(System.tmp_dir!(), "mu_app_nil_#{System.unique_integer([:positive])}")
File.mkdir_p!(tmp)
try do
result = Analyzer.analyze(app: nil, compile_path: tmp)
assert result == []
after
File.rm_rf(tmp)
end
end
test "honors :compile_path option pointing to an empty directory" do
tmp = Path.join(System.tmp_dir!(), "mu_empty_#{System.unique_integer([:positive])}")
File.mkdir_p!(tmp)