Skip to content

Test supervisor has :"$callers" populated with the test pid, but the child process does not #13666

Closed
@InAbsentia

Description

@InAbsentia

Elixir and Erlang/OTP versions

$ elixir --version
Erlang/OTP 27 [erts-15.0] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit]

Elixir 1.17.0 (compiled with Erlang/OTP 27)

Operating system

MacOS 14.5

Current behavior

When starting a GenServer in a test with start_supervised/1, the supervisor has :"$callers" set with the test pid, but the child process does not:

defmodule MyGenServer do
  use GenServer

  def init(_) do
    Process.get()
    |> Keyword.get(:"$ancestors")
    |> List.first()
    |> Process.info(:dictionary)
    |> dbg()

    {:ok, %{}}
  end
end

defmodule MyGenServerTest do
  use ExUnit.Case

  test "fetching data on start" do
    dbg(System.version())
    dbg(self())

    start_supervised!({MyGenServer, []})
  end
end

[test/my_gen_server_test.exs:29: MyGenServerTest."test fetching data on start"/1]
System.version() #=> "1.17.0"

[test/my_gen_server_test.exs:30: MyGenServerTest."test fetching data on start"/1]
self() #=> #PID<0.356.0>

[lib/my_gen_server.ex:44: MyGenServer.init/1]
Process.get() #=> [
  # Child process does *not* have `:"$callers"`
  "$ancestors": [#PID<0.362.0>, #PID<0.356.0>],
  "$initial_call": {MyGenServer, :init, 1}
]
|> Keyword.get(:"$ancestors") #=> [#PID<0.362.0>, #PID<0.356.0>]
|> List.first() #=> #PID<0.362.0>
|> Process.info(:dictionary) #=> {:dictionary,
 [
   # Supervisor does have `:"$callers"` with test pid
   "$callers": [#PID<0.356.0>],
   "$ancestors": [#PID<0.356.0>],
   "$initial_call": {:supervisor, ExUnit.OnExitHandler.Supervisor, 1}
 ]}

Expected behavior

From the discussion in #13252 and the documentation added in #13253, I expected that the child process would have :"$callers" populated with the test process's pid.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions