@@ -933,5 +933,56 @@ BOOST_AUTO_TEST_CASE(print_args_combined)
933933 BOOST_CHECK_EQUAL (proc.exit_code (), 0 );
934934}
935935
936+
937+ struct my_handler
938+ {
939+ boost::process::filesystem::path pt;
940+ bpv::error_code ec;
941+
942+ template <typename Launcher, typename CmdLine>
943+ bpv::error_code on_setup (Launcher &launcher, const bpv::filesystem::path& executable,
944+ CmdLine (&/* cmd_line*/ ))
945+ {
946+ pt = executable;
947+ if (executable == " /send/more/cops" )
948+ return asio::error::no_recovery;
949+ else
950+ return {};
951+ }
952+
953+ template <typename Launcher, typename CmdLine>
954+ void on_error (Launcher &launcher, const bpv::filesystem::path& executable,
955+ CmdLine (&/* cmd_line*/ ), const bpv::error_code & ec)
956+ {
957+ this ->ec = ec;
958+ }
959+
960+ template <typename Launcher, typename CmdLine>
961+ void on_success (Launcher &launcher, const bpv::filesystem::path& executable,
962+ CmdLine (&/* cmd_line*/ ))
963+ {
964+ ec.clear ();
965+ }
966+ };
967+
968+ BOOST_AUTO_TEST_CASE (custom_handlers)
969+ {
970+ my_handler mh;
971+
972+ asio::io_context ctx;
973+
974+ BOOST_CHECK_THROW (bpv::process (ctx, " /send/more/cops" , {}, mh), bpv::system_error);
975+ BOOST_CHECK_EQUAL (mh.ec , asio::error::no_recovery);
976+
977+ BOOST_CHECK_EQUAL (mh.pt , " /send/more/cops" );
978+
979+ using boost::unit_test::framework::master_test_suite;
980+ const auto pth = bpv::filesystem::absolute (master_test_suite ().argv [1 ]);
981+
982+ bpv::process proc (ctx, pth, {}, mh);
983+
984+ BOOST_CHECK_EQUAL (mh.pt , pth);
985+ }
986+
936987BOOST_AUTO_TEST_SUITE_END ();
937988
0 commit comments