]> Savannah Git Hosting - gnulib.git/commitdiff
posix_spawn_file_actions_addchdir tests: Avoid test failure on MSYS2.
authorBruno Haible <bruno@clisp.org>
Sun, 22 Dec 2024 11:10:14 +0000 (12:10 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 25 Dec 2024 14:31:14 +0000 (15:31 +0100)
* tests/test-posix_spawn-chdir.c (test): Recognize also the 'pwd' output
for root on MSYS2.

ChangeLog
tests/test-posix_spawn-chdir.c

index 103417b791cfc3b660f8f351615db9c1e4da99c1..8595bb5ccc87a85f911e1b4ab7015676f1348bab 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-12-22  Bruno Haible  <bruno@clisp.org>
+
+       posix_spawn_file_actions_addchdir tests: Avoid test failure on MSYS2.
+       * tests/test-posix_spawn-chdir.c (test): Recognize also the 'pwd' output
+       for root on MSYS2.
+
 2024-12-22  Bruno Haible  <bruno@clisp.org>
 
        test-framework-sh: Avoid test suite failures on MSYS2.
index de8d251d90a5dbf7f5334416ab5809a3f3a85713..a5f9b4af612194ae69aaea2f4cf41e15e683267f 100644 (file)
@@ -132,12 +132,19 @@ test (const char *pwd_prog)
   if (!(line_len == 2 && memcmp (line, "/\n", 2) == 0))
 #if defined _WIN32 && !defined __CYGWIN__
     /* If the pwd program is Cygwin's pwd, its output in the root directory is
-       "/cygdrive/N", where N is a lowercase letter.  */
-    if (!(line_len > 11
-          && memcmp (line, "/cygdrive/", 10) == 0
-          && line[10] >= 'a' && line[10] <= 'z'
-          && ((line_len == 12 && line[11] == '\n')
-              || (line_len == 13 && line[11] == '\r' && line[12] == '\n'))))
+       "/cygdrive/N", where N is a lowercase letter.
+       And if the pwd program is MSYS2 pwd, its output in the root directory is
+       "/N", where N is a lowercase letter.  */
+    if (!((line_len > 11
+           && memcmp (line, "/cygdrive/", 10) == 0
+           && line[10] >= 'a' && line[10] <= 'z'
+           && ((line_len == 12 && line[11] == '\n')
+               || (line_len == 13 && line[11] == '\r' && line[12] == '\n')))
+          || (line_len > 2
+              && line[0] == '/'
+              && line[1] >= 'a' && line[1] <= 'z'
+              && ((line_len == 3 && line[2] == '\n')
+                  || (line_len == 4 && line[2] == '\r' && line[3] == '\n')))))
 #endif
       {
         fprintf (stderr, "read output is not the expected output\n");