Skip to content

Commit

Permalink
test: include a case for setting OUT_DIR
Browse files Browse the repository at this point in the history
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
  • Loading branch information
Rustin170506 committed Dec 26, 2023
1 parent 4e792c2 commit 1f496dd
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions tests/testsuite/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4897,3 +4897,51 @@ fn cargo_test_print_env_verbose() {
)
.run();
}

#[cargo_test]
fn cargo_test_set_out_dir_env_var() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
edition = "2021"
"#,
)
.file(
"src/lib.rs",
r#"
pub fn add(left: usize, right: usize) -> usize {
left + right
}
"#,
)
.file(
"build.rs",
r#"
fn main() {}
"#,
)
.file(
"tests/case.rs",
r#"
#[cfg(test)]
pub mod tests {
#[test]
fn test_add() {
assert!(std::env::var("OUT_DIR").is_ok());
assert_eq!(foo::add(2, 5), 7);
}
}
"#,
)
.build();

p.cargo("test").run();
p.cargo("test --package foo --test case -- tests::test_add --exact --nocapture")
.with_stdout_contains("test tests::test_add ... FAILED")
.with_status(101)
.run();
}

0 comments on commit 1f496dd

Please sign in to comment.