diff --git a/src/vcpkg-test/system.process.cpp b/src/vcpkg-test/system.process.cpp index f2b031df36..537262c67f 100644 --- a/src/vcpkg-test/system.process.cpp +++ b/src/vcpkg-test/system.process.cpp @@ -41,6 +41,34 @@ TEST_CASE ("captures-output", "[system.process]") REQUIRE(run.output == expected); } +TEST_CASE ("closes-exit-minus-one cmd_execute", "[system.process]") +{ + auto test_program = Path(get_exe_path_of_current_process().parent_path()) / "closes-exit-minus-one"; + ProcessLaunchSettings settings; + auto exit_code = cmd_execute(Command{test_program}, settings).value_or_exit(VCPKG_LINE_INFO); +#ifdef _WIN32 + auto expected_exit_code = -1; +#else // ^^^ _WIN32 + auto expected_exit_code = 255; +#endif // ^^^ _WIN32 + REQUIRE(exit_code == expected_exit_code); +} + +TEST_CASE ("closes-exit-minus-one cmd_execute_and_capture_output", "[system.process]") +{ + auto test_program = Path(get_exe_path_of_current_process().parent_path()) / "closes-exit-minus-one"; + RedirectedProcessLaunchSettings settings; + settings.stdin_content = "this is some input that will be intentionally not read"; + auto run = cmd_execute_and_capture_output(Command{test_program}, settings).value_or_exit(VCPKG_LINE_INFO); +#ifdef _WIN32 + auto expected_exit_code = -1; +#else // ^^^ _WIN32 + auto expected_exit_code = 255; +#endif // ^^^ _WIN32 + REQUIRE(run.exit_code == expected_exit_code); + REQUIRE(run.output.empty()); +} + TEST_CASE ("no closes-stdin crash", "[system.process]") { auto test_program = Path(get_exe_path_of_current_process().parent_path()) / "closes-stdin";