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 29 0a 09 20 20 20 20 20 th ""))))..
6950: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 33 20 (debug:print 3
6960: 22 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d "max-concurrent-
6970: 6a 6f 62 73 3a 20 22 20 6d 61 78 2d 63 6f 6e 63 jobs: " max-conc
6980: 75 72 72 65 6e 74 2d 6a 6f 62 73 20 22 2c 20 6e urrent-jobs ", n
6990: 75 6d 2d 72 75 6e 6e 69 6e 67 3a 20 22 20 6e 75 um-running: " nu
69a0: 6d 2d 72 75 6e 6e 69 6e 67 29 0a 09 20 20 20 20 m-running)..
69b0: 20 20 28 69 66 20 28 72 75 6e 73 3a 63 61 6e 2d (if (runs:can-
69c0: 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64 run-more-tests d
69d0: 62 29 0a 09 09 20 20 28 62 65 67 69 6e 0a 09 09 b)... (begin...
69e0: 20 20 20 20 28 6c 65 74 20 6c 6f 6f 70 32 20 28 (let loop2 (
69f0: 28 74 73 20 28 64 62 3a 67 65 74 2d 74 65 73 74 (ts (db:get-test
6a00: 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 -info db run-id
6a10: 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 test-name item-p
6a20: 61 74 68 29 29 20 3b 3b 20 23 66 29 0a 09 09 09 ath)) ;; #f)....
6a30: 09 28 63 74 20 30 29 29 0a 09 09 20 20 20 20 20 .(ct 0))...
6a40: 20 28 69 66 20 28 61 6e 64 20 28 6e 6f 74 20 74 (if (and (not t
6a50: 73 29 0a 09 09 09 20 20 20 20 20 20 20 28 3c 20 s).... (<
6a60: 63 74 20 31 30 29 29 0a 09 09 09 20 20 28 62 65 ct 10)).... (be
6a70: 67 69 6e 0a 09 09 09 20 20 20 20 28 72 65 67 69 gin.... (regi
6a80: 73 74 65 72 2d 74 65 73 74 20 64 62 20 72 75 6e ster-test db run
6a90: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 -id test-name it
6aa0: 65 6d 2d 70 61 74 68 29 0a 09 09 09 20 20 20 20 em-path)....
6ab0: 28 64 62 3a 74 65 73 74 2d 73 65 74 2d 63 6f 6d (db:test-set-com
6ac0: 6d 65 6e 74 20 64 62 20 72 75 6e 2d 69 64 20 74 ment db run-id t
6ad0: 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 est-name item-pa
6ae0: 74 68 20 22 22 29 0a 09 09 09 20 20 20 20 28 6c th "").... (l
6af0: 6f 6f 70 32 20 28 64 62 3a 67 65 74 2d 74 65 73 oop2 (db:get-tes
6b00: 74 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64 t-info db run-id
6b10: 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d test-name item-
6b20: 70 61 74 68 29 0a 09 09 09 09 20 20 20 28 2b 20 path)..... (+
6b30: 63 74 20 31 29 29 29 0a 09 09 09 20 20 28 69 66 ct 1))).... (if
6b40: 20 74 73 0a 09 09 09 20 20 20 20 20 20 28 73 65 ts.... (se
6b50: 74 21 20 74 65 73 74 64 61 74 20 74 73 29 0a 09 t! testdat ts)..
6b60: 09 09 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09 .. (begin..
6b70: 09 09 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20 ...(debug:print
6b80: 30 20 22 57 41 52 4e 49 4e 47 3a 20 43 6f 75 6c 0 "WARNING: Coul
6b90: 64 6e 27 74 20 72 65 67 69 73 74 65 72 20 74 65 dn't register te
6ba0: 73 74 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 st " test-name "
6bb0: 20 77 69 74 68 20 69 74 65 6d 20 70 61 74 68 20 with item path
6bc0: 22 20 69 74 65 6d 2d 70 61 74 68 20 22 2c 20 73 " item-path ", s
6bd0: 6b 69 70 70 69 6e 67 22 29 0a 09 09 09 09 28 69 kipping").....(i
6be0: 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 61 f (not (null? ta
6bf0: 6c 29 29 0a 09 09 09 09 20 20 20 20 28 6c 6f 6f l))..... (loo
6c00: 70 20 28 63 61 72 20 74 61 6c 29 28 63 64 72 20 p (car tal)(cdr
6c10: 74 61 6c 29 29 29 29 29 29 29 0a 09 09 20 20 20 tal)))))))...
6c20: 20 28 63 68 61 6e 67 65 2d 64 69 72 65 63 74 6f (change-directo
6c30: 72 79 20 74 65 73 74 2d 70 61 74 68 29 0a 09 09 ry test-path)...
6c40: 20 20 20 20 3b 3b 20 74 68 69 73 20 62 6c 6f 63 ;; this bloc
6c50: 6b 20 69 73 20 68 65 72 65 20 6f 6e 6c 79 20 74 k is here only t
6c60: 6f 20 69 6e 66 6f 72 6d 20 74 68 65 20 75 73 65 o inform the use
6c70: 72 20 65 61 72 6c 79 20 6f 6e 0a 09 09 20 20 20 r early on...
6c80: 20 28 69 66 20 28 66 69 6c 65 2d 65 78 69 73 74 (if (file-exist
6c90: 73 3f 20 72 75 6e 63 6f 6e 66 69 67 66 29 0a 09 s? runconfigf)..
6ca0: 09 09 28 73 65 74 75 70 2d 65 6e 76 2d 64 65 66 ..(setup-env-def
6cb0: 61 75 6c 74 73 20 64 62 20 72 75 6e 63 6f 6e 66 aults db runconf
6cc0: 69 67 66 20 72 75 6e 2d 69 64 20 2a 61 6c 72 65 igf run-id *alre
6cd0: 61 64 79 2d 73 65 65 6e 2d 72 75 6e 63 6f 6e 66 ady-seen-runconf
6ce0: 69 67 2d 69 6e 66 6f 2a 29 0a 09 09 09 28 64 65 ig-info*)....(de
6cf0: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52 bug:print 0 "WAR
6d00: 4e 49 4e 47 3a 20 59 6f 75 20 64 6f 20 6e 6f 74 NING: You do not
6d10: 20 68 61 76 65 20 61 20 72 75 6e 20 63 6f 6e 66 have a run conf
6d20: 69 67 20 66 69 6c 65 3a 20 22 20 72 75 6e 63 6f ig file: " runco
6d30: 6e 66 69 67 66 29 29 0a 09 09 20 20 20 20 28 64 nfigf))... (d
6d40: 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 72 75 ebug:print 4 "ru
6d50: 6e 2d 69 64 3a 20 22 20 72 75 6e 2d 69 64 20 22 n-id: " run-id "
6d60: 20 74 65 73 74 2d 6e 61 6d 65 3a 20 22 20 74 65 test-name: " te
6d70: 73 74 2d 6e 61 6d 65 20 22 20 69 74 65 6d 2d 70 st-name " item-p
6d80: 61 74 68 3a 20 22 20 69 74 65 6d 2d 70 61 74 68 ath: " item-path
6d90: 20 22 20 74 65 73 74 64 61 74 3a 20 22 20 28 74 " testdat: " (t
6da0: 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 est:get-status t
6db0: 65 73 74 64 61 74 29 20 22 20 74 65 73 74 2d 73 estdat) " test-s
6dc0: 74 61 74 65 3a 20 22 20 28 74 65 73 74 3a 67 65 tate: " (test:ge
6dd0: 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 74 29 t-state testdat)
6de0: 29 0a 09 09 20 20 20 20 28 63 61 73 65 20 28 69 )... (case (i
6df0: 66 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 f (args:get-arg
6e00: 22 2d 66 6f 72 63 65 22 29 0a 09 09 09 20 20 20 "-force")....
6e10: 20 20 20 27 4e 4f 54 5f 53 54 41 52 54 45 44 0a 'NOT_STARTED.
6e20: 09 09 09 20 20 20 20 20 20 28 69 66 20 74 65 73 ... (if tes
6e30: 74 64 61 74 0a 09 09 09 09 20 20 28 73 74 72 69 tdat..... (stri
6e40: 6e 67 2d 3e 73 79 6d 62 6f 6c 20 28 74 65 73 74 ng->symbol (test
6e50: 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 :get-state testd
6e60: 61 74 29 29 0a 09 09 09 09 20 20 27 66 61 69 6c at))..... 'fail
6e70: 65 64 2d 74 6f 2d 69 6e 73 65 72 74 29 29 0a 09 ed-to-insert))..
6e80: 09 20 20 20 20 20 20 28 28 66 61 69 6c 65 64 2d . ((failed-
6e90: 74 6f 2d 69 6e 73 65 72 74 29 0a 09 09 20 20 20 to-insert)...
6ea0: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 (debug:print
6eb0: 20 30 20 22 45 52 52 4f 52 3a 20 46 61 69 6c 65 0 "ERROR: Faile
6ec0: 64 20 74 6f 20 69 6e 73 65 72 74 20 74 68 65 20 d to insert the
6ed0: 72 65 63 6f 72 64 20 69 6e 74 6f 20 74 68 65 20 record into the
6ee0: 64 62 22 29 29 0a 09 09 20 20 20 20 20 20 28 28 db"))... ((
6ef0: 4e 4f 54 5f 53 54 41 52 54 45 44 20 43 4f 4d 50 NOT_STARTED COMP
6f00: 4c 45 54 45 44 29 0a 09 09 20 20 20 20 20 20 20 LETED)...
6f10: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 36 20 22 (debug:print 6 "
6f20: 47 6f 74 20 68 65 72 65 2c 20 22 20 28 74 65 73 Got here, " (tes
6f30: 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 t:get-state test
6f40: 64 61 74 29 29 0a 09 09 20 20 20 20 20 20 20 28 dat))... (
6f50: 6c 65 74 20 28 28 72 75 6e 66 6c 61 67 20 23 66 let ((runflag #f
6f60: 29 29 0a 09 09 09 20 28 63 6f 6e 64 0a 09 09 09 )).... (cond....
6f70: 20 20 3b 3b 20 69 2e 65 2e 20 74 68 69 73 20 69 ;; i.e. this i
6f80: 73 20 74 68 65 20 70 61 72 65 6e 74 20 74 65 73 s the parent tes
6f90: 74 20 74 6f 20 61 20 73 75 69 74 65 20 6f 66 20 t to a suite of
6fa0: 69 74 65 6d 73 2c 20 6e 65 76 65 72 20 22 72 75 items, never "ru
6fb0: 6e 22 20 69 74 0a 09 09 09 20 20 28 70 61 72 65 n" it.... (pare
6fc0: 6e 74 2d 74 65 73 74 0a 09 09 09 20 20 20 28 73 nt-test.... (s
6fd0: 65 74 21 20 72 75 6e 66 6c 61 67 20 23 66 29 29 et! runflag #f))
6fe0: 0a 09 09 09 20 20 3b 3b 20 2d 66 6f 72 63 65 2c .... ;; -force,
6ff0: 20 72 75 6e 20 6e 6f 20 6d 61 74 74 65 72 20 77 run no matter w
7000: 68 61 74 0a 09 09 09 20 20 28 28 61 72 67 73 3a hat.... ((args:
7010: 67 65 74 2d 61 72 67 20 22 2d 66 6f 72 63 65 22 get-arg "-force"
7020: 29 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 )(set! runflag #
7030: 74 29 29 0a 09 09 09 20 20 3b 3b 20 4e 4f 54 5f t)).... ;; NOT_
7040: 53 54 41 52 54 45 44 2c 20 72 75 6e 20 6e 6f 20 STARTED, run no
7050: 6d 61 74 74 65 72 20 77 68 61 74 0a 09 09 09 20 matter what....
7060: 20 28 28 65 71 75 61 6c 3f 20 28 74 65 73 74 3a ((equal? (test:
7070: 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 get-state testda
7080: 74 29 20 22 4e 4f 54 5f 53 54 41 52 54 45 44 22 t) "NOT_STARTED"
7090: 29 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 )(set! runflag #
70a0: 74 29 29 0a 09 09 09 20 20 3b 3b 20 6e 6f 74 20 t)).... ;; not
70b0: 2d 72 65 72 75 6e 20 61 6e 64 20 50 41 53 53 2c -rerun and PASS,
70c0: 20 57 41 52 4e 20 6f 72 20 43 48 45 43 4b 2c 20 WARN or CHECK,
70d0: 64 6f 20 6e 6f 20 72 75 6e 0a 09 09 09 20 20 28 do no run.... (
70e0: 28 61 6e 64 20 28 6f 72 20 28 6e 6f 74 20 28 61 (and (or (not (a
70f0: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65 rgs:get-arg "-re
7100: 72 75 6e 22 29 29 0a 09 09 09 09 20 20 20 20 28 run"))..... (
7110: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 6b args:get-arg "-k
7120: 65 65 70 67 6f 69 6e 67 22 29 29 0a 09 09 09 09 eepgoing")).....
7130: 28 6d 65 6d 62 65 72 20 28 74 65 73 74 3a 67 65 (member (test:ge
7140: 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61 74 t-status testdat
7150: 29 20 27 28 22 50 41 53 53 22 20 22 57 41 52 4e ) '("PASS" "WARN
7160: 22 20 22 43 48 45 43 4b 22 29 29 29 0a 09 09 09 " "CHECK")))....
7170: 20 20 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67 (set! runflag
7180: 20 23 66 29 29 0a 09 09 09 20 20 3b 3b 20 2d 72 #f)).... ;; -r
7190: 65 72 75 6e 20 61 6e 64 20 73 74 61 74 75 73 20 erun and status
71a0: 69 73 20 6f 6e 65 20 6f 66 20 74 68 65 20 73 70 is one of the sp
71b0: 65 63 69 66 65 64 2c 20 72 75 6e 20 69 74 0a 09 ecifed, run it..
71c0: 09 09 20 20 28 28 61 6e 64 20 28 61 72 67 73 3a .. ((and (args:
71d0: 67 65 74 2d 61 72 67 20 22 2d 72 65 72 75 6e 22 get-arg "-rerun"
71e0: 29 0a 09 09 09 09 28 6c 65 74 20 28 28 72 65 72 ).....(let ((rer
71f0: 75 6e 6c 73 74 20 28 73 74 72 69 6e 67 2d 73 70 unlst (string-sp
7200: 6c 69 74 20 28 61 72 67 73 3a 67 65 74 2d 61 72 lit (args:get-ar
7210: 67 20 22 2d 72 65 72 75 6e 22 29 20 22 2c 22 29 g "-rerun") ",")
7220: 29 29 20 3b 3b 20 46 41 49 4c 2c 0a 09 09 09 09 )) ;; FAIL,.....
7230: 20 20 28 6d 65 6d 62 65 72 20 28 74 65 73 74 3a (member (test:
7240: 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 get-status testd
7250: 61 74 29 20 72 65 72 75 6e 6c 73 74 29 29 29 0a at) rerunlst))).
7260: 09 09 09 20 20 20 28 73 65 74 21 20 72 75 6e 66 ... (set! runf
7270: 6c 61 67 20 23 74 29 29 0a 09 09 09 20 20 3b 3b lag #t)).... ;;
7280: 20 2d 6b 65 65 70 67 6f 69 6e 67 2c 20 64 6f 20 -keepgoing, do
7290: 6e 6f 74 20 72 65 72 75 6e 20 46 41 49 4c 0a 09 not rerun FAIL..
72a0: 09 09 20 20 28 28 61 6e 64 20 28 61 72 67 73 3a .. ((and (args:
72b0: 67 65 74 2d 61 72 67 20 22 2d 6b 65 65 70 67 6f get-arg "-keepgo
72c0: 69 6e 67 22 29 0a 09 09 09 09 28 6d 65 6d 62 65 ing").....(membe
72d0: 72 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 r (test:get-stat
72e0: 75 73 20 74 65 73 74 64 61 74 29 20 27 28 22 46 us testdat) '("F
72f0: 41 49 4c 22 29 29 29 0a 09 09 09 20 20 20 28 73 AIL"))).... (s
7300: 65 74 21 20 72 75 6e 66 6c 61 67 20 23 66 29 29 et! runflag #f))
7310: 0a 09 09 09 20 20 28 28 61 6e 64 20 28 6e 6f 74 .... ((and (not
7320: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 (args:get-arg "
7330: 2d 72 65 72 75 6e 22 29 29 0a 09 09 09 09 28 6d -rerun")).....(m
7340: 65 6d 62 65 72 20 28 74 65 73 74 3a 67 65 74 2d ember (test:get-
7350: 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29 20 status testdat)
7360: 27 28 22 46 41 49 4c 22 20 22 6e 2f 61 22 29 29 '("FAIL" "n/a"))
7370: 29 0a 09 09 09 20 20 20 28 73 65 74 21 20 72 75 ).... (set! ru
7380: 6e 66 6c 61 67 20 23 74 29 29 0a 09 09 09 20 20 nflag #t))....
7390: 28 65 6c 73 65 20 28 73 65 74 21 20 72 75 6e 66 (else (set! runf
73a0: 6c 61 67 20 23 66 29 29 29 0a 09 09 09 20 28 64 lag #f))).... (d
73b0: 65 62 75 67 3a 70 72 69 6e 74 20 36 20 22 52 55 ebug:print 6 "RU
73c0: 4e 4e 49 4e 47 20 3d 3e 20 72 75 6e 66 6c 61 67 NNING => runflag
73d0: 3a 20 22 20 72 75 6e 66 6c 61 67 20 22 20 53 54 : " runflag " ST
73e0: 41 54 45 3a 20 22 20 28 74 65 73 74 3a 67 65 74 ATE: " (test:get
73f0: 2d 73 74 61 74 65 20 74 65 73 74 64 61 74 29 20 -state testdat)
7400: 22 20 53 54 41 54 55 53 3a 20 22 20 28 74 65 73 " STATUS: " (tes
7410: 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 t:get-status tes
7420: 74 64 61 74 29 29 0a 09 09 09 20 28 69 66 20 28 tdat)).... (if (
7430: 6e 6f 74 20 72 75 6e 66 6c 61 67 29 0a 09 09 09 not runflag)....
7440: 20 20 20 20 20 28 69 66 20 28 6e 6f 74 20 70 61 (if (not pa
7450: 72 65 6e 74 2d 74 65 73 74 29 0a 09 09 09 09 20 rent-test).....
7460: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 (debug:print 1 "
7470: 4e 4f 54 45 3a 20 4e 6f 74 20 73 74 61 72 74 69 NOTE: Not starti
7480: 6e 67 20 74 65 73 74 20 22 20 6e 65 77 2d 74 65 ng test " new-te
7490: 73 74 2d 6e 61 6d 65 20 22 20 61 73 20 69 74 20 st-name " as it
74a0: 69 73 20 73 74 61 74 65 20 5c 22 43 4f 4d 50 4c is state \"COMPL
74b0: 45 54 45 44 5c 22 20 61 6e 64 20 73 74 61 74 75 ETED\" and statu
74c0: 73 20 5c 22 22 20 28 74 65 73 74 3a 67 65 74 2d s \"" (test:get-
74d0: 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29 20 status testdat)
74e0: 22 5c 22 2c 20 75 73 65 20 2d 66 6f 72 63 65 20 "\", use -force
74f0: 74 6f 20 6f 76 65 72 72 69 64 65 22 29 29 0a 09 to override"))..
7500: 09 09 20 20 20 20 20 28 6c 65 74 2a 20 28 28 67 .. (let* ((g
7510: 65 74 2d 70 72 65 72 65 71 73 2d 63 6d 64 20 28 et-prereqs-cmd (
7520: 6c 61 6d 62 64 61 20 28 29 0a 09 09 09 09 09 09 lambda ().......
7530: 20 20 20 20 20 20 20 28 64 62 2d 67 65 74 2d 70 (db-get-p
7540: 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 20 64 rereqs-not-met d
7550: 62 20 72 75 6e 2d 69 64 20 77 61 69 74 6f 6e 29 b run-id waiton)
7560: 29 29 20 3b 3b 20 63 68 65 63 6b 20 62 65 66 6f )) ;; check befo
7570: 72 65 20 72 75 6e 6e 69 6e 67 20 2e 2e 2e 2e 0a re running .....
7580: 09 09 09 09 20 20 20 20 28 6c 61 75 6e 63 68 2d .... (launch-
7590: 63 6d 64 20 20 20 20 20 20 28 6c 61 6d 62 64 61 cmd (lambda
75a0: 20 28 29 0a 09 09 09 09 09 09 20 20 20 20 20 20 ().......
75b0: 20 28 6c 61 75 6e 63 68 2d 74 65 73 74 20 64 62 (launch-test db
75c0: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 63 6f 6e run-id test-con
75d0: 66 20 6b 65 79 76 61 6c 6c 73 74 20 74 65 73 74 f keyvallst test
75e0: 2d 6e 61 6d 65 20 74 65 73 74 2d 70 61 74 68 20 -name test-path
75f0: 69 74 65 6d 64 61 74 29 29 29 0a 09 09 09 09 20 itemdat))).....
7600: 20 20 20 28 74 65 73 74 72 75 6e 64 61 74 20 20 (testrundat
7610: 20 20 20 20 28 6c 69 73 74 20 67 65 74 2d 70 72 (list get-pr
7620: 65 72 65 71 73 2d 63 6d 64 20 6c 61 75 6e 63 68 ereqs-cmd launch
7630: 2d 63 6d 64 29 29 29 0a 09 09 09 20 20 20 20 20 -cmd)))....
7640: 20 20 28 69 66 20 28 6f 72 20 28 61 72 67 73 3a (if (or (args:
7650: 67 65 74 2d 61 72 67 20 22 2d 66 6f 72 63 65 22 get-arg "-force"
7660: 29 0a 09 09 09 09 20 20 20 20 20 20 20 28 6c 65 )..... (le
7670: 74 20 28 28 70 72 65 71 73 2d 6e 6f 74 2d 79 65 t ((preqs-not-ye
7680: 74 2d 6d 65 74 20 28 28 63 61 72 20 74 65 73 74 t-met ((car test
7690: 72 75 6e 64 61 74 29 29 29 29 0a 09 09 09 09 09 rundat))))......
76a0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20 (debug:print 2
76b0: 22 50 72 65 71 72 65 71 75 65 73 69 74 65 73 20 "Preqrequesites
76c0: 66 6f 72 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 for " test-name
76d0: 22 3a 20 22 20 70 72 65 71 73 2d 6e 6f 74 2d 79 ": " preqs-not-y
76e0: 65 74 2d 6d 65 74 29 0a 09 09 09 09 09 20 28 6e et-met)...... (n
76f0: 75 6c 6c 3f 20 70 72 65 71 73 2d 6e 6f 74 2d 79 ull? preqs-not-y
7700: 65 74 2d 6d 65 74 29 29 29 20 3b 3b 20 61 72 65 et-met))) ;; are
7710: 20 74 68 65 72 65 20 61 6e 79 20 74 65 73 74 73 there any tests
7720: 20 74 68 61 74 20 6d 75 73 74 20 62 65 20 72 75 that must be ru
7730: 6e 20 62 65 66 6f 72 65 20 74 68 69 73 20 6f 6e n before this on
7740: 65 2e 2e 2e 0a 09 09 09 09 20 20 20 28 69 66 20 e........ (if
7750: 28 6e 6f 74 20 28 28 63 61 64 72 20 74 65 73 74 (not ((cadr test
7760: 72 75 6e 64 61 74 29 29 29 20 3b 3b 20 74 68 69 rundat))) ;; thi
7770: 73 20 69 73 20 74 68 65 20 6c 69 6e 65 20 74 68 s is the line th
7780: 61 74 20 6c 61 75 6e 63 68 65 73 20 74 68 65 20 at launches the
7790: 74 65 73 74 20 74 6f 20 74 68 65 20 72 65 6d 6f test to the remo
77a0: 74 65 20 68 6f 73 74 0a 09 09 09 09 20 20 20 20 te host.....
77b0: 20 20 20 28 62 65 67 69 6e 0a 09 09 09 09 09 20 (begin......
77c0: 28 70 72 69 6e 74 20 22 45 52 52 4f 52 3a 20 46 (print "ERROR: F
77d0: 61 69 6c 65 64 20 74 6f 20 6c 61 75 6e 63 68 20 ailed to launch
77e0: 74 68 65 20 74 65 73 74 2e 20 45 78 69 74 69 6e the test. Exitin
77f0: 67 20 61 73 20 73 6f 6f 6e 20 61 73 20 70 6f 73 g as soon as pos
7800: 73 69 62 6c 65 22 29 0a 09 09 09 09 09 20 28 73 sible")...... (s
7810: 65 74 21 20 2a 67 6c 6f 62 61 6c 65 78 69 74 73 et! *globalexits
7820: 74 61 74 75 73 2a 20 31 29 20 3b 3b 20 0a 09 09 tatus* 1) ;; ...
7830: 09 09 09 20 28 70 72 6f 63 65 73 73 2d 73 69 67 ... (process-sig
7840: 6e 61 6c 20 28 63 75 72 72 65 6e 74 2d 70 72 6f nal (current-pro
7850: 63 65 73 73 2d 69 64 29 20 73 69 67 6e 61 6c 2f cess-id) signal/
7860: 6b 69 6c 6c 29 0a 09 09 09 09 09 20 3b 28 65 78 kill)...... ;(ex
7870: 69 74 20 31 29 0a 09 09 09 09 09 20 29 29 0a 09 it 1)...... ))..
7880: 09 09 09 20 20 20 28 69 66 20 28 6e 6f 74 20 28 ... (if (not (
7890: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 6b args:get-arg "-k
78a0: 65 65 70 67 6f 69 6e 67 22 29 29 0a 09 09 09 09 eepgoing")).....
78b0: 20 20 20 20 20 20 20 28 68 61 73 68 2d 74 61 62 (hash-tab
78c0: 6c 65 2d 73 65 74 21 20 2a 77 61 69 74 69 6e 67 le-set! *waiting
78d0: 2d 71 75 65 75 65 2a 20 6e 65 77 2d 74 65 73 74 -queue* new-test
78e0: 2d 6e 61 6d 65 20 74 65 73 74 72 75 6e 64 61 74 -name testrundat
78f0: 29 29 29 29 29 29 29 0a 09 09 20 20 20 20 20 20 )))))))...
7900: 28 28 4b 49 4c 4c 45 44 29 20 0a 09 09 20 20 20 ((KILLED) ...
7910: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 (debug:print
7920: 20 31 20 22 4e 4f 54 45 3a 20 22 20 6e 65 77 2d 1 "NOTE: " new-
7930: 74 65 73 74 2d 6e 61 6d 65 20 22 20 69 73 20 61 test-name " is a
7940: 6c 72 65 61 64 79 20 72 75 6e 6e 69 6e 67 20 6f lready running o
7950: 72 20 77 61 73 20 65 78 70 6c 69 63 74 6c 79 20 r was explictly
7960: 6b 69 6c 6c 65 64 2c 20 75 73 65 20 2d 66 6f 72 killed, use -for
7970: 63 65 20 74 6f 20 6c 61 75 6e 63 68 20 69 74 2e ce to launch it.
7980: 22 29 29 0a 09 09 20 20 20 20 20 20 28 28 4c 41 "))... ((LA
7990: 55 4e 43 48 45 44 20 52 45 4d 4f 54 45 48 4f 53 UNCHED REMOTEHOS
79a0: 54 53 54 41 52 54 20 52 55 4e 4e 49 4e 47 29 20 TSTART RUNNING)
79b0: 20 0a 09 09 20 20 20 20 20 20 20 28 69 66 20 28 ... (if (
79c0: 3e 20 28 2d 20 28 63 75 72 72 65 6e 74 2d 73 65 > (- (current-se
79d0: 63 6f 6e 64 73 29 28 2b 20 28 64 62 3a 74 65 73 conds)(+ (db:tes
79e0: 74 2d 67 65 74 2d 65 76 65 6e 74 5f 74 69 6d 65 t-get-event_time
79f0: 20 74 65 73 74 64 61 74 29 0a 09 09 09 09 09 09 testdat).......
7a00: 20 20 20 20 20 28 64 62 3a 74 65 73 74 2d 67 65 (db:test-ge
7a10: 74 2d 72 75 6e 5f 64 75 72 61 74 69 6f 6e 20 74 t-run_duration t
7a20: 65 73 74 64 61 74 29 29 29 0a 09 09 09 20 20 20 estdat)))....
7a30: 20 20 20 31 30 30 29 20 3b 3b 20 69 2e 65 2e 20 100) ;; i.e.
7a40: 6e 6f 20 75 70 64 61 74 65 20 66 6f 72 20 6d 6f no update for mo
7a50: 72 65 20 74 68 61 6e 20 31 30 30 20 73 65 63 6f re than 100 seco
7a60: 6e 64 73 0a 09 09 09 20 20 20 28 62 65 67 69 6e nds.... (begin
7a70: 0a 09 09 09 20 20 20 20 20 28 64 65 62 75 67 3a .... (debug:
7a80: 70 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e 47 print 0 "WARNING
7a90: 3a 20 54 65 73 74 20 22 20 74 65 73 74 2d 6e 61 : Test " test-na
7aa0: 6d 65 20 22 20 61 70 70 65 61 72 73 20 74 6f 20 me " appears to
7ab0: 62 65 20 64 65 61 64 2e 20 46 6f 72 63 69 6e 67 be dead. Forcing
7ac0: 20 69 74 20 74 6f 20 73 74 61 74 65 20 49 4e 43 it to state INC
7ad0: 4f 4d 50 4c 45 54 45 20 61 6e 64 20 73 74 61 74 OMPLETE and stat
7ae0: 75 73 20 53 54 55 43 4b 2f 44 45 41 44 22 29 0a us STUCK/DEAD").
7af0: 09 09 09 20 20 20 20 20 28 74 65 73 74 2d 73 65 ... (test-se
7b00: 74 2d 73 74 61 74 75 73 21 20 64 62 20 72 75 6e t-status! db run
7b10: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 22 49 -id test-name "I
7b20: 4e 43 4f 4d 50 4c 45 54 45 22 20 22 53 54 55 43 NCOMPLETE" "STUC
7b30: 4b 2f 44 45 41 44 22 20 69 74 65 6d 64 61 74 20 K/DEAD" itemdat
7b40: 22 54 65 73 74 20 69 73 20 73 74 75 63 6b 20 6f "Test is stuck o
7b50: 72 20 64 65 61 64 22 20 23 66 29 29 0a 09 09 09 r dead" #f))....
7b60: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 (debug:print
7b70: 32 20 22 4e 4f 54 45 3a 20 22 20 74 65 73 74 2d 2 "NOTE: " test-
7b80: 6e 61 6d 65 20 22 20 69 73 20 61 6c 72 65 61 64 name " is alread
7b90: 79 20 72 75 6e 6e 69 6e 67 22 29 29 29 0a 09 09 y running")))...
7ba0: 20 20 20 20 20 20 28 65 6c 73 65 20 20 20 20 20 (else
7bb0: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 (debug:print 0
7bc0: 20 22 45 52 52 4f 52 3a 20 46 61 69 6c 65 64 20 "ERROR: Failed
7bd0: 74 6f 20 6c 61 75 6e 63 68 20 74 65 73 74 20 22 to launch test "
7be0: 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20 22 new-test-name "
7bf0: 2e 20 55 6e 72 65 63 6f 67 6e 69 73 65 64 20 73 . Unrecognised s
7c00: 74 61 74 65 20 22 20 28 74 65 73 74 3a 67 65 74 tate " (test:get
7c10: 2d 73 74 61 74 65 20 74 65 73 74 64 61 74 29 29 -state testdat))
7c20: 29 29 29 29 0a 09 20 20 20 20 20 20 28 69 66 20 )))).. (if
7c30: 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 61 6c 29 (not (null? tal)
7c40: 29 0a 09 09 20 20 28 6c 6f 6f 70 20 28 63 61 72 )... (loop (car
7c50: 20 74 61 6c 29 28 63 64 72 20 74 61 6c 29 29 29 tal)(cdr tal)))
7c60: 29 29 29 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 ))))))..(define
7c70: 28 72 75 6e 2d 77 61 69 74 69 6e 67 2d 74 65 73 (run-waiting-tes
7c80: 74 73 20 64 62 29 0a 20 20 28 6c 65 74 20 28 28 ts db). (let ((
7c90: 6e 75 6d 74 72 69 65 73 20 20 20 20 20 20 20 20 numtries
7ca0: 20 20 20 30 29 0a 09 28 6c 61 73 74 2d 74 72 79 0)..(last-try
7cb0: 2d 74 69 6d 65 20 20 20 20 20 20 28 63 75 72 72 -time (curr
7cc0: 65 6e 74 2d 73 65 63 6f 6e 64 73 29 29 0a 09 28 ent-seconds))..(
7cd0: 74 69 6d 65 73 20 20 20 20 20 20 20 20 20 20 20 times
7ce0: 20 20 20 28 6c 69 73 74 20 31 29 29 29 20 3b 3b (list 1))) ;;
7cf0: 20 6d 69 6e 75 74 65 73 20 74 6f 20 77 61 69 74 minutes to wait
7d00: 20 62 65 66 6f 72 65 20 74 72 79 69 6e 67 20 61 before trying a
7d10: 67 61 69 6e 20 74 6f 20 6b 69 63 6b 20 6f 66 66 gain to kick off
7d20: 20 72 75 6e 73 0a 20 20 20 20 3b 3b 20 42 55 47 runs. ;; BUG
7d30: 20 74 68 69 73 20 68 61 63 6b 20 6f 66 20 62 72 this hack of br
7d40: 75 74 65 20 66 6f 72 63 65 20 72 65 74 72 79 69 ute force retryi
7d50: 6e 67 20 77 6f 72 6b 73 20 71 75 69 74 65 20 77 ng works quite w
7d60: 65 6c 6c 20 66 6f 72 20 6d 61 6e 79 20 63 61 73 ell for many cas
7d70: 65 73 20 62 75 74 20 0a 20 20 20 20 3b 3b 20 20 es but . ;;
7d80: 20 20 20 77 68 61 74 20 69 73 20 6e 65 65 64 65 what is neede
7d90: 64 20 69 73 20 74 6f 20 63 68 65 63 6b 20 74 68 d is to check th
7da0: 65 20 64 62 20 66 6f 72 20 74 65 73 74 73 20 74 e db for tests t
7db0: 68 61 74 20 68 61 76 65 20 66 61 69 6c 65 64 20 hat have failed
7dc0: 6c 65 73 73 20 74 68 61 6e 0a 20 20 20 20 3b 3b less than. ;;
7dd0: 20 20 20 20 20 4e 20 74 69 6d 65 73 20 6f 72 20 N times or
7de0: 6e 65 76 65 72 20 62 65 65 6e 20 73 74 61 72 74 never been start
7df0: 65 64 20 61 6e 64 20 6b 69 63 6b 20 74 68 65 6d ed and kick them
7e00: 20 6f 66 66 20 61 67 61 69 6e 0a 20 20 20 20 28 off again. (
7e10: 6c 65 74 20 6c 6f 6f 70 20 28 28 77 61 69 74 69 let loop ((waiti
7e20: 6e 67 2d 74 65 73 74 2d 6e 61 6d 65 73 20 28 68 ng-test-names (h
7e30: 61 73 68 2d 74 61 62 6c 65 2d 6b 65 79 73 20 2a ash-table-keys *
7e40: 77 61 69 74 69 6e 67 2d 71 75 65 75 65 2a 29 29 waiting-queue*))
7e50: 29 0a 20 20 20 20 20 20 28 63 6f 6e 64 0a 20 20 ). (cond.
7e60: 20 20 20 20 20 28 28 6e 6f 74 20 28 72 75 6e 73 ((not (runs
7e70: 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65 :can-run-more-te
7e80: 73 74 73 20 64 62 29 29 0a 09 28 73 6c 65 65 70 sts db))..(sleep
7e90: 20 32 29 0a 09 28 6c 6f 6f 70 20 77 61 69 74 69 2)..(loop waiti
7ea0: 6e 67 2d 74 65 73 74 2d 6e 61 6d 65 73 29 29 0a ng-test-names)).
7eb0: 20 20 20 20 20 20 20 28 28 6e 75 6c 6c 3f 20 77 ((null? w
7ec0: 61 69 74 69 6e 67 2d 74 65 73 74 2d 6e 61 6d 65 aiting-test-name
7ed0: 73 29 0a 09 28 64 65 62 75 67 3a 70 72 69 6e 74 s)..(debug:print
7ee0: 20 31 20 22 41 6c 6c 20 74 65 73 74 73 20 6c 61 1 "All tests la
7ef0: 75 6e 63 68 65 64 22 29 29 0a 20 20 20 20 20 20 unched")).
7f00: 20 28 65 6c 73 65 0a 09 28 73 65 74 21 20 6e 75 (else..(set! nu
7f10: 6d 74 72 69 65 73 20 28 2b 20 6e 75 6d 74 72 69 mtries (+ numtri
7f20: 65 73 20 31 29 29 0a 09 28 66 6f 72 2d 65 61 63 es 1))..(for-eac
7f30: 68 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74 6e h (lambda (testn
7f40: 61 6d 65 29 0a 09 09 20 20 20 20 28 69 66 20 28 ame)... (if (
7f50: 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72 runs:can-run-mor
7f60: 65 2d 74 65 73 74 73 20 64 62 29 0a 09 09 09 28 e-tests db)....(
7f70: 6c 65 74 2a 20 28 28 74 65 73 74 64 61 74 20 28 let* ((testdat (
7f80: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 20 2a hash-table-ref *
7f90: 77 61 69 74 69 6e 67 2d 71 75 65 75 65 2a 20 74 waiting-queue* t
7fa0: 65 73 74 6e 61 6d 65 29 29 0a 09 09 09 20 20 20 estname))....
7fb0: 20 20 20 20 28 70 72 65 72 65 71 73 20 28 28 63 (prereqs ((c
7fc0: 61 72 20 74 65 73 74 64 61 74 29 29 29 0a 09 09 ar testdat)))...
7fd0: 09 20 20 20 20 20 20 20 28 6c 64 62 20 20 20 20 . (ldb
7fe0: 20 28 69 66 20 64 62 20 64 62 20 28 6f 70 65 6e (if db db (open
7ff0: 2d 64 62 29 29 29 29 0a 09 09 09 20 20 28 64 65 -db)))).... (de
8000: 62 75 67 3a 70 72 69 6e 74 20 32 20 22 70 72 65 bug:print 2 "pre
8010: 72 65 71 73 20 72 65 6d 61 69 6e 69 6e 67 3a 20 reqs remaining:
8020: 22 20 70 72 65 72 65 71 73 29 0a 09 09 09 20 20 " prereqs)....
8030: 28 69 66 20 28 6e 75 6c 6c 3f 20 70 72 65 72 65 (if (null? prere
8040: 71 73 29 0a 09 09 09 20 20 20 20 20 20 28 62 65 qs).... (be
8050: 67 69 6e 0a 09 09 09 09 28 64 65 62 75 67 3a 70 gin.....(debug:p
8060: 72 69 6e 74 20 32 20 22 50 72 65 72 65 71 75 69 rint 2 "Prerequi
8070: 73 69 74 65 73 20 6d 65 74 2c 20 6c 61 75 6e 63 sites met, launc
8080: 68 69 6e 67 20 22 20 74 65 73 74 6e 61 6d 65 29 hing " testname)
8090: 0a 09 09 09 09 28 28 63 61 64 72 20 74 65 73 74 .....((cadr test
80a0: 64 61 74 29 29 0a 09 09 09 09 28 68 61 73 68 2d dat)).....(hash-
80b0: 74 61 62 6c 65 2d 64 65 6c 65 74 65 21 20 2a 77 table-delete! *w
80c0: 61 69 74 69 6e 67 2d 71 75 65 75 65 2a 20 74 65 aiting-queue* te
80d0: 73 74 6e 61 6d 65 29 29 29 0a 09 09 09 20 20 28 stname))).... (
80e0: 69 66 20 28 6e 6f 74 20 64 62 29 0a 09 09 09 20 if (not db)....
80f0: 20 20 20 20 20 28 73 71 6c 69 74 65 33 3a 66 69 (sqlite3:fi
8100: 6e 61 6c 69 7a 65 21 20 6c 64 62 29 29 29 29 29 nalize! ldb)))))
8110: 0a 09 09 20 20 77 61 69 74 69 6e 67 2d 74 65 73 ... waiting-tes
8120: 74 2d 6e 61 6d 65 73 29 0a 09 3b 3b 20 28 73 6c t-names)..;; (sl
8130: 65 65 70 20 31 30 29 20 3b 3b 20 6e 6f 20 70 6f eep 10) ;; no po
8140: 69 6e 74 20 69 6e 20 72 75 73 68 69 6e 67 20 74 int in rushing t
8150: 68 69 6e 67 73 20 61 74 20 74 68 69 73 20 73 74 hings at this st
8160: 61 67 65 3f 0a 09 28 6c 6f 6f 70 20 28 68 61 73 age?..(loop (has
8170: 68 2d 74 61 62 6c 65 2d 6b 65 79 73 20 2a 77 61 h-table-keys *wa
8180: 69 74 69 6e 67 2d 71 75 65 75 65 2a 29 29 29 29 iting-queue*))))
8190: 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 67 65 )))..(define (ge
81a0: 74 2d 64 69 72 2d 75 70 2d 6e 20 64 69 72 20 2e t-dir-up-n dir .
81b0: 20 70 61 72 61 6d 73 29 20 0a 20 20 28 6c 65 74 params) . (let
81c0: 20 28 28 64 70 61 72 74 73 20 20 28 73 74 72 69 ((dparts (stri
81d0: 6e 67 2d 73 70 6c 69 74 20 64 69 72 20 22 2f 22 ng-split dir "/"
81e0: 29 29 0a 09 28 63 6f 75 6e 74 20 20 20 28 69 66 ))..(count (if
81f0: 20 28 6e 75 6c 6c 3f 20 70 61 72 61 6d 73 29 20 (null? params)
8200: 31 20 28 63 61 72 20 70 61 72 61 6d 73 29 29 29 1 (car params)))
8210: 29 0a 20 20 20 20 28 63 6f 6e 63 20 22 2f 22 20 ). (conc "/"
8220: 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 (string-interspe
8230: 72 73 65 20 0a 09 20 20 20 20 20 20 20 28 74 61 rse .. (ta
8240: 6b 65 20 64 70 61 72 74 73 20 28 2d 20 28 6c 65 ke dparts (- (le
8250: 6e 67 74 68 20 64 70 61 72 74 73 29 20 63 6f 75 ngth dparts) cou
8260: 6e 74 29 29 0a 09 20 20 20 20 20 20 20 22 2f 22 nt)).. "/"
8270: 29 29 29 29 0a 3b 3b 20 52 65 6d 6f 76 65 20 72 )))).;; Remove r
8280: 75 6e 73 0a 3b 3b 20 66 69 65 6c 64 73 20 61 72 uns.;; fields ar
8290: 65 20 70 61 73 73 69 6e 67 20 69 6e 20 74 68 72 e passing in thr
82a0: 6f 75 67 68 20 0a 28 64 65 66 69 6e 65 20 28 72 ough .(define (r
82b0: 75 6e 73 3a 72 65 6d 6f 76 65 2d 72 75 6e 73 20 uns:remove-runs
82c0: 64 62 20 72 75 6e 6e 61 6d 65 70 61 74 74 20 74 db runnamepatt t
82d0: 65 73 74 70 61 74 74 20 69 74 65 6d 70 61 74 74 estpatt itempatt
82e0: 29 0a 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 73 ). (let* ((keys
82f0: 20 20 20 20 20 20 20 20 28 64 62 2d 67 65 74 2d (db-get-
8300: 6b 65 79 73 20 64 62 29 29 0a 09 20 28 72 75 6e keys db)).. (run
8310: 64 61 74 20 20 20 20 20 20 28 72 75 6e 73 3a 67 dat (runs:g
8320: 65 74 2d 72 75 6e 73 2d 62 79 2d 70 61 74 74 20 et-runs-by-patt
8330: 64 62 20 6b 65 79 73 20 72 75 6e 6e 61 6d 65 70 db keys runnamep
8340: 61 74 74 29 29 0a 09 20 28 68 65 61 64 65 72 20 att)).. (header
8350: 20 20 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66 (vector-ref
8360: 20 72 75 6e 64 61 74 20 30 29 29 0a 09 20 28 72 rundat 0)).. (r
8370: 75 6e 73 20 20 20 20 20 20 20 20 28 76 65 63 74 uns (vect
8380: 6f 72 2d 72 65 66 20 72 75 6e 64 61 74 20 31 29 or-ref rundat 1)
8390: 29 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72 )). (debug:pr
83a0: 69 6e 74 20 31 20 22 48 65 61 64 65 72 3a 20 22 int 1 "Header: "
83b0: 20 68 65 61 64 65 72 29 0a 20 20 20 20 28 66 6f header). (fo
83c0: 72 2d 65 61 63 68 0a 20 20 20 20 20 28 6c 61 6d r-each. (lam
83d0: 62 64 61 20 28 72 75 6e 29 0a 20 20 20 20 20 20 bda (run).
83e0: 20 28 6c 65 74 20 28 28 72 75 6e 6b 65 79 20 28 (let ((runkey (
83f0: 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 string-intersper
8400: 73 65 20 28 6d 61 70 20 28 6c 61 6d 62 64 61 20 se (map (lambda
8410: 28 6b 29 0a 09 09 09 09 09 09 28 64 62 3a 67 65 (k).......(db:ge
8420: 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 t-value-by-heade
8430: 72 20 72 75 6e 20 68 65 61 64 65 72 20 28 76 65 r run header (ve
8440: 63 74 6f 72 2d 72 65 66 20 6b 20 30 29 29 29 20 ctor-ref k 0)))
8450: 6b 65 79 73 29 20 22 2f 22 29 29 0a 09 20 20 20 keys) "/"))..
8460: 20 20 28 64 69 72 73 2d 74 6f 2d 72 65 6d 6f 76 (dirs-to-remov
8470: 65 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 e (make-hash-tab
8480: 6c 65 29 29 29 0a 09 20 28 6c 65 74 2a 20 28 28 le))).. (let* ((
8490: 72 75 6e 2d 69 64 20 28 64 62 3a 67 65 74 2d 76 run-id (db:get-v
84a0: 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72 alue-by-header r
84b0: 75 6e 20 68 65 61 64 65 72 20 22 69 64 22 29 20 un header "id")
84c0: 29 0a 09 09 28 74 65 73 74 73 20 20 28 64 62 2d )...(tests (db-
84d0: 67 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d 72 75 get-tests-for-ru
84e0: 6e 20 64 62 20 28 64 62 3a 67 65 74 2d 76 61 6c n db (db:get-val
84f0: 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e ue-by-header run
8500: 20 68 65 61 64 65 72 20 22 69 64 22 29 20 74 65 header "id") te
8510: 73 74 70 61 74 74 20 69 74 65 6d 70 61 74 74 29 stpatt itempatt)
8520: 29 0a 09 09 28 6c 61 73 74 74 70 61 74 68 20 22 )...(lasttpath "
8530: 2f 64 6f 65 73 2f 6e 6f 74 2f 65 78 69 73 74 2f /does/not/exist/
8540: 49 2f 68 6f 70 65 22 29 29 0a 0a 09 20 20 20 28 I/hope"))... (
8550: 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 if (not (null? t
8560: 65 73 74 73 29 29 0a 09 20 20 20 20 20 20 20 28 ests)).. (
8570: 62 65 67 69 6e 0a 09 09 20 28 64 65 62 75 67 3a begin... (debug:
8580: 70 72 69 6e 74 20 31 20 22 52 65 6d 6f 76 69 6e print 1 "Removin
8590: 67 20 74 65 73 74 73 20 66 6f 72 20 72 75 6e 3a g tests for run:
85a0: 20 22 20 72 75 6e 6b 65 79 20 22 20 22 20 28 64 " runkey " " (d
85b0: 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 b:get-value-by-h
85c0: 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65 72 eader run header
85d0: 20 22 72 75 6e 6e 61 6d 65 22 29 29 0a 09 09 20 "runname"))...
85e0: 28 66 6f 72 2d 65 61 63 68 0a 09 09 20 20 28 6c (for-each... (l
85f0: 61 6d 62 64 61 20 28 74 65 73 74 29 0a 09 09 20 ambda (test)...
8600: 20 20 20 28 6c 65 74 2a 20 28 28 69 74 65 6d 2d (let* ((item-
8610: 70 61 74 68 20 28 64 62 3a 74 65 73 74 2d 67 65 path (db:test-ge
8620: 74 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 t-item-path test
8630: 29 29 0a 09 09 09 20 20 20 28 74 65 73 74 2d 6e )).... (test-n
8640: 61 6d 65 20 28 64 62 3a 74 65 73 74 2d 67 65 74 ame (db:test-get
8650: 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 29 29 -testname test))
8660: 0a 09 09 09 20 20 20 28 72 75 6e 2d 64 69 72 20 .... (run-dir
8670: 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 72 (db:test-get-r
8680: 75 6e 64 69 72 20 74 65 73 74 29 29 29 0a 09 09 undir test)))...
8690: 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 (debug:pri
86a0: 6e 74 20 31 20 22 20 20 22 20 28 64 62 3a 74 65 nt 1 " " (db:te
86b0: 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 st-get-testname
86c0: 74 65 73 74 29 20 22 20 69 64 3a 20 22 20 28 64 test) " id: " (d
86d0: 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65 b:test-get-id te
86e0: 73 74 29 20 22 20 22 20 69 74 65 6d 2d 70 61 74 st) " " item-pat
86f0: 68 29 0a 09 09 20 20 20 20 20 20 28 64 62 3a 64 h)... (db:d
8700: 65 6c 65 74 65 2d 74 65 73 74 2d 72 65 63 6f 72 elete-test-recor
8710: 64 73 20 64 62 20 28 64 62 3a 74 65 73 74 2d 67 ds db (db:test-g
8720: 65 74 2d 69 64 20 74 65 73 74 29 29 0a 09 09 20 et-id test))...
8730: 20 20 20 20 20 28 69 66 20 28 3e 20 28 73 74 72 (if (> (str
8740: 69 6e 67 2d 6c 65 6e 67 74 68 20 72 75 6e 2d 64 ing-length run-d
8750: 69 72 29 20 35 29 20 3b 3b 20 62 61 64 20 68 65 ir) 5) ;; bad he
8760: 75 72 69 73 74 69 63 20 62 75 74 20 73 68 6f 75 uristic but shou
8770: 6c 64 20 70 72 65 76 65 6e 74 20 2f 74 6d 70 20 ld prevent /tmp
8780: 2f 68 6f 6d 65 20 65 74 63 2e 0a 09 09 09 20 20 /home etc.....
8790: 28 6c 65 74 20 28 28 66 75 6c 6c 70 61 74 68 20 (let ((fullpath
87a0: 72 75 6e 2d 64 69 72 29 29 20 3b 3b 20 22 2f 22 run-dir)) ;; "/"
87b0: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 (db:test-get-it
87c0: 65 6d 2d 70 61 74 68 20 74 65 73 74 29 29 29 29 em-path test))))
87d0: 0a 09 09 09 20 20 20 20 28 73 65 74 21 20 6c 61 .... (set! la
87e0: 73 74 74 70 61 74 68 20 66 75 6c 6c 70 61 74 68 sttpath fullpath
87f0: 29 0a 09 09 09 20 20 20 20 28 68 61 73 68 2d 74 ).... (hash-t
8800: 61 62 6c 65 2d 73 65 74 21 20 64 69 72 73 2d 74 able-set! dirs-t
8810: 6f 2d 72 65 6d 6f 76 65 20 66 75 6c 6c 70 61 74 o-remove fullpat
8820: 68 20 23 74 29 0a 09 09 09 20 20 20 20 3b 3b 20 h #t).... ;;
8830: 54 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 77 61 The following wa
8840: 73 20 74 68 65 20 73 61 66 65 20 64 65 6c 65 74 s the safe delet
8850: 65 20 63 6f 64 65 20 62 75 74 20 69 74 20 77 61 e code but it wa
8860: 73 20 6e 6f 74 20 62 65 69 6e 67 20 65 78 65 63 s not being exec
8870: 74 75 74 65 64 2e 0a 09 09 09 20 20 20 20 3b 3b tuted..... ;;
8880: 20 28 6c 65 74 2a 20 28 28 64 69 72 73 2d 63 6f (let* ((dirs-co
8890: 75 6e 74 20 28 2b 20 31 20 28 6c 65 6e 67 74 68 unt (+ 1 (length
88a0: 20 6b 65 79 73 29 28 6c 65 6e 67 74 68 20 28 73 keys)(length (s
88b0: 74 72 69 6e 67 2d 73 70 6c 69 74 20 69 74 65 6d tring-split item
88c0: 2d 70 61 74 68 20 22 2f 22 29 29 29 29 0a 09 09 -path "/"))))...
88d0: 09 20 20 20 20 3b 3b 20 20 20 20 20 20 20 20 28 . ;; (
88e0: 64 69 72 2d 74 6f 2d 72 65 6d 20 28 67 65 74 2d dir-to-rem (get-
88f0: 64 69 72 2d 75 70 2d 6e 20 66 75 6c 6c 70 61 74 dir-up-n fullpat
8900: 68 20 64 69 72 73 2d 63 6f 75 6e 74 29 29 0a 09 h dirs-count))..
8910: 09 09 20 20 20 20 3b 3b 20 20 20 20 20 20 20 20 .. ;;
8920: 28 72 65 6d 61 69 6e 69 6e 67 64 20 28 73 74 72 (remainingd (str
8930: 69 6e 67 2d 73 75 62 73 74 69 74 75 74 65 20 28 ing-substitute (
8940: 72 65 67 65 78 70 20 28 63 6f 6e 63 20 22 5e 22 regexp (conc "^"
8950: 20 64 69 72 2d 74 6f 2d 72 65 6d 20 22 2f 22 29 dir-to-rem "/")
8960: 29 20 22 22 20 66 75 6c 6c 70 61 74 68 29 29 0a ) "" fullpath)).
8970: 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20 20 20 ... ;;
8980: 20 28 63 6d 64 20 28 63 6f 6e 63 20 22 63 64 20 (cmd (conc "cd
8990: 22 20 64 69 72 2d 74 6f 2d 72 65 6d 20 22 3b 20 " dir-to-rem ";
89a0: 72 6d 64 69 72 20 2d 70 20 22 20 72 65 6d 61 69 rmdir -p " remai
89b0: 6e 69 6e 67 64 20 29 29 29 0a 09 09 09 20 20 20 ningd )))....
89c0: 20 3b 3b 20 20 20 28 69 66 20 28 66 69 6c 65 2d ;; (if (file-
89d0: 65 78 69 73 74 73 3f 20 66 75 6c 6c 70 61 74 68 exists? fullpath
89e0: 29 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20 ).... ;;
89f0: 20 20 28 62 65 67 69 6e 0a 09 09 09 20 20 20 20 (begin....
8a00: 3b 3b 20 20 20 20 20 20 20 20 20 28 64 65 62 75 ;; (debu
8a10: 67 3a 70 72 69 6e 74 20 31 20 63 6d 64 29 0a 09 g:print 1 cmd)..
8a20: 09 09 20 20 20 20 3b 3b 20 20 20 20 20 20 20 20 .. ;;
8a30: 20 28 73 79 73 74 65 6d 20 63 6d 64 29 29 29 0a (system cmd))).
8a40: 09 09 09 20 20 20 20 3b 3b 20 20 20 29 29 0a 09 ... ;; ))..
8a50: 09 09 20 20 20 20 29 29 29 29 0a 09 09 20 20 20 .. ))))...
8a60: 20 74 65 73 74 73 29 29 29 0a 0a 09 20 20 20 3b tests)))... ;
8a70: 3b 20 6c 6f 6f 6b 20 74 68 6f 75 67 68 20 74 68 ; look though th
8a80: 65 20 64 69 72 73 2d 74 6f 2d 72 65 6d 6f 76 65 e dirs-to-remove
8a90: 20 66 6f 72 20 63 61 6e 64 69 64 61 74 65 73 20 for candidates
8aa0: 66 6f 72 20 72 65 6d 6f 76 61 6c 2e 20 44 6f 20 for removal. Do
8ab0: 74 68 69 73 20 61 66 74 65 72 20 64 65 6c 65 74 this after delet
8ac0: 69 6e 67 20 74 68 65 20 72 65 63 6f 72 64 73 0a ing the records.
8ad0: 09 20 20 20 3b 3b 20 66 6f 72 20 65 61 63 68 20 . ;; for each
8ae0: 74 65 73 74 20 69 6e 20 63 61 73 65 20 77 65 20 test in case we
8af0: 67 65 74 20 6b 69 6c 6c 65 64 2e 20 54 68 61 74 get killed. That
8b00: 20 73 68 6f 75 6c 64 20 6d 69 6e 69 6d 69 7a 65 should minimize
8b10: 20 74 68 65 20 64 65 74 72 69 74 75 73 20 6c 65 the detritus le
8b20: 66 74 20 6f 6e 20 64 69 73 6b 0a 09 20 20 20 3b ft on disk.. ;
8b30: 3b 20 70 72 6f 63 65 73 73 20 74 68 65 20 64 69 ; process the di
8b40: 72 73 20 66 72 6f 6d 20 6c 6f 6e 67 65 73 74 20 rs from longest
8b50: 73 74 72 69 6e 67 20 6c 65 6e 67 74 68 20 74 6f string length to
8b60: 20 73 68 6f 72 74 65 73 74 0a 09 20 20 20 28 66 shortest.. (f
8b70: 6f 72 2d 65 61 63 68 20 0a 09 20 20 20 20 28 6c or-each .. (l
8b80: 61 6d 62 64 61 20 28 64 69 72 2d 74 6f 2d 72 65 ambda (dir-to-re
8b90: 6d 6f 76 65 29 0a 09 20 20 20 20 20 20 28 69 66 move).. (if
8ba0: 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 64 (file-exists? d
8bb0: 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 0a 09 09 ir-to-remove)...
8bc0: 20 20 28 6c 65 74 20 28 28 64 69 72 2d 69 6e 2d (let ((dir-in-
8bd0: 64 62 20 27 28 29 29 29 0a 09 09 20 20 20 20 28 db '()))... (
8be0: 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 sqlite3:for-each
8bf0: 2d 72 6f 77 0a 09 09 20 20 20 20 20 28 6c 61 6d -row... (lam
8c00: 62 64 61 20 28 64 69 72 29 0a 09 09 20 20 20 20 bda (dir)...
8c10: 20 20 20 28 73 65 74 21 20 64 69 72 2d 69 6e 2d (set! dir-in-
8c20: 64 62 20 28 63 6f 6e 73 20 64 69 72 20 64 69 72 db (cons dir dir
8c30: 2d 69 6e 2d 64 62 29 29 29 0a 09 09 20 20 20 20 -in-db)))...
8c40: 20 64 62 20 22 53 45 4c 45 43 54 20 72 75 6e 64 db "SELECT rund
8c50: 69 72 20 46 52 4f 4d 20 74 65 73 74 73 20 57 48 ir FROM tests WH
8c60: 45 52 45 20 72 75 6e 64 69 72 20 4c 49 4b 45 20 ERE rundir LIKE
8c70: 3f 3b 22 20 0a 09 09 20 20 20 20 20 28 63 6f 6e ?;" ... (con
8c80: 63 20 22 25 22 20 64 69 72 2d 74 6f 2d 72 65 6d c "%" dir-to-rem
8c90: 6f 76 65 20 22 25 22 29 29 20 3b 3b 20 79 65 73 ove "%")) ;; yes
8ca0: 2c 20 49 27 6d 20 67 6f 69 6e 67 20 74 6f 20 62 , I'm going to b
8cb0: 61 69 6c 20 69 66 20 74 68 65 72 65 20 69 73 20 ail if there is
8cc0: 61 6e 79 74 68 69 6e 67 20 6c 69 6b 65 20 74 68 anything like th
8cd0: 69 73 20 64 69 72 20 69 6e 20 74 68 65 20 64 62 is dir in the db
8ce0: 0a 09 09 20 20 20 20 28 69 66 20 28 6e 75 6c 6c ... (if (null
8cf0: 3f 20 64 69 72 2d 69 6e 2d 64 62 29 0a 09 09 09 ? dir-in-db)....
8d00: 28 62 65 67 69 6e 0a 09 09 09 20 20 28 64 65 62 (begin.... (deb
8d10: 75 67 3a 70 72 69 6e 74 20 32 20 22 52 65 6d 6f ug:print 2 "Remo
8d20: 76 69 6e 67 20 64 69 72 65 63 74 6f 72 79 20 77 ving directory w
8d30: 69 74 68 20 7a 65 72 6f 20 64 62 20 72 65 66 65 ith zero db refe
8d40: 72 65 6e 63 65 73 3a 20 22 20 64 69 72 2d 74 6f rences: " dir-to
8d50: 2d 72 65 6d 6f 76 65 29 0a 09 09 09 20 20 28 73 -remove).... (s
8d60: 79 73 74 65 6d 20 28 63 6f 6e 63 20 22 72 6d 20 ystem (conc "rm
8d70: 2d 72 66 20 22 20 64 69 72 2d 74 6f 2d 72 65 6d -rf " dir-to-rem
8d80: 6f 76 65 29 29 0a 09 09 09 20 20 28 68 61 73 68 ove)).... (hash
8d90: 2d 74 61 62 6c 65 2d 64 65 6c 65 74 65 21 20 64 -table-delete! d
8da0: 69 72 73 2d 74 6f 2d 72 65 6d 6f 76 65 20 64 69 irs-to-remove di
8db0: 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 29 0a 09 09 r-to-remove))...
8dc0: 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20 .(debug:print 2
8dd0: 22 53 6b 69 70 70 69 6e 67 20 72 65 6d 6f 76 61 "Skipping remova
8de0: 6c 20 6f 66 20 22 20 64 69 72 2d 74 6f 2d 72 65 l of " dir-to-re
8df0: 6d 6f 76 65 20 22 20 66 6f 72 20 6e 6f 77 20 61 move " for now a
8e00: 73 20 69 74 20 73 74 69 6c 6c 20 68 61 73 20 72 s it still has r
8e10: 65 66 65 72 65 6e 63 65 73 20 69 6e 20 74 68 65 eferences in the
8e20: 20 64 61 74 61 62 61 73 65 22 29 29 29 29 29 0a database"))))).
8e30: 09 20 20 20 20 28 73 6f 72 74 20 28 68 61 73 68 . (sort (hash
8e40: 2d 74 61 62 6c 65 2d 6b 65 79 73 20 64 69 72 73 -table-keys dirs
8e50: 2d 74 6f 2d 72 65 6d 6f 76 65 29 20 28 6c 61 6d -to-remove) (lam
8e60: 62 64 61 20 28 61 20 62 29 28 3e 20 28 73 74 72 bda (a b)(> (str
8e70: 69 6e 67 2d 6c 65 6e 67 74 68 20 61 29 28 73 74 ing-length a)(st
8e80: 72 69 6e 67 2d 6c 65 6e 67 74 68 20 62 29 29 29 ring-length b)))
8e90: 29 29 0a 0a 09 20 20 20 3b 3b 20 72 65 6d 6f 76 ))... ;; remov
8ea0: 65 20 74 68 65 20 72 75 6e 20 69 66 20 7a 65 72 e the run if zer
8eb0: 6f 20 74 65 73 74 73 20 72 65 6d 61 69 6e 0a 09 o tests remain..
8ec0: 20 20 20 28 6c 65 74 20 28 28 72 65 6d 74 65 73 (let ((remtes
8ed0: 74 73 20 28 64 62 2d 67 65 74 2d 74 65 73 74 73 ts (db-get-tests
8ee0: 2d 66 6f 72 2d 72 75 6e 20 64 62 20 28 64 62 3a -for-run db (db:
8ef0: 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 get-value-by-hea
8f00: 64 65 72 20 72 75 6e 20 68 65 61 64 65 72 20 22 der run header "
8f10: 69 64 22 29 29 29 29 0a 09 20 20 20 20 20 28 69 id")))).. (i
8f20: 66 20 28 6e 75 6c 6c 3f 20 72 65 6d 74 65 73 74 f (null? remtest
8f30: 73 29 20 3b 3b 20 6e 6f 20 6d 6f 72 65 20 74 65 s) ;; no more te
8f40: 73 74 73 20 72 65 6d 61 69 6e 69 6e 67 0a 09 09 sts remaining...
8f50: 20 28 6c 65 74 2a 20 28 28 64 70 61 72 74 73 20 (let* ((dparts
8f60: 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 6c (string-split l
8f70: 61 73 74 74 70 61 74 68 20 22 2f 22 29 29 0a 09 asttpath "/"))..
8f80: 09 09 28 72 75 6e 70 61 74 68 20 28 63 6f 6e 63 ..(runpath (conc
8f90: 20 22 2f 22 20 28 73 74 72 69 6e 67 2d 69 6e 74 "/" (string-int
8fa0: 65 72 73 70 65 72 73 65 20 0a 09 09 09 09 09 20 ersperse ......
8fb0: 20 20 20 28 74 61 6b 65 20 64 70 61 72 74 73 20 (take dparts
8fc0: 28 2d 20 28 6c 65 6e 67 74 68 20 64 70 61 72 74 (- (length dpart
8fd0: 73 29 20 31 29 29 0a 09 09 09 09 09 20 20 20 20 s) 1))......
8fe0: 22 2f 22 29 29 29 29 0a 09 09 20 20 20 28 64 65 "/"))))... (de
8ff0: 62 75 67 3a 70 72 69 6e 74 20 31 20 22 52 65 6d bug:print 1 "Rem
9000: 6f 76 69 6e 67 20 72 75 6e 3a 20 22 20 72 75 6e oving run: " run
9010: 6b 65 79 20 22 20 22 20 28 64 62 3a 67 65 74 2d key " " (db:get-
9020: 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 value-by-header
9030: 72 75 6e 20 68 65 61 64 65 72 20 22 72 75 6e 6e run header "runn
9040: 61 6d 65 22 29 29 0a 09 09 20 20 20 28 64 62 3a ame"))... (db:
9050: 64 65 6c 65 74 65 2d 72 75 6e 20 64 62 20 72 75 delete-run db ru
9060: 6e 2d 69 64 29 0a 09 09 20 20 20 3b 3b 20 6e 65 n-id)... ;; ne
9070: 65 64 20 74 6f 20 66 69 67 75 72 65 20 6f 75 74 ed to figure out
9080: 20 74 68 65 20 70 61 74 68 20 74 6f 20 74 68 65 the path to the
9090: 20 72 75 6e 20 64 69 72 20 61 6e 64 20 72 65 6d run dir and rem
90a0: 6f 76 65 20 69 74 20 69 66 20 65 6d 70 74 79 0a ove it if empty.
90b0: 09 09 20 20 20 3b 3b 20 20 20 20 28 69 66 20 28 .. ;; (if (
90c0: 6e 75 6c 6c 3f 20 28 67 6c 6f 62 20 28 63 6f 6e null? (glob (con
90d0: 63 20 72 75 6e 70 61 74 68 20 22 2f 2a 22 29 29 c runpath "/*"))
90e0: 29 0a 09 09 20 20 20 3b 3b 20 20 20 20 20 20 20 )... ;;
90f0: 20 28 62 65 67 69 6e 0a 09 09 20 20 20 3b 3b 20 (begin... ;;
9100: 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 . (debug:print 1
9110: 20 22 52 65 6d 6f 76 69 6e 67 20 72 75 6e 20 64 "Removing run d
9120: 69 72 20 22 20 72 75 6e 70 61 74 68 29 0a 09 09 ir " runpath)...
9130: 20 20 20 3b 3b 20 09 20 28 73 79 73 74 65 6d 20 ;; . (system
9140: 28 63 6f 6e 63 20 22 72 6d 64 69 72 20 2d 70 20 (conc "rmdir -p
9150: 22 20 72 75 6e 70 61 74 68 29 29 29 29 0a 09 09 " runpath))))...
9160: 20 20 20 29 29 29 29 0a 09 20 29 29 0a 20 20 20 )))).. )).
9170: 20 20 72 75 6e 73 29 29 29 0a 0a 3b 3b 3d 3d 3d runs)))..;;===
9180: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
9190: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
91a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
91b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
91c0: 3d 3d 3d 0a 3b 3b 20 52 6f 75 74 69 6e 65 73 20 ===.;; Routines
91d0: 66 6f 72 20 6d 61 6e 69 70 75 6c 61 74 69 6e 67 for manipulating
91e0: 20 72 75 6e 73 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d runs.;;========
91f0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
9200: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
9210: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
9220: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a ==============..
9230: 3b 3b 20 53 69 6e 63 65 20 6d 61 6e 79 20 63 61 ;; Since many ca
9240: 6c 6c 73 20 74 6f 20 61 20 72 75 6e 20 72 65 71 lls to a run req
9250: 75 69 72 65 20 70 72 65 74 74 79 20 6d 75 63 68 uire pretty much
9260: 20 74 68 65 20 73 61 6d 65 20 73 65 74 75 70 20 the same setup
9270: 0a 3b 3b 20 74 68 69 73 20 77 72 61 70 70 65 72 .;; this wrapper
9280: 20 69 73 20 75 73 65 64 20 74 6f 20 72 65 64 75 is used to redu
9290: 63 65 20 74 68 65 20 72 65 70 6c 69 63 61 74 69 ce the replicati
92a0: 6f 6e 20 6f 66 20 63 6f 64 65 0a 28 64 65 66 69 on of code.(defi
92b0: 6e 65 20 28 67 65 6e 65 72 61 6c 2d 72 75 6e 2d ne (general-run-
92c0: 63 61 6c 6c 20 73 77 69 74 63 68 6e 61 6d 65 20 call switchname
92d0: 61 63 74 69 6f 6e 2d 64 65 73 63 20 70 72 6f 63 action-desc proc
92e0: 29 0a 20 20 28 69 66 20 28 6e 6f 74 20 28 61 72 ). (if (not (ar
92f0: 67 73 3a 67 65 74 2d 61 72 67 20 22 3a 72 75 6e gs:get-arg ":run
9300: 6e 61 6d 65 22 29 29 0a 20 20 20 20 20 20 28 62 name")). (b
9310: 65 67 69 6e 0a 09 28 64 65 62 75 67 3a 70 72 69 egin..(debug:pri
9320: 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 4d 69 73 nt 0 "ERROR: Mis
9330: 73 69 6e 67 20 72 65 71 75 69 72 65 64 20 70 61 sing required pa
9340: 72 61 6d 65 74 65 72 20 66 6f 72 20 22 20 73 77 rameter for " sw
9350: 69 74 63 68 6e 61 6d 65 20 22 2c 20 79 6f 75 20 itchname ", you
9360: 6d 75 73 74 20 73 70 65 63 69 66 79 20 74 68 65 must specify the
9370: 20 72 75 6e 20 6e 61 6d 65 20 77 69 74 68 20 3a run name with :
9380: 72 75 6e 6e 61 6d 65 20 72 75 6e 6e 61 6d 65 22 runname runname"
9390: 29 0a 09 28 65 78 69 74 20 32 29 29 0a 20 20 20 )..(exit 2)).
93a0: 20 20 20 28 6c 65 74 20 28 28 64 62 20 23 66 29 (let ((db #f)
93b0: 29 0a 09 28 69 66 20 28 6e 6f 74 20 28 73 65 74 )..(if (not (set
93c0: 75 70 2d 66 6f 72 2d 72 75 6e 29 29 0a 09 20 20 up-for-run))..
93d0: 20 20 28 62 65 67 69 6e 20 0a 09 20 20 20 20 20 (begin ..
93e0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 (debug:print 0
93f0: 22 46 61 69 6c 65 64 20 74 6f 20 73 65 74 75 70 "Failed to setup
9400: 2c 20 65 78 69 74 69 6e 67 22 29 0a 09 20 20 20 , exiting")..
9410: 20 20 20 28 65 78 69 74 20 31 29 29 29 0a 09 28 (exit 1)))..(
9420: 73 65 74 21 20 64 62 20 28 6f 70 65 6e 2d 64 62 set! db (open-db
9430: 29 29 0a 09 28 69 66 20 28 6e 6f 74 20 28 63 61 ))..(if (not (ca
9440: 72 20 2a 63 6f 6e 66 69 67 69 6e 66 6f 2a 29 29 r *configinfo*))
9450: 0a 09 20 20 20 20 28 62 65 67 69 6e 0a 09 20 20 .. (begin..
9460: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 (debug:print
9470: 20 30 20 22 45 52 52 4f 52 3a 20 41 74 74 65 6d 0 "ERROR: Attem
9480: 70 74 65 64 20 74 6f 20 22 20 61 63 74 69 6f 6e pted to " action
9490: 2d 64 65 73 63 20 22 20 62 75 74 20 72 75 6e 20 -desc " but run
94a0: 61 72 65 61 20 63 6f 6e 66 69 67 20 66 69 6c 65 area config file
94b0: 20 6e 6f 74 20 66 6f 75 6e 64 22 29 0a 09 20 20 not found")..
94c0: 20 20 20 20 28 65 78 69 74 20 31 29 29 0a 09 20 (exit 1))..
94d0: 20 20 20 3b 3b 20 45 78 74 72 61 63 74 20 6f 75 ;; Extract ou
94e0: 74 20 73 74 75 66 66 20 6e 65 65 64 65 64 20 69 t stuff needed i
94f0: 6e 20 6d 6f 73 74 20 6f 72 20 6d 61 6e 79 20 63 n most or many c
9500: 61 6c 6c 73 0a 09 20 20 20 20 3b 3b 20 68 65 72 alls.. ;; her
9510: 65 20 74 68 65 6e 20 63 61 6c 6c 20 70 72 6f 63 e then call proc
9520: 0a 09 20 20 20 20 28 6c 65 74 2a 20 28 28 6b 65 .. (let* ((ke
9530: 79 73 20 20 20 20 20 20 20 28 64 62 2d 67 65 74 ys (db-get
9540: 2d 6b 65 79 73 20 64 62 29 29 0a 09 09 20 20 20 -keys db))...
9550: 28 6b 65 79 6e 61 6d 65 73 20 20 20 28 6d 61 70 (keynames (map
9560: 20 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64 6e 61 key:get-fieldna
9570: 6d 65 20 6b 65 79 73 29 29 0a 09 09 20 20 20 28 me keys))... (
9580: 6b 65 79 76 61 6c 6c 73 74 20 20 28 6b 65 79 73 keyvallst (keys
9590: 2d 3e 76 61 6c 6c 69 73 74 20 6b 65 79 73 20 23 ->vallist keys #
95a0: 74 29 29 29 0a 09 20 20 20 20 20 20 28 70 72 6f t))).. (pro
95b0: 63 20 64 62 20 6b 65 79 73 20 6b 65 79 6e 61 6d c db keys keynam
95c0: 65 73 20 6b 65 79 76 61 6c 6c 73 74 29 29 29 0a es keyvallst))).
95d0: 09 28 73 71 6c 69 74 65 33 3a 66 69 6e 61 6c 69 .(sqlite3:finali
95e0: 7a 65 21 20 64 62 29 0a 09 28 73 65 74 21 20 2a ze! db)..(set! *
95f0: 64 69 64 73 6f 6d 65 74 68 69 6e 67 2a 20 23 74 didsomething* #t
9600: 29 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d ))))..;;========
9610: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
9620: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
9630: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
9640: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b ==============.;
9650: 3b 20 52 6f 6c 6c 75 70 20 72 75 6e 73 0a 3b 3b ; Rollup runs.;;
9660: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
9670: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
9680: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
9690: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
96a0: 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 55 70 64 61 74 ======..;; Updat
96b0: 65 20 74 68 65 20 74 65 73 74 5f 6d 65 74 61 20 e the test_meta
96c0: 74 61 62 6c 65 20 66 6f 72 20 74 68 69 73 20 74 table for this t
96d0: 65 73 74 0a 28 64 65 66 69 6e 65 20 28 72 75 6e est.(define (run
96e0: 73 3a 75 70 64 61 74 65 2d 74 65 73 74 5f 6d 65 s:update-test_me
96f0: 74 61 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 20 ta db test-name
9700: 74 65 73 74 2d 63 6f 6e 66 29 0a 20 20 28 6c 65 test-conf). (le
9710: 74 20 28 28 63 75 72 72 72 65 63 6f 72 64 20 28 t ((currrecord (
9720: 64 62 3a 74 65 73 74 6d 65 74 61 2d 67 65 74 2d db:testmeta-get-
9730: 72 65 63 6f 72 64 20 64 62 20 74 65 73 74 2d 6e record db test-n
9740: 61 6d 65 29 29 29 0a 20 20 20 20 28 69 66 20 28 ame))). (if (
9750: 6e 6f 74 20 63 75 72 72 72 65 63 6f 72 64 29 0a not currrecord).
9760: 09 28 62 65 67 69 6e 0a 09 20 20 28 73 65 74 21 .(begin.. (set!
9770: 20 63 75 72 72 72 65 63 6f 72 64 20 28 6d 61 6b currrecord (mak
9780: 65 2d 76 65 63 74 6f 72 20 31 30 20 23 66 29 29 e-vector 10 #f))
9790: 0a 09 20 20 28 64 62 3a 74 65 73 74 6d 65 74 61 .. (db:testmeta
97a0: 2d 61 64 64 2d 72 65 63 6f 72 64 20 64 62 20 74 -add-record db t
97b0: 65 73 74 2d 6e 61 6d 65 29 29 29 0a 20 20 20 20 est-name))).
97c0: 28 66 6f 72 2d 65 61 63 68 20 0a 20 20 20 20 20 (for-each .
97d0: 28 6c 61 6d 62 64 61 20 28 6b 65 79 29 0a 20 20 (lambda (key).
97e0: 20 20 20 20 20 28 6c 65 74 2a 20 28 28 69 64 78 (let* ((idx
97f0: 20 28 63 61 64 72 20 6b 65 79 29 29 0a 09 20 20 (cadr key))..
9800: 20 20 20 20 28 66 6c 64 20 28 63 61 72 20 20 6b (fld (car k
9810: 65 79 29 29 0a 09 20 20 20 20 20 20 28 76 61 6c ey)).. (val
9820: 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 (config-lookup
9830: 74 65 73 74 2d 63 6f 6e 66 20 22 74 65 73 74 5f test-conf "test_
9840: 6d 65 74 61 22 20 66 6c 64 29 29 29 0a 09 20 28 meta" fld))).. (
9850: 69 66 20 28 61 6e 64 20 76 61 6c 20 28 6e 6f 74 if (and val (not
9860: 20 28 65 71 75 61 6c 3f 20 28 76 65 63 74 6f 72 (equal? (vector
9870: 2d 72 65 66 20 63 75 72 72 72 65 63 6f 72 64 20 -ref currrecord
9880: 69 64 78 29 20 76 61 6c 29 29 29 0a 09 20 20 20 idx) val)))..
9890: 20 20 28 62 65 67 69 6e 0a 09 20 20 20 20 20 20 (begin..
98a0: 20 28 70 72 69 6e 74 20 22 55 70 64 61 74 69 6e (print "Updatin
98b0: 67 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 g " test-name "
98c0: 22 20 66 6c 64 20 22 20 74 6f 20 22 20 76 61 6c " fld " to " val
98d0: 29 0a 09 20 20 20 20 20 20 20 28 64 62 3a 74 65 ).. (db:te
98e0: 73 74 6d 65 74 61 2d 75 70 64 61 74 65 2d 66 69 stmeta-update-fi
98f0: 65 6c 64 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 eld db test-name
9900: 20 66 6c 64 20 76 61 6c 29 29 29 29 29 0a 20 20 fld val))))).
9910: 20 20 20 27 28 28 22 61 75 74 68 6f 72 22 20 32 '(("author" 2
9920: 29 28 22 6f 77 6e 65 72 22 20 33 29 28 22 64 65 )("owner" 3)("de
9930: 73 63 72 69 70 74 69 6f 6e 22 20 34 29 28 22 72 scription" 4)("r
9940: 65 76 69 65 77 65 64 22 20 35 29 28 22 74 61 67 eviewed" 5)("tag
9950: 73 22 20 39 29 29 29 29 29 0a 0a 3b 3b 20 55 70 s" 9)))))..;; Up
9960: 64 61 74 65 20 74 65 73 74 5f 6d 65 74 61 20 66 date test_meta f
9970: 6f 72 20 61 6c 6c 20 74 65 73 74 73 0a 28 64 65 or all tests.(de
9980: 66 69 6e 65 20 28 72 75 6e 73 3a 75 70 64 61 74 fine (runs:updat
9990: 65 2d 61 6c 6c 2d 74 65 73 74 5f 6d 65 74 61 20 e-all-test_meta
99a0: 64 62 29 0a 20 20 28 6c 65 74 20 28 28 74 65 73 db). (let ((tes
99b0: 74 2d 6e 61 6d 65 73 20 28 67 65 74 2d 61 6c 6c t-names (get-all
99c0: 2d 6c 65 67 61 6c 2d 74 65 73 74 73 29 29 29 0a -legal-tests))).
99d0: 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 (for-each .
99e0: 20 20 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73 (lambda (tes
99f0: 74 2d 6e 61 6d 65 29 0a 20 20 20 20 20 20 20 28 t-name). (
9a00: 6c 65 74 2a 20 28 28 74 65 73 74 2d 70 61 74 68 let* ((test-path
9a10: 20 20 20 20 28 63 6f 6e 63 20 2a 74 6f 70 70 61 (conc *toppa
9a20: 74 68 2a 20 22 2f 74 65 73 74 73 2f 22 20 74 65 th* "/tests/" te
9a30: 73 74 2d 6e 61 6d 65 29 29 0a 09 20 20 20 20 20 st-name))..
9a40: 20 28 74 65 73 74 2d 63 6f 6e 66 69 67 66 20 28 (test-configf (
9a50: 63 6f 6e 63 20 74 65 73 74 2d 70 61 74 68 20 22 conc test-path "
9a60: 2f 74 65 73 74 63 6f 6e 66 69 67 22 29 29 0a 09 /testconfig"))..
9a70: 20 20 20 20 20 20 28 74 65 73 74 65 78 69 73 74 (testexist
9a80: 73 20 20 20 28 61 6e 64 20 28 66 69 6c 65 2d 65 s (and (file-e
9a90: 78 69 73 74 73 3f 20 74 65 73 74 2d 63 6f 6e 66 xists? test-conf
9aa0: 69 67 66 29 28 66 69 6c 65 2d 72 65 61 64 2d 61 igf)(file-read-a
9ab0: 63 63 65 73 73 3f 20 74 65 73 74 2d 63 6f 6e 66 ccess? test-conf
9ac0: 69 67 66 29 29 29 0a 09 20 20 20 20 20 20 3b 3b igf))).. ;;
9ad0: 20 72 65 61 64 20 63 6f 6e 66 69 67 73 20 77 69 read configs wi
9ae0: 74 68 20 74 72 69 63 6b 73 20 74 75 72 6e 65 64 th tricks turned
9af0: 20 6f 66 66 20 28 69 2e 65 2e 20 6e 6f 20 73 79 off (i.e. no sy
9b00: 73 74 65 6d 29 0a 09 20 20 20 20 20 20 28 74 65 stem).. (te
9b10: 73 74 2d 63 6f 6e 66 20 20 20 20 28 69 66 20 74 st-conf (if t
9b20: 65 73 74 65 78 69 73 74 73 20 28 72 65 61 64 2d estexists (read-
9b30: 63 6f 6e 66 69 67 20 74 65 73 74 2d 63 6f 6e 66 config test-conf
9b40: 69 67 66 20 23 66 20 23 66 29 28 6d 61 6b 65 2d igf #f #f)(make-
9b50: 68 61 73 68 2d 74 61 62 6c 65 29 29 29 29 0a 09 hash-table))))..
9b60: 20 28 72 75 6e 73 3a 75 70 64 61 74 65 2d 74 65 (runs:update-te
9b70: 73 74 5f 6d 65 74 61 20 64 62 20 74 65 73 74 2d st_meta db test-
9b80: 6e 61 6d 65 20 74 65 73 74 2d 63 6f 6e 66 29 29 name test-conf))
9b90: 29 0a 20 20 20 20 20 74 65 73 74 2d 6e 61 6d 65 ). test-name
9ba0: 73 29 29 29 0a 09 20 0a 3b 3b 20 54 68 69 73 20 s))).. .;; This
9bb0: 63 6f 75 6c 64 20 70 72 6f 62 61 62 6c 79 20 62 could probably b
9bc0: 65 20 72 65 66 61 63 74 6f 72 65 64 20 69 6e 74 e refactored int
9bd0: 6f 20 6f 6e 65 20 63 6f 6d 70 6c 65 78 20 71 75 o one complex qu
9be0: 65 72 79 20 2e 2e 2e 0a 28 64 65 66 69 6e 65 20 ery ....(define
9bf0: 28 72 75 6e 73 3a 72 6f 6c 6c 75 70 2d 72 75 6e (runs:rollup-run
9c00: 20 64 62 20 6b 65 79 73 29 0a 20 20 28 6c 65 74 db keys). (let
9c10: 2a 20 28 28 6e 65 77 2d 72 75 6e 2d 69 64 20 20 * ((new-run-id
9c20: 20 20 20 20 28 72 65 67 69 73 74 65 72 2d 72 75 (register-ru
9c30: 6e 20 64 62 20 6b 65 79 73 29 29 0a 09 20 28 70 n db keys)).. (p
9c40: 72 65 76 2d 74 65 73 74 73 20 20 20 20 20 20 28 rev-tests (
9c50: 74 65 73 74 3a 67 65 74 2d 6d 61 74 63 68 69 6e test:get-matchin
9c60: 67 2d 70 72 65 76 69 6f 75 73 2d 74 65 73 74 2d g-previous-test-
9c70: 72 75 6e 2d 72 65 63 6f 72 64 73 20 64 62 20 6e run-records db n
9c80: 65 77 2d 72 75 6e 2d 69 64 20 22 25 22 20 22 25 ew-run-id "%" "%
9c90: 22 29 29 0a 09 20 28 63 75 72 72 2d 74 65 73 74 ")).. (curr-test
9ca0: 73 20 20 20 20 20 20 28 64 62 2d 67 65 74 2d 74 s (db-get-t
9cb0: 65 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 ests-for-run db
9cc0: 6e 65 77 2d 72 75 6e 2d 69 64 20 22 25 22 20 22 new-run-id "%" "
9cd0: 25 22 29 29 0a 09 20 28 63 75 72 72 2d 74 65 73 %")).. (curr-tes
9ce0: 74 73 2d 68 61 73 68 20 28 6d 61 6b 65 2d 68 61 ts-hash (make-ha
9cf0: 73 68 2d 74 61 62 6c 65 29 29 29 0a 20 20 20 20 sh-table))).
9d00: 3b 3b 20 69 6e 64 65 78 20 74 68 65 20 61 6c 72 ;; index the alr
9d10: 65 61 64 79 20 73 61 76 65 64 20 74 65 73 74 73 eady saved tests
9d20: 20 62 79 20 74 65 73 74 6e 61 6d 65 20 61 6e 64 by testname and
9d30: 20 69 74 65 6d 70 61 74 68 20 69 6e 20 63 75 72 itempath in cur
9d40: 72 2d 74 65 73 74 73 2d 68 61 73 68 0a 20 20 20 r-tests-hash.
9d50: 20 28 66 6f 72 2d 65 61 63 68 0a 20 20 20 20 20 (for-each.
9d60: 28 6c 61 6d 62 64 61 20 28 74 65 73 74 64 61 74 (lambda (testdat
9d70: 29 0a 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28 ). (let* (
9d80: 28 74 65 73 74 6e 61 6d 65 20 20 28 64 62 3a 74 (testname (db:t
9d90: 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 est-get-testname
9da0: 20 74 65 73 74 64 61 74 29 29 0a 09 20 20 20 20 testdat))..
9db0: 20 20 28 69 74 65 6d 2d 70 61 74 68 20 28 64 62 (item-path (db
9dc0: 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 :test-get-item-p
9dd0: 61 74 68 20 74 65 73 74 64 61 74 29 29 0a 09 20 ath testdat))..
9de0: 20 20 20 20 20 28 66 75 6c 6c 2d 6e 61 6d 65 20 (full-name
9df0: 28 63 6f 6e 63 20 74 65 73 74 6e 61 6d 65 20 22 (conc testname "
9e00: 2f 22 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a /" item-path))).
9e10: 09 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 . (hash-table-se
9e20: 74 21 20 63 75 72 72 2d 74 65 73 74 73 2d 68 61 t! curr-tests-ha
9e30: 73 68 20 66 75 6c 6c 2d 6e 61 6d 65 20 74 65 73 sh full-name tes
9e40: 74 64 61 74 29 29 29 0a 20 20 20 20 20 63 75 72 tdat))). cur
9e50: 72 2d 74 65 73 74 73 29 0a 20 20 20 20 3b 3b 20 r-tests). ;;
9e60: 4e 4f 50 45 3a 20 4e 6f 6e 2d 6f 70 74 69 6d 61 NOPE: Non-optima
9e70: 6c 20 61 70 70 72 6f 61 63 68 2e 20 54 72 79 20 l approach. Try
9e80: 74 68 69 73 20 69 6e 73 74 65 61 64 2e 0a 20 20 this instead..
9e90: 20 20 3b 3b 20 20 20 31 2e 20 74 65 73 74 73 20 ;; 1. tests
9ea0: 61 72 65 20 72 65 63 65 69 76 65 64 20 69 6e 20 are received in
9eb0: 61 20 6c 69 73 74 2c 20 6d 6f 73 74 20 72 65 63 a list, most rec
9ec0: 65 6e 74 20 66 69 72 73 74 0a 20 20 20 20 3b 3b ent first. ;;
9ed0: 20 20 20 32 2e 20 72 65 70 6c 61 63 65 20 74 68 2. replace th
9ee0: 65 20 72 6f 6c 6c 75 70 20 74 65 73 74 20 77 69 e rollup test wi
9ef0: 74 68 20 74 68 65 20 6e 65 77 20 2a 61 6c 77 61 th the new *alwa
9f00: 79 73 2a 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 ys*. (for-eac
9f10: 68 20 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 h . (lambda
9f20: 28 74 65 73 74 64 61 74 29 0a 20 20 20 20 20 20 (testdat).
9f30: 20 28 6c 65 74 2a 20 28 28 74 65 73 74 6e 61 6d (let* ((testnam
9f40: 65 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d e (db:test-get-
9f50: 74 65 73 74 6e 61 6d 65 20 74 65 73 74 64 61 74 testname testdat
9f60: 29 29 0a 09 20 20 20 20 20 20 28 69 74 65 6d 2d )).. (item-
9f70: 70 61 74 68 20 28 64 62 3a 74 65 73 74 2d 67 65 path (db:test-ge
9f80: 74 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 t-item-path test
9f90: 64 61 74 29 29 0a 09 20 20 20 20 20 20 28 66 75 dat)).. (fu
9fa0: 6c 6c 2d 6e 61 6d 65 20 28 63 6f 6e 63 20 74 65 ll-name (conc te
9fb0: 73 74 6e 61 6d 65 20 22 2f 22 20 69 74 65 6d 2d stname "/" item-
9fc0: 70 61 74 68 29 29 0a 09 20 20 20 20 20 20 28 70 path)).. (p
9fd0: 72 65 76 2d 74 65 73 74 2d 64 61 74 20 28 68 61 rev-test-dat (ha
9fe0: 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 sh-table-ref/def
9ff0: 61 75 6c 74 20 63 75 72 72 2d 74 65 73 74 73 2d ault curr-tests-
a000: 68 61 73 68 20 66 75 6c 6c 2d 6e 61 6d 65 20 23 hash full-name #
a010: 66 29 29 0a 09 20 20 20 20 20 20 28 74 65 73 74 f)).. (test
a020: 2d 73 74 65 70 73 20 20 20 20 20 20 28 64 62 3a -steps (db:
a030: 67 65 74 2d 73 74 65 70 73 2d 66 6f 72 2d 74 65 get-steps-for-te
a040: 73 74 20 64 62 20 28 64 62 3a 74 65 73 74 2d 67 st db (db:test-g
a050: 65 74 2d 69 64 20 74 65 73 74 64 61 74 29 29 29 et-id testdat)))
a060: 0a 09 20 20 20 20 20 20 28 6e 65 77 2d 74 65 73 .. (new-tes
a070: 74 2d 72 65 63 6f 72 64 20 23 66 29 29 0a 09 20 t-record #f))..
a080: 3b 3b 20 72 65 70 6c 61 63 65 20 74 68 65 73 65 ;; replace these
a090: 20 77 69 74 68 20 69 6e 73 65 72 74 20 2e 2e 2e with insert ...
a0a0: 20 73 65 6c 65 63 74 0a 09 20 28 61 70 70 6c 79 select.. (apply
a0b0: 20 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 sqlite3:execute
a0c0: 20 0a 09 09 64 62 20 0a 09 09 28 63 6f 6e 63 20 ...db ...(conc
a0d0: 22 49 4e 53 45 52 54 20 4f 52 20 52 45 50 4c 41 "INSERT OR REPLA
a0e0: 43 45 20 49 4e 54 4f 20 74 65 73 74 73 20 28 72 CE INTO tests (r
a0f0: 75 6e 5f 69 64 2c 74 65 73 74 6e 61 6d 65 2c 73 un_id,testname,s
a100: 74 61 74 65 2c 73 74 61 74 75 73 2c 65 76 65 6e tate,status,even
a110: 74 5f 74 69 6d 65 2c 68 6f 73 74 2c 63 70 75 6c t_time,host,cpul
a120: 6f 61 64 2c 64 69 73 6b 66 72 65 65 2c 75 6e 61 oad,diskfree,una
a130: 6d 65 2c 72 75 6e 64 69 72 2c 69 74 65 6d 5f 70 me,rundir,item_p
a140: 61 74 68 2c 72 75 6e 5f 64 75 72 61 74 69 6f 6e ath,run_duration
a150: 2c 66 69 6e 61 6c 5f 6c 6f 67 66 2c 63 6f 6d 6d ,final_logf,comm
a160: 65 6e 74 2c 66 69 72 73 74 5f 65 72 72 2c 66 69 ent,first_err,fi
a170: 72 73 74 5f 77 61 72 6e 29 20 22 0a 09 09 20 20 rst_warn) "...
a180: 20 20 20 20 22 56 41 4c 55 45 53 20 28 3f 2c 3f "VALUES (?,?
a190: 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f ,?,?,?,?,?,?,?,?
a1a0: 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 29 3b 22 29 ,?,?,?,?,?,?);")
a1b0: 0a 09 09 6e 65 77 2d 72 75 6e 2d 69 64 20 28 63 ...new-run-id (c
a1c0: 64 64 72 20 28 76 65 63 74 6f 72 2d 3e 6c 69 73 ddr (vector->lis
a1d0: 74 20 74 65 73 74 64 61 74 29 29 29 0a 09 20 28 t testdat))).. (
a1e0: 73 65 74 21 20 6e 65 77 2d 74 65 73 74 64 61 74 set! new-testdat
a1f0: 20 28 63 61 72 20 28 64 62 2d 67 65 74 2d 74 65 (car (db-get-te
a200: 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 6e sts-for-run db n
a210: 65 77 2d 72 75 6e 2d 69 64 20 74 65 73 74 6e 61 ew-run-id testna
a220: 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a me item-path))).
a230: 09 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 . (hash-table-se
a240: 74 21 20 63 75 72 72 2d 74 65 73 74 73 2d 68 61 t! curr-tests-ha
a250: 73 68 20 66 75 6c 6c 2d 6e 61 6d 65 20 6e 65 77 sh full-name new
a260: 2d 74 65 73 74 64 61 74 29 20 3b 3b 20 74 68 69 -testdat) ;; thi
a270: 73 20 63 6f 75 6c 64 20 62 65 20 63 6f 6e 66 75 s could be confu
a280: 73 69 6e 67 2c 20 77 68 69 63 68 20 72 65 63 6f sing, which reco
a290: 72 64 20 73 68 6f 75 6c 64 20 67 6f 20 69 6e 74 rd should go int
a2a0: 6f 20 74 68 65 20 6c 6f 6f 6b 75 70 20 74 61 62 o the lookup tab
a2b0: 6c 65 3f 0a 09 20 3b 3b 20 4e 6f 77 20 64 75 70 le?.. ;; Now dup
a2c0: 6c 69 63 61 74 65 20 74 68 65 20 74 65 73 74 20 licate the test
a2d0: 73 74 65 70 73 0a 09 20 28 64 65 62 75 67 3a 70 steps.. (debug:p
a2e0: 72 69 6e 74 20 34 20 22 43 6f 70 79 69 6e 67 20 rint 4 "Copying
a2f0: 72 65 63 6f 72 64 73 20 69 6e 20 74 65 73 74 5f records in test_
a300: 73 74 65 70 73 20 66 72 6f 6d 20 74 65 73 74 5f steps from test_
a310: 69 64 3d 22 20 28 64 62 3a 74 65 73 74 2d 67 65 id=" (db:test-ge
a320: 74 2d 69 64 20 74 65 73 74 64 61 74 29 20 22 20 t-id testdat) "
a330: 74 6f 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65 to " (db:test-ge
a340: 74 2d 69 64 20 6e 65 77 2d 74 65 73 74 64 61 74 t-id new-testdat
a350: 29 29 0a 09 20 28 73 71 6c 69 74 65 33 3a 65 78 )).. (sqlite3:ex
a360: 65 63 75 74 65 20 0a 09 20 20 64 62 20 0a 09 20 ecute .. db ..
a370: 20 28 63 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f (conc "INSERT O
a380: 52 20 52 45 50 4c 41 43 45 20 49 4e 54 4f 20 74 R REPLACE INTO t
a390: 65 73 74 5f 73 74 65 70 73 20 28 74 65 73 74 5f est_steps (test_
a3a0: 69 64 2c 73 74 65 70 6e 61 6d 65 2c 73 74 61 74 id,stepname,stat
a3b0: 65 2c 73 74 61 74 75 73 2c 65 76 65 6e 74 5f 74 e,status,event_t
a3c0: 69 6d 65 2c 63 6f 6d 6d 65 6e 74 29 20 22 0a 09 ime,comment) "..
a3d0: 09 22 53 45 4c 45 43 54 20 22 20 28 64 62 3a 74 ."SELECT " (db:t
a3e0: 65 73 74 2d 67 65 74 2d 69 64 20 6e 65 77 2d 74 est-get-id new-t
a3f0: 65 73 74 64 61 74 29 20 22 2c 73 74 65 70 6e 61 estdat) ",stepna
a400: 6d 65 2c 73 74 61 74 65 2c 73 74 61 74 75 73 2c me,state,status,
a410: 65 76 65 6e 74 5f 74 69 6d 65 2c 63 6f 6d 6d 65 event_time,comme
a420: 6e 74 20 46 52 4f 4d 20 74 65 73 74 5f 73 74 65 nt FROM test_ste
a430: 70 73 20 57 48 45 52 45 20 74 65 73 74 5f 69 64 ps WHERE test_id
a440: 3d 3f 3b 22 29 0a 09 20 20 28 64 62 3a 74 65 73 =?;").. (db:tes
a450: 74 2d 67 65 74 2d 69 64 20 74 65 73 74 64 61 74 t-get-id testdat
a460: 29 29 0a 09 20 3b 3b 20 4e 6f 77 20 64 75 70 6c )).. ;; Now dupl
a470: 69 63 61 74 65 20 74 68 65 20 74 65 73 74 20 64 icate the test d
a480: 61 74 61 0a 09 20 28 64 65 62 75 67 3a 70 72 69 ata.. (debug:pri
a490: 6e 74 20 34 20 22 43 6f 70 79 69 6e 67 20 72 65 nt 4 "Copying re
a4a0: 63 6f 72 64 73 20 69 6e 20 74 65 73 74 5f 64 61 cords in test_da
a4b0: 74 61 20 66 72 6f 6d 20 74 65 73 74 5f 69 64 3d ta from test_id=
a4c0: 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 " (db:test-get-i
a4d0: 64 20 74 65 73 74 64 61 74 29 20 22 20 74 6f 20 d testdat) " to
a4e0: 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 " (db:test-get-i
a4f0: 64 20 6e 65 77 2d 74 65 73 74 64 61 74 29 29 0a d new-testdat)).
a500: 09 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75 . (sqlite3:execu
a510: 74 65 20 0a 09 20 20 64 62 20 0a 09 20 20 28 63 te .. db .. (c
a520: 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f 52 20 52 onc "INSERT OR R
a530: 45 50 4c 41 43 45 20 49 4e 54 4f 20 74 65 73 74 EPLACE INTO test
a540: 5f 64 61 74 61 20 28 74 65 73 74 5f 69 64 2c 63 _data (test_id,c
a550: 61 74 65 67 6f 72 79 2c 76 61 72 69 61 62 6c 65 ategory,variable
a560: 2c 76 61 6c 75 65 2c 65 78 70 65 63 74 65 64 2c ,value,expected,
a570: 74 6f 6c 2c 75 6e 69 74 73 2c 63 6f 6d 6d 65 6e tol,units,commen
a580: 74 29 20 22 0a 09 09 22 53 45 4c 45 43 54 20 22 t) "..."SELECT "
a590: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 (db:test-get-id
a5a0: 20 6e 65 77 2d 74 65 73 74 64 61 74 29 20 22 2c new-testdat) ",
a5b0: 63 61 74 65 67 6f 72 79 2c 76 61 72 69 61 62 6c category,variabl
a5c0: 65 2c 76 61 6c 75 65 2c 65 78 70 65 63 74 65 64 e,value,expected
a5d0: 2c 74 6f 6c 2c 75 6e 69 74 73 2c 63 6f 6d 6d 65 ,tol,units,comme
a5e0: 6e 74 20 46 52 4f 4d 20 74 65 73 74 5f 64 61 74 nt FROM test_dat
a5f0: 61 20 57 48 45 52 45 20 74 65 73 74 5f 69 64 3d a WHERE test_id=
a600: 3f 3b 22 29 0a 09 20 20 28 64 62 3a 74 65 73 74 ?;").. (db:test
a610: 2d 67 65 74 2d 69 64 20 74 65 73 74 64 61 74 29 -get-id testdat)
a620: 29 0a 09 20 29 29 0a 20 20 20 20 20 70 72 65 76 ).. )). prev
a630: 2d 74 65 73 74 73 29 29 29 0a 09 20 0a 20 20 20 -tests))).. .
a640: 20 20 0a .