0000: 0a 3b 3b 20 43 6f 70 79 72 69 67 68 74 20 32 30 .;; Copyright 20
0010: 30 36 2d 32 30 31 31 2c 20 4d 61 74 74 68 65 77 06-2011, Matthew
0020: 20 57 65 6c 6c 61 6e 64 2e 0a 3b 3b 20 0a 3b 3b Welland..;; .;;
0030: 20 20 54 68 69 73 20 70 72 6f 67 72 61 6d 20 69 This program i
0040: 73 20 6d 61 64 65 20 61 76 61 69 6c 61 62 6c 65 s made available
0050: 20 75 6e 64 65 72 20 74 68 65 20 47 4e 55 20 47 under the GNU G
0060: 50 4c 20 76 65 72 73 69 6f 6e 20 32 2e 30 20 6f PL version 2.0 o
0070: 72 0a 3b 3b 20 20 67 72 65 61 74 65 72 2e 20 53 r.;; greater. S
0080: 65 65 20 74 68 65 20 61 63 63 6f 6d 70 61 6e 79 ee the accompany
0090: 69 6e 67 20 66 69 6c 65 20 43 4f 50 59 49 4e 47 ing file COPYING
00a0: 20 66 6f 72 20 64 65 74 61 69 6c 73 2e 0a 3b 3b for details..;;
00b0: 20 0a 3b 3b 20 20 54 68 69 73 20 70 72 6f 67 72 .;; This progr
00c0: 61 6d 20 69 73 20 64 69 73 74 72 69 62 75 74 65 am is distribute
00d0: 64 20 57 49 54 48 4f 55 54 20 41 4e 59 20 57 41 d WITHOUT ANY WA
00e0: 52 52 41 4e 54 59 3b 20 77 69 74 68 6f 75 74 20 RRANTY; without
00f0: 65 76 65 6e 20 74 68 65 0a 3b 3b 20 20 69 6d 70 even the.;; imp
0100: 6c 69 65 64 20 77 61 72 72 61 6e 74 79 20 6f 66 lied warranty of
0110: 20 4d 45 52 43 48 41 4e 54 41 42 49 4c 49 54 59 MERCHANTABILITY
0120: 20 6f 72 20 46 49 54 4e 45 53 53 20 46 4f 52 20 or FITNESS FOR
0130: 41 20 50 41 52 54 49 43 55 4c 41 52 0a 3b 3b 20 A PARTICULAR.;;
0140: 20 50 55 52 50 4f 53 45 2e 0a 0a 3b 3b 20 20 73 PURPOSE...;; s
0150: 74 72 66 74 69 6d 65 28 27 25 6d 2f 25 64 2f 25 trftime('%m/%d/%
0160: 59 20 25 48 3a 25 4d 3a 25 53 27 2c 27 6e 6f 77 Y %H:%M:%S','now
0170: 27 2c 27 6c 6f 63 61 6c 74 69 6d 65 27 29 0a 0a ','localtime')..
0180: 3b 3b 20 72 65 67 69 73 74 65 72 20 61 20 74 65 ;; register a te
0190: 73 74 20 72 75 6e 20 77 69 74 68 20 74 68 65 20 st run with the
01a0: 64 62 0a 28 64 65 66 69 6e 65 20 28 72 65 67 69 db.(define (regi
01b0: 73 74 65 72 2d 72 75 6e 20 64 62 20 6b 65 79 73 ster-run db keys
01c0: 29 20 3b 3b 20 74 65 73 74 2d 6e 61 6d 65 29 0a ) ;; test-name).
01d0: 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 73 74 72 (let* ((keystr
01e0: 20 20 20 20 28 6b 65 79 73 2d 3e 6b 65 79 73 74 (keys->keyst
01f0: 72 20 6b 65 79 73 29 29 0a 09 20 28 63 6f 6d 6d r keys)).. (comm
0200: 61 20 20 20 20 20 28 69 66 20 28 3e 20 28 6c 65 a (if (> (le
0210: 6e 67 74 68 20 6b 65 79 73 29 20 30 29 20 22 2c ngth keys) 0) ",
0220: 22 20 22 22 29 29 0a 09 20 28 61 6e 64 73 74 72 " "")).. (andstr
0230: 20 20 20 20 28 69 66 20 28 3e 20 28 6c 65 6e 67 (if (> (leng
0240: 74 68 20 6b 65 79 73 29 20 30 29 20 22 20 41 4e th keys) 0) " AN
0250: 44 20 22 20 22 22 29 29 0a 09 20 28 76 61 6c 73 D " "")).. (vals
0260: 6c 6f 74 73 20 20 28 6b 65 79 73 2d 3e 76 61 6c lots (keys->val
0270: 73 6c 6f 74 73 20 6b 65 79 73 29 29 20 3b 3b 20 slots keys)) ;;
0280: 3f 2c 3f 2c 3f 20 2e 2e 2e 0a 09 20 28 6b 65 79 ?,?,? ..... (key
0290: 76 61 6c 6c 73 74 20 28 6b 65 79 73 2d 3e 76 61 vallst (keys->va
02a0: 6c 6c 69 73 74 20 6b 65 79 73 29 29 20 3b 3b 20 llist keys)) ;;
02b0: 65 78 74 72 61 63 74 73 20 74 68 65 20 76 61 6c extracts the val
02c0: 75 65 73 20 66 72 6f 6d 20 72 65 6d 61 69 6e 64 ues from remaind
02d0: 65 72 20 6f 66 20 28 61 72 67 76 29 0a 09 20 28 er of (argv).. (
02e0: 72 75 6e 6e 61 6d 65 20 20 20 28 67 65 74 2d 77 runname (get-w
02f0: 69 74 68 2d 64 65 66 61 75 6c 74 20 22 3a 72 75 ith-default ":ru
0300: 6e 6e 61 6d 65 22 20 23 66 29 29 0a 09 20 28 73 nname" #f)).. (s
0310: 74 61 74 65 20 20 20 20 20 28 67 65 74 2d 77 69 tate (get-wi
0320: 74 68 2d 64 65 66 61 75 6c 74 20 22 3a 73 74 61 th-default ":sta
0330: 74 65 22 20 22 6e 6f 22 29 29 0a 09 20 28 73 74 te" "no")).. (st
0340: 61 74 75 73 20 20 20 20 28 67 65 74 2d 77 69 74 atus (get-wit
0350: 68 2d 64 65 66 61 75 6c 74 20 22 3a 73 74 61 74 h-default ":stat
0360: 75 73 22 20 22 6e 2f 61 22 29 29 0a 09 20 28 61 us" "n/a")).. (a
0370: 6c 6c 76 61 6c 73 20 20 20 28 61 70 70 65 6e 64 llvals (append
0380: 20 28 6c 69 73 74 20 72 75 6e 6e 61 6d 65 20 73 (list runname s
0390: 74 61 74 65 20 73 74 61 74 75 73 20 75 73 65 72 tate status user
03a0: 29 20 6b 65 79 76 61 6c 6c 73 74 29 29 0a 09 20 ) keyvallst))..
03b0: 28 71 72 79 76 61 6c 73 20 20 20 28 61 70 70 65 (qryvals (appe
03c0: 6e 64 20 28 6c 69 73 74 20 72 75 6e 6e 61 6d 65 nd (list runname
03d0: 29 20 6b 65 79 76 61 6c 6c 73 74 29 29 0a 09 20 ) keyvallst))..
03e0: 28 6b 65 79 3d 3f 73 74 72 20 20 28 73 74 72 69 (key=?str (stri
03f0: 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 28 ng-intersperse (
0400: 6d 61 70 20 28 6c 61 6d 62 64 61 20 28 6b 29 28 map (lambda (k)(
0410: 63 6f 6e 63 20 28 6b 65 79 3a 67 65 74 2d 66 69 conc (key:get-fi
0420: 65 6c 64 6e 61 6d 65 20 6b 29 20 22 3d 3f 22 29 eldname k) "=?")
0430: 29 20 6b 65 79 73 29 20 22 20 41 4e 44 20 22 29 ) keys) " AND ")
0440: 29 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72 )). (debug:pr
0450: 69 6e 74 20 33 20 22 6b 65 79 73 3a 20 22 20 6b int 3 "keys: " k
0460: 65 79 73 20 22 20 61 6c 6c 76 61 6c 73 3a 20 22 eys " allvals: "
0470: 20 61 6c 6c 76 61 6c 73 20 22 20 6b 65 79 76 61 allvals " keyva
0480: 6c 6c 73 74 3a 20 22 20 6b 65 79 76 61 6c 6c 73 llst: " keyvalls
0490: 74 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72 t). (debug:pr
04a0: 69 6e 74 20 32 20 22 4e 4f 54 45 3a 20 75 73 69 int 2 "NOTE: usi
04b0: 6e 67 20 6b 65 79 20 22 20 28 73 74 72 69 6e 67 ng key " (string
04c0: 2d 69 6e 74 65 72 73 70 65 72 73 65 20 6b 65 79 -intersperse key
04d0: 76 61 6c 6c 73 74 20 22 2f 22 29 20 22 20 66 6f vallst "/") " fo
04e0: 72 20 74 68 69 73 20 72 75 6e 22 29 0a 20 20 20 r this run").
04f0: 20 28 69 66 20 28 61 6e 64 20 72 75 6e 6e 61 6d (if (and runnam
0500: 65 20 28 6e 75 6c 6c 3f 20 28 66 69 6c 74 65 72 e (null? (filter
0510: 20 28 6c 61 6d 62 64 61 20 28 78 29 28 6e 6f 74 (lambda (x)(not
0520: 20 78 29 29 20 6b 65 79 76 61 6c 6c 73 74 29 29 x)) keyvallst))
0530: 29 20 3b 3b 20 74 68 65 72 65 20 6d 75 73 74 20 ) ;; there must
0540: 62 65 20 61 20 62 65 74 74 65 72 20 77 61 79 20 be a better way
0550: 74 6f 20 22 61 70 70 6c 79 20 61 6e 64 22 0a 09 to "apply and"..
0560: 28 6c 65 74 20 28 28 72 65 73 20 23 66 29 29 0a (let ((res #f)).
0570: 09 20 20 28 61 70 70 6c 79 20 73 71 6c 69 74 65 . (apply sqlite
0580: 33 3a 65 78 65 63 75 74 65 20 64 62 20 28 63 6f 3:execute db (co
0590: 6e 63 20 22 49 4e 53 45 52 54 20 4f 52 20 49 47 nc "INSERT OR IG
05a0: 4e 4f 52 45 20 49 4e 54 4f 20 72 75 6e 73 20 28 NORE INTO runs (
05b0: 72 75 6e 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 runname,state,st
05c0: 61 74 75 73 2c 6f 77 6e 65 72 2c 65 76 65 6e 74 atus,owner,event
05d0: 5f 74 69 6d 65 22 20 63 6f 6d 6d 61 20 6b 65 79 _time" comma key
05e0: 73 74 72 20 22 29 20 56 41 4c 55 45 53 20 28 3f str ") VALUES (?
05f0: 2c 3f 2c 3f 2c 3f 2c 73 74 72 66 74 69 6d 65 28 ,?,?,?,strftime(
0600: 27 25 73 27 2c 27 6e 6f 77 27 29 22 20 63 6f 6d '%s','now')" com
0610: 6d 61 20 76 61 6c 73 6c 6f 74 73 20 22 29 3b 22 ma valslots ");"
0620: 29 0a 09 09 20 61 6c 6c 76 61 6c 73 29 0a 09 20 )... allvals)..
0630: 20 28 61 70 70 6c 79 20 73 71 6c 69 74 65 33 3a (apply sqlite3:
0640: 66 6f 72 2d 65 61 63 68 2d 72 6f 77 20 0a 09 20 for-each-row ..
0650: 20 20 28 6c 61 6d 62 64 61 20 28 69 64 29 0a 09 (lambda (id)..
0660: 20 20 20 20 20 28 73 65 74 21 20 72 65 73 20 69 (set! res i
0670: 64 29 29 0a 09 20 20 20 64 62 0a 09 20 20 20 28 d)).. db.. (
0680: 6c 65 74 20 28 28 71 72 79 20 28 63 6f 6e 63 20 let ((qry (conc
0690: 22 53 45 4c 45 43 54 20 69 64 20 46 52 4f 4d 20 "SELECT id FROM
06a0: 72 75 6e 73 20 57 48 45 52 45 20 28 72 75 6e 6e runs WHERE (runn
06b0: 61 6d 65 3d 3f 20 22 20 61 6e 64 73 74 72 20 6b ame=? " andstr k
06c0: 65 79 3d 3f 73 74 72 20 22 29 3b 22 29 29 29 0a ey=?str ");"))).
06d0: 09 20 20 20 20 20 3b 28 64 65 62 75 67 3a 70 72 . ;(debug:pr
06e0: 69 6e 74 20 34 20 22 71 72 79 3a 20 22 20 71 72 int 4 "qry: " qr
06f0: 79 29 20 0a 09 20 20 20 20 20 71 72 79 29 0a 09 y) .. qry)..
0700: 20 20 20 71 72 79 76 61 6c 73 29 0a 09 20 20 28 qryvals).. (
0710: 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 sqlite3:execute
0720: 64 62 20 22 55 50 44 41 54 45 20 72 75 6e 73 20 db "UPDATE runs
0730: 53 45 54 20 73 74 61 74 65 3d 3f 2c 73 74 61 74 SET state=?,stat
0740: 75 73 3d 3f 20 57 48 45 52 45 20 69 64 3d 3f 3b us=? WHERE id=?;
0750: 22 20 73 74 61 74 65 20 73 74 61 74 75 73 20 72 " state status r
0760: 65 73 29 0a 09 20 20 72 65 73 29 20 0a 09 28 62 es).. res) ..(b
0770: 65 67 69 6e 0a 09 20 20 28 64 65 62 75 67 3a 70 egin.. (debug:p
0780: 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 43 rint 0 "ERROR: C
0790: 61 6c 6c 65 64 20 77 69 74 68 6f 75 74 20 61 6c alled without al
07a0: 6c 20 6e 65 63 65 73 73 61 72 79 20 6b 65 79 73 l necessary keys
07b0: 22 29 0a 09 20 20 23 66 29 29 29 29 0a 0a 3b 3b ").. #f))))..;;
07c0: 20 72 75 6e 73 3a 67 65 74 2d 72 75 6e 73 2d 62 runs:get-runs-b
07d0: 79 2d 70 61 74 74 0a 3b 3b 20 67 65 74 20 72 75 y-patt.;; get ru
07e0: 6e 73 20 62 79 20 6c 69 73 74 20 6f 66 20 63 72 ns by list of cr
07f0: 69 74 65 72 69 61 0a 3b 3b 20 72 65 67 69 73 74 iteria.;; regist
0800: 65 72 20 61 20 74 65 73 74 20 72 75 6e 20 77 69 er a test run wi
0810: 74 68 20 74 68 65 20 64 62 0a 3b 3b 0a 3b 3b 20 th the db.;;.;;
0820: 55 73 65 3a 20 28 64 62 2d 67 65 74 2d 76 61 6c Use: (db-get-val
0830: 75 65 2d 62 79 2d 68 65 61 64 65 72 20 28 64 62 ue-by-header (db
0840: 3a 67 65 74 2d 68 65 61 64 65 72 20 72 75 6e 69 :get-header runi
0850: 6e 66 6f 29 28 64 62 3a 67 65 74 2d 72 6f 77 20 nfo)(db:get-row
0860: 72 75 6e 69 6e 66 6f 29 29 0a 3b 3b 20 20 74 6f runinfo)).;; to
0870: 20 65 78 74 72 61 63 74 20 69 6e 66 6f 20 66 72 extract info fr
0880: 6f 6d 20 74 68 65 20 73 74 72 75 63 74 75 72 65 om the structure
0890: 20 72 65 74 75 72 6e 65 64 0a 3b 3b 0a 28 64 65 returned.;;.(de
08a0: 66 69 6e 65 20 28 72 75 6e 73 3a 67 65 74 2d 72 fine (runs:get-r
08b0: 75 6e 73 2d 62 79 2d 70 61 74 74 20 64 62 20 6b uns-by-patt db k
08c0: 65 79 73 20 72 75 6e 6e 61 6d 65 70 61 74 74 20 eys runnamepatt
08d0: 2e 20 70 61 72 61 6d 73 29 20 3b 3b 20 74 65 73 . params) ;; tes
08e0: 74 2d 6e 61 6d 65 29 0a 20 20 28 6c 65 74 2a 20 t-name). (let*
08f0: 28 28 6b 65 79 76 61 6c 6c 73 74 20 28 6b 65 79 ((keyvallst (key
0900: 73 2d 3e 76 61 6c 6c 69 73 74 20 6b 65 79 73 29 s->vallist keys)
0910: 29 0a 09 20 28 74 6d 70 20 20 20 20 20 20 28 72 ).. (tmp (r
0920: 75 6e 73 3a 67 65 74 2d 73 74 64 2d 72 75 6e 2d uns:get-std-run-
0930: 66 69 65 6c 64 73 20 6b 65 79 73 20 27 28 22 69 fields keys '("i
0940: 64 22 20 22 72 75 6e 6e 61 6d 65 22 20 22 73 74 d" "runname" "st
0950: 61 74 65 22 20 22 73 74 61 74 75 73 22 20 22 6f ate" "status" "o
0960: 77 6e 65 72 22 20 22 65 76 65 6e 74 5f 74 69 6d wner" "event_tim
0970: 65 22 29 29 29 0a 09 20 28 6b 65 79 73 74 72 20 e"))).. (keystr
0980: 20 20 28 63 61 72 20 74 6d 70 29 29 0a 09 20 28 (car tmp)).. (
0990: 68 65 61 64 65 72 20 20 20 28 63 61 64 72 20 74 header (cadr t
09a0: 6d 70 29 29 0a 09 20 28 72 65 73 20 20 20 20 20 mp)).. (res
09b0: 27 28 29 29 0a 09 20 28 6b 65 79 2d 70 61 74 74 '()).. (key-patt
09c0: 20 22 22 29 29 0a 20 20 20 20 28 66 6f 72 2d 65 "")). (for-e
09d0: 61 63 68 20 28 6c 61 6d 62 64 61 20 28 6b 65 79 ach (lambda (key
09e0: 76 61 6c 29 0a 09 09 28 6c 65 74 2a 20 28 28 6b val)...(let* ((k
09f0: 65 79 20 20 20 20 28 76 65 63 74 6f 72 2d 72 65 ey (vector-re
0a00: 66 20 6b 65 79 76 61 6c 20 30 29 29 0a 09 09 20 f keyval 0))...
0a10: 20 20 20 20 20 20 28 66 75 6c 6b 65 79 20 28 63 (fulkey (c
0a20: 6f 6e 63 20 22 3a 22 20 6b 65 79 29 29 0a 09 09 onc ":" key))...
0a30: 20 20 20 20 20 20 20 28 70 61 74 74 20 20 20 28 (patt (
0a40: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 66 75 6c args:get-arg ful
0a50: 6b 65 79 29 29 29 0a 09 09 20 20 28 69 66 20 70 key)))... (if p
0a60: 61 74 74 0a 09 09 20 20 20 20 20 20 28 73 65 74 att... (set
0a70: 21 20 6b 65 79 2d 70 61 74 74 20 28 63 6f 6e 63 ! key-patt (conc
0a80: 20 6b 65 79 2d 70 61 74 74 20 22 20 41 4e 44 20 key-patt " AND
0a90: 22 20 6b 65 79 20 22 20 6c 69 6b 65 20 27 22 20 " key " like '"
0aa0: 70 61 74 74 20 22 27 22 29 29 0a 09 09 20 20 20 patt "'"))...
0ab0: 20 20 20 28 62 65 67 69 6e 0a 09 09 09 28 64 65 (begin....(de
0ac0: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 bug:print 0 "ERR
0ad0: 4f 52 3a 20 73 65 61 72 63 68 69 6e 67 20 66 6f OR: searching fo
0ae0: 72 20 72 75 6e 73 20 77 69 74 68 20 6e 6f 20 70 r runs with no p
0af0: 61 74 74 65 72 6e 20 73 65 74 20 66 6f 72 20 22 attern set for "
0b00: 20 66 75 6c 6b 65 79 29 0a 09 09 09 28 65 78 69 fulkey)....(exi
0b10: 74 20 36 29 29 29 29 29 0a 09 20 20 20 20 20 20 t 6)))))..
0b20: 6b 65 79 73 29 0a 20 20 20 20 28 73 71 6c 69 74 keys). (sqlit
0b30: 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77 20 e3:for-each-row
0b40: 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 61 . (lambda (a
0b50: 20 2e 20 72 29 0a 20 20 20 20 20 20 20 28 73 65 . r). (se
0b60: 74 21 20 72 65 73 20 28 63 6f 6e 73 20 28 6c 69 t! res (cons (li
0b70: 73 74 2d 3e 76 65 63 74 6f 72 20 28 63 6f 6e 73 st->vector (cons
0b80: 20 61 20 72 29 29 20 72 65 73 29 29 29 0a 20 20 a r)) res))).
0b90: 20 20 20 64 62 20 0a 20 20 20 20 20 28 63 6f 6e db . (con
0ba0: 63 20 22 53 45 4c 45 43 54 20 22 20 6b 65 79 73 c "SELECT " keys
0bb0: 74 72 20 22 20 46 52 4f 4d 20 72 75 6e 73 20 57 tr " FROM runs W
0bc0: 48 45 52 45 20 72 75 6e 6e 61 6d 65 20 6c 69 6b HERE runname lik
0bd0: 65 20 3f 20 22 20 6b 65 79 2d 70 61 74 74 20 22 e ? " key-patt "
0be0: 3b 22 29 0a 20 20 20 20 20 72 75 6e 6e 61 6d 65 ;"). runname
0bf0: 70 61 74 74 29 0a 20 20 20 20 28 76 65 63 74 6f patt). (vecto
0c00: 72 20 68 65 61 64 65 72 20 72 65 73 29 29 29 0a r header res))).
0c10: 0a 28 64 65 66 69 6e 65 20 28 72 65 67 69 73 74 .(define (regist
0c20: 65 72 2d 74 65 73 74 20 64 62 20 72 75 6e 2d 69 er-test db run-i
0c30: 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d d test-name item
0c40: 2d 70 61 74 68 29 0a 20 20 28 6c 65 74 20 28 28 -path). (let ((
0c50: 69 74 65 6d 2d 70 61 74 68 73 20 28 69 66 20 28 item-paths (if (
0c60: 65 71 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 equal? item-path
0c70: 20 22 22 29 0a 09 09 09 28 6c 69 73 74 20 69 74 "")....(list it
0c80: 65 6d 2d 70 61 74 68 29 0a 09 09 09 28 6c 69 73 em-path)....(lis
0c90: 74 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29 29 t item-path ""))
0ca0: 29 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 )). (for-each
0cb0: 20 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 . (lambda (
0cc0: 70 74 68 29 0a 20 20 20 20 20 20 20 28 73 71 6c pth). (sql
0cd0: 69 74 65 33 3a 65 78 65 63 75 74 65 20 64 62 20 ite3:execute db
0ce0: 22 49 4e 53 45 52 54 20 4f 52 20 49 47 4e 4f 52 "INSERT OR IGNOR
0cf0: 45 20 49 4e 54 4f 20 74 65 73 74 73 20 28 72 75 E INTO tests (ru
0d00: 6e 5f 69 64 2c 74 65 73 74 6e 61 6d 65 2c 65 76 n_id,testname,ev
0d10: 65 6e 74 5f 74 69 6d 65 2c 69 74 65 6d 5f 70 61 ent_time,item_pa
0d20: 74 68 2c 73 74 61 74 65 2c 73 74 61 74 75 73 29 th,state,status)
0d30: 20 56 41 4c 55 45 53 20 28 3f 2c 3f 2c 73 74 72 VALUES (?,?,str
0d40: 66 74 69 6d 65 28 27 25 73 27 2c 27 6e 6f 77 27 ftime('%s','now'
0d50: 29 2c 3f 2c 27 4e 4f 54 5f 53 54 41 52 54 45 44 ),?,'NOT_STARTED
0d60: 27 2c 27 6e 2f 61 27 29 3b 22 20 0a 09 09 09 72 ','n/a');" ....r
0d70: 75 6e 2d 69 64 20 0a 09 09 09 74 65 73 74 2d 6e un-id ....test-n
0d80: 61 6d 65 0a 09 09 09 70 74 68 20 0a 09 09 09 3b ame....pth ....;
0d90: 3b 20 28 63 6f 6e 63 20 22 2c 22 20 28 73 74 72 ; (conc "," (str
0da0: 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 ing-intersperse
0db0: 74 61 67 73 20 22 2c 22 29 20 22 2c 22 29 0a 09 tags ",") ",")..
0dc0: 09 09 29 29 0a 20 20 20 20 20 69 74 65 6d 2d 70 ..)). item-p
0dd0: 61 74 68 73 20 29 29 29 0a 0a 3b 3b 20 67 65 74 aths )))..;; get
0de0: 20 74 68 65 20 70 72 65 76 69 6f 75 73 20 72 65 the previous re
0df0: 63 6f 72 64 20 66 6f 72 20 77 68 65 6e 20 74 68 cord for when th
0e00: 69 73 20 74 65 73 74 20 77 61 73 20 72 75 6e 20 is test was run
0e10: 77 68 65 72 65 20 61 6c 6c 20 6b 65 79 73 20 6d where all keys m
0e20: 61 74 63 68 20 62 75 74 20 72 75 6e 6e 61 6d 65 atch but runname
0e30: 0a 3b 3b 20 72 65 74 75 72 6e 73 20 23 66 20 69 .;; returns #f i
0e40: 66 20 6e 6f 20 73 75 63 68 20 74 65 73 74 20 66 f no such test f
0e50: 6f 75 6e 64 2c 20 72 65 74 75 72 6e 73 20 61 20 ound, returns a
0e60: 73 69 6e 67 6c 65 20 74 65 73 74 20 72 65 63 6f single test reco
0e70: 72 64 20 69 66 20 66 6f 75 6e 64 0a 28 64 65 66 rd if found.(def
0e80: 69 6e 65 20 28 74 65 73 74 3a 67 65 74 2d 70 72 ine (test:get-pr
0e90: 65 76 69 6f 75 73 2d 74 65 73 74 2d 72 75 6e 2d evious-test-run-
0ea0: 72 65 63 6f 72 64 20 64 62 20 72 75 6e 2d 69 64 record db run-id
0eb0: 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d test-name item-
0ec0: 70 61 74 68 29 0a 20 20 28 6c 65 74 2a 20 28 28 path). (let* ((
0ed0: 6b 65 79 73 20 20 20 20 28 64 62 3a 67 65 74 2d keys (db:get-
0ee0: 6b 65 79 73 20 64 62 29 29 0a 09 20 28 73 65 6c keys db)).. (sel
0ef0: 73 74 72 20 20 28 73 74 72 69 6e 67 2d 69 6e 74 str (string-int
0f00: 65 72 73 70 65 72 73 65 20 28 6d 61 70 20 28 6c ersperse (map (l
0f10: 61 6d 62 64 61 20 28 78 29 28 76 65 63 74 6f 72 ambda (x)(vector
0f20: 2d 72 65 66 20 78 20 30 29 29 20 6b 65 79 73 29 -ref x 0)) keys)
0f30: 20 22 2c 22 29 29 0a 09 20 28 71 72 79 73 74 72 ",")).. (qrystr
0f40: 20 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 (string-inters
0f50: 70 65 72 73 65 20 28 6d 61 70 20 28 6c 61 6d 62 perse (map (lamb
0f60: 64 61 20 28 78 29 28 63 6f 6e 63 20 28 76 65 63 da (x)(conc (vec
0f70: 74 6f 72 2d 72 65 66 20 78 20 30 29 20 22 3d 3f tor-ref x 0) "=?
0f80: 22 29 29 20 6b 65 79 73 29 20 22 20 41 4e 44 20 ")) keys) " AND
0f90: 22 29 29 0a 09 20 28 6b 65 79 76 61 6c 73 20 23 ")).. (keyvals #
0fa0: 66 29 29 0a 20 20 20 20 3b 3b 20 66 69 72 73 74 f)). ;; first
0fb0: 20 6c 6f 6f 6b 20 75 70 20 74 68 65 20 6b 65 79 look up the key
0fc0: 20 76 61 6c 75 65 73 20 66 72 6f 6d 20 74 68 65 values from the
0fd0: 20 72 75 6e 20 73 65 6c 65 63 74 65 64 20 62 79 run selected by
0fe0: 20 72 75 6e 2d 69 64 0a 20 20 20 20 28 73 71 6c run-id. (sql
0ff0: 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f ite3:for-each-ro
1000: 77 20 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 w . (lambda
1010: 28 61 20 2e 20 62 29 0a 20 20 20 20 20 20 20 28 (a . b). (
1020: 73 65 74 21 20 6b 65 79 76 61 6c 73 20 28 63 6f set! keyvals (co
1030: 6e 73 20 61 20 62 29 29 29 0a 20 20 20 20 20 64 ns a b))). d
1040: 62 0a 20 20 20 20 20 28 63 6f 6e 63 20 22 53 45 b. (conc "SE
1050: 4c 45 43 54 20 22 20 73 65 6c 73 74 72 20 22 20 LECT " selstr "
1060: 46 52 4f 4d 20 72 75 6e 73 20 57 48 45 52 45 20 FROM runs WHERE
1070: 69 64 3d 3f 20 4f 52 44 45 52 20 42 59 20 65 76 id=? ORDER BY ev
1080: 65 6e 74 5f 74 69 6d 65 20 44 45 53 43 3b 22 29 ent_time DESC;")
1090: 20 72 75 6e 2d 69 64 29 0a 20 20 20 20 28 69 66 run-id). (if
10a0: 20 28 6e 6f 74 20 6b 65 79 76 61 6c 73 29 0a 09 (not keyvals)..
10b0: 23 66 0a 09 28 6c 65 74 20 28 28 70 72 65 76 2d #f..(let ((prev-
10c0: 72 75 6e 2d 69 64 73 20 27 28 29 29 29 0a 09 20 run-ids '()))..
10d0: 20 28 61 70 70 6c 79 20 73 71 6c 69 74 65 33 3a (apply sqlite3:
10e0: 66 6f 72 2d 65 61 63 68 2d 72 6f 77 0a 09 09 20 for-each-row...
10f0: 28 6c 61 6d 62 64 61 20 28 69 64 29 0a 09 09 20 (lambda (id)...
1100: 20 20 28 73 65 74 21 20 70 72 65 76 2d 72 75 6e (set! prev-run
1110: 2d 69 64 73 20 28 63 6f 6e 73 20 69 64 20 70 72 -ids (cons id pr
1120: 65 76 2d 72 75 6e 2d 69 64 73 29 29 29 0a 09 09 ev-run-ids)))...
1130: 20 64 62 0a 09 09 20 28 63 6f 6e 63 20 22 53 45 db... (conc "SE
1140: 4c 45 43 54 20 69 64 20 46 52 4f 4d 20 72 75 6e LECT id FROM run
1150: 73 20 57 48 45 52 45 20 22 20 71 72 79 73 74 72 s WHERE " qrystr
1160: 20 22 20 41 4e 44 20 69 64 20 21 3d 20 3f 3b 22 " AND id != ?;"
1170: 29 20 28 61 70 70 65 6e 64 20 6b 65 79 76 61 6c ) (append keyval
1180: 73 20 28 6c 69 73 74 20 72 75 6e 2d 69 64 29 29 s (list run-id))
1190: 29 0a 09 20 20 3b 3b 20 66 6f 72 20 65 61 63 68 ).. ;; for each
11a0: 20 72 75 6e 20 73 74 61 72 74 69 6e 67 20 77 69 run starting wi
11b0: 74 68 20 74 68 65 20 6d 6f 73 74 20 72 65 63 65 th the most rece
11c0: 6e 74 20 6c 6f 6f 6b 20 74 6f 20 73 65 65 20 69 nt look to see i
11d0: 66 20 74 68 65 72 65 20 69 73 20 61 20 6d 61 74 f there is a mat
11e0: 63 68 69 6e 67 20 74 65 73 74 0a 09 20 20 3b 3b ching test.. ;;
11f0: 20 69 66 20 66 6f 75 6e 64 20 74 68 65 6e 20 72 if found then r
1200: 65 74 75 72 6e 20 74 68 61 74 20 6d 61 74 63 68 eturn that match
1210: 69 6e 67 20 74 65 73 74 20 72 65 63 6f 72 64 0a ing test record.
1220: 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 . (debug:print
1230: 34 20 22 73 65 6c 73 74 72 3a 20 22 20 73 65 6c 4 "selstr: " sel
1240: 73 74 72 20 22 2c 20 71 72 79 73 74 72 3a 20 22 str ", qrystr: "
1250: 20 71 72 79 73 74 72 20 22 2c 20 6b 65 79 76 61 qrystr ", keyva
1260: 6c 73 3a 20 22 20 6b 65 79 76 61 6c 73 20 22 2c ls: " keyvals ",
1270: 20 70 72 65 76 69 6f 75 73 20 72 75 6e 20 69 64 previous run id
1280: 73 20 66 6f 75 6e 64 3a 20 22 20 70 72 65 76 2d s found: " prev-
1290: 72 75 6e 2d 69 64 73 29 0a 09 20 20 28 69 66 20 run-ids).. (if
12a0: 28 6e 75 6c 6c 3f 20 70 72 65 76 2d 72 75 6e 2d (null? prev-run-
12b0: 69 64 73 29 20 23 66 0a 09 20 20 20 20 20 20 28 ids) #f.. (
12c0: 6c 65 74 20 6c 6f 6f 70 20 28 28 68 65 64 20 28 let loop ((hed (
12d0: 63 61 72 20 70 72 65 76 2d 72 75 6e 2d 69 64 73 car prev-run-ids
12e0: 29 29 0a 09 09 09 20 28 74 61 6c 20 28 63 64 72 )).... (tal (cdr
12f0: 20 70 72 65 76 2d 72 75 6e 2d 69 64 73 29 29 29 prev-run-ids)))
1300: 0a 09 09 28 6c 65 74 20 28 28 72 65 73 75 6c 74 ...(let ((result
1310: 73 20 28 64 62 2d 67 65 74 2d 74 65 73 74 73 2d s (db-get-tests-
1320: 66 6f 72 2d 72 75 6e 20 64 62 20 68 65 64 20 74 for-run db hed t
1330: 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 est-name item-pa
1340: 74 68 29 29 29 0a 09 09 20 20 28 64 65 62 75 67 th)))... (debug
1350: 3a 70 72 69 6e 74 20 34 20 22 47 6f 74 20 74 65 :print 4 "Got te
1360: 73 74 73 20 66 6f 72 20 72 75 6e 2d 69 64 20 22 sts for run-id "
1370: 20 72 75 6e 2d 69 64 20 22 2c 20 74 65 73 74 2d run-id ", test-
1380: 6e 61 6d 65 20 22 20 74 65 73 74 2d 6e 61 6d 65 name " test-name
1390: 20 22 2c 20 69 74 65 6d 2d 70 61 74 68 20 22 20 ", item-path "
13a0: 69 74 65 6d 2d 70 61 74 68 20 22 3a 20 22 20 72 item-path ": " r
13b0: 65 73 75 6c 74 73 29 0a 09 09 20 20 28 69 66 20 esults)... (if
13c0: 28 61 6e 64 20 28 6e 75 6c 6c 3f 20 72 65 73 75 (and (null? resu
13d0: 6c 74 73 29 0a 09 09 09 20 20 20 28 6e 6f 74 20 lts).... (not
13e0: 28 6e 75 6c 6c 3f 20 74 61 6c 29 29 29 0a 09 09 (null? tal)))...
13f0: 20 20 20 20 20 20 28 6c 6f 6f 70 20 28 63 61 72 (loop (car
1400: 20 74 61 6c 29 28 63 64 72 20 74 61 6c 29 29 0a tal)(cdr tal)).
1410: 09 09 20 20 20 20 20 20 28 63 61 72 20 72 65 73 .. (car res
1420: 75 6c 74 73 29 29 29 29 29 29 29 29 29 0a 20 20 ults))))))))).
1430: 20 20 0a 3b 3b 20 67 65 74 20 74 68 65 20 70 72 .;; get the pr
1440: 65 76 69 6f 75 73 20 72 65 63 6f 72 64 73 20 66 evious records f
1450: 6f 72 20 77 68 65 6e 20 74 68 65 73 65 20 74 65 or when these te
1460: 73 74 73 20 77 65 72 65 20 72 75 6e 20 77 68 65 sts were run whe
1470: 72 65 20 61 6c 6c 20 6b 65 79 73 20 6d 61 74 63 re all keys matc
1480: 68 20 62 75 74 20 72 75 6e 6e 61 6d 65 0a 3b 3b h but runname.;;
1490: 20 4e 42 2f 2f 20 4d 65 72 67 65 20 74 68 69 73 NB// Merge this
14a0: 20 77 69 74 68 20 74 65 73 74 3a 67 65 74 2d 70 with test:get-p
14b0: 72 65 76 69 6f 75 73 2d 74 65 73 74 2d 72 75 6e revious-test-run
14c0: 2d 72 65 63 6f 72 64 73 3f 20 54 68 69 73 20 6f -records? This o
14d0: 6e 65 20 6c 6f 6f 6b 73 20 66 6f 72 20 61 6c 6c ne looks for all
14e0: 20 6d 61 74 63 68 69 6e 67 20 74 65 73 74 73 0a matching tests.
14f0: 3b 3b 20 63 61 6e 20 75 73 65 20 77 69 6c 64 63 ;; can use wildc
1500: 61 72 64 73 2e 20 0a 28 64 65 66 69 6e 65 20 28 ards. .(define (
1510: 74 65 73 74 3a 67 65 74 2d 6d 61 74 63 68 69 6e test:get-matchin
1520: 67 2d 70 72 65 76 69 6f 75 73 2d 74 65 73 74 2d g-previous-test-
1530: 72 75 6e 2d 72 65 63 6f 72 64 73 20 64 62 20 72 run-records db r
1540: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 un-id test-name
1550: 69 74 65 6d 2d 70 61 74 68 29 0a 20 20 28 6c 65 item-path). (le
1560: 74 2a 20 28 28 6b 65 79 73 20 20 20 20 28 64 62 t* ((keys (db
1570: 3a 67 65 74 2d 6b 65 79 73 20 64 62 29 29 0a 09 :get-keys db))..
1580: 20 28 73 65 6c 73 74 72 20 20 28 73 74 72 69 6e (selstr (strin
1590: 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 28 6d g-intersperse (m
15a0: 61 70 20 28 6c 61 6d 62 64 61 20 28 78 29 28 76 ap (lambda (x)(v
15b0: 65 63 74 6f 72 2d 72 65 66 20 78 20 30 29 29 20 ector-ref x 0))
15c0: 6b 65 79 73 29 20 22 2c 22 29 29 0a 09 20 28 71 keys) ",")).. (q
15d0: 72 79 73 74 72 20 20 28 73 74 72 69 6e 67 2d 69 rystr (string-i
15e0: 6e 74 65 72 73 70 65 72 73 65 20 28 6d 61 70 20 ntersperse (map
15f0: 28 6c 61 6d 62 64 61 20 28 78 29 28 63 6f 6e 63 (lambda (x)(conc
1600: 20 28 76 65 63 74 6f 72 2d 72 65 66 20 78 20 30 (vector-ref x 0
1610: 29 20 22 3d 3f 22 29 29 20 6b 65 79 73 29 20 22 ) "=?")) keys) "
1620: 20 41 4e 44 20 22 29 29 0a 09 20 28 6b 65 79 76 AND ")).. (keyv
1630: 61 6c 73 20 23 66 29 0a 09 20 28 74 65 73 74 73 als #f).. (tests
1640: 2d 68 61 73 68 20 28 6d 61 6b 65 2d 68 61 73 68 -hash (make-hash
1650: 2d 74 61 62 6c 65 29 29 29 0a 20 20 20 20 3b 3b -table))). ;;
1660: 20 66 69 72 73 74 20 6c 6f 6f 6b 20 75 70 20 74 first look up t
1670: 68 65 20 6b 65 79 20 76 61 6c 75 65 73 20 66 72 he key values fr
1680: 6f 6d 20 74 68 65 20 72 75 6e 20 73 65 6c 65 63 om the run selec
1690: 74 65 64 20 62 79 20 72 75 6e 2d 69 64 0a 20 20 ted by run-id.
16a0: 20 20 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 (sqlite3:for-e
16b0: 61 63 68 2d 72 6f 77 20 0a 20 20 20 20 20 28 6c ach-row . (l
16c0: 61 6d 62 64 61 20 28 61 20 2e 20 62 29 0a 20 20 ambda (a . b).
16d0: 20 20 20 20 20 28 73 65 74 21 20 6b 65 79 76 61 (set! keyva
16e0: 6c 73 20 28 63 6f 6e 73 20 61 20 62 29 29 29 0a ls (cons a b))).
16f0: 20 20 20 20 20 64 62 0a 20 20 20 20 20 28 63 6f db. (co
1700: 6e 63 20 22 53 45 4c 45 43 54 20 22 20 73 65 6c nc "SELECT " sel
1710: 73 74 72 20 22 20 46 52 4f 4d 20 72 75 6e 73 20 str " FROM runs
1720: 57 48 45 52 45 20 69 64 3d 3f 20 4f 52 44 45 52 WHERE id=? ORDER
1730: 20 42 59 20 65 76 65 6e 74 5f 74 69 6d 65 20 44 BY event_time D
1740: 45 53 43 3b 22 29 20 72 75 6e 2d 69 64 29 0a 20 ESC;") run-id).
1750: 20 20 20 28 69 66 20 28 6e 6f 74 20 6b 65 79 76 (if (not keyv
1760: 61 6c 73 29 0a 09 27 28 29 0a 09 28 6c 65 74 20 als)..'()..(let
1770: 28 28 70 72 65 76 2d 72 75 6e 2d 69 64 73 20 27 ((prev-run-ids '
1780: 28 29 29 29 0a 09 20 20 28 61 70 70 6c 79 20 73 ())).. (apply s
1790: 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d qlite3:for-each-
17a0: 72 6f 77 0a 09 09 20 28 6c 61 6d 62 64 61 20 28 row... (lambda (
17b0: 69 64 29 0a 09 09 20 20 20 28 73 65 74 21 20 70 id)... (set! p
17c0: 72 65 76 2d 72 75 6e 2d 69 64 73 20 28 63 6f 6e rev-run-ids (con
17d0: 73 20 69 64 20 70 72 65 76 2d 72 75 6e 2d 69 64 s id prev-run-id
17e0: 73 29 29 29 0a 09 09 20 64 62 0a 09 09 20 28 63 s)))... db... (c
17f0: 6f 6e 63 20 22 53 45 4c 45 43 54 20 69 64 20 46 onc "SELECT id F
1800: 52 4f 4d 20 72 75 6e 73 20 57 48 45 52 45 20 22 ROM runs WHERE "
1810: 20 71 72 79 73 74 72 20 22 20 41 4e 44 20 69 64 qrystr " AND id
1820: 20 21 3d 20 3f 3b 22 29 20 28 61 70 70 65 6e 64 != ?;") (append
1830: 20 6b 65 79 76 61 6c 73 20 28 6c 69 73 74 20 72 keyvals (list r
1840: 75 6e 2d 69 64 29 29 29 0a 09 20 20 3b 3b 20 63 un-id))).. ;; c
1850: 6f 6c 6c 65 63 74 20 61 6c 6c 20 6d 61 74 63 68 ollect all match
1860: 69 6e 67 20 74 65 73 74 73 20 66 6f 72 20 74 68 ing tests for th
1870: 65 20 72 75 6e 73 20 74 68 65 6e 0a 09 20 20 3b e runs then.. ;
1880: 3b 20 65 78 74 72 61 63 74 20 74 68 65 20 6d 6f ; extract the mo
1890: 73 74 20 72 65 63 65 6e 74 20 74 65 73 74 20 61 st recent test a
18a0: 6e 64 20 72 65 74 75 72 6e 20 74 68 61 74 2e 0a nd return that..
18b0: 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 . (debug:print
18c0: 34 20 22 73 65 6c 73 74 72 3a 20 22 20 73 65 6c 4 "selstr: " sel
18d0: 73 74 72 20 22 2c 20 71 72 79 73 74 72 3a 20 22 str ", qrystr: "
18e0: 20 71 72 79 73 74 72 20 22 2c 20 6b 65 79 76 61 qrystr ", keyva
18f0: 6c 73 3a 20 22 20 6b 65 79 76 61 6c 73 20 0a 09 ls: " keyvals ..
1900: 09 20 20 20 20 20 20 20 22 2c 20 70 72 65 76 69 . ", previ
1910: 6f 75 73 20 72 75 6e 20 69 64 73 20 66 6f 75 6e ous run ids foun
1920: 64 3a 20 22 20 70 72 65 76 2d 72 75 6e 2d 69 64 d: " prev-run-id
1930: 73 29 0a 09 20 20 28 69 66 20 28 6e 75 6c 6c 3f s).. (if (null?
1940: 20 70 72 65 76 2d 72 75 6e 2d 69 64 73 29 20 27 prev-run-ids) '
1950: 28 29 20 20 3b 3b 20 6e 6f 20 70 72 65 76 69 6f () ;; no previo
1960: 75 73 20 72 75 6e 73 3f 20 72 65 74 75 72 6e 20 us runs? return
1970: 6e 75 6c 6c 0a 09 20 20 20 20 20 20 28 6c 65 74 null.. (let
1980: 20 6c 6f 6f 70 20 28 28 68 65 64 20 28 63 61 72 loop ((hed (car
1990: 20 70 72 65 76 2d 72 75 6e 2d 69 64 73 29 29 0a prev-run-ids)).
19a0: 09 09 09 20 28 74 61 6c 20 28 63 64 72 20 70 72 ... (tal (cdr pr
19b0: 65 76 2d 72 75 6e 2d 69 64 73 29 29 29 0a 09 09 ev-run-ids)))...
19c0: 28 6c 65 74 20 28 28 72 65 73 75 6c 74 73 20 28 (let ((results (
19d0: 64 62 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f 72 db-get-tests-for
19e0: 2d 72 75 6e 20 64 62 20 68 65 64 20 74 65 73 74 -run db hed test
19f0: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 -name item-path)
1a00: 29 29 0a 09 09 20 20 28 64 65 62 75 67 3a 70 72 ))... (debug:pr
1a10: 69 6e 74 20 34 20 22 47 6f 74 20 74 65 73 74 73 int 4 "Got tests
1a20: 20 66 6f 72 20 72 75 6e 2d 69 64 20 22 20 72 75 for run-id " ru
1a30: 6e 2d 69 64 20 22 2c 20 74 65 73 74 2d 6e 61 6d n-id ", test-nam
1a40: 65 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 0a 09 e " test-name ..
1a50: 09 09 20 20 20 20 20 20 20 22 2c 20 69 74 65 6d .. ", item
1a60: 2d 70 61 74 68 20 22 20 69 74 65 6d 2d 70 61 74 -path " item-pat
1a70: 68 20 22 20 72 65 73 75 6c 74 73 3a 20 22 20 28 h " results: " (
1a80: 69 6e 74 65 72 73 70 65 72 73 65 20 72 65 73 75 intersperse resu
1a90: 6c 74 73 20 22 5c 6e 22 29 29 0a 09 09 20 20 3b lts "\n"))... ;
1aa0: 3b 20 4b 65 65 70 20 6f 6e 6c 79 20 74 68 65 20 ; Keep only the
1ab0: 79 6f 75 6e 67 65 73 74 20 6f 66 20 61 6e 79 20 youngest of any
1ac0: 74 65 73 74 2f 69 74 65 6d 20 63 6f 6d 62 69 6e test/item combin
1ad0: 61 74 69 6f 6e 0a 09 09 20 20 28 66 6f 72 2d 65 ation... (for-e
1ae0: 61 63 68 20 0a 09 09 20 20 20 28 6c 61 6d 62 64 ach ... (lambd
1af0: 61 20 28 74 65 73 74 64 61 74 29 0a 09 09 20 20 a (testdat)...
1b00: 20 20 20 28 6c 65 74 2a 20 28 28 66 75 6c 6c 2d (let* ((full-
1b10: 74 65 73 74 6e 61 6d 65 20 28 63 6f 6e 63 20 28 testname (conc (
1b20: 64 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74 db:test-get-test
1b30: 6e 61 6d 65 20 74 65 73 74 64 61 74 29 20 22 2f name testdat) "/
1b40: 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 " (db:test-get-i
1b50: 74 65 6d 2d 70 61 74 68 20 74 65 73 74 64 61 74 tem-path testdat
1b60: 29 29 29 0a 09 09 09 20 20 20 20 28 73 74 6f 72 ))).... (stor
1b70: 65 64 2d 74 65 73 74 20 20 20 28 68 61 73 68 2d ed-test (hash-
1b80: 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c table-ref/defaul
1b90: 74 20 74 65 73 74 73 2d 68 61 73 68 20 66 75 6c t tests-hash ful
1ba0: 6c 2d 74 65 73 74 6e 61 6d 65 20 23 66 29 29 29 l-testname #f)))
1bb0: 0a 09 09 20 20 20 20 20 20 20 28 69 66 20 28 6f ... (if (o
1bc0: 72 20 28 6e 6f 74 20 73 74 6f 72 65 64 2d 74 65 r (not stored-te
1bd0: 73 74 29 0a 09 09 09 20 20 20 20 20 20 20 28 61 st).... (a
1be0: 6e 64 20 73 74 6f 72 65 64 2d 74 65 73 74 0a 09 nd stored-test..
1bf0: 09 09 09 20 20 20 20 28 3e 20 28 64 62 3a 74 65 ... (> (db:te
1c00: 73 74 2d 67 65 74 2d 65 76 65 6e 74 5f 74 69 6d st-get-event_tim
1c10: 65 20 74 65 73 74 64 61 74 29 28 64 62 3a 74 65 e testdat)(db:te
1c20: 73 74 2d 67 65 74 2d 65 76 65 6e 74 5f 74 69 6d st-get-event_tim
1c30: 65 20 73 74 6f 72 65 64 2d 74 65 73 74 29 29 29 e stored-test)))
1c40: 29 0a 09 09 09 20 20 20 3b 3b 20 74 68 69 73 20 ).... ;; this
1c50: 74 65 73 74 20 69 73 20 79 6f 75 6e 67 65 72 2c test is younger,
1c60: 20 73 74 6f 72 65 20 69 74 20 69 6e 20 74 68 65 store it in the
1c70: 20 68 61 73 68 0a 09 09 09 20 20 20 28 68 61 73 hash.... (has
1c80: 68 2d 74 61 62 6c 65 2d 73 65 74 21 20 74 65 73 h-table-set! tes
1c90: 74 73 2d 68 61 73 68 20 66 75 6c 6c 2d 74 65 73 ts-hash full-tes
1ca0: 74 6e 61 6d 65 20 74 65 73 74 64 61 74 29 29 29 tname testdat)))
1cb0: 29 0a 09 09 20 20 20 72 65 73 75 6c 74 73 29 0a )... results).
1cc0: 09 09 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 74 .. (if (null? t
1cd0: 61 6c 29 0a 09 09 20 20 20 20 20 20 28 6d 61 70 al)... (map
1ce0: 20 63 64 72 20 28 68 61 73 68 2d 74 61 62 6c 65 cdr (hash-table
1cf0: 2d 3e 61 6c 69 73 74 20 74 65 73 74 73 2d 68 61 ->alist tests-ha
1d00: 73 68 29 29 20 3b 3b 20 72 65 74 75 72 6e 20 61 sh)) ;; return a
1d10: 20 6c 69 73 74 20 6f 66 20 74 68 65 20 6d 6f 73 list of the mos
1d20: 74 20 72 65 63 65 6e 74 20 74 65 73 74 73 0a 09 t recent tests..
1d30: 09 20 20 20 20 20 20 28 6c 6f 6f 70 20 28 63 61 . (loop (ca
1d40: 72 20 74 61 6c 29 28 63 64 72 20 74 61 6c 29 29 r tal)(cdr tal))
1d50: 29 29 29 29 29 29 29 29 0a 0a 28 64 65 66 69 6e ))))))))..(defin
1d60: 65 20 28 74 65 73 74 2d 73 65 74 2d 73 74 61 74 e (test-set-stat
1d70: 75 73 21 20 64 62 20 72 75 6e 2d 69 64 20 74 65 us! db run-id te
1d80: 73 74 2d 6e 61 6d 65 20 73 74 61 74 65 20 73 74 st-name state st
1d90: 61 74 75 73 20 69 74 65 6d 64 61 74 2d 6f 72 2d atus itemdat-or-
1da0: 70 61 74 68 20 63 6f 6d 6d 65 6e 74 20 64 61 74 path comment dat
1db0: 29 0a 20 20 28 6c 65 74 2a 20 28 28 72 65 61 6c ). (let* ((real
1dc0: 2d 73 74 61 74 75 73 20 73 74 61 74 75 73 29 0a -status status).
1dd0: 09 20 28 69 74 65 6d 2d 70 61 74 68 20 20 20 28 . (item-path (
1de0: 69 66 20 28 73 74 72 69 6e 67 3f 20 69 74 65 6d if (string? item
1df0: 64 61 74 2d 6f 72 2d 70 61 74 68 29 20 69 74 65 dat-or-path) ite
1e00: 6d 64 61 74 2d 6f 72 2d 70 61 74 68 20 28 69 74 mdat-or-path (it
1e10: 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69 74 em-list->path it
1e20: 65 6d 64 61 74 2d 6f 72 2d 70 61 74 68 29 29 29 emdat-or-path)))
1e30: 0a 09 20 28 6f 74 68 65 72 64 61 74 20 20 20 20 .. (otherdat
1e40: 28 69 66 20 64 61 74 20 64 61 74 20 28 6d 61 6b (if dat dat (mak
1e50: 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29 29 0a e-hash-table))).
1e60: 09 20 3b 3b 20 62 65 66 6f 72 65 20 70 72 6f 63 . ;; before proc
1e70: 65 65 64 69 6e 67 20 77 65 20 6d 75 73 74 20 66 eeding we must f
1e80: 69 6e 64 20 6f 75 74 20 69 66 20 74 68 65 20 70 ind out if the p
1e90: 72 65 76 69 6f 75 73 20 74 65 73 74 20 28 77 68 revious test (wh
1ea0: 65 72 65 20 61 6c 6c 20 6b 65 79 73 20 6d 61 74 ere all keys mat
1eb0: 63 68 65 64 20 65 78 63 65 70 74 20 72 75 6e 6e ched except runn
1ec0: 61 6d 65 29 0a 09 20 3b 3b 20 77 61 73 20 57 41 ame).. ;; was WA
1ed0: 49 56 45 44 20 69 66 20 74 68 69 73 20 74 65 73 IVED if this tes
1ee0: 74 20 69 73 20 46 41 49 4c 0a 09 20 28 77 61 69 t is FAIL.. (wai
1ef0: 76 65 64 20 20 20 28 69 66 20 28 65 71 75 61 6c ved (if (equal
1f00: 3f 20 73 74 61 74 75 73 20 22 46 41 49 4c 22 29 ? status "FAIL")
1f10: 0a 09 09 20 20 20 20 20 20 20 28 6c 65 74 20 28 ... (let (
1f20: 28 70 72 65 76 2d 74 65 73 74 20 28 74 65 73 74 (prev-test (test
1f30: 3a 67 65 74 2d 70 72 65 76 69 6f 75 73 2d 74 65 :get-previous-te
1f40: 73 74 2d 72 75 6e 2d 72 65 63 6f 72 64 20 64 62 st-run-record db
1f50: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d run-id test-nam
1f60: 65 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 09 e item-path)))..
1f70: 09 09 20 28 69 66 20 70 72 65 76 2d 74 65 73 74 .. (if prev-test
1f80: 20 3b 3b 20 74 72 75 65 20 69 66 20 77 65 20 66 ;; true if we f
1f90: 6f 75 6e 64 20 61 20 70 72 65 76 69 6f 75 73 20 ound a previous
1fa0: 74 65 73 74 20 69 6e 20 74 68 69 73 20 72 75 6e test in this run
1fb0: 20 73 65 72 69 65 73 0a 09 09 09 20 20 20 20 20 series....
1fc0: 28 6c 65 74 20 28 28 70 72 65 76 2d 73 74 61 74 (let ((prev-stat
1fd0: 75 73 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d us (db:test-get-
1fe0: 73 74 61 74 75 73 20 20 20 70 72 65 76 2d 74 65 status prev-te
1ff0: 73 74 29 29 0a 09 09 09 09 20 20 20 28 70 72 65 st))..... (pre
2000: 76 2d 73 74 61 74 65 20 20 28 64 62 3a 74 65 73 v-state (db:tes
2010: 74 2d 67 65 74 2d 73 74 61 74 65 20 20 20 20 70 t-get-state p
2020: 72 65 76 2d 74 65 73 74 29 29 0a 09 09 09 09 20 rev-test)).....
2030: 20 20 28 70 72 65 76 2d 63 6f 6d 6d 65 6e 74 20 (prev-comment
2040: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 63 6f 6d (db:test-get-com
2050: 6d 65 6e 74 20 70 72 65 76 2d 74 65 73 74 29 29 ment prev-test))
2060: 29 0a 09 09 09 20 20 20 20 20 20 20 28 64 65 62 ).... (deb
2070: 75 67 3a 70 72 69 6e 74 20 34 20 22 70 72 65 76 ug:print 4 "prev
2080: 2d 73 74 61 74 75 73 20 22 20 70 72 65 76 2d 73 -status " prev-s
2090: 74 61 74 75 73 20 22 2c 20 70 72 65 76 2d 73 74 tatus ", prev-st
20a0: 61 74 65 20 22 20 70 72 65 76 2d 73 74 61 74 65 ate " prev-state
20b0: 20 22 2c 20 70 72 65 76 2d 63 6f 6d 6d 65 6e 74 ", prev-comment
20c0: 20 22 20 70 72 65 76 2d 63 6f 6d 6d 65 6e 74 29 " prev-comment)
20d0: 0a 09 09 09 20 20 20 20 20 20 20 28 69 66 20 28 .... (if (
20e0: 61 6e 64 20 28 65 71 75 61 6c 3f 20 70 72 65 76 and (equal? prev
20f0: 2d 73 74 61 74 65 20 20 22 43 4f 4d 50 4c 45 54 -state "COMPLET
2100: 45 44 22 29 0a 09 09 09 09 09 28 65 71 75 61 6c ED")......(equal
2110: 3f 20 70 72 65 76 2d 73 74 61 74 75 73 20 22 57 ? prev-status "W
2120: 41 49 56 45 44 22 29 29 0a 09 09 09 09 20 20 20 AIVED")).....
2130: 70 72 65 76 2d 63 6f 6d 6d 65 6e 74 20 3b 3b 20 prev-comment ;;
2140: 77 61 69 76 65 64 20 69 73 20 65 69 74 68 65 72 waived is either
2150: 20 74 68 65 20 63 6f 6d 6d 65 6e 74 20 6f 72 20 the comment or
2160: 23 66 0a 09 09 09 09 20 20 20 23 66 29 29 0a 09 #f..... #f))..
2170: 09 09 20 20 20 20 20 23 66 29 29 0a 09 09 20 20 .. #f))...
2180: 20 20 20 20 20 23 66 29 29 29 0a 20 20 20 20 28 #f))). (
2190: 69 66 20 77 61 69 76 65 64 20 28 73 65 74 21 20 if waived (set!
21a0: 72 65 61 6c 2d 73 74 61 74 75 73 20 22 57 41 49 real-status "WAI
21b0: 56 45 44 22 29 29 0a 20 20 20 20 28 64 65 62 75 VED")). (debu
21c0: 67 3a 70 72 69 6e 74 20 34 20 22 72 65 61 6c 2d g:print 4 "real-
21d0: 73 74 61 74 75 73 20 22 20 72 65 61 6c 2d 73 74 status " real-st
21e0: 61 74 75 73 20 22 2c 20 77 61 69 76 65 64 20 22 atus ", waived "
21f0: 20 77 61 69 76 65 64 20 22 2c 20 73 74 61 74 75 waived ", statu
2200: 73 20 22 20 73 74 61 74 75 73 29 0a 0a 20 20 20 s " status)..
2210: 20 3b 3b 20 75 70 64 61 74 65 20 74 68 65 20 70 ;; update the p
2220: 72 69 6d 61 72 79 20 72 65 63 6f 72 64 20 49 46 rimary record IF
2230: 20 73 74 61 74 65 20 41 4e 44 20 73 74 61 74 75 state AND statu
2240: 73 20 61 72 65 20 64 65 66 69 6e 65 64 0a 20 20 s are defined.
2250: 20 20 28 69 66 20 28 61 6e 64 20 73 74 61 74 65 (if (and state
2260: 20 73 74 61 74 75 73 29 0a 09 28 73 71 6c 69 74 status)..(sqlit
2270: 65 33 3a 65 78 65 63 75 74 65 20 64 62 20 22 55 e3:execute db "U
2280: 50 44 41 54 45 20 74 65 73 74 73 20 53 45 54 20 PDATE tests SET
2290: 73 74 61 74 65 3d 3f 2c 73 74 61 74 75 73 3d 3f state=?,status=?
22a0: 2c 65 76 65 6e 74 5f 74 69 6d 65 3d 73 74 72 66 ,event_time=strf
22b0: 74 69 6d 65 28 27 25 73 27 2c 27 6e 6f 77 27 29 time('%s','now')
22c0: 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 WHERE run_id=?
22d0: 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 AND testname=? A
22e0: 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f 3b 22 ND item_path=?;"
22f0: 20 0a 09 09 09 20 73 74 61 74 65 20 72 65 61 6c .... state real
2300: 2d 73 74 61 74 75 73 20 72 75 6e 2d 69 64 20 74 -status run-id t
2310: 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 est-name item-pa
2320: 74 68 29 29 0a 20 20 20 20 3b 3b 20 61 64 64 20 th)). ;; add
2330: 6d 65 74 61 64 61 74 61 20 28 6e 65 65 64 20 74 metadata (need t
2340: 6f 20 64 6f 20 74 68 69 73 20 77 61 79 20 74 6f o do this way to
2350: 20 61 76 6f 69 64 20 53 51 4c 20 69 6e 6a 65 63 avoid SQL injec
2360: 74 69 6f 6e 20 69 73 73 75 65 73 29 0a 20 20 20 tion issues).
2370: 20 3b 3b 20 3a 76 61 6c 75 65 0a 20 20 20 20 28 ;; :value. (
2380: 6c 65 74 20 28 28 76 61 6c 20 28 68 61 73 68 2d let ((val (hash-
2390: 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c table-ref/defaul
23a0: 74 20 6f 74 68 65 72 64 61 74 20 22 3a 76 61 6c t otherdat ":val
23b0: 75 65 22 20 23 66 29 29 29 0a 20 20 20 20 20 20 ue" #f))).
23c0: 28 69 66 20 76 61 6c 0a 09 20 20 28 73 71 6c 69 (if val.. (sqli
23d0: 74 65 33 3a 65 78 65 63 75 74 65 20 64 62 20 22 te3:execute db "
23e0: 55 50 44 41 54 45 20 74 65 73 74 73 20 53 45 54 UPDATE tests SET
23f0: 20 76 61 6c 75 65 3d 3f 20 57 48 45 52 45 20 72 value=? WHERE r
2400: 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 un_id=? AND test
2410: 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f name=? AND item_
2420: 70 61 74 68 3d 3f 3b 22 20 76 61 6c 20 72 75 6e path=?;" val run
2430: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 -id test-name it
2440: 65 6d 2d 70 61 74 68 29 29 29 0a 20 20 20 20 3b em-path))). ;
2450: 3b 20 3a 65 78 70 65 63 74 65 64 5f 76 61 6c 75 ; :expected_valu
2460: 65 0a 20 20 20 20 28 6c 65 74 20 28 28 76 61 6c e. (let ((val
2470: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 (hash-table-ref
2480: 2f 64 65 66 61 75 6c 74 20 6f 74 68 65 72 64 61 /default otherda
2490: 74 20 22 3a 65 78 70 65 63 74 65 64 5f 76 61 6c t ":expected_val
24a0: 75 65 22 20 23 66 29 29 29 0a 20 20 20 20 20 20 ue" #f))).
24b0: 28 69 66 20 76 61 6c 0a 09 20 20 28 73 71 6c 69 (if val.. (sqli
24c0: 74 65 33 3a 65 78 65 63 75 74 65 20 64 62 20 22 te3:execute db "
24d0: 55 50 44 41 54 45 20 74 65 73 74 73 20 53 45 54 UPDATE tests SET
24e0: 20 65 78 70 65 63 74 65 64 5f 76 61 6c 75 65 3d expected_value=
24f0: 3f 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f ? WHERE run_id=?
2500: 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 AND testname=?
2510: 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f 3b AND item_path=?;
2520: 22 20 76 61 6c 20 72 75 6e 2d 69 64 20 74 65 73 " val run-id tes
2530: 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 t-name item-path
2540: 29 29 29 0a 20 20 20 20 3b 3b 20 3a 74 6f 6c 0a ))). ;; :tol.
2550: 20 20 20 20 28 6c 65 74 20 28 28 76 61 6c 20 28 (let ((val (
2560: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 hash-table-ref/d
2570: 65 66 61 75 6c 74 20 6f 74 68 65 72 64 61 74 20 efault otherdat
2580: 22 3a 74 6f 6c 22 20 23 66 29 29 29 0a 20 20 20 ":tol" #f))).
2590: 20 20 20 28 69 66 20 76 61 6c 0a 09 20 20 28 73 (if val.. (s
25a0: 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 64 qlite3:execute d
25b0: 62 20 22 55 50 44 41 54 45 20 74 65 73 74 73 20 b "UPDATE tests
25c0: 53 45 54 20 74 6f 6c 3d 3f 20 57 48 45 52 45 20 SET tol=? WHERE
25d0: 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 run_id=? AND tes
25e0: 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d tname=? AND item
25f0: 5f 70 61 74 68 3d 3f 3b 22 20 76 61 6c 20 72 75 _path=?;" val ru
2600: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 n-id test-name i
2610: 74 65 6d 2d 70 61 74 68 29 29 29 0a 20 20 20 20 tem-path))).
2620: 3b 3b 20 3a 66 69 72 73 74 5f 65 72 72 0a 20 20 ;; :first_err.
2630: 20 20 28 6c 65 74 20 28 28 76 61 6c 20 28 68 61 (let ((val (ha
2640: 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 sh-table-ref/def
2650: 61 75 6c 74 20 6f 74 68 65 72 64 61 74 20 22 3a ault otherdat ":
2660: 66 69 72 73 74 5f 65 72 72 22 20 23 66 29 29 29 first_err" #f)))
2670: 0a 20 20 20 20 20 20 28 69 66 20 76 61 6c 0a 09 . (if val..
2680: 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75 (sqlite3:execu
2690: 74 65 20 64 62 20 22 55 50 44 41 54 45 20 74 65 te db "UPDATE te
26a0: 73 74 73 20 53 45 54 20 66 69 72 73 74 5f 65 72 sts SET first_er
26b0: 72 3d 3f 20 57 48 45 52 45 20 72 75 6e 5f 69 64 r=? WHERE run_id
26c0: 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d =? AND testname=
26d0: 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d ? AND item_path=
26e0: 3f 3b 22 20 76 61 6c 20 72 75 6e 2d 69 64 20 74 ?;" val run-id t
26f0: 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 est-name item-pa
2700: 74 68 29 29 29 0a 20 20 20 20 3b 3b 20 3a 66 69 th))). ;; :fi
2710: 72 73 74 5f 77 61 72 6e 0a 20 20 20 20 28 6c 65 rst_warn. (le
2720: 74 20 28 28 76 61 6c 20 28 68 61 73 68 2d 74 61 t ((val (hash-ta
2730: 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 ble-ref/default
2740: 6f 74 68 65 72 64 61 74 20 22 3a 66 69 72 73 74 otherdat ":first
2750: 5f 77 61 72 6e 22 20 23 66 29 29 29 0a 20 20 20 _warn" #f))).
2760: 20 20 20 28 69 66 20 76 61 6c 0a 09 20 20 28 73 (if val.. (s
2770: 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 64 qlite3:execute d
2780: 62 20 22 55 50 44 41 54 45 20 74 65 73 74 73 20 b "UPDATE tests
2790: 53 45 54 20 66 69 72 73 74 5f 77 61 72 6e 3d 3f SET first_warn=?
27a0: 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 WHERE run_id=?
27b0: 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 AND testname=? A
27c0: 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f 3b 22 ND item_path=?;"
27d0: 20 76 61 6c 20 72 75 6e 2d 69 64 20 74 65 73 74 val run-id test
27e0: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 -name item-path)
27f0: 29 29 0a 20 20 20 20 28 6c 65 74 20 28 28 76 61 )). (let ((va
2800: 6c 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 l (hash-table-re
2810: 66 2f 64 65 66 61 75 6c 74 20 6f 74 68 65 72 64 f/default otherd
2820: 61 74 20 22 3a 75 6e 69 74 73 22 20 23 66 29 29 at ":units" #f))
2830: 29 0a 20 20 20 20 20 20 28 69 66 20 76 61 6c 0a ). (if val.
2840: 09 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63 . (sqlite3:exec
2850: 75 74 65 20 64 62 20 22 55 50 44 41 54 45 20 74 ute db "UPDATE t
2860: 65 73 74 73 20 53 45 54 20 75 6e 69 74 73 3d 3f ests SET units=?
2870: 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 WHERE run_id=?
2880: 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 AND testname=? A
2890: 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f 3b 22 ND item_path=?;"
28a0: 20 76 61 6c 20 72 75 6e 2d 69 64 20 74 65 73 74 val run-id test
28b0: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 -name item-path)
28c0: 29 29 0a 20 20 20 20 3b 3b 20 3a 74 6f 6c 5f 70 )). ;; :tol_p
28d0: 65 72 63 0a 20 20 20 20 28 6c 65 74 20 28 28 76 erc. (let ((v
28e0: 61 6c 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 al (hash-table-r
28f0: 65 66 2f 64 65 66 61 75 6c 74 20 6f 74 68 65 72 ef/default other
2900: 64 61 74 20 22 3a 74 6f 6c 5f 70 65 72 63 22 20 dat ":tol_perc"
2910: 23 66 29 29 29 0a 20 20 20 20 20 20 28 69 66 20 #f))). (if
2920: 76 61 6c 0a 09 20 20 28 73 71 6c 69 74 65 33 3a val.. (sqlite3:
2930: 65 78 65 63 75 74 65 20 64 62 20 22 55 50 44 41 execute db "UPDA
2940: 54 45 20 74 65 73 74 73 20 53 45 54 20 74 6f 6c TE tests SET tol
2950: 5f 70 65 72 63 3d 3f 20 57 48 45 52 45 20 72 75 _perc=? WHERE ru
2960: 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e n_id=? AND testn
2970: 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 ame=? AND item_p
2980: 61 74 68 3d 3f 3b 22 20 76 61 6c 20 72 75 6e 2d ath=?;" val run-
2990: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 id test-name ite
29a0: 6d 2d 70 61 74 68 29 29 29 0a 0a 20 20 20 20 3b m-path))).. ;
29b0: 3b 20 6e 65 65 64 20 74 6f 20 75 70 64 61 74 65 ; need to update
29c0: 20 74 68 65 20 74 6f 70 20 74 65 73 74 20 72 65 the top test re
29d0: 63 6f 72 64 20 69 66 20 50 41 53 53 20 6f 72 20 cord if PASS or
29e0: 46 41 49 4c 20 61 6e 64 20 74 68 69 73 20 69 73 FAIL and this is
29f0: 20 61 20 73 75 62 74 65 73 74 0a 20 20 20 20 28 a subtest. (
2a00: 69 66 20 28 61 6e 64 20 28 6e 6f 74 20 28 65 71 if (and (not (eq
2a10: 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 ual? item-path "
2a20: 22 29 29 0a 09 20 20 20 20 20 28 6f 72 20 28 65 ")).. (or (e
2a30: 71 75 61 6c 3f 20 73 74 61 74 75 73 20 22 50 41 qual? status "PA
2a40: 53 53 22 29 0a 09 09 20 28 65 71 75 61 6c 3f 20 SS")... (equal?
2a50: 73 74 61 74 75 73 20 22 57 41 52 4e 22 29 0a 09 status "WARN")..
2a60: 09 20 28 65 71 75 61 6c 3f 20 73 74 61 74 75 73 . (equal? status
2a70: 20 22 46 41 49 4c 22 29 0a 09 09 20 28 65 71 75 "FAIL")... (equ
2a80: 61 6c 3f 20 73 74 61 74 75 73 20 22 57 41 49 56 al? status "WAIV
2a90: 45 44 22 29 0a 09 09 20 28 65 71 75 61 6c 3f 20 ED")... (equal?
2aa0: 73 74 61 74 75 73 20 22 52 55 4e 4e 49 4e 47 22 status "RUNNING"
2ab0: 29 29 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 28 )))..(begin.. (
2ac0: 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 sqlite3:execute
2ad0: 0a 09 20 20 20 64 62 0a 09 20 20 20 22 55 50 44 .. db.. "UPD
2ae0: 41 54 45 20 74 65 73 74 73 20 0a 20 20 20 20 20 ATE tests .
2af0: 20 20 20 20 20 20 20 20 53 45 54 20 66 61 69 6c SET fail
2b00: 5f 63 6f 75 6e 74 3d 28 53 45 4c 45 43 54 20 63 _count=(SELECT c
2b10: 6f 75 6e 74 28 69 64 29 20 46 52 4f 4d 20 74 65 ount(id) FROM te
2b20: 73 74 73 20 57 48 45 52 45 20 72 75 6e 5f 69 64 sts WHERE run_id
2b30: 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d =? AND testname=
2b40: 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 20 ? AND item_path
2b50: 21 3d 20 27 27 20 41 4e 44 20 73 74 61 74 75 73 != '' AND status
2b60: 3d 27 46 41 49 4c 27 29 2c 0a 20 20 20 20 20 20 ='FAIL'),.
2b70: 20 20 20 20 20 20 20 20 20 20 20 70 61 73 73 5f pass_
2b80: 63 6f 75 6e 74 3d 28 53 45 4c 45 43 54 20 63 6f count=(SELECT co
2b90: 75 6e 74 28 69 64 29 20 46 52 4f 4d 20 74 65 73 unt(id) FROM tes
2ba0: 74 73 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d ts WHERE run_id=
2bb0: 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f ? AND testname=?
2bc0: 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 20 21 AND item_path !
2bd0: 3d 20 27 27 20 41 4e 44 20 28 73 74 61 74 75 73 = '' AND (status
2be0: 3d 27 50 41 53 53 27 20 4f 52 20 73 74 61 74 75 ='PASS' OR statu
2bf0: 73 3d 27 57 41 52 4e 27 20 4f 52 20 73 74 61 74 s='WARN' OR stat
2c00: 75 73 3d 27 57 41 49 56 45 44 27 29 29 0a 20 20 us='WAIVED')).
2c10: 20 20 20 20 20 20 20 20 20 20 20 57 48 45 52 45 WHERE
2c20: 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 run_id=? AND te
2c30: 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 stname=? AND ite
2c40: 6d 5f 70 61 74 68 3d 27 27 3b 22 0a 09 20 20 20 m_path='';"..
2c50: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 run-id test-name
2c60: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d run-id test-nam
2c70: 65 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 e run-id test-na
2c80: 6d 65 29 0a 09 20 20 28 69 66 20 28 65 71 75 61 me).. (if (equa
2c90: 6c 3f 20 73 74 61 74 75 73 20 22 52 55 4e 4e 49 l? status "RUNNI
2ca0: 4e 47 22 29 20 3b 3b 20 72 75 6e 6e 69 6e 67 20 NG") ;; running
2cb0: 74 61 6b 65 73 20 70 72 69 6f 72 69 74 79 20 6f takes priority o
2cc0: 76 65 72 20 61 6c 6c 20 6f 74 68 65 72 20 73 74 ver all other st
2cd0: 61 74 65 73 2c 20 66 6f 72 63 65 20 74 68 65 20 ates, force the
2ce0: 74 65 73 74 20 73 74 61 74 65 20 74 6f 20 52 55 test state to RU
2cf0: 4e 4e 49 4e 47 0a 09 20 20 20 20 20 20 28 73 71 NNING.. (sq
2d00: 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 64 62 lite3:execute db
2d10: 20 22 55 50 44 41 54 45 20 74 65 73 74 73 20 53 "UPDATE tests S
2d20: 45 54 20 73 74 61 74 65 3d 3f 20 57 48 45 52 45 ET state=? WHERE
2d30: 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 run_id=? AND te
2d40: 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 stname=? AND ite
2d50: 6d 5f 70 61 74 68 3d 27 27 3b 22 20 72 75 6e 2d m_path='';" run-
2d60: 69 64 20 74 65 73 74 2d 6e 61 6d 65 29 0a 09 20 id test-name)..
2d70: 20 20 20 20 20 28 73 71 6c 69 74 65 33 3a 65 78 (sqlite3:ex
2d80: 65 63 75 74 65 0a 09 20 20 20 20 20 20 20 64 62 ecute.. db
2d90: 0a 09 20 20 20 20 20 20 20 22 55 50 44 41 54 45 .. "UPDATE
2da0: 20 74 65 73 74 73 0a 20 20 20 20 20 20 20 20 20 tests.
2db0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 53 45 SE
2dc0: 54 20 73 74 61 74 65 3d 43 41 53 45 20 57 48 45 T state=CASE WHE
2dd0: 4e 20 28 53 45 4c 45 43 54 20 63 6f 75 6e 74 28 N (SELECT count(
2de0: 69 64 29 20 46 52 4f 4d 20 74 65 73 74 73 20 57 id) FROM tests W
2df0: 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e HERE run_id=? AN
2e00: 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 D testname=? AND
2e10: 20 69 74 65 6d 5f 70 61 74 68 20 21 3d 20 27 27 item_path != ''
2e20: 20 41 4e 44 20 73 74 61 74 65 20 69 6e 20 28 27 AND state in ('
2e30: 52 55 4e 4e 49 4e 47 27 2c 27 4e 4f 54 5f 53 54 RUNNING','NOT_ST
2e40: 41 52 54 45 44 27 29 29 20 3e 20 30 20 54 48 45 ARTED')) > 0 THE
2e50: 4e 20 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 N .
2e60: 20 20 20 20 20 20 20 20 20 20 20 20 20 27 52 55 'RU
2e70: 4e 4e 49 4e 47 27 0a 20 20 20 20 20 20 20 20 20 NNING'.
2e80: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 45 4c EL
2e90: 53 45 20 27 43 4f 4d 50 4c 45 54 45 44 27 20 45 SE 'COMPLETED' E
2ea0: 4e 44 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 ND,.
2eb0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 73 74 st
2ec0: 61 74 75 73 3d 43 41 53 45 20 57 48 45 4e 20 66 atus=CASE WHEN f
2ed0: 61 69 6c 5f 63 6f 75 6e 74 20 3e 20 30 20 54 48 ail_count > 0 TH
2ee0: 45 4e 20 27 46 41 49 4c 27 20 57 48 45 4e 20 70 EN 'FAIL' WHEN p
2ef0: 61 73 73 5f 63 6f 75 6e 74 20 3e 20 30 20 41 4e ass_count > 0 AN
2f00: 44 20 66 61 69 6c 5f 63 6f 75 6e 74 3d 30 20 54 D fail_count=0 T
2f10: 48 45 4e 20 27 50 41 53 53 27 20 45 4c 53 45 20 HEN 'PASS' ELSE
2f20: 27 55 4e 4b 4e 4f 57 4e 27 20 45 4e 44 0a 20 20 'UNKNOWN' END.
2f30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2f40: 20 20 20 20 20 57 48 45 52 45 20 72 75 6e 5f 69 WHERE run_i
2f50: 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 d=? AND testname
2f60: 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 =? AND item_path
2f70: 3d 27 27 3b 22 0a 09 20 20 20 20 20 20 20 72 75 ='';".. ru
2f80: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 72 n-id test-name r
2f90: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 29 un-id test-name)
2fa0: 29 29 29 0a 20 20 20 20 28 69 66 20 28 6f 72 20 ))). (if (or
2fb0: 28 61 6e 64 20 28 73 74 72 69 6e 67 3f 20 63 6f (and (string? co
2fc0: 6d 6d 65 6e 74 29 0a 09 09 20 28 73 74 72 69 6e mment)... (strin
2fd0: 67 2d 6d 61 74 63 68 20 28 72 65 67 65 78 70 20 g-match (regexp
2fe0: 22 5c 5c 53 2b 22 29 20 63 6f 6d 6d 65 6e 74 29 "\\S+") comment)
2ff0: 29 0a 09 20 20 20 20 77 61 69 76 65 64 29 0a 09 ).. waived)..
3000: 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 (sqlite3:execute
3010: 20 64 62 20 22 55 50 44 41 54 45 20 74 65 73 74 db "UPDATE test
3020: 73 20 53 45 54 20 63 6f 6d 6d 65 6e 74 3d 3f 20 s SET comment=?
3030: 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 WHERE run_id=? A
3040: 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e ND testname=? AN
3050: 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f 3b 22 0a D item_path=?;".
3060: 09 09 09 20 28 69 66 20 77 61 69 76 65 64 20 77 ... (if waived w
3070: 61 69 76 65 64 20 63 6f 6d 6d 65 6e 74 29 20 72 aived comment) r
3080: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 un-id test-name
3090: 69 74 65 6d 2d 70 61 74 68 29 29 0a 20 20 20 20 item-path)).
30a0: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73 ))..(define (tes
30b0: 74 2d 73 65 74 2d 6c 6f 67 21 20 64 62 20 72 75 t-set-log! db ru
30c0: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 n-id test-name i
30d0: 74 65 6d 64 61 74 20 6c 6f 67 66 29 20 0a 20 20 temdat logf) .
30e0: 28 6c 65 74 20 28 28 69 74 65 6d 2d 70 61 74 68 (let ((item-path
30f0: 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 (item-list->pat
3100: 68 20 69 74 65 6d 64 61 74 29 29 29 0a 20 20 20 h itemdat))).
3110: 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 (sqlite3:execut
3120: 65 20 64 62 20 22 55 50 44 41 54 45 20 74 65 73 e db "UPDATE tes
3130: 74 73 20 53 45 54 20 66 69 6e 61 6c 5f 6c 6f 67 ts SET final_log
3140: 66 3d 3f 20 57 48 45 52 45 20 72 75 6e 5f 69 64 f=? WHERE run_id
3150: 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d =? AND testname=
3160: 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d ? AND item_path=
3170: 3f 3b 22 20 0a 09 09 20 20 20 20 20 6c 6f 67 66 ?;" ... logf
3180: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d run-id test-nam
3190: 65 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 0a e item-path)))..
31a0: 28 64 65 66 69 6e 65 20 28 74 65 73 74 2d 73 65 (define (test-se
31b0: 74 2d 74 6f 70 6c 6f 67 21 20 64 62 20 72 75 6e t-toplog! db run
31c0: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 6c 6f -id test-name lo
31d0: 67 66 29 20 0a 20 20 28 73 71 6c 69 74 65 33 3a gf) . (sqlite3:
31e0: 65 78 65 63 75 74 65 20 64 62 20 22 55 50 44 41 execute db "UPDA
31f0: 54 45 20 74 65 73 74 73 20 53 45 54 20 66 69 6e TE tests SET fin
3200: 61 6c 5f 6c 6f 67 66 3d 3f 20 57 48 45 52 45 20 al_logf=? WHERE
3210: 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 run_id=? AND tes
3220: 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d tname=? AND item
3230: 5f 70 61 74 68 3d 27 27 3b 22 20 0a 09 09 20 20 _path='';" ...
3240: 20 6c 6f 67 66 20 72 75 6e 2d 69 64 20 74 65 73 logf run-id tes
3250: 74 2d 6e 61 6d 65 29 29 0a 0a 28 64 65 66 69 6e t-name))..(defin
3260: 65 20 28 74 65 73 74 73 3a 73 75 6d 6d 61 72 69 e (tests:summari
3270: 7a 65 2d 69 74 65 6d 73 20 64 62 20 72 75 6e 2d ze-items db run-
3280: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 66 6f 72 id test-name for
3290: 63 65 29 0a 20 20 3b 3b 20 69 66 20 6e 6f 74 20 ce). ;; if not
32a0: 66 6f 72 63 65 20 74 68 65 6e 20 6f 6e 6c 79 20 force then only
32b0: 75 70 64 61 74 65 20 74 68 65 20 72 65 63 6f 72 update the recor
32c0: 64 20 69 66 20 6f 6e 65 20 6f 66 20 74 68 65 73 d if one of thes
32d0: 65 20 69 73 20 74 72 75 65 3a 0a 20 20 3b 3b 20 e is true:. ;;
32e0: 20 20 31 2e 20 6c 6f 67 66 20 69 73 20 22 6c 6f 1. logf is "lo
32f0: 67 2f 66 69 6e 61 6c 2e 6c 6f 67 0a 20 20 3b 3b g/final.log. ;;
3300: 20 20 20 32 2e 20 6c 6f 67 66 20 69 73 20 73 61 2. logf is sa
3310: 6d 65 20 61 73 20 6f 75 74 70 75 74 66 69 6c 65 me as outputfile
3320: 6e 61 6d 65 0a 20 20 28 6c 65 74 20 28 28 6f 75 name. (let ((ou
3330: 74 70 75 74 66 69 6c 65 6e 61 6d 65 20 28 63 6f tputfilename (co
3340: 6e 63 20 22 6d 65 67 61 74 65 73 74 2d 72 6f 6c nc "megatest-rol
3350: 6c 75 70 2d 22 20 74 65 73 74 2d 6e 61 6d 65 20 lup-" test-name
3360: 22 2e 68 74 6d 6c 22 29 29 0a 09 28 6f 72 69 67 ".html"))..(orig
3370: 2d 64 69 72 20 20 20 20 20 20 20 28 63 75 72 72 -dir (curr
3380: 65 6e 74 2d 64 69 72 65 63 74 6f 72 79 29 29 0a ent-directory)).
3390: 09 28 6c 6f 67 66 20 20 20 20 20 20 20 20 20 20 .(logf
33a0: 20 23 66 29 29 0a 20 20 20 20 28 73 71 6c 69 74 #f)). (sqlit
33b0: 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77 20 e3:for-each-row
33c0: 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 70 . (lambda (p
33d0: 61 74 68 20 66 69 6e 61 6c 5f 6c 6f 67 66 29 0a ath final_logf).
33e0: 20 20 20 20 20 20 20 28 73 65 74 21 20 6c 6f 67 (set! log
33f0: 66 20 66 69 6e 61 6c 5f 6c 6f 67 66 29 0a 20 20 f final_logf).
3400: 20 20 20 20 20 28 69 66 20 28 64 69 72 65 63 74 (if (direct
3410: 6f 72 79 3f 20 70 61 74 68 29 0a 09 20 20 20 28 ory? path).. (
3420: 62 65 67 69 6e 0a 09 20 20 20 20 20 28 70 72 69 begin.. (pri
3430: 6e 74 20 22 46 6f 75 6e 64 20 70 61 74 68 3a 20 nt "Found path:
3440: 22 20 70 61 74 68 29 0a 09 20 20 20 20 20 28 63 " path).. (c
3450: 68 61 6e 67 65 2d 64 69 72 65 63 74 6f 72 79 20 hange-directory
3460: 70 61 74 68 29 29 0a 09 20 20 20 20 20 3b 3b 20 path)).. ;;
3470: 28 73 65 74 21 20 6f 75 74 70 75 74 66 69 6c 65 (set! outputfile
3480: 6e 61 6d 65 20 28 63 6f 6e 63 20 70 61 74 68 20 name (conc path
3490: 22 2f 22 20 6f 75 74 70 75 74 66 69 6c 65 6e 61 "/" outputfilena
34a0: 6d 65 29 29 29 0a 09 20 20 20 28 70 72 69 6e 74 me))).. (print
34b0: 20 22 4e 6f 20 73 75 63 68 20 70 61 74 68 3a 20 "No such path:
34c0: 22 20 70 61 74 68 29 29 29 0a 20 20 20 20 20 64 " path))). d
34d0: 62 20 0a 20 20 20 20 20 22 53 45 4c 45 43 54 20 b . "SELECT
34e0: 72 75 6e 64 69 72 2c 66 69 6e 61 6c 5f 6c 6f 67 rundir,final_log
34f0: 66 20 46 52 4f 4d 20 74 65 73 74 73 20 57 48 45 f FROM tests WHE
3500: 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 RE run_id=? AND
3510: 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 testname=? AND i
3520: 74 65 6d 5f 70 61 74 68 3d 27 27 3b 22 0a 20 20 tem_path='';".
3530: 20 20 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e run-id test-n
3540: 61 6d 65 29 0a 20 20 20 20 28 70 72 69 6e 74 20 ame). (print
3550: 22 73 75 6d 6d 61 72 69 7a 65 2d 69 74 65 6d 73 "summarize-items
3560: 20 77 69 74 68 20 6c 6f 67 66 20 22 20 6c 6f 67 with logf " log
3570: 66 29 0a 20 20 20 20 28 69 66 20 28 6f 72 20 28 f). (if (or (
3580: 65 71 75 61 6c 3f 20 6c 6f 67 66 20 22 6c 6f 67 equal? logf "log
3590: 73 2f 66 69 6e 61 6c 2e 6c 6f 67 22 29 0a 09 20 s/final.log")..
35a0: 20 20 20 28 65 71 75 61 6c 3f 20 6c 6f 67 66 20 (equal? logf
35b0: 6f 75 74 70 75 74 66 69 6c 65 6e 61 6d 65 29 0a outputfilename).
35c0: 09 20 20 20 20 66 6f 72 63 65 29 0a 09 28 62 65 . force)..(be
35d0: 67 69 6e 0a 09 20 20 28 69 66 20 28 6f 62 74 61 gin.. (if (obta
35e0: 69 6e 2d 64 6f 74 2d 6c 6f 63 6b 20 6f 75 74 70 in-dot-lock outp
35f0: 75 74 66 69 6c 65 6e 61 6d 65 20 31 20 32 30 20 utfilename 1 20
3600: 33 30 29 20 3b 3b 20 72 65 74 72 79 20 65 76 65 30) ;; retry eve
3610: 72 79 20 73 65 63 6f 6e 64 20 66 6f 72 20 32 30 ry second for 20
3620: 20 73 65 63 6f 6e 64 73 2c 20 63 61 6c 6c 20 69 seconds, call i
3630: 74 20 64 65 61 64 20 61 66 74 65 72 20 33 30 20 t dead after 30
3640: 73 65 63 6f 6e 64 73 20 61 6e 64 20 73 74 65 61 seconds and stea
3650: 6c 20 74 68 65 20 6c 6f 63 6b 0a 09 20 20 20 20 l the lock..
3660: 20 20 28 70 72 69 6e 74 20 22 4f 62 74 61 69 6e (print "Obtain
3670: 65 64 20 6c 6f 63 6b 20 66 6f 72 20 22 20 6f 75 ed lock for " ou
3680: 74 70 75 74 66 69 6c 65 6e 61 6d 65 29 0a 09 20 tputfilename)..
3690: 20 20 20 20 20 28 70 72 69 6e 74 20 22 46 61 69 (print "Fai
36a0: 6c 65 64 20 74 6f 20 6f 62 74 61 69 6e 20 6c 6f led to obtain lo
36b0: 63 6b 20 66 6f 72 20 22 20 6f 75 74 70 75 74 66 ck for " outputf
36c0: 69 6c 65 6e 61 6d 65 29 29 0a 09 20 20 28 6c 65 ilename)).. (le
36d0: 74 20 28 28 6f 75 70 20 20 20 20 28 6f 70 65 6e t ((oup (open
36e0: 2d 6f 75 74 70 75 74 2d 66 69 6c 65 20 6f 75 74 -output-file out
36f0: 70 75 74 66 69 6c 65 6e 61 6d 65 29 29 0a 09 09 putfilename))...
3700: 28 63 6f 75 6e 74 73 20 28 6d 61 6b 65 2d 68 61 (counts (make-ha
3710: 73 68 2d 74 61 62 6c 65 29 29 0a 09 09 28 73 74 sh-table))...(st
3720: 61 74 65 63 6f 75 6e 74 73 20 28 6d 61 6b 65 2d atecounts (make-
3730: 68 61 73 68 2d 74 61 62 6c 65 29 29 0a 09 09 28 hash-table))...(
3740: 6f 75 74 74 78 74 20 22 22 29 0a 09 09 28 74 6f outtxt "")...(to
3750: 74 20 20 20 20 30 29 29 0a 09 20 20 20 20 28 77 t 0)).. (w
3760: 69 74 68 2d 6f 75 74 70 75 74 2d 74 6f 2d 70 6f ith-output-to-po
3770: 72 74 0a 09 09 6f 75 70 0a 09 20 20 20 20 20 20 rt...oup..
3780: 28 6c 61 6d 62 64 61 20 28 29 0a 09 09 28 73 65 (lambda ()...(se
3790: 74 21 20 6f 75 74 74 78 74 20 28 63 6f 6e 63 20 t! outtxt (conc
37a0: 6f 75 74 74 78 74 20 22 3c 68 74 6d 6c 3e 3c 74 outtxt "<html><t
37b0: 69 74 6c 65 3e 53 75 6d 6d 61 72 79 3a 20 22 20 itle>Summary: "
37c0: 74 65 73 74 2d 6e 61 6d 65 20 0a 09 09 09 09 20 test-name .....
37d0: 20 20 22 3c 2f 74 69 74 6c 65 3e 3c 62 6f 64 79 "</title><body
37e0: 3e 3c 68 32 3e 53 75 6d 6d 61 72 79 20 66 6f 72 ><h2>Summary for
37f0: 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 3c 2f " test-name "</
3800: 68 32 3e 22 29 29 0a 09 09 28 73 71 6c 69 74 65 h2>"))...(sqlite
3810: 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77 20 0a 3:for-each-row .
3820: 09 09 20 28 6c 61 6d 62 64 61 20 28 69 64 20 69 .. (lambda (id i
3830: 74 65 6d 70 61 74 68 20 73 74 61 74 65 20 73 74 tempath state st
3840: 61 74 75 73 20 72 75 6e 5f 64 75 72 61 74 69 6f atus run_duratio
3850: 6e 20 6c 6f 67 66 20 63 6f 6d 6d 65 6e 74 29 0a n logf comment).
3860: 09 09 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65 .. (hash-table
3870: 2d 73 65 74 21 20 63 6f 75 6e 74 73 20 73 74 61 -set! counts sta
3880: 74 75 73 20 28 2b 20 31 20 28 68 61 73 68 2d 74 tus (+ 1 (hash-t
3890: 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 able-ref/default
38a0: 20 63 6f 75 6e 74 73 20 73 74 61 74 75 73 20 30 counts status 0
38b0: 29 29 29 0a 09 09 20 20 20 28 68 61 73 68 2d 74 )))... (hash-t
38c0: 61 62 6c 65 2d 73 65 74 21 20 73 74 61 74 65 63 able-set! statec
38d0: 6f 75 6e 74 73 20 73 74 61 74 65 20 28 2b 20 31 ounts state (+ 1
38e0: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 (hash-table-ref
38f0: 2f 64 65 66 61 75 6c 74 20 73 74 61 74 65 63 6f /default stateco
3900: 75 6e 74 73 20 73 74 61 74 65 20 30 29 29 29 0a unts state 0))).
3910: 09 09 20 20 20 28 73 65 74 21 20 6f 75 74 74 78 .. (set! outtx
3920: 74 20 28 63 6f 6e 63 20 6f 75 74 74 78 74 20 22 t (conc outtxt "
3930: 3c 74 72 3e 22 0a 09 09 09 09 20 20 20 20 20 20 <tr>".....
3940: 22 3c 74 64 3e 3c 61 20 68 72 65 66 3d 5c 22 22 "<td><a href=\""
3950: 20 69 74 65 6d 70 61 74 68 20 22 2f 22 20 6c 6f itempath "/" lo
3960: 67 66 20 22 5c 22 3e 20 22 20 69 74 65 6d 70 61 gf "\"> " itempa
3970: 74 68 20 22 3c 2f 61 3e 3c 2f 74 64 3e 22 20 0a th "</a></td>" .
3980: 09 09 09 09 20 20 20 20 20 20 22 3c 74 64 3e 22 .... "<td>"
3990: 20 73 74 61 74 65 20 20 20 20 22 3c 2f 74 64 3e state "</td>
39a0: 22 20 0a 09 09 09 09 20 20 20 20 20 20 22 3c 74 " ..... "<t
39b0: 64 3e 3c 66 6f 6e 74 20 63 6f 6c 6f 72 3d 22 20 d><font color="
39c0: 28 63 6f 6d 6d 6f 6e 3a 67 65 74 2d 63 6f 6c 6f (common:get-colo
39d0: 72 2d 66 72 6f 6d 2d 73 74 61 74 75 73 20 73 74 r-from-status st
39e0: 61 74 75 73 29 0a 09 09 09 09 20 20 20 20 20 20 atus).....
39f0: 22 3e 22 20 20 20 73 74 61 74 75 73 20 20 20 22 ">" status "
3a00: 3c 2f 66 6f 6e 74 3e 3c 2f 74 64 3e 22 0a 09 09 </font></td>"...
3a10: 09 09 20 20 20 20 20 20 22 3c 74 64 3e 22 20 28 .. "<td>" (
3a20: 69 66 20 28 65 71 75 61 6c 3f 20 63 6f 6d 6d 65 if (equal? comme
3a30: 6e 74 20 22 22 29 0a 09 09 09 09 09 09 20 22 26 nt "")....... "&
3a40: 6e 62 73 70 3b 22 0a 09 09 09 09 09 09 20 63 6f nbsp;"....... co
3a50: 6d 6d 65 6e 74 29 20 22 3c 2f 74 64 3e 22 0a 09 mment) "</td>"..
3a60: 09 09 09 09 09 20 22 3c 2f 74 72 3e 22 29 29 29 ..... "</tr>")))
3a70: 0a 09 09 20 64 62 0a 09 09 20 22 53 45 4c 45 43 ... db... "SELEC
3a80: 54 20 69 64 2c 69 74 65 6d 5f 70 61 74 68 2c 73 T id,item_path,s
3a90: 74 61 74 65 2c 73 74 61 74 75 73 2c 72 75 6e 5f tate,status,run_
3aa0: 64 75 72 61 74 69 6f 6e 2c 66 69 6e 61 6c 5f 6c duration,final_l
3ab0: 6f 67 66 2c 63 6f 6d 6d 65 6e 74 20 46 52 4f 4d ogf,comment FROM
3ac0: 20 74 65 73 74 73 20 57 48 45 52 45 20 72 75 6e tests WHERE run
3ad0: 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 _id=? AND testna
3ae0: 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 me=? AND item_pa
3af0: 74 68 20 21 3d 20 27 27 3b 22 0a 09 09 20 72 75 th != '';"... ru
3b00: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 29 0a n-id test-name).
3b10: 0a 09 09 28 70 72 69 6e 74 20 22 3c 74 61 62 6c ...(print "<tabl
3b20: 65 3e 3c 74 72 3e 3c 74 64 20 76 61 6c 69 67 6e e><tr><td valign
3b30: 3d 5c 22 74 6f 70 5c 22 3e 22 29 0a 09 09 3b 3b =\"top\">")...;;
3b40: 20 50 72 69 6e 74 20 6f 75 74 20 73 74 61 74 73 Print out stats
3b50: 20 66 6f 72 20 73 74 61 74 75 73 0a 09 09 28 73 for status...(s
3b60: 65 74 21 20 74 6f 74 20 30 29 0a 09 09 28 70 72 et! tot 0)...(pr
3b70: 69 6e 74 20 22 3c 74 61 62 6c 65 20 63 65 6c 6c int "<table cell
3b80: 73 70 61 63 69 6e 67 3d 5c 22 30 5c 22 20 62 6f spacing=\"0\" bo
3b90: 72 64 65 72 3d 5c 22 31 5c 22 3e 3c 74 72 3e 3c rder=\"1\"><tr><
3ba0: 74 64 20 63 6f 6c 73 70 61 6e 3d 5c 22 32 5c 22 td colspan=\"2\"
3bb0: 3e 3c 68 32 3e 53 74 61 74 65 20 73 74 61 74 73 ><h2>State stats
3bc0: 3c 2f 68 32 3e 3c 2f 74 64 3e 3c 2f 74 72 3e 22 </h2></td></tr>"
3bd0: 29 0a 09 09 28 66 6f 72 2d 65 61 63 68 20 28 6c )...(for-each (l
3be0: 61 6d 62 64 61 20 28 73 74 61 74 65 29 0a 09 09 ambda (state)...
3bf0: 09 20 20 20 20 28 73 65 74 21 20 74 6f 74 20 28 . (set! tot (
3c00: 2b 20 74 6f 74 20 28 68 61 73 68 2d 74 61 62 6c + tot (hash-tabl
3c10: 65 2d 72 65 66 20 73 74 61 74 65 63 6f 75 6e 74 e-ref statecount
3c20: 73 20 73 74 61 74 65 29 29 29 0a 09 09 09 20 20 s state)))....
3c30: 20 20 28 70 72 69 6e 74 20 22 3c 74 72 3e 3c 74 (print "<tr><t
3c40: 64 3e 22 20 73 74 61 74 65 20 22 3c 2f 74 64 3e d>" state "</td>
3c50: 3c 74 64 3e 22 20 28 68 61 73 68 2d 74 61 62 6c <td>" (hash-tabl
3c60: 65 2d 72 65 66 20 73 74 61 74 65 63 6f 75 6e 74 e-ref statecount
3c70: 73 20 73 74 61 74 65 29 20 22 3c 2f 74 64 3e 3c s state) "</td><
3c80: 2f 74 72 3e 22 29 29 0a 09 09 09 20 20 28 68 61 /tr>")).... (ha
3c90: 73 68 2d 74 61 62 6c 65 2d 6b 65 79 73 20 73 74 sh-table-keys st
3ca0: 61 74 65 63 6f 75 6e 74 73 29 29 0a 09 09 28 70 atecounts))...(p
3cb0: 72 69 6e 74 20 22 3c 74 72 3e 3c 74 64 3e 54 6f rint "<tr><td>To
3cc0: 74 61 6c 3c 2f 74 64 3e 3c 74 64 3e 22 20 74 6f tal</td><td>" to
3cd0: 74 20 22 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 t "</td></tr></t
3ce0: 61 62 6c 65 3e 22 29 0a 09 09 28 70 72 69 6e 74 able>")...(print
3cf0: 20 22 3c 2f 74 64 3e 3c 74 64 20 76 61 6c 69 67 "</td><td valig
3d00: 6e 3d 5c 22 74 6f 70 5c 22 3e 22 29 0a 09 09 3b n=\"top\">")...;
3d10: 3b 20 50 72 69 6e 74 20 6f 75 74 20 73 74 61 74 ; Print out stat
3d20: 73 20 66 6f 72 20 73 74 61 74 65 0a 09 09 28 73 s for state...(s
3d30: 65 74 21 20 74 6f 74 20 30 29 0a 09 09 28 70 72 et! tot 0)...(pr
3d40: 69 6e 74 20 22 3c 74 61 62 6c 65 20 63 65 6c 6c int "<table cell
3d50: 73 70 61 63 69 6e 67 3d 5c 22 30 5c 22 20 62 6f spacing=\"0\" bo
3d60: 72 64 65 72 3d 5c 22 31 5c 22 3e 3c 74 72 3e 3c rder=\"1\"><tr><
3d70: 74 64 20 63 6f 6c 73 70 61 6e 3d 5c 22 32 5c 22 td colspan=\"2\"
3d80: 3e 3c 68 32 3e 53 74 61 74 75 73 20 73 74 61 74 ><h2>Status stat
3d90: 73 3c 2f 68 32 3e 3c 2f 74 64 3e 3c 2f 74 72 3e s</h2></td></tr>
3da0: 22 29 0a 09 09 28 66 6f 72 2d 65 61 63 68 20 28 ")...(for-each (
3db0: 6c 61 6d 62 64 61 20 28 73 74 61 74 75 73 29 0a lambda (status).
3dc0: 09 09 09 20 20 20 20 28 73 65 74 21 20 74 6f 74 ... (set! tot
3dd0: 20 28 2b 20 74 6f 74 20 28 68 61 73 68 2d 74 61 (+ tot (hash-ta
3de0: 62 6c 65 2d 72 65 66 20 63 6f 75 6e 74 73 20 73 ble-ref counts s
3df0: 74 61 74 75 73 29 29 29 0a 09 09 09 20 20 20 20 tatus)))....
3e00: 28 70 72 69 6e 74 20 22 3c 74 72 3e 3c 74 64 3e (print "<tr><td>
3e10: 3c 66 6f 6e 74 20 63 6f 6c 6f 72 3d 5c 22 22 20 <font color=\""
3e20: 28 63 6f 6d 6d 6f 6e 3a 67 65 74 2d 63 6f 6c 6f (common:get-colo
3e30: 72 2d 66 72 6f 6d 2d 73 74 61 74 75 73 20 73 74 r-from-status st
3e40: 61 74 75 73 29 20 22 5c 22 3e 22 20 73 74 61 74 atus) "\">" stat
3e50: 75 73 0a 09 09 09 09 20 20 20 22 3c 2f 66 6f 6e us..... "</fon
3e60: 74 3e 3c 2f 74 64 3e 3c 74 64 3e 22 20 28 68 61 t></td><td>" (ha
3e70: 73 68 2d 74 61 62 6c 65 2d 72 65 66 20 63 6f 75 sh-table-ref cou
3e80: 6e 74 73 20 73 74 61 74 75 73 29 20 22 3c 2f 74 nts status) "</t
3e90: 64 3e 3c 2f 74 72 3e 22 29 29 0a 09 09 09 20 20 d></tr>"))....
3ea0: 28 68 61 73 68 2d 74 61 62 6c 65 2d 6b 65 79 73 (hash-table-keys
3eb0: 20 63 6f 75 6e 74 73 29 29 0a 09 09 28 70 72 69 counts))...(pri
3ec0: 6e 74 20 22 3c 74 72 3e 3c 74 64 3e 54 6f 74 61 nt "<tr><td>Tota
3ed0: 6c 3c 2f 74 64 3e 3c 74 64 3e 22 20 74 6f 74 20 l</td><td>" tot
3ee0: 22 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61 62 "</td></tr></tab
3ef0: 6c 65 3e 22 29 0a 09 09 28 70 72 69 6e 74 20 22 le>")...(print "
3f00: 3c 2f 74 64 3e 3c 2f 74 64 3e 3c 2f 74 72 3e 3c </td></td></tr><
3f10: 2f 74 61 62 6c 65 3e 22 29 0a 0a 09 09 28 70 72 /table>")....(pr
3f20: 69 6e 74 20 22 3c 74 61 62 6c 65 20 63 65 6c 6c int "<table cell
3f30: 73 70 61 63 69 6e 67 3d 5c 22 30 5c 22 20 62 6f spacing=\"0\" bo
3f40: 72 64 65 72 3d 5c 22 31 5c 22 3e 22 20 0a 09 09 rder=\"1\">" ...
3f50: 20 20 20 20 20 20 20 22 3c 74 72 3e 3c 74 64 3e "<tr><td>
3f60: 49 74 65 6d 3c 2f 74 64 3e 3c 74 64 3e 53 74 61 Item</td><td>Sta
3f70: 74 65 3c 2f 74 64 3e 3c 74 64 3e 53 74 61 74 75 te</td><td>Statu
3f80: 73 3c 2f 74 64 3e 3c 74 64 3e 43 6f 6d 6d 65 6e s</td><td>Commen
3f90: 74 3c 2f 74 64 3e 22 0a 09 09 20 20 20 20 20 20 t</td>"...
3fa0: 20 6f 75 74 74 78 74 20 22 3c 2f 74 61 62 6c 65 outtxt "</table
3fb0: 3e 3c 2f 62 6f 64 79 3e 3c 2f 68 74 6d 6c 3e 22 ></body></html>"
3fc0: 29 0a 09 09 28 72 65 6c 65 61 73 65 2d 64 6f 74 )...(release-dot
3fd0: 2d 6c 6f 63 6b 20 6f 75 74 70 75 74 66 69 6c 65 -lock outputfile
3fe0: 6e 61 6d 65 29 29 29 0a 09 20 20 20 20 28 63 6c name))).. (cl
3ff0: 6f 73 65 2d 6f 75 74 70 75 74 2d 70 6f 72 74 20 ose-output-port
4000: 6f 75 70 29 0a 09 20 20 20 20 28 63 68 61 6e 67 oup).. (chang
4010: 65 2d 64 69 72 65 63 74 6f 72 79 20 6f 72 69 67 e-directory orig
4020: 2d 64 69 72 29 0a 09 20 20 20 20 28 74 65 73 74 -dir).. (test
4030: 2d 73 65 74 2d 74 6f 70 6c 6f 67 21 20 64 62 20 -set-toplog! db
4040: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 run-id test-name
4050: 20 6f 75 74 70 75 74 66 69 6c 65 6e 61 6d 65 29 outputfilename)
4060: 0a 09 20 20 20 20 29 29 29 29 29 0a 0a 3b 3b 20 .. )))))..;;
4070: 3b 3b 20 54 4f 44 4f 3a 20 43 6f 6e 76 65 72 67 ;; TODO: Converg
4080: 65 20 74 68 69 73 20 77 69 74 68 20 64 62 3a 67 e this with db:g
4090: 65 74 2d 74 65 73 74 2d 69 6e 66 6f 0a 3b 3b 20 et-test-info.;;
40a0: 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 67 65 (define (runs:ge
40b0: 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 20 72 t-test-info db r
40c0: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 un-id test-name
40d0: 69 74 65 6d 2d 70 61 74 68 29 0a 3b 3b 20 20 20 item-path).;;
40e0: 28 6c 65 74 20 28 28 72 65 73 20 23 66 29 29 20 (let ((res #f))
40f0: 3b 3b 20 28 76 65 63 74 6f 72 20 23 66 20 23 66 ;; (vector #f #f
4100: 20 23 66 20 23 66 20 23 66 20 23 66 29 29 29 0a #f #f #f #f))).
4110: 3b 3b 20 20 20 20 20 28 73 71 6c 69 74 65 33 3a ;; (sqlite3:
4120: 66 6f 72 2d 65 61 63 68 2d 72 6f 77 20 0a 3b 3b for-each-row .;;
4130: 20 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 69 (lambda (i
4140: 64 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 d run-id test-na
4150: 6d 65 20 73 74 61 74 65 20 73 74 61 74 75 73 29 me state status)
4160: 0a 3b 3b 20 20 20 20 20 20 20 20 28 73 65 74 21 .;; (set!
4170: 20 72 65 73 20 28 76 65 63 74 6f 72 20 69 64 20 res (vector id
4180: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 run-id test-name
4190: 20 73 74 61 74 65 20 73 74 61 74 75 73 20 69 74 state status it
41a0: 65 6d 2d 70 61 74 68 29 29 29 0a 3b 3b 20 20 20 em-path))).;;
41b0: 20 20 20 64 62 20 22 53 45 4c 45 43 54 20 69 64 db "SELECT id
41c0: 2c 72 75 6e 5f 69 64 2c 74 65 73 74 6e 61 6d 65 ,run_id,testname
41d0: 2c 73 74 61 74 65 2c 73 74 61 74 75 73 20 46 52 ,state,status FR
41e0: 4f 4d 20 74 65 73 74 73 20 57 48 45 52 45 20 72 OM tests WHERE r
41f0: 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 un_id=? AND test
4200: 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f name=? AND item_
4210: 70 61 74 68 3d 3f 3b 22 0a 3b 3b 20 20 20 20 20 path=?;".;;
4220: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d run-id test-nam
4230: 65 20 69 74 65 6d 2d 70 61 74 68 29 0a 3b 3b 20 e item-path).;;
4240: 20 20 20 20 72 65 73 29 29 0a 0a 28 64 65 66 69 res))..(defi
4250: 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65 73 74 3a ne-inline (test:
4260: 67 65 74 2d 69 64 20 76 65 63 29 20 20 20 20 20 get-id vec)
4270: 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20 76 65 (vector-ref ve
4280: 63 20 30 29 29 0a 28 64 65 66 69 6e 65 2d 69 6e c 0)).(define-in
4290: 6c 69 6e 65 20 28 74 65 73 74 3a 67 65 74 2d 72 line (test:get-r
42a0: 75 6e 5f 69 64 20 76 65 63 29 20 20 20 28 76 65 un_id vec) (ve
42b0: 63 74 6f 72 2d 72 65 66 20 76 65 63 20 31 29 29 ctor-ref vec 1))
42c0: 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69 6e 65 20 .(define-inline
42d0: 28 74 65 73 74 3a 67 65 74 2d 74 65 73 74 2d 6e (test:get-test-n
42e0: 61 6d 65 20 76 65 63 29 28 76 65 63 74 6f 72 2d ame vec)(vector-
42f0: 72 65 66 20 76 65 63 20 32 29 29 0a 28 64 65 66 ref vec 2)).(def
4300: 69 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65 73 74 ine-inline (test
4310: 3a 67 65 74 2d 73 74 61 74 65 20 76 65 63 29 20 :get-state vec)
4320: 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20 76 (vector-ref v
4330: 65 63 20 33 29 29 0a 28 64 65 66 69 6e 65 2d 69 ec 3)).(define-i
4340: 6e 6c 69 6e 65 20 28 74 65 73 74 3a 67 65 74 2d nline (test:get-
4350: 73 74 61 74 75 73 20 76 65 63 29 20 20 20 28 76 status vec) (v
4360: 65 63 74 6f 72 2d 72 65 66 20 76 65 63 20 34 29 ector-ref vec 4)
4370: 29 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69 6e 65 ).(define-inline
4380: 20 28 74 65 73 74 3a 67 65 74 2d 69 74 65 6d 2d (test:get-item-
4390: 70 61 74 68 20 76 65 63 29 28 76 65 63 74 6f 72 path vec)(vector
43a0: 2d 72 65 66 20 76 65 63 20 35 29 29 0a 0a 28 64 -ref vec 5))..(d
43b0: 65 66 69 6e 65 20 28 72 75 6e 73 3a 74 65 73 74 efine (runs:test
43c0: 2d 67 65 74 2d 66 75 6c 6c 2d 70 61 74 68 20 74 -get-full-path t
43d0: 65 73 74 29 0a 20 20 28 6c 65 74 2a 20 28 28 74 est). (let* ((t
43e0: 65 73 74 6e 61 6d 65 20 28 64 62 3a 74 65 73 74 estname (db:test
43f0: 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 20 20 -get-testname
4400: 74 65 73 74 29 29 0a 09 20 28 69 74 65 6d 70 61 test)).. (itempa
4410: 74 68 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d th (db:test-get-
4420: 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 29 29 item-path test))
4430: 29 0a 20 20 20 20 28 63 6f 6e 63 20 74 65 73 74 ). (conc test
4440: 6e 61 6d 65 20 28 69 66 20 28 65 71 75 61 6c 3f name (if (equal?
4450: 20 69 74 65 6d 70 61 74 68 20 22 22 29 20 22 22 itempath "") ""
4460: 20 28 63 6f 6e 63 20 22 28 22 20 69 74 65 6d 70 (conc "(" itemp
4470: 61 74 68 20 22 29 22 29 29 29 29 29 0a 0a 28 64 ath ")")))))..(d
4480: 65 66 69 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65 efine-inline (te
4490: 73 74 3a 74 65 73 74 2d 67 65 74 2d 66 75 6c 6c st:test-get-full
44a0: 6e 61 6d 65 20 74 65 73 74 29 0a 20 20 20 28 63 name test). (c
44b0: 6f 6e 63 20 28 64 62 3a 74 65 73 74 2d 67 65 74 onc (db:test-get
44c0: 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 29 0a -testname test).
44d0: 09 20 28 69 66 20 28 65 71 75 61 6c 3f 20 28 64 . (if (equal? (d
44e0: 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d b:test-get-item-
44f0: 70 61 74 68 20 74 65 73 74 29 20 22 22 29 0a 09 path test) "")..
4500: 20 20 20 20 20 22 22 0a 09 20 20 20 20 20 28 63 "".. (c
4510: 6f 6e 63 20 22 28 22 20 28 64 62 3a 74 65 73 74 onc "(" (db:test
4520: 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74 -get-item-path t
4530: 65 73 74 29 20 22 29 22 29 29 29 29 0a 0a 28 64 est) ")"))))..(d
4540: 65 66 69 6e 65 20 28 63 68 65 63 6b 2d 76 61 6c efine (check-val
4550: 69 64 2d 69 74 65 6d 73 20 63 6c 61 73 73 20 69 id-items class i
4560: 74 65 6d 29 0a 20 20 28 6c 65 74 20 28 28 76 61 tem). (let ((va
4570: 6c 69 64 2d 76 61 6c 75 65 73 20 28 6c 65 74 20 lid-values (let
4580: 28 28 73 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b ((s (config-look
4590: 75 70 20 2a 63 6f 6e 66 69 67 64 61 74 2a 20 22 up *configdat* "
45a0: 76 61 6c 69 64 76 61 6c 75 65 73 22 20 63 6c 61 validvalues" cla
45b0: 73 73 29 29 29 0a 09 09 09 28 69 66 20 73 20 28 ss)))....(if s (
45c0: 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 73 29 20 string-split s)
45d0: 23 66 29 29 29 29 0a 20 20 20 20 28 69 66 20 76 #f)))). (if v
45e0: 61 6c 69 64 2d 76 61 6c 75 65 73 0a 09 28 69 66 alid-values..(if
45f0: 20 28 6d 65 6d 62 65 72 20 69 74 65 6d 20 76 61 (member item va
4600: 6c 69 64 2d 76 61 6c 75 65 73 29 0a 09 20 20 20 lid-values)..
4610: 20 69 74 65 6d 20 23 66 29 0a 09 69 74 65 6d 29 item #f)..item)
4620: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73 ))..(define (tes
4630: 74 73 74 65 70 2d 73 65 74 2d 73 74 61 74 75 73 tstep-set-status
4640: 21 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 ! db run-id test
4650: 2d 6e 61 6d 65 20 74 65 73 74 73 74 65 70 2d 6e -name teststep-n
4660: 61 6d 65 20 73 74 61 74 65 2d 69 6e 20 73 74 61 ame state-in sta
4670: 74 75 73 2d 69 6e 20 69 74 65 6d 64 61 74 20 63 tus-in itemdat c
4680: 6f 6d 6d 65 6e 74 29 0a 20 20 28 64 65 62 75 67 omment). (debug
4690: 3a 70 72 69 6e 74 20 34 20 22 72 75 6e 2d 69 64 :print 4 "run-id
46a0: 3a 20 22 20 72 75 6e 2d 69 64 20 22 20 74 65 73 : " run-id " tes
46b0: 74 2d 6e 61 6d 65 3a 20 22 20 74 65 73 74 2d 6e t-name: " test-n
46c0: 61 6d 65 29 0a 20 20 28 6c 65 74 2a 20 28 28 73 ame). (let* ((s
46d0: 74 61 74 65 20 20 20 20 20 28 63 68 65 63 6b 2d tate (check-
46e0: 76 61 6c 69 64 2d 69 74 65 6d 73 20 22 73 74 61 valid-items "sta
46f0: 74 65 22 20 73 74 61 74 65 2d 69 6e 29 29 0a 09 te" state-in))..
4700: 20 28 73 74 61 74 75 73 20 20 20 20 28 63 68 65 (status (che
4710: 63 6b 2d 76 61 6c 69 64 2d 69 74 65 6d 73 20 22 ck-valid-items "
4720: 73 74 61 74 75 73 22 20 73 74 61 74 75 73 2d 69 status" status-i
4730: 6e 29 29 0a 09 20 28 69 74 65 6d 2d 70 61 74 68 n)).. (item-path
4740: 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 (item-list->pat
4750: 68 20 69 74 65 6d 64 61 74 29 29 0a 09 20 28 74 h itemdat)).. (t
4760: 65 73 74 64 61 74 20 20 20 28 64 62 3a 67 65 74 estdat (db:get
4770: 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 20 72 75 -test-info db ru
4780: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 n-id test-name i
4790: 74 65 6d 2d 70 61 74 68 29 29 29 0a 20 20 20 20 tem-path))).
47a0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 35 20 22 (debug:print 5 "
47b0: 74 65 73 74 64 61 74 3a 20 22 20 74 65 73 74 64 testdat: " testd
47c0: 61 74 29 0a 20 20 20 20 28 69 66 20 28 61 6e 64 at). (if (and
47d0: 20 74 65 73 74 64 61 74 20 3b 3b 20 69 66 20 74 testdat ;; if t
47e0: 68 65 20 73 65 63 74 69 6f 6e 20 65 78 69 73 74 he section exist
47f0: 73 20 74 68 65 6e 20 66 6f 72 63 65 20 73 70 65 s then force spe
4800: 63 69 66 69 63 61 74 69 6f 6e 20 42 55 47 2c 20 cification BUG,
4810: 49 20 64 6f 6e 27 74 20 6c 69 6b 65 20 68 6f 77 I don't like how
4820: 20 74 68 69 73 20 77 6f 72 6b 73 2e 0a 09 20 20 this works...
4830: 20 20 20 28 6f 72 20 28 6e 6f 74 20 73 74 61 74 (or (not stat
4840: 65 29 28 6e 6f 74 20 73 74 61 74 75 73 29 29 29 e)(not status)))
4850: 0a 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 ..(debug:print 0
4860: 20 22 57 41 52 4e 49 4e 47 3a 20 49 6e 76 61 6c "WARNING: Inval
4870: 69 64 20 22 20 28 69 66 20 73 74 61 74 75 73 20 id " (if status
4880: 22 73 74 61 74 75 73 22 20 22 73 74 61 74 65 22 "status" "state"
4890: 29 0a 09 20 20 20 20 20 20 20 22 20 76 61 6c 75 ).. " valu
48a0: 65 20 5c 22 22 20 28 69 66 20 73 74 61 74 75 73 e \"" (if status
48b0: 20 73 74 61 74 75 73 2d 69 6e 20 73 74 61 74 65 status-in state
48c0: 2d 69 6e 29 20 22 5c 22 2c 20 75 70 64 61 74 65 -in) "\", update
48d0: 20 79 6f 75 72 20 76 61 6c 69 64 73 74 61 74 65 your validstate
48e0: 73 20 73 65 63 74 69 6f 6e 20 69 6e 20 6d 65 67 s section in meg
48f0: 61 74 65 73 74 2e 63 6f 6e 66 69 67 22 29 29 0a atest.config")).
4900: 20 20 20 20 28 69 66 20 74 65 73 74 64 61 74 0a (if testdat.
4910: 09 28 6c 65 74 20 28 28 74 65 73 74 2d 69 64 20 .(let ((test-id
4920: 28 74 65 73 74 3a 67 65 74 2d 69 64 20 74 65 73 (test:get-id tes
4930: 74 64 61 74 29 29 29 0a 09 20 20 28 73 71 6c 69 tdat))).. (sqli
4940: 74 65 33 3a 65 78 65 63 75 74 65 20 64 62 20 0a te3:execute db .
4950: 09 09 09 22 49 4e 53 45 52 54 20 4f 52 20 52 45 ..."INSERT OR RE
4960: 50 4c 41 43 45 20 69 6e 74 6f 20 74 65 73 74 5f PLACE into test_
4970: 73 74 65 70 73 20 28 74 65 73 74 5f 69 64 2c 73 steps (test_id,s
4980: 74 65 70 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 tepname,state,st
4990: 61 74 75 73 2c 65 76 65 6e 74 5f 74 69 6d 65 2c atus,event_time,
49a0: 63 6f 6d 6d 65 6e 74 29 20 56 41 4c 55 45 53 28 comment) VALUES(
49b0: 3f 2c 3f 2c 3f 2c 3f 2c 73 74 72 66 74 69 6d 65 ?,?,?,?,strftime
49c0: 28 27 25 73 27 2c 27 6e 6f 77 27 29 2c 3f 29 3b ('%s','now'),?);
49d0: 22 0a 09 09 09 74 65 73 74 2d 69 64 20 74 65 73 "....test-id tes
49e0: 74 73 74 65 70 2d 6e 61 6d 65 20 73 74 61 74 65 tstep-name state
49f0: 20 73 74 61 74 75 73 20 28 69 66 20 63 6f 6d 6d status (if comm
4a00: 65 6e 74 20 63 6f 6d 6d 65 6e 74 20 22 22 29 29 ent comment ""))
4a10: 29 0a 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20 )..(debug:print
4a20: 30 20 22 45 52 52 4f 52 3a 20 43 61 6e 27 74 20 0 "ERROR: Can't
4a30: 75 70 64 61 74 65 20 22 20 74 65 73 74 2d 6e 61 update " test-na
4a40: 6d 65 20 22 20 66 6f 72 20 72 75 6e 20 22 20 72 me " for run " r
4a50: 75 6e 2d 69 64 20 22 20 2d 3e 20 6e 6f 20 73 75 un-id " -> no su
4a60: 63 68 20 74 65 73 74 20 69 6e 20 64 62 22 29 29 ch test in db"))
4a70: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73 ))..(define (tes
4a80: 74 2d 67 65 74 2d 6b 69 6c 6c 2d 72 65 71 75 65 t-get-kill-reque
4a90: 73 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 st db run-id tes
4aa0: 74 2d 6e 61 6d 65 20 69 74 65 6d 64 61 74 29 0a t-name itemdat).
4ab0: 20 20 28 6c 65 74 2a 20 28 28 69 74 65 6d 2d 70 (let* ((item-p
4ac0: 61 74 68 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e ath (item-list->
4ad0: 70 61 74 68 20 69 74 65 6d 64 61 74 29 29 0a 09 path itemdat))..
4ae0: 20 28 74 65 73 74 64 61 74 20 20 20 28 64 62 3a (testdat (db:
4af0: 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 get-test-info db
4b00: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d run-id test-nam
4b10: 65 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 20 e item-path))).
4b20: 20 20 20 28 65 71 75 61 6c 3f 20 28 74 65 73 74 (equal? (test
4b30: 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 :get-state testd
4b40: 61 74 29 20 22 4b 49 4c 4c 52 45 51 22 29 29 29 at) "KILLREQ")))
4b50: 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73 74 2d ..(define (test-
4b60: 73 65 74 2d 6d 65 74 61 2d 69 6e 66 6f 20 64 62 set-meta-info db
4b70: 20 72 75 6e 2d 69 64 20 74 65 73 74 6e 61 6d 65 run-id testname
4b80: 20 69 74 65 6d 64 61 74 29 0a 20 20 28 6c 65 74 itemdat). (let
4b90: 20 28 28 69 74 65 6d 2d 70 61 74 68 20 28 69 74 ((item-path (it
4ba0: 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69 74 em-list->path it
4bb0: 65 6d 64 61 74 29 29 0a 09 28 63 70 75 6c 6f 61 emdat))..(cpuloa
4bc0: 64 20 20 28 67 65 74 2d 63 70 75 2d 6c 6f 61 64 d (get-cpu-load
4bd0: 29 29 0a 09 28 68 6f 73 74 6e 61 6d 65 20 28 67 ))..(hostname (g
4be0: 65 74 2d 68 6f 73 74 2d 6e 61 6d 65 29 29 0a 09 et-host-name))..
4bf0: 28 64 69 73 6b 66 72 65 65 20 28 67 65 74 2d 64 (diskfree (get-d
4c00: 66 20 28 63 75 72 72 65 6e 74 2d 64 69 72 65 63 f (current-direc
4c10: 74 6f 72 79 29 29 29 0a 09 28 75 6e 61 6d 65 20 tory)))..(uname
4c20: 20 20 20 28 67 65 74 2d 75 6e 61 6d 65 20 22 2d (get-uname "-
4c30: 73 72 76 70 69 6f 22 29 29 0a 09 28 72 75 6e 70 srvpio"))..(runp
4c40: 61 74 68 20 20 28 63 75 72 72 65 6e 74 2d 64 69 ath (current-di
4c50: 72 65 63 74 6f 72 79 29 29 29 0a 20 20 20 20 28 rectory))). (
4c60: 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 sqlite3:execute
4c70: 64 62 20 22 55 50 44 41 54 45 20 74 65 73 74 73 db "UPDATE tests
4c80: 20 53 45 54 20 68 6f 73 74 3d 3f 2c 63 70 75 6c SET host=?,cpul
4c90: 6f 61 64 3d 3f 2c 64 69 73 6b 66 72 65 65 3d 3f oad=?,diskfree=?
4ca0: 2c 75 6e 61 6d 65 3d 3f 2c 72 75 6e 64 69 72 3d ,uname=?,rundir=
4cb0: 3f 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f ? WHERE run_id=?
4cc0: 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 AND testname=?
4cd0: 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f 3b AND item_path=?;
4ce0: 22 0a 09 09 20 20 68 6f 73 74 6e 61 6d 65 0a 09 "... hostname..
4cf0: 09 20 20 63 70 75 6c 6f 61 64 0a 09 09 20 20 64 . cpuload... d
4d00: 69 73 6b 66 72 65 65 0a 09 09 20 20 75 6e 61 6d iskfree... unam
4d10: 65 0a 09 09 20 20 72 75 6e 70 61 74 68 0a 09 09 e... runpath...
4d20: 20 20 72 75 6e 2d 69 64 0a 09 09 20 20 74 65 73 run-id... tes
4d30: 74 6e 61 6d 65 0a 09 09 20 20 69 74 65 6d 2d 70 tname... item-p
4d40: 61 74 68 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 ath)))..(define
4d50: 28 74 65 73 74 2d 75 70 64 61 74 65 2d 6d 65 74 (test-update-met
4d60: 61 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64 a-info db run-id
4d70: 20 74 65 73 74 6e 61 6d 65 20 69 74 65 6d 64 61 testname itemda
4d80: 74 20 6d 69 6e 75 74 65 73 29 0a 20 20 28 6c 65 t minutes). (le
4d90: 74 20 28 28 69 74 65 6d 2d 70 61 74 68 20 28 69 t ((item-path (i
4da0: 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69 tem-list->path i
4db0: 74 65 6d 64 61 74 29 29 0a 09 28 63 70 75 6c 6f temdat))..(cpulo
4dc0: 61 64 20 20 28 67 65 74 2d 63 70 75 2d 6c 6f 61 ad (get-cpu-loa
4dd0: 64 29 29 0a 09 28 64 69 73 6b 66 72 65 65 20 28 d))..(diskfree (
4de0: 67 65 74 2d 64 66 20 28 63 75 72 72 65 6e 74 2d get-df (current-
4df0: 64 69 72 65 63 74 6f 72 79 29 29 29 29 0a 20 20 directory)))).
4e00: 20 20 28 69 66 20 28 6e 6f 74 20 63 70 75 6c 6f (if (not cpulo
4e10: 61 64 29 20 20 28 62 65 67 69 6e 20 28 64 65 62 ad) (begin (deb
4e20: 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e ug:print 0 "WARN
4e30: 49 4e 47 3a 20 43 50 55 4c 4f 41 44 20 6e 6f 74 ING: CPULOAD not
4e40: 20 66 6f 75 6e 64 2e 22 29 20 20 28 73 65 74 21 found.") (set!
4e50: 20 63 70 75 6c 6f 61 64 20 22 6e 2f 61 22 29 29 cpuload "n/a"))
4e60: 29 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 64 ). (if (not d
4e70: 69 73 6b 66 72 65 65 29 20 28 62 65 67 69 6e 20 iskfree) (begin
4e80: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 (debug:print 0 "
4e90: 57 41 52 4e 49 4e 47 3a 20 44 49 53 4b 46 52 45 WARNING: DISKFRE
4ea0: 45 20 6e 6f 74 20 66 6f 75 6e 64 2e 22 29 20 28 E not found.") (
4eb0: 73 65 74 21 20 64 69 73 6b 66 72 65 65 20 22 6e set! diskfree "n
4ec0: 2f 61 22 29 29 29 0a 20 20 20 20 28 69 66 20 28 /a"))). (if (
4ed0: 6e 6f 74 20 69 74 65 6d 2d 70 61 74 68 29 28 62 not item-path)(b
4ee0: 65 67 69 6e 20 28 64 65 62 75 67 3a 70 72 69 6e egin (debug:prin
4ef0: 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 49 54 t 0 "WARNING: IT
4f00: 45 4d 50 41 54 48 20 6e 6f 74 20 73 65 74 2e 22 EMPATH not set."
4f10: 29 20 20 20 28 73 65 74 21 20 69 74 65 6d 2d 70 ) (set! item-p
4f20: 61 74 68 20 22 22 29 29 29 0a 20 20 20 20 3b 3b ath ""))). ;;
4f30: 20 28 6c 65 74 20 28 28 74 65 73 74 69 6e 66 6f (let ((testinfo
4f40: 20 28 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e (db:get-test-in
4f50: 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 fo db run-id tes
4f60: 74 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 tname item-path)
4f70: 29 29 0a 20 20 20 20 3b 3b 20 20 20 28 69 66 20 )). ;; (if
4f80: 28 61 6e 64 20 28 6e 6f 74 20 28 65 71 75 61 6c (and (not (equal
4f90: 3f 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 73 ? (db:test-get-s
4fa0: 74 61 74 75 73 20 74 65 73 74 69 6e 66 6f 29 20 tatus testinfo)
4fb0: 22 43 4f 4d 50 4c 45 54 45 44 22 29 29 0a 20 20 "COMPLETED")).
4fc0: 20 20 3b 3b 20 20 20 20 20 20 20 20 20 20 20 20 ;;
4fd0: 28 6e 6f 74 20 28 65 71 75 61 6c 3f 20 28 64 62 (not (equal? (db
4fe0: 3a 74 65 73 74 2d 67 65 74 2d 73 74 61 74 75 73 :test-get-status
4ff0: 20 74 65 73 74 69 6e 66 6f 29 20 22 4b 49 4c 4c testinfo) "KILL
5000: 52 45 51 22 29 29 0a 20 20 20 20 28 73 71 6c 69 REQ")). (sqli
5010: 74 65 33 3a 65 78 65 63 75 74 65 0a 20 20 20 20 te3:execute.
5020: 20 64 62 0a 20 20 20 20 20 22 55 50 44 41 54 45 db. "UPDATE
5030: 20 74 65 73 74 73 20 53 45 54 20 63 70 75 6c 6f tests SET cpulo
5040: 61 64 3d 3f 2c 64 69 73 6b 66 72 65 65 3d 3f 2c ad=?,diskfree=?,
5050: 72 75 6e 5f 64 75 72 61 74 69 6f 6e 3d 3f 2c 73 run_duration=?,s
5060: 74 61 74 65 3d 27 52 55 4e 4e 49 4e 47 27 20 57 tate='RUNNING' W
5070: 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e HERE run_id=? AN
5080: 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 D testname=? AND
5090: 20 69 74 65 6d 5f 70 61 74 68 3d 3f 20 41 4e 44 item_path=? AND
50a0: 20 73 74 61 74 65 20 4e 4f 54 20 49 4e 20 28 27 state NOT IN ('
50b0: 43 4f 4d 50 4c 45 54 45 44 27 2c 27 4b 49 4c 4c COMPLETED','KILL
50c0: 52 45 51 27 2c 27 4b 49 4c 4c 45 44 27 29 3b 22 REQ','KILLED');"
50d0: 0a 20 20 20 20 20 63 70 75 6c 6f 61 64 0a 20 20 . cpuload.
50e0: 20 20 20 64 69 73 6b 66 72 65 65 0a 20 20 20 20 diskfree.
50f0: 20 6d 69 6e 75 74 65 73 0a 20 20 20 20 20 72 75 minutes. ru
5100: 6e 2d 69 64 0a 20 20 20 20 20 74 65 73 74 6e 61 n-id. testna
5110: 6d 65 0a 20 20 20 20 20 69 74 65 6d 2d 70 61 74 me. item-pat
5120: 68 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 73 h)))..(define (s
5130: 65 74 2d 6d 65 67 61 74 65 73 74 2d 65 6e 76 2d et-megatest-env-
5140: 76 61 72 73 20 64 62 20 72 75 6e 2d 69 64 29 0a vars db run-id).
5150: 20 20 28 6c 65 74 20 28 28 6b 65 79 73 20 28 64 (let ((keys (d
5160: 62 2d 67 65 74 2d 6b 65 79 73 20 64 62 29 29 29 b-get-keys db)))
5170: 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20 28 . (for-each (
5180: 6c 61 6d 62 64 61 20 28 6b 65 79 29 0a 09 09 28 lambda (key)...(
5190: 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 sqlite3:for-each
51a0: 2d 72 6f 77 0a 09 09 20 28 6c 61 6d 62 64 61 20 -row... (lambda
51b0: 28 76 61 6c 29 0a 09 09 20 20 20 28 64 65 62 75 (val)... (debu
51c0: 67 3a 70 72 69 6e 74 20 32 20 22 73 65 74 65 6e g:print 2 "seten
51d0: 76 20 22 20 28 6b 65 79 3a 67 65 74 2d 66 69 65 v " (key:get-fie
51e0: 6c 64 6e 61 6d 65 20 6b 65 79 29 20 22 20 22 20 ldname key) " "
51f0: 76 61 6c 29 0a 09 09 20 20 20 28 73 65 74 65 6e val)... (seten
5200: 76 20 28 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64 v (key:get-field
5210: 6e 61 6d 65 20 6b 65 79 29 20 76 61 6c 29 29 0a name key) val)).
5220: 09 09 20 64 62 20 0a 09 09 20 28 63 6f 6e 63 20 .. db ... (conc
5230: 22 53 45 4c 45 43 54 20 22 20 28 6b 65 79 3a 67 "SELECT " (key:g
5240: 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65 79 et-fieldname key
5250: 29 20 22 20 46 52 4f 4d 20 72 75 6e 73 20 57 48 ) " FROM runs WH
5260: 45 52 45 20 69 64 3d 3f 3b 22 29 0a 09 09 20 72 ERE id=?;")... r
5270: 75 6e 2d 69 64 29 29 0a 09 20 20 20 20 20 20 6b un-id)).. k
5280: 65 79 73 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 eys)))..(define
5290: 28 73 65 74 2d 69 74 65 6d 2d 65 6e 76 2d 76 61 (set-item-env-va
52a0: 72 73 20 69 74 65 6d 64 61 74 29 0a 20 20 28 66 rs itemdat). (f
52b0: 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 20 or-each (lambda
52c0: 28 69 74 65 6d 29 0a 09 20 20 20 20 20 20 28 64 (item).. (d
52d0: 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 73 65 ebug:print 2 "se
52e0: 74 65 6e 76 20 22 20 28 63 61 72 20 69 74 65 6d tenv " (car item
52f0: 29 20 22 20 22 20 28 63 61 64 72 20 69 74 65 6d ) " " (cadr item
5300: 29 29 0a 09 20 20 20 20 20 20 28 73 65 74 65 6e )).. (seten
5310: 76 20 28 63 61 72 20 69 74 65 6d 29 20 28 63 61 v (car item) (ca
5320: 64 72 20 69 74 65 6d 29 29 29 0a 09 20 20 20 20 dr item)))..
5330: 69 74 65 6d 64 61 74 29 29 0a 0a 28 64 65 66 69 itemdat))..(defi
5340: 6e 65 20 28 67 65 74 2d 61 6c 6c 2d 6c 65 67 61 ne (get-all-lega
5350: 6c 2d 74 65 73 74 73 29 0a 20 20 28 6c 65 74 2a l-tests). (let*
5360: 20 28 28 74 65 73 74 73 20 20 28 67 6c 6f 62 20 ((tests (glob
5370: 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74 68 2a 20 (conc *toppath*
5380: 22 2f 74 65 73 74 73 2f 2a 22 29 29 29 0a 09 20 "/tests/*")))..
5390: 28 72 65 73 20 20 20 20 27 28 29 29 29 0a 20 20 (res '())).
53a0: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 (debug:print 4
53b0: 20 22 49 4e 46 4f 3a 20 4c 6f 6f 6b 69 6e 67 20 "INFO: Looking
53c0: 61 74 20 74 65 73 74 73 20 22 20 28 73 74 72 69 at tests " (stri
53d0: 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 74 ng-intersperse t
53e0: 65 73 74 73 20 22 2c 22 29 29 0a 20 20 20 20 28 ests ",")). (
53f0: 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 for-each (lambda
5400: 20 28 74 65 73 74 70 61 74 68 29 0a 09 09 28 69 (testpath)...(i
5410: 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 f (file-exists?
5420: 28 63 6f 6e 63 20 74 65 73 74 70 61 74 68 20 22 (conc testpath "
5430: 2f 74 65 73 74 63 6f 6e 66 69 67 22 29 29 0a 09 /testconfig"))..
5440: 09 20 20 20 20 28 73 65 74 21 20 72 65 73 20 28 . (set! res (
5450: 63 6f 6e 73 20 28 6c 61 73 74 20 28 73 74 72 69 cons (last (stri
5460: 6e 67 2d 73 70 6c 69 74 20 74 65 73 74 70 61 74 ng-split testpat
5470: 68 20 22 2f 22 29 29 20 72 65 73 29 29 29 29 0a h "/")) res)))).
5480: 09 20 20 20 20 20 20 74 65 73 74 73 29 0a 20 20 . tests).
5490: 20 20 72 65 73 29 29 0a 0a 28 64 65 66 69 6e 65 res))..(define
54a0: 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d (runs:can-run-m
54b0: 6f 72 65 2d 74 65 73 74 73 20 64 62 29 0a 20 20 ore-tests db).
54c0: 28 6c 65 74 20 28 28 6e 75 6d 2d 72 75 6e 6e 69 (let ((num-runni
54d0: 6e 67 20 28 64 62 3a 67 65 74 2d 63 6f 75 6e 74 ng (db:get-count
54e0: 2d 74 65 73 74 73 2d 72 75 6e 6e 69 6e 67 20 64 -tests-running d
54f0: 62 29 29 0a 09 28 6d 61 78 2d 63 6f 6e 63 75 72 b))..(max-concur
5500: 72 65 6e 74 2d 6a 6f 62 73 20 28 63 6f 6e 66 69 rent-jobs (confi
5510: 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67 g-lookup *config
5520: 64 61 74 2a 20 22 73 65 74 75 70 22 20 22 6d 61 dat* "setup" "ma
5530: 78 5f 63 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f 62 x_concurrent_job
5540: 73 22 29 29 29 0a 20 20 20 20 28 64 65 62 75 67 s"))). (debug
5550: 3a 70 72 69 6e 74 20 32 20 22 6d 61 78 2d 63 6f :print 2 "max-co
5560: 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 3a 20 22 ncurrent-jobs: "
5570: 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d max-concurrent-
5580: 6a 6f 62 73 20 22 2c 20 6e 75 6d 2d 72 75 6e 6e jobs ", num-runn
5590: 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69 ing: " num-runni
55a0: 6e 67 29 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 ng). (if (not
55b0: 20 28 65 71 3f 20 30 20 2a 67 6c 6f 62 61 6c 65 (eq? 0 *globale
55c0: 78 69 74 73 74 61 74 75 73 2a 29 29 0a 09 23 66 xitstatus*))..#f
55d0: 0a 09 28 69 66 20 28 6f 72 20 28 6e 6f 74 20 6d ..(if (or (not m
55e0: 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f ax-concurrent-jo
55f0: 62 73 29 0a 09 09 28 61 6e 64 20 6d 61 78 2d 63 bs)...(and max-c
5600: 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 0a 09 oncurrent-jobs..
5610: 09 20 20 20 20 20 28 73 74 72 69 6e 67 2d 3e 6e . (string->n
5620: 75 6d 62 65 72 20 6d 61 78 2d 63 6f 6e 63 75 72 umber max-concur
5630: 72 65 6e 74 2d 6a 6f 62 73 29 0a 09 09 20 20 20 rent-jobs)...
5640: 20 20 28 6e 6f 74 20 28 3e 3d 20 6e 75 6d 2d 72 (not (>= num-r
5650: 75 6e 6e 69 6e 67 20 28 73 74 72 69 6e 67 2d 3e unning (string->
5660: 6e 75 6d 62 65 72 20 6d 61 78 2d 63 6f 6e 63 75 number max-concu
5670: 72 72 65 6e 74 2d 6a 6f 62 73 29 29 29 29 29 0a rrent-jobs))))).
5680: 09 20 20 20 20 23 74 0a 09 20 20 20 20 28 62 65 . #t.. (be
5690: 67 69 6e 20 0a 09 20 20 20 20 20 20 28 64 65 62 gin .. (deb
56a0: 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e ug:print 0 "WARN
56b0: 49 4e 47 3a 20 4d 61 78 20 72 75 6e 6e 69 6e 67 ING: Max running
56c0: 20 6a 6f 62 73 20 65 78 63 65 65 64 65 64 2c 20 jobs exceeded,
56d0: 63 75 72 72 65 6e 74 20 6e 75 6d 62 65 72 20 72 current number r
56e0: 75 6e 6e 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 unning: " num-ru
56f0: 6e 6e 69 6e 67 20 0a 09 09 09 20 20 20 22 2c 20 nning .... ",
5700: 6d 61 78 5f 63 6f 6e 63 75 72 72 65 6e 74 5f 6a max_concurrent_j
5710: 6f 62 73 3a 20 22 20 6d 61 78 2d 63 6f 6e 63 75 obs: " max-concu
5720: 72 72 65 6e 74 2d 6a 6f 62 73 29 0a 09 20 20 20 rrent-jobs)..
5730: 20 20 20 23 66 29 29 29 29 29 0a 20 20 0a 28 64 #f))))). .(d
5740: 65 66 69 6e 65 20 28 72 75 6e 2d 74 65 73 74 73 efine (run-tests
5750: 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 73 29 0a db test-names).
5760: 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 73 20 20 (let* ((keys
5770: 20 20 20 20 20 20 28 64 62 2d 67 65 74 2d 6b 65 (db-get-ke
5780: 79 73 20 64 62 29 29 0a 09 20 28 6b 65 79 76 61 ys db)).. (keyva
5790: 6c 6c 73 74 20 20 20 28 6b 65 79 73 2d 3e 76 61 llst (keys->va
57a0: 6c 6c 69 73 74 20 6b 65 79 73 20 23 74 29 29 0a llist keys #t)).
57b0: 09 20 28 72 75 6e 2d 69 64 20 20 20 20 20 20 28 . (run-id (
57c0: 72 65 67 69 73 74 65 72 2d 72 75 6e 20 64 62 20 register-run db
57d0: 6b 65 79 73 29 29 20 20 3b 3b 20 20 74 65 73 74 keys)) ;; test
57e0: 2d 6e 61 6d 65 29 29 29 0a 09 20 28 64 65 66 65 -name))).. (defe
57f0: 72 72 65 64 20 20 20 20 27 28 29 29 29 20 3b 3b rred '())) ;;
5800: 20 64 65 6c 61 79 20 72 75 6e 6e 69 6e 67 20 74 delay running t
5810: 68 65 73 65 20 73 69 6e 63 65 20 74 68 65 79 20 hese since they
5820: 68 61 76 65 20 61 20 77 61 69 74 6f 6e 20 63 6c have a waiton cl
5830: 61 75 73 65 0a 20 20 20 20 3b 3b 20 6f 6e 20 74 ause. ;; on t
5840: 68 65 20 66 69 72 73 74 20 70 61 73 73 20 6f 72 he first pass or
5850: 20 63 61 6c 6c 20 74 6f 20 72 75 6e 2d 74 65 73 call to run-tes
5860: 74 73 20 73 65 74 20 46 41 49 4c 53 20 74 6f 20 ts set FAILS to
5870: 4e 4f 54 5f 53 54 41 52 54 45 44 20 69 66 0a 20 NOT_STARTED if.
5880: 20 20 20 3b 3b 20 2d 6b 65 65 70 67 6f 69 6e 67 ;; -keepgoing
5890: 20 69 73 20 73 70 65 63 69 66 69 65 64 0a 20 20 is specified.
58a0: 20 20 28 69 66 20 28 61 6e 64 20 28 65 71 3f 20 (if (and (eq?
58b0: 2a 70 61 73 73 6e 75 6d 2a 20 30 29 0a 09 20 20 *passnum* 0)..
58c0: 20 20 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 (args:get-arg
58d0: 20 22 2d 6b 65 65 70 67 6f 69 6e 67 22 29 29 0a "-keepgoing")).
58e0: 09 28 62 65 67 69 6e 0a 09 20 20 3b 3b 20 68 61 .(begin.. ;; ha
58f0: 76 65 20 74 6f 20 64 65 6c 65 74 65 20 74 65 73 ve to delete tes
5900: 74 20 72 65 63 6f 72 64 73 20 77 68 65 72 65 20 t records where
5910: 4e 4f 54 5f 53 54 41 52 54 45 44 20 73 69 6e 63 NOT_STARTED sinc
5920: 65 20 74 68 65 79 20 63 61 6e 20 63 61 75 73 65 e they can cause
5930: 20 2d 6b 65 65 70 67 6f 69 6e 67 20 74 6f 20 0a -keepgoing to .
5940: 09 20 20 3b 3b 20 67 65 74 20 73 74 75 63 6b 20 . ;; get stuck
5950: 64 75 65 20 74 6f 20 62 65 63 6f 6d 69 6e 67 20 due to becoming
5960: 69 6e 61 63 63 65 73 73 69 62 6c 65 20 66 72 6f inaccessible fro
5970: 6d 20 61 20 66 61 69 6c 65 64 20 74 65 73 74 2e m a failed test.
5980: 20 49 2e 65 2e 20 69 66 20 74 65 73 74 20 42 20 I.e. if test B
5990: 64 65 70 65 6e 64 73 20 0a 09 20 20 3b 3b 20 6f depends .. ;; o
59a0: 6e 20 74 65 73 74 20 41 20 62 75 74 20 74 65 73 n test A but tes
59b0: 74 20 42 20 72 65 61 63 68 65 64 20 74 68 65 20 t B reached the
59c0: 70 6f 69 6e 74 20 6f 6e 20 62 65 69 6e 67 20 72 point on being r
59d0: 65 67 69 73 74 65 72 65 64 20 61 73 20 4e 4f 54 egistered as NOT
59e0: 5f 53 54 41 52 54 45 44 20 61 6e 64 20 74 65 73 _STARTED and tes
59f0: 74 0a 09 20 20 3b 3b 20 41 20 66 61 69 6c 65 64 t.. ;; A failed
5a00: 20 66 6f 72 20 73 6f 6d 65 20 72 65 61 73 6f 6e for some reason
5a10: 20 74 68 65 6e 20 6f 6e 20 72 65 2d 72 75 6e 20 then on re-run
5a20: 75 73 69 6e 67 20 2d 6b 65 65 70 67 6f 69 6e 67 using -keepgoing
5a30: 20 74 68 65 20 72 75 6e 20 63 61 6e 20 6e 65 76 the run can nev
5a40: 65 72 20 63 6f 6d 70 6c 65 74 65 2e 0a 09 20 20 er complete...
5a50: 28 64 62 3a 64 65 6c 65 74 65 2d 74 65 73 74 73 (db:delete-tests
5a60: 2d 69 6e 2d 73 74 61 74 65 20 64 62 20 72 75 6e -in-state db run
5a70: 2d 69 64 20 22 4e 4f 54 5f 53 54 41 52 54 45 44 -id "NOT_STARTED
5a80: 22 29 0a 09 20 20 28 64 62 3a 73 65 74 2d 74 65 ").. (db:set-te
5a90: 73 74 73 2d 73 74 61 74 65 2d 73 74 61 74 75 73 sts-state-status
5aa0: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d db run-id test-
5ab0: 6e 61 6d 65 73 20 23 66 20 22 46 41 49 4c 22 20 names #f "FAIL"
5ac0: 22 4e 4f 54 5f 53 54 41 52 54 45 44 22 20 22 46 "NOT_STARTED" "F
5ad0: 41 49 4c 22 29 29 29 0a 20 20 20 20 28 73 65 74 AIL"))). (set
5ae0: 21 20 2a 70 61 73 73 6e 75 6d 2a 20 28 2b 20 2a ! *passnum* (+ *
5af0: 70 61 73 73 6e 75 6d 2a 20 31 29 29 0a 20 20 20 passnum* 1)).
5b00: 20 28 6c 65 74 20 6c 6f 6f 70 20 28 28 6e 75 6d (let loop ((num
5b10: 74 69 6d 65 73 20 30 29 29 0a 20 20 20 20 20 20 times 0)).
5b20: 28 66 6f 72 2d 65 61 63 68 20 0a 20 20 20 20 20 (for-each .
5b30: 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74 2d (lambda (test-
5b40: 6e 61 6d 65 29 0a 09 20 28 69 66 20 28 72 75 6e name).. (if (run
5b50: 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65 2d 74 s:can-run-more-t
5b60: 65 73 74 73 20 64 62 29 0a 09 20 20 20 20 20 28 ests db).. (
5b70: 72 75 6e 2d 6f 6e 65 2d 74 65 73 74 20 64 62 20 run-one-test db
5b80: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 run-id test-name
5b90: 20 6b 65 79 76 61 6c 6c 73 74 29 0a 09 20 20 20 keyvallst)..
5ba0: 20 20 3b 3b 20 61 64 64 20 73 6f 6d 65 20 64 65 ;; add some de
5bb0: 6c 61 79 20 0a 09 20 20 20 20 20 3b 28 73 6c 65 lay .. ;(sle
5bc0: 65 70 20 32 29 0a 09 20 20 20 20 20 29 29 0a 20 ep 2).. )).
5bd0: 20 20 20 20 20 20 74 65 73 74 2d 6e 61 6d 65 73 test-names
5be0: 29 0a 20 20 20 20 20 20 3b 3b 20 28 72 75 6e 2d ). ;; (run-
5bf0: 77 61 69 74 69 6e 67 2d 74 65 73 74 73 20 64 62 waiting-tests db
5c00: 29 0a 20 20 20 20 20 20 28 69 66 20 28 61 72 67 ). (if (arg
5c10: 73 3a 67 65 74 2d 61 72 67 20 22 2d 6b 65 65 70 s:get-arg "-keep
5c20: 67 6f 69 6e 67 22 29 0a 09 20 20 28 6c 65 74 20 going").. (let
5c30: 28 28 65 73 74 72 65 6d 20 28 64 62 3a 65 73 74 ((estrem (db:est
5c40: 69 6d 61 74 65 64 2d 74 65 73 74 73 2d 72 65 6d imated-tests-rem
5c50: 61 69 6e 69 6e 67 20 64 62 20 72 75 6e 2d 69 64 aining db run-id
5c60: 29 29 29 0a 09 20 20 20 20 28 69 66 20 28 61 6e ))).. (if (an
5c70: 64 20 28 3e 20 65 73 74 72 65 6d 20 30 29 0a 09 d (> estrem 0)..
5c80: 09 20 20 20 20 20 28 65 71 3f 20 2a 67 6c 6f 62 . (eq? *glob
5c90: 61 6c 65 78 69 74 73 74 61 74 75 73 2a 20 30 29 alexitstatus* 0)
5ca0: 29 0a 09 09 28 62 65 67 69 6e 0a 09 09 20 20 28 )...(begin... (
5cb0: 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 4b debug:print 1 "K
5cc0: 65 65 70 20 67 6f 69 6e 67 2c 20 65 73 74 69 6d eep going, estim
5cd0: 61 74 65 64 20 22 20 65 73 74 72 65 6d 20 22 20 ated " estrem "
5ce0: 74 65 73 74 73 20 72 65 6d 61 69 6e 69 6e 67 20 tests remaining
5cf0: 74 6f 20 72 75 6e 2c 20 77 69 6c 6c 20 63 6f 6e to run, will con
5d00: 74 69 6e 75 65 20 69 6e 20 33 20 73 65 63 6f 6e tinue in 3 secon
5d10: 64 73 20 2e 2e 2e 22 29 0a 09 09 20 20 28 73 6c ds ...")... (sl
5d20: 65 65 70 20 33 29 0a 09 09 20 20 28 72 75 6e 2d eep 3)... (run-
5d30: 77 61 69 74 69 6e 67 2d 74 65 73 74 73 20 64 62 waiting-tests db
5d40: 29 0a 09 09 20 20 28 6c 6f 6f 70 20 28 2b 20 6e )... (loop (+ n
5d50: 75 6d 74 69 6d 65 73 20 31 29 29 29 29 29 29 29 umtimes 1)))))))
5d60: 29 29 0a 09 20 20 20 0a 3b 3b 20 56 45 52 59 20 )).. .;; VERY
5d70: 49 4e 45 46 46 49 43 49 45 4e 54 21 20 4d 6f 76 INEFFICIENT! Mov
5d80: 65 20 73 74 75 66 66 20 74 68 61 74 20 73 68 6f e stuff that sho
5d90: 75 6c 64 20 62 65 20 64 6f 6e 65 20 6f 6e 63 65 uld be done once
5da0: 20 75 70 20 74 6f 20 63 61 6c 6c 69 6e 67 20 70 up to calling p
5db0: 72 6f 63 0a 28 64 65 66 69 6e 65 20 28 72 75 6e roc.(define (run
5dc0: 2d 6f 6e 65 2d 74 65 73 74 20 64 62 20 72 75 6e -one-test db run
5dd0: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 6b 65 -id test-name ke
5de0: 79 76 61 6c 6c 73 74 29 0a 20 20 28 64 65 62 75 yvallst). (debu
5df0: 67 3a 70 72 69 6e 74 20 31 20 22 4c 61 75 6e 63 g:print 1 "Launc
5e00: 68 69 6e 67 20 74 65 73 74 20 22 20 74 65 73 74 hing test " test
5e10: 2d 6e 61 6d 65 29 0a 20 20 3b 3b 20 41 6c 6c 20 -name). ;; All
5e20: 74 68 65 73 65 20 76 61 72 73 20 6d 69 67 68 74 these vars might
5e30: 20 62 65 20 72 65 66 65 72 65 6e 63 65 64 20 62 be referenced b
5e40: 79 20 74 68 65 20 74 65 73 74 63 6f 6e 66 69 67 y the testconfig
5e50: 20 66 69 6c 65 20 72 65 61 64 65 72 0a 20 20 28 file reader. (
5e60: 73 65 74 65 6e 76 20 22 4d 54 5f 54 45 53 54 5f setenv "MT_TEST_
5e70: 4e 41 4d 45 22 20 74 65 73 74 2d 6e 61 6d 65 29 NAME" test-name)
5e80: 20 3b 3b 20 0a 20 20 28 73 65 74 65 6e 76 20 22 ;; . (setenv "
5e90: 4d 54 5f 52 55 4e 4e 41 4d 45 22 20 20 20 28 61 MT_RUNNAME" (a
5ea0: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 3a 72 75 rgs:get-arg ":ru
5eb0: 6e 6e 61 6d 65 22 29 29 0a 20 20 28 73 65 74 2d nname")). (set-
5ec0: 6d 65 67 61 74 65 73 74 2d 65 6e 76 2d 76 61 72 megatest-env-var
5ed0: 73 20 64 62 20 72 75 6e 2d 69 64 29 20 3b 3b 20 s db run-id) ;;
5ee0: 74 68 65 73 65 20 6d 61 79 20 62 65 20 6e 65 65 these may be nee
5ef0: 64 65 64 20 62 79 20 74 68 65 20 6c 61 75 6e 63 ded by the launc
5f00: 68 69 6e 67 20 70 72 6f 63 65 73 73 0a 20 20 28 hing process. (
5f10: 63 68 61 6e 67 65 2d 64 69 72 65 63 74 6f 72 79 change-directory
5f20: 20 2a 74 6f 70 70 61 74 68 2a 29 0a 20 20 28 6c *toppath*). (l
5f30: 65 74 2a 20 28 28 74 65 73 74 2d 70 61 74 68 20 et* ((test-path
5f40: 20 20 20 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74 (conc *toppat
5f50: 68 2a 20 22 2f 74 65 73 74 73 2f 22 20 74 65 73 h* "/tests/" tes
5f60: 74 2d 6e 61 6d 65 29 29 0a 09 20 28 74 65 73 74 t-name)).. (test
5f70: 2d 63 6f 6e 66 69 67 66 20 28 63 6f 6e 63 20 74 -configf (conc t
5f80: 65 73 74 2d 70 61 74 68 20 22 2f 74 65 73 74 63 est-path "/testc
5f90: 6f 6e 66 69 67 22 29 29 0a 09 20 28 74 65 73 74 onfig")).. (test
5fa0: 65 78 69 73 74 73 20 20 20 28 61 6e 64 20 28 66 exists (and (f
5fb0: 69 6c 65 2d 65 78 69 73 74 73 3f 20 74 65 73 74 ile-exists? test
5fc0: 2d 63 6f 6e 66 69 67 66 29 28 66 69 6c 65 2d 72 -configf)(file-r
5fd0: 65 61 64 2d 61 63 63 65 73 73 3f 20 74 65 73 74 ead-access? test
5fe0: 2d 63 6f 6e 66 69 67 66 29 29 29 0a 09 20 28 74 -configf))).. (t
5ff0: 65 73 74 2d 63 6f 6e 66 20 20 20 20 28 69 66 20 est-conf (if
6000: 74 65 73 74 65 78 69 73 74 73 20 28 72 65 61 64 testexists (read
6010: 2d 63 6f 6e 66 69 67 20 74 65 73 74 2d 63 6f 6e -config test-con
6020: 66 69 67 66 20 23 66 20 23 74 29 20 28 6d 61 6b figf #f #t) (mak
6030: 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29 29 0a e-hash-table))).
6040: 09 20 28 77 61 69 74 6f 6e 20 20 20 20 20 20 20 . (waiton
6050: 28 6c 65 74 20 28 28 77 20 28 63 6f 6e 66 69 67 (let ((w (config
6060: 2d 6c 6f 6f 6b 75 70 20 74 65 73 74 2d 63 6f 6e -lookup test-con
6070: 66 20 22 72 65 71 75 69 72 65 6d 65 6e 74 73 22 f "requirements"
6080: 20 22 77 61 69 74 6f 6e 22 29 29 29 0a 09 09 09 "waiton")))....
6090: 20 28 69 66 20 28 73 74 72 69 6e 67 3f 20 77 29 (if (string? w)
60a0: 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 77 29 (string-split w)
60b0: 27 28 29 29 29 29 0a 09 20 28 74 61 67 73 20 20 '()))).. (tags
60c0: 20 20 20 20 20 20 20 28 6c 65 74 20 28 28 74 20 (let ((t
60d0: 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 74 (config-lookup t
60e0: 65 73 74 2d 63 6f 6e 66 20 22 73 65 74 75 70 22 est-conf "setup"
60f0: 20 22 74 61 67 73 22 29 29 29 0a 09 09 09 20 3b "tags"))).... ;
6100: 3b 20 77 65 20 77 61 6e 74 20 6f 75 72 20 74 61 ; we want our ta
6110: 67 73 20 74 6f 20 62 65 20 73 65 70 61 72 61 74 gs to be separat
6120: 65 64 20 62 79 20 63 6f 6d 6d 61 73 20 61 6e 64 ed by commas and
6130: 20 66 75 6c 6c 79 20 64 65 6c 69 6d 69 74 65 64 fully delimited
6140: 20 62 79 20 63 6f 6d 6d 61 73 0a 09 09 09 20 3b by commas.... ;
6150: 3b 20 73 6f 20 74 68 61 74 20 71 75 65 72 69 65 ; so that querie
6160: 73 20 77 69 74 68 20 22 6c 69 6b 65 22 20 63 61 s with "like" ca
6170: 6e 20 74 69 65 20 74 6f 20 74 68 65 20 63 6f 6d n tie to the com
6180: 6d 61 73 20 61 74 20 65 69 74 68 65 72 20 65 6e mas at either en
6190: 64 20 6f 66 20 65 61 63 68 20 74 61 67 0a 09 09 d of each tag...
61a0: 09 20 3b 3b 20 77 68 69 6c 65 20 61 6c 73 6f 20 . ;; while also
61b0: 61 6c 6c 6f 77 69 6e 67 20 74 68 65 20 65 6e 64 allowing the end
61c0: 20 75 73 65 72 20 74 6f 20 66 72 65 65 6c 79 20 user to freely
61d0: 75 73 65 20 73 70 61 63 65 73 20 61 6e 64 20 63 use spaces and c
61e0: 6f 6d 6d 61 73 20 74 6f 20 73 65 70 61 72 61 74 ommas to separat
61f0: 65 20 74 61 67 73 0a 09 09 09 20 28 69 66 20 28 e tags.... (if (
6200: 73 74 72 69 6e 67 3f 20 74 29 28 73 74 72 69 6e string? t)(strin
6210: 67 2d 73 75 62 73 74 69 74 75 74 65 20 28 72 65 g-substitute (re
6220: 67 65 78 70 20 22 5b 2c 5c 5c 73 5d 2b 22 29 20 gexp "[,\\s]+")
6230: 22 2c 22 20 28 63 6f 6e 63 20 22 2c 22 20 74 20 "," (conc "," t
6240: 22 2c 22 29 20 23 74 29 0a 09 09 09 20 20 20 20 ",") #t)....
6250: 20 27 28 29 29 29 29 29 0a 20 20 20 20 28 69 66 '())))). (if
6260: 20 28 6e 6f 74 20 74 65 73 74 65 78 69 73 74 73 (not testexists
6270: 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 28 64 65 )..(begin.. (de
6280: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 bug:print 0 "ERR
6290: 4f 52 3a 20 43 61 6e 27 74 20 66 69 6e 64 20 63 OR: Can't find c
62a0: 6f 6e 66 69 67 20 66 69 6c 65 20 22 20 74 65 73 onfig file " tes
62b0: 74 2d 63 6f 6e 66 69 67 66 29 0a 09 20 20 28 65 t-configf).. (e
62c0: 78 69 74 20 32 29 29 0a 09 3b 3b 20 70 75 74 20 xit 2))..;; put
62d0: 74 6f 70 20 76 61 72 73 20 69 6e 74 6f 20 63 6f top vars into co
62e0: 6e 76 65 6e 69 65 6e 74 20 76 61 72 69 61 62 6c nvenient variabl
62f0: 65 73 20 61 6e 64 20 6f 70 65 6e 20 74 68 65 20 es and open the
6300: 64 62 0a 09 28 6c 65 74 2a 20 28 3b 3b 20 64 62 db..(let* (;; db
6310: 20 69 73 20 61 6c 77 61 79 73 20 61 74 20 2a 74 is always at *t
6320: 6f 70 70 61 74 68 2a 2f 64 62 2f 6d 65 67 61 74 oppath*/db/megat
6330: 65 73 74 2e 64 62 0a 09 20 20 20 20 20 20 20 28 est.db.. (
6340: 69 74 65 6d 73 20 20 20 20 20 20 20 28 68 61 73 items (has
6350: 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 h-table-ref/defa
6360: 75 6c 74 20 74 65 73 74 2d 63 6f 6e 66 20 22 69 ult test-conf "i
6370: 74 65 6d 73 22 20 27 28 29 29 29 0a 09 20 20 20 tems" '()))..
6380: 20 20 20 20 28 69 74 65 6d 73 74 61 62 6c 65 20 (itemstable
6390: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 (hash-table-ref
63a0: 2f 64 65 66 61 75 6c 74 20 74 65 73 74 2d 63 6f /default test-co
63b0: 6e 66 20 22 69 74 65 6d 73 74 61 62 6c 65 22 20 nf "itemstable"
63c0: 27 28 29 29 29 0a 09 20 20 20 20 20 20 20 28 61 '())).. (a
63d0: 6c 6c 69 74 65 6d 73 20 20 20 20 28 69 66 20 28 llitems (if (
63e0: 6f 72 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 69 or (not (null? i
63f0: 74 65 6d 73 29 29 28 6e 6f 74 20 28 6e 75 6c 6c tems))(not (null
6400: 3f 20 69 74 65 6d 73 74 61 62 6c 65 29 29 29 0a ? itemstable))).
6410: 09 09 09 09 28 61 70 70 65 6e 64 20 28 69 74 65 ....(append (ite
6420: 6d 2d 61 73 73 6f 63 2d 3e 69 74 65 6d 2d 6c 69 m-assoc->item-li
6430: 73 74 20 69 74 65 6d 73 29 0a 09 09 09 09 09 28 st items)......(
6440: 69 74 65 6d 2d 74 61 62 6c 65 2d 3e 69 74 65 6d item-table->item
6450: 2d 6c 69 73 74 20 69 74 65 6d 73 74 61 62 6c 65 -list itemstable
6460: 29 29 0a 09 09 09 09 27 28 28 29 29 29 29 20 3b )).....'(()))) ;
6470: 3b 20 61 20 6c 69 73 74 20 77 69 74 68 20 6f 6e ; a list with on
6480: 65 20 6e 75 6c 6c 20 6c 69 73 74 20 69 73 20 61 e null list is a
6490: 20 74 65 73 74 20 77 69 74 68 20 6e 6f 20 69 74 test with no it
64a0: 65 6d 73 0a 09 20 20 20 20 20 20 20 28 72 75 6e ems.. (run
64b0: 63 6f 6e 66 69 67 66 20 20 28 63 6f 6e 63 20 20 configf (conc
64c0: 2a 74 6f 70 70 61 74 68 2a 20 22 2f 72 75 6e 63 *toppath* "/runc
64d0: 6f 6e 66 69 67 73 2e 63 6f 6e 66 69 67 22 29 29 onfigs.config"))
64e0: 29 0a 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e ).. (debug:prin
64f0: 74 20 31 20 22 69 74 65 6d 73 3a 20 22 29 0a 09 t 1 "items: ")..
6500: 20 20 28 69 66 20 28 3e 3d 20 2a 76 65 72 62 6f (if (>= *verbo
6510: 73 69 74 79 2a 20 31 29 28 70 70 20 61 6c 6c 69 sity* 1)(pp alli
6520: 74 65 6d 73 29 29 0a 09 20 20 28 69 66 20 28 3e tems)).. (if (>
6530: 3d 20 2a 76 65 72 62 6f 73 69 74 79 2a 20 35 29 = *verbosity* 5)
6540: 0a 09 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09 .. (begin..
6550: 09 28 70 72 69 6e 74 20 22 69 74 65 6d 73 3a 20 .(print "items:
6560: 22 29 28 70 70 20 28 69 74 65 6d 2d 61 73 73 6f ")(pp (item-asso
6570: 63 2d 3e 69 74 65 6d 2d 6c 69 73 74 20 69 74 65 c->item-list ite
6580: 6d 73 29 29 0a 09 09 28 70 72 69 6e 74 20 22 69 ms))...(print "i
6590: 74 65 73 74 61 62 6c 65 3a 20 22 29 28 70 70 20 testable: ")(pp
65a0: 28 69 74 65 6d 2d 74 61 62 6c 65 2d 3e 69 74 65 (item-table->ite
65b0: 6d 2d 6c 69 73 74 20 69 74 65 6d 73 74 61 62 6c m-list itemstabl
65c0: 65 29 29 29 29 0a 09 20 20 28 69 66 20 28 61 72 e)))).. (if (ar
65d0: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 6d 22 29 gs:get-arg "-m")
65e0: 0a 09 20 20 20 20 20 20 28 64 62 3a 73 65 74 2d .. (db:set-
65f0: 63 6f 6d 6d 65 6e 74 2d 66 6f 72 2d 72 75 6e 20 comment-for-run
6600: 64 62 20 72 75 6e 2d 69 64 20 28 61 72 67 73 3a db run-id (args:
6610: 67 65 74 2d 61 72 67 20 22 2d 6d 22 29 29 29 0a get-arg "-m"))).
6620: 0a 09 20 20 3b 3b 20 48 65 72 65 20 69 73 20 77 .. ;; Here is w
6630: 68 65 72 65 20 74 68 65 20 74 65 73 74 5f 6d 65 here the test_me
6640: 74 61 20 74 61 62 6c 65 20 69 73 20 62 65 73 74 ta table is best
6650: 20 75 70 64 61 74 65 64 0a 09 20 20 28 72 75 6e updated.. (run
6660: 73 3a 75 70 64 61 74 65 2d 74 65 73 74 5f 6d 65 s:update-test_me
6670: 74 61 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 20 ta db test-name
6680: 74 65 73 74 2d 63 6f 6e 66 29 0a 0a 09 20 20 3b test-conf)... ;
6690: 3b 20 62 72 61 69 6e 64 65 61 64 20 77 6f 72 6b ; braindead work
66a0: 2d 61 72 6f 75 6e 64 20 66 6f 72 20 70 6f 6f 72 -around for poor
66b0: 6c 79 20 73 70 65 63 69 66 69 65 64 20 61 6c 6c ly specified all
66c0: 69 74 65 6d 73 20 6c 69 73 74 20 42 55 47 21 21 items list BUG!!
66d0: 21 20 46 49 58 4d 45 0a 09 20 20 28 69 66 20 28 ! FIXME.. (if (
66e0: 6e 75 6c 6c 3f 20 61 6c 6c 69 74 65 6d 73 29 28 null? allitems)(
66f0: 73 65 74 21 20 61 6c 6c 69 74 65 6d 73 20 27 28 set! allitems '(
6700: 28 29 29 29 29 0a 09 20 20 28 6c 65 74 20 6c 6f ()))).. (let lo
6710: 6f 70 20 28 28 69 74 65 6d 64 61 74 20 28 63 61 op ((itemdat (ca
6720: 72 20 61 6c 6c 69 74 65 6d 73 29 29 0a 09 09 20 r allitems))...
6730: 20 20 20 20 28 74 61 6c 20 20 20 20 20 28 63 64 (tal (cd
6740: 72 20 61 6c 6c 69 74 65 6d 73 29 29 29 0a 09 20 r allitems)))..
6750: 20 20 20 3b 3b 20 28 6c 61 6d 62 64 61 20 28 69 ;; (lambda (i
6760: 74 65 6d 64 61 74 29 20 3b 3b 3b 20 28 28 72 69 temdat) ;;; ((ri
6770: 70 65 6e 65 73 73 20 22 6f 76 65 72 72 69 70 65 peness "overripe
6780: 22 29 20 28 74 65 6d 70 65 72 61 74 75 72 65 20 ") (temperature
6790: 22 63 6f 6f 6c 22 29 20 28 73 65 61 73 6f 6e 20 "cool") (season
67a0: 22 73 75 6d 6d 65 72 22 29 29 0a 09 20 20 20 20 "summer"))..
67b0: 3b 3b 20 48 61 6e 64 6c 65 20 6c 69 73 74 73 20 ;; Handle lists
67c0: 6f 66 20 69 74 65 6d 73 0a 09 20 20 20 20 28 6c of items.. (l
67d0: 65 74 2a 20 28 28 69 74 65 6d 2d 70 61 74 68 20 et* ((item-path
67e0: 20 20 20 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e (item-list->
67f0: 70 61 74 68 20 69 74 65 6d 64 61 74 29 29 20 3b path itemdat)) ;
6800: 3b 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 ; (string-inters
6810: 70 65 72 73 65 20 28 6d 61 70 20 63 61 64 72 20 perse (map cadr
6820: 69 74 65 6d 64 61 74 29 20 22 2f 22 29 29 0a 09 itemdat) "/"))..
6830: 09 20 20 20 28 6e 65 77 2d 74 65 73 74 2d 70 61 . (new-test-pa
6840: 74 68 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 th (string-inter
6850: 73 70 65 72 73 65 20 28 63 6f 6e 73 20 74 65 73 sperse (cons tes
6860: 74 2d 70 61 74 68 20 28 6d 61 70 20 63 61 64 72 t-path (map cadr
6870: 20 69 74 65 6d 64 61 74 29 29 20 22 2f 22 29 29 itemdat)) "/"))
6880: 0a 09 09 20 20 20 28 6e 65 77 2d 74 65 73 74 2d ... (new-test-
6890: 6e 61 6d 65 20 28 69 66 20 28 65 71 75 61 6c 3f name (if (equal?
68a0: 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29 20 74 item-path "") t
68b0: 65 73 74 2d 6e 61 6d 65 20 28 63 6f 6e 63 20 74 est-name (conc t
68c0: 65 73 74 2d 6e 61 6d 65 20 22 2f 22 20 69 74 65 est-name "/" ite
68d0: 6d 2d 70 61 74 68 29 29 29 20 3b 3b 20 6a 75 73 m-path))) ;; jus
68e0: 74 20 6e 65 65 64 20 69 74 20 74 6f 20 62 65 20 t need it to be
68f0: 75 6e 69 71 75 65 0a 09 09 20 20 20 28 74 65 73 unique... (tes
6900: 74 64 61 74 20 20 20 23 66 29 0a 09 09 20 20 20 tdat #f)...
6910: 28 6e 75 6d 2d 72 75 6e 6e 69 6e 67 20 28 64 62 (num-running (db
6920: 3a 67 65 74 2d 63 6f 75 6e 74 2d 74 65 73 74 73 :get-count-tests
6930: 2d 72 75 6e 6e 69 6e 67 20 64 62 29 29 0a 09 09 -running db))...
6940: 20 20 20 28 6d 61 78 2d 63 6f 6e 63 75 72 72 65 (max-concurre
6950: 6e 74 2d 6a 6f 62 73 20 28 63 6f 6e 66 69 67 2d nt-jobs (config-
6960: 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67 64 61 lookup *configda
6970: 74 2a 20 22 73 65 74 75 70 22 20 22 6d 61 78 5f t* "setup" "max_
6980: 63 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f 62 73 22 concurrent_jobs"
6990: 29 29 0a 09 09 20 20 20 28 70 61 72 65 6e 74 2d ))... (parent-
69a0: 74 65 73 74 20 28 61 6e 64 20 28 6e 6f 74 20 28 test (and (not (
69b0: 6e 75 6c 6c 3f 20 69 74 65 6d 73 29 29 28 65 71 null? items))(eq
69c0: 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 ual? item-path "
69d0: 22 29 29 29 0a 09 09 20 20 20 28 73 69 6e 67 6c ")))... (singl
69e0: 65 2d 74 65 73 74 20 28 61 6e 64 20 28 6e 75 6c e-test (and (nul
69f0: 6c 3f 20 69 74 65 6d 73 29 20 28 65 71 75 61 6c l? items) (equal
6a00: 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29 29 ? item-path ""))
6a10: 29 0a 09 09 20 20 20 28 69 74 65 6d 2d 74 65 73 )... (item-tes
6a20: 74 20 20 20 28 6e 6f 74 20 28 65 71 75 61 6c 3f t (not (equal?
6a30: 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29 29 29 item-path "")))
6a40: 29 0a 09 20 20 20 20 20 20 28 64 65 62 75 67 3a ).. (debug:
6a50: 70 72 69 6e 74 20 33 20 22 6d 61 78 2d 63 6f 6e print 3 "max-con
6a60: 63 75 72 72 65 6e 74 2d 6a 6f 62 73 3a 20 22 20 current-jobs: "
6a70: 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a max-concurrent-j
6a80: 6f 62 73 20 22 2c 20 6e 75 6d 2d 72 75 6e 6e 69 obs ", num-runni
6a90: 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69 6e ng: " num-runnin
6aa0: 67 29 0a 09 20 20 20 20 20 20 28 69 66 20 28 72 g).. (if (r
6ab0: 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65 uns:can-run-more
6ac0: 2d 74 65 73 74 73 20 64 62 29 0a 09 09 20 20 28 -tests db)... (
6ad0: 62 65 67 69 6e 0a 09 09 20 20 20 20 28 6c 65 74 begin... (let
6ae0: 20 6c 6f 6f 70 32 20 28 28 74 73 20 28 64 62 3a loop2 ((ts (db:
6af0: 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 get-test-info db
6b00: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d run-id test-nam
6b10: 65 20 69 74 65 6d 2d 70 61 74 68 29 29 20 3b 3b e item-path)) ;;
6b20: 20 23 66 29 0a 09 09 09 09 28 63 74 20 30 29 29 #f).....(ct 0))
6b30: 0a 09 09 20 20 20 20 20 20 28 69 66 20 28 61 6e ... (if (an
6b40: 64 20 28 6e 6f 74 20 74 73 29 0a 09 09 09 20 20 d (not ts)....
6b50: 20 20 20 20 20 28 3c 20 63 74 20 31 30 29 29 0a (< ct 10)).
6b60: 09 09 09 20 20 28 62 65 67 69 6e 0a 09 09 09 20 ... (begin....
6b70: 20 20 20 28 72 65 67 69 73 74 65 72 2d 74 65 73 (register-tes
6b80: 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 t db run-id test
6b90: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 -name item-path)
6ba0: 0a 09 09 09 20 20 20 20 28 64 62 3a 74 65 73 74 .... (db:test
6bb0: 2d 73 65 74 2d 63 6f 6d 6d 65 6e 74 20 64 62 20 -set-comment db
6bc0: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 run-id test-name
6bd0: 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29 0a 09 item-path "")..
6be0: 09 09 20 20 20 20 28 6c 6f 6f 70 32 20 28 64 62 .. (loop2 (db
6bf0: 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 :get-test-info d
6c00: 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 b run-id test-na
6c10: 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 09 me item-path)...
6c20: 09 09 20 20 20 28 2b 20 63 74 20 31 29 29 29 0a .. (+ ct 1))).
6c30: 09 09 09 20 20 28 69 66 20 74 73 0a 09 09 09 20 ... (if ts....
6c40: 20 20 20 20 20 28 73 65 74 21 20 74 65 73 74 64 (set! testd
6c50: 61 74 20 74 73 29 0a 09 09 09 20 20 20 20 20 20 at ts)....
6c60: 28 62 65 67 69 6e 0a 09 09 09 09 28 64 65 62 75 (begin.....(debu
6c70: 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e 49 g:print 0 "WARNI
6c80: 4e 47 3a 20 43 6f 75 6c 64 6e 27 74 20 72 65 67 NG: Couldn't reg
6c90: 69 73 74 65 72 20 74 65 73 74 20 22 20 74 65 73 ister test " tes
6ca0: 74 2d 6e 61 6d 65 20 22 20 77 69 74 68 20 69 74 t-name " with it
6cb0: 65 6d 20 70 61 74 68 20 22 20 69 74 65 6d 2d 70 em path " item-p
6cc0: 61 74 68 20 22 2c 20 73 6b 69 70 70 69 6e 67 22 ath ", skipping"
6cd0: 29 0a 09 09 09 09 28 69 66 20 28 6e 6f 74 20 28 ).....(if (not (
6ce0: 6e 75 6c 6c 3f 20 74 61 6c 29 29 0a 09 09 09 09 null? tal)).....
6cf0: 20 20 20 20 28 6c 6f 6f 70 20 28 63 61 72 20 74 (loop (car t
6d00: 61 6c 29 28 63 64 72 20 74 61 6c 29 29 29 29 29 al)(cdr tal)))))
6d10: 29 29 0a 09 09 20 20 20 20 28 63 68 61 6e 67 65 ))... (change
6d20: 2d 64 69 72 65 63 74 6f 72 79 20 74 65 73 74 2d -directory test-
6d30: 70 61 74 68 29 0a 09 09 20 20 20 20 3b 3b 20 74 path)... ;; t
6d40: 68 69 73 20 62 6c 6f 63 6b 20 69 73 20 68 65 72 his block is her
6d50: 65 20 6f 6e 6c 79 20 74 6f 20 69 6e 66 6f 72 6d e only to inform
6d60: 20 74 68 65 20 75 73 65 72 20 65 61 72 6c 79 20 the user early
6d70: 6f 6e 0a 09 09 20 20 20 20 28 69 66 20 28 66 69 on... (if (fi
6d80: 6c 65 2d 65 78 69 73 74 73 3f 20 72 75 6e 63 6f le-exists? runco
6d90: 6e 66 69 67 66 29 0a 09 09 09 28 73 65 74 75 70 nfigf)....(setup
6da0: 2d 65 6e 76 2d 64 65 66 61 75 6c 74 73 20 64 62 -env-defaults db
6db0: 20 72 75 6e 63 6f 6e 66 69 67 66 20 72 75 6e 2d runconfigf run-
6dc0: 69 64 20 2a 61 6c 72 65 61 64 79 2d 73 65 65 6e id *already-seen
6dd0: 2d 72 75 6e 63 6f 6e 66 69 67 2d 69 6e 66 6f 2a -runconfig-info*
6de0: 29 0a 09 09 09 28 64 65 62 75 67 3a 70 72 69 6e )....(debug:prin
6df0: 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 59 6f t 0 "WARNING: Yo
6e00: 75 20 64 6f 20 6e 6f 74 20 68 61 76 65 20 61 20 u do not have a
6e10: 72 75 6e 20 63 6f 6e 66 69 67 20 66 69 6c 65 3a run config file:
6e20: 20 22 20 72 75 6e 63 6f 6e 66 69 67 66 29 29 0a " runconfigf)).
6e30: 09 09 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 .. (debug:pri
6e40: 6e 74 20 34 20 22 72 75 6e 2d 69 64 3a 20 22 20 nt 4 "run-id: "
6e50: 72 75 6e 2d 69 64 20 22 20 74 65 73 74 2d 6e 61 run-id " test-na
6e60: 6d 65 3a 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 me: " test-name
6e70: 22 20 69 74 65 6d 2d 70 61 74 68 3a 20 22 20 69 " item-path: " i
6e80: 74 65 6d 2d 70 61 74 68 20 22 20 74 65 73 74 64 tem-path " testd
6e90: 61 74 3a 20 22 20 28 74 65 73 74 3a 67 65 74 2d at: " (test:get-
6ea0: 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29 20 status testdat)
6eb0: 22 20 74 65 73 74 2d 73 74 61 74 65 3a 20 22 20 " test-state: "
6ec0: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 (test:get-state
6ed0: 74 65 73 74 64 61 74 29 29 0a 09 09 20 20 20 20 testdat))...
6ee0: 28 63 61 73 65 20 28 69 66 20 28 61 72 67 73 3a (case (if (args:
6ef0: 67 65 74 2d 61 72 67 20 22 2d 66 6f 72 63 65 22 get-arg "-force"
6f00: 29 0a 09 09 09 20 20 20 20 20 20 27 4e 4f 54 5f ).... 'NOT_
6f10: 53 54 41 52 54 45 44 0a 09 09 09 20 20 20 20 20 STARTED....
6f20: 20 28 69 66 20 74 65 73 74 64 61 74 0a 09 09 09 (if testdat....
6f30: 09 20 20 28 73 74 72 69 6e 67 2d 3e 73 79 6d 62 . (string->symb
6f40: 6f 6c 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 ol (test:get-sta
6f50: 74 65 20 74 65 73 74 64 61 74 29 29 0a 09 09 09 te testdat))....
6f60: 09 20 20 27 66 61 69 6c 65 64 2d 74 6f 2d 69 6e . 'failed-to-in
6f70: 73 65 72 74 29 29 0a 09 09 20 20 20 20 20 20 28 sert))... (
6f80: 28 66 61 69 6c 65 64 2d 74 6f 2d 69 6e 73 65 72 (failed-to-inser
6f90: 74 29 0a 09 09 20 20 20 20 20 20 20 28 64 65 62 t)... (deb
6fa0: 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f ug:print 0 "ERRO
6fb0: 52 3a 20 46 61 69 6c 65 64 20 74 6f 20 69 6e 73 R: Failed to ins
6fc0: 65 72 74 20 74 68 65 20 72 65 63 6f 72 64 20 69 ert the record i
6fd0: 6e 74 6f 20 74 68 65 20 64 62 22 29 29 0a 09 09 nto the db"))...
6fe0: 20 20 20 20 20 20 28 28 4e 4f 54 5f 53 54 41 52 ((NOT_STAR
6ff0: 54 45 44 20 43 4f 4d 50 4c 45 54 45 44 29 0a 09 TED COMPLETED)..
7000: 09 20 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 . (debug:p
7010: 72 69 6e 74 20 36 20 22 47 6f 74 20 68 65 72 65 rint 6 "Got here
7020: 2c 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 , " (test:get-st
7030: 61 74 65 20 74 65 73 74 64 61 74 29 29 0a 09 09 ate testdat))...
7040: 20 20 20 20 20 20 20 28 6c 65 74 20 28 28 72 75 (let ((ru
7050: 6e 66 6c 61 67 20 23 66 29 29 0a 09 09 09 20 28 nflag #f)).... (
7060: 63 6f 6e 64 0a 09 09 09 20 20 3b 3b 20 69 2e 65 cond.... ;; i.e
7070: 2e 20 74 68 69 73 20 69 73 20 74 68 65 20 70 61 . this is the pa
7080: 72 65 6e 74 20 74 65 73 74 20 74 6f 20 61 20 73 rent test to a s
7090: 75 69 74 65 20 6f 66 20 69 74 65 6d 73 2c 20 6e uite of items, n
70a0: 65 76 65 72 20 22 72 75 6e 22 20 69 74 0a 09 09 ever "run" it...
70b0: 09 20 20 28 70 61 72 65 6e 74 2d 74 65 73 74 0a . (parent-test.
70c0: 09 09 09 20 20 20 28 73 65 74 21 20 72 75 6e 66 ... (set! runf
70d0: 6c 61 67 20 23 66 29 29 0a 09 09 09 20 20 3b 3b lag #f)).... ;;
70e0: 20 2d 66 6f 72 63 65 2c 20 72 75 6e 20 6e 6f 20 -force, run no
70f0: 6d 61 74 74 65 72 20 77 68 61 74 0a 09 09 09 20 matter what....
7100: 20 28 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 ((args:get-arg
7110: 22 2d 66 6f 72 63 65 22 29 28 73 65 74 21 20 72 "-force")(set! r
7120: 75 6e 66 6c 61 67 20 23 74 29 29 0a 09 09 09 20 unflag #t))....
7130: 20 3b 3b 20 4e 4f 54 5f 53 54 41 52 54 45 44 2c ;; NOT_STARTED,
7140: 20 72 75 6e 20 6e 6f 20 6d 61 74 74 65 72 20 77 run no matter w
7150: 68 61 74 0a 09 09 09 20 20 28 28 65 71 75 61 6c hat.... ((equal
7160: 3f 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 ? (test:get-stat
7170: 65 20 74 65 73 74 64 61 74 29 20 22 4e 4f 54 5f e testdat) "NOT_
7180: 53 54 41 52 54 45 44 22 29 28 73 65 74 21 20 72 STARTED")(set! r
7190: 75 6e 66 6c 61 67 20 23 74 29 29 0a 09 09 09 20 unflag #t))....
71a0: 20 3b 3b 20 6e 6f 74 20 2d 72 65 72 75 6e 20 61 ;; not -rerun a
71b0: 6e 64 20 50 41 53 53 2c 20 57 41 52 4e 20 6f 72 nd PASS, WARN or
71c0: 20 43 48 45 43 4b 2c 20 64 6f 20 6e 6f 20 72 75 CHECK, do no ru
71d0: 6e 0a 09 09 09 20 20 28 28 61 6e 64 20 28 6f 72 n.... ((and (or
71e0: 20 28 6e 6f 74 20 28 61 72 67 73 3a 67 65 74 2d (not (args:get-
71f0: 61 72 67 20 22 2d 72 65 72 75 6e 22 29 29 0a 09 arg "-rerun"))..
7200: 09 09 09 20 20 20 20 28 61 72 67 73 3a 67 65 74 ... (args:get
7210: 2d 61 72 67 20 22 2d 6b 65 65 70 67 6f 69 6e 67 -arg "-keepgoing
7220: 22 29 29 0a 09 09 09 09 28 6d 65 6d 62 65 72 20 ")).....(member
7230: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 (test:get-status
7240: 20 74 65 73 74 64 61 74 29 20 27 28 22 50 41 53 testdat) '("PAS
7250: 53 22 20 22 57 41 52 4e 22 20 22 43 48 45 43 4b S" "WARN" "CHECK
7260: 22 29 29 29 0a 09 09 09 20 20 20 28 73 65 74 21 "))).... (set!
7270: 20 72 75 6e 66 6c 61 67 20 23 66 29 29 0a 09 09 runflag #f))...
7280: 09 20 20 3b 3b 20 2d 72 65 72 75 6e 20 61 6e 64 . ;; -rerun and
7290: 20 73 74 61 74 75 73 20 69 73 20 6f 6e 65 20 6f status is one o
72a0: 66 20 74 68 65 20 73 70 65 63 69 66 65 64 2c 20 f the specifed,
72b0: 72 75 6e 20 69 74 0a 09 09 09 20 20 28 28 61 6e run it.... ((an
72c0: 64 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 d (args:get-arg
72d0: 22 2d 72 65 72 75 6e 22 29 0a 09 09 09 09 28 6c "-rerun").....(l
72e0: 65 74 20 28 28 72 65 72 75 6e 6c 73 74 20 28 73 et ((rerunlst (s
72f0: 74 72 69 6e 67 2d 73 70 6c 69 74 20 28 61 72 67 tring-split (arg
7300: 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65 72 75 s:get-arg "-reru
7310: 6e 22 29 20 22 2c 22 29 29 29 20 3b 3b 20 46 41 n") ","))) ;; FA
7320: 49 4c 2c 0a 09 09 09 09 20 20 28 6d 65 6d 62 65 IL,..... (membe
7330: 72 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 r (test:get-stat
7340: 75 73 20 74 65 73 74 64 61 74 29 20 72 65 72 75 us testdat) reru
7350: 6e 6c 73 74 29 29 29 0a 09 09 09 20 20 20 28 73 nlst))).... (s
7360: 65 74 21 20 72 75 6e 66 6c 61 67 20 23 74 29 29 et! runflag #t))
7370: 0a 09 09 09 20 20 3b 3b 20 2d 6b 65 65 70 67 6f .... ;; -keepgo
7380: 69 6e 67 2c 20 64 6f 20 6e 6f 74 20 72 65 72 75 ing, do not reru
7390: 6e 20 46 41 49 4c 0a 09 09 09 20 20 28 28 61 6e n FAIL.... ((an
73a0: 64 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 d (args:get-arg
73b0: 22 2d 6b 65 65 70 67 6f 69 6e 67 22 29 0a 09 09 "-keepgoing")...
73c0: 09 09 28 6d 65 6d 62 65 72 20 28 74 65 73 74 3a ..(member (test:
73d0: 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 get-status testd
73e0: 61 74 29 20 27 28 22 46 41 49 4c 22 29 29 29 0a at) '("FAIL"))).
73f0: 09 09 09 20 20 20 28 73 65 74 21 20 72 75 6e 66 ... (set! runf
7400: 6c 61 67 20 23 66 29 29 0a 09 09 09 20 20 28 28 lag #f)).... ((
7410: 61 6e 64 20 28 6e 6f 74 20 28 61 72 67 73 3a 67 and (not (args:g
7420: 65 74 2d 61 72 67 20 22 2d 72 65 72 75 6e 22 29 et-arg "-rerun")
7430: 29 0a 09 09 09 09 28 6d 65 6d 62 65 72 20 28 74 ).....(member (t
7440: 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 est:get-status t
7450: 65 73 74 64 61 74 29 20 27 28 22 46 41 49 4c 22 estdat) '("FAIL"
7460: 20 22 6e 2f 61 22 29 29 29 0a 09 09 09 20 20 20 "n/a")))....
7470: 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 74 (set! runflag #t
7480: 29 29 0a 09 09 09 20 20 28 65 6c 73 65 20 28 73 )).... (else (s
7490: 65 74 21 20 72 75 6e 66 6c 61 67 20 23 66 29 29 et! runflag #f))
74a0: 29 0a 09 09 09 20 28 64 65 62 75 67 3a 70 72 69 ).... (debug:pri
74b0: 6e 74 20 36 20 22 52 55 4e 4e 49 4e 47 20 3d 3e nt 6 "RUNNING =>
74c0: 20 72 75 6e 66 6c 61 67 3a 20 22 20 72 75 6e 66 runflag: " runf
74d0: 6c 61 67 20 22 20 53 54 41 54 45 3a 20 22 20 28 lag " STATE: " (
74e0: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74 test:get-state t
74f0: 65 73 74 64 61 74 29 20 22 20 53 54 41 54 55 53 estdat) " STATUS
7500: 3a 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 : " (test:get-st
7510: 61 74 75 73 20 74 65 73 74 64 61 74 29 29 0a 09 atus testdat))..
7520: 09 09 20 28 69 66 20 28 6e 6f 74 20 72 75 6e 66 .. (if (not runf
7530: 6c 61 67 29 0a 09 09 09 20 20 20 20 20 28 69 66 lag).... (if
7540: 20 28 6e 6f 74 20 70 61 72 65 6e 74 2d 74 65 73 (not parent-tes
7550: 74 29 0a 09 09 09 09 20 28 64 65 62 75 67 3a 70 t)..... (debug:p
7560: 72 69 6e 74 20 31 20 22 4e 4f 54 45 3a 20 4e 6f rint 1 "NOTE: No
7570: 74 20 73 74 61 72 74 69 6e 67 20 74 65 73 74 20 t starting test
7580: 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20 " new-test-name
7590: 22 20 61 73 20 69 74 20 69 73 20 73 74 61 74 65 " as it is state
75a0: 20 5c 22 43 4f 4d 50 4c 45 54 45 44 5c 22 20 61 \"COMPLETED\" a
75b0: 6e 64 20 73 74 61 74 75 73 20 5c 22 22 20 28 74 nd status \"" (t
75c0: 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 est:get-status t
75d0: 65 73 74 64 61 74 29 20 22 5c 22 2c 20 75 73 65 estdat) "\", use
75e0: 20 2d 66 6f 72 63 65 20 74 6f 20 6f 76 65 72 72 -force to overr
75f0: 69 64 65 22 29 29 0a 09 09 09 20 20 20 20 20 28 ide")).... (
7600: 6c 65 74 2a 20 28 28 67 65 74 2d 70 72 65 72 65 let* ((get-prere
7610: 71 73 2d 63 6d 64 20 28 6c 61 6d 62 64 61 20 28 qs-cmd (lambda (
7620: 29 0a 09 09 09 09 09 09 20 20 20 20 20 20 20 28 )....... (
7630: 64 62 2d 67 65 74 2d 70 72 65 72 65 71 73 2d 6e db-get-prereqs-n
7640: 6f 74 2d 6d 65 74 20 64 62 20 72 75 6e 2d 69 64 ot-met db run-id
7650: 20 77 61 69 74 6f 6e 29 29 29 20 3b 3b 20 63 68 waiton))) ;; ch
7660: 65 63 6b 20 62 65 66 6f 72 65 20 72 75 6e 6e 69 eck before runni
7670: 6e 67 20 2e 2e 2e 2e 0a 09 09 09 09 20 20 20 20 ng .........
7680: 28 6c 61 75 6e 63 68 2d 63 6d 64 20 20 20 20 20 (launch-cmd
7690: 20 28 6c 61 6d 62 64 61 20 28 29 0a 09 09 09 09 (lambda ().....
76a0: 09 09 20 20 20 20 20 20 20 28 6c 61 75 6e 63 68 .. (launch
76b0: 2d 74 65 73 74 20 64 62 20 72 75 6e 2d 69 64 20 -test db run-id
76c0: 74 65 73 74 2d 63 6f 6e 66 20 6b 65 79 76 61 6c test-conf keyval
76d0: 6c 73 74 20 74 65 73 74 2d 6e 61 6d 65 20 74 65 lst test-name te
76e0: 73 74 2d 70 61 74 68 20 69 74 65 6d 64 61 74 29 st-path itemdat)
76f0: 29 29 0a 09 09 09 09 20 20 20 20 28 74 65 73 74 ))..... (test
7700: 72 75 6e 64 61 74 20 20 20 20 20 20 28 6c 69 73 rundat (lis
7710: 74 20 67 65 74 2d 70 72 65 72 65 71 73 2d 63 6d t get-prereqs-cm
7720: 64 20 6c 61 75 6e 63 68 2d 63 6d 64 29 29 29 0a d launch-cmd))).
7730: 09 09 09 20 20 20 20 20 20 20 28 69 66 20 28 6f ... (if (o
7740: 72 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 r (args:get-arg
7750: 22 2d 66 6f 72 63 65 22 29 0a 09 09 09 09 20 20 "-force").....
7760: 20 20 20 20 20 28 6c 65 74 20 28 28 70 72 65 71 (let ((preq
7770: 73 2d 6e 6f 74 2d 79 65 74 2d 6d 65 74 20 28 28 s-not-yet-met ((
7780: 63 61 72 20 74 65 73 74 72 75 6e 64 61 74 29 29 car testrundat))
7790: 29 29 0a 09 09 09 09 09 20 28 64 65 62 75 67 3a ))...... (debug:
77a0: 70 72 69 6e 74 20 32 20 22 50 72 65 71 72 65 71 print 2 "Preqreq
77b0: 75 65 73 69 74 65 73 20 66 6f 72 20 22 20 74 65 uesites for " te
77c0: 73 74 2d 6e 61 6d 65 20 22 3a 20 22 20 70 72 65 st-name ": " pre
77d0: 71 73 2d 6e 6f 74 2d 79 65 74 2d 6d 65 74 29 0a qs-not-yet-met).
77e0: 09 09 09 09 09 20 28 6e 75 6c 6c 3f 20 70 72 65 ..... (null? pre
77f0: 71 73 2d 6e 6f 74 2d 79 65 74 2d 6d 65 74 29 29 qs-not-yet-met))
7800: 29 20 3b 3b 20 61 72 65 20 74 68 65 72 65 20 61 ) ;; are there a
7810: 6e 79 20 74 65 73 74 73 20 74 68 61 74 20 6d 75 ny tests that mu
7820: 73 74 20 62 65 20 72 75 6e 20 62 65 66 6f 72 65 st be run before
7830: 20 74 68 69 73 20 6f 6e 65 2e 2e 2e 0a 09 09 09 this one.......
7840: 09 20 20 20 28 69 66 20 28 6e 6f 74 20 28 28 63 . (if (not ((c
7850: 61 64 72 20 74 65 73 74 72 75 6e 64 61 74 29 29 adr testrundat))
7860: 29 20 3b 3b 20 74 68 69 73 20 69 73 20 74 68 65 ) ;; this is the
7870: 20 6c 69 6e 65 20 74 68 61 74 20 6c 61 75 6e 63 line that launc
7880: 68 65 73 20 74 68 65 20 74 65 73 74 20 74 6f 20 hes the test to
7890: 74 68 65 20 72 65 6d 6f 74 65 20 68 6f 73 74 0a the remote host.
78a0: 09 09 09 09 20 20 20 20 20 20 20 28 62 65 67 69 .... (begi
78b0: 6e 0a 09 09 09 09 09 20 28 70 72 69 6e 74 20 22 n...... (print "
78c0: 45 52 52 4f 52 3a 20 46 61 69 6c 65 64 20 74 6f ERROR: Failed to
78d0: 20 6c 61 75 6e 63 68 20 74 68 65 20 74 65 73 74 launch the test
78e0: 2e 20 45 78 69 74 69 6e 67 20 61 73 20 73 6f 6f . Exiting as soo
78f0: 6e 20 61 73 20 70 6f 73 73 69 62 6c 65 22 29 0a n as possible").
7900: 09 09 09 09 09 20 28 73 65 74 21 20 2a 67 6c 6f ..... (set! *glo
7910: 62 61 6c 65 78 69 74 73 74 61 74 75 73 2a 20 31 balexitstatus* 1
7920: 29 20 3b 3b 20 0a 09 09 09 09 09 20 28 70 72 6f ) ;; ...... (pro
7930: 63 65 73 73 2d 73 69 67 6e 61 6c 20 28 63 75 72 cess-signal (cur
7940: 72 65 6e 74 2d 70 72 6f 63 65 73 73 2d 69 64 29 rent-process-id)
7950: 20 73 69 67 6e 61 6c 2f 6b 69 6c 6c 29 0a 09 09 signal/kill)...
7960: 09 09 09 20 3b 28 65 78 69 74 20 31 29 0a 09 09 ... ;(exit 1)...
7970: 09 09 09 20 29 29 0a 09 09 09 09 20 20 20 28 69 ... ))..... (i
7980: 66 20 28 6e 6f 74 20 28 61 72 67 73 3a 67 65 74 f (not (args:get
7990: 2d 61 72 67 20 22 2d 6b 65 65 70 67 6f 69 6e 67 -arg "-keepgoing
79a0: 22 29 29 0a 09 09 09 09 20 20 20 20 20 20 20 28 "))..... (
79b0: 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74 21 20 hash-table-set!
79c0: 2a 77 61 69 74 69 6e 67 2d 71 75 65 75 65 2a 20 *waiting-queue*
79d0: 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20 74 65 new-test-name te
79e0: 73 74 72 75 6e 64 61 74 29 29 29 29 29 29 29 0a strundat))))))).
79f0: 09 09 20 20 20 20 20 20 28 28 4b 49 4c 4c 45 44 .. ((KILLED
7a00: 29 20 0a 09 09 20 20 20 20 20 20 20 28 64 65 62 ) ... (deb
7a10: 75 67 3a 70 72 69 6e 74 20 31 20 22 4e 4f 54 45 ug:print 1 "NOTE
7a20: 3a 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d : " new-test-nam
7a30: 65 20 22 20 69 73 20 61 6c 72 65 61 64 79 20 72 e " is already r
7a40: 75 6e 6e 69 6e 67 20 6f 72 20 77 61 73 20 65 78 unning or was ex
7a50: 70 6c 69 63 74 6c 79 20 6b 69 6c 6c 65 64 2c 20 plictly killed,
7a60: 75 73 65 20 2d 66 6f 72 63 65 20 74 6f 20 6c 61 use -force to la
7a70: 75 6e 63 68 20 69 74 2e 22 29 29 0a 09 09 20 20 unch it."))...
7a80: 20 20 20 20 28 28 4c 41 55 4e 43 48 45 44 20 52 ((LAUNCHED R
7a90: 45 4d 4f 54 45 48 4f 53 54 53 54 41 52 54 20 52 EMOTEHOSTSTART R
7aa0: 55 4e 4e 49 4e 47 29 20 20 0a 09 09 20 20 20 20 UNNING) ...
7ab0: 20 20 20 28 69 66 20 28 3e 20 28 2d 20 28 63 75 (if (> (- (cu
7ac0: 72 72 65 6e 74 2d 73 65 63 6f 6e 64 73 29 28 2b rrent-seconds)(+
7ad0: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 65 76 (db:test-get-ev
7ae0: 65 6e 74 5f 74 69 6d 65 20 74 65 73 74 64 61 74 ent_time testdat
7af0: 29 0a 09 09 09 09 09 09 20 20 20 20 20 28 64 62 )....... (db
7b00: 3a 74 65 73 74 2d 67 65 74 2d 72 75 6e 5f 64 75 :test-get-run_du
7b10: 72 61 74 69 6f 6e 20 74 65 73 74 64 61 74 29 29 ration testdat))
7b20: 29 0a 09 09 09 20 20 20 20 20 20 31 30 30 29 20 ).... 100)
7b30: 3b 3b 20 69 2e 65 2e 20 6e 6f 20 75 70 64 61 74 ;; i.e. no updat
7b40: 65 20 66 6f 72 20 6d 6f 72 65 20 74 68 61 6e 20 e for more than
7b50: 31 30 30 20 73 65 63 6f 6e 64 73 0a 09 09 09 20 100 seconds....
7b60: 20 20 28 62 65 67 69 6e 0a 09 09 09 20 20 20 20 (begin....
7b70: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 (debug:print 0
7b80: 22 57 41 52 4e 49 4e 47 3a 20 54 65 73 74 20 22 "WARNING: Test "
7b90: 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 61 70 70 test-name " app
7ba0: 65 61 72 73 20 74 6f 20 62 65 20 64 65 61 64 2e ears to be dead.
7bb0: 20 46 6f 72 63 69 6e 67 20 69 74 20 74 6f 20 73 Forcing it to s
7bc0: 74 61 74 65 20 49 4e 43 4f 4d 50 4c 45 54 45 20 tate INCOMPLETE
7bd0: 61 6e 64 20 73 74 61 74 75 73 20 53 54 55 43 4b and status STUCK
7be0: 2f 44 45 41 44 22 29 0a 09 09 09 20 20 20 20 20 /DEAD")....
7bf0: 28 74 65 73 74 2d 73 65 74 2d 73 74 61 74 75 73 (test-set-status
7c00: 21 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 ! db run-id test
7c10: 2d 6e 61 6d 65 20 22 49 4e 43 4f 4d 50 4c 45 54 -name "INCOMPLET
7c20: 45 22 20 22 53 54 55 43 4b 2f 44 45 41 44 22 20 E" "STUCK/DEAD"
7c30: 69 74 65 6d 64 61 74 20 22 54 65 73 74 20 69 73 itemdat "Test is
7c40: 20 73 74 75 63 6b 20 6f 72 20 64 65 61 64 22 20 stuck or dead"
7c50: 23 66 29 29 0a 09 09 09 20 20 20 28 64 65 62 75 #f)).... (debu
7c60: 67 3a 70 72 69 6e 74 20 32 20 22 4e 4f 54 45 3a g:print 2 "NOTE:
7c70: 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 69 " test-name " i
7c80: 73 20 61 6c 72 65 61 64 79 20 72 75 6e 6e 69 6e s already runnin
7c90: 67 22 29 29 29 0a 09 09 20 20 20 20 20 20 28 65 g")))... (e
7ca0: 6c 73 65 20 20 20 20 20 20 20 28 64 65 62 75 67 lse (debug
7cb0: 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a :print 0 "ERROR:
7cc0: 20 46 61 69 6c 65 64 20 74 6f 20 6c 61 75 6e 63 Failed to launc
7cd0: 68 20 74 65 73 74 20 22 20 6e 65 77 2d 74 65 73 h test " new-tes
7ce0: 74 2d 6e 61 6d 65 20 22 2e 20 55 6e 72 65 63 6f t-name ". Unreco
7cf0: 67 6e 69 73 65 64 20 73 74 61 74 65 20 22 20 28 gnised state " (
7d00: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74 test:get-state t
7d10: 65 73 74 64 61 74 29 29 29 29 29 29 0a 09 20 20 estdat))))))..
7d20: 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28 6e 75 (if (not (nu
7d30: 6c 6c 3f 20 74 61 6c 29 29 0a 09 09 20 20 28 6c ll? tal))... (l
7d40: 6f 6f 70 20 28 63 61 72 20 74 61 6c 29 28 63 64 oop (car tal)(cd
7d50: 72 20 74 61 6c 29 29 29 29 29 29 29 29 29 0a 0a r tal)))))))))..
7d60: 28 64 65 66 69 6e 65 20 28 72 75 6e 2d 77 61 69 (define (run-wai
7d70: 74 69 6e 67 2d 74 65 73 74 73 20 64 62 29 0a 20 ting-tests db).
7d80: 20 28 6c 65 74 20 28 28 6e 75 6d 74 72 69 65 73 (let ((numtries
7d90: 20 20 20 20 20 20 20 20 20 20 20 30 29 0a 09 28 0)..(
7da0: 6c 61 73 74 2d 74 72 79 2d 74 69 6d 65 20 20 20 last-try-time
7db0: 20 20 20 28 63 75 72 72 65 6e 74 2d 73 65 63 6f (current-seco
7dc0: 6e 64 73 29 29 0a 09 28 74 69 6d 65 73 20 20 20 nds))..(times
7dd0: 20 20 20 20 20 20 20 20 20 20 20 28 6c 69 73 74 (list
7de0: 20 31 29 29 29 20 3b 3b 20 6d 69 6e 75 74 65 73 1))) ;; minutes
7df0: 20 74 6f 20 77 61 69 74 20 62 65 66 6f 72 65 20 to wait before
7e00: 74 72 79 69 6e 67 20 61 67 61 69 6e 20 74 6f 20 trying again to
7e10: 6b 69 63 6b 20 6f 66 66 20 72 75 6e 73 0a 20 20 kick off runs.
7e20: 20 20 3b 3b 20 42 55 47 20 74 68 69 73 20 68 61 ;; BUG this ha
7e30: 63 6b 20 6f 66 20 62 72 75 74 65 20 66 6f 72 63 ck of brute forc
7e40: 65 20 72 65 74 72 79 69 6e 67 20 77 6f 72 6b 73 e retrying works
7e50: 20 71 75 69 74 65 20 77 65 6c 6c 20 66 6f 72 20 quite well for
7e60: 6d 61 6e 79 20 63 61 73 65 73 20 62 75 74 20 0a many cases but .
7e70: 20 20 20 20 3b 3b 20 20 20 20 20 77 68 61 74 20 ;; what
7e80: 69 73 20 6e 65 65 64 65 64 20 69 73 20 74 6f 20 is needed is to
7e90: 63 68 65 63 6b 20 74 68 65 20 64 62 20 66 6f 72 check the db for
7ea0: 20 74 65 73 74 73 20 74 68 61 74 20 68 61 76 65 tests that have
7eb0: 20 66 61 69 6c 65 64 20 6c 65 73 73 20 74 68 61 failed less tha
7ec0: 6e 0a 20 20 20 20 3b 3b 20 20 20 20 20 4e 20 74 n. ;; N t
7ed0: 69 6d 65 73 20 6f 72 20 6e 65 76 65 72 20 62 65 imes or never be
7ee0: 65 6e 20 73 74 61 72 74 65 64 20 61 6e 64 20 6b en started and k
7ef0: 69 63 6b 20 74 68 65 6d 20 6f 66 66 20 61 67 61 ick them off aga
7f00: 69 6e 0a 20 20 20 20 28 6c 65 74 20 6c 6f 6f 70 in. (let loop
7f10: 20 28 28 77 61 69 74 69 6e 67 2d 74 65 73 74 2d ((waiting-test-
7f20: 6e 61 6d 65 73 20 28 68 61 73 68 2d 74 61 62 6c names (hash-tabl
7f30: 65 2d 6b 65 79 73 20 2a 77 61 69 74 69 6e 67 2d e-keys *waiting-
7f40: 71 75 65 75 65 2a 29 29 29 0a 20 20 20 20 20 20 queue*))).
7f50: 28 63 6f 6e 64 0a 20 20 20 20 20 20 20 28 28 6e (cond. ((n
7f60: 6f 74 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e ot (runs:can-run
7f70: 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64 62 29 29 -more-tests db))
7f80: 0a 09 28 73 6c 65 65 70 20 32 29 0a 09 28 6c 6f ..(sleep 2)..(lo
7f90: 6f 70 20 77 61 69 74 69 6e 67 2d 74 65 73 74 2d op waiting-test-
7fa0: 6e 61 6d 65 73 29 29 0a 20 20 20 20 20 20 20 28 names)). (
7fb0: 28 6e 75 6c 6c 3f 20 77 61 69 74 69 6e 67 2d 74 (null? waiting-t
7fc0: 65 73 74 2d 6e 61 6d 65 73 29 0a 09 28 64 65 62 est-names)..(deb
7fd0: 75 67 3a 70 72 69 6e 74 20 31 20 22 41 6c 6c 20 ug:print 1 "All
7fe0: 74 65 73 74 73 20 6c 61 75 6e 63 68 65 64 22 29 tests launched")
7ff0: 29 0a 20 20 20 20 20 20 20 28 65 6c 73 65 0a 09 ). (else..
8000: 28 73 65 74 21 20 6e 75 6d 74 72 69 65 73 20 28 (set! numtries (
8010: 2b 20 6e 75 6d 74 72 69 65 73 20 31 29 29 0a 09 + numtries 1))..
8020: 28 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 (for-each (lambd
8030: 61 20 28 74 65 73 74 6e 61 6d 65 29 0a 09 09 20 a (testname)...
8040: 20 20 20 28 69 66 20 28 72 75 6e 73 3a 63 61 6e (if (runs:can
8050: 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20 -run-more-tests
8060: 64 62 29 0a 09 09 09 28 6c 65 74 2a 20 28 28 74 db)....(let* ((t
8070: 65 73 74 64 61 74 20 28 68 61 73 68 2d 74 61 62 estdat (hash-tab
8080: 6c 65 2d 72 65 66 20 2a 77 61 69 74 69 6e 67 2d le-ref *waiting-
8090: 71 75 65 75 65 2a 20 74 65 73 74 6e 61 6d 65 29 queue* testname)
80a0: 29 0a 09 09 09 20 20 20 20 20 20 20 28 70 72 65 ).... (pre
80b0: 72 65 71 73 20 28 28 63 61 72 20 74 65 73 74 64 reqs ((car testd
80c0: 61 74 29 29 29 0a 09 09 09 20 20 20 20 20 20 20 at)))....
80d0: 28 6c 64 62 20 20 20 20 20 28 69 66 20 64 62 20 (ldb (if db
80e0: 64 62 20 28 6f 70 65 6e 2d 64 62 29 29 29 29 0a db (open-db)))).
80f0: 09 09 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e ... (debug:prin
8100: 74 20 32 20 22 70 72 65 72 65 71 73 20 72 65 6d t 2 "prereqs rem
8110: 61 69 6e 69 6e 67 3a 20 22 20 70 72 65 72 65 71 aining: " prereq
8120: 73 29 0a 09 09 09 20 20 28 69 66 20 28 6e 75 6c s).... (if (nul
8130: 6c 3f 20 70 72 65 72 65 71 73 29 0a 09 09 09 20 l? prereqs)....
8140: 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09 09 09 (begin.....
8150: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 (debug:print 2 "
8160: 50 72 65 72 65 71 75 69 73 69 74 65 73 20 6d 65 Prerequisites me
8170: 74 2c 20 6c 61 75 6e 63 68 69 6e 67 20 22 20 74 t, launching " t
8180: 65 73 74 6e 61 6d 65 29 0a 09 09 09 09 28 28 63 estname).....((c
8190: 61 64 72 20 74 65 73 74 64 61 74 29 29 0a 09 09 adr testdat))...
81a0: 09 09 28 68 61 73 68 2d 74 61 62 6c 65 2d 64 65 ..(hash-table-de
81b0: 6c 65 74 65 21 20 2a 77 61 69 74 69 6e 67 2d 71 lete! *waiting-q
81c0: 75 65 75 65 2a 20 74 65 73 74 6e 61 6d 65 29 29 ueue* testname))
81d0: 29 0a 09 09 09 20 20 28 69 66 20 28 6e 6f 74 20 ).... (if (not
81e0: 64 62 29 0a 09 09 09 20 20 20 20 20 20 28 73 71 db).... (sq
81f0: 6c 69 74 65 33 3a 66 69 6e 61 6c 69 7a 65 21 20 lite3:finalize!
8200: 6c 64 62 29 29 29 29 29 0a 09 09 20 20 77 61 69 ldb)))))... wai
8210: 74 69 6e 67 2d 74 65 73 74 2d 6e 61 6d 65 73 29 ting-test-names)
8220: 0a 09 3b 3b 20 28 73 6c 65 65 70 20 31 30 29 20 ..;; (sleep 10)
8230: 3b 3b 20 6e 6f 20 70 6f 69 6e 74 20 69 6e 20 72 ;; no point in r
8240: 75 73 68 69 6e 67 20 74 68 69 6e 67 73 20 61 74 ushing things at
8250: 20 74 68 69 73 20 73 74 61 67 65 3f 0a 09 28 6c this stage?..(l
8260: 6f 6f 70 20 28 68 61 73 68 2d 74 61 62 6c 65 2d oop (hash-table-
8270: 6b 65 79 73 20 2a 77 61 69 74 69 6e 67 2d 71 75 keys *waiting-qu
8280: 65 75 65 2a 29 29 29 29 29 29 29 0a 0a 28 64 65 eue*)))))))..(de
8290: 66 69 6e 65 20 28 67 65 74 2d 64 69 72 2d 75 70 fine (get-dir-up
82a0: 2d 6e 20 64 69 72 20 2e 20 70 61 72 61 6d 73 29 -n dir . params)
82b0: 20 0a 20 20 28 6c 65 74 20 28 28 64 70 61 72 74 . (let ((dpart
82c0: 73 20 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 s (string-split
82d0: 20 64 69 72 20 22 2f 22 29 29 0a 09 28 63 6f 75 dir "/"))..(cou
82e0: 6e 74 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 nt (if (null?
82f0: 70 61 72 61 6d 73 29 20 31 20 28 63 61 72 20 70 params) 1 (car p
8300: 61 72 61 6d 73 29 29 29 29 0a 20 20 20 20 28 63 arams)))). (c
8310: 6f 6e 63 20 22 2f 22 20 28 73 74 72 69 6e 67 2d onc "/" (string-
8320: 69 6e 74 65 72 73 70 65 72 73 65 20 0a 09 20 20 intersperse ..
8330: 20 20 20 20 20 28 74 61 6b 65 20 64 70 61 72 74 (take dpart
8340: 73 20 28 2d 20 28 6c 65 6e 67 74 68 20 64 70 61 s (- (length dpa
8350: 72 74 73 29 20 63 6f 75 6e 74 29 29 0a 09 20 20 rts) count))..
8360: 20 20 20 20 20 22 2f 22 29 29 29 29 0a 3b 3b 20 "/")))).;;
8370: 52 65 6d 6f 76 65 20 72 75 6e 73 0a 3b 3b 20 66 Remove runs.;; f
8380: 69 65 6c 64 73 20 61 72 65 20 70 61 73 73 69 6e ields are passin
8390: 67 20 69 6e 20 74 68 72 6f 75 67 68 20 0a 28 64 g in through .(d
83a0: 65 66 69 6e 65 20 28 72 75 6e 73 3a 72 65 6d 6f efine (runs:remo
83b0: 76 65 2d 72 75 6e 73 20 64 62 20 72 75 6e 6e 61 ve-runs db runna
83c0: 6d 65 70 61 74 74 20 74 65 73 74 70 61 74 74 20 mepatt testpatt
83d0: 69 74 65 6d 70 61 74 74 29 0a 20 20 28 6c 65 74 itempatt). (let
83e0: 2a 20 28 28 6b 65 79 73 20 20 20 20 20 20 20 20 * ((keys
83f0: 28 64 62 2d 67 65 74 2d 6b 65 79 73 20 64 62 29 (db-get-keys db)
8400: 29 0a 09 20 28 72 75 6e 64 61 74 20 20 20 20 20 ).. (rundat
8410: 20 28 72 75 6e 73 3a 67 65 74 2d 72 75 6e 73 2d (runs:get-runs-
8420: 62 79 2d 70 61 74 74 20 64 62 20 6b 65 79 73 20 by-patt db keys
8430: 72 75 6e 6e 61 6d 65 70 61 74 74 29 29 0a 09 20 runnamepatt))..
8440: 28 68 65 61 64 65 72 20 20 20 20 20 20 28 76 65 (header (ve
8450: 63 74 6f 72 2d 72 65 66 20 72 75 6e 64 61 74 20 ctor-ref rundat
8460: 30 29 29 0a 09 20 28 72 75 6e 73 20 20 20 20 20 0)).. (runs
8470: 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20 72 (vector-ref r
8480: 75 6e 64 61 74 20 31 29 29 29 0a 20 20 20 20 28 undat 1))). (
8490: 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 48 debug:print 1 "H
84a0: 65 61 64 65 72 3a 20 22 20 68 65 61 64 65 72 29 eader: " header)
84b0: 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 0a 20 . (for-each.
84c0: 20 20 20 20 28 6c 61 6d 62 64 61 20 28 72 75 6e (lambda (run
84d0: 29 0a 20 20 20 20 20 20 20 28 6c 65 74 20 28 28 ). (let ((
84e0: 72 75 6e 6b 65 79 20 28 73 74 72 69 6e 67 2d 69 runkey (string-i
84f0: 6e 74 65 72 73 70 65 72 73 65 20 28 6d 61 70 20 ntersperse (map
8500: 28 6c 61 6d 62 64 61 20 28 6b 29 0a 09 09 09 09 (lambda (k).....
8510: 09 09 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d ..(db:get-value-
8520: 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 by-header run he
8530: 61 64 65 72 20 28 76 65 63 74 6f 72 2d 72 65 66 ader (vector-ref
8540: 20 6b 20 30 29 29 29 20 6b 65 79 73 29 20 22 2f k 0))) keys) "/
8550: 22 29 29 0a 09 20 20 20 20 20 28 64 69 72 73 2d ")).. (dirs-
8560: 74 6f 2d 72 65 6d 6f 76 65 20 28 6d 61 6b 65 2d to-remove (make-
8570: 68 61 73 68 2d 74 61 62 6c 65 29 29 29 0a 09 20 hash-table)))..
8580: 28 6c 65 74 2a 20 28 28 72 75 6e 2d 69 64 20 28 (let* ((run-id (
8590: 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d db:get-value-by-
85a0: 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65 header run heade
85b0: 72 20 22 69 64 22 29 20 29 0a 09 09 28 74 65 73 r "id") )...(tes
85c0: 74 73 20 20 28 64 62 2d 67 65 74 2d 74 65 73 74 ts (db-get-test
85d0: 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 28 64 62 s-for-run db (db
85e0: 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 :get-value-by-he
85f0: 61 64 65 72 20 72 75 6e 20 68 65 61 64 65 72 20 ader run header
8600: 22 69 64 22 29 20 74 65 73 74 70 61 74 74 20 69 "id") testpatt i
8610: 74 65 6d 70 61 74 74 29 29 0a 09 09 28 6c 61 73 tempatt))...(las
8620: 74 74 70 61 74 68 20 22 2f 64 6f 65 73 2f 6e 6f ttpath "/does/no
8630: 74 2f 65 78 69 73 74 2f 49 2f 68 6f 70 65 22 29 t/exist/I/hope")
8640: 29 0a 0a 09 20 20 20 28 69 66 20 28 6e 6f 74 20 )... (if (not
8650: 28 6e 75 6c 6c 3f 20 74 65 73 74 73 29 29 0a 09 (null? tests))..
8660: 20 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09 (begin...
8670: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 (debug:print 1
8680: 22 52 65 6d 6f 76 69 6e 67 20 74 65 73 74 73 20 "Removing tests
8690: 66 6f 72 20 72 75 6e 3a 20 22 20 72 75 6e 6b 65 for run: " runke
86a0: 79 20 22 20 22 20 28 64 62 3a 67 65 74 2d 76 61 y " " (db:get-va
86b0: 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75 lue-by-header ru
86c0: 6e 20 68 65 61 64 65 72 20 22 72 75 6e 6e 61 6d n header "runnam
86d0: 65 22 29 29 0a 09 09 20 28 66 6f 72 2d 65 61 63 e"))... (for-eac
86e0: 68 0a 09 09 20 20 28 6c 61 6d 62 64 61 20 28 74 h... (lambda (t
86f0: 65 73 74 29 0a 09 09 20 20 20 20 28 6c 65 74 2a est)... (let*
8700: 20 28 28 69 74 65 6d 2d 70 61 74 68 20 28 64 62 ((item-path (db
8710: 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 :test-get-item-p
8720: 61 74 68 20 74 65 73 74 29 29 0a 09 09 09 20 20 ath test))....
8730: 20 28 74 65 73 74 2d 6e 61 6d 65 20 28 64 62 3a (test-name (db:
8740: 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d test-get-testnam
8750: 65 20 74 65 73 74 29 29 0a 09 09 09 20 20 20 28 e test)).... (
8760: 72 75 6e 2d 64 69 72 20 20 20 28 64 62 3a 74 65 run-dir (db:te
8770: 73 74 2d 67 65 74 2d 72 75 6e 64 69 72 20 74 65 st-get-rundir te
8780: 73 74 29 29 29 0a 09 09 20 20 20 20 20 20 28 64 st)))... (d
8790: 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 20 20 ebug:print 1 "
87a0: 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 74 " (db:test-get-t
87b0: 65 73 74 6e 61 6d 65 20 74 65 73 74 29 20 22 20 estname test) "
87c0: 69 64 3a 20 22 20 28 64 62 3a 74 65 73 74 2d 67 id: " (db:test-g
87d0: 65 74 2d 69 64 20 74 65 73 74 29 20 22 20 22 20 et-id test) " "
87e0: 69 74 65 6d 2d 70 61 74 68 29 0a 09 09 20 20 20 item-path)...
87f0: 20 20 20 28 64 62 3a 64 65 6c 65 74 65 2d 74 65 (db:delete-te
8800: 73 74 2d 72 65 63 6f 72 64 73 20 64 62 20 28 64 st-records db (d
8810: 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65 b:test-get-id te
8820: 73 74 29 29 0a 09 09 20 20 20 20 20 20 28 69 66 st))... (if
8830: 20 28 3e 20 28 73 74 72 69 6e 67 2d 6c 65 6e 67 (> (string-leng
8840: 74 68 20 72 75 6e 2d 64 69 72 29 20 35 29 20 3b th run-dir) 5) ;
8850: 3b 20 62 61 64 20 68 65 75 72 69 73 74 69 63 20 ; bad heuristic
8860: 62 75 74 20 73 68 6f 75 6c 64 20 70 72 65 76 65 but should preve
8870: 6e 74 20 2f 74 6d 70 20 2f 68 6f 6d 65 20 65 74 nt /tmp /home et
8880: 63 2e 0a 09 09 09 20 20 28 6c 65 74 20 28 28 66 c..... (let ((f
8890: 75 6c 6c 70 61 74 68 20 72 75 6e 2d 64 69 72 29 ullpath run-dir)
88a0: 29 20 3b 3b 20 22 2f 22 20 28 64 62 3a 74 65 73 ) ;; "/" (db:tes
88b0: 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 t-get-item-path
88c0: 74 65 73 74 29 29 29 29 0a 09 09 09 20 20 20 20 test))))....
88d0: 28 73 65 74 21 20 6c 61 73 74 74 70 61 74 68 20 (set! lasttpath
88e0: 66 75 6c 6c 70 61 74 68 29 0a 09 09 09 20 20 20 fullpath)....
88f0: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74 (hash-table-set
8900: 21 20 64 69 72 73 2d 74 6f 2d 72 65 6d 6f 76 65 ! dirs-to-remove
8910: 20 66 75 6c 6c 70 61 74 68 20 23 74 29 0a 09 09 fullpath #t)...
8920: 09 20 20 20 20 3b 3b 20 54 68 65 20 66 6f 6c 6c . ;; The foll
8930: 6f 77 69 6e 67 20 77 61 73 20 74 68 65 20 73 61 owing was the sa
8940: 66 65 20 64 65 6c 65 74 65 20 63 6f 64 65 20 62 fe delete code b
8950: 75 74 20 69 74 20 77 61 73 20 6e 6f 74 20 62 65 ut it was not be
8960: 69 6e 67 20 65 78 65 63 74 75 74 65 64 2e 0a 09 ing exectuted...
8970: 09 09 20 20 20 20 3b 3b 20 28 6c 65 74 2a 20 28 .. ;; (let* (
8980: 28 64 69 72 73 2d 63 6f 75 6e 74 20 28 2b 20 31 (dirs-count (+ 1
8990: 20 28 6c 65 6e 67 74 68 20 6b 65 79 73 29 28 6c (length keys)(l
89a0: 65 6e 67 74 68 20 28 73 74 72 69 6e 67 2d 73 70 ength (string-sp
89b0: 6c 69 74 20 69 74 65 6d 2d 70 61 74 68 20 22 2f lit item-path "/
89c0: 22 29 29 29 29 0a 09 09 09 20 20 20 20 3b 3b 20 ")))).... ;;
89d0: 20 20 20 20 20 20 20 28 64 69 72 2d 74 6f 2d 72 (dir-to-r
89e0: 65 6d 20 28 67 65 74 2d 64 69 72 2d 75 70 2d 6e em (get-dir-up-n
89f0: 20 66 75 6c 6c 70 61 74 68 20 64 69 72 73 2d 63 fullpath dirs-c
8a00: 6f 75 6e 74 29 29 0a 09 09 09 20 20 20 20 3b 3b ount)).... ;;
8a10: 20 20 20 20 20 20 20 20 28 72 65 6d 61 69 6e 69 (remaini
8a20: 6e 67 64 20 28 73 74 72 69 6e 67 2d 73 75 62 73 ngd (string-subs
8a30: 74 69 74 75 74 65 20 28 72 65 67 65 78 70 20 28 titute (regexp (
8a40: 63 6f 6e 63 20 22 5e 22 20 64 69 72 2d 74 6f 2d conc "^" dir-to-
8a50: 72 65 6d 20 22 2f 22 29 29 20 22 22 20 66 75 6c rem "/")) "" ful
8a60: 6c 70 61 74 68 29 29 0a 09 09 09 20 20 20 20 3b lpath)).... ;
8a70: 3b 20 20 20 20 20 20 20 20 28 63 6d 64 20 28 63 ; (cmd (c
8a80: 6f 6e 63 20 22 63 64 20 22 20 64 69 72 2d 74 6f onc "cd " dir-to
8a90: 2d 72 65 6d 20 22 3b 20 72 6d 64 69 72 20 2d 70 -rem "; rmdir -p
8aa0: 20 22 20 72 65 6d 61 69 6e 69 6e 67 64 20 29 29 " remainingd ))
8ab0: 29 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 28 69 ).... ;; (i
8ac0: 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 f (file-exists?
8ad0: 66 75 6c 6c 70 61 74 68 29 0a 09 09 09 20 20 20 fullpath)....
8ae0: 20 3b 3b 20 20 20 20 20 20 20 28 62 65 67 69 6e ;; (begin
8af0: 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20 20 .... ;;
8b00: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 (debug:print
8b10: 31 20 63 6d 64 29 0a 09 09 09 20 20 20 20 3b 3b 1 cmd).... ;;
8b20: 20 20 20 20 20 20 20 20 20 28 73 79 73 74 65 6d (system
8b30: 20 63 6d 64 29 29 29 0a 09 09 09 20 20 20 20 3b cmd))).... ;
8b40: 3b 20 20 20 29 29 0a 09 09 09 20 20 20 20 29 29 ; )).... ))
8b50: 29 29 0a 09 09 20 20 20 20 74 65 73 74 73 29 29 ))... tests))
8b60: 29 0a 0a 09 20 20 20 3b 3b 20 6c 6f 6f 6b 20 74 )... ;; look t
8b70: 68 6f 75 67 68 20 74 68 65 20 64 69 72 73 2d 74 hough the dirs-t
8b80: 6f 2d 72 65 6d 6f 76 65 20 66 6f 72 20 63 61 6e o-remove for can
8b90: 64 69 64 61 74 65 73 20 66 6f 72 20 72 65 6d 6f didates for remo
8ba0: 76 61 6c 2e 20 44 6f 20 74 68 69 73 20 61 66 74 val. Do this aft
8bb0: 65 72 20 64 65 6c 65 74 69 6e 67 20 74 68 65 20 er deleting the
8bc0: 72 65 63 6f 72 64 73 0a 09 20 20 20 3b 3b 20 66 records.. ;; f
8bd0: 6f 72 20 65 61 63 68 20 74 65 73 74 20 69 6e 20 or each test in
8be0: 63 61 73 65 20 77 65 20 67 65 74 20 6b 69 6c 6c case we get kill
8bf0: 65 64 2e 20 54 68 61 74 20 73 68 6f 75 6c 64 20 ed. That should
8c00: 6d 69 6e 69 6d 69 7a 65 20 74 68 65 20 64 65 74 minimize the det
8c10: 72 69 74 75 73 20 6c 65 66 74 20 6f 6e 20 64 69 ritus left on di
8c20: 73 6b 0a 09 20 20 20 3b 3b 20 70 72 6f 63 65 73 sk.. ;; proces
8c30: 73 20 74 68 65 20 64 69 72 73 20 66 72 6f 6d 20 s the dirs from
8c40: 6c 6f 6e 67 65 73 74 20 73 74 72 69 6e 67 20 6c longest string l
8c50: 65 6e 67 74 68 20 74 6f 20 73 68 6f 72 74 65 73 ength to shortes
8c60: 74 0a 09 20 20 20 28 66 6f 72 2d 65 61 63 68 20 t.. (for-each
8c70: 0a 09 20 20 20 20 28 6c 61 6d 62 64 61 20 28 64 .. (lambda (d
8c80: 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 0a 09 20 ir-to-remove)..
8c90: 20 20 20 20 20 28 69 66 20 28 66 69 6c 65 2d 65 (if (file-e
8ca0: 78 69 73 74 73 3f 20 64 69 72 2d 74 6f 2d 72 65 xists? dir-to-re
8cb0: 6d 6f 76 65 29 0a 09 09 20 20 28 6c 65 74 20 28 move)... (let (
8cc0: 28 64 69 72 2d 69 6e 2d 64 62 20 27 28 29 29 29 (dir-in-db '()))
8cd0: 0a 09 09 20 20 20 20 28 73 71 6c 69 74 65 33 3a ... (sqlite3:
8ce0: 66 6f 72 2d 65 61 63 68 2d 72 6f 77 0a 09 09 20 for-each-row...
8cf0: 20 20 20 20 28 6c 61 6d 62 64 61 20 28 64 69 72 (lambda (dir
8d00: 29 0a 09 09 20 20 20 20 20 20 20 28 73 65 74 21 )... (set!
8d10: 20 64 69 72 2d 69 6e 2d 64 62 20 28 63 6f 6e 73 dir-in-db (cons
8d20: 20 64 69 72 20 64 69 72 2d 69 6e 2d 64 62 29 29 dir dir-in-db))
8d30: 29 0a 09 09 20 20 20 20 20 64 62 20 22 53 45 4c )... db "SEL
8d40: 45 43 54 20 72 75 6e 64 69 72 20 46 52 4f 4d 20 ECT rundir FROM
8d50: 74 65 73 74 73 20 57 48 45 52 45 20 72 75 6e 64 tests WHERE rund
8d60: 69 72 20 4c 49 4b 45 20 3f 3b 22 20 0a 09 09 20 ir LIKE ?;" ...
8d70: 20 20 20 20 28 63 6f 6e 63 20 22 25 22 20 64 69 (conc "%" di
8d80: 72 2d 74 6f 2d 72 65 6d 6f 76 65 20 22 25 22 29 r-to-remove "%")
8d90: 29 20 3b 3b 20 79 65 73 2c 20 49 27 6d 20 67 6f ) ;; yes, I'm go
8da0: 69 6e 67 20 74 6f 20 62 61 69 6c 20 69 66 20 74 ing to bail if t
8db0: 68 65 72 65 20 69 73 20 61 6e 79 74 68 69 6e 67 here is anything
8dc0: 20 6c 69 6b 65 20 74 68 69 73 20 64 69 72 20 69 like this dir i
8dd0: 6e 20 74 68 65 20 64 62 0a 09 09 20 20 20 20 28 n the db... (
8de0: 69 66 20 28 6e 75 6c 6c 3f 20 64 69 72 2d 69 6e if (null? dir-in
8df0: 2d 64 62 29 0a 09 09 09 28 62 65 67 69 6e 0a 09 -db)....(begin..
8e00: 09 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 .. (debug:print
8e10: 20 32 20 22 52 65 6d 6f 76 69 6e 67 20 64 69 72 2 "Removing dir
8e20: 65 63 74 6f 72 79 20 77 69 74 68 20 7a 65 72 6f ectory with zero
8e30: 20 64 62 20 72 65 66 65 72 65 6e 63 65 73 3a 20 db references:
8e40: 22 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 " dir-to-remove)
8e50: 0a 09 09 09 20 20 28 73 79 73 74 65 6d 20 28 63 .... (system (c
8e60: 6f 6e 63 20 22 72 6d 20 2d 72 66 20 22 20 64 69 onc "rm -rf " di
8e70: 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 29 0a 09 09 r-to-remove))...
8e80: 09 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 64 . (hash-table-d
8e90: 65 6c 65 74 65 21 20 64 69 72 73 2d 74 6f 2d 72 elete! dirs-to-r
8ea0: 65 6d 6f 76 65 20 64 69 72 2d 74 6f 2d 72 65 6d emove dir-to-rem
8eb0: 6f 76 65 29 29 0a 09 09 09 28 64 65 62 75 67 3a ove))....(debug:
8ec0: 70 72 69 6e 74 20 32 20 22 53 6b 69 70 70 69 6e print 2 "Skippin
8ed0: 67 20 72 65 6d 6f 76 61 6c 20 6f 66 20 22 20 64 g removal of " d
8ee0: 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 20 22 20 66 ir-to-remove " f
8ef0: 6f 72 20 6e 6f 77 20 61 73 20 69 74 20 73 74 69 or now as it sti
8f00: 6c 6c 20 68 61 73 20 72 65 66 65 72 65 6e 63 65 ll has reference
8f10: 73 20 69 6e 20 74 68 65 20 64 61 74 61 62 61 73 s in the databas
8f20: 65 22 29 29 29 29 29 0a 09 20 20 20 20 28 73 6f e"))))).. (so
8f30: 72 74 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 6b rt (hash-table-k
8f40: 65 79 73 20 64 69 72 73 2d 74 6f 2d 72 65 6d 6f eys dirs-to-remo
8f50: 76 65 29 20 28 6c 61 6d 62 64 61 20 28 61 20 62 ve) (lambda (a b
8f60: 29 28 3e 20 28 73 74 72 69 6e 67 2d 6c 65 6e 67 )(> (string-leng
8f70: 74 68 20 61 29 28 73 74 72 69 6e 67 2d 6c 65 6e th a)(string-len
8f80: 67 74 68 20 62 29 29 29 29 29 0a 0a 09 20 20 20 gth b)))))...
8f90: 3b 3b 20 72 65 6d 6f 76 65 20 74 68 65 20 72 75 ;; remove the ru
8fa0: 6e 20 69 66 20 7a 65 72 6f 20 74 65 73 74 73 20 n if zero tests
8fb0: 72 65 6d 61 69 6e 0a 09 20 20 20 28 6c 65 74 20 remain.. (let
8fc0: 28 28 72 65 6d 74 65 73 74 73 20 28 64 62 2d 67 ((remtests (db-g
8fd0: 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d 72 75 6e et-tests-for-run
8fe0: 20 64 62 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 db (db:get-valu
8ff0: 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 e-by-header run
9000: 68 65 61 64 65 72 20 22 69 64 22 29 29 29 29 0a header "id")))).
9010: 09 20 20 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f . (if (null?
9020: 20 72 65 6d 74 65 73 74 73 29 20 3b 3b 20 6e 6f remtests) ;; no
9030: 20 6d 6f 72 65 20 74 65 73 74 73 20 72 65 6d 61 more tests rema
9040: 69 6e 69 6e 67 0a 09 09 20 28 6c 65 74 2a 20 28 ining... (let* (
9050: 28 64 70 61 72 74 73 20 20 28 73 74 72 69 6e 67 (dparts (string
9060: 2d 73 70 6c 69 74 20 6c 61 73 74 74 70 61 74 68 -split lasttpath
9070: 20 22 2f 22 29 29 0a 09 09 09 28 72 75 6e 70 61 "/"))....(runpa
9080: 74 68 20 28 63 6f 6e 63 20 22 2f 22 20 28 73 74 th (conc "/" (st
9090: 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 ring-intersperse
90a0: 20 0a 09 09 09 09 09 20 20 20 20 28 74 61 6b 65 ...... (take
90b0: 20 64 70 61 72 74 73 20 28 2d 20 28 6c 65 6e 67 dparts (- (leng
90c0: 74 68 20 64 70 61 72 74 73 29 20 31 29 29 0a 09 th dparts) 1))..
90d0: 09 09 09 09 20 20 20 20 22 2f 22 29 29 29 29 0a .... "/")))).
90e0: 09 09 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e .. (debug:prin
90f0: 74 20 31 20 22 52 65 6d 6f 76 69 6e 67 20 72 75 t 1 "Removing ru
9100: 6e 3a 20 22 20 72 75 6e 6b 65 79 20 22 20 22 20 n: " runkey " "
9110: 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 (db:get-value-by
9120: 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 -header run head
9130: 65 72 20 22 72 75 6e 6e 61 6d 65 22 29 29 0a 09 er "runname"))..
9140: 09 20 20 20 28 64 62 3a 64 65 6c 65 74 65 2d 72 . (db:delete-r
9150: 75 6e 20 64 62 20 72 75 6e 2d 69 64 29 0a 09 09 un db run-id)...
9160: 20 20 20 3b 3b 20 6e 65 65 64 20 74 6f 20 66 69 ;; need to fi
9170: 67 75 72 65 20 6f 75 74 20 74 68 65 20 70 61 74 gure out the pat
9180: 68 20 74 6f 20 74 68 65 20 72 75 6e 20 64 69 72 h to the run dir
9190: 20 61 6e 64 20 72 65 6d 6f 76 65 20 69 74 20 69 and remove it i
91a0: 66 20 65 6d 70 74 79 0a 09 09 20 20 20 3b 3b 20 f empty... ;;
91b0: 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 28 67 (if (null? (g
91c0: 6c 6f 62 20 28 63 6f 6e 63 20 72 75 6e 70 61 74 lob (conc runpat
91d0: 68 20 22 2f 2a 22 29 29 29 0a 09 09 20 20 20 3b h "/*")))... ;
91e0: 3b 20 20 20 20 20 20 20 20 28 62 65 67 69 6e 0a ; (begin.
91f0: 09 09 20 20 20 3b 3b 20 09 20 28 64 65 62 75 67 .. ;; . (debug
9200: 3a 70 72 69 6e 74 20 31 20 22 52 65 6d 6f 76 69 :print 1 "Removi
9210: 6e 67 20 72 75 6e 20 64 69 72 20 22 20 72 75 6e ng run dir " run
9220: 70 61 74 68 29 0a 09 09 20 20 20 3b 3b 20 09 20 path)... ;; .
9230: 28 73 79 73 74 65 6d 20 28 63 6f 6e 63 20 22 72 (system (conc "r
9240: 6d 64 69 72 20 2d 70 20 22 20 72 75 6e 70 61 74 mdir -p " runpat
9250: 68 29 29 29 29 0a 09 09 20 20 20 29 29 29 29 0a h))))... )))).
9260: 09 20 29 29 0a 20 20 20 20 20 72 75 6e 73 29 29 . )). runs))
9270: 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d )..;;===========
9280: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
9290: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
92a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
92b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 52 ===========.;; R
92c0: 6f 75 74 69 6e 65 73 20 66 6f 72 20 6d 61 6e 69 outines for mani
92d0: 70 75 6c 61 74 69 6e 67 20 72 75 6e 73 0a 3b 3b pulating runs.;;
92e0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
92f0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
9300: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
9310: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
9320: 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 53 69 6e 63 65 ======..;; Since
9330: 20 6d 61 6e 79 20 63 61 6c 6c 73 20 74 6f 20 61 many calls to a
9340: 20 72 75 6e 20 72 65 71 75 69 72 65 20 70 72 65 run require pre
9350: 74 74 79 20 6d 75 63 68 20 74 68 65 20 73 61 6d tty much the sam
9360: 65 20 73 65 74 75 70 20 0a 3b 3b 20 74 68 69 73 e setup .;; this
9370: 20 77 72 61 70 70 65 72 20 69 73 20 75 73 65 64 wrapper is used
9380: 20 74 6f 20 72 65 64 75 63 65 20 74 68 65 20 72 to reduce the r
9390: 65 70 6c 69 63 61 74 69 6f 6e 20 6f 66 20 63 6f eplication of co
93a0: 64 65 0a 28 64 65 66 69 6e 65 20 28 67 65 6e 65 de.(define (gene
93b0: 72 61 6c 2d 72 75 6e 2d 63 61 6c 6c 20 73 77 69 ral-run-call swi
93c0: 74 63 68 6e 61 6d 65 20 61 63 74 69 6f 6e 2d 64 tchname action-d
93d0: 65 73 63 20 70 72 6f 63 29 0a 20 20 28 69 66 20 esc proc). (if
93e0: 28 6e 6f 74 20 28 61 72 67 73 3a 67 65 74 2d 61 (not (args:get-a
93f0: 72 67 20 22 3a 72 75 6e 6e 61 6d 65 22 29 29 0a rg ":runname")).
9400: 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09 28 64 (begin..(d
9410: 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 ebug:print 0 "ER
9420: 52 4f 52 3a 20 4d 69 73 73 69 6e 67 20 72 65 71 ROR: Missing req
9430: 75 69 72 65 64 20 70 61 72 61 6d 65 74 65 72 20 uired parameter
9440: 66 6f 72 20 22 20 73 77 69 74 63 68 6e 61 6d 65 for " switchname
9450: 20 22 2c 20 79 6f 75 20 6d 75 73 74 20 73 70 65 ", you must spe
9460: 63 69 66 79 20 74 68 65 20 72 75 6e 20 6e 61 6d cify the run nam
9470: 65 20 77 69 74 68 20 3a 72 75 6e 6e 61 6d 65 20 e with :runname
9480: 72 75 6e 6e 61 6d 65 22 29 0a 09 28 65 78 69 74 runname")..(exit
9490: 20 32 29 29 0a 20 20 20 20 20 20 28 6c 65 74 20 2)). (let
94a0: 28 28 64 62 20 23 66 29 29 0a 09 28 69 66 20 28 ((db #f))..(if (
94b0: 6e 6f 74 20 28 73 65 74 75 70 2d 66 6f 72 2d 72 not (setup-for-r
94c0: 75 6e 29 29 0a 09 20 20 20 20 28 62 65 67 69 6e un)).. (begin
94d0: 20 0a 09 20 20 20 20 20 20 28 64 65 62 75 67 3a .. (debug:
94e0: 70 72 69 6e 74 20 30 20 22 46 61 69 6c 65 64 20 print 0 "Failed
94f0: 74 6f 20 73 65 74 75 70 2c 20 65 78 69 74 69 6e to setup, exitin
9500: 67 22 29 0a 09 20 20 20 20 20 20 28 65 78 69 74 g").. (exit
9510: 20 31 29 29 29 0a 09 28 73 65 74 21 20 64 62 20 1)))..(set! db
9520: 28 6f 70 65 6e 2d 64 62 29 29 0a 09 28 69 66 20 (open-db))..(if
9530: 28 6e 6f 74 20 28 63 61 72 20 2a 63 6f 6e 66 69 (not (car *confi
9540: 67 69 6e 66 6f 2a 29 29 0a 09 20 20 20 20 28 62 ginfo*)).. (b
9550: 65 67 69 6e 0a 09 20 20 20 20 20 20 28 64 65 62 egin.. (deb
9560: 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f ug:print 0 "ERRO
9570: 52 3a 20 41 74 74 65 6d 70 74 65 64 20 74 6f 20 R: Attempted to
9580: 22 20 61 63 74 69 6f 6e 2d 64 65 73 63 20 22 20 " action-desc "
9590: 62 75 74 20 72 75 6e 20 61 72 65 61 20 63 6f 6e but run area con
95a0: 66 69 67 20 66 69 6c 65 20 6e 6f 74 20 66 6f 75 fig file not fou
95b0: 6e 64 22 29 0a 09 20 20 20 20 20 20 28 65 78 69 nd").. (exi
95c0: 74 20 31 29 29 0a 09 20 20 20 20 3b 3b 20 45 78 t 1)).. ;; Ex
95d0: 74 72 61 63 74 20 6f 75 74 20 73 74 75 66 66 20 tract out stuff
95e0: 6e 65 65 64 65 64 20 69 6e 20 6d 6f 73 74 20 6f needed in most o
95f0: 72 20 6d 61 6e 79 20 63 61 6c 6c 73 0a 09 20 20 r many calls..
9600: 20 20 3b 3b 20 68 65 72 65 20 74 68 65 6e 20 63 ;; here then c
9610: 61 6c 6c 20 70 72 6f 63 0a 09 20 20 20 20 28 6c all proc.. (l
9620: 65 74 2a 20 28 28 6b 65 79 73 20 20 20 20 20 20 et* ((keys
9630: 20 28 64 62 2d 67 65 74 2d 6b 65 79 73 20 64 62 (db-get-keys db
9640: 29 29 0a 09 09 20 20 20 28 6b 65 79 6e 61 6d 65 ))... (keyname
9650: 73 20 20 20 28 6d 61 70 20 6b 65 79 3a 67 65 74 s (map key:get
9660: 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65 79 73 29 -fieldname keys)
9670: 29 0a 09 09 20 20 20 28 6b 65 79 76 61 6c 6c 73 )... (keyvalls
9680: 74 20 20 28 6b 65 79 73 2d 3e 76 61 6c 6c 69 73 t (keys->vallis
9690: 74 20 6b 65 79 73 20 23 74 29 29 29 0a 09 20 20 t keys #t)))..
96a0: 20 20 20 20 28 70 72 6f 63 20 64 62 20 6b 65 79 (proc db key
96b0: 73 20 6b 65 79 6e 61 6d 65 73 20 6b 65 79 76 61 s keynames keyva
96c0: 6c 6c 73 74 29 29 29 0a 09 28 73 71 6c 69 74 65 llst)))..(sqlite
96d0: 33 3a 66 69 6e 61 6c 69 7a 65 21 20 64 62 29 0a 3:finalize! db).
96e0: 09 28 73 65 74 21 20 2a 64 69 64 73 6f 6d 65 74 .(set! *didsomet
96f0: 68 69 6e 67 2a 20 23 74 29 29 29 29 0a 0a 3b 3b hing* #t))))..;;
9700: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
9710: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
9720: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
9730: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
9740: 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 52 6f 6c 6c 75 70 ======.;; Rollup
9750: 20 72 75 6e 73 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d runs.;;========
9760: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
9770: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
9780: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
9790: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a ==============..
97a0: 3b 3b 20 55 70 64 61 74 65 20 74 68 65 20 74 65 ;; Update the te
97b0: 73 74 5f 6d 65 74 61 20 74 61 62 6c 65 20 66 6f st_meta table fo
97c0: 72 20 74 68 69 73 20 74 65 73 74 0a 28 64 65 66 r this test.(def
97d0: 69 6e 65 20 28 72 75 6e 73 3a 75 70 64 61 74 65 ine (runs:update
97e0: 2d 74 65 73 74 5f 6d 65 74 61 20 64 62 20 74 65 -test_meta db te
97f0: 73 74 2d 6e 61 6d 65 20 74 65 73 74 2d 63 6f 6e st-name test-con
9800: 66 29 0a 20 20 28 6c 65 74 20 28 28 63 75 72 72 f). (let ((curr
9810: 72 65 63 6f 72 64 20 28 64 62 3a 74 65 73 74 6d record (db:testm
9820: 65 74 61 2d 67 65 74 2d 72 65 63 6f 72 64 20 64 eta-get-record d
9830: 62 20 74 65 73 74 2d 6e 61 6d 65 29 29 29 0a 20 b test-name))).
9840: 20 20 20 28 69 66 20 28 6e 6f 74 20 63 75 72 72 (if (not curr
9850: 72 65 63 6f 72 64 29 0a 09 28 62 65 67 69 6e 0a record)..(begin.
9860: 09 20 20 28 73 65 74 21 20 63 75 72 72 72 65 63 . (set! currrec
9870: 6f 72 64 20 28 6d 61 6b 65 2d 76 65 63 74 6f 72 ord (make-vector
9880: 20 31 30 20 23 66 29 29 0a 09 20 20 28 64 62 3a 10 #f)).. (db:
9890: 74 65 73 74 6d 65 74 61 2d 61 64 64 2d 72 65 63 testmeta-add-rec
98a0: 6f 72 64 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 ord db test-name
98b0: 29 29 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 ))). (for-eac
98c0: 68 20 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 h . (lambda
98d0: 28 6b 65 79 29 0a 20 20 20 20 20 20 20 28 6c 65 (key). (le
98e0: 74 2a 20 28 28 69 64 78 20 28 63 61 64 72 20 6b t* ((idx (cadr k
98f0: 65 79 29 29 0a 09 20 20 20 20 20 20 28 66 6c 64 ey)).. (fld
9900: 20 28 63 61 72 20 20 6b 65 79 29 29 0a 09 20 20 (car key))..
9910: 20 20 20 20 28 76 61 6c 20 28 63 6f 6e 66 69 67 (val (config
9920: 2d 6c 6f 6f 6b 75 70 20 74 65 73 74 2d 63 6f 6e -lookup test-con
9930: 66 20 22 74 65 73 74 5f 6d 65 74 61 22 20 66 6c f "test_meta" fl
9940: 64 29 29 29 0a 09 20 28 69 66 20 28 61 6e 64 20 d))).. (if (and
9950: 76 61 6c 20 28 6e 6f 74 20 28 65 71 75 61 6c 3f val (not (equal?
9960: 20 28 76 65 63 74 6f 72 2d 72 65 66 20 63 75 72 (vector-ref cur
9970: 72 72 65 63 6f 72 64 20 69 64 78 29 20 76 61 6c rrecord idx) val
9980: 29 29 29 0a 09 20 20 20 20 20 28 62 65 67 69 6e ))).. (begin
9990: 0a 09 20 20 20 20 20 20 20 28 70 72 69 6e 74 20 .. (print
99a0: 22 55 70 64 61 74 69 6e 67 20 22 20 74 65 73 74 "Updating " test
99b0: 2d 6e 61 6d 65 20 22 20 22 20 66 6c 64 20 22 20 -name " " fld "
99c0: 74 6f 20 22 20 76 61 6c 29 0a 09 20 20 20 20 20 to " val)..
99d0: 20 20 28 64 62 3a 74 65 73 74 6d 65 74 61 2d 75 (db:testmeta-u
99e0: 70 64 61 74 65 2d 66 69 65 6c 64 20 64 62 20 74 pdate-field db t
99f0: 65 73 74 2d 6e 61 6d 65 20 66 6c 64 20 76 61 6c est-name fld val
9a00: 29 29 29 29 29 0a 20 20 20 20 20 27 28 28 22 61 ))))). '(("a
9a10: 75 74 68 6f 72 22 20 32 29 28 22 6f 77 6e 65 72 uthor" 2)("owner
9a20: 22 20 33 29 28 22 64 65 73 63 72 69 70 74 69 6f " 3)("descriptio
9a30: 6e 22 20 34 29 28 22 72 65 76 69 65 77 65 64 22 n" 4)("reviewed"
9a40: 20 35 29 28 22 74 61 67 73 22 20 39 29 29 29 29 5)("tags" 9))))
9a50: 29 0a 0a 3b 3b 20 55 70 64 61 74 65 20 74 65 73 )..;; Update tes
9a60: 74 5f 6d 65 74 61 20 66 6f 72 20 61 6c 6c 20 74 t_meta for all t
9a70: 65 73 74 73 0a 28 64 65 66 69 6e 65 20 28 72 75 ests.(define (ru
9a80: 6e 73 3a 75 70 64 61 74 65 2d 61 6c 6c 2d 74 65 ns:update-all-te
9a90: 73 74 5f 6d 65 74 61 20 64 62 29 0a 20 20 28 6c st_meta db). (l
9aa0: 65 74 20 28 28 74 65 73 74 2d 6e 61 6d 65 73 20 et ((test-names
9ab0: 28 67 65 74 2d 61 6c 6c 2d 6c 65 67 61 6c 2d 74 (get-all-legal-t
9ac0: 65 73 74 73 29 29 29 0a 20 20 20 20 28 66 6f 72 ests))). (for
9ad0: 2d 65 61 63 68 20 0a 20 20 20 20 20 28 6c 61 6d -each . (lam
9ae0: 62 64 61 20 28 74 65 73 74 2d 6e 61 6d 65 29 0a bda (test-name).
9af0: 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28 28 74 (let* ((t
9b00: 65 73 74 2d 70 61 74 68 20 20 20 20 28 63 6f 6e est-path (con
9b10: 63 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f 74 65 c *toppath* "/te
9b20: 73 74 73 2f 22 20 74 65 73 74 2d 6e 61 6d 65 29 sts/" test-name)
9b30: 29 0a 09 20 20 20 20 20 20 28 74 65 73 74 2d 63 ).. (test-c
9b40: 6f 6e 66 69 67 66 20 28 63 6f 6e 63 20 74 65 73 onfigf (conc tes
9b50: 74 2d 70 61 74 68 20 22 2f 74 65 73 74 63 6f 6e t-path "/testcon
9b60: 66 69 67 22 29 29 0a 09 20 20 20 20 20 20 28 74 fig")).. (t
9b70: 65 73 74 65 78 69 73 74 73 20 20 20 28 61 6e 64 estexists (and
9b80: 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 74 (file-exists? t
9b90: 65 73 74 2d 63 6f 6e 66 69 67 66 29 28 66 69 6c est-configf)(fil
9ba0: 65 2d 72 65 61 64 2d 61 63 63 65 73 73 3f 20 74 e-read-access? t
9bb0: 65 73 74 2d 63 6f 6e 66 69 67 66 29 29 29 0a 09 est-configf)))..
9bc0: 20 20 20 20 20 20 3b 3b 20 72 65 61 64 20 63 6f ;; read co
9bd0: 6e 66 69 67 73 20 77 69 74 68 20 74 72 69 63 6b nfigs with trick
9be0: 73 20 74 75 72 6e 65 64 20 6f 66 66 20 28 69 2e s turned off (i.
9bf0: 65 2e 20 6e 6f 20 73 79 73 74 65 6d 29 0a 09 20 e. no system)..
9c00: 20 20 20 20 20 28 74 65 73 74 2d 63 6f 6e 66 20 (test-conf
9c10: 20 20 20 28 69 66 20 74 65 73 74 65 78 69 73 74 (if testexist
9c20: 73 20 28 72 65 61 64 2d 63 6f 6e 66 69 67 20 74 s (read-config t
9c30: 65 73 74 2d 63 6f 6e 66 69 67 66 20 23 66 20 23 est-configf #f #
9c40: 66 29 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 f)(make-hash-tab
9c50: 6c 65 29 29 29 29 0a 09 20 28 72 75 6e 73 3a 75 le)))).. (runs:u
9c60: 70 64 61 74 65 2d 74 65 73 74 5f 6d 65 74 61 20 pdate-test_meta
9c70: 64 62 20 74 65 73 74 2d 6e 61 6d 65 20 74 65 73 db test-name tes
9c80: 74 2d 63 6f 6e 66 29 29 29 0a 20 20 20 20 20 74 t-conf))). t
9c90: 65 73 74 2d 6e 61 6d 65 73 29 29 29 0a 09 20 0a est-names))).. .
9ca0: 3b 3b 20 54 68 69 73 20 63 6f 75 6c 64 20 70 72 ;; This could pr
9cb0: 6f 62 61 62 6c 79 20 62 65 20 72 65 66 61 63 74 obably be refact
9cc0: 6f 72 65 64 20 69 6e 74 6f 20 6f 6e 65 20 63 6f ored into one co
9cd0: 6d 70 6c 65 78 20 71 75 65 72 79 20 2e 2e 2e 0a mplex query ....
9ce0: 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 72 6f (define (runs:ro
9cf0: 6c 6c 75 70 2d 72 75 6e 20 64 62 20 6b 65 79 73 llup-run db keys
9d00: 29 0a 20 20 28 6c 65 74 2a 20 28 28 6e 65 77 2d ). (let* ((new-
9d10: 72 75 6e 2d 69 64 20 20 20 20 20 20 28 72 65 67 run-id (reg
9d20: 69 73 74 65 72 2d 72 75 6e 20 64 62 20 6b 65 79 ister-run db key
9d30: 73 29 29 0a 09 20 28 70 72 65 76 2d 74 65 73 74 s)).. (prev-test
9d40: 73 20 20 20 20 20 20 28 74 65 73 74 3a 67 65 74 s (test:get
9d50: 2d 6d 61 74 63 68 69 6e 67 2d 70 72 65 76 69 6f -matching-previo
9d60: 75 73 2d 74 65 73 74 2d 72 75 6e 2d 72 65 63 6f us-test-run-reco
9d70: 72 64 73 20 64 62 20 6e 65 77 2d 72 75 6e 2d 69 rds db new-run-i
9d80: 64 20 22 25 22 20 22 25 22 29 29 0a 09 20 28 63 d "%" "%")).. (c
9d90: 75 72 72 2d 74 65 73 74 73 20 20 20 20 20 20 28 urr-tests (
9da0: 64 62 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f 72 db-get-tests-for
9db0: 2d 72 75 6e 20 64 62 20 6e 65 77 2d 72 75 6e 2d -run db new-run-
9dc0: 69 64 20 22 25 22 20 22 25 22 29 29 0a 09 20 28 id "%" "%")).. (
9dd0: 63 75 72 72 2d 74 65 73 74 73 2d 68 61 73 68 20 curr-tests-hash
9de0: 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 (make-hash-table
9df0: 29 29 29 0a 20 20 20 20 3b 3b 20 69 6e 64 65 78 ))). ;; index
9e00: 20 74 68 65 20 61 6c 72 65 61 64 79 20 73 61 76 the already sav
9e10: 65 64 20 74 65 73 74 73 20 62 79 20 74 65 73 74 ed tests by test
9e20: 6e 61 6d 65 20 61 6e 64 20 69 74 65 6d 70 61 74 name and itempat
9e30: 68 20 69 6e 20 63 75 72 72 2d 74 65 73 74 73 2d h in curr-tests-
9e40: 68 61 73 68 0a 20 20 20 20 28 66 6f 72 2d 65 61 hash. (for-ea
9e50: 63 68 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 ch. (lambda
9e60: 28 74 65 73 74 64 61 74 29 0a 20 20 20 20 20 20 (testdat).
9e70: 20 28 6c 65 74 2a 20 28 28 74 65 73 74 6e 61 6d (let* ((testnam
9e80: 65 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d e (db:test-get-
9e90: 74 65 73 74 6e 61 6d 65 20 74 65 73 74 64 61 74 testname testdat
9ea0: 29 29 0a 09 20 20 20 20 20 20 28 69 74 65 6d 2d )).. (item-
9eb0: 70 61 74 68 20 28 64 62 3a 74 65 73 74 2d 67 65 path (db:test-ge
9ec0: 74 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 t-item-path test
9ed0: 64 61 74 29 29 0a 09 20 20 20 20 20 20 28 66 75 dat)).. (fu
9ee0: 6c 6c 2d 6e 61 6d 65 20 28 63 6f 6e 63 20 74 65 ll-name (conc te
9ef0: 73 74 6e 61 6d 65 20 22 2f 22 20 69 74 65 6d 2d stname "/" item-
9f00: 70 61 74 68 29 29 29 0a 09 20 28 68 61 73 68 2d path))).. (hash-
9f10: 74 61 62 6c 65 2d 73 65 74 21 20 63 75 72 72 2d table-set! curr-
9f20: 74 65 73 74 73 2d 68 61 73 68 20 66 75 6c 6c 2d tests-hash full-
9f30: 6e 61 6d 65 20 74 65 73 74 64 61 74 29 29 29 0a name testdat))).
9f40: 20 20 20 20 20 63 75 72 72 2d 74 65 73 74 73 29 curr-tests)
9f50: 0a 20 20 20 20 3b 3b 20 4e 4f 50 45 3a 20 4e 6f . ;; NOPE: No
9f60: 6e 2d 6f 70 74 69 6d 61 6c 20 61 70 70 72 6f 61 n-optimal approa
9f70: 63 68 2e 20 54 72 79 20 74 68 69 73 20 69 6e 73 ch. Try this ins
9f80: 74 65 61 64 2e 0a 20 20 20 20 3b 3b 20 20 20 31 tead.. ;; 1
9f90: 2e 20 74 65 73 74 73 20 61 72 65 20 72 65 63 65 . tests are rece
9fa0: 69 76 65 64 20 69 6e 20 61 20 6c 69 73 74 2c 20 ived in a list,
9fb0: 6d 6f 73 74 20 72 65 63 65 6e 74 20 66 69 72 73 most recent firs
9fc0: 74 0a 20 20 20 20 3b 3b 20 20 20 32 2e 20 72 65 t. ;; 2. re
9fd0: 70 6c 61 63 65 20 74 68 65 20 72 6f 6c 6c 75 70 place the rollup
9fe0: 20 74 65 73 74 20 77 69 74 68 20 74 68 65 20 6e test with the n
9ff0: 65 77 20 2a 61 6c 77 61 79 73 2a 0a 20 20 20 20 ew *always*.
a000: 28 66 6f 72 2d 65 61 63 68 20 0a 20 20 20 20 20 (for-each .
a010: 28 6c 61 6d 62 64 61 20 28 74 65 73 74 64 61 74 (lambda (testdat
a020: 29 0a 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28 ). (let* (
a030: 28 74 65 73 74 6e 61 6d 65 20 20 28 64 62 3a 74 (testname (db:t
a040: 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 est-get-testname
a050: 20 74 65 73 74 64 61 74 29 29 0a 09 20 20 20 20 testdat))..
a060: 20 20 28 69 74 65 6d 2d 70 61 74 68 20 28 64 62 (item-path (db
a070: 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 :test-get-item-p
a080: 61 74 68 20 74 65 73 74 64 61 74 29 29 0a 09 20 ath testdat))..
a090: 20 20 20 20 20 28 66 75 6c 6c 2d 6e 61 6d 65 20 (full-name
a0a0: 28 63 6f 6e 63 20 74 65 73 74 6e 61 6d 65 20 22 (conc testname "
a0b0: 2f 22 20 69 74 65 6d 2d 70 61 74 68 29 29 0a 09 /" item-path))..
a0c0: 20 20 20 20 20 20 28 70 72 65 76 2d 74 65 73 74 (prev-test
a0d0: 2d 64 61 74 20 28 68 61 73 68 2d 74 61 62 6c 65 -dat (hash-table
a0e0: 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 63 75 72 -ref/default cur
a0f0: 72 2d 74 65 73 74 73 2d 68 61 73 68 20 66 75 6c r-tests-hash ful
a100: 6c 2d 6e 61 6d 65 20 23 66 29 29 0a 09 20 20 20 l-name #f))..
a110: 20 20 20 28 74 65 73 74 2d 73 74 65 70 73 20 20 (test-steps
a120: 20 20 20 20 28 64 62 3a 67 65 74 2d 73 74 65 70 (db:get-step
a130: 73 2d 66 6f 72 2d 74 65 73 74 20 64 62 20 28 64 s-for-test db (d
a140: 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65 b:test-get-id te
a150: 73 74 64 61 74 29 29 29 0a 09 20 20 20 20 20 20 stdat)))..
a160: 28 6e 65 77 2d 74 65 73 74 2d 72 65 63 6f 72 64 (new-test-record
a170: 20 23 66 29 29 0a 09 20 3b 3b 20 72 65 70 6c 61 #f)).. ;; repla
a180: 63 65 20 74 68 65 73 65 20 77 69 74 68 20 69 6e ce these with in
a190: 73 65 72 74 20 2e 2e 2e 20 73 65 6c 65 63 74 0a sert ... select.
a1a0: 09 20 28 61 70 70 6c 79 20 73 71 6c 69 74 65 33 . (apply sqlite3
a1b0: 3a 65 78 65 63 75 74 65 20 0a 09 09 64 62 20 0a :execute ...db .
a1c0: 09 09 28 63 6f 6e 63 20 22 49 4e 53 45 52 54 20 ..(conc "INSERT
a1d0: 4f 52 20 52 45 50 4c 41 43 45 20 49 4e 54 4f 20 OR REPLACE INTO
a1e0: 74 65 73 74 73 20 28 72 75 6e 5f 69 64 2c 74 65 tests (run_id,te
a1f0: 73 74 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 61 stname,state,sta
a200: 74 75 73 2c 65 76 65 6e 74 5f 74 69 6d 65 2c 68 tus,event_time,h
a210: 6f 73 74 2c 63 70 75 6c 6f 61 64 2c 64 69 73 6b ost,cpuload,disk
a220: 66 72 65 65 2c 75 6e 61 6d 65 2c 72 75 6e 64 69 free,uname,rundi
a230: 72 2c 69 74 65 6d 5f 70 61 74 68 2c 72 75 6e 5f r,item_path,run_
a240: 64 75 72 61 74 69 6f 6e 2c 66 69 6e 61 6c 5f 6c duration,final_l
a250: 6f 67 66 2c 63 6f 6d 6d 65 6e 74 2c 66 69 72 73 ogf,comment,firs
a260: 74 5f 65 72 72 2c 66 69 72 73 74 5f 77 61 72 6e t_err,first_warn
a270: 29 20 22 0a 09 09 20 20 20 20 20 20 22 56 41 4c ) "... "VAL
a280: 55 45 53 20 28 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f UES (?,?,?,?,?,?
a290: 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f ,?,?,?,?,?,?,?,?
a2a0: 2c 3f 2c 3f 29 3b 22 29 0a 09 09 6e 65 77 2d 72 ,?,?);")...new-r
a2b0: 75 6e 2d 69 64 20 28 63 64 64 72 20 28 76 65 63 un-id (cddr (vec
a2c0: 74 6f 72 2d 3e 6c 69 73 74 20 74 65 73 74 64 61 tor->list testda
a2d0: 74 29 29 29 0a 09 20 28 73 65 74 21 20 6e 65 77 t))).. (set! new
a2e0: 2d 74 65 73 74 64 61 74 20 28 63 61 72 20 28 64 -testdat (car (d
a2f0: 62 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d b-get-tests-for-
a300: 72 75 6e 20 64 62 20 6e 65 77 2d 72 75 6e 2d 69 run db new-run-i
a310: 64 20 74 65 73 74 6e 61 6d 65 20 69 74 65 6d 2d d testname item-
a320: 70 61 74 68 29 29 29 0a 09 20 28 68 61 73 68 2d path))).. (hash-
a330: 74 61 62 6c 65 2d 73 65 74 21 20 63 75 72 72 2d table-set! curr-
a340: 74 65 73 74 73 2d 68 61 73 68 20 66 75 6c 6c 2d tests-hash full-
a350: 6e 61 6d 65 20 6e 65 77 2d 74 65 73 74 64 61 74 name new-testdat
a360: 29 20 3b 3b 20 74 68 69 73 20 63 6f 75 6c 64 20 ) ;; this could
a370: 62 65 20 63 6f 6e 66 75 73 69 6e 67 2c 20 77 68 be confusing, wh
a380: 69 63 68 20 72 65 63 6f 72 64 20 73 68 6f 75 6c ich record shoul
a390: 64 20 67 6f 20 69 6e 74 6f 20 74 68 65 20 6c 6f d go into the lo
a3a0: 6f 6b 75 70 20 74 61 62 6c 65 3f 0a 09 20 3b 3b okup table?.. ;;
a3b0: 20 4e 6f 77 20 64 75 70 6c 69 63 61 74 65 20 74 Now duplicate t
a3c0: 68 65 20 74 65 73 74 20 73 74 65 70 73 0a 09 20 he test steps..
a3d0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 (debug:print 4 "
a3e0: 43 6f 70 79 69 6e 67 20 72 65 63 6f 72 64 73 20 Copying records
a3f0: 69 6e 20 74 65 73 74 5f 73 74 65 70 73 20 66 72 in test_steps fr
a400: 6f 6d 20 74 65 73 74 5f 69 64 3d 22 20 28 64 62 om test_id=" (db
a410: 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 :test-get-id tes
a420: 74 64 61 74 29 20 22 20 74 6f 20 22 20 28 64 62 tdat) " to " (db
a430: 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 6e 65 77 :test-get-id new
a440: 2d 74 65 73 74 64 61 74 29 29 0a 09 20 28 73 71 -testdat)).. (sq
a450: 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 0a 09 lite3:execute ..
a460: 20 20 64 62 20 0a 09 20 20 28 63 6f 6e 63 20 22 db .. (conc "
a470: 49 4e 53 45 52 54 20 4f 52 20 52 45 50 4c 41 43 INSERT OR REPLAC
a480: 45 20 49 4e 54 4f 20 74 65 73 74 5f 73 74 65 70 E INTO test_step
a490: 73 20 28 74 65 73 74 5f 69 64 2c 73 74 65 70 6e s (test_id,stepn
a4a0: 61 6d 65 2c 73 74 61 74 65 2c 73 74 61 74 75 73 ame,state,status
a4b0: 2c 65 76 65 6e 74 5f 74 69 6d 65 2c 63 6f 6d 6d ,event_time,comm
a4c0: 65 6e 74 29 20 22 0a 09 09 22 53 45 4c 45 43 54 ent) "..."SELECT
a4d0: 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d " (db:test-get-
a4e0: 69 64 20 6e 65 77 2d 74 65 73 74 64 61 74 29 20 id new-testdat)
a4f0: 22 2c 73 74 65 70 6e 61 6d 65 2c 73 74 61 74 65 ",stepname,state
a500: 2c 73 74 61 74 75 73 2c 65 76 65 6e 74 5f 74 69 ,status,event_ti
a510: 6d 65 2c 63 6f 6d 6d 65 6e 74 20 46 52 4f 4d 20 me,comment FROM
a520: 74 65 73 74 5f 73 74 65 70 73 20 57 48 45 52 45 test_steps WHERE
a530: 20 74 65 73 74 5f 69 64 3d 3f 3b 22 29 0a 09 20 test_id=?;")..
a540: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 (db:test-get-id
a550: 20 74 65 73 74 64 61 74 29 29 0a 09 20 3b 3b 20 testdat)).. ;;
a560: 4e 6f 77 20 64 75 70 6c 69 63 61 74 65 20 74 68 Now duplicate th
a570: 65 20 74 65 73 74 20 64 61 74 61 0a 09 20 28 64 e test data.. (d
a580: 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 43 6f ebug:print 4 "Co
a590: 70 79 69 6e 67 20 72 65 63 6f 72 64 73 20 69 6e pying records in
a5a0: 20 74 65 73 74 5f 64 61 74 61 20 66 72 6f 6d 20 test_data from
a5b0: 74 65 73 74 5f 69 64 3d 22 20 28 64 62 3a 74 65 test_id=" (db:te
a5c0: 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74 64 61 st-get-id testda
a5d0: 74 29 20 22 20 74 6f 20 22 20 28 64 62 3a 74 65 t) " to " (db:te
a5e0: 73 74 2d 67 65 74 2d 69 64 20 6e 65 77 2d 74 65 st-get-id new-te
a5f0: 73 74 64 61 74 29 29 0a 09 20 28 73 71 6c 69 74 stdat)).. (sqlit
a600: 65 33 3a 65 78 65 63 75 74 65 20 0a 09 20 20 64 e3:execute .. d
a610: 62 20 0a 09 20 20 28 63 6f 6e 63 20 22 49 4e 53 b .. (conc "INS
a620: 45 52 54 20 4f 52 20 52 45 50 4c 41 43 45 20 49 ERT OR REPLACE I
a630: 4e 54 4f 20 74 65 73 74 5f 64 61 74 61 20 28 74 NTO test_data (t
a640: 65 73 74 5f 69 64 2c 63 61 74 65 67 6f 72 79 2c est_id,category,
a650: 76 61 72 69 61 62 6c 65 2c 76 61 6c 75 65 2c 65 variable,value,e
a660: 78 70 65 63 74 65 64 5f 76 61 6c 75 65 2c 74 6f xpected_value,to
a670: 6c 2c 75 6e 69 74 73 2c 63 6f 6d 6d 65 6e 74 29 l,units,comment)
a680: 20 22 0a 09 09 22 53 45 4c 45 43 54 20 22 20 28 "..."SELECT " (
a690: 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 6e db:test-get-id n
a6a0: 65 77 2d 74 65 73 74 64 61 74 29 20 22 2c 63 61 ew-testdat) ",ca
a6b0: 74 65 67 6f 72 79 2c 76 61 72 69 61 62 6c 65 2c tegory,variable,
a6c0: 76 61 6c 75 65 2c 65 78 70 65 63 74 65 64 5f 76 value,expected_v
a6d0: 61 6c 75 65 2c 74 6f 6c 2c 75 6e 69 74 73 2c 63 alue,tol,units,c
a6e0: 6f 6d 6d 65 6e 74 20 46 52 4f 4d 20 74 65 73 74 omment FROM test
a6f0: 5f 64 61 74 61 20 57 48 45 52 45 20 74 65 73 74 _data WHERE test
a700: 5f 69 64 3d 3f 3b 22 29 0a 09 20 20 28 64 62 3a _id=?;").. (db:
a710: 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74 test-get-id test
a720: 64 61 74 29 29 0a 09 20 29 29 0a 20 20 20 20 20 dat)).. )).
a730: 70 72 65 76 2d 74 65 73 74 73 29 29 29 0a 09 20 prev-tests)))..
a740: 0a 20 20 20 20 20 0a . .