Megatest

Hex Artifact Content
Login

Artifact 81b2c72b008911f32ca2197e8a21240c281122db:


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 72 75 6e 2d 69  ','n/a');" run-i
0d70: 64 20 74 65 73 74 2d 6e 61 6d 65 20 70 74 68 29  d test-name pth)
0d80: 29 0a 20 20 20 20 20 69 74 65 6d 2d 70 61 74 68  ).     item-path
0d90: 73 29 29 29 0a 0a 3b 3b 20 20 28 64 65 66 69 6e  s)))..;;  (defin
0da0: 65 20 64 62 20 28 6f 70 65 6e 2d 64 62 29 29 0a  e db (open-db)).
0db0: 3b 3b 20 20 28 74 65 73 74 2d 73 65 74 2d 73 74  ;;  (test-set-st
0dc0: 61 74 75 73 21 20 64 62 20 32 20 22 72 75 6e 66  atus! db 2 "runf
0dd0: 69 72 73 74 22 20 22 43 4f 4d 50 4c 45 54 45 44  irst" "COMPLETED
0de0: 22 20 22 50 41 53 53 22 20 22 73 75 6d 6d 65 72  " "PASS" "summer
0df0: 22 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73  ")..(define (tes
0e00: 74 2d 73 65 74 2d 73 74 61 74 75 73 21 20 64 62  t-set-status! db
0e10: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
0e20: 65 20 73 74 61 74 65 20 73 74 61 74 75 73 20 69  e state status i
0e30: 74 65 6d 64 61 74 2d 6f 72 2d 70 61 74 68 20 2e  temdat-or-path .
0e40: 20 63 6f 6d 6d 65 6e 74 29 0a 20 20 28 6c 65 74   comment).  (let
0e50: 20 28 28 69 74 65 6d 2d 70 61 74 68 20 28 69 66   ((item-path (if
0e60: 20 28 73 74 72 69 6e 67 3f 20 69 74 65 6d 64 61   (string? itemda
0e70: 74 2d 6f 72 2d 70 61 74 68 29 20 69 74 65 6d 64  t-or-path) itemd
0e80: 61 74 2d 6f 72 2d 70 61 74 68 20 28 69 74 65 6d  at-or-path (item
0e90: 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69 74 65 6d  -list->path item
0ea0: 64 61 74 2d 6f 72 2d 70 61 74 68 29 29 29 29 0a  dat-or-path)))).
0eb0: 20 20 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65      (sqlite3:exe
0ec0: 63 75 74 65 20 64 62 20 22 55 50 44 41 54 45 20  cute db "UPDATE 
0ed0: 74 65 73 74 73 20 53 45 54 20 73 74 61 74 65 3d  tests SET state=
0ee0: 3f 2c 73 74 61 74 75 73 3d 3f 2c 65 76 65 6e 74  ?,status=?,event
0ef0: 5f 74 69 6d 65 3d 73 74 72 66 74 69 6d 65 28 27  _time=strftime('
0f00: 25 73 27 2c 27 6e 6f 77 27 29 20 57 48 45 52 45  %s','now') WHERE
0f10: 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65   run_id=? AND te
0f20: 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65  stname=? AND ite
0f30: 6d 5f 70 61 74 68 3d 3f 3b 22 20 0a 09 09 20 20  m_path=?;" ...  
0f40: 20 20 20 73 74 61 74 65 20 73 74 61 74 75 73 20     state status 
0f50: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
0f60: 20 69 74 65 6d 2d 70 61 74 68 29 0a 20 20 20 20   item-path).    
0f70: 28 69 66 20 28 61 6e 64 20 28 6e 6f 74 20 28 65  (if (and (not (e
0f80: 71 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20  qual? item-path 
0f90: 22 22 29 29 20 3b 3b 20 6e 65 65 64 20 74 6f 20  "")) ;; need to 
0fa0: 75 70 64 61 74 65 20 74 68 65 20 74 6f 70 20 74  update the top t
0fb0: 65 73 74 20 72 65 63 6f 72 64 20 69 66 20 50 41  est record if PA
0fc0: 53 53 20 6f 72 20 46 41 49 4c 20 61 6e 64 20 74  SS or FAIL and t
0fd0: 68 69 73 20 69 73 20 61 20 73 75 62 74 65 73 74  his is a subtest
0fe0: 0a 09 20 20 20 20 20 28 6f 72 20 28 65 71 75 61  ..     (or (equa
0ff0: 6c 3f 20 73 74 61 74 75 73 20 22 50 41 53 53 22  l? status "PASS"
1000: 29 0a 09 09 20 28 65 71 75 61 6c 3f 20 73 74 61  )... (equal? sta
1010: 74 75 73 20 22 57 41 52 4e 22 29 0a 09 09 20 28  tus "WARN")... (
1020: 65 71 75 61 6c 3f 20 73 74 61 74 75 73 20 22 46  equal? status "F
1030: 41 49 4c 22 29 29 29 0a 09 28 62 65 67 69 6e 0a  AIL")))..(begin.
1040: 09 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63  .  (sqlite3:exec
1050: 75 74 65 20 0a 09 20 20 20 64 62 0a 09 20 20 20  ute ..   db..   
1060: 22 55 50 44 41 54 45 20 74 65 73 74 73 20 0a 20  "UPDATE tests . 
1070: 20 20 20 20 20 20 20 20 20 20 20 20 53 45 54 20              SET 
1080: 66 61 69 6c 5f 63 6f 75 6e 74 3d 28 53 45 4c 45  fail_count=(SELE
1090: 43 54 20 63 6f 75 6e 74 28 69 64 29 20 46 52 4f  CT count(id) FRO
10a0: 4d 20 74 65 73 74 73 20 57 48 45 52 45 20 72 75  M tests WHERE ru
10b0: 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e  n_id=? AND testn
10c0: 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70  ame=? AND item_p
10d0: 61 74 68 20 21 3d 20 27 27 20 41 4e 44 20 73 74  ath != '' AND st
10e0: 61 74 75 73 3d 27 46 41 49 4c 27 29 2c 0a 20 20  atus='FAIL'),.  
10f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 70                 p
1100: 61 73 73 5f 63 6f 75 6e 74 3d 28 53 45 4c 45 43  ass_count=(SELEC
1110: 54 20 63 6f 75 6e 74 28 69 64 29 20 46 52 4f 4d  T count(id) FROM
1120: 20 74 65 73 74 73 20 57 48 45 52 45 20 72 75 6e   tests WHERE run
1130: 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61  _id=? AND testna
1140: 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61  me=? AND item_pa
1150: 74 68 20 21 3d 20 27 27 20 41 4e 44 20 28 73 74  th != '' AND (st
1160: 61 74 75 73 3d 27 50 41 53 53 27 20 4f 52 20 73  atus='PASS' OR s
1170: 74 61 74 75 73 3d 27 57 41 52 4e 27 29 29 0a 20  tatus='WARN')). 
1180: 20 20 20 20 20 20 20 20 20 20 20 20 57 48 45 52              WHER
1190: 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74  E run_id=? AND t
11a0: 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74  estname=? AND it
11b0: 65 6d 5f 70 61 74 68 3d 27 27 3b 22 0a 09 20 20  em_path='';"..  
11c0: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
11d0: 65 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  e run-id test-na
11e0: 6d 65 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e  me run-id test-n
11f0: 61 6d 65 29 0a 09 20 20 28 73 71 6c 69 74 65 33  ame)..  (sqlite3
1200: 3a 65 78 65 63 75 74 65 0a 09 20 20 20 64 62 0a  :execute..   db.
1210: 09 20 20 20 22 55 50 44 41 54 45 20 74 65 73 74  .   "UPDATE test
1220: 73 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 53  s.             S
1230: 45 54 20 73 74 61 74 65 3d 27 43 4f 4d 50 4c 45  ET state='COMPLE
1240: 54 45 44 27 2c 0a 20 20 20 20 20 20 20 20 20 20  TED',.          
1250: 20 20 20 20 20 20 73 74 61 74 75 73 3d 43 41 53        status=CAS
1260: 45 20 57 48 45 4e 20 66 61 69 6c 5f 63 6f 75 6e  E WHEN fail_coun
1270: 74 20 3e 20 30 20 54 48 45 4e 20 27 46 41 49 4c  t > 0 THEN 'FAIL
1280: 27 20 57 48 45 4e 20 70 61 73 73 5f 63 6f 75 6e  ' WHEN pass_coun
1290: 74 20 3e 20 30 20 41 4e 44 20 66 61 69 6c 5f 63  t > 0 AND fail_c
12a0: 6f 75 6e 74 3d 30 20 54 48 45 4e 20 27 50 41 53  ount=0 THEN 'PAS
12b0: 53 27 20 45 4c 53 45 20 27 55 4e 4b 4e 4f 57 4e  S' ELSE 'UNKNOWN
12c0: 27 20 45 4e 44 0a 20 20 20 20 20 20 20 20 20 20  ' END.          
12d0: 20 20 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d     WHERE run_id=
12e0: 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f  ? AND testname=?
12f0: 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 27   AND item_path='
1300: 27 3b 22 0a 09 20 20 20 72 75 6e 2d 69 64 20 74  ';"..   run-id t
1310: 65 73 74 2d 6e 61 6d 65 29 29 29 0a 20 20 20 20  est-name))).    
1320: 28 69 66 20 28 61 6e 64 20 28 6e 6f 74 20 28 6e  (if (and (not (n
1330: 75 6c 6c 3f 20 63 6f 6d 6d 65 6e 74 29 29 0a 09  ull? comment))..
1340: 20 20 20 20 20 28 63 61 72 20 63 6f 6d 6d 65 6e       (car commen
1350: 74 29 29 0a 09 28 73 71 6c 69 74 65 33 3a 65 78  t))..(sqlite3:ex
1360: 65 63 75 74 65 20 64 62 20 22 55 50 44 41 54 45  ecute db "UPDATE
1370: 20 74 65 73 74 73 20 53 45 54 20 63 6f 6d 6d 65   tests SET comme
1380: 6e 74 3d 3f 20 57 48 45 52 45 20 72 75 6e 5f 69  nt=? WHERE run_i
1390: 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65  d=? AND testname
13a0: 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68  =? AND item_path
13b0: 3d 3f 3b 22 0a 09 09 09 20 28 63 61 72 20 63 6f  =?;".... (car co
13c0: 6d 6d 65 6e 74 29 20 72 75 6e 2d 69 64 20 74 65  mment) run-id te
13d0: 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74  st-name item-pat
13e0: 68 29 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28  h))))..(define (
13f0: 74 65 73 74 2d 73 65 74 2d 6c 6f 67 21 20 64 62  test-set-log! db
1400: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
1410: 65 20 69 74 65 6d 64 61 74 20 6c 6f 67 66 29 20  e itemdat logf) 
1420: 0a 20 20 28 6c 65 74 20 28 28 69 74 65 6d 2d 70  .  (let ((item-p
1430: 61 74 68 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e  ath (item-list->
1440: 70 61 74 68 20 69 74 65 6d 64 61 74 29 29 29 0a  path itemdat))).
1450: 20 20 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65      (sqlite3:exe
1460: 63 75 74 65 20 64 62 20 22 55 50 44 41 54 45 20  cute db "UPDATE 
1470: 74 65 73 74 73 20 53 45 54 20 66 69 6e 61 6c 5f  tests SET final_
1480: 6c 6f 67 66 3d 3f 20 57 48 45 52 45 20 72 75 6e  logf=? WHERE run
1490: 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61  _id=? AND testna
14a0: 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61  me=? AND item_pa
14b0: 74 68 3d 3f 3b 22 20 0a 09 09 20 20 20 20 20 6c  th=?;" ...     l
14c0: 6f 67 66 20 72 75 6e 2d 69 64 20 74 65 73 74 2d  ogf run-id test-
14d0: 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29  name item-path))
14e0: 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73 74  )..(define (test
14f0: 2d 73 65 74 2d 74 6f 70 6c 6f 67 21 20 64 62 20  -set-toplog! db 
1500: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
1510: 20 6c 6f 67 66 29 20 0a 20 20 28 73 71 6c 69 74   logf) .  (sqlit
1520: 65 33 3a 65 78 65 63 75 74 65 20 64 62 20 22 55  e3:execute db "U
1530: 50 44 41 54 45 20 74 65 73 74 73 20 53 45 54 20  PDATE tests SET 
1540: 66 69 6e 61 6c 5f 6c 6f 67 66 3d 3f 20 57 48 45  final_logf=? WHE
1550: 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20  RE run_id=? AND 
1560: 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69  testname=? AND i
1570: 74 65 6d 5f 70 61 74 68 3d 27 27 3b 22 20 0a 09  tem_path='';" ..
1580: 09 20 20 20 6c 6f 67 66 20 72 75 6e 2d 69 64 20  .   logf run-id 
1590: 74 65 73 74 2d 6e 61 6d 65 29 29 0a 0a 3b 3b 20  test-name))..;; 
15a0: 3b 3b 20 54 4f 44 4f 3a 20 43 6f 6e 76 65 72 67  ;; TODO: Converg
15b0: 65 20 74 68 69 73 20 77 69 74 68 20 64 62 3a 67  e this with db:g
15c0: 65 74 2d 74 65 73 74 2d 69 6e 66 6f 0a 3b 3b 20  et-test-info.;; 
15d0: 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 67 65  (define (runs:ge
15e0: 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 20 72  t-test-info db r
15f0: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
1600: 69 74 65 6d 2d 70 61 74 68 29 0a 3b 3b 20 20 20  item-path).;;   
1610: 28 6c 65 74 20 28 28 72 65 73 20 23 66 29 29 20  (let ((res #f)) 
1620: 3b 3b 20 28 76 65 63 74 6f 72 20 23 66 20 23 66  ;; (vector #f #f
1630: 20 23 66 20 23 66 20 23 66 20 23 66 29 29 29 0a   #f #f #f #f))).
1640: 3b 3b 20 20 20 20 20 28 73 71 6c 69 74 65 33 3a  ;;     (sqlite3:
1650: 66 6f 72 2d 65 61 63 68 2d 72 6f 77 20 0a 3b 3b  for-each-row .;;
1660: 20 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 69        (lambda (i
1670: 64 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  d run-id test-na
1680: 6d 65 20 73 74 61 74 65 20 73 74 61 74 75 73 29  me state status)
1690: 0a 3b 3b 20 20 20 20 20 20 20 20 28 73 65 74 21  .;;        (set!
16a0: 20 72 65 73 20 28 76 65 63 74 6f 72 20 69 64 20   res (vector id 
16b0: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
16c0: 20 73 74 61 74 65 20 73 74 61 74 75 73 20 69 74   state status it
16d0: 65 6d 2d 70 61 74 68 29 29 29 0a 3b 3b 20 20 20  em-path))).;;   
16e0: 20 20 20 64 62 20 22 53 45 4c 45 43 54 20 69 64     db "SELECT id
16f0: 2c 72 75 6e 5f 69 64 2c 74 65 73 74 6e 61 6d 65  ,run_id,testname
1700: 2c 73 74 61 74 65 2c 73 74 61 74 75 73 20 46 52  ,state,status FR
1710: 4f 4d 20 74 65 73 74 73 20 57 48 45 52 45 20 72  OM tests WHERE r
1720: 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74  un_id=? AND test
1730: 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f  name=? AND item_
1740: 70 61 74 68 3d 3f 3b 22 0a 3b 3b 20 20 20 20 20  path=?;".;;     
1750: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
1760: 65 20 69 74 65 6d 2d 70 61 74 68 29 0a 3b 3b 20  e item-path).;; 
1770: 20 20 20 20 72 65 73 29 29 0a 0a 28 64 65 66 69      res))..(defi
1780: 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65 73 74 3a  ne-inline (test:
1790: 67 65 74 2d 69 64 20 76 65 63 29 20 20 20 20 20  get-id vec)     
17a0: 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20 76 65    (vector-ref ve
17b0: 63 20 30 29 29 0a 28 64 65 66 69 6e 65 2d 69 6e  c 0)).(define-in
17c0: 6c 69 6e 65 20 28 74 65 73 74 3a 67 65 74 2d 72  line (test:get-r
17d0: 75 6e 5f 69 64 20 76 65 63 29 20 20 20 28 76 65  un_id vec)   (ve
17e0: 63 74 6f 72 2d 72 65 66 20 76 65 63 20 31 29 29  ctor-ref vec 1))
17f0: 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69 6e 65 20  .(define-inline 
1800: 28 74 65 73 74 3a 67 65 74 2d 74 65 73 74 2d 6e  (test:get-test-n
1810: 61 6d 65 20 76 65 63 29 28 76 65 63 74 6f 72 2d  ame vec)(vector-
1820: 72 65 66 20 76 65 63 20 32 29 29 0a 28 64 65 66  ref vec 2)).(def
1830: 69 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65 73 74  ine-inline (test
1840: 3a 67 65 74 2d 73 74 61 74 65 20 76 65 63 29 20  :get-state vec) 
1850: 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20 76     (vector-ref v
1860: 65 63 20 33 29 29 0a 28 64 65 66 69 6e 65 2d 69  ec 3)).(define-i
1870: 6e 6c 69 6e 65 20 28 74 65 73 74 3a 67 65 74 2d  nline (test:get-
1880: 73 74 61 74 75 73 20 76 65 63 29 20 20 20 28 76  status vec)   (v
1890: 65 63 74 6f 72 2d 72 65 66 20 76 65 63 20 34 29  ector-ref vec 4)
18a0: 29 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69 6e 65  ).(define-inline
18b0: 20 28 74 65 73 74 3a 67 65 74 2d 69 74 65 6d 2d   (test:get-item-
18c0: 70 61 74 68 20 76 65 63 29 28 76 65 63 74 6f 72  path vec)(vector
18d0: 2d 72 65 66 20 76 65 63 20 35 29 29 0a 0a 28 64  -ref vec 5))..(d
18e0: 65 66 69 6e 65 20 28 72 75 6e 73 3a 74 65 73 74  efine (runs:test
18f0: 2d 67 65 74 2d 66 75 6c 6c 2d 70 61 74 68 20 74  -get-full-path t
1900: 65 73 74 29 0a 20 20 28 6c 65 74 2a 20 28 28 74  est).  (let* ((t
1910: 65 73 74 6e 61 6d 65 20 28 64 62 3a 74 65 73 74  estname (db:test
1920: 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 20 20  -get-testname   
1930: 74 65 73 74 29 29 0a 09 20 28 69 74 65 6d 70 61  test)).. (itempa
1940: 74 68 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  th (db:test-get-
1950: 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 29 29  item-path test))
1960: 29 0a 20 20 20 20 28 63 6f 6e 63 20 74 65 73 74  ).    (conc test
1970: 6e 61 6d 65 20 28 69 66 20 28 65 71 75 61 6c 3f  name (if (equal?
1980: 20 69 74 65 6d 70 61 74 68 20 22 22 29 20 22 22   itempath "") ""
1990: 20 28 63 6f 6e 63 20 22 28 22 20 69 74 65 6d 70   (conc "(" itemp
19a0: 61 74 68 20 22 29 22 29 29 29 29 29 0a 0a 28 64  ath ")")))))..(d
19b0: 65 66 69 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65  efine-inline (te
19c0: 73 74 3a 74 65 73 74 2d 67 65 74 2d 66 75 6c 6c  st:test-get-full
19d0: 6e 61 6d 65 20 74 65 73 74 29 0a 20 20 20 28 63  name test).   (c
19e0: 6f 6e 63 20 28 64 62 3a 74 65 73 74 2d 67 65 74  onc (db:test-get
19f0: 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 29 0a  -testname test).
1a00: 09 20 28 69 66 20 28 65 71 75 61 6c 3f 20 28 64  . (if (equal? (d
1a10: 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d  b:test-get-item-
1a20: 70 61 74 68 20 74 65 73 74 29 20 22 22 29 0a 09  path test) "")..
1a30: 20 20 20 20 20 22 22 0a 09 20 20 20 20 20 28 63       ""..     (c
1a40: 6f 6e 63 20 22 28 22 20 28 64 62 3a 74 65 73 74  onc "(" (db:test
1a50: 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74  -get-item-path t
1a60: 65 73 74 29 20 22 29 22 29 29 29 29 0a 0a 28 64  est) ")"))))..(d
1a70: 65 66 69 6e 65 20 28 63 68 65 63 6b 2d 76 61 6c  efine (check-val
1a80: 69 64 2d 69 74 65 6d 73 20 63 6c 61 73 73 20 69  id-items class i
1a90: 74 65 6d 29 0a 20 20 28 6c 65 74 20 28 28 76 61  tem).  (let ((va
1aa0: 6c 69 64 2d 76 61 6c 75 65 73 20 28 6c 65 74 20  lid-values (let 
1ab0: 28 28 73 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b  ((s (config-look
1ac0: 75 70 20 2a 63 6f 6e 66 69 67 64 61 74 2a 20 22  up *configdat* "
1ad0: 76 61 6c 69 64 76 61 6c 75 65 73 22 20 63 6c 61  validvalues" cla
1ae0: 73 73 29 29 29 0a 09 09 09 28 69 66 20 73 20 28  ss)))....(if s (
1af0: 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 73 29 20  string-split s) 
1b00: 23 66 29 29 29 29 0a 20 20 20 20 28 69 66 20 76  #f)))).    (if v
1b10: 61 6c 69 64 2d 76 61 6c 75 65 73 0a 09 28 69 66  alid-values..(if
1b20: 20 28 6d 65 6d 62 65 72 20 69 74 65 6d 20 76 61   (member item va
1b30: 6c 69 64 2d 76 61 6c 75 65 73 29 0a 09 20 20 20  lid-values)..   
1b40: 20 69 74 65 6d 20 23 66 29 0a 09 69 74 65 6d 29   item #f)..item)
1b50: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73  ))..(define (tes
1b60: 74 73 74 65 70 2d 73 65 74 2d 73 74 61 74 75 73  tstep-set-status
1b70: 21 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  ! db run-id test
1b80: 2d 6e 61 6d 65 20 74 65 73 74 73 74 65 70 2d 6e  -name teststep-n
1b90: 61 6d 65 20 73 74 61 74 65 2d 69 6e 20 73 74 61  ame state-in sta
1ba0: 74 75 73 2d 69 6e 20 69 74 65 6d 64 61 74 20 63  tus-in itemdat c
1bb0: 6f 6d 6d 65 6e 74 29 0a 20 20 28 64 65 62 75 67  omment).  (debug
1bc0: 3a 70 72 69 6e 74 20 34 20 22 72 75 6e 2d 69 64  :print 4 "run-id
1bd0: 3a 20 22 20 72 75 6e 2d 69 64 20 22 20 74 65 73  : " run-id " tes
1be0: 74 2d 6e 61 6d 65 3a 20 22 20 74 65 73 74 2d 6e  t-name: " test-n
1bf0: 61 6d 65 29 0a 20 20 28 6c 65 74 2a 20 28 28 73  ame).  (let* ((s
1c00: 74 61 74 65 20 20 20 20 20 28 63 68 65 63 6b 2d  tate     (check-
1c10: 76 61 6c 69 64 2d 69 74 65 6d 73 20 22 73 74 61  valid-items "sta
1c20: 74 65 22 20 73 74 61 74 65 2d 69 6e 29 29 0a 09  te" state-in))..
1c30: 20 28 73 74 61 74 75 73 20 20 20 20 28 63 68 65   (status    (che
1c40: 63 6b 2d 76 61 6c 69 64 2d 69 74 65 6d 73 20 22  ck-valid-items "
1c50: 73 74 61 74 75 73 22 20 73 74 61 74 75 73 2d 69  status" status-i
1c60: 6e 29 29 0a 09 20 28 69 74 65 6d 2d 70 61 74 68  n)).. (item-path
1c70: 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74   (item-list->pat
1c80: 68 20 69 74 65 6d 64 61 74 29 29 0a 09 20 28 74  h itemdat)).. (t
1c90: 65 73 74 64 61 74 20 20 20 28 64 62 3a 67 65 74  estdat   (db:get
1ca0: 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 20 72 75  -test-info db ru
1cb0: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69  n-id test-name i
1cc0: 74 65 6d 2d 70 61 74 68 29 29 29 0a 20 20 20 20  tem-path))).    
1cd0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 35 20 22  (debug:print 5 "
1ce0: 74 65 73 74 64 61 74 3a 20 22 20 74 65 73 74 64  testdat: " testd
1cf0: 61 74 29 0a 20 20 20 20 28 69 66 20 28 61 6e 64  at).    (if (and
1d00: 20 74 65 73 74 64 61 74 20 3b 3b 20 69 66 20 74   testdat ;; if t
1d10: 68 65 20 73 65 63 74 69 6f 6e 20 65 78 69 73 74  he section exist
1d20: 73 20 74 68 65 6e 20 66 6f 72 63 65 20 73 70 65  s then force spe
1d30: 63 69 66 69 63 61 74 69 6f 6e 20 42 55 47 2c 20  cification BUG, 
1d40: 49 20 64 6f 6e 27 74 20 6c 69 6b 65 20 68 6f 77  I don't like how
1d50: 20 74 68 69 73 20 77 6f 72 6b 73 2e 0a 09 20 20   this works...  
1d60: 20 20 20 28 6f 72 20 28 6e 6f 74 20 73 74 61 74     (or (not stat
1d70: 65 29 28 6e 6f 74 20 73 74 61 74 75 73 29 29 29  e)(not status)))
1d80: 0a 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30  ..(debug:print 0
1d90: 20 22 57 41 52 4e 49 4e 47 3a 20 49 6e 76 61 6c   "WARNING: Inval
1da0: 69 64 20 22 20 28 69 66 20 73 74 61 74 75 73 20  id " (if status 
1db0: 22 73 74 61 74 75 73 22 20 22 73 74 61 74 65 22  "status" "state"
1dc0: 29 0a 09 20 20 20 20 20 20 20 22 20 76 61 6c 75  )..       " valu
1dd0: 65 20 5c 22 22 20 28 69 66 20 73 74 61 74 75 73  e \"" (if status
1de0: 20 73 74 61 74 75 73 2d 69 6e 20 73 74 61 74 65   status-in state
1df0: 2d 69 6e 29 20 22 5c 22 2c 20 75 70 64 61 74 65  -in) "\", update
1e00: 20 79 6f 75 72 20 76 61 6c 69 64 73 74 61 74 65   your validstate
1e10: 73 20 73 65 63 74 69 6f 6e 20 69 6e 20 6d 65 67  s section in meg
1e20: 61 74 65 73 74 2e 63 6f 6e 66 69 67 22 29 29 0a  atest.config")).
1e30: 20 20 20 20 28 69 66 20 74 65 73 74 64 61 74 0a      (if testdat.
1e40: 09 28 6c 65 74 20 28 28 74 65 73 74 2d 69 64 20  .(let ((test-id 
1e50: 28 74 65 73 74 3a 67 65 74 2d 69 64 20 74 65 73  (test:get-id tes
1e60: 74 64 61 74 29 29 29 0a 09 20 20 28 73 71 6c 69  tdat)))..  (sqli
1e70: 74 65 33 3a 65 78 65 63 75 74 65 20 64 62 20 0a  te3:execute db .
1e80: 09 09 09 22 49 4e 53 45 52 54 20 4f 52 20 52 45  ..."INSERT OR RE
1e90: 50 4c 41 43 45 20 69 6e 74 6f 20 74 65 73 74 5f  PLACE into test_
1ea0: 73 74 65 70 73 20 28 74 65 73 74 5f 69 64 2c 73  steps (test_id,s
1eb0: 74 65 70 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74  tepname,state,st
1ec0: 61 74 75 73 2c 65 76 65 6e 74 5f 74 69 6d 65 2c  atus,event_time,
1ed0: 63 6f 6d 6d 65 6e 74 29 20 56 41 4c 55 45 53 28  comment) VALUES(
1ee0: 3f 2c 3f 2c 3f 2c 3f 2c 73 74 72 66 74 69 6d 65  ?,?,?,?,strftime
1ef0: 28 27 25 73 27 2c 27 6e 6f 77 27 29 2c 3f 29 3b  ('%s','now'),?);
1f00: 22 0a 09 09 09 74 65 73 74 2d 69 64 20 74 65 73  "....test-id tes
1f10: 74 73 74 65 70 2d 6e 61 6d 65 20 73 74 61 74 65  tstep-name state
1f20: 20 73 74 61 74 75 73 20 28 69 66 20 63 6f 6d 6d   status (if comm
1f30: 65 6e 74 20 63 6f 6d 6d 65 6e 74 20 22 22 29 29  ent comment ""))
1f40: 29 0a 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20  )..(debug:print 
1f50: 30 20 22 45 52 52 4f 52 3a 20 43 61 6e 27 74 20  0 "ERROR: Can't 
1f60: 75 70 64 61 74 65 20 22 20 74 65 73 74 2d 6e 61  update " test-na
1f70: 6d 65 20 22 20 66 6f 72 20 72 75 6e 20 22 20 72  me " for run " r
1f80: 75 6e 2d 69 64 20 22 20 2d 3e 20 6e 6f 20 73 75  un-id " -> no su
1f90: 63 68 20 74 65 73 74 20 69 6e 20 64 62 22 29 29  ch test in db"))
1fa0: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73  ))..(define (tes
1fb0: 74 2d 67 65 74 2d 6b 69 6c 6c 2d 72 65 71 75 65  t-get-kill-reque
1fc0: 73 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  st db run-id tes
1fd0: 74 2d 6e 61 6d 65 20 69 74 65 6d 64 61 74 29 0a  t-name itemdat).
1fe0: 20 20 28 6c 65 74 2a 20 28 28 69 74 65 6d 2d 70    (let* ((item-p
1ff0: 61 74 68 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e  ath (item-list->
2000: 70 61 74 68 20 69 74 65 6d 64 61 74 29 29 0a 09  path itemdat))..
2010: 20 28 74 65 73 74 64 61 74 20 20 20 28 64 62 3a   (testdat   (db:
2020: 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62  get-test-info db
2030: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
2040: 65 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 20  e item-path))). 
2050: 20 20 20 28 65 71 75 61 6c 3f 20 28 74 65 73 74     (equal? (test
2060: 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64  :get-state testd
2070: 61 74 29 20 22 4b 49 4c 4c 52 45 51 22 29 29 29  at) "KILLREQ")))
2080: 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73 74 2d  ..(define (test-
2090: 73 65 74 2d 6d 65 74 61 2d 69 6e 66 6f 20 64 62  set-meta-info db
20a0: 20 72 75 6e 2d 69 64 20 74 65 73 74 6e 61 6d 65   run-id testname
20b0: 20 69 74 65 6d 64 61 74 29 0a 20 20 28 6c 65 74   itemdat).  (let
20c0: 20 28 28 69 74 65 6d 2d 70 61 74 68 20 28 69 74   ((item-path (it
20d0: 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69 74  em-list->path it
20e0: 65 6d 64 61 74 29 29 0a 09 28 63 70 75 6c 6f 61  emdat))..(cpuloa
20f0: 64 20 20 28 67 65 74 2d 63 70 75 2d 6c 6f 61 64  d  (get-cpu-load
2100: 29 29 0a 09 28 68 6f 73 74 6e 61 6d 65 20 28 67  ))..(hostname (g
2110: 65 74 2d 68 6f 73 74 2d 6e 61 6d 65 29 29 0a 09  et-host-name))..
2120: 28 64 69 73 6b 66 72 65 65 20 28 67 65 74 2d 64  (diskfree (get-d
2130: 66 20 28 63 75 72 72 65 6e 74 2d 64 69 72 65 63  f (current-direc
2140: 74 6f 72 79 29 29 29 0a 09 28 75 6e 61 6d 65 20  tory)))..(uname 
2150: 20 20 20 28 67 65 74 2d 75 6e 61 6d 65 20 22 2d     (get-uname "-
2160: 73 72 76 70 69 6f 22 29 29 0a 09 28 72 75 6e 70  srvpio"))..(runp
2170: 61 74 68 20 20 28 63 75 72 72 65 6e 74 2d 64 69  ath  (current-di
2180: 72 65 63 74 6f 72 79 29 29 29 0a 20 20 20 20 28  rectory))).    (
2190: 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20  sqlite3:execute 
21a0: 64 62 20 22 55 50 44 41 54 45 20 74 65 73 74 73  db "UPDATE tests
21b0: 20 53 45 54 20 68 6f 73 74 3d 3f 2c 63 70 75 6c   SET host=?,cpul
21c0: 6f 61 64 3d 3f 2c 64 69 73 6b 66 72 65 65 3d 3f  oad=?,diskfree=?
21d0: 2c 75 6e 61 6d 65 3d 3f 2c 72 75 6e 64 69 72 3d  ,uname=?,rundir=
21e0: 3f 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f  ? WHERE run_id=?
21f0: 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20   AND testname=? 
2200: 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f 3b  AND item_path=?;
2210: 22 0a 09 09 20 20 68 6f 73 74 6e 61 6d 65 0a 09  "...  hostname..
2220: 09 20 20 63 70 75 6c 6f 61 64 0a 09 09 20 20 64  .  cpuload...  d
2230: 69 73 6b 66 72 65 65 0a 09 09 20 20 75 6e 61 6d  iskfree...  unam
2240: 65 0a 09 09 20 20 72 75 6e 70 61 74 68 0a 09 09  e...  runpath...
2250: 20 20 72 75 6e 2d 69 64 0a 09 09 20 20 74 65 73    run-id...  tes
2260: 74 6e 61 6d 65 0a 09 09 20 20 69 74 65 6d 2d 70  tname...  item-p
2270: 61 74 68 29 29 29 0a 0a 28 64 65 66 69 6e 65 20  ath)))..(define 
2280: 28 74 65 73 74 2d 75 70 64 61 74 65 2d 6d 65 74  (test-update-met
2290: 61 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64  a-info db run-id
22a0: 20 74 65 73 74 6e 61 6d 65 20 69 74 65 6d 64 61   testname itemda
22b0: 74 20 6d 69 6e 75 74 65 73 29 0a 20 20 28 6c 65  t minutes).  (le
22c0: 74 20 28 28 69 74 65 6d 2d 70 61 74 68 20 28 69  t ((item-path (i
22d0: 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69  tem-list->path i
22e0: 74 65 6d 64 61 74 29 29 0a 09 28 63 70 75 6c 6f  temdat))..(cpulo
22f0: 61 64 20 20 28 67 65 74 2d 63 70 75 2d 6c 6f 61  ad  (get-cpu-loa
2300: 64 29 29 0a 09 28 64 69 73 6b 66 72 65 65 20 28  d))..(diskfree (
2310: 67 65 74 2d 64 66 20 28 63 75 72 72 65 6e 74 2d  get-df (current-
2320: 64 69 72 65 63 74 6f 72 79 29 29 29 29 0a 20 20  directory)))).  
2330: 20 20 28 69 66 20 28 6e 6f 74 20 63 70 75 6c 6f    (if (not cpulo
2340: 61 64 29 20 20 28 62 65 67 69 6e 20 28 64 65 62  ad)  (begin (deb
2350: 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e  ug:print 0 "WARN
2360: 49 4e 47 3a 20 43 50 55 4c 4f 41 44 20 6e 6f 74  ING: CPULOAD not
2370: 20 66 6f 75 6e 64 2e 22 29 20 20 28 73 65 74 21   found.")  (set!
2380: 20 63 70 75 6c 6f 61 64 20 22 6e 2f 61 22 29 29   cpuload "n/a"))
2390: 29 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 64  ).    (if (not d
23a0: 69 73 6b 66 72 65 65 29 20 28 62 65 67 69 6e 20  iskfree) (begin 
23b0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
23c0: 57 41 52 4e 49 4e 47 3a 20 44 49 53 4b 46 52 45  WARNING: DISKFRE
23d0: 45 20 6e 6f 74 20 66 6f 75 6e 64 2e 22 29 20 28  E not found.") (
23e0: 73 65 74 21 20 64 69 73 6b 66 72 65 65 20 22 6e  set! diskfree "n
23f0: 2f 61 22 29 29 29 0a 20 20 20 20 28 69 66 20 28  /a"))).    (if (
2400: 6e 6f 74 20 69 74 65 6d 2d 70 61 74 68 29 28 62  not item-path)(b
2410: 65 67 69 6e 20 28 64 65 62 75 67 3a 70 72 69 6e  egin (debug:prin
2420: 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 49 54  t 0 "WARNING: IT
2430: 45 4d 50 41 54 48 20 6e 6f 74 20 73 65 74 2e 22  EMPATH not set."
2440: 29 20 20 20 28 73 65 74 21 20 69 74 65 6d 2d 70  )   (set! item-p
2450: 61 74 68 20 22 22 29 29 29 0a 20 20 20 20 3b 3b  ath ""))).    ;;
2460: 20 28 6c 65 74 20 28 28 74 65 73 74 69 6e 66 6f   (let ((testinfo
2470: 20 28 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e   (db:get-test-in
2480: 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  fo db run-id tes
2490: 74 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  tname item-path)
24a0: 29 29 0a 20 20 20 20 3b 3b 20 20 20 28 69 66 20  )).    ;;   (if 
24b0: 28 61 6e 64 20 28 6e 6f 74 20 28 65 71 75 61 6c  (and (not (equal
24c0: 3f 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 73  ? (db:test-get-s
24d0: 74 61 74 75 73 20 74 65 73 74 69 6e 66 6f 29 20  tatus testinfo) 
24e0: 22 43 4f 4d 50 4c 45 54 45 44 22 29 29 0a 20 20  "COMPLETED")).  
24f0: 20 20 3b 3b 20 20 20 20 20 20 20 20 20 20 20 20    ;;            
2500: 28 6e 6f 74 20 28 65 71 75 61 6c 3f 20 28 64 62  (not (equal? (db
2510: 3a 74 65 73 74 2d 67 65 74 2d 73 74 61 74 75 73  :test-get-status
2520: 20 74 65 73 74 69 6e 66 6f 29 20 22 4b 49 4c 4c   testinfo) "KILL
2530: 52 45 51 22 29 29 0a 20 20 20 20 28 73 71 6c 69  REQ")).    (sqli
2540: 74 65 33 3a 65 78 65 63 75 74 65 0a 20 20 20 20  te3:execute.    
2550: 20 64 62 0a 20 20 20 20 20 22 55 50 44 41 54 45   db.     "UPDATE
2560: 20 74 65 73 74 73 20 53 45 54 20 63 70 75 6c 6f   tests SET cpulo
2570: 61 64 3d 3f 2c 64 69 73 6b 66 72 65 65 3d 3f 2c  ad=?,diskfree=?,
2580: 72 75 6e 5f 64 75 72 61 74 69 6f 6e 3d 3f 2c 73  run_duration=?,s
2590: 74 61 74 65 3d 27 52 55 4e 4e 49 4e 47 27 20 57  tate='RUNNING' W
25a0: 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e  HERE run_id=? AN
25b0: 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44  D testname=? AND
25c0: 20 69 74 65 6d 5f 70 61 74 68 3d 3f 20 41 4e 44   item_path=? AND
25d0: 20 73 74 61 74 65 20 4e 4f 54 20 49 4e 20 28 27   state NOT IN ('
25e0: 43 4f 4d 50 4c 45 54 45 44 27 2c 27 4b 49 4c 4c  COMPLETED','KILL
25f0: 52 45 51 27 2c 27 4b 49 4c 4c 45 44 27 29 3b 22  REQ','KILLED');"
2600: 0a 20 20 20 20 20 63 70 75 6c 6f 61 64 0a 20 20  .     cpuload.  
2610: 20 20 20 64 69 73 6b 66 72 65 65 0a 20 20 20 20     diskfree.    
2620: 20 6d 69 6e 75 74 65 73 0a 20 20 20 20 20 72 75   minutes.     ru
2630: 6e 2d 69 64 0a 20 20 20 20 20 74 65 73 74 6e 61  n-id.     testna
2640: 6d 65 0a 20 20 20 20 20 69 74 65 6d 2d 70 61 74  me.     item-pat
2650: 68 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 73  h)))..(define (s
2660: 65 74 2d 6d 65 67 61 74 65 73 74 2d 65 6e 76 2d  et-megatest-env-
2670: 76 61 72 73 20 64 62 20 72 75 6e 2d 69 64 29 0a  vars db run-id).
2680: 20 20 28 6c 65 74 20 28 28 6b 65 79 73 20 28 64    (let ((keys (d
2690: 62 2d 67 65 74 2d 6b 65 79 73 20 64 62 29 29 29  b-get-keys db)))
26a0: 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20 28  .    (for-each (
26b0: 6c 61 6d 62 64 61 20 28 6b 65 79 29 0a 09 09 28  lambda (key)...(
26c0: 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68  sqlite3:for-each
26d0: 2d 72 6f 77 0a 09 09 20 28 6c 61 6d 62 64 61 20  -row... (lambda 
26e0: 28 76 61 6c 29 0a 09 09 20 20 20 28 64 65 62 75  (val)...   (debu
26f0: 67 3a 70 72 69 6e 74 20 32 20 22 73 65 74 65 6e  g:print 2 "seten
2700: 76 20 22 20 28 6b 65 79 3a 67 65 74 2d 66 69 65  v " (key:get-fie
2710: 6c 64 6e 61 6d 65 20 6b 65 79 29 20 22 20 22 20  ldname key) " " 
2720: 76 61 6c 29 0a 09 09 20 20 20 28 73 65 74 65 6e  val)...   (seten
2730: 76 20 28 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64  v (key:get-field
2740: 6e 61 6d 65 20 6b 65 79 29 20 76 61 6c 29 29 0a  name key) val)).
2750: 09 09 20 64 62 20 0a 09 09 20 28 63 6f 6e 63 20  .. db ... (conc 
2760: 22 53 45 4c 45 43 54 20 22 20 28 6b 65 79 3a 67  "SELECT " (key:g
2770: 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65 79  et-fieldname key
2780: 29 20 22 20 46 52 4f 4d 20 72 75 6e 73 20 57 48  ) " FROM runs WH
2790: 45 52 45 20 69 64 3d 3f 3b 22 29 0a 09 09 20 72  ERE id=?;")... r
27a0: 75 6e 2d 69 64 29 29 0a 09 20 20 20 20 20 20 6b  un-id))..      k
27b0: 65 79 73 29 29 29 0a 0a 28 64 65 66 69 6e 65 20  eys)))..(define 
27c0: 28 73 65 74 2d 69 74 65 6d 2d 65 6e 76 2d 76 61  (set-item-env-va
27d0: 72 73 20 69 74 65 6d 64 61 74 29 0a 20 20 28 66  rs itemdat).  (f
27e0: 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 20  or-each (lambda 
27f0: 28 69 74 65 6d 29 0a 09 20 20 20 20 20 20 28 64  (item)..      (d
2800: 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 73 65  ebug:print 2 "se
2810: 74 65 6e 76 20 22 20 28 63 61 72 20 69 74 65 6d  tenv " (car item
2820: 29 20 22 20 22 20 28 63 61 64 72 20 69 74 65 6d  ) " " (cadr item
2830: 29 29 0a 09 20 20 20 20 20 20 28 73 65 74 65 6e  ))..      (seten
2840: 76 20 28 63 61 72 20 69 74 65 6d 29 20 28 63 61  v (car item) (ca
2850: 64 72 20 69 74 65 6d 29 29 29 0a 09 20 20 20 20  dr item)))..    
2860: 69 74 65 6d 64 61 74 29 29 0a 0a 28 64 65 66 69  itemdat))..(defi
2870: 6e 65 20 28 67 65 74 2d 61 6c 6c 2d 6c 65 67 61  ne (get-all-lega
2880: 6c 2d 74 65 73 74 73 29 0a 20 20 28 6c 65 74 2a  l-tests).  (let*
2890: 20 28 28 74 65 73 74 73 20 20 28 67 6c 6f 62 20   ((tests  (glob 
28a0: 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74 68 2a 20  (conc *toppath* 
28b0: 22 2f 74 65 73 74 73 2f 2a 22 29 29 29 0a 09 20  "/tests/*"))).. 
28c0: 28 72 65 73 20 20 20 20 27 28 29 29 29 0a 20 20  (res    '())).  
28d0: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34    (debug:print 4
28e0: 20 22 49 4e 46 4f 3a 20 4c 6f 6f 6b 69 6e 67 20   "INFO: Looking 
28f0: 61 74 20 74 65 73 74 73 20 22 20 28 73 74 72 69  at tests " (stri
2900: 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 74  ng-intersperse t
2910: 65 73 74 73 20 22 2c 22 29 29 0a 20 20 20 20 28  ests ",")).    (
2920: 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61  for-each (lambda
2930: 20 28 74 65 73 74 70 61 74 68 29 0a 09 09 28 69   (testpath)...(i
2940: 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20  f (file-exists? 
2950: 28 63 6f 6e 63 20 74 65 73 74 70 61 74 68 20 22  (conc testpath "
2960: 2f 74 65 73 74 63 6f 6e 66 69 67 22 29 29 0a 09  /testconfig"))..
2970: 09 20 20 20 20 28 73 65 74 21 20 72 65 73 20 28  .    (set! res (
2980: 63 6f 6e 73 20 28 6c 61 73 74 20 28 73 74 72 69  cons (last (stri
2990: 6e 67 2d 73 70 6c 69 74 20 74 65 73 74 70 61 74  ng-split testpat
29a0: 68 20 22 2f 22 29 29 20 72 65 73 29 29 29 29 0a  h "/")) res)))).
29b0: 09 20 20 20 20 20 20 74 65 73 74 73 29 0a 20 20  .      tests).  
29c0: 20 20 72 65 73 29 29 0a 0a 28 64 65 66 69 6e 65    res))..(define
29d0: 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d   (runs:can-run-m
29e0: 6f 72 65 2d 74 65 73 74 73 20 64 62 29 0a 20 20  ore-tests db).  
29f0: 28 6c 65 74 20 28 28 6e 75 6d 2d 72 75 6e 6e 69  (let ((num-runni
2a00: 6e 67 20 28 64 62 3a 67 65 74 2d 63 6f 75 6e 74  ng (db:get-count
2a10: 2d 74 65 73 74 73 2d 72 75 6e 6e 69 6e 67 20 64  -tests-running d
2a20: 62 29 29 0a 09 28 6d 61 78 2d 63 6f 6e 63 75 72  b))..(max-concur
2a30: 72 65 6e 74 2d 6a 6f 62 73 20 28 63 6f 6e 66 69  rent-jobs (confi
2a40: 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67  g-lookup *config
2a50: 64 61 74 2a 20 22 73 65 74 75 70 22 20 22 6d 61  dat* "setup" "ma
2a60: 78 5f 63 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f 62  x_concurrent_job
2a70: 73 22 29 29 29 0a 20 20 20 20 28 64 65 62 75 67  s"))).    (debug
2a80: 3a 70 72 69 6e 74 20 32 20 22 6d 61 78 2d 63 6f  :print 2 "max-co
2a90: 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 3a 20 22  ncurrent-jobs: "
2aa0: 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d   max-concurrent-
2ab0: 6a 6f 62 73 20 22 2c 20 6e 75 6d 2d 72 75 6e 6e  jobs ", num-runn
2ac0: 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69  ing: " num-runni
2ad0: 6e 67 29 0a 20 20 20 20 28 69 66 20 28 6f 72 20  ng).    (if (or 
2ae0: 28 6e 6f 74 20 6d 61 78 2d 63 6f 6e 63 75 72 72  (not max-concurr
2af0: 65 6e 74 2d 6a 6f 62 73 29 0a 09 20 20 20 20 28  ent-jobs)..    (
2b00: 61 6e 64 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65  and max-concurre
2b10: 6e 74 2d 6a 6f 62 73 0a 09 09 20 28 73 74 72 69  nt-jobs... (stri
2b20: 6e 67 2d 3e 6e 75 6d 62 65 72 20 6d 61 78 2d 63  ng->number max-c
2b30: 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29 0a  oncurrent-jobs).
2b40: 09 09 20 28 6e 6f 74 20 28 3e 3d 20 6e 75 6d 2d  .. (not (>= num-
2b50: 72 75 6e 6e 69 6e 67 20 28 73 74 72 69 6e 67 2d  running (string-
2b60: 3e 6e 75 6d 62 65 72 20 6d 61 78 2d 63 6f 6e 63  >number max-conc
2b70: 75 72 72 65 6e 74 2d 6a 6f 62 73 29 29 29 29 29  urrent-jobs)))))
2b80: 0a 09 23 74 0a 09 28 62 65 67 69 6e 20 0a 09 20  ..#t..(begin .. 
2b90: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
2ba0: 22 57 41 52 4e 49 4e 47 3a 20 4d 61 78 20 72 75  "WARNING: Max ru
2bb0: 6e 6e 69 6e 67 20 6a 6f 62 73 20 65 78 63 65 65  nning jobs excee
2bc0: 64 65 64 2c 20 63 75 72 72 65 6e 74 20 6e 75 6d  ded, current num
2bd0: 62 65 72 20 72 75 6e 6e 69 6e 67 3a 20 22 20 6e  ber running: " n
2be0: 75 6d 2d 72 75 6e 6e 69 6e 67 20 0a 09 09 09 20  um-running .... 
2bf0: 22 2c 20 6d 61 78 5f 63 6f 6e 63 75 72 72 65 6e  ", max_concurren
2c00: 74 5f 6a 6f 62 73 3a 20 22 20 6d 61 78 2d 63 6f  t_jobs: " max-co
2c10: 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29 0a 09  ncurrent-jobs)..
2c20: 20 20 23 66 29 29 29 29 0a 20 20 0a 28 64 65 66    #f)))).  .(def
2c30: 69 6e 65 20 28 72 75 6e 2d 74 65 73 74 73 20 64  ine (run-tests d
2c40: 62 20 74 65 73 74 2d 6e 61 6d 65 73 29 0a 20 20  b test-names).  
2c50: 28 6c 65 74 2a 20 28 28 6b 65 79 73 20 20 20 20  (let* ((keys    
2c60: 20 20 20 20 28 64 62 2d 67 65 74 2d 6b 65 79 73      (db-get-keys
2c70: 20 64 62 29 29 0a 09 20 28 6b 65 79 76 61 6c 6c   db)).. (keyvall
2c80: 73 74 20 20 20 28 6b 65 79 73 2d 3e 76 61 6c 6c  st   (keys->vall
2c90: 69 73 74 20 6b 65 79 73 20 23 74 29 29 0a 09 20  ist keys #t)).. 
2ca0: 28 72 75 6e 2d 69 64 20 20 20 20 20 20 28 72 65  (run-id      (re
2cb0: 67 69 73 74 65 72 2d 72 75 6e 20 64 62 20 6b 65  gister-run db ke
2cc0: 79 73 29 29 29 20 3b 3b 20 20 74 65 73 74 2d 6e  ys))) ;;  test-n
2cd0: 61 6d 65 29 29 29 0a 20 20 20 20 3b 3b 20 6f 6e  ame))).    ;; on
2ce0: 20 74 68 65 20 66 69 72 73 74 20 70 61 73 73 20   the first pass 
2cf0: 6f 72 20 63 61 6c 6c 20 74 6f 20 72 75 6e 2d 74  or call to run-t
2d00: 65 73 74 73 20 73 65 74 20 46 41 49 4c 53 20 74  ests set FAILS t
2d10: 6f 20 4e 4f 54 5f 53 54 41 52 54 45 44 20 69 66  o NOT_STARTED if
2d20: 0a 20 20 20 20 3b 3b 20 2d 6b 65 65 70 67 6f 69  .    ;; -keepgoi
2d30: 6e 67 20 69 73 20 73 70 65 63 69 66 69 65 64 0a  ng is specified.
2d40: 20 20 20 20 28 69 66 20 28 61 6e 64 20 28 65 71      (if (and (eq
2d50: 3f 20 2a 70 61 73 73 6e 75 6d 2a 20 30 29 0a 09  ? *passnum* 0)..
2d60: 20 20 20 20 20 28 61 72 67 73 3a 67 65 74 2d 61       (args:get-a
2d70: 72 67 20 22 2d 6b 65 65 70 67 6f 69 6e 67 22 29  rg "-keepgoing")
2d80: 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 3b 3b 20  )..(begin..  ;; 
2d90: 68 61 76 65 20 74 6f 20 64 65 6c 65 74 65 20 74  have to delete t
2da0: 65 73 74 20 72 65 63 6f 72 64 73 20 77 68 65 72  est records wher
2db0: 65 20 4e 4f 54 5f 53 54 41 52 54 45 44 20 73 69  e NOT_STARTED si
2dc0: 6e 63 65 20 74 68 65 79 20 63 61 6e 20 63 61 75  nce they can cau
2dd0: 73 65 20 2d 6b 65 65 70 67 6f 69 6e 67 20 74 6f  se -keepgoing to
2de0: 20 0a 09 20 20 3b 3b 20 67 65 74 20 73 74 75 63   ..  ;; get stuc
2df0: 6b 20 64 75 65 20 74 6f 20 62 65 63 6f 6d 69 6e  k due to becomin
2e00: 67 20 69 6e 61 63 63 65 73 73 69 62 6c 65 20 66  g inaccessible f
2e10: 72 6f 6d 20 61 20 66 61 69 6c 65 64 20 74 65 73  rom a failed tes
2e20: 74 2e 20 49 2e 65 2e 20 69 66 20 74 65 73 74 20  t. I.e. if test 
2e30: 42 20 64 65 70 65 6e 64 73 20 0a 09 20 20 3b 3b  B depends ..  ;;
2e40: 20 6f 6e 20 74 65 73 74 20 41 20 62 75 74 20 74   on test A but t
2e50: 65 73 74 20 42 20 72 65 61 63 68 65 64 20 74 68  est B reached th
2e60: 65 20 70 6f 69 6e 74 20 6f 6e 20 62 65 69 6e 67  e point on being
2e70: 20 72 65 67 69 73 74 65 72 65 64 20 61 73 20 4e   registered as N
2e80: 4f 54 5f 53 54 41 52 54 45 44 20 61 6e 64 20 74  OT_STARTED and t
2e90: 65 73 74 0a 09 20 20 3b 3b 20 41 20 66 61 69 6c  est..  ;; A fail
2ea0: 65 64 20 66 6f 72 20 73 6f 6d 65 20 72 65 61 73  ed for some reas
2eb0: 6f 6e 20 74 68 65 6e 20 6f 6e 20 72 65 2d 72 75  on then on re-ru
2ec0: 6e 20 75 73 69 6e 67 20 2d 6b 65 65 70 67 6f 69  n using -keepgoi
2ed0: 6e 67 20 74 68 65 20 72 75 6e 20 63 61 6e 20 6e  ng the run can n
2ee0: 65 76 65 72 20 63 6f 6d 70 6c 65 74 65 2e 0a 09  ever complete...
2ef0: 20 20 28 64 62 3a 64 65 6c 65 74 65 2d 74 65 73    (db:delete-tes
2f00: 74 73 2d 69 6e 2d 73 74 61 74 65 20 64 62 20 72  ts-in-state db r
2f10: 75 6e 2d 69 64 20 22 4e 4f 54 5f 53 54 41 52 54  un-id "NOT_START
2f20: 45 44 22 29 0a 09 20 20 28 64 62 3a 73 65 74 2d  ED")..  (db:set-
2f30: 74 65 73 74 73 2d 73 74 61 74 65 2d 73 74 61 74  tests-state-stat
2f40: 75 73 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  us db run-id tes
2f50: 74 2d 6e 61 6d 65 73 20 23 66 20 22 46 41 49 4c  t-names #f "FAIL
2f60: 22 20 22 4e 4f 54 5f 53 54 41 52 54 45 44 22 20  " "NOT_STARTED" 
2f70: 22 46 41 49 4c 22 29 29 29 0a 20 20 20 20 28 73  "FAIL"))).    (s
2f80: 65 74 21 20 2a 70 61 73 73 6e 75 6d 2a 20 28 2b  et! *passnum* (+
2f90: 20 2a 70 61 73 73 6e 75 6d 2a 20 31 29 29 0a 20   *passnum* 1)). 
2fa0: 20 20 20 28 6c 65 74 20 6c 6f 6f 70 20 28 28 6e     (let loop ((n
2fb0: 75 6d 74 69 6d 65 73 20 30 29 29 0a 20 20 20 20  umtimes 0)).    
2fc0: 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 20 20    (for-each .   
2fd0: 20 20 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73      (lambda (tes
2fe0: 74 2d 6e 61 6d 65 29 0a 09 20 28 69 66 20 28 72  t-name).. (if (r
2ff0: 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65  uns:can-run-more
3000: 2d 74 65 73 74 73 20 64 62 29 0a 09 20 20 20 20  -tests db)..    
3010: 20 28 72 75 6e 2d 6f 6e 65 2d 74 65 73 74 20 64   (run-one-test d
3020: 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  b run-id test-na
3030: 6d 65 20 6b 65 79 76 61 6c 6c 73 74 29 0a 09 20  me keyvallst).. 
3040: 20 20 20 20 3b 3b 20 61 64 64 20 73 6f 6d 65 20      ;; add some 
3050: 64 65 6c 61 79 20 0a 09 20 20 20 20 20 28 73 6c  delay ..     (sl
3060: 65 65 70 20 32 29 29 29 0a 20 20 20 20 20 20 20  eep 2))).       
3070: 74 65 73 74 2d 6e 61 6d 65 73 29 0a 20 20 20 20  test-names).    
3080: 20 20 3b 3b 20 28 72 75 6e 2d 77 61 69 74 69 6e    ;; (run-waitin
3090: 67 2d 74 65 73 74 73 20 64 62 29 0a 20 20 20 20  g-tests db).    
30a0: 20 20 28 69 66 20 28 61 72 67 73 3a 67 65 74 2d    (if (args:get-
30b0: 61 72 67 20 22 2d 6b 65 65 70 67 6f 69 6e 67 22  arg "-keepgoing"
30c0: 29 0a 09 20 20 28 6c 65 74 20 28 28 65 73 74 72  )..  (let ((estr
30d0: 65 6d 20 28 64 62 3a 65 73 74 69 6d 61 74 65 64  em (db:estimated
30e0: 2d 74 65 73 74 73 2d 72 65 6d 61 69 6e 69 6e 67  -tests-remaining
30f0: 20 64 62 20 72 75 6e 2d 69 64 29 29 29 0a 09 20   db run-id))).. 
3100: 20 20 20 28 69 66 20 28 3e 20 65 73 74 72 65 6d     (if (> estrem
3110: 20 30 29 0a 09 09 28 62 65 67 69 6e 0a 09 09 20   0)...(begin... 
3120: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20   (debug:print 1 
3130: 22 4b 65 65 70 20 67 6f 69 6e 67 2c 20 65 73 74  "Keep going, est
3140: 69 6d 61 74 65 64 20 22 20 65 73 74 72 65 6d 20  imated " estrem 
3150: 22 20 74 65 73 74 73 20 72 65 6d 61 69 6e 69 6e  " tests remainin
3160: 67 20 74 6f 20 72 75 6e 2c 20 77 69 6c 6c 20 63  g to run, will c
3170: 6f 6e 74 69 6e 75 65 20 69 6e 20 33 20 73 65 63  ontinue in 3 sec
3180: 6f 6e 64 73 20 2e 2e 2e 22 29 0a 09 09 20 20 28  onds ...")...  (
3190: 73 6c 65 65 70 20 33 29 0a 09 09 20 20 28 72 75  sleep 3)...  (ru
31a0: 6e 2d 77 61 69 74 69 6e 67 2d 74 65 73 74 73 20  n-waiting-tests 
31b0: 64 62 29 0a 09 09 20 20 28 6c 6f 6f 70 20 28 2b  db)...  (loop (+
31c0: 20 6e 75 6d 74 69 6d 65 73 20 31 29 29 29 29 29   numtimes 1)))))
31d0: 29 29 29 29 0a 09 20 20 20 0a 3b 3b 20 56 45 52  ))))..   .;; VER
31e0: 59 20 49 4e 45 46 46 49 43 49 45 4e 54 21 20 4d  Y INEFFICIENT! M
31f0: 6f 76 65 20 73 74 75 66 66 20 74 68 61 74 20 73  ove stuff that s
3200: 68 6f 75 6c 64 20 62 65 20 64 6f 6e 65 20 6f 6e  hould be done on
3210: 63 65 20 75 70 20 74 6f 20 63 61 6c 6c 69 6e 67  ce up to calling
3220: 20 70 72 6f 63 0a 28 64 65 66 69 6e 65 20 28 72   proc.(define (r
3230: 75 6e 2d 6f 6e 65 2d 74 65 73 74 20 64 62 20 72  un-one-test db r
3240: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
3250: 6b 65 79 76 61 6c 6c 73 74 29 0a 20 20 28 64 65  keyvallst).  (de
3260: 62 75 67 3a 70 72 69 6e 74 20 31 20 22 4c 61 75  bug:print 1 "Lau
3270: 6e 63 68 69 6e 67 20 74 65 73 74 20 22 20 74 65  nching test " te
3280: 73 74 2d 6e 61 6d 65 29 0a 20 20 3b 3b 20 41 6c  st-name).  ;; Al
3290: 6c 20 74 68 65 73 65 20 76 61 72 73 20 6d 69 67  l these vars mig
32a0: 68 74 20 62 65 20 72 65 66 65 72 65 6e 63 65 64  ht be referenced
32b0: 20 62 79 20 74 68 65 20 74 65 73 74 63 6f 6e 66   by the testconf
32c0: 69 67 20 66 69 6c 65 20 72 65 61 64 65 72 0a 20  ig file reader. 
32d0: 20 28 73 65 74 65 6e 76 20 22 4d 54 5f 54 45 53   (setenv "MT_TES
32e0: 54 5f 4e 41 4d 45 22 20 74 65 73 74 2d 6e 61 6d  T_NAME" test-nam
32f0: 65 29 20 3b 3b 20 0a 20 20 28 73 65 74 65 6e 76  e) ;; .  (setenv
3300: 20 22 4d 54 5f 52 55 4e 4e 41 4d 45 22 20 20 20   "MT_RUNNAME"   
3310: 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 3a  (args:get-arg ":
3320: 72 75 6e 6e 61 6d 65 22 29 29 0a 20 20 28 73 65  runname")).  (se
3330: 74 2d 6d 65 67 61 74 65 73 74 2d 65 6e 76 2d 76  t-megatest-env-v
3340: 61 72 73 20 64 62 20 72 75 6e 2d 69 64 29 20 3b  ars db run-id) ;
3350: 3b 20 74 68 65 73 65 20 6d 61 79 20 62 65 20 6e  ; these may be n
3360: 65 65 64 65 64 20 62 79 20 74 68 65 20 6c 61 75  eeded by the lau
3370: 6e 63 68 69 6e 67 20 70 72 6f 63 65 73 73 0a 20  nching process. 
3380: 20 28 63 68 61 6e 67 65 2d 64 69 72 65 63 74 6f   (change-directo
3390: 72 79 20 2a 74 6f 70 70 61 74 68 2a 29 0a 20 20  ry *toppath*).  
33a0: 28 6c 65 74 2a 20 28 28 74 65 73 74 2d 70 61 74  (let* ((test-pat
33b0: 68 20 20 20 20 28 63 6f 6e 63 20 2a 74 6f 70 70  h    (conc *topp
33c0: 61 74 68 2a 20 22 2f 74 65 73 74 73 2f 22 20 74  ath* "/tests/" t
33d0: 65 73 74 2d 6e 61 6d 65 29 29 0a 09 20 28 74 65  est-name)).. (te
33e0: 73 74 2d 63 6f 6e 66 69 67 66 20 28 63 6f 6e 63  st-configf (conc
33f0: 20 74 65 73 74 2d 70 61 74 68 20 22 2f 74 65 73   test-path "/tes
3400: 74 63 6f 6e 66 69 67 22 29 29 0a 09 20 28 74 65  tconfig")).. (te
3410: 73 74 65 78 69 73 74 73 20 20 20 28 61 6e 64 20  stexists   (and 
3420: 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 74 65  (file-exists? te
3430: 73 74 2d 63 6f 6e 66 69 67 66 29 28 66 69 6c 65  st-configf)(file
3440: 2d 72 65 61 64 2d 61 63 63 65 73 73 3f 20 74 65  -read-access? te
3450: 73 74 2d 63 6f 6e 66 69 67 66 29 29 29 0a 09 20  st-configf))).. 
3460: 28 74 65 73 74 2d 63 6f 6e 66 20 20 20 20 28 69  (test-conf    (i
3470: 66 20 74 65 73 74 65 78 69 73 74 73 20 28 72 65  f testexists (re
3480: 61 64 2d 63 6f 6e 66 69 67 20 74 65 73 74 2d 63  ad-config test-c
3490: 6f 6e 66 69 67 66 29 20 28 6d 61 6b 65 2d 68 61  onfigf) (make-ha
34a0: 73 68 2d 74 61 62 6c 65 29 29 29 0a 09 20 28 77  sh-table))).. (w
34b0: 61 69 74 6f 6e 20 20 20 20 20 20 20 28 6c 65 74  aiton       (let
34c0: 20 28 28 77 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f   ((w (config-loo
34d0: 6b 75 70 20 74 65 73 74 2d 63 6f 6e 66 20 22 72  kup test-conf "r
34e0: 65 71 75 69 72 65 6d 65 6e 74 73 22 20 22 77 61  equirements" "wa
34f0: 69 74 6f 6e 22 29 29 29 0a 09 09 09 20 28 69 66  iton"))).... (if
3500: 20 28 73 74 72 69 6e 67 3f 20 77 29 28 73 74 72   (string? w)(str
3510: 69 6e 67 2d 73 70 6c 69 74 20 77 29 27 28 29 29  ing-split w)'())
3520: 29 29 29 0a 20 20 20 20 28 69 66 20 28 6e 6f 74  ))).    (if (not
3530: 20 74 65 73 74 65 78 69 73 74 73 29 0a 09 28 62   testexists)..(b
3540: 65 67 69 6e 0a 09 20 20 28 64 65 62 75 67 3a 70  egin..  (debug:p
3550: 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 43  rint 0 "ERROR: C
3560: 61 6e 27 74 20 66 69 6e 64 20 63 6f 6e 66 69 67  an't find config
3570: 20 66 69 6c 65 20 22 20 74 65 73 74 2d 63 6f 6e   file " test-con
3580: 66 69 67 66 29 0a 09 20 20 28 65 78 69 74 20 32  figf)..  (exit 2
3590: 29 29 0a 09 3b 3b 20 70 75 74 20 74 6f 70 20 76  ))..;; put top v
35a0: 61 72 73 20 69 6e 74 6f 20 63 6f 6e 76 65 6e 69  ars into conveni
35b0: 65 6e 74 20 76 61 72 69 61 62 6c 65 73 20 61 6e  ent variables an
35c0: 64 20 6f 70 65 6e 20 74 68 65 20 64 62 0a 09 28  d open the db..(
35d0: 6c 65 74 2a 20 28 3b 3b 20 64 62 20 69 73 20 61  let* (;; db is a
35e0: 6c 77 61 79 73 20 61 74 20 2a 74 6f 70 70 61 74  lways at *toppat
35f0: 68 2a 2f 64 62 2f 6d 65 67 61 74 65 73 74 2e 64  h*/db/megatest.d
3600: 62 0a 09 20 20 20 20 20 20 20 28 69 74 65 6d 73  b..       (items
3610: 20 20 20 20 20 20 20 28 68 61 73 68 2d 74 61 62         (hash-tab
3620: 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 74  le-ref/default t
3630: 65 73 74 2d 63 6f 6e 66 20 22 69 74 65 6d 73 22  est-conf "items"
3640: 20 27 28 29 29 29 0a 09 20 20 20 20 20 20 20 28   '()))..       (
3650: 69 74 65 6d 73 74 61 62 6c 65 20 20 28 68 61 73  itemstable  (has
3660: 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61  h-table-ref/defa
3670: 75 6c 74 20 74 65 73 74 2d 63 6f 6e 66 20 22 69  ult test-conf "i
3680: 74 65 6d 73 74 61 62 6c 65 22 20 27 28 29 29 29  temstable" '()))
3690: 0a 09 20 20 20 20 20 20 20 28 61 6c 6c 69 74 65  ..       (allite
36a0: 6d 73 20 20 20 20 28 69 66 20 28 6f 72 20 28 6e  ms    (if (or (n
36b0: 6f 74 20 28 6e 75 6c 6c 3f 20 69 74 65 6d 73 29  ot (null? items)
36c0: 29 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 69 74 65  )(not (null? ite
36d0: 6d 73 74 61 62 6c 65 29 29 29 0a 09 09 09 09 28  mstable))).....(
36e0: 61 70 70 65 6e 64 20 28 69 74 65 6d 2d 61 73 73  append (item-ass
36f0: 6f 63 2d 3e 69 74 65 6d 2d 6c 69 73 74 20 69 74  oc->item-list it
3700: 65 6d 73 29 0a 09 09 09 09 09 28 69 74 65 6d 2d  ems)......(item-
3710: 74 61 62 6c 65 2d 3e 69 74 65 6d 2d 6c 69 73 74  table->item-list
3720: 20 69 74 65 6d 73 74 61 62 6c 65 29 29 0a 09 09   itemstable))...
3730: 09 09 27 28 28 29 29 29 29 20 3b 3b 20 61 20 6c  ..'(()))) ;; a l
3740: 69 73 74 20 77 69 74 68 20 6f 6e 65 20 6e 75 6c  ist with one nul
3750: 6c 20 6c 69 73 74 20 69 73 20 61 20 74 65 73 74  l list is a test
3760: 20 77 69 74 68 20 6e 6f 20 69 74 65 6d 73 0a 09   with no items..
3770: 20 20 20 20 20 20 20 28 72 75 6e 63 6f 6e 66 69         (runconfi
3780: 67 66 20 20 28 63 6f 6e 63 20 20 2a 74 6f 70 70  gf  (conc  *topp
3790: 61 74 68 2a 20 22 2f 72 75 6e 63 6f 6e 66 69 67  ath* "/runconfig
37a0: 73 2e 63 6f 6e 66 69 67 22 29 29 29 0a 09 20 20  s.config")))..  
37b0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22  (debug:print 1 "
37c0: 69 74 65 6d 73 3a 20 22 29 0a 09 20 20 28 69 66  items: ")..  (if
37d0: 20 28 3e 3d 20 2a 76 65 72 62 6f 73 69 74 79 2a   (>= *verbosity*
37e0: 20 31 29 28 70 70 20 61 6c 6c 69 74 65 6d 73 29   1)(pp allitems)
37f0: 29 0a 09 20 20 28 69 66 20 28 3e 3d 20 2a 76 65  )..  (if (>= *ve
3800: 72 62 6f 73 69 74 79 2a 20 35 29 0a 09 20 20 20  rbosity* 5)..   
3810: 20 20 20 28 62 65 67 69 6e 0a 09 09 28 70 72 69     (begin...(pri
3820: 6e 74 20 22 69 74 65 6d 73 3a 20 22 29 28 70 70  nt "items: ")(pp
3830: 20 28 69 74 65 6d 2d 61 73 73 6f 63 2d 3e 69 74   (item-assoc->it
3840: 65 6d 2d 6c 69 73 74 20 69 74 65 6d 73 29 29 0a  em-list items)).
3850: 09 09 28 70 72 69 6e 74 20 22 69 74 65 73 74 61  ..(print "itesta
3860: 62 6c 65 3a 20 22 29 28 70 70 20 28 69 74 65 6d  ble: ")(pp (item
3870: 2d 74 61 62 6c 65 2d 3e 69 74 65 6d 2d 6c 69 73  -table->item-lis
3880: 74 20 69 74 65 6d 73 74 61 62 6c 65 29 29 29 29  t itemstable))))
3890: 0a 09 20 20 28 69 66 20 28 61 72 67 73 3a 67 65  ..  (if (args:ge
38a0: 74 2d 61 72 67 20 22 2d 6d 22 29 0a 09 20 20 20  t-arg "-m")..   
38b0: 20 20 20 28 64 62 3a 73 65 74 2d 63 6f 6d 6d 65     (db:set-comme
38c0: 6e 74 2d 66 6f 72 2d 72 75 6e 20 64 62 20 72 75  nt-for-run db ru
38d0: 6e 2d 69 64 20 28 61 72 67 73 3a 67 65 74 2d 61  n-id (args:get-a
38e0: 72 67 20 22 2d 6d 22 29 29 29 0a 09 20 20 3b 3b  rg "-m")))..  ;;
38f0: 20 62 72 61 69 6e 64 65 61 64 20 77 6f 72 6b 2d   braindead work-
3900: 61 72 6f 75 6e 64 20 66 6f 72 20 70 6f 6f 72 6c  around for poorl
3910: 79 20 73 70 65 63 69 66 69 65 64 20 61 6c 6c 69  y specified alli
3920: 74 65 6d 73 20 6c 69 73 74 20 42 55 47 21 21 21  tems list BUG!!!
3930: 20 46 49 58 4d 45 0a 09 20 20 28 69 66 20 28 6e   FIXME..  (if (n
3940: 75 6c 6c 3f 20 61 6c 6c 69 74 65 6d 73 29 28 73  ull? allitems)(s
3950: 65 74 21 20 61 6c 6c 69 74 65 6d 73 20 27 28 28  et! allitems '((
3960: 29 29 29 29 0a 09 20 20 28 6c 65 74 20 6c 6f 6f  ))))..  (let loo
3970: 70 20 28 28 69 74 65 6d 64 61 74 20 28 63 61 72  p ((itemdat (car
3980: 20 61 6c 6c 69 74 65 6d 73 29 29 0a 09 09 20 20   allitems))...  
3990: 20 20 20 28 74 61 6c 20 20 20 20 20 28 63 64 72     (tal     (cdr
39a0: 20 61 6c 6c 69 74 65 6d 73 29 29 29 0a 09 20 20   allitems)))..  
39b0: 20 20 3b 3b 20 28 6c 61 6d 62 64 61 20 28 69 74    ;; (lambda (it
39c0: 65 6d 64 61 74 29 20 3b 3b 3b 20 28 28 72 69 70  emdat) ;;; ((rip
39d0: 65 6e 65 73 73 20 22 6f 76 65 72 72 69 70 65 22  eness "overripe"
39e0: 29 20 28 74 65 6d 70 65 72 61 74 75 72 65 20 22  ) (temperature "
39f0: 63 6f 6f 6c 22 29 20 28 73 65 61 73 6f 6e 20 22  cool") (season "
3a00: 73 75 6d 6d 65 72 22 29 29 0a 09 20 20 20 20 3b  summer"))..    ;
3a10: 3b 20 48 61 6e 64 6c 65 20 6c 69 73 74 73 20 6f  ; Handle lists o
3a20: 66 20 69 74 65 6d 73 0a 09 20 20 20 20 28 6c 65  f items..    (le
3a30: 74 2a 20 28 28 69 74 65 6d 2d 70 61 74 68 20 20  t* ((item-path  
3a40: 20 20 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70     (item-list->p
3a50: 61 74 68 20 69 74 65 6d 64 61 74 29 29 20 3b 3b  ath itemdat)) ;;
3a60: 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70   (string-intersp
3a70: 65 72 73 65 20 28 6d 61 70 20 63 61 64 72 20 69  erse (map cadr i
3a80: 74 65 6d 64 61 74 29 20 22 2f 22 29 29 0a 09 09  temdat) "/"))...
3a90: 20 20 20 28 6e 65 77 2d 74 65 73 74 2d 70 61 74     (new-test-pat
3aa0: 68 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73  h (string-inters
3ab0: 70 65 72 73 65 20 28 63 6f 6e 73 20 74 65 73 74  perse (cons test
3ac0: 2d 70 61 74 68 20 28 6d 61 70 20 63 61 64 72 20  -path (map cadr 
3ad0: 69 74 65 6d 64 61 74 29 29 20 22 2f 22 29 29 0a  itemdat)) "/")).
3ae0: 09 09 20 20 20 28 6e 65 77 2d 74 65 73 74 2d 6e  ..   (new-test-n
3af0: 61 6d 65 20 28 69 66 20 28 65 71 75 61 6c 3f 20  ame (if (equal? 
3b00: 69 74 65 6d 2d 70 61 74 68 20 22 22 29 20 74 65  item-path "") te
3b10: 73 74 2d 6e 61 6d 65 20 28 63 6f 6e 63 20 74 65  st-name (conc te
3b20: 73 74 2d 6e 61 6d 65 20 22 2f 22 20 69 74 65 6d  st-name "/" item
3b30: 2d 70 61 74 68 29 29 29 20 3b 3b 20 6a 75 73 74  -path))) ;; just
3b40: 20 6e 65 65 64 20 69 74 20 74 6f 20 62 65 20 75   need it to be u
3b50: 6e 69 71 75 65 0a 09 09 20 20 20 28 74 65 73 74  nique...   (test
3b60: 64 61 74 20 20 20 23 66 29 0a 09 09 20 20 20 28  dat   #f)...   (
3b70: 6e 75 6d 2d 72 75 6e 6e 69 6e 67 20 28 64 62 3a  num-running (db:
3b80: 67 65 74 2d 63 6f 75 6e 74 2d 74 65 73 74 73 2d  get-count-tests-
3b90: 72 75 6e 6e 69 6e 67 20 64 62 29 29 0a 09 09 20  running db))... 
3ba0: 20 20 28 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e    (max-concurren
3bb0: 74 2d 6a 6f 62 73 20 28 63 6f 6e 66 69 67 2d 6c  t-jobs (config-l
3bc0: 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67 64 61 74  ookup *configdat
3bd0: 2a 20 22 73 65 74 75 70 22 20 22 6d 61 78 5f 63  * "setup" "max_c
3be0: 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f 62 73 22 29  oncurrent_jobs")
3bf0: 29 0a 09 09 20 20 20 28 70 61 72 65 6e 74 2d 74  )...   (parent-t
3c00: 65 73 74 20 28 61 6e 64 20 28 6e 6f 74 20 28 6e  est (and (not (n
3c10: 75 6c 6c 3f 20 69 74 65 6d 73 29 29 28 65 71 75  ull? items))(equ
3c20: 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 22  al? item-path ""
3c30: 29 29 29 0a 09 09 20 20 20 28 73 69 6e 67 6c 65  )))...   (single
3c40: 2d 74 65 73 74 20 28 61 6e 64 20 28 6e 75 6c 6c  -test (and (null
3c50: 3f 20 69 74 65 6d 73 29 20 28 65 71 75 61 6c 3f  ? items) (equal?
3c60: 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29 29 29   item-path "")))
3c70: 0a 09 09 20 20 20 28 69 74 65 6d 2d 74 65 73 74  ...   (item-test
3c80: 20 20 20 28 6e 6f 74 20 28 65 71 75 61 6c 3f 20     (not (equal? 
3c90: 69 74 65 6d 2d 70 61 74 68 20 22 22 29 29 29 29  item-path ""))))
3ca0: 0a 09 20 20 20 20 20 20 28 64 65 62 75 67 3a 70  ..      (debug:p
3cb0: 72 69 6e 74 20 33 20 22 6d 61 78 2d 63 6f 6e 63  rint 3 "max-conc
3cc0: 75 72 72 65 6e 74 2d 6a 6f 62 73 3a 20 22 20 6d  urrent-jobs: " m
3cd0: 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f  ax-concurrent-jo
3ce0: 62 73 20 22 2c 20 6e 75 6d 2d 72 75 6e 6e 69 6e  bs ", num-runnin
3cf0: 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67  g: " num-running
3d00: 29 0a 09 20 20 20 20 20 20 28 69 66 20 28 72 75  )..      (if (ru
3d10: 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65 2d  ns:can-run-more-
3d20: 74 65 73 74 73 20 64 62 29 0a 09 09 20 20 28 62  tests db)...  (b
3d30: 65 67 69 6e 0a 09 09 20 20 20 20 28 6c 65 74 20  egin...    (let 
3d40: 6c 6f 6f 70 32 20 28 28 74 73 20 28 64 62 3a 67  loop2 ((ts (db:g
3d50: 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 20  et-test-info db 
3d60: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
3d70: 20 69 74 65 6d 2d 70 61 74 68 29 29 20 3b 3b 20   item-path)) ;; 
3d80: 23 66 29 0a 09 09 09 09 28 63 74 20 30 29 29 0a  #f).....(ct 0)).
3d90: 09 09 20 20 20 20 20 20 28 69 66 20 28 61 6e 64  ..      (if (and
3da0: 20 28 6e 6f 74 20 74 73 29 0a 09 09 09 20 20 20   (not ts)....   
3db0: 20 20 20 20 28 3c 20 63 74 20 31 30 29 29 0a 09      (< ct 10))..
3dc0: 09 09 20 20 28 62 65 67 69 6e 0a 09 09 09 20 20  ..  (begin....  
3dd0: 20 20 28 72 65 67 69 73 74 65 72 2d 74 65 73 74    (register-test
3de0: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d   db run-id test-
3df0: 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 0a  name item-path).
3e00: 09 09 09 20 20 20 20 28 64 62 3a 74 65 73 74 2d  ...    (db:test-
3e10: 73 65 74 2d 63 6f 6d 6d 65 6e 74 20 64 62 20 72  set-comment db r
3e20: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
3e30: 69 74 65 6d 2d 70 61 74 68 20 22 22 29 0a 09 09  item-path "")...
3e40: 09 20 20 20 20 28 6c 6f 6f 70 32 20 28 64 62 3a  .    (loop2 (db:
3e50: 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62  get-test-info db
3e60: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
3e70: 65 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 09 09  e item-path)....
3e80: 09 20 20 20 28 2b 20 63 74 20 31 29 29 29 0a 09  .   (+ ct 1)))..
3e90: 09 09 20 20 28 69 66 20 74 73 0a 09 09 09 20 20  ..  (if ts....  
3ea0: 20 20 20 20 28 73 65 74 21 20 74 65 73 74 64 61      (set! testda
3eb0: 74 20 74 73 29 0a 09 09 09 20 20 20 20 20 20 28  t ts)....      (
3ec0: 62 65 67 69 6e 0a 09 09 09 09 28 64 65 62 75 67  begin.....(debug
3ed0: 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e  :print 0 "WARNIN
3ee0: 47 3a 20 43 6f 75 6c 64 6e 27 74 20 72 65 67 69  G: Couldn't regi
3ef0: 73 74 65 72 20 74 65 73 74 20 22 20 74 65 73 74  ster test " test
3f00: 2d 6e 61 6d 65 20 22 20 77 69 74 68 20 69 74 65  -name " with ite
3f10: 6d 20 70 61 74 68 20 22 20 69 74 65 6d 2d 70 61  m path " item-pa
3f20: 74 68 20 22 2c 20 73 6b 69 70 70 69 6e 67 22 29  th ", skipping")
3f30: 0a 09 09 09 09 28 69 66 20 28 6e 6f 74 20 28 6e  .....(if (not (n
3f40: 75 6c 6c 3f 20 74 61 6c 29 29 0a 09 09 09 09 20  ull? tal))..... 
3f50: 20 20 20 28 6c 6f 6f 70 20 28 63 61 72 20 74 61     (loop (car ta
3f60: 6c 29 28 63 64 72 20 74 61 6c 29 29 29 29 29 29  l)(cdr tal))))))
3f70: 29 0a 09 09 20 20 20 20 28 63 68 61 6e 67 65 2d  )...    (change-
3f80: 64 69 72 65 63 74 6f 72 79 20 74 65 73 74 2d 70  directory test-p
3f90: 61 74 68 29 0a 09 09 20 20 20 20 3b 3b 20 74 68  ath)...    ;; th
3fa0: 69 73 20 62 6c 6f 63 6b 20 69 73 20 68 65 72 65  is block is here
3fb0: 20 6f 6e 6c 79 20 74 6f 20 69 6e 66 6f 72 6d 20   only to inform 
3fc0: 74 68 65 20 75 73 65 72 20 65 61 72 6c 79 20 6f  the user early o
3fd0: 6e 0a 09 09 20 20 20 20 28 69 66 20 28 66 69 6c  n...    (if (fil
3fe0: 65 2d 65 78 69 73 74 73 3f 20 72 75 6e 63 6f 6e  e-exists? runcon
3ff0: 66 69 67 66 29 0a 09 09 09 28 73 65 74 75 70 2d  figf)....(setup-
4000: 65 6e 76 2d 64 65 66 61 75 6c 74 73 20 64 62 20  env-defaults db 
4010: 72 75 6e 63 6f 6e 66 69 67 66 20 72 75 6e 2d 69  runconfigf run-i
4020: 64 20 2a 61 6c 72 65 61 64 79 2d 73 65 65 6e 2d  d *already-seen-
4030: 72 75 6e 63 6f 6e 66 69 67 2d 69 6e 66 6f 2a 29  runconfig-info*)
4040: 0a 09 09 09 28 64 65 62 75 67 3a 70 72 69 6e 74  ....(debug:print
4050: 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 59 6f 75   0 "WARNING: You
4060: 20 64 6f 20 6e 6f 74 20 68 61 76 65 20 61 20 72   do not have a r
4070: 75 6e 20 63 6f 6e 66 69 67 20 66 69 6c 65 3a 20  un config file: 
4080: 22 20 72 75 6e 63 6f 6e 66 69 67 66 29 29 0a 09  " runconfigf))..
4090: 09 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e  .    (debug:prin
40a0: 74 20 34 20 22 72 75 6e 2d 69 64 3a 20 22 20 72  t 4 "run-id: " r
40b0: 75 6e 2d 69 64 20 22 20 74 65 73 74 2d 6e 61 6d  un-id " test-nam
40c0: 65 3a 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22  e: " test-name "
40d0: 20 69 74 65 6d 2d 70 61 74 68 3a 20 22 20 69 74   item-path: " it
40e0: 65 6d 2d 70 61 74 68 20 22 20 74 65 73 74 64 61  em-path " testda
40f0: 74 3a 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73  t: " (test:get-s
4100: 74 61 74 75 73 20 74 65 73 74 64 61 74 29 20 22  tatus testdat) "
4110: 20 74 65 73 74 2d 73 74 61 74 65 3a 20 22 20 28   test-state: " (
4120: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74  test:get-state t
4130: 65 73 74 64 61 74 29 29 0a 09 09 20 20 20 20 28  estdat))...    (
4140: 63 61 73 65 20 28 69 66 20 28 61 72 67 73 3a 67  case (if (args:g
4150: 65 74 2d 61 72 67 20 22 2d 66 6f 72 63 65 22 29  et-arg "-force")
4160: 0a 09 09 09 20 20 20 20 20 20 27 4e 4f 54 5f 53  ....      'NOT_S
4170: 54 41 52 54 45 44 0a 09 09 09 20 20 20 20 20 20  TARTED....      
4180: 28 69 66 20 74 65 73 74 64 61 74 0a 09 09 09 09  (if testdat.....
4190: 20 20 28 73 74 72 69 6e 67 2d 3e 73 79 6d 62 6f    (string->symbo
41a0: 6c 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74  l (test:get-stat
41b0: 65 20 74 65 73 74 64 61 74 29 29 0a 09 09 09 09  e testdat)).....
41c0: 20 20 27 66 61 69 6c 65 64 2d 74 6f 2d 69 6e 73    'failed-to-ins
41d0: 65 72 74 29 29 0a 09 09 20 20 20 20 20 20 28 28  ert))...      ((
41e0: 66 61 69 6c 65 64 2d 74 6f 2d 69 6e 73 65 72 74  failed-to-insert
41f0: 29 0a 09 09 20 20 20 20 20 20 20 28 64 65 62 75  )...       (debu
4200: 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52  g:print 0 "ERROR
4210: 3a 20 46 61 69 6c 65 64 20 74 6f 20 69 6e 73 65  : Failed to inse
4220: 72 74 20 74 68 65 20 72 65 63 6f 72 64 20 69 6e  rt the record in
4230: 74 6f 20 74 68 65 20 64 62 22 29 29 0a 09 09 20  to the db"))... 
4240: 20 20 20 20 20 28 28 4e 4f 54 5f 53 54 41 52 54       ((NOT_START
4250: 45 44 20 43 4f 4d 50 4c 45 54 45 44 29 0a 09 09  ED COMPLETED)...
4260: 20 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72         (debug:pr
4270: 69 6e 74 20 36 20 22 47 6f 74 20 68 65 72 65 2c  int 6 "Got here,
4280: 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61   " (test:get-sta
4290: 74 65 20 74 65 73 74 64 61 74 29 29 0a 09 09 20  te testdat))... 
42a0: 20 20 20 20 20 20 28 6c 65 74 20 28 28 72 75 6e        (let ((run
42b0: 66 6c 61 67 20 23 66 29 29 0a 09 09 09 20 28 63  flag #f)).... (c
42c0: 6f 6e 64 0a 09 09 09 20 20 3b 3b 20 69 2e 65 2e  ond....  ;; i.e.
42d0: 20 74 68 69 73 20 69 73 20 74 68 65 20 70 61 72   this is the par
42e0: 65 6e 74 20 74 65 73 74 20 74 6f 20 61 20 73 75  ent test to a su
42f0: 69 74 65 20 6f 66 20 69 74 65 6d 73 2c 20 6e 65  ite of items, ne
4300: 76 65 72 20 22 72 75 6e 22 20 69 74 0a 09 09 09  ver "run" it....
4310: 20 20 28 70 61 72 65 6e 74 2d 74 65 73 74 0a 09    (parent-test..
4320: 09 09 20 20 20 28 73 65 74 21 20 72 75 6e 66 6c  ..   (set! runfl
4330: 61 67 20 23 66 29 29 0a 09 09 09 20 20 3b 3b 20  ag #f))....  ;; 
4340: 2d 66 6f 72 63 65 2c 20 72 75 6e 20 6e 6f 20 6d  -force, run no m
4350: 61 74 74 65 72 20 77 68 61 74 0a 09 09 09 20 20  atter what....  
4360: 28 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22  ((args:get-arg "
4370: 2d 66 6f 72 63 65 22 29 28 73 65 74 21 20 72 75  -force")(set! ru
4380: 6e 66 6c 61 67 20 23 74 29 29 0a 09 09 09 20 20  nflag #t))....  
4390: 3b 3b 20 4e 4f 54 5f 53 54 41 52 54 45 44 2c 20  ;; NOT_STARTED, 
43a0: 72 75 6e 20 6e 6f 20 6d 61 74 74 65 72 20 77 68  run no matter wh
43b0: 61 74 0a 09 09 09 20 20 28 28 65 71 75 61 6c 3f  at....  ((equal?
43c0: 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65   (test:get-state
43d0: 20 74 65 73 74 64 61 74 29 20 22 4e 4f 54 5f 53   testdat) "NOT_S
43e0: 54 41 52 54 45 44 22 29 28 73 65 74 21 20 72 75  TARTED")(set! ru
43f0: 6e 66 6c 61 67 20 23 74 29 29 0a 09 09 09 20 20  nflag #t))....  
4400: 3b 3b 20 6e 6f 74 20 2d 72 65 72 75 6e 20 61 6e  ;; not -rerun an
4410: 64 20 50 41 53 53 2c 20 57 41 52 4e 20 6f 72 20  d PASS, WARN or 
4420: 43 48 45 43 4b 2c 20 64 6f 20 6e 6f 20 72 75 6e  CHECK, do no run
4430: 0a 09 09 09 20 20 28 28 61 6e 64 20 28 6f 72 20  ....  ((and (or 
4440: 28 6e 6f 74 20 28 61 72 67 73 3a 67 65 74 2d 61  (not (args:get-a
4450: 72 67 20 22 2d 72 65 72 75 6e 22 29 29 0a 09 09  rg "-rerun"))...
4460: 09 09 20 20 20 20 28 61 72 67 73 3a 67 65 74 2d  ..    (args:get-
4470: 61 72 67 20 22 2d 6b 65 65 70 67 6f 69 6e 67 22  arg "-keepgoing"
4480: 29 29 0a 09 09 09 09 28 6d 65 6d 62 65 72 20 28  )).....(member (
4490: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20  test:get-status 
44a0: 74 65 73 74 64 61 74 29 20 27 28 22 50 41 53 53  testdat) '("PASS
44b0: 22 20 22 57 41 52 4e 22 20 22 43 48 45 43 4b 22  " "WARN" "CHECK"
44c0: 29 29 29 0a 09 09 09 20 20 20 28 73 65 74 21 20  )))....   (set! 
44d0: 72 75 6e 66 6c 61 67 20 23 66 29 29 0a 09 09 09  runflag #f))....
44e0: 20 20 3b 3b 20 2d 72 65 72 75 6e 20 61 6e 64 20    ;; -rerun and 
44f0: 73 74 61 74 75 73 20 69 73 20 6f 6e 65 20 6f 66  status is one of
4500: 20 74 68 65 20 73 70 65 63 69 66 65 64 2c 20 72   the specifed, r
4510: 75 6e 20 69 74 0a 09 09 09 20 20 28 28 61 6e 64  un it....  ((and
4520: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22   (args:get-arg "
4530: 2d 72 65 72 75 6e 22 29 0a 09 09 09 09 28 6c 65  -rerun").....(le
4540: 74 20 28 28 72 65 72 75 6e 6c 73 74 20 28 73 74  t ((rerunlst (st
4550: 72 69 6e 67 2d 73 70 6c 69 74 20 28 61 72 67 73  ring-split (args
4560: 3a 67 65 74 2d 61 72 67 20 22 2d 72 65 72 75 6e  :get-arg "-rerun
4570: 22 29 20 22 2c 22 29 29 29 20 3b 3b 20 46 41 49  ") ","))) ;; FAI
4580: 4c 2c 0a 09 09 09 09 20 20 28 6d 65 6d 62 65 72  L,.....  (member
4590: 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75   (test:get-statu
45a0: 73 20 74 65 73 74 64 61 74 29 20 72 65 72 75 6e  s testdat) rerun
45b0: 6c 73 74 29 29 29 0a 09 09 09 20 20 20 28 73 65  lst)))....   (se
45c0: 74 21 20 72 75 6e 66 6c 61 67 20 23 74 29 29 0a  t! runflag #t)).
45d0: 09 09 09 20 20 3b 3b 20 2d 6b 65 65 70 67 6f 69  ...  ;; -keepgoi
45e0: 6e 67 2c 20 64 6f 20 6e 6f 74 20 72 65 72 75 6e  ng, do not rerun
45f0: 20 46 41 49 4c 0a 09 09 09 20 20 28 28 61 6e 64   FAIL....  ((and
4600: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22   (args:get-arg "
4610: 2d 6b 65 65 70 67 6f 69 6e 67 22 29 0a 09 09 09  -keepgoing")....
4620: 09 28 6d 65 6d 62 65 72 20 28 74 65 73 74 3a 67  .(member (test:g
4630: 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61  et-status testda
4640: 74 29 20 27 28 22 46 41 49 4c 22 29 29 29 0a 09  t) '("FAIL")))..
4650: 09 09 20 20 20 28 73 65 74 21 20 72 75 6e 66 6c  ..   (set! runfl
4660: 61 67 20 23 66 29 29 0a 09 09 09 20 20 28 28 61  ag #f))....  ((a
4670: 6e 64 20 28 6e 6f 74 20 28 61 72 67 73 3a 67 65  nd (not (args:ge
4680: 74 2d 61 72 67 20 22 2d 72 65 72 75 6e 22 29 29  t-arg "-rerun"))
4690: 0a 09 09 09 09 28 6d 65 6d 62 65 72 20 28 74 65  .....(member (te
46a0: 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65  st:get-status te
46b0: 73 74 64 61 74 29 20 27 28 22 46 41 49 4c 22 20  stdat) '("FAIL" 
46c0: 22 6e 2f 61 22 29 29 29 0a 09 09 09 20 20 20 28  "n/a")))....   (
46d0: 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 74 29  set! runflag #t)
46e0: 29 0a 09 09 09 20 20 28 65 6c 73 65 20 28 73 65  )....  (else (se
46f0: 74 21 20 72 75 6e 66 6c 61 67 20 23 66 29 29 29  t! runflag #f)))
4700: 0a 09 09 09 20 28 64 65 62 75 67 3a 70 72 69 6e  .... (debug:prin
4710: 74 20 36 20 22 52 55 4e 4e 49 4e 47 20 3d 3e 20  t 6 "RUNNING => 
4720: 72 75 6e 66 6c 61 67 3a 20 22 20 72 75 6e 66 6c  runflag: " runfl
4730: 61 67 20 22 20 53 54 41 54 45 3a 20 22 20 28 74  ag " STATE: " (t
4740: 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65  est:get-state te
4750: 73 74 64 61 74 29 20 22 20 53 54 41 54 55 53 3a  stdat) " STATUS:
4760: 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61   " (test:get-sta
4770: 74 75 73 20 74 65 73 74 64 61 74 29 29 0a 09 09  tus testdat))...
4780: 09 20 28 69 66 20 28 6e 6f 74 20 72 75 6e 66 6c  . (if (not runfl
4790: 61 67 29 0a 09 09 09 20 20 20 20 20 28 69 66 20  ag)....     (if 
47a0: 28 6e 6f 74 20 70 61 72 65 6e 74 2d 74 65 73 74  (not parent-test
47b0: 29 0a 09 09 09 09 20 28 64 65 62 75 67 3a 70 72  )..... (debug:pr
47c0: 69 6e 74 20 31 20 22 4e 4f 54 45 3a 20 4e 6f 74  int 1 "NOTE: Not
47d0: 20 73 74 61 72 74 69 6e 67 20 74 65 73 74 20 22   starting test "
47e0: 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20 22   new-test-name "
47f0: 20 61 73 20 69 74 20 69 73 20 73 74 61 74 65 20   as it is state 
4800: 5c 22 43 4f 4d 50 4c 45 54 45 44 5c 22 20 61 6e  \"COMPLETED\" an
4810: 64 20 73 74 61 74 75 73 20 5c 22 22 20 28 74 65  d status \"" (te
4820: 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65  st:get-status te
4830: 73 74 64 61 74 29 20 22 5c 22 2c 20 75 73 65 20  stdat) "\", use 
4840: 2d 66 6f 72 63 65 20 74 6f 20 6f 76 65 72 72 69  -force to overri
4850: 64 65 22 29 29 0a 09 09 09 20 20 20 20 20 28 6c  de"))....     (l
4860: 65 74 2a 20 28 28 67 65 74 2d 70 72 65 72 65 71  et* ((get-prereq
4870: 73 2d 63 6d 64 20 28 6c 61 6d 62 64 61 20 28 29  s-cmd (lambda ()
4880: 0a 09 09 09 09 09 09 20 20 20 20 20 20 20 28 64  .......       (d
4890: 62 2d 67 65 74 2d 70 72 65 72 65 71 73 2d 6e 6f  b-get-prereqs-no
48a0: 74 2d 6d 65 74 20 64 62 20 72 75 6e 2d 69 64 20  t-met db run-id 
48b0: 77 61 69 74 6f 6e 29 29 29 20 3b 3b 20 63 68 65  waiton))) ;; che
48c0: 63 6b 20 62 65 66 6f 72 65 20 72 75 6e 6e 69 6e  ck before runnin
48d0: 67 20 2e 2e 2e 2e 0a 09 09 09 09 20 20 20 20 28  g .........    (
48e0: 6c 61 75 6e 63 68 2d 63 6d 64 20 20 20 20 20 20  launch-cmd      
48f0: 28 6c 61 6d 62 64 61 20 28 29 0a 09 09 09 09 09  (lambda ()......
4900: 09 20 20 20 20 20 20 20 28 6c 61 75 6e 63 68 2d  .       (launch-
4910: 74 65 73 74 20 64 62 20 72 75 6e 2d 69 64 20 74  test db run-id t
4920: 65 73 74 2d 63 6f 6e 66 20 6b 65 79 76 61 6c 6c  est-conf keyvall
4930: 73 74 20 74 65 73 74 2d 6e 61 6d 65 20 74 65 73  st test-name tes
4940: 74 2d 70 61 74 68 20 69 74 65 6d 64 61 74 29 29  t-path itemdat))
4950: 29 0a 09 09 09 09 20 20 20 20 28 74 65 73 74 72  ).....    (testr
4960: 75 6e 64 61 74 20 20 20 20 20 20 28 6c 69 73 74  undat      (list
4970: 20 67 65 74 2d 70 72 65 72 65 71 73 2d 63 6d 64   get-prereqs-cmd
4980: 20 6c 61 75 6e 63 68 2d 63 6d 64 29 29 29 0a 09   launch-cmd)))..
4990: 09 09 20 20 20 20 20 20 20 28 69 66 20 28 6f 72  ..       (if (or
49a0: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22   (args:get-arg "
49b0: 2d 66 6f 72 63 65 22 29 0a 09 09 09 09 20 20 20  -force").....   
49c0: 20 20 20 20 28 6e 75 6c 6c 3f 20 28 28 63 61 72      (null? ((car
49d0: 20 74 65 73 74 72 75 6e 64 61 74 29 29 29 29 20   testrundat)))) 
49e0: 3b 3b 20 61 72 65 20 74 68 65 72 65 20 61 6e 79  ;; are there any
49f0: 20 74 65 73 74 73 20 74 68 61 74 20 6d 75 73 74   tests that must
4a00: 20 62 65 20 72 75 6e 20 62 65 66 6f 72 65 20 74   be run before t
4a10: 68 69 73 20 6f 6e 65 2e 2e 2e 0a 09 09 09 09 20  his one........ 
4a20: 20 20 28 28 63 61 64 72 20 74 65 73 74 72 75 6e    ((cadr testrun
4a30: 64 61 74 29 29 20 3b 3b 20 74 68 69 73 20 69 73  dat)) ;; this is
4a40: 20 74 68 65 20 6c 69 6e 65 20 74 68 61 74 20 6c   the line that l
4a50: 61 75 6e 63 68 65 73 20 74 68 65 20 74 65 73 74  aunches the test
4a60: 20 74 6f 20 74 68 65 20 72 65 6d 6f 74 65 20 68   to the remote h
4a70: 6f 73 74 0a 09 09 09 09 20 20 20 28 69 66 20 28  ost.....   (if (
4a80: 6e 6f 74 20 28 61 72 67 73 3a 67 65 74 2d 61 72  not (args:get-ar
4a90: 67 20 22 2d 6b 65 65 70 67 6f 69 6e 67 22 29 29  g "-keepgoing"))
4aa0: 0a 09 09 09 09 20 20 20 20 20 20 20 28 68 61 73  .....       (has
4ab0: 68 2d 74 61 62 6c 65 2d 73 65 74 21 20 2a 77 61  h-table-set! *wa
4ac0: 69 74 69 6e 67 2d 71 75 65 75 65 2a 20 6e 65 77  iting-queue* new
4ad0: 2d 74 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 72  -test-name testr
4ae0: 75 6e 64 61 74 29 29 29 29 29 29 29 0a 09 09 20  undat)))))))... 
4af0: 20 20 20 20 20 28 28 4b 49 4c 4c 45 44 29 20 0a       ((KILLED) .
4b00: 09 09 20 20 20 20 20 20 20 28 64 65 62 75 67 3a  ..       (debug:
4b10: 70 72 69 6e 74 20 31 20 22 4e 4f 54 45 3a 20 22  print 1 "NOTE: "
4b20: 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20 22   new-test-name "
4b30: 20 69 73 20 61 6c 72 65 61 64 79 20 72 75 6e 6e   is already runn
4b40: 69 6e 67 20 6f 72 20 77 61 73 20 65 78 70 6c 69  ing or was expli
4b50: 63 74 6c 79 20 6b 69 6c 6c 65 64 2c 20 75 73 65  ctly killed, use
4b60: 20 2d 66 6f 72 63 65 20 74 6f 20 6c 61 75 6e 63   -force to launc
4b70: 68 20 69 74 2e 22 29 29 0a 09 09 20 20 20 20 20  h it."))...     
4b80: 20 28 28 4c 41 55 4e 43 48 45 44 20 52 45 4d 4f   ((LAUNCHED REMO
4b90: 54 45 48 4f 53 54 53 54 41 52 54 20 52 55 4e 4e  TEHOSTSTART RUNN
4ba0: 49 4e 47 29 20 20 0a 09 09 20 20 20 20 20 20 20  ING)  ...       
4bb0: 28 69 66 20 28 3e 20 28 2d 20 28 63 75 72 72 65  (if (> (- (curre
4bc0: 6e 74 2d 73 65 63 6f 6e 64 73 29 28 2b 20 28 64  nt-seconds)(+ (d
4bd0: 62 3a 74 65 73 74 2d 67 65 74 2d 65 76 65 6e 74  b:test-get-event
4be0: 5f 74 69 6d 65 20 74 65 73 74 64 61 74 29 0a 09  _time testdat)..
4bf0: 09 09 09 09 09 20 20 20 20 20 28 64 62 3a 74 65  .....     (db:te
4c00: 73 74 2d 67 65 74 2d 72 75 6e 5f 64 75 72 61 74  st-get-run_durat
4c10: 69 6f 6e 20 74 65 73 74 64 61 74 29 29 29 0a 09  ion testdat)))..
4c20: 09 09 20 20 20 20 20 20 31 30 30 29 20 3b 3b 20  ..      100) ;; 
4c30: 69 2e 65 2e 20 6e 6f 20 75 70 64 61 74 65 20 66  i.e. no update f
4c40: 6f 72 20 6d 6f 72 65 20 74 68 61 6e 20 31 30 30  or more than 100
4c50: 20 73 65 63 6f 6e 64 73 0a 09 09 09 20 20 20 28   seconds....   (
4c60: 62 65 67 69 6e 0a 09 09 09 20 20 20 20 20 28 64  begin....     (d
4c70: 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41  ebug:print 0 "WA
4c80: 52 4e 49 4e 47 3a 20 54 65 73 74 20 22 20 74 65  RNING: Test " te
4c90: 73 74 2d 6e 61 6d 65 20 22 20 61 70 70 65 61 72  st-name " appear
4ca0: 73 20 74 6f 20 62 65 20 64 65 61 64 2e 20 46 6f  s to be dead. Fo
4cb0: 72 63 69 6e 67 20 69 74 20 74 6f 20 73 74 61 74  rcing it to stat
4cc0: 65 20 49 4e 43 4f 4d 50 4c 45 54 45 20 61 6e 64  e INCOMPLETE and
4cd0: 20 73 74 61 74 75 73 20 53 54 55 43 4b 2f 44 45   status STUCK/DE
4ce0: 41 44 22 29 0a 09 09 09 20 20 20 20 20 28 74 65  AD")....     (te
4cf0: 73 74 2d 73 65 74 2d 73 74 61 74 75 73 21 20 64  st-set-status! d
4d00: 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  b run-id test-na
4d10: 6d 65 20 22 49 4e 43 4f 4d 50 4c 45 54 45 22 20  me "INCOMPLETE" 
4d20: 22 53 54 55 43 4b 2f 44 45 41 44 22 20 69 74 65  "STUCK/DEAD" ite
4d30: 6d 64 61 74 20 22 54 65 73 74 20 69 73 20 73 74  mdat "Test is st
4d40: 75 63 6b 20 6f 72 20 64 65 61 64 22 29 29 0a 09  uck or dead"))..
4d50: 09 09 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e  ..   (debug:prin
4d60: 74 20 32 20 22 4e 4f 54 45 3a 20 22 20 74 65 73  t 2 "NOTE: " tes
4d70: 74 2d 6e 61 6d 65 20 22 20 69 73 20 61 6c 72 65  t-name " is alre
4d80: 61 64 79 20 72 75 6e 6e 69 6e 67 22 29 29 29 0a  ady running"))).
4d90: 09 09 20 20 20 20 20 20 28 65 6c 73 65 20 20 20  ..      (else   
4da0: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
4db0: 20 30 20 22 45 52 52 4f 52 3a 20 46 61 69 6c 65   0 "ERROR: Faile
4dc0: 64 20 74 6f 20 6c 61 75 6e 63 68 20 74 65 73 74  d to launch test
4dd0: 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65   " new-test-name
4de0: 20 22 2e 20 55 6e 72 65 63 6f 67 6e 69 73 65 64   ". Unrecognised
4df0: 20 73 74 61 74 65 20 22 20 28 74 65 73 74 3a 67   state " (test:g
4e00: 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 74  et-state testdat
4e10: 29 29 29 29 29 29 0a 09 20 20 20 20 20 20 28 69  ))))))..      (i
4e20: 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 61  f (not (null? ta
4e30: 6c 29 29 0a 09 09 20 20 28 6c 6f 6f 70 20 28 63  l))...  (loop (c
4e40: 61 72 20 74 61 6c 29 28 63 64 72 20 74 61 6c 29  ar tal)(cdr tal)
4e50: 29 29 29 29 29 29 29 29 0a 0a 28 64 65 66 69 6e  ))))))))..(defin
4e60: 65 20 28 72 75 6e 2d 77 61 69 74 69 6e 67 2d 74  e (run-waiting-t
4e70: 65 73 74 73 20 64 62 29 0a 20 20 28 6c 65 74 20  ests db).  (let 
4e80: 28 28 6e 75 6d 74 72 69 65 73 20 20 20 20 20 20  ((numtries      
4e90: 20 20 20 20 20 30 29 0a 09 28 6c 61 73 74 2d 74       0)..(last-t
4ea0: 72 79 2d 74 69 6d 65 20 20 20 20 20 20 28 63 75  ry-time      (cu
4eb0: 72 72 65 6e 74 2d 73 65 63 6f 6e 64 73 29 29 0a  rrent-seconds)).
4ec0: 09 28 74 69 6d 65 73 20 20 20 20 20 20 20 20 20  .(times         
4ed0: 20 20 20 20 20 28 6c 69 73 74 20 31 29 29 29 20       (list 1))) 
4ee0: 3b 3b 20 6d 69 6e 75 74 65 73 20 74 6f 20 77 61  ;; minutes to wa
4ef0: 69 74 20 62 65 66 6f 72 65 20 74 72 79 69 6e 67  it before trying
4f00: 20 61 67 61 69 6e 20 74 6f 20 6b 69 63 6b 20 6f   again to kick o
4f10: 66 66 20 72 75 6e 73 0a 20 20 20 20 3b 3b 20 42  ff runs.    ;; B
4f20: 55 47 20 74 68 69 73 20 68 61 63 6b 20 6f 66 20  UG this hack of 
4f30: 62 72 75 74 65 20 66 6f 72 63 65 20 72 65 74 72  brute force retr
4f40: 79 69 6e 67 20 77 6f 72 6b 73 20 71 75 69 74 65  ying works quite
4f50: 20 77 65 6c 6c 20 66 6f 72 20 6d 61 6e 79 20 63   well for many c
4f60: 61 73 65 73 20 62 75 74 20 0a 20 20 20 20 3b 3b  ases but .    ;;
4f70: 20 20 20 20 20 77 68 61 74 20 69 73 20 6e 65 65       what is nee
4f80: 64 65 64 20 69 73 20 74 6f 20 63 68 65 63 6b 20  ded is to check 
4f90: 74 68 65 20 64 62 20 66 6f 72 20 74 65 73 74 73  the db for tests
4fa0: 20 74 68 61 74 20 68 61 76 65 20 66 61 69 6c 65   that have faile
4fb0: 64 20 6c 65 73 73 20 74 68 61 6e 0a 20 20 20 20  d less than.    
4fc0: 3b 3b 20 20 20 20 20 4e 20 74 69 6d 65 73 20 6f  ;;     N times o
4fd0: 72 20 6e 65 76 65 72 20 62 65 65 6e 20 73 74 61  r never been sta
4fe0: 72 74 65 64 20 61 6e 64 20 6b 69 63 6b 20 74 68  rted and kick th
4ff0: 65 6d 20 6f 66 66 20 61 67 61 69 6e 0a 20 20 20  em off again.   
5000: 20 28 6c 65 74 20 6c 6f 6f 70 20 28 28 77 61 69   (let loop ((wai
5010: 74 69 6e 67 2d 74 65 73 74 2d 6e 61 6d 65 73 20  ting-test-names 
5020: 28 68 61 73 68 2d 74 61 62 6c 65 2d 6b 65 79 73  (hash-table-keys
5030: 20 2a 77 61 69 74 69 6e 67 2d 71 75 65 75 65 2a   *waiting-queue*
5040: 29 29 29 0a 20 20 20 20 20 20 28 63 6f 6e 64 0a  ))).      (cond.
5050: 20 20 20 20 20 20 20 28 28 6e 6f 74 20 28 72 75         ((not (ru
5060: 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65 2d  ns:can-run-more-
5070: 74 65 73 74 73 20 64 62 29 29 0a 09 28 73 6c 65  tests db))..(sle
5080: 65 70 20 32 29 0a 09 28 6c 6f 6f 70 20 77 61 69  ep 2)..(loop wai
5090: 74 69 6e 67 2d 74 65 73 74 2d 6e 61 6d 65 73 29  ting-test-names)
50a0: 29 0a 20 20 20 20 20 20 20 28 28 6e 75 6c 6c 3f  ).       ((null?
50b0: 20 77 61 69 74 69 6e 67 2d 74 65 73 74 2d 6e 61   waiting-test-na
50c0: 6d 65 73 29 0a 09 28 64 65 62 75 67 3a 70 72 69  mes)..(debug:pri
50d0: 6e 74 20 31 20 22 41 6c 6c 20 74 65 73 74 73 20  nt 1 "All tests 
50e0: 6c 61 75 6e 63 68 65 64 22 29 29 0a 20 20 20 20  launched")).    
50f0: 20 20 20 28 65 6c 73 65 0a 09 28 73 65 74 21 20     (else..(set! 
5100: 6e 75 6d 74 72 69 65 73 20 28 2b 20 6e 75 6d 74  numtries (+ numt
5110: 72 69 65 73 20 31 29 29 0a 09 28 66 6f 72 2d 65  ries 1))..(for-e
5120: 61 63 68 20 28 6c 61 6d 62 64 61 20 28 74 65 73  ach (lambda (tes
5130: 74 6e 61 6d 65 29 0a 09 09 20 20 20 20 28 69 66  tname)...    (if
5140: 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d   (runs:can-run-m
5150: 6f 72 65 2d 74 65 73 74 73 20 64 62 29 0a 09 09  ore-tests db)...
5160: 09 28 6c 65 74 2a 20 28 28 74 65 73 74 64 61 74  .(let* ((testdat
5170: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
5180: 20 2a 77 61 69 74 69 6e 67 2d 71 75 65 75 65 2a   *waiting-queue*
5190: 20 74 65 73 74 6e 61 6d 65 29 29 0a 09 09 09 20   testname)).... 
51a0: 20 20 20 20 20 20 28 70 72 65 72 65 71 73 20 28        (prereqs (
51b0: 28 63 61 72 20 74 65 73 74 64 61 74 29 29 29 0a  (car testdat))).
51c0: 09 09 09 20 20 20 20 20 20 20 28 6c 64 62 20 20  ...       (ldb  
51d0: 20 20 20 28 69 66 20 64 62 20 64 62 20 28 6f 70     (if db db (op
51e0: 65 6e 2d 64 62 29 29 29 29 0a 09 09 09 20 20 28  en-db))))....  (
51f0: 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 70  debug:print 2 "p
5200: 72 65 72 65 71 73 20 72 65 6d 61 69 6e 69 6e 67  rereqs remaining
5210: 3a 20 22 20 70 72 65 72 65 71 73 29 0a 09 09 09  : " prereqs)....
5220: 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 70 72 65    (if (null? pre
5230: 72 65 71 73 29 0a 09 09 09 20 20 20 20 20 20 28  reqs)....      (
5240: 62 65 67 69 6e 0a 09 09 09 09 28 64 65 62 75 67  begin.....(debug
5250: 3a 70 72 69 6e 74 20 32 20 22 50 72 65 72 65 71  :print 2 "Prereq
5260: 75 69 73 69 74 65 73 20 6d 65 74 2c 20 6c 61 75  uisites met, lau
5270: 6e 63 68 69 6e 67 20 22 20 74 65 73 74 6e 61 6d  nching " testnam
5280: 65 29 0a 09 09 09 09 28 28 63 61 64 72 20 74 65  e).....((cadr te
5290: 73 74 64 61 74 29 29 0a 09 09 09 09 28 68 61 73  stdat)).....(has
52a0: 68 2d 74 61 62 6c 65 2d 64 65 6c 65 74 65 21 20  h-table-delete! 
52b0: 2a 77 61 69 74 69 6e 67 2d 71 75 65 75 65 2a 20  *waiting-queue* 
52c0: 74 65 73 74 6e 61 6d 65 29 29 29 0a 09 09 09 20  testname))).... 
52d0: 20 28 69 66 20 28 6e 6f 74 20 64 62 29 0a 09 09   (if (not db)...
52e0: 09 20 20 20 20 20 20 28 73 71 6c 69 74 65 33 3a  .      (sqlite3:
52f0: 66 69 6e 61 6c 69 7a 65 21 20 6c 64 62 29 29 29  finalize! ldb)))
5300: 29 29 0a 09 09 20 20 77 61 69 74 69 6e 67 2d 74  ))...  waiting-t
5310: 65 73 74 2d 6e 61 6d 65 73 29 0a 09 3b 3b 20 28  est-names)..;; (
5320: 73 6c 65 65 70 20 31 30 29 20 3b 3b 20 6e 6f 20  sleep 10) ;; no 
5330: 70 6f 69 6e 74 20 69 6e 20 72 75 73 68 69 6e 67  point in rushing
5340: 20 74 68 69 6e 67 73 20 61 74 20 74 68 69 73 20   things at this 
5350: 73 74 61 67 65 3f 0a 09 28 6c 6f 6f 70 20 28 68  stage?..(loop (h
5360: 61 73 68 2d 74 61 62 6c 65 2d 6b 65 79 73 20 2a  ash-table-keys *
5370: 77 61 69 74 69 6e 67 2d 71 75 65 75 65 2a 29 29  waiting-queue*))
5380: 29 29 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28  )))))..(define (
5390: 67 65 74 2d 64 69 72 2d 75 70 2d 6e 20 64 69 72  get-dir-up-n dir
53a0: 20 2e 20 70 61 72 61 6d 73 29 20 0a 20 20 28 6c   . params) .  (l
53b0: 65 74 20 28 28 64 70 61 72 74 73 20 20 28 73 74  et ((dparts  (st
53c0: 72 69 6e 67 2d 73 70 6c 69 74 20 64 69 72 20 22  ring-split dir "
53d0: 2f 22 29 29 0a 09 28 63 6f 75 6e 74 20 20 20 28  /"))..(count   (
53e0: 69 66 20 28 6e 75 6c 6c 3f 20 70 61 72 61 6d 73  if (null? params
53f0: 29 20 31 20 28 63 61 72 20 70 61 72 61 6d 73 29  ) 1 (car params)
5400: 29 29 29 0a 20 20 20 20 28 63 6f 6e 63 20 22 2f  ))).    (conc "/
5410: 22 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73  " (string-inters
5420: 70 65 72 73 65 20 0a 09 20 20 20 20 20 20 20 28  perse ..       (
5430: 74 61 6b 65 20 64 70 61 72 74 73 20 28 2d 20 28  take dparts (- (
5440: 6c 65 6e 67 74 68 20 64 70 61 72 74 73 29 20 63  length dparts) c
5450: 6f 75 6e 74 29 29 0a 09 20 20 20 20 20 20 20 22  ount))..       "
5460: 2f 22 29 29 29 29 0a 3b 3b 20 52 65 6d 6f 76 65  /")))).;; Remove
5470: 20 72 75 6e 73 0a 3b 3b 20 66 69 65 6c 64 73 20   runs.;; fields 
5480: 61 72 65 20 70 61 73 73 69 6e 67 20 69 6e 20 74  are passing in t
5490: 68 72 6f 75 67 68 20 0a 28 64 65 66 69 6e 65 20  hrough .(define 
54a0: 28 72 75 6e 73 3a 72 65 6d 6f 76 65 2d 72 75 6e  (runs:remove-run
54b0: 73 20 64 62 20 72 75 6e 6e 61 6d 65 70 61 74 74  s db runnamepatt
54c0: 20 74 65 73 74 70 61 74 74 20 69 74 65 6d 70 61   testpatt itempa
54d0: 74 74 29 0a 20 20 28 6c 65 74 2a 20 28 28 6b 65  tt).  (let* ((ke
54e0: 79 73 20 20 20 20 20 20 20 20 28 64 62 2d 67 65  ys        (db-ge
54f0: 74 2d 6b 65 79 73 20 64 62 29 29 0a 09 20 28 72  t-keys db)).. (r
5500: 75 6e 64 61 74 20 20 20 20 20 20 28 72 75 6e 73  undat      (runs
5510: 3a 67 65 74 2d 72 75 6e 73 2d 62 79 2d 70 61 74  :get-runs-by-pat
5520: 74 20 64 62 20 6b 65 79 73 20 72 75 6e 6e 61 6d  t db keys runnam
5530: 65 70 61 74 74 29 29 0a 09 20 28 68 65 61 64 65  epatt)).. (heade
5540: 72 20 20 20 20 20 20 28 76 65 63 74 6f 72 2d 72  r      (vector-r
5550: 65 66 20 72 75 6e 64 61 74 20 30 29 29 0a 09 20  ef rundat 0)).. 
5560: 28 72 75 6e 73 20 20 20 20 20 20 20 20 28 76 65  (runs        (ve
5570: 63 74 6f 72 2d 72 65 66 20 72 75 6e 64 61 74 20  ctor-ref rundat 
5580: 31 29 29 29 0a 20 20 20 20 28 64 65 62 75 67 3a  1))).    (debug:
5590: 70 72 69 6e 74 20 31 20 22 48 65 61 64 65 72 3a  print 1 "Header:
55a0: 20 22 20 68 65 61 64 65 72 29 0a 20 20 20 20 28   " header).    (
55b0: 66 6f 72 2d 65 61 63 68 0a 20 20 20 20 20 28 6c  for-each.     (l
55c0: 61 6d 62 64 61 20 28 72 75 6e 29 0a 20 20 20 20  ambda (run).    
55d0: 20 20 20 28 6c 65 74 20 28 28 72 75 6e 6b 65 79     (let ((runkey
55e0: 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70   (string-intersp
55f0: 65 72 73 65 20 28 6d 61 70 20 28 6c 61 6d 62 64  erse (map (lambd
5600: 61 20 28 6b 29 0a 09 09 09 09 09 09 28 64 62 3a  a (k).......(db:
5610: 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61  get-value-by-hea
5620: 64 65 72 20 72 75 6e 20 68 65 61 64 65 72 20 28  der run header (
5630: 76 65 63 74 6f 72 2d 72 65 66 20 6b 20 30 29 29  vector-ref k 0))
5640: 29 20 6b 65 79 73 29 20 22 2f 22 29 29 29 0a 09  ) keys) "/")))..
5650: 20 28 6c 65 74 2a 20 28 28 72 75 6e 2d 69 64 20   (let* ((run-id 
5660: 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79  (db:get-value-by
5670: 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64  -header run head
5680: 65 72 20 22 69 64 22 29 20 29 0a 09 09 28 74 65  er "id") )...(te
5690: 73 74 73 20 20 28 64 62 2d 67 65 74 2d 74 65 73  sts  (db-get-tes
56a0: 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 28 64  ts-for-run db (d
56b0: 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68  b:get-value-by-h
56c0: 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65 72  eader run header
56d0: 20 22 69 64 22 29 20 74 65 73 74 70 61 74 74 20   "id") testpatt 
56e0: 69 74 65 6d 70 61 74 74 29 29 0a 09 09 28 6c 61  itempatt))...(la
56f0: 73 74 74 70 61 74 68 20 22 2f 64 6f 65 73 2f 6e  sttpath "/does/n
5700: 6f 74 2f 65 78 69 73 74 2f 49 2f 68 6f 70 65 22  ot/exist/I/hope"
5710: 29 29 0a 09 20 20 20 28 69 66 20 28 6e 6f 74 20  ))..   (if (not 
5720: 28 6e 75 6c 6c 3f 20 74 65 73 74 73 29 29 0a 09  (null? tests))..
5730: 20 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09         (begin...
5740: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20   (debug:print 1 
5750: 22 52 65 6d 6f 76 69 6e 67 20 74 65 73 74 73 20  "Removing tests 
5760: 66 6f 72 20 72 75 6e 3a 20 22 20 72 75 6e 6b 65  for run: " runke
5770: 79 20 22 20 22 20 28 64 62 3a 67 65 74 2d 76 61  y " " (db:get-va
5780: 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75  lue-by-header ru
5790: 6e 20 68 65 61 64 65 72 20 22 72 75 6e 6e 61 6d  n header "runnam
57a0: 65 22 29 29 0a 09 09 20 28 66 6f 72 2d 65 61 63  e"))... (for-eac
57b0: 68 0a 09 09 20 20 28 6c 61 6d 62 64 61 20 28 74  h...  (lambda (t
57c0: 65 73 74 29 0a 09 09 20 20 20 20 28 6c 65 74 2a  est)...    (let*
57d0: 20 28 28 69 74 65 6d 2d 70 61 74 68 20 28 64 62   ((item-path (db
57e0: 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70  :test-get-item-p
57f0: 61 74 68 20 74 65 73 74 29 29 0a 09 09 09 20 20  ath test))....  
5800: 20 28 74 65 73 74 2d 6e 61 6d 65 20 28 64 62 3a   (test-name (db:
5810: 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d  test-get-testnam
5820: 65 20 74 65 73 74 29 29 0a 09 09 09 20 20 20 28  e test))....   (
5830: 72 75 6e 2d 64 69 72 20 20 20 28 64 62 3a 74 65  run-dir   (db:te
5840: 73 74 2d 67 65 74 2d 72 75 6e 64 69 72 20 74 65  st-get-rundir te
5850: 73 74 29 29 29 0a 09 09 20 20 20 20 20 20 28 64  st)))...      (d
5860: 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 20 20  ebug:print 1 "  
5870: 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 74  " (db:test-get-t
5880: 65 73 74 6e 61 6d 65 20 74 65 73 74 29 20 22 20  estname test) " 
5890: 69 64 3a 20 22 20 28 64 62 3a 74 65 73 74 2d 67  id: " (db:test-g
58a0: 65 74 2d 69 64 20 74 65 73 74 29 20 22 20 22 20  et-id test) " " 
58b0: 69 74 65 6d 2d 70 61 74 68 29 0a 09 09 20 20 20  item-path)...   
58c0: 20 20 20 28 64 62 3a 64 65 6c 65 74 65 2d 74 65     (db:delete-te
58d0: 73 74 2d 72 65 63 6f 72 64 73 20 64 62 20 28 64  st-records db (d
58e0: 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65  b:test-get-id te
58f0: 73 74 29 29 0a 09 09 20 20 20 20 20 20 28 69 66  st))...      (if
5900: 20 28 3e 20 28 73 74 72 69 6e 67 2d 6c 65 6e 67   (> (string-leng
5910: 74 68 20 72 75 6e 2d 64 69 72 29 20 35 29 20 3b  th run-dir) 5) ;
5920: 3b 20 62 61 64 20 68 65 75 72 69 73 74 69 63 20  ; bad heuristic 
5930: 62 75 74 20 73 68 6f 75 6c 64 20 70 72 65 76 65  but should preve
5940: 6e 74 20 2f 74 6d 70 20 2f 68 6f 6d 65 20 65 74  nt /tmp /home et
5950: 63 2e 0a 09 09 09 20 20 28 6c 65 74 20 28 28 66  c.....  (let ((f
5960: 75 6c 6c 70 61 74 68 20 72 75 6e 2d 64 69 72 29  ullpath run-dir)
5970: 29 20 3b 3b 20 22 2f 22 20 28 64 62 3a 74 65 73  ) ;; "/" (db:tes
5980: 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20  t-get-item-path 
5990: 74 65 73 74 29 29 29 29 0a 09 09 09 20 20 20 20  test))))....    
59a0: 28 73 65 74 21 20 6c 61 73 74 74 70 61 74 68 20  (set! lasttpath 
59b0: 66 75 6c 6c 70 61 74 68 29 0a 09 09 09 20 20 20  fullpath)....   
59c0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20   (debug:print 1 
59d0: 22 72 6d 20 2d 72 66 20 22 20 66 75 6c 6c 70 61  "rm -rf " fullpa
59e0: 74 68 29 0a 09 09 09 20 20 20 20 28 73 79 73 74  th)....    (syst
59f0: 65 6d 20 28 63 6f 6e 63 20 22 72 6d 20 2d 72 66  em (conc "rm -rf
5a00: 20 22 20 66 75 6c 6c 70 61 74 68 29 29 0a 09 09   " fullpath))...
5a10: 09 20 20 20 20 28 6c 65 74 2a 20 28 28 64 69 72  .    (let* ((dir
5a20: 73 2d 63 6f 75 6e 74 20 28 2b 20 31 20 28 6c 65  s-count (+ 1 (le
5a30: 6e 67 74 68 20 6b 65 79 73 29 28 6c 65 6e 67 74  ngth keys)(lengt
5a40: 68 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20  h (string-split 
5a50: 69 74 65 6d 2d 70 61 74 68 20 22 2f 22 29 29 29  item-path "/")))
5a60: 29 0a 09 09 09 09 20 20 20 28 64 69 72 2d 74 6f  ).....   (dir-to
5a70: 2d 72 65 6d 20 28 67 65 74 2d 64 69 72 2d 75 70  -rem (get-dir-up
5a80: 2d 6e 20 66 75 6c 6c 70 61 74 68 20 64 69 72 73  -n fullpath dirs
5a90: 2d 63 6f 75 6e 74 29 29 0a 09 09 09 09 20 20 20  -count)).....   
5aa0: 28 72 65 6d 61 69 6e 69 6e 67 64 20 28 73 74 72  (remainingd (str
5ab0: 69 6e 67 2d 73 75 62 73 74 69 74 75 74 65 20 28  ing-substitute (
5ac0: 72 65 67 65 78 70 20 28 63 6f 6e 63 20 22 5e 22  regexp (conc "^"
5ad0: 20 64 69 72 2d 74 6f 2d 72 65 6d 20 22 2f 22 29   dir-to-rem "/")
5ae0: 29 20 22 22 20 66 75 6c 6c 70 61 74 68 29 29 0a  ) "" fullpath)).
5af0: 09 09 09 09 20 20 20 28 63 6d 64 20 28 63 6f 6e  ....   (cmd (con
5b00: 63 20 22 63 64 20 22 20 64 69 72 2d 74 6f 2d 72  c "cd " dir-to-r
5b10: 65 6d 20 22 3b 20 72 6d 64 69 72 20 2d 70 20 22  em "; rmdir -p "
5b20: 20 72 65 6d 61 69 6e 69 6e 67 64 20 29 29 29 0a   remainingd ))).
5b30: 09 09 09 20 20 20 20 20 20 28 69 66 20 28 66 69  ...      (if (fi
5b40: 6c 65 2d 65 78 69 73 74 73 3f 20 66 75 6c 6c 70  le-exists? fullp
5b50: 61 74 68 29 0a 09 09 09 09 20 20 28 62 65 67 69  ath).....  (begi
5b60: 6e 0a 09 09 09 09 20 20 20 20 28 64 65 62 75 67  n.....    (debug
5b70: 3a 70 72 69 6e 74 20 31 20 63 6d 64 29 0a 09 09  :print 1 cmd)...
5b80: 09 09 20 20 20 20 28 73 79 73 74 65 6d 20 63 6d  ..    (system cm
5b90: 64 29 29 29 0a 09 09 09 20 20 20 20 20 20 29 29  d)))....      ))
5ba0: 0a 09 09 09 20 20 20 20 29 29 29 0a 09 09 20 20  ....    )))...  
5bb0: 20 20 74 65 73 74 73 29 29 29 0a 09 20 20 20 28    tests)))..   (
5bc0: 6c 65 74 20 28 28 72 65 6d 74 65 73 74 73 20 28  let ((remtests (
5bd0: 64 62 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f 72  db-get-tests-for
5be0: 2d 72 75 6e 20 64 62 20 28 64 62 3a 67 65 74 2d  -run db (db:get-
5bf0: 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20  value-by-header 
5c00: 72 75 6e 20 68 65 61 64 65 72 20 22 69 64 22 29  run header "id")
5c10: 29 29 29 0a 09 20 20 20 20 20 28 69 66 20 28 6e  )))..     (if (n
5c20: 75 6c 6c 3f 20 72 65 6d 74 65 73 74 73 29 20 3b  ull? remtests) ;
5c30: 3b 20 6e 6f 20 6d 6f 72 65 20 74 65 73 74 73 20  ; no more tests 
5c40: 72 65 6d 61 69 6e 69 6e 67 0a 09 09 20 28 6c 65  remaining... (le
5c50: 74 2a 20 28 28 64 70 61 72 74 73 20 20 28 73 74  t* ((dparts  (st
5c60: 72 69 6e 67 2d 73 70 6c 69 74 20 6c 61 73 74 74  ring-split lastt
5c70: 70 61 74 68 20 22 2f 22 29 29 0a 09 09 09 28 72  path "/"))....(r
5c80: 75 6e 70 61 74 68 20 28 63 6f 6e 63 20 22 2f 22  unpath (conc "/"
5c90: 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70   (string-intersp
5ca0: 65 72 73 65 20 0a 09 09 09 09 09 20 20 20 20 28  erse ......    (
5cb0: 74 61 6b 65 20 64 70 61 72 74 73 20 28 2d 20 28  take dparts (- (
5cc0: 6c 65 6e 67 74 68 20 64 70 61 72 74 73 29 20 31  length dparts) 1
5cd0: 29 29 0a 09 09 09 09 09 20 20 20 20 22 2f 22 29  ))......    "/")
5ce0: 29 29 29 0a 09 09 20 20 20 28 64 65 62 75 67 3a  )))...   (debug:
5cf0: 70 72 69 6e 74 20 31 20 22 52 65 6d 6f 76 69 6e  print 1 "Removin
5d00: 67 20 72 75 6e 3a 20 22 20 72 75 6e 6b 65 79 20  g run: " runkey 
5d10: 22 20 22 20 28 64 62 3a 67 65 74 2d 76 61 6c 75  " " (db:get-valu
5d20: 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20  e-by-header run 
5d30: 68 65 61 64 65 72 20 22 72 75 6e 6e 61 6d 65 22  header "runname"
5d40: 29 29 0a 09 09 20 20 20 28 64 62 3a 64 65 6c 65  ))...   (db:dele
5d50: 74 65 2d 72 75 6e 20 64 62 20 72 75 6e 2d 69 64  te-run db run-id
5d60: 29 0a 09 09 20 20 20 3b 3b 20 6e 65 65 64 20 74  )...   ;; need t
5d70: 6f 20 66 69 67 75 72 65 20 6f 75 74 20 74 68 65  o figure out the
5d80: 20 70 61 74 68 20 74 6f 20 74 68 65 20 72 75 6e   path to the run
5d90: 20 64 69 72 20 61 6e 64 20 72 65 6d 6f 76 65 20   dir and remove 
5da0: 69 74 20 69 66 20 65 6d 70 74 79 0a 09 09 20 20  it if empty...  
5db0: 20 3b 3b 20 20 20 20 28 69 66 20 28 6e 75 6c 6c   ;;    (if (null
5dc0: 3f 20 28 67 6c 6f 62 20 28 63 6f 6e 63 20 72 75  ? (glob (conc ru
5dd0: 6e 70 61 74 68 20 22 2f 2a 22 29 29 29 0a 09 09  npath "/*")))...
5de0: 20 20 20 3b 3b 20 20 20 20 20 20 20 20 28 62 65     ;;        (be
5df0: 67 69 6e 0a 09 09 20 20 20 3b 3b 20 09 20 28 64  gin...   ;; . (d
5e00: 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 52 65  ebug:print 1 "Re
5e10: 6d 6f 76 69 6e 67 20 72 75 6e 20 64 69 72 20 22  moving run dir "
5e20: 20 72 75 6e 70 61 74 68 29 0a 09 09 20 20 20 3b   runpath)...   ;
5e30: 3b 20 09 20 28 73 79 73 74 65 6d 20 28 63 6f 6e  ; . (system (con
5e40: 63 20 22 72 6d 64 69 72 20 2d 70 20 22 20 72 75  c "rmdir -p " ru
5e50: 6e 70 61 74 68 29 29 29 29 0a 09 09 20 20 20 29  npath))))...   )
5e60: 29 29 29 0a 09 20 29 29 0a 20 20 20 20 20 72 75  ))).. )).     ru
5e70: 6e 73 29 29 29 0a                                ns))).