elixir-lang / elixir

Elixir is a dynamic, functional language for building scalable and maintainable applications
https://elixir-lang.org/
Apache License 2.0
24.51k stars 3.38k forks source link

Cannot use `pry` inside a child app in an umbrella project #8807

Closed pdgonzalez872 closed 5 years ago

pdgonzalez872 commented 5 years ago

Hi!

I'm curious to know if the below is possible:

I want to run tests for a specific app inside an umbrella app and have the tests break("stop") for an IEx.pry call. Either I'm missing a command/don't know how to do it, or there may be a small bug somewhere. This feels like it should work so I decided to create the issue here instead of a the forum. I did search for existing issues, but did not find any.

Here is my elixir version:

umbrella_example :> elixir -v
Erlang/OTP 21 [erts-10.0.5] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe]

Elixir 1.7.2 (compiled with Erlang/OTP 19)

# on OSX

Here is an app that reproduces the behavior:

Here is what I have tried on my machine:

  # from the umbrella's root
  $ mix test # "runs correctly, does not break for pry -> Cannot pry msg, expected."
  $ iex -S mix test # "This works! runs the tests for both apps and correctly breaks for pry"
  # as seen here: https://elixirschool.com/blog/til-umbrella-app-child-app-tests/
  $ mix cmd --app b mix test --color # does not break for pry, expected.
  $ mix cmd --app b iex -S mix test --color # does not break for pry, enters IEx after test suite is run
  $ mix cmd --app iex -S b mix test --color # doesn't return anything, doesn't run anything. odd.
  $ iex -S mix cmd --app b mix test --color # starts IEx after the test suite is run, "Cannot pry msg"

Expected behavior:

I'd like to use the shim() fn in B and have an IEx.pry session there.

Please let me know if there is anything else you'd like to know and I'll provide it. Thanks for all your help as always! ❤️

josevalim commented 5 years ago

mix cmd runs a separate shell command, isolated from the current terminal, so what you want to do is not possible without going into the app and starting it directly, sorry.

pdgonzalez872 commented 5 years ago

Ah, makes sense. Thanks @josevalim!

pdgonzalez872 commented 5 years ago

I did find a solution that works: use a tag in the test you want to run. Eg: iex -S mix test --only tag_to_run

This solves my problem.

pdgonzalez872 commented 5 years ago

@josevalim an update: Seems like 1.9 has solved this problem! So, it is resolved :)

Thanks again!

pdgonzalez872 commented 5 years ago

"Resolved" here means that I was able to run the test I wanted and got the expected behavior since it pauses for IEx.pry not that the fact you mentioned about cmd is now incorrect.

iex -S mix test apps/first_app/test/my_test.exs with a require IEx; IEx.pry breakpoint. -> This works :)

❤️ Thanks again.