From d262d3054393fe8c445d80269fed9ef7e5b159d8 Mon Sep 17 00:00:00 2001 From: William Carroll Date: Thu, 23 Jan 2020 13:45:57 +0000 Subject: [PATCH] Attempt to package CL unit testing with Nix My first foray trying to package Common Lisp with Nix. I'm using @tazjin's buildLisp and other libraries, all of which I'm importing as `tpkgs`, and all of which have been a tremendous boon to my productivity. --- common-lisp/anaphora.nix | 17 +++++++++++++++++ common-lisp/cl-colors.nix | 20 ++++++++++++++++++++ common-lisp/default.nix | 13 +++++++++++++ common-lisp/let-plus.nix | 19 +++++++++++++++++++ common-lisp/prove-asdf.nix | 15 +++++++++++++++ common-lisp/prove.nix | 31 +++++++++++++++++++++++++++++++ common-lisp/unit-testing.lisp | 13 +++++++++++++ 7 files changed, 128 insertions(+) create mode 100644 common-lisp/anaphora.nix create mode 100644 common-lisp/cl-colors.nix create mode 100644 common-lisp/default.nix create mode 100644 common-lisp/let-plus.nix create mode 100644 common-lisp/prove-asdf.nix create mode 100644 common-lisp/prove.nix create mode 100644 common-lisp/unit-testing.lisp diff --git a/common-lisp/anaphora.nix b/common-lisp/anaphora.nix new file mode 100644 index 000000000..f64d01a50 --- /dev/null +++ b/common-lisp/anaphora.nix @@ -0,0 +1,17 @@ +{ tpkgs ? (import (builtins.fetchGit "https://git.tazj.in/") {}), ... }: + +let + src = builtins.fetchGit { + url = "https://github.com/tokenrove/anaphora.git"; + rev = "aeace4c68cf55098a67112750b28f8f2dc6d0e30"; + }; +in tpkgs.nix.buildLisp.library { + name = "anaphora"; + deps = []; + srcs = [ + "${src}/packages.lisp" + "${src}/early.lisp" + "${src}/symbolic.lisp" + "${src}/anaphora.lisp" + ]; +} diff --git a/common-lisp/cl-colors.nix b/common-lisp/cl-colors.nix new file mode 100644 index 000000000..cff40fef3 --- /dev/null +++ b/common-lisp/cl-colors.nix @@ -0,0 +1,20 @@ +{ tpkgs ? (import (builtins.fetchGit "https://git.tazj.in/") {}), ... }: + +let + src = builtins.fetchGit { + url = "https://github.com/tpapp/cl-colors.git"; + rev = "827410584553f5c717eec6182343b7605f707f75"; + }; +in tpkgs.nix.buildLisp.library { + name = "cl-colors"; + deps = with tpkgs.third_party.lisp; [ + alexandria + (import ./let-plus.nix {}) + ]; + srcs = [ + "${src}/package.lisp" + "${src}/colors.lisp" + "${src}/colornames.lisp" + "${src}/hexcolors.lisp" + ]; +} diff --git a/common-lisp/default.nix b/common-lisp/default.nix new file mode 100644 index 000000000..b3c51eea7 --- /dev/null +++ b/common-lisp/default.nix @@ -0,0 +1,13 @@ +{ tpkgs ? (import (builtins.fetchGit "https://git.tazj.in/") {}), ... }: + +tpkgs.nix.buildLisp.program { + name = "unit-testing"; + + deps = with tpkgs.third_party.lisp; [ + (import ./prove.nix {}) + ]; + + srcs = [ + ./unit-testing.lisp + ]; +} diff --git a/common-lisp/let-plus.nix b/common-lisp/let-plus.nix new file mode 100644 index 000000000..5b279477d --- /dev/null +++ b/common-lisp/let-plus.nix @@ -0,0 +1,19 @@ +{ tpkgs ? (import (builtins.fetchGit "https://git.tazj.in/") {}), ... }: + +let + src = builtins.fetchGit { + url = "https://github.com/tpapp/let-plus.git"; + rev = "7cf18b29ed0fe9c667a9a6a101b08ab9661a59e9"; + }; +in tpkgs.nix.buildLisp.library { + name = "let-plus"; + deps = with tpkgs.third_party.lisp; [ + alexandria + (import ./anaphora.nix {}) + ]; + srcs = [ + "${src}/package.lisp" + "${src}/let-plus.lisp" + "${src}/extensions.lisp" + ]; +} diff --git a/common-lisp/prove-asdf.nix b/common-lisp/prove-asdf.nix new file mode 100644 index 000000000..8a692cf12 --- /dev/null +++ b/common-lisp/prove-asdf.nix @@ -0,0 +1,15 @@ +{ tpkgs ? (import (builtins.fetchGit "https://git.tazj.in/") {}), ... }: + +let + src = builtins.fetchGit { + url = "https://github.com/fukamachi/prove.git"; + rev = "5d71f02795b89e36f34e8c7d50e69b67ec6ca2de"; + }; +in tpkgs.nix.buildLisp.library { + name = "prove-asdf"; + deps = []; + srcs = [ + "${src}/src/output.lisp" + "${src}/src/asdf.lisp" + ]; +} diff --git a/common-lisp/prove.nix b/common-lisp/prove.nix new file mode 100644 index 000000000..a4499dcea --- /dev/null +++ b/common-lisp/prove.nix @@ -0,0 +1,31 @@ +{ tpkgs ? (import (builtins.fetchGit "https://git.tazj.in/") {}), ... }: + +let + src = builtins.fetchGit { + url = "https://github.com/fukamachi/prove.git"; + rev = "5d71f02795b89e36f34e8c7d50e69b67ec6ca2de"; + }; +in tpkgs.nix.buildLisp.library { + name = "prove"; + deps = with tpkgs.third_party.lisp; [ + cl-ppcre + cl-ansi-text + (import ./cl-colors.nix {}) + alexandria + uiop + ]; + srcs = [ + "${src}/src/asdf.lisp" + "${src}/src/suite.lisp" + "${src}/src/color.lisp" + "${src}/src/output.lisp" + "${src}/src/prove.lisp" + "${src}/src/report.lisp" + "${src}/src/reporter.lisp" + "${src}/src/test.lisp" + "${src}/src/reporter/dot.lisp" + "${src}/src/reporter/fiveam.lisp" + "${src}/src/reporter/list.lisp" + "${src}/src/reporter/tap.lisp" + ]; +} diff --git a/common-lisp/unit-testing.lisp b/common-lisp/unit-testing.lisp new file mode 100644 index 000000000..c0b3be9b4 --- /dev/null +++ b/common-lisp/unit-testing.lisp @@ -0,0 +1,13 @@ +(in-package #:cl-user) +(defpackage #:my-test + (:documentation "Unit testing in Common Lisp.") + (:use #:cl)) +(in-package #:my-test) + +(plan 3) + +(ok (not (find 4 '(1 2 3)))) +(is 4 4) +(isnt 1 #\1) + +(finalize)