Megatest

Hex Artifact Content
Login

Artifact 96f6e3d21bf513f87813cb8ddc7bd46ab2c23612:


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 29 0a 20 20 28 64 65 62 75 67 3a 70 72 69  nt).  (debug:pri
45e0: 6e 74 20 34 20 22 72 75 6e 2d 69 64 3a 20 22 20  nt 4 "run-id: " 
45f0: 72 75 6e 2d 69 64 20 22 20 74 65 73 74 2d 6e 61  run-id " test-na
4600: 6d 65 3a 20 22 20 74 65 73 74 2d 6e 61 6d 65 29  me: " test-name)
4610: 0a 20 20 28 6c 65 74 2a 20 28 28 73 74 61 74 65  .  (let* ((state
4620: 20 20 20 20 20 28 63 68 65 63 6b 2d 76 61 6c 69       (check-vali
4630: 64 2d 69 74 65 6d 73 20 22 73 74 61 74 65 22 20  d-items "state" 
4640: 73 74 61 74 65 2d 69 6e 29 29 0a 09 20 28 73 74  state-in)).. (st
4650: 61 74 75 73 20 20 20 20 28 63 68 65 63 6b 2d 76  atus    (check-v
4660: 61 6c 69 64 2d 69 74 65 6d 73 20 22 73 74 61 74  alid-items "stat
4670: 75 73 22 20 73 74 61 74 75 73 2d 69 6e 29 29 0a  us" status-in)).
4680: 09 20 28 69 74 65 6d 2d 70 61 74 68 20 28 69 74  . (item-path (it
4690: 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69 74  em-list->path it
46a0: 65 6d 64 61 74 29 29 0a 09 20 28 74 65 73 74 64  emdat)).. (testd
46b0: 61 74 20 20 20 28 64 62 3a 67 65 74 2d 74 65 73  at   (db:get-tes
46c0: 74 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64  t-info db run-id
46d0: 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d   test-name item-
46e0: 70 61 74 68 29 29 29 0a 20 20 20 20 28 64 65 62  path))).    (deb
46f0: 75 67 3a 70 72 69 6e 74 20 35 20 22 74 65 73 74  ug:print 5 "test
4700: 64 61 74 3a 20 22 20 74 65 73 74 64 61 74 29 0a  dat: " testdat).
4710: 20 20 20 20 28 69 66 20 28 61 6e 64 20 74 65 73      (if (and tes
4720: 74 64 61 74 20 3b 3b 20 69 66 20 74 68 65 20 73  tdat ;; if the s
4730: 65 63 74 69 6f 6e 20 65 78 69 73 74 73 20 74 68  ection exists th
4740: 65 6e 20 66 6f 72 63 65 20 73 70 65 63 69 66 69  en force specifi
4750: 63 61 74 69 6f 6e 20 42 55 47 2c 20 49 20 64 6f  cation BUG, I do
4760: 6e 27 74 20 6c 69 6b 65 20 68 6f 77 20 74 68 69  n't like how thi
4770: 73 20 77 6f 72 6b 73 2e 0a 09 20 20 20 20 20 28  s works...     (
4780: 6f 72 20 28 6e 6f 74 20 73 74 61 74 65 29 28 6e  or (not state)(n
4790: 6f 74 20 73 74 61 74 75 73 29 29 29 0a 09 28 64  ot status)))..(d
47a0: 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41  ebug:print 0 "WA
47b0: 52 4e 49 4e 47 3a 20 49 6e 76 61 6c 69 64 20 22  RNING: Invalid "
47c0: 20 28 69 66 20 73 74 61 74 75 73 20 22 73 74 61   (if status "sta
47d0: 74 75 73 22 20 22 73 74 61 74 65 22 29 0a 09 20  tus" "state").. 
47e0: 20 20 20 20 20 20 22 20 76 61 6c 75 65 20 5c 22        " value \"
47f0: 22 20 28 69 66 20 73 74 61 74 75 73 20 73 74 61  " (if status sta
4800: 74 65 2d 69 6e 20 73 74 61 74 75 73 2d 69 6e 29  te-in status-in)
4810: 20 22 5c 22 2c 20 75 70 64 61 74 65 20 79 6f 75   "\", update you
4820: 72 20 76 61 6c 69 64 76 61 6c 75 65 73 20 73 65  r validvalues se
4830: 63 74 69 6f 6e 20 69 6e 20 6d 65 67 61 74 65 73  ction in megates
4840: 74 2e 63 6f 6e 66 69 67 22 29 29 0a 20 20 20 20  t.config")).    
4850: 28 69 66 20 74 65 73 74 64 61 74 0a 09 28 6c 65  (if testdat..(le
4860: 74 20 28 28 74 65 73 74 2d 69 64 20 28 74 65 73  t ((test-id (tes
4870: 74 3a 67 65 74 2d 69 64 20 74 65 73 74 64 61 74  t:get-id testdat
4880: 29 29 29 0a 09 20 20 28 73 71 6c 69 74 65 33 3a  )))..  (sqlite3:
4890: 65 78 65 63 75 74 65 20 64 62 20 0a 09 09 09 22  execute db ...."
48a0: 49 4e 53 45 52 54 20 4f 52 20 52 45 50 4c 41 43  INSERT OR REPLAC
48b0: 45 20 69 6e 74 6f 20 74 65 73 74 5f 73 74 65 70  E into test_step
48c0: 73 20 28 74 65 73 74 5f 69 64 2c 73 74 65 70 6e  s (test_id,stepn
48d0: 61 6d 65 2c 73 74 61 74 65 2c 73 74 61 74 75 73  ame,state,status
48e0: 2c 65 76 65 6e 74 5f 74 69 6d 65 2c 63 6f 6d 6d  ,event_time,comm
48f0: 65 6e 74 29 20 56 41 4c 55 45 53 28 3f 2c 3f 2c  ent) VALUES(?,?,
4900: 3f 2c 3f 2c 73 74 72 66 74 69 6d 65 28 27 25 73  ?,?,strftime('%s
4910: 27 2c 27 6e 6f 77 27 29 2c 3f 29 3b 22 0a 09 09  ','now'),?);"...
4920: 09 74 65 73 74 2d 69 64 20 74 65 73 74 73 74 65  .test-id testste
4930: 70 2d 6e 61 6d 65 20 73 74 61 74 65 2d 69 6e 20  p-name state-in 
4940: 73 74 61 74 75 73 2d 69 6e 20 28 69 66 20 63 6f  status-in (if co
4950: 6d 6d 65 6e 74 20 63 6f 6d 6d 65 6e 74 20 22 22  mment comment ""
4960: 29 29 29 0a 09 28 64 65 62 75 67 3a 70 72 69 6e  )))..(debug:prin
4970: 74 20 30 20 22 45 52 52 4f 52 3a 20 43 61 6e 27  t 0 "ERROR: Can'
4980: 74 20 75 70 64 61 74 65 20 22 20 74 65 73 74 2d  t update " test-
4990: 6e 61 6d 65 20 22 20 66 6f 72 20 72 75 6e 20 22  name " for run "
49a0: 20 72 75 6e 2d 69 64 20 22 20 2d 3e 20 6e 6f 20   run-id " -> no 
49b0: 73 75 63 68 20 74 65 73 74 20 69 6e 20 64 62 22  such test in db"
49c0: 29 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 74  ))))..(define (t
49d0: 65 73 74 2d 67 65 74 2d 6b 69 6c 6c 2d 72 65 71  est-get-kill-req
49e0: 75 65 73 74 20 64 62 20 72 75 6e 2d 69 64 20 74  uest db run-id t
49f0: 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 64 61 74  est-name itemdat
4a00: 29 0a 20 20 28 6c 65 74 2a 20 28 28 69 74 65 6d  ).  (let* ((item
4a10: 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c 69 73 74  -path (item-list
4a20: 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74 29 29  ->path itemdat))
4a30: 0a 09 20 28 74 65 73 74 64 61 74 20 20 20 28 64  .. (testdat   (d
4a40: 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20  b:get-test-info 
4a50: 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e  db run-id test-n
4a60: 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29 29  ame item-path)))
4a70: 0a 20 20 20 20 28 65 71 75 61 6c 3f 20 28 74 65  .    (equal? (te
4a80: 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73  st:get-state tes
4a90: 74 64 61 74 29 20 22 4b 49 4c 4c 52 45 51 22 29  tdat) "KILLREQ")
4aa0: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73  ))..(define (tes
4ab0: 74 2d 73 65 74 2d 6d 65 74 61 2d 69 6e 66 6f 20  t-set-meta-info 
4ac0: 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 6e 61  db run-id testna
4ad0: 6d 65 20 69 74 65 6d 64 61 74 29 0a 20 20 28 6c  me itemdat).  (l
4ae0: 65 74 20 28 28 69 74 65 6d 2d 70 61 74 68 20 28  et ((item-path (
4af0: 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20  item-list->path 
4b00: 69 74 65 6d 64 61 74 29 29 0a 09 28 63 70 75 6c  itemdat))..(cpul
4b10: 6f 61 64 20 20 28 67 65 74 2d 63 70 75 2d 6c 6f  oad  (get-cpu-lo
4b20: 61 64 29 29 0a 09 28 68 6f 73 74 6e 61 6d 65 20  ad))..(hostname 
4b30: 28 67 65 74 2d 68 6f 73 74 2d 6e 61 6d 65 29 29  (get-host-name))
4b40: 0a 09 28 64 69 73 6b 66 72 65 65 20 28 67 65 74  ..(diskfree (get
4b50: 2d 64 66 20 28 63 75 72 72 65 6e 74 2d 64 69 72  -df (current-dir
4b60: 65 63 74 6f 72 79 29 29 29 0a 09 28 75 6e 61 6d  ectory)))..(unam
4b70: 65 20 20 20 20 28 67 65 74 2d 75 6e 61 6d 65 20  e    (get-uname 
4b80: 22 2d 73 72 76 70 69 6f 22 29 29 0a 09 28 72 75  "-srvpio"))..(ru
4b90: 6e 70 61 74 68 20 20 28 63 75 72 72 65 6e 74 2d  npath  (current-
4ba0: 64 69 72 65 63 74 6f 72 79 29 29 29 0a 20 20 20  directory))).   
4bb0: 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74   (sqlite3:execut
4bc0: 65 20 64 62 20 22 55 50 44 41 54 45 20 74 65 73  e db "UPDATE tes
4bd0: 74 73 20 53 45 54 20 68 6f 73 74 3d 3f 2c 63 70  ts SET host=?,cp
4be0: 75 6c 6f 61 64 3d 3f 2c 64 69 73 6b 66 72 65 65  uload=?,diskfree
4bf0: 3d 3f 2c 75 6e 61 6d 65 3d 3f 2c 72 75 6e 64 69  =?,uname=?,rundi
4c00: 72 3d 3f 20 57 48 45 52 45 20 72 75 6e 5f 69 64  r=? WHERE run_id
4c10: 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d  =? AND testname=
4c20: 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d  ? AND item_path=
4c30: 3f 3b 22 0a 09 09 20 20 68 6f 73 74 6e 61 6d 65  ?;"...  hostname
4c40: 0a 09 09 20 20 63 70 75 6c 6f 61 64 0a 09 09 20  ...  cpuload... 
4c50: 20 64 69 73 6b 66 72 65 65 0a 09 09 20 20 75 6e   diskfree...  un
4c60: 61 6d 65 0a 09 09 20 20 72 75 6e 70 61 74 68 0a  ame...  runpath.
4c70: 09 09 20 20 72 75 6e 2d 69 64 0a 09 09 20 20 74  ..  run-id...  t
4c80: 65 73 74 6e 61 6d 65 0a 09 09 20 20 69 74 65 6d  estname...  item
4c90: 2d 70 61 74 68 29 29 29 0a 0a 28 64 65 66 69 6e  -path)))..(defin
4ca0: 65 20 28 74 65 73 74 2d 75 70 64 61 74 65 2d 6d  e (test-update-m
4cb0: 65 74 61 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d  eta-info db run-
4cc0: 69 64 20 74 65 73 74 6e 61 6d 65 20 69 74 65 6d  id testname item
4cd0: 64 61 74 20 6d 69 6e 75 74 65 73 20 63 70 75 6c  dat minutes cpul
4ce0: 6f 61 64 20 64 69 73 6b 66 72 65 65 20 74 6d 70  oad diskfree tmp
4cf0: 66 72 65 65 29 0a 20 20 28 6c 65 74 20 28 28 69  free).  (let ((i
4d00: 74 65 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c  tem-path (item-l
4d10: 69 73 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61  ist->path itemda
4d20: 74 29 29 29 0a 20 20 20 20 28 69 66 20 28 6e 6f  t))).    (if (no
4d30: 74 20 69 74 65 6d 2d 70 61 74 68 29 28 62 65 67  t item-path)(beg
4d40: 69 6e 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20  in (debug:print 
4d50: 30 20 22 57 41 52 4e 49 4e 47 3a 20 49 54 45 4d  0 "WARNING: ITEM
4d60: 50 41 54 48 20 6e 6f 74 20 73 65 74 2e 22 29 20  PATH not set.") 
4d70: 20 20 28 73 65 74 21 20 69 74 65 6d 2d 70 61 74    (set! item-pat
4d80: 68 20 22 22 29 29 29 0a 20 20 20 20 3b 3b 20 28  h ""))).    ;; (
4d90: 6c 65 74 20 28 28 74 65 73 74 69 6e 66 6f 20 28  let ((testinfo (
4da0: 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f  db:get-test-info
4db0: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 6e   db run-id testn
4dc0: 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29 29  ame item-path)))
4dd0: 0a 20 20 20 20 3b 3b 20 20 20 28 69 66 20 28 61  .    ;;   (if (a
4de0: 6e 64 20 28 6e 6f 74 20 28 65 71 75 61 6c 3f 20  nd (not (equal? 
4df0: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 73 74 61  (db:test-get-sta
4e00: 74 75 73 20 74 65 73 74 69 6e 66 6f 29 20 22 43  tus testinfo) "C
4e10: 4f 4d 50 4c 45 54 45 44 22 29 29 0a 20 20 20 20  OMPLETED")).    
4e20: 3b 3b 20 20 20 20 20 20 20 20 20 20 20 20 28 6e  ;;            (n
4e30: 6f 74 20 28 65 71 75 61 6c 3f 20 28 64 62 3a 74  ot (equal? (db:t
4e40: 65 73 74 2d 67 65 74 2d 73 74 61 74 75 73 20 74  est-get-status t
4e50: 65 73 74 69 6e 66 6f 29 20 22 4b 49 4c 4c 52 45  estinfo) "KILLRE
4e60: 51 22 29 29 0a 20 20 20 20 28 73 71 6c 69 74 65  Q")).    (sqlite
4e70: 33 3a 65 78 65 63 75 74 65 0a 20 20 20 20 20 64  3:execute.     d
4e80: 62 0a 20 20 20 20 20 22 55 50 44 41 54 45 20 74  b.     "UPDATE t
4e90: 65 73 74 73 20 53 45 54 20 63 70 75 6c 6f 61 64  ests SET cpuload
4ea0: 3d 3f 2c 64 69 73 6b 66 72 65 65 3d 3f 2c 72 75  =?,diskfree=?,ru
4eb0: 6e 5f 64 75 72 61 74 69 6f 6e 3d 3f 2c 73 74 61  n_duration=?,sta
4ec0: 74 65 3d 27 52 55 4e 4e 49 4e 47 27 20 57 48 45  te='RUNNING' WHE
4ed0: 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20  RE run_id=? AND 
4ee0: 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69  testname=? AND i
4ef0: 74 65 6d 5f 70 61 74 68 3d 3f 20 41 4e 44 20 73  tem_path=? AND s
4f00: 74 61 74 65 20 4e 4f 54 20 49 4e 20 28 27 43 4f  tate NOT IN ('CO
4f10: 4d 50 4c 45 54 45 44 27 2c 27 4b 49 4c 4c 52 45  MPLETED','KILLRE
4f20: 51 27 2c 27 4b 49 4c 4c 45 44 27 29 3b 22 0a 20  Q','KILLED');". 
4f30: 20 20 20 20 63 70 75 6c 6f 61 64 0a 20 20 20 20      cpuload.    
4f40: 20 64 69 73 6b 66 72 65 65 0a 20 20 20 20 20 6d   diskfree.     m
4f50: 69 6e 75 74 65 73 0a 20 20 20 20 20 72 75 6e 2d  inutes.     run-
4f60: 69 64 0a 20 20 20 20 20 74 65 73 74 6e 61 6d 65  id.     testname
4f70: 0a 20 20 20 20 20 69 74 65 6d 2d 70 61 74 68 29  .     item-path)
4f80: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 73 65 74  ))..(define (set
4f90: 2d 6d 65 67 61 74 65 73 74 2d 65 6e 76 2d 76 61  -megatest-env-va
4fa0: 72 73 20 64 62 20 72 75 6e 2d 69 64 29 0a 20 20  rs db run-id).  
4fb0: 28 6c 65 74 20 28 28 6b 65 79 73 20 28 64 62 2d  (let ((keys (db-
4fc0: 67 65 74 2d 6b 65 79 73 20 64 62 29 29 29 0a 20  get-keys db))). 
4fd0: 20 20 20 28 66 6f 72 2d 65 61 63 68 20 28 6c 61     (for-each (la
4fe0: 6d 62 64 61 20 28 6b 65 79 29 0a 09 09 28 73 71  mbda (key)...(sq
4ff0: 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72  lite3:for-each-r
5000: 6f 77 0a 09 09 20 28 6c 61 6d 62 64 61 20 28 76  ow... (lambda (v
5010: 61 6c 29 0a 09 09 20 20 20 28 64 65 62 75 67 3a  al)...   (debug:
5020: 70 72 69 6e 74 20 32 20 22 73 65 74 65 6e 76 20  print 2 "setenv 
5030: 22 20 28 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64  " (key:get-field
5040: 6e 61 6d 65 20 6b 65 79 29 20 22 20 22 20 76 61  name key) " " va
5050: 6c 29 0a 09 09 20 20 20 28 73 65 74 65 6e 76 20  l)...   (setenv 
5060: 28 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64 6e 61  (key:get-fieldna
5070: 6d 65 20 6b 65 79 29 20 76 61 6c 29 29 0a 09 09  me key) val))...
5080: 20 64 62 20 0a 09 09 20 28 63 6f 6e 63 20 22 53   db ... (conc "S
5090: 45 4c 45 43 54 20 22 20 28 6b 65 79 3a 67 65 74  ELECT " (key:get
50a0: 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65 79 29 20  -fieldname key) 
50b0: 22 20 46 52 4f 4d 20 72 75 6e 73 20 57 48 45 52  " FROM runs WHER
50c0: 45 20 69 64 3d 3f 3b 22 29 0a 09 09 20 72 75 6e  E id=?;")... run
50d0: 2d 69 64 29 29 0a 09 20 20 20 20 20 20 6b 65 79  -id))..      key
50e0: 73 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 73  s)))..(define (s
50f0: 65 74 2d 69 74 65 6d 2d 65 6e 76 2d 76 61 72 73  et-item-env-vars
5100: 20 69 74 65 6d 64 61 74 29 0a 20 20 28 66 6f 72   itemdat).  (for
5110: 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 20 28 69  -each (lambda (i
5120: 74 65 6d 29 0a 09 20 20 20 20 20 20 28 64 65 62  tem)..      (deb
5130: 75 67 3a 70 72 69 6e 74 20 32 20 22 73 65 74 65  ug:print 2 "sete
5140: 6e 76 20 22 20 28 63 61 72 20 69 74 65 6d 29 20  nv " (car item) 
5150: 22 20 22 20 28 63 61 64 72 20 69 74 65 6d 29 29  " " (cadr item))
5160: 0a 09 20 20 20 20 20 20 28 73 65 74 65 6e 76 20  ..      (setenv 
5170: 28 63 61 72 20 69 74 65 6d 29 20 28 63 61 64 72  (car item) (cadr
5180: 20 69 74 65 6d 29 29 29 0a 09 20 20 20 20 69 74   item)))..    it
5190: 65 6d 64 61 74 29 29 0a 0a 28 64 65 66 69 6e 65  emdat))..(define
51a0: 20 28 67 65 74 2d 61 6c 6c 2d 6c 65 67 61 6c 2d   (get-all-legal-
51b0: 74 65 73 74 73 29 0a 20 20 28 6c 65 74 2a 20 28  tests).  (let* (
51c0: 28 74 65 73 74 73 20 20 28 67 6c 6f 62 20 28 63  (tests  (glob (c
51d0: 6f 6e 63 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f  onc *toppath* "/
51e0: 74 65 73 74 73 2f 2a 22 29 29 29 0a 09 20 28 72  tests/*"))).. (r
51f0: 65 73 20 20 20 20 27 28 29 29 29 0a 20 20 20 20  es    '())).    
5200: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22  (debug:print 4 "
5210: 49 4e 46 4f 3a 20 4c 6f 6f 6b 69 6e 67 20 61 74  INFO: Looking at
5220: 20 74 65 73 74 73 20 22 20 28 73 74 72 69 6e 67   tests " (string
5230: 2d 69 6e 74 65 72 73 70 65 72 73 65 20 74 65 73  -intersperse tes
5240: 74 73 20 22 2c 22 29 29 0a 20 20 20 20 28 66 6f  ts ",")).    (fo
5250: 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 20 28  r-each (lambda (
5260: 74 65 73 74 70 61 74 68 29 0a 09 09 28 69 66 20  testpath)...(if 
5270: 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 28 63  (file-exists? (c
5280: 6f 6e 63 20 74 65 73 74 70 61 74 68 20 22 2f 74  onc testpath "/t
5290: 65 73 74 63 6f 6e 66 69 67 22 29 29 0a 09 09 20  estconfig"))... 
52a0: 20 20 20 28 73 65 74 21 20 72 65 73 20 28 63 6f     (set! res (co
52b0: 6e 73 20 28 6c 61 73 74 20 28 73 74 72 69 6e 67  ns (last (string
52c0: 2d 73 70 6c 69 74 20 74 65 73 74 70 61 74 68 20  -split testpath 
52d0: 22 2f 22 29 29 20 72 65 73 29 29 29 29 0a 09 20  "/")) res)))).. 
52e0: 20 20 20 20 20 74 65 73 74 73 29 0a 20 20 20 20       tests).    
52f0: 72 65 73 29 29 0a 0a 28 64 65 66 69 6e 65 20 28  res))..(define (
5300: 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72  runs:can-run-mor
5310: 65 2d 74 65 73 74 73 20 64 62 29 0a 20 20 28 6c  e-tests db).  (l
5320: 65 74 20 28 28 6e 75 6d 2d 72 75 6e 6e 69 6e 67  et ((num-running
5330: 20 28 64 62 3a 67 65 74 2d 63 6f 75 6e 74 2d 74   (db:get-count-t
5340: 65 73 74 73 2d 72 75 6e 6e 69 6e 67 20 64 62 29  ests-running db)
5350: 29 0a 09 28 6d 61 78 2d 63 6f 6e 63 75 72 72 65  )..(max-concurre
5360: 6e 74 2d 6a 6f 62 73 20 28 63 6f 6e 66 69 67 2d  nt-jobs (config-
5370: 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67 64 61  lookup *configda
5380: 74 2a 20 22 73 65 74 75 70 22 20 22 6d 61 78 5f  t* "setup" "max_
5390: 63 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f 62 73 22  concurrent_jobs"
53a0: 29 29 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70  ))).    (debug:p
53b0: 72 69 6e 74 20 32 20 22 6d 61 78 2d 63 6f 6e 63  rint 2 "max-conc
53c0: 75 72 72 65 6e 74 2d 6a 6f 62 73 3a 20 22 20 6d  urrent-jobs: " m
53d0: 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f  ax-concurrent-jo
53e0: 62 73 20 22 2c 20 6e 75 6d 2d 72 75 6e 6e 69 6e  bs ", num-runnin
53f0: 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67  g: " num-running
5400: 29 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28  ).    (if (not (
5410: 65 71 3f 20 30 20 2a 67 6c 6f 62 61 6c 65 78 69  eq? 0 *globalexi
5420: 74 73 74 61 74 75 73 2a 29 29 0a 09 23 66 0a 09  tstatus*))..#f..
5430: 28 69 66 20 28 6f 72 20 28 6e 6f 74 20 6d 61 78  (if (or (not max
5440: 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73  -concurrent-jobs
5450: 29 0a 09 09 28 61 6e 64 20 6d 61 78 2d 63 6f 6e  )...(and max-con
5460: 63 75 72 72 65 6e 74 2d 6a 6f 62 73 0a 09 09 20  current-jobs... 
5470: 20 20 20 20 28 73 74 72 69 6e 67 2d 3e 6e 75 6d      (string->num
5480: 62 65 72 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65  ber max-concurre
5490: 6e 74 2d 6a 6f 62 73 29 0a 09 09 20 20 20 20 20  nt-jobs)...     
54a0: 28 6e 6f 74 20 28 3e 3d 20 6e 75 6d 2d 72 75 6e  (not (>= num-run
54b0: 6e 69 6e 67 20 28 73 74 72 69 6e 67 2d 3e 6e 75  ning (string->nu
54c0: 6d 62 65 72 20 6d 61 78 2d 63 6f 6e 63 75 72 72  mber max-concurr
54d0: 65 6e 74 2d 6a 6f 62 73 29 29 29 29 29 0a 09 20  ent-jobs))))).. 
54e0: 20 20 20 23 74 0a 09 20 20 20 20 28 62 65 67 69     #t..    (begi
54f0: 6e 20 0a 09 20 20 20 20 20 20 28 64 65 62 75 67  n ..      (debug
5500: 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e  :print 0 "WARNIN
5510: 47 3a 20 4d 61 78 20 72 75 6e 6e 69 6e 67 20 6a  G: Max running j
5520: 6f 62 73 20 65 78 63 65 65 64 65 64 2c 20 63 75  obs exceeded, cu
5530: 72 72 65 6e 74 20 6e 75 6d 62 65 72 20 72 75 6e  rrent number run
5540: 6e 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e  ning: " num-runn
5550: 69 6e 67 20 0a 09 09 09 20 20 20 22 2c 20 6d 61  ing ....   ", ma
5560: 78 5f 63 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f 62  x_concurrent_job
5570: 73 3a 20 22 20 6d 61 78 2d 63 6f 6e 63 75 72 72  s: " max-concurr
5580: 65 6e 74 2d 6a 6f 62 73 29 0a 09 20 20 20 20 20  ent-jobs)..     
5590: 20 23 66 29 29 29 29 29 0a 20 20 0a 28 64 65 66   #f))))).  .(def
55a0: 69 6e 65 20 28 72 75 6e 2d 74 65 73 74 73 20 64  ine (run-tests d
55b0: 62 20 74 65 73 74 2d 6e 61 6d 65 73 29 0a 20 20  b test-names).  
55c0: 28 6c 65 74 2a 20 28 28 6b 65 79 73 20 20 20 20  (let* ((keys    
55d0: 20 20 20 20 28 64 62 2d 67 65 74 2d 6b 65 79 73      (db-get-keys
55e0: 20 64 62 29 29 0a 09 20 28 6b 65 79 76 61 6c 6c   db)).. (keyvall
55f0: 73 74 20 20 20 28 6b 65 79 73 2d 3e 76 61 6c 6c  st   (keys->vall
5600: 69 73 74 20 6b 65 79 73 20 23 74 29 29 0a 09 20  ist keys #t)).. 
5610: 28 72 75 6e 2d 69 64 20 20 20 20 20 20 28 72 65  (run-id      (re
5620: 67 69 73 74 65 72 2d 72 75 6e 20 64 62 20 6b 65  gister-run db ke
5630: 79 73 29 29 20 20 3b 3b 20 20 74 65 73 74 2d 6e  ys))  ;;  test-n
5640: 61 6d 65 29 29 29 0a 09 20 28 64 65 66 65 72 72  ame))).. (deferr
5650: 65 64 20 20 20 20 27 28 29 29 29 20 3b 3b 20 64  ed    '())) ;; d
5660: 65 6c 61 79 20 72 75 6e 6e 69 6e 67 20 74 68 65  elay running the
5670: 73 65 20 73 69 6e 63 65 20 74 68 65 79 20 68 61  se since they ha
5680: 76 65 20 61 20 77 61 69 74 6f 6e 20 63 6c 61 75  ve a waiton clau
5690: 73 65 0a 20 20 20 20 3b 3b 20 6f 6e 20 74 68 65  se.    ;; on the
56a0: 20 66 69 72 73 74 20 70 61 73 73 20 6f 72 20 63   first pass or c
56b0: 61 6c 6c 20 74 6f 20 72 75 6e 2d 74 65 73 74 73  all to run-tests
56c0: 20 73 65 74 20 46 41 49 4c 53 20 74 6f 20 4e 4f   set FAILS to NO
56d0: 54 5f 53 54 41 52 54 45 44 20 69 66 0a 20 20 20  T_STARTED if.   
56e0: 20 3b 3b 20 2d 6b 65 65 70 67 6f 69 6e 67 20 69   ;; -keepgoing i
56f0: 73 20 73 70 65 63 69 66 69 65 64 0a 20 20 20 20  s specified.    
5700: 28 69 66 20 28 61 6e 64 20 28 65 71 3f 20 2a 70  (if (and (eq? *p
5710: 61 73 73 6e 75 6d 2a 20 30 29 0a 09 20 20 20 20  assnum* 0)..    
5720: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22   (args:get-arg "
5730: 2d 6b 65 65 70 67 6f 69 6e 67 22 29 29 0a 09 28  -keepgoing"))..(
5740: 62 65 67 69 6e 0a 09 20 20 3b 3b 20 68 61 76 65  begin..  ;; have
5750: 20 74 6f 20 64 65 6c 65 74 65 20 74 65 73 74 20   to delete test 
5760: 72 65 63 6f 72 64 73 20 77 68 65 72 65 20 4e 4f  records where NO
5770: 54 5f 53 54 41 52 54 45 44 20 73 69 6e 63 65 20  T_STARTED since 
5780: 74 68 65 79 20 63 61 6e 20 63 61 75 73 65 20 2d  they can cause -
5790: 6b 65 65 70 67 6f 69 6e 67 20 74 6f 20 0a 09 20  keepgoing to .. 
57a0: 20 3b 3b 20 67 65 74 20 73 74 75 63 6b 20 64 75   ;; get stuck du
57b0: 65 20 74 6f 20 62 65 63 6f 6d 69 6e 67 20 69 6e  e to becoming in
57c0: 61 63 63 65 73 73 69 62 6c 65 20 66 72 6f 6d 20  accessible from 
57d0: 61 20 66 61 69 6c 65 64 20 74 65 73 74 2e 20 49  a failed test. I
57e0: 2e 65 2e 20 69 66 20 74 65 73 74 20 42 20 64 65  .e. if test B de
57f0: 70 65 6e 64 73 20 0a 09 20 20 3b 3b 20 6f 6e 20  pends ..  ;; on 
5800: 74 65 73 74 20 41 20 62 75 74 20 74 65 73 74 20  test A but test 
5810: 42 20 72 65 61 63 68 65 64 20 74 68 65 20 70 6f  B reached the po
5820: 69 6e 74 20 6f 6e 20 62 65 69 6e 67 20 72 65 67  int on being reg
5830: 69 73 74 65 72 65 64 20 61 73 20 4e 4f 54 5f 53  istered as NOT_S
5840: 54 41 52 54 45 44 20 61 6e 64 20 74 65 73 74 0a  TARTED and test.
5850: 09 20 20 3b 3b 20 41 20 66 61 69 6c 65 64 20 66  .  ;; A failed f
5860: 6f 72 20 73 6f 6d 65 20 72 65 61 73 6f 6e 20 74  or some reason t
5870: 68 65 6e 20 6f 6e 20 72 65 2d 72 75 6e 20 75 73  hen on re-run us
5880: 69 6e 67 20 2d 6b 65 65 70 67 6f 69 6e 67 20 74  ing -keepgoing t
5890: 68 65 20 72 75 6e 20 63 61 6e 20 6e 65 76 65 72  he run can never
58a0: 20 63 6f 6d 70 6c 65 74 65 2e 0a 09 20 20 28 64   complete...  (d
58b0: 62 3a 64 65 6c 65 74 65 2d 74 65 73 74 73 2d 69  b:delete-tests-i
58c0: 6e 2d 73 74 61 74 65 20 64 62 20 72 75 6e 2d 69  n-state db run-i
58d0: 64 20 22 4e 4f 54 5f 53 54 41 52 54 45 44 22 29  d "NOT_STARTED")
58e0: 0a 09 20 20 28 64 62 3a 73 65 74 2d 74 65 73 74  ..  (db:set-test
58f0: 73 2d 73 74 61 74 65 2d 73 74 61 74 75 73 20 64  s-state-status d
5900: 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  b run-id test-na
5910: 6d 65 73 20 23 66 20 22 46 41 49 4c 22 20 22 4e  mes #f "FAIL" "N
5920: 4f 54 5f 53 54 41 52 54 45 44 22 20 22 46 41 49  OT_STARTED" "FAI
5930: 4c 22 29 29 29 0a 20 20 20 20 28 73 65 74 21 20  L"))).    (set! 
5940: 2a 70 61 73 73 6e 75 6d 2a 20 28 2b 20 2a 70 61  *passnum* (+ *pa
5950: 73 73 6e 75 6d 2a 20 31 29 29 0a 20 20 20 20 28  ssnum* 1)).    (
5960: 6c 65 74 20 6c 6f 6f 70 20 28 28 6e 75 6d 74 69  let loop ((numti
5970: 6d 65 73 20 30 29 29 0a 20 20 20 20 20 20 28 66  mes 0)).      (f
5980: 6f 72 2d 65 61 63 68 20 0a 20 20 20 20 20 20 20  or-each .       
5990: 28 6c 61 6d 62 64 61 20 28 74 65 73 74 2d 6e 61  (lambda (test-na
59a0: 6d 65 29 0a 09 20 28 69 66 20 28 72 75 6e 73 3a  me).. (if (runs:
59b0: 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65 73  can-run-more-tes
59c0: 74 73 20 64 62 29 0a 09 20 20 20 20 20 28 72 75  ts db)..     (ru
59d0: 6e 2d 6f 6e 65 2d 74 65 73 74 20 64 62 20 72 75  n-one-test db ru
59e0: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 6b  n-id test-name k
59f0: 65 79 76 61 6c 6c 73 74 29 0a 09 20 20 20 20 20  eyvallst)..     
5a00: 3b 3b 20 61 64 64 20 73 6f 6d 65 20 64 65 6c 61  ;; add some dela
5a10: 79 20 0a 09 20 20 20 20 20 3b 28 73 6c 65 65 70  y ..     ;(sleep
5a20: 20 32 29 0a 09 20 20 20 20 20 29 29 0a 20 20 20   2)..     )).   
5a30: 20 20 20 20 74 65 73 74 2d 6e 61 6d 65 73 29 0a      test-names).
5a40: 20 20 20 20 20 20 3b 3b 20 28 72 75 6e 2d 77 61        ;; (run-wa
5a50: 69 74 69 6e 67 2d 74 65 73 74 73 20 64 62 29 0a  iting-tests db).
5a60: 20 20 20 20 20 20 28 69 66 20 28 61 72 67 73 3a        (if (args:
5a70: 67 65 74 2d 61 72 67 20 22 2d 6b 65 65 70 67 6f  get-arg "-keepgo
5a80: 69 6e 67 22 29 0a 09 20 20 28 6c 65 74 20 28 28  ing")..  (let ((
5a90: 65 73 74 72 65 6d 20 28 64 62 3a 65 73 74 69 6d  estrem (db:estim
5aa0: 61 74 65 64 2d 74 65 73 74 73 2d 72 65 6d 61 69  ated-tests-remai
5ab0: 6e 69 6e 67 20 64 62 20 72 75 6e 2d 69 64 29 29  ning db run-id))
5ac0: 29 0a 09 20 20 20 20 28 69 66 20 28 61 6e 64 20  )..    (if (and 
5ad0: 28 3e 20 65 73 74 72 65 6d 20 30 29 0a 09 09 20  (> estrem 0)... 
5ae0: 20 20 20 20 28 65 71 3f 20 2a 67 6c 6f 62 61 6c      (eq? *global
5af0: 65 78 69 74 73 74 61 74 75 73 2a 20 30 29 29 0a  exitstatus* 0)).
5b00: 09 09 28 62 65 67 69 6e 0a 09 09 20 20 28 64 65  ..(begin...  (de
5b10: 62 75 67 3a 70 72 69 6e 74 20 31 20 22 4b 65 65  bug:print 1 "Kee
5b20: 70 20 67 6f 69 6e 67 2c 20 65 73 74 69 6d 61 74  p going, estimat
5b30: 65 64 20 22 20 65 73 74 72 65 6d 20 22 20 74 65  ed " estrem " te
5b40: 73 74 73 20 72 65 6d 61 69 6e 69 6e 67 20 74 6f  sts remaining to
5b50: 20 72 75 6e 2c 20 77 69 6c 6c 20 63 6f 6e 74 69   run, will conti
5b60: 6e 75 65 20 69 6e 20 33 20 73 65 63 6f 6e 64 73  nue in 3 seconds
5b70: 20 2e 2e 2e 22 29 0a 09 09 20 20 28 73 6c 65 65   ...")...  (slee
5b80: 70 20 33 29 0a 09 09 20 20 28 72 75 6e 2d 77 61  p 3)...  (run-wa
5b90: 69 74 69 6e 67 2d 74 65 73 74 73 20 64 62 29 0a  iting-tests db).
5ba0: 09 09 20 20 28 6c 6f 6f 70 20 28 2b 20 6e 75 6d  ..  (loop (+ num
5bb0: 74 69 6d 65 73 20 31 29 29 29 29 29 29 29 29 29  times 1)))))))))
5bc0: 0a 09 20 20 20 0a 3b 3b 20 56 45 52 59 20 49 4e  ..   .;; VERY IN
5bd0: 45 46 46 49 43 49 45 4e 54 21 20 4d 6f 76 65 20  EFFICIENT! Move 
5be0: 73 74 75 66 66 20 74 68 61 74 20 73 68 6f 75 6c  stuff that shoul
5bf0: 64 20 62 65 20 64 6f 6e 65 20 6f 6e 63 65 20 75  d be done once u
5c00: 70 20 74 6f 20 63 61 6c 6c 69 6e 67 20 70 72 6f  p to calling pro
5c10: 63 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 2d 6f  c.(define (run-o
5c20: 6e 65 2d 74 65 73 74 20 64 62 20 72 75 6e 2d 69  ne-test db run-i
5c30: 64 20 74 65 73 74 2d 6e 61 6d 65 20 6b 65 79 76  d test-name keyv
5c40: 61 6c 6c 73 74 29 0a 20 20 28 64 65 62 75 67 3a  allst).  (debug:
5c50: 70 72 69 6e 74 20 31 20 22 4c 61 75 6e 63 68 69  print 1 "Launchi
5c60: 6e 67 20 74 65 73 74 20 22 20 74 65 73 74 2d 6e  ng test " test-n
5c70: 61 6d 65 29 0a 20 20 3b 3b 20 41 6c 6c 20 74 68  ame).  ;; All th
5c80: 65 73 65 20 76 61 72 73 20 6d 69 67 68 74 20 62  ese vars might b
5c90: 65 20 72 65 66 65 72 65 6e 63 65 64 20 62 79 20  e referenced by 
5ca0: 74 68 65 20 74 65 73 74 63 6f 6e 66 69 67 20 66  the testconfig f
5cb0: 69 6c 65 20 72 65 61 64 65 72 0a 20 20 28 73 65  ile reader.  (se
5cc0: 74 65 6e 76 20 22 4d 54 5f 54 45 53 54 5f 4e 41  tenv "MT_TEST_NA
5cd0: 4d 45 22 20 74 65 73 74 2d 6e 61 6d 65 29 20 3b  ME" test-name) ;
5ce0: 3b 20 0a 20 20 28 73 65 74 65 6e 76 20 22 4d 54  ; .  (setenv "MT
5cf0: 5f 52 55 4e 4e 41 4d 45 22 20 20 20 28 61 72 67  _RUNNAME"   (arg
5d00: 73 3a 67 65 74 2d 61 72 67 20 22 3a 72 75 6e 6e  s:get-arg ":runn
5d10: 61 6d 65 22 29 29 0a 20 20 28 73 65 74 2d 6d 65  ame")).  (set-me
5d20: 67 61 74 65 73 74 2d 65 6e 76 2d 76 61 72 73 20  gatest-env-vars 
5d30: 64 62 20 72 75 6e 2d 69 64 29 20 3b 3b 20 74 68  db run-id) ;; th
5d40: 65 73 65 20 6d 61 79 20 62 65 20 6e 65 65 64 65  ese may be neede
5d50: 64 20 62 79 20 74 68 65 20 6c 61 75 6e 63 68 69  d by the launchi
5d60: 6e 67 20 70 72 6f 63 65 73 73 0a 20 20 28 63 68  ng process.  (ch
5d70: 61 6e 67 65 2d 64 69 72 65 63 74 6f 72 79 20 2a  ange-directory *
5d80: 74 6f 70 70 61 74 68 2a 29 0a 20 20 28 6c 65 74  toppath*).  (let
5d90: 2a 20 28 28 74 65 73 74 2d 70 61 74 68 20 20 20  * ((test-path   
5da0: 20 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74 68 2a   (conc *toppath*
5db0: 20 22 2f 74 65 73 74 73 2f 22 20 74 65 73 74 2d   "/tests/" test-
5dc0: 6e 61 6d 65 29 29 0a 09 20 28 74 65 73 74 2d 63  name)).. (test-c
5dd0: 6f 6e 66 69 67 66 20 28 63 6f 6e 63 20 74 65 73  onfigf (conc tes
5de0: 74 2d 70 61 74 68 20 22 2f 74 65 73 74 63 6f 6e  t-path "/testcon
5df0: 66 69 67 22 29 29 0a 09 20 28 74 65 73 74 65 78  fig")).. (testex
5e00: 69 73 74 73 20 20 20 28 61 6e 64 20 28 66 69 6c  ists   (and (fil
5e10: 65 2d 65 78 69 73 74 73 3f 20 74 65 73 74 2d 63  e-exists? test-c
5e20: 6f 6e 66 69 67 66 29 28 66 69 6c 65 2d 72 65 61  onfigf)(file-rea
5e30: 64 2d 61 63 63 65 73 73 3f 20 74 65 73 74 2d 63  d-access? test-c
5e40: 6f 6e 66 69 67 66 29 29 29 0a 09 20 28 74 65 73  onfigf))).. (tes
5e50: 74 2d 63 6f 6e 66 20 20 20 20 28 69 66 20 74 65  t-conf    (if te
5e60: 73 74 65 78 69 73 74 73 20 28 72 65 61 64 2d 63  stexists (read-c
5e70: 6f 6e 66 69 67 20 74 65 73 74 2d 63 6f 6e 66 69  onfig test-confi
5e80: 67 66 20 23 66 20 23 74 29 20 28 6d 61 6b 65 2d  gf #f #t) (make-
5e90: 68 61 73 68 2d 74 61 62 6c 65 29 29 29 0a 09 20  hash-table))).. 
5ea0: 28 77 61 69 74 6f 6e 20 20 20 20 20 20 20 28 6c  (waiton       (l
5eb0: 65 74 20 28 28 77 20 28 63 6f 6e 66 69 67 2d 6c  et ((w (config-l
5ec0: 6f 6f 6b 75 70 20 74 65 73 74 2d 63 6f 6e 66 20  ookup test-conf 
5ed0: 22 72 65 71 75 69 72 65 6d 65 6e 74 73 22 20 22  "requirements" "
5ee0: 77 61 69 74 6f 6e 22 29 29 29 0a 09 09 09 20 28  waiton"))).... (
5ef0: 69 66 20 28 73 74 72 69 6e 67 3f 20 77 29 28 73  if (string? w)(s
5f00: 74 72 69 6e 67 2d 73 70 6c 69 74 20 77 29 27 28  tring-split w)'(
5f10: 29 29 29 29 0a 09 20 28 74 61 67 73 20 20 20 20  )))).. (tags    
5f20: 20 20 20 20 20 28 6c 65 74 20 28 28 74 20 28 63       (let ((t (c
5f30: 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 74 65 73  onfig-lookup tes
5f40: 74 2d 63 6f 6e 66 20 22 73 65 74 75 70 22 20 22  t-conf "setup" "
5f50: 74 61 67 73 22 29 29 29 0a 09 09 09 20 3b 3b 20  tags"))).... ;; 
5f60: 77 65 20 77 61 6e 74 20 6f 75 72 20 74 61 67 73  we want our tags
5f70: 20 74 6f 20 62 65 20 73 65 70 61 72 61 74 65 64   to be separated
5f80: 20 62 79 20 63 6f 6d 6d 61 73 20 61 6e 64 20 66   by commas and f
5f90: 75 6c 6c 79 20 64 65 6c 69 6d 69 74 65 64 20 62  ully delimited b
5fa0: 79 20 63 6f 6d 6d 61 73 0a 09 09 09 20 3b 3b 20  y commas.... ;; 
5fb0: 73 6f 20 74 68 61 74 20 71 75 65 72 69 65 73 20  so that queries 
5fc0: 77 69 74 68 20 22 6c 69 6b 65 22 20 63 61 6e 20  with "like" can 
5fd0: 74 69 65 20 74 6f 20 74 68 65 20 63 6f 6d 6d 61  tie to the comma
5fe0: 73 20 61 74 20 65 69 74 68 65 72 20 65 6e 64 20  s at either end 
5ff0: 6f 66 20 65 61 63 68 20 74 61 67 0a 09 09 09 20  of each tag.... 
6000: 3b 3b 20 77 68 69 6c 65 20 61 6c 73 6f 20 61 6c  ;; while also al
6010: 6c 6f 77 69 6e 67 20 74 68 65 20 65 6e 64 20 75  lowing the end u
6020: 73 65 72 20 74 6f 20 66 72 65 65 6c 79 20 75 73  ser to freely us
6030: 65 20 73 70 61 63 65 73 20 61 6e 64 20 63 6f 6d  e spaces and com
6040: 6d 61 73 20 74 6f 20 73 65 70 61 72 61 74 65 20  mas to separate 
6050: 74 61 67 73 0a 09 09 09 20 28 69 66 20 28 73 74  tags.... (if (st
6060: 72 69 6e 67 3f 20 74 29 28 73 74 72 69 6e 67 2d  ring? t)(string-
6070: 73 75 62 73 74 69 74 75 74 65 20 28 72 65 67 65  substitute (rege
6080: 78 70 20 22 5b 2c 5c 5c 73 5d 2b 22 29 20 22 2c  xp "[,\\s]+") ",
6090: 22 20 28 63 6f 6e 63 20 22 2c 22 20 74 20 22 2c  " (conc "," t ",
60a0: 22 29 20 23 74 29 0a 09 09 09 20 20 20 20 20 27  ") #t)....     '
60b0: 28 29 29 29 29 29 0a 20 20 20 20 28 69 66 20 28  ())))).    (if (
60c0: 6e 6f 74 20 74 65 73 74 65 78 69 73 74 73 29 0a  not testexists).
60d0: 09 28 62 65 67 69 6e 0a 09 20 20 28 64 65 62 75  .(begin..  (debu
60e0: 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52  g:print 0 "ERROR
60f0: 3a 20 43 61 6e 27 74 20 66 69 6e 64 20 63 6f 6e  : Can't find con
6100: 66 69 67 20 66 69 6c 65 20 22 20 74 65 73 74 2d  fig file " test-
6110: 63 6f 6e 66 69 67 66 29 0a 09 20 20 28 65 78 69  configf)..  (exi
6120: 74 20 32 29 29 0a 09 3b 3b 20 70 75 74 20 74 6f  t 2))..;; put to
6130: 70 20 76 61 72 73 20 69 6e 74 6f 20 63 6f 6e 76  p vars into conv
6140: 65 6e 69 65 6e 74 20 76 61 72 69 61 62 6c 65 73  enient variables
6150: 20 61 6e 64 20 6f 70 65 6e 20 74 68 65 20 64 62   and open the db
6160: 0a 09 28 6c 65 74 2a 20 28 3b 3b 20 64 62 20 69  ..(let* (;; db i
6170: 73 20 61 6c 77 61 79 73 20 61 74 20 2a 74 6f 70  s always at *top
6180: 70 61 74 68 2a 2f 64 62 2f 6d 65 67 61 74 65 73  path*/db/megates
6190: 74 2e 64 62 0a 09 20 20 20 20 20 20 20 28 69 74  t.db..       (it
61a0: 65 6d 73 20 20 20 20 20 20 20 28 68 61 73 68 2d  ems       (hash-
61b0: 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c  table-ref/defaul
61c0: 74 20 74 65 73 74 2d 63 6f 6e 66 20 22 69 74 65  t test-conf "ite
61d0: 6d 73 22 20 27 28 29 29 29 0a 09 20 20 20 20 20  ms" '()))..     
61e0: 20 20 28 69 74 65 6d 73 74 61 62 6c 65 20 20 28    (itemstable  (
61f0: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64  hash-table-ref/d
6200: 65 66 61 75 6c 74 20 74 65 73 74 2d 63 6f 6e 66  efault test-conf
6210: 20 22 69 74 65 6d 73 74 61 62 6c 65 22 20 27 28   "itemstable" '(
6220: 29 29 29 0a 09 20 20 20 20 20 20 20 28 61 6c 6c  )))..       (all
6230: 69 74 65 6d 73 20 20 20 20 28 69 66 20 28 6f 72  items    (if (or
6240: 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 69 74 65   (not (null? ite
6250: 6d 73 29 29 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20  ms))(not (null? 
6260: 69 74 65 6d 73 74 61 62 6c 65 29 29 29 0a 09 09  itemstable)))...
6270: 09 09 28 61 70 70 65 6e 64 20 28 69 74 65 6d 2d  ..(append (item-
6280: 61 73 73 6f 63 2d 3e 69 74 65 6d 2d 6c 69 73 74  assoc->item-list
6290: 20 69 74 65 6d 73 29 0a 09 09 09 09 09 28 69 74   items)......(it
62a0: 65 6d 2d 74 61 62 6c 65 2d 3e 69 74 65 6d 2d 6c  em-table->item-l
62b0: 69 73 74 20 69 74 65 6d 73 74 61 62 6c 65 29 29  ist itemstable))
62c0: 0a 09 09 09 09 27 28 28 29 29 29 29 20 3b 3b 20  .....'(()))) ;; 
62d0: 61 20 6c 69 73 74 20 77 69 74 68 20 6f 6e 65 20  a list with one 
62e0: 6e 75 6c 6c 20 6c 69 73 74 20 69 73 20 61 20 74  null list is a t
62f0: 65 73 74 20 77 69 74 68 20 6e 6f 20 69 74 65 6d  est with no item
6300: 73 0a 09 20 20 20 20 20 20 20 28 72 75 6e 63 6f  s..       (runco
6310: 6e 66 69 67 66 20 20 28 63 6f 6e 63 20 20 2a 74  nfigf  (conc  *t
6320: 6f 70 70 61 74 68 2a 20 22 2f 72 75 6e 63 6f 6e  oppath* "/runcon
6330: 66 69 67 73 2e 63 6f 6e 66 69 67 22 29 29 29 0a  figs.config"))).
6340: 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20  .  (debug:print 
6350: 31 20 22 69 74 65 6d 73 3a 20 22 29 0a 09 20 20  1 "items: ")..  
6360: 28 69 66 20 28 3e 3d 20 2a 76 65 72 62 6f 73 69  (if (>= *verbosi
6370: 74 79 2a 20 31 29 28 70 70 20 61 6c 6c 69 74 65  ty* 1)(pp allite
6380: 6d 73 29 29 0a 09 20 20 28 69 66 20 28 3e 3d 20  ms))..  (if (>= 
6390: 2a 76 65 72 62 6f 73 69 74 79 2a 20 35 29 0a 09  *verbosity* 5)..
63a0: 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09 28        (begin...(
63b0: 70 72 69 6e 74 20 22 69 74 65 6d 73 3a 20 22 29  print "items: ")
63c0: 28 70 70 20 28 69 74 65 6d 2d 61 73 73 6f 63 2d  (pp (item-assoc-
63d0: 3e 69 74 65 6d 2d 6c 69 73 74 20 69 74 65 6d 73  >item-list items
63e0: 29 29 0a 09 09 28 70 72 69 6e 74 20 22 69 74 65  ))...(print "ite
63f0: 73 74 61 62 6c 65 3a 20 22 29 28 70 70 20 28 69  stable: ")(pp (i
6400: 74 65 6d 2d 74 61 62 6c 65 2d 3e 69 74 65 6d 2d  tem-table->item-
6410: 6c 69 73 74 20 69 74 65 6d 73 74 61 62 6c 65 29  list itemstable)
6420: 29 29 29 0a 09 20 20 28 69 66 20 28 61 72 67 73  )))..  (if (args
6430: 3a 67 65 74 2d 61 72 67 20 22 2d 6d 22 29 0a 09  :get-arg "-m")..
6440: 20 20 20 20 20 20 28 64 62 3a 73 65 74 2d 63 6f        (db:set-co
6450: 6d 6d 65 6e 74 2d 66 6f 72 2d 72 75 6e 20 64 62  mment-for-run db
6460: 20 72 75 6e 2d 69 64 20 28 61 72 67 73 3a 67 65   run-id (args:ge
6470: 74 2d 61 72 67 20 22 2d 6d 22 29 29 29 0a 0a 09  t-arg "-m")))...
6480: 20 20 3b 3b 20 48 65 72 65 20 69 73 20 77 68 65    ;; Here is whe
6490: 72 65 20 74 68 65 20 74 65 73 74 5f 6d 65 74 61  re the test_meta
64a0: 20 74 61 62 6c 65 20 69 73 20 62 65 73 74 20 75   table is best u
64b0: 70 64 61 74 65 64 0a 09 20 20 28 72 75 6e 73 3a  pdated..  (runs:
64c0: 75 70 64 61 74 65 2d 74 65 73 74 5f 6d 65 74 61  update-test_meta
64d0: 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 20 74 65   db test-name te
64e0: 73 74 2d 63 6f 6e 66 29 0a 0a 09 20 20 3b 3b 20  st-conf)...  ;; 
64f0: 62 72 61 69 6e 64 65 61 64 20 77 6f 72 6b 2d 61  braindead work-a
6500: 72 6f 75 6e 64 20 66 6f 72 20 70 6f 6f 72 6c 79  round for poorly
6510: 20 73 70 65 63 69 66 69 65 64 20 61 6c 6c 69 74   specified allit
6520: 65 6d 73 20 6c 69 73 74 20 42 55 47 21 21 21 20  ems list BUG!!! 
6530: 46 49 58 4d 45 0a 09 20 20 28 69 66 20 28 6e 75  FIXME..  (if (nu
6540: 6c 6c 3f 20 61 6c 6c 69 74 65 6d 73 29 28 73 65  ll? allitems)(se
6550: 74 21 20 61 6c 6c 69 74 65 6d 73 20 27 28 28 29  t! allitems '(()
6560: 29 29 29 0a 09 20 20 28 6c 65 74 20 6c 6f 6f 70  )))..  (let loop
6570: 20 28 28 69 74 65 6d 64 61 74 20 28 63 61 72 20   ((itemdat (car 
6580: 61 6c 6c 69 74 65 6d 73 29 29 0a 09 09 20 20 20  allitems))...   
6590: 20 20 28 74 61 6c 20 20 20 20 20 28 63 64 72 20    (tal     (cdr 
65a0: 61 6c 6c 69 74 65 6d 73 29 29 29 0a 09 20 20 20  allitems)))..   
65b0: 20 3b 3b 20 28 6c 61 6d 62 64 61 20 28 69 74 65   ;; (lambda (ite
65c0: 6d 64 61 74 29 20 3b 3b 3b 20 28 28 72 69 70 65  mdat) ;;; ((ripe
65d0: 6e 65 73 73 20 22 6f 76 65 72 72 69 70 65 22 29  ness "overripe")
65e0: 20 28 74 65 6d 70 65 72 61 74 75 72 65 20 22 63   (temperature "c
65f0: 6f 6f 6c 22 29 20 28 73 65 61 73 6f 6e 20 22 73  ool") (season "s
6600: 75 6d 6d 65 72 22 29 29 0a 09 20 20 20 20 3b 3b  ummer"))..    ;;
6610: 20 48 61 6e 64 6c 65 20 6c 69 73 74 73 20 6f 66   Handle lists of
6620: 20 69 74 65 6d 73 0a 09 20 20 20 20 28 6c 65 74   items..    (let
6630: 2a 20 28 28 69 74 65 6d 2d 70 61 74 68 20 20 20  * ((item-path   
6640: 20 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61    (item-list->pa
6650: 74 68 20 69 74 65 6d 64 61 74 29 29 20 3b 3b 20  th itemdat)) ;; 
6660: 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65  (string-interspe
6670: 72 73 65 20 28 6d 61 70 20 63 61 64 72 20 69 74  rse (map cadr it
6680: 65 6d 64 61 74 29 20 22 2f 22 29 29 0a 09 09 20  emdat) "/"))... 
6690: 20 20 28 6e 65 77 2d 74 65 73 74 2d 70 61 74 68    (new-test-path
66a0: 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70   (string-intersp
66b0: 65 72 73 65 20 28 63 6f 6e 73 20 74 65 73 74 2d  erse (cons test-
66c0: 70 61 74 68 20 28 6d 61 70 20 63 61 64 72 20 69  path (map cadr i
66d0: 74 65 6d 64 61 74 29 29 20 22 2f 22 29 29 0a 09  temdat)) "/"))..
66e0: 09 20 20 20 28 6e 65 77 2d 74 65 73 74 2d 6e 61  .   (new-test-na
66f0: 6d 65 20 28 69 66 20 28 65 71 75 61 6c 3f 20 69  me (if (equal? i
6700: 74 65 6d 2d 70 61 74 68 20 22 22 29 20 74 65 73  tem-path "") tes
6710: 74 2d 6e 61 6d 65 20 28 63 6f 6e 63 20 74 65 73  t-name (conc tes
6720: 74 2d 6e 61 6d 65 20 22 2f 22 20 69 74 65 6d 2d  t-name "/" item-
6730: 70 61 74 68 29 29 29 20 3b 3b 20 6a 75 73 74 20  path))) ;; just 
6740: 6e 65 65 64 20 69 74 20 74 6f 20 62 65 20 75 6e  need it to be un
6750: 69 71 75 65 0a 09 09 20 20 20 28 74 65 73 74 64  ique...   (testd
6760: 61 74 20 20 20 23 66 29 0a 09 09 20 20 20 28 6e  at   #f)...   (n
6770: 75 6d 2d 72 75 6e 6e 69 6e 67 20 28 64 62 3a 67  um-running (db:g
6780: 65 74 2d 63 6f 75 6e 74 2d 74 65 73 74 73 2d 72  et-count-tests-r
6790: 75 6e 6e 69 6e 67 20 64 62 29 29 0a 09 09 20 20  unning db))...  
67a0: 20 28 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74   (max-concurrent
67b0: 2d 6a 6f 62 73 20 28 63 6f 6e 66 69 67 2d 6c 6f  -jobs (config-lo
67c0: 6f 6b 75 70 20 2a 63 6f 6e 66 69 67 64 61 74 2a  okup *configdat*
67d0: 20 22 73 65 74 75 70 22 20 22 6d 61 78 5f 63 6f   "setup" "max_co
67e0: 6e 63 75 72 72 65 6e 74 5f 6a 6f 62 73 22 29 29  ncurrent_jobs"))
67f0: 0a 09 09 20 20 20 28 70 61 72 65 6e 74 2d 74 65  ...   (parent-te
6800: 73 74 20 28 61 6e 64 20 28 6e 6f 74 20 28 6e 75  st (and (not (nu
6810: 6c 6c 3f 20 69 74 65 6d 73 29 29 28 65 71 75 61  ll? items))(equa
6820: 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29  l? item-path "")
6830: 29 29 0a 09 09 20 20 20 28 73 69 6e 67 6c 65 2d  ))...   (single-
6840: 74 65 73 74 20 28 61 6e 64 20 28 6e 75 6c 6c 3f  test (and (null?
6850: 20 69 74 65 6d 73 29 20 28 65 71 75 61 6c 3f 20   items) (equal? 
6860: 69 74 65 6d 2d 70 61 74 68 20 22 22 29 29 29 0a  item-path ""))).
6870: 09 09 20 20 20 28 69 74 65 6d 2d 74 65 73 74 20  ..   (item-test 
6880: 20 20 28 6e 6f 74 20 28 65 71 75 61 6c 3f 20 69    (not (equal? i
6890: 74 65 6d 2d 70 61 74 68 20 22 22 29 29 29 0a 09  tem-path "")))..
68a0: 09 20 20 20 28 69 74 65 6d 2d 70 61 74 74 20 20  .   (item-patt  
68b0: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22   (args:get-arg "
68c0: 2d 69 74 65 6d 70 61 74 74 22 29 29 0a 09 09 20  -itempatt"))... 
68d0: 20 20 28 70 61 74 74 2d 6d 61 74 63 68 20 20 28    (patt-match  (
68e0: 69 66 20 69 74 65 6d 2d 70 61 74 74 0a 09 09 09  if item-patt....
68f0: 09 20 20 20 20 28 73 74 72 69 6e 67 2d 6d 61 74  .    (string-mat
6900: 63 68 20 28 67 6c 6f 62 2d 3e 72 65 67 65 78 70  ch (glob->regexp
6910: 0a 09 09 09 09 09 09 20 20 20 28 73 74 72 69 6e  .......   (strin
6920: 67 2d 74 72 61 6e 73 6c 61 74 65 20 69 74 65 6d  g-translate item
6930: 2d 70 61 74 74 20 22 25 22 20 22 2a 22 29 29 0a  -patt "%" "*")).
6940: 09 09 09 09 09 09 20 20 69 74 65 6d 2d 70 61 74  ......  item-pat
6950: 68 29 0a 09 09 09 09 20 20 20 20 23 74 29 29 29  h).....    #t)))
6960: 0a 09 20 20 20 20 20 20 28 64 65 62 75 67 3a 70  ..      (debug:p
6970: 72 69 6e 74 20 33 20 22 6d 61 78 2d 63 6f 6e 63  rint 3 "max-conc
6980: 75 72 72 65 6e 74 2d 6a 6f 62 73 3a 20 22 20 6d  urrent-jobs: " m
6990: 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f  ax-concurrent-jo
69a0: 62 73 20 22 2c 20 6e 75 6d 2d 72 75 6e 6e 69 6e  bs ", num-runnin
69b0: 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67  g: " num-running
69c0: 29 0a 09 20 20 20 20 20 20 28 69 66 20 28 61 6e  )..      (if (an
69d0: 64 20 70 61 74 74 2d 6d 61 74 63 68 20 28 72 75  d patt-match (ru
69e0: 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65 2d  ns:can-run-more-
69f0: 74 65 73 74 73 20 64 62 29 29 0a 09 09 20 20 28  tests db))...  (
6a00: 62 65 67 69 6e 0a 09 09 20 20 20 20 28 6c 65 74  begin...    (let
6a10: 20 6c 6f 6f 70 32 20 28 28 74 73 20 28 64 62 3a   loop2 ((ts (db:
6a20: 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62  get-test-info db
6a30: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
6a40: 65 20 69 74 65 6d 2d 70 61 74 68 29 29 20 3b 3b  e item-path)) ;;
6a50: 20 23 66 29 0a 09 09 09 09 28 63 74 20 30 29 29   #f).....(ct 0))
6a60: 0a 09 09 20 20 20 20 20 20 28 69 66 20 28 61 6e  ...      (if (an
6a70: 64 20 28 6e 6f 74 20 74 73 29 0a 09 09 09 20 20  d (not ts)....  
6a80: 20 20 20 20 20 28 3c 20 63 74 20 31 30 29 29 0a       (< ct 10)).
6a90: 09 09 09 20 20 28 62 65 67 69 6e 0a 09 09 09 20  ...  (begin.... 
6aa0: 20 20 20 28 72 65 67 69 73 74 65 72 2d 74 65 73     (register-tes
6ab0: 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  t db run-id test
6ac0: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  -name item-path)
6ad0: 0a 09 09 09 20 20 20 20 28 64 62 3a 74 65 73 74  ....    (db:test
6ae0: 2d 73 65 74 2d 63 6f 6d 6d 65 6e 74 20 64 62 20  -set-comment db 
6af0: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
6b00: 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29 0a 09   item-path "")..
6b10: 09 09 20 20 20 20 28 6c 6f 6f 70 32 20 28 64 62  ..    (loop2 (db
6b20: 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64  :get-test-info d
6b30: 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  b run-id test-na
6b40: 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 09  me item-path)...
6b50: 09 09 20 20 20 28 2b 20 63 74 20 31 29 29 29 0a  ..   (+ ct 1))).
6b60: 09 09 09 20 20 28 69 66 20 74 73 0a 09 09 09 20  ...  (if ts.... 
6b70: 20 20 20 20 20 28 73 65 74 21 20 74 65 73 74 64       (set! testd
6b80: 61 74 20 74 73 29 0a 09 09 09 20 20 20 20 20 20  at ts)....      
6b90: 28 62 65 67 69 6e 0a 09 09 09 09 28 64 65 62 75  (begin.....(debu
6ba0: 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e 49  g:print 0 "WARNI
6bb0: 4e 47 3a 20 43 6f 75 6c 64 6e 27 74 20 72 65 67  NG: Couldn't reg
6bc0: 69 73 74 65 72 20 74 65 73 74 20 22 20 74 65 73  ister test " tes
6bd0: 74 2d 6e 61 6d 65 20 22 20 77 69 74 68 20 69 74  t-name " with it
6be0: 65 6d 20 70 61 74 68 20 22 20 69 74 65 6d 2d 70  em path " item-p
6bf0: 61 74 68 20 22 2c 20 73 6b 69 70 70 69 6e 67 22  ath ", skipping"
6c00: 29 0a 09 09 09 09 28 69 66 20 28 6e 6f 74 20 28  ).....(if (not (
6c10: 6e 75 6c 6c 3f 20 74 61 6c 29 29 0a 09 09 09 09  null? tal)).....
6c20: 20 20 20 20 28 6c 6f 6f 70 20 28 63 61 72 20 74      (loop (car t
6c30: 61 6c 29 28 63 64 72 20 74 61 6c 29 29 29 29 29  al)(cdr tal)))))
6c40: 29 29 0a 09 09 20 20 20 20 28 63 68 61 6e 67 65  ))...    (change
6c50: 2d 64 69 72 65 63 74 6f 72 79 20 74 65 73 74 2d  -directory test-
6c60: 70 61 74 68 29 0a 09 09 20 20 20 20 3b 3b 20 74  path)...    ;; t
6c70: 68 69 73 20 62 6c 6f 63 6b 20 69 73 20 68 65 72  his block is her
6c80: 65 20 6f 6e 6c 79 20 74 6f 20 69 6e 66 6f 72 6d  e only to inform
6c90: 20 74 68 65 20 75 73 65 72 20 65 61 72 6c 79 20   the user early 
6ca0: 6f 6e 0a 09 09 20 20 20 20 28 69 66 20 28 66 69  on...    (if (fi
6cb0: 6c 65 2d 65 78 69 73 74 73 3f 20 72 75 6e 63 6f  le-exists? runco
6cc0: 6e 66 69 67 66 29 0a 09 09 09 28 73 65 74 75 70  nfigf)....(setup
6cd0: 2d 65 6e 76 2d 64 65 66 61 75 6c 74 73 20 64 62  -env-defaults db
6ce0: 20 72 75 6e 63 6f 6e 66 69 67 66 20 72 75 6e 2d   runconfigf run-
6cf0: 69 64 20 2a 61 6c 72 65 61 64 79 2d 73 65 65 6e  id *already-seen
6d00: 2d 72 75 6e 63 6f 6e 66 69 67 2d 69 6e 66 6f 2a  -runconfig-info*
6d10: 29 0a 09 09 09 28 64 65 62 75 67 3a 70 72 69 6e  )....(debug:prin
6d20: 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 59 6f  t 0 "WARNING: Yo
6d30: 75 20 64 6f 20 6e 6f 74 20 68 61 76 65 20 61 20  u do not have a 
6d40: 72 75 6e 20 63 6f 6e 66 69 67 20 66 69 6c 65 3a  run config file:
6d50: 20 22 20 72 75 6e 63 6f 6e 66 69 67 66 29 29 0a   " runconfigf)).
6d60: 09 09 20 20 20 20 28 64 65 62 75 67 3a 70 72 69  ..    (debug:pri
6d70: 6e 74 20 34 20 22 72 75 6e 2d 69 64 3a 20 22 20  nt 4 "run-id: " 
6d80: 72 75 6e 2d 69 64 20 22 20 74 65 73 74 2d 6e 61  run-id " test-na
6d90: 6d 65 3a 20 22 20 74 65 73 74 2d 6e 61 6d 65 20  me: " test-name 
6da0: 22 20 69 74 65 6d 2d 70 61 74 68 3a 20 22 20 69  " item-path: " i
6db0: 74 65 6d 2d 70 61 74 68 20 22 20 74 65 73 74 64  tem-path " testd
6dc0: 61 74 3a 20 22 20 28 74 65 73 74 3a 67 65 74 2d  at: " (test:get-
6dd0: 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29 20  status testdat) 
6de0: 22 20 74 65 73 74 2d 73 74 61 74 65 3a 20 22 20  " test-state: " 
6df0: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20  (test:get-state 
6e00: 74 65 73 74 64 61 74 29 29 0a 09 09 20 20 20 20  testdat))...    
6e10: 28 63 61 73 65 20 28 69 66 20 28 61 72 67 73 3a  (case (if (args:
6e20: 67 65 74 2d 61 72 67 20 22 2d 66 6f 72 63 65 22  get-arg "-force"
6e30: 29 0a 09 09 09 20 20 20 20 20 20 27 4e 4f 54 5f  )....      'NOT_
6e40: 53 54 41 52 54 45 44 0a 09 09 09 20 20 20 20 20  STARTED....     
6e50: 20 28 69 66 20 74 65 73 74 64 61 74 0a 09 09 09   (if testdat....
6e60: 09 20 20 28 73 74 72 69 6e 67 2d 3e 73 79 6d 62  .  (string->symb
6e70: 6f 6c 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61  ol (test:get-sta
6e80: 74 65 20 74 65 73 74 64 61 74 29 29 0a 09 09 09  te testdat))....
6e90: 09 20 20 27 66 61 69 6c 65 64 2d 74 6f 2d 69 6e  .  'failed-to-in
6ea0: 73 65 72 74 29 29 0a 09 09 20 20 20 20 20 20 28  sert))...      (
6eb0: 28 66 61 69 6c 65 64 2d 74 6f 2d 69 6e 73 65 72  (failed-to-inser
6ec0: 74 29 0a 09 09 20 20 20 20 20 20 20 28 64 65 62  t)...       (deb
6ed0: 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f  ug:print 0 "ERRO
6ee0: 52 3a 20 46 61 69 6c 65 64 20 74 6f 20 69 6e 73  R: Failed to ins
6ef0: 65 72 74 20 74 68 65 20 72 65 63 6f 72 64 20 69  ert the record i
6f00: 6e 74 6f 20 74 68 65 20 64 62 22 29 29 0a 09 09  nto the db"))...
6f10: 20 20 20 20 20 20 28 28 4e 4f 54 5f 53 54 41 52        ((NOT_STAR
6f20: 54 45 44 20 43 4f 4d 50 4c 45 54 45 44 29 0a 09  TED COMPLETED)..
6f30: 09 20 20 20 20 20 20 20 28 64 65 62 75 67 3a 70  .       (debug:p
6f40: 72 69 6e 74 20 36 20 22 47 6f 74 20 68 65 72 65  rint 6 "Got here
6f50: 2c 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74  , " (test:get-st
6f60: 61 74 65 20 74 65 73 74 64 61 74 29 29 0a 09 09  ate testdat))...
6f70: 20 20 20 20 20 20 20 28 6c 65 74 20 28 28 72 75         (let ((ru
6f80: 6e 66 6c 61 67 20 23 66 29 29 0a 09 09 09 20 28  nflag #f)).... (
6f90: 63 6f 6e 64 0a 09 09 09 20 20 3b 3b 20 69 2e 65  cond....  ;; i.e
6fa0: 2e 20 74 68 69 73 20 69 73 20 74 68 65 20 70 61  . this is the pa
6fb0: 72 65 6e 74 20 74 65 73 74 20 74 6f 20 61 20 73  rent test to a s
6fc0: 75 69 74 65 20 6f 66 20 69 74 65 6d 73 2c 20 6e  uite of items, n
6fd0: 65 76 65 72 20 22 72 75 6e 22 20 69 74 0a 09 09  ever "run" it...
6fe0: 09 20 20 28 70 61 72 65 6e 74 2d 74 65 73 74 0a  .  (parent-test.
6ff0: 09 09 09 20 20 20 28 73 65 74 21 20 72 75 6e 66  ...   (set! runf
7000: 6c 61 67 20 23 66 29 29 0a 09 09 09 20 20 3b 3b  lag #f))....  ;;
7010: 20 2d 66 6f 72 63 65 2c 20 72 75 6e 20 6e 6f 20   -force, run no 
7020: 6d 61 74 74 65 72 20 77 68 61 74 0a 09 09 09 20  matter what.... 
7030: 20 28 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20   ((args:get-arg 
7040: 22 2d 66 6f 72 63 65 22 29 28 73 65 74 21 20 72  "-force")(set! r
7050: 75 6e 66 6c 61 67 20 23 74 29 29 0a 09 09 09 20  unflag #t)).... 
7060: 20 3b 3b 20 4e 4f 54 5f 53 54 41 52 54 45 44 2c   ;; NOT_STARTED,
7070: 20 72 75 6e 20 6e 6f 20 6d 61 74 74 65 72 20 77   run no matter w
7080: 68 61 74 0a 09 09 09 20 20 28 28 65 71 75 61 6c  hat....  ((equal
7090: 3f 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74  ? (test:get-stat
70a0: 65 20 74 65 73 74 64 61 74 29 20 22 4e 4f 54 5f  e testdat) "NOT_
70b0: 53 54 41 52 54 45 44 22 29 28 73 65 74 21 20 72  STARTED")(set! r
70c0: 75 6e 66 6c 61 67 20 23 74 29 29 0a 09 09 09 20  unflag #t)).... 
70d0: 20 3b 3b 20 6e 6f 74 20 2d 72 65 72 75 6e 20 61   ;; not -rerun a
70e0: 6e 64 20 50 41 53 53 2c 20 57 41 52 4e 20 6f 72  nd PASS, WARN or
70f0: 20 43 48 45 43 4b 2c 20 64 6f 20 6e 6f 20 72 75   CHECK, do no ru
7100: 6e 0a 09 09 09 20 20 28 28 61 6e 64 20 28 6f 72  n....  ((and (or
7110: 20 28 6e 6f 74 20 28 61 72 67 73 3a 67 65 74 2d   (not (args:get-
7120: 61 72 67 20 22 2d 72 65 72 75 6e 22 29 29 0a 09  arg "-rerun"))..
7130: 09 09 09 20 20 20 20 28 61 72 67 73 3a 67 65 74  ...    (args:get
7140: 2d 61 72 67 20 22 2d 6b 65 65 70 67 6f 69 6e 67  -arg "-keepgoing
7150: 22 29 29 0a 09 09 09 09 28 6d 65 6d 62 65 72 20  ")).....(member 
7160: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73  (test:get-status
7170: 20 74 65 73 74 64 61 74 29 20 27 28 22 50 41 53   testdat) '("PAS
7180: 53 22 20 22 57 41 52 4e 22 20 22 43 48 45 43 4b  S" "WARN" "CHECK
7190: 22 29 29 29 0a 09 09 09 20 20 20 28 73 65 74 21  ")))....   (set!
71a0: 20 72 75 6e 66 6c 61 67 20 23 66 29 29 0a 09 09   runflag #f))...
71b0: 09 20 20 3b 3b 20 2d 72 65 72 75 6e 20 61 6e 64  .  ;; -rerun and
71c0: 20 73 74 61 74 75 73 20 69 73 20 6f 6e 65 20 6f   status is one o
71d0: 66 20 74 68 65 20 73 70 65 63 69 66 65 64 2c 20  f the specifed, 
71e0: 72 75 6e 20 69 74 0a 09 09 09 20 20 28 28 61 6e  run it....  ((an
71f0: 64 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20  d (args:get-arg 
7200: 22 2d 72 65 72 75 6e 22 29 0a 09 09 09 09 28 6c  "-rerun").....(l
7210: 65 74 20 28 28 72 65 72 75 6e 6c 73 74 20 28 73  et ((rerunlst (s
7220: 74 72 69 6e 67 2d 73 70 6c 69 74 20 28 61 72 67  tring-split (arg
7230: 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65 72 75  s:get-arg "-reru
7240: 6e 22 29 20 22 2c 22 29 29 29 20 3b 3b 20 46 41  n") ","))) ;; FA
7250: 49 4c 2c 0a 09 09 09 09 20 20 28 6d 65 6d 62 65  IL,.....  (membe
7260: 72 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74  r (test:get-stat
7270: 75 73 20 74 65 73 74 64 61 74 29 20 72 65 72 75  us testdat) reru
7280: 6e 6c 73 74 29 29 29 0a 09 09 09 20 20 20 28 73  nlst)))....   (s
7290: 65 74 21 20 72 75 6e 66 6c 61 67 20 23 74 29 29  et! runflag #t))
72a0: 0a 09 09 09 20 20 3b 3b 20 2d 6b 65 65 70 67 6f  ....  ;; -keepgo
72b0: 69 6e 67 2c 20 64 6f 20 6e 6f 74 20 72 65 72 75  ing, do not reru
72c0: 6e 20 46 41 49 4c 0a 09 09 09 20 20 28 28 61 6e  n FAIL....  ((an
72d0: 64 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20  d (args:get-arg 
72e0: 22 2d 6b 65 65 70 67 6f 69 6e 67 22 29 0a 09 09  "-keepgoing")...
72f0: 09 09 28 6d 65 6d 62 65 72 20 28 74 65 73 74 3a  ..(member (test:
7300: 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64  get-status testd
7310: 61 74 29 20 27 28 22 46 41 49 4c 22 29 29 29 0a  at) '("FAIL"))).
7320: 09 09 09 20 20 20 28 73 65 74 21 20 72 75 6e 66  ...   (set! runf
7330: 6c 61 67 20 23 66 29 29 0a 09 09 09 20 20 28 28  lag #f))....  ((
7340: 61 6e 64 20 28 6e 6f 74 20 28 61 72 67 73 3a 67  and (not (args:g
7350: 65 74 2d 61 72 67 20 22 2d 72 65 72 75 6e 22 29  et-arg "-rerun")
7360: 29 0a 09 09 09 09 28 6d 65 6d 62 65 72 20 28 74  ).....(member (t
7370: 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74  est:get-status t
7380: 65 73 74 64 61 74 29 20 27 28 22 46 41 49 4c 22  estdat) '("FAIL"
7390: 20 22 6e 2f 61 22 29 29 29 0a 09 09 09 20 20 20   "n/a")))....   
73a0: 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 74  (set! runflag #t
73b0: 29 29 0a 09 09 09 20 20 28 65 6c 73 65 20 28 73  ))....  (else (s
73c0: 65 74 21 20 72 75 6e 66 6c 61 67 20 23 66 29 29  et! runflag #f))
73d0: 29 0a 09 09 09 20 28 64 65 62 75 67 3a 70 72 69  ).... (debug:pri
73e0: 6e 74 20 36 20 22 52 55 4e 4e 49 4e 47 20 3d 3e  nt 6 "RUNNING =>
73f0: 20 72 75 6e 66 6c 61 67 3a 20 22 20 72 75 6e 66   runflag: " runf
7400: 6c 61 67 20 22 20 53 54 41 54 45 3a 20 22 20 28  lag " STATE: " (
7410: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74  test:get-state t
7420: 65 73 74 64 61 74 29 20 22 20 53 54 41 54 55 53  estdat) " STATUS
7430: 3a 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74  : " (test:get-st
7440: 61 74 75 73 20 74 65 73 74 64 61 74 29 29 0a 09  atus testdat))..
7450: 09 09 20 28 69 66 20 28 6e 6f 74 20 72 75 6e 66  .. (if (not runf
7460: 6c 61 67 29 0a 09 09 09 20 20 20 20 20 28 69 66  lag)....     (if
7470: 20 28 6e 6f 74 20 70 61 72 65 6e 74 2d 74 65 73   (not parent-tes
7480: 74 29 0a 09 09 09 09 20 28 64 65 62 75 67 3a 70  t)..... (debug:p
7490: 72 69 6e 74 20 31 20 22 4e 4f 54 45 3a 20 4e 6f  rint 1 "NOTE: No
74a0: 74 20 73 74 61 72 74 69 6e 67 20 74 65 73 74 20  t starting test 
74b0: 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20  " new-test-name 
74c0: 22 20 61 73 20 69 74 20 69 73 20 73 74 61 74 65  " as it is state
74d0: 20 5c 22 43 4f 4d 50 4c 45 54 45 44 5c 22 20 61   \"COMPLETED\" a
74e0: 6e 64 20 73 74 61 74 75 73 20 5c 22 22 20 28 74  nd status \"" (t
74f0: 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74  est:get-status t
7500: 65 73 74 64 61 74 29 20 22 5c 22 2c 20 75 73 65  estdat) "\", use
7510: 20 2d 66 6f 72 63 65 20 74 6f 20 6f 76 65 72 72   -force to overr
7520: 69 64 65 22 29 29 0a 09 09 09 20 20 20 20 20 28  ide"))....     (
7530: 6c 65 74 2a 20 28 28 67 65 74 2d 70 72 65 72 65  let* ((get-prere
7540: 71 73 2d 63 6d 64 20 28 6c 61 6d 62 64 61 20 28  qs-cmd (lambda (
7550: 29 0a 09 09 09 09 09 09 20 20 20 20 20 20 20 28  ).......       (
7560: 64 62 2d 67 65 74 2d 70 72 65 72 65 71 73 2d 6e  db-get-prereqs-n
7570: 6f 74 2d 6d 65 74 20 64 62 20 72 75 6e 2d 69 64  ot-met db run-id
7580: 20 77 61 69 74 6f 6e 29 29 29 20 3b 3b 20 63 68   waiton))) ;; ch
7590: 65 63 6b 20 62 65 66 6f 72 65 20 72 75 6e 6e 69  eck before runni
75a0: 6e 67 20 2e 2e 2e 2e 0a 09 09 09 09 20 20 20 20  ng .........    
75b0: 28 6c 61 75 6e 63 68 2d 63 6d 64 20 20 20 20 20  (launch-cmd     
75c0: 20 28 6c 61 6d 62 64 61 20 28 29 0a 09 09 09 09   (lambda ().....
75d0: 09 09 20 20 20 20 20 20 20 28 6c 61 75 6e 63 68  ..       (launch
75e0: 2d 74 65 73 74 20 64 62 20 72 75 6e 2d 69 64 20  -test db run-id 
75f0: 74 65 73 74 2d 63 6f 6e 66 20 6b 65 79 76 61 6c  test-conf keyval
7600: 6c 73 74 20 74 65 73 74 2d 6e 61 6d 65 20 74 65  lst test-name te
7610: 73 74 2d 70 61 74 68 20 69 74 65 6d 64 61 74 29  st-path itemdat)
7620: 29 29 0a 09 09 09 09 20 20 20 20 28 74 65 73 74  )).....    (test
7630: 72 75 6e 64 61 74 20 20 20 20 20 20 28 6c 69 73  rundat      (lis
7640: 74 20 67 65 74 2d 70 72 65 72 65 71 73 2d 63 6d  t get-prereqs-cm
7650: 64 20 6c 61 75 6e 63 68 2d 63 6d 64 29 29 29 0a  d launch-cmd))).
7660: 09 09 09 20 20 20 20 20 20 20 28 69 66 20 28 6f  ...       (if (o
7670: 72 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20  r (args:get-arg 
7680: 22 2d 66 6f 72 63 65 22 29 0a 09 09 09 09 20 20  "-force").....  
7690: 20 20 20 20 20 28 6c 65 74 20 28 28 70 72 65 71       (let ((preq
76a0: 73 2d 6e 6f 74 2d 79 65 74 2d 6d 65 74 20 28 28  s-not-yet-met ((
76b0: 63 61 72 20 74 65 73 74 72 75 6e 64 61 74 29 29  car testrundat))
76c0: 29 29 0a 09 09 09 09 09 20 28 64 65 62 75 67 3a  ))...... (debug:
76d0: 70 72 69 6e 74 20 32 20 22 50 72 65 71 72 65 71  print 2 "Preqreq
76e0: 75 65 73 69 74 65 73 20 66 6f 72 20 22 20 74 65  uesites for " te
76f0: 73 74 2d 6e 61 6d 65 20 22 3a 20 22 20 70 72 65  st-name ": " pre
7700: 71 73 2d 6e 6f 74 2d 79 65 74 2d 6d 65 74 29 0a  qs-not-yet-met).
7710: 09 09 09 09 09 20 28 6e 75 6c 6c 3f 20 70 72 65  ..... (null? pre
7720: 71 73 2d 6e 6f 74 2d 79 65 74 2d 6d 65 74 29 29  qs-not-yet-met))
7730: 29 20 3b 3b 20 61 72 65 20 74 68 65 72 65 20 61  ) ;; are there a
7740: 6e 79 20 74 65 73 74 73 20 74 68 61 74 20 6d 75  ny tests that mu
7750: 73 74 20 62 65 20 72 75 6e 20 62 65 66 6f 72 65  st be run before
7760: 20 74 68 69 73 20 6f 6e 65 2e 2e 2e 0a 09 09 09   this one.......
7770: 09 20 20 20 28 69 66 20 28 6e 6f 74 20 28 28 63  .   (if (not ((c
7780: 61 64 72 20 74 65 73 74 72 75 6e 64 61 74 29 29  adr testrundat))
7790: 29 20 3b 3b 20 74 68 69 73 20 69 73 20 74 68 65  ) ;; this is the
77a0: 20 6c 69 6e 65 20 74 68 61 74 20 6c 61 75 6e 63   line that launc
77b0: 68 65 73 20 74 68 65 20 74 65 73 74 20 74 6f 20  hes the test to 
77c0: 74 68 65 20 72 65 6d 6f 74 65 20 68 6f 73 74 0a  the remote host.
77d0: 09 09 09 09 20 20 20 20 20 20 20 28 62 65 67 69  ....       (begi
77e0: 6e 0a 09 09 09 09 09 20 28 70 72 69 6e 74 20 22  n...... (print "
77f0: 45 52 52 4f 52 3a 20 46 61 69 6c 65 64 20 74 6f  ERROR: Failed to
7800: 20 6c 61 75 6e 63 68 20 74 68 65 20 74 65 73 74   launch the test
7810: 2e 20 45 78 69 74 69 6e 67 20 61 73 20 73 6f 6f  . Exiting as soo
7820: 6e 20 61 73 20 70 6f 73 73 69 62 6c 65 22 29 0a  n as possible").
7830: 09 09 09 09 09 20 28 73 65 74 21 20 2a 67 6c 6f  ..... (set! *glo
7840: 62 61 6c 65 78 69 74 73 74 61 74 75 73 2a 20 31  balexitstatus* 1
7850: 29 20 3b 3b 20 0a 09 09 09 09 09 20 28 70 72 6f  ) ;; ...... (pro
7860: 63 65 73 73 2d 73 69 67 6e 61 6c 20 28 63 75 72  cess-signal (cur
7870: 72 65 6e 74 2d 70 72 6f 63 65 73 73 2d 69 64 29  rent-process-id)
7880: 20 73 69 67 6e 61 6c 2f 6b 69 6c 6c 29 0a 09 09   signal/kill)...
7890: 09 09 09 20 3b 28 65 78 69 74 20 31 29 0a 09 09  ... ;(exit 1)...
78a0: 09 09 09 20 29 29 0a 09 09 09 09 20 20 20 28 69  ... )).....   (i
78b0: 66 20 28 6e 6f 74 20 28 61 72 67 73 3a 67 65 74  f (not (args:get
78c0: 2d 61 72 67 20 22 2d 6b 65 65 70 67 6f 69 6e 67  -arg "-keepgoing
78d0: 22 29 29 0a 09 09 09 09 20 20 20 20 20 20 20 28  ")).....       (
78e0: 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74 21 20  hash-table-set! 
78f0: 2a 77 61 69 74 69 6e 67 2d 71 75 65 75 65 2a 20  *waiting-queue* 
7900: 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20 74 65  new-test-name te
7910: 73 74 72 75 6e 64 61 74 29 29 29 29 29 29 29 0a  strundat))))))).
7920: 09 09 20 20 20 20 20 20 28 28 4b 49 4c 4c 45 44  ..      ((KILLED
7930: 29 20 0a 09 09 20 20 20 20 20 20 20 28 64 65 62  ) ...       (deb
7940: 75 67 3a 70 72 69 6e 74 20 31 20 22 4e 4f 54 45  ug:print 1 "NOTE
7950: 3a 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d  : " new-test-nam
7960: 65 20 22 20 69 73 20 61 6c 72 65 61 64 79 20 72  e " is already r
7970: 75 6e 6e 69 6e 67 20 6f 72 20 77 61 73 20 65 78  unning or was ex
7980: 70 6c 69 63 74 6c 79 20 6b 69 6c 6c 65 64 2c 20  plictly killed, 
7990: 75 73 65 20 2d 66 6f 72 63 65 20 74 6f 20 6c 61  use -force to la
79a0: 75 6e 63 68 20 69 74 2e 22 29 29 0a 09 09 20 20  unch it."))...  
79b0: 20 20 20 20 28 28 4c 41 55 4e 43 48 45 44 20 52      ((LAUNCHED R
79c0: 45 4d 4f 54 45 48 4f 53 54 53 54 41 52 54 20 52  EMOTEHOSTSTART R
79d0: 55 4e 4e 49 4e 47 29 20 20 0a 09 09 20 20 20 20  UNNING)  ...    
79e0: 20 20 20 28 69 66 20 28 3e 20 28 2d 20 28 63 75     (if (> (- (cu
79f0: 72 72 65 6e 74 2d 73 65 63 6f 6e 64 73 29 28 2b  rrent-seconds)(+
7a00: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 65 76   (db:test-get-ev
7a10: 65 6e 74 5f 74 69 6d 65 20 74 65 73 74 64 61 74  ent_time testdat
7a20: 29 0a 09 09 09 09 09 09 20 20 20 20 20 28 64 62  ).......     (db
7a30: 3a 74 65 73 74 2d 67 65 74 2d 72 75 6e 5f 64 75  :test-get-run_du
7a40: 72 61 74 69 6f 6e 20 74 65 73 74 64 61 74 29 29  ration testdat))
7a50: 29 0a 09 09 09 20 20 20 20 20 20 31 30 30 29 20  )....      100) 
7a60: 3b 3b 20 69 2e 65 2e 20 6e 6f 20 75 70 64 61 74  ;; i.e. no updat
7a70: 65 20 66 6f 72 20 6d 6f 72 65 20 74 68 61 6e 20  e for more than 
7a80: 31 30 30 20 73 65 63 6f 6e 64 73 0a 09 09 09 20  100 seconds.... 
7a90: 20 20 28 62 65 67 69 6e 0a 09 09 09 20 20 20 20    (begin....    
7aa0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
7ab0: 22 57 41 52 4e 49 4e 47 3a 20 54 65 73 74 20 22  "WARNING: Test "
7ac0: 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 61 70 70   test-name " app
7ad0: 65 61 72 73 20 74 6f 20 62 65 20 64 65 61 64 2e  ears to be dead.
7ae0: 20 46 6f 72 63 69 6e 67 20 69 74 20 74 6f 20 73   Forcing it to s
7af0: 74 61 74 65 20 49 4e 43 4f 4d 50 4c 45 54 45 20  tate INCOMPLETE 
7b00: 61 6e 64 20 73 74 61 74 75 73 20 53 54 55 43 4b  and status STUCK
7b10: 2f 44 45 41 44 22 29 0a 09 09 09 20 20 20 20 20  /DEAD")....     
7b20: 28 74 65 73 74 2d 73 65 74 2d 73 74 61 74 75 73  (test-set-status
7b30: 21 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  ! db run-id test
7b40: 2d 6e 61 6d 65 20 22 49 4e 43 4f 4d 50 4c 45 54  -name "INCOMPLET
7b50: 45 22 20 22 53 54 55 43 4b 2f 44 45 41 44 22 20  E" "STUCK/DEAD" 
7b60: 69 74 65 6d 64 61 74 20 22 54 65 73 74 20 69 73  itemdat "Test is
7b70: 20 73 74 75 63 6b 20 6f 72 20 64 65 61 64 22 20   stuck or dead" 
7b80: 23 66 29 29 0a 09 09 09 20 20 20 28 64 65 62 75  #f))....   (debu
7b90: 67 3a 70 72 69 6e 74 20 32 20 22 4e 4f 54 45 3a  g:print 2 "NOTE:
7ba0: 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 69   " test-name " i
7bb0: 73 20 61 6c 72 65 61 64 79 20 72 75 6e 6e 69 6e  s already runnin
7bc0: 67 22 29 29 29 0a 09 09 20 20 20 20 20 20 28 65  g")))...      (e
7bd0: 6c 73 65 20 20 20 20 20 20 20 28 64 65 62 75 67  lse       (debug
7be0: 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a  :print 0 "ERROR:
7bf0: 20 46 61 69 6c 65 64 20 74 6f 20 6c 61 75 6e 63   Failed to launc
7c00: 68 20 74 65 73 74 20 22 20 6e 65 77 2d 74 65 73  h test " new-tes
7c10: 74 2d 6e 61 6d 65 20 22 2e 20 55 6e 72 65 63 6f  t-name ". Unreco
7c20: 67 6e 69 73 65 64 20 73 74 61 74 65 20 22 20 28  gnised state " (
7c30: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74  test:get-state t
7c40: 65 73 74 64 61 74 29 29 29 29 29 29 0a 09 20 20  estdat))))))..  
7c50: 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28 6e 75      (if (not (nu
7c60: 6c 6c 3f 20 74 61 6c 29 29 0a 09 09 20 20 28 6c  ll? tal))...  (l
7c70: 6f 6f 70 20 28 63 61 72 20 74 61 6c 29 28 63 64  oop (car tal)(cd
7c80: 72 20 74 61 6c 29 29 29 29 29 29 29 29 29 0a 0a  r tal)))))))))..
7c90: 28 64 65 66 69 6e 65 20 28 72 75 6e 2d 77 61 69  (define (run-wai
7ca0: 74 69 6e 67 2d 74 65 73 74 73 20 64 62 29 0a 20  ting-tests db). 
7cb0: 20 28 6c 65 74 20 28 28 6e 75 6d 74 72 69 65 73   (let ((numtries
7cc0: 20 20 20 20 20 20 20 20 20 20 20 30 29 0a 09 28             0)..(
7cd0: 6c 61 73 74 2d 74 72 79 2d 74 69 6d 65 20 20 20  last-try-time   
7ce0: 20 20 20 28 63 75 72 72 65 6e 74 2d 73 65 63 6f     (current-seco
7cf0: 6e 64 73 29 29 0a 09 28 74 69 6d 65 73 20 20 20  nds))..(times   
7d00: 20 20 20 20 20 20 20 20 20 20 20 28 6c 69 73 74             (list
7d10: 20 31 29 29 29 20 3b 3b 20 6d 69 6e 75 74 65 73   1))) ;; minutes
7d20: 20 74 6f 20 77 61 69 74 20 62 65 66 6f 72 65 20   to wait before 
7d30: 74 72 79 69 6e 67 20 61 67 61 69 6e 20 74 6f 20  trying again to 
7d40: 6b 69 63 6b 20 6f 66 66 20 72 75 6e 73 0a 20 20  kick off runs.  
7d50: 20 20 3b 3b 20 42 55 47 20 74 68 69 73 20 68 61    ;; BUG this ha
7d60: 63 6b 20 6f 66 20 62 72 75 74 65 20 66 6f 72 63  ck of brute forc
7d70: 65 20 72 65 74 72 79 69 6e 67 20 77 6f 72 6b 73  e retrying works
7d80: 20 71 75 69 74 65 20 77 65 6c 6c 20 66 6f 72 20   quite well for 
7d90: 6d 61 6e 79 20 63 61 73 65 73 20 62 75 74 20 0a  many cases but .
7da0: 20 20 20 20 3b 3b 20 20 20 20 20 77 68 61 74 20      ;;     what 
7db0: 69 73 20 6e 65 65 64 65 64 20 69 73 20 74 6f 20  is needed is to 
7dc0: 63 68 65 63 6b 20 74 68 65 20 64 62 20 66 6f 72  check the db for
7dd0: 20 74 65 73 74 73 20 74 68 61 74 20 68 61 76 65   tests that have
7de0: 20 66 61 69 6c 65 64 20 6c 65 73 73 20 74 68 61   failed less tha
7df0: 6e 0a 20 20 20 20 3b 3b 20 20 20 20 20 4e 20 74  n.    ;;     N t
7e00: 69 6d 65 73 20 6f 72 20 6e 65 76 65 72 20 62 65  imes or never be
7e10: 65 6e 20 73 74 61 72 74 65 64 20 61 6e 64 20 6b  en started and k
7e20: 69 63 6b 20 74 68 65 6d 20 6f 66 66 20 61 67 61  ick them off aga
7e30: 69 6e 0a 20 20 20 20 28 6c 65 74 20 6c 6f 6f 70  in.    (let loop
7e40: 20 28 28 77 61 69 74 69 6e 67 2d 74 65 73 74 2d   ((waiting-test-
7e50: 6e 61 6d 65 73 20 28 68 61 73 68 2d 74 61 62 6c  names (hash-tabl
7e60: 65 2d 6b 65 79 73 20 2a 77 61 69 74 69 6e 67 2d  e-keys *waiting-
7e70: 71 75 65 75 65 2a 29 29 29 0a 20 20 20 20 20 20  queue*))).      
7e80: 28 63 6f 6e 64 0a 20 20 20 20 20 20 20 28 28 6e  (cond.       ((n
7e90: 6f 74 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e  ot (runs:can-run
7ea0: 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64 62 29 29  -more-tests db))
7eb0: 0a 09 28 73 6c 65 65 70 20 32 29 0a 09 28 6c 6f  ..(sleep 2)..(lo
7ec0: 6f 70 20 77 61 69 74 69 6e 67 2d 74 65 73 74 2d  op waiting-test-
7ed0: 6e 61 6d 65 73 29 29 0a 20 20 20 20 20 20 20 28  names)).       (
7ee0: 28 6e 75 6c 6c 3f 20 77 61 69 74 69 6e 67 2d 74  (null? waiting-t
7ef0: 65 73 74 2d 6e 61 6d 65 73 29 0a 09 28 64 65 62  est-names)..(deb
7f00: 75 67 3a 70 72 69 6e 74 20 31 20 22 41 6c 6c 20  ug:print 1 "All 
7f10: 74 65 73 74 73 20 6c 61 75 6e 63 68 65 64 22 29  tests launched")
7f20: 29 0a 20 20 20 20 20 20 20 28 65 6c 73 65 0a 09  ).       (else..
7f30: 28 73 65 74 21 20 6e 75 6d 74 72 69 65 73 20 28  (set! numtries (
7f40: 2b 20 6e 75 6d 74 72 69 65 73 20 31 29 29 0a 09  + numtries 1))..
7f50: 28 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64  (for-each (lambd
7f60: 61 20 28 74 65 73 74 6e 61 6d 65 29 0a 09 09 20  a (testname)... 
7f70: 20 20 20 28 69 66 20 28 72 75 6e 73 3a 63 61 6e     (if (runs:can
7f80: 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20  -run-more-tests 
7f90: 64 62 29 0a 09 09 09 28 6c 65 74 2a 20 28 28 74  db)....(let* ((t
7fa0: 65 73 74 64 61 74 20 28 68 61 73 68 2d 74 61 62  estdat (hash-tab
7fb0: 6c 65 2d 72 65 66 20 2a 77 61 69 74 69 6e 67 2d  le-ref *waiting-
7fc0: 71 75 65 75 65 2a 20 74 65 73 74 6e 61 6d 65 29  queue* testname)
7fd0: 29 0a 09 09 09 20 20 20 20 20 20 20 28 70 72 65  )....       (pre
7fe0: 72 65 71 73 20 28 28 63 61 72 20 74 65 73 74 64  reqs ((car testd
7ff0: 61 74 29 29 29 0a 09 09 09 20 20 20 20 20 20 20  at)))....       
8000: 28 6c 64 62 20 20 20 20 20 28 69 66 20 64 62 20  (ldb     (if db 
8010: 64 62 20 28 6f 70 65 6e 2d 64 62 29 29 29 29 0a  db (open-db)))).
8020: 09 09 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e  ...  (debug:prin
8030: 74 20 32 20 22 70 72 65 72 65 71 73 20 72 65 6d  t 2 "prereqs rem
8040: 61 69 6e 69 6e 67 3a 20 22 20 70 72 65 72 65 71  aining: " prereq
8050: 73 29 0a 09 09 09 20 20 28 69 66 20 28 6e 75 6c  s)....  (if (nul
8060: 6c 3f 20 70 72 65 72 65 71 73 29 0a 09 09 09 20  l? prereqs).... 
8070: 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09 09 09       (begin.....
8080: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22  (debug:print 2 "
8090: 50 72 65 72 65 71 75 69 73 69 74 65 73 20 6d 65  Prerequisites me
80a0: 74 2c 20 6c 61 75 6e 63 68 69 6e 67 20 22 20 74  t, launching " t
80b0: 65 73 74 6e 61 6d 65 29 0a 09 09 09 09 28 28 63  estname).....((c
80c0: 61 64 72 20 74 65 73 74 64 61 74 29 29 0a 09 09  adr testdat))...
80d0: 09 09 28 68 61 73 68 2d 74 61 62 6c 65 2d 64 65  ..(hash-table-de
80e0: 6c 65 74 65 21 20 2a 77 61 69 74 69 6e 67 2d 71  lete! *waiting-q
80f0: 75 65 75 65 2a 20 74 65 73 74 6e 61 6d 65 29 29  ueue* testname))
8100: 29 0a 09 09 09 20 20 28 69 66 20 28 6e 6f 74 20  )....  (if (not 
8110: 64 62 29 0a 09 09 09 20 20 20 20 20 20 28 73 71  db)....      (sq
8120: 6c 69 74 65 33 3a 66 69 6e 61 6c 69 7a 65 21 20  lite3:finalize! 
8130: 6c 64 62 29 29 29 29 29 0a 09 09 20 20 77 61 69  ldb)))))...  wai
8140: 74 69 6e 67 2d 74 65 73 74 2d 6e 61 6d 65 73 29  ting-test-names)
8150: 0a 09 3b 3b 20 28 73 6c 65 65 70 20 31 30 29 20  ..;; (sleep 10) 
8160: 3b 3b 20 6e 6f 20 70 6f 69 6e 74 20 69 6e 20 72  ;; no point in r
8170: 75 73 68 69 6e 67 20 74 68 69 6e 67 73 20 61 74  ushing things at
8180: 20 74 68 69 73 20 73 74 61 67 65 3f 0a 09 28 6c   this stage?..(l
8190: 6f 6f 70 20 28 68 61 73 68 2d 74 61 62 6c 65 2d  oop (hash-table-
81a0: 6b 65 79 73 20 2a 77 61 69 74 69 6e 67 2d 71 75  keys *waiting-qu
81b0: 65 75 65 2a 29 29 29 29 29 29 29 0a 0a 28 64 65  eue*)))))))..(de
81c0: 66 69 6e 65 20 28 67 65 74 2d 64 69 72 2d 75 70  fine (get-dir-up
81d0: 2d 6e 20 64 69 72 20 2e 20 70 61 72 61 6d 73 29  -n dir . params)
81e0: 20 0a 20 20 28 6c 65 74 20 28 28 64 70 61 72 74   .  (let ((dpart
81f0: 73 20 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74  s  (string-split
8200: 20 64 69 72 20 22 2f 22 29 29 0a 09 28 63 6f 75   dir "/"))..(cou
8210: 6e 74 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20  nt   (if (null? 
8220: 70 61 72 61 6d 73 29 20 31 20 28 63 61 72 20 70  params) 1 (car p
8230: 61 72 61 6d 73 29 29 29 29 0a 20 20 20 20 28 63  arams)))).    (c
8240: 6f 6e 63 20 22 2f 22 20 28 73 74 72 69 6e 67 2d  onc "/" (string-
8250: 69 6e 74 65 72 73 70 65 72 73 65 20 0a 09 20 20  intersperse ..  
8260: 20 20 20 20 20 28 74 61 6b 65 20 64 70 61 72 74       (take dpart
8270: 73 20 28 2d 20 28 6c 65 6e 67 74 68 20 64 70 61  s (- (length dpa
8280: 72 74 73 29 20 63 6f 75 6e 74 29 29 0a 09 20 20  rts) count))..  
8290: 20 20 20 20 20 22 2f 22 29 29 29 29 0a 3b 3b 20       "/")))).;; 
82a0: 52 65 6d 6f 76 65 20 72 75 6e 73 0a 3b 3b 20 66  Remove runs.;; f
82b0: 69 65 6c 64 73 20 61 72 65 20 70 61 73 73 69 6e  ields are passin
82c0: 67 20 69 6e 20 74 68 72 6f 75 67 68 20 0a 28 64  g in through .(d
82d0: 65 66 69 6e 65 20 28 72 75 6e 73 3a 72 65 6d 6f  efine (runs:remo
82e0: 76 65 2d 72 75 6e 73 20 64 62 20 72 75 6e 6e 61  ve-runs db runna
82f0: 6d 65 70 61 74 74 20 74 65 73 74 70 61 74 74 20  mepatt testpatt 
8300: 69 74 65 6d 70 61 74 74 29 0a 20 20 28 6c 65 74  itempatt).  (let
8310: 2a 20 28 28 6b 65 79 73 20 20 20 20 20 20 20 20  * ((keys        
8320: 28 64 62 2d 67 65 74 2d 6b 65 79 73 20 64 62 29  (db-get-keys db)
8330: 29 0a 09 20 28 72 75 6e 64 61 74 20 20 20 20 20  ).. (rundat     
8340: 20 28 72 75 6e 73 3a 67 65 74 2d 72 75 6e 73 2d   (runs:get-runs-
8350: 62 79 2d 70 61 74 74 20 64 62 20 6b 65 79 73 20  by-patt db keys 
8360: 72 75 6e 6e 61 6d 65 70 61 74 74 29 29 0a 09 20  runnamepatt)).. 
8370: 28 68 65 61 64 65 72 20 20 20 20 20 20 28 76 65  (header      (ve
8380: 63 74 6f 72 2d 72 65 66 20 72 75 6e 64 61 74 20  ctor-ref rundat 
8390: 30 29 29 0a 09 20 28 72 75 6e 73 20 20 20 20 20  0)).. (runs     
83a0: 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20 72     (vector-ref r
83b0: 75 6e 64 61 74 20 31 29 29 29 0a 20 20 20 20 28  undat 1))).    (
83c0: 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 48  debug:print 1 "H
83d0: 65 61 64 65 72 3a 20 22 20 68 65 61 64 65 72 29  eader: " header)
83e0: 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 0a 20  .    (for-each. 
83f0: 20 20 20 20 28 6c 61 6d 62 64 61 20 28 72 75 6e      (lambda (run
8400: 29 0a 20 20 20 20 20 20 20 28 6c 65 74 20 28 28  ).       (let ((
8410: 72 75 6e 6b 65 79 20 28 73 74 72 69 6e 67 2d 69  runkey (string-i
8420: 6e 74 65 72 73 70 65 72 73 65 20 28 6d 61 70 20  ntersperse (map 
8430: 28 6c 61 6d 62 64 61 20 28 6b 29 0a 09 09 09 09  (lambda (k).....
8440: 09 09 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d  ..(db:get-value-
8450: 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65  by-header run he
8460: 61 64 65 72 20 28 76 65 63 74 6f 72 2d 72 65 66  ader (vector-ref
8470: 20 6b 20 30 29 29 29 20 6b 65 79 73 29 20 22 2f   k 0))) keys) "/
8480: 22 29 29 0a 09 20 20 20 20 20 28 64 69 72 73 2d  "))..     (dirs-
8490: 74 6f 2d 72 65 6d 6f 76 65 20 28 6d 61 6b 65 2d  to-remove (make-
84a0: 68 61 73 68 2d 74 61 62 6c 65 29 29 29 0a 09 20  hash-table))).. 
84b0: 28 6c 65 74 2a 20 28 28 72 75 6e 2d 69 64 20 28  (let* ((run-id (
84c0: 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d  db:get-value-by-
84d0: 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65  header run heade
84e0: 72 20 22 69 64 22 29 20 29 0a 09 09 28 74 65 73  r "id") )...(tes
84f0: 74 73 20 20 28 64 62 2d 67 65 74 2d 74 65 73 74  ts  (db-get-test
8500: 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 28 64 62  s-for-run db (db
8510: 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65  :get-value-by-he
8520: 61 64 65 72 20 72 75 6e 20 68 65 61 64 65 72 20  ader run header 
8530: 22 69 64 22 29 20 74 65 73 74 70 61 74 74 20 69  "id") testpatt i
8540: 74 65 6d 70 61 74 74 20 27 28 29 20 27 28 29 29  tempatt '() '())
8550: 29 0a 09 09 28 6c 61 73 74 74 70 61 74 68 20 22  )...(lasttpath "
8560: 2f 64 6f 65 73 2f 6e 6f 74 2f 65 78 69 73 74 2f  /does/not/exist/
8570: 49 2f 68 6f 70 65 22 29 29 0a 0a 09 20 20 20 28  I/hope"))...   (
8580: 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74  if (not (null? t
8590: 65 73 74 73 29 29 0a 09 20 20 20 20 20 20 20 28  ests))..       (
85a0: 62 65 67 69 6e 0a 09 09 20 28 64 65 62 75 67 3a  begin... (debug:
85b0: 70 72 69 6e 74 20 31 20 22 52 65 6d 6f 76 69 6e  print 1 "Removin
85c0: 67 20 74 65 73 74 73 20 66 6f 72 20 72 75 6e 3a  g tests for run:
85d0: 20 22 20 72 75 6e 6b 65 79 20 22 20 22 20 28 64   " runkey " " (d
85e0: 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68  b:get-value-by-h
85f0: 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65 72  eader run header
8600: 20 22 72 75 6e 6e 61 6d 65 22 29 29 0a 09 09 20   "runname"))... 
8610: 28 66 6f 72 2d 65 61 63 68 0a 09 09 20 20 28 6c  (for-each...  (l
8620: 61 6d 62 64 61 20 28 74 65 73 74 29 0a 09 09 20  ambda (test)... 
8630: 20 20 20 28 6c 65 74 2a 20 28 28 69 74 65 6d 2d     (let* ((item-
8640: 70 61 74 68 20 28 64 62 3a 74 65 73 74 2d 67 65  path (db:test-ge
8650: 74 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74  t-item-path test
8660: 29 29 0a 09 09 09 20 20 20 28 74 65 73 74 2d 6e  ))....   (test-n
8670: 61 6d 65 20 28 64 62 3a 74 65 73 74 2d 67 65 74  ame (db:test-get
8680: 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 29 29  -testname test))
8690: 0a 09 09 09 20 20 20 28 72 75 6e 2d 64 69 72 20  ....   (run-dir 
86a0: 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 72    (db:test-get-r
86b0: 75 6e 64 69 72 20 74 65 73 74 29 29 29 0a 09 09  undir test)))...
86c0: 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69        (debug:pri
86d0: 6e 74 20 31 20 22 20 20 22 20 28 64 62 3a 74 65  nt 1 "  " (db:te
86e0: 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20  st-get-testname 
86f0: 74 65 73 74 29 20 22 20 69 64 3a 20 22 20 28 64  test) " id: " (d
8700: 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65  b:test-get-id te
8710: 73 74 29 20 22 20 22 20 69 74 65 6d 2d 70 61 74  st) " " item-pat
8720: 68 29 0a 09 09 20 20 20 20 20 20 28 64 62 3a 64  h)...      (db:d
8730: 65 6c 65 74 65 2d 74 65 73 74 2d 72 65 63 6f 72  elete-test-recor
8740: 64 73 20 64 62 20 28 64 62 3a 74 65 73 74 2d 67  ds db (db:test-g
8750: 65 74 2d 69 64 20 74 65 73 74 29 29 0a 09 09 20  et-id test))... 
8760: 20 20 20 20 20 28 69 66 20 28 3e 20 28 73 74 72       (if (> (str
8770: 69 6e 67 2d 6c 65 6e 67 74 68 20 72 75 6e 2d 64  ing-length run-d
8780: 69 72 29 20 35 29 20 3b 3b 20 62 61 64 20 68 65  ir) 5) ;; bad he
8790: 75 72 69 73 74 69 63 20 62 75 74 20 73 68 6f 75  uristic but shou
87a0: 6c 64 20 70 72 65 76 65 6e 74 20 2f 74 6d 70 20  ld prevent /tmp 
87b0: 2f 68 6f 6d 65 20 65 74 63 2e 0a 09 09 09 20 20  /home etc.....  
87c0: 28 6c 65 74 20 28 28 66 75 6c 6c 70 61 74 68 20  (let ((fullpath 
87d0: 72 75 6e 2d 64 69 72 29 29 20 3b 3b 20 22 2f 22  run-dir)) ;; "/"
87e0: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74   (db:test-get-it
87f0: 65 6d 2d 70 61 74 68 20 74 65 73 74 29 29 29 29  em-path test))))
8800: 0a 09 09 09 20 20 20 20 28 73 65 74 21 20 6c 61  ....    (set! la
8810: 73 74 74 70 61 74 68 20 66 75 6c 6c 70 61 74 68  sttpath fullpath
8820: 29 0a 09 09 09 20 20 20 20 28 68 61 73 68 2d 74  )....    (hash-t
8830: 61 62 6c 65 2d 73 65 74 21 20 64 69 72 73 2d 74  able-set! dirs-t
8840: 6f 2d 72 65 6d 6f 76 65 20 66 75 6c 6c 70 61 74  o-remove fullpat
8850: 68 20 23 74 29 0a 09 09 09 20 20 20 20 3b 3b 20  h #t)....    ;; 
8860: 54 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 77 61  The following wa
8870: 73 20 74 68 65 20 73 61 66 65 20 64 65 6c 65 74  s the safe delet
8880: 65 20 63 6f 64 65 20 62 75 74 20 69 74 20 77 61  e code but it wa
8890: 73 20 6e 6f 74 20 62 65 69 6e 67 20 65 78 65 63  s not being exec
88a0: 74 75 74 65 64 2e 0a 09 09 09 20 20 20 20 3b 3b  tuted.....    ;;
88b0: 20 28 6c 65 74 2a 20 28 28 64 69 72 73 2d 63 6f   (let* ((dirs-co
88c0: 75 6e 74 20 28 2b 20 31 20 28 6c 65 6e 67 74 68  unt (+ 1 (length
88d0: 20 6b 65 79 73 29 28 6c 65 6e 67 74 68 20 28 73   keys)(length (s
88e0: 74 72 69 6e 67 2d 73 70 6c 69 74 20 69 74 65 6d  tring-split item
88f0: 2d 70 61 74 68 20 22 2f 22 29 29 29 29 0a 09 09  -path "/"))))...
8900: 09 20 20 20 20 3b 3b 20 20 20 20 20 20 20 20 28  .    ;;        (
8910: 64 69 72 2d 74 6f 2d 72 65 6d 20 28 67 65 74 2d  dir-to-rem (get-
8920: 64 69 72 2d 75 70 2d 6e 20 66 75 6c 6c 70 61 74  dir-up-n fullpat
8930: 68 20 64 69 72 73 2d 63 6f 75 6e 74 29 29 0a 09  h dirs-count))..
8940: 09 09 20 20 20 20 3b 3b 20 20 20 20 20 20 20 20  ..    ;;        
8950: 28 72 65 6d 61 69 6e 69 6e 67 64 20 28 73 74 72  (remainingd (str
8960: 69 6e 67 2d 73 75 62 73 74 69 74 75 74 65 20 28  ing-substitute (
8970: 72 65 67 65 78 70 20 28 63 6f 6e 63 20 22 5e 22  regexp (conc "^"
8980: 20 64 69 72 2d 74 6f 2d 72 65 6d 20 22 2f 22 29   dir-to-rem "/")
8990: 29 20 22 22 20 66 75 6c 6c 70 61 74 68 29 29 0a  ) "" fullpath)).
89a0: 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20 20 20  ...    ;;       
89b0: 20 28 63 6d 64 20 28 63 6f 6e 63 20 22 63 64 20   (cmd (conc "cd 
89c0: 22 20 64 69 72 2d 74 6f 2d 72 65 6d 20 22 3b 20  " dir-to-rem "; 
89d0: 72 6d 64 69 72 20 2d 70 20 22 20 72 65 6d 61 69  rmdir -p " remai
89e0: 6e 69 6e 67 64 20 29 29 29 0a 09 09 09 20 20 20  ningd )))....   
89f0: 20 3b 3b 20 20 20 28 69 66 20 28 66 69 6c 65 2d   ;;   (if (file-
8a00: 65 78 69 73 74 73 3f 20 66 75 6c 6c 70 61 74 68  exists? fullpath
8a10: 29 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20  )....    ;;     
8a20: 20 20 28 62 65 67 69 6e 0a 09 09 09 20 20 20 20    (begin....    
8a30: 3b 3b 20 20 20 20 20 20 20 20 20 28 64 65 62 75  ;;         (debu
8a40: 67 3a 70 72 69 6e 74 20 31 20 63 6d 64 29 0a 09  g:print 1 cmd)..
8a50: 09 09 20 20 20 20 3b 3b 20 20 20 20 20 20 20 20  ..    ;;        
8a60: 20 28 73 79 73 74 65 6d 20 63 6d 64 29 29 29 0a   (system cmd))).
8a70: 09 09 09 20 20 20 20 3b 3b 20 20 20 29 29 0a 09  ...    ;;   ))..
8a80: 09 09 20 20 20 20 29 29 29 29 0a 09 09 20 20 20  ..    ))))...   
8a90: 20 74 65 73 74 73 29 29 29 0a 0a 09 20 20 20 3b   tests)))...   ;
8aa0: 3b 20 6c 6f 6f 6b 20 74 68 6f 75 67 68 20 74 68  ; look though th
8ab0: 65 20 64 69 72 73 2d 74 6f 2d 72 65 6d 6f 76 65  e dirs-to-remove
8ac0: 20 66 6f 72 20 63 61 6e 64 69 64 61 74 65 73 20   for candidates 
8ad0: 66 6f 72 20 72 65 6d 6f 76 61 6c 2e 20 44 6f 20  for removal. Do 
8ae0: 74 68 69 73 20 61 66 74 65 72 20 64 65 6c 65 74  this after delet
8af0: 69 6e 67 20 74 68 65 20 72 65 63 6f 72 64 73 0a  ing the records.
8b00: 09 20 20 20 3b 3b 20 66 6f 72 20 65 61 63 68 20  .   ;; for each 
8b10: 74 65 73 74 20 69 6e 20 63 61 73 65 20 77 65 20  test in case we 
8b20: 67 65 74 20 6b 69 6c 6c 65 64 2e 20 54 68 61 74  get killed. That
8b30: 20 73 68 6f 75 6c 64 20 6d 69 6e 69 6d 69 7a 65   should minimize
8b40: 20 74 68 65 20 64 65 74 72 69 74 75 73 20 6c 65   the detritus le
8b50: 66 74 20 6f 6e 20 64 69 73 6b 0a 09 20 20 20 3b  ft on disk..   ;
8b60: 3b 20 70 72 6f 63 65 73 73 20 74 68 65 20 64 69  ; process the di
8b70: 72 73 20 66 72 6f 6d 20 6c 6f 6e 67 65 73 74 20  rs from longest 
8b80: 73 74 72 69 6e 67 20 6c 65 6e 67 74 68 20 74 6f  string length to
8b90: 20 73 68 6f 72 74 65 73 74 0a 09 20 20 20 28 66   shortest..   (f
8ba0: 6f 72 2d 65 61 63 68 20 0a 09 20 20 20 20 28 6c  or-each ..    (l
8bb0: 61 6d 62 64 61 20 28 64 69 72 2d 74 6f 2d 72 65  ambda (dir-to-re
8bc0: 6d 6f 76 65 29 0a 09 20 20 20 20 20 20 28 69 66  move)..      (if
8bd0: 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 64   (file-exists? d
8be0: 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 0a 09 09  ir-to-remove)...
8bf0: 20 20 28 6c 65 74 20 28 28 64 69 72 2d 69 6e 2d    (let ((dir-in-
8c00: 64 62 20 27 28 29 29 29 0a 09 09 20 20 20 20 28  db '()))...    (
8c10: 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68  sqlite3:for-each
8c20: 2d 72 6f 77 0a 09 09 20 20 20 20 20 28 6c 61 6d  -row...     (lam
8c30: 62 64 61 20 28 64 69 72 29 0a 09 09 20 20 20 20  bda (dir)...    
8c40: 20 20 20 28 73 65 74 21 20 64 69 72 2d 69 6e 2d     (set! dir-in-
8c50: 64 62 20 28 63 6f 6e 73 20 64 69 72 20 64 69 72  db (cons dir dir
8c60: 2d 69 6e 2d 64 62 29 29 29 0a 09 09 20 20 20 20  -in-db)))...    
8c70: 20 64 62 20 22 53 45 4c 45 43 54 20 72 75 6e 64   db "SELECT rund
8c80: 69 72 20 46 52 4f 4d 20 74 65 73 74 73 20 57 48  ir FROM tests WH
8c90: 45 52 45 20 72 75 6e 64 69 72 20 4c 49 4b 45 20  ERE rundir LIKE 
8ca0: 3f 3b 22 20 0a 09 09 20 20 20 20 20 28 63 6f 6e  ?;" ...     (con
8cb0: 63 20 22 25 22 20 64 69 72 2d 74 6f 2d 72 65 6d  c "%" dir-to-rem
8cc0: 6f 76 65 20 22 25 22 29 29 20 3b 3b 20 79 65 73  ove "%")) ;; yes
8cd0: 2c 20 49 27 6d 20 67 6f 69 6e 67 20 74 6f 20 62  , I'm going to b
8ce0: 61 69 6c 20 69 66 20 74 68 65 72 65 20 69 73 20  ail if there is 
8cf0: 61 6e 79 74 68 69 6e 67 20 6c 69 6b 65 20 74 68  anything like th
8d00: 69 73 20 64 69 72 20 69 6e 20 74 68 65 20 64 62  is dir in the db
8d10: 0a 09 09 20 20 20 20 28 69 66 20 28 6e 75 6c 6c  ...    (if (null
8d20: 3f 20 64 69 72 2d 69 6e 2d 64 62 29 0a 09 09 09  ? dir-in-db)....
8d30: 28 62 65 67 69 6e 0a 09 09 09 20 20 28 64 65 62  (begin....  (deb
8d40: 75 67 3a 70 72 69 6e 74 20 32 20 22 52 65 6d 6f  ug:print 2 "Remo
8d50: 76 69 6e 67 20 64 69 72 65 63 74 6f 72 79 20 77  ving directory w
8d60: 69 74 68 20 7a 65 72 6f 20 64 62 20 72 65 66 65  ith zero db refe
8d70: 72 65 6e 63 65 73 3a 20 22 20 64 69 72 2d 74 6f  rences: " dir-to
8d80: 2d 72 65 6d 6f 76 65 29 0a 09 09 09 20 20 28 73  -remove)....  (s
8d90: 79 73 74 65 6d 20 28 63 6f 6e 63 20 22 72 6d 20  ystem (conc "rm 
8da0: 2d 72 66 20 22 20 64 69 72 2d 74 6f 2d 72 65 6d  -rf " dir-to-rem
8db0: 6f 76 65 29 29 0a 09 09 09 20 20 28 68 61 73 68  ove))....  (hash
8dc0: 2d 74 61 62 6c 65 2d 64 65 6c 65 74 65 21 20 64  -table-delete! d
8dd0: 69 72 73 2d 74 6f 2d 72 65 6d 6f 76 65 20 64 69  irs-to-remove di
8de0: 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 29 0a 09 09  r-to-remove))...
8df0: 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20  .(debug:print 2 
8e00: 22 53 6b 69 70 70 69 6e 67 20 72 65 6d 6f 76 61  "Skipping remova
8e10: 6c 20 6f 66 20 22 20 64 69 72 2d 74 6f 2d 72 65  l of " dir-to-re
8e20: 6d 6f 76 65 20 22 20 66 6f 72 20 6e 6f 77 20 61  move " for now a
8e30: 73 20 69 74 20 73 74 69 6c 6c 20 68 61 73 20 72  s it still has r
8e40: 65 66 65 72 65 6e 63 65 73 20 69 6e 20 74 68 65  eferences in the
8e50: 20 64 61 74 61 62 61 73 65 22 29 29 29 29 29 0a   database"))))).
8e60: 09 20 20 20 20 28 73 6f 72 74 20 28 68 61 73 68  .    (sort (hash
8e70: 2d 74 61 62 6c 65 2d 6b 65 79 73 20 64 69 72 73  -table-keys dirs
8e80: 2d 74 6f 2d 72 65 6d 6f 76 65 29 20 28 6c 61 6d  -to-remove) (lam
8e90: 62 64 61 20 28 61 20 62 29 28 3e 20 28 73 74 72  bda (a b)(> (str
8ea0: 69 6e 67 2d 6c 65 6e 67 74 68 20 61 29 28 73 74  ing-length a)(st
8eb0: 72 69 6e 67 2d 6c 65 6e 67 74 68 20 62 29 29 29  ring-length b)))
8ec0: 29 29 0a 0a 09 20 20 20 3b 3b 20 72 65 6d 6f 76  ))...   ;; remov
8ed0: 65 20 74 68 65 20 72 75 6e 20 69 66 20 7a 65 72  e the run if zer
8ee0: 6f 20 74 65 73 74 73 20 72 65 6d 61 69 6e 0a 09  o tests remain..
8ef0: 20 20 20 28 6c 65 74 20 28 28 72 65 6d 74 65 73     (let ((remtes
8f00: 74 73 20 28 64 62 2d 67 65 74 2d 74 65 73 74 73  ts (db-get-tests
8f10: 2d 66 6f 72 2d 72 75 6e 20 64 62 20 28 64 62 3a  -for-run db (db:
8f20: 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61  get-value-by-hea
8f30: 64 65 72 20 72 75 6e 20 68 65 61 64 65 72 20 22  der run header "
8f40: 69 64 22 29 20 23 66 20 23 66 20 27 28 29 20 27  id") #f #f '() '
8f50: 28 29 29 29 29 0a 09 20 20 20 20 20 28 69 66 20  ())))..     (if 
8f60: 28 6e 75 6c 6c 3f 20 72 65 6d 74 65 73 74 73 29  (null? remtests)
8f70: 20 3b 3b 20 6e 6f 20 6d 6f 72 65 20 74 65 73 74   ;; no more test
8f80: 73 20 72 65 6d 61 69 6e 69 6e 67 0a 09 09 20 28  s remaining... (
8f90: 6c 65 74 2a 20 28 28 64 70 61 72 74 73 20 20 28  let* ((dparts  (
8fa0: 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 6c 61 73  string-split las
8fb0: 74 74 70 61 74 68 20 22 2f 22 29 29 0a 09 09 09  ttpath "/"))....
8fc0: 28 72 75 6e 70 61 74 68 20 28 63 6f 6e 63 20 22  (runpath (conc "
8fd0: 2f 22 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72  /" (string-inter
8fe0: 73 70 65 72 73 65 20 0a 09 09 09 09 09 20 20 20  sperse ......   
8ff0: 20 28 74 61 6b 65 20 64 70 61 72 74 73 20 28 2d   (take dparts (-
9000: 20 28 6c 65 6e 67 74 68 20 64 70 61 72 74 73 29   (length dparts)
9010: 20 31 29 29 0a 09 09 09 09 09 20 20 20 20 22 2f   1))......    "/
9020: 22 29 29 29 29 0a 09 09 20 20 20 28 64 65 62 75  "))))...   (debu
9030: 67 3a 70 72 69 6e 74 20 31 20 22 52 65 6d 6f 76  g:print 1 "Remov
9040: 69 6e 67 20 72 75 6e 3a 20 22 20 72 75 6e 6b 65  ing run: " runke
9050: 79 20 22 20 22 20 28 64 62 3a 67 65 74 2d 76 61  y " " (db:get-va
9060: 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75  lue-by-header ru
9070: 6e 20 68 65 61 64 65 72 20 22 72 75 6e 6e 61 6d  n header "runnam
9080: 65 22 29 29 0a 09 09 20 20 20 28 64 62 3a 64 65  e"))...   (db:de
9090: 6c 65 74 65 2d 72 75 6e 20 64 62 20 72 75 6e 2d  lete-run db run-
90a0: 69 64 29 0a 09 09 20 20 20 3b 3b 20 6e 65 65 64  id)...   ;; need
90b0: 20 74 6f 20 66 69 67 75 72 65 20 6f 75 74 20 74   to figure out t
90c0: 68 65 20 70 61 74 68 20 74 6f 20 74 68 65 20 72  he path to the r
90d0: 75 6e 20 64 69 72 20 61 6e 64 20 72 65 6d 6f 76  un dir and remov
90e0: 65 20 69 74 20 69 66 20 65 6d 70 74 79 0a 09 09  e it if empty...
90f0: 20 20 20 3b 3b 20 20 20 20 28 69 66 20 28 6e 75     ;;    (if (nu
9100: 6c 6c 3f 20 28 67 6c 6f 62 20 28 63 6f 6e 63 20  ll? (glob (conc 
9110: 72 75 6e 70 61 74 68 20 22 2f 2a 22 29 29 29 0a  runpath "/*"))).
9120: 09 09 20 20 20 3b 3b 20 20 20 20 20 20 20 20 28  ..   ;;        (
9130: 62 65 67 69 6e 0a 09 09 20 20 20 3b 3b 20 09 20  begin...   ;; . 
9140: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22  (debug:print 1 "
9150: 52 65 6d 6f 76 69 6e 67 20 72 75 6e 20 64 69 72  Removing run dir
9160: 20 22 20 72 75 6e 70 61 74 68 29 0a 09 09 20 20   " runpath)...  
9170: 20 3b 3b 20 09 20 28 73 79 73 74 65 6d 20 28 63   ;; . (system (c
9180: 6f 6e 63 20 22 72 6d 64 69 72 20 2d 70 20 22 20  onc "rmdir -p " 
9190: 72 75 6e 70 61 74 68 29 29 29 29 0a 09 09 20 20  runpath))))...  
91a0: 20 29 29 29 29 0a 09 20 29 29 0a 20 20 20 20 20   )))).. )).     
91b0: 72 75 6e 73 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d  runs)))..;;=====
91c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
91d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
91e0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
91f0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9200: 3d 0a 3b 3b 20 52 6f 75 74 69 6e 65 73 20 66 6f  =.;; Routines fo
9210: 72 20 6d 61 6e 69 70 75 6c 61 74 69 6e 67 20 72  r manipulating r
9220: 75 6e 73 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  uns.;;==========
9230: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9240: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9250: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9260: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b  ============..;;
9270: 20 53 69 6e 63 65 20 6d 61 6e 79 20 63 61 6c 6c   Since many call
9280: 73 20 74 6f 20 61 20 72 75 6e 20 72 65 71 75 69  s to a run requi
9290: 72 65 20 70 72 65 74 74 79 20 6d 75 63 68 20 74  re pretty much t
92a0: 68 65 20 73 61 6d 65 20 73 65 74 75 70 20 0a 3b  he same setup .;
92b0: 3b 20 74 68 69 73 20 77 72 61 70 70 65 72 20 69  ; this wrapper i
92c0: 73 20 75 73 65 64 20 74 6f 20 72 65 64 75 63 65  s used to reduce
92d0: 20 74 68 65 20 72 65 70 6c 69 63 61 74 69 6f 6e   the replication
92e0: 20 6f 66 20 63 6f 64 65 0a 28 64 65 66 69 6e 65   of code.(define
92f0: 20 28 67 65 6e 65 72 61 6c 2d 72 75 6e 2d 63 61   (general-run-ca
9300: 6c 6c 20 73 77 69 74 63 68 6e 61 6d 65 20 61 63  ll switchname ac
9310: 74 69 6f 6e 2d 64 65 73 63 20 70 72 6f 63 29 0a  tion-desc proc).
9320: 20 20 28 69 66 20 28 6e 6f 74 20 28 61 72 67 73    (if (not (args
9330: 3a 67 65 74 2d 61 72 67 20 22 3a 72 75 6e 6e 61  :get-arg ":runna
9340: 6d 65 22 29 29 0a 20 20 20 20 20 20 28 62 65 67  me")).      (beg
9350: 69 6e 0a 09 28 64 65 62 75 67 3a 70 72 69 6e 74  in..(debug:print
9360: 20 30 20 22 45 52 52 4f 52 3a 20 4d 69 73 73 69   0 "ERROR: Missi
9370: 6e 67 20 72 65 71 75 69 72 65 64 20 70 61 72 61  ng required para
9380: 6d 65 74 65 72 20 66 6f 72 20 22 20 73 77 69 74  meter for " swit
9390: 63 68 6e 61 6d 65 20 22 2c 20 79 6f 75 20 6d 75  chname ", you mu
93a0: 73 74 20 73 70 65 63 69 66 79 20 74 68 65 20 72  st specify the r
93b0: 75 6e 20 6e 61 6d 65 20 77 69 74 68 20 3a 72 75  un name with :ru
93c0: 6e 6e 61 6d 65 20 72 75 6e 6e 61 6d 65 22 29 0a  nname runname").
93d0: 09 28 65 78 69 74 20 32 29 29 0a 20 20 20 20 20  .(exit 2)).     
93e0: 20 28 6c 65 74 20 28 28 64 62 20 23 66 29 29 0a   (let ((db #f)).
93f0: 09 28 69 66 20 28 6e 6f 74 20 28 73 65 74 75 70  .(if (not (setup
9400: 2d 66 6f 72 2d 72 75 6e 29 29 0a 09 20 20 20 20  -for-run))..    
9410: 28 62 65 67 69 6e 20 0a 09 20 20 20 20 20 20 28  (begin ..      (
9420: 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 46  debug:print 0 "F
9430: 61 69 6c 65 64 20 74 6f 20 73 65 74 75 70 2c 20  ailed to setup, 
9440: 65 78 69 74 69 6e 67 22 29 0a 09 20 20 20 20 20  exiting")..     
9450: 20 28 65 78 69 74 20 31 29 29 29 0a 09 28 73 65   (exit 1)))..(se
9460: 74 21 20 64 62 20 28 6f 70 65 6e 2d 64 62 29 29  t! db (open-db))
9470: 0a 09 28 69 66 20 28 6e 6f 74 20 28 63 61 72 20  ..(if (not (car 
9480: 2a 63 6f 6e 66 69 67 69 6e 66 6f 2a 29 29 0a 09  *configinfo*))..
9490: 20 20 20 20 28 62 65 67 69 6e 0a 09 20 20 20 20      (begin..    
94a0: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30    (debug:print 0
94b0: 20 22 45 52 52 4f 52 3a 20 41 74 74 65 6d 70 74   "ERROR: Attempt
94c0: 65 64 20 74 6f 20 22 20 61 63 74 69 6f 6e 2d 64  ed to " action-d
94d0: 65 73 63 20 22 20 62 75 74 20 72 75 6e 20 61 72  esc " but run ar
94e0: 65 61 20 63 6f 6e 66 69 67 20 66 69 6c 65 20 6e  ea config file n
94f0: 6f 74 20 66 6f 75 6e 64 22 29 0a 09 20 20 20 20  ot found")..    
9500: 20 20 28 65 78 69 74 20 31 29 29 0a 09 20 20 20    (exit 1))..   
9510: 20 3b 3b 20 45 78 74 72 61 63 74 20 6f 75 74 20   ;; Extract out 
9520: 73 74 75 66 66 20 6e 65 65 64 65 64 20 69 6e 20  stuff needed in 
9530: 6d 6f 73 74 20 6f 72 20 6d 61 6e 79 20 63 61 6c  most or many cal
9540: 6c 73 0a 09 20 20 20 20 3b 3b 20 68 65 72 65 20  ls..    ;; here 
9550: 74 68 65 6e 20 63 61 6c 6c 20 70 72 6f 63 0a 09  then call proc..
9560: 20 20 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 73      (let* ((keys
9570: 20 20 20 20 20 20 20 28 64 62 2d 67 65 74 2d 6b         (db-get-k
9580: 65 79 73 20 64 62 29 29 0a 09 09 20 20 20 28 6b  eys db))...   (k
9590: 65 79 6e 61 6d 65 73 20 20 20 28 6d 61 70 20 6b  eynames   (map k
95a0: 65 79 3a 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65  ey:get-fieldname
95b0: 20 6b 65 79 73 29 29 0a 09 09 20 20 20 28 6b 65   keys))...   (ke
95c0: 79 76 61 6c 6c 73 74 20 20 28 6b 65 79 73 2d 3e  yvallst  (keys->
95d0: 76 61 6c 6c 69 73 74 20 6b 65 79 73 20 23 74 29  vallist keys #t)
95e0: 29 29 0a 09 20 20 20 20 20 20 28 70 72 6f 63 20  ))..      (proc 
95f0: 64 62 20 6b 65 79 73 20 6b 65 79 6e 61 6d 65 73  db keys keynames
9600: 20 6b 65 79 76 61 6c 6c 73 74 29 29 29 0a 09 28   keyvallst)))..(
9610: 73 71 6c 69 74 65 33 3a 66 69 6e 61 6c 69 7a 65  sqlite3:finalize
9620: 21 20 64 62 29 0a 09 28 73 65 74 21 20 2a 64 69  ! db)..(set! *di
9630: 64 73 6f 6d 65 74 68 69 6e 67 2a 20 23 74 29 29  dsomething* #t))
9640: 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ))..;;==========
9650: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9660: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9670: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9680: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20  ============.;; 
9690: 52 6f 6c 6c 75 70 20 72 75 6e 73 0a 3b 3b 3d 3d  Rollup runs.;;==
96a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
96b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
96c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
96d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
96e0: 3d 3d 3d 3d 0a 0a 3b 3b 20 55 70 64 61 74 65 20  ====..;; Update 
96f0: 74 68 65 20 74 65 73 74 5f 6d 65 74 61 20 74 61  the test_meta ta
9700: 62 6c 65 20 66 6f 72 20 74 68 69 73 20 74 65 73  ble for this tes
9710: 74 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a  t.(define (runs:
9720: 75 70 64 61 74 65 2d 74 65 73 74 5f 6d 65 74 61  update-test_meta
9730: 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 20 74 65   db test-name te
9740: 73 74 2d 63 6f 6e 66 29 0a 20 20 28 6c 65 74 20  st-conf).  (let 
9750: 28 28 63 75 72 72 72 65 63 6f 72 64 20 28 64 62  ((currrecord (db
9760: 3a 74 65 73 74 6d 65 74 61 2d 67 65 74 2d 72 65  :testmeta-get-re
9770: 63 6f 72 64 20 64 62 20 74 65 73 74 2d 6e 61 6d  cord db test-nam
9780: 65 29 29 29 0a 20 20 20 20 28 69 66 20 28 6e 6f  e))).    (if (no
9790: 74 20 63 75 72 72 72 65 63 6f 72 64 29 0a 09 28  t currrecord)..(
97a0: 62 65 67 69 6e 0a 09 20 20 28 73 65 74 21 20 63  begin..  (set! c
97b0: 75 72 72 72 65 63 6f 72 64 20 28 6d 61 6b 65 2d  urrrecord (make-
97c0: 76 65 63 74 6f 72 20 31 30 20 23 66 29 29 0a 09  vector 10 #f))..
97d0: 20 20 28 64 62 3a 74 65 73 74 6d 65 74 61 2d 61    (db:testmeta-a
97e0: 64 64 2d 72 65 63 6f 72 64 20 64 62 20 74 65 73  dd-record db tes
97f0: 74 2d 6e 61 6d 65 29 29 29 0a 20 20 20 20 28 66  t-name))).    (f
9800: 6f 72 2d 65 61 63 68 20 0a 20 20 20 20 20 28 6c  or-each .     (l
9810: 61 6d 62 64 61 20 28 6b 65 79 29 0a 20 20 20 20  ambda (key).    
9820: 20 20 20 28 6c 65 74 2a 20 28 28 69 64 78 20 28     (let* ((idx (
9830: 63 61 64 72 20 6b 65 79 29 29 0a 09 20 20 20 20  cadr key))..    
9840: 20 20 28 66 6c 64 20 28 63 61 72 20 20 6b 65 79    (fld (car  key
9850: 29 29 0a 09 20 20 20 20 20 20 28 76 61 6c 20 28  ))..      (val (
9860: 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 74 65  config-lookup te
9870: 73 74 2d 63 6f 6e 66 20 22 74 65 73 74 5f 6d 65  st-conf "test_me
9880: 74 61 22 20 66 6c 64 29 29 29 0a 09 20 28 69 66  ta" fld))).. (if
9890: 20 28 61 6e 64 20 76 61 6c 20 28 6e 6f 74 20 28   (and val (not (
98a0: 65 71 75 61 6c 3f 20 28 76 65 63 74 6f 72 2d 72  equal? (vector-r
98b0: 65 66 20 63 75 72 72 72 65 63 6f 72 64 20 69 64  ef currrecord id
98c0: 78 29 20 76 61 6c 29 29 29 0a 09 20 20 20 20 20  x) val)))..     
98d0: 28 62 65 67 69 6e 0a 09 20 20 20 20 20 20 20 28  (begin..       (
98e0: 70 72 69 6e 74 20 22 55 70 64 61 74 69 6e 67 20  print "Updating 
98f0: 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 22 20  " test-name " " 
9900: 66 6c 64 20 22 20 74 6f 20 22 20 76 61 6c 29 0a  fld " to " val).
9910: 09 20 20 20 20 20 20 20 28 64 62 3a 74 65 73 74  .       (db:test
9920: 6d 65 74 61 2d 75 70 64 61 74 65 2d 66 69 65 6c  meta-update-fiel
9930: 64 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 20 66  d db test-name f
9940: 6c 64 20 76 61 6c 29 29 29 29 29 0a 20 20 20 20  ld val))))).    
9950: 20 27 28 28 22 61 75 74 68 6f 72 22 20 32 29 28   '(("author" 2)(
9960: 22 6f 77 6e 65 72 22 20 33 29 28 22 64 65 73 63  "owner" 3)("desc
9970: 72 69 70 74 69 6f 6e 22 20 34 29 28 22 72 65 76  ription" 4)("rev
9980: 69 65 77 65 64 22 20 35 29 28 22 74 61 67 73 22  iewed" 5)("tags"
9990: 20 39 29 29 29 29 29 0a 0a 3b 3b 20 55 70 64 61   9)))))..;; Upda
99a0: 74 65 20 74 65 73 74 5f 6d 65 74 61 20 66 6f 72  te test_meta for
99b0: 20 61 6c 6c 20 74 65 73 74 73 0a 28 64 65 66 69   all tests.(defi
99c0: 6e 65 20 28 72 75 6e 73 3a 75 70 64 61 74 65 2d  ne (runs:update-
99d0: 61 6c 6c 2d 74 65 73 74 5f 6d 65 74 61 20 64 62  all-test_meta db
99e0: 29 0a 20 20 28 6c 65 74 20 28 28 74 65 73 74 2d  ).  (let ((test-
99f0: 6e 61 6d 65 73 20 28 67 65 74 2d 61 6c 6c 2d 6c  names (get-all-l
9a00: 65 67 61 6c 2d 74 65 73 74 73 29 29 29 0a 20 20  egal-tests))).  
9a10: 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 20 20    (for-each .   
9a20: 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74 2d    (lambda (test-
9a30: 6e 61 6d 65 29 0a 20 20 20 20 20 20 20 28 6c 65  name).       (le
9a40: 74 2a 20 28 28 74 65 73 74 2d 70 61 74 68 20 20  t* ((test-path  
9a50: 20 20 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74 68    (conc *toppath
9a60: 2a 20 22 2f 74 65 73 74 73 2f 22 20 74 65 73 74  * "/tests/" test
9a70: 2d 6e 61 6d 65 29 29 0a 09 20 20 20 20 20 20 28  -name))..      (
9a80: 74 65 73 74 2d 63 6f 6e 66 69 67 66 20 28 63 6f  test-configf (co
9a90: 6e 63 20 74 65 73 74 2d 70 61 74 68 20 22 2f 74  nc test-path "/t
9aa0: 65 73 74 63 6f 6e 66 69 67 22 29 29 0a 09 20 20  estconfig"))..  
9ab0: 20 20 20 20 28 74 65 73 74 65 78 69 73 74 73 20      (testexists 
9ac0: 20 20 28 61 6e 64 20 28 66 69 6c 65 2d 65 78 69    (and (file-exi
9ad0: 73 74 73 3f 20 74 65 73 74 2d 63 6f 6e 66 69 67  sts? test-config
9ae0: 66 29 28 66 69 6c 65 2d 72 65 61 64 2d 61 63 63  f)(file-read-acc
9af0: 65 73 73 3f 20 74 65 73 74 2d 63 6f 6e 66 69 67  ess? test-config
9b00: 66 29 29 29 0a 09 20 20 20 20 20 20 3b 3b 20 72  f)))..      ;; r
9b10: 65 61 64 20 63 6f 6e 66 69 67 73 20 77 69 74 68  ead configs with
9b20: 20 74 72 69 63 6b 73 20 74 75 72 6e 65 64 20 6f   tricks turned o
9b30: 66 66 20 28 69 2e 65 2e 20 6e 6f 20 73 79 73 74  ff (i.e. no syst
9b40: 65 6d 29 0a 09 20 20 20 20 20 20 28 74 65 73 74  em)..      (test
9b50: 2d 63 6f 6e 66 20 20 20 20 28 69 66 20 74 65 73  -conf    (if tes
9b60: 74 65 78 69 73 74 73 20 28 72 65 61 64 2d 63 6f  texists (read-co
9b70: 6e 66 69 67 20 74 65 73 74 2d 63 6f 6e 66 69 67  nfig test-config
9b80: 66 20 23 66 20 23 66 29 28 6d 61 6b 65 2d 68 61  f #f #f)(make-ha
9b90: 73 68 2d 74 61 62 6c 65 29 29 29 29 0a 09 20 28  sh-table)))).. (
9ba0: 72 75 6e 73 3a 75 70 64 61 74 65 2d 74 65 73 74  runs:update-test
9bb0: 5f 6d 65 74 61 20 64 62 20 74 65 73 74 2d 6e 61  _meta db test-na
9bc0: 6d 65 20 74 65 73 74 2d 63 6f 6e 66 29 29 29 0a  me test-conf))).
9bd0: 20 20 20 20 20 74 65 73 74 2d 6e 61 6d 65 73 29       test-names)
9be0: 29 29 0a 09 20 0a 3b 3b 20 54 68 69 73 20 63 6f  )).. .;; This co
9bf0: 75 6c 64 20 70 72 6f 62 61 62 6c 79 20 62 65 20  uld probably be 
9c00: 72 65 66 61 63 74 6f 72 65 64 20 69 6e 74 6f 20  refactored into 
9c10: 6f 6e 65 20 63 6f 6d 70 6c 65 78 20 71 75 65 72  one complex quer
9c20: 79 20 2e 2e 2e 0a 28 64 65 66 69 6e 65 20 28 72  y ....(define (r
9c30: 75 6e 73 3a 72 6f 6c 6c 75 70 2d 72 75 6e 20 64  uns:rollup-run d
9c40: 62 20 6b 65 79 73 29 0a 20 20 28 6c 65 74 2a 20  b keys).  (let* 
9c50: 28 28 6e 65 77 2d 72 75 6e 2d 69 64 20 20 20 20  ((new-run-id    
9c60: 20 20 28 72 65 67 69 73 74 65 72 2d 72 75 6e 20    (register-run 
9c70: 64 62 20 6b 65 79 73 29 29 0a 09 20 28 70 72 65  db keys)).. (pre
9c80: 76 2d 74 65 73 74 73 20 20 20 20 20 20 28 74 65  v-tests      (te
9c90: 73 74 3a 67 65 74 2d 6d 61 74 63 68 69 6e 67 2d  st:get-matching-
9ca0: 70 72 65 76 69 6f 75 73 2d 74 65 73 74 2d 72 75  previous-test-ru
9cb0: 6e 2d 72 65 63 6f 72 64 73 20 64 62 20 6e 65 77  n-records db new
9cc0: 2d 72 75 6e 2d 69 64 20 22 25 22 20 22 25 22 29  -run-id "%" "%")
9cd0: 29 0a 09 20 28 63 75 72 72 2d 74 65 73 74 73 20  ).. (curr-tests 
9ce0: 20 20 20 20 20 28 64 62 2d 67 65 74 2d 74 65 73       (db-get-tes
9cf0: 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 6e 65  ts-for-run db ne
9d00: 77 2d 72 75 6e 2d 69 64 20 22 25 22 20 22 25 22  w-run-id "%" "%"
9d10: 20 27 28 29 20 27 28 29 29 29 0a 09 20 28 63 75   '() '())).. (cu
9d20: 72 72 2d 74 65 73 74 73 2d 68 61 73 68 20 28 6d  rr-tests-hash (m
9d30: 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29  ake-hash-table))
9d40: 29 0a 20 20 20 20 3b 3b 20 69 6e 64 65 78 20 74  ).    ;; index t
9d50: 68 65 20 61 6c 72 65 61 64 79 20 73 61 76 65 64  he already saved
9d60: 20 74 65 73 74 73 20 62 79 20 74 65 73 74 6e 61   tests by testna
9d70: 6d 65 20 61 6e 64 20 69 74 65 6d 70 61 74 68 20  me and itempath 
9d80: 69 6e 20 63 75 72 72 2d 74 65 73 74 73 2d 68 61  in curr-tests-ha
9d90: 73 68 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68  sh.    (for-each
9da0: 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 74  .     (lambda (t
9db0: 65 73 74 64 61 74 29 0a 20 20 20 20 20 20 20 28  estdat).       (
9dc0: 6c 65 74 2a 20 28 28 74 65 73 74 6e 61 6d 65 20  let* ((testname 
9dd0: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 74 65   (db:test-get-te
9de0: 73 74 6e 61 6d 65 20 74 65 73 74 64 61 74 29 29  stname testdat))
9df0: 0a 09 20 20 20 20 20 20 28 69 74 65 6d 2d 70 61  ..      (item-pa
9e00: 74 68 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  th (db:test-get-
9e10: 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 64 61  item-path testda
9e20: 74 29 29 0a 09 20 20 20 20 20 20 28 66 75 6c 6c  t))..      (full
9e30: 2d 6e 61 6d 65 20 28 63 6f 6e 63 20 74 65 73 74  -name (conc test
9e40: 6e 61 6d 65 20 22 2f 22 20 69 74 65 6d 2d 70 61  name "/" item-pa
9e50: 74 68 29 29 29 0a 09 20 28 68 61 73 68 2d 74 61  th))).. (hash-ta
9e60: 62 6c 65 2d 73 65 74 21 20 63 75 72 72 2d 74 65  ble-set! curr-te
9e70: 73 74 73 2d 68 61 73 68 20 66 75 6c 6c 2d 6e 61  sts-hash full-na
9e80: 6d 65 20 74 65 73 74 64 61 74 29 29 29 0a 20 20  me testdat))).  
9e90: 20 20 20 63 75 72 72 2d 74 65 73 74 73 29 0a 20     curr-tests). 
9ea0: 20 20 20 3b 3b 20 4e 4f 50 45 3a 20 4e 6f 6e 2d     ;; NOPE: Non-
9eb0: 6f 70 74 69 6d 61 6c 20 61 70 70 72 6f 61 63 68  optimal approach
9ec0: 2e 20 54 72 79 20 74 68 69 73 20 69 6e 73 74 65  . Try this inste
9ed0: 61 64 2e 0a 20 20 20 20 3b 3b 20 20 20 31 2e 20  ad..    ;;   1. 
9ee0: 74 65 73 74 73 20 61 72 65 20 72 65 63 65 69 76  tests are receiv
9ef0: 65 64 20 69 6e 20 61 20 6c 69 73 74 2c 20 6d 6f  ed in a list, mo
9f00: 73 74 20 72 65 63 65 6e 74 20 66 69 72 73 74 0a  st recent first.
9f10: 20 20 20 20 3b 3b 20 20 20 32 2e 20 72 65 70 6c      ;;   2. repl
9f20: 61 63 65 20 74 68 65 20 72 6f 6c 6c 75 70 20 74  ace the rollup t
9f30: 65 73 74 20 77 69 74 68 20 74 68 65 20 6e 65 77  est with the new
9f40: 20 2a 61 6c 77 61 79 73 2a 0a 20 20 20 20 28 66   *always*.    (f
9f50: 6f 72 2d 65 61 63 68 20 0a 20 20 20 20 20 28 6c  or-each .     (l
9f60: 61 6d 62 64 61 20 28 74 65 73 74 64 61 74 29 0a  ambda (testdat).
9f70: 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28 28 74         (let* ((t
9f80: 65 73 74 6e 61 6d 65 20 20 28 64 62 3a 74 65 73  estname  (db:tes
9f90: 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 74  t-get-testname t
9fa0: 65 73 74 64 61 74 29 29 0a 09 20 20 20 20 20 20  estdat))..      
9fb0: 28 69 74 65 6d 2d 70 61 74 68 20 28 64 62 3a 74  (item-path (db:t
9fc0: 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74  est-get-item-pat
9fd0: 68 20 74 65 73 74 64 61 74 29 29 0a 09 20 20 20  h testdat))..   
9fe0: 20 20 20 28 66 75 6c 6c 2d 6e 61 6d 65 20 28 63     (full-name (c
9ff0: 6f 6e 63 20 74 65 73 74 6e 61 6d 65 20 22 2f 22  onc testname "/"
a000: 20 69 74 65 6d 2d 70 61 74 68 29 29 0a 09 20 20   item-path))..  
a010: 20 20 20 20 28 70 72 65 76 2d 74 65 73 74 2d 64      (prev-test-d
a020: 61 74 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72  at (hash-table-r
a030: 65 66 2f 64 65 66 61 75 6c 74 20 63 75 72 72 2d  ef/default curr-
a040: 74 65 73 74 73 2d 68 61 73 68 20 66 75 6c 6c 2d  tests-hash full-
a050: 6e 61 6d 65 20 23 66 29 29 0a 09 20 20 20 20 20  name #f))..     
a060: 20 28 74 65 73 74 2d 73 74 65 70 73 20 20 20 20   (test-steps    
a070: 20 20 28 64 62 3a 67 65 74 2d 73 74 65 70 73 2d    (db:get-steps-
a080: 66 6f 72 2d 74 65 73 74 20 64 62 20 28 64 62 3a  for-test db (db:
a090: 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74  test-get-id test
a0a0: 64 61 74 29 29 29 0a 09 20 20 20 20 20 20 28 6e  dat)))..      (n
a0b0: 65 77 2d 74 65 73 74 2d 72 65 63 6f 72 64 20 23  ew-test-record #
a0c0: 66 29 29 0a 09 20 3b 3b 20 72 65 70 6c 61 63 65  f)).. ;; replace
a0d0: 20 74 68 65 73 65 20 77 69 74 68 20 69 6e 73 65   these with inse
a0e0: 72 74 20 2e 2e 2e 20 73 65 6c 65 63 74 0a 09 20  rt ... select.. 
a0f0: 28 61 70 70 6c 79 20 73 71 6c 69 74 65 33 3a 65  (apply sqlite3:e
a100: 78 65 63 75 74 65 20 0a 09 09 64 62 20 0a 09 09  xecute ...db ...
a110: 28 63 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f 52  (conc "INSERT OR
a120: 20 52 45 50 4c 41 43 45 20 49 4e 54 4f 20 74 65   REPLACE INTO te
a130: 73 74 73 20 28 72 75 6e 5f 69 64 2c 74 65 73 74  sts (run_id,test
a140: 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 61 74 75  name,state,statu
a150: 73 2c 65 76 65 6e 74 5f 74 69 6d 65 2c 68 6f 73  s,event_time,hos
a160: 74 2c 63 70 75 6c 6f 61 64 2c 64 69 73 6b 66 72  t,cpuload,diskfr
a170: 65 65 2c 75 6e 61 6d 65 2c 72 75 6e 64 69 72 2c  ee,uname,rundir,
a180: 69 74 65 6d 5f 70 61 74 68 2c 72 75 6e 5f 64 75  item_path,run_du
a190: 72 61 74 69 6f 6e 2c 66 69 6e 61 6c 5f 6c 6f 67  ration,final_log
a1a0: 66 2c 63 6f 6d 6d 65 6e 74 2c 66 69 72 73 74 5f  f,comment,first_
a1b0: 65 72 72 2c 66 69 72 73 74 5f 77 61 72 6e 29 20  err,first_warn) 
a1c0: 22 0a 09 09 20 20 20 20 20 20 22 56 41 4c 55 45  "...      "VALUE
a1d0: 53 20 28 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f  S (?,?,?,?,?,?,?
a1e0: 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f  ,?,?,?,?,?,?,?,?
a1f0: 2c 3f 29 3b 22 29 0a 09 09 6e 65 77 2d 72 75 6e  ,?);")...new-run
a200: 2d 69 64 20 28 63 64 64 72 20 28 76 65 63 74 6f  -id (cddr (vecto
a210: 72 2d 3e 6c 69 73 74 20 74 65 73 74 64 61 74 29  r->list testdat)
a220: 29 29 0a 09 20 28 73 65 74 21 20 6e 65 77 2d 74  )).. (set! new-t
a230: 65 73 74 64 61 74 20 28 63 61 72 20 28 64 62 2d  estdat (car (db-
a240: 67 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d 72 75  get-tests-for-ru
a250: 6e 20 64 62 20 6e 65 77 2d 72 75 6e 2d 69 64 20  n db new-run-id 
a260: 74 65 73 74 6e 61 6d 65 20 69 74 65 6d 2d 70 61  testname item-pa
a270: 74 68 20 27 28 29 20 27 28 29 29 29 29 0a 09 20  th '() '()))).. 
a280: 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74 21  (hash-table-set!
a290: 20 63 75 72 72 2d 74 65 73 74 73 2d 68 61 73 68   curr-tests-hash
a2a0: 20 66 75 6c 6c 2d 6e 61 6d 65 20 6e 65 77 2d 74   full-name new-t
a2b0: 65 73 74 64 61 74 29 20 3b 3b 20 74 68 69 73 20  estdat) ;; this 
a2c0: 63 6f 75 6c 64 20 62 65 20 63 6f 6e 66 75 73 69  could be confusi
a2d0: 6e 67 2c 20 77 68 69 63 68 20 72 65 63 6f 72 64  ng, which record
a2e0: 20 73 68 6f 75 6c 64 20 67 6f 20 69 6e 74 6f 20   should go into 
a2f0: 74 68 65 20 6c 6f 6f 6b 75 70 20 74 61 62 6c 65  the lookup table
a300: 3f 0a 09 20 3b 3b 20 4e 6f 77 20 64 75 70 6c 69  ?.. ;; Now dupli
a310: 63 61 74 65 20 74 68 65 20 74 65 73 74 20 73 74  cate the test st
a320: 65 70 73 0a 09 20 28 64 65 62 75 67 3a 70 72 69  eps.. (debug:pri
a330: 6e 74 20 34 20 22 43 6f 70 79 69 6e 67 20 72 65  nt 4 "Copying re
a340: 63 6f 72 64 73 20 69 6e 20 74 65 73 74 5f 73 74  cords in test_st
a350: 65 70 73 20 66 72 6f 6d 20 74 65 73 74 5f 69 64  eps from test_id
a360: 3d 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  =" (db:test-get-
a370: 69 64 20 74 65 73 74 64 61 74 29 20 22 20 74 6f  id testdat) " to
a380: 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d   " (db:test-get-
a390: 69 64 20 6e 65 77 2d 74 65 73 74 64 61 74 29 29  id new-testdat))
a3a0: 0a 09 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63  .. (sqlite3:exec
a3b0: 75 74 65 20 0a 09 20 20 64 62 20 0a 09 20 20 28  ute ..  db ..  (
a3c0: 63 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f 52 20  conc "INSERT OR 
a3d0: 52 45 50 4c 41 43 45 20 49 4e 54 4f 20 74 65 73  REPLACE INTO tes
a3e0: 74 5f 73 74 65 70 73 20 28 74 65 73 74 5f 69 64  t_steps (test_id
a3f0: 2c 73 74 65 70 6e 61 6d 65 2c 73 74 61 74 65 2c  ,stepname,state,
a400: 73 74 61 74 75 73 2c 65 76 65 6e 74 5f 74 69 6d  status,event_tim
a410: 65 2c 63 6f 6d 6d 65 6e 74 29 20 22 0a 09 09 22  e,comment) "..."
a420: 53 45 4c 45 43 54 20 22 20 28 64 62 3a 74 65 73  SELECT " (db:tes
a430: 74 2d 67 65 74 2d 69 64 20 6e 65 77 2d 74 65 73  t-get-id new-tes
a440: 74 64 61 74 29 20 22 2c 73 74 65 70 6e 61 6d 65  tdat) ",stepname
a450: 2c 73 74 61 74 65 2c 73 74 61 74 75 73 2c 65 76  ,state,status,ev
a460: 65 6e 74 5f 74 69 6d 65 2c 63 6f 6d 6d 65 6e 74  ent_time,comment
a470: 20 46 52 4f 4d 20 74 65 73 74 5f 73 74 65 70 73   FROM test_steps
a480: 20 57 48 45 52 45 20 74 65 73 74 5f 69 64 3d 3f   WHERE test_id=?
a490: 3b 22 29 0a 09 20 20 28 64 62 3a 74 65 73 74 2d  ;")..  (db:test-
a4a0: 67 65 74 2d 69 64 20 74 65 73 74 64 61 74 29 29  get-id testdat))
a4b0: 0a 09 20 3b 3b 20 4e 6f 77 20 64 75 70 6c 69 63  .. ;; Now duplic
a4c0: 61 74 65 20 74 68 65 20 74 65 73 74 20 64 61 74  ate the test dat
a4d0: 61 0a 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74  a.. (debug:print
a4e0: 20 34 20 22 43 6f 70 79 69 6e 67 20 72 65 63 6f   4 "Copying reco
a4f0: 72 64 73 20 69 6e 20 74 65 73 74 5f 64 61 74 61  rds in test_data
a500: 20 66 72 6f 6d 20 74 65 73 74 5f 69 64 3d 22 20   from test_id=" 
a510: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20  (db:test-get-id 
a520: 74 65 73 74 64 61 74 29 20 22 20 74 6f 20 22 20  testdat) " to " 
a530: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20  (db:test-get-id 
a540: 6e 65 77 2d 74 65 73 74 64 61 74 29 29 0a 09 20  new-testdat)).. 
a550: 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65  (sqlite3:execute
a560: 20 0a 09 20 20 64 62 20 0a 09 20 20 28 63 6f 6e   ..  db ..  (con
a570: 63 20 22 49 4e 53 45 52 54 20 4f 52 20 52 45 50  c "INSERT OR REP
a580: 4c 41 43 45 20 49 4e 54 4f 20 74 65 73 74 5f 64  LACE INTO test_d
a590: 61 74 61 20 28 74 65 73 74 5f 69 64 2c 63 61 74  ata (test_id,cat
a5a0: 65 67 6f 72 79 2c 76 61 72 69 61 62 6c 65 2c 76  egory,variable,v
a5b0: 61 6c 75 65 2c 65 78 70 65 63 74 65 64 2c 74 6f  alue,expected,to
a5c0: 6c 2c 75 6e 69 74 73 2c 63 6f 6d 6d 65 6e 74 29  l,units,comment)
a5d0: 20 22 0a 09 09 22 53 45 4c 45 43 54 20 22 20 28   "..."SELECT " (
a5e0: 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 6e  db:test-get-id n
a5f0: 65 77 2d 74 65 73 74 64 61 74 29 20 22 2c 63 61  ew-testdat) ",ca
a600: 74 65 67 6f 72 79 2c 76 61 72 69 61 62 6c 65 2c  tegory,variable,
a610: 76 61 6c 75 65 2c 65 78 70 65 63 74 65 64 2c 74  value,expected,t
a620: 6f 6c 2c 75 6e 69 74 73 2c 63 6f 6d 6d 65 6e 74  ol,units,comment
a630: 20 46 52 4f 4d 20 74 65 73 74 5f 64 61 74 61 20   FROM test_data 
a640: 57 48 45 52 45 20 74 65 73 74 5f 69 64 3d 3f 3b  WHERE test_id=?;
a650: 22 29 0a 09 20 20 28 64 62 3a 74 65 73 74 2d 67  ")..  (db:test-g
a660: 65 74 2d 69 64 20 74 65 73 74 64 61 74 29 29 0a  et-id testdat)).
a670: 09 20 29 29 0a 20 20 20 20 20 70 72 65 76 2d 74  . )).     prev-t
a680: 65 73 74 73 29 29 29 0a 09 20 0a 20 20 20 20 20  ests))).. .     
a690: 0a                                               .