Skip to content

Commit

Permalink
add test coverage for RUSTC_IF_UNCHANGED_ALLOWED_PATHS
Browse files Browse the repository at this point in the history
Signed-off-by: onur-ozkan <[email protected]>
  • Loading branch information
onur-ozkan committed Oct 18, 2024
1 parent 5fef0e9 commit 6e6625b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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] = &[
":!.github",
":!.clang-format",
":!.editorconfig",
Expand Down
17 changes: 16 additions & 1 deletion src/bootstrap/src/core/config/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -352,3 +352,18 @@ fn parse_rust_std_features_empty() {
fn parse_rust_std_features_invalid() {
parse("rust.std-features = \"backtrace\"");
}

#[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.");
}
}

0 comments on commit 6e6625b

Please sign in to comment.