From 8c41aaae046eb014b9192679f9c707fc429dbb9b Mon Sep 17 00:00:00 2001 From: Aleksei Bavshin Date: Fri, 7 Jan 2022 18:59:08 -0800 Subject: [PATCH] refactor(test): use single executable --- test/SafeSignal.cpp | 6 ------ test/config.cpp | 1 - test/main.cpp | 26 ++++++++++++++++++++++++++ test/meson.build | 23 ++++++----------------- 4 files changed, 32 insertions(+), 24 deletions(-) create mode 100644 test/main.cpp diff --git a/test/SafeSignal.cpp b/test/SafeSignal.cpp index 2c67317..244487f 100644 --- a/test/SafeSignal.cpp +++ b/test/SafeSignal.cpp @@ -1,4 +1,3 @@ -#define CATCH_CONFIG_RUNNER #include "util/SafeSignal.hpp" #include @@ -138,8 +137,3 @@ TEST_CASE_METHOD(GlibTestsFixture, "SafeSignal copy/move counter", "[signal][thr producer.join(); REQUIRE(count == NUM_EVENTS); } - -int main(int argc, char* argv[]) { - Glib::init(); - return Catch::Session().run(argc, argv); -} diff --git a/test/config.cpp b/test/config.cpp index edd6d6b..29b0502 100644 --- a/test/config.cpp +++ b/test/config.cpp @@ -1,4 +1,3 @@ -#define CATCH_CONFIG_MAIN #include "config.hpp" #include diff --git a/test/main.cpp b/test/main.cpp new file mode 100644 index 0000000..bbfcc9f --- /dev/null +++ b/test/main.cpp @@ -0,0 +1,26 @@ +#define CATCH_CONFIG_RUNNER +#include +#include +#include + +#include +#include +#include + +int main(int argc, char* argv[]) { + Catch::Session session; + Glib::init(); + + session.applyCommandLine(argc, argv); + const auto logger = spdlog::default_logger(); + const auto& reporter_name = session.config().getReporterName(); + if (reporter_name == "tap") { + spdlog::set_pattern("# [%l] %v"); + } else if (reporter_name == "compact") { + logger->sinks().clear(); + } else { + logger->sinks().assign({std::make_shared()}); + } + + return session.run(); +} diff --git a/test/meson.build b/test/meson.build index bbef21e..473a626 100644 --- a/test/meson.build +++ b/test/meson.build @@ -7,29 +7,18 @@ test_dep = [ spdlog, ] -config_test = executable( - 'config_test', +waybar_test = executable( + 'waybar_test', + 'main.cpp', + 'SafeSignal.cpp', 'config.cpp', '../src/config.cpp', dependencies: test_dep, include_directories: test_inc, ) -safesignal_test = executable( - 'safesignal_test', - 'SafeSignal.cpp', - dependencies: test_dep, - include_directories: test_inc, -) - test( - 'Configuration test', - config_test, - workdir: meson.source_root(), -) - -test( - 'SafeSignal test', - safesignal_test, + 'waybar', + waybar_test, workdir: meson.source_root(), )