Skip to content

Commit e1c55b5

Browse files
committed
Meta: Update makem.sh
1 parent b7e1468 commit e1c55b5

File tree

2 files changed

+36
-12
lines changed

2 files changed

+36
-12
lines changed

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,8 @@ endif
2525

2626
# * Rules
2727

28+
# TODO: Handle cases in which "test" or "tests" are called and a
29+
# directory by that name exists, which can confuse Make.
30+
2831
%:
2932
@./makem.sh $(VERBOSE) $(SANDBOX) $(AUTOINSTALL) $(@)

makem.sh

+33-12
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,23 @@ function files_args {
248248
done
249249
}
250250

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+
251268
function dependencies {
252269
# Echo list of package dependencies.
253270
egrep '^;; Package-Requires: ' $(project-source-files) $(project-test-files) \
@@ -451,12 +468,14 @@ function lint-package {
451468
}
452469

453470
function tests {
454-
# Run tests.
471+
verbose 1 "Running all tests..."
472+
455473
test-ert
456474
test-buttercup
457475
}
458476

459477
function test-buttercup {
478+
buttercup-tests-p || return 0
460479
compile || die
461480

462481
verbose 1 "Running Buttercup tests..."
@@ -473,6 +492,7 @@ function test-buttercup {
473492
}
474493

475494
function test-ert {
495+
ert-tests-p || return 0
476496
compile || die
477497

478498
verbose 1 "Running ERT tests..."
@@ -578,9 +598,17 @@ debug "Remaining args: ${rest[@]}"
578598

579599
trap cleanup EXIT INT TERM
580600

601+
if ! [[ ${project_source_files[@]} ]]
602+
then
603+
error "No files specified and not in a git repo."
604+
exit 1
605+
fi
606+
581607
if [[ $sandbox ]]
582608
then
583609
# Setup sandbox.
610+
type emacs-sandbox.sh &>/dev/null || die "emacs-sandbox.sh not found."
611+
584612
config_dir=$(mktemp -d) || die "Unable to make temp dir."
585613
temp_paths+=("$config_dir")
586614

@@ -600,27 +628,20 @@ then
600628
done
601629
fi
602630

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).
605632
emacs_command="emacs-sandbox.sh ${sandbox_basic_args[@]} ${sandbox_install_packages_args[@]} -- "
606633
debug "Initializing sandbox..."
607634

608635
run_emacs || die "Unable to initialize sandbox."
609636

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.
613639
emacs_command="emacs-sandbox.sh ${sandbox_basic_args[@]} --no-refresh-packages -- "
614640

615641
debug "Sandbox initialized."
616642
fi
617643

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.
624645
for rule in "${rest[@]}"
625646
do
626647
if type "$rule" 2>/dev/null | grep "$rule is a function" &>/dev/null

0 commit comments

Comments
 (0)