Skip to content
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

Improve zombie_killer compatability #111

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 3 additions & 3 deletions test/mix_test_watch/port_runner/port_runner_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ defmodule MixTestWatch.PortRunnerTest do

expected =
"MIX_ENV=test mix do run -e " <>
"'Application.put_env(:elixir, :ansi_enabled, true);', " <> "test --exclude integration"
"\"Application.put_env(:elixir, :ansi_enabled, true);\", " <> "test --exclude integration"

assert PortRunner.build_tasks_cmds(config) == expected
end
Expand All @@ -20,7 +20,7 @@ defmodule MixTestWatch.PortRunnerTest do

expected =
"MIX_ENV=test iex -S mix do run -e " <>
"'Application.put_env(:elixir, :ansi_enabled, true);', test"
"\"Application.put_env(:elixir, :ansi_enabled, true);\", test"

assert PortRunner.build_tasks_cmds(config) == expected
end
Expand All @@ -30,7 +30,7 @@ defmodule MixTestWatch.PortRunnerTest do

expected =
"MIX_ENV=test mix do run --no-start -e " <>
"'Application.put_env(:elixir, :ansi_enabled, true);', " <>
"\"Application.put_env(:elixir, :ansi_enabled, true);\", " <>
"test --exclude integration --no-start"

assert PortRunner.build_tasks_cmds(config) == expected
Expand Down