From 4533acd41d671cb7f02e48d73edde82d9ddd788d Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Wed, 5 Aug 2026 08:15:58 -0500 Subject: [PATCH] fix: resolve test suite warnings-as-errors failures - conn_case: remove compile-time alias for AccountsFixtures to fix compilation ordering warning - hrdps_client_test: clear global hrdps_cycle_available_fn in test setup so injected http_head takes effect (2 previously failing tests) - test_helper: use Code.ensure_loaded!/1 instead of Code.require_file to avoid redefining module warnings - mix.exs: add test_ignore_filters to suppress Elixir 1.20 test support file warnings --- mix.exs | 1 + .../weather/hrdps_client_test.exs | 14 +++++++++++--- test/test_helper.exs | 18 +++++++++++++----- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/mix.exs b/mix.exs index 99c75df5..5ef546b2 100644 --- a/mix.exs +++ b/mix.exs @@ -17,6 +17,7 @@ defmodule Microwaveprop.MixProject do compilers: [:phoenix_live_view] ++ Mix.compilers(), listeners: [Phoenix.CodeReloader], test_coverage: [summary: [threshold: 85]], + test_ignore_filters: [~r"test/support/"], # Disable protocol consolidation in test so test-only deps # (lazy_html) that implement core protocols (Enumerable) are # dispatched at runtime instead of failing at compile-time diff --git a/test/microwaveprop/weather/hrdps_client_test.exs b/test/microwaveprop/weather/hrdps_client_test.exs index fb8b51d6..ae841877 100644 --- a/test/microwaveprop/weather/hrdps_client_test.exs +++ b/test/microwaveprop/weather/hrdps_client_test.exs @@ -153,12 +153,20 @@ defmodule Microwaveprop.Weather.HrdpsClientTest do describe "cycle_available?/1 (injected http_head)" do setup do - prev = Application.get_env(:microwaveprop, :hrdps_http_head) + prev_head = Application.get_env(:microwaveprop, :hrdps_http_head) + prev_fn = Application.get_env(:microwaveprop, :hrdps_cycle_available_fn) + + # Clear the global cycle_available_fn so cycle_available?/1 falls + # through to probe_cycle/1, which reads the injected http_head. + Application.delete_env(:microwaveprop, :hrdps_cycle_available_fn) on_exit(fn -> - if prev, - do: Application.put_env(:microwaveprop, :hrdps_http_head, prev), + if prev_head, + do: Application.put_env(:microwaveprop, :hrdps_http_head, prev_head), else: Application.delete_env(:microwaveprop, :hrdps_http_head) + + if prev_fn, + do: Application.put_env(:microwaveprop, :hrdps_cycle_available_fn, prev_fn) end) :ok diff --git a/test/test_helper.exs b/test/test_helper.exs index a48c2c1c..f3f0d2c2 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -11,11 +11,19 @@ end # starts lazily compiling the test suite. The parallel compiler workers # inherit the code server state, so loading them here makes them visible # everywhere. -Code.require_file("test/support/data_case.ex") -Code.require_file("test/support/conn_case.ex") -Code.require_file("test/support/fixtures/accounts_fixtures.ex") -Code.require_file("test/support/fixtures/beacons_fixtures.ex") -Code.require_file("test/support/fixtures/contacts_fixtures.ex") +# Use ensure_loaded!/1 (not require_file) because mix compile already +# compiles these into _build — require_file recompiles them redundantly +# and triggers "redefining module" warnings that fail --warnings-as-errors. +Enum.each( + [ + Microwaveprop.DataCase, + MicrowavepropWeb.ConnCase, + Microwaveprop.AccountsFixtures, + Microwaveprop.BeaconsFixtures, + Microwaveprop.ContactsFixtures + ], + &Code.ensure_loaded!/1 +) ExUnit.start()