Megatest

Hex Artifact Content
Login

Artifact 243bc1392b4d2faae1e15b8e9da609de0a8dce4a:


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 3b 3b 20 28 70 72 69 6e 74  )).    ;; (print
0450: 20 22 6b 65 79 73 3a 20 22 20 6b 65 79 73 20 22   "keys: " keys "
0460: 20 61 6c 6c 76 61 6c 73 3a 20 22 20 61 6c 6c 76   allvals: " allv
0470: 61 6c 73 20 22 20 6b 65 79 76 61 6c 6c 73 74 3a  als " keyvallst:
0480: 20 22 20 6b 65 79 76 61 6c 6c 73 74 29 0a 20 20   " keyvallst).  
0490: 20 20 28 70 72 69 6e 74 20 22 4e 4f 54 45 3a 20    (print "NOTE: 
04a0: 75 73 69 6e 67 20 6b 65 79 20 22 20 28 73 74 72  using key " (str
04b0: 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20  ing-intersperse 
04c0: 6b 65 79 76 61 6c 6c 73 74 20 22 2f 22 29 20 22  keyvallst "/") "
04d0: 20 66 6f 72 20 74 68 69 73 20 72 75 6e 22 29 0a   for this run").
04e0: 20 20 20 20 28 69 66 20 28 61 6e 64 20 72 75 6e      (if (and run
04f0: 6e 61 6d 65 20 28 6e 75 6c 6c 3f 20 28 66 69 6c  name (null? (fil
0500: 74 65 72 20 28 6c 61 6d 62 64 61 20 28 78 29 28  ter (lambda (x)(
0510: 6e 6f 74 20 78 29 29 20 6b 65 79 76 61 6c 6c 73  not x)) keyvalls
0520: 74 29 29 29 20 3b 3b 20 74 68 65 72 65 20 6d 75  t))) ;; there mu
0530: 73 74 20 62 65 20 61 20 62 65 74 74 65 72 20 77  st be a better w
0540: 61 79 20 74 6f 20 22 61 70 70 6c 79 20 61 6e 64  ay to "apply and
0550: 22 0a 09 28 6c 65 74 20 28 28 72 65 73 20 23 66  "..(let ((res #f
0560: 29 29 0a 09 20 20 28 61 70 70 6c 79 20 73 71 6c  ))..  (apply sql
0570: 69 74 65 33 3a 65 78 65 63 75 74 65 20 64 62 20  ite3:execute db 
0580: 28 63 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f 52  (conc "INSERT OR
0590: 20 49 47 4e 4f 52 45 20 49 4e 54 4f 20 72 75 6e   IGNORE INTO run
05a0: 73 20 28 72 75 6e 6e 61 6d 65 2c 73 74 61 74 65  s (runname,state
05b0: 2c 73 74 61 74 75 73 2c 6f 77 6e 65 72 2c 65 76  ,status,owner,ev
05c0: 65 6e 74 5f 74 69 6d 65 22 20 63 6f 6d 6d 61 20  ent_time" comma 
05d0: 6b 65 79 73 74 72 20 22 29 20 56 41 4c 55 45 53  keystr ") VALUES
05e0: 20 28 3f 2c 3f 2c 3f 2c 3f 2c 73 74 72 66 74 69   (?,?,?,?,strfti
05f0: 6d 65 28 27 25 73 27 2c 27 6e 6f 77 27 29 22 20  me('%s','now')" 
0600: 63 6f 6d 6d 61 20 76 61 6c 73 6c 6f 74 73 20 22  comma valslots "
0610: 29 3b 22 29 0a 09 09 20 61 6c 6c 76 61 6c 73 29  );")... allvals)
0620: 0a 09 20 20 28 61 70 70 6c 79 20 73 71 6c 69 74  ..  (apply sqlit
0630: 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77 20  e3:for-each-row 
0640: 0a 09 20 20 20 28 6c 61 6d 62 64 61 20 28 69 64  ..   (lambda (id
0650: 29 0a 09 20 20 20 20 20 28 73 65 74 21 20 72 65  )..     (set! re
0660: 73 20 69 64 29 29 0a 09 20 20 20 64 62 0a 09 20  s id))..   db.. 
0670: 20 20 28 6c 65 74 20 28 28 71 72 79 20 28 63 6f    (let ((qry (co
0680: 6e 63 20 22 53 45 4c 45 43 54 20 69 64 20 46 52  nc "SELECT id FR
0690: 4f 4d 20 72 75 6e 73 20 57 48 45 52 45 20 28 72  OM runs WHERE (r
06a0: 75 6e 6e 61 6d 65 3d 3f 20 22 20 61 6e 64 73 74  unname=? " andst
06b0: 72 20 6b 65 79 3d 3f 73 74 72 20 22 29 3b 22 29  r key=?str ");")
06c0: 29 29 0a 09 20 20 20 20 20 3b 3b 20 28 70 72 69  ))..     ;; (pri
06d0: 6e 74 20 22 71 72 79 3a 20 22 20 71 72 79 29 20  nt "qry: " qry) 
06e0: 0a 09 20 20 20 20 20 71 72 79 29 0a 09 20 20 20  ..     qry)..   
06f0: 71 72 79 76 61 6c 73 29 0a 09 20 20 28 73 71 6c  qryvals)..  (sql
0700: 69 74 65 33 3a 65 78 65 63 75 74 65 20 64 62 20  ite3:execute db 
0710: 22 55 50 44 41 54 45 20 72 75 6e 73 20 53 45 54  "UPDATE runs SET
0720: 20 73 74 61 74 65 3d 3f 2c 73 74 61 74 75 73 3d   state=?,status=
0730: 3f 20 57 48 45 52 45 20 69 64 3d 3f 3b 22 20 73  ? WHERE id=?;" s
0740: 74 61 74 65 20 73 74 61 74 75 73 20 72 65 73 29  tate status res)
0750: 0a 09 20 20 72 65 73 29 20 0a 09 28 62 65 67 69  ..  res) ..(begi
0760: 6e 0a 09 20 20 28 70 72 69 6e 74 20 22 45 52 52  n..  (print "ERR
0770: 4f 52 3a 20 43 61 6c 6c 65 64 20 77 69 74 68 6f  OR: Called witho
0780: 75 74 20 61 6c 6c 20 6e 65 63 65 73 73 61 72 79  ut all necessary
0790: 20 6b 65 79 73 22 29 0a 09 20 20 23 66 29 29 29   keys")..  #f)))
07a0: 29 0a 0a 3b 3b 20 72 75 6e 73 3a 67 65 74 2d 72  )..;; runs:get-r
07b0: 75 6e 73 2d 62 79 2d 70 61 74 74 0a 3b 3b 20 67  uns-by-patt.;; g
07c0: 65 74 20 72 75 6e 73 20 62 79 20 6c 69 73 74 20  et runs by list 
07d0: 6f 66 20 63 72 69 74 65 72 69 61 0a 3b 3b 20 72  of criteria.;; r
07e0: 65 67 69 73 74 65 72 20 61 20 74 65 73 74 20 72  egister a test r
07f0: 75 6e 20 77 69 74 68 20 74 68 65 20 64 62 0a 3b  un with the db.;
0800: 3b 0a 3b 3b 20 55 73 65 3a 20 28 64 62 2d 67 65  ;.;; Use: (db-ge
0810: 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65  t-value-by-heade
0820: 72 20 28 64 62 3a 67 65 74 2d 68 65 61 64 65 72  r (db:get-header
0830: 20 72 75 6e 69 6e 66 6f 29 28 64 62 3a 67 65 74   runinfo)(db:get
0840: 2d 72 6f 77 20 72 75 6e 69 6e 66 6f 29 29 0a 3b  -row runinfo)).;
0850: 3b 20 20 74 6f 20 65 78 74 72 61 63 74 20 69 6e  ;  to extract in
0860: 66 6f 20 66 72 6f 6d 20 74 68 65 20 73 74 72 75  fo from the stru
0870: 63 74 75 72 65 20 72 65 74 75 72 6e 65 64 0a 3b  cture returned.;
0880: 3b 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a  ;.(define (runs:
0890: 67 65 74 2d 72 75 6e 73 2d 62 79 2d 70 61 74 74  get-runs-by-patt
08a0: 20 64 62 20 6b 65 79 73 20 72 75 6e 6e 61 6d 65   db keys runname
08b0: 70 61 74 74 20 2e 20 70 61 72 61 6d 73 29 20 3b  patt . params) ;
08c0: 3b 20 74 65 73 74 2d 6e 61 6d 65 29 0a 20 20 28  ; test-name).  (
08d0: 6c 65 74 2a 20 28 28 6b 65 79 76 61 6c 6c 73 74  let* ((keyvallst
08e0: 20 28 6b 65 79 73 2d 3e 76 61 6c 6c 69 73 74 20   (keys->vallist 
08f0: 6b 65 79 73 29 29 0a 09 20 28 74 6d 70 20 20 20  keys)).. (tmp   
0900: 20 20 20 28 72 75 6e 73 3a 67 65 74 2d 73 74 64     (runs:get-std
0910: 2d 72 75 6e 2d 66 69 65 6c 64 73 20 6b 65 79 73  -run-fields keys
0920: 20 27 28 22 69 64 22 20 22 72 75 6e 6e 61 6d 65   '("id" "runname
0930: 22 20 22 73 74 61 74 65 22 20 22 73 74 61 74 75  " "state" "statu
0940: 73 22 20 22 6f 77 6e 65 72 22 20 22 65 76 65 6e  s" "owner" "even
0950: 74 5f 74 69 6d 65 22 29 29 29 0a 09 20 28 6b 65  t_time"))).. (ke
0960: 79 73 74 72 20 20 20 28 63 61 72 20 74 6d 70 29  ystr   (car tmp)
0970: 29 0a 09 20 28 68 65 61 64 65 72 20 20 20 28 63  ).. (header   (c
0980: 61 64 72 20 74 6d 70 29 29 0a 09 20 28 72 65 73  adr tmp)).. (res
0990: 20 20 20 20 20 27 28 29 29 0a 09 20 28 6b 65 79       '()).. (key
09a0: 2d 70 61 74 74 20 22 22 29 29 0a 20 20 20 20 28  -patt "")).    (
09b0: 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61  for-each (lambda
09c0: 20 28 6b 65 79 76 61 6c 29 0a 09 09 28 6c 65 74   (keyval)...(let
09d0: 2a 20 28 28 6b 65 79 20 20 20 20 28 76 65 63 74  * ((key    (vect
09e0: 6f 72 2d 72 65 66 20 6b 65 79 76 61 6c 20 30 29  or-ref keyval 0)
09f0: 29 0a 09 09 20 20 20 20 20 20 20 28 66 75 6c 6b  )...       (fulk
0a00: 65 79 20 28 63 6f 6e 63 20 22 3a 22 20 6b 65 79  ey (conc ":" key
0a10: 29 29 0a 09 09 20 20 20 20 20 20 20 28 70 61 74  ))...       (pat
0a20: 74 20 20 20 28 61 72 67 73 3a 67 65 74 2d 61 72  t   (args:get-ar
0a30: 67 20 66 75 6c 6b 65 79 29 29 29 0a 09 09 20 20  g fulkey)))...  
0a40: 28 69 66 20 70 61 74 74 0a 09 09 20 20 20 20 20  (if patt...     
0a50: 20 28 73 65 74 21 20 6b 65 79 2d 70 61 74 74 20   (set! key-patt 
0a60: 28 63 6f 6e 63 20 6b 65 79 2d 70 61 74 74 20 22  (conc key-patt "
0a70: 20 41 4e 44 20 22 20 6b 65 79 20 22 20 6c 69 6b   AND " key " lik
0a80: 65 20 27 22 20 70 61 74 74 20 22 27 22 29 29 0a  e '" patt "'")).
0a90: 09 09 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09  ..      (begin..
0aa0: 09 09 28 70 72 69 6e 74 20 22 45 52 52 4f 52 3a  ..(print "ERROR:
0ab0: 20 73 65 61 72 63 68 69 6e 67 20 66 6f 72 20 72   searching for r
0ac0: 75 6e 73 20 77 69 74 68 20 6e 6f 20 70 61 74 74  uns with no patt
0ad0: 65 72 6e 20 73 65 74 20 66 6f 72 20 22 20 66 75  ern set for " fu
0ae0: 6c 6b 65 79 29 0a 09 09 09 28 65 78 69 74 20 36  lkey)....(exit 6
0af0: 29 29 29 29 29 0a 09 20 20 20 20 20 20 6b 65 79  )))))..      key
0b00: 73 29 0a 20 20 20 20 28 73 71 6c 69 74 65 33 3a  s).    (sqlite3:
0b10: 66 6f 72 2d 65 61 63 68 2d 72 6f 77 20 0a 20 20  for-each-row .  
0b20: 20 20 20 28 6c 61 6d 62 64 61 20 28 61 20 2e 20     (lambda (a . 
0b30: 72 29 0a 20 20 20 20 20 20 20 28 73 65 74 21 20  r).       (set! 
0b40: 72 65 73 20 28 63 6f 6e 73 20 28 6c 69 73 74 2d  res (cons (list-
0b50: 3e 76 65 63 74 6f 72 20 28 63 6f 6e 73 20 61 20  >vector (cons a 
0b60: 72 29 29 20 72 65 73 29 29 29 0a 20 20 20 20 20  r)) res))).     
0b70: 64 62 20 0a 20 20 20 20 20 28 63 6f 6e 63 20 22  db .     (conc "
0b80: 53 45 4c 45 43 54 20 22 20 6b 65 79 73 74 72 20  SELECT " keystr 
0b90: 22 20 46 52 4f 4d 20 72 75 6e 73 20 57 48 45 52  " FROM runs WHER
0ba0: 45 20 72 75 6e 6e 61 6d 65 20 6c 69 6b 65 20 3f  E runname like ?
0bb0: 20 22 20 6b 65 79 2d 70 61 74 74 20 22 3b 22 29   " key-patt ";")
0bc0: 0a 20 20 20 20 20 72 75 6e 6e 61 6d 65 70 61 74  .     runnamepat
0bd0: 74 29 0a 20 20 20 20 28 76 65 63 74 6f 72 20 68  t).    (vector h
0be0: 65 61 64 65 72 20 72 65 73 29 29 29 0a 0a 28 64  eader res)))..(d
0bf0: 65 66 69 6e 65 20 28 72 65 67 69 73 74 65 72 2d  efine (register-
0c00: 74 65 73 74 20 64 62 20 72 75 6e 2d 69 64 20 74  test db run-id t
0c10: 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61  est-name item-pa
0c20: 74 68 29 0a 20 20 28 73 71 6c 69 74 65 33 3a 65  th).  (sqlite3:e
0c30: 78 65 63 75 74 65 20 64 62 20 22 49 4e 53 45 52  xecute db "INSER
0c40: 54 20 4f 52 20 49 47 4e 4f 52 45 20 49 4e 54 4f  T OR IGNORE INTO
0c50: 20 74 65 73 74 73 20 28 72 75 6e 5f 69 64 2c 74   tests (run_id,t
0c60: 65 73 74 6e 61 6d 65 2c 65 76 65 6e 74 5f 74 69  estname,event_ti
0c70: 6d 65 2c 69 74 65 6d 5f 70 61 74 68 29 20 56 41  me,item_path) VA
0c80: 4c 55 45 53 20 28 3f 2c 3f 2c 73 74 72 66 74 69  LUES (?,?,strfti
0c90: 6d 65 28 27 25 73 27 2c 27 6e 6f 77 27 29 2c 3f  me('%s','now'),?
0ca0: 29 3b 22 20 72 75 6e 2d 69 64 20 74 65 73 74 2d  );" run-id test-
0cb0: 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29  name item-path))
0cc0: 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73 74 2d  ..(define (test-
0cd0: 73 65 74 2d 73 74 61 74 75 73 21 20 64 62 20 72  set-status! db r
0ce0: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
0cf0: 73 74 61 74 65 20 73 74 61 74 75 73 20 69 74 65  state status ite
0d00: 6d 64 61 74 2d 6f 72 2d 70 61 74 68 20 2e 20 63  mdat-or-path . c
0d10: 6f 6d 6d 65 6e 74 29 0a 20 20 28 6c 65 74 20 28  omment).  (let (
0d20: 28 69 74 65 6d 2d 70 61 74 68 20 28 69 66 20 28  (item-path (if (
0d30: 73 74 72 69 6e 67 3f 20 69 74 65 6d 64 61 74 2d  string? itemdat-
0d40: 6f 72 2d 70 61 74 68 29 20 69 74 65 6d 64 61 74  or-path) itemdat
0d50: 2d 6f 72 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c  -or-path (item-l
0d60: 69 73 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61  ist->path itemda
0d70: 74 2d 6f 72 2d 70 61 74 68 29 29 29 29 0a 20 20  t-or-path)))).  
0d80: 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75    (sqlite3:execu
0d90: 74 65 20 64 62 20 22 55 50 44 41 54 45 20 74 65  te db "UPDATE te
0da0: 73 74 73 20 53 45 54 20 73 74 61 74 65 3d 3f 2c  sts SET state=?,
0db0: 73 74 61 74 75 73 3d 3f 2c 65 76 65 6e 74 5f 74  status=?,event_t
0dc0: 69 6d 65 3d 73 74 72 66 74 69 6d 65 28 27 25 73  ime=strftime('%s
0dd0: 27 2c 27 6e 6f 77 27 29 20 57 48 45 52 45 20 72  ','now') WHERE r
0de0: 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74  un_id=? AND test
0df0: 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f  name=? AND item_
0e00: 70 61 74 68 3d 3f 3b 22 20 0a 09 09 20 20 20 20  path=?;" ...    
0e10: 20 73 74 61 74 65 20 73 74 61 74 75 73 20 72 75   state status ru
0e20: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69  n-id test-name i
0e30: 74 65 6d 2d 70 61 74 68 29 0a 20 20 20 20 28 69  tem-path).    (i
0e40: 66 20 28 61 6e 64 20 28 6e 6f 74 20 28 6e 75 6c  f (and (not (nul
0e50: 6c 3f 20 63 6f 6d 6d 65 6e 74 29 29 0a 09 20 20  l? comment))..  
0e60: 20 20 20 28 63 61 72 20 63 6f 6d 6d 65 6e 74 29     (car comment)
0e70: 29 0a 09 28 73 71 6c 69 74 65 33 3a 65 78 65 63  )..(sqlite3:exec
0e80: 75 74 65 20 64 62 20 22 55 50 44 41 54 45 20 74  ute db "UPDATE t
0e90: 65 73 74 73 20 53 45 54 20 63 6f 6d 6d 65 6e 74  ests SET comment
0ea0: 3d 3f 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d  =? WHERE run_id=
0eb0: 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f  ? AND testname=?
0ec0: 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f   AND item_path=?
0ed0: 3b 22 0a 09 09 09 20 28 63 61 72 20 63 6f 6d 6d  ;".... (car comm
0ee0: 65 6e 74 29 20 72 75 6e 2d 69 64 20 74 65 73 74  ent) run-id test
0ef0: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  -name item-path)
0f00: 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65  )))..(define (te
0f10: 73 74 2d 73 65 74 2d 6c 6f 67 21 20 64 62 20 72  st-set-log! db r
0f20: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
0f30: 69 74 65 6d 64 61 74 20 6c 6f 67 66 29 20 0a 20  itemdat logf) . 
0f40: 20 28 6c 65 74 20 28 28 69 74 65 6d 2d 70 61 74   (let ((item-pat
0f50: 68 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61  h (item-list->pa
0f60: 74 68 20 69 74 65 6d 64 61 74 29 29 29 0a 20 20  th itemdat))).  
0f70: 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75    (sqlite3:execu
0f80: 74 65 20 64 62 20 22 55 50 44 41 54 45 20 74 65  te db "UPDATE te
0f90: 73 74 73 20 53 45 54 20 66 69 6e 61 6c 5f 6c 6f  sts SET final_lo
0fa0: 67 66 3d 3f 20 57 48 45 52 45 20 72 75 6e 5f 69  gf=? WHERE run_i
0fb0: 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65  d=? AND testname
0fc0: 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68  =? AND item_path
0fd0: 3d 3f 3b 22 20 0a 09 09 20 20 20 20 20 6c 6f 67  =?;" ...     log
0fe0: 66 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  f run-id test-na
0ff0: 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a  me item-path))).
1000: 0a 3b 3b 20 3b 3b 20 54 4f 44 4f 3a 20 43 6f 6e  .;; ;; TODO: Con
1010: 76 65 72 67 65 20 74 68 69 73 20 77 69 74 68 20  verge this with 
1020: 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f  db:get-test-info
1030: 0a 3b 3b 20 28 64 65 66 69 6e 65 20 28 72 75 6e  .;; (define (run
1040: 73 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20  s:get-test-info 
1050: 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e  db run-id test-n
1060: 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 0a 3b  ame item-path).;
1070: 3b 20 20 20 28 6c 65 74 20 28 28 72 65 73 20 23  ;   (let ((res #
1080: 66 29 29 20 3b 3b 20 28 76 65 63 74 6f 72 20 23  f)) ;; (vector #
1090: 66 20 23 66 20 23 66 20 23 66 20 23 66 20 23 66  f #f #f #f #f #f
10a0: 29 29 29 0a 3b 3b 20 20 20 20 20 28 73 71 6c 69  ))).;;     (sqli
10b0: 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77  te3:for-each-row
10c0: 20 0a 3b 3b 20 20 20 20 20 20 28 6c 61 6d 62 64   .;;      (lambd
10d0: 61 20 28 69 64 20 72 75 6e 2d 69 64 20 74 65 73  a (id run-id tes
10e0: 74 2d 6e 61 6d 65 20 73 74 61 74 65 20 73 74 61  t-name state sta
10f0: 74 75 73 29 0a 3b 3b 20 20 20 20 20 20 20 20 28  tus).;;        (
1100: 73 65 74 21 20 72 65 73 20 28 76 65 63 74 6f 72  set! res (vector
1110: 20 69 64 20 72 75 6e 2d 69 64 20 74 65 73 74 2d   id run-id test-
1120: 6e 61 6d 65 20 73 74 61 74 65 20 73 74 61 74 75  name state statu
1130: 73 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 3b  s item-path))).;
1140: 3b 20 20 20 20 20 20 64 62 20 22 53 45 4c 45 43  ;      db "SELEC
1150: 54 20 69 64 2c 72 75 6e 5f 69 64 2c 74 65 73 74  T id,run_id,test
1160: 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 61 74 75  name,state,statu
1170: 73 20 46 52 4f 4d 20 74 65 73 74 73 20 57 48 45  s FROM tests WHE
1180: 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20  RE run_id=? AND 
1190: 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69  testname=? AND i
11a0: 74 65 6d 5f 70 61 74 68 3d 3f 3b 22 0a 3b 3b 20  tem_path=?;".;; 
11b0: 20 20 20 20 20 72 75 6e 2d 69 64 20 74 65 73 74       run-id test
11c0: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  -name item-path)
11d0: 0a 3b 3b 20 20 20 20 20 72 65 73 29 29 0a 0a 28  .;;     res))..(
11e0: 64 65 66 69 6e 65 2d 69 6e 6c 69 6e 65 20 28 74  define-inline (t
11f0: 65 73 74 3a 67 65 74 2d 69 64 20 76 65 63 29 20  est:get-id vec) 
1200: 20 20 20 20 20 20 28 76 65 63 74 6f 72 2d 72 65        (vector-re
1210: 66 20 76 65 63 20 30 29 29 0a 28 64 65 66 69 6e  f vec 0)).(defin
1220: 65 2d 69 6e 6c 69 6e 65 20 28 74 65 73 74 3a 67  e-inline (test:g
1230: 65 74 2d 72 75 6e 5f 69 64 20 76 65 63 29 20 20  et-run_id vec)  
1240: 20 28 76 65 63 74 6f 72 2d 72 65 66 20 76 65 63   (vector-ref vec
1250: 20 31 29 29 0a 28 64 65 66 69 6e 65 2d 69 6e 6c   1)).(define-inl
1260: 69 6e 65 20 28 74 65 73 74 3a 67 65 74 2d 74 65  ine (test:get-te
1270: 73 74 2d 6e 61 6d 65 20 76 65 63 29 28 76 65 63  st-name vec)(vec
1280: 74 6f 72 2d 72 65 66 20 76 65 63 20 32 29 29 0a  tor-ref vec 2)).
1290: 28 64 65 66 69 6e 65 2d 69 6e 6c 69 6e 65 20 28  (define-inline (
12a0: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 76  test:get-state v
12b0: 65 63 29 20 20 20 20 28 76 65 63 74 6f 72 2d 72  ec)    (vector-r
12c0: 65 66 20 76 65 63 20 33 29 29 0a 28 64 65 66 69  ef vec 3)).(defi
12d0: 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65 73 74 3a  ne-inline (test:
12e0: 67 65 74 2d 73 74 61 74 75 73 20 76 65 63 29 20  get-status vec) 
12f0: 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20 76 65    (vector-ref ve
1300: 63 20 34 29 29 0a 28 64 65 66 69 6e 65 2d 69 6e  c 4)).(define-in
1310: 6c 69 6e 65 20 28 74 65 73 74 3a 67 65 74 2d 69  line (test:get-i
1320: 74 65 6d 2d 70 61 74 68 20 76 65 63 29 28 76 65  tem-path vec)(ve
1330: 63 74 6f 72 2d 72 65 66 20 76 65 63 20 35 29 29  ctor-ref vec 5))
1340: 0a 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a  ..(define (runs:
1350: 74 65 73 74 2d 67 65 74 2d 66 75 6c 6c 2d 70 61  test-get-full-pa
1360: 74 68 20 74 65 73 74 29 0a 20 20 28 6c 65 74 2a  th test).  (let*
1370: 20 28 28 74 65 73 74 6e 61 6d 65 20 28 64 62 3a   ((testname (db:
1380: 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d  test-get-testnam
1390: 65 20 20 20 74 65 73 74 29 29 0a 09 20 28 69 74  e   test)).. (it
13a0: 65 6d 70 61 74 68 20 28 64 62 3a 74 65 73 74 2d  empath (db:test-
13b0: 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74 65  get-item-path te
13c0: 73 74 29 29 29 0a 20 20 20 20 28 63 6f 6e 63 20  st))).    (conc 
13d0: 74 65 73 74 6e 61 6d 65 20 28 69 66 20 28 65 71  testname (if (eq
13e0: 75 61 6c 3f 20 69 74 65 6d 70 61 74 68 20 22 22  ual? itempath ""
13f0: 29 20 22 22 20 28 63 6f 6e 63 20 22 28 22 20 69  ) "" (conc "(" i
1400: 74 65 6d 70 61 74 68 20 22 29 22 29 29 29 29 29  tempath ")")))))
1410: 0a 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69 6e 65  ..(define-inline
1420: 20 28 74 65 73 74 3a 74 65 73 74 2d 67 65 74 2d   (test:test-get-
1430: 66 75 6c 6c 6e 61 6d 65 20 74 65 73 74 29 0a 20  fullname test). 
1440: 20 20 28 63 6f 6e 63 20 28 64 62 3a 74 65 73 74    (conc (db:test
1450: 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 74 65  -get-testname te
1460: 73 74 29 0a 09 20 28 69 66 20 28 65 71 75 61 6c  st).. (if (equal
1470: 3f 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69  ? (db:test-get-i
1480: 74 65 6d 2d 70 61 74 68 20 74 65 73 74 29 20 22  tem-path test) "
1490: 22 29 0a 09 20 20 20 20 20 22 22 0a 09 20 20 20  ")..     ""..   
14a0: 20 20 28 63 6f 6e 63 20 22 28 22 20 28 64 62 3a    (conc "(" (db:
14b0: 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61  test-get-item-pa
14c0: 74 68 20 74 65 73 74 29 20 22 29 22 29 29 29 29  th test) ")"))))
14d0: 0a 0a 28 64 65 66 69 6e 65 20 28 63 68 65 63 6b  ..(define (check
14e0: 2d 76 61 6c 69 64 2d 69 74 65 6d 73 20 63 6c 61  -valid-items cla
14f0: 73 73 20 69 74 65 6d 29 0a 20 20 28 6c 65 74 20  ss item).  (let 
1500: 28 28 76 61 6c 69 64 2d 76 61 6c 75 65 73 20 28  ((valid-values (
1510: 6c 65 74 20 28 28 73 20 28 63 6f 6e 66 69 67 2d  let ((s (config-
1520: 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67 64 61  lookup *configda
1530: 74 2a 20 22 76 61 6c 69 64 76 61 6c 75 65 73 22  t* "validvalues"
1540: 20 63 6c 61 73 73 29 29 29 0a 09 09 09 28 69 66   class)))....(if
1550: 20 73 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74   s (string-split
1560: 20 73 29 20 23 66 29 29 29 29 0a 20 20 20 20 28   s) #f)))).    (
1570: 69 66 20 76 61 6c 69 64 2d 76 61 6c 75 65 73 0a  if valid-values.
1580: 09 28 69 66 20 28 6d 65 6d 62 65 72 20 69 74 65  .(if (member ite
1590: 6d 20 76 61 6c 69 64 2d 76 61 6c 75 65 73 29 0a  m valid-values).
15a0: 09 20 20 20 20 69 74 65 6d 20 23 66 29 0a 09 69  .    item #f)..i
15b0: 74 65 6d 29 29 29 0a 0a 28 64 65 66 69 6e 65 20  tem)))..(define 
15c0: 28 74 65 73 74 73 74 65 70 2d 73 65 74 2d 73 74  (teststep-set-st
15d0: 61 74 75 73 21 20 64 62 20 72 75 6e 2d 69 64 20  atus! db run-id 
15e0: 74 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 73 74  test-name testst
15f0: 65 70 2d 6e 61 6d 65 20 73 74 61 74 65 2d 69 6e  ep-name state-in
1600: 20 73 74 61 74 75 73 2d 69 6e 20 69 74 65 6d 64   status-in itemd
1610: 61 74 20 63 6f 6d 6d 65 6e 74 29 0a 20 20 3b 3b  at comment).  ;;
1620: 20 28 70 72 69 6e 74 20 22 72 75 6e 2d 69 64 3a   (print "run-id:
1630: 20 22 20 72 75 6e 2d 69 64 20 22 20 74 65 73 74   " run-id " test
1640: 2d 6e 61 6d 65 3a 20 22 20 74 65 73 74 2d 6e 61  -name: " test-na
1650: 6d 65 29 0a 20 20 28 6c 65 74 2a 20 28 28 73 74  me).  (let* ((st
1660: 61 74 65 20 20 20 20 20 28 63 68 65 63 6b 2d 76  ate     (check-v
1670: 61 6c 69 64 2d 69 74 65 6d 73 20 22 73 74 61 74  alid-items "stat
1680: 65 22 20 73 74 61 74 65 2d 69 6e 29 29 0a 09 20  e" state-in)).. 
1690: 28 73 74 61 74 75 73 20 20 20 20 28 63 68 65 63  (status    (chec
16a0: 6b 2d 76 61 6c 69 64 2d 69 74 65 6d 73 20 22 73  k-valid-items "s
16b0: 74 61 74 75 73 22 20 73 74 61 74 75 73 2d 69 6e  tatus" status-in
16c0: 29 29 0a 09 20 28 69 74 65 6d 2d 70 61 74 68 20  )).. (item-path 
16d0: 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68  (item-list->path
16e0: 20 69 74 65 6d 64 61 74 29 29 0a 09 20 28 74 65   itemdat)).. (te
16f0: 73 74 64 61 74 20 20 20 28 64 62 3a 67 65 74 2d  stdat   (db:get-
1700: 74 65 73 74 2d 69 6e 66 6f 20 64 62 20 72 75 6e  test-info db run
1710: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74  -id test-name it
1720: 65 6d 2d 70 61 74 68 29 29 29 0a 20 20 20 20 3b  em-path))).    ;
1730: 3b 20 28 70 72 69 6e 74 20 22 74 65 73 74 64 61  ; (print "testda
1740: 74 3a 20 22 20 74 65 73 74 64 61 74 29 0a 20 20  t: " testdat).  
1750: 20 20 28 69 66 20 28 61 6e 64 20 74 65 73 74 64    (if (and testd
1760: 61 74 20 3b 3b 20 69 66 20 74 68 65 20 73 65 63  at ;; if the sec
1770: 74 69 6f 6e 20 65 78 69 73 74 73 20 74 68 65 6e  tion exists then
1780: 20 66 6f 72 63 65 20 73 70 65 63 69 66 69 63 61   force specifica
1790: 74 69 6f 6e 20 42 55 47 2c 20 49 20 64 6f 6e 27  tion BUG, I don'
17a0: 74 20 6c 69 6b 65 20 68 6f 77 20 74 68 69 73 20  t like how this 
17b0: 77 6f 72 6b 73 2e 0a 09 20 20 20 20 20 28 6f 72  works...     (or
17c0: 20 28 6e 6f 74 20 73 74 61 74 65 29 28 6e 6f 74   (not state)(not
17d0: 20 73 74 61 74 75 73 29 29 29 0a 09 28 70 72 69   status)))..(pri
17e0: 6e 74 20 22 57 41 52 4e 49 4e 47 3a 20 49 6e 76  nt "WARNING: Inv
17f0: 61 6c 69 64 20 22 20 28 69 66 20 73 74 61 74 75  alid " (if statu
1800: 73 20 22 73 74 61 74 75 73 22 20 22 73 74 61 74  s "status" "stat
1810: 65 22 29 0a 09 20 20 20 20 20 20 20 22 20 76 61  e")..       " va
1820: 6c 75 65 20 5c 22 22 20 28 69 66 20 73 74 61 74  lue \"" (if stat
1830: 75 73 20 73 74 61 74 75 73 2d 69 6e 20 73 74 61  us status-in sta
1840: 74 65 2d 69 6e 29 20 22 5c 22 2c 20 75 70 64 61  te-in) "\", upda
1850: 74 65 20 79 6f 75 72 20 76 61 6c 69 64 73 74 61  te your validsta
1860: 74 65 73 20 73 65 63 74 69 6f 6e 20 69 6e 20 6d  tes section in m
1870: 65 67 61 74 65 73 74 2e 63 6f 6e 66 69 67 22 29  egatest.config")
1880: 29 0a 20 20 20 20 28 69 66 20 74 65 73 74 64 61  ).    (if testda
1890: 74 0a 09 28 6c 65 74 20 28 28 74 65 73 74 2d 69  t..(let ((test-i
18a0: 64 20 28 74 65 73 74 3a 67 65 74 2d 69 64 20 74  d (test:get-id t
18b0: 65 73 74 64 61 74 29 29 29 0a 09 20 20 28 73 71  estdat)))..  (sq
18c0: 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 64 62  lite3:execute db
18d0: 20 0a 09 09 09 22 49 4e 53 45 52 54 20 4f 52 20   ...."INSERT OR 
18e0: 52 45 50 4c 41 43 45 20 69 6e 74 6f 20 74 65 73  REPLACE into tes
18f0: 74 5f 73 74 65 70 73 20 28 74 65 73 74 5f 69 64  t_steps (test_id
1900: 2c 73 74 65 70 6e 61 6d 65 2c 73 74 61 74 65 2c  ,stepname,state,
1910: 73 74 61 74 75 73 2c 65 76 65 6e 74 5f 74 69 6d  status,event_tim
1920: 65 2c 63 6f 6d 6d 65 6e 74 29 20 56 41 4c 55 45  e,comment) VALUE
1930: 53 28 3f 2c 3f 2c 3f 2c 3f 2c 73 74 72 66 74 69  S(?,?,?,?,strfti
1940: 6d 65 28 27 25 73 27 2c 27 6e 6f 77 27 29 2c 3f  me('%s','now'),?
1950: 29 3b 22 0a 09 09 09 74 65 73 74 2d 69 64 20 74  );"....test-id t
1960: 65 73 74 73 74 65 70 2d 6e 61 6d 65 20 73 74 61  eststep-name sta
1970: 74 65 20 73 74 61 74 75 73 20 28 69 66 20 63 6f  te status (if co
1980: 6d 6d 65 6e 74 20 63 6f 6d 6d 65 6e 74 20 22 22  mment comment ""
1990: 29 29 29 0a 09 28 70 72 69 6e 74 20 22 45 52 52  )))..(print "ERR
19a0: 4f 52 3a 20 43 61 6e 27 74 20 75 70 64 61 74 65  OR: Can't update
19b0: 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 66   " test-name " f
19c0: 6f 72 20 72 75 6e 20 22 20 72 75 6e 2d 69 64 20  or run " run-id 
19d0: 22 20 2d 3e 20 6e 6f 20 73 75 63 68 20 74 65 73  " -> no such tes
19e0: 74 20 69 6e 20 64 62 22 29 29 29 29 0a 0a 28 64  t in db"))))..(d
19f0: 65 66 69 6e 65 20 28 74 65 73 74 2d 67 65 74 2d  efine (test-get-
1a00: 6b 69 6c 6c 2d 72 65 71 75 65 73 74 20 64 62 20  kill-request db 
1a10: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
1a20: 20 69 74 65 6d 64 61 74 29 0a 20 20 28 6c 65 74   itemdat).  (let
1a30: 2a 20 28 28 69 74 65 6d 2d 70 61 74 68 20 28 69  * ((item-path (i
1a40: 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69  tem-list->path i
1a50: 74 65 6d 64 61 74 29 29 0a 09 20 28 74 65 73 74  temdat)).. (test
1a60: 64 61 74 20 20 20 28 64 62 3a 67 65 74 2d 74 65  dat   (db:get-te
1a70: 73 74 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69  st-info db run-i
1a80: 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d  d test-name item
1a90: 2d 70 61 74 68 29 29 29 0a 20 20 20 20 28 65 71  -path))).    (eq
1aa0: 75 61 6c 3f 20 28 74 65 73 74 3a 67 65 74 2d 73  ual? (test:get-s
1ab0: 74 61 74 65 20 74 65 73 74 64 61 74 29 20 22 4b  tate testdat) "K
1ac0: 49 4c 4c 52 45 51 22 29 29 29 0a 0a 28 64 65 66  ILLREQ")))..(def
1ad0: 69 6e 65 20 28 74 65 73 74 2d 73 65 74 2d 6d 65  ine (test-set-me
1ae0: 74 61 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69  ta-info db run-i
1af0: 64 20 74 65 73 74 6e 61 6d 65 20 69 74 65 6d 64  d testname itemd
1b00: 61 74 29 0a 20 20 28 6c 65 74 20 28 28 69 74 65  at).  (let ((ite
1b10: 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c 69 73  m-path (item-lis
1b20: 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74 29  t->path itemdat)
1b30: 29 0a 09 28 63 70 75 6c 6f 61 64 20 20 28 67 65  )..(cpuload  (ge
1b40: 74 2d 63 70 75 2d 6c 6f 61 64 29 29 0a 09 28 68  t-cpu-load))..(h
1b50: 6f 73 74 6e 61 6d 65 20 28 67 65 74 2d 68 6f 73  ostname (get-hos
1b60: 74 2d 6e 61 6d 65 29 29 0a 09 28 64 69 73 6b 66  t-name))..(diskf
1b70: 72 65 65 20 28 67 65 74 2d 64 66 20 28 63 75 72  ree (get-df (cur
1b80: 72 65 6e 74 2d 64 69 72 65 63 74 6f 72 79 29 29  rent-directory))
1b90: 29 0a 09 28 75 6e 61 6d 65 20 20 20 20 28 67 65  )..(uname    (ge
1ba0: 74 2d 75 6e 61 6d 65 20 22 2d 73 72 76 70 69 6f  t-uname "-srvpio
1bb0: 22 29 29 0a 09 28 72 75 6e 70 61 74 68 20 20 28  "))..(runpath  (
1bc0: 63 75 72 72 65 6e 74 2d 64 69 72 65 63 74 6f 72  current-director
1bd0: 79 29 29 29 0a 20 20 20 20 28 73 71 6c 69 74 65  y))).    (sqlite
1be0: 33 3a 65 78 65 63 75 74 65 20 64 62 20 22 55 50  3:execute db "UP
1bf0: 44 41 54 45 20 74 65 73 74 73 20 53 45 54 20 68  DATE tests SET h
1c00: 6f 73 74 3d 3f 2c 63 70 75 6c 6f 61 64 3d 3f 2c  ost=?,cpuload=?,
1c10: 64 69 73 6b 66 72 65 65 3d 3f 2c 75 6e 61 6d 65  diskfree=?,uname
1c20: 3d 3f 2c 72 75 6e 64 69 72 3d 3f 20 57 48 45 52  =?,rundir=? WHER
1c30: 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74  E run_id=? AND t
1c40: 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74  estname=? AND it
1c50: 65 6d 5f 70 61 74 68 3d 3f 3b 22 0a 09 09 20 20  em_path=?;"...  
1c60: 68 6f 73 74 6e 61 6d 65 0a 09 09 20 20 63 70 75  hostname...  cpu
1c70: 6c 6f 61 64 0a 09 09 20 20 64 69 73 6b 66 72 65  load...  diskfre
1c80: 65 0a 09 09 20 20 75 6e 61 6d 65 0a 09 09 20 20  e...  uname...  
1c90: 72 75 6e 70 61 74 68 0a 09 09 20 20 72 75 6e 2d  runpath...  run-
1ca0: 69 64 0a 09 09 20 20 74 65 73 74 6e 61 6d 65 0a  id...  testname.
1cb0: 09 09 20 20 69 74 65 6d 2d 70 61 74 68 29 29 29  ..  item-path)))
1cc0: 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73 74 2d  ..(define (test-
1cd0: 75 70 64 61 74 65 2d 6d 65 74 61 2d 69 6e 66 6f  update-meta-info
1ce0: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 6e   db run-id testn
1cf0: 61 6d 65 20 69 74 65 6d 64 61 74 20 6d 69 6e 75  ame itemdat minu
1d00: 74 65 73 29 0a 20 20 28 6c 65 74 20 28 28 69 74  tes).  (let ((it
1d10: 65 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c 69  em-path (item-li
1d20: 73 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74  st->path itemdat
1d30: 29 29 0a 09 28 63 70 75 6c 6f 61 64 20 20 28 67  ))..(cpuload  (g
1d40: 65 74 2d 63 70 75 2d 6c 6f 61 64 29 29 0a 09 28  et-cpu-load))..(
1d50: 64 69 73 6b 66 72 65 65 20 28 67 65 74 2d 64 66  diskfree (get-df
1d60: 20 28 63 75 72 72 65 6e 74 2d 64 69 72 65 63 74   (current-direct
1d70: 6f 72 79 29 29 29 29 0a 20 20 20 20 28 69 66 20  ory)))).    (if 
1d80: 28 6e 6f 74 20 63 70 75 6c 6f 61 64 29 20 20 28  (not cpuload)  (
1d90: 62 65 67 69 6e 20 28 70 72 69 6e 74 20 22 57 41  begin (print "WA
1da0: 52 4e 49 4e 47 3a 20 43 50 55 4c 4f 41 44 20 6e  RNING: CPULOAD n
1db0: 6f 74 20 66 6f 75 6e 64 2e 22 29 20 20 28 73 65  ot found.")  (se
1dc0: 74 21 20 63 70 75 6c 6f 61 64 20 22 6e 2f 61 22  t! cpuload "n/a"
1dd0: 29 29 29 0a 20 20 20 20 28 69 66 20 28 6e 6f 74  ))).    (if (not
1de0: 20 64 69 73 6b 66 72 65 65 29 20 28 62 65 67 69   diskfree) (begi
1df0: 6e 20 28 70 72 69 6e 74 20 22 57 41 52 4e 49 4e  n (print "WARNIN
1e00: 47 3a 20 44 49 53 4b 46 52 45 45 20 6e 6f 74 20  G: DISKFREE not 
1e10: 66 6f 75 6e 64 2e 22 29 20 28 73 65 74 21 20 64  found.") (set! d
1e20: 69 73 6b 66 72 65 65 20 22 6e 2f 61 22 29 29 29  iskfree "n/a")))
1e30: 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 69 74  .    (if (not it
1e40: 65 6d 2d 70 61 74 68 29 28 62 65 67 69 6e 20 28  em-path)(begin (
1e50: 70 72 69 6e 74 20 22 57 41 52 4e 49 4e 47 3a 20  print "WARNING: 
1e60: 49 54 45 4d 50 41 54 48 20 6e 6f 74 20 73 65 74  ITEMPATH not set
1e70: 2e 22 29 20 20 20 28 73 65 74 21 20 69 74 65 6d  .")   (set! item
1e80: 2d 70 61 74 68 20 22 22 29 29 29 0a 20 20 20 20  -path ""))).    
1e90: 3b 3b 20 28 6c 65 74 20 28 28 74 65 73 74 69 6e  ;; (let ((testin
1ea0: 66 6f 20 28 64 62 3a 67 65 74 2d 74 65 73 74 2d  fo (db:get-test-
1eb0: 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74  info db run-id t
1ec0: 65 73 74 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74  estname item-pat
1ed0: 68 29 29 29 0a 20 20 20 20 3b 3b 20 20 20 28 69  h))).    ;;   (i
1ee0: 66 20 28 61 6e 64 20 28 6e 6f 74 20 28 65 71 75  f (and (not (equ
1ef0: 61 6c 3f 20 28 64 62 3a 74 65 73 74 2d 67 65 74  al? (db:test-get
1f00: 2d 73 74 61 74 75 73 20 74 65 73 74 69 6e 66 6f  -status testinfo
1f10: 29 20 22 43 4f 4d 50 4c 45 54 45 44 22 29 29 0a  ) "COMPLETED")).
1f20: 20 20 20 20 3b 3b 20 20 20 20 20 20 20 20 20 20      ;;          
1f30: 20 20 28 6e 6f 74 20 28 65 71 75 61 6c 3f 20 28    (not (equal? (
1f40: 64 62 3a 74 65 73 74 2d 67 65 74 2d 73 74 61 74  db:test-get-stat
1f50: 75 73 20 74 65 73 74 69 6e 66 6f 29 20 22 4b 49  us testinfo) "KI
1f60: 4c 4c 52 45 51 22 29 29 0a 20 20 20 20 28 73 71  LLREQ")).    (sq
1f70: 6c 69 74 65 33 3a 65 78 65 63 75 74 65 0a 20 20  lite3:execute.  
1f80: 20 20 20 64 62 0a 20 20 20 20 20 22 55 50 44 41     db.     "UPDA
1f90: 54 45 20 74 65 73 74 73 20 53 45 54 20 63 70 75  TE tests SET cpu
1fa0: 6c 6f 61 64 3d 3f 2c 64 69 73 6b 66 72 65 65 3d  load=?,diskfree=
1fb0: 3f 2c 72 75 6e 5f 64 75 72 61 74 69 6f 6e 3d 3f  ?,run_duration=?
1fc0: 2c 73 74 61 74 65 3d 27 52 55 4e 4e 49 4e 47 27  ,state='RUNNING'
1fd0: 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20   WHERE run_id=? 
1fe0: 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41  AND testname=? A
1ff0: 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f 20 41  ND item_path=? A
2000: 4e 44 20 73 74 61 74 65 20 4e 4f 54 20 49 4e 20  ND state NOT IN 
2010: 28 27 43 4f 4d 50 4c 45 54 45 44 27 2c 27 4b 49  ('COMPLETED','KI
2020: 4c 4c 52 45 51 27 2c 27 4b 49 4c 4c 45 44 27 29  LLREQ','KILLED')
2030: 3b 22 0a 20 20 20 20 20 63 70 75 6c 6f 61 64 0a  ;".     cpuload.
2040: 20 20 20 20 20 64 69 73 6b 66 72 65 65 0a 20 20       diskfree.  
2050: 20 20 20 6d 69 6e 75 74 65 73 0a 20 20 20 20 20     minutes.     
2060: 72 75 6e 2d 69 64 0a 20 20 20 20 20 74 65 73 74  run-id.     test
2070: 6e 61 6d 65 0a 20 20 20 20 20 69 74 65 6d 2d 70  name.     item-p
2080: 61 74 68 29 29 29 0a 0a 28 64 65 66 69 6e 65 20  ath)))..(define 
2090: 28 73 65 74 2d 6d 65 67 61 74 65 73 74 2d 65 6e  (set-megatest-en
20a0: 76 2d 76 61 72 73 20 64 62 20 72 75 6e 2d 69 64  v-vars db run-id
20b0: 29 0a 20 20 28 6c 65 74 20 28 28 6b 65 79 73 20  ).  (let ((keys 
20c0: 28 64 62 2d 67 65 74 2d 6b 65 79 73 20 64 62 29  (db-get-keys db)
20d0: 29 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68  )).    (for-each
20e0: 20 28 6c 61 6d 62 64 61 20 28 6b 65 79 29 0a 09   (lambda (key)..
20f0: 09 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61  .(sqlite3:for-ea
2100: 63 68 2d 72 6f 77 0a 09 09 20 28 6c 61 6d 62 64  ch-row... (lambd
2110: 61 20 28 76 61 6c 29 0a 09 09 20 20 20 28 70 72  a (val)...   (pr
2120: 69 6e 74 20 22 73 65 74 65 6e 76 20 22 20 28 6b  int "setenv " (k
2130: 65 79 3a 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65  ey:get-fieldname
2140: 20 6b 65 79 29 20 22 20 22 20 76 61 6c 29 0a 09   key) " " val)..
2150: 09 20 20 20 28 73 65 74 65 6e 76 20 28 6b 65 79  .   (setenv (key
2160: 3a 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b  :get-fieldname k
2170: 65 79 29 20 76 61 6c 29 29 0a 09 09 20 64 62 20  ey) val))... db 
2180: 0a 09 09 20 28 63 6f 6e 63 20 22 53 45 4c 45 43  ... (conc "SELEC
2190: 54 20 22 20 28 6b 65 79 3a 67 65 74 2d 66 69 65  T " (key:get-fie
21a0: 6c 64 6e 61 6d 65 20 6b 65 79 29 20 22 20 46 52  ldname key) " FR
21b0: 4f 4d 20 72 75 6e 73 20 57 48 45 52 45 20 69 64  OM runs WHERE id
21c0: 3d 3f 3b 22 29 0a 09 09 20 72 75 6e 2d 69 64 29  =?;")... run-id)
21d0: 29 0a 09 20 20 20 20 20 20 6b 65 79 73 29 29 29  )..      keys)))
21e0: 0a 0a 28 64 65 66 69 6e 65 20 28 73 65 74 2d 69  ..(define (set-i
21f0: 74 65 6d 2d 65 6e 76 2d 76 61 72 73 20 69 74 65  tem-env-vars ite
2200: 6d 64 61 74 29 0a 20 20 28 66 6f 72 2d 65 61 63  mdat).  (for-eac
2210: 68 20 28 6c 61 6d 62 64 61 20 28 69 74 65 6d 29  h (lambda (item)
2220: 0a 09 20 20 20 20 20 20 28 70 72 69 6e 74 20 22  ..      (print "
2230: 73 65 74 65 6e 76 20 22 20 28 63 61 72 20 69 74  setenv " (car it
2240: 65 6d 29 20 22 20 22 20 28 63 61 64 72 20 69 74  em) " " (cadr it
2250: 65 6d 29 29 0a 09 20 20 20 20 20 20 28 73 65 74  em))..      (set
2260: 65 6e 76 20 28 63 61 72 20 69 74 65 6d 29 20 28  env (car item) (
2270: 63 61 64 72 20 69 74 65 6d 29 29 29 0a 09 20 20  cadr item)))..  
2280: 20 20 69 74 65 6d 64 61 74 29 29 0a 0a 28 64 65    itemdat))..(de
2290: 66 69 6e 65 20 28 67 65 74 2d 61 6c 6c 2d 6c 65  fine (get-all-le
22a0: 67 61 6c 2d 74 65 73 74 73 29 0a 20 20 28 6c 65  gal-tests).  (le
22b0: 74 2a 20 28 28 74 65 73 74 73 20 20 28 67 6c 6f  t* ((tests  (glo
22c0: 62 20 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74 68  b (conc *toppath
22d0: 2a 20 22 2f 74 65 73 74 73 2f 2a 22 29 29 29 0a  * "/tests/*"))).
22e0: 09 20 28 72 65 73 20 20 20 20 27 28 29 29 29 0a  . (res    '())).
22f0: 20 20 20 20 3b 3b 20 28 70 72 69 6e 74 20 22 49      ;; (print "I
2300: 4e 46 4f 3a 20 4c 6f 6f 6b 69 6e 67 20 61 74 20  NFO: Looking at 
2310: 74 65 73 74 73 20 22 20 28 73 74 72 69 6e 67 2d  tests " (string-
2320: 69 6e 74 65 72 73 70 65 72 73 65 20 74 65 73 74  intersperse test
2330: 73 20 22 2c 22 29 29 0a 20 20 20 20 28 66 6f 72  s ",")).    (for
2340: 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 20 28 74  -each (lambda (t
2350: 65 73 74 70 61 74 68 29 0a 09 09 28 69 66 20 28  estpath)...(if (
2360: 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 28 63 6f  file-exists? (co
2370: 6e 63 20 74 65 73 74 70 61 74 68 20 22 2f 74 65  nc testpath "/te
2380: 73 74 63 6f 6e 66 69 67 22 29 29 0a 09 09 20 20  stconfig"))...  
2390: 20 20 28 73 65 74 21 20 72 65 73 20 28 63 6f 6e    (set! res (con
23a0: 73 20 28 6c 61 73 74 20 28 73 74 72 69 6e 67 2d  s (last (string-
23b0: 73 70 6c 69 74 20 74 65 73 74 70 61 74 68 20 22  split testpath "
23c0: 2f 22 29 29 20 72 65 73 29 29 29 29 0a 09 20 20  /")) res))))..  
23d0: 20 20 20 20 74 65 73 74 73 29 0a 20 20 20 20 72      tests).    r
23e0: 65 73 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 72  es))..(define (r
23f0: 75 6e 2d 74 65 73 74 73 20 64 62 20 74 65 73 74  un-tests db test
2400: 2d 6e 61 6d 65 73 29 0a 20 20 28 66 6f 72 2d 65  -names).  (for-e
2410: 61 63 68 20 0a 20 20 20 28 6c 61 6d 62 64 61 20  ach .   (lambda 
2420: 28 74 65 73 74 2d 6e 61 6d 65 29 0a 20 20 20 20  (test-name).    
2430: 20 28 6c 65 74 20 28 28 6e 75 6d 2d 72 75 6e 6e   (let ((num-runn
2440: 69 6e 67 20 28 64 62 3a 67 65 74 2d 63 6f 75 6e  ing (db:get-coun
2450: 74 2d 74 65 73 74 73 2d 72 75 6e 6e 69 6e 67 20  t-tests-running 
2460: 64 62 29 29 0a 09 20 20 20 28 6d 61 78 2d 63 6f  db))..   (max-co
2470: 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 20 28 63  ncurrent-jobs (c
2480: 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f  onfig-lookup *co
2490: 6e 66 69 67 64 61 74 2a 20 22 73 65 74 75 70 22  nfigdat* "setup"
24a0: 20 22 6d 61 78 5f 63 6f 6e 63 75 72 72 65 6e 74   "max_concurrent
24b0: 5f 6a 6f 62 73 22 29 29 29 0a 20 20 20 20 20 20  _jobs"))).      
24c0: 20 28 70 72 69 6e 74 20 22 6d 61 78 2d 63 6f 6e   (print "max-con
24d0: 63 75 72 72 65 6e 74 2d 6a 6f 62 73 3a 20 22 20  current-jobs: " 
24e0: 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a  max-concurrent-j
24f0: 6f 62 73 20 22 2c 20 6e 75 6d 2d 72 75 6e 6e 69  obs ", num-runni
2500: 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69 6e  ng: " num-runnin
2510: 67 29 0a 20 20 20 20 20 20 20 28 69 66 20 28 6f  g).       (if (o
2520: 72 20 28 6e 6f 74 20 6d 61 78 2d 63 6f 6e 63 75  r (not max-concu
2530: 72 72 65 6e 74 2d 6a 6f 62 73 29 0a 09 20 20 20  rrent-jobs)..   
2540: 20 20 20 20 28 61 6e 64 20 6d 61 78 2d 63 6f 6e      (and max-con
2550: 63 75 72 72 65 6e 74 2d 6a 6f 62 73 0a 09 09 20  current-jobs... 
2560: 20 20 20 28 73 74 72 69 6e 67 2d 3e 6e 75 6d 62     (string->numb
2570: 65 72 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e  er max-concurren
2580: 74 2d 6a 6f 62 73 29 0a 09 09 20 20 20 20 28 6e  t-jobs)...    (n
2590: 6f 74 20 28 3e 20 6e 75 6d 2d 72 75 6e 6e 69 6e  ot (> num-runnin
25a0: 67 20 28 73 74 72 69 6e 67 2d 3e 6e 75 6d 62 65  g (string->numbe
25b0: 72 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74  r max-concurrent
25c0: 2d 6a 6f 62 73 29 29 29 29 29 0a 09 20 20 20 28  -jobs)))))..   (
25d0: 72 75 6e 2d 6f 6e 65 2d 74 65 73 74 20 64 62 20  run-one-test db 
25e0: 74 65 73 74 2d 6e 61 6d 65 29 0a 09 20 20 20 28  test-name)..   (
25f0: 70 72 69 6e 74 20 22 57 41 52 4e 49 4e 47 3a 20  print "WARNING: 
2600: 4d 61 78 20 72 75 6e 6e 69 6e 67 20 6a 6f 62 73  Max running jobs
2610: 20 65 78 63 65 65 64 65 64 2c 20 63 75 72 72 65   exceeded, curre
2620: 6e 74 20 6e 75 6d 62 65 72 20 72 75 6e 6e 69 6e  nt number runnin
2630: 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67  g: " num-running
2640: 20 0a 09 09 20 20 22 2c 20 6d 61 78 5f 63 6f 6e   ...  ", max_con
2650: 63 75 72 72 65 6e 74 5f 6a 6f 62 73 3a 20 22 20  current_jobs: " 
2660: 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a  max-concurrent-j
2670: 6f 62 73 29 29 29 29 0a 20 20 20 74 65 73 74 2d  obs)))).   test-
2680: 6e 61 6d 65 73 29 29 0a 0a 28 64 65 66 69 6e 65  names))..(define
2690: 20 28 72 75 6e 2d 6f 6e 65 2d 74 65 73 74 20 64   (run-one-test d
26a0: 62 20 74 65 73 74 2d 6e 61 6d 65 29 0a 20 20 28  b test-name).  (
26b0: 70 72 69 6e 74 20 22 4c 61 75 6e 63 68 69 6e 67  print "Launching
26c0: 20 74 65 73 74 20 22 20 74 65 73 74 2d 6e 61 6d   test " test-nam
26d0: 65 29 0a 20 20 28 6c 65 74 2a 20 28 28 74 65 73  e).  (let* ((tes
26e0: 74 2d 70 61 74 68 20 20 20 20 28 63 6f 6e 63 20  t-path    (conc 
26f0: 2a 74 6f 70 70 61 74 68 2a 20 22 2f 74 65 73 74  *toppath* "/test
2700: 73 2f 22 20 74 65 73 74 2d 6e 61 6d 65 29 29 0a  s/" test-name)).
2710: 09 20 28 74 65 73 74 2d 63 6f 6e 66 69 67 66 20  . (test-configf 
2720: 28 63 6f 6e 63 20 74 65 73 74 2d 70 61 74 68 20  (conc test-path 
2730: 22 2f 74 65 73 74 63 6f 6e 66 69 67 22 29 29 0a  "/testconfig")).
2740: 09 20 28 74 65 73 74 65 78 69 73 74 73 20 20 20  . (testexists   
2750: 28 61 6e 64 20 28 66 69 6c 65 2d 65 78 69 73 74  (and (file-exist
2760: 73 3f 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 29  s? test-configf)
2770: 28 66 69 6c 65 2d 72 65 61 64 2d 61 63 63 65 73  (file-read-acces
2780: 73 3f 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 29  s? test-configf)
2790: 29 29 0a 09 20 28 74 65 73 74 2d 63 6f 6e 66 20  )).. (test-conf 
27a0: 20 20 20 28 69 66 20 74 65 73 74 65 78 69 73 74     (if testexist
27b0: 73 20 28 72 65 61 64 2d 63 6f 6e 66 69 67 20 74  s (read-config t
27c0: 65 73 74 2d 63 6f 6e 66 69 67 66 29 20 28 6d 61  est-configf) (ma
27d0: 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29 29  ke-hash-table)))
27e0: 0a 09 20 28 77 61 69 74 6f 6e 20 20 20 20 20 20  .. (waiton      
27f0: 20 28 6c 65 74 20 28 28 77 20 28 63 6f 6e 66 69   (let ((w (confi
2800: 67 2d 6c 6f 6f 6b 75 70 20 74 65 73 74 2d 63 6f  g-lookup test-co
2810: 6e 66 20 22 72 65 71 75 69 72 65 6d 65 6e 74 73  nf "requirements
2820: 22 20 22 77 61 69 74 6f 6e 22 29 29 29 0a 09 09  " "waiton")))...
2830: 09 20 28 69 66 20 28 73 74 72 69 6e 67 3f 20 77  . (if (string? w
2840: 29 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 77  )(string-split w
2850: 29 27 28 29 29 29 29 29 0a 20 20 20 20 28 69 66  )'())))).    (if
2860: 20 28 6e 6f 74 20 74 65 73 74 65 78 69 73 74 73   (not testexists
2870: 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 28 70 72  )..(begin..  (pr
2880: 69 6e 74 20 22 45 52 52 4f 52 3a 20 43 61 6e 27  int "ERROR: Can'
2890: 74 20 66 69 6e 64 20 63 6f 6e 66 69 67 20 66 69  t find config fi
28a0: 6c 65 20 22 20 74 65 73 74 2d 63 6f 6e 66 69 67  le " test-config
28b0: 66 29 0a 09 20 20 28 65 78 69 74 20 32 29 29 0a  f)..  (exit 2)).
28c0: 09 3b 3b 20 70 75 74 20 74 6f 70 20 76 61 72 73  .;; put top vars
28d0: 20 69 6e 74 6f 20 63 6f 6e 76 65 6e 69 65 6e 74   into convenient
28e0: 20 76 61 72 69 61 62 6c 65 73 20 61 6e 64 20 6f   variables and o
28f0: 70 65 6e 20 74 68 65 20 64 62 0a 09 28 6c 65 74  pen the db..(let
2900: 2a 20 28 3b 3b 20 64 62 20 69 73 20 61 6c 77 61  * (;; db is alwa
2910: 79 73 20 61 74 20 2a 74 6f 70 70 61 74 68 2a 2f  ys at *toppath*/
2920: 64 62 2f 6d 65 67 61 74 65 73 74 2e 64 62 0a 09  db/megatest.db..
2930: 20 20 20 20 20 20 20 28 6b 65 79 73 20 20 20 20         (keys    
2940: 20 20 20 20 28 64 62 2d 67 65 74 2d 6b 65 79 73      (db-get-keys
2950: 20 64 62 29 29 0a 09 20 20 20 20 20 20 20 28 6b   db))..       (k
2960: 65 79 76 61 6c 6c 73 74 20 20 20 28 6b 65 79 73  eyvallst   (keys
2970: 2d 3e 76 61 6c 6c 69 73 74 20 6b 65 79 73 20 23  ->vallist keys #
2980: 74 29 29 0a 09 20 20 20 20 20 20 20 28 69 74 65  t))..       (ite
2990: 6d 73 20 20 20 20 20 20 20 28 68 61 73 68 2d 74  ms       (hash-t
29a0: 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74  able-ref/default
29b0: 20 74 65 73 74 2d 63 6f 6e 66 20 22 69 74 65 6d   test-conf "item
29c0: 73 22 20 23 66 29 29 0a 09 20 20 20 20 20 20 20  s" #f))..       
29d0: 28 61 6c 6c 69 74 65 6d 73 20 20 20 20 28 69 74  (allitems    (it
29e0: 65 6d 2d 61 73 73 6f 63 2d 3e 69 74 65 6d 2d 6c  em-assoc->item-l
29f0: 69 73 74 20 69 74 65 6d 73 29 29 0a 09 20 20 20  ist items))..   
2a00: 20 20 20 20 28 72 75 6e 2d 69 64 20 20 20 20 20      (run-id     
2a10: 20 28 72 65 67 69 73 74 65 72 2d 72 75 6e 20 64   (register-run d
2a20: 62 20 6b 65 79 73 29 29 20 3b 3b 20 20 74 65 73  b keys)) ;;  tes
2a30: 74 2d 6e 61 6d 65 29 29 29 0a 09 20 20 20 20 20  t-name)))..     
2a40: 20 20 28 72 75 6e 63 6f 6e 66 69 67 66 20 20 28    (runconfigf  (
2a50: 63 6f 6e 63 20 20 2a 74 6f 70 70 61 74 68 2a 20  conc  *toppath* 
2a60: 22 2f 72 75 6e 63 6f 6e 66 69 67 73 2e 63 6f 6e  "/runconfigs.con
2a70: 66 69 67 22 29 29 29 0a 09 20 20 3b 3b 20 28 70  fig")))..  ;; (p
2a80: 72 69 6e 74 20 22 69 74 65 6d 73 3a 20 22 29 28  rint "items: ")(
2a90: 70 70 20 61 6c 6c 69 74 65 6d 73 29 0a 09 20 20  pp allitems)..  
2aa0: 28 69 66 20 28 61 72 67 73 3a 67 65 74 2d 61 72  (if (args:get-ar
2ab0: 67 20 22 2d 6d 22 29 0a 09 20 20 20 20 20 20 28  g "-m")..      (
2ac0: 64 62 3a 73 65 74 2d 63 6f 6d 6d 65 6e 74 2d 66  db:set-comment-f
2ad0: 6f 72 2d 72 75 6e 20 64 62 20 72 75 6e 2d 69 64  or-run db run-id
2ae0: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22   (args:get-arg "
2af0: 2d 6d 22 29 29 29 0a 09 20 20 28 6c 65 74 20 6c  -m")))..  (let l
2b00: 6f 6f 70 20 28 28 69 74 65 6d 64 61 74 20 28 63  oop ((itemdat (c
2b10: 61 72 20 61 6c 6c 69 74 65 6d 73 29 29 0a 09 09  ar allitems))...
2b20: 20 20 20 20 20 28 74 61 6c 20 20 20 20 20 28 63       (tal     (c
2b30: 64 72 20 61 6c 6c 69 74 65 6d 73 29 29 29 0a 09  dr allitems)))..
2b40: 20 20 20 20 3b 3b 20 28 6c 61 6d 62 64 61 20 28      ;; (lambda (
2b50: 69 74 65 6d 64 61 74 29 20 3b 3b 3b 20 28 28 72  itemdat) ;;; ((r
2b60: 69 70 65 6e 65 73 73 20 22 6f 76 65 72 72 69 70  ipeness "overrip
2b70: 65 22 29 20 28 74 65 6d 70 65 72 61 74 75 72 65  e") (temperature
2b80: 20 22 63 6f 6f 6c 22 29 20 28 73 65 61 73 6f 6e   "cool") (season
2b90: 20 22 73 75 6d 6d 65 72 22 29 29 0a 09 20 20 20   "summer"))..   
2ba0: 20 28 6c 65 74 2a 20 28 28 69 74 65 6d 2d 70 61   (let* ((item-pa
2bb0: 74 68 20 20 20 20 20 28 69 74 65 6d 2d 6c 69 73  th     (item-lis
2bc0: 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74 29  t->path itemdat)
2bd0: 29 20 3b 3b 20 28 73 74 72 69 6e 67 2d 69 6e 74  ) ;; (string-int
2be0: 65 72 73 70 65 72 73 65 20 28 6d 61 70 20 63 61  ersperse (map ca
2bf0: 64 72 20 69 74 65 6d 64 61 74 29 20 22 2f 22 29  dr itemdat) "/")
2c00: 29 0a 09 09 20 20 20 28 6e 65 77 2d 74 65 73 74  )...   (new-test
2c10: 2d 70 61 74 68 20 28 73 74 72 69 6e 67 2d 69 6e  -path (string-in
2c20: 74 65 72 73 70 65 72 73 65 20 28 63 6f 6e 73 20  tersperse (cons 
2c30: 74 65 73 74 2d 70 61 74 68 20 28 6d 61 70 20 63  test-path (map c
2c40: 61 64 72 20 69 74 65 6d 64 61 74 29 29 20 22 2f  adr itemdat)) "/
2c50: 22 29 29 0a 09 09 20 20 20 28 6e 65 77 2d 74 65  "))...   (new-te
2c60: 73 74 2d 6e 61 6d 65 20 28 69 66 20 28 65 71 75  st-name (if (equ
2c70: 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 22  al? item-path ""
2c80: 29 20 74 65 73 74 2d 6e 61 6d 65 20 28 63 6f 6e  ) test-name (con
2c90: 63 20 74 65 73 74 2d 6e 61 6d 65 20 22 2f 22 20  c test-name "/" 
2ca0: 69 74 65 6d 2d 70 61 74 68 29 29 29 20 3b 3b 20  item-path))) ;; 
2cb0: 6a 75 73 74 20 6e 65 65 64 20 69 74 20 74 6f 20  just need it to 
2cc0: 62 65 20 75 6e 69 71 75 65 0a 09 09 20 20 20 28  be unique...   (
2cd0: 74 65 73 74 2d 73 74 61 74 75 73 20 20 20 23 66  test-status   #f
2ce0: 29 0a 09 09 20 20 20 28 6e 75 6d 2d 72 75 6e 6e  )...   (num-runn
2cf0: 69 6e 67 20 28 64 62 3a 67 65 74 2d 63 6f 75 6e  ing (db:get-coun
2d00: 74 2d 74 65 73 74 73 2d 72 75 6e 6e 69 6e 67 20  t-tests-running 
2d10: 64 62 29 29 0a 09 09 20 20 20 28 6d 61 78 2d 63  db))...   (max-c
2d20: 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 20 28  oncurrent-jobs (
2d30: 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 2a 63  config-lookup *c
2d40: 6f 6e 66 69 67 64 61 74 2a 20 22 73 65 74 75 70  onfigdat* "setup
2d50: 22 20 22 6d 61 78 5f 63 6f 6e 63 75 72 72 65 6e  " "max_concurren
2d60: 74 5f 6a 6f 62 73 22 29 29 29 0a 09 20 20 20 20  t_jobs")))..    
2d70: 20 20 28 70 72 69 6e 74 20 22 6d 61 78 2d 63 6f    (print "max-co
2d80: 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 3a 20 22  ncurrent-jobs: "
2d90: 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d   max-concurrent-
2da0: 6a 6f 62 73 20 22 2c 20 6e 75 6d 2d 72 75 6e 6e  jobs ", num-runn
2db0: 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69  ing: " num-runni
2dc0: 6e 67 29 0a 09 20 20 20 20 20 20 28 69 66 20 28  ng)..      (if (
2dd0: 6e 6f 74 20 28 6f 72 20 28 6e 6f 74 20 6d 61 78  not (or (not max
2de0: 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73  -concurrent-jobs
2df0: 29 0a 09 09 09 20 20 20 28 61 6e 64 20 6d 61 78  )....   (and max
2e00: 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73  -concurrent-jobs
2e10: 0a 09 09 09 09 28 73 74 72 69 6e 67 2d 3e 6e 75  .....(string->nu
2e20: 6d 62 65 72 20 6d 61 78 2d 63 6f 6e 63 75 72 72  mber max-concurr
2e30: 65 6e 74 2d 6a 6f 62 73 29 0a 09 09 09 09 28 6e  ent-jobs).....(n
2e40: 6f 74 20 28 3e 20 6e 75 6d 2d 72 75 6e 6e 69 6e  ot (> num-runnin
2e50: 67 20 28 73 74 72 69 6e 67 2d 3e 6e 75 6d 62 65  g (string->numbe
2e60: 72 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74  r max-concurrent
2e70: 2d 6a 6f 62 73 29 29 29 29 29 29 0a 09 09 20 20  -jobs))))))...  
2e80: 28 70 72 69 6e 74 20 22 57 41 52 4e 49 4e 47 3a  (print "WARNING:
2e90: 20 4d 61 78 20 72 75 6e 6e 69 6e 67 20 6a 6f 62   Max running job
2ea0: 73 20 65 78 63 65 65 64 65 64 2c 20 63 75 72 72  s exceeded, curr
2eb0: 65 6e 74 20 6e 75 6d 62 65 72 20 72 75 6e 6e 69  ent number runni
2ec0: 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69 6e  ng: " num-runnin
2ed0: 67 20 0a 09 09 09 20 22 2c 20 6d 61 78 5f 63 6f  g .... ", max_co
2ee0: 6e 63 75 72 72 65 6e 74 5f 6a 6f 62 73 3a 20 22  ncurrent_jobs: "
2ef0: 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d   max-concurrent-
2f00: 6a 6f 62 73 29 0a 09 09 20 20 28 62 65 67 69 6e  jobs)...  (begin
2f10: 0a 09 09 20 20 20 20 28 6c 65 74 20 6c 6f 6f 70  ...    (let loop
2f20: 32 20 28 28 74 73 20 23 66 29 0a 09 09 09 09 28  2 ((ts #f).....(
2f30: 63 74 20 30 29 29 0a 09 09 20 20 20 20 20 20 28  ct 0))...      (
2f40: 69 66 20 28 61 6e 64 20 28 6e 6f 74 20 74 73 29  if (and (not ts)
2f50: 0a 09 09 09 20 20 20 20 20 20 20 28 3c 20 63 74  ....       (< ct
2f60: 20 31 30 29 29 0a 09 09 09 20 20 28 62 65 67 69   10))....  (begi
2f70: 6e 0a 09 09 09 20 20 20 20 28 72 65 67 69 73 74  n....    (regist
2f80: 65 72 2d 74 65 73 74 20 64 62 20 72 75 6e 2d 69  er-test db run-i
2f90: 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d  d test-name item
2fa0: 2d 70 61 74 68 29 0a 09 09 09 20 20 20 20 28 64  -path)....    (d
2fb0: 62 3a 74 65 73 74 2d 73 65 74 2d 63 6f 6d 6d 65  b:test-set-comme
2fc0: 6e 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  nt db run-id tes
2fd0: 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68  t-name item-path
2fe0: 20 22 22 29 0a 09 09 09 20 20 20 20 3b 3b 20 28   "")....    ;; (
2ff0: 74 65 73 74 2d 73 65 74 2d 73 74 61 74 75 73 21  test-set-status!
3000: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d   db run-id test-
3010: 6e 61 6d 65 20 22 4e 4f 54 5f 53 54 41 52 54 45  name "NOT_STARTE
3020: 44 22 20 22 6e 2f 61 22 20 69 74 65 6d 64 61 74  D" "n/a" itemdat
3030: 20 22 22 29 0a 09 09 09 20 20 20 20 3b 3b 20 28   "")....    ;; (
3040: 64 62 3a 73 65 74 2d 63 6f 6d 6d 65 6e 74 2d 66  db:set-comment-f
3050: 6f 72 2d 74 65 73 74 20 64 62 20 72 75 6e 2d 69  or-test db run-i
3060: 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d  d test-name item
3070: 2d 70 61 74 68 20 22 22 29 0a 09 09 09 20 20 20  -path "")....   
3080: 20 28 64 62 3a 64 65 6c 65 74 65 2d 74 65 73 74   (db:delete-test
3090: 2d 73 74 65 70 2d 72 65 63 6f 72 64 73 20 64 62  -step-records db
30a0: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
30b0: 65 29 20 3b 3b 20 63 6c 65 61 6e 20 6f 75 74 20  e) ;; clean out 
30c0: 69 66 20 74 68 69 73 20 69 73 20 61 20 72 65 2d  if this is a re-
30d0: 72 75 6e 0a 09 09 09 20 20 20 20 28 6c 6f 6f 70  run....    (loop
30e0: 32 20 28 64 62 3a 67 65 74 2d 74 65 73 74 2d 69  2 (db:get-test-i
30f0: 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65  nfo db run-id te
3100: 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74  st-name item-pat
3110: 68 29 0a 09 09 09 09 20 20 20 28 2b 20 63 74 20  h).....   (+ ct 
3120: 31 29 29 29 0a 09 09 09 20 20 28 69 66 20 74 73  1)))....  (if ts
3130: 0a 09 09 09 20 20 20 20 20 20 28 73 65 74 21 20  ....      (set! 
3140: 74 65 73 74 2d 73 74 61 74 75 73 20 74 73 29 0a  test-status ts).
3150: 09 09 09 20 20 20 20 20 20 28 62 65 67 69 6e 0a  ...      (begin.
3160: 09 09 09 09 28 70 72 69 6e 74 20 22 57 41 52 4e  ....(print "WARN
3170: 49 4e 47 3a 20 43 6f 75 6c 64 6e 27 74 20 72 65  ING: Couldn't re
3180: 67 69 73 74 65 72 20 74 65 73 74 20 22 20 74 65  gister test " te
3190: 73 74 2d 6e 61 6d 65 20 22 20 77 69 74 68 20 69  st-name " with i
31a0: 74 65 6d 20 70 61 74 68 20 22 20 69 74 65 6d 2d  tem path " item-
31b0: 70 61 74 68 20 22 2c 20 73 6b 69 70 70 69 6e 67  path ", skipping
31c0: 22 29 0a 09 09 09 09 28 69 66 20 28 6e 6f 74 20  ").....(if (not 
31d0: 28 6e 75 6c 6c 3f 20 74 61 6c 29 29 0a 09 09 09  (null? tal))....
31e0: 09 20 20 20 20 28 6c 6f 6f 70 20 28 63 61 72 20  .    (loop (car 
31f0: 74 61 6c 29 28 63 64 72 20 74 61 6c 29 29 29 29  tal)(cdr tal))))
3200: 29 29 29 0a 09 09 20 20 20 20 28 63 68 61 6e 67  )))...    (chang
3210: 65 2d 64 69 72 65 63 74 6f 72 79 20 74 65 73 74  e-directory test
3220: 2d 70 61 74 68 29 0a 09 09 20 20 20 20 3b 3b 20  -path)...    ;; 
3230: 74 68 69 73 20 62 6c 6f 63 6b 20 69 73 20 68 65  this block is he
3240: 72 65 20 6f 6e 6c 79 20 74 6f 20 69 6e 66 6f 72  re only to infor
3250: 6d 20 74 68 65 20 75 73 65 72 20 65 61 72 6c 79  m the user early
3260: 20 6f 6e 0a 09 09 20 20 20 20 28 69 66 20 28 66   on...    (if (f
3270: 69 6c 65 2d 65 78 69 73 74 73 3f 20 72 75 6e 63  ile-exists? runc
3280: 6f 6e 66 69 67 66 29 0a 09 09 09 28 73 65 74 75  onfigf)....(setu
3290: 70 2d 65 6e 76 2d 64 65 66 61 75 6c 74 73 20 64  p-env-defaults d
32a0: 62 20 72 75 6e 63 6f 6e 66 69 67 66 20 72 75 6e  b runconfigf run
32b0: 2d 69 64 20 2a 61 6c 72 65 61 64 79 2d 73 65 65  -id *already-see
32c0: 6e 2d 72 75 6e 63 6f 6e 66 69 67 2d 69 6e 66 6f  n-runconfig-info
32d0: 2a 29 0a 09 09 09 28 70 72 69 6e 74 20 22 57 41  *)....(print "WA
32e0: 52 4e 49 4e 47 3a 20 59 6f 75 20 64 6f 20 6e 6f  RNING: You do no
32f0: 74 20 68 61 76 65 20 61 20 72 75 6e 20 63 6f 6e  t have a run con
3300: 66 69 67 20 66 69 6c 65 3a 20 22 20 72 75 6e 63  fig file: " runc
3310: 6f 6e 66 69 67 66 29 29 0a 09 09 20 20 20 20 3b  onfigf))...    ;
3320: 3b 20 28 70 72 69 6e 74 20 22 72 75 6e 2d 69 64  ; (print "run-id
3330: 3a 20 22 20 72 75 6e 2d 69 64 20 22 20 74 65 73  : " run-id " tes
3340: 74 2d 6e 61 6d 65 3a 20 22 20 74 65 73 74 2d 6e  t-name: " test-n
3350: 61 6d 65 20 22 20 69 74 65 6d 2d 70 61 74 68 3a  ame " item-path:
3360: 20 22 20 69 74 65 6d 2d 70 61 74 68 20 22 20 74   " item-path " t
3370: 65 73 74 2d 73 74 61 74 75 73 3a 20 22 20 28 74  est-status: " (t
3380: 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74  est:get-status t
3390: 65 73 74 2d 73 74 61 74 75 73 29 20 22 20 74 65  est-status) " te
33a0: 73 74 2d 73 74 61 74 65 3a 20 22 20 28 74 65 73  st-state: " (tes
33b0: 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74  t:get-state test
33c0: 2d 73 74 61 74 75 73 29 29 0a 09 09 20 20 20 20  -status))...    
33d0: 28 63 61 73 65 20 28 69 66 20 28 61 72 67 73 3a  (case (if (args:
33e0: 67 65 74 2d 61 72 67 20 22 2d 66 6f 72 63 65 22  get-arg "-force"
33f0: 29 0a 09 09 09 20 20 20 20 20 20 27 4e 4f 54 5f  )....      'NOT_
3400: 53 54 41 52 54 45 44 0a 09 09 09 20 20 20 20 20  STARTED....     
3410: 20 28 69 66 20 74 65 73 74 2d 73 74 61 74 75 73   (if test-status
3420: 0a 09 09 09 09 20 20 28 73 74 72 69 6e 67 2d 3e  .....  (string->
3430: 73 79 6d 62 6f 6c 20 28 74 65 73 74 3a 67 65 74  symbol (test:get
3440: 2d 73 74 61 74 65 20 74 65 73 74 2d 73 74 61 74  -state test-stat
3450: 75 73 29 29 0a 09 09 09 09 20 20 27 66 61 69 6c  us)).....  'fail
3460: 65 64 2d 74 6f 2d 69 6e 73 65 72 74 29 29 0a 09  ed-to-insert))..
3470: 09 20 20 20 20 20 20 28 28 66 61 69 6c 65 64 2d  .      ((failed-
3480: 74 6f 2d 69 6e 73 65 72 74 29 0a 09 09 20 20 20  to-insert)...   
3490: 20 20 20 20 28 70 72 69 6e 74 20 22 45 52 52 4f      (print "ERRO
34a0: 52 3a 20 46 61 69 6c 65 64 20 74 6f 20 69 6e 73  R: Failed to ins
34b0: 65 72 74 20 74 68 65 20 72 65 63 6f 72 64 20 69  ert the record i
34c0: 6e 74 6f 20 74 68 65 20 64 62 22 29 29 0a 09 09  nto the db"))...
34d0: 20 20 20 20 20 20 28 28 4e 4f 54 5f 53 54 41 52        ((NOT_STAR
34e0: 54 45 44 20 43 4f 4d 50 4c 45 54 45 44 29 20 3b  TED COMPLETED) ;
34f0: 3b 20 28 63 61 64 72 20 73 74 61 74 75 73 20 69  ; (cadr status i
3500: 73 20 74 68 65 20 72 6f 77 20 69 64 20 66 6f 72  s the row id for
3510: 20 74 68 65 20 72 75 6e 20 72 65 63 6f 72 64 29   the run record)
3520: 0a 09 09 20 20 20 20 20 20 20 28 69 66 20 28 61  ...       (if (a
3530: 6e 64 20 28 65 71 75 61 6c 3f 20 28 74 65 73 74  nd (equal? (test
3540: 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 2d  :get-state test-
3550: 73 74 61 74 75 73 29 20 20 22 43 4f 4d 50 4c 45  status)  "COMPLE
3560: 54 45 44 22 29 0a 09 09 09 09 28 6f 72 20 28 65  TED").....(or (e
3570: 71 75 61 6c 3f 20 28 74 65 73 74 3a 67 65 74 2d  qual? (test:get-
3580: 73 74 61 74 75 73 20 74 65 73 74 2d 73 74 61 74  status test-stat
3590: 75 73 29 20 22 50 41 53 53 22 29 0a 09 09 09 09  us) "PASS").....
35a0: 20 20 20 20 28 65 71 75 61 6c 3f 20 28 74 65 73      (equal? (tes
35b0: 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73  t:get-status tes
35c0: 74 2d 73 74 61 74 75 73 29 20 22 43 48 45 43 4b  t-status) "CHECK
35d0: 22 29 29 0a 09 09 09 09 28 6e 6f 74 20 28 61 72  ")).....(not (ar
35e0: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 66 6f 72  gs:get-arg "-for
35f0: 63 65 22 29 29 29 0a 09 09 09 20 20 20 28 70 72  ce")))....   (pr
3600: 69 6e 74 20 22 4e 4f 54 45 3a 20 4e 6f 74 20 73  int "NOTE: Not s
3610: 74 61 72 74 69 6e 67 20 74 65 73 74 20 22 20 6e  tarting test " n
3620: 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20 22 20 61  ew-test-name " a
3630: 73 20 69 74 20 69 73 20 73 74 61 74 65 20 5c 22  s it is state \"
3640: 43 4f 4d 50 4c 45 54 45 44 5c 22 20 61 6e 64 20  COMPLETED\" and 
3650: 73 74 61 74 75 73 20 5c 22 22 20 28 74 65 73 74  status \"" (test
3660: 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74  :get-status test
3670: 2d 73 74 61 74 75 73 29 20 22 5c 22 2c 20 75 73  -status) "\", us
3680: 65 20 2d 66 6f 72 63 65 20 74 6f 20 6f 76 65 72  e -force to over
3690: 72 69 64 65 22 29 0a 09 09 09 20 20 20 28 6c 65  ride")....   (le
36a0: 74 2a 20 28 28 67 65 74 2d 70 72 65 72 65 71 73  t* ((get-prereqs
36b0: 2d 63 6d 64 20 28 6c 61 6d 62 64 61 20 28 29 0a  -cmd (lambda ().
36c0: 09 09 09 09 09 09 20 20 20 20 20 28 64 62 2d 67  ......     (db-g
36d0: 65 74 2d 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d  et-prereqs-not-m
36e0: 65 74 20 64 62 20 72 75 6e 2d 69 64 20 77 61 69  et db run-id wai
36f0: 74 6f 6e 29 29 29 20 3b 3b 20 63 68 65 63 6b 20  ton))) ;; check 
3700: 62 65 66 6f 72 65 20 72 75 6e 6e 69 6e 67 20 2e  before running .
3710: 2e 2e 2e 0a 09 09 09 09 20 20 28 6c 61 75 6e 63  ........  (launc
3720: 68 2d 63 6d 64 20 20 20 20 20 20 28 6c 61 6d 62  h-cmd      (lamb
3730: 64 61 20 28 29 0a 09 09 09 09 09 09 20 20 20 20  da ().......    
3740: 20 28 6c 61 75 6e 63 68 2d 74 65 73 74 20 64 62   (launch-test db
3750: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 63 6f 6e   run-id test-con
3760: 66 20 6b 65 79 76 61 6c 6c 73 74 20 74 65 73 74  f keyvallst test
3770: 2d 6e 61 6d 65 20 74 65 73 74 2d 70 61 74 68 20  -name test-path 
3780: 69 74 65 6d 64 61 74 29 29 29 0a 09 09 09 09 20  itemdat)))..... 
3790: 20 28 74 65 73 74 72 75 6e 64 61 74 20 20 20 20   (testrundat    
37a0: 20 20 28 6c 69 73 74 20 67 65 74 2d 70 72 65 72    (list get-prer
37b0: 65 71 73 2d 63 6d 64 20 6c 61 75 6e 63 68 2d 63  eqs-cmd launch-c
37c0: 6d 64 29 29 29 0a 09 09 09 20 20 20 20 20 28 69  md)))....     (i
37d0: 66 20 28 6f 72 20 28 61 72 67 73 3a 67 65 74 2d  f (or (args:get-
37e0: 61 72 67 20 22 2d 66 6f 72 63 65 22 29 0a 09 09  arg "-force")...
37f0: 09 09 20 20 20 20 20 28 6e 75 6c 6c 3f 20 28 28  ..     (null? ((
3800: 63 61 72 20 74 65 73 74 72 75 6e 64 61 74 29 29  car testrundat))
3810: 29 29 20 3b 3b 20 61 72 65 20 74 68 65 72 65 20  )) ;; are there 
3820: 61 6e 79 20 74 65 73 74 73 20 74 68 61 74 20 6d  any tests that m
3830: 75 73 74 20 62 65 20 72 75 6e 20 62 65 66 6f 72  ust be run befor
3840: 65 20 74 68 69 73 20 6f 6e 65 2e 2e 2e 0a 09 09  e this one......
3850: 09 09 20 28 28 63 61 64 72 20 74 65 73 74 72 75  .. ((cadr testru
3860: 6e 64 61 74 29 29 20 3b 3b 20 74 68 69 73 20 69  ndat)) ;; this i
3870: 73 20 74 68 65 20 6c 69 6e 65 20 74 68 61 74 20  s the line that 
3880: 6c 61 75 6e 63 68 65 73 20 74 68 65 20 74 65 73  launches the tes
3890: 74 20 74 6f 20 74 68 65 20 72 65 6d 6f 74 65 20  t to the remote 
38a0: 68 6f 73 74 0a 09 09 09 09 20 28 68 61 73 68 2d  host..... (hash-
38b0: 74 61 62 6c 65 2d 73 65 74 21 20 2a 77 61 69 74  table-set! *wait
38c0: 69 6e 67 2d 71 75 65 75 65 2a 20 6e 65 77 2d 74  ing-queue* new-t
38d0: 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 72 75 6e  est-name testrun
38e0: 64 61 74 29 29 29 29 29 0a 09 09 20 20 20 20 20  dat)))))...     
38f0: 20 28 28 4b 49 4c 4c 45 44 29 20 0a 09 09 20 20   ((KILLED) ...  
3900: 20 20 20 20 20 28 70 72 69 6e 74 20 22 4e 4f 54       (print "NOT
3910: 45 3a 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61  E: " new-test-na
3920: 6d 65 20 22 20 69 73 20 61 6c 72 65 61 64 79 20  me " is already 
3930: 72 75 6e 6e 69 6e 67 20 6f 72 20 77 61 73 20 65  running or was e
3940: 78 70 6c 69 63 74 6c 79 20 6b 69 6c 6c 65 64 2c  xplictly killed,
3950: 20 75 73 65 20 2d 66 6f 72 63 65 20 74 6f 20 6c   use -force to l
3960: 61 75 6e 63 68 20 69 74 2e 22 29 29 0a 09 09 20  aunch it."))... 
3970: 20 20 20 20 20 28 28 4c 41 55 4e 43 48 45 44 20       ((LAUNCHED 
3980: 52 45 4d 4f 54 45 48 4f 53 54 53 54 41 52 54 20  REMOTEHOSTSTART 
3990: 52 55 4e 4e 49 4e 47 29 20 20 0a 09 09 20 20 20  RUNNING)  ...   
39a0: 20 20 20 20 28 69 66 20 28 3e 20 28 2d 20 28 63      (if (> (- (c
39b0: 75 72 72 65 6e 74 2d 73 65 63 6f 6e 64 73 29 28  urrent-seconds)(
39c0: 2b 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 65  + (db:test-get-e
39d0: 76 65 6e 74 5f 74 69 6d 65 20 74 65 73 74 2d 73  vent_time test-s
39e0: 74 61 74 75 73 29 0a 09 09 09 09 09 09 20 20 20  tatus).......   
39f0: 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 72    (db:test-get-r
3a00: 75 6e 5f 64 75 72 61 74 69 6f 6e 20 74 65 73 74  un_duration test
3a10: 2d 73 74 61 74 75 73 29 29 29 0a 09 09 09 20 20  -status)))....  
3a20: 20 20 20 20 31 30 30 29 20 3b 3b 20 69 2e 65 2e      100) ;; i.e.
3a30: 20 6e 6f 20 75 70 64 61 74 65 20 66 6f 72 20 6d   no update for m
3a40: 6f 72 65 20 74 68 61 6e 20 31 30 30 20 73 65 63  ore than 100 sec
3a50: 6f 6e 64 73 0a 09 09 09 20 20 20 28 62 65 67 69  onds....   (begi
3a60: 6e 0a 09 09 09 20 20 20 20 20 28 70 72 69 6e 74  n....     (print
3a70: 20 22 57 41 52 4e 49 4e 47 3a 20 54 65 73 74 20   "WARNING: Test 
3a80: 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 61 70  " test-name " ap
3a90: 70 65 61 72 73 20 74 6f 20 62 65 20 64 65 61 64  pears to be dead
3aa0: 2e 22 29 0a 09 09 09 20 20 20 20 20 28 74 65 73  .")....     (tes
3ab0: 74 2d 73 65 74 2d 73 74 61 74 75 73 21 20 64 62  t-set-status! db
3ac0: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
3ad0: 65 20 22 49 4e 43 4f 4d 50 4c 45 54 45 22 20 22  e "INCOMPLETE" "
3ae0: 53 54 55 43 4b 2f 44 45 41 44 22 20 69 74 65 6d  STUCK/DEAD" item
3af0: 64 61 74 20 22 54 65 73 74 20 69 73 20 73 74 75  dat "Test is stu
3b00: 63 6b 20 6f 72 20 64 65 61 64 22 29 29 0a 09 09  ck or dead"))...
3b10: 09 20 20 20 28 70 72 69 6e 74 20 22 4e 4f 54 45  .   (print "NOTE
3b20: 3a 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20  : " test-name " 
3b30: 69 73 20 61 6c 72 65 61 64 79 20 72 75 6e 6e 69  is already runni
3b40: 6e 67 22 29 29 29 0a 09 09 20 20 20 20 20 20 28  ng")))...      (
3b50: 65 6c 73 65 20 20 20 20 20 20 20 28 70 72 69 6e  else       (prin
3b60: 74 20 22 45 52 52 4f 52 3a 20 46 61 69 6c 65 64  t "ERROR: Failed
3b70: 20 74 6f 20 6c 61 75 6e 63 68 20 74 65 73 74 20   to launch test 
3b80: 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20  " new-test-name 
3b90: 22 2e 20 55 6e 72 65 63 6f 67 6e 69 73 65 64 20  ". Unrecognised 
3ba0: 73 74 61 74 65 20 22 20 28 74 65 73 74 3a 67 65  state " (test:ge
3bb0: 74 2d 73 74 61 74 65 20 74 65 73 74 2d 73 74 61  t-state test-sta
3bc0: 74 75 73 29 29 29 29 29 29 0a 09 20 20 20 20 20  tus))))))..     
3bd0: 20 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f   (if (not (null?
3be0: 20 74 61 6c 29 29 0a 09 09 20 20 28 6c 6f 6f 70   tal))...  (loop
3bf0: 20 28 63 61 72 20 74 61 6c 29 28 63 64 72 20 74   (car tal)(cdr t
3c00: 61 6c 29 29 29 29 29 29 29 29 29 0a 0a 28 64 65  al)))))))))..(de
3c10: 66 69 6e 65 20 28 72 75 6e 2d 77 61 69 74 69 6e  fine (run-waitin
3c20: 67 2d 74 65 73 74 73 20 64 62 29 0a 20 20 28 6c  g-tests db).  (l
3c30: 65 74 20 28 28 6e 75 6d 74 72 69 65 73 20 20 20  et ((numtries   
3c40: 20 20 20 20 20 20 20 20 30 29 0a 09 28 6c 61 73          0)..(las
3c50: 74 2d 74 72 79 2d 74 69 6d 65 20 20 20 20 20 20  t-try-time      
3c60: 28 63 75 72 72 65 6e 74 2d 73 65 63 6f 6e 64 73  (current-seconds
3c70: 29 29 0a 09 28 74 69 6d 65 73 20 20 20 20 20 20  ))..(times      
3c80: 20 20 20 20 20 20 20 20 28 6c 69 73 74 20 31 29          (list 1)
3c90: 29 29 20 3b 3b 20 6d 69 6e 75 74 65 73 20 74 6f  )) ;; minutes to
3ca0: 20 77 61 69 74 20 62 65 66 6f 72 65 20 74 72 79   wait before try
3cb0: 69 6e 67 20 61 67 61 69 6e 20 74 6f 20 6b 69 63  ing again to kic
3cc0: 6b 20 6f 66 66 20 72 75 6e 73 0a 20 20 20 20 3b  k off runs.    ;
3cd0: 3b 20 42 55 47 20 74 68 69 73 20 68 61 63 6b 20  ; BUG this hack 
3ce0: 6f 66 20 62 72 75 74 65 20 66 6f 72 63 65 20 72  of brute force r
3cf0: 65 74 72 79 69 6e 67 20 77 6f 72 6b 73 20 71 75  etrying works qu
3d00: 69 74 65 20 77 65 6c 6c 20 66 6f 72 20 6d 61 6e  ite well for man
3d10: 79 20 63 61 73 65 73 20 62 75 74 20 0a 20 20 20  y cases but .   
3d20: 20 3b 3b 20 20 20 20 20 77 68 61 74 20 69 73 20   ;;     what is 
3d30: 6e 65 65 64 65 64 20 69 73 20 74 6f 20 63 68 65  needed is to che
3d40: 63 6b 20 74 68 65 20 64 62 20 66 6f 72 20 74 65  ck the db for te
3d50: 73 74 73 20 74 68 61 74 20 68 61 76 65 20 66 61  sts that have fa
3d60: 69 6c 65 64 20 6c 65 73 73 20 74 68 61 6e 0a 20  iled less than. 
3d70: 20 20 20 3b 3b 20 20 20 20 20 4e 20 74 69 6d 65     ;;     N time
3d80: 73 20 6f 72 20 6e 65 76 65 72 20 62 65 65 6e 20  s or never been 
3d90: 73 74 61 72 74 65 64 20 61 6e 64 20 6b 69 63 6b  started and kick
3da0: 20 74 68 65 6d 20 6f 66 66 20 61 67 61 69 6e 0a   them off again.
3db0: 20 20 20 20 28 6c 65 74 20 6c 6f 6f 70 20 28 28      (let loop ((
3dc0: 77 61 69 74 69 6e 67 2d 74 65 73 74 2d 6e 61 6d  waiting-test-nam
3dd0: 65 73 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 6b  es (hash-table-k
3de0: 65 79 73 20 2a 77 61 69 74 69 6e 67 2d 71 75 65  eys *waiting-que
3df0: 75 65 2a 29 29 29 0a 20 20 20 20 20 20 28 63 6f  ue*))).      (co
3e00: 6e 64 0a 20 20 20 20 20 20 20 28 28 6e 75 6c 6c  nd.       ((null
3e10: 3f 20 77 61 69 74 69 6e 67 2d 74 65 73 74 2d 6e  ? waiting-test-n
3e20: 61 6d 65 73 29 0a 09 28 70 72 69 6e 74 20 22 41  ames)..(print "A
3e30: 6c 6c 20 74 65 73 74 73 20 6c 61 75 6e 63 68 65  ll tests launche
3e40: 64 22 29 29 0a 20 20 20 20 20 20 20 28 28 3e 20  d")).       ((> 
3e50: 6e 75 6d 74 72 69 65 73 20 34 29 0a 09 28 70 72  numtries 4)..(pr
3e60: 69 6e 74 20 22 4e 4f 54 45 3a 20 54 72 69 65 64  int "NOTE: Tried
3e70: 20 6c 61 75 6e 63 68 69 6e 67 20 66 6f 75 72 20   launching four 
3e80: 74 69 6d 65 73 2c 20 70 65 72 68 61 70 73 20 72  times, perhaps r
3e90: 75 6e 20 6d 65 67 61 74 65 73 74 20 61 67 61 69  un megatest agai
3ea0: 6e 20 69 6e 20 61 20 66 65 77 20 6d 69 6e 75 74  n in a few minut
3eb0: 65 73 22 29 29 0a 20 20 20 20 20 20 20 28 65 6c  es")).       (el
3ec0: 73 65 0a 09 28 73 65 74 21 20 6e 75 6d 74 72 69  se..(set! numtri
3ed0: 65 73 20 28 2b 20 6e 75 6d 74 72 69 65 73 20 31  es (+ numtries 1
3ee0: 29 29 0a 09 28 66 6f 72 2d 65 61 63 68 20 28 6c  ))..(for-each (l
3ef0: 61 6d 62 64 61 20 28 74 65 73 74 6e 61 6d 65 29  ambda (testname)
3f00: 0a 09 09 20 20 20 20 28 6c 65 74 2a 20 28 28 74  ...    (let* ((t
3f10: 65 73 74 64 61 74 20 28 68 61 73 68 2d 74 61 62  estdat (hash-tab
3f20: 6c 65 2d 72 65 66 20 2a 77 61 69 74 69 6e 67 2d  le-ref *waiting-
3f30: 71 75 65 75 65 2a 20 74 65 73 74 6e 61 6d 65 29  queue* testname)
3f40: 29 0a 09 09 09 20 20 20 28 70 72 65 72 65 71 73  )....   (prereqs
3f50: 20 28 28 63 61 72 20 74 65 73 74 64 61 74 29 29   ((car testdat))
3f60: 29 0a 09 09 09 20 20 20 28 6c 64 62 20 20 20 20  )....   (ldb    
3f70: 20 28 69 66 20 64 62 20 64 62 20 28 6f 70 65 6e   (if db db (open
3f80: 2d 64 62 29 29 29 29 0a 09 09 20 20 20 20 20 20  -db))))...      
3f90: 3b 3b 20 28 70 72 69 6e 74 20 22 70 72 65 72 65  ;; (print "prere
3fa0: 71 73 20 72 65 6d 61 69 6e 69 6e 67 3a 20 22 20  qs remaining: " 
3fb0: 70 72 65 72 65 71 73 29 0a 09 09 20 20 20 20 20  prereqs)...     
3fc0: 20 28 69 66 20 28 6e 75 6c 6c 3f 20 70 72 65 72   (if (null? prer
3fd0: 65 71 73 29 0a 09 09 09 20 20 28 62 65 67 69 6e  eqs)....  (begin
3fe0: 0a 09 09 09 20 20 20 20 28 70 72 69 6e 74 20 22  ....    (print "
3ff0: 50 72 65 72 65 71 75 69 73 69 74 65 73 20 6d 65  Prerequisites me
4000: 74 2c 20 6c 61 75 6e 63 68 69 6e 67 20 22 20 74  t, launching " t
4010: 65 73 74 6e 61 6d 65 29 0a 09 09 09 20 20 20 20  estname)....    
4020: 28 28 63 61 64 72 20 74 65 73 74 64 61 74 29 29  ((cadr testdat))
4030: 0a 09 09 09 20 20 20 20 28 68 61 73 68 2d 74 61  ....    (hash-ta
4040: 62 6c 65 2d 64 65 6c 65 74 65 21 20 2a 77 61 69  ble-delete! *wai
4050: 74 69 6e 67 2d 71 75 65 75 65 2a 20 74 65 73 74  ting-queue* test
4060: 6e 61 6d 65 29 29 29 0a 09 09 20 20 20 20 20 20  name)))...      
4070: 28 69 66 20 28 6e 6f 74 20 64 62 29 0a 09 09 09  (if (not db)....
4080: 20 20 28 73 71 6c 69 74 65 33 3a 66 69 6e 61 6c    (sqlite3:final
4090: 69 7a 65 21 20 6c 64 62 29 29 29 29 0a 09 09 20  ize! ldb))))... 
40a0: 20 77 61 69 74 69 6e 67 2d 74 65 73 74 2d 6e 61   waiting-test-na
40b0: 6d 65 73 29 0a 09 28 73 6c 65 65 70 20 31 30 29  mes)..(sleep 10)
40c0: 20 3b 3b 20 6e 6f 20 70 6f 69 6e 74 20 69 6e 20   ;; no point in 
40d0: 72 75 73 68 69 6e 67 20 74 68 69 6e 67 73 20 61  rushing things a
40e0: 74 20 74 68 69 73 20 73 74 61 67 65 3f 0a 09 28  t this stage?..(
40f0: 6c 6f 6f 70 20 28 68 61 73 68 2d 74 61 62 6c 65  loop (hash-table
4100: 2d 6b 65 79 73 20 2a 77 61 69 74 69 6e 67 2d 71  -keys *waiting-q
4110: 75 65 75 65 2a 29 29 29 29 29 29 29 0a 0a 28 64  ueue*)))))))..(d
4120: 65 66 69 6e 65 20 28 67 65 74 2d 64 69 72 2d 75  efine (get-dir-u
4130: 70 2d 6f 6e 65 20 64 69 72 29 20 0a 20 20 28 6c  p-one dir) .  (l
4140: 65 74 20 28 28 64 70 61 72 74 73 20 20 28 73 74  et ((dparts  (st
4150: 72 69 6e 67 2d 73 70 6c 69 74 20 64 69 72 20 22  ring-split dir "
4160: 2f 22 29 29 29 0a 20 20 20 20 28 63 6f 6e 63 20  /"))).    (conc 
4170: 22 2f 22 20 28 73 74 72 69 6e 67 2d 69 6e 74 65  "/" (string-inte
4180: 72 73 70 65 72 73 65 20 0a 09 20 20 20 20 20 20  rsperse ..      
4190: 20 28 74 61 6b 65 20 64 70 61 72 74 73 20 28 2d   (take dparts (-
41a0: 20 28 6c 65 6e 67 74 68 20 64 70 61 72 74 73 29   (length dparts)
41b0: 20 31 29 29 0a 09 20 20 20 20 20 20 20 22 2f 22   1))..       "/"
41c0: 29 29 29 29 0a 3b 3b 20 52 65 6d 6f 76 65 20 72  )))).;; Remove r
41d0: 75 6e 73 0a 3b 3b 20 66 69 65 6c 64 73 20 61 72  uns.;; fields ar
41e0: 65 20 70 61 73 73 69 6e 67 20 69 6e 20 74 68 72  e passing in thr
41f0: 6f 75 67 68 20 0a 28 64 65 66 69 6e 65 20 28 72  ough .(define (r
4200: 75 6e 73 3a 72 65 6d 6f 76 65 2d 72 75 6e 73 20  uns:remove-runs 
4210: 64 62 20 72 75 6e 6e 61 6d 65 70 61 74 74 20 74  db runnamepatt t
4220: 65 73 74 70 61 74 74 20 69 74 65 6d 70 61 74 74  estpatt itempatt
4230: 29 0a 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 73  ).  (let* ((keys
4240: 20 20 20 20 20 20 20 20 28 64 62 2d 67 65 74 2d          (db-get-
4250: 6b 65 79 73 20 64 62 29 29 0a 09 20 28 72 75 6e  keys db)).. (run
4260: 64 61 74 20 20 20 20 20 20 28 72 75 6e 73 3a 67  dat      (runs:g
4270: 65 74 2d 72 75 6e 73 2d 62 79 2d 70 61 74 74 20  et-runs-by-patt 
4280: 64 62 20 6b 65 79 73 20 72 75 6e 6e 61 6d 65 70  db keys runnamep
4290: 61 74 74 29 29 0a 09 20 28 68 65 61 64 65 72 20  att)).. (header 
42a0: 20 20 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66       (vector-ref
42b0: 20 72 75 6e 64 61 74 20 30 29 29 0a 09 20 28 72   rundat 0)).. (r
42c0: 75 6e 73 20 20 20 20 20 20 20 20 28 76 65 63 74  uns        (vect
42d0: 6f 72 2d 72 65 66 20 72 75 6e 64 61 74 20 31 29  or-ref rundat 1)
42e0: 29 29 0a 20 20 20 20 28 70 72 69 6e 74 20 22 48  )).    (print "H
42f0: 65 61 64 65 72 3a 20 22 20 68 65 61 64 65 72 29  eader: " header)
4300: 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 0a 20  .    (for-each. 
4310: 20 20 20 20 28 6c 61 6d 62 64 61 20 28 72 75 6e      (lambda (run
4320: 29 0a 20 20 20 20 20 20 20 28 6c 65 74 20 28 28  ).       (let ((
4330: 72 75 6e 6b 65 79 20 28 73 74 72 69 6e 67 2d 69  runkey (string-i
4340: 6e 74 65 72 73 70 65 72 73 65 20 28 6d 61 70 20  ntersperse (map 
4350: 28 6c 61 6d 62 64 61 20 28 6b 29 0a 09 09 09 09  (lambda (k).....
4360: 09 09 28 64 62 2d 67 65 74 2d 76 61 6c 75 65 2d  ..(db-get-value-
4370: 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65  by-header run he
4380: 61 64 65 72 20 28 76 65 63 74 6f 72 2d 72 65 66  ader (vector-ref
4390: 20 6b 20 30 29 29 29 20 6b 65 79 73 29 20 22 2f   k 0))) keys) "/
43a0: 22 29 29 29 0a 09 20 28 6c 65 74 2a 20 28 28 72  "))).. (let* ((r
43b0: 75 6e 2d 69 64 20 28 64 62 2d 67 65 74 2d 76 61  un-id (db-get-va
43c0: 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75  lue-by-header ru
43d0: 6e 20 68 65 61 64 65 72 20 22 69 64 22 29 20 29  n header "id") )
43e0: 0a 09 09 28 74 65 73 74 73 20 20 28 64 62 2d 67  ...(tests  (db-g
43f0: 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d 72 75 6e  et-tests-for-run
4400: 20 64 62 20 28 64 62 2d 67 65 74 2d 76 61 6c 75   db (db-get-valu
4410: 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20  e-by-header run 
4420: 68 65 61 64 65 72 20 22 69 64 22 29 20 74 65 73  header "id") tes
4430: 74 70 61 74 74 20 69 74 65 6d 70 61 74 74 29 29  tpatt itempatt))
4440: 0a 09 09 28 6c 61 73 74 74 70 61 74 68 20 22 2f  ...(lasttpath "/
4450: 64 6f 65 73 2f 6e 6f 74 2f 65 78 69 73 74 2f 49  does/not/exist/I
4460: 2f 68 6f 70 65 22 29 29 0a 09 20 20 20 28 69 66  /hope"))..   (if
4470: 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 65 73   (not (null? tes
4480: 74 73 29 29 0a 09 20 20 20 20 20 20 20 28 62 65  ts))..       (be
4490: 67 69 6e 0a 09 09 20 28 70 72 69 6e 74 20 22 52  gin... (print "R
44a0: 65 6d 6f 76 69 6e 67 20 74 65 73 74 73 20 66 6f  emoving tests fo
44b0: 72 20 72 75 6e 3a 20 22 20 72 75 6e 6b 65 79 20  r run: " runkey 
44c0: 22 20 22 20 28 64 62 2d 67 65 74 2d 76 61 6c 75  " " (db-get-valu
44d0: 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20  e-by-header run 
44e0: 68 65 61 64 65 72 20 22 72 75 6e 6e 61 6d 65 22  header "runname"
44f0: 29 29 0a 09 09 20 28 66 6f 72 2d 65 61 63 68 0a  ))... (for-each.
4500: 09 09 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73  ..  (lambda (tes
4510: 74 29 0a 09 09 20 20 20 20 28 70 72 69 6e 74 20  t)...    (print 
4520: 22 20 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65  "  " (db:test-ge
4530: 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 29  t-testname test)
4540: 20 22 20 69 64 3a 20 22 20 28 64 62 3a 74 65 73   " id: " (db:tes
4550: 74 2d 67 65 74 2d 69 64 20 74 65 73 74 29 20 22  t-get-id test) "
4560: 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d   " (db:test-get-
4570: 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 29 29  item-path test))
4580: 0a 09 09 20 20 20 20 28 64 62 3a 64 65 6c 65 74  ...    (db:delet
4590: 65 2d 74 65 73 74 2d 72 65 63 6f 72 64 73 20 64  e-test-records d
45a0: 62 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69  b (db:test-get-i
45b0: 64 20 74 65 73 74 29 29 0a 09 09 20 20 20 20 28  d test))...    (
45c0: 69 66 20 28 3e 20 28 73 74 72 69 6e 67 2d 6c 65  if (> (string-le
45d0: 6e 67 74 68 20 28 64 62 3a 74 65 73 74 2d 67 65  ngth (db:test-ge
45e0: 74 2d 72 75 6e 64 69 72 20 74 65 73 74 29 29 20  t-rundir test)) 
45f0: 35 29 20 3b 3b 20 62 61 64 20 68 65 75 72 69 73  5) ;; bad heuris
4600: 74 69 63 20 62 75 74 20 73 68 6f 75 6c 64 20 70  tic but should p
4610: 72 65 76 65 6e 74 20 2f 74 6d 70 20 2f 68 6f 6d  revent /tmp /hom
4620: 65 20 65 74 63 2e 0a 09 09 09 28 6c 65 74 20 28  e etc.....(let (
4630: 28 66 75 6c 6c 70 61 74 68 20 28 64 62 3a 74 65  (fullpath (db:te
4640: 73 74 2d 67 65 74 2d 72 75 6e 64 69 72 20 74 65  st-get-rundir te
4650: 73 74 29 29 29 20 3b 3b 20 22 2f 22 20 28 64 62  st))) ;; "/" (db
4660: 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70  :test-get-item-p
4670: 61 74 68 20 74 65 73 74 29 29 29 29 0a 09 09 09  ath test))))....
4680: 20 20 28 73 65 74 21 20 6c 61 73 74 74 70 61 74    (set! lasttpat
4690: 68 20 66 75 6c 6c 70 61 74 68 29 0a 09 09 09 20  h fullpath).... 
46a0: 20 28 70 72 69 6e 74 20 22 72 6d 20 2d 72 66 20   (print "rm -rf 
46b0: 22 20 66 75 6c 6c 70 61 74 68 29 0a 09 09 09 20  " fullpath).... 
46c0: 20 28 73 79 73 74 65 6d 20 28 63 6f 6e 63 20 22   (system (conc "
46d0: 72 6d 20 2d 72 66 20 22 20 66 75 6c 6c 70 61 74  rm -rf " fullpat
46e0: 68 29 29 0a 09 09 09 20 20 28 6c 65 74 20 28 28  h))....  (let ((
46f0: 63 6d 64 20 28 63 6f 6e 63 20 22 72 6d 64 69 72  cmd (conc "rmdir
4700: 20 2d 70 20 22 20 28 67 65 74 2d 64 69 72 2d 75   -p " (get-dir-u
4710: 70 2d 6f 6e 65 20 66 75 6c 6c 70 61 74 68 29 29  p-one fullpath))
4720: 29 29 0a 09 09 09 20 20 20 20 28 70 72 69 6e 74  ))....    (print
4730: 20 63 6d 64 29 0a 09 09 09 20 20 20 20 28 73 79   cmd)....    (sy
4740: 73 74 65 6d 20 63 6d 64 29 29 0a 09 09 09 20 20  stem cmd))....  
4750: 29 29 29 0a 09 09 20 20 74 65 73 74 73 29 29 29  )))...  tests)))
4760: 0a 09 20 20 20 28 6c 65 74 20 28 28 72 65 6d 74  ..   (let ((remt
4770: 65 73 74 73 20 28 64 62 2d 67 65 74 2d 74 65 73  ests (db-get-tes
4780: 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 28 64  ts-for-run db (d
4790: 62 2d 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68  b-get-value-by-h
47a0: 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65 72  eader run header
47b0: 20 22 69 64 22 29 29 29 29 0a 09 20 20 20 20 20   "id"))))..     
47c0: 28 69 66 20 28 6e 75 6c 6c 3f 20 72 65 6d 74 65  (if (null? remte
47d0: 73 74 73 29 20 3b 3b 20 6e 6f 20 6d 6f 72 65 20  sts) ;; no more 
47e0: 74 65 73 74 73 20 72 65 6d 61 69 6e 69 6e 67 0a  tests remaining.
47f0: 09 09 20 28 6c 65 74 2a 20 28 28 64 70 61 72 74  .. (let* ((dpart
4800: 73 20 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74  s  (string-split
4810: 20 6c 61 73 74 74 70 61 74 68 20 22 2f 22 29 29   lasttpath "/"))
4820: 0a 09 09 09 28 72 75 6e 70 61 74 68 20 28 63 6f  ....(runpath (co
4830: 6e 63 20 22 2f 22 20 28 73 74 72 69 6e 67 2d 69  nc "/" (string-i
4840: 6e 74 65 72 73 70 65 72 73 65 20 0a 09 09 09 09  ntersperse .....
4850: 09 20 20 20 20 28 74 61 6b 65 20 64 70 61 72 74  .    (take dpart
4860: 73 20 28 2d 20 28 6c 65 6e 67 74 68 20 64 70 61  s (- (length dpa
4870: 72 74 73 29 20 31 29 29 0a 09 09 09 09 09 20 20  rts) 1))......  
4880: 20 20 22 2f 22 29 29 29 29 0a 09 09 20 20 20 28    "/"))))...   (
4890: 70 72 69 6e 74 20 22 52 65 6d 6f 76 69 6e 67 20  print "Removing 
48a0: 72 75 6e 3a 20 22 20 72 75 6e 6b 65 79 20 22 20  run: " runkey " 
48b0: 22 20 28 64 62 2d 67 65 74 2d 76 61 6c 75 65 2d  " (db-get-value-
48c0: 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65  by-header run he
48d0: 61 64 65 72 20 22 72 75 6e 6e 61 6d 65 22 29 29  ader "runname"))
48e0: 0a 09 09 20 20 20 28 64 62 3a 64 65 6c 65 74 65  ...   (db:delete
48f0: 2d 72 75 6e 20 64 62 20 72 75 6e 2d 69 64 29 0a  -run db run-id).
4900: 09 09 20 20 20 3b 3b 20 6e 65 65 64 20 74 6f 20  ..   ;; need to 
4910: 66 69 67 75 72 65 20 6f 75 74 20 74 68 65 20 70  figure out the p
4920: 61 74 68 20 74 6f 20 74 68 65 20 72 75 6e 20 64  ath to the run d
4930: 69 72 20 61 6e 64 20 72 65 6d 6f 76 65 20 69 74  ir and remove it
4940: 20 69 66 20 65 6d 70 74 79 0a 09 09 3b 3b 20 20   if empty...;;  
4950: 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 28 67 6c    (if (null? (gl
4960: 6f 62 20 28 63 6f 6e 63 20 72 75 6e 70 61 74 68  ob (conc runpath
4970: 20 22 2f 2a 22 29 29 29 0a 09 09 3b 3b 20 20 20   "/*")))...;;   
4980: 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09 3b 3b       (begin...;;
4990: 20 09 20 28 70 72 69 6e 74 20 22 52 65 6d 6f 76   . (print "Remov
49a0: 69 6e 67 20 72 75 6e 20 64 69 72 20 22 20 72 75  ing run dir " ru
49b0: 6e 70 61 74 68 29 0a 09 09 3b 3b 20 09 20 28 73  npath)...;; . (s
49c0: 79 73 74 65 6d 20 28 63 6f 6e 63 20 22 72 6d 64  ystem (conc "rmd
49d0: 69 72 20 2d 70 20 22 20 72 75 6e 70 61 74 68 29  ir -p " runpath)
49e0: 29 29 29 0a 09 09 20 20 20 29 29 29 0a 09 09 20  )))...   )))... 
49f0: 29 29 29 0a 20 20 20 20 20 72 75 6e 73 29 29 29  ))).     runs)))
4a00: 0a 0a                                            ..