Skip to content

Commit abac4dc

Browse files
committed
fix ci_rustc_if_unchanged_logic test
Signed-off-by: onur-ozkan <[email protected]>
1 parent 8a5f418 commit abac4dc

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

src/bootstrap/src/core/builder/tests.rs

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use std::thread;
22

3+
use build_helper::git::get_closest_merge_commit;
4+
35
use super::*;
46
use crate::Flags;
57
use crate::core::build_steps::doc::DocumentationFormat;
@@ -223,31 +225,30 @@ fn ci_rustc_if_unchanged_logic() {
223225
|&_| Ok(Default::default()),
224226
);
225227

226-
let build = Build::new(config.clone());
227-
let builder = Builder::new(&build);
228-
229228
if config.rust_info.is_from_tarball() {
230229
return;
231230
}
232231

232+
let build = Build::new(config.clone());
233+
let builder = Builder::new(&build);
234+
233235
if config.out.exists() {
234236
fs::remove_dir_all(&config.out).unwrap();
235237
}
236238

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

239-
let commit = helpers::get_closest_merge_base_commit(
241+
let compiler_path = build.src.join("compiler");
242+
let library_path = build.src.join("compiler");
243+
244+
let commit = get_closest_merge_commit(
240245
Some(&builder.config.src),
241246
&builder.config.git_config(),
242-
&builder.config.stage0_metadata.config.git_merge_commit_email,
243-
&[],
247+
&[compiler_path.clone(), library_path.clone()],
244248
)
245249
.unwrap();
246250

247-
let compiler_path = build.src.join("compiler");
248-
let library_path = build.src.join("library");
249-
250-
let has_changes = helpers::git(Some(&builder.src))
251+
let has_changes = !helpers::git(Some(&builder.src))
251252
.args(["diff-index", "--quiet", &commit])
252253
.arg("--")
253254
.args([compiler_path, library_path])
@@ -256,9 +257,7 @@ fn ci_rustc_if_unchanged_logic() {
256257
.unwrap()
257258
.success();
258259

259-
assert!(
260-
has_changes != config.out.join(config.build.to_string()).join("ci-rustc-sysroot").exists()
261-
);
260+
assert!(has_changes == config.download_rustc_commit.is_none());
262261
}
263262

264263
mod defaults {

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -2422,8 +2422,9 @@ impl Config {
24222422
ci_config_toml,
24232423
);
24242424

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

24292430
if disable_ci_rustc_if_incompatible && res.is_err() {

src/ci/docker/host-x86_64/mingw-check/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ ENV SCRIPT \
5555
git config --global user.name \"dummy\" && \
5656
git add ../compiler/rustc/src/main.rs && \
5757
git commit -m \"test commit for rust.download-rustc=if-unchanged logic\" && \
58-
python3 ../x.py test bootstrap -- core::builder::tests::ci_rustc_if_unchanged_logic && \
58+
DISABLE_CI_RUSTC_IF_INCOMPATIBLE=0 python3 ../x.py test bootstrap -- core::builder::tests::ci_rustc_if_unchanged_logic && \
5959
# Revert the dummy commit
6060
git reset --hard HEAD~1 && \
6161

src/ci/run.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ if [ "$CI" != "" ]; then
5252
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set change-id=99999999"
5353
fi
5454

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

0 commit comments

Comments
 (0)