@@ -25,71 +25,74 @@ defmodule Mix.Tasks.GradientTest do
2525 end
2626
2727 test "path to the beam file" do
28- output = run_task ( @ type_path , [ "--no-compile" , "--" , @ s_wrong_ret_beam ] )
28+ output = run_task ( @ type_path , test_opts ( [ @ s_wrong_ret_beam ] ) )
2929 assert 3 == String . split ( output , @ s_wrong_ret_ex ) |> length ( )
3030 end
3131
3232 test "path to the ex file" do
33- output = run_task ( @ type_path , [ "--no-compile" , "--" , @ s_wrong_ret_ex ] )
33+ output = run_task ( @ type_path , test_opts ( [ @ s_wrong_ret_ex ] ) )
3434 assert 3 == String . split ( output , @ s_wrong_ret_ex ) |> length ( )
3535 end
3636
3737 test "no_fancy option" do
38- output = run_task ( @ type_path , [ "--no-compile" , "--" , @ s_wrong_ret_beam ] )
38+ output = run_task ( @ type_path , test_opts ( [ @ s_wrong_ret_beam ] ) )
3939 assert String . contains? ( output , "The integer on line" )
4040 assert String . contains? ( output , "The tuple on line" )
4141
42- output = run_task ( @ type_path , [ "--no-compile" , "--no- fancy", "--" , @ s_wrong_ret_beam ] )
42+ output = run_task ( @ type_path , test_opts ( [ "--no-fancy" , "--" , @ s_wrong_ret_beam ] ) )
4343 assert String . contains? ( output , "The integer \e [33m1\e [0m on line" )
4444 assert String . contains? ( output , "The tuple \e [33m{:ok, []}\e [0m on line" )
4545 end
4646
4747 describe "colors" do
4848 test "no_colors option" do
49- output = run_task ( @ type_path , [ "--no-compile" , "--" , @ s_wrong_ret_beam ] )
49+ output = run_task ( @ type_path , test_opts ( [ @ s_wrong_ret_beam ] ) )
5050 assert String . contains? ( output , IO.ANSI . cyan ( ) )
5151 assert String . contains? ( output , IO.ANSI . red ( ) )
5252
53- output = run_task ( @ type_path , [ "--no-compile" , "--no- colors", "--" , @ s_wrong_ret_beam ] )
53+ output = run_task ( @ type_path , test_opts ( [ "--no-colors" , "--" , @ s_wrong_ret_beam ] ) )
5454 assert not String . contains? ( output , IO.ANSI . cyan ( ) )
5555 assert not String . contains? ( output , IO.ANSI . red ( ) )
5656 end
5757
5858 test "--expr-color and --type-color option" do
5959 output =
60- run_task ( @ type_path , [
61- "--no-compile" ,
62- "--no-fancy" ,
63- "--expr-color" ,
64- "green" ,
65- "--type-color" ,
66- "magenta" ,
67- "--" ,
68- @ s_wrong_ret_beam
69- ] )
60+ run_task (
61+ @ type_path ,
62+ test_opts ( [
63+ "--no-fancy" ,
64+ "--expr-color" ,
65+ "green" ,
66+ "--type-color" ,
67+ "magenta" ,
68+ "--" ,
69+ @ s_wrong_ret_beam
70+ ] )
71+ )
7072
7173 assert String . contains? ( output , IO.ANSI . green ( ) )
7274 assert String . contains? ( output , IO.ANSI . magenta ( ) )
7375 end
7476
7577 test "--underscore_color option" do
7678 output =
77- run_task ( @ type_path , [
78- "--no-compile" ,
79- "--underscore-color" ,
80- "green" ,
81- "--" ,
82- @ s_wrong_ret_beam
83- ] )
79+ run_task (
80+ @ type_path ,
81+ test_opts ( [
82+ "--underscore-color" ,
83+ "green" ,
84+ "--" ,
85+ @ s_wrong_ret_beam
86+ ] )
87+ )
8488
8589 assert String . contains? ( output , IO.ANSI . green ( ) )
8690 assert not String . contains? ( output , IO.ANSI . red ( ) )
8791 end
8892 end
8993
9094 test "--no-gradualizer-check option" do
91- output =
92- run_task ( @ type_path , [ "--no-compile" , "--no-gradualizer-check" , "--" , @ s_wrong_ret_beam ] )
95+ output = run_task ( @ type_path , test_opts ( [ "--no-gradualizer-check" , "--" , @ s_wrong_ret_beam ] ) )
9396
9497 assert String . contains? ( output , "No problems found!" )
9598 end
@@ -98,45 +101,42 @@ defmodule Mix.Tasks.GradientTest do
98101 beam = "Elixir.SpecAfterSpec.beam"
99102 ex_spec_error_msg = "The spec convert_a/1 on line"
100103
101- output = run_task ( @ examples_path , [ "--no-compile" , "--" , beam ] )
104+ output = run_task ( @ examples_path , test_opts ( [ beam ] ) )
102105 assert String . contains? ( output , ex_spec_error_msg )
103106
104- output = run_task ( @ examples_path , [ "--no-compile" , "--no- ex-check", "--" , beam ] )
107+ output = run_task ( @ examples_path , test_opts ( [ "--no-ex-check" , "--" , beam ] ) )
105108 assert not String . contains? ( output , ex_spec_error_msg )
106109 end
107110
108111 @ tag if ( System . version ( ) >= "1.13" , do: :skip , else: :ok )
109112 test "--no-specify option" do
110- output = run_task ( @ type_path , [ "--no-compile" , "--" , @ s_wrong_ret_beam ] )
113+ output = run_task ( @ type_path , test_opts ( [ @ s_wrong_ret_beam ] ) )
111114 assert String . contains? ( output , "on line 3" )
112115 assert String . contains? ( output , "on line 6" )
113116
114- output = run_task ( @ type_path , [ "--no-compile" , "--no- specify", "--" , @ s_wrong_ret_beam ] )
117+ output = run_task ( @ type_path , test_opts ( [ "--no-specify" , "--" , @ s_wrong_ret_beam ] ) )
115118 assert String . contains? ( output , "on line 0" )
116119 assert not String . contains? ( output , "on line 3" )
117120 assert not String . contains? ( output , "on line 6" )
118121 end
119122
120123 test "--stop-on-first-error option" do
121- output =
122- run_task ( @ type_path , [ "--no-compile" , "--stop-on-first-error" , "--" , @ s_wrong_ret_beam ] )
124+ output = run_task ( @ type_path , test_opts ( [ "--stop-on-first-error" , "--" , @ s_wrong_ret_beam ] ) )
123125
124126 assert 2 == String . split ( output , @ s_wrong_ret_ex ) |> length ( )
125127 end
126128
127129 test "--fmt-location option" do
128- output =
129- run_task ( @ type_path , [ "--no-compile" , "--fmt-location" , "none" , "--" , @ s_wrong_ret_beam ] )
130+ output = run_task ( @ type_path , test_opts ( [ "--fmt-location" , "none" , "--" , @ s_wrong_ret_beam ] ) )
130131
131132 assert String . contains? ( output , "s_wrong_ret.ex: The integer is expected to have type" )
132133
133- output =
134- run_task ( @ type_path , [ "--no-compile" , "--fmt-location" , "brief" , "--" , @ s_wrong_ret_beam ] )
134+ output = run_task ( @ type_path , test_opts ( [ "--fmt-location" , "brief" , "--" , @ s_wrong_ret_beam ] ) )
135135
136136 assert String . contains? ( output , "s_wrong_ret.ex:3: The integer is expected to have type" )
137137
138138 output =
139- run_task ( @ type_path , [ "--no-compile" , "-- fmt-location", "verbose" , "--" , @ s_wrong_ret_beam ] )
139+ run_task ( @ type_path , test_opts ( [ "--fmt-location" , "verbose" , "--" , @ s_wrong_ret_beam ] ) )
140140
141141 assert String . contains? (
142142 output ,
@@ -156,19 +156,18 @@ defmodule Mix.Tasks.GradientTest do
156156
157157 test "--infer option" do
158158 beam = "Elixir.ListInfer.beam"
159- output = run_task ( @ type_path , [ "--no-compile" , "--" , beam ] )
159+ output = run_task ( @ type_path , test_opts ( [ beam ] ) )
160160 assert String . contains? ( output , @ no_problems_msg )
161161
162- output = run_task ( @ type_path , [ "--no-compile" , "-- infer", "--" , beam ] )
162+ output = run_task ( @ type_path , test_opts ( [ "--infer" , "--" , beam ] ) )
163163 assert not String . contains? ( output , @ no_problems_msg )
164164 assert String . contains? ( output , "list_infer.ex: The variable on line 4" )
165165 end
166166
167167 test "--code-path option" do
168168 ex_file = "wrong_ret.ex"
169169
170- output =
171- run_task ( @ type_path , [ "--no-compile" , "--code-path" , ex_file , "--" , @ s_wrong_ret_beam ] )
170+ output = run_task ( @ type_path , test_opts ( [ "--code-path" , ex_file , "--" , @ s_wrong_ret_beam ] ) )
172171
173172 assert not String . contains? ( output , @ s_wrong_ret_ex )
174173 assert String . contains? ( output , ex_file )
@@ -187,4 +186,8 @@ defmodule Mix.Tasks.GradientTest do
187186 File . cd ( cwd )
188187 res
189188 end
189+
190+ def test_opts ( opts ) do
191+ [ "--no-comile" , "--no-deps" ] ++ opts
192+ end
190193end
0 commit comments