-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Write function to get child pid in tests #497
Conversation
lib/membrane/testing/utils.ex
Outdated
child_ref = Child.ref(child_name, opts) | ||
|
||
try do | ||
case :sys.get_state(parent_pid) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is meant for debugging purposes and relies on the core internals. Instead, do a normal call to the testing pipeline and make it take the PID from the context.
c37f825
to
1d5fc35
Compare
1d5fc35
to
b93b55e
Compare
fd918c6
to
949855f
Compare
lib/membrane/testing/pipeline.ex
Outdated
try do | ||
GenServer.call(parent_pid, msg) | ||
catch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use Message.call
instead, it handles the case when the process is not alive
lib/membrane/testing/utils.ex
Outdated
msg = Message.new(:get_child_pid, child_ref) | ||
|
||
try do | ||
GenServer.call(parent_pid, msg) | ||
catch | ||
:exit, {:noproc, {GenServer, :call, [^parent_pid, ^msg | _tail]}} -> | ||
{:error, :parent_not_alive} | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use Message.call
lib/membrane/testing/utils.ex
Outdated
""" | ||
@spec get_child_pid(pid(), Child.ref_t()) :: | ||
{:ok, pid()} | {:error, :parent_not_alive | :child_not_found} | ||
def get_child_pid(parent_pid, child_ref) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was to be moved to Membrane.Testing.Pipeline
@@ -0,0 +1,104 @@ | |||
defmodule Membrane.Testing.GetChildPidTest do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now this can be moved to testing pipeline tests
lib/membrane/testing/pipeline.ex
Outdated
If second argument is a child reference, function gets pid of this child | ||
from pipeline. | ||
|
||
Id second argument is a path of child references, function gets pid of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Id second argument is a path of child references, function gets pid of | |
If second argument is a path of child references, function gets pid of |
0137ccf
to
dd39507
Compare
b1143cb
to
7395d02
Compare
Related Jira ticket: https://membraneframework.atlassian.net/browse/MC-134