Skip to content

Commit 6e6625b

Browse files
committed
add test coverage for RUSTC_IF_UNCHANGED_ALLOWED_PATHS
Signed-off-by: onur-ozkan <[email protected]>
1 parent 5fef0e9 commit 6e6625b

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/bootstrap/src/core/config/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use crate::utils::helpers::{self, exe, output, t};
3737
///
3838
/// WARNING: Be cautious when adding paths to this list. If a path that influences the compiler build
3939
/// is added here, it will cause bootstrap to skip necessary rebuilds, which may lead to risky results.
40-
const RUSTC_IF_UNCHANGED_ALLOWED_PATHS: &[&str] = &[
40+
pub(crate) const RUSTC_IF_UNCHANGED_ALLOWED_PATHS: &[&str] = &[
4141
":!.github",
4242
":!.clang-format",
4343
":!.editorconfig",

src/bootstrap/src/core/config/tests.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use clap::CommandFactory;
88
use serde::Deserialize;
99

1010
use super::flags::Flags;
11-
use super::{ChangeIdWrapper, Config};
11+
use super::{ChangeIdWrapper, Config, RUSTC_IF_UNCHANGED_ALLOWED_PATHS};
1212
use crate::core::build_steps::clippy::get_clippy_rules_in_order;
1313
use crate::core::build_steps::llvm;
1414
use crate::core::config::{LldMode, Target, TargetSelection, TomlConfig};
@@ -352,3 +352,18 @@ fn parse_rust_std_features_empty() {
352352
fn parse_rust_std_features_invalid() {
353353
parse("rust.std-features = \"backtrace\"");
354354
}
355+
356+
#[test]
357+
fn check_rustc_if_unchanged_paths() {
358+
let config = parse("");
359+
let normalised_allowed_paths: Vec<_> = RUSTC_IF_UNCHANGED_ALLOWED_PATHS
360+
.iter()
361+
.map(|t| {
362+
t.strip_prefix(":!").expect(&format!("{t} doesn't have ':!' prefix, but it should."))
363+
})
364+
.collect();
365+
366+
for p in normalised_allowed_paths {
367+
assert!(config.src.join(p).exists(), "{p} doesn't exist.");
368+
}
369+
}

0 commit comments

Comments
 (0)