diff options
| author | Basil L. Contovounesios | 2018-05-15 01:22:04 +0900 |
|---|---|---|
| committer | Tino Calancha | 2018-05-15 01:22:04 +0900 |
| commit | 81fb3761ef491d55ba659594aed433f7f836f5b1 (patch) | |
| tree | 1ae146b2d55e04094ebe24c80631fcee042faea9 /test | |
| parent | 30bd61d67433c72641cb4d9a020b3c263aa6170f (diff) | |
| download | emacs-81fb3761ef491d55ba659594aed433f7f836f5b1.tar.gz emacs-81fb3761ef491d55ba659594aed433f7f836f5b1.zip | |
Fix a broken test
* lisp/simple.el (shell-command): Use call-process-shell-command,
start-process-shell-command, and file-attribute-size. (bug#30280)
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/simple-tests.el | 59 |
1 files changed, 40 insertions, 19 deletions
diff --git a/test/lisp/simple-tests.el b/test/lisp/simple-tests.el index 7a10df20587..678d9b9385a 100644 --- a/test/lisp/simple-tests.el +++ b/test/lisp/simple-tests.el | |||
| @@ -521,30 +521,51 @@ See Bug#21722." | |||
| 521 | (do-auto-fill) | 521 | (do-auto-fill) |
| 522 | (should (string-equal (buffer-string) "foo bar")))) | 522 | (should (string-equal (buffer-string) "foo bar")))) |
| 523 | 523 | ||
| 524 | |||
| 525 | ;;; Shell command. | ||
| 526 | |||
| 524 | (ert-deftest simple-tests-async-shell-command-30280 () | 527 | (ert-deftest simple-tests-async-shell-command-30280 () |
| 525 | "Test for https://debbugs.gnu.org/30280 ." | 528 | "Test for https://debbugs.gnu.org/30280 ." |
| 526 | :expected-result :failed | ||
| 527 | (let* ((async-shell-command-buffer 'new-buffer) | 529 | (let* ((async-shell-command-buffer 'new-buffer) |
| 528 | (async-shell-command-display-buffer nil) | 530 | (async-shell-command-display-buffer nil) |
| 529 | (str "*Async Shell Command*") | 531 | (base "name") |
| 530 | (buffers-name | 532 | (first (buffer-name (generate-new-buffer base))) |
| 531 | (cl-loop repeat 2 | 533 | (second (generate-new-buffer-name base)) |
| 532 | collect (buffer-name | 534 | ;; `save-window-excursion' doesn't restore frame configurations. |
| 533 | (generate-new-buffer str)))) | 535 | (pop-up-frames nil) |
| 534 | (inhibit-message t)) | 536 | (inhibit-message t)) |
| 535 | (mapc #'kill-buffer buffers-name) | 537 | ;; Let `shell-command' create the buffer as needed. |
| 536 | (async-shell-command | 538 | (kill-buffer first) |
| 537 | (format "%s -Q -batch -eval '(progn (sleep-for 3600) (message \"foo\"))'" | 539 | (unwind-protect |
| 538 | invocation-name)) | 540 | (save-window-excursion |
| 539 | (async-shell-command | 541 | ;; One command has no output, the other does. |
| 540 | (format "%s -Q -batch -eval '(progn (sleep-for 1) (message \"bar\"))'" | 542 | ;; Removing the -eval argument also yields no output, but |
| 541 | invocation-name)) | 543 | ;; then both commands exit simultaneously when |
| 542 | (let ((buffers (mapcar #'get-buffer buffers-name)) | 544 | ;; `accept-process-output' is called on the second command. |
| 543 | (processes (mapcar #'get-buffer-process buffers-name))) | 545 | (dolist (form '("(sleep-for 8)" "(message \"\")")) |
| 544 | (unwind-protect | 546 | (async-shell-command (format "%s -Q -batch -eval '%s'" |
| 545 | (should (memq (cadr buffers) (mapcar #'window-buffer (window-list)))) | 547 | invocation-name form) |
| 546 | (mapc #'delete-process processes) | 548 | first)) |
| 547 | (mapc #'kill-buffer buffers))))) | 549 | ;; First command should neither have nor display output. |
| 550 | (let* ((buffer (get-buffer first)) | ||
| 551 | (process (get-buffer-process buffer))) | ||
| 552 | (should (buffer-live-p buffer)) | ||
| 553 | (should process) | ||
| 554 | (should (zerop (buffer-size buffer))) | ||
| 555 | (should (not (get-buffer-window buffer)))) | ||
| 556 | ;; Second command should both have and display output. | ||
| 557 | (let* ((buffer (get-buffer second)) | ||
| 558 | (process (get-buffer-process buffer))) | ||
| 559 | (should (buffer-live-p buffer)) | ||
| 560 | (should process) | ||
| 561 | (should (accept-process-output process 4 nil t)) | ||
| 562 | (should (> (buffer-size buffer) 0)) | ||
| 563 | (should (get-buffer-window buffer)))) | ||
| 564 | (dolist (name (list first second)) | ||
| 565 | (let* ((buffer (get-buffer name)) | ||
| 566 | (process (and buffer (get-buffer-process buffer)))) | ||
| 567 | (when process (delete-process process)) | ||
| 568 | (when buffer (kill-buffer buffer))))))) | ||
| 548 | 569 | ||
| 549 | (provide 'simple-test) | 570 | (provide 'simple-test) |
| 550 | ;;; simple-test.el ends here | 571 | ;;; simple-test.el ends here |