summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@dashbit.co>2021-12-03 11:13:00 +0100
committerJosé Valim <jose.valim@dashbit.co>2021-12-03 11:13:00 +0100
commite48238950b29026b7e7afb7a840a203095109b21 (patch)
tree2eef82b768bd4d28c8cbc40bb23f718aea0ce9f2
parent6eb00ca7d2bddd9892dc2ef0dea2aef1c99f7e32 (diff)
downloadelixir-e48238950b29026b7e7afb7a840a203095109b21.tar.gz
Do not run test suite on mix test --profile-require
-rw-r--r--lib/mix/lib/mix/compilers/test.ex81
-rw-r--r--lib/mix/lib/mix/tasks/test.ex3
2 files changed, 41 insertions, 43 deletions
diff --git a/lib/mix/lib/mix/compilers/test.ex b/lib/mix/lib/mix/compilers/test.ex
index 88b8f2c30..69b724cef 100644
--- a/lib/mix/lib/mix/compilers/test.ex
+++ b/lib/mix/lib/mix/compilers/test.ex
@@ -25,52 +25,57 @@ defmodule Mix.Compilers.Test do
def require_and_run(matched_test_files, test_paths, opts) do
stale = opts[:stale]
- {test_files, stale_manifest_pid, parallel_require_opts} =
+ {test_files, stale_manifest_pid, parallel_require_callbacks} =
if stale do
set_up_stale(matched_test_files, test_paths, opts)
else
{matched_test_files, nil, []}
end
- if test_files == [] do
- :noop
- else
- task = ExUnit.async_run()
- parallel_require_opts = profile_opts(parallel_require_opts, opts)
- warnings_as_errors? = Keyword.get(opts, :warnings_as_errors, false)
-
- try do
- failed? =
- case Kernel.ParallelCompiler.require(test_files, parallel_require_opts) do
- {:ok, _, [_ | _]} when warnings_as_errors? -> true
- {:ok, _, _} -> false
- {:error, _, _} -> exit({:shutdown, 1})
- end
+ cond do
+ test_files == [] ->
+ :noop
+
+ Keyword.get(opts, :profile_require) == "time" ->
+ Kernel.ParallelCompiler.require(test_files, profile: :time)
+ :noop
+
+ true ->
+ task = ExUnit.async_run()
+ warnings_as_errors? = Keyword.get(opts, :warnings_as_errors, false)
+
+ try do
+ failed? =
+ case Kernel.ParallelCompiler.require(test_files, parallel_require_callbacks) do
+ {:ok, _, [_ | _]} when warnings_as_errors? -> true
+ {:ok, _, _} -> false
+ {:error, _, _} -> exit({:shutdown, 1})
+ end
+
+ %{failures: failures} = results = ExUnit.await_run(task)
- %{failures: failures} = results = ExUnit.await_run(task)
+ if failures == 0 do
+ if failed? do
+ message =
+ "\nERROR! Test suite aborted after successful execution due to warnings while using the --warnings-as-errors option"
- if failures == 0 do
- if failed? do
- message =
- "\nERROR! Test suite aborted after successful execution due to warnings while using the --warnings-as-errors option"
+ IO.puts(:stderr, IO.ANSI.format([:red, message]))
+ exit({:shutdown, 1})
+ end
- IO.puts(:stderr, IO.ANSI.format([:red, message]))
- exit({:shutdown, 1})
+ agent_write_manifest(stale_manifest_pid)
end
- agent_write_manifest(stale_manifest_pid)
+ {:ok, results}
+ catch
+ kind, reason ->
+ # In case there is an error, shut down the runner task
+ # before the error propagates up and trigger links.
+ Task.shutdown(task)
+ :erlang.raise(kind, reason, __STACKTRACE__)
+ after
+ agent_stop(stale_manifest_pid)
end
-
- {:ok, results}
- catch
- kind, reason ->
- # In case there is an error, shut down the runner task
- # before the error propagates up and trigger links.
- Task.shutdown(task)
- :erlang.raise(kind, reason, __STACKTRACE__)
- after
- agent_stop(stale_manifest_pid)
- end
end
end
@@ -167,14 +172,6 @@ defmodule Mix.Compilers.Test do
sources
end
- defp profile_opts(target, opts) do
- if Keyword.get(opts, :profile_require) == "time" do
- Keyword.put(target, :profile, :time)
- else
- target
- end
- end
-
## Manifest
defp manifest, do: Path.join(Mix.Project.manifest_path(), @stale_manifest)
diff --git a/lib/mix/lib/mix/tasks/test.ex b/lib/mix/lib/mix/tasks/test.ex
index 911f385d9..754cd1928 100644
--- a/lib/mix/lib/mix/tasks/test.ex
+++ b/lib/mix/lib/mix/tasks/test.ex
@@ -160,7 +160,8 @@ defmodule Mix.Tasks.Test do
* `--preload-modules` - preloads all modules defined in applications
- * `--profile-require` - profiles the time spent to require test files
+ * `--profile-require` - profiles the time spent to require test files.
+ Used only for debugging. The test suite does not run.
* `--raise` - raises if the test suite failed