Skip to content

Commit 83b784f

Browse files
committed
add comment explaining the test_build_dir
1 parent 8a0e380 commit 83b784f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2479,6 +2479,13 @@ fn find_correct_section_for_field(field_name: &str) -> Vec<WouldBeValidFor> {
24792479
.collect()
24802480
}
24812481

2482+
/// Resolve the build directory used for tests.
2483+
///
2484+
/// - When tests are run through bootstrap (`x.py test`), the build system
2485+
/// sets `CARGO_TARGET_DIR`, so we can trust and use it here.
2486+
/// - When tests are run directly with cargo test, `CARGO_TARGET_DIR` will
2487+
/// not be set. In that case we fall back to resolving relative to
2488+
/// `CARGO_MANIFEST_DIR`, by walking two parents up and appending `build`.
24822489
fn test_build_dir() -> PathBuf {
24832490
env::var_os("CARGO_TARGET_DIR")
24842491
.map(|value| Path::new(&value).parent().unwrap().to_path_buf())

0 commit comments

Comments
 (0)