Line data Source code
1 : // Copyright (c) 2012-2024 Made to Order Software Corp. All Rights Reserved 2 : // 3 : // https://snapwebsites.org/project/eventdispatcher 4 : // contact@m2osw.com 5 : // 6 : // This program is free software: you can redistribute it and/or modify 7 : // it under the terms of the GNU General Public License as published by 8 : // the Free Software Foundation, either version 3 of the License, or 9 : // (at your option) any later version. 10 : // 11 : // This program is distributed in the hope that it will be useful, 12 : // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 : // GNU General Public License for more details. 15 : // 16 : // You should have received a copy of the GNU General Public License 17 : // along with this program. If not, see <https://www.gnu.org/licenses/>. 18 : 19 : // Tell catch we want it to add the runner code in this file. 20 : #define CATCH_CONFIG_RUNNER 21 : 22 : // self 23 : // 24 : #include "catch_main.h" 25 : 26 : 27 : // eventdispatcher 28 : // 29 : #include <eventdispatcher/message_definition.h> 30 : #include <eventdispatcher/version.h> 31 : 32 : 33 : // libexcept 34 : // 35 : #include <libexcept/exception.h> 36 : 37 : 38 : // snaplogger 39 : // 40 : #include <snaplogger/logger.h> 41 : 42 : 43 : // C++ 44 : // 45 : #include <sstream> 46 : 47 : 48 : // last include 49 : // 50 : #include <snapdev/poison.h> 51 : 52 : 53 : 54 : namespace SNAP_CATCH2_NAMESPACE 55 : { 56 : 57 : 58 : char ** g_argv = nullptr; 59 : 60 : 61 : } // SNAP_CATCH2_NAMESPACE namespace 62 : 63 : 64 1 : int setup_test(Catch::Session & session) 65 : { 66 1 : snapdev::NOT_USED(session); 67 : 68 : // at this point, I setup all the paths in one place 69 : // 70 : // note that it is possible to change this list at any time 71 : // 72 : // WARNING: the order matters, we want to test with our source 73 : // (i.e. original) files first 74 : // 75 2 : ed::set_message_definition_paths( 76 2 : SNAP_CATCH2_NAMESPACE::g_source_dir() + "/tests/message-definitions:" 77 3 : + SNAP_CATCH2_NAMESPACE::g_source_dir() + "/eventdispatcher/message-definitions:" 78 3 : + SNAP_CATCH2_NAMESPACE::g_dist_dir() + "/share/eventdispatcher/messages"); 79 : 80 1 : return 0; 81 : } 82 : 83 : 84 2 : int main(int argc, char * argv[]) 85 : { 86 2 : SNAP_CATCH2_NAMESPACE::g_argv = argv; 87 : 88 2 : snaplogger::logger::pointer_t l(snaplogger::logger::get_instance()); 89 2 : l->add_console_appender(); 90 2 : l->set_severity(snaplogger::severity_t::SEVERITY_ALL); 91 : 92 2 : return SNAP_CATCH2_NAMESPACE::snap_catch2_main( 93 : "eventdispatcher" 94 : , EVENTDISPATCHER_VERSION_STRING 95 : , argc 96 : , argv 97 2 : , []() { libexcept::set_collect_stack(libexcept::collect_stack_t::COLLECT_STACK_NO); } 98 : , nullptr 99 : , &setup_test 100 2 : ); 101 2 : } 102 : 103 : 104 : // vim: ts=4 sw=4 et