Skip to content

Commit 183a31b

Browse files
authored
Rollup merge of rust-lang#112084 - ozkanonur:improvements, r=clubby789
enhancements on build_helper utilization and rustdoc-gui-test This change provides codebase improvements, resolves `FIXME` in `rustdoc-gui-test` and makes `rustdoc-gui` test able to find local `node_modules` directory outside of the source root.
2 parents f589451 + c64db2c commit 183a31b

File tree

19 files changed

+92
-82
lines changed

19 files changed

+92
-82
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4289,6 +4289,7 @@ dependencies = [
42894289
name = "rustdoc-gui-test"
42904290
version = "0.1.0"
42914291
dependencies = [
4292+
"build_helper",
42924293
"compiletest",
42934294
"getopts",
42944295
"walkdir",

src/bootstrap/builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ impl StepDescription {
381381
eprintln!(
382382
"note: if you are adding a new Step to bootstrap itself, make sure you register it with `describe!`"
383383
);
384-
crate::detail_exit(1);
384+
crate::detail_exit_macro!(1);
385385
}
386386
}
387387
}
@@ -1355,7 +1355,7 @@ impl<'a> Builder<'a> {
13551355
"error: `x.py clippy` requires a host `rustc` toolchain with the `clippy` component"
13561356
);
13571357
eprintln!("help: try `rustup component add clippy`");
1358-
crate::detail_exit(1);
1358+
crate::detail_exit_macro!(1);
13591359
});
13601360
if !t!(std::str::from_utf8(&output.stdout)).contains("nightly") {
13611361
rustflags.arg("--cfg=bootstrap");

src/bootstrap/compile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1686,7 +1686,7 @@ pub fn run_cargo(
16861686
});
16871687

16881688
if !ok {
1689-
crate::detail_exit(1);
1689+
crate::detail_exit_macro!(1);
16901690
}
16911691

16921692
// Ok now we need to actually find all the files listed in `toplevel`. We've

src/bootstrap/config.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use crate::channel::{self, GitInfo};
2323
pub use crate::flags::Subcommand;
2424
use crate::flags::{Color, Flags, Warnings};
2525
use crate::util::{exe, output, t};
26+
use build_helper::detail_exit_macro;
2627
use once_cell::sync::OnceCell;
2728
use serde::{Deserialize, Deserializer};
2829
use serde_derive::Deserialize;
@@ -579,7 +580,7 @@ macro_rules! define_config {
579580
panic!("overriding existing option")
580581
} else {
581582
eprintln!("overriding existing option: `{}`", stringify!($field));
582-
crate::detail_exit(2);
583+
detail_exit_macro!(2);
583584
}
584585
} else {
585586
self.$field = other.$field;
@@ -678,7 +679,7 @@ impl<T> Merge for Option<T> {
678679
panic!("overriding existing option")
679680
} else {
680681
eprintln!("overriding existing option");
681-
crate::detail_exit(2);
682+
detail_exit_macro!(2);
682683
}
683684
} else {
684685
*self = other;
@@ -944,7 +945,7 @@ impl Config {
944945
.and_then(|table: toml::Value| TomlConfig::deserialize(table))
945946
.unwrap_or_else(|err| {
946947
eprintln!("failed to parse TOML configuration '{}': {err}", file.display());
947-
crate::detail_exit(2);
948+
detail_exit_macro!(2);
948949
})
949950
}
950951
Self::parse_inner(args, get_toml)
@@ -978,7 +979,7 @@ impl Config {
978979
eprintln!(
979980
"Cannot use both `llvm_bolt_profile_generate` and `llvm_bolt_profile_use` at the same time"
980981
);
981-
crate::detail_exit(1);
982+
detail_exit_macro!(1);
982983
}
983984

984985
// Infer the rest of the configuration.
@@ -1094,7 +1095,7 @@ impl Config {
10941095
}
10951096
}
10961097
eprintln!("failed to parse override `{option}`: `{err}");
1097-
crate::detail_exit(2)
1098+
detail_exit_macro!(2)
10981099
}
10991100
toml.merge(override_toml, ReplaceOpt::Override);
11001101

@@ -1810,7 +1811,7 @@ impl Config {
18101811
println!("help: maybe your repository history is too shallow?");
18111812
println!("help: consider disabling `download-rustc`");
18121813
println!("help: or fetch enough history to include one upstream commit");
1813-
crate::detail_exit(1);
1814+
crate::detail_exit_macro!(1);
18141815
}
18151816

18161817
// Warn if there were changes to the compiler or standard library since the ancestor commit.

src/bootstrap/download.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ use std::{
77
process::{Command, Stdio},
88
};
99

10+
use build_helper::util::try_run;
1011
use once_cell::sync::OnceCell;
1112
use xz2::bufread::XzDecoder;
1213

1314
use crate::{
1415
config::RustfmtMetadata,
1516
llvm::detect_llvm_sha,
1617
t,
17-
util::{check_run, exe, program_out_of_date, try_run},
18+
util::{check_run, exe, program_out_of_date},
1819
Config,
1920
};
2021

@@ -245,7 +246,7 @@ impl Config {
245246
if !help_on_error.is_empty() {
246247
eprintln!("{}", help_on_error);
247248
}
248-
crate::detail_exit(1);
249+
crate::detail_exit_macro!(1);
249250
}
250251
}
251252

src/bootstrap/flags.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ impl Flags {
193193
} else {
194194
panic!("No paths available for subcommand `{}`", subcommand.as_str());
195195
}
196-
crate::detail_exit(0);
196+
crate::detail_exit_macro!(0);
197197
}
198198

199199
Flags::parse_from(it)
@@ -538,7 +538,7 @@ pub fn get_completion<G: clap_complete::Generator>(shell: G, path: &Path) -> Opt
538538
} else {
539539
std::fs::read_to_string(path).unwrap_or_else(|_| {
540540
eprintln!("couldn't read {}", path.display());
541-
crate::detail_exit(1)
541+
crate::detail_exit_macro!(1)
542542
})
543543
};
544544
let mut buf = Vec::new();

src/bootstrap/format.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fn rustfmt(src: &Path, rustfmt: &Path, paths: &[PathBuf], check: bool) -> impl F
4040
code, run `./x.py fmt` instead.",
4141
cmd_debug,
4242
);
43-
crate::detail_exit(1);
43+
crate::detail_exit_macro!(1);
4444
}
4545
true
4646
}
@@ -196,7 +196,7 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
196196

197197
let rustfmt_path = build.initial_rustfmt().unwrap_or_else(|| {
198198
eprintln!("./x.py fmt is not supported on this channel");
199-
crate::detail_exit(1);
199+
crate::detail_exit_macro!(1);
200200
});
201201
assert!(rustfmt_path.exists(), "{}", rustfmt_path.display());
202202
let src = build.src.clone();

src/bootstrap/lib.rs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use std::process::{Command, Stdio};
2727
use std::str;
2828

2929
use build_helper::ci::{gha, CiEnv};
30+
use build_helper::detail_exit_macro;
3031
use channel::GitInfo;
3132
use config::{DryRun, Target};
3233
use filetime::FileTime;
@@ -699,7 +700,7 @@ impl Build {
699700
for failure in failures.iter() {
700701
eprintln!(" - {}\n", failure);
701702
}
702-
detail_exit(1);
703+
detail_exit_macro!(1);
703704
}
704705

705706
#[cfg(feature = "build-metrics")]
@@ -1482,7 +1483,7 @@ impl Build {
14821483
"Error: Unable to find the stamp file {}, did you try to keep a nonexistent build stage?",
14831484
stamp.display()
14841485
);
1485-
crate::detail_exit(1);
1486+
crate::detail_exit_macro!(1);
14861487
}
14871488

14881489
let mut paths = Vec::new();
@@ -1674,7 +1675,7 @@ Alternatively, set `download-ci-llvm = true` in that `[llvm]` section
16741675
to download LLVM rather than building it.
16751676
"
16761677
);
1677-
detail_exit(1);
1678+
detail_exit_macro!(1);
16781679
}
16791680
}
16801681

@@ -1739,18 +1740,6 @@ fn chmod(path: &Path, perms: u32) {
17391740
#[cfg(windows)]
17401741
fn chmod(_path: &Path, _perms: u32) {}
17411742

1742-
/// If code is not 0 (successful exit status), exit status is 101 (rust's default error code.)
1743-
/// If the test is running and code is an error code, it will cause a panic.
1744-
fn detail_exit(code: i32) -> ! {
1745-
// if in test and code is an error code, panic with status code provided
1746-
if cfg!(test) {
1747-
panic!("status code: {}", code);
1748-
} else {
1749-
// otherwise,exit with provided status code
1750-
std::process::exit(code);
1751-
}
1752-
}
1753-
17541743
impl Compiler {
17551744
pub fn with_stage(mut self, stage: u32) -> Compiler {
17561745
self.stage = stage;

src/bootstrap/render_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub(crate) fn try_run_tests(builder: &Builder<'_>, cmd: &mut Command) -> bool {
3030

3131
if !run_tests(builder, cmd) {
3232
if builder.fail_fast {
33-
crate::detail_exit(1);
33+
crate::detail_exit_macro!(1);
3434
} else {
3535
let mut failures = builder.delayed_failures.borrow_mut();
3636
failures.push(format!("{cmd:?}"));

src/bootstrap/sanity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ You should install cmake, or set `download-ci-llvm = true` in the
104104
than building it.
105105
"
106106
);
107-
crate::detail_exit(1);
107+
crate::detail_exit_macro!(1);
108108
}
109109
}
110110

0 commit comments

Comments
 (0)