Megatest

Hex Artifact Content
Login

Artifact 19e8e11b2fd0f1cef779ee267ac570175972c7a4:


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 20 28 64  aths )))..;;  (d
0de0: 65 66 69 6e 65 20 64 62 20 28 6f 70 65 6e 2d 64  efine db (open-d
0df0: 62 29 29 0a 3b 3b 20 20 28 74 65 73 74 2d 73 65  b)).;;  (test-se
0e00: 74 2d 73 74 61 74 75 73 21 20 64 62 20 32 20 22  t-status! db 2 "
0e10: 72 75 6e 66 69 72 73 74 22 20 22 43 4f 4d 50 4c  runfirst" "COMPL
0e20: 45 54 45 44 22 20 22 50 41 53 53 22 20 22 73 75  ETED" "PASS" "su
0e30: 6d 6d 65 72 22 29 0a 0a 28 64 65 66 69 6e 65 20  mmer")..(define 
0e40: 28 74 65 73 74 2d 73 65 74 2d 73 74 61 74 75 73  (test-set-status
0e50: 21 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  ! db run-id test
0e60: 2d 6e 61 6d 65 20 73 74 61 74 65 20 73 74 61 74  -name state stat
0e70: 75 73 20 69 74 65 6d 64 61 74 2d 6f 72 2d 70 61  us itemdat-or-pa
0e80: 74 68 20 63 6f 6d 6d 65 6e 74 20 64 61 74 29 0a  th comment dat).
0e90: 20 20 28 6c 65 74 20 28 28 69 74 65 6d 2d 70 61    (let ((item-pa
0ea0: 74 68 20 28 69 66 20 28 73 74 72 69 6e 67 3f 20  th (if (string? 
0eb0: 69 74 65 6d 64 61 74 2d 6f 72 2d 70 61 74 68 29  itemdat-or-path)
0ec0: 20 69 74 65 6d 64 61 74 2d 6f 72 2d 70 61 74 68   itemdat-or-path
0ed0: 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74   (item-list->pat
0ee0: 68 20 69 74 65 6d 64 61 74 2d 6f 72 2d 70 61 74  h itemdat-or-pat
0ef0: 68 29 29 29 0a 09 28 6f 74 68 65 72 64 61 74 20  h)))..(otherdat 
0f00: 20 28 69 66 20 64 61 74 20 64 61 74 20 28 6d 61   (if dat dat (ma
0f10: 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29 29  ke-hash-table)))
0f20: 29 0a 20 20 20 20 3b 3b 20 75 70 64 61 74 65 20  ).    ;; update 
0f30: 74 68 65 20 70 72 69 6d 61 72 79 20 72 65 63 6f  the primary reco
0f40: 72 64 20 49 46 20 73 74 61 74 65 20 41 4e 44 20  rd IF state AND 
0f50: 73 74 61 74 75 73 20 61 72 65 20 64 65 66 69 6e  status are defin
0f60: 65 64 0a 20 20 20 20 28 69 66 20 28 61 6e 64 20  ed.    (if (and 
0f70: 73 74 61 74 65 20 73 74 61 74 75 73 29 0a 09 28  state status)..(
0f80: 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20  sqlite3:execute 
0f90: 64 62 20 22 55 50 44 41 54 45 20 74 65 73 74 73  db "UPDATE tests
0fa0: 20 53 45 54 20 73 74 61 74 65 3d 3f 2c 73 74 61   SET state=?,sta
0fb0: 74 75 73 3d 3f 2c 65 76 65 6e 74 5f 74 69 6d 65  tus=?,event_time
0fc0: 3d 73 74 72 66 74 69 6d 65 28 27 25 73 27 2c 27  =strftime('%s','
0fd0: 6e 6f 77 27 29 20 57 48 45 52 45 20 72 75 6e 5f  now') WHERE run_
0fe0: 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d  id=? AND testnam
0ff0: 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74  e=? AND item_pat
1000: 68 3d 3f 3b 22 20 0a 09 09 09 20 73 74 61 74 65  h=?;" .... state
1010: 20 73 74 61 74 75 73 20 72 75 6e 2d 69 64 20 74   status run-id t
1020: 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61  est-name item-pa
1030: 74 68 29 29 0a 20 20 20 20 3b 3b 20 61 64 64 20  th)).    ;; add 
1040: 6d 65 74 61 64 61 74 61 20 28 6e 65 65 64 20 74  metadata (need t
1050: 6f 20 64 6f 20 74 68 69 73 20 77 61 79 20 74 6f  o do this way to
1060: 20 61 76 6f 69 64 20 53 51 4c 20 69 6e 6a 65 63   avoid SQL injec
1070: 74 69 6f 6e 20 69 73 73 75 65 73 29 0a 20 20 20  tion issues).   
1080: 20 3b 3b 20 3a 76 61 6c 75 65 0a 20 20 20 20 28   ;; :value.    (
1090: 6c 65 74 20 28 28 76 61 6c 20 28 68 61 73 68 2d  let ((val (hash-
10a0: 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c  table-ref/defaul
10b0: 74 20 6f 74 68 65 72 64 61 74 20 22 3a 76 61 6c  t otherdat ":val
10c0: 75 65 22 20 23 66 29 29 29 0a 20 20 20 20 20 20  ue" #f))).      
10d0: 28 69 66 20 76 61 6c 0a 09 20 20 28 73 71 6c 69  (if val..  (sqli
10e0: 74 65 33 3a 65 78 65 63 75 74 65 20 64 62 20 22  te3:execute db "
10f0: 55 50 44 41 54 45 20 74 65 73 74 73 20 53 45 54  UPDATE tests SET
1100: 20 76 61 6c 75 65 3d 3f 20 57 48 45 52 45 20 72   value=? WHERE r
1110: 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74  un_id=? AND test
1120: 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f  name=? AND item_
1130: 70 61 74 68 3d 3f 3b 22 20 76 61 6c 20 72 75 6e  path=?;" val run
1140: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74  -id test-name it
1150: 65 6d 2d 70 61 74 68 29 29 29 0a 20 20 20 20 3b  em-path))).    ;
1160: 3b 20 3a 65 78 70 65 63 74 65 64 5f 76 61 6c 75  ; :expected_valu
1170: 65 0a 20 20 20 20 28 6c 65 74 20 28 28 76 61 6c  e.    (let ((val
1180: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
1190: 2f 64 65 66 61 75 6c 74 20 6f 74 68 65 72 64 61  /default otherda
11a0: 74 20 22 3a 65 78 70 65 63 74 65 64 5f 76 61 6c  t ":expected_val
11b0: 75 65 22 20 23 66 29 29 29 0a 20 20 20 20 20 20  ue" #f))).      
11c0: 28 69 66 20 76 61 6c 0a 09 20 20 28 73 71 6c 69  (if val..  (sqli
11d0: 74 65 33 3a 65 78 65 63 75 74 65 20 64 62 20 22  te3:execute db "
11e0: 55 50 44 41 54 45 20 74 65 73 74 73 20 53 45 54  UPDATE tests SET
11f0: 20 65 78 70 65 63 74 65 64 5f 76 61 6c 75 65 3d   expected_value=
1200: 3f 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f  ? WHERE run_id=?
1210: 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20   AND testname=? 
1220: 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f 3b  AND item_path=?;
1230: 22 20 76 61 6c 20 72 75 6e 2d 69 64 20 74 65 73  " val run-id tes
1240: 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68  t-name item-path
1250: 29 29 29 0a 20 20 20 20 3b 3b 20 3a 74 6f 6c 0a  ))).    ;; :tol.
1260: 20 20 20 20 28 6c 65 74 20 28 28 76 61 6c 20 28      (let ((val (
1270: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64  hash-table-ref/d
1280: 65 66 61 75 6c 74 20 6f 74 68 65 72 64 61 74 20  efault otherdat 
1290: 22 3a 74 6f 6c 22 20 23 66 29 29 29 0a 20 20 20  ":tol" #f))).   
12a0: 20 20 20 28 69 66 20 76 61 6c 0a 09 20 20 28 73     (if val..  (s
12b0: 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 64  qlite3:execute d
12c0: 62 20 22 55 50 44 41 54 45 20 74 65 73 74 73 20  b "UPDATE tests 
12d0: 53 45 54 20 74 6f 6c 3d 3f 20 57 48 45 52 45 20  SET tol=? WHERE 
12e0: 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73  run_id=? AND tes
12f0: 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d  tname=? AND item
1300: 5f 70 61 74 68 3d 3f 3b 22 20 76 61 6c 20 72 75  _path=?;" val ru
1310: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69  n-id test-name i
1320: 74 65 6d 2d 70 61 74 68 29 29 29 0a 20 20 20 20  tem-path))).    
1330: 3b 3b 20 3a 66 69 72 73 74 5f 65 72 72 0a 20 20  ;; :first_err.  
1340: 20 20 28 6c 65 74 20 28 28 76 61 6c 20 28 68 61    (let ((val (ha
1350: 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66  sh-table-ref/def
1360: 61 75 6c 74 20 6f 74 68 65 72 64 61 74 20 22 3a  ault otherdat ":
1370: 66 69 72 73 74 5f 65 72 72 22 20 23 66 29 29 29  first_err" #f)))
1380: 0a 20 20 20 20 20 20 28 69 66 20 76 61 6c 0a 09  .      (if val..
1390: 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75    (sqlite3:execu
13a0: 74 65 20 64 62 20 22 55 50 44 41 54 45 20 74 65  te db "UPDATE te
13b0: 73 74 73 20 53 45 54 20 66 69 72 73 74 5f 65 72  sts SET first_er
13c0: 72 3d 3f 20 57 48 45 52 45 20 72 75 6e 5f 69 64  r=? WHERE run_id
13d0: 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d  =? AND testname=
13e0: 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d  ? AND item_path=
13f0: 3f 3b 22 20 76 61 6c 20 72 75 6e 2d 69 64 20 74  ?;" val run-id t
1400: 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61  est-name item-pa
1410: 74 68 29 29 29 0a 20 20 20 20 3b 3b 20 3a 66 69  th))).    ;; :fi
1420: 72 73 74 5f 77 61 72 6e 0a 20 20 20 20 28 6c 65  rst_warn.    (le
1430: 74 20 28 28 76 61 6c 20 28 68 61 73 68 2d 74 61  t ((val (hash-ta
1440: 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20  ble-ref/default 
1450: 6f 74 68 65 72 64 61 74 20 22 3a 66 69 72 73 74  otherdat ":first
1460: 5f 77 61 72 6e 22 20 23 66 29 29 29 0a 20 20 20  _warn" #f))).   
1470: 20 20 20 28 69 66 20 76 61 6c 0a 09 20 20 28 73     (if val..  (s
1480: 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 64  qlite3:execute d
1490: 62 20 22 55 50 44 41 54 45 20 74 65 73 74 73 20  b "UPDATE tests 
14a0: 53 45 54 20 66 69 72 73 74 5f 77 61 72 6e 3d 3f  SET first_warn=?
14b0: 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20   WHERE run_id=? 
14c0: 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41  AND testname=? A
14d0: 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f 3b 22  ND item_path=?;"
14e0: 20 76 61 6c 20 72 75 6e 2d 69 64 20 74 65 73 74   val run-id test
14f0: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  -name item-path)
1500: 29 29 0a 20 20 20 20 28 6c 65 74 20 28 28 76 61  )).    (let ((va
1510: 6c 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65  l (hash-table-re
1520: 66 2f 64 65 66 61 75 6c 74 20 6f 74 68 65 72 64  f/default otherd
1530: 61 74 20 22 3a 75 6e 69 74 73 22 20 23 66 29 29  at ":units" #f))
1540: 29 0a 20 20 20 20 20 20 28 69 66 20 76 61 6c 0a  ).      (if val.
1550: 09 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63  .  (sqlite3:exec
1560: 75 74 65 20 64 62 20 22 55 50 44 41 54 45 20 74  ute db "UPDATE t
1570: 65 73 74 73 20 53 45 54 20 75 6e 69 74 73 3d 3f  ests SET units=?
1580: 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20   WHERE run_id=? 
1590: 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41  AND testname=? A
15a0: 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f 3b 22  ND item_path=?;"
15b0: 20 76 61 6c 20 72 75 6e 2d 69 64 20 74 65 73 74   val run-id test
15c0: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  -name item-path)
15d0: 29 29 0a 20 20 20 20 3b 3b 20 3a 74 6f 6c 5f 70  )).    ;; :tol_p
15e0: 65 72 63 0a 20 20 20 20 28 6c 65 74 20 28 28 76  erc.    (let ((v
15f0: 61 6c 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72  al (hash-table-r
1600: 65 66 2f 64 65 66 61 75 6c 74 20 6f 74 68 65 72  ef/default other
1610: 64 61 74 20 22 3a 74 6f 6c 5f 70 65 72 63 22 20  dat ":tol_perc" 
1620: 23 66 29 29 29 0a 20 20 20 20 20 20 28 69 66 20  #f))).      (if 
1630: 76 61 6c 0a 09 20 20 28 73 71 6c 69 74 65 33 3a  val..  (sqlite3:
1640: 65 78 65 63 75 74 65 20 64 62 20 22 55 50 44 41  execute db "UPDA
1650: 54 45 20 74 65 73 74 73 20 53 45 54 20 74 6f 6c  TE tests SET tol
1660: 5f 70 65 72 63 3d 3f 20 57 48 45 52 45 20 72 75  _perc=? WHERE ru
1670: 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e  n_id=? AND testn
1680: 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70  ame=? AND item_p
1690: 61 74 68 3d 3f 3b 22 20 76 61 6c 20 72 75 6e 2d  ath=?;" val run-
16a0: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65  id test-name ite
16b0: 6d 2d 70 61 74 68 29 29 29 0a 0a 20 20 20 20 3b  m-path)))..    ;
16c0: 3b 20 6e 65 65 64 20 74 6f 20 75 70 64 61 74 65  ; need to update
16d0: 20 74 68 65 20 74 6f 70 20 74 65 73 74 20 72 65   the top test re
16e0: 63 6f 72 64 20 69 66 20 50 41 53 53 20 6f 72 20  cord if PASS or 
16f0: 46 41 49 4c 20 61 6e 64 20 74 68 69 73 20 69 73  FAIL and this is
1700: 20 61 20 73 75 62 74 65 73 74 0a 20 20 20 20 28   a subtest.    (
1710: 69 66 20 28 61 6e 64 20 28 6e 6f 74 20 28 65 71  if (and (not (eq
1720: 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22  ual? item-path "
1730: 22 29 29 0a 09 20 20 20 20 20 28 6f 72 20 28 65  "))..     (or (e
1740: 71 75 61 6c 3f 20 73 74 61 74 75 73 20 22 50 41  qual? status "PA
1750: 53 53 22 29 0a 09 09 20 28 65 71 75 61 6c 3f 20  SS")... (equal? 
1760: 73 74 61 74 75 73 20 22 57 41 52 4e 22 29 0a 09  status "WARN")..
1770: 09 20 28 65 71 75 61 6c 3f 20 73 74 61 74 75 73  . (equal? status
1780: 20 22 46 41 49 4c 22 29 29 29 0a 09 28 62 65 67   "FAIL")))..(beg
1790: 69 6e 0a 09 20 20 28 73 71 6c 69 74 65 33 3a 65  in..  (sqlite3:e
17a0: 78 65 63 75 74 65 20 0a 09 20 20 20 64 62 0a 09  xecute ..   db..
17b0: 20 20 20 22 55 50 44 41 54 45 20 74 65 73 74 73     "UPDATE tests
17c0: 20 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 53   .             S
17d0: 45 54 20 66 61 69 6c 5f 63 6f 75 6e 74 3d 28 53  ET fail_count=(S
17e0: 45 4c 45 43 54 20 63 6f 75 6e 74 28 69 64 29 20  ELECT count(id) 
17f0: 46 52 4f 4d 20 74 65 73 74 73 20 57 48 45 52 45  FROM tests WHERE
1800: 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65   run_id=? AND te
1810: 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65  stname=? AND ite
1820: 6d 5f 70 61 74 68 20 21 3d 20 27 27 20 41 4e 44  m_path != '' AND
1830: 20 73 74 61 74 75 73 3d 27 46 41 49 4c 27 29 2c   status='FAIL'),
1840: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
1850: 20 20 70 61 73 73 5f 63 6f 75 6e 74 3d 28 53 45    pass_count=(SE
1860: 4c 45 43 54 20 63 6f 75 6e 74 28 69 64 29 20 46  LECT count(id) F
1870: 52 4f 4d 20 74 65 73 74 73 20 57 48 45 52 45 20  ROM tests WHERE 
1880: 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73  run_id=? AND tes
1890: 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d  tname=? AND item
18a0: 5f 70 61 74 68 20 21 3d 20 27 27 20 41 4e 44 20  _path != '' AND 
18b0: 28 73 74 61 74 75 73 3d 27 50 41 53 53 27 20 4f  (status='PASS' O
18c0: 52 20 73 74 61 74 75 73 3d 27 57 41 52 4e 27 29  R status='WARN')
18d0: 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 57  ).             W
18e0: 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e  HERE run_id=? AN
18f0: 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44  D testname=? AND
1900: 20 69 74 65 6d 5f 70 61 74 68 3d 27 27 3b 22 0a   item_path='';".
1910: 09 20 20 20 72 75 6e 2d 69 64 20 74 65 73 74 2d  .   run-id test-
1920: 6e 61 6d 65 20 72 75 6e 2d 69 64 20 74 65 73 74  name run-id test
1930: 2d 6e 61 6d 65 20 72 75 6e 2d 69 64 20 74 65 73  -name run-id tes
1940: 74 2d 6e 61 6d 65 29 0a 09 20 20 28 73 71 6c 69  t-name)..  (sqli
1950: 74 65 33 3a 65 78 65 63 75 74 65 0a 09 20 20 20  te3:execute..   
1960: 64 62 0a 09 20 20 20 22 55 50 44 41 54 45 20 74  db..   "UPDATE t
1970: 65 73 74 73 0a 20 20 20 20 20 20 20 20 20 20 20  ests.           
1980: 20 20 53 45 54 20 73 74 61 74 65 3d 43 41 53 45    SET state=CASE
1990: 20 57 48 45 4e 20 28 53 45 4c 45 43 54 20 63 6f   WHEN (SELECT co
19a0: 75 6e 74 28 69 64 29 20 46 52 4f 4d 20 74 65 73  unt(id) FROM tes
19b0: 74 73 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d  ts WHERE run_id=
19c0: 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f  ? AND testname=?
19d0: 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 20 21   AND item_path !
19e0: 3d 20 27 27 20 41 4e 44 20 73 74 61 74 65 20 69  = '' AND state i
19f0: 6e 20 28 27 52 55 4e 4e 49 4e 47 27 2c 27 4e 4f  n ('RUNNING','NO
1a00: 54 5f 53 54 41 52 54 45 44 27 29 29 20 3e 20 30  T_STARTED')) > 0
1a10: 20 54 48 45 4e 20 0a 20 20 20 20 20 20 20 20 20   THEN .         
1a20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1a30: 20 27 52 55 4e 4e 49 4e 47 27 0a 20 20 20 20 20   'RUNNING'.     
1a40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1a50: 20 20 45 4c 53 45 20 27 43 4f 4d 50 4c 45 54 45    ELSE 'COMPLETE
1a60: 44 27 20 45 4e 44 2c 0a 20 20 20 20 20 20 20 20  D' END,.        
1a70: 20 20 20 20 20 20 20 20 73 74 61 74 75 73 3d 43          status=C
1a80: 41 53 45 20 57 48 45 4e 20 66 61 69 6c 5f 63 6f  ASE WHEN fail_co
1a90: 75 6e 74 20 3e 20 30 20 54 48 45 4e 20 27 46 41  unt > 0 THEN 'FA
1aa0: 49 4c 27 20 57 48 45 4e 20 70 61 73 73 5f 63 6f  IL' WHEN pass_co
1ab0: 75 6e 74 20 3e 20 30 20 41 4e 44 20 66 61 69 6c  unt > 0 AND fail
1ac0: 5f 63 6f 75 6e 74 3d 30 20 54 48 45 4e 20 27 50  _count=0 THEN 'P
1ad0: 41 53 53 27 20 45 4c 53 45 20 27 55 4e 4b 4e 4f  ASS' ELSE 'UNKNO
1ae0: 57 4e 27 20 45 4e 44 0a 20 20 20 20 20 20 20 20  WN' END.        
1af0: 20 20 20 20 20 57 48 45 52 45 20 72 75 6e 5f 69       WHERE run_i
1b00: 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65  d=? AND testname
1b10: 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68  =? AND item_path
1b20: 3d 27 27 3b 22 0a 09 20 20 20 72 75 6e 2d 69 64  ='';"..   run-id
1b30: 20 74 65 73 74 2d 6e 61 6d 65 20 72 75 6e 2d 69   test-name run-i
1b40: 64 20 74 65 73 74 2d 6e 61 6d 65 29 29 29 0a 20  d test-name))). 
1b50: 20 20 20 28 69 66 20 28 61 6e 64 20 28 73 74 72     (if (and (str
1b60: 69 6e 67 3f 20 63 6f 6d 6d 65 6e 74 29 0a 09 20  ing? comment).. 
1b70: 20 20 20 20 28 73 74 72 69 6e 67 2d 6d 61 74 63      (string-matc
1b80: 68 20 28 72 65 67 65 78 70 20 22 5c 5c 53 2b 22  h (regexp "\\S+"
1b90: 29 20 63 6f 6d 6d 65 6e 74 29 29 0a 09 28 73 71  ) comment))..(sq
1ba0: 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 64 62  lite3:execute db
1bb0: 20 22 55 50 44 41 54 45 20 74 65 73 74 73 20 53   "UPDATE tests S
1bc0: 45 54 20 63 6f 6d 6d 65 6e 74 3d 3f 20 57 48 45  ET comment=? WHE
1bd0: 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20  RE run_id=? AND 
1be0: 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69  testname=? AND i
1bf0: 74 65 6d 5f 70 61 74 68 3d 3f 3b 22 0a 09 09 09  tem_path=?;"....
1c00: 20 28 63 61 72 20 63 6f 6d 6d 65 6e 74 29 20 72   (car comment) r
1c10: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
1c20: 69 74 65 6d 2d 70 61 74 68 29 29 0a 20 20 20 20  item-path)).    
1c30: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73  ))..(define (tes
1c40: 74 2d 73 65 74 2d 6c 6f 67 21 20 64 62 20 72 75  t-set-log! db ru
1c50: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69  n-id test-name i
1c60: 74 65 6d 64 61 74 20 6c 6f 67 66 29 20 0a 20 20  temdat logf) .  
1c70: 28 6c 65 74 20 28 28 69 74 65 6d 2d 70 61 74 68  (let ((item-path
1c80: 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74   (item-list->pat
1c90: 68 20 69 74 65 6d 64 61 74 29 29 29 0a 20 20 20  h itemdat))).   
1ca0: 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74   (sqlite3:execut
1cb0: 65 20 64 62 20 22 55 50 44 41 54 45 20 74 65 73  e db "UPDATE tes
1cc0: 74 73 20 53 45 54 20 66 69 6e 61 6c 5f 6c 6f 67  ts SET final_log
1cd0: 66 3d 3f 20 57 48 45 52 45 20 72 75 6e 5f 69 64  f=? WHERE run_id
1ce0: 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d  =? AND testname=
1cf0: 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d  ? AND item_path=
1d00: 3f 3b 22 20 0a 09 09 20 20 20 20 20 6c 6f 67 66  ?;" ...     logf
1d10: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
1d20: 65 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 0a  e item-path)))..
1d30: 28 64 65 66 69 6e 65 20 28 74 65 73 74 2d 73 65  (define (test-se
1d40: 74 2d 74 6f 70 6c 6f 67 21 20 64 62 20 72 75 6e  t-toplog! db run
1d50: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 6c 6f  -id test-name lo
1d60: 67 66 29 20 0a 20 20 28 73 71 6c 69 74 65 33 3a  gf) .  (sqlite3:
1d70: 65 78 65 63 75 74 65 20 64 62 20 22 55 50 44 41  execute db "UPDA
1d80: 54 45 20 74 65 73 74 73 20 53 45 54 20 66 69 6e  TE tests SET fin
1d90: 61 6c 5f 6c 6f 67 66 3d 3f 20 57 48 45 52 45 20  al_logf=? WHERE 
1da0: 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73  run_id=? AND tes
1db0: 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d  tname=? AND item
1dc0: 5f 70 61 74 68 3d 27 27 3b 22 20 0a 09 09 20 20  _path='';" ...  
1dd0: 20 6c 6f 67 66 20 72 75 6e 2d 69 64 20 74 65 73   logf run-id tes
1de0: 74 2d 6e 61 6d 65 29 29 0a 0a 28 64 65 66 69 6e  t-name))..(defin
1df0: 65 20 28 74 65 73 74 73 3a 73 75 6d 6d 61 72 69  e (tests:summari
1e00: 7a 65 2d 69 74 65 6d 73 20 64 62 20 72 75 6e 2d  ze-items db run-
1e10: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 66 6f 72  id test-name for
1e20: 63 65 29 0a 20 20 3b 3b 20 69 66 20 6e 6f 74 20  ce).  ;; if not 
1e30: 66 6f 72 63 65 20 74 68 65 6e 20 6f 6e 6c 79 20  force then only 
1e40: 75 70 64 61 74 65 20 74 68 65 20 72 65 63 6f 72  update the recor
1e50: 64 20 69 66 20 6f 6e 65 20 6f 66 20 74 68 65 73  d if one of thes
1e60: 65 20 69 73 20 74 72 75 65 3a 0a 20 20 3b 3b 20  e is true:.  ;; 
1e70: 20 20 31 2e 20 6c 6f 67 66 20 69 73 20 22 6c 6f    1. logf is "lo
1e80: 67 2f 66 69 6e 61 6c 2e 6c 6f 67 0a 20 20 3b 3b  g/final.log.  ;;
1e90: 20 20 20 32 2e 20 6c 6f 67 66 20 69 73 20 73 61     2. logf is sa
1ea0: 6d 65 20 61 73 20 6f 75 74 70 75 74 66 69 6c 65  me as outputfile
1eb0: 6e 61 6d 65 0a 20 20 28 6c 65 74 20 28 28 6f 75  name.  (let ((ou
1ec0: 74 70 75 74 66 69 6c 65 6e 61 6d 65 20 28 63 6f  tputfilename (co
1ed0: 6e 63 20 22 6d 65 67 61 74 65 73 74 2d 72 6f 6c  nc "megatest-rol
1ee0: 6c 75 70 2d 22 20 74 65 73 74 2d 6e 61 6d 65 20  lup-" test-name 
1ef0: 22 2e 68 74 6d 6c 22 29 29 0a 09 28 6f 72 69 67  ".html"))..(orig
1f00: 2d 64 69 72 20 20 20 20 20 20 20 28 63 75 72 72  -dir       (curr
1f10: 65 6e 74 2d 64 69 72 65 63 74 6f 72 79 29 29 0a  ent-directory)).
1f20: 09 28 6c 6f 67 66 20 20 20 20 20 20 20 20 20 20  .(logf          
1f30: 20 23 66 29 29 0a 20 20 20 20 28 73 71 6c 69 74   #f)).    (sqlit
1f40: 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77 20  e3:for-each-row 
1f50: 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 70  .     (lambda (p
1f60: 61 74 68 20 66 69 6e 61 6c 5f 6c 6f 67 66 29 0a  ath final_logf).
1f70: 20 20 20 20 20 20 20 28 73 65 74 21 20 6c 6f 67         (set! log
1f80: 66 20 66 69 6e 61 6c 5f 6c 6f 67 66 29 0a 20 20  f final_logf).  
1f90: 20 20 20 20 20 28 69 66 20 28 64 69 72 65 63 74       (if (direct
1fa0: 6f 72 79 3f 20 70 61 74 68 29 0a 09 20 20 20 28  ory? path)..   (
1fb0: 62 65 67 69 6e 0a 09 20 20 20 20 20 28 70 72 69  begin..     (pri
1fc0: 6e 74 20 22 46 6f 75 6e 64 20 70 61 74 68 3a 20  nt "Found path: 
1fd0: 22 20 70 61 74 68 29 0a 09 20 20 20 20 20 28 63  " path)..     (c
1fe0: 68 61 6e 67 65 2d 64 69 72 65 63 74 6f 72 79 20  hange-directory 
1ff0: 70 61 74 68 29 29 0a 09 20 20 20 20 20 3b 3b 20  path))..     ;; 
2000: 28 73 65 74 21 20 6f 75 74 70 75 74 66 69 6c 65  (set! outputfile
2010: 6e 61 6d 65 20 28 63 6f 6e 63 20 70 61 74 68 20  name (conc path 
2020: 22 2f 22 20 6f 75 74 70 75 74 66 69 6c 65 6e 61  "/" outputfilena
2030: 6d 65 29 29 29 0a 09 20 20 20 28 70 72 69 6e 74  me)))..   (print
2040: 20 22 4e 6f 20 73 75 63 68 20 70 61 74 68 3a 20   "No such path: 
2050: 22 20 70 61 74 68 29 29 29 0a 20 20 20 20 20 64  " path))).     d
2060: 62 20 0a 20 20 20 20 20 22 53 45 4c 45 43 54 20  b .     "SELECT 
2070: 72 75 6e 64 69 72 2c 66 69 6e 61 6c 5f 6c 6f 67  rundir,final_log
2080: 66 20 46 52 4f 4d 20 74 65 73 74 73 20 57 48 45  f FROM tests WHE
2090: 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20  RE run_id=? AND 
20a0: 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69  testname=? AND i
20b0: 74 65 6d 5f 70 61 74 68 3d 27 27 3b 22 0a 20 20  tem_path='';".  
20c0: 20 20 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e     run-id test-n
20d0: 61 6d 65 29 0a 20 20 20 20 28 70 72 69 6e 74 20  ame).    (print 
20e0: 22 73 75 6d 6d 61 72 69 7a 65 2d 69 74 65 6d 73  "summarize-items
20f0: 20 77 69 74 68 20 6c 6f 67 66 20 22 20 6c 6f 67   with logf " log
2100: 66 29 0a 20 20 20 20 28 69 66 20 28 6f 72 20 28  f).    (if (or (
2110: 65 71 75 61 6c 3f 20 6c 6f 67 66 20 22 6c 6f 67  equal? logf "log
2120: 73 2f 66 69 6e 61 6c 2e 6c 6f 67 22 29 0a 09 20  s/final.log").. 
2130: 20 20 20 28 65 71 75 61 6c 3f 20 6c 6f 67 66 20     (equal? logf 
2140: 6f 75 74 70 75 74 66 69 6c 65 6e 61 6d 65 29 0a  outputfilename).
2150: 09 20 20 20 20 66 6f 72 63 65 29 0a 09 28 62 65  .    force)..(be
2160: 67 69 6e 0a 09 20 20 28 69 66 20 28 6f 62 74 61  gin..  (if (obta
2170: 69 6e 2d 64 6f 74 2d 6c 6f 63 6b 20 6f 75 74 70  in-dot-lock outp
2180: 75 74 66 69 6c 65 6e 61 6d 65 20 31 20 32 30 20  utfilename 1 20 
2190: 33 30 29 20 3b 3b 20 72 65 74 72 79 20 65 76 65  30) ;; retry eve
21a0: 72 79 20 73 65 63 6f 6e 64 20 66 6f 72 20 32 30  ry second for 20
21b0: 20 73 65 63 6f 6e 64 73 2c 20 63 61 6c 6c 20 69   seconds, call i
21c0: 74 20 64 65 61 64 20 61 66 74 65 72 20 33 30 20  t dead after 30 
21d0: 73 65 63 6f 6e 64 73 20 61 6e 64 20 73 74 65 61  seconds and stea
21e0: 6c 20 74 68 65 20 6c 6f 63 6b 0a 09 20 20 20 20  l the lock..    
21f0: 20 20 28 70 72 69 6e 74 20 22 4f 62 74 61 69 6e    (print "Obtain
2200: 65 64 20 6c 6f 63 6b 20 66 6f 72 20 22 20 6f 75  ed lock for " ou
2210: 74 70 75 74 66 69 6c 65 6e 61 6d 65 29 0a 09 20  tputfilename).. 
2220: 20 20 20 20 20 28 70 72 69 6e 74 20 22 46 61 69       (print "Fai
2230: 6c 65 64 20 74 6f 20 6f 62 74 61 69 6e 20 6c 6f  led to obtain lo
2240: 63 6b 20 66 6f 72 20 22 20 6f 75 74 70 75 74 66  ck for " outputf
2250: 69 6c 65 6e 61 6d 65 29 29 0a 09 20 20 28 6c 65  ilename))..  (le
2260: 74 20 28 28 6f 75 70 20 20 20 20 28 6f 70 65 6e  t ((oup    (open
2270: 2d 6f 75 74 70 75 74 2d 66 69 6c 65 20 6f 75 74  -output-file out
2280: 70 75 74 66 69 6c 65 6e 61 6d 65 29 29 0a 09 09  putfilename))...
2290: 28 63 6f 75 6e 74 73 20 28 6d 61 6b 65 2d 68 61  (counts (make-ha
22a0: 73 68 2d 74 61 62 6c 65 29 29 0a 09 09 28 73 74  sh-table))...(st
22b0: 61 74 65 63 6f 75 6e 74 73 20 28 6d 61 6b 65 2d  atecounts (make-
22c0: 68 61 73 68 2d 74 61 62 6c 65 29 29 0a 09 09 28  hash-table))...(
22d0: 6f 75 74 74 78 74 20 22 22 29 0a 09 09 28 74 6f  outtxt "")...(to
22e0: 74 20 20 20 20 30 29 29 0a 09 20 20 20 20 28 77  t    0))..    (w
22f0: 69 74 68 2d 6f 75 74 70 75 74 2d 74 6f 2d 70 6f  ith-output-to-po
2300: 72 74 0a 09 09 6f 75 70 0a 09 20 20 20 20 20 20  rt...oup..      
2310: 28 6c 61 6d 62 64 61 20 28 29 0a 09 09 28 73 65  (lambda ()...(se
2320: 74 21 20 6f 75 74 74 78 74 20 28 63 6f 6e 63 20  t! outtxt (conc 
2330: 6f 75 74 74 78 74 20 22 3c 68 74 6d 6c 3e 3c 74  outtxt "<html><t
2340: 69 74 6c 65 3e 53 75 6d 6d 61 72 79 3a 20 22 20  itle>Summary: " 
2350: 74 65 73 74 2d 6e 61 6d 65 20 0a 09 09 09 09 20  test-name ..... 
2360: 20 20 22 3c 2f 74 69 74 6c 65 3e 3c 62 6f 64 79    "</title><body
2370: 3e 3c 68 32 3e 53 75 6d 6d 61 72 79 20 66 6f 72  ><h2>Summary for
2380: 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 3c 2f   " test-name "</
2390: 68 32 3e 22 29 29 0a 09 09 28 73 71 6c 69 74 65  h2>"))...(sqlite
23a0: 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77 20 0a  3:for-each-row .
23b0: 09 09 20 28 6c 61 6d 62 64 61 20 28 69 64 20 69  .. (lambda (id i
23c0: 74 65 6d 70 61 74 68 20 73 74 61 74 65 20 73 74  tempath state st
23d0: 61 74 75 73 20 72 75 6e 5f 64 75 72 61 74 69 6f  atus run_duratio
23e0: 6e 20 6c 6f 67 66 20 63 6f 6d 6d 65 6e 74 29 0a  n logf comment).
23f0: 09 09 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65  ..   (hash-table
2400: 2d 73 65 74 21 20 63 6f 75 6e 74 73 20 73 74 61  -set! counts sta
2410: 74 75 73 20 28 2b 20 31 20 28 68 61 73 68 2d 74  tus (+ 1 (hash-t
2420: 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74  able-ref/default
2430: 20 63 6f 75 6e 74 73 20 73 74 61 74 75 73 20 30   counts status 0
2440: 29 29 29 0a 09 09 20 20 20 28 68 61 73 68 2d 74  )))...   (hash-t
2450: 61 62 6c 65 2d 73 65 74 21 20 73 74 61 74 65 63  able-set! statec
2460: 6f 75 6e 74 73 20 73 74 61 74 65 20 28 2b 20 31  ounts state (+ 1
2470: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
2480: 2f 64 65 66 61 75 6c 74 20 73 74 61 74 65 63 6f  /default stateco
2490: 75 6e 74 73 20 73 74 61 74 65 20 30 29 29 29 0a  unts state 0))).
24a0: 09 09 20 20 20 28 73 65 74 21 20 6f 75 74 74 78  ..   (set! outtx
24b0: 74 20 28 63 6f 6e 63 20 6f 75 74 74 78 74 20 22  t (conc outtxt "
24c0: 3c 74 72 3e 22 0a 09 09 09 09 20 20 20 20 20 20  <tr>".....      
24d0: 22 3c 74 64 3e 3c 61 20 68 72 65 66 3d 5c 22 22  "<td><a href=\""
24e0: 20 69 74 65 6d 70 61 74 68 20 22 2f 22 20 6c 6f   itempath "/" lo
24f0: 67 66 20 22 5c 22 3e 20 22 20 69 74 65 6d 70 61  gf "\"> " itempa
2500: 74 68 20 22 3c 2f 61 3e 3c 2f 74 64 3e 22 20 0a  th "</a></td>" .
2510: 09 09 09 09 20 20 20 20 20 20 22 3c 74 64 3e 22  ....      "<td>"
2520: 20 73 74 61 74 65 20 20 20 20 22 3c 2f 74 64 3e   state    "</td>
2530: 22 20 0a 09 09 09 09 20 20 20 20 20 20 22 3c 74  " .....      "<t
2540: 64 3e 3c 66 6f 6e 74 20 63 6f 6c 6f 72 3d 22 20  d><font color=" 
2550: 28 63 6f 6d 6d 6f 6e 3a 67 65 74 2d 63 6f 6c 6f  (common:get-colo
2560: 72 2d 66 72 6f 6d 2d 73 74 61 74 75 73 20 73 74  r-from-status st
2570: 61 74 75 73 29 0a 09 09 09 09 20 20 20 20 20 20  atus).....      
2580: 22 3e 22 20 20 20 73 74 61 74 75 73 20 20 20 22  ">"   status   "
2590: 3c 2f 66 6f 6e 74 3e 3c 2f 74 64 3e 22 0a 09 09  </font></td>"...
25a0: 09 09 20 20 20 20 20 20 22 3c 74 64 3e 22 20 28  ..      "<td>" (
25b0: 69 66 20 28 65 71 75 61 6c 3f 20 63 6f 6d 6d 65  if (equal? comme
25c0: 6e 74 20 22 22 29 0a 09 09 09 09 09 09 20 22 26  nt "")....... "&
25d0: 6e 62 73 70 3b 22 0a 09 09 09 09 09 09 20 63 6f  nbsp;"....... co
25e0: 6d 6d 65 6e 74 29 20 22 3c 2f 74 64 3e 22 0a 09  mment) "</td>"..
25f0: 09 09 09 09 09 20 22 3c 2f 74 72 3e 22 29 29 29  ..... "</tr>")))
2600: 0a 09 09 20 64 62 0a 09 09 20 22 53 45 4c 45 43  ... db... "SELEC
2610: 54 20 69 64 2c 69 74 65 6d 5f 70 61 74 68 2c 73  T id,item_path,s
2620: 74 61 74 65 2c 73 74 61 74 75 73 2c 72 75 6e 5f  tate,status,run_
2630: 64 75 72 61 74 69 6f 6e 2c 66 69 6e 61 6c 5f 6c  duration,final_l
2640: 6f 67 66 2c 63 6f 6d 6d 65 6e 74 20 46 52 4f 4d  ogf,comment FROM
2650: 20 74 65 73 74 73 20 57 48 45 52 45 20 72 75 6e   tests WHERE run
2660: 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61  _id=? AND testna
2670: 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61  me=? AND item_pa
2680: 74 68 20 21 3d 20 27 27 3b 22 0a 09 09 20 72 75  th != '';"... ru
2690: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 29 0a  n-id test-name).
26a0: 0a 09 09 28 70 72 69 6e 74 20 22 3c 74 61 62 6c  ...(print "<tabl
26b0: 65 3e 3c 74 72 3e 3c 74 64 20 76 61 6c 69 67 6e  e><tr><td valign
26c0: 3d 5c 22 74 6f 70 5c 22 3e 22 29 0a 09 09 3b 3b  =\"top\">")...;;
26d0: 20 50 72 69 6e 74 20 6f 75 74 20 73 74 61 74 73   Print out stats
26e0: 20 66 6f 72 20 73 74 61 74 75 73 0a 09 09 28 73   for status...(s
26f0: 65 74 21 20 74 6f 74 20 30 29 0a 09 09 28 70 72  et! tot 0)...(pr
2700: 69 6e 74 20 22 3c 74 61 62 6c 65 20 63 65 6c 6c  int "<table cell
2710: 73 70 61 63 69 6e 67 3d 5c 22 30 5c 22 20 62 6f  spacing=\"0\" bo
2720: 72 64 65 72 3d 5c 22 31 5c 22 3e 3c 74 72 3e 3c  rder=\"1\"><tr><
2730: 74 64 20 63 6f 6c 73 70 61 6e 3d 5c 22 32 5c 22  td colspan=\"2\"
2740: 3e 3c 68 32 3e 53 74 61 74 65 20 73 74 61 74 73  ><h2>State stats
2750: 3c 2f 68 32 3e 3c 2f 74 64 3e 3c 2f 74 72 3e 22  </h2></td></tr>"
2760: 29 0a 09 09 28 66 6f 72 2d 65 61 63 68 20 28 6c  )...(for-each (l
2770: 61 6d 62 64 61 20 28 73 74 61 74 65 29 0a 09 09  ambda (state)...
2780: 09 20 20 20 20 28 73 65 74 21 20 74 6f 74 20 28  .    (set! tot (
2790: 2b 20 74 6f 74 20 28 68 61 73 68 2d 74 61 62 6c  + tot (hash-tabl
27a0: 65 2d 72 65 66 20 73 74 61 74 65 63 6f 75 6e 74  e-ref statecount
27b0: 73 20 73 74 61 74 65 29 29 29 0a 09 09 09 20 20  s state)))....  
27c0: 20 20 28 70 72 69 6e 74 20 22 3c 74 72 3e 3c 74    (print "<tr><t
27d0: 64 3e 22 20 73 74 61 74 65 20 22 3c 2f 74 64 3e  d>" state "</td>
27e0: 3c 74 64 3e 22 20 28 68 61 73 68 2d 74 61 62 6c  <td>" (hash-tabl
27f0: 65 2d 72 65 66 20 73 74 61 74 65 63 6f 75 6e 74  e-ref statecount
2800: 73 20 73 74 61 74 65 29 20 22 3c 2f 74 64 3e 3c  s state) "</td><
2810: 2f 74 72 3e 22 29 29 0a 09 09 09 20 20 28 68 61  /tr>"))....  (ha
2820: 73 68 2d 74 61 62 6c 65 2d 6b 65 79 73 20 73 74  sh-table-keys st
2830: 61 74 65 63 6f 75 6e 74 73 29 29 0a 09 09 28 70  atecounts))...(p
2840: 72 69 6e 74 20 22 3c 74 72 3e 3c 74 64 3e 54 6f  rint "<tr><td>To
2850: 74 61 6c 3c 2f 74 64 3e 3c 74 64 3e 22 20 74 6f  tal</td><td>" to
2860: 74 20 22 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74  t "</td></tr></t
2870: 61 62 6c 65 3e 22 29 0a 09 09 28 70 72 69 6e 74  able>")...(print
2880: 20 22 3c 2f 74 64 3e 3c 74 64 20 76 61 6c 69 67   "</td><td valig
2890: 6e 3d 5c 22 74 6f 70 5c 22 3e 22 29 0a 09 09 3b  n=\"top\">")...;
28a0: 3b 20 50 72 69 6e 74 20 6f 75 74 20 73 74 61 74  ; Print out stat
28b0: 73 20 66 6f 72 20 73 74 61 74 65 0a 09 09 28 73  s for state...(s
28c0: 65 74 21 20 74 6f 74 20 30 29 0a 09 09 28 70 72  et! tot 0)...(pr
28d0: 69 6e 74 20 22 3c 74 61 62 6c 65 20 63 65 6c 6c  int "<table cell
28e0: 73 70 61 63 69 6e 67 3d 5c 22 30 5c 22 20 62 6f  spacing=\"0\" bo
28f0: 72 64 65 72 3d 5c 22 31 5c 22 3e 3c 74 72 3e 3c  rder=\"1\"><tr><
2900: 74 64 20 63 6f 6c 73 70 61 6e 3d 5c 22 32 5c 22  td colspan=\"2\"
2910: 3e 3c 68 32 3e 53 74 61 74 75 73 20 73 74 61 74  ><h2>Status stat
2920: 73 3c 2f 68 32 3e 3c 2f 74 64 3e 3c 2f 74 72 3e  s</h2></td></tr>
2930: 22 29 0a 09 09 28 66 6f 72 2d 65 61 63 68 20 28  ")...(for-each (
2940: 6c 61 6d 62 64 61 20 28 73 74 61 74 75 73 29 0a  lambda (status).
2950: 09 09 09 20 20 20 20 28 73 65 74 21 20 74 6f 74  ...    (set! tot
2960: 20 28 2b 20 74 6f 74 20 28 68 61 73 68 2d 74 61   (+ tot (hash-ta
2970: 62 6c 65 2d 72 65 66 20 63 6f 75 6e 74 73 20 73  ble-ref counts s
2980: 74 61 74 75 73 29 29 29 0a 09 09 09 20 20 20 20  tatus)))....    
2990: 28 70 72 69 6e 74 20 22 3c 74 72 3e 3c 74 64 3e  (print "<tr><td>
29a0: 3c 66 6f 6e 74 20 63 6f 6c 6f 72 3d 5c 22 22 20  <font color=\"" 
29b0: 28 63 6f 6d 6d 6f 6e 3a 67 65 74 2d 63 6f 6c 6f  (common:get-colo
29c0: 72 2d 66 72 6f 6d 2d 73 74 61 74 75 73 20 73 74  r-from-status st
29d0: 61 74 75 73 29 20 22 5c 22 3e 22 20 73 74 61 74  atus) "\">" stat
29e0: 75 73 0a 09 09 09 09 20 20 20 22 3c 2f 66 6f 6e  us.....   "</fon
29f0: 74 3e 3c 2f 74 64 3e 3c 74 64 3e 22 20 28 68 61  t></td><td>" (ha
2a00: 73 68 2d 74 61 62 6c 65 2d 72 65 66 20 63 6f 75  sh-table-ref cou
2a10: 6e 74 73 20 73 74 61 74 75 73 29 20 22 3c 2f 74  nts status) "</t
2a20: 64 3e 3c 2f 74 72 3e 22 29 29 0a 09 09 09 20 20  d></tr>"))....  
2a30: 28 68 61 73 68 2d 74 61 62 6c 65 2d 6b 65 79 73  (hash-table-keys
2a40: 20 63 6f 75 6e 74 73 29 29 0a 09 09 28 70 72 69   counts))...(pri
2a50: 6e 74 20 22 3c 74 72 3e 3c 74 64 3e 54 6f 74 61  nt "<tr><td>Tota
2a60: 6c 3c 2f 74 64 3e 3c 74 64 3e 22 20 74 6f 74 20  l</td><td>" tot 
2a70: 22 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61 62  "</td></tr></tab
2a80: 6c 65 3e 22 29 0a 09 09 28 70 72 69 6e 74 20 22  le>")...(print "
2a90: 3c 2f 74 64 3e 3c 2f 74 64 3e 3c 2f 74 72 3e 3c  </td></td></tr><
2aa0: 2f 74 61 62 6c 65 3e 22 29 0a 0a 09 09 28 70 72  /table>")....(pr
2ab0: 69 6e 74 20 22 3c 74 61 62 6c 65 20 63 65 6c 6c  int "<table cell
2ac0: 73 70 61 63 69 6e 67 3d 5c 22 30 5c 22 20 62 6f  spacing=\"0\" bo
2ad0: 72 64 65 72 3d 5c 22 31 5c 22 3e 22 20 0a 09 09  rder=\"1\">" ...
2ae0: 20 20 20 20 20 20 20 22 3c 74 72 3e 3c 74 64 3e         "<tr><td>
2af0: 49 74 65 6d 3c 2f 74 64 3e 3c 74 64 3e 53 74 61  Item</td><td>Sta
2b00: 74 65 3c 2f 74 64 3e 3c 74 64 3e 53 74 61 74 75  te</td><td>Statu
2b10: 73 3c 2f 74 64 3e 3c 74 64 3e 43 6f 6d 6d 65 6e  s</td><td>Commen
2b20: 74 3c 2f 74 64 3e 22 0a 09 09 20 20 20 20 20 20  t</td>"...      
2b30: 20 6f 75 74 74 78 74 20 22 3c 2f 74 61 62 6c 65   outtxt "</table
2b40: 3e 3c 2f 62 6f 64 79 3e 3c 2f 68 74 6d 6c 3e 22  ></body></html>"
2b50: 29 0a 09 09 28 72 65 6c 65 61 73 65 2d 64 6f 74  )...(release-dot
2b60: 2d 6c 6f 63 6b 20 6f 75 74 70 75 74 66 69 6c 65  -lock outputfile
2b70: 6e 61 6d 65 29 29 29 0a 09 20 20 20 20 28 63 6c  name)))..    (cl
2b80: 6f 73 65 2d 6f 75 74 70 75 74 2d 70 6f 72 74 20  ose-output-port 
2b90: 6f 75 70 29 0a 09 20 20 20 20 28 63 68 61 6e 67  oup)..    (chang
2ba0: 65 2d 64 69 72 65 63 74 6f 72 79 20 6f 72 69 67  e-directory orig
2bb0: 2d 64 69 72 29 0a 09 20 20 20 20 28 74 65 73 74  -dir)..    (test
2bc0: 2d 73 65 74 2d 74 6f 70 6c 6f 67 21 20 64 62 20  -set-toplog! db 
2bd0: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
2be0: 20 6f 75 74 70 75 74 66 69 6c 65 6e 61 6d 65 29   outputfilename)
2bf0: 0a 09 20 20 20 20 29 29 29 29 29 0a 0a 3b 3b 20  ..    )))))..;; 
2c00: 3b 3b 20 54 4f 44 4f 3a 20 43 6f 6e 76 65 72 67  ;; TODO: Converg
2c10: 65 20 74 68 69 73 20 77 69 74 68 20 64 62 3a 67  e this with db:g
2c20: 65 74 2d 74 65 73 74 2d 69 6e 66 6f 0a 3b 3b 20  et-test-info.;; 
2c30: 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 67 65  (define (runs:ge
2c40: 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 20 72  t-test-info db r
2c50: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
2c60: 69 74 65 6d 2d 70 61 74 68 29 0a 3b 3b 20 20 20  item-path).;;   
2c70: 28 6c 65 74 20 28 28 72 65 73 20 23 66 29 29 20  (let ((res #f)) 
2c80: 3b 3b 20 28 76 65 63 74 6f 72 20 23 66 20 23 66  ;; (vector #f #f
2c90: 20 23 66 20 23 66 20 23 66 20 23 66 29 29 29 0a   #f #f #f #f))).
2ca0: 3b 3b 20 20 20 20 20 28 73 71 6c 69 74 65 33 3a  ;;     (sqlite3:
2cb0: 66 6f 72 2d 65 61 63 68 2d 72 6f 77 20 0a 3b 3b  for-each-row .;;
2cc0: 20 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 69        (lambda (i
2cd0: 64 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  d run-id test-na
2ce0: 6d 65 20 73 74 61 74 65 20 73 74 61 74 75 73 29  me state status)
2cf0: 0a 3b 3b 20 20 20 20 20 20 20 20 28 73 65 74 21  .;;        (set!
2d00: 20 72 65 73 20 28 76 65 63 74 6f 72 20 69 64 20   res (vector id 
2d10: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
2d20: 20 73 74 61 74 65 20 73 74 61 74 75 73 20 69 74   state status it
2d30: 65 6d 2d 70 61 74 68 29 29 29 0a 3b 3b 20 20 20  em-path))).;;   
2d40: 20 20 20 64 62 20 22 53 45 4c 45 43 54 20 69 64     db "SELECT id
2d50: 2c 72 75 6e 5f 69 64 2c 74 65 73 74 6e 61 6d 65  ,run_id,testname
2d60: 2c 73 74 61 74 65 2c 73 74 61 74 75 73 20 46 52  ,state,status FR
2d70: 4f 4d 20 74 65 73 74 73 20 57 48 45 52 45 20 72  OM tests WHERE r
2d80: 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74  un_id=? AND test
2d90: 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f  name=? AND item_
2da0: 70 61 74 68 3d 3f 3b 22 0a 3b 3b 20 20 20 20 20  path=?;".;;     
2db0: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
2dc0: 65 20 69 74 65 6d 2d 70 61 74 68 29 0a 3b 3b 20  e item-path).;; 
2dd0: 20 20 20 20 72 65 73 29 29 0a 0a 28 64 65 66 69      res))..(defi
2de0: 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65 73 74 3a  ne-inline (test:
2df0: 67 65 74 2d 69 64 20 76 65 63 29 20 20 20 20 20  get-id vec)     
2e00: 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20 76 65    (vector-ref ve
2e10: 63 20 30 29 29 0a 28 64 65 66 69 6e 65 2d 69 6e  c 0)).(define-in
2e20: 6c 69 6e 65 20 28 74 65 73 74 3a 67 65 74 2d 72  line (test:get-r
2e30: 75 6e 5f 69 64 20 76 65 63 29 20 20 20 28 76 65  un_id vec)   (ve
2e40: 63 74 6f 72 2d 72 65 66 20 76 65 63 20 31 29 29  ctor-ref vec 1))
2e50: 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69 6e 65 20  .(define-inline 
2e60: 28 74 65 73 74 3a 67 65 74 2d 74 65 73 74 2d 6e  (test:get-test-n
2e70: 61 6d 65 20 76 65 63 29 28 76 65 63 74 6f 72 2d  ame vec)(vector-
2e80: 72 65 66 20 76 65 63 20 32 29 29 0a 28 64 65 66  ref vec 2)).(def
2e90: 69 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65 73 74  ine-inline (test
2ea0: 3a 67 65 74 2d 73 74 61 74 65 20 76 65 63 29 20  :get-state vec) 
2eb0: 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20 76     (vector-ref v
2ec0: 65 63 20 33 29 29 0a 28 64 65 66 69 6e 65 2d 69  ec 3)).(define-i
2ed0: 6e 6c 69 6e 65 20 28 74 65 73 74 3a 67 65 74 2d  nline (test:get-
2ee0: 73 74 61 74 75 73 20 76 65 63 29 20 20 20 28 76  status vec)   (v
2ef0: 65 63 74 6f 72 2d 72 65 66 20 76 65 63 20 34 29  ector-ref vec 4)
2f00: 29 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69 6e 65  ).(define-inline
2f10: 20 28 74 65 73 74 3a 67 65 74 2d 69 74 65 6d 2d   (test:get-item-
2f20: 70 61 74 68 20 76 65 63 29 28 76 65 63 74 6f 72  path vec)(vector
2f30: 2d 72 65 66 20 76 65 63 20 35 29 29 0a 0a 28 64  -ref vec 5))..(d
2f40: 65 66 69 6e 65 20 28 72 75 6e 73 3a 74 65 73 74  efine (runs:test
2f50: 2d 67 65 74 2d 66 75 6c 6c 2d 70 61 74 68 20 74  -get-full-path t
2f60: 65 73 74 29 0a 20 20 28 6c 65 74 2a 20 28 28 74  est).  (let* ((t
2f70: 65 73 74 6e 61 6d 65 20 28 64 62 3a 74 65 73 74  estname (db:test
2f80: 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 20 20  -get-testname   
2f90: 74 65 73 74 29 29 0a 09 20 28 69 74 65 6d 70 61  test)).. (itempa
2fa0: 74 68 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  th (db:test-get-
2fb0: 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 29 29  item-path test))
2fc0: 29 0a 20 20 20 20 28 63 6f 6e 63 20 74 65 73 74  ).    (conc test
2fd0: 6e 61 6d 65 20 28 69 66 20 28 65 71 75 61 6c 3f  name (if (equal?
2fe0: 20 69 74 65 6d 70 61 74 68 20 22 22 29 20 22 22   itempath "") ""
2ff0: 20 28 63 6f 6e 63 20 22 28 22 20 69 74 65 6d 70   (conc "(" itemp
3000: 61 74 68 20 22 29 22 29 29 29 29 29 0a 0a 28 64  ath ")")))))..(d
3010: 65 66 69 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65  efine-inline (te
3020: 73 74 3a 74 65 73 74 2d 67 65 74 2d 66 75 6c 6c  st:test-get-full
3030: 6e 61 6d 65 20 74 65 73 74 29 0a 20 20 20 28 63  name test).   (c
3040: 6f 6e 63 20 28 64 62 3a 74 65 73 74 2d 67 65 74  onc (db:test-get
3050: 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 29 0a  -testname test).
3060: 09 20 28 69 66 20 28 65 71 75 61 6c 3f 20 28 64  . (if (equal? (d
3070: 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d  b:test-get-item-
3080: 70 61 74 68 20 74 65 73 74 29 20 22 22 29 0a 09  path test) "")..
3090: 20 20 20 20 20 22 22 0a 09 20 20 20 20 20 28 63       ""..     (c
30a0: 6f 6e 63 20 22 28 22 20 28 64 62 3a 74 65 73 74  onc "(" (db:test
30b0: 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74  -get-item-path t
30c0: 65 73 74 29 20 22 29 22 29 29 29 29 0a 0a 28 64  est) ")"))))..(d
30d0: 65 66 69 6e 65 20 28 63 68 65 63 6b 2d 76 61 6c  efine (check-val
30e0: 69 64 2d 69 74 65 6d 73 20 63 6c 61 73 73 20 69  id-items class i
30f0: 74 65 6d 29 0a 20 20 28 6c 65 74 20 28 28 76 61  tem).  (let ((va
3100: 6c 69 64 2d 76 61 6c 75 65 73 20 28 6c 65 74 20  lid-values (let 
3110: 28 28 73 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b  ((s (config-look
3120: 75 70 20 2a 63 6f 6e 66 69 67 64 61 74 2a 20 22  up *configdat* "
3130: 76 61 6c 69 64 76 61 6c 75 65 73 22 20 63 6c 61  validvalues" cla
3140: 73 73 29 29 29 0a 09 09 09 28 69 66 20 73 20 28  ss)))....(if s (
3150: 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 73 29 20  string-split s) 
3160: 23 66 29 29 29 29 0a 20 20 20 20 28 69 66 20 76  #f)))).    (if v
3170: 61 6c 69 64 2d 76 61 6c 75 65 73 0a 09 28 69 66  alid-values..(if
3180: 20 28 6d 65 6d 62 65 72 20 69 74 65 6d 20 76 61   (member item va
3190: 6c 69 64 2d 76 61 6c 75 65 73 29 0a 09 20 20 20  lid-values)..   
31a0: 20 69 74 65 6d 20 23 66 29 0a 09 69 74 65 6d 29   item #f)..item)
31b0: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73  ))..(define (tes
31c0: 74 73 74 65 70 2d 73 65 74 2d 73 74 61 74 75 73  tstep-set-status
31d0: 21 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  ! db run-id test
31e0: 2d 6e 61 6d 65 20 74 65 73 74 73 74 65 70 2d 6e  -name teststep-n
31f0: 61 6d 65 20 73 74 61 74 65 2d 69 6e 20 73 74 61  ame state-in sta
3200: 74 75 73 2d 69 6e 20 69 74 65 6d 64 61 74 20 63  tus-in itemdat c
3210: 6f 6d 6d 65 6e 74 29 0a 20 20 28 64 65 62 75 67  omment).  (debug
3220: 3a 70 72 69 6e 74 20 34 20 22 72 75 6e 2d 69 64  :print 4 "run-id
3230: 3a 20 22 20 72 75 6e 2d 69 64 20 22 20 74 65 73  : " run-id " tes
3240: 74 2d 6e 61 6d 65 3a 20 22 20 74 65 73 74 2d 6e  t-name: " test-n
3250: 61 6d 65 29 0a 20 20 28 6c 65 74 2a 20 28 28 73  ame).  (let* ((s
3260: 74 61 74 65 20 20 20 20 20 28 63 68 65 63 6b 2d  tate     (check-
3270: 76 61 6c 69 64 2d 69 74 65 6d 73 20 22 73 74 61  valid-items "sta
3280: 74 65 22 20 73 74 61 74 65 2d 69 6e 29 29 0a 09  te" state-in))..
3290: 20 28 73 74 61 74 75 73 20 20 20 20 28 63 68 65   (status    (che
32a0: 63 6b 2d 76 61 6c 69 64 2d 69 74 65 6d 73 20 22  ck-valid-items "
32b0: 73 74 61 74 75 73 22 20 73 74 61 74 75 73 2d 69  status" status-i
32c0: 6e 29 29 0a 09 20 28 69 74 65 6d 2d 70 61 74 68  n)).. (item-path
32d0: 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74   (item-list->pat
32e0: 68 20 69 74 65 6d 64 61 74 29 29 0a 09 20 28 74  h itemdat)).. (t
32f0: 65 73 74 64 61 74 20 20 20 28 64 62 3a 67 65 74  estdat   (db:get
3300: 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 20 72 75  -test-info db ru
3310: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69  n-id test-name i
3320: 74 65 6d 2d 70 61 74 68 29 29 29 0a 20 20 20 20  tem-path))).    
3330: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 35 20 22  (debug:print 5 "
3340: 74 65 73 74 64 61 74 3a 20 22 20 74 65 73 74 64  testdat: " testd
3350: 61 74 29 0a 20 20 20 20 28 69 66 20 28 61 6e 64  at).    (if (and
3360: 20 74 65 73 74 64 61 74 20 3b 3b 20 69 66 20 74   testdat ;; if t
3370: 68 65 20 73 65 63 74 69 6f 6e 20 65 78 69 73 74  he section exist
3380: 73 20 74 68 65 6e 20 66 6f 72 63 65 20 73 70 65  s then force spe
3390: 63 69 66 69 63 61 74 69 6f 6e 20 42 55 47 2c 20  cification BUG, 
33a0: 49 20 64 6f 6e 27 74 20 6c 69 6b 65 20 68 6f 77  I don't like how
33b0: 20 74 68 69 73 20 77 6f 72 6b 73 2e 0a 09 20 20   this works...  
33c0: 20 20 20 28 6f 72 20 28 6e 6f 74 20 73 74 61 74     (or (not stat
33d0: 65 29 28 6e 6f 74 20 73 74 61 74 75 73 29 29 29  e)(not status)))
33e0: 0a 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30  ..(debug:print 0
33f0: 20 22 57 41 52 4e 49 4e 47 3a 20 49 6e 76 61 6c   "WARNING: Inval
3400: 69 64 20 22 20 28 69 66 20 73 74 61 74 75 73 20  id " (if status 
3410: 22 73 74 61 74 75 73 22 20 22 73 74 61 74 65 22  "status" "state"
3420: 29 0a 09 20 20 20 20 20 20 20 22 20 76 61 6c 75  )..       " valu
3430: 65 20 5c 22 22 20 28 69 66 20 73 74 61 74 75 73  e \"" (if status
3440: 20 73 74 61 74 75 73 2d 69 6e 20 73 74 61 74 65   status-in state
3450: 2d 69 6e 29 20 22 5c 22 2c 20 75 70 64 61 74 65  -in) "\", update
3460: 20 79 6f 75 72 20 76 61 6c 69 64 73 74 61 74 65   your validstate
3470: 73 20 73 65 63 74 69 6f 6e 20 69 6e 20 6d 65 67  s section in meg
3480: 61 74 65 73 74 2e 63 6f 6e 66 69 67 22 29 29 0a  atest.config")).
3490: 20 20 20 20 28 69 66 20 74 65 73 74 64 61 74 0a      (if testdat.
34a0: 09 28 6c 65 74 20 28 28 74 65 73 74 2d 69 64 20  .(let ((test-id 
34b0: 28 74 65 73 74 3a 67 65 74 2d 69 64 20 74 65 73  (test:get-id tes
34c0: 74 64 61 74 29 29 29 0a 09 20 20 28 73 71 6c 69  tdat)))..  (sqli
34d0: 74 65 33 3a 65 78 65 63 75 74 65 20 64 62 20 0a  te3:execute db .
34e0: 09 09 09 22 49 4e 53 45 52 54 20 4f 52 20 52 45  ..."INSERT OR RE
34f0: 50 4c 41 43 45 20 69 6e 74 6f 20 74 65 73 74 5f  PLACE into test_
3500: 73 74 65 70 73 20 28 74 65 73 74 5f 69 64 2c 73  steps (test_id,s
3510: 74 65 70 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74  tepname,state,st
3520: 61 74 75 73 2c 65 76 65 6e 74 5f 74 69 6d 65 2c  atus,event_time,
3530: 63 6f 6d 6d 65 6e 74 29 20 56 41 4c 55 45 53 28  comment) VALUES(
3540: 3f 2c 3f 2c 3f 2c 3f 2c 73 74 72 66 74 69 6d 65  ?,?,?,?,strftime
3550: 28 27 25 73 27 2c 27 6e 6f 77 27 29 2c 3f 29 3b  ('%s','now'),?);
3560: 22 0a 09 09 09 74 65 73 74 2d 69 64 20 74 65 73  "....test-id tes
3570: 74 73 74 65 70 2d 6e 61 6d 65 20 73 74 61 74 65  tstep-name state
3580: 20 73 74 61 74 75 73 20 28 69 66 20 63 6f 6d 6d   status (if comm
3590: 65 6e 74 20 63 6f 6d 6d 65 6e 74 20 22 22 29 29  ent comment ""))
35a0: 29 0a 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20  )..(debug:print 
35b0: 30 20 22 45 52 52 4f 52 3a 20 43 61 6e 27 74 20  0 "ERROR: Can't 
35c0: 75 70 64 61 74 65 20 22 20 74 65 73 74 2d 6e 61  update " test-na
35d0: 6d 65 20 22 20 66 6f 72 20 72 75 6e 20 22 20 72  me " for run " r
35e0: 75 6e 2d 69 64 20 22 20 2d 3e 20 6e 6f 20 73 75  un-id " -> no su
35f0: 63 68 20 74 65 73 74 20 69 6e 20 64 62 22 29 29  ch test in db"))
3600: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73  ))..(define (tes
3610: 74 2d 67 65 74 2d 6b 69 6c 6c 2d 72 65 71 75 65  t-get-kill-reque
3620: 73 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  st db run-id tes
3630: 74 2d 6e 61 6d 65 20 69 74 65 6d 64 61 74 29 0a  t-name itemdat).
3640: 20 20 28 6c 65 74 2a 20 28 28 69 74 65 6d 2d 70    (let* ((item-p
3650: 61 74 68 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e  ath (item-list->
3660: 70 61 74 68 20 69 74 65 6d 64 61 74 29 29 0a 09  path itemdat))..
3670: 20 28 74 65 73 74 64 61 74 20 20 20 28 64 62 3a   (testdat   (db:
3680: 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62  get-test-info db
3690: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
36a0: 65 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 20  e item-path))). 
36b0: 20 20 20 28 65 71 75 61 6c 3f 20 28 74 65 73 74     (equal? (test
36c0: 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64  :get-state testd
36d0: 61 74 29 20 22 4b 49 4c 4c 52 45 51 22 29 29 29  at) "KILLREQ")))
36e0: 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73 74 2d  ..(define (test-
36f0: 73 65 74 2d 6d 65 74 61 2d 69 6e 66 6f 20 64 62  set-meta-info db
3700: 20 72 75 6e 2d 69 64 20 74 65 73 74 6e 61 6d 65   run-id testname
3710: 20 69 74 65 6d 64 61 74 29 0a 20 20 28 6c 65 74   itemdat).  (let
3720: 20 28 28 69 74 65 6d 2d 70 61 74 68 20 28 69 74   ((item-path (it
3730: 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69 74  em-list->path it
3740: 65 6d 64 61 74 29 29 0a 09 28 63 70 75 6c 6f 61  emdat))..(cpuloa
3750: 64 20 20 28 67 65 74 2d 63 70 75 2d 6c 6f 61 64  d  (get-cpu-load
3760: 29 29 0a 09 28 68 6f 73 74 6e 61 6d 65 20 28 67  ))..(hostname (g
3770: 65 74 2d 68 6f 73 74 2d 6e 61 6d 65 29 29 0a 09  et-host-name))..
3780: 28 64 69 73 6b 66 72 65 65 20 28 67 65 74 2d 64  (diskfree (get-d
3790: 66 20 28 63 75 72 72 65 6e 74 2d 64 69 72 65 63  f (current-direc
37a0: 74 6f 72 79 29 29 29 0a 09 28 75 6e 61 6d 65 20  tory)))..(uname 
37b0: 20 20 20 28 67 65 74 2d 75 6e 61 6d 65 20 22 2d     (get-uname "-
37c0: 73 72 76 70 69 6f 22 29 29 0a 09 28 72 75 6e 70  srvpio"))..(runp
37d0: 61 74 68 20 20 28 63 75 72 72 65 6e 74 2d 64 69  ath  (current-di
37e0: 72 65 63 74 6f 72 79 29 29 29 0a 20 20 20 20 28  rectory))).    (
37f0: 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20  sqlite3:execute 
3800: 64 62 20 22 55 50 44 41 54 45 20 74 65 73 74 73  db "UPDATE tests
3810: 20 53 45 54 20 68 6f 73 74 3d 3f 2c 63 70 75 6c   SET host=?,cpul
3820: 6f 61 64 3d 3f 2c 64 69 73 6b 66 72 65 65 3d 3f  oad=?,diskfree=?
3830: 2c 75 6e 61 6d 65 3d 3f 2c 72 75 6e 64 69 72 3d  ,uname=?,rundir=
3840: 3f 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f  ? WHERE run_id=?
3850: 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20   AND testname=? 
3860: 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f 3b  AND item_path=?;
3870: 22 0a 09 09 20 20 68 6f 73 74 6e 61 6d 65 0a 09  "...  hostname..
3880: 09 20 20 63 70 75 6c 6f 61 64 0a 09 09 20 20 64  .  cpuload...  d
3890: 69 73 6b 66 72 65 65 0a 09 09 20 20 75 6e 61 6d  iskfree...  unam
38a0: 65 0a 09 09 20 20 72 75 6e 70 61 74 68 0a 09 09  e...  runpath...
38b0: 20 20 72 75 6e 2d 69 64 0a 09 09 20 20 74 65 73    run-id...  tes
38c0: 74 6e 61 6d 65 0a 09 09 20 20 69 74 65 6d 2d 70  tname...  item-p
38d0: 61 74 68 29 29 29 0a 0a 28 64 65 66 69 6e 65 20  ath)))..(define 
38e0: 28 74 65 73 74 2d 75 70 64 61 74 65 2d 6d 65 74  (test-update-met
38f0: 61 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64  a-info db run-id
3900: 20 74 65 73 74 6e 61 6d 65 20 69 74 65 6d 64 61   testname itemda
3910: 74 20 6d 69 6e 75 74 65 73 29 0a 20 20 28 6c 65  t minutes).  (le
3920: 74 20 28 28 69 74 65 6d 2d 70 61 74 68 20 28 69  t ((item-path (i
3930: 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69  tem-list->path i
3940: 74 65 6d 64 61 74 29 29 0a 09 28 63 70 75 6c 6f  temdat))..(cpulo
3950: 61 64 20 20 28 67 65 74 2d 63 70 75 2d 6c 6f 61  ad  (get-cpu-loa
3960: 64 29 29 0a 09 28 64 69 73 6b 66 72 65 65 20 28  d))..(diskfree (
3970: 67 65 74 2d 64 66 20 28 63 75 72 72 65 6e 74 2d  get-df (current-
3980: 64 69 72 65 63 74 6f 72 79 29 29 29 29 0a 20 20  directory)))).  
3990: 20 20 28 69 66 20 28 6e 6f 74 20 63 70 75 6c 6f    (if (not cpulo
39a0: 61 64 29 20 20 28 62 65 67 69 6e 20 28 64 65 62  ad)  (begin (deb
39b0: 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e  ug:print 0 "WARN
39c0: 49 4e 47 3a 20 43 50 55 4c 4f 41 44 20 6e 6f 74  ING: CPULOAD not
39d0: 20 66 6f 75 6e 64 2e 22 29 20 20 28 73 65 74 21   found.")  (set!
39e0: 20 63 70 75 6c 6f 61 64 20 22 6e 2f 61 22 29 29   cpuload "n/a"))
39f0: 29 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 64  ).    (if (not d
3a00: 69 73 6b 66 72 65 65 29 20 28 62 65 67 69 6e 20  iskfree) (begin 
3a10: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
3a20: 57 41 52 4e 49 4e 47 3a 20 44 49 53 4b 46 52 45  WARNING: DISKFRE
3a30: 45 20 6e 6f 74 20 66 6f 75 6e 64 2e 22 29 20 28  E not found.") (
3a40: 73 65 74 21 20 64 69 73 6b 66 72 65 65 20 22 6e  set! diskfree "n
3a50: 2f 61 22 29 29 29 0a 20 20 20 20 28 69 66 20 28  /a"))).    (if (
3a60: 6e 6f 74 20 69 74 65 6d 2d 70 61 74 68 29 28 62  not item-path)(b
3a70: 65 67 69 6e 20 28 64 65 62 75 67 3a 70 72 69 6e  egin (debug:prin
3a80: 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 49 54  t 0 "WARNING: IT
3a90: 45 4d 50 41 54 48 20 6e 6f 74 20 73 65 74 2e 22  EMPATH not set."
3aa0: 29 20 20 20 28 73 65 74 21 20 69 74 65 6d 2d 70  )   (set! item-p
3ab0: 61 74 68 20 22 22 29 29 29 0a 20 20 20 20 3b 3b  ath ""))).    ;;
3ac0: 20 28 6c 65 74 20 28 28 74 65 73 74 69 6e 66 6f   (let ((testinfo
3ad0: 20 28 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e   (db:get-test-in
3ae0: 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  fo db run-id tes
3af0: 74 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  tname item-path)
3b00: 29 29 0a 20 20 20 20 3b 3b 20 20 20 28 69 66 20  )).    ;;   (if 
3b10: 28 61 6e 64 20 28 6e 6f 74 20 28 65 71 75 61 6c  (and (not (equal
3b20: 3f 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 73  ? (db:test-get-s
3b30: 74 61 74 75 73 20 74 65 73 74 69 6e 66 6f 29 20  tatus testinfo) 
3b40: 22 43 4f 4d 50 4c 45 54 45 44 22 29 29 0a 20 20  "COMPLETED")).  
3b50: 20 20 3b 3b 20 20 20 20 20 20 20 20 20 20 20 20    ;;            
3b60: 28 6e 6f 74 20 28 65 71 75 61 6c 3f 20 28 64 62  (not (equal? (db
3b70: 3a 74 65 73 74 2d 67 65 74 2d 73 74 61 74 75 73  :test-get-status
3b80: 20 74 65 73 74 69 6e 66 6f 29 20 22 4b 49 4c 4c   testinfo) "KILL
3b90: 52 45 51 22 29 29 0a 20 20 20 20 28 73 71 6c 69  REQ")).    (sqli
3ba0: 74 65 33 3a 65 78 65 63 75 74 65 0a 20 20 20 20  te3:execute.    
3bb0: 20 64 62 0a 20 20 20 20 20 22 55 50 44 41 54 45   db.     "UPDATE
3bc0: 20 74 65 73 74 73 20 53 45 54 20 63 70 75 6c 6f   tests SET cpulo
3bd0: 61 64 3d 3f 2c 64 69 73 6b 66 72 65 65 3d 3f 2c  ad=?,diskfree=?,
3be0: 72 75 6e 5f 64 75 72 61 74 69 6f 6e 3d 3f 2c 73  run_duration=?,s
3bf0: 74 61 74 65 3d 27 52 55 4e 4e 49 4e 47 27 20 57  tate='RUNNING' W
3c00: 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e  HERE run_id=? AN
3c10: 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44  D testname=? AND
3c20: 20 69 74 65 6d 5f 70 61 74 68 3d 3f 20 41 4e 44   item_path=? AND
3c30: 20 73 74 61 74 65 20 4e 4f 54 20 49 4e 20 28 27   state NOT IN ('
3c40: 43 4f 4d 50 4c 45 54 45 44 27 2c 27 4b 49 4c 4c  COMPLETED','KILL
3c50: 52 45 51 27 2c 27 4b 49 4c 4c 45 44 27 29 3b 22  REQ','KILLED');"
3c60: 0a 20 20 20 20 20 63 70 75 6c 6f 61 64 0a 20 20  .     cpuload.  
3c70: 20 20 20 64 69 73 6b 66 72 65 65 0a 20 20 20 20     diskfree.    
3c80: 20 6d 69 6e 75 74 65 73 0a 20 20 20 20 20 72 75   minutes.     ru
3c90: 6e 2d 69 64 0a 20 20 20 20 20 74 65 73 74 6e 61  n-id.     testna
3ca0: 6d 65 0a 20 20 20 20 20 69 74 65 6d 2d 70 61 74  me.     item-pat
3cb0: 68 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 73  h)))..(define (s
3cc0: 65 74 2d 6d 65 67 61 74 65 73 74 2d 65 6e 76 2d  et-megatest-env-
3cd0: 76 61 72 73 20 64 62 20 72 75 6e 2d 69 64 29 0a  vars db run-id).
3ce0: 20 20 28 6c 65 74 20 28 28 6b 65 79 73 20 28 64    (let ((keys (d
3cf0: 62 2d 67 65 74 2d 6b 65 79 73 20 64 62 29 29 29  b-get-keys db)))
3d00: 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20 28  .    (for-each (
3d10: 6c 61 6d 62 64 61 20 28 6b 65 79 29 0a 09 09 28  lambda (key)...(
3d20: 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68  sqlite3:for-each
3d30: 2d 72 6f 77 0a 09 09 20 28 6c 61 6d 62 64 61 20  -row... (lambda 
3d40: 28 76 61 6c 29 0a 09 09 20 20 20 28 64 65 62 75  (val)...   (debu
3d50: 67 3a 70 72 69 6e 74 20 32 20 22 73 65 74 65 6e  g:print 2 "seten
3d60: 76 20 22 20 28 6b 65 79 3a 67 65 74 2d 66 69 65  v " (key:get-fie
3d70: 6c 64 6e 61 6d 65 20 6b 65 79 29 20 22 20 22 20  ldname key) " " 
3d80: 76 61 6c 29 0a 09 09 20 20 20 28 73 65 74 65 6e  val)...   (seten
3d90: 76 20 28 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64  v (key:get-field
3da0: 6e 61 6d 65 20 6b 65 79 29 20 76 61 6c 29 29 0a  name key) val)).
3db0: 09 09 20 64 62 20 0a 09 09 20 28 63 6f 6e 63 20  .. db ... (conc 
3dc0: 22 53 45 4c 45 43 54 20 22 20 28 6b 65 79 3a 67  "SELECT " (key:g
3dd0: 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65 79  et-fieldname key
3de0: 29 20 22 20 46 52 4f 4d 20 72 75 6e 73 20 57 48  ) " FROM runs WH
3df0: 45 52 45 20 69 64 3d 3f 3b 22 29 0a 09 09 20 72  ERE id=?;")... r
3e00: 75 6e 2d 69 64 29 29 0a 09 20 20 20 20 20 20 6b  un-id))..      k
3e10: 65 79 73 29 29 29 0a 0a 28 64 65 66 69 6e 65 20  eys)))..(define 
3e20: 28 73 65 74 2d 69 74 65 6d 2d 65 6e 76 2d 76 61  (set-item-env-va
3e30: 72 73 20 69 74 65 6d 64 61 74 29 0a 20 20 28 66  rs itemdat).  (f
3e40: 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 20  or-each (lambda 
3e50: 28 69 74 65 6d 29 0a 09 20 20 20 20 20 20 28 64  (item)..      (d
3e60: 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 73 65  ebug:print 2 "se
3e70: 74 65 6e 76 20 22 20 28 63 61 72 20 69 74 65 6d  tenv " (car item
3e80: 29 20 22 20 22 20 28 63 61 64 72 20 69 74 65 6d  ) " " (cadr item
3e90: 29 29 0a 09 20 20 20 20 20 20 28 73 65 74 65 6e  ))..      (seten
3ea0: 76 20 28 63 61 72 20 69 74 65 6d 29 20 28 63 61  v (car item) (ca
3eb0: 64 72 20 69 74 65 6d 29 29 29 0a 09 20 20 20 20  dr item)))..    
3ec0: 69 74 65 6d 64 61 74 29 29 0a 0a 28 64 65 66 69  itemdat))..(defi
3ed0: 6e 65 20 28 67 65 74 2d 61 6c 6c 2d 6c 65 67 61  ne (get-all-lega
3ee0: 6c 2d 74 65 73 74 73 29 0a 20 20 28 6c 65 74 2a  l-tests).  (let*
3ef0: 20 28 28 74 65 73 74 73 20 20 28 67 6c 6f 62 20   ((tests  (glob 
3f00: 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74 68 2a 20  (conc *toppath* 
3f10: 22 2f 74 65 73 74 73 2f 2a 22 29 29 29 0a 09 20  "/tests/*"))).. 
3f20: 28 72 65 73 20 20 20 20 27 28 29 29 29 0a 20 20  (res    '())).  
3f30: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34    (debug:print 4
3f40: 20 22 49 4e 46 4f 3a 20 4c 6f 6f 6b 69 6e 67 20   "INFO: Looking 
3f50: 61 74 20 74 65 73 74 73 20 22 20 28 73 74 72 69  at tests " (stri
3f60: 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 74  ng-intersperse t
3f70: 65 73 74 73 20 22 2c 22 29 29 0a 20 20 20 20 28  ests ",")).    (
3f80: 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61  for-each (lambda
3f90: 20 28 74 65 73 74 70 61 74 68 29 0a 09 09 28 69   (testpath)...(i
3fa0: 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20  f (file-exists? 
3fb0: 28 63 6f 6e 63 20 74 65 73 74 70 61 74 68 20 22  (conc testpath "
3fc0: 2f 74 65 73 74 63 6f 6e 66 69 67 22 29 29 0a 09  /testconfig"))..
3fd0: 09 20 20 20 20 28 73 65 74 21 20 72 65 73 20 28  .    (set! res (
3fe0: 63 6f 6e 73 20 28 6c 61 73 74 20 28 73 74 72 69  cons (last (stri
3ff0: 6e 67 2d 73 70 6c 69 74 20 74 65 73 74 70 61 74  ng-split testpat
4000: 68 20 22 2f 22 29 29 20 72 65 73 29 29 29 29 0a  h "/")) res)))).
4010: 09 20 20 20 20 20 20 74 65 73 74 73 29 0a 20 20  .      tests).  
4020: 20 20 72 65 73 29 29 0a 0a 28 64 65 66 69 6e 65    res))..(define
4030: 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d   (runs:can-run-m
4040: 6f 72 65 2d 74 65 73 74 73 20 64 62 29 0a 20 20  ore-tests db).  
4050: 28 6c 65 74 20 28 28 6e 75 6d 2d 72 75 6e 6e 69  (let ((num-runni
4060: 6e 67 20 28 64 62 3a 67 65 74 2d 63 6f 75 6e 74  ng (db:get-count
4070: 2d 74 65 73 74 73 2d 72 75 6e 6e 69 6e 67 20 64  -tests-running d
4080: 62 29 29 0a 09 28 6d 61 78 2d 63 6f 6e 63 75 72  b))..(max-concur
4090: 72 65 6e 74 2d 6a 6f 62 73 20 28 63 6f 6e 66 69  rent-jobs (confi
40a0: 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67  g-lookup *config
40b0: 64 61 74 2a 20 22 73 65 74 75 70 22 20 22 6d 61  dat* "setup" "ma
40c0: 78 5f 63 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f 62  x_concurrent_job
40d0: 73 22 29 29 29 0a 20 20 20 20 28 64 65 62 75 67  s"))).    (debug
40e0: 3a 70 72 69 6e 74 20 32 20 22 6d 61 78 2d 63 6f  :print 2 "max-co
40f0: 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 3a 20 22  ncurrent-jobs: "
4100: 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d   max-concurrent-
4110: 6a 6f 62 73 20 22 2c 20 6e 75 6d 2d 72 75 6e 6e  jobs ", num-runn
4120: 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69  ing: " num-runni
4130: 6e 67 29 0a 20 20 20 20 28 69 66 20 28 6e 6f 74  ng).    (if (not
4140: 20 28 65 71 3f 20 30 20 2a 67 6c 6f 62 61 6c 65   (eq? 0 *globale
4150: 78 69 74 73 74 61 74 75 73 2a 29 29 0a 09 23 66  xitstatus*))..#f
4160: 0a 09 28 69 66 20 28 6f 72 20 28 6e 6f 74 20 6d  ..(if (or (not m
4170: 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f  ax-concurrent-jo
4180: 62 73 29 0a 09 09 28 61 6e 64 20 6d 61 78 2d 63  bs)...(and max-c
4190: 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 0a 09  oncurrent-jobs..
41a0: 09 20 20 20 20 20 28 73 74 72 69 6e 67 2d 3e 6e  .     (string->n
41b0: 75 6d 62 65 72 20 6d 61 78 2d 63 6f 6e 63 75 72  umber max-concur
41c0: 72 65 6e 74 2d 6a 6f 62 73 29 0a 09 09 20 20 20  rent-jobs)...   
41d0: 20 20 28 6e 6f 74 20 28 3e 3d 20 6e 75 6d 2d 72    (not (>= num-r
41e0: 75 6e 6e 69 6e 67 20 28 73 74 72 69 6e 67 2d 3e  unning (string->
41f0: 6e 75 6d 62 65 72 20 6d 61 78 2d 63 6f 6e 63 75  number max-concu
4200: 72 72 65 6e 74 2d 6a 6f 62 73 29 29 29 29 29 0a  rrent-jobs))))).
4210: 09 20 20 20 20 23 74 0a 09 20 20 20 20 28 62 65  .    #t..    (be
4220: 67 69 6e 20 0a 09 20 20 20 20 20 20 28 64 65 62  gin ..      (deb
4230: 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e  ug:print 0 "WARN
4240: 49 4e 47 3a 20 4d 61 78 20 72 75 6e 6e 69 6e 67  ING: Max running
4250: 20 6a 6f 62 73 20 65 78 63 65 65 64 65 64 2c 20   jobs exceeded, 
4260: 63 75 72 72 65 6e 74 20 6e 75 6d 62 65 72 20 72  current number r
4270: 75 6e 6e 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75  unning: " num-ru
4280: 6e 6e 69 6e 67 20 0a 09 09 09 20 20 20 22 2c 20  nning ....   ", 
4290: 6d 61 78 5f 63 6f 6e 63 75 72 72 65 6e 74 5f 6a  max_concurrent_j
42a0: 6f 62 73 3a 20 22 20 6d 61 78 2d 63 6f 6e 63 75  obs: " max-concu
42b0: 72 72 65 6e 74 2d 6a 6f 62 73 29 0a 09 20 20 20  rrent-jobs)..   
42c0: 20 20 20 23 66 29 29 29 29 29 0a 20 20 0a 28 64     #f))))).  .(d
42d0: 65 66 69 6e 65 20 28 72 75 6e 2d 74 65 73 74 73  efine (run-tests
42e0: 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 73 29 0a   db test-names).
42f0: 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 73 20 20    (let* ((keys  
4300: 20 20 20 20 20 20 28 64 62 2d 67 65 74 2d 6b 65        (db-get-ke
4310: 79 73 20 64 62 29 29 0a 09 20 28 6b 65 79 76 61  ys db)).. (keyva
4320: 6c 6c 73 74 20 20 20 28 6b 65 79 73 2d 3e 76 61  llst   (keys->va
4330: 6c 6c 69 73 74 20 6b 65 79 73 20 23 74 29 29 0a  llist keys #t)).
4340: 09 20 28 72 75 6e 2d 69 64 20 20 20 20 20 20 28  . (run-id      (
4350: 72 65 67 69 73 74 65 72 2d 72 75 6e 20 64 62 20  register-run db 
4360: 6b 65 79 73 29 29 20 20 3b 3b 20 20 74 65 73 74  keys))  ;;  test
4370: 2d 6e 61 6d 65 29 29 29 0a 09 20 28 64 65 66 65  -name))).. (defe
4380: 72 72 65 64 20 20 20 20 27 28 29 29 29 20 3b 3b  rred    '())) ;;
4390: 20 64 65 6c 61 79 20 72 75 6e 6e 69 6e 67 20 74   delay running t
43a0: 68 65 73 65 20 73 69 6e 63 65 20 74 68 65 79 20  hese since they 
43b0: 68 61 76 65 20 61 20 77 61 69 74 6f 6e 20 63 6c  have a waiton cl
43c0: 61 75 73 65 0a 20 20 20 20 3b 3b 20 6f 6e 20 74  ause.    ;; on t
43d0: 68 65 20 66 69 72 73 74 20 70 61 73 73 20 6f 72  he first pass or
43e0: 20 63 61 6c 6c 20 74 6f 20 72 75 6e 2d 74 65 73   call to run-tes
43f0: 74 73 20 73 65 74 20 46 41 49 4c 53 20 74 6f 20  ts set FAILS to 
4400: 4e 4f 54 5f 53 54 41 52 54 45 44 20 69 66 0a 20  NOT_STARTED if. 
4410: 20 20 20 3b 3b 20 2d 6b 65 65 70 67 6f 69 6e 67     ;; -keepgoing
4420: 20 69 73 20 73 70 65 63 69 66 69 65 64 0a 20 20   is specified.  
4430: 20 20 28 69 66 20 28 61 6e 64 20 28 65 71 3f 20    (if (and (eq? 
4440: 2a 70 61 73 73 6e 75 6d 2a 20 30 29 0a 09 20 20  *passnum* 0)..  
4450: 20 20 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67     (args:get-arg
4460: 20 22 2d 6b 65 65 70 67 6f 69 6e 67 22 29 29 0a   "-keepgoing")).
4470: 09 28 62 65 67 69 6e 0a 09 20 20 3b 3b 20 68 61  .(begin..  ;; ha
4480: 76 65 20 74 6f 20 64 65 6c 65 74 65 20 74 65 73  ve to delete tes
4490: 74 20 72 65 63 6f 72 64 73 20 77 68 65 72 65 20  t records where 
44a0: 4e 4f 54 5f 53 54 41 52 54 45 44 20 73 69 6e 63  NOT_STARTED sinc
44b0: 65 20 74 68 65 79 20 63 61 6e 20 63 61 75 73 65  e they can cause
44c0: 20 2d 6b 65 65 70 67 6f 69 6e 67 20 74 6f 20 0a   -keepgoing to .
44d0: 09 20 20 3b 3b 20 67 65 74 20 73 74 75 63 6b 20  .  ;; get stuck 
44e0: 64 75 65 20 74 6f 20 62 65 63 6f 6d 69 6e 67 20  due to becoming 
44f0: 69 6e 61 63 63 65 73 73 69 62 6c 65 20 66 72 6f  inaccessible fro
4500: 6d 20 61 20 66 61 69 6c 65 64 20 74 65 73 74 2e  m a failed test.
4510: 20 49 2e 65 2e 20 69 66 20 74 65 73 74 20 42 20   I.e. if test B 
4520: 64 65 70 65 6e 64 73 20 0a 09 20 20 3b 3b 20 6f  depends ..  ;; o
4530: 6e 20 74 65 73 74 20 41 20 62 75 74 20 74 65 73  n test A but tes
4540: 74 20 42 20 72 65 61 63 68 65 64 20 74 68 65 20  t B reached the 
4550: 70 6f 69 6e 74 20 6f 6e 20 62 65 69 6e 67 20 72  point on being r
4560: 65 67 69 73 74 65 72 65 64 20 61 73 20 4e 4f 54  egistered as NOT
4570: 5f 53 54 41 52 54 45 44 20 61 6e 64 20 74 65 73  _STARTED and tes
4580: 74 0a 09 20 20 3b 3b 20 41 20 66 61 69 6c 65 64  t..  ;; A failed
4590: 20 66 6f 72 20 73 6f 6d 65 20 72 65 61 73 6f 6e   for some reason
45a0: 20 74 68 65 6e 20 6f 6e 20 72 65 2d 72 75 6e 20   then on re-run 
45b0: 75 73 69 6e 67 20 2d 6b 65 65 70 67 6f 69 6e 67  using -keepgoing
45c0: 20 74 68 65 20 72 75 6e 20 63 61 6e 20 6e 65 76   the run can nev
45d0: 65 72 20 63 6f 6d 70 6c 65 74 65 2e 0a 09 20 20  er complete...  
45e0: 28 64 62 3a 64 65 6c 65 74 65 2d 74 65 73 74 73  (db:delete-tests
45f0: 2d 69 6e 2d 73 74 61 74 65 20 64 62 20 72 75 6e  -in-state db run
4600: 2d 69 64 20 22 4e 4f 54 5f 53 54 41 52 54 45 44  -id "NOT_STARTED
4610: 22 29 0a 09 20 20 28 64 62 3a 73 65 74 2d 74 65  ")..  (db:set-te
4620: 73 74 73 2d 73 74 61 74 65 2d 73 74 61 74 75 73  sts-state-status
4630: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d   db run-id test-
4640: 6e 61 6d 65 73 20 23 66 20 22 46 41 49 4c 22 20  names #f "FAIL" 
4650: 22 4e 4f 54 5f 53 54 41 52 54 45 44 22 20 22 46  "NOT_STARTED" "F
4660: 41 49 4c 22 29 29 29 0a 20 20 20 20 28 73 65 74  AIL"))).    (set
4670: 21 20 2a 70 61 73 73 6e 75 6d 2a 20 28 2b 20 2a  ! *passnum* (+ *
4680: 70 61 73 73 6e 75 6d 2a 20 31 29 29 0a 20 20 20  passnum* 1)).   
4690: 20 28 6c 65 74 20 6c 6f 6f 70 20 28 28 6e 75 6d   (let loop ((num
46a0: 74 69 6d 65 73 20 30 29 29 0a 20 20 20 20 20 20  times 0)).      
46b0: 28 66 6f 72 2d 65 61 63 68 20 0a 20 20 20 20 20  (for-each .     
46c0: 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74 2d    (lambda (test-
46d0: 6e 61 6d 65 29 0a 09 20 28 69 66 20 28 72 75 6e  name).. (if (run
46e0: 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65 2d 74  s:can-run-more-t
46f0: 65 73 74 73 20 64 62 29 0a 09 20 20 20 20 20 28  ests db)..     (
4700: 72 75 6e 2d 6f 6e 65 2d 74 65 73 74 20 64 62 20  run-one-test db 
4710: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
4720: 20 6b 65 79 76 61 6c 6c 73 74 29 0a 09 20 20 20   keyvallst)..   
4730: 20 20 3b 3b 20 61 64 64 20 73 6f 6d 65 20 64 65    ;; add some de
4740: 6c 61 79 20 0a 09 20 20 20 20 20 3b 28 73 6c 65  lay ..     ;(sle
4750: 65 70 20 32 29 0a 09 20 20 20 20 20 29 29 0a 20  ep 2)..     )). 
4760: 20 20 20 20 20 20 74 65 73 74 2d 6e 61 6d 65 73        test-names
4770: 29 0a 20 20 20 20 20 20 3b 3b 20 28 72 75 6e 2d  ).      ;; (run-
4780: 77 61 69 74 69 6e 67 2d 74 65 73 74 73 20 64 62  waiting-tests db
4790: 29 0a 20 20 20 20 20 20 28 69 66 20 28 61 72 67  ).      (if (arg
47a0: 73 3a 67 65 74 2d 61 72 67 20 22 2d 6b 65 65 70  s:get-arg "-keep
47b0: 67 6f 69 6e 67 22 29 0a 09 20 20 28 6c 65 74 20  going")..  (let 
47c0: 28 28 65 73 74 72 65 6d 20 28 64 62 3a 65 73 74  ((estrem (db:est
47d0: 69 6d 61 74 65 64 2d 74 65 73 74 73 2d 72 65 6d  imated-tests-rem
47e0: 61 69 6e 69 6e 67 20 64 62 20 72 75 6e 2d 69 64  aining db run-id
47f0: 29 29 29 0a 09 20 20 20 20 28 69 66 20 28 61 6e  )))..    (if (an
4800: 64 20 28 3e 20 65 73 74 72 65 6d 20 30 29 0a 09  d (> estrem 0)..
4810: 09 20 20 20 20 20 28 65 71 3f 20 2a 67 6c 6f 62  .     (eq? *glob
4820: 61 6c 65 78 69 74 73 74 61 74 75 73 2a 20 30 29  alexitstatus* 0)
4830: 29 0a 09 09 28 62 65 67 69 6e 0a 09 09 20 20 28  )...(begin...  (
4840: 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 4b  debug:print 1 "K
4850: 65 65 70 20 67 6f 69 6e 67 2c 20 65 73 74 69 6d  eep going, estim
4860: 61 74 65 64 20 22 20 65 73 74 72 65 6d 20 22 20  ated " estrem " 
4870: 74 65 73 74 73 20 72 65 6d 61 69 6e 69 6e 67 20  tests remaining 
4880: 74 6f 20 72 75 6e 2c 20 77 69 6c 6c 20 63 6f 6e  to run, will con
4890: 74 69 6e 75 65 20 69 6e 20 33 20 73 65 63 6f 6e  tinue in 3 secon
48a0: 64 73 20 2e 2e 2e 22 29 0a 09 09 20 20 28 73 6c  ds ...")...  (sl
48b0: 65 65 70 20 33 29 0a 09 09 20 20 28 72 75 6e 2d  eep 3)...  (run-
48c0: 77 61 69 74 69 6e 67 2d 74 65 73 74 73 20 64 62  waiting-tests db
48d0: 29 0a 09 09 20 20 28 6c 6f 6f 70 20 28 2b 20 6e  )...  (loop (+ n
48e0: 75 6d 74 69 6d 65 73 20 31 29 29 29 29 29 29 29  umtimes 1)))))))
48f0: 29 29 0a 09 20 20 20 0a 3b 3b 20 56 45 52 59 20  ))..   .;; VERY 
4900: 49 4e 45 46 46 49 43 49 45 4e 54 21 20 4d 6f 76  INEFFICIENT! Mov
4910: 65 20 73 74 75 66 66 20 74 68 61 74 20 73 68 6f  e stuff that sho
4920: 75 6c 64 20 62 65 20 64 6f 6e 65 20 6f 6e 63 65  uld be done once
4930: 20 75 70 20 74 6f 20 63 61 6c 6c 69 6e 67 20 70   up to calling p
4940: 72 6f 63 0a 28 64 65 66 69 6e 65 20 28 72 75 6e  roc.(define (run
4950: 2d 6f 6e 65 2d 74 65 73 74 20 64 62 20 72 75 6e  -one-test db run
4960: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 6b 65  -id test-name ke
4970: 79 76 61 6c 6c 73 74 29 0a 20 20 28 64 65 62 75  yvallst).  (debu
4980: 67 3a 70 72 69 6e 74 20 31 20 22 4c 61 75 6e 63  g:print 1 "Launc
4990: 68 69 6e 67 20 74 65 73 74 20 22 20 74 65 73 74  hing test " test
49a0: 2d 6e 61 6d 65 29 0a 20 20 3b 3b 20 41 6c 6c 20  -name).  ;; All 
49b0: 74 68 65 73 65 20 76 61 72 73 20 6d 69 67 68 74  these vars might
49c0: 20 62 65 20 72 65 66 65 72 65 6e 63 65 64 20 62   be referenced b
49d0: 79 20 74 68 65 20 74 65 73 74 63 6f 6e 66 69 67  y the testconfig
49e0: 20 66 69 6c 65 20 72 65 61 64 65 72 0a 20 20 28   file reader.  (
49f0: 73 65 74 65 6e 76 20 22 4d 54 5f 54 45 53 54 5f  setenv "MT_TEST_
4a00: 4e 41 4d 45 22 20 74 65 73 74 2d 6e 61 6d 65 29  NAME" test-name)
4a10: 20 3b 3b 20 0a 20 20 28 73 65 74 65 6e 76 20 22   ;; .  (setenv "
4a20: 4d 54 5f 52 55 4e 4e 41 4d 45 22 20 20 20 28 61  MT_RUNNAME"   (a
4a30: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 3a 72 75  rgs:get-arg ":ru
4a40: 6e 6e 61 6d 65 22 29 29 0a 20 20 28 73 65 74 2d  nname")).  (set-
4a50: 6d 65 67 61 74 65 73 74 2d 65 6e 76 2d 76 61 72  megatest-env-var
4a60: 73 20 64 62 20 72 75 6e 2d 69 64 29 20 3b 3b 20  s db run-id) ;; 
4a70: 74 68 65 73 65 20 6d 61 79 20 62 65 20 6e 65 65  these may be nee
4a80: 64 65 64 20 62 79 20 74 68 65 20 6c 61 75 6e 63  ded by the launc
4a90: 68 69 6e 67 20 70 72 6f 63 65 73 73 0a 20 20 28  hing process.  (
4aa0: 63 68 61 6e 67 65 2d 64 69 72 65 63 74 6f 72 79  change-directory
4ab0: 20 2a 74 6f 70 70 61 74 68 2a 29 0a 20 20 28 6c   *toppath*).  (l
4ac0: 65 74 2a 20 28 28 74 65 73 74 2d 70 61 74 68 20  et* ((test-path 
4ad0: 20 20 20 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74     (conc *toppat
4ae0: 68 2a 20 22 2f 74 65 73 74 73 2f 22 20 74 65 73  h* "/tests/" tes
4af0: 74 2d 6e 61 6d 65 29 29 0a 09 20 28 74 65 73 74  t-name)).. (test
4b00: 2d 63 6f 6e 66 69 67 66 20 28 63 6f 6e 63 20 74  -configf (conc t
4b10: 65 73 74 2d 70 61 74 68 20 22 2f 74 65 73 74 63  est-path "/testc
4b20: 6f 6e 66 69 67 22 29 29 0a 09 20 28 74 65 73 74  onfig")).. (test
4b30: 65 78 69 73 74 73 20 20 20 28 61 6e 64 20 28 66  exists   (and (f
4b40: 69 6c 65 2d 65 78 69 73 74 73 3f 20 74 65 73 74  ile-exists? test
4b50: 2d 63 6f 6e 66 69 67 66 29 28 66 69 6c 65 2d 72  -configf)(file-r
4b60: 65 61 64 2d 61 63 63 65 73 73 3f 20 74 65 73 74  ead-access? test
4b70: 2d 63 6f 6e 66 69 67 66 29 29 29 0a 09 20 28 74  -configf))).. (t
4b80: 65 73 74 2d 63 6f 6e 66 20 20 20 20 28 69 66 20  est-conf    (if 
4b90: 74 65 73 74 65 78 69 73 74 73 20 28 72 65 61 64  testexists (read
4ba0: 2d 63 6f 6e 66 69 67 20 74 65 73 74 2d 63 6f 6e  -config test-con
4bb0: 66 69 67 66 20 23 66 20 23 74 29 20 28 6d 61 6b  figf #f #t) (mak
4bc0: 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29 29 0a  e-hash-table))).
4bd0: 09 20 28 77 61 69 74 6f 6e 20 20 20 20 20 20 20  . (waiton       
4be0: 28 6c 65 74 20 28 28 77 20 28 63 6f 6e 66 69 67  (let ((w (config
4bf0: 2d 6c 6f 6f 6b 75 70 20 74 65 73 74 2d 63 6f 6e  -lookup test-con
4c00: 66 20 22 72 65 71 75 69 72 65 6d 65 6e 74 73 22  f "requirements"
4c10: 20 22 77 61 69 74 6f 6e 22 29 29 29 0a 09 09 09   "waiton")))....
4c20: 20 28 69 66 20 28 73 74 72 69 6e 67 3f 20 77 29   (if (string? w)
4c30: 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 77 29  (string-split w)
4c40: 27 28 29 29 29 29 0a 09 20 28 74 61 67 73 20 20  '()))).. (tags  
4c50: 20 20 20 20 20 20 20 28 6c 65 74 20 28 28 74 20         (let ((t 
4c60: 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 74  (config-lookup t
4c70: 65 73 74 2d 63 6f 6e 66 20 22 73 65 74 75 70 22  est-conf "setup"
4c80: 20 22 74 61 67 73 22 29 29 29 0a 09 09 09 20 3b   "tags"))).... ;
4c90: 3b 20 77 65 20 77 61 6e 74 20 6f 75 72 20 74 61  ; we want our ta
4ca0: 67 73 20 74 6f 20 62 65 20 73 65 70 61 72 61 74  gs to be separat
4cb0: 65 64 20 62 79 20 63 6f 6d 6d 61 73 20 61 6e 64  ed by commas and
4cc0: 20 66 75 6c 6c 79 20 64 65 6c 69 6d 69 74 65 64   fully delimited
4cd0: 20 62 79 20 63 6f 6d 6d 61 73 0a 09 09 09 20 3b   by commas.... ;
4ce0: 3b 20 73 6f 20 74 68 61 74 20 71 75 65 72 69 65  ; so that querie
4cf0: 73 20 77 69 74 68 20 22 6c 69 6b 65 22 20 63 61  s with "like" ca
4d00: 6e 20 74 69 65 20 74 6f 20 74 68 65 20 63 6f 6d  n tie to the com
4d10: 6d 61 73 20 61 74 20 65 69 74 68 65 72 20 65 6e  mas at either en
4d20: 64 20 6f 66 20 65 61 63 68 20 74 61 67 0a 09 09  d of each tag...
4d30: 09 20 3b 3b 20 77 68 69 6c 65 20 61 6c 73 6f 20  . ;; while also 
4d40: 61 6c 6c 6f 77 69 6e 67 20 74 68 65 20 65 6e 64  allowing the end
4d50: 20 75 73 65 72 20 74 6f 20 66 72 65 65 6c 79 20   user to freely 
4d60: 75 73 65 20 73 70 61 63 65 73 20 61 6e 64 20 63  use spaces and c
4d70: 6f 6d 6d 61 73 20 74 6f 20 73 65 70 61 72 61 74  ommas to separat
4d80: 65 20 74 61 67 73 0a 09 09 09 20 28 69 66 20 28  e tags.... (if (
4d90: 73 74 72 69 6e 67 3f 20 74 29 28 73 74 72 69 6e  string? t)(strin
4da0: 67 2d 73 75 62 73 74 69 74 75 74 65 20 28 72 65  g-substitute (re
4db0: 67 65 78 70 20 22 5b 2c 5c 5c 73 5d 2b 22 29 20  gexp "[,\\s]+") 
4dc0: 22 2c 22 20 28 63 6f 6e 63 20 22 2c 22 20 74 20  "," (conc "," t 
4dd0: 22 2c 22 29 20 23 74 29 0a 09 09 09 20 20 20 20  ",") #t)....    
4de0: 20 27 28 29 29 29 29 29 0a 20 20 20 20 28 69 66   '())))).    (if
4df0: 20 28 6e 6f 74 20 74 65 73 74 65 78 69 73 74 73   (not testexists
4e00: 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 28 64 65  )..(begin..  (de
4e10: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52  bug:print 0 "ERR
4e20: 4f 52 3a 20 43 61 6e 27 74 20 66 69 6e 64 20 63  OR: Can't find c
4e30: 6f 6e 66 69 67 20 66 69 6c 65 20 22 20 74 65 73  onfig file " tes
4e40: 74 2d 63 6f 6e 66 69 67 66 29 0a 09 20 20 28 65  t-configf)..  (e
4e50: 78 69 74 20 32 29 29 0a 09 3b 3b 20 70 75 74 20  xit 2))..;; put 
4e60: 74 6f 70 20 76 61 72 73 20 69 6e 74 6f 20 63 6f  top vars into co
4e70: 6e 76 65 6e 69 65 6e 74 20 76 61 72 69 61 62 6c  nvenient variabl
4e80: 65 73 20 61 6e 64 20 6f 70 65 6e 20 74 68 65 20  es and open the 
4e90: 64 62 0a 09 28 6c 65 74 2a 20 28 3b 3b 20 64 62  db..(let* (;; db
4ea0: 20 69 73 20 61 6c 77 61 79 73 20 61 74 20 2a 74   is always at *t
4eb0: 6f 70 70 61 74 68 2a 2f 64 62 2f 6d 65 67 61 74  oppath*/db/megat
4ec0: 65 73 74 2e 64 62 0a 09 20 20 20 20 20 20 20 28  est.db..       (
4ed0: 69 74 65 6d 73 20 20 20 20 20 20 20 28 68 61 73  items       (has
4ee0: 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61  h-table-ref/defa
4ef0: 75 6c 74 20 74 65 73 74 2d 63 6f 6e 66 20 22 69  ult test-conf "i
4f00: 74 65 6d 73 22 20 27 28 29 29 29 0a 09 20 20 20  tems" '()))..   
4f10: 20 20 20 20 28 69 74 65 6d 73 74 61 62 6c 65 20      (itemstable 
4f20: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
4f30: 2f 64 65 66 61 75 6c 74 20 74 65 73 74 2d 63 6f  /default test-co
4f40: 6e 66 20 22 69 74 65 6d 73 74 61 62 6c 65 22 20  nf "itemstable" 
4f50: 27 28 29 29 29 0a 09 20 20 20 20 20 20 20 28 61  '()))..       (a
4f60: 6c 6c 69 74 65 6d 73 20 20 20 20 28 69 66 20 28  llitems    (if (
4f70: 6f 72 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 69  or (not (null? i
4f80: 74 65 6d 73 29 29 28 6e 6f 74 20 28 6e 75 6c 6c  tems))(not (null
4f90: 3f 20 69 74 65 6d 73 74 61 62 6c 65 29 29 29 0a  ? itemstable))).
4fa0: 09 09 09 09 28 61 70 70 65 6e 64 20 28 69 74 65  ....(append (ite
4fb0: 6d 2d 61 73 73 6f 63 2d 3e 69 74 65 6d 2d 6c 69  m-assoc->item-li
4fc0: 73 74 20 69 74 65 6d 73 29 0a 09 09 09 09 09 28  st items)......(
4fd0: 69 74 65 6d 2d 74 61 62 6c 65 2d 3e 69 74 65 6d  item-table->item
4fe0: 2d 6c 69 73 74 20 69 74 65 6d 73 74 61 62 6c 65  -list itemstable
4ff0: 29 29 0a 09 09 09 09 27 28 28 29 29 29 29 20 3b  )).....'(()))) ;
5000: 3b 20 61 20 6c 69 73 74 20 77 69 74 68 20 6f 6e  ; a list with on
5010: 65 20 6e 75 6c 6c 20 6c 69 73 74 20 69 73 20 61  e null list is a
5020: 20 74 65 73 74 20 77 69 74 68 20 6e 6f 20 69 74   test with no it
5030: 65 6d 73 0a 09 20 20 20 20 20 20 20 28 72 75 6e  ems..       (run
5040: 63 6f 6e 66 69 67 66 20 20 28 63 6f 6e 63 20 20  configf  (conc  
5050: 2a 74 6f 70 70 61 74 68 2a 20 22 2f 72 75 6e 63  *toppath* "/runc
5060: 6f 6e 66 69 67 73 2e 63 6f 6e 66 69 67 22 29 29  onfigs.config"))
5070: 29 0a 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e  )..  (debug:prin
5080: 74 20 31 20 22 69 74 65 6d 73 3a 20 22 29 0a 09  t 1 "items: ")..
5090: 20 20 28 69 66 20 28 3e 3d 20 2a 76 65 72 62 6f    (if (>= *verbo
50a0: 73 69 74 79 2a 20 31 29 28 70 70 20 61 6c 6c 69  sity* 1)(pp alli
50b0: 74 65 6d 73 29 29 0a 09 20 20 28 69 66 20 28 3e  tems))..  (if (>
50c0: 3d 20 2a 76 65 72 62 6f 73 69 74 79 2a 20 35 29  = *verbosity* 5)
50d0: 0a 09 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09  ..      (begin..
50e0: 09 28 70 72 69 6e 74 20 22 69 74 65 6d 73 3a 20  .(print "items: 
50f0: 22 29 28 70 70 20 28 69 74 65 6d 2d 61 73 73 6f  ")(pp (item-asso
5100: 63 2d 3e 69 74 65 6d 2d 6c 69 73 74 20 69 74 65  c->item-list ite
5110: 6d 73 29 29 0a 09 09 28 70 72 69 6e 74 20 22 69  ms))...(print "i
5120: 74 65 73 74 61 62 6c 65 3a 20 22 29 28 70 70 20  testable: ")(pp 
5130: 28 69 74 65 6d 2d 74 61 62 6c 65 2d 3e 69 74 65  (item-table->ite
5140: 6d 2d 6c 69 73 74 20 69 74 65 6d 73 74 61 62 6c  m-list itemstabl
5150: 65 29 29 29 29 0a 09 20 20 28 69 66 20 28 61 72  e))))..  (if (ar
5160: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 6d 22 29  gs:get-arg "-m")
5170: 0a 09 20 20 20 20 20 20 28 64 62 3a 73 65 74 2d  ..      (db:set-
5180: 63 6f 6d 6d 65 6e 74 2d 66 6f 72 2d 72 75 6e 20  comment-for-run 
5190: 64 62 20 72 75 6e 2d 69 64 20 28 61 72 67 73 3a  db run-id (args:
51a0: 67 65 74 2d 61 72 67 20 22 2d 6d 22 29 29 29 0a  get-arg "-m"))).
51b0: 0a 09 20 20 3b 3b 20 48 65 72 65 20 69 73 20 77  ..  ;; Here is w
51c0: 68 65 72 65 20 74 68 65 20 74 65 73 74 5f 6d 65  here the test_me
51d0: 74 61 20 74 61 62 6c 65 20 69 73 20 62 65 73 74  ta table is best
51e0: 20 75 70 64 61 74 65 64 0a 09 20 20 28 72 75 6e   updated..  (run
51f0: 73 3a 75 70 64 61 74 65 2d 74 65 73 74 5f 6d 65  s:update-test_me
5200: 74 61 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 20  ta db test-name 
5210: 74 65 73 74 2d 63 6f 6e 66 29 0a 0a 09 20 20 3b  test-conf)...  ;
5220: 3b 20 62 72 61 69 6e 64 65 61 64 20 77 6f 72 6b  ; braindead work
5230: 2d 61 72 6f 75 6e 64 20 66 6f 72 20 70 6f 6f 72  -around for poor
5240: 6c 79 20 73 70 65 63 69 66 69 65 64 20 61 6c 6c  ly specified all
5250: 69 74 65 6d 73 20 6c 69 73 74 20 42 55 47 21 21  items list BUG!!
5260: 21 20 46 49 58 4d 45 0a 09 20 20 28 69 66 20 28  ! FIXME..  (if (
5270: 6e 75 6c 6c 3f 20 61 6c 6c 69 74 65 6d 73 29 28  null? allitems)(
5280: 73 65 74 21 20 61 6c 6c 69 74 65 6d 73 20 27 28  set! allitems '(
5290: 28 29 29 29 29 0a 09 20 20 28 6c 65 74 20 6c 6f  ())))..  (let lo
52a0: 6f 70 20 28 28 69 74 65 6d 64 61 74 20 28 63 61  op ((itemdat (ca
52b0: 72 20 61 6c 6c 69 74 65 6d 73 29 29 0a 09 09 20  r allitems))... 
52c0: 20 20 20 20 28 74 61 6c 20 20 20 20 20 28 63 64      (tal     (cd
52d0: 72 20 61 6c 6c 69 74 65 6d 73 29 29 29 0a 09 20  r allitems))).. 
52e0: 20 20 20 3b 3b 20 28 6c 61 6d 62 64 61 20 28 69     ;; (lambda (i
52f0: 74 65 6d 64 61 74 29 20 3b 3b 3b 20 28 28 72 69  temdat) ;;; ((ri
5300: 70 65 6e 65 73 73 20 22 6f 76 65 72 72 69 70 65  peness "overripe
5310: 22 29 20 28 74 65 6d 70 65 72 61 74 75 72 65 20  ") (temperature 
5320: 22 63 6f 6f 6c 22 29 20 28 73 65 61 73 6f 6e 20  "cool") (season 
5330: 22 73 75 6d 6d 65 72 22 29 29 0a 09 20 20 20 20  "summer"))..    
5340: 3b 3b 20 48 61 6e 64 6c 65 20 6c 69 73 74 73 20  ;; Handle lists 
5350: 6f 66 20 69 74 65 6d 73 0a 09 20 20 20 20 28 6c  of items..    (l
5360: 65 74 2a 20 28 28 69 74 65 6d 2d 70 61 74 68 20  et* ((item-path 
5370: 20 20 20 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e      (item-list->
5380: 70 61 74 68 20 69 74 65 6d 64 61 74 29 29 20 3b  path itemdat)) ;
5390: 3b 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73  ; (string-inters
53a0: 70 65 72 73 65 20 28 6d 61 70 20 63 61 64 72 20  perse (map cadr 
53b0: 69 74 65 6d 64 61 74 29 20 22 2f 22 29 29 0a 09  itemdat) "/"))..
53c0: 09 20 20 20 28 6e 65 77 2d 74 65 73 74 2d 70 61  .   (new-test-pa
53d0: 74 68 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72  th (string-inter
53e0: 73 70 65 72 73 65 20 28 63 6f 6e 73 20 74 65 73  sperse (cons tes
53f0: 74 2d 70 61 74 68 20 28 6d 61 70 20 63 61 64 72  t-path (map cadr
5400: 20 69 74 65 6d 64 61 74 29 29 20 22 2f 22 29 29   itemdat)) "/"))
5410: 0a 09 09 20 20 20 28 6e 65 77 2d 74 65 73 74 2d  ...   (new-test-
5420: 6e 61 6d 65 20 28 69 66 20 28 65 71 75 61 6c 3f  name (if (equal?
5430: 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29 20 74   item-path "") t
5440: 65 73 74 2d 6e 61 6d 65 20 28 63 6f 6e 63 20 74  est-name (conc t
5450: 65 73 74 2d 6e 61 6d 65 20 22 2f 22 20 69 74 65  est-name "/" ite
5460: 6d 2d 70 61 74 68 29 29 29 20 3b 3b 20 6a 75 73  m-path))) ;; jus
5470: 74 20 6e 65 65 64 20 69 74 20 74 6f 20 62 65 20  t need it to be 
5480: 75 6e 69 71 75 65 0a 09 09 20 20 20 28 74 65 73  unique...   (tes
5490: 74 64 61 74 20 20 20 23 66 29 0a 09 09 20 20 20  tdat   #f)...   
54a0: 28 6e 75 6d 2d 72 75 6e 6e 69 6e 67 20 28 64 62  (num-running (db
54b0: 3a 67 65 74 2d 63 6f 75 6e 74 2d 74 65 73 74 73  :get-count-tests
54c0: 2d 72 75 6e 6e 69 6e 67 20 64 62 29 29 0a 09 09  -running db))...
54d0: 20 20 20 28 6d 61 78 2d 63 6f 6e 63 75 72 72 65     (max-concurre
54e0: 6e 74 2d 6a 6f 62 73 20 28 63 6f 6e 66 69 67 2d  nt-jobs (config-
54f0: 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67 64 61  lookup *configda
5500: 74 2a 20 22 73 65 74 75 70 22 20 22 6d 61 78 5f  t* "setup" "max_
5510: 63 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f 62 73 22  concurrent_jobs"
5520: 29 29 0a 09 09 20 20 20 28 70 61 72 65 6e 74 2d  ))...   (parent-
5530: 74 65 73 74 20 28 61 6e 64 20 28 6e 6f 74 20 28  test (and (not (
5540: 6e 75 6c 6c 3f 20 69 74 65 6d 73 29 29 28 65 71  null? items))(eq
5550: 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22  ual? item-path "
5560: 22 29 29 29 0a 09 09 20 20 20 28 73 69 6e 67 6c  ")))...   (singl
5570: 65 2d 74 65 73 74 20 28 61 6e 64 20 28 6e 75 6c  e-test (and (nul
5580: 6c 3f 20 69 74 65 6d 73 29 20 28 65 71 75 61 6c  l? items) (equal
5590: 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29 29  ? item-path ""))
55a0: 29 0a 09 09 20 20 20 28 69 74 65 6d 2d 74 65 73  )...   (item-tes
55b0: 74 20 20 20 28 6e 6f 74 20 28 65 71 75 61 6c 3f  t   (not (equal?
55c0: 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29 29 29   item-path "")))
55d0: 29 0a 09 20 20 20 20 20 20 28 64 65 62 75 67 3a  )..      (debug:
55e0: 70 72 69 6e 74 20 33 20 22 6d 61 78 2d 63 6f 6e  print 3 "max-con
55f0: 63 75 72 72 65 6e 74 2d 6a 6f 62 73 3a 20 22 20  current-jobs: " 
5600: 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a  max-concurrent-j
5610: 6f 62 73 20 22 2c 20 6e 75 6d 2d 72 75 6e 6e 69  obs ", num-runni
5620: 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69 6e  ng: " num-runnin
5630: 67 29 0a 09 20 20 20 20 20 20 28 69 66 20 28 72  g)..      (if (r
5640: 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65  uns:can-run-more
5650: 2d 74 65 73 74 73 20 64 62 29 0a 09 09 20 20 28  -tests db)...  (
5660: 62 65 67 69 6e 0a 09 09 20 20 20 20 28 6c 65 74  begin...    (let
5670: 20 6c 6f 6f 70 32 20 28 28 74 73 20 28 64 62 3a   loop2 ((ts (db:
5680: 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62  get-test-info db
5690: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
56a0: 65 20 69 74 65 6d 2d 70 61 74 68 29 29 20 3b 3b  e item-path)) ;;
56b0: 20 23 66 29 0a 09 09 09 09 28 63 74 20 30 29 29   #f).....(ct 0))
56c0: 0a 09 09 20 20 20 20 20 20 28 69 66 20 28 61 6e  ...      (if (an
56d0: 64 20 28 6e 6f 74 20 74 73 29 0a 09 09 09 20 20  d (not ts)....  
56e0: 20 20 20 20 20 28 3c 20 63 74 20 31 30 29 29 0a       (< ct 10)).
56f0: 09 09 09 20 20 28 62 65 67 69 6e 0a 09 09 09 20  ...  (begin.... 
5700: 20 20 20 28 72 65 67 69 73 74 65 72 2d 74 65 73     (register-tes
5710: 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  t db run-id test
5720: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  -name item-path)
5730: 0a 09 09 09 20 20 20 20 28 64 62 3a 74 65 73 74  ....    (db:test
5740: 2d 73 65 74 2d 63 6f 6d 6d 65 6e 74 20 64 62 20  -set-comment db 
5750: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
5760: 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29 0a 09   item-path "")..
5770: 09 09 20 20 20 20 28 6c 6f 6f 70 32 20 28 64 62  ..    (loop2 (db
5780: 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64  :get-test-info d
5790: 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  b run-id test-na
57a0: 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 09  me item-path)...
57b0: 09 09 20 20 20 28 2b 20 63 74 20 31 29 29 29 0a  ..   (+ ct 1))).
57c0: 09 09 09 20 20 28 69 66 20 74 73 0a 09 09 09 20  ...  (if ts.... 
57d0: 20 20 20 20 20 28 73 65 74 21 20 74 65 73 74 64       (set! testd
57e0: 61 74 20 74 73 29 0a 09 09 09 20 20 20 20 20 20  at ts)....      
57f0: 28 62 65 67 69 6e 0a 09 09 09 09 28 64 65 62 75  (begin.....(debu
5800: 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e 49  g:print 0 "WARNI
5810: 4e 47 3a 20 43 6f 75 6c 64 6e 27 74 20 72 65 67  NG: Couldn't reg
5820: 69 73 74 65 72 20 74 65 73 74 20 22 20 74 65 73  ister test " tes
5830: 74 2d 6e 61 6d 65 20 22 20 77 69 74 68 20 69 74  t-name " with it
5840: 65 6d 20 70 61 74 68 20 22 20 69 74 65 6d 2d 70  em path " item-p
5850: 61 74 68 20 22 2c 20 73 6b 69 70 70 69 6e 67 22  ath ", skipping"
5860: 29 0a 09 09 09 09 28 69 66 20 28 6e 6f 74 20 28  ).....(if (not (
5870: 6e 75 6c 6c 3f 20 74 61 6c 29 29 0a 09 09 09 09  null? tal)).....
5880: 20 20 20 20 28 6c 6f 6f 70 20 28 63 61 72 20 74      (loop (car t
5890: 61 6c 29 28 63 64 72 20 74 61 6c 29 29 29 29 29  al)(cdr tal)))))
58a0: 29 29 0a 09 09 20 20 20 20 28 63 68 61 6e 67 65  ))...    (change
58b0: 2d 64 69 72 65 63 74 6f 72 79 20 74 65 73 74 2d  -directory test-
58c0: 70 61 74 68 29 0a 09 09 20 20 20 20 3b 3b 20 74  path)...    ;; t
58d0: 68 69 73 20 62 6c 6f 63 6b 20 69 73 20 68 65 72  his block is her
58e0: 65 20 6f 6e 6c 79 20 74 6f 20 69 6e 66 6f 72 6d  e only to inform
58f0: 20 74 68 65 20 75 73 65 72 20 65 61 72 6c 79 20   the user early 
5900: 6f 6e 0a 09 09 20 20 20 20 28 69 66 20 28 66 69  on...    (if (fi
5910: 6c 65 2d 65 78 69 73 74 73 3f 20 72 75 6e 63 6f  le-exists? runco
5920: 6e 66 69 67 66 29 0a 09 09 09 28 73 65 74 75 70  nfigf)....(setup
5930: 2d 65 6e 76 2d 64 65 66 61 75 6c 74 73 20 64 62  -env-defaults db
5940: 20 72 75 6e 63 6f 6e 66 69 67 66 20 72 75 6e 2d   runconfigf run-
5950: 69 64 20 2a 61 6c 72 65 61 64 79 2d 73 65 65 6e  id *already-seen
5960: 2d 72 75 6e 63 6f 6e 66 69 67 2d 69 6e 66 6f 2a  -runconfig-info*
5970: 29 0a 09 09 09 28 64 65 62 75 67 3a 70 72 69 6e  )....(debug:prin
5980: 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 59 6f  t 0 "WARNING: Yo
5990: 75 20 64 6f 20 6e 6f 74 20 68 61 76 65 20 61 20  u do not have a 
59a0: 72 75 6e 20 63 6f 6e 66 69 67 20 66 69 6c 65 3a  run config file:
59b0: 20 22 20 72 75 6e 63 6f 6e 66 69 67 66 29 29 0a   " runconfigf)).
59c0: 09 09 20 20 20 20 28 64 65 62 75 67 3a 70 72 69  ..    (debug:pri
59d0: 6e 74 20 34 20 22 72 75 6e 2d 69 64 3a 20 22 20  nt 4 "run-id: " 
59e0: 72 75 6e 2d 69 64 20 22 20 74 65 73 74 2d 6e 61  run-id " test-na
59f0: 6d 65 3a 20 22 20 74 65 73 74 2d 6e 61 6d 65 20  me: " test-name 
5a00: 22 20 69 74 65 6d 2d 70 61 74 68 3a 20 22 20 69  " item-path: " i
5a10: 74 65 6d 2d 70 61 74 68 20 22 20 74 65 73 74 64  tem-path " testd
5a20: 61 74 3a 20 22 20 28 74 65 73 74 3a 67 65 74 2d  at: " (test:get-
5a30: 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29 20  status testdat) 
5a40: 22 20 74 65 73 74 2d 73 74 61 74 65 3a 20 22 20  " test-state: " 
5a50: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20  (test:get-state 
5a60: 74 65 73 74 64 61 74 29 29 0a 09 09 20 20 20 20  testdat))...    
5a70: 28 63 61 73 65 20 28 69 66 20 28 61 72 67 73 3a  (case (if (args:
5a80: 67 65 74 2d 61 72 67 20 22 2d 66 6f 72 63 65 22  get-arg "-force"
5a90: 29 0a 09 09 09 20 20 20 20 20 20 27 4e 4f 54 5f  )....      'NOT_
5aa0: 53 54 41 52 54 45 44 0a 09 09 09 20 20 20 20 20  STARTED....     
5ab0: 20 28 69 66 20 74 65 73 74 64 61 74 0a 09 09 09   (if testdat....
5ac0: 09 20 20 28 73 74 72 69 6e 67 2d 3e 73 79 6d 62  .  (string->symb
5ad0: 6f 6c 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61  ol (test:get-sta
5ae0: 74 65 20 74 65 73 74 64 61 74 29 29 0a 09 09 09  te testdat))....
5af0: 09 20 20 27 66 61 69 6c 65 64 2d 74 6f 2d 69 6e  .  'failed-to-in
5b00: 73 65 72 74 29 29 0a 09 09 20 20 20 20 20 20 28  sert))...      (
5b10: 28 66 61 69 6c 65 64 2d 74 6f 2d 69 6e 73 65 72  (failed-to-inser
5b20: 74 29 0a 09 09 20 20 20 20 20 20 20 28 64 65 62  t)...       (deb
5b30: 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f  ug:print 0 "ERRO
5b40: 52 3a 20 46 61 69 6c 65 64 20 74 6f 20 69 6e 73  R: Failed to ins
5b50: 65 72 74 20 74 68 65 20 72 65 63 6f 72 64 20 69  ert the record i
5b60: 6e 74 6f 20 74 68 65 20 64 62 22 29 29 0a 09 09  nto the db"))...
5b70: 20 20 20 20 20 20 28 28 4e 4f 54 5f 53 54 41 52        ((NOT_STAR
5b80: 54 45 44 20 43 4f 4d 50 4c 45 54 45 44 29 0a 09  TED COMPLETED)..
5b90: 09 20 20 20 20 20 20 20 28 64 65 62 75 67 3a 70  .       (debug:p
5ba0: 72 69 6e 74 20 36 20 22 47 6f 74 20 68 65 72 65  rint 6 "Got here
5bb0: 2c 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74  , " (test:get-st
5bc0: 61 74 65 20 74 65 73 74 64 61 74 29 29 0a 09 09  ate testdat))...
5bd0: 20 20 20 20 20 20 20 28 6c 65 74 20 28 28 72 75         (let ((ru
5be0: 6e 66 6c 61 67 20 23 66 29 29 0a 09 09 09 20 28  nflag #f)).... (
5bf0: 63 6f 6e 64 0a 09 09 09 20 20 3b 3b 20 69 2e 65  cond....  ;; i.e
5c00: 2e 20 74 68 69 73 20 69 73 20 74 68 65 20 70 61  . this is the pa
5c10: 72 65 6e 74 20 74 65 73 74 20 74 6f 20 61 20 73  rent test to a s
5c20: 75 69 74 65 20 6f 66 20 69 74 65 6d 73 2c 20 6e  uite of items, n
5c30: 65 76 65 72 20 22 72 75 6e 22 20 69 74 0a 09 09  ever "run" it...
5c40: 09 20 20 28 70 61 72 65 6e 74 2d 74 65 73 74 0a  .  (parent-test.
5c50: 09 09 09 20 20 20 28 73 65 74 21 20 72 75 6e 66  ...   (set! runf
5c60: 6c 61 67 20 23 66 29 29 0a 09 09 09 20 20 3b 3b  lag #f))....  ;;
5c70: 20 2d 66 6f 72 63 65 2c 20 72 75 6e 20 6e 6f 20   -force, run no 
5c80: 6d 61 74 74 65 72 20 77 68 61 74 0a 09 09 09 20  matter what.... 
5c90: 20 28 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20   ((args:get-arg 
5ca0: 22 2d 66 6f 72 63 65 22 29 28 73 65 74 21 20 72  "-force")(set! r
5cb0: 75 6e 66 6c 61 67 20 23 74 29 29 0a 09 09 09 20  unflag #t)).... 
5cc0: 20 3b 3b 20 4e 4f 54 5f 53 54 41 52 54 45 44 2c   ;; NOT_STARTED,
5cd0: 20 72 75 6e 20 6e 6f 20 6d 61 74 74 65 72 20 77   run no matter w
5ce0: 68 61 74 0a 09 09 09 20 20 28 28 65 71 75 61 6c  hat....  ((equal
5cf0: 3f 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74  ? (test:get-stat
5d00: 65 20 74 65 73 74 64 61 74 29 20 22 4e 4f 54 5f  e testdat) "NOT_
5d10: 53 54 41 52 54 45 44 22 29 28 73 65 74 21 20 72  STARTED")(set! r
5d20: 75 6e 66 6c 61 67 20 23 74 29 29 0a 09 09 09 20  unflag #t)).... 
5d30: 20 3b 3b 20 6e 6f 74 20 2d 72 65 72 75 6e 20 61   ;; not -rerun a
5d40: 6e 64 20 50 41 53 53 2c 20 57 41 52 4e 20 6f 72  nd PASS, WARN or
5d50: 20 43 48 45 43 4b 2c 20 64 6f 20 6e 6f 20 72 75   CHECK, do no ru
5d60: 6e 0a 09 09 09 20 20 28 28 61 6e 64 20 28 6f 72  n....  ((and (or
5d70: 20 28 6e 6f 74 20 28 61 72 67 73 3a 67 65 74 2d   (not (args:get-
5d80: 61 72 67 20 22 2d 72 65 72 75 6e 22 29 29 0a 09  arg "-rerun"))..
5d90: 09 09 09 20 20 20 20 28 61 72 67 73 3a 67 65 74  ...    (args:get
5da0: 2d 61 72 67 20 22 2d 6b 65 65 70 67 6f 69 6e 67  -arg "-keepgoing
5db0: 22 29 29 0a 09 09 09 09 28 6d 65 6d 62 65 72 20  ")).....(member 
5dc0: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73  (test:get-status
5dd0: 20 74 65 73 74 64 61 74 29 20 27 28 22 50 41 53   testdat) '("PAS
5de0: 53 22 20 22 57 41 52 4e 22 20 22 43 48 45 43 4b  S" "WARN" "CHECK
5df0: 22 29 29 29 0a 09 09 09 20 20 20 28 73 65 74 21  ")))....   (set!
5e00: 20 72 75 6e 66 6c 61 67 20 23 66 29 29 0a 09 09   runflag #f))...
5e10: 09 20 20 3b 3b 20 2d 72 65 72 75 6e 20 61 6e 64  .  ;; -rerun and
5e20: 20 73 74 61 74 75 73 20 69 73 20 6f 6e 65 20 6f   status is one o
5e30: 66 20 74 68 65 20 73 70 65 63 69 66 65 64 2c 20  f the specifed, 
5e40: 72 75 6e 20 69 74 0a 09 09 09 20 20 28 28 61 6e  run it....  ((an
5e50: 64 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20  d (args:get-arg 
5e60: 22 2d 72 65 72 75 6e 22 29 0a 09 09 09 09 28 6c  "-rerun").....(l
5e70: 65 74 20 28 28 72 65 72 75 6e 6c 73 74 20 28 73  et ((rerunlst (s
5e80: 74 72 69 6e 67 2d 73 70 6c 69 74 20 28 61 72 67  tring-split (arg
5e90: 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65 72 75  s:get-arg "-reru
5ea0: 6e 22 29 20 22 2c 22 29 29 29 20 3b 3b 20 46 41  n") ","))) ;; FA
5eb0: 49 4c 2c 0a 09 09 09 09 20 20 28 6d 65 6d 62 65  IL,.....  (membe
5ec0: 72 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74  r (test:get-stat
5ed0: 75 73 20 74 65 73 74 64 61 74 29 20 72 65 72 75  us testdat) reru
5ee0: 6e 6c 73 74 29 29 29 0a 09 09 09 20 20 20 28 73  nlst)))....   (s
5ef0: 65 74 21 20 72 75 6e 66 6c 61 67 20 23 74 29 29  et! runflag #t))
5f00: 0a 09 09 09 20 20 3b 3b 20 2d 6b 65 65 70 67 6f  ....  ;; -keepgo
5f10: 69 6e 67 2c 20 64 6f 20 6e 6f 74 20 72 65 72 75  ing, do not reru
5f20: 6e 20 46 41 49 4c 0a 09 09 09 20 20 28 28 61 6e  n FAIL....  ((an
5f30: 64 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20  d (args:get-arg 
5f40: 22 2d 6b 65 65 70 67 6f 69 6e 67 22 29 0a 09 09  "-keepgoing")...
5f50: 09 09 28 6d 65 6d 62 65 72 20 28 74 65 73 74 3a  ..(member (test:
5f60: 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64  get-status testd
5f70: 61 74 29 20 27 28 22 46 41 49 4c 22 29 29 29 0a  at) '("FAIL"))).
5f80: 09 09 09 20 20 20 28 73 65 74 21 20 72 75 6e 66  ...   (set! runf
5f90: 6c 61 67 20 23 66 29 29 0a 09 09 09 20 20 28 28  lag #f))....  ((
5fa0: 61 6e 64 20 28 6e 6f 74 20 28 61 72 67 73 3a 67  and (not (args:g
5fb0: 65 74 2d 61 72 67 20 22 2d 72 65 72 75 6e 22 29  et-arg "-rerun")
5fc0: 29 0a 09 09 09 09 28 6d 65 6d 62 65 72 20 28 74  ).....(member (t
5fd0: 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74  est:get-status t
5fe0: 65 73 74 64 61 74 29 20 27 28 22 46 41 49 4c 22  estdat) '("FAIL"
5ff0: 20 22 6e 2f 61 22 29 29 29 0a 09 09 09 20 20 20   "n/a")))....   
6000: 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 74  (set! runflag #t
6010: 29 29 0a 09 09 09 20 20 28 65 6c 73 65 20 28 73  ))....  (else (s
6020: 65 74 21 20 72 75 6e 66 6c 61 67 20 23 66 29 29  et! runflag #f))
6030: 29 0a 09 09 09 20 28 64 65 62 75 67 3a 70 72 69  ).... (debug:pri
6040: 6e 74 20 36 20 22 52 55 4e 4e 49 4e 47 20 3d 3e  nt 6 "RUNNING =>
6050: 20 72 75 6e 66 6c 61 67 3a 20 22 20 72 75 6e 66   runflag: " runf
6060: 6c 61 67 20 22 20 53 54 41 54 45 3a 20 22 20 28  lag " STATE: " (
6070: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74  test:get-state t
6080: 65 73 74 64 61 74 29 20 22 20 53 54 41 54 55 53  estdat) " STATUS
6090: 3a 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74  : " (test:get-st
60a0: 61 74 75 73 20 74 65 73 74 64 61 74 29 29 0a 09  atus testdat))..
60b0: 09 09 20 28 69 66 20 28 6e 6f 74 20 72 75 6e 66  .. (if (not runf
60c0: 6c 61 67 29 0a 09 09 09 20 20 20 20 20 28 69 66  lag)....     (if
60d0: 20 28 6e 6f 74 20 70 61 72 65 6e 74 2d 74 65 73   (not parent-tes
60e0: 74 29 0a 09 09 09 09 20 28 64 65 62 75 67 3a 70  t)..... (debug:p
60f0: 72 69 6e 74 20 31 20 22 4e 4f 54 45 3a 20 4e 6f  rint 1 "NOTE: No
6100: 74 20 73 74 61 72 74 69 6e 67 20 74 65 73 74 20  t starting test 
6110: 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20  " new-test-name 
6120: 22 20 61 73 20 69 74 20 69 73 20 73 74 61 74 65  " as it is state
6130: 20 5c 22 43 4f 4d 50 4c 45 54 45 44 5c 22 20 61   \"COMPLETED\" a
6140: 6e 64 20 73 74 61 74 75 73 20 5c 22 22 20 28 74  nd status \"" (t
6150: 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74  est:get-status t
6160: 65 73 74 64 61 74 29 20 22 5c 22 2c 20 75 73 65  estdat) "\", use
6170: 20 2d 66 6f 72 63 65 20 74 6f 20 6f 76 65 72 72   -force to overr
6180: 69 64 65 22 29 29 0a 09 09 09 20 20 20 20 20 28  ide"))....     (
6190: 6c 65 74 2a 20 28 28 67 65 74 2d 70 72 65 72 65  let* ((get-prere
61a0: 71 73 2d 63 6d 64 20 28 6c 61 6d 62 64 61 20 28  qs-cmd (lambda (
61b0: 29 0a 09 09 09 09 09 09 20 20 20 20 20 20 20 28  ).......       (
61c0: 64 62 2d 67 65 74 2d 70 72 65 72 65 71 73 2d 6e  db-get-prereqs-n
61d0: 6f 74 2d 6d 65 74 20 64 62 20 72 75 6e 2d 69 64  ot-met db run-id
61e0: 20 77 61 69 74 6f 6e 29 29 29 20 3b 3b 20 63 68   waiton))) ;; ch
61f0: 65 63 6b 20 62 65 66 6f 72 65 20 72 75 6e 6e 69  eck before runni
6200: 6e 67 20 2e 2e 2e 2e 0a 09 09 09 09 20 20 20 20  ng .........    
6210: 28 6c 61 75 6e 63 68 2d 63 6d 64 20 20 20 20 20  (launch-cmd     
6220: 20 28 6c 61 6d 62 64 61 20 28 29 0a 09 09 09 09   (lambda ().....
6230: 09 09 20 20 20 20 20 20 20 28 6c 61 75 6e 63 68  ..       (launch
6240: 2d 74 65 73 74 20 64 62 20 72 75 6e 2d 69 64 20  -test db run-id 
6250: 74 65 73 74 2d 63 6f 6e 66 20 6b 65 79 76 61 6c  test-conf keyval
6260: 6c 73 74 20 74 65 73 74 2d 6e 61 6d 65 20 74 65  lst test-name te
6270: 73 74 2d 70 61 74 68 20 69 74 65 6d 64 61 74 29  st-path itemdat)
6280: 29 29 0a 09 09 09 09 20 20 20 20 28 74 65 73 74  )).....    (test
6290: 72 75 6e 64 61 74 20 20 20 20 20 20 28 6c 69 73  rundat      (lis
62a0: 74 20 67 65 74 2d 70 72 65 72 65 71 73 2d 63 6d  t get-prereqs-cm
62b0: 64 20 6c 61 75 6e 63 68 2d 63 6d 64 29 29 29 0a  d launch-cmd))).
62c0: 09 09 09 20 20 20 20 20 20 20 28 69 66 20 28 6f  ...       (if (o
62d0: 72 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20  r (args:get-arg 
62e0: 22 2d 66 6f 72 63 65 22 29 0a 09 09 09 09 20 20  "-force").....  
62f0: 20 20 20 20 20 28 6c 65 74 20 28 28 70 72 65 71       (let ((preq
6300: 73 2d 6e 6f 74 2d 79 65 74 2d 6d 65 74 20 28 28  s-not-yet-met ((
6310: 63 61 72 20 74 65 73 74 72 75 6e 64 61 74 29 29  car testrundat))
6320: 29 29 0a 09 09 09 09 09 20 28 64 65 62 75 67 3a  ))...... (debug:
6330: 70 72 69 6e 74 20 32 20 22 50 72 65 71 72 65 71  print 2 "Preqreq
6340: 75 65 73 69 74 65 73 20 66 6f 72 20 22 20 74 65  uesites for " te
6350: 73 74 2d 6e 61 6d 65 20 22 3a 20 22 20 70 72 65  st-name ": " pre
6360: 71 73 2d 6e 6f 74 2d 79 65 74 2d 6d 65 74 29 0a  qs-not-yet-met).
6370: 09 09 09 09 09 20 28 6e 75 6c 6c 3f 20 70 72 65  ..... (null? pre
6380: 71 73 2d 6e 6f 74 2d 79 65 74 2d 6d 65 74 29 29  qs-not-yet-met))
6390: 29 20 3b 3b 20 61 72 65 20 74 68 65 72 65 20 61  ) ;; are there a
63a0: 6e 79 20 74 65 73 74 73 20 74 68 61 74 20 6d 75  ny tests that mu
63b0: 73 74 20 62 65 20 72 75 6e 20 62 65 66 6f 72 65  st be run before
63c0: 20 74 68 69 73 20 6f 6e 65 2e 2e 2e 0a 09 09 09   this one.......
63d0: 09 20 20 20 28 69 66 20 28 6e 6f 74 20 28 28 63  .   (if (not ((c
63e0: 61 64 72 20 74 65 73 74 72 75 6e 64 61 74 29 29  adr testrundat))
63f0: 29 20 3b 3b 20 74 68 69 73 20 69 73 20 74 68 65  ) ;; this is the
6400: 20 6c 69 6e 65 20 74 68 61 74 20 6c 61 75 6e 63   line that launc
6410: 68 65 73 20 74 68 65 20 74 65 73 74 20 74 6f 20  hes the test to 
6420: 74 68 65 20 72 65 6d 6f 74 65 20 68 6f 73 74 0a  the remote host.
6430: 09 09 09 09 20 20 20 20 20 20 20 28 62 65 67 69  ....       (begi
6440: 6e 0a 09 09 09 09 09 20 28 70 72 69 6e 74 20 22  n...... (print "
6450: 45 52 52 4f 52 3a 20 46 61 69 6c 65 64 20 74 6f  ERROR: Failed to
6460: 20 6c 61 75 6e 63 68 20 74 68 65 20 74 65 73 74   launch the test
6470: 2e 20 45 78 69 74 69 6e 67 20 61 73 20 73 6f 6f  . Exiting as soo
6480: 6e 20 61 73 20 70 6f 73 73 69 62 6c 65 22 29 0a  n as possible").
6490: 09 09 09 09 09 20 28 73 65 74 21 20 2a 67 6c 6f  ..... (set! *glo
64a0: 62 61 6c 65 78 69 74 73 74 61 74 75 73 2a 20 31  balexitstatus* 1
64b0: 29 20 3b 3b 20 0a 09 09 09 09 09 20 28 70 72 6f  ) ;; ...... (pro
64c0: 63 65 73 73 2d 73 69 67 6e 61 6c 20 28 63 75 72  cess-signal (cur
64d0: 72 65 6e 74 2d 70 72 6f 63 65 73 73 2d 69 64 29  rent-process-id)
64e0: 20 73 69 67 6e 61 6c 2f 6b 69 6c 6c 29 0a 09 09   signal/kill)...
64f0: 09 09 09 20 3b 28 65 78 69 74 20 31 29 0a 09 09  ... ;(exit 1)...
6500: 09 09 09 20 29 29 0a 09 09 09 09 20 20 20 28 69  ... )).....   (i
6510: 66 20 28 6e 6f 74 20 28 61 72 67 73 3a 67 65 74  f (not (args:get
6520: 2d 61 72 67 20 22 2d 6b 65 65 70 67 6f 69 6e 67  -arg "-keepgoing
6530: 22 29 29 0a 09 09 09 09 20 20 20 20 20 20 20 28  ")).....       (
6540: 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74 21 20  hash-table-set! 
6550: 2a 77 61 69 74 69 6e 67 2d 71 75 65 75 65 2a 20  *waiting-queue* 
6560: 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20 74 65  new-test-name te
6570: 73 74 72 75 6e 64 61 74 29 29 29 29 29 29 29 0a  strundat))))))).
6580: 09 09 20 20 20 20 20 20 28 28 4b 49 4c 4c 45 44  ..      ((KILLED
6590: 29 20 0a 09 09 20 20 20 20 20 20 20 28 64 65 62  ) ...       (deb
65a0: 75 67 3a 70 72 69 6e 74 20 31 20 22 4e 4f 54 45  ug:print 1 "NOTE
65b0: 3a 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d  : " new-test-nam
65c0: 65 20 22 20 69 73 20 61 6c 72 65 61 64 79 20 72  e " is already r
65d0: 75 6e 6e 69 6e 67 20 6f 72 20 77 61 73 20 65 78  unning or was ex
65e0: 70 6c 69 63 74 6c 79 20 6b 69 6c 6c 65 64 2c 20  plictly killed, 
65f0: 75 73 65 20 2d 66 6f 72 63 65 20 74 6f 20 6c 61  use -force to la
6600: 75 6e 63 68 20 69 74 2e 22 29 29 0a 09 09 20 20  unch it."))...  
6610: 20 20 20 20 28 28 4c 41 55 4e 43 48 45 44 20 52      ((LAUNCHED R
6620: 45 4d 4f 54 45 48 4f 53 54 53 54 41 52 54 20 52  EMOTEHOSTSTART R
6630: 55 4e 4e 49 4e 47 29 20 20 0a 09 09 20 20 20 20  UNNING)  ...    
6640: 20 20 20 28 69 66 20 28 3e 20 28 2d 20 28 63 75     (if (> (- (cu
6650: 72 72 65 6e 74 2d 73 65 63 6f 6e 64 73 29 28 2b  rrent-seconds)(+
6660: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 65 76   (db:test-get-ev
6670: 65 6e 74 5f 74 69 6d 65 20 74 65 73 74 64 61 74  ent_time testdat
6680: 29 0a 09 09 09 09 09 09 20 20 20 20 20 28 64 62  ).......     (db
6690: 3a 74 65 73 74 2d 67 65 74 2d 72 75 6e 5f 64 75  :test-get-run_du
66a0: 72 61 74 69 6f 6e 20 74 65 73 74 64 61 74 29 29  ration testdat))
66b0: 29 0a 09 09 09 20 20 20 20 20 20 31 30 30 29 20  )....      100) 
66c0: 3b 3b 20 69 2e 65 2e 20 6e 6f 20 75 70 64 61 74  ;; i.e. no updat
66d0: 65 20 66 6f 72 20 6d 6f 72 65 20 74 68 61 6e 20  e for more than 
66e0: 31 30 30 20 73 65 63 6f 6e 64 73 0a 09 09 09 20  100 seconds.... 
66f0: 20 20 28 62 65 67 69 6e 0a 09 09 09 20 20 20 20    (begin....    
6700: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
6710: 22 57 41 52 4e 49 4e 47 3a 20 54 65 73 74 20 22  "WARNING: Test "
6720: 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 61 70 70   test-name " app
6730: 65 61 72 73 20 74 6f 20 62 65 20 64 65 61 64 2e  ears to be dead.
6740: 20 46 6f 72 63 69 6e 67 20 69 74 20 74 6f 20 73   Forcing it to s
6750: 74 61 74 65 20 49 4e 43 4f 4d 50 4c 45 54 45 20  tate INCOMPLETE 
6760: 61 6e 64 20 73 74 61 74 75 73 20 53 54 55 43 4b  and status STUCK
6770: 2f 44 45 41 44 22 29 0a 09 09 09 20 20 20 20 20  /DEAD")....     
6780: 28 74 65 73 74 2d 73 65 74 2d 73 74 61 74 75 73  (test-set-status
6790: 21 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  ! db run-id test
67a0: 2d 6e 61 6d 65 20 22 49 4e 43 4f 4d 50 4c 45 54  -name "INCOMPLET
67b0: 45 22 20 22 53 54 55 43 4b 2f 44 45 41 44 22 20  E" "STUCK/DEAD" 
67c0: 69 74 65 6d 64 61 74 20 22 54 65 73 74 20 69 73  itemdat "Test is
67d0: 20 73 74 75 63 6b 20 6f 72 20 64 65 61 64 22 29   stuck or dead")
67e0: 29 0a 09 09 09 20 20 20 28 64 65 62 75 67 3a 70  )....   (debug:p
67f0: 72 69 6e 74 20 32 20 22 4e 4f 54 45 3a 20 22 20  rint 2 "NOTE: " 
6800: 74 65 73 74 2d 6e 61 6d 65 20 22 20 69 73 20 61  test-name " is a
6810: 6c 72 65 61 64 79 20 72 75 6e 6e 69 6e 67 22 29  lready running")
6820: 29 29 0a 09 09 20 20 20 20 20 20 28 65 6c 73 65  ))...      (else
6830: 20 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72         (debug:pr
6840: 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 46 61  int 0 "ERROR: Fa
6850: 69 6c 65 64 20 74 6f 20 6c 61 75 6e 63 68 20 74  iled to launch t
6860: 65 73 74 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e  est " new-test-n
6870: 61 6d 65 20 22 2e 20 55 6e 72 65 63 6f 67 6e 69  ame ". Unrecogni
6880: 73 65 64 20 73 74 61 74 65 20 22 20 28 74 65 73  sed state " (tes
6890: 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74  t:get-state test
68a0: 64 61 74 29 29 29 29 29 29 0a 09 20 20 20 20 20  dat))))))..     
68b0: 20 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f   (if (not (null?
68c0: 20 74 61 6c 29 29 0a 09 09 20 20 28 6c 6f 6f 70   tal))...  (loop
68d0: 20 28 63 61 72 20 74 61 6c 29 28 63 64 72 20 74   (car tal)(cdr t
68e0: 61 6c 29 29 29 29 29 29 29 29 29 0a 0a 28 64 65  al)))))))))..(de
68f0: 66 69 6e 65 20 28 72 75 6e 2d 77 61 69 74 69 6e  fine (run-waitin
6900: 67 2d 74 65 73 74 73 20 64 62 29 0a 20 20 28 6c  g-tests db).  (l
6910: 65 74 20 28 28 6e 75 6d 74 72 69 65 73 20 20 20  et ((numtries   
6920: 20 20 20 20 20 20 20 20 30 29 0a 09 28 6c 61 73          0)..(las
6930: 74 2d 74 72 79 2d 74 69 6d 65 20 20 20 20 20 20  t-try-time      
6940: 28 63 75 72 72 65 6e 74 2d 73 65 63 6f 6e 64 73  (current-seconds
6950: 29 29 0a 09 28 74 69 6d 65 73 20 20 20 20 20 20  ))..(times      
6960: 20 20 20 20 20 20 20 20 28 6c 69 73 74 20 31 29          (list 1)
6970: 29 29 20 3b 3b 20 6d 69 6e 75 74 65 73 20 74 6f  )) ;; minutes to
6980: 20 77 61 69 74 20 62 65 66 6f 72 65 20 74 72 79   wait before try
6990: 69 6e 67 20 61 67 61 69 6e 20 74 6f 20 6b 69 63  ing again to kic
69a0: 6b 20 6f 66 66 20 72 75 6e 73 0a 20 20 20 20 3b  k off runs.    ;
69b0: 3b 20 42 55 47 20 74 68 69 73 20 68 61 63 6b 20  ; BUG this hack 
69c0: 6f 66 20 62 72 75 74 65 20 66 6f 72 63 65 20 72  of brute force r
69d0: 65 74 72 79 69 6e 67 20 77 6f 72 6b 73 20 71 75  etrying works qu
69e0: 69 74 65 20 77 65 6c 6c 20 66 6f 72 20 6d 61 6e  ite well for man
69f0: 79 20 63 61 73 65 73 20 62 75 74 20 0a 20 20 20  y cases but .   
6a00: 20 3b 3b 20 20 20 20 20 77 68 61 74 20 69 73 20   ;;     what is 
6a10: 6e 65 65 64 65 64 20 69 73 20 74 6f 20 63 68 65  needed is to che
6a20: 63 6b 20 74 68 65 20 64 62 20 66 6f 72 20 74 65  ck the db for te
6a30: 73 74 73 20 74 68 61 74 20 68 61 76 65 20 66 61  sts that have fa
6a40: 69 6c 65 64 20 6c 65 73 73 20 74 68 61 6e 0a 20  iled less than. 
6a50: 20 20 20 3b 3b 20 20 20 20 20 4e 20 74 69 6d 65     ;;     N time
6a60: 73 20 6f 72 20 6e 65 76 65 72 20 62 65 65 6e 20  s or never been 
6a70: 73 74 61 72 74 65 64 20 61 6e 64 20 6b 69 63 6b  started and kick
6a80: 20 74 68 65 6d 20 6f 66 66 20 61 67 61 69 6e 0a   them off again.
6a90: 20 20 20 20 28 6c 65 74 20 6c 6f 6f 70 20 28 28      (let loop ((
6aa0: 77 61 69 74 69 6e 67 2d 74 65 73 74 2d 6e 61 6d  waiting-test-nam
6ab0: 65 73 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 6b  es (hash-table-k
6ac0: 65 79 73 20 2a 77 61 69 74 69 6e 67 2d 71 75 65  eys *waiting-que
6ad0: 75 65 2a 29 29 29 0a 20 20 20 20 20 20 28 63 6f  ue*))).      (co
6ae0: 6e 64 0a 20 20 20 20 20 20 20 28 28 6e 6f 74 20  nd.       ((not 
6af0: 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f  (runs:can-run-mo
6b00: 72 65 2d 74 65 73 74 73 20 64 62 29 29 0a 09 28  re-tests db))..(
6b10: 73 6c 65 65 70 20 32 29 0a 09 28 6c 6f 6f 70 20  sleep 2)..(loop 
6b20: 77 61 69 74 69 6e 67 2d 74 65 73 74 2d 6e 61 6d  waiting-test-nam
6b30: 65 73 29 29 0a 20 20 20 20 20 20 20 28 28 6e 75  es)).       ((nu
6b40: 6c 6c 3f 20 77 61 69 74 69 6e 67 2d 74 65 73 74  ll? waiting-test
6b50: 2d 6e 61 6d 65 73 29 0a 09 28 64 65 62 75 67 3a  -names)..(debug:
6b60: 70 72 69 6e 74 20 31 20 22 41 6c 6c 20 74 65 73  print 1 "All tes
6b70: 74 73 20 6c 61 75 6e 63 68 65 64 22 29 29 0a 20  ts launched")). 
6b80: 20 20 20 20 20 20 28 65 6c 73 65 0a 09 28 73 65        (else..(se
6b90: 74 21 20 6e 75 6d 74 72 69 65 73 20 28 2b 20 6e  t! numtries (+ n
6ba0: 75 6d 74 72 69 65 73 20 31 29 29 0a 09 28 66 6f  umtries 1))..(fo
6bb0: 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 20 28  r-each (lambda (
6bc0: 74 65 73 74 6e 61 6d 65 29 0a 09 09 20 20 20 20  testname)...    
6bd0: 28 69 66 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75  (if (runs:can-ru
6be0: 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64 62 29  n-more-tests db)
6bf0: 0a 09 09 09 28 6c 65 74 2a 20 28 28 74 65 73 74  ....(let* ((test
6c00: 64 61 74 20 28 68 61 73 68 2d 74 61 62 6c 65 2d  dat (hash-table-
6c10: 72 65 66 20 2a 77 61 69 74 69 6e 67 2d 71 75 65  ref *waiting-que
6c20: 75 65 2a 20 74 65 73 74 6e 61 6d 65 29 29 0a 09  ue* testname))..
6c30: 09 09 20 20 20 20 20 20 20 28 70 72 65 72 65 71  ..       (prereq
6c40: 73 20 28 28 63 61 72 20 74 65 73 74 64 61 74 29  s ((car testdat)
6c50: 29 29 0a 09 09 09 20 20 20 20 20 20 20 28 6c 64  ))....       (ld
6c60: 62 20 20 20 20 20 28 69 66 20 64 62 20 64 62 20  b     (if db db 
6c70: 28 6f 70 65 6e 2d 64 62 29 29 29 29 0a 09 09 09  (open-db))))....
6c80: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32    (debug:print 2
6c90: 20 22 70 72 65 72 65 71 73 20 72 65 6d 61 69 6e   "prereqs remain
6ca0: 69 6e 67 3a 20 22 20 70 72 65 72 65 71 73 29 0a  ing: " prereqs).
6cb0: 09 09 09 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20  ...  (if (null? 
6cc0: 70 72 65 72 65 71 73 29 0a 09 09 09 20 20 20 20  prereqs)....    
6cd0: 20 20 28 62 65 67 69 6e 0a 09 09 09 09 28 64 65    (begin.....(de
6ce0: 62 75 67 3a 70 72 69 6e 74 20 32 20 22 50 72 65  bug:print 2 "Pre
6cf0: 72 65 71 75 69 73 69 74 65 73 20 6d 65 74 2c 20  requisites met, 
6d00: 6c 61 75 6e 63 68 69 6e 67 20 22 20 74 65 73 74  launching " test
6d10: 6e 61 6d 65 29 0a 09 09 09 09 28 28 63 61 64 72  name).....((cadr
6d20: 20 74 65 73 74 64 61 74 29 29 0a 09 09 09 09 28   testdat)).....(
6d30: 68 61 73 68 2d 74 61 62 6c 65 2d 64 65 6c 65 74  hash-table-delet
6d40: 65 21 20 2a 77 61 69 74 69 6e 67 2d 71 75 65 75  e! *waiting-queu
6d50: 65 2a 20 74 65 73 74 6e 61 6d 65 29 29 29 0a 09  e* testname)))..
6d60: 09 09 20 20 28 69 66 20 28 6e 6f 74 20 64 62 29  ..  (if (not db)
6d70: 0a 09 09 09 20 20 20 20 20 20 28 73 71 6c 69 74  ....      (sqlit
6d80: 65 33 3a 66 69 6e 61 6c 69 7a 65 21 20 6c 64 62  e3:finalize! ldb
6d90: 29 29 29 29 29 0a 09 09 20 20 77 61 69 74 69 6e  )))))...  waitin
6da0: 67 2d 74 65 73 74 2d 6e 61 6d 65 73 29 0a 09 3b  g-test-names)..;
6db0: 3b 20 28 73 6c 65 65 70 20 31 30 29 20 3b 3b 20  ; (sleep 10) ;; 
6dc0: 6e 6f 20 70 6f 69 6e 74 20 69 6e 20 72 75 73 68  no point in rush
6dd0: 69 6e 67 20 74 68 69 6e 67 73 20 61 74 20 74 68  ing things at th
6de0: 69 73 20 73 74 61 67 65 3f 0a 09 28 6c 6f 6f 70  is stage?..(loop
6df0: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 6b 65 79   (hash-table-key
6e00: 73 20 2a 77 61 69 74 69 6e 67 2d 71 75 65 75 65  s *waiting-queue
6e10: 2a 29 29 29 29 29 29 29 0a 0a 28 64 65 66 69 6e  *)))))))..(defin
6e20: 65 20 28 67 65 74 2d 64 69 72 2d 75 70 2d 6e 20  e (get-dir-up-n 
6e30: 64 69 72 20 2e 20 70 61 72 61 6d 73 29 20 0a 20  dir . params) . 
6e40: 20 28 6c 65 74 20 28 28 64 70 61 72 74 73 20 20   (let ((dparts  
6e50: 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 64 69  (string-split di
6e60: 72 20 22 2f 22 29 29 0a 09 28 63 6f 75 6e 74 20  r "/"))..(count 
6e70: 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 70 61 72    (if (null? par
6e80: 61 6d 73 29 20 31 20 28 63 61 72 20 70 61 72 61  ams) 1 (car para
6e90: 6d 73 29 29 29 29 0a 20 20 20 20 28 63 6f 6e 63  ms)))).    (conc
6ea0: 20 22 2f 22 20 28 73 74 72 69 6e 67 2d 69 6e 74   "/" (string-int
6eb0: 65 72 73 70 65 72 73 65 20 0a 09 20 20 20 20 20  ersperse ..     
6ec0: 20 20 28 74 61 6b 65 20 64 70 61 72 74 73 20 28    (take dparts (
6ed0: 2d 20 28 6c 65 6e 67 74 68 20 64 70 61 72 74 73  - (length dparts
6ee0: 29 20 63 6f 75 6e 74 29 29 0a 09 20 20 20 20 20  ) count))..     
6ef0: 20 20 22 2f 22 29 29 29 29 0a 3b 3b 20 52 65 6d    "/")))).;; Rem
6f00: 6f 76 65 20 72 75 6e 73 0a 3b 3b 20 66 69 65 6c  ove runs.;; fiel
6f10: 64 73 20 61 72 65 20 70 61 73 73 69 6e 67 20 69  ds are passing i
6f20: 6e 20 74 68 72 6f 75 67 68 20 0a 28 64 65 66 69  n through .(defi
6f30: 6e 65 20 28 72 75 6e 73 3a 72 65 6d 6f 76 65 2d  ne (runs:remove-
6f40: 72 75 6e 73 20 64 62 20 72 75 6e 6e 61 6d 65 70  runs db runnamep
6f50: 61 74 74 20 74 65 73 74 70 61 74 74 20 69 74 65  att testpatt ite
6f60: 6d 70 61 74 74 29 0a 20 20 28 6c 65 74 2a 20 28  mpatt).  (let* (
6f70: 28 6b 65 79 73 20 20 20 20 20 20 20 20 28 64 62  (keys        (db
6f80: 2d 67 65 74 2d 6b 65 79 73 20 64 62 29 29 0a 09  -get-keys db))..
6f90: 20 28 72 75 6e 64 61 74 20 20 20 20 20 20 28 72   (rundat      (r
6fa0: 75 6e 73 3a 67 65 74 2d 72 75 6e 73 2d 62 79 2d  uns:get-runs-by-
6fb0: 70 61 74 74 20 64 62 20 6b 65 79 73 20 72 75 6e  patt db keys run
6fc0: 6e 61 6d 65 70 61 74 74 29 29 0a 09 20 28 68 65  namepatt)).. (he
6fd0: 61 64 65 72 20 20 20 20 20 20 28 76 65 63 74 6f  ader      (vecto
6fe0: 72 2d 72 65 66 20 72 75 6e 64 61 74 20 30 29 29  r-ref rundat 0))
6ff0: 0a 09 20 28 72 75 6e 73 20 20 20 20 20 20 20 20  .. (runs        
7000: 28 76 65 63 74 6f 72 2d 72 65 66 20 72 75 6e 64  (vector-ref rund
7010: 61 74 20 31 29 29 29 0a 20 20 20 20 28 64 65 62  at 1))).    (deb
7020: 75 67 3a 70 72 69 6e 74 20 31 20 22 48 65 61 64  ug:print 1 "Head
7030: 65 72 3a 20 22 20 68 65 61 64 65 72 29 0a 20 20  er: " header).  
7040: 20 20 28 66 6f 72 2d 65 61 63 68 0a 20 20 20 20    (for-each.    
7050: 20 28 6c 61 6d 62 64 61 20 28 72 75 6e 29 0a 20   (lambda (run). 
7060: 20 20 20 20 20 20 28 6c 65 74 20 28 28 72 75 6e        (let ((run
7070: 6b 65 79 20 28 73 74 72 69 6e 67 2d 69 6e 74 65  key (string-inte
7080: 72 73 70 65 72 73 65 20 28 6d 61 70 20 28 6c 61  rsperse (map (la
7090: 6d 62 64 61 20 28 6b 29 0a 09 09 09 09 09 09 28  mbda (k).......(
70a0: 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d  db:get-value-by-
70b0: 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65  header run heade
70c0: 72 20 28 76 65 63 74 6f 72 2d 72 65 66 20 6b 20  r (vector-ref k 
70d0: 30 29 29 29 20 6b 65 79 73 29 20 22 2f 22 29 29  0))) keys) "/"))
70e0: 29 0a 09 20 28 6c 65 74 2a 20 28 28 72 75 6e 2d  ).. (let* ((run-
70f0: 69 64 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65  id (db:get-value
7100: 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68  -by-header run h
7110: 65 61 64 65 72 20 22 69 64 22 29 20 29 0a 09 09  eader "id") )...
7120: 28 74 65 73 74 73 20 20 28 64 62 2d 67 65 74 2d  (tests  (db-get-
7130: 74 65 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62  tests-for-run db
7140: 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62   (db:get-value-b
7150: 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61  y-header run hea
7160: 64 65 72 20 22 69 64 22 29 20 74 65 73 74 70 61  der "id") testpa
7170: 74 74 20 69 74 65 6d 70 61 74 74 29 29 0a 09 09  tt itempatt))...
7180: 28 6c 61 73 74 74 70 61 74 68 20 22 2f 64 6f 65  (lasttpath "/doe
7190: 73 2f 6e 6f 74 2f 65 78 69 73 74 2f 49 2f 68 6f  s/not/exist/I/ho
71a0: 70 65 22 29 29 0a 09 20 20 20 28 69 66 20 28 6e  pe"))..   (if (n
71b0: 6f 74 20 28 6e 75 6c 6c 3f 20 74 65 73 74 73 29  ot (null? tests)
71c0: 29 0a 09 20 20 20 20 20 20 20 28 62 65 67 69 6e  )..       (begin
71d0: 0a 09 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ... (debug:print
71e0: 20 31 20 22 52 65 6d 6f 76 69 6e 67 20 74 65 73   1 "Removing tes
71f0: 74 73 20 66 6f 72 20 72 75 6e 3a 20 22 20 72 75  ts for run: " ru
7200: 6e 6b 65 79 20 22 20 22 20 28 64 62 3a 67 65 74  nkey " " (db:get
7210: 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72  -value-by-header
7220: 20 72 75 6e 20 68 65 61 64 65 72 20 22 72 75 6e   run header "run
7230: 6e 61 6d 65 22 29 29 0a 09 09 20 28 66 6f 72 2d  name"))... (for-
7240: 65 61 63 68 0a 09 09 20 20 28 6c 61 6d 62 64 61  each...  (lambda
7250: 20 28 74 65 73 74 29 0a 09 09 20 20 20 20 28 6c   (test)...    (l
7260: 65 74 2a 20 28 28 69 74 65 6d 2d 70 61 74 68 20  et* ((item-path 
7270: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65  (db:test-get-ite
7280: 6d 2d 70 61 74 68 20 74 65 73 74 29 29 0a 09 09  m-path test))...
7290: 09 20 20 20 28 74 65 73 74 2d 6e 61 6d 65 20 28  .   (test-name (
72a0: 64 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74  db:test-get-test
72b0: 6e 61 6d 65 20 74 65 73 74 29 29 0a 09 09 09 20  name test)).... 
72c0: 20 20 28 72 75 6e 2d 64 69 72 20 20 20 28 64 62    (run-dir   (db
72d0: 3a 74 65 73 74 2d 67 65 74 2d 72 75 6e 64 69 72  :test-get-rundir
72e0: 20 74 65 73 74 29 29 29 0a 09 09 20 20 20 20 20   test)))...     
72f0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20   (debug:print 1 
7300: 22 20 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65  "  " (db:test-ge
7310: 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 29  t-testname test)
7320: 20 22 20 69 64 3a 20 22 20 28 64 62 3a 74 65 73   " id: " (db:tes
7330: 74 2d 67 65 74 2d 69 64 20 74 65 73 74 29 20 22  t-get-id test) "
7340: 20 22 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 09   " item-path)...
7350: 20 20 20 20 20 20 28 64 62 3a 64 65 6c 65 74 65        (db:delete
7360: 2d 74 65 73 74 2d 72 65 63 6f 72 64 73 20 64 62  -test-records db
7370: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64   (db:test-get-id
7380: 20 74 65 73 74 29 29 0a 09 09 20 20 20 20 20 20   test))...      
7390: 28 69 66 20 28 3e 20 28 73 74 72 69 6e 67 2d 6c  (if (> (string-l
73a0: 65 6e 67 74 68 20 72 75 6e 2d 64 69 72 29 20 35  ength run-dir) 5
73b0: 29 20 3b 3b 20 62 61 64 20 68 65 75 72 69 73 74  ) ;; bad heurist
73c0: 69 63 20 62 75 74 20 73 68 6f 75 6c 64 20 70 72  ic but should pr
73d0: 65 76 65 6e 74 20 2f 74 6d 70 20 2f 68 6f 6d 65  event /tmp /home
73e0: 20 65 74 63 2e 0a 09 09 09 20 20 28 6c 65 74 20   etc.....  (let 
73f0: 28 28 66 75 6c 6c 70 61 74 68 20 72 75 6e 2d 64  ((fullpath run-d
7400: 69 72 29 29 20 3b 3b 20 22 2f 22 20 28 64 62 3a  ir)) ;; "/" (db:
7410: 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61  test-get-item-pa
7420: 74 68 20 74 65 73 74 29 29 29 29 0a 09 09 09 20  th test)))).... 
7430: 20 20 20 28 73 65 74 21 20 6c 61 73 74 74 70 61     (set! lasttpa
7440: 74 68 20 66 75 6c 6c 70 61 74 68 29 0a 09 09 09  th fullpath)....
7450: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
7460: 20 31 20 22 72 6d 20 2d 72 66 20 22 20 66 75 6c   1 "rm -rf " ful
7470: 6c 70 61 74 68 29 0a 09 09 09 20 20 20 20 28 73  lpath)....    (s
7480: 79 73 74 65 6d 20 28 63 6f 6e 63 20 22 72 6d 20  ystem (conc "rm 
7490: 2d 72 66 20 22 20 66 75 6c 6c 70 61 74 68 29 29  -rf " fullpath))
74a0: 0a 09 09 09 20 20 20 20 28 6c 65 74 2a 20 28 28  ....    (let* ((
74b0: 64 69 72 73 2d 63 6f 75 6e 74 20 28 2b 20 31 20  dirs-count (+ 1 
74c0: 28 6c 65 6e 67 74 68 20 6b 65 79 73 29 28 6c 65  (length keys)(le
74d0: 6e 67 74 68 20 28 73 74 72 69 6e 67 2d 73 70 6c  ngth (string-spl
74e0: 69 74 20 69 74 65 6d 2d 70 61 74 68 20 22 2f 22  it item-path "/"
74f0: 29 29 29 29 0a 09 09 09 09 20 20 20 28 64 69 72  )))).....   (dir
7500: 2d 74 6f 2d 72 65 6d 20 28 67 65 74 2d 64 69 72  -to-rem (get-dir
7510: 2d 75 70 2d 6e 20 66 75 6c 6c 70 61 74 68 20 64  -up-n fullpath d
7520: 69 72 73 2d 63 6f 75 6e 74 29 29 0a 09 09 09 09  irs-count)).....
7530: 20 20 20 28 72 65 6d 61 69 6e 69 6e 67 64 20 28     (remainingd (
7540: 73 74 72 69 6e 67 2d 73 75 62 73 74 69 74 75 74  string-substitut
7550: 65 20 28 72 65 67 65 78 70 20 28 63 6f 6e 63 20  e (regexp (conc 
7560: 22 5e 22 20 64 69 72 2d 74 6f 2d 72 65 6d 20 22  "^" dir-to-rem "
7570: 2f 22 29 29 20 22 22 20 66 75 6c 6c 70 61 74 68  /")) "" fullpath
7580: 29 29 0a 09 09 09 09 20 20 20 28 63 6d 64 20 28  )).....   (cmd (
7590: 63 6f 6e 63 20 22 63 64 20 22 20 64 69 72 2d 74  conc "cd " dir-t
75a0: 6f 2d 72 65 6d 20 22 3b 20 72 6d 64 69 72 20 2d  o-rem "; rmdir -
75b0: 70 20 22 20 72 65 6d 61 69 6e 69 6e 67 64 20 29  p " remainingd )
75c0: 29 29 0a 09 09 09 20 20 20 20 20 20 28 69 66 20  ))....      (if 
75d0: 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 66 75  (file-exists? fu
75e0: 6c 6c 70 61 74 68 29 0a 09 09 09 09 20 20 28 62  llpath).....  (b
75f0: 65 67 69 6e 0a 09 09 09 09 20 20 20 20 28 64 65  egin.....    (de
7600: 62 75 67 3a 70 72 69 6e 74 20 31 20 63 6d 64 29  bug:print 1 cmd)
7610: 0a 09 09 09 09 20 20 20 20 28 73 79 73 74 65 6d  .....    (system
7620: 20 63 6d 64 29 29 29 0a 09 09 09 20 20 20 20 20   cmd)))....     
7630: 20 29 29 0a 09 09 09 20 20 20 20 29 29 29 0a 09   ))....    )))..
7640: 09 20 20 20 20 74 65 73 74 73 29 29 29 0a 09 20  .    tests))).. 
7650: 20 20 28 6c 65 74 20 28 28 72 65 6d 74 65 73 74    (let ((remtest
7660: 73 20 28 64 62 2d 67 65 74 2d 74 65 73 74 73 2d  s (db-get-tests-
7670: 66 6f 72 2d 72 75 6e 20 64 62 20 28 64 62 3a 67  for-run db (db:g
7680: 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64  et-value-by-head
7690: 65 72 20 72 75 6e 20 68 65 61 64 65 72 20 22 69  er run header "i
76a0: 64 22 29 29 29 29 0a 09 20 20 20 20 20 28 69 66  d"))))..     (if
76b0: 20 28 6e 75 6c 6c 3f 20 72 65 6d 74 65 73 74 73   (null? remtests
76c0: 29 20 3b 3b 20 6e 6f 20 6d 6f 72 65 20 74 65 73  ) ;; no more tes
76d0: 74 73 20 72 65 6d 61 69 6e 69 6e 67 0a 09 09 20  ts remaining... 
76e0: 28 6c 65 74 2a 20 28 28 64 70 61 72 74 73 20 20  (let* ((dparts  
76f0: 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 6c 61  (string-split la
7700: 73 74 74 70 61 74 68 20 22 2f 22 29 29 0a 09 09  sttpath "/"))...
7710: 09 28 72 75 6e 70 61 74 68 20 28 63 6f 6e 63 20  .(runpath (conc 
7720: 22 2f 22 20 28 73 74 72 69 6e 67 2d 69 6e 74 65  "/" (string-inte
7730: 72 73 70 65 72 73 65 20 0a 09 09 09 09 09 20 20  rsperse ......  
7740: 20 20 28 74 61 6b 65 20 64 70 61 72 74 73 20 28    (take dparts (
7750: 2d 20 28 6c 65 6e 67 74 68 20 64 70 61 72 74 73  - (length dparts
7760: 29 20 31 29 29 0a 09 09 09 09 09 20 20 20 20 22  ) 1))......    "
7770: 2f 22 29 29 29 29 0a 09 09 20 20 20 28 64 65 62  /"))))...   (deb
7780: 75 67 3a 70 72 69 6e 74 20 31 20 22 52 65 6d 6f  ug:print 1 "Remo
7790: 76 69 6e 67 20 72 75 6e 3a 20 22 20 72 75 6e 6b  ving run: " runk
77a0: 65 79 20 22 20 22 20 28 64 62 3a 67 65 74 2d 76  ey " " (db:get-v
77b0: 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72  alue-by-header r
77c0: 75 6e 20 68 65 61 64 65 72 20 22 72 75 6e 6e 61  un header "runna
77d0: 6d 65 22 29 29 0a 09 09 20 20 20 28 64 62 3a 64  me"))...   (db:d
77e0: 65 6c 65 74 65 2d 72 75 6e 20 64 62 20 72 75 6e  elete-run db run
77f0: 2d 69 64 29 0a 09 09 20 20 20 3b 3b 20 6e 65 65  -id)...   ;; nee
7800: 64 20 74 6f 20 66 69 67 75 72 65 20 6f 75 74 20  d to figure out 
7810: 74 68 65 20 70 61 74 68 20 74 6f 20 74 68 65 20  the path to the 
7820: 72 75 6e 20 64 69 72 20 61 6e 64 20 72 65 6d 6f  run dir and remo
7830: 76 65 20 69 74 20 69 66 20 65 6d 70 74 79 0a 09  ve it if empty..
7840: 09 20 20 20 3b 3b 20 20 20 20 28 69 66 20 28 6e  .   ;;    (if (n
7850: 75 6c 6c 3f 20 28 67 6c 6f 62 20 28 63 6f 6e 63  ull? (glob (conc
7860: 20 72 75 6e 70 61 74 68 20 22 2f 2a 22 29 29 29   runpath "/*")))
7870: 0a 09 09 20 20 20 3b 3b 20 20 20 20 20 20 20 20  ...   ;;        
7880: 28 62 65 67 69 6e 0a 09 09 20 20 20 3b 3b 20 09  (begin...   ;; .
7890: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20   (debug:print 1 
78a0: 22 52 65 6d 6f 76 69 6e 67 20 72 75 6e 20 64 69  "Removing run di
78b0: 72 20 22 20 72 75 6e 70 61 74 68 29 0a 09 09 20  r " runpath)... 
78c0: 20 20 3b 3b 20 09 20 28 73 79 73 74 65 6d 20 28    ;; . (system (
78d0: 63 6f 6e 63 20 22 72 6d 64 69 72 20 2d 70 20 22  conc "rmdir -p "
78e0: 20 72 75 6e 70 61 74 68 29 29 29 29 0a 09 09 20   runpath))))... 
78f0: 20 20 29 29 29 29 0a 09 20 29 29 0a 20 20 20 20    )))).. )).    
7900: 20 72 75 6e 73 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d   runs)))..;;====
7910: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7920: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7930: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7940: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7950: 3d 3d 0a 3b 3b 20 52 6f 75 74 69 6e 65 73 20 66  ==.;; Routines f
7960: 6f 72 20 6d 61 6e 69 70 75 6c 61 74 69 6e 67 20  or manipulating 
7970: 72 75 6e 73 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d  runs.;;=========
7980: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7990: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
79a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
79b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b  =============..;
79c0: 3b 20 53 69 6e 63 65 20 6d 61 6e 79 20 63 61 6c  ; Since many cal
79d0: 6c 73 20 74 6f 20 61 20 72 75 6e 20 72 65 71 75  ls to a run requ
79e0: 69 72 65 20 70 72 65 74 74 79 20 6d 75 63 68 20  ire pretty much 
79f0: 74 68 65 20 73 61 6d 65 20 73 65 74 75 70 20 0a  the same setup .
7a00: 3b 3b 20 74 68 69 73 20 77 72 61 70 70 65 72 20  ;; this wrapper 
7a10: 69 73 20 75 73 65 64 20 74 6f 20 72 65 64 75 63  is used to reduc
7a20: 65 20 74 68 65 20 72 65 70 6c 69 63 61 74 69 6f  e the replicatio
7a30: 6e 20 6f 66 20 63 6f 64 65 0a 28 64 65 66 69 6e  n of code.(defin
7a40: 65 20 28 67 65 6e 65 72 61 6c 2d 72 75 6e 2d 63  e (general-run-c
7a50: 61 6c 6c 20 73 77 69 74 63 68 6e 61 6d 65 20 61  all switchname a
7a60: 63 74 69 6f 6e 2d 64 65 73 63 20 70 72 6f 63 29  ction-desc proc)
7a70: 0a 20 20 28 69 66 20 28 6e 6f 74 20 28 61 72 67  .  (if (not (arg
7a80: 73 3a 67 65 74 2d 61 72 67 20 22 3a 72 75 6e 6e  s:get-arg ":runn
7a90: 61 6d 65 22 29 29 0a 20 20 20 20 20 20 28 62 65  ame")).      (be
7aa0: 67 69 6e 0a 09 28 64 65 62 75 67 3a 70 72 69 6e  gin..(debug:prin
7ab0: 74 20 30 20 22 45 52 52 4f 52 3a 20 4d 69 73 73  t 0 "ERROR: Miss
7ac0: 69 6e 67 20 72 65 71 75 69 72 65 64 20 70 61 72  ing required par
7ad0: 61 6d 65 74 65 72 20 66 6f 72 20 22 20 73 77 69  ameter for " swi
7ae0: 74 63 68 6e 61 6d 65 20 22 2c 20 79 6f 75 20 6d  tchname ", you m
7af0: 75 73 74 20 73 70 65 63 69 66 79 20 74 68 65 20  ust specify the 
7b00: 72 75 6e 20 6e 61 6d 65 20 77 69 74 68 20 3a 72  run name with :r
7b10: 75 6e 6e 61 6d 65 20 72 75 6e 6e 61 6d 65 22 29  unname runname")
7b20: 0a 09 28 65 78 69 74 20 32 29 29 0a 20 20 20 20  ..(exit 2)).    
7b30: 20 20 28 6c 65 74 20 28 28 64 62 20 23 66 29 29    (let ((db #f))
7b40: 0a 09 28 69 66 20 28 6e 6f 74 20 28 73 65 74 75  ..(if (not (setu
7b50: 70 2d 66 6f 72 2d 72 75 6e 29 29 0a 09 20 20 20  p-for-run))..   
7b60: 20 28 62 65 67 69 6e 20 0a 09 20 20 20 20 20 20   (begin ..      
7b70: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
7b80: 46 61 69 6c 65 64 20 74 6f 20 73 65 74 75 70 2c  Failed to setup,
7b90: 20 65 78 69 74 69 6e 67 22 29 0a 09 20 20 20 20   exiting")..    
7ba0: 20 20 28 65 78 69 74 20 31 29 29 29 0a 09 28 73    (exit 1)))..(s
7bb0: 65 74 21 20 64 62 20 28 6f 70 65 6e 2d 64 62 29  et! db (open-db)
7bc0: 29 0a 09 28 69 66 20 28 6e 6f 74 20 28 63 61 72  )..(if (not (car
7bd0: 20 2a 63 6f 6e 66 69 67 69 6e 66 6f 2a 29 29 0a   *configinfo*)).
7be0: 09 20 20 20 20 28 62 65 67 69 6e 0a 09 20 20 20  .    (begin..   
7bf0: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
7c00: 30 20 22 45 52 52 4f 52 3a 20 41 74 74 65 6d 70  0 "ERROR: Attemp
7c10: 74 65 64 20 74 6f 20 22 20 61 63 74 69 6f 6e 2d  ted to " action-
7c20: 64 65 73 63 20 22 20 62 75 74 20 72 75 6e 20 61  desc " but run a
7c30: 72 65 61 20 63 6f 6e 66 69 67 20 66 69 6c 65 20  rea config file 
7c40: 6e 6f 74 20 66 6f 75 6e 64 22 29 0a 09 20 20 20  not found")..   
7c50: 20 20 20 28 65 78 69 74 20 31 29 29 0a 09 20 20     (exit 1))..  
7c60: 20 20 3b 3b 20 45 78 74 72 61 63 74 20 6f 75 74    ;; Extract out
7c70: 20 73 74 75 66 66 20 6e 65 65 64 65 64 20 69 6e   stuff needed in
7c80: 20 6d 6f 73 74 20 6f 72 20 6d 61 6e 79 20 63 61   most or many ca
7c90: 6c 6c 73 0a 09 20 20 20 20 3b 3b 20 68 65 72 65  lls..    ;; here
7ca0: 20 74 68 65 6e 20 63 61 6c 6c 20 70 72 6f 63 0a   then call proc.
7cb0: 09 20 20 20 20 28 6c 65 74 2a 20 28 28 6b 65 79  .    (let* ((key
7cc0: 73 20 20 20 20 20 20 20 28 64 62 2d 67 65 74 2d  s       (db-get-
7cd0: 6b 65 79 73 20 64 62 29 29 0a 09 09 20 20 20 28  keys db))...   (
7ce0: 6b 65 79 6e 61 6d 65 73 20 20 20 28 6d 61 70 20  keynames   (map 
7cf0: 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64 6e 61 6d  key:get-fieldnam
7d00: 65 20 6b 65 79 73 29 29 0a 09 09 20 20 20 28 6b  e keys))...   (k
7d10: 65 79 76 61 6c 6c 73 74 20 20 28 6b 65 79 73 2d  eyvallst  (keys-
7d20: 3e 76 61 6c 6c 69 73 74 20 6b 65 79 73 20 23 74  >vallist keys #t
7d30: 29 29 29 0a 09 20 20 20 20 20 20 28 70 72 6f 63  )))..      (proc
7d40: 20 64 62 20 6b 65 79 73 20 6b 65 79 6e 61 6d 65   db keys keyname
7d50: 73 20 6b 65 79 76 61 6c 6c 73 74 29 29 29 0a 09  s keyvallst)))..
7d60: 28 73 71 6c 69 74 65 33 3a 66 69 6e 61 6c 69 7a  (sqlite3:finaliz
7d70: 65 21 20 64 62 29 0a 09 28 73 65 74 21 20 2a 64  e! db)..(set! *d
7d80: 69 64 73 6f 6d 65 74 68 69 6e 67 2a 20 23 74 29  idsomething* #t)
7d90: 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d  )))..;;=========
7da0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7db0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7dc0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7dd0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b  =============.;;
7de0: 20 52 6f 6c 6c 75 70 20 72 75 6e 73 0a 3b 3b 3d   Rollup runs.;;=
7df0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7e00: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7e10: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7e20: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7e30: 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 55 70 64 61 74 65  =====..;; Update
7e40: 20 74 68 65 20 74 65 73 74 5f 6d 65 74 61 20 74   the test_meta t
7e50: 61 62 6c 65 20 66 6f 72 20 74 68 69 73 20 74 65  able for this te
7e60: 73 74 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73  st.(define (runs
7e70: 3a 75 70 64 61 74 65 2d 74 65 73 74 5f 6d 65 74  :update-test_met
7e80: 61 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 20 74  a db test-name t
7e90: 65 73 74 2d 63 6f 6e 66 29 0a 20 20 28 6c 65 74  est-conf).  (let
7ea0: 20 28 28 63 75 72 72 72 65 63 6f 72 64 20 28 64   ((currrecord (d
7eb0: 62 3a 74 65 73 74 6d 65 74 61 2d 67 65 74 2d 72  b:testmeta-get-r
7ec0: 65 63 6f 72 64 20 64 62 20 74 65 73 74 2d 6e 61  ecord db test-na
7ed0: 6d 65 29 29 29 0a 20 20 20 20 28 69 66 20 28 6e  me))).    (if (n
7ee0: 6f 74 20 63 75 72 72 72 65 63 6f 72 64 29 0a 09  ot currrecord)..
7ef0: 28 62 65 67 69 6e 0a 09 20 20 28 73 65 74 21 20  (begin..  (set! 
7f00: 63 75 72 72 72 65 63 6f 72 64 20 28 6d 61 6b 65  currrecord (make
7f10: 2d 76 65 63 74 6f 72 20 31 30 20 23 66 29 29 0a  -vector 10 #f)).
7f20: 09 20 20 28 64 62 3a 74 65 73 74 6d 65 74 61 2d  .  (db:testmeta-
7f30: 61 64 64 2d 72 65 63 6f 72 64 20 64 62 20 74 65  add-record db te
7f40: 73 74 2d 6e 61 6d 65 29 29 29 0a 20 20 20 20 28  st-name))).    (
7f50: 66 6f 72 2d 65 61 63 68 20 0a 20 20 20 20 20 28  for-each .     (
7f60: 6c 61 6d 62 64 61 20 28 6b 65 79 29 0a 20 20 20  lambda (key).   
7f70: 20 20 20 20 28 6c 65 74 2a 20 28 28 69 64 78 20      (let* ((idx 
7f80: 28 63 61 64 72 20 6b 65 79 29 29 0a 09 20 20 20  (cadr key))..   
7f90: 20 20 20 28 66 6c 64 20 28 63 61 72 20 20 6b 65     (fld (car  ke
7fa0: 79 29 29 0a 09 20 20 20 20 20 20 28 76 61 6c 20  y))..      (val 
7fb0: 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 74  (config-lookup t
7fc0: 65 73 74 2d 63 6f 6e 66 20 22 74 65 73 74 5f 6d  est-conf "test_m
7fd0: 65 74 61 22 20 66 6c 64 29 29 29 0a 09 20 28 69  eta" fld))).. (i
7fe0: 66 20 28 61 6e 64 20 76 61 6c 20 28 6e 6f 74 20  f (and val (not 
7ff0: 28 65 71 75 61 6c 3f 20 28 76 65 63 74 6f 72 2d  (equal? (vector-
8000: 72 65 66 20 63 75 72 72 72 65 63 6f 72 64 20 69  ref currrecord i
8010: 64 78 29 20 76 61 6c 29 29 29 0a 09 20 20 20 20  dx) val)))..    
8020: 20 28 62 65 67 69 6e 0a 09 20 20 20 20 20 20 20   (begin..       
8030: 28 70 72 69 6e 74 20 22 55 70 64 61 74 69 6e 67  (print "Updating
8040: 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 22   " test-name " "
8050: 20 66 6c 64 20 22 20 74 6f 20 22 20 76 61 6c 29   fld " to " val)
8060: 0a 09 20 20 20 20 20 20 20 28 64 62 3a 74 65 73  ..       (db:tes
8070: 74 6d 65 74 61 2d 75 70 64 61 74 65 2d 66 69 65  tmeta-update-fie
8080: 6c 64 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 20  ld db test-name 
8090: 66 6c 64 20 76 61 6c 29 29 29 29 29 0a 20 20 20  fld val))))).   
80a0: 20 20 27 28 28 22 61 75 74 68 6f 72 22 20 32 29    '(("author" 2)
80b0: 28 22 6f 77 6e 65 72 22 20 33 29 28 22 64 65 73  ("owner" 3)("des
80c0: 63 72 69 70 74 69 6f 6e 22 20 34 29 28 22 72 65  cription" 4)("re
80d0: 76 69 65 77 65 64 22 20 35 29 28 22 74 61 67 73  viewed" 5)("tags
80e0: 22 20 39 29 29 29 29 29 0a 0a 3b 3b 20 55 70 64  " 9)))))..;; Upd
80f0: 61 74 65 20 74 65 73 74 5f 6d 65 74 61 20 66 6f  ate test_meta fo
8100: 72 20 61 6c 6c 20 74 65 73 74 73 0a 28 64 65 66  r all tests.(def
8110: 69 6e 65 20 28 72 75 6e 73 3a 75 70 64 61 74 65  ine (runs:update
8120: 2d 61 6c 6c 2d 74 65 73 74 5f 6d 65 74 61 20 64  -all-test_meta d
8130: 62 29 0a 20 20 28 6c 65 74 20 28 28 74 65 73 74  b).  (let ((test
8140: 2d 6e 61 6d 65 73 20 28 67 65 74 2d 61 6c 6c 2d  -names (get-all-
8150: 6c 65 67 61 6c 2d 74 65 73 74 73 29 29 29 0a 20  legal-tests))). 
8160: 20 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 20     (for-each .  
8170: 20 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74     (lambda (test
8180: 2d 6e 61 6d 65 29 0a 20 20 20 20 20 20 20 28 6c  -name).       (l
8190: 65 74 2a 20 28 28 74 65 73 74 2d 70 61 74 68 20  et* ((test-path 
81a0: 20 20 20 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74     (conc *toppat
81b0: 68 2a 20 22 2f 74 65 73 74 73 2f 22 20 74 65 73  h* "/tests/" tes
81c0: 74 2d 6e 61 6d 65 29 29 0a 09 20 20 20 20 20 20  t-name))..      
81d0: 28 74 65 73 74 2d 63 6f 6e 66 69 67 66 20 28 63  (test-configf (c
81e0: 6f 6e 63 20 74 65 73 74 2d 70 61 74 68 20 22 2f  onc test-path "/
81f0: 74 65 73 74 63 6f 6e 66 69 67 22 29 29 0a 09 20  testconfig")).. 
8200: 20 20 20 20 20 28 74 65 73 74 65 78 69 73 74 73       (testexists
8210: 20 20 20 28 61 6e 64 20 28 66 69 6c 65 2d 65 78     (and (file-ex
8220: 69 73 74 73 3f 20 74 65 73 74 2d 63 6f 6e 66 69  ists? test-confi
8230: 67 66 29 28 66 69 6c 65 2d 72 65 61 64 2d 61 63  gf)(file-read-ac
8240: 63 65 73 73 3f 20 74 65 73 74 2d 63 6f 6e 66 69  cess? test-confi
8250: 67 66 29 29 29 0a 09 20 20 20 20 20 20 3b 3b 20  gf)))..      ;; 
8260: 72 65 61 64 20 63 6f 6e 66 69 67 73 20 77 69 74  read configs wit
8270: 68 20 74 72 69 63 6b 73 20 74 75 72 6e 65 64 20  h tricks turned 
8280: 6f 66 66 20 28 69 2e 65 2e 20 6e 6f 20 73 79 73  off (i.e. no sys
8290: 74 65 6d 29 0a 09 20 20 20 20 20 20 28 74 65 73  tem)..      (tes
82a0: 74 2d 63 6f 6e 66 20 20 20 20 28 69 66 20 74 65  t-conf    (if te
82b0: 73 74 65 78 69 73 74 73 20 28 72 65 61 64 2d 63  stexists (read-c
82c0: 6f 6e 66 69 67 20 74 65 73 74 2d 63 6f 6e 66 69  onfig test-confi
82d0: 67 66 20 23 66 20 23 66 29 28 6d 61 6b 65 2d 68  gf #f #f)(make-h
82e0: 61 73 68 2d 74 61 62 6c 65 29 29 29 29 0a 09 20  ash-table)))).. 
82f0: 28 72 75 6e 73 3a 75 70 64 61 74 65 2d 74 65 73  (runs:update-tes
8300: 74 5f 6d 65 74 61 20 64 62 20 74 65 73 74 2d 6e  t_meta db test-n
8310: 61 6d 65 20 74 65 73 74 2d 63 6f 6e 66 29 29 29  ame test-conf)))
8320: 0a 20 20 20 20 20 74 65 73 74 2d 6e 61 6d 65 73  .     test-names
8330: 29 29 29 0a 09 20 0a 28 64 65 66 69 6e 65 20 28  ))).. .(define (
8340: 72 75 6e 73 3a 72 6f 6c 6c 75 70 2d 72 75 6e 20  runs:rollup-run 
8350: 64 62 20 6b 65 79 73 20 6b 65 79 6e 61 6d 65 73  db keys keynames
8360: 20 6b 65 79 76 61 6c 6c 73 74 20 6e 29 0a 20 20   keyvallst n).  
8370: 28 6c 65 74 2a 20 28 28 6e 65 77 2d 72 75 6e 2d  (let* ((new-run-
8380: 69 64 20 20 20 28 72 65 67 69 73 74 65 72 2d 72  id   (register-r
8390: 75 6e 20 64 62 20 6b 65 79 73 29 29 0a 09 20 28  un db keys)).. (
83a0: 73 69 6d 69 6c 61 72 2d 72 75 6e 73 20 28 64 62  similar-runs (db
83b0: 3a 67 65 74 2d 72 75 6e 73 20 64 62 20 6b 65 79  :get-runs db key
83c0: 73 29 29 0a 09 20 28 74 65 73 74 73 2d 6e 2d 64  s)).. (tests-n-d
83d0: 61 79 73 20 28 64 62 3a 67 65 74 2d 74 65 73 74  ays (db:get-test
83e0: 73 2d 6e 2d 64 61 79 73 20 64 62 20 73 69 6d 69  s-n-days db simi
83f0: 6c 61 72 2d 72 75 6e 73 29 29 29 0a 20 20 20 20  lar-runs))).    
8400: 28 66 6f 72 2d 65 61 63 68 20 0a 20 20 20 20 20  (for-each .     
8410: 28 6c 61 6d 62 64 61 20 28 74 65 73 74 2d 69 64  (lambda (test-id
8420: 29 0a 20 20 20 20 20 20 20 28 64 62 3a 72 6f 6c  ).       (db:rol
8430: 6c 75 70 2d 74 65 73 74 20 64 62 20 72 75 6e 2d  lup-test db run-
8440: 69 64 20 74 65 73 74 2d 69 64 29 29 0a 20 20 20  id test-id)).   
8450: 20 20 74 65 73 74 73 2d 6e 2d 64 61 79 73 29 29    tests-n-days))
8460: 29 0a                                            ).