From 6e217c2cd909e2868e69b4eb2c268d22a3dc9468 Mon Sep 17 00:00:00 2001 From: Randy Coulman Date: Fri, 20 Sep 2024 22:58:37 -0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Fix=20flickering=20test=20(#114)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use `start_supervised!` for the `DummyRunner` agent to avoid `already_started` errors. --- test/mix_test_interactive/end_to_end_test.exs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/test/mix_test_interactive/end_to_end_test.exs b/test/mix_test_interactive/end_to_end_test.exs index b382f56..36ed203 100644 --- a/test/mix_test_interactive/end_to_end_test.exs +++ b/test/mix_test_interactive/end_to_end_test.exs @@ -7,6 +7,12 @@ defmodule MixTestInteractive.EndToEndTest do defmodule DummyRunner do @moduledoc false + use Agent + + def start_link(test_pid) do + Agent.start_link(fn -> test_pid end, name: __MODULE__) + end + def run(config, args) do Agent.update(__MODULE__, fn test_pid -> send(test_pid, {config, args}) @@ -19,13 +25,12 @@ defmodule MixTestInteractive.EndToEndTest do @settings %Settings{} setup do - test_pid = self() - {:ok, _} = Agent.start_link(fn -> test_pid end, name: DummyRunner) - {:ok, io} = StringIO.open("") Process.group_leader(self(), io) - {:ok, pid} = start_supervised({InteractiveMode, config: @config, name: :end_to_end, settings: @settings}) + _pid = start_supervised!({DummyRunner, self()}) + pid = start_supervised!({InteractiveMode, config: @config, name: :end_to_end, settings: @settings}) + %{pid: pid} end