APPROVE COMMIT
NOTE: This patch has been committed
# HG changeset patch
# User Aidan Kehoe <kehoea(a)parhasard.net>
# Date 1523020486 -3600
# Fri Apr 06 14:14:46 2018 +0100
# Node ID 3e52d0a8ca3db32b980c27ee9d8bbc4b979af68b
# Parent eb122f8fba85ba574e69d593e95994ca0e6d2532
Avoid blowing the ARG_MAX limit on environment size, os-tests.el
src/ChangeLog addition:
2018-04-06 Aidan Kehoe <kehoea(a)parhasard.net>
* process-unix.c:
* process-unix.c (child_setup):
When execve() fails, print the associated error message.
tests/ChangeLog addition:
2018-04-06 Aidan Kehoe <kehoea(a)parhasard.net>
* automated/os-tests.el (handle-call-process-cases): New.
* automated/os-tests.el :
Rework the call-process-region tests, making the Assert messages
on failure more helpful, and not depending on #'executable-find.
Be polite after the #'substitute-in-file-name tests, remove our
unreasonably large values from the process environment.
diff -r eb122f8fba85 -r 3e52d0a8ca3d src/ChangeLog
--- a/src/ChangeLog Thu Jan 04 21:27:22 2018 +0000
+++ b/src/ChangeLog Fri Apr 06 14:14:46 2018 +0100
@@ -1,3 +1,9 @@
+2018-04-06 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * process-unix.c:
+ * process-unix.c (child_setup):
+ When execve() fails, print the associated error message.
+
2018-01-04 Aidan Kehoe <kehoea(a)parhasard.net>
Move the X GC cache to using the Lisp hash table structure (as
diff -r eb122f8fba85 -r 3e52d0a8ca3d src/process-unix.c
--- a/src/process-unix.c Thu Jan 04 21:27:22 2018 +0000
+++ b/src/process-unix.c Fri Apr 06 14:14:46 2018 +0100
@@ -896,7 +896,7 @@
Lisp_Object current_dir)
{
Ibyte **env;
- Ibyte *pwd;
+ Ibyte *pwd, *errmess;
#ifdef SET_EMACS_PRIORITY
if (emacs_priority != 0)
@@ -1033,7 +1033,9 @@
/* we've wrapped execve; it translates its arguments */
qxe_execve (new_argv[0], new_argv, env);
- stdout_out ("Can't exec program %s\n", new_argv[0]);
+ GET_STRERROR (errmess, errno);
+
+ stdout_out ("Can't exec program %s: %s\n", new_argv[0], errmess);
_exit (1);
}
diff -r eb122f8fba85 -r 3e52d0a8ca3d tests/ChangeLog
--- a/tests/ChangeLog Thu Jan 04 21:27:22 2018 +0000
+++ b/tests/ChangeLog Fri Apr 06 14:14:46 2018 +0100
@@ -1,3 +1,12 @@
+2018-04-06 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * automated/os-tests.el (handle-call-process-cases): New.
+ * automated/os-tests.el :
+ Rework the call-process-region tests, making the Assert messages
+ on failure more helpful, and not depending on #'executable-find.
+ Be polite after the #'substitute-in-file-name tests, remove our
+ unreasonably large values from the process environment.
+
2017-12-24 Aidan Kehoe <kehoea(a)parhasard.net>
* automated/mule-tests.el:
diff -r eb122f8fba85 -r 3e52d0a8ca3d tests/automated/os-tests.el
--- a/tests/automated/os-tests.el Thu Jan 04 21:27:22 2018 +0000
+++ b/tests/automated/os-tests.el Fri Apr 06 14:14:46 2018 +0100
@@ -34,60 +34,45 @@
;; in <b9yoeipvwn0.fsf(a)jpl.org>.
;; tac works by lines, unfortunately
-;; #### The contortions around `executable-find' gag me, but I don't have time
-;; to deal today. If we have `executable-find', we should use its value!
-(let* ((original-string "a\nb\nc\nd\n")
- ;; `executable-find' is in a package and may be unavailable.
- (tac-cases (if (and (fboundp 'executable-find) (executable-find
"tac"))
- '((1 . "c\nb\na\nd\n")
- (3 . "a\nc\nb\nd\n")
- (5 . "a\nc\nb\nd\n")
- (7 . "a\nc\nb\nd\n")
- (9 . "a\nd\nc\nb\n"))
- nil))
- (cat-cases (if (and (fboundp 'executable-find) (executable-find
"cat"))
- '((1 . "b\nc\na\nd\n")
- (3 . "a\nb\nc\nd\n")
- (5 . "a\nb\nc\nd\n")
- (7 . "a\nb\nc\nd\n")
- (9 . "a\nd\nb\nc\n"))
- nil))
- cases case)
- (with-temp-buffer
- (Skip-Test-Unless tac-cases
- "tac executable not found"
- "Tests of call-process-region with region deleted after inserting
+(macrolet
+ ((handle-call-process-cases (program &rest cases)
+ (cons
+ 'progn
+ (loop for (pos . result) in cases
+ nconc `((erase-buffer)
+ (insert "a\nb\nc\nd\n")
+ (goto-char ,pos)
+ (Assert (eql (call-process-region 3 7 ,program t t) 0)
+ ,(concat "failed calling " program))
+ (goto-char (point-min))
+ (Assert (equal (buffer-string) ,result)
+ ,(format "test call-process-region, %s, pos %d, "
+ program pos)))))))
+ (with-temp-buffer
+ (Skip-Test-Unless
+ (condition-case nil (call-process "tac") (process-error nil))
+ "tac executable not found"
+ "Tests of call-process-region with region deleted after inserting
tac process output."
- (setq cases tac-cases)
- (while cases
- (setq case (car cases)
- cases (cdr cases))
- (labels ((do-test (pos result)
- (erase-buffer)
- (insert original-string)
- (goto-char pos)
- (call-process-region 3 7 "tac" t t)
- (goto-char (point-min))
- (Assert (looking-at result))))
- (do-test (car case) (cdr case)))))
+ (handle-call-process-cases "tac"
+ (1 . "c\nb\na\nd\n")
+ (3 . "a\nc\nb\nd\n")
+ (5 . "a\nc\nb\nd\n")
+ (7 . "a\nc\nb\nd\n")
+ (9 . "a\nd\nc\nb\n")))
;; if you're in that much of a hurry you can blow cat off
;; if you've done tac, but I'm not going to bother
- (Skip-Test-Unless cat-cases
- "cat executable not found"
- "Tests of call-process-region with region deleted after inserting
+ (Skip-Test-Unless
+ (condition-case nil (call-process "cat") (process-error nil))
+ "cat executable not found"
+ "Tests of call-process-region with region deleted after inserting
cat process output."
- (setq cases cat-cases)
- (while cases
- (setq case (car cases)
- cases (cdr cases))
- (labels ((do-test (pos result)
- (erase-buffer)
- (insert original-string)
- (goto-char pos)
- (call-process-region 3 7 "cat" t t)
- (goto-char (point-min))
- (Assert (looking-at result))))
- (do-test (car case) (cdr case)))))))
+ (handle-call-process-cases "cat"
+ (1 . "b\nc\na\nd\n")
+ (3 . "a\nb\nc\nd\n")
+ (5 . "a\nb\nc\nd\n")
+ (7 . "a\nb\nc\nd\n")
+ (9 . "a\nd\nb\nc\n")))))
(loop
with envvar-not-existing = (symbol-name (gensym "whatever"))
@@ -120,8 +105,10 @@
(setenv envvar-existing envvar-existing-val))
for (pre post)
in examples
- do
- (Assert (string= post (substitute-in-file-name pre))))
+ do (Assert (string= post (substitute-in-file-name pre)))
+ ;; Be polite and don't overrun ARG_MAX for any processes called down
+ ;; the line.
+ finally (setenv envvar-existing nil t))
;; Check some restrictions introduced to the ZONE argument to #'encode-time.
--
‘As I sat looking up at the Guinness ad, I could never figure out /
How your man stayed up on the surfboard after forty pints of stout’
(C. Moore)
Show replies by date