From 1b8d142a14d76a2afdc62d8bfb90f9d2a0376c40 Mon Sep 17 00:00:00 2001 From: "Tyler A. Young" Date: Tue, 31 Dec 2024 09:30:36 -0600 Subject: [PATCH 1/2] Clarify that `mix do` early-exits on error A coworker and I had to test this ourselves to figure out what would happen in `mix do compile + test` if the compilation step failed, so I figured it'd be worth calling out this behavior in the docs. --- lib/mix/lib/mix/tasks/do.ex | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/mix/lib/mix/tasks/do.ex b/lib/mix/lib/mix/tasks/do.ex index d2c178da2d3..23f2e1c9846 100644 --- a/lib/mix/lib/mix/tasks/do.ex +++ b/lib/mix/lib/mix/tasks/do.ex @@ -4,7 +4,8 @@ defmodule Mix.Tasks.Do do @shortdoc "Executes the tasks separated by plus" @moduledoc """ - Executes the tasks separated by `+`: + Executes the tasks separated by `+`, aborting if any task exits + with an error: $ mix do compile --list + deps @@ -41,6 +42,16 @@ defmodule Mix.Tasks.Do do Since then, the `+` operator has been introduced as a separator for better support on Windows terminals. + ## Error handling + + If any task in the list of tasks exits with an error, + no subsequent tasks will be run. For instance: + + $ mix do compile + test + + If the compilation step fails, the tests will not be + attempted. + ## Command line options * `--app` - limit recursive tasks to the given apps. From 420956ee41822e07ce9bbf0a7fe59e172312811b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 31 Dec 2024 18:25:28 +0100 Subject: [PATCH 2/2] Update lib/mix/lib/mix/tasks/do.ex --- lib/mix/lib/mix/tasks/do.ex | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/mix/lib/mix/tasks/do.ex b/lib/mix/lib/mix/tasks/do.ex index 23f2e1c9846..6cdfb92faff 100644 --- a/lib/mix/lib/mix/tasks/do.ex +++ b/lib/mix/lib/mix/tasks/do.ex @@ -4,8 +4,9 @@ defmodule Mix.Tasks.Do do @shortdoc "Executes the tasks separated by plus" @moduledoc """ - Executes the tasks separated by `+`, aborting if any task exits - with an error: + Executes the tasks separated by `+`, aborting if any task errors. + + Here is an example: $ mix do compile --list + deps