Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.3 #4

Merged
merged 25 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
on: [push]
jobs:
tests:
strategy:
matrix:
os:
- ubuntu-latest
# - macos-latest
# - windows-latest
lisp:
- sbcl-bin
# - ecl
# - ccl-bin
# - abcl-bin
# - clasp-bin
# - cmu-bin
# - clisp-head
runs-on: ${{ matrix.os }}
env:
LISP: ${{ matrix.lisp }}
steps:
- uses: actions/checkout@v4
- uses: 40ants/setup-lisp@v4
with:
asdf-system: sijo-doctest
qlfile-template: |
dist ultralisp http://dist.ultralisp.org
- uses: 40ants/run-tests@v2
with:
asdf-system: sijo-doctest
35 changes: 18 additions & 17 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
*.FASL
*.fasl
*.lisp-temp
*.dfsl
*.pfsl
*.d64fsl
*.p64fsl
*.lx64fsl
*.lx32fsl
*.dx64fsl
*.dx32fsl
*.fx64fsl
*.fx32fsl
*.sx64fsl
*.sx32fsl
*.wx64fsl
*.wx32fsl
*.FASL
*.fasl
*.fas
*.lisp-temp
*.dfsl
*.pfsl
*.d64fsl
*.p64fsl
*.lx64fsl
*.lx32fsl
*.dx64fsl
*.dx32fsl
*.fx64fsl
*.fx32fsl
*.sx64fsl
*.sx32fsl
*.wx64fsl
*.wx32fsl
43 changes: 43 additions & 0 deletions CHANGELOG.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
* Changelog
All notable changes to this project will be documented in this file.

The format is based on [[https://keepachangelog.com/en/1.1.0][Keep a Changelog]], and this project *DOES NOT* adhere to [[https://semver.org/spec/v2.0.0.html][Semantic
Versioning]].

** [[https://github.com/simendsjo/sijo-doctest/compare/v0.2..v0.3][0.3.0]] - 2024-03-11
*** Added
- Support Embedded Common Lisp (ECL)
- Support Clozure Common Lisp (CCL)
- Support Armed Bear Common Lisp (ABCL)
- ~test-docstring~ for testing strings -- simplifies testing
- ~test-variable~ for testing variables
*** Changed
- Don't require an exact error, but rather a subclass of the expected error,
e.g. expecting ~type-error~ will allow a subclass like ~simple-type-error~.
- The general ~test~ is exported
- ~test~ runs ~test-package~ for ~package~
- ~test~ supports ~null~
- ~test~ supports ~string~
- ~test~ for symbol will test both variable and function/macro bound to that symbol
- Number of failed/passed tests is always returned, also when there are no
doctests for a thing, rather than ~nil~
*** Deprecated
*** Removed
*** Fixed
- ~test-package~ only includes symbols for the package under test
- ~test-package~ works for macros
*** Security

** [[https://github.com/simendsjo/sijo-doctest/commit/039516e828b5737569350a13ffc90c2d8346ad8c][0.2.0]] - 2024-03-01
*** Added
- ~test-package~ function to test all functions in a package
*** Changed
- Tweaked to evaluate expected results to avoid problems with ~fset~ and
readtables; ~#{||}~ cannot be used, and ~(fset:empty-map)~ neither
- Improved working with multiple values
- Print only when tests are failing (useful when testing entire packages)
*** Deprecated
*** Removed
*** Fixed
- ~run-doctests~ doesn't throw on empty docstring (triggered eof error)
*** Security
File renamed without changes.
41 changes: 13 additions & 28 deletions README.org
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Doctests for Lisp
[[https://github.com/simendsjo/sijo-doctest/actions/workflows/tests.yaml/badge.svg][Build badge]]

* Doctests for Lisp

See [[file:CHANGELOG.org][CHANGELOG]].

** Installation
Clone repository
#+begin_src bash
git clone [email protected]:simendsjo/sijo-doctest.git ~/quicklisp/local-projects/sijo-doctest
Expand All @@ -10,6 +15,7 @@ Load library
(ql:quickload :sijo-doctest)
#+end_src

** Usage
Write some doctests
#+begin_src lisp
(defun square (x)
Expand All @@ -24,27 +30,12 @@ Write some doctests
(* x x))
#+end_src

See [[file:doctest.lisp::defun test (thing &key (output t)][doctest.lisp::test]] for full documentation or look at the documentation for
the function directly
#+begin_src lisp :wrap quote :exports both
(documentation 'sijo-doctest::test 'function)
#+end_src

#+RESULTS:
#+begin_quote
Test extracts and tests code snippets embedded in the documentation string
of <thing>. It returns the number of tests failed and passed and prints a
description to <output>.

In order to have...[sly-elided string of length 3067]
#+end_quote

Test your package
#+begin_src lisp
(sijo-doctest:test-package :your-own-package)
#+end_src

* Documentation for ~sijo-doctest::test~
** Documentation for ~sijo-doctest::test~

Warning: This is bound to get out of date, so look at the documentation in the source.

Expand Down Expand Up @@ -80,13 +71,16 @@ Test extracts and tests code snippets embedded in the documentation string
2) (values 1 2) instead.

If you test a thing that doesn't have a documentation string, test will
return NIL.
return (values 0 0).
ECL NOTE: I pass an empty string here as redefining a function in ECL won't
remove the old docstring unless a docstring is explicitly passed.

>> (defun sqr (x)
""
(* x x))
'SQR
>> (sijo-doctest::test #'sqr)
NIL
(values 0 0)

If you need to test that a function signals a condition for certain inputs
you can use the name of the condition as the expected return value.
Expand Down Expand Up @@ -159,12 +153,3 @@ Test extracts and tests code snippets embedded in the documentation string
Results for SQR (FUNCTION): 1 of 4 failed.|
(values 1 3)
#+end_example

* Changelog
This fork has some minor differences to the upstream version:
- Tweaked to evaluate expected results to avoid problems with ~fset~ and
readtables; ~#{||}~ cannot be used, and ~(fset:empty-map)~ neither
- Improved working with multiple values
- Added a ~test-package~ function to test all functions in a package
- Print only when tests are failing (useful when testing entire packages)
- ~run-doctests~ doesn't throw on empty docstring (triggered eof error)
17 changes: 16 additions & 1 deletion sijo-doctest.asd
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
(defsystem :sijo-doctest
:in-order-to ((test-op (test-op :sijo-doctest/tests)))
:description "Doctests for Common Lisp"
:version "0.2"
:version "0.3"
:author "Johan Lindberg (Pulp Software) <[email protected]>, Simen Endsjø <[email protected]>"
:licence "GPL"
:serial t
:pathname "src/"
:components ((:file "doctest")))

(defsystem :sijo-doctest/tests
:depends-on (#:sijo-doctest
#:lisp-unit2)
:perform (test-op (o c)
(eval (read-from-string "
(lisp-unit2:with-summary ()
(lisp-unit2:run-tests
:package :sijo-doctest/tests
:name :sijo-doctest))")))
:pathname "tests/"
:components ((:file "doctest")))
Loading