mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
set long variants for required args
Currently some required arguments (like path of the root dir) are ordered, but it causes an user (mainly bootstrap) needs to remember the order. This commit introduces long arguments (e.g., --root-path) for required args.
This commit is contained in:
@@ -1293,19 +1293,19 @@ fn make_run(run: RunConfig<'_>) {
|
||||
/// for the `dev` or `nightly` channels.
|
||||
fn run(self, builder: &Builder<'_>) {
|
||||
let mut cmd = builder.tool_cmd(Tool::Tidy);
|
||||
cmd.arg(&builder.src);
|
||||
cmd.arg(&builder.initial_cargo);
|
||||
cmd.arg(&builder.out);
|
||||
cmd.arg(format!("--root-path={}", &builder.src.display()));
|
||||
cmd.arg(format!("--cargo-path={}", &builder.initial_cargo.display()));
|
||||
cmd.arg(format!("--output-dir={}", &builder.out.display()));
|
||||
// Tidy is heavily IO constrained. Still respect `-j`, but use a higher limit if `jobs` hasn't been configured.
|
||||
let jobs = builder.config.jobs.unwrap_or_else(|| {
|
||||
8 * std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get) as u32
|
||||
});
|
||||
cmd.arg(jobs.to_string());
|
||||
cmd.arg(format!("--concurrency={jobs}"));
|
||||
// pass the path to the yarn command used for installing js deps.
|
||||
if let Some(yarn) = &builder.config.yarn {
|
||||
cmd.arg(yarn);
|
||||
cmd.arg(format!("--npm-path={}", yarn.display()));
|
||||
} else {
|
||||
cmd.arg("yarn");
|
||||
cmd.arg("--npm-path=yarn");
|
||||
}
|
||||
if builder.is_verbose() {
|
||||
cmd.arg("--verbose");
|
||||
|
||||
@@ -25,30 +25,40 @@ fn command() -> Command {
|
||||
.arg(
|
||||
Arg::new("root_path")
|
||||
.help("path of the root directory")
|
||||
.long("root-path")
|
||||
.required(true)
|
||||
.value_parser(value_parser!(PathBuf)),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("cargo")
|
||||
.help("path of cargo")
|
||||
.long("cargo-path")
|
||||
.required(true)
|
||||
.value_parser(value_parser!(PathBuf)),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("output_directory")
|
||||
.help("path of output directory")
|
||||
.long("output-dir")
|
||||
.required(true)
|
||||
.value_parser(value_parser!(PathBuf)),
|
||||
)
|
||||
.arg(Arg::new("concurrency").required(true).value_parser(value_parser!(NonZeroUsize)))
|
||||
.arg(
|
||||
Arg::new("concurrency")
|
||||
.help("number of threads working concurrently")
|
||||
.long("concurrency")
|
||||
.required(true)
|
||||
.value_parser(value_parser!(NonZeroUsize)),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("npm")
|
||||
.help("path of npm")
|
||||
.long("npm-path")
|
||||
.required(true)
|
||||
.value_parser(value_parser!(PathBuf)),
|
||||
)
|
||||
.arg(Arg::new("verbose").help("verbose").long("verbose").action(ArgAction::SetTrue))
|
||||
.arg(Arg::new("bless").help("bless").long("bless").action(ArgAction::SetTrue))
|
||||
.arg(Arg::new("bless").help("target files are modified").long("bless").action(ArgAction::SetTrue))
|
||||
.arg(
|
||||
Arg::new("extra_checks")
|
||||
.help("extra checks")
|
||||
|
||||
@@ -2,15 +2,21 @@
|
||||
|
||||
use crate::arg_parser::TidyArgParser;
|
||||
|
||||
// Test all arguments
|
||||
#[test]
|
||||
fn test_tidy_parser() {
|
||||
fn test_tidy_parser_full() {
|
||||
let args = vec![
|
||||
"rust-tidy",
|
||||
"/home/user/rust", // Root dir
|
||||
"/home/user/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo", // Cardo location
|
||||
"/home/user/rust/build", // Build dir
|
||||
"16", // Number of concurrency
|
||||
"/home/user/rust/build/misc-tools/bin/yarn", // Yarn location
|
||||
"--root-path",
|
||||
"/home/user/rust",
|
||||
"--cargo-path",
|
||||
"/home/user/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo",
|
||||
"--output-dir",
|
||||
"/home/user/rust/build",
|
||||
"--concurrency",
|
||||
"16",
|
||||
"--npm-path",
|
||||
"yarn",
|
||||
"--verbose",
|
||||
"--bless",
|
||||
"--extra-checks",
|
||||
@@ -29,7 +35,7 @@ fn test_tidy_parser() {
|
||||
);
|
||||
assert_eq!(parsed_args.output_directory, PathBuf::from("/home/user/rust/build"));
|
||||
assert_eq!(parsed_args.concurrency.get(), 16);
|
||||
assert_eq!(parsed_args.npm, PathBuf::from("/home/user/rust/build/misc-tools/bin/yarn"));
|
||||
assert_eq!(parsed_args.npm, PathBuf::from("yarn"));
|
||||
assert!(parsed_args.verbose);
|
||||
assert!(parsed_args.bless);
|
||||
assert_eq!(
|
||||
|
||||
Reference in New Issue
Block a user