From 4dd8376647ab42613eaea59addeb006cf353f10b Mon Sep 17 00:00:00 2001 From: Gosha Tcherednitchenko Date: Fri, 1 Mar 2024 22:27:01 +0000 Subject: [PATCH] feat(tests): initial setup for tests --- .github/workflows/ci.yml | 35 +++++++++++++++++++++++++++++++++++ homestead-tests.asd | 14 ++++++++++++++ homestead.asd | 3 ++- tests/test-util.lisp | 19 +++++++++++++++++++ 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml create mode 100644 homestead-tests.asd create mode 100644 tests/test-util.lisp diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c891c11 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,35 @@ +### Adapted from: https://github.com/neil-lindquist/CI-Utils/blob/master/config-examples/.github/workflows/ci.yml +name: CI + +# Github Actions allows for running jobs on a wide variety of events +on: + push: # Commits pushed to Github + pull_request: # Pull request is update + workflow_dispatch: # Manually dispatched from Github's UI + +jobs: + test: + name: "sbcl on ubuntu" + runs-on: ubuntu-latest + + steps: + # This action checks out our code in the working directory + - uses: actions/checkout@v2 + # setup-lisp requires an env variable to be set, not matrix.lisp + - name: Set LISP env var + run: echo "LISP=sbcl-bin" >> $GITHUB_ENV + # This action installs roswell and a few other utilities such as qlot + - uses: 40ants/setup-lisp@v2 + + # These steps run our tests + # Windows needs to be run with the msys2 shell due to how roswell is installed + - name: Run tests + shell: bash + run: | + # Install the roswell script for the test library + ros install neil-lindquist/ci-utils # for run-fiveam + #ros install prove # for run-prove: + #ros install rove # for [run-] rove + + # Run the tests + run-fiveam -e t -l homestead-tests :homestead-tests diff --git a/homestead-tests.asd b/homestead-tests.asd new file mode 100644 index 0000000..850f108 --- /dev/null +++ b/homestead-tests.asd @@ -0,0 +1,14 @@ +(asdf:defsystem "homestead-tests" + :author "Gosha Tcherednitchenko " + :license "MIT License" + :depends-on ("homestead" "fiveam") + :serial t + :components ((:module "tests" + :components ((:file "test-util")))) + :perform (asdf:test-op (op system) + (let* ((fiveam:*on-failure* :backtrace) + (fiveam:*on-error* :backtrace) + (fiveam:*verbose-failures* t)) + (if (fiveam:run-all-tests :summary :end) + (format t "✅ All tests passed") + (error "❌ At least one suite failed"))))) diff --git a/homestead.asd b/homestead.asd index fff911f..78394ab 100644 --- a/homestead.asd +++ b/homestead.asd @@ -10,4 +10,5 @@ (:file "templates" :depends-on ("util")) (:file "node" :depends-on ("templates")) (:file "main" :depends-on ("util" "node"))))) - :description "A static website generator") + :description "A static website generator" + :in-order-to ((test-op (test-op "homestead-tests")))) diff --git a/tests/test-util.lisp b/tests/test-util.lisp new file mode 100644 index 0000000..8f53b4d --- /dev/null +++ b/tests/test-util.lisp @@ -0,0 +1,19 @@ +(defpackage homestead/tests/util + (:use :cl :it.bese.fiveam) + (:export :util-test-suite :|util-test-suite|)) + +(in-package :homestead/tests/util) + +(def-suite + util-test-suite + :description "Util test suite") +(in-suite util-test-suite) + +(test join + (let ((list '("a" "b"))) + (is (string= (homestead/util:join list) "a, b")) + (is (string= (homestead/util:join list " | ") "a | b")))) + +(test slurp + (let ((missing-file "/tmp/bob.txt")) + (is (equal '() (homestead/util:slurp missing-file)))))