about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFelix S. Klock II <pnkfelix@pnkfx.org>2021-03-15 17:37:06 -0400
committerFelix S. Klock II <pnkfelix@pnkfx.org>2021-03-15 23:19:35 -0400
commitd6de60fb322828ec3b828278f05598f2db282142 (patch)
tree950f091b717e5f03c008d1c4a95433662949d251
parent107896c32d5dda4db508968ff34997a39d286966 (diff)
Make bootstrap be more informative when one does `x.py test` on a beta checkout without other mods.
To be clear, by default running `x.py test` on a checkout of the beta branch
currently fails, and with this change will continue to fail, because `x.py
tests` runs `x.py test src/tools/tidy` which tries to run `rustfmt` and that
will fail because the `rustfmt` binary is pinned to the current nighlty and we
do not attempt to distribute one for the beta builds.

This change gives a better error message than the current message, which is just
"./x.py fmt is not supported on this channel" without providing any hint about
what one might do about that problem.

(update: placated tidy.)
-rw-r--r--src/bootstrap/test.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs
index 5d836c6bb62..86d940cd733 100644
--- a/src/bootstrap/test.rs
+++ b/src/bootstrap/test.rs
@@ -791,6 +791,19 @@ impl Step for Tidy {
 
         if builder.config.channel == "dev" || builder.config.channel == "nightly" {
             builder.info("fmt check");
+            if builder.config.initial_rustfmt.is_none() {
+                let inferred_rustfmt_dir = builder.config.initial_rustc.parent().unwrap();
+                eprintln!(
+                    "\
+error: no `rustfmt` binary found in {PATH}
+info: `rust.channel` is currently set to \"{CHAN}\"
+help: if you are testing a beta branch, set `rust.channel` to \"beta\" in the `config.toml` file
+help: to skip test's attempt to check tidiness, pass `--exclude src/tools/tidy` to `x.py test`",
+                    PATH = inferred_rustfmt_dir.display(),
+                    CHAN = builder.config.channel,
+                );
+                std::process::exit(1);
+            }
             crate::format::format(&builder.build, !builder.config.cmd.bless());
         }
     }