Skip to content

Commit c8ebc18

Browse files
committed
test: include a case for setting OUT_DIR
Signed-off-by: hi-rustin <[email protected]>
1 parent d45969a commit c8ebc18

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

tests/testsuite/test.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4897,3 +4897,51 @@ fn cargo_test_print_env_verbose() {
48974897
)
48984898
.run();
48994899
}
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+
}

0 commit comments

Comments
 (0)