Skip to content

Commit b2dc01c

Browse files
committed
Fix framework-specific testing command working incorrectly when `eldev-test-framework' is explicitly set to a list of frameworks.
1 parent 5d59d3d commit b2dc01c

File tree

5 files changed

+66
-9
lines changed

5 files changed

+66
-9
lines changed

eldev.el

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3236,6 +3236,8 @@ for details."
32363236
(if (cdr used-frameworks)
32373237
;; Print summary over all test types if we have run more than one.
32383238
(unless (eq pass 'count)
3239+
;; Using "(s)" because if replaced with proper singular/plural form of word
3240+
;; "test", "of them" becomes weird.
32393241
(let ((summary (eldev-format-message "\nTesting summary: %d test(s), of them %d passed, %d failed, %d skipped"
32403242
(+ eldev-test-num-passed eldev-test-num-failed eldev-test-num-skipped)
32413243
eldev-test-num-passed eldev-test-num-failed eldev-test-num-skipped)))
@@ -3304,14 +3306,19 @@ framework(s) are autodetected where possible, among those allowed
33043306
by parameter POSSIBLE-FRAMEWORKS (if that is not specified, only
33053307
frameworks based on `.el' files, i.e. ERT and Buttercup, are
33063308
considered allowed)."
3307-
(let ((frameworks (or (eldev-listify eldev-test-framework)
3308-
(mapcar #'car (eldev-filter (let* ((framework (car it))
3309-
(detect (when (if possible-frameworks
3310-
(memq framework possible-frameworks)
3311-
(null (cdr (assq 'fileset (cdr it)))))
3312-
(cdr (assq 'detect (cdr it))))))
3313-
(and detect (funcall detect)))
3314-
eldev-test-known-frameworks)))))
3309+
(let ((frameworks (eldev-listify eldev-test-framework)))
3310+
(setf frameworks (if frameworks
3311+
(eldev-filter (if possible-frameworks
3312+
(memq it possible-frameworks)
3313+
(null (eldev-test-get-framework-entry it 'fileset)))
3314+
frameworks)
3315+
(mapcar #'car (eldev-filter (let* ((framework (car it))
3316+
(detect (when (if possible-frameworks
3317+
(memq framework possible-frameworks)
3318+
(null (cdr (assq 'fileset (cdr it)))))
3319+
(cdr (assq 'detect (cdr it))))))
3320+
(and detect (funcall detect)))
3321+
eldev-test-known-frameworks))))
33153322
(if (cdr frameworks) frameworks (car frameworks))))
33163323

33173324
(defun eldev-test-preprocess-selectors (framework selectors)

test/integration/buttercup.el

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,33 @@
1717
(should (= exit-code 0))))
1818

1919

20+
;; `project-i' has two ERT and two Buttercup tests. Make sure that this combination works
21+
;; both in autodetermined and explicit ways.
22+
23+
(eldev-ert-defargtest eldev-test-buttercup-project-i-1 (command explicitly-configured)
24+
(('test nil)
25+
('test t)
26+
('test-ert nil)
27+
('test-ert t)
28+
('test-buttercup nil)
29+
('test-buttercup t))
30+
(eldev--test-run "project-i" (:eval `(,@(if explicitly-configured
31+
'("--setup" (setf eldev-test-framework '(ert buttercup)))
32+
'("--setup" (setf eldev-test-framework nil)))
33+
,command))
34+
;; Make sure that the exact tests executed match the issued command.
35+
(let ((ran-ert (string-match-p "Running 2 tests" stdout))
36+
(ran-buttercup (string-match-p "Running 2 specs" stdout))
37+
(ran-both (string-match-p "Testing summary: 4 test(s)" stdout)))
38+
(pcase command
39+
(`test (should (and ran-ert ran-buttercup ran-both)))
40+
(`test-ert (should ran-ert)
41+
(should-not (or ran-buttercup ran-both)))
42+
(`test-buttercup (should ran-buttercup)
43+
(should-not (or ran-ert ran-both))))
44+
(should (= exit-code 0)))))
45+
46+
2047
(ert-deftest eldev-test-buttercup-erroneous-backtrace-1 ()
2148
;; Until Eldev 0.7 (and Buttercup 1.23) a pointless and unneded backtrace would have
2249
;; been printed if a test failed and Eldev was in debug mode.

test/project-i/project-i.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
;;; project-i.el --- Test project with autoload cookies in multiple files
1+
;;; project-i.el --- Test project with autoload cookies in multiple files and both ERT and Buttercup tests
22

33
;; Version: 1.0
44
;; Homepage: https://example.com/

test/project-i/test/buttercup.el

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
(require 'project-i)
2+
(require 'project-i-advanced)
3+
(require 'buttercup)
4+
5+
;; All tests pass.
6+
7+
(describe "Project D tests"
8+
(it "has working `project-i-hello'"
9+
(expect (project-i-hello) :to-equal "Hello"))
10+
11+
(it "has working `project-i-hello-to'"
12+
(expect (project-i-hello-to "world") :to-equal "Hello, world!")))

test/project-i/test/ert.el

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(require 'project-i)
2+
(require 'project-i-advanced)
3+
(require 'ert)
4+
5+
;; All tests pass.
6+
7+
(ert-deftest project-i-test-hello ()
8+
(should (string= (project-i-hello) "Hello")))
9+
10+
(ert-deftest project-i-test-hello-advanced ()
11+
(should (string= (project-i-hello-to "world") "Hello, world!")))

0 commit comments

Comments
 (0)