Skip to content

Commit 9bf036a

Browse files
committed
Support --code-path option
1 parent e9e883d commit 9bf036a

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

lib/mix/tasks/gradient.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ defmodule Mix.Tasks.Gradient do
1111
* `--no-gradualizer-check` - do not perform the Gradualizer checks
1212
* `--no-specify` - do not specify missing lines in AST what can
1313
result in less precise error messages
14+
* `--code-path` - provide a path to the .ex file containing code for analyzed .beam
1415
1516
* `--no-deps` - do not import dependencies to the Gradualizer
1617
* `--stop_on_first_error` - stop type checking at the first error
@@ -40,6 +41,7 @@ defmodule Mix.Tasks.Gradient do
4041
no_ex_check: :boolean,
4142
no_gradualizer_check: :boolean,
4243
no_specify: :boolean,
44+
code_path: :string,
4345
# checker options
4446
no_deps: :boolean,
4547
stop_on_first_error: :boolean,

test/mix/tasks/gradient_test.exs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ defmodule Mix.Tasks.GradientTest do
99
@s_wrong_ret_beam "Elixir.SWrongRet.beam"
1010
@s_wrong_ret_ex "s_wrong_ret.ex"
1111

12-
#@tag :skip
1312
test "--no-compile option" do
1413
info = "Compiling project..."
1514

@@ -155,6 +154,13 @@ defmodule Mix.Tasks.GradientTest do
155154
# FIXME provide implementation
156155
end
157156

157+
test "--code-path option" do
158+
ex_file = "wrong_ret.ex"
159+
output = run_task(@type_path, ["--no-compile", "--code-path", ex_file, "--", @s_wrong_ret_beam])
160+
assert not String.contains?(output, @s_wrong_ret_ex)
161+
assert String.contains?(output, ex_file)
162+
end
163+
158164
def run_task(rel_path, args) do
159165
run_in_path(rel_path, fn ->
160166
capture_io(fn -> Mix.Tasks.Gradient.run(args) end)
@@ -168,13 +174,4 @@ defmodule Mix.Tasks.GradientTest do
168174
File.cd(cwd)
169175
res
170176
end
171-
172-
def was_dir?(dir) do
173-
if File.dir?(dir) do
174-
:os.cmd(String.to_charlist("rm -Rf " <> dir))
175-
true
176-
else
177-
false
178-
end
179-
end
180177
end

0 commit comments

Comments
 (0)