emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/auctex e195604 04/15: Reduce code duplication in tests


From: Tassilo Horn
Subject: [elpa] externals/auctex e195604 04/15: Reduce code duplication in tests
Date: Wed, 6 Dec 2017 09:48:33 -0500 (EST)

branch: externals/auctex
commit e19560472b06c2d0ae37e07cb3f5e0b9ab403162
Author: Mosè Giordano <address@hidden>
Commit: Mosè Giordano <address@hidden>

    Reduce code duplication in tests
    
    * tests/make-test-deps.emacs-lisp: New file.
    * tests/Makefile (%.log): Load it make-test-deps.emacs-lisp when running 
tests.
    * tests/context/context-test.el:
    * tests/japanese/error-parsing.el:
    * tests/japanese/parse-timing.el:
    * tests/japanese/preview-latex.el:
    * tests/latex/latex-test.el:
    * tests/tex/error-parsing.el:
    * tests/tex/path-expansion.el:
    * tests/tex/utility.el: Remove code moved to make-test-deps.emacs-lisp.
---
 tests/Makefile                                     |  3 +-
 tests/context/context-test.el                      | 12 -------
 tests/japanese/error-parsing.el                    |  7 ----
 tests/japanese/parse-timing.el                     | 18 -----------
 tests/japanese/preview-latex.el                    | 19 -----------
 tests/latex/latex-test.el                          | 19 -----------
 .../context-test.el => make-test-deps.emacs-lisp}  | 37 +++++++++-------------
 tests/tex/error-parsing.el                         | 12 -------
 tests/tex/path-expansion.el                        |  1 -
 tests/tex/utility.el                               |  1 -
 10 files changed, 17 insertions(+), 112 deletions(-)

diff --git a/tests/Makefile b/tests/Makefile
index 208ab72..db62b30 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -55,7 +55,8 @@ all: check
 WRITE_LOG = 2>&1 | tee $@
 
 %.log: %.el
-       $(emacs) -l ert -l $< -f ert-run-tests-batch-and-exit ${WRITE_LOG}
+       $(emacs) -l ert -l make-test-deps.emacs-lisp -l $< \
+       -f ert-run-tests-batch-and-exit ${WRITE_LOG}
 
 ELFILES = $(wildcard */*.el)
 LOGFILES = $(patsubst %.el,%.log, ${ELFILES})
diff --git a/tests/context/context-test.el b/tests/context/context-test.el
index 05647e4..1fcc999 100644
--- a/tests/context/context-test.el
+++ b/tests/context/context-test.el
@@ -24,18 +24,6 @@
 (require 'ert)
 (require 'context)
 
-(defun AUCTeX-set-ert-path (&rest sym-val)
-  "Set first element of SYM-VAL to the next one, and so on.
-
-The value is the path to the test file, make sure it is expanded
-in the right directory even when the ERT test from the command
-line and from another directory."
-  (while sym-val
-    (set (pop sym-val)
-        (expand-file-name (pop sym-val)
-                          (when load-file-name
-                            (file-name-directory load-file-name))))))
-
 (AUCTeX-set-ert-path
  'ConTeXt-indent-test/in
  "context-indentation-in.tex"
diff --git a/tests/japanese/error-parsing.el b/tests/japanese/error-parsing.el
index 571e0a6..c2f8f90 100644
--- a/tests/japanese/error-parsing.el
+++ b/tests/japanese/error-parsing.el
@@ -26,13 +26,6 @@
 (setq japanese-TeX-error-messages t)
 (require 'tex-jp)
 
-;; Add the "style/" directory to `TeX-style-path',
-;; so we can load style files inside tests.
-(add-to-list 'TeX-style-path
-             (expand-file-name "../../style"
-                               (when load-file-name
-                                 (file-name-directory load-file-name))))
-
 (ert-deftest japanese-TeX-help-message ()
   "Test the fallback behavior of `TeX-help-error'.
 It should pick up error messages from the log file even if
diff --git a/tests/japanese/parse-timing.el b/tests/japanese/parse-timing.el
index 800428a..1c49eb7 100644
--- a/tests/japanese/parse-timing.el
+++ b/tests/japanese/parse-timing.el
@@ -33,24 +33,6 @@
 (require 'ert)
 (require 'tex-jp)
 
-;; Add the "style/" directory to `TeX-style-path',
-;; so we can load style files inside tests.
-(add-to-list 'TeX-style-path
-             (expand-file-name "../../style"
-                               (when load-file-name
-                                 (file-name-directory load-file-name))))
-
-(defun AUCTeX-set-ert-path (&rest sym-val)
-  "Set first element of SYM-VAL to the next one, and so on.
-
-The value is the path to the test file, make sure it is expanded
-in the right directory even when the ERT test from the command
-line and from another directory."
-  (while sym-val
-    (set (pop sym-val)
-        (expand-file-name (pop sym-val)
-                          (when load-file-name
-                            (file-name-directory load-file-name))))))
 (AUCTeX-set-ert-path
  'parse-timing
  "parse-timing-test.tex")
diff --git a/tests/japanese/preview-latex.el b/tests/japanese/preview-latex.el
index 5885456..44697d6 100644
--- a/tests/japanese/preview-latex.el
+++ b/tests/japanese/preview-latex.el
@@ -26,25 +26,6 @@
   (require 'tex-jp))
 (require 'preview)
 
-;; Add the "style/" directory to `TeX-style-path',
-;; so we can load style files inside tests.
-(add-to-list 'TeX-style-path
-             (expand-file-name "../../style"
-                               (when load-file-name
-                                 (file-name-directory load-file-name))))
-
-(defun AUCTeX-set-ert-path (&rest sym-val)
-  "Set first element of SYM-VAL to the next one, and so on.
-
-The value is the path to the test file, make sure it is expanded
-in the right directory even when the ERT test from the command
-line and from another directory."
-  (while sym-val
-    (set (pop sym-val)
-        (expand-file-name (pop sym-val)
-                          (when load-file-name
-                            (file-name-directory load-file-name))))))
-
 (AUCTeX-set-ert-path
  'platex-shift-jis
  "preview-error-test.tex"
diff --git a/tests/latex/latex-test.el b/tests/latex/latex-test.el
index a53d48e..a2dc565 100644
--- a/tests/latex/latex-test.el
+++ b/tests/latex/latex-test.el
@@ -24,25 +24,6 @@
 (require 'ert)
 (require 'latex)
 
-;; Add the "style/" directory to `TeX-style-path',
-;; so we can load style files inside tests.
-(add-to-list 'TeX-style-path
-            (expand-file-name "../../style"
-                              (when load-file-name
-                                (file-name-directory load-file-name))))
-
-(defun AUCTeX-set-ert-path (&rest sym-val)
-  "Set first element of SYM-VAL to the next one, and so on.
-
-The value is the path to the test file, make sure it is expanded
-in the right directory even when the ERT test from the command
-line and from another directory."
-  (while sym-val
-    (set (pop sym-val)
-        (expand-file-name (pop sym-val)
-                          (when load-file-name
-                            (file-name-directory load-file-name))))))
-
 (AUCTeX-set-ert-path
  'LaTeX-indent-tabular-test/in
  "tabular-in.tex"
diff --git a/tests/context/context-test.el b/tests/make-test-deps.emacs-lisp
similarity index 66%
copy from tests/context/context-test.el
copy to tests/make-test-deps.emacs-lisp
index 05647e4..17a88f4 100644
--- a/tests/context/context-test.el
+++ b/tests/make-test-deps.emacs-lisp
@@ -1,4 +1,4 @@
-;;; context-test.el --- tests for ConTeXt mode
+;; -*- emacs-lisp -*-
 
 ;; Copyright (C) 2017 Free Software Foundation, Inc.
 
@@ -19,10 +19,22 @@
 ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 ;; 02110-1301, USA.
 
+;;; Commentary:
+
+;; This file provides some functions and .
+
+;; It has an .emacs-lisp extension because it makes the Makefile easier!
+
 ;;; Code:
 
-(require 'ert)
-(require 'context)
+(require 'tex)
+
+;; Add the "style/" directory to `TeX-style-path',
+;; so we can load style files inside tests.
+(add-to-list 'TeX-style-path
+            (expand-file-name "../style"
+                              (when load-file-name
+                                (file-name-directory load-file-name))))
 
 (defun AUCTeX-set-ert-path (&rest sym-val)
   "Set first element of SYM-VAL to the next one, and so on.
@@ -35,22 +47,3 @@ line and from another directory."
         (expand-file-name (pop sym-val)
                           (when load-file-name
                             (file-name-directory load-file-name))))))
-
-(AUCTeX-set-ert-path
- 'ConTeXt-indent-test/in
- "context-indentation-in.tex"
- 'ConTeXt-indent-test/out
- "context-indentation-out.tex")
-
-(ert-deftest ConTeXt-indent ()
-  (should (string=
-           (with-temp-buffer
-             (insert-file-contents ConTeXt-indent-test/in)
-             (ConTeXt-mode)
-             (indent-region (point-min) (point-max))
-             (buffer-string))
-           (with-temp-buffer
-             (insert-file-contents ConTeXt-indent-test/out)
-             (buffer-string)))))
-
-;;; context-test.el ends here
diff --git a/tests/tex/error-parsing.el b/tests/tex/error-parsing.el
index 3da46c1..f9df789 100644
--- a/tests/tex/error-parsing.el
+++ b/tests/tex/error-parsing.el
@@ -24,18 +24,6 @@
 (require 'ert)
 (require 'tex-buf)
 
-(defun AUCTeX-set-ert-path (&rest sym-val)
-  "Set first element of SYM-VAL to the next one, and so on.
-
-The value is the path to the test file, make sure it is expanded
-in the right directory even when the ERT test is run from the
-command line and from another directory."
-  (while sym-val
-    (set (pop sym-val)
-        (expand-file-name (pop sym-val)
-                          (when load-file-name
-                            (file-name-directory load-file-name))))))
-
 (AUCTeX-set-ert-path
  'TeX-test-compilation-log
  "compilation-log.txt")
diff --git a/tests/tex/path-expansion.el b/tests/tex/path-expansion.el
index 4b9b5c0..3a1d72e 100644
--- a/tests/tex/path-expansion.el
+++ b/tests/tex/path-expansion.el
@@ -22,7 +22,6 @@
 ;;; Code:
 
 (require 'ert)
-(require 'tex)
 
 (ert-deftest TeX-variable-truncation ()
   "Check whether list variable is not truncated as side effect."
diff --git a/tests/tex/utility.el b/tests/tex/utility.el
index 843bd57..92442ba 100644
--- a/tests/tex/utility.el
+++ b/tests/tex/utility.el
@@ -22,7 +22,6 @@
 ;;; Code:
 
 (require 'ert)
-(require 'tex)
 
 (ert-deftest TeX-infinite-loop ()
   "Check whether functions don't fall into infinite loop."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]