Skip to content

Commit

Permalink
fix ci_rustc_if_unchanged_logic test
Browse files Browse the repository at this point in the history
Signed-off-by: onur-ozkan <work@onurozkan.dev>
  • Loading branch information
onur-ozkan committed Oct 8, 2024
1 parent 8a5f418 commit abac4dc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
25 changes: 12 additions & 13 deletions src/bootstrap/src/core/builder/tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::thread;

use build_helper::git::get_closest_merge_commit;

use super::*;
use crate::Flags;
use crate::core::build_steps::doc::DocumentationFormat;
Expand Down Expand Up @@ -223,31 +225,30 @@ fn ci_rustc_if_unchanged_logic() {
|&_| Ok(Default::default()),
);

let build = Build::new(config.clone());
let builder = Builder::new(&build);

if config.rust_info.is_from_tarball() {
return;
}

let build = Build::new(config.clone());
let builder = Builder::new(&build);

if config.out.exists() {
fs::remove_dir_all(&config.out).unwrap();
}

builder.run_step_descriptions(&Builder::get_step_descriptions(config.cmd.kind()), &[]);

let commit = helpers::get_closest_merge_base_commit(
let compiler_path = build.src.join("compiler");
let library_path = build.src.join("compiler");

let commit = get_closest_merge_commit(
Some(&builder.config.src),
&builder.config.git_config(),
&builder.config.stage0_metadata.config.git_merge_commit_email,
&[],
&[compiler_path.clone(), library_path.clone()],
)
.unwrap();

let compiler_path = build.src.join("compiler");
let library_path = build.src.join("library");

let has_changes = helpers::git(Some(&builder.src))
let has_changes = !helpers::git(Some(&builder.src))
.args(["diff-index", "--quiet", &commit])
.arg("--")
.args([compiler_path, library_path])
Expand All @@ -256,9 +257,7 @@ fn ci_rustc_if_unchanged_logic() {
.unwrap()
.success();

assert!(
has_changes != config.out.join(config.build.to_string()).join("ci-rustc-sysroot").exists()
);
assert!(has_changes == config.download_rustc_commit.is_none());
}

mod defaults {
Expand Down
5 changes: 3 additions & 2 deletions src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2422,8 +2422,9 @@ impl Config {
ci_config_toml,
);

let disable_ci_rustc_if_incompatible =
env::var_os("DISABLE_CI_RUSTC_IF_INCOMPATIBLE")
// Primarily used by CI runners to avoid handling download-rustc incompatible
// options one by one on shell scripts.
let disable_ci_rustc_if_incompatible = env::var_os("DISABLE_CI_RUSTC_IF_INCOMPATIBLE")
.is_some_and(|s| s == "1" || s == "true");

if disable_ci_rustc_if_incompatible && res.is_err() {
Expand Down
2 changes: 1 addition & 1 deletion src/ci/docker/host-x86_64/mingw-check/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ ENV SCRIPT \
git config --global user.name \"dummy\" && \
git add ../compiler/rustc/src/main.rs && \
git commit -m \"test commit for rust.download-rustc=if-unchanged logic\" && \
python3 ../x.py test bootstrap -- core::builder::tests::ci_rustc_if_unchanged_logic && \
DISABLE_CI_RUSTC_IF_INCOMPATIBLE=0 python3 ../x.py test bootstrap -- core::builder::tests::ci_rustc_if_unchanged_logic && \
# Revert the dummy commit
git reset --hard HEAD~1 && \

Expand Down
3 changes: 2 additions & 1 deletion src/ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ if [ "$CI" != "" ]; then
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set change-id=99999999"
fi

# If runner uses an incompatible option and `FORCE_CI_RUSTC` is not defined, switch to in-tree rustc.
# If runner uses an incompatible option and `FORCE_CI_RUSTC` is not defined,
# switch to in-tree rustc.
if [ "$FORCE_CI_RUSTC" == "" ]; then
DISABLE_CI_RUSTC_IF_INCOMPATIBLE=1
fi
Expand Down

0 comments on commit abac4dc

Please sign in to comment.