Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions src/bootstrap/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ dependencies = [
"libc",
"object",
"opener",
"pretty_assertions",
"semver",
"serde",
"serde_derive",
Expand Down Expand Up @@ -229,12 +228,6 @@ dependencies = [
"typenum",
]

[[package]]
name = "diff"
version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8"

[[package]]
name = "digest"
version = "0.10.7"
Expand Down Expand Up @@ -526,16 +519,6 @@ version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2"

[[package]]
name = "pretty_assertions"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ae130e2f271fbc2ac3a40fb1d07180839cdbbe443c7a27e1e3c13c5cac0116d"
dependencies = [
"diff",
"yansi",
]

[[package]]
name = "proc-macro2"
version = "1.0.89"
Expand Down Expand Up @@ -1144,9 +1127,3 @@ checksum = "388c44dc09d76f1536602ead6d325eb532f5c122f17782bd57fb47baeeb767e2"
dependencies = [
"lzma-sys",
]

[[package]]
name = "yansi"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049"
1 change: 0 additions & 1 deletion src/bootstrap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ features = [
]

[dev-dependencies]
pretty_assertions = "1.4"
insta = "1.43"

# We care a lot about bootstrap's compile times, so don't include debuginfo for
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/src/core/build_steps/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ pub const LLVM_INVALIDATION_PATHS: &[&str] = &[
];

/// Detect whether LLVM sources have been modified locally or not.
#[cfg_attr(test, expect(dead_code))]
pub(crate) fn detect_llvm_freshness(config: &Config, is_git: bool) -> PathFreshness {
if is_git {
config.check_path_modifications(LLVM_INVALIDATION_PATHS)
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/src/core/build_steps/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,7 @@ impl Step for LlvmBitcodeLinker {
}

#[derive(Debug, Clone, Hash, PartialEq, Eq)]
#[cfg_attr(test, expect(dead_code))]
pub struct LibcxxVersionTool {
pub target: TargetSelection,
}
Expand Down
6 changes: 2 additions & 4 deletions src/bootstrap/src/core/builder/cli_paths/tests.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use std::collections::{BTreeSet, HashSet};
use std::fs;
use std::path::{Path, PathBuf};
use std::path::PathBuf;
use std::sync::{Arc, Mutex};

use crate::Build;
use crate::core::builder::cli_paths::match_paths_to_steps_and_run;
use crate::core::builder::{Builder, StepDescription};
use crate::utils::tests::TestCtx;

Expand Down Expand Up @@ -34,7 +32,7 @@ fn render_steps_for_cli_args(args_str: &str) -> String {
let mut builder = Builder::new(&build);

// Tell the builder to log steps that it would run, instead of running them.
let mut buf = Arc::new(Mutex::new(String::new()));
let buf = Arc::new(Mutex::new(String::new()));
let buf2 = Arc::clone(&buf);
builder.log_cli_step_for_tests = Some(Box::new(move |step_desc, pathsets, targets| {
use std::fmt::Write;
Expand Down
66 changes: 12 additions & 54 deletions src/bootstrap/src/core/builder/tests.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
// ignore-tidy-file-filelength
use std::env::VarError;
use std::{panic, thread};
use std::panic;

use build_helper::stage0_parser::parse_stage0_file;
use llvm::prebuilt_llvm_config;

use super::*;
use crate::Flags;
use crate::core::build_steps::doc::DocumentationFormat;
use crate::core::builder::cli_paths::PATH_REMAP;
use crate::core::config::Config;
use crate::utils::cache::ExecutedStep;
Expand All @@ -17,7 +14,6 @@ use crate::utils::tests::{ConfigBuilder, TestCtx};

static TEST_TRIPLE_1: &str = "i686-unknown-haiku";
static TEST_TRIPLE_2: &str = "i686-unknown-hurd-gnu";
static TEST_TRIPLE_3: &str = "i686-unknown-netbsd";

fn configure(cmd: &str, host: &[&str], target: &[&str]) -> Config {
configure_with_args(&[cmd], host, target)
Expand All @@ -27,10 +23,6 @@ fn configure_with_args(cmd: &[&str], host: &[&str], target: &[&str]) -> Config {
TestCtx::new().config(cmd[0]).args(&cmd[1..]).hosts(host).targets(target).create_config()
}

fn first<A, B>(v: Vec<(A, B)>) -> Vec<A> {
v.into_iter().map(|(a, _)| a).collect::<Vec<_>>()
}

fn run_build(paths: &[PathBuf], config: Config) -> Cache {
let kind = config.cmd.kind();
let build = Build::new(config);
Expand All @@ -46,28 +38,6 @@ fn check_cli<const N: usize>(paths: [&str; N]) {
);
}

macro_rules! std {
($host:ident => $target:ident, stage = $stage:literal) => {
compile::Std::new(
Compiler::new($stage, TargetSelection::from_user($host)),
TargetSelection::from_user($target),
)
};
}

macro_rules! doc_std {
($host:ident => $target:ident, stage = $stage:literal) => {{ doc::Std::new($stage, TargetSelection::from_user($target), DocumentationFormat::Html) }};
}

macro_rules! rustc {
($host:ident => $target:ident, stage = $stage:literal) => {
compile::Rustc::new(
Compiler::new($stage, TargetSelection::from_user($host)),
TargetSelection::from_user($target),
)
};
}

#[test]
fn test_valid() {
// make sure multi suite paths are accepted
Expand Down Expand Up @@ -228,10 +198,7 @@ fn parse_config_download_rustc_at(path: &Path, download_rustc: &str, ci: bool) -
}

mod dist {
use pretty_assertions::assert_eq;

use super::{Config, TEST_TRIPLE_1, TEST_TRIPLE_2, TEST_TRIPLE_3, first, run_build};
use crate::Flags;
use super::{Config, TEST_TRIPLE_1, TEST_TRIPLE_2};
use crate::core::builder::tests::host_target;
use crate::core::builder::*;

Expand Down Expand Up @@ -344,7 +311,7 @@ fn test_test_coverage() {
// case is the one that failed.
println!("Testing case: {cmd:?}");
let config = configure_with_args(cmd, &[], &[TEST_TRIPLE_1]);
let mut cache = run_build(&config.paths.clone(), config);
let cache = run_build(&config.paths.clone(), config);

let modes =
cache.inspect_all_steps_of_type::<test::Coverage, _>(|step, ()| step.mode.as_str());
Expand Down Expand Up @@ -507,22 +474,15 @@ fn any_debug() {
/// These tests use insta for snapshot testing.
/// See bootstrap's README on how to bless the snapshots.
mod snapshot {
use std::path::PathBuf;

use crate::core::build_steps::{compile, dist, doc, test, tool};
use crate::core::builder::tests::{
RenderConfig, TEST_TRIPLE_1, TEST_TRIPLE_2, TEST_TRIPLE_3, configure, first, host_target,
render_steps, run_build,
};
use crate::core::builder::{Builder, Kind, StepDescription, StepMetadata};
use crate::Compiler;
use crate::core::build_steps::test;
use crate::core::builder::tests::{RenderConfig, TEST_TRIPLE_1, TEST_TRIPLE_2, host_target};
use crate::core::builder::{Kind, StepMetadata};
use crate::core::config::TargetSelection;
use crate::core::config::toml::target::{
DefaultLinuxLinkerOverride, with_default_linux_linker_overrides,
};
use crate::utils::cache::Cache;
use crate::utils::helpers::get_host_target;
use crate::utils::tests::{ConfigBuilder, TestCtx};
use crate::{Build, Compiler, Config, Flags, Subcommand};

#[test]
fn build_default() {
Expand Down Expand Up @@ -2426,7 +2386,6 @@ mod snapshot {
#[test]
fn test_library_tests_only_does_not_build_rustdoc() {
let ctx = TestCtx::new();
let host = TargetSelection::from_user(&host_target());
insta::assert_snapshot!(
ctx.config("test").args(&["--tests", "library/core"]).render_steps(),
@r"
Expand Down Expand Up @@ -3257,7 +3216,7 @@ impl ExecutedSteps {
}

fn fuzzy_metadata_eq(executed: &StepMetadata, to_match: &StepMetadata) -> bool {
let StepMetadata { name, kind, target, built_by: _, stage: _, metadata } = executed;
let StepMetadata { name, kind, target, built_by: _, stage: _, metadata: _ } = executed;
*name == to_match.name && *kind == to_match.kind && *target == to_match.target
}

Expand Down Expand Up @@ -3309,8 +3268,6 @@ fn render_steps(steps: &[ExecutedStep], config: RenderConfig) -> String {
steps
.iter()
.filter_map(|step| {
use std::fmt::Write;

let Some(metadata) = &step.metadata else {
return None;
};
Expand All @@ -3324,12 +3281,13 @@ fn render_steps(steps: &[ExecutedStep], config: RenderConfig) -> String {
fn render_metadata(metadata: &StepMetadata, config: &RenderConfig) -> String {
let mut record = format!("[{}] ", metadata.kind.as_str());
if let Some(compiler) = metadata.built_by {
write!(record, "{} -> ", render_compiler(compiler, config));
write!(record, "{} -> ", render_compiler(compiler, config)).unwrap();
}
let stage = metadata.get_stage().map(|stage| format!("{stage} ")).unwrap_or_default();
write!(record, "{} {stage}<{}>", metadata.name, normalize_target(metadata.target, config));
write!(record, "{} {stage}<{}>", metadata.name, normalize_target(metadata.target, config))
.unwrap();
if let Some(metadata) = &metadata.metadata {
write!(record, " {metadata}");
write!(record, " {metadata}").unwrap();
}
record
}
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ use crate::core::download::{
};
use crate::utils::channel;
use crate::utils::exec::{ExecutionContext, command};
#[cfg_attr(test, expect(unused_imports))]
use crate::utils::helpers::{exe, fail, get_host_target};
use crate::{
CodegenBackendKind, GitInfo, OnceLock, TargetSelection, check_ci_llvm, exit, helpers, t,
Expand Down
18 changes: 4 additions & 14 deletions src/bootstrap/src/core/config/tests.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use std::collections::BTreeSet;
use std::fs::{File, remove_file};
use std::fs;
use std::fs::File;
use std::io::Write;
use std::path::{Path, PathBuf};
use std::{env, fs};
use std::path::PathBuf;

use build_helper::ci::CiEnv;
use build_helper::git::PathFreshness;
use clap::CommandFactory;
use serde::Deserialize;

use super::flags::Flags;
use super::toml::change_id::ChangeIdWrapper;
Expand All @@ -16,23 +15,14 @@ use super::{Config, RUSTC_IF_UNCHANGED_ALLOWED_PATHS};
use crate::ChangeId;
use crate::core::build_steps::clippy::{LintConfig, get_clippy_rules_in_order};
use crate::core::build_steps::llvm::LLVM_INVALIDATION_PATHS;
use crate::core::build_steps::{llvm, test};
use crate::core::config::toml::TomlConfig;
use crate::core::config::{
BootstrapOverrideLld, CompilerBuiltins, StringOrBool, Target, TargetSelection,
};
use crate::core::config::{BootstrapOverrideLld, CompilerBuiltins, Target, TargetSelection};
use crate::utils::tests::TestCtx;
use crate::utils::tests::git::git_test;

pub(crate) fn parse(config: &str) -> Config {
TestCtx::new().config("check").with_default_toml_config(config).create_config()
}

fn get_toml(file: &Path) -> Result<TomlConfig, toml::de::Error> {
let contents = std::fs::read_to_string(file).unwrap();
toml::from_str(&contents).and_then(|table: toml::Value| TomlConfig::deserialize(table))
}

fn modified(upstream: impl Into<String>, changes: &[&str]) -> PathFreshness {
PathFreshness::HasLocalModifications {
upstream: upstream.into(),
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/src/core/config/toml/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use serde::{Deserialize, Deserializer};

use crate::core::config::StringOrBool;
#[cfg_attr(test, expect(unused_imports))]
use crate::core::config::toml::{Merge, ReplaceOpt, TomlConfig};
use crate::{HashMap, HashSet, PathBuf, define_config, exit};

Expand Down
7 changes: 4 additions & 3 deletions src/bootstrap/src/core/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,8 @@ pub(crate) fn is_download_ci_available(target_triple: &str, llvm_assertions: boo

#[cfg(test)]
pub(crate) fn maybe_download_rustfmt<'a>(
dwn_ctx: impl AsRef<DownloadContext<'a>>,
out: &Path,
_dwn_ctx: impl AsRef<DownloadContext<'a>>,
_out: &Path,
) -> Option<PathBuf> {
Some(PathBuf::new())
}
Expand Down Expand Up @@ -574,7 +574,7 @@ pub(crate) fn maybe_download_rustfmt<'a>(
}

#[cfg(test)]
pub(crate) fn download_beta_toolchain<'a>(dwn_ctx: impl AsRef<DownloadContext<'a>>, out: &Path) {}
pub(crate) fn download_beta_toolchain<'a>(_dwn_ctx: impl AsRef<DownloadContext<'a>>, _out: &Path) {}

#[cfg(not(test))]
pub(crate) fn download_beta_toolchain<'a>(dwn_ctx: impl AsRef<DownloadContext<'a>>, out: &Path) {
Expand All @@ -600,6 +600,7 @@ pub(crate) fn download_beta_toolchain<'a>(dwn_ctx: impl AsRef<DownloadContext<'a
}

#[allow(clippy::too_many_arguments)]
#[cfg_attr(test, expect(dead_code))]
fn download_toolchain<'a>(
dwn_ctx: impl AsRef<DownloadContext<'a>>,
out: &Path,
Expand Down
1 change: 0 additions & 1 deletion src/bootstrap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
//!
//! More documentation can be found in each respective module below, and you can
//! also check out the `src/bootstrap/README.md` file for more information.
#![cfg_attr(test, allow(unused))]

use std::cell::Cell;
use std::collections::{BTreeSet, HashMap, HashSet};
Expand Down
4 changes: 1 addition & 3 deletions src/bootstrap/src/utils/build_stamp/tests.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use std::path::PathBuf;

use tempfile::TempDir;

use crate::{BuildStamp, Config, Flags};
use crate::BuildStamp;

#[test]
#[should_panic(expected = "prefix can not start or end with '.'")]
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/utils/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ impl Cache {
}

#[cfg(test)]
pub fn into_executed_steps(mut self) -> Vec<ExecutedStep> {
pub fn into_executed_steps(self) -> Vec<ExecutedStep> {
mem::take(&mut self.executed_steps.borrow_mut())
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/bootstrap/src/utils/cache/tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use std::path::PathBuf;

use crate::utils::cache::{INTERNER, Internable, Interner, TyIntern};
use crate::utils::cache::{INTERNER, Interner, TyIntern};

#[test]
fn test_string_interning() {
Expand Down
10 changes: 5 additions & 5 deletions src/bootstrap/src/utils/cc_detect/tests.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::path::{Path, PathBuf};
use std::{env, iter};
use std::iter;
use std::path::PathBuf;

use super::*;
use crate::Build;
use crate::core::config::{Target, TargetSelection};
use crate::utils::tests::TestCtx;
use crate::{Build, Config, Flags, t};

#[test]
fn test_ndk_compiler_c() {
Expand Down Expand Up @@ -85,7 +85,7 @@ fn test_default_compiler_wasi() {
let wasi_sdk = PathBuf::from("/wasi-sdk");
build.wasi_sdk_path = Some(wasi_sdk.clone());

let mut cfg = cc::Build::new();
let cfg = cc::Build::new();
if let Some(result) = default_compiler(&cfg, Language::C, target.clone(), &build) {
let expected = {
let compiler = format!("{}-clang", target.triple);
Expand All @@ -104,7 +104,7 @@ fn test_default_compiler_fallback() {
let config = TestCtx::new().config("build").create_config();
let build = Build::new(config);
let target = TargetSelection::from_user("x86_64-unknown-linux-gnu");
let mut cfg = cc::Build::new();
let cfg = cc::Build::new();
let result = default_compiler(&cfg, Language::C, target, &build);
assert!(result.is_none(), "default_compiler should return None for generic targets");
}
Expand Down
Loading
Loading