Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions test/v2/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,67 @@ BOOST_AUTO_TEST_CASE(print_args_out)
}


BOOST_AUTO_TEST_CASE(print_args_spec_out)
{
using boost::unit_test::framework::master_test_suite;
const auto pth = master_test_suite().argv[1];

asio::io_context ctx;

asio::readable_pipe rp{ctx};
asio::writable_pipe wp{ctx};
asio::connect_pipe(rp, wp);


bpv::process proc(ctx, pth, {"print-args", "&foo", "&", "|bar", "\"", "#foobar"}, bpv::process_stdio{/*in*/{},/*out*/wp, /*err*/ nullptr});

wp.close();
asio::streambuf st;
std::istream is{&st};
bpv::error_code ec;

auto sz = asio::read(rp, st, ec);
while (ec == asio::error::interrupted)
sz += asio::read(rp, st, ec);

BOOST_CHECK_NE(sz, 0u);
BOOST_CHECK_MESSAGE((ec == asio::error::broken_pipe) || (ec == asio::error::eof), ec.message());

std::string line;
BOOST_CHECK(std::getline(is, line));
trim_end(line);
BOOST_CHECK_EQUAL(pth, line);

BOOST_CHECK(std::getline(is, line));
trim_end(line);
BOOST_CHECK_EQUAL("print-args", line);

BOOST_CHECK(std::getline(is, line));
trim_end(line);
BOOST_CHECK_EQUAL("&foo", line);

BOOST_CHECK(std::getline(is, line));
trim_end(line);
BOOST_CHECK_EQUAL("&", line);

BOOST_CHECK(std::getline(is, line));
trim_end(line);
BOOST_CHECK_EQUAL("|bar", line);

BOOST_CHECK(std::getline(is, line));
trim_end(line);
BOOST_CHECK_EQUAL("\"", line);

BOOST_CHECK(std::getline(is, line));
trim_end(line);
BOOST_CHECK_EQUAL("#foobar", line);


proc.wait();
BOOST_CHECK(proc.exit_code() == 0);
}


BOOST_AUTO_TEST_CASE(print_args_err)
{
using boost::unit_test::framework::master_test_suite;
Expand Down
Loading