Skip to content

Commit cef021a

Browse files
authored
Rollup merge of rust-lang#152840 - jieyouxu:bootstrap-install-src-no-docs, r=clubby789
Add bootstrap snapshot tests for {`install`, `install src`} And `install src` with `build.docs = false`. This is mostly to get coverage for the baseline to make it easier to review rust-lang#150845.
2 parents eb37a6c + a9e6a89 commit cef021a

2 files changed

Lines changed: 157 additions & 3 deletions

File tree

src/bootstrap/src/core/builder/tests.rs

Lines changed: 152 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2854,19 +2854,168 @@ mod snapshot {
28542854
.render_steps(), @"[clippy] rustc 0 <host> -> bootstrap 1 <host>");
28552855
}
28562856

2857+
#[test]
2858+
fn install_plain() {
2859+
let ctx = TestCtx::new();
2860+
insta::assert_snapshot!(
2861+
ctx.config("install")
2862+
.args(&[
2863+
// Using backslashes fails with `--set`
2864+
"--set", &format!("install.prefix={}", ctx.normalized_dir()),
2865+
"--set", &format!("install.bindir={}", ctx.normalized_dir()),
2866+
"--set", &format!("install.libdir={}", ctx.normalized_dir()),
2867+
"--set", &format!("install.datadir={}", ctx.normalized_dir()),
2868+
"--set", &format!("install.mandir={}", ctx.normalized_dir()),
2869+
"--set", &format!("install.sysconfdir={}", ctx.normalized_dir()),
2870+
"--build", "x86_64-unknown-linux-gnu",
2871+
"--host", "x86_64-unknown-linux-gnu",
2872+
"--target", "x86_64-unknown-linux-gnu",
2873+
])
2874+
.get_steps()
2875+
.render_with(RenderConfig {
2876+
normalize_host: false
2877+
}), @r"
2878+
[build] llvm <x86_64-unknown-linux-gnu>
2879+
[build] rustc 0 <x86_64-unknown-linux-gnu> -> rustc 1 <x86_64-unknown-linux-gnu>
2880+
[build] rustc 0 <x86_64-unknown-linux-gnu> -> UnstableBookGen 1 <x86_64-unknown-linux-gnu>
2881+
[build] rustc 0 <x86_64-unknown-linux-gnu> -> Rustbook 1 <x86_64-unknown-linux-gnu>
2882+
[doc] unstable-book (book) <x86_64-unknown-linux-gnu>
2883+
[build] rustc 1 <x86_64-unknown-linux-gnu> -> std 1 <x86_64-unknown-linux-gnu>
2884+
[doc] book (book) <x86_64-unknown-linux-gnu>
2885+
[doc] book/first-edition (book) <x86_64-unknown-linux-gnu>
2886+
[doc] book/second-edition (book) <x86_64-unknown-linux-gnu>
2887+
[doc] book/2018-edition (book) <x86_64-unknown-linux-gnu>
2888+
[build] rustdoc 1 <x86_64-unknown-linux-gnu>
2889+
[doc] rustc 1 <x86_64-unknown-linux-gnu> -> standalone 2 <x86_64-unknown-linux-gnu>
2890+
[doc] rustc 1 <x86_64-unknown-linux-gnu> -> std 1 <x86_64-unknown-linux-gnu> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind]
2891+
[build] rustc 1 <x86_64-unknown-linux-gnu> -> rustc 2 <x86_64-unknown-linux-gnu>
2892+
[build] rustc 1 <x86_64-unknown-linux-gnu> -> error-index 2 <x86_64-unknown-linux-gnu>
2893+
[doc] rustc 1 <x86_64-unknown-linux-gnu> -> error-index 2 <x86_64-unknown-linux-gnu>
2894+
[doc] nomicon (book) <x86_64-unknown-linux-gnu>
2895+
[doc] rustc 1 <x86_64-unknown-linux-gnu> -> reference (book) 2 <x86_64-unknown-linux-gnu>
2896+
[doc] rustdoc (book) <x86_64-unknown-linux-gnu>
2897+
[doc] rust-by-example (book) <x86_64-unknown-linux-gnu>
2898+
[build] rustc 0 <x86_64-unknown-linux-gnu> -> LintDocs 1 <x86_64-unknown-linux-gnu>
2899+
[doc] rustc (book) <x86_64-unknown-linux-gnu>
2900+
[doc] cargo (book) <x86_64-unknown-linux-gnu>
2901+
[doc] clippy (book) <x86_64-unknown-linux-gnu>
2902+
[doc] embedded-book (book) <x86_64-unknown-linux-gnu>
2903+
[doc] edition-guide (book) <x86_64-unknown-linux-gnu>
2904+
[doc] style-guide (book) <x86_64-unknown-linux-gnu>
2905+
[doc] rustc 1 <x86_64-unknown-linux-gnu> -> releases 2 <x86_64-unknown-linux-gnu>
2906+
[build] rustc 0 <x86_64-unknown-linux-gnu> -> RustInstaller 1 <x86_64-unknown-linux-gnu>
2907+
[dist] docs <x86_64-unknown-linux-gnu>
2908+
[dist] rustc 1 <x86_64-unknown-linux-gnu> -> std 1 <x86_64-unknown-linux-gnu>
2909+
[build] rustdoc 2 <x86_64-unknown-linux-gnu>
2910+
[build] rustc 0 <x86_64-unknown-linux-gnu> -> GenerateCopyright 1 <x86_64-unknown-linux-gnu>
2911+
[dist] rustc <x86_64-unknown-linux-gnu>
2912+
");
2913+
}
2914+
2915+
#[test]
2916+
fn install_src() {
2917+
let ctx = TestCtx::new();
2918+
insta::assert_snapshot!(
2919+
ctx.config("install")
2920+
.path("src")
2921+
.args(&[
2922+
// Using backslashes fails with `--set`
2923+
"--set", &format!("install.prefix={}", ctx.normalized_dir()),
2924+
"--set", &format!("install.bindir={}", ctx.normalized_dir()),
2925+
"--set", &format!("install.libdir={}", ctx.normalized_dir()),
2926+
"--set", &format!("install.datadir={}", ctx.normalized_dir()),
2927+
"--set", &format!("install.mandir={}", ctx.normalized_dir()),
2928+
"--set", &format!("install.sysconfdir={}", ctx.normalized_dir()),
2929+
"--build", "x86_64-unknown-linux-gnu",
2930+
"--host", "x86_64-unknown-linux-gnu",
2931+
"--target", "x86_64-unknown-linux-gnu",
2932+
])
2933+
.get_steps()
2934+
.render_with(RenderConfig {
2935+
normalize_host: false
2936+
}), @r"
2937+
[build] llvm <x86_64-unknown-linux-gnu>
2938+
[build] rustc 0 <x86_64-unknown-linux-gnu> -> rustc 1 <x86_64-unknown-linux-gnu>
2939+
[build] rustc 0 <x86_64-unknown-linux-gnu> -> UnstableBookGen 1 <x86_64-unknown-linux-gnu>
2940+
[build] rustc 0 <x86_64-unknown-linux-gnu> -> Rustbook 1 <x86_64-unknown-linux-gnu>
2941+
[doc] unstable-book (book) <x86_64-unknown-linux-gnu>
2942+
[build] rustc 1 <x86_64-unknown-linux-gnu> -> std 1 <x86_64-unknown-linux-gnu>
2943+
[doc] book (book) <x86_64-unknown-linux-gnu>
2944+
[doc] book/first-edition (book) <x86_64-unknown-linux-gnu>
2945+
[doc] book/second-edition (book) <x86_64-unknown-linux-gnu>
2946+
[doc] book/2018-edition (book) <x86_64-unknown-linux-gnu>
2947+
[build] rustdoc 1 <x86_64-unknown-linux-gnu>
2948+
[doc] rustc 1 <x86_64-unknown-linux-gnu> -> standalone 2 <x86_64-unknown-linux-gnu>
2949+
[doc] rustc 1 <x86_64-unknown-linux-gnu> -> std 1 <x86_64-unknown-linux-gnu> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind]
2950+
[build] rustc 1 <x86_64-unknown-linux-gnu> -> rustc 2 <x86_64-unknown-linux-gnu>
2951+
[build] rustc 1 <x86_64-unknown-linux-gnu> -> error-index 2 <x86_64-unknown-linux-gnu>
2952+
[doc] rustc 1 <x86_64-unknown-linux-gnu> -> error-index 2 <x86_64-unknown-linux-gnu>
2953+
[doc] nomicon (book) <x86_64-unknown-linux-gnu>
2954+
[doc] rustc 1 <x86_64-unknown-linux-gnu> -> reference (book) 2 <x86_64-unknown-linux-gnu>
2955+
[doc] rustdoc (book) <x86_64-unknown-linux-gnu>
2956+
[doc] rust-by-example (book) <x86_64-unknown-linux-gnu>
2957+
[build] rustc 0 <x86_64-unknown-linux-gnu> -> LintDocs 1 <x86_64-unknown-linux-gnu>
2958+
[doc] rustc (book) <x86_64-unknown-linux-gnu>
2959+
[doc] cargo (book) <x86_64-unknown-linux-gnu>
2960+
[doc] clippy (book) <x86_64-unknown-linux-gnu>
2961+
[doc] embedded-book (book) <x86_64-unknown-linux-gnu>
2962+
[doc] edition-guide (book) <x86_64-unknown-linux-gnu>
2963+
[doc] style-guide (book) <x86_64-unknown-linux-gnu>
2964+
[doc] rustc 1 <x86_64-unknown-linux-gnu> -> releases 2 <x86_64-unknown-linux-gnu>
2965+
[build] rustc 0 <x86_64-unknown-linux-gnu> -> RustInstaller 1 <x86_64-unknown-linux-gnu>
2966+
[dist] docs <x86_64-unknown-linux-gnu>
2967+
[dist] src <>
2968+
");
2969+
}
2970+
2971+
#[test]
2972+
fn install_src_no_docs() {
2973+
let ctx = TestCtx::new();
2974+
insta::assert_snapshot!(
2975+
ctx.config("install")
2976+
.path("src")
2977+
.args(&[
2978+
// Using backslashes fails with `--set`
2979+
"--set", &format!("install.prefix={}", ctx.normalized_dir()),
2980+
"--set", &format!("install.bindir={}", ctx.normalized_dir()),
2981+
"--set", &format!("install.libdir={}", ctx.normalized_dir()),
2982+
"--set", &format!("install.datadir={}", ctx.normalized_dir()),
2983+
"--set", &format!("install.mandir={}", ctx.normalized_dir()),
2984+
"--set", &format!("install.sysconfdir={}", ctx.normalized_dir()),
2985+
"--set", "build.docs=false",
2986+
"--build", "x86_64-unknown-linux-gnu",
2987+
"--host", "x86_64-unknown-linux-gnu",
2988+
"--target", "x86_64-unknown-linux-gnu",
2989+
])
2990+
.get_steps()
2991+
.render_with(RenderConfig {
2992+
normalize_host: false
2993+
}), @r"
2994+
[build] llvm <x86_64-unknown-linux-gnu>
2995+
[build] rustc 0 <x86_64-unknown-linux-gnu> -> rustc 1 <x86_64-unknown-linux-gnu>
2996+
[build] rustc 0 <x86_64-unknown-linux-gnu> -> RustInstaller 1 <x86_64-unknown-linux-gnu>
2997+
[dist] docs <x86_64-unknown-linux-gnu>
2998+
[dist] src <>
2999+
");
3000+
}
3001+
28573002
#[test]
28583003
fn install_extended() {
28593004
let ctx = TestCtx::new();
28603005
insta::assert_snapshot!(
28613006
ctx.config("install")
28623007
.args(&[
28633008
// Using backslashes fails with `--set`
2864-
"--set", &format!("install.prefix={}", ctx.dir().display()).replace("\\", "/"),
2865-
"--set", &format!("install.sysconfdir={}", ctx.dir().display()).replace("\\", "/"),
3009+
"--set", &format!("install.prefix={}", ctx.normalized_dir()),
3010+
"--set", &format!("install.bindir={}", ctx.normalized_dir()),
3011+
"--set", &format!("install.libdir={}", ctx.normalized_dir()),
3012+
"--set", &format!("install.datadir={}", ctx.normalized_dir()),
3013+
"--set", &format!("install.mandir={}", ctx.normalized_dir()),
3014+
"--set", &format!("install.sysconfdir={}", ctx.normalized_dir()),
28663015
"--set", "build.extended=true",
28673016
// For Cranelift to be disted
28683017
"--build", "x86_64-unknown-linux-gnu",
2869-
"--host", "x86_64-unknown-linux-gnu"
3018+
"--host", "x86_64-unknown-linux-gnu",
28703019
])
28713020
.get_steps()
28723021
.render_with(RenderConfig {

src/bootstrap/src/utils/tests/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ impl TestCtx {
3535
self.directory.path()
3636
}
3737

38+
/// Using backslashes fails with `--set`
39+
pub fn normalized_dir(&self) -> String {
40+
self.dir().to_string_lossy().replace("\\", "/")
41+
}
42+
3843
/// Starts a new invocation of bootstrap that executes `kind` as its top level command
3944
/// (i.e. `x <kind>`). Returns a builder that configures the created config through CLI flags.
4045
pub fn config(&self, kind: &str) -> ConfigBuilder {

0 commit comments

Comments
 (0)