mirror of
https://github.com/boostorg/process.git
synced 2026-01-24 06:02:13 +00:00
split up the async_system test
This commit is contained in:
@@ -104,82 +104,4 @@ BOOST_AUTO_TEST_CASE(stackful_error, *boost::unit_test::timeout(15))
|
||||
ios.run();
|
||||
|
||||
BOOST_CHECK(did_something_else);
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(stackless, *boost::unit_test::timeout(15))
|
||||
{
|
||||
using boost::unit_test::framework::master_test_suite;
|
||||
|
||||
boost::asio::io_context ios;
|
||||
|
||||
bool did_something_else = false;
|
||||
|
||||
struct stackless_t : boost::asio::coroutine
|
||||
{
|
||||
boost::asio::io_context & ios;
|
||||
bool & did_something_else;
|
||||
|
||||
stackless_t(boost::asio::io_context & ios_,
|
||||
bool & did_something_else)
|
||||
: ios(ios_), did_something_else(did_something_else) {}
|
||||
void operator()(
|
||||
boost::system::error_code ec = boost::system::error_code(),
|
||||
std::size_t exit_code = 0)
|
||||
{
|
||||
if (!ec) reenter (this)
|
||||
{
|
||||
yield bp::async_system(
|
||||
ios, *this,
|
||||
master_test_suite().argv[1],
|
||||
"test", "--exit-code", "42");
|
||||
|
||||
BOOST_CHECK_EQUAL(exit_code, 42);
|
||||
BOOST_CHECK(did_something_else);
|
||||
}
|
||||
}
|
||||
} stackless{ios, did_something_else};
|
||||
|
||||
ios.post([&]{stackless();});
|
||||
ios.post([&]{did_something_else = true;});
|
||||
|
||||
ios.run();
|
||||
|
||||
BOOST_CHECK(did_something_else);
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(future, *boost::unit_test::timeout(15))
|
||||
{
|
||||
using boost::unit_test::framework::master_test_suite;
|
||||
|
||||
boost::asio::io_context ios;
|
||||
|
||||
std::future<int> fut = bp::async_system(
|
||||
ios, boost::asio::use_future,
|
||||
master_test_suite().argv[1],
|
||||
"test", "--exit-code", "42");
|
||||
|
||||
ios.run();
|
||||
|
||||
int exit_code = 0;
|
||||
BOOST_CHECK_NO_THROW(exit_code = fut.get());
|
||||
|
||||
BOOST_CHECK_EQUAL(exit_code, 42);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(future_error, *boost::unit_test::timeout(15))
|
||||
{
|
||||
using boost::unit_test::framework::master_test_suite;
|
||||
|
||||
boost::asio::io_context ios;
|
||||
|
||||
std::future<int> fut = bp::async_system(
|
||||
ios, boost::asio::use_future,
|
||||
"invalid-command");
|
||||
|
||||
ios.run();
|
||||
|
||||
int exit_code = 0;
|
||||
BOOST_CHECK_THROW(exit_code = fut.get(), boost::system::system_error);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user