mirror of
https://github.com/matrix-construct/construct
synced 2024-12-24 14:34:00 +01:00
construct: Synchronize smoketest quit action with console command completion.
This commit is contained in:
parent
bae534d56b
commit
0492090b56
3 changed files with 24 additions and 6 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue