From cf70249c2a41e85863f3369ca0a8516e6726ccf3 Mon Sep 17 00:00:00 2001 From: DominikWolek Date: Wed, 7 Feb 2024 12:14:13 +0100 Subject: [PATCH] Apply revier suggestions --- .../membrane/integration/child_crash_test.exs | 19 ++++++++++--------- test/support/child_crash_test/pipeline.ex | 10 +++++----- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/test/membrane/integration/child_crash_test.exs b/test/membrane/integration/child_crash_test.exs index af1125089..da423a5ca 100644 --- a/test/membrane/integration/child_crash_test.exs +++ b/test/membrane/integration/child_crash_test.exs @@ -67,20 +67,21 @@ defmodule Membrane.Integration.ChildCrashTest do assert_pipeline_crash_group_down(pipeline_pid, 1) end - test "Pipeline receive correct crash reason" do - Process.flag(:trap_exit, true) - - pipeline_pid = Testing.Pipeline.start_link_supervised!(module: ChildCrashTest.Pipeline) - + test "Pipeline receives correct crash reason" do + pipeline_pid = Testing.Pipeline.start_supervised!(module: ChildCrashTest.Pipeline) ChildCrashTest.Pipeline.add_path(pipeline_pid, [], :source, 1, :group_1) - [source_pid] = [:source] |> Enum.map(&get_pid_and_link(&1, pipeline_pid)) + # time for pipeline to start :source + Process.sleep(100) - ChildCrashTest.Pipeline.inform_about_details_in_case_of_crash(pipeline_pid, self()) + ChildCrashTest.Pipeline.inform_about_details_in_case_of_crash(pipeline_pid) - Process.exit(source_pid, :crash) + Testing.Pipeline.get_child_pid!(pipeline_pid, :source) + |> Process.exit(:custom_crash_reason) + + assert_receive {:crash, crash_reason: :custom_crash_reason} - assert_receive({:crash, reason: :crash}) + Testing.Pipeline.terminate(pipeline_pid) end test "Crash group consisting of bin crashes" do diff --git a/test/support/child_crash_test/pipeline.ex b/test/support/child_crash_test/pipeline.ex index 14d8ba4f9..6761a67c1 100644 --- a/test/support/child_crash_test/pipeline.ex +++ b/test/support/child_crash_test/pipeline.ex @@ -40,8 +40,8 @@ defmodule Membrane.Support.ChildCrashTest.Pipeline do end @impl true - def handle_crash_group_down(_group_name, %{reason: reason}, %{send_to: pid} = state) do - send(pid, {:crash, reason: reason}) + def handle_crash_group_down(_group_name, %{crash_reason: crash_reason}, %{send_to: pid} = state) do + send(pid, {:crash, crash_reason: crash_reason}) {[], state} end @@ -109,8 +109,8 @@ defmodule Membrane.Support.ChildCrashTest.Pipeline do send(pid, {:create_path, spec}) end - @spec inform_about_details_in_case_of_crash(pid(), pid()) :: any() - def inform_about_details_in_case_of_crash(pid, send_to) do - send(pid, {:inform_about_crash, send_to}) + @spec inform_about_details_in_case_of_crash(pid()) :: any() + def inform_about_details_in_case_of_crash(pid) do + send(pid, {:inform_about_crash, self()}) end end