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 2, 2024
1 parent 3bffce2 commit 4a75edb
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 1 deletion.
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
### 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

env:
LISP: sbcl-bin
steps:
- uses: actions/checkout@v2
- uses: 40ants/setup-lisp@v4
with:
asdf-system: homestead
- uses: 40ants/run-tests@v2
with:
asdf-system: homestead
run-test: |
(ql:quickload :fiveam)
(asdf:test-system :homestead)
10 changes: 10 additions & 0 deletions homestead-tests.asd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(defsystem "homestead-tests"
:author "Gosha Tcherednitchenko <[email protected]>"
:license "MIT License"
:depends-on (#:homestead #:fiveam)
:serial t
:components ((:module "tests"
:components ((:file "all")
(:file "test-util" :depends-on ("all")))))
:perform (test-op (o c)
(symbol-call :homestead/tests :run-all!)))
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"))))
13 changes: 13 additions & 0 deletions tests/all.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(defpackage homestead/tests
(:use :cl :fiveam)
(:export :all-tests))

(in-package :homestead/tests)

(def-suite all-tests :description "Top-level test suite for all tests.")

(defun run-all! ()
(let ((ok (run! 'all-tests)))
(if ok
(format t "✅ All tests passed")
(error "❌ At least one suite failed"))))
20 changes: 20 additions & 0 deletions tests/test-util.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
(defpackage homestead/tests/util
(:use :cl :fiveam)
(:export :util-test-suite :|util-test-suite|))

(in-package :homestead/tests/util)

(def-suite
util-test-suite
:description "Util test suite"
:in homestead/tests:all-tests)
(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 4a75edb

Please sign in to comment.