aprs.me/test/mix/tasks/compile/unused_test.exs
Graham McIntire 4c5c730ee7
Speed up the slowest tests
- packet_replay: stop_replay test reduces fake-task receive timeout from 5s to 200ms
- broadcast_task_supervisor: scheduler_usage takes configurable sample seconds;
  test uses sample-pair API (instant) instead of blocking 1-second sample
- health_check: ask_if_alive timeout is now configurable; unresponsive-pid test
  uses 50ms timeout instead of waiting full 5-second default
- mix_unused/analyzer_test: cache analyze() result in setup_all so 4 tests share
  one analyze pass instead of running 4 separate scans
- mix/tasks/compile/unused_test: consolidate three slow severity tests into one
- log_sanitizer + packet_field_whitelist: cap property-test runs at 25 (was 100)
- historical_loading: trim 200ms post-event sleeps to 50ms
- movement: refute_push_event timeout from 200ms to 50ms

Total suite time: ~45s -> 40.6s; 2488 tests, 0 failures.
2026-05-09 10:56:03 -05:00

45 lines
1.2 KiB
Elixir

defmodule Mix.Tasks.Compile.UnusedTest do
use ExUnit.Case, async: false
alias Mix.Tasks.Compile.Unused
describe "manifests/0" do
test "returns an empty list (no manifest tracking)" do
assert Unused.manifests() == []
end
end
describe "clean/0" do
test "returns :ok" do
assert Unused.clean() == :ok
end
end
describe "run/1" do
test "manifests/0 and clean/0 are idempotent" do
assert Unused.manifests() == Unused.manifests()
assert Unused.clean() == :ok
assert Unused.clean() == :ok
end
test "exercises run/1 across all severity arg variants" do
# Each Unused.run/1 call invokes the analyzer (which scans all BEAMs
# and is the slow part). We exercise every severity branch in a
# single test so we only pay analyze cost a small number of times.
arg_lists = [
[],
["--severity", "error"],
["--severity", "warning"],
["--severity", "info"],
["--severity", "garbage"]
]
ExUnit.CaptureIO.capture_io(fn ->
for args <- arg_lists do
result = Unused.run(args)
assert match?({:ok, _}, result) or match?({:error, _}, result)
end
end)
end
end
end