Skip to content

Commit

Permalink
fixed popen test.
Browse files Browse the repository at this point in the history
  • Loading branch information
klemens-morgenstern committed Jun 22, 2023
1 parent 799a48c commit 78a5499
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion test/v2/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ BOOST_AUTO_TEST_CASE(wenvironment)
for (const auto ke : bpe::current())
{
std::string key = std::get<0>(ke).string();
printf("Getting env '%s'\n", key.c_str());
printf("Getting env '%s' of value '%s' (from '%s')\n", key.c_str(), std::get<1>(key).c_str(), ke.c_str());
BOOST_CHECK_EQUAL(bpe::get(std::get<0>(ke)), std::get<1>(ke));
}

Expand Down
8 changes: 3 additions & 5 deletions test/v2/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,24 +371,22 @@ BOOST_AUTO_TEST_CASE(popen)

asio::io_context ctx;

asio::readable_pipe rp{ctx};


// default CWD
bpv::popen proc(/*bpv::default_process_launcher(), */ctx, pth, {"echo"});

BOOST_CHECK_EQUAL(asio::write(proc, asio::buffer("FOOBAR", 6)), 6);

proc.get_stdin().close();

std::string res;
boost::system::error_code ec;
std::size_t n = asio::read(proc, asio::dynamic_buffer(res), ec);
while (ec == asio::error::interrupted)
n += asio::read(rp, asio::dynamic_buffer(res), ec);
n += asio::read(proc, asio::dynamic_buffer(res), ec);

BOOST_CHECK_MESSAGE(ec == asio::error::eof
|| ec == asio::error::broken_pipe
|| ec == asio::error::bad_descriptor,
|| ec == asio::error::broken_pipe,
ec.message());
BOOST_REQUIRE_GE(n, 1u);
BOOST_CHECK_EQUAL(res, "FOOBAR");
Expand Down

0 comments on commit 78a5499

Please sign in to comment.