Skip to content

Commit dfd12b9

Browse files
committed
Do not run test suite on mix test --profile-require
1 parent ed91b33 commit dfd12b9

File tree

2 files changed

+41
-43
lines changed

2 files changed

+41
-43
lines changed

lib/mix/lib/mix/compilers/test.ex

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -25,52 +25,57 @@ defmodule Mix.Compilers.Test do
2525
def require_and_run(matched_test_files, test_paths, opts) do
2626
stale = opts[:stale]
2727

28-
{test_files, stale_manifest_pid, parallel_require_opts} =
28+
{test_files, stale_manifest_pid, parallel_require_callbacks} =
2929
if stale do
3030
set_up_stale(matched_test_files, test_paths, opts)
3131
else
3232
{matched_test_files, nil, []}
3333
end
3434

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)
4956

50-
%{failures: failures} = results = ExUnit.await_run(task)
57+
if failures == 0 do
58+
if failed? do
59+
message =
60+
"\nERROR! Test suite aborted after successful execution due to warnings while using the --warnings-as-errors option"
5161

52-
if failures == 0 do
53-
if failed? do
54-
message =
55-
"\nERROR! 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
5665

57-
IO.puts(:stderr, IO.ANSI.format([:red, message]))
58-
exit({:shutdown, 1})
66+
agent_write_manifest(stale_manifest_pid)
5967
end
6068

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)
6278
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
7479
end
7580
end
7681

@@ -167,14 +172,6 @@ defmodule Mix.Compilers.Test do
167172
sources
168173
end
169174

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-
178175
## Manifest
179176

180177
defp manifest, do: Path.join(Mix.Project.manifest_path(), @stale_manifest)

lib/mix/lib/mix/tasks/test.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ defmodule Mix.Tasks.Test do
160160
161161
* `--preload-modules` - preloads all modules defined in applications
162162
163-
* `--profile-require` - profiles the time spent to require test files
163+
* `--profile-require` - profiles the time spent to require test files.
164+
Used only for debugging. The test suite does not run.
164165
165166
* `--raise` - raises if the test suite failed
166167

0 commit comments

Comments
 (0)