add test coverage for RUSTC_IF_UNCHANGED_ALLOWED_PATHS

Signed-off-by: onur-ozkan <work@onurozkan.dev>
This commit is contained in:
onur-ozkan 2024-10-17 15:15:34 +03:00
parent baa95efa7a
commit 72e63e3ad5
2 changed files with 17 additions and 2 deletions

View file

@ -37,7 +37,7 @@ use crate::utils::helpers::{self, exe, output, t};
///
/// WARNING: Be cautious when adding paths to this list. If a path that influences the compiler build
/// is added here, it will cause bootstrap to skip necessary rebuilds, which may lead to risky results.
const RUSTC_IF_UNCHANGED_ALLOWED_PATHS: &[&str] = &[
pub(crate) const RUSTC_IF_UNCHANGED_ALLOWED_PATHS: &[&str] = &[
":!.clang-format",
":!.editorconfig",
":!.git-blame-ignore-revs",

View file

@ -8,7 +8,7 @@ use clap::CommandFactory;
use serde::Deserialize;
use super::flags::Flags;
use super::{ChangeIdWrapper, Config};
use super::{ChangeIdWrapper, Config, RUSTC_IF_UNCHANGED_ALLOWED_PATHS};
use crate::core::build_steps::clippy::get_clippy_rules_in_order;
use crate::core::build_steps::llvm;
use crate::core::config::{LldMode, Target, TargetSelection, TomlConfig};
@ -410,3 +410,18 @@ fn jobs_precedence() {
);
assert_eq!(config.jobs, Some(123));
}
#[test]
fn check_rustc_if_unchanged_paths() {
let config = parse("");
let normalised_allowed_paths: Vec<_> = RUSTC_IF_UNCHANGED_ALLOWED_PATHS
.iter()
.map(|t| {
t.strip_prefix(":!").expect(&format!("{t} doesn't have ':!' prefix, but it should."))
})
.collect();
for p in normalised_allowed_paths {
assert!(config.src.join(p).exists(), "{p} doesn't exist.");
}
}