Megatest

Hex Artifact Content
Login

Artifact 94662cef73c8e0e0bcdd12bd0594e5d54d4b4a84:


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 29 0a 20  nits"    ""))). 
27d0: 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e       (debug:prin
27e0: 74 20 34 20 0a 09 09 20 20 20 22 63 61 74 65 67  t 4 ...   "categ
27f0: 6f 72 79 3a 20 22 20 63 61 74 65 67 6f 72 79 20  ory: " category 
2800: 22 2c 20 76 61 72 69 61 62 6c 65 3a 20 22 20 76  ", variable: " v
2810: 61 72 69 61 62 6c 65 20 22 2c 20 76 61 6c 75 65  ariable ", value
2820: 3a 20 22 20 76 61 6c 75 65 0a 09 09 20 20 20 22  : " value...   "
2830: 2c 20 65 78 70 65 63 74 65 64 3a 20 22 20 65 78  , expected: " ex
2840: 70 65 63 74 65 64 20 22 2c 20 74 6f 6c 3a 20 22  pected ", tol: "
2850: 20 74 6f 6c 20 22 2c 20 75 6e 69 74 73 3a 20 22   tol ", units: "
2860: 20 75 6e 69 74 73 29 0a 20 20 20 20 20 20 28 69   units).      (i
2870: 66 20 28 61 6e 64 20 76 61 6c 75 65 20 65 78 70  f (and value exp
2880: 65 63 74 65 64 20 74 6f 6c 29 20 3b 3b 20 61 6c  ected tol) ;; al
2890: 6c 20 74 68 72 65 65 20 72 65 71 75 69 72 65 64  l three required
28a0: 0a 09 20 20 28 64 62 3a 63 73 76 2d 3e 74 65 73  ..  (db:csv->tes
28b0: 74 2d 64 61 74 61 20 64 62 20 74 65 73 74 2d 69  t-data db test-i
28c0: 64 20 0a 09 09 09 20 20 20 20 20 28 63 6f 6e 63  d ....     (conc
28d0: 20 63 61 74 65 67 6f 72 79 20 22 2c 22 0a 09 09   category ","...
28e0: 09 09 20 20 20 76 61 72 69 61 62 6c 65 20 22 2c  ..   variable ",
28f0: 22 0a 09 09 09 09 20 20 20 76 61 6c 75 65 20 20  ".....   value  
2900: 20 20 22 2c 22 0a 09 09 09 09 20 20 20 65 78 70    ",".....   exp
2910: 65 63 74 65 64 20 22 2c 22 0a 09 09 09 09 20 20  ected ",".....  
2920: 20 74 6f 6c 20 20 20 20 20 20 22 2c 22 0a 09 09   tol      ","...
2930: 09 09 20 20 20 75 6e 69 74 73 20 20 20 20 22 2c  ..   units    ",
2940: 22 0a 09 09 09 09 20 20 20 63 6f 6d 6d 65 6e 74  ".....   comment
2950: 20 20 22 2c 22 29 29 29 29 0a 09 09 09 09 20 20    ",")))).....  
2960: 20 0a 20 20 20 20 3b 3b 20 6e 65 65 64 20 74 6f   .    ;; need to
2970: 20 75 70 64 61 74 65 20 74 68 65 20 74 6f 70 20   update the top 
2980: 74 65 73 74 20 72 65 63 6f 72 64 20 69 66 20 50  test record if P
2990: 41 53 53 20 6f 72 20 46 41 49 4c 20 61 6e 64 20  ASS or FAIL and 
29a0: 74 68 69 73 20 69 73 20 61 20 73 75 62 74 65 73  this is a subtes
29b0: 74 0a 20 20 20 20 28 69 66 20 28 61 6e 64 20 28  t.    (if (and (
29c0: 6e 6f 74 20 28 65 71 75 61 6c 3f 20 69 74 65 6d  not (equal? item
29d0: 2d 70 61 74 68 20 22 22 29 29 0a 09 20 20 20 20  -path ""))..    
29e0: 20 28 6f 72 20 28 65 71 75 61 6c 3f 20 73 74 61   (or (equal? sta
29f0: 74 75 73 20 22 50 41 53 53 22 29 0a 09 09 20 28  tus "PASS")... (
2a00: 65 71 75 61 6c 3f 20 73 74 61 74 75 73 20 22 57  equal? status "W
2a10: 41 52 4e 22 29 0a 09 09 20 28 65 71 75 61 6c 3f  ARN")... (equal?
2a20: 20 73 74 61 74 75 73 20 22 46 41 49 4c 22 29 0a   status "FAIL").
2a30: 09 09 20 28 65 71 75 61 6c 3f 20 73 74 61 74 75  .. (equal? statu
2a40: 73 20 22 57 41 49 56 45 44 22 29 0a 09 09 20 28  s "WAIVED")... (
2a50: 65 71 75 61 6c 3f 20 73 74 61 74 75 73 20 22 52  equal? status "R
2a60: 55 4e 4e 49 4e 47 22 29 29 29 0a 09 28 62 65 67  UNNING")))..(beg
2a70: 69 6e 0a 09 20 20 28 73 71 6c 69 74 65 33 3a 65  in..  (sqlite3:e
2a80: 78 65 63 75 74 65 20 0a 09 20 20 20 64 62 0a 09  xecute ..   db..
2a90: 20 20 20 22 55 50 44 41 54 45 20 74 65 73 74 73     "UPDATE tests
2aa0: 20 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 53   .             S
2ab0: 45 54 20 66 61 69 6c 5f 63 6f 75 6e 74 3d 28 53  ET fail_count=(S
2ac0: 45 4c 45 43 54 20 63 6f 75 6e 74 28 69 64 29 20  ELECT count(id) 
2ad0: 46 52 4f 4d 20 74 65 73 74 73 20 57 48 45 52 45  FROM tests WHERE
2ae0: 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65   run_id=? AND te
2af0: 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65  stname=? AND ite
2b00: 6d 5f 70 61 74 68 20 21 3d 20 27 27 20 41 4e 44  m_path != '' AND
2b10: 20 73 74 61 74 75 73 3d 27 46 41 49 4c 27 29 2c   status='FAIL'),
2b20: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
2b30: 20 20 70 61 73 73 5f 63 6f 75 6e 74 3d 28 53 45    pass_count=(SE
2b40: 4c 45 43 54 20 63 6f 75 6e 74 28 69 64 29 20 46  LECT count(id) F
2b50: 52 4f 4d 20 74 65 73 74 73 20 57 48 45 52 45 20  ROM tests WHERE 
2b60: 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73  run_id=? AND tes
2b70: 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d  tname=? AND item
2b80: 5f 70 61 74 68 20 21 3d 20 27 27 20 41 4e 44 20  _path != '' AND 
2b90: 28 73 74 61 74 75 73 3d 27 50 41 53 53 27 20 4f  (status='PASS' O
2ba0: 52 20 73 74 61 74 75 73 3d 27 57 41 52 4e 27 20  R status='WARN' 
2bb0: 4f 52 20 73 74 61 74 75 73 3d 27 57 41 49 56 45  OR status='WAIVE
2bc0: 44 27 29 29 0a 20 20 20 20 20 20 20 20 20 20 20  D')).           
2bd0: 20 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f    WHERE run_id=?
2be0: 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20   AND testname=? 
2bf0: 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 27 27  AND item_path=''
2c00: 3b 22 0a 09 20 20 20 72 75 6e 2d 69 64 20 74 65  ;"..   run-id te
2c10: 73 74 2d 6e 61 6d 65 20 72 75 6e 2d 69 64 20 74  st-name run-id t
2c20: 65 73 74 2d 6e 61 6d 65 20 72 75 6e 2d 69 64 20  est-name run-id 
2c30: 74 65 73 74 2d 6e 61 6d 65 29 0a 09 20 20 28 69  test-name)..  (i
2c40: 66 20 28 65 71 75 61 6c 3f 20 73 74 61 74 75 73  f (equal? status
2c50: 20 22 52 55 4e 4e 49 4e 47 22 29 20 3b 3b 20 72   "RUNNING") ;; r
2c60: 75 6e 6e 69 6e 67 20 74 61 6b 65 73 20 70 72 69  unning takes pri
2c70: 6f 72 69 74 79 20 6f 76 65 72 20 61 6c 6c 20 6f  ority over all o
2c80: 74 68 65 72 20 73 74 61 74 65 73 2c 20 66 6f 72  ther states, for
2c90: 63 65 20 74 68 65 20 74 65 73 74 20 73 74 61 74  ce the test stat
2ca0: 65 20 74 6f 20 52 55 4e 4e 49 4e 47 0a 09 20 20  e to RUNNING..  
2cb0: 20 20 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65      (sqlite3:exe
2cc0: 63 75 74 65 20 64 62 20 22 55 50 44 41 54 45 20  cute db "UPDATE 
2cd0: 74 65 73 74 73 20 53 45 54 20 73 74 61 74 65 3d  tests SET state=
2ce0: 3f 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f  ? WHERE run_id=?
2cf0: 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20   AND testname=? 
2d00: 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 27 27  AND item_path=''
2d10: 3b 22 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e  ;" run-id test-n
2d20: 61 6d 65 29 0a 09 20 20 20 20 20 20 28 73 71 6c  ame)..      (sql
2d30: 69 74 65 33 3a 65 78 65 63 75 74 65 0a 09 20 20  ite3:execute..  
2d40: 20 20 20 20 20 64 62 0a 09 20 20 20 20 20 20 20       db..       
2d50: 22 55 50 44 41 54 45 20 74 65 73 74 73 0a 20 20  "UPDATE tests.  
2d60: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2d70: 20 20 20 20 20 53 45 54 20 73 74 61 74 65 3d 43       SET state=C
2d80: 41 53 45 20 57 48 45 4e 20 28 53 45 4c 45 43 54  ASE WHEN (SELECT
2d90: 20 63 6f 75 6e 74 28 69 64 29 20 46 52 4f 4d 20   count(id) FROM 
2da0: 74 65 73 74 73 20 57 48 45 52 45 20 72 75 6e 5f  tests WHERE run_
2db0: 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d  id=? AND testnam
2dc0: 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74  e=? AND item_pat
2dd0: 68 20 21 3d 20 27 27 20 41 4e 44 20 73 74 61 74  h != '' AND stat
2de0: 65 20 69 6e 20 28 27 52 55 4e 4e 49 4e 47 27 2c  e in ('RUNNING',
2df0: 27 4e 4f 54 5f 53 54 41 52 54 45 44 27 29 29 20  'NOT_STARTED')) 
2e00: 3e 20 30 20 54 48 45 4e 20 0a 20 20 20 20 20 20  > 0 THEN .      
2e10: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2e20: 20 20 20 20 27 52 55 4e 4e 49 4e 47 27 0a 20 20      'RUNNING'.  
2e30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2e40: 20 20 20 20 20 45 4c 53 45 20 27 43 4f 4d 50 4c       ELSE 'COMPL
2e50: 45 54 45 44 27 20 45 4e 44 2c 0a 20 20 20 20 20  ETED' END,.     
2e60: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2e70: 20 20 20 20 20 73 74 61 74 75 73 3d 43 41 53 45       status=CASE
2e80: 20 57 48 45 4e 20 66 61 69 6c 5f 63 6f 75 6e 74   WHEN fail_count
2e90: 20 3e 20 30 20 54 48 45 4e 20 27 46 41 49 4c 27   > 0 THEN 'FAIL'
2ea0: 20 57 48 45 4e 20 70 61 73 73 5f 63 6f 75 6e 74   WHEN pass_count
2eb0: 20 3e 20 30 20 41 4e 44 20 66 61 69 6c 5f 63 6f   > 0 AND fail_co
2ec0: 75 6e 74 3d 30 20 54 48 45 4e 20 27 50 41 53 53  unt=0 THEN 'PASS
2ed0: 27 20 45 4c 53 45 20 27 55 4e 4b 4e 4f 57 4e 27  ' ELSE 'UNKNOWN'
2ee0: 20 45 4e 44 0a 20 20 20 20 20 20 20 20 20 20 20   END.           
2ef0: 20 20 20 20 20 20 20 20 20 20 20 20 57 48 45 52              WHER
2f00: 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74  E run_id=? AND t
2f10: 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74  estname=? AND it
2f20: 65 6d 5f 70 61 74 68 3d 27 27 3b 22 0a 09 20 20  em_path='';"..  
2f30: 20 20 20 20 20 72 75 6e 2d 69 64 20 74 65 73 74       run-id test
2f40: 2d 6e 61 6d 65 20 72 75 6e 2d 69 64 20 74 65 73  -name run-id tes
2f50: 74 2d 6e 61 6d 65 29 29 29 29 0a 20 20 20 20 28  t-name)))).    (
2f60: 69 66 20 28 6f 72 20 28 61 6e 64 20 28 73 74 72  if (or (and (str
2f70: 69 6e 67 3f 20 63 6f 6d 6d 65 6e 74 29 0a 09 09  ing? comment)...
2f80: 20 28 73 74 72 69 6e 67 2d 6d 61 74 63 68 20 28   (string-match (
2f90: 72 65 67 65 78 70 20 22 5c 5c 53 2b 22 29 20 63  regexp "\\S+") c
2fa0: 6f 6d 6d 65 6e 74 29 29 0a 09 20 20 20 20 77 61  omment))..    wa
2fb0: 69 76 65 64 29 0a 09 28 73 71 6c 69 74 65 33 3a  ived)..(sqlite3:
2fc0: 65 78 65 63 75 74 65 20 64 62 20 22 55 50 44 41  execute db "UPDA
2fd0: 54 45 20 74 65 73 74 73 20 53 45 54 20 63 6f 6d  TE tests SET com
2fe0: 6d 65 6e 74 3d 3f 20 57 48 45 52 45 20 72 75 6e  ment=? WHERE run
2ff0: 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61  _id=? AND testna
3000: 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61  me=? AND item_pa
3010: 74 68 3d 3f 3b 22 0a 09 09 09 20 28 69 66 20 77  th=?;".... (if w
3020: 61 69 76 65 64 20 77 61 69 76 65 64 20 63 6f 6d  aived waived com
3030: 6d 65 6e 74 29 20 72 75 6e 2d 69 64 20 74 65 73  ment) run-id tes
3040: 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68  t-name item-path
3050: 29 29 0a 20 20 20 20 29 29 0a 0a 28 64 65 66 69  )).    ))..(defi
3060: 6e 65 20 28 74 65 73 74 2d 73 65 74 2d 6c 6f 67  ne (test-set-log
3070: 21 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  ! db run-id test
3080: 2d 6e 61 6d 65 20 69 74 65 6d 64 61 74 20 6c 6f  -name itemdat lo
3090: 67 66 29 20 0a 20 20 28 6c 65 74 20 28 28 69 74  gf) .  (let ((it
30a0: 65 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c 69  em-path (item-li
30b0: 73 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74  st->path itemdat
30c0: 29 29 29 0a 20 20 20 20 28 73 71 6c 69 74 65 33  ))).    (sqlite3
30d0: 3a 65 78 65 63 75 74 65 20 64 62 20 22 55 50 44  :execute db "UPD
30e0: 41 54 45 20 74 65 73 74 73 20 53 45 54 20 66 69  ATE tests SET fi
30f0: 6e 61 6c 5f 6c 6f 67 66 3d 3f 20 57 48 45 52 45  nal_logf=? WHERE
3100: 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65   run_id=? AND te
3110: 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65  stname=? AND ite
3120: 6d 5f 70 61 74 68 3d 3f 3b 22 20 0a 09 09 20 20  m_path=?;" ...  
3130: 20 20 20 6c 6f 67 66 20 72 75 6e 2d 69 64 20 74     logf run-id t
3140: 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61  est-name item-pa
3150: 74 68 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28  th)))..(define (
3160: 74 65 73 74 2d 73 65 74 2d 74 6f 70 6c 6f 67 21  test-set-toplog!
3170: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d   db run-id test-
3180: 6e 61 6d 65 20 6c 6f 67 66 29 20 0a 20 20 28 73  name logf) .  (s
3190: 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 64  qlite3:execute d
31a0: 62 20 22 55 50 44 41 54 45 20 74 65 73 74 73 20  b "UPDATE tests 
31b0: 53 45 54 20 66 69 6e 61 6c 5f 6c 6f 67 66 3d 3f  SET final_logf=?
31c0: 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20   WHERE run_id=? 
31d0: 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41  AND testname=? A
31e0: 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 27 27 3b  ND item_path='';
31f0: 22 20 0a 09 09 20 20 20 6c 6f 67 66 20 72 75 6e  " ...   logf run
3200: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 29 29 0a  -id test-name)).
3210: 0a 28 64 65 66 69 6e 65 20 28 74 65 73 74 73 3a  .(define (tests:
3220: 73 75 6d 6d 61 72 69 7a 65 2d 69 74 65 6d 73 20  summarize-items 
3230: 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e  db run-id test-n
3240: 61 6d 65 20 66 6f 72 63 65 29 0a 20 20 3b 3b 20  ame force).  ;; 
3250: 69 66 20 6e 6f 74 20 66 6f 72 63 65 20 74 68 65  if not force the
3260: 6e 20 6f 6e 6c 79 20 75 70 64 61 74 65 20 74 68  n only update th
3270: 65 20 72 65 63 6f 72 64 20 69 66 20 6f 6e 65 20  e record if one 
3280: 6f 66 20 74 68 65 73 65 20 69 73 20 74 72 75 65  of these is true
3290: 3a 0a 20 20 3b 3b 20 20 20 31 2e 20 6c 6f 67 66  :.  ;;   1. logf
32a0: 20 69 73 20 22 6c 6f 67 2f 66 69 6e 61 6c 2e 6c   is "log/final.l
32b0: 6f 67 0a 20 20 3b 3b 20 20 20 32 2e 20 6c 6f 67  og.  ;;   2. log
32c0: 66 20 69 73 20 73 61 6d 65 20 61 73 20 6f 75 74  f is same as out
32d0: 70 75 74 66 69 6c 65 6e 61 6d 65 0a 20 20 28 6c  putfilename.  (l
32e0: 65 74 20 28 28 6f 75 74 70 75 74 66 69 6c 65 6e  et ((outputfilen
32f0: 61 6d 65 20 28 63 6f 6e 63 20 22 6d 65 67 61 74  ame (conc "megat
3300: 65 73 74 2d 72 6f 6c 6c 75 70 2d 22 20 74 65 73  est-rollup-" tes
3310: 74 2d 6e 61 6d 65 20 22 2e 68 74 6d 6c 22 29 29  t-name ".html"))
3320: 0a 09 28 6f 72 69 67 2d 64 69 72 20 20 20 20 20  ..(orig-dir     
3330: 20 20 28 63 75 72 72 65 6e 74 2d 64 69 72 65 63    (current-direc
3340: 74 6f 72 79 29 29 0a 09 28 6c 6f 67 66 20 20 20  tory))..(logf   
3350: 20 20 20 20 20 20 20 20 23 66 29 29 0a 20 20 20          #f)).   
3360: 20 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61   (sqlite3:for-ea
3370: 63 68 2d 72 6f 77 20 0a 20 20 20 20 20 28 6c 61  ch-row .     (la
3380: 6d 62 64 61 20 28 70 61 74 68 20 66 69 6e 61 6c  mbda (path final
3390: 5f 6c 6f 67 66 29 0a 20 20 20 20 20 20 20 28 73  _logf).       (s
33a0: 65 74 21 20 6c 6f 67 66 20 66 69 6e 61 6c 5f 6c  et! logf final_l
33b0: 6f 67 66 29 0a 20 20 20 20 20 20 20 28 69 66 20  ogf).       (if 
33c0: 28 64 69 72 65 63 74 6f 72 79 3f 20 70 61 74 68  (directory? path
33d0: 29 0a 09 20 20 20 28 62 65 67 69 6e 0a 09 20 20  )..   (begin..  
33e0: 20 20 20 28 70 72 69 6e 74 20 22 46 6f 75 6e 64     (print "Found
33f0: 20 70 61 74 68 3a 20 22 20 70 61 74 68 29 0a 09   path: " path)..
3400: 20 20 20 20 20 28 63 68 61 6e 67 65 2d 64 69 72       (change-dir
3410: 65 63 74 6f 72 79 20 70 61 74 68 29 29 0a 09 20  ectory path)).. 
3420: 20 20 20 20 3b 3b 20 28 73 65 74 21 20 6f 75 74      ;; (set! out
3430: 70 75 74 66 69 6c 65 6e 61 6d 65 20 28 63 6f 6e  putfilename (con
3440: 63 20 70 61 74 68 20 22 2f 22 20 6f 75 74 70 75  c path "/" outpu
3450: 74 66 69 6c 65 6e 61 6d 65 29 29 29 0a 09 20 20  tfilename)))..  
3460: 20 28 70 72 69 6e 74 20 22 4e 6f 20 73 75 63 68   (print "No such
3470: 20 70 61 74 68 3a 20 22 20 70 61 74 68 29 29 29   path: " path)))
3480: 0a 20 20 20 20 20 64 62 20 0a 20 20 20 20 20 22  .     db .     "
3490: 53 45 4c 45 43 54 20 72 75 6e 64 69 72 2c 66 69  SELECT rundir,fi
34a0: 6e 61 6c 5f 6c 6f 67 66 20 46 52 4f 4d 20 74 65  nal_logf FROM te
34b0: 73 74 73 20 57 48 45 52 45 20 72 75 6e 5f 69 64  sts WHERE run_id
34c0: 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d  =? AND testname=
34d0: 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d  ? AND item_path=
34e0: 27 27 3b 22 0a 20 20 20 20 20 72 75 6e 2d 69 64  '';".     run-id
34f0: 20 74 65 73 74 2d 6e 61 6d 65 29 0a 20 20 20 20   test-name).    
3500: 28 70 72 69 6e 74 20 22 73 75 6d 6d 61 72 69 7a  (print "summariz
3510: 65 2d 69 74 65 6d 73 20 77 69 74 68 20 6c 6f 67  e-items with log
3520: 66 20 22 20 6c 6f 67 66 29 0a 20 20 20 20 28 69  f " logf).    (i
3530: 66 20 28 6f 72 20 28 65 71 75 61 6c 3f 20 6c 6f  f (or (equal? lo
3540: 67 66 20 22 6c 6f 67 73 2f 66 69 6e 61 6c 2e 6c  gf "logs/final.l
3550: 6f 67 22 29 0a 09 20 20 20 20 28 65 71 75 61 6c  og")..    (equal
3560: 3f 20 6c 6f 67 66 20 6f 75 74 70 75 74 66 69 6c  ? logf outputfil
3570: 65 6e 61 6d 65 29 0a 09 20 20 20 20 66 6f 72 63  ename)..    forc
3580: 65 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 28 69  e)..(begin..  (i
3590: 66 20 28 6f 62 74 61 69 6e 2d 64 6f 74 2d 6c 6f  f (obtain-dot-lo
35a0: 63 6b 20 6f 75 74 70 75 74 66 69 6c 65 6e 61 6d  ck outputfilenam
35b0: 65 20 31 20 32 30 20 33 30 29 20 3b 3b 20 72 65  e 1 20 30) ;; re
35c0: 74 72 79 20 65 76 65 72 79 20 73 65 63 6f 6e 64  try every second
35d0: 20 66 6f 72 20 32 30 20 73 65 63 6f 6e 64 73 2c   for 20 seconds,
35e0: 20 63 61 6c 6c 20 69 74 20 64 65 61 64 20 61 66   call it dead af
35f0: 74 65 72 20 33 30 20 73 65 63 6f 6e 64 73 20 61  ter 30 seconds a
3600: 6e 64 20 73 74 65 61 6c 20 74 68 65 20 6c 6f 63  nd steal the loc
3610: 6b 0a 09 20 20 20 20 20 20 28 70 72 69 6e 74 20  k..      (print 
3620: 22 4f 62 74 61 69 6e 65 64 20 6c 6f 63 6b 20 66  "Obtained lock f
3630: 6f 72 20 22 20 6f 75 74 70 75 74 66 69 6c 65 6e  or " outputfilen
3640: 61 6d 65 29 0a 09 20 20 20 20 20 20 28 70 72 69  ame)..      (pri
3650: 6e 74 20 22 46 61 69 6c 65 64 20 74 6f 20 6f 62  nt "Failed to ob
3660: 74 61 69 6e 20 6c 6f 63 6b 20 66 6f 72 20 22 20  tain lock for " 
3670: 6f 75 74 70 75 74 66 69 6c 65 6e 61 6d 65 29 29  outputfilename))
3680: 0a 09 20 20 28 6c 65 74 20 28 28 6f 75 70 20 20  ..  (let ((oup  
3690: 20 20 28 6f 70 65 6e 2d 6f 75 74 70 75 74 2d 66    (open-output-f
36a0: 69 6c 65 20 6f 75 74 70 75 74 66 69 6c 65 6e 61  ile outputfilena
36b0: 6d 65 29 29 0a 09 09 28 63 6f 75 6e 74 73 20 28  me))...(counts (
36c0: 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 29  make-hash-table)
36d0: 29 0a 09 09 28 73 74 61 74 65 63 6f 75 6e 74 73  )...(statecounts
36e0: 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c   (make-hash-tabl
36f0: 65 29 29 0a 09 09 28 6f 75 74 74 78 74 20 22 22  e))...(outtxt ""
3700: 29 0a 09 09 28 74 6f 74 20 20 20 20 30 29 29 0a  )...(tot    0)).
3710: 09 20 20 20 20 28 77 69 74 68 2d 6f 75 74 70 75  .    (with-outpu
3720: 74 2d 74 6f 2d 70 6f 72 74 0a 09 09 6f 75 70 0a  t-to-port...oup.
3730: 09 20 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28  .      (lambda (
3740: 29 0a 09 09 28 73 65 74 21 20 6f 75 74 74 78 74  )...(set! outtxt
3750: 20 28 63 6f 6e 63 20 6f 75 74 74 78 74 20 22 3c   (conc outtxt "<
3760: 68 74 6d 6c 3e 3c 74 69 74 6c 65 3e 53 75 6d 6d  html><title>Summ
3770: 61 72 79 3a 20 22 20 74 65 73 74 2d 6e 61 6d 65  ary: " test-name
3780: 20 0a 09 09 09 09 20 20 20 22 3c 2f 74 69 74 6c   .....   "</titl
3790: 65 3e 3c 62 6f 64 79 3e 3c 68 32 3e 53 75 6d 6d  e><body><h2>Summ
37a0: 61 72 79 20 66 6f 72 20 22 20 74 65 73 74 2d 6e  ary for " test-n
37b0: 61 6d 65 20 22 3c 2f 68 32 3e 22 29 29 0a 09 09  ame "</h2>"))...
37c0: 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63  (sqlite3:for-eac
37d0: 68 2d 72 6f 77 20 0a 09 09 20 28 6c 61 6d 62 64  h-row ... (lambd
37e0: 61 20 28 69 64 20 69 74 65 6d 70 61 74 68 20 73  a (id itempath s
37f0: 74 61 74 65 20 73 74 61 74 75 73 20 72 75 6e 5f  tate status run_
3800: 64 75 72 61 74 69 6f 6e 20 6c 6f 67 66 20 63 6f  duration logf co
3810: 6d 6d 65 6e 74 29 0a 09 09 20 20 20 28 68 61 73  mment)...   (has
3820: 68 2d 74 61 62 6c 65 2d 73 65 74 21 20 63 6f 75  h-table-set! cou
3830: 6e 74 73 20 73 74 61 74 75 73 20 28 2b 20 31 20  nts status (+ 1 
3840: 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f  (hash-table-ref/
3850: 64 65 66 61 75 6c 74 20 63 6f 75 6e 74 73 20 73  default counts s
3860: 74 61 74 75 73 20 30 29 29 29 0a 09 09 20 20 20  tatus 0)))...   
3870: 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74 21  (hash-table-set!
3880: 20 73 74 61 74 65 63 6f 75 6e 74 73 20 73 74 61   statecounts sta
3890: 74 65 20 28 2b 20 31 20 28 68 61 73 68 2d 74 61  te (+ 1 (hash-ta
38a0: 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20  ble-ref/default 
38b0: 73 74 61 74 65 63 6f 75 6e 74 73 20 73 74 61 74  statecounts stat
38c0: 65 20 30 29 29 29 0a 09 09 20 20 20 28 73 65 74  e 0)))...   (set
38d0: 21 20 6f 75 74 74 78 74 20 28 63 6f 6e 63 20 6f  ! outtxt (conc o
38e0: 75 74 74 78 74 20 22 3c 74 72 3e 22 0a 09 09 09  uttxt "<tr>"....
38f0: 09 20 20 20 20 20 20 22 3c 74 64 3e 3c 61 20 68  .      "<td><a h
3900: 72 65 66 3d 5c 22 22 20 69 74 65 6d 70 61 74 68  ref=\"" itempath
3910: 20 22 2f 22 20 6c 6f 67 66 20 22 5c 22 3e 20 22   "/" logf "\"> "
3920: 20 69 74 65 6d 70 61 74 68 20 22 3c 2f 61 3e 3c   itempath "</a><
3930: 2f 74 64 3e 22 20 0a 09 09 09 09 20 20 20 20 20  /td>" .....     
3940: 20 22 3c 74 64 3e 22 20 73 74 61 74 65 20 20 20   "<td>" state   
3950: 20 22 3c 2f 74 64 3e 22 20 0a 09 09 09 09 20 20   "</td>" .....  
3960: 20 20 20 20 22 3c 74 64 3e 3c 66 6f 6e 74 20 63      "<td><font c
3970: 6f 6c 6f 72 3d 22 20 28 63 6f 6d 6d 6f 6e 3a 67  olor=" (common:g
3980: 65 74 2d 63 6f 6c 6f 72 2d 66 72 6f 6d 2d 73 74  et-color-from-st
3990: 61 74 75 73 20 73 74 61 74 75 73 29 0a 09 09 09  atus status)....
39a0: 09 20 20 20 20 20 20 22 3e 22 20 20 20 73 74 61  .      ">"   sta
39b0: 74 75 73 20 20 20 22 3c 2f 66 6f 6e 74 3e 3c 2f  tus   "</font></
39c0: 74 64 3e 22 0a 09 09 09 09 20 20 20 20 20 20 22  td>".....      "
39d0: 3c 74 64 3e 22 20 28 69 66 20 28 65 71 75 61 6c  <td>" (if (equal
39e0: 3f 20 63 6f 6d 6d 65 6e 74 20 22 22 29 0a 09 09  ? comment "")...
39f0: 09 09 09 09 20 22 26 6e 62 73 70 3b 22 0a 09 09  .... "&nbsp;"...
3a00: 09 09 09 09 20 63 6f 6d 6d 65 6e 74 29 20 22 3c  .... comment) "<
3a10: 2f 74 64 3e 22 0a 09 09 09 09 09 09 20 22 3c 2f  /td>"....... "</
3a20: 74 72 3e 22 29 29 29 0a 09 09 20 64 62 0a 09 09  tr>")))... db...
3a30: 20 22 53 45 4c 45 43 54 20 69 64 2c 69 74 65 6d   "SELECT id,item
3a40: 5f 70 61 74 68 2c 73 74 61 74 65 2c 73 74 61 74  _path,state,stat
3a50: 75 73 2c 72 75 6e 5f 64 75 72 61 74 69 6f 6e 2c  us,run_duration,
3a60: 66 69 6e 61 6c 5f 6c 6f 67 66 2c 63 6f 6d 6d 65  final_logf,comme
3a70: 6e 74 20 46 52 4f 4d 20 74 65 73 74 73 20 57 48  nt FROM tests WH
3a80: 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44  ERE run_id=? AND
3a90: 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20   testname=? AND 
3aa0: 69 74 65 6d 5f 70 61 74 68 20 21 3d 20 27 27 3b  item_path != '';
3ab0: 22 0a 09 09 20 72 75 6e 2d 69 64 20 74 65 73 74  "... run-id test
3ac0: 2d 6e 61 6d 65 29 0a 0a 09 09 28 70 72 69 6e 74  -name)....(print
3ad0: 20 22 3c 74 61 62 6c 65 3e 3c 74 72 3e 3c 74 64   "<table><tr><td
3ae0: 20 76 61 6c 69 67 6e 3d 5c 22 74 6f 70 5c 22 3e   valign=\"top\">
3af0: 22 29 0a 09 09 3b 3b 20 50 72 69 6e 74 20 6f 75  ")...;; Print ou
3b00: 74 20 73 74 61 74 73 20 66 6f 72 20 73 74 61 74  t stats for stat
3b10: 75 73 0a 09 09 28 73 65 74 21 20 74 6f 74 20 30  us...(set! tot 0
3b20: 29 0a 09 09 28 70 72 69 6e 74 20 22 3c 74 61 62  )...(print "<tab
3b30: 6c 65 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d 5c  le cellspacing=\
3b40: 22 30 5c 22 20 62 6f 72 64 65 72 3d 5c 22 31 5c  "0\" border=\"1\
3b50: 22 3e 3c 74 72 3e 3c 74 64 20 63 6f 6c 73 70 61  "><tr><td colspa
3b60: 6e 3d 5c 22 32 5c 22 3e 3c 68 32 3e 53 74 61 74  n=\"2\"><h2>Stat
3b70: 65 20 73 74 61 74 73 3c 2f 68 32 3e 3c 2f 74 64  e stats</h2></td
3b80: 3e 3c 2f 74 72 3e 22 29 0a 09 09 28 66 6f 72 2d  ></tr>")...(for-
3b90: 65 61 63 68 20 28 6c 61 6d 62 64 61 20 28 73 74  each (lambda (st
3ba0: 61 74 65 29 0a 09 09 09 20 20 20 20 28 73 65 74  ate)....    (set
3bb0: 21 20 74 6f 74 20 28 2b 20 74 6f 74 20 28 68 61  ! tot (+ tot (ha
3bc0: 73 68 2d 74 61 62 6c 65 2d 72 65 66 20 73 74 61  sh-table-ref sta
3bd0: 74 65 63 6f 75 6e 74 73 20 73 74 61 74 65 29 29  tecounts state))
3be0: 29 0a 09 09 09 20 20 20 20 28 70 72 69 6e 74 20  )....    (print 
3bf0: 22 3c 74 72 3e 3c 74 64 3e 22 20 73 74 61 74 65  "<tr><td>" state
3c00: 20 22 3c 2f 74 64 3e 3c 74 64 3e 22 20 28 68 61   "</td><td>" (ha
3c10: 73 68 2d 74 61 62 6c 65 2d 72 65 66 20 73 74 61  sh-table-ref sta
3c20: 74 65 63 6f 75 6e 74 73 20 73 74 61 74 65 29 20  tecounts state) 
3c30: 22 3c 2f 74 64 3e 3c 2f 74 72 3e 22 29 29 0a 09  "</td></tr>"))..
3c40: 09 09 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d  ..  (hash-table-
3c50: 6b 65 79 73 20 73 74 61 74 65 63 6f 75 6e 74 73  keys statecounts
3c60: 29 29 0a 09 09 28 70 72 69 6e 74 20 22 3c 74 72  ))...(print "<tr
3c70: 3e 3c 74 64 3e 54 6f 74 61 6c 3c 2f 74 64 3e 3c  ><td>Total</td><
3c80: 74 64 3e 22 20 74 6f 74 20 22 3c 2f 74 64 3e 3c  td>" tot "</td><
3c90: 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e 22 29 0a 09  /tr></table>")..
3ca0: 09 28 70 72 69 6e 74 20 22 3c 2f 74 64 3e 3c 74  .(print "</td><t
3cb0: 64 20 76 61 6c 69 67 6e 3d 5c 22 74 6f 70 5c 22  d valign=\"top\"
3cc0: 3e 22 29 0a 09 09 3b 3b 20 50 72 69 6e 74 20 6f  >")...;; Print o
3cd0: 75 74 20 73 74 61 74 73 20 66 6f 72 20 73 74 61  ut stats for sta
3ce0: 74 65 0a 09 09 28 73 65 74 21 20 74 6f 74 20 30  te...(set! tot 0
3cf0: 29 0a 09 09 28 70 72 69 6e 74 20 22 3c 74 61 62  )...(print "<tab
3d00: 6c 65 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d 5c  le cellspacing=\
3d10: 22 30 5c 22 20 62 6f 72 64 65 72 3d 5c 22 31 5c  "0\" border=\"1\
3d20: 22 3e 3c 74 72 3e 3c 74 64 20 63 6f 6c 73 70 61  "><tr><td colspa
3d30: 6e 3d 5c 22 32 5c 22 3e 3c 68 32 3e 53 74 61 74  n=\"2\"><h2>Stat
3d40: 75 73 20 73 74 61 74 73 3c 2f 68 32 3e 3c 2f 74  us stats</h2></t
3d50: 64 3e 3c 2f 74 72 3e 22 29 0a 09 09 28 66 6f 72  d></tr>")...(for
3d60: 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 20 28 73  -each (lambda (s
3d70: 74 61 74 75 73 29 0a 09 09 09 20 20 20 20 28 73  tatus)....    (s
3d80: 65 74 21 20 74 6f 74 20 28 2b 20 74 6f 74 20 28  et! tot (+ tot (
3d90: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 20 63  hash-table-ref c
3da0: 6f 75 6e 74 73 20 73 74 61 74 75 73 29 29 29 0a  ounts status))).
3db0: 09 09 09 20 20 20 20 28 70 72 69 6e 74 20 22 3c  ...    (print "<
3dc0: 74 72 3e 3c 74 64 3e 3c 66 6f 6e 74 20 63 6f 6c  tr><td><font col
3dd0: 6f 72 3d 5c 22 22 20 28 63 6f 6d 6d 6f 6e 3a 67  or=\"" (common:g
3de0: 65 74 2d 63 6f 6c 6f 72 2d 66 72 6f 6d 2d 73 74  et-color-from-st
3df0: 61 74 75 73 20 73 74 61 74 75 73 29 20 22 5c 22  atus status) "\"
3e00: 3e 22 20 73 74 61 74 75 73 0a 09 09 09 09 20 20  >" status.....  
3e10: 20 22 3c 2f 66 6f 6e 74 3e 3c 2f 74 64 3e 3c 74   "</font></td><t
3e20: 64 3e 22 20 28 68 61 73 68 2d 74 61 62 6c 65 2d  d>" (hash-table-
3e30: 72 65 66 20 63 6f 75 6e 74 73 20 73 74 61 74 75  ref counts statu
3e40: 73 29 20 22 3c 2f 74 64 3e 3c 2f 74 72 3e 22 29  s) "</td></tr>")
3e50: 29 0a 09 09 09 20 20 28 68 61 73 68 2d 74 61 62  )....  (hash-tab
3e60: 6c 65 2d 6b 65 79 73 20 63 6f 75 6e 74 73 29 29  le-keys counts))
3e70: 0a 09 09 28 70 72 69 6e 74 20 22 3c 74 72 3e 3c  ...(print "<tr><
3e80: 74 64 3e 54 6f 74 61 6c 3c 2f 74 64 3e 3c 74 64  td>Total</td><td
3e90: 3e 22 20 74 6f 74 20 22 3c 2f 74 64 3e 3c 2f 74  >" tot "</td></t
3ea0: 72 3e 3c 2f 74 61 62 6c 65 3e 22 29 0a 09 09 28  r></table>")...(
3eb0: 70 72 69 6e 74 20 22 3c 2f 74 64 3e 3c 2f 74 64  print "</td></td
3ec0: 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e 22 29  ></tr></table>")
3ed0: 0a 0a 09 09 28 70 72 69 6e 74 20 22 3c 74 61 62  ....(print "<tab
3ee0: 6c 65 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d 5c  le cellspacing=\
3ef0: 22 30 5c 22 20 62 6f 72 64 65 72 3d 5c 22 31 5c  "0\" border=\"1\
3f00: 22 3e 22 20 0a 09 09 20 20 20 20 20 20 20 22 3c  ">" ...       "<
3f10: 74 72 3e 3c 74 64 3e 49 74 65 6d 3c 2f 74 64 3e  tr><td>Item</td>
3f20: 3c 74 64 3e 53 74 61 74 65 3c 2f 74 64 3e 3c 74  <td>State</td><t
3f30: 64 3e 53 74 61 74 75 73 3c 2f 74 64 3e 3c 74 64  d>Status</td><td
3f40: 3e 43 6f 6d 6d 65 6e 74 3c 2f 74 64 3e 22 0a 09  >Comment</td>"..
3f50: 09 20 20 20 20 20 20 20 6f 75 74 74 78 74 20 22  .       outtxt "
3f60: 3c 2f 74 61 62 6c 65 3e 3c 2f 62 6f 64 79 3e 3c  </table></body><
3f70: 2f 68 74 6d 6c 3e 22 29 0a 09 09 28 72 65 6c 65  /html>")...(rele
3f80: 61 73 65 2d 64 6f 74 2d 6c 6f 63 6b 20 6f 75 74  ase-dot-lock out
3f90: 70 75 74 66 69 6c 65 6e 61 6d 65 29 29 29 0a 09  putfilename)))..
3fa0: 20 20 20 20 28 63 6c 6f 73 65 2d 6f 75 74 70 75      (close-outpu
3fb0: 74 2d 70 6f 72 74 20 6f 75 70 29 0a 09 20 20 20  t-port oup)..   
3fc0: 20 28 63 68 61 6e 67 65 2d 64 69 72 65 63 74 6f   (change-directo
3fd0: 72 79 20 6f 72 69 67 2d 64 69 72 29 0a 09 20 20  ry orig-dir)..  
3fe0: 20 20 28 74 65 73 74 2d 73 65 74 2d 74 6f 70 6c    (test-set-topl
3ff0: 6f 67 21 20 64 62 20 72 75 6e 2d 69 64 20 74 65  og! db run-id te
4000: 73 74 2d 6e 61 6d 65 20 6f 75 74 70 75 74 66 69  st-name outputfi
4010: 6c 65 6e 61 6d 65 29 0a 09 20 20 20 20 29 29 29  lename)..    )))
4020: 29 29 0a 0a 3b 3b 20 3b 3b 20 54 4f 44 4f 3a 20  ))..;; ;; TODO: 
4030: 43 6f 6e 76 65 72 67 65 20 74 68 69 73 20 77 69  Converge this wi
4040: 74 68 20 64 62 3a 67 65 74 2d 74 65 73 74 2d 69  th db:get-test-i
4050: 6e 66 6f 0a 3b 3b 20 28 64 65 66 69 6e 65 20 28  nfo.;; (define (
4060: 72 75 6e 73 3a 67 65 74 2d 74 65 73 74 2d 69 6e  runs:get-test-in
4070: 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  fo db run-id tes
4080: 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68  t-name item-path
4090: 29 0a 3b 3b 20 20 20 28 6c 65 74 20 28 28 72 65  ).;;   (let ((re
40a0: 73 20 23 66 29 29 20 3b 3b 20 28 76 65 63 74 6f  s #f)) ;; (vecto
40b0: 72 20 23 66 20 23 66 20 23 66 20 23 66 20 23 66  r #f #f #f #f #f
40c0: 20 23 66 29 29 29 0a 3b 3b 20 20 20 20 20 28 73   #f))).;;     (s
40d0: 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d  qlite3:for-each-
40e0: 72 6f 77 20 0a 3b 3b 20 20 20 20 20 20 28 6c 61  row .;;      (la
40f0: 6d 62 64 61 20 28 69 64 20 72 75 6e 2d 69 64 20  mbda (id run-id 
4100: 74 65 73 74 2d 6e 61 6d 65 20 73 74 61 74 65 20  test-name state 
4110: 73 74 61 74 75 73 29 0a 3b 3b 20 20 20 20 20 20  status).;;      
4120: 20 20 28 73 65 74 21 20 72 65 73 20 28 76 65 63    (set! res (vec
4130: 74 6f 72 20 69 64 20 72 75 6e 2d 69 64 20 74 65  tor id run-id te
4140: 73 74 2d 6e 61 6d 65 20 73 74 61 74 65 20 73 74  st-name state st
4150: 61 74 75 73 20 69 74 65 6d 2d 70 61 74 68 29 29  atus item-path))
4160: 29 0a 3b 3b 20 20 20 20 20 20 64 62 20 22 53 45  ).;;      db "SE
4170: 4c 45 43 54 20 69 64 2c 72 75 6e 5f 69 64 2c 74  LECT id,run_id,t
4180: 65 73 74 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74  estname,state,st
4190: 61 74 75 73 20 46 52 4f 4d 20 74 65 73 74 73 20  atus FROM tests 
41a0: 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41  WHERE run_id=? A
41b0: 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e  ND testname=? AN
41c0: 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f 3b 22 0a  D item_path=?;".
41d0: 3b 3b 20 20 20 20 20 20 72 75 6e 2d 69 64 20 74  ;;      run-id t
41e0: 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61  est-name item-pa
41f0: 74 68 29 0a 3b 3b 20 20 20 20 20 72 65 73 29 29  th).;;     res))
4200: 0a 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69 6e 65  ..(define-inline
4210: 20 28 74 65 73 74 3a 67 65 74 2d 69 64 20 76 65   (test:get-id ve
4220: 63 29 20 20 20 20 20 20 20 28 76 65 63 74 6f 72  c)       (vector
4230: 2d 72 65 66 20 76 65 63 20 30 29 29 0a 28 64 65  -ref vec 0)).(de
4240: 66 69 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65 73  fine-inline (tes
4250: 74 3a 67 65 74 2d 72 75 6e 5f 69 64 20 76 65 63  t:get-run_id vec
4260: 29 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20  )   (vector-ref 
4270: 76 65 63 20 31 29 29 0a 28 64 65 66 69 6e 65 2d  vec 1)).(define-
4280: 69 6e 6c 69 6e 65 20 28 74 65 73 74 3a 67 65 74  inline (test:get
4290: 2d 74 65 73 74 2d 6e 61 6d 65 20 76 65 63 29 28  -test-name vec)(
42a0: 76 65 63 74 6f 72 2d 72 65 66 20 76 65 63 20 32  vector-ref vec 2
42b0: 29 29 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69 6e  )).(define-inlin
42c0: 65 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74  e (test:get-stat
42d0: 65 20 76 65 63 29 20 20 20 20 28 76 65 63 74 6f  e vec)    (vecto
42e0: 72 2d 72 65 66 20 76 65 63 20 33 29 29 0a 28 64  r-ref vec 3)).(d
42f0: 65 66 69 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65  efine-inline (te
4300: 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 76 65  st:get-status ve
4310: 63 29 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66  c)   (vector-ref
4320: 20 76 65 63 20 34 29 29 0a 28 64 65 66 69 6e 65   vec 4)).(define
4330: 2d 69 6e 6c 69 6e 65 20 28 74 65 73 74 3a 67 65  -inline (test:ge
4340: 74 2d 69 74 65 6d 2d 70 61 74 68 20 76 65 63 29  t-item-path vec)
4350: 28 76 65 63 74 6f 72 2d 72 65 66 20 76 65 63 20  (vector-ref vec 
4360: 35 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 72 75  5))..(define (ru
4370: 6e 73 3a 74 65 73 74 2d 67 65 74 2d 66 75 6c 6c  ns:test-get-full
4380: 2d 70 61 74 68 20 74 65 73 74 29 0a 20 20 28 6c  -path test).  (l
4390: 65 74 2a 20 28 28 74 65 73 74 6e 61 6d 65 20 28  et* ((testname (
43a0: 64 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74  db:test-get-test
43b0: 6e 61 6d 65 20 20 20 74 65 73 74 29 29 0a 09 20  name   test)).. 
43c0: 28 69 74 65 6d 70 61 74 68 20 28 64 62 3a 74 65  (itempath (db:te
43d0: 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68  st-get-item-path
43e0: 20 74 65 73 74 29 29 29 0a 20 20 20 20 28 63 6f   test))).    (co
43f0: 6e 63 20 74 65 73 74 6e 61 6d 65 20 28 69 66 20  nc testname (if 
4400: 28 65 71 75 61 6c 3f 20 69 74 65 6d 70 61 74 68  (equal? itempath
4410: 20 22 22 29 20 22 22 20 28 63 6f 6e 63 20 22 28   "") "" (conc "(
4420: 22 20 69 74 65 6d 70 61 74 68 20 22 29 22 29 29  " itempath ")"))
4430: 29 29 29 0a 0a 28 64 65 66 69 6e 65 2d 69 6e 6c  )))..(define-inl
4440: 69 6e 65 20 28 74 65 73 74 3a 74 65 73 74 2d 67  ine (test:test-g
4450: 65 74 2d 66 75 6c 6c 6e 61 6d 65 20 74 65 73 74  et-fullname test
4460: 29 0a 20 20 20 28 63 6f 6e 63 20 28 64 62 3a 74  ).   (conc (db:t
4470: 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65  est-get-testname
4480: 20 74 65 73 74 29 0a 09 20 28 69 66 20 28 65 71   test).. (if (eq
4490: 75 61 6c 3f 20 28 64 62 3a 74 65 73 74 2d 67 65  ual? (db:test-ge
44a0: 74 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74  t-item-path test
44b0: 29 20 22 22 29 0a 09 20 20 20 20 20 22 22 0a 09  ) "")..     ""..
44c0: 20 20 20 20 20 28 63 6f 6e 63 20 22 28 22 20 28       (conc "(" (
44d0: 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d  db:test-get-item
44e0: 2d 70 61 74 68 20 74 65 73 74 29 20 22 29 22 29  -path test) ")")
44f0: 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 63 68  )))..(define (ch
4500: 65 63 6b 2d 76 61 6c 69 64 2d 69 74 65 6d 73 20  eck-valid-items 
4510: 63 6c 61 73 73 20 69 74 65 6d 29 0a 20 20 28 6c  class item).  (l
4520: 65 74 20 28 28 76 61 6c 69 64 2d 76 61 6c 75 65  et ((valid-value
4530: 73 20 28 6c 65 74 20 28 28 73 20 28 63 6f 6e 66  s (let ((s (conf
4540: 69 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69  ig-lookup *confi
4550: 67 64 61 74 2a 20 22 76 61 6c 69 64 76 61 6c 75  gdat* "validvalu
4560: 65 73 22 20 63 6c 61 73 73 29 29 29 0a 09 09 09  es" class)))....
4570: 28 69 66 20 73 20 28 73 74 72 69 6e 67 2d 73 70  (if s (string-sp
4580: 6c 69 74 20 73 29 20 23 66 29 29 29 29 0a 20 20  lit s) #f)))).  
4590: 20 20 28 69 66 20 76 61 6c 69 64 2d 76 61 6c 75    (if valid-valu
45a0: 65 73 0a 09 28 69 66 20 28 6d 65 6d 62 65 72 20  es..(if (member 
45b0: 69 74 65 6d 20 76 61 6c 69 64 2d 76 61 6c 75 65  item valid-value
45c0: 73 29 0a 09 20 20 20 20 69 74 65 6d 20 23 66 29  s)..    item #f)
45d0: 0a 09 69 74 65 6d 29 29 29 0a 0a 28 64 65 66 69  ..item)))..(defi
45e0: 6e 65 20 28 74 65 73 74 73 74 65 70 2d 73 65 74  ne (teststep-set
45f0: 2d 73 74 61 74 75 73 21 20 64 62 20 72 75 6e 2d  -status! db run-
4600: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 74 65 73  id test-name tes
4610: 74 73 74 65 70 2d 6e 61 6d 65 20 73 74 61 74 65  tstep-name state
4620: 2d 69 6e 20 73 74 61 74 75 73 2d 69 6e 20 69 74  -in status-in it
4630: 65 6d 64 61 74 20 63 6f 6d 6d 65 6e 74 29 0a 20  emdat comment). 
4640: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20   (debug:print 4 
4650: 22 72 75 6e 2d 69 64 3a 20 22 20 72 75 6e 2d 69  "run-id: " run-i
4660: 64 20 22 20 74 65 73 74 2d 6e 61 6d 65 3a 20 22  d " test-name: "
4670: 20 74 65 73 74 2d 6e 61 6d 65 29 0a 20 20 28 6c   test-name).  (l
4680: 65 74 2a 20 28 28 73 74 61 74 65 20 20 20 20 20  et* ((state     
4690: 28 63 68 65 63 6b 2d 76 61 6c 69 64 2d 69 74 65  (check-valid-ite
46a0: 6d 73 20 22 73 74 61 74 65 22 20 73 74 61 74 65  ms "state" state
46b0: 2d 69 6e 29 29 0a 09 20 28 73 74 61 74 75 73 20  -in)).. (status 
46c0: 20 20 20 28 63 68 65 63 6b 2d 76 61 6c 69 64 2d     (check-valid-
46d0: 69 74 65 6d 73 20 22 73 74 61 74 75 73 22 20 73  items "status" s
46e0: 74 61 74 75 73 2d 69 6e 29 29 0a 09 20 28 69 74  tatus-in)).. (it
46f0: 65 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c 69  em-path (item-li
4700: 73 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74  st->path itemdat
4710: 29 29 0a 09 20 28 74 65 73 74 64 61 74 20 20 20  )).. (testdat   
4720: 28 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66  (db:get-test-inf
4730: 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  o db run-id test
4740: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  -name item-path)
4750: 29 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72  )).    (debug:pr
4760: 69 6e 74 20 35 20 22 74 65 73 74 64 61 74 3a 20  int 5 "testdat: 
4770: 22 20 74 65 73 74 64 61 74 29 0a 20 20 20 20 28  " testdat).    (
4780: 69 66 20 28 61 6e 64 20 74 65 73 74 64 61 74 20  if (and testdat 
4790: 3b 3b 20 69 66 20 74 68 65 20 73 65 63 74 69 6f  ;; if the sectio
47a0: 6e 20 65 78 69 73 74 73 20 74 68 65 6e 20 66 6f  n exists then fo
47b0: 72 63 65 20 73 70 65 63 69 66 69 63 61 74 69 6f  rce specificatio
47c0: 6e 20 42 55 47 2c 20 49 20 64 6f 6e 27 74 20 6c  n BUG, I don't l
47d0: 69 6b 65 20 68 6f 77 20 74 68 69 73 20 77 6f 72  ike how this wor
47e0: 6b 73 2e 0a 09 20 20 20 20 20 28 6f 72 20 28 6e  ks...     (or (n
47f0: 6f 74 20 73 74 61 74 65 29 28 6e 6f 74 20 73 74  ot state)(not st
4800: 61 74 75 73 29 29 29 0a 09 28 64 65 62 75 67 3a  atus)))..(debug:
4810: 70 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e 47  print 0 "WARNING
4820: 3a 20 49 6e 76 61 6c 69 64 20 22 20 28 69 66 20  : Invalid " (if 
4830: 73 74 61 74 75 73 20 22 73 74 61 74 75 73 22 20  status "status" 
4840: 22 73 74 61 74 65 22 29 0a 09 20 20 20 20 20 20  "state")..      
4850: 20 22 20 76 61 6c 75 65 20 5c 22 22 20 28 69 66   " value \"" (if
4860: 20 73 74 61 74 75 73 20 73 74 61 74 75 73 2d 69   status status-i
4870: 6e 20 73 74 61 74 65 2d 69 6e 29 20 22 5c 22 2c  n state-in) "\",
4880: 20 75 70 64 61 74 65 20 79 6f 75 72 20 76 61 6c   update your val
4890: 69 64 73 74 61 74 65 73 20 73 65 63 74 69 6f 6e  idstates section
48a0: 20 69 6e 20 6d 65 67 61 74 65 73 74 2e 63 6f 6e   in megatest.con
48b0: 66 69 67 22 29 29 0a 20 20 20 20 28 69 66 20 74  fig")).    (if t
48c0: 65 73 74 64 61 74 0a 09 28 6c 65 74 20 28 28 74  estdat..(let ((t
48d0: 65 73 74 2d 69 64 20 28 74 65 73 74 3a 67 65 74  est-id (test:get
48e0: 2d 69 64 20 74 65 73 74 64 61 74 29 29 29 0a 09  -id testdat)))..
48f0: 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75    (sqlite3:execu
4900: 74 65 20 64 62 20 0a 09 09 09 22 49 4e 53 45 52  te db ...."INSER
4910: 54 20 4f 52 20 52 45 50 4c 41 43 45 20 69 6e 74  T OR REPLACE int
4920: 6f 20 74 65 73 74 5f 73 74 65 70 73 20 28 74 65  o test_steps (te
4930: 73 74 5f 69 64 2c 73 74 65 70 6e 61 6d 65 2c 73  st_id,stepname,s
4940: 74 61 74 65 2c 73 74 61 74 75 73 2c 65 76 65 6e  tate,status,even
4950: 74 5f 74 69 6d 65 2c 63 6f 6d 6d 65 6e 74 29 20  t_time,comment) 
4960: 56 41 4c 55 45 53 28 3f 2c 3f 2c 3f 2c 3f 2c 73  VALUES(?,?,?,?,s
4970: 74 72 66 74 69 6d 65 28 27 25 73 27 2c 27 6e 6f  trftime('%s','no
4980: 77 27 29 2c 3f 29 3b 22 0a 09 09 09 74 65 73 74  w'),?);"....test
4990: 2d 69 64 20 74 65 73 74 73 74 65 70 2d 6e 61 6d  -id teststep-nam
49a0: 65 20 73 74 61 74 65 20 73 74 61 74 75 73 20 28  e state status (
49b0: 69 66 20 63 6f 6d 6d 65 6e 74 20 63 6f 6d 6d 65  if comment comme
49c0: 6e 74 20 22 22 29 29 29 0a 09 28 64 65 62 75 67  nt "")))..(debug
49d0: 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a  :print 0 "ERROR:
49e0: 20 43 61 6e 27 74 20 75 70 64 61 74 65 20 22 20   Can't update " 
49f0: 74 65 73 74 2d 6e 61 6d 65 20 22 20 66 6f 72 20  test-name " for 
4a00: 72 75 6e 20 22 20 72 75 6e 2d 69 64 20 22 20 2d  run " run-id " -
4a10: 3e 20 6e 6f 20 73 75 63 68 20 74 65 73 74 20 69  > no such test i
4a20: 6e 20 64 62 22 29 29 29 29 0a 0a 28 64 65 66 69  n db"))))..(defi
4a30: 6e 65 20 28 74 65 73 74 2d 67 65 74 2d 6b 69 6c  ne (test-get-kil
4a40: 6c 2d 72 65 71 75 65 73 74 20 64 62 20 72 75 6e  l-request db run
4a50: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74  -id test-name it
4a60: 65 6d 64 61 74 29 0a 20 20 28 6c 65 74 2a 20 28  emdat).  (let* (
4a70: 28 69 74 65 6d 2d 70 61 74 68 20 28 69 74 65 6d  (item-path (item
4a80: 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69 74 65 6d  -list->path item
4a90: 64 61 74 29 29 0a 09 20 28 74 65 73 74 64 61 74  dat)).. (testdat
4aa0: 20 20 20 28 64 62 3a 67 65 74 2d 74 65 73 74 2d     (db:get-test-
4ab0: 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74  info db run-id t
4ac0: 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61  est-name item-pa
4ad0: 74 68 29 29 29 0a 20 20 20 20 28 65 71 75 61 6c  th))).    (equal
4ae0: 3f 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74  ? (test:get-stat
4af0: 65 20 74 65 73 74 64 61 74 29 20 22 4b 49 4c 4c  e testdat) "KILL
4b00: 52 45 51 22 29 29 29 0a 0a 28 64 65 66 69 6e 65  REQ")))..(define
4b10: 20 28 74 65 73 74 2d 73 65 74 2d 6d 65 74 61 2d   (test-set-meta-
4b20: 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74  info db run-id t
4b30: 65 73 74 6e 61 6d 65 20 69 74 65 6d 64 61 74 29  estname itemdat)
4b40: 0a 20 20 28 6c 65 74 20 28 28 69 74 65 6d 2d 70  .  (let ((item-p
4b50: 61 74 68 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e  ath (item-list->
4b60: 70 61 74 68 20 69 74 65 6d 64 61 74 29 29 0a 09  path itemdat))..
4b70: 28 63 70 75 6c 6f 61 64 20 20 28 67 65 74 2d 63  (cpuload  (get-c
4b80: 70 75 2d 6c 6f 61 64 29 29 0a 09 28 68 6f 73 74  pu-load))..(host
4b90: 6e 61 6d 65 20 28 67 65 74 2d 68 6f 73 74 2d 6e  name (get-host-n
4ba0: 61 6d 65 29 29 0a 09 28 64 69 73 6b 66 72 65 65  ame))..(diskfree
4bb0: 20 28 67 65 74 2d 64 66 20 28 63 75 72 72 65 6e   (get-df (curren
4bc0: 74 2d 64 69 72 65 63 74 6f 72 79 29 29 29 0a 09  t-directory)))..
4bd0: 28 75 6e 61 6d 65 20 20 20 20 28 67 65 74 2d 75  (uname    (get-u
4be0: 6e 61 6d 65 20 22 2d 73 72 76 70 69 6f 22 29 29  name "-srvpio"))
4bf0: 0a 09 28 72 75 6e 70 61 74 68 20 20 28 63 75 72  ..(runpath  (cur
4c00: 72 65 6e 74 2d 64 69 72 65 63 74 6f 72 79 29 29  rent-directory))
4c10: 29 0a 20 20 20 20 28 73 71 6c 69 74 65 33 3a 65  ).    (sqlite3:e
4c20: 78 65 63 75 74 65 20 64 62 20 22 55 50 44 41 54  xecute db "UPDAT
4c30: 45 20 74 65 73 74 73 20 53 45 54 20 68 6f 73 74  E tests SET host
4c40: 3d 3f 2c 63 70 75 6c 6f 61 64 3d 3f 2c 64 69 73  =?,cpuload=?,dis
4c50: 6b 66 72 65 65 3d 3f 2c 75 6e 61 6d 65 3d 3f 2c  kfree=?,uname=?,
4c60: 72 75 6e 64 69 72 3d 3f 20 57 48 45 52 45 20 72  rundir=? WHERE r
4c70: 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74  un_id=? AND test
4c80: 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f  name=? AND item_
4c90: 70 61 74 68 3d 3f 3b 22 0a 09 09 20 20 68 6f 73  path=?;"...  hos
4ca0: 74 6e 61 6d 65 0a 09 09 20 20 63 70 75 6c 6f 61  tname...  cpuloa
4cb0: 64 0a 09 09 20 20 64 69 73 6b 66 72 65 65 0a 09  d...  diskfree..
4cc0: 09 20 20 75 6e 61 6d 65 0a 09 09 20 20 72 75 6e  .  uname...  run
4cd0: 70 61 74 68 0a 09 09 20 20 72 75 6e 2d 69 64 0a  path...  run-id.
4ce0: 09 09 20 20 74 65 73 74 6e 61 6d 65 0a 09 09 20  ..  testname... 
4cf0: 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 0a 28   item-path)))..(
4d00: 64 65 66 69 6e 65 20 28 74 65 73 74 2d 75 70 64  define (test-upd
4d10: 61 74 65 2d 6d 65 74 61 2d 69 6e 66 6f 20 64 62  ate-meta-info db
4d20: 20 72 75 6e 2d 69 64 20 74 65 73 74 6e 61 6d 65   run-id testname
4d30: 20 69 74 65 6d 64 61 74 20 6d 69 6e 75 74 65 73   itemdat minutes
4d40: 20 63 70 75 6c 6f 61 64 20 64 69 73 6b 66 72 65   cpuload diskfre
4d50: 65 20 74 6d 70 66 72 65 65 29 0a 20 20 28 6c 65  e tmpfree).  (le
4d60: 74 20 28 28 69 74 65 6d 2d 70 61 74 68 20 28 69  t ((item-path (i
4d70: 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69  tem-list->path i
4d80: 74 65 6d 64 61 74 29 29 29 0a 20 20 20 20 28 69  temdat))).    (i
4d90: 66 20 28 6e 6f 74 20 69 74 65 6d 2d 70 61 74 68  f (not item-path
4da0: 29 28 62 65 67 69 6e 20 28 64 65 62 75 67 3a 70  )(begin (debug:p
4db0: 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e 47 3a  rint 0 "WARNING:
4dc0: 20 49 54 45 4d 50 41 54 48 20 6e 6f 74 20 73 65   ITEMPATH not se
4dd0: 74 2e 22 29 20 20 20 28 73 65 74 21 20 69 74 65  t.")   (set! ite
4de0: 6d 2d 70 61 74 68 20 22 22 29 29 29 0a 20 20 20  m-path ""))).   
4df0: 20 3b 3b 20 28 6c 65 74 20 28 28 74 65 73 74 69   ;; (let ((testi
4e00: 6e 66 6f 20 28 64 62 3a 67 65 74 2d 74 65 73 74  nfo (db:get-test
4e10: 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64 20  -info db run-id 
4e20: 74 65 73 74 6e 61 6d 65 20 69 74 65 6d 2d 70 61  testname item-pa
4e30: 74 68 29 29 29 0a 20 20 20 20 3b 3b 20 20 20 28  th))).    ;;   (
4e40: 69 66 20 28 61 6e 64 20 28 6e 6f 74 20 28 65 71  if (and (not (eq
4e50: 75 61 6c 3f 20 28 64 62 3a 74 65 73 74 2d 67 65  ual? (db:test-ge
4e60: 74 2d 73 74 61 74 75 73 20 74 65 73 74 69 6e 66  t-status testinf
4e70: 6f 29 20 22 43 4f 4d 50 4c 45 54 45 44 22 29 29  o) "COMPLETED"))
4e80: 0a 20 20 20 20 3b 3b 20 20 20 20 20 20 20 20 20  .    ;;         
4e90: 20 20 20 28 6e 6f 74 20 28 65 71 75 61 6c 3f 20     (not (equal? 
4ea0: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 73 74 61  (db:test-get-sta
4eb0: 74 75 73 20 74 65 73 74 69 6e 66 6f 29 20 22 4b  tus testinfo) "K
4ec0: 49 4c 4c 52 45 51 22 29 29 0a 20 20 20 20 28 73  ILLREQ")).    (s
4ed0: 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 0a 20  qlite3:execute. 
4ee0: 20 20 20 20 64 62 0a 20 20 20 20 20 22 55 50 44      db.     "UPD
4ef0: 41 54 45 20 74 65 73 74 73 20 53 45 54 20 63 70  ATE tests SET cp
4f00: 75 6c 6f 61 64 3d 3f 2c 64 69 73 6b 66 72 65 65  uload=?,diskfree
4f10: 3d 3f 2c 72 75 6e 5f 64 75 72 61 74 69 6f 6e 3d  =?,run_duration=
4f20: 3f 2c 73 74 61 74 65 3d 27 52 55 4e 4e 49 4e 47  ?,state='RUNNING
4f30: 27 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f  ' WHERE run_id=?
4f40: 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20   AND testname=? 
4f50: 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f 20  AND item_path=? 
4f60: 41 4e 44 20 73 74 61 74 65 20 4e 4f 54 20 49 4e  AND state NOT IN
4f70: 20 28 27 43 4f 4d 50 4c 45 54 45 44 27 2c 27 4b   ('COMPLETED','K
4f80: 49 4c 4c 52 45 51 27 2c 27 4b 49 4c 4c 45 44 27  ILLREQ','KILLED'
4f90: 29 3b 22 0a 20 20 20 20 20 63 70 75 6c 6f 61 64  );".     cpuload
4fa0: 0a 20 20 20 20 20 64 69 73 6b 66 72 65 65 0a 20  .     diskfree. 
4fb0: 20 20 20 20 6d 69 6e 75 74 65 73 0a 20 20 20 20      minutes.    
4fc0: 20 72 75 6e 2d 69 64 0a 20 20 20 20 20 74 65 73   run-id.     tes
4fd0: 74 6e 61 6d 65 0a 20 20 20 20 20 69 74 65 6d 2d  tname.     item-
4fe0: 70 61 74 68 29 29 29 0a 0a 28 64 65 66 69 6e 65  path)))..(define
4ff0: 20 28 73 65 74 2d 6d 65 67 61 74 65 73 74 2d 65   (set-megatest-e
5000: 6e 76 2d 76 61 72 73 20 64 62 20 72 75 6e 2d 69  nv-vars db run-i
5010: 64 29 0a 20 20 28 6c 65 74 20 28 28 6b 65 79 73  d).  (let ((keys
5020: 20 28 64 62 2d 67 65 74 2d 6b 65 79 73 20 64 62   (db-get-keys db
5030: 29 29 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63  ))).    (for-eac
5040: 68 20 28 6c 61 6d 62 64 61 20 28 6b 65 79 29 0a  h (lambda (key).
5050: 09 09 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65  ..(sqlite3:for-e
5060: 61 63 68 2d 72 6f 77 0a 09 09 20 28 6c 61 6d 62  ach-row... (lamb
5070: 64 61 20 28 76 61 6c 29 0a 09 09 20 20 20 28 64  da (val)...   (d
5080: 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 73 65  ebug:print 2 "se
5090: 74 65 6e 76 20 22 20 28 6b 65 79 3a 67 65 74 2d  tenv " (key:get-
50a0: 66 69 65 6c 64 6e 61 6d 65 20 6b 65 79 29 20 22  fieldname key) "
50b0: 20 22 20 76 61 6c 29 0a 09 09 20 20 20 28 73 65   " val)...   (se
50c0: 74 65 6e 76 20 28 6b 65 79 3a 67 65 74 2d 66 69  tenv (key:get-fi
50d0: 65 6c 64 6e 61 6d 65 20 6b 65 79 29 20 76 61 6c  eldname key) val
50e0: 29 29 0a 09 09 20 64 62 20 0a 09 09 20 28 63 6f  ))... db ... (co
50f0: 6e 63 20 22 53 45 4c 45 43 54 20 22 20 28 6b 65  nc "SELECT " (ke
5100: 79 3a 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20  y:get-fieldname 
5110: 6b 65 79 29 20 22 20 46 52 4f 4d 20 72 75 6e 73  key) " FROM runs
5120: 20 57 48 45 52 45 20 69 64 3d 3f 3b 22 29 0a 09   WHERE id=?;")..
5130: 09 20 72 75 6e 2d 69 64 29 29 0a 09 20 20 20 20  . run-id))..    
5140: 20 20 6b 65 79 73 29 29 29 0a 0a 28 64 65 66 69    keys)))..(defi
5150: 6e 65 20 28 73 65 74 2d 69 74 65 6d 2d 65 6e 76  ne (set-item-env
5160: 2d 76 61 72 73 20 69 74 65 6d 64 61 74 29 0a 20  -vars itemdat). 
5170: 20 28 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62   (for-each (lamb
5180: 64 61 20 28 69 74 65 6d 29 0a 09 20 20 20 20 20  da (item)..     
5190: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20   (debug:print 2 
51a0: 22 73 65 74 65 6e 76 20 22 20 28 63 61 72 20 69  "setenv " (car i
51b0: 74 65 6d 29 20 22 20 22 20 28 63 61 64 72 20 69  tem) " " (cadr i
51c0: 74 65 6d 29 29 0a 09 20 20 20 20 20 20 28 73 65  tem))..      (se
51d0: 74 65 6e 76 20 28 63 61 72 20 69 74 65 6d 29 20  tenv (car item) 
51e0: 28 63 61 64 72 20 69 74 65 6d 29 29 29 0a 09 20  (cadr item))).. 
51f0: 20 20 20 69 74 65 6d 64 61 74 29 29 0a 0a 28 64     itemdat))..(d
5200: 65 66 69 6e 65 20 28 67 65 74 2d 61 6c 6c 2d 6c  efine (get-all-l
5210: 65 67 61 6c 2d 74 65 73 74 73 29 0a 20 20 28 6c  egal-tests).  (l
5220: 65 74 2a 20 28 28 74 65 73 74 73 20 20 28 67 6c  et* ((tests  (gl
5230: 6f 62 20 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74  ob (conc *toppat
5240: 68 2a 20 22 2f 74 65 73 74 73 2f 2a 22 29 29 29  h* "/tests/*")))
5250: 0a 09 20 28 72 65 73 20 20 20 20 27 28 29 29 29  .. (res    '()))
5260: 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e  .    (debug:prin
5270: 74 20 34 20 22 49 4e 46 4f 3a 20 4c 6f 6f 6b 69  t 4 "INFO: Looki
5280: 6e 67 20 61 74 20 74 65 73 74 73 20 22 20 28 73  ng at tests " (s
5290: 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73  tring-interspers
52a0: 65 20 74 65 73 74 73 20 22 2c 22 29 29 0a 20 20  e tests ",")).  
52b0: 20 20 28 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d    (for-each (lam
52c0: 62 64 61 20 28 74 65 73 74 70 61 74 68 29 0a 09  bda (testpath)..
52d0: 09 28 69 66 20 28 66 69 6c 65 2d 65 78 69 73 74  .(if (file-exist
52e0: 73 3f 20 28 63 6f 6e 63 20 74 65 73 74 70 61 74  s? (conc testpat
52f0: 68 20 22 2f 74 65 73 74 63 6f 6e 66 69 67 22 29  h "/testconfig")
5300: 29 0a 09 09 20 20 20 20 28 73 65 74 21 20 72 65  )...    (set! re
5310: 73 20 28 63 6f 6e 73 20 28 6c 61 73 74 20 28 73  s (cons (last (s
5320: 74 72 69 6e 67 2d 73 70 6c 69 74 20 74 65 73 74  tring-split test
5330: 70 61 74 68 20 22 2f 22 29 29 20 72 65 73 29 29  path "/")) res))
5340: 29 29 0a 09 20 20 20 20 20 20 74 65 73 74 73 29  ))..      tests)
5350: 0a 20 20 20 20 72 65 73 29 29 0a 0a 28 64 65 66  .    res))..(def
5360: 69 6e 65 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75  ine (runs:can-ru
5370: 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64 62 29  n-more-tests db)
5380: 0a 20 20 28 6c 65 74 20 28 28 6e 75 6d 2d 72 75  .  (let ((num-ru
5390: 6e 6e 69 6e 67 20 28 64 62 3a 67 65 74 2d 63 6f  nning (db:get-co
53a0: 75 6e 74 2d 74 65 73 74 73 2d 72 75 6e 6e 69 6e  unt-tests-runnin
53b0: 67 20 64 62 29 29 0a 09 28 6d 61 78 2d 63 6f 6e  g db))..(max-con
53c0: 63 75 72 72 65 6e 74 2d 6a 6f 62 73 20 28 63 6f  current-jobs (co
53d0: 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e  nfig-lookup *con
53e0: 66 69 67 64 61 74 2a 20 22 73 65 74 75 70 22 20  figdat* "setup" 
53f0: 22 6d 61 78 5f 63 6f 6e 63 75 72 72 65 6e 74 5f  "max_concurrent_
5400: 6a 6f 62 73 22 29 29 29 0a 20 20 20 20 28 64 65  jobs"))).    (de
5410: 62 75 67 3a 70 72 69 6e 74 20 32 20 22 6d 61 78  bug:print 2 "max
5420: 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73  -concurrent-jobs
5430: 3a 20 22 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65  : " max-concurre
5440: 6e 74 2d 6a 6f 62 73 20 22 2c 20 6e 75 6d 2d 72  nt-jobs ", num-r
5450: 75 6e 6e 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75  unning: " num-ru
5460: 6e 6e 69 6e 67 29 0a 20 20 20 20 28 69 66 20 28  nning).    (if (
5470: 6e 6f 74 20 28 65 71 3f 20 30 20 2a 67 6c 6f 62  not (eq? 0 *glob
5480: 61 6c 65 78 69 74 73 74 61 74 75 73 2a 29 29 0a  alexitstatus*)).
5490: 09 23 66 0a 09 28 69 66 20 28 6f 72 20 28 6e 6f  .#f..(if (or (no
54a0: 74 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74  t max-concurrent
54b0: 2d 6a 6f 62 73 29 0a 09 09 28 61 6e 64 20 6d 61  -jobs)...(and ma
54c0: 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62  x-concurrent-job
54d0: 73 0a 09 09 20 20 20 20 20 28 73 74 72 69 6e 67  s...     (string
54e0: 2d 3e 6e 75 6d 62 65 72 20 6d 61 78 2d 63 6f 6e  ->number max-con
54f0: 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29 0a 09 09  current-jobs)...
5500: 20 20 20 20 20 28 6e 6f 74 20 28 3e 3d 20 6e 75       (not (>= nu
5510: 6d 2d 72 75 6e 6e 69 6e 67 20 28 73 74 72 69 6e  m-running (strin
5520: 67 2d 3e 6e 75 6d 62 65 72 20 6d 61 78 2d 63 6f  g->number max-co
5530: 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29 29 29  ncurrent-jobs)))
5540: 29 29 0a 09 20 20 20 20 23 74 0a 09 20 20 20 20  ))..    #t..    
5550: 28 62 65 67 69 6e 20 0a 09 20 20 20 20 20 20 28  (begin ..      (
5560: 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 57  debug:print 0 "W
5570: 41 52 4e 49 4e 47 3a 20 4d 61 78 20 72 75 6e 6e  ARNING: Max runn
5580: 69 6e 67 20 6a 6f 62 73 20 65 78 63 65 65 64 65  ing jobs exceede
5590: 64 2c 20 63 75 72 72 65 6e 74 20 6e 75 6d 62 65  d, current numbe
55a0: 72 20 72 75 6e 6e 69 6e 67 3a 20 22 20 6e 75 6d  r running: " num
55b0: 2d 72 75 6e 6e 69 6e 67 20 0a 09 09 09 20 20 20  -running ....   
55c0: 22 2c 20 6d 61 78 5f 63 6f 6e 63 75 72 72 65 6e  ", max_concurren
55d0: 74 5f 6a 6f 62 73 3a 20 22 20 6d 61 78 2d 63 6f  t_jobs: " max-co
55e0: 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29 0a 09  ncurrent-jobs)..
55f0: 20 20 20 20 20 20 23 66 29 29 29 29 29 0a 20 20        #f))))).  
5600: 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 2d 74 65  .(define (run-te
5610: 73 74 73 20 64 62 20 74 65 73 74 2d 6e 61 6d 65  sts db test-name
5620: 73 29 0a 20 20 28 6c 65 74 2a 20 28 28 6b 65 79  s).  (let* ((key
5630: 73 20 20 20 20 20 20 20 20 28 64 62 2d 67 65 74  s        (db-get
5640: 2d 6b 65 79 73 20 64 62 29 29 0a 09 20 28 6b 65  -keys db)).. (ke
5650: 79 76 61 6c 6c 73 74 20 20 20 28 6b 65 79 73 2d  yvallst   (keys-
5660: 3e 76 61 6c 6c 69 73 74 20 6b 65 79 73 20 23 74  >vallist keys #t
5670: 29 29 0a 09 20 28 72 75 6e 2d 69 64 20 20 20 20  )).. (run-id    
5680: 20 20 28 72 65 67 69 73 74 65 72 2d 72 75 6e 20    (register-run 
5690: 64 62 20 6b 65 79 73 29 29 20 20 3b 3b 20 20 74  db keys))  ;;  t
56a0: 65 73 74 2d 6e 61 6d 65 29 29 29 0a 09 20 28 64  est-name))).. (d
56b0: 65 66 65 72 72 65 64 20 20 20 20 27 28 29 29 29  eferred    '()))
56c0: 20 3b 3b 20 64 65 6c 61 79 20 72 75 6e 6e 69 6e   ;; delay runnin
56d0: 67 20 74 68 65 73 65 20 73 69 6e 63 65 20 74 68  g these since th
56e0: 65 79 20 68 61 76 65 20 61 20 77 61 69 74 6f 6e  ey have a waiton
56f0: 20 63 6c 61 75 73 65 0a 20 20 20 20 3b 3b 20 6f   clause.    ;; o
5700: 6e 20 74 68 65 20 66 69 72 73 74 20 70 61 73 73  n the first pass
5710: 20 6f 72 20 63 61 6c 6c 20 74 6f 20 72 75 6e 2d   or call to run-
5720: 74 65 73 74 73 20 73 65 74 20 46 41 49 4c 53 20  tests set FAILS 
5730: 74 6f 20 4e 4f 54 5f 53 54 41 52 54 45 44 20 69  to NOT_STARTED i
5740: 66 0a 20 20 20 20 3b 3b 20 2d 6b 65 65 70 67 6f  f.    ;; -keepgo
5750: 69 6e 67 20 69 73 20 73 70 65 63 69 66 69 65 64  ing is specified
5760: 0a 20 20 20 20 28 69 66 20 28 61 6e 64 20 28 65  .    (if (and (e
5770: 71 3f 20 2a 70 61 73 73 6e 75 6d 2a 20 30 29 0a  q? *passnum* 0).
5780: 09 20 20 20 20 20 28 61 72 67 73 3a 67 65 74 2d  .     (args:get-
5790: 61 72 67 20 22 2d 6b 65 65 70 67 6f 69 6e 67 22  arg "-keepgoing"
57a0: 29 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 3b 3b  ))..(begin..  ;;
57b0: 20 68 61 76 65 20 74 6f 20 64 65 6c 65 74 65 20   have to delete 
57c0: 74 65 73 74 20 72 65 63 6f 72 64 73 20 77 68 65  test records whe
57d0: 72 65 20 4e 4f 54 5f 53 54 41 52 54 45 44 20 73  re NOT_STARTED s
57e0: 69 6e 63 65 20 74 68 65 79 20 63 61 6e 20 63 61  ince they can ca
57f0: 75 73 65 20 2d 6b 65 65 70 67 6f 69 6e 67 20 74  use -keepgoing t
5800: 6f 20 0a 09 20 20 3b 3b 20 67 65 74 20 73 74 75  o ..  ;; get stu
5810: 63 6b 20 64 75 65 20 74 6f 20 62 65 63 6f 6d 69  ck due to becomi
5820: 6e 67 20 69 6e 61 63 63 65 73 73 69 62 6c 65 20  ng inaccessible 
5830: 66 72 6f 6d 20 61 20 66 61 69 6c 65 64 20 74 65  from a failed te
5840: 73 74 2e 20 49 2e 65 2e 20 69 66 20 74 65 73 74  st. I.e. if test
5850: 20 42 20 64 65 70 65 6e 64 73 20 0a 09 20 20 3b   B depends ..  ;
5860: 3b 20 6f 6e 20 74 65 73 74 20 41 20 62 75 74 20  ; on test A but 
5870: 74 65 73 74 20 42 20 72 65 61 63 68 65 64 20 74  test B reached t
5880: 68 65 20 70 6f 69 6e 74 20 6f 6e 20 62 65 69 6e  he point on bein
5890: 67 20 72 65 67 69 73 74 65 72 65 64 20 61 73 20  g registered as 
58a0: 4e 4f 54 5f 53 54 41 52 54 45 44 20 61 6e 64 20  NOT_STARTED and 
58b0: 74 65 73 74 0a 09 20 20 3b 3b 20 41 20 66 61 69  test..  ;; A fai
58c0: 6c 65 64 20 66 6f 72 20 73 6f 6d 65 20 72 65 61  led for some rea
58d0: 73 6f 6e 20 74 68 65 6e 20 6f 6e 20 72 65 2d 72  son then on re-r
58e0: 75 6e 20 75 73 69 6e 67 20 2d 6b 65 65 70 67 6f  un using -keepgo
58f0: 69 6e 67 20 74 68 65 20 72 75 6e 20 63 61 6e 20  ing the run can 
5900: 6e 65 76 65 72 20 63 6f 6d 70 6c 65 74 65 2e 0a  never complete..
5910: 09 20 20 28 64 62 3a 64 65 6c 65 74 65 2d 74 65  .  (db:delete-te
5920: 73 74 73 2d 69 6e 2d 73 74 61 74 65 20 64 62 20  sts-in-state db 
5930: 72 75 6e 2d 69 64 20 22 4e 4f 54 5f 53 54 41 52  run-id "NOT_STAR
5940: 54 45 44 22 29 0a 09 20 20 28 64 62 3a 73 65 74  TED")..  (db:set
5950: 2d 74 65 73 74 73 2d 73 74 61 74 65 2d 73 74 61  -tests-state-sta
5960: 74 75 73 20 64 62 20 72 75 6e 2d 69 64 20 74 65  tus db run-id te
5970: 73 74 2d 6e 61 6d 65 73 20 23 66 20 22 46 41 49  st-names #f "FAI
5980: 4c 22 20 22 4e 4f 54 5f 53 54 41 52 54 45 44 22  L" "NOT_STARTED"
5990: 20 22 46 41 49 4c 22 29 29 29 0a 20 20 20 20 28   "FAIL"))).    (
59a0: 73 65 74 21 20 2a 70 61 73 73 6e 75 6d 2a 20 28  set! *passnum* (
59b0: 2b 20 2a 70 61 73 73 6e 75 6d 2a 20 31 29 29 0a  + *passnum* 1)).
59c0: 20 20 20 20 28 6c 65 74 20 6c 6f 6f 70 20 28 28      (let loop ((
59d0: 6e 75 6d 74 69 6d 65 73 20 30 29 29 0a 20 20 20  numtimes 0)).   
59e0: 20 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 20     (for-each .  
59f0: 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 74 65       (lambda (te
5a00: 73 74 2d 6e 61 6d 65 29 0a 09 20 28 69 66 20 28  st-name).. (if (
5a10: 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72  runs:can-run-mor
5a20: 65 2d 74 65 73 74 73 20 64 62 29 0a 09 20 20 20  e-tests db)..   
5a30: 20 20 28 72 75 6e 2d 6f 6e 65 2d 74 65 73 74 20    (run-one-test 
5a40: 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e  db run-id test-n
5a50: 61 6d 65 20 6b 65 79 76 61 6c 6c 73 74 29 0a 09  ame keyvallst)..
5a60: 20 20 20 20 20 3b 3b 20 61 64 64 20 73 6f 6d 65       ;; add some
5a70: 20 64 65 6c 61 79 20 0a 09 20 20 20 20 20 3b 28   delay ..     ;(
5a80: 73 6c 65 65 70 20 32 29 0a 09 20 20 20 20 20 29  sleep 2)..     )
5a90: 29 0a 20 20 20 20 20 20 20 74 65 73 74 2d 6e 61  ).       test-na
5aa0: 6d 65 73 29 0a 20 20 20 20 20 20 3b 3b 20 28 72  mes).      ;; (r
5ab0: 75 6e 2d 77 61 69 74 69 6e 67 2d 74 65 73 74 73  un-waiting-tests
5ac0: 20 64 62 29 0a 20 20 20 20 20 20 28 69 66 20 28   db).      (if (
5ad0: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 6b  args:get-arg "-k
5ae0: 65 65 70 67 6f 69 6e 67 22 29 0a 09 20 20 28 6c  eepgoing")..  (l
5af0: 65 74 20 28 28 65 73 74 72 65 6d 20 28 64 62 3a  et ((estrem (db:
5b00: 65 73 74 69 6d 61 74 65 64 2d 74 65 73 74 73 2d  estimated-tests-
5b10: 72 65 6d 61 69 6e 69 6e 67 20 64 62 20 72 75 6e  remaining db run
5b20: 2d 69 64 29 29 29 0a 09 20 20 20 20 28 69 66 20  -id)))..    (if 
5b30: 28 61 6e 64 20 28 3e 20 65 73 74 72 65 6d 20 30  (and (> estrem 0
5b40: 29 0a 09 09 20 20 20 20 20 28 65 71 3f 20 2a 67  )...     (eq? *g
5b50: 6c 6f 62 61 6c 65 78 69 74 73 74 61 74 75 73 2a  lobalexitstatus*
5b60: 20 30 29 29 0a 09 09 28 62 65 67 69 6e 0a 09 09   0))...(begin...
5b70: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31    (debug:print 1
5b80: 20 22 4b 65 65 70 20 67 6f 69 6e 67 2c 20 65 73   "Keep going, es
5b90: 74 69 6d 61 74 65 64 20 22 20 65 73 74 72 65 6d  timated " estrem
5ba0: 20 22 20 74 65 73 74 73 20 72 65 6d 61 69 6e 69   " tests remaini
5bb0: 6e 67 20 74 6f 20 72 75 6e 2c 20 77 69 6c 6c 20  ng to run, will 
5bc0: 63 6f 6e 74 69 6e 75 65 20 69 6e 20 33 20 73 65  continue in 3 se
5bd0: 63 6f 6e 64 73 20 2e 2e 2e 22 29 0a 09 09 20 20  conds ...")...  
5be0: 28 73 6c 65 65 70 20 33 29 0a 09 09 20 20 28 72  (sleep 3)...  (r
5bf0: 75 6e 2d 77 61 69 74 69 6e 67 2d 74 65 73 74 73  un-waiting-tests
5c00: 20 64 62 29 0a 09 09 20 20 28 6c 6f 6f 70 20 28   db)...  (loop (
5c10: 2b 20 6e 75 6d 74 69 6d 65 73 20 31 29 29 29 29  + numtimes 1))))
5c20: 29 29 29 29 29 0a 09 20 20 20 0a 3b 3b 20 56 45  )))))..   .;; VE
5c30: 52 59 20 49 4e 45 46 46 49 43 49 45 4e 54 21 20  RY INEFFICIENT! 
5c40: 4d 6f 76 65 20 73 74 75 66 66 20 74 68 61 74 20  Move stuff that 
5c50: 73 68 6f 75 6c 64 20 62 65 20 64 6f 6e 65 20 6f  should be done o
5c60: 6e 63 65 20 75 70 20 74 6f 20 63 61 6c 6c 69 6e  nce up to callin
5c70: 67 20 70 72 6f 63 0a 28 64 65 66 69 6e 65 20 28  g proc.(define (
5c80: 72 75 6e 2d 6f 6e 65 2d 74 65 73 74 20 64 62 20  run-one-test db 
5c90: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
5ca0: 20 6b 65 79 76 61 6c 6c 73 74 29 0a 20 20 28 64   keyvallst).  (d
5cb0: 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 4c 61  ebug:print 1 "La
5cc0: 75 6e 63 68 69 6e 67 20 74 65 73 74 20 22 20 74  unching test " t
5cd0: 65 73 74 2d 6e 61 6d 65 29 0a 20 20 3b 3b 20 41  est-name).  ;; A
5ce0: 6c 6c 20 74 68 65 73 65 20 76 61 72 73 20 6d 69  ll these vars mi
5cf0: 67 68 74 20 62 65 20 72 65 66 65 72 65 6e 63 65  ght be reference
5d00: 64 20 62 79 20 74 68 65 20 74 65 73 74 63 6f 6e  d by the testcon
5d10: 66 69 67 20 66 69 6c 65 20 72 65 61 64 65 72 0a  fig file reader.
5d20: 20 20 28 73 65 74 65 6e 76 20 22 4d 54 5f 54 45    (setenv "MT_TE
5d30: 53 54 5f 4e 41 4d 45 22 20 74 65 73 74 2d 6e 61  ST_NAME" test-na
5d40: 6d 65 29 20 3b 3b 20 0a 20 20 28 73 65 74 65 6e  me) ;; .  (seten
5d50: 76 20 22 4d 54 5f 52 55 4e 4e 41 4d 45 22 20 20  v "MT_RUNNAME"  
5d60: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22   (args:get-arg "
5d70: 3a 72 75 6e 6e 61 6d 65 22 29 29 0a 20 20 28 73  :runname")).  (s
5d80: 65 74 2d 6d 65 67 61 74 65 73 74 2d 65 6e 76 2d  et-megatest-env-
5d90: 76 61 72 73 20 64 62 20 72 75 6e 2d 69 64 29 20  vars db run-id) 
5da0: 3b 3b 20 74 68 65 73 65 20 6d 61 79 20 62 65 20  ;; these may be 
5db0: 6e 65 65 64 65 64 20 62 79 20 74 68 65 20 6c 61  needed by the la
5dc0: 75 6e 63 68 69 6e 67 20 70 72 6f 63 65 73 73 0a  unching process.
5dd0: 20 20 28 63 68 61 6e 67 65 2d 64 69 72 65 63 74    (change-direct
5de0: 6f 72 79 20 2a 74 6f 70 70 61 74 68 2a 29 0a 20  ory *toppath*). 
5df0: 20 28 6c 65 74 2a 20 28 28 74 65 73 74 2d 70 61   (let* ((test-pa
5e00: 74 68 20 20 20 20 28 63 6f 6e 63 20 2a 74 6f 70  th    (conc *top
5e10: 70 61 74 68 2a 20 22 2f 74 65 73 74 73 2f 22 20  path* "/tests/" 
5e20: 74 65 73 74 2d 6e 61 6d 65 29 29 0a 09 20 28 74  test-name)).. (t
5e30: 65 73 74 2d 63 6f 6e 66 69 67 66 20 28 63 6f 6e  est-configf (con
5e40: 63 20 74 65 73 74 2d 70 61 74 68 20 22 2f 74 65  c test-path "/te
5e50: 73 74 63 6f 6e 66 69 67 22 29 29 0a 09 20 28 74  stconfig")).. (t
5e60: 65 73 74 65 78 69 73 74 73 20 20 20 28 61 6e 64  estexists   (and
5e70: 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 74   (file-exists? t
5e80: 65 73 74 2d 63 6f 6e 66 69 67 66 29 28 66 69 6c  est-configf)(fil
5e90: 65 2d 72 65 61 64 2d 61 63 63 65 73 73 3f 20 74  e-read-access? t
5ea0: 65 73 74 2d 63 6f 6e 66 69 67 66 29 29 29 0a 09  est-configf)))..
5eb0: 20 28 74 65 73 74 2d 63 6f 6e 66 20 20 20 20 28   (test-conf    (
5ec0: 69 66 20 74 65 73 74 65 78 69 73 74 73 20 28 72  if testexists (r
5ed0: 65 61 64 2d 63 6f 6e 66 69 67 20 74 65 73 74 2d  ead-config test-
5ee0: 63 6f 6e 66 69 67 66 20 23 66 20 23 74 29 20 28  configf #f #t) (
5ef0: 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 29  make-hash-table)
5f00: 29 29 0a 09 20 28 77 61 69 74 6f 6e 20 20 20 20  )).. (waiton    
5f10: 20 20 20 28 6c 65 74 20 28 28 77 20 28 63 6f 6e     (let ((w (con
5f20: 66 69 67 2d 6c 6f 6f 6b 75 70 20 74 65 73 74 2d  fig-lookup test-
5f30: 63 6f 6e 66 20 22 72 65 71 75 69 72 65 6d 65 6e  conf "requiremen
5f40: 74 73 22 20 22 77 61 69 74 6f 6e 22 29 29 29 0a  ts" "waiton"))).
5f50: 09 09 09 20 28 69 66 20 28 73 74 72 69 6e 67 3f  ... (if (string?
5f60: 20 77 29 28 73 74 72 69 6e 67 2d 73 70 6c 69 74   w)(string-split
5f70: 20 77 29 27 28 29 29 29 29 0a 09 20 28 74 61 67   w)'()))).. (tag
5f80: 73 20 20 20 20 20 20 20 20 20 28 6c 65 74 20 28  s         (let (
5f90: 28 74 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75  (t (config-looku
5fa0: 70 20 74 65 73 74 2d 63 6f 6e 66 20 22 73 65 74  p test-conf "set
5fb0: 75 70 22 20 22 74 61 67 73 22 29 29 29 0a 09 09  up" "tags")))...
5fc0: 09 20 3b 3b 20 77 65 20 77 61 6e 74 20 6f 75 72  . ;; we want our
5fd0: 20 74 61 67 73 20 74 6f 20 62 65 20 73 65 70 61   tags to be sepa
5fe0: 72 61 74 65 64 20 62 79 20 63 6f 6d 6d 61 73 20  rated by commas 
5ff0: 61 6e 64 20 66 75 6c 6c 79 20 64 65 6c 69 6d 69  and fully delimi
6000: 74 65 64 20 62 79 20 63 6f 6d 6d 61 73 0a 09 09  ted by commas...
6010: 09 20 3b 3b 20 73 6f 20 74 68 61 74 20 71 75 65  . ;; so that que
6020: 72 69 65 73 20 77 69 74 68 20 22 6c 69 6b 65 22  ries with "like"
6030: 20 63 61 6e 20 74 69 65 20 74 6f 20 74 68 65 20   can tie to the 
6040: 63 6f 6d 6d 61 73 20 61 74 20 65 69 74 68 65 72  commas at either
6050: 20 65 6e 64 20 6f 66 20 65 61 63 68 20 74 61 67   end of each tag
6060: 0a 09 09 09 20 3b 3b 20 77 68 69 6c 65 20 61 6c  .... ;; while al
6070: 73 6f 20 61 6c 6c 6f 77 69 6e 67 20 74 68 65 20  so allowing the 
6080: 65 6e 64 20 75 73 65 72 20 74 6f 20 66 72 65 65  end user to free
6090: 6c 79 20 75 73 65 20 73 70 61 63 65 73 20 61 6e  ly use spaces an
60a0: 64 20 63 6f 6d 6d 61 73 20 74 6f 20 73 65 70 61  d commas to sepa
60b0: 72 61 74 65 20 74 61 67 73 0a 09 09 09 20 28 69  rate tags.... (i
60c0: 66 20 28 73 74 72 69 6e 67 3f 20 74 29 28 73 74  f (string? t)(st
60d0: 72 69 6e 67 2d 73 75 62 73 74 69 74 75 74 65 20  ring-substitute 
60e0: 28 72 65 67 65 78 70 20 22 5b 2c 5c 5c 73 5d 2b  (regexp "[,\\s]+
60f0: 22 29 20 22 2c 22 20 28 63 6f 6e 63 20 22 2c 22  ") "," (conc ","
6100: 20 74 20 22 2c 22 29 20 23 74 29 0a 09 09 09 20   t ",") #t).... 
6110: 20 20 20 20 27 28 29 29 29 29 29 0a 20 20 20 20      '())))).    
6120: 28 69 66 20 28 6e 6f 74 20 74 65 73 74 65 78 69  (if (not testexi
6130: 73 74 73 29 0a 09 28 62 65 67 69 6e 0a 09 20 20  sts)..(begin..  
6140: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
6150: 45 52 52 4f 52 3a 20 43 61 6e 27 74 20 66 69 6e  ERROR: Can't fin
6160: 64 20 63 6f 6e 66 69 67 20 66 69 6c 65 20 22 20  d config file " 
6170: 74 65 73 74 2d 63 6f 6e 66 69 67 66 29 0a 09 20  test-configf).. 
6180: 20 28 65 78 69 74 20 32 29 29 0a 09 3b 3b 20 70   (exit 2))..;; p
6190: 75 74 20 74 6f 70 20 76 61 72 73 20 69 6e 74 6f  ut top vars into
61a0: 20 63 6f 6e 76 65 6e 69 65 6e 74 20 76 61 72 69   convenient vari
61b0: 61 62 6c 65 73 20 61 6e 64 20 6f 70 65 6e 20 74  ables and open t
61c0: 68 65 20 64 62 0a 09 28 6c 65 74 2a 20 28 3b 3b  he db..(let* (;;
61d0: 20 64 62 20 69 73 20 61 6c 77 61 79 73 20 61 74   db is always at
61e0: 20 2a 74 6f 70 70 61 74 68 2a 2f 64 62 2f 6d 65   *toppath*/db/me
61f0: 67 61 74 65 73 74 2e 64 62 0a 09 20 20 20 20 20  gatest.db..     
6200: 20 20 28 69 74 65 6d 73 20 20 20 20 20 20 20 28    (items       (
6210: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64  hash-table-ref/d
6220: 65 66 61 75 6c 74 20 74 65 73 74 2d 63 6f 6e 66  efault test-conf
6230: 20 22 69 74 65 6d 73 22 20 27 28 29 29 29 0a 09   "items" '()))..
6240: 20 20 20 20 20 20 20 28 69 74 65 6d 73 74 61 62         (itemstab
6250: 6c 65 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d  le  (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 74 61 62 6c  -conf "itemstabl
6280: 65 22 20 27 28 29 29 29 0a 09 20 20 20 20 20 20  e" '()))..      
6290: 20 28 61 6c 6c 69 74 65 6d 73 20 20 20 20 28 69   (allitems    (i
62a0: 66 20 28 6f 72 20 28 6e 6f 74 20 28 6e 75 6c 6c  f (or (not (null
62b0: 3f 20 69 74 65 6d 73 29 29 28 6e 6f 74 20 28 6e  ? items))(not (n
62c0: 75 6c 6c 3f 20 69 74 65 6d 73 74 61 62 6c 65 29  ull? itemstable)
62d0: 29 29 0a 09 09 09 09 28 61 70 70 65 6e 64 20 28  )).....(append (
62e0: 69 74 65 6d 2d 61 73 73 6f 63 2d 3e 69 74 65 6d  item-assoc->item
62f0: 2d 6c 69 73 74 20 69 74 65 6d 73 29 0a 09 09 09  -list items)....
6300: 09 09 28 69 74 65 6d 2d 74 61 62 6c 65 2d 3e 69  ..(item-table->i
6310: 74 65 6d 2d 6c 69 73 74 20 69 74 65 6d 73 74 61  tem-list itemsta
6320: 62 6c 65 29 29 0a 09 09 09 09 27 28 28 29 29 29  ble)).....'(()))
6330: 29 20 3b 3b 20 61 20 6c 69 73 74 20 77 69 74 68  ) ;; a list with
6340: 20 6f 6e 65 20 6e 75 6c 6c 20 6c 69 73 74 20 69   one null list i
6350: 73 20 61 20 74 65 73 74 20 77 69 74 68 20 6e 6f  s a test with no
6360: 20 69 74 65 6d 73 0a 09 20 20 20 20 20 20 20 28   items..       (
6370: 72 75 6e 63 6f 6e 66 69 67 66 20 20 28 63 6f 6e  runconfigf  (con
6380: 63 20 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f 72  c  *toppath* "/r
6390: 75 6e 63 6f 6e 66 69 67 73 2e 63 6f 6e 66 69 67  unconfigs.config
63a0: 22 29 29 29 0a 09 20 20 28 64 65 62 75 67 3a 70  ")))..  (debug:p
63b0: 72 69 6e 74 20 31 20 22 69 74 65 6d 73 3a 20 22  rint 1 "items: "
63c0: 29 0a 09 20 20 28 69 66 20 28 3e 3d 20 2a 76 65  )..  (if (>= *ve
63d0: 72 62 6f 73 69 74 79 2a 20 31 29 28 70 70 20 61  rbosity* 1)(pp a
63e0: 6c 6c 69 74 65 6d 73 29 29 0a 09 20 20 28 69 66  llitems))..  (if
63f0: 20 28 3e 3d 20 2a 76 65 72 62 6f 73 69 74 79 2a   (>= *verbosity*
6400: 20 35 29 0a 09 20 20 20 20 20 20 28 62 65 67 69   5)..      (begi
6410: 6e 0a 09 09 28 70 72 69 6e 74 20 22 69 74 65 6d  n...(print "item
6420: 73 3a 20 22 29 28 70 70 20 28 69 74 65 6d 2d 61  s: ")(pp (item-a
6430: 73 73 6f 63 2d 3e 69 74 65 6d 2d 6c 69 73 74 20  ssoc->item-list 
6440: 69 74 65 6d 73 29 29 0a 09 09 28 70 72 69 6e 74  items))...(print
6450: 20 22 69 74 65 73 74 61 62 6c 65 3a 20 22 29 28   "itestable: ")(
6460: 70 70 20 28 69 74 65 6d 2d 74 61 62 6c 65 2d 3e  pp (item-table->
6470: 69 74 65 6d 2d 6c 69 73 74 20 69 74 65 6d 73 74  item-list itemst
6480: 61 62 6c 65 29 29 29 29 0a 09 20 20 28 69 66 20  able))))..  (if 
6490: 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d  (args:get-arg "-
64a0: 6d 22 29 0a 09 20 20 20 20 20 20 28 64 62 3a 73  m")..      (db:s
64b0: 65 74 2d 63 6f 6d 6d 65 6e 74 2d 66 6f 72 2d 72  et-comment-for-r
64c0: 75 6e 20 64 62 20 72 75 6e 2d 69 64 20 28 61 72  un db run-id (ar
64d0: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 6d 22 29  gs:get-arg "-m")
64e0: 29 29 0a 0a 09 20 20 3b 3b 20 48 65 72 65 20 69  ))...  ;; Here i
64f0: 73 20 77 68 65 72 65 20 74 68 65 20 74 65 73 74  s where the test
6500: 5f 6d 65 74 61 20 74 61 62 6c 65 20 69 73 20 62  _meta table is b
6510: 65 73 74 20 75 70 64 61 74 65 64 0a 09 20 20 28  est updated..  (
6520: 72 75 6e 73 3a 75 70 64 61 74 65 2d 74 65 73 74  runs:update-test
6530: 5f 6d 65 74 61 20 64 62 20 74 65 73 74 2d 6e 61  _meta db test-na
6540: 6d 65 20 74 65 73 74 2d 63 6f 6e 66 29 0a 0a 09  me test-conf)...
6550: 20 20 3b 3b 20 62 72 61 69 6e 64 65 61 64 20 77    ;; braindead w
6560: 6f 72 6b 2d 61 72 6f 75 6e 64 20 66 6f 72 20 70  ork-around for p
6570: 6f 6f 72 6c 79 20 73 70 65 63 69 66 69 65 64 20  oorly specified 
6580: 61 6c 6c 69 74 65 6d 73 20 6c 69 73 74 20 42 55  allitems list BU
6590: 47 21 21 21 20 46 49 58 4d 45 0a 09 20 20 28 69  G!!! FIXME..  (i
65a0: 66 20 28 6e 75 6c 6c 3f 20 61 6c 6c 69 74 65 6d  f (null? allitem
65b0: 73 29 28 73 65 74 21 20 61 6c 6c 69 74 65 6d 73  s)(set! allitems
65c0: 20 27 28 28 29 29 29 29 0a 09 20 20 28 6c 65 74   '(())))..  (let
65d0: 20 6c 6f 6f 70 20 28 28 69 74 65 6d 64 61 74 20   loop ((itemdat 
65e0: 28 63 61 72 20 61 6c 6c 69 74 65 6d 73 29 29 0a  (car allitems)).
65f0: 09 09 20 20 20 20 20 28 74 61 6c 20 20 20 20 20  ..     (tal     
6600: 28 63 64 72 20 61 6c 6c 69 74 65 6d 73 29 29 29  (cdr allitems)))
6610: 0a 09 20 20 20 20 3b 3b 20 28 6c 61 6d 62 64 61  ..    ;; (lambda
6620: 20 28 69 74 65 6d 64 61 74 29 20 3b 3b 3b 20 28   (itemdat) ;;; (
6630: 28 72 69 70 65 6e 65 73 73 20 22 6f 76 65 72 72  (ripeness "overr
6640: 69 70 65 22 29 20 28 74 65 6d 70 65 72 61 74 75  ipe") (temperatu
6650: 72 65 20 22 63 6f 6f 6c 22 29 20 28 73 65 61 73  re "cool") (seas
6660: 6f 6e 20 22 73 75 6d 6d 65 72 22 29 29 0a 09 20  on "summer")).. 
6670: 20 20 20 3b 3b 20 48 61 6e 64 6c 65 20 6c 69 73     ;; Handle lis
6680: 74 73 20 6f 66 20 69 74 65 6d 73 0a 09 20 20 20  ts of items..   
6690: 20 28 6c 65 74 2a 20 28 28 69 74 65 6d 2d 70 61   (let* ((item-pa
66a0: 74 68 20 20 20 20 20 28 69 74 65 6d 2d 6c 69 73  th     (item-lis
66b0: 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74 29  t->path itemdat)
66c0: 29 20 3b 3b 20 28 73 74 72 69 6e 67 2d 69 6e 74  ) ;; (string-int
66d0: 65 72 73 70 65 72 73 65 20 28 6d 61 70 20 63 61  ersperse (map ca
66e0: 64 72 20 69 74 65 6d 64 61 74 29 20 22 2f 22 29  dr itemdat) "/")
66f0: 29 0a 09 09 20 20 20 28 6e 65 77 2d 74 65 73 74  )...   (new-test
6700: 2d 70 61 74 68 20 28 73 74 72 69 6e 67 2d 69 6e  -path (string-in
6710: 74 65 72 73 70 65 72 73 65 20 28 63 6f 6e 73 20  tersperse (cons 
6720: 74 65 73 74 2d 70 61 74 68 20 28 6d 61 70 20 63  test-path (map c
6730: 61 64 72 20 69 74 65 6d 64 61 74 29 29 20 22 2f  adr itemdat)) "/
6740: 22 29 29 0a 09 09 20 20 20 28 6e 65 77 2d 74 65  "))...   (new-te
6750: 73 74 2d 6e 61 6d 65 20 28 69 66 20 28 65 71 75  st-name (if (equ
6760: 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 22  al? item-path ""
6770: 29 20 74 65 73 74 2d 6e 61 6d 65 20 28 63 6f 6e  ) test-name (con
6780: 63 20 74 65 73 74 2d 6e 61 6d 65 20 22 2f 22 20  c test-name "/" 
6790: 69 74 65 6d 2d 70 61 74 68 29 29 29 20 3b 3b 20  item-path))) ;; 
67a0: 6a 75 73 74 20 6e 65 65 64 20 69 74 20 74 6f 20  just need it to 
67b0: 62 65 20 75 6e 69 71 75 65 0a 09 09 20 20 20 28  be unique...   (
67c0: 74 65 73 74 64 61 74 20 20 20 23 66 29 0a 09 09  testdat   #f)...
67d0: 20 20 20 28 6e 75 6d 2d 72 75 6e 6e 69 6e 67 20     (num-running 
67e0: 28 64 62 3a 67 65 74 2d 63 6f 75 6e 74 2d 74 65  (db:get-count-te
67f0: 73 74 73 2d 72 75 6e 6e 69 6e 67 20 64 62 29 29  sts-running db))
6800: 0a 09 09 20 20 20 28 6d 61 78 2d 63 6f 6e 63 75  ...   (max-concu
6810: 72 72 65 6e 74 2d 6a 6f 62 73 20 28 63 6f 6e 66  rrent-jobs (conf
6820: 69 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69  ig-lookup *confi
6830: 67 64 61 74 2a 20 22 73 65 74 75 70 22 20 22 6d  gdat* "setup" "m
6840: 61 78 5f 63 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f  ax_concurrent_jo
6850: 62 73 22 29 29 0a 09 09 20 20 20 28 70 61 72 65  bs"))...   (pare
6860: 6e 74 2d 74 65 73 74 20 28 61 6e 64 20 28 6e 6f  nt-test (and (no
6870: 74 20 28 6e 75 6c 6c 3f 20 69 74 65 6d 73 29 29  t (null? items))
6880: 28 65 71 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74  (equal? item-pat
6890: 68 20 22 22 29 29 29 0a 09 09 20 20 20 28 73 69  h "")))...   (si
68a0: 6e 67 6c 65 2d 74 65 73 74 20 28 61 6e 64 20 28  ngle-test (and (
68b0: 6e 75 6c 6c 3f 20 69 74 65 6d 73 29 20 28 65 71  null? items) (eq
68c0: 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22  ual? item-path "
68d0: 22 29 29 29 0a 09 09 20 20 20 28 69 74 65 6d 2d  ")))...   (item-
68e0: 74 65 73 74 20 20 20 28 6e 6f 74 20 28 65 71 75  test   (not (equ
68f0: 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 22  al? item-path ""
6900: 29 29 29 29 0a 09 20 20 20 20 20 20 28 64 65 62  ))))..      (deb
6910: 75 67 3a 70 72 69 6e 74 20 33 20 22 6d 61 78 2d  ug:print 3 "max-
6920: 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 3a  concurrent-jobs:
6930: 20 22 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e   " max-concurren
6940: 74 2d 6a 6f 62 73 20 22 2c 20 6e 75 6d 2d 72 75  t-jobs ", num-ru
6950: 6e 6e 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e  nning: " num-run
6960: 6e 69 6e 67 29 0a 09 20 20 20 20 20 20 28 69 66  ning)..      (if
6970: 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d   (runs:can-run-m
6980: 6f 72 65 2d 74 65 73 74 73 20 64 62 29 0a 09 09  ore-tests db)...
6990: 20 20 28 62 65 67 69 6e 0a 09 09 20 20 20 20 28    (begin...    (
69a0: 6c 65 74 20 6c 6f 6f 70 32 20 28 28 74 73 20 28  let loop2 ((ts (
69b0: 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f  db:get-test-info
69c0: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d   db run-id test-
69d0: 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29  name item-path))
69e0: 20 3b 3b 20 23 66 29 0a 09 09 09 09 28 63 74 20   ;; #f).....(ct 
69f0: 30 29 29 0a 09 09 20 20 20 20 20 20 28 69 66 20  0))...      (if 
6a00: 28 61 6e 64 20 28 6e 6f 74 20 74 73 29 0a 09 09  (and (not ts)...
6a10: 09 20 20 20 20 20 20 20 28 3c 20 63 74 20 31 30  .       (< ct 10
6a20: 29 29 0a 09 09 09 20 20 28 62 65 67 69 6e 0a 09  ))....  (begin..
6a30: 09 09 20 20 20 20 28 72 65 67 69 73 74 65 72 2d  ..    (register-
6a40: 74 65 73 74 20 64 62 20 72 75 6e 2d 69 64 20 74  test db run-id t
6a50: 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61  est-name item-pa
6a60: 74 68 29 0a 09 09 09 20 20 20 20 28 64 62 3a 74  th)....    (db:t
6a70: 65 73 74 2d 73 65 74 2d 63 6f 6d 6d 65 6e 74 20  est-set-comment 
6a80: 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e  db run-id test-n
6a90: 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 20 22 22  ame item-path ""
6aa0: 29 0a 09 09 09 20 20 20 20 28 6c 6f 6f 70 32 20  )....    (loop2 
6ab0: 28 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66  (db:get-test-inf
6ac0: 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  o db run-id test
6ad0: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  -name item-path)
6ae0: 0a 09 09 09 09 20 20 20 28 2b 20 63 74 20 31 29  .....   (+ ct 1)
6af0: 29 29 0a 09 09 09 20 20 28 69 66 20 74 73 0a 09  ))....  (if ts..
6b00: 09 09 20 20 20 20 20 20 28 73 65 74 21 20 74 65  ..      (set! te
6b10: 73 74 64 61 74 20 74 73 29 0a 09 09 09 20 20 20  stdat ts)....   
6b20: 20 20 20 28 62 65 67 69 6e 0a 09 09 09 09 28 64     (begin.....(d
6b30: 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41  ebug:print 0 "WA
6b40: 52 4e 49 4e 47 3a 20 43 6f 75 6c 64 6e 27 74 20  RNING: Couldn't 
6b50: 72 65 67 69 73 74 65 72 20 74 65 73 74 20 22 20  register test " 
6b60: 74 65 73 74 2d 6e 61 6d 65 20 22 20 77 69 74 68  test-name " with
6b70: 20 69 74 65 6d 20 70 61 74 68 20 22 20 69 74 65   item path " ite
6b80: 6d 2d 70 61 74 68 20 22 2c 20 73 6b 69 70 70 69  m-path ", skippi
6b90: 6e 67 22 29 0a 09 09 09 09 28 69 66 20 28 6e 6f  ng").....(if (no
6ba0: 74 20 28 6e 75 6c 6c 3f 20 74 61 6c 29 29 0a 09  t (null? tal))..
6bb0: 09 09 09 20 20 20 20 28 6c 6f 6f 70 20 28 63 61  ...    (loop (ca
6bc0: 72 20 74 61 6c 29 28 63 64 72 20 74 61 6c 29 29  r tal)(cdr tal))
6bd0: 29 29 29 29 29 0a 09 09 20 20 20 20 28 63 68 61  )))))...    (cha
6be0: 6e 67 65 2d 64 69 72 65 63 74 6f 72 79 20 74 65  nge-directory te
6bf0: 73 74 2d 70 61 74 68 29 0a 09 09 20 20 20 20 3b  st-path)...    ;
6c00: 3b 20 74 68 69 73 20 62 6c 6f 63 6b 20 69 73 20  ; this block is 
6c10: 68 65 72 65 20 6f 6e 6c 79 20 74 6f 20 69 6e 66  here only to inf
6c20: 6f 72 6d 20 74 68 65 20 75 73 65 72 20 65 61 72  orm the user ear
6c30: 6c 79 20 6f 6e 0a 09 09 20 20 20 20 28 69 66 20  ly on...    (if 
6c40: 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 72 75  (file-exists? ru
6c50: 6e 63 6f 6e 66 69 67 66 29 0a 09 09 09 28 73 65  nconfigf)....(se
6c60: 74 75 70 2d 65 6e 76 2d 64 65 66 61 75 6c 74 73  tup-env-defaults
6c70: 20 64 62 20 72 75 6e 63 6f 6e 66 69 67 66 20 72   db runconfigf r
6c80: 75 6e 2d 69 64 20 2a 61 6c 72 65 61 64 79 2d 73  un-id *already-s
6c90: 65 65 6e 2d 72 75 6e 63 6f 6e 66 69 67 2d 69 6e  een-runconfig-in
6ca0: 66 6f 2a 29 0a 09 09 09 28 64 65 62 75 67 3a 70  fo*)....(debug:p
6cb0: 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e 47 3a  rint 0 "WARNING:
6cc0: 20 59 6f 75 20 64 6f 20 6e 6f 74 20 68 61 76 65   You do not have
6cd0: 20 61 20 72 75 6e 20 63 6f 6e 66 69 67 20 66 69   a run config fi
6ce0: 6c 65 3a 20 22 20 72 75 6e 63 6f 6e 66 69 67 66  le: " runconfigf
6cf0: 29 29 0a 09 09 20 20 20 20 28 64 65 62 75 67 3a  ))...    (debug:
6d00: 70 72 69 6e 74 20 34 20 22 72 75 6e 2d 69 64 3a  print 4 "run-id:
6d10: 20 22 20 72 75 6e 2d 69 64 20 22 20 74 65 73 74   " run-id " test
6d20: 2d 6e 61 6d 65 3a 20 22 20 74 65 73 74 2d 6e 61  -name: " test-na
6d30: 6d 65 20 22 20 69 74 65 6d 2d 70 61 74 68 3a 20  me " item-path: 
6d40: 22 20 69 74 65 6d 2d 70 61 74 68 20 22 20 74 65  " item-path " te
6d50: 73 74 64 61 74 3a 20 22 20 28 74 65 73 74 3a 67  stdat: " (test:g
6d60: 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61  et-status testda
6d70: 74 29 20 22 20 74 65 73 74 2d 73 74 61 74 65 3a  t) " test-state:
6d80: 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61   " (test:get-sta
6d90: 74 65 20 74 65 73 74 64 61 74 29 29 0a 09 09 20  te testdat))... 
6da0: 20 20 20 28 63 61 73 65 20 28 69 66 20 28 61 72     (case (if (ar
6db0: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 66 6f 72  gs:get-arg "-for
6dc0: 63 65 22 29 0a 09 09 09 20 20 20 20 20 20 27 4e  ce")....      'N
6dd0: 4f 54 5f 53 54 41 52 54 45 44 0a 09 09 09 20 20  OT_STARTED....  
6de0: 20 20 20 20 28 69 66 20 74 65 73 74 64 61 74 0a      (if testdat.
6df0: 09 09 09 09 20 20 28 73 74 72 69 6e 67 2d 3e 73  ....  (string->s
6e00: 79 6d 62 6f 6c 20 28 74 65 73 74 3a 67 65 74 2d  ymbol (test:get-
6e10: 73 74 61 74 65 20 74 65 73 74 64 61 74 29 29 0a  state testdat)).
6e20: 09 09 09 09 20 20 27 66 61 69 6c 65 64 2d 74 6f  ....  'failed-to
6e30: 2d 69 6e 73 65 72 74 29 29 0a 09 09 20 20 20 20  -insert))...    
6e40: 20 20 28 28 66 61 69 6c 65 64 2d 74 6f 2d 69 6e    ((failed-to-in
6e50: 73 65 72 74 29 0a 09 09 20 20 20 20 20 20 20 28  sert)...       (
6e60: 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45  debug:print 0 "E
6e70: 52 52 4f 52 3a 20 46 61 69 6c 65 64 20 74 6f 20  RROR: Failed to 
6e80: 69 6e 73 65 72 74 20 74 68 65 20 72 65 63 6f 72  insert the recor
6e90: 64 20 69 6e 74 6f 20 74 68 65 20 64 62 22 29 29  d into the db"))
6ea0: 0a 09 09 20 20 20 20 20 20 28 28 4e 4f 54 5f 53  ...      ((NOT_S
6eb0: 54 41 52 54 45 44 20 43 4f 4d 50 4c 45 54 45 44  TARTED COMPLETED
6ec0: 29 0a 09 09 20 20 20 20 20 20 20 28 64 65 62 75  )...       (debu
6ed0: 67 3a 70 72 69 6e 74 20 36 20 22 47 6f 74 20 68  g:print 6 "Got h
6ee0: 65 72 65 2c 20 22 20 28 74 65 73 74 3a 67 65 74  ere, " (test:get
6ef0: 2d 73 74 61 74 65 20 74 65 73 74 64 61 74 29 29  -state testdat))
6f00: 0a 09 09 20 20 20 20 20 20 20 28 6c 65 74 20 28  ...       (let (
6f10: 28 72 75 6e 66 6c 61 67 20 23 66 29 29 0a 09 09  (runflag #f))...
6f20: 09 20 28 63 6f 6e 64 0a 09 09 09 20 20 3b 3b 20  . (cond....  ;; 
6f30: 69 2e 65 2e 20 74 68 69 73 20 69 73 20 74 68 65  i.e. this is the
6f40: 20 70 61 72 65 6e 74 20 74 65 73 74 20 74 6f 20   parent test to 
6f50: 61 20 73 75 69 74 65 20 6f 66 20 69 74 65 6d 73  a suite of items
6f60: 2c 20 6e 65 76 65 72 20 22 72 75 6e 22 20 69 74  , never "run" it
6f70: 0a 09 09 09 20 20 28 70 61 72 65 6e 74 2d 74 65  ....  (parent-te
6f80: 73 74 0a 09 09 09 20 20 20 28 73 65 74 21 20 72  st....   (set! r
6f90: 75 6e 66 6c 61 67 20 23 66 29 29 0a 09 09 09 20  unflag #f)).... 
6fa0: 20 3b 3b 20 2d 66 6f 72 63 65 2c 20 72 75 6e 20   ;; -force, run 
6fb0: 6e 6f 20 6d 61 74 74 65 72 20 77 68 61 74 0a 09  no matter what..
6fc0: 09 09 20 20 28 28 61 72 67 73 3a 67 65 74 2d 61  ..  ((args:get-a
6fd0: 72 67 20 22 2d 66 6f 72 63 65 22 29 28 73 65 74  rg "-force")(set
6fe0: 21 20 72 75 6e 66 6c 61 67 20 23 74 29 29 0a 09  ! runflag #t))..
6ff0: 09 09 20 20 3b 3b 20 4e 4f 54 5f 53 54 41 52 54  ..  ;; NOT_START
7000: 45 44 2c 20 72 75 6e 20 6e 6f 20 6d 61 74 74 65  ED, run no matte
7010: 72 20 77 68 61 74 0a 09 09 09 20 20 28 28 65 71  r what....  ((eq
7020: 75 61 6c 3f 20 28 74 65 73 74 3a 67 65 74 2d 73  ual? (test:get-s
7030: 74 61 74 65 20 74 65 73 74 64 61 74 29 20 22 4e  tate testdat) "N
7040: 4f 54 5f 53 54 41 52 54 45 44 22 29 28 73 65 74  OT_STARTED")(set
7050: 21 20 72 75 6e 66 6c 61 67 20 23 74 29 29 0a 09  ! runflag #t))..
7060: 09 09 20 20 3b 3b 20 6e 6f 74 20 2d 72 65 72 75  ..  ;; not -reru
7070: 6e 20 61 6e 64 20 50 41 53 53 2c 20 57 41 52 4e  n and PASS, WARN
7080: 20 6f 72 20 43 48 45 43 4b 2c 20 64 6f 20 6e 6f   or CHECK, do no
7090: 20 72 75 6e 0a 09 09 09 20 20 28 28 61 6e 64 20   run....  ((and 
70a0: 28 6f 72 20 28 6e 6f 74 20 28 61 72 67 73 3a 67  (or (not (args:g
70b0: 65 74 2d 61 72 67 20 22 2d 72 65 72 75 6e 22 29  et-arg "-rerun")
70c0: 29 0a 09 09 09 09 20 20 20 20 28 61 72 67 73 3a  ).....    (args:
70d0: 67 65 74 2d 61 72 67 20 22 2d 6b 65 65 70 67 6f  get-arg "-keepgo
70e0: 69 6e 67 22 29 29 0a 09 09 09 09 28 6d 65 6d 62  ing")).....(memb
70f0: 65 72 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61  er (test:get-sta
7100: 74 75 73 20 74 65 73 74 64 61 74 29 20 27 28 22  tus testdat) '("
7110: 50 41 53 53 22 20 22 57 41 52 4e 22 20 22 43 48  PASS" "WARN" "CH
7120: 45 43 4b 22 29 29 29 0a 09 09 09 20 20 20 28 73  ECK")))....   (s
7130: 65 74 21 20 72 75 6e 66 6c 61 67 20 23 66 29 29  et! runflag #f))
7140: 0a 09 09 09 20 20 3b 3b 20 2d 72 65 72 75 6e 20  ....  ;; -rerun 
7150: 61 6e 64 20 73 74 61 74 75 73 20 69 73 20 6f 6e  and status is on
7160: 65 20 6f 66 20 74 68 65 20 73 70 65 63 69 66 65  e of the specife
7170: 64 2c 20 72 75 6e 20 69 74 0a 09 09 09 20 20 28  d, run it....  (
7180: 28 61 6e 64 20 28 61 72 67 73 3a 67 65 74 2d 61  (and (args:get-a
7190: 72 67 20 22 2d 72 65 72 75 6e 22 29 0a 09 09 09  rg "-rerun")....
71a0: 09 28 6c 65 74 20 28 28 72 65 72 75 6e 6c 73 74  .(let ((rerunlst
71b0: 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 28   (string-split (
71c0: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72  args:get-arg "-r
71d0: 65 72 75 6e 22 29 20 22 2c 22 29 29 29 20 3b 3b  erun") ","))) ;;
71e0: 20 46 41 49 4c 2c 0a 09 09 09 09 20 20 28 6d 65   FAIL,.....  (me
71f0: 6d 62 65 72 20 28 74 65 73 74 3a 67 65 74 2d 73  mber (test:get-s
7200: 74 61 74 75 73 20 74 65 73 74 64 61 74 29 20 72  tatus testdat) r
7210: 65 72 75 6e 6c 73 74 29 29 29 0a 09 09 09 20 20  erunlst)))....  
7220: 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23   (set! runflag #
7230: 74 29 29 0a 09 09 09 20 20 3b 3b 20 2d 6b 65 65  t))....  ;; -kee
7240: 70 67 6f 69 6e 67 2c 20 64 6f 20 6e 6f 74 20 72  pgoing, do not r
7250: 65 72 75 6e 20 46 41 49 4c 0a 09 09 09 20 20 28  erun FAIL....  (
7260: 28 61 6e 64 20 28 61 72 67 73 3a 67 65 74 2d 61  (and (args:get-a
7270: 72 67 20 22 2d 6b 65 65 70 67 6f 69 6e 67 22 29  rg "-keepgoing")
7280: 0a 09 09 09 09 28 6d 65 6d 62 65 72 20 28 74 65  .....(member (te
7290: 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65  st:get-status te
72a0: 73 74 64 61 74 29 20 27 28 22 46 41 49 4c 22 29  stdat) '("FAIL")
72b0: 29 29 0a 09 09 09 20 20 20 28 73 65 74 21 20 72  ))....   (set! r
72c0: 75 6e 66 6c 61 67 20 23 66 29 29 0a 09 09 09 20  unflag #f)).... 
72d0: 20 28 28 61 6e 64 20 28 6e 6f 74 20 28 61 72 67   ((and (not (arg
72e0: 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65 72 75  s:get-arg "-reru
72f0: 6e 22 29 29 0a 09 09 09 09 28 6d 65 6d 62 65 72  n")).....(member
7300: 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75   (test:get-statu
7310: 73 20 74 65 73 74 64 61 74 29 20 27 28 22 46 41  s testdat) '("FA
7320: 49 4c 22 20 22 6e 2f 61 22 29 29 29 0a 09 09 09  IL" "n/a")))....
7330: 20 20 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67     (set! runflag
7340: 20 23 74 29 29 0a 09 09 09 20 20 28 65 6c 73 65   #t))....  (else
7350: 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23   (set! runflag #
7360: 66 29 29 29 0a 09 09 09 20 28 64 65 62 75 67 3a  f))).... (debug:
7370: 70 72 69 6e 74 20 36 20 22 52 55 4e 4e 49 4e 47  print 6 "RUNNING
7380: 20 3d 3e 20 72 75 6e 66 6c 61 67 3a 20 22 20 72   => runflag: " r
7390: 75 6e 66 6c 61 67 20 22 20 53 54 41 54 45 3a 20  unflag " STATE: 
73a0: 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74  " (test:get-stat
73b0: 65 20 74 65 73 74 64 61 74 29 20 22 20 53 54 41  e testdat) " STA
73c0: 54 55 53 3a 20 22 20 28 74 65 73 74 3a 67 65 74  TUS: " (test:get
73d0: 2d 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29  -status testdat)
73e0: 29 0a 09 09 09 20 28 69 66 20 28 6e 6f 74 20 72  ).... (if (not r
73f0: 75 6e 66 6c 61 67 29 0a 09 09 09 20 20 20 20 20  unflag)....     
7400: 28 69 66 20 28 6e 6f 74 20 70 61 72 65 6e 74 2d  (if (not parent-
7410: 74 65 73 74 29 0a 09 09 09 09 20 28 64 65 62 75  test)..... (debu
7420: 67 3a 70 72 69 6e 74 20 31 20 22 4e 4f 54 45 3a  g:print 1 "NOTE:
7430: 20 4e 6f 74 20 73 74 61 72 74 69 6e 67 20 74 65   Not starting te
7440: 73 74 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61  st " new-test-na
7450: 6d 65 20 22 20 61 73 20 69 74 20 69 73 20 73 74  me " as it is st
7460: 61 74 65 20 5c 22 43 4f 4d 50 4c 45 54 45 44 5c  ate \"COMPLETED\
7470: 22 20 61 6e 64 20 73 74 61 74 75 73 20 5c 22 22  " and status \""
7480: 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75   (test:get-statu
7490: 73 20 74 65 73 74 64 61 74 29 20 22 5c 22 2c 20  s testdat) "\", 
74a0: 75 73 65 20 2d 66 6f 72 63 65 20 74 6f 20 6f 76  use -force to ov
74b0: 65 72 72 69 64 65 22 29 29 0a 09 09 09 20 20 20  erride"))....   
74c0: 20 20 28 6c 65 74 2a 20 28 28 67 65 74 2d 70 72    (let* ((get-pr
74d0: 65 72 65 71 73 2d 63 6d 64 20 28 6c 61 6d 62 64  ereqs-cmd (lambd
74e0: 61 20 28 29 0a 09 09 09 09 09 09 20 20 20 20 20  a ().......     
74f0: 20 20 28 64 62 2d 67 65 74 2d 70 72 65 72 65 71    (db-get-prereq
7500: 73 2d 6e 6f 74 2d 6d 65 74 20 64 62 20 72 75 6e  s-not-met db run
7510: 2d 69 64 20 77 61 69 74 6f 6e 29 29 29 20 3b 3b  -id waiton))) ;;
7520: 20 63 68 65 63 6b 20 62 65 66 6f 72 65 20 72 75   check before ru
7530: 6e 6e 69 6e 67 20 2e 2e 2e 2e 0a 09 09 09 09 20  nning ......... 
7540: 20 20 20 28 6c 61 75 6e 63 68 2d 63 6d 64 20 20     (launch-cmd  
7550: 20 20 20 20 28 6c 61 6d 62 64 61 20 28 29 0a 09      (lambda ()..
7560: 09 09 09 09 09 20 20 20 20 20 20 20 28 6c 61 75  .....       (lau
7570: 6e 63 68 2d 74 65 73 74 20 64 62 20 72 75 6e 2d  nch-test db run-
7580: 69 64 20 74 65 73 74 2d 63 6f 6e 66 20 6b 65 79  id test-conf key
7590: 76 61 6c 6c 73 74 20 74 65 73 74 2d 6e 61 6d 65  vallst test-name
75a0: 20 74 65 73 74 2d 70 61 74 68 20 69 74 65 6d 64   test-path itemd
75b0: 61 74 29 29 29 0a 09 09 09 09 20 20 20 20 28 74  at))).....    (t
75c0: 65 73 74 72 75 6e 64 61 74 20 20 20 20 20 20 28  estrundat      (
75d0: 6c 69 73 74 20 67 65 74 2d 70 72 65 72 65 71 73  list get-prereqs
75e0: 2d 63 6d 64 20 6c 61 75 6e 63 68 2d 63 6d 64 29  -cmd launch-cmd)
75f0: 29 29 0a 09 09 09 20 20 20 20 20 20 20 28 69 66  ))....       (if
7600: 20 28 6f 72 20 28 61 72 67 73 3a 67 65 74 2d 61   (or (args:get-a
7610: 72 67 20 22 2d 66 6f 72 63 65 22 29 0a 09 09 09  rg "-force")....
7620: 09 20 20 20 20 20 20 20 28 6c 65 74 20 28 28 70  .       (let ((p
7630: 72 65 71 73 2d 6e 6f 74 2d 79 65 74 2d 6d 65 74  reqs-not-yet-met
7640: 20 28 28 63 61 72 20 74 65 73 74 72 75 6e 64 61   ((car testrunda
7650: 74 29 29 29 29 0a 09 09 09 09 09 20 28 64 65 62  t))))...... (deb
7660: 75 67 3a 70 72 69 6e 74 20 32 20 22 50 72 65 71  ug:print 2 "Preq
7670: 72 65 71 75 65 73 69 74 65 73 20 66 6f 72 20 22  requesites for "
7680: 20 74 65 73 74 2d 6e 61 6d 65 20 22 3a 20 22 20   test-name ": " 
7690: 70 72 65 71 73 2d 6e 6f 74 2d 79 65 74 2d 6d 65  preqs-not-yet-me
76a0: 74 29 0a 09 09 09 09 09 20 28 6e 75 6c 6c 3f 20  t)...... (null? 
76b0: 70 72 65 71 73 2d 6e 6f 74 2d 79 65 74 2d 6d 65  preqs-not-yet-me
76c0: 74 29 29 29 20 3b 3b 20 61 72 65 20 74 68 65 72  t))) ;; are ther
76d0: 65 20 61 6e 79 20 74 65 73 74 73 20 74 68 61 74  e any tests that
76e0: 20 6d 75 73 74 20 62 65 20 72 75 6e 20 62 65 66   must be run bef
76f0: 6f 72 65 20 74 68 69 73 20 6f 6e 65 2e 2e 2e 0a  ore this one....
7700: 09 09 09 09 20 20 20 28 69 66 20 28 6e 6f 74 20  ....   (if (not 
7710: 28 28 63 61 64 72 20 74 65 73 74 72 75 6e 64 61  ((cadr testrunda
7720: 74 29 29 29 20 3b 3b 20 74 68 69 73 20 69 73 20  t))) ;; this is 
7730: 74 68 65 20 6c 69 6e 65 20 74 68 61 74 20 6c 61  the line that la
7740: 75 6e 63 68 65 73 20 74 68 65 20 74 65 73 74 20  unches the test 
7750: 74 6f 20 74 68 65 20 72 65 6d 6f 74 65 20 68 6f  to the remote ho
7760: 73 74 0a 09 09 09 09 20 20 20 20 20 20 20 28 62  st.....       (b
7770: 65 67 69 6e 0a 09 09 09 09 09 20 28 70 72 69 6e  egin...... (prin
7780: 74 20 22 45 52 52 4f 52 3a 20 46 61 69 6c 65 64  t "ERROR: Failed
7790: 20 74 6f 20 6c 61 75 6e 63 68 20 74 68 65 20 74   to launch the t
77a0: 65 73 74 2e 20 45 78 69 74 69 6e 67 20 61 73 20  est. Exiting as 
77b0: 73 6f 6f 6e 20 61 73 20 70 6f 73 73 69 62 6c 65  soon as possible
77c0: 22 29 0a 09 09 09 09 09 20 28 73 65 74 21 20 2a  ")...... (set! *
77d0: 67 6c 6f 62 61 6c 65 78 69 74 73 74 61 74 75 73  globalexitstatus
77e0: 2a 20 31 29 20 3b 3b 20 0a 09 09 09 09 09 20 28  * 1) ;; ...... (
77f0: 70 72 6f 63 65 73 73 2d 73 69 67 6e 61 6c 20 28  process-signal (
7800: 63 75 72 72 65 6e 74 2d 70 72 6f 63 65 73 73 2d  current-process-
7810: 69 64 29 20 73 69 67 6e 61 6c 2f 6b 69 6c 6c 29  id) signal/kill)
7820: 0a 09 09 09 09 09 20 3b 28 65 78 69 74 20 31 29  ...... ;(exit 1)
7830: 0a 09 09 09 09 09 20 29 29 0a 09 09 09 09 20 20  ...... )).....  
7840: 20 28 69 66 20 28 6e 6f 74 20 28 61 72 67 73 3a   (if (not (args:
7850: 67 65 74 2d 61 72 67 20 22 2d 6b 65 65 70 67 6f  get-arg "-keepgo
7860: 69 6e 67 22 29 29 0a 09 09 09 09 20 20 20 20 20  ing")).....     
7870: 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65    (hash-table-se
7880: 74 21 20 2a 77 61 69 74 69 6e 67 2d 71 75 65 75  t! *waiting-queu
7890: 65 2a 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65  e* new-test-name
78a0: 20 74 65 73 74 72 75 6e 64 61 74 29 29 29 29 29   testrundat)))))
78b0: 29 29 0a 09 09 20 20 20 20 20 20 28 28 4b 49 4c  ))...      ((KIL
78c0: 4c 45 44 29 20 0a 09 09 20 20 20 20 20 20 20 28  LED) ...       (
78d0: 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 4e  debug:print 1 "N
78e0: 4f 54 45 3a 20 22 20 6e 65 77 2d 74 65 73 74 2d  OTE: " new-test-
78f0: 6e 61 6d 65 20 22 20 69 73 20 61 6c 72 65 61 64  name " is alread
7900: 79 20 72 75 6e 6e 69 6e 67 20 6f 72 20 77 61 73  y running or was
7910: 20 65 78 70 6c 69 63 74 6c 79 20 6b 69 6c 6c 65   explictly kille
7920: 64 2c 20 75 73 65 20 2d 66 6f 72 63 65 20 74 6f  d, use -force to
7930: 20 6c 61 75 6e 63 68 20 69 74 2e 22 29 29 0a 09   launch it."))..
7940: 09 20 20 20 20 20 20 28 28 4c 41 55 4e 43 48 45  .      ((LAUNCHE
7950: 44 20 52 45 4d 4f 54 45 48 4f 53 54 53 54 41 52  D REMOTEHOSTSTAR
7960: 54 20 52 55 4e 4e 49 4e 47 29 20 20 0a 09 09 20  T RUNNING)  ... 
7970: 20 20 20 20 20 20 28 69 66 20 28 3e 20 28 2d 20        (if (> (- 
7980: 28 63 75 72 72 65 6e 74 2d 73 65 63 6f 6e 64 73  (current-seconds
7990: 29 28 2b 20 28 64 62 3a 74 65 73 74 2d 67 65 74  )(+ (db:test-get
79a0: 2d 65 76 65 6e 74 5f 74 69 6d 65 20 74 65 73 74  -event_time test
79b0: 64 61 74 29 0a 09 09 09 09 09 09 20 20 20 20 20  dat).......     
79c0: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 72 75 6e  (db:test-get-run
79d0: 5f 64 75 72 61 74 69 6f 6e 20 74 65 73 74 64 61  _duration testda
79e0: 74 29 29 29 0a 09 09 09 20 20 20 20 20 20 31 30  t)))....      10
79f0: 30 29 20 3b 3b 20 69 2e 65 2e 20 6e 6f 20 75 70  0) ;; i.e. no up
7a00: 64 61 74 65 20 66 6f 72 20 6d 6f 72 65 20 74 68  date for more th
7a10: 61 6e 20 31 30 30 20 73 65 63 6f 6e 64 73 0a 09  an 100 seconds..
7a20: 09 09 20 20 20 28 62 65 67 69 6e 0a 09 09 09 20  ..   (begin.... 
7a30: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
7a40: 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 54 65 73   0 "WARNING: Tes
7a50: 74 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20  t " test-name " 
7a60: 61 70 70 65 61 72 73 20 74 6f 20 62 65 20 64 65  appears to be de
7a70: 61 64 2e 20 46 6f 72 63 69 6e 67 20 69 74 20 74  ad. Forcing it t
7a80: 6f 20 73 74 61 74 65 20 49 4e 43 4f 4d 50 4c 45  o state INCOMPLE
7a90: 54 45 20 61 6e 64 20 73 74 61 74 75 73 20 53 54  TE and status ST
7aa0: 55 43 4b 2f 44 45 41 44 22 29 0a 09 09 09 20 20  UCK/DEAD")....  
7ab0: 20 20 20 28 74 65 73 74 2d 73 65 74 2d 73 74 61     (test-set-sta
7ac0: 74 75 73 21 20 64 62 20 72 75 6e 2d 69 64 20 74  tus! db run-id t
7ad0: 65 73 74 2d 6e 61 6d 65 20 22 49 4e 43 4f 4d 50  est-name "INCOMP
7ae0: 4c 45 54 45 22 20 22 53 54 55 43 4b 2f 44 45 41  LETE" "STUCK/DEA
7af0: 44 22 20 69 74 65 6d 64 61 74 20 22 54 65 73 74  D" itemdat "Test
7b00: 20 69 73 20 73 74 75 63 6b 20 6f 72 20 64 65 61   is stuck or dea
7b10: 64 22 20 23 66 29 29 0a 09 09 09 20 20 20 28 64  d" #f))....   (d
7b20: 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 4e 4f  ebug:print 2 "NO
7b30: 54 45 3a 20 22 20 74 65 73 74 2d 6e 61 6d 65 20  TE: " test-name 
7b40: 22 20 69 73 20 61 6c 72 65 61 64 79 20 72 75 6e  " is already run
7b50: 6e 69 6e 67 22 29 29 29 0a 09 09 20 20 20 20 20  ning")))...     
7b60: 20 28 65 6c 73 65 20 20 20 20 20 20 20 28 64 65   (else       (de
7b70: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52  bug:print 0 "ERR
7b80: 4f 52 3a 20 46 61 69 6c 65 64 20 74 6f 20 6c 61  OR: Failed to la
7b90: 75 6e 63 68 20 74 65 73 74 20 22 20 6e 65 77 2d  unch test " new-
7ba0: 74 65 73 74 2d 6e 61 6d 65 20 22 2e 20 55 6e 72  test-name ". Unr
7bb0: 65 63 6f 67 6e 69 73 65 64 20 73 74 61 74 65 20  ecognised state 
7bc0: 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74  " (test:get-stat
7bd0: 65 20 74 65 73 74 64 61 74 29 29 29 29 29 29 0a  e testdat)))))).
7be0: 09 20 20 20 20 20 20 28 69 66 20 28 6e 6f 74 20  .      (if (not 
7bf0: 28 6e 75 6c 6c 3f 20 74 61 6c 29 29 0a 09 09 20  (null? tal))... 
7c00: 20 28 6c 6f 6f 70 20 28 63 61 72 20 74 61 6c 29   (loop (car tal)
7c10: 28 63 64 72 20 74 61 6c 29 29 29 29 29 29 29 29  (cdr tal))))))))
7c20: 29 0a 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 2d  )..(define (run-
7c30: 77 61 69 74 69 6e 67 2d 74 65 73 74 73 20 64 62  waiting-tests db
7c40: 29 0a 20 20 28 6c 65 74 20 28 28 6e 75 6d 74 72  ).  (let ((numtr
7c50: 69 65 73 20 20 20 20 20 20 20 20 20 20 20 30 29  ies           0)
7c60: 0a 09 28 6c 61 73 74 2d 74 72 79 2d 74 69 6d 65  ..(last-try-time
7c70: 20 20 20 20 20 20 28 63 75 72 72 65 6e 74 2d 73        (current-s
7c80: 65 63 6f 6e 64 73 29 29 0a 09 28 74 69 6d 65 73  econds))..(times
7c90: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 6c                (l
7ca0: 69 73 74 20 31 29 29 29 20 3b 3b 20 6d 69 6e 75  ist 1))) ;; minu
7cb0: 74 65 73 20 74 6f 20 77 61 69 74 20 62 65 66 6f  tes to wait befo
7cc0: 72 65 20 74 72 79 69 6e 67 20 61 67 61 69 6e 20  re trying again 
7cd0: 74 6f 20 6b 69 63 6b 20 6f 66 66 20 72 75 6e 73  to kick off runs
7ce0: 0a 20 20 20 20 3b 3b 20 42 55 47 20 74 68 69 73  .    ;; BUG this
7cf0: 20 68 61 63 6b 20 6f 66 20 62 72 75 74 65 20 66   hack of brute f
7d00: 6f 72 63 65 20 72 65 74 72 79 69 6e 67 20 77 6f  orce retrying wo
7d10: 72 6b 73 20 71 75 69 74 65 20 77 65 6c 6c 20 66  rks quite well f
7d20: 6f 72 20 6d 61 6e 79 20 63 61 73 65 73 20 62 75  or many cases bu
7d30: 74 20 0a 20 20 20 20 3b 3b 20 20 20 20 20 77 68  t .    ;;     wh
7d40: 61 74 20 69 73 20 6e 65 65 64 65 64 20 69 73 20  at is needed is 
7d50: 74 6f 20 63 68 65 63 6b 20 74 68 65 20 64 62 20  to check the db 
7d60: 66 6f 72 20 74 65 73 74 73 20 74 68 61 74 20 68  for tests that h
7d70: 61 76 65 20 66 61 69 6c 65 64 20 6c 65 73 73 20  ave failed less 
7d80: 74 68 61 6e 0a 20 20 20 20 3b 3b 20 20 20 20 20  than.    ;;     
7d90: 4e 20 74 69 6d 65 73 20 6f 72 20 6e 65 76 65 72  N times or never
7da0: 20 62 65 65 6e 20 73 74 61 72 74 65 64 20 61 6e   been started an
7db0: 64 20 6b 69 63 6b 20 74 68 65 6d 20 6f 66 66 20  d kick them off 
7dc0: 61 67 61 69 6e 0a 20 20 20 20 28 6c 65 74 20 6c  again.    (let l
7dd0: 6f 6f 70 20 28 28 77 61 69 74 69 6e 67 2d 74 65  oop ((waiting-te
7de0: 73 74 2d 6e 61 6d 65 73 20 28 68 61 73 68 2d 74  st-names (hash-t
7df0: 61 62 6c 65 2d 6b 65 79 73 20 2a 77 61 69 74 69  able-keys *waiti
7e00: 6e 67 2d 71 75 65 75 65 2a 29 29 29 0a 20 20 20  ng-queue*))).   
7e10: 20 20 20 28 63 6f 6e 64 0a 20 20 20 20 20 20 20     (cond.       
7e20: 28 28 6e 6f 74 20 28 72 75 6e 73 3a 63 61 6e 2d  ((not (runs:can-
7e30: 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64  run-more-tests d
7e40: 62 29 29 0a 09 28 73 6c 65 65 70 20 32 29 0a 09  b))..(sleep 2)..
7e50: 28 6c 6f 6f 70 20 77 61 69 74 69 6e 67 2d 74 65  (loop waiting-te
7e60: 73 74 2d 6e 61 6d 65 73 29 29 0a 20 20 20 20 20  st-names)).     
7e70: 20 20 28 28 6e 75 6c 6c 3f 20 77 61 69 74 69 6e    ((null? waitin
7e80: 67 2d 74 65 73 74 2d 6e 61 6d 65 73 29 0a 09 28  g-test-names)..(
7e90: 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 41  debug:print 1 "A
7ea0: 6c 6c 20 74 65 73 74 73 20 6c 61 75 6e 63 68 65  ll tests launche
7eb0: 64 22 29 29 0a 20 20 20 20 20 20 20 28 65 6c 73  d")).       (els
7ec0: 65 0a 09 28 73 65 74 21 20 6e 75 6d 74 72 69 65  e..(set! numtrie
7ed0: 73 20 28 2b 20 6e 75 6d 74 72 69 65 73 20 31 29  s (+ numtries 1)
7ee0: 29 0a 09 28 66 6f 72 2d 65 61 63 68 20 28 6c 61  )..(for-each (la
7ef0: 6d 62 64 61 20 28 74 65 73 74 6e 61 6d 65 29 0a  mbda (testname).
7f00: 09 09 20 20 20 20 28 69 66 20 28 72 75 6e 73 3a  ..    (if (runs:
7f10: 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65 73  can-run-more-tes
7f20: 74 73 20 64 62 29 0a 09 09 09 28 6c 65 74 2a 20  ts db)....(let* 
7f30: 28 28 74 65 73 74 64 61 74 20 28 68 61 73 68 2d  ((testdat (hash-
7f40: 74 61 62 6c 65 2d 72 65 66 20 2a 77 61 69 74 69  table-ref *waiti
7f50: 6e 67 2d 71 75 65 75 65 2a 20 74 65 73 74 6e 61  ng-queue* testna
7f60: 6d 65 29 29 0a 09 09 09 20 20 20 20 20 20 20 28  me))....       (
7f70: 70 72 65 72 65 71 73 20 28 28 63 61 72 20 74 65  prereqs ((car te
7f80: 73 74 64 61 74 29 29 29 0a 09 09 09 20 20 20 20  stdat)))....    
7f90: 20 20 20 28 6c 64 62 20 20 20 20 20 28 69 66 20     (ldb     (if 
7fa0: 64 62 20 64 62 20 28 6f 70 65 6e 2d 64 62 29 29  db db (open-db))
7fb0: 29 29 0a 09 09 09 20 20 28 64 65 62 75 67 3a 70  ))....  (debug:p
7fc0: 72 69 6e 74 20 32 20 22 70 72 65 72 65 71 73 20  rint 2 "prereqs 
7fd0: 72 65 6d 61 69 6e 69 6e 67 3a 20 22 20 70 72 65  remaining: " pre
7fe0: 72 65 71 73 29 0a 09 09 09 20 20 28 69 66 20 28  reqs)....  (if (
7ff0: 6e 75 6c 6c 3f 20 70 72 65 72 65 71 73 29 0a 09  null? prereqs)..
8000: 09 09 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09  ..      (begin..
8010: 09 09 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20  ...(debug:print 
8020: 32 20 22 50 72 65 72 65 71 75 69 73 69 74 65 73  2 "Prerequisites
8030: 20 6d 65 74 2c 20 6c 61 75 6e 63 68 69 6e 67 20   met, launching 
8040: 22 20 74 65 73 74 6e 61 6d 65 29 0a 09 09 09 09  " testname).....
8050: 28 28 63 61 64 72 20 74 65 73 74 64 61 74 29 29  ((cadr testdat))
8060: 0a 09 09 09 09 28 68 61 73 68 2d 74 61 62 6c 65  .....(hash-table
8070: 2d 64 65 6c 65 74 65 21 20 2a 77 61 69 74 69 6e  -delete! *waitin
8080: 67 2d 71 75 65 75 65 2a 20 74 65 73 74 6e 61 6d  g-queue* testnam
8090: 65 29 29 29 0a 09 09 09 20 20 28 69 66 20 28 6e  e)))....  (if (n
80a0: 6f 74 20 64 62 29 0a 09 09 09 20 20 20 20 20 20  ot db)....      
80b0: 28 73 71 6c 69 74 65 33 3a 66 69 6e 61 6c 69 7a  (sqlite3:finaliz
80c0: 65 21 20 6c 64 62 29 29 29 29 29 0a 09 09 20 20  e! ldb)))))...  
80d0: 77 61 69 74 69 6e 67 2d 74 65 73 74 2d 6e 61 6d  waiting-test-nam
80e0: 65 73 29 0a 09 3b 3b 20 28 73 6c 65 65 70 20 31  es)..;; (sleep 1
80f0: 30 29 20 3b 3b 20 6e 6f 20 70 6f 69 6e 74 20 69  0) ;; no point i
8100: 6e 20 72 75 73 68 69 6e 67 20 74 68 69 6e 67 73  n rushing things
8110: 20 61 74 20 74 68 69 73 20 73 74 61 67 65 3f 0a   at this stage?.
8120: 09 28 6c 6f 6f 70 20 28 68 61 73 68 2d 74 61 62  .(loop (hash-tab
8130: 6c 65 2d 6b 65 79 73 20 2a 77 61 69 74 69 6e 67  le-keys *waiting
8140: 2d 71 75 65 75 65 2a 29 29 29 29 29 29 29 0a 0a  -queue*)))))))..
8150: 28 64 65 66 69 6e 65 20 28 67 65 74 2d 64 69 72  (define (get-dir
8160: 2d 75 70 2d 6e 20 64 69 72 20 2e 20 70 61 72 61  -up-n dir . para
8170: 6d 73 29 20 0a 20 20 28 6c 65 74 20 28 28 64 70  ms) .  (let ((dp
8180: 61 72 74 73 20 20 28 73 74 72 69 6e 67 2d 73 70  arts  (string-sp
8190: 6c 69 74 20 64 69 72 20 22 2f 22 29 29 0a 09 28  lit dir "/"))..(
81a0: 63 6f 75 6e 74 20 20 20 28 69 66 20 28 6e 75 6c  count   (if (nul
81b0: 6c 3f 20 70 61 72 61 6d 73 29 20 31 20 28 63 61  l? params) 1 (ca
81c0: 72 20 70 61 72 61 6d 73 29 29 29 29 0a 20 20 20  r params)))).   
81d0: 20 28 63 6f 6e 63 20 22 2f 22 20 28 73 74 72 69   (conc "/" (stri
81e0: 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 0a  ng-intersperse .
81f0: 09 20 20 20 20 20 20 20 28 74 61 6b 65 20 64 70  .       (take dp
8200: 61 72 74 73 20 28 2d 20 28 6c 65 6e 67 74 68 20  arts (- (length 
8210: 64 70 61 72 74 73 29 20 63 6f 75 6e 74 29 29 0a  dparts) count)).
8220: 09 20 20 20 20 20 20 20 22 2f 22 29 29 29 29 0a  .       "/")))).
8230: 3b 3b 20 52 65 6d 6f 76 65 20 72 75 6e 73 0a 3b  ;; Remove runs.;
8240: 3b 20 66 69 65 6c 64 73 20 61 72 65 20 70 61 73  ; fields are pas
8250: 73 69 6e 67 20 69 6e 20 74 68 72 6f 75 67 68 20  sing in through 
8260: 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 72  .(define (runs:r
8270: 65 6d 6f 76 65 2d 72 75 6e 73 20 64 62 20 72 75  emove-runs db ru
8280: 6e 6e 61 6d 65 70 61 74 74 20 74 65 73 74 70 61  nnamepatt testpa
8290: 74 74 20 69 74 65 6d 70 61 74 74 29 0a 20 20 28  tt itempatt).  (
82a0: 6c 65 74 2a 20 28 28 6b 65 79 73 20 20 20 20 20  let* ((keys     
82b0: 20 20 20 28 64 62 2d 67 65 74 2d 6b 65 79 73 20     (db-get-keys 
82c0: 64 62 29 29 0a 09 20 28 72 75 6e 64 61 74 20 20  db)).. (rundat  
82d0: 20 20 20 20 28 72 75 6e 73 3a 67 65 74 2d 72 75      (runs:get-ru
82e0: 6e 73 2d 62 79 2d 70 61 74 74 20 64 62 20 6b 65  ns-by-patt db ke
82f0: 79 73 20 72 75 6e 6e 61 6d 65 70 61 74 74 29 29  ys runnamepatt))
8300: 0a 09 20 28 68 65 61 64 65 72 20 20 20 20 20 20  .. (header      
8310: 28 76 65 63 74 6f 72 2d 72 65 66 20 72 75 6e 64  (vector-ref rund
8320: 61 74 20 30 29 29 0a 09 20 28 72 75 6e 73 20 20  at 0)).. (runs  
8330: 20 20 20 20 20 20 28 76 65 63 74 6f 72 2d 72 65        (vector-re
8340: 66 20 72 75 6e 64 61 74 20 31 29 29 29 0a 20 20  f rundat 1))).  
8350: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31    (debug:print 1
8360: 20 22 48 65 61 64 65 72 3a 20 22 20 68 65 61 64   "Header: " head
8370: 65 72 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63  er).    (for-eac
8380: 68 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28  h.     (lambda (
8390: 72 75 6e 29 0a 20 20 20 20 20 20 20 28 6c 65 74  run).       (let
83a0: 20 28 28 72 75 6e 6b 65 79 20 28 73 74 72 69 6e   ((runkey (strin
83b0: 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 28 6d  g-intersperse (m
83c0: 61 70 20 28 6c 61 6d 62 64 61 20 28 6b 29 0a 09  ap (lambda (k)..
83d0: 09 09 09 09 09 28 64 62 3a 67 65 74 2d 76 61 6c  .....(db:get-val
83e0: 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e  ue-by-header run
83f0: 20 68 65 61 64 65 72 20 28 76 65 63 74 6f 72 2d   header (vector-
8400: 72 65 66 20 6b 20 30 29 29 29 20 6b 65 79 73 29  ref k 0))) keys)
8410: 20 22 2f 22 29 29 0a 09 20 20 20 20 20 28 64 69   "/"))..     (di
8420: 72 73 2d 74 6f 2d 72 65 6d 6f 76 65 20 28 6d 61  rs-to-remove (ma
8430: 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29 29  ke-hash-table)))
8440: 0a 09 20 28 6c 65 74 2a 20 28 28 72 75 6e 2d 69  .. (let* ((run-i
8450: 64 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d  d (db:get-value-
8460: 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65  by-header run he
8470: 61 64 65 72 20 22 69 64 22 29 20 29 0a 09 09 28  ader "id") )...(
8480: 74 65 73 74 73 20 20 28 64 62 2d 67 65 74 2d 74  tests  (db-get-t
8490: 65 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20  ests-for-run db 
84a0: 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79  (db:get-value-by
84b0: 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64  -header run head
84c0: 65 72 20 22 69 64 22 29 20 74 65 73 74 70 61 74  er "id") testpat
84d0: 74 20 69 74 65 6d 70 61 74 74 29 29 0a 09 09 28  t itempatt))...(
84e0: 6c 61 73 74 74 70 61 74 68 20 22 2f 64 6f 65 73  lasttpath "/does
84f0: 2f 6e 6f 74 2f 65 78 69 73 74 2f 49 2f 68 6f 70  /not/exist/I/hop
8500: 65 22 29 29 0a 0a 09 20 20 20 28 69 66 20 28 6e  e"))...   (if (n
8510: 6f 74 20 28 6e 75 6c 6c 3f 20 74 65 73 74 73 29  ot (null? tests)
8520: 29 0a 09 20 20 20 20 20 20 20 28 62 65 67 69 6e  )..       (begin
8530: 0a 09 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ... (debug:print
8540: 20 31 20 22 52 65 6d 6f 76 69 6e 67 20 74 65 73   1 "Removing tes
8550: 74 73 20 66 6f 72 20 72 75 6e 3a 20 22 20 72 75  ts for run: " ru
8560: 6e 6b 65 79 20 22 20 22 20 28 64 62 3a 67 65 74  nkey " " (db:get
8570: 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72  -value-by-header
8580: 20 72 75 6e 20 68 65 61 64 65 72 20 22 72 75 6e   run header "run
8590: 6e 61 6d 65 22 29 29 0a 09 09 20 28 66 6f 72 2d  name"))... (for-
85a0: 65 61 63 68 0a 09 09 20 20 28 6c 61 6d 62 64 61  each...  (lambda
85b0: 20 28 74 65 73 74 29 0a 09 09 20 20 20 20 28 6c   (test)...    (l
85c0: 65 74 2a 20 28 28 69 74 65 6d 2d 70 61 74 68 20  et* ((item-path 
85d0: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65  (db:test-get-ite
85e0: 6d 2d 70 61 74 68 20 74 65 73 74 29 29 0a 09 09  m-path test))...
85f0: 09 20 20 20 28 74 65 73 74 2d 6e 61 6d 65 20 28  .   (test-name (
8600: 64 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74  db:test-get-test
8610: 6e 61 6d 65 20 74 65 73 74 29 29 0a 09 09 09 20  name test)).... 
8620: 20 20 28 72 75 6e 2d 64 69 72 20 20 20 28 64 62    (run-dir   (db
8630: 3a 74 65 73 74 2d 67 65 74 2d 72 75 6e 64 69 72  :test-get-rundir
8640: 20 74 65 73 74 29 29 29 0a 09 09 20 20 20 20 20   test)))...     
8650: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20   (debug:print 1 
8660: 22 20 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65  "  " (db:test-ge
8670: 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 29  t-testname test)
8680: 20 22 20 69 64 3a 20 22 20 28 64 62 3a 74 65 73   " id: " (db:tes
8690: 74 2d 67 65 74 2d 69 64 20 74 65 73 74 29 20 22  t-get-id test) "
86a0: 20 22 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 09   " item-path)...
86b0: 20 20 20 20 20 20 28 64 62 3a 64 65 6c 65 74 65        (db:delete
86c0: 2d 74 65 73 74 2d 72 65 63 6f 72 64 73 20 64 62  -test-records db
86d0: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64   (db:test-get-id
86e0: 20 74 65 73 74 29 29 0a 09 09 20 20 20 20 20 20   test))...      
86f0: 28 69 66 20 28 3e 20 28 73 74 72 69 6e 67 2d 6c  (if (> (string-l
8700: 65 6e 67 74 68 20 72 75 6e 2d 64 69 72 29 20 35  ength run-dir) 5
8710: 29 20 3b 3b 20 62 61 64 20 68 65 75 72 69 73 74  ) ;; bad heurist
8720: 69 63 20 62 75 74 20 73 68 6f 75 6c 64 20 70 72  ic but should pr
8730: 65 76 65 6e 74 20 2f 74 6d 70 20 2f 68 6f 6d 65  event /tmp /home
8740: 20 65 74 63 2e 0a 09 09 09 20 20 28 6c 65 74 20   etc.....  (let 
8750: 28 28 66 75 6c 6c 70 61 74 68 20 72 75 6e 2d 64  ((fullpath run-d
8760: 69 72 29 29 20 3b 3b 20 22 2f 22 20 28 64 62 3a  ir)) ;; "/" (db:
8770: 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61  test-get-item-pa
8780: 74 68 20 74 65 73 74 29 29 29 29 0a 09 09 09 20  th test)))).... 
8790: 20 20 20 28 73 65 74 21 20 6c 61 73 74 74 70 61     (set! lasttpa
87a0: 74 68 20 66 75 6c 6c 70 61 74 68 29 0a 09 09 09  th fullpath)....
87b0: 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d      (hash-table-
87c0: 73 65 74 21 20 64 69 72 73 2d 74 6f 2d 72 65 6d  set! dirs-to-rem
87d0: 6f 76 65 20 66 75 6c 6c 70 61 74 68 20 23 74 29  ove fullpath #t)
87e0: 0a 09 09 09 20 20 20 20 3b 3b 20 54 68 65 20 66  ....    ;; The f
87f0: 6f 6c 6c 6f 77 69 6e 67 20 77 61 73 20 74 68 65  ollowing was the
8800: 20 73 61 66 65 20 64 65 6c 65 74 65 20 63 6f 64   safe delete cod
8810: 65 20 62 75 74 20 69 74 20 77 61 73 20 6e 6f 74  e but it was not
8820: 20 62 65 69 6e 67 20 65 78 65 63 74 75 74 65 64   being exectuted
8830: 2e 0a 09 09 09 20 20 20 20 3b 3b 20 28 6c 65 74  .....    ;; (let
8840: 2a 20 28 28 64 69 72 73 2d 63 6f 75 6e 74 20 28  * ((dirs-count (
8850: 2b 20 31 20 28 6c 65 6e 67 74 68 20 6b 65 79 73  + 1 (length keys
8860: 29 28 6c 65 6e 67 74 68 20 28 73 74 72 69 6e 67  )(length (string
8870: 2d 73 70 6c 69 74 20 69 74 65 6d 2d 70 61 74 68  -split item-path
8880: 20 22 2f 22 29 29 29 29 0a 09 09 09 20 20 20 20   "/"))))....    
8890: 3b 3b 20 20 20 20 20 20 20 20 28 64 69 72 2d 74  ;;        (dir-t
88a0: 6f 2d 72 65 6d 20 28 67 65 74 2d 64 69 72 2d 75  o-rem (get-dir-u
88b0: 70 2d 6e 20 66 75 6c 6c 70 61 74 68 20 64 69 72  p-n fullpath dir
88c0: 73 2d 63 6f 75 6e 74 29 29 0a 09 09 09 20 20 20  s-count))....   
88d0: 20 3b 3b 20 20 20 20 20 20 20 20 28 72 65 6d 61   ;;        (rema
88e0: 69 6e 69 6e 67 64 20 28 73 74 72 69 6e 67 2d 73  iningd (string-s
88f0: 75 62 73 74 69 74 75 74 65 20 28 72 65 67 65 78  ubstitute (regex
8900: 70 20 28 63 6f 6e 63 20 22 5e 22 20 64 69 72 2d  p (conc "^" dir-
8910: 74 6f 2d 72 65 6d 20 22 2f 22 29 29 20 22 22 20  to-rem "/")) "" 
8920: 66 75 6c 6c 70 61 74 68 29 29 0a 09 09 09 20 20  fullpath))....  
8930: 20 20 3b 3b 20 20 20 20 20 20 20 20 28 63 6d 64    ;;        (cmd
8940: 20 28 63 6f 6e 63 20 22 63 64 20 22 20 64 69 72   (conc "cd " dir
8950: 2d 74 6f 2d 72 65 6d 20 22 3b 20 72 6d 64 69 72  -to-rem "; rmdir
8960: 20 2d 70 20 22 20 72 65 6d 61 69 6e 69 6e 67 64   -p " remainingd
8970: 20 29 29 29 0a 09 09 09 20 20 20 20 3b 3b 20 20   )))....    ;;  
8980: 20 28 69 66 20 28 66 69 6c 65 2d 65 78 69 73 74   (if (file-exist
8990: 73 3f 20 66 75 6c 6c 70 61 74 68 29 0a 09 09 09  s? fullpath)....
89a0: 20 20 20 20 3b 3b 20 20 20 20 20 20 20 28 62 65      ;;       (be
89b0: 67 69 6e 0a 09 09 09 20 20 20 20 3b 3b 20 20 20  gin....    ;;   
89c0: 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69        (debug:pri
89d0: 6e 74 20 31 20 63 6d 64 29 0a 09 09 09 20 20 20  nt 1 cmd)....   
89e0: 20 3b 3b 20 20 20 20 20 20 20 20 20 28 73 79 73   ;;         (sys
89f0: 74 65 6d 20 63 6d 64 29 29 29 0a 09 09 09 20 20  tem cmd)))....  
8a00: 20 20 3b 3b 20 20 20 29 29 0a 09 09 09 20 20 20    ;;   ))....   
8a10: 20 29 29 29 29 0a 09 09 20 20 20 20 74 65 73 74   ))))...    test
8a20: 73 29 29 29 0a 0a 09 20 20 20 3b 3b 20 6c 6f 6f  s)))...   ;; loo
8a30: 6b 20 74 68 6f 75 67 68 20 74 68 65 20 64 69 72  k though the dir
8a40: 73 2d 74 6f 2d 72 65 6d 6f 76 65 20 66 6f 72 20  s-to-remove for 
8a50: 63 61 6e 64 69 64 61 74 65 73 20 66 6f 72 20 72  candidates for r
8a60: 65 6d 6f 76 61 6c 2e 20 44 6f 20 74 68 69 73 20  emoval. Do this 
8a70: 61 66 74 65 72 20 64 65 6c 65 74 69 6e 67 20 74  after deleting t
8a80: 68 65 20 72 65 63 6f 72 64 73 0a 09 20 20 20 3b  he records..   ;
8a90: 3b 20 66 6f 72 20 65 61 63 68 20 74 65 73 74 20  ; for each test 
8aa0: 69 6e 20 63 61 73 65 20 77 65 20 67 65 74 20 6b  in case we get k
8ab0: 69 6c 6c 65 64 2e 20 54 68 61 74 20 73 68 6f 75  illed. That shou
8ac0: 6c 64 20 6d 69 6e 69 6d 69 7a 65 20 74 68 65 20  ld minimize the 
8ad0: 64 65 74 72 69 74 75 73 20 6c 65 66 74 20 6f 6e  detritus left on
8ae0: 20 64 69 73 6b 0a 09 20 20 20 3b 3b 20 70 72 6f   disk..   ;; pro
8af0: 63 65 73 73 20 74 68 65 20 64 69 72 73 20 66 72  cess the dirs fr
8b00: 6f 6d 20 6c 6f 6e 67 65 73 74 20 73 74 72 69 6e  om longest strin
8b10: 67 20 6c 65 6e 67 74 68 20 74 6f 20 73 68 6f 72  g length to shor
8b20: 74 65 73 74 0a 09 20 20 20 28 66 6f 72 2d 65 61  test..   (for-ea
8b30: 63 68 20 0a 09 20 20 20 20 28 6c 61 6d 62 64 61  ch ..    (lambda
8b40: 20 28 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29   (dir-to-remove)
8b50: 0a 09 20 20 20 20 20 20 28 69 66 20 28 66 69 6c  ..      (if (fil
8b60: 65 2d 65 78 69 73 74 73 3f 20 64 69 72 2d 74 6f  e-exists? dir-to
8b70: 2d 72 65 6d 6f 76 65 29 0a 09 09 20 20 28 6c 65  -remove)...  (le
8b80: 74 20 28 28 64 69 72 2d 69 6e 2d 64 62 20 27 28  t ((dir-in-db '(
8b90: 29 29 29 0a 09 09 20 20 20 20 28 73 71 6c 69 74  )))...    (sqlit
8ba0: 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77 0a  e3:for-each-row.
8bb0: 09 09 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28  ..     (lambda (
8bc0: 64 69 72 29 0a 09 09 20 20 20 20 20 20 20 28 73  dir)...       (s
8bd0: 65 74 21 20 64 69 72 2d 69 6e 2d 64 62 20 28 63  et! dir-in-db (c
8be0: 6f 6e 73 20 64 69 72 20 64 69 72 2d 69 6e 2d 64  ons dir dir-in-d
8bf0: 62 29 29 29 0a 09 09 20 20 20 20 20 64 62 20 22  b)))...     db "
8c00: 53 45 4c 45 43 54 20 72 75 6e 64 69 72 20 46 52  SELECT rundir FR
8c10: 4f 4d 20 74 65 73 74 73 20 57 48 45 52 45 20 72  OM tests WHERE r
8c20: 75 6e 64 69 72 20 4c 49 4b 45 20 3f 3b 22 20 0a  undir LIKE ?;" .
8c30: 09 09 20 20 20 20 20 28 63 6f 6e 63 20 22 25 22  ..     (conc "%"
8c40: 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 20 22   dir-to-remove "
8c50: 25 22 29 29 20 3b 3b 20 79 65 73 2c 20 49 27 6d  %")) ;; yes, I'm
8c60: 20 67 6f 69 6e 67 20 74 6f 20 62 61 69 6c 20 69   going to bail i
8c70: 66 20 74 68 65 72 65 20 69 73 20 61 6e 79 74 68  f there is anyth
8c80: 69 6e 67 20 6c 69 6b 65 20 74 68 69 73 20 64 69  ing like this di
8c90: 72 20 69 6e 20 74 68 65 20 64 62 0a 09 09 20 20  r in the db...  
8ca0: 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 64 69 72    (if (null? dir
8cb0: 2d 69 6e 2d 64 62 29 0a 09 09 09 28 62 65 67 69  -in-db)....(begi
8cc0: 6e 0a 09 09 09 20 20 28 64 65 62 75 67 3a 70 72  n....  (debug:pr
8cd0: 69 6e 74 20 32 20 22 52 65 6d 6f 76 69 6e 67 20  int 2 "Removing 
8ce0: 64 69 72 65 63 74 6f 72 79 20 77 69 74 68 20 7a  directory with z
8cf0: 65 72 6f 20 64 62 20 72 65 66 65 72 65 6e 63 65  ero db reference
8d00: 73 3a 20 22 20 64 69 72 2d 74 6f 2d 72 65 6d 6f  s: " dir-to-remo
8d10: 76 65 29 0a 09 09 09 20 20 28 73 79 73 74 65 6d  ve)....  (system
8d20: 20 28 63 6f 6e 63 20 22 72 6d 20 2d 72 66 20 22   (conc "rm -rf "
8d30: 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 29   dir-to-remove))
8d40: 0a 09 09 09 20 20 28 68 61 73 68 2d 74 61 62 6c  ....  (hash-tabl
8d50: 65 2d 64 65 6c 65 74 65 21 20 64 69 72 73 2d 74  e-delete! dirs-t
8d60: 6f 2d 72 65 6d 6f 76 65 20 64 69 72 2d 74 6f 2d  o-remove dir-to-
8d70: 72 65 6d 6f 76 65 29 29 0a 09 09 09 28 64 65 62  remove))....(deb
8d80: 75 67 3a 70 72 69 6e 74 20 32 20 22 53 6b 69 70  ug:print 2 "Skip
8d90: 70 69 6e 67 20 72 65 6d 6f 76 61 6c 20 6f 66 20  ping removal of 
8da0: 22 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 20  " dir-to-remove 
8db0: 22 20 66 6f 72 20 6e 6f 77 20 61 73 20 69 74 20  " for now as it 
8dc0: 73 74 69 6c 6c 20 68 61 73 20 72 65 66 65 72 65  still has refere
8dd0: 6e 63 65 73 20 69 6e 20 74 68 65 20 64 61 74 61  nces in the data
8de0: 62 61 73 65 22 29 29 29 29 29 0a 09 20 20 20 20  base")))))..    
8df0: 28 73 6f 72 74 20 28 68 61 73 68 2d 74 61 62 6c  (sort (hash-tabl
8e00: 65 2d 6b 65 79 73 20 64 69 72 73 2d 74 6f 2d 72  e-keys dirs-to-r
8e10: 65 6d 6f 76 65 29 20 28 6c 61 6d 62 64 61 20 28  emove) (lambda (
8e20: 61 20 62 29 28 3e 20 28 73 74 72 69 6e 67 2d 6c  a b)(> (string-l
8e30: 65 6e 67 74 68 20 61 29 28 73 74 72 69 6e 67 2d  ength a)(string-
8e40: 6c 65 6e 67 74 68 20 62 29 29 29 29 29 0a 0a 09  length b)))))...
8e50: 20 20 20 3b 3b 20 72 65 6d 6f 76 65 20 74 68 65     ;; remove the
8e60: 20 72 75 6e 20 69 66 20 7a 65 72 6f 20 74 65 73   run if zero tes
8e70: 74 73 20 72 65 6d 61 69 6e 0a 09 20 20 20 28 6c  ts remain..   (l
8e80: 65 74 20 28 28 72 65 6d 74 65 73 74 73 20 28 64  et ((remtests (d
8e90: 62 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d  b-get-tests-for-
8ea0: 72 75 6e 20 64 62 20 28 64 62 3a 67 65 74 2d 76  run db (db:get-v
8eb0: 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72  alue-by-header r
8ec0: 75 6e 20 68 65 61 64 65 72 20 22 69 64 22 29 29  un header "id"))
8ed0: 29 29 0a 09 20 20 20 20 20 28 69 66 20 28 6e 75  ))..     (if (nu
8ee0: 6c 6c 3f 20 72 65 6d 74 65 73 74 73 29 20 3b 3b  ll? remtests) ;;
8ef0: 20 6e 6f 20 6d 6f 72 65 20 74 65 73 74 73 20 72   no more tests r
8f00: 65 6d 61 69 6e 69 6e 67 0a 09 09 20 28 6c 65 74  emaining... (let
8f10: 2a 20 28 28 64 70 61 72 74 73 20 20 28 73 74 72  * ((dparts  (str
8f20: 69 6e 67 2d 73 70 6c 69 74 20 6c 61 73 74 74 70  ing-split lasttp
8f30: 61 74 68 20 22 2f 22 29 29 0a 09 09 09 28 72 75  ath "/"))....(ru
8f40: 6e 70 61 74 68 20 28 63 6f 6e 63 20 22 2f 22 20  npath (conc "/" 
8f50: 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65  (string-interspe
8f60: 72 73 65 20 0a 09 09 09 09 09 20 20 20 20 28 74  rse ......    (t
8f70: 61 6b 65 20 64 70 61 72 74 73 20 28 2d 20 28 6c  ake dparts (- (l
8f80: 65 6e 67 74 68 20 64 70 61 72 74 73 29 20 31 29  ength dparts) 1)
8f90: 29 0a 09 09 09 09 09 20 20 20 20 22 2f 22 29 29  )......    "/"))
8fa0: 29 29 0a 09 09 20 20 20 28 64 65 62 75 67 3a 70  ))...   (debug:p
8fb0: 72 69 6e 74 20 31 20 22 52 65 6d 6f 76 69 6e 67  rint 1 "Removing
8fc0: 20 72 75 6e 3a 20 22 20 72 75 6e 6b 65 79 20 22   run: " runkey "
8fd0: 20 22 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65   " (db:get-value
8fe0: 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68  -by-header run h
8ff0: 65 61 64 65 72 20 22 72 75 6e 6e 61 6d 65 22 29  eader "runname")
9000: 29 0a 09 09 20 20 20 28 64 62 3a 64 65 6c 65 74  )...   (db:delet
9010: 65 2d 72 75 6e 20 64 62 20 72 75 6e 2d 69 64 29  e-run db run-id)
9020: 0a 09 09 20 20 20 3b 3b 20 6e 65 65 64 20 74 6f  ...   ;; need to
9030: 20 66 69 67 75 72 65 20 6f 75 74 20 74 68 65 20   figure out the 
9040: 70 61 74 68 20 74 6f 20 74 68 65 20 72 75 6e 20  path to the run 
9050: 64 69 72 20 61 6e 64 20 72 65 6d 6f 76 65 20 69  dir and remove i
9060: 74 20 69 66 20 65 6d 70 74 79 0a 09 09 20 20 20  t if empty...   
9070: 3b 3b 20 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f  ;;    (if (null?
9080: 20 28 67 6c 6f 62 20 28 63 6f 6e 63 20 72 75 6e   (glob (conc run
9090: 70 61 74 68 20 22 2f 2a 22 29 29 29 0a 09 09 20  path "/*")))... 
90a0: 20 20 3b 3b 20 20 20 20 20 20 20 20 28 62 65 67    ;;        (beg
90b0: 69 6e 0a 09 09 20 20 20 3b 3b 20 09 20 28 64 65  in...   ;; . (de
90c0: 62 75 67 3a 70 72 69 6e 74 20 31 20 22 52 65 6d  bug:print 1 "Rem
90d0: 6f 76 69 6e 67 20 72 75 6e 20 64 69 72 20 22 20  oving run dir " 
90e0: 72 75 6e 70 61 74 68 29 0a 09 09 20 20 20 3b 3b  runpath)...   ;;
90f0: 20 09 20 28 73 79 73 74 65 6d 20 28 63 6f 6e 63   . (system (conc
9100: 20 22 72 6d 64 69 72 20 2d 70 20 22 20 72 75 6e   "rmdir -p " run
9110: 70 61 74 68 29 29 29 29 0a 09 09 20 20 20 29 29  path))))...   ))
9120: 29 29 0a 09 20 29 29 0a 20 20 20 20 20 72 75 6e  )).. )).     run
9130: 73 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d  s)))..;;========
9140: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9150: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9160: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9170: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b  ==============.;
9180: 3b 20 52 6f 75 74 69 6e 65 73 20 66 6f 72 20 6d  ; Routines for m
9190: 61 6e 69 70 75 6c 61 74 69 6e 67 20 72 75 6e 73  anipulating runs
91a0: 0a 3b 3b 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 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
91d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
91e0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 53 69  =========..;; Si
91f0: 6e 63 65 20 6d 61 6e 79 20 63 61 6c 6c 73 20 74  nce many calls t
9200: 6f 20 61 20 72 75 6e 20 72 65 71 75 69 72 65 20  o a run require 
9210: 70 72 65 74 74 79 20 6d 75 63 68 20 74 68 65 20  pretty much the 
9220: 73 61 6d 65 20 73 65 74 75 70 20 0a 3b 3b 20 74  same setup .;; t
9230: 68 69 73 20 77 72 61 70 70 65 72 20 69 73 20 75  his wrapper is u
9240: 73 65 64 20 74 6f 20 72 65 64 75 63 65 20 74 68  sed to reduce th
9250: 65 20 72 65 70 6c 69 63 61 74 69 6f 6e 20 6f 66  e replication of
9260: 20 63 6f 64 65 0a 28 64 65 66 69 6e 65 20 28 67   code.(define (g
9270: 65 6e 65 72 61 6c 2d 72 75 6e 2d 63 61 6c 6c 20  eneral-run-call 
9280: 73 77 69 74 63 68 6e 61 6d 65 20 61 63 74 69 6f  switchname actio
9290: 6e 2d 64 65 73 63 20 70 72 6f 63 29 0a 20 20 28  n-desc proc).  (
92a0: 69 66 20 28 6e 6f 74 20 28 61 72 67 73 3a 67 65  if (not (args:ge
92b0: 74 2d 61 72 67 20 22 3a 72 75 6e 6e 61 6d 65 22  t-arg ":runname"
92c0: 29 29 0a 20 20 20 20 20 20 28 62 65 67 69 6e 0a  )).      (begin.
92d0: 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20  .(debug:print 0 
92e0: 22 45 52 52 4f 52 3a 20 4d 69 73 73 69 6e 67 20  "ERROR: Missing 
92f0: 72 65 71 75 69 72 65 64 20 70 61 72 61 6d 65 74  required paramet
9300: 65 72 20 66 6f 72 20 22 20 73 77 69 74 63 68 6e  er for " switchn
9310: 61 6d 65 20 22 2c 20 79 6f 75 20 6d 75 73 74 20  ame ", you must 
9320: 73 70 65 63 69 66 79 20 74 68 65 20 72 75 6e 20  specify the run 
9330: 6e 61 6d 65 20 77 69 74 68 20 3a 72 75 6e 6e 61  name with :runna
9340: 6d 65 20 72 75 6e 6e 61 6d 65 22 29 0a 09 28 65  me runname")..(e
9350: 78 69 74 20 32 29 29 0a 20 20 20 20 20 20 28 6c  xit 2)).      (l
9360: 65 74 20 28 28 64 62 20 23 66 29 29 0a 09 28 69  et ((db #f))..(i
9370: 66 20 28 6e 6f 74 20 28 73 65 74 75 70 2d 66 6f  f (not (setup-fo
9380: 72 2d 72 75 6e 29 29 0a 09 20 20 20 20 28 62 65  r-run))..    (be
9390: 67 69 6e 20 0a 09 20 20 20 20 20 20 28 64 65 62  gin ..      (deb
93a0: 75 67 3a 70 72 69 6e 74 20 30 20 22 46 61 69 6c  ug:print 0 "Fail
93b0: 65 64 20 74 6f 20 73 65 74 75 70 2c 20 65 78 69  ed to setup, exi
93c0: 74 69 6e 67 22 29 0a 09 20 20 20 20 20 20 28 65  ting")..      (e
93d0: 78 69 74 20 31 29 29 29 0a 09 28 73 65 74 21 20  xit 1)))..(set! 
93e0: 64 62 20 28 6f 70 65 6e 2d 64 62 29 29 0a 09 28  db (open-db))..(
93f0: 69 66 20 28 6e 6f 74 20 28 63 61 72 20 2a 63 6f  if (not (car *co
9400: 6e 66 69 67 69 6e 66 6f 2a 29 29 0a 09 20 20 20  nfiginfo*))..   
9410: 20 28 62 65 67 69 6e 0a 09 20 20 20 20 20 20 28   (begin..      (
9420: 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45  debug:print 0 "E
9430: 52 52 4f 52 3a 20 41 74 74 65 6d 70 74 65 64 20  RROR: Attempted 
9440: 74 6f 20 22 20 61 63 74 69 6f 6e 2d 64 65 73 63  to " action-desc
9450: 20 22 20 62 75 74 20 72 75 6e 20 61 72 65 61 20   " but run area 
9460: 63 6f 6e 66 69 67 20 66 69 6c 65 20 6e 6f 74 20  config file not 
9470: 66 6f 75 6e 64 22 29 0a 09 20 20 20 20 20 20 28  found")..      (
9480: 65 78 69 74 20 31 29 29 0a 09 20 20 20 20 3b 3b  exit 1))..    ;;
9490: 20 45 78 74 72 61 63 74 20 6f 75 74 20 73 74 75   Extract out stu
94a0: 66 66 20 6e 65 65 64 65 64 20 69 6e 20 6d 6f 73  ff needed in mos
94b0: 74 20 6f 72 20 6d 61 6e 79 20 63 61 6c 6c 73 0a  t or many calls.
94c0: 09 20 20 20 20 3b 3b 20 68 65 72 65 20 74 68 65  .    ;; here the
94d0: 6e 20 63 61 6c 6c 20 70 72 6f 63 0a 09 20 20 20  n call proc..   
94e0: 20 28 6c 65 74 2a 20 28 28 6b 65 79 73 20 20 20   (let* ((keys   
94f0: 20 20 20 20 28 64 62 2d 67 65 74 2d 6b 65 79 73      (db-get-keys
9500: 20 64 62 29 29 0a 09 09 20 20 20 28 6b 65 79 6e   db))...   (keyn
9510: 61 6d 65 73 20 20 20 28 6d 61 70 20 6b 65 79 3a  ames   (map key:
9520: 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65  get-fieldname ke
9530: 79 73 29 29 0a 09 09 20 20 20 28 6b 65 79 76 61  ys))...   (keyva
9540: 6c 6c 73 74 20 20 28 6b 65 79 73 2d 3e 76 61 6c  llst  (keys->val
9550: 6c 69 73 74 20 6b 65 79 73 20 23 74 29 29 29 0a  list keys #t))).
9560: 09 20 20 20 20 20 20 28 70 72 6f 63 20 64 62 20  .      (proc db 
9570: 6b 65 79 73 20 6b 65 79 6e 61 6d 65 73 20 6b 65  keys keynames ke
9580: 79 76 61 6c 6c 73 74 29 29 29 0a 09 28 73 71 6c  yvallst)))..(sql
9590: 69 74 65 33 3a 66 69 6e 61 6c 69 7a 65 21 20 64  ite3:finalize! d
95a0: 62 29 0a 09 28 73 65 74 21 20 2a 64 69 64 73 6f  b)..(set! *didso
95b0: 6d 65 74 68 69 6e 67 2a 20 23 74 29 29 29 29 0a  mething* #t)))).
95c0: 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  .;;=============
95d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
95e0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
95f0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9600: 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 52 6f 6c  =========.;; Rol
9610: 6c 75 70 20 72 75 6e 73 0a 3b 3b 3d 3d 3d 3d 3d  lup runs.;;=====
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 3d 3d  ================
9650: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9660: 3d 0a 0a 3b 3b 20 55 70 64 61 74 65 20 74 68 65  =..;; Update the
9670: 20 74 65 73 74 5f 6d 65 74 61 20 74 61 62 6c 65   test_meta table
9680: 20 66 6f 72 20 74 68 69 73 20 74 65 73 74 0a 28   for this test.(
9690: 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 75 70 64  define (runs:upd
96a0: 61 74 65 2d 74 65 73 74 5f 6d 65 74 61 20 64 62  ate-test_meta db
96b0: 20 74 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 2d   test-name test-
96c0: 63 6f 6e 66 29 0a 20 20 28 6c 65 74 20 28 28 63  conf).  (let ((c
96d0: 75 72 72 72 65 63 6f 72 64 20 28 64 62 3a 74 65  urrrecord (db:te
96e0: 73 74 6d 65 74 61 2d 67 65 74 2d 72 65 63 6f 72  stmeta-get-recor
96f0: 64 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 29 29  d db test-name))
9700: 29 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 63  ).    (if (not c
9710: 75 72 72 72 65 63 6f 72 64 29 0a 09 28 62 65 67  urrrecord)..(beg
9720: 69 6e 0a 09 20 20 28 73 65 74 21 20 63 75 72 72  in..  (set! curr
9730: 72 65 63 6f 72 64 20 28 6d 61 6b 65 2d 76 65 63  record (make-vec
9740: 74 6f 72 20 31 30 20 23 66 29 29 0a 09 20 20 28  tor 10 #f))..  (
9750: 64 62 3a 74 65 73 74 6d 65 74 61 2d 61 64 64 2d  db:testmeta-add-
9760: 72 65 63 6f 72 64 20 64 62 20 74 65 73 74 2d 6e  record db test-n
9770: 61 6d 65 29 29 29 0a 20 20 20 20 28 66 6f 72 2d  ame))).    (for-
9780: 65 61 63 68 20 0a 20 20 20 20 20 28 6c 61 6d 62  each .     (lamb
9790: 64 61 20 28 6b 65 79 29 0a 20 20 20 20 20 20 20  da (key).       
97a0: 28 6c 65 74 2a 20 28 28 69 64 78 20 28 63 61 64  (let* ((idx (cad
97b0: 72 20 6b 65 79 29 29 0a 09 20 20 20 20 20 20 28  r key))..      (
97c0: 66 6c 64 20 28 63 61 72 20 20 6b 65 79 29 29 0a  fld (car  key)).
97d0: 09 20 20 20 20 20 20 28 76 61 6c 20 28 63 6f 6e  .      (val (con
97e0: 66 69 67 2d 6c 6f 6f 6b 75 70 20 74 65 73 74 2d  fig-lookup test-
97f0: 63 6f 6e 66 20 22 74 65 73 74 5f 6d 65 74 61 22  conf "test_meta"
9800: 20 66 6c 64 29 29 29 0a 09 20 28 69 66 20 28 61   fld))).. (if (a
9810: 6e 64 20 76 61 6c 20 28 6e 6f 74 20 28 65 71 75  nd val (not (equ
9820: 61 6c 3f 20 28 76 65 63 74 6f 72 2d 72 65 66 20  al? (vector-ref 
9830: 63 75 72 72 72 65 63 6f 72 64 20 69 64 78 29 20  currrecord idx) 
9840: 76 61 6c 29 29 29 0a 09 20 20 20 20 20 28 62 65  val)))..     (be
9850: 67 69 6e 0a 09 20 20 20 20 20 20 20 28 70 72 69  gin..       (pri
9860: 6e 74 20 22 55 70 64 61 74 69 6e 67 20 22 20 74  nt "Updating " t
9870: 65 73 74 2d 6e 61 6d 65 20 22 20 22 20 66 6c 64  est-name " " fld
9880: 20 22 20 74 6f 20 22 20 76 61 6c 29 0a 09 20 20   " to " val)..  
9890: 20 20 20 20 20 28 64 62 3a 74 65 73 74 6d 65 74       (db:testmet
98a0: 61 2d 75 70 64 61 74 65 2d 66 69 65 6c 64 20 64  a-update-field d
98b0: 62 20 74 65 73 74 2d 6e 61 6d 65 20 66 6c 64 20  b test-name fld 
98c0: 76 61 6c 29 29 29 29 29 0a 20 20 20 20 20 27 28  val))))).     '(
98d0: 28 22 61 75 74 68 6f 72 22 20 32 29 28 22 6f 77  ("author" 2)("ow
98e0: 6e 65 72 22 20 33 29 28 22 64 65 73 63 72 69 70  ner" 3)("descrip
98f0: 74 69 6f 6e 22 20 34 29 28 22 72 65 76 69 65 77  tion" 4)("review
9900: 65 64 22 20 35 29 28 22 74 61 67 73 22 20 39 29  ed" 5)("tags" 9)
9910: 29 29 29 29 0a 0a 3b 3b 20 55 70 64 61 74 65 20  ))))..;; Update 
9920: 74 65 73 74 5f 6d 65 74 61 20 66 6f 72 20 61 6c  test_meta for al
9930: 6c 20 74 65 73 74 73 0a 28 64 65 66 69 6e 65 20  l tests.(define 
9940: 28 72 75 6e 73 3a 75 70 64 61 74 65 2d 61 6c 6c  (runs:update-all
9950: 2d 74 65 73 74 5f 6d 65 74 61 20 64 62 29 0a 20  -test_meta db). 
9960: 20 28 6c 65 74 20 28 28 74 65 73 74 2d 6e 61 6d   (let ((test-nam
9970: 65 73 20 28 67 65 74 2d 61 6c 6c 2d 6c 65 67 61  es (get-all-lega
9980: 6c 2d 74 65 73 74 73 29 29 29 0a 20 20 20 20 28  l-tests))).    (
9990: 66 6f 72 2d 65 61 63 68 20 0a 20 20 20 20 20 28  for-each .     (
99a0: 6c 61 6d 62 64 61 20 28 74 65 73 74 2d 6e 61 6d  lambda (test-nam
99b0: 65 29 0a 20 20 20 20 20 20 20 28 6c 65 74 2a 20  e).       (let* 
99c0: 28 28 74 65 73 74 2d 70 61 74 68 20 20 20 20 28  ((test-path    (
99d0: 63 6f 6e 63 20 2a 74 6f 70 70 61 74 68 2a 20 22  conc *toppath* "
99e0: 2f 74 65 73 74 73 2f 22 20 74 65 73 74 2d 6e 61  /tests/" test-na
99f0: 6d 65 29 29 0a 09 20 20 20 20 20 20 28 74 65 73  me))..      (tes
9a00: 74 2d 63 6f 6e 66 69 67 66 20 28 63 6f 6e 63 20  t-configf (conc 
9a10: 74 65 73 74 2d 70 61 74 68 20 22 2f 74 65 73 74  test-path "/test
9a20: 63 6f 6e 66 69 67 22 29 29 0a 09 20 20 20 20 20  config"))..     
9a30: 20 28 74 65 73 74 65 78 69 73 74 73 20 20 20 28   (testexists   (
9a40: 61 6e 64 20 28 66 69 6c 65 2d 65 78 69 73 74 73  and (file-exists
9a50: 3f 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 29 28  ? test-configf)(
9a60: 66 69 6c 65 2d 72 65 61 64 2d 61 63 63 65 73 73  file-read-access
9a70: 3f 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 29 29  ? test-configf))
9a80: 29 0a 09 20 20 20 20 20 20 3b 3b 20 72 65 61 64  )..      ;; read
9a90: 20 63 6f 6e 66 69 67 73 20 77 69 74 68 20 74 72   configs with tr
9aa0: 69 63 6b 73 20 74 75 72 6e 65 64 20 6f 66 66 20  icks turned off 
9ab0: 28 69 2e 65 2e 20 6e 6f 20 73 79 73 74 65 6d 29  (i.e. no system)
9ac0: 0a 09 20 20 20 20 20 20 28 74 65 73 74 2d 63 6f  ..      (test-co
9ad0: 6e 66 20 20 20 20 28 69 66 20 74 65 73 74 65 78  nf    (if testex
9ae0: 69 73 74 73 20 28 72 65 61 64 2d 63 6f 6e 66 69  ists (read-confi
9af0: 67 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 20 23  g test-configf #
9b00: 66 20 23 66 29 28 6d 61 6b 65 2d 68 61 73 68 2d  f #f)(make-hash-
9b10: 74 61 62 6c 65 29 29 29 29 0a 09 20 28 72 75 6e  table)))).. (run
9b20: 73 3a 75 70 64 61 74 65 2d 74 65 73 74 5f 6d 65  s:update-test_me
9b30: 74 61 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 20  ta db test-name 
9b40: 74 65 73 74 2d 63 6f 6e 66 29 29 29 0a 20 20 20  test-conf))).   
9b50: 20 20 74 65 73 74 2d 6e 61 6d 65 73 29 29 29 0a    test-names))).
9b60: 09 20 0a 3b 3b 20 54 68 69 73 20 63 6f 75 6c 64  . .;; This could
9b70: 20 70 72 6f 62 61 62 6c 79 20 62 65 20 72 65 66   probably be ref
9b80: 61 63 74 6f 72 65 64 20 69 6e 74 6f 20 6f 6e 65  actored into one
9b90: 20 63 6f 6d 70 6c 65 78 20 71 75 65 72 79 20 2e   complex query .
9ba0: 2e 2e 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73  ...(define (runs
9bb0: 3a 72 6f 6c 6c 75 70 2d 72 75 6e 20 64 62 20 6b  :rollup-run db k
9bc0: 65 79 73 29 0a 20 20 28 6c 65 74 2a 20 28 28 6e  eys).  (let* ((n
9bd0: 65 77 2d 72 75 6e 2d 69 64 20 20 20 20 20 20 28  ew-run-id      (
9be0: 72 65 67 69 73 74 65 72 2d 72 75 6e 20 64 62 20  register-run db 
9bf0: 6b 65 79 73 29 29 0a 09 20 28 70 72 65 76 2d 74  keys)).. (prev-t
9c00: 65 73 74 73 20 20 20 20 20 20 28 74 65 73 74 3a  ests      (test:
9c10: 67 65 74 2d 6d 61 74 63 68 69 6e 67 2d 70 72 65  get-matching-pre
9c20: 76 69 6f 75 73 2d 74 65 73 74 2d 72 75 6e 2d 72  vious-test-run-r
9c30: 65 63 6f 72 64 73 20 64 62 20 6e 65 77 2d 72 75  ecords db new-ru
9c40: 6e 2d 69 64 20 22 25 22 20 22 25 22 29 29 0a 09  n-id "%" "%"))..
9c50: 20 28 63 75 72 72 2d 74 65 73 74 73 20 20 20 20   (curr-tests    
9c60: 20 20 28 64 62 2d 67 65 74 2d 74 65 73 74 73 2d    (db-get-tests-
9c70: 66 6f 72 2d 72 75 6e 20 64 62 20 6e 65 77 2d 72  for-run db new-r
9c80: 75 6e 2d 69 64 20 22 25 22 20 22 25 22 29 29 0a  un-id "%" "%")).
9c90: 09 20 28 63 75 72 72 2d 74 65 73 74 73 2d 68 61  . (curr-tests-ha
9ca0: 73 68 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61  sh (make-hash-ta
9cb0: 62 6c 65 29 29 29 0a 20 20 20 20 3b 3b 20 69 6e  ble))).    ;; in
9cc0: 64 65 78 20 74 68 65 20 61 6c 72 65 61 64 79 20  dex the already 
9cd0: 73 61 76 65 64 20 74 65 73 74 73 20 62 79 20 74  saved tests by t
9ce0: 65 73 74 6e 61 6d 65 20 61 6e 64 20 69 74 65 6d  estname and item
9cf0: 70 61 74 68 20 69 6e 20 63 75 72 72 2d 74 65 73  path in curr-tes
9d00: 74 73 2d 68 61 73 68 0a 20 20 20 20 28 66 6f 72  ts-hash.    (for
9d10: 2d 65 61 63 68 0a 20 20 20 20 20 28 6c 61 6d 62  -each.     (lamb
9d20: 64 61 20 28 74 65 73 74 64 61 74 29 0a 20 20 20  da (testdat).   
9d30: 20 20 20 20 28 6c 65 74 2a 20 28 28 74 65 73 74      (let* ((test
9d40: 6e 61 6d 65 20 20 28 64 62 3a 74 65 73 74 2d 67  name  (db:test-g
9d50: 65 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74  et-testname test
9d60: 64 61 74 29 29 0a 09 20 20 20 20 20 20 28 69 74  dat))..      (it
9d70: 65 6d 2d 70 61 74 68 20 28 64 62 3a 74 65 73 74  em-path (db:test
9d80: 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74  -get-item-path t
9d90: 65 73 74 64 61 74 29 29 0a 09 20 20 20 20 20 20  estdat))..      
9da0: 28 66 75 6c 6c 2d 6e 61 6d 65 20 28 63 6f 6e 63  (full-name (conc
9db0: 20 74 65 73 74 6e 61 6d 65 20 22 2f 22 20 69 74   testname "/" it
9dc0: 65 6d 2d 70 61 74 68 29 29 29 0a 09 20 28 68 61  em-path))).. (ha
9dd0: 73 68 2d 74 61 62 6c 65 2d 73 65 74 21 20 63 75  sh-table-set! cu
9de0: 72 72 2d 74 65 73 74 73 2d 68 61 73 68 20 66 75  rr-tests-hash fu
9df0: 6c 6c 2d 6e 61 6d 65 20 74 65 73 74 64 61 74 29  ll-name testdat)
9e00: 29 29 0a 20 20 20 20 20 63 75 72 72 2d 74 65 73  )).     curr-tes
9e10: 74 73 29 0a 20 20 20 20 3b 3b 20 4e 4f 50 45 3a  ts).    ;; NOPE:
9e20: 20 4e 6f 6e 2d 6f 70 74 69 6d 61 6c 20 61 70 70   Non-optimal app
9e30: 72 6f 61 63 68 2e 20 54 72 79 20 74 68 69 73 20  roach. Try this 
9e40: 69 6e 73 74 65 61 64 2e 0a 20 20 20 20 3b 3b 20  instead..    ;; 
9e50: 20 20 31 2e 20 74 65 73 74 73 20 61 72 65 20 72    1. tests are r
9e60: 65 63 65 69 76 65 64 20 69 6e 20 61 20 6c 69 73  eceived in a lis
9e70: 74 2c 20 6d 6f 73 74 20 72 65 63 65 6e 74 20 66  t, most recent f
9e80: 69 72 73 74 0a 20 20 20 20 3b 3b 20 20 20 32 2e  irst.    ;;   2.
9e90: 20 72 65 70 6c 61 63 65 20 74 68 65 20 72 6f 6c   replace the rol
9ea0: 6c 75 70 20 74 65 73 74 20 77 69 74 68 20 74 68  lup test with th
9eb0: 65 20 6e 65 77 20 2a 61 6c 77 61 79 73 2a 0a 20  e new *always*. 
9ec0: 20 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 20     (for-each .  
9ed0: 20 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74     (lambda (test
9ee0: 64 61 74 29 0a 20 20 20 20 20 20 20 28 6c 65 74  dat).       (let
9ef0: 2a 20 28 28 74 65 73 74 6e 61 6d 65 20 20 28 64  * ((testname  (d
9f00: 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e  b:test-get-testn
9f10: 61 6d 65 20 74 65 73 74 64 61 74 29 29 0a 09 20  ame testdat)).. 
9f20: 20 20 20 20 20 28 69 74 65 6d 2d 70 61 74 68 20       (item-path 
9f30: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65  (db:test-get-ite
9f40: 6d 2d 70 61 74 68 20 74 65 73 74 64 61 74 29 29  m-path testdat))
9f50: 0a 09 20 20 20 20 20 20 28 66 75 6c 6c 2d 6e 61  ..      (full-na
9f60: 6d 65 20 28 63 6f 6e 63 20 74 65 73 74 6e 61 6d  me (conc testnam
9f70: 65 20 22 2f 22 20 69 74 65 6d 2d 70 61 74 68 29  e "/" item-path)
9f80: 29 0a 09 20 20 20 20 20 20 28 70 72 65 76 2d 74  )..      (prev-t
9f90: 65 73 74 2d 64 61 74 20 28 68 61 73 68 2d 74 61  est-dat (hash-ta
9fa0: 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20  ble-ref/default 
9fb0: 63 75 72 72 2d 74 65 73 74 73 2d 68 61 73 68 20  curr-tests-hash 
9fc0: 66 75 6c 6c 2d 6e 61 6d 65 20 23 66 29 29 0a 09  full-name #f))..
9fd0: 20 20 20 20 20 20 28 74 65 73 74 2d 73 74 65 70        (test-step
9fe0: 73 20 20 20 20 20 20 28 64 62 3a 67 65 74 2d 73  s      (db:get-s
9ff0: 74 65 70 73 2d 66 6f 72 2d 74 65 73 74 20 64 62  teps-for-test db
a000: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64   (db:test-get-id
a010: 20 74 65 73 74 64 61 74 29 29 29 0a 09 20 20 20   testdat)))..   
a020: 20 20 20 28 6e 65 77 2d 74 65 73 74 2d 72 65 63     (new-test-rec
a030: 6f 72 64 20 23 66 29 29 0a 09 20 3b 3b 20 72 65  ord #f)).. ;; re
a040: 70 6c 61 63 65 20 74 68 65 73 65 20 77 69 74 68  place these with
a050: 20 69 6e 73 65 72 74 20 2e 2e 2e 20 73 65 6c 65   insert ... sele
a060: 63 74 0a 09 20 28 61 70 70 6c 79 20 73 71 6c 69  ct.. (apply sqli
a070: 74 65 33 3a 65 78 65 63 75 74 65 20 0a 09 09 64  te3:execute ...d
a080: 62 20 0a 09 09 28 63 6f 6e 63 20 22 49 4e 53 45  b ...(conc "INSE
a090: 52 54 20 4f 52 20 52 45 50 4c 41 43 45 20 49 4e  RT OR REPLACE IN
a0a0: 54 4f 20 74 65 73 74 73 20 28 72 75 6e 5f 69 64  TO tests (run_id
a0b0: 2c 74 65 73 74 6e 61 6d 65 2c 73 74 61 74 65 2c  ,testname,state,
a0c0: 73 74 61 74 75 73 2c 65 76 65 6e 74 5f 74 69 6d  status,event_tim
a0d0: 65 2c 68 6f 73 74 2c 63 70 75 6c 6f 61 64 2c 64  e,host,cpuload,d
a0e0: 69 73 6b 66 72 65 65 2c 75 6e 61 6d 65 2c 72 75  iskfree,uname,ru
a0f0: 6e 64 69 72 2c 69 74 65 6d 5f 70 61 74 68 2c 72  ndir,item_path,r
a100: 75 6e 5f 64 75 72 61 74 69 6f 6e 2c 66 69 6e 61  un_duration,fina
a110: 6c 5f 6c 6f 67 66 2c 63 6f 6d 6d 65 6e 74 2c 66  l_logf,comment,f
a120: 69 72 73 74 5f 65 72 72 2c 66 69 72 73 74 5f 77  irst_err,first_w
a130: 61 72 6e 29 20 22 0a 09 09 20 20 20 20 20 20 22  arn) "...      "
a140: 56 41 4c 55 45 53 20 28 3f 2c 3f 2c 3f 2c 3f 2c  VALUES (?,?,?,?,
a150: 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c  ?,?,?,?,?,?,?,?,
a160: 3f 2c 3f 2c 3f 2c 3f 29 3b 22 29 0a 09 09 6e 65  ?,?,?,?);")...ne
a170: 77 2d 72 75 6e 2d 69 64 20 28 63 64 64 72 20 28  w-run-id (cddr (
a180: 76 65 63 74 6f 72 2d 3e 6c 69 73 74 20 74 65 73  vector->list tes
a190: 74 64 61 74 29 29 29 0a 09 20 28 73 65 74 21 20  tdat))).. (set! 
a1a0: 6e 65 77 2d 74 65 73 74 64 61 74 20 28 63 61 72  new-testdat (car
a1b0: 20 28 64 62 2d 67 65 74 2d 74 65 73 74 73 2d 66   (db-get-tests-f
a1c0: 6f 72 2d 72 75 6e 20 64 62 20 6e 65 77 2d 72 75  or-run db new-ru
a1d0: 6e 2d 69 64 20 74 65 73 74 6e 61 6d 65 20 69 74  n-id testname it
a1e0: 65 6d 2d 70 61 74 68 29 29 29 0a 09 20 28 68 61  em-path))).. (ha
a1f0: 73 68 2d 74 61 62 6c 65 2d 73 65 74 21 20 63 75  sh-table-set! cu
a200: 72 72 2d 74 65 73 74 73 2d 68 61 73 68 20 66 75  rr-tests-hash fu
a210: 6c 6c 2d 6e 61 6d 65 20 6e 65 77 2d 74 65 73 74  ll-name new-test
a220: 64 61 74 29 20 3b 3b 20 74 68 69 73 20 63 6f 75  dat) ;; this cou
a230: 6c 64 20 62 65 20 63 6f 6e 66 75 73 69 6e 67 2c  ld be confusing,
a240: 20 77 68 69 63 68 20 72 65 63 6f 72 64 20 73 68   which record sh
a250: 6f 75 6c 64 20 67 6f 20 69 6e 74 6f 20 74 68 65  ould go into the
a260: 20 6c 6f 6f 6b 75 70 20 74 61 62 6c 65 3f 0a 09   lookup table?..
a270: 20 3b 3b 20 4e 6f 77 20 64 75 70 6c 69 63 61 74   ;; Now duplicat
a280: 65 20 74 68 65 20 74 65 73 74 20 73 74 65 70 73  e the test steps
a290: 0a 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20  .. (debug:print 
a2a0: 34 20 22 43 6f 70 79 69 6e 67 20 72 65 63 6f 72  4 "Copying recor
a2b0: 64 73 20 69 6e 20 74 65 73 74 5f 73 74 65 70 73  ds in test_steps
a2c0: 20 66 72 6f 6d 20 74 65 73 74 5f 69 64 3d 22 20   from test_id=" 
a2d0: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20  (db:test-get-id 
a2e0: 74 65 73 74 64 61 74 29 20 22 20 74 6f 20 22 20  testdat) " to " 
a2f0: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20  (db:test-get-id 
a300: 6e 65 77 2d 74 65 73 74 64 61 74 29 29 0a 09 20  new-testdat)).. 
a310: 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65  (sqlite3:execute
a320: 20 0a 09 20 20 64 62 20 0a 09 20 20 28 63 6f 6e   ..  db ..  (con
a330: 63 20 22 49 4e 53 45 52 54 20 4f 52 20 52 45 50  c "INSERT OR REP
a340: 4c 41 43 45 20 49 4e 54 4f 20 74 65 73 74 5f 73  LACE INTO test_s
a350: 74 65 70 73 20 28 74 65 73 74 5f 69 64 2c 73 74  teps (test_id,st
a360: 65 70 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 61  epname,state,sta
a370: 74 75 73 2c 65 76 65 6e 74 5f 74 69 6d 65 2c 63  tus,event_time,c
a380: 6f 6d 6d 65 6e 74 29 20 22 0a 09 09 22 53 45 4c  omment) "..."SEL
a390: 45 43 54 20 22 20 28 64 62 3a 74 65 73 74 2d 67  ECT " (db:test-g
a3a0: 65 74 2d 69 64 20 6e 65 77 2d 74 65 73 74 64 61  et-id new-testda
a3b0: 74 29 20 22 2c 73 74 65 70 6e 61 6d 65 2c 73 74  t) ",stepname,st
a3c0: 61 74 65 2c 73 74 61 74 75 73 2c 65 76 65 6e 74  ate,status,event
a3d0: 5f 74 69 6d 65 2c 63 6f 6d 6d 65 6e 74 20 46 52  _time,comment FR
a3e0: 4f 4d 20 74 65 73 74 5f 73 74 65 70 73 20 57 48  OM test_steps WH
a3f0: 45 52 45 20 74 65 73 74 5f 69 64 3d 3f 3b 22 29  ERE test_id=?;")
a400: 0a 09 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74  ..  (db:test-get
a410: 2d 69 64 20 74 65 73 74 64 61 74 29 29 0a 09 20  -id testdat)).. 
a420: 3b 3b 20 4e 6f 77 20 64 75 70 6c 69 63 61 74 65  ;; Now duplicate
a430: 20 74 68 65 20 74 65 73 74 20 64 61 74 61 0a 09   the test data..
a440: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20   (debug:print 4 
a450: 22 43 6f 70 79 69 6e 67 20 72 65 63 6f 72 64 73  "Copying records
a460: 20 69 6e 20 74 65 73 74 5f 64 61 74 61 20 66 72   in test_data fr
a470: 6f 6d 20 74 65 73 74 5f 69 64 3d 22 20 28 64 62  om test_id=" (db
a480: 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73  :test-get-id tes
a490: 74 64 61 74 29 20 22 20 74 6f 20 22 20 28 64 62  tdat) " to " (db
a4a0: 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 6e 65 77  :test-get-id new
a4b0: 2d 74 65 73 74 64 61 74 29 29 0a 09 20 28 73 71  -testdat)).. (sq
a4c0: 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 0a 09  lite3:execute ..
a4d0: 20 20 64 62 20 0a 09 20 20 28 63 6f 6e 63 20 22    db ..  (conc "
a4e0: 49 4e 53 45 52 54 20 4f 52 20 52 45 50 4c 41 43  INSERT OR REPLAC
a4f0: 45 20 49 4e 54 4f 20 74 65 73 74 5f 64 61 74 61  E INTO test_data
a500: 20 28 74 65 73 74 5f 69 64 2c 63 61 74 65 67 6f   (test_id,catego
a510: 72 79 2c 76 61 72 69 61 62 6c 65 2c 76 61 6c 75  ry,variable,valu
a520: 65 2c 65 78 70 65 63 74 65 64 2c 74 6f 6c 2c 75  e,expected,tol,u
a530: 6e 69 74 73 2c 63 6f 6d 6d 65 6e 74 29 20 22 0a  nits,comment) ".
a540: 09 09 22 53 45 4c 45 43 54 20 22 20 28 64 62 3a  .."SELECT " (db:
a550: 74 65 73 74 2d 67 65 74 2d 69 64 20 6e 65 77 2d  test-get-id new-
a560: 74 65 73 74 64 61 74 29 20 22 2c 63 61 74 65 67  testdat) ",categ
a570: 6f 72 79 2c 76 61 72 69 61 62 6c 65 2c 76 61 6c  ory,variable,val
a580: 75 65 2c 65 78 70 65 63 74 65 64 2c 74 6f 6c 2c  ue,expected,tol,
a590: 75 6e 69 74 73 2c 63 6f 6d 6d 65 6e 74 20 46 52  units,comment FR
a5a0: 4f 4d 20 74 65 73 74 5f 64 61 74 61 20 57 48 45  OM test_data WHE
a5b0: 52 45 20 74 65 73 74 5f 69 64 3d 3f 3b 22 29 0a  RE test_id=?;").
a5c0: 09 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  .  (db:test-get-
a5d0: 69 64 20 74 65 73 74 64 61 74 29 29 0a 09 20 29  id testdat)).. )
a5e0: 29 0a 20 20 20 20 20 70 72 65 76 2d 74 65 73 74  ).     prev-test
a5f0: 73 29 29 29 0a 09 20 0a 20 20 20 20 20 0a        s))).. .     .