diff options
| author | bit-aloo <sshourya17@gmail.com> | 2025-09-22 18:54:23 +0530 |
|---|---|---|
| committer | bit-aloo <sshourya17@gmail.com> | 2025-09-22 18:54:23 +0530 |
| commit | 83b784fda12a3422bfa7ce14c1bbd9864df70e5e (patch) | |
| tree | b9d269379bad1d7cd9aaf41afa82e12818b00290 /src | |
| parent | 8a0e3808c04c16732c4651884c2a28063f4eec43 (diff) | |
| download | rust-83b784fda12a3422bfa7ce14c1bbd9864df70e5e.tar.gz rust-83b784fda12a3422bfa7ce14c1bbd9864df70e5e.zip | |
add comment explaining the test_build_dir
Diffstat (limited to 'src')
| -rw-r--r-- | src/bootstrap/src/core/config/config.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 957de5367ef..280ae088f3f 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -2479,6 +2479,13 @@ fn find_correct_section_for_field(field_name: &str) -> Vec<WouldBeValidFor> { .collect() } +/// Resolve the build directory used for tests. +/// +/// - When tests are run through bootstrap (`x.py test`), the build system +/// sets `CARGO_TARGET_DIR`, so we can trust and use it here. +/// - When tests are run directly with cargo test, `CARGO_TARGET_DIR` will +/// not be set. In that case we fall back to resolving relative to +/// `CARGO_MANIFEST_DIR`, by walking two parents up and appending `build`. fn test_build_dir() -> PathBuf { env::var_os("CARGO_TARGET_DIR") .map(|value| Path::new(&value).parent().unwrap().to_path_buf()) |
