mirror of
				https://github.com/rad4day/Waybar.git
				synced 2025-10-30 23:42:42 +01:00 
			
		
		
		
	test: fix build with Catch2 v2.x
Use smaller includes for Catch2 v3.
This commit is contained in:
		| @@ -447,7 +447,7 @@ endif | |||||||
|  |  | ||||||
| catch2 = dependency( | catch2 = dependency( | ||||||
|     'catch2', |     'catch2', | ||||||
|     version: '>=3.0.0', |     version: '>=2.0.0', | ||||||
|     fallback: ['catch2', 'catch2_dep'], |     fallback: ['catch2', 'catch2_dep'], | ||||||
|     required: get_option('tests'), |     required: get_option('tests'), | ||||||
| ) | ) | ||||||
|   | |||||||
| @@ -2,7 +2,11 @@ | |||||||
|  |  | ||||||
| #include <glibmm.h> | #include <glibmm.h> | ||||||
|  |  | ||||||
| #include <catch2/catch_all.hpp> | #if __has_include(<catch2/catch_test_macros.hpp>) | ||||||
|  | #include <catch2/catch_test_macros.hpp> | ||||||
|  | #else | ||||||
|  | #include <catch2/catch.hpp> | ||||||
|  | #endif | ||||||
| #include <thread> | #include <thread> | ||||||
| #include <type_traits> | #include <type_traits> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,6 +1,10 @@ | |||||||
| #include "config.hpp" | #include "config.hpp" | ||||||
|  |  | ||||||
| #include <catch2/catch_all.hpp> | #if __has_include(<catch2/catch_test_macros.hpp>) | ||||||
|  | #include <catch2/catch_test_macros.hpp> | ||||||
|  | #else | ||||||
|  | #include <catch2/catch.hpp> | ||||||
|  | #endif | ||||||
|  |  | ||||||
| TEST_CASE("Load simple config", "[config]") { | TEST_CASE("Load simple config", "[config]") { | ||||||
|   waybar::Config conf; |   waybar::Config conf; | ||||||
|   | |||||||
| @@ -3,8 +3,13 @@ | |||||||
| #include <spdlog/sinks/stdout_sinks.h> | #include <spdlog/sinks/stdout_sinks.h> | ||||||
| #include <spdlog/spdlog.h> | #include <spdlog/spdlog.h> | ||||||
|  |  | ||||||
|  | #if __has_include(<catch2/catch_all.hpp>) | ||||||
| #include <catch2/catch_all.hpp> | #include <catch2/catch_all.hpp> | ||||||
| #include <catch2/reporters/catch_reporter_tap.hpp> | #include <catch2/reporters/catch_reporter_tap.hpp> | ||||||
|  | #else | ||||||
|  | #include <catch2/catch.hpp> | ||||||
|  | #include <catch2/catch_reporter_tap.hpp> | ||||||
|  | #endif | ||||||
| #include <memory> | #include <memory> | ||||||
|  |  | ||||||
| int main(int argc, char* argv[]) { | int main(int argc, char* argv[]) { | ||||||
| @@ -13,10 +18,16 @@ int main(int argc, char* argv[]) { | |||||||
|  |  | ||||||
|   session.applyCommandLine(argc, argv); |   session.applyCommandLine(argc, argv); | ||||||
|   const auto logger = spdlog::default_logger(); |   const auto logger = spdlog::default_logger(); | ||||||
|  | #if CATCH_VERSION_MAJOR >= 3 | ||||||
|   for (const auto& spec : session.config().getReporterSpecs()) { |   for (const auto& spec : session.config().getReporterSpecs()) { | ||||||
|     if (spec.name() == "tap") { |     const auto& reporter_name = spec.name(); | ||||||
|  | #else | ||||||
|  |   { | ||||||
|  |     const auto& reporter_name = session.config().getReporterName(); | ||||||
|  | #endif | ||||||
|  |     if (reporter_name == "tap") { | ||||||
|       spdlog::set_pattern("# [%l] %v"); |       spdlog::set_pattern("# [%l] %v"); | ||||||
|     } else if (spec.name() == "compact") { |     } else if (reporter_name == "compact") { | ||||||
|       logger->sinks().clear(); |       logger->sinks().clear(); | ||||||
|     } else { |     } else { | ||||||
|       logger->sinks().assign({std::make_shared<spdlog::sinks::stderr_sink_st>()}); |       logger->sinks().assign({std::make_shared<spdlog::sinks::stderr_sink_st>()}); | ||||||
|   | |||||||
| @@ -3,7 +3,12 @@ | |||||||
| #include <date/date.h> | #include <date/date.h> | ||||||
| #include <date/tz.h> | #include <date/tz.h> | ||||||
|  |  | ||||||
| #include <catch2/catch_all.hpp> | #if __has_include(<catch2/catch_test_macros.hpp>) | ||||||
|  | #include <catch2/catch_test_macros.hpp> | ||||||
|  | #include <catch2/matchers/catch_matchers_all.hpp> | ||||||
|  | #else | ||||||
|  | #include <catch2/catch.hpp> | ||||||
|  | #endif | ||||||
| #include <chrono> | #include <chrono> | ||||||
| #include <stdexcept> | #include <stdexcept> | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Aleksei Bavshin
					Aleksei Bavshin