Skip to content

Commit

Permalink
jacktasia#150 enable lexical bindings
Browse files Browse the repository at this point in the history
It's been observed that tests fail on GNU Emacs 24.3 if lexical-bindings are
enabled. There could be various reasons for this, but most obvious is
that Emacs 24.3 had `byte-compile-add-to-list` function, which was used
as byte-compiled version of `add-to-list`:
emacs-mirror/emacs@0b31660#diff-38337c5e732c14fa599af4a0f6e53f18L4272

ert-runner compiles files before the test run, so tests used the
compiled version.

This commit rewrites functions that depended on add-to-list.
  • Loading branch information
Artem Khramov committed Jul 25, 2017
1 parent e1a6647 commit d6f77f3
Showing 1 changed file with 31 additions and 32 deletions.
63 changes: 31 additions & 32 deletions dumb-jump.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; dumb-jump.el --- jump to definition for multiple languages without configuration.
;;; dumb-jump.el --- jump to definition for multiple languages without configuration. -*- lexical-binding: t; -*-

;; Copyright (C) 2015-2016 jack angers
;; Author: jack angers
Expand Down Expand Up @@ -1025,77 +1025,76 @@ not just a string."
(defun dumb-jump-test-rules (&optional run-not-tests)
"Test all the grep rules and return count of those that fail.
Optionally pass t for RUN-NOT-TESTS to see a list of all failed rules."
(let ((failures '())
(fail-tmpl "grep %s FAILURE '%s' %s in response '%s' | CMD: '%s' | regex: '%s'")
(variant (if (eq (dumb-jump-grep-installed?) 'gnu) 'gnu-grep 'grep)))
(-each (--filter (member "grep" (plist-get it :supports)) dumb-jump-find-rules)
(let ((fail-tmpl "grep FAILURE '%s' %s in response '%s' | CMD: '%s' | rule: '%s'")
(variant (if (eq (dumb-jump-grep-installed?) 'gnu) 'gnu-grep 'grep)))
(-mapcat
(lambda (rule)
(-each (plist-get rule (if run-not-tests :not :tests))
(-mapcat
(lambda (test)
(let* ((cmd (concat "grep -En -e "
(let* ((cmd (concat "grep -En -e "
(shell-quote-argument (dumb-jump-populate-regex (plist-get rule :regex) "test" variant))))
(resp (dumb-jump-run-test test cmd)))
(when (or
(and (not run-not-tests) (not (s-contains? test resp)))
(and run-not-tests (> (length resp) 0)))
(add-to-list 'failures (format fail-tmpl (if run-not-tests "not" "")
test (if run-not-tests "IS unexpectedly" "NOT") resp cmd (plist-get rule :regex)))))))))
failures))
(list (format fail-tmpl (if run-not-tests "not" "")
test (if run-not-tests "IS unexpectedly" "NOT") resp cmd (plist-get rule :regex))))))
(plist-get rule (if run-not-tests :not :tests))))
(--filter (member "grep" (plist-get it :supports)) dumb-jump-find-rules))))

(defun dumb-jump-test-ag-rules (&optional run-not-tests)
"Test all the ag rules and return count of those that fail.
Optionally pass t for RUN-NOT-TESTS to see a list of all failed rules"
(let ((failures '())
(fail-tmpl "ag FAILURE '%s' %s in response '%s' | CMD: '%s' | rule: '%s'"))
(-each (--filter (member "ag" (plist-get it :supports)) dumb-jump-find-rules)
(let ((fail-tmpl "ag FAILURE '%s' %s in response '%s' | CMD: '%s' | rule: '%s'"))
(-mapcat
(lambda (rule)
(-each (plist-get rule (if run-not-tests :not :tests))
(-mapcat
(lambda (test)
(let* ((cmd (concat "ag --nocolor --nogroup "
(shell-quote-argument (dumb-jump-populate-regex (plist-get rule :regex) "test" 'ag))))
(resp (dumb-jump-run-test test cmd)))
(when (or
(and (not run-not-tests) (not (s-contains? test resp)))
(and run-not-tests (> (length resp) 0)))
(add-to-list 'failures (format fail-tmpl test (if run-not-tests "IS unexpectedly" "NOT") resp cmd rule))))))))
failures))
(list (format fail-tmpl test (if run-not-tests "IS unexpectedly" "NOT") resp cmd rule)))))
(plist-get rule (if run-not-tests :not :tests))))
(--filter (member "ag" (plist-get it :supports)) dumb-jump-find-rules))))

(defun dumb-jump-test-rg-rules (&optional run-not-tests)
"Test all the rg rules and return count of those that fail.
Optionally pass t for RUN-NOT-TESTS to see a list of all failed rules"
(let ((failures '())
(fail-tmpl "rg FAILURE '%s' %s in response '%s' | CMD: '%s' | rule: '%s'"))
(-each (--filter (member "rg" (plist-get it :supports)) dumb-jump-find-rules)
(let ((fail-tmpl "rg FAILURE '%s' %s in response '%s' | CMD: '%s' | rule: '%s'"))
(-mapcat
(lambda (rule)
(-each (plist-get rule (if run-not-tests :not :tests))
(-mapcat
(lambda (test)
(let* ((cmd (concat "rg --color never --no-heading "
(shell-quote-argument (dumb-jump-populate-regex (plist-get rule :regex) "test" 'rg))))
(resp (dumb-jump-run-test test cmd)))
(when (or
(and (not run-not-tests) (not (s-contains? test resp)))
(and run-not-tests (> (length resp) 0)))
(add-to-list 'failures (format fail-tmpl test (if run-not-tests "IS unexpectedly" "NOT") resp cmd rule))))))))
failures))
(list (format fail-tmpl test (if run-not-tests "IS unexpectedly" "NOT") resp cmd rule)))))
(plist-get rule (if run-not-tests :not :tests))))
(--filter (member "rg" (plist-get it :supports)) dumb-jump-find-rules))))

(defun dumb-jump-test-git-grep-rules (&optional run-not-tests)
"Test all the git grep rules and return count of those that fail.
"Test all the rg rules and return count of those that fail.
Optionally pass t for RUN-NOT-TESTS to see a list of all failed rules"
(let ((failures '())
(fail-tmpl "git grep FAILURE '%s' %s in response '%s' | CMD: '%s' | rule: '%s'"))
(-each (--filter (member "git-grep" (plist-get it :supports)) dumb-jump-find-rules)
(let ((fail-tmpl "rg FAILURE '%s' %s in response '%s' | CMD: '%s' | rule: '%s'"))
(-mapcat
(lambda (rule)
(-each (plist-get rule (if run-not-tests :not :tests))
(-mapcat
(lambda (test)
(let* ((cmd (concat "git grep --color=never -h --untracked -E "
(shell-quote-argument
(dumb-jump-populate-regex (plist-get rule :regex) "test" 'git-grep))))
(let* ((cmd (concat "git grep --color=never -h --untracked -E "
(shell-quote-argument (dumb-jump-populate-regex (plist-get rule :regex) "test" 'git-grep))))
(resp (dumb-jump-run-git-grep-test test cmd)))
(when (or
(and (not run-not-tests) (not (s-contains? test resp)))
(and run-not-tests (> (length resp) 0)))
(add-to-list 'failures (format fail-tmpl test (if run-not-tests "IS unexpectedly" "NOT") resp cmd rule))))))))
failures))
(list (format fail-tmpl test (if run-not-tests "IS unexpectedly" "NOT") resp cmd rule)))))
(plist-get rule (if run-not-tests :not :tests))))
(--filter (member "grep" (plist-get it :supports)) dumb-jump-find-rules))))

(defun dumb-jump-message (str &rest args)
"Log message STR with ARGS to the *Messages* buffer if not using dumb-jump-quiet."
Expand Down

0 comments on commit d6f77f3

Please sign in to comment.