APPROVE COMMIT 21.5
Several of the tests call functions that produce messages concerning
marks being set or text inserted.  This patch introduces a macro
Silence-Message for use in the test suite to suppress such output, and
uses it in several places.
Index: tests/ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/tests/ChangeLog,v
retrieving revision 1.81
diff -u -r1.81 ChangeLog
--- tests/ChangeLog	24 Jun 2006 13:50:19 -0000	1.81
+++ tests/ChangeLog	24 Jun 2006 13:54:47 -0000
@@ -0,0 +1,7 @@
+2006-06-24  Stephen J. Turnbull  <stephen(a)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.
+
Index: tests/automated/mule-tests.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/tests/automated/mule-tests.el,v
retrieving revision 1.9
diff -u -r1.9 mule-tests.el
--- tests/automated/mule-tests.el	3 Jun 2006 17:51:06 -0000	1.9
+++ tests/automated/mule-tests.el	24 Jun 2006 13:54:47 -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...
 
Index: tests/automated/region-tests.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/tests/automated/region-tests.el,v
retrieving revision 1.1
diff -u -r1.1 region-tests.el
--- tests/automated/region-tests.el	24 Feb 2005 23:02:37 -0000	1.1
+++ tests/automated/region-tests.el	24 Jun 2006 13:54:47 -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
Index: tests/automated/tag-tests.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/tests/automated/tag-tests.el,v
retrieving revision 1.3
diff -u -r1.3 tag-tests.el
--- tests/automated/tag-tests.el	13 May 2004 16:41:27 -0000	1.3
+++ tests/automated/tag-tests.el	24 Jun 2006 13:54:47 -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)))
 
Index: tests/automated/test-harness.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/tests/automated/test-harness.el,v
retrieving revision 1.21
diff -u -r1.21 test-harness.el
--- tests/automated/test-harness.el	24 Jun 2006 13:50:23 -0000	1.21
+++ tests/automated/test-harness.el	24 Jun 2006 13:54:47 -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"
@@ -322,6 +330,10 @@
 				 ,quoted-body error-info)
 		  (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))
-- 
Graduate School of Systems and Information Engineering   University of Tsukuba
http://turnbull.sk.tsukuba.ac.jp/        Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
        Economics of Information Communication and Computation Systems
          Experimental Economics, Microeconomic Theory, Game Theory