diff options
| author | Michael Albinus | 2018-07-17 12:03:43 +0200 |
|---|---|---|
| committer | Michael Albinus | 2018-07-17 12:03:43 +0200 |
| commit | 798cbac170f05a749a4d5130d64d83c202f09158 (patch) | |
| tree | 8541cd26117f0aee8bc02612f98d99fe49127ef2 /test/src | |
| parent | 94a16e7360b69191001bc594ab1b66f2b6bf97c2 (diff) | |
| download | emacs-798cbac170f05a749a4d5130d64d83c202f09158.tar.gz emacs-798cbac170f05a749a4d5130d64d83c202f09158.zip | |
Add variable main-thread, fix Bug#32169
* doc/lispref/threads.texi (Basic Thread Functions): Add example,
how to propagate signals to the main thread. Describe variable
`main-thread'. Document optional argument CLEANUP of
`thread-last-error'.
* src/thread.c (Fthread_last_error): Add optional argument
CLEANUP. (Bug#32169)
(main-thread): New defvar.
* test/src/thread-tests.el (thread-last-error): Adapt declaration.
(main-thread): Declare.
(threads-main-thread): New test.
(threads-errors): Extend test.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/thread-tests.el | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/test/src/thread-tests.el b/test/src/thread-tests.el index a00a9c84bd6..a447fb3914e 100644 --- a/test/src/thread-tests.el +++ b/test/src/thread-tests.el | |||
| @@ -34,10 +34,11 @@ | |||
| 34 | (declare-function thread--blocker "thread.c" (thread)) | 34 | (declare-function thread--blocker "thread.c" (thread)) |
| 35 | (declare-function thread-alive-p "thread.c" (thread)) | 35 | (declare-function thread-alive-p "thread.c" (thread)) |
| 36 | (declare-function thread-join "thread.c" (thread)) | 36 | (declare-function thread-join "thread.c" (thread)) |
| 37 | (declare-function thread-last-error "thread.c" ()) | 37 | (declare-function thread-last-error "thread.c" (&optional cleanup)) |
| 38 | (declare-function thread-name "thread.c" (thread)) | 38 | (declare-function thread-name "thread.c" (thread)) |
| 39 | (declare-function thread-signal "thread.c" (thread error-symbol data)) | 39 | (declare-function thread-signal "thread.c" (thread error-symbol data)) |
| 40 | (declare-function thread-yield "thread.c" ()) | 40 | (declare-function thread-yield "thread.c" ()) |
| 41 | (defvar main-thread) | ||
| 41 | 42 | ||
| 42 | (ert-deftest threads-is-one () | 43 | (ert-deftest threads-is-one () |
| 43 | "Test for existence of a thread." | 44 | "Test for existence of a thread." |
| @@ -71,6 +72,11 @@ | |||
| 71 | (skip-unless (featurep 'threads)) | 72 | (skip-unless (featurep 'threads)) |
| 72 | (should (listp (all-threads)))) | 73 | (should (listp (all-threads)))) |
| 73 | 74 | ||
| 75 | (ert-deftest threads-main-thread () | ||
| 76 | "Simple test for all-threads." | ||
| 77 | (skip-unless (featurep 'threads)) | ||
| 78 | (should (eq main-thread (car (all-threads))))) | ||
| 79 | |||
| 74 | (defvar threads-test-global nil) | 80 | (defvar threads-test-global nil) |
| 75 | 81 | ||
| 76 | (defun threads-test-thread1 () | 82 | (defun threads-test-thread1 () |
| @@ -275,6 +281,9 @@ | |||
| 275 | (thread-yield)) | 281 | (thread-yield)) |
| 276 | (should (equal (thread-last-error) | 282 | (should (equal (thread-last-error) |
| 277 | '(error "Error is called"))) | 283 | '(error "Error is called"))) |
| 284 | (should (equal (thread-last-error 'cleanup) | ||
| 285 | '(error "Error is called"))) | ||
| 286 | (should-not (thread-last-error)) | ||
| 278 | (setq th2 (make-thread #'threads-custom "threads-custom")) | 287 | (setq th2 (make-thread #'threads-custom "threads-custom")) |
| 279 | (should (threadp th2)))) | 288 | (should (threadp th2)))) |
| 280 | 289 | ||