Skip to content

Commit

Permalink
Improve zombie_killer compatability
Browse files Browse the repository at this point in the history
Problem:
- Combination of zombie_killer and test command quotes are causing
  the unit tests to not run

Solution:
- Remove use of exec in sh script because it is being used incorrectly
- Change command quoting to match what is conventionally used with sh -c
  • Loading branch information
grantwest committed Nov 6, 2019
1 parent cabcb68 commit 6beb46c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/mix_test_watch/port_runner/port_runner.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ defmodule MixTestWatch.PortRunner do

_ ->
Path.join(:code.priv_dir(:mix_test_watch), "zombie_killer")
|> System.cmd(["sh", "-c", command], into: IO.stream(:stdio, :line))
|> System.cmd(["sh", "-c", "'" <> command <> "'"], into: IO.stream(:stdio, :line))
end

:ok
Expand All @@ -40,8 +40,8 @@ defmodule MixTestWatch.PortRunner do

ansi =
case Enum.member?(config.cli_args, "--no-start") do
true -> "run --no-start -e 'Application.put_env(:elixir, :ansi_enabled, true);'"
false -> "run -e 'Application.put_env(:elixir, :ansi_enabled, true);'"
true -> "run --no-start -e \"Application.put_env(:elixir, :ansi_enabled, true);\""
false -> "run -e \"Application.put_env(:elixir, :ansi_enabled, true);\""
end

[config.cli_executable, "do", ansi <> ",", task, args]
Expand Down
6 changes: 3 additions & 3 deletions priv/zombie_killer
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/bin/sh

# Start the program in the background
exec "$@" &
eval "$@" &
pid1=$!

# Silence warnings from here on
exec >/dev/null 2>&1

# Read from stdin in the background and
# kill running program when stdin closes
exec 0<&0 $(
while read; do :; done
0<&0 $(
while read UNUSED ; do :; done
kill -KILL $pid1
) &
pid2=$!
Expand Down

0 comments on commit 6beb46c

Please sign in to comment.