diff --git a/lib/elixir/lib/kernel/cli.ex b/lib/elixir/lib/kernel/cli.ex index 83869f7602..9dc3a79705 100644 --- a/lib/elixir/lib/kernel/cli.ex +++ b/lib/elixir/lib/kernel/cli.ex @@ -94,12 +94,12 @@ defmodule Kernel.CLI do end defp process_shared(['-pa',h|t], config) do - Code.prepend_path h + Enum.each File.wildcard(File.expand_path(h)), Code.prepend_path(&1) process_shared t, config end defp process_shared(['-pz',h|t], config) do - Code.append_path(h) + Enum.each File.wildcard(File.expand_path(h)), Code.append_path(&1) process_shared t, config end diff --git a/lib/elixir/test/elixir/kernel/cli_test.exs b/lib/elixir/test/elixir/kernel/cli_test.exs index ec434fcca8..63b29593ca 100644 --- a/lib/elixir/test/elixir/kernel/cli_test.exs +++ b/lib/elixir/test/elixir/kernel/cli_test.exs @@ -12,6 +12,31 @@ defmodule Kernel.CLI.InitTest do end end +defmodule Kernel.CLI.OptionParsingTest do + use ExUnit.Case, async: true + import PathHelpers + + test :path do + root = fixture_path("../../..") /> to_char_list + list = elixir('-e "IO.inspect Erlang.code.get_path" -pa "#{root}/*" -pz "#{root}/lib/*"') + { path, _ } = Code.eval list, [] + + # pa + assert File.expand_path('ebin', root) in path + assert File.expand_path('lib', root) in path + assert File.expand_path('src', root) in path + + # pz + assert File.expand_path('lib/list', root) in path + end + + test :require do + options = ['-r', fixture_path('../../../lib/list/*') /> to_char_list, '-r', '/never/gonna/*/up'] + { config, _argv } = Kernel.CLI.process_options(options, Kernel.CLI.Config.new) + assert {:require, fixture_path "../../../lib/list/chars.ex"} in config.commands + end +end + defmodule Kernel.CLI.AtExitTest do use ExUnit.Case, async: true import PathHelpers