diff options
author | José Valim <jose.valim@plataformatec.com.br> | 2014-05-24 12:32:32 +0200 |
---|---|---|
committer | José Valim <jose.valim@plataformatec.com.br> | 2014-05-24 12:32:39 +0200 |
commit | 6720cb6830ba329c45cf0c3c0224b659497b4366 (patch) | |
tree | 7a6ad76549a9ce272b727783c646634017381ab0 | |
parent | 9337d50775d4be9d61386011f65a38f5ca3ec0dc (diff) | |
download | elixir-6720cb6830ba329c45cf0c3c0224b659497b4366.tar.gz |
Simplify beam writing mechanism
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | lib/elixir/lib/module.ex | 2 | ||||
-rw-r--r-- | lib/elixir/test/common_test_helpers.exs | 38 | ||||
-rw-r--r-- | lib/elixir/test/elixir/fixtures/docs/README | 2 | ||||
-rw-r--r-- | lib/elixir/test/elixir/kernel/docs_test.exs | 30 | ||||
-rw-r--r-- | lib/elixir/test/elixir/protocol_test.exs | 18 | ||||
-rw-r--r-- | lib/elixir/test/elixir/test_helper.exs | 15 | ||||
-rw-r--r-- | lib/ex_unit/test/ex_unit/doc_test_test.exs | 82 | ||||
-rw-r--r-- | lib/ex_unit/test/test_helper.exs | 16 | ||||
-rw-r--r-- | lib/iex/lib/iex/autocomplete.ex | 2 | ||||
-rw-r--r-- | lib/iex/test/iex/helpers_test.exs | 37 | ||||
-rw-r--r-- | lib/iex/test/iex/interaction_test.exs | 20 | ||||
-rw-r--r-- | lib/iex/test/test_helper.exs | 2 | ||||
-rw-r--r-- | lib/mix/test/mix/task_test.exs | 45 | ||||
-rw-r--r-- | lib/mix/test/test_helper.exs | 9 |
15 files changed, 116 insertions, 203 deletions
diff --git a/.gitignore b/.gitignore index d4d844e04..9f5a6a247 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ /ebin /lib/*/ebin/* /lib/*/tmp -/lib/*/test/tmp /lib/elixir/src/elixir.app.src /lib/elixir/src/*_lexer.erl /lib/elixir/src/*_parser.erl diff --git a/lib/elixir/lib/module.ex b/lib/elixir/lib/module.ex index 546cc9595..b0405cb09 100644 --- a/lib/elixir/lib/module.ex +++ b/lib/elixir/lib/module.ex @@ -537,7 +537,7 @@ defmodule Module do end defp simplify_signature({var, _, atom}, _i) when is_atom(atom) do - case atom_to_binary(var) do + case Atom.to_string(var) do "_" <> rest -> {String.to_atom(rest), [], Elixir} _ -> {var, [], nil} end diff --git a/lib/elixir/test/common_test_helpers.exs b/lib/elixir/test/common_test_helpers.exs deleted file mode 100644 index 1218b301b..000000000 --- a/lib/elixir/test/common_test_helpers.exs +++ /dev/null @@ -1,38 +0,0 @@ -defmodule CodeHelpers do - defp fixture_dir() do - Path.expand("elixir/fixtures/docs", __DIR__) - end - - def enter_fixture_dir() do - Path.wildcard(fixture_dir <> "/*.beam") - |> Enum.map(&File.rm/1) - Code.prepend_path(fixture_dir) - :ok - end - - def leave_fixture_dir() do - :code.get_path() - |> List.delete(fixture_dir) - |> :code.set_path() - :ok - end - - defmacro defbeam(kind \\ :module, name, do_body) do - mod = case kind do - :module -> - quote do - name = unquote(name); defmodule(name, unquote(do_body)) - end - - :protocol -> - quote do - name = unquote(name); defprotocol(name, unquote(do_body)) - end - end - quote do - {:module, _, bin, _} = unquote(mod) - beam_path = Path.join(unquote(fixture_dir), atom_to_binary(name) <> ".beam") - File.write!(beam_path, bin) - end - end -end diff --git a/lib/elixir/test/elixir/fixtures/docs/README b/lib/elixir/test/elixir/fixtures/docs/README deleted file mode 100644 index 68bb90170..000000000 --- a/lib/elixir/test/elixir/fixtures/docs/README +++ /dev/null @@ -1,2 +0,0 @@ -This directory is reserved for storing temporary .beam files. It is used by -tests that need to access module docs. diff --git a/lib/elixir/test/elixir/kernel/docs_test.exs b/lib/elixir/test/elixir/kernel/docs_test.exs index 3747bf8ab..1b0d55a49 100644 --- a/lib/elixir/test/elixir/kernel/docs_test.exs +++ b/lib/elixir/test/elixir/kernel/docs_test.exs @@ -3,26 +3,14 @@ Code.require_file "../test_helper.exs", __DIR__ defmodule Kernel.DocsTest do use ExUnit.Case - setup_all do - CodeHelpers.enter_fixture_dir() - end - - teardown_all do - CodeHelpers.leave_fixture_dir() - end - test "compiled with docs" do - expected = [ - {{:fun, 2}, 60, :def, [{:x, [], nil}, {:y, [], nil}], "This is fun!\n"}, - {{:nofun, 0}, 67, :def, [], nil}, - {{:sneaky, 1}, 65, :def, [{:bool1, [], Elixir}], false}, - ] - deftestmodule(SampleDocs) - docs = Code.get_docs(SampleDocs, :all) - assert docs[:docs] == expected - assert docs[:moduledoc] == {54, "Hello, I am a module"} + + assert [{{:fun, 2}, _, :def, [{:x, [], nil}, {:y, [], nil}], "This is fun!\n"}, + {{:nofun, 0}, _, :def, [], nil}, + {{:sneaky, 1}, _, :def, [{:bool1, [], Elixir}], false}] = docs[:docs] + assert {_, "Hello, I am a module"} = docs[:moduledoc] end test "compiled without docs" do @@ -36,7 +24,7 @@ defmodule Kernel.DocsTest do Code.compiler_options(docs: true) end - test "compiled in memory" do + test "compiled in memory does not have accessible docs" do defmodule NoDocs do @moduledoc "moduledoc" @@ -49,9 +37,9 @@ defmodule Kernel.DocsTest do end defp deftestmodule(name) do - import CodeHelpers, only: [defbeam: 2] + import PathHelpers - defbeam name do + write_beam(defmodule name do @moduledoc "Hello, I am a module" @doc """ @@ -67,6 +55,6 @@ defmodule Kernel.DocsTest do def nofun() do 'not fun at all' end - end + end) end end diff --git a/lib/elixir/test/elixir/protocol_test.exs b/lib/elixir/test/elixir/protocol_test.exs index a8d8bb8d5..09912c954 100644 --- a/lib/elixir/test/elixir/protocol_test.exs +++ b/lib/elixir/test/elixir/protocol_test.exs @@ -3,14 +3,6 @@ Code.require_file "test_helper.exs", __DIR__ defmodule ProtocolTest do use ExUnit.Case, async: true - setup_all do - CodeHelpers.enter_fixture_dir() - end - - teardown_all do - CodeHelpers.leave_fixture_dir() - end - defprotocol Sample do @type t :: any @doc "Ok" @@ -97,14 +89,14 @@ defmodule ProtocolTest do end test "protocol documentation" do - import CodeHelpers, only: [defbeam: 3] + import PathHelpers - defbeam :protocol, SampleDocsProto do + write_beam(defprotocol SampleDocsProto do @type t :: any @doc "Ok" @spec ok(t) :: boolean def ok(thing) - end + end) docs = Code.get_docs(SampleDocsProto, :docs) assert {{:ok, 1}, _, :def, [{:thing, _, nil}], "Ok"} = @@ -119,10 +111,10 @@ defmodule ProtocolTest do test "protocol defines callbacks" do assert get_callbacks(Sample, :ok, 1) == - [{:type, 17, :fun, [{:type, 17, :product, [{:type, 17, :t, []}]}, {:type, 17, :boolean, []}]}] + [{:type, 9, :fun, [{:type, 9, :product, [{:type, 9, :t, []}]}, {:type, 9, :boolean, []}]}] assert get_callbacks(WithAny, :ok, 1) == - [{:type, 24, :fun, [{:type, 24, :product, [{:type, 24, :t, []}]}, {:type, 24, :term, []}]}] + [{:type, 16, :fun, [{:type, 16, :product, [{:type, 16, :t, []}]}, {:type, 16, :term, []}]}] end test "protocol defines attributes" do diff --git a/lib/elixir/test/elixir/test_helper.exs b/lib/elixir/test/elixir/test_helper.exs index ffc01a98d..6edf43dd1 100644 --- a/lib/elixir/test/elixir/test_helper.exs +++ b/lib/elixir/test/elixir/test_helper.exs @@ -1,7 +1,11 @@ -Code.require_file "../common_test_helpers.exs", __DIR__ - ExUnit.start [trace: "--trace" in System.argv] +# Beam files compiled on demand +path = Path.expand("../../tmp/beams", __DIR__) +File.rm_rf!(path) +File.mkdir_p!(path) +Code.prepend_path(path) + Code.compiler_options debug_info: true defmodule PathHelpers do @@ -37,6 +41,13 @@ defmodule PathHelpers do executable_path("elixirc") end + def write_beam({:module, name, bin, _} = res) do + File.mkdir_p!(unquote(path)) + beam_path = Path.join(unquote(path), Atom.to_string(name) <> ".beam") + File.write!(beam_path, bin) + res + end + defp runcmd(executable,args) do :os.cmd :binary.bin_to_list("#{executable} #{IO.chardata_to_string(args)}#{redirect_std_err_on_win}") end diff --git a/lib/ex_unit/test/ex_unit/doc_test_test.exs b/lib/ex_unit/test/ex_unit/doc_test_test.exs index dced0fc48..64108f70d 100644 --- a/lib/ex_unit/test/ex_unit/doc_test_test.exs +++ b/lib/ex_unit/test/ex_unit/doc_test_test.exs @@ -1,12 +1,8 @@ Code.require_file "../test_helper.exs", __DIR__ -# cleanup leftover .beam files before writing new modules -CodeHelpers.enter_fixture_dir() +import PathHelpers -import CodeHelpers, only: [defbeam: 2] - - -defbeam ExUnit.DocTestTest.GoodModule do +defmodule ExUnit.DocTestTest.GoodModule do @doc """ iex> test_fun 1 @@ -51,9 +47,9 @@ defbeam ExUnit.DocTestTest.GoodModule do #HashDict<[c: 2, b: 1, a: 0]> """ def inspect2_test, do: :ok -end +end |> write_beam -defbeam ExUnit.DocTestTest.MultipleExceptions do +defmodule ExUnit.DocTestTest.MultipleExceptions do @doc """ iex> 1 + "" ** (ArithmeticError) bad argument in arithmetic expression @@ -61,9 +57,9 @@ defbeam ExUnit.DocTestTest.MultipleExceptions do ** (ArithmeticError) bad argument in arithmetic expression """ def two_exceptions, do: :ok -end +end |> write_beam -defbeam ExUnit.DocTestTest.SomewhatGoodModuleWithOnly do +defmodule ExUnit.DocTestTest.SomewhatGoodModuleWithOnly do @doc """ iex> test_fun 1 @@ -79,9 +75,9 @@ defbeam ExUnit.DocTestTest.SomewhatGoodModuleWithOnly do 1 """ def test_fun1, do: 1 -end +end |> write_beam -defbeam ExUnit.DocTestTest.SomewhatGoodModuleWithExcept do +defmodule ExUnit.DocTestTest.SomewhatGoodModuleWithExcept do @doc """ iex> test_fun 1 @@ -97,17 +93,17 @@ defbeam ExUnit.DocTestTest.SomewhatGoodModuleWithExcept do 1 """ def test_fun1, do: 1 -end +end |> write_beam -defbeam ExUnit.DocTestTest.NoImport do +defmodule ExUnit.DocTestTest.NoImport do @doc """ iex> ExUnit.DocTestTest.NoImport.min(1, 2) 2 """ def min(a, b), do: max(a, b) -end +end |> write_beam -defbeam ExUnit.DocTestTest.Invalid do +defmodule ExUnit.DocTestTest.Invalid do @moduledoc """ iex> 1 + * 1 @@ -129,9 +125,9 @@ defbeam ExUnit.DocTestTest.Invalid do ** (RuntimeError) hello """ -end +end |> write_beam -defbeam ExUnit.DocTestTest.IndentationHeredocs do +defmodule ExUnit.DocTestTest.IndentationHeredocs do @doc ~S''' Receives a test and formats its failure. @@ -145,9 +141,9 @@ defbeam ExUnit.DocTestTest.IndentationHeredocs do ''' def heredocs, do: :ok -end +end |> write_beam -defbeam ExUnit.DocTestTest.IndentationMismatchedPrompt do +defmodule ExUnit.DocTestTest.IndentationMismatchedPrompt do @doc ~S''' iex> foo = 1 iex> bar = 2 @@ -155,42 +151,38 @@ defbeam ExUnit.DocTestTest.IndentationMismatchedPrompt do 3 ''' def mismatched, do: :ok -end +end |> write_beam -defbeam ExUnit.DocTestTest.IndentationTooMuch do +defmodule ExUnit.DocTestTest.IndentationTooMuch do @doc ~S''' iex> 1 + 2 3 ''' def too_much, do: :ok -end +end |> write_beam -defbeam ExUnit.DocTestTest.IndentationNotEnough do +defmodule ExUnit.DocTestTest.IndentationNotEnough do @doc ~S''' iex> 1 + 2 3 ''' def not_enough, do: :ok -end +end |> write_beam -defbeam ExUnit.DocTestTest.Incomplete do +defmodule ExUnit.DocTestTest.Incomplete do @doc ~S''' iex> 1 + 2 ''' def not_enough, do: :ok -end +end |> write_beam defmodule ExUnit.DocTestTest do use ExUnit.Case - teardown_all do - CodeHelpers.leave_fixture_dir() - end - # This is intentional. The doctests in DocTest's docs # fail for demonstration purposes. - #doctest ExUnit.DocTest + # doctest ExUnit.DocTest doctest ExUnit.DocTestTest.GoodModule, import: true doctest ExUnit.DocTestTest.SomewhatGoodModuleWithOnly, only: [test_fun: 0], import: true @@ -211,58 +203,58 @@ defmodule ExUnit.DocTestTest do assert output =~ """ 1) test moduledoc at ExUnit.DocTestTest.Invalid (1) (ExUnit.DocTestTest.ActuallyCompiled) - test/ex_unit/doc_test_test.exs:206 - Doctest did not compile, got: (SyntaxError) test/ex_unit/doc_test_test.exs:110: syntax error before: '*' + test/ex_unit/doc_test_test.exs:198 + Doctest did not compile, got: (SyntaxError) test/ex_unit/doc_test_test.exs:106: syntax error before: '*' code: 1 + * 1 stacktrace: - test/ex_unit/doc_test_test.exs:110: ExUnit.DocTestTest.Invalid (module) + test/ex_unit/doc_test_test.exs:106: ExUnit.DocTestTest.Invalid (module) """ assert output =~ """ 2) test moduledoc at ExUnit.DocTestTest.Invalid (2) (ExUnit.DocTestTest.ActuallyCompiled) - test/ex_unit/doc_test_test.exs:206 + test/ex_unit/doc_test_test.exs:198 Doctest failed code: 1 + hd(List.flatten([1])) === 3 lhs: 2 stacktrace: - test/ex_unit/doc_test_test.exs:110: ExUnit.DocTestTest.Invalid (module) + test/ex_unit/doc_test_test.exs:106: ExUnit.DocTestTest.Invalid (module) """ assert output =~ """ 3) test moduledoc at ExUnit.DocTestTest.Invalid (3) (ExUnit.DocTestTest.ActuallyCompiled) - test/ex_unit/doc_test_test.exs:206 + test/ex_unit/doc_test_test.exs:198 Doctest failed code: inspect(:oops) === "#HashDict<[]>" lhs: ":oops" stacktrace: - test/ex_unit/doc_test_test.exs:110: ExUnit.DocTestTest.Invalid (module) + test/ex_unit/doc_test_test.exs:106: ExUnit.DocTestTest.Invalid (module) """ assert output =~ """ 4) test moduledoc at ExUnit.DocTestTest.Invalid (4) (ExUnit.DocTestTest.ActuallyCompiled) - test/ex_unit/doc_test_test.exs:206 + test/ex_unit/doc_test_test.exs:198 Doctest failed: got UndefinedFunctionError with message undefined function: Hello.world/0 code: Hello.world stacktrace: - test/ex_unit/doc_test_test.exs:110: ExUnit.DocTestTest.Invalid (module) + test/ex_unit/doc_test_test.exs:106: ExUnit.DocTestTest.Invalid (module) """ assert output =~ """ 5) test moduledoc at ExUnit.DocTestTest.Invalid (5) (ExUnit.DocTestTest.ActuallyCompiled) - test/ex_unit/doc_test_test.exs:206 + test/ex_unit/doc_test_test.exs:198 Doctest failed: expected exception WhatIsThis with message "oops" but got RuntimeError with message "oops" code: raise "oops" stacktrace: - test/ex_unit/doc_test_test.exs:110: ExUnit.DocTestTest.Invalid (module) + test/ex_unit/doc_test_test.exs:106: ExUnit.DocTestTest.Invalid (module) """ assert output =~ """ 6) test moduledoc at ExUnit.DocTestTest.Invalid (6) (ExUnit.DocTestTest.ActuallyCompiled) - test/ex_unit/doc_test_test.exs:206 + test/ex_unit/doc_test_test.exs:198 Doctest failed: expected exception RuntimeError with message "hello" but got RuntimeError with message "oops" code: raise "oops" stacktrace: - test/ex_unit/doc_test_test.exs:110: ExUnit.DocTestTest.Invalid (module) + test/ex_unit/doc_test_test.exs:106: ExUnit.DocTestTest.Invalid (module) """ end diff --git a/lib/ex_unit/test/test_helper.exs b/lib/ex_unit/test/test_helper.exs index 06488430a..e7e72338e 100644 --- a/lib/ex_unit/test/test_helper.exs +++ b/lib/ex_unit/test/test_helper.exs @@ -1,3 +1,15 @@ -Code.require_file "../../elixir/test/common_test_helpers.exs", __DIR__ - ExUnit.start [trace: "--trace" in System.argv] + +# Beam files compiled on demand +path = Path.expand("../tmp/beams", __DIR__) +File.rm_rf!(path) +File.mkdir_p!(path) +Code.prepend_path(path) + +defmodule PathHelpers do + def write_beam({:module, name, bin, _} = res) do + beam_path = Path.join(unquote(path), Atom.to_string(name) <> ".beam") + File.write!(beam_path, bin) + res + end +end diff --git a/lib/iex/lib/iex/autocomplete.ex b/lib/iex/lib/iex/autocomplete.ex index 618a96492..0e0296ad0 100644 --- a/lib/iex/lib/iex/autocomplete.ex +++ b/lib/iex/lib/iex/autocomplete.ex @@ -46,7 +46,7 @@ defmodule IEx.Autocomplete do {:ok, {atom, _, nil}} when is_atom(atom) -> expand_call Kernel, Atom.to_string(atom) {:ok, {:__aliases__, _, [root]}} -> - expand_elixir_modules [], atom_to_binary(root) + expand_elixir_modules [], Atom.to_string(root) {:ok, {:__aliases__, _, [h|_] = list}} when is_atom(h) -> hint = Atom.to_string(List.last(list)) list = Enum.take(list, length(list) - 1) diff --git a/lib/iex/test/iex/helpers_test.exs b/lib/iex/test/iex/helpers_test.exs index 2f2c90a28..fe132ef1a 100644 --- a/lib/iex/test/iex/helpers_test.exs +++ b/lib/iex/test/iex/helpers_test.exs @@ -3,27 +3,6 @@ Code.require_file "../test_helper.exs", __DIR__ defmodule IEx.HelpersTest do use IEx.Case - setup_all do - CodeHelpers.enter_fixture_dir() - import CodeHelpers, only: [defbeam: 2] - - defbeam IExDocsSample do - @doc """ - Test function 1 - """ - def test_fun_1, do: :ok - - @doc """ - Test function 2 - """ - def test_fun_2(arg \\ 99), do: arg - end - end - - teardown_all do - CodeHelpers.leave_fixture_dir() - end - import IEx.Helpers test "clear helper" do @@ -47,18 +26,14 @@ defmodule IEx.HelpersTest do end test "h helper function" do - doc_1 = "* def test_fun_1()\n\nTest function 1\n\n" - doc_2 = "* def test_fun_2(arg \\\\ 99)\n\nTest function 2\n\n" - - assert capture_io(fn -> h IExDocsSample.test_fun_1/0 end) == doc_1 - assert capture_io(fn -> h IExDocsSample.test_fun_2/1 end) == doc_2 + pwd_h = "* def pwd()\n\nPrints the current working directory.\n\n" + c_h = "* def c(files, path \\\\ \".\")\n\nExpects a list of files to compile" - output = capture_io(fn -> h IExDocsSample.test_fun_1 end) - assert :binary.match(output, doc_1) - assert :binary.match(output, doc_2) + assert capture_io(fn -> h IEx.Helpers.pwd/0 end) =~ pwd_h + assert capture_io(fn -> h IEx.Helpers.c/2 end) =~ c_h - assert capture_io(fn -> h pwd end) - == "* def pwd()\n\nPrints the current working directory.\n\n\n" + assert capture_io(fn -> h Iex.Helpers.c/1 end) =~ c_h + assert capture_io(fn -> h pwd end) =~ pwd_h end test "h helper __info__" do diff --git a/lib/iex/test/iex/interaction_test.exs b/lib/iex/test/iex/interaction_test.exs index 695c25713..6d3de2054 100644 --- a/lib/iex/test/iex/interaction_test.exs +++ b/lib/iex/test/iex/interaction_test.exs @@ -3,22 +3,6 @@ Code.require_file "../test_helper.exs", __DIR__ defmodule IEx.InteractionTest do use IEx.Case - setup_all do - CodeHelpers.enter_fixture_dir() - import CodeHelpers, only: [defbeam: 2] - - defbeam IExModuledocSample do - @doc """ - Hello, I have %{red}ANSI%{reset} escapes. - """ - def ansi_escapes, do: :ok - end - end - - teardown_all do - CodeHelpers.leave_fixture_dir() - end - ## Basic interaction test "whole output" do @@ -123,8 +107,8 @@ defmodule IEx.InteractionTest do # Test that ANSI escapes in the docs are left alone opts = [colors: [enabled: true]] - assert capture_iex("h IExModuledocSample.ansi_escapes", opts) - =~ ~r"Hello, I have %\{red}ANSI%\{reset} escapes" + assert capture_iex("h IO.ANSI.escape_fragment", opts) + =~ ~r"%\{red\}" # Test that ANSI escapes in iex output are left alone opts = [colors: [enabled: true, eval_result: "red", eval_info: "red"]] diff --git a/lib/iex/test/test_helper.exs b/lib/iex/test/test_helper.exs index 755d0b718..38e6f57a2 100644 --- a/lib/iex/test/test_helper.exs +++ b/lib/iex/test/test_helper.exs @@ -1,5 +1,3 @@ -Code.require_file "../../elixir/test/common_test_helpers.exs", __DIR__ - Application.start(:iex) Application.put_env(:iex, :colors, [enabled: false]) ExUnit.start [trace: "--trace" in System.argv] diff --git a/lib/mix/test/mix/task_test.exs b/lib/mix/test/mix/task_test.exs index 976410efc..48f08fe85 100644 --- a/lib/mix/test/mix/task_test.exs +++ b/lib/mix/test/mix/task_test.exs @@ -1,28 +1,37 @@ Code.require_file "../test_helper.exs", __DIR__ -defmodule Mix.TaskTest do - use MixTest.Case - - setup_all do - CodeHelpers.enter_fixture_dir() - import CodeHelpers, only: [defbeam: 2] +path = MixTest.Case.tmp_path("beams") +File.rm_rf!(path) +File.mkdir_p!(path) + +write_beam = fn {:module, name, bin, _} -> + path + |> Path.join(Atom.to_string(name) <> ".beam") + |> File.write!(bin) +end - defbeam Mix.Tasks.Hello do - use Mix.Task - @shortdoc "This is short documentation, see" +defmodule Mix.Tasks.Hello do + use Mix.Task + @shortdoc "This is short documentation, see" - @moduledoc """ - A test task. - """ + @moduledoc """ + A test task. + """ - def run(_) do - "Hello, World!" - end - end + def run(_) do + "Hello, World!" end +end |> write_beam.() + +defmodule Mix.Tasks.Invalid do +end |> write_beam.() + +defmodule Mix.TaskTest do + use MixTest.Case - teardown_all do - CodeHelpers.leave_fixture_dir() + setup do + Code.prepend_path unquote(path) + :ok end test :run do diff --git a/lib/mix/test/test_helper.exs b/lib/mix/test/test_helper.exs index a5f147817..10a36a9f1 100644 --- a/lib/mix/test/test_helper.exs +++ b/lib/mix/test/test_helper.exs @@ -1,5 +1,3 @@ -Code.require_file "../../elixir/test/common_test_helpers.exs", __DIR__ - Mix.start() Mix.shell(Mix.Shell.Process) @@ -107,15 +105,10 @@ defmodule MixTest.Case do end end -## Some tasks fixtures - -defmodule Mix.Tasks.Invalid do -end - ## Copy fixtures to tmp source = MixTest.Case.fixture_path("rebar_dep") -dest = Path.join(MixTest.Case.tmp_path, "rebar_dep") +dest = MixTest.Case.tmp_path("rebar_dep") File.mkdir_p!(dest) File.cp_r!(source, dest) |