File tree Expand file tree Collapse file tree 2 files changed +50
-1
lines changed
crates/cargo-test-support/src Expand file tree Collapse file tree 2 files changed +50
-1
lines changed Original file line number Diff line number Diff line change @@ -1286,7 +1286,8 @@ pub trait TestEnv: Sized {
1286
1286
. env_remove ( "RUSTFLAGS" )
1287
1287
. env_remove ( "SSH_AUTH_SOCK" ) // ensure an outer agent is never contacted
1288
1288
. env_remove ( "USER" ) // not set on some rust-lang docker images
1289
- . env_remove ( "XDG_CONFIG_HOME" ) ; // see #2345
1289
+ . env_remove ( "XDG_CONFIG_HOME" ) // see #2345
1290
+ . env_remove ( "OUT_DIR" ) ; // see #13204
1290
1291
if cfg ! ( target_os = "macos" ) {
1291
1292
// Work-around a bug in macOS 10.15, see `link_or_copy` for details.
1292
1293
self = self . env ( "__CARGO_COPY_DONT_LINK_DO_NOT_USE_THIS" , "1" ) ;
Original file line number Diff line number Diff line change @@ -4897,3 +4897,51 @@ fn cargo_test_print_env_verbose() {
4897
4897
)
4898
4898
. run ( ) ;
4899
4899
}
4900
+
4901
+ #[ cargo_test]
4902
+ fn cargo_test_set_out_dir_env_var ( ) {
4903
+ let p = project ( )
4904
+ . file (
4905
+ "Cargo.toml" ,
4906
+ r#"
4907
+ [package]
4908
+ name = "foo"
4909
+ version = "0.0.1"
4910
+ edition = "2021"
4911
+ "# ,
4912
+ )
4913
+ . file (
4914
+ "src/lib.rs" ,
4915
+ r#"
4916
+ pub fn add(left: usize, right: usize) -> usize {
4917
+ left + right
4918
+ }
4919
+ "# ,
4920
+ )
4921
+ . file (
4922
+ "build.rs" ,
4923
+ r#"
4924
+ fn main() {}
4925
+ "# ,
4926
+ )
4927
+ . file (
4928
+ "tests/case.rs" ,
4929
+ r#"
4930
+ #[cfg(test)]
4931
+ pub mod tests {
4932
+ #[test]
4933
+ fn test_add() {
4934
+ assert!(std::env::var("OUT_DIR").is_ok());
4935
+ assert_eq!(foo::add(2, 5), 7);
4936
+ }
4937
+ }
4938
+ "# ,
4939
+ )
4940
+ . build ( ) ;
4941
+
4942
+ p. cargo ( "test" ) . run ( ) ;
4943
+ p. cargo ( "test --package foo --test case -- tests::test_add --exact --nocapture" )
4944
+ . with_stdout_contains ( "test tests::test_add ... FAILED" )
4945
+ . with_status ( 101 )
4946
+ . run ( ) ;
4947
+ }
You can’t perform that action at this time.
0 commit comments