Skip to content

Commit d13d46c

Browse files
Add config files and clean up noisy test output (#60)
1 parent 6759a7e commit d13d46c

File tree

5 files changed

+22
-5
lines changed

5 files changed

+22
-5
lines changed

config/config.exs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
import Config
22

33
config :phoenix, :json_library, Jason
4+
5+
import_config "#{config_env()}.exs"

config/dev.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import Config

config/prod.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import Config

config/test.exs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Config
2+
3+
config :logger, level: :warning

test/flame_on/capture/server_test.exs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ defmodule FlameOn.Capture.ServerTest do
77

88
setup do
99
on_exit(fn ->
10-
if Process.whereis(Server) do
11-
Process.exit(Process.whereis(Server), :kill)
12-
Process.sleep(100)
10+
if pid = Process.whereis(Server) do
11+
GenServer.stop(pid, :normal)
1312
end
1413

1514
case ETS.Set.wrap_existing(Server) do
@@ -149,6 +148,7 @@ defmodule FlameOn.Capture.ServerTest do
149148
end
150149

151150
test "handles :out trace message for sleep" do
151+
Logger.configure(level: :debug)
152152
config = build_config()
153153
{:ok, pid} = Server.start(config)
154154

@@ -158,6 +158,8 @@ defmodule FlameOn.Capture.ServerTest do
158158
Process.sleep(10)
159159
end)
160160

161+
Logger.configure(level: :warning)
162+
161163
state = :sys.get_state(pid)
162164

163165
assert length(state.stack) == 2
@@ -167,18 +169,23 @@ defmodule FlameOn.Capture.ServerTest do
167169
end
168170

169171
test "handles :in trace message for sleep" do
172+
Logger.configure(level: :debug)
170173
config = build_config()
171174
{:ok, pid} = Server.start(config)
172175

173-
send(pid, {:trace_ts, self(), :out, {:example, :foo, 0}, {0, 1000, 0}})
174-
Process.sleep(10)
176+
capture_log(fn ->
177+
send(pid, {:trace_ts, self(), :out, {:example, :foo, 0}, {0, 1000, 0}})
178+
Process.sleep(10)
179+
end)
175180

176181
log =
177182
capture_log(fn ->
178183
send(pid, {:trace_ts, self(), :in, {:example, :foo, 0}, {0, 2000, 0}})
179184
Process.sleep(10)
180185
end)
181186

187+
Logger.configure(level: :warning)
188+
182189
state = :sys.get_state(pid)
183190

184191
assert [starter] = state.stack
@@ -188,6 +195,7 @@ defmodule FlameOn.Capture.ServerTest do
188195
end
189196

190197
test "logs trace messages at debug level" do
198+
Logger.configure(level: :debug)
191199
config = build_config()
192200
{:ok, pid} = Server.start(config)
193201

@@ -197,6 +205,8 @@ defmodule FlameOn.Capture.ServerTest do
197205
Process.sleep(10)
198206
end)
199207

208+
Logger.configure(level: :warning)
209+
200210
assert log =~ "flame_on trace: call"
201211
assert log =~ "{:example, :foo, 0}"
202212
end

0 commit comments

Comments
 (0)