commit d551e255fe79ea1e463fe757554a55bf5adf5058
parent 289e66aa6f062b1282b2e877e939183a2f5653b3
Author: cfillion <cfillion@users.noreply.github.com>
Date: Thu, 18 Aug 2022 21:59:52 -0400
migrate to Catch2 v3
Diffstat:
7 files changed, 22 insertions(+), 23 deletions(-)
diff --git a/.appveyor.yml b/.appveyor.yml
@@ -98,9 +98,9 @@ for:
# https://letsencrypt.org/docs/dst-root-ca-x3-expiration-september-2021/
- sudo curl -k https://curl.se/ca/cacert.pem -o /etc/ssl/cert.pem
- # backport vcpkg bugfixes
+ # update to Catch2 v3
git -C ~/vcpkg fetch
- git -C ~/vcpkg restore -s 38d6712d5644ede4ff597e889549f5d540dcf8ff ports/catch2
+ git -C ~/vcpkg restore -s 50fe35a3c3ca43ffe3b436380cf563100406459a ports/catch2
fi
artifacts:
- path: build/reaper_reapack*.dylib
diff --git a/README.md b/README.md
@@ -26,7 +26,7 @@ Install the following libraries (and development headers if your system provides
them separately):
- [Boost](https://www.boost.org/) (1.56 or later)
-- [Catch2](https://github.com/catchorg/Catch2)
+- [Catch2](https://github.com/catchorg/Catch2) (3.0 or later)
- [libcurl](https://curl.haxx.se/libcurl/)
- [libxml2](http://www.xmlsoft.org/)
- [OpenSSL](https://www.openssl.org/) or compatible
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
@@ -13,7 +13,6 @@ add_executable(tests EXCLUDE_FROM_ALL
helper.hpp
index.cpp
index_v1.cpp
- main.cpp
metadata.cpp
package.cpp
path.cpp
@@ -36,4 +35,4 @@ target_include_directories(tests PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/vendor ${CMAKE_SOURCE_DIR}/vendor/reaper-sdk/sdk
)
-target_link_libraries(tests Catch2::Catch2 reapack)
+target_link_libraries(tests Catch2::Catch2WithMain reapack)
diff --git a/test/helper.hpp b/test/helper.hpp
@@ -7,4 +7,6 @@ class Time;
std::ostream &operator<<(std::ostream &, const std::set<Path> &);
// include Catch only after having declared our ostream overloads
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
+#include <catch2/matchers/catch_matchers_contains.hpp>
+#include <catch2/matchers/catch_matchers_string.hpp>
diff --git a/test/main.cpp b/test/main.cpp
@@ -1,2 +0,0 @@
-#define CATCH_CONFIG_MAIN
-#include "helper.hpp"
diff --git a/test/receipt.cpp b/test/receipt.cpp
@@ -4,7 +4,7 @@
#include <index.hpp>
-using Catch::Matchers::Contains;
+using Catch::Matchers::ContainsSubstring;
using Catch::Matchers::EndsWith;
static const char *M = "[receipt]";
@@ -166,41 +166,41 @@ TEST_CASE("format install ticket", M) {
SECTION("contains fullname") {
stream << InstallTicket{v3, {}};
- REQUIRE_THAT(stream.str(), Contains(pkg.fullName()));
+ REQUIRE_THAT(stream.str(), ContainsSubstring(pkg.fullName()));
}
SECTION("prepend newline if stream nonempty") {
stream << "something";
stream << InstallTicket{v3, {}};
- REQUIRE_THAT(stream.str(), Contains("something\r\n"));
+ REQUIRE_THAT(stream.str(), ContainsSubstring("something\r\n"));
}
SECTION("installed from scratch") {
stream << InstallTicket{v2, {}};
- REQUIRE_THAT(stream.str(), Contains("[new]") &&
- !Contains("v1.0\r\n") && Contains("v2.0\r\n") && !Contains("v3.0\r\n"));
+ REQUIRE_THAT(stream.str(), ContainsSubstring("[new]") &&
+ !ContainsSubstring("v1.0\r\n") && ContainsSubstring("v2.0\r\n") && !ContainsSubstring("v3.0\r\n"));
}
SECTION("reinstalled") {
entry.version = VersionName("2.0");
stream << InstallTicket{v2, entry};
- REQUIRE_THAT(stream.str(), Contains("[reinstalled]") &&
- !Contains("v1.0\r\n") && Contains("v2.0\r\n") && !Contains("v3.0\r\n"));
+ REQUIRE_THAT(stream.str(), ContainsSubstring("[reinstalled]") &&
+ !ContainsSubstring("v1.0\r\n") && ContainsSubstring("v2.0\r\n") && !ContainsSubstring("v3.0\r\n"));
}
SECTION("update") {
entry.version = VersionName("1.0");
stream << InstallTicket{v3, entry};
- REQUIRE_THAT(stream.str(), Contains("[v1.0 -> v3.0]") &&
- !Contains("v1.0\r\n") && Contains("\r\nv3.0\r\n No changelog\r\nv2.0"));
+ REQUIRE_THAT(stream.str(), ContainsSubstring("[v1.0 -> v3.0]") &&
+ !ContainsSubstring("v1.0\r\n") && ContainsSubstring("\r\nv3.0\r\n No changelog\r\nv2.0"));
REQUIRE_THAT(stream.str(), !EndsWith("\r\n"));
}
SECTION("downgrade") {
entry.version = VersionName("3.0");
stream << InstallTicket{v1, entry};
- REQUIRE_THAT(stream.str(), Contains("[v3.0 -> v1.0]") &&
- Contains("v1.0\r\n") && !Contains("v2.0\r\n") && !Contains("v3.0\r\n"));
+ REQUIRE_THAT(stream.str(), ContainsSubstring("[v3.0 -> v1.0]") &&
+ ContainsSubstring("v1.0\r\n") && !ContainsSubstring("v2.0\r\n") && !ContainsSubstring("v3.0\r\n"));
}
}
diff --git a/test/remote.cpp b/test/remote.cpp
@@ -171,17 +171,17 @@ TEST_CASE("protect remote", M) {
TEST_CASE("autoinstall remote", M) {
Remote remote;
- REQUIRE_FALSE(remote.autoInstall());
+ REQUIRE_FALSE(bool{remote.autoInstall()});
REQUIRE(remote.autoInstall(true));
REQUIRE_FALSE(remote.autoInstall(false));
remote.setAutoInstall(true);
- REQUIRE(remote.autoInstall());
+ REQUIRE(bool{remote.autoInstall()});
REQUIRE(remote.autoInstall(true));
REQUIRE(remote.autoInstall(false));
remote.setAutoInstall(false);
- REQUIRE_FALSE(remote.autoInstall());
+ REQUIRE_FALSE(bool{remote.autoInstall()});
REQUIRE_FALSE(remote.autoInstall(true));
REQUIRE_FALSE(remote.autoInstall(false));
}
@@ -260,7 +260,7 @@ TEST_CASE("unserialize remote", M) {
SECTION("auto-install enabled") {
Remote remote = Remote::fromString("name|url|1|1");
- REQUIRE(remote.autoInstall());
+ REQUIRE(bool{remote.autoInstall()});
}
SECTION("auto-install enabled") {