Skip to content

Commit

Permalink
Code.require_file and Code.load_file now expect the full name as argu…
Browse files Browse the repository at this point in the history
…ment
  • Loading branch information
José Valim committed Aug 21, 2012
1 parent 2a94699 commit 68828d2
Show file tree
Hide file tree
Showing 65 changed files with 68 additions and 72 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -9,6 +9,7 @@

* deprecations
* [GenServer] Rename `GenServer.Behavior` to `GenServer.Behaviour`
* [Code] `Code.require_file` and `Code.load_file` now expect the full name as argument

* bug fix
* [Macro] Fixed a bug where quoted expressions were not behaving the same as their non-quoted counterparts
Expand Down
2 changes: 1 addition & 1 deletion lib/eex/test/eex/smart_engine_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../test_helper", __FILE__
Code.require_file "../../test_helper.exs", __FILE__

defmodule EEx.SmartEngineTest do
use ExUnit.Case, async: true
Expand Down
2 changes: 1 addition & 1 deletion lib/eex/test/eex/tokenizer_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../test_helper", __FILE__
Code.require_file "../../test_helper.exs", __FILE__

defmodule EEx.TokenizerTest do
use ExUnit.Case, async: true
Expand Down
2 changes: 1 addition & 1 deletion lib/eex/test/eex_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../test_helper", __FILE__
Code.require_file "../test_helper.exs", __FILE__

require EEx

Expand Down
7 changes: 1 addition & 6 deletions lib/elixir/lib/code.ex
Expand Up @@ -162,9 +162,6 @@ defmodule Code do
in many times. I.e. if `load_file` is called N times with
a given file, the given file will be loaded N times. Check
`require_file` if you don't want a file to be loaded concurrently.
When loading a file, you may skip passing .exs as extension as
Elixir automatically adds it for you.
"""
def load_file(file, relative_to // nil) when is_binary(file) do
file = find_file(file, relative_to)
Expand All @@ -186,9 +183,6 @@ defmodule Code do
available. I.e. if `require_file` is called N times with a given
file, the given file will be loaded only once. Check `load_file`
if you want a file to be loaded concurrently.
When requiring a file, you may skip passing .exs as extension as
Elixir automatically adds it for you.
"""
def require_file(file, relative_to // nil) when is_binary(file) do
file = find_file(file, relative_to)
Expand Down Expand Up @@ -332,6 +326,7 @@ defmodule Code do
else
prefix = "#{file}.exs"
if File.regular?(prefix) do
IO.write "[WARNING] Passing a file without .exs extension to Code.load_file or Code.require_file is deprecated, please pass the full name instead\n#{Exception.formatted_stacktrace}"
prefix
else
raise ArgumentError, message: "could not load #{file}"
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/access_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../test_helper", __FILE__
Code.require_file "../test_helper.exs", __FILE__

defmodule Access.TupleTest do
use ExUnit.Case, async: true
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/behaviour_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../test_helper", __FILE__
Code.require_file "../test_helper.exs", __FILE__

defmodule BehaviourTest do
use ExUnit.Case, async: true
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/binary/chars_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../test_helper", __FILE__
Code.require_file "../../test_helper.exs", __FILE__

defmodule Binary.Chars.AtomTest do
use ExUnit.Case, async: true
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/binary/inspect_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../test_helper", __FILE__
Code.require_file "../../test_helper.exs", __FILE__

defmodule Binary.Inspect.AtomTest do
use ExUnit.Case, async: true
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/binary_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../test_helper", __FILE__
Code.require_file "../test_helper.exs", __FILE__

defmodule Binary.LiteralTest do
use ExUnit.Case, async: true
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/bitwise_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../test_helper", __FILE__
Code.require_file "../test_helper.exs", __FILE__

defmodule Bitwise.FunctionsTest do
use ExUnit.Case, async: true
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/char_list_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../test_helper", __FILE__
Code.require_file "../test_helper.exs", __FILE__

defmodule CharListTest do
use ExUnit.Case, async: true
Expand Down
8 changes: 4 additions & 4 deletions lib/elixir/test/elixir/code_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../test_helper", __FILE__
Code.require_file "../test_helper.exs", __FILE__

defmodule CodeTest do
use ExUnit.Case, async: true
Expand Down Expand Up @@ -29,13 +29,13 @@ defmodule CodeTest do
end

test :require do
Code.require_file fixture_path("code_sample")
Code.require_file fixture_path("code_sample.exs")
assert fixture_path("code_sample.exs") in Code.loaded_files
assert Code.require_file(fixture_path("code_sample")) == nil
assert Code.require_file(fixture_path("code_sample.exs")) == nil

Code.unload_files [fixture_path("code_sample.exs")]
refute fixture_path("code_sample.exs") in Code.loaded_files
assert Code.require_file(fixture_path("code_sample")) != nil
assert Code.require_file(fixture_path("code_sample.exs")) != nil
end

test :file do
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/dict_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../test_helper", __FILE__
Code.require_file "../test_helper.exs", __FILE__

defmodule DictTest.Common do
defmacro __using__(module) do
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/enum_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../test_helper", __FILE__
Code.require_file "../test_helper.exs", __FILE__

defmodule EnumTest.Common do
use ExUnit.Case, async: true
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/exception_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../test_helper", __FILE__
Code.require_file "../test_helper.exs", __FILE__

defmodule Kernel.ExceptionTest do
use ExUnit.Case, async: true
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/file_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../test_helper", __FILE__
Code.require_file "../test_helper.exs", __FILE__

defmodule FileTest do
import PathHelpers
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/iex/autocomplete_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../test_helper", __FILE__
Code.require_file "../../test_helper.exs", __FILE__

defmodule IEx.AutocompleteTest do
use ExUnit.Case, async: true
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/io_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../test_helper", __FILE__
Code.require_file "../test_helper.exs", __FILE__

defmodule IOTest do
use ExUnit.Case, async: true
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/kernel/alias_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../test_helper", __FILE__
Code.require_file "../../test_helper.exs", __FILE__

defmodule Kernel.AliasTest.Nested do
def value, do: 1
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/kernel/case_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../test_helper", __FILE__
Code.require_file "../../test_helper.exs", __FILE__

defmodule Kernel.CaseTest do
use ExUnit.Case, async: true
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/kernel/cli_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../test_helper", __FILE__
Code.require_file "../../test_helper.exs", __FILE__

defmodule Kernel.CLI.InitTest do
use ExUnit.Case, async: true
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/kernel/comprehension_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../test_helper", __FILE__
Code.require_file "../../test_helper.exs", __FILE__

defmodule Kernel.ComprehensionTest do
use ExUnit.Case, async: true
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/kernel/def_clauses_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../test_helper", __FILE__
Code.require_file "../../test_helper.exs", __FILE__

defmodule Kernel.DefClause do
defmacro defclause(expr, block) do
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/kernel/doc_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../test_helper", __FILE__
Code.require_file "../../test_helper.exs", __FILE__

defmodule Kernel.DocTest do
use ExUnit.Case
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/kernel/errors_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../test_helper", __FILE__
Code.require_file "../../test_helper.exs", __FILE__

defmodule Kernel.ErrorsTest do
use ExUnit.Case, async: true
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/kernel/import_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../test_helper", __FILE__
Code.require_file "../../test_helper.exs", __FILE__

defmodule Kernel.ImportAvailable do
defmacro flatten do
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/kernel/macros_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../test_helper", __FILE__
Code.require_file "../../test_helper.exs", __FILE__

defmodule Kernel.MacrosTest.Nested do
defmacro value, do: 1
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/kernel/overridable_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../test_helper", __FILE__
Code.require_file "../../test_helper.exs", __FILE__

defmodule Kernel.Overridable do
def sample do
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/kernel/partial_application_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../test_helper", __FILE__
Code.require_file "../../test_helper.exs", __FILE__

defmodule Kernel.PartialApplicationTest do
use ExUnit.Case, async: true
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/kernel/quote_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../test_helper", __FILE__
Code.require_file "../../test_helper.exs", __FILE__

defmodule Kernel.QuoteTest.Hygiene do
defmacro no_interference do
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/kernel/rescue_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../test_helper", __FILE__
Code.require_file "../../test_helper.exs", __FILE__

defmodule Kernel.RescueTest do
use ExUnit.Case, async: true
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/kernel_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../test_helper", __FILE__
Code.require_file "../test_helper.exs", __FILE__

defmodule KernelTest do
defmodule Conversions do
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/keyword_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../test_helper", __FILE__
Code.require_file "../test_helper.exs", __FILE__

defmodule KeywordTest do
use ExUnit.Case, async: true
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/list/chars_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../test_helper", __FILE__
Code.require_file "../../test_helper.exs", __FILE__

defmodule List.Chars.AtomTest do
use ExUnit.Case, async: true
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/list_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../test_helper", __FILE__
Code.require_file "../test_helper.exs", __FILE__

defmodule ListTest do
use ExUnit.Case, async: true
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/macro_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../test_helper", __FILE__
Code.require_file "../test_helper.exs", __FILE__

defmodule Macro.ExternalTest do
defmacro external do
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/module_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../test_helper", __FILE__
Code.require_file "../test_helper.exs", __FILE__

defmodule ModuleTest.ToBeUsed do
def value, do: 1
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/option_parser_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../test_helper", __FILE__
Code.require_file "../test_helper.exs", __FILE__

defmodule OptionParserTest do
use ExUnit.Case, async: true
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/protocol_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../test_helper", __FILE__
Code.require_file "../test_helper.exs", __FILE__

defprotocol ProtocolTest.WithAll do
@doc "Blank"
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/range_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../test_helper", __FILE__
Code.require_file "../test_helper.exs", __FILE__

defmodule RangeTest do
use ExUnit.Case, async: true
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/record_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../test_helper", __FILE__
Code.require_file "../test_helper.exs", __FILE__

defrecord RecordTest.FileInfo,
Record.extract(:file_info, from_lib: "kernel/include/file.hrl")
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/regex_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../test_helper", __FILE__
Code.require_file "../test_helper.exs", __FILE__

defmodule Regex.BinaryTest do
use ExUnit.Case, async: true
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/system_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../test_helper", __FILE__
Code.require_file "../test_helper.exs", __FILE__

require Erlang.os, as: OS

Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/tuple_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../test_helper", __FILE__
Code.require_file "../test_helper.exs", __FILE__

defmodule TupleTest do
use ExUnit.Case, async: true
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/elixir/typespec_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../test_helper", __FILE__
Code.require_file "../test_helper.exs", __FILE__

defmodule Typespec.Test.Type do
use ExUnit.Case, async: true
Expand Down
2 changes: 1 addition & 1 deletion lib/ex_unit/test/ex_unit/assertions_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../test_helper", __FILE__
Code.require_file "../../test_helper.exs", __FILE__

defmodule ExUnit.AssertionsTest.Value do
def tuple, do: { 2, 1 }
Expand Down
2 changes: 1 addition & 1 deletion lib/ex_unit/test/ex_unit/callbacks_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../test_helper", __FILE__
Code.require_file "../../test_helper.exs", __FILE__

defmodule ExUnit.CallbacksTest do
use ExUnit.Case, sync: false
Expand Down
2 changes: 1 addition & 1 deletion lib/mix/lib/mix/tasks/new.ex
Expand Up @@ -105,7 +105,7 @@ defmodule Mix.Tasks.New do
"""

embed_template :test_lib, """
Code.require_file "../test_helper", __FILE__
Code.require_file "../test_helper.exs", __FILE__
defmodule <%= @mod %>Test do
use ExUnit.Case
Expand Down
2 changes: 1 addition & 1 deletion lib/mix/test/mix/cli_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../test_helper", __FILE__
Code.require_file "../../test_helper.exs", __FILE__

defmodule Mix.CLITest do
use MixTest.Case
Expand Down
2 changes: 1 addition & 1 deletion lib/mix/test/mix/generator_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../test_helper", __FILE__
Code.require_file "../../test_helper.exs", __FILE__

defmodule Mix.GeneratorTest do
use MixTest.Case
Expand Down
2 changes: 1 addition & 1 deletion lib/mix/test/mix/project_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../test_helper", __FILE__
Code.require_file "../../test_helper.exs", __FILE__

defmodule Mix.ProjectTest do
use MixTest.Case
Expand Down
2 changes: 1 addition & 1 deletion lib/mix/test/mix/task_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../test_helper", __FILE__
Code.require_file "../../test_helper.exs", __FILE__

defmodule Mix.TaskTest do
use MixTest.Case
Expand Down
2 changes: 1 addition & 1 deletion lib/mix/test/mix/tasks/clean_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../../test_helper", __FILE__
Code.require_file "../../../test_helper.exs", __FILE__

defmodule Mix.Tasks.CleanTest do
use MixTest.Case
Expand Down
2 changes: 1 addition & 1 deletion lib/mix/test/mix/tasks/compile.app_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../../test_helper", __FILE__
Code.require_file "../../../test_helper.exs", __FILE__

defmodule Mix.Tasks.Compile.AppTest do
use MixTest.Case
Expand Down
2 changes: 1 addition & 1 deletion lib/mix/test/mix/tasks/compile.elixir_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../../test_helper", __FILE__
Code.require_file "../../../test_helper.exs", __FILE__

defmodule Mix.Tasks.Compile.ElixirTest do
use MixTest.Case
Expand Down
2 changes: 1 addition & 1 deletion lib/mix/test/mix/tasks/compile_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../../test_helper", __FILE__
Code.require_file "../../../test_helper.exs", __FILE__

defmodule Mix.Tasks.CompileTest do
use MixTest.Case
Expand Down
2 changes: 1 addition & 1 deletion lib/mix/test/mix/tasks/deps.git_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../../test_helper", __FILE__
Code.require_file "../../../test_helper.exs", __FILE__

defmodule Mix.Tasks.DepsGitTest do
use MixTest.Case
Expand Down
2 changes: 1 addition & 1 deletion lib/mix/test/mix/tasks/deps.raw_test.exs
@@ -1,4 +1,4 @@
Code.require_file "../../../test_helper", __FILE__
Code.require_file "../../../test_helper.exs", __FILE__

defmodule Mix.Tasks.DepsPathTest do
use MixTest.Case
Expand Down

0 comments on commit 68828d2

Please sign in to comment.