Skip to content

Commit

Permalink
feat(tests): initial setup for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
goshatch committed Mar 1, 2024
1 parent 3bffce2 commit 4dd8376
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 1 deletion.
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions homestead-tests.asd
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
(asdf:defsystem "homestead-tests"
:author "Gosha Tcherednitchenko <mail@gosha.net>"
: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")))))
3 changes: 2 additions & 1 deletion homestead.asd
Original file line number Diff line number Diff line change
Expand Up @@ -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"))))
19 changes: 19 additions & 0 deletions tests/test-util.lisp
Original file line number Diff line number Diff line change
@@ -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)))))

0 comments on commit 4dd8376

Please sign in to comment.