refactor(test): use single executable

pull/1380/head
Aleksei Bavshin 2022-01-07 18:59:08 -08:00
parent c0d84853ea
commit 8c41aaae04
No known key found for this signature in database
GPG Key ID: 4F071603387A382A
4 changed files with 32 additions and 24 deletions

View File

@ -1,4 +1,3 @@
#define CATCH_CONFIG_RUNNER
#include "util/SafeSignal.hpp"
#include <glibmm.h>
@ -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);
}

View File

@ -1,4 +1,3 @@
#define CATCH_CONFIG_MAIN
#include "config.hpp"
#include <catch2/catch.hpp>

26
test/main.cpp 100644
View File

@ -0,0 +1,26 @@
#define CATCH_CONFIG_RUNNER
#include <glibmm.h>
#include <spdlog/sinks/stdout_sinks.h>
#include <spdlog/spdlog.h>
#include <catch2/catch.hpp>
#include <catch2/catch_reporter_tap.hpp>
#include <memory>
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<spdlog::sinks::stderr_sink_st>()});
}
return session.run();
}

View File

@ -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(),
)