 
   test "sort options", context do
     in_tmp context.test, fn ->
-      assert capture_io(fn ->
-        Fprof.run(["-e", "Enum.each(1..5, fn(_) -> MapSet.new end)", "--sort", "acc"])
-      end) =~ ~r(MapSet\.new/0 *5 *\d+\.\d{3} *\d+\.\d{3})
+      expr = "Enum.each(1..5, fn(_) -> MapSet.new end)"
+      assert capture_io(fn -> Fprof.run(["-e",expr, "--sort", "acc"]) end) =~ ~r(MapSet\.new/0 *5 *\d+\.\d{3} *\d+\.\d{3})
 
-      assert capture_io(fn ->
-        Fprof.run(["-e", "Enum.each(1..5, fn(_) -> MapSet.new end)", "--sort", "own"])
-      end) =~ ~r(MapSet\.new/0 *5 *\d+\.\d{3} *\d+\.\d{3})
+      expr = "Enum.each(1..5, fn(_) -> MapSet.new end)"
+      assert capture_io(fn -> Fprof.run(["-e",expr, "--sort", "own"]) end) =~ ~r(MapSet\.new/0 *5 *\d+\.\d{3} *\d+\.\d{3})
     end
   end
 
   test "errors on missing files", context do
     in_tmp context.test, fn ->
-      assert_raise Mix.Error, "No files matched pattern \"non-existent\" given to --require", fn ->
-        capture_io(fn -> Fprof.run ["-r", "non-existent"] end)
-      end
+      message = "No files matched pattern \"non-existent\" given to --require"
 
-      assert_raise Mix.Error, "No files matched pattern \"non-existent\" given to --require", fn ->
-        capture_io(fn -> Fprof.run ["-pr", "non-existent"] end)
-      end
+      assert_raise Mix.Error,message,fn ->
+                     capture_io(fn -> Fprof.run(["-r", "non-existent"]) end)
+                   end
 
+      assert_raise Mix.Error,message,fn ->
+                     capture_io(fn -> Fprof.run(["-pr", "non-existent"]) end)
+                   end
+                   
       assert_raise Mix.Error, "No such file: non-existent", fn ->
-        capture_io(fn -> Fprof.run ["non-existent"] end)
+        capture_io(fn -> Fprof.run(["non-existent"]) end)
       end
 
       File.mkdir_p!("lib")
+
       assert_raise Mix.Error, "No such file: lib", fn ->
-        capture_io(fn -> Fprof.run ["lib"] end)
+        capture_io(fn -> Fprof.run(["lib"]) end)
       end
     end
   end

Code.require_file "../../test_helper.exs", __DIR__

defmodule Mix.Tasks.Profile.FprofTest do
  use MixTest.Case

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

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