[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master d4b5edf: Add 'packages/test-simple/' from commit '75eea25b
From: |
Rocky Bernstein |
Subject: |
[elpa] master d4b5edf: Add 'packages/test-simple/' from commit '75eea25bae04d8e5e3e835a2770f02f0ff4602c4' |
Date: |
Sun, 15 Feb 2015 23:37:12 +0000 |
branch: master
commit d4b5edf096766e9335a92180ff931823b006c556
Merge: bfb36f0 75eea25
Author: rocky <address@hidden>
Commit: rocky <address@hidden>
Add 'packages/test-simple/' from commit
'75eea25bae04d8e5e3e835a2770f02f0ff4602c4'
git-subtree-dir: packages/test-simple
git-subtree-mainline: bfb36f072e1d8b382639bd5cc6087fb0c963894b
git-subtree-split: 75eea25bae04d8e5e3e835a2770f02f0ff4602c4
---
packages/test-simple/.gitignore | 14 ++
packages/test-simple/.travis.yml | 8 +
packages/test-simple/AUTHORS | 2 +
packages/test-simple/COPYING | 340 ++++++++++++++++++++++++++++
packages/test-simple/Carton | 4 +
packages/test-simple/INSTALL | 18 ++
packages/test-simple/Makefile.am | 46 ++++
packages/test-simple/NEWS | 5 +
packages/test-simple/README.md | 71 ++++++
packages/test-simple/THANKS | 1 +
packages/test-simple/autogen.sh | 7 +
packages/test-simple/common.mk | 5 +
packages/test-simple/compute-lispdir.sh | 46 ++++
packages/test-simple/configure.ac | 44 ++++
packages/test-simple/elisp-comp | 94 ++++++++
packages/test-simple/example/gcd.el | 13 +
packages/test-simple/example/test-gcd.el | 20 ++
packages/test-simple/install-from-git.sh | 94 ++++++++
packages/test-simple/make-check-filter.rb | 21 ++
packages/test-simple/test-simple.el | 336 +++++++++++++++++++++++++++
packages/test-simple/test/.gitignore | 2 +
packages/test-simple/test/Makefile.am | 29 +++
packages/test-simple/test/test-basic.el | 13 +
packages/test-simple/test/test-fns.el | 23 ++
packages/test-simple/test/test-no-clear.el | 11 +
25 files changed, 1267 insertions(+), 0 deletions(-)
diff --git a/packages/test-simple/.gitignore b/packages/test-simple/.gitignore
new file mode 100644
index 0000000..0b38301
--- /dev/null
+++ b/packages/test-simple/.gitignore
@@ -0,0 +1,14 @@
+*elc
+*~
+/Makefile
+/Makefile.in
+/aclocal.m4
+/autom4te.cache
+/config.log
+/config.status
+/configure
+/elc-stamp
+/install-sh
+/missing
+/script
+/README
diff --git a/packages/test-simple/.travis.yml b/packages/test-simple/.travis.yml
new file mode 100644
index 0000000..9280a20
--- /dev/null
+++ b/packages/test-simple/.travis.yml
@@ -0,0 +1,8 @@
+language: emacs
+
+install:
+ # Install emacs.
+ - "sudo apt-get install emacs23-nox"
+
+# run the tests
+script: /bin/sh ./autogen.sh && make check
diff --git a/packages/test-simple/AUTHORS b/packages/test-simple/AUTHORS
new file mode 100644
index 0000000..772a532
--- /dev/null
+++ b/packages/test-simple/AUTHORS
@@ -0,0 +1,2 @@
+Rocky Bernstein (address@hidden) adapted from Phil Hagelberg's behave.el
+
diff --git a/packages/test-simple/COPYING b/packages/test-simple/COPYING
new file mode 100644
index 0000000..60549be
--- /dev/null
+++ b/packages/test-simple/COPYING
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) 19yy <name of author>
+
+ 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 of the License, 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) 19yy name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/packages/test-simple/Carton b/packages/test-simple/Carton
new file mode 100644
index 0000000..b039f40
--- /dev/null
+++ b/packages/test-simple/Carton
@@ -0,0 +1,4 @@
+(source "melpa" "http://melpa.milkbox.net/packages/")
+
+(package "test-simple" "0.2.1"
+ "Unit tests for GNU emacs that work interactively and in batch")
diff --git a/packages/test-simple/ChangeLog b/packages/test-simple/ChangeLog
new file mode 100644
index 0000000..e69de29
diff --git a/packages/test-simple/INSTALL b/packages/test-simple/INSTALL
new file mode 100644
index 0000000..20f7800
--- /dev/null
+++ b/packages/test-simple/INSTALL
@@ -0,0 +1,18 @@
+This package is now installable from inside Emacs and melpa.
+
+We have an old-style GNU autoconf configuration as well and an install
+script to pick that up from git sources. For this, you will need:
+
+ * Emacs, of course. Version 23 or better
+ * _autoconf_ and _autoreconf_ to build the configure script. Usually
_autoreconf_ comes with an "autoconf" package
+ * GNU Make -- or even better "remake":http//bashdb.sf.net/remake
+
+If you are feeling lucky, you can try running the install script from the
github repository:
+
+ $ bash < <( curl
https://raw.github.com/rocky/emacs-test-simple/master/install-from-git.sh )
+
+Otherwise:
+
+ git clone http://github.com/rocky/emacs-test-simple
+ cd emacs-test-simple
+ ./configure && make && [sudo] make install
diff --git a/packages/test-simple/Makefile.am b/packages/test-simple/Makefile.am
new file mode 100644
index 0000000..524deb2
--- /dev/null
+++ b/packages/test-simple/Makefile.am
@@ -0,0 +1,46 @@
+# Note: This makefile include remake-style target comments.
+# These comments before the targets start with #:
+# remake --tasks to shows the targets and the comments
+
+GIT2CL ?= git2cl
+RUBY ?= ruby
+
+lisp_files := $(wildcard *.el)
+lisp_LISP = $(lisp_files)
+test_files := $(wildcard test/*.el)
+
+EXTRA_DIST = $(lisp_files) $(test_files) README THANKS README.md COPYING
+
+CHECK_FILES = $(notdir $(test_files:.el=.run))
+
+
+check: $(test-files)
+ $(MAKE) -C test check
+
+README: README.textile
+ ln -s README.md README
+
+PHONY=check clean dist distclean test check-short check-terse install-short
+
+if MAINTAINER_MODE
+
+ChangeLog:
+ git log --pretty --numstat --summary | $(GIT2CL) > $@
+
+ACLOCAL_AMFLAGS=-I .
+
+endif
+
+#: Run all tests
+test: check
+
+check-short:
+ $(MAKE) -C test check 2>&1 | ruby make-check-filter.rb
+
+#: Run all tests without and show just the failure lines
+check-terse:
+ $(MAKE) check 2>&1 | $(RUBY) make-check-filter.rb | grep failure
+
+#: Run "make install"
+install-short:
+ $(MAKE) install 2>&1 | $(RUBY) make-check-filter.rb
diff --git a/packages/test-simple/NEWS b/packages/test-simple/NEWS
new file mode 100644
index 0000000..f35d826
--- /dev/null
+++ b/packages/test-simple/NEWS
@@ -0,0 +1,5 @@
+1.0
+Initial Melpa release
+
+0.2
+Initial Release
diff --git a/packages/test-simple/README.md b/packages/test-simple/README.md
new file mode 100644
index 0000000..7a473b0
--- /dev/null
+++ b/packages/test-simple/README.md
@@ -0,0 +1,71 @@
+[![Build
Status](https://travis-ci.org/rocky/emacs-test-simple.png)](https://travis-ci.org/rocky/emacs-test-simple)
+
+*test-simple.el* is :
+
+* Simple -- no need for context macros, enclosing specifications, or required
test tags. But if you want, you still can add custom assert failure messages or
add notes before a group of tests.
+* Accomodates both interactive and non-interactive use:
+ * For interactive use one can use `eval-last-sexp`, `eval-region`, and
`eval-buffer`
+ * For non-interactive use run as: `emacs --batch --no-site-file --no-splash
--load <test-lisp-code.el>`
+
+I use this in my [Debugger front end](https://github.com/rocky/emacs-dbgr).
+
+Here is an example found in the [examples
directory](https://github.com/rocky/emacs-test-simple/tree/master/test).
+
+In file `gcd.el`:
+
+ (defun gcd(a b)
+ "Greatest Common Divisor of A and B"
+ ;; Make a < b
+ (if (> a b)
+ (let ((c a))
+ (setq a b)
+ (setq b c)))
+ (cond
+ ((< a 0) nil)
+ ((or (= 0 (- b a)) (= a 1)) a)
+ (t (gcd (- b a) a))
+ )
+ )
+
+
+In file `test-gcd.el` in the same directory:
+
+ (require 'test-simple)
+ (test-simple-start) ;; Zero counters and start the stop watch.
+
+ ;; Use (load-file) below because we want to always to read the source.
+ ;; Also, we don't want no stinking compiled source.
+ (assert-t (load-file "./gcd.el")
+ "Can't load gcd.el - are you in the right directory?" )
+
+ (note "degenerate cases")
+
+ (assert-nil (gcd 5 -1) "using positive numbers")
+ (assert-nil (gcd -4 1) "using positive numbers, switched order")
+ (assert-raises error (gcd "a" 32)
+ "Passing a string value should raise an error")
+
+ (note "GCD computations")
+ (assert-equal 1 (gcd 3 5) "gcd(3,5)")
+ (assert-equal 8 (gcd 8 32) "gcd(8,32)")
+
+ (end-tests) ;; Stop the clock and print a summary
+
+Edit (with Emacs of course) `test-gcd.el` and run `M-x eval-current-buffer`
+
+You should see in buffer `*test-simple*`:
+
+ test-gcd.el
+ ......
+ 0 failures in 6 assertions (0.002646 seconds)
+
+Now let's try from a command line:
+
+ $ emacs --batch --no-site-file --no-splash --load test-gcd.el
+ Loading /src/external-vcs/emacs-test-simple/example/gcd.el (source)...
+ *scratch*
+ ......
+ 0 failures in 6 assertions (0.000723 seconds)
+
+*Author:* Rocky Bernstein <address@hidden> <br>
+[![endorse](https://api.coderwall.com/rocky/endorsecount.png)](https://coderwall.com/rocky)
diff --git a/packages/test-simple/THANKS b/packages/test-simple/THANKS
new file mode 100644
index 0000000..4dae07d
--- /dev/null
+++ b/packages/test-simple/THANKS
@@ -0,0 +1 @@
+Lars Andersen (expez) - Getting this packaged and put on to Melpa.
diff --git a/packages/test-simple/autogen.sh b/packages/test-simple/autogen.sh
new file mode 100755
index 0000000..5f00302
--- /dev/null
+++ b/packages/test-simple/autogen.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+cp README.md README
+autoreconf -vi && \
+autoconf && {
+ echo "Running configure with --enable-maintainer-mode $@"
+ ./configure --enable-maintainer-mode $@
+}
diff --git a/packages/test-simple/common.mk b/packages/test-simple/common.mk
new file mode 100644
index 0000000..26b6325
--- /dev/null
+++ b/packages/test-simple/common.mk
@@ -0,0 +1,5 @@
+short:
+ $(MAKE) 2>&1 >/dev/null | ruby $(top_srcdir)/make-check-filter.rb
+
+%.short:
+ $(MAKE) $(@:.short=) 2>&1 >/dev/null
diff --git a/packages/test-simple/compute-lispdir.sh
b/packages/test-simple/compute-lispdir.sh
new file mode 100755
index 0000000..dba43c9
--- /dev/null
+++ b/packages/test-simple/compute-lispdir.sh
@@ -0,0 +1,46 @@
+#!/bin/bash
+# Figures out a reasonable --prefix
+typeset -i rc=0
+typeset -i DEBUG=${DEBUG:-0}
+EMACS_PROG=${EMACS_PROG:-emacs}
+list=$($EMACS_PROG --batch --no-splash --eval '(message (substring (format
"%s" load-path) 1 -1))' 2>&1)
+rc=$?
+if (( rc != 0 )) ; then
+ echo >&2 "Something went running $EMACS_PROG"
+ exit $rc
+$cmd
+fi
+for dir in $list ; do
+ if [[ -d $dir ]] ; then
+ case $dir in
+ */emacs/site-lisp)
+ ((DEBUG)) && echo "site lisp: $dir"
+ echo "$dir"
+ exit 0
+ ;;
+ esac
+ fi
+done
+for dir in $list ; do
+ if [[ -d $dir ]] ; then
+ case $dir in
+ */emacs/2[34]\.[0-9]/site-lisp)
+ ((DEBUG)) && echo "versioned site lisp: $dir"
+ echo "$dir"
+ exit 0
+ ;;
+ esac
+ fi
+done
+for dir in $list ; do
+ if [[ -d $dir ]] ; then
+ case $dir in
+ */emacs/2[34]\.[0-9]/site-lisp)
+ ((DEBUG)) && echo "versioned site lisp: $dir"
+ echo "$dir"
+ exit 0
+ ;;
+ esac
+ fi
+done
+exit 0
diff --git a/packages/test-simple/configure.ac
b/packages/test-simple/configure.ac
new file mode 100644
index 0000000..ae0cbee
--- /dev/null
+++ b/packages/test-simple/configure.ac
@@ -0,0 +1,44 @@
+dnl FIXME: pick up from test-simple.el
+AC_INIT(emacs-test-simple, 1.0,)
+AC_CONFIG_SRCDIR(test-simple.el)
+AM_INIT_AUTOMAKE([foreign])
+AM_MAINTAINER_MODE
+
+AC_PATH_PROG([EMACS], [emacs], [emacs])
+AC_MSG_NOTICE("Checking emacs version and prerequiste packages")
+$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 until above error is corrected.])
+fi
+
+##################################################################
+# See if --with-lispdir was set. If not, set it to a reasonable default
+# based on where bash thinks bashdb is supposed to be installed.
+##################################################################
+
+AM_MISSING_PROG(GIT2CL, git2cl, $missing_dir)
+
+# Check whether --with-lispdir was given.
+if test "${with_lispdir+set}" = set -o "${prefix+set}" = set; then :
+else
+ my_lispdir=$(EMACS_PROG=$EMACS $SH_PROG $(dirname $0)/compute-lispdir.sh)
+ if test "${my_lispdir+set}" = set; then :
+ with_lispdir=$my_lispdir
+ echo "'compute-lispdir.sh' lispdir install directory override:
'$with_lispdir'"
+ fi
+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 test/Makefile])
+AC_OUTPUT
diff --git a/packages/test-simple/elisp-comp b/packages/test-simple/elisp-comp
new file mode 100755
index 0000000..ecc6b15
--- /dev/null
+++ b/packages/test-simple/elisp-comp
@@ -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 <address@hidden>, 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 <address@hidden> or send patches to
+# <address@hidden>.
+
+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 <address@hidden>.
+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:
diff --git a/packages/test-simple/example/gcd.el
b/packages/test-simple/example/gcd.el
new file mode 100644
index 0000000..9a1ac20
--- /dev/null
+++ b/packages/test-simple/example/gcd.el
@@ -0,0 +1,13 @@
+(defun gcd(a b)
+ "Greatest Common Divisor of A and B"
+ ;; Make a < b
+ (if (> a b)
+ (let ((c a))
+ (setq a b)
+ (setq b c)))
+ (cond
+ ((< a 0) nil)
+ ((or (= 0 (- b a)) (= a 1)) a)
+ (t (gcd (- b a) a))
+ )
+)
diff --git a/packages/test-simple/example/test-gcd.el
b/packages/test-simple/example/test-gcd.el
new file mode 100644
index 0000000..ce4ccae
--- /dev/null
+++ b/packages/test-simple/example/test-gcd.el
@@ -0,0 +1,20 @@
+(require 'test-simple)
+
+(test-simple-start)
+
+(assert-t (load-file "./gcd.el")
+ "Can't load gcd.el - are you in the right directory?" )
+
+(note "degenereate cases")
+
+(assert-nil (gcd 5 -1) "using positive numbers")
+(assert-nil (gcd -4 1) "using positive numbers, switched order")
+
+(note "GCD computations")
+(assert-equal 1 (gcd 3 5) "gcd(3,5)")
+(assert-equal 8 (gcd 8 32) "gcd(8,32)")
+
+(assert-raises error (gcd "a" 32)
+ "Passing a string value should raise an error")
+
+(end-tests)
diff --git a/packages/test-simple/install-from-git.sh
b/packages/test-simple/install-from-git.sh
new file mode 100755
index 0000000..6034983
--- /dev/null
+++ b/packages/test-simple/install-from-git.sh
@@ -0,0 +1,94 @@
+#!/bin/bash
+# This installs all emcs-test-simple and its prerequisites. If you are lucky
+# you can just run this:
+#
+# bash ./install-from-git.sh
+#
+# However we do provide for some customization...
+#
+# 1. GIT PROTOCOL
+# ===============
+#
+# If your "git clone" can't handle the "http" protocol, you might be
+# able to use the "git" protocol. To do this set the GIT_PROTOCOL
+# variable like this:
+#
+# GIT_PROTOCOL=git sh ./install-from-git.sh
+#
+# 2. configure options (e.g --prefix)
+# ====================================
+
+# If you want to customize configuration parameters, for example,
+# choose where to install, you can pass configure options to this
+# script. For example:# can pass configure options.
+#
+# sh ./install-from-git.sh --prefix=/tmp
+#
+# 3. TO "sudo" or not to "sudo"?
+# ==============================
+# If you are running as root on a *Nix-like box, then there's no problem.
+#
+# If you are not running as root, "sudo" might be invoked to install
+# code. On systems that don't have a "sudo" command but need
+# filesystem permission, then you get by with setting SUDO_CMD to "su root-c"
+# For example:
+#
+# SUDO_CMD='su root -c' sh ./install-from-git.sh
+#
+# If you have sufficient filesystem permission (which is often the
+# case on Windows or cygwin) then you might not need or want sudo. So
+# here, set SUDO_CMD to a blank:
+#
+# SUDO_CMD=' ' sh ./install-from-git.sh
+#
+#
+# To finish here is an invocation using all 3 above options:
+# GIT_PROTOCOL='git' SUDO_CMD=' ' sh ./install-from-git.sh --prefix=/tmp
+
+GIT_PROTOCOL=${GIT_PROTOCOL:-http}
+
+run_cmd() {
+ echo "--- Running command: $@"
+ $@
+ rc=$?
+ echo "--- $@ exit status is $?"
+ return $rc
+}
+
+if (( $(id -u) != 0)) ; then
+ if [[ -z "$SUDO_CMD" ]] ; then
+ need_sudo='sudo'
+ if which $need_sudo >/dev/null 2>&1 ; then
+ try_cmd=''
+ else
+ need_sudo='su root -c'
+ try_cmd='su'
+ fi
+ else
+ need_sudo="$SUDO_CMD"
+ fi
+else
+ need_sudo=''
+ try_cmd=''
+fi
+
+for program in git make $try_cmd ; do
+ if ! which $program >/dev/null 2>&1 ; then
+ echo "Cant find program $program in $PATH"
+ exit 1
+ fi
+done
+
+for pkg in emacs-test-simple ; do
+ echo '******************************************'
+ echo Trying to install ${pkg}...
+ echo '******************************************'
+ run_cmd git clone ${GIT_PROTOCOL}://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
diff --git a/packages/test-simple/make-check-filter.rb
b/packages/test-simple/make-check-filter.rb
new file mode 100755
index 0000000..daee7c9
--- /dev/null
+++ b/packages/test-simple/make-check-filter.rb
@@ -0,0 +1,21 @@
+#!/usr/bin/env ruby
+# Use this to cut out the crud from make check.
+# Use like this:
+# make check 2>&1 | ruby ../make-check-filter.rb
+# See Makefile.am
+pats = ["^(?:Loading",
+ 'make\[',
+ "Making check in",
+ '\(cd \.\.',
+ "make -C",
+ "Test-Unit",
+ "Fontifying",
+ '\s*$'
+ ].join('|') + ')'
+# puts pats
+skip_re = /#{pats}/
+
+while gets()
+ next if $_ =~ skip_re
+ puts $_
+end
diff --git a/packages/test-simple/test-simple.el
b/packages/test-simple/test-simple.el
new file mode 100644
index 0000000..dde4bad
--- /dev/null
+++ b/packages/test-simple/test-simple.el
@@ -0,0 +1,336 @@
+;;; test-simple.el --- Simple Unit Test Framework for Emacs Lisp
+;; Rewritten from Phil Hagelberg's behave.el by rocky
+
+;; Copyright (C) 2010, 2012-2013, 2014 Rocky Bernstein
+
+;; Author: Rocky Bernstein
+;; URL: http://github.com/rocky/emacs-test-simple
+;; Keywords: unit-test
+;; Version: 1.0
+
+;; This file is NOT part of GNU Emacs.
+
+;; 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 3 of the
+;; License, 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/>.
+
+;;; Commentary:
+
+;; test-simple.el is:
+;;
+;; * Simple. No need for
+;; - context macros,
+;; - enclosing specifications,
+;; - required test tags.
+;;
+;; But if you want, you still can enclose tests in a local scope,
+;; add customized assert failure messages, or add summary messages
+;; before a group of tests.
+;;
+;; * Accomodates both interactive and non-interactive use.
+;; - For interactive use, one can use `eval-last-sexp', `eval-region',
+;; and `eval-buffer'. One can `edebug' the code.
+;; - For non-interactive use, run:
+;; emacs --batch --no-site-file --no-splash --load <test-lisp-code.el>
+;;
+;; Here is an example using gcd.el found in the examples directory.
+;;
+;; (require 'test-simple)
+;; (test-simple-start) ;; Zero counters and start the stop watch.
+;;
+;; ;; Use (load-file) below because we want to always to read the source.
+;; ;; Also, we don't want no stinking compiled source.
+;; (assert-t (load-file "./gcd.el")
+;; "Can't load gcd.el - are you in the right directory?" )
+;;
+;; (note "degenerate cases")
+;;
+;; (assert-nil (gcd 5 -1) "using positive numbers")
+;; (assert-nil (gcd -4 1) "using positive numbers, switched order")
+;; (assert-raises error (gcd "a" 32)
+;; "Passing a string value should raise an error")
+;;
+;; (note "GCD computations")
+;; (assert-equal 1 (gcd 3 5) "gcd(3,5)")
+;; (assert-equal 8 (gcd 8 32) "gcd(8,32)")
+;; (end-tests) ;; Stop the clock and print a summary
+;;
+;; Edit (with Emacs of course) test-gcd.el and run M-x eval-current-buffer
+;;
+;; You should see in buffer *test-simple*:
+;;
+;; test-gcd.el
+;; ......
+;; 0 failures in 6 assertions (0.002646 seconds)
+;;
+;; Now let us try from a command line:
+;;
+;; $ emacs --batch --no-site-file --no-splash --load test-gcd.el
+;; Loading /src/external-vcs/emacs-test-simple/example/gcd.el (source)...
+;; *scratch*
+;; ......
+;; 0 failures in 6 assertions (0.000723 seconds)
+
+;;; To do:
+
+;; Main issues: more expect predicates
+
+(require 'time-date)
+
+;;; Code:
+
+(eval-when-compile
+ (byte-compile-disable-warning 'cl-functions)
+ ;; Somehow disabling cl-functions causes the erroneous message:
+ ;; Warning: the function `reduce' might not be defined at runtime.
+ ;; FIXME: isolate, fix and/or report back to Emacs developers a bug
+ ;; (byte-compile-disable-warning 'unresolved)
+ (require 'cl)
+ )
+(require 'cl)
+
+(defvar test-simple-debug-on-error nil
+ "If non-nil raise an error on the first failure.")
+
+(defvar test-simple-verbosity 0
+ "The greater the number the more verbose output.")
+
+(defstruct test-info
+ description ;; description of last group of tests
+ (assert-count 0) ;; total number of assertions run
+ (failure-count 0) ;; total number of failures seen
+ (start-time (current-time)) ;; Time run started
+ )
+
+(defvar test-simple-info (make-test-info)
+ "Variable to store testing information for a buffer.")
+
+(defun note (description &optional test-info)
+ "Adds a name to a group of tests."
+ (if (getenv "USE_TAP")
+ (test-simple-msg (format "# %s" description) 't)
+ (if (> test-simple-verbosity 0)
+ (test-simple-msg (concat "\n" description) 't))
+ (unless test-info
+ (setq test-info test-simple-info))
+ (setf (test-info-description test-info) description)
+ ))
+
+;;;###autoload
+(defmacro test-simple-start (&optional test-start-msg)
+ `(test-simple-clear nil
+ (or ,test-start-msg
+ (if (and (functionp '__FILE__) (__FILE__))
+ (file-name-nondirectory (__FILE__))
+ (buffer-name)))
+ ))
+
+;;;###autoload
+(defun test-simple-clear (&optional test-info test-start-msg)
+ "Initializes and resets everything to run tests. You should run
+this before running any assertions. Running more than once clears
+out information from the previous run."
+
+ (interactive)
+
+ (unless test-info
+ (unless test-simple-info
+ (make-variable-buffer-local (defvar test-simple-info (make-test-info))))
+ (setq test-info test-simple-info))
+
+ (setf (test-info-description test-info) "none set")
+ (setf (test-info-start-time test-info) (current-time))
+ (setf (test-info-assert-count test-info) 0)
+ (setf (test-info-failure-count test-info) 0)
+
+ (with-current-buffer (get-buffer-create "*test-simple*")
+ (let ((old-read-only inhibit-read-only))
+ (setq inhibit-read-only 't)
+ (delete-region (point-min) (point-max))
+ (if test-start-msg (insert (format "%s\n" test-start-msg)))
+ (setq inhibit-read-only old-read-only)))
+ (unless noninteractive
+ (message "Test-Simple: test information cleared")))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Assertion tests
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defmacro assert-raises (error-condition body &optional fail-message test-info)
+ (let ((fail-message (or fail-message
+ (format "assert-raises did not get expected %s"
+ error-condition))))
+ (list 'condition-case nil
+ (list 'progn body
+ (list 'assert-t nil fail-message test-info))
+ (list error-condition '(assert-t t)))))
+
+(defun assert-op (op expected actual &optional fail-message test-info)
+ "expectation is that ACTUAL should be equal to EXPECTED."
+ (unless test-info (setq test-info test-simple-info))
+ (incf (test-info-assert-count test-info))
+ (if (not (funcall op actual expected))
+ (let* ((fail-message
+ (if fail-message
+ (format "Message: %s" fail-message)
+ ""))
+ (expect-message
+ (format "\n Expected: %s\n Got: %s" expected actual))
+ (test-info-mess
+ (if (boundp 'test-info)
+ (test-info-description test-info)
+ "unset")))
+ (add-failure (format "assert-%s" op) test-info-mess
+ (concat fail-message expect-message)))
+ (ok-msg fail-message)))
+
+(defun assert-equal (expected actual &optional fail-message test-info)
+ "expectation is that ACTUAL should be equal to EXPECTED."
+ (assert-op 'equal expected actual fail-message test-info))
+
+(defun assert-eq (expected actual &optional fail-message test-info)
+ "expectation is that ACTUAL should be EQ to EXPECTED."
+ (assert-op 'eql expected actual fail-message test-info))
+
+(defun assert-eql (expected actual &optional fail-message test-info)
+ "expectation is that ACTUAL should be EQL to EXPECTED."
+ (assert-op 'eql expected actual fail-message test-info))
+
+(defun assert-matches (expected-regexp actual &optional fail-message test-info)
+ "expectation is that ACTUAL should match EXPECTED-REGEXP."
+ (unless test-info (setq test-info test-simple-info))
+ (incf (test-info-assert-count test-info))
+ (if (not (string-match expected-regexp actual))
+ (let* ((fail-message
+ (if fail-message
+ (format "\n\tMessage: %s" fail-message)
+ ""))
+ (expect-message
+ (format "\tExpected Regexp: %s\n\tGot: %s"
+ expected-regexp actual))
+ (test-info-mess
+ (if (boundp 'test-info)
+ (test-info-description test-info)
+ "unset")))
+ (add-failure "assert-equal" test-info-mess
+ (concat expect-message fail-message)))
+ (progn (test-simple-msg ".") t)))
+
+(defun assert-t (actual &optional fail-message test-info)
+ "expectation is that ACTUAL is not nil."
+ (assert-nil (not actual) fail-message test-info "assert-t"))
+
+(defun assert-nil (actual &optional fail-message test-info assert-type)
+ "expectation is that ACTUAL is nil. FAIL-MESSAGE is an optional
+additional message to be displayed. Since several assertions
+funnel down to this one, ASSERT-TYPE is an optional type."
+ (unless test-info (setq test-info test-simple-info))
+ (incf (test-info-assert-count test-info))
+ (if actual
+ (let* ((fail-message
+ (if fail-message
+ (format "\n\tMessage: %s" fail-message)
+ ""))
+ (test-info-mess
+ (if (boundp 'test-simple-info)
+ (test-info-description test-simple-info)
+ "unset")))
+ (add-failure "assert-nil" test-info-mess fail-message test-info))
+ (ok-msg fail-message)))
+
+(defun add-failure(type test-info-msg fail-msg &optional test-info)
+ (unless test-info (setq test-info test-simple-info))
+ (incf (test-info-failure-count test-info))
+ (let ((failure-msg
+ (format "\nDescription: %s, type %s\n%s" test-info-msg type fail-msg))
+ (old-read-only inhibit-read-only)
+ )
+ (save-excursion
+ (not-ok-msg fail-msg)
+ (test-simple-msg failure-msg 't)
+ (unless noninteractive
+ (if test-simple-debug-on-error
+ (signal 'test-simple-assert-failed failure-msg)
+ ;;(message failure-msg)
+ )))))
+
+(defun end-tests (&optional test-info)
+ "Give a tally of the tests run"
+ (interactive)
+ (unless test-info (setq test-info test-simple-info))
+ (test-simple-describe-failures test-info)
+ (if noninteractive
+ (progn
+ (switch-to-buffer "*test-simple*")
+ (message "%s" (buffer-substring (point-min) (point-max)))
+ )
+ (switch-to-buffer-other-window "*test-simple*")
+ ))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Reporting
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defun test-simple-msg(msg &optional newline)
+ (switch-to-buffer "*test-simple*")
+ (let ((old-read-only inhibit-read-only))
+ (setq inhibit-read-only 't)
+ (insert msg)
+ (if newline (insert "\n"))
+ (setq inhibit-read-only old-read-only)
+ (switch-to-buffer nil)
+ ))
+
+(defun ok-msg(fail-message &optional test-info)
+ (unless test-info (setq test-info test-simple-info))
+ (let ((msg (if (getenv "USE_TAP")
+ (if (equal fail-message "")
+ (format "ok %d\n" (test-info-assert-count test-info))
+ (format "ok %d - %s\n"
+ (test-info-assert-count test-info)
+ fail-message))
+ ".")))
+ (test-simple-msg msg))
+ 't)
+
+(defun not-ok-msg(fail-message &optional test-info)
+ (unless test-info (setq test-info test-simple-info))
+ (let ((msg (if (getenv "USE_TAP")
+ (format "not ok %d\n" (test-info-assert-count test-info))
+ "F")))
+ (test-simple-msg msg))
+ nil)
+
+(defun test-simple-summary-line(info)
+ (let*
+ ((failures (test-info-failure-count info))
+ (asserts (test-info-assert-count info))
+ (problems (concat (number-to-string failures) " failure"
+ (unless (= 1 failures) "s")))
+ (tests (concat (number-to-string asserts) " assertion"
+ (unless (= 1 asserts) "s")))
+ (elapsed-time (time-since (test-info-start-time info)))
+ )
+ (if (getenv "USE_TAP")
+ (format "1..%d" asserts)
+ (format "\n%s in %s (%g seconds)" problems tests
+ (float-time elapsed-time))
+ )))
+
+(defun test-simple-describe-failures(&optional test-info)
+ (unless test-info (setq test-info test-simple-info))
+ (goto-char (point-max))
+ (test-simple-msg (test-simple-summary-line test-info)))
+
+(provide 'test-simple)
+;;; test-simple.el ends here
diff --git a/packages/test-simple/test/.gitignore
b/packages/test-simple/test/.gitignore
new file mode 100644
index 0000000..b336cc7
--- /dev/null
+++ b/packages/test-simple/test/.gitignore
@@ -0,0 +1,2 @@
+/Makefile
+/Makefile.in
diff --git a/packages/test-simple/test/Makefile.am
b/packages/test-simple/test/Makefile.am
new file mode 100644
index 0000000..cd86850
--- /dev/null
+++ b/packages/test-simple/test/Makefile.am
@@ -0,0 +1,29 @@
+include $(top_srcdir)/common.mk
+
+PHONY=check test all
+EXTRA_DIST=gcd.py gcd.rb
+
+all:
+
+#: same thing as "check"
+test: check
+
+test_files := $(wildcard test-*.el)
+
+CHECK_FILES = $(notdir $(test_files:.el=.run))
+
+#: Run all tests
+check: $(CHECK_FILES)
+
+#: Run all tests with minimum verbosity
+check-short:
+ $(MAKE) check 2>&1 | ruby ../make-check-filter.rb
+
+test-%.run:
+ (cd $(top_srcdir)/test && $(EMACS) --batch --no-site-file --no-splash
--load $(@:.run=.el))
+
+# Whatever it is you want to do, it should be forwarded to the
+# to top-level directories
+%:
+ $(MAKE) -C .. $@
+
diff --git a/packages/test-simple/test/test-basic.el
b/packages/test-simple/test/test-basic.el
new file mode 100644
index 0000000..72cb5b3
--- /dev/null
+++ b/packages/test-simple/test/test-basic.el
@@ -0,0 +1,13 @@
+(require 'cl)
+(load-file "../test-simple.el")
+(test-simple-start "test-simple.el")
+
+(note "basic-tests")
+(assert-t (memq 'test-simple features) "'test-simple provided")
+
+(assert-nil nil "assert-nil failure test")
+(assert-nil nil "Knights if ni")
+(assert-equal 5 (+ 1 4) "assert-equal")
+(assert-raises error (error "you should not see this") "assert-raises")
+
+(end-tests)
diff --git a/packages/test-simple/test/test-fns.el
b/packages/test-simple/test/test-fns.el
new file mode 100644
index 0000000..c690289
--- /dev/null
+++ b/packages/test-simple/test/test-fns.el
@@ -0,0 +1,23 @@
+(require 'cl)
+(load-file "../test-simple.el")
+(test-simple-clear)
+
+(setq test-info (make-test-info))
+(test-simple-clear test-info)
+
+(note "Initializing test information")
+(assert-equal 0 (test-info-assert-count test-info) "Count zeroed")
+(assert-equal 0 (test-info-failure-count test-info) "Failure zeroed")
+
+(note "Summary information")
+(assert-matches "0 failures in 0 assertions" (test-simple-summary-line
test-info)
+ "initial summary")
+(incf (test-info-assert-count test-info))
+(incf (test-info-failure-count test-info))
+(assert-matches "1 failure in 1 assertion" (test-simple-summary-line test-info)
+ "handling singular correctly")
+(incf (test-info-assert-count test-info))
+(assert-matches "1 failure in 2 assertions" (test-simple-summary-line
test-info)
+ "back to plural for two assertions")
+
+(end-tests)
diff --git a/packages/test-simple/test/test-no-clear.el
b/packages/test-simple/test/test-no-clear.el
new file mode 100644
index 0000000..5ac81a4
--- /dev/null
+++ b/packages/test-simple/test/test-no-clear.el
@@ -0,0 +1,11 @@
+(require 'cl)
+(load-file "../test-simple.el")
+;; We don't do this or test-simple-start
+;; (test-simple-clear)
+
+(note "no-test-start")
+(assert-t (memq 'test-simple features) "'test-simple provided")
+
+(assert-nil nil)
+
+(end-tests)