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 d324d2f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/vcpkg-test/system.process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

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

View workflow job for this annotation

GitHub Actions / builds / build (windows-2022, windows-ci)

the following warning is treated as an error

Check warning on line 54 in src/vcpkg-test/system.process.cpp

View workflow job for this annotation

GitHub Actions / builds / build (windows-2022, windows-ci)

'==': signed/unsigned mismatch

Check failure on line 54 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 == expected_exit_code )

Check failure on line 54 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 54 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 54 in src/vcpkg-test/system.process.cpp

View workflow job for this annotation

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

REQUIRE( exit_code == expected_exit_code )

Check failure on line 54 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 54 in src/vcpkg-test/system.process.cpp

View workflow job for this annotation

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

65280 (0xff00) == 255
}

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);

Check warning on line 68 in src/vcpkg-test/system.process.cpp

View workflow job for this annotation

GitHub Actions / builds / build (windows-2022, windows-ci)

'==': signed/unsigned mismatch
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 d324d2f

Please sign in to comment.