tests: simplify and reduce the strictness of version string regex patterns
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Tue, 11 Apr 2023 14:47:20 +0000 (16:47 +0200)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Tue, 11 Apr 2023 15:54:57 +0000 (17:54 +0200)
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 <bartosz.golaszewski@linaro.org>
bindings/cxx/tests/tests-misc.cpp
bindings/python/tests/tests_module.py
tests/tests-misc.c

index 200fd35dba29798ab609b55314ec52bed2cf7d9c..1fa300a4454ce5df670600315b182f30e3e50219 100644 (file)
@@ -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+)$"));
        }
 }
 
index d4c90e2cc7d65f9db4c65598a1b332f2497a8826..edc0647505878d4a451c8681ecc7e00e7a3fe767 100644 (file)
@@ -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)
index a4c35fb48587297fed0c62b874d8d7945b2fd9a2..1e30ad25d62119626057344a9cbd29e22d8609f4 100644 (file)
@@ -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;