~theothornhill/advent

95ed951bed73cd81f9048e166ed708a2016a1597 — Theodor Thornhill 4 years ago d24a2c2
Add tests
8 files changed, 53 insertions(+), 3 deletions(-)

A .build.yml
A .gitignore
M 2020/package.lisp
A 2020/tests/2020-tests.lisp
A 2020/tests/package.lisp
M advent.asd
A test.lisp
A test.sh
A .build.yml => .build.yml +14 -0
@@ 0,0 1,14 @@
image: archlinux
packages:
  - sbcl
sources:
  - https://git.sr.ht/~theothornhill/lisp-ci
  - https://git.sr.ht/~theothornhill/advent
tasks:
  - setup: |
      ./lisp-ci/lisp-ci.sh
      mv ~/advent ~/quicklisp/local-projects/
      cd ~/quicklisp/local-projects/advent
  - test: |
      cd ~/quicklisp/local-projects/advent
      ./test.sh

A .gitignore => .gitignore +1 -0
@@ 0,0 1,1 @@
**/*.fasl

M 2020/package.lisp => 2020/package.lisp +4 -1
@@ 1,2 1,5 @@
(defpackage :advent-2020
  (:use :cl))
  (:use :cl)
  (:export
   :is-it-2020?-part-1
   :is-it-2020?-part-2))

A 2020/tests/2020-tests.lisp => 2020/tests/2020-tests.lisp +9 -0
@@ 0,0 1,9 @@
(in-package :advent/tests)

(deftest day1-part-1
  (testing "Day one part 1 should return correct number"
    (ok (= (is-it-2020?-part-1) 703131))))

(deftest day1-part-2
  (testing "Day one part 2 should return correct number"
    (ok (= (is-it-2020?-part-2) 272423970))))

A 2020/tests/package.lisp => 2020/tests/package.lisp +4 -0
@@ 0,0 1,4 @@
(defpackage :advent/tests
  (:use :cl
        :rove
        :advent-2020))

M advent.asd => advent.asd +15 -2
@@ 1,4 1,3 @@

(asdf:defsystem :advent
  :description "Advent of Code"
  :author "Theodor Thornhill <theo@thornhill.no>"


@@ 18,4 17,18 @@
               (:module "2020"
                :components ((:file "package")
                             (:module "days"
                              :components ((:file "day1")))))))
                              :components ((:file "day1"))))))
  :in-order-to ((test-op (test-op "advent/tests"))))

(asdf:defsystem :advent/tests
  :description "Tests for advent of code"
  :author "Theodor Thornhill <theo@thornhill.no>"
  :license "GPLv3"
  :version "0.0.1"
  :depends-on (:rove
               :advent)
  :components ((:module "2020"
                :components ((:module "tests"
                              :components ((:file "package")
                                           (:file "2020-tests"))))))
  :perform (test-op (o c) (symbol-call :rove '#:run :advent/tests)))

A test.lisp => test.lisp +3 -0
@@ 0,0 1,3 @@
(ql:quickload :advent/tests)

(asdf:test-system :advent)

A test.sh => test.sh +3 -0
@@ 0,0 1,3 @@
#!/bin/bash

sbcl --non-interactive --load test.lisp