From 172a10fdc5df62b332638dcfc6bf3ac3b28123f7 Mon Sep 17 00:00:00 2001 From: Jaidyn Ann <10477760+JadedCtrl@users.noreply.github.com> Date: Mon, 27 May 2024 22:49:05 -0500 Subject: [PATCH] Add tests using lisp-unit2 These are basic, place-holder tests; not too useful at the moment. --- Makefile | 8 ++++++++ eksd.asd | 42 ++++++++++++++++++++++++++++++++++++++++-- t/eksd.lisp | 26 ++++++++++++++++++++++++++ t/unix.lisp | 27 +++++++++++++++++++++++++++ 4 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 t/eksd.lisp create mode 100644 t/unix.lisp diff --git a/Makefile b/Makefile index e5af8d5..0719778 100644 --- a/Makefile +++ b/Makefile @@ -18,3 +18,11 @@ build: --eval '(ql:quickload :eksd/unix)' \ --eval '(asdf:make :eksd/unix)' \ --eval '(quit)' + +test: + $(LISP) --load eksd.asd \ + --eval '(ql:quickload :eksd)' \ + --eval '(ql:quickload :eksd/unix)' \ + --eval '(asdf:test-system :eksd)' \ + --eval '(asdf:test-system :eksd/unix)' \ + --eval '(quit)' diff --git a/eksd.asd b/eksd.asd index 5c902eb..ce24aba 100644 --- a/eksd.asd +++ b/eksd.asd @@ -7,7 +7,9 @@ :homepage "https://hak.xwx.moe/jadedctrl/eksd" :description "For reading files into hex— `xxd`-like with text-tables." :depends-on () - :components ((:file "src/eksd"))) + :components ((:file "src/eksd")) + :in-order-to ((test-op (test-op "eksd/tests")) + (build-op (build-op "eksd/unix")))) (asdf:defsystem "eksd/unix" :version "0.11" @@ -20,4 +22,40 @@ :build-pathname "eksd" :entry-point "eksd/unix:main" :depends-on (:cl-strings :eksd :unix-opts) - :components ((:file "src/unix"))) + :components ((:file "src/unix")) + :in-order-to ((test-op (test-op "eksd/unix/tests")))) + + + +;;; Tests +;;; ————————————————————————————————————— +(asdf:defsystem "eksd/tests" + :version "0.11" + :license "GPLv3" + :author "Jaidyn Ann " + :homepage "https://hak.xwx.moe/jadedctrl/eksd" + :description "Tests for the the eksd package." + :depends-on (:eksd :lisp-unit2) + :components ((:file "t/eksd"))) + +(asdf:defsystem "eksd/unix/tests" + :version "0.11" + :license "GPLv3" + :author "Jaidyn Ann " + :homepage "https://hak.xwx.moe/jadedctrl/eksd" + :description "Tests for the eksd.unix package." + :depends-on (:eksd/unix :lisp-unit2) + :components ((:file "t/unix"))) + + +;; Following methods borrowed from lisp-unit2’s documentation: +;; https://github.com/AccelerationNet/lisp-unit2/blob/master/README.md#asdf +(defmethod asdf:perform ((o asdf:test-op) (c (eql (asdf:find-system :eksd/tests)))) + (eval (read-from-string + "(lisp-unit2:with-summary () + (lisp-unit2:run-tests :package :eksd/tests))"))) + +(defmethod asdf:perform ((o asdf:test-op) (c (eql (asdf:find-system :eksd/unix/tests)))) + (eval (read-from-string + "(lisp-unit2:with-summary () + (lisp-unit2:run-tests :package :eksd/unix/tests))"))) diff --git a/t/eksd.lisp b/t/eksd.lisp new file mode 100644 index 0000000..ee7885c --- /dev/null +++ b/t/eksd.lisp @@ -0,0 +1,26 @@ +;;;; eksd.tests: Tests for eksd package. + +;; Copyright © 2024 Jaidyn Ann +;; +;; 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 . + +(defpackage :eksd/tests + (:use :cl :lisp-unit2) + (:export :char-hex.space)) + +(in-package :eksd/tests) + +(define-test char-hex.space + (:tags '(char-hex)) + (assert-equal (eksd::char-hex #\space) "20")) diff --git a/t/unix.lisp b/t/unix.lisp new file mode 100644 index 0000000..d357399 --- /dev/null +++ b/t/unix.lisp @@ -0,0 +1,27 @@ +;;;; eksd.unix.tests: Tests for eksd’s UNIX frontend package. + +;; Copyright © 2024 Jaidyn Ann +;; +;; 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 . + +(defpackage :eksd/unix/tests + (:use :cl :lisp-unit2) + (:export :de-tail)) + +(in-package :eksd/unix/tests) + +(define-test de-tail + (:tags '(de-tail)) + (assert-equal (eksd/unix::de-tail '(1 2 3)) + '(1 2)))