[glib] tests: Disable /date/month_names test with older libc versions
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] tests: Disable /date/month_names test with older libc versions
- Date: Tue, 20 Feb 2018 12:06:26 +0000 (UTC)
commit 493d3438e805c11f8f2f084e5b7b69f145a3bf38
Author: Philip Withnall <withnall endlessm com>
Date: Tue Feb 20 12:02:20 2018 +0000
tests: Disable /date/month_names test with older libc versions
The test for %OB with g_date_strftime() fails with old libc versions
which don’ŧ support the ‘O’ modifier. g_date_strftime() explicitly
doesn’t add additional format placeholders over what’s supported by the
system strftime(), so just disable the test in that case.
The test remains useful on systems with newer libc versions, or on
Windows, where the win32 fallback path is taken.
Signed-off-by: Philip Withnall <withnall endlessm com>
https://bugzilla.gnome.org/show_bug.cgi?id=749206
glib/tests/date.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/glib/tests/date.c b/glib/tests/date.c
index 2ec33c5d8..4c2585281 100644
--- a/glib/tests/date.c
+++ b/glib/tests/date.c
@@ -176,12 +176,27 @@ test_parse (void)
static void
test_month_names (void)
{
+#if defined(HAVE_LANGINFO_ABALTMON) || defined(G_OS_WIN32)
GDate *gdate;
gchar buf[101];
gchar *oldlocale;
#ifdef G_OS_WIN32
LCID old_lcid;
#endif
+#endif /* defined(HAVE_LANGINFO_ABALTMON) || defined(G_OS_WIN32) */
+
+ g_test_bug ("749206");
+
+ /* This test can only work (on non-Windows platforms) if libc supports the %OB
+ * (etc.) format placeholders. If it doesn’t, strftime() (and hence
+ * g_date_strftime()) will return the placeholder unsubstituted.
+ * g_date_strftime() explicitly documents that it doesn’t provide any more
+ * format placeholders than the system strftime(), so we should skip the test
+ * in that case. If people need %OB support, they should depend on a suitable
+ * version of libc, or use g_date_time_format(). */
+#if !defined(HAVE_LANGINFO_ABALTMON) && !defined(G_OS_WIN32)
+ g_test_skip ("libc doesn’t support alternate month names");
+#else
#define TEST_DATE(d,m,y,f,o) \
g_date_set_dmy (gdate, d, m, y); \
@@ -193,8 +208,6 @@ test_month_names (void)
g_assert_cmpint (g_date_get_month (gdate), ==, m); \
g_assert_cmpint (g_date_get_year (gdate), ==, y);
- g_test_bug ("749206");
-
oldlocale = g_strdup (setlocale (LC_ALL, NULL));
#ifdef G_OS_WIN32
old_lcid = GetThreadLocale ();
@@ -373,7 +386,7 @@ test_month_names (void)
SetThreadLocale (old_lcid);
#endif
g_free (oldlocale);
-
+#endif /* defined(HAVE_LANGINFO_ABALTMON) || defined(G_OS_WIN32) */
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]