Skip to content

Commit 872cc02

Browse files
Ashay Tikekarjosevalim
Ashay Tikekar
authored andcommitted
Run formatter on lib/test/mix/tasks/profile.fprof_test.exs (#6794)
1 parent c358b92 commit 872cc02

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed
Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Code.require_file "../../test_helper.exs", __DIR__
1+
Code.require_file("../../test_helper.exs", __DIR__)
22

33
defmodule Mix.Tasks.Profile.FprofTest do
44
use MixTest.Case
@@ -11,38 +11,37 @@ defmodule Mix.Tasks.Profile.FprofTest do
1111
test "profiles evaluated expression", context do
1212
in_tmp context.test, fn ->
1313
assert capture_io(fn ->
14-
Fprof.run(["-e", "Enum.each(1..5, fn(_) -> MapSet.new end)"])
15-
end) =~ ~r(MapSet\.new/0 *5 *\d+\.\d{3} *\d+\.\d{3})
14+
Fprof.run(["-e", "Enum.each(1..5, fn(_) -> MapSet.new end)"])
15+
end) =~ ~r(MapSet\.new/0 *5 *\d+\.\d{3} *\d+\.\d{3})
1616
end
1717
end
1818

1919
test "profiles the script", context do
2020
in_tmp context.test, fn ->
2121
profile_script_name = "profile_script.ex"
2222

23-
File.write! profile_script_name, """
23+
File.write!(profile_script_name, """
2424
Enum.each(1..5, fn(_) -> MapSet.new end)
25-
"""
25+
""")
2626

2727
assert capture_io(fn ->
28-
Fprof.run([profile_script_name])
29-
end) =~ ~r(MapSet\.new/0 *5 *\d+\.\d{3} *\d+\.\d{3})
28+
Fprof.run([profile_script_name])
29+
end) =~ ~r(MapSet\.new/0 *5 *\d+\.\d{3} *\d+\.\d{3})
3030
end
3131
end
3232

3333
test "expands callers", context do
3434
in_tmp context.test, fn ->
3535
assert capture_io(fn ->
36-
Fprof.run(["-e", "Enum.each(1..5, fn(_) -> MapSet.new end)", "--callers"])
37-
end) =~ ~r(MapSet\.new/0 *5 *\d+\.\d{3} *\d+\.\d{3} +<--)
36+
Fprof.run(["-e", "Enum.each(1..5, fn(_) -> MapSet.new end)", "--callers"])
37+
end) =~ ~r(MapSet\.new/0 *5 *\d+\.\d{3} *\d+\.\d{3} +<--)
3838
end
3939
end
4040

4141
test "expands processes", context do
4242
in_tmp context.test, fn ->
43-
output = capture_io(fn ->
44-
Fprof.run(["-e", "spawn(fn -> Process.sleep(:infinity) end); Enum.each(1..5, fn(_) -> MapSet.new end)", "--details"])
45-
end)
43+
expr = "spawn(fn -> Process.sleep(:infinity) end); Enum.each(1..5, fn(_) -> MapSet.new end)"
44+
output =capture_io(fn -> Fprof.run(["-e",expr,"--details"]) end)
4645
assert output =~ ~r(#{:erlang.pid_to_list(self())} +\d+ +\d+\.\d{3})
4746
assert output =~ ~r(spawned by #{:erlang.pid_to_list(self())})
4847
assert output =~ ~r(as :erlang.apply)
@@ -52,46 +51,47 @@ defmodule Mix.Tasks.Profile.FprofTest do
5251

5352
test "sort options", context do
5453
in_tmp context.test, fn ->
55-
assert capture_io(fn ->
56-
Fprof.run(["-e", "Enum.each(1..5, fn(_) -> MapSet.new end)", "--sort", "acc"])
57-
end) =~ ~r(MapSet\.new/0 *5 *\d+\.\d{3} *\d+\.\d{3})
54+
expr = "Enum.each(1..5, fn(_) -> MapSet.new end)"
55+
assert capture_io(fn -> Fprof.run(["-e",expr, "--sort", "acc"]) end) =~ ~r(MapSet\.new/0 *5 *\d+\.\d{3} *\d+\.\d{3})
5856

59-
assert capture_io(fn ->
60-
Fprof.run(["-e", "Enum.each(1..5, fn(_) -> MapSet.new end)", "--sort", "own"])
61-
end) =~ ~r(MapSet\.new/0 *5 *\d+\.\d{3} *\d+\.\d{3})
57+
expr = "Enum.each(1..5, fn(_) -> MapSet.new end)"
58+
assert capture_io(fn -> Fprof.run(["-e",expr, "--sort", "own"]) end) =~ ~r(MapSet\.new/0 *5 *\d+\.\d{3} *\d+\.\d{3})
6259
end
6360
end
6461

6562
test "errors on missing files", context do
6663
in_tmp context.test, fn ->
67-
assert_raise Mix.Error, "No files matched pattern \"non-existent\" given to --require", fn ->
68-
capture_io(fn -> Fprof.run ["-r", "non-existent"] end)
69-
end
64+
message = "No files matched pattern \"non-existent\" given to --require"
7065

71-
assert_raise Mix.Error, "No files matched pattern \"non-existent\" given to --require", fn ->
72-
capture_io(fn -> Fprof.run ["-pr", "non-existent"] end)
73-
end
66+
assert_raise Mix.Error,message,fn ->
67+
capture_io(fn -> Fprof.run(["-r", "non-existent"]) end)
68+
end
7469

70+
assert_raise Mix.Error,message,fn ->
71+
capture_io(fn -> Fprof.run(["-pr", "non-existent"]) end)
72+
end
73+
7574
assert_raise Mix.Error, "No such file: non-existent", fn ->
76-
capture_io(fn -> Fprof.run ["non-existent"] end)
75+
capture_io(fn -> Fprof.run(["non-existent"]) end)
7776
end
7877

7978
File.mkdir_p!("lib")
79+
8080
assert_raise Mix.Error, "No such file: lib", fn ->
81-
capture_io(fn -> Fprof.run ["lib"] end)
81+
capture_io(fn -> Fprof.run(["lib"]) end)
8282
end
8383
end
8484
end
8585

8686
test "warmup", context do
8787
in_tmp context.test, fn ->
8888
assert capture_io(fn ->
89-
Fprof.run(["-e", "Enum.each(1..5, fn(_) -> MapSet.new end)"])
90-
end) =~ "Warmup..."
89+
Fprof.run(["-e", "Enum.each(1..5, fn(_) -> MapSet.new end)"])
90+
end) =~ "Warmup..."
9191

9292
refute capture_io(fn ->
93-
Fprof.run(["-e", "Enum.each(1..5, fn(_) -> MapSet.new end)", "--no-warmup"])
94-
end) =~ "Warmup..."
93+
Fprof.run(["-e", "Enum.each(1..5, fn(_) -> MapSet.new end)", "--no-warmup"])
94+
end) =~ "Warmup..."
9595
end
9696
end
9797
end

0 commit comments

Comments
 (0)