Skip to content

Fix ./x check bootstrap (again) #144445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/bootstrap/src/utils/shared_helpers.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
//! This module serves two purposes:
//! 1. It is part of the `utils` module and used in other parts of bootstrap.
//! 2. It is embedded inside bootstrap shims to avoid a dependency on the bootstrap library.
//! Therefore, this module should never use any other bootstrap module. This reduces binary
//! size and improves compilation time by minimizing linking time.
//!
//! 1. It is part of the `utils` module and used in other parts of bootstrap.
//! 2. It is embedded inside bootstrap shims to avoid a dependency on the bootstrap library.
//! Therefore, this module should never use any other bootstrap module. This reduces binary size
//! and improves compilation time by minimizing linking time.

// # Note on tests
//
// If we were to declare a tests submodule here, the shim binaries that include this module via
// `#[path]` would fail to find it, which breaks `./x check bootstrap`. So instead the unit tests
// for this module are in `super::tests::shared_helpers_tests`.

#![allow(dead_code)]

#[cfg(test)]
mod tests;

use std::env;
use std::ffi::OsString;
use std::fs::OpenOptions;
use std::io::Write;
use std::process::Command;
use std::str::FromStr;

// If we were to declare a tests submodule here, the shim binaries that include this
// module via `#[path]` would fail to find it, which breaks `./x check bootstrap`.
// So instead the unit tests for this module are in `super::tests::shared_helpers_tests`.

/// Returns the environment variable which the dynamic library lookup path
/// resides in for this platform.
pub fn dylib_path_var() -> &'static str {
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/src/utils/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ use crate::{Build, Config, Flags, t};

pub mod git;

// Note: tests for `shared_helpers` is separate here, as otherwise shim binaries that include the
// `shared_helpers` via `#[path]` would fail to find it, breaking `./x check bootstrap`.
mod shared_helpers_tests;

/// Holds temporary state of a bootstrap test.
/// Right now it is only used to redirect the build directory of the bootstrap
/// invocation, in the future it would be great if we could actually execute
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
//! The `shared_helpers` module can't have its own tests submodule, because that would cause
//! problems for the shim binaries that include it via `#[path]`, so instead those unit tests live
//! here.
//!
//! To prevent tidy from complaining about this file not being named `tests.rs`, it lives inside a
//! submodule directory named `tests`.

use crate::utils::shared_helpers::parse_value_from_args;

#[test]
Expand Down
1 change: 1 addition & 0 deletions src/ci/docker/host-x86_64/pr-check-1/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ COPY host-x86_64/pr-check-1/validate-toolstate.sh /scripts/
# We disable optimized compiler built-ins because that requires a C toolchain for the target.
# We also skip the x86_64-unknown-linux-gnu target as it is well-tested by other jobs.
ENV SCRIPT \
python3 ../x.py check bootstrap && \
/scripts/check-default-config-profiles.sh && \
python3 ../x.py build src/tools/build-manifest && \
python3 ../x.py test --stage 0 src/tools/compiletest && \
Expand Down
Loading