File tree Expand file tree Collapse file tree 5 files changed +69
-6
lines changed
test/commands/test/buttercup Expand file tree Collapse file tree 5 files changed +69
-6
lines changed Original file line number Diff line number Diff line change 1717
1818"use strict" ;
1919
20- exports . command = [ 'buttercup [files ..]' ] ;
20+ exports . command = [ 'buttercup [directories ..]' ] ;
2121exports . desc = 'Run buttercup tests' ;
2222exports . builder = yargs => yargs
2323 . positional (
24- '[files ..]' , {
25- description : 'files you want buttercup to run on ' ,
24+ '[directories ..]' , {
25+ description : 'directories containing buttercup tests, must be children of the current directory ' ,
2626 type : 'array' ,
2727 } ) ;
2828
2929exports . handler = async ( argv ) => {
30- await UTIL . e_call ( argv , 'test/buttercup' , argv . files ) ;
30+ await UTIL . e_call ( argv , 'test/buttercup' , argv . directories ) ;
3131} ;
Original file line number Diff line number Diff line change 2222 ; ; Start Testing
2323 (require 'buttercup )
2424 ; ; Propose fix from https://github.com/jorgenschaefer/emacs-buttercup/pull/217
25- (let ((load-path (cons " ." load-path)))
25+ (let* ((load-path (cons " ." load-path))
26+ ; ; this does not include options
27+ (args (eask-args)))
28+ ; ; buttercup-run-discover uses command-line-args-left not command-line-args
29+ (setq command-line-args-left args)
30+ ; ; Seems like buttercup-run-discover only works on directories that are children of
31+ ; ; the current directory.
32+ ; ; When given a parent directory it always fails with "No suites found", even if there are tests.
33+ ; ; Since this is a bit confusing, we warn the user specifically.
34+ ; ; See discussion https://github.com/emacs-eask/cli/pull/281
35+ (when-let ((bad-arg (seq-find (lambda (x ) (not (file-in-directory-p x default-directory))) args)))
36+ (error " Buttercup cannot run in parent directory: %s " bad-arg))
2637 (buttercup-run-discover)))
2738
2839; ;; test/buttercup.el ends here
Original file line number Diff line number Diff line change @@ -26,4 +26,25 @@ echo "Test command 'buttercup'..."
2626cd $( dirname " $0 " )
2727
2828eask install-deps --dev
29- eask test buttercup
29+ if eask test buttercup; then
30+ # this runs all tests, so should error
31+ echo " expected error"
32+ exit 1
33+ fi
34+
35+ # buttercup takes directories as arguments
36+ eask test buttercup ./test-ok
37+ if eask test buttercup ./test-ok ./test-fail; then
38+ echo " expected error"
39+ exit 1
40+ fi
41+
42+ # buttercup does not take options
43+ eask test buttercup --no-color ./test-ok
44+
45+ # Because load-path is manually set, cannot refer to parent directories.
46+ # Note this does work if you do ../buttercup/test-ok/, but not for any other directory.
47+ if eask test buttercup ../ert/ 2>&1 | grep ' No suites defined' ; then
48+ echo " expected error"
49+ exit 1
50+ fi
Original file line number Diff line number Diff line change 1+ ; ;; buttercup-test.el --- Test the command buttercup -*- lexical-binding : t ; -*-
2+
3+ ; ; Copyright (C) 2022-2024 the Eask authors.
4+
5+ ; ; This program is free software; you can redistribute it and/or modify
6+ ; ; it under the terms of the GNU General Public License as published by
7+ ; ; the Free Software Foundation, either version 3 of the License, or
8+ ; ; (at your option) any later version.
9+
10+ ; ; This program is distributed in the hope that it will be useful,
11+ ; ; but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ ; ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+ ; ; GNU General Public License for more details.
14+
15+ ; ; You should have received a copy of the GNU General Public License
16+ ; ; along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
18+ ; ;; Commentary:
19+
20+ ; ; Tests for the command buttercup
21+
22+ ; ;; Code:
23+
24+ (require 'buttercup )
25+ (require 'debug )
26+
27+ (describe " A failing suite"
28+ (it " contains a spec with a false expectation"
29+ (expect t :to-be nil )))
30+
31+ ; ;; buttercup-test.el ends here
File renamed without changes.
You can’t perform that action at this time.
0 commit comments