@@ -248,6 +248,23 @@ function files_args {
248
248
done
249
249
}
250
250
251
+ function buttercup-tests-p {
252
+ # Return 0 if Buttercup tests are found.
253
+ debug " Checking for Buttercup tests..."
254
+
255
+ grep " (require 'buttercup)" $( project-test-files) & > /dev/null
256
+ }
257
+
258
+ function ert-tests-p {
259
+ # Return 0 if ERT tests are found.
260
+ debug " Checking for ERT tests..."
261
+
262
+ # We check for this rather than "(require 'ert)", because ERT may
263
+ # already be loaded in Emacs and might not be loaded with
264
+ # "require" in a test file.
265
+ grep " (ert-deftest" $( project-test-files) & > /dev/null
266
+ }
267
+
251
268
function dependencies {
252
269
# Echo list of package dependencies.
253
270
egrep ' ^;; Package-Requires: ' $( project-source-files) $( project-test-files) \
@@ -451,12 +468,14 @@ function lint-package {
451
468
}
452
469
453
470
function tests {
454
- # Run tests.
471
+ verbose 1 " Running all tests..."
472
+
455
473
test-ert
456
474
test-buttercup
457
475
}
458
476
459
477
function test-buttercup {
478
+ buttercup-tests-p || return 0
460
479
compile || die
461
480
462
481
verbose 1 " Running Buttercup tests..."
@@ -473,6 +492,7 @@ function test-buttercup {
473
492
}
474
493
475
494
function test-ert {
495
+ ert-tests-p || return 0
476
496
compile || die
477
497
478
498
verbose 1 " Running ERT tests..."
@@ -578,9 +598,17 @@ debug "Remaining args: ${rest[@]}"
578
598
579
599
trap cleanup EXIT INT TERM
580
600
601
+ if ! [[ ${project_source_files[@]} ]]
602
+ then
603
+ error " No files specified and not in a git repo."
604
+ exit 1
605
+ fi
606
+
581
607
if [[ $sandbox ]]
582
608
then
583
609
# Setup sandbox.
610
+ type emacs-sandbox.sh & > /dev/null || die " emacs-sandbox.sh not found."
611
+
584
612
config_dir=$( mktemp -d) || die " Unable to make temp dir."
585
613
temp_paths+=(" $config_dir " )
586
614
@@ -600,27 +628,20 @@ then
600
628
done
601
629
fi
602
630
603
- # Initialize the sandbox (installs packages once rather than for
604
- # every rule.
631
+ # Initialize the sandbox (installs packages once rather than for every rule).
605
632
emacs_command=" emacs-sandbox.sh ${sandbox_basic_args[@]} ${sandbox_install_packages_args[@]} -- "
606
633
debug " Initializing sandbox..."
607
634
608
635
run_emacs || die " Unable to initialize sandbox."
609
636
610
- # After the sandbox is initialized and packages are installed, set
611
- # the command to prevent the package lists from being refreshed on
612
- # each invocation.
637
+ # After the sandbox is initialized and packages are installed, set the command
638
+ # to prevent the package lists from being refreshed on each invocation.
613
639
emacs_command=" emacs-sandbox.sh ${sandbox_basic_args[@]} --no-refresh-packages -- "
614
640
615
641
debug " Sandbox initialized."
616
642
fi
617
643
618
- if ! [[ ${project_source_files[@]} ]]
619
- then
620
- error " No files specified and not in a git repo."
621
- exit 1
622
- fi
623
-
644
+ # Run rules.
624
645
for rule in " ${rest[@]} "
625
646
do
626
647
if type " $rule " 2> /dev/null | grep " $rule is a function" & > /dev/null
0 commit comments