changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > core / lisp/lib/skel/tests.lisp

changeset 630: f4a464cc1628
parent: 5bd0eb9fa1fa
child: bbd9024f2fe2
author: Richard Westhaver <ellis@rwest.io>
date: Wed, 28 Aug 2024 22:08:42 -0400
permissions: -rw-r--r--
description: skel/vm work, added json benchmark
1 ;;; skel/tests.lisp --- skel tests
2 (defpackage :skel/tests
3  (:use :cl :skel :rt :log :obj :dat/sxp)
4  (:import-from :uiop :file-exists-p))
5 
6 (in-package :skel/tests)
7 
8 (defsuite :skel)
9 (in-suite :skel)
10 
11 (defvar %tmp)
12 (defun tmp-path (ext)
13  (setq %tmp (format nil "/tmp/~A.~A" (gensym) ext)))
14 
15 (defun do-tmp-path (file &rest body)
16  (prog1 body
17  (when (file-exists-p file) (delete-file file))))
18 
19 (deftest header-comments ()
20  "Make sure header comments are generated correctly.
21 
22 This covers variations of make-source-header-comment, make-source-file-header,
23 make-shebang-comment, and make-shebang-file-header."
24  (is (eq (type-of (make-shebang-file-header
25  (make-shebang-comment "/dev/null")))
26  'file-header))
27  (is (eq (type-of (make-source-file-header
28  (make-source-header-comment
29  "foo-test"
30  :timestamp t
31  :description "nothing to see here"
32  :opts '("Definitely-Not_Emacs: T;"))))
33  'file-header)))
34 
35 (deftest skelfile ()
36  "Ensure skelfiles are created and loaded correctly and that they signal
37 the appropriate restarts."
38  (do-tmp-path (tmp-path "sk")
39  (is (sk-write-file
40  (make-instance 'sk-project :name "nada" :path "test" :vc :hg) :path %tmp :if-exists :supersede))
41  (ignore-errors (delete-file %tmp))
42  (setf %tmp (tmp-path "sk"))
43  (is (init-skelfile %tmp))
44  (is (load-skelfile %tmp))
45  (is (build-ast (sk-read-file (make-instance 'sk-project) %tmp)))))
46 
47 (deftest skelrc ()
48  "Ensure skelrc files are created and loaded correctly."
49  (do-tmp-path (tmp-path "skrc")))
50 
51 (deftest makefile ()
52  "Make sure makefiles are making out ok."
53  (do-tmp-path (tmp-path "mk")
54  (flet ((mk (&optional path) (make-instance 'makefile :name (gensym)
55  :path (or path (pathname %tmp)) :description "barfood"))
56  (src (path) (list path))
57  (cmd (body) (make-instance 'sk-command :body body))
58  (rule (tr sr) (make-sk-rule tr sr nil)))
59  (is (null (sk-write-file (mk) :if-exists :supersede :path (tmp-path "mk"))))
60  (let* ((tr1 (tmp-path "t1"))
61  (tr2 (tmp-path "t2"))
62  (sr (src (tmp-path "s1")))
63  (r1 (rule tr1 sr))
64  (r2 (rule sr tr2))
65  (mk1 (mk "test.mk")))
66  (is (push-mk-rule r1 mk1))
67  (is (push-mk-rule r2 mk1))
68  (is (push-mk-directive
69  (cmd "ifeq ($(DEBUG),1) echo foo
70 endif")
71  mk1))
72  (is (push-mk-var '(a b) mk1))
73  (is (push-mk-var '(b c) mk1))
74  ;; FIXME
75  (is (null (sk-write-file mk1 :if-exists :supersede :path (pathname (tmp-path "mk")))))
76  ))))
77 
78 (deftest vm ()
79  "EXPERIMENTAL"
80  (with-skel-vm (vm)
81  (is (sb-lockless::split-ordered-list-p *skel-scope*))
82  (is (sb-vm:arena-p *skel-arena*))
83  (is (skel-vm-p vm))))
84 
85 (deftest asd ()
86  (let ((sk (make-instance 'sk-project :components '((:lisp "test")
87  (:lisp-system "test")))))
88  (is sk)))