Commit 188a9d99 authored by Glenn Morris's avatar Glenn Morris

Add some test skip conditions

* test/lisp/vc/vc-bzr-tests.el (vc-bzr-test-bug9726)
(vc-bzr-test-bug9781): Skip if bzr is faulty.
* test/src/thread-tests.el: Skip if not compiled with threads.
parent 06439525
...@@ -53,7 +53,8 @@ ...@@ -53,7 +53,8 @@
(insert (file-name-nondirectory ignored-dir)) (insert (file-name-nondirectory ignored-dir))
(write-region nil nil (expand-file-name ".bzrignore" bzrdir) (write-region nil nil (expand-file-name ".bzrignore" bzrdir)
nil 'silent)) nil 'silent))
(call-process vc-bzr-program nil nil nil "init") (skip-unless (eq 0 ; some internal bzr error
(call-process vc-bzr-program nil nil nil "init")))
(call-process vc-bzr-program nil nil nil "add") (call-process vc-bzr-program nil nil nil "add")
(call-process vc-bzr-program nil nil nil "commit" "-m" "Commit 1") (call-process vc-bzr-program nil nil nil "commit" "-m" "Commit 1")
(with-temp-buffer (with-temp-buffer
...@@ -84,7 +85,8 @@ ...@@ -84,7 +85,8 @@
process-environment))) process-environment)))
(unwind-protect (unwind-protect
(progn (progn
(call-process vc-bzr-program nil nil nil "init") (skip-unless (eq 0 ; some internal bzr error
(call-process vc-bzr-program nil nil nil "init")))
(make-directory subdir) (make-directory subdir)
(with-temp-buffer (with-temp-buffer
(insert "text") (insert "text")
......
...@@ -20,29 +20,35 @@ ...@@ -20,29 +20,35 @@
;;; Code: ;;; Code:
(ert-deftest threads-is-one () (ert-deftest threads-is-one ()
"test for existence of a thread" "Test for existence of a thread."
(skip-unless (fboundp 'make-thread))
(should (current-thread))) (should (current-thread)))
(ert-deftest threads-threadp () (ert-deftest threads-threadp ()
"test of threadp" "Test of threadp."
(skip-unless (fboundp 'make-thread))
(should (threadp (current-thread)))) (should (threadp (current-thread))))
(ert-deftest threads-type () (ert-deftest threads-type ()
"test of thread type" "Test of thread type."
(skip-unless (fboundp 'make-thread))
(should (eq (type-of (current-thread)) 'thread))) (should (eq (type-of (current-thread)) 'thread)))
(ert-deftest threads-name () (ert-deftest threads-name ()
"test for name of a thread" "Test for name of a thread."
(skip-unless (fboundp 'make-thread))
(should (should
(string= "hi bob" (thread-name (make-thread #'ignore "hi bob"))))) (string= "hi bob" (thread-name (make-thread #'ignore "hi bob")))))
(ert-deftest threads-alive () (ert-deftest threads-alive ()
"test for thread liveness" "Test for thread liveness."
(skip-unless (fboundp 'make-thread))
(should (should
(thread-alive-p (make-thread #'ignore)))) (thread-alive-p (make-thread #'ignore))))
(ert-deftest threads-all-threads () (ert-deftest threads-all-threads ()
"simple test for all-threads" "Simple test for all-threads."
(skip-unless (fboundp 'make-thread))
(should (listp (all-threads)))) (should (listp (all-threads))))
(defvar threads-test-global nil) (defvar threads-test-global nil)
...@@ -51,7 +57,8 @@ ...@@ -51,7 +57,8 @@
(setq threads-test-global 23)) (setq threads-test-global 23))
(ert-deftest threads-basic () (ert-deftest threads-basic ()
"basic thread test" "Basic thread test."
(skip-unless (fboundp 'make-thread))
(should (should
(progn (progn
(setq threads-test-global nil) (setq threads-test-global nil)
...@@ -61,7 +68,8 @@ ...@@ -61,7 +68,8 @@
threads-test-global))) threads-test-global)))
(ert-deftest threads-join () (ert-deftest threads-join ()
"test of thread-join" "Test of `thread-join'."
(skip-unless (fboundp 'make-thread))
(should (should
(progn (progn
(setq threads-test-global nil) (setq threads-test-global nil)
...@@ -71,7 +79,8 @@ ...@@ -71,7 +79,8 @@
(not (thread-alive-p thread))))))) (not (thread-alive-p thread)))))))
(ert-deftest threads-join-self () (ert-deftest threads-join-self ()
"cannot thread-join the current thread" "Cannot `thread-join' the current thread."
(skip-unless (fboundp 'make-thread))
(should-error (thread-join (current-thread)))) (should-error (thread-join (current-thread))))
(defvar threads-test-binding nil) (defvar threads-test-binding nil)
...@@ -82,7 +91,8 @@ ...@@ -82,7 +91,8 @@
(setq threads-test-global 23)) (setq threads-test-global 23))
(ert-deftest threads-let-binding () (ert-deftest threads-let-binding ()
"simple test of threads and let bindings" "Simple test of threads and let bindings."
(skip-unless (fboundp 'make-thread))
(should (should
(progn (progn
(setq threads-test-global nil) (setq threads-test-global nil)
...@@ -93,19 +103,23 @@ ...@@ -93,19 +103,23 @@
threads-test-global)))) threads-test-global))))
(ert-deftest threads-mutexp () (ert-deftest threads-mutexp ()
"simple test of mutexp" "Simple test of `mutexp'."
(skip-unless (fboundp 'make-thread))
(should-not (mutexp 'hi))) (should-not (mutexp 'hi)))
(ert-deftest threads-mutexp-2 () (ert-deftest threads-mutexp-2 ()
"another simple test of mutexp" "Another simple test of `mutexp'."
(skip-unless (fboundp 'make-thread))
(should (mutexp (make-mutex)))) (should (mutexp (make-mutex))))
(ert-deftest threads-mutex-type () (ert-deftest threads-mutex-type ()
"type-of mutex" "type-of mutex."
(skip-unless (fboundp 'make-thread))
(should (eq (type-of (make-mutex)) 'mutex))) (should (eq (type-of (make-mutex)) 'mutex)))
(ert-deftest threads-mutex-lock-unlock () (ert-deftest threads-mutex-lock-unlock ()
"test mutex-lock and unlock" "Test mutex-lock and unlock."
(skip-unless (fboundp 'make-thread))
(should (should
(let ((mx (make-mutex))) (let ((mx (make-mutex)))
(mutex-lock mx) (mutex-lock mx)
...@@ -113,7 +127,8 @@ ...@@ -113,7 +127,8 @@
t))) t)))
(ert-deftest threads-mutex-recursive () (ert-deftest threads-mutex-recursive ()
"test mutex-lock and unlock" "Test mutex recursion."
(skip-unless (fboundp 'make-thread))
(should (should
(let ((mx (make-mutex))) (let ((mx (make-mutex)))
(mutex-lock mx) (mutex-lock mx)
...@@ -133,7 +148,8 @@ ...@@ -133,7 +148,8 @@
(mutex-unlock threads-mutex)) (mutex-unlock threads-mutex))
(ert-deftest threads-mutex-contention () (ert-deftest threads-mutex-contention ()
"test of mutex contention" "Test of mutex contention."
(skip-unless (fboundp 'make-thread))
(should (should
(progn (progn
(setq threads-mutex (make-mutex)) (setq threads-mutex (make-mutex))
...@@ -153,7 +169,8 @@ ...@@ -153,7 +169,8 @@
(mutex-lock threads-mutex)) (mutex-lock threads-mutex))
(ert-deftest threads-mutex-signal () (ert-deftest threads-mutex-signal ()
"test signaling a blocked thread" "Test signaling a blocked thread."
(skip-unless (fboundp 'make-thread))
(should (should
(progn (progn
(setq threads-mutex (make-mutex)) (setq threads-mutex (make-mutex))
...@@ -170,7 +187,8 @@ ...@@ -170,7 +187,8 @@
(setq threads-test-global 23)) (setq threads-test-global 23))
(ert-deftest threads-io-switch () (ert-deftest threads-io-switch ()
"test that accept-process-output causes thread switch" "Test that `accept-process-output' causes thread switch."
(skip-unless (fboundp 'make-thread))
(should (should
(progn (progn
(setq threads-test-global nil) (setq threads-test-global nil)
...@@ -180,31 +198,37 @@ ...@@ -180,31 +198,37 @@
threads-test-global))) threads-test-global)))
(ert-deftest threads-condvarp () (ert-deftest threads-condvarp ()
"simple test of condition-variable-p" "Simple test of `condition-variable-p'."
(skip-unless (fboundp 'make-thread))
(should-not (condition-variable-p 'hi))) (should-not (condition-variable-p 'hi)))
(ert-deftest threads-condvarp-2 () (ert-deftest threads-condvarp-2 ()
"another simple test of condition-variable-p" "Another simple test of `condition-variable-p'."
(skip-unless (fboundp 'make-thread))
(should (condition-variable-p (make-condition-variable (make-mutex))))) (should (condition-variable-p (make-condition-variable (make-mutex)))))
(ert-deftest threads-condvar-type () (ert-deftest threads-condvar-type ()
"type-of condvar" "type-of condvar"
(skip-unless (fboundp 'make-thread))
(should (eq (type-of (make-condition-variable (make-mutex))) (should (eq (type-of (make-condition-variable (make-mutex)))
'condition-variable))) 'condition-variable)))
(ert-deftest threads-condvar-mutex () (ert-deftest threads-condvar-mutex ()
"simple test of condition-mutex" "Simple test of `condition-mutex'."
(skip-unless (fboundp 'make-thread))
(should (should
(let ((m (make-mutex))) (let ((m (make-mutex)))
(eq m (condition-mutex (make-condition-variable m)))))) (eq m (condition-mutex (make-condition-variable m))))))
(ert-deftest threads-condvar-name () (ert-deftest threads-condvar-name ()
"simple test of condition-name" "Simple test of `condition-name'."
(skip-unless (fboundp 'make-thread))
(should (should
(eq nil (condition-name (make-condition-variable (make-mutex)))))) (eq nil (condition-name (make-condition-variable (make-mutex))))))
(ert-deftest threads-condvar-name-2 () (ert-deftest threads-condvar-name-2 ()
"another simple test of condition-name" "Another simple test of `condition-name'."
(skip-unless (fboundp 'make-thread))
(should (should
(string= "hi bob" (string= "hi bob"
(condition-name (make-condition-variable (make-mutex) (condition-name (make-condition-variable (make-mutex)
...@@ -222,6 +246,7 @@ ...@@ -222,6 +246,7 @@
(ert-deftest thread-errors () (ert-deftest thread-errors ()
"Test what happens when a thread signals an error." "Test what happens when a thread signals an error."
(skip-unless (fboundp 'make-thread))
(let (th1 th2) (let (th1 th2)
(setq th1 (make-thread #'call-error "call-error")) (setq th1 (make-thread #'call-error "call-error"))
(should (threadp th1)) (should (threadp th1))
...@@ -234,6 +259,7 @@ ...@@ -234,6 +259,7 @@
(ert-deftest thread-sticky-point () (ert-deftest thread-sticky-point ()
"Test bug #25165 with point movement in cloned buffer." "Test bug #25165 with point movement in cloned buffer."
(skip-unless (fboundp 'make-thread))
(with-temp-buffer (with-temp-buffer
(insert "Lorem ipsum dolor sit amet, consectetur adipiscing elit.") (insert "Lorem ipsum dolor sit amet, consectetur adipiscing elit.")
(goto-char (point-min)) (goto-char (point-min))
...@@ -244,6 +270,7 @@ ...@@ -244,6 +270,7 @@
(ert-deftest thread-signal-early () (ert-deftest thread-signal-early ()
"Test signaling a thread as soon as it is started by the OS." "Test signaling a thread as soon as it is started by the OS."
(skip-unless (fboundp 'make-thread))
(let ((thread (let ((thread
(make-thread #'(lambda () (make-thread #'(lambda ()
(while t (thread-yield)))))) (while t (thread-yield))))))
...@@ -263,7 +290,8 @@ ...@@ -263,7 +290,8 @@
(condition-wait threads-condvar))) (condition-wait threads-condvar)))
(ert-deftest threads-condvar-wait () (ert-deftest threads-condvar-wait ()
"test waiting on conditional variable" "Test waiting on conditional variable."
(skip-unless (fboundp 'make-thread))
(let ((cv-mutex (make-mutex)) (let ((cv-mutex (make-mutex))
new-thread) new-thread)
;; We could have spurious threads from the previous tests still ;; We could have spurious threads from the previous tests still
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment