Megatest

Hex Artifact Content
Login

Artifact ba29b0b8e2e2b1ce75b3c842e8b03f835d39ccba:


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 69 66 20 28 6e 75 6c  ..      (if (nul
1420: 6c 3f 20 72 65 73 75 6c 74 73 29 20 23 66 0a 09  l? results) #f..
1430: 09 09 20 20 28 63 61 72 20 72 65 73 75 6c 74 73  ..  (car results
1440: 29 29 29 29 29 29 29 29 29 29 0a 20 20 20 20 0a  )))))))))).    .
1450: 3b 3b 20 67 65 74 20 74 68 65 20 70 72 65 76 69  ;; get the previ
1460: 6f 75 73 20 72 65 63 6f 72 64 73 20 66 6f 72 20  ous records for 
1470: 77 68 65 6e 20 74 68 65 73 65 20 74 65 73 74 73  when these tests
1480: 20 77 65 72 65 20 72 75 6e 20 77 68 65 72 65 20   were run where 
1490: 61 6c 6c 20 6b 65 79 73 20 6d 61 74 63 68 20 62  all keys match b
14a0: 75 74 20 72 75 6e 6e 61 6d 65 0a 3b 3b 20 4e 42  ut runname.;; NB
14b0: 2f 2f 20 4d 65 72 67 65 20 74 68 69 73 20 77 69  // Merge this wi
14c0: 74 68 20 74 65 73 74 3a 67 65 74 2d 70 72 65 76  th test:get-prev
14d0: 69 6f 75 73 2d 74 65 73 74 2d 72 75 6e 2d 72 65  ious-test-run-re
14e0: 63 6f 72 64 73 3f 20 54 68 69 73 20 6f 6e 65 20  cords? This one 
14f0: 6c 6f 6f 6b 73 20 66 6f 72 20 61 6c 6c 20 6d 61  looks for all ma
1500: 74 63 68 69 6e 67 20 74 65 73 74 73 0a 3b 3b 20  tching tests.;; 
1510: 63 61 6e 20 75 73 65 20 77 69 6c 64 63 61 72 64  can use wildcard
1520: 73 2e 20 0a 28 64 65 66 69 6e 65 20 28 74 65 73  s. .(define (tes
1530: 74 3a 67 65 74 2d 6d 61 74 63 68 69 6e 67 2d 70  t:get-matching-p
1540: 72 65 76 69 6f 75 73 2d 74 65 73 74 2d 72 75 6e  revious-test-run
1550: 2d 72 65 63 6f 72 64 73 20 64 62 20 72 75 6e 2d  -records db run-
1560: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65  id test-name ite
1570: 6d 2d 70 61 74 68 29 0a 20 20 28 6c 65 74 2a 20  m-path).  (let* 
1580: 28 28 6b 65 79 73 20 20 20 20 28 64 62 3a 67 65  ((keys    (db:ge
1590: 74 2d 6b 65 79 73 20 64 62 29 29 0a 09 20 28 73  t-keys db)).. (s
15a0: 65 6c 73 74 72 20 20 28 73 74 72 69 6e 67 2d 69  elstr  (string-i
15b0: 6e 74 65 72 73 70 65 72 73 65 20 28 6d 61 70 20  ntersperse (map 
15c0: 28 6c 61 6d 62 64 61 20 28 78 29 28 76 65 63 74  (lambda (x)(vect
15d0: 6f 72 2d 72 65 66 20 78 20 30 29 29 20 6b 65 79  or-ref x 0)) key
15e0: 73 29 20 22 2c 22 29 29 0a 09 20 28 71 72 79 73  s) ",")).. (qrys
15f0: 74 72 20 20 28 73 74 72 69 6e 67 2d 69 6e 74 65  tr  (string-inte
1600: 72 73 70 65 72 73 65 20 28 6d 61 70 20 28 6c 61  rsperse (map (la
1610: 6d 62 64 61 20 28 78 29 28 63 6f 6e 63 20 28 76  mbda (x)(conc (v
1620: 65 63 74 6f 72 2d 72 65 66 20 78 20 30 29 20 22  ector-ref x 0) "
1630: 3d 3f 22 29 29 20 6b 65 79 73 29 20 22 20 41 4e  =?")) keys) " AN
1640: 44 20 22 29 29 0a 09 20 28 6b 65 79 76 61 6c 73  D ")).. (keyvals
1650: 20 23 66 29 0a 09 20 28 74 65 73 74 73 2d 68 61   #f).. (tests-ha
1660: 73 68 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61  sh (make-hash-ta
1670: 62 6c 65 29 29 29 0a 20 20 20 20 3b 3b 20 66 69  ble))).    ;; fi
1680: 72 73 74 20 6c 6f 6f 6b 20 75 70 20 74 68 65 20  rst look up the 
1690: 6b 65 79 20 76 61 6c 75 65 73 20 66 72 6f 6d 20  key values from 
16a0: 74 68 65 20 72 75 6e 20 73 65 6c 65 63 74 65 64  the run selected
16b0: 20 62 79 20 72 75 6e 2d 69 64 0a 20 20 20 20 28   by run-id.    (
16c0: 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68  sqlite3:for-each
16d0: 2d 72 6f 77 20 0a 20 20 20 20 20 28 6c 61 6d 62  -row .     (lamb
16e0: 64 61 20 28 61 20 2e 20 62 29 0a 20 20 20 20 20  da (a . b).     
16f0: 20 20 28 73 65 74 21 20 6b 65 79 76 61 6c 73 20    (set! keyvals 
1700: 28 63 6f 6e 73 20 61 20 62 29 29 29 0a 20 20 20  (cons a b))).   
1710: 20 20 64 62 0a 20 20 20 20 20 28 63 6f 6e 63 20    db.     (conc 
1720: 22 53 45 4c 45 43 54 20 22 20 73 65 6c 73 74 72  "SELECT " selstr
1730: 20 22 20 46 52 4f 4d 20 72 75 6e 73 20 57 48 45   " FROM runs WHE
1740: 52 45 20 69 64 3d 3f 20 4f 52 44 45 52 20 42 59  RE id=? ORDER BY
1750: 20 65 76 65 6e 74 5f 74 69 6d 65 20 44 45 53 43   event_time DESC
1760: 3b 22 29 20 72 75 6e 2d 69 64 29 0a 20 20 20 20  ;") run-id).    
1770: 28 69 66 20 28 6e 6f 74 20 6b 65 79 76 61 6c 73  (if (not keyvals
1780: 29 0a 09 27 28 29 0a 09 28 6c 65 74 20 28 28 70  )..'()..(let ((p
1790: 72 65 76 2d 72 75 6e 2d 69 64 73 20 27 28 29 29  rev-run-ids '())
17a0: 29 0a 09 20 20 28 61 70 70 6c 79 20 73 71 6c 69  )..  (apply sqli
17b0: 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77  te3:for-each-row
17c0: 0a 09 09 20 28 6c 61 6d 62 64 61 20 28 69 64 29  ... (lambda (id)
17d0: 0a 09 09 20 20 20 28 73 65 74 21 20 70 72 65 76  ...   (set! prev
17e0: 2d 72 75 6e 2d 69 64 73 20 28 63 6f 6e 73 20 69  -run-ids (cons i
17f0: 64 20 70 72 65 76 2d 72 75 6e 2d 69 64 73 29 29  d prev-run-ids))
1800: 29 0a 09 09 20 64 62 0a 09 09 20 28 63 6f 6e 63  )... db... (conc
1810: 20 22 53 45 4c 45 43 54 20 69 64 20 46 52 4f 4d   "SELECT id FROM
1820: 20 72 75 6e 73 20 57 48 45 52 45 20 22 20 71 72   runs WHERE " qr
1830: 79 73 74 72 20 22 20 41 4e 44 20 69 64 20 21 3d  ystr " AND id !=
1840: 20 3f 3b 22 29 20 28 61 70 70 65 6e 64 20 6b 65   ?;") (append ke
1850: 79 76 61 6c 73 20 28 6c 69 73 74 20 72 75 6e 2d  yvals (list run-
1860: 69 64 29 29 29 0a 09 20 20 3b 3b 20 63 6f 6c 6c  id)))..  ;; coll
1870: 65 63 74 20 61 6c 6c 20 6d 61 74 63 68 69 6e 67  ect all matching
1880: 20 74 65 73 74 73 20 66 6f 72 20 74 68 65 20 72   tests for the r
1890: 75 6e 73 20 74 68 65 6e 0a 09 20 20 3b 3b 20 65  uns then..  ;; e
18a0: 78 74 72 61 63 74 20 74 68 65 20 6d 6f 73 74 20  xtract the most 
18b0: 72 65 63 65 6e 74 20 74 65 73 74 20 61 6e 64 20  recent test and 
18c0: 72 65 74 75 72 6e 20 74 68 61 74 2e 0a 09 20 20  return that...  
18d0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22  (debug:print 4 "
18e0: 73 65 6c 73 74 72 3a 20 22 20 73 65 6c 73 74 72  selstr: " selstr
18f0: 20 22 2c 20 71 72 79 73 74 72 3a 20 22 20 71 72   ", qrystr: " qr
1900: 79 73 74 72 20 22 2c 20 6b 65 79 76 61 6c 73 3a  ystr ", keyvals:
1910: 20 22 20 6b 65 79 76 61 6c 73 20 0a 09 09 20 20   " keyvals ...  
1920: 20 20 20 20 20 22 2c 20 70 72 65 76 69 6f 75 73       ", previous
1930: 20 72 75 6e 20 69 64 73 20 66 6f 75 6e 64 3a 20   run ids found: 
1940: 22 20 70 72 65 76 2d 72 75 6e 2d 69 64 73 29 0a  " prev-run-ids).
1950: 09 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 70 72  .  (if (null? pr
1960: 65 76 2d 72 75 6e 2d 69 64 73 29 20 27 28 29 20  ev-run-ids) '() 
1970: 20 3b 3b 20 6e 6f 20 70 72 65 76 69 6f 75 73 20   ;; no previous 
1980: 72 75 6e 73 3f 20 72 65 74 75 72 6e 20 6e 75 6c  runs? return nul
1990: 6c 0a 09 20 20 20 20 20 20 28 6c 65 74 20 6c 6f  l..      (let lo
19a0: 6f 70 20 28 28 68 65 64 20 28 63 61 72 20 70 72  op ((hed (car pr
19b0: 65 76 2d 72 75 6e 2d 69 64 73 29 29 0a 09 09 09  ev-run-ids))....
19c0: 20 28 74 61 6c 20 28 63 64 72 20 70 72 65 76 2d   (tal (cdr prev-
19d0: 72 75 6e 2d 69 64 73 29 29 29 0a 09 09 28 6c 65  run-ids)))...(le
19e0: 74 20 28 28 72 65 73 75 6c 74 73 20 28 64 62 2d  t ((results (db-
19f0: 67 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d 72 75  get-tests-for-ru
1a00: 6e 20 64 62 20 68 65 64 20 74 65 73 74 2d 6e 61  n db hed test-na
1a10: 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a  me item-path))).
1a20: 09 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ..  (debug:print
1a30: 20 34 20 22 47 6f 74 20 74 65 73 74 73 20 66 6f   4 "Got tests fo
1a40: 72 20 72 75 6e 2d 69 64 20 22 20 72 75 6e 2d 69  r run-id " run-i
1a50: 64 20 22 2c 20 74 65 73 74 2d 6e 61 6d 65 20 22  d ", test-name "
1a60: 20 74 65 73 74 2d 6e 61 6d 65 20 0a 09 09 09 20   test-name .... 
1a70: 20 20 20 20 20 20 22 2c 20 69 74 65 6d 2d 70 61        ", item-pa
1a80: 74 68 20 22 20 69 74 65 6d 2d 70 61 74 68 20 22  th " item-path "
1a90: 20 72 65 73 75 6c 74 73 3a 20 22 20 28 69 6e 74   results: " (int
1aa0: 65 72 73 70 65 72 73 65 20 72 65 73 75 6c 74 73  ersperse results
1ab0: 20 22 5c 6e 22 29 29 0a 09 09 20 20 3b 3b 20 4b   "\n"))...  ;; K
1ac0: 65 65 70 20 6f 6e 6c 79 20 74 68 65 20 79 6f 75  eep only the you
1ad0: 6e 67 65 73 74 20 6f 66 20 61 6e 79 20 74 65 73  ngest of any tes
1ae0: 74 2f 69 74 65 6d 20 63 6f 6d 62 69 6e 61 74 69  t/item combinati
1af0: 6f 6e 0a 09 09 20 20 28 66 6f 72 2d 65 61 63 68  on...  (for-each
1b00: 20 0a 09 09 20 20 20 28 6c 61 6d 62 64 61 20 28   ...   (lambda (
1b10: 74 65 73 74 64 61 74 29 0a 09 09 20 20 20 20 20  testdat)...     
1b20: 28 6c 65 74 2a 20 28 28 66 75 6c 6c 2d 74 65 73  (let* ((full-tes
1b30: 74 6e 61 6d 65 20 28 63 6f 6e 63 20 28 64 62 3a  tname (conc (db:
1b40: 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d  test-get-testnam
1b50: 65 20 74 65 73 74 64 61 74 29 20 22 2f 22 20 28  e testdat) "/" (
1b60: 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d  db:test-get-item
1b70: 2d 70 61 74 68 20 74 65 73 74 64 61 74 29 29 29  -path testdat)))
1b80: 0a 09 09 09 20 20 20 20 28 73 74 6f 72 65 64 2d  ....    (stored-
1b90: 74 65 73 74 20 20 20 28 68 61 73 68 2d 74 61 62  test   (hash-tab
1ba0: 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 74  le-ref/default t
1bb0: 65 73 74 73 2d 68 61 73 68 20 66 75 6c 6c 2d 74  ests-hash full-t
1bc0: 65 73 74 6e 61 6d 65 20 23 66 29 29 29 0a 09 09  estname #f)))...
1bd0: 20 20 20 20 20 20 20 28 69 66 20 28 6f 72 20 28         (if (or (
1be0: 6e 6f 74 20 73 74 6f 72 65 64 2d 74 65 73 74 29  not stored-test)
1bf0: 0a 09 09 09 20 20 20 20 20 20 20 28 61 6e 64 20  ....       (and 
1c00: 73 74 6f 72 65 64 2d 74 65 73 74 0a 09 09 09 09  stored-test.....
1c10: 20 20 20 20 28 3e 20 28 64 62 3a 74 65 73 74 2d      (> (db:test-
1c20: 67 65 74 2d 65 76 65 6e 74 5f 74 69 6d 65 20 74  get-event_time t
1c30: 65 73 74 64 61 74 29 28 64 62 3a 74 65 73 74 2d  estdat)(db:test-
1c40: 67 65 74 2d 65 76 65 6e 74 5f 74 69 6d 65 20 73  get-event_time s
1c50: 74 6f 72 65 64 2d 74 65 73 74 29 29 29 29 0a 09  tored-test))))..
1c60: 09 09 20 20 20 3b 3b 20 74 68 69 73 20 74 65 73  ..   ;; this tes
1c70: 74 20 69 73 20 79 6f 75 6e 67 65 72 2c 20 73 74  t is younger, st
1c80: 6f 72 65 20 69 74 20 69 6e 20 74 68 65 20 68 61  ore it in the ha
1c90: 73 68 0a 09 09 09 20 20 20 28 68 61 73 68 2d 74  sh....   (hash-t
1ca0: 61 62 6c 65 2d 73 65 74 21 20 74 65 73 74 73 2d  able-set! tests-
1cb0: 68 61 73 68 20 66 75 6c 6c 2d 74 65 73 74 6e 61  hash full-testna
1cc0: 6d 65 20 74 65 73 74 64 61 74 29 29 29 29 0a 09  me testdat))))..
1cd0: 09 20 20 20 72 65 73 75 6c 74 73 29 0a 09 09 20  .   results)... 
1ce0: 20 28 69 66 20 28 6e 75 6c 6c 3f 20 74 61 6c 29   (if (null? tal)
1cf0: 0a 09 09 20 20 20 20 20 20 28 6d 61 70 20 63 64  ...      (map cd
1d00: 72 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 3e 61  r (hash-table->a
1d10: 6c 69 73 74 20 74 65 73 74 73 2d 68 61 73 68 29  list tests-hash)
1d20: 29 20 3b 3b 20 72 65 74 75 72 6e 20 61 20 6c 69  ) ;; return a li
1d30: 73 74 20 6f 66 20 74 68 65 20 6d 6f 73 74 20 72  st of the most r
1d40: 65 63 65 6e 74 20 74 65 73 74 73 0a 09 09 20 20  ecent tests...  
1d50: 20 20 20 20 28 6c 6f 6f 70 20 28 63 61 72 20 74      (loop (car t
1d60: 61 6c 29 28 63 64 72 20 74 61 6c 29 29 29 29 29  al)(cdr tal)))))
1d70: 29 29 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28  )))))..(define (
1d80: 74 65 73 74 2d 73 65 74 2d 73 74 61 74 75 73 21  test-set-status!
1d90: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d   db run-id test-
1da0: 6e 61 6d 65 20 73 74 61 74 65 20 73 74 61 74 75  name state statu
1db0: 73 20 69 74 65 6d 64 61 74 2d 6f 72 2d 70 61 74  s itemdat-or-pat
1dc0: 68 20 63 6f 6d 6d 65 6e 74 20 64 61 74 29 0a 20  h comment dat). 
1dd0: 20 28 6c 65 74 2a 20 28 28 72 65 61 6c 2d 73 74   (let* ((real-st
1de0: 61 74 75 73 20 73 74 61 74 75 73 29 0a 09 20 28  atus status).. (
1df0: 69 74 65 6d 2d 70 61 74 68 20 20 20 28 69 66 20  item-path   (if 
1e00: 28 73 74 72 69 6e 67 3f 20 69 74 65 6d 64 61 74  (string? itemdat
1e10: 2d 6f 72 2d 70 61 74 68 29 20 69 74 65 6d 64 61  -or-path) itemda
1e20: 74 2d 6f 72 2d 70 61 74 68 20 28 69 74 65 6d 2d  t-or-path (item-
1e30: 6c 69 73 74 2d 3e 70 61 74 68 20 69 74 65 6d 64  list->path itemd
1e40: 61 74 2d 6f 72 2d 70 61 74 68 29 29 29 0a 09 20  at-or-path))).. 
1e50: 28 74 65 73 74 64 61 74 20 20 20 20 20 28 64 62  (testdat     (db
1e60: 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64  :get-test-info d
1e70: 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  b run-id test-na
1e80: 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29 0a 09  me item-path))..
1e90: 20 28 74 65 73 74 2d 69 64 20 20 20 20 20 28 69   (test-id     (i
1ea0: 66 20 74 65 73 74 64 61 74 20 28 64 62 3a 74 65  f testdat (db:te
1eb0: 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74 64 61  st-get-id testda
1ec0: 74 29 20 23 66 29 29 0a 09 20 28 6f 74 68 65 72  t) #f)).. (other
1ed0: 64 61 74 20 20 20 20 28 69 66 20 64 61 74 20 64  dat    (if dat d
1ee0: 61 74 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61  at (make-hash-ta
1ef0: 62 6c 65 29 29 29 0a 09 20 3b 3b 20 62 65 66 6f  ble))).. ;; befo
1f00: 72 65 20 70 72 6f 63 65 65 64 69 6e 67 20 77 65  re proceeding we
1f10: 20 6d 75 73 74 20 66 69 6e 64 20 6f 75 74 20 69   must find out i
1f20: 66 20 74 68 65 20 70 72 65 76 69 6f 75 73 20 74  f the previous t
1f30: 65 73 74 20 28 77 68 65 72 65 20 61 6c 6c 20 6b  est (where all k
1f40: 65 79 73 20 6d 61 74 63 68 65 64 20 65 78 63 65  eys matched exce
1f50: 70 74 20 72 75 6e 6e 61 6d 65 29 0a 09 20 3b 3b  pt runname).. ;;
1f60: 20 77 61 73 20 57 41 49 56 45 44 20 69 66 20 74   was WAIVED if t
1f70: 68 69 73 20 74 65 73 74 20 69 73 20 46 41 49 4c  his test is FAIL
1f80: 0a 09 20 28 77 61 69 76 65 64 20 20 20 28 69 66  .. (waived   (if
1f90: 20 28 65 71 75 61 6c 3f 20 73 74 61 74 75 73 20   (equal? status 
1fa0: 22 46 41 49 4c 22 29 0a 09 09 20 20 20 20 20 20  "FAIL")...      
1fb0: 20 28 6c 65 74 20 28 28 70 72 65 76 2d 74 65 73   (let ((prev-tes
1fc0: 74 20 28 74 65 73 74 3a 67 65 74 2d 70 72 65 76  t (test:get-prev
1fd0: 69 6f 75 73 2d 74 65 73 74 2d 72 75 6e 2d 72 65  ious-test-run-re
1fe0: 63 6f 72 64 20 64 62 20 72 75 6e 2d 69 64 20 74  cord db run-id t
1ff0: 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61  est-name item-pa
2000: 74 68 29 29 29 0a 09 09 09 20 28 69 66 20 70 72  th))).... (if pr
2010: 65 76 2d 74 65 73 74 20 3b 3b 20 74 72 75 65 20  ev-test ;; true 
2020: 69 66 20 77 65 20 66 6f 75 6e 64 20 61 20 70 72  if we found a pr
2030: 65 76 69 6f 75 73 20 74 65 73 74 20 69 6e 20 74  evious test in t
2040: 68 69 73 20 72 75 6e 20 73 65 72 69 65 73 0a 09  his run series..
2050: 09 09 20 20 20 20 20 28 6c 65 74 20 28 28 70 72  ..     (let ((pr
2060: 65 76 2d 73 74 61 74 75 73 20 28 64 62 3a 74 65  ev-status (db:te
2070: 73 74 2d 67 65 74 2d 73 74 61 74 75 73 20 20 20  st-get-status   
2080: 70 72 65 76 2d 74 65 73 74 29 29 0a 09 09 09 09  prev-test)).....
2090: 20 20 20 28 70 72 65 76 2d 73 74 61 74 65 20 20     (prev-state  
20a0: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 73 74 61  (db:test-get-sta
20b0: 74 65 20 20 20 20 70 72 65 76 2d 74 65 73 74 29  te    prev-test)
20c0: 29 0a 09 09 09 09 20 20 20 28 70 72 65 76 2d 63  ).....   (prev-c
20d0: 6f 6d 6d 65 6e 74 20 28 64 62 3a 74 65 73 74 2d  omment (db:test-
20e0: 67 65 74 2d 63 6f 6d 6d 65 6e 74 20 70 72 65 76  get-comment prev
20f0: 2d 74 65 73 74 29 29 29 0a 09 09 09 20 20 20 20  -test)))....    
2100: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
2110: 34 20 22 70 72 65 76 2d 73 74 61 74 75 73 20 22  4 "prev-status "
2120: 20 70 72 65 76 2d 73 74 61 74 75 73 20 22 2c 20   prev-status ", 
2130: 70 72 65 76 2d 73 74 61 74 65 20 22 20 70 72 65  prev-state " pre
2140: 76 2d 73 74 61 74 65 20 22 2c 20 70 72 65 76 2d  v-state ", prev-
2150: 63 6f 6d 6d 65 6e 74 20 22 20 70 72 65 76 2d 63  comment " prev-c
2160: 6f 6d 6d 65 6e 74 29 0a 09 09 09 20 20 20 20 20  omment)....     
2170: 20 20 28 69 66 20 28 61 6e 64 20 28 65 71 75 61    (if (and (equa
2180: 6c 3f 20 70 72 65 76 2d 73 74 61 74 65 20 20 22  l? prev-state  "
2190: 43 4f 4d 50 4c 45 54 45 44 22 29 0a 09 09 09 09  COMPLETED").....
21a0: 09 28 65 71 75 61 6c 3f 20 70 72 65 76 2d 73 74  .(equal? prev-st
21b0: 61 74 75 73 20 22 57 41 49 56 45 44 22 29 29 0a  atus "WAIVED")).
21c0: 09 09 09 09 20 20 20 70 72 65 76 2d 63 6f 6d 6d  ....   prev-comm
21d0: 65 6e 74 20 3b 3b 20 77 61 69 76 65 64 20 69 73  ent ;; waived is
21e0: 20 65 69 74 68 65 72 20 74 68 65 20 63 6f 6d 6d   either the comm
21f0: 65 6e 74 20 6f 72 20 23 66 0a 09 09 09 09 20 20  ent or #f.....  
2200: 20 23 66 29 29 0a 09 09 09 20 20 20 20 20 23 66   #f))....     #f
2210: 29 29 0a 09 09 20 20 20 20 20 20 20 23 66 29 29  ))...       #f))
2220: 29 0a 20 20 20 20 28 69 66 20 77 61 69 76 65 64  ).    (if waived
2230: 20 28 73 65 74 21 20 72 65 61 6c 2d 73 74 61 74   (set! real-stat
2240: 75 73 20 22 57 41 49 56 45 44 22 29 29 0a 20 20  us "WAIVED")).  
2250: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34    (debug:print 4
2260: 20 22 72 65 61 6c 2d 73 74 61 74 75 73 20 22 20   "real-status " 
2270: 72 65 61 6c 2d 73 74 61 74 75 73 20 22 2c 20 77  real-status ", w
2280: 61 69 76 65 64 20 22 20 77 61 69 76 65 64 20 22  aived " waived "
2290: 2c 20 73 74 61 74 75 73 20 22 20 73 74 61 74 75  , status " statu
22a0: 73 29 0a 0a 20 20 20 20 3b 3b 20 75 70 64 61 74  s)..    ;; updat
22b0: 65 20 74 68 65 20 70 72 69 6d 61 72 79 20 72 65  e the primary re
22c0: 63 6f 72 64 20 49 46 20 73 74 61 74 65 20 41 4e  cord IF state AN
22d0: 44 20 73 74 61 74 75 73 20 61 72 65 20 64 65 66  D status are def
22e0: 69 6e 65 64 0a 20 20 20 20 28 69 66 20 28 61 6e  ined.    (if (an
22f0: 64 20 73 74 61 74 65 20 73 74 61 74 75 73 29 0a  d state status).
2300: 09 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74  .(sqlite3:execut
2310: 65 20 64 62 20 22 55 50 44 41 54 45 20 74 65 73  e db "UPDATE tes
2320: 74 73 20 53 45 54 20 73 74 61 74 65 3d 3f 2c 73  ts SET state=?,s
2330: 74 61 74 75 73 3d 3f 2c 65 76 65 6e 74 5f 74 69  tatus=?,event_ti
2340: 6d 65 3d 73 74 72 66 74 69 6d 65 28 27 25 73 27  me=strftime('%s'
2350: 2c 27 6e 6f 77 27 29 20 57 48 45 52 45 20 72 75  ,'now') WHERE ru
2360: 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e  n_id=? AND testn
2370: 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70  ame=? AND item_p
2380: 61 74 68 3d 3f 3b 22 20 0a 09 09 09 20 73 74 61  ath=?;" .... sta
2390: 74 65 20 72 65 61 6c 2d 73 74 61 74 75 73 20 72  te real-status r
23a0: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
23b0: 69 74 65 6d 2d 70 61 74 68 29 29 0a 0a 20 20 20  item-path))..   
23c0: 20 3b 3b 20 69 66 20 73 74 61 74 75 73 20 69 73   ;; if status is
23d0: 20 22 41 55 54 4f 22 20 74 68 65 6e 20 63 61 6c   "AUTO" then cal
23e0: 6c 20 72 6f 6c 6c 75 70 0a 20 20 20 20 28 69 66  l rollup.    (if
23f0: 20 28 61 6e 64 20 74 65 73 74 2d 69 64 20 73 74   (and test-id st
2400: 61 74 65 20 73 74 61 74 75 73 20 28 65 71 75 61  ate status (equa
2410: 6c 3f 20 73 74 61 74 75 73 20 22 41 55 54 4f 22  l? status "AUTO"
2420: 29 29 20 0a 09 28 64 62 3a 74 65 73 74 2d 64 61  )) ..(db:test-da
2430: 74 61 2d 72 6f 6c 6c 75 70 20 64 62 20 74 65 73  ta-rollup db tes
2440: 74 2d 69 64 29 29 0a 0a 20 20 20 20 3b 3b 20 61  t-id))..    ;; a
2450: 64 64 20 6d 65 74 61 64 61 74 61 20 28 6e 65 65  dd metadata (nee
2460: 64 20 74 6f 20 64 6f 20 74 68 69 73 20 77 61 79  d to do this way
2470: 20 74 6f 20 61 76 6f 69 64 20 53 51 4c 20 69 6e   to avoid SQL in
2480: 6a 65 63 74 69 6f 6e 20 69 73 73 75 65 73 29 0a  jection issues).
2490: 0a 20 20 20 20 3b 3b 20 3a 66 69 72 73 74 5f 65  .    ;; :first_e
24a0: 72 72 0a 20 20 20 20 28 6c 65 74 20 28 28 76 61  rr.    (let ((va
24b0: 6c 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65  l (hash-table-re
24c0: 66 2f 64 65 66 61 75 6c 74 20 6f 74 68 65 72 64  f/default otherd
24d0: 61 74 20 22 3a 66 69 72 73 74 5f 65 72 72 22 20  at ":first_err" 
24e0: 23 66 29 29 29 0a 20 20 20 20 20 20 28 69 66 20  #f))).      (if 
24f0: 76 61 6c 0a 09 20 20 28 73 71 6c 69 74 65 33 3a  val..  (sqlite3:
2500: 65 78 65 63 75 74 65 20 64 62 20 22 55 50 44 41  execute db "UPDA
2510: 54 45 20 74 65 73 74 73 20 53 45 54 20 66 69 72  TE tests SET fir
2520: 73 74 5f 65 72 72 3d 3f 20 57 48 45 52 45 20 72  st_err=? WHERE r
2530: 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74  un_id=? AND test
2540: 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f  name=? AND item_
2550: 70 61 74 68 3d 3f 3b 22 20 76 61 6c 20 72 75 6e  path=?;" val run
2560: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74  -id test-name it
2570: 65 6d 2d 70 61 74 68 29 29 29 0a 0a 20 20 20 20  em-path)))..    
2580: 3b 3b 20 3a 66 69 72 73 74 5f 77 61 72 6e 0a 20  ;; :first_warn. 
2590: 20 20 20 28 6c 65 74 20 28 28 76 61 6c 20 28 68     (let ((val (h
25a0: 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65  ash-table-ref/de
25b0: 66 61 75 6c 74 20 6f 74 68 65 72 64 61 74 20 22  fault otherdat "
25c0: 3a 66 69 72 73 74 5f 77 61 72 6e 22 20 23 66 29  :first_warn" #f)
25d0: 29 29 0a 20 20 20 20 20 20 28 69 66 20 76 61 6c  )).      (if val
25e0: 0a 09 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65  ..  (sqlite3:exe
25f0: 63 75 74 65 20 64 62 20 22 55 50 44 41 54 45 20  cute db "UPDATE 
2600: 74 65 73 74 73 20 53 45 54 20 66 69 72 73 74 5f  tests SET first_
2610: 77 61 72 6e 3d 3f 20 57 48 45 52 45 20 72 75 6e  warn=? WHERE run
2620: 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61  _id=? AND testna
2630: 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61  me=? AND item_pa
2640: 74 68 3d 3f 3b 22 20 76 61 6c 20 72 75 6e 2d 69  th=?;" val run-i
2650: 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d  d test-name item
2660: 2d 70 61 74 68 29 29 29 0a 0a 20 20 20 20 28 6c  -path)))..    (l
2670: 65 74 20 28 28 63 61 74 65 67 6f 72 79 20 28 68  et ((category (h
2680: 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65  ash-table-ref/de
2690: 66 61 75 6c 74 20 6f 74 68 65 72 64 61 74 20 22  fault otherdat "
26a0: 3a 63 61 74 65 67 6f 72 79 22 20 22 22 29 29 0a  :category" "")).
26b0: 09 20 20 28 76 61 72 69 61 62 6c 65 20 28 68 61  .  (variable (ha
26c0: 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66  sh-table-ref/def
26d0: 61 75 6c 74 20 6f 74 68 65 72 64 61 74 20 22 3a  ault otherdat ":
26e0: 76 61 72 69 61 62 6c 65 22 20 22 22 29 29 0a 09  variable" ""))..
26f0: 20 20 28 76 61 6c 75 65 20 20 20 20 28 68 61 73    (value    (has
2700: 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61  h-table-ref/defa
2710: 75 6c 74 20 6f 74 68 65 72 64 61 74 20 22 3a 76  ult otherdat ":v
2720: 61 6c 75 65 22 20 20 20 20 23 66 29 29 0a 09 20  alue"    #f)).. 
2730: 20 28 65 78 70 65 63 74 65 64 20 28 68 61 73 68   (expected (hash
2740: 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75  -table-ref/defau
2750: 6c 74 20 6f 74 68 65 72 64 61 74 20 22 3a 65 78  lt otherdat ":ex
2760: 70 65 63 74 65 64 22 20 23 66 29 29 0a 09 20 20  pected" #f))..  
2770: 28 74 6f 6c 20 20 20 20 20 20 28 68 61 73 68 2d  (tol      (hash-
2780: 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c  table-ref/defaul
2790: 74 20 6f 74 68 65 72 64 61 74 20 22 3a 74 6f 6c  t otherdat ":tol
27a0: 22 20 20 20 20 20 20 23 66 29 29 0a 09 20 20 28  "      #f))..  (
27b0: 75 6e 69 74 73 20 20 20 20 28 68 61 73 68 2d 74  units    (hash-t
27c0: 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74  able-ref/default
27d0: 20 6f 74 68 65 72 64 61 74 20 22 3a 75 6e 69 74   otherdat ":unit
27e0: 73 22 20 20 20 20 22 22 29 29 0a 09 20 20 28 64  s"    ""))..  (d
27f0: 63 6f 6d 6d 65 6e 74 20 28 68 61 73 68 2d 74 61  comment (hash-ta
2800: 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20  ble-ref/default 
2810: 6f 74 68 65 72 64 61 74 20 22 3a 63 6f 6d 6d 65  otherdat ":comme
2820: 6e 74 22 20 20 22 22 29 29 29 0a 20 20 20 20 20  nt"  ""))).     
2830: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20   (debug:print 4 
2840: 0a 09 09 20 20 20 22 63 61 74 65 67 6f 72 79 3a  ...   "category:
2850: 20 22 20 63 61 74 65 67 6f 72 79 20 22 2c 20 76   " category ", v
2860: 61 72 69 61 62 6c 65 3a 20 22 20 76 61 72 69 61  ariable: " varia
2870: 62 6c 65 20 22 2c 20 76 61 6c 75 65 3a 20 22 20  ble ", value: " 
2880: 76 61 6c 75 65 0a 09 09 20 20 20 22 2c 20 65 78  value...   ", ex
2890: 70 65 63 74 65 64 3a 20 22 20 65 78 70 65 63 74  pected: " expect
28a0: 65 64 20 22 2c 20 74 6f 6c 3a 20 22 20 74 6f 6c  ed ", tol: " tol
28b0: 20 22 2c 20 75 6e 69 74 73 3a 20 22 20 75 6e 69   ", units: " uni
28c0: 74 73 29 0a 20 20 20 20 20 20 28 69 66 20 28 61  ts).      (if (a
28d0: 6e 64 20 76 61 6c 75 65 20 65 78 70 65 63 74 65  nd value expecte
28e0: 64 20 74 6f 6c 29 20 3b 3b 20 61 6c 6c 20 74 68  d tol) ;; all th
28f0: 72 65 65 20 72 65 71 75 69 72 65 64 0a 09 20 20  ree required..  
2900: 28 64 62 3a 63 73 76 2d 3e 74 65 73 74 2d 64 61  (db:csv->test-da
2910: 74 61 20 64 62 20 74 65 73 74 2d 69 64 20 0a 09  ta db test-id ..
2920: 09 09 20 20 20 20 20 28 63 6f 6e 63 20 63 61 74  ..     (conc cat
2930: 65 67 6f 72 79 20 22 2c 22 0a 09 09 09 09 20 20  egory ",".....  
2940: 20 76 61 72 69 61 62 6c 65 20 22 2c 22 0a 09 09   variable ","...
2950: 09 09 20 20 20 76 61 6c 75 65 20 20 20 20 22 2c  ..   value    ",
2960: 22 0a 09 09 09 09 20 20 20 65 78 70 65 63 74 65  ".....   expecte
2970: 64 20 22 2c 22 0a 09 09 09 09 20 20 20 74 6f 6c  d ",".....   tol
2980: 20 20 20 20 20 20 22 2c 22 0a 09 09 09 09 20 20        ",".....  
2990: 20 75 6e 69 74 73 20 20 20 20 22 2c 22 0a 09 09   units    ","...
29a0: 09 09 20 20 20 64 63 6f 6d 6d 65 6e 74 20 22 2c  ..   dcomment ",
29b0: 22 29 29 29 29 0a 09 09 09 09 20 20 20 0a 20 20  ")))).....   .  
29c0: 20 20 3b 3b 20 6e 65 65 64 20 74 6f 20 75 70 64    ;; need to upd
29d0: 61 74 65 20 74 68 65 20 74 6f 70 20 74 65 73 74  ate the top test
29e0: 20 72 65 63 6f 72 64 20 69 66 20 50 41 53 53 20   record if PASS 
29f0: 6f 72 20 46 41 49 4c 20 61 6e 64 20 74 68 69 73  or FAIL and this
2a00: 20 69 73 20 61 20 73 75 62 74 65 73 74 0a 20 20   is a subtest.  
2a10: 20 20 28 69 66 20 28 61 6e 64 20 28 6e 6f 74 20    (if (and (not 
2a20: 28 65 71 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74  (equal? item-pat
2a30: 68 20 22 22 29 29 0a 09 20 20 20 20 20 28 6f 72  h ""))..     (or
2a40: 20 28 65 71 75 61 6c 3f 20 73 74 61 74 75 73 20   (equal? status 
2a50: 22 50 41 53 53 22 29 0a 09 09 20 28 65 71 75 61  "PASS")... (equa
2a60: 6c 3f 20 73 74 61 74 75 73 20 22 57 41 52 4e 22  l? status "WARN"
2a70: 29 0a 09 09 20 28 65 71 75 61 6c 3f 20 73 74 61  )... (equal? sta
2a80: 74 75 73 20 22 46 41 49 4c 22 29 0a 09 09 20 28  tus "FAIL")... (
2a90: 65 71 75 61 6c 3f 20 73 74 61 74 75 73 20 22 57  equal? status "W
2aa0: 41 49 56 45 44 22 29 0a 09 09 20 28 65 71 75 61  AIVED")... (equa
2ab0: 6c 3f 20 73 74 61 74 75 73 20 22 52 55 4e 4e 49  l? status "RUNNI
2ac0: 4e 47 22 29 29 29 0a 09 28 62 65 67 69 6e 0a 09  NG")))..(begin..
2ad0: 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75    (sqlite3:execu
2ae0: 74 65 20 0a 09 20 20 20 64 62 0a 09 20 20 20 22  te ..   db..   "
2af0: 55 50 44 41 54 45 20 74 65 73 74 73 20 0a 20 20  UPDATE tests .  
2b00: 20 20 20 20 20 20 20 20 20 20 20 53 45 54 20 66             SET f
2b10: 61 69 6c 5f 63 6f 75 6e 74 3d 28 53 45 4c 45 43  ail_count=(SELEC
2b20: 54 20 63 6f 75 6e 74 28 69 64 29 20 46 52 4f 4d  T count(id) FROM
2b30: 20 74 65 73 74 73 20 57 48 45 52 45 20 72 75 6e   tests WHERE run
2b40: 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61  _id=? AND testna
2b50: 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61  me=? AND item_pa
2b60: 74 68 20 21 3d 20 27 27 20 41 4e 44 20 73 74 61  th != '' AND sta
2b70: 74 75 73 3d 27 46 41 49 4c 27 29 2c 0a 20 20 20  tus='FAIL'),.   
2b80: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 70 61                pa
2b90: 73 73 5f 63 6f 75 6e 74 3d 28 53 45 4c 45 43 54  ss_count=(SELECT
2ba0: 20 63 6f 75 6e 74 28 69 64 29 20 46 52 4f 4d 20   count(id) FROM 
2bb0: 74 65 73 74 73 20 57 48 45 52 45 20 72 75 6e 5f  tests WHERE run_
2bc0: 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d  id=? AND testnam
2bd0: 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74  e=? AND item_pat
2be0: 68 20 21 3d 20 27 27 20 41 4e 44 20 28 73 74 61  h != '' AND (sta
2bf0: 74 75 73 3d 27 50 41 53 53 27 20 4f 52 20 73 74  tus='PASS' OR st
2c00: 61 74 75 73 3d 27 57 41 52 4e 27 20 4f 52 20 73  atus='WARN' OR s
2c10: 74 61 74 75 73 3d 27 57 41 49 56 45 44 27 29 29  tatus='WAIVED'))
2c20: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 57 48  .             WH
2c30: 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44  ERE run_id=? AND
2c40: 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20   testname=? AND 
2c50: 69 74 65 6d 5f 70 61 74 68 3d 27 27 3b 22 0a 09  item_path='';"..
2c60: 20 20 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e     run-id test-n
2c70: 61 6d 65 20 72 75 6e 2d 69 64 20 74 65 73 74 2d  ame run-id test-
2c80: 6e 61 6d 65 20 72 75 6e 2d 69 64 20 74 65 73 74  name run-id test
2c90: 2d 6e 61 6d 65 29 0a 09 20 20 28 69 66 20 28 65  -name)..  (if (e
2ca0: 71 75 61 6c 3f 20 73 74 61 74 75 73 20 22 52 55  qual? status "RU
2cb0: 4e 4e 49 4e 47 22 29 20 3b 3b 20 72 75 6e 6e 69  NNING") ;; runni
2cc0: 6e 67 20 74 61 6b 65 73 20 70 72 69 6f 72 69 74  ng takes priorit
2cd0: 79 20 6f 76 65 72 20 61 6c 6c 20 6f 74 68 65 72  y over all other
2ce0: 20 73 74 61 74 65 73 2c 20 66 6f 72 63 65 20 74   states, force t
2cf0: 68 65 20 74 65 73 74 20 73 74 61 74 65 20 74 6f  he test state to
2d00: 20 52 55 4e 4e 49 4e 47 0a 09 20 20 20 20 20 20   RUNNING..      
2d10: 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65  (sqlite3:execute
2d20: 20 64 62 20 22 55 50 44 41 54 45 20 74 65 73 74   db "UPDATE test
2d30: 73 20 53 45 54 20 73 74 61 74 65 3d 3f 20 57 48  s SET state=? WH
2d40: 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44  ERE run_id=? AND
2d50: 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20   testname=? AND 
2d60: 69 74 65 6d 5f 70 61 74 68 3d 27 27 3b 22 20 72  item_path='';" r
2d70: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 29  un-id test-name)
2d80: 0a 09 20 20 20 20 20 20 28 73 71 6c 69 74 65 33  ..      (sqlite3
2d90: 3a 65 78 65 63 75 74 65 0a 09 20 20 20 20 20 20  :execute..      
2da0: 20 64 62 0a 09 20 20 20 20 20 20 20 22 55 50 44   db..       "UPD
2db0: 41 54 45 20 74 65 73 74 73 0a 20 20 20 20 20 20  ATE tests.      
2dc0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2dd0: 20 53 45 54 20 73 74 61 74 65 3d 43 41 53 45 20   SET state=CASE 
2de0: 57 48 45 4e 20 28 53 45 4c 45 43 54 20 63 6f 75  WHEN (SELECT cou
2df0: 6e 74 28 69 64 29 20 46 52 4f 4d 20 74 65 73 74  nt(id) FROM test
2e00: 73 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f  s WHERE run_id=?
2e10: 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20   AND testname=? 
2e20: 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 20 21 3d  AND item_path !=
2e30: 20 27 27 20 41 4e 44 20 73 74 61 74 65 20 69 6e   '' AND state in
2e40: 20 28 27 52 55 4e 4e 49 4e 47 27 2c 27 4e 4f 54   ('RUNNING','NOT
2e50: 5f 53 54 41 52 54 45 44 27 29 29 20 3e 20 30 20  _STARTED')) > 0 
2e60: 54 48 45 4e 20 0a 20 20 20 20 20 20 20 20 20 20  THEN .          
2e70: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2e80: 27 52 55 4e 4e 49 4e 47 27 0a 20 20 20 20 20 20  'RUNNING'.      
2e90: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2ea0: 20 45 4c 53 45 20 27 43 4f 4d 50 4c 45 54 45 44   ELSE 'COMPLETED
2eb0: 27 20 45 4e 44 2c 0a 20 20 20 20 20 20 20 20 20  ' END,.         
2ec0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2ed0: 20 73 74 61 74 75 73 3d 43 41 53 45 20 57 48 45   status=CASE WHE
2ee0: 4e 20 66 61 69 6c 5f 63 6f 75 6e 74 20 3e 20 30  N fail_count > 0
2ef0: 20 54 48 45 4e 20 27 46 41 49 4c 27 20 57 48 45   THEN 'FAIL' WHE
2f00: 4e 20 70 61 73 73 5f 63 6f 75 6e 74 20 3e 20 30  N pass_count > 0
2f10: 20 41 4e 44 20 66 61 69 6c 5f 63 6f 75 6e 74 3d   AND fail_count=
2f20: 30 20 54 48 45 4e 20 27 50 41 53 53 27 20 45 4c  0 THEN 'PASS' EL
2f30: 53 45 20 27 55 4e 4b 4e 4f 57 4e 27 20 45 4e 44  SE 'UNKNOWN' END
2f40: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
2f50: 20 20 20 20 20 20 20 20 57 48 45 52 45 20 72 75          WHERE ru
2f60: 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e  n_id=? AND testn
2f70: 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70  ame=? AND item_p
2f80: 61 74 68 3d 27 27 3b 22 0a 09 20 20 20 20 20 20  ath='';"..      
2f90: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
2fa0: 65 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  e run-id test-na
2fb0: 6d 65 29 29 29 29 0a 20 20 20 20 28 69 66 20 28  me)))).    (if (
2fc0: 6f 72 20 28 61 6e 64 20 28 73 74 72 69 6e 67 3f  or (and (string?
2fd0: 20 63 6f 6d 6d 65 6e 74 29 0a 09 09 20 28 73 74   comment)... (st
2fe0: 72 69 6e 67 2d 6d 61 74 63 68 20 28 72 65 67 65  ring-match (rege
2ff0: 78 70 20 22 5c 5c 53 2b 22 29 20 63 6f 6d 6d 65  xp "\\S+") comme
3000: 6e 74 29 29 0a 09 20 20 20 20 77 61 69 76 65 64  nt))..    waived
3010: 29 0a 09 28 73 71 6c 69 74 65 33 3a 65 78 65 63  )..(sqlite3:exec
3020: 75 74 65 20 64 62 20 22 55 50 44 41 54 45 20 74  ute db "UPDATE t
3030: 65 73 74 73 20 53 45 54 20 63 6f 6d 6d 65 6e 74  ests SET comment
3040: 3d 3f 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d  =? WHERE run_id=
3050: 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f  ? AND testname=?
3060: 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f   AND item_path=?
3070: 3b 22 0a 09 09 09 20 28 69 66 20 77 61 69 76 65  ;".... (if waive
3080: 64 20 77 61 69 76 65 64 20 63 6f 6d 6d 65 6e 74  d waived comment
3090: 29 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  ) run-id test-na
30a0: 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29 0a 20  me item-path)). 
30b0: 20 20 20 29 29 0a 0a 28 64 65 66 69 6e 65 20 28     ))..(define (
30c0: 74 65 73 74 2d 73 65 74 2d 6c 6f 67 21 20 64 62  test-set-log! db
30d0: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
30e0: 65 20 69 74 65 6d 64 61 74 20 6c 6f 67 66 29 20  e itemdat logf) 
30f0: 0a 20 20 28 6c 65 74 20 28 28 69 74 65 6d 2d 70  .  (let ((item-p
3100: 61 74 68 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e  ath (item-list->
3110: 70 61 74 68 20 69 74 65 6d 64 61 74 29 29 29 0a  path itemdat))).
3120: 20 20 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65      (sqlite3:exe
3130: 63 75 74 65 20 64 62 20 22 55 50 44 41 54 45 20  cute db "UPDATE 
3140: 74 65 73 74 73 20 53 45 54 20 66 69 6e 61 6c 5f  tests SET final_
3150: 6c 6f 67 66 3d 3f 20 57 48 45 52 45 20 72 75 6e  logf=? WHERE run
3160: 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61  _id=? AND testna
3170: 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61  me=? AND item_pa
3180: 74 68 3d 3f 3b 22 20 0a 09 09 20 20 20 20 20 6c  th=?;" ...     l
3190: 6f 67 66 20 72 75 6e 2d 69 64 20 74 65 73 74 2d  ogf run-id test-
31a0: 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29  name item-path))
31b0: 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73 74  )..(define (test
31c0: 2d 73 65 74 2d 74 6f 70 6c 6f 67 21 20 64 62 20  -set-toplog! db 
31d0: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
31e0: 20 6c 6f 67 66 29 20 0a 20 20 28 73 71 6c 69 74   logf) .  (sqlit
31f0: 65 33 3a 65 78 65 63 75 74 65 20 64 62 20 22 55  e3:execute db "U
3200: 50 44 41 54 45 20 74 65 73 74 73 20 53 45 54 20  PDATE tests SET 
3210: 66 69 6e 61 6c 5f 6c 6f 67 66 3d 3f 20 57 48 45  final_logf=? WHE
3220: 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20  RE run_id=? AND 
3230: 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69  testname=? AND i
3240: 74 65 6d 5f 70 61 74 68 3d 27 27 3b 22 20 0a 09  tem_path='';" ..
3250: 09 20 20 20 6c 6f 67 66 20 72 75 6e 2d 69 64 20  .   logf run-id 
3260: 74 65 73 74 2d 6e 61 6d 65 29 29 0a 0a 28 64 65  test-name))..(de
3270: 66 69 6e 65 20 28 74 65 73 74 73 3a 73 75 6d 6d  fine (tests:summ
3280: 61 72 69 7a 65 2d 69 74 65 6d 73 20 64 62 20 72  arize-items db r
3290: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
32a0: 66 6f 72 63 65 29 0a 20 20 3b 3b 20 69 66 20 6e  force).  ;; if n
32b0: 6f 74 20 66 6f 72 63 65 20 74 68 65 6e 20 6f 6e  ot force then on
32c0: 6c 79 20 75 70 64 61 74 65 20 74 68 65 20 72 65  ly update the re
32d0: 63 6f 72 64 20 69 66 20 6f 6e 65 20 6f 66 20 74  cord if one of t
32e0: 68 65 73 65 20 69 73 20 74 72 75 65 3a 0a 20 20  hese is true:.  
32f0: 3b 3b 20 20 20 31 2e 20 6c 6f 67 66 20 69 73 20  ;;   1. logf is 
3300: 22 6c 6f 67 2f 66 69 6e 61 6c 2e 6c 6f 67 0a 20  "log/final.log. 
3310: 20 3b 3b 20 20 20 32 2e 20 6c 6f 67 66 20 69 73   ;;   2. logf is
3320: 20 73 61 6d 65 20 61 73 20 6f 75 74 70 75 74 66   same as outputf
3330: 69 6c 65 6e 61 6d 65 0a 20 20 28 6c 65 74 20 28  ilename.  (let (
3340: 28 6f 75 74 70 75 74 66 69 6c 65 6e 61 6d 65 20  (outputfilename 
3350: 28 63 6f 6e 63 20 22 6d 65 67 61 74 65 73 74 2d  (conc "megatest-
3360: 72 6f 6c 6c 75 70 2d 22 20 74 65 73 74 2d 6e 61  rollup-" test-na
3370: 6d 65 20 22 2e 68 74 6d 6c 22 29 29 0a 09 28 6f  me ".html"))..(o
3380: 72 69 67 2d 64 69 72 20 20 20 20 20 20 20 28 63  rig-dir       (c
3390: 75 72 72 65 6e 74 2d 64 69 72 65 63 74 6f 72 79  urrent-directory
33a0: 29 29 0a 09 28 6c 6f 67 66 20 20 20 20 20 20 20  ))..(logf       
33b0: 20 20 20 20 23 66 29 29 0a 20 20 20 20 28 73 71      #f)).    (sq
33c0: 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72  lite3:for-each-r
33d0: 6f 77 20 0a 20 20 20 20 20 28 6c 61 6d 62 64 61  ow .     (lambda
33e0: 20 28 70 61 74 68 20 66 69 6e 61 6c 5f 6c 6f 67   (path final_log
33f0: 66 29 0a 20 20 20 20 20 20 20 28 73 65 74 21 20  f).       (set! 
3400: 6c 6f 67 66 20 66 69 6e 61 6c 5f 6c 6f 67 66 29  logf final_logf)
3410: 0a 20 20 20 20 20 20 20 28 69 66 20 28 64 69 72  .       (if (dir
3420: 65 63 74 6f 72 79 3f 20 70 61 74 68 29 0a 09 20  ectory? path).. 
3430: 20 20 28 62 65 67 69 6e 0a 09 20 20 20 20 20 28    (begin..     (
3440: 70 72 69 6e 74 20 22 46 6f 75 6e 64 20 70 61 74  print "Found pat
3450: 68 3a 20 22 20 70 61 74 68 29 0a 09 20 20 20 20  h: " path)..    
3460: 20 28 63 68 61 6e 67 65 2d 64 69 72 65 63 74 6f   (change-directo
3470: 72 79 20 70 61 74 68 29 29 0a 09 20 20 20 20 20  ry path))..     
3480: 3b 3b 20 28 73 65 74 21 20 6f 75 74 70 75 74 66  ;; (set! outputf
3490: 69 6c 65 6e 61 6d 65 20 28 63 6f 6e 63 20 70 61  ilename (conc pa
34a0: 74 68 20 22 2f 22 20 6f 75 74 70 75 74 66 69 6c  th "/" outputfil
34b0: 65 6e 61 6d 65 29 29 29 0a 09 20 20 20 28 70 72  ename)))..   (pr
34c0: 69 6e 74 20 22 4e 6f 20 73 75 63 68 20 70 61 74  int "No such pat
34d0: 68 3a 20 22 20 70 61 74 68 29 29 29 0a 20 20 20  h: " path))).   
34e0: 20 20 64 62 20 0a 20 20 20 20 20 22 53 45 4c 45    db .     "SELE
34f0: 43 54 20 72 75 6e 64 69 72 2c 66 69 6e 61 6c 5f  CT rundir,final_
3500: 6c 6f 67 66 20 46 52 4f 4d 20 74 65 73 74 73 20  logf FROM tests 
3510: 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41  WHERE run_id=? A
3520: 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e  ND testname=? AN
3530: 44 20 69 74 65 6d 5f 70 61 74 68 3d 27 27 3b 22  D item_path='';"
3540: 0a 20 20 20 20 20 72 75 6e 2d 69 64 20 74 65 73  .     run-id tes
3550: 74 2d 6e 61 6d 65 29 0a 20 20 20 20 28 70 72 69  t-name).    (pri
3560: 6e 74 20 22 73 75 6d 6d 61 72 69 7a 65 2d 69 74  nt "summarize-it
3570: 65 6d 73 20 77 69 74 68 20 6c 6f 67 66 20 22 20  ems with logf " 
3580: 6c 6f 67 66 29 0a 20 20 20 20 28 69 66 20 28 6f  logf).    (if (o
3590: 72 20 28 65 71 75 61 6c 3f 20 6c 6f 67 66 20 22  r (equal? logf "
35a0: 6c 6f 67 73 2f 66 69 6e 61 6c 2e 6c 6f 67 22 29  logs/final.log")
35b0: 0a 09 20 20 20 20 28 65 71 75 61 6c 3f 20 6c 6f  ..    (equal? lo
35c0: 67 66 20 6f 75 74 70 75 74 66 69 6c 65 6e 61 6d  gf outputfilenam
35d0: 65 29 0a 09 20 20 20 20 66 6f 72 63 65 29 0a 09  e)..    force)..
35e0: 28 62 65 67 69 6e 0a 09 20 20 28 69 66 20 28 6f  (begin..  (if (o
35f0: 62 74 61 69 6e 2d 64 6f 74 2d 6c 6f 63 6b 20 6f  btain-dot-lock o
3600: 75 74 70 75 74 66 69 6c 65 6e 61 6d 65 20 31 20  utputfilename 1 
3610: 32 30 20 33 30 29 20 3b 3b 20 72 65 74 72 79 20  20 30) ;; retry 
3620: 65 76 65 72 79 20 73 65 63 6f 6e 64 20 66 6f 72  every second for
3630: 20 32 30 20 73 65 63 6f 6e 64 73 2c 20 63 61 6c   20 seconds, cal
3640: 6c 20 69 74 20 64 65 61 64 20 61 66 74 65 72 20  l it dead after 
3650: 33 30 20 73 65 63 6f 6e 64 73 20 61 6e 64 20 73  30 seconds and s
3660: 74 65 61 6c 20 74 68 65 20 6c 6f 63 6b 0a 09 20  teal the lock.. 
3670: 20 20 20 20 20 28 70 72 69 6e 74 20 22 4f 62 74       (print "Obt
3680: 61 69 6e 65 64 20 6c 6f 63 6b 20 66 6f 72 20 22  ained lock for "
3690: 20 6f 75 74 70 75 74 66 69 6c 65 6e 61 6d 65 29   outputfilename)
36a0: 0a 09 20 20 20 20 20 20 28 70 72 69 6e 74 20 22  ..      (print "
36b0: 46 61 69 6c 65 64 20 74 6f 20 6f 62 74 61 69 6e  Failed to obtain
36c0: 20 6c 6f 63 6b 20 66 6f 72 20 22 20 6f 75 74 70   lock for " outp
36d0: 75 74 66 69 6c 65 6e 61 6d 65 29 29 0a 09 20 20  utfilename))..  
36e0: 28 6c 65 74 20 28 28 6f 75 70 20 20 20 20 28 6f  (let ((oup    (o
36f0: 70 65 6e 2d 6f 75 74 70 75 74 2d 66 69 6c 65 20  pen-output-file 
3700: 6f 75 74 70 75 74 66 69 6c 65 6e 61 6d 65 29 29  outputfilename))
3710: 0a 09 09 28 63 6f 75 6e 74 73 20 28 6d 61 6b 65  ...(counts (make
3720: 2d 68 61 73 68 2d 74 61 62 6c 65 29 29 0a 09 09  -hash-table))...
3730: 28 73 74 61 74 65 63 6f 75 6e 74 73 20 28 6d 61  (statecounts (ma
3740: 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29 0a  ke-hash-table)).
3750: 09 09 28 6f 75 74 74 78 74 20 22 22 29 0a 09 09  ..(outtxt "")...
3760: 28 74 6f 74 20 20 20 20 30 29 29 0a 09 20 20 20  (tot    0))..   
3770: 20 28 77 69 74 68 2d 6f 75 74 70 75 74 2d 74 6f   (with-output-to
3780: 2d 70 6f 72 74 0a 09 09 6f 75 70 0a 09 20 20 20  -port...oup..   
3790: 20 20 20 28 6c 61 6d 62 64 61 20 28 29 0a 09 09     (lambda ()...
37a0: 28 73 65 74 21 20 6f 75 74 74 78 74 20 28 63 6f  (set! outtxt (co
37b0: 6e 63 20 6f 75 74 74 78 74 20 22 3c 68 74 6d 6c  nc outtxt "<html
37c0: 3e 3c 74 69 74 6c 65 3e 53 75 6d 6d 61 72 79 3a  ><title>Summary:
37d0: 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 0a 09 09   " test-name ...
37e0: 09 09 20 20 20 22 3c 2f 74 69 74 6c 65 3e 3c 62  ..   "</title><b
37f0: 6f 64 79 3e 3c 68 32 3e 53 75 6d 6d 61 72 79 20  ody><h2>Summary 
3800: 66 6f 72 20 22 20 74 65 73 74 2d 6e 61 6d 65 20  for " test-name 
3810: 22 3c 2f 68 32 3e 22 29 29 0a 09 09 28 73 71 6c  "</h2>"))...(sql
3820: 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f  ite3:for-each-ro
3830: 77 20 0a 09 09 20 28 6c 61 6d 62 64 61 20 28 69  w ... (lambda (i
3840: 64 20 69 74 65 6d 70 61 74 68 20 73 74 61 74 65  d itempath state
3850: 20 73 74 61 74 75 73 20 72 75 6e 5f 64 75 72 61   status run_dura
3860: 74 69 6f 6e 20 6c 6f 67 66 20 63 6f 6d 6d 65 6e  tion logf commen
3870: 74 29 0a 09 09 20 20 20 28 68 61 73 68 2d 74 61  t)...   (hash-ta
3880: 62 6c 65 2d 73 65 74 21 20 63 6f 75 6e 74 73 20  ble-set! counts 
3890: 73 74 61 74 75 73 20 28 2b 20 31 20 28 68 61 73  status (+ 1 (has
38a0: 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61  h-table-ref/defa
38b0: 75 6c 74 20 63 6f 75 6e 74 73 20 73 74 61 74 75  ult counts statu
38c0: 73 20 30 29 29 29 0a 09 09 20 20 20 28 68 61 73  s 0)))...   (has
38d0: 68 2d 74 61 62 6c 65 2d 73 65 74 21 20 73 74 61  h-table-set! sta
38e0: 74 65 63 6f 75 6e 74 73 20 73 74 61 74 65 20 28  tecounts state (
38f0: 2b 20 31 20 28 68 61 73 68 2d 74 61 62 6c 65 2d  + 1 (hash-table-
3900: 72 65 66 2f 64 65 66 61 75 6c 74 20 73 74 61 74  ref/default stat
3910: 65 63 6f 75 6e 74 73 20 73 74 61 74 65 20 30 29  ecounts state 0)
3920: 29 29 0a 09 09 20 20 20 28 73 65 74 21 20 6f 75  ))...   (set! ou
3930: 74 74 78 74 20 28 63 6f 6e 63 20 6f 75 74 74 78  ttxt (conc outtx
3940: 74 20 22 3c 74 72 3e 22 0a 09 09 09 09 20 20 20  t "<tr>".....   
3950: 20 20 20 22 3c 74 64 3e 3c 61 20 68 72 65 66 3d     "<td><a href=
3960: 5c 22 22 20 69 74 65 6d 70 61 74 68 20 22 2f 22  \"" itempath "/"
3970: 20 6c 6f 67 66 20 22 5c 22 3e 20 22 20 69 74 65   logf "\"> " ite
3980: 6d 70 61 74 68 20 22 3c 2f 61 3e 3c 2f 74 64 3e  mpath "</a></td>
3990: 22 20 0a 09 09 09 09 20 20 20 20 20 20 22 3c 74  " .....      "<t
39a0: 64 3e 22 20 73 74 61 74 65 20 20 20 20 22 3c 2f  d>" state    "</
39b0: 74 64 3e 22 20 0a 09 09 09 09 20 20 20 20 20 20  td>" .....      
39c0: 22 3c 74 64 3e 3c 66 6f 6e 74 20 63 6f 6c 6f 72  "<td><font color
39d0: 3d 22 20 28 63 6f 6d 6d 6f 6e 3a 67 65 74 2d 63  =" (common:get-c
39e0: 6f 6c 6f 72 2d 66 72 6f 6d 2d 73 74 61 74 75 73  olor-from-status
39f0: 20 73 74 61 74 75 73 29 0a 09 09 09 09 20 20 20   status).....   
3a00: 20 20 20 22 3e 22 20 20 20 73 74 61 74 75 73 20     ">"   status 
3a10: 20 20 22 3c 2f 66 6f 6e 74 3e 3c 2f 74 64 3e 22    "</font></td>"
3a20: 0a 09 09 09 09 20 20 20 20 20 20 22 3c 74 64 3e  .....      "<td>
3a30: 22 20 28 69 66 20 28 65 71 75 61 6c 3f 20 63 6f  " (if (equal? co
3a40: 6d 6d 65 6e 74 20 22 22 29 0a 09 09 09 09 09 09  mment "").......
3a50: 20 22 26 6e 62 73 70 3b 22 0a 09 09 09 09 09 09   "&nbsp;".......
3a60: 20 63 6f 6d 6d 65 6e 74 29 20 22 3c 2f 74 64 3e   comment) "</td>
3a70: 22 0a 09 09 09 09 09 09 20 22 3c 2f 74 72 3e 22  "....... "</tr>"
3a80: 29 29 29 0a 09 09 20 64 62 0a 09 09 20 22 53 45  )))... db... "SE
3a90: 4c 45 43 54 20 69 64 2c 69 74 65 6d 5f 70 61 74  LECT id,item_pat
3aa0: 68 2c 73 74 61 74 65 2c 73 74 61 74 75 73 2c 72  h,state,status,r
3ab0: 75 6e 5f 64 75 72 61 74 69 6f 6e 2c 66 69 6e 61  un_duration,fina
3ac0: 6c 5f 6c 6f 67 66 2c 63 6f 6d 6d 65 6e 74 20 46  l_logf,comment F
3ad0: 52 4f 4d 20 74 65 73 74 73 20 57 48 45 52 45 20  ROM tests WHERE 
3ae0: 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73  run_id=? AND tes
3af0: 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d  tname=? AND item
3b00: 5f 70 61 74 68 20 21 3d 20 27 27 3b 22 0a 09 09  _path != '';"...
3b10: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
3b20: 65 29 0a 0a 09 09 28 70 72 69 6e 74 20 22 3c 74  e)....(print "<t
3b30: 61 62 6c 65 3e 3c 74 72 3e 3c 74 64 20 76 61 6c  able><tr><td val
3b40: 69 67 6e 3d 5c 22 74 6f 70 5c 22 3e 22 29 0a 09  ign=\"top\">")..
3b50: 09 3b 3b 20 50 72 69 6e 74 20 6f 75 74 20 73 74  .;; Print out st
3b60: 61 74 73 20 66 6f 72 20 73 74 61 74 75 73 0a 09  ats for status..
3b70: 09 28 73 65 74 21 20 74 6f 74 20 30 29 0a 09 09  .(set! tot 0)...
3b80: 28 70 72 69 6e 74 20 22 3c 74 61 62 6c 65 20 63  (print "<table c
3b90: 65 6c 6c 73 70 61 63 69 6e 67 3d 5c 22 30 5c 22  ellspacing=\"0\"
3ba0: 20 62 6f 72 64 65 72 3d 5c 22 31 5c 22 3e 3c 74   border=\"1\"><t
3bb0: 72 3e 3c 74 64 20 63 6f 6c 73 70 61 6e 3d 5c 22  r><td colspan=\"
3bc0: 32 5c 22 3e 3c 68 32 3e 53 74 61 74 65 20 73 74  2\"><h2>State st
3bd0: 61 74 73 3c 2f 68 32 3e 3c 2f 74 64 3e 3c 2f 74  ats</h2></td></t
3be0: 72 3e 22 29 0a 09 09 28 66 6f 72 2d 65 61 63 68  r>")...(for-each
3bf0: 20 28 6c 61 6d 62 64 61 20 28 73 74 61 74 65 29   (lambda (state)
3c00: 0a 09 09 09 20 20 20 20 28 73 65 74 21 20 74 6f  ....    (set! to
3c10: 74 20 28 2b 20 74 6f 74 20 28 68 61 73 68 2d 74  t (+ tot (hash-t
3c20: 61 62 6c 65 2d 72 65 66 20 73 74 61 74 65 63 6f  able-ref stateco
3c30: 75 6e 74 73 20 73 74 61 74 65 29 29 29 0a 09 09  unts state)))...
3c40: 09 20 20 20 20 28 70 72 69 6e 74 20 22 3c 74 72  .    (print "<tr
3c50: 3e 3c 74 64 3e 22 20 73 74 61 74 65 20 22 3c 2f  ><td>" state "</
3c60: 74 64 3e 3c 74 64 3e 22 20 28 68 61 73 68 2d 74  td><td>" (hash-t
3c70: 61 62 6c 65 2d 72 65 66 20 73 74 61 74 65 63 6f  able-ref stateco
3c80: 75 6e 74 73 20 73 74 61 74 65 29 20 22 3c 2f 74  unts state) "</t
3c90: 64 3e 3c 2f 74 72 3e 22 29 29 0a 09 09 09 20 20  d></tr>"))....  
3ca0: 28 68 61 73 68 2d 74 61 62 6c 65 2d 6b 65 79 73  (hash-table-keys
3cb0: 20 73 74 61 74 65 63 6f 75 6e 74 73 29 29 0a 09   statecounts))..
3cc0: 09 28 70 72 69 6e 74 20 22 3c 74 72 3e 3c 74 64  .(print "<tr><td
3cd0: 3e 54 6f 74 61 6c 3c 2f 74 64 3e 3c 74 64 3e 22  >Total</td><td>"
3ce0: 20 74 6f 74 20 22 3c 2f 74 64 3e 3c 2f 74 72 3e   tot "</td></tr>
3cf0: 3c 2f 74 61 62 6c 65 3e 22 29 0a 09 09 28 70 72  </table>")...(pr
3d00: 69 6e 74 20 22 3c 2f 74 64 3e 3c 74 64 20 76 61  int "</td><td va
3d10: 6c 69 67 6e 3d 5c 22 74 6f 70 5c 22 3e 22 29 0a  lign=\"top\">").
3d20: 09 09 3b 3b 20 50 72 69 6e 74 20 6f 75 74 20 73  ..;; Print out s
3d30: 74 61 74 73 20 66 6f 72 20 73 74 61 74 65 0a 09  tats for state..
3d40: 09 28 73 65 74 21 20 74 6f 74 20 30 29 0a 09 09  .(set! tot 0)...
3d50: 28 70 72 69 6e 74 20 22 3c 74 61 62 6c 65 20 63  (print "<table c
3d60: 65 6c 6c 73 70 61 63 69 6e 67 3d 5c 22 30 5c 22  ellspacing=\"0\"
3d70: 20 62 6f 72 64 65 72 3d 5c 22 31 5c 22 3e 3c 74   border=\"1\"><t
3d80: 72 3e 3c 74 64 20 63 6f 6c 73 70 61 6e 3d 5c 22  r><td colspan=\"
3d90: 32 5c 22 3e 3c 68 32 3e 53 74 61 74 75 73 20 73  2\"><h2>Status s
3da0: 74 61 74 73 3c 2f 68 32 3e 3c 2f 74 64 3e 3c 2f  tats</h2></td></
3db0: 74 72 3e 22 29 0a 09 09 28 66 6f 72 2d 65 61 63  tr>")...(for-eac
3dc0: 68 20 28 6c 61 6d 62 64 61 20 28 73 74 61 74 75  h (lambda (statu
3dd0: 73 29 0a 09 09 09 20 20 20 20 28 73 65 74 21 20  s)....    (set! 
3de0: 74 6f 74 20 28 2b 20 74 6f 74 20 28 68 61 73 68  tot (+ tot (hash
3df0: 2d 74 61 62 6c 65 2d 72 65 66 20 63 6f 75 6e 74  -table-ref count
3e00: 73 20 73 74 61 74 75 73 29 29 29 0a 09 09 09 20  s status))).... 
3e10: 20 20 20 28 70 72 69 6e 74 20 22 3c 74 72 3e 3c     (print "<tr><
3e20: 74 64 3e 3c 66 6f 6e 74 20 63 6f 6c 6f 72 3d 5c  td><font color=\
3e30: 22 22 20 28 63 6f 6d 6d 6f 6e 3a 67 65 74 2d 63  "" (common:get-c
3e40: 6f 6c 6f 72 2d 66 72 6f 6d 2d 73 74 61 74 75 73  olor-from-status
3e50: 20 73 74 61 74 75 73 29 20 22 5c 22 3e 22 20 73   status) "\">" s
3e60: 74 61 74 75 73 0a 09 09 09 09 20 20 20 22 3c 2f  tatus.....   "</
3e70: 66 6f 6e 74 3e 3c 2f 74 64 3e 3c 74 64 3e 22 20  font></td><td>" 
3e80: 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 20  (hash-table-ref 
3e90: 63 6f 75 6e 74 73 20 73 74 61 74 75 73 29 20 22  counts status) "
3ea0: 3c 2f 74 64 3e 3c 2f 74 72 3e 22 29 29 0a 09 09  </td></tr>"))...
3eb0: 09 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 6b  .  (hash-table-k
3ec0: 65 79 73 20 63 6f 75 6e 74 73 29 29 0a 09 09 28  eys counts))...(
3ed0: 70 72 69 6e 74 20 22 3c 74 72 3e 3c 74 64 3e 54  print "<tr><td>T
3ee0: 6f 74 61 6c 3c 2f 74 64 3e 3c 74 64 3e 22 20 74  otal</td><td>" t
3ef0: 6f 74 20 22 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f  ot "</td></tr></
3f00: 74 61 62 6c 65 3e 22 29 0a 09 09 28 70 72 69 6e  table>")...(prin
3f10: 74 20 22 3c 2f 74 64 3e 3c 2f 74 64 3e 3c 2f 74  t "</td></td></t
3f20: 72 3e 3c 2f 74 61 62 6c 65 3e 22 29 0a 0a 09 09  r></table>")....
3f30: 28 70 72 69 6e 74 20 22 3c 74 61 62 6c 65 20 63  (print "<table c
3f40: 65 6c 6c 73 70 61 63 69 6e 67 3d 5c 22 30 5c 22  ellspacing=\"0\"
3f50: 20 62 6f 72 64 65 72 3d 5c 22 31 5c 22 3e 22 20   border=\"1\">" 
3f60: 0a 09 09 20 20 20 20 20 20 20 22 3c 74 72 3e 3c  ...       "<tr><
3f70: 74 64 3e 49 74 65 6d 3c 2f 74 64 3e 3c 74 64 3e  td>Item</td><td>
3f80: 53 74 61 74 65 3c 2f 74 64 3e 3c 74 64 3e 53 74  State</td><td>St
3f90: 61 74 75 73 3c 2f 74 64 3e 3c 74 64 3e 43 6f 6d  atus</td><td>Com
3fa0: 6d 65 6e 74 3c 2f 74 64 3e 22 0a 09 09 20 20 20  ment</td>"...   
3fb0: 20 20 20 20 6f 75 74 74 78 74 20 22 3c 2f 74 61      outtxt "</ta
3fc0: 62 6c 65 3e 3c 2f 62 6f 64 79 3e 3c 2f 68 74 6d  ble></body></htm
3fd0: 6c 3e 22 29 0a 09 09 28 72 65 6c 65 61 73 65 2d  l>")...(release-
3fe0: 64 6f 74 2d 6c 6f 63 6b 20 6f 75 74 70 75 74 66  dot-lock outputf
3ff0: 69 6c 65 6e 61 6d 65 29 29 29 0a 09 20 20 20 20  ilename)))..    
4000: 28 63 6c 6f 73 65 2d 6f 75 74 70 75 74 2d 70 6f  (close-output-po
4010: 72 74 20 6f 75 70 29 0a 09 20 20 20 20 28 63 68  rt oup)..    (ch
4020: 61 6e 67 65 2d 64 69 72 65 63 74 6f 72 79 20 6f  ange-directory o
4030: 72 69 67 2d 64 69 72 29 0a 09 20 20 20 20 28 74  rig-dir)..    (t
4040: 65 73 74 2d 73 65 74 2d 74 6f 70 6c 6f 67 21 20  est-set-toplog! 
4050: 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e  db run-id test-n
4060: 61 6d 65 20 6f 75 74 70 75 74 66 69 6c 65 6e 61  ame outputfilena
4070: 6d 65 29 0a 09 20 20 20 20 29 29 29 29 29 0a 0a  me)..    )))))..
4080: 3b 3b 20 3b 3b 20 54 4f 44 4f 3a 20 43 6f 6e 76  ;; ;; TODO: Conv
4090: 65 72 67 65 20 74 68 69 73 20 77 69 74 68 20 64  erge this with d
40a0: 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 0a  b:get-test-info.
40b0: 3b 3b 20 28 64 65 66 69 6e 65 20 28 72 75 6e 73  ;; (define (runs
40c0: 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64  :get-test-info d
40d0: 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  b run-id test-na
40e0: 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 0a 3b 3b  me item-path).;;
40f0: 20 20 20 28 6c 65 74 20 28 28 72 65 73 20 23 66     (let ((res #f
4100: 29 29 20 3b 3b 20 28 76 65 63 74 6f 72 20 23 66  )) ;; (vector #f
4110: 20 23 66 20 23 66 20 23 66 20 23 66 20 23 66 29   #f #f #f #f #f)
4120: 29 29 0a 3b 3b 20 20 20 20 20 28 73 71 6c 69 74  )).;;     (sqlit
4130: 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77 20  e3:for-each-row 
4140: 0a 3b 3b 20 20 20 20 20 20 28 6c 61 6d 62 64 61  .;;      (lambda
4150: 20 28 69 64 20 72 75 6e 2d 69 64 20 74 65 73 74   (id run-id test
4160: 2d 6e 61 6d 65 20 73 74 61 74 65 20 73 74 61 74  -name state stat
4170: 75 73 29 0a 3b 3b 20 20 20 20 20 20 20 20 28 73  us).;;        (s
4180: 65 74 21 20 72 65 73 20 28 76 65 63 74 6f 72 20  et! res (vector 
4190: 69 64 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e  id run-id test-n
41a0: 61 6d 65 20 73 74 61 74 65 20 73 74 61 74 75 73  ame state status
41b0: 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 3b 3b   item-path))).;;
41c0: 20 20 20 20 20 20 64 62 20 22 53 45 4c 45 43 54        db "SELECT
41d0: 20 69 64 2c 72 75 6e 5f 69 64 2c 74 65 73 74 6e   id,run_id,testn
41e0: 61 6d 65 2c 73 74 61 74 65 2c 73 74 61 74 75 73  ame,state,status
41f0: 20 46 52 4f 4d 20 74 65 73 74 73 20 57 48 45 52   FROM tests WHER
4200: 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74  E run_id=? AND t
4210: 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74  estname=? AND it
4220: 65 6d 5f 70 61 74 68 3d 3f 3b 22 0a 3b 3b 20 20  em_path=?;".;;  
4230: 20 20 20 20 72 75 6e 2d 69 64 20 74 65 73 74 2d      run-id test-
4240: 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 0a  name item-path).
4250: 3b 3b 20 20 20 20 20 72 65 73 29 29 0a 0a 28 64  ;;     res))..(d
4260: 65 66 69 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65  efine-inline (te
4270: 73 74 3a 67 65 74 2d 69 64 20 76 65 63 29 20 20  st:get-id vec)  
4280: 20 20 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66       (vector-ref
4290: 20 76 65 63 20 30 29 29 0a 28 64 65 66 69 6e 65   vec 0)).(define
42a0: 2d 69 6e 6c 69 6e 65 20 28 74 65 73 74 3a 67 65  -inline (test:ge
42b0: 74 2d 72 75 6e 5f 69 64 20 76 65 63 29 20 20 20  t-run_id vec)   
42c0: 28 76 65 63 74 6f 72 2d 72 65 66 20 76 65 63 20  (vector-ref vec 
42d0: 31 29 29 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69  1)).(define-inli
42e0: 6e 65 20 28 74 65 73 74 3a 67 65 74 2d 74 65 73  ne (test:get-tes
42f0: 74 2d 6e 61 6d 65 20 76 65 63 29 28 76 65 63 74  t-name vec)(vect
4300: 6f 72 2d 72 65 66 20 76 65 63 20 32 29 29 0a 28  or-ref vec 2)).(
4310: 64 65 66 69 6e 65 2d 69 6e 6c 69 6e 65 20 28 74  define-inline (t
4320: 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 76 65  est:get-state ve
4330: 63 29 20 20 20 20 28 76 65 63 74 6f 72 2d 72 65  c)    (vector-re
4340: 66 20 76 65 63 20 33 29 29 0a 28 64 65 66 69 6e  f vec 3)).(defin
4350: 65 2d 69 6e 6c 69 6e 65 20 28 74 65 73 74 3a 67  e-inline (test:g
4360: 65 74 2d 73 74 61 74 75 73 20 76 65 63 29 20 20  et-status vec)  
4370: 20 28 76 65 63 74 6f 72 2d 72 65 66 20 76 65 63   (vector-ref vec
4380: 20 34 29 29 0a 28 64 65 66 69 6e 65 2d 69 6e 6c   4)).(define-inl
4390: 69 6e 65 20 28 74 65 73 74 3a 67 65 74 2d 69 74  ine (test:get-it
43a0: 65 6d 2d 70 61 74 68 20 76 65 63 29 28 76 65 63  em-path vec)(vec
43b0: 74 6f 72 2d 72 65 66 20 76 65 63 20 35 29 29 0a  tor-ref vec 5)).
43c0: 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 74  .(define (runs:t
43d0: 65 73 74 2d 67 65 74 2d 66 75 6c 6c 2d 70 61 74  est-get-full-pat
43e0: 68 20 74 65 73 74 29 0a 20 20 28 6c 65 74 2a 20  h test).  (let* 
43f0: 28 28 74 65 73 74 6e 61 6d 65 20 28 64 62 3a 74  ((testname (db:t
4400: 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65  est-get-testname
4410: 20 20 20 74 65 73 74 29 29 0a 09 20 28 69 74 65     test)).. (ite
4420: 6d 70 61 74 68 20 28 64 62 3a 74 65 73 74 2d 67  mpath (db:test-g
4430: 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73  et-item-path tes
4440: 74 29 29 29 0a 20 20 20 20 28 63 6f 6e 63 20 74  t))).    (conc t
4450: 65 73 74 6e 61 6d 65 20 28 69 66 20 28 65 71 75  estname (if (equ
4460: 61 6c 3f 20 69 74 65 6d 70 61 74 68 20 22 22 29  al? itempath "")
4470: 20 22 22 20 28 63 6f 6e 63 20 22 28 22 20 69 74   "" (conc "(" it
4480: 65 6d 70 61 74 68 20 22 29 22 29 29 29 29 29 0a  empath ")"))))).
4490: 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69 6e 65 20  .(define-inline 
44a0: 28 74 65 73 74 3a 74 65 73 74 2d 67 65 74 2d 66  (test:test-get-f
44b0: 75 6c 6c 6e 61 6d 65 20 74 65 73 74 29 0a 20 20  ullname test).  
44c0: 20 28 63 6f 6e 63 20 28 64 62 3a 74 65 73 74 2d   (conc (db:test-
44d0: 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73  get-testname tes
44e0: 74 29 0a 09 20 28 69 66 20 28 65 71 75 61 6c 3f  t).. (if (equal?
44f0: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74   (db:test-get-it
4500: 65 6d 2d 70 61 74 68 20 74 65 73 74 29 20 22 22  em-path test) ""
4510: 29 0a 09 20 20 20 20 20 22 22 0a 09 20 20 20 20  )..     ""..    
4520: 20 28 63 6f 6e 63 20 22 28 22 20 28 64 62 3a 74   (conc "(" (db:t
4530: 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74  est-get-item-pat
4540: 68 20 74 65 73 74 29 20 22 29 22 29 29 29 29 0a  h test) ")")))).
4550: 0a 28 64 65 66 69 6e 65 20 28 63 68 65 63 6b 2d  .(define (check-
4560: 76 61 6c 69 64 2d 69 74 65 6d 73 20 63 6c 61 73  valid-items clas
4570: 73 20 69 74 65 6d 29 0a 20 20 28 6c 65 74 20 28  s item).  (let (
4580: 28 76 61 6c 69 64 2d 76 61 6c 75 65 73 20 28 6c  (valid-values (l
4590: 65 74 20 28 28 73 20 28 63 6f 6e 66 69 67 2d 6c  et ((s (config-l
45a0: 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67 64 61 74  ookup *configdat
45b0: 2a 20 22 76 61 6c 69 64 76 61 6c 75 65 73 22 20  * "validvalues" 
45c0: 63 6c 61 73 73 29 29 29 0a 09 09 09 28 69 66 20  class)))....(if 
45d0: 73 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20  s (string-split 
45e0: 73 29 20 23 66 29 29 29 29 0a 20 20 20 20 28 69  s) #f)))).    (i
45f0: 66 20 76 61 6c 69 64 2d 76 61 6c 75 65 73 0a 09  f valid-values..
4600: 28 69 66 20 28 6d 65 6d 62 65 72 20 69 74 65 6d  (if (member item
4610: 20 76 61 6c 69 64 2d 76 61 6c 75 65 73 29 0a 09   valid-values)..
4620: 20 20 20 20 69 74 65 6d 20 23 66 29 0a 09 69 74      item #f)..it
4630: 65 6d 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28  em)))..(define (
4640: 74 65 73 74 73 74 65 70 2d 73 65 74 2d 73 74 61  teststep-set-sta
4650: 74 75 73 21 20 64 62 20 72 75 6e 2d 69 64 20 74  tus! db run-id t
4660: 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 73 74 65  est-name testste
4670: 70 2d 6e 61 6d 65 20 73 74 61 74 65 2d 69 6e 20  p-name state-in 
4680: 73 74 61 74 75 73 2d 69 6e 20 69 74 65 6d 64 61  status-in itemda
4690: 74 20 63 6f 6d 6d 65 6e 74 29 0a 20 20 28 64 65  t comment).  (de
46a0: 62 75 67 3a 70 72 69 6e 74 20 34 20 22 72 75 6e  bug:print 4 "run
46b0: 2d 69 64 3a 20 22 20 72 75 6e 2d 69 64 20 22 20  -id: " run-id " 
46c0: 74 65 73 74 2d 6e 61 6d 65 3a 20 22 20 74 65 73  test-name: " tes
46d0: 74 2d 6e 61 6d 65 29 0a 20 20 28 6c 65 74 2a 20  t-name).  (let* 
46e0: 28 28 73 74 61 74 65 20 20 20 20 20 28 63 68 65  ((state     (che
46f0: 63 6b 2d 76 61 6c 69 64 2d 69 74 65 6d 73 20 22  ck-valid-items "
4700: 73 74 61 74 65 22 20 73 74 61 74 65 2d 69 6e 29  state" state-in)
4710: 29 0a 09 20 28 73 74 61 74 75 73 20 20 20 20 28  ).. (status    (
4720: 63 68 65 63 6b 2d 76 61 6c 69 64 2d 69 74 65 6d  check-valid-item
4730: 73 20 22 73 74 61 74 75 73 22 20 73 74 61 74 75  s "status" statu
4740: 73 2d 69 6e 29 29 0a 09 20 28 69 74 65 6d 2d 70  s-in)).. (item-p
4750: 61 74 68 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e  ath (item-list->
4760: 70 61 74 68 20 69 74 65 6d 64 61 74 29 29 0a 09  path itemdat))..
4770: 20 28 74 65 73 74 64 61 74 20 20 20 28 64 62 3a   (testdat   (db:
4780: 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62  get-test-info db
4790: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
47a0: 65 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 20  e item-path))). 
47b0: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
47c0: 35 20 22 74 65 73 74 64 61 74 3a 20 22 20 74 65  5 "testdat: " te
47d0: 73 74 64 61 74 29 0a 20 20 20 20 28 69 66 20 28  stdat).    (if (
47e0: 61 6e 64 20 74 65 73 74 64 61 74 20 3b 3b 20 69  and testdat ;; i
47f0: 66 20 74 68 65 20 73 65 63 74 69 6f 6e 20 65 78  f the section ex
4800: 69 73 74 73 20 74 68 65 6e 20 66 6f 72 63 65 20  ists then force 
4810: 73 70 65 63 69 66 69 63 61 74 69 6f 6e 20 42 55  specification BU
4820: 47 2c 20 49 20 64 6f 6e 27 74 20 6c 69 6b 65 20  G, I don't like 
4830: 68 6f 77 20 74 68 69 73 20 77 6f 72 6b 73 2e 0a  how this works..
4840: 09 20 20 20 20 20 28 6f 72 20 28 6e 6f 74 20 73  .     (or (not s
4850: 74 61 74 65 29 28 6e 6f 74 20 73 74 61 74 75 73  tate)(not status
4860: 29 29 29 0a 09 28 64 65 62 75 67 3a 70 72 69 6e  )))..(debug:prin
4870: 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 49 6e  t 0 "WARNING: In
4880: 76 61 6c 69 64 20 22 20 28 69 66 20 73 74 61 74  valid " (if stat
4890: 75 73 20 22 73 74 61 74 75 73 22 20 22 73 74 61  us "status" "sta
48a0: 74 65 22 29 0a 09 20 20 20 20 20 20 20 22 20 76  te")..       " v
48b0: 61 6c 75 65 20 5c 22 22 20 28 69 66 20 73 74 61  alue \"" (if sta
48c0: 74 75 73 20 73 74 61 74 65 2d 69 6e 20 73 74 61  tus state-in sta
48d0: 74 75 73 2d 69 6e 29 20 22 5c 22 2c 20 75 70 64  tus-in) "\", upd
48e0: 61 74 65 20 79 6f 75 72 20 76 61 6c 69 64 76 61  ate your validva
48f0: 6c 75 65 73 20 73 65 63 74 69 6f 6e 20 69 6e 20  lues section in 
4900: 6d 65 67 61 74 65 73 74 2e 63 6f 6e 66 69 67 22  megatest.config"
4910: 29 29 0a 20 20 20 20 28 69 66 20 74 65 73 74 64  )).    (if testd
4920: 61 74 0a 09 28 6c 65 74 20 28 28 74 65 73 74 2d  at..(let ((test-
4930: 69 64 20 28 74 65 73 74 3a 67 65 74 2d 69 64 20  id (test:get-id 
4940: 74 65 73 74 64 61 74 29 29 29 0a 09 20 20 28 73  testdat)))..  (s
4950: 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 64  qlite3:execute d
4960: 62 20 0a 09 09 09 22 49 4e 53 45 52 54 20 4f 52  b ...."INSERT OR
4970: 20 52 45 50 4c 41 43 45 20 69 6e 74 6f 20 74 65   REPLACE into te
4980: 73 74 5f 73 74 65 70 73 20 28 74 65 73 74 5f 69  st_steps (test_i
4990: 64 2c 73 74 65 70 6e 61 6d 65 2c 73 74 61 74 65  d,stepname,state
49a0: 2c 73 74 61 74 75 73 2c 65 76 65 6e 74 5f 74 69  ,status,event_ti
49b0: 6d 65 2c 63 6f 6d 6d 65 6e 74 29 20 56 41 4c 55  me,comment) VALU
49c0: 45 53 28 3f 2c 3f 2c 3f 2c 3f 2c 73 74 72 66 74  ES(?,?,?,?,strft
49d0: 69 6d 65 28 27 25 73 27 2c 27 6e 6f 77 27 29 2c  ime('%s','now'),
49e0: 3f 29 3b 22 0a 09 09 09 74 65 73 74 2d 69 64 20  ?);"....test-id 
49f0: 74 65 73 74 73 74 65 70 2d 6e 61 6d 65 20 73 74  teststep-name st
4a00: 61 74 65 2d 69 6e 20 73 74 61 74 75 73 2d 69 6e  ate-in status-in
4a10: 20 28 69 66 20 63 6f 6d 6d 65 6e 74 20 63 6f 6d   (if comment com
4a20: 6d 65 6e 74 20 22 22 29 29 29 0a 09 28 64 65 62  ment "")))..(deb
4a30: 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f  ug:print 0 "ERRO
4a40: 52 3a 20 43 61 6e 27 74 20 75 70 64 61 74 65 20  R: Can't update 
4a50: 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 66 6f  " test-name " fo
4a60: 72 20 72 75 6e 20 22 20 72 75 6e 2d 69 64 20 22  r run " run-id "
4a70: 20 2d 3e 20 6e 6f 20 73 75 63 68 20 74 65 73 74   -> no such test
4a80: 20 69 6e 20 64 62 22 29 29 29 29 0a 0a 28 64 65   in db"))))..(de
4a90: 66 69 6e 65 20 28 74 65 73 74 2d 67 65 74 2d 6b  fine (test-get-k
4aa0: 69 6c 6c 2d 72 65 71 75 65 73 74 20 64 62 20 72  ill-request db r
4ab0: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
4ac0: 69 74 65 6d 64 61 74 29 0a 20 20 28 6c 65 74 2a  itemdat).  (let*
4ad0: 20 28 28 69 74 65 6d 2d 70 61 74 68 20 28 69 74   ((item-path (it
4ae0: 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69 74  em-list->path it
4af0: 65 6d 64 61 74 29 29 0a 09 20 28 74 65 73 74 64  emdat)).. (testd
4b00: 61 74 20 20 20 28 64 62 3a 67 65 74 2d 74 65 73  at   (db:get-tes
4b10: 74 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64  t-info db run-id
4b20: 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d   test-name item-
4b30: 70 61 74 68 29 29 29 0a 20 20 20 20 28 65 71 75  path))).    (equ
4b40: 61 6c 3f 20 28 74 65 73 74 3a 67 65 74 2d 73 74  al? (test:get-st
4b50: 61 74 65 20 74 65 73 74 64 61 74 29 20 22 4b 49  ate testdat) "KI
4b60: 4c 4c 52 45 51 22 29 29 29 0a 0a 28 64 65 66 69  LLREQ")))..(defi
4b70: 6e 65 20 28 74 65 73 74 2d 73 65 74 2d 6d 65 74  ne (test-set-met
4b80: 61 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64  a-info db run-id
4b90: 20 74 65 73 74 6e 61 6d 65 20 69 74 65 6d 64 61   testname itemda
4ba0: 74 29 0a 20 20 28 6c 65 74 20 28 28 69 74 65 6d  t).  (let ((item
4bb0: 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c 69 73 74  -path (item-list
4bc0: 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74 29 29  ->path itemdat))
4bd0: 0a 09 28 63 70 75 6c 6f 61 64 20 20 28 67 65 74  ..(cpuload  (get
4be0: 2d 63 70 75 2d 6c 6f 61 64 29 29 0a 09 28 68 6f  -cpu-load))..(ho
4bf0: 73 74 6e 61 6d 65 20 28 67 65 74 2d 68 6f 73 74  stname (get-host
4c00: 2d 6e 61 6d 65 29 29 0a 09 28 64 69 73 6b 66 72  -name))..(diskfr
4c10: 65 65 20 28 67 65 74 2d 64 66 20 28 63 75 72 72  ee (get-df (curr
4c20: 65 6e 74 2d 64 69 72 65 63 74 6f 72 79 29 29 29  ent-directory)))
4c30: 0a 09 28 75 6e 61 6d 65 20 20 20 20 28 67 65 74  ..(uname    (get
4c40: 2d 75 6e 61 6d 65 20 22 2d 73 72 76 70 69 6f 22  -uname "-srvpio"
4c50: 29 29 0a 09 28 72 75 6e 70 61 74 68 20 20 28 63  ))..(runpath  (c
4c60: 75 72 72 65 6e 74 2d 64 69 72 65 63 74 6f 72 79  urrent-directory
4c70: 29 29 29 0a 20 20 20 20 28 73 71 6c 69 74 65 33  ))).    (sqlite3
4c80: 3a 65 78 65 63 75 74 65 20 64 62 20 22 55 50 44  :execute db "UPD
4c90: 41 54 45 20 74 65 73 74 73 20 53 45 54 20 68 6f  ATE tests SET ho
4ca0: 73 74 3d 3f 2c 63 70 75 6c 6f 61 64 3d 3f 2c 64  st=?,cpuload=?,d
4cb0: 69 73 6b 66 72 65 65 3d 3f 2c 75 6e 61 6d 65 3d  iskfree=?,uname=
4cc0: 3f 2c 72 75 6e 64 69 72 3d 3f 20 57 48 45 52 45  ?,rundir=? WHERE
4cd0: 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65   run_id=? AND te
4ce0: 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65  stname=? AND ite
4cf0: 6d 5f 70 61 74 68 3d 3f 3b 22 0a 09 09 20 20 68  m_path=?;"...  h
4d00: 6f 73 74 6e 61 6d 65 0a 09 09 20 20 63 70 75 6c  ostname...  cpul
4d10: 6f 61 64 0a 09 09 20 20 64 69 73 6b 66 72 65 65  oad...  diskfree
4d20: 0a 09 09 20 20 75 6e 61 6d 65 0a 09 09 20 20 72  ...  uname...  r
4d30: 75 6e 70 61 74 68 0a 09 09 20 20 72 75 6e 2d 69  unpath...  run-i
4d40: 64 0a 09 09 20 20 74 65 73 74 6e 61 6d 65 0a 09  d...  testname..
4d50: 09 20 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a  .  item-path))).
4d60: 0a 28 64 65 66 69 6e 65 20 28 74 65 73 74 2d 75  .(define (test-u
4d70: 70 64 61 74 65 2d 6d 65 74 61 2d 69 6e 66 6f 20  pdate-meta-info 
4d80: 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 6e 61  db run-id testna
4d90: 6d 65 20 69 74 65 6d 64 61 74 20 6d 69 6e 75 74  me itemdat minut
4da0: 65 73 20 63 70 75 6c 6f 61 64 20 64 69 73 6b 66  es cpuload diskf
4db0: 72 65 65 20 74 6d 70 66 72 65 65 29 0a 20 20 28  ree tmpfree).  (
4dc0: 6c 65 74 20 28 28 69 74 65 6d 2d 70 61 74 68 20  let ((item-path 
4dd0: 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68  (item-list->path
4de0: 20 69 74 65 6d 64 61 74 29 29 29 0a 20 20 20 20   itemdat))).    
4df0: 28 69 66 20 28 6e 6f 74 20 69 74 65 6d 2d 70 61  (if (not item-pa
4e00: 74 68 29 28 62 65 67 69 6e 20 28 64 65 62 75 67  th)(begin (debug
4e10: 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e  :print 0 "WARNIN
4e20: 47 3a 20 49 54 45 4d 50 41 54 48 20 6e 6f 74 20  G: ITEMPATH not 
4e30: 73 65 74 2e 22 29 20 20 20 28 73 65 74 21 20 69  set.")   (set! i
4e40: 74 65 6d 2d 70 61 74 68 20 22 22 29 29 29 0a 20  tem-path ""))). 
4e50: 20 20 20 3b 3b 20 28 6c 65 74 20 28 28 74 65 73     ;; (let ((tes
4e60: 74 69 6e 66 6f 20 28 64 62 3a 67 65 74 2d 74 65  tinfo (db:get-te
4e70: 73 74 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69  st-info db run-i
4e80: 64 20 74 65 73 74 6e 61 6d 65 20 69 74 65 6d 2d  d testname item-
4e90: 70 61 74 68 29 29 29 0a 20 20 20 20 3b 3b 20 20  path))).    ;;  
4ea0: 20 28 69 66 20 28 61 6e 64 20 28 6e 6f 74 20 28   (if (and (not (
4eb0: 65 71 75 61 6c 3f 20 28 64 62 3a 74 65 73 74 2d  equal? (db:test-
4ec0: 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 69  get-status testi
4ed0: 6e 66 6f 29 20 22 43 4f 4d 50 4c 45 54 45 44 22  nfo) "COMPLETED"
4ee0: 29 29 0a 20 20 20 20 3b 3b 20 20 20 20 20 20 20  )).    ;;       
4ef0: 20 20 20 20 20 28 6e 6f 74 20 28 65 71 75 61 6c       (not (equal
4f00: 3f 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 73  ? (db:test-get-s
4f10: 74 61 74 75 73 20 74 65 73 74 69 6e 66 6f 29 20  tatus testinfo) 
4f20: 22 4b 49 4c 4c 52 45 51 22 29 29 0a 20 20 20 20  "KILLREQ")).    
4f30: 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65  (sqlite3:execute
4f40: 0a 20 20 20 20 20 64 62 0a 20 20 20 20 20 22 55  .     db.     "U
4f50: 50 44 41 54 45 20 74 65 73 74 73 20 53 45 54 20  PDATE tests SET 
4f60: 63 70 75 6c 6f 61 64 3d 3f 2c 64 69 73 6b 66 72  cpuload=?,diskfr
4f70: 65 65 3d 3f 2c 72 75 6e 5f 64 75 72 61 74 69 6f  ee=?,run_duratio
4f80: 6e 3d 3f 2c 73 74 61 74 65 3d 27 52 55 4e 4e 49  n=?,state='RUNNI
4f90: 4e 47 27 20 57 48 45 52 45 20 72 75 6e 5f 69 64  NG' WHERE run_id
4fa0: 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d  =? AND testname=
4fb0: 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d  ? AND item_path=
4fc0: 3f 20 41 4e 44 20 73 74 61 74 65 20 4e 4f 54 20  ? AND state NOT 
4fd0: 49 4e 20 28 27 43 4f 4d 50 4c 45 54 45 44 27 2c  IN ('COMPLETED',
4fe0: 27 4b 49 4c 4c 52 45 51 27 2c 27 4b 49 4c 4c 45  'KILLREQ','KILLE
4ff0: 44 27 29 3b 22 0a 20 20 20 20 20 63 70 75 6c 6f  D');".     cpulo
5000: 61 64 0a 20 20 20 20 20 64 69 73 6b 66 72 65 65  ad.     diskfree
5010: 0a 20 20 20 20 20 6d 69 6e 75 74 65 73 0a 20 20  .     minutes.  
5020: 20 20 20 72 75 6e 2d 69 64 0a 20 20 20 20 20 74     run-id.     t
5030: 65 73 74 6e 61 6d 65 0a 20 20 20 20 20 69 74 65  estname.     ite
5040: 6d 2d 70 61 74 68 29 29 29 0a 0a 28 64 65 66 69  m-path)))..(defi
5050: 6e 65 20 28 73 65 74 2d 6d 65 67 61 74 65 73 74  ne (set-megatest
5060: 2d 65 6e 76 2d 76 61 72 73 20 64 62 20 72 75 6e  -env-vars db run
5070: 2d 69 64 29 0a 20 20 28 6c 65 74 20 28 28 6b 65  -id).  (let ((ke
5080: 79 73 20 28 64 62 2d 67 65 74 2d 6b 65 79 73 20  ys (db-get-keys 
5090: 64 62 29 29 29 0a 20 20 20 20 28 66 6f 72 2d 65  db))).    (for-e
50a0: 61 63 68 20 28 6c 61 6d 62 64 61 20 28 6b 65 79  ach (lambda (key
50b0: 29 0a 09 09 28 73 71 6c 69 74 65 33 3a 66 6f 72  )...(sqlite3:for
50c0: 2d 65 61 63 68 2d 72 6f 77 0a 09 09 20 28 6c 61  -each-row... (la
50d0: 6d 62 64 61 20 28 76 61 6c 29 0a 09 09 20 20 20  mbda (val)...   
50e0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22  (debug:print 2 "
50f0: 73 65 74 65 6e 76 20 22 20 28 6b 65 79 3a 67 65  setenv " (key:ge
5100: 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65 79 29  t-fieldname key)
5110: 20 22 20 22 20 76 61 6c 29 0a 09 09 20 20 20 28   " " val)...   (
5120: 73 65 74 65 6e 76 20 28 6b 65 79 3a 67 65 74 2d  setenv (key:get-
5130: 66 69 65 6c 64 6e 61 6d 65 20 6b 65 79 29 20 76  fieldname key) v
5140: 61 6c 29 29 0a 09 09 20 64 62 20 0a 09 09 20 28  al))... db ... (
5150: 63 6f 6e 63 20 22 53 45 4c 45 43 54 20 22 20 28  conc "SELECT " (
5160: 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64 6e 61 6d  key:get-fieldnam
5170: 65 20 6b 65 79 29 20 22 20 46 52 4f 4d 20 72 75  e key) " FROM ru
5180: 6e 73 20 57 48 45 52 45 20 69 64 3d 3f 3b 22 29  ns WHERE id=?;")
5190: 0a 09 09 20 72 75 6e 2d 69 64 29 29 0a 09 20 20  ... run-id))..  
51a0: 20 20 20 20 6b 65 79 73 29 29 29 0a 0a 28 64 65      keys)))..(de
51b0: 66 69 6e 65 20 28 73 65 74 2d 69 74 65 6d 2d 65  fine (set-item-e
51c0: 6e 76 2d 76 61 72 73 20 69 74 65 6d 64 61 74 29  nv-vars itemdat)
51d0: 0a 20 20 28 66 6f 72 2d 65 61 63 68 20 28 6c 61  .  (for-each (la
51e0: 6d 62 64 61 20 28 69 74 65 6d 29 0a 09 20 20 20  mbda (item)..   
51f0: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
5200: 32 20 22 73 65 74 65 6e 76 20 22 20 28 63 61 72  2 "setenv " (car
5210: 20 69 74 65 6d 29 20 22 20 22 20 28 63 61 64 72   item) " " (cadr
5220: 20 69 74 65 6d 29 29 0a 09 20 20 20 20 20 20 28   item))..      (
5230: 73 65 74 65 6e 76 20 28 63 61 72 20 69 74 65 6d  setenv (car item
5240: 29 20 28 63 61 64 72 20 69 74 65 6d 29 29 29 0a  ) (cadr item))).
5250: 09 20 20 20 20 69 74 65 6d 64 61 74 29 29 0a 0a  .    itemdat))..
5260: 28 64 65 66 69 6e 65 20 28 67 65 74 2d 61 6c 6c  (define (get-all
5270: 2d 6c 65 67 61 6c 2d 74 65 73 74 73 29 0a 20 20  -legal-tests).  
5280: 28 6c 65 74 2a 20 28 28 74 65 73 74 73 20 20 28  (let* ((tests  (
5290: 67 6c 6f 62 20 28 63 6f 6e 63 20 2a 74 6f 70 70  glob (conc *topp
52a0: 61 74 68 2a 20 22 2f 74 65 73 74 73 2f 2a 22 29  ath* "/tests/*")
52b0: 29 29 0a 09 20 28 72 65 73 20 20 20 20 27 28 29  )).. (res    '()
52c0: 29 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72  )).    (debug:pr
52d0: 69 6e 74 20 34 20 22 49 4e 46 4f 3a 20 4c 6f 6f  int 4 "INFO: Loo
52e0: 6b 69 6e 67 20 61 74 20 74 65 73 74 73 20 22 20  king at tests " 
52f0: 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65  (string-interspe
5300: 72 73 65 20 74 65 73 74 73 20 22 2c 22 29 29 0a  rse tests ",")).
5310: 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20 28 6c      (for-each (l
5320: 61 6d 62 64 61 20 28 74 65 73 74 70 61 74 68 29  ambda (testpath)
5330: 0a 09 09 28 69 66 20 28 66 69 6c 65 2d 65 78 69  ...(if (file-exi
5340: 73 74 73 3f 20 28 63 6f 6e 63 20 74 65 73 74 70  sts? (conc testp
5350: 61 74 68 20 22 2f 74 65 73 74 63 6f 6e 66 69 67  ath "/testconfig
5360: 22 29 29 0a 09 09 20 20 20 20 28 73 65 74 21 20  "))...    (set! 
5370: 72 65 73 20 28 63 6f 6e 73 20 28 6c 61 73 74 20  res (cons (last 
5380: 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 74 65  (string-split te
5390: 73 74 70 61 74 68 20 22 2f 22 29 29 20 72 65 73  stpath "/")) res
53a0: 29 29 29 29 0a 09 20 20 20 20 20 20 74 65 73 74  ))))..      test
53b0: 73 29 0a 20 20 20 20 72 65 73 29 29 0a 0a 28 64  s).    res))..(d
53c0: 65 66 69 6e 65 20 28 72 75 6e 73 3a 63 61 6e 2d  efine (runs:can-
53d0: 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64  run-more-tests d
53e0: 62 29 0a 20 20 28 6c 65 74 20 28 28 6e 75 6d 2d  b).  (let ((num-
53f0: 72 75 6e 6e 69 6e 67 20 28 64 62 3a 67 65 74 2d  running (db:get-
5400: 63 6f 75 6e 74 2d 74 65 73 74 73 2d 72 75 6e 6e  count-tests-runn
5410: 69 6e 67 20 64 62 29 29 0a 09 28 6d 61 78 2d 63  ing db))..(max-c
5420: 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 20 28  oncurrent-jobs (
5430: 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 2a 63  config-lookup *c
5440: 6f 6e 66 69 67 64 61 74 2a 20 22 73 65 74 75 70  onfigdat* "setup
5450: 22 20 22 6d 61 78 5f 63 6f 6e 63 75 72 72 65 6e  " "max_concurren
5460: 74 5f 6a 6f 62 73 22 29 29 29 0a 20 20 20 20 28  t_jobs"))).    (
5470: 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 6d  debug:print 2 "m
5480: 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f  ax-concurrent-jo
5490: 62 73 3a 20 22 20 6d 61 78 2d 63 6f 6e 63 75 72  bs: " max-concur
54a0: 72 65 6e 74 2d 6a 6f 62 73 20 22 2c 20 6e 75 6d  rent-jobs ", num
54b0: 2d 72 75 6e 6e 69 6e 67 3a 20 22 20 6e 75 6d 2d  -running: " num-
54c0: 72 75 6e 6e 69 6e 67 29 0a 20 20 20 20 28 69 66  running).    (if
54d0: 20 28 6e 6f 74 20 28 65 71 3f 20 30 20 2a 67 6c   (not (eq? 0 *gl
54e0: 6f 62 61 6c 65 78 69 74 73 74 61 74 75 73 2a 29  obalexitstatus*)
54f0: 29 0a 09 23 66 0a 09 28 69 66 20 28 6f 72 20 28  )..#f..(if (or (
5500: 6e 6f 74 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65  not max-concurre
5510: 6e 74 2d 6a 6f 62 73 29 0a 09 09 28 61 6e 64 20  nt-jobs)...(and 
5520: 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a  max-concurrent-j
5530: 6f 62 73 0a 09 09 20 20 20 20 20 28 73 74 72 69  obs...     (stri
5540: 6e 67 2d 3e 6e 75 6d 62 65 72 20 6d 61 78 2d 63  ng->number max-c
5550: 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29 0a  oncurrent-jobs).
5560: 09 09 20 20 20 20 20 28 6e 6f 74 20 28 3e 3d 20  ..     (not (>= 
5570: 6e 75 6d 2d 72 75 6e 6e 69 6e 67 20 28 73 74 72  num-running (str
5580: 69 6e 67 2d 3e 6e 75 6d 62 65 72 20 6d 61 78 2d  ing->number max-
5590: 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29  concurrent-jobs)
55a0: 29 29 29 29 0a 09 20 20 20 20 23 74 0a 09 20 20  ))))..    #t..  
55b0: 20 20 28 62 65 67 69 6e 20 0a 09 20 20 20 20 20    (begin ..     
55c0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
55d0: 22 57 41 52 4e 49 4e 47 3a 20 4d 61 78 20 72 75  "WARNING: Max ru
55e0: 6e 6e 69 6e 67 20 6a 6f 62 73 20 65 78 63 65 65  nning jobs excee
55f0: 64 65 64 2c 20 63 75 72 72 65 6e 74 20 6e 75 6d  ded, current num
5600: 62 65 72 20 72 75 6e 6e 69 6e 67 3a 20 22 20 6e  ber running: " n
5610: 75 6d 2d 72 75 6e 6e 69 6e 67 20 0a 09 09 09 20  um-running .... 
5620: 20 20 22 2c 20 6d 61 78 5f 63 6f 6e 63 75 72 72    ", max_concurr
5630: 65 6e 74 5f 6a 6f 62 73 3a 20 22 20 6d 61 78 2d  ent_jobs: " max-
5640: 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29  concurrent-jobs)
5650: 0a 09 20 20 20 20 20 20 23 66 29 29 29 29 29 0a  ..      #f))))).
5660: 20 20 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 2d    .(define (run-
5670: 74 65 73 74 73 20 64 62 20 74 65 73 74 2d 6e 61  tests db test-na
5680: 6d 65 73 29 0a 20 20 28 6c 65 74 2a 20 28 28 6b  mes).  (let* ((k
5690: 65 79 73 20 20 20 20 20 20 20 20 28 64 62 2d 67  eys        (db-g
56a0: 65 74 2d 6b 65 79 73 20 64 62 29 29 0a 09 20 28  et-keys db)).. (
56b0: 6b 65 79 76 61 6c 6c 73 74 20 20 20 28 6b 65 79  keyvallst   (key
56c0: 73 2d 3e 76 61 6c 6c 69 73 74 20 6b 65 79 73 20  s->vallist keys 
56d0: 23 74 29 29 0a 09 20 28 72 75 6e 2d 69 64 20 20  #t)).. (run-id  
56e0: 20 20 20 20 28 72 65 67 69 73 74 65 72 2d 72 75      (register-ru
56f0: 6e 20 64 62 20 6b 65 79 73 29 29 20 20 3b 3b 20  n db keys))  ;; 
5700: 20 74 65 73 74 2d 6e 61 6d 65 29 29 29 0a 09 20   test-name))).. 
5710: 28 64 65 66 65 72 72 65 64 20 20 20 20 27 28 29  (deferred    '()
5720: 29 29 20 3b 3b 20 64 65 6c 61 79 20 72 75 6e 6e  )) ;; delay runn
5730: 69 6e 67 20 74 68 65 73 65 20 73 69 6e 63 65 20  ing these since 
5740: 74 68 65 79 20 68 61 76 65 20 61 20 77 61 69 74  they have a wait
5750: 6f 6e 20 63 6c 61 75 73 65 0a 20 20 20 20 3b 3b  on clause.    ;;
5760: 20 6f 6e 20 74 68 65 20 66 69 72 73 74 20 70 61   on the first pa
5770: 73 73 20 6f 72 20 63 61 6c 6c 20 74 6f 20 72 75  ss or call to ru
5780: 6e 2d 74 65 73 74 73 20 73 65 74 20 46 41 49 4c  n-tests set FAIL
5790: 53 20 74 6f 20 4e 4f 54 5f 53 54 41 52 54 45 44  S to NOT_STARTED
57a0: 20 69 66 0a 20 20 20 20 3b 3b 20 2d 6b 65 65 70   if.    ;; -keep
57b0: 67 6f 69 6e 67 20 69 73 20 73 70 65 63 69 66 69  going is specifi
57c0: 65 64 0a 20 20 20 20 28 69 66 20 28 61 6e 64 20  ed.    (if (and 
57d0: 28 65 71 3f 20 2a 70 61 73 73 6e 75 6d 2a 20 30  (eq? *passnum* 0
57e0: 29 0a 09 20 20 20 20 20 28 61 72 67 73 3a 67 65  )..     (args:ge
57f0: 74 2d 61 72 67 20 22 2d 6b 65 65 70 67 6f 69 6e  t-arg "-keepgoin
5800: 67 22 29 29 0a 09 28 62 65 67 69 6e 0a 09 20 20  g"))..(begin..  
5810: 3b 3b 20 68 61 76 65 20 74 6f 20 64 65 6c 65 74  ;; have to delet
5820: 65 20 74 65 73 74 20 72 65 63 6f 72 64 73 20 77  e test records w
5830: 68 65 72 65 20 4e 4f 54 5f 53 54 41 52 54 45 44  here NOT_STARTED
5840: 20 73 69 6e 63 65 20 74 68 65 79 20 63 61 6e 20   since they can 
5850: 63 61 75 73 65 20 2d 6b 65 65 70 67 6f 69 6e 67  cause -keepgoing
5860: 20 74 6f 20 0a 09 20 20 3b 3b 20 67 65 74 20 73   to ..  ;; get s
5870: 74 75 63 6b 20 64 75 65 20 74 6f 20 62 65 63 6f  tuck due to beco
5880: 6d 69 6e 67 20 69 6e 61 63 63 65 73 73 69 62 6c  ming inaccessibl
5890: 65 20 66 72 6f 6d 20 61 20 66 61 69 6c 65 64 20  e from a failed 
58a0: 74 65 73 74 2e 20 49 2e 65 2e 20 69 66 20 74 65  test. I.e. if te
58b0: 73 74 20 42 20 64 65 70 65 6e 64 73 20 0a 09 20  st B depends .. 
58c0: 20 3b 3b 20 6f 6e 20 74 65 73 74 20 41 20 62 75   ;; on test A bu
58d0: 74 20 74 65 73 74 20 42 20 72 65 61 63 68 65 64  t test B reached
58e0: 20 74 68 65 20 70 6f 69 6e 74 20 6f 6e 20 62 65   the point on be
58f0: 69 6e 67 20 72 65 67 69 73 74 65 72 65 64 20 61  ing registered a
5900: 73 20 4e 4f 54 5f 53 54 41 52 54 45 44 20 61 6e  s NOT_STARTED an
5910: 64 20 74 65 73 74 0a 09 20 20 3b 3b 20 41 20 66  d test..  ;; A f
5920: 61 69 6c 65 64 20 66 6f 72 20 73 6f 6d 65 20 72  ailed for some r
5930: 65 61 73 6f 6e 20 74 68 65 6e 20 6f 6e 20 72 65  eason then on re
5940: 2d 72 75 6e 20 75 73 69 6e 67 20 2d 6b 65 65 70  -run using -keep
5950: 67 6f 69 6e 67 20 74 68 65 20 72 75 6e 20 63 61  going the run ca
5960: 6e 20 6e 65 76 65 72 20 63 6f 6d 70 6c 65 74 65  n never complete
5970: 2e 0a 09 20 20 28 64 62 3a 64 65 6c 65 74 65 2d  ...  (db:delete-
5980: 74 65 73 74 73 2d 69 6e 2d 73 74 61 74 65 20 64  tests-in-state d
5990: 62 20 72 75 6e 2d 69 64 20 22 4e 4f 54 5f 53 54  b run-id "NOT_ST
59a0: 41 52 54 45 44 22 29 0a 09 20 20 28 64 62 3a 73  ARTED")..  (db:s
59b0: 65 74 2d 74 65 73 74 73 2d 73 74 61 74 65 2d 73  et-tests-state-s
59c0: 74 61 74 75 73 20 64 62 20 72 75 6e 2d 69 64 20  tatus db run-id 
59d0: 74 65 73 74 2d 6e 61 6d 65 73 20 23 66 20 22 46  test-names #f "F
59e0: 41 49 4c 22 20 22 4e 4f 54 5f 53 54 41 52 54 45  AIL" "NOT_STARTE
59f0: 44 22 20 22 46 41 49 4c 22 29 29 29 0a 20 20 20  D" "FAIL"))).   
5a00: 20 28 73 65 74 21 20 2a 70 61 73 73 6e 75 6d 2a   (set! *passnum*
5a10: 20 28 2b 20 2a 70 61 73 73 6e 75 6d 2a 20 31 29   (+ *passnum* 1)
5a20: 29 0a 20 20 20 20 28 6c 65 74 20 6c 6f 6f 70 20  ).    (let loop 
5a30: 28 28 6e 75 6d 74 69 6d 65 73 20 30 29 29 0a 20  ((numtimes 0)). 
5a40: 20 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20 0a       (for-each .
5a50: 20 20 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28         (lambda (
5a60: 74 65 73 74 2d 6e 61 6d 65 29 0a 09 20 28 69 66  test-name).. (if
5a70: 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d   (runs:can-run-m
5a80: 6f 72 65 2d 74 65 73 74 73 20 64 62 29 0a 09 20  ore-tests db).. 
5a90: 20 20 20 20 28 72 75 6e 2d 6f 6e 65 2d 74 65 73      (run-one-tes
5aa0: 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  t db run-id test
5ab0: 2d 6e 61 6d 65 20 6b 65 79 76 61 6c 6c 73 74 29  -name keyvallst)
5ac0: 0a 09 20 20 20 20 20 3b 3b 20 61 64 64 20 73 6f  ..     ;; add so
5ad0: 6d 65 20 64 65 6c 61 79 20 0a 09 20 20 20 20 20  me delay ..     
5ae0: 3b 28 73 6c 65 65 70 20 32 29 0a 09 20 20 20 20  ;(sleep 2)..    
5af0: 20 29 29 0a 20 20 20 20 20 20 20 74 65 73 74 2d   )).       test-
5b00: 6e 61 6d 65 73 29 0a 20 20 20 20 20 20 3b 3b 20  names).      ;; 
5b10: 28 72 75 6e 2d 77 61 69 74 69 6e 67 2d 74 65 73  (run-waiting-tes
5b20: 74 73 20 64 62 29 0a 20 20 20 20 20 20 28 69 66  ts db).      (if
5b30: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22   (args:get-arg "
5b40: 2d 6b 65 65 70 67 6f 69 6e 67 22 29 0a 09 20 20  -keepgoing")..  
5b50: 28 6c 65 74 20 28 28 65 73 74 72 65 6d 20 28 64  (let ((estrem (d
5b60: 62 3a 65 73 74 69 6d 61 74 65 64 2d 74 65 73 74  b:estimated-test
5b70: 73 2d 72 65 6d 61 69 6e 69 6e 67 20 64 62 20 72  s-remaining db r
5b80: 75 6e 2d 69 64 29 29 29 0a 09 20 20 20 20 28 69  un-id)))..    (i
5b90: 66 20 28 61 6e 64 20 28 3e 20 65 73 74 72 65 6d  f (and (> estrem
5ba0: 20 30 29 0a 09 09 20 20 20 20 20 28 65 71 3f 20   0)...     (eq? 
5bb0: 2a 67 6c 6f 62 61 6c 65 78 69 74 73 74 61 74 75  *globalexitstatu
5bc0: 73 2a 20 30 29 29 0a 09 09 28 62 65 67 69 6e 0a  s* 0))...(begin.
5bd0: 09 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ..  (debug:print
5be0: 20 31 20 22 4b 65 65 70 20 67 6f 69 6e 67 2c 20   1 "Keep going, 
5bf0: 65 73 74 69 6d 61 74 65 64 20 22 20 65 73 74 72  estimated " estr
5c00: 65 6d 20 22 20 74 65 73 74 73 20 72 65 6d 61 69  em " tests remai
5c10: 6e 69 6e 67 20 74 6f 20 72 75 6e 2c 20 77 69 6c  ning to run, wil
5c20: 6c 20 63 6f 6e 74 69 6e 75 65 20 69 6e 20 33 20  l continue in 3 
5c30: 73 65 63 6f 6e 64 73 20 2e 2e 2e 22 29 0a 09 09  seconds ...")...
5c40: 20 20 28 73 6c 65 65 70 20 33 29 0a 09 09 20 20    (sleep 3)...  
5c50: 28 72 75 6e 2d 77 61 69 74 69 6e 67 2d 74 65 73  (run-waiting-tes
5c60: 74 73 20 64 62 29 0a 09 09 20 20 28 6c 6f 6f 70  ts db)...  (loop
5c70: 20 28 2b 20 6e 75 6d 74 69 6d 65 73 20 31 29 29   (+ numtimes 1))
5c80: 29 29 29 29 29 29 29 0a 09 20 20 20 0a 3b 3b 20  )))))))..   .;; 
5c90: 56 45 52 59 20 49 4e 45 46 46 49 43 49 45 4e 54  VERY INEFFICIENT
5ca0: 21 20 4d 6f 76 65 20 73 74 75 66 66 20 74 68 61  ! Move stuff tha
5cb0: 74 20 73 68 6f 75 6c 64 20 62 65 20 64 6f 6e 65  t should be done
5cc0: 20 6f 6e 63 65 20 75 70 20 74 6f 20 63 61 6c 6c   once up to call
5cd0: 69 6e 67 20 70 72 6f 63 0a 28 64 65 66 69 6e 65  ing proc.(define
5ce0: 20 28 72 75 6e 2d 6f 6e 65 2d 74 65 73 74 20 64   (run-one-test d
5cf0: 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  b run-id test-na
5d00: 6d 65 20 6b 65 79 76 61 6c 6c 73 74 29 0a 20 20  me keyvallst).  
5d10: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22  (debug:print 1 "
5d20: 4c 61 75 6e 63 68 69 6e 67 20 74 65 73 74 20 22  Launching test "
5d30: 20 74 65 73 74 2d 6e 61 6d 65 29 0a 20 20 3b 3b   test-name).  ;;
5d40: 20 41 6c 6c 20 74 68 65 73 65 20 76 61 72 73 20   All these vars 
5d50: 6d 69 67 68 74 20 62 65 20 72 65 66 65 72 65 6e  might be referen
5d60: 63 65 64 20 62 79 20 74 68 65 20 74 65 73 74 63  ced by the testc
5d70: 6f 6e 66 69 67 20 66 69 6c 65 20 72 65 61 64 65  onfig file reade
5d80: 72 0a 20 20 28 73 65 74 65 6e 76 20 22 4d 54 5f  r.  (setenv "MT_
5d90: 54 45 53 54 5f 4e 41 4d 45 22 20 74 65 73 74 2d  TEST_NAME" test-
5da0: 6e 61 6d 65 29 20 3b 3b 20 0a 20 20 28 73 65 74  name) ;; .  (set
5db0: 65 6e 76 20 22 4d 54 5f 52 55 4e 4e 41 4d 45 22  env "MT_RUNNAME"
5dc0: 20 20 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67     (args:get-arg
5dd0: 20 22 3a 72 75 6e 6e 61 6d 65 22 29 29 0a 20 20   ":runname")).  
5de0: 28 73 65 74 2d 6d 65 67 61 74 65 73 74 2d 65 6e  (set-megatest-en
5df0: 76 2d 76 61 72 73 20 64 62 20 72 75 6e 2d 69 64  v-vars db run-id
5e00: 29 20 3b 3b 20 74 68 65 73 65 20 6d 61 79 20 62  ) ;; these may b
5e10: 65 20 6e 65 65 64 65 64 20 62 79 20 74 68 65 20  e needed by the 
5e20: 6c 61 75 6e 63 68 69 6e 67 20 70 72 6f 63 65 73  launching proces
5e30: 73 0a 20 20 28 63 68 61 6e 67 65 2d 64 69 72 65  s.  (change-dire
5e40: 63 74 6f 72 79 20 2a 74 6f 70 70 61 74 68 2a 29  ctory *toppath*)
5e50: 0a 20 20 28 6c 65 74 2a 20 28 28 74 65 73 74 2d  .  (let* ((test-
5e60: 70 61 74 68 20 20 20 20 28 63 6f 6e 63 20 2a 74  path    (conc *t
5e70: 6f 70 70 61 74 68 2a 20 22 2f 74 65 73 74 73 2f  oppath* "/tests/
5e80: 22 20 74 65 73 74 2d 6e 61 6d 65 29 29 0a 09 20  " test-name)).. 
5e90: 28 74 65 73 74 2d 63 6f 6e 66 69 67 66 20 28 63  (test-configf (c
5ea0: 6f 6e 63 20 74 65 73 74 2d 70 61 74 68 20 22 2f  onc test-path "/
5eb0: 74 65 73 74 63 6f 6e 66 69 67 22 29 29 0a 09 20  testconfig")).. 
5ec0: 28 74 65 73 74 65 78 69 73 74 73 20 20 20 28 61  (testexists   (a
5ed0: 6e 64 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f  nd (file-exists?
5ee0: 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 29 28 66   test-configf)(f
5ef0: 69 6c 65 2d 72 65 61 64 2d 61 63 63 65 73 73 3f  ile-read-access?
5f00: 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 29 29 29   test-configf)))
5f10: 0a 09 20 28 74 65 73 74 2d 63 6f 6e 66 20 20 20  .. (test-conf   
5f20: 20 28 69 66 20 74 65 73 74 65 78 69 73 74 73 20   (if testexists 
5f30: 28 72 65 61 64 2d 63 6f 6e 66 69 67 20 74 65 73  (read-config tes
5f40: 74 2d 63 6f 6e 66 69 67 66 20 23 66 20 23 74 29  t-configf #f #t)
5f50: 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c   (make-hash-tabl
5f60: 65 29 29 29 0a 09 20 28 77 61 69 74 6f 6e 20 20  e))).. (waiton  
5f70: 20 20 20 20 20 28 6c 65 74 20 28 28 77 20 28 63       (let ((w (c
5f80: 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 74 65 73  onfig-lookup tes
5f90: 74 2d 63 6f 6e 66 20 22 72 65 71 75 69 72 65 6d  t-conf "requirem
5fa0: 65 6e 74 73 22 20 22 77 61 69 74 6f 6e 22 29 29  ents" "waiton"))
5fb0: 29 0a 09 09 09 20 28 69 66 20 28 73 74 72 69 6e  ).... (if (strin
5fc0: 67 3f 20 77 29 28 73 74 72 69 6e 67 2d 73 70 6c  g? w)(string-spl
5fd0: 69 74 20 77 29 27 28 29 29 29 29 0a 09 20 28 74  it w)'()))).. (t
5fe0: 61 67 73 20 20 20 20 20 20 20 20 20 28 6c 65 74  ags         (let
5ff0: 20 28 28 74 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f   ((t (config-loo
6000: 6b 75 70 20 74 65 73 74 2d 63 6f 6e 66 20 22 73  kup test-conf "s
6010: 65 74 75 70 22 20 22 74 61 67 73 22 29 29 29 0a  etup" "tags"))).
6020: 09 09 09 20 3b 3b 20 77 65 20 77 61 6e 74 20 6f  ... ;; we want o
6030: 75 72 20 74 61 67 73 20 74 6f 20 62 65 20 73 65  ur tags to be se
6040: 70 61 72 61 74 65 64 20 62 79 20 63 6f 6d 6d 61  parated by comma
6050: 73 20 61 6e 64 20 66 75 6c 6c 79 20 64 65 6c 69  s and fully deli
6060: 6d 69 74 65 64 20 62 79 20 63 6f 6d 6d 61 73 0a  mited by commas.
6070: 09 09 09 20 3b 3b 20 73 6f 20 74 68 61 74 20 71  ... ;; so that q
6080: 75 65 72 69 65 73 20 77 69 74 68 20 22 6c 69 6b  ueries with "lik
6090: 65 22 20 63 61 6e 20 74 69 65 20 74 6f 20 74 68  e" can tie to th
60a0: 65 20 63 6f 6d 6d 61 73 20 61 74 20 65 69 74 68  e commas at eith
60b0: 65 72 20 65 6e 64 20 6f 66 20 65 61 63 68 20 74  er end of each t
60c0: 61 67 0a 09 09 09 20 3b 3b 20 77 68 69 6c 65 20  ag.... ;; while 
60d0: 61 6c 73 6f 20 61 6c 6c 6f 77 69 6e 67 20 74 68  also allowing th
60e0: 65 20 65 6e 64 20 75 73 65 72 20 74 6f 20 66 72  e end user to fr
60f0: 65 65 6c 79 20 75 73 65 20 73 70 61 63 65 73 20  eely use spaces 
6100: 61 6e 64 20 63 6f 6d 6d 61 73 20 74 6f 20 73 65  and commas to se
6110: 70 61 72 61 74 65 20 74 61 67 73 0a 09 09 09 20  parate tags.... 
6120: 28 69 66 20 28 73 74 72 69 6e 67 3f 20 74 29 28  (if (string? t)(
6130: 73 74 72 69 6e 67 2d 73 75 62 73 74 69 74 75 74  string-substitut
6140: 65 20 28 72 65 67 65 78 70 20 22 5b 2c 5c 5c 73  e (regexp "[,\\s
6150: 5d 2b 22 29 20 22 2c 22 20 28 63 6f 6e 63 20 22  ]+") "," (conc "
6160: 2c 22 20 74 20 22 2c 22 29 20 23 74 29 0a 09 09  ," t ",") #t)...
6170: 09 20 20 20 20 20 27 28 29 29 29 29 29 0a 20 20  .     '())))).  
6180: 20 20 28 69 66 20 28 6e 6f 74 20 74 65 73 74 65    (if (not teste
6190: 78 69 73 74 73 29 0a 09 28 62 65 67 69 6e 0a 09  xists)..(begin..
61a0: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30    (debug:print 0
61b0: 20 22 45 52 52 4f 52 3a 20 43 61 6e 27 74 20 66   "ERROR: Can't f
61c0: 69 6e 64 20 63 6f 6e 66 69 67 20 66 69 6c 65 20  ind config file 
61d0: 22 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 29 0a  " test-configf).
61e0: 09 20 20 28 65 78 69 74 20 32 29 29 0a 09 3b 3b  .  (exit 2))..;;
61f0: 20 70 75 74 20 74 6f 70 20 76 61 72 73 20 69 6e   put top vars in
6200: 74 6f 20 63 6f 6e 76 65 6e 69 65 6e 74 20 76 61  to convenient va
6210: 72 69 61 62 6c 65 73 20 61 6e 64 20 6f 70 65 6e  riables and open
6220: 20 74 68 65 20 64 62 0a 09 28 6c 65 74 2a 20 28   the db..(let* (
6230: 3b 3b 20 64 62 20 69 73 20 61 6c 77 61 79 73 20  ;; db is always 
6240: 61 74 20 2a 74 6f 70 70 61 74 68 2a 2f 64 62 2f  at *toppath*/db/
6250: 6d 65 67 61 74 65 73 74 2e 64 62 0a 09 20 20 20  megatest.db..   
6260: 20 20 20 20 28 69 74 65 6d 73 20 20 20 20 20 20      (items      
6270: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
6280: 2f 64 65 66 61 75 6c 74 20 74 65 73 74 2d 63 6f  /default test-co
6290: 6e 66 20 22 69 74 65 6d 73 22 20 27 28 29 29 29  nf "items" '()))
62a0: 0a 09 20 20 20 20 20 20 20 28 69 74 65 6d 73 74  ..       (itemst
62b0: 61 62 6c 65 20 20 28 68 61 73 68 2d 74 61 62 6c  able  (hash-tabl
62c0: 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 74 65  e-ref/default te
62d0: 73 74 2d 63 6f 6e 66 20 22 69 74 65 6d 73 74 61  st-conf "itemsta
62e0: 62 6c 65 22 20 27 28 29 29 29 0a 09 20 20 20 20  ble" '()))..    
62f0: 20 20 20 28 61 6c 6c 69 74 65 6d 73 20 20 20 20     (allitems    
6300: 28 69 66 20 28 6f 72 20 28 6e 6f 74 20 28 6e 75  (if (or (not (nu
6310: 6c 6c 3f 20 69 74 65 6d 73 29 29 28 6e 6f 74 20  ll? items))(not 
6320: 28 6e 75 6c 6c 3f 20 69 74 65 6d 73 74 61 62 6c  (null? itemstabl
6330: 65 29 29 29 0a 09 09 09 09 28 61 70 70 65 6e 64  e))).....(append
6340: 20 28 69 74 65 6d 2d 61 73 73 6f 63 2d 3e 69 74   (item-assoc->it
6350: 65 6d 2d 6c 69 73 74 20 69 74 65 6d 73 29 0a 09  em-list items)..
6360: 09 09 09 09 28 69 74 65 6d 2d 74 61 62 6c 65 2d  ....(item-table-
6370: 3e 69 74 65 6d 2d 6c 69 73 74 20 69 74 65 6d 73  >item-list items
6380: 74 61 62 6c 65 29 29 0a 09 09 09 09 27 28 28 29  table)).....'(()
6390: 29 29 29 20 3b 3b 20 61 20 6c 69 73 74 20 77 69  ))) ;; a list wi
63a0: 74 68 20 6f 6e 65 20 6e 75 6c 6c 20 6c 69 73 74  th one null list
63b0: 20 69 73 20 61 20 74 65 73 74 20 77 69 74 68 20   is a test with 
63c0: 6e 6f 20 69 74 65 6d 73 0a 09 20 20 20 20 20 20  no items..      
63d0: 20 28 72 75 6e 63 6f 6e 66 69 67 66 20 20 28 63   (runconfigf  (c
63e0: 6f 6e 63 20 20 2a 74 6f 70 70 61 74 68 2a 20 22  onc  *toppath* "
63f0: 2f 72 75 6e 63 6f 6e 66 69 67 73 2e 63 6f 6e 66  /runconfigs.conf
6400: 69 67 22 29 29 29 0a 09 20 20 28 64 65 62 75 67  ig")))..  (debug
6410: 3a 70 72 69 6e 74 20 31 20 22 69 74 65 6d 73 3a  :print 1 "items:
6420: 20 22 29 0a 09 20 20 28 69 66 20 28 3e 3d 20 2a   ")..  (if (>= *
6430: 76 65 72 62 6f 73 69 74 79 2a 20 31 29 28 70 70  verbosity* 1)(pp
6440: 20 61 6c 6c 69 74 65 6d 73 29 29 0a 09 20 20 28   allitems))..  (
6450: 69 66 20 28 3e 3d 20 2a 76 65 72 62 6f 73 69 74  if (>= *verbosit
6460: 79 2a 20 35 29 0a 09 20 20 20 20 20 20 28 62 65  y* 5)..      (be
6470: 67 69 6e 0a 09 09 28 70 72 69 6e 74 20 22 69 74  gin...(print "it
6480: 65 6d 73 3a 20 22 29 28 70 70 20 28 69 74 65 6d  ems: ")(pp (item
6490: 2d 61 73 73 6f 63 2d 3e 69 74 65 6d 2d 6c 69 73  -assoc->item-lis
64a0: 74 20 69 74 65 6d 73 29 29 0a 09 09 28 70 72 69  t items))...(pri
64b0: 6e 74 20 22 69 74 65 73 74 61 62 6c 65 3a 20 22  nt "itestable: "
64c0: 29 28 70 70 20 28 69 74 65 6d 2d 74 61 62 6c 65  )(pp (item-table
64d0: 2d 3e 69 74 65 6d 2d 6c 69 73 74 20 69 74 65 6d  ->item-list item
64e0: 73 74 61 62 6c 65 29 29 29 29 0a 09 20 20 28 69  stable))))..  (i
64f0: 66 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20  f (args:get-arg 
6500: 22 2d 6d 22 29 0a 09 20 20 20 20 20 20 28 64 62  "-m")..      (db
6510: 3a 73 65 74 2d 63 6f 6d 6d 65 6e 74 2d 66 6f 72  :set-comment-for
6520: 2d 72 75 6e 20 64 62 20 72 75 6e 2d 69 64 20 28  -run db run-id (
6530: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 6d  args:get-arg "-m
6540: 22 29 29 29 0a 0a 09 20 20 3b 3b 20 48 65 72 65  ")))...  ;; Here
6550: 20 69 73 20 77 68 65 72 65 20 74 68 65 20 74 65   is where the te
6560: 73 74 5f 6d 65 74 61 20 74 61 62 6c 65 20 69 73  st_meta table is
6570: 20 62 65 73 74 20 75 70 64 61 74 65 64 0a 09 20   best updated.. 
6580: 20 28 72 75 6e 73 3a 75 70 64 61 74 65 2d 74 65   (runs:update-te
6590: 73 74 5f 6d 65 74 61 20 64 62 20 74 65 73 74 2d  st_meta db test-
65a0: 6e 61 6d 65 20 74 65 73 74 2d 63 6f 6e 66 29 0a  name test-conf).
65b0: 0a 09 20 20 3b 3b 20 62 72 61 69 6e 64 65 61 64  ..  ;; braindead
65c0: 20 77 6f 72 6b 2d 61 72 6f 75 6e 64 20 66 6f 72   work-around for
65d0: 20 70 6f 6f 72 6c 79 20 73 70 65 63 69 66 69 65   poorly specifie
65e0: 64 20 61 6c 6c 69 74 65 6d 73 20 6c 69 73 74 20  d allitems list 
65f0: 42 55 47 21 21 21 20 46 49 58 4d 45 0a 09 20 20  BUG!!! FIXME..  
6600: 28 69 66 20 28 6e 75 6c 6c 3f 20 61 6c 6c 69 74  (if (null? allit
6610: 65 6d 73 29 28 73 65 74 21 20 61 6c 6c 69 74 65  ems)(set! allite
6620: 6d 73 20 27 28 28 29 29 29 29 0a 09 20 20 28 6c  ms '(())))..  (l
6630: 65 74 20 6c 6f 6f 70 20 28 28 69 74 65 6d 64 61  et loop ((itemda
6640: 74 20 28 63 61 72 20 61 6c 6c 69 74 65 6d 73 29  t (car allitems)
6650: 29 0a 09 09 20 20 20 20 20 28 74 61 6c 20 20 20  )...     (tal   
6660: 20 20 28 63 64 72 20 61 6c 6c 69 74 65 6d 73 29    (cdr allitems)
6670: 29 29 0a 09 20 20 20 20 3b 3b 20 28 6c 61 6d 62  ))..    ;; (lamb
6680: 64 61 20 28 69 74 65 6d 64 61 74 29 20 3b 3b 3b  da (itemdat) ;;;
6690: 20 28 28 72 69 70 65 6e 65 73 73 20 22 6f 76 65   ((ripeness "ove
66a0: 72 72 69 70 65 22 29 20 28 74 65 6d 70 65 72 61  rripe") (tempera
66b0: 74 75 72 65 20 22 63 6f 6f 6c 22 29 20 28 73 65  ture "cool") (se
66c0: 61 73 6f 6e 20 22 73 75 6d 6d 65 72 22 29 29 0a  ason "summer")).
66d0: 09 20 20 20 20 3b 3b 20 48 61 6e 64 6c 65 20 6c  .    ;; Handle l
66e0: 69 73 74 73 20 6f 66 20 69 74 65 6d 73 0a 09 20  ists of items.. 
66f0: 20 20 20 28 6c 65 74 2a 20 28 28 69 74 65 6d 2d     (let* ((item-
6700: 70 61 74 68 20 20 20 20 20 28 69 74 65 6d 2d 6c  path     (item-l
6710: 69 73 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61  ist->path itemda
6720: 74 29 29 20 3b 3b 20 28 73 74 72 69 6e 67 2d 69  t)) ;; (string-i
6730: 6e 74 65 72 73 70 65 72 73 65 20 28 6d 61 70 20  ntersperse (map 
6740: 63 61 64 72 20 69 74 65 6d 64 61 74 29 20 22 2f  cadr itemdat) "/
6750: 22 29 29 0a 09 09 20 20 20 28 6e 65 77 2d 74 65  "))...   (new-te
6760: 73 74 2d 70 61 74 68 20 28 73 74 72 69 6e 67 2d  st-path (string-
6770: 69 6e 74 65 72 73 70 65 72 73 65 20 28 63 6f 6e  intersperse (con
6780: 73 20 74 65 73 74 2d 70 61 74 68 20 28 6d 61 70  s test-path (map
6790: 20 63 61 64 72 20 69 74 65 6d 64 61 74 29 29 20   cadr itemdat)) 
67a0: 22 2f 22 29 29 0a 09 09 20 20 20 28 6e 65 77 2d  "/"))...   (new-
67b0: 74 65 73 74 2d 6e 61 6d 65 20 28 69 66 20 28 65  test-name (if (e
67c0: 71 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20  qual? item-path 
67d0: 22 22 29 20 74 65 73 74 2d 6e 61 6d 65 20 28 63  "") test-name (c
67e0: 6f 6e 63 20 74 65 73 74 2d 6e 61 6d 65 20 22 2f  onc test-name "/
67f0: 22 20 69 74 65 6d 2d 70 61 74 68 29 29 29 20 3b  " item-path))) ;
6800: 3b 20 6a 75 73 74 20 6e 65 65 64 20 69 74 20 74  ; just need it t
6810: 6f 20 62 65 20 75 6e 69 71 75 65 0a 09 09 20 20  o be unique...  
6820: 20 28 74 65 73 74 64 61 74 20 20 20 23 66 29 0a   (testdat   #f).
6830: 09 09 20 20 20 28 6e 75 6d 2d 72 75 6e 6e 69 6e  ..   (num-runnin
6840: 67 20 28 64 62 3a 67 65 74 2d 63 6f 75 6e 74 2d  g (db:get-count-
6850: 74 65 73 74 73 2d 72 75 6e 6e 69 6e 67 20 64 62  tests-running db
6860: 29 29 0a 09 09 20 20 20 28 6d 61 78 2d 63 6f 6e  ))...   (max-con
6870: 63 75 72 72 65 6e 74 2d 6a 6f 62 73 20 28 63 6f  current-jobs (co
6880: 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e  nfig-lookup *con
6890: 66 69 67 64 61 74 2a 20 22 73 65 74 75 70 22 20  figdat* "setup" 
68a0: 22 6d 61 78 5f 63 6f 6e 63 75 72 72 65 6e 74 5f  "max_concurrent_
68b0: 6a 6f 62 73 22 29 29 0a 09 09 20 20 20 28 70 61  jobs"))...   (pa
68c0: 72 65 6e 74 2d 74 65 73 74 20 28 61 6e 64 20 28  rent-test (and (
68d0: 6e 6f 74 20 28 6e 75 6c 6c 3f 20 69 74 65 6d 73  not (null? items
68e0: 29 29 28 65 71 75 61 6c 3f 20 69 74 65 6d 2d 70  ))(equal? item-p
68f0: 61 74 68 20 22 22 29 29 29 0a 09 09 20 20 20 28  ath "")))...   (
6900: 73 69 6e 67 6c 65 2d 74 65 73 74 20 28 61 6e 64  single-test (and
6910: 20 28 6e 75 6c 6c 3f 20 69 74 65 6d 73 29 20 28   (null? items) (
6920: 65 71 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68  equal? item-path
6930: 20 22 22 29 29 29 0a 09 09 20 20 20 28 69 74 65   "")))...   (ite
6940: 6d 2d 74 65 73 74 20 20 20 28 6e 6f 74 20 28 65  m-test   (not (e
6950: 71 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20  qual? item-path 
6960: 22 22 29 29 29 0a 09 09 20 20 20 28 69 74 65 6d  "")))...   (item
6970: 2d 70 61 74 74 20 20 20 28 61 72 67 73 3a 67 65  -patt   (args:ge
6980: 74 2d 61 72 67 20 22 2d 69 74 65 6d 70 61 74 74  t-arg "-itempatt
6990: 22 29 29 0a 09 09 20 20 20 28 70 61 74 74 2d 6d  "))...   (patt-m
69a0: 61 74 63 68 20 20 28 69 66 20 69 74 65 6d 2d 70  atch  (if item-p
69b0: 61 74 74 0a 09 09 09 09 20 20 20 20 28 73 74 72  att.....    (str
69c0: 69 6e 67 2d 6d 61 74 63 68 20 28 67 6c 6f 62 2d  ing-match (glob-
69d0: 3e 72 65 67 65 78 70 0a 09 09 09 09 09 09 20 20  >regexp.......  
69e0: 20 28 73 74 72 69 6e 67 2d 74 72 61 6e 73 6c 61   (string-transla
69f0: 74 65 20 69 74 65 6d 2d 70 61 74 74 20 22 25 22  te item-patt "%"
6a00: 20 22 2a 22 29 29 0a 09 09 09 09 09 09 20 20 69   "*")).......  i
6a10: 74 65 6d 2d 70 61 74 68 29 0a 09 09 09 09 20 20  tem-path).....  
6a20: 20 20 23 74 29 29 29 0a 09 20 20 20 20 20 20 28    #t)))..      (
6a30: 64 65 62 75 67 3a 70 72 69 6e 74 20 33 20 22 6d  debug:print 3 "m
6a40: 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f  ax-concurrent-jo
6a50: 62 73 3a 20 22 20 6d 61 78 2d 63 6f 6e 63 75 72  bs: " max-concur
6a60: 72 65 6e 74 2d 6a 6f 62 73 20 22 2c 20 6e 75 6d  rent-jobs ", num
6a70: 2d 72 75 6e 6e 69 6e 67 3a 20 22 20 6e 75 6d 2d  -running: " num-
6a80: 72 75 6e 6e 69 6e 67 29 0a 09 20 20 20 20 20 20  running)..      
6a90: 28 69 66 20 28 61 6e 64 20 70 61 74 74 2d 6d 61  (if (and patt-ma
6aa0: 74 63 68 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75  tch (runs:can-ru
6ab0: 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64 62 29  n-more-tests db)
6ac0: 29 0a 09 09 20 20 28 62 65 67 69 6e 0a 09 09 20  )...  (begin... 
6ad0: 20 20 20 28 6c 65 74 20 6c 6f 6f 70 32 20 28 28     (let loop2 ((
6ae0: 74 73 20 28 64 62 3a 67 65 74 2d 74 65 73 74 2d  ts (db:get-test-
6af0: 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74  info db run-id t
6b00: 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61  est-name item-pa
6b10: 74 68 29 29 20 3b 3b 20 23 66 29 0a 09 09 09 09  th)) ;; #f).....
6b20: 28 63 74 20 30 29 29 0a 09 09 20 20 20 20 20 20  (ct 0))...      
6b30: 28 69 66 20 28 61 6e 64 20 28 6e 6f 74 20 74 73  (if (and (not ts
6b40: 29 0a 09 09 09 20 20 20 20 20 20 20 28 3c 20 63  )....       (< c
6b50: 74 20 31 30 29 29 0a 09 09 09 20 20 28 62 65 67  t 10))....  (beg
6b60: 69 6e 0a 09 09 09 20 20 20 20 28 72 65 67 69 73  in....    (regis
6b70: 74 65 72 2d 74 65 73 74 20 64 62 20 72 75 6e 2d  ter-test db run-
6b80: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65  id test-name ite
6b90: 6d 2d 70 61 74 68 29 0a 09 09 09 20 20 20 20 28  m-path)....    (
6ba0: 64 62 3a 74 65 73 74 2d 73 65 74 2d 63 6f 6d 6d  db:test-set-comm
6bb0: 65 6e 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65  ent db run-id te
6bc0: 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74  st-name item-pat
6bd0: 68 20 22 22 29 0a 09 09 09 20 20 20 20 28 6c 6f  h "")....    (lo
6be0: 6f 70 32 20 28 64 62 3a 67 65 74 2d 74 65 73 74  op2 (db:get-test
6bf0: 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64 20  -info db run-id 
6c00: 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70  test-name item-p
6c10: 61 74 68 29 0a 09 09 09 09 20 20 20 28 2b 20 63  ath).....   (+ c
6c20: 74 20 31 29 29 29 0a 09 09 09 20 20 28 69 66 20  t 1)))....  (if 
6c30: 74 73 0a 09 09 09 20 20 20 20 20 20 28 73 65 74  ts....      (set
6c40: 21 20 74 65 73 74 64 61 74 20 74 73 29 0a 09 09  ! testdat ts)...
6c50: 09 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09  .      (begin...
6c60: 09 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30  ..(debug:print 0
6c70: 20 22 57 41 52 4e 49 4e 47 3a 20 43 6f 75 6c 64   "WARNING: Could
6c80: 6e 27 74 20 72 65 67 69 73 74 65 72 20 74 65 73  n't register tes
6c90: 74 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20  t " test-name " 
6ca0: 77 69 74 68 20 69 74 65 6d 20 70 61 74 68 20 22  with item path "
6cb0: 20 69 74 65 6d 2d 70 61 74 68 20 22 2c 20 73 6b   item-path ", sk
6cc0: 69 70 70 69 6e 67 22 29 0a 09 09 09 09 28 69 66  ipping").....(if
6cd0: 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 61 6c   (not (null? tal
6ce0: 29 29 0a 09 09 09 09 20 20 20 20 28 6c 6f 6f 70  )).....    (loop
6cf0: 20 28 63 61 72 20 74 61 6c 29 28 63 64 72 20 74   (car tal)(cdr t
6d00: 61 6c 29 29 29 29 29 29 29 0a 09 09 20 20 20 20  al)))))))...    
6d10: 28 63 68 61 6e 67 65 2d 64 69 72 65 63 74 6f 72  (change-director
6d20: 79 20 74 65 73 74 2d 70 61 74 68 29 0a 09 09 20  y test-path)... 
6d30: 20 20 20 3b 3b 20 74 68 69 73 20 62 6c 6f 63 6b     ;; this block
6d40: 20 69 73 20 68 65 72 65 20 6f 6e 6c 79 20 74 6f   is here only to
6d50: 20 69 6e 66 6f 72 6d 20 74 68 65 20 75 73 65 72   inform the user
6d60: 20 65 61 72 6c 79 20 6f 6e 0a 09 09 20 20 20 20   early on...    
6d70: 28 69 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73  (if (file-exists
6d80: 3f 20 72 75 6e 63 6f 6e 66 69 67 66 29 0a 09 09  ? runconfigf)...
6d90: 09 28 73 65 74 75 70 2d 65 6e 76 2d 64 65 66 61  .(setup-env-defa
6da0: 75 6c 74 73 20 64 62 20 72 75 6e 63 6f 6e 66 69  ults db runconfi
6db0: 67 66 20 72 75 6e 2d 69 64 20 2a 61 6c 72 65 61  gf run-id *alrea
6dc0: 64 79 2d 73 65 65 6e 2d 72 75 6e 63 6f 6e 66 69  dy-seen-runconfi
6dd0: 67 2d 69 6e 66 6f 2a 29 0a 09 09 09 28 64 65 62  g-info*)....(deb
6de0: 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e  ug:print 0 "WARN
6df0: 49 4e 47 3a 20 59 6f 75 20 64 6f 20 6e 6f 74 20  ING: You do not 
6e00: 68 61 76 65 20 61 20 72 75 6e 20 63 6f 6e 66 69  have a run confi
6e10: 67 20 66 69 6c 65 3a 20 22 20 72 75 6e 63 6f 6e  g file: " runcon
6e20: 66 69 67 66 29 29 0a 09 09 20 20 20 20 28 64 65  figf))...    (de
6e30: 62 75 67 3a 70 72 69 6e 74 20 34 20 22 72 75 6e  bug:print 4 "run
6e40: 2d 69 64 3a 20 22 20 72 75 6e 2d 69 64 20 22 20  -id: " run-id " 
6e50: 74 65 73 74 2d 6e 61 6d 65 3a 20 22 20 74 65 73  test-name: " tes
6e60: 74 2d 6e 61 6d 65 20 22 20 69 74 65 6d 2d 70 61  t-name " item-pa
6e70: 74 68 3a 20 22 20 69 74 65 6d 2d 70 61 74 68 20  th: " item-path 
6e80: 22 20 74 65 73 74 64 61 74 3a 20 22 20 28 74 65  " testdat: " (te
6e90: 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65  st:get-status te
6ea0: 73 74 64 61 74 29 20 22 20 74 65 73 74 2d 73 74  stdat) " test-st
6eb0: 61 74 65 3a 20 22 20 28 74 65 73 74 3a 67 65 74  ate: " (test:get
6ec0: 2d 73 74 61 74 65 20 74 65 73 74 64 61 74 29 29  -state testdat))
6ed0: 0a 09 09 20 20 20 20 28 63 61 73 65 20 28 69 66  ...    (case (if
6ee0: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22   (args:get-arg "
6ef0: 2d 66 6f 72 63 65 22 29 0a 09 09 09 20 20 20 20  -force")....    
6f00: 20 20 27 4e 4f 54 5f 53 54 41 52 54 45 44 0a 09    'NOT_STARTED..
6f10: 09 09 20 20 20 20 20 20 28 69 66 20 74 65 73 74  ..      (if test
6f20: 64 61 74 0a 09 09 09 09 20 20 28 73 74 72 69 6e  dat.....  (strin
6f30: 67 2d 3e 73 79 6d 62 6f 6c 20 28 74 65 73 74 3a  g->symbol (test:
6f40: 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61  get-state testda
6f50: 74 29 29 0a 09 09 09 09 20 20 27 66 61 69 6c 65  t)).....  'faile
6f60: 64 2d 74 6f 2d 69 6e 73 65 72 74 29 29 0a 09 09  d-to-insert))...
6f70: 20 20 20 20 20 20 28 28 66 61 69 6c 65 64 2d 74        ((failed-t
6f80: 6f 2d 69 6e 73 65 72 74 29 0a 09 09 20 20 20 20  o-insert)...    
6f90: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
6fa0: 30 20 22 45 52 52 4f 52 3a 20 46 61 69 6c 65 64  0 "ERROR: Failed
6fb0: 20 74 6f 20 69 6e 73 65 72 74 20 74 68 65 20 72   to insert the r
6fc0: 65 63 6f 72 64 20 69 6e 74 6f 20 74 68 65 20 64  ecord into the d
6fd0: 62 22 29 29 0a 09 09 20 20 20 20 20 20 28 28 4e  b"))...      ((N
6fe0: 4f 54 5f 53 54 41 52 54 45 44 20 43 4f 4d 50 4c  OT_STARTED COMPL
6ff0: 45 54 45 44 29 0a 09 09 20 20 20 20 20 20 20 28  ETED)...       (
7000: 64 65 62 75 67 3a 70 72 69 6e 74 20 36 20 22 47  debug:print 6 "G
7010: 6f 74 20 68 65 72 65 2c 20 22 20 28 74 65 73 74  ot here, " (test
7020: 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64  :get-state testd
7030: 61 74 29 29 0a 09 09 20 20 20 20 20 20 20 28 6c  at))...       (l
7040: 65 74 20 28 28 72 75 6e 66 6c 61 67 20 23 66 29  et ((runflag #f)
7050: 29 0a 09 09 09 20 28 63 6f 6e 64 0a 09 09 09 20  ).... (cond.... 
7060: 20 3b 3b 20 69 2e 65 2e 20 74 68 69 73 20 69 73   ;; i.e. this is
7070: 20 74 68 65 20 70 61 72 65 6e 74 20 74 65 73 74   the parent test
7080: 20 74 6f 20 61 20 73 75 69 74 65 20 6f 66 20 69   to a suite of i
7090: 74 65 6d 73 2c 20 6e 65 76 65 72 20 22 72 75 6e  tems, never "run
70a0: 22 20 69 74 0a 09 09 09 20 20 28 70 61 72 65 6e  " it....  (paren
70b0: 74 2d 74 65 73 74 0a 09 09 09 20 20 20 28 73 65  t-test....   (se
70c0: 74 21 20 72 75 6e 66 6c 61 67 20 23 66 29 29 0a  t! runflag #f)).
70d0: 09 09 09 20 20 3b 3b 20 2d 66 6f 72 63 65 2c 20  ...  ;; -force, 
70e0: 72 75 6e 20 6e 6f 20 6d 61 74 74 65 72 20 77 68  run no matter wh
70f0: 61 74 0a 09 09 09 20 20 28 28 61 72 67 73 3a 67  at....  ((args:g
7100: 65 74 2d 61 72 67 20 22 2d 66 6f 72 63 65 22 29  et-arg "-force")
7110: 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 74  (set! runflag #t
7120: 29 29 0a 09 09 09 20 20 3b 3b 20 4e 4f 54 5f 53  ))....  ;; NOT_S
7130: 54 41 52 54 45 44 2c 20 72 75 6e 20 6e 6f 20 6d  TARTED, run no m
7140: 61 74 74 65 72 20 77 68 61 74 0a 09 09 09 20 20  atter what....  
7150: 28 28 65 71 75 61 6c 3f 20 28 74 65 73 74 3a 67  ((equal? (test:g
7160: 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 74  et-state testdat
7170: 29 20 22 4e 4f 54 5f 53 54 41 52 54 45 44 22 29  ) "NOT_STARTED")
7180: 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 74  (set! runflag #t
7190: 29 29 0a 09 09 09 20 20 3b 3b 20 6e 6f 74 20 2d  ))....  ;; not -
71a0: 72 65 72 75 6e 20 61 6e 64 20 50 41 53 53 2c 20  rerun and PASS, 
71b0: 57 41 52 4e 20 6f 72 20 43 48 45 43 4b 2c 20 64  WARN or CHECK, d
71c0: 6f 20 6e 6f 20 72 75 6e 0a 09 09 09 20 20 28 28  o no run....  ((
71d0: 61 6e 64 20 28 6f 72 20 28 6e 6f 74 20 28 61 72  and (or (not (ar
71e0: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65 72  gs:get-arg "-rer
71f0: 75 6e 22 29 29 0a 09 09 09 09 20 20 20 20 28 61  un")).....    (a
7200: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 6b 65  rgs:get-arg "-ke
7210: 65 70 67 6f 69 6e 67 22 29 29 0a 09 09 09 09 28  epgoing")).....(
7220: 6d 65 6d 62 65 72 20 28 74 65 73 74 3a 67 65 74  member (test:get
7230: 2d 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29  -status testdat)
7240: 20 27 28 22 50 41 53 53 22 20 22 57 41 52 4e 22   '("PASS" "WARN"
7250: 20 22 43 48 45 43 4b 22 29 29 29 0a 09 09 09 20   "CHECK"))).... 
7260: 20 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20    (set! runflag 
7270: 23 66 29 29 0a 09 09 09 20 20 3b 3b 20 2d 72 65  #f))....  ;; -re
7280: 72 75 6e 20 61 6e 64 20 73 74 61 74 75 73 20 69  run and status i
7290: 73 20 6f 6e 65 20 6f 66 20 74 68 65 20 73 70 65  s one of the spe
72a0: 63 69 66 65 64 2c 20 72 75 6e 20 69 74 0a 09 09  cifed, run it...
72b0: 09 20 20 28 28 61 6e 64 20 28 61 72 67 73 3a 67  .  ((and (args:g
72c0: 65 74 2d 61 72 67 20 22 2d 72 65 72 75 6e 22 29  et-arg "-rerun")
72d0: 0a 09 09 09 09 28 6c 65 74 20 28 28 72 65 72 75  .....(let ((reru
72e0: 6e 6c 73 74 20 28 73 74 72 69 6e 67 2d 73 70 6c  nlst (string-spl
72f0: 69 74 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67  it (args:get-arg
7300: 20 22 2d 72 65 72 75 6e 22 29 20 22 2c 22 29 29   "-rerun") ","))
7310: 29 20 3b 3b 20 46 41 49 4c 2c 0a 09 09 09 09 20  ) ;; FAIL,..... 
7320: 20 28 6d 65 6d 62 65 72 20 28 74 65 73 74 3a 67   (member (test:g
7330: 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61  et-status testda
7340: 74 29 20 72 65 72 75 6e 6c 73 74 29 29 29 0a 09  t) rerunlst)))..
7350: 09 09 20 20 20 28 73 65 74 21 20 72 75 6e 66 6c  ..   (set! runfl
7360: 61 67 20 23 74 29 29 0a 09 09 09 20 20 3b 3b 20  ag #t))....  ;; 
7370: 2d 6b 65 65 70 67 6f 69 6e 67 2c 20 64 6f 20 6e  -keepgoing, do n
7380: 6f 74 20 72 65 72 75 6e 20 46 41 49 4c 0a 09 09  ot rerun FAIL...
7390: 09 20 20 28 28 61 6e 64 20 28 61 72 67 73 3a 67  .  ((and (args:g
73a0: 65 74 2d 61 72 67 20 22 2d 6b 65 65 70 67 6f 69  et-arg "-keepgoi
73b0: 6e 67 22 29 0a 09 09 09 09 28 6d 65 6d 62 65 72  ng").....(member
73c0: 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75   (test:get-statu
73d0: 73 20 74 65 73 74 64 61 74 29 20 27 28 22 46 41  s testdat) '("FA
73e0: 49 4c 22 29 29 29 0a 09 09 09 20 20 20 28 73 65  IL")))....   (se
73f0: 74 21 20 72 75 6e 66 6c 61 67 20 23 66 29 29 0a  t! runflag #f)).
7400: 09 09 09 20 20 28 28 61 6e 64 20 28 6e 6f 74 20  ...  ((and (not 
7410: 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d  (args:get-arg "-
7420: 72 65 72 75 6e 22 29 29 0a 09 09 09 09 28 6d 65  rerun")).....(me
7430: 6d 62 65 72 20 28 74 65 73 74 3a 67 65 74 2d 73  mber (test:get-s
7440: 74 61 74 75 73 20 74 65 73 74 64 61 74 29 20 27  tatus testdat) '
7450: 28 22 46 41 49 4c 22 20 22 6e 2f 61 22 29 29 29  ("FAIL" "n/a")))
7460: 0a 09 09 09 20 20 20 28 73 65 74 21 20 72 75 6e  ....   (set! run
7470: 66 6c 61 67 20 23 74 29 29 0a 09 09 09 20 20 28  flag #t))....  (
7480: 65 6c 73 65 20 28 73 65 74 21 20 72 75 6e 66 6c  else (set! runfl
7490: 61 67 20 23 66 29 29 29 0a 09 09 09 20 28 64 65  ag #f))).... (de
74a0: 62 75 67 3a 70 72 69 6e 74 20 36 20 22 52 55 4e  bug:print 6 "RUN
74b0: 4e 49 4e 47 20 3d 3e 20 72 75 6e 66 6c 61 67 3a  NING => runflag:
74c0: 20 22 20 72 75 6e 66 6c 61 67 20 22 20 53 54 41   " runflag " STA
74d0: 54 45 3a 20 22 20 28 74 65 73 74 3a 67 65 74 2d  TE: " (test:get-
74e0: 73 74 61 74 65 20 74 65 73 74 64 61 74 29 20 22  state testdat) "
74f0: 20 53 54 41 54 55 53 3a 20 22 20 28 74 65 73 74   STATUS: " (test
7500: 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74  :get-status test
7510: 64 61 74 29 29 0a 09 09 09 20 28 69 66 20 28 6e  dat)).... (if (n
7520: 6f 74 20 72 75 6e 66 6c 61 67 29 0a 09 09 09 20  ot runflag).... 
7530: 20 20 20 20 28 69 66 20 28 6e 6f 74 20 70 61 72      (if (not par
7540: 65 6e 74 2d 74 65 73 74 29 0a 09 09 09 09 20 28  ent-test)..... (
7550: 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 4e  debug:print 1 "N
7560: 4f 54 45 3a 20 4e 6f 74 20 73 74 61 72 74 69 6e  OTE: Not startin
7570: 67 20 74 65 73 74 20 22 20 6e 65 77 2d 74 65 73  g test " new-tes
7580: 74 2d 6e 61 6d 65 20 22 20 61 73 20 69 74 20 69  t-name " as it i
7590: 73 20 73 74 61 74 65 20 5c 22 43 4f 4d 50 4c 45  s state \"COMPLE
75a0: 54 45 44 5c 22 20 61 6e 64 20 73 74 61 74 75 73  TED\" and status
75b0: 20 5c 22 22 20 28 74 65 73 74 3a 67 65 74 2d 73   \"" (test:get-s
75c0: 74 61 74 75 73 20 74 65 73 74 64 61 74 29 20 22  tatus testdat) "
75d0: 5c 22 2c 20 75 73 65 20 2d 66 6f 72 63 65 20 74  \", use -force t
75e0: 6f 20 6f 76 65 72 72 69 64 65 22 29 29 0a 09 09  o override"))...
75f0: 09 20 20 20 20 20 28 6c 65 74 2a 20 28 28 67 65  .     (let* ((ge
7600: 74 2d 70 72 65 72 65 71 73 2d 63 6d 64 20 28 6c  t-prereqs-cmd (l
7610: 61 6d 62 64 61 20 28 29 0a 09 09 09 09 09 09 20  ambda ()....... 
7620: 20 20 20 20 20 20 28 64 62 2d 67 65 74 2d 70 72        (db-get-pr
7630: 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 20 64 62  ereqs-not-met db
7640: 20 72 75 6e 2d 69 64 20 77 61 69 74 6f 6e 29 29   run-id waiton))
7650: 29 20 3b 3b 20 63 68 65 63 6b 20 62 65 66 6f 72  ) ;; check befor
7660: 65 20 72 75 6e 6e 69 6e 67 20 2e 2e 2e 2e 0a 09  e running ......
7670: 09 09 09 20 20 20 20 28 6c 61 75 6e 63 68 2d 63  ...    (launch-c
7680: 6d 64 20 20 20 20 20 20 28 6c 61 6d 62 64 61 20  md      (lambda 
7690: 28 29 0a 09 09 09 09 09 09 20 20 20 20 20 20 20  ().......       
76a0: 28 6c 61 75 6e 63 68 2d 74 65 73 74 20 64 62 20  (launch-test db 
76b0: 72 75 6e 2d 69 64 20 74 65 73 74 2d 63 6f 6e 66  run-id test-conf
76c0: 20 6b 65 79 76 61 6c 6c 73 74 20 74 65 73 74 2d   keyvallst test-
76d0: 6e 61 6d 65 20 74 65 73 74 2d 70 61 74 68 20 69  name test-path i
76e0: 74 65 6d 64 61 74 29 29 29 0a 09 09 09 09 20 20  temdat))).....  
76f0: 20 20 28 74 65 73 74 72 75 6e 64 61 74 20 20 20    (testrundat   
7700: 20 20 20 28 6c 69 73 74 20 67 65 74 2d 70 72 65     (list get-pre
7710: 72 65 71 73 2d 63 6d 64 20 6c 61 75 6e 63 68 2d  reqs-cmd launch-
7720: 63 6d 64 29 29 29 0a 09 09 09 20 20 20 20 20 20  cmd)))....      
7730: 20 28 69 66 20 28 6f 72 20 28 61 72 67 73 3a 67   (if (or (args:g
7740: 65 74 2d 61 72 67 20 22 2d 66 6f 72 63 65 22 29  et-arg "-force")
7750: 0a 09 09 09 09 20 20 20 20 20 20 20 28 6c 65 74  .....       (let
7760: 20 28 28 70 72 65 71 73 2d 6e 6f 74 2d 79 65 74   ((preqs-not-yet
7770: 2d 6d 65 74 20 28 28 63 61 72 20 74 65 73 74 72  -met ((car testr
7780: 75 6e 64 61 74 29 29 29 29 0a 09 09 09 09 09 20  undat))))...... 
7790: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22  (debug:print 2 "
77a0: 50 72 65 71 72 65 71 75 65 73 69 74 65 73 20 66  Preqrequesites f
77b0: 6f 72 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22  or " test-name "
77c0: 3a 20 22 20 70 72 65 71 73 2d 6e 6f 74 2d 79 65  : " preqs-not-ye
77d0: 74 2d 6d 65 74 29 0a 09 09 09 09 09 20 28 6e 75  t-met)...... (nu
77e0: 6c 6c 3f 20 70 72 65 71 73 2d 6e 6f 74 2d 79 65  ll? preqs-not-ye
77f0: 74 2d 6d 65 74 29 29 29 20 3b 3b 20 61 72 65 20  t-met))) ;; are 
7800: 74 68 65 72 65 20 61 6e 79 20 74 65 73 74 73 20  there any tests 
7810: 74 68 61 74 20 6d 75 73 74 20 62 65 20 72 75 6e  that must be run
7820: 20 62 65 66 6f 72 65 20 74 68 69 73 20 6f 6e 65   before this one
7830: 2e 2e 2e 0a 09 09 09 09 20 20 20 28 69 66 20 28  ........   (if (
7840: 6e 6f 74 20 28 28 63 61 64 72 20 74 65 73 74 72  not ((cadr testr
7850: 75 6e 64 61 74 29 29 29 20 3b 3b 20 74 68 69 73  undat))) ;; this
7860: 20 69 73 20 74 68 65 20 6c 69 6e 65 20 74 68 61   is the line tha
7870: 74 20 6c 61 75 6e 63 68 65 73 20 74 68 65 20 74  t launches the t
7880: 65 73 74 20 74 6f 20 74 68 65 20 72 65 6d 6f 74  est to the remot
7890: 65 20 68 6f 73 74 0a 09 09 09 09 20 20 20 20 20  e host.....     
78a0: 20 20 28 62 65 67 69 6e 0a 09 09 09 09 09 20 28    (begin...... (
78b0: 70 72 69 6e 74 20 22 45 52 52 4f 52 3a 20 46 61  print "ERROR: Fa
78c0: 69 6c 65 64 20 74 6f 20 6c 61 75 6e 63 68 20 74  iled to launch t
78d0: 68 65 20 74 65 73 74 2e 20 45 78 69 74 69 6e 67  he test. Exiting
78e0: 20 61 73 20 73 6f 6f 6e 20 61 73 20 70 6f 73 73   as soon as poss
78f0: 69 62 6c 65 22 29 0a 09 09 09 09 09 20 28 73 65  ible")...... (se
7900: 74 21 20 2a 67 6c 6f 62 61 6c 65 78 69 74 73 74  t! *globalexitst
7910: 61 74 75 73 2a 20 31 29 20 3b 3b 20 0a 09 09 09  atus* 1) ;; ....
7920: 09 09 20 28 70 72 6f 63 65 73 73 2d 73 69 67 6e  .. (process-sign
7930: 61 6c 20 28 63 75 72 72 65 6e 74 2d 70 72 6f 63  al (current-proc
7940: 65 73 73 2d 69 64 29 20 73 69 67 6e 61 6c 2f 6b  ess-id) signal/k
7950: 69 6c 6c 29 0a 09 09 09 09 09 20 3b 28 65 78 69  ill)...... ;(exi
7960: 74 20 31 29 0a 09 09 09 09 09 20 29 29 0a 09 09  t 1)...... ))...
7970: 09 09 20 20 20 28 69 66 20 28 6e 6f 74 20 28 61  ..   (if (not (a
7980: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 6b 65  rgs:get-arg "-ke
7990: 65 70 67 6f 69 6e 67 22 29 29 0a 09 09 09 09 20  epgoing"))..... 
79a0: 20 20 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c        (hash-tabl
79b0: 65 2d 73 65 74 21 20 2a 77 61 69 74 69 6e 67 2d  e-set! *waiting-
79c0: 71 75 65 75 65 2a 20 6e 65 77 2d 74 65 73 74 2d  queue* new-test-
79d0: 6e 61 6d 65 20 74 65 73 74 72 75 6e 64 61 74 29  name testrundat)
79e0: 29 29 29 29 29 29 0a 09 09 20 20 20 20 20 20 28  ))))))...      (
79f0: 28 4b 49 4c 4c 45 44 29 20 0a 09 09 20 20 20 20  (KILLED) ...    
7a00: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
7a10: 31 20 22 4e 4f 54 45 3a 20 22 20 6e 65 77 2d 74  1 "NOTE: " new-t
7a20: 65 73 74 2d 6e 61 6d 65 20 22 20 69 73 20 61 6c  est-name " is al
7a30: 72 65 61 64 79 20 72 75 6e 6e 69 6e 67 20 6f 72  ready running or
7a40: 20 77 61 73 20 65 78 70 6c 69 63 74 6c 79 20 6b   was explictly k
7a50: 69 6c 6c 65 64 2c 20 75 73 65 20 2d 66 6f 72 63  illed, use -forc
7a60: 65 20 74 6f 20 6c 61 75 6e 63 68 20 69 74 2e 22  e to launch it."
7a70: 29 29 0a 09 09 20 20 20 20 20 20 28 28 4c 41 55  ))...      ((LAU
7a80: 4e 43 48 45 44 20 52 45 4d 4f 54 45 48 4f 53 54  NCHED REMOTEHOST
7a90: 53 54 41 52 54 20 52 55 4e 4e 49 4e 47 29 20 20  START RUNNING)  
7aa0: 0a 09 09 20 20 20 20 20 20 20 28 69 66 20 28 3e  ...       (if (>
7ab0: 20 28 2d 20 28 63 75 72 72 65 6e 74 2d 73 65 63   (- (current-sec
7ac0: 6f 6e 64 73 29 28 2b 20 28 64 62 3a 74 65 73 74  onds)(+ (db:test
7ad0: 2d 67 65 74 2d 65 76 65 6e 74 5f 74 69 6d 65 20  -get-event_time 
7ae0: 74 65 73 74 64 61 74 29 0a 09 09 09 09 09 09 20  testdat)....... 
7af0: 20 20 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74      (db:test-get
7b00: 2d 72 75 6e 5f 64 75 72 61 74 69 6f 6e 20 74 65  -run_duration te
7b10: 73 74 64 61 74 29 29 29 0a 09 09 09 20 20 20 20  stdat)))....    
7b20: 20 20 31 30 30 29 20 3b 3b 20 69 2e 65 2e 20 6e    100) ;; i.e. n
7b30: 6f 20 75 70 64 61 74 65 20 66 6f 72 20 6d 6f 72  o update for mor
7b40: 65 20 74 68 61 6e 20 31 30 30 20 73 65 63 6f 6e  e than 100 secon
7b50: 64 73 0a 09 09 09 20 20 20 28 62 65 67 69 6e 0a  ds....   (begin.
7b60: 09 09 09 20 20 20 20 20 28 64 65 62 75 67 3a 70  ...     (debug:p
7b70: 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e 47 3a  rint 0 "WARNING:
7b80: 20 54 65 73 74 20 22 20 74 65 73 74 2d 6e 61 6d   Test " test-nam
7b90: 65 20 22 20 61 70 70 65 61 72 73 20 74 6f 20 62  e " appears to b
7ba0: 65 20 64 65 61 64 2e 20 46 6f 72 63 69 6e 67 20  e dead. Forcing 
7bb0: 69 74 20 74 6f 20 73 74 61 74 65 20 49 4e 43 4f  it to state INCO
7bc0: 4d 50 4c 45 54 45 20 61 6e 64 20 73 74 61 74 75  MPLETE and statu
7bd0: 73 20 53 54 55 43 4b 2f 44 45 41 44 22 29 0a 09  s STUCK/DEAD")..
7be0: 09 09 20 20 20 20 20 28 74 65 73 74 2d 73 65 74  ..     (test-set
7bf0: 2d 73 74 61 74 75 73 21 20 64 62 20 72 75 6e 2d  -status! db run-
7c00: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 22 49 4e  id test-name "IN
7c10: 43 4f 4d 50 4c 45 54 45 22 20 22 53 54 55 43 4b  COMPLETE" "STUCK
7c20: 2f 44 45 41 44 22 20 69 74 65 6d 64 61 74 20 22  /DEAD" itemdat "
7c30: 54 65 73 74 20 69 73 20 73 74 75 63 6b 20 6f 72  Test is stuck or
7c40: 20 64 65 61 64 22 20 23 66 29 29 0a 09 09 09 20   dead" #f)).... 
7c50: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32    (debug:print 2
7c60: 20 22 4e 4f 54 45 3a 20 22 20 74 65 73 74 2d 6e   "NOTE: " test-n
7c70: 61 6d 65 20 22 20 69 73 20 61 6c 72 65 61 64 79  ame " is already
7c80: 20 72 75 6e 6e 69 6e 67 22 29 29 29 0a 09 09 20   running")))... 
7c90: 20 20 20 20 20 28 65 6c 73 65 20 20 20 20 20 20       (else      
7ca0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
7cb0: 22 45 52 52 4f 52 3a 20 46 61 69 6c 65 64 20 74  "ERROR: Failed t
7cc0: 6f 20 6c 61 75 6e 63 68 20 74 65 73 74 20 22 20  o launch test " 
7cd0: 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20 22 2e  new-test-name ".
7ce0: 20 55 6e 72 65 63 6f 67 6e 69 73 65 64 20 73 74   Unrecognised st
7cf0: 61 74 65 20 22 20 28 74 65 73 74 3a 67 65 74 2d  ate " (test:get-
7d00: 73 74 61 74 65 20 74 65 73 74 64 61 74 29 29 29  state testdat)))
7d10: 29 29 29 0a 09 20 20 20 20 20 20 28 69 66 20 28  )))..      (if (
7d20: 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 61 6c 29 29  not (null? tal))
7d30: 0a 09 09 20 20 28 6c 6f 6f 70 20 28 63 61 72 20  ...  (loop (car 
7d40: 74 61 6c 29 28 63 64 72 20 74 61 6c 29 29 29 29  tal)(cdr tal))))
7d50: 29 29 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28  )))))..(define (
7d60: 72 75 6e 2d 77 61 69 74 69 6e 67 2d 74 65 73 74  run-waiting-test
7d70: 73 20 64 62 29 0a 20 20 28 6c 65 74 20 28 28 6e  s db).  (let ((n
7d80: 75 6d 74 72 69 65 73 20 20 20 20 20 20 20 20 20  umtries         
7d90: 20 20 30 29 0a 09 28 6c 61 73 74 2d 74 72 79 2d    0)..(last-try-
7da0: 74 69 6d 65 20 20 20 20 20 20 28 63 75 72 72 65  time      (curre
7db0: 6e 74 2d 73 65 63 6f 6e 64 73 29 29 0a 09 28 74  nt-seconds))..(t
7dc0: 69 6d 65 73 20 20 20 20 20 20 20 20 20 20 20 20  imes            
7dd0: 20 20 28 6c 69 73 74 20 31 29 29 29 20 3b 3b 20    (list 1))) ;; 
7de0: 6d 69 6e 75 74 65 73 20 74 6f 20 77 61 69 74 20  minutes to wait 
7df0: 62 65 66 6f 72 65 20 74 72 79 69 6e 67 20 61 67  before trying ag
7e00: 61 69 6e 20 74 6f 20 6b 69 63 6b 20 6f 66 66 20  ain to kick off 
7e10: 72 75 6e 73 0a 20 20 20 20 3b 3b 20 42 55 47 20  runs.    ;; BUG 
7e20: 74 68 69 73 20 68 61 63 6b 20 6f 66 20 62 72 75  this hack of bru
7e30: 74 65 20 66 6f 72 63 65 20 72 65 74 72 79 69 6e  te force retryin
7e40: 67 20 77 6f 72 6b 73 20 71 75 69 74 65 20 77 65  g works quite we
7e50: 6c 6c 20 66 6f 72 20 6d 61 6e 79 20 63 61 73 65  ll for many case
7e60: 73 20 62 75 74 20 0a 20 20 20 20 3b 3b 20 20 20  s but .    ;;   
7e70: 20 20 77 68 61 74 20 69 73 20 6e 65 65 64 65 64    what is needed
7e80: 20 69 73 20 74 6f 20 63 68 65 63 6b 20 74 68 65   is to check the
7e90: 20 64 62 20 66 6f 72 20 74 65 73 74 73 20 74 68   db for tests th
7ea0: 61 74 20 68 61 76 65 20 66 61 69 6c 65 64 20 6c  at have failed l
7eb0: 65 73 73 20 74 68 61 6e 0a 20 20 20 20 3b 3b 20  ess than.    ;; 
7ec0: 20 20 20 20 4e 20 74 69 6d 65 73 20 6f 72 20 6e      N times or n
7ed0: 65 76 65 72 20 62 65 65 6e 20 73 74 61 72 74 65  ever been starte
7ee0: 64 20 61 6e 64 20 6b 69 63 6b 20 74 68 65 6d 20  d and kick them 
7ef0: 6f 66 66 20 61 67 61 69 6e 0a 20 20 20 20 28 6c  off again.    (l
7f00: 65 74 20 6c 6f 6f 70 20 28 28 77 61 69 74 69 6e  et loop ((waitin
7f10: 67 2d 74 65 73 74 2d 6e 61 6d 65 73 20 28 68 61  g-test-names (ha
7f20: 73 68 2d 74 61 62 6c 65 2d 6b 65 79 73 20 2a 77  sh-table-keys *w
7f30: 61 69 74 69 6e 67 2d 71 75 65 75 65 2a 29 29 29  aiting-queue*)))
7f40: 0a 20 20 20 20 20 20 28 63 6f 6e 64 0a 20 20 20  .      (cond.   
7f50: 20 20 20 20 28 28 6e 6f 74 20 28 72 75 6e 73 3a      ((not (runs:
7f60: 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65 73  can-run-more-tes
7f70: 74 73 20 64 62 29 29 0a 09 28 73 6c 65 65 70 20  ts db))..(sleep 
7f80: 32 29 0a 09 28 6c 6f 6f 70 20 77 61 69 74 69 6e  2)..(loop waitin
7f90: 67 2d 74 65 73 74 2d 6e 61 6d 65 73 29 29 0a 20  g-test-names)). 
7fa0: 20 20 20 20 20 20 28 28 6e 75 6c 6c 3f 20 77 61        ((null? wa
7fb0: 69 74 69 6e 67 2d 74 65 73 74 2d 6e 61 6d 65 73  iting-test-names
7fc0: 29 0a 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20  )..(debug:print 
7fd0: 31 20 22 41 6c 6c 20 74 65 73 74 73 20 6c 61 75  1 "All tests lau
7fe0: 6e 63 68 65 64 22 29 29 0a 20 20 20 20 20 20 20  nched")).       
7ff0: 28 65 6c 73 65 0a 09 28 73 65 74 21 20 6e 75 6d  (else..(set! num
8000: 74 72 69 65 73 20 28 2b 20 6e 75 6d 74 72 69 65  tries (+ numtrie
8010: 73 20 31 29 29 0a 09 28 66 6f 72 2d 65 61 63 68  s 1))..(for-each
8020: 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74 6e 61   (lambda (testna
8030: 6d 65 29 0a 09 09 20 20 20 20 28 69 66 20 28 72  me)...    (if (r
8040: 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65  uns:can-run-more
8050: 2d 74 65 73 74 73 20 64 62 29 0a 09 09 09 28 6c  -tests db)....(l
8060: 65 74 2a 20 28 28 74 65 73 74 64 61 74 20 28 68  et* ((testdat (h
8070: 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 20 2a 77  ash-table-ref *w
8080: 61 69 74 69 6e 67 2d 71 75 65 75 65 2a 20 74 65  aiting-queue* te
8090: 73 74 6e 61 6d 65 29 29 0a 09 09 09 20 20 20 20  stname))....    
80a0: 20 20 20 28 70 72 65 72 65 71 73 20 28 28 63 61     (prereqs ((ca
80b0: 72 20 74 65 73 74 64 61 74 29 29 29 0a 09 09 09  r testdat)))....
80c0: 20 20 20 20 20 20 20 28 6c 64 62 20 20 20 20 20         (ldb     
80d0: 28 69 66 20 64 62 20 64 62 20 28 6f 70 65 6e 2d  (if db db (open-
80e0: 64 62 29 29 29 29 0a 09 09 09 20 20 28 64 65 62  db))))....  (deb
80f0: 75 67 3a 70 72 69 6e 74 20 32 20 22 70 72 65 72  ug:print 2 "prer
8100: 65 71 73 20 72 65 6d 61 69 6e 69 6e 67 3a 20 22  eqs remaining: "
8110: 20 70 72 65 72 65 71 73 29 0a 09 09 09 20 20 28   prereqs)....  (
8120: 69 66 20 28 6e 75 6c 6c 3f 20 70 72 65 72 65 71  if (null? prereq
8130: 73 29 0a 09 09 09 20 20 20 20 20 20 28 62 65 67  s)....      (beg
8140: 69 6e 0a 09 09 09 09 28 64 65 62 75 67 3a 70 72  in.....(debug:pr
8150: 69 6e 74 20 32 20 22 50 72 65 72 65 71 75 69 73  int 2 "Prerequis
8160: 69 74 65 73 20 6d 65 74 2c 20 6c 61 75 6e 63 68  ites met, launch
8170: 69 6e 67 20 22 20 74 65 73 74 6e 61 6d 65 29 0a  ing " testname).
8180: 09 09 09 09 28 28 63 61 64 72 20 74 65 73 74 64  ....((cadr testd
8190: 61 74 29 29 0a 09 09 09 09 28 68 61 73 68 2d 74  at)).....(hash-t
81a0: 61 62 6c 65 2d 64 65 6c 65 74 65 21 20 2a 77 61  able-delete! *wa
81b0: 69 74 69 6e 67 2d 71 75 65 75 65 2a 20 74 65 73  iting-queue* tes
81c0: 74 6e 61 6d 65 29 29 29 0a 09 09 09 20 20 28 69  tname)))....  (i
81d0: 66 20 28 6e 6f 74 20 64 62 29 0a 09 09 09 20 20  f (not db)....  
81e0: 20 20 20 20 28 73 71 6c 69 74 65 33 3a 66 69 6e      (sqlite3:fin
81f0: 61 6c 69 7a 65 21 20 6c 64 62 29 29 29 29 29 0a  alize! ldb))))).
8200: 09 09 20 20 77 61 69 74 69 6e 67 2d 74 65 73 74  ..  waiting-test
8210: 2d 6e 61 6d 65 73 29 0a 09 3b 3b 20 28 73 6c 65  -names)..;; (sle
8220: 65 70 20 31 30 29 20 3b 3b 20 6e 6f 20 70 6f 69  ep 10) ;; no poi
8230: 6e 74 20 69 6e 20 72 75 73 68 69 6e 67 20 74 68  nt in rushing th
8240: 69 6e 67 73 20 61 74 20 74 68 69 73 20 73 74 61  ings at this sta
8250: 67 65 3f 0a 09 28 6c 6f 6f 70 20 28 68 61 73 68  ge?..(loop (hash
8260: 2d 74 61 62 6c 65 2d 6b 65 79 73 20 2a 77 61 69  -table-keys *wai
8270: 74 69 6e 67 2d 71 75 65 75 65 2a 29 29 29 29 29  ting-queue*)))))
8280: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 67 65 74  ))..(define (get
8290: 2d 64 69 72 2d 75 70 2d 6e 20 64 69 72 20 2e 20  -dir-up-n dir . 
82a0: 70 61 72 61 6d 73 29 20 0a 20 20 28 6c 65 74 20  params) .  (let 
82b0: 28 28 64 70 61 72 74 73 20 20 28 73 74 72 69 6e  ((dparts  (strin
82c0: 67 2d 73 70 6c 69 74 20 64 69 72 20 22 2f 22 29  g-split dir "/")
82d0: 29 0a 09 28 63 6f 75 6e 74 20 20 20 28 69 66 20  )..(count   (if 
82e0: 28 6e 75 6c 6c 3f 20 70 61 72 61 6d 73 29 20 31  (null? params) 1
82f0: 20 28 63 61 72 20 70 61 72 61 6d 73 29 29 29 29   (car params))))
8300: 0a 20 20 20 20 28 63 6f 6e 63 20 22 2f 22 20 28  .    (conc "/" (
8310: 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72  string-intersper
8320: 73 65 20 0a 09 20 20 20 20 20 20 20 28 74 61 6b  se ..       (tak
8330: 65 20 64 70 61 72 74 73 20 28 2d 20 28 6c 65 6e  e dparts (- (len
8340: 67 74 68 20 64 70 61 72 74 73 29 20 63 6f 75 6e  gth dparts) coun
8350: 74 29 29 0a 09 20 20 20 20 20 20 20 22 2f 22 29  t))..       "/")
8360: 29 29 29 0a 3b 3b 20 52 65 6d 6f 76 65 20 72 75  ))).;; Remove ru
8370: 6e 73 0a 3b 3b 20 66 69 65 6c 64 73 20 61 72 65  ns.;; fields are
8380: 20 70 61 73 73 69 6e 67 20 69 6e 20 74 68 72 6f   passing in thro
8390: 75 67 68 20 0a 28 64 65 66 69 6e 65 20 28 72 75  ugh .(define (ru
83a0: 6e 73 3a 72 65 6d 6f 76 65 2d 72 75 6e 73 20 64  ns:remove-runs d
83b0: 62 20 72 75 6e 6e 61 6d 65 70 61 74 74 20 74 65  b runnamepatt te
83c0: 73 74 70 61 74 74 20 69 74 65 6d 70 61 74 74 29  stpatt itempatt)
83d0: 0a 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 73 20  .  (let* ((keys 
83e0: 20 20 20 20 20 20 20 28 64 62 2d 67 65 74 2d 6b         (db-get-k
83f0: 65 79 73 20 64 62 29 29 0a 09 20 28 72 75 6e 64  eys db)).. (rund
8400: 61 74 20 20 20 20 20 20 28 72 75 6e 73 3a 67 65  at      (runs:ge
8410: 74 2d 72 75 6e 73 2d 62 79 2d 70 61 74 74 20 64  t-runs-by-patt d
8420: 62 20 6b 65 79 73 20 72 75 6e 6e 61 6d 65 70 61  b keys runnamepa
8430: 74 74 29 29 0a 09 20 28 68 65 61 64 65 72 20 20  tt)).. (header  
8440: 20 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20      (vector-ref 
8450: 72 75 6e 64 61 74 20 30 29 29 0a 09 20 28 72 75  rundat 0)).. (ru
8460: 6e 73 20 20 20 20 20 20 20 20 28 76 65 63 74 6f  ns        (vecto
8470: 72 2d 72 65 66 20 72 75 6e 64 61 74 20 31 29 29  r-ref rundat 1))
8480: 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72 69  ).    (debug:pri
8490: 6e 74 20 31 20 22 48 65 61 64 65 72 3a 20 22 20  nt 1 "Header: " 
84a0: 68 65 61 64 65 72 29 0a 20 20 20 20 28 66 6f 72  header).    (for
84b0: 2d 65 61 63 68 0a 20 20 20 20 20 28 6c 61 6d 62  -each.     (lamb
84c0: 64 61 20 28 72 75 6e 29 0a 20 20 20 20 20 20 20  da (run).       
84d0: 28 6c 65 74 20 28 28 72 75 6e 6b 65 79 20 28 73  (let ((runkey (s
84e0: 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73  tring-interspers
84f0: 65 20 28 6d 61 70 20 28 6c 61 6d 62 64 61 20 28  e (map (lambda (
8500: 6b 29 0a 09 09 09 09 09 09 28 64 62 3a 67 65 74  k).......(db:get
8510: 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72  -value-by-header
8520: 20 72 75 6e 20 68 65 61 64 65 72 20 28 76 65 63   run header (vec
8530: 74 6f 72 2d 72 65 66 20 6b 20 30 29 29 29 20 6b  tor-ref k 0))) k
8540: 65 79 73 29 20 22 2f 22 29 29 0a 09 20 20 20 20  eys) "/"))..    
8550: 20 28 64 69 72 73 2d 74 6f 2d 72 65 6d 6f 76 65   (dirs-to-remove
8560: 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c   (make-hash-tabl
8570: 65 29 29 29 0a 09 20 28 6c 65 74 2a 20 28 28 72  e))).. (let* ((r
8580: 75 6e 2d 69 64 20 28 64 62 3a 67 65 74 2d 76 61  un-id (db:get-va
8590: 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75  lue-by-header ru
85a0: 6e 20 68 65 61 64 65 72 20 22 69 64 22 29 20 29  n header "id") )
85b0: 0a 09 09 28 74 65 73 74 73 20 20 28 64 62 2d 67  ...(tests  (db-g
85c0: 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d 72 75 6e  et-tests-for-run
85d0: 20 64 62 20 28 64 62 3a 67 65 74 2d 76 61 6c 75   db (db:get-valu
85e0: 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20  e-by-header run 
85f0: 68 65 61 64 65 72 20 22 69 64 22 29 20 74 65 73  header "id") tes
8600: 74 70 61 74 74 20 69 74 65 6d 70 61 74 74 29 29  tpatt itempatt))
8610: 0a 09 09 28 6c 61 73 74 74 70 61 74 68 20 22 2f  ...(lasttpath "/
8620: 64 6f 65 73 2f 6e 6f 74 2f 65 78 69 73 74 2f 49  does/not/exist/I
8630: 2f 68 6f 70 65 22 29 29 0a 0a 09 20 20 20 28 69  /hope"))...   (i
8640: 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 65  f (not (null? te
8650: 73 74 73 29 29 0a 09 20 20 20 20 20 20 20 28 62  sts))..       (b
8660: 65 67 69 6e 0a 09 09 20 28 64 65 62 75 67 3a 70  egin... (debug:p
8670: 72 69 6e 74 20 31 20 22 52 65 6d 6f 76 69 6e 67  rint 1 "Removing
8680: 20 74 65 73 74 73 20 66 6f 72 20 72 75 6e 3a 20   tests for run: 
8690: 22 20 72 75 6e 6b 65 79 20 22 20 22 20 28 64 62  " runkey " " (db
86a0: 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65  :get-value-by-he
86b0: 61 64 65 72 20 72 75 6e 20 68 65 61 64 65 72 20  ader run header 
86c0: 22 72 75 6e 6e 61 6d 65 22 29 29 0a 09 09 20 28  "runname"))... (
86d0: 66 6f 72 2d 65 61 63 68 0a 09 09 20 20 28 6c 61  for-each...  (la
86e0: 6d 62 64 61 20 28 74 65 73 74 29 0a 09 09 20 20  mbda (test)...  
86f0: 20 20 28 6c 65 74 2a 20 28 28 69 74 65 6d 2d 70    (let* ((item-p
8700: 61 74 68 20 28 64 62 3a 74 65 73 74 2d 67 65 74  ath (db:test-get
8710: 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 29  -item-path test)
8720: 29 0a 09 09 09 20 20 20 28 74 65 73 74 2d 6e 61  )....   (test-na
8730: 6d 65 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  me (db:test-get-
8740: 74 65 73 74 6e 61 6d 65 20 74 65 73 74 29 29 0a  testname test)).
8750: 09 09 09 20 20 20 28 72 75 6e 2d 64 69 72 20 20  ...   (run-dir  
8760: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 72 75   (db:test-get-ru
8770: 6e 64 69 72 20 74 65 73 74 29 29 29 0a 09 09 20  ndir test)))... 
8780: 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e       (debug:prin
8790: 74 20 31 20 22 20 20 22 20 28 64 62 3a 74 65 73  t 1 "  " (db:tes
87a0: 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 74  t-get-testname t
87b0: 65 73 74 29 20 22 20 69 64 3a 20 22 20 28 64 62  est) " id: " (db
87c0: 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73  :test-get-id tes
87d0: 74 29 20 22 20 22 20 69 74 65 6d 2d 70 61 74 68  t) " " item-path
87e0: 29 0a 09 09 20 20 20 20 20 20 28 64 62 3a 64 65  )...      (db:de
87f0: 6c 65 74 65 2d 74 65 73 74 2d 72 65 63 6f 72 64  lete-test-record
8800: 73 20 64 62 20 28 64 62 3a 74 65 73 74 2d 67 65  s db (db:test-ge
8810: 74 2d 69 64 20 74 65 73 74 29 29 0a 09 09 20 20  t-id test))...  
8820: 20 20 20 20 28 69 66 20 28 3e 20 28 73 74 72 69      (if (> (stri
8830: 6e 67 2d 6c 65 6e 67 74 68 20 72 75 6e 2d 64 69  ng-length run-di
8840: 72 29 20 35 29 20 3b 3b 20 62 61 64 20 68 65 75  r) 5) ;; bad heu
8850: 72 69 73 74 69 63 20 62 75 74 20 73 68 6f 75 6c  ristic but shoul
8860: 64 20 70 72 65 76 65 6e 74 20 2f 74 6d 70 20 2f  d prevent /tmp /
8870: 68 6f 6d 65 20 65 74 63 2e 0a 09 09 09 20 20 28  home etc.....  (
8880: 6c 65 74 20 28 28 66 75 6c 6c 70 61 74 68 20 72  let ((fullpath r
8890: 75 6e 2d 64 69 72 29 29 20 3b 3b 20 22 2f 22 20  un-dir)) ;; "/" 
88a0: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65  (db:test-get-ite
88b0: 6d 2d 70 61 74 68 20 74 65 73 74 29 29 29 29 0a  m-path test)))).
88c0: 09 09 09 20 20 20 20 28 73 65 74 21 20 6c 61 73  ...    (set! las
88d0: 74 74 70 61 74 68 20 66 75 6c 6c 70 61 74 68 29  ttpath fullpath)
88e0: 0a 09 09 09 20 20 20 20 28 68 61 73 68 2d 74 61  ....    (hash-ta
88f0: 62 6c 65 2d 73 65 74 21 20 64 69 72 73 2d 74 6f  ble-set! dirs-to
8900: 2d 72 65 6d 6f 76 65 20 66 75 6c 6c 70 61 74 68  -remove fullpath
8910: 20 23 74 29 0a 09 09 09 20 20 20 20 3b 3b 20 54   #t)....    ;; T
8920: 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 77 61 73  he following was
8930: 20 74 68 65 20 73 61 66 65 20 64 65 6c 65 74 65   the safe delete
8940: 20 63 6f 64 65 20 62 75 74 20 69 74 20 77 61 73   code but it was
8950: 20 6e 6f 74 20 62 65 69 6e 67 20 65 78 65 63 74   not being exect
8960: 75 74 65 64 2e 0a 09 09 09 20 20 20 20 3b 3b 20  uted.....    ;; 
8970: 28 6c 65 74 2a 20 28 28 64 69 72 73 2d 63 6f 75  (let* ((dirs-cou
8980: 6e 74 20 28 2b 20 31 20 28 6c 65 6e 67 74 68 20  nt (+ 1 (length 
8990: 6b 65 79 73 29 28 6c 65 6e 67 74 68 20 28 73 74  keys)(length (st
89a0: 72 69 6e 67 2d 73 70 6c 69 74 20 69 74 65 6d 2d  ring-split item-
89b0: 70 61 74 68 20 22 2f 22 29 29 29 29 0a 09 09 09  path "/"))))....
89c0: 20 20 20 20 3b 3b 20 20 20 20 20 20 20 20 28 64      ;;        (d
89d0: 69 72 2d 74 6f 2d 72 65 6d 20 28 67 65 74 2d 64  ir-to-rem (get-d
89e0: 69 72 2d 75 70 2d 6e 20 66 75 6c 6c 70 61 74 68  ir-up-n fullpath
89f0: 20 64 69 72 73 2d 63 6f 75 6e 74 29 29 0a 09 09   dirs-count))...
8a00: 09 20 20 20 20 3b 3b 20 20 20 20 20 20 20 20 28  .    ;;        (
8a10: 72 65 6d 61 69 6e 69 6e 67 64 20 28 73 74 72 69  remainingd (stri
8a20: 6e 67 2d 73 75 62 73 74 69 74 75 74 65 20 28 72  ng-substitute (r
8a30: 65 67 65 78 70 20 28 63 6f 6e 63 20 22 5e 22 20  egexp (conc "^" 
8a40: 64 69 72 2d 74 6f 2d 72 65 6d 20 22 2f 22 29 29  dir-to-rem "/"))
8a50: 20 22 22 20 66 75 6c 6c 70 61 74 68 29 29 0a 09   "" fullpath))..
8a60: 09 09 20 20 20 20 3b 3b 20 20 20 20 20 20 20 20  ..    ;;        
8a70: 28 63 6d 64 20 28 63 6f 6e 63 20 22 63 64 20 22  (cmd (conc "cd "
8a80: 20 64 69 72 2d 74 6f 2d 72 65 6d 20 22 3b 20 72   dir-to-rem "; r
8a90: 6d 64 69 72 20 2d 70 20 22 20 72 65 6d 61 69 6e  mdir -p " remain
8aa0: 69 6e 67 64 20 29 29 29 0a 09 09 09 20 20 20 20  ingd )))....    
8ab0: 3b 3b 20 20 20 28 69 66 20 28 66 69 6c 65 2d 65  ;;   (if (file-e
8ac0: 78 69 73 74 73 3f 20 66 75 6c 6c 70 61 74 68 29  xists? fullpath)
8ad0: 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20 20  ....    ;;      
8ae0: 20 28 62 65 67 69 6e 0a 09 09 09 20 20 20 20 3b   (begin....    ;
8af0: 3b 20 20 20 20 20 20 20 20 20 28 64 65 62 75 67  ;         (debug
8b00: 3a 70 72 69 6e 74 20 31 20 63 6d 64 29 0a 09 09  :print 1 cmd)...
8b10: 09 20 20 20 20 3b 3b 20 20 20 20 20 20 20 20 20  .    ;;         
8b20: 28 73 79 73 74 65 6d 20 63 6d 64 29 29 29 0a 09  (system cmd)))..
8b30: 09 09 20 20 20 20 3b 3b 20 20 20 29 29 0a 09 09  ..    ;;   ))...
8b40: 09 20 20 20 20 29 29 29 29 0a 09 09 20 20 20 20  .    ))))...    
8b50: 74 65 73 74 73 29 29 29 0a 0a 09 20 20 20 3b 3b  tests)))...   ;;
8b60: 20 6c 6f 6f 6b 20 74 68 6f 75 67 68 20 74 68 65   look though the
8b70: 20 64 69 72 73 2d 74 6f 2d 72 65 6d 6f 76 65 20   dirs-to-remove 
8b80: 66 6f 72 20 63 61 6e 64 69 64 61 74 65 73 20 66  for candidates f
8b90: 6f 72 20 72 65 6d 6f 76 61 6c 2e 20 44 6f 20 74  or removal. Do t
8ba0: 68 69 73 20 61 66 74 65 72 20 64 65 6c 65 74 69  his after deleti
8bb0: 6e 67 20 74 68 65 20 72 65 63 6f 72 64 73 0a 09  ng the records..
8bc0: 20 20 20 3b 3b 20 66 6f 72 20 65 61 63 68 20 74     ;; for each t
8bd0: 65 73 74 20 69 6e 20 63 61 73 65 20 77 65 20 67  est in case we g
8be0: 65 74 20 6b 69 6c 6c 65 64 2e 20 54 68 61 74 20  et killed. That 
8bf0: 73 68 6f 75 6c 64 20 6d 69 6e 69 6d 69 7a 65 20  should minimize 
8c00: 74 68 65 20 64 65 74 72 69 74 75 73 20 6c 65 66  the detritus lef
8c10: 74 20 6f 6e 20 64 69 73 6b 0a 09 20 20 20 3b 3b  t on disk..   ;;
8c20: 20 70 72 6f 63 65 73 73 20 74 68 65 20 64 69 72   process the dir
8c30: 73 20 66 72 6f 6d 20 6c 6f 6e 67 65 73 74 20 73  s from longest s
8c40: 74 72 69 6e 67 20 6c 65 6e 67 74 68 20 74 6f 20  tring length to 
8c50: 73 68 6f 72 74 65 73 74 0a 09 20 20 20 28 66 6f  shortest..   (fo
8c60: 72 2d 65 61 63 68 20 0a 09 20 20 20 20 28 6c 61  r-each ..    (la
8c70: 6d 62 64 61 20 28 64 69 72 2d 74 6f 2d 72 65 6d  mbda (dir-to-rem
8c80: 6f 76 65 29 0a 09 20 20 20 20 20 20 28 69 66 20  ove)..      (if 
8c90: 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 64 69  (file-exists? di
8ca0: 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 0a 09 09 20  r-to-remove)... 
8cb0: 20 28 6c 65 74 20 28 28 64 69 72 2d 69 6e 2d 64   (let ((dir-in-d
8cc0: 62 20 27 28 29 29 29 0a 09 09 20 20 20 20 28 73  b '()))...    (s
8cd0: 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d  qlite3:for-each-
8ce0: 72 6f 77 0a 09 09 20 20 20 20 20 28 6c 61 6d 62  row...     (lamb
8cf0: 64 61 20 28 64 69 72 29 0a 09 09 20 20 20 20 20  da (dir)...     
8d00: 20 20 28 73 65 74 21 20 64 69 72 2d 69 6e 2d 64    (set! dir-in-d
8d10: 62 20 28 63 6f 6e 73 20 64 69 72 20 64 69 72 2d  b (cons dir dir-
8d20: 69 6e 2d 64 62 29 29 29 0a 09 09 20 20 20 20 20  in-db)))...     
8d30: 64 62 20 22 53 45 4c 45 43 54 20 72 75 6e 64 69  db "SELECT rundi
8d40: 72 20 46 52 4f 4d 20 74 65 73 74 73 20 57 48 45  r FROM tests WHE
8d50: 52 45 20 72 75 6e 64 69 72 20 4c 49 4b 45 20 3f  RE rundir LIKE ?
8d60: 3b 22 20 0a 09 09 20 20 20 20 20 28 63 6f 6e 63  ;" ...     (conc
8d70: 20 22 25 22 20 64 69 72 2d 74 6f 2d 72 65 6d 6f   "%" dir-to-remo
8d80: 76 65 20 22 25 22 29 29 20 3b 3b 20 79 65 73 2c  ve "%")) ;; yes,
8d90: 20 49 27 6d 20 67 6f 69 6e 67 20 74 6f 20 62 61   I'm going to ba
8da0: 69 6c 20 69 66 20 74 68 65 72 65 20 69 73 20 61  il if there is a
8db0: 6e 79 74 68 69 6e 67 20 6c 69 6b 65 20 74 68 69  nything like thi
8dc0: 73 20 64 69 72 20 69 6e 20 74 68 65 20 64 62 0a  s dir in the db.
8dd0: 09 09 20 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f  ..    (if (null?
8de0: 20 64 69 72 2d 69 6e 2d 64 62 29 0a 09 09 09 28   dir-in-db)....(
8df0: 62 65 67 69 6e 0a 09 09 09 20 20 28 64 65 62 75  begin....  (debu
8e00: 67 3a 70 72 69 6e 74 20 32 20 22 52 65 6d 6f 76  g:print 2 "Remov
8e10: 69 6e 67 20 64 69 72 65 63 74 6f 72 79 20 77 69  ing directory wi
8e20: 74 68 20 7a 65 72 6f 20 64 62 20 72 65 66 65 72  th zero db refer
8e30: 65 6e 63 65 73 3a 20 22 20 64 69 72 2d 74 6f 2d  ences: " dir-to-
8e40: 72 65 6d 6f 76 65 29 0a 09 09 09 20 20 28 73 79  remove)....  (sy
8e50: 73 74 65 6d 20 28 63 6f 6e 63 20 22 72 6d 20 2d  stem (conc "rm -
8e60: 72 66 20 22 20 64 69 72 2d 74 6f 2d 72 65 6d 6f  rf " dir-to-remo
8e70: 76 65 29 29 0a 09 09 09 20 20 28 68 61 73 68 2d  ve))....  (hash-
8e80: 74 61 62 6c 65 2d 64 65 6c 65 74 65 21 20 64 69  table-delete! di
8e90: 72 73 2d 74 6f 2d 72 65 6d 6f 76 65 20 64 69 72  rs-to-remove dir
8ea0: 2d 74 6f 2d 72 65 6d 6f 76 65 29 29 0a 09 09 09  -to-remove))....
8eb0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22  (debug:print 2 "
8ec0: 53 6b 69 70 70 69 6e 67 20 72 65 6d 6f 76 61 6c  Skipping removal
8ed0: 20 6f 66 20 22 20 64 69 72 2d 74 6f 2d 72 65 6d   of " dir-to-rem
8ee0: 6f 76 65 20 22 20 66 6f 72 20 6e 6f 77 20 61 73  ove " for now as
8ef0: 20 69 74 20 73 74 69 6c 6c 20 68 61 73 20 72 65   it still has re
8f00: 66 65 72 65 6e 63 65 73 20 69 6e 20 74 68 65 20  ferences in the 
8f10: 64 61 74 61 62 61 73 65 22 29 29 29 29 29 0a 09  database")))))..
8f20: 20 20 20 20 28 73 6f 72 74 20 28 68 61 73 68 2d      (sort (hash-
8f30: 74 61 62 6c 65 2d 6b 65 79 73 20 64 69 72 73 2d  table-keys dirs-
8f40: 74 6f 2d 72 65 6d 6f 76 65 29 20 28 6c 61 6d 62  to-remove) (lamb
8f50: 64 61 20 28 61 20 62 29 28 3e 20 28 73 74 72 69  da (a b)(> (stri
8f60: 6e 67 2d 6c 65 6e 67 74 68 20 61 29 28 73 74 72  ng-length a)(str
8f70: 69 6e 67 2d 6c 65 6e 67 74 68 20 62 29 29 29 29  ing-length b))))
8f80: 29 0a 0a 09 20 20 20 3b 3b 20 72 65 6d 6f 76 65  )...   ;; remove
8f90: 20 74 68 65 20 72 75 6e 20 69 66 20 7a 65 72 6f   the run if zero
8fa0: 20 74 65 73 74 73 20 72 65 6d 61 69 6e 0a 09 20   tests remain.. 
8fb0: 20 20 28 6c 65 74 20 28 28 72 65 6d 74 65 73 74    (let ((remtest
8fc0: 73 20 28 64 62 2d 67 65 74 2d 74 65 73 74 73 2d  s (db-get-tests-
8fd0: 66 6f 72 2d 72 75 6e 20 64 62 20 28 64 62 3a 67  for-run db (db:g
8fe0: 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64  et-value-by-head
8ff0: 65 72 20 72 75 6e 20 68 65 61 64 65 72 20 22 69  er run header "i
9000: 64 22 29 29 29 29 0a 09 20 20 20 20 20 28 69 66  d"))))..     (if
9010: 20 28 6e 75 6c 6c 3f 20 72 65 6d 74 65 73 74 73   (null? remtests
9020: 29 20 3b 3b 20 6e 6f 20 6d 6f 72 65 20 74 65 73  ) ;; no more tes
9030: 74 73 20 72 65 6d 61 69 6e 69 6e 67 0a 09 09 20  ts remaining... 
9040: 28 6c 65 74 2a 20 28 28 64 70 61 72 74 73 20 20  (let* ((dparts  
9050: 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 6c 61  (string-split la
9060: 73 74 74 70 61 74 68 20 22 2f 22 29 29 0a 09 09  sttpath "/"))...
9070: 09 28 72 75 6e 70 61 74 68 20 28 63 6f 6e 63 20  .(runpath (conc 
9080: 22 2f 22 20 28 73 74 72 69 6e 67 2d 69 6e 74 65  "/" (string-inte
9090: 72 73 70 65 72 73 65 20 0a 09 09 09 09 09 20 20  rsperse ......  
90a0: 20 20 28 74 61 6b 65 20 64 70 61 72 74 73 20 28    (take dparts (
90b0: 2d 20 28 6c 65 6e 67 74 68 20 64 70 61 72 74 73  - (length dparts
90c0: 29 20 31 29 29 0a 09 09 09 09 09 20 20 20 20 22  ) 1))......    "
90d0: 2f 22 29 29 29 29 0a 09 09 20 20 20 28 64 65 62  /"))))...   (deb
90e0: 75 67 3a 70 72 69 6e 74 20 31 20 22 52 65 6d 6f  ug:print 1 "Remo
90f0: 76 69 6e 67 20 72 75 6e 3a 20 22 20 72 75 6e 6b  ving run: " runk
9100: 65 79 20 22 20 22 20 28 64 62 3a 67 65 74 2d 76  ey " " (db:get-v
9110: 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72  alue-by-header r
9120: 75 6e 20 68 65 61 64 65 72 20 22 72 75 6e 6e 61  un header "runna
9130: 6d 65 22 29 29 0a 09 09 20 20 20 28 64 62 3a 64  me"))...   (db:d
9140: 65 6c 65 74 65 2d 72 75 6e 20 64 62 20 72 75 6e  elete-run db run
9150: 2d 69 64 29 0a 09 09 20 20 20 3b 3b 20 6e 65 65  -id)...   ;; nee
9160: 64 20 74 6f 20 66 69 67 75 72 65 20 6f 75 74 20  d to figure out 
9170: 74 68 65 20 70 61 74 68 20 74 6f 20 74 68 65 20  the path to the 
9180: 72 75 6e 20 64 69 72 20 61 6e 64 20 72 65 6d 6f  run dir and remo
9190: 76 65 20 69 74 20 69 66 20 65 6d 70 74 79 0a 09  ve it if empty..
91a0: 09 20 20 20 3b 3b 20 20 20 20 28 69 66 20 28 6e  .   ;;    (if (n
91b0: 75 6c 6c 3f 20 28 67 6c 6f 62 20 28 63 6f 6e 63  ull? (glob (conc
91c0: 20 72 75 6e 70 61 74 68 20 22 2f 2a 22 29 29 29   runpath "/*")))
91d0: 0a 09 09 20 20 20 3b 3b 20 20 20 20 20 20 20 20  ...   ;;        
91e0: 28 62 65 67 69 6e 0a 09 09 20 20 20 3b 3b 20 09  (begin...   ;; .
91f0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20   (debug:print 1 
9200: 22 52 65 6d 6f 76 69 6e 67 20 72 75 6e 20 64 69  "Removing run di
9210: 72 20 22 20 72 75 6e 70 61 74 68 29 0a 09 09 20  r " runpath)... 
9220: 20 20 3b 3b 20 09 20 28 73 79 73 74 65 6d 20 28    ;; . (system (
9230: 63 6f 6e 63 20 22 72 6d 64 69 72 20 2d 70 20 22  conc "rmdir -p "
9240: 20 72 75 6e 70 61 74 68 29 29 29 29 0a 09 09 20   runpath))))... 
9250: 20 20 29 29 29 29 0a 09 20 29 29 0a 20 20 20 20    )))).. )).    
9260: 20 72 75 6e 73 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d   runs)))..;;====
9270: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9280: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9290: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
92a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
92b0: 3d 3d 0a 3b 3b 20 52 6f 75 74 69 6e 65 73 20 66  ==.;; Routines f
92c0: 6f 72 20 6d 61 6e 69 70 75 6c 61 74 69 6e 67 20  or manipulating 
92d0: 72 75 6e 73 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d  runs.;;=========
92e0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
92f0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9300: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9310: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b  =============..;
9320: 3b 20 53 69 6e 63 65 20 6d 61 6e 79 20 63 61 6c  ; Since many cal
9330: 6c 73 20 74 6f 20 61 20 72 75 6e 20 72 65 71 75  ls to a run requ
9340: 69 72 65 20 70 72 65 74 74 79 20 6d 75 63 68 20  ire pretty much 
9350: 74 68 65 20 73 61 6d 65 20 73 65 74 75 70 20 0a  the same setup .
9360: 3b 3b 20 74 68 69 73 20 77 72 61 70 70 65 72 20  ;; this wrapper 
9370: 69 73 20 75 73 65 64 20 74 6f 20 72 65 64 75 63  is used to reduc
9380: 65 20 74 68 65 20 72 65 70 6c 69 63 61 74 69 6f  e the replicatio
9390: 6e 20 6f 66 20 63 6f 64 65 0a 28 64 65 66 69 6e  n of code.(defin
93a0: 65 20 28 67 65 6e 65 72 61 6c 2d 72 75 6e 2d 63  e (general-run-c
93b0: 61 6c 6c 20 73 77 69 74 63 68 6e 61 6d 65 20 61  all switchname a
93c0: 63 74 69 6f 6e 2d 64 65 73 63 20 70 72 6f 63 29  ction-desc proc)
93d0: 0a 20 20 28 69 66 20 28 6e 6f 74 20 28 61 72 67  .  (if (not (arg
93e0: 73 3a 67 65 74 2d 61 72 67 20 22 3a 72 75 6e 6e  s:get-arg ":runn
93f0: 61 6d 65 22 29 29 0a 20 20 20 20 20 20 28 62 65  ame")).      (be
9400: 67 69 6e 0a 09 28 64 65 62 75 67 3a 70 72 69 6e  gin..(debug:prin
9410: 74 20 30 20 22 45 52 52 4f 52 3a 20 4d 69 73 73  t 0 "ERROR: Miss
9420: 69 6e 67 20 72 65 71 75 69 72 65 64 20 70 61 72  ing required par
9430: 61 6d 65 74 65 72 20 66 6f 72 20 22 20 73 77 69  ameter for " swi
9440: 74 63 68 6e 61 6d 65 20 22 2c 20 79 6f 75 20 6d  tchname ", you m
9450: 75 73 74 20 73 70 65 63 69 66 79 20 74 68 65 20  ust specify the 
9460: 72 75 6e 20 6e 61 6d 65 20 77 69 74 68 20 3a 72  run name with :r
9470: 75 6e 6e 61 6d 65 20 72 75 6e 6e 61 6d 65 22 29  unname runname")
9480: 0a 09 28 65 78 69 74 20 32 29 29 0a 20 20 20 20  ..(exit 2)).    
9490: 20 20 28 6c 65 74 20 28 28 64 62 20 23 66 29 29    (let ((db #f))
94a0: 0a 09 28 69 66 20 28 6e 6f 74 20 28 73 65 74 75  ..(if (not (setu
94b0: 70 2d 66 6f 72 2d 72 75 6e 29 29 0a 09 20 20 20  p-for-run))..   
94c0: 20 28 62 65 67 69 6e 20 0a 09 20 20 20 20 20 20   (begin ..      
94d0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
94e0: 46 61 69 6c 65 64 20 74 6f 20 73 65 74 75 70 2c  Failed to setup,
94f0: 20 65 78 69 74 69 6e 67 22 29 0a 09 20 20 20 20   exiting")..    
9500: 20 20 28 65 78 69 74 20 31 29 29 29 0a 09 28 73    (exit 1)))..(s
9510: 65 74 21 20 64 62 20 28 6f 70 65 6e 2d 64 62 29  et! db (open-db)
9520: 29 0a 09 28 69 66 20 28 6e 6f 74 20 28 63 61 72  )..(if (not (car
9530: 20 2a 63 6f 6e 66 69 67 69 6e 66 6f 2a 29 29 0a   *configinfo*)).
9540: 09 20 20 20 20 28 62 65 67 69 6e 0a 09 20 20 20  .    (begin..   
9550: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
9560: 30 20 22 45 52 52 4f 52 3a 20 41 74 74 65 6d 70  0 "ERROR: Attemp
9570: 74 65 64 20 74 6f 20 22 20 61 63 74 69 6f 6e 2d  ted to " action-
9580: 64 65 73 63 20 22 20 62 75 74 20 72 75 6e 20 61  desc " but run a
9590: 72 65 61 20 63 6f 6e 66 69 67 20 66 69 6c 65 20  rea config file 
95a0: 6e 6f 74 20 66 6f 75 6e 64 22 29 0a 09 20 20 20  not found")..   
95b0: 20 20 20 28 65 78 69 74 20 31 29 29 0a 09 20 20     (exit 1))..  
95c0: 20 20 3b 3b 20 45 78 74 72 61 63 74 20 6f 75 74    ;; Extract out
95d0: 20 73 74 75 66 66 20 6e 65 65 64 65 64 20 69 6e   stuff needed in
95e0: 20 6d 6f 73 74 20 6f 72 20 6d 61 6e 79 20 63 61   most or many ca
95f0: 6c 6c 73 0a 09 20 20 20 20 3b 3b 20 68 65 72 65  lls..    ;; here
9600: 20 74 68 65 6e 20 63 61 6c 6c 20 70 72 6f 63 0a   then call proc.
9610: 09 20 20 20 20 28 6c 65 74 2a 20 28 28 6b 65 79  .    (let* ((key
9620: 73 20 20 20 20 20 20 20 28 64 62 2d 67 65 74 2d  s       (db-get-
9630: 6b 65 79 73 20 64 62 29 29 0a 09 09 20 20 20 28  keys db))...   (
9640: 6b 65 79 6e 61 6d 65 73 20 20 20 28 6d 61 70 20  keynames   (map 
9650: 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64 6e 61 6d  key:get-fieldnam
9660: 65 20 6b 65 79 73 29 29 0a 09 09 20 20 20 28 6b  e keys))...   (k
9670: 65 79 76 61 6c 6c 73 74 20 20 28 6b 65 79 73 2d  eyvallst  (keys-
9680: 3e 76 61 6c 6c 69 73 74 20 6b 65 79 73 20 23 74  >vallist keys #t
9690: 29 29 29 0a 09 20 20 20 20 20 20 28 70 72 6f 63  )))..      (proc
96a0: 20 64 62 20 6b 65 79 73 20 6b 65 79 6e 61 6d 65   db keys keyname
96b0: 73 20 6b 65 79 76 61 6c 6c 73 74 29 29 29 0a 09  s keyvallst)))..
96c0: 28 73 71 6c 69 74 65 33 3a 66 69 6e 61 6c 69 7a  (sqlite3:finaliz
96d0: 65 21 20 64 62 29 0a 09 28 73 65 74 21 20 2a 64  e! db)..(set! *d
96e0: 69 64 73 6f 6d 65 74 68 69 6e 67 2a 20 23 74 29  idsomething* #t)
96f0: 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d  )))..;;=========
9700: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9710: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9720: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9730: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b  =============.;;
9740: 20 52 6f 6c 6c 75 70 20 72 75 6e 73 0a 3b 3b 3d   Rollup runs.;;=
9750: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9760: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9770: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9780: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9790: 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 55 70 64 61 74 65  =====..;; Update
97a0: 20 74 68 65 20 74 65 73 74 5f 6d 65 74 61 20 74   the test_meta t
97b0: 61 62 6c 65 20 66 6f 72 20 74 68 69 73 20 74 65  able for this te
97c0: 73 74 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73  st.(define (runs
97d0: 3a 75 70 64 61 74 65 2d 74 65 73 74 5f 6d 65 74  :update-test_met
97e0: 61 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 20 74  a db test-name t
97f0: 65 73 74 2d 63 6f 6e 66 29 0a 20 20 28 6c 65 74  est-conf).  (let
9800: 20 28 28 63 75 72 72 72 65 63 6f 72 64 20 28 64   ((currrecord (d
9810: 62 3a 74 65 73 74 6d 65 74 61 2d 67 65 74 2d 72  b:testmeta-get-r
9820: 65 63 6f 72 64 20 64 62 20 74 65 73 74 2d 6e 61  ecord db test-na
9830: 6d 65 29 29 29 0a 20 20 20 20 28 69 66 20 28 6e  me))).    (if (n
9840: 6f 74 20 63 75 72 72 72 65 63 6f 72 64 29 0a 09  ot currrecord)..
9850: 28 62 65 67 69 6e 0a 09 20 20 28 73 65 74 21 20  (begin..  (set! 
9860: 63 75 72 72 72 65 63 6f 72 64 20 28 6d 61 6b 65  currrecord (make
9870: 2d 76 65 63 74 6f 72 20 31 30 20 23 66 29 29 0a  -vector 10 #f)).
9880: 09 20 20 28 64 62 3a 74 65 73 74 6d 65 74 61 2d  .  (db:testmeta-
9890: 61 64 64 2d 72 65 63 6f 72 64 20 64 62 20 74 65  add-record db te
98a0: 73 74 2d 6e 61 6d 65 29 29 29 0a 20 20 20 20 28  st-name))).    (
98b0: 66 6f 72 2d 65 61 63 68 20 0a 20 20 20 20 20 28  for-each .     (
98c0: 6c 61 6d 62 64 61 20 28 6b 65 79 29 0a 20 20 20  lambda (key).   
98d0: 20 20 20 20 28 6c 65 74 2a 20 28 28 69 64 78 20      (let* ((idx 
98e0: 28 63 61 64 72 20 6b 65 79 29 29 0a 09 20 20 20  (cadr key))..   
98f0: 20 20 20 28 66 6c 64 20 28 63 61 72 20 20 6b 65     (fld (car  ke
9900: 79 29 29 0a 09 20 20 20 20 20 20 28 76 61 6c 20  y))..      (val 
9910: 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 74  (config-lookup t
9920: 65 73 74 2d 63 6f 6e 66 20 22 74 65 73 74 5f 6d  est-conf "test_m
9930: 65 74 61 22 20 66 6c 64 29 29 29 0a 09 20 28 69  eta" fld))).. (i
9940: 66 20 28 61 6e 64 20 76 61 6c 20 28 6e 6f 74 20  f (and val (not 
9950: 28 65 71 75 61 6c 3f 20 28 76 65 63 74 6f 72 2d  (equal? (vector-
9960: 72 65 66 20 63 75 72 72 72 65 63 6f 72 64 20 69  ref currrecord i
9970: 64 78 29 20 76 61 6c 29 29 29 0a 09 20 20 20 20  dx) val)))..    
9980: 20 28 62 65 67 69 6e 0a 09 20 20 20 20 20 20 20   (begin..       
9990: 28 70 72 69 6e 74 20 22 55 70 64 61 74 69 6e 67  (print "Updating
99a0: 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 22   " test-name " "
99b0: 20 66 6c 64 20 22 20 74 6f 20 22 20 76 61 6c 29   fld " to " val)
99c0: 0a 09 20 20 20 20 20 20 20 28 64 62 3a 74 65 73  ..       (db:tes
99d0: 74 6d 65 74 61 2d 75 70 64 61 74 65 2d 66 69 65  tmeta-update-fie
99e0: 6c 64 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 20  ld db test-name 
99f0: 66 6c 64 20 76 61 6c 29 29 29 29 29 0a 20 20 20  fld val))))).   
9a00: 20 20 27 28 28 22 61 75 74 68 6f 72 22 20 32 29    '(("author" 2)
9a10: 28 22 6f 77 6e 65 72 22 20 33 29 28 22 64 65 73  ("owner" 3)("des
9a20: 63 72 69 70 74 69 6f 6e 22 20 34 29 28 22 72 65  cription" 4)("re
9a30: 76 69 65 77 65 64 22 20 35 29 28 22 74 61 67 73  viewed" 5)("tags
9a40: 22 20 39 29 29 29 29 29 0a 0a 3b 3b 20 55 70 64  " 9)))))..;; Upd
9a50: 61 74 65 20 74 65 73 74 5f 6d 65 74 61 20 66 6f  ate test_meta fo
9a60: 72 20 61 6c 6c 20 74 65 73 74 73 0a 28 64 65 66  r all tests.(def
9a70: 69 6e 65 20 28 72 75 6e 73 3a 75 70 64 61 74 65  ine (runs:update
9a80: 2d 61 6c 6c 2d 74 65 73 74 5f 6d 65 74 61 20 64  -all-test_meta d
9a90: 62 29 0a 20 20 28 6c 65 74 20 28 28 74 65 73 74  b).  (let ((test
9aa0: 2d 6e 61 6d 65 73 20 28 67 65 74 2d 61 6c 6c 2d  -names (get-all-
9ab0: 6c 65 67 61 6c 2d 74 65 73 74 73 29 29 29 0a 20  legal-tests))). 
9ac0: 20 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 20     (for-each .  
9ad0: 20 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74     (lambda (test
9ae0: 2d 6e 61 6d 65 29 0a 20 20 20 20 20 20 20 28 6c  -name).       (l
9af0: 65 74 2a 20 28 28 74 65 73 74 2d 70 61 74 68 20  et* ((test-path 
9b00: 20 20 20 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74     (conc *toppat
9b10: 68 2a 20 22 2f 74 65 73 74 73 2f 22 20 74 65 73  h* "/tests/" tes
9b20: 74 2d 6e 61 6d 65 29 29 0a 09 20 20 20 20 20 20  t-name))..      
9b30: 28 74 65 73 74 2d 63 6f 6e 66 69 67 66 20 28 63  (test-configf (c
9b40: 6f 6e 63 20 74 65 73 74 2d 70 61 74 68 20 22 2f  onc test-path "/
9b50: 74 65 73 74 63 6f 6e 66 69 67 22 29 29 0a 09 20  testconfig")).. 
9b60: 20 20 20 20 20 28 74 65 73 74 65 78 69 73 74 73       (testexists
9b70: 20 20 20 28 61 6e 64 20 28 66 69 6c 65 2d 65 78     (and (file-ex
9b80: 69 73 74 73 3f 20 74 65 73 74 2d 63 6f 6e 66 69  ists? test-confi
9b90: 67 66 29 28 66 69 6c 65 2d 72 65 61 64 2d 61 63  gf)(file-read-ac
9ba0: 63 65 73 73 3f 20 74 65 73 74 2d 63 6f 6e 66 69  cess? test-confi
9bb0: 67 66 29 29 29 0a 09 20 20 20 20 20 20 3b 3b 20  gf)))..      ;; 
9bc0: 72 65 61 64 20 63 6f 6e 66 69 67 73 20 77 69 74  read configs wit
9bd0: 68 20 74 72 69 63 6b 73 20 74 75 72 6e 65 64 20  h tricks turned 
9be0: 6f 66 66 20 28 69 2e 65 2e 20 6e 6f 20 73 79 73  off (i.e. no sys
9bf0: 74 65 6d 29 0a 09 20 20 20 20 20 20 28 74 65 73  tem)..      (tes
9c00: 74 2d 63 6f 6e 66 20 20 20 20 28 69 66 20 74 65  t-conf    (if te
9c10: 73 74 65 78 69 73 74 73 20 28 72 65 61 64 2d 63  stexists (read-c
9c20: 6f 6e 66 69 67 20 74 65 73 74 2d 63 6f 6e 66 69  onfig test-confi
9c30: 67 66 20 23 66 20 23 66 29 28 6d 61 6b 65 2d 68  gf #f #f)(make-h
9c40: 61 73 68 2d 74 61 62 6c 65 29 29 29 29 0a 09 20  ash-table)))).. 
9c50: 28 72 75 6e 73 3a 75 70 64 61 74 65 2d 74 65 73  (runs:update-tes
9c60: 74 5f 6d 65 74 61 20 64 62 20 74 65 73 74 2d 6e  t_meta db test-n
9c70: 61 6d 65 20 74 65 73 74 2d 63 6f 6e 66 29 29 29  ame test-conf)))
9c80: 0a 20 20 20 20 20 74 65 73 74 2d 6e 61 6d 65 73  .     test-names
9c90: 29 29 29 0a 09 20 0a 3b 3b 20 54 68 69 73 20 63  ))).. .;; This c
9ca0: 6f 75 6c 64 20 70 72 6f 62 61 62 6c 79 20 62 65  ould probably be
9cb0: 20 72 65 66 61 63 74 6f 72 65 64 20 69 6e 74 6f   refactored into
9cc0: 20 6f 6e 65 20 63 6f 6d 70 6c 65 78 20 71 75 65   one complex que
9cd0: 72 79 20 2e 2e 2e 0a 28 64 65 66 69 6e 65 20 28  ry ....(define (
9ce0: 72 75 6e 73 3a 72 6f 6c 6c 75 70 2d 72 75 6e 20  runs:rollup-run 
9cf0: 64 62 20 6b 65 79 73 29 0a 20 20 28 6c 65 74 2a  db keys).  (let*
9d00: 20 28 28 6e 65 77 2d 72 75 6e 2d 69 64 20 20 20   ((new-run-id   
9d10: 20 20 20 28 72 65 67 69 73 74 65 72 2d 72 75 6e     (register-run
9d20: 20 64 62 20 6b 65 79 73 29 29 0a 09 20 28 70 72   db keys)).. (pr
9d30: 65 76 2d 74 65 73 74 73 20 20 20 20 20 20 28 74  ev-tests      (t
9d40: 65 73 74 3a 67 65 74 2d 6d 61 74 63 68 69 6e 67  est:get-matching
9d50: 2d 70 72 65 76 69 6f 75 73 2d 74 65 73 74 2d 72  -previous-test-r
9d60: 75 6e 2d 72 65 63 6f 72 64 73 20 64 62 20 6e 65  un-records db ne
9d70: 77 2d 72 75 6e 2d 69 64 20 22 25 22 20 22 25 22  w-run-id "%" "%"
9d80: 29 29 0a 09 20 28 63 75 72 72 2d 74 65 73 74 73  )).. (curr-tests
9d90: 20 20 20 20 20 20 28 64 62 2d 67 65 74 2d 74 65        (db-get-te
9da0: 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 6e  sts-for-run db n
9db0: 65 77 2d 72 75 6e 2d 69 64 20 22 25 22 20 22 25  ew-run-id "%" "%
9dc0: 22 29 29 0a 09 20 28 63 75 72 72 2d 74 65 73 74  ")).. (curr-test
9dd0: 73 2d 68 61 73 68 20 28 6d 61 6b 65 2d 68 61 73  s-hash (make-has
9de0: 68 2d 74 61 62 6c 65 29 29 29 0a 20 20 20 20 3b  h-table))).    ;
9df0: 3b 20 69 6e 64 65 78 20 74 68 65 20 61 6c 72 65  ; index the alre
9e00: 61 64 79 20 73 61 76 65 64 20 74 65 73 74 73 20  ady saved tests 
9e10: 62 79 20 74 65 73 74 6e 61 6d 65 20 61 6e 64 20  by testname and 
9e20: 69 74 65 6d 70 61 74 68 20 69 6e 20 63 75 72 72  itempath in curr
9e30: 2d 74 65 73 74 73 2d 68 61 73 68 0a 20 20 20 20  -tests-hash.    
9e40: 28 66 6f 72 2d 65 61 63 68 0a 20 20 20 20 20 28  (for-each.     (
9e50: 6c 61 6d 62 64 61 20 28 74 65 73 74 64 61 74 29  lambda (testdat)
9e60: 0a 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28 28  .       (let* ((
9e70: 74 65 73 74 6e 61 6d 65 20 20 28 64 62 3a 74 65  testname  (db:te
9e80: 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20  st-get-testname 
9e90: 74 65 73 74 64 61 74 29 29 0a 09 20 20 20 20 20  testdat))..     
9ea0: 20 28 69 74 65 6d 2d 70 61 74 68 20 28 64 62 3a   (item-path (db:
9eb0: 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61  test-get-item-pa
9ec0: 74 68 20 74 65 73 74 64 61 74 29 29 0a 09 20 20  th testdat))..  
9ed0: 20 20 20 20 28 66 75 6c 6c 2d 6e 61 6d 65 20 28      (full-name (
9ee0: 63 6f 6e 63 20 74 65 73 74 6e 61 6d 65 20 22 2f  conc testname "/
9ef0: 22 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 09  " item-path)))..
9f00: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74   (hash-table-set
9f10: 21 20 63 75 72 72 2d 74 65 73 74 73 2d 68 61 73  ! curr-tests-has
9f20: 68 20 66 75 6c 6c 2d 6e 61 6d 65 20 74 65 73 74  h full-name test
9f30: 64 61 74 29 29 29 0a 20 20 20 20 20 63 75 72 72  dat))).     curr
9f40: 2d 74 65 73 74 73 29 0a 20 20 20 20 3b 3b 20 4e  -tests).    ;; N
9f50: 4f 50 45 3a 20 4e 6f 6e 2d 6f 70 74 69 6d 61 6c  OPE: Non-optimal
9f60: 20 61 70 70 72 6f 61 63 68 2e 20 54 72 79 20 74   approach. Try t
9f70: 68 69 73 20 69 6e 73 74 65 61 64 2e 0a 20 20 20  his instead..   
9f80: 20 3b 3b 20 20 20 31 2e 20 74 65 73 74 73 20 61   ;;   1. tests a
9f90: 72 65 20 72 65 63 65 69 76 65 64 20 69 6e 20 61  re received in a
9fa0: 20 6c 69 73 74 2c 20 6d 6f 73 74 20 72 65 63 65   list, most rece
9fb0: 6e 74 20 66 69 72 73 74 0a 20 20 20 20 3b 3b 20  nt first.    ;; 
9fc0: 20 20 32 2e 20 72 65 70 6c 61 63 65 20 74 68 65    2. replace the
9fd0: 20 72 6f 6c 6c 75 70 20 74 65 73 74 20 77 69 74   rollup test wit
9fe0: 68 20 74 68 65 20 6e 65 77 20 2a 61 6c 77 61 79  h the new *alway
9ff0: 73 2a 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68  s*.    (for-each
a000: 20 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28   .     (lambda (
a010: 74 65 73 74 64 61 74 29 0a 20 20 20 20 20 20 20  testdat).       
a020: 28 6c 65 74 2a 20 28 28 74 65 73 74 6e 61 6d 65  (let* ((testname
a030: 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 74    (db:test-get-t
a040: 65 73 74 6e 61 6d 65 20 74 65 73 74 64 61 74 29  estname testdat)
a050: 29 0a 09 20 20 20 20 20 20 28 69 74 65 6d 2d 70  )..      (item-p
a060: 61 74 68 20 28 64 62 3a 74 65 73 74 2d 67 65 74  ath (db:test-get
a070: 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 64  -item-path testd
a080: 61 74 29 29 0a 09 20 20 20 20 20 20 28 66 75 6c  at))..      (ful
a090: 6c 2d 6e 61 6d 65 20 28 63 6f 6e 63 20 74 65 73  l-name (conc tes
a0a0: 74 6e 61 6d 65 20 22 2f 22 20 69 74 65 6d 2d 70  tname "/" item-p
a0b0: 61 74 68 29 29 0a 09 20 20 20 20 20 20 28 70 72  ath))..      (pr
a0c0: 65 76 2d 74 65 73 74 2d 64 61 74 20 28 68 61 73  ev-test-dat (has
a0d0: 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61  h-table-ref/defa
a0e0: 75 6c 74 20 63 75 72 72 2d 74 65 73 74 73 2d 68  ult curr-tests-h
a0f0: 61 73 68 20 66 75 6c 6c 2d 6e 61 6d 65 20 23 66  ash full-name #f
a100: 29 29 0a 09 20 20 20 20 20 20 28 74 65 73 74 2d  ))..      (test-
a110: 73 74 65 70 73 20 20 20 20 20 20 28 64 62 3a 67  steps      (db:g
a120: 65 74 2d 73 74 65 70 73 2d 66 6f 72 2d 74 65 73  et-steps-for-tes
a130: 74 20 64 62 20 28 64 62 3a 74 65 73 74 2d 67 65  t db (db:test-ge
a140: 74 2d 69 64 20 74 65 73 74 64 61 74 29 29 29 0a  t-id testdat))).
a150: 09 20 20 20 20 20 20 28 6e 65 77 2d 74 65 73 74  .      (new-test
a160: 2d 72 65 63 6f 72 64 20 23 66 29 29 0a 09 20 3b  -record #f)).. ;
a170: 3b 20 72 65 70 6c 61 63 65 20 74 68 65 73 65 20  ; replace these 
a180: 77 69 74 68 20 69 6e 73 65 72 74 20 2e 2e 2e 20  with insert ... 
a190: 73 65 6c 65 63 74 0a 09 20 28 61 70 70 6c 79 20  select.. (apply 
a1a0: 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20  sqlite3:execute 
a1b0: 0a 09 09 64 62 20 0a 09 09 28 63 6f 6e 63 20 22  ...db ...(conc "
a1c0: 49 4e 53 45 52 54 20 4f 52 20 52 45 50 4c 41 43  INSERT OR REPLAC
a1d0: 45 20 49 4e 54 4f 20 74 65 73 74 73 20 28 72 75  E INTO tests (ru
a1e0: 6e 5f 69 64 2c 74 65 73 74 6e 61 6d 65 2c 73 74  n_id,testname,st
a1f0: 61 74 65 2c 73 74 61 74 75 73 2c 65 76 65 6e 74  ate,status,event
a200: 5f 74 69 6d 65 2c 68 6f 73 74 2c 63 70 75 6c 6f  _time,host,cpulo
a210: 61 64 2c 64 69 73 6b 66 72 65 65 2c 75 6e 61 6d  ad,diskfree,unam
a220: 65 2c 72 75 6e 64 69 72 2c 69 74 65 6d 5f 70 61  e,rundir,item_pa
a230: 74 68 2c 72 75 6e 5f 64 75 72 61 74 69 6f 6e 2c  th,run_duration,
a240: 66 69 6e 61 6c 5f 6c 6f 67 66 2c 63 6f 6d 6d 65  final_logf,comme
a250: 6e 74 2c 66 69 72 73 74 5f 65 72 72 2c 66 69 72  nt,first_err,fir
a260: 73 74 5f 77 61 72 6e 29 20 22 0a 09 09 20 20 20  st_warn) "...   
a270: 20 20 20 22 56 41 4c 55 45 53 20 28 3f 2c 3f 2c     "VALUES (?,?,
a280: 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c  ?,?,?,?,?,?,?,?,
a290: 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 29 3b 22 29 0a  ?,?,?,?,?,?);").
a2a0: 09 09 6e 65 77 2d 72 75 6e 2d 69 64 20 28 63 64  ..new-run-id (cd
a2b0: 64 72 20 28 76 65 63 74 6f 72 2d 3e 6c 69 73 74  dr (vector->list
a2c0: 20 74 65 73 74 64 61 74 29 29 29 0a 09 20 28 73   testdat))).. (s
a2d0: 65 74 21 20 6e 65 77 2d 74 65 73 74 64 61 74 20  et! new-testdat 
a2e0: 28 63 61 72 20 28 64 62 2d 67 65 74 2d 74 65 73  (car (db-get-tes
a2f0: 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 6e 65  ts-for-run db ne
a300: 77 2d 72 75 6e 2d 69 64 20 74 65 73 74 6e 61 6d  w-run-id testnam
a310: 65 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 09  e item-path)))..
a320: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74   (hash-table-set
a330: 21 20 63 75 72 72 2d 74 65 73 74 73 2d 68 61 73  ! curr-tests-has
a340: 68 20 66 75 6c 6c 2d 6e 61 6d 65 20 6e 65 77 2d  h full-name new-
a350: 74 65 73 74 64 61 74 29 20 3b 3b 20 74 68 69 73  testdat) ;; this
a360: 20 63 6f 75 6c 64 20 62 65 20 63 6f 6e 66 75 73   could be confus
a370: 69 6e 67 2c 20 77 68 69 63 68 20 72 65 63 6f 72  ing, which recor
a380: 64 20 73 68 6f 75 6c 64 20 67 6f 20 69 6e 74 6f  d should go into
a390: 20 74 68 65 20 6c 6f 6f 6b 75 70 20 74 61 62 6c   the lookup tabl
a3a0: 65 3f 0a 09 20 3b 3b 20 4e 6f 77 20 64 75 70 6c  e?.. ;; Now dupl
a3b0: 69 63 61 74 65 20 74 68 65 20 74 65 73 74 20 73  icate the test s
a3c0: 74 65 70 73 0a 09 20 28 64 65 62 75 67 3a 70 72  teps.. (debug:pr
a3d0: 69 6e 74 20 34 20 22 43 6f 70 79 69 6e 67 20 72  int 4 "Copying r
a3e0: 65 63 6f 72 64 73 20 69 6e 20 74 65 73 74 5f 73  ecords in test_s
a3f0: 74 65 70 73 20 66 72 6f 6d 20 74 65 73 74 5f 69  teps from test_i
a400: 64 3d 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74  d=" (db:test-get
a410: 2d 69 64 20 74 65 73 74 64 61 74 29 20 22 20 74  -id testdat) " t
a420: 6f 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74  o " (db:test-get
a430: 2d 69 64 20 6e 65 77 2d 74 65 73 74 64 61 74 29  -id new-testdat)
a440: 29 0a 09 20 28 73 71 6c 69 74 65 33 3a 65 78 65  ).. (sqlite3:exe
a450: 63 75 74 65 20 0a 09 20 20 64 62 20 0a 09 20 20  cute ..  db ..  
a460: 28 63 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f 52  (conc "INSERT OR
a470: 20 52 45 50 4c 41 43 45 20 49 4e 54 4f 20 74 65   REPLACE INTO te
a480: 73 74 5f 73 74 65 70 73 20 28 74 65 73 74 5f 69  st_steps (test_i
a490: 64 2c 73 74 65 70 6e 61 6d 65 2c 73 74 61 74 65  d,stepname,state
a4a0: 2c 73 74 61 74 75 73 2c 65 76 65 6e 74 5f 74 69  ,status,event_ti
a4b0: 6d 65 2c 63 6f 6d 6d 65 6e 74 29 20 22 0a 09 09  me,comment) "...
a4c0: 22 53 45 4c 45 43 54 20 22 20 28 64 62 3a 74 65  "SELECT " (db:te
a4d0: 73 74 2d 67 65 74 2d 69 64 20 6e 65 77 2d 74 65  st-get-id new-te
a4e0: 73 74 64 61 74 29 20 22 2c 73 74 65 70 6e 61 6d  stdat) ",stepnam
a4f0: 65 2c 73 74 61 74 65 2c 73 74 61 74 75 73 2c 65  e,state,status,e
a500: 76 65 6e 74 5f 74 69 6d 65 2c 63 6f 6d 6d 65 6e  vent_time,commen
a510: 74 20 46 52 4f 4d 20 74 65 73 74 5f 73 74 65 70  t FROM test_step
a520: 73 20 57 48 45 52 45 20 74 65 73 74 5f 69 64 3d  s WHERE test_id=
a530: 3f 3b 22 29 0a 09 20 20 28 64 62 3a 74 65 73 74  ?;")..  (db:test
a540: 2d 67 65 74 2d 69 64 20 74 65 73 74 64 61 74 29  -get-id testdat)
a550: 29 0a 09 20 3b 3b 20 4e 6f 77 20 64 75 70 6c 69  ).. ;; Now dupli
a560: 63 61 74 65 20 74 68 65 20 74 65 73 74 20 64 61  cate the test da
a570: 74 61 0a 09 20 28 64 65 62 75 67 3a 70 72 69 6e  ta.. (debug:prin
a580: 74 20 34 20 22 43 6f 70 79 69 6e 67 20 72 65 63  t 4 "Copying rec
a590: 6f 72 64 73 20 69 6e 20 74 65 73 74 5f 64 61 74  ords in test_dat
a5a0: 61 20 66 72 6f 6d 20 74 65 73 74 5f 69 64 3d 22  a from test_id="
a5b0: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64   (db:test-get-id
a5c0: 20 74 65 73 74 64 61 74 29 20 22 20 74 6f 20 22   testdat) " to "
a5d0: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64   (db:test-get-id
a5e0: 20 6e 65 77 2d 74 65 73 74 64 61 74 29 29 0a 09   new-testdat))..
a5f0: 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74   (sqlite3:execut
a600: 65 20 0a 09 20 20 64 62 20 0a 09 20 20 28 63 6f  e ..  db ..  (co
a610: 6e 63 20 22 49 4e 53 45 52 54 20 4f 52 20 52 45  nc "INSERT OR RE
a620: 50 4c 41 43 45 20 49 4e 54 4f 20 74 65 73 74 5f  PLACE INTO test_
a630: 64 61 74 61 20 28 74 65 73 74 5f 69 64 2c 63 61  data (test_id,ca
a640: 74 65 67 6f 72 79 2c 76 61 72 69 61 62 6c 65 2c  tegory,variable,
a650: 76 61 6c 75 65 2c 65 78 70 65 63 74 65 64 2c 74  value,expected,t
a660: 6f 6c 2c 75 6e 69 74 73 2c 63 6f 6d 6d 65 6e 74  ol,units,comment
a670: 29 20 22 0a 09 09 22 53 45 4c 45 43 54 20 22 20  ) "..."SELECT " 
a680: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20  (db:test-get-id 
a690: 6e 65 77 2d 74 65 73 74 64 61 74 29 20 22 2c 63  new-testdat) ",c
a6a0: 61 74 65 67 6f 72 79 2c 76 61 72 69 61 62 6c 65  ategory,variable
a6b0: 2c 76 61 6c 75 65 2c 65 78 70 65 63 74 65 64 2c  ,value,expected,
a6c0: 74 6f 6c 2c 75 6e 69 74 73 2c 63 6f 6d 6d 65 6e  tol,units,commen
a6d0: 74 20 46 52 4f 4d 20 74 65 73 74 5f 64 61 74 61  t FROM test_data
a6e0: 20 57 48 45 52 45 20 74 65 73 74 5f 69 64 3d 3f   WHERE test_id=?
a6f0: 3b 22 29 0a 09 20 20 28 64 62 3a 74 65 73 74 2d  ;")..  (db:test-
a700: 67 65 74 2d 69 64 20 74 65 73 74 64 61 74 29 29  get-id testdat))
a710: 0a 09 20 29 29 0a 20 20 20 20 20 70 72 65 76 2d  .. )).     prev-
a720: 74 65 73 74 73 29 29 29 0a 09 20 0a 20 20 20 20  tests))).. .    
a730: 20 0a                                             .