unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#36568: with-suppress-warnings not working in seq-tests.el
@ 2019-07-10  3:23 Stefan Kangas
  2019-07-10  3:42 ` Stefan Kangas
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Stefan Kangas @ 2019-07-10  3:23 UTC (permalink / raw)
  To: 36568

[-- Attachment #1: Type: text/plain, Size: 1240 bytes --]

On current master, I'm seeing strange behaviour when trying to
suppress warnings in the test suite using with-suppressed-warnings.

(See also related bug Bug#36567 -- not sure if it's a duplicate.
Please merge if it is.)

Steps to reproduce:
0. Apply attached patch bug-suppressed-warnings.diff
1. Open shell
2. cd emacs/test
3. rm lisp/emacs-lisp/seq-tests.elc
4. make lisp/emacs-lisp/seq-tests

Result:
  ELC      lisp/emacs-lisp/seq-tests.elc

In toplevel form:
lisp/emacs-lisp/seq-tests.el:183:20:Warning: `seq-contains' is an obsolete
    function (as of 27.1); use `seq-contains-p' instead.
lisp/emacs-lisp/seq-tests.el:183:20:Warning: `seq-contains' is an obsolete
    function (as of 27.1); use `seq-contains-p' instead.
lisp/emacs-lisp/seq-tests.el:183:20:Warning: `seq-contains' is an obsolete
    function (as of 27.1); use `seq-contains-p' instead.
[...]

Expected result:
No such warnings appear.


In GNU Emacs 27.0.50 (build 2, x86_64-apple-darwin15.6.0, NS
appkit-1404.47 Version 10.11.6 (Build 15G22010))
 of 2019-07-10 built on Stefans-MBP
Repository revision: 77cf71ce8cc611ecfd143277441e2ad4acc9401b
Repository branch: master
Windowing system distributor 'Apple', version 10.3.1404
System Description:  Mac OS X 10.11.6

[-- Attachment #2: bug-suppressed-warnings.diff --]
[-- Type: application/octet-stream, Size: 1221 bytes --]

diff --git a/test/lisp/emacs-lisp/seq-tests.el b/test/lisp/emacs-lisp/seq-tests.el
index ef05e2b389..35fa2b1916 100644
--- a/test/lisp/emacs-lisp/seq-tests.el
+++ b/test/lisp/emacs-lisp/seq-tests.el
@@ -174,16 +174,18 @@ test-seq-find
   (should (seq-find #'null '(1 2 3) 'sentinel)))
 
 (ert-deftest test-seq-contains ()
-  (with-test-sequences (seq '(3 4 5 6))
-    (should (seq-contains seq 3))
-    (should-not (seq-contains seq 7)))
-  (with-test-sequences (seq '())
-    (should-not (seq-contains seq 3))
-    (should-not (seq-contains seq nil))))
+  (with-suppressed-warnings ((obsolete seq-contains))
+    (with-test-sequences (seq '(3 4 5 6))
+      (should (seq-contains seq 3))
+      (should-not (seq-contains seq 7)))
+    (with-test-sequences (seq '())
+      (should-not (seq-contains seq 3))
+      (should-not (seq-contains seq nil)))))
 
 (ert-deftest test-seq-contains-should-return-the-elt ()
-  (with-test-sequences (seq '(3 4 5 6))
-    (should (= 5 (seq-contains seq 5)))))
+  (with-suppressed-warnings ((obsolete seq-contains))
+    (with-test-sequences (seq '(3 4 5 6))
+      (should (= 5 (seq-contains seq 5))))))
 
 (ert-deftest test-seq-contains-p ()
   (with-test-sequences (seq '(3 4 5 6))

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#36568: with-suppress-warnings not working in seq-tests.el
  2019-07-10  3:23 bug#36568: with-suppress-warnings not working in seq-tests.el Stefan Kangas
@ 2019-07-10  3:42 ` Stefan Kangas
  2020-08-22 14:14 ` Lars Ingebrigtsen
  2021-12-05  3:22 ` Lars Ingebrigtsen
  2 siblings, 0 replies; 8+ messages in thread
From: Stefan Kangas @ 2019-07-10  3:42 UTC (permalink / raw)
  To: 36568

You could also use the patch in Bug#36565 to test this, I think.  That
is broken for what superficially looks like similar reasons.

Thanks,
Stefan Kangas





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#36568: with-suppress-warnings not working in seq-tests.el
  2019-07-10  3:23 bug#36568: with-suppress-warnings not working in seq-tests.el Stefan Kangas
  2019-07-10  3:42 ` Stefan Kangas
@ 2020-08-22 14:14 ` Lars Ingebrigtsen
  2020-10-07  4:57   ` Lars Ingebrigtsen
  2021-12-05  3:22 ` Lars Ingebrigtsen
  2 siblings, 1 reply; 8+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-22 14:14 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 36568, Stefan Monnier

Stefan Kangas <stefan@marxist.se> writes:

> On current master, I'm seeing strange behaviour when trying to
> suppress warnings in the test suite using with-suppressed-warnings.

[...]

> In toplevel form:
> lisp/emacs-lisp/seq-tests.el:183:20:Warning: `seq-contains' is an obsolete
>     function (as of 27.1); use `seq-contains-p' instead.

Odd.  To reproduce, I tried to just do:

(require 'seq)

(defun foo ()
  (with-suppressed-warnings ((obsolete seq-contains))
    (seq-contains '(3 4 5 6) 3)))

But the warning is suppressed correctly then.  So there's ... something
in the way the test files are compile that breaks
with-suppressed-warnings?  Something in the ert macros?  Anybody got any
ideas?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#36568: with-suppress-warnings not working in seq-tests.el
  2020-08-22 14:14 ` Lars Ingebrigtsen
@ 2020-10-07  4:57   ` Lars Ingebrigtsen
  2020-10-07  5:18     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 8+ messages in thread
From: Lars Ingebrigtsen @ 2020-10-07  4:57 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 36568, Stefan Monnier

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Odd.  To reproduce, I tried to just do:
>
> (require 'seq)
>
> (defun foo ()
>   (with-suppressed-warnings ((obsolete seq-contains))
>     (seq-contains '(3 4 5 6) 3)))
>
> But the warning is suppressed correctly then.  So there's ... something
> in the way the test files are compile that breaks
> with-suppressed-warnings?  Something in the ert macros?  Anybody got any
> ideas?

I poked around a bit more, and wondered whether the suppression would
survive if I pushed it as close to the function as possible:

(ert-deftest test-seq-contains-should-return-the-elt ()
  (should (= 5 (with-suppressed-warnings ((obsolete seq-contains))
                 (seq-contains '(1 2 3 4 5) 5)))))

But this leads to:

Debugger entered--Lisp error: (void-function internal--with-suppressed-warnings)
  signal(void-function (internal--with-suppressed-warnings))
  apply(signal (void-function (internal--with-suppressed-warnings)))
  (setq value-2846 (apply fn-2844 args-2845))
  (unwind-protect (setq value-2846 (apply fn-2844 args-2845)) (setq form-description-2848 (nconc (list '(should (= 5 (with-suppressed-warnings ... ...)))) (list :form (cons fn-2844 args-2845)) (if (eql value-2846 'ert-form-evaluation-aborted-2847) nil (list :value value-2846)) (let ((-explainer- (and (symbolp ...) (get ... ...)))) (if -explainer- (progn (list :explanation (apply -explainer- args-2845))))))) (ert--signal-should-execution form-description-2848))
  (if (unwind-protect (setq value-2846 (apply fn-2844 args-2845)) (setq form-description-2848 (nconc (list '(should (= 5 ...))) (list :form (cons fn-2844 args-2845)) (if (eql value-2846 'ert-form-evaluation-aborted-2847) nil (list :value value-2846)) (let ((-explainer- (and ... ...))) (if -explainer- (progn (list :explanation ...)))))) (ert--signal-should-execution form-description-2848)) nil (ert-fail form-description-2848))
  (let (form-description-2848) (if (unwind-protect (setq value-2846 (apply fn-2844 args-2845)) (setq form-description-2848 (nconc (list '(should ...)) (list :form (cons fn-2844 args-2845)) (if (eql value-2846 'ert-form-evaluation-aborted-2847) nil (list :value value-2846)) (let ((-explainer- ...)) (if -explainer- (progn ...))))) (ert--signal-should-execution form-description-2848)) nil (ert-fail form-description-2848)))
  (let ((value-2846 'ert-form-evaluation-aborted-2847)) (let (form-description-2848) (if (unwind-protect (setq value-2846 (apply fn-2844 args-2845)) (setq form-description-2848 (nconc (list '...) (list :form (cons fn-2844 args-2845)) (if (eql value-2846 ...) nil (list :value value-2846)) (let (...) (if -explainer- ...)))) (ert--signal-should-execution form-description-2848)) nil (ert-fail form-description-2848))) value-2846)
  (let* ((fn-2844 #'=) (args-2845 (condition-case err (let ((signal-hook-function #'ert--should-signal-hook)) (list 5 (internal--with-suppressed-warnings '... (progn ...)))) (error (progn (setq fn-2844 #'signal) (list (car err) (cdr err))))))) (let ((value-2846 'ert-form-evaluation-aborted-2847)) (let (form-description-2848) (if (unwind-protect (setq value-2846 (apply fn-2844 args-2845)) (setq form-description-2848 (nconc (list ...) (list :form ...) (if ... nil ...) (let ... ...))) (ert--signal-should-execution form-description-2848)) nil (ert-fail form-description-2848))) value-2846))
  (progn (let* ((fn-2844 #'=) (args-2845 (condition-case err (let ((signal-hook-function ...)) (list 5 (internal--with-suppressed-warnings ... ...))) (error (progn (setq fn-2844 ...) (list ... ...)))))) (let ((value-2846 'ert-form-evaluation-aborted-2847)) (let (form-description-2848) (if (unwind-protect (setq value-2846 (apply fn-2844 args-2845)) (setq form-description-2848 (nconc ... ... ... ...)) (ert--signal-should-execution form-description-2848)) nil (ert-fail form-description-2848))) value-2846)))
  eval((progn (let* ((fn-2844 #'=) (args-2845 (condition-case err (let (...) (list 5 ...)) (error (progn ... ...))))) (let ((value-2846 'ert-form-evaluation-aborted-2847)) (let (form-description-2848) (if (unwind-protect (setq value-2846 ...) (setq form-description-2848 ...) (ert--signal-should-execution form-description-2848)) nil (ert-fail form-description-2848))) value-2846))) t)
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#36568: with-suppress-warnings not working in seq-tests.el
  2020-10-07  4:57   ` Lars Ingebrigtsen
@ 2020-10-07  5:18     ` Lars Ingebrigtsen
  2020-10-07  5:35       ` Michael Heerdegen
  0 siblings, 1 reply; 8+ messages in thread
From: Lars Ingebrigtsen @ 2020-10-07  5:18 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 36568, Stefan Monnier

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Debugger entered--Lisp error: (void-function internal--with-suppressed-warnings)
>   signal(void-function (internal--with-suppressed-warnings))
>   apply(signal (void-function (internal--with-suppressed-warnings)))

Ah, this is due to

(defvar byte-compile-initial-macro-environment
...
    (with-suppressed-warnings
        . ,(lambda (warnings &rest body)
             ;; We let-bind `byte-compile--suppressed-warnings' here in order
             ;; to affect warnings emitted during macroexpansion.
             ;; Later `internal--with-suppressed-warnings' binds it again, this
             ;; time in order to affect warnings emitted during the
             ;; compilation itself.
             (let ((byte-compile--suppressed-warnings
                    (append warnings byte-compile--suppressed-warnings)))
               ;; This function doesn't exist, but is just a placeholder
               ;; symbol to hook up with the
               ;; `byte-hunk-handler'/`byte-defop-compiler-1' machinery.
               `(internal--with-suppressed-warnings
                 ',warnings
                 ,(macroexpand-all `(progn ,@body)
                                   macroexpand-all-environment))))))


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#36568: with-suppress-warnings not working in seq-tests.el
  2020-10-07  5:18     ` Lars Ingebrigtsen
@ 2020-10-07  5:35       ` Michael Heerdegen
  0 siblings, 0 replies; 8+ messages in thread
From: Michael Heerdegen @ 2020-10-07  5:35 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Stefan Kangas, 36568, Stefan Monnier

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Lars Ingebrigtsen <larsi@gnus.org> writes:
>
> > Debugger entered--Lisp error: (void-function internal--with-suppressed-warnings)
> >   signal(void-function (internal--with-suppressed-warnings))
> >   apply(signal (void-function (internal--with-suppressed-warnings)))
>
> Ah, this is due to
>
> (defvar byte-compile-initial-macro-environment

Yes, I have found `ert--expand-should-1' where the macroexpansion is
performed and came to the same conclusion.  This function already has a
FIXME on its top ;-)

Michael.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#36568: with-suppress-warnings not working in seq-tests.el
  2019-07-10  3:23 bug#36568: with-suppress-warnings not working in seq-tests.el Stefan Kangas
  2019-07-10  3:42 ` Stefan Kangas
  2020-08-22 14:14 ` Lars Ingebrigtsen
@ 2021-12-05  3:22 ` Lars Ingebrigtsen
  2021-12-05 11:27   ` Stefan Kangas
  2 siblings, 1 reply; 8+ messages in thread
From: Lars Ingebrigtsen @ 2021-12-05  3:22 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 36568

Stefan Kangas <stefan@marxist.se> writes:

> On current master, I'm seeing strange behaviour when trying to
> suppress warnings in the test suite using with-suppressed-warnings.
>
> (See also related bug Bug#36567 -- not sure if it's a duplicate.
> Please merge if it is.)
>
> Steps to reproduce:
> 0. Apply attached patch bug-suppressed-warnings.diff
> 1. Open shell
> 2. cd emacs/test
> 3. rm lisp/emacs-lisp/seq-tests.elc
> 4. make lisp/emacs-lisp/seq-tests
>
> Result:
>   ELC      lisp/emacs-lisp/seq-tests.elc
>
> In toplevel form:
> lisp/emacs-lisp/seq-tests.el:183:20:Warning: `seq-contains' is an obsolete
>     function (as of 27.1); use `seq-contains-p' instead.

Looks like this has been fixed (perhaps by that recent change to
macroexp/warning suppression?)  So I've now removed the workaround from
seq-tests.el, and I'm not seeing any warnings, and I'm therefore closing
this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#36568: with-suppress-warnings not working in seq-tests.el
  2021-12-05  3:22 ` Lars Ingebrigtsen
@ 2021-12-05 11:27   ` Stefan Kangas
  0 siblings, 0 replies; 8+ messages in thread
From: Stefan Kangas @ 2021-12-05 11:27 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 36568

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Looks like this has been fixed (perhaps by that recent change to
> macroexp/warning suppression?)  So I've now removed the workaround from
> seq-tests.el, and I'm not seeing any warnings, and I'm therefore closing
> this bug report.

Aha, that's good.  I removed two similar hacks, and the warnings are
indeed gone in those cases as well.





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-12-05 11:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-10  3:23 bug#36568: with-suppress-warnings not working in seq-tests.el Stefan Kangas
2019-07-10  3:42 ` Stefan Kangas
2020-08-22 14:14 ` Lars Ingebrigtsen
2020-10-07  4:57   ` Lars Ingebrigtsen
2020-10-07  5:18     ` Lars Ingebrigtsen
2020-10-07  5:35       ` Michael Heerdegen
2021-12-05  3:22 ` Lars Ingebrigtsen
2021-12-05 11:27   ` Stefan Kangas

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).