changelog shortlog graph tags branches changeset files revisions annotate raw help

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

changeset 632: bbd9024f2fe2
parent: 83f8623a6ec3
child: 74e563ed4537
author: Richard Westhaver <ellis@rwest.io>
date: Sat, 31 Aug 2024 22:34:56 -0400
permissions: -rw-r--r--
description: lib/rt upgrades and refactoring
1 (defpackage :rt/tests
2  (:use :cl :std :rt :sb-sprof :rt/flamegraph :rt/tracing :rt/cover :rt/bench))
3 
4 (in-package :rt/tests)
5 
6 (defsuite :rt)
7 (in-suite :rt)
8 
9 (deftest rt (:profile t :persist t)
10  (with-fixture (fx (:tmp :directory "/tmp/"))
11  (is fx))
12  (signals (error t) (test-form (make-instance 'test-result))))
13 
14 (deftest flamegraph (:profile t)
15  (let ((f "/tmp/test.txt")) ;; open with https://speedscope.app or
16  ;; output svg with flamegraph.pl >>
17  ;; test.svg
18  (save-flamegraph (f :sample-interval 0.001 :show-progress t :report :flat)
19  (loop for x from 0 to 1000
20  do (* x x)))
21  (is (probe-file f))
22  (delete-file f)))
23 
24 (deftest tracing (:profile t :skip t) ;; fails in x
25  (let ((f "/tmp/tracing.json")
26  (*default-arg-converter* +arg-converter-store-only-simple-objects-and-strings+)) ;; open with chrome://tracing
27  (flet ((foo (i)
28  (let ((v0 (make-bit-vector 256))
29  (v1 (make-bit-vector 256 1)))
30  (loop for x across v0
31  for y across v1
32  collect (list y (+ i x))))))
33  (trace "STD")
34  (start-tracing)
35  (dotimes (i 100) (foo i))
36  (save-report f))
37  (is (probe-file f))
38  (delete-file f)))
39 
40 (deftest cover (:profile t)
41  (start-coverage)
42  (stop-coverage)
43  (coverage-report))
44 
45 (deftest tmp ()
46  (is (null (with-tmp-directory ())))
47  (is (null (with-tmp-file ())))
48  (is (with-tmp-file (f1 :name "temporary-file")
49  (is (probe-file *tmp*))
50  (write-string "1 2 3 4" f1)
51  (force-output f1)
52  (is (= 7 (file-length f1)))))
53  (is (with-tmp-directory ("foobar")
54  (is (directory-path-p (probe-file *tmp*))))))
55