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 74 65 73 74 64 61 74 20 20 20 20 20 .. (testdat
1e40: 28 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66 (db:get-test-inf
1e50: 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 o db run-id test
1e60: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 -name item-path)
1e70: 29 0a 09 20 28 74 65 73 74 2d 69 64 20 20 20 20 ).. (test-id
1e80: 20 28 69 66 20 74 65 73 74 64 61 74 20 28 64 62 (if testdat (db
1e90: 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 :test-get-id tes
1ea0: 74 64 61 74 29 20 23 66 29 29 0a 09 20 28 6f 74 tdat) #f)).. (ot
1eb0: 68 65 72 64 61 74 20 20 20 20 28 69 66 20 64 61 herdat (if da
1ec0: 74 20 64 61 74 20 28 6d 61 6b 65 2d 68 61 73 68 t dat (make-hash
1ed0: 2d 74 61 62 6c 65 29 29 29 0a 09 20 3b 3b 20 62 -table))).. ;; b
1ee0: 65 66 6f 72 65 20 70 72 6f 63 65 65 64 69 6e 67 efore proceeding
1ef0: 20 77 65 20 6d 75 73 74 20 66 69 6e 64 20 6f 75 we must find ou
1f00: 74 20 69 66 20 74 68 65 20 70 72 65 76 69 6f 75 t if the previou
1f10: 73 20 74 65 73 74 20 28 77 68 65 72 65 20 61 6c s test (where al
1f20: 6c 20 6b 65 79 73 20 6d 61 74 63 68 65 64 20 65 l keys matched e
1f30: 78 63 65 70 74 20 72 75 6e 6e 61 6d 65 29 0a 09 xcept runname)..
1f40: 20 3b 3b 20 77 61 73 20 57 41 49 56 45 44 20 69 ;; was WAIVED i
1f50: 66 20 74 68 69 73 20 74 65 73 74 20 69 73 20 46 f this test is F
1f60: 41 49 4c 0a 09 20 28 77 61 69 76 65 64 20 20 20 AIL.. (waived
1f70: 28 69 66 20 28 65 71 75 61 6c 3f 20 73 74 61 74 (if (equal? stat
1f80: 75 73 20 22 46 41 49 4c 22 29 0a 09 09 20 20 20 us "FAIL")...
1f90: 20 20 20 20 28 6c 65 74 20 28 28 70 72 65 76 2d (let ((prev-
1fa0: 74 65 73 74 20 28 74 65 73 74 3a 67 65 74 2d 70 test (test:get-p
1fb0: 72 65 76 69 6f 75 73 2d 74 65 73 74 2d 72 75 6e revious-test-run
1fc0: 2d 72 65 63 6f 72 64 20 64 62 20 72 75 6e 2d 69 -record db run-i
1fd0: 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d d test-name item
1fe0: 2d 70 61 74 68 29 29 29 0a 09 09 09 20 28 69 66 -path))).... (if
1ff0: 20 70 72 65 76 2d 74 65 73 74 20 3b 3b 20 74 72 prev-test ;; tr
2000: 75 65 20 69 66 20 77 65 20 66 6f 75 6e 64 20 61 ue if we found a
2010: 20 70 72 65 76 69 6f 75 73 20 74 65 73 74 20 69 previous test i
2020: 6e 20 74 68 69 73 20 72 75 6e 20 73 65 72 69 65 n this run serie
2030: 73 0a 09 09 09 20 20 20 20 20 28 6c 65 74 20 28 s.... (let (
2040: 28 70 72 65 76 2d 73 74 61 74 75 73 20 28 64 62 (prev-status (db
2050: 3a 74 65 73 74 2d 67 65 74 2d 73 74 61 74 75 73 :test-get-status
2060: 20 20 20 70 72 65 76 2d 74 65 73 74 29 29 0a 09 prev-test))..
2070: 09 09 09 20 20 20 28 70 72 65 76 2d 73 74 61 74 ... (prev-stat
2080: 65 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d e (db:test-get-
2090: 73 74 61 74 65 20 20 20 20 70 72 65 76 2d 74 65 state prev-te
20a0: 73 74 29 29 0a 09 09 09 09 20 20 20 28 70 72 65 st))..... (pre
20b0: 76 2d 63 6f 6d 6d 65 6e 74 20 28 64 62 3a 74 65 v-comment (db:te
20c0: 73 74 2d 67 65 74 2d 63 6f 6d 6d 65 6e 74 20 70 st-get-comment p
20d0: 72 65 76 2d 74 65 73 74 29 29 29 0a 09 09 09 20 rev-test)))....
20e0: 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 (debug:pri
20f0: 6e 74 20 34 20 22 70 72 65 76 2d 73 74 61 74 75 nt 4 "prev-statu
2100: 73 20 22 20 70 72 65 76 2d 73 74 61 74 75 73 20 s " prev-status
2110: 22 2c 20 70 72 65 76 2d 73 74 61 74 65 20 22 20 ", prev-state "
2120: 70 72 65 76 2d 73 74 61 74 65 20 22 2c 20 70 72 prev-state ", pr
2130: 65 76 2d 63 6f 6d 6d 65 6e 74 20 22 20 70 72 65 ev-comment " pre
2140: 76 2d 63 6f 6d 6d 65 6e 74 29 0a 09 09 09 20 20 v-comment)....
2150: 20 20 20 20 20 28 69 66 20 28 61 6e 64 20 28 65 (if (and (e
2160: 71 75 61 6c 3f 20 70 72 65 76 2d 73 74 61 74 65 qual? prev-state
2170: 20 20 22 43 4f 4d 50 4c 45 54 45 44 22 29 0a 09 "COMPLETED")..
2180: 09 09 09 09 28 65 71 75 61 6c 3f 20 70 72 65 76 ....(equal? prev
2190: 2d 73 74 61 74 75 73 20 22 57 41 49 56 45 44 22 -status "WAIVED"
21a0: 29 29 0a 09 09 09 09 20 20 20 70 72 65 76 2d 63 ))..... prev-c
21b0: 6f 6d 6d 65 6e 74 20 3b 3b 20 77 61 69 76 65 64 omment ;; waived
21c0: 20 69 73 20 65 69 74 68 65 72 20 74 68 65 20 63 is either the c
21d0: 6f 6d 6d 65 6e 74 20 6f 72 20 23 66 0a 09 09 09 omment or #f....
21e0: 09 20 20 20 23 66 29 29 0a 09 09 09 20 20 20 20 . #f))....
21f0: 20 23 66 29 29 0a 09 09 20 20 20 20 20 20 20 23 #f))... #
2200: 66 29 29 29 0a 20 20 20 20 28 69 66 20 77 61 69 f))). (if wai
2210: 76 65 64 20 28 73 65 74 21 20 72 65 61 6c 2d 73 ved (set! real-s
2220: 74 61 74 75 73 20 22 57 41 49 56 45 44 22 29 29 tatus "WAIVED"))
2230: 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e . (debug:prin
2240: 74 20 34 20 22 72 65 61 6c 2d 73 74 61 74 75 73 t 4 "real-status
2250: 20 22 20 72 65 61 6c 2d 73 74 61 74 75 73 20 22 " real-status "
2260: 2c 20 77 61 69 76 65 64 20 22 20 77 61 69 76 65 , waived " waive
2270: 64 20 22 2c 20 73 74 61 74 75 73 20 22 20 73 74 d ", status " st
2280: 61 74 75 73 29 0a 0a 20 20 20 20 3b 3b 20 75 70 atus).. ;; up
2290: 64 61 74 65 20 74 68 65 20 70 72 69 6d 61 72 79 date the primary
22a0: 20 72 65 63 6f 72 64 20 49 46 20 73 74 61 74 65 record IF state
22b0: 20 41 4e 44 20 73 74 61 74 75 73 20 61 72 65 20 AND status are
22c0: 64 65 66 69 6e 65 64 0a 20 20 20 20 28 69 66 20 defined. (if
22d0: 28 61 6e 64 20 73 74 61 74 65 20 73 74 61 74 75 (and state statu
22e0: 73 29 0a 09 28 73 71 6c 69 74 65 33 3a 65 78 65 s)..(sqlite3:exe
22f0: 63 75 74 65 20 64 62 20 22 55 50 44 41 54 45 20 cute db "UPDATE
2300: 74 65 73 74 73 20 53 45 54 20 73 74 61 74 65 3d tests SET state=
2310: 3f 2c 73 74 61 74 75 73 3d 3f 2c 65 76 65 6e 74 ?,status=?,event
2320: 5f 74 69 6d 65 3d 73 74 72 66 74 69 6d 65 28 27 _time=strftime('
2330: 25 73 27 2c 27 6e 6f 77 27 29 20 57 48 45 52 45 %s','now') WHERE
2340: 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 run_id=? AND te
2350: 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 stname=? AND ite
2360: 6d 5f 70 61 74 68 3d 3f 3b 22 20 0a 09 09 09 20 m_path=?;" ....
2370: 73 74 61 74 65 20 72 65 61 6c 2d 73 74 61 74 75 state real-statu
2380: 73 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 s run-id test-na
2390: 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29 0a 0a me item-path))..
23a0: 20 20 20 20 3b 3b 20 69 66 20 73 74 61 74 75 73 ;; if status
23b0: 20 69 73 20 22 41 55 54 4f 22 20 74 68 65 6e 20 is "AUTO" then
23c0: 63 61 6c 6c 20 72 6f 6c 6c 75 70 0a 20 20 20 20 call rollup.
23d0: 28 69 66 20 28 61 6e 64 20 74 65 73 74 2d 69 64 (if (and test-id
23e0: 20 73 74 61 74 65 20 73 74 61 74 75 73 20 28 65 state status (e
23f0: 71 75 61 6c 3f 20 73 74 61 74 75 73 20 22 41 55 qual? status "AU
2400: 54 4f 22 29 29 20 0a 09 28 64 62 3a 74 65 73 74 TO")) ..(db:test
2410: 2d 64 61 74 61 2d 72 6f 6c 6c 75 70 20 64 62 20 -data-rollup db
2420: 74 65 73 74 2d 69 64 29 29 0a 0a 20 20 20 20 3b test-id)).. ;
2430: 3b 20 61 64 64 20 6d 65 74 61 64 61 74 61 20 28 ; add metadata (
2440: 6e 65 65 64 20 74 6f 20 64 6f 20 74 68 69 73 20 need to do this
2450: 77 61 79 20 74 6f 20 61 76 6f 69 64 20 53 51 4c way to avoid SQL
2460: 20 69 6e 6a 65 63 74 69 6f 6e 20 69 73 73 75 65 injection issue
2470: 73 29 0a 0a 20 20 20 20 3b 3b 20 3a 66 69 72 73 s).. ;; :firs
2480: 74 5f 65 72 72 0a 20 20 20 20 28 6c 65 74 20 28 t_err. (let (
2490: 28 76 61 6c 20 28 68 61 73 68 2d 74 61 62 6c 65 (val (hash-table
24a0: 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 6f 74 68 -ref/default oth
24b0: 65 72 64 61 74 20 22 3a 66 69 72 73 74 5f 65 72 erdat ":first_er
24c0: 72 22 20 23 66 29 29 29 0a 20 20 20 20 20 20 28 r" #f))). (
24d0: 69 66 20 76 61 6c 0a 09 20 20 28 73 71 6c 69 74 if val.. (sqlit
24e0: 65 33 3a 65 78 65 63 75 74 65 20 64 62 20 22 55 e3:execute db "U
24f0: 50 44 41 54 45 20 74 65 73 74 73 20 53 45 54 20 PDATE tests SET
2500: 66 69 72 73 74 5f 65 72 72 3d 3f 20 57 48 45 52 first_err=? WHER
2510: 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 E run_id=? AND t
2520: 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 estname=? AND it
2530: 65 6d 5f 70 61 74 68 3d 3f 3b 22 20 76 61 6c 20 em_path=?;" val
2540: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 run-id test-name
2550: 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 0a 20 item-path)))..
2560: 20 20 20 3b 3b 20 3a 66 69 72 73 74 5f 77 61 72 ;; :first_war
2570: 6e 0a 20 20 20 20 28 6c 65 74 20 28 28 76 61 6c n. (let ((val
2580: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 (hash-table-ref
2590: 2f 64 65 66 61 75 6c 74 20 6f 74 68 65 72 64 61 /default otherda
25a0: 74 20 22 3a 66 69 72 73 74 5f 77 61 72 6e 22 20 t ":first_warn"
25b0: 23 66 29 29 29 0a 20 20 20 20 20 20 28 69 66 20 #f))). (if
25c0: 76 61 6c 0a 09 20 20 28 73 71 6c 69 74 65 33 3a val.. (sqlite3:
25d0: 65 78 65 63 75 74 65 20 64 62 20 22 55 50 44 41 execute db "UPDA
25e0: 54 45 20 74 65 73 74 73 20 53 45 54 20 66 69 72 TE tests SET fir
25f0: 73 74 5f 77 61 72 6e 3d 3f 20 57 48 45 52 45 20 st_warn=? WHERE
2600: 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 run_id=? AND tes
2610: 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d tname=? AND item
2620: 5f 70 61 74 68 3d 3f 3b 22 20 76 61 6c 20 72 75 _path=?;" val ru
2630: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 n-id test-name i
2640: 74 65 6d 2d 70 61 74 68 29 29 29 0a 0a 20 20 20 tem-path)))..
2650: 20 28 6c 65 74 20 28 28 63 61 74 65 67 6f 72 79 (let ((category
2660: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 (hash-table-ref
2670: 2f 64 65 66 61 75 6c 74 20 6f 74 68 65 72 64 61 /default otherda
2680: 74 20 22 3a 63 61 74 65 67 6f 72 79 22 20 22 22 t ":category" ""
2690: 29 29 0a 09 20 20 28 76 61 72 69 61 62 6c 65 20 )).. (variable
26a0: 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f (hash-table-ref/
26b0: 64 65 66 61 75 6c 74 20 6f 74 68 65 72 64 61 74 default otherdat
26c0: 20 22 3a 76 61 72 69 61 62 6c 65 22 20 22 22 29 ":variable" "")
26d0: 29 0a 09 20 20 28 76 61 6c 75 65 20 20 20 20 28 ).. (value (
26e0: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 hash-table-ref/d
26f0: 65 66 61 75 6c 74 20 6f 74 68 65 72 64 61 74 20 efault otherdat
2700: 22 3a 76 61 6c 75 65 22 20 20 20 20 23 66 29 29 ":value" #f))
2710: 0a 09 20 20 28 65 78 70 65 63 74 65 64 20 28 68 .. (expected (h
2720: 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 ash-table-ref/de
2730: 66 61 75 6c 74 20 6f 74 68 65 72 64 61 74 20 22 fault otherdat "
2740: 3a 65 78 70 65 63 74 65 64 22 20 23 66 29 29 0a :expected" #f)).
2750: 09 20 20 28 74 6f 6c 20 20 20 20 20 20 28 68 61 . (tol (ha
2760: 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 sh-table-ref/def
2770: 61 75 6c 74 20 6f 74 68 65 72 64 61 74 20 22 3a ault otherdat ":
2780: 74 6f 6c 22 20 20 20 20 20 20 23 66 29 29 0a 09 tol" #f))..
2790: 20 20 28 75 6e 69 74 73 20 20 20 20 28 68 61 73 (units (has
27a0: 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 h-table-ref/defa
27b0: 75 6c 74 20 6f 74 68 65 72 64 61 74 20 22 3a 75 ult otherdat ":u
27c0: 6e 69 74 73 22 20 20 20 20 22 22 29 29 0a 09 20 nits" ""))..
27d0: 20 28 64 63 6f 6d 6d 65 6e 74 20 28 68 61 73 68 (dcomment (hash
27e0: 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 -table-ref/defau
27f0: 6c 74 20 6f 74 68 65 72 64 61 74 20 22 3a 63 6f lt otherdat ":co
2800: 6d 6d 65 6e 74 22 20 20 22 22 29 29 29 0a 20 20 mment" ""))).
2810: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 (debug:print
2820: 20 34 20 0a 09 09 20 20 20 22 63 61 74 65 67 6f 4 ... "catego
2830: 72 79 3a 20 22 20 63 61 74 65 67 6f 72 79 20 22 ry: " category "
2840: 2c 20 76 61 72 69 61 62 6c 65 3a 20 22 20 76 61 , variable: " va
2850: 72 69 61 62 6c 65 20 22 2c 20 76 61 6c 75 65 3a riable ", value:
2860: 20 22 20 76 61 6c 75 65 0a 09 09 20 20 20 22 2c " value... ",
2870: 20 65 78 70 65 63 74 65 64 3a 20 22 20 65 78 70 expected: " exp
2880: 65 63 74 65 64 20 22 2c 20 74 6f 6c 3a 20 22 20 ected ", tol: "
2890: 74 6f 6c 20 22 2c 20 75 6e 69 74 73 3a 20 22 20 tol ", units: "
28a0: 75 6e 69 74 73 29 0a 20 20 20 20 20 20 28 69 66 units). (if
28b0: 20 28 61 6e 64 20 76 61 6c 75 65 20 65 78 70 65 (and value expe
28c0: 63 74 65 64 20 74 6f 6c 29 20 3b 3b 20 61 6c 6c cted tol) ;; all
28d0: 20 74 68 72 65 65 20 72 65 71 75 69 72 65 64 0a three required.
28e0: 09 20 20 28 64 62 3a 63 73 76 2d 3e 74 65 73 74 . (db:csv->test
28f0: 2d 64 61 74 61 20 64 62 20 74 65 73 74 2d 69 64 -data db test-id
2900: 20 0a 09 09 09 20 20 20 20 20 28 63 6f 6e 63 20 .... (conc
2910: 63 61 74 65 67 6f 72 79 20 22 2c 22 0a 09 09 09 category ","....
2920: 09 20 20 20 76 61 72 69 61 62 6c 65 20 22 2c 22 . variable ","
2930: 0a 09 09 09 09 20 20 20 76 61 6c 75 65 20 20 20 ..... value
2940: 20 22 2c 22 0a 09 09 09 09 20 20 20 65 78 70 65 ","..... expe
2950: 63 74 65 64 20 22 2c 22 0a 09 09 09 09 20 20 20 cted ",".....
2960: 74 6f 6c 20 20 20 20 20 20 22 2c 22 0a 09 09 09 tol ","....
2970: 09 20 20 20 75 6e 69 74 73 20 20 20 20 22 2c 22 . units ","
2980: 0a 09 09 09 09 20 20 20 64 63 6f 6d 6d 65 6e 74 ..... dcomment
2990: 20 22 2c 22 29 29 29 29 0a 09 09 09 09 20 20 20 ",")))).....
29a0: 0a 20 20 20 20 3b 3b 20 6e 65 65 64 20 74 6f 20 . ;; need to
29b0: 75 70 64 61 74 65 20 74 68 65 20 74 6f 70 20 74 update the top t
29c0: 65 73 74 20 72 65 63 6f 72 64 20 69 66 20 50 41 est record if PA
29d0: 53 53 20 6f 72 20 46 41 49 4c 20 61 6e 64 20 74 SS or FAIL and t
29e0: 68 69 73 20 69 73 20 61 20 73 75 62 74 65 73 74 his is a subtest
29f0: 0a 20 20 20 20 28 69 66 20 28 61 6e 64 20 28 6e . (if (and (n
2a00: 6f 74 20 28 65 71 75 61 6c 3f 20 69 74 65 6d 2d ot (equal? item-
2a10: 70 61 74 68 20 22 22 29 29 0a 09 20 20 20 20 20 path ""))..
2a20: 28 6f 72 20 28 65 71 75 61 6c 3f 20 73 74 61 74 (or (equal? stat
2a30: 75 73 20 22 50 41 53 53 22 29 0a 09 09 20 28 65 us "PASS")... (e
2a40: 71 75 61 6c 3f 20 73 74 61 74 75 73 20 22 57 41 qual? status "WA
2a50: 52 4e 22 29 0a 09 09 20 28 65 71 75 61 6c 3f 20 RN")... (equal?
2a60: 73 74 61 74 75 73 20 22 46 41 49 4c 22 29 0a 09 status "FAIL")..
2a70: 09 20 28 65 71 75 61 6c 3f 20 73 74 61 74 75 73 . (equal? status
2a80: 20 22 57 41 49 56 45 44 22 29 0a 09 09 20 28 65 "WAIVED")... (e
2a90: 71 75 61 6c 3f 20 73 74 61 74 75 73 20 22 52 55 qual? status "RU
2aa0: 4e 4e 49 4e 47 22 29 29 29 0a 09 28 62 65 67 69 NNING")))..(begi
2ab0: 6e 0a 09 20 20 28 73 71 6c 69 74 65 33 3a 65 78 n.. (sqlite3:ex
2ac0: 65 63 75 74 65 20 0a 09 20 20 20 64 62 0a 09 20 ecute .. db..
2ad0: 20 20 22 55 50 44 41 54 45 20 74 65 73 74 73 20 "UPDATE tests
2ae0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 53 45 . SE
2af0: 54 20 66 61 69 6c 5f 63 6f 75 6e 74 3d 28 53 45 T fail_count=(SE
2b00: 4c 45 43 54 20 63 6f 75 6e 74 28 69 64 29 20 46 LECT count(id) F
2b10: 52 4f 4d 20 74 65 73 74 73 20 57 48 45 52 45 20 ROM tests WHERE
2b20: 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 run_id=? AND tes
2b30: 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d tname=? AND item
2b40: 5f 70 61 74 68 20 21 3d 20 27 27 20 41 4e 44 20 _path != '' AND
2b50: 73 74 61 74 75 73 3d 27 46 41 49 4c 27 29 2c 0a status='FAIL'),.
2b60: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2b70: 20 70 61 73 73 5f 63 6f 75 6e 74 3d 28 53 45 4c pass_count=(SEL
2b80: 45 43 54 20 63 6f 75 6e 74 28 69 64 29 20 46 52 ECT count(id) FR
2b90: 4f 4d 20 74 65 73 74 73 20 57 48 45 52 45 20 72 OM tests WHERE r
2ba0: 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 un_id=? AND test
2bb0: 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f name=? AND item_
2bc0: 70 61 74 68 20 21 3d 20 27 27 20 41 4e 44 20 28 path != '' AND (
2bd0: 73 74 61 74 75 73 3d 27 50 41 53 53 27 20 4f 52 status='PASS' OR
2be0: 20 73 74 61 74 75 73 3d 27 57 41 52 4e 27 20 4f status='WARN' O
2bf0: 52 20 73 74 61 74 75 73 3d 27 57 41 49 56 45 44 R status='WAIVED
2c00: 27 29 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 ')).
2c10: 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 WHERE run_id=?
2c20: 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 AND testname=? A
2c30: 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 27 27 3b ND item_path='';
2c40: 22 0a 09 20 20 20 72 75 6e 2d 69 64 20 74 65 73 ".. run-id tes
2c50: 74 2d 6e 61 6d 65 20 72 75 6e 2d 69 64 20 74 65 t-name run-id te
2c60: 73 74 2d 6e 61 6d 65 20 72 75 6e 2d 69 64 20 74 st-name run-id t
2c70: 65 73 74 2d 6e 61 6d 65 29 0a 09 20 20 28 69 66 est-name).. (if
2c80: 20 28 65 71 75 61 6c 3f 20 73 74 61 74 75 73 20 (equal? status
2c90: 22 52 55 4e 4e 49 4e 47 22 29 20 3b 3b 20 72 75 "RUNNING") ;; ru
2ca0: 6e 6e 69 6e 67 20 74 61 6b 65 73 20 70 72 69 6f nning takes prio
2cb0: 72 69 74 79 20 6f 76 65 72 20 61 6c 6c 20 6f 74 rity over all ot
2cc0: 68 65 72 20 73 74 61 74 65 73 2c 20 66 6f 72 63 her states, forc
2cd0: 65 20 74 68 65 20 74 65 73 74 20 73 74 61 74 65 e the test state
2ce0: 20 74 6f 20 52 55 4e 4e 49 4e 47 0a 09 20 20 20 to RUNNING..
2cf0: 20 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63 (sqlite3:exec
2d00: 75 74 65 20 64 62 20 22 55 50 44 41 54 45 20 74 ute db "UPDATE t
2d10: 65 73 74 73 20 53 45 54 20 73 74 61 74 65 3d 3f ests SET state=?
2d20: 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 WHERE run_id=?
2d30: 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 AND testname=? A
2d40: 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 27 27 3b ND item_path='';
2d50: 22 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 " run-id test-na
2d60: 6d 65 29 0a 09 20 20 20 20 20 20 28 73 71 6c 69 me).. (sqli
2d70: 74 65 33 3a 65 78 65 63 75 74 65 0a 09 20 20 20 te3:execute..
2d80: 20 20 20 20 64 62 0a 09 20 20 20 20 20 20 20 22 db.. "
2d90: 55 50 44 41 54 45 20 74 65 73 74 73 0a 20 20 20 UPDATE tests.
2da0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2db0: 20 20 20 20 53 45 54 20 73 74 61 74 65 3d 43 41 SET state=CA
2dc0: 53 45 20 57 48 45 4e 20 28 53 45 4c 45 43 54 20 SE WHEN (SELECT
2dd0: 63 6f 75 6e 74 28 69 64 29 20 46 52 4f 4d 20 74 count(id) FROM t
2de0: 65 73 74 73 20 57 48 45 52 45 20 72 75 6e 5f 69 ests WHERE run_i
2df0: 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 d=? AND testname
2e00: 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 =? AND item_path
2e10: 20 21 3d 20 27 27 20 41 4e 44 20 73 74 61 74 65 != '' AND state
2e20: 20 69 6e 20 28 27 52 55 4e 4e 49 4e 47 27 2c 27 in ('RUNNING','
2e30: 4e 4f 54 5f 53 54 41 52 54 45 44 27 29 29 20 3e NOT_STARTED')) >
2e40: 20 30 20 54 48 45 4e 20 0a 20 20 20 20 20 20 20 0 THEN .
2e50: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2e60: 20 20 20 27 52 55 4e 4e 49 4e 47 27 0a 20 20 20 'RUNNING'.
2e70: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2e80: 20 20 20 20 45 4c 53 45 20 27 43 4f 4d 50 4c 45 ELSE 'COMPLE
2e90: 54 45 44 27 20 45 4e 44 2c 0a 20 20 20 20 20 20 TED' END,.
2ea0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2eb0: 20 20 20 20 73 74 61 74 75 73 3d 43 41 53 45 20 status=CASE
2ec0: 57 48 45 4e 20 66 61 69 6c 5f 63 6f 75 6e 74 20 WHEN fail_count
2ed0: 3e 20 30 20 54 48 45 4e 20 27 46 41 49 4c 27 20 > 0 THEN 'FAIL'
2ee0: 57 48 45 4e 20 70 61 73 73 5f 63 6f 75 6e 74 20 WHEN pass_count
2ef0: 3e 20 30 20 41 4e 44 20 66 61 69 6c 5f 63 6f 75 > 0 AND fail_cou
2f00: 6e 74 3d 30 20 54 48 45 4e 20 27 50 41 53 53 27 nt=0 THEN 'PASS'
2f10: 20 45 4c 53 45 20 27 55 4e 4b 4e 4f 57 4e 27 20 ELSE 'UNKNOWN'
2f20: 45 4e 44 0a 20 20 20 20 20 20 20 20 20 20 20 20 END.
2f30: 20 20 20 20 20 20 20 20 20 20 20 57 48 45 52 45 WHERE
2f40: 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 run_id=? AND te
2f50: 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 stname=? AND ite
2f60: 6d 5f 70 61 74 68 3d 27 27 3b 22 0a 09 20 20 20 m_path='';"..
2f70: 20 20 20 20 72 75 6e 2d 69 64 20 74 65 73 74 2d run-id test-
2f80: 6e 61 6d 65 20 72 75 6e 2d 69 64 20 74 65 73 74 name run-id test
2f90: 2d 6e 61 6d 65 29 29 29 29 0a 20 20 20 20 28 69 -name)))). (i
2fa0: 66 20 28 6f 72 20 28 61 6e 64 20 28 73 74 72 69 f (or (and (stri
2fb0: 6e 67 3f 20 63 6f 6d 6d 65 6e 74 29 0a 09 09 20 ng? comment)...
2fc0: 28 73 74 72 69 6e 67 2d 6d 61 74 63 68 20 28 72 (string-match (r
2fd0: 65 67 65 78 70 20 22 5c 5c 53 2b 22 29 20 63 6f egexp "\\S+") co
2fe0: 6d 6d 65 6e 74 29 29 0a 09 20 20 20 20 77 61 69 mment)).. wai
2ff0: 76 65 64 29 0a 09 28 73 71 6c 69 74 65 33 3a 65 ved)..(sqlite3:e
3000: 78 65 63 75 74 65 20 64 62 20 22 55 50 44 41 54 xecute db "UPDAT
3010: 45 20 74 65 73 74 73 20 53 45 54 20 63 6f 6d 6d E tests SET comm
3020: 65 6e 74 3d 3f 20 57 48 45 52 45 20 72 75 6e 5f ent=? WHERE run_
3030: 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d id=? AND testnam
3040: 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 e=? AND item_pat
3050: 68 3d 3f 3b 22 0a 09 09 09 20 28 69 66 20 77 61 h=?;".... (if wa
3060: 69 76 65 64 20 77 61 69 76 65 64 20 63 6f 6d 6d ived waived comm
3070: 65 6e 74 29 20 72 75 6e 2d 69 64 20 74 65 73 74 ent) run-id test
3080: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 -name item-path)
3090: 29 0a 20 20 20 20 29 29 0a 0a 28 64 65 66 69 6e ). ))..(defin
30a0: 65 20 28 74 65 73 74 2d 73 65 74 2d 6c 6f 67 21 e (test-set-log!
30b0: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d db run-id test-
30c0: 6e 61 6d 65 20 69 74 65 6d 64 61 74 20 6c 6f 67 name itemdat log
30d0: 66 29 20 0a 20 20 28 6c 65 74 20 28 28 69 74 65 f) . (let ((ite
30e0: 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c 69 73 m-path (item-lis
30f0: 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74 29 t->path itemdat)
3100: 29 29 0a 20 20 20 20 28 73 71 6c 69 74 65 33 3a )). (sqlite3:
3110: 65 78 65 63 75 74 65 20 64 62 20 22 55 50 44 41 execute db "UPDA
3120: 54 45 20 74 65 73 74 73 20 53 45 54 20 66 69 6e TE tests SET fin
3130: 61 6c 5f 6c 6f 67 66 3d 3f 20 57 48 45 52 45 20 al_logf=? WHERE
3140: 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 run_id=? AND tes
3150: 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d tname=? AND item
3160: 5f 70 61 74 68 3d 3f 3b 22 20 0a 09 09 20 20 20 _path=?;" ...
3170: 20 20 6c 6f 67 66 20 72 75 6e 2d 69 64 20 74 65 logf run-id te
3180: 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 st-name item-pat
3190: 68 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 h)))..(define (t
31a0: 65 73 74 2d 73 65 74 2d 74 6f 70 6c 6f 67 21 20 est-set-toplog!
31b0: 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e db run-id test-n
31c0: 61 6d 65 20 6c 6f 67 66 29 20 0a 20 20 28 73 71 ame logf) . (sq
31d0: 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 64 62 lite3:execute db
31e0: 20 22 55 50 44 41 54 45 20 74 65 73 74 73 20 53 "UPDATE tests S
31f0: 45 54 20 66 69 6e 61 6c 5f 6c 6f 67 66 3d 3f 20 ET final_logf=?
3200: 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 WHERE run_id=? A
3210: 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e ND testname=? AN
3220: 44 20 69 74 65 6d 5f 70 61 74 68 3d 27 27 3b 22 D item_path='';"
3230: 20 0a 09 09 20 20 20 6c 6f 67 66 20 72 75 6e 2d ... logf run-
3240: 69 64 20 74 65 73 74 2d 6e 61 6d 65 29 29 0a 0a id test-name))..
3250: 28 64 65 66 69 6e 65 20 28 74 65 73 74 73 3a 73 (define (tests:s
3260: 75 6d 6d 61 72 69 7a 65 2d 69 74 65 6d 73 20 64 ummarize-items d
3270: 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 b run-id test-na
3280: 6d 65 20 66 6f 72 63 65 29 0a 20 20 3b 3b 20 69 me force). ;; i
3290: 66 20 6e 6f 74 20 66 6f 72 63 65 20 74 68 65 6e f not force then
32a0: 20 6f 6e 6c 79 20 75 70 64 61 74 65 20 74 68 65 only update the
32b0: 20 72 65 63 6f 72 64 20 69 66 20 6f 6e 65 20 6f record if one o
32c0: 66 20 74 68 65 73 65 20 69 73 20 74 72 75 65 3a f these is true:
32d0: 0a 20 20 3b 3b 20 20 20 31 2e 20 6c 6f 67 66 20 . ;; 1. logf
32e0: 69 73 20 22 6c 6f 67 2f 66 69 6e 61 6c 2e 6c 6f is "log/final.lo
32f0: 67 0a 20 20 3b 3b 20 20 20 32 2e 20 6c 6f 67 66 g. ;; 2. logf
3300: 20 69 73 20 73 61 6d 65 20 61 73 20 6f 75 74 70 is same as outp
3310: 75 74 66 69 6c 65 6e 61 6d 65 0a 20 20 28 6c 65 utfilename. (le
3320: 74 20 28 28 6f 75 74 70 75 74 66 69 6c 65 6e 61 t ((outputfilena
3330: 6d 65 20 28 63 6f 6e 63 20 22 6d 65 67 61 74 65 me (conc "megate
3340: 73 74 2d 72 6f 6c 6c 75 70 2d 22 20 74 65 73 74 st-rollup-" test
3350: 2d 6e 61 6d 65 20 22 2e 68 74 6d 6c 22 29 29 0a -name ".html")).
3360: 09 28 6f 72 69 67 2d 64 69 72 20 20 20 20 20 20 .(orig-dir
3370: 20 28 63 75 72 72 65 6e 74 2d 64 69 72 65 63 74 (current-direct
3380: 6f 72 79 29 29 0a 09 28 6c 6f 67 66 20 20 20 20 ory))..(logf
3390: 20 20 20 20 20 20 20 23 66 29 29 0a 20 20 20 20 #f)).
33a0: 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 (sqlite3:for-eac
33b0: 68 2d 72 6f 77 20 0a 20 20 20 20 20 28 6c 61 6d h-row . (lam
33c0: 62 64 61 20 28 70 61 74 68 20 66 69 6e 61 6c 5f bda (path final_
33d0: 6c 6f 67 66 29 0a 20 20 20 20 20 20 20 28 73 65 logf). (se
33e0: 74 21 20 6c 6f 67 66 20 66 69 6e 61 6c 5f 6c 6f t! logf final_lo
33f0: 67 66 29 0a 20 20 20 20 20 20 20 28 69 66 20 28 gf). (if (
3400: 64 69 72 65 63 74 6f 72 79 3f 20 70 61 74 68 29 directory? path)
3410: 0a 09 20 20 20 28 62 65 67 69 6e 0a 09 20 20 20 .. (begin..
3420: 20 20 28 70 72 69 6e 74 20 22 46 6f 75 6e 64 20 (print "Found
3430: 70 61 74 68 3a 20 22 20 70 61 74 68 29 0a 09 20 path: " path)..
3440: 20 20 20 20 28 63 68 61 6e 67 65 2d 64 69 72 65 (change-dire
3450: 63 74 6f 72 79 20 70 61 74 68 29 29 0a 09 20 20 ctory path))..
3460: 20 20 20 3b 3b 20 28 73 65 74 21 20 6f 75 74 70 ;; (set! outp
3470: 75 74 66 69 6c 65 6e 61 6d 65 20 28 63 6f 6e 63 utfilename (conc
3480: 20 70 61 74 68 20 22 2f 22 20 6f 75 74 70 75 74 path "/" output
3490: 66 69 6c 65 6e 61 6d 65 29 29 29 0a 09 20 20 20 filename)))..
34a0: 28 70 72 69 6e 74 20 22 4e 6f 20 73 75 63 68 20 (print "No such
34b0: 70 61 74 68 3a 20 22 20 70 61 74 68 29 29 29 0a path: " path))).
34c0: 20 20 20 20 20 64 62 20 0a 20 20 20 20 20 22 53 db . "S
34d0: 45 4c 45 43 54 20 72 75 6e 64 69 72 2c 66 69 6e ELECT rundir,fin
34e0: 61 6c 5f 6c 6f 67 66 20 46 52 4f 4d 20 74 65 73 al_logf FROM tes
34f0: 74 73 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d ts WHERE run_id=
3500: 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f ? AND testname=?
3510: 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 27 AND item_path='
3520: 27 3b 22 0a 20 20 20 20 20 72 75 6e 2d 69 64 20 ';". run-id
3530: 74 65 73 74 2d 6e 61 6d 65 29 0a 20 20 20 20 28 test-name). (
3540: 70 72 69 6e 74 20 22 73 75 6d 6d 61 72 69 7a 65 print "summarize
3550: 2d 69 74 65 6d 73 20 77 69 74 68 20 6c 6f 67 66 -items with logf
3560: 20 22 20 6c 6f 67 66 29 0a 20 20 20 20 28 69 66 " logf). (if
3570: 20 28 6f 72 20 28 65 71 75 61 6c 3f 20 6c 6f 67 (or (equal? log
3580: 66 20 22 6c 6f 67 73 2f 66 69 6e 61 6c 2e 6c 6f f "logs/final.lo
3590: 67 22 29 0a 09 20 20 20 20 28 65 71 75 61 6c 3f g").. (equal?
35a0: 20 6c 6f 67 66 20 6f 75 74 70 75 74 66 69 6c 65 logf outputfile
35b0: 6e 61 6d 65 29 0a 09 20 20 20 20 66 6f 72 63 65 name).. force
35c0: 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 28 69 66 )..(begin.. (if
35d0: 20 28 6f 62 74 61 69 6e 2d 64 6f 74 2d 6c 6f 63 (obtain-dot-loc
35e0: 6b 20 6f 75 74 70 75 74 66 69 6c 65 6e 61 6d 65 k outputfilename
35f0: 20 31 20 32 30 20 33 30 29 20 3b 3b 20 72 65 74 1 20 30) ;; ret
3600: 72 79 20 65 76 65 72 79 20 73 65 63 6f 6e 64 20 ry every second
3610: 66 6f 72 20 32 30 20 73 65 63 6f 6e 64 73 2c 20 for 20 seconds,
3620: 63 61 6c 6c 20 69 74 20 64 65 61 64 20 61 66 74 call it dead aft
3630: 65 72 20 33 30 20 73 65 63 6f 6e 64 73 20 61 6e er 30 seconds an
3640: 64 20 73 74 65 61 6c 20 74 68 65 20 6c 6f 63 6b d steal the lock
3650: 0a 09 20 20 20 20 20 20 28 70 72 69 6e 74 20 22 .. (print "
3660: 4f 62 74 61 69 6e 65 64 20 6c 6f 63 6b 20 66 6f Obtained lock fo
3670: 72 20 22 20 6f 75 74 70 75 74 66 69 6c 65 6e 61 r " outputfilena
3680: 6d 65 29 0a 09 20 20 20 20 20 20 28 70 72 69 6e me).. (prin
3690: 74 20 22 46 61 69 6c 65 64 20 74 6f 20 6f 62 74 t "Failed to obt
36a0: 61 69 6e 20 6c 6f 63 6b 20 66 6f 72 20 22 20 6f ain lock for " o
36b0: 75 74 70 75 74 66 69 6c 65 6e 61 6d 65 29 29 0a utputfilename)).
36c0: 09 20 20 28 6c 65 74 20 28 28 6f 75 70 20 20 20 . (let ((oup
36d0: 20 28 6f 70 65 6e 2d 6f 75 74 70 75 74 2d 66 69 (open-output-fi
36e0: 6c 65 20 6f 75 74 70 75 74 66 69 6c 65 6e 61 6d le outputfilenam
36f0: 65 29 29 0a 09 09 28 63 6f 75 6e 74 73 20 28 6d e))...(counts (m
3700: 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29 ake-hash-table))
3710: 0a 09 09 28 73 74 61 74 65 63 6f 75 6e 74 73 20 ...(statecounts
3720: 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 (make-hash-table
3730: 29 29 0a 09 09 28 6f 75 74 74 78 74 20 22 22 29 ))...(outtxt "")
3740: 0a 09 09 28 74 6f 74 20 20 20 20 30 29 29 0a 09 ...(tot 0))..
3750: 20 20 20 20 28 77 69 74 68 2d 6f 75 74 70 75 74 (with-output
3760: 2d 74 6f 2d 70 6f 72 74 0a 09 09 6f 75 70 0a 09 -to-port...oup..
3770: 20 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 29 (lambda ()
3780: 0a 09 09 28 73 65 74 21 20 6f 75 74 74 78 74 20 ...(set! outtxt
3790: 28 63 6f 6e 63 20 6f 75 74 74 78 74 20 22 3c 68 (conc outtxt "<h
37a0: 74 6d 6c 3e 3c 74 69 74 6c 65 3e 53 75 6d 6d 61 tml><title>Summa
37b0: 72 79 3a 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 ry: " test-name
37c0: 0a 09 09 09 09 20 20 20 22 3c 2f 74 69 74 6c 65 ..... "</title
37d0: 3e 3c 62 6f 64 79 3e 3c 68 32 3e 53 75 6d 6d 61 ><body><h2>Summa
37e0: 72 79 20 66 6f 72 20 22 20 74 65 73 74 2d 6e 61 ry for " test-na
37f0: 6d 65 20 22 3c 2f 68 32 3e 22 29 29 0a 09 09 28 me "</h2>"))...(
3800: 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 sqlite3:for-each
3810: 2d 72 6f 77 20 0a 09 09 20 28 6c 61 6d 62 64 61 -row ... (lambda
3820: 20 28 69 64 20 69 74 65 6d 70 61 74 68 20 73 74 (id itempath st
3830: 61 74 65 20 73 74 61 74 75 73 20 72 75 6e 5f 64 ate status run_d
3840: 75 72 61 74 69 6f 6e 20 6c 6f 67 66 20 63 6f 6d uration logf com
3850: 6d 65 6e 74 29 0a 09 09 20 20 20 28 68 61 73 68 ment)... (hash
3860: 2d 74 61 62 6c 65 2d 73 65 74 21 20 63 6f 75 6e -table-set! coun
3870: 74 73 20 73 74 61 74 75 73 20 28 2b 20 31 20 28 ts status (+ 1 (
3880: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 hash-table-ref/d
3890: 65 66 61 75 6c 74 20 63 6f 75 6e 74 73 20 73 74 efault counts st
38a0: 61 74 75 73 20 30 29 29 29 0a 09 09 20 20 20 28 atus 0)))... (
38b0: 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74 21 20 hash-table-set!
38c0: 73 74 61 74 65 63 6f 75 6e 74 73 20 73 74 61 74 statecounts stat
38d0: 65 20 28 2b 20 31 20 28 68 61 73 68 2d 74 61 62 e (+ 1 (hash-tab
38e0: 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 73 le-ref/default s
38f0: 74 61 74 65 63 6f 75 6e 74 73 20 73 74 61 74 65 tatecounts state
3900: 20 30 29 29 29 0a 09 09 20 20 20 28 73 65 74 21 0)))... (set!
3910: 20 6f 75 74 74 78 74 20 28 63 6f 6e 63 20 6f 75 outtxt (conc ou
3920: 74 74 78 74 20 22 3c 74 72 3e 22 0a 09 09 09 09 ttxt "<tr>".....
3930: 20 20 20 20 20 20 22 3c 74 64 3e 3c 61 20 68 72 "<td><a hr
3940: 65 66 3d 5c 22 22 20 69 74 65 6d 70 61 74 68 20 ef=\"" itempath
3950: 22 2f 22 20 6c 6f 67 66 20 22 5c 22 3e 20 22 20 "/" logf "\"> "
3960: 69 74 65 6d 70 61 74 68 20 22 3c 2f 61 3e 3c 2f itempath "</a></
3970: 74 64 3e 22 20 0a 09 09 09 09 20 20 20 20 20 20 td>" .....
3980: 22 3c 74 64 3e 22 20 73 74 61 74 65 20 20 20 20 "<td>" state
3990: 22 3c 2f 74 64 3e 22 20 0a 09 09 09 09 20 20 20 "</td>" .....
39a0: 20 20 20 22 3c 74 64 3e 3c 66 6f 6e 74 20 63 6f "<td><font co
39b0: 6c 6f 72 3d 22 20 28 63 6f 6d 6d 6f 6e 3a 67 65 lor=" (common:ge
39c0: 74 2d 63 6f 6c 6f 72 2d 66 72 6f 6d 2d 73 74 61 t-color-from-sta
39d0: 74 75 73 20 73 74 61 74 75 73 29 0a 09 09 09 09 tus status).....
39e0: 20 20 20 20 20 20 22 3e 22 20 20 20 73 74 61 74 ">" stat
39f0: 75 73 20 20 20 22 3c 2f 66 6f 6e 74 3e 3c 2f 74 us "</font></t
3a00: 64 3e 22 0a 09 09 09 09 20 20 20 20 20 20 22 3c d>"..... "<
3a10: 74 64 3e 22 20 28 69 66 20 28 65 71 75 61 6c 3f td>" (if (equal?
3a20: 20 63 6f 6d 6d 65 6e 74 20 22 22 29 0a 09 09 09 comment "")....
3a30: 09 09 09 20 22 26 6e 62 73 70 3b 22 0a 09 09 09 ... " "....
3a40: 09 09 09 20 63 6f 6d 6d 65 6e 74 29 20 22 3c 2f ... comment) "</
3a50: 74 64 3e 22 0a 09 09 09 09 09 09 20 22 3c 2f 74 td>"....... "</t
3a60: 72 3e 22 29 29 29 0a 09 09 20 64 62 0a 09 09 20 r>")))... db...
3a70: 22 53 45 4c 45 43 54 20 69 64 2c 69 74 65 6d 5f "SELECT id,item_
3a80: 70 61 74 68 2c 73 74 61 74 65 2c 73 74 61 74 75 path,state,statu
3a90: 73 2c 72 75 6e 5f 64 75 72 61 74 69 6f 6e 2c 66 s,run_duration,f
3aa0: 69 6e 61 6c 5f 6c 6f 67 66 2c 63 6f 6d 6d 65 6e inal_logf,commen
3ab0: 74 20 46 52 4f 4d 20 74 65 73 74 73 20 57 48 45 t FROM tests WHE
3ac0: 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 RE run_id=? AND
3ad0: 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 testname=? AND i
3ae0: 74 65 6d 5f 70 61 74 68 20 21 3d 20 27 27 3b 22 tem_path != '';"
3af0: 0a 09 09 20 72 75 6e 2d 69 64 20 74 65 73 74 2d ... run-id test-
3b00: 6e 61 6d 65 29 0a 0a 09 09 28 70 72 69 6e 74 20 name)....(print
3b10: 22 3c 74 61 62 6c 65 3e 3c 74 72 3e 3c 74 64 20 "<table><tr><td
3b20: 76 61 6c 69 67 6e 3d 5c 22 74 6f 70 5c 22 3e 22 valign=\"top\">"
3b30: 29 0a 09 09 3b 3b 20 50 72 69 6e 74 20 6f 75 74 )...;; Print out
3b40: 20 73 74 61 74 73 20 66 6f 72 20 73 74 61 74 75 stats for statu
3b50: 73 0a 09 09 28 73 65 74 21 20 74 6f 74 20 30 29 s...(set! tot 0)
3b60: 0a 09 09 28 70 72 69 6e 74 20 22 3c 74 61 62 6c ...(print "<tabl
3b70: 65 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d 5c 22 e cellspacing=\"
3b80: 30 5c 22 20 62 6f 72 64 65 72 3d 5c 22 31 5c 22 0\" border=\"1\"
3b90: 3e 3c 74 72 3e 3c 74 64 20 63 6f 6c 73 70 61 6e ><tr><td colspan
3ba0: 3d 5c 22 32 5c 22 3e 3c 68 32 3e 53 74 61 74 65 =\"2\"><h2>State
3bb0: 20 73 74 61 74 73 3c 2f 68 32 3e 3c 2f 74 64 3e stats</h2></td>
3bc0: 3c 2f 74 72 3e 22 29 0a 09 09 28 66 6f 72 2d 65 </tr>")...(for-e
3bd0: 61 63 68 20 28 6c 61 6d 62 64 61 20 28 73 74 61 ach (lambda (sta
3be0: 74 65 29 0a 09 09 09 20 20 20 20 28 73 65 74 21 te).... (set!
3bf0: 20 74 6f 74 20 28 2b 20 74 6f 74 20 28 68 61 73 tot (+ tot (has
3c00: 68 2d 74 61 62 6c 65 2d 72 65 66 20 73 74 61 74 h-table-ref stat
3c10: 65 63 6f 75 6e 74 73 20 73 74 61 74 65 29 29 29 ecounts state)))
3c20: 0a 09 09 09 20 20 20 20 28 70 72 69 6e 74 20 22 .... (print "
3c30: 3c 74 72 3e 3c 74 64 3e 22 20 73 74 61 74 65 20 <tr><td>" state
3c40: 22 3c 2f 74 64 3e 3c 74 64 3e 22 20 28 68 61 73 "</td><td>" (has
3c50: 68 2d 74 61 62 6c 65 2d 72 65 66 20 73 74 61 74 h-table-ref stat
3c60: 65 63 6f 75 6e 74 73 20 73 74 61 74 65 29 20 22 ecounts state) "
3c70: 3c 2f 74 64 3e 3c 2f 74 72 3e 22 29 29 0a 09 09 </td></tr>"))...
3c80: 09 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 6b . (hash-table-k
3c90: 65 79 73 20 73 74 61 74 65 63 6f 75 6e 74 73 29 eys statecounts)
3ca0: 29 0a 09 09 28 70 72 69 6e 74 20 22 3c 74 72 3e )...(print "<tr>
3cb0: 3c 74 64 3e 54 6f 74 61 6c 3c 2f 74 64 3e 3c 74 <td>Total</td><t
3cc0: 64 3e 22 20 74 6f 74 20 22 3c 2f 74 64 3e 3c 2f d>" tot "</td></
3cd0: 74 72 3e 3c 2f 74 61 62 6c 65 3e 22 29 0a 09 09 tr></table>")...
3ce0: 28 70 72 69 6e 74 20 22 3c 2f 74 64 3e 3c 74 64 (print "</td><td
3cf0: 20 76 61 6c 69 67 6e 3d 5c 22 74 6f 70 5c 22 3e valign=\"top\">
3d00: 22 29 0a 09 09 3b 3b 20 50 72 69 6e 74 20 6f 75 ")...;; Print ou
3d10: 74 20 73 74 61 74 73 20 66 6f 72 20 73 74 61 74 t stats for stat
3d20: 65 0a 09 09 28 73 65 74 21 20 74 6f 74 20 30 29 e...(set! tot 0)
3d30: 0a 09 09 28 70 72 69 6e 74 20 22 3c 74 61 62 6c ...(print "<tabl
3d40: 65 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d 5c 22 e cellspacing=\"
3d50: 30 5c 22 20 62 6f 72 64 65 72 3d 5c 22 31 5c 22 0\" border=\"1\"
3d60: 3e 3c 74 72 3e 3c 74 64 20 63 6f 6c 73 70 61 6e ><tr><td colspan
3d70: 3d 5c 22 32 5c 22 3e 3c 68 32 3e 53 74 61 74 75 =\"2\"><h2>Statu
3d80: 73 20 73 74 61 74 73 3c 2f 68 32 3e 3c 2f 74 64 s stats</h2></td
3d90: 3e 3c 2f 74 72 3e 22 29 0a 09 09 28 66 6f 72 2d ></tr>")...(for-
3da0: 65 61 63 68 20 28 6c 61 6d 62 64 61 20 28 73 74 each (lambda (st
3db0: 61 74 75 73 29 0a 09 09 09 20 20 20 20 28 73 65 atus).... (se
3dc0: 74 21 20 74 6f 74 20 28 2b 20 74 6f 74 20 28 68 t! tot (+ tot (h
3dd0: 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 20 63 6f ash-table-ref co
3de0: 75 6e 74 73 20 73 74 61 74 75 73 29 29 29 0a 09 unts status)))..
3df0: 09 09 20 20 20 20 28 70 72 69 6e 74 20 22 3c 74 .. (print "<t
3e00: 72 3e 3c 74 64 3e 3c 66 6f 6e 74 20 63 6f 6c 6f r><td><font colo
3e10: 72 3d 5c 22 22 20 28 63 6f 6d 6d 6f 6e 3a 67 65 r=\"" (common:ge
3e20: 74 2d 63 6f 6c 6f 72 2d 66 72 6f 6d 2d 73 74 61 t-color-from-sta
3e30: 74 75 73 20 73 74 61 74 75 73 29 20 22 5c 22 3e tus status) "\">
3e40: 22 20 73 74 61 74 75 73 0a 09 09 09 09 20 20 20 " status.....
3e50: 22 3c 2f 66 6f 6e 74 3e 3c 2f 74 64 3e 3c 74 64 "</font></td><td
3e60: 3e 22 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 >" (hash-table-r
3e70: 65 66 20 63 6f 75 6e 74 73 20 73 74 61 74 75 73 ef counts status
3e80: 29 20 22 3c 2f 74 64 3e 3c 2f 74 72 3e 22 29 29 ) "</td></tr>"))
3e90: 0a 09 09 09 20 20 28 68 61 73 68 2d 74 61 62 6c .... (hash-tabl
3ea0: 65 2d 6b 65 79 73 20 63 6f 75 6e 74 73 29 29 0a e-keys counts)).
3eb0: 09 09 28 70 72 69 6e 74 20 22 3c 74 72 3e 3c 74 ..(print "<tr><t
3ec0: 64 3e 54 6f 74 61 6c 3c 2f 74 64 3e 3c 74 64 3e d>Total</td><td>
3ed0: 22 20 74 6f 74 20 22 3c 2f 74 64 3e 3c 2f 74 72 " tot "</td></tr
3ee0: 3e 3c 2f 74 61 62 6c 65 3e 22 29 0a 09 09 28 70 ></table>")...(p
3ef0: 72 69 6e 74 20 22 3c 2f 74 64 3e 3c 2f 74 64 3e rint "</td></td>
3f00: 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e 22 29 0a </tr></table>").
3f10: 0a 09 09 28 70 72 69 6e 74 20 22 3c 74 61 62 6c ...(print "<tabl
3f20: 65 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d 5c 22 e cellspacing=\"
3f30: 30 5c 22 20 62 6f 72 64 65 72 3d 5c 22 31 5c 22 0\" border=\"1\"
3f40: 3e 22 20 0a 09 09 20 20 20 20 20 20 20 22 3c 74 >" ... "<t
3f50: 72 3e 3c 74 64 3e 49 74 65 6d 3c 2f 74 64 3e 3c r><td>Item</td><
3f60: 74 64 3e 53 74 61 74 65 3c 2f 74 64 3e 3c 74 64 td>State</td><td
3f70: 3e 53 74 61 74 75 73 3c 2f 74 64 3e 3c 74 64 3e >Status</td><td>
3f80: 43 6f 6d 6d 65 6e 74 3c 2f 74 64 3e 22 0a 09 09 Comment</td>"...
3f90: 20 20 20 20 20 20 20 6f 75 74 74 78 74 20 22 3c outtxt "<
3fa0: 2f 74 61 62 6c 65 3e 3c 2f 62 6f 64 79 3e 3c 2f /table></body></
3fb0: 68 74 6d 6c 3e 22 29 0a 09 09 28 72 65 6c 65 61 html>")...(relea
3fc0: 73 65 2d 64 6f 74 2d 6c 6f 63 6b 20 6f 75 74 70 se-dot-lock outp
3fd0: 75 74 66 69 6c 65 6e 61 6d 65 29 29 29 0a 09 20 utfilename)))..
3fe0: 20 20 20 28 63 6c 6f 73 65 2d 6f 75 74 70 75 74 (close-output
3ff0: 2d 70 6f 72 74 20 6f 75 70 29 0a 09 20 20 20 20 -port oup)..
4000: 28 63 68 61 6e 67 65 2d 64 69 72 65 63 74 6f 72 (change-director
4010: 79 20 6f 72 69 67 2d 64 69 72 29 0a 09 20 20 20 y orig-dir)..
4020: 20 28 74 65 73 74 2d 73 65 74 2d 74 6f 70 6c 6f (test-set-toplo
4030: 67 21 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 g! db run-id tes
4040: 74 2d 6e 61 6d 65 20 6f 75 74 70 75 74 66 69 6c t-name outputfil
4050: 65 6e 61 6d 65 29 0a 09 20 20 20 20 29 29 29 29 ename).. ))))
4060: 29 0a 0a 3b 3b 20 3b 3b 20 54 4f 44 4f 3a 20 43 )..;; ;; TODO: C
4070: 6f 6e 76 65 72 67 65 20 74 68 69 73 20 77 69 74 onverge this wit
4080: 68 20 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e h db:get-test-in
4090: 66 6f 0a 3b 3b 20 28 64 65 66 69 6e 65 20 28 72 fo.;; (define (r
40a0: 75 6e 73 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66 uns:get-test-inf
40b0: 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 o db run-id test
40c0: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 -name item-path)
40d0: 0a 3b 3b 20 20 20 28 6c 65 74 20 28 28 72 65 73 .;; (let ((res
40e0: 20 23 66 29 29 20 3b 3b 20 28 76 65 63 74 6f 72 #f)) ;; (vector
40f0: 20 23 66 20 23 66 20 23 66 20 23 66 20 23 66 20 #f #f #f #f #f
4100: 23 66 29 29 29 0a 3b 3b 20 20 20 20 20 28 73 71 #f))).;; (sq
4110: 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 lite3:for-each-r
4120: 6f 77 20 0a 3b 3b 20 20 20 20 20 20 28 6c 61 6d ow .;; (lam
4130: 62 64 61 20 28 69 64 20 72 75 6e 2d 69 64 20 74 bda (id run-id t
4140: 65 73 74 2d 6e 61 6d 65 20 73 74 61 74 65 20 73 est-name state s
4150: 74 61 74 75 73 29 0a 3b 3b 20 20 20 20 20 20 20 tatus).;;
4160: 20 28 73 65 74 21 20 72 65 73 20 28 76 65 63 74 (set! res (vect
4170: 6f 72 20 69 64 20 72 75 6e 2d 69 64 20 74 65 73 or id run-id tes
4180: 74 2d 6e 61 6d 65 20 73 74 61 74 65 20 73 74 61 t-name state sta
4190: 74 75 73 20 69 74 65 6d 2d 70 61 74 68 29 29 29 tus item-path)))
41a0: 0a 3b 3b 20 20 20 20 20 20 64 62 20 22 53 45 4c .;; db "SEL
41b0: 45 43 54 20 69 64 2c 72 75 6e 5f 69 64 2c 74 65 ECT id,run_id,te
41c0: 73 74 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 61 stname,state,sta
41d0: 74 75 73 20 46 52 4f 4d 20 74 65 73 74 73 20 57 tus FROM tests W
41e0: 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e HERE run_id=? AN
41f0: 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 D testname=? AND
4200: 20 69 74 65 6d 5f 70 61 74 68 3d 3f 3b 22 0a 3b item_path=?;".;
4210: 3b 20 20 20 20 20 20 72 75 6e 2d 69 64 20 74 65 ; run-id te
4220: 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 st-name item-pat
4230: 68 29 0a 3b 3b 20 20 20 20 20 72 65 73 29 29 0a h).;; res)).
4240: 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69 6e 65 20 .(define-inline
4250: 28 74 65 73 74 3a 67 65 74 2d 69 64 20 76 65 63 (test:get-id vec
4260: 29 20 20 20 20 20 20 20 28 76 65 63 74 6f 72 2d ) (vector-
4270: 72 65 66 20 76 65 63 20 30 29 29 0a 28 64 65 66 ref vec 0)).(def
4280: 69 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65 73 74 ine-inline (test
4290: 3a 67 65 74 2d 72 75 6e 5f 69 64 20 76 65 63 29 :get-run_id vec)
42a0: 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20 76 (vector-ref v
42b0: 65 63 20 31 29 29 0a 28 64 65 66 69 6e 65 2d 69 ec 1)).(define-i
42c0: 6e 6c 69 6e 65 20 28 74 65 73 74 3a 67 65 74 2d nline (test:get-
42d0: 74 65 73 74 2d 6e 61 6d 65 20 76 65 63 29 28 76 test-name vec)(v
42e0: 65 63 74 6f 72 2d 72 65 66 20 76 65 63 20 32 29 ector-ref vec 2)
42f0: 29 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69 6e 65 ).(define-inline
4300: 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 (test:get-state
4310: 20 76 65 63 29 20 20 20 20 28 76 65 63 74 6f 72 vec) (vector
4320: 2d 72 65 66 20 76 65 63 20 33 29 29 0a 28 64 65 -ref vec 3)).(de
4330: 66 69 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65 73 fine-inline (tes
4340: 74 3a 67 65 74 2d 73 74 61 74 75 73 20 76 65 63 t:get-status vec
4350: 29 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20 ) (vector-ref
4360: 76 65 63 20 34 29 29 0a 28 64 65 66 69 6e 65 2d vec 4)).(define-
4370: 69 6e 6c 69 6e 65 20 28 74 65 73 74 3a 67 65 74 inline (test:get
4380: 2d 69 74 65 6d 2d 70 61 74 68 20 76 65 63 29 28 -item-path vec)(
4390: 76 65 63 74 6f 72 2d 72 65 66 20 76 65 63 20 35 vector-ref vec 5
43a0: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 72 75 6e ))..(define (run
43b0: 73 3a 74 65 73 74 2d 67 65 74 2d 66 75 6c 6c 2d s:test-get-full-
43c0: 70 61 74 68 20 74 65 73 74 29 0a 20 20 28 6c 65 path test). (le
43d0: 74 2a 20 28 28 74 65 73 74 6e 61 6d 65 20 28 64 t* ((testname (d
43e0: 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e b:test-get-testn
43f0: 61 6d 65 20 20 20 74 65 73 74 29 29 0a 09 20 28 ame test)).. (
4400: 69 74 65 6d 70 61 74 68 20 28 64 62 3a 74 65 73 itempath (db:tes
4410: 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 t-get-item-path
4420: 74 65 73 74 29 29 29 0a 20 20 20 20 28 63 6f 6e test))). (con
4430: 63 20 74 65 73 74 6e 61 6d 65 20 28 69 66 20 28 c testname (if (
4440: 65 71 75 61 6c 3f 20 69 74 65 6d 70 61 74 68 20 equal? itempath
4450: 22 22 29 20 22 22 20 28 63 6f 6e 63 20 22 28 22 "") "" (conc "("
4460: 20 69 74 65 6d 70 61 74 68 20 22 29 22 29 29 29 itempath ")")))
4470: 29 29 0a 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69 ))..(define-inli
4480: 6e 65 20 28 74 65 73 74 3a 74 65 73 74 2d 67 65 ne (test:test-ge
4490: 74 2d 66 75 6c 6c 6e 61 6d 65 20 74 65 73 74 29 t-fullname test)
44a0: 0a 20 20 20 28 63 6f 6e 63 20 28 64 62 3a 74 65 . (conc (db:te
44b0: 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 st-get-testname
44c0: 74 65 73 74 29 0a 09 20 28 69 66 20 28 65 71 75 test).. (if (equ
44d0: 61 6c 3f 20 28 64 62 3a 74 65 73 74 2d 67 65 74 al? (db:test-get
44e0: 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 29 -item-path test)
44f0: 20 22 22 29 0a 09 20 20 20 20 20 22 22 0a 09 20 "").. ""..
4500: 20 20 20 20 28 63 6f 6e 63 20 22 28 22 20 28 64 (conc "(" (d
4510: 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d b:test-get-item-
4520: 70 61 74 68 20 74 65 73 74 29 20 22 29 22 29 29 path test) ")"))
4530: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 63 68 65 ))..(define (che
4540: 63 6b 2d 76 61 6c 69 64 2d 69 74 65 6d 73 20 63 ck-valid-items c
4550: 6c 61 73 73 20 69 74 65 6d 29 0a 20 20 28 6c 65 lass item). (le
4560: 74 20 28 28 76 61 6c 69 64 2d 76 61 6c 75 65 73 t ((valid-values
4570: 20 28 6c 65 74 20 28 28 73 20 28 63 6f 6e 66 69 (let ((s (confi
4580: 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67 g-lookup *config
4590: 64 61 74 2a 20 22 76 61 6c 69 64 76 61 6c 75 65 dat* "validvalue
45a0: 73 22 20 63 6c 61 73 73 29 29 29 0a 09 09 09 28 s" class)))....(
45b0: 69 66 20 73 20 28 73 74 72 69 6e 67 2d 73 70 6c if s (string-spl
45c0: 69 74 20 73 29 20 23 66 29 29 29 29 0a 20 20 20 it s) #f)))).
45d0: 20 28 69 66 20 76 61 6c 69 64 2d 76 61 6c 75 65 (if valid-value
45e0: 73 0a 09 28 69 66 20 28 6d 65 6d 62 65 72 20 69 s..(if (member i
45f0: 74 65 6d 20 76 61 6c 69 64 2d 76 61 6c 75 65 73 tem valid-values
4600: 29 0a 09 20 20 20 20 69 74 65 6d 20 23 66 29 0a ).. item #f).
4610: 09 69 74 65 6d 29 29 29 0a 0a 28 64 65 66 69 6e .item)))..(defin
4620: 65 20 28 74 65 73 74 73 74 65 70 2d 73 65 74 2d e (teststep-set-
4630: 73 74 61 74 75 73 21 20 64 62 20 72 75 6e 2d 69 status! db run-i
4640: 64 20 74 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 d test-name test
4650: 73 74 65 70 2d 6e 61 6d 65 20 73 74 61 74 65 2d step-name state-
4660: 69 6e 20 73 74 61 74 75 73 2d 69 6e 20 69 74 65 in status-in ite
4670: 6d 64 61 74 20 63 6f 6d 6d 65 6e 74 29 0a 20 20 mdat comment).
4680: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 (debug:print 4 "
4690: 72 75 6e 2d 69 64 3a 20 22 20 72 75 6e 2d 69 64 run-id: " run-id
46a0: 20 22 20 74 65 73 74 2d 6e 61 6d 65 3a 20 22 20 " test-name: "
46b0: 74 65 73 74 2d 6e 61 6d 65 29 0a 20 20 28 6c 65 test-name). (le
46c0: 74 2a 20 28 28 73 74 61 74 65 20 20 20 20 20 28 t* ((state (
46d0: 63 68 65 63 6b 2d 76 61 6c 69 64 2d 69 74 65 6d check-valid-item
46e0: 73 20 22 73 74 61 74 65 22 20 73 74 61 74 65 2d s "state" state-
46f0: 69 6e 29 29 0a 09 20 28 73 74 61 74 75 73 20 20 in)).. (status
4700: 20 20 28 63 68 65 63 6b 2d 76 61 6c 69 64 2d 69 (check-valid-i
4710: 74 65 6d 73 20 22 73 74 61 74 75 73 22 20 73 74 tems "status" st
4720: 61 74 75 73 2d 69 6e 29 29 0a 09 20 28 69 74 65 atus-in)).. (ite
4730: 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c 69 73 m-path (item-lis
4740: 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74 29 t->path itemdat)
4750: 29 0a 09 20 28 74 65 73 74 64 61 74 20 20 20 28 ).. (testdat (
4760: 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f db:get-test-info
4770: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d db run-id test-
4780: 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29 name item-path))
4790: 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 ). (debug:pri
47a0: 6e 74 20 35 20 22 74 65 73 74 64 61 74 3a 20 22 nt 5 "testdat: "
47b0: 20 74 65 73 74 64 61 74 29 0a 20 20 20 20 28 69 testdat). (i
47c0: 66 20 28 61 6e 64 20 74 65 73 74 64 61 74 20 3b f (and testdat ;
47d0: 3b 20 69 66 20 74 68 65 20 73 65 63 74 69 6f 6e ; if the section
47e0: 20 65 78 69 73 74 73 20 74 68 65 6e 20 66 6f 72 exists then for
47f0: 63 65 20 73 70 65 63 69 66 69 63 61 74 69 6f 6e ce specification
4800: 20 42 55 47 2c 20 49 20 64 6f 6e 27 74 20 6c 69 BUG, I don't li
4810: 6b 65 20 68 6f 77 20 74 68 69 73 20 77 6f 72 6b ke how this work
4820: 73 2e 0a 09 20 20 20 20 20 28 6f 72 20 28 6e 6f s... (or (no
4830: 74 20 73 74 61 74 65 29 28 6e 6f 74 20 73 74 61 t state)(not sta
4840: 74 75 73 29 29 29 0a 09 28 64 65 62 75 67 3a 70 tus)))..(debug:p
4850: 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e 47 3a rint 0 "WARNING:
4860: 20 49 6e 76 61 6c 69 64 20 22 20 28 69 66 20 73 Invalid " (if s
4870: 74 61 74 75 73 20 22 73 74 61 74 75 73 22 20 22 tatus "status" "
4880: 73 74 61 74 65 22 29 0a 09 20 20 20 20 20 20 20 state")..
4890: 22 20 76 61 6c 75 65 20 5c 22 22 20 28 69 66 20 " value \"" (if
48a0: 73 74 61 74 75 73 20 73 74 61 74 65 2d 69 6e 20 status state-in
48b0: 73 74 61 74 75 73 2d 69 6e 29 20 22 5c 22 2c 20 status-in) "\",
48c0: 75 70 64 61 74 65 20 79 6f 75 72 20 76 61 6c 69 update your vali
48d0: 64 76 61 6c 75 65 73 20 73 65 63 74 69 6f 6e 20 dvalues section
48e0: 69 6e 20 6d 65 67 61 74 65 73 74 2e 63 6f 6e 66 in megatest.conf
48f0: 69 67 22 29 29 0a 20 20 20 20 28 69 66 20 74 65 ig")). (if te
4900: 73 74 64 61 74 0a 09 28 6c 65 74 20 28 28 74 65 stdat..(let ((te
4910: 73 74 2d 69 64 20 28 74 65 73 74 3a 67 65 74 2d st-id (test:get-
4920: 69 64 20 74 65 73 74 64 61 74 29 29 29 0a 09 20 id testdat)))..
4930: 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 (sqlite3:execut
4940: 65 20 64 62 20 0a 09 09 09 22 49 4e 53 45 52 54 e db ...."INSERT
4950: 20 4f 52 20 52 45 50 4c 41 43 45 20 69 6e 74 6f OR REPLACE into
4960: 20 74 65 73 74 5f 73 74 65 70 73 20 28 74 65 73 test_steps (tes
4970: 74 5f 69 64 2c 73 74 65 70 6e 61 6d 65 2c 73 74 t_id,stepname,st
4980: 61 74 65 2c 73 74 61 74 75 73 2c 65 76 65 6e 74 ate,status,event
4990: 5f 74 69 6d 65 2c 63 6f 6d 6d 65 6e 74 29 20 56 _time,comment) V
49a0: 41 4c 55 45 53 28 3f 2c 3f 2c 3f 2c 3f 2c 73 74 ALUES(?,?,?,?,st
49b0: 72 66 74 69 6d 65 28 27 25 73 27 2c 27 6e 6f 77 rftime('%s','now
49c0: 27 29 2c 3f 29 3b 22 0a 09 09 09 74 65 73 74 2d '),?);"....test-
49d0: 69 64 20 74 65 73 74 73 74 65 70 2d 6e 61 6d 65 id teststep-name
49e0: 20 73 74 61 74 65 2d 69 6e 20 73 74 61 74 75 73 state-in status
49f0: 2d 69 6e 20 28 69 66 20 63 6f 6d 6d 65 6e 74 20 -in (if comment
4a00: 63 6f 6d 6d 65 6e 74 20 22 22 29 29 29 0a 09 28 comment "")))..(
4a10: 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 debug:print 0 "E
4a20: 52 52 4f 52 3a 20 43 61 6e 27 74 20 75 70 64 61 RROR: Can't upda
4a30: 74 65 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 te " test-name "
4a40: 20 66 6f 72 20 72 75 6e 20 22 20 72 75 6e 2d 69 for run " run-i
4a50: 64 20 22 20 2d 3e 20 6e 6f 20 73 75 63 68 20 74 d " -> no such t
4a60: 65 73 74 20 69 6e 20 64 62 22 29 29 29 29 0a 0a est in db"))))..
4a70: 28 64 65 66 69 6e 65 20 28 74 65 73 74 2d 67 65 (define (test-ge
4a80: 74 2d 6b 69 6c 6c 2d 72 65 71 75 65 73 74 20 64 t-kill-request d
4a90: 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 b run-id test-na
4aa0: 6d 65 20 69 74 65 6d 64 61 74 29 0a 20 20 28 6c me itemdat). (l
4ab0: 65 74 2a 20 28 28 69 74 65 6d 2d 70 61 74 68 20 et* ((item-path
4ac0: 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 (item-list->path
4ad0: 20 69 74 65 6d 64 61 74 29 29 0a 09 20 28 74 65 itemdat)).. (te
4ae0: 73 74 64 61 74 20 20 20 28 64 62 3a 67 65 74 2d stdat (db:get-
4af0: 74 65 73 74 2d 69 6e 66 6f 20 64 62 20 72 75 6e test-info db run
4b00: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 -id test-name it
4b10: 65 6d 2d 70 61 74 68 29 29 29 0a 20 20 20 20 28 em-path))). (
4b20: 65 71 75 61 6c 3f 20 28 74 65 73 74 3a 67 65 74 equal? (test:get
4b30: 2d 73 74 61 74 65 20 74 65 73 74 64 61 74 29 20 -state testdat)
4b40: 22 4b 49 4c 4c 52 45 51 22 29 29 29 0a 0a 28 64 "KILLREQ")))..(d
4b50: 65 66 69 6e 65 20 28 74 65 73 74 2d 73 65 74 2d efine (test-set-
4b60: 6d 65 74 61 2d 69 6e 66 6f 20 64 62 20 72 75 6e meta-info db run
4b70: 2d 69 64 20 74 65 73 74 6e 61 6d 65 20 69 74 65 -id testname ite
4b80: 6d 64 61 74 29 0a 20 20 28 6c 65 74 20 28 28 69 mdat). (let ((i
4b90: 74 65 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c tem-path (item-l
4ba0: 69 73 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 ist->path itemda
4bb0: 74 29 29 0a 09 28 63 70 75 6c 6f 61 64 20 20 28 t))..(cpuload (
4bc0: 67 65 74 2d 63 70 75 2d 6c 6f 61 64 29 29 0a 09 get-cpu-load))..
4bd0: 28 68 6f 73 74 6e 61 6d 65 20 28 67 65 74 2d 68 (hostname (get-h
4be0: 6f 73 74 2d 6e 61 6d 65 29 29 0a 09 28 64 69 73 ost-name))..(dis
4bf0: 6b 66 72 65 65 20 28 67 65 74 2d 64 66 20 28 63 kfree (get-df (c
4c00: 75 72 72 65 6e 74 2d 64 69 72 65 63 74 6f 72 79 urrent-directory
4c10: 29 29 29 0a 09 28 75 6e 61 6d 65 20 20 20 20 28 )))..(uname (
4c20: 67 65 74 2d 75 6e 61 6d 65 20 22 2d 73 72 76 70 get-uname "-srvp
4c30: 69 6f 22 29 29 0a 09 28 72 75 6e 70 61 74 68 20 io"))..(runpath
4c40: 20 28 63 75 72 72 65 6e 74 2d 64 69 72 65 63 74 (current-direct
4c50: 6f 72 79 29 29 29 0a 20 20 20 20 28 73 71 6c 69 ory))). (sqli
4c60: 74 65 33 3a 65 78 65 63 75 74 65 20 64 62 20 22 te3:execute db "
4c70: 55 50 44 41 54 45 20 74 65 73 74 73 20 53 45 54 UPDATE tests SET
4c80: 20 68 6f 73 74 3d 3f 2c 63 70 75 6c 6f 61 64 3d host=?,cpuload=
4c90: 3f 2c 64 69 73 6b 66 72 65 65 3d 3f 2c 75 6e 61 ?,diskfree=?,una
4ca0: 6d 65 3d 3f 2c 72 75 6e 64 69 72 3d 3f 20 57 48 me=?,rundir=? WH
4cb0: 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 ERE run_id=? AND
4cc0: 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 testname=? AND
4cd0: 69 74 65 6d 5f 70 61 74 68 3d 3f 3b 22 0a 09 09 item_path=?;"...
4ce0: 20 20 68 6f 73 74 6e 61 6d 65 0a 09 09 20 20 63 hostname... c
4cf0: 70 75 6c 6f 61 64 0a 09 09 20 20 64 69 73 6b 66 puload... diskf
4d00: 72 65 65 0a 09 09 20 20 75 6e 61 6d 65 0a 09 09 ree... uname...
4d10: 20 20 72 75 6e 70 61 74 68 0a 09 09 20 20 72 75 runpath... ru
4d20: 6e 2d 69 64 0a 09 09 20 20 74 65 73 74 6e 61 6d n-id... testnam
4d30: 65 0a 09 09 20 20 69 74 65 6d 2d 70 61 74 68 29 e... item-path)
4d40: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73 ))..(define (tes
4d50: 74 2d 75 70 64 61 74 65 2d 6d 65 74 61 2d 69 6e t-update-meta-in
4d60: 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 fo db run-id tes
4d70: 74 6e 61 6d 65 20 69 74 65 6d 64 61 74 20 6d 69 tname itemdat mi
4d80: 6e 75 74 65 73 20 63 70 75 6c 6f 61 64 20 64 69 nutes cpuload di
4d90: 73 6b 66 72 65 65 20 74 6d 70 66 72 65 65 29 0a skfree tmpfree).
4da0: 20 20 28 6c 65 74 20 28 28 69 74 65 6d 2d 70 61 (let ((item-pa
4db0: 74 68 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 th (item-list->p
4dc0: 61 74 68 20 69 74 65 6d 64 61 74 29 29 29 0a 20 ath itemdat))).
4dd0: 20 20 20 28 69 66 20 28 6e 6f 74 20 69 74 65 6d (if (not item
4de0: 2d 70 61 74 68 29 28 62 65 67 69 6e 20 28 64 65 -path)(begin (de
4df0: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52 bug:print 0 "WAR
4e00: 4e 49 4e 47 3a 20 49 54 45 4d 50 41 54 48 20 6e NING: ITEMPATH n
4e10: 6f 74 20 73 65 74 2e 22 29 20 20 20 28 73 65 74 ot set.") (set
4e20: 21 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29 29 ! item-path ""))
4e30: 29 0a 20 20 20 20 3b 3b 20 28 6c 65 74 20 28 28 ). ;; (let ((
4e40: 74 65 73 74 69 6e 66 6f 20 28 64 62 3a 67 65 74 testinfo (db:get
4e50: 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 20 72 75 -test-info db ru
4e60: 6e 2d 69 64 20 74 65 73 74 6e 61 6d 65 20 69 74 n-id testname it
4e70: 65 6d 2d 70 61 74 68 29 29 29 0a 20 20 20 20 3b em-path))). ;
4e80: 3b 20 20 20 28 69 66 20 28 61 6e 64 20 28 6e 6f ; (if (and (no
4e90: 74 20 28 65 71 75 61 6c 3f 20 28 64 62 3a 74 65 t (equal? (db:te
4ea0: 73 74 2d 67 65 74 2d 73 74 61 74 75 73 20 74 65 st-get-status te
4eb0: 73 74 69 6e 66 6f 29 20 22 43 4f 4d 50 4c 45 54 stinfo) "COMPLET
4ec0: 45 44 22 29 29 0a 20 20 20 20 3b 3b 20 20 20 20 ED")). ;;
4ed0: 20 20 20 20 20 20 20 20 28 6e 6f 74 20 28 65 71 (not (eq
4ee0: 75 61 6c 3f 20 28 64 62 3a 74 65 73 74 2d 67 65 ual? (db:test-ge
4ef0: 74 2d 73 74 61 74 75 73 20 74 65 73 74 69 6e 66 t-status testinf
4f00: 6f 29 20 22 4b 49 4c 4c 52 45 51 22 29 29 0a 20 o) "KILLREQ")).
4f10: 20 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63 (sqlite3:exec
4f20: 75 74 65 0a 20 20 20 20 20 64 62 0a 20 20 20 20 ute. db.
4f30: 20 22 55 50 44 41 54 45 20 74 65 73 74 73 20 53 "UPDATE tests S
4f40: 45 54 20 63 70 75 6c 6f 61 64 3d 3f 2c 64 69 73 ET cpuload=?,dis
4f50: 6b 66 72 65 65 3d 3f 2c 72 75 6e 5f 64 75 72 61 kfree=?,run_dura
4f60: 74 69 6f 6e 3d 3f 2c 73 74 61 74 65 3d 27 52 55 tion=?,state='RU
4f70: 4e 4e 49 4e 47 27 20 57 48 45 52 45 20 72 75 6e NNING' WHERE run
4f80: 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 _id=? AND testna
4f90: 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 me=? AND item_pa
4fa0: 74 68 3d 3f 20 41 4e 44 20 73 74 61 74 65 20 4e th=? AND state N
4fb0: 4f 54 20 49 4e 20 28 27 43 4f 4d 50 4c 45 54 45 OT IN ('COMPLETE
4fc0: 44 27 2c 27 4b 49 4c 4c 52 45 51 27 2c 27 4b 49 D','KILLREQ','KI
4fd0: 4c 4c 45 44 27 29 3b 22 0a 20 20 20 20 20 63 70 LLED');". cp
4fe0: 75 6c 6f 61 64 0a 20 20 20 20 20 64 69 73 6b 66 uload. diskf
4ff0: 72 65 65 0a 20 20 20 20 20 6d 69 6e 75 74 65 73 ree. minutes
5000: 0a 20 20 20 20 20 72 75 6e 2d 69 64 0a 20 20 20 . run-id.
5010: 20 20 74 65 73 74 6e 61 6d 65 0a 20 20 20 20 20 testname.
5020: 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 0a 28 64 item-path)))..(d
5030: 65 66 69 6e 65 20 28 73 65 74 2d 6d 65 67 61 74 efine (set-megat
5040: 65 73 74 2d 65 6e 76 2d 76 61 72 73 20 64 62 20 est-env-vars db
5050: 72 75 6e 2d 69 64 29 0a 20 20 28 6c 65 74 20 28 run-id). (let (
5060: 28 6b 65 79 73 20 28 64 62 2d 67 65 74 2d 6b 65 (keys (db-get-ke
5070: 79 73 20 64 62 29 29 29 0a 20 20 20 20 28 66 6f ys db))). (fo
5080: 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 20 28 r-each (lambda (
5090: 6b 65 79 29 0a 09 09 28 73 71 6c 69 74 65 33 3a key)...(sqlite3:
50a0: 66 6f 72 2d 65 61 63 68 2d 72 6f 77 0a 09 09 20 for-each-row...
50b0: 28 6c 61 6d 62 64 61 20 28 76 61 6c 29 0a 09 09 (lambda (val)...
50c0: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 (debug:print
50d0: 32 20 22 73 65 74 65 6e 76 20 22 20 28 6b 65 79 2 "setenv " (key
50e0: 3a 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b :get-fieldname k
50f0: 65 79 29 20 22 20 22 20 76 61 6c 29 0a 09 09 20 ey) " " val)...
5100: 20 20 28 73 65 74 65 6e 76 20 28 6b 65 79 3a 67 (setenv (key:g
5110: 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65 79 et-fieldname key
5120: 29 20 76 61 6c 29 29 0a 09 09 20 64 62 20 0a 09 ) val))... db ..
5130: 09 20 28 63 6f 6e 63 20 22 53 45 4c 45 43 54 20 . (conc "SELECT
5140: 22 20 28 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64 " (key:get-field
5150: 6e 61 6d 65 20 6b 65 79 29 20 22 20 46 52 4f 4d name key) " FROM
5160: 20 72 75 6e 73 20 57 48 45 52 45 20 69 64 3d 3f runs WHERE id=?
5170: 3b 22 29 0a 09 09 20 72 75 6e 2d 69 64 29 29 0a ;")... run-id)).
5180: 09 20 20 20 20 20 20 6b 65 79 73 29 29 29 0a 0a . keys)))..
5190: 28 64 65 66 69 6e 65 20 28 73 65 74 2d 69 74 65 (define (set-ite
51a0: 6d 2d 65 6e 76 2d 76 61 72 73 20 69 74 65 6d 64 m-env-vars itemd
51b0: 61 74 29 0a 20 20 28 66 6f 72 2d 65 61 63 68 20 at). (for-each
51c0: 28 6c 61 6d 62 64 61 20 28 69 74 65 6d 29 0a 09 (lambda (item)..
51d0: 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 (debug:pri
51e0: 6e 74 20 32 20 22 73 65 74 65 6e 76 20 22 20 28 nt 2 "setenv " (
51f0: 63 61 72 20 69 74 65 6d 29 20 22 20 22 20 28 63 car item) " " (c
5200: 61 64 72 20 69 74 65 6d 29 29 0a 09 20 20 20 20 adr item))..
5210: 20 20 28 73 65 74 65 6e 76 20 28 63 61 72 20 69 (setenv (car i
5220: 74 65 6d 29 20 28 63 61 64 72 20 69 74 65 6d 29 tem) (cadr item)
5230: 29 29 0a 09 20 20 20 20 69 74 65 6d 64 61 74 29 )).. itemdat)
5240: 29 0a 0a 28 64 65 66 69 6e 65 20 28 67 65 74 2d )..(define (get-
5250: 61 6c 6c 2d 6c 65 67 61 6c 2d 74 65 73 74 73 29 all-legal-tests)
5260: 0a 20 20 28 6c 65 74 2a 20 28 28 74 65 73 74 73 . (let* ((tests
5270: 20 20 28 67 6c 6f 62 20 28 63 6f 6e 63 20 2a 74 (glob (conc *t
5280: 6f 70 70 61 74 68 2a 20 22 2f 74 65 73 74 73 2f oppath* "/tests/
5290: 2a 22 29 29 29 0a 09 20 28 72 65 73 20 20 20 20 *"))).. (res
52a0: 27 28 29 29 29 0a 20 20 20 20 28 64 65 62 75 67 '())). (debug
52b0: 3a 70 72 69 6e 74 20 34 20 22 49 4e 46 4f 3a 20 :print 4 "INFO:
52c0: 4c 6f 6f 6b 69 6e 67 20 61 74 20 74 65 73 74 73 Looking at tests
52d0: 20 22 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 " (string-inter
52e0: 73 70 65 72 73 65 20 74 65 73 74 73 20 22 2c 22 sperse tests ","
52f0: 29 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 )). (for-each
5300: 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74 70 61 (lambda (testpa
5310: 74 68 29 0a 09 09 28 69 66 20 28 66 69 6c 65 2d th)...(if (file-
5320: 65 78 69 73 74 73 3f 20 28 63 6f 6e 63 20 74 65 exists? (conc te
5330: 73 74 70 61 74 68 20 22 2f 74 65 73 74 63 6f 6e stpath "/testcon
5340: 66 69 67 22 29 29 0a 09 09 20 20 20 20 28 73 65 fig"))... (se
5350: 74 21 20 72 65 73 20 28 63 6f 6e 73 20 28 6c 61 t! res (cons (la
5360: 73 74 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 st (string-split
5370: 20 74 65 73 74 70 61 74 68 20 22 2f 22 29 29 20 testpath "/"))
5380: 72 65 73 29 29 29 29 0a 09 20 20 20 20 20 20 74 res)))).. t
5390: 65 73 74 73 29 0a 20 20 20 20 72 65 73 29 29 0a ests). res)).
53a0: 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 63 .(define (runs:c
53b0: 61 6e 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 an-run-more-test
53c0: 73 20 64 62 29 0a 20 20 28 6c 65 74 20 28 28 6e s db). (let ((n
53d0: 75 6d 2d 72 75 6e 6e 69 6e 67 20 28 64 62 3a 67 um-running (db:g
53e0: 65 74 2d 63 6f 75 6e 74 2d 74 65 73 74 73 2d 72 et-count-tests-r
53f0: 75 6e 6e 69 6e 67 20 64 62 29 29 0a 09 28 6d 61 unning db))..(ma
5400: 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 x-concurrent-job
5410: 73 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 s (config-lookup
5420: 20 2a 63 6f 6e 66 69 67 64 61 74 2a 20 22 73 65 *configdat* "se
5430: 74 75 70 22 20 22 6d 61 78 5f 63 6f 6e 63 75 72 tup" "max_concur
5440: 72 65 6e 74 5f 6a 6f 62 73 22 29 29 29 0a 20 20 rent_jobs"))).
5450: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32 (debug:print 2
5460: 20 22 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 "max-concurrent
5470: 2d 6a 6f 62 73 3a 20 22 20 6d 61 78 2d 63 6f 6e -jobs: " max-con
5480: 63 75 72 72 65 6e 74 2d 6a 6f 62 73 20 22 2c 20 current-jobs ",
5490: 6e 75 6d 2d 72 75 6e 6e 69 6e 67 3a 20 22 20 6e num-running: " n
54a0: 75 6d 2d 72 75 6e 6e 69 6e 67 29 0a 20 20 20 20 um-running).
54b0: 28 69 66 20 28 6e 6f 74 20 28 65 71 3f 20 30 20 (if (not (eq? 0
54c0: 2a 67 6c 6f 62 61 6c 65 78 69 74 73 74 61 74 75 *globalexitstatu
54d0: 73 2a 29 29 0a 09 23 66 0a 09 28 69 66 20 28 6f s*))..#f..(if (o
54e0: 72 20 28 6e 6f 74 20 6d 61 78 2d 63 6f 6e 63 75 r (not max-concu
54f0: 72 72 65 6e 74 2d 6a 6f 62 73 29 0a 09 09 28 61 rrent-jobs)...(a
5500: 6e 64 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e nd max-concurren
5510: 74 2d 6a 6f 62 73 0a 09 09 20 20 20 20 20 28 73 t-jobs... (s
5520: 74 72 69 6e 67 2d 3e 6e 75 6d 62 65 72 20 6d 61 tring->number ma
5530: 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 x-concurrent-job
5540: 73 29 0a 09 09 20 20 20 20 20 28 6e 6f 74 20 28 s)... (not (
5550: 3e 3d 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67 20 28 >= num-running (
5560: 73 74 72 69 6e 67 2d 3e 6e 75 6d 62 65 72 20 6d string->number m
5570: 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f ax-concurrent-jo
5580: 62 73 29 29 29 29 29 0a 09 20 20 20 20 23 74 0a bs))))).. #t.
5590: 09 20 20 20 20 28 62 65 67 69 6e 20 0a 09 20 20 . (begin ..
55a0: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 (debug:print
55b0: 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 4d 61 78 0 "WARNING: Max
55c0: 20 72 75 6e 6e 69 6e 67 20 6a 6f 62 73 20 65 78 running jobs ex
55d0: 63 65 65 64 65 64 2c 20 63 75 72 72 65 6e 74 20 ceeded, current
55e0: 6e 75 6d 62 65 72 20 72 75 6e 6e 69 6e 67 3a 20 number running:
55f0: 22 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67 20 0a 09 " num-running ..
5600: 09 09 20 20 20 22 2c 20 6d 61 78 5f 63 6f 6e 63 .. ", max_conc
5610: 75 72 72 65 6e 74 5f 6a 6f 62 73 3a 20 22 20 6d urrent_jobs: " m
5620: 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f ax-concurrent-jo
5630: 62 73 29 0a 09 20 20 20 20 20 20 23 66 29 29 29 bs).. #f)))
5640: 29 29 0a 20 20 0a 28 64 65 66 69 6e 65 20 28 72 )). .(define (r
5650: 75 6e 2d 74 65 73 74 73 20 64 62 20 74 65 73 74 un-tests db test
5660: 2d 6e 61 6d 65 73 29 0a 20 20 28 6c 65 74 2a 20 -names). (let*
5670: 28 28 6b 65 79 73 20 20 20 20 20 20 20 20 28 64 ((keys (d
5680: 62 2d 67 65 74 2d 6b 65 79 73 20 64 62 29 29 0a b-get-keys db)).
5690: 09 20 28 6b 65 79 76 61 6c 6c 73 74 20 20 20 28 . (keyvallst (
56a0: 6b 65 79 73 2d 3e 76 61 6c 6c 69 73 74 20 6b 65 keys->vallist ke
56b0: 79 73 20 23 74 29 29 0a 09 20 28 72 75 6e 2d 69 ys #t)).. (run-i
56c0: 64 20 20 20 20 20 20 28 72 65 67 69 73 74 65 72 d (register
56d0: 2d 72 75 6e 20 64 62 20 6b 65 79 73 29 29 20 20 -run db keys))
56e0: 3b 3b 20 20 74 65 73 74 2d 6e 61 6d 65 29 29 29 ;; test-name)))
56f0: 0a 09 20 28 64 65 66 65 72 72 65 64 20 20 20 20 .. (deferred
5700: 27 28 29 29 29 20 3b 3b 20 64 65 6c 61 79 20 72 '())) ;; delay r
5710: 75 6e 6e 69 6e 67 20 74 68 65 73 65 20 73 69 6e unning these sin
5720: 63 65 20 74 68 65 79 20 68 61 76 65 20 61 20 77 ce they have a w
5730: 61 69 74 6f 6e 20 63 6c 61 75 73 65 0a 20 20 20 aiton clause.
5740: 20 3b 3b 20 6f 6e 20 74 68 65 20 66 69 72 73 74 ;; on the first
5750: 20 70 61 73 73 20 6f 72 20 63 61 6c 6c 20 74 6f pass or call to
5760: 20 72 75 6e 2d 74 65 73 74 73 20 73 65 74 20 46 run-tests set F
5770: 41 49 4c 53 20 74 6f 20 4e 4f 54 5f 53 54 41 52 AILS to NOT_STAR
5780: 54 45 44 20 69 66 0a 20 20 20 20 3b 3b 20 2d 6b TED if. ;; -k
5790: 65 65 70 67 6f 69 6e 67 20 69 73 20 73 70 65 63 eepgoing is spec
57a0: 69 66 69 65 64 0a 20 20 20 20 28 69 66 20 28 61 ified. (if (a
57b0: 6e 64 20 28 65 71 3f 20 2a 70 61 73 73 6e 75 6d nd (eq? *passnum
57c0: 2a 20 30 29 0a 09 20 20 20 20 20 28 61 72 67 73 * 0).. (args
57d0: 3a 67 65 74 2d 61 72 67 20 22 2d 6b 65 65 70 67 :get-arg "-keepg
57e0: 6f 69 6e 67 22 29 29 0a 09 28 62 65 67 69 6e 0a oing"))..(begin.
57f0: 09 20 20 3b 3b 20 68 61 76 65 20 74 6f 20 64 65 . ;; have to de
5800: 6c 65 74 65 20 74 65 73 74 20 72 65 63 6f 72 64 lete test record
5810: 73 20 77 68 65 72 65 20 4e 4f 54 5f 53 54 41 52 s where NOT_STAR
5820: 54 45 44 20 73 69 6e 63 65 20 74 68 65 79 20 63 TED since they c
5830: 61 6e 20 63 61 75 73 65 20 2d 6b 65 65 70 67 6f an cause -keepgo
5840: 69 6e 67 20 74 6f 20 0a 09 20 20 3b 3b 20 67 65 ing to .. ;; ge
5850: 74 20 73 74 75 63 6b 20 64 75 65 20 74 6f 20 62 t stuck due to b
5860: 65 63 6f 6d 69 6e 67 20 69 6e 61 63 63 65 73 73 ecoming inaccess
5870: 69 62 6c 65 20 66 72 6f 6d 20 61 20 66 61 69 6c ible from a fail
5880: 65 64 20 74 65 73 74 2e 20 49 2e 65 2e 20 69 66 ed test. I.e. if
5890: 20 74 65 73 74 20 42 20 64 65 70 65 6e 64 73 20 test B depends
58a0: 0a 09 20 20 3b 3b 20 6f 6e 20 74 65 73 74 20 41 .. ;; on test A
58b0: 20 62 75 74 20 74 65 73 74 20 42 20 72 65 61 63 but test B reac
58c0: 68 65 64 20 74 68 65 20 70 6f 69 6e 74 20 6f 6e hed the point on
58d0: 20 62 65 69 6e 67 20 72 65 67 69 73 74 65 72 65 being registere
58e0: 64 20 61 73 20 4e 4f 54 5f 53 54 41 52 54 45 44 d as NOT_STARTED
58f0: 20 61 6e 64 20 74 65 73 74 0a 09 20 20 3b 3b 20 and test.. ;;
5900: 41 20 66 61 69 6c 65 64 20 66 6f 72 20 73 6f 6d A failed for som
5910: 65 20 72 65 61 73 6f 6e 20 74 68 65 6e 20 6f 6e e reason then on
5920: 20 72 65 2d 72 75 6e 20 75 73 69 6e 67 20 2d 6b re-run using -k
5930: 65 65 70 67 6f 69 6e 67 20 74 68 65 20 72 75 6e eepgoing the run
5940: 20 63 61 6e 20 6e 65 76 65 72 20 63 6f 6d 70 6c can never compl
5950: 65 74 65 2e 0a 09 20 20 28 64 62 3a 64 65 6c 65 ete... (db:dele
5960: 74 65 2d 74 65 73 74 73 2d 69 6e 2d 73 74 61 74 te-tests-in-stat
5970: 65 20 64 62 20 72 75 6e 2d 69 64 20 22 4e 4f 54 e db run-id "NOT
5980: 5f 53 54 41 52 54 45 44 22 29 0a 09 20 20 28 64 _STARTED").. (d
5990: 62 3a 73 65 74 2d 74 65 73 74 73 2d 73 74 61 74 b:set-tests-stat
59a0: 65 2d 73 74 61 74 75 73 20 64 62 20 72 75 6e 2d e-status db run-
59b0: 69 64 20 74 65 73 74 2d 6e 61 6d 65 73 20 23 66 id test-names #f
59c0: 20 22 46 41 49 4c 22 20 22 4e 4f 54 5f 53 54 41 "FAIL" "NOT_STA
59d0: 52 54 45 44 22 20 22 46 41 49 4c 22 29 29 29 0a RTED" "FAIL"))).
59e0: 20 20 20 20 28 73 65 74 21 20 2a 70 61 73 73 6e (set! *passn
59f0: 75 6d 2a 20 28 2b 20 2a 70 61 73 73 6e 75 6d 2a um* (+ *passnum*
5a00: 20 31 29 29 0a 20 20 20 20 28 6c 65 74 20 6c 6f 1)). (let lo
5a10: 6f 70 20 28 28 6e 75 6d 74 69 6d 65 73 20 30 29 op ((numtimes 0)
5a20: 29 0a 20 20 20 20 20 20 28 66 6f 72 2d 65 61 63 ). (for-eac
5a30: 68 20 0a 20 20 20 20 20 20 20 28 6c 61 6d 62 64 h . (lambd
5a40: 61 20 28 74 65 73 74 2d 6e 61 6d 65 29 0a 09 20 a (test-name)..
5a50: 28 69 66 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75 (if (runs:can-ru
5a60: 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64 62 29 n-more-tests db)
5a70: 0a 09 20 20 20 20 20 28 72 75 6e 2d 6f 6e 65 2d .. (run-one-
5a80: 74 65 73 74 20 64 62 20 72 75 6e 2d 69 64 20 74 test db run-id t
5a90: 65 73 74 2d 6e 61 6d 65 20 6b 65 79 76 61 6c 6c est-name keyvall
5aa0: 73 74 29 0a 09 20 20 20 20 20 3b 3b 20 61 64 64 st).. ;; add
5ab0: 20 73 6f 6d 65 20 64 65 6c 61 79 20 0a 09 20 20 some delay ..
5ac0: 20 20 20 3b 28 73 6c 65 65 70 20 32 29 0a 09 20 ;(sleep 2)..
5ad0: 20 20 20 20 29 29 0a 20 20 20 20 20 20 20 74 65 )). te
5ae0: 73 74 2d 6e 61 6d 65 73 29 0a 20 20 20 20 20 20 st-names).
5af0: 3b 3b 20 28 72 75 6e 2d 77 61 69 74 69 6e 67 2d ;; (run-waiting-
5b00: 74 65 73 74 73 20 64 62 29 0a 20 20 20 20 20 20 tests db).
5b10: 28 69 66 20 28 61 72 67 73 3a 67 65 74 2d 61 72 (if (args:get-ar
5b20: 67 20 22 2d 6b 65 65 70 67 6f 69 6e 67 22 29 0a g "-keepgoing").
5b30: 09 20 20 28 6c 65 74 20 28 28 65 73 74 72 65 6d . (let ((estrem
5b40: 20 28 64 62 3a 65 73 74 69 6d 61 74 65 64 2d 74 (db:estimated-t
5b50: 65 73 74 73 2d 72 65 6d 61 69 6e 69 6e 67 20 64 ests-remaining d
5b60: 62 20 72 75 6e 2d 69 64 29 29 29 0a 09 20 20 20 b run-id)))..
5b70: 20 28 69 66 20 28 61 6e 64 20 28 3e 20 65 73 74 (if (and (> est
5b80: 72 65 6d 20 30 29 0a 09 09 20 20 20 20 20 28 65 rem 0)... (e
5b90: 71 3f 20 2a 67 6c 6f 62 61 6c 65 78 69 74 73 74 q? *globalexitst
5ba0: 61 74 75 73 2a 20 30 29 29 0a 09 09 28 62 65 67 atus* 0))...(beg
5bb0: 69 6e 0a 09 09 20 20 28 64 65 62 75 67 3a 70 72 in... (debug:pr
5bc0: 69 6e 74 20 31 20 22 4b 65 65 70 20 67 6f 69 6e int 1 "Keep goin
5bd0: 67 2c 20 65 73 74 69 6d 61 74 65 64 20 22 20 65 g, estimated " e
5be0: 73 74 72 65 6d 20 22 20 74 65 73 74 73 20 72 65 strem " tests re
5bf0: 6d 61 69 6e 69 6e 67 20 74 6f 20 72 75 6e 2c 20 maining to run,
5c00: 77 69 6c 6c 20 63 6f 6e 74 69 6e 75 65 20 69 6e will continue in
5c10: 20 33 20 73 65 63 6f 6e 64 73 20 2e 2e 2e 22 29 3 seconds ...")
5c20: 0a 09 09 20 20 28 73 6c 65 65 70 20 33 29 0a 09 ... (sleep 3)..
5c30: 09 20 20 28 72 75 6e 2d 77 61 69 74 69 6e 67 2d . (run-waiting-
5c40: 74 65 73 74 73 20 64 62 29 0a 09 09 20 20 28 6c tests db)... (l
5c50: 6f 6f 70 20 28 2b 20 6e 75 6d 74 69 6d 65 73 20 oop (+ numtimes
5c60: 31 29 29 29 29 29 29 29 29 29 0a 09 20 20 20 0a 1))))))))).. .
5c70: 3b 3b 20 56 45 52 59 20 49 4e 45 46 46 49 43 49 ;; VERY INEFFICI
5c80: 45 4e 54 21 20 4d 6f 76 65 20 73 74 75 66 66 20 ENT! Move stuff
5c90: 74 68 61 74 20 73 68 6f 75 6c 64 20 62 65 20 64 that should be d
5ca0: 6f 6e 65 20 6f 6e 63 65 20 75 70 20 74 6f 20 63 one once up to c
5cb0: 61 6c 6c 69 6e 67 20 70 72 6f 63 0a 28 64 65 66 alling proc.(def
5cc0: 69 6e 65 20 28 72 75 6e 2d 6f 6e 65 2d 74 65 73 ine (run-one-tes
5cd0: 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 t db run-id test
5ce0: 2d 6e 61 6d 65 20 6b 65 79 76 61 6c 6c 73 74 29 -name keyvallst)
5cf0: 0a 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 . (debug:print
5d00: 31 20 22 4c 61 75 6e 63 68 69 6e 67 20 74 65 73 1 "Launching tes
5d10: 74 20 22 20 74 65 73 74 2d 6e 61 6d 65 29 0a 20 t " test-name).
5d20: 20 3b 3b 20 41 6c 6c 20 74 68 65 73 65 20 76 61 ;; All these va
5d30: 72 73 20 6d 69 67 68 74 20 62 65 20 72 65 66 65 rs might be refe
5d40: 72 65 6e 63 65 64 20 62 79 20 74 68 65 20 74 65 renced by the te
5d50: 73 74 63 6f 6e 66 69 67 20 66 69 6c 65 20 72 65 stconfig file re
5d60: 61 64 65 72 0a 20 20 28 73 65 74 65 6e 76 20 22 ader. (setenv "
5d70: 4d 54 5f 54 45 53 54 5f 4e 41 4d 45 22 20 74 65 MT_TEST_NAME" te
5d80: 73 74 2d 6e 61 6d 65 29 20 3b 3b 20 0a 20 20 28 st-name) ;; . (
5d90: 73 65 74 65 6e 76 20 22 4d 54 5f 52 55 4e 4e 41 setenv "MT_RUNNA
5da0: 4d 45 22 20 20 20 28 61 72 67 73 3a 67 65 74 2d ME" (args:get-
5db0: 61 72 67 20 22 3a 72 75 6e 6e 61 6d 65 22 29 29 arg ":runname"))
5dc0: 0a 20 20 28 73 65 74 2d 6d 65 67 61 74 65 73 74 . (set-megatest
5dd0: 2d 65 6e 76 2d 76 61 72 73 20 64 62 20 72 75 6e -env-vars db run
5de0: 2d 69 64 29 20 3b 3b 20 74 68 65 73 65 20 6d 61 -id) ;; these ma
5df0: 79 20 62 65 20 6e 65 65 64 65 64 20 62 79 20 74 y be needed by t
5e00: 68 65 20 6c 61 75 6e 63 68 69 6e 67 20 70 72 6f he launching pro
5e10: 63 65 73 73 0a 20 20 28 63 68 61 6e 67 65 2d 64 cess. (change-d
5e20: 69 72 65 63 74 6f 72 79 20 2a 74 6f 70 70 61 74 irectory *toppat
5e30: 68 2a 29 0a 20 20 28 6c 65 74 2a 20 28 28 74 65 h*). (let* ((te
5e40: 73 74 2d 70 61 74 68 20 20 20 20 28 63 6f 6e 63 st-path (conc
5e50: 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f 74 65 73 *toppath* "/tes
5e60: 74 73 2f 22 20 74 65 73 74 2d 6e 61 6d 65 29 29 ts/" test-name))
5e70: 0a 09 20 28 74 65 73 74 2d 63 6f 6e 66 69 67 66 .. (test-configf
5e80: 20 28 63 6f 6e 63 20 74 65 73 74 2d 70 61 74 68 (conc test-path
5e90: 20 22 2f 74 65 73 74 63 6f 6e 66 69 67 22 29 29 "/testconfig"))
5ea0: 0a 09 20 28 74 65 73 74 65 78 69 73 74 73 20 20 .. (testexists
5eb0: 20 28 61 6e 64 20 28 66 69 6c 65 2d 65 78 69 73 (and (file-exis
5ec0: 74 73 3f 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 ts? test-configf
5ed0: 29 28 66 69 6c 65 2d 72 65 61 64 2d 61 63 63 65 )(file-read-acce
5ee0: 73 73 3f 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 ss? test-configf
5ef0: 29 29 29 0a 09 20 28 74 65 73 74 2d 63 6f 6e 66 ))).. (test-conf
5f00: 20 20 20 20 28 69 66 20 74 65 73 74 65 78 69 73 (if testexis
5f10: 74 73 20 28 72 65 61 64 2d 63 6f 6e 66 69 67 20 ts (read-config
5f20: 74 65 73 74 2d 63 6f 6e 66 69 67 66 20 23 66 20 test-configf #f
5f30: 23 74 29 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74 #t) (make-hash-t
5f40: 61 62 6c 65 29 29 29 0a 09 20 28 77 61 69 74 6f able))).. (waito
5f50: 6e 20 20 20 20 20 20 20 28 6c 65 74 20 28 28 77 n (let ((w
5f60: 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 (config-lookup
5f70: 74 65 73 74 2d 63 6f 6e 66 20 22 72 65 71 75 69 test-conf "requi
5f80: 72 65 6d 65 6e 74 73 22 20 22 77 61 69 74 6f 6e rements" "waiton
5f90: 22 29 29 29 0a 09 09 09 20 28 69 66 20 28 73 74 "))).... (if (st
5fa0: 72 69 6e 67 3f 20 77 29 28 73 74 72 69 6e 67 2d ring? w)(string-
5fb0: 73 70 6c 69 74 20 77 29 27 28 29 29 29 29 0a 09 split w)'())))..
5fc0: 20 28 74 61 67 73 20 20 20 20 20 20 20 20 20 28 (tags (
5fd0: 6c 65 74 20 28 28 74 20 28 63 6f 6e 66 69 67 2d let ((t (config-
5fe0: 6c 6f 6f 6b 75 70 20 74 65 73 74 2d 63 6f 6e 66 lookup test-conf
5ff0: 20 22 73 65 74 75 70 22 20 22 74 61 67 73 22 29 "setup" "tags")
6000: 29 29 0a 09 09 09 20 3b 3b 20 77 65 20 77 61 6e )).... ;; we wan
6010: 74 20 6f 75 72 20 74 61 67 73 20 74 6f 20 62 65 t our tags to be
6020: 20 73 65 70 61 72 61 74 65 64 20 62 79 20 63 6f separated by co
6030: 6d 6d 61 73 20 61 6e 64 20 66 75 6c 6c 79 20 64 mmas and fully d
6040: 65 6c 69 6d 69 74 65 64 20 62 79 20 63 6f 6d 6d elimited by comm
6050: 61 73 0a 09 09 09 20 3b 3b 20 73 6f 20 74 68 61 as.... ;; so tha
6060: 74 20 71 75 65 72 69 65 73 20 77 69 74 68 20 22 t queries with "
6070: 6c 69 6b 65 22 20 63 61 6e 20 74 69 65 20 74 6f like" can tie to
6080: 20 74 68 65 20 63 6f 6d 6d 61 73 20 61 74 20 65 the commas at e
6090: 69 74 68 65 72 20 65 6e 64 20 6f 66 20 65 61 63 ither end of eac
60a0: 68 20 74 61 67 0a 09 09 09 20 3b 3b 20 77 68 69 h tag.... ;; whi
60b0: 6c 65 20 61 6c 73 6f 20 61 6c 6c 6f 77 69 6e 67 le also allowing
60c0: 20 74 68 65 20 65 6e 64 20 75 73 65 72 20 74 6f the end user to
60d0: 20 66 72 65 65 6c 79 20 75 73 65 20 73 70 61 63 freely use spac
60e0: 65 73 20 61 6e 64 20 63 6f 6d 6d 61 73 20 74 6f es and commas to
60f0: 20 73 65 70 61 72 61 74 65 20 74 61 67 73 0a 09 separate tags..
6100: 09 09 20 28 69 66 20 28 73 74 72 69 6e 67 3f 20 .. (if (string?
6110: 74 29 28 73 74 72 69 6e 67 2d 73 75 62 73 74 69 t)(string-substi
6120: 74 75 74 65 20 28 72 65 67 65 78 70 20 22 5b 2c tute (regexp "[,
6130: 5c 5c 73 5d 2b 22 29 20 22 2c 22 20 28 63 6f 6e \\s]+") "," (con
6140: 63 20 22 2c 22 20 74 20 22 2c 22 29 20 23 74 29 c "," t ",") #t)
6150: 0a 09 09 09 20 20 20 20 20 27 28 29 29 29 29 29 .... '()))))
6160: 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 74 65 . (if (not te
6170: 73 74 65 78 69 73 74 73 29 0a 09 28 62 65 67 69 stexists)..(begi
6180: 6e 0a 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e n.. (debug:prin
6190: 74 20 30 20 22 45 52 52 4f 52 3a 20 43 61 6e 27 t 0 "ERROR: Can'
61a0: 74 20 66 69 6e 64 20 63 6f 6e 66 69 67 20 66 69 t find config fi
61b0: 6c 65 20 22 20 74 65 73 74 2d 63 6f 6e 66 69 67 le " test-config
61c0: 66 29 0a 09 20 20 28 65 78 69 74 20 32 29 29 0a f).. (exit 2)).
61d0: 09 3b 3b 20 70 75 74 20 74 6f 70 20 76 61 72 73 .;; put top vars
61e0: 20 69 6e 74 6f 20 63 6f 6e 76 65 6e 69 65 6e 74 into convenient
61f0: 20 76 61 72 69 61 62 6c 65 73 20 61 6e 64 20 6f variables and o
6200: 70 65 6e 20 74 68 65 20 64 62 0a 09 28 6c 65 74 pen the db..(let
6210: 2a 20 28 3b 3b 20 64 62 20 69 73 20 61 6c 77 61 * (;; db is alwa
6220: 79 73 20 61 74 20 2a 74 6f 70 70 61 74 68 2a 2f ys at *toppath*/
6230: 64 62 2f 6d 65 67 61 74 65 73 74 2e 64 62 0a 09 db/megatest.db..
6240: 20 20 20 20 20 20 20 28 69 74 65 6d 73 20 20 20 (items
6250: 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d (hash-table-
6260: 72 65 66 2f 64 65 66 61 75 6c 74 20 74 65 73 74 ref/default test
6270: 2d 63 6f 6e 66 20 22 69 74 65 6d 73 22 20 27 28 -conf "items" '(
6280: 29 29 29 0a 09 20 20 20 20 20 20 20 28 69 74 65 ))).. (ite
6290: 6d 73 74 61 62 6c 65 20 20 28 68 61 73 68 2d 74 mstable (hash-t
62a0: 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 able-ref/default
62b0: 20 74 65 73 74 2d 63 6f 6e 66 20 22 69 74 65 6d test-conf "item
62c0: 73 74 61 62 6c 65 22 20 27 28 29 29 29 0a 09 20 stable" '()))..
62d0: 20 20 20 20 20 20 28 61 6c 6c 69 74 65 6d 73 20 (allitems
62e0: 20 20 20 28 69 66 20 28 6f 72 20 28 6e 6f 74 20 (if (or (not
62f0: 28 6e 75 6c 6c 3f 20 69 74 65 6d 73 29 29 28 6e (null? items))(n
6300: 6f 74 20 28 6e 75 6c 6c 3f 20 69 74 65 6d 73 74 ot (null? itemst
6310: 61 62 6c 65 29 29 29 0a 09 09 09 09 28 61 70 70 able))).....(app
6320: 65 6e 64 20 28 69 74 65 6d 2d 61 73 73 6f 63 2d end (item-assoc-
6330: 3e 69 74 65 6d 2d 6c 69 73 74 20 69 74 65 6d 73 >item-list items
6340: 29 0a 09 09 09 09 09 28 69 74 65 6d 2d 74 61 62 )......(item-tab
6350: 6c 65 2d 3e 69 74 65 6d 2d 6c 69 73 74 20 69 74 le->item-list it
6360: 65 6d 73 74 61 62 6c 65 29 29 0a 09 09 09 09 27 emstable)).....'
6370: 28 28 29 29 29 29 20 3b 3b 20 61 20 6c 69 73 74 (()))) ;; a list
6380: 20 77 69 74 68 20 6f 6e 65 20 6e 75 6c 6c 20 6c with one null l
6390: 69 73 74 20 69 73 20 61 20 74 65 73 74 20 77 69 ist is a test wi
63a0: 74 68 20 6e 6f 20 69 74 65 6d 73 0a 09 20 20 20 th no items..
63b0: 20 20 20 20 28 72 75 6e 63 6f 6e 66 69 67 66 20 (runconfigf
63c0: 20 28 63 6f 6e 63 20 20 2a 74 6f 70 70 61 74 68 (conc *toppath
63d0: 2a 20 22 2f 72 75 6e 63 6f 6e 66 69 67 73 2e 63 * "/runconfigs.c
63e0: 6f 6e 66 69 67 22 29 29 29 0a 09 20 20 28 64 65 onfig"))).. (de
63f0: 62 75 67 3a 70 72 69 6e 74 20 31 20 22 69 74 65 bug:print 1 "ite
6400: 6d 73 3a 20 22 29 0a 09 20 20 28 69 66 20 28 3e ms: ").. (if (>
6410: 3d 20 2a 76 65 72 62 6f 73 69 74 79 2a 20 31 29 = *verbosity* 1)
6420: 28 70 70 20 61 6c 6c 69 74 65 6d 73 29 29 0a 09 (pp allitems))..
6430: 20 20 28 69 66 20 28 3e 3d 20 2a 76 65 72 62 6f (if (>= *verbo
6440: 73 69 74 79 2a 20 35 29 0a 09 20 20 20 20 20 20 sity* 5)..
6450: 28 62 65 67 69 6e 0a 09 09 28 70 72 69 6e 74 20 (begin...(print
6460: 22 69 74 65 6d 73 3a 20 22 29 28 70 70 20 28 69 "items: ")(pp (i
6470: 74 65 6d 2d 61 73 73 6f 63 2d 3e 69 74 65 6d 2d tem-assoc->item-
6480: 6c 69 73 74 20 69 74 65 6d 73 29 29 0a 09 09 28 list items))...(
6490: 70 72 69 6e 74 20 22 69 74 65 73 74 61 62 6c 65 print "itestable
64a0: 3a 20 22 29 28 70 70 20 28 69 74 65 6d 2d 74 61 : ")(pp (item-ta
64b0: 62 6c 65 2d 3e 69 74 65 6d 2d 6c 69 73 74 20 69 ble->item-list i
64c0: 74 65 6d 73 74 61 62 6c 65 29 29 29 29 0a 09 20 temstable))))..
64d0: 20 28 69 66 20 28 61 72 67 73 3a 67 65 74 2d 61 (if (args:get-a
64e0: 72 67 20 22 2d 6d 22 29 0a 09 20 20 20 20 20 20 rg "-m")..
64f0: 28 64 62 3a 73 65 74 2d 63 6f 6d 6d 65 6e 74 2d (db:set-comment-
6500: 66 6f 72 2d 72 75 6e 20 64 62 20 72 75 6e 2d 69 for-run db run-i
6510: 64 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 d (args:get-arg
6520: 22 2d 6d 22 29 29 29 0a 0a 09 20 20 3b 3b 20 48 "-m")))... ;; H
6530: 65 72 65 20 69 73 20 77 68 65 72 65 20 74 68 65 ere is where the
6540: 20 74 65 73 74 5f 6d 65 74 61 20 74 61 62 6c 65 test_meta table
6550: 20 69 73 20 62 65 73 74 20 75 70 64 61 74 65 64 is best updated
6560: 0a 09 20 20 28 72 75 6e 73 3a 75 70 64 61 74 65 .. (runs:update
6570: 2d 74 65 73 74 5f 6d 65 74 61 20 64 62 20 74 65 -test_meta db te
6580: 73 74 2d 6e 61 6d 65 20 74 65 73 74 2d 63 6f 6e st-name test-con
6590: 66 29 0a 0a 09 20 20 3b 3b 20 62 72 61 69 6e 64 f)... ;; braind
65a0: 65 61 64 20 77 6f 72 6b 2d 61 72 6f 75 6e 64 20 ead work-around
65b0: 66 6f 72 20 70 6f 6f 72 6c 79 20 73 70 65 63 69 for poorly speci
65c0: 66 69 65 64 20 61 6c 6c 69 74 65 6d 73 20 6c 69 fied allitems li
65d0: 73 74 20 42 55 47 21 21 21 20 46 49 58 4d 45 0a st BUG!!! FIXME.
65e0: 09 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 61 6c . (if (null? al
65f0: 6c 69 74 65 6d 73 29 28 73 65 74 21 20 61 6c 6c litems)(set! all
6600: 69 74 65 6d 73 20 27 28 28 29 29 29 29 0a 09 20 items '(())))..
6610: 20 28 6c 65 74 20 6c 6f 6f 70 20 28 28 69 74 65 (let loop ((ite
6620: 6d 64 61 74 20 28 63 61 72 20 61 6c 6c 69 74 65 mdat (car allite
6630: 6d 73 29 29 0a 09 09 20 20 20 20 20 28 74 61 6c ms))... (tal
6640: 20 20 20 20 20 28 63 64 72 20 61 6c 6c 69 74 65 (cdr allite
6650: 6d 73 29 29 29 0a 09 20 20 20 20 3b 3b 20 28 6c ms))).. ;; (l
6660: 61 6d 62 64 61 20 28 69 74 65 6d 64 61 74 29 20 ambda (itemdat)
6670: 3b 3b 3b 20 28 28 72 69 70 65 6e 65 73 73 20 22 ;;; ((ripeness "
6680: 6f 76 65 72 72 69 70 65 22 29 20 28 74 65 6d 70 overripe") (temp
6690: 65 72 61 74 75 72 65 20 22 63 6f 6f 6c 22 29 20 erature "cool")
66a0: 28 73 65 61 73 6f 6e 20 22 73 75 6d 6d 65 72 22 (season "summer"
66b0: 29 29 0a 09 20 20 20 20 3b 3b 20 48 61 6e 64 6c )).. ;; Handl
66c0: 65 20 6c 69 73 74 73 20 6f 66 20 69 74 65 6d 73 e lists of items
66d0: 0a 09 20 20 20 20 28 6c 65 74 2a 20 28 28 69 74 .. (let* ((it
66e0: 65 6d 2d 70 61 74 68 20 20 20 20 20 28 69 74 65 em-path (ite
66f0: 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69 74 65 m-list->path ite
6700: 6d 64 61 74 29 29 20 3b 3b 20 28 73 74 72 69 6e mdat)) ;; (strin
6710: 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 28 6d g-intersperse (m
6720: 61 70 20 63 61 64 72 20 69 74 65 6d 64 61 74 29 ap cadr itemdat)
6730: 20 22 2f 22 29 29 0a 09 09 20 20 20 28 6e 65 77 "/"))... (new
6740: 2d 74 65 73 74 2d 70 61 74 68 20 28 73 74 72 69 -test-path (stri
6750: 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 28 ng-intersperse (
6760: 63 6f 6e 73 20 74 65 73 74 2d 70 61 74 68 20 28 cons test-path (
6770: 6d 61 70 20 63 61 64 72 20 69 74 65 6d 64 61 74 map cadr itemdat
6780: 29 29 20 22 2f 22 29 29 0a 09 09 20 20 20 28 6e )) "/"))... (n
6790: 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20 28 69 66 ew-test-name (if
67a0: 20 28 65 71 75 61 6c 3f 20 69 74 65 6d 2d 70 61 (equal? item-pa
67b0: 74 68 20 22 22 29 20 74 65 73 74 2d 6e 61 6d 65 th "") test-name
67c0: 20 28 63 6f 6e 63 20 74 65 73 74 2d 6e 61 6d 65 (conc test-name
67d0: 20 22 2f 22 20 69 74 65 6d 2d 70 61 74 68 29 29 "/" item-path))
67e0: 29 20 3b 3b 20 6a 75 73 74 20 6e 65 65 64 20 69 ) ;; just need i
67f0: 74 20 74 6f 20 62 65 20 75 6e 69 71 75 65 0a 09 t to be unique..
6800: 09 20 20 20 28 74 65 73 74 64 61 74 20 20 20 23 . (testdat #
6810: 66 29 0a 09 09 20 20 20 28 6e 75 6d 2d 72 75 6e f)... (num-run
6820: 6e 69 6e 67 20 28 64 62 3a 67 65 74 2d 63 6f 75 ning (db:get-cou
6830: 6e 74 2d 74 65 73 74 73 2d 72 75 6e 6e 69 6e 67 nt-tests-running
6840: 20 64 62 29 29 0a 09 09 20 20 20 28 6d 61 78 2d db))... (max-
6850: 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 20 concurrent-jobs
6860: 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 2a (config-lookup *
6870: 63 6f 6e 66 69 67 64 61 74 2a 20 22 73 65 74 75 configdat* "setu
6880: 70 22 20 22 6d 61 78 5f 63 6f 6e 63 75 72 72 65 p" "max_concurre
6890: 6e 74 5f 6a 6f 62 73 22 29 29 0a 09 09 20 20 20 nt_jobs"))...
68a0: 28 70 61 72 65 6e 74 2d 74 65 73 74 20 28 61 6e (parent-test (an
68b0: 64 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 69 74 d (not (null? it
68c0: 65 6d 73 29 29 28 65 71 75 61 6c 3f 20 69 74 65 ems))(equal? ite
68d0: 6d 2d 70 61 74 68 20 22 22 29 29 29 0a 09 09 20 m-path "")))...
68e0: 20 20 28 73 69 6e 67 6c 65 2d 74 65 73 74 20 28 (single-test (
68f0: 61 6e 64 20 28 6e 75 6c 6c 3f 20 69 74 65 6d 73 and (null? items
6900: 29 20 28 65 71 75 61 6c 3f 20 69 74 65 6d 2d 70 ) (equal? item-p
6910: 61 74 68 20 22 22 29 29 29 0a 09 09 20 20 20 28 ath "")))... (
6920: 69 74 65 6d 2d 74 65 73 74 20 20 20 28 6e 6f 74 item-test (not
6930: 20 28 65 71 75 61 6c 3f 20 69 74 65 6d 2d 70 61 (equal? item-pa
6940: 74 68 20 22 22 29 29 29 0a 09 09 20 20 20 28 69 th "")))... (i
6950: 74 65 6d 2d 70 61 74 74 20 20 20 28 61 72 67 73 tem-patt (args
6960: 3a 67 65 74 2d 61 72 67 20 22 2d 69 74 65 6d 70 :get-arg "-itemp
6970: 61 74 74 22 29 29 0a 09 09 20 20 20 28 70 61 74 att"))... (pat
6980: 74 2d 6d 61 74 63 68 20 20 28 69 66 20 69 74 65 t-match (if ite
6990: 6d 2d 70 61 74 74 0a 09 09 09 09 20 20 20 20 28 m-patt..... (
69a0: 73 74 72 69 6e 67 2d 6d 61 74 63 68 20 28 67 6c string-match (gl
69b0: 6f 62 2d 3e 72 65 67 65 78 70 0a 09 09 09 09 09 ob->regexp......
69c0: 09 20 20 20 28 73 74 72 69 6e 67 2d 74 72 61 6e . (string-tran
69d0: 73 6c 61 74 65 20 69 74 65 6d 2d 70 61 74 74 20 slate item-patt
69e0: 22 25 22 20 22 2a 22 29 29 0a 09 09 09 09 09 09 "%" "*")).......
69f0: 20 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 09 09 item-path)....
6a00: 09 20 20 20 20 23 74 29 29 29 0a 09 20 20 20 20 . #t)))..
6a10: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 33 (debug:print 3
6a20: 20 22 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 "max-concurrent
6a30: 2d 6a 6f 62 73 3a 20 22 20 6d 61 78 2d 63 6f 6e -jobs: " max-con
6a40: 63 75 72 72 65 6e 74 2d 6a 6f 62 73 20 22 2c 20 current-jobs ",
6a50: 6e 75 6d 2d 72 75 6e 6e 69 6e 67 3a 20 22 20 6e num-running: " n
6a60: 75 6d 2d 72 75 6e 6e 69 6e 67 29 0a 09 20 20 20 um-running)..
6a70: 20 20 20 28 69 66 20 28 61 6e 64 20 70 61 74 74 (if (and patt
6a80: 2d 6d 61 74 63 68 20 28 72 75 6e 73 3a 63 61 6e -match (runs:can
6a90: 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20 -run-more-tests
6aa0: 64 62 29 29 0a 09 09 20 20 28 62 65 67 69 6e 0a db))... (begin.
6ab0: 09 09 20 20 20 20 28 6c 65 74 20 6c 6f 6f 70 32 .. (let loop2
6ac0: 20 28 28 74 73 20 28 64 62 3a 67 65 74 2d 74 65 ((ts (db:get-te
6ad0: 73 74 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 st-info db run-i
6ae0: 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d d test-name item
6af0: 2d 70 61 74 68 29 29 20 3b 3b 20 23 66 29 0a 09 -path)) ;; #f)..
6b00: 09 09 09 28 63 74 20 30 29 29 0a 09 09 20 20 20 ...(ct 0))...
6b10: 20 20 20 28 69 66 20 28 61 6e 64 20 28 6e 6f 74 (if (and (not
6b20: 20 74 73 29 0a 09 09 09 20 20 20 20 20 20 20 28 ts).... (
6b30: 3c 20 63 74 20 31 30 29 29 0a 09 09 09 20 20 28 < ct 10)).... (
6b40: 62 65 67 69 6e 0a 09 09 09 20 20 20 20 28 72 65 begin.... (re
6b50: 67 69 73 74 65 72 2d 74 65 73 74 20 64 62 20 72 gister-test db r
6b60: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 un-id test-name
6b70: 69 74 65 6d 2d 70 61 74 68 29 0a 09 09 09 20 20 item-path)....
6b80: 20 20 28 64 62 3a 74 65 73 74 2d 73 65 74 2d 63 (db:test-set-c
6b90: 6f 6d 6d 65 6e 74 20 64 62 20 72 75 6e 2d 69 64 omment db run-id
6ba0: 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d test-name item-
6bb0: 70 61 74 68 20 22 22 29 0a 09 09 09 20 20 20 20 path "")....
6bc0: 28 6c 6f 6f 70 32 20 28 64 62 3a 67 65 74 2d 74 (loop2 (db:get-t
6bd0: 65 73 74 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d est-info db run-
6be0: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 id test-name ite
6bf0: 6d 2d 70 61 74 68 29 0a 09 09 09 09 20 20 20 28 m-path)..... (
6c00: 2b 20 63 74 20 31 29 29 29 0a 09 09 09 20 20 28 + ct 1))).... (
6c10: 69 66 20 74 73 0a 09 09 09 20 20 20 20 20 20 28 if ts.... (
6c20: 73 65 74 21 20 74 65 73 74 64 61 74 20 74 73 29 set! testdat ts)
6c30: 0a 09 09 09 20 20 20 20 20 20 28 62 65 67 69 6e .... (begin
6c40: 0a 09 09 09 09 28 64 65 62 75 67 3a 70 72 69 6e .....(debug:prin
6c50: 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 43 6f t 0 "WARNING: Co
6c60: 75 6c 64 6e 27 74 20 72 65 67 69 73 74 65 72 20 uldn't register
6c70: 74 65 73 74 20 22 20 74 65 73 74 2d 6e 61 6d 65 test " test-name
6c80: 20 22 20 77 69 74 68 20 69 74 65 6d 20 70 61 74 " with item pat
6c90: 68 20 22 20 69 74 65 6d 2d 70 61 74 68 20 22 2c h " item-path ",
6ca0: 20 73 6b 69 70 70 69 6e 67 22 29 0a 09 09 09 09 skipping").....
6cb0: 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 (if (not (null?
6cc0: 74 61 6c 29 29 0a 09 09 09 09 20 20 20 20 28 6c tal))..... (l
6cd0: 6f 6f 70 20 28 63 61 72 20 74 61 6c 29 28 63 64 oop (car tal)(cd
6ce0: 72 20 74 61 6c 29 29 29 29 29 29 29 0a 09 09 20 r tal)))))))...
6cf0: 20 20 20 28 63 68 61 6e 67 65 2d 64 69 72 65 63 (change-direc
6d00: 74 6f 72 79 20 74 65 73 74 2d 70 61 74 68 29 0a tory test-path).
6d10: 09 09 20 20 20 20 3b 3b 20 74 68 69 73 20 62 6c .. ;; this bl
6d20: 6f 63 6b 20 69 73 20 68 65 72 65 20 6f 6e 6c 79 ock is here only
6d30: 20 74 6f 20 69 6e 66 6f 72 6d 20 74 68 65 20 75 to inform the u
6d40: 73 65 72 20 65 61 72 6c 79 20 6f 6e 0a 09 09 20 ser early on...
6d50: 20 20 20 28 69 66 20 28 66 69 6c 65 2d 65 78 69 (if (file-exi
6d60: 73 74 73 3f 20 72 75 6e 63 6f 6e 66 69 67 66 29 sts? runconfigf)
6d70: 0a 09 09 09 28 73 65 74 75 70 2d 65 6e 76 2d 64 ....(setup-env-d
6d80: 65 66 61 75 6c 74 73 20 64 62 20 72 75 6e 63 6f efaults db runco
6d90: 6e 66 69 67 66 20 72 75 6e 2d 69 64 20 2a 61 6c nfigf run-id *al
6da0: 72 65 61 64 79 2d 73 65 65 6e 2d 72 75 6e 63 6f ready-seen-runco
6db0: 6e 66 69 67 2d 69 6e 66 6f 2a 29 0a 09 09 09 28 nfig-info*)....(
6dc0: 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 57 debug:print 0 "W
6dd0: 41 52 4e 49 4e 47 3a 20 59 6f 75 20 64 6f 20 6e ARNING: You do n
6de0: 6f 74 20 68 61 76 65 20 61 20 72 75 6e 20 63 6f ot have a run co
6df0: 6e 66 69 67 20 66 69 6c 65 3a 20 22 20 72 75 6e nfig file: " run
6e00: 63 6f 6e 66 69 67 66 29 29 0a 09 09 20 20 20 20 configf))...
6e10: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 (debug:print 4 "
6e20: 72 75 6e 2d 69 64 3a 20 22 20 72 75 6e 2d 69 64 run-id: " run-id
6e30: 20 22 20 74 65 73 74 2d 6e 61 6d 65 3a 20 22 20 " test-name: "
6e40: 74 65 73 74 2d 6e 61 6d 65 20 22 20 69 74 65 6d test-name " item
6e50: 2d 70 61 74 68 3a 20 22 20 69 74 65 6d 2d 70 61 -path: " item-pa
6e60: 74 68 20 22 20 74 65 73 74 64 61 74 3a 20 22 20 th " testdat: "
6e70: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 (test:get-status
6e80: 20 74 65 73 74 64 61 74 29 20 22 20 74 65 73 74 testdat) " test
6e90: 2d 73 74 61 74 65 3a 20 22 20 28 74 65 73 74 3a -state: " (test:
6ea0: 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 get-state testda
6eb0: 74 29 29 0a 09 09 20 20 20 20 28 63 61 73 65 20 t))... (case
6ec0: 28 69 66 20 28 61 72 67 73 3a 67 65 74 2d 61 72 (if (args:get-ar
6ed0: 67 20 22 2d 66 6f 72 63 65 22 29 0a 09 09 09 20 g "-force")....
6ee0: 20 20 20 20 20 27 4e 4f 54 5f 53 54 41 52 54 45 'NOT_STARTE
6ef0: 44 0a 09 09 09 20 20 20 20 20 20 28 69 66 20 74 D.... (if t
6f00: 65 73 74 64 61 74 0a 09 09 09 09 20 20 28 73 74 estdat..... (st
6f10: 72 69 6e 67 2d 3e 73 79 6d 62 6f 6c 20 28 74 65 ring->symbol (te
6f20: 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 st:get-state tes
6f30: 74 64 61 74 29 29 0a 09 09 09 09 20 20 27 66 61 tdat))..... 'fa
6f40: 69 6c 65 64 2d 74 6f 2d 69 6e 73 65 72 74 29 29 iled-to-insert))
6f50: 0a 09 09 20 20 20 20 20 20 28 28 66 61 69 6c 65 ... ((faile
6f60: 64 2d 74 6f 2d 69 6e 73 65 72 74 29 0a 09 09 20 d-to-insert)...
6f70: 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 (debug:pri
6f80: 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 46 61 69 nt 0 "ERROR: Fai
6f90: 6c 65 64 20 74 6f 20 69 6e 73 65 72 74 20 74 68 led to insert th
6fa0: 65 20 72 65 63 6f 72 64 20 69 6e 74 6f 20 74 68 e record into th
6fb0: 65 20 64 62 22 29 29 0a 09 09 20 20 20 20 20 20 e db"))...
6fc0: 28 28 4e 4f 54 5f 53 54 41 52 54 45 44 20 43 4f ((NOT_STARTED CO
6fd0: 4d 50 4c 45 54 45 44 29 0a 09 09 20 20 20 20 20 MPLETED)...
6fe0: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 36 (debug:print 6
6ff0: 20 22 47 6f 74 20 68 65 72 65 2c 20 22 20 28 74 "Got here, " (t
7000: 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65 est:get-state te
7010: 73 74 64 61 74 29 29 0a 09 09 20 20 20 20 20 20 stdat))...
7020: 20 28 6c 65 74 20 28 28 72 75 6e 66 6c 61 67 20 (let ((runflag
7030: 23 66 29 29 0a 09 09 09 20 28 63 6f 6e 64 0a 09 #f)).... (cond..
7040: 09 09 20 20 3b 3b 20 69 2e 65 2e 20 74 68 69 73 .. ;; i.e. this
7050: 20 69 73 20 74 68 65 20 70 61 72 65 6e 74 20 74 is the parent t
7060: 65 73 74 20 74 6f 20 61 20 73 75 69 74 65 20 6f est to a suite o
7070: 66 20 69 74 65 6d 73 2c 20 6e 65 76 65 72 20 22 f items, never "
7080: 72 75 6e 22 20 69 74 0a 09 09 09 20 20 28 70 61 run" it.... (pa
7090: 72 65 6e 74 2d 74 65 73 74 0a 09 09 09 20 20 20 rent-test....
70a0: 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 66 (set! runflag #f
70b0: 29 29 0a 09 09 09 20 20 3b 3b 20 2d 66 6f 72 63 )).... ;; -forc
70c0: 65 2c 20 72 75 6e 20 6e 6f 20 6d 61 74 74 65 72 e, run no matter
70d0: 20 77 68 61 74 0a 09 09 09 20 20 28 28 61 72 67 what.... ((arg
70e0: 73 3a 67 65 74 2d 61 72 67 20 22 2d 66 6f 72 63 s:get-arg "-forc
70f0: 65 22 29 28 73 65 74 21 20 72 75 6e 66 6c 61 67 e")(set! runflag
7100: 20 23 74 29 29 0a 09 09 09 20 20 3b 3b 20 4e 4f #t)).... ;; NO
7110: 54 5f 53 54 41 52 54 45 44 2c 20 72 75 6e 20 6e T_STARTED, run n
7120: 6f 20 6d 61 74 74 65 72 20 77 68 61 74 0a 09 09 o matter what...
7130: 09 20 20 28 28 65 71 75 61 6c 3f 20 28 74 65 73 . ((equal? (tes
7140: 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 t:get-state test
7150: 64 61 74 29 20 22 4e 4f 54 5f 53 54 41 52 54 45 dat) "NOT_STARTE
7160: 44 22 29 28 73 65 74 21 20 72 75 6e 66 6c 61 67 D")(set! runflag
7170: 20 23 74 29 29 0a 09 09 09 20 20 3b 3b 20 6e 6f #t)).... ;; no
7180: 74 20 2d 72 65 72 75 6e 20 61 6e 64 20 50 41 53 t -rerun and PAS
7190: 53 2c 20 57 41 52 4e 20 6f 72 20 43 48 45 43 4b S, WARN or CHECK
71a0: 2c 20 64 6f 20 6e 6f 20 72 75 6e 0a 09 09 09 20 , do no run....
71b0: 20 28 28 61 6e 64 20 28 6f 72 20 28 6e 6f 74 20 ((and (or (not
71c0: 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d (args:get-arg "-
71d0: 72 65 72 75 6e 22 29 29 0a 09 09 09 09 20 20 20 rerun")).....
71e0: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 (args:get-arg "
71f0: 2d 6b 65 65 70 67 6f 69 6e 67 22 29 29 0a 09 09 -keepgoing"))...
7200: 09 09 28 6d 65 6d 62 65 72 20 28 74 65 73 74 3a ..(member (test:
7210: 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 get-status testd
7220: 61 74 29 20 27 28 22 50 41 53 53 22 20 22 57 41 at) '("PASS" "WA
7230: 52 4e 22 20 22 43 48 45 43 4b 22 29 29 29 0a 09 RN" "CHECK")))..
7240: 09 09 20 20 20 28 73 65 74 21 20 72 75 6e 66 6c .. (set! runfl
7250: 61 67 20 23 66 29 29 0a 09 09 09 20 20 3b 3b 20 ag #f)).... ;;
7260: 2d 72 65 72 75 6e 20 61 6e 64 20 73 74 61 74 75 -rerun and statu
7270: 73 20 69 73 20 6f 6e 65 20 6f 66 20 74 68 65 20 s is one of the
7280: 73 70 65 63 69 66 65 64 2c 20 72 75 6e 20 69 74 specifed, run it
7290: 0a 09 09 09 20 20 28 28 61 6e 64 20 28 61 72 67 .... ((and (arg
72a0: 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65 72 75 s:get-arg "-reru
72b0: 6e 22 29 0a 09 09 09 09 28 6c 65 74 20 28 28 72 n").....(let ((r
72c0: 65 72 75 6e 6c 73 74 20 28 73 74 72 69 6e 67 2d erunlst (string-
72d0: 73 70 6c 69 74 20 28 61 72 67 73 3a 67 65 74 2d split (args:get-
72e0: 61 72 67 20 22 2d 72 65 72 75 6e 22 29 20 22 2c arg "-rerun") ",
72f0: 22 29 29 29 20 3b 3b 20 46 41 49 4c 2c 0a 09 09 "))) ;; FAIL,...
7300: 09 09 20 20 28 6d 65 6d 62 65 72 20 28 74 65 73 .. (member (tes
7310: 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 t:get-status tes
7320: 74 64 61 74 29 20 72 65 72 75 6e 6c 73 74 29 29 tdat) rerunlst))
7330: 29 0a 09 09 09 20 20 20 28 73 65 74 21 20 72 75 ).... (set! ru
7340: 6e 66 6c 61 67 20 23 74 29 29 0a 09 09 09 20 20 nflag #t))....
7350: 3b 3b 20 2d 6b 65 65 70 67 6f 69 6e 67 2c 20 64 ;; -keepgoing, d
7360: 6f 20 6e 6f 74 20 72 65 72 75 6e 20 46 41 49 4c o not rerun FAIL
7370: 0a 09 09 09 20 20 28 28 61 6e 64 20 28 61 72 67 .... ((and (arg
7380: 73 3a 67 65 74 2d 61 72 67 20 22 2d 6b 65 65 70 s:get-arg "-keep
7390: 67 6f 69 6e 67 22 29 0a 09 09 09 09 28 6d 65 6d going").....(mem
73a0: 62 65 72 20 28 74 65 73 74 3a 67 65 74 2d 73 74 ber (test:get-st
73b0: 61 74 75 73 20 74 65 73 74 64 61 74 29 20 27 28 atus testdat) '(
73c0: 22 46 41 49 4c 22 29 29 29 0a 09 09 09 20 20 20 "FAIL")))....
73d0: 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 66 (set! runflag #f
73e0: 29 29 0a 09 09 09 20 20 28 28 61 6e 64 20 28 6e )).... ((and (n
73f0: 6f 74 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 ot (args:get-arg
7400: 20 22 2d 72 65 72 75 6e 22 29 29 0a 09 09 09 09 "-rerun")).....
7410: 28 6d 65 6d 62 65 72 20 28 74 65 73 74 3a 67 65 (member (test:ge
7420: 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61 74 t-status testdat
7430: 29 20 27 28 22 46 41 49 4c 22 20 22 6e 2f 61 22 ) '("FAIL" "n/a"
7440: 29 29 29 0a 09 09 09 20 20 20 28 73 65 74 21 20 ))).... (set!
7450: 72 75 6e 66 6c 61 67 20 23 74 29 29 0a 09 09 09 runflag #t))....
7460: 20 20 28 65 6c 73 65 20 28 73 65 74 21 20 72 75 (else (set! ru
7470: 6e 66 6c 61 67 20 23 66 29 29 29 0a 09 09 09 20 nflag #f)))....
7480: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 36 20 22 (debug:print 6 "
7490: 52 55 4e 4e 49 4e 47 20 3d 3e 20 72 75 6e 66 6c RUNNING => runfl
74a0: 61 67 3a 20 22 20 72 75 6e 66 6c 61 67 20 22 20 ag: " runflag "
74b0: 53 54 41 54 45 3a 20 22 20 28 74 65 73 74 3a 67 STATE: " (test:g
74c0: 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 74 et-state testdat
74d0: 29 20 22 20 53 54 41 54 55 53 3a 20 22 20 28 74 ) " STATUS: " (t
74e0: 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 est:get-status t
74f0: 65 73 74 64 61 74 29 29 0a 09 09 09 20 28 69 66 estdat)).... (if
7500: 20 28 6e 6f 74 20 72 75 6e 66 6c 61 67 29 0a 09 (not runflag)..
7510: 09 09 20 20 20 20 20 28 69 66 20 28 6e 6f 74 20 .. (if (not
7520: 70 61 72 65 6e 74 2d 74 65 73 74 29 0a 09 09 09 parent-test)....
7530: 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 . (debug:print 1
7540: 20 22 4e 4f 54 45 3a 20 4e 6f 74 20 73 74 61 72 "NOTE: Not star
7550: 74 69 6e 67 20 74 65 73 74 20 22 20 6e 65 77 2d ting test " new-
7560: 74 65 73 74 2d 6e 61 6d 65 20 22 20 61 73 20 69 test-name " as i
7570: 74 20 69 73 20 73 74 61 74 65 20 5c 22 43 4f 4d t is state \"COM
7580: 50 4c 45 54 45 44 5c 22 20 61 6e 64 20 73 74 61 PLETED\" and sta
7590: 74 75 73 20 5c 22 22 20 28 74 65 73 74 3a 67 65 tus \"" (test:ge
75a0: 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61 74 t-status testdat
75b0: 29 20 22 5c 22 2c 20 75 73 65 20 2d 66 6f 72 63 ) "\", use -forc
75c0: 65 20 74 6f 20 6f 76 65 72 72 69 64 65 22 29 29 e to override"))
75d0: 0a 09 09 09 20 20 20 20 20 28 6c 65 74 2a 20 28 .... (let* (
75e0: 28 67 65 74 2d 70 72 65 72 65 71 73 2d 63 6d 64 (get-prereqs-cmd
75f0: 20 28 6c 61 6d 62 64 61 20 28 29 0a 09 09 09 09 (lambda ().....
7600: 09 09 20 20 20 20 20 20 20 28 64 62 2d 67 65 74 .. (db-get
7610: 2d 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 -prereqs-not-met
7620: 20 64 62 20 72 75 6e 2d 69 64 20 77 61 69 74 6f db run-id waito
7630: 6e 29 29 29 20 3b 3b 20 63 68 65 63 6b 20 62 65 n))) ;; check be
7640: 66 6f 72 65 20 72 75 6e 6e 69 6e 67 20 2e 2e 2e fore running ...
7650: 2e 0a 09 09 09 09 20 20 20 20 28 6c 61 75 6e 63 ...... (launc
7660: 68 2d 63 6d 64 20 20 20 20 20 20 28 6c 61 6d 62 h-cmd (lamb
7670: 64 61 20 28 29 0a 09 09 09 09 09 09 20 20 20 20 da ().......
7680: 20 20 20 28 6c 61 75 6e 63 68 2d 74 65 73 74 20 (launch-test
7690: 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 63 db run-id test-c
76a0: 6f 6e 66 20 6b 65 79 76 61 6c 6c 73 74 20 74 65 onf keyvallst te
76b0: 73 74 2d 6e 61 6d 65 20 74 65 73 74 2d 70 61 74 st-name test-pat
76c0: 68 20 69 74 65 6d 64 61 74 29 29 29 0a 09 09 09 h itemdat)))....
76d0: 09 20 20 20 20 28 74 65 73 74 72 75 6e 64 61 74 . (testrundat
76e0: 20 20 20 20 20 20 28 6c 69 73 74 20 67 65 74 2d (list get-
76f0: 70 72 65 72 65 71 73 2d 63 6d 64 20 6c 61 75 6e prereqs-cmd laun
7700: 63 68 2d 63 6d 64 29 29 29 0a 09 09 09 20 20 20 ch-cmd)))....
7710: 20 20 20 20 28 69 66 20 28 6f 72 20 28 61 72 67 (if (or (arg
7720: 73 3a 67 65 74 2d 61 72 67 20 22 2d 66 6f 72 63 s:get-arg "-forc
7730: 65 22 29 0a 09 09 09 09 20 20 20 20 20 20 20 28 e")..... (
7740: 6c 65 74 20 28 28 70 72 65 71 73 2d 6e 6f 74 2d let ((preqs-not-
7750: 79 65 74 2d 6d 65 74 20 28 28 63 61 72 20 74 65 yet-met ((car te
7760: 73 74 72 75 6e 64 61 74 29 29 29 29 0a 09 09 09 strundat))))....
7770: 09 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 .. (debug:print
7780: 32 20 22 50 72 65 71 72 65 71 75 65 73 69 74 65 2 "Preqrequesite
7790: 73 20 66 6f 72 20 22 20 74 65 73 74 2d 6e 61 6d s for " test-nam
77a0: 65 20 22 3a 20 22 20 70 72 65 71 73 2d 6e 6f 74 e ": " preqs-not
77b0: 2d 79 65 74 2d 6d 65 74 29 0a 09 09 09 09 09 20 -yet-met)......
77c0: 28 6e 75 6c 6c 3f 20 70 72 65 71 73 2d 6e 6f 74 (null? preqs-not
77d0: 2d 79 65 74 2d 6d 65 74 29 29 29 20 3b 3b 20 61 -yet-met))) ;; a
77e0: 72 65 20 74 68 65 72 65 20 61 6e 79 20 74 65 73 re there any tes
77f0: 74 73 20 74 68 61 74 20 6d 75 73 74 20 62 65 20 ts that must be
7800: 72 75 6e 20 62 65 66 6f 72 65 20 74 68 69 73 20 run before this
7810: 6f 6e 65 2e 2e 2e 0a 09 09 09 09 20 20 20 28 69 one........ (i
7820: 66 20 28 6e 6f 74 20 28 28 63 61 64 72 20 74 65 f (not ((cadr te
7830: 73 74 72 75 6e 64 61 74 29 29 29 20 3b 3b 20 74 strundat))) ;; t
7840: 68 69 73 20 69 73 20 74 68 65 20 6c 69 6e 65 20 his is the line
7850: 74 68 61 74 20 6c 61 75 6e 63 68 65 73 20 74 68 that launches th
7860: 65 20 74 65 73 74 20 74 6f 20 74 68 65 20 72 65 e test to the re
7870: 6d 6f 74 65 20 68 6f 73 74 0a 09 09 09 09 20 20 mote host.....
7880: 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09 09 09 (begin.....
7890: 09 20 28 70 72 69 6e 74 20 22 45 52 52 4f 52 3a . (print "ERROR:
78a0: 20 46 61 69 6c 65 64 20 74 6f 20 6c 61 75 6e 63 Failed to launc
78b0: 68 20 74 68 65 20 74 65 73 74 2e 20 45 78 69 74 h the test. Exit
78c0: 69 6e 67 20 61 73 20 73 6f 6f 6e 20 61 73 20 70 ing as soon as p
78d0: 6f 73 73 69 62 6c 65 22 29 0a 09 09 09 09 09 20 ossible")......
78e0: 28 73 65 74 21 20 2a 67 6c 6f 62 61 6c 65 78 69 (set! *globalexi
78f0: 74 73 74 61 74 75 73 2a 20 31 29 20 3b 3b 20 0a tstatus* 1) ;; .
7900: 09 09 09 09 09 20 28 70 72 6f 63 65 73 73 2d 73 ..... (process-s
7910: 69 67 6e 61 6c 20 28 63 75 72 72 65 6e 74 2d 70 ignal (current-p
7920: 72 6f 63 65 73 73 2d 69 64 29 20 73 69 67 6e 61 rocess-id) signa
7930: 6c 2f 6b 69 6c 6c 29 0a 09 09 09 09 09 20 3b 28 l/kill)...... ;(
7940: 65 78 69 74 20 31 29 0a 09 09 09 09 09 20 29 29 exit 1)...... ))
7950: 0a 09 09 09 09 20 20 20 28 69 66 20 28 6e 6f 74 ..... (if (not
7960: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 (args:get-arg "
7970: 2d 6b 65 65 70 67 6f 69 6e 67 22 29 29 0a 09 09 -keepgoing"))...
7980: 09 09 20 20 20 20 20 20 20 28 68 61 73 68 2d 74 .. (hash-t
7990: 61 62 6c 65 2d 73 65 74 21 20 2a 77 61 69 74 69 able-set! *waiti
79a0: 6e 67 2d 71 75 65 75 65 2a 20 6e 65 77 2d 74 65 ng-queue* new-te
79b0: 73 74 2d 6e 61 6d 65 20 74 65 73 74 72 75 6e 64 st-name testrund
79c0: 61 74 29 29 29 29 29 29 29 0a 09 09 20 20 20 20 at)))))))...
79d0: 20 20 28 28 4b 49 4c 4c 45 44 29 20 0a 09 09 20 ((KILLED) ...
79e0: 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 (debug:pri
79f0: 6e 74 20 31 20 22 4e 4f 54 45 3a 20 22 20 6e 65 nt 1 "NOTE: " ne
7a00: 77 2d 74 65 73 74 2d 6e 61 6d 65 20 22 20 69 73 w-test-name " is
7a10: 20 61 6c 72 65 61 64 79 20 72 75 6e 6e 69 6e 67 already running
7a20: 20 6f 72 20 77 61 73 20 65 78 70 6c 69 63 74 6c or was explictl
7a30: 79 20 6b 69 6c 6c 65 64 2c 20 75 73 65 20 2d 66 y killed, use -f
7a40: 6f 72 63 65 20 74 6f 20 6c 61 75 6e 63 68 20 69 orce to launch i
7a50: 74 2e 22 29 29 0a 09 09 20 20 20 20 20 20 28 28 t."))... ((
7a60: 4c 41 55 4e 43 48 45 44 20 52 45 4d 4f 54 45 48 LAUNCHED REMOTEH
7a70: 4f 53 54 53 54 41 52 54 20 52 55 4e 4e 49 4e 47 OSTSTART RUNNING
7a80: 29 20 20 0a 09 09 20 20 20 20 20 20 20 28 69 66 ) ... (if
7a90: 20 28 3e 20 28 2d 20 28 63 75 72 72 65 6e 74 2d (> (- (current-
7aa0: 73 65 63 6f 6e 64 73 29 28 2b 20 28 64 62 3a 74 seconds)(+ (db:t
7ab0: 65 73 74 2d 67 65 74 2d 65 76 65 6e 74 5f 74 69 est-get-event_ti
7ac0: 6d 65 20 74 65 73 74 64 61 74 29 0a 09 09 09 09 me testdat).....
7ad0: 09 09 20 20 20 20 20 28 64 62 3a 74 65 73 74 2d .. (db:test-
7ae0: 67 65 74 2d 72 75 6e 5f 64 75 72 61 74 69 6f 6e get-run_duration
7af0: 20 74 65 73 74 64 61 74 29 29 29 0a 09 09 09 20 testdat)))....
7b00: 20 20 20 20 20 31 30 30 29 20 3b 3b 20 69 2e 65 100) ;; i.e
7b10: 2e 20 6e 6f 20 75 70 64 61 74 65 20 66 6f 72 20 . no update for
7b20: 6d 6f 72 65 20 74 68 61 6e 20 31 30 30 20 73 65 more than 100 se
7b30: 63 6f 6e 64 73 0a 09 09 09 20 20 20 28 62 65 67 conds.... (beg
7b40: 69 6e 0a 09 09 09 20 20 20 20 20 28 64 65 62 75 in.... (debu
7b50: 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e 49 g:print 0 "WARNI
7b60: 4e 47 3a 20 54 65 73 74 20 22 20 74 65 73 74 2d NG: Test " test-
7b70: 6e 61 6d 65 20 22 20 61 70 70 65 61 72 73 20 74 name " appears t
7b80: 6f 20 62 65 20 64 65 61 64 2e 20 46 6f 72 63 69 o be dead. Forci
7b90: 6e 67 20 69 74 20 74 6f 20 73 74 61 74 65 20 49 ng it to state I
7ba0: 4e 43 4f 4d 50 4c 45 54 45 20 61 6e 64 20 73 74 NCOMPLETE and st
7bb0: 61 74 75 73 20 53 54 55 43 4b 2f 44 45 41 44 22 atus STUCK/DEAD"
7bc0: 29 0a 09 09 09 20 20 20 20 20 28 74 65 73 74 2d ).... (test-
7bd0: 73 65 74 2d 73 74 61 74 75 73 21 20 64 62 20 72 set-status! db r
7be0: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 un-id test-name
7bf0: 22 49 4e 43 4f 4d 50 4c 45 54 45 22 20 22 53 54 "INCOMPLETE" "ST
7c00: 55 43 4b 2f 44 45 41 44 22 20 69 74 65 6d 64 61 UCK/DEAD" itemda
7c10: 74 20 22 54 65 73 74 20 69 73 20 73 74 75 63 6b t "Test is stuck
7c20: 20 6f 72 20 64 65 61 64 22 20 23 66 29 29 0a 09 or dead" #f))..
7c30: 09 09 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e .. (debug:prin
7c40: 74 20 32 20 22 4e 4f 54 45 3a 20 22 20 74 65 73 t 2 "NOTE: " tes
7c50: 74 2d 6e 61 6d 65 20 22 20 69 73 20 61 6c 72 65 t-name " is alre
7c60: 61 64 79 20 72 75 6e 6e 69 6e 67 22 29 29 29 0a ady running"))).
7c70: 09 09 20 20 20 20 20 20 28 65 6c 73 65 20 20 20 .. (else
7c80: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 (debug:print
7c90: 20 30 20 22 45 52 52 4f 52 3a 20 46 61 69 6c 65 0 "ERROR: Faile
7ca0: 64 20 74 6f 20 6c 61 75 6e 63 68 20 74 65 73 74 d to launch test
7cb0: 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 " new-test-name
7cc0: 20 22 2e 20 55 6e 72 65 63 6f 67 6e 69 73 65 64 ". Unrecognised
7cd0: 20 73 74 61 74 65 20 22 20 28 74 65 73 74 3a 67 state " (test:g
7ce0: 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 74 et-state testdat
7cf0: 29 29 29 29 29 29 0a 09 20 20 20 20 20 20 28 69 )))))).. (i
7d00: 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 61 f (not (null? ta
7d10: 6c 29 29 0a 09 09 20 20 28 6c 6f 6f 70 20 28 63 l))... (loop (c
7d20: 61 72 20 74 61 6c 29 28 63 64 72 20 74 61 6c 29 ar tal)(cdr tal)
7d30: 29 29 29 29 29 29 29 29 0a 0a 28 64 65 66 69 6e ))))))))..(defin
7d40: 65 20 28 72 75 6e 2d 77 61 69 74 69 6e 67 2d 74 e (run-waiting-t
7d50: 65 73 74 73 20 64 62 29 0a 20 20 28 6c 65 74 20 ests db). (let
7d60: 28 28 6e 75 6d 74 72 69 65 73 20 20 20 20 20 20 ((numtries
7d70: 20 20 20 20 20 30 29 0a 09 28 6c 61 73 74 2d 74 0)..(last-t
7d80: 72 79 2d 74 69 6d 65 20 20 20 20 20 20 28 63 75 ry-time (cu
7d90: 72 72 65 6e 74 2d 73 65 63 6f 6e 64 73 29 29 0a rrent-seconds)).
7da0: 09 28 74 69 6d 65 73 20 20 20 20 20 20 20 20 20 .(times
7db0: 20 20 20 20 20 28 6c 69 73 74 20 31 29 29 29 20 (list 1)))
7dc0: 3b 3b 20 6d 69 6e 75 74 65 73 20 74 6f 20 77 61 ;; minutes to wa
7dd0: 69 74 20 62 65 66 6f 72 65 20 74 72 79 69 6e 67 it before trying
7de0: 20 61 67 61 69 6e 20 74 6f 20 6b 69 63 6b 20 6f again to kick o
7df0: 66 66 20 72 75 6e 73 0a 20 20 20 20 3b 3b 20 42 ff runs. ;; B
7e00: 55 47 20 74 68 69 73 20 68 61 63 6b 20 6f 66 20 UG this hack of
7e10: 62 72 75 74 65 20 66 6f 72 63 65 20 72 65 74 72 brute force retr
7e20: 79 69 6e 67 20 77 6f 72 6b 73 20 71 75 69 74 65 ying works quite
7e30: 20 77 65 6c 6c 20 66 6f 72 20 6d 61 6e 79 20 63 well for many c
7e40: 61 73 65 73 20 62 75 74 20 0a 20 20 20 20 3b 3b ases but . ;;
7e50: 20 20 20 20 20 77 68 61 74 20 69 73 20 6e 65 65 what is nee
7e60: 64 65 64 20 69 73 20 74 6f 20 63 68 65 63 6b 20 ded is to check
7e70: 74 68 65 20 64 62 20 66 6f 72 20 74 65 73 74 73 the db for tests
7e80: 20 74 68 61 74 20 68 61 76 65 20 66 61 69 6c 65 that have faile
7e90: 64 20 6c 65 73 73 20 74 68 61 6e 0a 20 20 20 20 d less than.
7ea0: 3b 3b 20 20 20 20 20 4e 20 74 69 6d 65 73 20 6f ;; N times o
7eb0: 72 20 6e 65 76 65 72 20 62 65 65 6e 20 73 74 61 r never been sta
7ec0: 72 74 65 64 20 61 6e 64 20 6b 69 63 6b 20 74 68 rted and kick th
7ed0: 65 6d 20 6f 66 66 20 61 67 61 69 6e 0a 20 20 20 em off again.
7ee0: 20 28 6c 65 74 20 6c 6f 6f 70 20 28 28 77 61 69 (let loop ((wai
7ef0: 74 69 6e 67 2d 74 65 73 74 2d 6e 61 6d 65 73 20 ting-test-names
7f00: 28 68 61 73 68 2d 74 61 62 6c 65 2d 6b 65 79 73 (hash-table-keys
7f10: 20 2a 77 61 69 74 69 6e 67 2d 71 75 65 75 65 2a *waiting-queue*
7f20: 29 29 29 0a 20 20 20 20 20 20 28 63 6f 6e 64 0a ))). (cond.
7f30: 20 20 20 20 20 20 20 28 28 6e 6f 74 20 28 72 75 ((not (ru
7f40: 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65 2d ns:can-run-more-
7f50: 74 65 73 74 73 20 64 62 29 29 0a 09 28 73 6c 65 tests db))..(sle
7f60: 65 70 20 32 29 0a 09 28 6c 6f 6f 70 20 77 61 69 ep 2)..(loop wai
7f70: 74 69 6e 67 2d 74 65 73 74 2d 6e 61 6d 65 73 29 ting-test-names)
7f80: 29 0a 20 20 20 20 20 20 20 28 28 6e 75 6c 6c 3f ). ((null?
7f90: 20 77 61 69 74 69 6e 67 2d 74 65 73 74 2d 6e 61 waiting-test-na
7fa0: 6d 65 73 29 0a 09 28 64 65 62 75 67 3a 70 72 69 mes)..(debug:pri
7fb0: 6e 74 20 31 20 22 41 6c 6c 20 74 65 73 74 73 20 nt 1 "All tests
7fc0: 6c 61 75 6e 63 68 65 64 22 29 29 0a 20 20 20 20 launched")).
7fd0: 20 20 20 28 65 6c 73 65 0a 09 28 73 65 74 21 20 (else..(set!
7fe0: 6e 75 6d 74 72 69 65 73 20 28 2b 20 6e 75 6d 74 numtries (+ numt
7ff0: 72 69 65 73 20 31 29 29 0a 09 28 66 6f 72 2d 65 ries 1))..(for-e
8000: 61 63 68 20 28 6c 61 6d 62 64 61 20 28 74 65 73 ach (lambda (tes
8010: 74 6e 61 6d 65 29 0a 09 09 20 20 20 20 28 69 66 tname)... (if
8020: 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d (runs:can-run-m
8030: 6f 72 65 2d 74 65 73 74 73 20 64 62 29 0a 09 09 ore-tests db)...
8040: 09 28 6c 65 74 2a 20 28 28 74 65 73 74 64 61 74 .(let* ((testdat
8050: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 (hash-table-ref
8060: 20 2a 77 61 69 74 69 6e 67 2d 71 75 65 75 65 2a *waiting-queue*
8070: 20 74 65 73 74 6e 61 6d 65 29 29 0a 09 09 09 20 testname))....
8080: 20 20 20 20 20 20 28 70 72 65 72 65 71 73 20 28 (prereqs (
8090: 28 63 61 72 20 74 65 73 74 64 61 74 29 29 29 0a (car testdat))).
80a0: 09 09 09 20 20 20 20 20 20 20 28 6c 64 62 20 20 ... (ldb
80b0: 20 20 20 28 69 66 20 64 62 20 64 62 20 28 6f 70 (if db db (op
80c0: 65 6e 2d 64 62 29 29 29 29 0a 09 09 09 20 20 28 en-db)))).... (
80d0: 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 70 debug:print 2 "p
80e0: 72 65 72 65 71 73 20 72 65 6d 61 69 6e 69 6e 67 rereqs remaining
80f0: 3a 20 22 20 70 72 65 72 65 71 73 29 0a 09 09 09 : " prereqs)....
8100: 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 70 72 65 (if (null? pre
8110: 72 65 71 73 29 0a 09 09 09 20 20 20 20 20 20 28 reqs).... (
8120: 62 65 67 69 6e 0a 09 09 09 09 28 64 65 62 75 67 begin.....(debug
8130: 3a 70 72 69 6e 74 20 32 20 22 50 72 65 72 65 71 :print 2 "Prereq
8140: 75 69 73 69 74 65 73 20 6d 65 74 2c 20 6c 61 75 uisites met, lau
8150: 6e 63 68 69 6e 67 20 22 20 74 65 73 74 6e 61 6d nching " testnam
8160: 65 29 0a 09 09 09 09 28 28 63 61 64 72 20 74 65 e).....((cadr te
8170: 73 74 64 61 74 29 29 0a 09 09 09 09 28 68 61 73 stdat)).....(has
8180: 68 2d 74 61 62 6c 65 2d 64 65 6c 65 74 65 21 20 h-table-delete!
8190: 2a 77 61 69 74 69 6e 67 2d 71 75 65 75 65 2a 20 *waiting-queue*
81a0: 74 65 73 74 6e 61 6d 65 29 29 29 0a 09 09 09 20 testname)))....
81b0: 20 28 69 66 20 28 6e 6f 74 20 64 62 29 0a 09 09 (if (not db)...
81c0: 09 20 20 20 20 20 20 28 73 71 6c 69 74 65 33 3a . (sqlite3:
81d0: 66 69 6e 61 6c 69 7a 65 21 20 6c 64 62 29 29 29 finalize! ldb)))
81e0: 29 29 0a 09 09 20 20 77 61 69 74 69 6e 67 2d 74 ))... waiting-t
81f0: 65 73 74 2d 6e 61 6d 65 73 29 0a 09 3b 3b 20 28 est-names)..;; (
8200: 73 6c 65 65 70 20 31 30 29 20 3b 3b 20 6e 6f 20 sleep 10) ;; no
8210: 70 6f 69 6e 74 20 69 6e 20 72 75 73 68 69 6e 67 point in rushing
8220: 20 74 68 69 6e 67 73 20 61 74 20 74 68 69 73 20 things at this
8230: 73 74 61 67 65 3f 0a 09 28 6c 6f 6f 70 20 28 68 stage?..(loop (h
8240: 61 73 68 2d 74 61 62 6c 65 2d 6b 65 79 73 20 2a ash-table-keys *
8250: 77 61 69 74 69 6e 67 2d 71 75 65 75 65 2a 29 29 waiting-queue*))
8260: 29 29 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 )))))..(define (
8270: 67 65 74 2d 64 69 72 2d 75 70 2d 6e 20 64 69 72 get-dir-up-n dir
8280: 20 2e 20 70 61 72 61 6d 73 29 20 0a 20 20 28 6c . params) . (l
8290: 65 74 20 28 28 64 70 61 72 74 73 20 20 28 73 74 et ((dparts (st
82a0: 72 69 6e 67 2d 73 70 6c 69 74 20 64 69 72 20 22 ring-split dir "
82b0: 2f 22 29 29 0a 09 28 63 6f 75 6e 74 20 20 20 28 /"))..(count (
82c0: 69 66 20 28 6e 75 6c 6c 3f 20 70 61 72 61 6d 73 if (null? params
82d0: 29 20 31 20 28 63 61 72 20 70 61 72 61 6d 73 29 ) 1 (car params)
82e0: 29 29 29 0a 20 20 20 20 28 63 6f 6e 63 20 22 2f ))). (conc "/
82f0: 22 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 " (string-inters
8300: 70 65 72 73 65 20 0a 09 20 20 20 20 20 20 20 28 perse .. (
8310: 74 61 6b 65 20 64 70 61 72 74 73 20 28 2d 20 28 take dparts (- (
8320: 6c 65 6e 67 74 68 20 64 70 61 72 74 73 29 20 63 length dparts) c
8330: 6f 75 6e 74 29 29 0a 09 20 20 20 20 20 20 20 22 ount)).. "
8340: 2f 22 29 29 29 29 0a 3b 3b 20 52 65 6d 6f 76 65 /")))).;; Remove
8350: 20 72 75 6e 73 0a 3b 3b 20 66 69 65 6c 64 73 20 runs.;; fields
8360: 61 72 65 20 70 61 73 73 69 6e 67 20 69 6e 20 74 are passing in t
8370: 68 72 6f 75 67 68 20 0a 28 64 65 66 69 6e 65 20 hrough .(define
8380: 28 72 75 6e 73 3a 72 65 6d 6f 76 65 2d 72 75 6e (runs:remove-run
8390: 73 20 64 62 20 72 75 6e 6e 61 6d 65 70 61 74 74 s db runnamepatt
83a0: 20 74 65 73 74 70 61 74 74 20 69 74 65 6d 70 61 testpatt itempa
83b0: 74 74 29 0a 20 20 28 6c 65 74 2a 20 28 28 6b 65 tt). (let* ((ke
83c0: 79 73 20 20 20 20 20 20 20 20 28 64 62 2d 67 65 ys (db-ge
83d0: 74 2d 6b 65 79 73 20 64 62 29 29 0a 09 20 28 72 t-keys db)).. (r
83e0: 75 6e 64 61 74 20 20 20 20 20 20 28 72 75 6e 73 undat (runs
83f0: 3a 67 65 74 2d 72 75 6e 73 2d 62 79 2d 70 61 74 :get-runs-by-pat
8400: 74 20 64 62 20 6b 65 79 73 20 72 75 6e 6e 61 6d t db keys runnam
8410: 65 70 61 74 74 29 29 0a 09 20 28 68 65 61 64 65 epatt)).. (heade
8420: 72 20 20 20 20 20 20 28 76 65 63 74 6f 72 2d 72 r (vector-r
8430: 65 66 20 72 75 6e 64 61 74 20 30 29 29 0a 09 20 ef rundat 0))..
8440: 28 72 75 6e 73 20 20 20 20 20 20 20 20 28 76 65 (runs (ve
8450: 63 74 6f 72 2d 72 65 66 20 72 75 6e 64 61 74 20 ctor-ref rundat
8460: 31 29 29 29 0a 20 20 20 20 28 64 65 62 75 67 3a 1))). (debug:
8470: 70 72 69 6e 74 20 31 20 22 48 65 61 64 65 72 3a print 1 "Header:
8480: 20 22 20 68 65 61 64 65 72 29 0a 20 20 20 20 28 " header). (
8490: 66 6f 72 2d 65 61 63 68 0a 20 20 20 20 20 28 6c for-each. (l
84a0: 61 6d 62 64 61 20 28 72 75 6e 29 0a 20 20 20 20 ambda (run).
84b0: 20 20 20 28 6c 65 74 20 28 28 72 75 6e 6b 65 79 (let ((runkey
84c0: 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 (string-intersp
84d0: 65 72 73 65 20 28 6d 61 70 20 28 6c 61 6d 62 64 erse (map (lambd
84e0: 61 20 28 6b 29 0a 09 09 09 09 09 09 28 64 62 3a a (k).......(db:
84f0: 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 get-value-by-hea
8500: 64 65 72 20 72 75 6e 20 68 65 61 64 65 72 20 28 der run header (
8510: 76 65 63 74 6f 72 2d 72 65 66 20 6b 20 30 29 29 vector-ref k 0))
8520: 29 20 6b 65 79 73 29 20 22 2f 22 29 29 0a 09 20 ) keys) "/"))..
8530: 20 20 20 20 28 64 69 72 73 2d 74 6f 2d 72 65 6d (dirs-to-rem
8540: 6f 76 65 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74 ove (make-hash-t
8550: 61 62 6c 65 29 29 29 0a 09 20 28 6c 65 74 2a 20 able))).. (let*
8560: 28 28 72 75 6e 2d 69 64 20 28 64 62 3a 67 65 74 ((run-id (db:get
8570: 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 -value-by-header
8580: 20 72 75 6e 20 68 65 61 64 65 72 20 22 69 64 22 run header "id"
8590: 29 20 29 0a 09 09 28 74 65 73 74 73 20 20 28 64 ) )...(tests (d
85a0: 62 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d b-get-tests-for-
85b0: 72 75 6e 20 64 62 20 28 64 62 3a 67 65 74 2d 76 run db (db:get-v
85c0: 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72 alue-by-header r
85d0: 75 6e 20 68 65 61 64 65 72 20 22 69 64 22 29 20 un header "id")
85e0: 74 65 73 74 70 61 74 74 20 69 74 65 6d 70 61 74 testpatt itempat
85f0: 74 29 29 0a 09 09 28 6c 61 73 74 74 70 61 74 68 t))...(lasttpath
8600: 20 22 2f 64 6f 65 73 2f 6e 6f 74 2f 65 78 69 73 "/does/not/exis
8610: 74 2f 49 2f 68 6f 70 65 22 29 29 0a 0a 09 20 20 t/I/hope"))...
8620: 20 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f (if (not (null?
8630: 20 74 65 73 74 73 29 29 0a 09 20 20 20 20 20 20 tests))..
8640: 20 28 62 65 67 69 6e 0a 09 09 20 28 64 65 62 75 (begin... (debu
8650: 67 3a 70 72 69 6e 74 20 31 20 22 52 65 6d 6f 76 g:print 1 "Remov
8660: 69 6e 67 20 74 65 73 74 73 20 66 6f 72 20 72 75 ing tests for ru
8670: 6e 3a 20 22 20 72 75 6e 6b 65 79 20 22 20 22 20 n: " runkey " "
8680: 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 (db:get-value-by
8690: 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 -header run head
86a0: 65 72 20 22 72 75 6e 6e 61 6d 65 22 29 29 0a 09 er "runname"))..
86b0: 09 20 28 66 6f 72 2d 65 61 63 68 0a 09 09 20 20 . (for-each...
86c0: 28 6c 61 6d 62 64 61 20 28 74 65 73 74 29 0a 09 (lambda (test)..
86d0: 09 20 20 20 20 28 6c 65 74 2a 20 28 28 69 74 65 . (let* ((ite
86e0: 6d 2d 70 61 74 68 20 28 64 62 3a 74 65 73 74 2d m-path (db:test-
86f0: 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 get-item-path te
8700: 73 74 29 29 0a 09 09 09 20 20 20 28 74 65 73 74 st)).... (test
8710: 2d 6e 61 6d 65 20 28 64 62 3a 74 65 73 74 2d 67 -name (db:test-g
8720: 65 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 et-testname test
8730: 29 29 0a 09 09 09 20 20 20 28 72 75 6e 2d 64 69 )).... (run-di
8740: 72 20 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74 r (db:test-get
8750: 2d 72 75 6e 64 69 72 20 74 65 73 74 29 29 29 0a -rundir test))).
8760: 09 09 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 .. (debug:p
8770: 72 69 6e 74 20 31 20 22 20 20 22 20 28 64 62 3a rint 1 " " (db:
8780: 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d test-get-testnam
8790: 65 20 74 65 73 74 29 20 22 20 69 64 3a 20 22 20 e test) " id: "
87a0: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 (db:test-get-id
87b0: 74 65 73 74 29 20 22 20 22 20 69 74 65 6d 2d 70 test) " " item-p
87c0: 61 74 68 29 0a 09 09 20 20 20 20 20 20 28 64 62 ath)... (db
87d0: 3a 64 65 6c 65 74 65 2d 74 65 73 74 2d 72 65 63 :delete-test-rec
87e0: 6f 72 64 73 20 64 62 20 28 64 62 3a 74 65 73 74 ords db (db:test
87f0: 2d 67 65 74 2d 69 64 20 74 65 73 74 29 29 0a 09 -get-id test))..
8800: 09 20 20 20 20 20 20 28 69 66 20 28 3e 20 28 73 . (if (> (s
8810: 74 72 69 6e 67 2d 6c 65 6e 67 74 68 20 72 75 6e tring-length run
8820: 2d 64 69 72 29 20 35 29 20 3b 3b 20 62 61 64 20 -dir) 5) ;; bad
8830: 68 65 75 72 69 73 74 69 63 20 62 75 74 20 73 68 heuristic but sh
8840: 6f 75 6c 64 20 70 72 65 76 65 6e 74 20 2f 74 6d ould prevent /tm
8850: 70 20 2f 68 6f 6d 65 20 65 74 63 2e 0a 09 09 09 p /home etc.....
8860: 20 20 28 6c 65 74 20 28 28 66 75 6c 6c 70 61 74 (let ((fullpat
8870: 68 20 72 75 6e 2d 64 69 72 29 29 20 3b 3b 20 22 h run-dir)) ;; "
8880: 2f 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d /" (db:test-get-
8890: 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 29 29 item-path test))
88a0: 29 29 0a 09 09 09 20 20 20 20 28 73 65 74 21 20 )).... (set!
88b0: 6c 61 73 74 74 70 61 74 68 20 66 75 6c 6c 70 61 lasttpath fullpa
88c0: 74 68 29 0a 09 09 09 20 20 20 20 28 68 61 73 68 th).... (hash
88d0: 2d 74 61 62 6c 65 2d 73 65 74 21 20 64 69 72 73 -table-set! dirs
88e0: 2d 74 6f 2d 72 65 6d 6f 76 65 20 66 75 6c 6c 70 -to-remove fullp
88f0: 61 74 68 20 23 74 29 0a 09 09 09 20 20 20 20 3b ath #t).... ;
8900: 3b 20 54 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 ; The following
8910: 77 61 73 20 74 68 65 20 73 61 66 65 20 64 65 6c was the safe del
8920: 65 74 65 20 63 6f 64 65 20 62 75 74 20 69 74 20 ete code but it
8930: 77 61 73 20 6e 6f 74 20 62 65 69 6e 67 20 65 78 was not being ex
8940: 65 63 74 75 74 65 64 2e 0a 09 09 09 20 20 20 20 ectuted.....
8950: 3b 3b 20 28 6c 65 74 2a 20 28 28 64 69 72 73 2d ;; (let* ((dirs-
8960: 63 6f 75 6e 74 20 28 2b 20 31 20 28 6c 65 6e 67 count (+ 1 (leng
8970: 74 68 20 6b 65 79 73 29 28 6c 65 6e 67 74 68 20 th keys)(length
8980: 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 69 74 (string-split it
8990: 65 6d 2d 70 61 74 68 20 22 2f 22 29 29 29 29 0a em-path "/")))).
89a0: 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20 20 20 ... ;;
89b0: 20 28 64 69 72 2d 74 6f 2d 72 65 6d 20 28 67 65 (dir-to-rem (ge
89c0: 74 2d 64 69 72 2d 75 70 2d 6e 20 66 75 6c 6c 70 t-dir-up-n fullp
89d0: 61 74 68 20 64 69 72 73 2d 63 6f 75 6e 74 29 29 ath dirs-count))
89e0: 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20 20 .... ;;
89f0: 20 20 28 72 65 6d 61 69 6e 69 6e 67 64 20 28 73 (remainingd (s
8a00: 74 72 69 6e 67 2d 73 75 62 73 74 69 74 75 74 65 tring-substitute
8a10: 20 28 72 65 67 65 78 70 20 28 63 6f 6e 63 20 22 (regexp (conc "
8a20: 5e 22 20 64 69 72 2d 74 6f 2d 72 65 6d 20 22 2f ^" dir-to-rem "/
8a30: 22 29 29 20 22 22 20 66 75 6c 6c 70 61 74 68 29 ")) "" fullpath)
8a40: 29 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20 ).... ;;
8a50: 20 20 20 28 63 6d 64 20 28 63 6f 6e 63 20 22 63 (cmd (conc "c
8a60: 64 20 22 20 64 69 72 2d 74 6f 2d 72 65 6d 20 22 d " dir-to-rem "
8a70: 3b 20 72 6d 64 69 72 20 2d 70 20 22 20 72 65 6d ; rmdir -p " rem
8a80: 61 69 6e 69 6e 67 64 20 29 29 29 0a 09 09 09 20 ainingd )))....
8a90: 20 20 20 3b 3b 20 20 20 28 69 66 20 28 66 69 6c ;; (if (fil
8aa0: 65 2d 65 78 69 73 74 73 3f 20 66 75 6c 6c 70 61 e-exists? fullpa
8ab0: 74 68 29 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 th).... ;;
8ac0: 20 20 20 20 28 62 65 67 69 6e 0a 09 09 09 20 20 (begin....
8ad0: 20 20 3b 3b 20 20 20 20 20 20 20 20 20 28 64 65 ;; (de
8ae0: 62 75 67 3a 70 72 69 6e 74 20 31 20 63 6d 64 29 bug:print 1 cmd)
8af0: 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20 20 .... ;;
8b00: 20 20 20 28 73 79 73 74 65 6d 20 63 6d 64 29 29 (system cmd))
8b10: 29 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 29 29 ).... ;; ))
8b20: 0a 09 09 09 20 20 20 20 29 29 29 29 0a 09 09 20 .... ))))...
8b30: 20 20 20 74 65 73 74 73 29 29 29 0a 0a 09 20 20 tests)))...
8b40: 20 3b 3b 20 6c 6f 6f 6b 20 74 68 6f 75 67 68 20 ;; look though
8b50: 74 68 65 20 64 69 72 73 2d 74 6f 2d 72 65 6d 6f the dirs-to-remo
8b60: 76 65 20 66 6f 72 20 63 61 6e 64 69 64 61 74 65 ve for candidate
8b70: 73 20 66 6f 72 20 72 65 6d 6f 76 61 6c 2e 20 44 s for removal. D
8b80: 6f 20 74 68 69 73 20 61 66 74 65 72 20 64 65 6c o this after del
8b90: 65 74 69 6e 67 20 74 68 65 20 72 65 63 6f 72 64 eting the record
8ba0: 73 0a 09 20 20 20 3b 3b 20 66 6f 72 20 65 61 63 s.. ;; for eac
8bb0: 68 20 74 65 73 74 20 69 6e 20 63 61 73 65 20 77 h test in case w
8bc0: 65 20 67 65 74 20 6b 69 6c 6c 65 64 2e 20 54 68 e get killed. Th
8bd0: 61 74 20 73 68 6f 75 6c 64 20 6d 69 6e 69 6d 69 at should minimi
8be0: 7a 65 20 74 68 65 20 64 65 74 72 69 74 75 73 20 ze the detritus
8bf0: 6c 65 66 74 20 6f 6e 20 64 69 73 6b 0a 09 20 20 left on disk..
8c00: 20 3b 3b 20 70 72 6f 63 65 73 73 20 74 68 65 20 ;; process the
8c10: 64 69 72 73 20 66 72 6f 6d 20 6c 6f 6e 67 65 73 dirs from longes
8c20: 74 20 73 74 72 69 6e 67 20 6c 65 6e 67 74 68 20 t string length
8c30: 74 6f 20 73 68 6f 72 74 65 73 74 0a 09 20 20 20 to shortest..
8c40: 28 66 6f 72 2d 65 61 63 68 20 0a 09 20 20 20 20 (for-each ..
8c50: 28 6c 61 6d 62 64 61 20 28 64 69 72 2d 74 6f 2d (lambda (dir-to-
8c60: 72 65 6d 6f 76 65 29 0a 09 20 20 20 20 20 20 28 remove).. (
8c70: 69 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f if (file-exists?
8c80: 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 0a dir-to-remove).
8c90: 09 09 20 20 28 6c 65 74 20 28 28 64 69 72 2d 69 .. (let ((dir-i
8ca0: 6e 2d 64 62 20 27 28 29 29 29 0a 09 09 20 20 20 n-db '()))...
8cb0: 20 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 (sqlite3:for-ea
8cc0: 63 68 2d 72 6f 77 0a 09 09 20 20 20 20 20 28 6c ch-row... (l
8cd0: 61 6d 62 64 61 20 28 64 69 72 29 0a 09 09 20 20 ambda (dir)...
8ce0: 20 20 20 20 20 28 73 65 74 21 20 64 69 72 2d 69 (set! dir-i
8cf0: 6e 2d 64 62 20 28 63 6f 6e 73 20 64 69 72 20 64 n-db (cons dir d
8d00: 69 72 2d 69 6e 2d 64 62 29 29 29 0a 09 09 20 20 ir-in-db)))...
8d10: 20 20 20 64 62 20 22 53 45 4c 45 43 54 20 72 75 db "SELECT ru
8d20: 6e 64 69 72 20 46 52 4f 4d 20 74 65 73 74 73 20 ndir FROM tests
8d30: 57 48 45 52 45 20 72 75 6e 64 69 72 20 4c 49 4b WHERE rundir LIK
8d40: 45 20 3f 3b 22 20 0a 09 09 20 20 20 20 20 28 63 E ?;" ... (c
8d50: 6f 6e 63 20 22 25 22 20 64 69 72 2d 74 6f 2d 72 onc "%" dir-to-r
8d60: 65 6d 6f 76 65 20 22 25 22 29 29 20 3b 3b 20 79 emove "%")) ;; y
8d70: 65 73 2c 20 49 27 6d 20 67 6f 69 6e 67 20 74 6f es, I'm going to
8d80: 20 62 61 69 6c 20 69 66 20 74 68 65 72 65 20 69 bail if there i
8d90: 73 20 61 6e 79 74 68 69 6e 67 20 6c 69 6b 65 20 s anything like
8da0: 74 68 69 73 20 64 69 72 20 69 6e 20 74 68 65 20 this dir in the
8db0: 64 62 0a 09 09 20 20 20 20 28 69 66 20 28 6e 75 db... (if (nu
8dc0: 6c 6c 3f 20 64 69 72 2d 69 6e 2d 64 62 29 0a 09 ll? dir-in-db)..
8dd0: 09 09 28 62 65 67 69 6e 0a 09 09 09 20 20 28 64 ..(begin.... (d
8de0: 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 52 65 ebug:print 2 "Re
8df0: 6d 6f 76 69 6e 67 20 64 69 72 65 63 74 6f 72 79 moving directory
8e00: 20 77 69 74 68 20 7a 65 72 6f 20 64 62 20 72 65 with zero db re
8e10: 66 65 72 65 6e 63 65 73 3a 20 22 20 64 69 72 2d ferences: " dir-
8e20: 74 6f 2d 72 65 6d 6f 76 65 29 0a 09 09 09 20 20 to-remove)....
8e30: 28 73 79 73 74 65 6d 20 28 63 6f 6e 63 20 22 72 (system (conc "r
8e40: 6d 20 2d 72 66 20 22 20 64 69 72 2d 74 6f 2d 72 m -rf " dir-to-r
8e50: 65 6d 6f 76 65 29 29 0a 09 09 09 20 20 28 68 61 emove)).... (ha
8e60: 73 68 2d 74 61 62 6c 65 2d 64 65 6c 65 74 65 21 sh-table-delete!
8e70: 20 64 69 72 73 2d 74 6f 2d 72 65 6d 6f 76 65 20 dirs-to-remove
8e80: 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 29 0a dir-to-remove)).
8e90: 09 09 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20 ...(debug:print
8ea0: 32 20 22 53 6b 69 70 70 69 6e 67 20 72 65 6d 6f 2 "Skipping remo
8eb0: 76 61 6c 20 6f 66 20 22 20 64 69 72 2d 74 6f 2d val of " dir-to-
8ec0: 72 65 6d 6f 76 65 20 22 20 66 6f 72 20 6e 6f 77 remove " for now
8ed0: 20 61 73 20 69 74 20 73 74 69 6c 6c 20 68 61 73 as it still has
8ee0: 20 72 65 66 65 72 65 6e 63 65 73 20 69 6e 20 74 references in t
8ef0: 68 65 20 64 61 74 61 62 61 73 65 22 29 29 29 29 he database"))))
8f00: 29 0a 09 20 20 20 20 28 73 6f 72 74 20 28 68 61 ).. (sort (ha
8f10: 73 68 2d 74 61 62 6c 65 2d 6b 65 79 73 20 64 69 sh-table-keys di
8f20: 72 73 2d 74 6f 2d 72 65 6d 6f 76 65 29 20 28 6c rs-to-remove) (l
8f30: 61 6d 62 64 61 20 28 61 20 62 29 28 3e 20 28 73 ambda (a b)(> (s
8f40: 74 72 69 6e 67 2d 6c 65 6e 67 74 68 20 61 29 28 tring-length a)(
8f50: 73 74 72 69 6e 67 2d 6c 65 6e 67 74 68 20 62 29 string-length b)
8f60: 29 29 29 29 0a 0a 09 20 20 20 3b 3b 20 72 65 6d ))))... ;; rem
8f70: 6f 76 65 20 74 68 65 20 72 75 6e 20 69 66 20 7a ove the run if z
8f80: 65 72 6f 20 74 65 73 74 73 20 72 65 6d 61 69 6e ero tests remain
8f90: 0a 09 20 20 20 28 6c 65 74 20 28 28 72 65 6d 74 .. (let ((remt
8fa0: 65 73 74 73 20 28 64 62 2d 67 65 74 2d 74 65 73 ests (db-get-tes
8fb0: 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 28 64 ts-for-run db (d
8fc0: 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 b:get-value-by-h
8fd0: 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65 72 eader run header
8fe0: 20 22 69 64 22 29 29 29 29 0a 09 20 20 20 20 20 "id"))))..
8ff0: 28 69 66 20 28 6e 75 6c 6c 3f 20 72 65 6d 74 65 (if (null? remte
9000: 73 74 73 29 20 3b 3b 20 6e 6f 20 6d 6f 72 65 20 sts) ;; no more
9010: 74 65 73 74 73 20 72 65 6d 61 69 6e 69 6e 67 0a tests remaining.
9020: 09 09 20 28 6c 65 74 2a 20 28 28 64 70 61 72 74 .. (let* ((dpart
9030: 73 20 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 s (string-split
9040: 20 6c 61 73 74 74 70 61 74 68 20 22 2f 22 29 29 lasttpath "/"))
9050: 0a 09 09 09 28 72 75 6e 70 61 74 68 20 28 63 6f ....(runpath (co
9060: 6e 63 20 22 2f 22 20 28 73 74 72 69 6e 67 2d 69 nc "/" (string-i
9070: 6e 74 65 72 73 70 65 72 73 65 20 0a 09 09 09 09 ntersperse .....
9080: 09 20 20 20 20 28 74 61 6b 65 20 64 70 61 72 74 . (take dpart
9090: 73 20 28 2d 20 28 6c 65 6e 67 74 68 20 64 70 61 s (- (length dpa
90a0: 72 74 73 29 20 31 29 29 0a 09 09 09 09 09 20 20 rts) 1))......
90b0: 20 20 22 2f 22 29 29 29 29 0a 09 09 20 20 20 28 "/"))))... (
90c0: 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 52 debug:print 1 "R
90d0: 65 6d 6f 76 69 6e 67 20 72 75 6e 3a 20 22 20 72 emoving run: " r
90e0: 75 6e 6b 65 79 20 22 20 22 20 28 64 62 3a 67 65 unkey " " (db:ge
90f0: 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 t-value-by-heade
9100: 72 20 72 75 6e 20 68 65 61 64 65 72 20 22 72 75 r run header "ru
9110: 6e 6e 61 6d 65 22 29 29 0a 09 09 20 20 20 28 64 nname"))... (d
9120: 62 3a 64 65 6c 65 74 65 2d 72 75 6e 20 64 62 20 b:delete-run db
9130: 72 75 6e 2d 69 64 29 0a 09 09 20 20 20 3b 3b 20 run-id)... ;;
9140: 6e 65 65 64 20 74 6f 20 66 69 67 75 72 65 20 6f need to figure o
9150: 75 74 20 74 68 65 20 70 61 74 68 20 74 6f 20 74 ut the path to t
9160: 68 65 20 72 75 6e 20 64 69 72 20 61 6e 64 20 72 he run dir and r
9170: 65 6d 6f 76 65 20 69 74 20 69 66 20 65 6d 70 74 emove it if empt
9180: 79 0a 09 09 20 20 20 3b 3b 20 20 20 20 28 69 66 y... ;; (if
9190: 20 28 6e 75 6c 6c 3f 20 28 67 6c 6f 62 20 28 63 (null? (glob (c
91a0: 6f 6e 63 20 72 75 6e 70 61 74 68 20 22 2f 2a 22 onc runpath "/*"
91b0: 29 29 29 0a 09 09 20 20 20 3b 3b 20 20 20 20 20 )))... ;;
91c0: 20 20 20 28 62 65 67 69 6e 0a 09 09 20 20 20 3b (begin... ;
91d0: 3b 20 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74 ; . (debug:print
91e0: 20 31 20 22 52 65 6d 6f 76 69 6e 67 20 72 75 6e 1 "Removing run
91f0: 20 64 69 72 20 22 20 72 75 6e 70 61 74 68 29 0a dir " runpath).
9200: 09 09 20 20 20 3b 3b 20 09 20 28 73 79 73 74 65 .. ;; . (syste
9210: 6d 20 28 63 6f 6e 63 20 22 72 6d 64 69 72 20 2d m (conc "rmdir -
9220: 70 20 22 20 72 75 6e 70 61 74 68 29 29 29 29 0a p " runpath)))).
9230: 09 09 20 20 20 29 29 29 29 0a 09 20 29 29 0a 20 .. )))).. )).
9240: 20 20 20 20 72 75 6e 73 29 29 29 0a 0a 3b 3b 3d runs)))..;;=
9250: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
9260: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
9270: 3d 3d 3d 3d 3d 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 0a 3b 3b 20 52 6f 75 74 69 6e 65 =====.;; Routine
92a0: 73 20 66 6f 72 20 6d 61 6e 69 70 75 6c 61 74 69 s for manipulati
92b0: 6e 67 20 72 75 6e 73 0a 3b 3b 3d 3d 3d 3d 3d 3d ng runs.;;======
92c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
92d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
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: 0a 0a 3b 3b 20 53 69 6e 63 65 20 6d 61 6e 79 20 ..;; Since many
9310: 63 61 6c 6c 73 20 74 6f 20 61 20 72 75 6e 20 72 calls to a run r
9320: 65 71 75 69 72 65 20 70 72 65 74 74 79 20 6d 75 equire pretty mu
9330: 63 68 20 74 68 65 20 73 61 6d 65 20 73 65 74 75 ch the same setu
9340: 70 20 0a 3b 3b 20 74 68 69 73 20 77 72 61 70 70 p .;; this wrapp
9350: 65 72 20 69 73 20 75 73 65 64 20 74 6f 20 72 65 er is used to re
9360: 64 75 63 65 20 74 68 65 20 72 65 70 6c 69 63 61 duce the replica
9370: 74 69 6f 6e 20 6f 66 20 63 6f 64 65 0a 28 64 65 tion of code.(de
9380: 66 69 6e 65 20 28 67 65 6e 65 72 61 6c 2d 72 75 fine (general-ru
9390: 6e 2d 63 61 6c 6c 20 73 77 69 74 63 68 6e 61 6d n-call switchnam
93a0: 65 20 61 63 74 69 6f 6e 2d 64 65 73 63 20 70 72 e action-desc pr
93b0: 6f 63 29 0a 20 20 28 69 66 20 28 6e 6f 74 20 28 oc). (if (not (
93c0: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 3a 72 args:get-arg ":r
93d0: 75 6e 6e 61 6d 65 22 29 29 0a 20 20 20 20 20 20 unname")).
93e0: 28 62 65 67 69 6e 0a 09 28 64 65 62 75 67 3a 70 (begin..(debug:p
93f0: 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 4d rint 0 "ERROR: M
9400: 69 73 73 69 6e 67 20 72 65 71 75 69 72 65 64 20 issing required
9410: 70 61 72 61 6d 65 74 65 72 20 66 6f 72 20 22 20 parameter for "
9420: 73 77 69 74 63 68 6e 61 6d 65 20 22 2c 20 79 6f switchname ", yo
9430: 75 20 6d 75 73 74 20 73 70 65 63 69 66 79 20 74 u must specify t
9440: 68 65 20 72 75 6e 20 6e 61 6d 65 20 77 69 74 68 he run name with
9450: 20 3a 72 75 6e 6e 61 6d 65 20 72 75 6e 6e 61 6d :runname runnam
9460: 65 22 29 0a 09 28 65 78 69 74 20 32 29 29 0a 20 e")..(exit 2)).
9470: 20 20 20 20 20 28 6c 65 74 20 28 28 64 62 20 23 (let ((db #
9480: 66 29 29 0a 09 28 69 66 20 28 6e 6f 74 20 28 73 f))..(if (not (s
9490: 65 74 75 70 2d 66 6f 72 2d 72 75 6e 29 29 0a 09 etup-for-run))..
94a0: 20 20 20 20 28 62 65 67 69 6e 20 0a 09 20 20 20 (begin ..
94b0: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 (debug:print
94c0: 30 20 22 46 61 69 6c 65 64 20 74 6f 20 73 65 74 0 "Failed to set
94d0: 75 70 2c 20 65 78 69 74 69 6e 67 22 29 0a 09 20 up, exiting")..
94e0: 20 20 20 20 20 28 65 78 69 74 20 31 29 29 29 0a (exit 1))).
94f0: 09 28 73 65 74 21 20 64 62 20 28 6f 70 65 6e 2d .(set! db (open-
9500: 64 62 29 29 0a 09 28 69 66 20 28 6e 6f 74 20 28 db))..(if (not (
9510: 63 61 72 20 2a 63 6f 6e 66 69 67 69 6e 66 6f 2a car *configinfo*
9520: 29 29 0a 09 20 20 20 20 28 62 65 67 69 6e 0a 09 )).. (begin..
9530: 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 (debug:pri
9540: 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 41 74 74 nt 0 "ERROR: Att
9550: 65 6d 70 74 65 64 20 74 6f 20 22 20 61 63 74 69 empted to " acti
9560: 6f 6e 2d 64 65 73 63 20 22 20 62 75 74 20 72 75 on-desc " but ru
9570: 6e 20 61 72 65 61 20 63 6f 6e 66 69 67 20 66 69 n area config fi
9580: 6c 65 20 6e 6f 74 20 66 6f 75 6e 64 22 29 0a 09 le not found")..
9590: 20 20 20 20 20 20 28 65 78 69 74 20 31 29 29 0a (exit 1)).
95a0: 09 20 20 20 20 3b 3b 20 45 78 74 72 61 63 74 20 . ;; Extract
95b0: 6f 75 74 20 73 74 75 66 66 20 6e 65 65 64 65 64 out stuff needed
95c0: 20 69 6e 20 6d 6f 73 74 20 6f 72 20 6d 61 6e 79 in most or many
95d0: 20 63 61 6c 6c 73 0a 09 20 20 20 20 3b 3b 20 68 calls.. ;; h
95e0: 65 72 65 20 74 68 65 6e 20 63 61 6c 6c 20 70 72 ere then call pr
95f0: 6f 63 0a 09 20 20 20 20 28 6c 65 74 2a 20 28 28 oc.. (let* ((
9600: 6b 65 79 73 20 20 20 20 20 20 20 28 64 62 2d 67 keys (db-g
9610: 65 74 2d 6b 65 79 73 20 64 62 29 29 0a 09 09 20 et-keys db))...
9620: 20 20 28 6b 65 79 6e 61 6d 65 73 20 20 20 28 6d (keynames (m
9630: 61 70 20 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64 ap key:get-field
9640: 6e 61 6d 65 20 6b 65 79 73 29 29 0a 09 09 20 20 name keys))...
9650: 20 28 6b 65 79 76 61 6c 6c 73 74 20 20 28 6b 65 (keyvallst (ke
9660: 79 73 2d 3e 76 61 6c 6c 69 73 74 20 6b 65 79 73 ys->vallist keys
9670: 20 23 74 29 29 29 0a 09 20 20 20 20 20 20 28 70 #t))).. (p
9680: 72 6f 63 20 64 62 20 6b 65 79 73 20 6b 65 79 6e roc db keys keyn
9690: 61 6d 65 73 20 6b 65 79 76 61 6c 6c 73 74 29 29 ames keyvallst))
96a0: 29 0a 09 28 73 71 6c 69 74 65 33 3a 66 69 6e 61 )..(sqlite3:fina
96b0: 6c 69 7a 65 21 20 64 62 29 0a 09 28 73 65 74 21 lize! db)..(set!
96c0: 20 2a 64 69 64 73 6f 6d 65 74 68 69 6e 67 2a 20 *didsomething*
96d0: 23 74 29 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d #t))))..;;======
96e0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
96f0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
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: 0a 3b 3b 20 52 6f 6c 6c 75 70 20 72 75 6e 73 0a .;; Rollup runs.
9730: 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ;;==============
9740: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
9750: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
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 0a 0a 3b 3b 20 55 70 64 ========..;; Upd
9780: 61 74 65 20 74 68 65 20 74 65 73 74 5f 6d 65 74 ate the test_met
9790: 61 20 74 61 62 6c 65 20 66 6f 72 20 74 68 69 73 a table for this
97a0: 20 74 65 73 74 0a 28 64 65 66 69 6e 65 20 28 72 test.(define (r
97b0: 75 6e 73 3a 75 70 64 61 74 65 2d 74 65 73 74 5f uns:update-test_
97c0: 6d 65 74 61 20 64 62 20 74 65 73 74 2d 6e 61 6d meta db test-nam
97d0: 65 20 74 65 73 74 2d 63 6f 6e 66 29 0a 20 20 28 e test-conf). (
97e0: 6c 65 74 20 28 28 63 75 72 72 72 65 63 6f 72 64 let ((currrecord
97f0: 20 28 64 62 3a 74 65 73 74 6d 65 74 61 2d 67 65 (db:testmeta-ge
9800: 74 2d 72 65 63 6f 72 64 20 64 62 20 74 65 73 74 t-record db test
9810: 2d 6e 61 6d 65 29 29 29 0a 20 20 20 20 28 69 66 -name))). (if
9820: 20 28 6e 6f 74 20 63 75 72 72 72 65 63 6f 72 64 (not currrecord
9830: 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 28 73 65 )..(begin.. (se
9840: 74 21 20 63 75 72 72 72 65 63 6f 72 64 20 28 6d t! currrecord (m
9850: 61 6b 65 2d 76 65 63 74 6f 72 20 31 30 20 23 66 ake-vector 10 #f
9860: 29 29 0a 09 20 20 28 64 62 3a 74 65 73 74 6d 65 )).. (db:testme
9870: 74 61 2d 61 64 64 2d 72 65 63 6f 72 64 20 64 62 ta-add-record db
9880: 20 74 65 73 74 2d 6e 61 6d 65 29 29 29 0a 20 20 test-name))).
9890: 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 20 20 (for-each .
98a0: 20 20 28 6c 61 6d 62 64 61 20 28 6b 65 79 29 0a (lambda (key).
98b0: 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28 28 69 (let* ((i
98c0: 64 78 20 28 63 61 64 72 20 6b 65 79 29 29 0a 09 dx (cadr key))..
98d0: 20 20 20 20 20 20 28 66 6c 64 20 28 63 61 72 20 (fld (car
98e0: 20 6b 65 79 29 29 0a 09 20 20 20 20 20 20 28 76 key)).. (v
98f0: 61 6c 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 al (config-looku
9900: 70 20 74 65 73 74 2d 63 6f 6e 66 20 22 74 65 73 p test-conf "tes
9910: 74 5f 6d 65 74 61 22 20 66 6c 64 29 29 29 0a 09 t_meta" fld)))..
9920: 20 28 69 66 20 28 61 6e 64 20 76 61 6c 20 28 6e (if (and val (n
9930: 6f 74 20 28 65 71 75 61 6c 3f 20 28 76 65 63 74 ot (equal? (vect
9940: 6f 72 2d 72 65 66 20 63 75 72 72 72 65 63 6f 72 or-ref currrecor
9950: 64 20 69 64 78 29 20 76 61 6c 29 29 29 0a 09 20 d idx) val)))..
9960: 20 20 20 20 28 62 65 67 69 6e 0a 09 20 20 20 20 (begin..
9970: 20 20 20 28 70 72 69 6e 74 20 22 55 70 64 61 74 (print "Updat
9980: 69 6e 67 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 ing " test-name
9990: 22 20 22 20 66 6c 64 20 22 20 74 6f 20 22 20 76 " " fld " to " v
99a0: 61 6c 29 0a 09 20 20 20 20 20 20 20 28 64 62 3a al).. (db:
99b0: 74 65 73 74 6d 65 74 61 2d 75 70 64 61 74 65 2d testmeta-update-
99c0: 66 69 65 6c 64 20 64 62 20 74 65 73 74 2d 6e 61 field db test-na
99d0: 6d 65 20 66 6c 64 20 76 61 6c 29 29 29 29 29 0a me fld val))))).
99e0: 20 20 20 20 20 27 28 28 22 61 75 74 68 6f 72 22 '(("author"
99f0: 20 32 29 28 22 6f 77 6e 65 72 22 20 33 29 28 22 2)("owner" 3)("
9a00: 64 65 73 63 72 69 70 74 69 6f 6e 22 20 34 29 28 description" 4)(
9a10: 22 72 65 76 69 65 77 65 64 22 20 35 29 28 22 74 "reviewed" 5)("t
9a20: 61 67 73 22 20 39 29 29 29 29 29 0a 0a 3b 3b 20 ags" 9)))))..;;
9a30: 55 70 64 61 74 65 20 74 65 73 74 5f 6d 65 74 61 Update test_meta
9a40: 20 66 6f 72 20 61 6c 6c 20 74 65 73 74 73 0a 28 for all tests.(
9a50: 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 75 70 64 define (runs:upd
9a60: 61 74 65 2d 61 6c 6c 2d 74 65 73 74 5f 6d 65 74 ate-all-test_met
9a70: 61 20 64 62 29 0a 20 20 28 6c 65 74 20 28 28 74 a db). (let ((t
9a80: 65 73 74 2d 6e 61 6d 65 73 20 28 67 65 74 2d 61 est-names (get-a
9a90: 6c 6c 2d 6c 65 67 61 6c 2d 74 65 73 74 73 29 29 ll-legal-tests))
9aa0: 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20 ). (for-each
9ab0: 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 74 . (lambda (t
9ac0: 65 73 74 2d 6e 61 6d 65 29 0a 20 20 20 20 20 20 est-name).
9ad0: 20 28 6c 65 74 2a 20 28 28 74 65 73 74 2d 70 61 (let* ((test-pa
9ae0: 74 68 20 20 20 20 28 63 6f 6e 63 20 2a 74 6f 70 th (conc *top
9af0: 70 61 74 68 2a 20 22 2f 74 65 73 74 73 2f 22 20 path* "/tests/"
9b00: 74 65 73 74 2d 6e 61 6d 65 29 29 0a 09 20 20 20 test-name))..
9b10: 20 20 20 28 74 65 73 74 2d 63 6f 6e 66 69 67 66 (test-configf
9b20: 20 28 63 6f 6e 63 20 74 65 73 74 2d 70 61 74 68 (conc test-path
9b30: 20 22 2f 74 65 73 74 63 6f 6e 66 69 67 22 29 29 "/testconfig"))
9b40: 0a 09 20 20 20 20 20 20 28 74 65 73 74 65 78 69 .. (testexi
9b50: 73 74 73 20 20 20 28 61 6e 64 20 28 66 69 6c 65 sts (and (file
9b60: 2d 65 78 69 73 74 73 3f 20 74 65 73 74 2d 63 6f -exists? test-co
9b70: 6e 66 69 67 66 29 28 66 69 6c 65 2d 72 65 61 64 nfigf)(file-read
9b80: 2d 61 63 63 65 73 73 3f 20 74 65 73 74 2d 63 6f -access? test-co
9b90: 6e 66 69 67 66 29 29 29 0a 09 20 20 20 20 20 20 nfigf)))..
9ba0: 3b 3b 20 72 65 61 64 20 63 6f 6e 66 69 67 73 20 ;; read configs
9bb0: 77 69 74 68 20 74 72 69 63 6b 73 20 74 75 72 6e with tricks turn
9bc0: 65 64 20 6f 66 66 20 28 69 2e 65 2e 20 6e 6f 20 ed off (i.e. no
9bd0: 73 79 73 74 65 6d 29 0a 09 20 20 20 20 20 20 28 system).. (
9be0: 74 65 73 74 2d 63 6f 6e 66 20 20 20 20 28 69 66 test-conf (if
9bf0: 20 74 65 73 74 65 78 69 73 74 73 20 28 72 65 61 testexists (rea
9c00: 64 2d 63 6f 6e 66 69 67 20 74 65 73 74 2d 63 6f d-config test-co
9c10: 6e 66 69 67 66 20 23 66 20 23 66 29 28 6d 61 6b nfigf #f #f)(mak
9c20: 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29 29 29 e-hash-table))))
9c30: 0a 09 20 28 72 75 6e 73 3a 75 70 64 61 74 65 2d .. (runs:update-
9c40: 74 65 73 74 5f 6d 65 74 61 20 64 62 20 74 65 73 test_meta db tes
9c50: 74 2d 6e 61 6d 65 20 74 65 73 74 2d 63 6f 6e 66 t-name test-conf
9c60: 29 29 29 0a 20 20 20 20 20 74 65 73 74 2d 6e 61 ))). test-na
9c70: 6d 65 73 29 29 29 0a 09 20 0a 3b 3b 20 54 68 69 mes))).. .;; Thi
9c80: 73 20 63 6f 75 6c 64 20 70 72 6f 62 61 62 6c 79 s could probably
9c90: 20 62 65 20 72 65 66 61 63 74 6f 72 65 64 20 69 be refactored i
9ca0: 6e 74 6f 20 6f 6e 65 20 63 6f 6d 70 6c 65 78 20 nto one complex
9cb0: 71 75 65 72 79 20 2e 2e 2e 0a 28 64 65 66 69 6e query ....(defin
9cc0: 65 20 28 72 75 6e 73 3a 72 6f 6c 6c 75 70 2d 72 e (runs:rollup-r
9cd0: 75 6e 20 64 62 20 6b 65 79 73 29 0a 20 20 28 6c un db keys). (l
9ce0: 65 74 2a 20 28 28 6e 65 77 2d 72 75 6e 2d 69 64 et* ((new-run-id
9cf0: 20 20 20 20 20 20 28 72 65 67 69 73 74 65 72 2d (register-
9d00: 72 75 6e 20 64 62 20 6b 65 79 73 29 29 0a 09 20 run db keys))..
9d10: 28 70 72 65 76 2d 74 65 73 74 73 20 20 20 20 20 (prev-tests
9d20: 20 28 74 65 73 74 3a 67 65 74 2d 6d 61 74 63 68 (test:get-match
9d30: 69 6e 67 2d 70 72 65 76 69 6f 75 73 2d 74 65 73 ing-previous-tes
9d40: 74 2d 72 75 6e 2d 72 65 63 6f 72 64 73 20 64 62 t-run-records db
9d50: 20 6e 65 77 2d 72 75 6e 2d 69 64 20 22 25 22 20 new-run-id "%"
9d60: 22 25 22 29 29 0a 09 20 28 63 75 72 72 2d 74 65 "%")).. (curr-te
9d70: 73 74 73 20 20 20 20 20 20 28 64 62 2d 67 65 74 sts (db-get
9d80: 2d 74 65 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64 -tests-for-run d
9d90: 62 20 6e 65 77 2d 72 75 6e 2d 69 64 20 22 25 22 b new-run-id "%"
9da0: 20 22 25 22 29 29 0a 09 20 28 63 75 72 72 2d 74 "%")).. (curr-t
9db0: 65 73 74 73 2d 68 61 73 68 20 28 6d 61 6b 65 2d ests-hash (make-
9dc0: 68 61 73 68 2d 74 61 62 6c 65 29 29 29 0a 20 20 hash-table))).
9dd0: 20 20 3b 3b 20 69 6e 64 65 78 20 74 68 65 20 61 ;; index the a
9de0: 6c 72 65 61 64 79 20 73 61 76 65 64 20 74 65 73 lready saved tes
9df0: 74 73 20 62 79 20 74 65 73 74 6e 61 6d 65 20 61 ts by testname a
9e00: 6e 64 20 69 74 65 6d 70 61 74 68 20 69 6e 20 63 nd itempath in c
9e10: 75 72 72 2d 74 65 73 74 73 2d 68 61 73 68 0a 20 urr-tests-hash.
9e20: 20 20 20 28 66 6f 72 2d 65 61 63 68 0a 20 20 20 (for-each.
9e30: 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74 64 (lambda (testd
9e40: 61 74 29 0a 20 20 20 20 20 20 20 28 6c 65 74 2a at). (let*
9e50: 20 28 28 74 65 73 74 6e 61 6d 65 20 20 28 64 62 ((testname (db
9e60: 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 :test-get-testna
9e70: 6d 65 20 74 65 73 74 64 61 74 29 29 0a 09 20 20 me testdat))..
9e80: 20 20 20 20 28 69 74 65 6d 2d 70 61 74 68 20 28 (item-path (
9e90: 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d db:test-get-item
9ea0: 2d 70 61 74 68 20 74 65 73 74 64 61 74 29 29 0a -path testdat)).
9eb0: 09 20 20 20 20 20 20 28 66 75 6c 6c 2d 6e 61 6d . (full-nam
9ec0: 65 20 28 63 6f 6e 63 20 74 65 73 74 6e 61 6d 65 e (conc testname
9ed0: 20 22 2f 22 20 69 74 65 6d 2d 70 61 74 68 29 29 "/" item-path))
9ee0: 29 0a 09 20 28 68 61 73 68 2d 74 61 62 6c 65 2d ).. (hash-table-
9ef0: 73 65 74 21 20 63 75 72 72 2d 74 65 73 74 73 2d set! curr-tests-
9f00: 68 61 73 68 20 66 75 6c 6c 2d 6e 61 6d 65 20 74 hash full-name t
9f10: 65 73 74 64 61 74 29 29 29 0a 20 20 20 20 20 63 estdat))). c
9f20: 75 72 72 2d 74 65 73 74 73 29 0a 20 20 20 20 3b urr-tests). ;
9f30: 3b 20 4e 4f 50 45 3a 20 4e 6f 6e 2d 6f 70 74 69 ; NOPE: Non-opti
9f40: 6d 61 6c 20 61 70 70 72 6f 61 63 68 2e 20 54 72 mal approach. Tr
9f50: 79 20 74 68 69 73 20 69 6e 73 74 65 61 64 2e 0a y this instead..
9f60: 20 20 20 20 3b 3b 20 20 20 31 2e 20 74 65 73 74 ;; 1. test
9f70: 73 20 61 72 65 20 72 65 63 65 69 76 65 64 20 69 s are received i
9f80: 6e 20 61 20 6c 69 73 74 2c 20 6d 6f 73 74 20 72 n a list, most r
9f90: 65 63 65 6e 74 20 66 69 72 73 74 0a 20 20 20 20 ecent first.
9fa0: 3b 3b 20 20 20 32 2e 20 72 65 70 6c 61 63 65 20 ;; 2. replace
9fb0: 74 68 65 20 72 6f 6c 6c 75 70 20 74 65 73 74 20 the rollup test
9fc0: 77 69 74 68 20 74 68 65 20 6e 65 77 20 2a 61 6c with the new *al
9fd0: 77 61 79 73 2a 0a 20 20 20 20 28 66 6f 72 2d 65 ways*. (for-e
9fe0: 61 63 68 20 0a 20 20 20 20 20 28 6c 61 6d 62 64 ach . (lambd
9ff0: 61 20 28 74 65 73 74 64 61 74 29 0a 20 20 20 20 a (testdat).
a000: 20 20 20 28 6c 65 74 2a 20 28 28 74 65 73 74 6e (let* ((testn
a010: 61 6d 65 20 20 28 64 62 3a 74 65 73 74 2d 67 65 ame (db:test-ge
a020: 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 64 t-testname testd
a030: 61 74 29 29 0a 09 20 20 20 20 20 20 28 69 74 65 at)).. (ite
a040: 6d 2d 70 61 74 68 20 28 64 62 3a 74 65 73 74 2d m-path (db:test-
a050: 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 get-item-path te
a060: 73 74 64 61 74 29 29 0a 09 20 20 20 20 20 20 28 stdat)).. (
a070: 66 75 6c 6c 2d 6e 61 6d 65 20 28 63 6f 6e 63 20 full-name (conc
a080: 74 65 73 74 6e 61 6d 65 20 22 2f 22 20 69 74 65 testname "/" ite
a090: 6d 2d 70 61 74 68 29 29 0a 09 20 20 20 20 20 20 m-path))..
a0a0: 28 70 72 65 76 2d 74 65 73 74 2d 64 61 74 20 28 (prev-test-dat (
a0b0: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 hash-table-ref/d
a0c0: 65 66 61 75 6c 74 20 63 75 72 72 2d 74 65 73 74 efault curr-test
a0d0: 73 2d 68 61 73 68 20 66 75 6c 6c 2d 6e 61 6d 65 s-hash full-name
a0e0: 20 23 66 29 29 0a 09 20 20 20 20 20 20 28 74 65 #f)).. (te
a0f0: 73 74 2d 73 74 65 70 73 20 20 20 20 20 20 28 64 st-steps (d
a100: 62 3a 67 65 74 2d 73 74 65 70 73 2d 66 6f 72 2d b:get-steps-for-
a110: 74 65 73 74 20 64 62 20 28 64 62 3a 74 65 73 74 test db (db:test
a120: 2d 67 65 74 2d 69 64 20 74 65 73 74 64 61 74 29 -get-id testdat)
a130: 29 29 0a 09 20 20 20 20 20 20 28 6e 65 77 2d 74 )).. (new-t
a140: 65 73 74 2d 72 65 63 6f 72 64 20 23 66 29 29 0a est-record #f)).
a150: 09 20 3b 3b 20 72 65 70 6c 61 63 65 20 74 68 65 . ;; replace the
a160: 73 65 20 77 69 74 68 20 69 6e 73 65 72 74 20 2e se with insert .
a170: 2e 2e 20 73 65 6c 65 63 74 0a 09 20 28 61 70 70 .. select.. (app
a180: 6c 79 20 73 71 6c 69 74 65 33 3a 65 78 65 63 75 ly sqlite3:execu
a190: 74 65 20 0a 09 09 64 62 20 0a 09 09 28 63 6f 6e te ...db ...(con
a1a0: 63 20 22 49 4e 53 45 52 54 20 4f 52 20 52 45 50 c "INSERT OR REP
a1b0: 4c 41 43 45 20 49 4e 54 4f 20 74 65 73 74 73 20 LACE INTO tests
a1c0: 28 72 75 6e 5f 69 64 2c 74 65 73 74 6e 61 6d 65 (run_id,testname
a1d0: 2c 73 74 61 74 65 2c 73 74 61 74 75 73 2c 65 76 ,state,status,ev
a1e0: 65 6e 74 5f 74 69 6d 65 2c 68 6f 73 74 2c 63 70 ent_time,host,cp
a1f0: 75 6c 6f 61 64 2c 64 69 73 6b 66 72 65 65 2c 75 uload,diskfree,u
a200: 6e 61 6d 65 2c 72 75 6e 64 69 72 2c 69 74 65 6d name,rundir,item
a210: 5f 70 61 74 68 2c 72 75 6e 5f 64 75 72 61 74 69 _path,run_durati
a220: 6f 6e 2c 66 69 6e 61 6c 5f 6c 6f 67 66 2c 63 6f on,final_logf,co
a230: 6d 6d 65 6e 74 2c 66 69 72 73 74 5f 65 72 72 2c mment,first_err,
a240: 66 69 72 73 74 5f 77 61 72 6e 29 20 22 0a 09 09 first_warn) "...
a250: 20 20 20 20 20 20 22 56 41 4c 55 45 53 20 28 3f "VALUES (?
a260: 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f ,?,?,?,?,?,?,?,?
a270: 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 29 3b ,?,?,?,?,?,?,?);
a280: 22 29 0a 09 09 6e 65 77 2d 72 75 6e 2d 69 64 20 ")...new-run-id
a290: 28 63 64 64 72 20 28 76 65 63 74 6f 72 2d 3e 6c (cddr (vector->l
a2a0: 69 73 74 20 74 65 73 74 64 61 74 29 29 29 0a 09 ist testdat)))..
a2b0: 20 28 73 65 74 21 20 6e 65 77 2d 74 65 73 74 64 (set! new-testd
a2c0: 61 74 20 28 63 61 72 20 28 64 62 2d 67 65 74 2d at (car (db-get-
a2d0: 74 65 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 tests-for-run db
a2e0: 20 6e 65 77 2d 72 75 6e 2d 69 64 20 74 65 73 74 new-run-id test
a2f0: 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29 name item-path))
a300: 29 0a 09 20 28 68 61 73 68 2d 74 61 62 6c 65 2d ).. (hash-table-
a310: 73 65 74 21 20 63 75 72 72 2d 74 65 73 74 73 2d set! curr-tests-
a320: 68 61 73 68 20 66 75 6c 6c 2d 6e 61 6d 65 20 6e hash full-name n
a330: 65 77 2d 74 65 73 74 64 61 74 29 20 3b 3b 20 74 ew-testdat) ;; t
a340: 68 69 73 20 63 6f 75 6c 64 20 62 65 20 63 6f 6e his could be con
a350: 66 75 73 69 6e 67 2c 20 77 68 69 63 68 20 72 65 fusing, which re
a360: 63 6f 72 64 20 73 68 6f 75 6c 64 20 67 6f 20 69 cord should go i
a370: 6e 74 6f 20 74 68 65 20 6c 6f 6f 6b 75 70 20 74 nto the lookup t
a380: 61 62 6c 65 3f 0a 09 20 3b 3b 20 4e 6f 77 20 64 able?.. ;; Now d
a390: 75 70 6c 69 63 61 74 65 20 74 68 65 20 74 65 73 uplicate the tes
a3a0: 74 20 73 74 65 70 73 0a 09 20 28 64 65 62 75 67 t steps.. (debug
a3b0: 3a 70 72 69 6e 74 20 34 20 22 43 6f 70 79 69 6e :print 4 "Copyin
a3c0: 67 20 72 65 63 6f 72 64 73 20 69 6e 20 74 65 73 g records in tes
a3d0: 74 5f 73 74 65 70 73 20 66 72 6f 6d 20 74 65 73 t_steps from tes
a3e0: 74 5f 69 64 3d 22 20 28 64 62 3a 74 65 73 74 2d t_id=" (db:test-
a3f0: 67 65 74 2d 69 64 20 74 65 73 74 64 61 74 29 20 get-id testdat)
a400: 22 20 74 6f 20 22 20 28 64 62 3a 74 65 73 74 2d " to " (db:test-
a410: 67 65 74 2d 69 64 20 6e 65 77 2d 74 65 73 74 64 get-id new-testd
a420: 61 74 29 29 0a 09 20 28 73 71 6c 69 74 65 33 3a at)).. (sqlite3:
a430: 65 78 65 63 75 74 65 20 0a 09 20 20 64 62 20 0a execute .. db .
a440: 09 20 20 28 63 6f 6e 63 20 22 49 4e 53 45 52 54 . (conc "INSERT
a450: 20 4f 52 20 52 45 50 4c 41 43 45 20 49 4e 54 4f OR REPLACE INTO
a460: 20 74 65 73 74 5f 73 74 65 70 73 20 28 74 65 73 test_steps (tes
a470: 74 5f 69 64 2c 73 74 65 70 6e 61 6d 65 2c 73 74 t_id,stepname,st
a480: 61 74 65 2c 73 74 61 74 75 73 2c 65 76 65 6e 74 ate,status,event
a490: 5f 74 69 6d 65 2c 63 6f 6d 6d 65 6e 74 29 20 22 _time,comment) "
a4a0: 0a 09 09 22 53 45 4c 45 43 54 20 22 20 28 64 62 ..."SELECT " (db
a4b0: 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 6e 65 77 :test-get-id new
a4c0: 2d 74 65 73 74 64 61 74 29 20 22 2c 73 74 65 70 -testdat) ",step
a4d0: 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 61 74 75 name,state,statu
a4e0: 73 2c 65 76 65 6e 74 5f 74 69 6d 65 2c 63 6f 6d s,event_time,com
a4f0: 6d 65 6e 74 20 46 52 4f 4d 20 74 65 73 74 5f 73 ment FROM test_s
a500: 74 65 70 73 20 57 48 45 52 45 20 74 65 73 74 5f teps WHERE test_
a510: 69 64 3d 3f 3b 22 29 0a 09 20 20 28 64 62 3a 74 id=?;").. (db:t
a520: 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74 64 est-get-id testd
a530: 61 74 29 29 0a 09 20 3b 3b 20 4e 6f 77 20 64 75 at)).. ;; Now du
a540: 70 6c 69 63 61 74 65 20 74 68 65 20 74 65 73 74 plicate the test
a550: 20 64 61 74 61 0a 09 20 28 64 65 62 75 67 3a 70 data.. (debug:p
a560: 72 69 6e 74 20 34 20 22 43 6f 70 79 69 6e 67 20 rint 4 "Copying
a570: 72 65 63 6f 72 64 73 20 69 6e 20 74 65 73 74 5f records in test_
a580: 64 61 74 61 20 66 72 6f 6d 20 74 65 73 74 5f 69 data from test_i
a590: 64 3d 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 d=" (db:test-get
a5a0: 2d 69 64 20 74 65 73 74 64 61 74 29 20 22 20 74 -id testdat) " t
a5b0: 6f 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 o " (db:test-get
a5c0: 2d 69 64 20 6e 65 77 2d 74 65 73 74 64 61 74 29 -id new-testdat)
a5d0: 29 0a 09 20 28 73 71 6c 69 74 65 33 3a 65 78 65 ).. (sqlite3:exe
a5e0: 63 75 74 65 20 0a 09 20 20 64 62 20 0a 09 20 20 cute .. db ..
a5f0: 28 63 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f 52 (conc "INSERT OR
a600: 20 52 45 50 4c 41 43 45 20 49 4e 54 4f 20 74 65 REPLACE INTO te
a610: 73 74 5f 64 61 74 61 20 28 74 65 73 74 5f 69 64 st_data (test_id
a620: 2c 63 61 74 65 67 6f 72 79 2c 76 61 72 69 61 62 ,category,variab
a630: 6c 65 2c 76 61 6c 75 65 2c 65 78 70 65 63 74 65 le,value,expecte
a640: 64 2c 74 6f 6c 2c 75 6e 69 74 73 2c 63 6f 6d 6d d,tol,units,comm
a650: 65 6e 74 29 20 22 0a 09 09 22 53 45 4c 45 43 54 ent) "..."SELECT
a660: 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d " (db:test-get-
a670: 69 64 20 6e 65 77 2d 74 65 73 74 64 61 74 29 20 id new-testdat)
a680: 22 2c 63 61 74 65 67 6f 72 79 2c 76 61 72 69 61 ",category,varia
a690: 62 6c 65 2c 76 61 6c 75 65 2c 65 78 70 65 63 74 ble,value,expect
a6a0: 65 64 2c 74 6f 6c 2c 75 6e 69 74 73 2c 63 6f 6d ed,tol,units,com
a6b0: 6d 65 6e 74 20 46 52 4f 4d 20 74 65 73 74 5f 64 ment FROM test_d
a6c0: 61 74 61 20 57 48 45 52 45 20 74 65 73 74 5f 69 ata WHERE test_i
a6d0: 64 3d 3f 3b 22 29 0a 09 20 20 28 64 62 3a 74 65 d=?;").. (db:te
a6e0: 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74 64 61 st-get-id testda
a6f0: 74 29 29 0a 09 20 29 29 0a 20 20 20 20 20 70 72 t)).. )). pr
a700: 65 76 2d 74 65 73 74 73 29 29 29 0a 09 20 0a 20 ev-tests))).. .
a710: 20 20 20 20 0a .