[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] scratch/editorconfig 4444fc9a90: Misc changes accrued while try
From: |
Stefan Monnier |
Subject: |
[nongnu] scratch/editorconfig 4444fc9a90: Misc changes accrued while trying to run the tests |
Date: |
Mon, 10 Jun 2024 23:28:26 -0400 (EDT) |
branch: scratch/editorconfig
commit 4444fc9a90ab76e9383c2108f8734508467136a1
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
Misc changes accrued while trying to run the tests
* Makefile (SRCS): Filter out `editorconfig-autoloads.el` and
`editorconfig-pkg.el`.
(test-ert): Explicitly load the $OBJS files.
* editorconfig.el (editorconfig-call-get-properties-function):
Don't catch errors when debugging.
* ert-tests/editorconfig.el: Use `expand-file-name` rather than
`concat`.
(editorconfig-ert-dir, editorconfig-secondary-ert-dir)
(editorconfig-local-variables-ert-dir): Use `macroexp-file-name` rather
than `default-directory`.
(test-trim-trailing-ws): Adjust to new code that sets
`before-save-hook` rather than `write-file-functions`.
* ert-tests/editorconfig-core-handle.el (editorconfig--fixtures):
Rename from `fixtures`. Adjust all users (and use `expand-file-name`
rather than `concat`).
---
Makefile | 11 ++++---
editorconfig.el | 2 +-
ert-tests/editorconfig-core-handle.el | 39 ++++++++++-------------
ert-tests/editorconfig.el | 58 +++++++++++++++++++++--------------
4 files changed, 59 insertions(+), 51 deletions(-)
diff --git a/Makefile b/Makefile
index 963f6de2ed..0c5eec25be 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ ERT_TESTS = $(wildcard $(PROJECT_ROOT_DIR)/ert-tests/*.el)
BATCHFLAGS = -batch -q --no-site-file -L $(PROJECT_ROOT_DIR)
MAIN_SRC = editorconfig.el
-SRCS = $(wildcard $(PROJECT_ROOT_DIR)/*.el)
+SRCS = $(filter-out %-autoloads.el %-pkg.el, $(wildcard
$(PROJECT_ROOT_DIR)/*.el))
OBJS = $(SRCS:.el=.elc)
.PHONY: check-unix check-dos \
@@ -54,11 +54,12 @@ test: test-ert test-core
# ert test
test-ert: $(ERT_TESTS) $(OBJS)
- $(EMACS) $(BATCHFLAGS) \
- --eval "(setq debug-on-error t)" \
- --eval "(require 'ert)" \
+ $(EMACS) $(BATCHFLAGS) \
+ --eval "(setq debug-on-error t)" \
+ --eval "(require 'ert)" \
--eval "(setq metadata-el-files '($(MAIN_SRC:%=\"%\")))" \
- $(ERT_TESTS:%=-l "%") \
+ $(OBJS:%=-l "%") \
+ $(ERT_TESTS:%=-l "%") \
-f ert-run-tests-batch-and-exit
diff --git a/editorconfig.el b/editorconfig.el
index d6e521bb2e..1606d94413 100644
--- a/editorconfig.el
+++ b/editorconfig.el
@@ -700,7 +700,7 @@ This function also removes `unset' properties and calls
(setq filename (expand-file-name filename))
(editorconfig-error "Invalid argument: %S" filename))
(let ((props nil))
- (condition-case err
+ (condition-case-unless-debug err
(setq props (funcall editorconfig-get-properties-function
filename))
(error
diff --git a/ert-tests/editorconfig-core-handle.el
b/ert-tests/editorconfig-core-handle.el
index 454a1ab1be..485a10289b 100644
--- a/ert-tests/editorconfig-core-handle.el
+++ b/ert-tests/editorconfig-core-handle.el
@@ -25,48 +25,43 @@
(require 'editorconfig-core-handle "../editorconfig-core-handle")
-(defconst fixtures (concat (file-name-directory load-file-name) "fixtures/")
+(defconst editorconfig--fixtures (expand-file-name "fixtures/"
+ (file-name-directory load-file-name))
"Path to fixtures.")
(set-variable 'vc-handled-backends nil)
(ert-deftest test-editorconfig-core-handle ()
;; handle.ini
- (let* ((conf (concat fixtures "handle.ini"))
+ (let* ((conf (expand-file-name "handle.ini" editorconfig--fixtures))
(handle (editorconfig-core-handle conf)))
(should (editorconfig-core-handle-root-p handle))
- (should (equal (editorconfig-core-handle-get-properties handle
- (concat fixtures
- "b.js"))
+ (should (equal (editorconfig-core-handle-get-properties
+ handle (expand-file-name "b.js" editorconfig--fixtures))
'((("key2" . "value2")))))
- (should (equal (editorconfig-core-handle-get-properties handle
- (concat fixtures
- "a.js"))
+ (should (equal (editorconfig-core-handle-get-properties
+ handle (expand-file-name "a.js" editorconfig--fixtures))
'((("key1" . "value1")) (("key2" . "value2"))))))
;; Test twice for checking cache
- (let* ((conf (concat fixtures "handle.ini"))
+ (let* ((conf (expand-file-name "handle.ini" editorconfig--fixtures))
(handle (editorconfig-core-handle conf)))
(should (editorconfig-core-handle-root-p handle))
- (should (equal (editorconfig-core-handle-get-properties handle
- (concat fixtures
- "b.js"))
+ (should (equal (editorconfig-core-handle-get-properties
+ handle (expand-file-name "b.js" editorconfig--fixtures))
'((("key2" . "value2")))))
- (should (equal (editorconfig-core-handle-get-properties handle
- (concat fixtures
- "a.js"))
+ (should (equal (editorconfig-core-handle-get-properties
+ handle (expand-file-name "a.js" editorconfig--fixtures))
'((("key1" . "value1")) (("key2" . "value2"))))))
;; handle2.ini
- (let* ((conf (concat fixtures "handle2.ini"))
+ (let* ((conf (expand-file-name "handle2.ini" editorconfig--fixtures))
(handle (editorconfig-core-handle conf)))
(should-not (editorconfig-core-handle-root-p handle))
- (should (equal (editorconfig-core-handle-get-properties handle
- (concat fixtures
- "b.js"))
+ (should (equal (editorconfig-core-handle-get-properties
+ handle (expand-file-name "b.js" editorconfig--fixtures))
nil))
- (should (equal (editorconfig-core-handle-get-properties handle
- (concat fixtures
- "a.js"))
+ (should (equal (editorconfig-core-handle-get-properties
+ handle (expand-file-name "a.js" editorconfig--fixtures))
'((("key" . "value"))))))
;; For checking various normal whitespace (line breaks, horizontal space,
vertical space, etc.)
diff --git a/ert-tests/editorconfig.el b/ert-tests/editorconfig.el
index 4dae1fa5eb..0e285a55bb 100644
--- a/ert-tests/editorconfig.el
+++ b/ert-tests/editorconfig.el
@@ -58,23 +58,26 @@
(should (featurep 'editorconfig)))
(defvar editorconfig-ert-dir
- (concat default-directory "ert-tests/plugin-tests/test_files/"))
+ (expand-file-name "plugin-tests/test_files/"
+ (file-name-directory (macroexp-file-name))))
(defvar editorconfig-secondary-ert-dir
- (concat default-directory "ert-tests/test_files_secondary/"))
+ (expand-file-name "test_files_secondary/"
+ (file-name-directory (macroexp-file-name))))
(defvar editorconfig-local-variables-ert-dir
- (concat default-directory "ert-tests/local_variables/"))
+ (expand-file-name "local_variables/"
+ (file-name-directory (macroexp-file-name))))
(ert-deftest test-editorconfig nil
"Check if properties are applied."
(editorconfig-mode 1)
- (with-visit-file (concat editorconfig-ert-dir "3_space.txt")
+ (with-visit-file (expand-file-name "3_space.txt" editorconfig-ert-dir)
(should (eq tab-width 3))
(should (eq indent-tabs-mode nil)))
- (with-visit-file (concat editorconfig-ert-dir "4_space.py")
+ (with-visit-file (expand-file-name "4_space.py" editorconfig-ert-dir)
(should (eq python-indent-offset 4))
(should (eq tab-width 8))
(should (eq indent-tabs-mode nil)))
@@ -83,40 +86,44 @@
(ert-deftest test-lisp-use-default-indent nil
(editorconfig-mode 1)
- (with-visit-file (concat editorconfig-secondary-ert-dir "2_space.el")
+ (with-visit-file (expand-file-name "2_space.el"
+ editorconfig-secondary-ert-dir)
(should (eq lisp-indent-offset 2)))
(let ((editorconfig-lisp-use-default-indent t))
- (with-visit-file (concat editorconfig-secondary-ert-dir "2_space.el")
+ (with-visit-file (expand-file-name "2_space.el"
+ editorconfig-secondary-ert-dir)
(should (eq lisp-indent-offset nil))))
(let ((editorconfig-lisp-use-default-indent 2))
- (with-visit-file (concat editorconfig-secondary-ert-dir "2_space.el")
+ (with-visit-file (expand-file-name "2_space.el"
+ editorconfig-secondary-ert-dir)
(should (eq lisp-indent-offset nil))))
(let ((editorconfig-lisp-use-default-indent 4))
- (with-visit-file (concat editorconfig-secondary-ert-dir "2_space.el")
+ (with-visit-file (expand-file-name "2_space.el"
+ editorconfig-secondary-ert-dir)
(should (eq lisp-indent-offset 2))))
(editorconfig-mode -1))
(ert-deftest test-trim-trailing-ws nil
(editorconfig-mode 1)
- (with-visit-file (concat editorconfig-ert-dir "trim.txt")
+ (with-visit-file (expand-file-name "trim.txt" editorconfig-ert-dir)
(should (memq 'delete-trailing-whitespace
- write-file-functions)))
- (with-visit-file (concat editorconfig-ert-dir "trim.txt")
+ before-save-hook)))
+ (with-visit-file (expand-file-name "trim.txt" editorconfig-ert-dir)
(read-only-mode 1)
(should (not (memq 'delete-trailing-whitespace
- write-file-functions))))
+ before-save-hook))))
(editorconfig-mode -1))
(ert-deftest test-charset nil
(editorconfig-mode 1)
- (with-visit-file (concat editorconfig-ert-dir "latin1.txt")
+ (with-visit-file (expand-file-name "latin1.txt" editorconfig-ert-dir)
(set-buffer-file-coding-system 'undecided-unix)
(should (eq buffer-file-coding-system
'iso-latin-1-unix)))
- (with-visit-file (concat editorconfig-ert-dir "utf-16be.txt")
+ (with-visit-file (expand-file-name "utf-16be.txt" editorconfig-ert-dir)
(set-buffer-file-coding-system 'undecided-unix)
(should (eq buffer-file-coding-system
'utf-16be-with-signature-unix)))
@@ -125,21 +132,25 @@
(ert-deftest test-local-variables nil
(editorconfig-mode 1)
- (with-visit-file (concat editorconfig-local-variables-ert-dir
"file_locals.rb")
+ (with-visit-file (expand-file-name "file_locals.rb"
+ editorconfig-local-variables-ert-dir)
(should (eq tab-width 9))
(should (eq ruby-indent-level 7)))
- (with-visit-file (concat editorconfig-local-variables-ert-dir "dir_locals.c")
+ (with-visit-file (expand-file-name "dir_locals.c"
+ editorconfig-local-variables-ert-dir)
(should (eq tab-width 9))
(should (eq c-basic-offset 7)))
(let ((editorconfig-override-file-local-variables nil))
- (with-visit-file (concat editorconfig-local-variables-ert-dir
"file_locals.rb")
+ (with-visit-file (expand-file-name "file_locals.rb"
+ editorconfig-local-variables-ert-dir)
(should (eq tab-width 5))
(should (eq ruby-indent-level 3))))
(let ((editorconfig-override-dir-local-variables nil))
- (with-visit-file (concat editorconfig-local-variables-ert-dir
"dir_locals.c")
+ (with-visit-file (expand-file-name "dir_locals.c"
+ editorconfig-local-variables-ert-dir)
(should (eq tab-width 5))
(should (eq c-basic-offset 3))))
(editorconfig-mode -1))
@@ -147,17 +158,18 @@
(ert-deftest test-file-type-emacs nil
:expected-result t ;; Ignore failure
(editorconfig-mode 1)
- (with-visit-file (concat editorconfig-secondary-ert-dir "c.txt")
+ (with-visit-file (expand-file-name "c.txt" editorconfig-secondary-ert-dir)
(should (eq major-mode 'conf-unix-mode)))
(editorconfig-mode -1))
(ert-deftest test-file-type-ext nil
:expected-result t ;; Ignore failure
(editorconfig-mode 1)
- (with-visit-file (concat editorconfig-secondary-ert-dir "a.txt")
+ (with-visit-file (expand-file-name "a.txt" editorconfig-secondary-ert-dir)
(should (eq major-mode 'conf-unix-mode)))
- (with-visit-file (concat editorconfig-secondary-ert-dir "bin/perlscript")
+ (with-visit-file (expand-file-name "bin/perlscript"
+ editorconfig-secondary-ert-dir)
(should (eq major-mode 'perl-mode))
(should (eq perl-indent-level 5)))
(editorconfig-mode -1))
@@ -167,7 +179,7 @@
(add-hook 'editorconfig-hack-properties-functions
(lambda (props)
(puthash 'indent_size "5" props)))
- (with-visit-file (concat editorconfig-ert-dir "4_space.py")
+ (with-visit-file (expand-file-name "4_space.py" editorconfig-ert-dir)
(should (eq python-indent-offset 5)))
(setq editorconfig-hack-properties-functions nil)
(editorconfig-mode -1))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] scratch/editorconfig 4444fc9a90: Misc changes accrued while trying to run the tests,
Stefan Monnier <=