diff --git a/.gitea/workflows/dfi.bash b/.gitea/workflows/dfi.bash index 4f6e5f3..46c479f 100755 --- a/.gitea/workflows/dfi.bash +++ b/.gitea/workflows/dfi.bash @@ -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 } diff --git a/container/src/root/common/utility.hh b/container/src/root/common/utility.hh index b86c6f7..90d7dee 100644 --- a/container/src/root/common/utility.hh +++ b/container/src/root/common/utility.hh @@ -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 diff --git a/container/src/root/test/unit/utility.hh b/container/src/root/test/unit/utility.hh index e74db59..848f75b 100644 --- a/container/src/root/test/unit/utility.hh +++ b/container/src/root/test/unit/utility.hh @@ -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);