diff --git a/lib/membrane/children_spec.ex b/lib/membrane/children_spec.ex index 7507da384..a5120180f 100644 --- a/lib/membrane/children_spec.ex +++ b/lib/membrane/children_spec.ex @@ -452,7 +452,9 @@ defmodule Membrane.ChildrenSpec do via_in(builder, :input) end |> Builder.finish_link(child_name) - |> then(&%Builder{&1 | children: [child_spec | &1.children]}) + |> then(fn %Builder{} = builder -> + %Builder{builder | children: [child_spec | builder.children]} + end) end @doc """ @@ -465,7 +467,9 @@ defmodule Membrane.ChildrenSpec do :ok = validate_pad_name(pad) get_child({Membrane.Bin, :itself}) - |> then(&%Builder{&1 | status: :from_pad, from_pad: pad, from_pad_props: %{}}) + |> then(fn %Builder{} = builder -> + %Builder{builder | status: :from_pad, from_pad: pad, from_pad_props: %{}} + end) end @doc """ @@ -488,7 +492,9 @@ defmodule Membrane.ChildrenSpec do else via_out(builder, :output) end - |> then(&%Builder{&1 | status: :to_pad, to_pad: pad, to_pad_props: %{}}) + |> then(fn %Builder{} = builder -> + %Builder{builder | status: :to_pad, to_pad: pad, to_pad_props: %{}} + end) |> get_child({Membrane.Bin, :itself}) end @@ -541,7 +547,7 @@ defmodule Membrane.ChildrenSpec do "Invalid link specification: input #{inspect(pad)} placed after another input" end - def via_in(%Builder{links: [%{to: {Membrane.Bin, :itself}} | _]}, pad, _props) do + def via_in(%Builder{links: [%{to: {Membrane.Bin, :itself}} | _rest]}, pad, _props) do raise ParentError, "Invalid link specification: input #{inspect(pad)} placed after bin's output" end @@ -572,7 +578,9 @@ defmodule Membrane.ChildrenSpec do else via_out(builder, :output) end - |> then(&%Builder{&1 | status: :to_pad, to_pad: pad, to_pad_props: Enum.into(props, %{})}) + |> then(fn %Builder{} = builder -> + %Builder{builder | status: :to_pad, to_pad: pad, to_pad_props: Enum.into(props, %{})} + end) end @doc """ @@ -598,7 +606,7 @@ defmodule Membrane.ChildrenSpec do raise ParentError, "Invalid link specification: output #{inspect(pad)} placed after an input" end - def via_out(%Builder{links: [%{to: {Membrane.Bin, :itself}} | _]}, pad, _props) do + def via_out(%Builder{links: [%{to: {Membrane.Bin, :itself}} | _rest]}, pad, _props) do raise ParentError, "Invalid link specification: output #{inspect(pad)} placed after bin's output" end diff --git a/lib/membrane/core/child/pad_controller.ex b/lib/membrane/core/child/pad_controller.ex index d3b1a588d..25c8791eb 100644 --- a/lib/membrane/core/child/pad_controller.ex +++ b/lib/membrane/core/child/pad_controller.ex @@ -61,7 +61,7 @@ defmodule Membrane.Core.Child.PadController do map | no_return def parse_pad_options!(pad_name, options, state) do {_pad_name, pad_spec} = - PadSpecHandler.get_pads(state) |> Enum.find(fn {k, _} -> k == pad_name end) + PadSpecHandler.get_pads(state) |> Enum.find(fn {k, _desc} -> k == pad_name end) bunch_field_specs = Bunch.KVList.map_values(pad_spec.options || [], &Keyword.take(&1, [:default])) diff --git a/lib/membrane/core/child/pads_specs.ex b/lib/membrane/core/child/pads_specs.ex index 61e1363b4..a646ab148 100644 --- a/lib/membrane/core/child/pads_specs.ex +++ b/lib/membrane/core/child/pads_specs.ex @@ -340,7 +340,7 @@ defmodule Membrane.Core.Child.PadsSpecs do def generate_docs_from_pads_specs(pads_specs) do pads_docs = pads_specs - |> Enum.sort_by(fn {_, config} -> config[:direction] end) + |> Enum.sort_by(fn {_pad_name, config} -> config[:direction] end) |> Enum.map(&generate_docs_from_pad_specs/1) |> Enum.reduce(fn x, acc -> quote do diff --git a/lib/membrane/core/element.ex b/lib/membrane/core/element.ex index 3631119e9..7d4ffb69b 100644 --- a/lib/membrane/core/element.ex +++ b/lib/membrane/core/element.ex @@ -102,6 +102,10 @@ defmodule Membrane.Core.Element do end end + # Suppress false positive dialyzer warnings resulting from + # broken handling of opaque types - in this case MapSet.t() + # https://github.com/elixir-lang/elixir/issues/14576 + @dialyzer {:nowarn_function, do_init: 1} defp do_init(options) do Process.link(options.parent_supervisor) @@ -141,9 +145,9 @@ defmodule Membrane.Core.Element do state = %State{ module: options.module, - type: options.module.membrane_element_type(), name: options.name, parent_pid: options.parent, + type: options.module.membrane_element_type(), synchronization: %{ parent_clock: options.parent_clock, timers: %{}, diff --git a/lib/membrane/core/element/action_handler.ex b/lib/membrane/core/element/action_handler.ex index e4eb82b7f..c77dbbe5f 100644 --- a/lib/membrane/core/element/action_handler.ex +++ b/lib/membrane/core/element/action_handler.ex @@ -75,13 +75,13 @@ defmodule Membrane.Core.Element.ActionHandler do end @impl CallbackHandler - def handle_action({action, _}, :handle_init, _params, _state) + def handle_action({action, _arg}, :handle_init, _params, _state) when action not in [:latency, :notify_parent] do raise ActionError, action: action, reason: {:invalid_callback, :handle_init} end @impl CallbackHandler - def handle_action({action, _}, _cb, _params, %State{playback: playback}) + def handle_action({action, _arg}, _cb, _params, %State{playback: playback}) when playback != :playing and action in [ :buffer, @@ -291,12 +291,13 @@ defmodule Membrane.Core.Element.ActionHandler do actions |> Bunch.Enum.chunk_by_prev( fn - {:buffer, {pad, _}}, {:buffer, {pad, _}} -> true + {:buffer, {pad, _buffer1}}, {:buffer, {pad, _buffer2}} -> true _prev_action, _action -> false end, fn - [{:buffer, {pad, _}} | _] = buffers -> - {:buffer, {pad, buffers |> Enum.map(fn {_, {_, b}} -> [b] end) |> List.flatten()}} + [{:buffer, {pad, _buffer}} | _rest] = buffers -> + {:buffer, + {pad, buffers |> Enum.map(fn {:buffer, {_pad, b}} -> [b] end) |> List.flatten()}} [other] -> other diff --git a/lib/membrane/core/element/auto_flow_controller.ex b/lib/membrane/core/element/auto_flow_controller.ex index 36c6fc3e1..9621224e6 100644 --- a/lib/membrane/core/element/auto_flow_controller.ex +++ b/lib/membrane/core/element/auto_flow_controller.ex @@ -218,6 +218,10 @@ defmodule Membrane.Core.Element.AutoFlowController do |> Map.put(:popping_auto_flow_queue?, false) end + # Suppress false positive dialyzer warnings resulting from + # broken handling of opaque types - in this case MapSet.t() + # https://github.com/elixir-lang/elixir/issues/14576 + @dialyzer {:nowarn_function, bump_demand: 1} defp bump_demand(state) do if state.effective_flow_control == :pull and state.satisfied_auto_output_pads == @empty_map_set do diff --git a/lib/membrane/core/element/event_controller.ex b/lib/membrane/core/element/event_controller.ex index c3e3a76c4..3496a4673 100644 --- a/lib/membrane/core/element/event_controller.ex +++ b/lib/membrane/core/element/event_controller.ex @@ -5,7 +5,6 @@ defmodule Membrane.Core.Element.EventController do use Bunch - alias Membrane.{Event, Pad, Sync} alias Membrane.Core.{CallbackHandler, Events, Message, Telemetry} alias Membrane.Core.Child.PadModel @@ -19,6 +18,7 @@ defmodule Membrane.Core.Element.EventController do } alias Membrane.Core.Element.ManualFlowController.InputQueue + alias Membrane.{Event, Pad, Sync} require Membrane.Core.Child.PadModel require Membrane.Core.Message diff --git a/lib/membrane/core/element/lifecycle_controller.ex b/lib/membrane/core/element/lifecycle_controller.ex index 1a225ad71..825edabd9 100644 --- a/lib/membrane/core/element/lifecycle_controller.ex +++ b/lib/membrane/core/element/lifecycle_controller.ex @@ -73,7 +73,7 @@ defmodule Membrane.Core.Element.LifecycleController do end @spec handle_playing(State.t()) :: State.t() - def handle_playing(state) do + def handle_playing(%State{} = state) do Membrane.Logger.debug("Got play request") state = diff --git a/lib/membrane/core/element/manual_flow_controller.ex b/lib/membrane/core/element/manual_flow_controller.ex index be20a37d9..038b0486f 100644 --- a/lib/membrane/core/element/manual_flow_controller.ex +++ b/lib/membrane/core/element/manual_flow_controller.ex @@ -80,7 +80,7 @@ defmodule Membrane.Core.Element.ManualFlowController do |> handle_delayed_demands() end - defp do_supply_demand(pad_ref, state) do + defp do_supply_demand(pad_ref, %State{} = state) do # marking is state that actual demand supply has been started (note changing back to false when finished) state = %State{state | delay_demands?: true} @@ -90,7 +90,7 @@ defmodule Membrane.Core.Element.ManualFlowController do InputQueue.take(pad_data.input_queue, pad_data.manual_demand_size) state = PadModel.set_data!(state, pad_ref, :input_queue, new_input_queue) - state = handle_input_queue_output(pad_ref, popped_data, state) + %State{} = state = handle_input_queue_output(pad_ref, popped_data, state) %State{state | delay_demands?: false} end diff --git a/lib/membrane/core/element/playback_queue.ex b/lib/membrane/core/element/playback_queue.ex index 52f6ad91d..e796f4ffa 100644 --- a/lib/membrane/core/element/playback_queue.ex +++ b/lib/membrane/core/element/playback_queue.ex @@ -12,7 +12,8 @@ defmodule Membrane.Core.Element.PlaybackQueue do @spec eval(State.t()) :: State.t() def eval(%State{playback_queue: playback_queue} = state) do - state = + %State{} = + state = playback_queue |> List.foldr(state, fn function, state -> function.(state) end) diff --git a/lib/membrane/core/element/state.ex b/lib/membrane/core/element/state.ex index f3f0a6348..35d1a44b5 100644 --- a/lib/membrane/core/element/state.ex +++ b/lib/membrane/core/element/state.ex @@ -15,15 +15,12 @@ defmodule Membrane.Core.Element.State do @type t :: %__MODULE__{ module: module(), - type: Element.type(), name: Element.name(), + parent_pid: pid(), + playback: Membrane.Playback.t(), + type: Element.type(), internal_state: Element.state() | nil, pads_info: PadModel.pads_info() | nil, - pads_data: PadModel.pads_data() | nil, - parent_pid: pid(), - delay_demands?: boolean(), - delayed_demands: MapSet.t({Pad.ref(), :supply | :redemand}), - handle_demand_loop_counter: non_neg_integer(), synchronization: %{ timers: %{Timer.id() => Timer.t()}, parent_clock: Clock.t(), @@ -31,22 +28,25 @@ defmodule Membrane.Core.Element.State do stream_sync: Sync.t(), clock: Clock.t() | nil }, - auto_input_pads: [Pad.ref()], + delayed_demands: MapSet.t({Pad.ref(), :supply | :redemand}), + effective_flow_control: EffectiveFlowController.effective_flow_control(), initialized?: boolean(), - playback: Membrane.Playback.t(), - playback_queue: Membrane.Core.Element.PlaybackQueue.t(), - resource_guard: Membrane.ResourceGuard.t(), - subprocess_supervisor: pid(), terminating?: boolean(), setup_incomplete_returned?: boolean(), - effective_flow_control: EffectiveFlowController.effective_flow_control(), + delay_demands?: boolean(), popping_auto_flow_queue?: boolean(), - pads_to_snapshot: MapSet.t(), stalker: Membrane.Core.Stalker.t(), + resource_guard: Membrane.ResourceGuard.t(), + subprocess_supervisor: pid(), + handle_demand_loop_counter: non_neg_integer(), + pads_to_snapshot: MapSet.t(), + playback_queue: Membrane.Core.Element.PlaybackQueue.t(), + diamond_detection_state: DiamondDatectionState.t(), + pads_data: PadModel.pads_data() | nil, satisfied_auto_output_pads: MapSet.t(), awaiting_auto_input_pads: MapSet.t(), - resume_delayed_demands_loop_in_mailbox?: boolean(), - diamond_detection_state: DiamondDatectionState.t() + auto_input_pads: [Pad.ref()], + resume_delayed_demands_loop_in_mailbox?: boolean() } # READ THIS BEFORE ADDING NEW FIELD!!! diff --git a/lib/membrane/core/element/stream_format_controller.ex b/lib/membrane/core/element/stream_format_controller.ex index 87f617ff5..a282e90cc 100644 --- a/lib/membrane/core/element/stream_format_controller.ex +++ b/lib/membrane/core/element/stream_format_controller.ex @@ -5,7 +5,6 @@ defmodule Membrane.Core.Element.StreamFormatController do use Bunch - alias Membrane.{Pad, StreamFormat} alias Membrane.Core.{CallbackHandler, Telemetry} alias Membrane.Core.Child.PadModel @@ -18,6 +17,7 @@ defmodule Membrane.Core.Element.StreamFormatController do } alias Membrane.Core.Element.ManualFlowController.InputQueue + alias Membrane.{Pad, StreamFormat} require Membrane.Core.Child.PadModel require Membrane.Core.Telemetry diff --git a/lib/membrane/core/filter_aggregator/context.ex b/lib/membrane/core/filter_aggregator/context.ex index 022c47f6d..8f0e96eb3 100644 --- a/lib/membrane/core/filter_aggregator/context.ex +++ b/lib/membrane/core/filter_aggregator/context.ex @@ -15,6 +15,10 @@ defmodule Membrane.Core.FilterAggregator.Context do @type action :: Element.Action.t() | Membrane.Core.FilterAggregator.InternalAction.t() @spec build_context!(Element.name(), module(), t()) :: t() + # Suppress false positive dialyzer warnings resulting from + # broken handling of opaque types - in this case MapSet.t() + # https://github.com/elixir-lang/elixir/issues/14576 + @dialyzer {:nowarn_function, build_context!: 3} def build_context!(name, module, agg_ctx) do pad_descriptions = module.membrane_pads() pads = pad_descriptions |> MapSet.new(fn {k, _v} -> k end) diff --git a/lib/membrane/core/parent/child_life_controller/crash_group_utils.ex b/lib/membrane/core/parent/child_life_controller/crash_group_utils.ex index 3203dc9e0..aaf8d5f31 100644 --- a/lib/membrane/core/parent/child_life_controller/crash_group_utils.ex +++ b/lib/membrane/core/parent/child_life_controller/crash_group_utils.ex @@ -92,12 +92,14 @@ defmodule Membrane.Core.Parent.ChildLifeController.CrashGroupUtils do update_in( state.crash_groups[group.name], - &%CrashGroup{ - &1 - | detonating?: true, - crash_initiator: crash_initiator, - crash_reason: reason - } + fn %CrashGroup{} = group -> + %CrashGroup{ + group + | detonating?: true, + crash_initiator: crash_initiator, + crash_reason: reason + } + end ) end diff --git a/lib/membrane/core/parent/child_life_controller/link_utils.ex b/lib/membrane/core/parent/child_life_controller/link_utils.ex index 5d56be0b4..48aefe965 100644 --- a/lib/membrane/core/parent/child_life_controller/link_utils.ex +++ b/lib/membrane/core/parent/child_life_controller/link_utils.ex @@ -156,12 +156,14 @@ defmodule Membrane.Core.Parent.ChildLifeController.LinkUtils do links = Enum.map( links, - &%Link{ - &1 - | spec_ref: spec_ref, - from: resolve_endpoint(&1.from, state), - to: resolve_endpoint(&1.to, state) - } + fn %Link{} = link -> + %Link{ + link + | spec_ref: spec_ref, + from: resolve_endpoint(link.from, state), + to: resolve_endpoint(link.to, state) + } + end ) :ok = validate_links(links, state) @@ -235,13 +237,12 @@ defmodule Membrane.Core.Parent.ChildLifeController.LinkUtils do end end - defp resolve_endpoint(endpoint, state) do - %Endpoint{child: child, pad_spec: pad_spec} = endpoint - child_data = Parent.ChildrenModel.get_child_data!(state, child) - pad_name = Pad.name_by_ref(pad_spec) + defp resolve_endpoint(%Endpoint{} = endpoint, state) do + child_data = Parent.ChildrenModel.get_child_data!(state, endpoint.child) + pad_name = Pad.name_by_ref(endpoint.pad_spec) withl pad: {:ok, pad_info} <- Keyword.fetch(child_data.module.membrane_pads(), pad_name), - ref: {:ok, ref} <- make_pad_ref(pad_spec, pad_info.availability) do + ref: {:ok, ref} <- make_pad_ref(endpoint.pad_spec, pad_info.availability) do %Endpoint{ endpoint | pid: child_data.pid, @@ -251,11 +252,12 @@ defmodule Membrane.Core.Parent.ChildLifeController.LinkUtils do } else pad: :error -> - raise LinkError, "Child #{inspect(child)} does not have pad #{inspect(pad_spec)}" + raise LinkError, + "Child #{inspect(endpoint.child)} does not have pad #{inspect(endpoint.pad_spec)}" ref: {:error, :invalid_availability} -> raise LinkError, - "Dynamic pad ref #{inspect(pad_spec)} passed for static pad of child #{inspect(child)}" + "Dynamic pad ref #{inspect(endpoint.pad_spec)} passed for static pad of child #{inspect(endpoint.child)}" end end diff --git a/lib/membrane/core/parent/child_life_controller/startup_utils.ex b/lib/membrane/core/parent/child_life_controller/startup_utils.ex index 766ddf610..0d6872cb7 100644 --- a/lib/membrane/core/parent/child_life_controller/startup_utils.ex +++ b/lib/membrane/core/parent/child_life_controller/startup_utils.ex @@ -172,7 +172,7 @@ defmodule Membrane.Core.Parent.ChildLifeController.StartupUtils do :ok end - defp start_child(child, node, syncs, log_metadata, group, state) do + defp start_child(%ChildEntry{} = child, node, syncs, log_metadata, group, state) do %ChildEntry{name: name, module: module, options: options} = child Membrane.Logger.debug( diff --git a/lib/membrane/core/parent/specification_parser.ex b/lib/membrane/core/parent/specification_parser.ex index 969c4bfc8..ff44f34c2 100644 --- a/lib/membrane/core/parent/specification_parser.ex +++ b/lib/membrane/core/parent/specification_parser.ex @@ -2,9 +2,9 @@ defmodule Membrane.Core.Parent.SpecificationParser do @moduledoc false use Bunch + alias Membrane.{ChildrenSpec, Element, Pad, ParentError} alias Membrane.Core.Parent.Link alias Membrane.Core.Parent.Link.Endpoint - alias Membrane.{ChildrenSpec, Element, Pad, ParentError} require Membrane.Logger @@ -28,7 +28,7 @@ defmodule Membrane.Core.Parent.SpecificationParser do %ChildrenSpec.Builder{links: links, children: children, status: :done} = builder -> if links == [] and children == [] do Membrane.Logger.warning( - "The specification you have passed: #{builder} has no effect - it doesn't produce any children nor links." + "The specification you have passed: #{inspect(builder)} has no effect - it doesn't produce any children nor links." ) end diff --git a/lib/membrane/core/pipeline.ex b/lib/membrane/core/pipeline.ex index a20a5bfe1..6f61fbab5 100644 --- a/lib/membrane/core/pipeline.ex +++ b/lib/membrane/core/pipeline.ex @@ -5,8 +5,8 @@ defmodule Membrane.Core.Pipeline do alias __MODULE__.{ActionHandler, State} alias Membrane.{Clock, ResourceGuard} alias Membrane.Core.{CallbackHandler, ProcessHelper, Stalker, SubprocessSupervisor} - alias Membrane.Core.Pipeline.CallbackContext alias Membrane.Core.Parent.{ChildLifeController, LifecycleController} + alias Membrane.Core.Pipeline.CallbackContext alias Membrane.Core.TimerController require Membrane.Core.Utils, as: Utils diff --git a/lib/membrane/core/timer.ex b/lib/membrane/core/timer.ex index bd4eab23f..d6a8575a0 100644 --- a/lib/membrane/core/timer.ex +++ b/lib/membrane/core/timer.ex @@ -40,7 +40,7 @@ defmodule Membrane.Core.Timer do end @spec update_ratio(t, Clock.ratio()) :: t - def update_ratio(timer, ratio) do + def update_ratio(%__MODULE__{} = timer, ratio) do %__MODULE__{timer | ratio: ratio} end @@ -55,7 +55,7 @@ defmodule Membrane.Core.Timer do timer end - def tick(timer) do + def tick(%__MODULE__{} = timer) do %__MODULE__{ id: id, interval: interval, @@ -89,7 +89,7 @@ defmodule Membrane.Core.Timer do |> tick() end - def set_interval(timer, interval) do + def set_interval(%__MODULE__{} = timer, interval) do %__MODULE__{timer | interval: interval} end end diff --git a/lib/membrane/element/with_input_pads.ex b/lib/membrane/element/with_input_pads.ex index defa5a6f1..fddd78b17 100644 --- a/lib/membrane/element/with_input_pads.ex +++ b/lib/membrane/element/with_input_pads.ex @@ -8,8 +8,8 @@ defmodule Membrane.Element.WithInputPads do For more information on implementing elements, see `Membrane.Element.Base`. """ - alias Membrane.Core.Child.PadsSpecs alias Membrane.{Buffer, Element, Pad} + alias Membrane.Core.Child.PadsSpecs alias Membrane.Element.CallbackContext @doc """ @@ -88,7 +88,7 @@ defmodule Membrane.Element.WithInputPads do PadsSpecs.def_pad(name, :input, spec, element_type) end - defmacro __using__(_) do + defmacro __using__(_element) do quote location: :keep do @behaviour unquote(__MODULE__) diff --git a/lib/membrane/element/with_output_pads.ex b/lib/membrane/element/with_output_pads.ex index 55eaf43fc..63be43e6c 100644 --- a/lib/membrane/element/with_output_pads.ex +++ b/lib/membrane/element/with_output_pads.ex @@ -51,7 +51,7 @@ defmodule Membrane.Element.WithOutputPads do PadsSpecs.def_pad(name, :output, spec, element_type) end - defmacro __using__(_) do + defmacro __using__(_element) do quote location: :keep do @behaviour unquote(__MODULE__) diff --git a/lib/membrane/testing/dynamic_source.ex b/lib/membrane/testing/dynamic_source.ex index b0d6ba96b..536112d1a 100644 --- a/lib/membrane/testing/dynamic_source.ex +++ b/lib/membrane/testing/dynamic_source.ex @@ -121,7 +121,9 @@ defmodule Membrane.Testing.DynamicSource do def handle_demand(pad, _size, :buffers, _ctx, %{type: :enum} = state) do output_for_pad = state.output_for_pad[pad] - if length(output_for_pad) > 0 do + if Enum.empty?(output_for_pad) do + {[end_of_stream: pad], state} + else [payload | rest] = output_for_pad { @@ -131,8 +133,6 @@ defmodule Membrane.Testing.DynamicSource do ], Map.update!(state, :output_for_pad, &Map.put(&1, pad, rest)) } - else - {[end_of_stream: pad], state} end end diff --git a/lib/membrane/testing/pipeline.ex b/lib/membrane/testing/pipeline.ex index b6af8ecf9..4b8975ef4 100644 --- a/lib/membrane/testing/pipeline.ex +++ b/lib/membrane/testing/pipeline.ex @@ -323,8 +323,8 @@ defmodule Membrane.Testing.Pipeline do module when is_atom(module) -> case Code.ensure_compiled(module) do - {:module, _} -> :ok - {:error, _} -> raise "Unknown module: #{inspect(module)}" + {:module, _module} -> :ok + {:error, _error} -> raise "Unknown module: #{inspect(module)}" end new_state = %State{ diff --git a/mix.exs b/mix.exs index 00bd53cd3..99e6d319e 100644 --- a/mix.exs +++ b/mix.exs @@ -17,12 +17,6 @@ defmodule Membrane.Mixfile do source_url: link(), docs: docs(), aliases: [docs: ["docs", ©_assets/1]], - preferred_cli_env: [ - coveralls: :test, - "coveralls.detail": :test, - "coveralls.post": :test, - "coveralls.html": :test - ], test_coverage: [tool: ExCoveralls, test_task: "test"], deps: deps() ] @@ -32,6 +26,17 @@ defmodule Membrane.Mixfile do [extra_applications: [:logger]] end + def cli do + [ + preferred_envs: [ + coveralls: :test, + "coveralls.detail": :test, + "coveralls.post": :test, + "coveralls.html": :test + ] + ] + end + defp elixirc_paths(:test), do: ["lib", "test/support"] defp elixirc_paths(:benchmark), do: ["lib", "benchmark"] defp elixirc_paths(_env), do: ["lib"] @@ -220,7 +225,7 @@ defmodule Membrane.Mixfile do end defp copy_assets(_args) do - File.cp_r("assets", "doc/assets", fn _source, _destination -> true end) + File.cp_r("assets", "doc/assets", on_conflict: fn _source, _destination -> true end) end defp package do diff --git a/mix.lock b/mix.lock index 7c6cad95e..aa6f8b6a0 100644 --- a/mix.lock +++ b/mix.lock @@ -1,12 +1,12 @@ %{ "bunch": {:hex, :bunch, "1.6.1", "5393d827a64d5f846092703441ea50e65bc09f37fd8e320878f13e63d410aec7", [:mix], [], "hexpm", "286cc3add551628b30605efbe2fca4e38cc1bea89bcd0a1a7226920b3364fe4a"}, "bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"}, - "coerce": {:hex, :coerce, "1.0.1", "211c27386315dc2894ac11bc1f413a0e38505d808153367bd5c6e75a4003d096", [:mix], [], "hexpm", "b44a691700f7a1a15b4b7e2ff1fa30bebd669929ac8aa43cffe9e2f8bf051cf1"}, - "credo": {:hex, :credo, "1.7.10", "6e64fe59be8da5e30a1b96273b247b5cf1cc9e336b5fd66302a64b25749ad44d", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "71fbc9a6b8be21d993deca85bf151df023a3097b01e09a2809d460348561d8cd"}, + "coerce": {:hex, :coerce, "1.0.2", "5ef791040c92baaa5dd344887563faaeac6e6742573a167493294f8af3672bbe", [:mix], [], "hexpm", "0b3451c729571234fdac478636c298e71d1f2ce1243abed5fa43fa3181b980eb"}, + "credo": {:hex, :credo, "1.7.14", "c7e75216cea8d978ba8c60ed9dede4cc79a1c99a266c34b3600dd2c33b96bc92", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "12a97d6bb98c277e4fb1dff45aaf5c137287416009d214fb46e68147bd9e0203"}, "dialyxir": {:hex, :dialyxir, "1.4.5", "ca1571ac18e0f88d4ab245f0b60fa31ff1b12cbae2b11bd25d207f865e8ae78a", [:mix], [{:erlex, ">= 0.2.7", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "b0fb08bb8107c750db5c0b324fa2df5ceaa0f9307690ee3c1f6ba5b9eb5d35c3"}, "earmark_parser": {:hex, :earmark_parser, "1.4.44", "f20830dd6b5c77afe2b063777ddbbff09f9759396500cdbe7523efd58d7a339c", [:mix], [], "hexpm", "4778ac752b4701a5599215f7030989c989ffdc4f6df457c5f36938cc2d2a2750"}, "erlex": {:hex, :erlex, "0.2.7", "810e8725f96ab74d17aac676e748627a07bc87eb950d2b83acd29dc047a30595", [:mix], [], "hexpm", "3ed95f79d1a844c3f6bf0cea61e0d5612a42ce56da9c03f01df538685365efb0"}, - "ex_doc": {:hex, :ex_doc, "0.39.1", "e19d356a1ba1e8f8cfc79ce1c3f83884b6abfcb79329d435d4bbb3e97ccc286e", [:mix], [{:earmark_parser, "~> 1.4.44", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "8abf0ed3e3ca87c0847dfc4168ceab5bedfe881692f1b7c45f4a11b232806865"}, + "ex_doc": {:hex, :ex_doc, "0.39.3", "519c6bc7e84a2918b737aec7ef48b96aa4698342927d080437f61395d361dcee", [:mix], [{:earmark_parser, "~> 1.4.44", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "0590955cf7ad3b625780ee1c1ea627c28a78948c6c0a9b0322bd976a079996e1"}, "excoveralls": {:hex, :excoveralls, "0.18.3", "bca47a24d69a3179951f51f1db6d3ed63bca9017f476fe520eb78602d45f7756", [:mix], [{:castore, "~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "746f404fcd09d5029f1b211739afb8fb8575d775b21f6a3908e7ce3e640724c6"}, "file_system": {:hex, :file_system, "1.0.1", "79e8ceaddb0416f8b8cd02a0127bdbababe7bf4a23d2a395b983c1f8b3f73edd", [:mix], [], "hexpm", "4414d1f38863ddf9120720cd976fce5bdde8e91d8283353f0e31850fa89feb9e"}, "jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"}, diff --git a/test/membrane/core/element/input_queue_test.exs b/test/membrane/core/element/input_queue_test.exs index 0bef78f60..8f852fa4a 100644 --- a/test/membrane/core/element/input_queue_test.exs +++ b/test/membrane/core/element/input_queue_test.exs @@ -256,7 +256,7 @@ defmodule Membrane.Core.Element.InputQueueTest do end test "set `size` to 0 when there are not enough buffers", context do - {_, %{size: new_size}} = InputQueue.take(context.input_queue, 10) + {_output, %{size: new_size}} = InputQueue.take(context.input_queue, 10) assert new_size == 0 end diff --git a/test/membrane/core/element/stream_format_controller_test.exs b/test/membrane/core/element/stream_format_controller_test.exs index 766bb01d2..6b9955e1d 100644 --- a/test/membrane/core/element/stream_format_controller_test.exs +++ b/test/membrane/core/element/stream_format_controller_test.exs @@ -2,9 +2,9 @@ defmodule Membrane.Core.Element.StreamFormatControllerTest do use ExUnit.Case, async: true alias Membrane.Buffer - alias Membrane.Core.Message alias Membrane.Core.Element.{AtomicDemand, State} alias Membrane.Core.Element.ManualFlowController.InputQueue + alias Membrane.Core.Message alias Membrane.Core.SubprocessSupervisor alias Membrane.StreamFormat.Mock, as: MockStreamFormat alias Membrane.Support.DemandsTest.Filter diff --git a/test/membrane/integration/stalker_test.exs b/test/membrane/integration/stalker_test.exs index 92ff04047..66e4cab02 100644 --- a/test/membrane/integration/stalker_test.exs +++ b/test/membrane/integration/stalker_test.exs @@ -114,7 +114,7 @@ defmodule Membrane.Integration.StalkerTest do # we should receive some metrics assert_receive {:metrics, metrics, _timestamp}, 2000 - assert length(metrics) > 0 + refute Enum.empty?(metrics) stop_children(pipeline) diff --git a/test/membrane/integration/sync_test.exs b/test/membrane/integration/sync_test.exs index dd1fe6639..cec933df6 100644 --- a/test/membrane/integration/sync_test.exs +++ b/test/membrane/integration/sync_test.exs @@ -4,8 +4,8 @@ defmodule Membrane.Integration.SyncTest do import Membrane.ChildrenSpec import Membrane.Testing.Assertions - alias Membrane.{Testing, Time} alias Membrane.Support.{Sync, TestBins} + alias Membrane.{Testing, Time} alias TestBins.TestFilter @tick_number_error 5 @@ -122,7 +122,7 @@ defmodule Membrane.Integration.SyncTest do assert {:error, reason} = Testing.Pipeline.start_link_supervised(options) - assert {%Membrane.ParentError{}, _} = reason + assert {%Membrane.ParentError{}, _stacktrace} = reason end test "synchronization inside a bin is possible" do diff --git a/test/membrane/integration/sync_test/ticking_pace.exs b/test/membrane/integration/sync_test/ticking_pace.exs index 1c1af3ced..a8c66d433 100644 --- a/test/membrane/integration/sync_test/ticking_pace.exs +++ b/test/membrane/integration/sync_test/ticking_pace.exs @@ -29,7 +29,7 @@ defmodule Membrane.Integration.SyncTest.TickingPace do %{synchronization: %{clock_provider: %{clock: original_clock, provider: :sink}}} = :sys.get_state(pipeline) - for _ <- 1..tries do + for _i <- 1..tries do send(original_clock, {:membrane_clock_update, reported_interval}) Process.sleep(actual_report_interval) end diff --git a/test/membrane/telemetry_test.exs b/test/membrane/telemetry_test.exs index e87e2c060..626ffb211 100644 --- a/test/membrane/telemetry_test.exs +++ b/test/membrane/telemetry_test.exs @@ -103,14 +103,14 @@ defmodule Membrane.TelemetryTest do assert_receive {^ref, :telemetry_ack, {[:membrane, :element, ^span, :start], results, - %{component_path: [_, ^element_type]}}}, + %{component_path: [_pipeline, ^element_type]}}}, 1000 assert results.monotonic_time assert_receive {^ref, :telemetry_ack, {[:membrane, :element, ^span, :stop], results, - %{component_path: [_, ^element_type]} = metadata}}, + %{component_path: [_pipeline, ^element_type]} = metadata}}, 1000 assert results.duration >= 0 @@ -215,14 +215,14 @@ defmodule Membrane.TelemetryTest do from: ":filter", pad_from: ":output", pad_to: ":input", - parent_component_path: _, + parent_component_path: _path, to: ":sink" }, %{ from: ":source", pad_from: ":output", pad_to: ":input", - parent_component_path: _, + parent_component_path: _path, to: ":filter" } ] = Enum.sort([link1.value, link2.value]) @@ -241,7 +241,7 @@ defmodule Membrane.TelemetryTest do test "Buffer", %{child_spec: child_spec} do ref = setup_pipeline_for(:buffer, child_spec) - for _ <- 1..3 do + for _i <- 1..3 do assert_receive {^ref, :telemetry_ack, {[:membrane, :datapoint, :buffer], measurement, metadata}} diff --git a/test/support/child_removal_test/pipeline.ex b/test/support/child_removal_test/pipeline.ex index 9b7c70b35..f9cc11db2 100644 --- a/test/support/child_removal_test/pipeline.ex +++ b/test/support/child_removal_test/pipeline.ex @@ -67,7 +67,7 @@ defmodule Membrane.Support.ChildRemovalTest.Pipeline do defp maybe_add_extra_source(children, _opts), do: children - defp maybe_add_extra_source_link(links, %{extra_source: _}) do + defp maybe_add_extra_source_link(links, %{extra_source: _source}) do [ get_child(:extra_source) |> via_in(:input2, target_queue_size: 10) |> get_child(:filter3) | links