[glib/wip/pwithnall/fix-environment-tests] tests: Fix environment test on FreeBSD




commit 4bb9e20fff26300411716fba0c9969d3f866890e
Author: Philip Withnall <pwithnall endlessos org>
Date:   Thu Dec 23 13:04:49 2021 +0000

    tests: Fix environment test on FreeBSD
    
    Fix for commit 20c8ea1bc651bc4b79d39b80d42b468f6e7a2dc8; while Linux
    seems happy to return the value for the invalid key we set above, BSD
    returns NULL (which is probably a more valid thing to do).
    
    Accept both.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 glib/tests/environment.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/glib/tests/environment.c b/glib/tests/environment.c
index 486acc907..6400e3a69 100644
--- a/glib/tests/environment.c
+++ b/glib/tests/environment.c
@@ -103,8 +103,11 @@ test_getenv (void)
 
   g_assert_true (g_setenv ("foo", "bar=baz", TRUE));
 
+  /* Different OSs return different values; some return NULL because the key
+   * is invalid, but some are happy to return what we set above. */
   data = g_getenv ("foo=bar");
-  g_assert_cmpstr (data, ==, "baz");
+  if (data != NULL)
+    g_assert_cmpstr (data, ==, "baz");
 
   data = g_getenv ("foo");
   g_assert_cmpstr (data, ==, "bar=baz");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]