Megatest

Hex Artifact Content
Login

Artifact 9b2009f6fdac80296cd26c9087db998709967df7:


0000: 0a 3b 3b 20 43 6f 70 79 72 69 67 68 74 20 32 30  .;; Copyright 20
0010: 30 36 2d 32 30 31 31 2c 20 4d 61 74 74 68 65 77  06-2011, Matthew
0020: 20 57 65 6c 6c 61 6e 64 2e 0a 3b 3b 20 0a 3b 3b   Welland..;; .;;
0030: 20 20 54 68 69 73 20 70 72 6f 67 72 61 6d 20 69    This program i
0040: 73 20 6d 61 64 65 20 61 76 61 69 6c 61 62 6c 65  s made available
0050: 20 75 6e 64 65 72 20 74 68 65 20 47 4e 55 20 47   under the GNU G
0060: 50 4c 20 76 65 72 73 69 6f 6e 20 32 2e 30 20 6f  PL version 2.0 o
0070: 72 0a 3b 3b 20 20 67 72 65 61 74 65 72 2e 20 53  r.;;  greater. S
0080: 65 65 20 74 68 65 20 61 63 63 6f 6d 70 61 6e 79  ee the accompany
0090: 69 6e 67 20 66 69 6c 65 20 43 4f 50 59 49 4e 47  ing file COPYING
00a0: 20 66 6f 72 20 64 65 74 61 69 6c 73 2e 0a 3b 3b   for details..;;
00b0: 20 0a 3b 3b 20 20 54 68 69 73 20 70 72 6f 67 72   .;;  This progr
00c0: 61 6d 20 69 73 20 64 69 73 74 72 69 62 75 74 65  am is distribute
00d0: 64 20 57 49 54 48 4f 55 54 20 41 4e 59 20 57 41  d WITHOUT ANY WA
00e0: 52 52 41 4e 54 59 3b 20 77 69 74 68 6f 75 74 20  RRANTY; without 
00f0: 65 76 65 6e 20 74 68 65 0a 3b 3b 20 20 69 6d 70  even the.;;  imp
0100: 6c 69 65 64 20 77 61 72 72 61 6e 74 79 20 6f 66  lied warranty of
0110: 20 4d 45 52 43 48 41 4e 54 41 42 49 4c 49 54 59   MERCHANTABILITY
0120: 20 6f 72 20 46 49 54 4e 45 53 53 20 46 4f 52 20   or FITNESS FOR 
0130: 41 20 50 41 52 54 49 43 55 4c 41 52 0a 3b 3b 20  A PARTICULAR.;; 
0140: 20 50 55 52 50 4f 53 45 2e 0a 0a 3b 3b 20 20 73   PURPOSE...;;  s
0150: 74 72 66 74 69 6d 65 28 27 25 6d 2f 25 64 2f 25  trftime('%m/%d/%
0160: 59 20 25 48 3a 25 4d 3a 25 53 27 2c 27 6e 6f 77  Y %H:%M:%S','now
0170: 27 2c 27 6c 6f 63 61 6c 74 69 6d 65 27 29 0a 0a  ','localtime')..
0180: 3b 3b 20 72 65 67 69 73 74 65 72 20 61 20 74 65  ;; register a te
0190: 73 74 20 72 75 6e 20 77 69 74 68 20 74 68 65 20  st run with the 
01a0: 64 62 0a 28 64 65 66 69 6e 65 20 28 72 65 67 69  db.(define (regi
01b0: 73 74 65 72 2d 72 75 6e 20 64 62 20 6b 65 79 73  ster-run db keys
01c0: 29 20 3b 3b 20 74 65 73 74 2d 6e 61 6d 65 29 0a  ) ;; test-name).
01d0: 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 73 74 72    (let* ((keystr
01e0: 20 20 20 20 28 6b 65 79 73 2d 3e 6b 65 79 73 74      (keys->keyst
01f0: 72 20 6b 65 79 73 29 29 0a 09 20 28 63 6f 6d 6d  r keys)).. (comm
0200: 61 20 20 20 20 20 28 69 66 20 28 3e 20 28 6c 65  a     (if (> (le
0210: 6e 67 74 68 20 6b 65 79 73 29 20 30 29 20 22 2c  ngth keys) 0) ",
0220: 22 20 22 22 29 29 0a 09 20 28 61 6e 64 73 74 72  " "")).. (andstr
0230: 20 20 20 20 28 69 66 20 28 3e 20 28 6c 65 6e 67      (if (> (leng
0240: 74 68 20 6b 65 79 73 29 20 30 29 20 22 20 41 4e  th keys) 0) " AN
0250: 44 20 22 20 22 22 29 29 0a 09 20 28 76 61 6c 73  D " "")).. (vals
0260: 6c 6f 74 73 20 20 28 6b 65 79 73 2d 3e 76 61 6c  lots  (keys->val
0270: 73 6c 6f 74 73 20 6b 65 79 73 29 29 20 3b 3b 20  slots keys)) ;; 
0280: 3f 2c 3f 2c 3f 20 2e 2e 2e 0a 09 20 28 6b 65 79  ?,?,? ..... (key
0290: 76 61 6c 6c 73 74 20 28 6b 65 79 73 2d 3e 76 61  vallst (keys->va
02a0: 6c 6c 69 73 74 20 6b 65 79 73 29 29 20 3b 3b 20  llist keys)) ;; 
02b0: 65 78 74 72 61 63 74 73 20 74 68 65 20 76 61 6c  extracts the val
02c0: 75 65 73 20 66 72 6f 6d 20 72 65 6d 61 69 6e 64  ues from remaind
02d0: 65 72 20 6f 66 20 28 61 72 67 76 29 0a 09 20 28  er of (argv).. (
02e0: 72 75 6e 6e 61 6d 65 20 20 20 28 67 65 74 2d 77  runname   (get-w
02f0: 69 74 68 2d 64 65 66 61 75 6c 74 20 22 3a 72 75  ith-default ":ru
0300: 6e 6e 61 6d 65 22 20 23 66 29 29 0a 09 20 28 73  nname" #f)).. (s
0310: 74 61 74 65 20 20 20 20 20 28 67 65 74 2d 77 69  tate     (get-wi
0320: 74 68 2d 64 65 66 61 75 6c 74 20 22 3a 73 74 61  th-default ":sta
0330: 74 65 22 20 22 6e 6f 22 29 29 0a 09 20 28 73 74  te" "no")).. (st
0340: 61 74 75 73 20 20 20 20 28 67 65 74 2d 77 69 74  atus    (get-wit
0350: 68 2d 64 65 66 61 75 6c 74 20 22 3a 73 74 61 74  h-default ":stat
0360: 75 73 22 20 22 6e 2f 61 22 29 29 0a 09 20 28 61  us" "n/a")).. (a
0370: 6c 6c 76 61 6c 73 20 20 20 28 61 70 70 65 6e 64  llvals   (append
0380: 20 28 6c 69 73 74 20 72 75 6e 6e 61 6d 65 20 73   (list runname s
0390: 74 61 74 65 20 73 74 61 74 75 73 20 75 73 65 72  tate status user
03a0: 29 20 6b 65 79 76 61 6c 6c 73 74 29 29 0a 09 20  ) keyvallst)).. 
03b0: 28 71 72 79 76 61 6c 73 20 20 20 28 61 70 70 65  (qryvals   (appe
03c0: 6e 64 20 28 6c 69 73 74 20 72 75 6e 6e 61 6d 65  nd (list runname
03d0: 29 20 6b 65 79 76 61 6c 6c 73 74 29 29 0a 09 20  ) keyvallst)).. 
03e0: 28 6b 65 79 3d 3f 73 74 72 20 20 28 73 74 72 69  (key=?str  (stri
03f0: 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 28  ng-intersperse (
0400: 6d 61 70 20 28 6c 61 6d 62 64 61 20 28 6b 29 28  map (lambda (k)(
0410: 63 6f 6e 63 20 28 6b 65 79 3a 67 65 74 2d 66 69  conc (key:get-fi
0420: 65 6c 64 6e 61 6d 65 20 6b 29 20 22 3d 3f 22 29  eldname k) "=?")
0430: 29 20 6b 65 79 73 29 20 22 20 41 4e 44 20 22 29  ) keys) " AND ")
0440: 29 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72  )).    (debug:pr
0450: 69 6e 74 20 33 20 22 6b 65 79 73 3a 20 22 20 6b  int 3 "keys: " k
0460: 65 79 73 20 22 20 61 6c 6c 76 61 6c 73 3a 20 22  eys " allvals: "
0470: 20 61 6c 6c 76 61 6c 73 20 22 20 6b 65 79 76 61   allvals " keyva
0480: 6c 6c 73 74 3a 20 22 20 6b 65 79 76 61 6c 6c 73  llst: " keyvalls
0490: 74 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72  t).    (debug:pr
04a0: 69 6e 74 20 32 20 22 4e 4f 54 45 3a 20 75 73 69  int 2 "NOTE: usi
04b0: 6e 67 20 6b 65 79 20 22 20 28 73 74 72 69 6e 67  ng key " (string
04c0: 2d 69 6e 74 65 72 73 70 65 72 73 65 20 6b 65 79  -intersperse key
04d0: 76 61 6c 6c 73 74 20 22 2f 22 29 20 22 20 66 6f  vallst "/") " fo
04e0: 72 20 74 68 69 73 20 72 75 6e 22 29 0a 20 20 20  r this run").   
04f0: 20 28 69 66 20 28 61 6e 64 20 72 75 6e 6e 61 6d   (if (and runnam
0500: 65 20 28 6e 75 6c 6c 3f 20 28 66 69 6c 74 65 72  e (null? (filter
0510: 20 28 6c 61 6d 62 64 61 20 28 78 29 28 6e 6f 74   (lambda (x)(not
0520: 20 78 29 29 20 6b 65 79 76 61 6c 6c 73 74 29 29   x)) keyvallst))
0530: 29 20 3b 3b 20 74 68 65 72 65 20 6d 75 73 74 20  ) ;; there must 
0540: 62 65 20 61 20 62 65 74 74 65 72 20 77 61 79 20  be a better way 
0550: 74 6f 20 22 61 70 70 6c 79 20 61 6e 64 22 0a 09  to "apply and"..
0560: 28 6c 65 74 20 28 28 72 65 73 20 23 66 29 29 0a  (let ((res #f)).
0570: 09 20 20 28 61 70 70 6c 79 20 73 71 6c 69 74 65  .  (apply sqlite
0580: 33 3a 65 78 65 63 75 74 65 20 64 62 20 28 63 6f  3:execute db (co
0590: 6e 63 20 22 49 4e 53 45 52 54 20 4f 52 20 49 47  nc "INSERT OR IG
05a0: 4e 4f 52 45 20 49 4e 54 4f 20 72 75 6e 73 20 28  NORE INTO runs (
05b0: 72 75 6e 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74  runname,state,st
05c0: 61 74 75 73 2c 6f 77 6e 65 72 2c 65 76 65 6e 74  atus,owner,event
05d0: 5f 74 69 6d 65 22 20 63 6f 6d 6d 61 20 6b 65 79  _time" comma key
05e0: 73 74 72 20 22 29 20 56 41 4c 55 45 53 20 28 3f  str ") VALUES (?
05f0: 2c 3f 2c 3f 2c 3f 2c 73 74 72 66 74 69 6d 65 28  ,?,?,?,strftime(
0600: 27 25 73 27 2c 27 6e 6f 77 27 29 22 20 63 6f 6d  '%s','now')" com
0610: 6d 61 20 76 61 6c 73 6c 6f 74 73 20 22 29 3b 22  ma valslots ");"
0620: 29 0a 09 09 20 61 6c 6c 76 61 6c 73 29 0a 09 20  )... allvals).. 
0630: 20 28 61 70 70 6c 79 20 73 71 6c 69 74 65 33 3a   (apply sqlite3:
0640: 66 6f 72 2d 65 61 63 68 2d 72 6f 77 20 0a 09 20  for-each-row .. 
0650: 20 20 28 6c 61 6d 62 64 61 20 28 69 64 29 0a 09    (lambda (id)..
0660: 20 20 20 20 20 28 73 65 74 21 20 72 65 73 20 69       (set! res i
0670: 64 29 29 0a 09 20 20 20 64 62 0a 09 20 20 20 28  d))..   db..   (
0680: 6c 65 74 20 28 28 71 72 79 20 28 63 6f 6e 63 20  let ((qry (conc 
0690: 22 53 45 4c 45 43 54 20 69 64 20 46 52 4f 4d 20  "SELECT id FROM 
06a0: 72 75 6e 73 20 57 48 45 52 45 20 28 72 75 6e 6e  runs WHERE (runn
06b0: 61 6d 65 3d 3f 20 22 20 61 6e 64 73 74 72 20 6b  ame=? " andstr k
06c0: 65 79 3d 3f 73 74 72 20 22 29 3b 22 29 29 29 0a  ey=?str ");"))).
06d0: 09 20 20 20 20 20 3b 28 64 65 62 75 67 3a 70 72  .     ;(debug:pr
06e0: 69 6e 74 20 34 20 22 71 72 79 3a 20 22 20 71 72  int 4 "qry: " qr
06f0: 79 29 20 0a 09 20 20 20 20 20 71 72 79 29 0a 09  y) ..     qry)..
0700: 20 20 20 71 72 79 76 61 6c 73 29 0a 09 20 20 28     qryvals)..  (
0710: 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20  sqlite3:execute 
0720: 64 62 20 22 55 50 44 41 54 45 20 72 75 6e 73 20  db "UPDATE runs 
0730: 53 45 54 20 73 74 61 74 65 3d 3f 2c 73 74 61 74  SET state=?,stat
0740: 75 73 3d 3f 20 57 48 45 52 45 20 69 64 3d 3f 3b  us=? WHERE id=?;
0750: 22 20 73 74 61 74 65 20 73 74 61 74 75 73 20 72  " state status r
0760: 65 73 29 0a 09 20 20 72 65 73 29 20 0a 09 28 62  es)..  res) ..(b
0770: 65 67 69 6e 0a 09 20 20 28 64 65 62 75 67 3a 70  egin..  (debug:p
0780: 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 43  rint 0 "ERROR: C
0790: 61 6c 6c 65 64 20 77 69 74 68 6f 75 74 20 61 6c  alled without al
07a0: 6c 20 6e 65 63 65 73 73 61 72 79 20 6b 65 79 73  l necessary keys
07b0: 22 29 0a 09 20 20 23 66 29 29 29 29 0a 0a 3b 3b  ")..  #f))))..;;
07c0: 20 72 75 6e 73 3a 67 65 74 2d 72 75 6e 73 2d 62   runs:get-runs-b
07d0: 79 2d 70 61 74 74 0a 3b 3b 20 67 65 74 20 72 75  y-patt.;; get ru
07e0: 6e 73 20 62 79 20 6c 69 73 74 20 6f 66 20 63 72  ns by list of cr
07f0: 69 74 65 72 69 61 0a 3b 3b 20 72 65 67 69 73 74  iteria.;; regist
0800: 65 72 20 61 20 74 65 73 74 20 72 75 6e 20 77 69  er a test run wi
0810: 74 68 20 74 68 65 20 64 62 0a 3b 3b 0a 3b 3b 20  th the db.;;.;; 
0820: 55 73 65 3a 20 28 64 62 2d 67 65 74 2d 76 61 6c  Use: (db-get-val
0830: 75 65 2d 62 79 2d 68 65 61 64 65 72 20 28 64 62  ue-by-header (db
0840: 3a 67 65 74 2d 68 65 61 64 65 72 20 72 75 6e 69  :get-header runi
0850: 6e 66 6f 29 28 64 62 3a 67 65 74 2d 72 6f 77 20  nfo)(db:get-row 
0860: 72 75 6e 69 6e 66 6f 29 29 0a 3b 3b 20 20 74 6f  runinfo)).;;  to
0870: 20 65 78 74 72 61 63 74 20 69 6e 66 6f 20 66 72   extract info fr
0880: 6f 6d 20 74 68 65 20 73 74 72 75 63 74 75 72 65  om the structure
0890: 20 72 65 74 75 72 6e 65 64 0a 3b 3b 0a 28 64 65   returned.;;.(de
08a0: 66 69 6e 65 20 28 72 75 6e 73 3a 67 65 74 2d 72  fine (runs:get-r
08b0: 75 6e 73 2d 62 79 2d 70 61 74 74 20 64 62 20 6b  uns-by-patt db k
08c0: 65 79 73 20 72 75 6e 6e 61 6d 65 70 61 74 74 20  eys runnamepatt 
08d0: 2e 20 70 61 72 61 6d 73 29 20 3b 3b 20 74 65 73  . params) ;; tes
08e0: 74 2d 6e 61 6d 65 29 0a 20 20 28 6c 65 74 2a 20  t-name).  (let* 
08f0: 28 28 6b 65 79 76 61 6c 6c 73 74 20 28 6b 65 79  ((keyvallst (key
0900: 73 2d 3e 76 61 6c 6c 69 73 74 20 6b 65 79 73 29  s->vallist keys)
0910: 29 0a 09 20 28 74 6d 70 20 20 20 20 20 20 28 72  ).. (tmp      (r
0920: 75 6e 73 3a 67 65 74 2d 73 74 64 2d 72 75 6e 2d  uns:get-std-run-
0930: 66 69 65 6c 64 73 20 6b 65 79 73 20 27 28 22 69  fields keys '("i
0940: 64 22 20 22 72 75 6e 6e 61 6d 65 22 20 22 73 74  d" "runname" "st
0950: 61 74 65 22 20 22 73 74 61 74 75 73 22 20 22 6f  ate" "status" "o
0960: 77 6e 65 72 22 20 22 65 76 65 6e 74 5f 74 69 6d  wner" "event_tim
0970: 65 22 29 29 29 0a 09 20 28 6b 65 79 73 74 72 20  e"))).. (keystr 
0980: 20 20 28 63 61 72 20 74 6d 70 29 29 0a 09 20 28    (car tmp)).. (
0990: 68 65 61 64 65 72 20 20 20 28 63 61 64 72 20 74  header   (cadr t
09a0: 6d 70 29 29 0a 09 20 28 72 65 73 20 20 20 20 20  mp)).. (res     
09b0: 27 28 29 29 0a 09 20 28 6b 65 79 2d 70 61 74 74  '()).. (key-patt
09c0: 20 22 22 29 29 0a 20 20 20 20 28 66 6f 72 2d 65   "")).    (for-e
09d0: 61 63 68 20 28 6c 61 6d 62 64 61 20 28 6b 65 79  ach (lambda (key
09e0: 76 61 6c 29 0a 09 09 28 6c 65 74 2a 20 28 28 6b  val)...(let* ((k
09f0: 65 79 20 20 20 20 28 76 65 63 74 6f 72 2d 72 65  ey    (vector-re
0a00: 66 20 6b 65 79 76 61 6c 20 30 29 29 0a 09 09 20  f keyval 0))... 
0a10: 20 20 20 20 20 20 28 66 75 6c 6b 65 79 20 28 63        (fulkey (c
0a20: 6f 6e 63 20 22 3a 22 20 6b 65 79 29 29 0a 09 09  onc ":" key))...
0a30: 20 20 20 20 20 20 20 28 70 61 74 74 20 20 20 28         (patt   (
0a40: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 66 75 6c  args:get-arg ful
0a50: 6b 65 79 29 29 29 0a 09 09 20 20 28 69 66 20 70  key)))...  (if p
0a60: 61 74 74 0a 09 09 20 20 20 20 20 20 28 73 65 74  att...      (set
0a70: 21 20 6b 65 79 2d 70 61 74 74 20 28 63 6f 6e 63  ! key-patt (conc
0a80: 20 6b 65 79 2d 70 61 74 74 20 22 20 41 4e 44 20   key-patt " AND 
0a90: 22 20 6b 65 79 20 22 20 6c 69 6b 65 20 27 22 20  " key " like '" 
0aa0: 70 61 74 74 20 22 27 22 29 29 0a 09 09 20 20 20  patt "'"))...   
0ab0: 20 20 20 28 62 65 67 69 6e 0a 09 09 09 28 64 65     (begin....(de
0ac0: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52  bug:print 0 "ERR
0ad0: 4f 52 3a 20 73 65 61 72 63 68 69 6e 67 20 66 6f  OR: searching fo
0ae0: 72 20 72 75 6e 73 20 77 69 74 68 20 6e 6f 20 70  r runs with no p
0af0: 61 74 74 65 72 6e 20 73 65 74 20 66 6f 72 20 22  attern set for "
0b00: 20 66 75 6c 6b 65 79 29 0a 09 09 09 28 65 78 69   fulkey)....(exi
0b10: 74 20 36 29 29 29 29 29 0a 09 20 20 20 20 20 20  t 6)))))..      
0b20: 6b 65 79 73 29 0a 20 20 20 20 28 73 71 6c 69 74  keys).    (sqlit
0b30: 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77 20  e3:for-each-row 
0b40: 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 61  .     (lambda (a
0b50: 20 2e 20 72 29 0a 20 20 20 20 20 20 20 28 73 65   . r).       (se
0b60: 74 21 20 72 65 73 20 28 63 6f 6e 73 20 28 6c 69  t! res (cons (li
0b70: 73 74 2d 3e 76 65 63 74 6f 72 20 28 63 6f 6e 73  st->vector (cons
0b80: 20 61 20 72 29 29 20 72 65 73 29 29 29 0a 20 20   a r)) res))).  
0b90: 20 20 20 64 62 20 0a 20 20 20 20 20 28 63 6f 6e     db .     (con
0ba0: 63 20 22 53 45 4c 45 43 54 20 22 20 6b 65 79 73  c "SELECT " keys
0bb0: 74 72 20 22 20 46 52 4f 4d 20 72 75 6e 73 20 57  tr " FROM runs W
0bc0: 48 45 52 45 20 72 75 6e 6e 61 6d 65 20 6c 69 6b  HERE runname lik
0bd0: 65 20 3f 20 22 20 6b 65 79 2d 70 61 74 74 20 22  e ? " key-patt "
0be0: 3b 22 29 0a 20 20 20 20 20 72 75 6e 6e 61 6d 65  ;").     runname
0bf0: 70 61 74 74 29 0a 20 20 20 20 28 76 65 63 74 6f  patt).    (vecto
0c00: 72 20 68 65 61 64 65 72 20 72 65 73 29 29 29 0a  r header res))).
0c10: 0a 28 64 65 66 69 6e 65 20 28 72 65 67 69 73 74  .(define (regist
0c20: 65 72 2d 74 65 73 74 20 64 62 20 72 75 6e 2d 69  er-test db run-i
0c30: 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d  d test-name item
0c40: 2d 70 61 74 68 29 0a 20 20 28 6c 65 74 20 28 28  -path).  (let ((
0c50: 69 74 65 6d 2d 70 61 74 68 73 20 28 69 66 20 28  item-paths (if (
0c60: 65 71 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68  equal? item-path
0c70: 20 22 22 29 0a 09 09 09 28 6c 69 73 74 20 69 74   "")....(list it
0c80: 65 6d 2d 70 61 74 68 29 0a 09 09 09 28 6c 69 73  em-path)....(lis
0c90: 74 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29 29  t item-path ""))
0ca0: 29 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68  )).    (for-each
0cb0: 20 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28   .     (lambda (
0cc0: 70 74 68 29 0a 20 20 20 20 20 20 20 28 73 71 6c  pth).       (sql
0cd0: 69 74 65 33 3a 65 78 65 63 75 74 65 20 64 62 20  ite3:execute db 
0ce0: 22 49 4e 53 45 52 54 20 4f 52 20 49 47 4e 4f 52  "INSERT OR IGNOR
0cf0: 45 20 49 4e 54 4f 20 74 65 73 74 73 20 28 72 75  E INTO tests (ru
0d00: 6e 5f 69 64 2c 74 65 73 74 6e 61 6d 65 2c 65 76  n_id,testname,ev
0d10: 65 6e 74 5f 74 69 6d 65 2c 69 74 65 6d 5f 70 61  ent_time,item_pa
0d20: 74 68 2c 73 74 61 74 65 2c 73 74 61 74 75 73 29  th,state,status)
0d30: 20 56 41 4c 55 45 53 20 28 3f 2c 3f 2c 73 74 72   VALUES (?,?,str
0d40: 66 74 69 6d 65 28 27 25 73 27 2c 27 6e 6f 77 27  ftime('%s','now'
0d50: 29 2c 3f 2c 27 4e 4f 54 5f 53 54 41 52 54 45 44  ),?,'NOT_STARTED
0d60: 27 2c 27 6e 2f 61 27 29 3b 22 20 0a 09 09 09 72  ','n/a');" ....r
0d70: 75 6e 2d 69 64 20 0a 09 09 09 74 65 73 74 2d 6e  un-id ....test-n
0d80: 61 6d 65 0a 09 09 09 70 74 68 20 0a 09 09 09 3b  ame....pth ....;
0d90: 3b 20 28 63 6f 6e 63 20 22 2c 22 20 28 73 74 72  ; (conc "," (str
0da0: 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20  ing-intersperse 
0db0: 74 61 67 73 20 22 2c 22 29 20 22 2c 22 29 0a 09  tags ",") ",")..
0dc0: 09 09 29 29 0a 20 20 20 20 20 69 74 65 6d 2d 70  ..)).     item-p
0dd0: 61 74 68 73 20 29 29 29 0a 0a 3b 3b 20 67 65 74  aths )))..;; get
0de0: 20 74 68 65 20 70 72 65 76 69 6f 75 73 20 72 65   the previous re
0df0: 63 6f 72 64 20 66 6f 72 20 77 68 65 6e 20 74 68  cord for when th
0e00: 69 73 20 74 65 73 74 20 77 61 73 20 72 75 6e 20  is test was run 
0e10: 77 68 65 72 65 20 61 6c 6c 20 6b 65 79 73 20 6d  where all keys m
0e20: 61 74 63 68 20 62 75 74 20 72 75 6e 6e 61 6d 65  atch but runname
0e30: 0a 3b 3b 20 72 65 74 75 72 6e 73 20 23 66 20 69  .;; returns #f i
0e40: 66 20 6e 6f 20 73 75 63 68 20 74 65 73 74 20 66  f no such test f
0e50: 6f 75 6e 64 2c 20 72 65 74 75 72 6e 73 20 61 20  ound, returns a 
0e60: 73 69 6e 67 6c 65 20 74 65 73 74 20 72 65 63 6f  single test reco
0e70: 72 64 20 69 66 20 66 6f 75 6e 64 0a 28 64 65 66  rd if found.(def
0e80: 69 6e 65 20 28 74 65 73 74 3a 67 65 74 2d 70 72  ine (test:get-pr
0e90: 65 76 69 6f 75 73 2d 74 65 73 74 2d 72 75 6e 2d  evious-test-run-
0ea0: 72 65 63 6f 72 64 20 64 62 20 72 75 6e 2d 69 64  record db run-id
0eb0: 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d   test-name item-
0ec0: 70 61 74 68 29 0a 20 20 28 6c 65 74 2a 20 28 28  path).  (let* ((
0ed0: 6b 65 79 73 20 20 20 20 28 64 62 3a 67 65 74 2d  keys    (db:get-
0ee0: 6b 65 79 73 20 64 62 29 29 0a 09 20 28 73 65 6c  keys db)).. (sel
0ef0: 73 74 72 20 20 28 73 74 72 69 6e 67 2d 69 6e 74  str  (string-int
0f00: 65 72 73 70 65 72 73 65 20 28 6d 61 70 20 28 6c  ersperse (map (l
0f10: 61 6d 62 64 61 20 28 78 29 28 76 65 63 74 6f 72  ambda (x)(vector
0f20: 2d 72 65 66 20 78 20 30 29 29 20 6b 65 79 73 29  -ref x 0)) keys)
0f30: 20 22 2c 22 29 29 0a 09 20 28 71 72 79 73 74 72   ",")).. (qrystr
0f40: 20 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73    (string-inters
0f50: 70 65 72 73 65 20 28 6d 61 70 20 28 6c 61 6d 62  perse (map (lamb
0f60: 64 61 20 28 78 29 28 63 6f 6e 63 20 28 76 65 63  da (x)(conc (vec
0f70: 74 6f 72 2d 72 65 66 20 78 20 30 29 20 22 3d 3f  tor-ref x 0) "=?
0f80: 22 29 29 20 6b 65 79 73 29 20 22 20 41 4e 44 20  ")) keys) " AND 
0f90: 22 29 29 0a 09 20 28 6b 65 79 76 61 6c 73 20 23  ")).. (keyvals #
0fa0: 66 29 29 0a 20 20 20 20 3b 3b 20 66 69 72 73 74  f)).    ;; first
0fb0: 20 6c 6f 6f 6b 20 75 70 20 74 68 65 20 6b 65 79   look up the key
0fc0: 20 76 61 6c 75 65 73 20 66 72 6f 6d 20 74 68 65   values from the
0fd0: 20 72 75 6e 20 73 65 6c 65 63 74 65 64 20 62 79   run selected by
0fe0: 20 72 75 6e 2d 69 64 0a 20 20 20 20 28 73 71 6c   run-id.    (sql
0ff0: 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f  ite3:for-each-ro
1000: 77 20 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20  w .     (lambda 
1010: 28 61 20 2e 20 62 29 0a 20 20 20 20 20 20 20 28  (a . b).       (
1020: 73 65 74 21 20 6b 65 79 76 61 6c 73 20 28 63 6f  set! keyvals (co
1030: 6e 73 20 61 20 62 29 29 29 0a 20 20 20 20 20 64  ns a b))).     d
1040: 62 0a 20 20 20 20 20 28 63 6f 6e 63 20 22 53 45  b.     (conc "SE
1050: 4c 45 43 54 20 22 20 73 65 6c 73 74 72 20 22 20  LECT " selstr " 
1060: 46 52 4f 4d 20 72 75 6e 73 20 57 48 45 52 45 20  FROM runs WHERE 
1070: 69 64 3d 3f 20 4f 52 44 45 52 20 42 59 20 65 76  id=? ORDER BY ev
1080: 65 6e 74 5f 74 69 6d 65 20 44 45 53 43 3b 22 29  ent_time DESC;")
1090: 20 72 75 6e 2d 69 64 29 0a 20 20 20 20 28 69 66   run-id).    (if
10a0: 20 28 6e 6f 74 20 6b 65 79 76 61 6c 73 29 0a 09   (not keyvals)..
10b0: 23 66 0a 09 28 6c 65 74 20 28 28 70 72 65 76 2d  #f..(let ((prev-
10c0: 72 75 6e 2d 69 64 73 20 27 28 29 29 29 0a 09 20  run-ids '())).. 
10d0: 20 28 61 70 70 6c 79 20 73 71 6c 69 74 65 33 3a   (apply sqlite3:
10e0: 66 6f 72 2d 65 61 63 68 2d 72 6f 77 0a 09 09 20  for-each-row... 
10f0: 28 6c 61 6d 62 64 61 20 28 69 64 29 0a 09 09 20  (lambda (id)... 
1100: 20 20 28 73 65 74 21 20 70 72 65 76 2d 72 75 6e    (set! prev-run
1110: 2d 69 64 73 20 28 63 6f 6e 73 20 69 64 20 70 72  -ids (cons id pr
1120: 65 76 2d 72 75 6e 2d 69 64 73 29 29 29 0a 09 09  ev-run-ids)))...
1130: 20 64 62 0a 09 09 20 28 63 6f 6e 63 20 22 53 45   db... (conc "SE
1140: 4c 45 43 54 20 69 64 20 46 52 4f 4d 20 72 75 6e  LECT id FROM run
1150: 73 20 57 48 45 52 45 20 22 20 71 72 79 73 74 72  s WHERE " qrystr
1160: 20 22 20 41 4e 44 20 69 64 20 21 3d 20 3f 3b 22   " AND id != ?;"
1170: 29 20 28 61 70 70 65 6e 64 20 6b 65 79 76 61 6c  ) (append keyval
1180: 73 20 28 6c 69 73 74 20 72 75 6e 2d 69 64 29 29  s (list run-id))
1190: 29 0a 09 20 20 3b 3b 20 66 6f 72 20 65 61 63 68  )..  ;; for each
11a0: 20 72 75 6e 20 73 74 61 72 74 69 6e 67 20 77 69   run starting wi
11b0: 74 68 20 74 68 65 20 6d 6f 73 74 20 72 65 63 65  th the most rece
11c0: 6e 74 20 6c 6f 6f 6b 20 74 6f 20 73 65 65 20 69  nt look to see i
11d0: 66 20 74 68 65 72 65 20 69 73 20 61 20 6d 61 74  f there is a mat
11e0: 63 68 69 6e 67 20 74 65 73 74 0a 09 20 20 3b 3b  ching test..  ;;
11f0: 20 69 66 20 66 6f 75 6e 64 20 74 68 65 6e 20 72   if found then r
1200: 65 74 75 72 6e 20 74 68 61 74 20 6d 61 74 63 68  eturn that match
1210: 69 6e 67 20 74 65 73 74 20 72 65 63 6f 72 64 0a  ing test record.
1220: 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20  .  (debug:print 
1230: 34 20 22 73 65 6c 73 74 72 3a 20 22 20 73 65 6c  4 "selstr: " sel
1240: 73 74 72 20 22 2c 20 71 72 79 73 74 72 3a 20 22  str ", qrystr: "
1250: 20 71 72 79 73 74 72 20 22 2c 20 6b 65 79 76 61   qrystr ", keyva
1260: 6c 73 3a 20 22 20 6b 65 79 76 61 6c 73 20 22 2c  ls: " keyvals ",
1270: 20 70 72 65 76 69 6f 75 73 20 72 75 6e 20 69 64   previous run id
1280: 73 20 66 6f 75 6e 64 3a 20 22 20 70 72 65 76 2d  s found: " prev-
1290: 72 75 6e 2d 69 64 73 29 0a 09 20 20 28 69 66 20  run-ids)..  (if 
12a0: 28 6e 75 6c 6c 3f 20 70 72 65 76 2d 72 75 6e 2d  (null? prev-run-
12b0: 69 64 73 29 20 23 66 0a 09 20 20 20 20 20 20 28  ids) #f..      (
12c0: 6c 65 74 20 6c 6f 6f 70 20 28 28 68 65 64 20 28  let loop ((hed (
12d0: 63 61 72 20 70 72 65 76 2d 72 75 6e 2d 69 64 73  car prev-run-ids
12e0: 29 29 0a 09 09 09 20 28 74 61 6c 20 28 63 64 72  )).... (tal (cdr
12f0: 20 70 72 65 76 2d 72 75 6e 2d 69 64 73 29 29 29   prev-run-ids)))
1300: 0a 09 09 28 6c 65 74 20 28 28 72 65 73 75 6c 74  ...(let ((result
1310: 73 20 28 64 62 2d 67 65 74 2d 74 65 73 74 73 2d  s (db-get-tests-
1320: 66 6f 72 2d 72 75 6e 20 64 62 20 68 65 64 20 74  for-run db hed t
1330: 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61  est-name item-pa
1340: 74 68 29 29 29 0a 09 09 20 20 28 64 65 62 75 67  th)))...  (debug
1350: 3a 70 72 69 6e 74 20 34 20 22 47 6f 74 20 74 65  :print 4 "Got te
1360: 73 74 73 20 66 6f 72 20 72 75 6e 2d 69 64 20 22  sts for run-id "
1370: 20 72 75 6e 2d 69 64 20 22 2c 20 74 65 73 74 2d   run-id ", test-
1380: 6e 61 6d 65 20 22 20 74 65 73 74 2d 6e 61 6d 65  name " test-name
1390: 20 22 2c 20 69 74 65 6d 2d 70 61 74 68 20 22 20   ", item-path " 
13a0: 69 74 65 6d 2d 70 61 74 68 20 22 3a 20 22 20 72  item-path ": " r
13b0: 65 73 75 6c 74 73 29 0a 09 09 20 20 28 69 66 20  esults)...  (if 
13c0: 28 61 6e 64 20 28 6e 75 6c 6c 3f 20 72 65 73 75  (and (null? resu
13d0: 6c 74 73 29 0a 09 09 09 20 20 20 28 6e 6f 74 20  lts)....   (not 
13e0: 28 6e 75 6c 6c 3f 20 74 61 6c 29 29 29 0a 09 09  (null? tal)))...
13f0: 20 20 20 20 20 20 28 6c 6f 6f 70 20 28 63 61 72        (loop (car
1400: 20 74 61 6c 29 28 63 64 72 20 74 61 6c 29 29 0a   tal)(cdr tal)).
1410: 09 09 20 20 20 20 20 20 28 63 61 72 20 72 65 73  ..      (car res
1420: 75 6c 74 73 29 29 29 29 29 29 29 29 29 0a 20 20  ults))))))))).  
1430: 20 20 0a 3b 3b 20 67 65 74 20 74 68 65 20 70 72    .;; get the pr
1440: 65 76 69 6f 75 73 20 72 65 63 6f 72 64 73 20 66  evious records f
1450: 6f 72 20 77 68 65 6e 20 74 68 65 73 65 20 74 65  or when these te
1460: 73 74 73 20 77 65 72 65 20 72 75 6e 20 77 68 65  sts were run whe
1470: 72 65 20 61 6c 6c 20 6b 65 79 73 20 6d 61 74 63  re all keys matc
1480: 68 20 62 75 74 20 72 75 6e 6e 61 6d 65 0a 3b 3b  h but runname.;;
1490: 20 4e 42 2f 2f 20 4d 65 72 67 65 20 74 68 69 73   NB// Merge this
14a0: 20 77 69 74 68 20 74 65 73 74 3a 67 65 74 2d 70   with test:get-p
14b0: 72 65 76 69 6f 75 73 2d 74 65 73 74 2d 72 75 6e  revious-test-run
14c0: 2d 72 65 63 6f 72 64 73 3f 20 54 68 69 73 20 6f  -records? This o
14d0: 6e 65 20 6c 6f 6f 6b 73 20 66 6f 72 20 61 6c 6c  ne looks for all
14e0: 20 6d 61 74 63 68 69 6e 67 20 74 65 73 74 73 0a   matching tests.
14f0: 3b 3b 20 63 61 6e 20 75 73 65 20 77 69 6c 64 63  ;; can use wildc
1500: 61 72 64 73 2e 20 0a 28 64 65 66 69 6e 65 20 28  ards. .(define (
1510: 74 65 73 74 3a 67 65 74 2d 6d 61 74 63 68 69 6e  test:get-matchin
1520: 67 2d 70 72 65 76 69 6f 75 73 2d 74 65 73 74 2d  g-previous-test-
1530: 72 75 6e 2d 72 65 63 6f 72 64 73 20 64 62 20 72  run-records db r
1540: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
1550: 69 74 65 6d 2d 70 61 74 68 29 0a 20 20 28 6c 65  item-path).  (le
1560: 74 2a 20 28 28 6b 65 79 73 20 20 20 20 28 64 62  t* ((keys    (db
1570: 3a 67 65 74 2d 6b 65 79 73 20 64 62 29 29 0a 09  :get-keys db))..
1580: 20 28 73 65 6c 73 74 72 20 20 28 73 74 72 69 6e   (selstr  (strin
1590: 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 28 6d  g-intersperse (m
15a0: 61 70 20 28 6c 61 6d 62 64 61 20 28 78 29 28 76  ap (lambda (x)(v
15b0: 65 63 74 6f 72 2d 72 65 66 20 78 20 30 29 29 20  ector-ref x 0)) 
15c0: 6b 65 79 73 29 20 22 2c 22 29 29 0a 09 20 28 71  keys) ",")).. (q
15d0: 72 79 73 74 72 20 20 28 73 74 72 69 6e 67 2d 69  rystr  (string-i
15e0: 6e 74 65 72 73 70 65 72 73 65 20 28 6d 61 70 20  ntersperse (map 
15f0: 28 6c 61 6d 62 64 61 20 28 78 29 28 63 6f 6e 63  (lambda (x)(conc
1600: 20 28 76 65 63 74 6f 72 2d 72 65 66 20 78 20 30   (vector-ref x 0
1610: 29 20 22 3d 3f 22 29 29 20 6b 65 79 73 29 20 22  ) "=?")) keys) "
1620: 20 41 4e 44 20 22 29 29 0a 09 20 28 6b 65 79 76   AND ")).. (keyv
1630: 61 6c 73 20 23 66 29 0a 09 20 28 74 65 73 74 73  als #f).. (tests
1640: 2d 68 61 73 68 20 28 6d 61 6b 65 2d 68 61 73 68  -hash (make-hash
1650: 2d 74 61 62 6c 65 29 29 29 0a 20 20 20 20 3b 3b  -table))).    ;;
1660: 20 66 69 72 73 74 20 6c 6f 6f 6b 20 75 70 20 74   first look up t
1670: 68 65 20 6b 65 79 20 76 61 6c 75 65 73 20 66 72  he key values fr
1680: 6f 6d 20 74 68 65 20 72 75 6e 20 73 65 6c 65 63  om the run selec
1690: 74 65 64 20 62 79 20 72 75 6e 2d 69 64 0a 20 20  ted by run-id.  
16a0: 20 20 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65    (sqlite3:for-e
16b0: 61 63 68 2d 72 6f 77 20 0a 20 20 20 20 20 28 6c  ach-row .     (l
16c0: 61 6d 62 64 61 20 28 61 20 2e 20 62 29 0a 20 20  ambda (a . b).  
16d0: 20 20 20 20 20 28 73 65 74 21 20 6b 65 79 76 61       (set! keyva
16e0: 6c 73 20 28 63 6f 6e 73 20 61 20 62 29 29 29 0a  ls (cons a b))).
16f0: 20 20 20 20 20 64 62 0a 20 20 20 20 20 28 63 6f       db.     (co
1700: 6e 63 20 22 53 45 4c 45 43 54 20 22 20 73 65 6c  nc "SELECT " sel
1710: 73 74 72 20 22 20 46 52 4f 4d 20 72 75 6e 73 20  str " FROM runs 
1720: 57 48 45 52 45 20 69 64 3d 3f 20 4f 52 44 45 52  WHERE id=? ORDER
1730: 20 42 59 20 65 76 65 6e 74 5f 74 69 6d 65 20 44   BY event_time D
1740: 45 53 43 3b 22 29 20 72 75 6e 2d 69 64 29 0a 20  ESC;") run-id). 
1750: 20 20 20 28 69 66 20 28 6e 6f 74 20 6b 65 79 76     (if (not keyv
1760: 61 6c 73 29 0a 09 27 28 29 0a 09 28 6c 65 74 20  als)..'()..(let 
1770: 28 28 70 72 65 76 2d 72 75 6e 2d 69 64 73 20 27  ((prev-run-ids '
1780: 28 29 29 29 0a 09 20 20 28 61 70 70 6c 79 20 73  ()))..  (apply s
1790: 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d  qlite3:for-each-
17a0: 72 6f 77 0a 09 09 20 28 6c 61 6d 62 64 61 20 28  row... (lambda (
17b0: 69 64 29 0a 09 09 20 20 20 28 73 65 74 21 20 70  id)...   (set! p
17c0: 72 65 76 2d 72 75 6e 2d 69 64 73 20 28 63 6f 6e  rev-run-ids (con
17d0: 73 20 69 64 20 70 72 65 76 2d 72 75 6e 2d 69 64  s id prev-run-id
17e0: 73 29 29 29 0a 09 09 20 64 62 0a 09 09 20 28 63  s)))... db... (c
17f0: 6f 6e 63 20 22 53 45 4c 45 43 54 20 69 64 20 46  onc "SELECT id F
1800: 52 4f 4d 20 72 75 6e 73 20 57 48 45 52 45 20 22  ROM runs WHERE "
1810: 20 71 72 79 73 74 72 20 22 20 41 4e 44 20 69 64   qrystr " AND id
1820: 20 21 3d 20 3f 3b 22 29 20 28 61 70 70 65 6e 64   != ?;") (append
1830: 20 6b 65 79 76 61 6c 73 20 28 6c 69 73 74 20 72   keyvals (list r
1840: 75 6e 2d 69 64 29 29 29 0a 09 20 20 3b 3b 20 63  un-id)))..  ;; c
1850: 6f 6c 6c 65 63 74 20 61 6c 6c 20 6d 61 74 63 68  ollect all match
1860: 69 6e 67 20 74 65 73 74 73 20 66 6f 72 20 74 68  ing tests for th
1870: 65 20 72 75 6e 73 20 74 68 65 6e 0a 09 20 20 3b  e runs then..  ;
1880: 3b 20 65 78 74 72 61 63 74 20 74 68 65 20 6d 6f  ; extract the mo
1890: 73 74 20 72 65 63 65 6e 74 20 74 65 73 74 20 61  st recent test a
18a0: 6e 64 20 72 65 74 75 72 6e 20 74 68 61 74 2e 0a  nd return that..
18b0: 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20  .  (debug:print 
18c0: 34 20 22 73 65 6c 73 74 72 3a 20 22 20 73 65 6c  4 "selstr: " sel
18d0: 73 74 72 20 22 2c 20 71 72 79 73 74 72 3a 20 22  str ", qrystr: "
18e0: 20 71 72 79 73 74 72 20 22 2c 20 6b 65 79 76 61   qrystr ", keyva
18f0: 6c 73 3a 20 22 20 6b 65 79 76 61 6c 73 20 0a 09  ls: " keyvals ..
1900: 09 20 20 20 20 20 20 20 22 2c 20 70 72 65 76 69  .       ", previ
1910: 6f 75 73 20 72 75 6e 20 69 64 73 20 66 6f 75 6e  ous run ids foun
1920: 64 3a 20 22 20 70 72 65 76 2d 72 75 6e 2d 69 64  d: " prev-run-id
1930: 73 29 0a 09 20 20 28 69 66 20 28 6e 75 6c 6c 3f  s)..  (if (null?
1940: 20 70 72 65 76 2d 72 75 6e 2d 69 64 73 29 20 27   prev-run-ids) '
1950: 28 29 20 20 3b 3b 20 6e 6f 20 70 72 65 76 69 6f  ()  ;; no previo
1960: 75 73 20 72 75 6e 73 3f 20 72 65 74 75 72 6e 20  us runs? return 
1970: 6e 75 6c 6c 0a 09 20 20 20 20 20 20 28 6c 65 74  null..      (let
1980: 20 6c 6f 6f 70 20 28 28 68 65 64 20 28 63 61 72   loop ((hed (car
1990: 20 70 72 65 76 2d 72 75 6e 2d 69 64 73 29 29 0a   prev-run-ids)).
19a0: 09 09 09 20 28 74 61 6c 20 28 63 64 72 20 70 72  ... (tal (cdr pr
19b0: 65 76 2d 72 75 6e 2d 69 64 73 29 29 29 0a 09 09  ev-run-ids)))...
19c0: 28 6c 65 74 20 28 28 72 65 73 75 6c 74 73 20 28  (let ((results (
19d0: 64 62 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f 72  db-get-tests-for
19e0: 2d 72 75 6e 20 64 62 20 68 65 64 20 74 65 73 74  -run db hed test
19f0: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  -name item-path)
1a00: 29 29 0a 09 09 20 20 28 64 65 62 75 67 3a 70 72  ))...  (debug:pr
1a10: 69 6e 74 20 34 20 22 47 6f 74 20 74 65 73 74 73  int 4 "Got tests
1a20: 20 66 6f 72 20 72 75 6e 2d 69 64 20 22 20 72 75   for run-id " ru
1a30: 6e 2d 69 64 20 22 2c 20 74 65 73 74 2d 6e 61 6d  n-id ", test-nam
1a40: 65 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 0a 09  e " test-name ..
1a50: 09 09 20 20 20 20 20 20 20 22 2c 20 69 74 65 6d  ..       ", item
1a60: 2d 70 61 74 68 20 22 20 69 74 65 6d 2d 70 61 74  -path " item-pat
1a70: 68 20 22 20 72 65 73 75 6c 74 73 3a 20 22 20 28  h " results: " (
1a80: 69 6e 74 65 72 73 70 65 72 73 65 20 72 65 73 75  intersperse resu
1a90: 6c 74 73 20 22 5c 6e 22 29 29 0a 09 09 20 20 3b  lts "\n"))...  ;
1aa0: 3b 20 4b 65 65 70 20 6f 6e 6c 79 20 74 68 65 20  ; Keep only the 
1ab0: 79 6f 75 6e 67 65 73 74 20 6f 66 20 61 6e 79 20  youngest of any 
1ac0: 74 65 73 74 2f 69 74 65 6d 20 63 6f 6d 62 69 6e  test/item combin
1ad0: 61 74 69 6f 6e 0a 09 09 20 20 28 66 6f 72 2d 65  ation...  (for-e
1ae0: 61 63 68 20 0a 09 09 20 20 20 28 6c 61 6d 62 64  ach ...   (lambd
1af0: 61 20 28 74 65 73 74 64 61 74 29 0a 09 09 20 20  a (testdat)...  
1b00: 20 20 20 28 6c 65 74 2a 20 28 28 66 75 6c 6c 2d     (let* ((full-
1b10: 74 65 73 74 6e 61 6d 65 20 28 63 6f 6e 63 20 28  testname (conc (
1b20: 64 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74  db:test-get-test
1b30: 6e 61 6d 65 20 74 65 73 74 64 61 74 29 20 22 2f  name testdat) "/
1b40: 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69  " (db:test-get-i
1b50: 74 65 6d 2d 70 61 74 68 20 74 65 73 74 64 61 74  tem-path testdat
1b60: 29 29 29 0a 09 09 09 20 20 20 20 28 73 74 6f 72  )))....    (stor
1b70: 65 64 2d 74 65 73 74 20 20 20 28 68 61 73 68 2d  ed-test   (hash-
1b80: 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c  table-ref/defaul
1b90: 74 20 74 65 73 74 73 2d 68 61 73 68 20 66 75 6c  t tests-hash ful
1ba0: 6c 2d 74 65 73 74 6e 61 6d 65 20 23 66 29 29 29  l-testname #f)))
1bb0: 0a 09 09 20 20 20 20 20 20 20 28 69 66 20 28 6f  ...       (if (o
1bc0: 72 20 28 6e 6f 74 20 73 74 6f 72 65 64 2d 74 65  r (not stored-te
1bd0: 73 74 29 0a 09 09 09 20 20 20 20 20 20 20 28 61  st)....       (a
1be0: 6e 64 20 73 74 6f 72 65 64 2d 74 65 73 74 0a 09  nd stored-test..
1bf0: 09 09 09 20 20 20 20 28 3e 20 28 64 62 3a 74 65  ...    (> (db:te
1c00: 73 74 2d 67 65 74 2d 65 76 65 6e 74 5f 74 69 6d  st-get-event_tim
1c10: 65 20 74 65 73 74 64 61 74 29 28 64 62 3a 74 65  e testdat)(db:te
1c20: 73 74 2d 67 65 74 2d 65 76 65 6e 74 5f 74 69 6d  st-get-event_tim
1c30: 65 20 73 74 6f 72 65 64 2d 74 65 73 74 29 29 29  e stored-test)))
1c40: 29 0a 09 09 09 20 20 20 3b 3b 20 74 68 69 73 20  )....   ;; this 
1c50: 74 65 73 74 20 69 73 20 79 6f 75 6e 67 65 72 2c  test is younger,
1c60: 20 73 74 6f 72 65 20 69 74 20 69 6e 20 74 68 65   store it in the
1c70: 20 68 61 73 68 0a 09 09 09 20 20 20 28 68 61 73   hash....   (has
1c80: 68 2d 74 61 62 6c 65 2d 73 65 74 21 20 74 65 73  h-table-set! tes
1c90: 74 73 2d 68 61 73 68 20 66 75 6c 6c 2d 74 65 73  ts-hash full-tes
1ca0: 74 6e 61 6d 65 20 74 65 73 74 64 61 74 29 29 29  tname testdat)))
1cb0: 29 0a 09 09 20 20 20 72 65 73 75 6c 74 73 29 0a  )...   results).
1cc0: 09 09 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 74  ..  (if (null? t
1cd0: 61 6c 29 0a 09 09 20 20 20 20 20 20 28 6d 61 70  al)...      (map
1ce0: 20 63 64 72 20 28 68 61 73 68 2d 74 61 62 6c 65   cdr (hash-table
1cf0: 2d 3e 61 6c 69 73 74 20 74 65 73 74 73 2d 68 61  ->alist tests-ha
1d00: 73 68 29 29 20 3b 3b 20 72 65 74 75 72 6e 20 61  sh)) ;; return a
1d10: 20 6c 69 73 74 20 6f 66 20 74 68 65 20 6d 6f 73   list of the mos
1d20: 74 20 72 65 63 65 6e 74 20 74 65 73 74 73 0a 09  t recent tests..
1d30: 09 20 20 20 20 20 20 28 6c 6f 6f 70 20 28 63 61  .      (loop (ca
1d40: 72 20 74 61 6c 29 28 63 64 72 20 74 61 6c 29 29  r tal)(cdr tal))
1d50: 29 29 29 29 29 29 29 29 0a 0a 28 64 65 66 69 6e  ))))))))..(defin
1d60: 65 20 28 74 65 73 74 2d 73 65 74 2d 73 74 61 74  e (test-set-stat
1d70: 75 73 21 20 64 62 20 72 75 6e 2d 69 64 20 74 65  us! db run-id te
1d80: 73 74 2d 6e 61 6d 65 20 73 74 61 74 65 20 73 74  st-name state st
1d90: 61 74 75 73 20 69 74 65 6d 64 61 74 2d 6f 72 2d  atus itemdat-or-
1da0: 70 61 74 68 20 63 6f 6d 6d 65 6e 74 20 64 61 74  path comment dat
1db0: 29 0a 20 20 28 6c 65 74 2a 20 28 28 72 65 61 6c  ).  (let* ((real
1dc0: 2d 73 74 61 74 75 73 20 73 74 61 74 75 73 29 0a  -status status).
1dd0: 09 20 28 69 74 65 6d 2d 70 61 74 68 20 20 20 28  . (item-path   (
1de0: 69 66 20 28 73 74 72 69 6e 67 3f 20 69 74 65 6d  if (string? item
1df0: 64 61 74 2d 6f 72 2d 70 61 74 68 29 20 69 74 65  dat-or-path) ite
1e00: 6d 64 61 74 2d 6f 72 2d 70 61 74 68 20 28 69 74  mdat-or-path (it
1e10: 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69 74  em-list->path it
1e20: 65 6d 64 61 74 2d 6f 72 2d 70 61 74 68 29 29 29  emdat-or-path)))
1e30: 0a 09 20 28 74 65 73 74 64 61 74 20 20 20 20 20  .. (testdat     
1e40: 28 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66  (db:get-test-inf
1e50: 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  o db run-id test
1e60: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  -name item-path)
1e70: 29 0a 09 20 28 74 65 73 74 2d 69 64 20 20 20 20  ).. (test-id    
1e80: 20 28 69 66 20 74 65 73 74 64 61 74 20 28 64 62   (if testdat (db
1e90: 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73  :test-get-id tes
1ea0: 74 64 61 74 29 20 23 66 29 29 0a 09 20 28 6f 74  tdat) #f)).. (ot
1eb0: 68 65 72 64 61 74 20 20 20 20 28 69 66 20 64 61  herdat    (if da
1ec0: 74 20 64 61 74 20 28 6d 61 6b 65 2d 68 61 73 68  t dat (make-hash
1ed0: 2d 74 61 62 6c 65 29 29 29 0a 09 20 3b 3b 20 62  -table))).. ;; b
1ee0: 65 66 6f 72 65 20 70 72 6f 63 65 65 64 69 6e 67  efore proceeding
1ef0: 20 77 65 20 6d 75 73 74 20 66 69 6e 64 20 6f 75   we must find ou
1f00: 74 20 69 66 20 74 68 65 20 70 72 65 76 69 6f 75  t if the previou
1f10: 73 20 74 65 73 74 20 28 77 68 65 72 65 20 61 6c  s test (where al
1f20: 6c 20 6b 65 79 73 20 6d 61 74 63 68 65 64 20 65  l keys matched e
1f30: 78 63 65 70 74 20 72 75 6e 6e 61 6d 65 29 0a 09  xcept runname)..
1f40: 20 3b 3b 20 77 61 73 20 57 41 49 56 45 44 20 69   ;; was WAIVED i
1f50: 66 20 74 68 69 73 20 74 65 73 74 20 69 73 20 46  f this test is F
1f60: 41 49 4c 0a 09 20 28 77 61 69 76 65 64 20 20 20  AIL.. (waived   
1f70: 28 69 66 20 28 65 71 75 61 6c 3f 20 73 74 61 74  (if (equal? stat
1f80: 75 73 20 22 46 41 49 4c 22 29 0a 09 09 20 20 20  us "FAIL")...   
1f90: 20 20 20 20 28 6c 65 74 20 28 28 70 72 65 76 2d      (let ((prev-
1fa0: 74 65 73 74 20 28 74 65 73 74 3a 67 65 74 2d 70  test (test:get-p
1fb0: 72 65 76 69 6f 75 73 2d 74 65 73 74 2d 72 75 6e  revious-test-run
1fc0: 2d 72 65 63 6f 72 64 20 64 62 20 72 75 6e 2d 69  -record db run-i
1fd0: 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d  d test-name item
1fe0: 2d 70 61 74 68 29 29 29 0a 09 09 09 20 28 69 66  -path))).... (if
1ff0: 20 70 72 65 76 2d 74 65 73 74 20 3b 3b 20 74 72   prev-test ;; tr
2000: 75 65 20 69 66 20 77 65 20 66 6f 75 6e 64 20 61  ue if we found a
2010: 20 70 72 65 76 69 6f 75 73 20 74 65 73 74 20 69   previous test i
2020: 6e 20 74 68 69 73 20 72 75 6e 20 73 65 72 69 65  n this run serie
2030: 73 0a 09 09 09 20 20 20 20 20 28 6c 65 74 20 28  s....     (let (
2040: 28 70 72 65 76 2d 73 74 61 74 75 73 20 28 64 62  (prev-status (db
2050: 3a 74 65 73 74 2d 67 65 74 2d 73 74 61 74 75 73  :test-get-status
2060: 20 20 20 70 72 65 76 2d 74 65 73 74 29 29 0a 09     prev-test))..
2070: 09 09 09 20 20 20 28 70 72 65 76 2d 73 74 61 74  ...   (prev-stat
2080: 65 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  e  (db:test-get-
2090: 73 74 61 74 65 20 20 20 20 70 72 65 76 2d 74 65  state    prev-te
20a0: 73 74 29 29 0a 09 09 09 09 20 20 20 28 70 72 65  st)).....   (pre
20b0: 76 2d 63 6f 6d 6d 65 6e 74 20 28 64 62 3a 74 65  v-comment (db:te
20c0: 73 74 2d 67 65 74 2d 63 6f 6d 6d 65 6e 74 20 70  st-get-comment p
20d0: 72 65 76 2d 74 65 73 74 29 29 29 0a 09 09 09 20  rev-test))).... 
20e0: 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69        (debug:pri
20f0: 6e 74 20 34 20 22 70 72 65 76 2d 73 74 61 74 75  nt 4 "prev-statu
2100: 73 20 22 20 70 72 65 76 2d 73 74 61 74 75 73 20  s " prev-status 
2110: 22 2c 20 70 72 65 76 2d 73 74 61 74 65 20 22 20  ", prev-state " 
2120: 70 72 65 76 2d 73 74 61 74 65 20 22 2c 20 70 72  prev-state ", pr
2130: 65 76 2d 63 6f 6d 6d 65 6e 74 20 22 20 70 72 65  ev-comment " pre
2140: 76 2d 63 6f 6d 6d 65 6e 74 29 0a 09 09 09 20 20  v-comment)....  
2150: 20 20 20 20 20 28 69 66 20 28 61 6e 64 20 28 65       (if (and (e
2160: 71 75 61 6c 3f 20 70 72 65 76 2d 73 74 61 74 65  qual? prev-state
2170: 20 20 22 43 4f 4d 50 4c 45 54 45 44 22 29 0a 09    "COMPLETED")..
2180: 09 09 09 09 28 65 71 75 61 6c 3f 20 70 72 65 76  ....(equal? prev
2190: 2d 73 74 61 74 75 73 20 22 57 41 49 56 45 44 22  -status "WAIVED"
21a0: 29 29 0a 09 09 09 09 20 20 20 70 72 65 76 2d 63  )).....   prev-c
21b0: 6f 6d 6d 65 6e 74 20 3b 3b 20 77 61 69 76 65 64  omment ;; waived
21c0: 20 69 73 20 65 69 74 68 65 72 20 74 68 65 20 63   is either the c
21d0: 6f 6d 6d 65 6e 74 20 6f 72 20 23 66 0a 09 09 09  omment or #f....
21e0: 09 20 20 20 23 66 29 29 0a 09 09 09 20 20 20 20  .   #f))....    
21f0: 20 23 66 29 29 0a 09 09 20 20 20 20 20 20 20 23   #f))...       #
2200: 66 29 29 29 0a 20 20 20 20 28 69 66 20 77 61 69  f))).    (if wai
2210: 76 65 64 20 28 73 65 74 21 20 72 65 61 6c 2d 73  ved (set! real-s
2220: 74 61 74 75 73 20 22 57 41 49 56 45 44 22 29 29  tatus "WAIVED"))
2230: 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e  .    (debug:prin
2240: 74 20 34 20 22 72 65 61 6c 2d 73 74 61 74 75 73  t 4 "real-status
2250: 20 22 20 72 65 61 6c 2d 73 74 61 74 75 73 20 22   " real-status "
2260: 2c 20 77 61 69 76 65 64 20 22 20 77 61 69 76 65  , waived " waive
2270: 64 20 22 2c 20 73 74 61 74 75 73 20 22 20 73 74  d ", status " st
2280: 61 74 75 73 29 0a 0a 20 20 20 20 3b 3b 20 75 70  atus)..    ;; up
2290: 64 61 74 65 20 74 68 65 20 70 72 69 6d 61 72 79  date the primary
22a0: 20 72 65 63 6f 72 64 20 49 46 20 73 74 61 74 65   record IF state
22b0: 20 41 4e 44 20 73 74 61 74 75 73 20 61 72 65 20   AND status are 
22c0: 64 65 66 69 6e 65 64 0a 20 20 20 20 28 69 66 20  defined.    (if 
22d0: 28 61 6e 64 20 73 74 61 74 65 20 73 74 61 74 75  (and state statu
22e0: 73 29 0a 09 28 73 71 6c 69 74 65 33 3a 65 78 65  s)..(sqlite3:exe
22f0: 63 75 74 65 20 64 62 20 22 55 50 44 41 54 45 20  cute db "UPDATE 
2300: 74 65 73 74 73 20 53 45 54 20 73 74 61 74 65 3d  tests SET state=
2310: 3f 2c 73 74 61 74 75 73 3d 3f 2c 65 76 65 6e 74  ?,status=?,event
2320: 5f 74 69 6d 65 3d 73 74 72 66 74 69 6d 65 28 27  _time=strftime('
2330: 25 73 27 2c 27 6e 6f 77 27 29 20 57 48 45 52 45  %s','now') WHERE
2340: 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65   run_id=? AND te
2350: 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65  stname=? AND ite
2360: 6d 5f 70 61 74 68 3d 3f 3b 22 20 0a 09 09 09 20  m_path=?;" .... 
2370: 73 74 61 74 65 20 72 65 61 6c 2d 73 74 61 74 75  state real-statu
2380: 73 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  s run-id test-na
2390: 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29 0a 0a  me item-path))..
23a0: 20 20 20 20 3b 3b 20 69 66 20 73 74 61 74 75 73      ;; if status
23b0: 20 69 73 20 22 41 55 54 4f 22 20 74 68 65 6e 20   is "AUTO" then 
23c0: 63 61 6c 6c 20 72 6f 6c 6c 75 70 0a 20 20 20 20  call rollup.    
23d0: 28 69 66 20 28 61 6e 64 20 74 65 73 74 2d 69 64  (if (and test-id
23e0: 20 73 74 61 74 65 20 73 74 61 74 75 73 20 28 65   state status (e
23f0: 71 75 61 6c 3f 20 73 74 61 74 75 73 20 22 41 55  qual? status "AU
2400: 54 4f 22 29 29 20 0a 09 28 64 62 3a 74 65 73 74  TO")) ..(db:test
2410: 2d 64 61 74 61 2d 72 6f 6c 6c 75 70 20 64 62 20  -data-rollup db 
2420: 74 65 73 74 2d 69 64 29 29 0a 0a 20 20 20 20 3b  test-id))..    ;
2430: 3b 20 61 64 64 20 6d 65 74 61 64 61 74 61 20 28  ; add metadata (
2440: 6e 65 65 64 20 74 6f 20 64 6f 20 74 68 69 73 20  need to do this 
2450: 77 61 79 20 74 6f 20 61 76 6f 69 64 20 53 51 4c  way to avoid SQL
2460: 20 69 6e 6a 65 63 74 69 6f 6e 20 69 73 73 75 65   injection issue
2470: 73 29 0a 0a 20 20 20 20 3b 3b 20 3a 66 69 72 73  s)..    ;; :firs
2480: 74 5f 65 72 72 0a 20 20 20 20 28 6c 65 74 20 28  t_err.    (let (
2490: 28 76 61 6c 20 28 68 61 73 68 2d 74 61 62 6c 65  (val (hash-table
24a0: 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 6f 74 68  -ref/default oth
24b0: 65 72 64 61 74 20 22 3a 66 69 72 73 74 5f 65 72  erdat ":first_er
24c0: 72 22 20 23 66 29 29 29 0a 20 20 20 20 20 20 28  r" #f))).      (
24d0: 69 66 20 76 61 6c 0a 09 20 20 28 73 71 6c 69 74  if val..  (sqlit
24e0: 65 33 3a 65 78 65 63 75 74 65 20 64 62 20 22 55  e3:execute db "U
24f0: 50 44 41 54 45 20 74 65 73 74 73 20 53 45 54 20  PDATE tests SET 
2500: 66 69 72 73 74 5f 65 72 72 3d 3f 20 57 48 45 52  first_err=? WHER
2510: 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74  E run_id=? AND t
2520: 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74  estname=? AND it
2530: 65 6d 5f 70 61 74 68 3d 3f 3b 22 20 76 61 6c 20  em_path=?;" val 
2540: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
2550: 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 0a 20   item-path))).. 
2560: 20 20 20 3b 3b 20 3a 66 69 72 73 74 5f 77 61 72     ;; :first_war
2570: 6e 0a 20 20 20 20 28 6c 65 74 20 28 28 76 61 6c  n.    (let ((val
2580: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
2590: 2f 64 65 66 61 75 6c 74 20 6f 74 68 65 72 64 61  /default otherda
25a0: 74 20 22 3a 66 69 72 73 74 5f 77 61 72 6e 22 20  t ":first_warn" 
25b0: 23 66 29 29 29 0a 20 20 20 20 20 20 28 69 66 20  #f))).      (if 
25c0: 76 61 6c 0a 09 20 20 28 73 71 6c 69 74 65 33 3a  val..  (sqlite3:
25d0: 65 78 65 63 75 74 65 20 64 62 20 22 55 50 44 41  execute db "UPDA
25e0: 54 45 20 74 65 73 74 73 20 53 45 54 20 66 69 72  TE tests SET fir
25f0: 73 74 5f 77 61 72 6e 3d 3f 20 57 48 45 52 45 20  st_warn=? WHERE 
2600: 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73  run_id=? AND tes
2610: 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d  tname=? AND item
2620: 5f 70 61 74 68 3d 3f 3b 22 20 76 61 6c 20 72 75  _path=?;" val ru
2630: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69  n-id test-name i
2640: 74 65 6d 2d 70 61 74 68 29 29 29 0a 0a 20 20 20  tem-path)))..   
2650: 20 28 6c 65 74 20 28 28 63 61 74 65 67 6f 72 79   (let ((category
2660: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
2670: 2f 64 65 66 61 75 6c 74 20 6f 74 68 65 72 64 61  /default otherda
2680: 74 20 22 3a 63 61 74 65 67 6f 72 79 22 20 22 22  t ":category" ""
2690: 29 29 0a 09 20 20 28 76 61 72 69 61 62 6c 65 20  ))..  (variable 
26a0: 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f  (hash-table-ref/
26b0: 64 65 66 61 75 6c 74 20 6f 74 68 65 72 64 61 74  default otherdat
26c0: 20 22 3a 76 61 72 69 61 62 6c 65 22 20 22 22 29   ":variable" "")
26d0: 29 0a 09 20 20 28 76 61 6c 75 65 20 20 20 20 28  )..  (value    (
26e0: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64  hash-table-ref/d
26f0: 65 66 61 75 6c 74 20 6f 74 68 65 72 64 61 74 20  efault otherdat 
2700: 22 3a 76 61 6c 75 65 22 20 20 20 20 23 66 29 29  ":value"    #f))
2710: 0a 09 20 20 28 65 78 70 65 63 74 65 64 20 28 68  ..  (expected (h
2720: 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65  ash-table-ref/de
2730: 66 61 75 6c 74 20 6f 74 68 65 72 64 61 74 20 22  fault otherdat "
2740: 3a 65 78 70 65 63 74 65 64 22 20 23 66 29 29 0a  :expected" #f)).
2750: 09 20 20 28 74 6f 6c 20 20 20 20 20 20 28 68 61  .  (tol      (ha
2760: 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66  sh-table-ref/def
2770: 61 75 6c 74 20 6f 74 68 65 72 64 61 74 20 22 3a  ault otherdat ":
2780: 74 6f 6c 22 20 20 20 20 20 20 23 66 29 29 0a 09  tol"      #f))..
2790: 20 20 28 75 6e 69 74 73 20 20 20 20 28 68 61 73    (units    (has
27a0: 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61  h-table-ref/defa
27b0: 75 6c 74 20 6f 74 68 65 72 64 61 74 20 22 3a 75  ult otherdat ":u
27c0: 6e 69 74 73 22 20 20 20 20 22 22 29 29 0a 09 20  nits"    "")).. 
27d0: 20 28 64 63 6f 6d 6d 65 6e 74 20 28 68 61 73 68   (dcomment (hash
27e0: 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75  -table-ref/defau
27f0: 6c 74 20 6f 74 68 65 72 64 61 74 20 22 3a 63 6f  lt otherdat ":co
2800: 6d 6d 65 6e 74 22 20 20 22 22 29 29 29 0a 20 20  mment"  ""))).  
2810: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
2820: 20 34 20 0a 09 09 20 20 20 22 63 61 74 65 67 6f   4 ...   "catego
2830: 72 79 3a 20 22 20 63 61 74 65 67 6f 72 79 20 22  ry: " category "
2840: 2c 20 76 61 72 69 61 62 6c 65 3a 20 22 20 76 61  , variable: " va
2850: 72 69 61 62 6c 65 20 22 2c 20 76 61 6c 75 65 3a  riable ", value:
2860: 20 22 20 76 61 6c 75 65 0a 09 09 20 20 20 22 2c   " value...   ",
2870: 20 65 78 70 65 63 74 65 64 3a 20 22 20 65 78 70   expected: " exp
2880: 65 63 74 65 64 20 22 2c 20 74 6f 6c 3a 20 22 20  ected ", tol: " 
2890: 74 6f 6c 20 22 2c 20 75 6e 69 74 73 3a 20 22 20  tol ", units: " 
28a0: 75 6e 69 74 73 29 0a 20 20 20 20 20 20 28 69 66  units).      (if
28b0: 20 28 61 6e 64 20 76 61 6c 75 65 20 65 78 70 65   (and value expe
28c0: 63 74 65 64 20 74 6f 6c 29 20 3b 3b 20 61 6c 6c  cted tol) ;; all
28d0: 20 74 68 72 65 65 20 72 65 71 75 69 72 65 64 0a   three required.
28e0: 09 20 20 28 64 62 3a 63 73 76 2d 3e 74 65 73 74  .  (db:csv->test
28f0: 2d 64 61 74 61 20 64 62 20 74 65 73 74 2d 69 64  -data db test-id
2900: 20 0a 09 09 09 20 20 20 20 20 28 63 6f 6e 63 20   ....     (conc 
2910: 63 61 74 65 67 6f 72 79 20 22 2c 22 0a 09 09 09  category ","....
2920: 09 20 20 20 76 61 72 69 61 62 6c 65 20 22 2c 22  .   variable ","
2930: 0a 09 09 09 09 20 20 20 76 61 6c 75 65 20 20 20  .....   value   
2940: 20 22 2c 22 0a 09 09 09 09 20 20 20 65 78 70 65   ",".....   expe
2950: 63 74 65 64 20 22 2c 22 0a 09 09 09 09 20 20 20  cted ",".....   
2960: 74 6f 6c 20 20 20 20 20 20 22 2c 22 0a 09 09 09  tol      ","....
2970: 09 20 20 20 75 6e 69 74 73 20 20 20 20 22 2c 22  .   units    ","
2980: 0a 09 09 09 09 20 20 20 64 63 6f 6d 6d 65 6e 74  .....   dcomment
2990: 20 22 2c 22 29 29 29 29 0a 09 09 09 09 20 20 20   ",")))).....   
29a0: 0a 20 20 20 20 3b 3b 20 6e 65 65 64 20 74 6f 20  .    ;; need to 
29b0: 75 70 64 61 74 65 20 74 68 65 20 74 6f 70 20 74  update the top t
29c0: 65 73 74 20 72 65 63 6f 72 64 20 69 66 20 50 41  est record if PA
29d0: 53 53 20 6f 72 20 46 41 49 4c 20 61 6e 64 20 74  SS or FAIL and t
29e0: 68 69 73 20 69 73 20 61 20 73 75 62 74 65 73 74  his is a subtest
29f0: 0a 20 20 20 20 28 69 66 20 28 61 6e 64 20 28 6e  .    (if (and (n
2a00: 6f 74 20 28 65 71 75 61 6c 3f 20 69 74 65 6d 2d  ot (equal? item-
2a10: 70 61 74 68 20 22 22 29 29 0a 09 20 20 20 20 20  path ""))..     
2a20: 28 6f 72 20 28 65 71 75 61 6c 3f 20 73 74 61 74  (or (equal? stat
2a30: 75 73 20 22 50 41 53 53 22 29 0a 09 09 20 28 65  us "PASS")... (e
2a40: 71 75 61 6c 3f 20 73 74 61 74 75 73 20 22 57 41  qual? status "WA
2a50: 52 4e 22 29 0a 09 09 20 28 65 71 75 61 6c 3f 20  RN")... (equal? 
2a60: 73 74 61 74 75 73 20 22 46 41 49 4c 22 29 0a 09  status "FAIL")..
2a70: 09 20 28 65 71 75 61 6c 3f 20 73 74 61 74 75 73  . (equal? status
2a80: 20 22 57 41 49 56 45 44 22 29 0a 09 09 20 28 65   "WAIVED")... (e
2a90: 71 75 61 6c 3f 20 73 74 61 74 75 73 20 22 52 55  qual? status "RU
2aa0: 4e 4e 49 4e 47 22 29 29 29 0a 09 28 62 65 67 69  NNING")))..(begi
2ab0: 6e 0a 09 20 20 28 73 71 6c 69 74 65 33 3a 65 78  n..  (sqlite3:ex
2ac0: 65 63 75 74 65 20 0a 09 20 20 20 64 62 0a 09 20  ecute ..   db.. 
2ad0: 20 20 22 55 50 44 41 54 45 20 74 65 73 74 73 20    "UPDATE tests 
2ae0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 53 45  .             SE
2af0: 54 20 66 61 69 6c 5f 63 6f 75 6e 74 3d 28 53 45  T fail_count=(SE
2b00: 4c 45 43 54 20 63 6f 75 6e 74 28 69 64 29 20 46  LECT count(id) F
2b10: 52 4f 4d 20 74 65 73 74 73 20 57 48 45 52 45 20  ROM tests WHERE 
2b20: 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73  run_id=? AND tes
2b30: 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d  tname=? AND item
2b40: 5f 70 61 74 68 20 21 3d 20 27 27 20 41 4e 44 20  _path != '' AND 
2b50: 73 74 61 74 75 73 3d 27 46 41 49 4c 27 29 2c 0a  status='FAIL'),.
2b60: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2b70: 20 70 61 73 73 5f 63 6f 75 6e 74 3d 28 53 45 4c   pass_count=(SEL
2b80: 45 43 54 20 63 6f 75 6e 74 28 69 64 29 20 46 52  ECT count(id) FR
2b90: 4f 4d 20 74 65 73 74 73 20 57 48 45 52 45 20 72  OM tests WHERE r
2ba0: 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74  un_id=? AND test
2bb0: 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f  name=? AND item_
2bc0: 70 61 74 68 20 21 3d 20 27 27 20 41 4e 44 20 28  path != '' AND (
2bd0: 73 74 61 74 75 73 3d 27 50 41 53 53 27 20 4f 52  status='PASS' OR
2be0: 20 73 74 61 74 75 73 3d 27 57 41 52 4e 27 20 4f   status='WARN' O
2bf0: 52 20 73 74 61 74 75 73 3d 27 57 41 49 56 45 44  R status='WAIVED
2c00: 27 29 29 0a 20 20 20 20 20 20 20 20 20 20 20 20  ')).            
2c10: 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20   WHERE run_id=? 
2c20: 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41  AND testname=? A
2c30: 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 27 27 3b  ND item_path='';
2c40: 22 0a 09 20 20 20 72 75 6e 2d 69 64 20 74 65 73  "..   run-id tes
2c50: 74 2d 6e 61 6d 65 20 72 75 6e 2d 69 64 20 74 65  t-name run-id te
2c60: 73 74 2d 6e 61 6d 65 20 72 75 6e 2d 69 64 20 74  st-name run-id t
2c70: 65 73 74 2d 6e 61 6d 65 29 0a 09 20 20 28 69 66  est-name)..  (if
2c80: 20 28 65 71 75 61 6c 3f 20 73 74 61 74 75 73 20   (equal? status 
2c90: 22 52 55 4e 4e 49 4e 47 22 29 20 3b 3b 20 72 75  "RUNNING") ;; ru
2ca0: 6e 6e 69 6e 67 20 74 61 6b 65 73 20 70 72 69 6f  nning takes prio
2cb0: 72 69 74 79 20 6f 76 65 72 20 61 6c 6c 20 6f 74  rity over all ot
2cc0: 68 65 72 20 73 74 61 74 65 73 2c 20 66 6f 72 63  her states, forc
2cd0: 65 20 74 68 65 20 74 65 73 74 20 73 74 61 74 65  e the test state
2ce0: 20 74 6f 20 52 55 4e 4e 49 4e 47 0a 09 20 20 20   to RUNNING..   
2cf0: 20 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63     (sqlite3:exec
2d00: 75 74 65 20 64 62 20 22 55 50 44 41 54 45 20 74  ute db "UPDATE t
2d10: 65 73 74 73 20 53 45 54 20 73 74 61 74 65 3d 3f  ests SET state=?
2d20: 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20   WHERE run_id=? 
2d30: 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41  AND testname=? A
2d40: 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 27 27 3b  ND item_path='';
2d50: 22 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  " run-id test-na
2d60: 6d 65 29 0a 09 20 20 20 20 20 20 28 73 71 6c 69  me)..      (sqli
2d70: 74 65 33 3a 65 78 65 63 75 74 65 0a 09 20 20 20  te3:execute..   
2d80: 20 20 20 20 64 62 0a 09 20 20 20 20 20 20 20 22      db..       "
2d90: 55 50 44 41 54 45 20 74 65 73 74 73 0a 20 20 20  UPDATE tests.   
2da0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2db0: 20 20 20 20 53 45 54 20 73 74 61 74 65 3d 43 41      SET state=CA
2dc0: 53 45 20 57 48 45 4e 20 28 53 45 4c 45 43 54 20  SE WHEN (SELECT 
2dd0: 63 6f 75 6e 74 28 69 64 29 20 46 52 4f 4d 20 74  count(id) FROM t
2de0: 65 73 74 73 20 57 48 45 52 45 20 72 75 6e 5f 69  ests WHERE run_i
2df0: 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65  d=? AND testname
2e00: 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68  =? AND item_path
2e10: 20 21 3d 20 27 27 20 41 4e 44 20 73 74 61 74 65   != '' AND state
2e20: 20 69 6e 20 28 27 52 55 4e 4e 49 4e 47 27 2c 27   in ('RUNNING','
2e30: 4e 4f 54 5f 53 54 41 52 54 45 44 27 29 29 20 3e  NOT_STARTED')) >
2e40: 20 30 20 54 48 45 4e 20 0a 20 20 20 20 20 20 20   0 THEN .       
2e50: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2e60: 20 20 20 27 52 55 4e 4e 49 4e 47 27 0a 20 20 20     'RUNNING'.   
2e70: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2e80: 20 20 20 20 45 4c 53 45 20 27 43 4f 4d 50 4c 45      ELSE 'COMPLE
2e90: 54 45 44 27 20 45 4e 44 2c 0a 20 20 20 20 20 20  TED' END,.      
2ea0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2eb0: 20 20 20 20 73 74 61 74 75 73 3d 43 41 53 45 20      status=CASE 
2ec0: 57 48 45 4e 20 66 61 69 6c 5f 63 6f 75 6e 74 20  WHEN fail_count 
2ed0: 3e 20 30 20 54 48 45 4e 20 27 46 41 49 4c 27 20  > 0 THEN 'FAIL' 
2ee0: 57 48 45 4e 20 70 61 73 73 5f 63 6f 75 6e 74 20  WHEN pass_count 
2ef0: 3e 20 30 20 41 4e 44 20 66 61 69 6c 5f 63 6f 75  > 0 AND fail_cou
2f00: 6e 74 3d 30 20 54 48 45 4e 20 27 50 41 53 53 27  nt=0 THEN 'PASS'
2f10: 20 45 4c 53 45 20 27 55 4e 4b 4e 4f 57 4e 27 20   ELSE 'UNKNOWN' 
2f20: 45 4e 44 0a 20 20 20 20 20 20 20 20 20 20 20 20  END.            
2f30: 20 20 20 20 20 20 20 20 20 20 20 57 48 45 52 45             WHERE
2f40: 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65   run_id=? AND te
2f50: 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65  stname=? AND ite
2f60: 6d 5f 70 61 74 68 3d 27 27 3b 22 0a 09 20 20 20  m_path='';"..   
2f70: 20 20 20 20 72 75 6e 2d 69 64 20 74 65 73 74 2d      run-id test-
2f80: 6e 61 6d 65 20 72 75 6e 2d 69 64 20 74 65 73 74  name run-id test
2f90: 2d 6e 61 6d 65 29 29 29 29 0a 20 20 20 20 28 69  -name)))).    (i
2fa0: 66 20 28 6f 72 20 28 61 6e 64 20 28 73 74 72 69  f (or (and (stri
2fb0: 6e 67 3f 20 63 6f 6d 6d 65 6e 74 29 0a 09 09 20  ng? comment)... 
2fc0: 28 73 74 72 69 6e 67 2d 6d 61 74 63 68 20 28 72  (string-match (r
2fd0: 65 67 65 78 70 20 22 5c 5c 53 2b 22 29 20 63 6f  egexp "\\S+") co
2fe0: 6d 6d 65 6e 74 29 29 0a 09 20 20 20 20 77 61 69  mment))..    wai
2ff0: 76 65 64 29 0a 09 28 73 71 6c 69 74 65 33 3a 65  ved)..(sqlite3:e
3000: 78 65 63 75 74 65 20 64 62 20 22 55 50 44 41 54  xecute db "UPDAT
3010: 45 20 74 65 73 74 73 20 53 45 54 20 63 6f 6d 6d  E tests SET comm
3020: 65 6e 74 3d 3f 20 57 48 45 52 45 20 72 75 6e 5f  ent=? WHERE run_
3030: 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d  id=? AND testnam
3040: 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74  e=? AND item_pat
3050: 68 3d 3f 3b 22 0a 09 09 09 20 28 69 66 20 77 61  h=?;".... (if wa
3060: 69 76 65 64 20 77 61 69 76 65 64 20 63 6f 6d 6d  ived waived comm
3070: 65 6e 74 29 20 72 75 6e 2d 69 64 20 74 65 73 74  ent) run-id test
3080: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  -name item-path)
3090: 29 0a 20 20 20 20 29 29 0a 0a 28 64 65 66 69 6e  ).    ))..(defin
30a0: 65 20 28 74 65 73 74 2d 73 65 74 2d 6c 6f 67 21  e (test-set-log!
30b0: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d   db run-id test-
30c0: 6e 61 6d 65 20 69 74 65 6d 64 61 74 20 6c 6f 67  name itemdat log
30d0: 66 29 20 0a 20 20 28 6c 65 74 20 28 28 69 74 65  f) .  (let ((ite
30e0: 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c 69 73  m-path (item-lis
30f0: 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74 29  t->path itemdat)
3100: 29 29 0a 20 20 20 20 28 73 71 6c 69 74 65 33 3a  )).    (sqlite3:
3110: 65 78 65 63 75 74 65 20 64 62 20 22 55 50 44 41  execute db "UPDA
3120: 54 45 20 74 65 73 74 73 20 53 45 54 20 66 69 6e  TE tests SET fin
3130: 61 6c 5f 6c 6f 67 66 3d 3f 20 57 48 45 52 45 20  al_logf=? WHERE 
3140: 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73  run_id=? AND tes
3150: 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d  tname=? AND item
3160: 5f 70 61 74 68 3d 3f 3b 22 20 0a 09 09 20 20 20  _path=?;" ...   
3170: 20 20 6c 6f 67 66 20 72 75 6e 2d 69 64 20 74 65    logf run-id te
3180: 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74  st-name item-pat
3190: 68 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 74  h)))..(define (t
31a0: 65 73 74 2d 73 65 74 2d 74 6f 70 6c 6f 67 21 20  est-set-toplog! 
31b0: 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e  db run-id test-n
31c0: 61 6d 65 20 6c 6f 67 66 29 20 0a 20 20 28 73 71  ame logf) .  (sq
31d0: 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 64 62  lite3:execute db
31e0: 20 22 55 50 44 41 54 45 20 74 65 73 74 73 20 53   "UPDATE tests S
31f0: 45 54 20 66 69 6e 61 6c 5f 6c 6f 67 66 3d 3f 20  ET final_logf=? 
3200: 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41  WHERE run_id=? A
3210: 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e  ND testname=? AN
3220: 44 20 69 74 65 6d 5f 70 61 74 68 3d 27 27 3b 22  D item_path='';"
3230: 20 0a 09 09 20 20 20 6c 6f 67 66 20 72 75 6e 2d   ...   logf run-
3240: 69 64 20 74 65 73 74 2d 6e 61 6d 65 29 29 0a 0a  id test-name))..
3250: 28 64 65 66 69 6e 65 20 28 74 65 73 74 73 3a 73  (define (tests:s
3260: 75 6d 6d 61 72 69 7a 65 2d 69 74 65 6d 73 20 64  ummarize-items d
3270: 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  b run-id test-na
3280: 6d 65 20 66 6f 72 63 65 29 0a 20 20 3b 3b 20 69  me force).  ;; i
3290: 66 20 6e 6f 74 20 66 6f 72 63 65 20 74 68 65 6e  f not force then
32a0: 20 6f 6e 6c 79 20 75 70 64 61 74 65 20 74 68 65   only update the
32b0: 20 72 65 63 6f 72 64 20 69 66 20 6f 6e 65 20 6f   record if one o
32c0: 66 20 74 68 65 73 65 20 69 73 20 74 72 75 65 3a  f these is true:
32d0: 0a 20 20 3b 3b 20 20 20 31 2e 20 6c 6f 67 66 20  .  ;;   1. logf 
32e0: 69 73 20 22 6c 6f 67 2f 66 69 6e 61 6c 2e 6c 6f  is "log/final.lo
32f0: 67 0a 20 20 3b 3b 20 20 20 32 2e 20 6c 6f 67 66  g.  ;;   2. logf
3300: 20 69 73 20 73 61 6d 65 20 61 73 20 6f 75 74 70   is same as outp
3310: 75 74 66 69 6c 65 6e 61 6d 65 0a 20 20 28 6c 65  utfilename.  (le
3320: 74 20 28 28 6f 75 74 70 75 74 66 69 6c 65 6e 61  t ((outputfilena
3330: 6d 65 20 28 63 6f 6e 63 20 22 6d 65 67 61 74 65  me (conc "megate
3340: 73 74 2d 72 6f 6c 6c 75 70 2d 22 20 74 65 73 74  st-rollup-" test
3350: 2d 6e 61 6d 65 20 22 2e 68 74 6d 6c 22 29 29 0a  -name ".html")).
3360: 09 28 6f 72 69 67 2d 64 69 72 20 20 20 20 20 20  .(orig-dir      
3370: 20 28 63 75 72 72 65 6e 74 2d 64 69 72 65 63 74   (current-direct
3380: 6f 72 79 29 29 0a 09 28 6c 6f 67 66 20 20 20 20  ory))..(logf    
3390: 20 20 20 20 20 20 20 23 66 29 29 0a 20 20 20 20         #f)).    
33a0: 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63  (sqlite3:for-eac
33b0: 68 2d 72 6f 77 20 0a 20 20 20 20 20 28 6c 61 6d  h-row .     (lam
33c0: 62 64 61 20 28 70 61 74 68 20 66 69 6e 61 6c 5f  bda (path final_
33d0: 6c 6f 67 66 29 0a 20 20 20 20 20 20 20 28 73 65  logf).       (se
33e0: 74 21 20 6c 6f 67 66 20 66 69 6e 61 6c 5f 6c 6f  t! logf final_lo
33f0: 67 66 29 0a 20 20 20 20 20 20 20 28 69 66 20 28  gf).       (if (
3400: 64 69 72 65 63 74 6f 72 79 3f 20 70 61 74 68 29  directory? path)
3410: 0a 09 20 20 20 28 62 65 67 69 6e 0a 09 20 20 20  ..   (begin..   
3420: 20 20 28 70 72 69 6e 74 20 22 46 6f 75 6e 64 20    (print "Found 
3430: 70 61 74 68 3a 20 22 20 70 61 74 68 29 0a 09 20  path: " path).. 
3440: 20 20 20 20 28 63 68 61 6e 67 65 2d 64 69 72 65      (change-dire
3450: 63 74 6f 72 79 20 70 61 74 68 29 29 0a 09 20 20  ctory path))..  
3460: 20 20 20 3b 3b 20 28 73 65 74 21 20 6f 75 74 70     ;; (set! outp
3470: 75 74 66 69 6c 65 6e 61 6d 65 20 28 63 6f 6e 63  utfilename (conc
3480: 20 70 61 74 68 20 22 2f 22 20 6f 75 74 70 75 74   path "/" output
3490: 66 69 6c 65 6e 61 6d 65 29 29 29 0a 09 20 20 20  filename)))..   
34a0: 28 70 72 69 6e 74 20 22 4e 6f 20 73 75 63 68 20  (print "No such 
34b0: 70 61 74 68 3a 20 22 20 70 61 74 68 29 29 29 0a  path: " path))).
34c0: 20 20 20 20 20 64 62 20 0a 20 20 20 20 20 22 53       db .     "S
34d0: 45 4c 45 43 54 20 72 75 6e 64 69 72 2c 66 69 6e  ELECT rundir,fin
34e0: 61 6c 5f 6c 6f 67 66 20 46 52 4f 4d 20 74 65 73  al_logf FROM tes
34f0: 74 73 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d  ts WHERE run_id=
3500: 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f  ? AND testname=?
3510: 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 27   AND item_path='
3520: 27 3b 22 0a 20 20 20 20 20 72 75 6e 2d 69 64 20  ';".     run-id 
3530: 74 65 73 74 2d 6e 61 6d 65 29 0a 20 20 20 20 28  test-name).    (
3540: 70 72 69 6e 74 20 22 73 75 6d 6d 61 72 69 7a 65  print "summarize
3550: 2d 69 74 65 6d 73 20 77 69 74 68 20 6c 6f 67 66  -items with logf
3560: 20 22 20 6c 6f 67 66 29 0a 20 20 20 20 28 69 66   " logf).    (if
3570: 20 28 6f 72 20 28 65 71 75 61 6c 3f 20 6c 6f 67   (or (equal? log
3580: 66 20 22 6c 6f 67 73 2f 66 69 6e 61 6c 2e 6c 6f  f "logs/final.lo
3590: 67 22 29 0a 09 20 20 20 20 28 65 71 75 61 6c 3f  g")..    (equal?
35a0: 20 6c 6f 67 66 20 6f 75 74 70 75 74 66 69 6c 65   logf outputfile
35b0: 6e 61 6d 65 29 0a 09 20 20 20 20 66 6f 72 63 65  name)..    force
35c0: 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 28 69 66  )..(begin..  (if
35d0: 20 28 6f 62 74 61 69 6e 2d 64 6f 74 2d 6c 6f 63   (obtain-dot-loc
35e0: 6b 20 6f 75 74 70 75 74 66 69 6c 65 6e 61 6d 65  k outputfilename
35f0: 20 31 20 32 30 20 33 30 29 20 3b 3b 20 72 65 74   1 20 30) ;; ret
3600: 72 79 20 65 76 65 72 79 20 73 65 63 6f 6e 64 20  ry every second 
3610: 66 6f 72 20 32 30 20 73 65 63 6f 6e 64 73 2c 20  for 20 seconds, 
3620: 63 61 6c 6c 20 69 74 20 64 65 61 64 20 61 66 74  call it dead aft
3630: 65 72 20 33 30 20 73 65 63 6f 6e 64 73 20 61 6e  er 30 seconds an
3640: 64 20 73 74 65 61 6c 20 74 68 65 20 6c 6f 63 6b  d steal the lock
3650: 0a 09 20 20 20 20 20 20 28 70 72 69 6e 74 20 22  ..      (print "
3660: 4f 62 74 61 69 6e 65 64 20 6c 6f 63 6b 20 66 6f  Obtained lock fo
3670: 72 20 22 20 6f 75 74 70 75 74 66 69 6c 65 6e 61  r " outputfilena
3680: 6d 65 29 0a 09 20 20 20 20 20 20 28 70 72 69 6e  me)..      (prin
3690: 74 20 22 46 61 69 6c 65 64 20 74 6f 20 6f 62 74  t "Failed to obt
36a0: 61 69 6e 20 6c 6f 63 6b 20 66 6f 72 20 22 20 6f  ain lock for " o
36b0: 75 74 70 75 74 66 69 6c 65 6e 61 6d 65 29 29 0a  utputfilename)).
36c0: 09 20 20 28 6c 65 74 20 28 28 6f 75 70 20 20 20  .  (let ((oup   
36d0: 20 28 6f 70 65 6e 2d 6f 75 74 70 75 74 2d 66 69   (open-output-fi
36e0: 6c 65 20 6f 75 74 70 75 74 66 69 6c 65 6e 61 6d  le outputfilenam
36f0: 65 29 29 0a 09 09 28 63 6f 75 6e 74 73 20 28 6d  e))...(counts (m
3700: 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29  ake-hash-table))
3710: 0a 09 09 28 73 74 61 74 65 63 6f 75 6e 74 73 20  ...(statecounts 
3720: 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65  (make-hash-table
3730: 29 29 0a 09 09 28 6f 75 74 74 78 74 20 22 22 29  ))...(outtxt "")
3740: 0a 09 09 28 74 6f 74 20 20 20 20 30 29 29 0a 09  ...(tot    0))..
3750: 20 20 20 20 28 77 69 74 68 2d 6f 75 74 70 75 74      (with-output
3760: 2d 74 6f 2d 70 6f 72 74 0a 09 09 6f 75 70 0a 09  -to-port...oup..
3770: 20 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 29        (lambda ()
3780: 0a 09 09 28 73 65 74 21 20 6f 75 74 74 78 74 20  ...(set! outtxt 
3790: 28 63 6f 6e 63 20 6f 75 74 74 78 74 20 22 3c 68  (conc outtxt "<h
37a0: 74 6d 6c 3e 3c 74 69 74 6c 65 3e 53 75 6d 6d 61  tml><title>Summa
37b0: 72 79 3a 20 22 20 74 65 73 74 2d 6e 61 6d 65 20  ry: " test-name 
37c0: 0a 09 09 09 09 20 20 20 22 3c 2f 74 69 74 6c 65  .....   "</title
37d0: 3e 3c 62 6f 64 79 3e 3c 68 32 3e 53 75 6d 6d 61  ><body><h2>Summa
37e0: 72 79 20 66 6f 72 20 22 20 74 65 73 74 2d 6e 61  ry for " test-na
37f0: 6d 65 20 22 3c 2f 68 32 3e 22 29 29 0a 09 09 28  me "</h2>"))...(
3800: 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68  sqlite3:for-each
3810: 2d 72 6f 77 20 0a 09 09 20 28 6c 61 6d 62 64 61  -row ... (lambda
3820: 20 28 69 64 20 69 74 65 6d 70 61 74 68 20 73 74   (id itempath st
3830: 61 74 65 20 73 74 61 74 75 73 20 72 75 6e 5f 64  ate status run_d
3840: 75 72 61 74 69 6f 6e 20 6c 6f 67 66 20 63 6f 6d  uration logf com
3850: 6d 65 6e 74 29 0a 09 09 20 20 20 28 68 61 73 68  ment)...   (hash
3860: 2d 74 61 62 6c 65 2d 73 65 74 21 20 63 6f 75 6e  -table-set! coun
3870: 74 73 20 73 74 61 74 75 73 20 28 2b 20 31 20 28  ts status (+ 1 (
3880: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64  hash-table-ref/d
3890: 65 66 61 75 6c 74 20 63 6f 75 6e 74 73 20 73 74  efault counts st
38a0: 61 74 75 73 20 30 29 29 29 0a 09 09 20 20 20 28  atus 0)))...   (
38b0: 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74 21 20  hash-table-set! 
38c0: 73 74 61 74 65 63 6f 75 6e 74 73 20 73 74 61 74  statecounts stat
38d0: 65 20 28 2b 20 31 20 28 68 61 73 68 2d 74 61 62  e (+ 1 (hash-tab
38e0: 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 73  le-ref/default s
38f0: 74 61 74 65 63 6f 75 6e 74 73 20 73 74 61 74 65  tatecounts state
3900: 20 30 29 29 29 0a 09 09 20 20 20 28 73 65 74 21   0)))...   (set!
3910: 20 6f 75 74 74 78 74 20 28 63 6f 6e 63 20 6f 75   outtxt (conc ou
3920: 74 74 78 74 20 22 3c 74 72 3e 22 0a 09 09 09 09  ttxt "<tr>".....
3930: 20 20 20 20 20 20 22 3c 74 64 3e 3c 61 20 68 72        "<td><a hr
3940: 65 66 3d 5c 22 22 20 69 74 65 6d 70 61 74 68 20  ef=\"" itempath 
3950: 22 2f 22 20 6c 6f 67 66 20 22 5c 22 3e 20 22 20  "/" logf "\"> " 
3960: 69 74 65 6d 70 61 74 68 20 22 3c 2f 61 3e 3c 2f  itempath "</a></
3970: 74 64 3e 22 20 0a 09 09 09 09 20 20 20 20 20 20  td>" .....      
3980: 22 3c 74 64 3e 22 20 73 74 61 74 65 20 20 20 20  "<td>" state    
3990: 22 3c 2f 74 64 3e 22 20 0a 09 09 09 09 20 20 20  "</td>" .....   
39a0: 20 20 20 22 3c 74 64 3e 3c 66 6f 6e 74 20 63 6f     "<td><font co
39b0: 6c 6f 72 3d 22 20 28 63 6f 6d 6d 6f 6e 3a 67 65  lor=" (common:ge
39c0: 74 2d 63 6f 6c 6f 72 2d 66 72 6f 6d 2d 73 74 61  t-color-from-sta
39d0: 74 75 73 20 73 74 61 74 75 73 29 0a 09 09 09 09  tus status).....
39e0: 20 20 20 20 20 20 22 3e 22 20 20 20 73 74 61 74        ">"   stat
39f0: 75 73 20 20 20 22 3c 2f 66 6f 6e 74 3e 3c 2f 74  us   "</font></t
3a00: 64 3e 22 0a 09 09 09 09 20 20 20 20 20 20 22 3c  d>".....      "<
3a10: 74 64 3e 22 20 28 69 66 20 28 65 71 75 61 6c 3f  td>" (if (equal?
3a20: 20 63 6f 6d 6d 65 6e 74 20 22 22 29 0a 09 09 09   comment "")....
3a30: 09 09 09 20 22 26 6e 62 73 70 3b 22 0a 09 09 09  ... "&nbsp;"....
3a40: 09 09 09 20 63 6f 6d 6d 65 6e 74 29 20 22 3c 2f  ... comment) "</
3a50: 74 64 3e 22 0a 09 09 09 09 09 09 20 22 3c 2f 74  td>"....... "</t
3a60: 72 3e 22 29 29 29 0a 09 09 20 64 62 0a 09 09 20  r>")))... db... 
3a70: 22 53 45 4c 45 43 54 20 69 64 2c 69 74 65 6d 5f  "SELECT id,item_
3a80: 70 61 74 68 2c 73 74 61 74 65 2c 73 74 61 74 75  path,state,statu
3a90: 73 2c 72 75 6e 5f 64 75 72 61 74 69 6f 6e 2c 66  s,run_duration,f
3aa0: 69 6e 61 6c 5f 6c 6f 67 66 2c 63 6f 6d 6d 65 6e  inal_logf,commen
3ab0: 74 20 46 52 4f 4d 20 74 65 73 74 73 20 57 48 45  t FROM tests WHE
3ac0: 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20  RE run_id=? AND 
3ad0: 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69  testname=? AND i
3ae0: 74 65 6d 5f 70 61 74 68 20 21 3d 20 27 27 3b 22  tem_path != '';"
3af0: 0a 09 09 20 72 75 6e 2d 69 64 20 74 65 73 74 2d  ... run-id test-
3b00: 6e 61 6d 65 29 0a 0a 09 09 28 70 72 69 6e 74 20  name)....(print 
3b10: 22 3c 74 61 62 6c 65 3e 3c 74 72 3e 3c 74 64 20  "<table><tr><td 
3b20: 76 61 6c 69 67 6e 3d 5c 22 74 6f 70 5c 22 3e 22  valign=\"top\">"
3b30: 29 0a 09 09 3b 3b 20 50 72 69 6e 74 20 6f 75 74  )...;; Print out
3b40: 20 73 74 61 74 73 20 66 6f 72 20 73 74 61 74 75   stats for statu
3b50: 73 0a 09 09 28 73 65 74 21 20 74 6f 74 20 30 29  s...(set! tot 0)
3b60: 0a 09 09 28 70 72 69 6e 74 20 22 3c 74 61 62 6c  ...(print "<tabl
3b70: 65 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d 5c 22  e cellspacing=\"
3b80: 30 5c 22 20 62 6f 72 64 65 72 3d 5c 22 31 5c 22  0\" border=\"1\"
3b90: 3e 3c 74 72 3e 3c 74 64 20 63 6f 6c 73 70 61 6e  ><tr><td colspan
3ba0: 3d 5c 22 32 5c 22 3e 3c 68 32 3e 53 74 61 74 65  =\"2\"><h2>State
3bb0: 20 73 74 61 74 73 3c 2f 68 32 3e 3c 2f 74 64 3e   stats</h2></td>
3bc0: 3c 2f 74 72 3e 22 29 0a 09 09 28 66 6f 72 2d 65  </tr>")...(for-e
3bd0: 61 63 68 20 28 6c 61 6d 62 64 61 20 28 73 74 61  ach (lambda (sta
3be0: 74 65 29 0a 09 09 09 20 20 20 20 28 73 65 74 21  te)....    (set!
3bf0: 20 74 6f 74 20 28 2b 20 74 6f 74 20 28 68 61 73   tot (+ tot (has
3c00: 68 2d 74 61 62 6c 65 2d 72 65 66 20 73 74 61 74  h-table-ref stat
3c10: 65 63 6f 75 6e 74 73 20 73 74 61 74 65 29 29 29  ecounts state)))
3c20: 0a 09 09 09 20 20 20 20 28 70 72 69 6e 74 20 22  ....    (print "
3c30: 3c 74 72 3e 3c 74 64 3e 22 20 73 74 61 74 65 20  <tr><td>" state 
3c40: 22 3c 2f 74 64 3e 3c 74 64 3e 22 20 28 68 61 73  "</td><td>" (has
3c50: 68 2d 74 61 62 6c 65 2d 72 65 66 20 73 74 61 74  h-table-ref stat
3c60: 65 63 6f 75 6e 74 73 20 73 74 61 74 65 29 20 22  ecounts state) "
3c70: 3c 2f 74 64 3e 3c 2f 74 72 3e 22 29 29 0a 09 09  </td></tr>"))...
3c80: 09 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 6b  .  (hash-table-k
3c90: 65 79 73 20 73 74 61 74 65 63 6f 75 6e 74 73 29  eys statecounts)
3ca0: 29 0a 09 09 28 70 72 69 6e 74 20 22 3c 74 72 3e  )...(print "<tr>
3cb0: 3c 74 64 3e 54 6f 74 61 6c 3c 2f 74 64 3e 3c 74  <td>Total</td><t
3cc0: 64 3e 22 20 74 6f 74 20 22 3c 2f 74 64 3e 3c 2f  d>" tot "</td></
3cd0: 74 72 3e 3c 2f 74 61 62 6c 65 3e 22 29 0a 09 09  tr></table>")...
3ce0: 28 70 72 69 6e 74 20 22 3c 2f 74 64 3e 3c 74 64  (print "</td><td
3cf0: 20 76 61 6c 69 67 6e 3d 5c 22 74 6f 70 5c 22 3e   valign=\"top\">
3d00: 22 29 0a 09 09 3b 3b 20 50 72 69 6e 74 20 6f 75  ")...;; Print ou
3d10: 74 20 73 74 61 74 73 20 66 6f 72 20 73 74 61 74  t stats for stat
3d20: 65 0a 09 09 28 73 65 74 21 20 74 6f 74 20 30 29  e...(set! tot 0)
3d30: 0a 09 09 28 70 72 69 6e 74 20 22 3c 74 61 62 6c  ...(print "<tabl
3d40: 65 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d 5c 22  e cellspacing=\"
3d50: 30 5c 22 20 62 6f 72 64 65 72 3d 5c 22 31 5c 22  0\" border=\"1\"
3d60: 3e 3c 74 72 3e 3c 74 64 20 63 6f 6c 73 70 61 6e  ><tr><td colspan
3d70: 3d 5c 22 32 5c 22 3e 3c 68 32 3e 53 74 61 74 75  =\"2\"><h2>Statu
3d80: 73 20 73 74 61 74 73 3c 2f 68 32 3e 3c 2f 74 64  s stats</h2></td
3d90: 3e 3c 2f 74 72 3e 22 29 0a 09 09 28 66 6f 72 2d  ></tr>")...(for-
3da0: 65 61 63 68 20 28 6c 61 6d 62 64 61 20 28 73 74  each (lambda (st
3db0: 61 74 75 73 29 0a 09 09 09 20 20 20 20 28 73 65  atus)....    (se
3dc0: 74 21 20 74 6f 74 20 28 2b 20 74 6f 74 20 28 68  t! tot (+ tot (h
3dd0: 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 20 63 6f  ash-table-ref co
3de0: 75 6e 74 73 20 73 74 61 74 75 73 29 29 29 0a 09  unts status)))..
3df0: 09 09 20 20 20 20 28 70 72 69 6e 74 20 22 3c 74  ..    (print "<t
3e00: 72 3e 3c 74 64 3e 3c 66 6f 6e 74 20 63 6f 6c 6f  r><td><font colo
3e10: 72 3d 5c 22 22 20 28 63 6f 6d 6d 6f 6e 3a 67 65  r=\"" (common:ge
3e20: 74 2d 63 6f 6c 6f 72 2d 66 72 6f 6d 2d 73 74 61  t-color-from-sta
3e30: 74 75 73 20 73 74 61 74 75 73 29 20 22 5c 22 3e  tus status) "\">
3e40: 22 20 73 74 61 74 75 73 0a 09 09 09 09 20 20 20  " status.....   
3e50: 22 3c 2f 66 6f 6e 74 3e 3c 2f 74 64 3e 3c 74 64  "</font></td><td
3e60: 3e 22 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72  >" (hash-table-r
3e70: 65 66 20 63 6f 75 6e 74 73 20 73 74 61 74 75 73  ef counts status
3e80: 29 20 22 3c 2f 74 64 3e 3c 2f 74 72 3e 22 29 29  ) "</td></tr>"))
3e90: 0a 09 09 09 20 20 28 68 61 73 68 2d 74 61 62 6c  ....  (hash-tabl
3ea0: 65 2d 6b 65 79 73 20 63 6f 75 6e 74 73 29 29 0a  e-keys counts)).
3eb0: 09 09 28 70 72 69 6e 74 20 22 3c 74 72 3e 3c 74  ..(print "<tr><t
3ec0: 64 3e 54 6f 74 61 6c 3c 2f 74 64 3e 3c 74 64 3e  d>Total</td><td>
3ed0: 22 20 74 6f 74 20 22 3c 2f 74 64 3e 3c 2f 74 72  " tot "</td></tr
3ee0: 3e 3c 2f 74 61 62 6c 65 3e 22 29 0a 09 09 28 70  ></table>")...(p
3ef0: 72 69 6e 74 20 22 3c 2f 74 64 3e 3c 2f 74 64 3e  rint "</td></td>
3f00: 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e 22 29 0a  </tr></table>").
3f10: 0a 09 09 28 70 72 69 6e 74 20 22 3c 74 61 62 6c  ...(print "<tabl
3f20: 65 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d 5c 22  e cellspacing=\"
3f30: 30 5c 22 20 62 6f 72 64 65 72 3d 5c 22 31 5c 22  0\" border=\"1\"
3f40: 3e 22 20 0a 09 09 20 20 20 20 20 20 20 22 3c 74  >" ...       "<t
3f50: 72 3e 3c 74 64 3e 49 74 65 6d 3c 2f 74 64 3e 3c  r><td>Item</td><
3f60: 74 64 3e 53 74 61 74 65 3c 2f 74 64 3e 3c 74 64  td>State</td><td
3f70: 3e 53 74 61 74 75 73 3c 2f 74 64 3e 3c 74 64 3e  >Status</td><td>
3f80: 43 6f 6d 6d 65 6e 74 3c 2f 74 64 3e 22 0a 09 09  Comment</td>"...
3f90: 20 20 20 20 20 20 20 6f 75 74 74 78 74 20 22 3c         outtxt "<
3fa0: 2f 74 61 62 6c 65 3e 3c 2f 62 6f 64 79 3e 3c 2f  /table></body></
3fb0: 68 74 6d 6c 3e 22 29 0a 09 09 28 72 65 6c 65 61  html>")...(relea
3fc0: 73 65 2d 64 6f 74 2d 6c 6f 63 6b 20 6f 75 74 70  se-dot-lock outp
3fd0: 75 74 66 69 6c 65 6e 61 6d 65 29 29 29 0a 09 20  utfilename))).. 
3fe0: 20 20 20 28 63 6c 6f 73 65 2d 6f 75 74 70 75 74     (close-output
3ff0: 2d 70 6f 72 74 20 6f 75 70 29 0a 09 20 20 20 20  -port oup)..    
4000: 28 63 68 61 6e 67 65 2d 64 69 72 65 63 74 6f 72  (change-director
4010: 79 20 6f 72 69 67 2d 64 69 72 29 0a 09 20 20 20  y orig-dir)..   
4020: 20 28 74 65 73 74 2d 73 65 74 2d 74 6f 70 6c 6f   (test-set-toplo
4030: 67 21 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  g! db run-id tes
4040: 74 2d 6e 61 6d 65 20 6f 75 74 70 75 74 66 69 6c  t-name outputfil
4050: 65 6e 61 6d 65 29 0a 09 20 20 20 20 29 29 29 29  ename)..    ))))
4060: 29 0a 0a 3b 3b 20 3b 3b 20 54 4f 44 4f 3a 20 43  )..;; ;; TODO: C
4070: 6f 6e 76 65 72 67 65 20 74 68 69 73 20 77 69 74  onverge this wit
4080: 68 20 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e  h db:get-test-in
4090: 66 6f 0a 3b 3b 20 28 64 65 66 69 6e 65 20 28 72  fo.;; (define (r
40a0: 75 6e 73 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66  uns:get-test-inf
40b0: 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  o db run-id test
40c0: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  -name item-path)
40d0: 0a 3b 3b 20 20 20 28 6c 65 74 20 28 28 72 65 73  .;;   (let ((res
40e0: 20 23 66 29 29 20 3b 3b 20 28 76 65 63 74 6f 72   #f)) ;; (vector
40f0: 20 23 66 20 23 66 20 23 66 20 23 66 20 23 66 20   #f #f #f #f #f 
4100: 23 66 29 29 29 0a 3b 3b 20 20 20 20 20 28 73 71  #f))).;;     (sq
4110: 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72  lite3:for-each-r
4120: 6f 77 20 0a 3b 3b 20 20 20 20 20 20 28 6c 61 6d  ow .;;      (lam
4130: 62 64 61 20 28 69 64 20 72 75 6e 2d 69 64 20 74  bda (id run-id t
4140: 65 73 74 2d 6e 61 6d 65 20 73 74 61 74 65 20 73  est-name state s
4150: 74 61 74 75 73 29 0a 3b 3b 20 20 20 20 20 20 20  tatus).;;       
4160: 20 28 73 65 74 21 20 72 65 73 20 28 76 65 63 74   (set! res (vect
4170: 6f 72 20 69 64 20 72 75 6e 2d 69 64 20 74 65 73  or id run-id tes
4180: 74 2d 6e 61 6d 65 20 73 74 61 74 65 20 73 74 61  t-name state sta
4190: 74 75 73 20 69 74 65 6d 2d 70 61 74 68 29 29 29  tus item-path)))
41a0: 0a 3b 3b 20 20 20 20 20 20 64 62 20 22 53 45 4c  .;;      db "SEL
41b0: 45 43 54 20 69 64 2c 72 75 6e 5f 69 64 2c 74 65  ECT id,run_id,te
41c0: 73 74 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 61  stname,state,sta
41d0: 74 75 73 20 46 52 4f 4d 20 74 65 73 74 73 20 57  tus FROM tests W
41e0: 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e  HERE run_id=? AN
41f0: 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44  D testname=? AND
4200: 20 69 74 65 6d 5f 70 61 74 68 3d 3f 3b 22 0a 3b   item_path=?;".;
4210: 3b 20 20 20 20 20 20 72 75 6e 2d 69 64 20 74 65  ;      run-id te
4220: 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74  st-name item-pat
4230: 68 29 0a 3b 3b 20 20 20 20 20 72 65 73 29 29 0a  h).;;     res)).
4240: 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69 6e 65 20  .(define-inline 
4250: 28 74 65 73 74 3a 67 65 74 2d 69 64 20 76 65 63  (test:get-id vec
4260: 29 20 20 20 20 20 20 20 28 76 65 63 74 6f 72 2d  )       (vector-
4270: 72 65 66 20 76 65 63 20 30 29 29 0a 28 64 65 66  ref vec 0)).(def
4280: 69 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65 73 74  ine-inline (test
4290: 3a 67 65 74 2d 72 75 6e 5f 69 64 20 76 65 63 29  :get-run_id vec)
42a0: 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20 76     (vector-ref v
42b0: 65 63 20 31 29 29 0a 28 64 65 66 69 6e 65 2d 69  ec 1)).(define-i
42c0: 6e 6c 69 6e 65 20 28 74 65 73 74 3a 67 65 74 2d  nline (test:get-
42d0: 74 65 73 74 2d 6e 61 6d 65 20 76 65 63 29 28 76  test-name vec)(v
42e0: 65 63 74 6f 72 2d 72 65 66 20 76 65 63 20 32 29  ector-ref vec 2)
42f0: 29 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69 6e 65  ).(define-inline
4300: 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65   (test:get-state
4310: 20 76 65 63 29 20 20 20 20 28 76 65 63 74 6f 72   vec)    (vector
4320: 2d 72 65 66 20 76 65 63 20 33 29 29 0a 28 64 65  -ref vec 3)).(de
4330: 66 69 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65 73  fine-inline (tes
4340: 74 3a 67 65 74 2d 73 74 61 74 75 73 20 76 65 63  t:get-status vec
4350: 29 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20  )   (vector-ref 
4360: 76 65 63 20 34 29 29 0a 28 64 65 66 69 6e 65 2d  vec 4)).(define-
4370: 69 6e 6c 69 6e 65 20 28 74 65 73 74 3a 67 65 74  inline (test:get
4380: 2d 69 74 65 6d 2d 70 61 74 68 20 76 65 63 29 28  -item-path vec)(
4390: 76 65 63 74 6f 72 2d 72 65 66 20 76 65 63 20 35  vector-ref vec 5
43a0: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 72 75 6e  ))..(define (run
43b0: 73 3a 74 65 73 74 2d 67 65 74 2d 66 75 6c 6c 2d  s:test-get-full-
43c0: 70 61 74 68 20 74 65 73 74 29 0a 20 20 28 6c 65  path test).  (le
43d0: 74 2a 20 28 28 74 65 73 74 6e 61 6d 65 20 28 64  t* ((testname (d
43e0: 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e  b:test-get-testn
43f0: 61 6d 65 20 20 20 74 65 73 74 29 29 0a 09 20 28  ame   test)).. (
4400: 69 74 65 6d 70 61 74 68 20 28 64 62 3a 74 65 73  itempath (db:tes
4410: 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20  t-get-item-path 
4420: 74 65 73 74 29 29 29 0a 20 20 20 20 28 63 6f 6e  test))).    (con
4430: 63 20 74 65 73 74 6e 61 6d 65 20 28 69 66 20 28  c testname (if (
4440: 65 71 75 61 6c 3f 20 69 74 65 6d 70 61 74 68 20  equal? itempath 
4450: 22 22 29 20 22 22 20 28 63 6f 6e 63 20 22 28 22  "") "" (conc "("
4460: 20 69 74 65 6d 70 61 74 68 20 22 29 22 29 29 29   itempath ")")))
4470: 29 29 0a 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69  ))..(define-inli
4480: 6e 65 20 28 74 65 73 74 3a 74 65 73 74 2d 67 65  ne (test:test-ge
4490: 74 2d 66 75 6c 6c 6e 61 6d 65 20 74 65 73 74 29  t-fullname test)
44a0: 0a 20 20 20 28 63 6f 6e 63 20 28 64 62 3a 74 65  .   (conc (db:te
44b0: 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20  st-get-testname 
44c0: 74 65 73 74 29 0a 09 20 28 69 66 20 28 65 71 75  test).. (if (equ
44d0: 61 6c 3f 20 28 64 62 3a 74 65 73 74 2d 67 65 74  al? (db:test-get
44e0: 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 29  -item-path test)
44f0: 20 22 22 29 0a 09 20 20 20 20 20 22 22 0a 09 20   "")..     "".. 
4500: 20 20 20 20 28 63 6f 6e 63 20 22 28 22 20 28 64      (conc "(" (d
4510: 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d  b:test-get-item-
4520: 70 61 74 68 20 74 65 73 74 29 20 22 29 22 29 29  path test) ")"))
4530: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 63 68 65  ))..(define (che
4540: 63 6b 2d 76 61 6c 69 64 2d 69 74 65 6d 73 20 63  ck-valid-items c
4550: 6c 61 73 73 20 69 74 65 6d 29 0a 20 20 28 6c 65  lass item).  (le
4560: 74 20 28 28 76 61 6c 69 64 2d 76 61 6c 75 65 73  t ((valid-values
4570: 20 28 6c 65 74 20 28 28 73 20 28 63 6f 6e 66 69   (let ((s (confi
4580: 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67  g-lookup *config
4590: 64 61 74 2a 20 22 76 61 6c 69 64 76 61 6c 75 65  dat* "validvalue
45a0: 73 22 20 63 6c 61 73 73 29 29 29 0a 09 09 09 28  s" class)))....(
45b0: 69 66 20 73 20 28 73 74 72 69 6e 67 2d 73 70 6c  if s (string-spl
45c0: 69 74 20 73 29 20 23 66 29 29 29 29 0a 20 20 20  it s) #f)))).   
45d0: 20 28 69 66 20 76 61 6c 69 64 2d 76 61 6c 75 65   (if valid-value
45e0: 73 0a 09 28 69 66 20 28 6d 65 6d 62 65 72 20 69  s..(if (member i
45f0: 74 65 6d 20 76 61 6c 69 64 2d 76 61 6c 75 65 73  tem valid-values
4600: 29 0a 09 20 20 20 20 69 74 65 6d 20 23 66 29 0a  )..    item #f).
4610: 09 69 74 65 6d 29 29 29 0a 0a 28 64 65 66 69 6e  .item)))..(defin
4620: 65 20 28 74 65 73 74 73 74 65 70 2d 73 65 74 2d  e (teststep-set-
4630: 73 74 61 74 75 73 21 20 64 62 20 72 75 6e 2d 69  status! db run-i
4640: 64 20 74 65 73 74 2d 6e 61 6d 65 20 74 65 73 74  d test-name test
4650: 73 74 65 70 2d 6e 61 6d 65 20 73 74 61 74 65 2d  step-name state-
4660: 69 6e 20 73 74 61 74 75 73 2d 69 6e 20 69 74 65  in status-in ite
4670: 6d 64 61 74 20 63 6f 6d 6d 65 6e 74 29 0a 20 20  mdat comment).  
4680: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22  (debug:print 4 "
4690: 72 75 6e 2d 69 64 3a 20 22 20 72 75 6e 2d 69 64  run-id: " run-id
46a0: 20 22 20 74 65 73 74 2d 6e 61 6d 65 3a 20 22 20   " test-name: " 
46b0: 74 65 73 74 2d 6e 61 6d 65 29 0a 20 20 28 6c 65  test-name).  (le
46c0: 74 2a 20 28 28 73 74 61 74 65 20 20 20 20 20 28  t* ((state     (
46d0: 63 68 65 63 6b 2d 76 61 6c 69 64 2d 69 74 65 6d  check-valid-item
46e0: 73 20 22 73 74 61 74 65 22 20 73 74 61 74 65 2d  s "state" state-
46f0: 69 6e 29 29 0a 09 20 28 73 74 61 74 75 73 20 20  in)).. (status  
4700: 20 20 28 63 68 65 63 6b 2d 76 61 6c 69 64 2d 69    (check-valid-i
4710: 74 65 6d 73 20 22 73 74 61 74 75 73 22 20 73 74  tems "status" st
4720: 61 74 75 73 2d 69 6e 29 29 0a 09 20 28 69 74 65  atus-in)).. (ite
4730: 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c 69 73  m-path (item-lis
4740: 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74 29  t->path itemdat)
4750: 29 0a 09 20 28 74 65 73 74 64 61 74 20 20 20 28  ).. (testdat   (
4760: 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f  db:get-test-info
4770: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d   db run-id test-
4780: 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29  name item-path))
4790: 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72 69  ).    (debug:pri
47a0: 6e 74 20 35 20 22 74 65 73 74 64 61 74 3a 20 22  nt 5 "testdat: "
47b0: 20 74 65 73 74 64 61 74 29 0a 20 20 20 20 28 69   testdat).    (i
47c0: 66 20 28 61 6e 64 20 74 65 73 74 64 61 74 20 3b  f (and testdat ;
47d0: 3b 20 69 66 20 74 68 65 20 73 65 63 74 69 6f 6e  ; if the section
47e0: 20 65 78 69 73 74 73 20 74 68 65 6e 20 66 6f 72   exists then for
47f0: 63 65 20 73 70 65 63 69 66 69 63 61 74 69 6f 6e  ce specification
4800: 20 42 55 47 2c 20 49 20 64 6f 6e 27 74 20 6c 69   BUG, I don't li
4810: 6b 65 20 68 6f 77 20 74 68 69 73 20 77 6f 72 6b  ke how this work
4820: 73 2e 0a 09 20 20 20 20 20 28 6f 72 20 28 6e 6f  s...     (or (no
4830: 74 20 73 74 61 74 65 29 28 6e 6f 74 20 73 74 61  t state)(not sta
4840: 74 75 73 29 29 29 0a 09 28 64 65 62 75 67 3a 70  tus)))..(debug:p
4850: 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e 47 3a  rint 0 "WARNING:
4860: 20 49 6e 76 61 6c 69 64 20 22 20 28 69 66 20 73   Invalid " (if s
4870: 74 61 74 75 73 20 22 73 74 61 74 75 73 22 20 22  tatus "status" "
4880: 73 74 61 74 65 22 29 0a 09 20 20 20 20 20 20 20  state")..       
4890: 22 20 76 61 6c 75 65 20 5c 22 22 20 28 69 66 20  " value \"" (if 
48a0: 73 74 61 74 75 73 20 73 74 61 74 75 73 2d 69 6e  status status-in
48b0: 20 73 74 61 74 65 2d 69 6e 29 20 22 5c 22 2c 20   state-in) "\", 
48c0: 75 70 64 61 74 65 20 79 6f 75 72 20 76 61 6c 69  update your vali
48d0: 64 73 74 61 74 65 73 20 73 65 63 74 69 6f 6e 20  dstates section 
48e0: 69 6e 20 6d 65 67 61 74 65 73 74 2e 63 6f 6e 66  in megatest.conf
48f0: 69 67 22 29 29 0a 20 20 20 20 28 69 66 20 74 65  ig")).    (if te
4900: 73 74 64 61 74 0a 09 28 6c 65 74 20 28 28 74 65  stdat..(let ((te
4910: 73 74 2d 69 64 20 28 74 65 73 74 3a 67 65 74 2d  st-id (test:get-
4920: 69 64 20 74 65 73 74 64 61 74 29 29 29 0a 09 20  id testdat))).. 
4930: 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74   (sqlite3:execut
4940: 65 20 64 62 20 0a 09 09 09 22 49 4e 53 45 52 54  e db ...."INSERT
4950: 20 4f 52 20 52 45 50 4c 41 43 45 20 69 6e 74 6f   OR REPLACE into
4960: 20 74 65 73 74 5f 73 74 65 70 73 20 28 74 65 73   test_steps (tes
4970: 74 5f 69 64 2c 73 74 65 70 6e 61 6d 65 2c 73 74  t_id,stepname,st
4980: 61 74 65 2c 73 74 61 74 75 73 2c 65 76 65 6e 74  ate,status,event
4990: 5f 74 69 6d 65 2c 63 6f 6d 6d 65 6e 74 29 20 56  _time,comment) V
49a0: 41 4c 55 45 53 28 3f 2c 3f 2c 3f 2c 3f 2c 73 74  ALUES(?,?,?,?,st
49b0: 72 66 74 69 6d 65 28 27 25 73 27 2c 27 6e 6f 77  rftime('%s','now
49c0: 27 29 2c 3f 29 3b 22 0a 09 09 09 74 65 73 74 2d  '),?);"....test-
49d0: 69 64 20 74 65 73 74 73 74 65 70 2d 6e 61 6d 65  id teststep-name
49e0: 20 73 74 61 74 65 20 73 74 61 74 75 73 20 28 69   state status (i
49f0: 66 20 63 6f 6d 6d 65 6e 74 20 63 6f 6d 6d 65 6e  f comment commen
4a00: 74 20 22 22 29 29 29 0a 09 28 64 65 62 75 67 3a  t "")))..(debug:
4a10: 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20  print 0 "ERROR: 
4a20: 43 61 6e 27 74 20 75 70 64 61 74 65 20 22 20 74  Can't update " t
4a30: 65 73 74 2d 6e 61 6d 65 20 22 20 66 6f 72 20 72  est-name " for r
4a40: 75 6e 20 22 20 72 75 6e 2d 69 64 20 22 20 2d 3e  un " run-id " ->
4a50: 20 6e 6f 20 73 75 63 68 20 74 65 73 74 20 69 6e   no such test in
4a60: 20 64 62 22 29 29 29 29 0a 0a 28 64 65 66 69 6e   db"))))..(defin
4a70: 65 20 28 74 65 73 74 2d 67 65 74 2d 6b 69 6c 6c  e (test-get-kill
4a80: 2d 72 65 71 75 65 73 74 20 64 62 20 72 75 6e 2d  -request db run-
4a90: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65  id test-name ite
4aa0: 6d 64 61 74 29 0a 20 20 28 6c 65 74 2a 20 28 28  mdat).  (let* ((
4ab0: 69 74 65 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d  item-path (item-
4ac0: 6c 69 73 74 2d 3e 70 61 74 68 20 69 74 65 6d 64  list->path itemd
4ad0: 61 74 29 29 0a 09 20 28 74 65 73 74 64 61 74 20  at)).. (testdat 
4ae0: 20 20 28 64 62 3a 67 65 74 2d 74 65 73 74 2d 69    (db:get-test-i
4af0: 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65  nfo db run-id te
4b00: 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74  st-name item-pat
4b10: 68 29 29 29 0a 20 20 20 20 28 65 71 75 61 6c 3f  h))).    (equal?
4b20: 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65   (test:get-state
4b30: 20 74 65 73 74 64 61 74 29 20 22 4b 49 4c 4c 52   testdat) "KILLR
4b40: 45 51 22 29 29 29 0a 0a 28 64 65 66 69 6e 65 20  EQ")))..(define 
4b50: 28 74 65 73 74 2d 73 65 74 2d 6d 65 74 61 2d 69  (test-set-meta-i
4b60: 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65  nfo db run-id te
4b70: 73 74 6e 61 6d 65 20 69 74 65 6d 64 61 74 29 0a  stname itemdat).
4b80: 20 20 28 6c 65 74 20 28 28 69 74 65 6d 2d 70 61    (let ((item-pa
4b90: 74 68 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70  th (item-list->p
4ba0: 61 74 68 20 69 74 65 6d 64 61 74 29 29 0a 09 28  ath itemdat))..(
4bb0: 63 70 75 6c 6f 61 64 20 20 28 67 65 74 2d 63 70  cpuload  (get-cp
4bc0: 75 2d 6c 6f 61 64 29 29 0a 09 28 68 6f 73 74 6e  u-load))..(hostn
4bd0: 61 6d 65 20 28 67 65 74 2d 68 6f 73 74 2d 6e 61  ame (get-host-na
4be0: 6d 65 29 29 0a 09 28 64 69 73 6b 66 72 65 65 20  me))..(diskfree 
4bf0: 28 67 65 74 2d 64 66 20 28 63 75 72 72 65 6e 74  (get-df (current
4c00: 2d 64 69 72 65 63 74 6f 72 79 29 29 29 0a 09 28  -directory)))..(
4c10: 75 6e 61 6d 65 20 20 20 20 28 67 65 74 2d 75 6e  uname    (get-un
4c20: 61 6d 65 20 22 2d 73 72 76 70 69 6f 22 29 29 0a  ame "-srvpio")).
4c30: 09 28 72 75 6e 70 61 74 68 20 20 28 63 75 72 72  .(runpath  (curr
4c40: 65 6e 74 2d 64 69 72 65 63 74 6f 72 79 29 29 29  ent-directory)))
4c50: 0a 20 20 20 20 28 73 71 6c 69 74 65 33 3a 65 78  .    (sqlite3:ex
4c60: 65 63 75 74 65 20 64 62 20 22 55 50 44 41 54 45  ecute db "UPDATE
4c70: 20 74 65 73 74 73 20 53 45 54 20 68 6f 73 74 3d   tests SET host=
4c80: 3f 2c 63 70 75 6c 6f 61 64 3d 3f 2c 64 69 73 6b  ?,cpuload=?,disk
4c90: 66 72 65 65 3d 3f 2c 75 6e 61 6d 65 3d 3f 2c 72  free=?,uname=?,r
4ca0: 75 6e 64 69 72 3d 3f 20 57 48 45 52 45 20 72 75  undir=? WHERE ru
4cb0: 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e  n_id=? AND testn
4cc0: 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70  ame=? AND item_p
4cd0: 61 74 68 3d 3f 3b 22 0a 09 09 20 20 68 6f 73 74  ath=?;"...  host
4ce0: 6e 61 6d 65 0a 09 09 20 20 63 70 75 6c 6f 61 64  name...  cpuload
4cf0: 0a 09 09 20 20 64 69 73 6b 66 72 65 65 0a 09 09  ...  diskfree...
4d00: 20 20 75 6e 61 6d 65 0a 09 09 20 20 72 75 6e 70    uname...  runp
4d10: 61 74 68 0a 09 09 20 20 72 75 6e 2d 69 64 0a 09  ath...  run-id..
4d20: 09 20 20 74 65 73 74 6e 61 6d 65 0a 09 09 20 20  .  testname...  
4d30: 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 0a 28 64  item-path)))..(d
4d40: 65 66 69 6e 65 20 28 74 65 73 74 2d 75 70 64 61  efine (test-upda
4d50: 74 65 2d 6d 65 74 61 2d 69 6e 66 6f 20 64 62 20  te-meta-info db 
4d60: 72 75 6e 2d 69 64 20 74 65 73 74 6e 61 6d 65 20  run-id testname 
4d70: 69 74 65 6d 64 61 74 20 6d 69 6e 75 74 65 73 20  itemdat minutes 
4d80: 63 70 75 6c 6f 61 64 20 64 69 73 6b 66 72 65 65  cpuload diskfree
4d90: 20 74 6d 70 66 72 65 65 29 0a 20 20 28 6c 65 74   tmpfree).  (let
4da0: 20 28 28 69 74 65 6d 2d 70 61 74 68 20 28 69 74   ((item-path (it
4db0: 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69 74  em-list->path it
4dc0: 65 6d 64 61 74 29 29 29 0a 20 20 20 20 28 69 66  emdat))).    (if
4dd0: 20 28 6e 6f 74 20 69 74 65 6d 2d 70 61 74 68 29   (not item-path)
4de0: 28 62 65 67 69 6e 20 28 64 65 62 75 67 3a 70 72  (begin (debug:pr
4df0: 69 6e 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20  int 0 "WARNING: 
4e00: 49 54 45 4d 50 41 54 48 20 6e 6f 74 20 73 65 74  ITEMPATH not set
4e10: 2e 22 29 20 20 20 28 73 65 74 21 20 69 74 65 6d  .")   (set! item
4e20: 2d 70 61 74 68 20 22 22 29 29 29 0a 20 20 20 20  -path ""))).    
4e30: 3b 3b 20 28 6c 65 74 20 28 28 74 65 73 74 69 6e  ;; (let ((testin
4e40: 66 6f 20 28 64 62 3a 67 65 74 2d 74 65 73 74 2d  fo (db:get-test-
4e50: 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74  info db run-id t
4e60: 65 73 74 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74  estname item-pat
4e70: 68 29 29 29 0a 20 20 20 20 3b 3b 20 20 20 28 69  h))).    ;;   (i
4e80: 66 20 28 61 6e 64 20 28 6e 6f 74 20 28 65 71 75  f (and (not (equ
4e90: 61 6c 3f 20 28 64 62 3a 74 65 73 74 2d 67 65 74  al? (db:test-get
4ea0: 2d 73 74 61 74 75 73 20 74 65 73 74 69 6e 66 6f  -status testinfo
4eb0: 29 20 22 43 4f 4d 50 4c 45 54 45 44 22 29 29 0a  ) "COMPLETED")).
4ec0: 20 20 20 20 3b 3b 20 20 20 20 20 20 20 20 20 20      ;;          
4ed0: 20 20 28 6e 6f 74 20 28 65 71 75 61 6c 3f 20 28    (not (equal? (
4ee0: 64 62 3a 74 65 73 74 2d 67 65 74 2d 73 74 61 74  db:test-get-stat
4ef0: 75 73 20 74 65 73 74 69 6e 66 6f 29 20 22 4b 49  us testinfo) "KI
4f00: 4c 4c 52 45 51 22 29 29 0a 20 20 20 20 28 73 71  LLREQ")).    (sq
4f10: 6c 69 74 65 33 3a 65 78 65 63 75 74 65 0a 20 20  lite3:execute.  
4f20: 20 20 20 64 62 0a 20 20 20 20 20 22 55 50 44 41     db.     "UPDA
4f30: 54 45 20 74 65 73 74 73 20 53 45 54 20 63 70 75  TE tests SET cpu
4f40: 6c 6f 61 64 3d 3f 2c 64 69 73 6b 66 72 65 65 3d  load=?,diskfree=
4f50: 3f 2c 72 75 6e 5f 64 75 72 61 74 69 6f 6e 3d 3f  ?,run_duration=?
4f60: 2c 73 74 61 74 65 3d 27 52 55 4e 4e 49 4e 47 27  ,state='RUNNING'
4f70: 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20   WHERE run_id=? 
4f80: 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41  AND testname=? A
4f90: 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f 20 41  ND item_path=? A
4fa0: 4e 44 20 73 74 61 74 65 20 4e 4f 54 20 49 4e 20  ND state NOT IN 
4fb0: 28 27 43 4f 4d 50 4c 45 54 45 44 27 2c 27 4b 49  ('COMPLETED','KI
4fc0: 4c 4c 52 45 51 27 2c 27 4b 49 4c 4c 45 44 27 29  LLREQ','KILLED')
4fd0: 3b 22 0a 20 20 20 20 20 63 70 75 6c 6f 61 64 0a  ;".     cpuload.
4fe0: 20 20 20 20 20 64 69 73 6b 66 72 65 65 0a 20 20       diskfree.  
4ff0: 20 20 20 6d 69 6e 75 74 65 73 0a 20 20 20 20 20     minutes.     
5000: 72 75 6e 2d 69 64 0a 20 20 20 20 20 74 65 73 74  run-id.     test
5010: 6e 61 6d 65 0a 20 20 20 20 20 69 74 65 6d 2d 70  name.     item-p
5020: 61 74 68 29 29 29 0a 0a 28 64 65 66 69 6e 65 20  ath)))..(define 
5030: 28 73 65 74 2d 6d 65 67 61 74 65 73 74 2d 65 6e  (set-megatest-en
5040: 76 2d 76 61 72 73 20 64 62 20 72 75 6e 2d 69 64  v-vars db run-id
5050: 29 0a 20 20 28 6c 65 74 20 28 28 6b 65 79 73 20  ).  (let ((keys 
5060: 28 64 62 2d 67 65 74 2d 6b 65 79 73 20 64 62 29  (db-get-keys db)
5070: 29 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68  )).    (for-each
5080: 20 28 6c 61 6d 62 64 61 20 28 6b 65 79 29 0a 09   (lambda (key)..
5090: 09 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61  .(sqlite3:for-ea
50a0: 63 68 2d 72 6f 77 0a 09 09 20 28 6c 61 6d 62 64  ch-row... (lambd
50b0: 61 20 28 76 61 6c 29 0a 09 09 20 20 20 28 64 65  a (val)...   (de
50c0: 62 75 67 3a 70 72 69 6e 74 20 32 20 22 73 65 74  bug:print 2 "set
50d0: 65 6e 76 20 22 20 28 6b 65 79 3a 67 65 74 2d 66  env " (key:get-f
50e0: 69 65 6c 64 6e 61 6d 65 20 6b 65 79 29 20 22 20  ieldname key) " 
50f0: 22 20 76 61 6c 29 0a 09 09 20 20 20 28 73 65 74  " val)...   (set
5100: 65 6e 76 20 28 6b 65 79 3a 67 65 74 2d 66 69 65  env (key:get-fie
5110: 6c 64 6e 61 6d 65 20 6b 65 79 29 20 76 61 6c 29  ldname key) val)
5120: 29 0a 09 09 20 64 62 20 0a 09 09 20 28 63 6f 6e  )... db ... (con
5130: 63 20 22 53 45 4c 45 43 54 20 22 20 28 6b 65 79  c "SELECT " (key
5140: 3a 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b  :get-fieldname k
5150: 65 79 29 20 22 20 46 52 4f 4d 20 72 75 6e 73 20  ey) " FROM runs 
5160: 57 48 45 52 45 20 69 64 3d 3f 3b 22 29 0a 09 09  WHERE id=?;")...
5170: 20 72 75 6e 2d 69 64 29 29 0a 09 20 20 20 20 20   run-id))..     
5180: 20 6b 65 79 73 29 29 29 0a 0a 28 64 65 66 69 6e   keys)))..(defin
5190: 65 20 28 73 65 74 2d 69 74 65 6d 2d 65 6e 76 2d  e (set-item-env-
51a0: 76 61 72 73 20 69 74 65 6d 64 61 74 29 0a 20 20  vars itemdat).  
51b0: 28 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64  (for-each (lambd
51c0: 61 20 28 69 74 65 6d 29 0a 09 20 20 20 20 20 20  a (item)..      
51d0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22  (debug:print 2 "
51e0: 73 65 74 65 6e 76 20 22 20 28 63 61 72 20 69 74  setenv " (car it
51f0: 65 6d 29 20 22 20 22 20 28 63 61 64 72 20 69 74  em) " " (cadr it
5200: 65 6d 29 29 0a 09 20 20 20 20 20 20 28 73 65 74  em))..      (set
5210: 65 6e 76 20 28 63 61 72 20 69 74 65 6d 29 20 28  env (car item) (
5220: 63 61 64 72 20 69 74 65 6d 29 29 29 0a 09 20 20  cadr item)))..  
5230: 20 20 69 74 65 6d 64 61 74 29 29 0a 0a 28 64 65    itemdat))..(de
5240: 66 69 6e 65 20 28 67 65 74 2d 61 6c 6c 2d 6c 65  fine (get-all-le
5250: 67 61 6c 2d 74 65 73 74 73 29 0a 20 20 28 6c 65  gal-tests).  (le
5260: 74 2a 20 28 28 74 65 73 74 73 20 20 28 67 6c 6f  t* ((tests  (glo
5270: 62 20 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74 68  b (conc *toppath
5280: 2a 20 22 2f 74 65 73 74 73 2f 2a 22 29 29 29 0a  * "/tests/*"))).
5290: 09 20 28 72 65 73 20 20 20 20 27 28 29 29 29 0a  . (res    '())).
52a0: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
52b0: 20 34 20 22 49 4e 46 4f 3a 20 4c 6f 6f 6b 69 6e   4 "INFO: Lookin
52c0: 67 20 61 74 20 74 65 73 74 73 20 22 20 28 73 74  g at tests " (st
52d0: 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65  ring-intersperse
52e0: 20 74 65 73 74 73 20 22 2c 22 29 29 0a 20 20 20   tests ",")).   
52f0: 20 28 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62   (for-each (lamb
5300: 64 61 20 28 74 65 73 74 70 61 74 68 29 0a 09 09  da (testpath)...
5310: 28 69 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73  (if (file-exists
5320: 3f 20 28 63 6f 6e 63 20 74 65 73 74 70 61 74 68  ? (conc testpath
5330: 20 22 2f 74 65 73 74 63 6f 6e 66 69 67 22 29 29   "/testconfig"))
5340: 0a 09 09 20 20 20 20 28 73 65 74 21 20 72 65 73  ...    (set! res
5350: 20 28 63 6f 6e 73 20 28 6c 61 73 74 20 28 73 74   (cons (last (st
5360: 72 69 6e 67 2d 73 70 6c 69 74 20 74 65 73 74 70  ring-split testp
5370: 61 74 68 20 22 2f 22 29 29 20 72 65 73 29 29 29  ath "/")) res)))
5380: 29 0a 09 20 20 20 20 20 20 74 65 73 74 73 29 0a  )..      tests).
5390: 20 20 20 20 72 65 73 29 29 0a 0a 28 64 65 66 69      res))..(defi
53a0: 6e 65 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e  ne (runs:can-run
53b0: 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64 62 29 0a  -more-tests db).
53c0: 20 20 28 6c 65 74 20 28 28 6e 75 6d 2d 72 75 6e    (let ((num-run
53d0: 6e 69 6e 67 20 28 64 62 3a 67 65 74 2d 63 6f 75  ning (db:get-cou
53e0: 6e 74 2d 74 65 73 74 73 2d 72 75 6e 6e 69 6e 67  nt-tests-running
53f0: 20 64 62 29 29 0a 09 28 6d 61 78 2d 63 6f 6e 63   db))..(max-conc
5400: 75 72 72 65 6e 74 2d 6a 6f 62 73 20 28 63 6f 6e  urrent-jobs (con
5410: 66 69 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66  fig-lookup *conf
5420: 69 67 64 61 74 2a 20 22 73 65 74 75 70 22 20 22  igdat* "setup" "
5430: 6d 61 78 5f 63 6f 6e 63 75 72 72 65 6e 74 5f 6a  max_concurrent_j
5440: 6f 62 73 22 29 29 29 0a 20 20 20 20 28 64 65 62  obs"))).    (deb
5450: 75 67 3a 70 72 69 6e 74 20 32 20 22 6d 61 78 2d  ug:print 2 "max-
5460: 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 3a  concurrent-jobs:
5470: 20 22 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e   " max-concurren
5480: 74 2d 6a 6f 62 73 20 22 2c 20 6e 75 6d 2d 72 75  t-jobs ", num-ru
5490: 6e 6e 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e  nning: " num-run
54a0: 6e 69 6e 67 29 0a 20 20 20 20 28 69 66 20 28 6e  ning).    (if (n
54b0: 6f 74 20 28 65 71 3f 20 30 20 2a 67 6c 6f 62 61  ot (eq? 0 *globa
54c0: 6c 65 78 69 74 73 74 61 74 75 73 2a 29 29 0a 09  lexitstatus*))..
54d0: 23 66 0a 09 28 69 66 20 28 6f 72 20 28 6e 6f 74  #f..(if (or (not
54e0: 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d   max-concurrent-
54f0: 6a 6f 62 73 29 0a 09 09 28 61 6e 64 20 6d 61 78  jobs)...(and max
5500: 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73  -concurrent-jobs
5510: 0a 09 09 20 20 20 20 20 28 73 74 72 69 6e 67 2d  ...     (string-
5520: 3e 6e 75 6d 62 65 72 20 6d 61 78 2d 63 6f 6e 63  >number max-conc
5530: 75 72 72 65 6e 74 2d 6a 6f 62 73 29 0a 09 09 20  urrent-jobs)... 
5540: 20 20 20 20 28 6e 6f 74 20 28 3e 3d 20 6e 75 6d      (not (>= num
5550: 2d 72 75 6e 6e 69 6e 67 20 28 73 74 72 69 6e 67  -running (string
5560: 2d 3e 6e 75 6d 62 65 72 20 6d 61 78 2d 63 6f 6e  ->number max-con
5570: 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29 29 29 29  current-jobs))))
5580: 29 0a 09 20 20 20 20 23 74 0a 09 20 20 20 20 28  )..    #t..    (
5590: 62 65 67 69 6e 20 0a 09 20 20 20 20 20 20 28 64  begin ..      (d
55a0: 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41  ebug:print 0 "WA
55b0: 52 4e 49 4e 47 3a 20 4d 61 78 20 72 75 6e 6e 69  RNING: Max runni
55c0: 6e 67 20 6a 6f 62 73 20 65 78 63 65 65 64 65 64  ng jobs exceeded
55d0: 2c 20 63 75 72 72 65 6e 74 20 6e 75 6d 62 65 72  , current number
55e0: 20 72 75 6e 6e 69 6e 67 3a 20 22 20 6e 75 6d 2d   running: " num-
55f0: 72 75 6e 6e 69 6e 67 20 0a 09 09 09 20 20 20 22  running ....   "
5600: 2c 20 6d 61 78 5f 63 6f 6e 63 75 72 72 65 6e 74  , max_concurrent
5610: 5f 6a 6f 62 73 3a 20 22 20 6d 61 78 2d 63 6f 6e  _jobs: " max-con
5620: 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29 0a 09 20  current-jobs).. 
5630: 20 20 20 20 20 23 66 29 29 29 29 29 0a 20 20 0a       #f))))).  .
5640: 28 64 65 66 69 6e 65 20 28 72 75 6e 2d 74 65 73  (define (run-tes
5650: 74 73 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 73  ts db test-names
5660: 29 0a 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 73  ).  (let* ((keys
5670: 20 20 20 20 20 20 20 20 28 64 62 2d 67 65 74 2d          (db-get-
5680: 6b 65 79 73 20 64 62 29 29 0a 09 20 28 6b 65 79  keys db)).. (key
5690: 76 61 6c 6c 73 74 20 20 20 28 6b 65 79 73 2d 3e  vallst   (keys->
56a0: 76 61 6c 6c 69 73 74 20 6b 65 79 73 20 23 74 29  vallist keys #t)
56b0: 29 0a 09 20 28 72 75 6e 2d 69 64 20 20 20 20 20  ).. (run-id     
56c0: 20 28 72 65 67 69 73 74 65 72 2d 72 75 6e 20 64   (register-run d
56d0: 62 20 6b 65 79 73 29 29 20 20 3b 3b 20 20 74 65  b keys))  ;;  te
56e0: 73 74 2d 6e 61 6d 65 29 29 29 0a 09 20 28 64 65  st-name))).. (de
56f0: 66 65 72 72 65 64 20 20 20 20 27 28 29 29 29 20  ferred    '())) 
5700: 3b 3b 20 64 65 6c 61 79 20 72 75 6e 6e 69 6e 67  ;; delay running
5710: 20 74 68 65 73 65 20 73 69 6e 63 65 20 74 68 65   these since the
5720: 79 20 68 61 76 65 20 61 20 77 61 69 74 6f 6e 20  y have a waiton 
5730: 63 6c 61 75 73 65 0a 20 20 20 20 3b 3b 20 6f 6e  clause.    ;; on
5740: 20 74 68 65 20 66 69 72 73 74 20 70 61 73 73 20   the first pass 
5750: 6f 72 20 63 61 6c 6c 20 74 6f 20 72 75 6e 2d 74  or call to run-t
5760: 65 73 74 73 20 73 65 74 20 46 41 49 4c 53 20 74  ests set FAILS t
5770: 6f 20 4e 4f 54 5f 53 54 41 52 54 45 44 20 69 66  o NOT_STARTED if
5780: 0a 20 20 20 20 3b 3b 20 2d 6b 65 65 70 67 6f 69  .    ;; -keepgoi
5790: 6e 67 20 69 73 20 73 70 65 63 69 66 69 65 64 0a  ng is specified.
57a0: 20 20 20 20 28 69 66 20 28 61 6e 64 20 28 65 71      (if (and (eq
57b0: 3f 20 2a 70 61 73 73 6e 75 6d 2a 20 30 29 0a 09  ? *passnum* 0)..
57c0: 20 20 20 20 20 28 61 72 67 73 3a 67 65 74 2d 61       (args:get-a
57d0: 72 67 20 22 2d 6b 65 65 70 67 6f 69 6e 67 22 29  rg "-keepgoing")
57e0: 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 3b 3b 20  )..(begin..  ;; 
57f0: 68 61 76 65 20 74 6f 20 64 65 6c 65 74 65 20 74  have to delete t
5800: 65 73 74 20 72 65 63 6f 72 64 73 20 77 68 65 72  est records wher
5810: 65 20 4e 4f 54 5f 53 54 41 52 54 45 44 20 73 69  e NOT_STARTED si
5820: 6e 63 65 20 74 68 65 79 20 63 61 6e 20 63 61 75  nce they can cau
5830: 73 65 20 2d 6b 65 65 70 67 6f 69 6e 67 20 74 6f  se -keepgoing to
5840: 20 0a 09 20 20 3b 3b 20 67 65 74 20 73 74 75 63   ..  ;; get stuc
5850: 6b 20 64 75 65 20 74 6f 20 62 65 63 6f 6d 69 6e  k due to becomin
5860: 67 20 69 6e 61 63 63 65 73 73 69 62 6c 65 20 66  g inaccessible f
5870: 72 6f 6d 20 61 20 66 61 69 6c 65 64 20 74 65 73  rom a failed tes
5880: 74 2e 20 49 2e 65 2e 20 69 66 20 74 65 73 74 20  t. I.e. if test 
5890: 42 20 64 65 70 65 6e 64 73 20 0a 09 20 20 3b 3b  B depends ..  ;;
58a0: 20 6f 6e 20 74 65 73 74 20 41 20 62 75 74 20 74   on test A but t
58b0: 65 73 74 20 42 20 72 65 61 63 68 65 64 20 74 68  est B reached th
58c0: 65 20 70 6f 69 6e 74 20 6f 6e 20 62 65 69 6e 67  e point on being
58d0: 20 72 65 67 69 73 74 65 72 65 64 20 61 73 20 4e   registered as N
58e0: 4f 54 5f 53 54 41 52 54 45 44 20 61 6e 64 20 74  OT_STARTED and t
58f0: 65 73 74 0a 09 20 20 3b 3b 20 41 20 66 61 69 6c  est..  ;; A fail
5900: 65 64 20 66 6f 72 20 73 6f 6d 65 20 72 65 61 73  ed for some reas
5910: 6f 6e 20 74 68 65 6e 20 6f 6e 20 72 65 2d 72 75  on then on re-ru
5920: 6e 20 75 73 69 6e 67 20 2d 6b 65 65 70 67 6f 69  n using -keepgoi
5930: 6e 67 20 74 68 65 20 72 75 6e 20 63 61 6e 20 6e  ng the run can n
5940: 65 76 65 72 20 63 6f 6d 70 6c 65 74 65 2e 0a 09  ever complete...
5950: 20 20 28 64 62 3a 64 65 6c 65 74 65 2d 74 65 73    (db:delete-tes
5960: 74 73 2d 69 6e 2d 73 74 61 74 65 20 64 62 20 72  ts-in-state db r
5970: 75 6e 2d 69 64 20 22 4e 4f 54 5f 53 54 41 52 54  un-id "NOT_START
5980: 45 44 22 29 0a 09 20 20 28 64 62 3a 73 65 74 2d  ED")..  (db:set-
5990: 74 65 73 74 73 2d 73 74 61 74 65 2d 73 74 61 74  tests-state-stat
59a0: 75 73 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  us db run-id tes
59b0: 74 2d 6e 61 6d 65 73 20 23 66 20 22 46 41 49 4c  t-names #f "FAIL
59c0: 22 20 22 4e 4f 54 5f 53 54 41 52 54 45 44 22 20  " "NOT_STARTED" 
59d0: 22 46 41 49 4c 22 29 29 29 0a 20 20 20 20 28 73  "FAIL"))).    (s
59e0: 65 74 21 20 2a 70 61 73 73 6e 75 6d 2a 20 28 2b  et! *passnum* (+
59f0: 20 2a 70 61 73 73 6e 75 6d 2a 20 31 29 29 0a 20   *passnum* 1)). 
5a00: 20 20 20 28 6c 65 74 20 6c 6f 6f 70 20 28 28 6e     (let loop ((n
5a10: 75 6d 74 69 6d 65 73 20 30 29 29 0a 20 20 20 20  umtimes 0)).    
5a20: 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 20 20    (for-each .   
5a30: 20 20 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73      (lambda (tes
5a40: 74 2d 6e 61 6d 65 29 0a 09 20 28 69 66 20 28 72  t-name).. (if (r
5a50: 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65  uns:can-run-more
5a60: 2d 74 65 73 74 73 20 64 62 29 0a 09 20 20 20 20  -tests db)..    
5a70: 20 28 72 75 6e 2d 6f 6e 65 2d 74 65 73 74 20 64   (run-one-test d
5a80: 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  b run-id test-na
5a90: 6d 65 20 6b 65 79 76 61 6c 6c 73 74 29 0a 09 20  me keyvallst).. 
5aa0: 20 20 20 20 3b 3b 20 61 64 64 20 73 6f 6d 65 20      ;; add some 
5ab0: 64 65 6c 61 79 20 0a 09 20 20 20 20 20 3b 28 73  delay ..     ;(s
5ac0: 6c 65 65 70 20 32 29 0a 09 20 20 20 20 20 29 29  leep 2)..     ))
5ad0: 0a 20 20 20 20 20 20 20 74 65 73 74 2d 6e 61 6d  .       test-nam
5ae0: 65 73 29 0a 20 20 20 20 20 20 3b 3b 20 28 72 75  es).      ;; (ru
5af0: 6e 2d 77 61 69 74 69 6e 67 2d 74 65 73 74 73 20  n-waiting-tests 
5b00: 64 62 29 0a 20 20 20 20 20 20 28 69 66 20 28 61  db).      (if (a
5b10: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 6b 65  rgs:get-arg "-ke
5b20: 65 70 67 6f 69 6e 67 22 29 0a 09 20 20 28 6c 65  epgoing")..  (le
5b30: 74 20 28 28 65 73 74 72 65 6d 20 28 64 62 3a 65  t ((estrem (db:e
5b40: 73 74 69 6d 61 74 65 64 2d 74 65 73 74 73 2d 72  stimated-tests-r
5b50: 65 6d 61 69 6e 69 6e 67 20 64 62 20 72 75 6e 2d  emaining db run-
5b60: 69 64 29 29 29 0a 09 20 20 20 20 28 69 66 20 28  id)))..    (if (
5b70: 61 6e 64 20 28 3e 20 65 73 74 72 65 6d 20 30 29  and (> estrem 0)
5b80: 0a 09 09 20 20 20 20 20 28 65 71 3f 20 2a 67 6c  ...     (eq? *gl
5b90: 6f 62 61 6c 65 78 69 74 73 74 61 74 75 73 2a 20  obalexitstatus* 
5ba0: 30 29 29 0a 09 09 28 62 65 67 69 6e 0a 09 09 20  0))...(begin... 
5bb0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20   (debug:print 1 
5bc0: 22 4b 65 65 70 20 67 6f 69 6e 67 2c 20 65 73 74  "Keep going, est
5bd0: 69 6d 61 74 65 64 20 22 20 65 73 74 72 65 6d 20  imated " estrem 
5be0: 22 20 74 65 73 74 73 20 72 65 6d 61 69 6e 69 6e  " tests remainin
5bf0: 67 20 74 6f 20 72 75 6e 2c 20 77 69 6c 6c 20 63  g to run, will c
5c00: 6f 6e 74 69 6e 75 65 20 69 6e 20 33 20 73 65 63  ontinue in 3 sec
5c10: 6f 6e 64 73 20 2e 2e 2e 22 29 0a 09 09 20 20 28  onds ...")...  (
5c20: 73 6c 65 65 70 20 33 29 0a 09 09 20 20 28 72 75  sleep 3)...  (ru
5c30: 6e 2d 77 61 69 74 69 6e 67 2d 74 65 73 74 73 20  n-waiting-tests 
5c40: 64 62 29 0a 09 09 20 20 28 6c 6f 6f 70 20 28 2b  db)...  (loop (+
5c50: 20 6e 75 6d 74 69 6d 65 73 20 31 29 29 29 29 29   numtimes 1)))))
5c60: 29 29 29 29 0a 09 20 20 20 0a 3b 3b 20 56 45 52  ))))..   .;; VER
5c70: 59 20 49 4e 45 46 46 49 43 49 45 4e 54 21 20 4d  Y INEFFICIENT! M
5c80: 6f 76 65 20 73 74 75 66 66 20 74 68 61 74 20 73  ove stuff that s
5c90: 68 6f 75 6c 64 20 62 65 20 64 6f 6e 65 20 6f 6e  hould be done on
5ca0: 63 65 20 75 70 20 74 6f 20 63 61 6c 6c 69 6e 67  ce up to calling
5cb0: 20 70 72 6f 63 0a 28 64 65 66 69 6e 65 20 28 72   proc.(define (r
5cc0: 75 6e 2d 6f 6e 65 2d 74 65 73 74 20 64 62 20 72  un-one-test db r
5cd0: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
5ce0: 6b 65 79 76 61 6c 6c 73 74 29 0a 20 20 28 64 65  keyvallst).  (de
5cf0: 62 75 67 3a 70 72 69 6e 74 20 31 20 22 4c 61 75  bug:print 1 "Lau
5d00: 6e 63 68 69 6e 67 20 74 65 73 74 20 22 20 74 65  nching test " te
5d10: 73 74 2d 6e 61 6d 65 29 0a 20 20 3b 3b 20 41 6c  st-name).  ;; Al
5d20: 6c 20 74 68 65 73 65 20 76 61 72 73 20 6d 69 67  l these vars mig
5d30: 68 74 20 62 65 20 72 65 66 65 72 65 6e 63 65 64  ht be referenced
5d40: 20 62 79 20 74 68 65 20 74 65 73 74 63 6f 6e 66   by the testconf
5d50: 69 67 20 66 69 6c 65 20 72 65 61 64 65 72 0a 20  ig file reader. 
5d60: 20 28 73 65 74 65 6e 76 20 22 4d 54 5f 54 45 53   (setenv "MT_TES
5d70: 54 5f 4e 41 4d 45 22 20 74 65 73 74 2d 6e 61 6d  T_NAME" test-nam
5d80: 65 29 20 3b 3b 20 0a 20 20 28 73 65 74 65 6e 76  e) ;; .  (setenv
5d90: 20 22 4d 54 5f 52 55 4e 4e 41 4d 45 22 20 20 20   "MT_RUNNAME"   
5da0: 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 3a  (args:get-arg ":
5db0: 72 75 6e 6e 61 6d 65 22 29 29 0a 20 20 28 73 65  runname")).  (se
5dc0: 74 2d 6d 65 67 61 74 65 73 74 2d 65 6e 76 2d 76  t-megatest-env-v
5dd0: 61 72 73 20 64 62 20 72 75 6e 2d 69 64 29 20 3b  ars db run-id) ;
5de0: 3b 20 74 68 65 73 65 20 6d 61 79 20 62 65 20 6e  ; these may be n
5df0: 65 65 64 65 64 20 62 79 20 74 68 65 20 6c 61 75  eeded by the lau
5e00: 6e 63 68 69 6e 67 20 70 72 6f 63 65 73 73 0a 20  nching process. 
5e10: 20 28 63 68 61 6e 67 65 2d 64 69 72 65 63 74 6f   (change-directo
5e20: 72 79 20 2a 74 6f 70 70 61 74 68 2a 29 0a 20 20  ry *toppath*).  
5e30: 28 6c 65 74 2a 20 28 28 74 65 73 74 2d 70 61 74  (let* ((test-pat
5e40: 68 20 20 20 20 28 63 6f 6e 63 20 2a 74 6f 70 70  h    (conc *topp
5e50: 61 74 68 2a 20 22 2f 74 65 73 74 73 2f 22 20 74  ath* "/tests/" t
5e60: 65 73 74 2d 6e 61 6d 65 29 29 0a 09 20 28 74 65  est-name)).. (te
5e70: 73 74 2d 63 6f 6e 66 69 67 66 20 28 63 6f 6e 63  st-configf (conc
5e80: 20 74 65 73 74 2d 70 61 74 68 20 22 2f 74 65 73   test-path "/tes
5e90: 74 63 6f 6e 66 69 67 22 29 29 0a 09 20 28 74 65  tconfig")).. (te
5ea0: 73 74 65 78 69 73 74 73 20 20 20 28 61 6e 64 20  stexists   (and 
5eb0: 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 74 65  (file-exists? te
5ec0: 73 74 2d 63 6f 6e 66 69 67 66 29 28 66 69 6c 65  st-configf)(file
5ed0: 2d 72 65 61 64 2d 61 63 63 65 73 73 3f 20 74 65  -read-access? te
5ee0: 73 74 2d 63 6f 6e 66 69 67 66 29 29 29 0a 09 20  st-configf))).. 
5ef0: 28 74 65 73 74 2d 63 6f 6e 66 20 20 20 20 28 69  (test-conf    (i
5f00: 66 20 74 65 73 74 65 78 69 73 74 73 20 28 72 65  f testexists (re
5f10: 61 64 2d 63 6f 6e 66 69 67 20 74 65 73 74 2d 63  ad-config test-c
5f20: 6f 6e 66 69 67 66 20 23 66 20 23 74 29 20 28 6d  onfigf #f #t) (m
5f30: 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29  ake-hash-table))
5f40: 29 0a 09 20 28 77 61 69 74 6f 6e 20 20 20 20 20  ).. (waiton     
5f50: 20 20 28 6c 65 74 20 28 28 77 20 28 63 6f 6e 66    (let ((w (conf
5f60: 69 67 2d 6c 6f 6f 6b 75 70 20 74 65 73 74 2d 63  ig-lookup test-c
5f70: 6f 6e 66 20 22 72 65 71 75 69 72 65 6d 65 6e 74  onf "requirement
5f80: 73 22 20 22 77 61 69 74 6f 6e 22 29 29 29 0a 09  s" "waiton")))..
5f90: 09 09 20 28 69 66 20 28 73 74 72 69 6e 67 3f 20  .. (if (string? 
5fa0: 77 29 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20  w)(string-split 
5fb0: 77 29 27 28 29 29 29 29 0a 09 20 28 74 61 67 73  w)'()))).. (tags
5fc0: 20 20 20 20 20 20 20 20 20 28 6c 65 74 20 28 28           (let ((
5fd0: 74 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70  t (config-lookup
5fe0: 20 74 65 73 74 2d 63 6f 6e 66 20 22 73 65 74 75   test-conf "setu
5ff0: 70 22 20 22 74 61 67 73 22 29 29 29 0a 09 09 09  p" "tags")))....
6000: 20 3b 3b 20 77 65 20 77 61 6e 74 20 6f 75 72 20   ;; we want our 
6010: 74 61 67 73 20 74 6f 20 62 65 20 73 65 70 61 72  tags to be separ
6020: 61 74 65 64 20 62 79 20 63 6f 6d 6d 61 73 20 61  ated by commas a
6030: 6e 64 20 66 75 6c 6c 79 20 64 65 6c 69 6d 69 74  nd fully delimit
6040: 65 64 20 62 79 20 63 6f 6d 6d 61 73 0a 09 09 09  ed by commas....
6050: 20 3b 3b 20 73 6f 20 74 68 61 74 20 71 75 65 72   ;; so that quer
6060: 69 65 73 20 77 69 74 68 20 22 6c 69 6b 65 22 20  ies with "like" 
6070: 63 61 6e 20 74 69 65 20 74 6f 20 74 68 65 20 63  can tie to the c
6080: 6f 6d 6d 61 73 20 61 74 20 65 69 74 68 65 72 20  ommas at either 
6090: 65 6e 64 20 6f 66 20 65 61 63 68 20 74 61 67 0a  end of each tag.
60a0: 09 09 09 20 3b 3b 20 77 68 69 6c 65 20 61 6c 73  ... ;; while als
60b0: 6f 20 61 6c 6c 6f 77 69 6e 67 20 74 68 65 20 65  o allowing the e
60c0: 6e 64 20 75 73 65 72 20 74 6f 20 66 72 65 65 6c  nd user to freel
60d0: 79 20 75 73 65 20 73 70 61 63 65 73 20 61 6e 64  y use spaces and
60e0: 20 63 6f 6d 6d 61 73 20 74 6f 20 73 65 70 61 72   commas to separ
60f0: 61 74 65 20 74 61 67 73 0a 09 09 09 20 28 69 66  ate tags.... (if
6100: 20 28 73 74 72 69 6e 67 3f 20 74 29 28 73 74 72   (string? t)(str
6110: 69 6e 67 2d 73 75 62 73 74 69 74 75 74 65 20 28  ing-substitute (
6120: 72 65 67 65 78 70 20 22 5b 2c 5c 5c 73 5d 2b 22  regexp "[,\\s]+"
6130: 29 20 22 2c 22 20 28 63 6f 6e 63 20 22 2c 22 20  ) "," (conc "," 
6140: 74 20 22 2c 22 29 20 23 74 29 0a 09 09 09 20 20  t ",") #t)....  
6150: 20 20 20 27 28 29 29 29 29 29 0a 20 20 20 20 28     '())))).    (
6160: 69 66 20 28 6e 6f 74 20 74 65 73 74 65 78 69 73  if (not testexis
6170: 74 73 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 28  ts)..(begin..  (
6180: 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45  debug:print 0 "E
6190: 52 52 4f 52 3a 20 43 61 6e 27 74 20 66 69 6e 64  RROR: Can't find
61a0: 20 63 6f 6e 66 69 67 20 66 69 6c 65 20 22 20 74   config file " t
61b0: 65 73 74 2d 63 6f 6e 66 69 67 66 29 0a 09 20 20  est-configf)..  
61c0: 28 65 78 69 74 20 32 29 29 0a 09 3b 3b 20 70 75  (exit 2))..;; pu
61d0: 74 20 74 6f 70 20 76 61 72 73 20 69 6e 74 6f 20  t top vars into 
61e0: 63 6f 6e 76 65 6e 69 65 6e 74 20 76 61 72 69 61  convenient varia
61f0: 62 6c 65 73 20 61 6e 64 20 6f 70 65 6e 20 74 68  bles and open th
6200: 65 20 64 62 0a 09 28 6c 65 74 2a 20 28 3b 3b 20  e db..(let* (;; 
6210: 64 62 20 69 73 20 61 6c 77 61 79 73 20 61 74 20  db is always at 
6220: 2a 74 6f 70 70 61 74 68 2a 2f 64 62 2f 6d 65 67  *toppath*/db/meg
6230: 61 74 65 73 74 2e 64 62 0a 09 20 20 20 20 20 20  atest.db..      
6240: 20 28 69 74 65 6d 73 20 20 20 20 20 20 20 28 68   (items       (h
6250: 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65  ash-table-ref/de
6260: 66 61 75 6c 74 20 74 65 73 74 2d 63 6f 6e 66 20  fault test-conf 
6270: 22 69 74 65 6d 73 22 20 27 28 29 29 29 0a 09 20  "items" '())).. 
6280: 20 20 20 20 20 20 28 69 74 65 6d 73 74 61 62 6c        (itemstabl
6290: 65 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72  e  (hash-table-r
62a0: 65 66 2f 64 65 66 61 75 6c 74 20 74 65 73 74 2d  ef/default test-
62b0: 63 6f 6e 66 20 22 69 74 65 6d 73 74 61 62 6c 65  conf "itemstable
62c0: 22 20 27 28 29 29 29 0a 09 20 20 20 20 20 20 20  " '()))..       
62d0: 28 61 6c 6c 69 74 65 6d 73 20 20 20 20 28 69 66  (allitems    (if
62e0: 20 28 6f 72 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f   (or (not (null?
62f0: 20 69 74 65 6d 73 29 29 28 6e 6f 74 20 28 6e 75   items))(not (nu
6300: 6c 6c 3f 20 69 74 65 6d 73 74 61 62 6c 65 29 29  ll? itemstable))
6310: 29 0a 09 09 09 09 28 61 70 70 65 6e 64 20 28 69  ).....(append (i
6320: 74 65 6d 2d 61 73 73 6f 63 2d 3e 69 74 65 6d 2d  tem-assoc->item-
6330: 6c 69 73 74 20 69 74 65 6d 73 29 0a 09 09 09 09  list items).....
6340: 09 28 69 74 65 6d 2d 74 61 62 6c 65 2d 3e 69 74  .(item-table->it
6350: 65 6d 2d 6c 69 73 74 20 69 74 65 6d 73 74 61 62  em-list itemstab
6360: 6c 65 29 29 0a 09 09 09 09 27 28 28 29 29 29 29  le)).....'(())))
6370: 20 3b 3b 20 61 20 6c 69 73 74 20 77 69 74 68 20   ;; a list with 
6380: 6f 6e 65 20 6e 75 6c 6c 20 6c 69 73 74 20 69 73  one null list is
6390: 20 61 20 74 65 73 74 20 77 69 74 68 20 6e 6f 20   a test with no 
63a0: 69 74 65 6d 73 0a 09 20 20 20 20 20 20 20 28 72  items..       (r
63b0: 75 6e 63 6f 6e 66 69 67 66 20 20 28 63 6f 6e 63  unconfigf  (conc
63c0: 20 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f 72 75    *toppath* "/ru
63d0: 6e 63 6f 6e 66 69 67 73 2e 63 6f 6e 66 69 67 22  nconfigs.config"
63e0: 29 29 29 0a 09 20 20 28 64 65 62 75 67 3a 70 72  )))..  (debug:pr
63f0: 69 6e 74 20 31 20 22 69 74 65 6d 73 3a 20 22 29  int 1 "items: ")
6400: 0a 09 20 20 28 69 66 20 28 3e 3d 20 2a 76 65 72  ..  (if (>= *ver
6410: 62 6f 73 69 74 79 2a 20 31 29 28 70 70 20 61 6c  bosity* 1)(pp al
6420: 6c 69 74 65 6d 73 29 29 0a 09 20 20 28 69 66 20  litems))..  (if 
6430: 28 3e 3d 20 2a 76 65 72 62 6f 73 69 74 79 2a 20  (>= *verbosity* 
6440: 35 29 0a 09 20 20 20 20 20 20 28 62 65 67 69 6e  5)..      (begin
6450: 0a 09 09 28 70 72 69 6e 74 20 22 69 74 65 6d 73  ...(print "items
6460: 3a 20 22 29 28 70 70 20 28 69 74 65 6d 2d 61 73  : ")(pp (item-as
6470: 73 6f 63 2d 3e 69 74 65 6d 2d 6c 69 73 74 20 69  soc->item-list i
6480: 74 65 6d 73 29 29 0a 09 09 28 70 72 69 6e 74 20  tems))...(print 
6490: 22 69 74 65 73 74 61 62 6c 65 3a 20 22 29 28 70  "itestable: ")(p
64a0: 70 20 28 69 74 65 6d 2d 74 61 62 6c 65 2d 3e 69  p (item-table->i
64b0: 74 65 6d 2d 6c 69 73 74 20 69 74 65 6d 73 74 61  tem-list itemsta
64c0: 62 6c 65 29 29 29 29 0a 09 20 20 28 69 66 20 28  ble))))..  (if (
64d0: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 6d  args:get-arg "-m
64e0: 22 29 0a 09 20 20 20 20 20 20 28 64 62 3a 73 65  ")..      (db:se
64f0: 74 2d 63 6f 6d 6d 65 6e 74 2d 66 6f 72 2d 72 75  t-comment-for-ru
6500: 6e 20 64 62 20 72 75 6e 2d 69 64 20 28 61 72 67  n db run-id (arg
6510: 73 3a 67 65 74 2d 61 72 67 20 22 2d 6d 22 29 29  s:get-arg "-m"))
6520: 29 0a 0a 09 20 20 3b 3b 20 48 65 72 65 20 69 73  )...  ;; Here is
6530: 20 77 68 65 72 65 20 74 68 65 20 74 65 73 74 5f   where the test_
6540: 6d 65 74 61 20 74 61 62 6c 65 20 69 73 20 62 65  meta table is be
6550: 73 74 20 75 70 64 61 74 65 64 0a 09 20 20 28 72  st updated..  (r
6560: 75 6e 73 3a 75 70 64 61 74 65 2d 74 65 73 74 5f  uns:update-test_
6570: 6d 65 74 61 20 64 62 20 74 65 73 74 2d 6e 61 6d  meta db test-nam
6580: 65 20 74 65 73 74 2d 63 6f 6e 66 29 0a 0a 09 20  e test-conf)... 
6590: 20 3b 3b 20 62 72 61 69 6e 64 65 61 64 20 77 6f   ;; braindead wo
65a0: 72 6b 2d 61 72 6f 75 6e 64 20 66 6f 72 20 70 6f  rk-around for po
65b0: 6f 72 6c 79 20 73 70 65 63 69 66 69 65 64 20 61  orly specified a
65c0: 6c 6c 69 74 65 6d 73 20 6c 69 73 74 20 42 55 47  llitems list BUG
65d0: 21 21 21 20 46 49 58 4d 45 0a 09 20 20 28 69 66  !!! FIXME..  (if
65e0: 20 28 6e 75 6c 6c 3f 20 61 6c 6c 69 74 65 6d 73   (null? allitems
65f0: 29 28 73 65 74 21 20 61 6c 6c 69 74 65 6d 73 20  )(set! allitems 
6600: 27 28 28 29 29 29 29 0a 09 20 20 28 6c 65 74 20  '(())))..  (let 
6610: 6c 6f 6f 70 20 28 28 69 74 65 6d 64 61 74 20 28  loop ((itemdat (
6620: 63 61 72 20 61 6c 6c 69 74 65 6d 73 29 29 0a 09  car allitems))..
6630: 09 20 20 20 20 20 28 74 61 6c 20 20 20 20 20 28  .     (tal     (
6640: 63 64 72 20 61 6c 6c 69 74 65 6d 73 29 29 29 0a  cdr allitems))).
6650: 09 20 20 20 20 3b 3b 20 28 6c 61 6d 62 64 61 20  .    ;; (lambda 
6660: 28 69 74 65 6d 64 61 74 29 20 3b 3b 3b 20 28 28  (itemdat) ;;; ((
6670: 72 69 70 65 6e 65 73 73 20 22 6f 76 65 72 72 69  ripeness "overri
6680: 70 65 22 29 20 28 74 65 6d 70 65 72 61 74 75 72  pe") (temperatur
6690: 65 20 22 63 6f 6f 6c 22 29 20 28 73 65 61 73 6f  e "cool") (seaso
66a0: 6e 20 22 73 75 6d 6d 65 72 22 29 29 0a 09 20 20  n "summer"))..  
66b0: 20 20 3b 3b 20 48 61 6e 64 6c 65 20 6c 69 73 74    ;; Handle list
66c0: 73 20 6f 66 20 69 74 65 6d 73 0a 09 20 20 20 20  s of items..    
66d0: 28 6c 65 74 2a 20 28 28 69 74 65 6d 2d 70 61 74  (let* ((item-pat
66e0: 68 20 20 20 20 20 28 69 74 65 6d 2d 6c 69 73 74  h     (item-list
66f0: 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74 29 29  ->path itemdat))
6700: 20 3b 3b 20 28 73 74 72 69 6e 67 2d 69 6e 74 65   ;; (string-inte
6710: 72 73 70 65 72 73 65 20 28 6d 61 70 20 63 61 64  rsperse (map cad
6720: 72 20 69 74 65 6d 64 61 74 29 20 22 2f 22 29 29  r itemdat) "/"))
6730: 0a 09 09 20 20 20 28 6e 65 77 2d 74 65 73 74 2d  ...   (new-test-
6740: 70 61 74 68 20 28 73 74 72 69 6e 67 2d 69 6e 74  path (string-int
6750: 65 72 73 70 65 72 73 65 20 28 63 6f 6e 73 20 74  ersperse (cons t
6760: 65 73 74 2d 70 61 74 68 20 28 6d 61 70 20 63 61  est-path (map ca
6770: 64 72 20 69 74 65 6d 64 61 74 29 29 20 22 2f 22  dr itemdat)) "/"
6780: 29 29 0a 09 09 20 20 20 28 6e 65 77 2d 74 65 73  ))...   (new-tes
6790: 74 2d 6e 61 6d 65 20 28 69 66 20 28 65 71 75 61  t-name (if (equa
67a0: 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29  l? item-path "")
67b0: 20 74 65 73 74 2d 6e 61 6d 65 20 28 63 6f 6e 63   test-name (conc
67c0: 20 74 65 73 74 2d 6e 61 6d 65 20 22 2f 22 20 69   test-name "/" i
67d0: 74 65 6d 2d 70 61 74 68 29 29 29 20 3b 3b 20 6a  tem-path))) ;; j
67e0: 75 73 74 20 6e 65 65 64 20 69 74 20 74 6f 20 62  ust need it to b
67f0: 65 20 75 6e 69 71 75 65 0a 09 09 20 20 20 28 74  e unique...   (t
6800: 65 73 74 64 61 74 20 20 20 23 66 29 0a 09 09 20  estdat   #f)... 
6810: 20 20 28 6e 75 6d 2d 72 75 6e 6e 69 6e 67 20 28    (num-running (
6820: 64 62 3a 67 65 74 2d 63 6f 75 6e 74 2d 74 65 73  db:get-count-tes
6830: 74 73 2d 72 75 6e 6e 69 6e 67 20 64 62 29 29 0a  ts-running db)).
6840: 09 09 20 20 20 28 6d 61 78 2d 63 6f 6e 63 75 72  ..   (max-concur
6850: 72 65 6e 74 2d 6a 6f 62 73 20 28 63 6f 6e 66 69  rent-jobs (confi
6860: 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67  g-lookup *config
6870: 64 61 74 2a 20 22 73 65 74 75 70 22 20 22 6d 61  dat* "setup" "ma
6880: 78 5f 63 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f 62  x_concurrent_job
6890: 73 22 29 29 0a 09 09 20 20 20 28 70 61 72 65 6e  s"))...   (paren
68a0: 74 2d 74 65 73 74 20 28 61 6e 64 20 28 6e 6f 74  t-test (and (not
68b0: 20 28 6e 75 6c 6c 3f 20 69 74 65 6d 73 29 29 28   (null? items))(
68c0: 65 71 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68  equal? item-path
68d0: 20 22 22 29 29 29 0a 09 09 20 20 20 28 73 69 6e   "")))...   (sin
68e0: 67 6c 65 2d 74 65 73 74 20 28 61 6e 64 20 28 6e  gle-test (and (n
68f0: 75 6c 6c 3f 20 69 74 65 6d 73 29 20 28 65 71 75  ull? items) (equ
6900: 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 22  al? item-path ""
6910: 29 29 29 0a 09 09 20 20 20 28 69 74 65 6d 2d 74  )))...   (item-t
6920: 65 73 74 20 20 20 28 6e 6f 74 20 28 65 71 75 61  est   (not (equa
6930: 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29  l? item-path "")
6940: 29 29 29 0a 09 20 20 20 20 20 20 28 64 65 62 75  )))..      (debu
6950: 67 3a 70 72 69 6e 74 20 33 20 22 6d 61 78 2d 63  g:print 3 "max-c
6960: 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 3a 20  oncurrent-jobs: 
6970: 22 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74  " max-concurrent
6980: 2d 6a 6f 62 73 20 22 2c 20 6e 75 6d 2d 72 75 6e  -jobs ", num-run
6990: 6e 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e  ning: " num-runn
69a0: 69 6e 67 29 0a 09 20 20 20 20 20 20 28 69 66 20  ing)..      (if 
69b0: 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f  (runs:can-run-mo
69c0: 72 65 2d 74 65 73 74 73 20 64 62 29 0a 09 09 20  re-tests db)... 
69d0: 20 28 62 65 67 69 6e 0a 09 09 20 20 20 20 28 6c   (begin...    (l
69e0: 65 74 20 6c 6f 6f 70 32 20 28 28 74 73 20 28 64  et loop2 ((ts (d
69f0: 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20  b:get-test-info 
6a00: 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e  db run-id test-n
6a10: 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29 20  ame item-path)) 
6a20: 3b 3b 20 23 66 29 0a 09 09 09 09 28 63 74 20 30  ;; #f).....(ct 0
6a30: 29 29 0a 09 09 20 20 20 20 20 20 28 69 66 20 28  ))...      (if (
6a40: 61 6e 64 20 28 6e 6f 74 20 74 73 29 0a 09 09 09  and (not ts)....
6a50: 20 20 20 20 20 20 20 28 3c 20 63 74 20 31 30 29         (< ct 10)
6a60: 29 0a 09 09 09 20 20 28 62 65 67 69 6e 0a 09 09  )....  (begin...
6a70: 09 20 20 20 20 28 72 65 67 69 73 74 65 72 2d 74  .    (register-t
6a80: 65 73 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65  est db run-id te
6a90: 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74  st-name item-pat
6aa0: 68 29 0a 09 09 09 20 20 20 20 28 64 62 3a 74 65  h)....    (db:te
6ab0: 73 74 2d 73 65 74 2d 63 6f 6d 6d 65 6e 74 20 64  st-set-comment d
6ac0: 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  b run-id test-na
6ad0: 6d 65 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29  me item-path "")
6ae0: 0a 09 09 09 20 20 20 20 28 6c 6f 6f 70 32 20 28  ....    (loop2 (
6af0: 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f  db:get-test-info
6b00: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d   db run-id test-
6b10: 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 0a  name item-path).
6b20: 09 09 09 09 20 20 20 28 2b 20 63 74 20 31 29 29  ....   (+ ct 1))
6b30: 29 0a 09 09 09 20 20 28 69 66 20 74 73 0a 09 09  )....  (if ts...
6b40: 09 20 20 20 20 20 20 28 73 65 74 21 20 74 65 73  .      (set! tes
6b50: 74 64 61 74 20 74 73 29 0a 09 09 09 20 20 20 20  tdat ts)....    
6b60: 20 20 28 62 65 67 69 6e 0a 09 09 09 09 28 64 65    (begin.....(de
6b70: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52  bug:print 0 "WAR
6b80: 4e 49 4e 47 3a 20 43 6f 75 6c 64 6e 27 74 20 72  NING: Couldn't r
6b90: 65 67 69 73 74 65 72 20 74 65 73 74 20 22 20 74  egister test " t
6ba0: 65 73 74 2d 6e 61 6d 65 20 22 20 77 69 74 68 20  est-name " with 
6bb0: 69 74 65 6d 20 70 61 74 68 20 22 20 69 74 65 6d  item path " item
6bc0: 2d 70 61 74 68 20 22 2c 20 73 6b 69 70 70 69 6e  -path ", skippin
6bd0: 67 22 29 0a 09 09 09 09 28 69 66 20 28 6e 6f 74  g").....(if (not
6be0: 20 28 6e 75 6c 6c 3f 20 74 61 6c 29 29 0a 09 09   (null? tal))...
6bf0: 09 09 20 20 20 20 28 6c 6f 6f 70 20 28 63 61 72  ..    (loop (car
6c00: 20 74 61 6c 29 28 63 64 72 20 74 61 6c 29 29 29   tal)(cdr tal)))
6c10: 29 29 29 29 0a 09 09 20 20 20 20 28 63 68 61 6e  ))))...    (chan
6c20: 67 65 2d 64 69 72 65 63 74 6f 72 79 20 74 65 73  ge-directory tes
6c30: 74 2d 70 61 74 68 29 0a 09 09 20 20 20 20 3b 3b  t-path)...    ;;
6c40: 20 74 68 69 73 20 62 6c 6f 63 6b 20 69 73 20 68   this block is h
6c50: 65 72 65 20 6f 6e 6c 79 20 74 6f 20 69 6e 66 6f  ere only to info
6c60: 72 6d 20 74 68 65 20 75 73 65 72 20 65 61 72 6c  rm the user earl
6c70: 79 20 6f 6e 0a 09 09 20 20 20 20 28 69 66 20 28  y on...    (if (
6c80: 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 72 75 6e  file-exists? run
6c90: 63 6f 6e 66 69 67 66 29 0a 09 09 09 28 73 65 74  configf)....(set
6ca0: 75 70 2d 65 6e 76 2d 64 65 66 61 75 6c 74 73 20  up-env-defaults 
6cb0: 64 62 20 72 75 6e 63 6f 6e 66 69 67 66 20 72 75  db runconfigf ru
6cc0: 6e 2d 69 64 20 2a 61 6c 72 65 61 64 79 2d 73 65  n-id *already-se
6cd0: 65 6e 2d 72 75 6e 63 6f 6e 66 69 67 2d 69 6e 66  en-runconfig-inf
6ce0: 6f 2a 29 0a 09 09 09 28 64 65 62 75 67 3a 70 72  o*)....(debug:pr
6cf0: 69 6e 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20  int 0 "WARNING: 
6d00: 59 6f 75 20 64 6f 20 6e 6f 74 20 68 61 76 65 20  You do not have 
6d10: 61 20 72 75 6e 20 63 6f 6e 66 69 67 20 66 69 6c  a run config fil
6d20: 65 3a 20 22 20 72 75 6e 63 6f 6e 66 69 67 66 29  e: " runconfigf)
6d30: 29 0a 09 09 20 20 20 20 28 64 65 62 75 67 3a 70  )...    (debug:p
6d40: 72 69 6e 74 20 34 20 22 72 75 6e 2d 69 64 3a 20  rint 4 "run-id: 
6d50: 22 20 72 75 6e 2d 69 64 20 22 20 74 65 73 74 2d  " run-id " test-
6d60: 6e 61 6d 65 3a 20 22 20 74 65 73 74 2d 6e 61 6d  name: " test-nam
6d70: 65 20 22 20 69 74 65 6d 2d 70 61 74 68 3a 20 22  e " item-path: "
6d80: 20 69 74 65 6d 2d 70 61 74 68 20 22 20 74 65 73   item-path " tes
6d90: 74 64 61 74 3a 20 22 20 28 74 65 73 74 3a 67 65  tdat: " (test:ge
6da0: 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61 74  t-status testdat
6db0: 29 20 22 20 74 65 73 74 2d 73 74 61 74 65 3a 20  ) " test-state: 
6dc0: 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74  " (test:get-stat
6dd0: 65 20 74 65 73 74 64 61 74 29 29 0a 09 09 20 20  e testdat))...  
6de0: 20 20 28 63 61 73 65 20 28 69 66 20 28 61 72 67    (case (if (arg
6df0: 73 3a 67 65 74 2d 61 72 67 20 22 2d 66 6f 72 63  s:get-arg "-forc
6e00: 65 22 29 0a 09 09 09 20 20 20 20 20 20 27 4e 4f  e")....      'NO
6e10: 54 5f 53 54 41 52 54 45 44 0a 09 09 09 20 20 20  T_STARTED....   
6e20: 20 20 20 28 69 66 20 74 65 73 74 64 61 74 0a 09     (if testdat..
6e30: 09 09 09 20 20 28 73 74 72 69 6e 67 2d 3e 73 79  ...  (string->sy
6e40: 6d 62 6f 6c 20 28 74 65 73 74 3a 67 65 74 2d 73  mbol (test:get-s
6e50: 74 61 74 65 20 74 65 73 74 64 61 74 29 29 0a 09  tate testdat))..
6e60: 09 09 09 20 20 27 66 61 69 6c 65 64 2d 74 6f 2d  ...  'failed-to-
6e70: 69 6e 73 65 72 74 29 29 0a 09 09 20 20 20 20 20  insert))...     
6e80: 20 28 28 66 61 69 6c 65 64 2d 74 6f 2d 69 6e 73   ((failed-to-ins
6e90: 65 72 74 29 0a 09 09 20 20 20 20 20 20 20 28 64  ert)...       (d
6ea0: 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52  ebug:print 0 "ER
6eb0: 52 4f 52 3a 20 46 61 69 6c 65 64 20 74 6f 20 69  ROR: Failed to i
6ec0: 6e 73 65 72 74 20 74 68 65 20 72 65 63 6f 72 64  nsert the record
6ed0: 20 69 6e 74 6f 20 74 68 65 20 64 62 22 29 29 0a   into the db")).
6ee0: 09 09 20 20 20 20 20 20 28 28 4e 4f 54 5f 53 54  ..      ((NOT_ST
6ef0: 41 52 54 45 44 20 43 4f 4d 50 4c 45 54 45 44 29  ARTED COMPLETED)
6f00: 0a 09 09 20 20 20 20 20 20 20 28 64 65 62 75 67  ...       (debug
6f10: 3a 70 72 69 6e 74 20 36 20 22 47 6f 74 20 68 65  :print 6 "Got he
6f20: 72 65 2c 20 22 20 28 74 65 73 74 3a 67 65 74 2d  re, " (test:get-
6f30: 73 74 61 74 65 20 74 65 73 74 64 61 74 29 29 0a  state testdat)).
6f40: 09 09 20 20 20 20 20 20 20 28 6c 65 74 20 28 28  ..       (let ((
6f50: 72 75 6e 66 6c 61 67 20 23 66 29 29 0a 09 09 09  runflag #f))....
6f60: 20 28 63 6f 6e 64 0a 09 09 09 20 20 3b 3b 20 69   (cond....  ;; i
6f70: 2e 65 2e 20 74 68 69 73 20 69 73 20 74 68 65 20  .e. this is the 
6f80: 70 61 72 65 6e 74 20 74 65 73 74 20 74 6f 20 61  parent test to a
6f90: 20 73 75 69 74 65 20 6f 66 20 69 74 65 6d 73 2c   suite of items,
6fa0: 20 6e 65 76 65 72 20 22 72 75 6e 22 20 69 74 0a   never "run" it.
6fb0: 09 09 09 20 20 28 70 61 72 65 6e 74 2d 74 65 73  ...  (parent-tes
6fc0: 74 0a 09 09 09 20 20 20 28 73 65 74 21 20 72 75  t....   (set! ru
6fd0: 6e 66 6c 61 67 20 23 66 29 29 0a 09 09 09 20 20  nflag #f))....  
6fe0: 3b 3b 20 2d 66 6f 72 63 65 2c 20 72 75 6e 20 6e  ;; -force, run n
6ff0: 6f 20 6d 61 74 74 65 72 20 77 68 61 74 0a 09 09  o matter what...
7000: 09 20 20 28 28 61 72 67 73 3a 67 65 74 2d 61 72  .  ((args:get-ar
7010: 67 20 22 2d 66 6f 72 63 65 22 29 28 73 65 74 21  g "-force")(set!
7020: 20 72 75 6e 66 6c 61 67 20 23 74 29 29 0a 09 09   runflag #t))...
7030: 09 20 20 3b 3b 20 4e 4f 54 5f 53 54 41 52 54 45  .  ;; NOT_STARTE
7040: 44 2c 20 72 75 6e 20 6e 6f 20 6d 61 74 74 65 72  D, run no matter
7050: 20 77 68 61 74 0a 09 09 09 20 20 28 28 65 71 75   what....  ((equ
7060: 61 6c 3f 20 28 74 65 73 74 3a 67 65 74 2d 73 74  al? (test:get-st
7070: 61 74 65 20 74 65 73 74 64 61 74 29 20 22 4e 4f  ate testdat) "NO
7080: 54 5f 53 54 41 52 54 45 44 22 29 28 73 65 74 21  T_STARTED")(set!
7090: 20 72 75 6e 66 6c 61 67 20 23 74 29 29 0a 09 09   runflag #t))...
70a0: 09 20 20 3b 3b 20 6e 6f 74 20 2d 72 65 72 75 6e  .  ;; not -rerun
70b0: 20 61 6e 64 20 50 41 53 53 2c 20 57 41 52 4e 20   and PASS, WARN 
70c0: 6f 72 20 43 48 45 43 4b 2c 20 64 6f 20 6e 6f 20  or CHECK, do no 
70d0: 72 75 6e 0a 09 09 09 20 20 28 28 61 6e 64 20 28  run....  ((and (
70e0: 6f 72 20 28 6e 6f 74 20 28 61 72 67 73 3a 67 65  or (not (args:ge
70f0: 74 2d 61 72 67 20 22 2d 72 65 72 75 6e 22 29 29  t-arg "-rerun"))
7100: 0a 09 09 09 09 20 20 20 20 28 61 72 67 73 3a 67  .....    (args:g
7110: 65 74 2d 61 72 67 20 22 2d 6b 65 65 70 67 6f 69  et-arg "-keepgoi
7120: 6e 67 22 29 29 0a 09 09 09 09 28 6d 65 6d 62 65  ng")).....(membe
7130: 72 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74  r (test:get-stat
7140: 75 73 20 74 65 73 74 64 61 74 29 20 27 28 22 50  us testdat) '("P
7150: 41 53 53 22 20 22 57 41 52 4e 22 20 22 43 48 45  ASS" "WARN" "CHE
7160: 43 4b 22 29 29 29 0a 09 09 09 20 20 20 28 73 65  CK")))....   (se
7170: 74 21 20 72 75 6e 66 6c 61 67 20 23 66 29 29 0a  t! runflag #f)).
7180: 09 09 09 20 20 3b 3b 20 2d 72 65 72 75 6e 20 61  ...  ;; -rerun a
7190: 6e 64 20 73 74 61 74 75 73 20 69 73 20 6f 6e 65  nd status is one
71a0: 20 6f 66 20 74 68 65 20 73 70 65 63 69 66 65 64   of the specifed
71b0: 2c 20 72 75 6e 20 69 74 0a 09 09 09 20 20 28 28  , run it....  ((
71c0: 61 6e 64 20 28 61 72 67 73 3a 67 65 74 2d 61 72  and (args:get-ar
71d0: 67 20 22 2d 72 65 72 75 6e 22 29 0a 09 09 09 09  g "-rerun").....
71e0: 28 6c 65 74 20 28 28 72 65 72 75 6e 6c 73 74 20  (let ((rerunlst 
71f0: 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 28 61  (string-split (a
7200: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65  rgs:get-arg "-re
7210: 72 75 6e 22 29 20 22 2c 22 29 29 29 20 3b 3b 20  run") ","))) ;; 
7220: 46 41 49 4c 2c 0a 09 09 09 09 20 20 28 6d 65 6d  FAIL,.....  (mem
7230: 62 65 72 20 28 74 65 73 74 3a 67 65 74 2d 73 74  ber (test:get-st
7240: 61 74 75 73 20 74 65 73 74 64 61 74 29 20 72 65  atus testdat) re
7250: 72 75 6e 6c 73 74 29 29 29 0a 09 09 09 20 20 20  runlst)))....   
7260: 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 74  (set! runflag #t
7270: 29 29 0a 09 09 09 20 20 3b 3b 20 2d 6b 65 65 70  ))....  ;; -keep
7280: 67 6f 69 6e 67 2c 20 64 6f 20 6e 6f 74 20 72 65  going, do not re
7290: 72 75 6e 20 46 41 49 4c 0a 09 09 09 20 20 28 28  run FAIL....  ((
72a0: 61 6e 64 20 28 61 72 67 73 3a 67 65 74 2d 61 72  and (args:get-ar
72b0: 67 20 22 2d 6b 65 65 70 67 6f 69 6e 67 22 29 0a  g "-keepgoing").
72c0: 09 09 09 09 28 6d 65 6d 62 65 72 20 28 74 65 73  ....(member (tes
72d0: 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73  t:get-status tes
72e0: 74 64 61 74 29 20 27 28 22 46 41 49 4c 22 29 29  tdat) '("FAIL"))
72f0: 29 0a 09 09 09 20 20 20 28 73 65 74 21 20 72 75  )....   (set! ru
7300: 6e 66 6c 61 67 20 23 66 29 29 0a 09 09 09 20 20  nflag #f))....  
7310: 28 28 61 6e 64 20 28 6e 6f 74 20 28 61 72 67 73  ((and (not (args
7320: 3a 67 65 74 2d 61 72 67 20 22 2d 72 65 72 75 6e  :get-arg "-rerun
7330: 22 29 29 0a 09 09 09 09 28 6d 65 6d 62 65 72 20  ")).....(member 
7340: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73  (test:get-status
7350: 20 74 65 73 74 64 61 74 29 20 27 28 22 46 41 49   testdat) '("FAI
7360: 4c 22 20 22 6e 2f 61 22 29 29 29 0a 09 09 09 20  L" "n/a"))).... 
7370: 20 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20    (set! runflag 
7380: 23 74 29 29 0a 09 09 09 20 20 28 65 6c 73 65 20  #t))....  (else 
7390: 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 66  (set! runflag #f
73a0: 29 29 29 0a 09 09 09 20 28 64 65 62 75 67 3a 70  ))).... (debug:p
73b0: 72 69 6e 74 20 36 20 22 52 55 4e 4e 49 4e 47 20  rint 6 "RUNNING 
73c0: 3d 3e 20 72 75 6e 66 6c 61 67 3a 20 22 20 72 75  => runflag: " ru
73d0: 6e 66 6c 61 67 20 22 20 53 54 41 54 45 3a 20 22  nflag " STATE: "
73e0: 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65   (test:get-state
73f0: 20 74 65 73 74 64 61 74 29 20 22 20 53 54 41 54   testdat) " STAT
7400: 55 53 3a 20 22 20 28 74 65 73 74 3a 67 65 74 2d  US: " (test:get-
7410: 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29 29  status testdat))
7420: 0a 09 09 09 20 28 69 66 20 28 6e 6f 74 20 72 75  .... (if (not ru
7430: 6e 66 6c 61 67 29 0a 09 09 09 20 20 20 20 20 28  nflag)....     (
7440: 69 66 20 28 6e 6f 74 20 70 61 72 65 6e 74 2d 74  if (not parent-t
7450: 65 73 74 29 0a 09 09 09 09 20 28 64 65 62 75 67  est)..... (debug
7460: 3a 70 72 69 6e 74 20 31 20 22 4e 4f 54 45 3a 20  :print 1 "NOTE: 
7470: 4e 6f 74 20 73 74 61 72 74 69 6e 67 20 74 65 73  Not starting tes
7480: 74 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d  t " new-test-nam
7490: 65 20 22 20 61 73 20 69 74 20 69 73 20 73 74 61  e " as it is sta
74a0: 74 65 20 5c 22 43 4f 4d 50 4c 45 54 45 44 5c 22  te \"COMPLETED\"
74b0: 20 61 6e 64 20 73 74 61 74 75 73 20 5c 22 22 20   and status \"" 
74c0: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73  (test:get-status
74d0: 20 74 65 73 74 64 61 74 29 20 22 5c 22 2c 20 75   testdat) "\", u
74e0: 73 65 20 2d 66 6f 72 63 65 20 74 6f 20 6f 76 65  se -force to ove
74f0: 72 72 69 64 65 22 29 29 0a 09 09 09 20 20 20 20  rride"))....    
7500: 20 28 6c 65 74 2a 20 28 28 67 65 74 2d 70 72 65   (let* ((get-pre
7510: 72 65 71 73 2d 63 6d 64 20 28 6c 61 6d 62 64 61  reqs-cmd (lambda
7520: 20 28 29 0a 09 09 09 09 09 09 20 20 20 20 20 20   ().......      
7530: 20 28 64 62 2d 67 65 74 2d 70 72 65 72 65 71 73   (db-get-prereqs
7540: 2d 6e 6f 74 2d 6d 65 74 20 64 62 20 72 75 6e 2d  -not-met db run-
7550: 69 64 20 77 61 69 74 6f 6e 29 29 29 20 3b 3b 20  id waiton))) ;; 
7560: 63 68 65 63 6b 20 62 65 66 6f 72 65 20 72 75 6e  check before run
7570: 6e 69 6e 67 20 2e 2e 2e 2e 0a 09 09 09 09 20 20  ning .........  
7580: 20 20 28 6c 61 75 6e 63 68 2d 63 6d 64 20 20 20    (launch-cmd   
7590: 20 20 20 28 6c 61 6d 62 64 61 20 28 29 0a 09 09     (lambda ()...
75a0: 09 09 09 09 20 20 20 20 20 20 20 28 6c 61 75 6e  ....       (laun
75b0: 63 68 2d 74 65 73 74 20 64 62 20 72 75 6e 2d 69  ch-test db run-i
75c0: 64 20 74 65 73 74 2d 63 6f 6e 66 20 6b 65 79 76  d test-conf keyv
75d0: 61 6c 6c 73 74 20 74 65 73 74 2d 6e 61 6d 65 20  allst test-name 
75e0: 74 65 73 74 2d 70 61 74 68 20 69 74 65 6d 64 61  test-path itemda
75f0: 74 29 29 29 0a 09 09 09 09 20 20 20 20 28 74 65  t))).....    (te
7600: 73 74 72 75 6e 64 61 74 20 20 20 20 20 20 28 6c  strundat      (l
7610: 69 73 74 20 67 65 74 2d 70 72 65 72 65 71 73 2d  ist get-prereqs-
7620: 63 6d 64 20 6c 61 75 6e 63 68 2d 63 6d 64 29 29  cmd launch-cmd))
7630: 29 0a 09 09 09 20 20 20 20 20 20 20 28 69 66 20  )....       (if 
7640: 28 6f 72 20 28 61 72 67 73 3a 67 65 74 2d 61 72  (or (args:get-ar
7650: 67 20 22 2d 66 6f 72 63 65 22 29 0a 09 09 09 09  g "-force").....
7660: 20 20 20 20 20 20 20 28 6c 65 74 20 28 28 70 72         (let ((pr
7670: 65 71 73 2d 6e 6f 74 2d 79 65 74 2d 6d 65 74 20  eqs-not-yet-met 
7680: 28 28 63 61 72 20 74 65 73 74 72 75 6e 64 61 74  ((car testrundat
7690: 29 29 29 29 0a 09 09 09 09 09 20 28 64 65 62 75  ))))...... (debu
76a0: 67 3a 70 72 69 6e 74 20 32 20 22 50 72 65 71 72  g:print 2 "Preqr
76b0: 65 71 75 65 73 69 74 65 73 20 66 6f 72 20 22 20  equesites for " 
76c0: 74 65 73 74 2d 6e 61 6d 65 20 22 3a 20 22 20 70  test-name ": " p
76d0: 72 65 71 73 2d 6e 6f 74 2d 79 65 74 2d 6d 65 74  reqs-not-yet-met
76e0: 29 0a 09 09 09 09 09 20 28 6e 75 6c 6c 3f 20 70  )...... (null? p
76f0: 72 65 71 73 2d 6e 6f 74 2d 79 65 74 2d 6d 65 74  reqs-not-yet-met
7700: 29 29 29 20 3b 3b 20 61 72 65 20 74 68 65 72 65  ))) ;; are there
7710: 20 61 6e 79 20 74 65 73 74 73 20 74 68 61 74 20   any tests that 
7720: 6d 75 73 74 20 62 65 20 72 75 6e 20 62 65 66 6f  must be run befo
7730: 72 65 20 74 68 69 73 20 6f 6e 65 2e 2e 2e 0a 09  re this one.....
7740: 09 09 09 20 20 20 28 69 66 20 28 6e 6f 74 20 28  ...   (if (not (
7750: 28 63 61 64 72 20 74 65 73 74 72 75 6e 64 61 74  (cadr testrundat
7760: 29 29 29 20 3b 3b 20 74 68 69 73 20 69 73 20 74  ))) ;; this is t
7770: 68 65 20 6c 69 6e 65 20 74 68 61 74 20 6c 61 75  he line that lau
7780: 6e 63 68 65 73 20 74 68 65 20 74 65 73 74 20 74  nches the test t
7790: 6f 20 74 68 65 20 72 65 6d 6f 74 65 20 68 6f 73  o the remote hos
77a0: 74 0a 09 09 09 09 20 20 20 20 20 20 20 28 62 65  t.....       (be
77b0: 67 69 6e 0a 09 09 09 09 09 20 28 70 72 69 6e 74  gin...... (print
77c0: 20 22 45 52 52 4f 52 3a 20 46 61 69 6c 65 64 20   "ERROR: Failed 
77d0: 74 6f 20 6c 61 75 6e 63 68 20 74 68 65 20 74 65  to launch the te
77e0: 73 74 2e 20 45 78 69 74 69 6e 67 20 61 73 20 73  st. Exiting as s
77f0: 6f 6f 6e 20 61 73 20 70 6f 73 73 69 62 6c 65 22  oon as possible"
7800: 29 0a 09 09 09 09 09 20 28 73 65 74 21 20 2a 67  )...... (set! *g
7810: 6c 6f 62 61 6c 65 78 69 74 73 74 61 74 75 73 2a  lobalexitstatus*
7820: 20 31 29 20 3b 3b 20 0a 09 09 09 09 09 20 28 70   1) ;; ...... (p
7830: 72 6f 63 65 73 73 2d 73 69 67 6e 61 6c 20 28 63  rocess-signal (c
7840: 75 72 72 65 6e 74 2d 70 72 6f 63 65 73 73 2d 69  urrent-process-i
7850: 64 29 20 73 69 67 6e 61 6c 2f 6b 69 6c 6c 29 0a  d) signal/kill).
7860: 09 09 09 09 09 20 3b 28 65 78 69 74 20 31 29 0a  ..... ;(exit 1).
7870: 09 09 09 09 09 20 29 29 0a 09 09 09 09 20 20 20  ..... )).....   
7880: 28 69 66 20 28 6e 6f 74 20 28 61 72 67 73 3a 67  (if (not (args:g
7890: 65 74 2d 61 72 67 20 22 2d 6b 65 65 70 67 6f 69  et-arg "-keepgoi
78a0: 6e 67 22 29 29 0a 09 09 09 09 20 20 20 20 20 20  ng")).....      
78b0: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74   (hash-table-set
78c0: 21 20 2a 77 61 69 74 69 6e 67 2d 71 75 65 75 65  ! *waiting-queue
78d0: 2a 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20  * new-test-name 
78e0: 74 65 73 74 72 75 6e 64 61 74 29 29 29 29 29 29  testrundat))))))
78f0: 29 0a 09 09 20 20 20 20 20 20 28 28 4b 49 4c 4c  )...      ((KILL
7900: 45 44 29 20 0a 09 09 20 20 20 20 20 20 20 28 64  ED) ...       (d
7910: 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 4e 4f  ebug:print 1 "NO
7920: 54 45 3a 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e  TE: " new-test-n
7930: 61 6d 65 20 22 20 69 73 20 61 6c 72 65 61 64 79  ame " is already
7940: 20 72 75 6e 6e 69 6e 67 20 6f 72 20 77 61 73 20   running or was 
7950: 65 78 70 6c 69 63 74 6c 79 20 6b 69 6c 6c 65 64  explictly killed
7960: 2c 20 75 73 65 20 2d 66 6f 72 63 65 20 74 6f 20  , use -force to 
7970: 6c 61 75 6e 63 68 20 69 74 2e 22 29 29 0a 09 09  launch it."))...
7980: 20 20 20 20 20 20 28 28 4c 41 55 4e 43 48 45 44        ((LAUNCHED
7990: 20 52 45 4d 4f 54 45 48 4f 53 54 53 54 41 52 54   REMOTEHOSTSTART
79a0: 20 52 55 4e 4e 49 4e 47 29 20 20 0a 09 09 20 20   RUNNING)  ...  
79b0: 20 20 20 20 20 28 69 66 20 28 3e 20 28 2d 20 28       (if (> (- (
79c0: 63 75 72 72 65 6e 74 2d 73 65 63 6f 6e 64 73 29  current-seconds)
79d0: 28 2b 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  (+ (db:test-get-
79e0: 65 76 65 6e 74 5f 74 69 6d 65 20 74 65 73 74 64  event_time testd
79f0: 61 74 29 0a 09 09 09 09 09 09 20 20 20 20 20 28  at).......     (
7a00: 64 62 3a 74 65 73 74 2d 67 65 74 2d 72 75 6e 5f  db:test-get-run_
7a10: 64 75 72 61 74 69 6f 6e 20 74 65 73 74 64 61 74  duration testdat
7a20: 29 29 29 0a 09 09 09 20 20 20 20 20 20 31 30 30  )))....      100
7a30: 29 20 3b 3b 20 69 2e 65 2e 20 6e 6f 20 75 70 64  ) ;; i.e. no upd
7a40: 61 74 65 20 66 6f 72 20 6d 6f 72 65 20 74 68 61  ate for more tha
7a50: 6e 20 31 30 30 20 73 65 63 6f 6e 64 73 0a 09 09  n 100 seconds...
7a60: 09 20 20 20 28 62 65 67 69 6e 0a 09 09 09 20 20  .   (begin....  
7a70: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
7a80: 30 20 22 57 41 52 4e 49 4e 47 3a 20 54 65 73 74  0 "WARNING: Test
7a90: 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 61   " test-name " a
7aa0: 70 70 65 61 72 73 20 74 6f 20 62 65 20 64 65 61  ppears to be dea
7ab0: 64 2e 20 46 6f 72 63 69 6e 67 20 69 74 20 74 6f  d. Forcing it to
7ac0: 20 73 74 61 74 65 20 49 4e 43 4f 4d 50 4c 45 54   state INCOMPLET
7ad0: 45 20 61 6e 64 20 73 74 61 74 75 73 20 53 54 55  E and status STU
7ae0: 43 4b 2f 44 45 41 44 22 29 0a 09 09 09 20 20 20  CK/DEAD")....   
7af0: 20 20 28 74 65 73 74 2d 73 65 74 2d 73 74 61 74    (test-set-stat
7b00: 75 73 21 20 64 62 20 72 75 6e 2d 69 64 20 74 65  us! db run-id te
7b10: 73 74 2d 6e 61 6d 65 20 22 49 4e 43 4f 4d 50 4c  st-name "INCOMPL
7b20: 45 54 45 22 20 22 53 54 55 43 4b 2f 44 45 41 44  ETE" "STUCK/DEAD
7b30: 22 20 69 74 65 6d 64 61 74 20 22 54 65 73 74 20  " itemdat "Test 
7b40: 69 73 20 73 74 75 63 6b 20 6f 72 20 64 65 61 64  is stuck or dead
7b50: 22 20 23 66 29 29 0a 09 09 09 20 20 20 28 64 65  " #f))....   (de
7b60: 62 75 67 3a 70 72 69 6e 74 20 32 20 22 4e 4f 54  bug:print 2 "NOT
7b70: 45 3a 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22  E: " test-name "
7b80: 20 69 73 20 61 6c 72 65 61 64 79 20 72 75 6e 6e   is already runn
7b90: 69 6e 67 22 29 29 29 0a 09 09 20 20 20 20 20 20  ing")))...      
7ba0: 28 65 6c 73 65 20 20 20 20 20 20 20 28 64 65 62  (else       (deb
7bb0: 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f  ug:print 0 "ERRO
7bc0: 52 3a 20 46 61 69 6c 65 64 20 74 6f 20 6c 61 75  R: Failed to lau
7bd0: 6e 63 68 20 74 65 73 74 20 22 20 6e 65 77 2d 74  nch test " new-t
7be0: 65 73 74 2d 6e 61 6d 65 20 22 2e 20 55 6e 72 65  est-name ". Unre
7bf0: 63 6f 67 6e 69 73 65 64 20 73 74 61 74 65 20 22  cognised state "
7c00: 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65   (test:get-state
7c10: 20 74 65 73 74 64 61 74 29 29 29 29 29 29 0a 09   testdat))))))..
7c20: 20 20 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28        (if (not (
7c30: 6e 75 6c 6c 3f 20 74 61 6c 29 29 0a 09 09 20 20  null? tal))...  
7c40: 28 6c 6f 6f 70 20 28 63 61 72 20 74 61 6c 29 28  (loop (car tal)(
7c50: 63 64 72 20 74 61 6c 29 29 29 29 29 29 29 29 29  cdr tal)))))))))
7c60: 0a 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 2d 77  ..(define (run-w
7c70: 61 69 74 69 6e 67 2d 74 65 73 74 73 20 64 62 29  aiting-tests db)
7c80: 0a 20 20 28 6c 65 74 20 28 28 6e 75 6d 74 72 69  .  (let ((numtri
7c90: 65 73 20 20 20 20 20 20 20 20 20 20 20 30 29 0a  es           0).
7ca0: 09 28 6c 61 73 74 2d 74 72 79 2d 74 69 6d 65 20  .(last-try-time 
7cb0: 20 20 20 20 20 28 63 75 72 72 65 6e 74 2d 73 65       (current-se
7cc0: 63 6f 6e 64 73 29 29 0a 09 28 74 69 6d 65 73 20  conds))..(times 
7cd0: 20 20 20 20 20 20 20 20 20 20 20 20 20 28 6c 69               (li
7ce0: 73 74 20 31 29 29 29 20 3b 3b 20 6d 69 6e 75 74  st 1))) ;; minut
7cf0: 65 73 20 74 6f 20 77 61 69 74 20 62 65 66 6f 72  es to wait befor
7d00: 65 20 74 72 79 69 6e 67 20 61 67 61 69 6e 20 74  e trying again t
7d10: 6f 20 6b 69 63 6b 20 6f 66 66 20 72 75 6e 73 0a  o kick off runs.
7d20: 20 20 20 20 3b 3b 20 42 55 47 20 74 68 69 73 20      ;; BUG this 
7d30: 68 61 63 6b 20 6f 66 20 62 72 75 74 65 20 66 6f  hack of brute fo
7d40: 72 63 65 20 72 65 74 72 79 69 6e 67 20 77 6f 72  rce retrying wor
7d50: 6b 73 20 71 75 69 74 65 20 77 65 6c 6c 20 66 6f  ks quite well fo
7d60: 72 20 6d 61 6e 79 20 63 61 73 65 73 20 62 75 74  r many cases but
7d70: 20 0a 20 20 20 20 3b 3b 20 20 20 20 20 77 68 61   .    ;;     wha
7d80: 74 20 69 73 20 6e 65 65 64 65 64 20 69 73 20 74  t is needed is t
7d90: 6f 20 63 68 65 63 6b 20 74 68 65 20 64 62 20 66  o check the db f
7da0: 6f 72 20 74 65 73 74 73 20 74 68 61 74 20 68 61  or tests that ha
7db0: 76 65 20 66 61 69 6c 65 64 20 6c 65 73 73 20 74  ve failed less t
7dc0: 68 61 6e 0a 20 20 20 20 3b 3b 20 20 20 20 20 4e  han.    ;;     N
7dd0: 20 74 69 6d 65 73 20 6f 72 20 6e 65 76 65 72 20   times or never 
7de0: 62 65 65 6e 20 73 74 61 72 74 65 64 20 61 6e 64  been started and
7df0: 20 6b 69 63 6b 20 74 68 65 6d 20 6f 66 66 20 61   kick them off a
7e00: 67 61 69 6e 0a 20 20 20 20 28 6c 65 74 20 6c 6f  gain.    (let lo
7e10: 6f 70 20 28 28 77 61 69 74 69 6e 67 2d 74 65 73  op ((waiting-tes
7e20: 74 2d 6e 61 6d 65 73 20 28 68 61 73 68 2d 74 61  t-names (hash-ta
7e30: 62 6c 65 2d 6b 65 79 73 20 2a 77 61 69 74 69 6e  ble-keys *waitin
7e40: 67 2d 71 75 65 75 65 2a 29 29 29 0a 20 20 20 20  g-queue*))).    
7e50: 20 20 28 63 6f 6e 64 0a 20 20 20 20 20 20 20 28    (cond.       (
7e60: 28 6e 6f 74 20 28 72 75 6e 73 3a 63 61 6e 2d 72  (not (runs:can-r
7e70: 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64 62  un-more-tests db
7e80: 29 29 0a 09 28 73 6c 65 65 70 20 32 29 0a 09 28  ))..(sleep 2)..(
7e90: 6c 6f 6f 70 20 77 61 69 74 69 6e 67 2d 74 65 73  loop waiting-tes
7ea0: 74 2d 6e 61 6d 65 73 29 29 0a 20 20 20 20 20 20  t-names)).      
7eb0: 20 28 28 6e 75 6c 6c 3f 20 77 61 69 74 69 6e 67   ((null? waiting
7ec0: 2d 74 65 73 74 2d 6e 61 6d 65 73 29 0a 09 28 64  -test-names)..(d
7ed0: 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 41 6c  ebug:print 1 "Al
7ee0: 6c 20 74 65 73 74 73 20 6c 61 75 6e 63 68 65 64  l tests launched
7ef0: 22 29 29 0a 20 20 20 20 20 20 20 28 65 6c 73 65  ")).       (else
7f00: 0a 09 28 73 65 74 21 20 6e 75 6d 74 72 69 65 73  ..(set! numtries
7f10: 20 28 2b 20 6e 75 6d 74 72 69 65 73 20 31 29 29   (+ numtries 1))
7f20: 0a 09 28 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d  ..(for-each (lam
7f30: 62 64 61 20 28 74 65 73 74 6e 61 6d 65 29 0a 09  bda (testname)..
7f40: 09 20 20 20 20 28 69 66 20 28 72 75 6e 73 3a 63  .    (if (runs:c
7f50: 61 6e 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74  an-run-more-test
7f60: 73 20 64 62 29 0a 09 09 09 28 6c 65 74 2a 20 28  s db)....(let* (
7f70: 28 74 65 73 74 64 61 74 20 28 68 61 73 68 2d 74  (testdat (hash-t
7f80: 61 62 6c 65 2d 72 65 66 20 2a 77 61 69 74 69 6e  able-ref *waitin
7f90: 67 2d 71 75 65 75 65 2a 20 74 65 73 74 6e 61 6d  g-queue* testnam
7fa0: 65 29 29 0a 09 09 09 20 20 20 20 20 20 20 28 70  e))....       (p
7fb0: 72 65 72 65 71 73 20 28 28 63 61 72 20 74 65 73  rereqs ((car tes
7fc0: 74 64 61 74 29 29 29 0a 09 09 09 20 20 20 20 20  tdat)))....     
7fd0: 20 20 28 6c 64 62 20 20 20 20 20 28 69 66 20 64    (ldb     (if d
7fe0: 62 20 64 62 20 28 6f 70 65 6e 2d 64 62 29 29 29  b db (open-db)))
7ff0: 29 0a 09 09 09 20 20 28 64 65 62 75 67 3a 70 72  )....  (debug:pr
8000: 69 6e 74 20 32 20 22 70 72 65 72 65 71 73 20 72  int 2 "prereqs r
8010: 65 6d 61 69 6e 69 6e 67 3a 20 22 20 70 72 65 72  emaining: " prer
8020: 65 71 73 29 0a 09 09 09 20 20 28 69 66 20 28 6e  eqs)....  (if (n
8030: 75 6c 6c 3f 20 70 72 65 72 65 71 73 29 0a 09 09  ull? prereqs)...
8040: 09 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09  .      (begin...
8050: 09 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32  ..(debug:print 2
8060: 20 22 50 72 65 72 65 71 75 69 73 69 74 65 73 20   "Prerequisites 
8070: 6d 65 74 2c 20 6c 61 75 6e 63 68 69 6e 67 20 22  met, launching "
8080: 20 74 65 73 74 6e 61 6d 65 29 0a 09 09 09 09 28   testname).....(
8090: 28 63 61 64 72 20 74 65 73 74 64 61 74 29 29 0a  (cadr testdat)).
80a0: 09 09 09 09 28 68 61 73 68 2d 74 61 62 6c 65 2d  ....(hash-table-
80b0: 64 65 6c 65 74 65 21 20 2a 77 61 69 74 69 6e 67  delete! *waiting
80c0: 2d 71 75 65 75 65 2a 20 74 65 73 74 6e 61 6d 65  -queue* testname
80d0: 29 29 29 0a 09 09 09 20 20 28 69 66 20 28 6e 6f  )))....  (if (no
80e0: 74 20 64 62 29 0a 09 09 09 20 20 20 20 20 20 28  t db)....      (
80f0: 73 71 6c 69 74 65 33 3a 66 69 6e 61 6c 69 7a 65  sqlite3:finalize
8100: 21 20 6c 64 62 29 29 29 29 29 0a 09 09 20 20 77  ! ldb)))))...  w
8110: 61 69 74 69 6e 67 2d 74 65 73 74 2d 6e 61 6d 65  aiting-test-name
8120: 73 29 0a 09 3b 3b 20 28 73 6c 65 65 70 20 31 30  s)..;; (sleep 10
8130: 29 20 3b 3b 20 6e 6f 20 70 6f 69 6e 74 20 69 6e  ) ;; no point in
8140: 20 72 75 73 68 69 6e 67 20 74 68 69 6e 67 73 20   rushing things 
8150: 61 74 20 74 68 69 73 20 73 74 61 67 65 3f 0a 09  at this stage?..
8160: 28 6c 6f 6f 70 20 28 68 61 73 68 2d 74 61 62 6c  (loop (hash-tabl
8170: 65 2d 6b 65 79 73 20 2a 77 61 69 74 69 6e 67 2d  e-keys *waiting-
8180: 71 75 65 75 65 2a 29 29 29 29 29 29 29 0a 0a 28  queue*)))))))..(
8190: 64 65 66 69 6e 65 20 28 67 65 74 2d 64 69 72 2d  define (get-dir-
81a0: 75 70 2d 6e 20 64 69 72 20 2e 20 70 61 72 61 6d  up-n dir . param
81b0: 73 29 20 0a 20 20 28 6c 65 74 20 28 28 64 70 61  s) .  (let ((dpa
81c0: 72 74 73 20 20 28 73 74 72 69 6e 67 2d 73 70 6c  rts  (string-spl
81d0: 69 74 20 64 69 72 20 22 2f 22 29 29 0a 09 28 63  it dir "/"))..(c
81e0: 6f 75 6e 74 20 20 20 28 69 66 20 28 6e 75 6c 6c  ount   (if (null
81f0: 3f 20 70 61 72 61 6d 73 29 20 31 20 28 63 61 72  ? params) 1 (car
8200: 20 70 61 72 61 6d 73 29 29 29 29 0a 20 20 20 20   params)))).    
8210: 28 63 6f 6e 63 20 22 2f 22 20 28 73 74 72 69 6e  (conc "/" (strin
8220: 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 0a 09  g-intersperse ..
8230: 20 20 20 20 20 20 20 28 74 61 6b 65 20 64 70 61         (take dpa
8240: 72 74 73 20 28 2d 20 28 6c 65 6e 67 74 68 20 64  rts (- (length d
8250: 70 61 72 74 73 29 20 63 6f 75 6e 74 29 29 0a 09  parts) count))..
8260: 20 20 20 20 20 20 20 22 2f 22 29 29 29 29 0a 3b         "/")))).;
8270: 3b 20 52 65 6d 6f 76 65 20 72 75 6e 73 0a 3b 3b  ; Remove runs.;;
8280: 20 66 69 65 6c 64 73 20 61 72 65 20 70 61 73 73   fields are pass
8290: 69 6e 67 20 69 6e 20 74 68 72 6f 75 67 68 20 0a  ing in through .
82a0: 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 72 65  (define (runs:re
82b0: 6d 6f 76 65 2d 72 75 6e 73 20 64 62 20 72 75 6e  move-runs db run
82c0: 6e 61 6d 65 70 61 74 74 20 74 65 73 74 70 61 74  namepatt testpat
82d0: 74 20 69 74 65 6d 70 61 74 74 29 0a 20 20 28 6c  t itempatt).  (l
82e0: 65 74 2a 20 28 28 6b 65 79 73 20 20 20 20 20 20  et* ((keys      
82f0: 20 20 28 64 62 2d 67 65 74 2d 6b 65 79 73 20 64    (db-get-keys d
8300: 62 29 29 0a 09 20 28 72 75 6e 64 61 74 20 20 20  b)).. (rundat   
8310: 20 20 20 28 72 75 6e 73 3a 67 65 74 2d 72 75 6e     (runs:get-run
8320: 73 2d 62 79 2d 70 61 74 74 20 64 62 20 6b 65 79  s-by-patt db key
8330: 73 20 72 75 6e 6e 61 6d 65 70 61 74 74 29 29 0a  s runnamepatt)).
8340: 09 20 28 68 65 61 64 65 72 20 20 20 20 20 20 28  . (header      (
8350: 76 65 63 74 6f 72 2d 72 65 66 20 72 75 6e 64 61  vector-ref runda
8360: 74 20 30 29 29 0a 09 20 28 72 75 6e 73 20 20 20  t 0)).. (runs   
8370: 20 20 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66       (vector-ref
8380: 20 72 75 6e 64 61 74 20 31 29 29 29 0a 20 20 20   rundat 1))).   
8390: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20   (debug:print 1 
83a0: 22 48 65 61 64 65 72 3a 20 22 20 68 65 61 64 65  "Header: " heade
83b0: 72 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68  r).    (for-each
83c0: 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 72  .     (lambda (r
83d0: 75 6e 29 0a 20 20 20 20 20 20 20 28 6c 65 74 20  un).       (let 
83e0: 28 28 72 75 6e 6b 65 79 20 28 73 74 72 69 6e 67  ((runkey (string
83f0: 2d 69 6e 74 65 72 73 70 65 72 73 65 20 28 6d 61  -intersperse (ma
8400: 70 20 28 6c 61 6d 62 64 61 20 28 6b 29 0a 09 09  p (lambda (k)...
8410: 09 09 09 09 28 64 62 3a 67 65 74 2d 76 61 6c 75  ....(db:get-valu
8420: 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20  e-by-header run 
8430: 68 65 61 64 65 72 20 28 76 65 63 74 6f 72 2d 72  header (vector-r
8440: 65 66 20 6b 20 30 29 29 29 20 6b 65 79 73 29 20  ef k 0))) keys) 
8450: 22 2f 22 29 29 0a 09 20 20 20 20 20 28 64 69 72  "/"))..     (dir
8460: 73 2d 74 6f 2d 72 65 6d 6f 76 65 20 28 6d 61 6b  s-to-remove (mak
8470: 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29 29 0a  e-hash-table))).
8480: 09 20 28 6c 65 74 2a 20 28 28 72 75 6e 2d 69 64  . (let* ((run-id
8490: 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62   (db:get-value-b
84a0: 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61  y-header run hea
84b0: 64 65 72 20 22 69 64 22 29 20 29 0a 09 09 28 74  der "id") )...(t
84c0: 65 73 74 73 20 20 28 64 62 2d 67 65 74 2d 74 65  ests  (db-get-te
84d0: 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 28  sts-for-run db (
84e0: 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d  db:get-value-by-
84f0: 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65  header run heade
8500: 72 20 22 69 64 22 29 20 74 65 73 74 70 61 74 74  r "id") testpatt
8510: 20 69 74 65 6d 70 61 74 74 29 29 0a 09 09 28 6c   itempatt))...(l
8520: 61 73 74 74 70 61 74 68 20 22 2f 64 6f 65 73 2f  asttpath "/does/
8530: 6e 6f 74 2f 65 78 69 73 74 2f 49 2f 68 6f 70 65  not/exist/I/hope
8540: 22 29 29 0a 0a 09 20 20 20 28 69 66 20 28 6e 6f  "))...   (if (no
8550: 74 20 28 6e 75 6c 6c 3f 20 74 65 73 74 73 29 29  t (null? tests))
8560: 0a 09 20 20 20 20 20 20 20 28 62 65 67 69 6e 0a  ..       (begin.
8570: 09 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20  .. (debug:print 
8580: 31 20 22 52 65 6d 6f 76 69 6e 67 20 74 65 73 74  1 "Removing test
8590: 73 20 66 6f 72 20 72 75 6e 3a 20 22 20 72 75 6e  s for run: " run
85a0: 6b 65 79 20 22 20 22 20 28 64 62 3a 67 65 74 2d  key " " (db:get-
85b0: 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20  value-by-header 
85c0: 72 75 6e 20 68 65 61 64 65 72 20 22 72 75 6e 6e  run header "runn
85d0: 61 6d 65 22 29 29 0a 09 09 20 28 66 6f 72 2d 65  ame"))... (for-e
85e0: 61 63 68 0a 09 09 20 20 28 6c 61 6d 62 64 61 20  ach...  (lambda 
85f0: 28 74 65 73 74 29 0a 09 09 20 20 20 20 28 6c 65  (test)...    (le
8600: 74 2a 20 28 28 69 74 65 6d 2d 70 61 74 68 20 28  t* ((item-path (
8610: 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d  db:test-get-item
8620: 2d 70 61 74 68 20 74 65 73 74 29 29 0a 09 09 09  -path test))....
8630: 20 20 20 28 74 65 73 74 2d 6e 61 6d 65 20 28 64     (test-name (d
8640: 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e  b:test-get-testn
8650: 61 6d 65 20 74 65 73 74 29 29 0a 09 09 09 20 20  ame test))....  
8660: 20 28 72 75 6e 2d 64 69 72 20 20 20 28 64 62 3a   (run-dir   (db:
8670: 74 65 73 74 2d 67 65 74 2d 72 75 6e 64 69 72 20  test-get-rundir 
8680: 74 65 73 74 29 29 29 0a 09 09 20 20 20 20 20 20  test)))...      
8690: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22  (debug:print 1 "
86a0: 20 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74    " (db:test-get
86b0: 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 29 20  -testname test) 
86c0: 22 20 69 64 3a 20 22 20 28 64 62 3a 74 65 73 74  " id: " (db:test
86d0: 2d 67 65 74 2d 69 64 20 74 65 73 74 29 20 22 20  -get-id test) " 
86e0: 22 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 09 20  " item-path)... 
86f0: 20 20 20 20 20 28 64 62 3a 64 65 6c 65 74 65 2d       (db:delete-
8700: 74 65 73 74 2d 72 65 63 6f 72 64 73 20 64 62 20  test-records db 
8710: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20  (db:test-get-id 
8720: 74 65 73 74 29 29 0a 09 09 20 20 20 20 20 20 28  test))...      (
8730: 69 66 20 28 3e 20 28 73 74 72 69 6e 67 2d 6c 65  if (> (string-le
8740: 6e 67 74 68 20 72 75 6e 2d 64 69 72 29 20 35 29  ngth run-dir) 5)
8750: 20 3b 3b 20 62 61 64 20 68 65 75 72 69 73 74 69   ;; bad heuristi
8760: 63 20 62 75 74 20 73 68 6f 75 6c 64 20 70 72 65  c but should pre
8770: 76 65 6e 74 20 2f 74 6d 70 20 2f 68 6f 6d 65 20  vent /tmp /home 
8780: 65 74 63 2e 0a 09 09 09 20 20 28 6c 65 74 20 28  etc.....  (let (
8790: 28 66 75 6c 6c 70 61 74 68 20 72 75 6e 2d 64 69  (fullpath run-di
87a0: 72 29 29 20 3b 3b 20 22 2f 22 20 28 64 62 3a 74  r)) ;; "/" (db:t
87b0: 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74  est-get-item-pat
87c0: 68 20 74 65 73 74 29 29 29 29 0a 09 09 09 20 20  h test))))....  
87d0: 20 20 28 73 65 74 21 20 6c 61 73 74 74 70 61 74    (set! lasttpat
87e0: 68 20 66 75 6c 6c 70 61 74 68 29 0a 09 09 09 20  h fullpath).... 
87f0: 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73     (hash-table-s
8800: 65 74 21 20 64 69 72 73 2d 74 6f 2d 72 65 6d 6f  et! dirs-to-remo
8810: 76 65 20 66 75 6c 6c 70 61 74 68 20 23 74 29 0a  ve fullpath #t).
8820: 09 09 09 20 20 20 20 3b 3b 20 54 68 65 20 66 6f  ...    ;; The fo
8830: 6c 6c 6f 77 69 6e 67 20 77 61 73 20 74 68 65 20  llowing was the 
8840: 73 61 66 65 20 64 65 6c 65 74 65 20 63 6f 64 65  safe delete code
8850: 20 62 75 74 20 69 74 20 77 61 73 20 6e 6f 74 20   but it was not 
8860: 62 65 69 6e 67 20 65 78 65 63 74 75 74 65 64 2e  being exectuted.
8870: 0a 09 09 09 20 20 20 20 3b 3b 20 28 6c 65 74 2a  ....    ;; (let*
8880: 20 28 28 64 69 72 73 2d 63 6f 75 6e 74 20 28 2b   ((dirs-count (+
8890: 20 31 20 28 6c 65 6e 67 74 68 20 6b 65 79 73 29   1 (length keys)
88a0: 28 6c 65 6e 67 74 68 20 28 73 74 72 69 6e 67 2d  (length (string-
88b0: 73 70 6c 69 74 20 69 74 65 6d 2d 70 61 74 68 20  split item-path 
88c0: 22 2f 22 29 29 29 29 0a 09 09 09 20 20 20 20 3b  "/"))))....    ;
88d0: 3b 20 20 20 20 20 20 20 20 28 64 69 72 2d 74 6f  ;        (dir-to
88e0: 2d 72 65 6d 20 28 67 65 74 2d 64 69 72 2d 75 70  -rem (get-dir-up
88f0: 2d 6e 20 66 75 6c 6c 70 61 74 68 20 64 69 72 73  -n fullpath dirs
8900: 2d 63 6f 75 6e 74 29 29 0a 09 09 09 20 20 20 20  -count))....    
8910: 3b 3b 20 20 20 20 20 20 20 20 28 72 65 6d 61 69  ;;        (remai
8920: 6e 69 6e 67 64 20 28 73 74 72 69 6e 67 2d 73 75  ningd (string-su
8930: 62 73 74 69 74 75 74 65 20 28 72 65 67 65 78 70  bstitute (regexp
8940: 20 28 63 6f 6e 63 20 22 5e 22 20 64 69 72 2d 74   (conc "^" dir-t
8950: 6f 2d 72 65 6d 20 22 2f 22 29 29 20 22 22 20 66  o-rem "/")) "" f
8960: 75 6c 6c 70 61 74 68 29 29 0a 09 09 09 20 20 20  ullpath))....   
8970: 20 3b 3b 20 20 20 20 20 20 20 20 28 63 6d 64 20   ;;        (cmd 
8980: 28 63 6f 6e 63 20 22 63 64 20 22 20 64 69 72 2d  (conc "cd " dir-
8990: 74 6f 2d 72 65 6d 20 22 3b 20 72 6d 64 69 72 20  to-rem "; rmdir 
89a0: 2d 70 20 22 20 72 65 6d 61 69 6e 69 6e 67 64 20  -p " remainingd 
89b0: 29 29 29 0a 09 09 09 20 20 20 20 3b 3b 20 20 20  )))....    ;;   
89c0: 28 69 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73  (if (file-exists
89d0: 3f 20 66 75 6c 6c 70 61 74 68 29 0a 09 09 09 20  ? fullpath).... 
89e0: 20 20 20 3b 3b 20 20 20 20 20 20 20 28 62 65 67     ;;       (beg
89f0: 69 6e 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 20  in....    ;;    
8a00: 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e       (debug:prin
8a10: 74 20 31 20 63 6d 64 29 0a 09 09 09 20 20 20 20  t 1 cmd)....    
8a20: 3b 3b 20 20 20 20 20 20 20 20 20 28 73 79 73 74  ;;         (syst
8a30: 65 6d 20 63 6d 64 29 29 29 0a 09 09 09 20 20 20  em cmd)))....   
8a40: 20 3b 3b 20 20 20 29 29 0a 09 09 09 20 20 20 20   ;;   ))....    
8a50: 29 29 29 29 0a 09 09 20 20 20 20 74 65 73 74 73  ))))...    tests
8a60: 29 29 29 0a 0a 09 20 20 20 3b 3b 20 6c 6f 6f 6b  )))...   ;; look
8a70: 20 74 68 6f 75 67 68 20 74 68 65 20 64 69 72 73   though the dirs
8a80: 2d 74 6f 2d 72 65 6d 6f 76 65 20 66 6f 72 20 63  -to-remove for c
8a90: 61 6e 64 69 64 61 74 65 73 20 66 6f 72 20 72 65  andidates for re
8aa0: 6d 6f 76 61 6c 2e 20 44 6f 20 74 68 69 73 20 61  moval. Do this a
8ab0: 66 74 65 72 20 64 65 6c 65 74 69 6e 67 20 74 68  fter deleting th
8ac0: 65 20 72 65 63 6f 72 64 73 0a 09 20 20 20 3b 3b  e records..   ;;
8ad0: 20 66 6f 72 20 65 61 63 68 20 74 65 73 74 20 69   for each test i
8ae0: 6e 20 63 61 73 65 20 77 65 20 67 65 74 20 6b 69  n case we get ki
8af0: 6c 6c 65 64 2e 20 54 68 61 74 20 73 68 6f 75 6c  lled. That shoul
8b00: 64 20 6d 69 6e 69 6d 69 7a 65 20 74 68 65 20 64  d minimize the d
8b10: 65 74 72 69 74 75 73 20 6c 65 66 74 20 6f 6e 20  etritus left on 
8b20: 64 69 73 6b 0a 09 20 20 20 3b 3b 20 70 72 6f 63  disk..   ;; proc
8b30: 65 73 73 20 74 68 65 20 64 69 72 73 20 66 72 6f  ess the dirs fro
8b40: 6d 20 6c 6f 6e 67 65 73 74 20 73 74 72 69 6e 67  m longest string
8b50: 20 6c 65 6e 67 74 68 20 74 6f 20 73 68 6f 72 74   length to short
8b60: 65 73 74 0a 09 20 20 20 28 66 6f 72 2d 65 61 63  est..   (for-eac
8b70: 68 20 0a 09 20 20 20 20 28 6c 61 6d 62 64 61 20  h ..    (lambda 
8b80: 28 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 0a  (dir-to-remove).
8b90: 09 20 20 20 20 20 20 28 69 66 20 28 66 69 6c 65  .      (if (file
8ba0: 2d 65 78 69 73 74 73 3f 20 64 69 72 2d 74 6f 2d  -exists? dir-to-
8bb0: 72 65 6d 6f 76 65 29 0a 09 09 20 20 28 6c 65 74  remove)...  (let
8bc0: 20 28 28 64 69 72 2d 69 6e 2d 64 62 20 27 28 29   ((dir-in-db '()
8bd0: 29 29 0a 09 09 20 20 20 20 28 73 71 6c 69 74 65  ))...    (sqlite
8be0: 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77 0a 09  3:for-each-row..
8bf0: 09 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 64  .     (lambda (d
8c00: 69 72 29 0a 09 09 20 20 20 20 20 20 20 28 73 65  ir)...       (se
8c10: 74 21 20 64 69 72 2d 69 6e 2d 64 62 20 28 63 6f  t! dir-in-db (co
8c20: 6e 73 20 64 69 72 20 64 69 72 2d 69 6e 2d 64 62  ns dir dir-in-db
8c30: 29 29 29 0a 09 09 20 20 20 20 20 64 62 20 22 53  )))...     db "S
8c40: 45 4c 45 43 54 20 72 75 6e 64 69 72 20 46 52 4f  ELECT rundir FRO
8c50: 4d 20 74 65 73 74 73 20 57 48 45 52 45 20 72 75  M tests WHERE ru
8c60: 6e 64 69 72 20 4c 49 4b 45 20 3f 3b 22 20 0a 09  ndir LIKE ?;" ..
8c70: 09 20 20 20 20 20 28 63 6f 6e 63 20 22 25 22 20  .     (conc "%" 
8c80: 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 20 22 25  dir-to-remove "%
8c90: 22 29 29 20 3b 3b 20 79 65 73 2c 20 49 27 6d 20  ")) ;; yes, I'm 
8ca0: 67 6f 69 6e 67 20 74 6f 20 62 61 69 6c 20 69 66  going to bail if
8cb0: 20 74 68 65 72 65 20 69 73 20 61 6e 79 74 68 69   there is anythi
8cc0: 6e 67 20 6c 69 6b 65 20 74 68 69 73 20 64 69 72  ng like this dir
8cd0: 20 69 6e 20 74 68 65 20 64 62 0a 09 09 20 20 20   in the db...   
8ce0: 20 28 69 66 20 28 6e 75 6c 6c 3f 20 64 69 72 2d   (if (null? dir-
8cf0: 69 6e 2d 64 62 29 0a 09 09 09 28 62 65 67 69 6e  in-db)....(begin
8d00: 0a 09 09 09 20 20 28 64 65 62 75 67 3a 70 72 69  ....  (debug:pri
8d10: 6e 74 20 32 20 22 52 65 6d 6f 76 69 6e 67 20 64  nt 2 "Removing d
8d20: 69 72 65 63 74 6f 72 79 20 77 69 74 68 20 7a 65  irectory with ze
8d30: 72 6f 20 64 62 20 72 65 66 65 72 65 6e 63 65 73  ro db references
8d40: 3a 20 22 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76  : " dir-to-remov
8d50: 65 29 0a 09 09 09 20 20 28 73 79 73 74 65 6d 20  e)....  (system 
8d60: 28 63 6f 6e 63 20 22 72 6d 20 2d 72 66 20 22 20  (conc "rm -rf " 
8d70: 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 29 0a  dir-to-remove)).
8d80: 09 09 09 20 20 28 68 61 73 68 2d 74 61 62 6c 65  ...  (hash-table
8d90: 2d 64 65 6c 65 74 65 21 20 64 69 72 73 2d 74 6f  -delete! dirs-to
8da0: 2d 72 65 6d 6f 76 65 20 64 69 72 2d 74 6f 2d 72  -remove dir-to-r
8db0: 65 6d 6f 76 65 29 29 0a 09 09 09 28 64 65 62 75  emove))....(debu
8dc0: 67 3a 70 72 69 6e 74 20 32 20 22 53 6b 69 70 70  g:print 2 "Skipp
8dd0: 69 6e 67 20 72 65 6d 6f 76 61 6c 20 6f 66 20 22  ing removal of "
8de0: 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 20 22   dir-to-remove "
8df0: 20 66 6f 72 20 6e 6f 77 20 61 73 20 69 74 20 73   for now as it s
8e00: 74 69 6c 6c 20 68 61 73 20 72 65 66 65 72 65 6e  till has referen
8e10: 63 65 73 20 69 6e 20 74 68 65 20 64 61 74 61 62  ces in the datab
8e20: 61 73 65 22 29 29 29 29 29 0a 09 20 20 20 20 28  ase")))))..    (
8e30: 73 6f 72 74 20 28 68 61 73 68 2d 74 61 62 6c 65  sort (hash-table
8e40: 2d 6b 65 79 73 20 64 69 72 73 2d 74 6f 2d 72 65  -keys dirs-to-re
8e50: 6d 6f 76 65 29 20 28 6c 61 6d 62 64 61 20 28 61  move) (lambda (a
8e60: 20 62 29 28 3e 20 28 73 74 72 69 6e 67 2d 6c 65   b)(> (string-le
8e70: 6e 67 74 68 20 61 29 28 73 74 72 69 6e 67 2d 6c  ngth a)(string-l
8e80: 65 6e 67 74 68 20 62 29 29 29 29 29 0a 0a 09 20  ength b)))))... 
8e90: 20 20 3b 3b 20 72 65 6d 6f 76 65 20 74 68 65 20    ;; remove the 
8ea0: 72 75 6e 20 69 66 20 7a 65 72 6f 20 74 65 73 74  run if zero test
8eb0: 73 20 72 65 6d 61 69 6e 0a 09 20 20 20 28 6c 65  s remain..   (le
8ec0: 74 20 28 28 72 65 6d 74 65 73 74 73 20 28 64 62  t ((remtests (db
8ed0: 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d 72  -get-tests-for-r
8ee0: 75 6e 20 64 62 20 28 64 62 3a 67 65 74 2d 76 61  un db (db:get-va
8ef0: 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75  lue-by-header ru
8f00: 6e 20 68 65 61 64 65 72 20 22 69 64 22 29 29 29  n header "id")))
8f10: 29 0a 09 20 20 20 20 20 28 69 66 20 28 6e 75 6c  )..     (if (nul
8f20: 6c 3f 20 72 65 6d 74 65 73 74 73 29 20 3b 3b 20  l? remtests) ;; 
8f30: 6e 6f 20 6d 6f 72 65 20 74 65 73 74 73 20 72 65  no more tests re
8f40: 6d 61 69 6e 69 6e 67 0a 09 09 20 28 6c 65 74 2a  maining... (let*
8f50: 20 28 28 64 70 61 72 74 73 20 20 28 73 74 72 69   ((dparts  (stri
8f60: 6e 67 2d 73 70 6c 69 74 20 6c 61 73 74 74 70 61  ng-split lasttpa
8f70: 74 68 20 22 2f 22 29 29 0a 09 09 09 28 72 75 6e  th "/"))....(run
8f80: 70 61 74 68 20 28 63 6f 6e 63 20 22 2f 22 20 28  path (conc "/" (
8f90: 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72  string-intersper
8fa0: 73 65 20 0a 09 09 09 09 09 20 20 20 20 28 74 61  se ......    (ta
8fb0: 6b 65 20 64 70 61 72 74 73 20 28 2d 20 28 6c 65  ke dparts (- (le
8fc0: 6e 67 74 68 20 64 70 61 72 74 73 29 20 31 29 29  ngth dparts) 1))
8fd0: 0a 09 09 09 09 09 20 20 20 20 22 2f 22 29 29 29  ......    "/")))
8fe0: 29 0a 09 09 20 20 20 28 64 65 62 75 67 3a 70 72  )...   (debug:pr
8ff0: 69 6e 74 20 31 20 22 52 65 6d 6f 76 69 6e 67 20  int 1 "Removing 
9000: 72 75 6e 3a 20 22 20 72 75 6e 6b 65 79 20 22 20  run: " runkey " 
9010: 22 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d  " (db:get-value-
9020: 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65  by-header run he
9030: 61 64 65 72 20 22 72 75 6e 6e 61 6d 65 22 29 29  ader "runname"))
9040: 0a 09 09 20 20 20 28 64 62 3a 64 65 6c 65 74 65  ...   (db:delete
9050: 2d 72 75 6e 20 64 62 20 72 75 6e 2d 69 64 29 0a  -run db run-id).
9060: 09 09 20 20 20 3b 3b 20 6e 65 65 64 20 74 6f 20  ..   ;; need to 
9070: 66 69 67 75 72 65 20 6f 75 74 20 74 68 65 20 70  figure out the p
9080: 61 74 68 20 74 6f 20 74 68 65 20 72 75 6e 20 64  ath to the run d
9090: 69 72 20 61 6e 64 20 72 65 6d 6f 76 65 20 69 74  ir and remove it
90a0: 20 69 66 20 65 6d 70 74 79 0a 09 09 20 20 20 3b   if empty...   ;
90b0: 3b 20 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20  ;    (if (null? 
90c0: 28 67 6c 6f 62 20 28 63 6f 6e 63 20 72 75 6e 70  (glob (conc runp
90d0: 61 74 68 20 22 2f 2a 22 29 29 29 0a 09 09 20 20  ath "/*")))...  
90e0: 20 3b 3b 20 20 20 20 20 20 20 20 28 62 65 67 69   ;;        (begi
90f0: 6e 0a 09 09 20 20 20 3b 3b 20 09 20 28 64 65 62  n...   ;; . (deb
9100: 75 67 3a 70 72 69 6e 74 20 31 20 22 52 65 6d 6f  ug:print 1 "Remo
9110: 76 69 6e 67 20 72 75 6e 20 64 69 72 20 22 20 72  ving run dir " r
9120: 75 6e 70 61 74 68 29 0a 09 09 20 20 20 3b 3b 20  unpath)...   ;; 
9130: 09 20 28 73 79 73 74 65 6d 20 28 63 6f 6e 63 20  . (system (conc 
9140: 22 72 6d 64 69 72 20 2d 70 20 22 20 72 75 6e 70  "rmdir -p " runp
9150: 61 74 68 29 29 29 29 0a 09 09 20 20 20 29 29 29  ath))))...   )))
9160: 29 0a 09 20 29 29 0a 20 20 20 20 20 72 75 6e 73  ).. )).     runs
9170: 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d  )))..;;=========
9180: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9190: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
91a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
91b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b  =============.;;
91c0: 20 52 6f 75 74 69 6e 65 73 20 66 6f 72 20 6d 61   Routines for ma
91d0: 6e 69 70 75 6c 61 74 69 6e 67 20 72 75 6e 73 0a  nipulating runs.
91e0: 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ;;==============
91f0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9200: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9210: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9220: 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 53 69 6e  ========..;; Sin
9230: 63 65 20 6d 61 6e 79 20 63 61 6c 6c 73 20 74 6f  ce many calls to
9240: 20 61 20 72 75 6e 20 72 65 71 75 69 72 65 20 70   a run require p
9250: 72 65 74 74 79 20 6d 75 63 68 20 74 68 65 20 73  retty much the s
9260: 61 6d 65 20 73 65 74 75 70 20 0a 3b 3b 20 74 68  ame setup .;; th
9270: 69 73 20 77 72 61 70 70 65 72 20 69 73 20 75 73  is wrapper is us
9280: 65 64 20 74 6f 20 72 65 64 75 63 65 20 74 68 65  ed to reduce the
9290: 20 72 65 70 6c 69 63 61 74 69 6f 6e 20 6f 66 20   replication of 
92a0: 63 6f 64 65 0a 28 64 65 66 69 6e 65 20 28 67 65  code.(define (ge
92b0: 6e 65 72 61 6c 2d 72 75 6e 2d 63 61 6c 6c 20 73  neral-run-call s
92c0: 77 69 74 63 68 6e 61 6d 65 20 61 63 74 69 6f 6e  witchname action
92d0: 2d 64 65 73 63 20 70 72 6f 63 29 0a 20 20 28 69  -desc proc).  (i
92e0: 66 20 28 6e 6f 74 20 28 61 72 67 73 3a 67 65 74  f (not (args:get
92f0: 2d 61 72 67 20 22 3a 72 75 6e 6e 61 6d 65 22 29  -arg ":runname")
9300: 29 0a 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09  ).      (begin..
9310: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
9320: 45 52 52 4f 52 3a 20 4d 69 73 73 69 6e 67 20 72  ERROR: Missing r
9330: 65 71 75 69 72 65 64 20 70 61 72 61 6d 65 74 65  equired paramete
9340: 72 20 66 6f 72 20 22 20 73 77 69 74 63 68 6e 61  r for " switchna
9350: 6d 65 20 22 2c 20 79 6f 75 20 6d 75 73 74 20 73  me ", you must s
9360: 70 65 63 69 66 79 20 74 68 65 20 72 75 6e 20 6e  pecify the run n
9370: 61 6d 65 20 77 69 74 68 20 3a 72 75 6e 6e 61 6d  ame with :runnam
9380: 65 20 72 75 6e 6e 61 6d 65 22 29 0a 09 28 65 78  e runname")..(ex
9390: 69 74 20 32 29 29 0a 20 20 20 20 20 20 28 6c 65  it 2)).      (le
93a0: 74 20 28 28 64 62 20 23 66 29 29 0a 09 28 69 66  t ((db #f))..(if
93b0: 20 28 6e 6f 74 20 28 73 65 74 75 70 2d 66 6f 72   (not (setup-for
93c0: 2d 72 75 6e 29 29 0a 09 20 20 20 20 28 62 65 67  -run))..    (beg
93d0: 69 6e 20 0a 09 20 20 20 20 20 20 28 64 65 62 75  in ..      (debu
93e0: 67 3a 70 72 69 6e 74 20 30 20 22 46 61 69 6c 65  g:print 0 "Faile
93f0: 64 20 74 6f 20 73 65 74 75 70 2c 20 65 78 69 74  d to setup, exit
9400: 69 6e 67 22 29 0a 09 20 20 20 20 20 20 28 65 78  ing")..      (ex
9410: 69 74 20 31 29 29 29 0a 09 28 73 65 74 21 20 64  it 1)))..(set! d
9420: 62 20 28 6f 70 65 6e 2d 64 62 29 29 0a 09 28 69  b (open-db))..(i
9430: 66 20 28 6e 6f 74 20 28 63 61 72 20 2a 63 6f 6e  f (not (car *con
9440: 66 69 67 69 6e 66 6f 2a 29 29 0a 09 20 20 20 20  figinfo*))..    
9450: 28 62 65 67 69 6e 0a 09 20 20 20 20 20 20 28 64  (begin..      (d
9460: 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52  ebug:print 0 "ER
9470: 52 4f 52 3a 20 41 74 74 65 6d 70 74 65 64 20 74  ROR: Attempted t
9480: 6f 20 22 20 61 63 74 69 6f 6e 2d 64 65 73 63 20  o " action-desc 
9490: 22 20 62 75 74 20 72 75 6e 20 61 72 65 61 20 63  " but run area c
94a0: 6f 6e 66 69 67 20 66 69 6c 65 20 6e 6f 74 20 66  onfig file not f
94b0: 6f 75 6e 64 22 29 0a 09 20 20 20 20 20 20 28 65  ound")..      (e
94c0: 78 69 74 20 31 29 29 0a 09 20 20 20 20 3b 3b 20  xit 1))..    ;; 
94d0: 45 78 74 72 61 63 74 20 6f 75 74 20 73 74 75 66  Extract out stuf
94e0: 66 20 6e 65 65 64 65 64 20 69 6e 20 6d 6f 73 74  f needed in most
94f0: 20 6f 72 20 6d 61 6e 79 20 63 61 6c 6c 73 0a 09   or many calls..
9500: 20 20 20 20 3b 3b 20 68 65 72 65 20 74 68 65 6e      ;; here then
9510: 20 63 61 6c 6c 20 70 72 6f 63 0a 09 20 20 20 20   call proc..    
9520: 28 6c 65 74 2a 20 28 28 6b 65 79 73 20 20 20 20  (let* ((keys    
9530: 20 20 20 28 64 62 2d 67 65 74 2d 6b 65 79 73 20     (db-get-keys 
9540: 64 62 29 29 0a 09 09 20 20 20 28 6b 65 79 6e 61  db))...   (keyna
9550: 6d 65 73 20 20 20 28 6d 61 70 20 6b 65 79 3a 67  mes   (map key:g
9560: 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65 79  et-fieldname key
9570: 73 29 29 0a 09 09 20 20 20 28 6b 65 79 76 61 6c  s))...   (keyval
9580: 6c 73 74 20 20 28 6b 65 79 73 2d 3e 76 61 6c 6c  lst  (keys->vall
9590: 69 73 74 20 6b 65 79 73 20 23 74 29 29 29 0a 09  ist keys #t)))..
95a0: 20 20 20 20 20 20 28 70 72 6f 63 20 64 62 20 6b        (proc db k
95b0: 65 79 73 20 6b 65 79 6e 61 6d 65 73 20 6b 65 79  eys keynames key
95c0: 76 61 6c 6c 73 74 29 29 29 0a 09 28 73 71 6c 69  vallst)))..(sqli
95d0: 74 65 33 3a 66 69 6e 61 6c 69 7a 65 21 20 64 62  te3:finalize! db
95e0: 29 0a 09 28 73 65 74 21 20 2a 64 69 64 73 6f 6d  )..(set! *didsom
95f0: 65 74 68 69 6e 67 2a 20 23 74 29 29 29 29 0a 0a  ething* #t))))..
9600: 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ;;==============
9610: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9620: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9630: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9640: 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 52 6f 6c 6c  ========.;; Roll
9650: 75 70 20 72 75 6e 73 0a 3b 3b 3d 3d 3d 3d 3d 3d  up runs.;;======
9660: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9670: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9680: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9690: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
96a0: 0a 0a 3b 3b 20 55 70 64 61 74 65 20 74 68 65 20  ..;; Update the 
96b0: 74 65 73 74 5f 6d 65 74 61 20 74 61 62 6c 65 20  test_meta table 
96c0: 66 6f 72 20 74 68 69 73 20 74 65 73 74 0a 28 64  for this test.(d
96d0: 65 66 69 6e 65 20 28 72 75 6e 73 3a 75 70 64 61  efine (runs:upda
96e0: 74 65 2d 74 65 73 74 5f 6d 65 74 61 20 64 62 20  te-test_meta db 
96f0: 74 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 2d 63  test-name test-c
9700: 6f 6e 66 29 0a 20 20 28 6c 65 74 20 28 28 63 75  onf).  (let ((cu
9710: 72 72 72 65 63 6f 72 64 20 28 64 62 3a 74 65 73  rrrecord (db:tes
9720: 74 6d 65 74 61 2d 67 65 74 2d 72 65 63 6f 72 64  tmeta-get-record
9730: 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 29 29 29   db test-name)))
9740: 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 63 75  .    (if (not cu
9750: 72 72 72 65 63 6f 72 64 29 0a 09 28 62 65 67 69  rrrecord)..(begi
9760: 6e 0a 09 20 20 28 73 65 74 21 20 63 75 72 72 72  n..  (set! currr
9770: 65 63 6f 72 64 20 28 6d 61 6b 65 2d 76 65 63 74  ecord (make-vect
9780: 6f 72 20 31 30 20 23 66 29 29 0a 09 20 20 28 64  or 10 #f))..  (d
9790: 62 3a 74 65 73 74 6d 65 74 61 2d 61 64 64 2d 72  b:testmeta-add-r
97a0: 65 63 6f 72 64 20 64 62 20 74 65 73 74 2d 6e 61  ecord db test-na
97b0: 6d 65 29 29 29 0a 20 20 20 20 28 66 6f 72 2d 65  me))).    (for-e
97c0: 61 63 68 20 0a 20 20 20 20 20 28 6c 61 6d 62 64  ach .     (lambd
97d0: 61 20 28 6b 65 79 29 0a 20 20 20 20 20 20 20 28  a (key).       (
97e0: 6c 65 74 2a 20 28 28 69 64 78 20 28 63 61 64 72  let* ((idx (cadr
97f0: 20 6b 65 79 29 29 0a 09 20 20 20 20 20 20 28 66   key))..      (f
9800: 6c 64 20 28 63 61 72 20 20 6b 65 79 29 29 0a 09  ld (car  key))..
9810: 20 20 20 20 20 20 28 76 61 6c 20 28 63 6f 6e 66        (val (conf
9820: 69 67 2d 6c 6f 6f 6b 75 70 20 74 65 73 74 2d 63  ig-lookup test-c
9830: 6f 6e 66 20 22 74 65 73 74 5f 6d 65 74 61 22 20  onf "test_meta" 
9840: 66 6c 64 29 29 29 0a 09 20 28 69 66 20 28 61 6e  fld))).. (if (an
9850: 64 20 76 61 6c 20 28 6e 6f 74 20 28 65 71 75 61  d val (not (equa
9860: 6c 3f 20 28 76 65 63 74 6f 72 2d 72 65 66 20 63  l? (vector-ref c
9870: 75 72 72 72 65 63 6f 72 64 20 69 64 78 29 20 76  urrrecord idx) v
9880: 61 6c 29 29 29 0a 09 20 20 20 20 20 28 62 65 67  al)))..     (beg
9890: 69 6e 0a 09 20 20 20 20 20 20 20 28 70 72 69 6e  in..       (prin
98a0: 74 20 22 55 70 64 61 74 69 6e 67 20 22 20 74 65  t "Updating " te
98b0: 73 74 2d 6e 61 6d 65 20 22 20 22 20 66 6c 64 20  st-name " " fld 
98c0: 22 20 74 6f 20 22 20 76 61 6c 29 0a 09 20 20 20  " to " val)..   
98d0: 20 20 20 20 28 64 62 3a 74 65 73 74 6d 65 74 61      (db:testmeta
98e0: 2d 75 70 64 61 74 65 2d 66 69 65 6c 64 20 64 62  -update-field db
98f0: 20 74 65 73 74 2d 6e 61 6d 65 20 66 6c 64 20 76   test-name fld v
9900: 61 6c 29 29 29 29 29 0a 20 20 20 20 20 27 28 28  al))))).     '((
9910: 22 61 75 74 68 6f 72 22 20 32 29 28 22 6f 77 6e  "author" 2)("own
9920: 65 72 22 20 33 29 28 22 64 65 73 63 72 69 70 74  er" 3)("descript
9930: 69 6f 6e 22 20 34 29 28 22 72 65 76 69 65 77 65  ion" 4)("reviewe
9940: 64 22 20 35 29 28 22 74 61 67 73 22 20 39 29 29  d" 5)("tags" 9))
9950: 29 29 29 0a 0a 3b 3b 20 55 70 64 61 74 65 20 74  )))..;; Update t
9960: 65 73 74 5f 6d 65 74 61 20 66 6f 72 20 61 6c 6c  est_meta for all
9970: 20 74 65 73 74 73 0a 28 64 65 66 69 6e 65 20 28   tests.(define (
9980: 72 75 6e 73 3a 75 70 64 61 74 65 2d 61 6c 6c 2d  runs:update-all-
9990: 74 65 73 74 5f 6d 65 74 61 20 64 62 29 0a 20 20  test_meta db).  
99a0: 28 6c 65 74 20 28 28 74 65 73 74 2d 6e 61 6d 65  (let ((test-name
99b0: 73 20 28 67 65 74 2d 61 6c 6c 2d 6c 65 67 61 6c  s (get-all-legal
99c0: 2d 74 65 73 74 73 29 29 29 0a 20 20 20 20 28 66  -tests))).    (f
99d0: 6f 72 2d 65 61 63 68 20 0a 20 20 20 20 20 28 6c  or-each .     (l
99e0: 61 6d 62 64 61 20 28 74 65 73 74 2d 6e 61 6d 65  ambda (test-name
99f0: 29 0a 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28  ).       (let* (
9a00: 28 74 65 73 74 2d 70 61 74 68 20 20 20 20 28 63  (test-path    (c
9a10: 6f 6e 63 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f  onc *toppath* "/
9a20: 74 65 73 74 73 2f 22 20 74 65 73 74 2d 6e 61 6d  tests/" test-nam
9a30: 65 29 29 0a 09 20 20 20 20 20 20 28 74 65 73 74  e))..      (test
9a40: 2d 63 6f 6e 66 69 67 66 20 28 63 6f 6e 63 20 74  -configf (conc t
9a50: 65 73 74 2d 70 61 74 68 20 22 2f 74 65 73 74 63  est-path "/testc
9a60: 6f 6e 66 69 67 22 29 29 0a 09 20 20 20 20 20 20  onfig"))..      
9a70: 28 74 65 73 74 65 78 69 73 74 73 20 20 20 28 61  (testexists   (a
9a80: 6e 64 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f  nd (file-exists?
9a90: 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 29 28 66   test-configf)(f
9aa0: 69 6c 65 2d 72 65 61 64 2d 61 63 63 65 73 73 3f  ile-read-access?
9ab0: 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 29 29 29   test-configf)))
9ac0: 0a 09 20 20 20 20 20 20 3b 3b 20 72 65 61 64 20  ..      ;; read 
9ad0: 63 6f 6e 66 69 67 73 20 77 69 74 68 20 74 72 69  configs with tri
9ae0: 63 6b 73 20 74 75 72 6e 65 64 20 6f 66 66 20 28  cks turned off (
9af0: 69 2e 65 2e 20 6e 6f 20 73 79 73 74 65 6d 29 0a  i.e. no system).
9b00: 09 20 20 20 20 20 20 28 74 65 73 74 2d 63 6f 6e  .      (test-con
9b10: 66 20 20 20 20 28 69 66 20 74 65 73 74 65 78 69  f    (if testexi
9b20: 73 74 73 20 28 72 65 61 64 2d 63 6f 6e 66 69 67  sts (read-config
9b30: 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 20 23 66   test-configf #f
9b40: 20 23 66 29 28 6d 61 6b 65 2d 68 61 73 68 2d 74   #f)(make-hash-t
9b50: 61 62 6c 65 29 29 29 29 0a 09 20 28 72 75 6e 73  able)))).. (runs
9b60: 3a 75 70 64 61 74 65 2d 74 65 73 74 5f 6d 65 74  :update-test_met
9b70: 61 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 20 74  a db test-name t
9b80: 65 73 74 2d 63 6f 6e 66 29 29 29 0a 20 20 20 20  est-conf))).    
9b90: 20 74 65 73 74 2d 6e 61 6d 65 73 29 29 29 0a 09   test-names)))..
9ba0: 20 0a 3b 3b 20 54 68 69 73 20 63 6f 75 6c 64 20   .;; This could 
9bb0: 70 72 6f 62 61 62 6c 79 20 62 65 20 72 65 66 61  probably be refa
9bc0: 63 74 6f 72 65 64 20 69 6e 74 6f 20 6f 6e 65 20  ctored into one 
9bd0: 63 6f 6d 70 6c 65 78 20 71 75 65 72 79 20 2e 2e  complex query ..
9be0: 2e 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a  ..(define (runs:
9bf0: 72 6f 6c 6c 75 70 2d 72 75 6e 20 64 62 20 6b 65  rollup-run db ke
9c00: 79 73 29 0a 20 20 28 6c 65 74 2a 20 28 28 6e 65  ys).  (let* ((ne
9c10: 77 2d 72 75 6e 2d 69 64 20 20 20 20 20 20 28 72  w-run-id      (r
9c20: 65 67 69 73 74 65 72 2d 72 75 6e 20 64 62 20 6b  egister-run db k
9c30: 65 79 73 29 29 0a 09 20 28 70 72 65 76 2d 74 65  eys)).. (prev-te
9c40: 73 74 73 20 20 20 20 20 20 28 74 65 73 74 3a 67  sts      (test:g
9c50: 65 74 2d 6d 61 74 63 68 69 6e 67 2d 70 72 65 76  et-matching-prev
9c60: 69 6f 75 73 2d 74 65 73 74 2d 72 75 6e 2d 72 65  ious-test-run-re
9c70: 63 6f 72 64 73 20 64 62 20 6e 65 77 2d 72 75 6e  cords db new-run
9c80: 2d 69 64 20 22 25 22 20 22 25 22 29 29 0a 09 20  -id "%" "%")).. 
9c90: 28 63 75 72 72 2d 74 65 73 74 73 20 20 20 20 20  (curr-tests     
9ca0: 20 28 64 62 2d 67 65 74 2d 74 65 73 74 73 2d 66   (db-get-tests-f
9cb0: 6f 72 2d 72 75 6e 20 64 62 20 6e 65 77 2d 72 75  or-run db new-ru
9cc0: 6e 2d 69 64 20 22 25 22 20 22 25 22 29 29 0a 09  n-id "%" "%"))..
9cd0: 20 28 63 75 72 72 2d 74 65 73 74 73 2d 68 61 73   (curr-tests-has
9ce0: 68 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62  h (make-hash-tab
9cf0: 6c 65 29 29 29 0a 20 20 20 20 3b 3b 20 69 6e 64  le))).    ;; ind
9d00: 65 78 20 74 68 65 20 61 6c 72 65 61 64 79 20 73  ex the already s
9d10: 61 76 65 64 20 74 65 73 74 73 20 62 79 20 74 65  aved tests by te
9d20: 73 74 6e 61 6d 65 20 61 6e 64 20 69 74 65 6d 70  stname and itemp
9d30: 61 74 68 20 69 6e 20 63 75 72 72 2d 74 65 73 74  ath in curr-test
9d40: 73 2d 68 61 73 68 0a 20 20 20 20 28 66 6f 72 2d  s-hash.    (for-
9d50: 65 61 63 68 0a 20 20 20 20 20 28 6c 61 6d 62 64  each.     (lambd
9d60: 61 20 28 74 65 73 74 64 61 74 29 0a 20 20 20 20  a (testdat).    
9d70: 20 20 20 28 6c 65 74 2a 20 28 28 74 65 73 74 6e     (let* ((testn
9d80: 61 6d 65 20 20 28 64 62 3a 74 65 73 74 2d 67 65  ame  (db:test-ge
9d90: 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 64  t-testname testd
9da0: 61 74 29 29 0a 09 20 20 20 20 20 20 28 69 74 65  at))..      (ite
9db0: 6d 2d 70 61 74 68 20 28 64 62 3a 74 65 73 74 2d  m-path (db:test-
9dc0: 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74 65  get-item-path te
9dd0: 73 74 64 61 74 29 29 0a 09 20 20 20 20 20 20 28  stdat))..      (
9de0: 66 75 6c 6c 2d 6e 61 6d 65 20 28 63 6f 6e 63 20  full-name (conc 
9df0: 74 65 73 74 6e 61 6d 65 20 22 2f 22 20 69 74 65  testname "/" ite
9e00: 6d 2d 70 61 74 68 29 29 29 0a 09 20 28 68 61 73  m-path))).. (has
9e10: 68 2d 74 61 62 6c 65 2d 73 65 74 21 20 63 75 72  h-table-set! cur
9e20: 72 2d 74 65 73 74 73 2d 68 61 73 68 20 66 75 6c  r-tests-hash ful
9e30: 6c 2d 6e 61 6d 65 20 74 65 73 74 64 61 74 29 29  l-name testdat))
9e40: 29 0a 20 20 20 20 20 63 75 72 72 2d 74 65 73 74  ).     curr-test
9e50: 73 29 0a 20 20 20 20 3b 3b 20 4e 4f 50 45 3a 20  s).    ;; NOPE: 
9e60: 4e 6f 6e 2d 6f 70 74 69 6d 61 6c 20 61 70 70 72  Non-optimal appr
9e70: 6f 61 63 68 2e 20 54 72 79 20 74 68 69 73 20 69  oach. Try this i
9e80: 6e 73 74 65 61 64 2e 0a 20 20 20 20 3b 3b 20 20  nstead..    ;;  
9e90: 20 31 2e 20 74 65 73 74 73 20 61 72 65 20 72 65   1. tests are re
9ea0: 63 65 69 76 65 64 20 69 6e 20 61 20 6c 69 73 74  ceived in a list
9eb0: 2c 20 6d 6f 73 74 20 72 65 63 65 6e 74 20 66 69  , most recent fi
9ec0: 72 73 74 0a 20 20 20 20 3b 3b 20 20 20 32 2e 20  rst.    ;;   2. 
9ed0: 72 65 70 6c 61 63 65 20 74 68 65 20 72 6f 6c 6c  replace the roll
9ee0: 75 70 20 74 65 73 74 20 77 69 74 68 20 74 68 65  up test with the
9ef0: 20 6e 65 77 20 2a 61 6c 77 61 79 73 2a 0a 20 20   new *always*.  
9f00: 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 20 20    (for-each .   
9f10: 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74 64    (lambda (testd
9f20: 61 74 29 0a 20 20 20 20 20 20 20 28 6c 65 74 2a  at).       (let*
9f30: 20 28 28 74 65 73 74 6e 61 6d 65 20 20 28 64 62   ((testname  (db
9f40: 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61  :test-get-testna
9f50: 6d 65 20 74 65 73 74 64 61 74 29 29 0a 09 20 20  me testdat))..  
9f60: 20 20 20 20 28 69 74 65 6d 2d 70 61 74 68 20 28      (item-path (
9f70: 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d  db:test-get-item
9f80: 2d 70 61 74 68 20 74 65 73 74 64 61 74 29 29 0a  -path testdat)).
9f90: 09 20 20 20 20 20 20 28 66 75 6c 6c 2d 6e 61 6d  .      (full-nam
9fa0: 65 20 28 63 6f 6e 63 20 74 65 73 74 6e 61 6d 65  e (conc testname
9fb0: 20 22 2f 22 20 69 74 65 6d 2d 70 61 74 68 29 29   "/" item-path))
9fc0: 0a 09 20 20 20 20 20 20 28 70 72 65 76 2d 74 65  ..      (prev-te
9fd0: 73 74 2d 64 61 74 20 28 68 61 73 68 2d 74 61 62  st-dat (hash-tab
9fe0: 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 63  le-ref/default c
9ff0: 75 72 72 2d 74 65 73 74 73 2d 68 61 73 68 20 66  urr-tests-hash f
a000: 75 6c 6c 2d 6e 61 6d 65 20 23 66 29 29 0a 09 20  ull-name #f)).. 
a010: 20 20 20 20 20 28 74 65 73 74 2d 73 74 65 70 73       (test-steps
a020: 20 20 20 20 20 20 28 64 62 3a 67 65 74 2d 73 74        (db:get-st
a030: 65 70 73 2d 66 6f 72 2d 74 65 73 74 20 64 62 20  eps-for-test db 
a040: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20  (db:test-get-id 
a050: 74 65 73 74 64 61 74 29 29 29 0a 09 20 20 20 20  testdat)))..    
a060: 20 20 28 6e 65 77 2d 74 65 73 74 2d 72 65 63 6f    (new-test-reco
a070: 72 64 20 23 66 29 29 0a 09 20 3b 3b 20 72 65 70  rd #f)).. ;; rep
a080: 6c 61 63 65 20 74 68 65 73 65 20 77 69 74 68 20  lace these with 
a090: 69 6e 73 65 72 74 20 2e 2e 2e 20 73 65 6c 65 63  insert ... selec
a0a0: 74 0a 09 20 28 61 70 70 6c 79 20 73 71 6c 69 74  t.. (apply sqlit
a0b0: 65 33 3a 65 78 65 63 75 74 65 20 0a 09 09 64 62  e3:execute ...db
a0c0: 20 0a 09 09 28 63 6f 6e 63 20 22 49 4e 53 45 52   ...(conc "INSER
a0d0: 54 20 4f 52 20 52 45 50 4c 41 43 45 20 49 4e 54  T OR REPLACE INT
a0e0: 4f 20 74 65 73 74 73 20 28 72 75 6e 5f 69 64 2c  O tests (run_id,
a0f0: 74 65 73 74 6e 61 6d 65 2c 73 74 61 74 65 2c 73  testname,state,s
a100: 74 61 74 75 73 2c 65 76 65 6e 74 5f 74 69 6d 65  tatus,event_time
a110: 2c 68 6f 73 74 2c 63 70 75 6c 6f 61 64 2c 64 69  ,host,cpuload,di
a120: 73 6b 66 72 65 65 2c 75 6e 61 6d 65 2c 72 75 6e  skfree,uname,run
a130: 64 69 72 2c 69 74 65 6d 5f 70 61 74 68 2c 72 75  dir,item_path,ru
a140: 6e 5f 64 75 72 61 74 69 6f 6e 2c 66 69 6e 61 6c  n_duration,final
a150: 5f 6c 6f 67 66 2c 63 6f 6d 6d 65 6e 74 2c 66 69  _logf,comment,fi
a160: 72 73 74 5f 65 72 72 2c 66 69 72 73 74 5f 77 61  rst_err,first_wa
a170: 72 6e 29 20 22 0a 09 09 20 20 20 20 20 20 22 56  rn) "...      "V
a180: 41 4c 55 45 53 20 28 3f 2c 3f 2c 3f 2c 3f 2c 3f  ALUES (?,?,?,?,?
a190: 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f  ,?,?,?,?,?,?,?,?
a1a0: 2c 3f 2c 3f 2c 3f 29 3b 22 29 0a 09 09 6e 65 77  ,?,?,?);")...new
a1b0: 2d 72 75 6e 2d 69 64 20 28 63 64 64 72 20 28 76  -run-id (cddr (v
a1c0: 65 63 74 6f 72 2d 3e 6c 69 73 74 20 74 65 73 74  ector->list test
a1d0: 64 61 74 29 29 29 0a 09 20 28 73 65 74 21 20 6e  dat))).. (set! n
a1e0: 65 77 2d 74 65 73 74 64 61 74 20 28 63 61 72 20  ew-testdat (car 
a1f0: 28 64 62 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f  (db-get-tests-fo
a200: 72 2d 72 75 6e 20 64 62 20 6e 65 77 2d 72 75 6e  r-run db new-run
a210: 2d 69 64 20 74 65 73 74 6e 61 6d 65 20 69 74 65  -id testname ite
a220: 6d 2d 70 61 74 68 29 29 29 0a 09 20 28 68 61 73  m-path))).. (has
a230: 68 2d 74 61 62 6c 65 2d 73 65 74 21 20 63 75 72  h-table-set! cur
a240: 72 2d 74 65 73 74 73 2d 68 61 73 68 20 66 75 6c  r-tests-hash ful
a250: 6c 2d 6e 61 6d 65 20 6e 65 77 2d 74 65 73 74 64  l-name new-testd
a260: 61 74 29 20 3b 3b 20 74 68 69 73 20 63 6f 75 6c  at) ;; this coul
a270: 64 20 62 65 20 63 6f 6e 66 75 73 69 6e 67 2c 20  d be confusing, 
a280: 77 68 69 63 68 20 72 65 63 6f 72 64 20 73 68 6f  which record sho
a290: 75 6c 64 20 67 6f 20 69 6e 74 6f 20 74 68 65 20  uld go into the 
a2a0: 6c 6f 6f 6b 75 70 20 74 61 62 6c 65 3f 0a 09 20  lookup table?.. 
a2b0: 3b 3b 20 4e 6f 77 20 64 75 70 6c 69 63 61 74 65  ;; Now duplicate
a2c0: 20 74 68 65 20 74 65 73 74 20 73 74 65 70 73 0a   the test steps.
a2d0: 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34  . (debug:print 4
a2e0: 20 22 43 6f 70 79 69 6e 67 20 72 65 63 6f 72 64   "Copying record
a2f0: 73 20 69 6e 20 74 65 73 74 5f 73 74 65 70 73 20  s in test_steps 
a300: 66 72 6f 6d 20 74 65 73 74 5f 69 64 3d 22 20 28  from test_id=" (
a310: 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74  db:test-get-id t
a320: 65 73 74 64 61 74 29 20 22 20 74 6f 20 22 20 28  estdat) " to " (
a330: 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 6e  db:test-get-id n
a340: 65 77 2d 74 65 73 74 64 61 74 29 29 0a 09 20 28  ew-testdat)).. (
a350: 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20  sqlite3:execute 
a360: 0a 09 20 20 64 62 20 0a 09 20 20 28 63 6f 6e 63  ..  db ..  (conc
a370: 20 22 49 4e 53 45 52 54 20 4f 52 20 52 45 50 4c   "INSERT OR REPL
a380: 41 43 45 20 49 4e 54 4f 20 74 65 73 74 5f 73 74  ACE INTO test_st
a390: 65 70 73 20 28 74 65 73 74 5f 69 64 2c 73 74 65  eps (test_id,ste
a3a0: 70 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 61 74  pname,state,stat
a3b0: 75 73 2c 65 76 65 6e 74 5f 74 69 6d 65 2c 63 6f  us,event_time,co
a3c0: 6d 6d 65 6e 74 29 20 22 0a 09 09 22 53 45 4c 45  mment) "..."SELE
a3d0: 43 54 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65  CT " (db:test-ge
a3e0: 74 2d 69 64 20 6e 65 77 2d 74 65 73 74 64 61 74  t-id new-testdat
a3f0: 29 20 22 2c 73 74 65 70 6e 61 6d 65 2c 73 74 61  ) ",stepname,sta
a400: 74 65 2c 73 74 61 74 75 73 2c 65 76 65 6e 74 5f  te,status,event_
a410: 74 69 6d 65 2c 63 6f 6d 6d 65 6e 74 20 46 52 4f  time,comment FRO
a420: 4d 20 74 65 73 74 5f 73 74 65 70 73 20 57 48 45  M test_steps WHE
a430: 52 45 20 74 65 73 74 5f 69 64 3d 3f 3b 22 29 0a  RE test_id=?;").
a440: 09 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  .  (db:test-get-
a450: 69 64 20 74 65 73 74 64 61 74 29 29 0a 09 20 3b  id testdat)).. ;
a460: 3b 20 4e 6f 77 20 64 75 70 6c 69 63 61 74 65 20  ; Now duplicate 
a470: 74 68 65 20 74 65 73 74 20 64 61 74 61 0a 09 20  the test data.. 
a480: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22  (debug:print 4 "
a490: 43 6f 70 79 69 6e 67 20 72 65 63 6f 72 64 73 20  Copying records 
a4a0: 69 6e 20 74 65 73 74 5f 64 61 74 61 20 66 72 6f  in test_data fro
a4b0: 6d 20 74 65 73 74 5f 69 64 3d 22 20 28 64 62 3a  m test_id=" (db:
a4c0: 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74  test-get-id test
a4d0: 64 61 74 29 20 22 20 74 6f 20 22 20 28 64 62 3a  dat) " to " (db:
a4e0: 74 65 73 74 2d 67 65 74 2d 69 64 20 6e 65 77 2d  test-get-id new-
a4f0: 74 65 73 74 64 61 74 29 29 0a 09 20 28 73 71 6c  testdat)).. (sql
a500: 69 74 65 33 3a 65 78 65 63 75 74 65 20 0a 09 20  ite3:execute .. 
a510: 20 64 62 20 0a 09 20 20 28 63 6f 6e 63 20 22 49   db ..  (conc "I
a520: 4e 53 45 52 54 20 4f 52 20 52 45 50 4c 41 43 45  NSERT OR REPLACE
a530: 20 49 4e 54 4f 20 74 65 73 74 5f 64 61 74 61 20   INTO test_data 
a540: 28 74 65 73 74 5f 69 64 2c 63 61 74 65 67 6f 72  (test_id,categor
a550: 79 2c 76 61 72 69 61 62 6c 65 2c 76 61 6c 75 65  y,variable,value
a560: 2c 65 78 70 65 63 74 65 64 2c 74 6f 6c 2c 75 6e  ,expected,tol,un
a570: 69 74 73 2c 63 6f 6d 6d 65 6e 74 29 20 22 0a 09  its,comment) "..
a580: 09 22 53 45 4c 45 43 54 20 22 20 28 64 62 3a 74  ."SELECT " (db:t
a590: 65 73 74 2d 67 65 74 2d 69 64 20 6e 65 77 2d 74  est-get-id new-t
a5a0: 65 73 74 64 61 74 29 20 22 2c 63 61 74 65 67 6f  estdat) ",catego
a5b0: 72 79 2c 76 61 72 69 61 62 6c 65 2c 76 61 6c 75  ry,variable,valu
a5c0: 65 2c 65 78 70 65 63 74 65 64 2c 74 6f 6c 2c 75  e,expected,tol,u
a5d0: 6e 69 74 73 2c 63 6f 6d 6d 65 6e 74 20 46 52 4f  nits,comment FRO
a5e0: 4d 20 74 65 73 74 5f 64 61 74 61 20 57 48 45 52  M test_data WHER
a5f0: 45 20 74 65 73 74 5f 69 64 3d 3f 3b 22 29 0a 09  E test_id=?;")..
a600: 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69    (db:test-get-i
a610: 64 20 74 65 73 74 64 61 74 29 29 0a 09 20 29 29  d testdat)).. ))
a620: 0a 20 20 20 20 20 70 72 65 76 2d 74 65 73 74 73  .     prev-tests
a630: 29 29 29 0a 09 20 0a 20 20 20 20 20 0a           ))).. .     .