Rename projects, docgen->sheep, checkstyle->wolf
[wolf] / src / test / main.lisp
1 (in-package #:wolf-test)
2
3 (defvar *tests* nil)
4
5 (defmacro deftest (filename success &optional msg line-no col-no)
6  `(push
7    (lambda ()
8     (let
9      ((green (format nil "~c[1;32m" #\Esc))
10       (red (format nil "~c[1;31m" #\Esc))
11       (result (wolf:check-file ,filename)))
12      (cond
13       ((not (eql ,success (car result)))
14        (format t "~A- ~A failed, expected ~A and got ~A~c[0m~%"
15         red ,filename ,success (car result) #\Esc))
16       ((and (eql :failure ,success) (string/= ,msg (third result)))
17        (format t "~A- ~A failed, expected msg ~A and got msg ~A~c[0m~%"
18         red ,filename ,msg (third result) #\Esc))
19       ((and (eql :failure ,success) (/= ,line-no (fourth result)))
20        (format t "~A- ~A failed, expected line ~A and got line ~A~c[0m~%"
21         red ,filename ,line-no (fourth result) #\Esc))
22       ((and (eql :failure ,success) (/= ,col-no (fifth result)))
23        (format t "~A- ~A failed, expected column ~A and got column ~A~c[0m~%"
24         red ,filename ,col-no (fifth result) #\Esc))
25       (t (format t "~A- ~A passed ~c[0m~%" green ,filename #\Esc) t))))
26    *tests*))
27
28 ; This really is just here to check against regressions
29 (defun run-all-tests ()
30  (let
31   ((results (mapcar #'funcall *tests*)))
32   (every #'identity results)))
33
34 (deftest #P"resources/commentneedsspace.lisp" :failure "Multiline top level forms must be separated by a space" 6 0)
35 (deftest #P"resources/emptylineatend.lisp" :failure "Must not end with empty line" 8 0)
36 (deftest #P"resources/good.lisp" :success)
37 (deftest #P"resources/goodcomment.lisp" :success)
38 (deftest #P"resources/hangingcloseparens1.lisp" :failure "No hanging close parens" 11 0)
39 (deftest #P"resources/hangingcloseparens2.lisp" :failure "No hanging close parens" 12 1)
40 (deftest #P"resources/internalsymbols.lisp" :failure "No internal symbols from other packages" 6 22)
41 (deftest #P"resources/invalidindent1.lisp" :failure "All form elements must be indented equally" 9 5)
42 (deftest #P"resources/invalidindent2.lisp" :failure "All form elements must be indented equally" 11 6)
43 (deftest #P"resources/longform.lisp" :failure "Forms can't be over 50 lines long" 117 60)
44 (deftest #P"resources/longline.lisp" :failure "Line longer than 120 characters" 2 0)
45 (deftest #P"resources/newlineafteropenparens.lisp" :failure "No new line after opening form" 11 5)
46 (deftest #P"resources/nopackage.lisp" :failure "Must begin with in-package form" 0 0)
47 (deftest #P"resources/package.lisp" :success)
48 (deftest #P"resources/spaceafteropenparens.lisp" :failure "No space after opening parens" 11 5)
49 (deftest #P"resources/tabs.lisp" :failure "Must not use tabs" 4 0)
50 (deftest #P"resources/toplevelindented.lisp" :failure "Top level forms must begin on first column" 3 1)
51 (deftest #P"resources/twoemptylines.lisp" :failure "Must not have two empty lines in a row" 2 0)
52 (deftest #P"resources/twoemptylineswithcomment.lisp" :failure "Must not have two empty lines in a row" 8 0)
53 (deftest #P"resources/twoinpackage.lisp" :failure "Only one in-package per file" 9 0)
54 (deftest #P"resources/twospaces.lisp" :failure "Only one space between items of a form" 8 6)
55 (deftest #P"resources/unspacedforms.lisp" :failure "Multiline top level forms must be separated by a space" 4 0)
56 (deftest #P"resources/whitespaceendline.lisp" :failure "No whitespace at end of line" 4 106)
57 (deftest #P"resources/whitespacelines.lisp" :failure "No whitespace only lines" 1 1)