Megatest

Hex Artifact Content
Login

Artifact 9af3e39a19a599adcc4d95d0302e0665d79be719:


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: 28 75 73 65 20 73 71 6c 69 74 65 33 20 73 72 66  (use sqlite3 srf
0190: 69 2d 31 20 70 6f 73 69 78 20 72 65 67 65 78 20  i-1 posix regex 
01a0: 72 65 67 65 78 2d 63 61 73 65 20 73 72 66 69 2d  regex-case srfi-
01b0: 36 39 20 64 6f 74 2d 6c 6f 63 6b 69 6e 67 29 0a  69 dot-locking).
01c0: 28 69 6d 70 6f 72 74 20 28 70 72 65 66 69 78 20  (import (prefix 
01d0: 73 71 6c 69 74 65 33 20 73 71 6c 69 74 65 33 3a  sqlite3 sqlite3:
01e0: 29 29 0a 0a 28 64 65 63 6c 61 72 65 20 28 75 6e  ))..(declare (un
01f0: 69 74 20 72 75 6e 73 29 29 0a 28 64 65 63 6c 61  it runs)).(decla
0200: 72 65 20 28 75 73 65 73 20 64 62 29 29 0a 28 64  re (uses db)).(d
0210: 65 63 6c 61 72 65 20 28 75 73 65 73 20 63 6f 6d  eclare (uses com
0220: 6d 6f 6e 29 29 0a 28 64 65 63 6c 61 72 65 20 28  mon)).(declare (
0230: 75 73 65 73 20 69 74 65 6d 73 29 29 0a 28 64 65  uses items)).(de
0240: 63 6c 61 72 65 20 28 75 73 65 73 20 72 75 6e 63  clare (uses runc
0250: 6f 6e 66 69 67 29 29 0a 0a 28 69 6e 63 6c 75 64  onfig))..(includ
0260: 65 20 22 63 6f 6d 6d 6f 6e 5f 72 65 63 6f 72 64  e "common_record
0270: 73 2e 73 63 6d 22 29 0a 28 69 6e 63 6c 75 64 65  s.scm").(include
0280: 20 22 6b 65 79 5f 72 65 63 6f 72 64 73 2e 73 63   "key_records.sc
0290: 6d 22 29 0a 28 69 6e 63 6c 75 64 65 20 22 64 62  m").(include "db
02a0: 5f 72 65 63 6f 72 64 73 2e 73 63 6d 22 29 0a 28  _records.scm").(
02b0: 69 6e 63 6c 75 64 65 20 22 72 75 6e 5f 72 65 63  include "run_rec
02c0: 6f 72 64 73 2e 73 63 6d 22 29 0a 0a 3b 3b 20 72  ords.scm")..;; r
02d0: 65 67 69 73 74 65 72 20 61 20 74 65 73 74 20 72  egister a test r
02e0: 75 6e 20 77 69 74 68 20 74 68 65 20 64 62 0a 28  un with the db.(
02f0: 64 65 66 69 6e 65 20 28 72 65 67 69 73 74 65 72  define (register
0300: 2d 72 75 6e 20 64 62 20 6b 65 79 73 29 20 3b 3b  -run db keys) ;;
0310: 20 74 65 73 74 2d 6e 61 6d 65 29 0a 20 20 28 6c   test-name).  (l
0320: 65 74 2a 20 28 28 6b 65 79 73 74 72 20 20 20 20  et* ((keystr    
0330: 28 6b 65 79 73 2d 3e 6b 65 79 73 74 72 20 6b 65  (keys->keystr ke
0340: 79 73 29 29 0a 09 20 28 63 6f 6d 6d 61 20 20 20  ys)).. (comma   
0350: 20 20 28 69 66 20 28 3e 20 28 6c 65 6e 67 74 68    (if (> (length
0360: 20 6b 65 79 73 29 20 30 29 20 22 2c 22 20 22 22   keys) 0) "," ""
0370: 29 29 0a 09 20 28 61 6e 64 73 74 72 20 20 20 20  )).. (andstr    
0380: 28 69 66 20 28 3e 20 28 6c 65 6e 67 74 68 20 6b  (if (> (length k
0390: 65 79 73 29 20 30 29 20 22 20 41 4e 44 20 22 20  eys) 0) " AND " 
03a0: 22 22 29 29 0a 09 20 28 76 61 6c 73 6c 6f 74 73  "")).. (valslots
03b0: 20 20 28 6b 65 79 73 2d 3e 76 61 6c 73 6c 6f 74    (keys->valslot
03c0: 73 20 6b 65 79 73 29 29 20 3b 3b 20 3f 2c 3f 2c  s keys)) ;; ?,?,
03d0: 3f 20 2e 2e 2e 0a 09 20 28 6b 65 79 76 61 6c 6c  ? ..... (keyvall
03e0: 73 74 20 28 6b 65 79 73 2d 3e 76 61 6c 6c 69 73  st (keys->vallis
03f0: 74 20 6b 65 79 73 29 29 20 3b 3b 20 65 78 74 72  t keys)) ;; extr
0400: 61 63 74 73 20 74 68 65 20 76 61 6c 75 65 73 20  acts the values 
0410: 66 72 6f 6d 20 72 65 6d 61 69 6e 64 65 72 20 6f  from remainder o
0420: 66 20 28 61 72 67 76 29 0a 09 20 28 72 75 6e 6e  f (argv).. (runn
0430: 61 6d 65 20 20 20 28 67 65 74 2d 77 69 74 68 2d  ame   (get-with-
0440: 64 65 66 61 75 6c 74 20 22 3a 72 75 6e 6e 61 6d  default ":runnam
0450: 65 22 20 23 66 29 29 0a 09 20 28 73 74 61 74 65  e" #f)).. (state
0460: 20 20 20 20 20 28 67 65 74 2d 77 69 74 68 2d 64       (get-with-d
0470: 65 66 61 75 6c 74 20 22 3a 73 74 61 74 65 22 20  efault ":state" 
0480: 22 6e 6f 22 29 29 0a 09 20 28 73 74 61 74 75 73  "no")).. (status
0490: 20 20 20 20 28 67 65 74 2d 77 69 74 68 2d 64 65      (get-with-de
04a0: 66 61 75 6c 74 20 22 3a 73 74 61 74 75 73 22 20  fault ":status" 
04b0: 22 6e 2f 61 22 29 29 0a 09 20 28 61 6c 6c 76 61  "n/a")).. (allva
04c0: 6c 73 20 20 20 28 61 70 70 65 6e 64 20 28 6c 69  ls   (append (li
04d0: 73 74 20 72 75 6e 6e 61 6d 65 20 73 74 61 74 65  st runname state
04e0: 20 73 74 61 74 75 73 20 75 73 65 72 29 20 6b 65   status user) ke
04f0: 79 76 61 6c 6c 73 74 29 29 0a 09 20 28 71 72 79  yvallst)).. (qry
0500: 76 61 6c 73 20 20 20 28 61 70 70 65 6e 64 20 28  vals   (append (
0510: 6c 69 73 74 20 72 75 6e 6e 61 6d 65 29 20 6b 65  list runname) ke
0520: 79 76 61 6c 6c 73 74 29 29 0a 09 20 28 6b 65 79  yvallst)).. (key
0530: 3d 3f 73 74 72 20 20 28 73 74 72 69 6e 67 2d 69  =?str  (string-i
0540: 6e 74 65 72 73 70 65 72 73 65 20 28 6d 61 70 20  ntersperse (map 
0550: 28 6c 61 6d 62 64 61 20 28 6b 29 28 63 6f 6e 63  (lambda (k)(conc
0560: 20 28 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64 6e   (key:get-fieldn
0570: 61 6d 65 20 6b 29 20 22 3d 3f 22 29 29 20 6b 65  ame k) "=?")) ke
0580: 79 73 29 20 22 20 41 4e 44 20 22 29 29 29 0a 20  ys) " AND "))). 
0590: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
05a0: 33 20 22 6b 65 79 73 3a 20 22 20 6b 65 79 73 20  3 "keys: " keys 
05b0: 22 20 61 6c 6c 76 61 6c 73 3a 20 22 20 61 6c 6c  " allvals: " all
05c0: 76 61 6c 73 20 22 20 6b 65 79 76 61 6c 6c 73 74  vals " keyvallst
05d0: 3a 20 22 20 6b 65 79 76 61 6c 6c 73 74 29 0a 20  : " keyvallst). 
05e0: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
05f0: 32 20 22 4e 4f 54 45 3a 20 75 73 69 6e 67 20 6b  2 "NOTE: using k
0600: 65 79 20 22 20 28 73 74 72 69 6e 67 2d 69 6e 74  ey " (string-int
0610: 65 72 73 70 65 72 73 65 20 6b 65 79 76 61 6c 6c  ersperse keyvall
0620: 73 74 20 22 2f 22 29 20 22 20 66 6f 72 20 74 68  st "/") " for th
0630: 69 73 20 72 75 6e 22 29 0a 20 20 20 20 28 69 66  is run").    (if
0640: 20 28 61 6e 64 20 72 75 6e 6e 61 6d 65 20 28 6e   (and runname (n
0650: 75 6c 6c 3f 20 28 66 69 6c 74 65 72 20 28 6c 61  ull? (filter (la
0660: 6d 62 64 61 20 28 78 29 28 6e 6f 74 20 78 29 29  mbda (x)(not x))
0670: 20 6b 65 79 76 61 6c 6c 73 74 29 29 29 20 3b 3b   keyvallst))) ;;
0680: 20 74 68 65 72 65 20 6d 75 73 74 20 62 65 20 61   there must be a
0690: 20 62 65 74 74 65 72 20 77 61 79 20 74 6f 20 22   better way to "
06a0: 61 70 70 6c 79 20 61 6e 64 22 0a 09 28 6c 65 74  apply and"..(let
06b0: 20 28 28 72 65 73 20 23 66 29 29 0a 09 20 20 28   ((res #f))..  (
06c0: 61 70 70 6c 79 20 73 71 6c 69 74 65 33 3a 65 78  apply sqlite3:ex
06d0: 65 63 75 74 65 20 64 62 20 28 63 6f 6e 63 20 22  ecute db (conc "
06e0: 49 4e 53 45 52 54 20 4f 52 20 49 47 4e 4f 52 45  INSERT OR IGNORE
06f0: 20 49 4e 54 4f 20 72 75 6e 73 20 28 72 75 6e 6e   INTO runs (runn
0700: 61 6d 65 2c 73 74 61 74 65 2c 73 74 61 74 75 73  ame,state,status
0710: 2c 6f 77 6e 65 72 2c 65 76 65 6e 74 5f 74 69 6d  ,owner,event_tim
0720: 65 22 20 63 6f 6d 6d 61 20 6b 65 79 73 74 72 20  e" comma keystr 
0730: 22 29 20 56 41 4c 55 45 53 20 28 3f 2c 3f 2c 3f  ") VALUES (?,?,?
0740: 2c 3f 2c 73 74 72 66 74 69 6d 65 28 27 25 73 27  ,?,strftime('%s'
0750: 2c 27 6e 6f 77 27 29 22 20 63 6f 6d 6d 61 20 76  ,'now')" comma v
0760: 61 6c 73 6c 6f 74 73 20 22 29 3b 22 29 0a 09 09  alslots ");")...
0770: 20 61 6c 6c 76 61 6c 73 29 0a 09 20 20 28 61 70   allvals)..  (ap
0780: 70 6c 79 20 73 71 6c 69 74 65 33 3a 66 6f 72 2d  ply sqlite3:for-
0790: 65 61 63 68 2d 72 6f 77 20 0a 09 20 20 20 28 6c  each-row ..   (l
07a0: 61 6d 62 64 61 20 28 69 64 29 0a 09 20 20 20 20  ambda (id)..    
07b0: 20 28 73 65 74 21 20 72 65 73 20 69 64 29 29 0a   (set! res id)).
07c0: 09 20 20 20 64 62 0a 09 20 20 20 28 6c 65 74 20  .   db..   (let 
07d0: 28 28 71 72 79 20 28 63 6f 6e 63 20 22 53 45 4c  ((qry (conc "SEL
07e0: 45 43 54 20 69 64 20 46 52 4f 4d 20 72 75 6e 73  ECT id FROM runs
07f0: 20 57 48 45 52 45 20 28 72 75 6e 6e 61 6d 65 3d   WHERE (runname=
0800: 3f 20 22 20 61 6e 64 73 74 72 20 6b 65 79 3d 3f  ? " andstr key=?
0810: 73 74 72 20 22 29 3b 22 29 29 29 0a 09 20 20 20  str ");")))..   
0820: 20 20 3b 28 64 65 62 75 67 3a 70 72 69 6e 74 20    ;(debug:print 
0830: 34 20 22 71 72 79 3a 20 22 20 71 72 79 29 20 0a  4 "qry: " qry) .
0840: 09 20 20 20 20 20 71 72 79 29 0a 09 20 20 20 71  .     qry)..   q
0850: 72 79 76 61 6c 73 29 0a 09 20 20 28 73 71 6c 69  ryvals)..  (sqli
0860: 74 65 33 3a 65 78 65 63 75 74 65 20 64 62 20 22  te3:execute db "
0870: 55 50 44 41 54 45 20 72 75 6e 73 20 53 45 54 20  UPDATE runs SET 
0880: 73 74 61 74 65 3d 3f 2c 73 74 61 74 75 73 3d 3f  state=?,status=?
0890: 20 57 48 45 52 45 20 69 64 3d 3f 3b 22 20 73 74   WHERE id=?;" st
08a0: 61 74 65 20 73 74 61 74 75 73 20 72 65 73 29 0a  ate status res).
08b0: 09 20 20 72 65 73 29 20 0a 09 28 62 65 67 69 6e  .  res) ..(begin
08c0: 0a 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ..  (debug:print
08d0: 20 30 20 22 45 52 52 4f 52 3a 20 43 61 6c 6c 65   0 "ERROR: Calle
08e0: 64 20 77 69 74 68 6f 75 74 20 61 6c 6c 20 6e 65  d without all ne
08f0: 63 65 73 73 61 72 79 20 6b 65 79 73 22 29 0a 09  cessary keys")..
0900: 20 20 23 66 29 29 29 29 0a 0a 3b 3b 20 72 75 6e    #f))))..;; run
0910: 73 3a 67 65 74 2d 72 75 6e 73 2d 62 79 2d 70 61  s:get-runs-by-pa
0920: 74 74 0a 3b 3b 20 67 65 74 20 72 75 6e 73 20 62  tt.;; get runs b
0930: 79 20 6c 69 73 74 20 6f 66 20 63 72 69 74 65 72  y list of criter
0940: 69 61 0a 3b 3b 20 72 65 67 69 73 74 65 72 20 61  ia.;; register a
0950: 20 74 65 73 74 20 72 75 6e 20 77 69 74 68 20 74   test run with t
0960: 68 65 20 64 62 0a 3b 3b 0a 3b 3b 20 55 73 65 3a  he db.;;.;; Use:
0970: 20 28 64 62 2d 67 65 74 2d 76 61 6c 75 65 2d 62   (db-get-value-b
0980: 79 2d 68 65 61 64 65 72 20 28 64 62 3a 67 65 74  y-header (db:get
0990: 2d 68 65 61 64 65 72 20 72 75 6e 69 6e 66 6f 29  -header runinfo)
09a0: 28 64 62 3a 67 65 74 2d 72 6f 77 20 72 75 6e 69  (db:get-row runi
09b0: 6e 66 6f 29 29 0a 3b 3b 20 20 74 6f 20 65 78 74  nfo)).;;  to ext
09c0: 72 61 63 74 20 69 6e 66 6f 20 66 72 6f 6d 20 74  ract info from t
09d0: 68 65 20 73 74 72 75 63 74 75 72 65 20 72 65 74  he structure ret
09e0: 75 72 6e 65 64 0a 3b 3b 0a 28 64 65 66 69 6e 65  urned.;;.(define
09f0: 20 28 72 75 6e 73 3a 67 65 74 2d 72 75 6e 73 2d   (runs:get-runs-
0a00: 62 79 2d 70 61 74 74 20 64 62 20 6b 65 79 73 20  by-patt db keys 
0a10: 72 75 6e 6e 61 6d 65 70 61 74 74 20 2e 20 70 61  runnamepatt . pa
0a20: 72 61 6d 73 29 20 3b 3b 20 74 65 73 74 2d 6e 61  rams) ;; test-na
0a30: 6d 65 29 0a 20 20 28 6c 65 74 2a 20 28 28 6b 65  me).  (let* ((ke
0a40: 79 76 61 6c 6c 73 74 20 28 6b 65 79 73 2d 3e 76  yvallst (keys->v
0a50: 61 6c 6c 69 73 74 20 6b 65 79 73 29 29 0a 09 20  allist keys)).. 
0a60: 28 74 6d 70 20 20 20 20 20 20 28 72 75 6e 73 3a  (tmp      (runs:
0a70: 67 65 74 2d 73 74 64 2d 72 75 6e 2d 66 69 65 6c  get-std-run-fiel
0a80: 64 73 20 6b 65 79 73 20 27 28 22 69 64 22 20 22  ds keys '("id" "
0a90: 72 75 6e 6e 61 6d 65 22 20 22 73 74 61 74 65 22  runname" "state"
0aa0: 20 22 73 74 61 74 75 73 22 20 22 6f 77 6e 65 72   "status" "owner
0ab0: 22 20 22 65 76 65 6e 74 5f 74 69 6d 65 22 29 29  " "event_time"))
0ac0: 29 0a 09 20 28 6b 65 79 73 74 72 20 20 20 28 63  ).. (keystr   (c
0ad0: 61 72 20 74 6d 70 29 29 0a 09 20 28 68 65 61 64  ar tmp)).. (head
0ae0: 65 72 20 20 20 28 63 61 64 72 20 74 6d 70 29 29  er   (cadr tmp))
0af0: 0a 09 20 28 72 65 73 20 20 20 20 20 27 28 29 29  .. (res     '())
0b00: 0a 09 20 28 6b 65 79 2d 70 61 74 74 20 22 22 29  .. (key-patt "")
0b10: 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20  ).    (for-each 
0b20: 28 6c 61 6d 62 64 61 20 28 6b 65 79 76 61 6c 29  (lambda (keyval)
0b30: 0a 09 09 28 6c 65 74 2a 20 28 28 6b 65 79 20 20  ...(let* ((key  
0b40: 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20 6b 65    (vector-ref ke
0b50: 79 76 61 6c 20 30 29 29 0a 09 09 20 20 20 20 20  yval 0))...     
0b60: 20 20 28 66 75 6c 6b 65 79 20 28 63 6f 6e 63 20    (fulkey (conc 
0b70: 22 3a 22 20 6b 65 79 29 29 0a 09 09 20 20 20 20  ":" key))...    
0b80: 20 20 20 28 70 61 74 74 20 20 20 28 61 72 67 73     (patt   (args
0b90: 3a 67 65 74 2d 61 72 67 20 66 75 6c 6b 65 79 29  :get-arg fulkey)
0ba0: 29 29 0a 09 09 20 20 28 69 66 20 70 61 74 74 0a  ))...  (if patt.
0bb0: 09 09 20 20 20 20 20 20 28 73 65 74 21 20 6b 65  ..      (set! ke
0bc0: 79 2d 70 61 74 74 20 28 63 6f 6e 63 20 6b 65 79  y-patt (conc key
0bd0: 2d 70 61 74 74 20 22 20 41 4e 44 20 22 20 6b 65  -patt " AND " ke
0be0: 79 20 22 20 6c 69 6b 65 20 27 22 20 70 61 74 74  y " like '" patt
0bf0: 20 22 27 22 29 29 0a 09 09 20 20 20 20 20 20 28   "'"))...      (
0c00: 62 65 67 69 6e 0a 09 09 09 28 64 65 62 75 67 3a  begin....(debug:
0c10: 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20  print 0 "ERROR: 
0c20: 73 65 61 72 63 68 69 6e 67 20 66 6f 72 20 72 75  searching for ru
0c30: 6e 73 20 77 69 74 68 20 6e 6f 20 70 61 74 74 65  ns with no patte
0c40: 72 6e 20 73 65 74 20 66 6f 72 20 22 20 66 75 6c  rn set for " ful
0c50: 6b 65 79 29 0a 09 09 09 28 65 78 69 74 20 36 29  key)....(exit 6)
0c60: 29 29 29 29 0a 09 20 20 20 20 20 20 6b 65 79 73  ))))..      keys
0c70: 29 0a 20 20 20 20 28 73 71 6c 69 74 65 33 3a 66  ).    (sqlite3:f
0c80: 6f 72 2d 65 61 63 68 2d 72 6f 77 20 0a 20 20 20  or-each-row .   
0c90: 20 20 28 6c 61 6d 62 64 61 20 28 61 20 2e 20 72    (lambda (a . r
0ca0: 29 0a 20 20 20 20 20 20 20 28 73 65 74 21 20 72  ).       (set! r
0cb0: 65 73 20 28 63 6f 6e 73 20 28 6c 69 73 74 2d 3e  es (cons (list->
0cc0: 76 65 63 74 6f 72 20 28 63 6f 6e 73 20 61 20 72  vector (cons a r
0cd0: 29 29 20 72 65 73 29 29 29 0a 20 20 20 20 20 64  )) res))).     d
0ce0: 62 20 0a 20 20 20 20 20 28 63 6f 6e 63 20 22 53  b .     (conc "S
0cf0: 45 4c 45 43 54 20 22 20 6b 65 79 73 74 72 20 22  ELECT " keystr "
0d00: 20 46 52 4f 4d 20 72 75 6e 73 20 57 48 45 52 45   FROM runs WHERE
0d10: 20 72 75 6e 6e 61 6d 65 20 6c 69 6b 65 20 3f 20   runname like ? 
0d20: 22 20 6b 65 79 2d 70 61 74 74 20 22 3b 22 29 0a  " key-patt ";").
0d30: 20 20 20 20 20 72 75 6e 6e 61 6d 65 70 61 74 74       runnamepatt
0d40: 29 0a 20 20 20 20 28 76 65 63 74 6f 72 20 68 65  ).    (vector he
0d50: 61 64 65 72 20 72 65 73 29 29 29 0a 0a 28 64 65  ader res)))..(de
0d60: 66 69 6e 65 20 28 72 65 67 69 73 74 65 72 2d 74  fine (register-t
0d70: 65 73 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65  est db run-id te
0d80: 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74  st-name item-pat
0d90: 68 29 0a 20 20 28 6c 65 74 20 28 28 69 74 65 6d  h).  (let ((item
0da0: 2d 70 61 74 68 73 20 28 69 66 20 28 65 71 75 61  -paths (if (equa
0db0: 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29  l? item-path "")
0dc0: 0a 09 09 09 28 6c 69 73 74 20 69 74 65 6d 2d 70  ....(list item-p
0dd0: 61 74 68 29 0a 09 09 09 28 6c 69 73 74 20 69 74  ath)....(list it
0de0: 65 6d 2d 70 61 74 68 20 22 22 29 29 29 29 0a 20  em-path "")))). 
0df0: 20 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 20     (for-each .  
0e00: 20 20 20 28 6c 61 6d 62 64 61 20 28 70 74 68 29     (lambda (pth)
0e10: 0a 20 20 20 20 20 20 20 28 73 71 6c 69 74 65 33  .       (sqlite3
0e20: 3a 65 78 65 63 75 74 65 20 64 62 20 22 49 4e 53  :execute db "INS
0e30: 45 52 54 20 4f 52 20 49 47 4e 4f 52 45 20 49 4e  ERT OR IGNORE IN
0e40: 54 4f 20 74 65 73 74 73 20 28 72 75 6e 5f 69 64  TO tests (run_id
0e50: 2c 74 65 73 74 6e 61 6d 65 2c 65 76 65 6e 74 5f  ,testname,event_
0e60: 74 69 6d 65 2c 69 74 65 6d 5f 70 61 74 68 2c 73  time,item_path,s
0e70: 74 61 74 65 2c 73 74 61 74 75 73 29 20 56 41 4c  tate,status) VAL
0e80: 55 45 53 20 28 3f 2c 3f 2c 73 74 72 66 74 69 6d  UES (?,?,strftim
0e90: 65 28 27 25 73 27 2c 27 6e 6f 77 27 29 2c 3f 2c  e('%s','now'),?,
0ea0: 27 4e 4f 54 5f 53 54 41 52 54 45 44 27 2c 27 6e  'NOT_STARTED','n
0eb0: 2f 61 27 29 3b 22 20 0a 09 09 09 72 75 6e 2d 69  /a');" ....run-i
0ec0: 64 20 0a 09 09 09 74 65 73 74 2d 6e 61 6d 65 0a  d ....test-name.
0ed0: 09 09 09 70 74 68 20 0a 09 09 09 3b 3b 20 28 63  ...pth ....;; (c
0ee0: 6f 6e 63 20 22 2c 22 20 28 73 74 72 69 6e 67 2d  onc "," (string-
0ef0: 69 6e 74 65 72 73 70 65 72 73 65 20 74 61 67 73  intersperse tags
0f00: 20 22 2c 22 29 20 22 2c 22 29 0a 09 09 09 29 29   ",") ",")....))
0f10: 0a 20 20 20 20 20 69 74 65 6d 2d 70 61 74 68 73  .     item-paths
0f20: 20 29 29 29 0a 0a 3b 3b 20 67 65 74 20 74 68 65   )))..;; get the
0f30: 20 70 72 65 76 69 6f 75 73 20 72 65 63 6f 72 64   previous record
0f40: 20 66 6f 72 20 77 68 65 6e 20 74 68 69 73 20 74   for when this t
0f50: 65 73 74 20 77 61 73 20 72 75 6e 20 77 68 65 72  est was run wher
0f60: 65 20 61 6c 6c 20 6b 65 79 73 20 6d 61 74 63 68  e all keys match
0f70: 20 62 75 74 20 72 75 6e 6e 61 6d 65 0a 3b 3b 20   but runname.;; 
0f80: 72 65 74 75 72 6e 73 20 23 66 20 69 66 20 6e 6f  returns #f if no
0f90: 20 73 75 63 68 20 74 65 73 74 20 66 6f 75 6e 64   such test found
0fa0: 2c 20 72 65 74 75 72 6e 73 20 61 20 73 69 6e 67  , returns a sing
0fb0: 6c 65 20 74 65 73 74 20 72 65 63 6f 72 64 20 69  le test record i
0fc0: 66 20 66 6f 75 6e 64 0a 28 64 65 66 69 6e 65 20  f found.(define 
0fd0: 28 74 65 73 74 3a 67 65 74 2d 70 72 65 76 69 6f  (test:get-previo
0fe0: 75 73 2d 74 65 73 74 2d 72 75 6e 2d 72 65 63 6f  us-test-run-reco
0ff0: 72 64 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  rd db run-id tes
1000: 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68  t-name item-path
1010: 29 0a 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 73  ).  (let* ((keys
1020: 20 20 20 20 28 64 62 3a 67 65 74 2d 6b 65 79 73      (db:get-keys
1030: 20 64 62 29 29 0a 09 20 28 73 65 6c 73 74 72 20   db)).. (selstr 
1040: 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70   (string-intersp
1050: 65 72 73 65 20 28 6d 61 70 20 28 6c 61 6d 62 64  erse (map (lambd
1060: 61 20 28 78 29 28 76 65 63 74 6f 72 2d 72 65 66  a (x)(vector-ref
1070: 20 78 20 30 29 29 20 6b 65 79 73 29 20 22 2c 22   x 0)) keys) ","
1080: 29 29 0a 09 20 28 71 72 79 73 74 72 20 20 28 73  )).. (qrystr  (s
1090: 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73  tring-interspers
10a0: 65 20 28 6d 61 70 20 28 6c 61 6d 62 64 61 20 28  e (map (lambda (
10b0: 78 29 28 63 6f 6e 63 20 28 76 65 63 74 6f 72 2d  x)(conc (vector-
10c0: 72 65 66 20 78 20 30 29 20 22 3d 3f 22 29 29 20  ref x 0) "=?")) 
10d0: 6b 65 79 73 29 20 22 20 41 4e 44 20 22 29 29 0a  keys) " AND ")).
10e0: 09 20 28 6b 65 79 76 61 6c 73 20 23 66 29 29 0a  . (keyvals #f)).
10f0: 20 20 20 20 3b 3b 20 66 69 72 73 74 20 6c 6f 6f      ;; first loo
1100: 6b 20 75 70 20 74 68 65 20 6b 65 79 20 76 61 6c  k up the key val
1110: 75 65 73 20 66 72 6f 6d 20 74 68 65 20 72 75 6e  ues from the run
1120: 20 73 65 6c 65 63 74 65 64 20 62 79 20 72 75 6e   selected by run
1130: 2d 69 64 0a 20 20 20 20 28 73 71 6c 69 74 65 33  -id.    (sqlite3
1140: 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77 20 0a 20  :for-each-row . 
1150: 20 20 20 20 28 6c 61 6d 62 64 61 20 28 61 20 2e      (lambda (a .
1160: 20 62 29 0a 20 20 20 20 20 20 20 28 73 65 74 21   b).       (set!
1170: 20 6b 65 79 76 61 6c 73 20 28 63 6f 6e 73 20 61   keyvals (cons a
1180: 20 62 29 29 29 0a 20 20 20 20 20 64 62 0a 20 20   b))).     db.  
1190: 20 20 20 28 63 6f 6e 63 20 22 53 45 4c 45 43 54     (conc "SELECT
11a0: 20 22 20 73 65 6c 73 74 72 20 22 20 46 52 4f 4d   " selstr " FROM
11b0: 20 72 75 6e 73 20 57 48 45 52 45 20 69 64 3d 3f   runs WHERE id=?
11c0: 20 4f 52 44 45 52 20 42 59 20 65 76 65 6e 74 5f   ORDER BY event_
11d0: 74 69 6d 65 20 44 45 53 43 3b 22 29 20 72 75 6e  time DESC;") run
11e0: 2d 69 64 29 0a 20 20 20 20 28 69 66 20 28 6e 6f  -id).    (if (no
11f0: 74 20 6b 65 79 76 61 6c 73 29 0a 09 23 66 0a 09  t keyvals)..#f..
1200: 28 6c 65 74 20 28 28 70 72 65 76 2d 72 75 6e 2d  (let ((prev-run-
1210: 69 64 73 20 27 28 29 29 29 0a 09 20 20 28 61 70  ids '()))..  (ap
1220: 70 6c 79 20 73 71 6c 69 74 65 33 3a 66 6f 72 2d  ply sqlite3:for-
1230: 65 61 63 68 2d 72 6f 77 0a 09 09 20 28 6c 61 6d  each-row... (lam
1240: 62 64 61 20 28 69 64 29 0a 09 09 20 20 20 28 73  bda (id)...   (s
1250: 65 74 21 20 70 72 65 76 2d 72 75 6e 2d 69 64 73  et! prev-run-ids
1260: 20 28 63 6f 6e 73 20 69 64 20 70 72 65 76 2d 72   (cons id prev-r
1270: 75 6e 2d 69 64 73 29 29 29 0a 09 09 20 64 62 0a  un-ids)))... db.
1280: 09 09 20 28 63 6f 6e 63 20 22 53 45 4c 45 43 54  .. (conc "SELECT
1290: 20 69 64 20 46 52 4f 4d 20 72 75 6e 73 20 57 48   id FROM runs WH
12a0: 45 52 45 20 22 20 71 72 79 73 74 72 20 22 20 41  ERE " qrystr " A
12b0: 4e 44 20 69 64 20 21 3d 20 3f 3b 22 29 20 28 61  ND id != ?;") (a
12c0: 70 70 65 6e 64 20 6b 65 79 76 61 6c 73 20 28 6c  ppend keyvals (l
12d0: 69 73 74 20 72 75 6e 2d 69 64 29 29 29 0a 09 20  ist run-id))).. 
12e0: 20 3b 3b 20 66 6f 72 20 65 61 63 68 20 72 75 6e   ;; for each run
12f0: 20 73 74 61 72 74 69 6e 67 20 77 69 74 68 20 74   starting with t
1300: 68 65 20 6d 6f 73 74 20 72 65 63 65 6e 74 20 6c  he most recent l
1310: 6f 6f 6b 20 74 6f 20 73 65 65 20 69 66 20 74 68  ook to see if th
1320: 65 72 65 20 69 73 20 61 20 6d 61 74 63 68 69 6e  ere is a matchin
1330: 67 20 74 65 73 74 0a 09 20 20 3b 3b 20 69 66 20  g test..  ;; if 
1340: 66 6f 75 6e 64 20 74 68 65 6e 20 72 65 74 75 72  found then retur
1350: 6e 20 74 68 61 74 20 6d 61 74 63 68 69 6e 67 20  n that matching 
1360: 74 65 73 74 20 72 65 63 6f 72 64 0a 09 20 20 28  test record..  (
1370: 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 73  debug:print 4 "s
1380: 65 6c 73 74 72 3a 20 22 20 73 65 6c 73 74 72 20  elstr: " selstr 
1390: 22 2c 20 71 72 79 73 74 72 3a 20 22 20 71 72 79  ", qrystr: " qry
13a0: 73 74 72 20 22 2c 20 6b 65 79 76 61 6c 73 3a 20  str ", keyvals: 
13b0: 22 20 6b 65 79 76 61 6c 73 20 22 2c 20 70 72 65  " keyvals ", pre
13c0: 76 69 6f 75 73 20 72 75 6e 20 69 64 73 20 66 6f  vious run ids fo
13d0: 75 6e 64 3a 20 22 20 70 72 65 76 2d 72 75 6e 2d  und: " prev-run-
13e0: 69 64 73 29 0a 09 20 20 28 69 66 20 28 6e 75 6c  ids)..  (if (nul
13f0: 6c 3f 20 70 72 65 76 2d 72 75 6e 2d 69 64 73 29  l? prev-run-ids)
1400: 20 23 66 0a 09 20 20 20 20 20 20 28 6c 65 74 20   #f..      (let 
1410: 6c 6f 6f 70 20 28 28 68 65 64 20 28 63 61 72 20  loop ((hed (car 
1420: 70 72 65 76 2d 72 75 6e 2d 69 64 73 29 29 0a 09  prev-run-ids))..
1430: 09 09 20 28 74 61 6c 20 28 63 64 72 20 70 72 65  .. (tal (cdr pre
1440: 76 2d 72 75 6e 2d 69 64 73 29 29 29 0a 09 09 28  v-run-ids)))...(
1450: 6c 65 74 20 28 28 72 65 73 75 6c 74 73 20 28 64  let ((results (d
1460: 62 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d  b-get-tests-for-
1470: 72 75 6e 20 64 62 20 68 65 64 20 74 65 73 74 2d  run db hed test-
1480: 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 20 27  name item-path '
1490: 28 29 20 27 28 29 29 29 29 0a 09 09 20 20 28 64  () '())))...  (d
14a0: 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 47 6f  ebug:print 4 "Go
14b0: 74 20 74 65 73 74 73 20 66 6f 72 20 72 75 6e 2d  t tests for run-
14c0: 69 64 20 22 20 72 75 6e 2d 69 64 20 22 2c 20 74  id " run-id ", t
14d0: 65 73 74 2d 6e 61 6d 65 20 22 20 74 65 73 74 2d  est-name " test-
14e0: 6e 61 6d 65 20 22 2c 20 69 74 65 6d 2d 70 61 74  name ", item-pat
14f0: 68 20 22 20 69 74 65 6d 2d 70 61 74 68 20 22 3a  h " item-path ":
1500: 20 22 20 72 65 73 75 6c 74 73 29 0a 09 09 20 20   " results)...  
1510: 28 69 66 20 28 61 6e 64 20 28 6e 75 6c 6c 3f 20  (if (and (null? 
1520: 72 65 73 75 6c 74 73 29 0a 09 09 09 20 20 20 28  results)....   (
1530: 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 61 6c 29 29  not (null? tal))
1540: 29 0a 09 09 20 20 20 20 20 20 28 6c 6f 6f 70 20  )...      (loop 
1550: 28 63 61 72 20 74 61 6c 29 28 63 64 72 20 74 61  (car tal)(cdr ta
1560: 6c 29 29 0a 09 09 20 20 20 20 20 20 28 69 66 20  l))...      (if 
1570: 28 6e 75 6c 6c 3f 20 72 65 73 75 6c 74 73 29 20  (null? results) 
1580: 23 66 0a 09 09 09 20 20 28 63 61 72 20 72 65 73  #f....  (car res
1590: 75 6c 74 73 29 29 29 29 29 29 29 29 29 29 0a 20  ults)))))))))). 
15a0: 20 20 20 0a 3b 3b 20 67 65 74 20 74 68 65 20 70     .;; get the p
15b0: 72 65 76 69 6f 75 73 20 72 65 63 6f 72 64 73 20  revious records 
15c0: 66 6f 72 20 77 68 65 6e 20 74 68 65 73 65 20 74  for when these t
15d0: 65 73 74 73 20 77 65 72 65 20 72 75 6e 20 77 68  ests were run wh
15e0: 65 72 65 20 61 6c 6c 20 6b 65 79 73 20 6d 61 74  ere all keys mat
15f0: 63 68 20 62 75 74 20 72 75 6e 6e 61 6d 65 0a 3b  ch but runname.;
1600: 3b 20 4e 42 2f 2f 20 4d 65 72 67 65 20 74 68 69  ; NB// Merge thi
1610: 73 20 77 69 74 68 20 74 65 73 74 3a 67 65 74 2d  s with test:get-
1620: 70 72 65 76 69 6f 75 73 2d 74 65 73 74 2d 72 75  previous-test-ru
1630: 6e 2d 72 65 63 6f 72 64 73 3f 20 54 68 69 73 20  n-records? This 
1640: 6f 6e 65 20 6c 6f 6f 6b 73 20 66 6f 72 20 61 6c  one looks for al
1650: 6c 20 6d 61 74 63 68 69 6e 67 20 74 65 73 74 73  l matching tests
1660: 0a 3b 3b 20 63 61 6e 20 75 73 65 20 77 69 6c 64  .;; can use wild
1670: 63 61 72 64 73 2e 20 0a 28 64 65 66 69 6e 65 20  cards. .(define 
1680: 28 74 65 73 74 3a 67 65 74 2d 6d 61 74 63 68 69  (test:get-matchi
1690: 6e 67 2d 70 72 65 76 69 6f 75 73 2d 74 65 73 74  ng-previous-test
16a0: 2d 72 75 6e 2d 72 65 63 6f 72 64 73 20 64 62 20  -run-records db 
16b0: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
16c0: 20 69 74 65 6d 2d 70 61 74 68 29 0a 20 20 28 6c   item-path).  (l
16d0: 65 74 2a 20 28 28 6b 65 79 73 20 20 20 20 28 64  et* ((keys    (d
16e0: 62 3a 67 65 74 2d 6b 65 79 73 20 64 62 29 29 0a  b:get-keys db)).
16f0: 09 20 28 73 65 6c 73 74 72 20 20 28 73 74 72 69  . (selstr  (stri
1700: 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 28  ng-intersperse (
1710: 6d 61 70 20 28 6c 61 6d 62 64 61 20 28 78 29 28  map (lambda (x)(
1720: 76 65 63 74 6f 72 2d 72 65 66 20 78 20 30 29 29  vector-ref x 0))
1730: 20 6b 65 79 73 29 20 22 2c 22 29 29 0a 09 20 28   keys) ",")).. (
1740: 71 72 79 73 74 72 20 20 28 73 74 72 69 6e 67 2d  qrystr  (string-
1750: 69 6e 74 65 72 73 70 65 72 73 65 20 28 6d 61 70  intersperse (map
1760: 20 28 6c 61 6d 62 64 61 20 28 78 29 28 63 6f 6e   (lambda (x)(con
1770: 63 20 28 76 65 63 74 6f 72 2d 72 65 66 20 78 20  c (vector-ref x 
1780: 30 29 20 22 3d 3f 22 29 29 20 6b 65 79 73 29 20  0) "=?")) keys) 
1790: 22 20 41 4e 44 20 22 29 29 0a 09 20 28 6b 65 79  " AND ")).. (key
17a0: 76 61 6c 73 20 23 66 29 0a 09 20 28 74 65 73 74  vals #f).. (test
17b0: 73 2d 68 61 73 68 20 28 6d 61 6b 65 2d 68 61 73  s-hash (make-has
17c0: 68 2d 74 61 62 6c 65 29 29 29 0a 20 20 20 20 3b  h-table))).    ;
17d0: 3b 20 66 69 72 73 74 20 6c 6f 6f 6b 20 75 70 20  ; first look up 
17e0: 74 68 65 20 6b 65 79 20 76 61 6c 75 65 73 20 66  the key values f
17f0: 72 6f 6d 20 74 68 65 20 72 75 6e 20 73 65 6c 65  rom the run sele
1800: 63 74 65 64 20 62 79 20 72 75 6e 2d 69 64 0a 20  cted by run-id. 
1810: 20 20 20 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d     (sqlite3:for-
1820: 65 61 63 68 2d 72 6f 77 20 0a 20 20 20 20 20 28  each-row .     (
1830: 6c 61 6d 62 64 61 20 28 61 20 2e 20 62 29 0a 20  lambda (a . b). 
1840: 20 20 20 20 20 20 28 73 65 74 21 20 6b 65 79 76        (set! keyv
1850: 61 6c 73 20 28 63 6f 6e 73 20 61 20 62 29 29 29  als (cons a b)))
1860: 0a 20 20 20 20 20 64 62 0a 20 20 20 20 20 28 63  .     db.     (c
1870: 6f 6e 63 20 22 53 45 4c 45 43 54 20 22 20 73 65  onc "SELECT " se
1880: 6c 73 74 72 20 22 20 46 52 4f 4d 20 72 75 6e 73  lstr " FROM runs
1890: 20 57 48 45 52 45 20 69 64 3d 3f 20 4f 52 44 45   WHERE id=? ORDE
18a0: 52 20 42 59 20 65 76 65 6e 74 5f 74 69 6d 65 20  R BY event_time 
18b0: 44 45 53 43 3b 22 29 20 72 75 6e 2d 69 64 29 0a  DESC;") run-id).
18c0: 20 20 20 20 28 69 66 20 28 6e 6f 74 20 6b 65 79      (if (not key
18d0: 76 61 6c 73 29 0a 09 27 28 29 0a 09 28 6c 65 74  vals)..'()..(let
18e0: 20 28 28 70 72 65 76 2d 72 75 6e 2d 69 64 73 20   ((prev-run-ids 
18f0: 27 28 29 29 29 0a 09 20 20 28 61 70 70 6c 79 20  '()))..  (apply 
1900: 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68  sqlite3:for-each
1910: 2d 72 6f 77 0a 09 09 20 28 6c 61 6d 62 64 61 20  -row... (lambda 
1920: 28 69 64 29 0a 09 09 20 20 20 28 73 65 74 21 20  (id)...   (set! 
1930: 70 72 65 76 2d 72 75 6e 2d 69 64 73 20 28 63 6f  prev-run-ids (co
1940: 6e 73 20 69 64 20 70 72 65 76 2d 72 75 6e 2d 69  ns id prev-run-i
1950: 64 73 29 29 29 0a 09 09 20 64 62 0a 09 09 20 28  ds)))... db... (
1960: 63 6f 6e 63 20 22 53 45 4c 45 43 54 20 69 64 20  conc "SELECT id 
1970: 46 52 4f 4d 20 72 75 6e 73 20 57 48 45 52 45 20  FROM runs WHERE 
1980: 22 20 71 72 79 73 74 72 20 22 20 41 4e 44 20 69  " qrystr " AND i
1990: 64 20 21 3d 20 3f 3b 22 29 20 28 61 70 70 65 6e  d != ?;") (appen
19a0: 64 20 6b 65 79 76 61 6c 73 20 28 6c 69 73 74 20  d keyvals (list 
19b0: 72 75 6e 2d 69 64 29 29 29 0a 09 20 20 3b 3b 20  run-id)))..  ;; 
19c0: 63 6f 6c 6c 65 63 74 20 61 6c 6c 20 6d 61 74 63  collect all matc
19d0: 68 69 6e 67 20 74 65 73 74 73 20 66 6f 72 20 74  hing tests for t
19e0: 68 65 20 72 75 6e 73 20 74 68 65 6e 0a 09 20 20  he runs then..  
19f0: 3b 3b 20 65 78 74 72 61 63 74 20 74 68 65 20 6d  ;; extract the m
1a00: 6f 73 74 20 72 65 63 65 6e 74 20 74 65 73 74 20  ost recent test 
1a10: 61 6e 64 20 72 65 74 75 72 6e 20 74 68 61 74 2e  and return that.
1a20: 0a 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ..  (debug:print
1a30: 20 34 20 22 73 65 6c 73 74 72 3a 20 22 20 73 65   4 "selstr: " se
1a40: 6c 73 74 72 20 22 2c 20 71 72 79 73 74 72 3a 20  lstr ", qrystr: 
1a50: 22 20 71 72 79 73 74 72 20 22 2c 20 6b 65 79 76  " qrystr ", keyv
1a60: 61 6c 73 3a 20 22 20 6b 65 79 76 61 6c 73 20 0a  als: " keyvals .
1a70: 09 09 20 20 20 20 20 20 20 22 2c 20 70 72 65 76  ..       ", prev
1a80: 69 6f 75 73 20 72 75 6e 20 69 64 73 20 66 6f 75  ious run ids fou
1a90: 6e 64 3a 20 22 20 70 72 65 76 2d 72 75 6e 2d 69  nd: " prev-run-i
1aa0: 64 73 29 0a 09 20 20 28 69 66 20 28 6e 75 6c 6c  ds)..  (if (null
1ab0: 3f 20 70 72 65 76 2d 72 75 6e 2d 69 64 73 29 20  ? prev-run-ids) 
1ac0: 27 28 29 20 20 3b 3b 20 6e 6f 20 70 72 65 76 69  '()  ;; no previ
1ad0: 6f 75 73 20 72 75 6e 73 3f 20 72 65 74 75 72 6e  ous runs? return
1ae0: 20 6e 75 6c 6c 0a 09 20 20 20 20 20 20 28 6c 65   null..      (le
1af0: 74 20 6c 6f 6f 70 20 28 28 68 65 64 20 28 63 61  t loop ((hed (ca
1b00: 72 20 70 72 65 76 2d 72 75 6e 2d 69 64 73 29 29  r prev-run-ids))
1b10: 0a 09 09 09 20 28 74 61 6c 20 28 63 64 72 20 70  .... (tal (cdr p
1b20: 72 65 76 2d 72 75 6e 2d 69 64 73 29 29 29 0a 09  rev-run-ids)))..
1b30: 09 28 6c 65 74 20 28 28 72 65 73 75 6c 74 73 20  .(let ((results 
1b40: 28 64 62 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f  (db-get-tests-fo
1b50: 72 2d 72 75 6e 20 64 62 20 68 65 64 20 74 65 73  r-run db hed tes
1b60: 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68  t-name item-path
1b70: 20 27 28 29 20 27 28 29 29 29 29 0a 09 09 20 20   '() '())))...  
1b80: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22  (debug:print 4 "
1b90: 47 6f 74 20 74 65 73 74 73 20 66 6f 72 20 72 75  Got tests for ru
1ba0: 6e 2d 69 64 20 22 20 72 75 6e 2d 69 64 20 22 2c  n-id " run-id ",
1bb0: 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 74 65 73   test-name " tes
1bc0: 74 2d 6e 61 6d 65 20 0a 09 09 09 20 20 20 20 20  t-name ....     
1bd0: 20 20 22 2c 20 69 74 65 6d 2d 70 61 74 68 20 22    ", item-path "
1be0: 20 69 74 65 6d 2d 70 61 74 68 20 22 20 72 65 73   item-path " res
1bf0: 75 6c 74 73 3a 20 22 20 28 69 6e 74 65 72 73 70  ults: " (intersp
1c00: 65 72 73 65 20 72 65 73 75 6c 74 73 20 22 5c 6e  erse results "\n
1c10: 22 29 29 0a 09 09 20 20 3b 3b 20 4b 65 65 70 20  "))...  ;; Keep 
1c20: 6f 6e 6c 79 20 74 68 65 20 79 6f 75 6e 67 65 73  only the younges
1c30: 74 20 6f 66 20 61 6e 79 20 74 65 73 74 2f 69 74  t of any test/it
1c40: 65 6d 20 63 6f 6d 62 69 6e 61 74 69 6f 6e 0a 09  em combination..
1c50: 09 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 09 09  .  (for-each ...
1c60: 20 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74     (lambda (test
1c70: 64 61 74 29 0a 09 09 20 20 20 20 20 28 6c 65 74  dat)...     (let
1c80: 2a 20 28 28 66 75 6c 6c 2d 74 65 73 74 6e 61 6d  * ((full-testnam
1c90: 65 20 28 63 6f 6e 63 20 28 64 62 3a 74 65 73 74  e (conc (db:test
1ca0: 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 74 65  -get-testname te
1cb0: 73 74 64 61 74 29 20 22 2f 22 20 28 64 62 3a 74  stdat) "/" (db:t
1cc0: 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74  est-get-item-pat
1cd0: 68 20 74 65 73 74 64 61 74 29 29 29 0a 09 09 09  h testdat)))....
1ce0: 20 20 20 20 28 73 74 6f 72 65 64 2d 74 65 73 74      (stored-test
1cf0: 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72     (hash-table-r
1d00: 65 66 2f 64 65 66 61 75 6c 74 20 74 65 73 74 73  ef/default tests
1d10: 2d 68 61 73 68 20 66 75 6c 6c 2d 74 65 73 74 6e  -hash full-testn
1d20: 61 6d 65 20 23 66 29 29 29 0a 09 09 20 20 20 20  ame #f)))...    
1d30: 20 20 20 28 69 66 20 28 6f 72 20 28 6e 6f 74 20     (if (or (not 
1d40: 73 74 6f 72 65 64 2d 74 65 73 74 29 0a 09 09 09  stored-test)....
1d50: 20 20 20 20 20 20 20 28 61 6e 64 20 73 74 6f 72         (and stor
1d60: 65 64 2d 74 65 73 74 0a 09 09 09 09 20 20 20 20  ed-test.....    
1d70: 28 3e 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  (> (db:test-get-
1d80: 65 76 65 6e 74 5f 74 69 6d 65 20 74 65 73 74 64  event_time testd
1d90: 61 74 29 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  at)(db:test-get-
1da0: 65 76 65 6e 74 5f 74 69 6d 65 20 73 74 6f 72 65  event_time store
1db0: 64 2d 74 65 73 74 29 29 29 29 0a 09 09 09 20 20  d-test))))....  
1dc0: 20 3b 3b 20 74 68 69 73 20 74 65 73 74 20 69 73   ;; this test is
1dd0: 20 79 6f 75 6e 67 65 72 2c 20 73 74 6f 72 65 20   younger, store 
1de0: 69 74 20 69 6e 20 74 68 65 20 68 61 73 68 0a 09  it in the hash..
1df0: 09 09 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65  ..   (hash-table
1e00: 2d 73 65 74 21 20 74 65 73 74 73 2d 68 61 73 68  -set! tests-hash
1e10: 20 66 75 6c 6c 2d 74 65 73 74 6e 61 6d 65 20 74   full-testname t
1e20: 65 73 74 64 61 74 29 29 29 29 0a 09 09 20 20 20  estdat))))...   
1e30: 72 65 73 75 6c 74 73 29 0a 09 09 20 20 28 69 66  results)...  (if
1e40: 20 28 6e 75 6c 6c 3f 20 74 61 6c 29 0a 09 09 20   (null? tal)... 
1e50: 20 20 20 20 20 28 6d 61 70 20 63 64 72 20 28 68       (map cdr (h
1e60: 61 73 68 2d 74 61 62 6c 65 2d 3e 61 6c 69 73 74  ash-table->alist
1e70: 20 74 65 73 74 73 2d 68 61 73 68 29 29 20 3b 3b   tests-hash)) ;;
1e80: 20 72 65 74 75 72 6e 20 61 20 6c 69 73 74 20 6f   return a list o
1e90: 66 20 74 68 65 20 6d 6f 73 74 20 72 65 63 65 6e  f the most recen
1ea0: 74 20 74 65 73 74 73 0a 09 09 20 20 20 20 20 20  t tests...      
1eb0: 28 6c 6f 6f 70 20 28 63 61 72 20 74 61 6c 29 28  (loop (car tal)(
1ec0: 63 64 72 20 74 61 6c 29 29 29 29 29 29 29 29 29  cdr tal)))))))))
1ed0: 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73 74  )..(define (test
1ee0: 2d 73 65 74 2d 73 74 61 74 75 73 21 20 64 62 20  -set-status! db 
1ef0: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
1f00: 20 73 74 61 74 65 20 73 74 61 74 75 73 20 69 74   state status it
1f10: 65 6d 64 61 74 2d 6f 72 2d 70 61 74 68 20 63 6f  emdat-or-path co
1f20: 6d 6d 65 6e 74 20 64 61 74 29 0a 20 20 28 6c 65  mment dat).  (le
1f30: 74 2a 20 28 28 72 65 61 6c 2d 73 74 61 74 75 73  t* ((real-status
1f40: 20 73 74 61 74 75 73 29 0a 09 20 28 69 74 65 6d   status).. (item
1f50: 2d 70 61 74 68 20 20 20 28 69 66 20 28 73 74 72  -path   (if (str
1f60: 69 6e 67 3f 20 69 74 65 6d 64 61 74 2d 6f 72 2d  ing? itemdat-or-
1f70: 70 61 74 68 29 20 69 74 65 6d 64 61 74 2d 6f 72  path) itemdat-or
1f80: 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c 69 73 74  -path (item-list
1f90: 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74 2d 6f  ->path itemdat-o
1fa0: 72 2d 70 61 74 68 29 29 29 0a 09 20 28 74 65 73  r-path))).. (tes
1fb0: 74 64 61 74 20 20 20 20 20 28 64 62 3a 67 65 74  tdat     (db:get
1fc0: 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 20 72 75  -test-info db ru
1fd0: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69  n-id test-name i
1fe0: 74 65 6d 2d 70 61 74 68 29 29 0a 09 20 28 74 65  tem-path)).. (te
1ff0: 73 74 2d 69 64 20 20 20 20 20 28 69 66 20 74 65  st-id     (if te
2000: 73 74 64 61 74 20 28 64 62 3a 74 65 73 74 2d 67  stdat (db:test-g
2010: 65 74 2d 69 64 20 74 65 73 74 64 61 74 29 20 23  et-id testdat) #
2020: 66 29 29 0a 09 20 28 6f 74 68 65 72 64 61 74 20  f)).. (otherdat 
2030: 20 20 20 28 69 66 20 64 61 74 20 64 61 74 20 28     (if dat dat (
2040: 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 29  make-hash-table)
2050: 29 29 0a 09 20 3b 3b 20 62 65 66 6f 72 65 20 70  )).. ;; before p
2060: 72 6f 63 65 65 64 69 6e 67 20 77 65 20 6d 75 73  roceeding we mus
2070: 74 20 66 69 6e 64 20 6f 75 74 20 69 66 20 74 68  t find out if th
2080: 65 20 70 72 65 76 69 6f 75 73 20 74 65 73 74 20  e previous test 
2090: 28 77 68 65 72 65 20 61 6c 6c 20 6b 65 79 73 20  (where all keys 
20a0: 6d 61 74 63 68 65 64 20 65 78 63 65 70 74 20 72  matched except r
20b0: 75 6e 6e 61 6d 65 29 0a 09 20 3b 3b 20 77 61 73  unname).. ;; was
20c0: 20 57 41 49 56 45 44 20 69 66 20 74 68 69 73 20   WAIVED if this 
20d0: 74 65 73 74 20 69 73 20 46 41 49 4c 0a 09 20 28  test is FAIL.. (
20e0: 77 61 69 76 65 64 20 20 20 28 69 66 20 28 65 71  waived   (if (eq
20f0: 75 61 6c 3f 20 73 74 61 74 75 73 20 22 46 41 49  ual? status "FAI
2100: 4c 22 29 0a 09 09 20 20 20 20 20 20 20 28 6c 65  L")...       (le
2110: 74 20 28 28 70 72 65 76 2d 74 65 73 74 20 28 74  t ((prev-test (t
2120: 65 73 74 3a 67 65 74 2d 70 72 65 76 69 6f 75 73  est:get-previous
2130: 2d 74 65 73 74 2d 72 75 6e 2d 72 65 63 6f 72 64  -test-run-record
2140: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d   db run-id test-
2150: 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29  name item-path))
2160: 29 0a 09 09 09 20 28 69 66 20 70 72 65 76 2d 74  ).... (if prev-t
2170: 65 73 74 20 3b 3b 20 74 72 75 65 20 69 66 20 77  est ;; true if w
2180: 65 20 66 6f 75 6e 64 20 61 20 70 72 65 76 69 6f  e found a previo
2190: 75 73 20 74 65 73 74 20 69 6e 20 74 68 69 73 20  us test in this 
21a0: 72 75 6e 20 73 65 72 69 65 73 0a 09 09 09 20 20  run series....  
21b0: 20 20 20 28 6c 65 74 20 28 28 70 72 65 76 2d 73     (let ((prev-s
21c0: 74 61 74 75 73 20 28 64 62 3a 74 65 73 74 2d 67  tatus (db:test-g
21d0: 65 74 2d 73 74 61 74 75 73 20 20 20 70 72 65 76  et-status   prev
21e0: 2d 74 65 73 74 29 29 0a 09 09 09 09 20 20 20 28  -test)).....   (
21f0: 70 72 65 76 2d 73 74 61 74 65 20 20 28 64 62 3a  prev-state  (db:
2200: 74 65 73 74 2d 67 65 74 2d 73 74 61 74 65 20 20  test-get-state  
2210: 20 20 70 72 65 76 2d 74 65 73 74 29 29 0a 09 09    prev-test))...
2220: 09 09 20 20 20 28 70 72 65 76 2d 63 6f 6d 6d 65  ..   (prev-comme
2230: 6e 74 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  nt (db:test-get-
2240: 63 6f 6d 6d 65 6e 74 20 70 72 65 76 2d 74 65 73  comment prev-tes
2250: 74 29 29 29 0a 09 09 09 20 20 20 20 20 20 20 28  t)))....       (
2260: 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 70  debug:print 4 "p
2270: 72 65 76 2d 73 74 61 74 75 73 20 22 20 70 72 65  rev-status " pre
2280: 76 2d 73 74 61 74 75 73 20 22 2c 20 70 72 65 76  v-status ", prev
2290: 2d 73 74 61 74 65 20 22 20 70 72 65 76 2d 73 74  -state " prev-st
22a0: 61 74 65 20 22 2c 20 70 72 65 76 2d 63 6f 6d 6d  ate ", prev-comm
22b0: 65 6e 74 20 22 20 70 72 65 76 2d 63 6f 6d 6d 65  ent " prev-comme
22c0: 6e 74 29 0a 09 09 09 20 20 20 20 20 20 20 28 69  nt)....       (i
22d0: 66 20 28 61 6e 64 20 28 65 71 75 61 6c 3f 20 70  f (and (equal? p
22e0: 72 65 76 2d 73 74 61 74 65 20 20 22 43 4f 4d 50  rev-state  "COMP
22f0: 4c 45 54 45 44 22 29 0a 09 09 09 09 09 28 65 71  LETED")......(eq
2300: 75 61 6c 3f 20 70 72 65 76 2d 73 74 61 74 75 73  ual? prev-status
2310: 20 22 57 41 49 56 45 44 22 29 29 0a 09 09 09 09   "WAIVED")).....
2320: 20 20 20 70 72 65 76 2d 63 6f 6d 6d 65 6e 74 20     prev-comment 
2330: 3b 3b 20 77 61 69 76 65 64 20 69 73 20 65 69 74  ;; waived is eit
2340: 68 65 72 20 74 68 65 20 63 6f 6d 6d 65 6e 74 20  her the comment 
2350: 6f 72 20 23 66 0a 09 09 09 09 20 20 20 23 66 29  or #f.....   #f)
2360: 29 0a 09 09 09 20 20 20 20 20 23 66 29 29 0a 09  )....     #f))..
2370: 09 20 20 20 20 20 20 20 23 66 29 29 29 0a 20 20  .       #f))).  
2380: 20 20 28 69 66 20 77 61 69 76 65 64 20 28 73 65    (if waived (se
2390: 74 21 20 72 65 61 6c 2d 73 74 61 74 75 73 20 22  t! real-status "
23a0: 57 41 49 56 45 44 22 29 29 0a 20 20 20 20 28 64  WAIVED")).    (d
23b0: 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 72 65  ebug:print 4 "re
23c0: 61 6c 2d 73 74 61 74 75 73 20 22 20 72 65 61 6c  al-status " real
23d0: 2d 73 74 61 74 75 73 20 22 2c 20 77 61 69 76 65  -status ", waive
23e0: 64 20 22 20 77 61 69 76 65 64 20 22 2c 20 73 74  d " waived ", st
23f0: 61 74 75 73 20 22 20 73 74 61 74 75 73 29 0a 0a  atus " status)..
2400: 20 20 20 20 3b 3b 20 75 70 64 61 74 65 20 74 68      ;; update th
2410: 65 20 70 72 69 6d 61 72 79 20 72 65 63 6f 72 64  e primary record
2420: 20 49 46 20 73 74 61 74 65 20 41 4e 44 20 73 74   IF state AND st
2430: 61 74 75 73 20 61 72 65 20 64 65 66 69 6e 65 64  atus are defined
2440: 0a 20 20 20 20 28 69 66 20 28 61 6e 64 20 73 74  .    (if (and st
2450: 61 74 65 20 73 74 61 74 75 73 29 0a 09 28 73 71  ate status)..(sq
2460: 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 64 62  lite3:execute db
2470: 20 22 55 50 44 41 54 45 20 74 65 73 74 73 20 53   "UPDATE tests S
2480: 45 54 20 73 74 61 74 65 3d 3f 2c 73 74 61 74 75  ET state=?,statu
2490: 73 3d 3f 2c 65 76 65 6e 74 5f 74 69 6d 65 3d 73  s=?,event_time=s
24a0: 74 72 66 74 69 6d 65 28 27 25 73 27 2c 27 6e 6f  trftime('%s','no
24b0: 77 27 29 20 57 48 45 52 45 20 72 75 6e 5f 69 64  w') WHERE run_id
24c0: 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d  =? AND testname=
24d0: 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d  ? AND item_path=
24e0: 3f 3b 22 20 0a 09 09 09 20 73 74 61 74 65 20 72  ?;" .... state r
24f0: 65 61 6c 2d 73 74 61 74 75 73 20 72 75 6e 2d 69  eal-status run-i
2500: 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d  d test-name item
2510: 2d 70 61 74 68 29 29 0a 0a 20 20 20 20 3b 3b 20  -path))..    ;; 
2520: 69 66 20 73 74 61 74 75 73 20 69 73 20 22 41 55  if status is "AU
2530: 54 4f 22 20 74 68 65 6e 20 63 61 6c 6c 20 72 6f  TO" then call ro
2540: 6c 6c 75 70 0a 20 20 20 20 28 69 66 20 28 61 6e  llup.    (if (an
2550: 64 20 74 65 73 74 2d 69 64 20 73 74 61 74 65 20  d test-id state 
2560: 73 74 61 74 75 73 20 28 65 71 75 61 6c 3f 20 73  status (equal? s
2570: 74 61 74 75 73 20 22 41 55 54 4f 22 29 29 20 0a  tatus "AUTO")) .
2580: 09 28 64 62 3a 74 65 73 74 2d 64 61 74 61 2d 72  .(db:test-data-r
2590: 6f 6c 6c 75 70 20 64 62 20 74 65 73 74 2d 69 64  ollup db test-id
25a0: 29 29 0a 0a 20 20 20 20 3b 3b 20 61 64 64 20 6d  ))..    ;; add m
25b0: 65 74 61 64 61 74 61 20 28 6e 65 65 64 20 74 6f  etadata (need to
25c0: 20 64 6f 20 74 68 69 73 20 77 61 79 20 74 6f 20   do this way to 
25d0: 61 76 6f 69 64 20 53 51 4c 20 69 6e 6a 65 63 74  avoid SQL inject
25e0: 69 6f 6e 20 69 73 73 75 65 73 29 0a 0a 20 20 20  ion issues)..   
25f0: 20 3b 3b 20 3a 66 69 72 73 74 5f 65 72 72 0a 20   ;; :first_err. 
2600: 20 20 20 28 6c 65 74 20 28 28 76 61 6c 20 28 68     (let ((val (h
2610: 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65  ash-table-ref/de
2620: 66 61 75 6c 74 20 6f 74 68 65 72 64 61 74 20 22  fault otherdat "
2630: 3a 66 69 72 73 74 5f 65 72 72 22 20 23 66 29 29  :first_err" #f))
2640: 29 0a 20 20 20 20 20 20 28 69 66 20 76 61 6c 0a  ).      (if val.
2650: 09 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63  .  (sqlite3:exec
2660: 75 74 65 20 64 62 20 22 55 50 44 41 54 45 20 74  ute db "UPDATE t
2670: 65 73 74 73 20 53 45 54 20 66 69 72 73 74 5f 65  ests SET first_e
2680: 72 72 3d 3f 20 57 48 45 52 45 20 72 75 6e 5f 69  rr=? WHERE run_i
2690: 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65  d=? AND testname
26a0: 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68  =? AND item_path
26b0: 3d 3f 3b 22 20 76 61 6c 20 72 75 6e 2d 69 64 20  =?;" val run-id 
26c0: 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70  test-name item-p
26d0: 61 74 68 29 29 29 0a 0a 20 20 20 20 3b 3b 20 3a  ath)))..    ;; :
26e0: 66 69 72 73 74 5f 77 61 72 6e 0a 20 20 20 20 28  first_warn.    (
26f0: 6c 65 74 20 28 28 76 61 6c 20 28 68 61 73 68 2d  let ((val (hash-
2700: 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c  table-ref/defaul
2710: 74 20 6f 74 68 65 72 64 61 74 20 22 3a 66 69 72  t otherdat ":fir
2720: 73 74 5f 77 61 72 6e 22 20 23 66 29 29 29 0a 20  st_warn" #f))). 
2730: 20 20 20 20 20 28 69 66 20 76 61 6c 0a 09 20 20       (if val..  
2740: 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65  (sqlite3:execute
2750: 20 64 62 20 22 55 50 44 41 54 45 20 74 65 73 74   db "UPDATE test
2760: 73 20 53 45 54 20 66 69 72 73 74 5f 77 61 72 6e  s SET first_warn
2770: 3d 3f 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d  =? WHERE run_id=
2780: 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f  ? AND testname=?
2790: 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f   AND item_path=?
27a0: 3b 22 20 76 61 6c 20 72 75 6e 2d 69 64 20 74 65  ;" val run-id te
27b0: 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74  st-name item-pat
27c0: 68 29 29 29 0a 0a 20 20 20 20 28 6c 65 74 20 28  h)))..    (let (
27d0: 28 63 61 74 65 67 6f 72 79 20 28 68 61 73 68 2d  (category (hash-
27e0: 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c  table-ref/defaul
27f0: 74 20 6f 74 68 65 72 64 61 74 20 22 3a 63 61 74  t otherdat ":cat
2800: 65 67 6f 72 79 22 20 22 22 29 29 0a 09 20 20 28  egory" ""))..  (
2810: 76 61 72 69 61 62 6c 65 20 28 68 61 73 68 2d 74  variable (hash-t
2820: 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74  able-ref/default
2830: 20 6f 74 68 65 72 64 61 74 20 22 3a 76 61 72 69   otherdat ":vari
2840: 61 62 6c 65 22 20 22 22 29 29 0a 09 20 20 28 76  able" ""))..  (v
2850: 61 6c 75 65 20 20 20 20 28 68 61 73 68 2d 74 61  alue    (hash-ta
2860: 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20  ble-ref/default 
2870: 6f 74 68 65 72 64 61 74 20 22 3a 76 61 6c 75 65  otherdat ":value
2880: 22 20 20 20 20 23 66 29 29 0a 09 20 20 28 65 78  "    #f))..  (ex
2890: 70 65 63 74 65 64 20 28 68 61 73 68 2d 74 61 62  pected (hash-tab
28a0: 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 6f  le-ref/default o
28b0: 74 68 65 72 64 61 74 20 22 3a 65 78 70 65 63 74  therdat ":expect
28c0: 65 64 22 20 23 66 29 29 0a 09 20 20 28 74 6f 6c  ed" #f))..  (tol
28d0: 20 20 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c        (hash-tabl
28e0: 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 6f 74  e-ref/default ot
28f0: 68 65 72 64 61 74 20 22 3a 74 6f 6c 22 20 20 20  herdat ":tol"   
2900: 20 20 20 23 66 29 29 0a 09 20 20 28 75 6e 69 74     #f))..  (unit
2910: 73 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65  s    (hash-table
2920: 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 6f 74 68  -ref/default oth
2930: 65 72 64 61 74 20 22 3a 75 6e 69 74 73 22 20 20  erdat ":units"  
2940: 20 20 22 22 29 29 0a 09 20 20 28 64 63 6f 6d 6d    ""))..  (dcomm
2950: 65 6e 74 20 28 68 61 73 68 2d 74 61 62 6c 65 2d  ent (hash-table-
2960: 72 65 66 2f 64 65 66 61 75 6c 74 20 6f 74 68 65  ref/default othe
2970: 72 64 61 74 20 22 3a 63 6f 6d 6d 65 6e 74 22 20  rdat ":comment" 
2980: 20 22 22 29 29 29 0a 20 20 20 20 20 20 28 64 65   ""))).      (de
2990: 62 75 67 3a 70 72 69 6e 74 20 34 20 0a 09 09 20  bug:print 4 ... 
29a0: 20 20 22 63 61 74 65 67 6f 72 79 3a 20 22 20 63    "category: " c
29b0: 61 74 65 67 6f 72 79 20 22 2c 20 76 61 72 69 61  ategory ", varia
29c0: 62 6c 65 3a 20 22 20 76 61 72 69 61 62 6c 65 20  ble: " variable 
29d0: 22 2c 20 76 61 6c 75 65 3a 20 22 20 76 61 6c 75  ", value: " valu
29e0: 65 0a 09 09 20 20 20 22 2c 20 65 78 70 65 63 74  e...   ", expect
29f0: 65 64 3a 20 22 20 65 78 70 65 63 74 65 64 20 22  ed: " expected "
2a00: 2c 20 74 6f 6c 3a 20 22 20 74 6f 6c 20 22 2c 20  , tol: " tol ", 
2a10: 75 6e 69 74 73 3a 20 22 20 75 6e 69 74 73 29 0a  units: " units).
2a20: 20 20 20 20 20 20 28 69 66 20 28 61 6e 64 20 76        (if (and v
2a30: 61 6c 75 65 20 65 78 70 65 63 74 65 64 20 74 6f  alue expected to
2a40: 6c 29 20 3b 3b 20 61 6c 6c 20 74 68 72 65 65 20  l) ;; all three 
2a50: 72 65 71 75 69 72 65 64 0a 09 20 20 28 64 62 3a  required..  (db:
2a60: 63 73 76 2d 3e 74 65 73 74 2d 64 61 74 61 20 64  csv->test-data d
2a70: 62 20 74 65 73 74 2d 69 64 20 0a 09 09 09 20 20  b test-id ....  
2a80: 20 20 20 28 63 6f 6e 63 20 63 61 74 65 67 6f 72     (conc categor
2a90: 79 20 22 2c 22 0a 09 09 09 09 20 20 20 76 61 72  y ",".....   var
2aa0: 69 61 62 6c 65 20 22 2c 22 0a 09 09 09 09 20 20  iable ",".....  
2ab0: 20 76 61 6c 75 65 20 20 20 20 22 2c 22 0a 09 09   value    ","...
2ac0: 09 09 20 20 20 65 78 70 65 63 74 65 64 20 22 2c  ..   expected ",
2ad0: 22 0a 09 09 09 09 20 20 20 74 6f 6c 20 20 20 20  ".....   tol    
2ae0: 20 20 22 2c 22 0a 09 09 09 09 20 20 20 75 6e 69    ",".....   uni
2af0: 74 73 20 20 20 20 22 2c 22 0a 09 09 09 09 20 20  ts    ",".....  
2b00: 20 64 63 6f 6d 6d 65 6e 74 20 22 2c 22 29 29 29   dcomment ",")))
2b10: 29 0a 09 09 09 09 20 20 20 0a 20 20 20 20 3b 3b  ).....   .    ;;
2b20: 20 6e 65 65 64 20 74 6f 20 75 70 64 61 74 65 20   need to update 
2b30: 74 68 65 20 74 6f 70 20 74 65 73 74 20 72 65 63  the top test rec
2b40: 6f 72 64 20 69 66 20 50 41 53 53 20 6f 72 20 46  ord if PASS or F
2b50: 41 49 4c 20 61 6e 64 20 74 68 69 73 20 69 73 20  AIL and this is 
2b60: 61 20 73 75 62 74 65 73 74 0a 20 20 20 20 28 69  a subtest.    (i
2b70: 66 20 28 61 6e 64 20 28 6e 6f 74 20 28 65 71 75  f (and (not (equ
2b80: 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 22  al? item-path ""
2b90: 29 29 0a 09 20 20 20 20 20 28 6f 72 20 28 65 71  ))..     (or (eq
2ba0: 75 61 6c 3f 20 73 74 61 74 75 73 20 22 50 41 53  ual? status "PAS
2bb0: 53 22 29 0a 09 09 20 28 65 71 75 61 6c 3f 20 73  S")... (equal? s
2bc0: 74 61 74 75 73 20 22 57 41 52 4e 22 29 0a 09 09  tatus "WARN")...
2bd0: 20 28 65 71 75 61 6c 3f 20 73 74 61 74 75 73 20   (equal? status 
2be0: 22 46 41 49 4c 22 29 0a 09 09 20 28 65 71 75 61  "FAIL")... (equa
2bf0: 6c 3f 20 73 74 61 74 75 73 20 22 57 41 49 56 45  l? status "WAIVE
2c00: 44 22 29 0a 09 09 20 28 65 71 75 61 6c 3f 20 73  D")... (equal? s
2c10: 74 61 74 75 73 20 22 52 55 4e 4e 49 4e 47 22 29  tatus "RUNNING")
2c20: 29 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 28 73  ))..(begin..  (s
2c30: 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 0a  qlite3:execute .
2c40: 09 20 20 20 64 62 0a 09 20 20 20 22 55 50 44 41  .   db..   "UPDA
2c50: 54 45 20 74 65 73 74 73 20 0a 20 20 20 20 20 20  TE tests .      
2c60: 20 20 20 20 20 20 20 53 45 54 20 66 61 69 6c 5f         SET fail_
2c70: 63 6f 75 6e 74 3d 28 53 45 4c 45 43 54 20 63 6f  count=(SELECT co
2c80: 75 6e 74 28 69 64 29 20 46 52 4f 4d 20 74 65 73  unt(id) FROM tes
2c90: 74 73 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d  ts WHERE run_id=
2ca0: 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f  ? AND testname=?
2cb0: 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 20 21   AND item_path !
2cc0: 3d 20 27 27 20 41 4e 44 20 73 74 61 74 75 73 3d  = '' AND status=
2cd0: 27 46 41 49 4c 27 29 2c 0a 20 20 20 20 20 20 20  'FAIL'),.       
2ce0: 20 20 20 20 20 20 20 20 20 20 70 61 73 73 5f 63            pass_c
2cf0: 6f 75 6e 74 3d 28 53 45 4c 45 43 54 20 63 6f 75  ount=(SELECT cou
2d00: 6e 74 28 69 64 29 20 46 52 4f 4d 20 74 65 73 74  nt(id) FROM test
2d10: 73 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f  s WHERE run_id=?
2d20: 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20   AND testname=? 
2d30: 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 20 21 3d  AND item_path !=
2d40: 20 27 27 20 41 4e 44 20 28 73 74 61 74 75 73 3d   '' AND (status=
2d50: 27 50 41 53 53 27 20 4f 52 20 73 74 61 74 75 73  'PASS' OR status
2d60: 3d 27 57 41 52 4e 27 20 4f 52 20 73 74 61 74 75  ='WARN' OR statu
2d70: 73 3d 27 57 41 49 56 45 44 27 29 29 0a 20 20 20  s='WAIVED')).   
2d80: 20 20 20 20 20 20 20 20 20 20 57 48 45 52 45 20            WHERE 
2d90: 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73  run_id=? AND tes
2da0: 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d  tname=? AND item
2db0: 5f 70 61 74 68 3d 27 27 3b 22 0a 09 20 20 20 72  _path='';"..   r
2dc0: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
2dd0: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
2de0: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
2df0: 65 29 0a 09 20 20 28 69 66 20 28 65 71 75 61 6c  e)..  (if (equal
2e00: 3f 20 73 74 61 74 75 73 20 22 52 55 4e 4e 49 4e  ? status "RUNNIN
2e10: 47 22 29 20 3b 3b 20 72 75 6e 6e 69 6e 67 20 74  G") ;; running t
2e20: 61 6b 65 73 20 70 72 69 6f 72 69 74 79 20 6f 76  akes priority ov
2e30: 65 72 20 61 6c 6c 20 6f 74 68 65 72 20 73 74 61  er all other sta
2e40: 74 65 73 2c 20 66 6f 72 63 65 20 74 68 65 20 74  tes, force the t
2e50: 65 73 74 20 73 74 61 74 65 20 74 6f 20 52 55 4e  est state to RUN
2e60: 4e 49 4e 47 0a 09 20 20 20 20 20 20 28 73 71 6c  NING..      (sql
2e70: 69 74 65 33 3a 65 78 65 63 75 74 65 20 64 62 20  ite3:execute db 
2e80: 22 55 50 44 41 54 45 20 74 65 73 74 73 20 53 45  "UPDATE tests SE
2e90: 54 20 73 74 61 74 65 3d 3f 20 57 48 45 52 45 20  T state=? WHERE 
2ea0: 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73  run_id=? AND tes
2eb0: 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d  tname=? AND item
2ec0: 5f 70 61 74 68 3d 27 27 3b 22 20 72 75 6e 2d 69  _path='';" run-i
2ed0: 64 20 74 65 73 74 2d 6e 61 6d 65 29 0a 09 20 20  d test-name)..  
2ee0: 20 20 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65      (sqlite3:exe
2ef0: 63 75 74 65 0a 09 20 20 20 20 20 20 20 64 62 0a  cute..       db.
2f00: 09 20 20 20 20 20 20 20 22 55 50 44 41 54 45 20  .       "UPDATE 
2f10: 74 65 73 74 73 0a 20 20 20 20 20 20 20 20 20 20  tests.          
2f20: 20 20 20 20 20 20 20 20 20 20 20 20 20 53 45 54               SET
2f30: 20 73 74 61 74 65 3d 43 41 53 45 20 57 48 45 4e   state=CASE WHEN
2f40: 20 28 53 45 4c 45 43 54 20 63 6f 75 6e 74 28 69   (SELECT count(i
2f50: 64 29 20 46 52 4f 4d 20 74 65 73 74 73 20 57 48  d) FROM tests WH
2f60: 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44  ERE run_id=? AND
2f70: 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20   testname=? AND 
2f80: 69 74 65 6d 5f 70 61 74 68 20 21 3d 20 27 27 20  item_path != '' 
2f90: 41 4e 44 20 73 74 61 74 65 20 69 6e 20 28 27 52  AND state in ('R
2fa0: 55 4e 4e 49 4e 47 27 2c 27 4e 4f 54 5f 53 54 41  UNNING','NOT_STA
2fb0: 52 54 45 44 27 29 29 20 3e 20 30 20 54 48 45 4e  RTED')) > 0 THEN
2fc0: 20 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20   .              
2fd0: 20 20 20 20 20 20 20 20 20 20 20 20 27 52 55 4e              'RUN
2fe0: 4e 49 4e 47 27 0a 20 20 20 20 20 20 20 20 20 20  NING'.          
2ff0: 20 20 20 20 20 20 20 20 20 20 20 20 20 45 4c 53               ELS
3000: 45 20 27 43 4f 4d 50 4c 45 54 45 44 27 20 45 4e  E 'COMPLETED' EN
3010: 44 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  D,.             
3020: 20 20 20 20 20 20 20 20 20 20 20 20 20 73 74 61               sta
3030: 74 75 73 3d 43 41 53 45 20 57 48 45 4e 20 66 61  tus=CASE WHEN fa
3040: 69 6c 5f 63 6f 75 6e 74 20 3e 20 30 20 54 48 45  il_count > 0 THE
3050: 4e 20 27 46 41 49 4c 27 20 57 48 45 4e 20 70 61  N 'FAIL' WHEN pa
3060: 73 73 5f 63 6f 75 6e 74 20 3e 20 30 20 41 4e 44  ss_count > 0 AND
3070: 20 66 61 69 6c 5f 63 6f 75 6e 74 3d 30 20 54 48   fail_count=0 TH
3080: 45 4e 20 27 50 41 53 53 27 20 45 4c 53 45 20 27  EN 'PASS' ELSE '
3090: 55 4e 4b 4e 4f 57 4e 27 20 45 4e 44 0a 20 20 20  UNKNOWN' END.   
30a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
30b0: 20 20 20 20 57 48 45 52 45 20 72 75 6e 5f 69 64      WHERE run_id
30c0: 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d  =? AND testname=
30d0: 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d  ? AND item_path=
30e0: 27 27 3b 22 0a 09 20 20 20 20 20 20 20 72 75 6e  '';"..       run
30f0: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 72 75  -id test-name ru
3100: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 29 29  n-id test-name))
3110: 29 29 0a 20 20 20 20 28 69 66 20 28 6f 72 20 28  )).    (if (or (
3120: 61 6e 64 20 28 73 74 72 69 6e 67 3f 20 63 6f 6d  and (string? com
3130: 6d 65 6e 74 29 0a 09 09 20 28 73 74 72 69 6e 67  ment)... (string
3140: 2d 6d 61 74 63 68 20 28 72 65 67 65 78 70 20 22  -match (regexp "
3150: 5c 5c 53 2b 22 29 20 63 6f 6d 6d 65 6e 74 29 29  \\S+") comment))
3160: 0a 09 20 20 20 20 77 61 69 76 65 64 29 0a 09 28  ..    waived)..(
3170: 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20  sqlite3:execute 
3180: 64 62 20 22 55 50 44 41 54 45 20 74 65 73 74 73  db "UPDATE tests
3190: 20 53 45 54 20 63 6f 6d 6d 65 6e 74 3d 3f 20 57   SET comment=? W
31a0: 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e  HERE run_id=? AN
31b0: 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44  D testname=? AND
31c0: 20 69 74 65 6d 5f 70 61 74 68 3d 3f 3b 22 0a 09   item_path=?;"..
31d0: 09 09 20 28 69 66 20 77 61 69 76 65 64 20 77 61  .. (if waived wa
31e0: 69 76 65 64 20 63 6f 6d 6d 65 6e 74 29 20 72 75  ived comment) ru
31f0: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69  n-id test-name i
3200: 74 65 6d 2d 70 61 74 68 29 29 0a 20 20 20 20 29  tem-path)).    )
3210: 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73 74  )..(define (test
3220: 2d 73 65 74 2d 6c 6f 67 21 20 64 62 20 72 75 6e  -set-log! db run
3230: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74  -id test-name it
3240: 65 6d 64 61 74 20 6c 6f 67 66 29 20 0a 20 20 28  emdat logf) .  (
3250: 6c 65 74 20 28 28 69 74 65 6d 2d 70 61 74 68 20  let ((item-path 
3260: 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68  (item-list->path
3270: 20 69 74 65 6d 64 61 74 29 29 29 0a 20 20 20 20   itemdat))).    
3280: 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65  (sqlite3:execute
3290: 20 64 62 20 22 55 50 44 41 54 45 20 74 65 73 74   db "UPDATE test
32a0: 73 20 53 45 54 20 66 69 6e 61 6c 5f 6c 6f 67 66  s SET final_logf
32b0: 3d 3f 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d  =? WHERE run_id=
32c0: 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f  ? AND testname=?
32d0: 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f   AND item_path=?
32e0: 3b 22 20 0a 09 09 20 20 20 20 20 6c 6f 67 66 20  ;" ...     logf 
32f0: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
3300: 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 0a 28   item-path)))..(
3310: 64 65 66 69 6e 65 20 28 74 65 73 74 2d 73 65 74  define (test-set
3320: 2d 74 6f 70 6c 6f 67 21 20 64 62 20 72 75 6e 2d  -toplog! db run-
3330: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 6c 6f 67  id test-name log
3340: 66 29 20 0a 20 20 28 73 71 6c 69 74 65 33 3a 65  f) .  (sqlite3:e
3350: 78 65 63 75 74 65 20 64 62 20 22 55 50 44 41 54  xecute db "UPDAT
3360: 45 20 74 65 73 74 73 20 53 45 54 20 66 69 6e 61  E tests SET fina
3370: 6c 5f 6c 6f 67 66 3d 3f 20 57 48 45 52 45 20 72  l_logf=? WHERE r
3380: 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74  un_id=? AND test
3390: 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f  name=? AND item_
33a0: 70 61 74 68 3d 27 27 3b 22 20 0a 09 09 20 20 20  path='';" ...   
33b0: 6c 6f 67 66 20 72 75 6e 2d 69 64 20 74 65 73 74  logf run-id test
33c0: 2d 6e 61 6d 65 29 29 0a 0a 28 64 65 66 69 6e 65  -name))..(define
33d0: 20 28 74 65 73 74 73 3a 73 75 6d 6d 61 72 69 7a   (tests:summariz
33e0: 65 2d 69 74 65 6d 73 20 64 62 20 72 75 6e 2d 69  e-items db run-i
33f0: 64 20 74 65 73 74 2d 6e 61 6d 65 20 66 6f 72 63  d test-name forc
3400: 65 29 0a 20 20 3b 3b 20 69 66 20 6e 6f 74 20 66  e).  ;; if not f
3410: 6f 72 63 65 20 74 68 65 6e 20 6f 6e 6c 79 20 75  orce then only u
3420: 70 64 61 74 65 20 74 68 65 20 72 65 63 6f 72 64  pdate the record
3430: 20 69 66 20 6f 6e 65 20 6f 66 20 74 68 65 73 65   if one of these
3440: 20 69 73 20 74 72 75 65 3a 0a 20 20 3b 3b 20 20   is true:.  ;;  
3450: 20 31 2e 20 6c 6f 67 66 20 69 73 20 22 6c 6f 67   1. logf is "log
3460: 2f 66 69 6e 61 6c 2e 6c 6f 67 0a 20 20 3b 3b 20  /final.log.  ;; 
3470: 20 20 32 2e 20 6c 6f 67 66 20 69 73 20 73 61 6d    2. logf is sam
3480: 65 20 61 73 20 6f 75 74 70 75 74 66 69 6c 65 6e  e as outputfilen
3490: 61 6d 65 0a 20 20 28 6c 65 74 20 28 28 6f 75 74  ame.  (let ((out
34a0: 70 75 74 66 69 6c 65 6e 61 6d 65 20 28 63 6f 6e  putfilename (con
34b0: 63 20 22 6d 65 67 61 74 65 73 74 2d 72 6f 6c 6c  c "megatest-roll
34c0: 75 70 2d 22 20 74 65 73 74 2d 6e 61 6d 65 20 22  up-" test-name "
34d0: 2e 68 74 6d 6c 22 29 29 0a 09 28 6f 72 69 67 2d  .html"))..(orig-
34e0: 64 69 72 20 20 20 20 20 20 20 28 63 75 72 72 65  dir       (curre
34f0: 6e 74 2d 64 69 72 65 63 74 6f 72 79 29 29 0a 09  nt-directory))..
3500: 28 6c 6f 67 66 20 20 20 20 20 20 20 20 20 20 20  (logf           
3510: 23 66 29 29 0a 20 20 20 20 28 73 71 6c 69 74 65  #f)).    (sqlite
3520: 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77 20 0a  3:for-each-row .
3530: 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 70 61       (lambda (pa
3540: 74 68 20 66 69 6e 61 6c 5f 6c 6f 67 66 29 0a 20  th final_logf). 
3550: 20 20 20 20 20 20 28 73 65 74 21 20 6c 6f 67 66        (set! logf
3560: 20 66 69 6e 61 6c 5f 6c 6f 67 66 29 0a 20 20 20   final_logf).   
3570: 20 20 20 20 28 69 66 20 28 64 69 72 65 63 74 6f      (if (directo
3580: 72 79 3f 20 70 61 74 68 29 0a 09 20 20 20 28 62  ry? path)..   (b
3590: 65 67 69 6e 0a 09 20 20 20 20 20 28 70 72 69 6e  egin..     (prin
35a0: 74 20 22 46 6f 75 6e 64 20 70 61 74 68 3a 20 22  t "Found path: "
35b0: 20 70 61 74 68 29 0a 09 20 20 20 20 20 28 63 68   path)..     (ch
35c0: 61 6e 67 65 2d 64 69 72 65 63 74 6f 72 79 20 70  ange-directory p
35d0: 61 74 68 29 29 0a 09 20 20 20 20 20 3b 3b 20 28  ath))..     ;; (
35e0: 73 65 74 21 20 6f 75 74 70 75 74 66 69 6c 65 6e  set! outputfilen
35f0: 61 6d 65 20 28 63 6f 6e 63 20 70 61 74 68 20 22  ame (conc path "
3600: 2f 22 20 6f 75 74 70 75 74 66 69 6c 65 6e 61 6d  /" outputfilenam
3610: 65 29 29 29 0a 09 20 20 20 28 70 72 69 6e 74 20  e)))..   (print 
3620: 22 4e 6f 20 73 75 63 68 20 70 61 74 68 3a 20 22  "No such path: "
3630: 20 70 61 74 68 29 29 29 0a 20 20 20 20 20 64 62   path))).     db
3640: 20 0a 20 20 20 20 20 22 53 45 4c 45 43 54 20 72   .     "SELECT r
3650: 75 6e 64 69 72 2c 66 69 6e 61 6c 5f 6c 6f 67 66  undir,final_logf
3660: 20 46 52 4f 4d 20 74 65 73 74 73 20 57 48 45 52   FROM tests WHER
3670: 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74  E run_id=? AND t
3680: 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74  estname=? AND it
3690: 65 6d 5f 70 61 74 68 3d 27 27 3b 22 0a 20 20 20  em_path='';".   
36a0: 20 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61    run-id test-na
36b0: 6d 65 29 0a 20 20 20 20 28 70 72 69 6e 74 20 22  me).    (print "
36c0: 73 75 6d 6d 61 72 69 7a 65 2d 69 74 65 6d 73 20  summarize-items 
36d0: 77 69 74 68 20 6c 6f 67 66 20 22 20 6c 6f 67 66  with logf " logf
36e0: 29 0a 20 20 20 20 28 69 66 20 28 6f 72 20 28 65  ).    (if (or (e
36f0: 71 75 61 6c 3f 20 6c 6f 67 66 20 22 6c 6f 67 73  qual? logf "logs
3700: 2f 66 69 6e 61 6c 2e 6c 6f 67 22 29 0a 09 20 20  /final.log")..  
3710: 20 20 28 65 71 75 61 6c 3f 20 6c 6f 67 66 20 6f    (equal? logf o
3720: 75 74 70 75 74 66 69 6c 65 6e 61 6d 65 29 0a 09  utputfilename)..
3730: 20 20 20 20 66 6f 72 63 65 29 0a 09 28 62 65 67      force)..(beg
3740: 69 6e 0a 09 20 20 28 69 66 20 28 6f 62 74 61 69  in..  (if (obtai
3750: 6e 2d 64 6f 74 2d 6c 6f 63 6b 20 6f 75 74 70 75  n-dot-lock outpu
3760: 74 66 69 6c 65 6e 61 6d 65 20 31 20 32 30 20 33  tfilename 1 20 3
3770: 30 29 20 3b 3b 20 72 65 74 72 79 20 65 76 65 72  0) ;; retry ever
3780: 79 20 73 65 63 6f 6e 64 20 66 6f 72 20 32 30 20  y second for 20 
3790: 73 65 63 6f 6e 64 73 2c 20 63 61 6c 6c 20 69 74  seconds, call it
37a0: 20 64 65 61 64 20 61 66 74 65 72 20 33 30 20 73   dead after 30 s
37b0: 65 63 6f 6e 64 73 20 61 6e 64 20 73 74 65 61 6c  econds and steal
37c0: 20 74 68 65 20 6c 6f 63 6b 0a 09 20 20 20 20 20   the lock..     
37d0: 20 28 70 72 69 6e 74 20 22 4f 62 74 61 69 6e 65   (print "Obtaine
37e0: 64 20 6c 6f 63 6b 20 66 6f 72 20 22 20 6f 75 74  d lock for " out
37f0: 70 75 74 66 69 6c 65 6e 61 6d 65 29 0a 09 20 20  putfilename)..  
3800: 20 20 20 20 28 70 72 69 6e 74 20 22 46 61 69 6c      (print "Fail
3810: 65 64 20 74 6f 20 6f 62 74 61 69 6e 20 6c 6f 63  ed to obtain loc
3820: 6b 20 66 6f 72 20 22 20 6f 75 74 70 75 74 66 69  k for " outputfi
3830: 6c 65 6e 61 6d 65 29 29 0a 09 20 20 28 6c 65 74  lename))..  (let
3840: 20 28 28 6f 75 70 20 20 20 20 28 6f 70 65 6e 2d   ((oup    (open-
3850: 6f 75 74 70 75 74 2d 66 69 6c 65 20 6f 75 74 70  output-file outp
3860: 75 74 66 69 6c 65 6e 61 6d 65 29 29 0a 09 09 28  utfilename))...(
3870: 63 6f 75 6e 74 73 20 28 6d 61 6b 65 2d 68 61 73  counts (make-has
3880: 68 2d 74 61 62 6c 65 29 29 0a 09 09 28 73 74 61  h-table))...(sta
3890: 74 65 63 6f 75 6e 74 73 20 28 6d 61 6b 65 2d 68  tecounts (make-h
38a0: 61 73 68 2d 74 61 62 6c 65 29 29 0a 09 09 28 6f  ash-table))...(o
38b0: 75 74 74 78 74 20 22 22 29 0a 09 09 28 74 6f 74  uttxt "")...(tot
38c0: 20 20 20 20 30 29 29 0a 09 20 20 20 20 28 77 69      0))..    (wi
38d0: 74 68 2d 6f 75 74 70 75 74 2d 74 6f 2d 70 6f 72  th-output-to-por
38e0: 74 0a 09 09 6f 75 70 0a 09 20 20 20 20 20 20 28  t...oup..      (
38f0: 6c 61 6d 62 64 61 20 28 29 0a 09 09 28 73 65 74  lambda ()...(set
3900: 21 20 6f 75 74 74 78 74 20 28 63 6f 6e 63 20 6f  ! outtxt (conc o
3910: 75 74 74 78 74 20 22 3c 68 74 6d 6c 3e 3c 74 69  uttxt "<html><ti
3920: 74 6c 65 3e 53 75 6d 6d 61 72 79 3a 20 22 20 74  tle>Summary: " t
3930: 65 73 74 2d 6e 61 6d 65 20 0a 09 09 09 09 20 20  est-name .....  
3940: 20 22 3c 2f 74 69 74 6c 65 3e 3c 62 6f 64 79 3e   "</title><body>
3950: 3c 68 32 3e 53 75 6d 6d 61 72 79 20 66 6f 72 20  <h2>Summary for 
3960: 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 3c 2f 68  " test-name "</h
3970: 32 3e 22 29 29 0a 09 09 28 73 71 6c 69 74 65 33  2>"))...(sqlite3
3980: 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77 20 0a 09  :for-each-row ..
3990: 09 20 28 6c 61 6d 62 64 61 20 28 69 64 20 69 74  . (lambda (id it
39a0: 65 6d 70 61 74 68 20 73 74 61 74 65 20 73 74 61  empath state sta
39b0: 74 75 73 20 72 75 6e 5f 64 75 72 61 74 69 6f 6e  tus run_duration
39c0: 20 6c 6f 67 66 20 63 6f 6d 6d 65 6e 74 29 0a 09   logf comment)..
39d0: 09 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d  .   (hash-table-
39e0: 73 65 74 21 20 63 6f 75 6e 74 73 20 73 74 61 74  set! counts stat
39f0: 75 73 20 28 2b 20 31 20 28 68 61 73 68 2d 74 61  us (+ 1 (hash-ta
3a00: 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20  ble-ref/default 
3a10: 63 6f 75 6e 74 73 20 73 74 61 74 75 73 20 30 29  counts status 0)
3a20: 29 29 0a 09 09 20 20 20 28 68 61 73 68 2d 74 61  ))...   (hash-ta
3a30: 62 6c 65 2d 73 65 74 21 20 73 74 61 74 65 63 6f  ble-set! stateco
3a40: 75 6e 74 73 20 73 74 61 74 65 20 28 2b 20 31 20  unts state (+ 1 
3a50: 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f  (hash-table-ref/
3a60: 64 65 66 61 75 6c 74 20 73 74 61 74 65 63 6f 75  default statecou
3a70: 6e 74 73 20 73 74 61 74 65 20 30 29 29 29 0a 09  nts state 0)))..
3a80: 09 20 20 20 28 73 65 74 21 20 6f 75 74 74 78 74  .   (set! outtxt
3a90: 20 28 63 6f 6e 63 20 6f 75 74 74 78 74 20 22 3c   (conc outtxt "<
3aa0: 74 72 3e 22 0a 09 09 09 09 20 20 20 20 20 20 22  tr>".....      "
3ab0: 3c 74 64 3e 3c 61 20 68 72 65 66 3d 5c 22 22 20  <td><a href=\"" 
3ac0: 69 74 65 6d 70 61 74 68 20 22 2f 22 20 6c 6f 67  itempath "/" log
3ad0: 66 20 22 5c 22 3e 20 22 20 69 74 65 6d 70 61 74  f "\"> " itempat
3ae0: 68 20 22 3c 2f 61 3e 3c 2f 74 64 3e 22 20 0a 09  h "</a></td>" ..
3af0: 09 09 09 20 20 20 20 20 20 22 3c 74 64 3e 22 20  ...      "<td>" 
3b00: 73 74 61 74 65 20 20 20 20 22 3c 2f 74 64 3e 22  state    "</td>"
3b10: 20 0a 09 09 09 09 20 20 20 20 20 20 22 3c 74 64   .....      "<td
3b20: 3e 3c 66 6f 6e 74 20 63 6f 6c 6f 72 3d 22 20 28  ><font color=" (
3b30: 63 6f 6d 6d 6f 6e 3a 67 65 74 2d 63 6f 6c 6f 72  common:get-color
3b40: 2d 66 72 6f 6d 2d 73 74 61 74 75 73 20 73 74 61  -from-status sta
3b50: 74 75 73 29 0a 09 09 09 09 20 20 20 20 20 20 22  tus).....      "
3b60: 3e 22 20 20 20 73 74 61 74 75 73 20 20 20 22 3c  >"   status   "<
3b70: 2f 66 6f 6e 74 3e 3c 2f 74 64 3e 22 0a 09 09 09  /font></td>"....
3b80: 09 20 20 20 20 20 20 22 3c 74 64 3e 22 20 28 69  .      "<td>" (i
3b90: 66 20 28 65 71 75 61 6c 3f 20 63 6f 6d 6d 65 6e  f (equal? commen
3ba0: 74 20 22 22 29 0a 09 09 09 09 09 09 20 22 26 6e  t "")....... "&n
3bb0: 62 73 70 3b 22 0a 09 09 09 09 09 09 20 63 6f 6d  bsp;"....... com
3bc0: 6d 65 6e 74 29 20 22 3c 2f 74 64 3e 22 0a 09 09  ment) "</td>"...
3bd0: 09 09 09 09 20 22 3c 2f 74 72 3e 22 29 29 29 0a  .... "</tr>"))).
3be0: 09 09 20 64 62 0a 09 09 20 22 53 45 4c 45 43 54  .. db... "SELECT
3bf0: 20 69 64 2c 69 74 65 6d 5f 70 61 74 68 2c 73 74   id,item_path,st
3c00: 61 74 65 2c 73 74 61 74 75 73 2c 72 75 6e 5f 64  ate,status,run_d
3c10: 75 72 61 74 69 6f 6e 2c 66 69 6e 61 6c 5f 6c 6f  uration,final_lo
3c20: 67 66 2c 63 6f 6d 6d 65 6e 74 20 46 52 4f 4d 20  gf,comment FROM 
3c30: 74 65 73 74 73 20 57 48 45 52 45 20 72 75 6e 5f  tests WHERE run_
3c40: 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d  id=? AND testnam
3c50: 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74  e=? AND item_pat
3c60: 68 20 21 3d 20 27 27 3b 22 0a 09 09 20 72 75 6e  h != '';"... run
3c70: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 29 0a 0a  -id test-name)..
3c80: 09 09 28 70 72 69 6e 74 20 22 3c 74 61 62 6c 65  ..(print "<table
3c90: 3e 3c 74 72 3e 3c 74 64 20 76 61 6c 69 67 6e 3d  ><tr><td valign=
3ca0: 5c 22 74 6f 70 5c 22 3e 22 29 0a 09 09 3b 3b 20  \"top\">")...;; 
3cb0: 50 72 69 6e 74 20 6f 75 74 20 73 74 61 74 73 20  Print out stats 
3cc0: 66 6f 72 20 73 74 61 74 75 73 0a 09 09 28 73 65  for status...(se
3cd0: 74 21 20 74 6f 74 20 30 29 0a 09 09 28 70 72 69  t! tot 0)...(pri
3ce0: 6e 74 20 22 3c 74 61 62 6c 65 20 63 65 6c 6c 73  nt "<table cells
3cf0: 70 61 63 69 6e 67 3d 5c 22 30 5c 22 20 62 6f 72  pacing=\"0\" bor
3d00: 64 65 72 3d 5c 22 31 5c 22 3e 3c 74 72 3e 3c 74  der=\"1\"><tr><t
3d10: 64 20 63 6f 6c 73 70 61 6e 3d 5c 22 32 5c 22 3e  d colspan=\"2\">
3d20: 3c 68 32 3e 53 74 61 74 65 20 73 74 61 74 73 3c  <h2>State stats<
3d30: 2f 68 32 3e 3c 2f 74 64 3e 3c 2f 74 72 3e 22 29  /h2></td></tr>")
3d40: 0a 09 09 28 66 6f 72 2d 65 61 63 68 20 28 6c 61  ...(for-each (la
3d50: 6d 62 64 61 20 28 73 74 61 74 65 29 0a 09 09 09  mbda (state)....
3d60: 20 20 20 20 28 73 65 74 21 20 74 6f 74 20 28 2b      (set! tot (+
3d70: 20 74 6f 74 20 28 68 61 73 68 2d 74 61 62 6c 65   tot (hash-table
3d80: 2d 72 65 66 20 73 74 61 74 65 63 6f 75 6e 74 73  -ref statecounts
3d90: 20 73 74 61 74 65 29 29 29 0a 09 09 09 20 20 20   state)))....   
3da0: 20 28 70 72 69 6e 74 20 22 3c 74 72 3e 3c 74 64   (print "<tr><td
3db0: 3e 22 20 73 74 61 74 65 20 22 3c 2f 74 64 3e 3c  >" state "</td><
3dc0: 74 64 3e 22 20 28 68 61 73 68 2d 74 61 62 6c 65  td>" (hash-table
3dd0: 2d 72 65 66 20 73 74 61 74 65 63 6f 75 6e 74 73  -ref statecounts
3de0: 20 73 74 61 74 65 29 20 22 3c 2f 74 64 3e 3c 2f   state) "</td></
3df0: 74 72 3e 22 29 29 0a 09 09 09 20 20 28 68 61 73  tr>"))....  (has
3e00: 68 2d 74 61 62 6c 65 2d 6b 65 79 73 20 73 74 61  h-table-keys sta
3e10: 74 65 63 6f 75 6e 74 73 29 29 0a 09 09 28 70 72  tecounts))...(pr
3e20: 69 6e 74 20 22 3c 74 72 3e 3c 74 64 3e 54 6f 74  int "<tr><td>Tot
3e30: 61 6c 3c 2f 74 64 3e 3c 74 64 3e 22 20 74 6f 74  al</td><td>" tot
3e40: 20 22 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61   "</td></tr></ta
3e50: 62 6c 65 3e 22 29 0a 09 09 28 70 72 69 6e 74 20  ble>")...(print 
3e60: 22 3c 2f 74 64 3e 3c 74 64 20 76 61 6c 69 67 6e  "</td><td valign
3e70: 3d 5c 22 74 6f 70 5c 22 3e 22 29 0a 09 09 3b 3b  =\"top\">")...;;
3e80: 20 50 72 69 6e 74 20 6f 75 74 20 73 74 61 74 73   Print out stats
3e90: 20 66 6f 72 20 73 74 61 74 65 0a 09 09 28 73 65   for state...(se
3ea0: 74 21 20 74 6f 74 20 30 29 0a 09 09 28 70 72 69  t! tot 0)...(pri
3eb0: 6e 74 20 22 3c 74 61 62 6c 65 20 63 65 6c 6c 73  nt "<table cells
3ec0: 70 61 63 69 6e 67 3d 5c 22 30 5c 22 20 62 6f 72  pacing=\"0\" bor
3ed0: 64 65 72 3d 5c 22 31 5c 22 3e 3c 74 72 3e 3c 74  der=\"1\"><tr><t
3ee0: 64 20 63 6f 6c 73 70 61 6e 3d 5c 22 32 5c 22 3e  d colspan=\"2\">
3ef0: 3c 68 32 3e 53 74 61 74 75 73 20 73 74 61 74 73  <h2>Status stats
3f00: 3c 2f 68 32 3e 3c 2f 74 64 3e 3c 2f 74 72 3e 22  </h2></td></tr>"
3f10: 29 0a 09 09 28 66 6f 72 2d 65 61 63 68 20 28 6c  )...(for-each (l
3f20: 61 6d 62 64 61 20 28 73 74 61 74 75 73 29 0a 09  ambda (status)..
3f30: 09 09 20 20 20 20 28 73 65 74 21 20 74 6f 74 20  ..    (set! tot 
3f40: 28 2b 20 74 6f 74 20 28 68 61 73 68 2d 74 61 62  (+ tot (hash-tab
3f50: 6c 65 2d 72 65 66 20 63 6f 75 6e 74 73 20 73 74  le-ref counts st
3f60: 61 74 75 73 29 29 29 0a 09 09 09 20 20 20 20 28  atus)))....    (
3f70: 70 72 69 6e 74 20 22 3c 74 72 3e 3c 74 64 3e 3c  print "<tr><td><
3f80: 66 6f 6e 74 20 63 6f 6c 6f 72 3d 5c 22 22 20 28  font color=\"" (
3f90: 63 6f 6d 6d 6f 6e 3a 67 65 74 2d 63 6f 6c 6f 72  common:get-color
3fa0: 2d 66 72 6f 6d 2d 73 74 61 74 75 73 20 73 74 61  -from-status sta
3fb0: 74 75 73 29 20 22 5c 22 3e 22 20 73 74 61 74 75  tus) "\">" statu
3fc0: 73 0a 09 09 09 09 20 20 20 22 3c 2f 66 6f 6e 74  s.....   "</font
3fd0: 3e 3c 2f 74 64 3e 3c 74 64 3e 22 20 28 68 61 73  ></td><td>" (has
3fe0: 68 2d 74 61 62 6c 65 2d 72 65 66 20 63 6f 75 6e  h-table-ref coun
3ff0: 74 73 20 73 74 61 74 75 73 29 20 22 3c 2f 74 64  ts status) "</td
4000: 3e 3c 2f 74 72 3e 22 29 29 0a 09 09 09 20 20 28  ></tr>"))....  (
4010: 68 61 73 68 2d 74 61 62 6c 65 2d 6b 65 79 73 20  hash-table-keys 
4020: 63 6f 75 6e 74 73 29 29 0a 09 09 28 70 72 69 6e  counts))...(prin
4030: 74 20 22 3c 74 72 3e 3c 74 64 3e 54 6f 74 61 6c  t "<tr><td>Total
4040: 3c 2f 74 64 3e 3c 74 64 3e 22 20 74 6f 74 20 22  </td><td>" tot "
4050: 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c  </td></tr></tabl
4060: 65 3e 22 29 0a 09 09 28 70 72 69 6e 74 20 22 3c  e>")...(print "<
4070: 2f 74 64 3e 3c 2f 74 64 3e 3c 2f 74 72 3e 3c 2f  /td></td></tr></
4080: 74 61 62 6c 65 3e 22 29 0a 0a 09 09 28 70 72 69  table>")....(pri
4090: 6e 74 20 22 3c 74 61 62 6c 65 20 63 65 6c 6c 73  nt "<table cells
40a0: 70 61 63 69 6e 67 3d 5c 22 30 5c 22 20 62 6f 72  pacing=\"0\" bor
40b0: 64 65 72 3d 5c 22 31 5c 22 3e 22 20 0a 09 09 20  der=\"1\">" ... 
40c0: 20 20 20 20 20 20 22 3c 74 72 3e 3c 74 64 3e 49        "<tr><td>I
40d0: 74 65 6d 3c 2f 74 64 3e 3c 74 64 3e 53 74 61 74  tem</td><td>Stat
40e0: 65 3c 2f 74 64 3e 3c 74 64 3e 53 74 61 74 75 73  e</td><td>Status
40f0: 3c 2f 74 64 3e 3c 74 64 3e 43 6f 6d 6d 65 6e 74  </td><td>Comment
4100: 3c 2f 74 64 3e 22 0a 09 09 20 20 20 20 20 20 20  </td>"...       
4110: 6f 75 74 74 78 74 20 22 3c 2f 74 61 62 6c 65 3e  outtxt "</table>
4120: 3c 2f 62 6f 64 79 3e 3c 2f 68 74 6d 6c 3e 22 29  </body></html>")
4130: 0a 09 09 28 72 65 6c 65 61 73 65 2d 64 6f 74 2d  ...(release-dot-
4140: 6c 6f 63 6b 20 6f 75 74 70 75 74 66 69 6c 65 6e  lock outputfilen
4150: 61 6d 65 29 29 29 0a 09 20 20 20 20 28 63 6c 6f  ame)))..    (clo
4160: 73 65 2d 6f 75 74 70 75 74 2d 70 6f 72 74 20 6f  se-output-port o
4170: 75 70 29 0a 09 20 20 20 20 28 63 68 61 6e 67 65  up)..    (change
4180: 2d 64 69 72 65 63 74 6f 72 79 20 6f 72 69 67 2d  -directory orig-
4190: 64 69 72 29 0a 09 20 20 20 20 28 74 65 73 74 2d  dir)..    (test-
41a0: 73 65 74 2d 74 6f 70 6c 6f 67 21 20 64 62 20 72  set-toplog! db r
41b0: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
41c0: 6f 75 74 70 75 74 66 69 6c 65 6e 61 6d 65 29 0a  outputfilename).
41d0: 09 20 20 20 20 29 29 29 29 29 0a 0a 3b 3b 20 3b  .    )))))..;; ;
41e0: 3b 20 54 4f 44 4f 3a 20 43 6f 6e 76 65 72 67 65  ; TODO: Converge
41f0: 20 74 68 69 73 20 77 69 74 68 20 64 62 3a 67 65   this with db:ge
4200: 74 2d 74 65 73 74 2d 69 6e 66 6f 0a 3b 3b 20 28  t-test-info.;; (
4210: 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 67 65 74  define (runs:get
4220: 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 20 72 75  -test-info db ru
4230: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69  n-id test-name i
4240: 74 65 6d 2d 70 61 74 68 29 0a 3b 3b 20 20 20 28  tem-path).;;   (
4250: 6c 65 74 20 28 28 72 65 73 20 23 66 29 29 20 3b  let ((res #f)) ;
4260: 3b 20 28 76 65 63 74 6f 72 20 23 66 20 23 66 20  ; (vector #f #f 
4270: 23 66 20 23 66 20 23 66 20 23 66 29 29 29 0a 3b  #f #f #f #f))).;
4280: 3b 20 20 20 20 20 28 73 71 6c 69 74 65 33 3a 66  ;     (sqlite3:f
4290: 6f 72 2d 65 61 63 68 2d 72 6f 77 20 0a 3b 3b 20  or-each-row .;; 
42a0: 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 69 64       (lambda (id
42b0: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
42c0: 65 20 73 74 61 74 65 20 73 74 61 74 75 73 29 0a  e state status).
42d0: 3b 3b 20 20 20 20 20 20 20 20 28 73 65 74 21 20  ;;        (set! 
42e0: 72 65 73 20 28 76 65 63 74 6f 72 20 69 64 20 72  res (vector id r
42f0: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
4300: 73 74 61 74 65 20 73 74 61 74 75 73 20 69 74 65  state status ite
4310: 6d 2d 70 61 74 68 29 29 29 0a 3b 3b 20 20 20 20  m-path))).;;    
4320: 20 20 64 62 20 22 53 45 4c 45 43 54 20 69 64 2c    db "SELECT id,
4330: 72 75 6e 5f 69 64 2c 74 65 73 74 6e 61 6d 65 2c  run_id,testname,
4340: 73 74 61 74 65 2c 73 74 61 74 75 73 20 46 52 4f  state,status FRO
4350: 4d 20 74 65 73 74 73 20 57 48 45 52 45 20 72 75  M tests WHERE ru
4360: 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e  n_id=? AND testn
4370: 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70  ame=? AND item_p
4380: 61 74 68 3d 3f 3b 22 0a 3b 3b 20 20 20 20 20 20  ath=?;".;;      
4390: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
43a0: 20 69 74 65 6d 2d 70 61 74 68 29 0a 3b 3b 20 20   item-path).;;  
43b0: 20 20 20 72 65 73 29 29 0a 0a 28 64 65 66 69 6e     res))..(defin
43c0: 65 20 28 72 75 6e 73 3a 74 65 73 74 2d 67 65 74  e (runs:test-get
43d0: 2d 66 75 6c 6c 2d 70 61 74 68 20 74 65 73 74 29  -full-path test)
43e0: 0a 20 20 28 6c 65 74 2a 20 28 28 74 65 73 74 6e  .  (let* ((testn
43f0: 61 6d 65 20 28 64 62 3a 74 65 73 74 2d 67 65 74  ame (db:test-get
4400: 2d 74 65 73 74 6e 61 6d 65 20 20 20 74 65 73 74  -testname   test
4410: 29 29 0a 09 20 28 69 74 65 6d 70 61 74 68 20 28  )).. (itempath (
4420: 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d  db:test-get-item
4430: 2d 70 61 74 68 20 74 65 73 74 29 29 29 0a 20 20  -path test))).  
4440: 20 20 28 63 6f 6e 63 20 74 65 73 74 6e 61 6d 65    (conc testname
4450: 20 28 69 66 20 28 65 71 75 61 6c 3f 20 69 74 65   (if (equal? ite
4460: 6d 70 61 74 68 20 22 22 29 20 22 22 20 28 63 6f  mpath "") "" (co
4470: 6e 63 20 22 28 22 20 69 74 65 6d 70 61 74 68 20  nc "(" itempath 
4480: 22 29 22 29 29 29 29 29 0a 0a 28 64 65 66 69 6e  ")")))))..(defin
4490: 65 20 28 63 68 65 63 6b 2d 76 61 6c 69 64 2d 69  e (check-valid-i
44a0: 74 65 6d 73 20 63 6c 61 73 73 20 69 74 65 6d 29  tems class item)
44b0: 0a 20 20 28 6c 65 74 20 28 28 76 61 6c 69 64 2d  .  (let ((valid-
44c0: 76 61 6c 75 65 73 20 28 6c 65 74 20 28 28 73 20  values (let ((s 
44d0: 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 2a  (config-lookup *
44e0: 63 6f 6e 66 69 67 64 61 74 2a 20 22 76 61 6c 69  configdat* "vali
44f0: 64 76 61 6c 75 65 73 22 20 63 6c 61 73 73 29 29  dvalues" class))
4500: 29 0a 09 09 09 28 69 66 20 73 20 28 73 74 72 69  )....(if s (stri
4510: 6e 67 2d 73 70 6c 69 74 20 73 29 20 23 66 29 29  ng-split s) #f))
4520: 29 29 0a 20 20 20 20 28 69 66 20 76 61 6c 69 64  )).    (if valid
4530: 2d 76 61 6c 75 65 73 0a 09 28 69 66 20 28 6d 65  -values..(if (me
4540: 6d 62 65 72 20 69 74 65 6d 20 76 61 6c 69 64 2d  mber item valid-
4550: 76 61 6c 75 65 73 29 0a 09 20 20 20 20 69 74 65  values)..    ite
4560: 6d 20 23 66 29 0a 09 69 74 65 6d 29 29 29 0a 0a  m #f)..item)))..
4570: 28 64 65 66 69 6e 65 20 28 74 65 73 74 73 74 65  (define (testste
4580: 70 2d 73 65 74 2d 73 74 61 74 75 73 21 20 64 62  p-set-status! db
4590: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
45a0: 65 20 74 65 73 74 73 74 65 70 2d 6e 61 6d 65 20  e teststep-name 
45b0: 73 74 61 74 65 2d 69 6e 20 73 74 61 74 75 73 2d  state-in status-
45c0: 69 6e 20 69 74 65 6d 64 61 74 20 63 6f 6d 6d 65  in itemdat comme
45d0: 6e 74 20 6c 6f 67 66 69 6c 65 29 0a 20 20 28 64  nt logfile).  (d
45e0: 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 72 75  ebug:print 4 "ru
45f0: 6e 2d 69 64 3a 20 22 20 72 75 6e 2d 69 64 20 22  n-id: " run-id "
4600: 20 74 65 73 74 2d 6e 61 6d 65 3a 20 22 20 74 65   test-name: " te
4610: 73 74 2d 6e 61 6d 65 29 0a 20 20 28 6c 65 74 2a  st-name).  (let*
4620: 20 28 28 73 74 61 74 65 20 20 20 20 20 28 63 68   ((state     (ch
4630: 65 63 6b 2d 76 61 6c 69 64 2d 69 74 65 6d 73 20  eck-valid-items 
4640: 22 73 74 61 74 65 22 20 73 74 61 74 65 2d 69 6e  "state" state-in
4650: 29 29 0a 09 20 28 73 74 61 74 75 73 20 20 20 20  )).. (status    
4660: 28 63 68 65 63 6b 2d 76 61 6c 69 64 2d 69 74 65  (check-valid-ite
4670: 6d 73 20 22 73 74 61 74 75 73 22 20 73 74 61 74  ms "status" stat
4680: 75 73 2d 69 6e 29 29 0a 09 20 28 69 74 65 6d 2d  us-in)).. (item-
4690: 70 61 74 68 20 28 69 74 65 6d 2d 6c 69 73 74 2d  path (item-list-
46a0: 3e 70 61 74 68 20 69 74 65 6d 64 61 74 29 29 0a  >path itemdat)).
46b0: 09 20 28 74 65 73 74 64 61 74 20 20 20 28 64 62  . (testdat   (db
46c0: 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64  :get-test-info d
46d0: 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  b run-id test-na
46e0: 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a  me item-path))).
46f0: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
4700: 20 35 20 22 74 65 73 74 64 61 74 3a 20 22 20 74   5 "testdat: " t
4710: 65 73 74 64 61 74 29 0a 20 20 20 20 28 69 66 20  estdat).    (if 
4720: 28 61 6e 64 20 74 65 73 74 64 61 74 20 3b 3b 20  (and testdat ;; 
4730: 69 66 20 74 68 65 20 73 65 63 74 69 6f 6e 20 65  if the section e
4740: 78 69 73 74 73 20 74 68 65 6e 20 66 6f 72 63 65  xists then force
4750: 20 73 70 65 63 69 66 69 63 61 74 69 6f 6e 20 42   specification B
4760: 55 47 2c 20 49 20 64 6f 6e 27 74 20 6c 69 6b 65  UG, I don't like
4770: 20 68 6f 77 20 74 68 69 73 20 77 6f 72 6b 73 2e   how this works.
4780: 0a 09 20 20 20 20 20 28 6f 72 20 28 6e 6f 74 20  ..     (or (not 
4790: 73 74 61 74 65 29 28 6e 6f 74 20 73 74 61 74 75  state)(not statu
47a0: 73 29 29 29 0a 09 28 64 65 62 75 67 3a 70 72 69  s)))..(debug:pri
47b0: 6e 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 49  nt 0 "WARNING: I
47c0: 6e 76 61 6c 69 64 20 22 20 28 69 66 20 73 74 61  nvalid " (if sta
47d0: 74 75 73 20 22 73 74 61 74 75 73 22 20 22 73 74  tus "status" "st
47e0: 61 74 65 22 29 0a 09 20 20 20 20 20 20 20 22 20  ate")..       " 
47f0: 76 61 6c 75 65 20 5c 22 22 20 28 69 66 20 73 74  value \"" (if st
4800: 61 74 75 73 20 73 74 61 74 65 2d 69 6e 20 73 74  atus state-in st
4810: 61 74 75 73 2d 69 6e 29 20 22 5c 22 2c 20 75 70  atus-in) "\", up
4820: 64 61 74 65 20 79 6f 75 72 20 76 61 6c 69 64 76  date your validv
4830: 61 6c 75 65 73 20 73 65 63 74 69 6f 6e 20 69 6e  alues section in
4840: 20 6d 65 67 61 74 65 73 74 2e 63 6f 6e 66 69 67   megatest.config
4850: 22 29 29 0a 20 20 20 20 28 69 66 20 74 65 73 74  ")).    (if test
4860: 64 61 74 0a 09 28 6c 65 74 20 28 28 74 65 73 74  dat..(let ((test
4870: 2d 69 64 20 28 74 65 73 74 3a 67 65 74 2d 69 64  -id (test:get-id
4880: 20 74 65 73 74 64 61 74 29 29 29 0a 09 20 20 3b   testdat)))..  ;
4890: 3b 20 46 49 58 4d 45 20 2d 20 74 68 69 73 20 73  ; FIXME - this s
48a0: 68 6f 75 6c 64 20 6e 6f 74 20 75 70 64 61 74 65  hould not update
48b0: 20 74 68 65 20 6c 6f 67 66 69 6c 65 20 75 6e 6c   the logfile unl
48c0: 65 73 73 20 69 74 20 69 73 20 73 70 65 63 69 66  ess it is specif
48d0: 69 65 64 2e 0a 09 20 20 28 73 71 6c 69 74 65 33  ied...  (sqlite3
48e0: 3a 65 78 65 63 75 74 65 20 64 62 20 0a 09 09 09  :execute db ....
48f0: 22 49 4e 53 45 52 54 20 4f 52 20 52 45 50 4c 41  "INSERT OR REPLA
4900: 43 45 20 69 6e 74 6f 20 74 65 73 74 5f 73 74 65  CE into test_ste
4910: 70 73 20 28 74 65 73 74 5f 69 64 2c 73 74 65 70  ps (test_id,step
4920: 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 61 74 75  name,state,statu
4930: 73 2c 65 76 65 6e 74 5f 74 69 6d 65 2c 63 6f 6d  s,event_time,com
4940: 6d 65 6e 74 2c 6c 6f 67 66 69 6c 65 29 20 56 41  ment,logfile) VA
4950: 4c 55 45 53 28 3f 2c 3f 2c 3f 2c 3f 2c 73 74 72  LUES(?,?,?,?,str
4960: 66 74 69 6d 65 28 27 25 73 27 2c 27 6e 6f 77 27  ftime('%s','now'
4970: 29 2c 3f 2c 3f 29 3b 22 0a 09 09 09 74 65 73 74  ),?,?);"....test
4980: 2d 69 64 20 74 65 73 74 73 74 65 70 2d 6e 61 6d  -id teststep-nam
4990: 65 20 73 74 61 74 65 2d 69 6e 20 73 74 61 74 75  e state-in statu
49a0: 73 2d 69 6e 20 28 69 66 20 63 6f 6d 6d 65 6e 74  s-in (if comment
49b0: 20 63 6f 6d 6d 65 6e 74 20 22 22 29 20 28 69 66   comment "") (if
49c0: 20 6c 6f 67 66 69 6c 65 20 6c 6f 67 66 69 6c 65   logfile logfile
49d0: 20 22 22 29 29 29 0a 09 28 64 65 62 75 67 3a 70   "")))..(debug:p
49e0: 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 43  rint 0 "ERROR: C
49f0: 61 6e 27 74 20 75 70 64 61 74 65 20 22 20 74 65  an't update " te
4a00: 73 74 2d 6e 61 6d 65 20 22 20 66 6f 72 20 72 75  st-name " for ru
4a10: 6e 20 22 20 72 75 6e 2d 69 64 20 22 20 2d 3e 20  n " run-id " -> 
4a20: 6e 6f 20 73 75 63 68 20 74 65 73 74 20 69 6e 20  no such test in 
4a30: 64 62 22 29 29 29 29 0a 0a 28 64 65 66 69 6e 65  db"))))..(define
4a40: 20 28 74 65 73 74 2d 67 65 74 2d 6b 69 6c 6c 2d   (test-get-kill-
4a50: 72 65 71 75 65 73 74 20 64 62 20 72 75 6e 2d 69  request db run-i
4a60: 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d  d test-name item
4a70: 64 61 74 29 0a 20 20 28 6c 65 74 2a 20 28 28 69  dat).  (let* ((i
4a80: 74 65 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c  tem-path (item-l
4a90: 69 73 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61  ist->path itemda
4aa0: 74 29 29 0a 09 20 28 74 65 73 74 64 61 74 20 20  t)).. (testdat  
4ab0: 20 28 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e   (db:get-test-in
4ac0: 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  fo db run-id tes
4ad0: 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68  t-name item-path
4ae0: 29 29 29 0a 20 20 20 20 28 65 71 75 61 6c 3f 20  ))).    (equal? 
4af0: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20  (test:get-state 
4b00: 74 65 73 74 64 61 74 29 20 22 4b 49 4c 4c 52 45  testdat) "KILLRE
4b10: 51 22 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28  Q")))..(define (
4b20: 74 65 73 74 2d 73 65 74 2d 6d 65 74 61 2d 69 6e  test-set-meta-in
4b30: 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  fo db run-id tes
4b40: 74 6e 61 6d 65 20 69 74 65 6d 64 61 74 29 0a 20  tname itemdat). 
4b50: 20 28 6c 65 74 20 28 28 69 74 65 6d 2d 70 61 74   (let ((item-pat
4b60: 68 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61  h (item-list->pa
4b70: 74 68 20 69 74 65 6d 64 61 74 29 29 0a 09 28 63  th itemdat))..(c
4b80: 70 75 6c 6f 61 64 20 20 28 67 65 74 2d 63 70 75  puload  (get-cpu
4b90: 2d 6c 6f 61 64 29 29 0a 09 28 68 6f 73 74 6e 61  -load))..(hostna
4ba0: 6d 65 20 28 67 65 74 2d 68 6f 73 74 2d 6e 61 6d  me (get-host-nam
4bb0: 65 29 29 0a 09 28 64 69 73 6b 66 72 65 65 20 28  e))..(diskfree (
4bc0: 67 65 74 2d 64 66 20 28 63 75 72 72 65 6e 74 2d  get-df (current-
4bd0: 64 69 72 65 63 74 6f 72 79 29 29 29 0a 09 28 75  directory)))..(u
4be0: 6e 61 6d 65 20 20 20 20 28 67 65 74 2d 75 6e 61  name    (get-una
4bf0: 6d 65 20 22 2d 73 72 76 70 69 6f 22 29 29 0a 09  me "-srvpio"))..
4c00: 28 72 75 6e 70 61 74 68 20 20 28 63 75 72 72 65  (runpath  (curre
4c10: 6e 74 2d 64 69 72 65 63 74 6f 72 79 29 29 29 0a  nt-directory))).
4c20: 20 20 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65      (sqlite3:exe
4c30: 63 75 74 65 20 64 62 20 22 55 50 44 41 54 45 20  cute db "UPDATE 
4c40: 74 65 73 74 73 20 53 45 54 20 68 6f 73 74 3d 3f  tests SET host=?
4c50: 2c 63 70 75 6c 6f 61 64 3d 3f 2c 64 69 73 6b 66  ,cpuload=?,diskf
4c60: 72 65 65 3d 3f 2c 75 6e 61 6d 65 3d 3f 2c 72 75  ree=?,uname=?,ru
4c70: 6e 64 69 72 3d 3f 20 57 48 45 52 45 20 72 75 6e  ndir=? WHERE run
4c80: 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61  _id=? AND testna
4c90: 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61  me=? AND item_pa
4ca0: 74 68 3d 3f 3b 22 0a 09 09 20 20 68 6f 73 74 6e  th=?;"...  hostn
4cb0: 61 6d 65 0a 09 09 20 20 63 70 75 6c 6f 61 64 0a  ame...  cpuload.
4cc0: 09 09 20 20 64 69 73 6b 66 72 65 65 0a 09 09 20  ..  diskfree... 
4cd0: 20 75 6e 61 6d 65 0a 09 09 20 20 72 75 6e 70 61   uname...  runpa
4ce0: 74 68 0a 09 09 20 20 72 75 6e 2d 69 64 0a 09 09  th...  run-id...
4cf0: 20 20 74 65 73 74 6e 61 6d 65 0a 09 09 20 20 69    testname...  i
4d00: 74 65 6d 2d 70 61 74 68 29 29 29 0a 0a 28 64 65  tem-path)))..(de
4d10: 66 69 6e 65 20 28 74 65 73 74 2d 75 70 64 61 74  fine (test-updat
4d20: 65 2d 6d 65 74 61 2d 69 6e 66 6f 20 64 62 20 72  e-meta-info db r
4d30: 75 6e 2d 69 64 20 74 65 73 74 6e 61 6d 65 20 69  un-id testname i
4d40: 74 65 6d 64 61 74 20 6d 69 6e 75 74 65 73 20 63  temdat minutes c
4d50: 70 75 6c 6f 61 64 20 64 69 73 6b 66 72 65 65 20  puload diskfree 
4d60: 74 6d 70 66 72 65 65 29 0a 20 20 28 6c 65 74 20  tmpfree).  (let 
4d70: 28 28 69 74 65 6d 2d 70 61 74 68 20 28 69 74 65  ((item-path (ite
4d80: 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69 74 65  m-list->path ite
4d90: 6d 64 61 74 29 29 29 0a 20 20 20 20 28 69 66 20  mdat))).    (if 
4da0: 28 6e 6f 74 20 69 74 65 6d 2d 70 61 74 68 29 28  (not item-path)(
4db0: 62 65 67 69 6e 20 28 64 65 62 75 67 3a 70 72 69  begin (debug:pri
4dc0: 6e 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 49  nt 0 "WARNING: I
4dd0: 54 45 4d 50 41 54 48 20 6e 6f 74 20 73 65 74 2e  TEMPATH not set.
4de0: 22 29 20 20 20 28 73 65 74 21 20 69 74 65 6d 2d  ")   (set! item-
4df0: 70 61 74 68 20 22 22 29 29 29 0a 20 20 20 20 3b  path ""))).    ;
4e00: 3b 20 28 6c 65 74 20 28 28 74 65 73 74 69 6e 66  ; (let ((testinf
4e10: 6f 20 28 64 62 3a 67 65 74 2d 74 65 73 74 2d 69  o (db:get-test-i
4e20: 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65  nfo db run-id te
4e30: 73 74 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68  stname item-path
4e40: 29 29 29 0a 20 20 20 20 3b 3b 20 20 20 28 69 66  ))).    ;;   (if
4e50: 20 28 61 6e 64 20 28 6e 6f 74 20 28 65 71 75 61   (and (not (equa
4e60: 6c 3f 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  l? (db:test-get-
4e70: 73 74 61 74 75 73 20 74 65 73 74 69 6e 66 6f 29  status testinfo)
4e80: 20 22 43 4f 4d 50 4c 45 54 45 44 22 29 29 0a 20   "COMPLETED")). 
4e90: 20 20 20 3b 3b 20 20 20 20 20 20 20 20 20 20 20     ;;           
4ea0: 20 28 6e 6f 74 20 28 65 71 75 61 6c 3f 20 28 64   (not (equal? (d
4eb0: 62 3a 74 65 73 74 2d 67 65 74 2d 73 74 61 74 75  b:test-get-statu
4ec0: 73 20 74 65 73 74 69 6e 66 6f 29 20 22 4b 49 4c  s testinfo) "KIL
4ed0: 4c 52 45 51 22 29 29 0a 20 20 20 20 28 73 71 6c  LREQ")).    (sql
4ee0: 69 74 65 33 3a 65 78 65 63 75 74 65 0a 20 20 20  ite3:execute.   
4ef0: 20 20 64 62 0a 20 20 20 20 20 22 55 50 44 41 54    db.     "UPDAT
4f00: 45 20 74 65 73 74 73 20 53 45 54 20 63 70 75 6c  E tests SET cpul
4f10: 6f 61 64 3d 3f 2c 64 69 73 6b 66 72 65 65 3d 3f  oad=?,diskfree=?
4f20: 2c 72 75 6e 5f 64 75 72 61 74 69 6f 6e 3d 3f 2c  ,run_duration=?,
4f30: 73 74 61 74 65 3d 27 52 55 4e 4e 49 4e 47 27 20  state='RUNNING' 
4f40: 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41  WHERE run_id=? A
4f50: 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e  ND testname=? AN
4f60: 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f 20 41 4e  D item_path=? AN
4f70: 44 20 73 74 61 74 65 20 4e 4f 54 20 49 4e 20 28  D state NOT IN (
4f80: 27 43 4f 4d 50 4c 45 54 45 44 27 2c 27 4b 49 4c  'COMPLETED','KIL
4f90: 4c 52 45 51 27 2c 27 4b 49 4c 4c 45 44 27 29 3b  LREQ','KILLED');
4fa0: 22 0a 20 20 20 20 20 63 70 75 6c 6f 61 64 0a 20  ".     cpuload. 
4fb0: 20 20 20 20 64 69 73 6b 66 72 65 65 0a 20 20 20      diskfree.   
4fc0: 20 20 6d 69 6e 75 74 65 73 0a 20 20 20 20 20 72    minutes.     r
4fd0: 75 6e 2d 69 64 0a 20 20 20 20 20 74 65 73 74 6e  un-id.     testn
4fe0: 61 6d 65 0a 20 20 20 20 20 69 74 65 6d 2d 70 61  ame.     item-pa
4ff0: 74 68 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28  th)))..(define (
5000: 73 65 74 2d 6d 65 67 61 74 65 73 74 2d 65 6e 76  set-megatest-env
5010: 2d 76 61 72 73 20 64 62 20 72 75 6e 2d 69 64 29  -vars db run-id)
5020: 0a 20 20 28 6c 65 74 20 28 28 6b 65 79 73 20 28  .  (let ((keys (
5030: 64 62 2d 67 65 74 2d 6b 65 79 73 20 64 62 29 29  db-get-keys db))
5040: 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20  ).    (for-each 
5050: 28 6c 61 6d 62 64 61 20 28 6b 65 79 29 0a 09 09  (lambda (key)...
5060: 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63  (sqlite3:for-eac
5070: 68 2d 72 6f 77 0a 09 09 20 28 6c 61 6d 62 64 61  h-row... (lambda
5080: 20 28 76 61 6c 29 0a 09 09 20 20 20 28 64 65 62   (val)...   (deb
5090: 75 67 3a 70 72 69 6e 74 20 32 20 22 73 65 74 65  ug:print 2 "sete
50a0: 6e 76 20 22 20 28 6b 65 79 3a 67 65 74 2d 66 69  nv " (key:get-fi
50b0: 65 6c 64 6e 61 6d 65 20 6b 65 79 29 20 22 20 22  eldname key) " "
50c0: 20 76 61 6c 29 0a 09 09 20 20 20 28 73 65 74 65   val)...   (sete
50d0: 6e 76 20 28 6b 65 79 3a 67 65 74 2d 66 69 65 6c  nv (key:get-fiel
50e0: 64 6e 61 6d 65 20 6b 65 79 29 20 76 61 6c 29 29  dname key) val))
50f0: 0a 09 09 20 64 62 20 0a 09 09 20 28 63 6f 6e 63  ... db ... (conc
5100: 20 22 53 45 4c 45 43 54 20 22 20 28 6b 65 79 3a   "SELECT " (key:
5110: 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65  get-fieldname ke
5120: 79 29 20 22 20 46 52 4f 4d 20 72 75 6e 73 20 57  y) " FROM runs W
5130: 48 45 52 45 20 69 64 3d 3f 3b 22 29 0a 09 09 20  HERE id=?;")... 
5140: 72 75 6e 2d 69 64 29 29 0a 09 20 20 20 20 20 20  run-id))..      
5150: 6b 65 79 73 29 29 29 0a 0a 28 64 65 66 69 6e 65  keys)))..(define
5160: 20 28 73 65 74 2d 69 74 65 6d 2d 65 6e 76 2d 76   (set-item-env-v
5170: 61 72 73 20 69 74 65 6d 64 61 74 29 0a 20 20 28  ars itemdat).  (
5180: 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61  for-each (lambda
5190: 20 28 69 74 65 6d 29 0a 09 20 20 20 20 20 20 28   (item)..      (
51a0: 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 73  debug:print 2 "s
51b0: 65 74 65 6e 76 20 22 20 28 63 61 72 20 69 74 65  etenv " (car ite
51c0: 6d 29 20 22 20 22 20 28 63 61 64 72 20 69 74 65  m) " " (cadr ite
51d0: 6d 29 29 0a 09 20 20 20 20 20 20 28 73 65 74 65  m))..      (sete
51e0: 6e 76 20 28 63 61 72 20 69 74 65 6d 29 20 28 63  nv (car item) (c
51f0: 61 64 72 20 69 74 65 6d 29 29 29 0a 09 20 20 20  adr item)))..   
5200: 20 69 74 65 6d 64 61 74 29 29 0a 0a 28 64 65 66   itemdat))..(def
5210: 69 6e 65 20 28 67 65 74 2d 61 6c 6c 2d 6c 65 67  ine (get-all-leg
5220: 61 6c 2d 74 65 73 74 73 29 0a 20 20 28 6c 65 74  al-tests).  (let
5230: 2a 20 28 28 74 65 73 74 73 20 20 28 67 6c 6f 62  * ((tests  (glob
5240: 20 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74 68 2a   (conc *toppath*
5250: 20 22 2f 74 65 73 74 73 2f 2a 22 29 29 29 0a 09   "/tests/*")))..
5260: 20 28 72 65 73 20 20 20 20 27 28 29 29 29 0a 20   (res    '())). 
5270: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
5280: 34 20 22 49 4e 46 4f 3a 20 4c 6f 6f 6b 69 6e 67  4 "INFO: Looking
5290: 20 61 74 20 74 65 73 74 73 20 22 20 28 73 74 72   at tests " (str
52a0: 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20  ing-intersperse 
52b0: 74 65 73 74 73 20 22 2c 22 29 29 0a 20 20 20 20  tests ",")).    
52c0: 28 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64  (for-each (lambd
52d0: 61 20 28 74 65 73 74 70 61 74 68 29 0a 09 09 28  a (testpath)...(
52e0: 69 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f  if (file-exists?
52f0: 20 28 63 6f 6e 63 20 74 65 73 74 70 61 74 68 20   (conc testpath 
5300: 22 2f 74 65 73 74 63 6f 6e 66 69 67 22 29 29 0a  "/testconfig")).
5310: 09 09 20 20 20 20 28 73 65 74 21 20 72 65 73 20  ..    (set! res 
5320: 28 63 6f 6e 73 20 28 6c 61 73 74 20 28 73 74 72  (cons (last (str
5330: 69 6e 67 2d 73 70 6c 69 74 20 74 65 73 74 70 61  ing-split testpa
5340: 74 68 20 22 2f 22 29 29 20 72 65 73 29 29 29 29  th "/")) res))))
5350: 0a 09 20 20 20 20 20 20 74 65 73 74 73 29 0a 20  ..      tests). 
5360: 20 20 20 72 65 73 29 29 0a 0a 28 64 65 66 69 6e     res))..(defin
5370: 65 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d  e (runs:can-run-
5380: 6d 6f 72 65 2d 74 65 73 74 73 20 64 62 29 0a 20  more-tests db). 
5390: 20 28 6c 65 74 20 28 28 6e 75 6d 2d 72 75 6e 6e   (let ((num-runn
53a0: 69 6e 67 20 28 64 62 3a 67 65 74 2d 63 6f 75 6e  ing (db:get-coun
53b0: 74 2d 74 65 73 74 73 2d 72 75 6e 6e 69 6e 67 20  t-tests-running 
53c0: 64 62 29 29 0a 09 28 6d 61 78 2d 63 6f 6e 63 75  db))..(max-concu
53d0: 72 72 65 6e 74 2d 6a 6f 62 73 20 28 63 6f 6e 66  rrent-jobs (conf
53e0: 69 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69  ig-lookup *confi
53f0: 67 64 61 74 2a 20 22 73 65 74 75 70 22 20 22 6d  gdat* "setup" "m
5400: 61 78 5f 63 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f  ax_concurrent_jo
5410: 62 73 22 29 29 29 0a 20 20 20 20 28 64 65 62 75  bs"))).    (debu
5420: 67 3a 70 72 69 6e 74 20 32 20 22 6d 61 78 2d 63  g:print 2 "max-c
5430: 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 3a 20  oncurrent-jobs: 
5440: 22 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74  " max-concurrent
5450: 2d 6a 6f 62 73 20 22 2c 20 6e 75 6d 2d 72 75 6e  -jobs ", num-run
5460: 6e 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e  ning: " num-runn
5470: 69 6e 67 29 0a 20 20 20 20 28 69 66 20 28 6e 6f  ing).    (if (no
5480: 74 20 28 65 71 3f 20 30 20 2a 67 6c 6f 62 61 6c  t (eq? 0 *global
5490: 65 78 69 74 73 74 61 74 75 73 2a 29 29 0a 09 23  exitstatus*))..#
54a0: 66 0a 09 28 69 66 20 28 6f 72 20 28 6e 6f 74 20  f..(if (or (not 
54b0: 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a  max-concurrent-j
54c0: 6f 62 73 29 0a 09 09 28 61 6e 64 20 6d 61 78 2d  obs)...(and max-
54d0: 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 0a  concurrent-jobs.
54e0: 09 09 20 20 20 20 20 28 73 74 72 69 6e 67 2d 3e  ..     (string->
54f0: 6e 75 6d 62 65 72 20 6d 61 78 2d 63 6f 6e 63 75  number max-concu
5500: 72 72 65 6e 74 2d 6a 6f 62 73 29 0a 09 09 20 20  rrent-jobs)...  
5510: 20 20 20 28 6e 6f 74 20 28 3e 3d 20 6e 75 6d 2d     (not (>= num-
5520: 72 75 6e 6e 69 6e 67 20 28 73 74 72 69 6e 67 2d  running (string-
5530: 3e 6e 75 6d 62 65 72 20 6d 61 78 2d 63 6f 6e 63  >number max-conc
5540: 75 72 72 65 6e 74 2d 6a 6f 62 73 29 29 29 29 29  urrent-jobs)))))
5550: 0a 09 20 20 20 20 23 74 0a 09 20 20 20 20 28 62  ..    #t..    (b
5560: 65 67 69 6e 20 0a 09 20 20 20 20 20 20 28 64 65  egin ..      (de
5570: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52  bug:print 0 "WAR
5580: 4e 49 4e 47 3a 20 4d 61 78 20 72 75 6e 6e 69 6e  NING: Max runnin
5590: 67 20 6a 6f 62 73 20 65 78 63 65 65 64 65 64 2c  g jobs exceeded,
55a0: 20 63 75 72 72 65 6e 74 20 6e 75 6d 62 65 72 20   current number 
55b0: 72 75 6e 6e 69 6e 67 3a 20 22 20 6e 75 6d 2d 72  running: " num-r
55c0: 75 6e 6e 69 6e 67 20 0a 09 09 09 20 20 20 22 2c  unning ....   ",
55d0: 20 6d 61 78 5f 63 6f 6e 63 75 72 72 65 6e 74 5f   max_concurrent_
55e0: 6a 6f 62 73 3a 20 22 20 6d 61 78 2d 63 6f 6e 63  jobs: " max-conc
55f0: 75 72 72 65 6e 74 2d 6a 6f 62 73 29 0a 09 20 20  urrent-jobs)..  
5600: 20 20 20 20 23 66 29 29 29 29 29 0a 0a 28 64 65      #f)))))..(de
5610: 66 69 6e 65 20 28 74 65 73 74 3a 67 65 74 2d 74  fine (test:get-t
5620: 65 73 74 63 6f 6e 66 69 67 20 74 65 73 74 2d 6e  estconfig test-n
5630: 61 6d 65 20 73 79 73 74 65 6d 2d 61 6c 6c 6f 77  ame system-allow
5640: 65 64 29 0a 20 20 28 6c 65 74 2a 20 28 28 74 65  ed).  (let* ((te
5650: 73 74 2d 70 61 74 68 20 20 20 20 28 63 6f 6e 63  st-path    (conc
5660: 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f 74 65 73   *toppath* "/tes
5670: 74 73 2f 22 20 74 65 73 74 2d 6e 61 6d 65 29 29  ts/" test-name))
5680: 0a 09 20 28 74 65 73 74 2d 63 6f 6e 66 69 67 66  .. (test-configf
5690: 20 28 63 6f 6e 63 20 74 65 73 74 2d 70 61 74 68   (conc test-path
56a0: 20 22 2f 74 65 73 74 63 6f 6e 66 69 67 22 29 29   "/testconfig"))
56b0: 0a 09 20 28 74 65 73 74 65 78 69 73 74 73 20 20  .. (testexists  
56c0: 20 28 61 6e 64 20 28 66 69 6c 65 2d 65 78 69 73   (and (file-exis
56d0: 74 73 3f 20 74 65 73 74 2d 63 6f 6e 66 69 67 66  ts? test-configf
56e0: 29 28 66 69 6c 65 2d 72 65 61 64 2d 61 63 63 65  )(file-read-acce
56f0: 73 73 3f 20 74 65 73 74 2d 63 6f 6e 66 69 67 66  ss? test-configf
5700: 29 29 29 29 0a 20 20 20 20 28 69 66 20 74 65 73  )))).    (if tes
5710: 74 65 78 69 73 74 73 0a 09 28 72 65 61 64 2d 63  texists..(read-c
5720: 6f 6e 66 69 67 20 74 65 73 74 2d 63 6f 6e 66 69  onfig test-confi
5730: 67 66 20 23 66 20 73 79 73 74 65 6d 2d 61 6c 6c  gf #f system-all
5740: 6f 77 65 64 29 0a 09 23 66 29 29 29 0a 20 20 0a  owed)..#f))).  .
5750: 3b 3b 20 73 6f 72 74 20 74 65 73 74 73 20 62 79  ;; sort tests by
5760: 20 70 72 69 6f 72 69 74 79 20 61 6e 64 20 77 61   priority and wa
5770: 69 74 6f 6e 0a 3b 3b 20 4d 6f 76 65 20 74 65 73  iton.;; Move tes
5780: 74 20 73 70 65 63 69 66 69 63 20 73 74 75 66 66  t specific stuff
5790: 20 74 6f 20 61 20 74 65 73 74 20 75 6e 69 74 20   to a test unit 
57a0: 46 49 58 4d 45 20 6f 6e 65 20 6f 66 20 74 68 65  FIXME one of the
57b0: 73 65 20 64 61 79 73 0a 28 64 65 66 69 6e 65 20  se days.(define 
57c0: 28 74 65 73 74 73 3a 73 6f 72 74 2d 62 79 2d 70  (tests:sort-by-p
57d0: 72 69 6f 72 69 74 79 2d 61 6e 64 2d 77 61 69 74  riority-and-wait
57e0: 6f 6e 20 74 65 73 74 2d 6e 61 6d 65 73 29 0a 20  on test-names). 
57f0: 20 28 6c 65 74 20 28 28 74 65 73 74 64 65 74 61   (let ((testdeta
5800: 69 6c 73 20 20 20 28 6d 61 6b 65 2d 68 61 73 68  ils   (make-hash
5810: 2d 74 61 62 6c 65 29 29 0a 09 28 6d 75 6e 67 65  -table))..(munge
5820: 70 72 69 6f 72 69 74 79 20 28 6c 61 6d 62 64 61  priority (lambda
5830: 20 28 70 72 69 6f 72 69 74 79 29 0a 09 09 09 20   (priority).... 
5840: 28 69 66 20 70 72 69 6f 72 69 74 79 0a 09 09 09  (if priority....
5850: 20 20 20 20 20 28 6c 65 74 20 28 28 74 6d 70 20       (let ((tmp 
5860: 28 61 6e 79 2d 3e 6e 75 6d 62 65 72 20 70 72 69  (any->number pri
5870: 6f 72 69 74 79 29 29 29 0a 09 09 09 20 20 20 20  ority)))....    
5880: 20 20 20 28 69 66 20 74 6d 70 20 74 6d 70 20 28     (if tmp tmp (
5890: 62 65 67 69 6e 20 28 64 65 62 75 67 3a 70 72 69  begin (debug:pri
58a0: 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 62 61 64  nt 0 "ERROR: bad
58b0: 20 70 72 69 6f 72 69 74 79 20 76 61 6c 75 65 20   priority value 
58c0: 22 20 70 72 69 6f 72 69 74 79 20 22 2c 20 75 73  " priority ", us
58d0: 69 6e 67 20 30 22 29 20 30 29 29 29 0a 09 09 09  ing 0") 0)))....
58e0: 20 20 20 20 20 30 29 29 29 29 0a 20 20 20 20 28       0)))).    (
58f0: 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61  for-each (lambda
5900: 20 28 74 65 73 74 2d 6e 61 6d 65 29 0a 09 09 28   (test-name)...(
5910: 6c 65 74 20 28 28 74 65 73 74 2d 63 6f 6e 66 69  let ((test-confi
5920: 67 20 28 74 65 73 74 3a 67 65 74 2d 74 65 73 74  g (test:get-test
5930: 63 6f 6e 66 69 67 20 74 65 73 74 2d 6e 61 6d 65  config test-name
5940: 20 23 66 29 29 29 0a 09 09 20 20 28 69 66 20 74   #f)))...  (if t
5950: 65 73 74 2d 63 6f 6e 66 69 67 20 28 68 61 73 68  est-config (hash
5960: 2d 74 61 62 6c 65 2d 73 65 74 21 20 74 65 73 74  -table-set! test
5970: 64 65 74 61 69 6c 73 20 74 65 73 74 2d 6e 61 6d  details test-nam
5980: 65 20 74 65 73 74 2d 63 6f 6e 66 69 67 29 29 29  e test-config)))
5990: 29 0a 09 20 20 20 20 20 20 74 65 73 74 2d 6e 61  )..      test-na
59a0: 6d 65 73 29 0a 20 20 20 20 28 73 6f 72 74 20 0a  mes).    (sort .
59b0: 20 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65       (hash-table
59c0: 2d 6b 65 79 73 20 74 65 73 74 64 65 74 61 69 6c  -keys testdetail
59d0: 73 29 20 3b 3b 20 61 76 6f 69 64 20 64 65 61 6c  s) ;; avoid deal
59e0: 69 6e 67 20 77 69 74 68 20 64 65 6c 65 74 65 64  ing with deleted
59f0: 20 74 65 73 74 73 2c 20 6c 6f 6f 6b 20 61 74 20   tests, look at 
5a00: 74 68 65 20 68 61 73 68 20 74 61 62 6c 65 0a 20  the hash table. 
5a10: 20 20 20 20 28 6c 61 6d 62 64 61 20 28 61 20 62      (lambda (a b
5a20: 29 0a 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28  ).       (let* (
5a30: 28 74 63 6f 6e 66 2d 61 20 20 20 28 68 61 73 68  (tconf-a   (hash
5a40: 2d 74 61 62 6c 65 2d 72 65 66 20 74 65 73 74 64  -table-ref testd
5a50: 65 74 61 69 6c 73 20 61 29 29 0a 09 20 20 20 20  etails a))..    
5a60: 20 20 28 74 63 6f 6e 66 2d 62 20 20 20 28 68 61    (tconf-b   (ha
5a70: 73 68 2d 74 61 62 6c 65 2d 72 65 66 20 74 65 73  sh-table-ref tes
5a80: 74 64 65 74 61 69 6c 73 20 62 29 29 0a 09 20 20  tdetails b))..  
5a90: 20 20 20 20 28 61 2d 77 61 69 74 6f 6e 20 20 20      (a-waiton   
5aa0: 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 74  (config-lookup t
5ab0: 63 6f 6e 66 2d 61 20 22 72 65 71 75 69 72 65 6d  conf-a "requirem
5ac0: 65 6e 74 73 22 20 22 77 61 69 74 6f 6e 22 29 29  ents" "waiton"))
5ad0: 0a 09 20 20 20 20 20 20 28 62 2d 77 61 69 74 6f  ..      (b-waito
5ae0: 6e 20 20 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b  n   (config-look
5af0: 75 70 20 74 63 6f 6e 66 2d 62 20 22 72 65 71 75  up tconf-b "requ
5b00: 69 72 65 6d 65 6e 74 73 22 20 22 77 61 69 74 6f  irements" "waito
5b10: 6e 22 29 29 0a 09 20 20 20 20 20 20 28 61 2d 70  n"))..      (a-p
5b20: 72 69 6f 72 69 74 79 20 28 6d 75 6e 67 65 70 72  riority (mungepr
5b30: 69 6f 72 69 74 79 20 28 63 6f 6e 66 69 67 2d 6c  iority (config-l
5b40: 6f 6f 6b 75 70 20 74 63 6f 6e 66 2d 61 20 22 72  ookup tconf-a "r
5b50: 65 71 75 69 72 65 6d 65 6e 74 73 22 20 22 70 72  equirements" "pr
5b60: 69 6f 72 69 74 79 22 29 29 29 0a 09 20 20 20 20  iority")))..    
5b70: 20 20 28 62 2d 70 72 69 6f 72 69 74 79 20 28 6d    (b-priority (m
5b80: 75 6e 67 65 70 72 69 6f 72 69 74 79 20 28 63 6f  ungepriority (co
5b90: 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 74 63 6f 6e  nfig-lookup tcon
5ba0: 66 2d 62 20 22 72 65 71 75 69 72 65 6d 65 6e 74  f-b "requirement
5bb0: 73 22 20 22 70 72 69 6f 72 69 74 79 22 29 29 29  s" "priority")))
5bc0: 29 0a 09 20 28 69 66 20 28 61 6e 64 20 61 2d 77  ).. (if (and a-w
5bd0: 61 69 74 6f 6e 20 28 65 71 75 61 6c 3f 20 61 2d  aiton (equal? a-
5be0: 77 61 69 74 6f 6e 20 62 29 29 0a 09 20 20 20 20  waiton b))..    
5bf0: 20 23 66 20 3b 3b 20 63 61 6e 6e 6f 74 20 68 61   #f ;; cannot ha
5c00: 76 65 20 61 20 77 68 69 63 68 20 69 73 20 77 61  ve a which is wa
5c10: 69 74 69 6e 67 20 6f 6e 20 62 20 68 61 70 70 65  iting on b happe
5c20: 6e 69 6e 67 20 62 65 66 6f 72 65 20 62 0a 09 20  ning before b.. 
5c30: 20 20 20 20 28 69 66 20 28 61 6e 64 20 62 2d 77      (if (and b-w
5c40: 61 69 74 6f 6e 20 28 65 71 75 61 6c 3f 20 62 2d  aiton (equal? b-
5c50: 77 61 69 74 6f 6e 20 61 29 29 0a 09 09 20 23 74  waiton a))... #t
5c60: 20 3b 3b 20 74 68 69 73 20 69 73 20 74 68 65 20   ;; this is the 
5c70: 63 6f 72 72 65 63 74 20 6f 72 64 65 72 2c 20 62  correct order, b
5c80: 20 69 73 20 77 61 69 74 69 6e 67 20 6f 6e 20 61   is waiting on a
5c90: 20 61 6e 64 20 62 20 69 73 20 62 65 66 6f 72 65   and b is before
5ca0: 20 61 0a 09 09 20 28 69 66 20 28 3e 20 61 2d 70   a... (if (> a-p
5cb0: 72 69 6f 72 69 74 79 20 62 2d 70 72 69 6f 72 69  riority b-priori
5cc0: 74 79 29 0a 09 09 20 20 20 20 20 23 74 20 3b 3b  ty)...     #t ;;
5cd0: 20 69 66 20 61 20 69 73 20 61 20 68 69 67 68 65   if a is a highe
5ce0: 72 20 70 72 69 6f 72 69 74 79 20 74 68 61 6e 20  r priority than 
5cf0: 62 20 74 68 65 6e 20 77 65 20 61 72 65 20 67 6f  b then we are go
5d00: 6f 64 20 74 6f 20 67 6f 0a 09 09 20 20 20 20 20  od to go...     
5d10: 23 66 29 29 29 29 29 29 29 29 0a 0a 3b 3b 20 54  #f))))))))..;; T
5d20: 68 69 73 20 69 73 20 6f 72 69 67 69 6e 61 6c 20  his is original 
5d30: 72 75 6e 2d 74 65 73 74 73 2c 20 74 68 69 73 20  run-tests, this 
5d40: 72 6f 75 74 69 6e 65 20 69 73 20 64 65 70 72 65  routine is depre
5d50: 63 61 74 65 64 20 61 6e 64 20 77 65 20 77 69 6c  cated and we wil
5d60: 6c 20 74 72 61 6e 73 69 74 69 6f 6e 20 74 6f 20  l transition to 
5d70: 75 73 69 6e 67 20 72 75 6e 73 3a 72 75 6e 2d 74  using runs:run-t
5d80: 65 73 74 73 20 28 73 65 65 20 62 65 6c 6f 77 29  ests (see below)
5d90: 0a 3b 3b 0a 28 64 65 66 69 6e 65 20 28 72 75 6e  .;;.(define (run
5da0: 2d 74 65 73 74 73 20 64 62 20 74 65 73 74 2d 6e  -tests db test-n
5db0: 61 6d 65 73 29 0a 20 20 28 6c 65 74 2a 20 28 28  ames).  (let* ((
5dc0: 6b 65 79 73 20 20 20 20 20 20 20 20 28 64 62 2d  keys        (db-
5dd0: 67 65 74 2d 6b 65 79 73 20 64 62 29 29 0a 09 20  get-keys db)).. 
5de0: 28 6b 65 79 76 61 6c 6c 73 74 20 20 20 28 6b 65  (keyvallst   (ke
5df0: 79 73 2d 3e 76 61 6c 6c 69 73 74 20 6b 65 79 73  ys->vallist keys
5e00: 20 23 74 29 29 0a 09 20 28 72 75 6e 2d 69 64 20   #t)).. (run-id 
5e10: 20 20 20 20 20 28 72 65 67 69 73 74 65 72 2d 72       (register-r
5e20: 75 6e 20 64 62 20 6b 65 79 73 29 29 20 20 3b 3b  un db keys))  ;;
5e30: 20 20 74 65 73 74 2d 6e 61 6d 65 29 29 29 0a 09    test-name)))..
5e40: 20 28 64 65 66 65 72 72 65 64 20 20 20 20 27 28   (deferred    '(
5e50: 29 29 29 20 3b 3b 20 64 65 6c 61 79 20 72 75 6e  ))) ;; delay run
5e60: 6e 69 6e 67 20 74 68 65 73 65 20 73 69 6e 63 65  ning these since
5e70: 20 74 68 65 79 20 68 61 76 65 20 61 20 77 61 69   they have a wai
5e80: 74 6f 6e 20 63 6c 61 75 73 65 0a 20 20 20 20 3b  ton clause.    ;
5e90: 3b 20 6f 6e 20 74 68 65 20 66 69 72 73 74 20 70  ; on the first p
5ea0: 61 73 73 20 6f 72 20 63 61 6c 6c 20 74 6f 20 72  ass or call to r
5eb0: 75 6e 2d 74 65 73 74 73 20 73 65 74 20 46 41 49  un-tests set FAI
5ec0: 4c 53 20 74 6f 20 4e 4f 54 5f 53 54 41 52 54 45  LS to NOT_STARTE
5ed0: 44 20 69 66 0a 20 20 20 20 3b 3b 20 2d 6b 65 65  D if.    ;; -kee
5ee0: 70 67 6f 69 6e 67 20 69 73 20 73 70 65 63 69 66  pgoing is specif
5ef0: 69 65 64 0a 20 20 20 20 28 69 66 20 28 61 6e 64  ied.    (if (and
5f00: 20 28 65 71 3f 20 2a 70 61 73 73 6e 75 6d 2a 20   (eq? *passnum* 
5f10: 30 29 0a 09 20 20 20 20 20 28 61 72 67 73 3a 67  0)..     (args:g
5f20: 65 74 2d 61 72 67 20 22 2d 6b 65 65 70 67 6f 69  et-arg "-keepgoi
5f30: 6e 67 22 29 29 0a 09 28 62 65 67 69 6e 0a 09 20  ng"))..(begin.. 
5f40: 20 3b 3b 20 68 61 76 65 20 74 6f 20 64 65 6c 65   ;; have to dele
5f50: 74 65 20 74 65 73 74 20 72 65 63 6f 72 64 73 20  te test records 
5f60: 77 68 65 72 65 20 4e 4f 54 5f 53 54 41 52 54 45  where NOT_STARTE
5f70: 44 20 73 69 6e 63 65 20 74 68 65 79 20 63 61 6e  D since they can
5f80: 20 63 61 75 73 65 20 2d 6b 65 65 70 67 6f 69 6e   cause -keepgoin
5f90: 67 20 74 6f 20 0a 09 20 20 3b 3b 20 67 65 74 20  g to ..  ;; get 
5fa0: 73 74 75 63 6b 20 64 75 65 20 74 6f 20 62 65 63  stuck due to bec
5fb0: 6f 6d 69 6e 67 20 69 6e 61 63 63 65 73 73 69 62  oming inaccessib
5fc0: 6c 65 20 66 72 6f 6d 20 61 20 66 61 69 6c 65 64  le from a failed
5fd0: 20 74 65 73 74 2e 20 49 2e 65 2e 20 69 66 20 74   test. I.e. if t
5fe0: 65 73 74 20 42 20 64 65 70 65 6e 64 73 20 0a 09  est B depends ..
5ff0: 20 20 3b 3b 20 6f 6e 20 74 65 73 74 20 41 20 62    ;; on test A b
6000: 75 74 20 74 65 73 74 20 42 20 72 65 61 63 68 65  ut test B reache
6010: 64 20 74 68 65 20 70 6f 69 6e 74 20 6f 6e 20 62  d the point on b
6020: 65 69 6e 67 20 72 65 67 69 73 74 65 72 65 64 20  eing registered 
6030: 61 73 20 4e 4f 54 5f 53 54 41 52 54 45 44 20 61  as NOT_STARTED a
6040: 6e 64 20 74 65 73 74 0a 09 20 20 3b 3b 20 41 20  nd test..  ;; A 
6050: 66 61 69 6c 65 64 20 66 6f 72 20 73 6f 6d 65 20  failed for some 
6060: 72 65 61 73 6f 6e 20 74 68 65 6e 20 6f 6e 20 72  reason then on r
6070: 65 2d 72 75 6e 20 75 73 69 6e 67 20 2d 6b 65 65  e-run using -kee
6080: 70 67 6f 69 6e 67 20 74 68 65 20 72 75 6e 20 63  pgoing the run c
6090: 61 6e 20 6e 65 76 65 72 20 63 6f 6d 70 6c 65 74  an never complet
60a0: 65 2e 0a 09 20 20 28 64 62 3a 64 65 6c 65 74 65  e...  (db:delete
60b0: 2d 74 65 73 74 73 2d 69 6e 2d 73 74 61 74 65 20  -tests-in-state 
60c0: 64 62 20 72 75 6e 2d 69 64 20 22 4e 4f 54 5f 53  db run-id "NOT_S
60d0: 54 41 52 54 45 44 22 29 0a 09 20 20 28 64 62 3a  TARTED")..  (db:
60e0: 73 65 74 2d 74 65 73 74 73 2d 73 74 61 74 65 2d  set-tests-state-
60f0: 73 74 61 74 75 73 20 64 62 20 72 75 6e 2d 69 64  status db run-id
6100: 20 74 65 73 74 2d 6e 61 6d 65 73 20 23 66 20 22   test-names #f "
6110: 46 41 49 4c 22 20 22 4e 4f 54 5f 53 54 41 52 54  FAIL" "NOT_START
6120: 45 44 22 20 22 46 41 49 4c 22 29 29 29 0a 20 20  ED" "FAIL"))).  
6130: 20 20 28 73 65 74 21 20 2a 70 61 73 73 6e 75 6d    (set! *passnum
6140: 2a 20 28 2b 20 2a 70 61 73 73 6e 75 6d 2a 20 31  * (+ *passnum* 1
6150: 29 29 0a 20 20 20 20 28 6c 65 74 20 6c 6f 6f 70  )).    (let loop
6160: 20 28 28 6e 75 6d 74 69 6d 65 73 20 30 29 29 0a   ((numtimes 0)).
6170: 20 20 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20        (for-each 
6180: 0a 20 20 20 20 20 20 20 28 6c 61 6d 62 64 61 20  .       (lambda 
6190: 28 74 65 73 74 2d 6e 61 6d 65 29 0a 09 20 28 69  (test-name).. (i
61a0: 66 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d  f (runs:can-run-
61b0: 6d 6f 72 65 2d 74 65 73 74 73 20 64 62 29 0a 09  more-tests db)..
61c0: 20 20 20 20 20 28 72 75 6e 2d 6f 6e 65 2d 74 65       (run-one-te
61d0: 73 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  st db run-id tes
61e0: 74 2d 6e 61 6d 65 20 6b 65 79 76 61 6c 6c 73 74  t-name keyvallst
61f0: 29 0a 09 20 20 20 20 20 3b 3b 20 61 64 64 20 73  )..     ;; add s
6200: 6f 6d 65 20 64 65 6c 61 79 20 0a 09 20 20 20 20  ome delay ..    
6210: 20 3b 28 73 6c 65 65 70 20 32 29 0a 09 20 20 20   ;(sleep 2)..   
6220: 20 20 29 29 0a 20 20 20 20 20 20 20 28 74 65 73    )).       (tes
6230: 74 73 3a 73 6f 72 74 2d 62 79 2d 70 72 69 6f 72  ts:sort-by-prior
6240: 69 74 79 2d 61 6e 64 2d 77 61 69 74 6f 6e 20 74  ity-and-waiton t
6250: 65 73 74 2d 6e 61 6d 65 73 29 29 0a 20 20 20 20  est-names)).    
6260: 20 20 3b 3b 20 28 72 75 6e 2d 77 61 69 74 69 6e    ;; (run-waitin
6270: 67 2d 74 65 73 74 73 20 64 62 29 0a 20 20 20 20  g-tests db).    
6280: 20 20 28 69 66 20 28 61 72 67 73 3a 67 65 74 2d    (if (args:get-
6290: 61 72 67 20 22 2d 6b 65 65 70 67 6f 69 6e 67 22  arg "-keepgoing"
62a0: 29 0a 09 20 20 28 6c 65 74 20 28 28 65 73 74 72  )..  (let ((estr
62b0: 65 6d 20 28 64 62 3a 65 73 74 69 6d 61 74 65 64  em (db:estimated
62c0: 2d 74 65 73 74 73 2d 72 65 6d 61 69 6e 69 6e 67  -tests-remaining
62d0: 20 64 62 20 72 75 6e 2d 69 64 29 29 29 0a 09 20   db run-id))).. 
62e0: 20 20 20 28 69 66 20 28 61 6e 64 20 28 3e 20 65     (if (and (> e
62f0: 73 74 72 65 6d 20 30 29 0a 09 09 20 20 20 20 20  strem 0)...     
6300: 28 65 71 3f 20 2a 67 6c 6f 62 61 6c 65 78 69 74  (eq? *globalexit
6310: 73 74 61 74 75 73 2a 20 30 29 29 0a 09 09 28 62  status* 0))...(b
6320: 65 67 69 6e 0a 09 09 20 20 28 64 65 62 75 67 3a  egin...  (debug:
6330: 70 72 69 6e 74 20 31 20 22 4b 65 65 70 20 67 6f  print 1 "Keep go
6340: 69 6e 67 2c 20 65 73 74 69 6d 61 74 65 64 20 22  ing, estimated "
6350: 20 65 73 74 72 65 6d 20 22 20 74 65 73 74 73 20   estrem " tests 
6360: 72 65 6d 61 69 6e 69 6e 67 20 74 6f 20 72 75 6e  remaining to run
6370: 2c 20 77 69 6c 6c 20 63 6f 6e 74 69 6e 75 65 20  , will continue 
6380: 69 6e 20 33 20 73 65 63 6f 6e 64 73 20 2e 2e 2e  in 3 seconds ...
6390: 22 29 0a 09 09 20 20 28 73 6c 65 65 70 20 33 29  ")...  (sleep 3)
63a0: 0a 09 09 20 20 28 72 75 6e 2d 77 61 69 74 69 6e  ...  (run-waitin
63b0: 67 2d 74 65 73 74 73 20 64 62 29 0a 09 09 20 20  g-tests db)...  
63c0: 28 6c 6f 6f 70 20 28 2b 20 6e 75 6d 74 69 6d 65  (loop (+ numtime
63d0: 73 20 31 29 29 29 29 29 29 29 29 29 0a 09 20 20  s 1)))))))))..  
63e0: 0a 3b 3b 20 56 45 52 59 20 49 4e 45 46 46 49 43  .;; VERY INEFFIC
63f0: 49 45 4e 54 21 20 4d 6f 76 65 20 73 74 75 66 66  IENT! Move stuff
6400: 20 74 68 61 74 20 73 68 6f 75 6c 64 20 62 65 20   that should be 
6410: 64 6f 6e 65 20 6f 6e 63 65 20 75 70 20 74 6f 20  done once up to 
6420: 63 61 6c 6c 69 6e 67 20 70 72 6f 63 0a 28 64 65  calling proc.(de
6430: 66 69 6e 65 20 28 72 75 6e 2d 6f 6e 65 2d 74 65  fine (run-one-te
6440: 73 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  st db run-id tes
6450: 74 2d 6e 61 6d 65 20 6b 65 79 76 61 6c 6c 73 74  t-name keyvallst
6460: 29 0a 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ).  (debug:print
6470: 20 31 20 22 4c 61 75 6e 63 68 69 6e 67 20 74 65   1 "Launching te
6480: 73 74 20 22 20 74 65 73 74 2d 6e 61 6d 65 29 0a  st " test-name).
6490: 20 20 3b 3b 20 41 6c 6c 20 74 68 65 73 65 20 76    ;; All these v
64a0: 61 72 73 20 6d 69 67 68 74 20 62 65 20 72 65 66  ars might be ref
64b0: 65 72 65 6e 63 65 64 20 62 79 20 74 68 65 20 74  erenced by the t
64c0: 65 73 74 63 6f 6e 66 69 67 20 66 69 6c 65 20 72  estconfig file r
64d0: 65 61 64 65 72 0a 20 20 28 73 65 74 65 6e 76 20  eader.  (setenv 
64e0: 22 4d 54 5f 54 45 53 54 5f 4e 41 4d 45 22 20 74  "MT_TEST_NAME" t
64f0: 65 73 74 2d 6e 61 6d 65 29 20 3b 3b 20 0a 20 20  est-name) ;; .  
6500: 28 73 65 74 65 6e 76 20 22 4d 54 5f 52 55 4e 4e  (setenv "MT_RUNN
6510: 41 4d 45 22 20 20 20 28 61 72 67 73 3a 67 65 74  AME"   (args:get
6520: 2d 61 72 67 20 22 3a 72 75 6e 6e 61 6d 65 22 29  -arg ":runname")
6530: 29 0a 20 20 28 73 65 74 2d 6d 65 67 61 74 65 73  ).  (set-megates
6540: 74 2d 65 6e 76 2d 76 61 72 73 20 64 62 20 72 75  t-env-vars db ru
6550: 6e 2d 69 64 29 20 3b 3b 20 74 68 65 73 65 20 6d  n-id) ;; these m
6560: 61 79 20 62 65 20 6e 65 65 64 65 64 20 62 79 20  ay be needed by 
6570: 74 68 65 20 6c 61 75 6e 63 68 69 6e 67 20 70 72  the launching pr
6580: 6f 63 65 73 73 0a 20 20 28 63 68 61 6e 67 65 2d  ocess.  (change-
6590: 64 69 72 65 63 74 6f 72 79 20 2a 74 6f 70 70 61  directory *toppa
65a0: 74 68 2a 29 0a 20 20 28 6c 65 74 2a 20 28 28 74  th*).  (let* ((t
65b0: 65 73 74 2d 70 61 74 68 20 20 20 20 28 63 6f 6e  est-path    (con
65c0: 63 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f 74 65  c *toppath* "/te
65d0: 73 74 73 2f 22 20 74 65 73 74 2d 6e 61 6d 65 29  sts/" test-name)
65e0: 29 20 3b 3b 20 63 6f 75 6c 64 20 75 73 65 20 74  ) ;; could use t
65f0: 65 73 74 3a 67 65 74 2d 74 65 73 74 63 6f 6e 66  est:get-testconf
6600: 69 67 20 68 65 72 65 20 2e 2e 2e 0a 09 20 28 74  ig here ..... (t
6610: 65 73 74 2d 63 6f 6e 66 69 67 66 20 28 63 6f 6e  est-configf (con
6620: 63 20 74 65 73 74 2d 70 61 74 68 20 22 2f 74 65  c test-path "/te
6630: 73 74 63 6f 6e 66 69 67 22 29 29 0a 09 20 28 74  stconfig")).. (t
6640: 65 73 74 65 78 69 73 74 73 20 20 20 28 61 6e 64  estexists   (and
6650: 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 74   (file-exists? t
6660: 65 73 74 2d 63 6f 6e 66 69 67 66 29 28 66 69 6c  est-configf)(fil
6670: 65 2d 72 65 61 64 2d 61 63 63 65 73 73 3f 20 74  e-read-access? t
6680: 65 73 74 2d 63 6f 6e 66 69 67 66 29 29 29 0a 09  est-configf)))..
6690: 20 28 74 65 73 74 2d 63 6f 6e 66 20 20 20 20 28   (test-conf    (
66a0: 69 66 20 74 65 73 74 65 78 69 73 74 73 20 28 72  if testexists (r
66b0: 65 61 64 2d 63 6f 6e 66 69 67 20 74 65 73 74 2d  ead-config test-
66c0: 63 6f 6e 66 69 67 66 20 23 66 20 23 74 29 20 28  configf #f #t) (
66d0: 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 29  make-hash-table)
66e0: 29 29 0a 09 20 28 77 61 69 74 6f 6e 20 20 20 20  )).. (waiton    
66f0: 20 20 20 28 6c 65 74 20 28 28 77 20 28 63 6f 6e     (let ((w (con
6700: 66 69 67 2d 6c 6f 6f 6b 75 70 20 74 65 73 74 2d  fig-lookup test-
6710: 63 6f 6e 66 20 22 72 65 71 75 69 72 65 6d 65 6e  conf "requiremen
6720: 74 73 22 20 22 77 61 69 74 6f 6e 22 29 29 29 0a  ts" "waiton"))).
6730: 09 09 09 20 28 69 66 20 28 73 74 72 69 6e 67 3f  ... (if (string?
6740: 20 77 29 28 73 74 72 69 6e 67 2d 73 70 6c 69 74   w)(string-split
6750: 20 77 29 27 28 29 29 29 29 0a 09 20 28 74 61 67   w)'()))).. (tag
6760: 73 20 20 20 20 20 20 20 20 20 28 6c 65 74 20 28  s         (let (
6770: 28 74 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75  (t (config-looku
6780: 70 20 74 65 73 74 2d 63 6f 6e 66 20 22 73 65 74  p test-conf "set
6790: 75 70 22 20 22 74 61 67 73 22 29 29 29 0a 09 09  up" "tags")))...
67a0: 09 20 3b 3b 20 77 65 20 77 61 6e 74 20 6f 75 72  . ;; we want our
67b0: 20 74 61 67 73 20 74 6f 20 62 65 20 73 65 70 61   tags to be sepa
67c0: 72 61 74 65 64 20 62 79 20 63 6f 6d 6d 61 73 20  rated by commas 
67d0: 61 6e 64 20 66 75 6c 6c 79 20 64 65 6c 69 6d 69  and fully delimi
67e0: 74 65 64 20 62 79 20 63 6f 6d 6d 61 73 0a 09 09  ted by commas...
67f0: 09 20 3b 3b 20 73 6f 20 74 68 61 74 20 71 75 65  . ;; so that que
6800: 72 69 65 73 20 77 69 74 68 20 22 6c 69 6b 65 22  ries with "like"
6810: 20 63 61 6e 20 74 69 65 20 74 6f 20 74 68 65 20   can tie to the 
6820: 63 6f 6d 6d 61 73 20 61 74 20 65 69 74 68 65 72  commas at either
6830: 20 65 6e 64 20 6f 66 20 65 61 63 68 20 74 61 67   end of each tag
6840: 0a 09 09 09 20 3b 3b 20 77 68 69 6c 65 20 61 6c  .... ;; while al
6850: 73 6f 20 61 6c 6c 6f 77 69 6e 67 20 74 68 65 20  so allowing the 
6860: 65 6e 64 20 75 73 65 72 20 74 6f 20 66 72 65 65  end user to free
6870: 6c 79 20 75 73 65 20 73 70 61 63 65 73 20 61 6e  ly use spaces an
6880: 64 20 63 6f 6d 6d 61 73 20 74 6f 20 73 65 70 61  d commas to sepa
6890: 72 61 74 65 20 74 61 67 73 0a 09 09 09 20 28 69  rate tags.... (i
68a0: 66 20 28 73 74 72 69 6e 67 3f 20 74 29 28 73 74  f (string? t)(st
68b0: 72 69 6e 67 2d 73 75 62 73 74 69 74 75 74 65 20  ring-substitute 
68c0: 28 72 65 67 65 78 70 20 22 5b 2c 5c 5c 73 5d 2b  (regexp "[,\\s]+
68d0: 22 29 20 22 2c 22 20 28 63 6f 6e 63 20 22 2c 22  ") "," (conc ","
68e0: 20 74 20 22 2c 22 29 20 23 74 29 0a 09 09 09 20   t ",") #t).... 
68f0: 20 20 20 20 27 28 29 29 29 29 29 0a 20 20 20 20      '())))).    
6900: 28 69 66 20 28 6e 6f 74 20 74 65 73 74 65 78 69  (if (not testexi
6910: 73 74 73 29 0a 09 28 62 65 67 69 6e 0a 09 20 20  sts)..(begin..  
6920: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
6930: 45 52 52 4f 52 3a 20 43 61 6e 27 74 20 66 69 6e  ERROR: Can't fin
6940: 64 20 63 6f 6e 66 69 67 20 66 69 6c 65 20 22 20  d config file " 
6950: 74 65 73 74 2d 63 6f 6e 66 69 67 66 29 0a 09 20  test-configf).. 
6960: 20 28 65 78 69 74 20 32 29 29 0a 09 3b 3b 20 70   (exit 2))..;; p
6970: 75 74 20 74 6f 70 20 76 61 72 73 20 69 6e 74 6f  ut top vars into
6980: 20 63 6f 6e 76 65 6e 69 65 6e 74 20 76 61 72 69   convenient vari
6990: 61 62 6c 65 73 20 61 6e 64 20 6f 70 65 6e 20 74  ables and open t
69a0: 68 65 20 64 62 0a 09 28 6c 65 74 2a 20 28 3b 3b  he db..(let* (;;
69b0: 20 64 62 20 69 73 20 61 6c 77 61 79 73 20 61 74   db is always at
69c0: 20 2a 74 6f 70 70 61 74 68 2a 2f 64 62 2f 6d 65   *toppath*/db/me
69d0: 67 61 74 65 73 74 2e 64 62 0a 09 20 20 20 20 20  gatest.db..     
69e0: 20 20 28 69 74 65 6d 73 20 20 20 20 20 20 20 28    (items       (
69f0: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64  hash-table-ref/d
6a00: 65 66 61 75 6c 74 20 74 65 73 74 2d 63 6f 6e 66  efault test-conf
6a10: 20 22 69 74 65 6d 73 22 20 27 28 29 29 29 0a 09   "items" '()))..
6a20: 20 20 20 20 20 20 20 28 69 74 65 6d 73 74 61 62         (itemstab
6a30: 6c 65 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d  le  (hash-table-
6a40: 72 65 66 2f 64 65 66 61 75 6c 74 20 74 65 73 74  ref/default test
6a50: 2d 63 6f 6e 66 20 22 69 74 65 6d 73 74 61 62 6c  -conf "itemstabl
6a60: 65 22 20 27 28 29 29 29 0a 09 20 20 20 20 20 20  e" '()))..      
6a70: 20 28 61 6c 6c 69 74 65 6d 73 20 20 20 20 28 69   (allitems    (i
6a80: 66 20 28 6f 72 20 28 6e 6f 74 20 28 6e 75 6c 6c  f (or (not (null
6a90: 3f 20 69 74 65 6d 73 29 29 28 6e 6f 74 20 28 6e  ? items))(not (n
6aa0: 75 6c 6c 3f 20 69 74 65 6d 73 74 61 62 6c 65 29  ull? itemstable)
6ab0: 29 29 0a 09 09 09 09 28 61 70 70 65 6e 64 20 28  )).....(append (
6ac0: 69 74 65 6d 2d 61 73 73 6f 63 2d 3e 69 74 65 6d  item-assoc->item
6ad0: 2d 6c 69 73 74 20 69 74 65 6d 73 29 0a 09 09 09  -list items)....
6ae0: 09 09 28 69 74 65 6d 2d 74 61 62 6c 65 2d 3e 69  ..(item-table->i
6af0: 74 65 6d 2d 6c 69 73 74 20 69 74 65 6d 73 74 61  tem-list itemsta
6b00: 62 6c 65 29 29 0a 09 09 09 09 27 28 28 29 29 29  ble)).....'(()))
6b10: 29 20 3b 3b 20 61 20 6c 69 73 74 20 77 69 74 68  ) ;; a list with
6b20: 20 6f 6e 65 20 6e 75 6c 6c 20 6c 69 73 74 20 69   one null list i
6b30: 73 20 61 20 74 65 73 74 20 77 69 74 68 20 6e 6f  s a test with no
6b40: 20 69 74 65 6d 73 0a 09 20 20 20 20 20 20 20 28   items..       (
6b50: 72 75 6e 63 6f 6e 66 69 67 66 20 20 28 63 6f 6e  runconfigf  (con
6b60: 63 20 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f 72  c  *toppath* "/r
6b70: 75 6e 63 6f 6e 66 69 67 73 2e 63 6f 6e 66 69 67  unconfigs.config
6b80: 22 29 29 29 0a 09 20 20 28 64 65 62 75 67 3a 70  ")))..  (debug:p
6b90: 72 69 6e 74 20 31 20 22 69 74 65 6d 73 3a 20 22  rint 1 "items: "
6ba0: 29 0a 09 20 20 28 69 66 20 28 3e 3d 20 2a 76 65  )..  (if (>= *ve
6bb0: 72 62 6f 73 69 74 79 2a 20 31 29 28 70 70 20 61  rbosity* 1)(pp a
6bc0: 6c 6c 69 74 65 6d 73 29 29 0a 09 20 20 28 69 66  llitems))..  (if
6bd0: 20 28 3e 3d 20 2a 76 65 72 62 6f 73 69 74 79 2a   (>= *verbosity*
6be0: 20 35 29 0a 09 20 20 20 20 20 20 28 62 65 67 69   5)..      (begi
6bf0: 6e 0a 09 09 28 70 72 69 6e 74 20 22 69 74 65 6d  n...(print "item
6c00: 73 3a 20 22 29 28 70 70 20 28 69 74 65 6d 2d 61  s: ")(pp (item-a
6c10: 73 73 6f 63 2d 3e 69 74 65 6d 2d 6c 69 73 74 20  ssoc->item-list 
6c20: 69 74 65 6d 73 29 29 0a 09 09 28 70 72 69 6e 74  items))...(print
6c30: 20 22 69 74 65 73 74 61 62 6c 65 3a 20 22 29 28   "itestable: ")(
6c40: 70 70 20 28 69 74 65 6d 2d 74 61 62 6c 65 2d 3e  pp (item-table->
6c50: 69 74 65 6d 2d 6c 69 73 74 20 69 74 65 6d 73 74  item-list itemst
6c60: 61 62 6c 65 29 29 29 29 0a 09 20 20 28 69 66 20  able))))..  (if 
6c70: 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d  (args:get-arg "-
6c80: 6d 22 29 0a 09 20 20 20 20 20 20 28 64 62 3a 73  m")..      (db:s
6c90: 65 74 2d 63 6f 6d 6d 65 6e 74 2d 66 6f 72 2d 72  et-comment-for-r
6ca0: 75 6e 20 64 62 20 72 75 6e 2d 69 64 20 28 61 72  un db run-id (ar
6cb0: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 6d 22 29  gs:get-arg "-m")
6cc0: 29 29 0a 0a 09 20 20 3b 3b 20 48 65 72 65 20 69  ))...  ;; Here i
6cd0: 73 20 77 68 65 72 65 20 74 68 65 20 74 65 73 74  s where the test
6ce0: 5f 6d 65 74 61 20 74 61 62 6c 65 20 69 73 20 62  _meta table is b
6cf0: 65 73 74 20 75 70 64 61 74 65 64 0a 09 20 20 28  est updated..  (
6d00: 72 75 6e 73 3a 75 70 64 61 74 65 2d 74 65 73 74  runs:update-test
6d10: 5f 6d 65 74 61 20 64 62 20 74 65 73 74 2d 6e 61  _meta db test-na
6d20: 6d 65 20 74 65 73 74 2d 63 6f 6e 66 29 0a 0a 09  me test-conf)...
6d30: 20 20 3b 3b 20 62 72 61 69 6e 64 65 61 64 20 77    ;; braindead w
6d40: 6f 72 6b 2d 61 72 6f 75 6e 64 20 66 6f 72 20 70  ork-around for p
6d50: 6f 6f 72 6c 79 20 73 70 65 63 69 66 69 65 64 20  oorly specified 
6d60: 61 6c 6c 69 74 65 6d 73 20 6c 69 73 74 20 42 55  allitems list BU
6d70: 47 21 21 21 20 46 49 58 4d 45 0a 09 20 20 28 69  G!!! FIXME..  (i
6d80: 66 20 28 6e 75 6c 6c 3f 20 61 6c 6c 69 74 65 6d  f (null? allitem
6d90: 73 29 28 73 65 74 21 20 61 6c 6c 69 74 65 6d 73  s)(set! allitems
6da0: 20 27 28 28 29 29 29 29 0a 09 20 20 28 6c 65 74   '(())))..  (let
6db0: 20 6c 6f 6f 70 20 28 28 69 74 65 6d 64 61 74 20   loop ((itemdat 
6dc0: 28 63 61 72 20 61 6c 6c 69 74 65 6d 73 29 29 0a  (car allitems)).
6dd0: 09 09 20 20 20 20 20 28 74 61 6c 20 20 20 20 20  ..     (tal     
6de0: 28 63 64 72 20 61 6c 6c 69 74 65 6d 73 29 29 29  (cdr allitems)))
6df0: 0a 09 20 20 20 20 3b 3b 20 28 6c 61 6d 62 64 61  ..    ;; (lambda
6e00: 20 28 69 74 65 6d 64 61 74 29 20 3b 3b 3b 20 28   (itemdat) ;;; (
6e10: 28 72 69 70 65 6e 65 73 73 20 22 6f 76 65 72 72  (ripeness "overr
6e20: 69 70 65 22 29 20 28 74 65 6d 70 65 72 61 74 75  ipe") (temperatu
6e30: 72 65 20 22 63 6f 6f 6c 22 29 20 28 73 65 61 73  re "cool") (seas
6e40: 6f 6e 20 22 73 75 6d 6d 65 72 22 29 29 0a 09 20  on "summer")).. 
6e50: 20 20 20 3b 3b 20 48 61 6e 64 6c 65 20 6c 69 73     ;; Handle lis
6e60: 74 73 20 6f 66 20 69 74 65 6d 73 0a 09 20 20 20  ts of items..   
6e70: 20 28 6c 65 74 2a 20 28 28 69 74 65 6d 2d 70 61   (let* ((item-pa
6e80: 74 68 20 20 20 20 20 28 69 74 65 6d 2d 6c 69 73  th     (item-lis
6e90: 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74 29  t->path itemdat)
6ea0: 29 20 3b 3b 20 28 73 74 72 69 6e 67 2d 69 6e 74  ) ;; (string-int
6eb0: 65 72 73 70 65 72 73 65 20 28 6d 61 70 20 63 61  ersperse (map ca
6ec0: 64 72 20 69 74 65 6d 64 61 74 29 20 22 2f 22 29  dr itemdat) "/")
6ed0: 29 0a 09 09 20 20 20 28 6e 65 77 2d 74 65 73 74  )...   (new-test
6ee0: 2d 70 61 74 68 20 28 73 74 72 69 6e 67 2d 69 6e  -path (string-in
6ef0: 74 65 72 73 70 65 72 73 65 20 28 63 6f 6e 73 20  tersperse (cons 
6f00: 74 65 73 74 2d 70 61 74 68 20 28 6d 61 70 20 63  test-path (map c
6f10: 61 64 72 20 69 74 65 6d 64 61 74 29 29 20 22 2f  adr itemdat)) "/
6f20: 22 29 29 0a 09 09 20 20 20 28 6e 65 77 2d 74 65  "))...   (new-te
6f30: 73 74 2d 6e 61 6d 65 20 28 69 66 20 28 65 71 75  st-name (if (equ
6f40: 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 22  al? item-path ""
6f50: 29 20 74 65 73 74 2d 6e 61 6d 65 20 28 63 6f 6e  ) test-name (con
6f60: 63 20 74 65 73 74 2d 6e 61 6d 65 20 22 2f 22 20  c test-name "/" 
6f70: 69 74 65 6d 2d 70 61 74 68 29 29 29 20 3b 3b 20  item-path))) ;; 
6f80: 6a 75 73 74 20 6e 65 65 64 20 69 74 20 74 6f 20  just need it to 
6f90: 62 65 20 75 6e 69 71 75 65 0a 09 09 20 20 20 28  be unique...   (
6fa0: 74 65 73 74 64 61 74 20 20 20 23 66 29 0a 09 09  testdat   #f)...
6fb0: 20 20 20 28 6e 75 6d 2d 72 75 6e 6e 69 6e 67 20     (num-running 
6fc0: 28 64 62 3a 67 65 74 2d 63 6f 75 6e 74 2d 74 65  (db:get-count-te
6fd0: 73 74 73 2d 72 75 6e 6e 69 6e 67 20 64 62 29 29  sts-running db))
6fe0: 0a 09 09 20 20 20 28 6d 61 78 2d 63 6f 6e 63 75  ...   (max-concu
6ff0: 72 72 65 6e 74 2d 6a 6f 62 73 20 28 63 6f 6e 66  rrent-jobs (conf
7000: 69 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69  ig-lookup *confi
7010: 67 64 61 74 2a 20 22 73 65 74 75 70 22 20 22 6d  gdat* "setup" "m
7020: 61 78 5f 63 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f  ax_concurrent_jo
7030: 62 73 22 29 29 0a 09 09 20 20 20 28 70 61 72 65  bs"))...   (pare
7040: 6e 74 2d 74 65 73 74 20 28 61 6e 64 20 28 6e 6f  nt-test (and (no
7050: 74 20 28 6e 75 6c 6c 3f 20 69 74 65 6d 73 29 29  t (null? items))
7060: 28 65 71 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74  (equal? item-pat
7070: 68 20 22 22 29 29 29 0a 09 09 20 20 20 28 73 69  h "")))...   (si
7080: 6e 67 6c 65 2d 74 65 73 74 20 28 61 6e 64 20 28  ngle-test (and (
7090: 6e 75 6c 6c 3f 20 69 74 65 6d 73 29 20 28 65 71  null? items) (eq
70a0: 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22  ual? item-path "
70b0: 22 29 29 29 0a 09 09 20 20 20 28 69 74 65 6d 2d  ")))...   (item-
70c0: 74 65 73 74 20 20 20 28 6e 6f 74 20 28 65 71 75  test   (not (equ
70d0: 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 22  al? item-path ""
70e0: 29 29 29 0a 09 09 20 20 20 28 69 74 65 6d 2d 70  )))...   (item-p
70f0: 61 74 74 20 20 20 28 61 72 67 73 3a 67 65 74 2d  att   (args:get-
7100: 61 72 67 20 22 2d 69 74 65 6d 70 61 74 74 22 29  arg "-itempatt")
7110: 29 0a 09 09 20 20 20 28 70 61 74 74 2d 6d 61 74  )...   (patt-mat
7120: 63 68 20 20 28 69 66 20 69 74 65 6d 2d 70 61 74  ch  (if item-pat
7130: 74 0a 09 09 09 09 20 20 20 20 28 73 74 72 69 6e  t.....    (strin
7140: 67 2d 6d 61 74 63 68 20 28 67 6c 6f 62 2d 3e 72  g-match (glob->r
7150: 65 67 65 78 70 0a 09 09 09 09 09 09 20 20 20 28  egexp.......   (
7160: 73 74 72 69 6e 67 2d 74 72 61 6e 73 6c 61 74 65  string-translate
7170: 20 69 74 65 6d 2d 70 61 74 74 20 22 25 22 20 22   item-patt "%" "
7180: 2a 22 29 29 0a 09 09 09 09 09 09 20 20 69 74 65  *")).......  ite
7190: 6d 2d 70 61 74 68 29 0a 09 09 09 09 20 20 20 20  m-path).....    
71a0: 23 74 29 29 29 0a 09 20 20 20 20 20 20 28 64 65  #t)))..      (de
71b0: 62 75 67 3a 70 72 69 6e 74 20 33 20 22 6d 61 78  bug:print 3 "max
71c0: 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73  -concurrent-jobs
71d0: 3a 20 22 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65  : " max-concurre
71e0: 6e 74 2d 6a 6f 62 73 20 22 2c 20 6e 75 6d 2d 72  nt-jobs ", num-r
71f0: 75 6e 6e 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75  unning: " num-ru
7200: 6e 6e 69 6e 67 29 0a 09 20 20 20 20 20 20 28 69  nning)..      (i
7210: 66 20 28 61 6e 64 20 70 61 74 74 2d 6d 61 74 63  f (and patt-matc
7220: 68 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d  h (runs:can-run-
7230: 6d 6f 72 65 2d 74 65 73 74 73 20 64 62 29 29 0a  more-tests db)).
7240: 09 09 20 20 28 62 65 67 69 6e 0a 09 09 20 20 20  ..  (begin...   
7250: 20 28 6c 65 74 20 6c 6f 6f 70 32 20 28 28 74 73   (let loop2 ((ts
7260: 20 28 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e   (db:get-test-in
7270: 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  fo db run-id tes
7280: 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68  t-name item-path
7290: 29 29 20 3b 3b 20 23 66 29 0a 09 09 09 09 28 63  )) ;; #f).....(c
72a0: 74 20 30 29 29 0a 09 09 20 20 20 20 20 20 28 69  t 0))...      (i
72b0: 66 20 28 61 6e 64 20 28 6e 6f 74 20 74 73 29 0a  f (and (not ts).
72c0: 09 09 09 20 20 20 20 20 20 20 28 3c 20 63 74 20  ...       (< ct 
72d0: 31 30 29 29 0a 09 09 09 20 20 28 62 65 67 69 6e  10))....  (begin
72e0: 0a 09 09 09 20 20 20 20 28 72 65 67 69 73 74 65  ....    (registe
72f0: 72 2d 74 65 73 74 20 64 62 20 72 75 6e 2d 69 64  r-test db run-id
7300: 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d   test-name item-
7310: 70 61 74 68 29 0a 09 09 09 20 20 20 20 28 64 62  path)....    (db
7320: 3a 74 65 73 74 2d 73 65 74 2d 63 6f 6d 6d 65 6e  :test-set-commen
7330: 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  t db run-id test
7340: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 20  -name item-path 
7350: 22 22 29 0a 09 09 09 20 20 20 20 28 6c 6f 6f 70  "")....    (loop
7360: 32 20 28 64 62 3a 67 65 74 2d 74 65 73 74 2d 69  2 (db:get-test-i
7370: 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65  nfo db run-id te
7380: 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74  st-name item-pat
7390: 68 29 0a 09 09 09 09 20 20 20 28 2b 20 63 74 20  h).....   (+ ct 
73a0: 31 29 29 29 0a 09 09 09 20 20 28 69 66 20 74 73  1)))....  (if ts
73b0: 0a 09 09 09 20 20 20 20 20 20 28 73 65 74 21 20  ....      (set! 
73c0: 74 65 73 74 64 61 74 20 74 73 29 0a 09 09 09 20  testdat ts).... 
73d0: 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09 09 09       (begin.....
73e0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
73f0: 57 41 52 4e 49 4e 47 3a 20 43 6f 75 6c 64 6e 27  WARNING: Couldn'
7400: 74 20 72 65 67 69 73 74 65 72 20 74 65 73 74 20  t register test 
7410: 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 77 69  " test-name " wi
7420: 74 68 20 69 74 65 6d 20 70 61 74 68 20 22 20 69  th item path " i
7430: 74 65 6d 2d 70 61 74 68 20 22 2c 20 73 6b 69 70  tem-path ", skip
7440: 70 69 6e 67 22 29 0a 09 09 09 09 28 69 66 20 28  ping").....(if (
7450: 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 61 6c 29 29  not (null? tal))
7460: 0a 09 09 09 09 20 20 20 20 28 6c 6f 6f 70 20 28  .....    (loop (
7470: 63 61 72 20 74 61 6c 29 28 63 64 72 20 74 61 6c  car tal)(cdr tal
7480: 29 29 29 29 29 29 29 0a 09 09 20 20 20 20 28 63  )))))))...    (c
7490: 68 61 6e 67 65 2d 64 69 72 65 63 74 6f 72 79 20  hange-directory 
74a0: 74 65 73 74 2d 70 61 74 68 29 0a 09 09 20 20 20  test-path)...   
74b0: 20 3b 3b 20 74 68 69 73 20 62 6c 6f 63 6b 20 69   ;; this block i
74c0: 73 20 68 65 72 65 20 6f 6e 6c 79 20 74 6f 20 69  s here only to i
74d0: 6e 66 6f 72 6d 20 74 68 65 20 75 73 65 72 20 65  nform the user e
74e0: 61 72 6c 79 20 6f 6e 0a 09 09 20 20 20 20 28 69  arly on...    (i
74f0: 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20  f (file-exists? 
7500: 72 75 6e 63 6f 6e 66 69 67 66 29 0a 09 09 09 28  runconfigf)....(
7510: 73 65 74 75 70 2d 65 6e 76 2d 64 65 66 61 75 6c  setup-env-defaul
7520: 74 73 20 64 62 20 72 75 6e 63 6f 6e 66 69 67 66  ts db runconfigf
7530: 20 72 75 6e 2d 69 64 20 2a 61 6c 72 65 61 64 79   run-id *already
7540: 2d 73 65 65 6e 2d 72 75 6e 63 6f 6e 66 69 67 2d  -seen-runconfig-
7550: 69 6e 66 6f 2a 29 0a 09 09 09 28 64 65 62 75 67  info*)....(debug
7560: 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e  :print 0 "WARNIN
7570: 47 3a 20 59 6f 75 20 64 6f 20 6e 6f 74 20 68 61  G: You do not ha
7580: 76 65 20 61 20 72 75 6e 20 63 6f 6e 66 69 67 20  ve a run config 
7590: 66 69 6c 65 3a 20 22 20 72 75 6e 63 6f 6e 66 69  file: " runconfi
75a0: 67 66 29 29 0a 09 09 20 20 20 20 28 64 65 62 75  gf))...    (debu
75b0: 67 3a 70 72 69 6e 74 20 34 20 22 72 75 6e 2d 69  g:print 4 "run-i
75c0: 64 3a 20 22 20 72 75 6e 2d 69 64 20 22 20 74 65  d: " run-id " te
75d0: 73 74 2d 6e 61 6d 65 3a 20 22 20 74 65 73 74 2d  st-name: " test-
75e0: 6e 61 6d 65 20 22 20 69 74 65 6d 2d 70 61 74 68  name " item-path
75f0: 3a 20 22 20 69 74 65 6d 2d 70 61 74 68 20 22 20  : " item-path " 
7600: 74 65 73 74 64 61 74 3a 20 22 20 28 74 65 73 74  testdat: " (test
7610: 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74  :get-status test
7620: 64 61 74 29 20 22 20 74 65 73 74 2d 73 74 61 74  dat) " test-stat
7630: 65 3a 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73  e: " (test:get-s
7640: 74 61 74 65 20 74 65 73 74 64 61 74 29 29 0a 09  tate testdat))..
7650: 09 20 20 20 20 28 63 61 73 65 20 28 69 66 20 28  .    (case (if (
7660: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 66  args:get-arg "-f
7670: 6f 72 63 65 22 29 0a 09 09 09 20 20 20 20 20 20  orce")....      
7680: 27 4e 4f 54 5f 53 54 41 52 54 45 44 0a 09 09 09  'NOT_STARTED....
7690: 20 20 20 20 20 20 28 69 66 20 74 65 73 74 64 61        (if testda
76a0: 74 0a 09 09 09 09 20 20 28 73 74 72 69 6e 67 2d  t.....  (string-
76b0: 3e 73 79 6d 62 6f 6c 20 28 74 65 73 74 3a 67 65  >symbol (test:ge
76c0: 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 74 29  t-state testdat)
76d0: 29 0a 09 09 09 09 20 20 27 66 61 69 6c 65 64 2d  ).....  'failed-
76e0: 74 6f 2d 69 6e 73 65 72 74 29 29 0a 09 09 20 20  to-insert))...  
76f0: 20 20 20 20 28 28 66 61 69 6c 65 64 2d 74 6f 2d      ((failed-to-
7700: 69 6e 73 65 72 74 29 0a 09 09 20 20 20 20 20 20  insert)...      
7710: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
7720: 22 45 52 52 4f 52 3a 20 46 61 69 6c 65 64 20 74  "ERROR: Failed t
7730: 6f 20 69 6e 73 65 72 74 20 74 68 65 20 72 65 63  o insert the rec
7740: 6f 72 64 20 69 6e 74 6f 20 74 68 65 20 64 62 22  ord into the db"
7750: 29 29 0a 09 09 20 20 20 20 20 20 28 28 4e 4f 54  ))...      ((NOT
7760: 5f 53 54 41 52 54 45 44 20 43 4f 4d 50 4c 45 54  _STARTED COMPLET
7770: 45 44 29 0a 09 09 20 20 20 20 20 20 20 28 64 65  ED)...       (de
7780: 62 75 67 3a 70 72 69 6e 74 20 36 20 22 47 6f 74  bug:print 6 "Got
7790: 20 68 65 72 65 2c 20 22 20 28 74 65 73 74 3a 67   here, " (test:g
77a0: 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 74  et-state testdat
77b0: 29 29 0a 09 09 20 20 20 20 20 20 20 28 6c 65 74  ))...       (let
77c0: 20 28 28 72 75 6e 66 6c 61 67 20 23 66 29 29 0a   ((runflag #f)).
77d0: 09 09 09 20 28 63 6f 6e 64 0a 09 09 09 20 20 3b  ... (cond....  ;
77e0: 3b 20 69 2e 65 2e 20 74 68 69 73 20 69 73 20 74  ; i.e. this is t
77f0: 68 65 20 70 61 72 65 6e 74 20 74 65 73 74 20 74  he parent test t
7800: 6f 20 61 20 73 75 69 74 65 20 6f 66 20 69 74 65  o a suite of ite
7810: 6d 73 2c 20 6e 65 76 65 72 20 22 72 75 6e 22 20  ms, never "run" 
7820: 69 74 0a 09 09 09 20 20 28 70 61 72 65 6e 74 2d  it....  (parent-
7830: 74 65 73 74 0a 09 09 09 20 20 20 28 73 65 74 21  test....   (set!
7840: 20 72 75 6e 66 6c 61 67 20 23 66 29 29 0a 09 09   runflag #f))...
7850: 09 20 20 3b 3b 20 2d 66 6f 72 63 65 2c 20 72 75  .  ;; -force, ru
7860: 6e 20 6e 6f 20 6d 61 74 74 65 72 20 77 68 61 74  n no matter what
7870: 0a 09 09 09 20 20 28 28 61 72 67 73 3a 67 65 74  ....  ((args:get
7880: 2d 61 72 67 20 22 2d 66 6f 72 63 65 22 29 28 73  -arg "-force")(s
7890: 65 74 21 20 72 75 6e 66 6c 61 67 20 23 74 29 29  et! runflag #t))
78a0: 0a 09 09 09 20 20 3b 3b 20 4e 4f 54 5f 53 54 41  ....  ;; NOT_STA
78b0: 52 54 45 44 2c 20 72 75 6e 20 6e 6f 20 6d 61 74  RTED, run no mat
78c0: 74 65 72 20 77 68 61 74 0a 09 09 09 20 20 28 28  ter what....  ((
78d0: 65 71 75 61 6c 3f 20 28 74 65 73 74 3a 67 65 74  equal? (test:get
78e0: 2d 73 74 61 74 65 20 74 65 73 74 64 61 74 29 20  -state testdat) 
78f0: 22 4e 4f 54 5f 53 54 41 52 54 45 44 22 29 28 73  "NOT_STARTED")(s
7900: 65 74 21 20 72 75 6e 66 6c 61 67 20 23 74 29 29  et! runflag #t))
7910: 0a 09 09 09 20 20 3b 3b 20 6e 6f 74 20 2d 72 65  ....  ;; not -re
7920: 72 75 6e 20 61 6e 64 20 50 41 53 53 2c 20 57 41  run and PASS, WA
7930: 52 4e 20 6f 72 20 43 48 45 43 4b 2c 20 64 6f 20  RN or CHECK, do 
7940: 6e 6f 20 72 75 6e 0a 09 09 09 20 20 28 28 61 6e  no run....  ((an
7950: 64 20 28 6f 72 20 28 6e 6f 74 20 28 61 72 67 73  d (or (not (args
7960: 3a 67 65 74 2d 61 72 67 20 22 2d 72 65 72 75 6e  :get-arg "-rerun
7970: 22 29 29 0a 09 09 09 09 20 20 20 20 28 61 72 67  ")).....    (arg
7980: 73 3a 67 65 74 2d 61 72 67 20 22 2d 6b 65 65 70  s:get-arg "-keep
7990: 67 6f 69 6e 67 22 29 29 0a 09 09 09 09 28 6d 65  going")).....(me
79a0: 6d 62 65 72 20 28 74 65 73 74 3a 67 65 74 2d 73  mber (test:get-s
79b0: 74 61 74 75 73 20 74 65 73 74 64 61 74 29 20 27  tatus testdat) '
79c0: 28 22 50 41 53 53 22 20 22 57 41 52 4e 22 20 22  ("PASS" "WARN" "
79d0: 43 48 45 43 4b 22 29 29 29 0a 09 09 09 20 20 20  CHECK")))....   
79e0: 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 66  (set! runflag #f
79f0: 29 29 0a 09 09 09 20 20 3b 3b 20 2d 72 65 72 75  ))....  ;; -reru
7a00: 6e 20 61 6e 64 20 73 74 61 74 75 73 20 69 73 20  n and status is 
7a10: 6f 6e 65 20 6f 66 20 74 68 65 20 73 70 65 63 69  one of the speci
7a20: 66 65 64 2c 20 72 75 6e 20 69 74 0a 09 09 09 20  fed, run it.... 
7a30: 20 28 28 61 6e 64 20 28 61 72 67 73 3a 67 65 74   ((and (args:get
7a40: 2d 61 72 67 20 22 2d 72 65 72 75 6e 22 29 0a 09  -arg "-rerun")..
7a50: 09 09 09 28 6c 65 74 20 28 28 72 65 72 75 6e 6c  ...(let ((rerunl
7a60: 73 74 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74  st (string-split
7a70: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22   (args:get-arg "
7a80: 2d 72 65 72 75 6e 22 29 20 22 2c 22 29 29 29 20  -rerun") ","))) 
7a90: 3b 3b 20 46 41 49 4c 2c 0a 09 09 09 09 20 20 28  ;; FAIL,.....  (
7aa0: 6d 65 6d 62 65 72 20 28 74 65 73 74 3a 67 65 74  member (test:get
7ab0: 2d 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29  -status testdat)
7ac0: 20 72 65 72 75 6e 6c 73 74 29 29 29 0a 09 09 09   rerunlst)))....
7ad0: 20 20 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67     (set! runflag
7ae0: 20 23 74 29 29 0a 09 09 09 20 20 3b 3b 20 2d 6b   #t))....  ;; -k
7af0: 65 65 70 67 6f 69 6e 67 2c 20 64 6f 20 6e 6f 74  eepgoing, do not
7b00: 20 72 65 72 75 6e 20 46 41 49 4c 0a 09 09 09 20   rerun FAIL.... 
7b10: 20 28 28 61 6e 64 20 28 61 72 67 73 3a 67 65 74   ((and (args:get
7b20: 2d 61 72 67 20 22 2d 6b 65 65 70 67 6f 69 6e 67  -arg "-keepgoing
7b30: 22 29 0a 09 09 09 09 28 6d 65 6d 62 65 72 20 28  ").....(member (
7b40: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20  test:get-status 
7b50: 74 65 73 74 64 61 74 29 20 27 28 22 46 41 49 4c  testdat) '("FAIL
7b60: 22 29 29 29 0a 09 09 09 20 20 20 28 73 65 74 21  ")))....   (set!
7b70: 20 72 75 6e 66 6c 61 67 20 23 66 29 29 0a 09 09   runflag #f))...
7b80: 09 20 20 28 28 61 6e 64 20 28 6e 6f 74 20 28 61  .  ((and (not (a
7b90: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65  rgs:get-arg "-re
7ba0: 72 75 6e 22 29 29 0a 09 09 09 09 28 6d 65 6d 62  run")).....(memb
7bb0: 65 72 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61  er (test:get-sta
7bc0: 74 75 73 20 74 65 73 74 64 61 74 29 20 27 28 22  tus testdat) '("
7bd0: 46 41 49 4c 22 20 22 6e 2f 61 22 29 29 29 0a 09  FAIL" "n/a")))..
7be0: 09 09 20 20 20 28 73 65 74 21 20 72 75 6e 66 6c  ..   (set! runfl
7bf0: 61 67 20 23 74 29 29 0a 09 09 09 20 20 28 65 6c  ag #t))....  (el
7c00: 73 65 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67  se (set! runflag
7c10: 20 23 66 29 29 29 0a 09 09 09 20 28 64 65 62 75   #f))).... (debu
7c20: 67 3a 70 72 69 6e 74 20 36 20 22 52 55 4e 4e 49  g:print 6 "RUNNI
7c30: 4e 47 20 3d 3e 20 72 75 6e 66 6c 61 67 3a 20 22  NG => runflag: "
7c40: 20 72 75 6e 66 6c 61 67 20 22 20 53 54 41 54 45   runflag " STATE
7c50: 3a 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74  : " (test:get-st
7c60: 61 74 65 20 74 65 73 74 64 61 74 29 20 22 20 53  ate testdat) " S
7c70: 54 41 54 55 53 3a 20 22 20 28 74 65 73 74 3a 67  TATUS: " (test:g
7c80: 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61  et-status testda
7c90: 74 29 29 0a 09 09 09 20 28 69 66 20 28 6e 6f 74  t)).... (if (not
7ca0: 20 72 75 6e 66 6c 61 67 29 0a 09 09 09 20 20 20   runflag)....   
7cb0: 20 20 28 69 66 20 28 6e 6f 74 20 70 61 72 65 6e    (if (not paren
7cc0: 74 2d 74 65 73 74 29 0a 09 09 09 09 20 28 64 65  t-test)..... (de
7cd0: 62 75 67 3a 70 72 69 6e 74 20 31 20 22 4e 4f 54  bug:print 1 "NOT
7ce0: 45 3a 20 4e 6f 74 20 73 74 61 72 74 69 6e 67 20  E: Not starting 
7cf0: 74 65 73 74 20 22 20 6e 65 77 2d 74 65 73 74 2d  test " new-test-
7d00: 6e 61 6d 65 20 22 20 61 73 20 69 74 20 69 73 20  name " as it is 
7d10: 73 74 61 74 65 20 5c 22 43 4f 4d 50 4c 45 54 45  state \"COMPLETE
7d20: 44 5c 22 20 61 6e 64 20 73 74 61 74 75 73 20 5c  D\" and status \
7d30: 22 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61  "" (test:get-sta
7d40: 74 75 73 20 74 65 73 74 64 61 74 29 20 22 5c 22  tus testdat) "\"
7d50: 2c 20 75 73 65 20 2d 66 6f 72 63 65 20 74 6f 20  , use -force to 
7d60: 6f 76 65 72 72 69 64 65 22 29 29 0a 09 09 09 20  override")).... 
7d70: 20 20 20 20 28 6c 65 74 2a 20 28 28 67 65 74 2d      (let* ((get-
7d80: 70 72 65 72 65 71 73 2d 63 6d 64 20 28 6c 61 6d  prereqs-cmd (lam
7d90: 62 64 61 20 28 29 0a 09 09 09 09 09 09 20 20 20  bda ().......   
7da0: 20 20 20 20 28 64 62 2d 67 65 74 2d 70 72 65 72      (db-get-prer
7db0: 65 71 73 2d 6e 6f 74 2d 6d 65 74 20 64 62 20 72  eqs-not-met db r
7dc0: 75 6e 2d 69 64 20 77 61 69 74 6f 6e 29 29 29 20  un-id waiton))) 
7dd0: 3b 3b 20 63 68 65 63 6b 20 62 65 66 6f 72 65 20  ;; check before 
7de0: 72 75 6e 6e 69 6e 67 20 2e 2e 2e 2e 0a 09 09 09  running ........
7df0: 09 20 20 20 20 28 6c 61 75 6e 63 68 2d 63 6d 64  .    (launch-cmd
7e00: 20 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 29        (lambda ()
7e10: 0a 09 09 09 09 09 09 20 20 20 20 20 20 20 28 6c  .......       (l
7e20: 61 75 6e 63 68 2d 74 65 73 74 20 64 62 20 72 75  aunch-test db ru
7e30: 6e 2d 69 64 20 28 61 72 67 73 3a 67 65 74 2d 61  n-id (args:get-a
7e40: 72 67 20 22 3a 72 75 6e 6e 61 6d 65 22 29 20 74  rg ":runname") t
7e50: 65 73 74 2d 63 6f 6e 66 20 6b 65 79 76 61 6c 6c  est-conf keyvall
7e60: 73 74 20 74 65 73 74 2d 6e 61 6d 65 20 74 65 73  st test-name tes
7e70: 74 2d 70 61 74 68 20 69 74 65 6d 64 61 74 29 29  t-path itemdat))
7e80: 29 0a 09 09 09 09 20 20 20 20 28 74 65 73 74 72  ).....    (testr
7e90: 75 6e 64 61 74 20 20 20 20 20 20 28 6c 69 73 74  undat      (list
7ea0: 20 67 65 74 2d 70 72 65 72 65 71 73 2d 63 6d 64   get-prereqs-cmd
7eb0: 20 6c 61 75 6e 63 68 2d 63 6d 64 29 29 29 0a 09   launch-cmd)))..
7ec0: 09 09 20 20 20 20 20 20 20 28 69 66 20 28 6f 72  ..       (if (or
7ed0: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22   (args:get-arg "
7ee0: 2d 66 6f 72 63 65 22 29 0a 09 09 09 09 20 20 20  -force").....   
7ef0: 20 20 20 20 28 6c 65 74 20 28 28 70 72 65 71 73      (let ((preqs
7f00: 2d 6e 6f 74 2d 79 65 74 2d 6d 65 74 20 28 28 63  -not-yet-met ((c
7f10: 61 72 20 74 65 73 74 72 75 6e 64 61 74 29 29 29  ar testrundat)))
7f20: 29 0a 09 09 09 09 09 20 28 64 65 62 75 67 3a 70  )...... (debug:p
7f30: 72 69 6e 74 20 32 20 22 50 72 65 71 72 65 71 75  rint 2 "Preqrequ
7f40: 65 73 69 74 65 73 20 66 6f 72 20 22 20 74 65 73  esites for " tes
7f50: 74 2d 6e 61 6d 65 20 22 3a 20 22 20 70 72 65 71  t-name ": " preq
7f60: 73 2d 6e 6f 74 2d 79 65 74 2d 6d 65 74 29 0a 09  s-not-yet-met)..
7f70: 09 09 09 09 20 28 6e 75 6c 6c 3f 20 70 72 65 71  .... (null? preq
7f80: 73 2d 6e 6f 74 2d 79 65 74 2d 6d 65 74 29 29 29  s-not-yet-met)))
7f90: 20 3b 3b 20 61 72 65 20 74 68 65 72 65 20 61 6e   ;; are there an
7fa0: 79 20 74 65 73 74 73 20 74 68 61 74 20 6d 75 73  y tests that mus
7fb0: 74 20 62 65 20 72 75 6e 20 62 65 66 6f 72 65 20  t be run before 
7fc0: 74 68 69 73 20 6f 6e 65 2e 2e 2e 0a 09 09 09 09  this one........
7fd0: 20 20 20 28 69 66 20 28 6e 6f 74 20 28 28 63 61     (if (not ((ca
7fe0: 64 72 20 74 65 73 74 72 75 6e 64 61 74 29 29 29  dr testrundat)))
7ff0: 20 3b 3b 20 74 68 69 73 20 69 73 20 74 68 65 20   ;; this is the 
8000: 6c 69 6e 65 20 74 68 61 74 20 6c 61 75 6e 63 68  line that launch
8010: 65 73 20 74 68 65 20 74 65 73 74 20 74 6f 20 74  es the test to t
8020: 68 65 20 72 65 6d 6f 74 65 20 68 6f 73 74 0a 09  he remote host..
8030: 09 09 09 20 20 20 20 20 20 20 28 62 65 67 69 6e  ...       (begin
8040: 0a 09 09 09 09 09 20 28 70 72 69 6e 74 20 22 45  ...... (print "E
8050: 52 52 4f 52 3a 20 46 61 69 6c 65 64 20 74 6f 20  RROR: Failed to 
8060: 6c 61 75 6e 63 68 20 74 68 65 20 74 65 73 74 2e  launch the test.
8070: 20 45 78 69 74 69 6e 67 20 61 73 20 73 6f 6f 6e   Exiting as soon
8080: 20 61 73 20 70 6f 73 73 69 62 6c 65 22 29 0a 09   as possible")..
8090: 09 09 09 09 20 28 73 65 74 21 20 2a 67 6c 6f 62  .... (set! *glob
80a0: 61 6c 65 78 69 74 73 74 61 74 75 73 2a 20 31 29  alexitstatus* 1)
80b0: 20 3b 3b 20 0a 09 09 09 09 09 20 28 70 72 6f 63   ;; ...... (proc
80c0: 65 73 73 2d 73 69 67 6e 61 6c 20 28 63 75 72 72  ess-signal (curr
80d0: 65 6e 74 2d 70 72 6f 63 65 73 73 2d 69 64 29 20  ent-process-id) 
80e0: 73 69 67 6e 61 6c 2f 6b 69 6c 6c 29 0a 09 09 09  signal/kill)....
80f0: 09 09 20 3b 28 65 78 69 74 20 31 29 0a 09 09 09  .. ;(exit 1)....
8100: 09 09 20 29 29 0a 09 09 09 09 20 20 20 28 69 66  .. )).....   (if
8110: 20 28 6e 6f 74 20 28 61 72 67 73 3a 67 65 74 2d   (not (args:get-
8120: 61 72 67 20 22 2d 6b 65 65 70 67 6f 69 6e 67 22  arg "-keepgoing"
8130: 29 29 0a 09 09 09 09 20 20 20 20 20 20 20 28 68  )).....       (h
8140: 61 73 68 2d 74 61 62 6c 65 2d 73 65 74 21 20 2a  ash-table-set! *
8150: 77 61 69 74 69 6e 67 2d 71 75 65 75 65 2a 20 6e  waiting-queue* n
8160: 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20 74 65 73  ew-test-name tes
8170: 74 72 75 6e 64 61 74 29 29 29 29 29 29 29 0a 09  trundat)))))))..
8180: 09 20 20 20 20 20 20 28 28 4b 49 4c 4c 45 44 29  .      ((KILLED)
8190: 20 0a 09 09 20 20 20 20 20 20 20 28 64 65 62 75   ...       (debu
81a0: 67 3a 70 72 69 6e 74 20 31 20 22 4e 4f 54 45 3a  g:print 1 "NOTE:
81b0: 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65   " new-test-name
81c0: 20 22 20 69 73 20 61 6c 72 65 61 64 79 20 72 75   " is already ru
81d0: 6e 6e 69 6e 67 20 6f 72 20 77 61 73 20 65 78 70  nning or was exp
81e0: 6c 69 63 74 6c 79 20 6b 69 6c 6c 65 64 2c 20 75  lictly killed, u
81f0: 73 65 20 2d 66 6f 72 63 65 20 74 6f 20 6c 61 75  se -force to lau
8200: 6e 63 68 20 69 74 2e 22 29 29 0a 09 09 20 20 20  nch it."))...   
8210: 20 20 20 28 28 4c 41 55 4e 43 48 45 44 20 52 45     ((LAUNCHED RE
8220: 4d 4f 54 45 48 4f 53 54 53 54 41 52 54 20 52 55  MOTEHOSTSTART RU
8230: 4e 4e 49 4e 47 29 20 20 0a 09 09 20 20 20 20 20  NNING)  ...     
8240: 20 20 28 69 66 20 28 3e 20 28 2d 20 28 63 75 72    (if (> (- (cur
8250: 72 65 6e 74 2d 73 65 63 6f 6e 64 73 29 28 2b 20  rent-seconds)(+ 
8260: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 65 76 65  (db:test-get-eve
8270: 6e 74 5f 74 69 6d 65 20 74 65 73 74 64 61 74 29  nt_time testdat)
8280: 0a 09 09 09 09 09 09 20 20 20 20 20 28 64 62 3a  .......     (db:
8290: 74 65 73 74 2d 67 65 74 2d 72 75 6e 5f 64 75 72  test-get-run_dur
82a0: 61 74 69 6f 6e 20 74 65 73 74 64 61 74 29 29 29  ation testdat)))
82b0: 0a 09 09 09 20 20 20 20 20 20 31 30 30 29 20 3b  ....      100) ;
82c0: 3b 20 69 2e 65 2e 20 6e 6f 20 75 70 64 61 74 65  ; i.e. no update
82d0: 20 66 6f 72 20 6d 6f 72 65 20 74 68 61 6e 20 31   for more than 1
82e0: 30 30 20 73 65 63 6f 6e 64 73 0a 09 09 09 20 20  00 seconds....  
82f0: 20 28 62 65 67 69 6e 0a 09 09 09 20 20 20 20 20   (begin....     
8300: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
8310: 57 41 52 4e 49 4e 47 3a 20 54 65 73 74 20 22 20  WARNING: Test " 
8320: 74 65 73 74 2d 6e 61 6d 65 20 22 20 61 70 70 65  test-name " appe
8330: 61 72 73 20 74 6f 20 62 65 20 64 65 61 64 2e 20  ars to be dead. 
8340: 46 6f 72 63 69 6e 67 20 69 74 20 74 6f 20 73 74  Forcing it to st
8350: 61 74 65 20 49 4e 43 4f 4d 50 4c 45 54 45 20 61  ate INCOMPLETE a
8360: 6e 64 20 73 74 61 74 75 73 20 53 54 55 43 4b 2f  nd status STUCK/
8370: 44 45 41 44 22 29 0a 09 09 09 20 20 20 20 20 28  DEAD")....     (
8380: 74 65 73 74 2d 73 65 74 2d 73 74 61 74 75 73 21  test-set-status!
8390: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d   db run-id test-
83a0: 6e 61 6d 65 20 22 49 4e 43 4f 4d 50 4c 45 54 45  name "INCOMPLETE
83b0: 22 20 22 53 54 55 43 4b 2f 44 45 41 44 22 20 69  " "STUCK/DEAD" i
83c0: 74 65 6d 64 61 74 20 22 54 65 73 74 20 69 73 20  temdat "Test is 
83d0: 73 74 75 63 6b 20 6f 72 20 64 65 61 64 22 20 23  stuck or dead" #
83e0: 66 29 29 0a 09 09 09 20 20 20 28 64 65 62 75 67  f))....   (debug
83f0: 3a 70 72 69 6e 74 20 32 20 22 4e 4f 54 45 3a 20  :print 2 "NOTE: 
8400: 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 69 73  " test-name " is
8410: 20 61 6c 72 65 61 64 79 20 72 75 6e 6e 69 6e 67   already running
8420: 22 29 29 29 0a 09 09 20 20 20 20 20 20 28 65 6c  ")))...      (el
8430: 73 65 20 20 20 20 20 20 20 28 64 65 62 75 67 3a  se       (debug:
8440: 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20  print 0 "ERROR: 
8450: 46 61 69 6c 65 64 20 74 6f 20 6c 61 75 6e 63 68  Failed to launch
8460: 20 74 65 73 74 20 22 20 6e 65 77 2d 74 65 73 74   test " new-test
8470: 2d 6e 61 6d 65 20 22 2e 20 55 6e 72 65 63 6f 67  -name ". Unrecog
8480: 6e 69 73 65 64 20 73 74 61 74 65 20 22 20 28 74  nised state " (t
8490: 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65  est:get-state te
84a0: 73 74 64 61 74 29 29 29 29 29 29 0a 09 20 20 20  stdat))))))..   
84b0: 20 20 20 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c     (if (not (nul
84c0: 6c 3f 20 74 61 6c 29 29 0a 09 09 20 20 28 6c 6f  l? tal))...  (lo
84d0: 6f 70 20 28 63 61 72 20 74 61 6c 29 28 63 64 72  op (car tal)(cdr
84e0: 20 74 61 6c 29 29 29 29 29 29 29 29 29 0a 0a 28   tal)))))))))..(
84f0: 64 65 66 69 6e 65 20 28 72 75 6e 2d 77 61 69 74  define (run-wait
8500: 69 6e 67 2d 74 65 73 74 73 20 64 62 29 0a 20 20  ing-tests db).  
8510: 28 6c 65 74 20 28 28 6e 75 6d 74 72 69 65 73 20  (let ((numtries 
8520: 20 20 20 20 20 20 20 20 20 20 30 29 0a 09 28 6c            0)..(l
8530: 61 73 74 2d 74 72 79 2d 74 69 6d 65 20 20 20 20  ast-try-time    
8540: 20 20 28 63 75 72 72 65 6e 74 2d 73 65 63 6f 6e    (current-secon
8550: 64 73 29 29 0a 09 28 74 69 6d 65 73 20 20 20 20  ds))..(times    
8560: 20 20 20 20 20 20 20 20 20 20 28 6c 69 73 74 20            (list 
8570: 31 29 29 29 20 3b 3b 20 6d 69 6e 75 74 65 73 20  1))) ;; minutes 
8580: 74 6f 20 77 61 69 74 20 62 65 66 6f 72 65 20 74  to wait before t
8590: 72 79 69 6e 67 20 61 67 61 69 6e 20 74 6f 20 6b  rying again to k
85a0: 69 63 6b 20 6f 66 66 20 72 75 6e 73 0a 20 20 20  ick off runs.   
85b0: 20 3b 3b 20 42 55 47 20 74 68 69 73 20 68 61 63   ;; BUG this hac
85c0: 6b 20 6f 66 20 62 72 75 74 65 20 66 6f 72 63 65  k of brute force
85d0: 20 72 65 74 72 79 69 6e 67 20 77 6f 72 6b 73 20   retrying works 
85e0: 71 75 69 74 65 20 77 65 6c 6c 20 66 6f 72 20 6d  quite well for m
85f0: 61 6e 79 20 63 61 73 65 73 20 62 75 74 20 0a 20  any cases but . 
8600: 20 20 20 3b 3b 20 20 20 20 20 77 68 61 74 20 69     ;;     what i
8610: 73 20 6e 65 65 64 65 64 20 69 73 20 74 6f 20 63  s needed is to c
8620: 68 65 63 6b 20 74 68 65 20 64 62 20 66 6f 72 20  heck the db for 
8630: 74 65 73 74 73 20 74 68 61 74 20 68 61 76 65 20  tests that have 
8640: 66 61 69 6c 65 64 20 6c 65 73 73 20 74 68 61 6e  failed less than
8650: 0a 20 20 20 20 3b 3b 20 20 20 20 20 4e 20 74 69  .    ;;     N ti
8660: 6d 65 73 20 6f 72 20 6e 65 76 65 72 20 62 65 65  mes or never bee
8670: 6e 20 73 74 61 72 74 65 64 20 61 6e 64 20 6b 69  n started and ki
8680: 63 6b 20 74 68 65 6d 20 6f 66 66 20 61 67 61 69  ck them off agai
8690: 6e 0a 20 20 20 20 28 6c 65 74 20 6c 6f 6f 70 20  n.    (let loop 
86a0: 28 28 77 61 69 74 69 6e 67 2d 74 65 73 74 2d 6e  ((waiting-test-n
86b0: 61 6d 65 73 20 28 68 61 73 68 2d 74 61 62 6c 65  ames (hash-table
86c0: 2d 6b 65 79 73 20 2a 77 61 69 74 69 6e 67 2d 71  -keys *waiting-q
86d0: 75 65 75 65 2a 29 29 29 0a 20 20 20 20 20 20 28  ueue*))).      (
86e0: 63 6f 6e 64 0a 20 20 20 20 20 20 20 28 28 6e 6f  cond.       ((no
86f0: 74 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d  t (runs:can-run-
8700: 6d 6f 72 65 2d 74 65 73 74 73 20 64 62 29 29 0a  more-tests db)).
8710: 09 28 73 6c 65 65 70 20 32 29 0a 09 28 6c 6f 6f  .(sleep 2)..(loo
8720: 70 20 77 61 69 74 69 6e 67 2d 74 65 73 74 2d 6e  p waiting-test-n
8730: 61 6d 65 73 29 29 0a 20 20 20 20 20 20 20 28 28  ames)).       ((
8740: 6e 75 6c 6c 3f 20 77 61 69 74 69 6e 67 2d 74 65  null? waiting-te
8750: 73 74 2d 6e 61 6d 65 73 29 0a 09 28 64 65 62 75  st-names)..(debu
8760: 67 3a 70 72 69 6e 74 20 31 20 22 41 6c 6c 20 74  g:print 1 "All t
8770: 65 73 74 73 20 6c 61 75 6e 63 68 65 64 22 29 29  ests launched"))
8780: 0a 20 20 20 20 20 20 20 28 65 6c 73 65 0a 09 28  .       (else..(
8790: 73 65 74 21 20 6e 75 6d 74 72 69 65 73 20 28 2b  set! numtries (+
87a0: 20 6e 75 6d 74 72 69 65 73 20 31 29 29 0a 09 28   numtries 1))..(
87b0: 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61  for-each (lambda
87c0: 20 28 74 65 73 74 6e 61 6d 65 29 0a 09 09 20 20   (testname)...  
87d0: 20 20 28 69 66 20 28 72 75 6e 73 3a 63 61 6e 2d    (if (runs:can-
87e0: 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64  run-more-tests d
87f0: 62 29 0a 09 09 09 28 6c 65 74 2a 20 28 28 74 65  b)....(let* ((te
8800: 73 74 64 61 74 20 28 68 61 73 68 2d 74 61 62 6c  stdat (hash-tabl
8810: 65 2d 72 65 66 20 2a 77 61 69 74 69 6e 67 2d 71  e-ref *waiting-q
8820: 75 65 75 65 2a 20 74 65 73 74 6e 61 6d 65 29 29  ueue* testname))
8830: 0a 09 09 09 20 20 20 20 20 20 20 28 70 72 65 72  ....       (prer
8840: 65 71 73 20 28 28 63 61 72 20 74 65 73 74 64 61  eqs ((car testda
8850: 74 29 29 29 0a 09 09 09 20 20 20 20 20 20 20 28  t)))....       (
8860: 6c 64 62 20 20 20 20 20 28 69 66 20 64 62 20 64  ldb     (if db d
8870: 62 20 28 6f 70 65 6e 2d 64 62 29 29 29 29 0a 09  b (open-db))))..
8880: 09 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ..  (debug:print
8890: 20 32 20 22 70 72 65 72 65 71 73 20 72 65 6d 61   2 "prereqs rema
88a0: 69 6e 69 6e 67 3a 20 22 20 70 72 65 72 65 71 73  ining: " prereqs
88b0: 29 0a 09 09 09 20 20 28 69 66 20 28 6e 75 6c 6c  )....  (if (null
88c0: 3f 20 70 72 65 72 65 71 73 29 0a 09 09 09 20 20  ? prereqs)....  
88d0: 20 20 20 20 28 62 65 67 69 6e 0a 09 09 09 09 28      (begin.....(
88e0: 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 50  debug:print 2 "P
88f0: 72 65 72 65 71 75 69 73 69 74 65 73 20 6d 65 74  rerequisites met
8900: 2c 20 6c 61 75 6e 63 68 69 6e 67 20 22 20 74 65  , launching " te
8910: 73 74 6e 61 6d 65 29 0a 09 09 09 09 28 28 63 61  stname).....((ca
8920: 64 72 20 74 65 73 74 64 61 74 29 29 0a 09 09 09  dr testdat))....
8930: 09 28 68 61 73 68 2d 74 61 62 6c 65 2d 64 65 6c  .(hash-table-del
8940: 65 74 65 21 20 2a 77 61 69 74 69 6e 67 2d 71 75  ete! *waiting-qu
8950: 65 75 65 2a 20 74 65 73 74 6e 61 6d 65 29 29 29  eue* testname)))
8960: 0a 09 09 09 20 20 28 69 66 20 28 6e 6f 74 20 64  ....  (if (not d
8970: 62 29 0a 09 09 09 20 20 20 20 20 20 28 73 71 6c  b)....      (sql
8980: 69 74 65 33 3a 66 69 6e 61 6c 69 7a 65 21 20 6c  ite3:finalize! l
8990: 64 62 29 29 29 29 29 0a 09 09 20 20 77 61 69 74  db)))))...  wait
89a0: 69 6e 67 2d 74 65 73 74 2d 6e 61 6d 65 73 29 0a  ing-test-names).
89b0: 09 3b 3b 20 28 73 6c 65 65 70 20 31 30 29 20 3b  .;; (sleep 10) ;
89c0: 3b 20 6e 6f 20 70 6f 69 6e 74 20 69 6e 20 72 75  ; no point in ru
89d0: 73 68 69 6e 67 20 74 68 69 6e 67 73 20 61 74 20  shing things at 
89e0: 74 68 69 73 20 73 74 61 67 65 3f 0a 09 28 6c 6f  this stage?..(lo
89f0: 6f 70 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 6b  op (hash-table-k
8a00: 65 79 73 20 2a 77 61 69 74 69 6e 67 2d 71 75 65  eys *waiting-que
8a10: 75 65 2a 29 29 29 29 29 29 29 0a 0a 3b 3b 3d 3d  ue*)))))))..;;==
8a20: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
8a30: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
8a40: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
8a50: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
8a60: 3d 3d 3d 3d 0a 3b 3b 20 4e 65 77 20 6d 65 74 68  ====.;; New meth
8a70: 6f 64 6f 6c 6f 67 79 2e 20 54 68 65 73 65 20 72  odology. These r
8a80: 6f 75 74 69 6e 65 73 20 77 69 6c 6c 20 72 65 70  outines will rep
8a90: 6c 61 63 65 20 74 68 65 20 61 62 6f 76 65 20 69  lace the above i
8aa0: 6e 20 74 69 6d 65 2e 20 46 6f 72 0a 3b 3b 20 6e  n time. For.;; n
8ab0: 6f 77 20 74 68 65 20 63 6f 64 65 20 69 73 20 64  ow the code is d
8ac0: 75 70 6c 69 63 61 74 65 64 2e 20 54 68 69 73 20  uplicated. This 
8ad0: 73 74 75 66 66 20 69 73 20 69 6e 69 74 69 61 6c  stuff is initial
8ae0: 6c 79 20 75 73 65 64 20 69 6e 20 74 68 65 20 6d  ly used in the m
8af0: 6f 6e 69 74 6f 72 0a 3b 3b 20 62 61 73 65 64 20  onitor.;; based 
8b00: 63 6f 64 65 2e 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d  code..;;========
8b10: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
8b20: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
8b30: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
8b40: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a  ==============..
8b50: 3b 3b 20 72 65 67 69 73 74 65 72 20 61 20 74 65  ;; register a te
8b60: 73 74 20 72 75 6e 20 77 69 74 68 20 74 68 65 20  st run with the 
8b70: 64 62 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73  db.(define (runs
8b80: 3a 72 65 67 69 73 74 65 72 2d 72 75 6e 20 64 62  :register-run db
8b90: 20 6b 65 79 73 20 6b 65 79 76 61 6c 6c 73 74 20   keys keyvallst 
8ba0: 72 75 6e 6e 61 6d 65 20 73 74 61 74 65 20 73 74  runname state st
8bb0: 61 74 75 73 20 75 73 65 72 29 0a 20 20 28 6c 65  atus user).  (le
8bc0: 74 2a 20 28 28 6b 65 79 73 74 72 20 20 20 20 28  t* ((keystr    (
8bd0: 6b 65 79 73 2d 3e 6b 65 79 73 74 72 20 6b 65 79  keys->keystr key
8be0: 73 29 29 0a 09 20 28 63 6f 6d 6d 61 20 20 20 20  s)).. (comma    
8bf0: 20 28 69 66 20 28 3e 20 28 6c 65 6e 67 74 68 20   (if (> (length 
8c00: 6b 65 79 73 29 20 30 29 20 22 2c 22 20 22 22 29  keys) 0) "," "")
8c10: 29 0a 09 20 28 61 6e 64 73 74 72 20 20 20 20 28  ).. (andstr    (
8c20: 69 66 20 28 3e 20 28 6c 65 6e 67 74 68 20 6b 65  if (> (length ke
8c30: 79 73 29 20 30 29 20 22 20 41 4e 44 20 22 20 22  ys) 0) " AND " "
8c40: 22 29 29 0a 09 20 28 76 61 6c 73 6c 6f 74 73 20  ")).. (valslots 
8c50: 20 28 6b 65 79 73 2d 3e 76 61 6c 73 6c 6f 74 73   (keys->valslots
8c60: 20 6b 65 79 73 29 29 20 3b 3b 20 3f 2c 3f 2c 3f   keys)) ;; ?,?,?
8c70: 20 2e 2e 2e 0a 09 20 28 6b 65 79 76 61 6c 73 20   ..... (keyvals 
8c80: 20 20 28 6d 61 70 20 63 61 64 72 20 6b 65 79 76    (map cadr keyv
8c90: 61 6c 6c 73 74 29 29 0a 09 20 28 61 6c 6c 76 61  allst)).. (allva
8ca0: 6c 73 20 20 20 28 61 70 70 65 6e 64 20 28 6c 69  ls   (append (li
8cb0: 73 74 20 72 75 6e 6e 61 6d 65 20 73 74 61 74 65  st runname state
8cc0: 20 73 74 61 74 75 73 20 75 73 65 72 29 20 6b 65   status user) ke
8cd0: 79 76 61 6c 73 29 29 0a 09 20 28 71 72 79 76 61  yvals)).. (qryva
8ce0: 6c 73 20 20 20 28 61 70 70 65 6e 64 20 28 6c 69  ls   (append (li
8cf0: 73 74 20 72 75 6e 6e 61 6d 65 29 20 6b 65 79 76  st runname) keyv
8d00: 61 6c 73 29 29 0a 09 20 28 6b 65 79 3d 3f 73 74  als)).. (key=?st
8d10: 72 20 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72  r  (string-inter
8d20: 73 70 65 72 73 65 20 28 6d 61 70 20 28 6c 61 6d  sperse (map (lam
8d30: 62 64 61 20 28 6b 29 28 63 6f 6e 63 20 28 6b 65  bda (k)(conc (ke
8d40: 79 3a 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20  y:get-fieldname 
8d50: 6b 29 20 22 3d 3f 22 29 29 20 6b 65 79 73 29 20  k) "=?")) keys) 
8d60: 22 20 41 4e 44 20 22 29 29 29 0a 20 20 20 20 28  " AND "))).    (
8d70: 64 65 62 75 67 3a 70 72 69 6e 74 20 33 20 22 6b  debug:print 3 "k
8d80: 65 79 73 3a 20 22 20 6b 65 79 73 20 22 20 61 6c  eys: " keys " al
8d90: 6c 76 61 6c 73 3a 20 22 20 61 6c 6c 76 61 6c 73  lvals: " allvals
8da0: 20 22 20 6b 65 79 76 61 6c 73 3a 20 22 20 6b 65   " keyvals: " ke
8db0: 79 76 61 6c 73 29 0a 20 20 20 20 28 64 65 62 75  yvals).    (debu
8dc0: 67 3a 70 72 69 6e 74 20 32 20 22 4e 4f 54 45 3a  g:print 2 "NOTE:
8dd0: 20 75 73 69 6e 67 20 74 61 72 67 65 74 20 22 20   using target " 
8de0: 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65  (string-interspe
8df0: 72 73 65 20 6b 65 79 76 61 6c 73 20 22 2f 22 29  rse keyvals "/")
8e00: 20 22 20 66 6f 72 20 74 68 69 73 20 72 75 6e 22   " for this run"
8e10: 29 0a 20 20 20 20 28 69 66 20 28 61 6e 64 20 72  ).    (if (and r
8e20: 75 6e 6e 61 6d 65 20 28 6e 75 6c 6c 3f 20 28 66  unname (null? (f
8e30: 69 6c 74 65 72 20 28 6c 61 6d 62 64 61 20 28 78  ilter (lambda (x
8e40: 29 28 6e 6f 74 20 78 29 29 20 6b 65 79 76 61 6c  )(not x)) keyval
8e50: 73 29 29 29 20 3b 3b 20 74 68 65 72 65 20 6d 75  s))) ;; there mu
8e60: 73 74 20 62 65 20 61 20 62 65 74 74 65 72 20 77  st be a better w
8e70: 61 79 20 74 6f 20 22 61 70 70 6c 79 20 61 6e 64  ay to "apply and
8e80: 22 0a 09 28 6c 65 74 20 28 28 72 65 73 20 23 66  "..(let ((res #f
8e90: 29 29 0a 09 20 20 28 61 70 70 6c 79 20 73 71 6c  ))..  (apply sql
8ea0: 69 74 65 33 3a 65 78 65 63 75 74 65 20 64 62 20  ite3:execute db 
8eb0: 28 63 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f 52  (conc "INSERT OR
8ec0: 20 49 47 4e 4f 52 45 20 49 4e 54 4f 20 72 75 6e   IGNORE INTO run
8ed0: 73 20 28 72 75 6e 6e 61 6d 65 2c 73 74 61 74 65  s (runname,state
8ee0: 2c 73 74 61 74 75 73 2c 6f 77 6e 65 72 2c 65 76  ,status,owner,ev
8ef0: 65 6e 74 5f 74 69 6d 65 22 20 63 6f 6d 6d 61 20  ent_time" comma 
8f00: 6b 65 79 73 74 72 20 22 29 20 56 41 4c 55 45 53  keystr ") VALUES
8f10: 20 28 3f 2c 3f 2c 3f 2c 3f 2c 73 74 72 66 74 69   (?,?,?,?,strfti
8f20: 6d 65 28 27 25 73 27 2c 27 6e 6f 77 27 29 22 20  me('%s','now')" 
8f30: 63 6f 6d 6d 61 20 76 61 6c 73 6c 6f 74 73 20 22  comma valslots "
8f40: 29 3b 22 29 0a 09 09 20 61 6c 6c 76 61 6c 73 29  );")... allvals)
8f50: 0a 09 20 20 28 61 70 70 6c 79 20 73 71 6c 69 74  ..  (apply sqlit
8f60: 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77 20  e3:for-each-row 
8f70: 0a 09 20 20 20 28 6c 61 6d 62 64 61 20 28 69 64  ..   (lambda (id
8f80: 29 0a 09 20 20 20 20 20 28 73 65 74 21 20 72 65  )..     (set! re
8f90: 73 20 69 64 29 29 0a 09 20 20 20 64 62 0a 09 20  s id))..   db.. 
8fa0: 20 20 28 6c 65 74 20 28 28 71 72 79 20 28 63 6f    (let ((qry (co
8fb0: 6e 63 20 22 53 45 4c 45 43 54 20 69 64 20 46 52  nc "SELECT id FR
8fc0: 4f 4d 20 72 75 6e 73 20 57 48 45 52 45 20 28 72  OM runs WHERE (r
8fd0: 75 6e 6e 61 6d 65 3d 3f 20 22 20 61 6e 64 73 74  unname=? " andst
8fe0: 72 20 6b 65 79 3d 3f 73 74 72 20 22 29 3b 22 29  r key=?str ");")
8ff0: 29 29 0a 09 20 20 20 20 20 3b 28 64 65 62 75 67  ))..     ;(debug
9000: 3a 70 72 69 6e 74 20 34 20 22 71 72 79 3a 20 22  :print 4 "qry: "
9010: 20 71 72 79 29 20 0a 09 20 20 20 20 20 71 72 79   qry) ..     qry
9020: 29 0a 09 20 20 20 71 72 79 76 61 6c 73 29 0a 09  )..   qryvals)..
9030: 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75    (sqlite3:execu
9040: 74 65 20 64 62 20 22 55 50 44 41 54 45 20 72 75  te db "UPDATE ru
9050: 6e 73 20 53 45 54 20 73 74 61 74 65 3d 3f 2c 73  ns SET state=?,s
9060: 74 61 74 75 73 3d 3f 20 57 48 45 52 45 20 69 64  tatus=? WHERE id
9070: 3d 3f 3b 22 20 73 74 61 74 65 20 73 74 61 74 75  =?;" state statu
9080: 73 20 72 65 73 29 0a 09 20 20 72 65 73 29 20 0a  s res)..  res) .
9090: 09 28 62 65 67 69 6e 0a 09 20 20 28 64 65 62 75  .(begin..  (debu
90a0: 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52  g:print 0 "ERROR
90b0: 3a 20 43 61 6c 6c 65 64 20 77 69 74 68 6f 75 74  : Called without
90c0: 20 61 6c 6c 20 6e 65 63 65 73 73 61 72 79 20 6b   all necessary k
90d0: 65 79 73 22 29 0a 09 20 20 23 66 29 29 29 29 0a  eys")..  #f)))).
90e0: 0a 3b 3b 20 54 68 69 73 20 69 73 20 61 20 64 75  .;; This is a du
90f0: 70 6c 69 63 61 74 65 20 6f 66 20 72 75 6e 2d 74  plicate of run-t
9100: 65 73 74 73 20 28 77 68 69 63 68 20 68 61 73 20  ests (which has 
9110: 62 65 65 6e 20 64 65 70 72 65 63 61 74 65 64 29  been deprecated)
9120: 2e 20 55 73 65 20 74 68 69 73 20 6f 6e 65 20 69  . Use this one i
9130: 6e 73 74 65 61 64 20 6f 66 20 72 75 6e 20 74 65  nstead of run te
9140: 73 74 73 2e 0a 3b 3b 20 6b 65 79 76 61 6c 73 0a  sts..;; keyvals.
9150: 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 72 75  (define (runs:ru
9160: 6e 2d 74 65 73 74 73 20 64 62 20 74 61 72 67 65  n-tests db targe
9170: 74 20 72 75 6e 6e 61 6d 65 20 74 65 73 74 2d 70  t runname test-p
9180: 61 74 74 73 20 69 74 65 6d 2d 70 61 74 74 73 20  atts item-patts 
9190: 75 73 65 72 20 66 6c 61 67 73 29 0a 20 20 28 6c  user flags).  (l
91a0: 65 74 2a 20 28 28 6b 65 79 73 20 20 20 20 20 20  et* ((keys      
91b0: 20 20 28 64 62 2d 67 65 74 2d 6b 65 79 73 20 64    (db-get-keys d
91c0: 62 29 29 0a 09 20 28 6b 65 79 76 61 6c 6c 73 74  b)).. (keyvallst
91d0: 20 20 20 28 6b 65 79 73 3a 74 61 72 67 65 74 2d     (keys:target-
91e0: 3e 6b 65 79 76 61 6c 20 6b 65 79 73 20 74 61 72  >keyval keys tar
91f0: 67 65 74 29 29 0a 09 20 28 72 75 6e 2d 69 64 20  get)).. (run-id 
9200: 20 20 20 20 20 28 72 75 6e 73 3a 72 65 67 69 73       (runs:regis
9210: 74 65 72 2d 72 75 6e 20 64 62 20 6b 65 79 73 20  ter-run db keys 
9220: 6b 65 79 76 61 6c 6c 73 74 20 72 75 6e 6e 61 6d  keyvallst runnam
9230: 65 20 22 6e 65 77 22 20 22 6e 2f 61 22 20 75 73  e "new" "n/a" us
9240: 65 72 29 29 20 20 3b 3b 20 20 74 65 73 74 2d 6e  er))  ;;  test-n
9250: 61 6d 65 29 29 29 0a 09 20 28 64 65 66 65 72 72  ame))).. (deferr
9260: 65 64 20 20 20 20 27 28 29 29 20 3b 3b 20 64 65  ed    '()) ;; de
9270: 6c 61 79 20 72 75 6e 6e 69 6e 67 20 74 68 65 73  lay running thes
9280: 65 20 73 69 6e 63 65 20 74 68 65 79 20 68 61 76  e since they hav
9290: 65 20 61 20 77 61 69 74 6f 6e 20 63 6c 61 75 73  e a waiton claus
92a0: 65 0a 09 20 28 6b 65 65 70 67 6f 69 6e 67 20 20  e.. (keepgoing  
92b0: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
92c0: 2f 64 65 66 61 75 6c 74 20 66 6c 61 67 73 20 22  /default flags "
92d0: 2d 6b 65 65 70 67 6f 69 6e 67 22 20 23 66 29 29  -keepgoing" #f))
92e0: 0a 09 20 28 74 65 73 74 2d 6e 61 6d 65 73 20 20  .. (test-names  
92f0: 27 28 29 29 29 0a 20 20 20 20 3b 3b 20 6c 6f 6f  '())).    ;; loo
9300: 6b 20 75 70 20 61 6c 6c 20 74 65 73 74 73 20 6d  k up all tests m
9310: 61 74 63 68 69 6e 67 20 74 68 65 20 63 6f 6d 6d  atching the comm
9320: 61 20 73 65 70 61 72 61 74 65 64 20 6c 69 73 74  a separated list
9330: 20 6f 66 20 67 6c 6f 62 73 20 69 6e 0a 20 20 20   of globs in.   
9340: 20 3b 3b 20 74 65 73 74 2d 70 61 74 74 73 20 28   ;; test-patts (
9350: 75 73 69 6e 67 20 25 20 61 73 20 77 69 6c 64 63  using % as wildc
9360: 61 72 64 29 0a 20 20 20 20 28 66 6f 72 2d 65 61  ard).    (for-ea
9370: 63 68 20 0a 20 20 20 20 20 28 6c 61 6d 62 64 61  ch .     (lambda
9380: 20 28 70 61 74 74 29 0a 20 20 20 20 20 20 20 28   (patt).       (
9390: 6c 65 74 20 28 28 74 65 73 74 73 20 28 67 6c 6f  let ((tests (glo
93a0: 62 20 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74 68  b (conc *toppath
93b0: 2a 20 22 2f 74 65 73 74 73 2f 22 20 28 73 74 72  * "/tests/" (str
93c0: 69 6e 67 2d 74 72 61 6e 73 6c 61 74 65 20 70 61  ing-translate pa
93d0: 74 74 20 22 25 22 20 22 2a 22 29 29 29 29 29 0a  tt "%" "*"))))).
93e0: 09 20 28 73 65 74 21 20 74 65 73 74 73 20 28 66  . (set! tests (f
93f0: 69 6c 74 65 72 20 28 6c 61 6d 62 64 61 20 28 74  ilter (lambda (t
9400: 65 73 74 29 28 66 69 6c 65 2d 65 78 69 73 74 73  est)(file-exists
9410: 3f 20 28 63 6f 6e 63 20 74 65 73 74 20 22 2f 74  ? (conc test "/t
9420: 65 73 74 63 6f 6e 66 69 67 22 29 29 29 20 74 65  estconfig"))) te
9430: 73 74 73 29 29 0a 09 20 28 73 65 74 21 20 74 65  sts)).. (set! te
9440: 73 74 2d 6e 61 6d 65 73 20 28 61 70 70 65 6e 64  st-names (append
9450: 20 74 65 73 74 2d 6e 61 6d 65 73 20 0a 09 09 09   test-names ....
9460: 09 20 20 28 6d 61 70 20 28 6c 61 6d 62 64 61 20  .  (map (lambda 
9470: 28 74 65 73 74 70 29 0a 09 09 09 09 09 20 28 6c  (testp)...... (l
9480: 61 73 74 20 28 73 74 72 69 6e 67 2d 73 70 6c 69  ast (string-spli
9490: 74 20 74 65 73 74 70 20 22 2f 22 29 29 29 0a 09  t testp "/")))..
94a0: 09 09 09 20 20 20 20 20 20 20 74 65 73 74 73 29  ...       tests)
94b0: 29 29 29 29 0a 20 20 20 20 20 28 73 74 72 69 6e  )))).     (strin
94c0: 67 2d 73 70 6c 69 74 20 74 65 73 74 2d 70 61 74  g-split test-pat
94d0: 74 73 20 22 2c 22 29 29 0a 0a 20 20 20 20 3b 3b  ts ","))..    ;;
94e0: 20 6e 6f 77 20 72 65 6d 6f 76 65 20 64 75 70 6c   now remove dupl
94f0: 69 63 61 74 65 73 0a 20 20 20 20 28 73 65 74 21  icates.    (set!
9500: 20 74 65 73 74 2d 6e 61 6d 65 73 20 28 64 65 6c   test-names (del
9510: 65 74 65 2d 64 75 70 6c 69 63 61 74 65 73 20 74  ete-duplicates t
9520: 65 73 74 2d 6e 61 6d 65 73 29 29 0a 0a 20 20 20  est-names))..   
9530: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
9540: 22 49 4e 46 4f 3a 20 74 65 73 74 20 6e 61 6d 65  "INFO: test name
9550: 73 20 22 20 74 65 73 74 2d 6e 61 6d 65 73 29 0a  s " test-names).
9560: 0a 20 20 20 20 3b 3b 20 6e 6f 77 20 61 64 64 20  .    ;; now add 
9570: 6e 6f 6e 2d 64 69 72 65 63 74 6c 79 20 72 65 66  non-directly ref
9580: 65 72 65 6e 63 65 64 20 64 65 70 65 6e 64 65 6e  erenced dependen
9590: 63 69 65 73 20 28 69 2e 65 2e 20 77 61 69 74 6f  cies (i.e. waito
95a0: 6e 29 0a 20 20 20 20 3b 3b 20 63 6f 75 6c 64 20  n).    ;; could 
95b0: 63 61 63 68 65 20 61 6c 6c 20 74 68 65 73 65 20  cache all these 
95c0: 73 69 6e 63 65 20 74 68 65 79 20 6e 65 65 64 20  since they need 
95d0: 74 6f 20 62 65 20 72 65 61 64 20 61 67 61 69 6e  to be read again
95e0: 20 2e 2e 2e 0a 20 20 20 20 3b 3b 20 46 49 58 4d   ....    ;; FIXM
95f0: 45 20 53 4f 4d 45 44 41 59 0a 20 20 20 20 28 66  E SOMEDAY.    (f
9600: 6f 72 2d 65 61 63 68 20 0a 20 20 20 20 20 28 6c  or-each .     (l
9610: 61 6d 62 64 61 20 28 74 65 73 74 2d 6e 61 6d 65  ambda (test-name
9620: 29 0a 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28  ).       (let* (
9630: 28 63 6f 6e 66 69 67 20 28 74 65 73 74 3a 67 65  (config (test:ge
9640: 74 2d 74 65 73 74 63 6f 6e 66 69 67 20 74 65 73  t-testconfig tes
9650: 74 2d 6e 61 6d 65 20 23 66 29 29 0a 09 20 20 20  t-name #f))..   
9660: 20 20 20 28 77 61 69 74 6f 6e 20 28 63 6f 6e 66     (waiton (conf
9670: 69 67 2d 6c 6f 6f 6b 75 70 20 63 6f 6e 66 69 67  ig-lookup config
9680: 20 22 72 65 71 75 69 72 65 6d 65 6e 74 73 22 20   "requirements" 
9690: 22 77 61 69 74 6f 6e 22 29 29 29 0a 09 20 28 69  "waiton"))).. (i
96a0: 66 20 28 61 6e 64 20 77 61 69 74 6f 6e 20 28 6e  f (and waiton (n
96b0: 6f 74 20 28 6d 65 6d 62 65 72 20 77 61 69 74 6f  ot (member waito
96c0: 6e 20 74 65 73 74 2d 6e 61 6d 65 73 29 29 29 0a  n test-names))).
96d0: 09 20 20 20 20 20 28 73 65 74 21 20 74 65 73 74  .     (set! test
96e0: 2d 6e 61 6d 65 73 20 28 61 70 70 65 6e 64 20 74  -names (append t
96f0: 65 73 74 2d 6e 61 6d 65 73 20 28 6c 69 73 74 20  est-names (list 
9700: 77 61 69 74 6f 6e 29 29 29 29 29 29 0a 20 20 20  waiton)))))).   
9710: 20 20 74 65 73 74 2d 6e 61 6d 65 73 29 0a 0a 20    test-names).. 
9720: 20 20 20 3b 3b 20 6f 6e 20 74 68 65 20 66 69 72     ;; on the fir
9730: 73 74 20 70 61 73 73 20 6f 72 20 63 61 6c 6c 20  st pass or call 
9740: 74 6f 20 72 75 6e 2d 74 65 73 74 73 20 73 65 74  to run-tests set
9750: 20 46 41 49 4c 53 20 74 6f 20 4e 4f 54 5f 53 54   FAILS to NOT_ST
9760: 41 52 54 45 44 20 69 66 0a 20 20 20 20 3b 3b 20  ARTED if.    ;; 
9770: 2d 6b 65 65 70 67 6f 69 6e 67 20 69 73 20 73 70  -keepgoing is sp
9780: 65 63 69 66 69 65 64 0a 20 20 20 20 28 69 66 20  ecified.    (if 
9790: 28 61 6e 64 20 28 65 71 3f 20 2a 70 61 73 73 6e  (and (eq? *passn
97a0: 75 6d 2a 20 30 29 0a 09 20 20 20 20 20 6b 65 65  um* 0)..     kee
97b0: 70 67 6f 69 6e 67 29 0a 09 28 62 65 67 69 6e 0a  pgoing)..(begin.
97c0: 09 20 20 3b 3b 20 68 61 76 65 20 74 6f 20 64 65  .  ;; have to de
97d0: 6c 65 74 65 20 74 65 73 74 20 72 65 63 6f 72 64  lete test record
97e0: 73 20 77 68 65 72 65 20 4e 4f 54 5f 53 54 41 52  s where NOT_STAR
97f0: 54 45 44 20 73 69 6e 63 65 20 74 68 65 79 20 63  TED since they c
9800: 61 6e 20 63 61 75 73 65 20 2d 6b 65 65 70 67 6f  an cause -keepgo
9810: 69 6e 67 20 74 6f 20 0a 09 20 20 3b 3b 20 67 65  ing to ..  ;; ge
9820: 74 20 73 74 75 63 6b 20 64 75 65 20 74 6f 20 62  t stuck due to b
9830: 65 63 6f 6d 69 6e 67 20 69 6e 61 63 63 65 73 73  ecoming inaccess
9840: 69 62 6c 65 20 66 72 6f 6d 20 61 20 66 61 69 6c  ible from a fail
9850: 65 64 20 74 65 73 74 2e 20 49 2e 65 2e 20 69 66  ed test. I.e. if
9860: 20 74 65 73 74 20 42 20 64 65 70 65 6e 64 73 20   test B depends 
9870: 0a 09 20 20 3b 3b 20 6f 6e 20 74 65 73 74 20 41  ..  ;; on test A
9880: 20 62 75 74 20 74 65 73 74 20 42 20 72 65 61 63   but test B reac
9890: 68 65 64 20 74 68 65 20 70 6f 69 6e 74 20 6f 6e  hed the point on
98a0: 20 62 65 69 6e 67 20 72 65 67 69 73 74 65 72 65   being registere
98b0: 64 20 61 73 20 4e 4f 54 5f 53 54 41 52 54 45 44  d as NOT_STARTED
98c0: 20 61 6e 64 20 74 65 73 74 0a 09 20 20 3b 3b 20   and test..  ;; 
98d0: 41 20 66 61 69 6c 65 64 20 66 6f 72 20 73 6f 6d  A failed for som
98e0: 65 20 72 65 61 73 6f 6e 20 74 68 65 6e 20 6f 6e  e reason then on
98f0: 20 72 65 2d 72 75 6e 20 75 73 69 6e 67 20 2d 6b   re-run using -k
9900: 65 65 70 67 6f 69 6e 67 20 74 68 65 20 72 75 6e  eepgoing the run
9910: 20 63 61 6e 20 6e 65 76 65 72 20 63 6f 6d 70 6c   can never compl
9920: 65 74 65 2e 0a 09 20 20 28 64 62 3a 64 65 6c 65  ete...  (db:dele
9930: 74 65 2d 74 65 73 74 73 2d 69 6e 2d 73 74 61 74  te-tests-in-stat
9940: 65 20 64 62 20 72 75 6e 2d 69 64 20 22 4e 4f 54  e db run-id "NOT
9950: 5f 53 54 41 52 54 45 44 22 29 0a 09 20 20 28 64  _STARTED")..  (d
9960: 62 3a 73 65 74 2d 74 65 73 74 73 2d 73 74 61 74  b:set-tests-stat
9970: 65 2d 73 74 61 74 75 73 20 64 62 20 72 75 6e 2d  e-status db run-
9980: 69 64 20 74 65 73 74 2d 6e 61 6d 65 73 20 23 66  id test-names #f
9990: 20 22 46 41 49 4c 22 20 22 4e 4f 54 5f 53 54 41   "FAIL" "NOT_STA
99a0: 52 54 45 44 22 20 22 46 41 49 4c 22 29 29 29 0a  RTED" "FAIL"))).
99b0: 20 20 20 20 28 73 65 74 21 20 2a 70 61 73 73 6e      (set! *passn
99c0: 75 6d 2a 20 28 2b 20 2a 70 61 73 73 6e 75 6d 2a  um* (+ *passnum*
99d0: 20 31 29 29 0a 20 20 20 20 28 6c 65 74 20 6c 6f   1)).    (let lo
99e0: 6f 70 20 28 28 6e 75 6d 74 69 6d 65 73 20 30 29  op ((numtimes 0)
99f0: 29 0a 20 20 20 20 20 20 28 66 6f 72 2d 65 61 63  ).      (for-eac
9a00: 68 20 0a 20 20 20 20 20 20 20 28 6c 61 6d 62 64  h .       (lambd
9a10: 61 20 28 74 65 73 74 2d 6e 61 6d 65 29 0a 09 20  a (test-name).. 
9a20: 28 69 66 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75  (if (runs:can-ru
9a30: 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64 62 29  n-more-tests db)
9a40: 0a 09 20 20 20 20 20 28 72 75 6e 3a 74 65 73 74  ..     (run:test
9a50: 20 64 62 20 72 75 6e 2d 69 64 20 72 75 6e 6e 61   db run-id runna
9a60: 6d 65 20 74 65 73 74 2d 6e 61 6d 65 20 6b 65 79  me test-name key
9a70: 76 61 6c 6c 73 74 20 69 74 65 6d 2d 70 61 74 74  vallst item-patt
9a80: 73 20 66 6c 61 67 73 29 0a 09 20 20 20 20 20 29  s flags)..     )
9a90: 29 0a 20 20 20 20 20 20 20 28 74 65 73 74 73 3a  ).       (tests:
9aa0: 73 6f 72 74 2d 62 79 2d 70 72 69 6f 72 69 74 79  sort-by-priority
9ab0: 2d 61 6e 64 2d 77 61 69 74 6f 6e 20 74 65 73 74  -and-waiton test
9ac0: 2d 6e 61 6d 65 73 29 29 0a 20 20 20 20 20 20 3b  -names)).      ;
9ad0: 3b 20 28 72 75 6e 2d 77 61 69 74 69 6e 67 2d 74  ; (run-waiting-t
9ae0: 65 73 74 73 20 64 62 29 0a 20 20 20 20 20 20 28  ests db).      (
9af0: 69 66 20 6b 65 65 70 67 6f 69 6e 67 0a 09 20 20  if keepgoing..  
9b00: 28 6c 65 74 20 28 28 65 73 74 72 65 6d 20 28 64  (let ((estrem (d
9b10: 62 3a 65 73 74 69 6d 61 74 65 64 2d 74 65 73 74  b:estimated-test
9b20: 73 2d 72 65 6d 61 69 6e 69 6e 67 20 64 62 20 72  s-remaining db r
9b30: 75 6e 2d 69 64 29 29 29 0a 09 20 20 20 20 28 69  un-id)))..    (i
9b40: 66 20 28 61 6e 64 20 28 3e 20 65 73 74 72 65 6d  f (and (> estrem
9b50: 20 30 29 0a 09 09 20 20 20 20 20 28 65 71 3f 20   0)...     (eq? 
9b60: 2a 67 6c 6f 62 61 6c 65 78 69 74 73 74 61 74 75  *globalexitstatu
9b70: 73 2a 20 30 29 29 0a 09 09 28 62 65 67 69 6e 0a  s* 0))...(begin.
9b80: 09 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ..  (debug:print
9b90: 20 31 20 22 4b 65 65 70 20 67 6f 69 6e 67 2c 20   1 "Keep going, 
9ba0: 65 73 74 69 6d 61 74 65 64 20 22 20 65 73 74 72  estimated " estr
9bb0: 65 6d 20 22 20 74 65 73 74 73 20 72 65 6d 61 69  em " tests remai
9bc0: 6e 69 6e 67 20 74 6f 20 72 75 6e 2c 20 77 69 6c  ning to run, wil
9bd0: 6c 20 63 6f 6e 74 69 6e 75 65 20 69 6e 20 33 20  l continue in 3 
9be0: 73 65 63 6f 6e 64 73 20 2e 2e 2e 22 29 0a 09 09  seconds ...")...
9bf0: 20 20 28 73 6c 65 65 70 20 33 29 0a 09 09 20 20    (sleep 3)...  
9c00: 28 72 75 6e 2d 77 61 69 74 69 6e 67 2d 74 65 73  (run-waiting-tes
9c10: 74 73 20 64 62 29 0a 09 09 20 20 28 6c 6f 6f 70  ts db)...  (loop
9c20: 20 28 2b 20 6e 75 6d 74 69 6d 65 73 20 31 29 29   (+ numtimes 1))
9c30: 29 29 29 29 29 29 29 0a 0a 28 64 65 66 69 6e 65  )))))))..(define
9c40: 20 28 72 75 6e 3a 74 65 73 74 20 64 62 20 72 75   (run:test db ru
9c50: 6e 2d 69 64 20 72 75 6e 6e 61 6d 65 20 74 65 73  n-id runname tes
9c60: 74 2d 6e 61 6d 65 20 6b 65 79 76 61 6c 6c 73 74  t-name keyvallst
9c70: 20 69 74 65 6d 2d 70 61 74 74 73 20 66 6c 61 67   item-patts flag
9c80: 73 29 0a 20 20 28 64 65 62 75 67 3a 70 72 69 6e  s).  (debug:prin
9c90: 74 20 31 20 22 4c 61 75 6e 63 68 69 6e 67 20 74  t 1 "Launching t
9ca0: 65 73 74 20 22 20 74 65 73 74 2d 6e 61 6d 65 29  est " test-name)
9cb0: 0a 20 20 3b 3b 20 41 6c 6c 20 74 68 65 73 65 20  .  ;; All these 
9cc0: 76 61 72 73 20 6d 69 67 68 74 20 62 65 20 72 65  vars might be re
9cd0: 66 65 72 65 6e 63 65 64 20 62 79 20 74 68 65 20  ferenced by the 
9ce0: 74 65 73 74 63 6f 6e 66 69 67 20 66 69 6c 65 20  testconfig file 
9cf0: 72 65 61 64 65 72 0a 20 20 28 73 65 74 65 6e 76  reader.  (setenv
9d00: 20 22 4d 54 5f 54 45 53 54 5f 4e 41 4d 45 22 20   "MT_TEST_NAME" 
9d10: 74 65 73 74 2d 6e 61 6d 65 29 20 3b 3b 20 0a 20  test-name) ;; . 
9d20: 20 28 73 65 74 65 6e 76 20 22 4d 54 5f 52 55 4e   (setenv "MT_RUN
9d30: 4e 41 4d 45 22 20 20 20 72 75 6e 6e 61 6d 65 29  NAME"   runname)
9d40: 0a 20 20 28 73 65 74 2d 6d 65 67 61 74 65 73 74  .  (set-megatest
9d50: 2d 65 6e 76 2d 76 61 72 73 20 64 62 20 72 75 6e  -env-vars db run
9d60: 2d 69 64 29 20 3b 3b 20 74 68 65 73 65 20 6d 61  -id) ;; these ma
9d70: 79 20 62 65 20 6e 65 65 64 65 64 20 62 79 20 74  y be needed by t
9d80: 68 65 20 6c 61 75 6e 63 68 69 6e 67 20 70 72 6f  he launching pro
9d90: 63 65 73 73 0a 20 20 28 63 68 61 6e 67 65 2d 64  cess.  (change-d
9da0: 69 72 65 63 74 6f 72 79 20 2a 74 6f 70 70 61 74  irectory *toppat
9db0: 68 2a 29 0a 20 20 28 6c 65 74 2a 20 28 28 74 65  h*).  (let* ((te
9dc0: 73 74 2d 70 61 74 68 20 20 20 20 28 63 6f 6e 63  st-path    (conc
9dd0: 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f 74 65 73   *toppath* "/tes
9de0: 74 73 2f 22 20 74 65 73 74 2d 6e 61 6d 65 29 29  ts/" test-name))
9df0: 20 3b 3b 20 63 6f 75 6c 64 20 75 73 65 20 74 65   ;; could use te
9e00: 73 74 3a 67 65 74 2d 74 65 73 74 63 6f 6e 66 69  st:get-testconfi
9e10: 67 20 68 65 72 65 20 2e 2e 2e 0a 09 20 28 74 65  g here ..... (te
9e20: 73 74 2d 63 6f 6e 66 69 67 66 20 28 63 6f 6e 63  st-configf (conc
9e30: 20 74 65 73 74 2d 70 61 74 68 20 22 2f 74 65 73   test-path "/tes
9e40: 74 63 6f 6e 66 69 67 22 29 29 0a 09 20 28 74 65  tconfig")).. (te
9e50: 73 74 65 78 69 73 74 73 20 20 20 28 61 6e 64 20  stexists   (and 
9e60: 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 74 65  (file-exists? te
9e70: 73 74 2d 63 6f 6e 66 69 67 66 29 28 66 69 6c 65  st-configf)(file
9e80: 2d 72 65 61 64 2d 61 63 63 65 73 73 3f 20 74 65  -read-access? te
9e90: 73 74 2d 63 6f 6e 66 69 67 66 29 29 29 0a 09 20  st-configf))).. 
9ea0: 28 74 65 73 74 2d 63 6f 6e 66 20 20 20 20 28 69  (test-conf    (i
9eb0: 66 20 74 65 73 74 65 78 69 73 74 73 20 28 72 65  f testexists (re
9ec0: 61 64 2d 63 6f 6e 66 69 67 20 74 65 73 74 2d 63  ad-config test-c
9ed0: 6f 6e 66 69 67 66 20 23 66 20 23 74 29 20 28 6d  onfigf #f #t) (m
9ee0: 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29  ake-hash-table))
9ef0: 29 0a 09 20 28 77 61 69 74 6f 6e 20 20 20 20 20  ).. (waiton     
9f00: 20 20 28 6c 65 74 20 28 28 77 20 28 63 6f 6e 66    (let ((w (conf
9f10: 69 67 2d 6c 6f 6f 6b 75 70 20 74 65 73 74 2d 63  ig-lookup test-c
9f20: 6f 6e 66 20 22 72 65 71 75 69 72 65 6d 65 6e 74  onf "requirement
9f30: 73 22 20 22 77 61 69 74 6f 6e 22 29 29 29 0a 09  s" "waiton")))..
9f40: 09 09 20 28 69 66 20 28 73 74 72 69 6e 67 3f 20  .. (if (string? 
9f50: 77 29 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20  w)(string-split 
9f60: 77 29 27 28 29 29 29 29 0a 09 20 28 66 6f 72 63  w)'()))).. (forc
9f70: 65 20 20 20 20 20 20 20 20 28 68 61 73 68 2d 74  e        (hash-t
9f80: 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74  able-ref/default
9f90: 20 66 6c 61 67 73 20 22 2d 66 6f 72 63 65 22 20   flags "-force" 
9fa0: 23 66 29 29 0a 09 20 28 72 65 72 75 6e 20 20 20  #f)).. (rerun   
9fb0: 20 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65       (hash-table
9fc0: 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 66 6c 61  -ref/default fla
9fd0: 67 73 20 22 2d 72 65 72 75 6e 22 20 23 66 29 29  gs "-rerun" #f))
9fe0: 0a 09 20 28 6b 65 65 70 67 6f 69 6e 67 20 20 20  .. (keepgoing   
9ff0: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
a000: 2f 64 65 66 61 75 6c 74 20 66 6c 61 67 73 20 22  /default flags "
a010: 2d 6b 65 65 70 67 6f 69 6e 67 22 20 23 66 29 29  -keepgoing" #f))
a020: 0a 09 20 3b 3b 20 41 72 65 20 74 68 65 73 65 20  .. ;; Are these 
a030: 74 61 67 73 20 73 74 69 6c 6c 20 75 73 65 64 3f  tags still used?
a040: 20 49 20 64 6f 6e 27 74 20 74 68 69 6e 6b 20 73   I don't think s
a050: 6f 2e 2e 2e 0a 09 20 3b 3b 28 74 61 67 73 20 20  o..... ;;(tags  
a060: 20 20 20 20 20 20 20 28 6c 65 74 20 28 28 74 20         (let ((t 
a070: 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 74  (config-lookup t
a080: 65 73 74 2d 63 6f 6e 66 20 22 73 65 74 75 70 22  est-conf "setup"
a090: 20 22 74 61 67 73 22 29 29 29 0a 09 20 3b 3b 20   "tags"))).. ;; 
a0a0: 20 20 20 20 20 20 09 20 3b 3b 20 77 65 20 77 61        . ;; we wa
a0b0: 6e 74 20 6f 75 72 20 74 61 67 73 20 74 6f 20 62  nt our tags to b
a0c0: 65 20 73 65 70 61 72 61 74 65 64 20 62 79 20 63  e separated by c
a0d0: 6f 6d 6d 61 73 20 61 6e 64 20 66 75 6c 6c 79 20  ommas and fully 
a0e0: 64 65 6c 69 6d 69 74 65 64 20 62 79 20 63 6f 6d  delimited by com
a0f0: 6d 61 73 0a 09 20 3b 3b 20 20 20 20 20 20 20 09  mas.. ;;       .
a100: 20 3b 3b 20 73 6f 20 74 68 61 74 20 71 75 65 72   ;; so that quer
a110: 69 65 73 20 77 69 74 68 20 22 6c 69 6b 65 22 20  ies with "like" 
a120: 63 61 6e 20 74 69 65 20 74 6f 20 74 68 65 20 63  can tie to the c
a130: 6f 6d 6d 61 73 20 61 74 20 65 69 74 68 65 72 20  ommas at either 
a140: 65 6e 64 20 6f 66 20 65 61 63 68 20 74 61 67 0a  end of each tag.
a150: 09 20 3b 3b 20 20 20 20 20 20 20 09 20 3b 3b 20  . ;;       . ;; 
a160: 77 68 69 6c 65 20 61 6c 73 6f 20 61 6c 6c 6f 77  while also allow
a170: 69 6e 67 20 74 68 65 20 65 6e 64 20 75 73 65 72  ing the end user
a180: 20 74 6f 20 66 72 65 65 6c 79 20 75 73 65 20 73   to freely use s
a190: 70 61 63 65 73 20 61 6e 64 20 63 6f 6d 6d 61 73  paces and commas
a1a0: 20 74 6f 20 73 65 70 61 72 61 74 65 20 74 61 67   to separate tag
a1b0: 73 0a 09 20 3b 3b 20 20 20 20 20 20 20 09 20 28  s.. ;;       . (
a1c0: 69 66 20 28 73 74 72 69 6e 67 3f 20 74 29 28 73  if (string? t)(s
a1d0: 74 72 69 6e 67 2d 73 75 62 73 74 69 74 75 74 65  tring-substitute
a1e0: 20 28 72 65 67 65 78 70 20 22 5b 2c 5c 5c 73 5d   (regexp "[,\\s]
a1f0: 2b 22 29 20 22 2c 22 20 28 63 6f 6e 63 20 22 2c  +") "," (conc ",
a200: 22 20 74 20 22 2c 22 29 20 23 74 29 0a 09 20 3b  " t ",") #t).. ;
a210: 3b 20 20 20 20 20 20 20 09 20 20 20 20 20 27 28  ;       .     '(
a220: 29 29 29 29 29 0a 09 20 29 0a 20 20 20 20 28 69  ))))).. ).    (i
a230: 66 20 28 6e 6f 74 20 74 65 73 74 65 78 69 73 74  f (not testexist
a240: 73 29 0a 09 3b 3b 20 69 66 20 74 68 65 20 74 65  s)..;; if the te
a250: 73 74 20 69 73 20 69 6c 6c 20 64 65 66 69 6e 65  st is ill define
a260: 64 20 73 70 69 74 20 6f 75 74 20 61 6e 20 65 72  d spit out an er
a270: 72 6f 72 20 62 75 74 20 6b 65 65 70 20 67 6f 69  ror but keep goi
a280: 6e 67 20 28 64 69 66 66 65 72 65 6e 74 20 66 72  ng (different fr
a290: 6f 6d 20 68 6f 77 20 64 6f 6e 65 20 70 72 65 76  om how done prev
a2a0: 69 6f 75 73 6c 79 0a 09 28 64 65 62 75 67 3a 70  iously..(debug:p
a2b0: 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 43  rint 0 "ERROR: C
a2c0: 61 6e 27 74 20 66 69 6e 64 20 63 6f 6e 66 69 67  an't find config
a2d0: 20 66 69 6c 65 20 22 20 74 65 73 74 2d 63 6f 6e   file " test-con
a2e0: 66 69 67 66 29 0a 09 3b 3b 20 70 75 74 20 74 6f  figf)..;; put to
a2f0: 70 20 76 61 72 73 20 69 6e 74 6f 20 63 6f 6e 76  p vars into conv
a300: 65 6e 69 65 6e 74 20 76 61 72 69 61 62 6c 65 73  enient variables
a310: 20 61 6e 64 20 6f 70 65 6e 20 74 68 65 20 64 62   and open the db
a320: 0a 09 28 6c 65 74 2a 20 28 3b 3b 20 64 62 20 69  ..(let* (;; db i
a330: 73 20 61 6c 77 61 79 73 20 61 74 20 2a 74 6f 70  s always at *top
a340: 70 61 74 68 2a 2f 64 62 2f 6d 65 67 61 74 65 73  path*/db/megates
a350: 74 2e 64 62 0a 09 20 20 20 20 20 20 20 28 69 74  t.db..       (it
a360: 65 6d 73 20 20 20 20 20 20 20 28 68 61 73 68 2d  ems       (hash-
a370: 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c  table-ref/defaul
a380: 74 20 74 65 73 74 2d 63 6f 6e 66 20 22 69 74 65  t test-conf "ite
a390: 6d 73 22 20 27 28 29 29 29 0a 09 20 20 20 20 20  ms" '()))..     
a3a0: 20 20 28 69 74 65 6d 73 74 61 62 6c 65 20 20 28    (itemstable  (
a3b0: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64  hash-table-ref/d
a3c0: 65 66 61 75 6c 74 20 74 65 73 74 2d 63 6f 6e 66  efault test-conf
a3d0: 20 22 69 74 65 6d 73 74 61 62 6c 65 22 20 27 28   "itemstable" '(
a3e0: 29 29 29 0a 09 20 20 20 20 20 20 20 28 61 6c 6c  )))..       (all
a3f0: 69 74 65 6d 73 20 20 20 20 28 69 66 20 28 6f 72  items    (if (or
a400: 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 69 74 65   (not (null? ite
a410: 6d 73 29 29 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20  ms))(not (null? 
a420: 69 74 65 6d 73 74 61 62 6c 65 29 29 29 0a 09 09  itemstable)))...
a430: 09 09 28 61 70 70 65 6e 64 20 28 69 74 65 6d 2d  ..(append (item-
a440: 61 73 73 6f 63 2d 3e 69 74 65 6d 2d 6c 69 73 74  assoc->item-list
a450: 20 69 74 65 6d 73 29 0a 09 09 09 09 09 28 69 74   items)......(it
a460: 65 6d 2d 74 61 62 6c 65 2d 3e 69 74 65 6d 2d 6c  em-table->item-l
a470: 69 73 74 20 69 74 65 6d 73 74 61 62 6c 65 29 29  ist itemstable))
a480: 0a 09 09 09 09 27 28 28 29 29 29 29 20 3b 3b 20  .....'(()))) ;; 
a490: 61 20 6c 69 73 74 20 77 69 74 68 20 6f 6e 65 20  a list with one 
a4a0: 6e 75 6c 6c 20 6c 69 73 74 20 69 73 20 61 20 74  null list is a t
a4b0: 65 73 74 20 77 69 74 68 20 6e 6f 20 69 74 65 6d  est with no item
a4c0: 73 0a 09 20 20 20 20 20 20 20 28 72 75 6e 63 6f  s..       (runco
a4d0: 6e 66 69 67 66 20 20 28 63 6f 6e 63 20 20 2a 74  nfigf  (conc  *t
a4e0: 6f 70 70 61 74 68 2a 20 22 2f 72 75 6e 63 6f 6e  oppath* "/runcon
a4f0: 66 69 67 73 2e 63 6f 6e 66 69 67 22 29 29 29 0a  figs.config"))).
a500: 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20  .  (debug:print 
a510: 31 20 22 69 74 65 6d 73 3a 20 22 29 0a 09 20 20  1 "items: ")..  
a520: 28 69 66 20 28 3e 3d 20 2a 76 65 72 62 6f 73 69  (if (>= *verbosi
a530: 74 79 2a 20 31 29 28 70 70 20 61 6c 6c 69 74 65  ty* 1)(pp allite
a540: 6d 73 29 29 0a 09 20 20 28 69 66 20 28 3e 3d 20  ms))..  (if (>= 
a550: 2a 76 65 72 62 6f 73 69 74 79 2a 20 35 29 0a 09  *verbosity* 5)..
a560: 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09 28        (begin...(
a570: 70 72 69 6e 74 20 22 69 74 65 6d 73 3a 20 22 29  print "items: ")
a580: 28 70 70 20 28 69 74 65 6d 2d 61 73 73 6f 63 2d  (pp (item-assoc-
a590: 3e 69 74 65 6d 2d 6c 69 73 74 20 69 74 65 6d 73  >item-list items
a5a0: 29 29 0a 09 09 28 70 72 69 6e 74 20 22 69 74 65  ))...(print "ite
a5b0: 6d 73 74 61 62 6c 65 3a 20 22 29 28 70 70 20 28  mstable: ")(pp (
a5c0: 69 74 65 6d 2d 74 61 62 6c 65 2d 3e 69 74 65 6d  item-table->item
a5d0: 2d 6c 69 73 74 20 69 74 65 6d 73 74 61 62 6c 65  -list itemstable
a5e0: 29 29 29 29 0a 0a 09 20 20 3b 3b 20 43 6f 6d 6d  ))))...  ;; Comm
a5f0: 65 6e 74 73 20 61 72 65 20 6c 6f 61 64 65 64 20  ents are loaded 
a600: 62 79 20 74 68 65 20 74 65 73 74 20 72 75 6e 2c  by the test run,
a610: 20 6e 6f 74 20 61 74 20 6c 61 75 6e 63 68 20 74   not at launch t
a620: 69 6d 65 20 28 69 6e 20 67 65 6e 65 72 61 6c 29  ime (in general)
a630: 0a 09 20 20 3b 3b 28 69 66 20 28 61 72 67 73 3a  ..  ;;(if (args:
a640: 67 65 74 2d 61 72 67 20 22 2d 6d 22 29 0a 09 20  get-arg "-m").. 
a650: 20 3b 3b 20 20 20 20 28 64 62 3a 73 65 74 2d 63   ;;    (db:set-c
a660: 6f 6d 6d 65 6e 74 2d 66 6f 72 2d 72 75 6e 20 64  omment-for-run d
a670: 62 20 72 75 6e 2d 69 64 20 28 61 72 67 73 3a 67  b run-id (args:g
a680: 65 74 2d 61 72 67 20 22 2d 6d 22 29 29 29 0a 0a  et-arg "-m")))..
a690: 09 20 20 3b 3b 20 48 65 72 65 20 69 73 20 77 68  .  ;; Here is wh
a6a0: 65 72 65 20 74 68 65 20 74 65 73 74 5f 6d 65 74  ere the test_met
a6b0: 61 20 74 61 62 6c 65 20 69 73 20 62 65 73 74 20  a table is best 
a6c0: 75 70 64 61 74 65 64 0a 09 20 20 28 72 75 6e 73  updated..  (runs
a6d0: 3a 75 70 64 61 74 65 2d 74 65 73 74 5f 6d 65 74  :update-test_met
a6e0: 61 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 20 74  a db test-name t
a6f0: 65 73 74 2d 63 6f 6e 66 29 0a 0a 09 20 20 3b 3b  est-conf)...  ;;
a700: 20 62 72 61 69 6e 64 65 61 64 20 77 6f 72 6b 2d   braindead work-
a710: 61 72 6f 75 6e 64 20 66 6f 72 20 70 6f 6f 72 6c  around for poorl
a720: 79 20 73 70 65 63 69 66 69 65 64 20 61 6c 6c 69  y specified alli
a730: 74 65 6d 73 20 6c 69 73 74 20 42 55 47 21 21 21  tems list BUG!!!
a740: 20 46 49 58 4d 45 0a 09 20 20 28 69 66 20 28 6e   FIXME..  (if (n
a750: 75 6c 6c 3f 20 61 6c 6c 69 74 65 6d 73 29 28 73  ull? allitems)(s
a760: 65 74 21 20 61 6c 6c 69 74 65 6d 73 20 27 28 28  et! allitems '((
a770: 29 29 29 29 0a 09 20 20 28 6c 65 74 20 6c 6f 6f  ))))..  (let loo
a780: 70 20 28 28 69 74 65 6d 64 61 74 20 28 63 61 72  p ((itemdat (car
a790: 20 61 6c 6c 69 74 65 6d 73 29 29 0a 09 09 20 20   allitems))...  
a7a0: 20 20 20 28 74 61 6c 20 20 20 20 20 28 63 64 72     (tal     (cdr
a7b0: 20 61 6c 6c 69 74 65 6d 73 29 29 29 0a 09 20 20   allitems)))..  
a7c0: 20 20 3b 3b 20 28 6c 61 6d 62 64 61 20 28 69 74    ;; (lambda (it
a7d0: 65 6d 64 61 74 29 20 3b 3b 3b 20 28 28 72 69 70  emdat) ;;; ((rip
a7e0: 65 6e 65 73 73 20 22 6f 76 65 72 72 69 70 65 22  eness "overripe"
a7f0: 29 20 28 74 65 6d 70 65 72 61 74 75 72 65 20 22  ) (temperature "
a800: 63 6f 6f 6c 22 29 20 28 73 65 61 73 6f 6e 20 22  cool") (season "
a810: 73 75 6d 6d 65 72 22 29 29 0a 09 20 20 20 20 3b  summer"))..    ;
a820: 3b 20 48 61 6e 64 6c 65 20 6c 69 73 74 73 20 6f  ; Handle lists o
a830: 66 20 69 74 65 6d 73 0a 09 20 20 20 20 28 6c 65  f items..    (le
a840: 74 2a 20 28 28 69 74 65 6d 2d 70 61 74 68 20 20  t* ((item-path  
a850: 20 20 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70     (item-list->p
a860: 61 74 68 20 69 74 65 6d 64 61 74 29 29 20 3b 3b  ath itemdat)) ;;
a870: 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70   (string-intersp
a880: 65 72 73 65 20 28 6d 61 70 20 63 61 64 72 20 69  erse (map cadr i
a890: 74 65 6d 64 61 74 29 20 22 2f 22 29 29 0a 09 09  temdat) "/"))...
a8a0: 20 20 20 28 6e 65 77 2d 74 65 73 74 2d 70 61 74     (new-test-pat
a8b0: 68 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73  h (string-inters
a8c0: 70 65 72 73 65 20 28 63 6f 6e 73 20 74 65 73 74  perse (cons test
a8d0: 2d 70 61 74 68 20 28 6d 61 70 20 63 61 64 72 20  -path (map cadr 
a8e0: 69 74 65 6d 64 61 74 29 29 20 22 2f 22 29 29 0a  itemdat)) "/")).
a8f0: 09 09 20 20 20 28 6e 65 77 2d 74 65 73 74 2d 6e  ..   (new-test-n
a900: 61 6d 65 20 28 69 66 20 28 65 71 75 61 6c 3f 20  ame (if (equal? 
a910: 69 74 65 6d 2d 70 61 74 68 20 22 22 29 20 74 65  item-path "") te
a920: 73 74 2d 6e 61 6d 65 20 28 63 6f 6e 63 20 74 65  st-name (conc te
a930: 73 74 2d 6e 61 6d 65 20 22 2f 22 20 69 74 65 6d  st-name "/" item
a940: 2d 70 61 74 68 29 29 29 20 3b 3b 20 6a 75 73 74  -path))) ;; just
a950: 20 6e 65 65 64 20 69 74 20 74 6f 20 62 65 20 75   need it to be u
a960: 6e 69 71 75 65 0a 09 09 20 20 20 28 74 65 73 74  nique...   (test
a970: 64 61 74 20 20 20 23 66 29 0a 09 09 20 20 20 28  dat   #f)...   (
a980: 6e 75 6d 2d 72 75 6e 6e 69 6e 67 20 28 64 62 3a  num-running (db:
a990: 67 65 74 2d 63 6f 75 6e 74 2d 74 65 73 74 73 2d  get-count-tests-
a9a0: 72 75 6e 6e 69 6e 67 20 64 62 29 29 0a 09 09 20  running db))... 
a9b0: 20 20 28 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e    (max-concurren
a9c0: 74 2d 6a 6f 62 73 20 28 63 6f 6e 66 69 67 2d 6c  t-jobs (config-l
a9d0: 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67 64 61 74  ookup *configdat
a9e0: 2a 20 22 73 65 74 75 70 22 20 22 6d 61 78 5f 63  * "setup" "max_c
a9f0: 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f 62 73 22 29  oncurrent_jobs")
aa00: 29 0a 09 09 20 20 20 28 70 61 72 65 6e 74 2d 74  )...   (parent-t
aa10: 65 73 74 20 28 61 6e 64 20 28 6e 6f 74 20 28 6e  est (and (not (n
aa20: 75 6c 6c 3f 20 69 74 65 6d 73 29 29 28 65 71 75  ull? items))(equ
aa30: 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 22  al? item-path ""
aa40: 29 29 29 0a 09 09 20 20 20 28 73 69 6e 67 6c 65  )))...   (single
aa50: 2d 74 65 73 74 20 28 61 6e 64 20 28 6e 75 6c 6c  -test (and (null
aa60: 3f 20 69 74 65 6d 73 29 20 28 65 71 75 61 6c 3f  ? items) (equal?
aa70: 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29 29 29   item-path "")))
aa80: 0a 09 09 20 20 20 28 69 74 65 6d 2d 74 65 73 74  ...   (item-test
aa90: 20 20 20 28 6e 6f 74 20 28 65 71 75 61 6c 3f 20     (not (equal? 
aaa0: 69 74 65 6d 2d 70 61 74 68 20 22 22 29 29 29 0a  item-path ""))).
aab0: 09 09 20 20 20 3b 3b 20 6c 6f 6f 6b 20 74 68 72  ..   ;; look thr
aac0: 6f 75 67 68 20 61 6c 6c 20 74 68 65 20 69 74 65  ough all the ite
aad0: 6d 2d 70 61 74 74 73 20 69 66 20 64 65 66 69 6e  m-patts if defin
aae0: 65 64 2c 20 66 6f 72 6d 61 74 20 69 73 20 70 61  ed, format is pa
aaf0: 74 74 31 2c 70 61 74 74 32 2c 70 61 74 74 33 20  tt1,patt2,patt3 
ab00: 2e 2e 2e 20 77 69 6c 64 63 61 72 64 20 69 73 20  ... wildcard is 
ab10: 25 0a 09 09 20 20 20 28 69 74 65 6d 2d 6d 61 74  %...   (item-mat
ab20: 63 68 65 73 20 28 69 66 20 69 74 65 6d 2d 70 61  ches (if item-pa
ab30: 74 74 73 0a 09 09 09 09 20 20 20 20 20 28 6c 65  tts.....     (le
ab40: 74 20 28 28 72 65 73 20 23 66 29 29 0a 09 09 09  t ((res #f))....
ab50: 09 20 20 20 20 20 20 20 28 66 6f 72 2d 65 61 63  .       (for-eac
ab60: 68 20 0a 09 09 09 09 09 28 6c 61 6d 62 64 61 20  h ......(lambda 
ab70: 28 70 61 74 74 29 0a 09 09 09 09 09 20 20 28 69  (patt)......  (i
ab80: 66 20 28 73 74 72 69 6e 67 2d 6d 61 74 63 68 20  f (string-match 
ab90: 28 67 6c 6f 62 2d 3e 72 65 67 65 78 70 0a 09 09  (glob->regexp...
aba0: 09 09 09 09 09 20 20 20 20 20 28 73 74 72 69 6e  .....     (strin
abb0: 67 2d 74 72 61 6e 73 6c 61 74 65 20 70 61 74 74  g-translate patt
abc0: 20 22 25 22 20 22 2a 22 29 29 0a 09 09 09 09 09   "%" "*"))......
abd0: 09 09 20 20 20 20 69 74 65 6d 2d 70 61 74 68 29  ..    item-path)
abe0: 0a 09 09 09 09 09 20 20 20 20 20 20 28 73 65 74  ......      (set
abf0: 21 20 72 65 73 20 23 74 29 29 29 0a 09 09 09 09  ! res #t))).....
ac00: 09 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 69  .(string-split i
ac10: 74 65 6d 2d 70 61 74 74 73 20 22 2c 22 29 29 29  tem-patts ",")))
ac20: 0a 09 09 09 09 20 20 20 20 23 74 29 29 29 0a 09  .....    #t)))..
ac30: 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69        (debug:pri
ac40: 6e 74 20 33 20 22 6d 61 78 2d 63 6f 6e 63 75 72  nt 3 "max-concur
ac50: 72 65 6e 74 2d 6a 6f 62 73 3a 20 22 20 6d 61 78  rent-jobs: " max
ac60: 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73  -concurrent-jobs
ac70: 20 22 2c 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67 3a   ", num-running:
ac80: 20 22 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67 29 0a   " num-running).
ac90: 09 20 20 20 20 20 20 28 69 66 20 28 61 6e 64 20  .      (if (and 
aca0: 69 74 65 6d 2d 6d 61 74 63 68 65 73 20 28 72 75  item-matches (ru
acb0: 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65 2d  ns:can-run-more-
acc0: 74 65 73 74 73 20 64 62 29 29 0a 09 09 20 20 28  tests db))...  (
acd0: 62 65 67 69 6e 0a 09 09 20 20 20 20 28 6c 65 74  begin...    (let
ace0: 20 6c 6f 6f 70 32 20 28 28 74 73 20 28 64 62 3a   loop2 ((ts (db:
acf0: 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62  get-test-info db
ad00: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
ad10: 65 20 69 74 65 6d 2d 70 61 74 68 29 29 20 3b 3b  e item-path)) ;;
ad20: 20 23 66 29 0a 09 09 09 09 28 63 74 20 30 29 29   #f).....(ct 0))
ad30: 0a 09 09 20 20 20 20 20 20 28 69 66 20 28 61 6e  ...      (if (an
ad40: 64 20 28 6e 6f 74 20 74 73 29 0a 09 09 09 20 20  d (not ts)....  
ad50: 20 20 20 20 20 28 3c 20 63 74 20 31 30 29 29 0a       (< ct 10)).
ad60: 09 09 09 20 20 28 62 65 67 69 6e 0a 09 09 09 20  ...  (begin.... 
ad70: 20 20 20 28 72 65 67 69 73 74 65 72 2d 74 65 73     (register-tes
ad80: 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  t db run-id test
ad90: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  -name item-path)
ada0: 0a 09 09 09 20 20 20 20 3b 3b 20 57 68 79 20 64  ....    ;; Why d
adb0: 69 64 20 49 20 73 65 74 20 74 68 65 20 63 6f 6d  id I set the com
adc0: 6d 65 6e 74 20 68 65 72 65 3f 21 3f 20 50 4f 53  ment here?!? POS
add0: 53 49 42 4c 45 20 42 55 47 20 42 55 54 20 49 27  SIBLE BUG BUT I'
ade0: 4d 20 52 45 4d 4f 56 49 4e 47 20 49 54 20 46 4f  M REMOVING IT FO
adf0: 52 20 4e 4f 57 20 31 30 2f 32 33 2f 32 30 31 31  R NOW 10/23/2011
ae00: 0a 09 09 09 20 20 20 20 3b 3b 20 28 64 62 3a 74  ....    ;; (db:t
ae10: 65 73 74 2d 73 65 74 2d 63 6f 6d 6d 65 6e 74 20  est-set-comment 
ae20: 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e  db run-id test-n
ae30: 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 20 22 22  ame item-path ""
ae40: 29 0a 09 09 09 20 20 20 20 28 6c 6f 6f 70 32 20  )....    (loop2 
ae50: 28 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66  (db:get-test-inf
ae60: 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  o db run-id test
ae70: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  -name item-path)
ae80: 0a 09 09 09 09 20 20 20 28 2b 20 63 74 20 31 29  .....   (+ ct 1)
ae90: 29 29 0a 09 09 09 20 20 28 69 66 20 74 73 0a 09  ))....  (if ts..
aea0: 09 09 20 20 20 20 20 20 28 73 65 74 21 20 74 65  ..      (set! te
aeb0: 73 74 64 61 74 20 74 73 29 0a 09 09 09 20 20 20  stdat ts)....   
aec0: 20 20 20 28 62 65 67 69 6e 0a 09 09 09 09 28 64     (begin.....(d
aed0: 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41  ebug:print 0 "WA
aee0: 52 4e 49 4e 47 3a 20 43 6f 75 6c 64 6e 27 74 20  RNING: Couldn't 
aef0: 72 65 67 69 73 74 65 72 20 74 65 73 74 20 22 20  register test " 
af00: 74 65 73 74 2d 6e 61 6d 65 20 22 20 77 69 74 68  test-name " with
af10: 20 69 74 65 6d 20 70 61 74 68 20 22 20 69 74 65   item path " ite
af20: 6d 2d 70 61 74 68 20 22 2c 20 73 6b 69 70 70 69  m-path ", skippi
af30: 6e 67 22 29 0a 09 09 09 09 28 69 66 20 28 6e 6f  ng").....(if (no
af40: 74 20 28 6e 75 6c 6c 3f 20 74 61 6c 29 29 0a 09  t (null? tal))..
af50: 09 09 09 20 20 20 20 28 6c 6f 6f 70 20 28 63 61  ...    (loop (ca
af60: 72 20 74 61 6c 29 28 63 64 72 20 74 61 6c 29 29  r tal)(cdr tal))
af70: 29 29 29 29 29 0a 09 09 20 20 20 20 28 63 68 61  )))))...    (cha
af80: 6e 67 65 2d 64 69 72 65 63 74 6f 72 79 20 74 65  nge-directory te
af90: 73 74 2d 70 61 74 68 29 0a 09 09 20 20 20 20 3b  st-path)...    ;
afa0: 3b 20 74 68 69 73 20 62 6c 6f 63 6b 20 69 73 20  ; this block is 
afb0: 68 65 72 65 20 6f 6e 6c 79 20 74 6f 20 69 6e 66  here only to inf
afc0: 6f 72 6d 20 74 68 65 20 75 73 65 72 20 65 61 72  orm the user ear
afd0: 6c 79 20 6f 6e 0a 09 09 20 20 20 20 28 69 66 20  ly on...    (if 
afe0: 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 72 75  (file-exists? ru
aff0: 6e 63 6f 6e 66 69 67 66 29 0a 09 09 09 28 73 65  nconfigf)....(se
b000: 74 75 70 2d 65 6e 76 2d 64 65 66 61 75 6c 74 73  tup-env-defaults
b010: 20 64 62 20 72 75 6e 63 6f 6e 66 69 67 66 20 72   db runconfigf r
b020: 75 6e 2d 69 64 20 2a 61 6c 72 65 61 64 79 2d 73  un-id *already-s
b030: 65 65 6e 2d 72 75 6e 63 6f 6e 66 69 67 2d 69 6e  een-runconfig-in
b040: 66 6f 2a 29 0a 09 09 09 28 64 65 62 75 67 3a 70  fo*)....(debug:p
b050: 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e 47 3a  rint 0 "WARNING:
b060: 20 59 6f 75 20 64 6f 20 6e 6f 74 20 68 61 76 65   You do not have
b070: 20 61 20 72 75 6e 20 63 6f 6e 66 69 67 20 66 69   a run config fi
b080: 6c 65 3a 20 22 20 72 75 6e 63 6f 6e 66 69 67 66  le: " runconfigf
b090: 29 29 0a 09 09 20 20 20 20 28 64 65 62 75 67 3a  ))...    (debug:
b0a0: 70 72 69 6e 74 20 34 20 22 72 75 6e 2d 69 64 3a  print 4 "run-id:
b0b0: 20 22 20 72 75 6e 2d 69 64 20 22 20 74 65 73 74   " run-id " test
b0c0: 2d 6e 61 6d 65 3a 20 22 20 74 65 73 74 2d 6e 61  -name: " test-na
b0d0: 6d 65 20 22 20 69 74 65 6d 2d 70 61 74 68 3a 20  me " item-path: 
b0e0: 22 20 69 74 65 6d 2d 70 61 74 68 20 22 20 74 65  " item-path " te
b0f0: 73 74 64 61 74 3a 20 22 20 28 74 65 73 74 3a 67  stdat: " (test:g
b100: 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61  et-status testda
b110: 74 29 20 22 20 74 65 73 74 2d 73 74 61 74 65 3a  t) " test-state:
b120: 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61   " (test:get-sta
b130: 74 65 20 74 65 73 74 64 61 74 29 29 0a 09 09 20  te testdat))... 
b140: 20 20 20 28 63 61 73 65 20 28 69 66 20 66 6f 72     (case (if for
b150: 63 65 20 3b 3b 20 28 61 72 67 73 3a 67 65 74 2d  ce ;; (args:get-
b160: 61 72 67 20 22 2d 66 6f 72 63 65 22 29 0a 09 09  arg "-force")...
b170: 09 20 20 20 20 20 20 27 4e 4f 54 5f 53 54 41 52  .      'NOT_STAR
b180: 54 45 44 0a 09 09 09 20 20 20 20 20 20 28 69 66  TED....      (if
b190: 20 74 65 73 74 64 61 74 0a 09 09 09 09 20 20 28   testdat.....  (
b1a0: 73 74 72 69 6e 67 2d 3e 73 79 6d 62 6f 6c 20 28  string->symbol (
b1b0: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74  test:get-state t
b1c0: 65 73 74 64 61 74 29 29 0a 09 09 09 09 20 20 27  estdat)).....  '
b1d0: 66 61 69 6c 65 64 2d 74 6f 2d 69 6e 73 65 72 74  failed-to-insert
b1e0: 29 29 0a 09 09 20 20 20 20 20 20 28 28 66 61 69  ))...      ((fai
b1f0: 6c 65 64 2d 74 6f 2d 69 6e 73 65 72 74 29 0a 09  led-to-insert)..
b200: 09 20 20 20 20 20 20 20 28 64 65 62 75 67 3a 70  .       (debug:p
b210: 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 46  rint 0 "ERROR: F
b220: 61 69 6c 65 64 20 74 6f 20 69 6e 73 65 72 74 20  ailed to insert 
b230: 74 68 65 20 72 65 63 6f 72 64 20 69 6e 74 6f 20  the record into 
b240: 74 68 65 20 64 62 22 29 29 0a 09 09 20 20 20 20  the db"))...    
b250: 20 20 28 28 4e 4f 54 5f 53 54 41 52 54 45 44 20    ((NOT_STARTED 
b260: 43 4f 4d 50 4c 45 54 45 44 29 0a 09 09 20 20 20  COMPLETED)...   
b270: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
b280: 20 36 20 22 47 6f 74 20 68 65 72 65 2c 20 22 20   6 "Got here, " 
b290: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20  (test:get-state 
b2a0: 74 65 73 74 64 61 74 29 29 0a 09 09 20 20 20 20  testdat))...    
b2b0: 20 20 20 28 6c 65 74 20 28 28 72 75 6e 66 6c 61     (let ((runfla
b2c0: 67 20 23 66 29 29 0a 09 09 09 20 28 63 6f 6e 64  g #f)).... (cond
b2d0: 0a 09 09 09 20 20 3b 3b 20 69 2e 65 2e 20 74 68  ....  ;; i.e. th
b2e0: 69 73 20 69 73 20 74 68 65 20 70 61 72 65 6e 74  is is the parent
b2f0: 20 74 65 73 74 20 74 6f 20 61 20 73 75 69 74 65   test to a suite
b300: 20 6f 66 20 69 74 65 6d 73 2c 20 6e 65 76 65 72   of items, never
b310: 20 22 72 75 6e 22 20 69 74 0a 09 09 09 20 20 28   "run" it....  (
b320: 70 61 72 65 6e 74 2d 74 65 73 74 0a 09 09 09 20  parent-test.... 
b330: 20 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20    (set! runflag 
b340: 23 66 29 29 0a 09 09 09 20 20 3b 3b 20 2d 66 6f  #f))....  ;; -fo
b350: 72 63 65 2c 20 72 75 6e 20 6e 6f 20 6d 61 74 74  rce, run no matt
b360: 65 72 20 77 68 61 74 0a 09 09 09 20 20 28 66 6f  er what....  (fo
b370: 72 63 65 20 28 73 65 74 21 20 72 75 6e 66 6c 61  rce (set! runfla
b380: 67 20 23 74 29 29 0a 09 09 09 20 20 3b 3b 20 4e  g #t))....  ;; N
b390: 4f 54 5f 53 54 41 52 54 45 44 2c 20 72 75 6e 20  OT_STARTED, run 
b3a0: 6e 6f 20 6d 61 74 74 65 72 20 77 68 61 74 0a 09  no matter what..
b3b0: 09 09 20 20 28 28 65 71 75 61 6c 3f 20 28 74 65  ..  ((equal? (te
b3c0: 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73  st:get-state tes
b3d0: 74 64 61 74 29 20 22 4e 4f 54 5f 53 54 41 52 54  tdat) "NOT_START
b3e0: 45 44 22 29 28 73 65 74 21 20 72 75 6e 66 6c 61  ED")(set! runfla
b3f0: 67 20 23 74 29 29 0a 09 09 09 20 20 3b 3b 20 6e  g #t))....  ;; n
b400: 6f 74 20 2d 72 65 72 75 6e 20 61 6e 64 20 50 41  ot -rerun and PA
b410: 53 53 2c 20 57 41 52 4e 20 6f 72 20 43 48 45 43  SS, WARN or CHEC
b420: 4b 2c 20 64 6f 20 6e 6f 20 72 75 6e 0a 09 09 09  K, do no run....
b430: 20 20 28 28 61 6e 64 20 28 6f 72 20 28 6e 6f 74    ((and (or (not
b440: 20 72 65 72 75 6e 29 0a 09 09 09 09 20 20 20 20   rerun).....    
b450: 6b 65 65 70 67 6f 69 6e 67 29 0a 09 09 09 09 28  keepgoing).....(
b460: 6d 65 6d 62 65 72 20 28 74 65 73 74 3a 67 65 74  member (test:get
b470: 2d 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29  -status testdat)
b480: 20 27 28 22 50 41 53 53 22 20 22 57 41 52 4e 22   '("PASS" "WARN"
b490: 20 22 43 48 45 43 4b 22 29 29 29 0a 09 09 09 20   "CHECK"))).... 
b4a0: 20 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20    (set! runflag 
b4b0: 23 66 29 29 0a 09 09 09 20 20 3b 3b 20 2d 72 65  #f))....  ;; -re
b4c0: 72 75 6e 20 61 6e 64 20 73 74 61 74 75 73 20 69  run and status i
b4d0: 73 20 6f 6e 65 20 6f 66 20 74 68 65 20 73 70 65  s one of the spe
b4e0: 63 69 66 65 64 2c 20 72 75 6e 20 69 74 0a 09 09  cifed, run it...
b4f0: 09 20 20 28 28 61 6e 64 20 72 65 72 75 6e 0a 09  .  ((and rerun..
b500: 09 09 09 28 6c 65 74 20 28 28 72 65 72 75 6e 6c  ...(let ((rerunl
b510: 73 74 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74  st (string-split
b520: 20 72 65 72 75 6e 20 22 2c 22 29 29 29 20 3b 3b   rerun ","))) ;;
b530: 20 46 41 49 4c 2c 0a 09 09 09 09 20 20 28 6d 65   FAIL,.....  (me
b540: 6d 62 65 72 20 28 74 65 73 74 3a 67 65 74 2d 73  mber (test:get-s
b550: 74 61 74 75 73 20 74 65 73 74 64 61 74 29 20 72  tatus testdat) r
b560: 65 72 75 6e 6c 73 74 29 29 29 0a 09 09 09 20 20  erunlst)))....  
b570: 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23   (set! runflag #
b580: 74 29 29 0a 09 09 09 20 20 3b 3b 20 2d 6b 65 65  t))....  ;; -kee
b590: 70 67 6f 69 6e 67 2c 20 64 6f 20 6e 6f 74 20 72  pgoing, do not r
b5a0: 65 72 75 6e 20 46 41 49 4c 0a 09 09 09 20 20 28  erun FAIL....  (
b5b0: 28 61 6e 64 20 6b 65 65 70 67 6f 69 6e 67 0a 09  (and keepgoing..
b5c0: 09 09 09 28 6d 65 6d 62 65 72 20 28 74 65 73 74  ...(member (test
b5d0: 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74  :get-status test
b5e0: 64 61 74 29 20 27 28 22 46 41 49 4c 22 29 29 29  dat) '("FAIL")))
b5f0: 0a 09 09 09 20 20 20 28 73 65 74 21 20 72 75 6e  ....   (set! run
b600: 66 6c 61 67 20 23 66 29 29 0a 09 09 09 20 20 28  flag #f))....  (
b610: 28 61 6e 64 20 28 6e 6f 74 20 72 65 72 75 6e 29  (and (not rerun)
b620: 0a 09 09 09 09 28 6d 65 6d 62 65 72 20 28 74 65  .....(member (te
b630: 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65  st:get-status te
b640: 73 74 64 61 74 29 20 27 28 22 46 41 49 4c 22 20  stdat) '("FAIL" 
b650: 22 6e 2f 61 22 29 29 29 0a 09 09 09 20 20 20 28  "n/a")))....   (
b660: 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 74 29  set! runflag #t)
b670: 29 0a 09 09 09 20 20 28 65 6c 73 65 20 28 73 65  )....  (else (se
b680: 74 21 20 72 75 6e 66 6c 61 67 20 23 66 29 29 29  t! runflag #f)))
b690: 0a 09 09 09 20 28 64 65 62 75 67 3a 70 72 69 6e  .... (debug:prin
b6a0: 74 20 36 20 22 52 55 4e 4e 49 4e 47 20 3d 3e 20  t 6 "RUNNING => 
b6b0: 72 75 6e 66 6c 61 67 3a 20 22 20 72 75 6e 66 6c  runflag: " runfl
b6c0: 61 67 20 22 20 53 54 41 54 45 3a 20 22 20 28 74  ag " STATE: " (t
b6d0: 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65  est:get-state te
b6e0: 73 74 64 61 74 29 20 22 20 53 54 41 54 55 53 3a  stdat) " STATUS:
b6f0: 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61   " (test:get-sta
b700: 74 75 73 20 74 65 73 74 64 61 74 29 29 0a 09 09  tus testdat))...
b710: 09 20 28 69 66 20 28 6e 6f 74 20 72 75 6e 66 6c  . (if (not runfl
b720: 61 67 29 0a 09 09 09 20 20 20 20 20 28 69 66 20  ag)....     (if 
b730: 28 6e 6f 74 20 70 61 72 65 6e 74 2d 74 65 73 74  (not parent-test
b740: 29 0a 09 09 09 09 20 28 64 65 62 75 67 3a 70 72  )..... (debug:pr
b750: 69 6e 74 20 31 20 22 4e 4f 54 45 3a 20 4e 6f 74  int 1 "NOTE: Not
b760: 20 73 74 61 72 74 69 6e 67 20 74 65 73 74 20 22   starting test "
b770: 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20 22   new-test-name "
b780: 20 61 73 20 69 74 20 69 73 20 73 74 61 74 65 20   as it is state 
b790: 5c 22 43 4f 4d 50 4c 45 54 45 44 5c 22 20 61 6e  \"COMPLETED\" an
b7a0: 64 20 73 74 61 74 75 73 20 5c 22 22 20 28 74 65  d status \"" (te
b7b0: 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65  st:get-status te
b7c0: 73 74 64 61 74 29 20 22 5c 22 2c 20 75 73 65 20  stdat) "\", use 
b7d0: 2d 66 6f 72 63 65 20 74 6f 20 6f 76 65 72 72 69  -force to overri
b7e0: 64 65 22 29 29 0a 09 09 09 20 20 20 20 20 28 6c  de"))....     (l
b7f0: 65 74 2a 20 28 28 67 65 74 2d 70 72 65 72 65 71  et* ((get-prereq
b800: 73 2d 63 6d 64 20 28 6c 61 6d 62 64 61 20 28 29  s-cmd (lambda ()
b810: 0a 09 09 09 09 09 09 20 20 20 20 20 20 20 28 64  .......       (d
b820: 62 2d 67 65 74 2d 70 72 65 72 65 71 73 2d 6e 6f  b-get-prereqs-no
b830: 74 2d 6d 65 74 20 64 62 20 72 75 6e 2d 69 64 20  t-met db run-id 
b840: 77 61 69 74 6f 6e 29 29 29 20 3b 3b 20 63 68 65  waiton))) ;; che
b850: 63 6b 20 62 65 66 6f 72 65 20 72 75 6e 6e 69 6e  ck before runnin
b860: 67 20 2e 2e 2e 2e 0a 09 09 09 09 20 20 20 20 28  g .........    (
b870: 6c 61 75 6e 63 68 2d 63 6d 64 20 20 20 20 20 20  launch-cmd      
b880: 28 6c 61 6d 62 64 61 20 28 29 0a 09 09 09 09 09  (lambda ()......
b890: 09 20 20 20 20 20 20 20 28 6c 61 75 6e 63 68 2d  .       (launch-
b8a0: 74 65 73 74 20 64 62 20 72 75 6e 2d 69 64 20 72  test db run-id r
b8b0: 75 6e 6e 61 6d 65 20 74 65 73 74 2d 63 6f 6e 66  unname test-conf
b8c0: 20 6b 65 79 76 61 6c 6c 73 74 20 74 65 73 74 2d   keyvallst test-
b8d0: 6e 61 6d 65 20 74 65 73 74 2d 70 61 74 68 20 69  name test-path i
b8e0: 74 65 6d 64 61 74 29 29 29 0a 09 09 09 09 20 20  temdat))).....  
b8f0: 20 20 28 74 65 73 74 72 75 6e 64 61 74 20 20 20    (testrundat   
b900: 20 20 20 28 6c 69 73 74 20 67 65 74 2d 70 72 65     (list get-pre
b910: 72 65 71 73 2d 63 6d 64 20 6c 61 75 6e 63 68 2d  reqs-cmd launch-
b920: 63 6d 64 29 29 29 0a 09 09 09 20 20 20 20 20 20  cmd)))....      
b930: 20 28 69 66 20 28 6f 72 20 66 6f 72 63 65 0a 09   (if (or force..
b940: 09 09 09 20 20 20 20 20 20 20 28 6c 65 74 20 28  ...       (let (
b950: 28 70 72 65 71 73 2d 6e 6f 74 2d 79 65 74 2d 6d  (preqs-not-yet-m
b960: 65 74 20 28 28 63 61 72 20 74 65 73 74 72 75 6e  et ((car testrun
b970: 64 61 74 29 29 29 29 0a 09 09 09 09 09 20 28 64  dat))))...... (d
b980: 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 50 72  ebug:print 2 "Pr
b990: 65 71 72 65 71 75 65 73 69 74 65 73 20 66 6f 72  eqrequesites for
b9a0: 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 3a 20   " test-name ": 
b9b0: 22 20 70 72 65 71 73 2d 6e 6f 74 2d 79 65 74 2d  " preqs-not-yet-
b9c0: 6d 65 74 29 0a 09 09 09 09 09 20 28 6e 75 6c 6c  met)...... (null
b9d0: 3f 20 70 72 65 71 73 2d 6e 6f 74 2d 79 65 74 2d  ? preqs-not-yet-
b9e0: 6d 65 74 29 29 29 20 3b 3b 20 61 72 65 20 74 68  met))) ;; are th
b9f0: 65 72 65 20 61 6e 79 20 74 65 73 74 73 20 74 68  ere any tests th
ba00: 61 74 20 6d 75 73 74 20 62 65 20 72 75 6e 20 62  at must be run b
ba10: 65 66 6f 72 65 20 74 68 69 73 20 6f 6e 65 2e 2e  efore this one..
ba20: 2e 0a 09 09 09 09 20 20 20 28 69 66 20 28 6e 6f  ......   (if (no
ba30: 74 20 28 28 63 61 64 72 20 74 65 73 74 72 75 6e  t ((cadr testrun
ba40: 64 61 74 29 29 29 20 3b 3b 20 74 68 69 73 20 69  dat))) ;; this i
ba50: 73 20 74 68 65 20 6c 69 6e 65 20 74 68 61 74 20  s the line that 
ba60: 6c 61 75 6e 63 68 65 73 20 74 68 65 20 74 65 73  launches the tes
ba70: 74 20 74 6f 20 74 68 65 20 72 65 6d 6f 74 65 20  t to the remote 
ba80: 68 6f 73 74 0a 09 09 09 09 20 20 20 20 20 20 20  host.....       
ba90: 28 62 65 67 69 6e 0a 09 09 09 09 09 20 28 70 72  (begin...... (pr
baa0: 69 6e 74 20 22 45 52 52 4f 52 3a 20 46 61 69 6c  int "ERROR: Fail
bab0: 65 64 20 74 6f 20 6c 61 75 6e 63 68 20 74 68 65  ed to launch the
bac0: 20 74 65 73 74 2e 20 45 78 69 74 69 6e 67 20 61   test. Exiting a
bad0: 73 20 73 6f 6f 6e 20 61 73 20 70 6f 73 73 69 62  s soon as possib
bae0: 6c 65 22 29 0a 09 09 09 09 09 20 28 73 65 74 21  le")...... (set!
baf0: 20 2a 67 6c 6f 62 61 6c 65 78 69 74 73 74 61 74   *globalexitstat
bb00: 75 73 2a 20 31 29 20 3b 3b 20 0a 09 09 09 09 09  us* 1) ;; ......
bb10: 20 28 70 72 6f 63 65 73 73 2d 73 69 67 6e 61 6c   (process-signal
bb20: 20 28 63 75 72 72 65 6e 74 2d 70 72 6f 63 65 73   (current-proces
bb30: 73 2d 69 64 29 20 73 69 67 6e 61 6c 2f 6b 69 6c  s-id) signal/kil
bb40: 6c 29 0a 09 09 09 09 09 20 3b 28 65 78 69 74 20  l)...... ;(exit 
bb50: 31 29 0a 09 09 09 09 09 20 29 29 0a 09 09 09 09  1)...... )).....
bb60: 20 20 20 28 69 66 20 28 6e 6f 74 20 6b 65 65 70     (if (not keep
bb70: 67 6f 69 6e 67 29 0a 09 09 09 09 20 20 20 20 20  going).....     
bb80: 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65    (hash-table-se
bb90: 74 21 20 2a 77 61 69 74 69 6e 67 2d 71 75 65 75  t! *waiting-queu
bba0: 65 2a 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65  e* new-test-name
bbb0: 20 74 65 73 74 72 75 6e 64 61 74 29 29 29 29 29   testrundat)))))
bbc0: 29 29 0a 09 09 20 20 20 20 20 20 28 28 4b 49 4c  ))...      ((KIL
bbd0: 4c 45 44 29 20 0a 09 09 20 20 20 20 20 20 20 28  LED) ...       (
bbe0: 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 4e  debug:print 1 "N
bbf0: 4f 54 45 3a 20 22 20 6e 65 77 2d 74 65 73 74 2d  OTE: " new-test-
bc00: 6e 61 6d 65 20 22 20 69 73 20 61 6c 72 65 61 64  name " is alread
bc10: 79 20 72 75 6e 6e 69 6e 67 20 6f 72 20 77 61 73  y running or was
bc20: 20 65 78 70 6c 69 63 74 6c 79 20 6b 69 6c 6c 65   explictly kille
bc30: 64 2c 20 75 73 65 20 2d 66 6f 72 63 65 20 74 6f  d, use -force to
bc40: 20 6c 61 75 6e 63 68 20 69 74 2e 22 29 29 0a 09   launch it."))..
bc50: 09 20 20 20 20 20 20 28 28 4c 41 55 4e 43 48 45  .      ((LAUNCHE
bc60: 44 20 52 45 4d 4f 54 45 48 4f 53 54 53 54 41 52  D REMOTEHOSTSTAR
bc70: 54 20 52 55 4e 4e 49 4e 47 29 20 20 0a 09 09 20  T RUNNING)  ... 
bc80: 20 20 20 20 20 20 28 69 66 20 28 3e 20 28 2d 20        (if (> (- 
bc90: 28 63 75 72 72 65 6e 74 2d 73 65 63 6f 6e 64 73  (current-seconds
bca0: 29 28 2b 20 28 64 62 3a 74 65 73 74 2d 67 65 74  )(+ (db:test-get
bcb0: 2d 65 76 65 6e 74 5f 74 69 6d 65 20 74 65 73 74  -event_time test
bcc0: 64 61 74 29 0a 09 09 09 09 09 09 20 20 20 20 20  dat).......     
bcd0: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 72 75 6e  (db:test-get-run
bce0: 5f 64 75 72 61 74 69 6f 6e 20 74 65 73 74 64 61  _duration testda
bcf0: 74 29 29 29 0a 09 09 09 20 20 20 20 20 20 31 30  t)))....      10
bd00: 30 29 20 3b 3b 20 69 2e 65 2e 20 6e 6f 20 75 70  0) ;; i.e. no up
bd10: 64 61 74 65 20 66 6f 72 20 6d 6f 72 65 20 74 68  date for more th
bd20: 61 6e 20 31 30 30 20 73 65 63 6f 6e 64 73 0a 09  an 100 seconds..
bd30: 09 09 20 20 20 28 62 65 67 69 6e 0a 09 09 09 20  ..   (begin.... 
bd40: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
bd50: 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 54 65 73   0 "WARNING: Tes
bd60: 74 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20  t " test-name " 
bd70: 61 70 70 65 61 72 73 20 74 6f 20 62 65 20 64 65  appears to be de
bd80: 61 64 2e 20 46 6f 72 63 69 6e 67 20 69 74 20 74  ad. Forcing it t
bd90: 6f 20 73 74 61 74 65 20 49 4e 43 4f 4d 50 4c 45  o state INCOMPLE
bda0: 54 45 20 61 6e 64 20 73 74 61 74 75 73 20 53 54  TE and status ST
bdb0: 55 43 4b 2f 44 45 41 44 22 29 0a 09 09 09 20 20  UCK/DEAD")....  
bdc0: 20 20 20 28 74 65 73 74 2d 73 65 74 2d 73 74 61     (test-set-sta
bdd0: 74 75 73 21 20 64 62 20 72 75 6e 2d 69 64 20 74  tus! db run-id t
bde0: 65 73 74 2d 6e 61 6d 65 20 22 49 4e 43 4f 4d 50  est-name "INCOMP
bdf0: 4c 45 54 45 22 20 22 53 54 55 43 4b 2f 44 45 41  LETE" "STUCK/DEA
be00: 44 22 20 69 74 65 6d 64 61 74 20 22 54 65 73 74  D" itemdat "Test
be10: 20 69 73 20 73 74 75 63 6b 20 6f 72 20 64 65 61   is stuck or dea
be20: 64 22 20 23 66 29 29 0a 09 09 09 20 20 20 28 64  d" #f))....   (d
be30: 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 4e 4f  ebug:print 2 "NO
be40: 54 45 3a 20 22 20 74 65 73 74 2d 6e 61 6d 65 20  TE: " test-name 
be50: 22 20 69 73 20 61 6c 72 65 61 64 79 20 72 75 6e  " is already run
be60: 6e 69 6e 67 22 29 29 29 0a 09 09 20 20 20 20 20  ning")))...     
be70: 20 28 65 6c 73 65 20 20 20 20 20 20 20 28 64 65   (else       (de
be80: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52  bug:print 0 "ERR
be90: 4f 52 3a 20 46 61 69 6c 65 64 20 74 6f 20 6c 61  OR: Failed to la
bea0: 75 6e 63 68 20 74 65 73 74 20 22 20 6e 65 77 2d  unch test " new-
beb0: 74 65 73 74 2d 6e 61 6d 65 20 22 2e 20 55 6e 72  test-name ". Unr
bec0: 65 63 6f 67 6e 69 73 65 64 20 73 74 61 74 65 20  ecognised state 
bed0: 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74  " (test:get-stat
bee0: 65 20 74 65 73 74 64 61 74 29 29 29 29 29 29 0a  e testdat)))))).
bef0: 09 20 20 20 20 20 20 28 69 66 20 28 6e 6f 74 20  .      (if (not 
bf00: 28 6e 75 6c 6c 3f 20 74 61 6c 29 29 0a 09 09 20  (null? tal))... 
bf10: 20 28 6c 6f 6f 70 20 28 63 61 72 20 74 61 6c 29   (loop (car tal)
bf20: 28 63 64 72 20 74 61 6c 29 29 29 29 29 29 29 29  (cdr tal))))))))
bf30: 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  )..;;===========
bf40: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
bf50: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
bf60: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
bf70: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 45  ===========.;; E
bf80: 4e 44 20 4f 46 20 4e 45 57 20 53 54 55 46 46 0a  ND OF NEW STUFF.
bf90: 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ;;==============
bfa0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
bfb0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
bfc0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
bfd0: 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 28 64 65 66 69 6e  ========..(defin
bfe0: 65 20 28 67 65 74 2d 64 69 72 2d 75 70 2d 6e 20  e (get-dir-up-n 
bff0: 64 69 72 20 2e 20 70 61 72 61 6d 73 29 20 0a 20  dir . params) . 
c000: 20 28 6c 65 74 20 28 28 64 70 61 72 74 73 20 20   (let ((dparts  
c010: 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 64 69  (string-split di
c020: 72 20 22 2f 22 29 29 0a 09 28 63 6f 75 6e 74 20  r "/"))..(count 
c030: 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 70 61 72    (if (null? par
c040: 61 6d 73 29 20 31 20 28 63 61 72 20 70 61 72 61  ams) 1 (car para
c050: 6d 73 29 29 29 29 0a 20 20 20 20 28 63 6f 6e 63  ms)))).    (conc
c060: 20 22 2f 22 20 28 73 74 72 69 6e 67 2d 69 6e 74   "/" (string-int
c070: 65 72 73 70 65 72 73 65 20 0a 09 20 20 20 20 20  ersperse ..     
c080: 20 20 28 74 61 6b 65 20 64 70 61 72 74 73 20 28    (take dparts (
c090: 2d 20 28 6c 65 6e 67 74 68 20 64 70 61 72 74 73  - (length dparts
c0a0: 29 20 63 6f 75 6e 74 29 29 0a 09 20 20 20 20 20  ) count))..     
c0b0: 20 20 22 2f 22 29 29 29 29 0a 3b 3b 20 52 65 6d    "/")))).;; Rem
c0c0: 6f 76 65 20 72 75 6e 73 0a 3b 3b 20 66 69 65 6c  ove runs.;; fiel
c0d0: 64 73 20 61 72 65 20 70 61 73 73 69 6e 67 20 69  ds are passing i
c0e0: 6e 20 74 68 72 6f 75 67 68 20 0a 28 64 65 66 69  n through .(defi
c0f0: 6e 65 20 28 72 75 6e 73 3a 72 65 6d 6f 76 65 2d  ne (runs:remove-
c100: 72 75 6e 73 20 64 62 20 72 75 6e 6e 61 6d 65 70  runs db runnamep
c110: 61 74 74 20 74 65 73 74 70 61 74 74 20 69 74 65  att testpatt ite
c120: 6d 70 61 74 74 29 0a 20 20 28 6c 65 74 2a 20 28  mpatt).  (let* (
c130: 28 6b 65 79 73 20 20 20 20 20 20 20 20 28 64 62  (keys        (db
c140: 2d 67 65 74 2d 6b 65 79 73 20 64 62 29 29 0a 09  -get-keys db))..
c150: 20 28 72 75 6e 64 61 74 20 20 20 20 20 20 28 72   (rundat      (r
c160: 75 6e 73 3a 67 65 74 2d 72 75 6e 73 2d 62 79 2d  uns:get-runs-by-
c170: 70 61 74 74 20 64 62 20 6b 65 79 73 20 72 75 6e  patt db keys run
c180: 6e 61 6d 65 70 61 74 74 29 29 0a 09 20 28 68 65  namepatt)).. (he
c190: 61 64 65 72 20 20 20 20 20 20 28 76 65 63 74 6f  ader      (vecto
c1a0: 72 2d 72 65 66 20 72 75 6e 64 61 74 20 30 29 29  r-ref rundat 0))
c1b0: 0a 09 20 28 72 75 6e 73 20 20 20 20 20 20 20 20  .. (runs        
c1c0: 28 76 65 63 74 6f 72 2d 72 65 66 20 72 75 6e 64  (vector-ref rund
c1d0: 61 74 20 31 29 29 29 0a 20 20 20 20 28 64 65 62  at 1))).    (deb
c1e0: 75 67 3a 70 72 69 6e 74 20 31 20 22 48 65 61 64  ug:print 1 "Head
c1f0: 65 72 3a 20 22 20 68 65 61 64 65 72 29 0a 20 20  er: " header).  
c200: 20 20 28 66 6f 72 2d 65 61 63 68 0a 20 20 20 20    (for-each.    
c210: 20 28 6c 61 6d 62 64 61 20 28 72 75 6e 29 0a 20   (lambda (run). 
c220: 20 20 20 20 20 20 28 6c 65 74 20 28 28 72 75 6e        (let ((run
c230: 6b 65 79 20 28 73 74 72 69 6e 67 2d 69 6e 74 65  key (string-inte
c240: 72 73 70 65 72 73 65 20 28 6d 61 70 20 28 6c 61  rsperse (map (la
c250: 6d 62 64 61 20 28 6b 29 0a 09 09 09 09 09 09 28  mbda (k).......(
c260: 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d  db:get-value-by-
c270: 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65  header run heade
c280: 72 20 28 76 65 63 74 6f 72 2d 72 65 66 20 6b 20  r (vector-ref k 
c290: 30 29 29 29 20 6b 65 79 73 29 20 22 2f 22 29 29  0))) keys) "/"))
c2a0: 0a 09 20 20 20 20 20 28 64 69 72 73 2d 74 6f 2d  ..     (dirs-to-
c2b0: 72 65 6d 6f 76 65 20 28 6d 61 6b 65 2d 68 61 73  remove (make-has
c2c0: 68 2d 74 61 62 6c 65 29 29 29 0a 09 20 28 6c 65  h-table))).. (le
c2d0: 74 2a 20 28 28 72 75 6e 2d 69 64 20 28 64 62 3a  t* ((run-id (db:
c2e0: 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61  get-value-by-hea
c2f0: 64 65 72 20 72 75 6e 20 68 65 61 64 65 72 20 22  der run header "
c300: 69 64 22 29 20 29 0a 09 09 28 74 65 73 74 73 20  id") )...(tests 
c310: 20 28 64 62 2d 67 65 74 2d 74 65 73 74 73 2d 66   (db-get-tests-f
c320: 6f 72 2d 72 75 6e 20 64 62 20 28 64 62 3a 67 65  or-run db (db:ge
c330: 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65  t-value-by-heade
c340: 72 20 72 75 6e 20 68 65 61 64 65 72 20 22 69 64  r run header "id
c350: 22 29 20 74 65 73 74 70 61 74 74 20 69 74 65 6d  ") testpatt item
c360: 70 61 74 74 20 27 28 29 20 27 28 29 29 29 0a 09  patt '() '()))..
c370: 09 28 6c 61 73 74 74 70 61 74 68 20 22 2f 64 6f  .(lasttpath "/do
c380: 65 73 2f 6e 6f 74 2f 65 78 69 73 74 2f 49 2f 68  es/not/exist/I/h
c390: 6f 70 65 22 29 29 0a 0a 09 20 20 20 28 69 66 20  ope"))...   (if 
c3a0: 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 65 73 74  (not (null? test
c3b0: 73 29 29 0a 09 20 20 20 20 20 20 20 28 62 65 67  s))..       (beg
c3c0: 69 6e 0a 09 09 20 28 64 65 62 75 67 3a 70 72 69  in... (debug:pri
c3d0: 6e 74 20 31 20 22 52 65 6d 6f 76 69 6e 67 20 74  nt 1 "Removing t
c3e0: 65 73 74 73 20 66 6f 72 20 72 75 6e 3a 20 22 20  ests for run: " 
c3f0: 72 75 6e 6b 65 79 20 22 20 22 20 28 64 62 3a 67  runkey " " (db:g
c400: 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64  et-value-by-head
c410: 65 72 20 72 75 6e 20 68 65 61 64 65 72 20 22 72  er run header "r
c420: 75 6e 6e 61 6d 65 22 29 29 0a 09 09 20 28 66 6f  unname"))... (fo
c430: 72 2d 65 61 63 68 0a 09 09 20 20 28 6c 61 6d 62  r-each...  (lamb
c440: 64 61 20 28 74 65 73 74 29 0a 09 09 20 20 20 20  da (test)...    
c450: 28 6c 65 74 2a 20 28 28 69 74 65 6d 2d 70 61 74  (let* ((item-pat
c460: 68 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69  h (db:test-get-i
c470: 74 65 6d 2d 70 61 74 68 20 74 65 73 74 29 29 0a  tem-path test)).
c480: 09 09 09 20 20 20 28 74 65 73 74 2d 6e 61 6d 65  ...   (test-name
c490: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 74 65   (db:test-get-te
c4a0: 73 74 6e 61 6d 65 20 74 65 73 74 29 29 0a 09 09  stname test))...
c4b0: 09 20 20 20 28 72 75 6e 2d 64 69 72 20 20 20 28  .   (run-dir   (
c4c0: 64 62 3a 74 65 73 74 2d 67 65 74 2d 72 75 6e 64  db:test-get-rund
c4d0: 69 72 20 74 65 73 74 29 29 29 0a 09 09 20 20 20  ir test)))...   
c4e0: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
c4f0: 31 20 22 20 20 22 20 28 64 62 3a 74 65 73 74 2d  1 "  " (db:test-
c500: 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73  get-testname tes
c510: 74 29 20 22 20 69 64 3a 20 22 20 28 64 62 3a 74  t) " id: " (db:t
c520: 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74 29  est-get-id test)
c530: 20 22 20 22 20 69 74 65 6d 2d 70 61 74 68 29 0a   " " item-path).
c540: 09 09 20 20 20 20 20 20 28 64 62 3a 64 65 6c 65  ..      (db:dele
c550: 74 65 2d 74 65 73 74 2d 72 65 63 6f 72 64 73 20  te-test-records 
c560: 64 62 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  db (db:test-get-
c570: 69 64 20 74 65 73 74 29 29 0a 09 09 20 20 20 20  id test))...    
c580: 20 20 28 69 66 20 28 3e 20 28 73 74 72 69 6e 67    (if (> (string
c590: 2d 6c 65 6e 67 74 68 20 72 75 6e 2d 64 69 72 29  -length run-dir)
c5a0: 20 35 29 20 3b 3b 20 62 61 64 20 68 65 75 72 69   5) ;; bad heuri
c5b0: 73 74 69 63 20 62 75 74 20 73 68 6f 75 6c 64 20  stic but should 
c5c0: 70 72 65 76 65 6e 74 20 2f 74 6d 70 20 2f 68 6f  prevent /tmp /ho
c5d0: 6d 65 20 65 74 63 2e 0a 09 09 09 20 20 28 6c 65  me etc.....  (le
c5e0: 74 20 28 28 66 75 6c 6c 70 61 74 68 20 72 75 6e  t ((fullpath run
c5f0: 2d 64 69 72 29 29 20 3b 3b 20 22 2f 22 20 28 64  -dir)) ;; "/" (d
c600: 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d  b:test-get-item-
c610: 70 61 74 68 20 74 65 73 74 29 29 29 29 0a 09 09  path test))))...
c620: 09 20 20 20 20 28 73 65 74 21 20 6c 61 73 74 74  .    (set! lastt
c630: 70 61 74 68 20 66 75 6c 6c 70 61 74 68 29 0a 09  path fullpath)..
c640: 09 09 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c  ..    (hash-tabl
c650: 65 2d 73 65 74 21 20 64 69 72 73 2d 74 6f 2d 72  e-set! dirs-to-r
c660: 65 6d 6f 76 65 20 66 75 6c 6c 70 61 74 68 20 23  emove fullpath #
c670: 74 29 0a 09 09 09 20 20 20 20 3b 3b 20 54 68 65  t)....    ;; The
c680: 20 66 6f 6c 6c 6f 77 69 6e 67 20 77 61 73 20 74   following was t
c690: 68 65 20 73 61 66 65 20 64 65 6c 65 74 65 20 63  he safe delete c
c6a0: 6f 64 65 20 62 75 74 20 69 74 20 77 61 73 20 6e  ode but it was n
c6b0: 6f 74 20 62 65 69 6e 67 20 65 78 65 63 74 75 74  ot being exectut
c6c0: 65 64 2e 0a 09 09 09 20 20 20 20 3b 3b 20 28 6c  ed.....    ;; (l
c6d0: 65 74 2a 20 28 28 64 69 72 73 2d 63 6f 75 6e 74  et* ((dirs-count
c6e0: 20 28 2b 20 31 20 28 6c 65 6e 67 74 68 20 6b 65   (+ 1 (length ke
c6f0: 79 73 29 28 6c 65 6e 67 74 68 20 28 73 74 72 69  ys)(length (stri
c700: 6e 67 2d 73 70 6c 69 74 20 69 74 65 6d 2d 70 61  ng-split item-pa
c710: 74 68 20 22 2f 22 29 29 29 29 0a 09 09 09 20 20  th "/"))))....  
c720: 20 20 3b 3b 20 20 20 20 20 20 20 20 28 64 69 72    ;;        (dir
c730: 2d 74 6f 2d 72 65 6d 20 28 67 65 74 2d 64 69 72  -to-rem (get-dir
c740: 2d 75 70 2d 6e 20 66 75 6c 6c 70 61 74 68 20 64  -up-n fullpath d
c750: 69 72 73 2d 63 6f 75 6e 74 29 29 0a 09 09 09 20  irs-count)).... 
c760: 20 20 20 3b 3b 20 20 20 20 20 20 20 20 28 72 65     ;;        (re
c770: 6d 61 69 6e 69 6e 67 64 20 28 73 74 72 69 6e 67  mainingd (string
c780: 2d 73 75 62 73 74 69 74 75 74 65 20 28 72 65 67  -substitute (reg
c790: 65 78 70 20 28 63 6f 6e 63 20 22 5e 22 20 64 69  exp (conc "^" di
c7a0: 72 2d 74 6f 2d 72 65 6d 20 22 2f 22 29 29 20 22  r-to-rem "/")) "
c7b0: 22 20 66 75 6c 6c 70 61 74 68 29 29 0a 09 09 09  " fullpath))....
c7c0: 20 20 20 20 3b 3b 20 20 20 20 20 20 20 20 28 63      ;;        (c
c7d0: 6d 64 20 28 63 6f 6e 63 20 22 63 64 20 22 20 64  md (conc "cd " d
c7e0: 69 72 2d 74 6f 2d 72 65 6d 20 22 3b 20 72 6d 64  ir-to-rem "; rmd
c7f0: 69 72 20 2d 70 20 22 20 72 65 6d 61 69 6e 69 6e  ir -p " remainin
c800: 67 64 20 29 29 29 0a 09 09 09 20 20 20 20 3b 3b  gd )))....    ;;
c810: 20 20 20 28 69 66 20 28 66 69 6c 65 2d 65 78 69     (if (file-exi
c820: 73 74 73 3f 20 66 75 6c 6c 70 61 74 68 29 0a 09  sts? fullpath)..
c830: 09 09 20 20 20 20 3b 3b 20 20 20 20 20 20 20 28  ..    ;;       (
c840: 62 65 67 69 6e 0a 09 09 09 20 20 20 20 3b 3b 20  begin....    ;; 
c850: 20 20 20 20 20 20 20 20 28 64 65 62 75 67 3a 70          (debug:p
c860: 72 69 6e 74 20 31 20 63 6d 64 29 0a 09 09 09 20  rint 1 cmd).... 
c870: 20 20 20 3b 3b 20 20 20 20 20 20 20 20 20 28 73     ;;         (s
c880: 79 73 74 65 6d 20 63 6d 64 29 29 29 0a 09 09 09  ystem cmd)))....
c890: 20 20 20 20 3b 3b 20 20 20 29 29 0a 09 09 09 20      ;;   )).... 
c8a0: 20 20 20 29 29 29 29 0a 09 09 20 20 20 20 74 65     ))))...    te
c8b0: 73 74 73 29 29 29 0a 0a 09 20 20 20 3b 3b 20 6c  sts)))...   ;; l
c8c0: 6f 6f 6b 20 74 68 6f 75 67 68 20 74 68 65 20 64  ook though the d
c8d0: 69 72 73 2d 74 6f 2d 72 65 6d 6f 76 65 20 66 6f  irs-to-remove fo
c8e0: 72 20 63 61 6e 64 69 64 61 74 65 73 20 66 6f 72  r candidates for
c8f0: 20 72 65 6d 6f 76 61 6c 2e 20 44 6f 20 74 68 69   removal. Do thi
c900: 73 20 61 66 74 65 72 20 64 65 6c 65 74 69 6e 67  s after deleting
c910: 20 74 68 65 20 72 65 63 6f 72 64 73 0a 09 20 20   the records..  
c920: 20 3b 3b 20 66 6f 72 20 65 61 63 68 20 74 65 73   ;; for each tes
c930: 74 20 69 6e 20 63 61 73 65 20 77 65 20 67 65 74  t in case we get
c940: 20 6b 69 6c 6c 65 64 2e 20 54 68 61 74 20 73 68   killed. That sh
c950: 6f 75 6c 64 20 6d 69 6e 69 6d 69 7a 65 20 74 68  ould minimize th
c960: 65 20 64 65 74 72 69 74 75 73 20 6c 65 66 74 20  e detritus left 
c970: 6f 6e 20 64 69 73 6b 0a 09 20 20 20 3b 3b 20 70  on disk..   ;; p
c980: 72 6f 63 65 73 73 20 74 68 65 20 64 69 72 73 20  rocess the dirs 
c990: 66 72 6f 6d 20 6c 6f 6e 67 65 73 74 20 73 74 72  from longest str
c9a0: 69 6e 67 20 6c 65 6e 67 74 68 20 74 6f 20 73 68  ing length to sh
c9b0: 6f 72 74 65 73 74 0a 09 20 20 20 28 66 6f 72 2d  ortest..   (for-
c9c0: 65 61 63 68 20 0a 09 20 20 20 20 28 6c 61 6d 62  each ..    (lamb
c9d0: 64 61 20 28 64 69 72 2d 74 6f 2d 72 65 6d 6f 76  da (dir-to-remov
c9e0: 65 29 0a 09 20 20 20 20 20 20 28 69 66 20 28 66  e)..      (if (f
c9f0: 69 6c 65 2d 65 78 69 73 74 73 3f 20 64 69 72 2d  ile-exists? dir-
ca00: 74 6f 2d 72 65 6d 6f 76 65 29 0a 09 09 20 20 28  to-remove)...  (
ca10: 6c 65 74 20 28 28 64 69 72 2d 69 6e 2d 64 62 20  let ((dir-in-db 
ca20: 27 28 29 29 29 0a 09 09 20 20 20 20 28 73 71 6c  '()))...    (sql
ca30: 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f  ite3:for-each-ro
ca40: 77 0a 09 09 20 20 20 20 20 28 6c 61 6d 62 64 61  w...     (lambda
ca50: 20 28 64 69 72 29 0a 09 09 20 20 20 20 20 20 20   (dir)...       
ca60: 28 73 65 74 21 20 64 69 72 2d 69 6e 2d 64 62 20  (set! dir-in-db 
ca70: 28 63 6f 6e 73 20 64 69 72 20 64 69 72 2d 69 6e  (cons dir dir-in
ca80: 2d 64 62 29 29 29 0a 09 09 20 20 20 20 20 64 62  -db)))...     db
ca90: 20 22 53 45 4c 45 43 54 20 72 75 6e 64 69 72 20   "SELECT rundir 
caa0: 46 52 4f 4d 20 74 65 73 74 73 20 57 48 45 52 45  FROM tests WHERE
cab0: 20 72 75 6e 64 69 72 20 4c 49 4b 45 20 3f 3b 22   rundir LIKE ?;"
cac0: 20 0a 09 09 20 20 20 20 20 28 63 6f 6e 63 20 22   ...     (conc "
cad0: 25 22 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65  %" dir-to-remove
cae0: 20 22 25 22 29 29 20 3b 3b 20 79 65 73 2c 20 49   "%")) ;; yes, I
caf0: 27 6d 20 67 6f 69 6e 67 20 74 6f 20 62 61 69 6c  'm going to bail
cb00: 20 69 66 20 74 68 65 72 65 20 69 73 20 61 6e 79   if there is any
cb10: 74 68 69 6e 67 20 6c 69 6b 65 20 74 68 69 73 20  thing like this 
cb20: 64 69 72 20 69 6e 20 74 68 65 20 64 62 0a 09 09  dir in the db...
cb30: 20 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 64      (if (null? d
cb40: 69 72 2d 69 6e 2d 64 62 29 0a 09 09 09 28 62 65  ir-in-db)....(be
cb50: 67 69 6e 0a 09 09 09 20 20 28 64 65 62 75 67 3a  gin....  (debug:
cb60: 70 72 69 6e 74 20 32 20 22 52 65 6d 6f 76 69 6e  print 2 "Removin
cb70: 67 20 64 69 72 65 63 74 6f 72 79 20 77 69 74 68  g directory with
cb80: 20 7a 65 72 6f 20 64 62 20 72 65 66 65 72 65 6e   zero db referen
cb90: 63 65 73 3a 20 22 20 64 69 72 2d 74 6f 2d 72 65  ces: " dir-to-re
cba0: 6d 6f 76 65 29 0a 09 09 09 20 20 28 73 79 73 74  move)....  (syst
cbb0: 65 6d 20 28 63 6f 6e 63 20 22 72 6d 20 2d 72 66  em (conc "rm -rf
cbc0: 20 22 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65   " dir-to-remove
cbd0: 29 29 0a 09 09 09 20 20 28 68 61 73 68 2d 74 61  ))....  (hash-ta
cbe0: 62 6c 65 2d 64 65 6c 65 74 65 21 20 64 69 72 73  ble-delete! dirs
cbf0: 2d 74 6f 2d 72 65 6d 6f 76 65 20 64 69 72 2d 74  -to-remove dir-t
cc00: 6f 2d 72 65 6d 6f 76 65 29 29 0a 09 09 09 28 64  o-remove))....(d
cc10: 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 53 6b  ebug:print 2 "Sk
cc20: 69 70 70 69 6e 67 20 72 65 6d 6f 76 61 6c 20 6f  ipping removal o
cc30: 66 20 22 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76  f " dir-to-remov
cc40: 65 20 22 20 66 6f 72 20 6e 6f 77 20 61 73 20 69  e " for now as i
cc50: 74 20 73 74 69 6c 6c 20 68 61 73 20 72 65 66 65  t still has refe
cc60: 72 65 6e 63 65 73 20 69 6e 20 74 68 65 20 64 61  rences in the da
cc70: 74 61 62 61 73 65 22 29 29 29 29 29 0a 09 20 20  tabase")))))..  
cc80: 20 20 28 73 6f 72 74 20 28 68 61 73 68 2d 74 61    (sort (hash-ta
cc90: 62 6c 65 2d 6b 65 79 73 20 64 69 72 73 2d 74 6f  ble-keys dirs-to
cca0: 2d 72 65 6d 6f 76 65 29 20 28 6c 61 6d 62 64 61  -remove) (lambda
ccb0: 20 28 61 20 62 29 28 3e 20 28 73 74 72 69 6e 67   (a b)(> (string
ccc0: 2d 6c 65 6e 67 74 68 20 61 29 28 73 74 72 69 6e  -length a)(strin
ccd0: 67 2d 6c 65 6e 67 74 68 20 62 29 29 29 29 29 0a  g-length b))))).
cce0: 0a 09 20 20 20 3b 3b 20 72 65 6d 6f 76 65 20 74  ..   ;; remove t
ccf0: 68 65 20 72 75 6e 20 69 66 20 7a 65 72 6f 20 74  he run if zero t
cd00: 65 73 74 73 20 72 65 6d 61 69 6e 0a 09 20 20 20  ests remain..   
cd10: 28 6c 65 74 20 28 28 72 65 6d 74 65 73 74 73 20  (let ((remtests 
cd20: 28 64 62 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f  (db-get-tests-fo
cd30: 72 2d 72 75 6e 20 64 62 20 28 64 62 3a 67 65 74  r-run db (db:get
cd40: 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72  -value-by-header
cd50: 20 72 75 6e 20 68 65 61 64 65 72 20 22 69 64 22   run header "id"
cd60: 29 20 23 66 20 23 66 20 27 28 29 20 27 28 29 29  ) #f #f '() '())
cd70: 29 29 0a 09 20 20 20 20 20 28 69 66 20 28 6e 75  ))..     (if (nu
cd80: 6c 6c 3f 20 72 65 6d 74 65 73 74 73 29 20 3b 3b  ll? remtests) ;;
cd90: 20 6e 6f 20 6d 6f 72 65 20 74 65 73 74 73 20 72   no more tests r
cda0: 65 6d 61 69 6e 69 6e 67 0a 09 09 20 28 6c 65 74  emaining... (let
cdb0: 2a 20 28 28 64 70 61 72 74 73 20 20 28 73 74 72  * ((dparts  (str
cdc0: 69 6e 67 2d 73 70 6c 69 74 20 6c 61 73 74 74 70  ing-split lasttp
cdd0: 61 74 68 20 22 2f 22 29 29 0a 09 09 09 28 72 75  ath "/"))....(ru
cde0: 6e 70 61 74 68 20 28 63 6f 6e 63 20 22 2f 22 20  npath (conc "/" 
cdf0: 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65  (string-interspe
ce00: 72 73 65 20 0a 09 09 09 09 09 20 20 20 20 28 74  rse ......    (t
ce10: 61 6b 65 20 64 70 61 72 74 73 20 28 2d 20 28 6c  ake dparts (- (l
ce20: 65 6e 67 74 68 20 64 70 61 72 74 73 29 20 31 29  ength dparts) 1)
ce30: 29 0a 09 09 09 09 09 20 20 20 20 22 2f 22 29 29  )......    "/"))
ce40: 29 29 0a 09 09 20 20 20 28 64 65 62 75 67 3a 70  ))...   (debug:p
ce50: 72 69 6e 74 20 31 20 22 52 65 6d 6f 76 69 6e 67  rint 1 "Removing
ce60: 20 72 75 6e 3a 20 22 20 72 75 6e 6b 65 79 20 22   run: " runkey "
ce70: 20 22 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65   " (db:get-value
ce80: 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68  -by-header run h
ce90: 65 61 64 65 72 20 22 72 75 6e 6e 61 6d 65 22 29  eader "runname")
cea0: 29 0a 09 09 20 20 20 28 64 62 3a 64 65 6c 65 74  )...   (db:delet
ceb0: 65 2d 72 75 6e 20 64 62 20 72 75 6e 2d 69 64 29  e-run db run-id)
cec0: 0a 09 09 20 20 20 3b 3b 20 6e 65 65 64 20 74 6f  ...   ;; need to
ced0: 20 66 69 67 75 72 65 20 6f 75 74 20 74 68 65 20   figure out the 
cee0: 70 61 74 68 20 74 6f 20 74 68 65 20 72 75 6e 20  path to the run 
cef0: 64 69 72 20 61 6e 64 20 72 65 6d 6f 76 65 20 69  dir and remove i
cf00: 74 20 69 66 20 65 6d 70 74 79 0a 09 09 20 20 20  t if empty...   
cf10: 3b 3b 20 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f  ;;    (if (null?
cf20: 20 28 67 6c 6f 62 20 28 63 6f 6e 63 20 72 75 6e   (glob (conc run
cf30: 70 61 74 68 20 22 2f 2a 22 29 29 29 0a 09 09 20  path "/*")))... 
cf40: 20 20 3b 3b 20 20 20 20 20 20 20 20 28 62 65 67    ;;        (beg
cf50: 69 6e 0a 09 09 20 20 20 3b 3b 20 09 20 28 64 65  in...   ;; . (de
cf60: 62 75 67 3a 70 72 69 6e 74 20 31 20 22 52 65 6d  bug:print 1 "Rem
cf70: 6f 76 69 6e 67 20 72 75 6e 20 64 69 72 20 22 20  oving run dir " 
cf80: 72 75 6e 70 61 74 68 29 0a 09 09 20 20 20 3b 3b  runpath)...   ;;
cf90: 20 09 20 28 73 79 73 74 65 6d 20 28 63 6f 6e 63   . (system (conc
cfa0: 20 22 72 6d 64 69 72 20 2d 70 20 22 20 72 75 6e   "rmdir -p " run
cfb0: 70 61 74 68 29 29 29 29 0a 09 09 20 20 20 29 29  path))))...   ))
cfc0: 29 29 0a 09 20 29 29 0a 20 20 20 20 20 72 75 6e  )).. )).     run
cfd0: 73 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d  s)))..;;========
cfe0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
cff0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
d000: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
d010: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b  ==============.;
d020: 3b 20 52 6f 75 74 69 6e 65 73 20 66 6f 72 20 6d  ; Routines for m
d030: 61 6e 69 70 75 6c 61 74 69 6e 67 20 72 75 6e 73  anipulating runs
d040: 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  .;;=============
d050: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
d060: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
d070: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
d080: 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 53 69  =========..;; Si
d090: 6e 63 65 20 6d 61 6e 79 20 63 61 6c 6c 73 20 74  nce many calls t
d0a0: 6f 20 61 20 72 75 6e 20 72 65 71 75 69 72 65 20  o a run require 
d0b0: 70 72 65 74 74 79 20 6d 75 63 68 20 74 68 65 20  pretty much the 
d0c0: 73 61 6d 65 20 73 65 74 75 70 20 0a 3b 3b 20 74  same setup .;; t
d0d0: 68 69 73 20 77 72 61 70 70 65 72 20 69 73 20 75  his wrapper is u
d0e0: 73 65 64 20 74 6f 20 72 65 64 75 63 65 20 74 68  sed to reduce th
d0f0: 65 20 72 65 70 6c 69 63 61 74 69 6f 6e 20 6f 66  e replication of
d100: 20 63 6f 64 65 0a 28 64 65 66 69 6e 65 20 28 67   code.(define (g
d110: 65 6e 65 72 61 6c 2d 72 75 6e 2d 63 61 6c 6c 20  eneral-run-call 
d120: 73 77 69 74 63 68 6e 61 6d 65 20 61 63 74 69 6f  switchname actio
d130: 6e 2d 64 65 73 63 20 70 72 6f 63 29 0a 20 20 28  n-desc proc).  (
d140: 69 66 20 28 6e 6f 74 20 28 61 72 67 73 3a 67 65  if (not (args:ge
d150: 74 2d 61 72 67 20 22 3a 72 75 6e 6e 61 6d 65 22  t-arg ":runname"
d160: 29 29 0a 20 20 20 20 20 20 28 62 65 67 69 6e 0a  )).      (begin.
d170: 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20  .(debug:print 0 
d180: 22 45 52 52 4f 52 3a 20 4d 69 73 73 69 6e 67 20  "ERROR: Missing 
d190: 72 65 71 75 69 72 65 64 20 70 61 72 61 6d 65 74  required paramet
d1a0: 65 72 20 66 6f 72 20 22 20 73 77 69 74 63 68 6e  er for " switchn
d1b0: 61 6d 65 20 22 2c 20 79 6f 75 20 6d 75 73 74 20  ame ", you must 
d1c0: 73 70 65 63 69 66 79 20 74 68 65 20 72 75 6e 20  specify the run 
d1d0: 6e 61 6d 65 20 77 69 74 68 20 3a 72 75 6e 6e 61  name with :runna
d1e0: 6d 65 20 72 75 6e 6e 61 6d 65 22 29 0a 09 28 65  me runname")..(e
d1f0: 78 69 74 20 32 29 29 0a 20 20 20 20 20 20 28 6c  xit 2)).      (l
d200: 65 74 20 28 28 64 62 20 20 20 23 66 29 0a 09 20  et ((db   #f).. 
d210: 20 20 20 28 6b 65 79 73 20 23 66 29 29 0a 09 28     (keys #f))..(
d220: 69 66 20 28 6e 6f 74 20 28 73 65 74 75 70 2d 66  if (not (setup-f
d230: 6f 72 2d 72 75 6e 29 29 0a 09 20 20 20 20 28 62  or-run))..    (b
d240: 65 67 69 6e 20 0a 09 20 20 20 20 20 20 28 64 65  egin ..      (de
d250: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 46 61 69  bug:print 0 "Fai
d260: 6c 65 64 20 74 6f 20 73 65 74 75 70 2c 20 65 78  led to setup, ex
d270: 69 74 69 6e 67 22 29 0a 09 20 20 20 20 20 20 28  iting")..      (
d280: 65 78 69 74 20 31 29 29 29 0a 09 28 73 65 74 21  exit 1)))..(set!
d290: 20 64 62 20 20 20 28 6f 70 65 6e 2d 64 62 29 29   db   (open-db))
d2a0: 0a 09 28 73 65 74 21 20 6b 65 79 73 20 28 64 62  ..(set! keys (db
d2b0: 2d 67 65 74 2d 6b 65 79 73 20 64 62 29 29 0a 09  -get-keys db))..
d2c0: 3b 3b 20 68 61 76 65 20 65 6e 6f 75 67 68 20 74  ;; have enough t
d2d0: 6f 20 70 72 6f 63 65 73 73 20 2d 74 61 72 67 65  o process -targe
d2e0: 74 20 6f 72 20 2d 72 65 71 74 61 72 67 20 68 65  t or -reqtarg he
d2f0: 72 65 0a 09 28 69 66 20 28 61 72 67 73 3a 67 65  re..(if (args:ge
d300: 74 2d 61 72 67 20 22 2d 72 65 71 74 61 72 67 22  t-arg "-reqtarg"
d310: 29 0a 09 20 20 20 20 28 6c 65 74 2a 20 28 28 72  )..    (let* ((r
d320: 75 6e 63 6f 6e 66 69 67 66 20 28 63 6f 6e 63 20  unconfigf (conc 
d330: 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f 72 75 6e   *toppath* "/run
d340: 63 6f 6e 66 69 67 73 2e 63 6f 6e 66 69 67 22 29  configs.config")
d350: 29 0a 09 09 20 20 20 28 72 75 6e 63 6f 6e 66 69  )...   (runconfi
d360: 67 20 20 28 72 65 61 64 2d 63 6f 6e 66 69 67 20  g  (read-config 
d370: 72 75 6e 63 6f 6e 66 69 67 66 20 23 66 20 23 66  runconfigf #f #f
d380: 29 29 29 0a 09 20 20 20 20 20 20 28 69 66 20 28  )))..      (if (
d390: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64  hash-table-ref/d
d3a0: 65 66 61 75 6c 74 20 72 75 6e 63 6f 6e 66 69 67  efault runconfig
d3b0: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22   (args:get-arg "
d3c0: 2d 72 65 71 74 61 72 67 22 29 20 23 66 29 0a 09  -reqtarg") #f)..
d3d0: 09 20 20 28 6b 65 79 73 3a 74 61 72 67 65 74 2d  .  (keys:target-
d3e0: 73 65 74 2d 61 72 67 73 20 6b 65 79 73 20 28 61  set-args keys (a
d3f0: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65  rgs:get-arg "-re
d400: 71 74 61 72 67 22 29 20 61 72 67 73 3a 61 72 67  qtarg") args:arg
d410: 2d 68 61 73 68 29 0a 09 09 20 20 28 62 65 67 69  -hash)...  (begi
d420: 6e 0a 09 09 20 20 20 20 28 64 65 62 75 67 3a 70  n...    (debug:p
d430: 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 5b  rint 0 "ERROR: [
d440: 22 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20  " (args:get-arg 
d450: 22 2d 72 65 71 74 61 72 67 22 29 20 22 5d 20 6e  "-reqtarg") "] n
d460: 6f 74 20 66 6f 75 6e 64 20 69 6e 20 22 20 72 75  ot found in " ru
d470: 6e 63 6f 6e 66 69 67 66 29 0a 09 09 20 20 20 20  nconfigf)...    
d480: 28 73 71 6c 69 74 65 33 3a 66 69 6e 61 6c 69 7a  (sqlite3:finaliz
d490: 65 21 20 64 62 29 0a 09 09 20 20 20 20 28 65 78  e! db)...    (ex
d4a0: 69 74 20 31 29 29 29 29 0a 09 20 20 20 20 28 69  it 1))))..    (i
d4b0: 66 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20  f (args:get-arg 
d4c0: 22 2d 74 61 72 67 65 74 22 29 0a 09 09 28 6b 65  "-target")...(ke
d4d0: 79 73 3a 74 61 72 67 65 74 2d 73 65 74 2d 61 72  ys:target-set-ar
d4e0: 67 73 20 6b 65 79 73 20 28 61 72 67 73 3a 67 65  gs keys (args:ge
d4f0: 74 2d 61 72 67 20 22 2d 74 61 72 67 65 74 22 20  t-arg "-target" 
d500: 61 72 67 73 3a 61 72 67 2d 68 61 73 68 29 20 61  args:arg-hash) a
d510: 72 67 73 3a 61 72 67 2d 68 61 73 68 29 29 29 0a  rgs:arg-hash))).
d520: 09 28 69 66 20 28 6e 6f 74 20 28 63 61 72 20 2a  .(if (not (car *
d530: 63 6f 6e 66 69 67 69 6e 66 6f 2a 29 29 0a 09 20  configinfo*)).. 
d540: 20 20 20 28 62 65 67 69 6e 0a 09 20 20 20 20 20     (begin..     
d550: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
d560: 22 45 52 52 4f 52 3a 20 41 74 74 65 6d 70 74 65  "ERROR: Attempte
d570: 64 20 74 6f 20 22 20 61 63 74 69 6f 6e 2d 64 65  d to " action-de
d580: 73 63 20 22 20 62 75 74 20 72 75 6e 20 61 72 65  sc " but run are
d590: 61 20 63 6f 6e 66 69 67 20 66 69 6c 65 20 6e 6f  a config file no
d5a0: 74 20 66 6f 75 6e 64 22 29 0a 09 20 20 20 20 20  t found")..     
d5b0: 20 28 65 78 69 74 20 31 29 29 0a 09 20 20 20 20   (exit 1))..    
d5c0: 3b 3b 20 45 78 74 72 61 63 74 20 6f 75 74 20 73  ;; Extract out s
d5d0: 74 75 66 66 20 6e 65 65 64 65 64 20 69 6e 20 6d  tuff needed in m
d5e0: 6f 73 74 20 6f 72 20 6d 61 6e 79 20 63 61 6c 6c  ost or many call
d5f0: 73 0a 09 20 20 20 20 3b 3b 20 68 65 72 65 20 74  s..    ;; here t
d600: 68 65 6e 20 63 61 6c 6c 20 70 72 6f 63 0a 09 20  hen call proc.. 
d610: 20 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 6e 61     (let* ((keyna
d620: 6d 65 73 20 20 20 28 6d 61 70 20 6b 65 79 3a 67  mes   (map key:g
d630: 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65 79  et-fieldname key
d640: 73 29 29 0a 09 09 20 20 20 28 6b 65 79 76 61 6c  s))...   (keyval
d650: 6c 73 74 20 20 28 6b 65 79 73 2d 3e 76 61 6c 6c  lst  (keys->vall
d660: 69 73 74 20 6b 65 79 73 20 23 74 29 29 29 0a 09  ist keys #t)))..
d670: 20 20 20 20 20 20 28 70 72 6f 63 20 64 62 20 6b        (proc db k
d680: 65 79 73 20 6b 65 79 6e 61 6d 65 73 20 6b 65 79  eys keynames key
d690: 76 61 6c 6c 73 74 29 29 29 0a 09 28 73 71 6c 69  vallst)))..(sqli
d6a0: 74 65 33 3a 66 69 6e 61 6c 69 7a 65 21 20 64 62  te3:finalize! db
d6b0: 29 0a 09 28 73 65 74 21 20 2a 64 69 64 73 6f 6d  )..(set! *didsom
d6c0: 65 74 68 69 6e 67 2a 20 23 74 29 29 29 29 0a 0a  ething* #t))))..
d6d0: 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ;;==============
d6e0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
d6f0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
d700: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
d710: 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 52 6f 6c 6c  ========.;; Roll
d720: 75 70 20 72 75 6e 73 0a 3b 3b 3d 3d 3d 3d 3d 3d  up runs.;;======
d730: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
d740: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
d750: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
d760: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
d770: 0a 0a 3b 3b 20 55 70 64 61 74 65 20 74 68 65 20  ..;; Update the 
d780: 74 65 73 74 5f 6d 65 74 61 20 74 61 62 6c 65 20  test_meta table 
d790: 66 6f 72 20 74 68 69 73 20 74 65 73 74 0a 28 64  for this test.(d
d7a0: 65 66 69 6e 65 20 28 72 75 6e 73 3a 75 70 64 61  efine (runs:upda
d7b0: 74 65 2d 74 65 73 74 5f 6d 65 74 61 20 64 62 20  te-test_meta db 
d7c0: 74 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 2d 63  test-name test-c
d7d0: 6f 6e 66 29 0a 20 20 28 6c 65 74 20 28 28 63 75  onf).  (let ((cu
d7e0: 72 72 72 65 63 6f 72 64 20 28 64 62 3a 74 65 73  rrrecord (db:tes
d7f0: 74 6d 65 74 61 2d 67 65 74 2d 72 65 63 6f 72 64  tmeta-get-record
d800: 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 29 29 29   db test-name)))
d810: 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 63 75  .    (if (not cu
d820: 72 72 72 65 63 6f 72 64 29 0a 09 28 62 65 67 69  rrrecord)..(begi
d830: 6e 0a 09 20 20 28 73 65 74 21 20 63 75 72 72 72  n..  (set! currr
d840: 65 63 6f 72 64 20 28 6d 61 6b 65 2d 76 65 63 74  ecord (make-vect
d850: 6f 72 20 31 30 20 23 66 29 29 0a 09 20 20 28 64  or 10 #f))..  (d
d860: 62 3a 74 65 73 74 6d 65 74 61 2d 61 64 64 2d 72  b:testmeta-add-r
d870: 65 63 6f 72 64 20 64 62 20 74 65 73 74 2d 6e 61  ecord db test-na
d880: 6d 65 29 29 29 0a 20 20 20 20 28 66 6f 72 2d 65  me))).    (for-e
d890: 61 63 68 20 0a 20 20 20 20 20 28 6c 61 6d 62 64  ach .     (lambd
d8a0: 61 20 28 6b 65 79 29 0a 20 20 20 20 20 20 20 28  a (key).       (
d8b0: 6c 65 74 2a 20 28 28 69 64 78 20 28 63 61 64 72  let* ((idx (cadr
d8c0: 20 6b 65 79 29 29 0a 09 20 20 20 20 20 20 28 66   key))..      (f
d8d0: 6c 64 20 28 63 61 72 20 20 6b 65 79 29 29 0a 09  ld (car  key))..
d8e0: 20 20 20 20 20 20 28 76 61 6c 20 28 63 6f 6e 66        (val (conf
d8f0: 69 67 2d 6c 6f 6f 6b 75 70 20 74 65 73 74 2d 63  ig-lookup test-c
d900: 6f 6e 66 20 22 74 65 73 74 5f 6d 65 74 61 22 20  onf "test_meta" 
d910: 66 6c 64 29 29 29 0a 09 20 28 69 66 20 28 61 6e  fld))).. (if (an
d920: 64 20 76 61 6c 20 28 6e 6f 74 20 28 65 71 75 61  d val (not (equa
d930: 6c 3f 20 28 76 65 63 74 6f 72 2d 72 65 66 20 63  l? (vector-ref c
d940: 75 72 72 72 65 63 6f 72 64 20 69 64 78 29 20 76  urrrecord idx) v
d950: 61 6c 29 29 29 0a 09 20 20 20 20 20 28 62 65 67  al)))..     (beg
d960: 69 6e 0a 09 20 20 20 20 20 20 20 28 70 72 69 6e  in..       (prin
d970: 74 20 22 55 70 64 61 74 69 6e 67 20 22 20 74 65  t "Updating " te
d980: 73 74 2d 6e 61 6d 65 20 22 20 22 20 66 6c 64 20  st-name " " fld 
d990: 22 20 74 6f 20 22 20 76 61 6c 29 0a 09 20 20 20  " to " val)..   
d9a0: 20 20 20 20 28 64 62 3a 74 65 73 74 6d 65 74 61      (db:testmeta
d9b0: 2d 75 70 64 61 74 65 2d 66 69 65 6c 64 20 64 62  -update-field db
d9c0: 20 74 65 73 74 2d 6e 61 6d 65 20 66 6c 64 20 76   test-name fld v
d9d0: 61 6c 29 29 29 29 29 0a 20 20 20 20 20 27 28 28  al))))).     '((
d9e0: 22 61 75 74 68 6f 72 22 20 32 29 28 22 6f 77 6e  "author" 2)("own
d9f0: 65 72 22 20 33 29 28 22 64 65 73 63 72 69 70 74  er" 3)("descript
da00: 69 6f 6e 22 20 34 29 28 22 72 65 76 69 65 77 65  ion" 4)("reviewe
da10: 64 22 20 35 29 28 22 74 61 67 73 22 20 39 29 29  d" 5)("tags" 9))
da20: 29 29 29 0a 0a 3b 3b 20 55 70 64 61 74 65 20 74  )))..;; Update t
da30: 65 73 74 5f 6d 65 74 61 20 66 6f 72 20 61 6c 6c  est_meta for all
da40: 20 74 65 73 74 73 0a 28 64 65 66 69 6e 65 20 28   tests.(define (
da50: 72 75 6e 73 3a 75 70 64 61 74 65 2d 61 6c 6c 2d  runs:update-all-
da60: 74 65 73 74 5f 6d 65 74 61 20 64 62 29 0a 20 20  test_meta db).  
da70: 28 6c 65 74 20 28 28 74 65 73 74 2d 6e 61 6d 65  (let ((test-name
da80: 73 20 28 67 65 74 2d 61 6c 6c 2d 6c 65 67 61 6c  s (get-all-legal
da90: 2d 74 65 73 74 73 29 29 29 0a 20 20 20 20 28 66  -tests))).    (f
daa0: 6f 72 2d 65 61 63 68 20 0a 20 20 20 20 20 28 6c  or-each .     (l
dab0: 61 6d 62 64 61 20 28 74 65 73 74 2d 6e 61 6d 65  ambda (test-name
dac0: 29 0a 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28  ).       (let* (
dad0: 28 74 65 73 74 2d 70 61 74 68 20 20 20 20 28 63  (test-path    (c
dae0: 6f 6e 63 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f  onc *toppath* "/
daf0: 74 65 73 74 73 2f 22 20 74 65 73 74 2d 6e 61 6d  tests/" test-nam
db00: 65 29 29 0a 09 20 20 20 20 20 20 28 74 65 73 74  e))..      (test
db10: 2d 63 6f 6e 66 69 67 66 20 28 63 6f 6e 63 20 74  -configf (conc t
db20: 65 73 74 2d 70 61 74 68 20 22 2f 74 65 73 74 63  est-path "/testc
db30: 6f 6e 66 69 67 22 29 29 0a 09 20 20 20 20 20 20  onfig"))..      
db40: 28 74 65 73 74 65 78 69 73 74 73 20 20 20 28 61  (testexists   (a
db50: 6e 64 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f  nd (file-exists?
db60: 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 29 28 66   test-configf)(f
db70: 69 6c 65 2d 72 65 61 64 2d 61 63 63 65 73 73 3f  ile-read-access?
db80: 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 29 29 29   test-configf)))
db90: 0a 09 20 20 20 20 20 20 3b 3b 20 72 65 61 64 20  ..      ;; read 
dba0: 63 6f 6e 66 69 67 73 20 77 69 74 68 20 74 72 69  configs with tri
dbb0: 63 6b 73 20 74 75 72 6e 65 64 20 6f 66 66 20 28  cks turned off (
dbc0: 69 2e 65 2e 20 6e 6f 20 73 79 73 74 65 6d 29 0a  i.e. no system).
dbd0: 09 20 20 20 20 20 20 28 74 65 73 74 2d 63 6f 6e  .      (test-con
dbe0: 66 20 20 20 20 28 69 66 20 74 65 73 74 65 78 69  f    (if testexi
dbf0: 73 74 73 20 28 72 65 61 64 2d 63 6f 6e 66 69 67  sts (read-config
dc00: 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 20 23 66   test-configf #f
dc10: 20 23 66 29 28 6d 61 6b 65 2d 68 61 73 68 2d 74   #f)(make-hash-t
dc20: 61 62 6c 65 29 29 29 29 0a 09 20 28 72 75 6e 73  able)))).. (runs
dc30: 3a 75 70 64 61 74 65 2d 74 65 73 74 5f 6d 65 74  :update-test_met
dc40: 61 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 20 74  a db test-name t
dc50: 65 73 74 2d 63 6f 6e 66 29 29 29 0a 20 20 20 20  est-conf))).    
dc60: 20 74 65 73 74 2d 6e 61 6d 65 73 29 29 29 0a 09   test-names)))..
dc70: 20 0a 3b 3b 20 54 68 69 73 20 63 6f 75 6c 64 20   .;; This could 
dc80: 70 72 6f 62 61 62 6c 79 20 62 65 20 72 65 66 61  probably be refa
dc90: 63 74 6f 72 65 64 20 69 6e 74 6f 20 6f 6e 65 20  ctored into one 
dca0: 63 6f 6d 70 6c 65 78 20 71 75 65 72 79 20 2e 2e  complex query ..
dcb0: 2e 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a  ..(define (runs:
dcc0: 72 6f 6c 6c 75 70 2d 72 75 6e 20 64 62 20 6b 65  rollup-run db ke
dcd0: 79 73 29 0a 20 20 28 6c 65 74 2a 20 28 28 6e 65  ys).  (let* ((ne
dce0: 77 2d 72 75 6e 2d 69 64 20 20 20 20 20 20 28 72  w-run-id      (r
dcf0: 65 67 69 73 74 65 72 2d 72 75 6e 20 64 62 20 6b  egister-run db k
dd00: 65 79 73 29 29 0a 09 20 28 70 72 65 76 2d 74 65  eys)).. (prev-te
dd10: 73 74 73 20 20 20 20 20 20 28 74 65 73 74 3a 67  sts      (test:g
dd20: 65 74 2d 6d 61 74 63 68 69 6e 67 2d 70 72 65 76  et-matching-prev
dd30: 69 6f 75 73 2d 74 65 73 74 2d 72 75 6e 2d 72 65  ious-test-run-re
dd40: 63 6f 72 64 73 20 64 62 20 6e 65 77 2d 72 75 6e  cords db new-run
dd50: 2d 69 64 20 22 25 22 20 22 25 22 29 29 0a 09 20  -id "%" "%")).. 
dd60: 28 63 75 72 72 2d 74 65 73 74 73 20 20 20 20 20  (curr-tests     
dd70: 20 28 64 62 2d 67 65 74 2d 74 65 73 74 73 2d 66   (db-get-tests-f
dd80: 6f 72 2d 72 75 6e 20 64 62 20 6e 65 77 2d 72 75  or-run db new-ru
dd90: 6e 2d 69 64 20 22 25 22 20 22 25 22 20 27 28 29  n-id "%" "%" '()
dda0: 20 27 28 29 29 29 0a 09 20 28 63 75 72 72 2d 74   '())).. (curr-t
ddb0: 65 73 74 73 2d 68 61 73 68 20 28 6d 61 6b 65 2d  ests-hash (make-
ddc0: 68 61 73 68 2d 74 61 62 6c 65 29 29 29 0a 20 20  hash-table))).  
ddd0: 20 20 28 64 62 3a 75 70 64 61 74 65 2d 72 75 6e    (db:update-run
dde0: 2d 65 76 65 6e 74 5f 74 69 6d 65 20 64 62 20 6e  -event_time db n
ddf0: 65 77 2d 72 75 6e 2d 69 64 29 0a 20 20 20 20 3b  ew-run-id).    ;
de00: 3b 20 69 6e 64 65 78 20 74 68 65 20 61 6c 72 65  ; index the alre
de10: 61 64 79 20 73 61 76 65 64 20 74 65 73 74 73 20  ady saved tests 
de20: 62 79 20 74 65 73 74 6e 61 6d 65 20 61 6e 64 20  by testname and 
de30: 69 74 65 6d 70 61 74 68 20 69 6e 20 63 75 72 72  itempath in curr
de40: 2d 74 65 73 74 73 2d 68 61 73 68 0a 20 20 20 20  -tests-hash.    
de50: 28 66 6f 72 2d 65 61 63 68 0a 20 20 20 20 20 28  (for-each.     (
de60: 6c 61 6d 62 64 61 20 28 74 65 73 74 64 61 74 29  lambda (testdat)
de70: 0a 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28 28  .       (let* ((
de80: 74 65 73 74 6e 61 6d 65 20 20 28 64 62 3a 74 65  testname  (db:te
de90: 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20  st-get-testname 
dea0: 74 65 73 74 64 61 74 29 29 0a 09 20 20 20 20 20  testdat))..     
deb0: 20 28 69 74 65 6d 2d 70 61 74 68 20 28 64 62 3a   (item-path (db:
dec0: 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61  test-get-item-pa
ded0: 74 68 20 74 65 73 74 64 61 74 29 29 0a 09 20 20  th testdat))..  
dee0: 20 20 20 20 28 66 75 6c 6c 2d 6e 61 6d 65 20 28      (full-name (
def0: 63 6f 6e 63 20 74 65 73 74 6e 61 6d 65 20 22 2f  conc testname "/
df00: 22 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 09  " item-path)))..
df10: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74   (hash-table-set
df20: 21 20 63 75 72 72 2d 74 65 73 74 73 2d 68 61 73  ! curr-tests-has
df30: 68 20 66 75 6c 6c 2d 6e 61 6d 65 20 74 65 73 74  h full-name test
df40: 64 61 74 29 29 29 0a 20 20 20 20 20 63 75 72 72  dat))).     curr
df50: 2d 74 65 73 74 73 29 0a 20 20 20 20 3b 3b 20 4e  -tests).    ;; N
df60: 4f 50 45 3a 20 4e 6f 6e 2d 6f 70 74 69 6d 61 6c  OPE: Non-optimal
df70: 20 61 70 70 72 6f 61 63 68 2e 20 54 72 79 20 74   approach. Try t
df80: 68 69 73 20 69 6e 73 74 65 61 64 2e 0a 20 20 20  his instead..   
df90: 20 3b 3b 20 20 20 31 2e 20 74 65 73 74 73 20 61   ;;   1. tests a
dfa0: 72 65 20 72 65 63 65 69 76 65 64 20 69 6e 20 61  re received in a
dfb0: 20 6c 69 73 74 2c 20 6d 6f 73 74 20 72 65 63 65   list, most rece
dfc0: 6e 74 20 66 69 72 73 74 0a 20 20 20 20 3b 3b 20  nt first.    ;; 
dfd0: 20 20 32 2e 20 72 65 70 6c 61 63 65 20 74 68 65    2. replace the
dfe0: 20 72 6f 6c 6c 75 70 20 74 65 73 74 20 77 69 74   rollup test wit
dff0: 68 20 74 68 65 20 6e 65 77 20 2a 61 6c 77 61 79  h the new *alway
e000: 73 2a 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68  s*.    (for-each
e010: 20 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28   .     (lambda (
e020: 74 65 73 74 64 61 74 29 0a 20 20 20 20 20 20 20  testdat).       
e030: 28 6c 65 74 2a 20 28 28 74 65 73 74 6e 61 6d 65  (let* ((testname
e040: 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 74    (db:test-get-t
e050: 65 73 74 6e 61 6d 65 20 74 65 73 74 64 61 74 29  estname testdat)
e060: 29 0a 09 20 20 20 20 20 20 28 69 74 65 6d 2d 70  )..      (item-p
e070: 61 74 68 20 28 64 62 3a 74 65 73 74 2d 67 65 74  ath (db:test-get
e080: 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 64  -item-path testd
e090: 61 74 29 29 0a 09 20 20 20 20 20 20 28 66 75 6c  at))..      (ful
e0a0: 6c 2d 6e 61 6d 65 20 28 63 6f 6e 63 20 74 65 73  l-name (conc tes
e0b0: 74 6e 61 6d 65 20 22 2f 22 20 69 74 65 6d 2d 70  tname "/" item-p
e0c0: 61 74 68 29 29 0a 09 20 20 20 20 20 20 28 70 72  ath))..      (pr
e0d0: 65 76 2d 74 65 73 74 2d 64 61 74 20 28 68 61 73  ev-test-dat (has
e0e0: 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61  h-table-ref/defa
e0f0: 75 6c 74 20 63 75 72 72 2d 74 65 73 74 73 2d 68  ult curr-tests-h
e100: 61 73 68 20 66 75 6c 6c 2d 6e 61 6d 65 20 23 66  ash full-name #f
e110: 29 29 0a 09 20 20 20 20 20 20 28 74 65 73 74 2d  ))..      (test-
e120: 73 74 65 70 73 20 20 20 20 20 20 28 64 62 3a 67  steps      (db:g
e130: 65 74 2d 73 74 65 70 73 2d 66 6f 72 2d 74 65 73  et-steps-for-tes
e140: 74 20 64 62 20 28 64 62 3a 74 65 73 74 2d 67 65  t db (db:test-ge
e150: 74 2d 69 64 20 74 65 73 74 64 61 74 29 29 29 0a  t-id testdat))).
e160: 09 20 20 20 20 20 20 28 6e 65 77 2d 74 65 73 74  .      (new-test
e170: 2d 72 65 63 6f 72 64 20 23 66 29 29 0a 09 20 3b  -record #f)).. ;
e180: 3b 20 72 65 70 6c 61 63 65 20 74 68 65 73 65 20  ; replace these 
e190: 77 69 74 68 20 69 6e 73 65 72 74 20 2e 2e 2e 20  with insert ... 
e1a0: 73 65 6c 65 63 74 0a 09 20 28 61 70 70 6c 79 20  select.. (apply 
e1b0: 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20  sqlite3:execute 
e1c0: 0a 09 09 64 62 20 0a 09 09 28 63 6f 6e 63 20 22  ...db ...(conc "
e1d0: 49 4e 53 45 52 54 20 4f 52 20 52 45 50 4c 41 43  INSERT OR REPLAC
e1e0: 45 20 49 4e 54 4f 20 74 65 73 74 73 20 28 72 75  E INTO tests (ru
e1f0: 6e 5f 69 64 2c 74 65 73 74 6e 61 6d 65 2c 73 74  n_id,testname,st
e200: 61 74 65 2c 73 74 61 74 75 73 2c 65 76 65 6e 74  ate,status,event
e210: 5f 74 69 6d 65 2c 68 6f 73 74 2c 63 70 75 6c 6f  _time,host,cpulo
e220: 61 64 2c 64 69 73 6b 66 72 65 65 2c 75 6e 61 6d  ad,diskfree,unam
e230: 65 2c 72 75 6e 64 69 72 2c 69 74 65 6d 5f 70 61  e,rundir,item_pa
e240: 74 68 2c 72 75 6e 5f 64 75 72 61 74 69 6f 6e 2c  th,run_duration,
e250: 66 69 6e 61 6c 5f 6c 6f 67 66 2c 63 6f 6d 6d 65  final_logf,comme
e260: 6e 74 2c 66 69 72 73 74 5f 65 72 72 2c 66 69 72  nt,first_err,fir
e270: 73 74 5f 77 61 72 6e 29 20 22 0a 09 09 20 20 20  st_warn) "...   
e280: 20 20 20 22 56 41 4c 55 45 53 20 28 3f 2c 3f 2c     "VALUES (?,?,
e290: 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c  ?,?,?,?,?,?,?,?,
e2a0: 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 29 3b 22 29 0a  ?,?,?,?,?,?);").
e2b0: 09 09 6e 65 77 2d 72 75 6e 2d 69 64 20 28 63 64  ..new-run-id (cd
e2c0: 64 72 20 28 76 65 63 74 6f 72 2d 3e 6c 69 73 74  dr (vector->list
e2d0: 20 74 65 73 74 64 61 74 29 29 29 0a 09 20 28 73   testdat))).. (s
e2e0: 65 74 21 20 6e 65 77 2d 74 65 73 74 64 61 74 20  et! new-testdat 
e2f0: 28 63 61 72 20 28 64 62 2d 67 65 74 2d 74 65 73  (car (db-get-tes
e300: 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 6e 65  ts-for-run db ne
e310: 77 2d 72 75 6e 2d 69 64 20 74 65 73 74 6e 61 6d  w-run-id testnam
e320: 65 20 69 74 65 6d 2d 70 61 74 68 20 27 28 29 20  e item-path '() 
e330: 27 28 29 29 29 29 0a 09 20 28 68 61 73 68 2d 74  '()))).. (hash-t
e340: 61 62 6c 65 2d 73 65 74 21 20 63 75 72 72 2d 74  able-set! curr-t
e350: 65 73 74 73 2d 68 61 73 68 20 66 75 6c 6c 2d 6e  ests-hash full-n
e360: 61 6d 65 20 6e 65 77 2d 74 65 73 74 64 61 74 29  ame new-testdat)
e370: 20 3b 3b 20 74 68 69 73 20 63 6f 75 6c 64 20 62   ;; this could b
e380: 65 20 63 6f 6e 66 75 73 69 6e 67 2c 20 77 68 69  e confusing, whi
e390: 63 68 20 72 65 63 6f 72 64 20 73 68 6f 75 6c 64  ch record should
e3a0: 20 67 6f 20 69 6e 74 6f 20 74 68 65 20 6c 6f 6f   go into the loo
e3b0: 6b 75 70 20 74 61 62 6c 65 3f 0a 09 20 3b 3b 20  kup table?.. ;; 
e3c0: 4e 6f 77 20 64 75 70 6c 69 63 61 74 65 20 74 68  Now duplicate th
e3d0: 65 20 74 65 73 74 20 73 74 65 70 73 0a 09 20 28  e test steps.. (
e3e0: 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 43  debug:print 4 "C
e3f0: 6f 70 79 69 6e 67 20 72 65 63 6f 72 64 73 20 69  opying records i
e400: 6e 20 74 65 73 74 5f 73 74 65 70 73 20 66 72 6f  n test_steps fro
e410: 6d 20 74 65 73 74 5f 69 64 3d 22 20 28 64 62 3a  m test_id=" (db:
e420: 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74  test-get-id test
e430: 64 61 74 29 20 22 20 74 6f 20 22 20 28 64 62 3a  dat) " to " (db:
e440: 74 65 73 74 2d 67 65 74 2d 69 64 20 6e 65 77 2d  test-get-id new-
e450: 74 65 73 74 64 61 74 29 29 0a 09 20 28 73 71 6c  testdat)).. (sql
e460: 69 74 65 33 3a 65 78 65 63 75 74 65 20 0a 09 20  ite3:execute .. 
e470: 20 64 62 20 0a 09 20 20 28 63 6f 6e 63 20 22 49   db ..  (conc "I
e480: 4e 53 45 52 54 20 4f 52 20 52 45 50 4c 41 43 45  NSERT OR REPLACE
e490: 20 49 4e 54 4f 20 74 65 73 74 5f 73 74 65 70 73   INTO test_steps
e4a0: 20 28 74 65 73 74 5f 69 64 2c 73 74 65 70 6e 61   (test_id,stepna
e4b0: 6d 65 2c 73 74 61 74 65 2c 73 74 61 74 75 73 2c  me,state,status,
e4c0: 65 76 65 6e 74 5f 74 69 6d 65 2c 63 6f 6d 6d 65  event_time,comme
e4d0: 6e 74 29 20 22 0a 09 09 22 53 45 4c 45 43 54 20  nt) "..."SELECT 
e4e0: 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69  " (db:test-get-i
e4f0: 64 20 6e 65 77 2d 74 65 73 74 64 61 74 29 20 22  d new-testdat) "
e500: 2c 73 74 65 70 6e 61 6d 65 2c 73 74 61 74 65 2c  ,stepname,state,
e510: 73 74 61 74 75 73 2c 65 76 65 6e 74 5f 74 69 6d  status,event_tim
e520: 65 2c 63 6f 6d 6d 65 6e 74 20 46 52 4f 4d 20 74  e,comment FROM t
e530: 65 73 74 5f 73 74 65 70 73 20 57 48 45 52 45 20  est_steps WHERE 
e540: 74 65 73 74 5f 69 64 3d 3f 3b 22 29 0a 09 20 20  test_id=?;")..  
e550: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20  (db:test-get-id 
e560: 74 65 73 74 64 61 74 29 29 0a 09 20 3b 3b 20 4e  testdat)).. ;; N
e570: 6f 77 20 64 75 70 6c 69 63 61 74 65 20 74 68 65  ow duplicate the
e580: 20 74 65 73 74 20 64 61 74 61 0a 09 20 28 64 65   test data.. (de
e590: 62 75 67 3a 70 72 69 6e 74 20 34 20 22 43 6f 70  bug:print 4 "Cop
e5a0: 79 69 6e 67 20 72 65 63 6f 72 64 73 20 69 6e 20  ying records in 
e5b0: 74 65 73 74 5f 64 61 74 61 20 66 72 6f 6d 20 74  test_data from t
e5c0: 65 73 74 5f 69 64 3d 22 20 28 64 62 3a 74 65 73  est_id=" (db:tes
e5d0: 74 2d 67 65 74 2d 69 64 20 74 65 73 74 64 61 74  t-get-id testdat
e5e0: 29 20 22 20 74 6f 20 22 20 28 64 62 3a 74 65 73  ) " to " (db:tes
e5f0: 74 2d 67 65 74 2d 69 64 20 6e 65 77 2d 74 65 73  t-get-id new-tes
e600: 74 64 61 74 29 29 0a 09 20 28 73 71 6c 69 74 65  tdat)).. (sqlite
e610: 33 3a 65 78 65 63 75 74 65 20 0a 09 20 20 64 62  3:execute ..  db
e620: 20 0a 09 20 20 28 63 6f 6e 63 20 22 49 4e 53 45   ..  (conc "INSE
e630: 52 54 20 4f 52 20 52 45 50 4c 41 43 45 20 49 4e  RT OR REPLACE IN
e640: 54 4f 20 74 65 73 74 5f 64 61 74 61 20 28 74 65  TO test_data (te
e650: 73 74 5f 69 64 2c 63 61 74 65 67 6f 72 79 2c 76  st_id,category,v
e660: 61 72 69 61 62 6c 65 2c 76 61 6c 75 65 2c 65 78  ariable,value,ex
e670: 70 65 63 74 65 64 2c 74 6f 6c 2c 75 6e 69 74 73  pected,tol,units
e680: 2c 63 6f 6d 6d 65 6e 74 29 20 22 0a 09 09 22 53  ,comment) "..."S
e690: 45 4c 45 43 54 20 22 20 28 64 62 3a 74 65 73 74  ELECT " (db:test
e6a0: 2d 67 65 74 2d 69 64 20 6e 65 77 2d 74 65 73 74  -get-id new-test
e6b0: 64 61 74 29 20 22 2c 63 61 74 65 67 6f 72 79 2c  dat) ",category,
e6c0: 76 61 72 69 61 62 6c 65 2c 76 61 6c 75 65 2c 65  variable,value,e
e6d0: 78 70 65 63 74 65 64 2c 74 6f 6c 2c 75 6e 69 74  xpected,tol,unit
e6e0: 73 2c 63 6f 6d 6d 65 6e 74 20 46 52 4f 4d 20 74  s,comment FROM t
e6f0: 65 73 74 5f 64 61 74 61 20 57 48 45 52 45 20 74  est_data WHERE t
e700: 65 73 74 5f 69 64 3d 3f 3b 22 29 0a 09 20 20 28  est_id=?;")..  (
e710: 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74  db:test-get-id t
e720: 65 73 74 64 61 74 29 29 0a 09 20 29 29 0a 20 20  estdat)).. )).  
e730: 20 20 20 70 72 65 76 2d 74 65 73 74 73 29 29 29     prev-tests)))
e740: 0a 09 20 0a 20 20 20 20 20 0a                    .. .     .