Coverage report: /home/ellis/comp/core/lib/rt/tests.lisp

KindCoveredAll%
expression625 24.0
branch00nil
Key
Not instrumented
Conditionalized out
Executed
Not executed
 
Both branches taken
One branch taken
Neither branch taken
1
 ;;; tests.lisp --- RT Tests
2
 
3
 ;;; Code:
4
 (defpackage :rt/tests
5
   (:use :cl :std :rt :rt/flamegraph :rt/tracing :rt/cover :rt/bench :rt/fuzz))
6
 
7
 (in-package :rt/tests)
8
 
9
 (defsuite :rt
10
   :policy '(optimize sb-cover:store-coverage-data debug)
11
   :fixtures (list
12
              (make-fixture :tmp :name :fx1)))
13
 
14
 (in-suite :rt)
15
 
16
 (defun %foo (input)
17
   (loop for x below input
18
         collect (loop for y in (%foo x)
19
                       collect (cons x y))))
20
 
21
 (deftest rt (:profile t :persist t)
22
   (with-fixture (fx :tmp :directory "/tmp/")
23
     (istype 'tmp-fixture fx))
24
   (signals (error t) (test-form (make-instance 'test-result))))
25
 
26
 (deftest flamegraph (:profile t :cover t)
27
   (let ((f "/tmp/test.txt")) ;; open with https://speedscope.app or
28
                              ;; output svg with flamegraph.pl >>
29
                              ;; test.svg
30
     (with-flamegraph (f :sample-interval 0.00001 :show-progress t :report :flat)
31
       (%foo 20))
32
     (is (probe-file f))
33
     (delete-file f)))
34
 
35
 (deftest tracing (:profile t)
36
   (let ((f "/tmp/tracing.json")
37
         (tracing::*default-arg-converter* tracing::+arg-converter-store-only-simple-objects-and-strings+)) ;; open with chrome://tracing
38
     (trace "STD")
39
     (with-tracing ("RT" "RT/TESTS")
40
       (%foo 25))
41
     (save-report f)
42
     (is (probe-file f))
43
     (delete-file f)))
44
 
45
 (deftest cover (:profile t :skip t)
46
   ;; todo
47
   (coverage-report))
48
 
49
 (deftest fixture (:fx "fx1")
50
   (print *fx*))
51
 
52
 (deftest tmp ()
53
   (is (null (with-tmp-directory ())))
54
   (is (null (with-tmp-file (file))))
55
   (is (with-tmp-file (f1 :name "temporary-file")
56
         (is (probe-file *tmp*))
57
         (write-string "1 2 3 4" f1)
58
         (force-output f1)
59
         (is (= 7 (file-length f1)))))
60
   (is (with-tmp-directory ("foobar")
61
         (is (directory-path-p (probe-file *tmp*))))))
62
 
63
 (deftest fuzz ()
64
   (defclass foo-fuzz (fuzzer) ())
65
   (is (integerp
66
        (fuzz (make-instance 'foo-fuzz))))
67
   (is (= 100 (length (fuzz* (make-random-state) (fuzz-generator (make-instance 'foo-fuzz)) :count 100)))))