@@ -25,52 +25,57 @@ defmodule Mix.Compilers.Test do
25
25
def require_and_run ( matched_test_files , test_paths , opts ) do
26
26
stale = opts [ :stale ]
27
27
28
- { test_files , stale_manifest_pid , parallel_require_opts } =
28
+ { test_files , stale_manifest_pid , parallel_require_callbacks } =
29
29
if stale do
30
30
set_up_stale ( matched_test_files , test_paths , opts )
31
31
else
32
32
{ matched_test_files , nil , [ ] }
33
33
end
34
34
35
- if test_files == [ ] do
36
- :noop
37
- else
38
- task = ExUnit . async_run ( )
39
- parallel_require_opts = profile_opts ( parallel_require_opts , opts )
40
- warnings_as_errors? = Keyword . get ( opts , :warnings_as_errors , false )
41
-
42
- try do
43
- failed? =
44
- case Kernel.ParallelCompiler . require ( test_files , parallel_require_opts ) do
45
- { :ok , _ , [ _ | _ ] } when warnings_as_errors? -> true
46
- { :ok , _ , _ } -> false
47
- { :error , _ , _ } -> exit ( { :shutdown , 1 } )
48
- end
35
+ cond do
36
+ test_files == [ ] ->
37
+ :noop
38
+
39
+ Keyword . get ( opts , :profile_require ) == "time" ->
40
+ Kernel.ParallelCompiler . require ( test_files , profile: :time )
41
+ :noop
42
+
43
+ true ->
44
+ task = ExUnit . async_run ( )
45
+ warnings_as_errors? = Keyword . get ( opts , :warnings_as_errors , false )
46
+
47
+ try do
48
+ failed? =
49
+ case Kernel.ParallelCompiler . require ( test_files , parallel_require_callbacks ) do
50
+ { :ok , _ , [ _ | _ ] } when warnings_as_errors? -> true
51
+ { :ok , _ , _ } -> false
52
+ { :error , _ , _ } -> exit ( { :shutdown , 1 } )
53
+ end
54
+
55
+ % { failures: failures } = results = ExUnit . await_run ( task )
49
56
50
- % { failures: failures } = results = ExUnit . await_run ( task )
57
+ if failures == 0 do
58
+ if failed? do
59
+ message =
60
+ "\n ERROR! Test suite aborted after successful execution due to warnings while using the --warnings-as-errors option"
51
61
52
- if failures == 0 do
53
- if failed? do
54
- message =
55
- "\n ERROR! Test suite aborted after successful execution due to warnings while using the --warnings-as-errors option"
62
+ IO . puts ( :stderr , IO.ANSI . format ( [ :red , message ] ) )
63
+ exit ( { :shutdown , 1 } )
64
+ end
56
65
57
- IO . puts ( :stderr , IO.ANSI . format ( [ :red , message ] ) )
58
- exit ( { :shutdown , 1 } )
66
+ agent_write_manifest ( stale_manifest_pid )
59
67
end
60
68
61
- agent_write_manifest ( stale_manifest_pid )
69
+ { :ok , results }
70
+ catch
71
+ kind , reason ->
72
+ # In case there is an error, shut down the runner task
73
+ # before the error propagates up and trigger links.
74
+ Task . shutdown ( task )
75
+ :erlang . raise ( kind , reason , __STACKTRACE__ )
76
+ after
77
+ agent_stop ( stale_manifest_pid )
62
78
end
63
-
64
- { :ok , results }
65
- catch
66
- kind , reason ->
67
- # In case there is an error, shut down the runner task
68
- # before the error propagates up and trigger links.
69
- Task . shutdown ( task )
70
- :erlang . raise ( kind , reason , __STACKTRACE__ )
71
- after
72
- agent_stop ( stale_manifest_pid )
73
- end
74
79
end
75
80
end
76
81
@@ -167,14 +172,6 @@ defmodule Mix.Compilers.Test do
167
172
sources
168
173
end
169
174
170
- defp profile_opts ( target , opts ) do
171
- if Keyword . get ( opts , :profile_require ) == "time" do
172
- Keyword . put ( target , :profile , :time )
173
- else
174
- target
175
- end
176
- end
177
-
178
175
## Manifest
179
176
180
177
defp manifest , do: Path . join ( Mix.Project . manifest_path ( ) , @ stale_manifest )
0 commit comments