changeset 3472:43b4a54fbf66

[xemacs-hg @ 2006-06-24 14:30:36 by stephent] Silence commands that set marks etc in test suite. <87wtb67hm2.fsf@tleepslib.sk.tsukuba.ac.jp>
author stephent
date Sat, 24 Jun 2006 14:30:39 +0000
parents 3b1f8220a65e
children 5938ccee377f
files tests/ChangeLog tests/automated/mule-tests.el tests/automated/region-tests.el tests/automated/tag-tests.el tests/automated/test-harness.el
diffstat 5 files changed, 45 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/tests/ChangeLog	Sat Jun 24 13:50:23 2006 +0000
+++ b/tests/ChangeLog	Sat Jun 24 14:30:39 2006 +0000
@@ -1,3 +1,10 @@
+2006-06-24  Stephen J. Turnbull  <stephen@xemacs.org>
+
+	* automated/test-harness.el (Silence-Message): New macro.
+	* automated/mule-tests.el: Use it.
+	* automated/region-tests.el: Use it.
+	* automated/tag-tests.el: Use it.
+
 2006-06-24  Stephen J. Turnbull  <stephen@xemacs.org>
 
 	* automated/test-harness.el: Improve handling of unexpected errors.
--- a/tests/automated/mule-tests.el	Sat Jun 24 13:50:23 2006 +0000
+++ b/tests/automated/mule-tests.el	Sat Jun 24 14:30:39 2006 +0000
@@ -340,18 +340,18 @@
 	    'iso-8859-2))
 	 )
     ;; This is how you suppress output from `message', called by `write-region'
-    (flet ((append-message (&rest args) ()))
-      (Assert (not (equal name1 name2)))
-      (Assert (not (file-exists-p name1)))
-      (write-region (point-min) (point-max) name1)
-      (Assert (file-exists-p name1))
-      (when (fboundp 'make-symbolic-link)
-	(make-symbolic-link name1 name2)
-	(Assert (file-exists-p name2))
-	(Assert (equal (file-truename name2) name1))
-	(Assert (equal (file-truename name1) name1)))
+    (Assert (not (equal name1 name2)))
+    (Assert (not (file-exists-p name1)))
+    (Silence-Message
+     (write-region (point-min) (point-max) name1))
+    (Assert (file-exists-p name1))
+    (when (fboundp 'make-symbolic-link)
+      (make-symbolic-link name1 name2)
+      (Assert (file-exists-p name2))
+      (Assert (equal (file-truename name2) name1))
+      (Assert (equal (file-truename name1) name1)))
 
-      (ignore-file-errors (delete-file name1) (delete-file name2))))
+      (ignore-file-errors (delete-file name1) (delete-file name2)))
 
   ;; Add many more file operation tests here...
 
--- a/tests/automated/region-tests.el	Sat Jun 24 13:50:23 2006 +0000
+++ b/tests/automated/region-tests.el	Sat Jun 24 14:30:39 2006 +0000
@@ -43,10 +43,12 @@
   ;; Using active regions
   (let ((zmacs-regions t)
         (first-buffer (current-buffer)))
-    (insert (buffer-name))
+    (Silence-Message
+     (insert (buffer-name)))
     (Assert (not (region-exists-p)))
     (Assert (not (region-active-p)))
-    (mark-whole-buffer)
+    (Silence-Message
+     (mark-whole-buffer))
     (Assert (region-exists-p))
     (Assert (region-active-p))
     ;; Turn off active regions
@@ -62,7 +64,8 @@
     ;; Region is active again
     (Assert (region-active-p))
     (with-temp-buffer
-      (insert (buffer-name))
+      (Silence-Message
+       (insert (buffer-name)))
       ;; Region exists in first buffer, not this second one
       (Assert (not (region-exists-p)))
       ;; Region not active in this second temp buffer
@@ -70,7 +73,8 @@
       ;; Region still active in first temp buffer
       (Assert (eq (zmacs-region-buffer) first-buffer))
       ;; Activate region in second temp buffer
-      (mark-whole-buffer)
+      (Silence-Message
+       (mark-whole-buffer))
       ;; Region exists in second temp buffer
       (Assert (region-exists-p))
       ;; Region active in second temp buffer
--- a/tests/automated/tag-tests.el	Sat Jun 24 13:50:23 2006 +0000
+++ b/tests/automated/tag-tests.el	Sat Jun 24 14:30:39 2006 +0000
@@ -68,20 +68,23 @@
   (let ((tags-always-exact t))
 
     ;; Search for the tag "mystruct"; this should succeed
-    (find-tag "mystruct")
+    (Silence-Message
+     (find-tag "mystruct"))
     (Assert (eq (point) 2))
 
     ;; Search again.  The search should fail, based on the patch that
     ;; Sven Grundmann submitted for 21.4.16.
     (Check-Error-Message error "No more entries matching mystruct"
-			 (tags-loop-continue)))
+			 (Silence-Message
+			  (tags-loop-continue))))
 
   (let ((tags-always-exact nil))
 
     ;; Search for the definition of "require". Until the etags.el upgrade
     ;; from 21.5 in 21.4.16, this test would fail.
     (condition-case nil
-	(find-tag "require")
+	(Silence-Message
+	 (find-tag "require"))
       (t t))
     (Assert (eq (point) 52)))
 
--- a/tests/automated/test-harness.el	Sat Jun 24 13:50:23 2006 +0000
+++ b/tests/automated/test-harness.el	Sat Jun 24 14:30:39 2006 +0000
@@ -38,6 +38,14 @@
 ;;; Implementation-Incomplete-Expect-Failure wrapper macros to mark them.
 ;;; A lot of the tests we run push limits; suppress Ebola message with the
 ;;; Ignore-Ebola wrapper macro.
+;;; Some noisy code will call `message'.  Output from `message' can be
+;;; suppressed with the Silence-Message macro.  Functions that are known to
+;;; issue messages include `write-region', `find-tag', `tag-loop-continue',
+;;; `insert', and `mark-whole-buffer'.  N.B. The Silence-Message macro
+;;; currently does not suppress the newlines printed by `message'.
+;;; Definitely do not use Silence-Message with Check-Message.
+;;; In general it should probably only be used on code that prepares for a
+;;; test, not on tests.
 ;;; 
 ;;; You run the tests using M-x test-emacs-test-file,
 ;;; or $(EMACS) -batch -l .../test-harness.el -f batch-test-emacs file ...
@@ -291,7 +299,7 @@
 			     ,quoted-body ',expected-error error-info)
 	      (incf wrong-error-failures)))))
 
-
+      ;; Do not use this with Silence-Message.
       (defmacro Check-Message (expected-message-regexp &rest body)
 	(Skip-Test-Unless (fboundp 'defadvice)
 			  "can't defadvice"
@@ -323,6 +331,10 @@
 		  (incf other-failures)))
 	       (ad-unadvise 'message)))))
 
+      ;; #### Perhaps this should override `message' itself, too?
+      (defmacro Silence-Message (&rest body)
+	`(flet ((append-message (&rest args) ())) ,@body))
+
       (defmacro Ignore-Ebola (&rest body)
 	`(let ((debug-issue-ebola-notices -42)) ,@body))