diff options
| author | Glenn Morris | 2018-11-10 19:13:20 -0800 |
|---|---|---|
| committer | Glenn Morris | 2018-11-10 19:13:20 -0800 |
| commit | c30f24d03dbdc730bc4c8fbc0e1309830e8c9767 (patch) | |
| tree | 17f734364169660401c088a302dfdfd80548bef1 /test/src | |
| parent | 1a3d471d87ea459bc2c2d704c5578e6977e68e83 (diff) | |
| download | emacs-c30f24d03dbdc730bc4c8fbc0e1309830e8c9767.tar.gz emacs-c30f24d03dbdc730bc4c8fbc0e1309830e8c9767.zip | |
* test/src/editfns-tests.el (test-group-name): Improve test.
Make more portable and hopefully more robust using getent. (Bug#33195)
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/editfns-tests.el | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el index 6ce49fdc28b..09584d1694a 100644 --- a/test/src/editfns-tests.el +++ b/test/src/editfns-tests.el | |||
| @@ -352,17 +352,24 @@ | |||
| 352 | "-0x000000003ffffffffffffffe000000000000000 ")))) | 352 | "-0x000000003ffffffffffffffe000000000000000 ")))) |
| 353 | 353 | ||
| 354 | (ert-deftest test-group-name () | 354 | (ert-deftest test-group-name () |
| 355 | (should (stringp (group-name (group-gid)))) | ||
| 356 | (should-error (group-name 'foo)) | ||
| 355 | (cond | 357 | (cond |
| 356 | ((memq system-type '(windows-nt ms-dos)) | 358 | ((memq system-type '(windows-nt ms-dos)) |
| 357 | (should (stringp (group-name (group-gid)))) | 359 | (should-not (group-name 123456789))) |
| 358 | (should-not (group-name 123456789)) | 360 | ((executable-find "getent") |
| 359 | (should-error (group-name 'foo))) | 361 | (with-temp-buffer |
| 360 | (t | 362 | (let (stat name) |
| 361 | (let ((list `((0 . "root") | 363 | (dolist (gid (list 0 1212345 (group-gid))) |
| 362 | ;;; (1000 . ,(user-login-name 1000)) | 364 | (erase-buffer) |
| 363 | (1212345 . nil)))) | 365 | (setq stat (call-process "getent" nil '(t nil) nil "group" |
| 364 | (dolist (test list) | 366 | (number-to-string gid))) |
| 365 | (should (equal (group-name (car test)) (cdr test))))) | 367 | (setq name (group-name gid)) |
| 366 | (should-error (group-name 'foo))))) | 368 | (goto-char (point-min)) |
| 369 | (cond ((eq stat 0) | ||
| 370 | (if (looking-at "\\([[:alnum:]_-]+\\):") | ||
| 371 | (should (string= (match-string 1) name)))) | ||
| 372 | ((eq stat 2) | ||
| 373 | (should-not name))))))))) | ||
| 367 | 374 | ||
| 368 | ;;; editfns-tests.el ends here | 375 | ;;; editfns-tests.el ends here |