emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master c30f24d: * test/src/editfns-tests.el (test-group-na


From: Glenn Morris
Subject: [Emacs-diffs] master c30f24d: * test/src/editfns-tests.el (test-group-name): Improve test.
Date: Sat, 10 Nov 2018 22:14:31 -0500 (EST)

branch: master
commit c30f24d03dbdc730bc4c8fbc0e1309830e8c9767
Author: Glenn Morris <address@hidden>
Commit: Glenn Morris <address@hidden>

    * test/src/editfns-tests.el (test-group-name): Improve test.
    
    Make more portable and hopefully more robust using getent.  (Bug#33195)
---
 test/src/editfns-tests.el | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el
index 6ce49fd..09584d1 100644
--- a/test/src/editfns-tests.el
+++ b/test/src/editfns-tests.el
@@ -352,17 +352,24 @@
                    "-0x000000003ffffffffffffffe000000000000000        "))))
 
 (ert-deftest test-group-name ()
+  (should (stringp (group-name (group-gid))))
+  (should-error (group-name 'foo))
   (cond
    ((memq system-type '(windows-nt ms-dos))
-    (should (stringp (group-name (group-gid))))
-    (should-not (group-name 123456789))
-    (should-error (group-name 'foo)))
-   (t
-    (let ((list `((0 . "root")
-;;;                  (1000 . ,(user-login-name 1000))
-                  (1212345 . nil))))
-      (dolist (test list)
-        (should (equal (group-name (car test)) (cdr test)))))
-    (should-error (group-name 'foo)))))
+    (should-not (group-name 123456789)))
+   ((executable-find "getent")
+    (with-temp-buffer
+      (let (stat name)
+      (dolist (gid (list 0 1212345 (group-gid)))
+        (erase-buffer)
+        (setq stat (call-process "getent" nil '(t nil) nil "group"
+                                 (number-to-string gid)))
+        (setq name (group-name gid))
+        (goto-char (point-min))
+        (cond ((eq stat 0)
+               (if (looking-at "\\([[:alnum:]_-]+\\):")
+                   (should (string= (match-string 1) name))))
+              ((eq stat 2)
+               (should-not name)))))))))
 
 ;;; editfns-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]