From: Bartosz Golaszewski Date: Tue, 11 Apr 2023 14:47:20 +0000 (+0200) Subject: tests: simplify and reduce the strictness of version string regex patterns X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=b740f64daf62f16548b48126723da8f59cdb6515;p=qemu-gpiodev%2Flibgpiod.git tests: simplify and reduce the strictness of version string regex patterns It seems like every release there's some new problem with parsing the version strings in tests. Let's reduce the strictness of the patterns to avoid future test failures and accept the following version schemes: X.Y X.Y.Z X.Y-devel X.Y-rcZ Signed-off-by: Bartosz Golaszewski --- diff --git a/bindings/cxx/tests/tests-misc.cpp b/bindings/cxx/tests/tests-misc.cpp index 200fd35..1fa300a 100644 --- a/bindings/cxx/tests/tests-misc.cpp +++ b/bindings/cxx/tests/tests-misc.cpp @@ -71,7 +71,7 @@ TEST_CASE("api_version() returns a valid API version", "[misc]") SECTION("check api_version() format") { REQUIRE_THAT(::gpiod::api_version(), - regex_matcher("^[0-9][1-9]?\\.[0-9][1-9]?(\\.[0-9]?|\\-devel|\\-rc[0-9])$")); + regex_matcher("^\\d+\\.\\d+(\\.\\d+|\\-devel|\\-rc\\d+)$")); } } diff --git a/bindings/python/tests/tests_module.py b/bindings/python/tests/tests_module.py index d4c90e2..edc0647 100644 --- a/bindings/python/tests/tests_module.py +++ b/bindings/python/tests/tests_module.py @@ -51,7 +51,7 @@ class IsGPIOChip(TestCase): class VersionString(TestCase): - VERSION_PATTERN = "^[0-9][1-9]?\\.[0-9][1-9]?(\\.[0-9]?|\\-devel|\\-rc[0-9])$" + VERSION_PATTERN = "^\\d+\\.\\d+(\\.\\d+|\\-devel|\\-rc\\d+)$" def test_api_version_string(self): self.assertRegex(gpiod.api_version, VersionString.VERSION_PATTERN) diff --git a/tests/tests-misc.c b/tests/tests-misc.c index a4c35fb..1e30ad2 100644 --- a/tests/tests-misc.c +++ b/tests/tests-misc.c @@ -67,7 +67,7 @@ GPIOD_TEST_CASE(is_gpiochip_null_path) GPIOD_TEST_CASE(version_string) { - static const gchar *const pattern = "^[0-9][1-9]?\\.[0-9][1-9]?(\\.[0-9]?|\\-devel|\\-rc[0-9])$"; + static const gchar *const pattern = "^\\d+\\.\\d+(\\.\\d+|\\-devel|\\-rc\\d+)$"; g_autoptr(GError) err = NULL; g_autoptr(GRegex) regex = NULL;