Merge pull request #298 into master

44707d9f repo: gitea: workflows: dfi: impl: refactor with common exit function (Aaron Fiore)
46ae4007 container: root: test: unit: utility: add exit function no-op case (Aaron Fiore)
8a1d06be container: root: common: add interpreter exit function (Aaron Fiore)
This commit is contained in:
2026-02-13 17:02:27 -08:00
3 changed files with 22 additions and 3 deletions

View File

@@ -702,18 +702,18 @@ function container::finance::root()
"${ci_shell[@]}" "$_exec '$_root macros/repo/test/unit.C' $_exit"
"${ci_shell[@]}" "$_exec '$_root macros/repo/test/unit.C Pluggable\*:Macro\*:Plugin\*' $_exit"
"${ci_shell[@]}" "$_exec '$_root macros/repo/web/server.C gSystem-\>Exit\(0\)\;'"
"${ci_shell[@]}" "$_exec '$_root macros/repo/web/server.C dfi::common::exit\(0,\\\\\\\"Server\\\\\\\"\)\;'"
# TODO: ^ return value of macro
#
# Plugins
#
"${ci_shell[@]}" "$_exec '$_root plugins/repo/example/example.cc dfi::plugin::example::MyExamples\\ my\;my.example1\(\)\;gSystem-\>Exit\(0\)\;'"
"${ci_shell[@]}" "$_exec '$_root plugins/repo/example/example.cc dfi::plugin::example::MyExamples\\ my\;my.example1\(\)\;dfi::common::exit\(0,\\\\\\\"MyExamples\\\\\\\"\)\;'"
# WARNING: bitcoin plugin requires dfi client-side bitcoin plugin
# and must run *AFTER* the above client::finance::plugins() test
"${ci_shell[@]}" "$_exec '$_root plugins/repo/bitcoin/bitcoin.cc try{dfi::macro::load\(\\\\\\\"repo/test/unit.C\\\\\\\"\)\;}catch\(...\){gSystem-\>Exit\(1\)\;}gSystem-\>Exit\(0\)\;' $_exit"
"${ci_shell[@]}" "$_exec '$_root plugins/repo/bitcoin/bitcoin.cc try{dfi::macro::load\(\\\\\\\"repo/test/unit.C\\\\\\\"\)\;}catch\(...\){dfi::common::exit\(1\)\;}dfi::common::exit\(0\)\;' $_exit"
client::finance::down
}

View File

@@ -276,6 +276,19 @@ int exec(const std::string& cmd)
return gSystem->Exec(cmd.c_str());
}
//! \brief Exit the interpreter with given status (and message)
//! \param code Exit code status (return code)
//! \param message Optional exit message
//! \since docker-finance 1.2.0
void exit(const int code, const std::string& message = {})
{
// TODO(unassigned): logger
if (!message.empty())
std::cout << "Exiting: '" << message << "'" << std::endl;
gSystem->Exit(code);
}
//! \brief Make current timestamp
//! \return timestamp in "yyyy-mm-ddThh:mm:ssZ" format
//! \since docker-finance 1.0.0

View File

@@ -341,6 +341,12 @@ TEST_F(CommonFree, exec)
ASSERT_EQ(common::exec("pwd"), 0);
}
TEST_F(CommonFree, exit)
{
// NOTE: no-op (or else entire framework exits).
// Execution is covered in functional tests (gitea workflow).
}
TEST_F(CommonFree, make_timestamp)
{
ASSERT_EQ(common::make_timestamp().size(), 20);