Skip to content

Commit

Permalink
Add test cases of system.process.cpp closes-exit-minus-one
Browse files Browse the repository at this point in the history
  • Loading branch information
WangWeiLin-MV committed Sep 19, 2024
1 parent faed8f6 commit 7fb0a31
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/vcpkg-test/system.process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,38 @@ 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 return_value = cmd_execute(Command{test_program}, settings).value_or_exit(VCPKG_LINE_INFO);
#ifdef _WIN32
REQUIRE(return_value == 0xFFFFFFFFul);
#else // ^^^ _WIN32 / !_WIN32 vvv
if (WIFEXITED(return_value))
{
REQUIRE(WEXITSTATUS(return_value) == 0x000000FFul);
}
else
{
FAIL();
}
#endif // ^^^ _WIN32
}

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
REQUIRE(run.exit_code == 0xFFFFFFFFul);
#else // ^^^ _WIN32 / !_WIN32 vvv
REQUIRE(run.exit_code == 0x000000FFul);
#endif // ^^^ _WIN32
}

TEST_CASE ("no closes-stdin crash", "[system.process]")
{
auto test_program = Path(get_exe_path_of_current_process().parent_path()) / "closes-stdin";
Expand Down

0 comments on commit 7fb0a31

Please sign in to comment.