Skip to content

Commit a140442

Browse files
committed
add test coverage for RUSTC_IF_UNCHANGED_ALLOWED_PATHS
Signed-off-by: onur-ozkan <[email protected]>
1 parent 57f6ecf commit a140442

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};
@@ -410,3 +410,18 @@ fn jobs_precedence() {
410410
);
411411
assert_eq!(config.jobs, Some(123));
412412
}
413+
414+
#[test]
415+
fn check_rustc_if_unchanged_paths() {
416+
let config = parse("");
417+
let normalised_allowed_paths: Vec<_> = RUSTC_IF_UNCHANGED_ALLOWED_PATHS
418+
.iter()
419+
.map(|t| {
420+
t.strip_prefix(":!").expect(&format!("{t} doesn't have ':!' prefix, but it should."))
421+
})
422+
.collect();
423+
424+
for p in normalised_allowed_paths {
425+
assert!(config.src.join(p).exists(), "{p} doesn't exist.");
426+
}
427+
}

0 commit comments

Comments
 (0)