Skip to content

Commit

Permalink
Rework test-unit into something even simpler.
Browse files Browse the repository at this point in the history
  • Loading branch information
rocky committed Jun 2, 2012
0 parents commit 69166d1
Show file tree
Hide file tree
Showing 14 changed files with 1,233 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

/*~
/aclocal.m4
2 changes: 2 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Rocky Bernstein (rocky@gnu.org) adapted from Phil Hagelberg's behave.el

340 changes: 340 additions & 0 deletions COPYING

Large diffs are not rendered by default.

Empty file added ChangeLog
Empty file.
370 changes: 370 additions & 0 deletions INSTALL

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
lisp_files := $(wildcard *.el)
test_files := $(wildcard test/test-*.el)

EXTRA_DIST = $(lisp_files) $(test_files) README README.textile COPYING

CHECK_FILES = $(notdir $(test_files:.el=.run))

lisp_LISP = $(lisp_files)

check: $(CHECK_FILES)

README: README.textile
cp README.textile README

# FIGURE out how to DRY the run rules.
test-simple-basic.run:
(cd $(srcdir)/test && $(EMACS) -batch --no-site-file --no-splash --no-load -l $(@:.run=.el) )

.PHONY: $(CHECK_FILES)

if MAINTAINER_MODE

CL = ChangeLog
ChangeLog:
git log --pretty --numstat --summary | $(GIT2CL) > $@

ACLOCAL_AMFLAGS=-I .

endif

test: check
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
0.2
Initial Release
9 changes: 9 additions & 0 deletions README.textile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
_test-unit.el_ allows you to create unit tests for your Emacs Lisp code. Executable specifications allow you to check that your code is working correctly in an automated fashion that you can use to drive the focus of your development. (It's related to Test-Driven Development.) You can read up on it at the "Behavior-Driven Development Wiki":http://behaviour-driven.org.

Specifications and contexts both must have docstrings so that when the specifications aren't met it is easy to see what caused the failure. Each specification should live within a context. In each context, you can set up relevant things to test, such as necessary buffers or data structures. (Be sure to use lexical-let for setting up the variables you need--since the specify macro uses lambdas, closures will be made for those variables.) Everything within the context is executed normally.

Each context can be tagged with the @tag@ form. This allows you to group your contexts by tags. When you execute the specs, M-x test-unit will ask you to give some tags, and it will execute all contexts that match those tags.

When you want to run the specs, evaluate them and press @M-x@ @test-unit@. Enter the tags you want to run (or "all"), and they will be executed with results in the @*test-unit*@ buffer. You can also do @M-x@ specifications to show a list of all the specified behaviors of the code.

See also Christian Ohler's "ert":http://github.com/ohler/ert.
7 changes: 7 additions & 0 deletions autogen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
autoreconf -vfi && \
autoconf && {
echo "Running configure with --enable-maintainer-mode $@"
./configure --enable-maintainer-mode $@
}

25 changes: 25 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
AC_INIT(emacs-test-simple, 0.02vc,)
AC_CONFIG_SRCDIR(test-simple.el)
AM_INIT_AUTOMAKE([foreign])
AM_MAINTAINER_MODE
AM_MISSING_PROG(GIT2CL, git2cl, $missing_dir)

AC_PATH_PROG([EMACS], [emacs], [emacs])
$EMACS -batch -q -no-site-file -eval \
'(if (<= emacs-major-version 22)
(progn
(error "You need GNU Emacs 23 or better.")
(kill-emacs 1)
))'
if test $? -ne 0 ; then
AC_MSG_ERROR([Can't continue with this version of Emacs])
fi

##
## Find out where to install the debugger emacs lisp files
##
AM_PATH_LISPDIR
AM_CONDITIONAL(INSTALL_EMACS_LISP, test "x$lispdir" != "x")

AC_CONFIG_FILES([Makefile])
AC_OUTPUT
94 changes: 94 additions & 0 deletions elisp-comp
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/bin/sh
# Copyright (C) 1995, 2000, 2003, 2004, 2005, 2009, 2010 Free Software
# Foundation, Inc.

scriptversion=2010-02-06.18; # UTC

# Franc,ois Pinard <pinard@iro.umontreal.ca>, 1995.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.

# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.

case $1 in
'')
echo "$0: No files. Try \`$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: elisp-comp [--help] [--version] FILES...
This script byte-compiles all `.el' files listed as FILES using GNU
Emacs, and put the resulting `.elc' files into the current directory,
so disregarding the original directories used in `.el' arguments.
This script manages in such a way that all Emacs LISP files to
be compiled are made visible between themselves, in the event
they require or load-library one another.
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "elisp-comp $scriptversion"
exit $?
;;
esac

if test -z "$EMACS" || test "$EMACS" = "t"; then
# Value of "t" means we are running in a shell under Emacs.
# Just assume Emacs is called "emacs".
EMACS=emacs
fi

tempdir=elc.$$

# Cleanup the temporary directory on exit.
trap 'ret=$?; rm -rf "$tempdir" && exit $ret' 0
do_exit='(exit $ret); exit $ret'
trap "ret=129; $do_exit" 1
trap "ret=130; $do_exit" 2
trap "ret=141; $do_exit" 13
trap "ret=143; $do_exit" 15

mkdir $tempdir
cp "$@" $tempdir

(
cd $tempdir
echo "(setq load-path (cons nil load-path))" > script
$EMACS -batch -q -l script -f batch-byte-compile *.el || exit $?
mv *.elc ..
) || exit $?

(exit 0); exit 0

# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:
36 changes: 36 additions & 0 deletions install-from-git.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
# Install emacs-dbgr from git
run_cmd() {
echo "--- Running command: $@"
$@
rc=$?
echo "--- $@ exit status is $?"
return $rc
}

if (( $(id -u) != 0)) ; then
need_sudo='sudo'
else
need_sudo=''
fi
for program in git make $need_sudo ; do
if ! which $program >/dev/null 2>&1 ; then
echo "Cant find program $program in $PATH"
exit 1
fi
done

packages=emacs-test-unit
for pkg in $packages ; do
echo '******************************************'
echo Trying to install ${pkg}...
echo '******************************************'
run_cmd git clone http://github.com/rocky/${pkg}.git
(cd $pkg && \
run_cmd $SHELL ./autogen.sh && \
run_cmd ./configure && \
run_cmd make && \
run_cmd make check && \
run_cmd $need_sudo make install
)
done
Loading

0 comments on commit 69166d1

Please sign in to comment.