aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMattias EngdegÄrd2021-04-09 18:49:16 +0200
committerMattias EngdegÄrd2021-04-09 19:20:55 +0200
commitb7a7e879d02570cbf74aa87686b6b0ed4e6b0c3b (patch)
tree0eaa74f4818c97c413aeb2e66a96d858bf417b9a /test
parenta2a7cfde29aa71f9ea503b8dc467d694f6e5b69f (diff)
downloademacs-b7a7e879d02570cbf74aa87686b6b0ed4e6b0c3b.tar.gz
emacs-b7a7e879d02570cbf74aa87686b6b0ed4e6b0c3b.zip
Better compiler warning tests
These changes allow all bytecomp-tests to be run interactively. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp--with-warning-test) (bytecomp--define-warning-file-test): Interpret any space in the pattern as arbitrary whitespace to tolerate line breaks. Don't abuse the expected-failure mechanism when checking for the expected absense of a warning. (bytecomp/*.el): Rewrite patterns to work with line breaks in the middle.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/emacs-lisp/bytecomp-tests.el49
1 files changed, 25 insertions, 24 deletions
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el
index b1377e59f77..1953878d6f5 100644
--- a/test/lisp/emacs-lisp/bytecomp-tests.el
+++ b/test/lisp/emacs-lisp/bytecomp-tests.el
@@ -569,8 +569,8 @@ byte-compiled. Run with dynamic binding."
569 `(with-current-buffer (get-buffer-create "*Compile-Log*") 569 `(with-current-buffer (get-buffer-create "*Compile-Log*")
570 (let ((inhibit-read-only t)) (erase-buffer)) 570 (let ((inhibit-read-only t)) (erase-buffer))
571 (byte-compile ,@form) 571 (byte-compile ,@form)
572 (ert-info ((buffer-string) :prefix "buffer: ") 572 (ert-info ((prin1-to-string (buffer-string)) :prefix "buffer: ")
573 (should (re-search-forward ,re-warning))))) 573 (should (re-search-forward ,(string-replace " " "[ \n]+" re-warning))))))
574 574
575(ert-deftest bytecomp-warn-wrong-args () 575(ert-deftest bytecomp-warn-wrong-args ()
576 (bytecomp--with-warning-test "remq.*3.*2" 576 (bytecomp--with-warning-test "remq.*3.*2"
@@ -596,12 +596,13 @@ byte-compiled. Run with dynamic binding."
596 596
597(defmacro bytecomp--define-warning-file-test (file re-warning &optional reverse) 597(defmacro bytecomp--define-warning-file-test (file re-warning &optional reverse)
598 `(ert-deftest ,(intern (format "bytecomp/%s" file)) () 598 `(ert-deftest ,(intern (format "bytecomp/%s" file)) ()
599 :expected-result ,(if reverse :failed :passed)
600 (with-current-buffer (get-buffer-create "*Compile-Log*") 599 (with-current-buffer (get-buffer-create "*Compile-Log*")
601 (let ((inhibit-read-only t)) (erase-buffer)) 600 (let ((inhibit-read-only t)) (erase-buffer))
602 (byte-compile-file ,(ert-resource-file file)) 601 (byte-compile-file ,(ert-resource-file file))
603 (ert-info ((buffer-string) :prefix "buffer: ") 602 (ert-info ((buffer-string) :prefix "buffer: ")
604 (should (re-search-forward ,re-warning)))))) 603 (,(if reverse 'should-not 'should)
604 (re-search-forward ,(string-replace " " "[ \n]+" re-warning)
605 nil t))))))
605 606
606(bytecomp--define-warning-file-test "error-lexical-var-with-add-hook.el" 607(bytecomp--define-warning-file-test "error-lexical-var-with-add-hook.el"
607 "add-hook.*lexical var") 608 "add-hook.*lexical var")
@@ -643,10 +644,10 @@ byte-compiled. Run with dynamic binding."
643 "free.*foo") 644 "free.*foo")
644 645
645(bytecomp--define-warning-file-test "warn-free-variable-reference.el" 646(bytecomp--define-warning-file-test "warn-free-variable-reference.el"
646 "free.*bar") 647 "free variable .bar")
647 648
648(bytecomp--define-warning-file-test "warn-make-variable-buffer-local.el" 649(bytecomp--define-warning-file-test "warn-make-variable-buffer-local.el"
649 "make-variable-buffer-local.*not called at toplevel") 650 "make-variable-buffer-local. not called at toplevel")
650 651
651(bytecomp--define-warning-file-test "warn-interactive-only.el" 652(bytecomp--define-warning-file-test "warn-interactive-only.el"
652 "next-line.*interactive use only.*forward-line") 653 "next-line.*interactive use only.*forward-line")
@@ -655,19 +656,19 @@ byte-compiled. Run with dynamic binding."
655 "malformed interactive spec") 656 "malformed interactive spec")
656 657
657(bytecomp--define-warning-file-test "warn-obsolete-defun.el" 658(bytecomp--define-warning-file-test "warn-obsolete-defun.el"
658 "foo-obsolete.*obsolete function.*99.99") 659 "foo-obsolete. is an obsolete function (as of 99.99)")
659 660
660(defvar bytecomp--tests-obsolete-var nil) 661(defvar bytecomp--tests-obsolete-var nil)
661(make-obsolete-variable 'bytecomp--tests-obsolete-var nil "99.99") 662(make-obsolete-variable 'bytecomp--tests-obsolete-var nil "99.99")
662 663
663(bytecomp--define-warning-file-test "warn-obsolete-hook.el" 664(bytecomp--define-warning-file-test "warn-obsolete-hook.el"
664 "bytecomp--tests-obs.*obsolete[^z-a]*99.99") 665 "bytecomp--tests-obsolete-var. is an obsolete variable (as of 99.99)")
665 666
666(bytecomp--define-warning-file-test "warn-obsolete-variable-same-file.el" 667(bytecomp--define-warning-file-test "warn-obsolete-variable-same-file.el"
667 "foo-obs.*obsolete.*99.99" t) 668 "foo-obs.*obsolete.*99.99" t)
668 669
669(bytecomp--define-warning-file-test "warn-obsolete-variable.el" 670(bytecomp--define-warning-file-test "warn-obsolete-variable.el"
670 "bytecomp--tests-obs.*obsolete[^z-a]*99.99") 671 "bytecomp--tests-obsolete-var. is an obsolete variable (as of 99.99)")
671 672
672(bytecomp--define-warning-file-test "warn-obsolete-variable-bound.el" 673(bytecomp--define-warning-file-test "warn-obsolete-variable-bound.el"
673 "bytecomp--tests-obs.*obsolete.*99.99" t) 674 "bytecomp--tests-obs.*obsolete.*99.99" t)
@@ -698,64 +699,64 @@ byte-compiled. Run with dynamic binding."
698 699
699(bytecomp--define-warning-file-test 700(bytecomp--define-warning-file-test
700 "warn-wide-docstring-autoload.el" 701 "warn-wide-docstring-autoload.el"
701 "autoload.*foox.*wider than.*characters") 702 "autoload .foox. docstring wider than .* characters")
702 703
703(bytecomp--define-warning-file-test 704(bytecomp--define-warning-file-test
704 "warn-wide-docstring-custom-declare-variable.el" 705 "warn-wide-docstring-custom-declare-variable.el"
705 "custom-declare-variable.*foo.*wider than.*characters") 706 "custom-declare-variable .foo. docstring wider than .* characters")
706 707
707(bytecomp--define-warning-file-test 708(bytecomp--define-warning-file-test
708 "warn-wide-docstring-defalias.el" 709 "warn-wide-docstring-defalias.el"
709 "defalias.*foo.*wider than.*characters") 710 "defalias .foo. docstring wider than .* characters")
710 711
711(bytecomp--define-warning-file-test 712(bytecomp--define-warning-file-test
712 "warn-wide-docstring-defconst.el" 713 "warn-wide-docstring-defconst.el"
713 "defconst.*foo.*wider than.*characters") 714 "defconst .foo-bar. docstring wider than .* characters")
714 715
715(bytecomp--define-warning-file-test 716(bytecomp--define-warning-file-test
716 "warn-wide-docstring-define-abbrev-table.el" 717 "warn-wide-docstring-define-abbrev-table.el"
717 "define-abbrev.*foo.*wider than.*characters") 718 "define-abbrev-table .foo. docstring wider than .* characters")
718 719
719(bytecomp--define-warning-file-test 720(bytecomp--define-warning-file-test
720 "warn-wide-docstring-define-obsolete-function-alias.el" 721 "warn-wide-docstring-define-obsolete-function-alias.el"
721 "defalias.*foo.*wider than.*characters") 722 "defalias .foo. docstring wider than .* characters")
722 723
723(bytecomp--define-warning-file-test 724(bytecomp--define-warning-file-test
724 "warn-wide-docstring-define-obsolete-variable-alias.el" 725 "warn-wide-docstring-define-obsolete-variable-alias.el"
725 "defvaralias.*foo.*wider than.*characters") 726 "defvaralias .foo. docstring wider than .* characters")
726 727
727;; TODO: We don't yet issue warnings for defuns. 728;; TODO: We don't yet issue warnings for defuns.
728(bytecomp--define-warning-file-test 729(bytecomp--define-warning-file-test
729 "warn-wide-docstring-defun.el" 730 "warn-wide-docstring-defun.el"
730 "wider than.*characters" 'reverse) 731 "wider than .* characters" 'reverse)
731 732
732(bytecomp--define-warning-file-test 733(bytecomp--define-warning-file-test
733 "warn-wide-docstring-defvar.el" 734 "warn-wide-docstring-defvar.el"
734 "defvar.*foo.*wider than.*characters") 735 "defvar .foo-bar. docstring wider than .* characters")
735 736
736(bytecomp--define-warning-file-test 737(bytecomp--define-warning-file-test
737 "warn-wide-docstring-defvaralias.el" 738 "warn-wide-docstring-defvaralias.el"
738 "defvaralias.*foo.*wider than.*characters") 739 "defvaralias .foo-bar. docstring wider than .* characters")
739 740
740(bytecomp--define-warning-file-test 741(bytecomp--define-warning-file-test
741 "warn-wide-docstring-ignore-fill-column.el" 742 "warn-wide-docstring-ignore-fill-column.el"
742 "defvar.*foo.*wider than.*characters" 'reverse) 743 "defvar .foo-bar. docstring wider than .* characters" 'reverse)
743 744
744(bytecomp--define-warning-file-test 745(bytecomp--define-warning-file-test
745 "warn-wide-docstring-ignore-override.el" 746 "warn-wide-docstring-ignore-override.el"
746 "defvar.*foo.*wider than.*characters" 'reverse) 747 "defvar .foo-bar. docstring wider than .* characters" 'reverse)
747 748
748(bytecomp--define-warning-file-test 749(bytecomp--define-warning-file-test
749 "warn-wide-docstring-ignore.el" 750 "warn-wide-docstring-ignore.el"
750 "defvar.*foo.*wider than.*characters" 'reverse) 751 "defvar .foo-bar. docstring wider than .* characters" 'reverse)
751 752
752(bytecomp--define-warning-file-test 753(bytecomp--define-warning-file-test
753 "warn-wide-docstring-multiline-first.el" 754 "warn-wide-docstring-multiline-first.el"
754 "defvar.*foo.*wider than.*characters") 755 "defvar .foo-bar. docstring wider than .* characters")
755 756
756(bytecomp--define-warning-file-test 757(bytecomp--define-warning-file-test
757 "warn-wide-docstring-multiline.el" 758 "warn-wide-docstring-multiline.el"
758 "defvar.*foo.*wider than.*characters") 759 "defvar .foo-bar. docstring wider than .* characters")
759 760
760(bytecomp--define-warning-file-test 761(bytecomp--define-warning-file-test
761 "nowarn-inline-after-defvar.el" 762 "nowarn-inline-after-defvar.el"