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 18, 2024
1 parent ae24691 commit 2bdd1ee
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/vcpkg-test/system.process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,32 @@ 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
REQUIRE(exit_code == -1);
#else // ^^^ _WIN32
REQUIRE(exit_code == 255);

Check failure on line 52 in src/vcpkg-test/system.process.cpp

View workflow job for this annotation

GitHub Actions / builds / build (ubuntu-20.04, linux-ci)

REQUIRE( exit_code == 255 )

Check failure on line 52 in src/vcpkg-test/system.process.cpp

View workflow job for this annotation

GitHub Actions / builds / build (ubuntu-20.04, linux-ci)

with expansion:

Check failure on line 52 in src/vcpkg-test/system.process.cpp

View workflow job for this annotation

GitHub Actions / builds / build (ubuntu-20.04, linux-ci)

65280 (0xff00) == 255

Check failure on line 52 in src/vcpkg-test/system.process.cpp

View workflow job for this annotation

GitHub Actions / builds / build (macos-12, macos-ci)

REQUIRE( exit_code == 255 )

Check failure on line 52 in src/vcpkg-test/system.process.cpp

View workflow job for this annotation

GitHub Actions / builds / build (macos-12, macos-ci)

with expansion:

Check failure on line 52 in src/vcpkg-test/system.process.cpp

View workflow job for this annotation

GitHub Actions / builds / build (macos-12, macos-ci)

65280 (0xff00) == 255
#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 == -1);
#else // ^^^ _WIN32
REQUIRE(run.exit_code == 255);
#endif // ^^^ _WIN32
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";
Expand Down

0 comments on commit 2bdd1ee

Please sign in to comment.