Skip to content

Commit

Permalink
Sanitize Makefile a bit
Browse files Browse the repository at this point in the history
* elpa.el: Don't add default-directory to load-path; leave that to
the Makefile harness.

* Makefile (LOAD): Remove.
(src-elcs, test-elcs): New explicit file lists.
(all): Default to compilation not testing, as per GNU conventions.
(deps): Call Emacs with -Q.
(test): Byte-compile package and test sources and allow loading
byte-compiled versions.
(compile): Byte-compile each .el individually (#3038, #3039), with
minimal dependencies.
(plain): Specify '-L .' now that elpa.el no longer does it.
(clean): Remove known .elc files, not wildcard.

* ivy-test.el:
(ivy-read-prompt, ivy-completing-read-handlers, ivy-partial-files):
Refactor for clean byte-compilation.
  • Loading branch information
basil-conto committed Apr 5, 2024
1 parent e0b1a6c commit a38bc60
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 95 deletions.
49 changes: 36 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,30 +1,53 @@
emacs ?= emacs

LOAD = -l elpa.el -l colir.el -l ivy-overlay.el -l ivy.el -l swiper.el -l counsel.el
RM ?= rm -f

all: test
src-elcs = \
colir.elc \
ivy-faces.elc \
ivy-overlay.elc \
ivy.elc \
ivy-avy.elc \
ivy-hydra.elc \
swiper.elc \
counsel.elc

test-elcs = ivy-test.elc

.PHONY: all
all: compile

.PHONY: deps
deps:
$(emacs) -batch -l targets/install-deps.el
$(emacs) -Q -batch -l targets/install-deps.el

test:
$(emacs) -batch $(LOAD) -l ivy-test.el -f ivy-test-run-tests
.PHONY: test
test: compile $(test-elcs)
$(emacs) -Q -batch -l elpa.el -L . -l ivy-test -f ivy-test-run-tests

.PHONY: checkdoc
checkdoc:
$(emacs) -batch -l targets/checkdoc.el

compile:
$(emacs) -batch -l elpa.el -L . -f batch-byte-compile colir.el ivy-faces.el ivy-overlay.el ivy.el ivy-avy.el ivy-hydra.el swiper.el counsel.el
.PHONY: compile
compile: $(src-elcs)

plain:
$(emacs) --version
$(emacs) -Q -l elpa.el -l targets/plain.el
.PHONY: plain
plain: compile
$(emacs) -version
$(emacs) -Q -l elpa.el -L . -l targets/plain.el

.PHONY: obsolete
obsolete:
$(emacs) -batch -l targets/obsolete-config.el

.PHONY: clean
clean:
$(RM) *.elc
$(RM) $(src-elcs) $(test-elcs)

%.elc: %.el
$(emacs) -Q -batch -L . -f batch-byte-compile $<

.PHONY: all test checkdoc compile plain obsolete update-issues clean
ivy-avy.elc: ivy-avy.el
ivy-hydra.elc: ivy-hydra.el
ivy-avy.elc ivy-hydra.elc:
$(emacs) -Q -batch -l elpa.el -L . -f batch-byte-compile $<
1 change: 0 additions & 1 deletion elpa.el
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
(format "~/.elpa/%s/elpa"
(concat emacs-version (when (getenv "MELPA_STABLE") "-stable")))))
(package-initialize)
(add-to-list 'load-path default-directory)
144 changes: 63 additions & 81 deletions ivy-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ Since `execute-kbd-macro' doesn't pick up a let-bound `default-directory'.")

(defvar ivy-test-inhibit-message t)

;; New in Emacs 25.
(defvar inhibit-message)

(cl-defun ivy-with (expr keys &key dir)
"Evaluate EXPR followed by KEYS."
(let ((ivy-expr expr)
Expand Down Expand Up @@ -292,6 +295,8 @@ Since `execute-kbd-macro' doesn't pick up a let-bound `default-directory'.")
:expected-result (if (>= emacs-major-version 25)
:passed
:failed)
;; New in Emacs 25.
(defvar search-default-mode)
(let ((search-default-mode 'char-fold-to-regexp))
(should (string= (swiper--re-builder "f b")
"\\(\\(?:ḟ\\|[fᶠḟⓕf𝐟𝑓𝒇𝒻𝓯𝔣𝕗𝖋𝖿𝗳𝘧𝙛𝚏]\\)\\).*?\\(\\(?:b[̣̱̇]\\|[bᵇḃḅḇⓑb𝐛𝑏𝒃𝒷𝓫𝔟𝕓𝖇𝖻𝗯𝘣𝙗𝚋]\\)\\)"))
Expand Down Expand Up @@ -785,80 +790,55 @@ Since `execute-kbd-macro' doesn't pick up a let-bound `default-directory'.")
"default")))

(ert-deftest ivy-read-prompt ()
(setq prompt "pattern: ")
(setq collection '("blue" "yellow"))
(should (equal
(ivy-with
'(let ((ivy-use-selectable-prompt nil))
(ivy-read prompt collection))
"bl C-m")
"blue"))
(should (equal
(ivy-with
'(let ((ivy-use-selectable-prompt nil))
(ivy-read prompt collection))
"bl C-p C-m")
"blue"))
(should (equal
(ivy-with
'(let ((ivy-use-selectable-prompt nil))
(ivy-read prompt collection))
"bl C-j")
"blue"))
(should (equal
(ivy-with
'(let ((ivy-use-selectable-prompt nil))
(ivy-read prompt collection))
"bl C-p C-j")
"blue"))
(should (equal
(ivy-with
'(let ((ivy-use-selectable-prompt nil))
(ivy-read prompt collection))
"bl C-M-j")
"bl"))
(should (equal
(ivy-with
'(let ((ivy-use-selectable-prompt nil))
(ivy-read prompt collection))
"bl C-p C-M-j")
"bl"))
(should (equal
(ivy-with
'(let ((ivy-use-selectable-prompt t))
(ivy-read prompt collection))
"bl C-m")
"blue"))
(should (equal
(ivy-with
'(let ((ivy-use-selectable-prompt t))
(ivy-read prompt collection))
"bl C-p C-m")
"bl"))
(should (equal
(ivy-with
'(let ((ivy-use-selectable-prompt t))
(ivy-read prompt collection))
"bl C-j")
"blue"))
(should (equal
(ivy-with
'(let ((ivy-use-selectable-prompt t))
(ivy-read prompt collection))
"bl C-p C-j")
"bl"))
(should (equal
(ivy-with
'(let ((ivy-use-selectable-prompt t))
(ivy-read prompt collection))
"bl C-M-j")
"bl"))
(should (equal
(ivy-with
'(let ((ivy-use-selectable-prompt t))
(ivy-read prompt collection))
"bl C-p C-M-j")
"bl")))
(let ((read '(ivy-read "pattern: " '("blue" "yellow"))))
(should (equal (ivy-with
`(let ((ivy-use-selectable-prompt nil)) ,read)
"bl C-m")
"blue"))
(should (equal (ivy-with
`(let ((ivy-use-selectable-prompt nil)) ,read)
"bl C-p C-m")
"blue"))
(should (equal (ivy-with
`(let ((ivy-use-selectable-prompt nil)) ,read)
"bl C-j")
"blue"))
(should (equal (ivy-with
`(let ((ivy-use-selectable-prompt nil)) ,read)
"bl C-p C-j")
"blue"))
(should (equal (ivy-with
`(let ((ivy-use-selectable-prompt nil)) ,read)
"bl C-M-j")
"bl"))
(should (equal (ivy-with
`(let ((ivy-use-selectable-prompt nil)) ,read)
"bl C-p C-M-j")
"bl"))
(should (equal (ivy-with
`(let ((ivy-use-selectable-prompt t)) ,read)
"bl C-m")
"blue"))
(should (equal (ivy-with
`(let ((ivy-use-selectable-prompt t)) ,read)
"bl C-p C-m")
"bl"))
(should (equal (ivy-with
`(let ((ivy-use-selectable-prompt t)) ,read)
"bl C-j")
"blue"))
(should (equal (ivy-with
`(let ((ivy-use-selectable-prompt t)) ,read)
"bl C-p C-j")
"bl"))
(should (equal (ivy-with
`(let ((ivy-use-selectable-prompt t)) ,read)
"bl C-M-j")
"bl"))
(should (equal (ivy-with
`(let ((ivy-use-selectable-prompt t)) ,read)
"bl C-p C-M-j")
"bl"))))

(defmacro ivy-with-r (expr &rest keys)
`(with-output-to-string
Expand Down Expand Up @@ -995,7 +975,8 @@ Since `execute-kbd-macro' doesn't pick up a let-bound `default-directory'.")
;; Handler = `completing-read-default'; make sure ivy-read
;; is never called
(cl-letf (((symbol-function 'ivy-read)
(lambda (&rest args) (error "`ivy-read' should not be called"))))
(lambda (&rest _)
(error "`ivy-read' should not be called"))))

(should
(equal ""
Expand Down Expand Up @@ -1140,13 +1121,14 @@ Since `execute-kbd-macro' doesn't pick up a let-bound `default-directory'.")
(let (dir)
(unwind-protect
(let ((ivy-minibuffer-map
;; Avoid modifying global `ivy-minibuffer-map'.
(easy-mmode-define-keymap
'(("\t" . ivy-partial)
;; Allow quitting during `execute-kbd-macro'.
(let ((map (make-sparse-keymap)))
;; Avoid modifying global `ivy-minibuffer-map'.
(set-keymap-parent map ivy-minibuffer-map)
(define-key map "\t" #'ivy-partial)
;; Allow quitting during `execute-kbd-macro'.
;; See issue #2906 and URL `https://bugs.gnu.org/48603'.
("\C-g" . abort-recursive-edit))
nil nil `(:inherit ,ivy-minibuffer-map)))
(define-key map "\C-g" #'abort-recursive-edit)
map))
(subdirs '("test1/" "test2/")))
(setq dir (file-name-as-directory (make-temp-file "ivy-test-" t)))
(dolist (subdir subdirs)
Expand Down

0 comments on commit a38bc60

Please sign in to comment.