Megatest

Hex Artifact Content
Login

Artifact bee21070b6fe9fcfb18b19ea4b29e0db9b258838:


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 43 41 53 45 20 57 48  ET state=CASE WH
1240: 45 4e 20 28 53 45 4c 45 43 54 20 63 6f 75 6e 74  EN (SELECT count
1250: 28 69 64 29 20 46 52 4f 4d 20 74 65 73 74 73 20  (id) FROM tests 
1260: 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41  WHERE run_id=? A
1270: 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e  ND testname=? AN
1280: 44 20 69 74 65 6d 5f 70 61 74 68 20 21 3d 20 27  D item_path != '
1290: 27 20 41 4e 44 20 73 74 61 74 65 20 69 6e 20 28  ' AND state in (
12a0: 27 52 55 4e 4e 49 4e 47 27 2c 27 4e 4f 54 5f 53  'RUNNING','NOT_S
12b0: 54 41 52 54 45 44 27 29 29 20 3e 20 30 20 54 48  TARTED')) > 0 TH
12c0: 45 4e 20 0a 20 20 20 20 20 20 20 20 20 20 20 20  EN .            
12d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 27 52                'R
12e0: 55 4e 4e 49 4e 47 27 0a 20 20 20 20 20 20 20 20  UNNING'.        
12f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 45                 E
1300: 4c 53 45 20 27 43 4f 4d 50 4c 45 54 45 44 27 20  LSE 'COMPLETED' 
1310: 45 4e 44 2c 0a 20 20 20 20 20 20 20 20 20 20 20  END,.           
1320: 20 20 20 20 20 73 74 61 74 75 73 3d 43 41 53 45       status=CASE
1330: 20 57 48 45 4e 20 66 61 69 6c 5f 63 6f 75 6e 74   WHEN fail_count
1340: 20 3e 20 30 20 54 48 45 4e 20 27 46 41 49 4c 27   > 0 THEN 'FAIL'
1350: 20 57 48 45 4e 20 70 61 73 73 5f 63 6f 75 6e 74   WHEN pass_count
1360: 20 3e 20 30 20 41 4e 44 20 66 61 69 6c 5f 63 6f   > 0 AND fail_co
1370: 75 6e 74 3d 30 20 54 48 45 4e 20 27 50 41 53 53  unt=0 THEN 'PASS
1380: 27 20 45 4c 53 45 20 27 55 4e 4b 4e 4f 57 4e 27  ' ELSE 'UNKNOWN'
1390: 20 45 4e 44 0a 20 20 20 20 20 20 20 20 20 20 20   END.           
13a0: 20 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f    WHERE run_id=?
13b0: 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20   AND testname=? 
13c0: 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 27 27  AND item_path=''
13d0: 3b 22 0a 09 20 20 20 72 75 6e 2d 69 64 20 74 65  ;"..   run-id te
13e0: 73 74 2d 6e 61 6d 65 20 72 75 6e 2d 69 64 20 74  st-name run-id t
13f0: 65 73 74 2d 6e 61 6d 65 29 29 29 0a 20 20 20 20  est-name))).    
1400: 28 69 66 20 28 61 6e 64 20 28 6e 6f 74 20 28 6e  (if (and (not (n
1410: 75 6c 6c 3f 20 63 6f 6d 6d 65 6e 74 29 29 0a 09  ull? comment))..
1420: 20 20 20 20 20 28 63 61 72 20 63 6f 6d 6d 65 6e       (car commen
1430: 74 29 29 0a 09 28 73 71 6c 69 74 65 33 3a 65 78  t))..(sqlite3:ex
1440: 65 63 75 74 65 20 64 62 20 22 55 50 44 41 54 45  ecute db "UPDATE
1450: 20 74 65 73 74 73 20 53 45 54 20 63 6f 6d 6d 65   tests SET comme
1460: 6e 74 3d 3f 20 57 48 45 52 45 20 72 75 6e 5f 69  nt=? WHERE run_i
1470: 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65  d=? AND testname
1480: 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68  =? AND item_path
1490: 3d 3f 3b 22 0a 09 09 09 20 28 63 61 72 20 63 6f  =?;".... (car co
14a0: 6d 6d 65 6e 74 29 20 72 75 6e 2d 69 64 20 74 65  mment) run-id te
14b0: 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74  st-name item-pat
14c0: 68 29 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28  h))))..(define (
14d0: 74 65 73 74 2d 73 65 74 2d 6c 6f 67 21 20 64 62  test-set-log! db
14e0: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
14f0: 65 20 69 74 65 6d 64 61 74 20 6c 6f 67 66 29 20  e itemdat logf) 
1500: 0a 20 20 28 6c 65 74 20 28 28 69 74 65 6d 2d 70  .  (let ((item-p
1510: 61 74 68 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e  ath (item-list->
1520: 70 61 74 68 20 69 74 65 6d 64 61 74 29 29 29 0a  path itemdat))).
1530: 20 20 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65      (sqlite3:exe
1540: 63 75 74 65 20 64 62 20 22 55 50 44 41 54 45 20  cute db "UPDATE 
1550: 74 65 73 74 73 20 53 45 54 20 66 69 6e 61 6c 5f  tests SET final_
1560: 6c 6f 67 66 3d 3f 20 57 48 45 52 45 20 72 75 6e  logf=? WHERE run
1570: 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61  _id=? AND testna
1580: 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61  me=? AND item_pa
1590: 74 68 3d 3f 3b 22 20 0a 09 09 20 20 20 20 20 6c  th=?;" ...     l
15a0: 6f 67 66 20 72 75 6e 2d 69 64 20 74 65 73 74 2d  ogf run-id test-
15b0: 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29  name item-path))
15c0: 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73 74  )..(define (test
15d0: 2d 73 65 74 2d 74 6f 70 6c 6f 67 21 20 64 62 20  -set-toplog! db 
15e0: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
15f0: 20 6c 6f 67 66 29 20 0a 20 20 28 73 71 6c 69 74   logf) .  (sqlit
1600: 65 33 3a 65 78 65 63 75 74 65 20 64 62 20 22 55  e3:execute db "U
1610: 50 44 41 54 45 20 74 65 73 74 73 20 53 45 54 20  PDATE tests SET 
1620: 66 69 6e 61 6c 5f 6c 6f 67 66 3d 3f 20 57 48 45  final_logf=? WHE
1630: 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20  RE run_id=? AND 
1640: 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69  testname=? AND i
1650: 74 65 6d 5f 70 61 74 68 3d 27 27 3b 22 20 0a 09  tem_path='';" ..
1660: 09 20 20 20 6c 6f 67 66 20 72 75 6e 2d 69 64 20  .   logf run-id 
1670: 74 65 73 74 2d 6e 61 6d 65 29 29 0a 0a 3b 3b 20  test-name))..;; 
1680: 3b 3b 20 54 4f 44 4f 3a 20 43 6f 6e 76 65 72 67  ;; TODO: Converg
1690: 65 20 74 68 69 73 20 77 69 74 68 20 64 62 3a 67  e this with db:g
16a0: 65 74 2d 74 65 73 74 2d 69 6e 66 6f 0a 3b 3b 20  et-test-info.;; 
16b0: 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 67 65  (define (runs:ge
16c0: 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 20 72  t-test-info db r
16d0: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
16e0: 69 74 65 6d 2d 70 61 74 68 29 0a 3b 3b 20 20 20  item-path).;;   
16f0: 28 6c 65 74 20 28 28 72 65 73 20 23 66 29 29 20  (let ((res #f)) 
1700: 3b 3b 20 28 76 65 63 74 6f 72 20 23 66 20 23 66  ;; (vector #f #f
1710: 20 23 66 20 23 66 20 23 66 20 23 66 29 29 29 0a   #f #f #f #f))).
1720: 3b 3b 20 20 20 20 20 28 73 71 6c 69 74 65 33 3a  ;;     (sqlite3:
1730: 66 6f 72 2d 65 61 63 68 2d 72 6f 77 20 0a 3b 3b  for-each-row .;;
1740: 20 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 69        (lambda (i
1750: 64 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  d run-id test-na
1760: 6d 65 20 73 74 61 74 65 20 73 74 61 74 75 73 29  me state status)
1770: 0a 3b 3b 20 20 20 20 20 20 20 20 28 73 65 74 21  .;;        (set!
1780: 20 72 65 73 20 28 76 65 63 74 6f 72 20 69 64 20   res (vector id 
1790: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
17a0: 20 73 74 61 74 65 20 73 74 61 74 75 73 20 69 74   state status it
17b0: 65 6d 2d 70 61 74 68 29 29 29 0a 3b 3b 20 20 20  em-path))).;;   
17c0: 20 20 20 64 62 20 22 53 45 4c 45 43 54 20 69 64     db "SELECT id
17d0: 2c 72 75 6e 5f 69 64 2c 74 65 73 74 6e 61 6d 65  ,run_id,testname
17e0: 2c 73 74 61 74 65 2c 73 74 61 74 75 73 20 46 52  ,state,status FR
17f0: 4f 4d 20 74 65 73 74 73 20 57 48 45 52 45 20 72  OM tests WHERE r
1800: 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74  un_id=? AND test
1810: 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f  name=? AND item_
1820: 70 61 74 68 3d 3f 3b 22 0a 3b 3b 20 20 20 20 20  path=?;".;;     
1830: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
1840: 65 20 69 74 65 6d 2d 70 61 74 68 29 0a 3b 3b 20  e item-path).;; 
1850: 20 20 20 20 72 65 73 29 29 0a 0a 28 64 65 66 69      res))..(defi
1860: 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65 73 74 3a  ne-inline (test:
1870: 67 65 74 2d 69 64 20 76 65 63 29 20 20 20 20 20  get-id vec)     
1880: 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20 76 65    (vector-ref ve
1890: 63 20 30 29 29 0a 28 64 65 66 69 6e 65 2d 69 6e  c 0)).(define-in
18a0: 6c 69 6e 65 20 28 74 65 73 74 3a 67 65 74 2d 72  line (test:get-r
18b0: 75 6e 5f 69 64 20 76 65 63 29 20 20 20 28 76 65  un_id vec)   (ve
18c0: 63 74 6f 72 2d 72 65 66 20 76 65 63 20 31 29 29  ctor-ref vec 1))
18d0: 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69 6e 65 20  .(define-inline 
18e0: 28 74 65 73 74 3a 67 65 74 2d 74 65 73 74 2d 6e  (test:get-test-n
18f0: 61 6d 65 20 76 65 63 29 28 76 65 63 74 6f 72 2d  ame vec)(vector-
1900: 72 65 66 20 76 65 63 20 32 29 29 0a 28 64 65 66  ref vec 2)).(def
1910: 69 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65 73 74  ine-inline (test
1920: 3a 67 65 74 2d 73 74 61 74 65 20 76 65 63 29 20  :get-state vec) 
1930: 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20 76     (vector-ref v
1940: 65 63 20 33 29 29 0a 28 64 65 66 69 6e 65 2d 69  ec 3)).(define-i
1950: 6e 6c 69 6e 65 20 28 74 65 73 74 3a 67 65 74 2d  nline (test:get-
1960: 73 74 61 74 75 73 20 76 65 63 29 20 20 20 28 76  status vec)   (v
1970: 65 63 74 6f 72 2d 72 65 66 20 76 65 63 20 34 29  ector-ref vec 4)
1980: 29 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69 6e 65  ).(define-inline
1990: 20 28 74 65 73 74 3a 67 65 74 2d 69 74 65 6d 2d   (test:get-item-
19a0: 70 61 74 68 20 76 65 63 29 28 76 65 63 74 6f 72  path vec)(vector
19b0: 2d 72 65 66 20 76 65 63 20 35 29 29 0a 0a 28 64  -ref vec 5))..(d
19c0: 65 66 69 6e 65 20 28 72 75 6e 73 3a 74 65 73 74  efine (runs:test
19d0: 2d 67 65 74 2d 66 75 6c 6c 2d 70 61 74 68 20 74  -get-full-path t
19e0: 65 73 74 29 0a 20 20 28 6c 65 74 2a 20 28 28 74  est).  (let* ((t
19f0: 65 73 74 6e 61 6d 65 20 28 64 62 3a 74 65 73 74  estname (db:test
1a00: 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 20 20  -get-testname   
1a10: 74 65 73 74 29 29 0a 09 20 28 69 74 65 6d 70 61  test)).. (itempa
1a20: 74 68 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  th (db:test-get-
1a30: 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 29 29  item-path test))
1a40: 29 0a 20 20 20 20 28 63 6f 6e 63 20 74 65 73 74  ).    (conc test
1a50: 6e 61 6d 65 20 28 69 66 20 28 65 71 75 61 6c 3f  name (if (equal?
1a60: 20 69 74 65 6d 70 61 74 68 20 22 22 29 20 22 22   itempath "") ""
1a70: 20 28 63 6f 6e 63 20 22 28 22 20 69 74 65 6d 70   (conc "(" itemp
1a80: 61 74 68 20 22 29 22 29 29 29 29 29 0a 0a 28 64  ath ")")))))..(d
1a90: 65 66 69 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65  efine-inline (te
1aa0: 73 74 3a 74 65 73 74 2d 67 65 74 2d 66 75 6c 6c  st:test-get-full
1ab0: 6e 61 6d 65 20 74 65 73 74 29 0a 20 20 20 28 63  name test).   (c
1ac0: 6f 6e 63 20 28 64 62 3a 74 65 73 74 2d 67 65 74  onc (db:test-get
1ad0: 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 29 0a  -testname test).
1ae0: 09 20 28 69 66 20 28 65 71 75 61 6c 3f 20 28 64  . (if (equal? (d
1af0: 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d  b:test-get-item-
1b00: 70 61 74 68 20 74 65 73 74 29 20 22 22 29 0a 09  path test) "")..
1b10: 20 20 20 20 20 22 22 0a 09 20 20 20 20 20 28 63       ""..     (c
1b20: 6f 6e 63 20 22 28 22 20 28 64 62 3a 74 65 73 74  onc "(" (db:test
1b30: 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74  -get-item-path t
1b40: 65 73 74 29 20 22 29 22 29 29 29 29 0a 0a 28 64  est) ")"))))..(d
1b50: 65 66 69 6e 65 20 28 63 68 65 63 6b 2d 76 61 6c  efine (check-val
1b60: 69 64 2d 69 74 65 6d 73 20 63 6c 61 73 73 20 69  id-items class i
1b70: 74 65 6d 29 0a 20 20 28 6c 65 74 20 28 28 76 61  tem).  (let ((va
1b80: 6c 69 64 2d 76 61 6c 75 65 73 20 28 6c 65 74 20  lid-values (let 
1b90: 28 28 73 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b  ((s (config-look
1ba0: 75 70 20 2a 63 6f 6e 66 69 67 64 61 74 2a 20 22  up *configdat* "
1bb0: 76 61 6c 69 64 76 61 6c 75 65 73 22 20 63 6c 61  validvalues" cla
1bc0: 73 73 29 29 29 0a 09 09 09 28 69 66 20 73 20 28  ss)))....(if s (
1bd0: 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 73 29 20  string-split s) 
1be0: 23 66 29 29 29 29 0a 20 20 20 20 28 69 66 20 76  #f)))).    (if v
1bf0: 61 6c 69 64 2d 76 61 6c 75 65 73 0a 09 28 69 66  alid-values..(if
1c00: 20 28 6d 65 6d 62 65 72 20 69 74 65 6d 20 76 61   (member item va
1c10: 6c 69 64 2d 76 61 6c 75 65 73 29 0a 09 20 20 20  lid-values)..   
1c20: 20 69 74 65 6d 20 23 66 29 0a 09 69 74 65 6d 29   item #f)..item)
1c30: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73  ))..(define (tes
1c40: 74 73 74 65 70 2d 73 65 74 2d 73 74 61 74 75 73  tstep-set-status
1c50: 21 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  ! db run-id test
1c60: 2d 6e 61 6d 65 20 74 65 73 74 73 74 65 70 2d 6e  -name teststep-n
1c70: 61 6d 65 20 73 74 61 74 65 2d 69 6e 20 73 74 61  ame state-in sta
1c80: 74 75 73 2d 69 6e 20 69 74 65 6d 64 61 74 20 63  tus-in itemdat c
1c90: 6f 6d 6d 65 6e 74 29 0a 20 20 28 64 65 62 75 67  omment).  (debug
1ca0: 3a 70 72 69 6e 74 20 34 20 22 72 75 6e 2d 69 64  :print 4 "run-id
1cb0: 3a 20 22 20 72 75 6e 2d 69 64 20 22 20 74 65 73  : " run-id " tes
1cc0: 74 2d 6e 61 6d 65 3a 20 22 20 74 65 73 74 2d 6e  t-name: " test-n
1cd0: 61 6d 65 29 0a 20 20 28 6c 65 74 2a 20 28 28 73  ame).  (let* ((s
1ce0: 74 61 74 65 20 20 20 20 20 28 63 68 65 63 6b 2d  tate     (check-
1cf0: 76 61 6c 69 64 2d 69 74 65 6d 73 20 22 73 74 61  valid-items "sta
1d00: 74 65 22 20 73 74 61 74 65 2d 69 6e 29 29 0a 09  te" state-in))..
1d10: 20 28 73 74 61 74 75 73 20 20 20 20 28 63 68 65   (status    (che
1d20: 63 6b 2d 76 61 6c 69 64 2d 69 74 65 6d 73 20 22  ck-valid-items "
1d30: 73 74 61 74 75 73 22 20 73 74 61 74 75 73 2d 69  status" status-i
1d40: 6e 29 29 0a 09 20 28 69 74 65 6d 2d 70 61 74 68  n)).. (item-path
1d50: 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74   (item-list->pat
1d60: 68 20 69 74 65 6d 64 61 74 29 29 0a 09 20 28 74  h itemdat)).. (t
1d70: 65 73 74 64 61 74 20 20 20 28 64 62 3a 67 65 74  estdat   (db:get
1d80: 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 20 72 75  -test-info db ru
1d90: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69  n-id test-name i
1da0: 74 65 6d 2d 70 61 74 68 29 29 29 0a 20 20 20 20  tem-path))).    
1db0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 35 20 22  (debug:print 5 "
1dc0: 74 65 73 74 64 61 74 3a 20 22 20 74 65 73 74 64  testdat: " testd
1dd0: 61 74 29 0a 20 20 20 20 28 69 66 20 28 61 6e 64  at).    (if (and
1de0: 20 74 65 73 74 64 61 74 20 3b 3b 20 69 66 20 74   testdat ;; if t
1df0: 68 65 20 73 65 63 74 69 6f 6e 20 65 78 69 73 74  he section exist
1e00: 73 20 74 68 65 6e 20 66 6f 72 63 65 20 73 70 65  s then force spe
1e10: 63 69 66 69 63 61 74 69 6f 6e 20 42 55 47 2c 20  cification BUG, 
1e20: 49 20 64 6f 6e 27 74 20 6c 69 6b 65 20 68 6f 77  I don't like how
1e30: 20 74 68 69 73 20 77 6f 72 6b 73 2e 0a 09 20 20   this works...  
1e40: 20 20 20 28 6f 72 20 28 6e 6f 74 20 73 74 61 74     (or (not stat
1e50: 65 29 28 6e 6f 74 20 73 74 61 74 75 73 29 29 29  e)(not status)))
1e60: 0a 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30  ..(debug:print 0
1e70: 20 22 57 41 52 4e 49 4e 47 3a 20 49 6e 76 61 6c   "WARNING: Inval
1e80: 69 64 20 22 20 28 69 66 20 73 74 61 74 75 73 20  id " (if status 
1e90: 22 73 74 61 74 75 73 22 20 22 73 74 61 74 65 22  "status" "state"
1ea0: 29 0a 09 20 20 20 20 20 20 20 22 20 76 61 6c 75  )..       " valu
1eb0: 65 20 5c 22 22 20 28 69 66 20 73 74 61 74 75 73  e \"" (if status
1ec0: 20 73 74 61 74 75 73 2d 69 6e 20 73 74 61 74 65   status-in state
1ed0: 2d 69 6e 29 20 22 5c 22 2c 20 75 70 64 61 74 65  -in) "\", update
1ee0: 20 79 6f 75 72 20 76 61 6c 69 64 73 74 61 74 65   your validstate
1ef0: 73 20 73 65 63 74 69 6f 6e 20 69 6e 20 6d 65 67  s section in meg
1f00: 61 74 65 73 74 2e 63 6f 6e 66 69 67 22 29 29 0a  atest.config")).
1f10: 20 20 20 20 28 69 66 20 74 65 73 74 64 61 74 0a      (if testdat.
1f20: 09 28 6c 65 74 20 28 28 74 65 73 74 2d 69 64 20  .(let ((test-id 
1f30: 28 74 65 73 74 3a 67 65 74 2d 69 64 20 74 65 73  (test:get-id tes
1f40: 74 64 61 74 29 29 29 0a 09 20 20 28 73 71 6c 69  tdat)))..  (sqli
1f50: 74 65 33 3a 65 78 65 63 75 74 65 20 64 62 20 0a  te3:execute db .
1f60: 09 09 09 22 49 4e 53 45 52 54 20 4f 52 20 52 45  ..."INSERT OR RE
1f70: 50 4c 41 43 45 20 69 6e 74 6f 20 74 65 73 74 5f  PLACE into test_
1f80: 73 74 65 70 73 20 28 74 65 73 74 5f 69 64 2c 73  steps (test_id,s
1f90: 74 65 70 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74  tepname,state,st
1fa0: 61 74 75 73 2c 65 76 65 6e 74 5f 74 69 6d 65 2c  atus,event_time,
1fb0: 63 6f 6d 6d 65 6e 74 29 20 56 41 4c 55 45 53 28  comment) VALUES(
1fc0: 3f 2c 3f 2c 3f 2c 3f 2c 73 74 72 66 74 69 6d 65  ?,?,?,?,strftime
1fd0: 28 27 25 73 27 2c 27 6e 6f 77 27 29 2c 3f 29 3b  ('%s','now'),?);
1fe0: 22 0a 09 09 09 74 65 73 74 2d 69 64 20 74 65 73  "....test-id tes
1ff0: 74 73 74 65 70 2d 6e 61 6d 65 20 73 74 61 74 65  tstep-name state
2000: 20 73 74 61 74 75 73 20 28 69 66 20 63 6f 6d 6d   status (if comm
2010: 65 6e 74 20 63 6f 6d 6d 65 6e 74 20 22 22 29 29  ent comment ""))
2020: 29 0a 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20  )..(debug:print 
2030: 30 20 22 45 52 52 4f 52 3a 20 43 61 6e 27 74 20  0 "ERROR: Can't 
2040: 75 70 64 61 74 65 20 22 20 74 65 73 74 2d 6e 61  update " test-na
2050: 6d 65 20 22 20 66 6f 72 20 72 75 6e 20 22 20 72  me " for run " r
2060: 75 6e 2d 69 64 20 22 20 2d 3e 20 6e 6f 20 73 75  un-id " -> no su
2070: 63 68 20 74 65 73 74 20 69 6e 20 64 62 22 29 29  ch test in db"))
2080: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73  ))..(define (tes
2090: 74 2d 67 65 74 2d 6b 69 6c 6c 2d 72 65 71 75 65  t-get-kill-reque
20a0: 73 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  st db run-id tes
20b0: 74 2d 6e 61 6d 65 20 69 74 65 6d 64 61 74 29 0a  t-name itemdat).
20c0: 20 20 28 6c 65 74 2a 20 28 28 69 74 65 6d 2d 70    (let* ((item-p
20d0: 61 74 68 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e  ath (item-list->
20e0: 70 61 74 68 20 69 74 65 6d 64 61 74 29 29 0a 09  path itemdat))..
20f0: 20 28 74 65 73 74 64 61 74 20 20 20 28 64 62 3a   (testdat   (db:
2100: 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62  get-test-info db
2110: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
2120: 65 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 20  e item-path))). 
2130: 20 20 20 28 65 71 75 61 6c 3f 20 28 74 65 73 74     (equal? (test
2140: 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64  :get-state testd
2150: 61 74 29 20 22 4b 49 4c 4c 52 45 51 22 29 29 29  at) "KILLREQ")))
2160: 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73 74 2d  ..(define (test-
2170: 73 65 74 2d 6d 65 74 61 2d 69 6e 66 6f 20 64 62  set-meta-info db
2180: 20 72 75 6e 2d 69 64 20 74 65 73 74 6e 61 6d 65   run-id testname
2190: 20 69 74 65 6d 64 61 74 29 0a 20 20 28 6c 65 74   itemdat).  (let
21a0: 20 28 28 69 74 65 6d 2d 70 61 74 68 20 28 69 74   ((item-path (it
21b0: 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69 74  em-list->path it
21c0: 65 6d 64 61 74 29 29 0a 09 28 63 70 75 6c 6f 61  emdat))..(cpuloa
21d0: 64 20 20 28 67 65 74 2d 63 70 75 2d 6c 6f 61 64  d  (get-cpu-load
21e0: 29 29 0a 09 28 68 6f 73 74 6e 61 6d 65 20 28 67  ))..(hostname (g
21f0: 65 74 2d 68 6f 73 74 2d 6e 61 6d 65 29 29 0a 09  et-host-name))..
2200: 28 64 69 73 6b 66 72 65 65 20 28 67 65 74 2d 64  (diskfree (get-d
2210: 66 20 28 63 75 72 72 65 6e 74 2d 64 69 72 65 63  f (current-direc
2220: 74 6f 72 79 29 29 29 0a 09 28 75 6e 61 6d 65 20  tory)))..(uname 
2230: 20 20 20 28 67 65 74 2d 75 6e 61 6d 65 20 22 2d     (get-uname "-
2240: 73 72 76 70 69 6f 22 29 29 0a 09 28 72 75 6e 70  srvpio"))..(runp
2250: 61 74 68 20 20 28 63 75 72 72 65 6e 74 2d 64 69  ath  (current-di
2260: 72 65 63 74 6f 72 79 29 29 29 0a 20 20 20 20 28  rectory))).    (
2270: 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20  sqlite3:execute 
2280: 64 62 20 22 55 50 44 41 54 45 20 74 65 73 74 73  db "UPDATE tests
2290: 20 53 45 54 20 68 6f 73 74 3d 3f 2c 63 70 75 6c   SET host=?,cpul
22a0: 6f 61 64 3d 3f 2c 64 69 73 6b 66 72 65 65 3d 3f  oad=?,diskfree=?
22b0: 2c 75 6e 61 6d 65 3d 3f 2c 72 75 6e 64 69 72 3d  ,uname=?,rundir=
22c0: 3f 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f  ? WHERE run_id=?
22d0: 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20   AND testname=? 
22e0: 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f 3b  AND item_path=?;
22f0: 22 0a 09 09 20 20 68 6f 73 74 6e 61 6d 65 0a 09  "...  hostname..
2300: 09 20 20 63 70 75 6c 6f 61 64 0a 09 09 20 20 64  .  cpuload...  d
2310: 69 73 6b 66 72 65 65 0a 09 09 20 20 75 6e 61 6d  iskfree...  unam
2320: 65 0a 09 09 20 20 72 75 6e 70 61 74 68 0a 09 09  e...  runpath...
2330: 20 20 72 75 6e 2d 69 64 0a 09 09 20 20 74 65 73    run-id...  tes
2340: 74 6e 61 6d 65 0a 09 09 20 20 69 74 65 6d 2d 70  tname...  item-p
2350: 61 74 68 29 29 29 0a 0a 28 64 65 66 69 6e 65 20  ath)))..(define 
2360: 28 74 65 73 74 2d 75 70 64 61 74 65 2d 6d 65 74  (test-update-met
2370: 61 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64  a-info db run-id
2380: 20 74 65 73 74 6e 61 6d 65 20 69 74 65 6d 64 61   testname itemda
2390: 74 20 6d 69 6e 75 74 65 73 29 0a 20 20 28 6c 65  t minutes).  (le
23a0: 74 20 28 28 69 74 65 6d 2d 70 61 74 68 20 28 69  t ((item-path (i
23b0: 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69  tem-list->path i
23c0: 74 65 6d 64 61 74 29 29 0a 09 28 63 70 75 6c 6f  temdat))..(cpulo
23d0: 61 64 20 20 28 67 65 74 2d 63 70 75 2d 6c 6f 61  ad  (get-cpu-loa
23e0: 64 29 29 0a 09 28 64 69 73 6b 66 72 65 65 20 28  d))..(diskfree (
23f0: 67 65 74 2d 64 66 20 28 63 75 72 72 65 6e 74 2d  get-df (current-
2400: 64 69 72 65 63 74 6f 72 79 29 29 29 29 0a 20 20  directory)))).  
2410: 20 20 28 69 66 20 28 6e 6f 74 20 63 70 75 6c 6f    (if (not cpulo
2420: 61 64 29 20 20 28 62 65 67 69 6e 20 28 64 65 62  ad)  (begin (deb
2430: 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e  ug:print 0 "WARN
2440: 49 4e 47 3a 20 43 50 55 4c 4f 41 44 20 6e 6f 74  ING: CPULOAD not
2450: 20 66 6f 75 6e 64 2e 22 29 20 20 28 73 65 74 21   found.")  (set!
2460: 20 63 70 75 6c 6f 61 64 20 22 6e 2f 61 22 29 29   cpuload "n/a"))
2470: 29 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 64  ).    (if (not d
2480: 69 73 6b 66 72 65 65 29 20 28 62 65 67 69 6e 20  iskfree) (begin 
2490: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
24a0: 57 41 52 4e 49 4e 47 3a 20 44 49 53 4b 46 52 45  WARNING: DISKFRE
24b0: 45 20 6e 6f 74 20 66 6f 75 6e 64 2e 22 29 20 28  E not found.") (
24c0: 73 65 74 21 20 64 69 73 6b 66 72 65 65 20 22 6e  set! diskfree "n
24d0: 2f 61 22 29 29 29 0a 20 20 20 20 28 69 66 20 28  /a"))).    (if (
24e0: 6e 6f 74 20 69 74 65 6d 2d 70 61 74 68 29 28 62  not item-path)(b
24f0: 65 67 69 6e 20 28 64 65 62 75 67 3a 70 72 69 6e  egin (debug:prin
2500: 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 49 54  t 0 "WARNING: IT
2510: 45 4d 50 41 54 48 20 6e 6f 74 20 73 65 74 2e 22  EMPATH not set."
2520: 29 20 20 20 28 73 65 74 21 20 69 74 65 6d 2d 70  )   (set! item-p
2530: 61 74 68 20 22 22 29 29 29 0a 20 20 20 20 3b 3b  ath ""))).    ;;
2540: 20 28 6c 65 74 20 28 28 74 65 73 74 69 6e 66 6f   (let ((testinfo
2550: 20 28 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e   (db:get-test-in
2560: 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  fo db run-id tes
2570: 74 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  tname item-path)
2580: 29 29 0a 20 20 20 20 3b 3b 20 20 20 28 69 66 20  )).    ;;   (if 
2590: 28 61 6e 64 20 28 6e 6f 74 20 28 65 71 75 61 6c  (and (not (equal
25a0: 3f 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 73  ? (db:test-get-s
25b0: 74 61 74 75 73 20 74 65 73 74 69 6e 66 6f 29 20  tatus testinfo) 
25c0: 22 43 4f 4d 50 4c 45 54 45 44 22 29 29 0a 20 20  "COMPLETED")).  
25d0: 20 20 3b 3b 20 20 20 20 20 20 20 20 20 20 20 20    ;;            
25e0: 28 6e 6f 74 20 28 65 71 75 61 6c 3f 20 28 64 62  (not (equal? (db
25f0: 3a 74 65 73 74 2d 67 65 74 2d 73 74 61 74 75 73  :test-get-status
2600: 20 74 65 73 74 69 6e 66 6f 29 20 22 4b 49 4c 4c   testinfo) "KILL
2610: 52 45 51 22 29 29 0a 20 20 20 20 28 73 71 6c 69  REQ")).    (sqli
2620: 74 65 33 3a 65 78 65 63 75 74 65 0a 20 20 20 20  te3:execute.    
2630: 20 64 62 0a 20 20 20 20 20 22 55 50 44 41 54 45   db.     "UPDATE
2640: 20 74 65 73 74 73 20 53 45 54 20 63 70 75 6c 6f   tests SET cpulo
2650: 61 64 3d 3f 2c 64 69 73 6b 66 72 65 65 3d 3f 2c  ad=?,diskfree=?,
2660: 72 75 6e 5f 64 75 72 61 74 69 6f 6e 3d 3f 2c 73  run_duration=?,s
2670: 74 61 74 65 3d 27 52 55 4e 4e 49 4e 47 27 20 57  tate='RUNNING' W
2680: 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e  HERE run_id=? AN
2690: 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44  D testname=? AND
26a0: 20 69 74 65 6d 5f 70 61 74 68 3d 3f 20 41 4e 44   item_path=? AND
26b0: 20 73 74 61 74 65 20 4e 4f 54 20 49 4e 20 28 27   state NOT IN ('
26c0: 43 4f 4d 50 4c 45 54 45 44 27 2c 27 4b 49 4c 4c  COMPLETED','KILL
26d0: 52 45 51 27 2c 27 4b 49 4c 4c 45 44 27 29 3b 22  REQ','KILLED');"
26e0: 0a 20 20 20 20 20 63 70 75 6c 6f 61 64 0a 20 20  .     cpuload.  
26f0: 20 20 20 64 69 73 6b 66 72 65 65 0a 20 20 20 20     diskfree.    
2700: 20 6d 69 6e 75 74 65 73 0a 20 20 20 20 20 72 75   minutes.     ru
2710: 6e 2d 69 64 0a 20 20 20 20 20 74 65 73 74 6e 61  n-id.     testna
2720: 6d 65 0a 20 20 20 20 20 69 74 65 6d 2d 70 61 74  me.     item-pat
2730: 68 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 73  h)))..(define (s
2740: 65 74 2d 6d 65 67 61 74 65 73 74 2d 65 6e 76 2d  et-megatest-env-
2750: 76 61 72 73 20 64 62 20 72 75 6e 2d 69 64 29 0a  vars db run-id).
2760: 20 20 28 6c 65 74 20 28 28 6b 65 79 73 20 28 64    (let ((keys (d
2770: 62 2d 67 65 74 2d 6b 65 79 73 20 64 62 29 29 29  b-get-keys db)))
2780: 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20 28  .    (for-each (
2790: 6c 61 6d 62 64 61 20 28 6b 65 79 29 0a 09 09 28  lambda (key)...(
27a0: 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68  sqlite3:for-each
27b0: 2d 72 6f 77 0a 09 09 20 28 6c 61 6d 62 64 61 20  -row... (lambda 
27c0: 28 76 61 6c 29 0a 09 09 20 20 20 28 64 65 62 75  (val)...   (debu
27d0: 67 3a 70 72 69 6e 74 20 32 20 22 73 65 74 65 6e  g:print 2 "seten
27e0: 76 20 22 20 28 6b 65 79 3a 67 65 74 2d 66 69 65  v " (key:get-fie
27f0: 6c 64 6e 61 6d 65 20 6b 65 79 29 20 22 20 22 20  ldname key) " " 
2800: 76 61 6c 29 0a 09 09 20 20 20 28 73 65 74 65 6e  val)...   (seten
2810: 76 20 28 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64  v (key:get-field
2820: 6e 61 6d 65 20 6b 65 79 29 20 76 61 6c 29 29 0a  name key) val)).
2830: 09 09 20 64 62 20 0a 09 09 20 28 63 6f 6e 63 20  .. db ... (conc 
2840: 22 53 45 4c 45 43 54 20 22 20 28 6b 65 79 3a 67  "SELECT " (key:g
2850: 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65 79  et-fieldname key
2860: 29 20 22 20 46 52 4f 4d 20 72 75 6e 73 20 57 48  ) " FROM runs WH
2870: 45 52 45 20 69 64 3d 3f 3b 22 29 0a 09 09 20 72  ERE id=?;")... r
2880: 75 6e 2d 69 64 29 29 0a 09 20 20 20 20 20 20 6b  un-id))..      k
2890: 65 79 73 29 29 29 0a 0a 28 64 65 66 69 6e 65 20  eys)))..(define 
28a0: 28 73 65 74 2d 69 74 65 6d 2d 65 6e 76 2d 76 61  (set-item-env-va
28b0: 72 73 20 69 74 65 6d 64 61 74 29 0a 20 20 28 66  rs itemdat).  (f
28c0: 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 20  or-each (lambda 
28d0: 28 69 74 65 6d 29 0a 09 20 20 20 20 20 20 28 64  (item)..      (d
28e0: 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 73 65  ebug:print 2 "se
28f0: 74 65 6e 76 20 22 20 28 63 61 72 20 69 74 65 6d  tenv " (car item
2900: 29 20 22 20 22 20 28 63 61 64 72 20 69 74 65 6d  ) " " (cadr item
2910: 29 29 0a 09 20 20 20 20 20 20 28 73 65 74 65 6e  ))..      (seten
2920: 76 20 28 63 61 72 20 69 74 65 6d 29 20 28 63 61  v (car item) (ca
2930: 64 72 20 69 74 65 6d 29 29 29 0a 09 20 20 20 20  dr item)))..    
2940: 69 74 65 6d 64 61 74 29 29 0a 0a 28 64 65 66 69  itemdat))..(defi
2950: 6e 65 20 28 67 65 74 2d 61 6c 6c 2d 6c 65 67 61  ne (get-all-lega
2960: 6c 2d 74 65 73 74 73 29 0a 20 20 28 6c 65 74 2a  l-tests).  (let*
2970: 20 28 28 74 65 73 74 73 20 20 28 67 6c 6f 62 20   ((tests  (glob 
2980: 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74 68 2a 20  (conc *toppath* 
2990: 22 2f 74 65 73 74 73 2f 2a 22 29 29 29 0a 09 20  "/tests/*"))).. 
29a0: 28 72 65 73 20 20 20 20 27 28 29 29 29 0a 20 20  (res    '())).  
29b0: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34    (debug:print 4
29c0: 20 22 49 4e 46 4f 3a 20 4c 6f 6f 6b 69 6e 67 20   "INFO: Looking 
29d0: 61 74 20 74 65 73 74 73 20 22 20 28 73 74 72 69  at tests " (stri
29e0: 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 74  ng-intersperse t
29f0: 65 73 74 73 20 22 2c 22 29 29 0a 20 20 20 20 28  ests ",")).    (
2a00: 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61  for-each (lambda
2a10: 20 28 74 65 73 74 70 61 74 68 29 0a 09 09 28 69   (testpath)...(i
2a20: 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20  f (file-exists? 
2a30: 28 63 6f 6e 63 20 74 65 73 74 70 61 74 68 20 22  (conc testpath "
2a40: 2f 74 65 73 74 63 6f 6e 66 69 67 22 29 29 0a 09  /testconfig"))..
2a50: 09 20 20 20 20 28 73 65 74 21 20 72 65 73 20 28  .    (set! res (
2a60: 63 6f 6e 73 20 28 6c 61 73 74 20 28 73 74 72 69  cons (last (stri
2a70: 6e 67 2d 73 70 6c 69 74 20 74 65 73 74 70 61 74  ng-split testpat
2a80: 68 20 22 2f 22 29 29 20 72 65 73 29 29 29 29 0a  h "/")) res)))).
2a90: 09 20 20 20 20 20 20 74 65 73 74 73 29 0a 20 20  .      tests).  
2aa0: 20 20 72 65 73 29 29 0a 0a 28 64 65 66 69 6e 65    res))..(define
2ab0: 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d   (runs:can-run-m
2ac0: 6f 72 65 2d 74 65 73 74 73 20 64 62 29 0a 20 20  ore-tests db).  
2ad0: 28 6c 65 74 20 28 28 6e 75 6d 2d 72 75 6e 6e 69  (let ((num-runni
2ae0: 6e 67 20 28 64 62 3a 67 65 74 2d 63 6f 75 6e 74  ng (db:get-count
2af0: 2d 74 65 73 74 73 2d 72 75 6e 6e 69 6e 67 20 64  -tests-running d
2b00: 62 29 29 0a 09 28 6d 61 78 2d 63 6f 6e 63 75 72  b))..(max-concur
2b10: 72 65 6e 74 2d 6a 6f 62 73 20 28 63 6f 6e 66 69  rent-jobs (confi
2b20: 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67  g-lookup *config
2b30: 64 61 74 2a 20 22 73 65 74 75 70 22 20 22 6d 61  dat* "setup" "ma
2b40: 78 5f 63 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f 62  x_concurrent_job
2b50: 73 22 29 29 29 0a 20 20 20 20 28 64 65 62 75 67  s"))).    (debug
2b60: 3a 70 72 69 6e 74 20 32 20 22 6d 61 78 2d 63 6f  :print 2 "max-co
2b70: 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 3a 20 22  ncurrent-jobs: "
2b80: 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d   max-concurrent-
2b90: 6a 6f 62 73 20 22 2c 20 6e 75 6d 2d 72 75 6e 6e  jobs ", num-runn
2ba0: 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69  ing: " num-runni
2bb0: 6e 67 29 0a 20 20 20 20 28 69 66 20 28 6e 6f 74  ng).    (if (not
2bc0: 20 28 65 71 3f 20 30 20 2a 67 6c 6f 62 61 6c 65   (eq? 0 *globale
2bd0: 78 69 74 73 74 61 74 75 73 2a 29 29 0a 09 23 66  xitstatus*))..#f
2be0: 0a 09 28 69 66 20 28 6f 72 20 28 6e 6f 74 20 6d  ..(if (or (not m
2bf0: 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f  ax-concurrent-jo
2c00: 62 73 29 0a 09 09 28 61 6e 64 20 6d 61 78 2d 63  bs)...(and max-c
2c10: 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 0a 09  oncurrent-jobs..
2c20: 09 20 20 20 20 20 28 73 74 72 69 6e 67 2d 3e 6e  .     (string->n
2c30: 75 6d 62 65 72 20 6d 61 78 2d 63 6f 6e 63 75 72  umber max-concur
2c40: 72 65 6e 74 2d 6a 6f 62 73 29 0a 09 09 20 20 20  rent-jobs)...   
2c50: 20 20 28 6e 6f 74 20 28 3e 3d 20 6e 75 6d 2d 72    (not (>= num-r
2c60: 75 6e 6e 69 6e 67 20 28 73 74 72 69 6e 67 2d 3e  unning (string->
2c70: 6e 75 6d 62 65 72 20 6d 61 78 2d 63 6f 6e 63 75  number max-concu
2c80: 72 72 65 6e 74 2d 6a 6f 62 73 29 29 29 29 29 0a  rrent-jobs))))).
2c90: 09 20 20 20 20 23 74 0a 09 20 20 20 20 28 62 65  .    #t..    (be
2ca0: 67 69 6e 20 0a 09 20 20 20 20 20 20 28 64 65 62  gin ..      (deb
2cb0: 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e  ug:print 0 "WARN
2cc0: 49 4e 47 3a 20 4d 61 78 20 72 75 6e 6e 69 6e 67  ING: Max running
2cd0: 20 6a 6f 62 73 20 65 78 63 65 65 64 65 64 2c 20   jobs exceeded, 
2ce0: 63 75 72 72 65 6e 74 20 6e 75 6d 62 65 72 20 72  current number r
2cf0: 75 6e 6e 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75  unning: " num-ru
2d00: 6e 6e 69 6e 67 20 0a 09 09 09 20 20 20 22 2c 20  nning ....   ", 
2d10: 6d 61 78 5f 63 6f 6e 63 75 72 72 65 6e 74 5f 6a  max_concurrent_j
2d20: 6f 62 73 3a 20 22 20 6d 61 78 2d 63 6f 6e 63 75  obs: " max-concu
2d30: 72 72 65 6e 74 2d 6a 6f 62 73 29 0a 09 20 20 20  rrent-jobs)..   
2d40: 20 20 20 23 66 29 29 29 29 29 0a 20 20 0a 28 64     #f))))).  .(d
2d50: 65 66 69 6e 65 20 28 72 75 6e 2d 74 65 73 74 73  efine (run-tests
2d60: 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 73 29 0a   db test-names).
2d70: 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 73 20 20    (let* ((keys  
2d80: 20 20 20 20 20 20 28 64 62 2d 67 65 74 2d 6b 65        (db-get-ke
2d90: 79 73 20 64 62 29 29 0a 09 20 28 6b 65 79 76 61  ys db)).. (keyva
2da0: 6c 6c 73 74 20 20 20 28 6b 65 79 73 2d 3e 76 61  llst   (keys->va
2db0: 6c 6c 69 73 74 20 6b 65 79 73 20 23 74 29 29 0a  llist keys #t)).
2dc0: 09 20 28 72 75 6e 2d 69 64 20 20 20 20 20 20 28  . (run-id      (
2dd0: 72 65 67 69 73 74 65 72 2d 72 75 6e 20 64 62 20  register-run db 
2de0: 6b 65 79 73 29 29 29 20 3b 3b 20 20 74 65 73 74  keys))) ;;  test
2df0: 2d 6e 61 6d 65 29 29 29 0a 20 20 20 20 3b 3b 20  -name))).    ;; 
2e00: 6f 6e 20 74 68 65 20 66 69 72 73 74 20 70 61 73  on the first pas
2e10: 73 20 6f 72 20 63 61 6c 6c 20 74 6f 20 72 75 6e  s or call to run
2e20: 2d 74 65 73 74 73 20 73 65 74 20 46 41 49 4c 53  -tests set FAILS
2e30: 20 74 6f 20 4e 4f 54 5f 53 54 41 52 54 45 44 20   to NOT_STARTED 
2e40: 69 66 0a 20 20 20 20 3b 3b 20 2d 6b 65 65 70 67  if.    ;; -keepg
2e50: 6f 69 6e 67 20 69 73 20 73 70 65 63 69 66 69 65  oing is specifie
2e60: 64 0a 20 20 20 20 28 69 66 20 28 61 6e 64 20 28  d.    (if (and (
2e70: 65 71 3f 20 2a 70 61 73 73 6e 75 6d 2a 20 30 29  eq? *passnum* 0)
2e80: 0a 09 20 20 20 20 20 28 61 72 67 73 3a 67 65 74  ..     (args:get
2e90: 2d 61 72 67 20 22 2d 6b 65 65 70 67 6f 69 6e 67  -arg "-keepgoing
2ea0: 22 29 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 3b  "))..(begin..  ;
2eb0: 3b 20 68 61 76 65 20 74 6f 20 64 65 6c 65 74 65  ; have to delete
2ec0: 20 74 65 73 74 20 72 65 63 6f 72 64 73 20 77 68   test records wh
2ed0: 65 72 65 20 4e 4f 54 5f 53 54 41 52 54 45 44 20  ere NOT_STARTED 
2ee0: 73 69 6e 63 65 20 74 68 65 79 20 63 61 6e 20 63  since they can c
2ef0: 61 75 73 65 20 2d 6b 65 65 70 67 6f 69 6e 67 20  ause -keepgoing 
2f00: 74 6f 20 0a 09 20 20 3b 3b 20 67 65 74 20 73 74  to ..  ;; get st
2f10: 75 63 6b 20 64 75 65 20 74 6f 20 62 65 63 6f 6d  uck due to becom
2f20: 69 6e 67 20 69 6e 61 63 63 65 73 73 69 62 6c 65  ing inaccessible
2f30: 20 66 72 6f 6d 20 61 20 66 61 69 6c 65 64 20 74   from a failed t
2f40: 65 73 74 2e 20 49 2e 65 2e 20 69 66 20 74 65 73  est. I.e. if tes
2f50: 74 20 42 20 64 65 70 65 6e 64 73 20 0a 09 20 20  t B depends ..  
2f60: 3b 3b 20 6f 6e 20 74 65 73 74 20 41 20 62 75 74  ;; on test A but
2f70: 20 74 65 73 74 20 42 20 72 65 61 63 68 65 64 20   test B reached 
2f80: 74 68 65 20 70 6f 69 6e 74 20 6f 6e 20 62 65 69  the point on bei
2f90: 6e 67 20 72 65 67 69 73 74 65 72 65 64 20 61 73  ng registered as
2fa0: 20 4e 4f 54 5f 53 54 41 52 54 45 44 20 61 6e 64   NOT_STARTED and
2fb0: 20 74 65 73 74 0a 09 20 20 3b 3b 20 41 20 66 61   test..  ;; A fa
2fc0: 69 6c 65 64 20 66 6f 72 20 73 6f 6d 65 20 72 65  iled for some re
2fd0: 61 73 6f 6e 20 74 68 65 6e 20 6f 6e 20 72 65 2d  ason then on re-
2fe0: 72 75 6e 20 75 73 69 6e 67 20 2d 6b 65 65 70 67  run using -keepg
2ff0: 6f 69 6e 67 20 74 68 65 20 72 75 6e 20 63 61 6e  oing the run can
3000: 20 6e 65 76 65 72 20 63 6f 6d 70 6c 65 74 65 2e   never complete.
3010: 0a 09 20 20 28 64 62 3a 64 65 6c 65 74 65 2d 74  ..  (db:delete-t
3020: 65 73 74 73 2d 69 6e 2d 73 74 61 74 65 20 64 62  ests-in-state db
3030: 20 72 75 6e 2d 69 64 20 22 4e 4f 54 5f 53 54 41   run-id "NOT_STA
3040: 52 54 45 44 22 29 0a 09 20 20 28 64 62 3a 73 65  RTED")..  (db:se
3050: 74 2d 74 65 73 74 73 2d 73 74 61 74 65 2d 73 74  t-tests-state-st
3060: 61 74 75 73 20 64 62 20 72 75 6e 2d 69 64 20 74  atus db run-id t
3070: 65 73 74 2d 6e 61 6d 65 73 20 23 66 20 22 46 41  est-names #f "FA
3080: 49 4c 22 20 22 4e 4f 54 5f 53 54 41 52 54 45 44  IL" "NOT_STARTED
3090: 22 20 22 46 41 49 4c 22 29 29 29 0a 20 20 20 20  " "FAIL"))).    
30a0: 28 73 65 74 21 20 2a 70 61 73 73 6e 75 6d 2a 20  (set! *passnum* 
30b0: 28 2b 20 2a 70 61 73 73 6e 75 6d 2a 20 31 29 29  (+ *passnum* 1))
30c0: 0a 20 20 20 20 28 6c 65 74 20 6c 6f 6f 70 20 28  .    (let loop (
30d0: 28 6e 75 6d 74 69 6d 65 73 20 30 29 29 0a 20 20  (numtimes 0)).  
30e0: 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20      (for-each . 
30f0: 20 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 74        (lambda (t
3100: 65 73 74 2d 6e 61 6d 65 29 0a 09 20 28 69 66 20  est-name).. (if 
3110: 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f  (runs:can-run-mo
3120: 72 65 2d 74 65 73 74 73 20 64 62 29 0a 09 20 20  re-tests db)..  
3130: 20 20 20 28 72 75 6e 2d 6f 6e 65 2d 74 65 73 74     (run-one-test
3140: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d   db run-id test-
3150: 6e 61 6d 65 20 6b 65 79 76 61 6c 6c 73 74 29 0a  name keyvallst).
3160: 09 20 20 20 20 20 3b 3b 20 61 64 64 20 73 6f 6d  .     ;; add som
3170: 65 20 64 65 6c 61 79 20 0a 09 20 20 20 20 20 3b  e delay ..     ;
3180: 28 73 6c 65 65 70 20 32 29 0a 09 20 20 20 20 20  (sleep 2)..     
3190: 29 29 0a 20 20 20 20 20 20 20 74 65 73 74 2d 6e  )).       test-n
31a0: 61 6d 65 73 29 0a 20 20 20 20 20 20 3b 3b 20 28  ames).      ;; (
31b0: 72 75 6e 2d 77 61 69 74 69 6e 67 2d 74 65 73 74  run-waiting-test
31c0: 73 20 64 62 29 0a 20 20 20 20 20 20 28 69 66 20  s db).      (if 
31d0: 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d  (args:get-arg "-
31e0: 6b 65 65 70 67 6f 69 6e 67 22 29 0a 09 20 20 28  keepgoing")..  (
31f0: 6c 65 74 20 28 28 65 73 74 72 65 6d 20 28 64 62  let ((estrem (db
3200: 3a 65 73 74 69 6d 61 74 65 64 2d 74 65 73 74 73  :estimated-tests
3210: 2d 72 65 6d 61 69 6e 69 6e 67 20 64 62 20 72 75  -remaining db ru
3220: 6e 2d 69 64 29 29 29 0a 09 20 20 20 20 28 69 66  n-id)))..    (if
3230: 20 28 61 6e 64 20 28 3e 20 65 73 74 72 65 6d 20   (and (> estrem 
3240: 30 29 0a 09 09 20 20 20 20 20 28 65 71 3f 20 2a  0)...     (eq? *
3250: 67 6c 6f 62 61 6c 65 78 69 74 73 74 61 74 75 73  globalexitstatus
3260: 2a 20 30 29 29 0a 09 09 28 62 65 67 69 6e 0a 09  * 0))...(begin..
3270: 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20  .  (debug:print 
3280: 31 20 22 4b 65 65 70 20 67 6f 69 6e 67 2c 20 65  1 "Keep going, e
3290: 73 74 69 6d 61 74 65 64 20 22 20 65 73 74 72 65  stimated " estre
32a0: 6d 20 22 20 74 65 73 74 73 20 72 65 6d 61 69 6e  m " tests remain
32b0: 69 6e 67 20 74 6f 20 72 75 6e 2c 20 77 69 6c 6c  ing to run, will
32c0: 20 63 6f 6e 74 69 6e 75 65 20 69 6e 20 33 20 73   continue in 3 s
32d0: 65 63 6f 6e 64 73 20 2e 2e 2e 22 29 0a 09 09 20  econds ...")... 
32e0: 20 28 73 6c 65 65 70 20 33 29 0a 09 09 20 20 28   (sleep 3)...  (
32f0: 72 75 6e 2d 77 61 69 74 69 6e 67 2d 74 65 73 74  run-waiting-test
3300: 73 20 64 62 29 0a 09 09 20 20 28 6c 6f 6f 70 20  s db)...  (loop 
3310: 28 2b 20 6e 75 6d 74 69 6d 65 73 20 31 29 29 29  (+ numtimes 1)))
3320: 29 29 29 29 29 29 0a 09 20 20 20 0a 3b 3b 20 56  ))))))..   .;; V
3330: 45 52 59 20 49 4e 45 46 46 49 43 49 45 4e 54 21  ERY INEFFICIENT!
3340: 20 4d 6f 76 65 20 73 74 75 66 66 20 74 68 61 74   Move stuff that
3350: 20 73 68 6f 75 6c 64 20 62 65 20 64 6f 6e 65 20   should be done 
3360: 6f 6e 63 65 20 75 70 20 74 6f 20 63 61 6c 6c 69  once up to calli
3370: 6e 67 20 70 72 6f 63 0a 28 64 65 66 69 6e 65 20  ng proc.(define 
3380: 28 72 75 6e 2d 6f 6e 65 2d 74 65 73 74 20 64 62  (run-one-test db
3390: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
33a0: 65 20 6b 65 79 76 61 6c 6c 73 74 29 0a 20 20 28  e keyvallst).  (
33b0: 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 4c  debug:print 1 "L
33c0: 61 75 6e 63 68 69 6e 67 20 74 65 73 74 20 22 20  aunching test " 
33d0: 74 65 73 74 2d 6e 61 6d 65 29 0a 20 20 3b 3b 20  test-name).  ;; 
33e0: 41 6c 6c 20 74 68 65 73 65 20 76 61 72 73 20 6d  All these vars m
33f0: 69 67 68 74 20 62 65 20 72 65 66 65 72 65 6e 63  ight be referenc
3400: 65 64 20 62 79 20 74 68 65 20 74 65 73 74 63 6f  ed by the testco
3410: 6e 66 69 67 20 66 69 6c 65 20 72 65 61 64 65 72  nfig file reader
3420: 0a 20 20 28 73 65 74 65 6e 76 20 22 4d 54 5f 54  .  (setenv "MT_T
3430: 45 53 54 5f 4e 41 4d 45 22 20 74 65 73 74 2d 6e  EST_NAME" test-n
3440: 61 6d 65 29 20 3b 3b 20 0a 20 20 28 73 65 74 65  ame) ;; .  (sete
3450: 6e 76 20 22 4d 54 5f 52 55 4e 4e 41 4d 45 22 20  nv "MT_RUNNAME" 
3460: 20 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20    (args:get-arg 
3470: 22 3a 72 75 6e 6e 61 6d 65 22 29 29 0a 20 20 28  ":runname")).  (
3480: 73 65 74 2d 6d 65 67 61 74 65 73 74 2d 65 6e 76  set-megatest-env
3490: 2d 76 61 72 73 20 64 62 20 72 75 6e 2d 69 64 29  -vars db run-id)
34a0: 20 3b 3b 20 74 68 65 73 65 20 6d 61 79 20 62 65   ;; these may be
34b0: 20 6e 65 65 64 65 64 20 62 79 20 74 68 65 20 6c   needed by the l
34c0: 61 75 6e 63 68 69 6e 67 20 70 72 6f 63 65 73 73  aunching process
34d0: 0a 20 20 28 63 68 61 6e 67 65 2d 64 69 72 65 63  .  (change-direc
34e0: 74 6f 72 79 20 2a 74 6f 70 70 61 74 68 2a 29 0a  tory *toppath*).
34f0: 20 20 28 6c 65 74 2a 20 28 28 74 65 73 74 2d 70    (let* ((test-p
3500: 61 74 68 20 20 20 20 28 63 6f 6e 63 20 2a 74 6f  ath    (conc *to
3510: 70 70 61 74 68 2a 20 22 2f 74 65 73 74 73 2f 22  ppath* "/tests/"
3520: 20 74 65 73 74 2d 6e 61 6d 65 29 29 0a 09 20 28   test-name)).. (
3530: 74 65 73 74 2d 63 6f 6e 66 69 67 66 20 28 63 6f  test-configf (co
3540: 6e 63 20 74 65 73 74 2d 70 61 74 68 20 22 2f 74  nc test-path "/t
3550: 65 73 74 63 6f 6e 66 69 67 22 29 29 0a 09 20 28  estconfig")).. (
3560: 74 65 73 74 65 78 69 73 74 73 20 20 20 28 61 6e  testexists   (an
3570: 64 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20  d (file-exists? 
3580: 74 65 73 74 2d 63 6f 6e 66 69 67 66 29 28 66 69  test-configf)(fi
3590: 6c 65 2d 72 65 61 64 2d 61 63 63 65 73 73 3f 20  le-read-access? 
35a0: 74 65 73 74 2d 63 6f 6e 66 69 67 66 29 29 29 0a  test-configf))).
35b0: 09 20 28 74 65 73 74 2d 63 6f 6e 66 20 20 20 20  . (test-conf    
35c0: 28 69 66 20 74 65 73 74 65 78 69 73 74 73 20 28  (if testexists (
35d0: 72 65 61 64 2d 63 6f 6e 66 69 67 20 74 65 73 74  read-config test
35e0: 2d 63 6f 6e 66 69 67 66 29 20 28 6d 61 6b 65 2d  -configf) (make-
35f0: 68 61 73 68 2d 74 61 62 6c 65 29 29 29 0a 09 20  hash-table))).. 
3600: 28 77 61 69 74 6f 6e 20 20 20 20 20 20 20 28 6c  (waiton       (l
3610: 65 74 20 28 28 77 20 28 63 6f 6e 66 69 67 2d 6c  et ((w (config-l
3620: 6f 6f 6b 75 70 20 74 65 73 74 2d 63 6f 6e 66 20  ookup test-conf 
3630: 22 72 65 71 75 69 72 65 6d 65 6e 74 73 22 20 22  "requirements" "
3640: 77 61 69 74 6f 6e 22 29 29 29 0a 09 09 09 20 28  waiton"))).... (
3650: 69 66 20 28 73 74 72 69 6e 67 3f 20 77 29 28 73  if (string? w)(s
3660: 74 72 69 6e 67 2d 73 70 6c 69 74 20 77 29 27 28  tring-split w)'(
3670: 29 29 29 29 29 0a 20 20 20 20 28 69 66 20 28 6e  ))))).    (if (n
3680: 6f 74 20 74 65 73 74 65 78 69 73 74 73 29 0a 09  ot testexists)..
3690: 28 62 65 67 69 6e 0a 09 20 20 28 64 65 62 75 67  (begin..  (debug
36a0: 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a  :print 0 "ERROR:
36b0: 20 43 61 6e 27 74 20 66 69 6e 64 20 63 6f 6e 66   Can't find conf
36c0: 69 67 20 66 69 6c 65 20 22 20 74 65 73 74 2d 63  ig file " test-c
36d0: 6f 6e 66 69 67 66 29 0a 09 20 20 28 65 78 69 74  onfigf)..  (exit
36e0: 20 32 29 29 0a 09 3b 3b 20 70 75 74 20 74 6f 70   2))..;; put top
36f0: 20 76 61 72 73 20 69 6e 74 6f 20 63 6f 6e 76 65   vars into conve
3700: 6e 69 65 6e 74 20 76 61 72 69 61 62 6c 65 73 20  nient variables 
3710: 61 6e 64 20 6f 70 65 6e 20 74 68 65 20 64 62 0a  and open the db.
3720: 09 28 6c 65 74 2a 20 28 3b 3b 20 64 62 20 69 73  .(let* (;; db is
3730: 20 61 6c 77 61 79 73 20 61 74 20 2a 74 6f 70 70   always at *topp
3740: 61 74 68 2a 2f 64 62 2f 6d 65 67 61 74 65 73 74  ath*/db/megatest
3750: 2e 64 62 0a 09 20 20 20 20 20 20 20 28 69 74 65  .db..       (ite
3760: 6d 73 20 20 20 20 20 20 20 28 68 61 73 68 2d 74  ms       (hash-t
3770: 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74  able-ref/default
3780: 20 74 65 73 74 2d 63 6f 6e 66 20 22 69 74 65 6d   test-conf "item
3790: 73 22 20 27 28 29 29 29 0a 09 20 20 20 20 20 20  s" '()))..      
37a0: 20 28 69 74 65 6d 73 74 61 62 6c 65 20 20 28 68   (itemstable  (h
37b0: 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65  ash-table-ref/de
37c0: 66 61 75 6c 74 20 74 65 73 74 2d 63 6f 6e 66 20  fault test-conf 
37d0: 22 69 74 65 6d 73 74 61 62 6c 65 22 20 27 28 29  "itemstable" '()
37e0: 29 29 0a 09 20 20 20 20 20 20 20 28 61 6c 6c 69  ))..       (alli
37f0: 74 65 6d 73 20 20 20 20 28 69 66 20 28 6f 72 20  tems    (if (or 
3800: 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 69 74 65 6d  (not (null? item
3810: 73 29 29 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 69  s))(not (null? i
3820: 74 65 6d 73 74 61 62 6c 65 29 29 29 0a 09 09 09  temstable)))....
3830: 09 28 61 70 70 65 6e 64 20 28 69 74 65 6d 2d 61  .(append (item-a
3840: 73 73 6f 63 2d 3e 69 74 65 6d 2d 6c 69 73 74 20  ssoc->item-list 
3850: 69 74 65 6d 73 29 0a 09 09 09 09 09 28 69 74 65  items)......(ite
3860: 6d 2d 74 61 62 6c 65 2d 3e 69 74 65 6d 2d 6c 69  m-table->item-li
3870: 73 74 20 69 74 65 6d 73 74 61 62 6c 65 29 29 0a  st itemstable)).
3880: 09 09 09 09 27 28 28 29 29 29 29 20 3b 3b 20 61  ....'(()))) ;; a
3890: 20 6c 69 73 74 20 77 69 74 68 20 6f 6e 65 20 6e   list with one n
38a0: 75 6c 6c 20 6c 69 73 74 20 69 73 20 61 20 74 65  ull list is a te
38b0: 73 74 20 77 69 74 68 20 6e 6f 20 69 74 65 6d 73  st with no items
38c0: 0a 09 20 20 20 20 20 20 20 28 72 75 6e 63 6f 6e  ..       (runcon
38d0: 66 69 67 66 20 20 28 63 6f 6e 63 20 20 2a 74 6f  figf  (conc  *to
38e0: 70 70 61 74 68 2a 20 22 2f 72 75 6e 63 6f 6e 66  ppath* "/runconf
38f0: 69 67 73 2e 63 6f 6e 66 69 67 22 29 29 29 0a 09  igs.config")))..
3900: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31    (debug:print 1
3910: 20 22 69 74 65 6d 73 3a 20 22 29 0a 09 20 20 28   "items: ")..  (
3920: 69 66 20 28 3e 3d 20 2a 76 65 72 62 6f 73 69 74  if (>= *verbosit
3930: 79 2a 20 31 29 28 70 70 20 61 6c 6c 69 74 65 6d  y* 1)(pp allitem
3940: 73 29 29 0a 09 20 20 28 69 66 20 28 3e 3d 20 2a  s))..  (if (>= *
3950: 76 65 72 62 6f 73 69 74 79 2a 20 35 29 0a 09 20  verbosity* 5).. 
3960: 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09 28 70       (begin...(p
3970: 72 69 6e 74 20 22 69 74 65 6d 73 3a 20 22 29 28  rint "items: ")(
3980: 70 70 20 28 69 74 65 6d 2d 61 73 73 6f 63 2d 3e  pp (item-assoc->
3990: 69 74 65 6d 2d 6c 69 73 74 20 69 74 65 6d 73 29  item-list items)
39a0: 29 0a 09 09 28 70 72 69 6e 74 20 22 69 74 65 73  )...(print "ites
39b0: 74 61 62 6c 65 3a 20 22 29 28 70 70 20 28 69 74  table: ")(pp (it
39c0: 65 6d 2d 74 61 62 6c 65 2d 3e 69 74 65 6d 2d 6c  em-table->item-l
39d0: 69 73 74 20 69 74 65 6d 73 74 61 62 6c 65 29 29  ist itemstable))
39e0: 29 29 0a 09 20 20 28 69 66 20 28 61 72 67 73 3a  ))..  (if (args:
39f0: 67 65 74 2d 61 72 67 20 22 2d 6d 22 29 0a 09 20  get-arg "-m").. 
3a00: 20 20 20 20 20 28 64 62 3a 73 65 74 2d 63 6f 6d       (db:set-com
3a10: 6d 65 6e 74 2d 66 6f 72 2d 72 75 6e 20 64 62 20  ment-for-run db 
3a20: 72 75 6e 2d 69 64 20 28 61 72 67 73 3a 67 65 74  run-id (args:get
3a30: 2d 61 72 67 20 22 2d 6d 22 29 29 29 0a 09 20 20  -arg "-m")))..  
3a40: 3b 3b 20 62 72 61 69 6e 64 65 61 64 20 77 6f 72  ;; braindead wor
3a50: 6b 2d 61 72 6f 75 6e 64 20 66 6f 72 20 70 6f 6f  k-around for poo
3a60: 72 6c 79 20 73 70 65 63 69 66 69 65 64 20 61 6c  rly specified al
3a70: 6c 69 74 65 6d 73 20 6c 69 73 74 20 42 55 47 21  litems list BUG!
3a80: 21 21 20 46 49 58 4d 45 0a 09 20 20 28 69 66 20  !! FIXME..  (if 
3a90: 28 6e 75 6c 6c 3f 20 61 6c 6c 69 74 65 6d 73 29  (null? allitems)
3aa0: 28 73 65 74 21 20 61 6c 6c 69 74 65 6d 73 20 27  (set! allitems '
3ab0: 28 28 29 29 29 29 0a 09 20 20 28 6c 65 74 20 6c  (())))..  (let l
3ac0: 6f 6f 70 20 28 28 69 74 65 6d 64 61 74 20 28 63  oop ((itemdat (c
3ad0: 61 72 20 61 6c 6c 69 74 65 6d 73 29 29 0a 09 09  ar allitems))...
3ae0: 20 20 20 20 20 28 74 61 6c 20 20 20 20 20 28 63       (tal     (c
3af0: 64 72 20 61 6c 6c 69 74 65 6d 73 29 29 29 0a 09  dr allitems)))..
3b00: 20 20 20 20 3b 3b 20 28 6c 61 6d 62 64 61 20 28      ;; (lambda (
3b10: 69 74 65 6d 64 61 74 29 20 3b 3b 3b 20 28 28 72  itemdat) ;;; ((r
3b20: 69 70 65 6e 65 73 73 20 22 6f 76 65 72 72 69 70  ipeness "overrip
3b30: 65 22 29 20 28 74 65 6d 70 65 72 61 74 75 72 65  e") (temperature
3b40: 20 22 63 6f 6f 6c 22 29 20 28 73 65 61 73 6f 6e   "cool") (season
3b50: 20 22 73 75 6d 6d 65 72 22 29 29 0a 09 20 20 20   "summer"))..   
3b60: 20 3b 3b 20 48 61 6e 64 6c 65 20 6c 69 73 74 73   ;; Handle lists
3b70: 20 6f 66 20 69 74 65 6d 73 0a 09 20 20 20 20 28   of items..    (
3b80: 6c 65 74 2a 20 28 28 69 74 65 6d 2d 70 61 74 68  let* ((item-path
3b90: 20 20 20 20 20 28 69 74 65 6d 2d 6c 69 73 74 2d       (item-list-
3ba0: 3e 70 61 74 68 20 69 74 65 6d 64 61 74 29 29 20  >path itemdat)) 
3bb0: 3b 3b 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72  ;; (string-inter
3bc0: 73 70 65 72 73 65 20 28 6d 61 70 20 63 61 64 72  sperse (map cadr
3bd0: 20 69 74 65 6d 64 61 74 29 20 22 2f 22 29 29 0a   itemdat) "/")).
3be0: 09 09 20 20 20 28 6e 65 77 2d 74 65 73 74 2d 70  ..   (new-test-p
3bf0: 61 74 68 20 28 73 74 72 69 6e 67 2d 69 6e 74 65  ath (string-inte
3c00: 72 73 70 65 72 73 65 20 28 63 6f 6e 73 20 74 65  rsperse (cons te
3c10: 73 74 2d 70 61 74 68 20 28 6d 61 70 20 63 61 64  st-path (map cad
3c20: 72 20 69 74 65 6d 64 61 74 29 29 20 22 2f 22 29  r itemdat)) "/")
3c30: 29 0a 09 09 20 20 20 28 6e 65 77 2d 74 65 73 74  )...   (new-test
3c40: 2d 6e 61 6d 65 20 28 69 66 20 28 65 71 75 61 6c  -name (if (equal
3c50: 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29 20  ? item-path "") 
3c60: 74 65 73 74 2d 6e 61 6d 65 20 28 63 6f 6e 63 20  test-name (conc 
3c70: 74 65 73 74 2d 6e 61 6d 65 20 22 2f 22 20 69 74  test-name "/" it
3c80: 65 6d 2d 70 61 74 68 29 29 29 20 3b 3b 20 6a 75  em-path))) ;; ju
3c90: 73 74 20 6e 65 65 64 20 69 74 20 74 6f 20 62 65  st need it to be
3ca0: 20 75 6e 69 71 75 65 0a 09 09 20 20 20 28 74 65   unique...   (te
3cb0: 73 74 64 61 74 20 20 20 23 66 29 0a 09 09 20 20  stdat   #f)...  
3cc0: 20 28 6e 75 6d 2d 72 75 6e 6e 69 6e 67 20 28 64   (num-running (d
3cd0: 62 3a 67 65 74 2d 63 6f 75 6e 74 2d 74 65 73 74  b:get-count-test
3ce0: 73 2d 72 75 6e 6e 69 6e 67 20 64 62 29 29 0a 09  s-running db))..
3cf0: 09 20 20 20 28 6d 61 78 2d 63 6f 6e 63 75 72 72  .   (max-concurr
3d00: 65 6e 74 2d 6a 6f 62 73 20 28 63 6f 6e 66 69 67  ent-jobs (config
3d10: 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67 64  -lookup *configd
3d20: 61 74 2a 20 22 73 65 74 75 70 22 20 22 6d 61 78  at* "setup" "max
3d30: 5f 63 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f 62 73  _concurrent_jobs
3d40: 22 29 29 0a 09 09 20 20 20 28 70 61 72 65 6e 74  "))...   (parent
3d50: 2d 74 65 73 74 20 28 61 6e 64 20 28 6e 6f 74 20  -test (and (not 
3d60: 28 6e 75 6c 6c 3f 20 69 74 65 6d 73 29 29 28 65  (null? items))(e
3d70: 71 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20  qual? item-path 
3d80: 22 22 29 29 29 0a 09 09 20 20 20 28 73 69 6e 67  "")))...   (sing
3d90: 6c 65 2d 74 65 73 74 20 28 61 6e 64 20 28 6e 75  le-test (and (nu
3da0: 6c 6c 3f 20 69 74 65 6d 73 29 20 28 65 71 75 61  ll? items) (equa
3db0: 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29  l? item-path "")
3dc0: 29 29 0a 09 09 20 20 20 28 69 74 65 6d 2d 74 65  ))...   (item-te
3dd0: 73 74 20 20 20 28 6e 6f 74 20 28 65 71 75 61 6c  st   (not (equal
3de0: 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29 29  ? item-path ""))
3df0: 29 29 0a 09 20 20 20 20 20 20 28 64 65 62 75 67  ))..      (debug
3e00: 3a 70 72 69 6e 74 20 33 20 22 6d 61 78 2d 63 6f  :print 3 "max-co
3e10: 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 3a 20 22  ncurrent-jobs: "
3e20: 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d   max-concurrent-
3e30: 6a 6f 62 73 20 22 2c 20 6e 75 6d 2d 72 75 6e 6e  jobs ", num-runn
3e40: 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69  ing: " num-runni
3e50: 6e 67 29 0a 09 20 20 20 20 20 20 28 69 66 20 28  ng)..      (if (
3e60: 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72  runs:can-run-mor
3e70: 65 2d 74 65 73 74 73 20 64 62 29 0a 09 09 20 20  e-tests db)...  
3e80: 28 62 65 67 69 6e 0a 09 09 20 20 20 20 28 6c 65  (begin...    (le
3e90: 74 20 6c 6f 6f 70 32 20 28 28 74 73 20 28 64 62  t loop2 ((ts (db
3ea0: 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64  :get-test-info d
3eb0: 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  b run-id test-na
3ec0: 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29 20 3b  me item-path)) ;
3ed0: 3b 20 23 66 29 0a 09 09 09 09 28 63 74 20 30 29  ; #f).....(ct 0)
3ee0: 29 0a 09 09 20 20 20 20 20 20 28 69 66 20 28 61  )...      (if (a
3ef0: 6e 64 20 28 6e 6f 74 20 74 73 29 0a 09 09 09 20  nd (not ts).... 
3f00: 20 20 20 20 20 20 28 3c 20 63 74 20 31 30 29 29        (< ct 10))
3f10: 0a 09 09 09 20 20 28 62 65 67 69 6e 0a 09 09 09  ....  (begin....
3f20: 20 20 20 20 28 72 65 67 69 73 74 65 72 2d 74 65      (register-te
3f30: 73 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  st db run-id tes
3f40: 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68  t-name item-path
3f50: 29 0a 09 09 09 20 20 20 20 28 64 62 3a 74 65 73  )....    (db:tes
3f60: 74 2d 73 65 74 2d 63 6f 6d 6d 65 6e 74 20 64 62  t-set-comment db
3f70: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
3f80: 65 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29 0a  e item-path "").
3f90: 09 09 09 20 20 20 20 28 6c 6f 6f 70 32 20 28 64  ...    (loop2 (d
3fa0: 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20  b:get-test-info 
3fb0: 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e  db run-id test-n
3fc0: 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 0a 09  ame item-path)..
3fd0: 09 09 09 20 20 20 28 2b 20 63 74 20 31 29 29 29  ...   (+ ct 1)))
3fe0: 0a 09 09 09 20 20 28 69 66 20 74 73 0a 09 09 09  ....  (if ts....
3ff0: 20 20 20 20 20 20 28 73 65 74 21 20 74 65 73 74        (set! test
4000: 64 61 74 20 74 73 29 0a 09 09 09 20 20 20 20 20  dat ts)....     
4010: 20 28 62 65 67 69 6e 0a 09 09 09 09 28 64 65 62   (begin.....(deb
4020: 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e  ug:print 0 "WARN
4030: 49 4e 47 3a 20 43 6f 75 6c 64 6e 27 74 20 72 65  ING: Couldn't re
4040: 67 69 73 74 65 72 20 74 65 73 74 20 22 20 74 65  gister test " te
4050: 73 74 2d 6e 61 6d 65 20 22 20 77 69 74 68 20 69  st-name " with i
4060: 74 65 6d 20 70 61 74 68 20 22 20 69 74 65 6d 2d  tem path " item-
4070: 70 61 74 68 20 22 2c 20 73 6b 69 70 70 69 6e 67  path ", skipping
4080: 22 29 0a 09 09 09 09 28 69 66 20 28 6e 6f 74 20  ").....(if (not 
4090: 28 6e 75 6c 6c 3f 20 74 61 6c 29 29 0a 09 09 09  (null? tal))....
40a0: 09 20 20 20 20 28 6c 6f 6f 70 20 28 63 61 72 20  .    (loop (car 
40b0: 74 61 6c 29 28 63 64 72 20 74 61 6c 29 29 29 29  tal)(cdr tal))))
40c0: 29 29 29 0a 09 09 20 20 20 20 28 63 68 61 6e 67  )))...    (chang
40d0: 65 2d 64 69 72 65 63 74 6f 72 79 20 74 65 73 74  e-directory test
40e0: 2d 70 61 74 68 29 0a 09 09 20 20 20 20 3b 3b 20  -path)...    ;; 
40f0: 74 68 69 73 20 62 6c 6f 63 6b 20 69 73 20 68 65  this block is he
4100: 72 65 20 6f 6e 6c 79 20 74 6f 20 69 6e 66 6f 72  re only to infor
4110: 6d 20 74 68 65 20 75 73 65 72 20 65 61 72 6c 79  m the user early
4120: 20 6f 6e 0a 09 09 20 20 20 20 28 69 66 20 28 66   on...    (if (f
4130: 69 6c 65 2d 65 78 69 73 74 73 3f 20 72 75 6e 63  ile-exists? runc
4140: 6f 6e 66 69 67 66 29 0a 09 09 09 28 73 65 74 75  onfigf)....(setu
4150: 70 2d 65 6e 76 2d 64 65 66 61 75 6c 74 73 20 64  p-env-defaults d
4160: 62 20 72 75 6e 63 6f 6e 66 69 67 66 20 72 75 6e  b runconfigf run
4170: 2d 69 64 20 2a 61 6c 72 65 61 64 79 2d 73 65 65  -id *already-see
4180: 6e 2d 72 75 6e 63 6f 6e 66 69 67 2d 69 6e 66 6f  n-runconfig-info
4190: 2a 29 0a 09 09 09 28 64 65 62 75 67 3a 70 72 69  *)....(debug:pri
41a0: 6e 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 59  nt 0 "WARNING: Y
41b0: 6f 75 20 64 6f 20 6e 6f 74 20 68 61 76 65 20 61  ou do not have a
41c0: 20 72 75 6e 20 63 6f 6e 66 69 67 20 66 69 6c 65   run config file
41d0: 3a 20 22 20 72 75 6e 63 6f 6e 66 69 67 66 29 29  : " runconfigf))
41e0: 0a 09 09 20 20 20 20 28 64 65 62 75 67 3a 70 72  ...    (debug:pr
41f0: 69 6e 74 20 34 20 22 72 75 6e 2d 69 64 3a 20 22  int 4 "run-id: "
4200: 20 72 75 6e 2d 69 64 20 22 20 74 65 73 74 2d 6e   run-id " test-n
4210: 61 6d 65 3a 20 22 20 74 65 73 74 2d 6e 61 6d 65  ame: " test-name
4220: 20 22 20 69 74 65 6d 2d 70 61 74 68 3a 20 22 20   " item-path: " 
4230: 69 74 65 6d 2d 70 61 74 68 20 22 20 74 65 73 74  item-path " test
4240: 64 61 74 3a 20 22 20 28 74 65 73 74 3a 67 65 74  dat: " (test:get
4250: 2d 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29  -status testdat)
4260: 20 22 20 74 65 73 74 2d 73 74 61 74 65 3a 20 22   " test-state: "
4270: 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65   (test:get-state
4280: 20 74 65 73 74 64 61 74 29 29 0a 09 09 20 20 20   testdat))...   
4290: 20 28 63 61 73 65 20 28 69 66 20 28 61 72 67 73   (case (if (args
42a0: 3a 67 65 74 2d 61 72 67 20 22 2d 66 6f 72 63 65  :get-arg "-force
42b0: 22 29 0a 09 09 09 20 20 20 20 20 20 27 4e 4f 54  ")....      'NOT
42c0: 5f 53 54 41 52 54 45 44 0a 09 09 09 20 20 20 20  _STARTED....    
42d0: 20 20 28 69 66 20 74 65 73 74 64 61 74 0a 09 09    (if testdat...
42e0: 09 09 20 20 28 73 74 72 69 6e 67 2d 3e 73 79 6d  ..  (string->sym
42f0: 62 6f 6c 20 28 74 65 73 74 3a 67 65 74 2d 73 74  bol (test:get-st
4300: 61 74 65 20 74 65 73 74 64 61 74 29 29 0a 09 09  ate testdat))...
4310: 09 09 20 20 27 66 61 69 6c 65 64 2d 74 6f 2d 69  ..  'failed-to-i
4320: 6e 73 65 72 74 29 29 0a 09 09 20 20 20 20 20 20  nsert))...      
4330: 28 28 66 61 69 6c 65 64 2d 74 6f 2d 69 6e 73 65  ((failed-to-inse
4340: 72 74 29 0a 09 09 20 20 20 20 20 20 20 28 64 65  rt)...       (de
4350: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52  bug:print 0 "ERR
4360: 4f 52 3a 20 46 61 69 6c 65 64 20 74 6f 20 69 6e  OR: Failed to in
4370: 73 65 72 74 20 74 68 65 20 72 65 63 6f 72 64 20  sert the record 
4380: 69 6e 74 6f 20 74 68 65 20 64 62 22 29 29 0a 09  into the db"))..
4390: 09 20 20 20 20 20 20 28 28 4e 4f 54 5f 53 54 41  .      ((NOT_STA
43a0: 52 54 45 44 20 43 4f 4d 50 4c 45 54 45 44 29 0a  RTED COMPLETED).
43b0: 09 09 20 20 20 20 20 20 20 28 64 65 62 75 67 3a  ..       (debug:
43c0: 70 72 69 6e 74 20 36 20 22 47 6f 74 20 68 65 72  print 6 "Got her
43d0: 65 2c 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73  e, " (test:get-s
43e0: 74 61 74 65 20 74 65 73 74 64 61 74 29 29 0a 09  tate testdat))..
43f0: 09 20 20 20 20 20 20 20 28 6c 65 74 20 28 28 72  .       (let ((r
4400: 75 6e 66 6c 61 67 20 23 66 29 29 0a 09 09 09 20  unflag #f)).... 
4410: 28 63 6f 6e 64 0a 09 09 09 20 20 3b 3b 20 69 2e  (cond....  ;; i.
4420: 65 2e 20 74 68 69 73 20 69 73 20 74 68 65 20 70  e. this is the p
4430: 61 72 65 6e 74 20 74 65 73 74 20 74 6f 20 61 20  arent test to a 
4440: 73 75 69 74 65 20 6f 66 20 69 74 65 6d 73 2c 20  suite of items, 
4450: 6e 65 76 65 72 20 22 72 75 6e 22 20 69 74 0a 09  never "run" it..
4460: 09 09 20 20 28 70 61 72 65 6e 74 2d 74 65 73 74  ..  (parent-test
4470: 0a 09 09 09 20 20 20 28 73 65 74 21 20 72 75 6e  ....   (set! run
4480: 66 6c 61 67 20 23 66 29 29 0a 09 09 09 20 20 3b  flag #f))....  ;
4490: 3b 20 2d 66 6f 72 63 65 2c 20 72 75 6e 20 6e 6f  ; -force, run no
44a0: 20 6d 61 74 74 65 72 20 77 68 61 74 0a 09 09 09   matter what....
44b0: 20 20 28 28 61 72 67 73 3a 67 65 74 2d 61 72 67    ((args:get-arg
44c0: 20 22 2d 66 6f 72 63 65 22 29 28 73 65 74 21 20   "-force")(set! 
44d0: 72 75 6e 66 6c 61 67 20 23 74 29 29 0a 09 09 09  runflag #t))....
44e0: 20 20 3b 3b 20 4e 4f 54 5f 53 54 41 52 54 45 44    ;; NOT_STARTED
44f0: 2c 20 72 75 6e 20 6e 6f 20 6d 61 74 74 65 72 20  , run no matter 
4500: 77 68 61 74 0a 09 09 09 20 20 28 28 65 71 75 61  what....  ((equa
4510: 6c 3f 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61  l? (test:get-sta
4520: 74 65 20 74 65 73 74 64 61 74 29 20 22 4e 4f 54  te testdat) "NOT
4530: 5f 53 54 41 52 54 45 44 22 29 28 73 65 74 21 20  _STARTED")(set! 
4540: 72 75 6e 66 6c 61 67 20 23 74 29 29 0a 09 09 09  runflag #t))....
4550: 20 20 3b 3b 20 6e 6f 74 20 2d 72 65 72 75 6e 20    ;; not -rerun 
4560: 61 6e 64 20 50 41 53 53 2c 20 57 41 52 4e 20 6f  and PASS, WARN o
4570: 72 20 43 48 45 43 4b 2c 20 64 6f 20 6e 6f 20 72  r CHECK, do no r
4580: 75 6e 0a 09 09 09 20 20 28 28 61 6e 64 20 28 6f  un....  ((and (o
4590: 72 20 28 6e 6f 74 20 28 61 72 67 73 3a 67 65 74  r (not (args:get
45a0: 2d 61 72 67 20 22 2d 72 65 72 75 6e 22 29 29 0a  -arg "-rerun")).
45b0: 09 09 09 09 20 20 20 20 28 61 72 67 73 3a 67 65  ....    (args:ge
45c0: 74 2d 61 72 67 20 22 2d 6b 65 65 70 67 6f 69 6e  t-arg "-keepgoin
45d0: 67 22 29 29 0a 09 09 09 09 28 6d 65 6d 62 65 72  g")).....(member
45e0: 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75   (test:get-statu
45f0: 73 20 74 65 73 74 64 61 74 29 20 27 28 22 50 41  s testdat) '("PA
4600: 53 53 22 20 22 57 41 52 4e 22 20 22 43 48 45 43  SS" "WARN" "CHEC
4610: 4b 22 29 29 29 0a 09 09 09 20 20 20 28 73 65 74  K")))....   (set
4620: 21 20 72 75 6e 66 6c 61 67 20 23 66 29 29 0a 09  ! runflag #f))..
4630: 09 09 20 20 3b 3b 20 2d 72 65 72 75 6e 20 61 6e  ..  ;; -rerun an
4640: 64 20 73 74 61 74 75 73 20 69 73 20 6f 6e 65 20  d status is one 
4650: 6f 66 20 74 68 65 20 73 70 65 63 69 66 65 64 2c  of the specifed,
4660: 20 72 75 6e 20 69 74 0a 09 09 09 20 20 28 28 61   run it....  ((a
4670: 6e 64 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67  nd (args:get-arg
4680: 20 22 2d 72 65 72 75 6e 22 29 0a 09 09 09 09 28   "-rerun").....(
4690: 6c 65 74 20 28 28 72 65 72 75 6e 6c 73 74 20 28  let ((rerunlst (
46a0: 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 28 61 72  string-split (ar
46b0: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65 72  gs:get-arg "-rer
46c0: 75 6e 22 29 20 22 2c 22 29 29 29 20 3b 3b 20 46  un") ","))) ;; F
46d0: 41 49 4c 2c 0a 09 09 09 09 20 20 28 6d 65 6d 62  AIL,.....  (memb
46e0: 65 72 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61  er (test:get-sta
46f0: 74 75 73 20 74 65 73 74 64 61 74 29 20 72 65 72  tus testdat) rer
4700: 75 6e 6c 73 74 29 29 29 0a 09 09 09 20 20 20 28  unlst)))....   (
4710: 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 74 29  set! runflag #t)
4720: 29 0a 09 09 09 20 20 3b 3b 20 2d 6b 65 65 70 67  )....  ;; -keepg
4730: 6f 69 6e 67 2c 20 64 6f 20 6e 6f 74 20 72 65 72  oing, do not rer
4740: 75 6e 20 46 41 49 4c 0a 09 09 09 20 20 28 28 61  un FAIL....  ((a
4750: 6e 64 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67  nd (args:get-arg
4760: 20 22 2d 6b 65 65 70 67 6f 69 6e 67 22 29 0a 09   "-keepgoing")..
4770: 09 09 09 28 6d 65 6d 62 65 72 20 28 74 65 73 74  ...(member (test
4780: 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74  :get-status test
4790: 64 61 74 29 20 27 28 22 46 41 49 4c 22 29 29 29  dat) '("FAIL")))
47a0: 0a 09 09 09 20 20 20 28 73 65 74 21 20 72 75 6e  ....   (set! run
47b0: 66 6c 61 67 20 23 66 29 29 0a 09 09 09 20 20 28  flag #f))....  (
47c0: 28 61 6e 64 20 28 6e 6f 74 20 28 61 72 67 73 3a  (and (not (args:
47d0: 67 65 74 2d 61 72 67 20 22 2d 72 65 72 75 6e 22  get-arg "-rerun"
47e0: 29 29 0a 09 09 09 09 28 6d 65 6d 62 65 72 20 28  )).....(member (
47f0: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20  test:get-status 
4800: 74 65 73 74 64 61 74 29 20 27 28 22 46 41 49 4c  testdat) '("FAIL
4810: 22 20 22 6e 2f 61 22 29 29 29 0a 09 09 09 20 20  " "n/a")))....  
4820: 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23   (set! runflag #
4830: 74 29 29 0a 09 09 09 20 20 28 65 6c 73 65 20 28  t))....  (else (
4840: 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 66 29  set! runflag #f)
4850: 29 29 0a 09 09 09 20 28 64 65 62 75 67 3a 70 72  )).... (debug:pr
4860: 69 6e 74 20 36 20 22 52 55 4e 4e 49 4e 47 20 3d  int 6 "RUNNING =
4870: 3e 20 72 75 6e 66 6c 61 67 3a 20 22 20 72 75 6e  > runflag: " run
4880: 66 6c 61 67 20 22 20 53 54 41 54 45 3a 20 22 20  flag " STATE: " 
4890: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20  (test:get-state 
48a0: 74 65 73 74 64 61 74 29 20 22 20 53 54 41 54 55  testdat) " STATU
48b0: 53 3a 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73  S: " (test:get-s
48c0: 74 61 74 75 73 20 74 65 73 74 64 61 74 29 29 0a  tatus testdat)).
48d0: 09 09 09 20 28 69 66 20 28 6e 6f 74 20 72 75 6e  ... (if (not run
48e0: 66 6c 61 67 29 0a 09 09 09 20 20 20 20 20 28 69  flag)....     (i
48f0: 66 20 28 6e 6f 74 20 70 61 72 65 6e 74 2d 74 65  f (not parent-te
4900: 73 74 29 0a 09 09 09 09 20 28 64 65 62 75 67 3a  st)..... (debug:
4910: 70 72 69 6e 74 20 31 20 22 4e 4f 54 45 3a 20 4e  print 1 "NOTE: N
4920: 6f 74 20 73 74 61 72 74 69 6e 67 20 74 65 73 74  ot starting test
4930: 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65   " new-test-name
4940: 20 22 20 61 73 20 69 74 20 69 73 20 73 74 61 74   " as it is stat
4950: 65 20 5c 22 43 4f 4d 50 4c 45 54 45 44 5c 22 20  e \"COMPLETED\" 
4960: 61 6e 64 20 73 74 61 74 75 73 20 5c 22 22 20 28  and status \"" (
4970: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20  test:get-status 
4980: 74 65 73 74 64 61 74 29 20 22 5c 22 2c 20 75 73  testdat) "\", us
4990: 65 20 2d 66 6f 72 63 65 20 74 6f 20 6f 76 65 72  e -force to over
49a0: 72 69 64 65 22 29 29 0a 09 09 09 20 20 20 20 20  ride"))....     
49b0: 28 6c 65 74 2a 20 28 28 67 65 74 2d 70 72 65 72  (let* ((get-prer
49c0: 65 71 73 2d 63 6d 64 20 28 6c 61 6d 62 64 61 20  eqs-cmd (lambda 
49d0: 28 29 0a 09 09 09 09 09 09 20 20 20 20 20 20 20  ().......       
49e0: 28 64 62 2d 67 65 74 2d 70 72 65 72 65 71 73 2d  (db-get-prereqs-
49f0: 6e 6f 74 2d 6d 65 74 20 64 62 20 72 75 6e 2d 69  not-met db run-i
4a00: 64 20 77 61 69 74 6f 6e 29 29 29 20 3b 3b 20 63  d waiton))) ;; c
4a10: 68 65 63 6b 20 62 65 66 6f 72 65 20 72 75 6e 6e  heck before runn
4a20: 69 6e 67 20 2e 2e 2e 2e 0a 09 09 09 09 20 20 20  ing .........   
4a30: 20 28 6c 61 75 6e 63 68 2d 63 6d 64 20 20 20 20   (launch-cmd    
4a40: 20 20 28 6c 61 6d 62 64 61 20 28 29 0a 09 09 09    (lambda ()....
4a50: 09 09 09 20 20 20 20 20 20 20 28 6c 61 75 6e 63  ...       (launc
4a60: 68 2d 74 65 73 74 20 64 62 20 72 75 6e 2d 69 64  h-test db run-id
4a70: 20 74 65 73 74 2d 63 6f 6e 66 20 6b 65 79 76 61   test-conf keyva
4a80: 6c 6c 73 74 20 74 65 73 74 2d 6e 61 6d 65 20 74  llst test-name t
4a90: 65 73 74 2d 70 61 74 68 20 69 74 65 6d 64 61 74  est-path itemdat
4aa0: 29 29 29 0a 09 09 09 09 20 20 20 20 28 74 65 73  ))).....    (tes
4ab0: 74 72 75 6e 64 61 74 20 20 20 20 20 20 28 6c 69  trundat      (li
4ac0: 73 74 20 67 65 74 2d 70 72 65 72 65 71 73 2d 63  st get-prereqs-c
4ad0: 6d 64 20 6c 61 75 6e 63 68 2d 63 6d 64 29 29 29  md launch-cmd)))
4ae0: 0a 09 09 09 20 20 20 20 20 20 20 28 69 66 20 28  ....       (if (
4af0: 6f 72 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67  or (args:get-arg
4b00: 20 22 2d 66 6f 72 63 65 22 29 0a 09 09 09 09 20   "-force")..... 
4b10: 20 20 20 20 20 20 28 6e 75 6c 6c 3f 20 28 28 63        (null? ((c
4b20: 61 72 20 74 65 73 74 72 75 6e 64 61 74 29 29 29  ar testrundat)))
4b30: 29 20 3b 3b 20 61 72 65 20 74 68 65 72 65 20 61  ) ;; are there a
4b40: 6e 79 20 74 65 73 74 73 20 74 68 61 74 20 6d 75  ny tests that mu
4b50: 73 74 20 62 65 20 72 75 6e 20 62 65 66 6f 72 65  st be run before
4b60: 20 74 68 69 73 20 6f 6e 65 2e 2e 2e 0a 09 09 09   this one.......
4b70: 09 20 20 20 28 69 66 20 28 6e 6f 74 20 28 28 63  .   (if (not ((c
4b80: 61 64 72 20 74 65 73 74 72 75 6e 64 61 74 29 29  adr testrundat))
4b90: 29 20 3b 3b 20 74 68 69 73 20 69 73 20 74 68 65  ) ;; this is the
4ba0: 20 6c 69 6e 65 20 74 68 61 74 20 6c 61 75 6e 63   line that launc
4bb0: 68 65 73 20 74 68 65 20 74 65 73 74 20 74 6f 20  hes the test to 
4bc0: 74 68 65 20 72 65 6d 6f 74 65 20 68 6f 73 74 0a  the remote host.
4bd0: 09 09 09 09 20 20 20 20 20 20 20 28 62 65 67 69  ....       (begi
4be0: 6e 0a 09 09 09 09 09 20 28 70 72 69 6e 74 20 22  n...... (print "
4bf0: 45 52 52 4f 52 3a 20 46 61 69 6c 65 64 20 74 6f  ERROR: Failed to
4c00: 20 6c 61 75 6e 63 68 20 74 68 65 20 74 65 73 74   launch the test
4c10: 2e 20 45 78 69 74 69 6e 67 20 61 73 20 73 6f 6f  . Exiting as soo
4c20: 6e 20 61 73 20 70 6f 73 73 69 62 6c 65 22 29 0a  n as possible").
4c30: 09 09 09 09 09 20 28 73 65 74 21 20 2a 67 6c 6f  ..... (set! *glo
4c40: 62 61 6c 65 78 69 74 73 74 61 74 75 73 2a 20 31  balexitstatus* 1
4c50: 29 20 3b 3b 20 0a 09 09 09 09 09 20 28 70 72 6f  ) ;; ...... (pro
4c60: 63 65 73 73 2d 73 69 67 6e 61 6c 20 28 63 75 72  cess-signal (cur
4c70: 72 65 6e 74 2d 70 72 6f 63 65 73 73 2d 69 64 29  rent-process-id)
4c80: 20 73 69 67 6e 61 6c 2f 6b 69 6c 6c 29 0a 09 09   signal/kill)...
4c90: 09 09 09 20 3b 28 65 78 69 74 20 31 29 0a 09 09  ... ;(exit 1)...
4ca0: 09 09 09 20 29 29 0a 09 09 09 09 20 20 20 28 69  ... )).....   (i
4cb0: 66 20 28 6e 6f 74 20 28 61 72 67 73 3a 67 65 74  f (not (args:get
4cc0: 2d 61 72 67 20 22 2d 6b 65 65 70 67 6f 69 6e 67  -arg "-keepgoing
4cd0: 22 29 29 0a 09 09 09 09 20 20 20 20 20 20 20 28  ")).....       (
4ce0: 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74 21 20  hash-table-set! 
4cf0: 2a 77 61 69 74 69 6e 67 2d 71 75 65 75 65 2a 20  *waiting-queue* 
4d00: 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20 74 65  new-test-name te
4d10: 73 74 72 75 6e 64 61 74 29 29 29 29 29 29 29 0a  strundat))))))).
4d20: 09 09 20 20 20 20 20 20 28 28 4b 49 4c 4c 45 44  ..      ((KILLED
4d30: 29 20 0a 09 09 20 20 20 20 20 20 20 28 64 65 62  ) ...       (deb
4d40: 75 67 3a 70 72 69 6e 74 20 31 20 22 4e 4f 54 45  ug:print 1 "NOTE
4d50: 3a 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d  : " new-test-nam
4d60: 65 20 22 20 69 73 20 61 6c 72 65 61 64 79 20 72  e " is already r
4d70: 75 6e 6e 69 6e 67 20 6f 72 20 77 61 73 20 65 78  unning or was ex
4d80: 70 6c 69 63 74 6c 79 20 6b 69 6c 6c 65 64 2c 20  plictly killed, 
4d90: 75 73 65 20 2d 66 6f 72 63 65 20 74 6f 20 6c 61  use -force to la
4da0: 75 6e 63 68 20 69 74 2e 22 29 29 0a 09 09 20 20  unch it."))...  
4db0: 20 20 20 20 28 28 4c 41 55 4e 43 48 45 44 20 52      ((LAUNCHED R
4dc0: 45 4d 4f 54 45 48 4f 53 54 53 54 41 52 54 20 52  EMOTEHOSTSTART R
4dd0: 55 4e 4e 49 4e 47 29 20 20 0a 09 09 20 20 20 20  UNNING)  ...    
4de0: 20 20 20 28 69 66 20 28 3e 20 28 2d 20 28 63 75     (if (> (- (cu
4df0: 72 72 65 6e 74 2d 73 65 63 6f 6e 64 73 29 28 2b  rrent-seconds)(+
4e00: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 65 76   (db:test-get-ev
4e10: 65 6e 74 5f 74 69 6d 65 20 74 65 73 74 64 61 74  ent_time testdat
4e20: 29 0a 09 09 09 09 09 09 20 20 20 20 20 28 64 62  ).......     (db
4e30: 3a 74 65 73 74 2d 67 65 74 2d 72 75 6e 5f 64 75  :test-get-run_du
4e40: 72 61 74 69 6f 6e 20 74 65 73 74 64 61 74 29 29  ration testdat))
4e50: 29 0a 09 09 09 20 20 20 20 20 20 31 30 30 29 20  )....      100) 
4e60: 3b 3b 20 69 2e 65 2e 20 6e 6f 20 75 70 64 61 74  ;; i.e. no updat
4e70: 65 20 66 6f 72 20 6d 6f 72 65 20 74 68 61 6e 20  e for more than 
4e80: 31 30 30 20 73 65 63 6f 6e 64 73 0a 09 09 09 20  100 seconds.... 
4e90: 20 20 28 62 65 67 69 6e 0a 09 09 09 20 20 20 20    (begin....    
4ea0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
4eb0: 22 57 41 52 4e 49 4e 47 3a 20 54 65 73 74 20 22  "WARNING: Test "
4ec0: 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 61 70 70   test-name " app
4ed0: 65 61 72 73 20 74 6f 20 62 65 20 64 65 61 64 2e  ears to be dead.
4ee0: 20 46 6f 72 63 69 6e 67 20 69 74 20 74 6f 20 73   Forcing it to s
4ef0: 74 61 74 65 20 49 4e 43 4f 4d 50 4c 45 54 45 20  tate INCOMPLETE 
4f00: 61 6e 64 20 73 74 61 74 75 73 20 53 54 55 43 4b  and status STUCK
4f10: 2f 44 45 41 44 22 29 0a 09 09 09 20 20 20 20 20  /DEAD")....     
4f20: 28 74 65 73 74 2d 73 65 74 2d 73 74 61 74 75 73  (test-set-status
4f30: 21 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  ! db run-id test
4f40: 2d 6e 61 6d 65 20 22 49 4e 43 4f 4d 50 4c 45 54  -name "INCOMPLET
4f50: 45 22 20 22 53 54 55 43 4b 2f 44 45 41 44 22 20  E" "STUCK/DEAD" 
4f60: 69 74 65 6d 64 61 74 20 22 54 65 73 74 20 69 73  itemdat "Test is
4f70: 20 73 74 75 63 6b 20 6f 72 20 64 65 61 64 22 29   stuck or dead")
4f80: 29 0a 09 09 09 20 20 20 28 64 65 62 75 67 3a 70  )....   (debug:p
4f90: 72 69 6e 74 20 32 20 22 4e 4f 54 45 3a 20 22 20  rint 2 "NOTE: " 
4fa0: 74 65 73 74 2d 6e 61 6d 65 20 22 20 69 73 20 61  test-name " is a
4fb0: 6c 72 65 61 64 79 20 72 75 6e 6e 69 6e 67 22 29  lready running")
4fc0: 29 29 0a 09 09 20 20 20 20 20 20 28 65 6c 73 65  ))...      (else
4fd0: 20 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72         (debug:pr
4fe0: 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 46 61  int 0 "ERROR: Fa
4ff0: 69 6c 65 64 20 74 6f 20 6c 61 75 6e 63 68 20 74  iled to launch t
5000: 65 73 74 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e  est " new-test-n
5010: 61 6d 65 20 22 2e 20 55 6e 72 65 63 6f 67 6e 69  ame ". Unrecogni
5020: 73 65 64 20 73 74 61 74 65 20 22 20 28 74 65 73  sed state " (tes
5030: 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74  t:get-state test
5040: 64 61 74 29 29 29 29 29 29 0a 09 20 20 20 20 20  dat))))))..     
5050: 20 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f   (if (not (null?
5060: 20 74 61 6c 29 29 0a 09 09 20 20 28 6c 6f 6f 70   tal))...  (loop
5070: 20 28 63 61 72 20 74 61 6c 29 28 63 64 72 20 74   (car tal)(cdr t
5080: 61 6c 29 29 29 29 29 29 29 29 29 0a 0a 28 64 65  al)))))))))..(de
5090: 66 69 6e 65 20 28 72 75 6e 2d 77 61 69 74 69 6e  fine (run-waitin
50a0: 67 2d 74 65 73 74 73 20 64 62 29 0a 20 20 28 6c  g-tests db).  (l
50b0: 65 74 20 28 28 6e 75 6d 74 72 69 65 73 20 20 20  et ((numtries   
50c0: 20 20 20 20 20 20 20 20 30 29 0a 09 28 6c 61 73          0)..(las
50d0: 74 2d 74 72 79 2d 74 69 6d 65 20 20 20 20 20 20  t-try-time      
50e0: 28 63 75 72 72 65 6e 74 2d 73 65 63 6f 6e 64 73  (current-seconds
50f0: 29 29 0a 09 28 74 69 6d 65 73 20 20 20 20 20 20  ))..(times      
5100: 20 20 20 20 20 20 20 20 28 6c 69 73 74 20 31 29          (list 1)
5110: 29 29 20 3b 3b 20 6d 69 6e 75 74 65 73 20 74 6f  )) ;; minutes to
5120: 20 77 61 69 74 20 62 65 66 6f 72 65 20 74 72 79   wait before try
5130: 69 6e 67 20 61 67 61 69 6e 20 74 6f 20 6b 69 63  ing again to kic
5140: 6b 20 6f 66 66 20 72 75 6e 73 0a 20 20 20 20 3b  k off runs.    ;
5150: 3b 20 42 55 47 20 74 68 69 73 20 68 61 63 6b 20  ; BUG this hack 
5160: 6f 66 20 62 72 75 74 65 20 66 6f 72 63 65 20 72  of brute force r
5170: 65 74 72 79 69 6e 67 20 77 6f 72 6b 73 20 71 75  etrying works qu
5180: 69 74 65 20 77 65 6c 6c 20 66 6f 72 20 6d 61 6e  ite well for man
5190: 79 20 63 61 73 65 73 20 62 75 74 20 0a 20 20 20  y cases but .   
51a0: 20 3b 3b 20 20 20 20 20 77 68 61 74 20 69 73 20   ;;     what is 
51b0: 6e 65 65 64 65 64 20 69 73 20 74 6f 20 63 68 65  needed is to che
51c0: 63 6b 20 74 68 65 20 64 62 20 66 6f 72 20 74 65  ck the db for te
51d0: 73 74 73 20 74 68 61 74 20 68 61 76 65 20 66 61  sts that have fa
51e0: 69 6c 65 64 20 6c 65 73 73 20 74 68 61 6e 0a 20  iled less than. 
51f0: 20 20 20 3b 3b 20 20 20 20 20 4e 20 74 69 6d 65     ;;     N time
5200: 73 20 6f 72 20 6e 65 76 65 72 20 62 65 65 6e 20  s or never been 
5210: 73 74 61 72 74 65 64 20 61 6e 64 20 6b 69 63 6b  started and kick
5220: 20 74 68 65 6d 20 6f 66 66 20 61 67 61 69 6e 0a   them off again.
5230: 20 20 20 20 28 6c 65 74 20 6c 6f 6f 70 20 28 28      (let loop ((
5240: 77 61 69 74 69 6e 67 2d 74 65 73 74 2d 6e 61 6d  waiting-test-nam
5250: 65 73 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 6b  es (hash-table-k
5260: 65 79 73 20 2a 77 61 69 74 69 6e 67 2d 71 75 65  eys *waiting-que
5270: 75 65 2a 29 29 29 0a 20 20 20 20 20 20 28 63 6f  ue*))).      (co
5280: 6e 64 0a 20 20 20 20 20 20 20 28 28 6e 6f 74 20  nd.       ((not 
5290: 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f  (runs:can-run-mo
52a0: 72 65 2d 74 65 73 74 73 20 64 62 29 29 0a 09 28  re-tests db))..(
52b0: 73 6c 65 65 70 20 32 29 0a 09 28 6c 6f 6f 70 20  sleep 2)..(loop 
52c0: 77 61 69 74 69 6e 67 2d 74 65 73 74 2d 6e 61 6d  waiting-test-nam
52d0: 65 73 29 29 0a 20 20 20 20 20 20 20 28 28 6e 75  es)).       ((nu
52e0: 6c 6c 3f 20 77 61 69 74 69 6e 67 2d 74 65 73 74  ll? waiting-test
52f0: 2d 6e 61 6d 65 73 29 0a 09 28 64 65 62 75 67 3a  -names)..(debug:
5300: 70 72 69 6e 74 20 31 20 22 41 6c 6c 20 74 65 73  print 1 "All tes
5310: 74 73 20 6c 61 75 6e 63 68 65 64 22 29 29 0a 20  ts launched")). 
5320: 20 20 20 20 20 20 28 65 6c 73 65 0a 09 28 73 65        (else..(se
5330: 74 21 20 6e 75 6d 74 72 69 65 73 20 28 2b 20 6e  t! numtries (+ n
5340: 75 6d 74 72 69 65 73 20 31 29 29 0a 09 28 66 6f  umtries 1))..(fo
5350: 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 20 28  r-each (lambda (
5360: 74 65 73 74 6e 61 6d 65 29 0a 09 09 20 20 20 20  testname)...    
5370: 28 69 66 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75  (if (runs:can-ru
5380: 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64 62 29  n-more-tests db)
5390: 0a 09 09 09 28 6c 65 74 2a 20 28 28 74 65 73 74  ....(let* ((test
53a0: 64 61 74 20 28 68 61 73 68 2d 74 61 62 6c 65 2d  dat (hash-table-
53b0: 72 65 66 20 2a 77 61 69 74 69 6e 67 2d 71 75 65  ref *waiting-que
53c0: 75 65 2a 20 74 65 73 74 6e 61 6d 65 29 29 0a 09  ue* testname))..
53d0: 09 09 20 20 20 20 20 20 20 28 70 72 65 72 65 71  ..       (prereq
53e0: 73 20 28 28 63 61 72 20 74 65 73 74 64 61 74 29  s ((car testdat)
53f0: 29 29 0a 09 09 09 20 20 20 20 20 20 20 28 6c 64  ))....       (ld
5400: 62 20 20 20 20 20 28 69 66 20 64 62 20 64 62 20  b     (if db db 
5410: 28 6f 70 65 6e 2d 64 62 29 29 29 29 0a 09 09 09  (open-db))))....
5420: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32    (debug:print 2
5430: 20 22 70 72 65 72 65 71 73 20 72 65 6d 61 69 6e   "prereqs remain
5440: 69 6e 67 3a 20 22 20 70 72 65 72 65 71 73 29 0a  ing: " prereqs).
5450: 09 09 09 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20  ...  (if (null? 
5460: 70 72 65 72 65 71 73 29 0a 09 09 09 20 20 20 20  prereqs)....    
5470: 20 20 28 62 65 67 69 6e 0a 09 09 09 09 28 64 65    (begin.....(de
5480: 62 75 67 3a 70 72 69 6e 74 20 32 20 22 50 72 65  bug:print 2 "Pre
5490: 72 65 71 75 69 73 69 74 65 73 20 6d 65 74 2c 20  requisites met, 
54a0: 6c 61 75 6e 63 68 69 6e 67 20 22 20 74 65 73 74  launching " test
54b0: 6e 61 6d 65 29 0a 09 09 09 09 28 28 63 61 64 72  name).....((cadr
54c0: 20 74 65 73 74 64 61 74 29 29 0a 09 09 09 09 28   testdat)).....(
54d0: 68 61 73 68 2d 74 61 62 6c 65 2d 64 65 6c 65 74  hash-table-delet
54e0: 65 21 20 2a 77 61 69 74 69 6e 67 2d 71 75 65 75  e! *waiting-queu
54f0: 65 2a 20 74 65 73 74 6e 61 6d 65 29 29 29 0a 09  e* testname)))..
5500: 09 09 20 20 28 69 66 20 28 6e 6f 74 20 64 62 29  ..  (if (not db)
5510: 0a 09 09 09 20 20 20 20 20 20 28 73 71 6c 69 74  ....      (sqlit
5520: 65 33 3a 66 69 6e 61 6c 69 7a 65 21 20 6c 64 62  e3:finalize! ldb
5530: 29 29 29 29 29 0a 09 09 20 20 77 61 69 74 69 6e  )))))...  waitin
5540: 67 2d 74 65 73 74 2d 6e 61 6d 65 73 29 0a 09 3b  g-test-names)..;
5550: 3b 20 28 73 6c 65 65 70 20 31 30 29 20 3b 3b 20  ; (sleep 10) ;; 
5560: 6e 6f 20 70 6f 69 6e 74 20 69 6e 20 72 75 73 68  no point in rush
5570: 69 6e 67 20 74 68 69 6e 67 73 20 61 74 20 74 68  ing things at th
5580: 69 73 20 73 74 61 67 65 3f 0a 09 28 6c 6f 6f 70  is stage?..(loop
5590: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 6b 65 79   (hash-table-key
55a0: 73 20 2a 77 61 69 74 69 6e 67 2d 71 75 65 75 65  s *waiting-queue
55b0: 2a 29 29 29 29 29 29 29 0a 0a 28 64 65 66 69 6e  *)))))))..(defin
55c0: 65 20 28 67 65 74 2d 64 69 72 2d 75 70 2d 6e 20  e (get-dir-up-n 
55d0: 64 69 72 20 2e 20 70 61 72 61 6d 73 29 20 0a 20  dir . params) . 
55e0: 20 28 6c 65 74 20 28 28 64 70 61 72 74 73 20 20   (let ((dparts  
55f0: 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 64 69  (string-split di
5600: 72 20 22 2f 22 29 29 0a 09 28 63 6f 75 6e 74 20  r "/"))..(count 
5610: 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 70 61 72    (if (null? par
5620: 61 6d 73 29 20 31 20 28 63 61 72 20 70 61 72 61  ams) 1 (car para
5630: 6d 73 29 29 29 29 0a 20 20 20 20 28 63 6f 6e 63  ms)))).    (conc
5640: 20 22 2f 22 20 28 73 74 72 69 6e 67 2d 69 6e 74   "/" (string-int
5650: 65 72 73 70 65 72 73 65 20 0a 09 20 20 20 20 20  ersperse ..     
5660: 20 20 28 74 61 6b 65 20 64 70 61 72 74 73 20 28    (take dparts (
5670: 2d 20 28 6c 65 6e 67 74 68 20 64 70 61 72 74 73  - (length dparts
5680: 29 20 63 6f 75 6e 74 29 29 0a 09 20 20 20 20 20  ) count))..     
5690: 20 20 22 2f 22 29 29 29 29 0a 3b 3b 20 52 65 6d    "/")))).;; Rem
56a0: 6f 76 65 20 72 75 6e 73 0a 3b 3b 20 66 69 65 6c  ove runs.;; fiel
56b0: 64 73 20 61 72 65 20 70 61 73 73 69 6e 67 20 69  ds are passing i
56c0: 6e 20 74 68 72 6f 75 67 68 20 0a 28 64 65 66 69  n through .(defi
56d0: 6e 65 20 28 72 75 6e 73 3a 72 65 6d 6f 76 65 2d  ne (runs:remove-
56e0: 72 75 6e 73 20 64 62 20 72 75 6e 6e 61 6d 65 70  runs db runnamep
56f0: 61 74 74 20 74 65 73 74 70 61 74 74 20 69 74 65  att testpatt ite
5700: 6d 70 61 74 74 29 0a 20 20 28 6c 65 74 2a 20 28  mpatt).  (let* (
5710: 28 6b 65 79 73 20 20 20 20 20 20 20 20 28 64 62  (keys        (db
5720: 2d 67 65 74 2d 6b 65 79 73 20 64 62 29 29 0a 09  -get-keys db))..
5730: 20 28 72 75 6e 64 61 74 20 20 20 20 20 20 28 72   (rundat      (r
5740: 75 6e 73 3a 67 65 74 2d 72 75 6e 73 2d 62 79 2d  uns:get-runs-by-
5750: 70 61 74 74 20 64 62 20 6b 65 79 73 20 72 75 6e  patt db keys run
5760: 6e 61 6d 65 70 61 74 74 29 29 0a 09 20 28 68 65  namepatt)).. (he
5770: 61 64 65 72 20 20 20 20 20 20 28 76 65 63 74 6f  ader      (vecto
5780: 72 2d 72 65 66 20 72 75 6e 64 61 74 20 30 29 29  r-ref rundat 0))
5790: 0a 09 20 28 72 75 6e 73 20 20 20 20 20 20 20 20  .. (runs        
57a0: 28 76 65 63 74 6f 72 2d 72 65 66 20 72 75 6e 64  (vector-ref rund
57b0: 61 74 20 31 29 29 29 0a 20 20 20 20 28 64 65 62  at 1))).    (deb
57c0: 75 67 3a 70 72 69 6e 74 20 31 20 22 48 65 61 64  ug:print 1 "Head
57d0: 65 72 3a 20 22 20 68 65 61 64 65 72 29 0a 20 20  er: " header).  
57e0: 20 20 28 66 6f 72 2d 65 61 63 68 0a 20 20 20 20    (for-each.    
57f0: 20 28 6c 61 6d 62 64 61 20 28 72 75 6e 29 0a 20   (lambda (run). 
5800: 20 20 20 20 20 20 28 6c 65 74 20 28 28 72 75 6e        (let ((run
5810: 6b 65 79 20 28 73 74 72 69 6e 67 2d 69 6e 74 65  key (string-inte
5820: 72 73 70 65 72 73 65 20 28 6d 61 70 20 28 6c 61  rsperse (map (la
5830: 6d 62 64 61 20 28 6b 29 0a 09 09 09 09 09 09 28  mbda (k).......(
5840: 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d  db:get-value-by-
5850: 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65  header run heade
5860: 72 20 28 76 65 63 74 6f 72 2d 72 65 66 20 6b 20  r (vector-ref k 
5870: 30 29 29 29 20 6b 65 79 73 29 20 22 2f 22 29 29  0))) keys) "/"))
5880: 29 0a 09 20 28 6c 65 74 2a 20 28 28 72 75 6e 2d  ).. (let* ((run-
5890: 69 64 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65  id (db:get-value
58a0: 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68  -by-header run h
58b0: 65 61 64 65 72 20 22 69 64 22 29 20 29 0a 09 09  eader "id") )...
58c0: 28 74 65 73 74 73 20 20 28 64 62 2d 67 65 74 2d  (tests  (db-get-
58d0: 74 65 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62  tests-for-run db
58e0: 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62   (db:get-value-b
58f0: 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61  y-header run hea
5900: 64 65 72 20 22 69 64 22 29 20 74 65 73 74 70 61  der "id") testpa
5910: 74 74 20 69 74 65 6d 70 61 74 74 29 29 0a 09 09  tt itempatt))...
5920: 28 6c 61 73 74 74 70 61 74 68 20 22 2f 64 6f 65  (lasttpath "/doe
5930: 73 2f 6e 6f 74 2f 65 78 69 73 74 2f 49 2f 68 6f  s/not/exist/I/ho
5940: 70 65 22 29 29 0a 09 20 20 20 28 69 66 20 28 6e  pe"))..   (if (n
5950: 6f 74 20 28 6e 75 6c 6c 3f 20 74 65 73 74 73 29  ot (null? tests)
5960: 29 0a 09 20 20 20 20 20 20 20 28 62 65 67 69 6e  )..       (begin
5970: 0a 09 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ... (debug:print
5980: 20 31 20 22 52 65 6d 6f 76 69 6e 67 20 74 65 73   1 "Removing tes
5990: 74 73 20 66 6f 72 20 72 75 6e 3a 20 22 20 72 75  ts for run: " ru
59a0: 6e 6b 65 79 20 22 20 22 20 28 64 62 3a 67 65 74  nkey " " (db:get
59b0: 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72  -value-by-header
59c0: 20 72 75 6e 20 68 65 61 64 65 72 20 22 72 75 6e   run header "run
59d0: 6e 61 6d 65 22 29 29 0a 09 09 20 28 66 6f 72 2d  name"))... (for-
59e0: 65 61 63 68 0a 09 09 20 20 28 6c 61 6d 62 64 61  each...  (lambda
59f0: 20 28 74 65 73 74 29 0a 09 09 20 20 20 20 28 6c   (test)...    (l
5a00: 65 74 2a 20 28 28 69 74 65 6d 2d 70 61 74 68 20  et* ((item-path 
5a10: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65  (db:test-get-ite
5a20: 6d 2d 70 61 74 68 20 74 65 73 74 29 29 0a 09 09  m-path test))...
5a30: 09 20 20 20 28 74 65 73 74 2d 6e 61 6d 65 20 28  .   (test-name (
5a40: 64 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74  db:test-get-test
5a50: 6e 61 6d 65 20 74 65 73 74 29 29 0a 09 09 09 20  name test)).... 
5a60: 20 20 28 72 75 6e 2d 64 69 72 20 20 20 28 64 62    (run-dir   (db
5a70: 3a 74 65 73 74 2d 67 65 74 2d 72 75 6e 64 69 72  :test-get-rundir
5a80: 20 74 65 73 74 29 29 29 0a 09 09 20 20 20 20 20   test)))...     
5a90: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20   (debug:print 1 
5aa0: 22 20 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65  "  " (db:test-ge
5ab0: 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 29  t-testname test)
5ac0: 20 22 20 69 64 3a 20 22 20 28 64 62 3a 74 65 73   " id: " (db:tes
5ad0: 74 2d 67 65 74 2d 69 64 20 74 65 73 74 29 20 22  t-get-id test) "
5ae0: 20 22 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 09   " item-path)...
5af0: 20 20 20 20 20 20 28 64 62 3a 64 65 6c 65 74 65        (db:delete
5b00: 2d 74 65 73 74 2d 72 65 63 6f 72 64 73 20 64 62  -test-records db
5b10: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64   (db:test-get-id
5b20: 20 74 65 73 74 29 29 0a 09 09 20 20 20 20 20 20   test))...      
5b30: 28 69 66 20 28 3e 20 28 73 74 72 69 6e 67 2d 6c  (if (> (string-l
5b40: 65 6e 67 74 68 20 72 75 6e 2d 64 69 72 29 20 35  ength run-dir) 5
5b50: 29 20 3b 3b 20 62 61 64 20 68 65 75 72 69 73 74  ) ;; bad heurist
5b60: 69 63 20 62 75 74 20 73 68 6f 75 6c 64 20 70 72  ic but should pr
5b70: 65 76 65 6e 74 20 2f 74 6d 70 20 2f 68 6f 6d 65  event /tmp /home
5b80: 20 65 74 63 2e 0a 09 09 09 20 20 28 6c 65 74 20   etc.....  (let 
5b90: 28 28 66 75 6c 6c 70 61 74 68 20 72 75 6e 2d 64  ((fullpath run-d
5ba0: 69 72 29 29 20 3b 3b 20 22 2f 22 20 28 64 62 3a  ir)) ;; "/" (db:
5bb0: 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61  test-get-item-pa
5bc0: 74 68 20 74 65 73 74 29 29 29 29 0a 09 09 09 20  th test)))).... 
5bd0: 20 20 20 28 73 65 74 21 20 6c 61 73 74 74 70 61     (set! lasttpa
5be0: 74 68 20 66 75 6c 6c 70 61 74 68 29 0a 09 09 09  th fullpath)....
5bf0: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
5c00: 20 31 20 22 72 6d 20 2d 72 66 20 22 20 66 75 6c   1 "rm -rf " ful
5c10: 6c 70 61 74 68 29 0a 09 09 09 20 20 20 20 28 73  lpath)....    (s
5c20: 79 73 74 65 6d 20 28 63 6f 6e 63 20 22 72 6d 20  ystem (conc "rm 
5c30: 2d 72 66 20 22 20 66 75 6c 6c 70 61 74 68 29 29  -rf " fullpath))
5c40: 0a 09 09 09 20 20 20 20 28 6c 65 74 2a 20 28 28  ....    (let* ((
5c50: 64 69 72 73 2d 63 6f 75 6e 74 20 28 2b 20 31 20  dirs-count (+ 1 
5c60: 28 6c 65 6e 67 74 68 20 6b 65 79 73 29 28 6c 65  (length keys)(le
5c70: 6e 67 74 68 20 28 73 74 72 69 6e 67 2d 73 70 6c  ngth (string-spl
5c80: 69 74 20 69 74 65 6d 2d 70 61 74 68 20 22 2f 22  it item-path "/"
5c90: 29 29 29 29 0a 09 09 09 09 20 20 20 28 64 69 72  )))).....   (dir
5ca0: 2d 74 6f 2d 72 65 6d 20 28 67 65 74 2d 64 69 72  -to-rem (get-dir
5cb0: 2d 75 70 2d 6e 20 66 75 6c 6c 70 61 74 68 20 64  -up-n fullpath d
5cc0: 69 72 73 2d 63 6f 75 6e 74 29 29 0a 09 09 09 09  irs-count)).....
5cd0: 20 20 20 28 72 65 6d 61 69 6e 69 6e 67 64 20 28     (remainingd (
5ce0: 73 74 72 69 6e 67 2d 73 75 62 73 74 69 74 75 74  string-substitut
5cf0: 65 20 28 72 65 67 65 78 70 20 28 63 6f 6e 63 20  e (regexp (conc 
5d00: 22 5e 22 20 64 69 72 2d 74 6f 2d 72 65 6d 20 22  "^" dir-to-rem "
5d10: 2f 22 29 29 20 22 22 20 66 75 6c 6c 70 61 74 68  /")) "" fullpath
5d20: 29 29 0a 09 09 09 09 20 20 20 28 63 6d 64 20 28  )).....   (cmd (
5d30: 63 6f 6e 63 20 22 63 64 20 22 20 64 69 72 2d 74  conc "cd " dir-t
5d40: 6f 2d 72 65 6d 20 22 3b 20 72 6d 64 69 72 20 2d  o-rem "; rmdir -
5d50: 70 20 22 20 72 65 6d 61 69 6e 69 6e 67 64 20 29  p " remainingd )
5d60: 29 29 0a 09 09 09 20 20 20 20 20 20 28 69 66 20  ))....      (if 
5d70: 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 66 75  (file-exists? fu
5d80: 6c 6c 70 61 74 68 29 0a 09 09 09 09 20 20 28 62  llpath).....  (b
5d90: 65 67 69 6e 0a 09 09 09 09 20 20 20 20 28 64 65  egin.....    (de
5da0: 62 75 67 3a 70 72 69 6e 74 20 31 20 63 6d 64 29  bug:print 1 cmd)
5db0: 0a 09 09 09 09 20 20 20 20 28 73 79 73 74 65 6d  .....    (system
5dc0: 20 63 6d 64 29 29 29 0a 09 09 09 20 20 20 20 20   cmd)))....     
5dd0: 20 29 29 0a 09 09 09 20 20 20 20 29 29 29 0a 09   ))....    )))..
5de0: 09 20 20 20 20 74 65 73 74 73 29 29 29 0a 09 20  .    tests))).. 
5df0: 20 20 28 6c 65 74 20 28 28 72 65 6d 74 65 73 74    (let ((remtest
5e00: 73 20 28 64 62 2d 67 65 74 2d 74 65 73 74 73 2d  s (db-get-tests-
5e10: 66 6f 72 2d 72 75 6e 20 64 62 20 28 64 62 3a 67  for-run db (db:g
5e20: 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64  et-value-by-head
5e30: 65 72 20 72 75 6e 20 68 65 61 64 65 72 20 22 69  er run header "i
5e40: 64 22 29 29 29 29 0a 09 20 20 20 20 20 28 69 66  d"))))..     (if
5e50: 20 28 6e 75 6c 6c 3f 20 72 65 6d 74 65 73 74 73   (null? remtests
5e60: 29 20 3b 3b 20 6e 6f 20 6d 6f 72 65 20 74 65 73  ) ;; no more tes
5e70: 74 73 20 72 65 6d 61 69 6e 69 6e 67 0a 09 09 20  ts remaining... 
5e80: 28 6c 65 74 2a 20 28 28 64 70 61 72 74 73 20 20  (let* ((dparts  
5e90: 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 6c 61  (string-split la
5ea0: 73 74 74 70 61 74 68 20 22 2f 22 29 29 0a 09 09  sttpath "/"))...
5eb0: 09 28 72 75 6e 70 61 74 68 20 28 63 6f 6e 63 20  .(runpath (conc 
5ec0: 22 2f 22 20 28 73 74 72 69 6e 67 2d 69 6e 74 65  "/" (string-inte
5ed0: 72 73 70 65 72 73 65 20 0a 09 09 09 09 09 20 20  rsperse ......  
5ee0: 20 20 28 74 61 6b 65 20 64 70 61 72 74 73 20 28    (take dparts (
5ef0: 2d 20 28 6c 65 6e 67 74 68 20 64 70 61 72 74 73  - (length dparts
5f00: 29 20 31 29 29 0a 09 09 09 09 09 20 20 20 20 22  ) 1))......    "
5f10: 2f 22 29 29 29 29 0a 09 09 20 20 20 28 64 65 62  /"))))...   (deb
5f20: 75 67 3a 70 72 69 6e 74 20 31 20 22 52 65 6d 6f  ug:print 1 "Remo
5f30: 76 69 6e 67 20 72 75 6e 3a 20 22 20 72 75 6e 6b  ving run: " runk
5f40: 65 79 20 22 20 22 20 28 64 62 3a 67 65 74 2d 76  ey " " (db:get-v
5f50: 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72  alue-by-header r
5f60: 75 6e 20 68 65 61 64 65 72 20 22 72 75 6e 6e 61  un header "runna
5f70: 6d 65 22 29 29 0a 09 09 20 20 20 28 64 62 3a 64  me"))...   (db:d
5f80: 65 6c 65 74 65 2d 72 75 6e 20 64 62 20 72 75 6e  elete-run db run
5f90: 2d 69 64 29 0a 09 09 20 20 20 3b 3b 20 6e 65 65  -id)...   ;; nee
5fa0: 64 20 74 6f 20 66 69 67 75 72 65 20 6f 75 74 20  d to figure out 
5fb0: 74 68 65 20 70 61 74 68 20 74 6f 20 74 68 65 20  the path to the 
5fc0: 72 75 6e 20 64 69 72 20 61 6e 64 20 72 65 6d 6f  run dir and remo
5fd0: 76 65 20 69 74 20 69 66 20 65 6d 70 74 79 0a 09  ve it if empty..
5fe0: 09 20 20 20 3b 3b 20 20 20 20 28 69 66 20 28 6e  .   ;;    (if (n
5ff0: 75 6c 6c 3f 20 28 67 6c 6f 62 20 28 63 6f 6e 63  ull? (glob (conc
6000: 20 72 75 6e 70 61 74 68 20 22 2f 2a 22 29 29 29   runpath "/*")))
6010: 0a 09 09 20 20 20 3b 3b 20 20 20 20 20 20 20 20  ...   ;;        
6020: 28 62 65 67 69 6e 0a 09 09 20 20 20 3b 3b 20 09  (begin...   ;; .
6030: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20   (debug:print 1 
6040: 22 52 65 6d 6f 76 69 6e 67 20 72 75 6e 20 64 69  "Removing run di
6050: 72 20 22 20 72 75 6e 70 61 74 68 29 0a 09 09 20  r " runpath)... 
6060: 20 20 3b 3b 20 09 20 28 73 79 73 74 65 6d 20 28    ;; . (system (
6070: 63 6f 6e 63 20 22 72 6d 64 69 72 20 2d 70 20 22  conc "rmdir -p "
6080: 20 72 75 6e 70 61 74 68 29 29 29 29 0a 09 09 20   runpath))))... 
6090: 20 20 29 29 29 29 0a 09 20 29 29 0a 20 20 20 20    )))).. )).    
60a0: 20 72 75 6e 73 29 29 29 0a                        runs))).