Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/elixir/lib/config/provider.ex
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ defmodule Config.Provider do
defp write_config!(config, path) do
contents = :io_lib.format("%% coding: utf-8~n~tw.~n", [config])

case File.write(path, contents, [:utf8]) do
case File.write(path, IO.chardata_to_string(contents)) do
:ok ->
:ok

Expand Down
6 changes: 3 additions & 3 deletions lib/elixir/test/elixir/config/provider_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ defmodule Config.ProviderTest do
assert config[@config_app] == [config_providers_booted: {:booted, nil}]
end

@tag sys_config: [my_app: [encoding: {:"£", "£", '£'}]]
@tag sys_config: [my_app: [encoding: {:time_μs, :"£", "£", '£'}]]
test "writes sys_config with encoding" do
init_and_assert_boot()
config = consult(@sys_config)
assert config[:my_app][:encoding] == {:"£", "£", '£'}
assert config[:my_app][:encoding] == {:time_μs, :"£", "£", '£'}
end

@tag sys_config: [my_app: [key: :old_value, sys_key: :sys_value, extra_config: :old_value]]
Expand Down Expand Up @@ -185,6 +185,6 @@ defmodule Config.ProviderTest do
end

defp write_sys_config!(data) do
File.write!(@sys_config, :io_lib.format("~tw.~n", [data]), [:utf8])
File.write!(@sys_config, IO.chardata_to_string(:io_lib.format("~tw.~n", [data])))
end
end
8 changes: 4 additions & 4 deletions lib/mix/lib/mix/release.ex
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ defmodule Mix.Release do
args = [runtime_config?, sys_config]
format = "%% coding: utf-8~n%% RUNTIME_CONFIG=~s~n~tw.~n"
File.mkdir_p!(Path.dirname(path))
File.write!(path, :io_lib.format(format, args), [:utf8])
File.write!(path, IO.chardata_to_string(:io_lib.format(format, args)))

case :file.consult(path) do
{:ok, _} ->
Expand Down Expand Up @@ -513,7 +513,7 @@ defmodule Mix.Release do
:ok | {:error, String.t()}
def make_boot_script(release, path, modes, prepend_paths \\ []) do
with {:ok, rel_spec} <- build_release_spec(release, modes) do
File.write!(path <> ".rel", consultable(rel_spec), [:utf8])
File.write!(path <> ".rel", consultable(rel_spec))

sys_path = String.to_charlist(path)

Expand All @@ -536,7 +536,7 @@ defmodule Mix.Release do
|> prepend_paths_to_script(prepend_paths)

script = {:script, rel_info, instructions}
File.write!(script_path, consultable(script), [:utf8])
File.write!(script_path, consultable(script))
:ok = :systools.script2boot(sys_path)

{:error, module, info} ->
Expand Down Expand Up @@ -658,7 +658,7 @@ defmodule Mix.Release do
end

defp consultable(term) do
:io_lib.format("%% coding: utf-8~n~tp.~n", [term])
IO.chardata_to_string(:io_lib.format("%% coding: utf-8~n~tp.~n", [term]))
end

@doc """
Expand Down
2 changes: 1 addition & 1 deletion lib/mix/test/fixtures/release_test/config/config.exs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Config

config :release_test, :static, :was_set
config :release_test, :encoding, {:"£", "£", '£'}
config :release_test, :encoding, {:time_μs, :"£", "£", '£'}
8 changes: 6 additions & 2 deletions lib/mix/test/mix/release_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -488,11 +488,15 @@ defmodule Mix.ReleaseTest do
end

test "writes sys_config with encoding" do
assert make_sys_config(release([]), [encoding: {:"£", "£", '£'}], "unused/runtime/path") ==
assert make_sys_config(
release([]),
[encoding: {:time_μs, :"£", "£", '£'}],
"unused/runtime/path"
) ==
:ok

{:ok, contents} = :file.consult(@sys_config)
assert contents == [[encoding: {:"£", "£", '£'}]]
assert contents == [[encoding: {:time_μs, :"£", "£", '£'}]]
end

test "writes the given sys_config with config providers" do
Expand Down
6 changes: 3 additions & 3 deletions lib/mix/test/mix/tasks/release_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ defmodule Mix.Tasks.ReleaseTest do
assert %{
app_dir: app_dir,
cookie_env: ^cookie,
encoding: {:"£", "£", '£'},
encoding: {:time_μs, :"£", "£", '£'},
mode: :embedded,
node: release_node("release_test"),
protocols_consolidated?: true,
Expand Down Expand Up @@ -322,7 +322,7 @@ defmodule Mix.Tasks.ReleaseTest do
File.write!("config/releases.exs", """
import Config
config :release_test, :runtime, :was_set
config :release_test, :encoding, {:runtime, :"£", "£", '£'}
config :release_test, :encoding, {:runtime, :time_μs, :"£", "£", '£'}
""")

root = Path.absname("_build/dev/rel/runtime_config")
Expand All @@ -348,7 +348,7 @@ defmodule Mix.Tasks.ReleaseTest do
open_port(Path.join(root, "bin/runtime_config"), ['start'])

assert %{
encoding: {:runtime, :"£", "£", '£'},
encoding: {:runtime, :time_μs, :"£", "£", '£'},
mode: :embedded,
node: release_node("runtime_config"),
protocols_consolidated?: true,
Expand Down