• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2016 Klemens D. Morgenstern
2 //
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 
6 #define BOOST_TEST_MAIN
7 #define BOOST_TEST_IGNORE_SIGCHLD
8 #include <boost/test/included/unit_test.hpp>
9 
10 #include <boost/process/error.hpp>
11 #include <boost/process/io.hpp>
12 #include <boost/process/async.hpp>
13 #include <boost/process/child.hpp>
14 #include <boost/process/async_system.hpp>
15 
16 #include <string>
17 #include <boost/asio/io_context.hpp>
18 #include <boost/asio/post.hpp>
19 #include <boost/asio/spawn.hpp>
20 #include <boost/asio/coroutine.hpp>
21 #include <boost/asio/use_future.hpp>
22 #include <boost/asio/yield.hpp>
23 
24 #include <vector>
25 #include <array>
26 BOOST_AUTO_TEST_SUITE( async );
27 
28 namespace bp = boost::process;
29 BOOST_AUTO_TEST_CASE(stackful_except, *boost::unit_test::timeout(15))
30 {
31     using boost::unit_test::framework::master_test_suite;
32 
33     bool did_something_else = false;
34 
35     boost::asio::io_context ios;
36     auto stackful =
37             [&](boost::asio::yield_context yield_)
__anon474084ea0102(boost::asio::yield_context yield_) 38             {
39 
40                 BOOST_CHECK_THROW(
41                     bp::async_system(
42                         ios, yield_,
43                         "none-existing-exe"), boost::system::system_error);
44 
45                 BOOST_CHECK(did_something_else);
46             };
47 
48     boost::asio::spawn(ios, stackful);
__anon474084ea0202null49     boost::asio::post(ios.get_executor(), [&]{did_something_else = true;});
50     ios.run();
51 
52     BOOST_CHECK(did_something_else);
53 }
54 
55 BOOST_AUTO_TEST_SUITE_END();
56