From 6bb8c2fb8598e25ea7c22a3e3eea09ba3a87c8d4 Mon Sep 17 00:00:00 2001 From: Arlo Siemsen Date: Mon, 10 Oct 2022 10:59:25 -0500 Subject: [PATCH] Add test to verify stdin is closed for build.rs --- tests/testsuite/build_script.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/testsuite/build_script.rs b/tests/testsuite/build_script.rs index dceec92538bf..69980361a6fe 100644 --- a/tests/testsuite/build_script.rs +++ b/tests/testsuite/build_script.rs @@ -4905,3 +4905,27 @@ for more information about build script outputs. ) .run(); } + +#[cargo_test] +fn custom_build_closes_stdin() { + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.5.0" + build = "build.rs" + "#, + ) + .file("src/main.rs", "fn main() {}") + .file( + "build.rs", + r#"fn main() { + let mut line = String::new(); + std::io::stdin().read_line(&mut line).unwrap(); + }"#, + ) + .build(); + p.cargo("build").run(); +}