Skip to content

Commit b5d05e3

Browse files
authored
Unrolled build for rust-lang#134883
Rollup merge of rust-lang#134883 - Zalathar:shared-helpers, r=clubby789 bootstrap: Fix `./x check bootstrap` by moving `shared_helpers::tests` Running `./x check bootstrap` currently doesn't work, because it builds the bootstrap shim binaries with `cfg(test)`, and those binaries can't find a `tests` submodule when they include `shared_helpers.rs` via `#[path]`. This PR fixes that by taking the tests module and moving it to `super::tests::shared_helpers_tests` instead. (The extra `tests` submodule prevents tidy from complaining about unit tests that aren't in a dedicated tests module.) --- It would be nice to also run `./x check bootstrap compiletest` in CI, so that this and rust-lang#134848 don't regress, but I didn't want to bundle that change with this fix.
2 parents e7738af + 4192293 commit b5d05e3

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

src/bootstrap/src/utils/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ pub(crate) mod metrics;
1414
pub(crate) mod render_tests;
1515
pub(crate) mod shared_helpers;
1616
pub(crate) mod tarball;
17+
#[cfg(test)]
18+
mod tests;

src/bootstrap/src/utils/shared_helpers.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ use std::io::Write;
1313
use std::process::Command;
1414
use std::str::FromStr;
1515

16-
#[cfg(test)]
17-
mod tests;
16+
// If we were to declare a tests submodule here, the shim binaries that include this
17+
// module via `#[path]` would fail to find it, which breaks `./x check bootstrap`.
18+
// So instead the unit tests for this module are in `super::tests::shared_helpers_tests`.
1819

1920
/// Returns the environment variable which the dynamic library lookup path
2021
/// resides in for this platform.

src/bootstrap/src/utils/tests/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mod shared_helpers_tests;

src/bootstrap/src/utils/shared_helpers/tests.rs renamed to src/bootstrap/src/utils/tests/shared_helpers_tests.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
use super::parse_value_from_args;
1+
//! The `shared_helpers` module can't have its own tests submodule, because
2+
//! that would cause problems for the shim binaries that include it via
3+
//! `#[path]`, so instead those unit tests live here.
4+
//!
5+
//! To prevent tidy from complaining about this file not being named `tests.rs`,
6+
//! it lives inside a submodule directory named `tests`.
7+
8+
use crate::utils::shared_helpers::parse_value_from_args;
29

310
#[test]
411
fn test_parse_value_from_args() {

0 commit comments

Comments
 (0)