0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-25 06:53:58 +01:00

construct: Synchronize smoketest quit action with console command completion.

This commit is contained in:
Jason Volk 2020-09-27 17:00:29 -07:00
parent bae534d56b
commit 0492090b56
3 changed files with 24 additions and 6 deletions

View file

@ -71,6 +71,9 @@ construct::console::seen_message;
decltype(construct::console::queue)
construct::console::queue;
decltype(construct::console::quit_when_done)
construct::console::quit_when_done;
bool
construct::console::spawn()
{
@ -155,6 +158,9 @@ try
if(!next_command())
break;
if(quit_when_done)
ircd::post{ircd::quit};
return;
}

View file

@ -19,6 +19,7 @@ struct construct::console
static const ircd::string_view console_message;
static std::once_flag seen_message;
static std::deque<std::string> queue;
static bool quit_when_done;
std::string line;
std::string record_path;

View file

@ -178,17 +178,28 @@ noexcept try
// The smoketest uses this ircd::run::level callback to set a flag when
// each ircd::run::level is reached. All flags must be set to pass. The
// smoketest is inert unless the -smoketest program option is used. Note
// the special case for run::level::RUN, which initiates the transition
// to QUIT; the ircd::post allows any operations queued in the io_context
// to run in case the smoketest isn't the only callback being invoked.
// smoketest is inert unless the -smoketest program option is used.
const ircd::run::changed smoketester
{
[](const auto &level)
{
smoketest.at(size_t(level) + 1) = true;
if(smoketest[0] && level == ircd::run::level::RUN)
ircd::post {[] { ircd::quit(); }};
if(!smoketest[0])
return;
if(level != ircd::run::level::RUN)
return;
if(construct::console::active())
{
construct::console::quit_when_done = true;
return;
};
ircd::post
{
ircd::quit
};
}
};