Megatest

Hex Artifact Content
Login

Artifact d434521016458489cabf20ba9dce3d6cd59f2402:


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 3b 3b 20 28 6c 65 74 20 28 28 76 61 6c     ;; (let ((val
2610: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
2620: 2f 64 65 66 61 75 6c 74 20 6f 74 68 65 72 64 61  /default otherda
2630: 74 20 22 3a 66 69 72 73 74 5f 65 72 72 22 20 23  t ":first_err" #
2640: 66 29 29 29 0a 20 20 20 20 3b 3b 20 20 20 28 69  f))).    ;;   (i
2650: 66 20 76 61 6c 0a 20 20 20 20 3b 3b 20 20 20 20  f val.    ;;    
2660: 20 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63     (sqlite3:exec
2670: 75 74 65 20 64 62 20 22 55 50 44 41 54 45 20 74  ute db "UPDATE t
2680: 65 73 74 73 20 53 45 54 20 66 69 72 73 74 5f 65  ests SET first_e
2690: 72 72 3d 3f 20 57 48 45 52 45 20 72 75 6e 5f 69  rr=? WHERE run_i
26a0: 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65  d=? AND testname
26b0: 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68  =? AND item_path
26c0: 3d 3f 3b 22 20 76 61 6c 20 72 75 6e 2d 69 64 20  =?;" val run-id 
26d0: 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70  test-name item-p
26e0: 61 74 68 29 29 29 0a 20 20 20 20 3b 3b 20 0a 20  ath))).    ;; . 
26f0: 20 20 20 3b 3b 20 3b 3b 20 3a 66 69 72 73 74 5f     ;; ;; :first_
2700: 77 61 72 6e 0a 20 20 20 20 3b 3b 20 28 6c 65 74  warn.    ;; (let
2710: 20 28 28 76 61 6c 20 28 68 61 73 68 2d 74 61 62   ((val (hash-tab
2720: 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 6f  le-ref/default o
2730: 74 68 65 72 64 61 74 20 22 3a 66 69 72 73 74 5f  therdat ":first_
2740: 77 61 72 6e 22 20 23 66 29 29 29 0a 20 20 20 20  warn" #f))).    
2750: 3b 3b 20 20 20 28 69 66 20 76 61 6c 0a 20 20 20  ;;   (if val.   
2760: 20 3b 3b 20 20 20 20 20 20 20 28 73 71 6c 69 74   ;;       (sqlit
2770: 65 33 3a 65 78 65 63 75 74 65 20 64 62 20 22 55  e3:execute db "U
2780: 50 44 41 54 45 20 74 65 73 74 73 20 53 45 54 20  PDATE tests SET 
2790: 66 69 72 73 74 5f 77 61 72 6e 3d 3f 20 57 48 45  first_warn=? WHE
27a0: 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20  RE run_id=? AND 
27b0: 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69  testname=? AND i
27c0: 74 65 6d 5f 70 61 74 68 3d 3f 3b 22 20 76 61 6c  tem_path=?;" val
27d0: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
27e0: 65 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 0a  e item-path)))..
27f0: 20 20 20 20 28 6c 65 74 20 28 28 63 61 74 65 67      (let ((categ
2800: 6f 72 79 20 28 68 61 73 68 2d 74 61 62 6c 65 2d  ory (hash-table-
2810: 72 65 66 2f 64 65 66 61 75 6c 74 20 6f 74 68 65  ref/default othe
2820: 72 64 61 74 20 22 3a 63 61 74 65 67 6f 72 79 22  rdat ":category"
2830: 20 22 22 29 29 0a 09 20 20 28 76 61 72 69 61 62   ""))..  (variab
2840: 6c 65 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72  le (hash-table-r
2850: 65 66 2f 64 65 66 61 75 6c 74 20 6f 74 68 65 72  ef/default other
2860: 64 61 74 20 22 3a 76 61 72 69 61 62 6c 65 22 20  dat ":variable" 
2870: 22 22 29 29 0a 09 20 20 28 76 61 6c 75 65 20 20  ""))..  (value  
2880: 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65    (hash-table-re
2890: 66 2f 64 65 66 61 75 6c 74 20 6f 74 68 65 72 64  f/default otherd
28a0: 61 74 20 22 3a 76 61 6c 75 65 22 20 20 20 20 23  at ":value"    #
28b0: 66 29 29 0a 09 20 20 28 65 78 70 65 63 74 65 64  f))..  (expected
28c0: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
28d0: 2f 64 65 66 61 75 6c 74 20 6f 74 68 65 72 64 61  /default otherda
28e0: 74 20 22 3a 65 78 70 65 63 74 65 64 22 20 23 66  t ":expected" #f
28f0: 29 29 0a 09 20 20 28 74 6f 6c 20 20 20 20 20 20  ))..  (tol      
2900: 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f  (hash-table-ref/
2910: 64 65 66 61 75 6c 74 20 6f 74 68 65 72 64 61 74  default otherdat
2920: 20 22 3a 74 6f 6c 22 20 20 20 20 20 20 23 66 29   ":tol"      #f)
2930: 29 0a 09 20 20 28 75 6e 69 74 73 20 20 20 20 28  )..  (units    (
2940: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64  hash-table-ref/d
2950: 65 66 61 75 6c 74 20 6f 74 68 65 72 64 61 74 20  efault otherdat 
2960: 22 3a 75 6e 69 74 73 22 20 20 20 20 22 22 29 29  ":units"    ""))
2970: 0a 09 20 20 28 64 63 6f 6d 6d 65 6e 74 20 28 68  ..  (dcomment (h
2980: 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65  ash-table-ref/de
2990: 66 61 75 6c 74 20 6f 74 68 65 72 64 61 74 20 22  fault otherdat "
29a0: 3a 63 6f 6d 6d 65 6e 74 22 20 20 22 22 29 29 29  :comment"  "")))
29b0: 0a 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72  .      (debug:pr
29c0: 69 6e 74 20 34 20 0a 09 09 20 20 20 22 63 61 74  int 4 ...   "cat
29d0: 65 67 6f 72 79 3a 20 22 20 63 61 74 65 67 6f 72  egory: " categor
29e0: 79 20 22 2c 20 76 61 72 69 61 62 6c 65 3a 20 22  y ", variable: "
29f0: 20 76 61 72 69 61 62 6c 65 20 22 2c 20 76 61 6c   variable ", val
2a00: 75 65 3a 20 22 20 76 61 6c 75 65 0a 09 09 20 20  ue: " value...  
2a10: 20 22 2c 20 65 78 70 65 63 74 65 64 3a 20 22 20   ", expected: " 
2a20: 65 78 70 65 63 74 65 64 20 22 2c 20 74 6f 6c 3a  expected ", tol:
2a30: 20 22 20 74 6f 6c 20 22 2c 20 75 6e 69 74 73 3a   " tol ", units:
2a40: 20 22 20 75 6e 69 74 73 29 0a 20 20 20 20 20 20   " units).      
2a50: 28 69 66 20 28 61 6e 64 20 76 61 6c 75 65 20 65  (if (and value e
2a60: 78 70 65 63 74 65 64 20 74 6f 6c 29 20 3b 3b 20  xpected tol) ;; 
2a70: 61 6c 6c 20 74 68 72 65 65 20 72 65 71 75 69 72  all three requir
2a80: 65 64 0a 09 20 20 28 64 62 3a 63 73 76 2d 3e 74  ed..  (db:csv->t
2a90: 65 73 74 2d 64 61 74 61 20 64 62 20 74 65 73 74  est-data db test
2aa0: 2d 69 64 20 0a 09 09 09 20 20 20 20 20 28 63 6f  -id ....     (co
2ab0: 6e 63 20 63 61 74 65 67 6f 72 79 20 22 2c 22 0a  nc category ",".
2ac0: 09 09 09 09 20 20 20 76 61 72 69 61 62 6c 65 20  ....   variable 
2ad0: 22 2c 22 0a 09 09 09 09 20 20 20 76 61 6c 75 65  ",".....   value
2ae0: 20 20 20 20 22 2c 22 0a 09 09 09 09 20 20 20 65      ",".....   e
2af0: 78 70 65 63 74 65 64 20 22 2c 22 0a 09 09 09 09  xpected ",".....
2b00: 20 20 20 74 6f 6c 20 20 20 20 20 20 22 2c 22 0a     tol      ",".
2b10: 09 09 09 09 20 20 20 75 6e 69 74 73 20 20 20 20  ....   units    
2b20: 22 2c 22 0a 09 09 09 09 20 20 20 64 63 6f 6d 6d  ",".....   dcomm
2b30: 65 6e 74 20 22 2c 22 29 29 29 29 0a 09 09 09 09  ent ",")))).....
2b40: 20 20 20 0a 20 20 20 20 3b 3b 20 6e 65 65 64 20     .    ;; need 
2b50: 74 6f 20 75 70 64 61 74 65 20 74 68 65 20 74 6f  to update the to
2b60: 70 20 74 65 73 74 20 72 65 63 6f 72 64 20 69 66  p test record if
2b70: 20 50 41 53 53 20 6f 72 20 46 41 49 4c 20 61 6e   PASS or FAIL an
2b80: 64 20 74 68 69 73 20 69 73 20 61 20 73 75 62 74  d this is a subt
2b90: 65 73 74 0a 20 20 20 20 28 69 66 20 28 61 6e 64  est.    (if (and
2ba0: 20 28 6e 6f 74 20 28 65 71 75 61 6c 3f 20 69 74   (not (equal? it
2bb0: 65 6d 2d 70 61 74 68 20 22 22 29 29 0a 09 20 20  em-path ""))..  
2bc0: 20 20 20 28 6f 72 20 28 65 71 75 61 6c 3f 20 73     (or (equal? s
2bd0: 74 61 74 75 73 20 22 50 41 53 53 22 29 0a 09 09  tatus "PASS")...
2be0: 20 28 65 71 75 61 6c 3f 20 73 74 61 74 75 73 20   (equal? status 
2bf0: 22 57 41 52 4e 22 29 0a 09 09 20 28 65 71 75 61  "WARN")... (equa
2c00: 6c 3f 20 73 74 61 74 75 73 20 22 46 41 49 4c 22  l? status "FAIL"
2c10: 29 0a 09 09 20 28 65 71 75 61 6c 3f 20 73 74 61  )... (equal? sta
2c20: 74 75 73 20 22 57 41 49 56 45 44 22 29 0a 09 09  tus "WAIVED")...
2c30: 20 28 65 71 75 61 6c 3f 20 73 74 61 74 75 73 20   (equal? status 
2c40: 22 52 55 4e 4e 49 4e 47 22 29 29 29 0a 09 28 62  "RUNNING")))..(b
2c50: 65 67 69 6e 0a 09 20 20 28 73 71 6c 69 74 65 33  egin..  (sqlite3
2c60: 3a 65 78 65 63 75 74 65 20 0a 09 20 20 20 64 62  :execute ..   db
2c70: 0a 09 20 20 20 22 55 50 44 41 54 45 20 74 65 73  ..   "UPDATE tes
2c80: 74 73 20 0a 20 20 20 20 20 20 20 20 20 20 20 20  ts .            
2c90: 20 53 45 54 20 66 61 69 6c 5f 63 6f 75 6e 74 3d   SET fail_count=
2ca0: 28 53 45 4c 45 43 54 20 63 6f 75 6e 74 28 69 64  (SELECT count(id
2cb0: 29 20 46 52 4f 4d 20 74 65 73 74 73 20 57 48 45  ) FROM tests WHE
2cc0: 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20  RE run_id=? AND 
2cd0: 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69  testname=? AND i
2ce0: 74 65 6d 5f 70 61 74 68 20 21 3d 20 27 27 20 41  tem_path != '' A
2cf0: 4e 44 20 73 74 61 74 75 73 3d 27 46 41 49 4c 27  ND status='FAIL'
2d00: 29 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  ),.             
2d10: 20 20 20 20 70 61 73 73 5f 63 6f 75 6e 74 3d 28      pass_count=(
2d20: 53 45 4c 45 43 54 20 63 6f 75 6e 74 28 69 64 29  SELECT count(id)
2d30: 20 46 52 4f 4d 20 74 65 73 74 73 20 57 48 45 52   FROM tests WHER
2d40: 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74  E run_id=? AND t
2d50: 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74  estname=? AND it
2d60: 65 6d 5f 70 61 74 68 20 21 3d 20 27 27 20 41 4e  em_path != '' AN
2d70: 44 20 28 73 74 61 74 75 73 3d 27 50 41 53 53 27  D (status='PASS'
2d80: 20 4f 52 20 73 74 61 74 75 73 3d 27 57 41 52 4e   OR status='WARN
2d90: 27 20 4f 52 20 73 74 61 74 75 73 3d 27 57 41 49  ' OR status='WAI
2da0: 56 45 44 27 29 29 0a 20 20 20 20 20 20 20 20 20  VED')).         
2db0: 20 20 20 20 57 48 45 52 45 20 72 75 6e 5f 69 64      WHERE run_id
2dc0: 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d  =? AND testname=
2dd0: 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d  ? AND item_path=
2de0: 27 27 3b 22 0a 09 20 20 20 72 75 6e 2d 69 64 20  '';"..   run-id 
2df0: 74 65 73 74 2d 6e 61 6d 65 20 72 75 6e 2d 69 64  test-name run-id
2e00: 20 74 65 73 74 2d 6e 61 6d 65 20 72 75 6e 2d 69   test-name run-i
2e10: 64 20 74 65 73 74 2d 6e 61 6d 65 29 0a 09 20 20  d test-name)..  
2e20: 28 69 66 20 28 65 71 75 61 6c 3f 20 73 74 61 74  (if (equal? stat
2e30: 75 73 20 22 52 55 4e 4e 49 4e 47 22 29 20 3b 3b  us "RUNNING") ;;
2e40: 20 72 75 6e 6e 69 6e 67 20 74 61 6b 65 73 20 70   running takes p
2e50: 72 69 6f 72 69 74 79 20 6f 76 65 72 20 61 6c 6c  riority over all
2e60: 20 6f 74 68 65 72 20 73 74 61 74 65 73 2c 20 66   other states, f
2e70: 6f 72 63 65 20 74 68 65 20 74 65 73 74 20 73 74  orce the test st
2e80: 61 74 65 20 74 6f 20 52 55 4e 4e 49 4e 47 0a 09  ate to RUNNING..
2e90: 20 20 20 20 20 20 28 73 71 6c 69 74 65 33 3a 65        (sqlite3:e
2ea0: 78 65 63 75 74 65 20 64 62 20 22 55 50 44 41 54  xecute db "UPDAT
2eb0: 45 20 74 65 73 74 73 20 53 45 54 20 73 74 61 74  E tests SET stat
2ec0: 65 3d 3f 20 57 48 45 52 45 20 72 75 6e 5f 69 64  e=? WHERE run_id
2ed0: 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d  =? AND testname=
2ee0: 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d  ? AND item_path=
2ef0: 27 27 3b 22 20 72 75 6e 2d 69 64 20 74 65 73 74  '';" run-id test
2f00: 2d 6e 61 6d 65 29 0a 09 20 20 20 20 20 20 28 73  -name)..      (s
2f10: 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 0a 09  qlite3:execute..
2f20: 20 20 20 20 20 20 20 64 62 0a 09 20 20 20 20 20         db..     
2f30: 20 20 22 55 50 44 41 54 45 20 74 65 73 74 73 0a    "UPDATE tests.
2f40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2f50: 20 20 20 20 20 20 20 53 45 54 20 73 74 61 74 65         SET state
2f60: 3d 43 41 53 45 20 57 48 45 4e 20 28 53 45 4c 45  =CASE WHEN (SELE
2f70: 43 54 20 63 6f 75 6e 74 28 69 64 29 20 46 52 4f  CT count(id) FRO
2f80: 4d 20 74 65 73 74 73 20 57 48 45 52 45 20 72 75  M tests WHERE ru
2f90: 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e  n_id=? AND testn
2fa0: 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70  ame=? AND item_p
2fb0: 61 74 68 20 21 3d 20 27 27 20 41 4e 44 20 73 74  ath != '' AND st
2fc0: 61 74 65 20 69 6e 20 28 27 52 55 4e 4e 49 4e 47  ate in ('RUNNING
2fd0: 27 2c 27 4e 4f 54 5f 53 54 41 52 54 45 44 27 29  ','NOT_STARTED')
2fe0: 29 20 3e 20 30 20 54 48 45 4e 20 0a 20 20 20 20  ) > 0 THEN .    
2ff0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
3000: 20 20 20 20 20 20 27 52 55 4e 4e 49 4e 47 27 0a        'RUNNING'.
3010: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
3020: 20 20 20 20 20 20 20 45 4c 53 45 20 27 43 4f 4d         ELSE 'COM
3030: 50 4c 45 54 45 44 27 20 45 4e 44 2c 0a 20 20 20  PLETED' END,.   
3040: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
3050: 20 20 20 20 20 20 20 73 74 61 74 75 73 3d 43 41         status=CA
3060: 53 45 20 57 48 45 4e 20 66 61 69 6c 5f 63 6f 75  SE WHEN fail_cou
3070: 6e 74 20 3e 20 30 20 54 48 45 4e 20 27 46 41 49  nt > 0 THEN 'FAI
3080: 4c 27 20 57 48 45 4e 20 70 61 73 73 5f 63 6f 75  L' WHEN pass_cou
3090: 6e 74 20 3e 20 30 20 41 4e 44 20 66 61 69 6c 5f  nt > 0 AND fail_
30a0: 63 6f 75 6e 74 3d 30 20 54 48 45 4e 20 27 50 41  count=0 THEN 'PA
30b0: 53 53 27 20 45 4c 53 45 20 27 55 4e 4b 4e 4f 57  SS' ELSE 'UNKNOW
30c0: 4e 27 20 45 4e 44 0a 20 20 20 20 20 20 20 20 20  N' END.         
30d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 57 48                WH
30e0: 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44  ERE run_id=? AND
30f0: 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20   testname=? AND 
3100: 69 74 65 6d 5f 70 61 74 68 3d 27 27 3b 22 0a 09  item_path='';"..
3110: 20 20 20 20 20 20 20 72 75 6e 2d 69 64 20 74 65         run-id te
3120: 73 74 2d 6e 61 6d 65 20 72 75 6e 2d 69 64 20 74  st-name run-id t
3130: 65 73 74 2d 6e 61 6d 65 29 29 29 29 0a 20 20 20  est-name)))).   
3140: 20 28 69 66 20 28 6f 72 20 28 61 6e 64 20 28 73   (if (or (and (s
3150: 74 72 69 6e 67 3f 20 63 6f 6d 6d 65 6e 74 29 0a  tring? comment).
3160: 09 09 20 28 73 74 72 69 6e 67 2d 6d 61 74 63 68  .. (string-match
3170: 20 28 72 65 67 65 78 70 20 22 5c 5c 53 2b 22 29   (regexp "\\S+")
3180: 20 63 6f 6d 6d 65 6e 74 29 29 0a 09 20 20 20 20   comment))..    
3190: 77 61 69 76 65 64 29 0a 09 28 73 71 6c 69 74 65  waived)..(sqlite
31a0: 33 3a 65 78 65 63 75 74 65 20 64 62 20 22 55 50  3:execute db "UP
31b0: 44 41 54 45 20 74 65 73 74 73 20 53 45 54 20 63  DATE tests SET c
31c0: 6f 6d 6d 65 6e 74 3d 3f 20 57 48 45 52 45 20 72  omment=? WHERE r
31d0: 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74  un_id=? AND test
31e0: 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f  name=? AND item_
31f0: 70 61 74 68 3d 3f 3b 22 0a 09 09 09 20 28 69 66  path=?;".... (if
3200: 20 77 61 69 76 65 64 20 77 61 69 76 65 64 20 63   waived waived c
3210: 6f 6d 6d 65 6e 74 29 20 72 75 6e 2d 69 64 20 74  omment) run-id t
3220: 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61  est-name item-pa
3230: 74 68 29 29 0a 20 20 20 20 29 29 0a 0a 28 64 65  th)).    ))..(de
3240: 66 69 6e 65 20 28 74 65 73 74 2d 73 65 74 2d 6c  fine (test-set-l
3250: 6f 67 21 20 64 62 20 72 75 6e 2d 69 64 20 74 65  og! db run-id te
3260: 73 74 2d 6e 61 6d 65 20 69 74 65 6d 64 61 74 20  st-name itemdat 
3270: 6c 6f 67 66 29 20 0a 20 20 28 6c 65 74 20 28 28  logf) .  (let ((
3280: 69 74 65 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d  item-path (item-
3290: 6c 69 73 74 2d 3e 70 61 74 68 20 69 74 65 6d 64  list->path itemd
32a0: 61 74 29 29 29 0a 20 20 20 20 28 73 71 6c 69 74  at))).    (sqlit
32b0: 65 33 3a 65 78 65 63 75 74 65 20 64 62 20 22 55  e3:execute db "U
32c0: 50 44 41 54 45 20 74 65 73 74 73 20 53 45 54 20  PDATE tests SET 
32d0: 66 69 6e 61 6c 5f 6c 6f 67 66 3d 3f 20 57 48 45  final_logf=? WHE
32e0: 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20  RE run_id=? AND 
32f0: 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69  testname=? AND i
3300: 74 65 6d 5f 70 61 74 68 3d 3f 3b 22 20 0a 09 09  tem_path=?;" ...
3310: 20 20 20 20 20 6c 6f 67 66 20 72 75 6e 2d 69 64       logf run-id
3320: 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d   test-name item-
3330: 70 61 74 68 29 29 29 0a 0a 28 64 65 66 69 6e 65  path)))..(define
3340: 20 28 74 65 73 74 2d 73 65 74 2d 74 6f 70 6c 6f   (test-set-toplo
3350: 67 21 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  g! db run-id tes
3360: 74 2d 6e 61 6d 65 20 6c 6f 67 66 29 20 0a 20 20  t-name logf) .  
3370: 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65  (sqlite3:execute
3380: 20 64 62 20 22 55 50 44 41 54 45 20 74 65 73 74   db "UPDATE test
3390: 73 20 53 45 54 20 66 69 6e 61 6c 5f 6c 6f 67 66  s SET final_logf
33a0: 3d 3f 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d  =? WHERE run_id=
33b0: 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f  ? AND testname=?
33c0: 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 27   AND item_path='
33d0: 27 3b 22 20 0a 09 09 20 20 20 6c 6f 67 66 20 72  ';" ...   logf r
33e0: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 29  un-id test-name)
33f0: 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73 74  )..(define (test
3400: 73 3a 73 75 6d 6d 61 72 69 7a 65 2d 69 74 65 6d  s:summarize-item
3410: 73 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  s db run-id test
3420: 2d 6e 61 6d 65 20 66 6f 72 63 65 29 0a 20 20 3b  -name force).  ;
3430: 3b 20 69 66 20 6e 6f 74 20 66 6f 72 63 65 20 74  ; if not force t
3440: 68 65 6e 20 6f 6e 6c 79 20 75 70 64 61 74 65 20  hen only update 
3450: 74 68 65 20 72 65 63 6f 72 64 20 69 66 20 6f 6e  the record if on
3460: 65 20 6f 66 20 74 68 65 73 65 20 69 73 20 74 72  e of these is tr
3470: 75 65 3a 0a 20 20 3b 3b 20 20 20 31 2e 20 6c 6f  ue:.  ;;   1. lo
3480: 67 66 20 69 73 20 22 6c 6f 67 2f 66 69 6e 61 6c  gf is "log/final
3490: 2e 6c 6f 67 0a 20 20 3b 3b 20 20 20 32 2e 20 6c  .log.  ;;   2. l
34a0: 6f 67 66 20 69 73 20 73 61 6d 65 20 61 73 20 6f  ogf is same as o
34b0: 75 74 70 75 74 66 69 6c 65 6e 61 6d 65 0a 20 20  utputfilename.  
34c0: 28 6c 65 74 20 28 28 6f 75 74 70 75 74 66 69 6c  (let ((outputfil
34d0: 65 6e 61 6d 65 20 28 63 6f 6e 63 20 22 6d 65 67  ename (conc "meg
34e0: 61 74 65 73 74 2d 72 6f 6c 6c 75 70 2d 22 20 74  atest-rollup-" t
34f0: 65 73 74 2d 6e 61 6d 65 20 22 2e 68 74 6d 6c 22  est-name ".html"
3500: 29 29 0a 09 28 6f 72 69 67 2d 64 69 72 20 20 20  ))..(orig-dir   
3510: 20 20 20 20 28 63 75 72 72 65 6e 74 2d 64 69 72      (current-dir
3520: 65 63 74 6f 72 79 29 29 0a 09 28 6c 6f 67 66 20  ectory))..(logf 
3530: 20 20 20 20 20 20 20 20 20 20 23 66 29 29 0a 20            #f)). 
3540: 20 20 20 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d     (sqlite3:for-
3550: 65 61 63 68 2d 72 6f 77 20 0a 20 20 20 20 20 28  each-row .     (
3560: 6c 61 6d 62 64 61 20 28 70 61 74 68 20 66 69 6e  lambda (path fin
3570: 61 6c 5f 6c 6f 67 66 29 0a 20 20 20 20 20 20 20  al_logf).       
3580: 28 73 65 74 21 20 6c 6f 67 66 20 66 69 6e 61 6c  (set! logf final
3590: 5f 6c 6f 67 66 29 0a 20 20 20 20 20 20 20 28 69  _logf).       (i
35a0: 66 20 28 64 69 72 65 63 74 6f 72 79 3f 20 70 61  f (directory? pa
35b0: 74 68 29 0a 09 20 20 20 28 62 65 67 69 6e 0a 09  th)..   (begin..
35c0: 20 20 20 20 20 28 70 72 69 6e 74 20 22 46 6f 75       (print "Fou
35d0: 6e 64 20 70 61 74 68 3a 20 22 20 70 61 74 68 29  nd path: " path)
35e0: 0a 09 20 20 20 20 20 28 63 68 61 6e 67 65 2d 64  ..     (change-d
35f0: 69 72 65 63 74 6f 72 79 20 70 61 74 68 29 29 0a  irectory path)).
3600: 09 20 20 20 20 20 3b 3b 20 28 73 65 74 21 20 6f  .     ;; (set! o
3610: 75 74 70 75 74 66 69 6c 65 6e 61 6d 65 20 28 63  utputfilename (c
3620: 6f 6e 63 20 70 61 74 68 20 22 2f 22 20 6f 75 74  onc path "/" out
3630: 70 75 74 66 69 6c 65 6e 61 6d 65 29 29 29 0a 09  putfilename)))..
3640: 20 20 20 28 70 72 69 6e 74 20 22 4e 6f 20 73 75     (print "No su
3650: 63 68 20 70 61 74 68 3a 20 22 20 70 61 74 68 29  ch path: " path)
3660: 29 29 0a 20 20 20 20 20 64 62 20 0a 20 20 20 20  )).     db .    
3670: 20 22 53 45 4c 45 43 54 20 72 75 6e 64 69 72 2c   "SELECT rundir,
3680: 66 69 6e 61 6c 5f 6c 6f 67 66 20 46 52 4f 4d 20  final_logf FROM 
3690: 74 65 73 74 73 20 57 48 45 52 45 20 72 75 6e 5f  tests WHERE run_
36a0: 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d  id=? AND testnam
36b0: 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74  e=? AND item_pat
36c0: 68 3d 27 27 3b 22 0a 20 20 20 20 20 72 75 6e 2d  h='';".     run-
36d0: 69 64 20 74 65 73 74 2d 6e 61 6d 65 29 0a 20 20  id test-name).  
36e0: 20 20 28 70 72 69 6e 74 20 22 73 75 6d 6d 61 72    (print "summar
36f0: 69 7a 65 2d 69 74 65 6d 73 20 77 69 74 68 20 6c  ize-items with l
3700: 6f 67 66 20 22 20 6c 6f 67 66 29 0a 20 20 20 20  ogf " logf).    
3710: 28 69 66 20 28 6f 72 20 28 65 71 75 61 6c 3f 20  (if (or (equal? 
3720: 6c 6f 67 66 20 22 6c 6f 67 73 2f 66 69 6e 61 6c  logf "logs/final
3730: 2e 6c 6f 67 22 29 0a 09 20 20 20 20 28 65 71 75  .log")..    (equ
3740: 61 6c 3f 20 6c 6f 67 66 20 6f 75 74 70 75 74 66  al? logf outputf
3750: 69 6c 65 6e 61 6d 65 29 0a 09 20 20 20 20 66 6f  ilename)..    fo
3760: 72 63 65 29 0a 09 28 62 65 67 69 6e 0a 09 20 20  rce)..(begin..  
3770: 28 69 66 20 28 6f 62 74 61 69 6e 2d 64 6f 74 2d  (if (obtain-dot-
3780: 6c 6f 63 6b 20 6f 75 74 70 75 74 66 69 6c 65 6e  lock outputfilen
3790: 61 6d 65 20 31 20 32 30 20 33 30 29 20 3b 3b 20  ame 1 20 30) ;; 
37a0: 72 65 74 72 79 20 65 76 65 72 79 20 73 65 63 6f  retry every seco
37b0: 6e 64 20 66 6f 72 20 32 30 20 73 65 63 6f 6e 64  nd for 20 second
37c0: 73 2c 20 63 61 6c 6c 20 69 74 20 64 65 61 64 20  s, call it dead 
37d0: 61 66 74 65 72 20 33 30 20 73 65 63 6f 6e 64 73  after 30 seconds
37e0: 20 61 6e 64 20 73 74 65 61 6c 20 74 68 65 20 6c   and steal the l
37f0: 6f 63 6b 0a 09 20 20 20 20 20 20 28 70 72 69 6e  ock..      (prin
3800: 74 20 22 4f 62 74 61 69 6e 65 64 20 6c 6f 63 6b  t "Obtained lock
3810: 20 66 6f 72 20 22 20 6f 75 74 70 75 74 66 69 6c   for " outputfil
3820: 65 6e 61 6d 65 29 0a 09 20 20 20 20 20 20 28 70  ename)..      (p
3830: 72 69 6e 74 20 22 46 61 69 6c 65 64 20 74 6f 20  rint "Failed to 
3840: 6f 62 74 61 69 6e 20 6c 6f 63 6b 20 66 6f 72 20  obtain lock for 
3850: 22 20 6f 75 74 70 75 74 66 69 6c 65 6e 61 6d 65  " outputfilename
3860: 29 29 0a 09 20 20 28 6c 65 74 20 28 28 6f 75 70  ))..  (let ((oup
3870: 20 20 20 20 28 6f 70 65 6e 2d 6f 75 74 70 75 74      (open-output
3880: 2d 66 69 6c 65 20 6f 75 74 70 75 74 66 69 6c 65  -file outputfile
3890: 6e 61 6d 65 29 29 0a 09 09 28 63 6f 75 6e 74 73  name))...(counts
38a0: 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c   (make-hash-tabl
38b0: 65 29 29 0a 09 09 28 73 74 61 74 65 63 6f 75 6e  e))...(statecoun
38c0: 74 73 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61  ts (make-hash-ta
38d0: 62 6c 65 29 29 0a 09 09 28 6f 75 74 74 78 74 20  ble))...(outtxt 
38e0: 22 22 29 0a 09 09 28 74 6f 74 20 20 20 20 30 29  "")...(tot    0)
38f0: 29 0a 09 20 20 20 20 28 77 69 74 68 2d 6f 75 74  )..    (with-out
3900: 70 75 74 2d 74 6f 2d 70 6f 72 74 0a 09 09 6f 75  put-to-port...ou
3910: 70 0a 09 20 20 20 20 20 20 28 6c 61 6d 62 64 61  p..      (lambda
3920: 20 28 29 0a 09 09 28 73 65 74 21 20 6f 75 74 74   ()...(set! outt
3930: 78 74 20 28 63 6f 6e 63 20 6f 75 74 74 78 74 20  xt (conc outtxt 
3940: 22 3c 68 74 6d 6c 3e 3c 74 69 74 6c 65 3e 53 75  "<html><title>Su
3950: 6d 6d 61 72 79 3a 20 22 20 74 65 73 74 2d 6e 61  mmary: " test-na
3960: 6d 65 20 0a 09 09 09 09 20 20 20 22 3c 2f 74 69  me .....   "</ti
3970: 74 6c 65 3e 3c 62 6f 64 79 3e 3c 68 32 3e 53 75  tle><body><h2>Su
3980: 6d 6d 61 72 79 20 66 6f 72 20 22 20 74 65 73 74  mmary for " test
3990: 2d 6e 61 6d 65 20 22 3c 2f 68 32 3e 22 29 29 0a  -name "</h2>")).
39a0: 09 09 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65  ..(sqlite3:for-e
39b0: 61 63 68 2d 72 6f 77 20 0a 09 09 20 28 6c 61 6d  ach-row ... (lam
39c0: 62 64 61 20 28 69 64 20 69 74 65 6d 70 61 74 68  bda (id itempath
39d0: 20 73 74 61 74 65 20 73 74 61 74 75 73 20 72 75   state status ru
39e0: 6e 5f 64 75 72 61 74 69 6f 6e 20 6c 6f 67 66 20  n_duration logf 
39f0: 63 6f 6d 6d 65 6e 74 29 0a 09 09 20 20 20 28 68  comment)...   (h
3a00: 61 73 68 2d 74 61 62 6c 65 2d 73 65 74 21 20 63  ash-table-set! c
3a10: 6f 75 6e 74 73 20 73 74 61 74 75 73 20 28 2b 20  ounts status (+ 
3a20: 31 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65  1 (hash-table-re
3a30: 66 2f 64 65 66 61 75 6c 74 20 63 6f 75 6e 74 73  f/default counts
3a40: 20 73 74 61 74 75 73 20 30 29 29 29 0a 09 09 20   status 0)))... 
3a50: 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65    (hash-table-se
3a60: 74 21 20 73 74 61 74 65 63 6f 75 6e 74 73 20 73  t! statecounts s
3a70: 74 61 74 65 20 28 2b 20 31 20 28 68 61 73 68 2d  tate (+ 1 (hash-
3a80: 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c  table-ref/defaul
3a90: 74 20 73 74 61 74 65 63 6f 75 6e 74 73 20 73 74  t statecounts st
3aa0: 61 74 65 20 30 29 29 29 0a 09 09 20 20 20 28 73  ate 0)))...   (s
3ab0: 65 74 21 20 6f 75 74 74 78 74 20 28 63 6f 6e 63  et! outtxt (conc
3ac0: 20 6f 75 74 74 78 74 20 22 3c 74 72 3e 22 0a 09   outtxt "<tr>"..
3ad0: 09 09 09 20 20 20 20 20 20 22 3c 74 64 3e 3c 61  ...      "<td><a
3ae0: 20 68 72 65 66 3d 5c 22 22 20 69 74 65 6d 70 61   href=\"" itempa
3af0: 74 68 20 22 2f 22 20 6c 6f 67 66 20 22 5c 22 3e  th "/" logf "\">
3b00: 20 22 20 69 74 65 6d 70 61 74 68 20 22 3c 2f 61   " itempath "</a
3b10: 3e 3c 2f 74 64 3e 22 20 0a 09 09 09 09 20 20 20  ></td>" .....   
3b20: 20 20 20 22 3c 74 64 3e 22 20 73 74 61 74 65 20     "<td>" state 
3b30: 20 20 20 22 3c 2f 74 64 3e 22 20 0a 09 09 09 09     "</td>" .....
3b40: 20 20 20 20 20 20 22 3c 74 64 3e 3c 66 6f 6e 74        "<td><font
3b50: 20 63 6f 6c 6f 72 3d 22 20 28 63 6f 6d 6d 6f 6e   color=" (common
3b60: 3a 67 65 74 2d 63 6f 6c 6f 72 2d 66 72 6f 6d 2d  :get-color-from-
3b70: 73 74 61 74 75 73 20 73 74 61 74 75 73 29 0a 09  status status)..
3b80: 09 09 09 20 20 20 20 20 20 22 3e 22 20 20 20 73  ...      ">"   s
3b90: 74 61 74 75 73 20 20 20 22 3c 2f 66 6f 6e 74 3e  tatus   "</font>
3ba0: 3c 2f 74 64 3e 22 0a 09 09 09 09 20 20 20 20 20  </td>".....     
3bb0: 20 22 3c 74 64 3e 22 20 28 69 66 20 28 65 71 75   "<td>" (if (equ
3bc0: 61 6c 3f 20 63 6f 6d 6d 65 6e 74 20 22 22 29 0a  al? comment "").
3bd0: 09 09 09 09 09 09 20 22 26 6e 62 73 70 3b 22 0a  ...... "&nbsp;".
3be0: 09 09 09 09 09 09 20 63 6f 6d 6d 65 6e 74 29 20  ...... comment) 
3bf0: 22 3c 2f 74 64 3e 22 0a 09 09 09 09 09 09 20 22  "</td>"....... "
3c00: 3c 2f 74 72 3e 22 29 29 29 0a 09 09 20 64 62 0a  </tr>")))... db.
3c10: 09 09 20 22 53 45 4c 45 43 54 20 69 64 2c 69 74  .. "SELECT id,it
3c20: 65 6d 5f 70 61 74 68 2c 73 74 61 74 65 2c 73 74  em_path,state,st
3c30: 61 74 75 73 2c 72 75 6e 5f 64 75 72 61 74 69 6f  atus,run_duratio
3c40: 6e 2c 66 69 6e 61 6c 5f 6c 6f 67 66 2c 63 6f 6d  n,final_logf,com
3c50: 6d 65 6e 74 20 46 52 4f 4d 20 74 65 73 74 73 20  ment FROM tests 
3c60: 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41  WHERE run_id=? A
3c70: 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e  ND testname=? AN
3c80: 44 20 69 74 65 6d 5f 70 61 74 68 20 21 3d 20 27  D item_path != '
3c90: 27 3b 22 0a 09 09 20 72 75 6e 2d 69 64 20 74 65  ';"... run-id te
3ca0: 73 74 2d 6e 61 6d 65 29 0a 0a 09 09 28 70 72 69  st-name)....(pri
3cb0: 6e 74 20 22 3c 74 61 62 6c 65 3e 3c 74 72 3e 3c  nt "<table><tr><
3cc0: 74 64 20 76 61 6c 69 67 6e 3d 5c 22 74 6f 70 5c  td valign=\"top\
3cd0: 22 3e 22 29 0a 09 09 3b 3b 20 50 72 69 6e 74 20  ">")...;; Print 
3ce0: 6f 75 74 20 73 74 61 74 73 20 66 6f 72 20 73 74  out stats for st
3cf0: 61 74 75 73 0a 09 09 28 73 65 74 21 20 74 6f 74  atus...(set! tot
3d00: 20 30 29 0a 09 09 28 70 72 69 6e 74 20 22 3c 74   0)...(print "<t
3d10: 61 62 6c 65 20 63 65 6c 6c 73 70 61 63 69 6e 67  able cellspacing
3d20: 3d 5c 22 30 5c 22 20 62 6f 72 64 65 72 3d 5c 22  =\"0\" border=\"
3d30: 31 5c 22 3e 3c 74 72 3e 3c 74 64 20 63 6f 6c 73  1\"><tr><td cols
3d40: 70 61 6e 3d 5c 22 32 5c 22 3e 3c 68 32 3e 53 74  pan=\"2\"><h2>St
3d50: 61 74 65 20 73 74 61 74 73 3c 2f 68 32 3e 3c 2f  ate stats</h2></
3d60: 74 64 3e 3c 2f 74 72 3e 22 29 0a 09 09 28 66 6f  td></tr>")...(fo
3d70: 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 20 28  r-each (lambda (
3d80: 73 74 61 74 65 29 0a 09 09 09 20 20 20 20 28 73  state)....    (s
3d90: 65 74 21 20 74 6f 74 20 28 2b 20 74 6f 74 20 28  et! tot (+ tot (
3da0: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 20 73  hash-table-ref s
3db0: 74 61 74 65 63 6f 75 6e 74 73 20 73 74 61 74 65  tatecounts state
3dc0: 29 29 29 0a 09 09 09 20 20 20 20 28 70 72 69 6e  )))....    (prin
3dd0: 74 20 22 3c 74 72 3e 3c 74 64 3e 22 20 73 74 61  t "<tr><td>" sta
3de0: 74 65 20 22 3c 2f 74 64 3e 3c 74 64 3e 22 20 28  te "</td><td>" (
3df0: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 20 73  hash-table-ref s
3e00: 74 61 74 65 63 6f 75 6e 74 73 20 73 74 61 74 65  tatecounts state
3e10: 29 20 22 3c 2f 74 64 3e 3c 2f 74 72 3e 22 29 29  ) "</td></tr>"))
3e20: 0a 09 09 09 20 20 28 68 61 73 68 2d 74 61 62 6c  ....  (hash-tabl
3e30: 65 2d 6b 65 79 73 20 73 74 61 74 65 63 6f 75 6e  e-keys statecoun
3e40: 74 73 29 29 0a 09 09 28 70 72 69 6e 74 20 22 3c  ts))...(print "<
3e50: 74 72 3e 3c 74 64 3e 54 6f 74 61 6c 3c 2f 74 64  tr><td>Total</td
3e60: 3e 3c 74 64 3e 22 20 74 6f 74 20 22 3c 2f 74 64  ><td>" tot "</td
3e70: 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e 22 29  ></tr></table>")
3e80: 0a 09 09 28 70 72 69 6e 74 20 22 3c 2f 74 64 3e  ...(print "</td>
3e90: 3c 74 64 20 76 61 6c 69 67 6e 3d 5c 22 74 6f 70  <td valign=\"top
3ea0: 5c 22 3e 22 29 0a 09 09 3b 3b 20 50 72 69 6e 74  \">")...;; Print
3eb0: 20 6f 75 74 20 73 74 61 74 73 20 66 6f 72 20 73   out stats for s
3ec0: 74 61 74 65 0a 09 09 28 73 65 74 21 20 74 6f 74  tate...(set! tot
3ed0: 20 30 29 0a 09 09 28 70 72 69 6e 74 20 22 3c 74   0)...(print "<t
3ee0: 61 62 6c 65 20 63 65 6c 6c 73 70 61 63 69 6e 67  able cellspacing
3ef0: 3d 5c 22 30 5c 22 20 62 6f 72 64 65 72 3d 5c 22  =\"0\" border=\"
3f00: 31 5c 22 3e 3c 74 72 3e 3c 74 64 20 63 6f 6c 73  1\"><tr><td cols
3f10: 70 61 6e 3d 5c 22 32 5c 22 3e 3c 68 32 3e 53 74  pan=\"2\"><h2>St
3f20: 61 74 75 73 20 73 74 61 74 73 3c 2f 68 32 3e 3c  atus stats</h2><
3f30: 2f 74 64 3e 3c 2f 74 72 3e 22 29 0a 09 09 28 66  /td></tr>")...(f
3f40: 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 20  or-each (lambda 
3f50: 28 73 74 61 74 75 73 29 0a 09 09 09 20 20 20 20  (status)....    
3f60: 28 73 65 74 21 20 74 6f 74 20 28 2b 20 74 6f 74  (set! tot (+ tot
3f70: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
3f80: 20 63 6f 75 6e 74 73 20 73 74 61 74 75 73 29 29   counts status))
3f90: 29 0a 09 09 09 20 20 20 20 28 70 72 69 6e 74 20  )....    (print 
3fa0: 22 3c 74 72 3e 3c 74 64 3e 3c 66 6f 6e 74 20 63  "<tr><td><font c
3fb0: 6f 6c 6f 72 3d 5c 22 22 20 28 63 6f 6d 6d 6f 6e  olor=\"" (common
3fc0: 3a 67 65 74 2d 63 6f 6c 6f 72 2d 66 72 6f 6d 2d  :get-color-from-
3fd0: 73 74 61 74 75 73 20 73 74 61 74 75 73 29 20 22  status status) "
3fe0: 5c 22 3e 22 20 73 74 61 74 75 73 0a 09 09 09 09  \">" status.....
3ff0: 20 20 20 22 3c 2f 66 6f 6e 74 3e 3c 2f 74 64 3e     "</font></td>
4000: 3c 74 64 3e 22 20 28 68 61 73 68 2d 74 61 62 6c  <td>" (hash-tabl
4010: 65 2d 72 65 66 20 63 6f 75 6e 74 73 20 73 74 61  e-ref counts sta
4020: 74 75 73 29 20 22 3c 2f 74 64 3e 3c 2f 74 72 3e  tus) "</td></tr>
4030: 22 29 29 0a 09 09 09 20 20 28 68 61 73 68 2d 74  "))....  (hash-t
4040: 61 62 6c 65 2d 6b 65 79 73 20 63 6f 75 6e 74 73  able-keys counts
4050: 29 29 0a 09 09 28 70 72 69 6e 74 20 22 3c 74 72  ))...(print "<tr
4060: 3e 3c 74 64 3e 54 6f 74 61 6c 3c 2f 74 64 3e 3c  ><td>Total</td><
4070: 74 64 3e 22 20 74 6f 74 20 22 3c 2f 74 64 3e 3c  td>" tot "</td><
4080: 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e 22 29 0a 09  /tr></table>")..
4090: 09 28 70 72 69 6e 74 20 22 3c 2f 74 64 3e 3c 2f  .(print "</td></
40a0: 74 64 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e  td></tr></table>
40b0: 22 29 0a 0a 09 09 28 70 72 69 6e 74 20 22 3c 74  ")....(print "<t
40c0: 61 62 6c 65 20 63 65 6c 6c 73 70 61 63 69 6e 67  able cellspacing
40d0: 3d 5c 22 30 5c 22 20 62 6f 72 64 65 72 3d 5c 22  =\"0\" border=\"
40e0: 31 5c 22 3e 22 20 0a 09 09 20 20 20 20 20 20 20  1\">" ...       
40f0: 22 3c 74 72 3e 3c 74 64 3e 49 74 65 6d 3c 2f 74  "<tr><td>Item</t
4100: 64 3e 3c 74 64 3e 53 74 61 74 65 3c 2f 74 64 3e  d><td>State</td>
4110: 3c 74 64 3e 53 74 61 74 75 73 3c 2f 74 64 3e 3c  <td>Status</td><
4120: 74 64 3e 43 6f 6d 6d 65 6e 74 3c 2f 74 64 3e 22  td>Comment</td>"
4130: 0a 09 09 20 20 20 20 20 20 20 6f 75 74 74 78 74  ...       outtxt
4140: 20 22 3c 2f 74 61 62 6c 65 3e 3c 2f 62 6f 64 79   "</table></body
4150: 3e 3c 2f 68 74 6d 6c 3e 22 29 0a 09 09 28 72 65  ></html>")...(re
4160: 6c 65 61 73 65 2d 64 6f 74 2d 6c 6f 63 6b 20 6f  lease-dot-lock o
4170: 75 74 70 75 74 66 69 6c 65 6e 61 6d 65 29 29 29  utputfilename)))
4180: 0a 09 20 20 20 20 28 63 6c 6f 73 65 2d 6f 75 74  ..    (close-out
4190: 70 75 74 2d 70 6f 72 74 20 6f 75 70 29 0a 09 20  put-port oup).. 
41a0: 20 20 20 28 63 68 61 6e 67 65 2d 64 69 72 65 63     (change-direc
41b0: 74 6f 72 79 20 6f 72 69 67 2d 64 69 72 29 0a 09  tory orig-dir)..
41c0: 20 20 20 20 28 74 65 73 74 2d 73 65 74 2d 74 6f      (test-set-to
41d0: 70 6c 6f 67 21 20 64 62 20 72 75 6e 2d 69 64 20  plog! db run-id 
41e0: 74 65 73 74 2d 6e 61 6d 65 20 6f 75 74 70 75 74  test-name output
41f0: 66 69 6c 65 6e 61 6d 65 29 0a 09 20 20 20 20 29  filename)..    )
4200: 29 29 29 29 0a 0a 3b 3b 20 3b 3b 20 54 4f 44 4f  ))))..;; ;; TODO
4210: 3a 20 43 6f 6e 76 65 72 67 65 20 74 68 69 73 20  : Converge this 
4220: 77 69 74 68 20 64 62 3a 67 65 74 2d 74 65 73 74  with db:get-test
4230: 2d 69 6e 66 6f 0a 3b 3b 20 28 64 65 66 69 6e 65  -info.;; (define
4240: 20 28 72 75 6e 73 3a 67 65 74 2d 74 65 73 74 2d   (runs:get-test-
4250: 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74  info db run-id t
4260: 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61  est-name item-pa
4270: 74 68 29 0a 3b 3b 20 20 20 28 6c 65 74 20 28 28  th).;;   (let ((
4280: 72 65 73 20 23 66 29 29 20 3b 3b 20 28 76 65 63  res #f)) ;; (vec
4290: 74 6f 72 20 23 66 20 23 66 20 23 66 20 23 66 20  tor #f #f #f #f 
42a0: 23 66 20 23 66 29 29 29 0a 3b 3b 20 20 20 20 20  #f #f))).;;     
42b0: 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63  (sqlite3:for-eac
42c0: 68 2d 72 6f 77 20 0a 3b 3b 20 20 20 20 20 20 28  h-row .;;      (
42d0: 6c 61 6d 62 64 61 20 28 69 64 20 72 75 6e 2d 69  lambda (id run-i
42e0: 64 20 74 65 73 74 2d 6e 61 6d 65 20 73 74 61 74  d test-name stat
42f0: 65 20 73 74 61 74 75 73 29 0a 3b 3b 20 20 20 20  e status).;;    
4300: 20 20 20 20 28 73 65 74 21 20 72 65 73 20 28 76      (set! res (v
4310: 65 63 74 6f 72 20 69 64 20 72 75 6e 2d 69 64 20  ector id run-id 
4320: 74 65 73 74 2d 6e 61 6d 65 20 73 74 61 74 65 20  test-name state 
4330: 73 74 61 74 75 73 20 69 74 65 6d 2d 70 61 74 68  status item-path
4340: 29 29 29 0a 3b 3b 20 20 20 20 20 20 64 62 20 22  ))).;;      db "
4350: 53 45 4c 45 43 54 20 69 64 2c 72 75 6e 5f 69 64  SELECT id,run_id
4360: 2c 74 65 73 74 6e 61 6d 65 2c 73 74 61 74 65 2c  ,testname,state,
4370: 73 74 61 74 75 73 20 46 52 4f 4d 20 74 65 73 74  status FROM test
4380: 73 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f  s WHERE run_id=?
4390: 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20   AND testname=? 
43a0: 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f 3b  AND item_path=?;
43b0: 22 0a 3b 3b 20 20 20 20 20 20 72 75 6e 2d 69 64  ".;;      run-id
43c0: 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d   test-name item-
43d0: 70 61 74 68 29 0a 3b 3b 20 20 20 20 20 72 65 73  path).;;     res
43e0: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 72 75 6e  ))..(define (run
43f0: 73 3a 74 65 73 74 2d 67 65 74 2d 66 75 6c 6c 2d  s:test-get-full-
4400: 70 61 74 68 20 74 65 73 74 29 0a 20 20 28 6c 65  path test).  (le
4410: 74 2a 20 28 28 74 65 73 74 6e 61 6d 65 20 28 64  t* ((testname (d
4420: 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e  b:test-get-testn
4430: 61 6d 65 20 20 20 74 65 73 74 29 29 0a 09 20 28  ame   test)).. (
4440: 69 74 65 6d 70 61 74 68 20 28 64 62 3a 74 65 73  itempath (db:tes
4450: 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20  t-get-item-path 
4460: 74 65 73 74 29 29 29 0a 20 20 20 20 28 63 6f 6e  test))).    (con
4470: 63 20 74 65 73 74 6e 61 6d 65 20 28 69 66 20 28  c testname (if (
4480: 65 71 75 61 6c 3f 20 69 74 65 6d 70 61 74 68 20  equal? itempath 
4490: 22 22 29 20 22 22 20 28 63 6f 6e 63 20 22 28 22  "") "" (conc "("
44a0: 20 69 74 65 6d 70 61 74 68 20 22 29 22 29 29 29   itempath ")")))
44b0: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 63 68 65  ))..(define (che
44c0: 63 6b 2d 76 61 6c 69 64 2d 69 74 65 6d 73 20 63  ck-valid-items c
44d0: 6c 61 73 73 20 69 74 65 6d 29 0a 20 20 28 6c 65  lass item).  (le
44e0: 74 20 28 28 76 61 6c 69 64 2d 76 61 6c 75 65 73  t ((valid-values
44f0: 20 28 6c 65 74 20 28 28 73 20 28 63 6f 6e 66 69   (let ((s (confi
4500: 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67  g-lookup *config
4510: 64 61 74 2a 20 22 76 61 6c 69 64 76 61 6c 75 65  dat* "validvalue
4520: 73 22 20 63 6c 61 73 73 29 29 29 0a 09 09 09 28  s" class)))....(
4530: 69 66 20 73 20 28 73 74 72 69 6e 67 2d 73 70 6c  if s (string-spl
4540: 69 74 20 73 29 20 23 66 29 29 29 29 0a 20 20 20  it s) #f)))).   
4550: 20 28 69 66 20 76 61 6c 69 64 2d 76 61 6c 75 65   (if valid-value
4560: 73 0a 09 28 69 66 20 28 6d 65 6d 62 65 72 20 69  s..(if (member i
4570: 74 65 6d 20 76 61 6c 69 64 2d 76 61 6c 75 65 73  tem valid-values
4580: 29 0a 09 20 20 20 20 69 74 65 6d 20 23 66 29 0a  )..    item #f).
4590: 09 69 74 65 6d 29 29 29 0a 0a 28 64 65 66 69 6e  .item)))..(defin
45a0: 65 20 28 74 65 73 74 73 74 65 70 2d 73 65 74 2d  e (teststep-set-
45b0: 73 74 61 74 75 73 21 20 64 62 20 72 75 6e 2d 69  status! db run-i
45c0: 64 20 74 65 73 74 2d 6e 61 6d 65 20 74 65 73 74  d test-name test
45d0: 73 74 65 70 2d 6e 61 6d 65 20 73 74 61 74 65 2d  step-name state-
45e0: 69 6e 20 73 74 61 74 75 73 2d 69 6e 20 69 74 65  in status-in ite
45f0: 6d 64 61 74 20 63 6f 6d 6d 65 6e 74 20 6c 6f 67  mdat comment log
4600: 66 69 6c 65 29 0a 20 20 28 64 65 62 75 67 3a 70  file).  (debug:p
4610: 72 69 6e 74 20 34 20 22 72 75 6e 2d 69 64 3a 20  rint 4 "run-id: 
4620: 22 20 72 75 6e 2d 69 64 20 22 20 74 65 73 74 2d  " run-id " test-
4630: 6e 61 6d 65 3a 20 22 20 74 65 73 74 2d 6e 61 6d  name: " test-nam
4640: 65 29 0a 20 20 28 6c 65 74 2a 20 28 28 73 74 61  e).  (let* ((sta
4650: 74 65 20 20 20 20 20 28 63 68 65 63 6b 2d 76 61  te     (check-va
4660: 6c 69 64 2d 69 74 65 6d 73 20 22 73 74 61 74 65  lid-items "state
4670: 22 20 73 74 61 74 65 2d 69 6e 29 29 0a 09 20 28  " state-in)).. (
4680: 73 74 61 74 75 73 20 20 20 20 28 63 68 65 63 6b  status    (check
4690: 2d 76 61 6c 69 64 2d 69 74 65 6d 73 20 22 73 74  -valid-items "st
46a0: 61 74 75 73 22 20 73 74 61 74 75 73 2d 69 6e 29  atus" status-in)
46b0: 29 0a 09 20 28 69 74 65 6d 2d 70 61 74 68 20 28  ).. (item-path (
46c0: 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20  item-list->path 
46d0: 69 74 65 6d 64 61 74 29 29 0a 09 20 28 74 65 73  itemdat)).. (tes
46e0: 74 64 61 74 20 20 20 28 64 62 3a 67 65 74 2d 74  tdat   (db:get-t
46f0: 65 73 74 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d  est-info db run-
4700: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65  id test-name ite
4710: 6d 2d 70 61 74 68 29 29 29 0a 20 20 20 20 28 64  m-path))).    (d
4720: 65 62 75 67 3a 70 72 69 6e 74 20 35 20 22 74 65  ebug:print 5 "te
4730: 73 74 64 61 74 3a 20 22 20 74 65 73 74 64 61 74  stdat: " testdat
4740: 29 0a 20 20 20 20 28 69 66 20 28 61 6e 64 20 74  ).    (if (and t
4750: 65 73 74 64 61 74 20 3b 3b 20 69 66 20 74 68 65  estdat ;; if the
4760: 20 73 65 63 74 69 6f 6e 20 65 78 69 73 74 73 20   section exists 
4770: 74 68 65 6e 20 66 6f 72 63 65 20 73 70 65 63 69  then force speci
4780: 66 69 63 61 74 69 6f 6e 20 42 55 47 2c 20 49 20  fication BUG, I 
4790: 64 6f 6e 27 74 20 6c 69 6b 65 20 68 6f 77 20 74  don't like how t
47a0: 68 69 73 20 77 6f 72 6b 73 2e 0a 09 20 20 20 20  his works...    
47b0: 20 28 6f 72 20 28 6e 6f 74 20 73 74 61 74 65 29   (or (not state)
47c0: 28 6e 6f 74 20 73 74 61 74 75 73 29 29 29 0a 09  (not status)))..
47d0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
47e0: 57 41 52 4e 49 4e 47 3a 20 49 6e 76 61 6c 69 64  WARNING: Invalid
47f0: 20 22 20 28 69 66 20 73 74 61 74 75 73 20 22 73   " (if status "s
4800: 74 61 74 75 73 22 20 22 73 74 61 74 65 22 29 0a  tatus" "state").
4810: 09 20 20 20 20 20 20 20 22 20 76 61 6c 75 65 20  .       " value 
4820: 5c 22 22 20 28 69 66 20 73 74 61 74 75 73 20 73  \"" (if status s
4830: 74 61 74 65 2d 69 6e 20 73 74 61 74 75 73 2d 69  tate-in status-i
4840: 6e 29 20 22 5c 22 2c 20 75 70 64 61 74 65 20 79  n) "\", update y
4850: 6f 75 72 20 76 61 6c 69 64 76 61 6c 75 65 73 20  our validvalues 
4860: 73 65 63 74 69 6f 6e 20 69 6e 20 6d 65 67 61 74  section in megat
4870: 65 73 74 2e 63 6f 6e 66 69 67 22 29 29 0a 20 20  est.config")).  
4880: 20 20 28 69 66 20 74 65 73 74 64 61 74 0a 09 28    (if testdat..(
4890: 6c 65 74 20 28 28 74 65 73 74 2d 69 64 20 28 74  let ((test-id (t
48a0: 65 73 74 3a 67 65 74 2d 69 64 20 74 65 73 74 64  est:get-id testd
48b0: 61 74 29 29 29 0a 09 20 20 3b 3b 20 46 49 58 4d  at)))..  ;; FIXM
48c0: 45 20 2d 20 74 68 69 73 20 73 68 6f 75 6c 64 20  E - this should 
48d0: 6e 6f 74 20 75 70 64 61 74 65 20 74 68 65 20 6c  not update the l
48e0: 6f 67 66 69 6c 65 20 75 6e 6c 65 73 73 20 69 74  ogfile unless it
48f0: 20 69 73 20 73 70 65 63 69 66 69 65 64 2e 0a 09   is specified...
4900: 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75    (sqlite3:execu
4910: 74 65 20 64 62 20 0a 09 09 09 22 49 4e 53 45 52  te db ...."INSER
4920: 54 20 4f 52 20 52 45 50 4c 41 43 45 20 69 6e 74  T OR REPLACE int
4930: 6f 20 74 65 73 74 5f 73 74 65 70 73 20 28 74 65  o test_steps (te
4940: 73 74 5f 69 64 2c 73 74 65 70 6e 61 6d 65 2c 73  st_id,stepname,s
4950: 74 61 74 65 2c 73 74 61 74 75 73 2c 65 76 65 6e  tate,status,even
4960: 74 5f 74 69 6d 65 2c 63 6f 6d 6d 65 6e 74 2c 6c  t_time,comment,l
4970: 6f 67 66 69 6c 65 29 20 56 41 4c 55 45 53 28 3f  ogfile) VALUES(?
4980: 2c 3f 2c 3f 2c 3f 2c 73 74 72 66 74 69 6d 65 28  ,?,?,?,strftime(
4990: 27 25 73 27 2c 27 6e 6f 77 27 29 2c 3f 2c 3f 29  '%s','now'),?,?)
49a0: 3b 22 0a 09 09 09 74 65 73 74 2d 69 64 20 74 65  ;"....test-id te
49b0: 73 74 73 74 65 70 2d 6e 61 6d 65 20 73 74 61 74  ststep-name stat
49c0: 65 2d 69 6e 20 73 74 61 74 75 73 2d 69 6e 20 28  e-in status-in (
49d0: 69 66 20 63 6f 6d 6d 65 6e 74 20 63 6f 6d 6d 65  if comment comme
49e0: 6e 74 20 22 22 29 20 28 69 66 20 6c 6f 67 66 69  nt "") (if logfi
49f0: 6c 65 20 6c 6f 67 66 69 6c 65 20 22 22 29 29 29  le logfile "")))
4a00: 0a 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30  ..(debug:print 0
4a10: 20 22 45 52 52 4f 52 3a 20 43 61 6e 27 74 20 75   "ERROR: Can't u
4a20: 70 64 61 74 65 20 22 20 74 65 73 74 2d 6e 61 6d  pdate " test-nam
4a30: 65 20 22 20 66 6f 72 20 72 75 6e 20 22 20 72 75  e " for run " ru
4a40: 6e 2d 69 64 20 22 20 2d 3e 20 6e 6f 20 73 75 63  n-id " -> no suc
4a50: 68 20 74 65 73 74 20 69 6e 20 64 62 22 29 29 29  h test in db")))
4a60: 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65 73 74  )..(define (test
4a70: 2d 67 65 74 2d 6b 69 6c 6c 2d 72 65 71 75 65 73  -get-kill-reques
4a80: 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  t db run-id test
4a90: 2d 6e 61 6d 65 20 69 74 65 6d 64 61 74 29 0a 20  -name itemdat). 
4aa0: 20 28 6c 65 74 2a 20 28 28 69 74 65 6d 2d 70 61   (let* ((item-pa
4ab0: 74 68 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70  th (item-list->p
4ac0: 61 74 68 20 69 74 65 6d 64 61 74 29 29 0a 09 20  ath itemdat)).. 
4ad0: 28 74 65 73 74 64 61 74 20 20 20 28 64 62 3a 67  (testdat   (db:g
4ae0: 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 20  et-test-info db 
4af0: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
4b00: 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 20 20   item-path))).  
4b10: 20 20 28 65 71 75 61 6c 3f 20 28 74 65 73 74 3a    (equal? (test:
4b20: 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61  get-state testda
4b30: 74 29 20 22 4b 49 4c 4c 52 45 51 22 29 29 29 0a  t) "KILLREQ"))).
4b40: 0a 28 64 65 66 69 6e 65 20 28 74 65 73 74 2d 73  .(define (test-s
4b50: 65 74 2d 6d 65 74 61 2d 69 6e 66 6f 20 64 62 20  et-meta-info db 
4b60: 72 75 6e 2d 69 64 20 74 65 73 74 6e 61 6d 65 20  run-id testname 
4b70: 69 74 65 6d 64 61 74 29 0a 20 20 28 6c 65 74 20  itemdat).  (let 
4b80: 28 28 69 74 65 6d 2d 70 61 74 68 20 28 69 74 65  ((item-path (ite
4b90: 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69 74 65  m-list->path ite
4ba0: 6d 64 61 74 29 29 0a 09 28 63 70 75 6c 6f 61 64  mdat))..(cpuload
4bb0: 20 20 28 67 65 74 2d 63 70 75 2d 6c 6f 61 64 29    (get-cpu-load)
4bc0: 29 0a 09 28 68 6f 73 74 6e 61 6d 65 20 28 67 65  )..(hostname (ge
4bd0: 74 2d 68 6f 73 74 2d 6e 61 6d 65 29 29 0a 09 28  t-host-name))..(
4be0: 64 69 73 6b 66 72 65 65 20 28 67 65 74 2d 64 66  diskfree (get-df
4bf0: 20 28 63 75 72 72 65 6e 74 2d 64 69 72 65 63 74   (current-direct
4c00: 6f 72 79 29 29 29 0a 09 28 75 6e 61 6d 65 20 20  ory)))..(uname  
4c10: 20 20 28 67 65 74 2d 75 6e 61 6d 65 20 22 2d 73    (get-uname "-s
4c20: 72 76 70 69 6f 22 29 29 0a 09 28 72 75 6e 70 61  rvpio"))..(runpa
4c30: 74 68 20 20 28 63 75 72 72 65 6e 74 2d 64 69 72  th  (current-dir
4c40: 65 63 74 6f 72 79 29 29 29 0a 20 20 20 20 28 73  ectory))).    (s
4c50: 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 64  qlite3:execute d
4c60: 62 20 22 55 50 44 41 54 45 20 74 65 73 74 73 20  b "UPDATE tests 
4c70: 53 45 54 20 68 6f 73 74 3d 3f 2c 63 70 75 6c 6f  SET host=?,cpulo
4c80: 61 64 3d 3f 2c 64 69 73 6b 66 72 65 65 3d 3f 2c  ad=?,diskfree=?,
4c90: 75 6e 61 6d 65 3d 3f 2c 72 75 6e 64 69 72 3d 3f  uname=?,rundir=?
4ca0: 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20   WHERE run_id=? 
4cb0: 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41  AND testname=? A
4cc0: 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f 3b 22  ND item_path=?;"
4cd0: 0a 09 09 20 20 68 6f 73 74 6e 61 6d 65 0a 09 09  ...  hostname...
4ce0: 20 20 63 70 75 6c 6f 61 64 0a 09 09 20 20 64 69    cpuload...  di
4cf0: 73 6b 66 72 65 65 0a 09 09 20 20 75 6e 61 6d 65  skfree...  uname
4d00: 0a 09 09 20 20 72 75 6e 70 61 74 68 0a 09 09 20  ...  runpath... 
4d10: 20 72 75 6e 2d 69 64 0a 09 09 20 20 74 65 73 74   run-id...  test
4d20: 6e 61 6d 65 0a 09 09 20 20 69 74 65 6d 2d 70 61  name...  item-pa
4d30: 74 68 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28  th)))..(define (
4d40: 74 65 73 74 2d 75 70 64 61 74 65 2d 6d 65 74 61  test-update-meta
4d50: 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64 20  -info db run-id 
4d60: 74 65 73 74 6e 61 6d 65 20 69 74 65 6d 64 61 74  testname itemdat
4d70: 20 6d 69 6e 75 74 65 73 20 63 70 75 6c 6f 61 64   minutes cpuload
4d80: 20 64 69 73 6b 66 72 65 65 20 74 6d 70 66 72 65   diskfree tmpfre
4d90: 65 29 0a 20 20 28 6c 65 74 20 28 28 69 74 65 6d  e).  (let ((item
4da0: 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c 69 73 74  -path (item-list
4db0: 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74 29 29  ->path itemdat))
4dc0: 29 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 69  ).    (if (not i
4dd0: 74 65 6d 2d 70 61 74 68 29 28 62 65 67 69 6e 20  tem-path)(begin 
4de0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
4df0: 57 41 52 4e 49 4e 47 3a 20 49 54 45 4d 50 41 54  WARNING: ITEMPAT
4e00: 48 20 6e 6f 74 20 73 65 74 2e 22 29 20 20 20 28  H not set.")   (
4e10: 73 65 74 21 20 69 74 65 6d 2d 70 61 74 68 20 22  set! item-path "
4e20: 22 29 29 29 0a 20 20 20 20 3b 3b 20 28 6c 65 74  "))).    ;; (let
4e30: 20 28 28 74 65 73 74 69 6e 66 6f 20 28 64 62 3a   ((testinfo (db:
4e40: 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62  get-test-info db
4e50: 20 72 75 6e 2d 69 64 20 74 65 73 74 6e 61 6d 65   run-id testname
4e60: 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 20 20   item-path))).  
4e70: 20 20 3b 3b 20 20 20 28 69 66 20 28 61 6e 64 20    ;;   (if (and 
4e80: 28 6e 6f 74 20 28 65 71 75 61 6c 3f 20 28 64 62  (not (equal? (db
4e90: 3a 74 65 73 74 2d 67 65 74 2d 73 74 61 74 75 73  :test-get-status
4ea0: 20 74 65 73 74 69 6e 66 6f 29 20 22 43 4f 4d 50   testinfo) "COMP
4eb0: 4c 45 54 45 44 22 29 29 0a 20 20 20 20 3b 3b 20  LETED")).    ;; 
4ec0: 20 20 20 20 20 20 20 20 20 20 20 28 6e 6f 74 20             (not 
4ed0: 28 65 71 75 61 6c 3f 20 28 64 62 3a 74 65 73 74  (equal? (db:test
4ee0: 2d 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74  -get-status test
4ef0: 69 6e 66 6f 29 20 22 4b 49 4c 4c 52 45 51 22 29  info) "KILLREQ")
4f00: 29 0a 20 20 20 20 28 73 71 6c 69 74 65 33 3a 65  ).    (sqlite3:e
4f10: 78 65 63 75 74 65 0a 20 20 20 20 20 64 62 0a 20  xecute.     db. 
4f20: 20 20 20 20 22 55 50 44 41 54 45 20 74 65 73 74      "UPDATE test
4f30: 73 20 53 45 54 20 63 70 75 6c 6f 61 64 3d 3f 2c  s SET cpuload=?,
4f40: 64 69 73 6b 66 72 65 65 3d 3f 2c 72 75 6e 5f 64  diskfree=?,run_d
4f50: 75 72 61 74 69 6f 6e 3d 3f 2c 73 74 61 74 65 3d  uration=?,state=
4f60: 27 52 55 4e 4e 49 4e 47 27 20 57 48 45 52 45 20  'RUNNING' WHERE 
4f70: 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73  run_id=? AND tes
4f80: 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d  tname=? AND item
4f90: 5f 70 61 74 68 3d 3f 20 41 4e 44 20 73 74 61 74  _path=? AND stat
4fa0: 65 20 4e 4f 54 20 49 4e 20 28 27 43 4f 4d 50 4c  e NOT IN ('COMPL
4fb0: 45 54 45 44 27 2c 27 4b 49 4c 4c 52 45 51 27 2c  ETED','KILLREQ',
4fc0: 27 4b 49 4c 4c 45 44 27 29 3b 22 0a 20 20 20 20  'KILLED');".    
4fd0: 20 63 70 75 6c 6f 61 64 0a 20 20 20 20 20 64 69   cpuload.     di
4fe0: 73 6b 66 72 65 65 0a 20 20 20 20 20 6d 69 6e 75  skfree.     minu
4ff0: 74 65 73 0a 20 20 20 20 20 72 75 6e 2d 69 64 0a  tes.     run-id.
5000: 20 20 20 20 20 74 65 73 74 6e 61 6d 65 0a 20 20       testname.  
5010: 20 20 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a     item-path))).
5020: 0a 28 64 65 66 69 6e 65 20 28 73 65 74 2d 6d 65  .(define (set-me
5030: 67 61 74 65 73 74 2d 65 6e 76 2d 76 61 72 73 20  gatest-env-vars 
5040: 64 62 20 72 75 6e 2d 69 64 29 0a 20 20 28 6c 65  db run-id).  (le
5050: 74 20 28 28 6b 65 79 73 20 28 64 62 2d 67 65 74  t ((keys (db-get
5060: 2d 6b 65 79 73 20 64 62 29 29 29 0a 20 20 20 20  -keys db))).    
5070: 28 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64  (for-each (lambd
5080: 61 20 28 6b 65 79 29 0a 09 09 28 73 71 6c 69 74  a (key)...(sqlit
5090: 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77 0a  e3:for-each-row.
50a0: 09 09 20 28 6c 61 6d 62 64 61 20 28 76 61 6c 29  .. (lambda (val)
50b0: 0a 09 09 20 20 20 28 64 65 62 75 67 3a 70 72 69  ...   (debug:pri
50c0: 6e 74 20 32 20 22 73 65 74 65 6e 76 20 22 20 28  nt 2 "setenv " (
50d0: 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64 6e 61 6d  key:get-fieldnam
50e0: 65 20 6b 65 79 29 20 22 20 22 20 76 61 6c 29 0a  e key) " " val).
50f0: 09 09 20 20 20 28 73 65 74 65 6e 76 20 28 6b 65  ..   (setenv (ke
5100: 79 3a 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20  y:get-fieldname 
5110: 6b 65 79 29 20 76 61 6c 29 29 0a 09 09 20 64 62  key) val))... db
5120: 20 0a 09 09 20 28 63 6f 6e 63 20 22 53 45 4c 45   ... (conc "SELE
5130: 43 54 20 22 20 28 6b 65 79 3a 67 65 74 2d 66 69  CT " (key:get-fi
5140: 65 6c 64 6e 61 6d 65 20 6b 65 79 29 20 22 20 46  eldname key) " F
5150: 52 4f 4d 20 72 75 6e 73 20 57 48 45 52 45 20 69  ROM runs WHERE i
5160: 64 3d 3f 3b 22 29 0a 09 09 20 72 75 6e 2d 69 64  d=?;")... run-id
5170: 29 29 0a 09 20 20 20 20 20 20 6b 65 79 73 29 29  ))..      keys))
5180: 29 0a 0a 28 64 65 66 69 6e 65 20 28 73 65 74 2d  )..(define (set-
5190: 69 74 65 6d 2d 65 6e 76 2d 76 61 72 73 20 69 74  item-env-vars it
51a0: 65 6d 64 61 74 29 0a 20 20 28 66 6f 72 2d 65 61  emdat).  (for-ea
51b0: 63 68 20 28 6c 61 6d 62 64 61 20 28 69 74 65 6d  ch (lambda (item
51c0: 29 0a 09 20 20 20 20 20 20 28 64 65 62 75 67 3a  )..      (debug:
51d0: 70 72 69 6e 74 20 32 20 22 73 65 74 65 6e 76 20  print 2 "setenv 
51e0: 22 20 28 63 61 72 20 69 74 65 6d 29 20 22 20 22  " (car item) " "
51f0: 20 28 63 61 64 72 20 69 74 65 6d 29 29 0a 09 20   (cadr item)).. 
5200: 20 20 20 20 20 28 73 65 74 65 6e 76 20 28 63 61       (setenv (ca
5210: 72 20 69 74 65 6d 29 20 28 63 61 64 72 20 69 74  r item) (cadr it
5220: 65 6d 29 29 29 0a 09 20 20 20 20 69 74 65 6d 64  em)))..    itemd
5230: 61 74 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 67  at))..(define (g
5240: 65 74 2d 61 6c 6c 2d 6c 65 67 61 6c 2d 74 65 73  et-all-legal-tes
5250: 74 73 29 0a 20 20 28 6c 65 74 2a 20 28 28 74 65  ts).  (let* ((te
5260: 73 74 73 20 20 28 67 6c 6f 62 20 28 63 6f 6e 63  sts  (glob (conc
5270: 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f 74 65 73   *toppath* "/tes
5280: 74 73 2f 2a 22 29 29 29 0a 09 20 28 72 65 73 20  ts/*"))).. (res 
5290: 20 20 20 27 28 29 29 29 0a 20 20 20 20 28 64 65     '())).    (de
52a0: 62 75 67 3a 70 72 69 6e 74 20 34 20 22 49 4e 46  bug:print 4 "INF
52b0: 4f 3a 20 4c 6f 6f 6b 69 6e 67 20 61 74 20 74 65  O: Looking at te
52c0: 73 74 73 20 22 20 28 73 74 72 69 6e 67 2d 69 6e  sts " (string-in
52d0: 74 65 72 73 70 65 72 73 65 20 74 65 73 74 73 20  tersperse tests 
52e0: 22 2c 22 29 29 0a 20 20 20 20 28 66 6f 72 2d 65  ",")).    (for-e
52f0: 61 63 68 20 28 6c 61 6d 62 64 61 20 28 74 65 73  ach (lambda (tes
5300: 74 70 61 74 68 29 0a 09 09 28 69 66 20 28 66 69  tpath)...(if (fi
5310: 6c 65 2d 65 78 69 73 74 73 3f 20 28 63 6f 6e 63  le-exists? (conc
5320: 20 74 65 73 74 70 61 74 68 20 22 2f 74 65 73 74   testpath "/test
5330: 63 6f 6e 66 69 67 22 29 29 0a 09 09 20 20 20 20  config"))...    
5340: 28 73 65 74 21 20 72 65 73 20 28 63 6f 6e 73 20  (set! res (cons 
5350: 28 6c 61 73 74 20 28 73 74 72 69 6e 67 2d 73 70  (last (string-sp
5360: 6c 69 74 20 74 65 73 74 70 61 74 68 20 22 2f 22  lit testpath "/"
5370: 29 29 20 72 65 73 29 29 29 29 0a 09 20 20 20 20  )) res))))..    
5380: 20 20 74 65 73 74 73 29 0a 20 20 20 20 72 65 73    tests).    res
5390: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 72 75 6e  ))..(define (run
53a0: 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65 2d 74  s:can-run-more-t
53b0: 65 73 74 73 20 64 62 29 0a 20 20 28 6c 65 74 20  ests db).  (let 
53c0: 28 28 6e 75 6d 2d 72 75 6e 6e 69 6e 67 20 28 64  ((num-running (d
53d0: 62 3a 67 65 74 2d 63 6f 75 6e 74 2d 74 65 73 74  b:get-count-test
53e0: 73 2d 72 75 6e 6e 69 6e 67 20 64 62 29 29 0a 09  s-running db))..
53f0: 28 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d  (max-concurrent-
5400: 6a 6f 62 73 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f  jobs (config-loo
5410: 6b 75 70 20 2a 63 6f 6e 66 69 67 64 61 74 2a 20  kup *configdat* 
5420: 22 73 65 74 75 70 22 20 22 6d 61 78 5f 63 6f 6e  "setup" "max_con
5430: 63 75 72 72 65 6e 74 5f 6a 6f 62 73 22 29 29 29  current_jobs")))
5440: 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e  .    (debug:prin
5450: 74 20 32 20 22 6d 61 78 2d 63 6f 6e 63 75 72 72  t 2 "max-concurr
5460: 65 6e 74 2d 6a 6f 62 73 3a 20 22 20 6d 61 78 2d  ent-jobs: " max-
5470: 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 20  concurrent-jobs 
5480: 22 2c 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67 3a 20  ", num-running: 
5490: 22 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67 29 0a 20  " num-running). 
54a0: 20 20 20 28 69 66 20 28 6e 6f 74 20 28 65 71 3f     (if (not (eq?
54b0: 20 30 20 2a 67 6c 6f 62 61 6c 65 78 69 74 73 74   0 *globalexitst
54c0: 61 74 75 73 2a 29 29 0a 09 23 66 0a 09 28 69 66  atus*))..#f..(if
54d0: 20 28 6f 72 20 28 6e 6f 74 20 6d 61 78 2d 63 6f   (or (not max-co
54e0: 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29 0a 09  ncurrent-jobs)..
54f0: 09 28 61 6e 64 20 6d 61 78 2d 63 6f 6e 63 75 72  .(and max-concur
5500: 72 65 6e 74 2d 6a 6f 62 73 0a 09 09 20 20 20 20  rent-jobs...    
5510: 20 28 73 74 72 69 6e 67 2d 3e 6e 75 6d 62 65 72   (string->number
5520: 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d   max-concurrent-
5530: 6a 6f 62 73 29 0a 09 09 20 20 20 20 20 28 6e 6f  jobs)...     (no
5540: 74 20 28 3e 3d 20 6e 75 6d 2d 72 75 6e 6e 69 6e  t (>= num-runnin
5550: 67 20 28 73 74 72 69 6e 67 2d 3e 6e 75 6d 62 65  g (string->numbe
5560: 72 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74  r max-concurrent
5570: 2d 6a 6f 62 73 29 29 29 29 29 0a 09 20 20 20 20  -jobs)))))..    
5580: 23 74 0a 09 20 20 20 20 28 62 65 67 69 6e 20 0a  #t..    (begin .
5590: 09 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72  .      (debug:pr
55a0: 69 6e 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20  int 0 "WARNING: 
55b0: 4d 61 78 20 72 75 6e 6e 69 6e 67 20 6a 6f 62 73  Max running jobs
55c0: 20 65 78 63 65 65 64 65 64 2c 20 63 75 72 72 65   exceeded, curre
55d0: 6e 74 20 6e 75 6d 62 65 72 20 72 75 6e 6e 69 6e  nt number runnin
55e0: 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67  g: " num-running
55f0: 20 0a 09 09 09 20 20 20 22 2c 20 6d 61 78 5f 63   ....   ", max_c
5600: 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f 62 73 3a 20  oncurrent_jobs: 
5610: 22 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74  " max-concurrent
5620: 2d 6a 6f 62 73 29 0a 09 20 20 20 20 20 20 23 66  -jobs)..      #f
5630: 29 29 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28  )))))..(define (
5640: 74 65 73 74 3a 67 65 74 2d 74 65 73 74 63 6f 6e  test:get-testcon
5650: 66 69 67 20 74 65 73 74 2d 6e 61 6d 65 20 73 79  fig test-name sy
5660: 73 74 65 6d 2d 61 6c 6c 6f 77 65 64 29 0a 20 20  stem-allowed).  
5670: 28 6c 65 74 2a 20 28 28 74 65 73 74 2d 70 61 74  (let* ((test-pat
5680: 68 20 20 20 20 28 63 6f 6e 63 20 2a 74 6f 70 70  h    (conc *topp
5690: 61 74 68 2a 20 22 2f 74 65 73 74 73 2f 22 20 74  ath* "/tests/" t
56a0: 65 73 74 2d 6e 61 6d 65 29 29 0a 09 20 28 74 65  est-name)).. (te
56b0: 73 74 2d 63 6f 6e 66 69 67 66 20 28 63 6f 6e 63  st-configf (conc
56c0: 20 74 65 73 74 2d 70 61 74 68 20 22 2f 74 65 73   test-path "/tes
56d0: 74 63 6f 6e 66 69 67 22 29 29 0a 09 20 28 74 65  tconfig")).. (te
56e0: 73 74 65 78 69 73 74 73 20 20 20 28 61 6e 64 20  stexists   (and 
56f0: 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 74 65  (file-exists? te
5700: 73 74 2d 63 6f 6e 66 69 67 66 29 28 66 69 6c 65  st-configf)(file
5710: 2d 72 65 61 64 2d 61 63 63 65 73 73 3f 20 74 65  -read-access? te
5720: 73 74 2d 63 6f 6e 66 69 67 66 29 29 29 29 0a 20  st-configf)))). 
5730: 20 20 20 28 69 66 20 74 65 73 74 65 78 69 73 74     (if testexist
5740: 73 0a 09 28 72 65 61 64 2d 63 6f 6e 66 69 67 20  s..(read-config 
5750: 74 65 73 74 2d 63 6f 6e 66 69 67 66 20 23 66 20  test-configf #f 
5760: 73 79 73 74 65 6d 2d 61 6c 6c 6f 77 65 64 20 65  system-allowed e
5770: 6e 76 69 72 6f 6e 2d 70 61 74 74 3a 20 28 69 66  nviron-patt: (if
5780: 20 73 79 73 74 65 6d 2d 61 6c 6c 6f 77 65 64 0a   system-allowed.
5790: 09 09 09 09 09 09 09 09 20 20 20 20 20 20 22 70  ........      "p
57a0: 72 65 2d 6c 61 75 6e 63 68 2d 65 6e 76 2d 76 61  re-launch-env-va
57b0: 72 73 22 0a 09 09 09 09 09 09 09 09 20 20 20 20  rs".........    
57c0: 20 20 23 66 29 29 0a 09 23 66 29 29 29 0a 20 20    #f))..#f))).  
57d0: 0a 3b 3b 20 73 6f 72 74 20 74 65 73 74 73 20 62  .;; sort tests b
57e0: 79 20 70 72 69 6f 72 69 74 79 20 61 6e 64 20 77  y priority and w
57f0: 61 69 74 6f 6e 0a 3b 3b 20 4d 6f 76 65 20 74 65  aiton.;; Move te
5800: 73 74 20 73 70 65 63 69 66 69 63 20 73 74 75 66  st specific stuf
5810: 66 20 74 6f 20 61 20 74 65 73 74 20 75 6e 69 74  f to a test unit
5820: 20 46 49 58 4d 45 20 6f 6e 65 20 6f 66 20 74 68   FIXME one of th
5830: 65 73 65 20 64 61 79 73 0a 28 64 65 66 69 6e 65  ese days.(define
5840: 20 28 74 65 73 74 73 3a 73 6f 72 74 2d 62 79 2d   (tests:sort-by-
5850: 70 72 69 6f 72 69 74 79 2d 61 6e 64 2d 77 61 69  priority-and-wai
5860: 74 6f 6e 20 74 65 73 74 2d 6e 61 6d 65 73 29 0a  ton test-names).
5870: 20 20 28 6c 65 74 20 28 28 74 65 73 74 64 65 74    (let ((testdet
5880: 61 69 6c 73 20 20 20 28 6d 61 6b 65 2d 68 61 73  ails   (make-has
5890: 68 2d 74 61 62 6c 65 29 29 0a 09 28 6d 75 6e 67  h-table))..(mung
58a0: 65 70 72 69 6f 72 69 74 79 20 28 6c 61 6d 62 64  epriority (lambd
58b0: 61 20 28 70 72 69 6f 72 69 74 79 29 0a 09 09 09  a (priority)....
58c0: 20 28 69 66 20 70 72 69 6f 72 69 74 79 0a 09 09   (if priority...
58d0: 09 20 20 20 20 20 28 6c 65 74 20 28 28 74 6d 70  .     (let ((tmp
58e0: 20 28 61 6e 79 2d 3e 6e 75 6d 62 65 72 20 70 72   (any->number pr
58f0: 69 6f 72 69 74 79 29 29 29 0a 09 09 09 20 20 20  iority)))....   
5900: 20 20 20 20 28 69 66 20 74 6d 70 20 74 6d 70 20      (if tmp tmp 
5910: 28 62 65 67 69 6e 20 28 64 65 62 75 67 3a 70 72  (begin (debug:pr
5920: 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 62 61  int 0 "ERROR: ba
5930: 64 20 70 72 69 6f 72 69 74 79 20 76 61 6c 75 65  d priority value
5940: 20 22 20 70 72 69 6f 72 69 74 79 20 22 2c 20 75   " priority ", u
5950: 73 69 6e 67 20 30 22 29 20 30 29 29 29 0a 09 09  sing 0") 0)))...
5960: 09 20 20 20 20 20 30 29 29 29 29 0a 20 20 20 20  .     0)))).    
5970: 28 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64  (for-each (lambd
5980: 61 20 28 74 65 73 74 2d 6e 61 6d 65 29 0a 09 09  a (test-name)...
5990: 28 6c 65 74 20 28 28 74 65 73 74 2d 63 6f 6e 66  (let ((test-conf
59a0: 69 67 20 28 74 65 73 74 3a 67 65 74 2d 74 65 73  ig (test:get-tes
59b0: 74 63 6f 6e 66 69 67 20 74 65 73 74 2d 6e 61 6d  tconfig test-nam
59c0: 65 20 23 66 29 29 29 0a 09 09 20 20 28 69 66 20  e #f)))...  (if 
59d0: 74 65 73 74 2d 63 6f 6e 66 69 67 20 28 68 61 73  test-config (has
59e0: 68 2d 74 61 62 6c 65 2d 73 65 74 21 20 74 65 73  h-table-set! tes
59f0: 74 64 65 74 61 69 6c 73 20 74 65 73 74 2d 6e 61  tdetails test-na
5a00: 6d 65 20 74 65 73 74 2d 63 6f 6e 66 69 67 29 29  me test-config))
5a10: 29 29 0a 09 20 20 20 20 20 20 74 65 73 74 2d 6e  ))..      test-n
5a20: 61 6d 65 73 29 0a 20 20 20 20 28 73 6f 72 74 20  ames).    (sort 
5a30: 0a 20 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c  .     (hash-tabl
5a40: 65 2d 6b 65 79 73 20 74 65 73 74 64 65 74 61 69  e-keys testdetai
5a50: 6c 73 29 20 3b 3b 20 61 76 6f 69 64 20 64 65 61  ls) ;; avoid dea
5a60: 6c 69 6e 67 20 77 69 74 68 20 64 65 6c 65 74 65  ling with delete
5a70: 64 20 74 65 73 74 73 2c 20 6c 6f 6f 6b 20 61 74  d tests, look at
5a80: 20 74 68 65 20 68 61 73 68 20 74 61 62 6c 65 0a   the hash table.
5a90: 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 61 20       (lambda (a 
5aa0: 62 29 0a 20 20 20 20 20 20 20 28 6c 65 74 2a 20  b).       (let* 
5ab0: 28 28 74 63 6f 6e 66 2d 61 20 20 20 28 68 61 73  ((tconf-a   (has
5ac0: 68 2d 74 61 62 6c 65 2d 72 65 66 20 74 65 73 74  h-table-ref test
5ad0: 64 65 74 61 69 6c 73 20 61 29 29 0a 09 20 20 20  details a))..   
5ae0: 20 20 20 28 74 63 6f 6e 66 2d 62 20 20 20 28 68     (tconf-b   (h
5af0: 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 20 74 65  ash-table-ref te
5b00: 73 74 64 65 74 61 69 6c 73 20 62 29 29 0a 09 20  stdetails b)).. 
5b10: 20 20 20 20 20 28 61 2d 77 61 69 74 6f 6e 20 20       (a-waiton  
5b20: 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20   (config-lookup 
5b30: 74 63 6f 6e 66 2d 61 20 22 72 65 71 75 69 72 65  tconf-a "require
5b40: 6d 65 6e 74 73 22 20 22 77 61 69 74 6f 6e 22 29  ments" "waiton")
5b50: 29 0a 09 20 20 20 20 20 20 28 62 2d 77 61 69 74  )..      (b-wait
5b60: 6f 6e 20 20 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f  on   (config-loo
5b70: 6b 75 70 20 74 63 6f 6e 66 2d 62 20 22 72 65 71  kup tconf-b "req
5b80: 75 69 72 65 6d 65 6e 74 73 22 20 22 77 61 69 74  uirements" "wait
5b90: 6f 6e 22 29 29 0a 09 20 20 20 20 20 20 28 61 2d  on"))..      (a-
5ba0: 70 72 69 6f 72 69 74 79 20 28 6d 75 6e 67 65 70  priority (mungep
5bb0: 72 69 6f 72 69 74 79 20 28 63 6f 6e 66 69 67 2d  riority (config-
5bc0: 6c 6f 6f 6b 75 70 20 74 63 6f 6e 66 2d 61 20 22  lookup tconf-a "
5bd0: 72 65 71 75 69 72 65 6d 65 6e 74 73 22 20 22 70  requirements" "p
5be0: 72 69 6f 72 69 74 79 22 29 29 29 0a 09 20 20 20  riority")))..   
5bf0: 20 20 20 28 62 2d 70 72 69 6f 72 69 74 79 20 28     (b-priority (
5c00: 6d 75 6e 67 65 70 72 69 6f 72 69 74 79 20 28 63  mungepriority (c
5c10: 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 74 63 6f  onfig-lookup tco
5c20: 6e 66 2d 62 20 22 72 65 71 75 69 72 65 6d 65 6e  nf-b "requiremen
5c30: 74 73 22 20 22 70 72 69 6f 72 69 74 79 22 29 29  ts" "priority"))
5c40: 29 29 0a 09 20 28 69 66 20 28 61 6e 64 20 61 2d  )).. (if (and a-
5c50: 77 61 69 74 6f 6e 20 28 65 71 75 61 6c 3f 20 61  waiton (equal? a
5c60: 2d 77 61 69 74 6f 6e 20 62 29 29 0a 09 20 20 20  -waiton b))..   
5c70: 20 20 23 66 20 3b 3b 20 63 61 6e 6e 6f 74 20 68    #f ;; cannot h
5c80: 61 76 65 20 61 20 77 68 69 63 68 20 69 73 20 77  ave a which is w
5c90: 61 69 74 69 6e 67 20 6f 6e 20 62 20 68 61 70 70  aiting on b happ
5ca0: 65 6e 69 6e 67 20 62 65 66 6f 72 65 20 62 0a 09  ening before b..
5cb0: 20 20 20 20 20 28 69 66 20 28 61 6e 64 20 62 2d       (if (and b-
5cc0: 77 61 69 74 6f 6e 20 28 65 71 75 61 6c 3f 20 62  waiton (equal? b
5cd0: 2d 77 61 69 74 6f 6e 20 61 29 29 0a 09 09 20 23  -waiton a))... #
5ce0: 74 20 3b 3b 20 74 68 69 73 20 69 73 20 74 68 65  t ;; this is the
5cf0: 20 63 6f 72 72 65 63 74 20 6f 72 64 65 72 2c 20   correct order, 
5d00: 62 20 69 73 20 77 61 69 74 69 6e 67 20 6f 6e 20  b is waiting on 
5d10: 61 20 61 6e 64 20 62 20 69 73 20 62 65 66 6f 72  a and b is befor
5d20: 65 20 61 0a 09 09 20 28 69 66 20 28 3e 20 61 2d  e a... (if (> a-
5d30: 70 72 69 6f 72 69 74 79 20 62 2d 70 72 69 6f 72  priority b-prior
5d40: 69 74 79 29 0a 09 09 20 20 20 20 20 23 74 20 3b  ity)...     #t ;
5d50: 3b 20 69 66 20 61 20 69 73 20 61 20 68 69 67 68  ; if a is a high
5d60: 65 72 20 70 72 69 6f 72 69 74 79 20 74 68 61 6e  er priority than
5d70: 20 62 20 74 68 65 6e 20 77 65 20 61 72 65 20 67   b then we are g
5d80: 6f 6f 64 20 74 6f 20 67 6f 0a 09 09 20 20 20 20  ood to go...    
5d90: 20 23 66 29 29 29 29 29 29 29 29 0a 0a 3b 3b 20   #f))))))))..;; 
5da0: 54 68 69 73 20 69 73 20 6f 72 69 67 69 6e 61 6c  This is original
5db0: 20 72 75 6e 2d 74 65 73 74 73 2c 20 74 68 69 73   run-tests, this
5dc0: 20 72 6f 75 74 69 6e 65 20 69 73 20 64 65 70 72   routine is depr
5dd0: 65 63 61 74 65 64 20 61 6e 64 20 77 65 20 77 69  ecated and we wi
5de0: 6c 6c 20 74 72 61 6e 73 69 74 69 6f 6e 20 74 6f  ll transition to
5df0: 20 75 73 69 6e 67 20 72 75 6e 73 3a 72 75 6e 2d   using runs:run-
5e00: 74 65 73 74 73 20 28 73 65 65 20 62 65 6c 6f 77  tests (see below
5e10: 29 0a 3b 3b 0a 28 64 65 66 69 6e 65 20 28 72 75  ).;;.(define (ru
5e20: 6e 2d 74 65 73 74 73 20 64 62 20 74 65 73 74 2d  n-tests db test-
5e30: 6e 61 6d 65 73 29 0a 20 20 28 6c 65 74 2a 20 28  names).  (let* (
5e40: 28 6b 65 79 73 20 20 20 20 20 20 20 20 28 64 62  (keys        (db
5e50: 2d 67 65 74 2d 6b 65 79 73 20 64 62 29 29 0a 09  -get-keys db))..
5e60: 20 28 6b 65 79 76 61 6c 6c 73 74 20 20 20 28 6b   (keyvallst   (k
5e70: 65 79 73 2d 3e 76 61 6c 6c 69 73 74 20 6b 65 79  eys->vallist key
5e80: 73 20 23 74 29 29 0a 09 20 28 72 75 6e 2d 69 64  s #t)).. (run-id
5e90: 20 20 20 20 20 20 28 72 65 67 69 73 74 65 72 2d        (register-
5ea0: 72 75 6e 20 64 62 20 6b 65 79 73 29 29 20 20 3b  run db keys))  ;
5eb0: 3b 20 20 74 65 73 74 2d 6e 61 6d 65 29 29 29 0a  ;  test-name))).
5ec0: 09 20 28 64 65 66 65 72 72 65 64 20 20 20 20 27  . (deferred    '
5ed0: 28 29 29 20 3b 3b 20 64 65 6c 61 79 20 72 75 6e  ()) ;; delay run
5ee0: 6e 69 6e 67 20 74 68 65 73 65 20 73 69 6e 63 65  ning these since
5ef0: 20 74 68 65 79 20 68 61 76 65 20 61 20 77 61 69   they have a wai
5f00: 74 6f 6e 20 63 6c 61 75 73 65 0a 09 20 28 72 75  ton clause.. (ru
5f10: 6e 63 6f 6e 66 69 67 66 20 20 20 28 63 6f 6e 63  nconfigf   (conc
5f20: 20 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f 72 75    *toppath* "/ru
5f30: 6e 63 6f 6e 66 69 67 73 2e 63 6f 6e 66 69 67 22  nconfigs.config"
5f40: 29 29 0a 09 20 28 72 65 71 75 69 72 65 64 2d 74  )).. (required-t
5f50: 65 73 74 73 20 27 28 29 29 29 0a 0a 20 20 20 20  ests '()))..    
5f60: 3b 3b 20 6e 6f 77 20 61 64 64 20 6e 6f 6e 2d 64  ;; now add non-d
5f70: 69 72 65 63 74 6c 79 20 72 65 66 65 72 65 6e 63  irectly referenc
5f80: 65 64 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20  ed dependencies 
5f90: 28 69 2e 65 2e 20 77 61 69 74 6f 6e 29 0a 20 20  (i.e. waiton).  
5fa0: 20 20 3b 3b 20 63 6f 75 6c 64 20 63 61 63 68 65    ;; could cache
5fb0: 20 61 6c 6c 20 74 68 65 73 65 20 73 69 6e 63 65   all these since
5fc0: 20 74 68 65 79 20 6e 65 65 64 20 74 6f 20 62 65   they need to be
5fd0: 20 72 65 61 64 20 61 67 61 69 6e 20 2e 2e 2e 0a   read again ....
5fe0: 20 20 20 20 3b 3b 20 46 49 58 4d 45 20 53 4f 4d      ;; FIXME SOM
5ff0: 45 44 41 59 0a 20 20 20 20 28 69 66 20 28 6e 6f  EDAY.    (if (no
6000: 74 20 28 6e 75 6c 6c 3f 20 74 65 73 74 2d 6e 61  t (null? test-na
6010: 6d 65 73 29 29 0a 09 28 6c 65 74 20 6c 6f 6f 70  mes))..(let loop
6020: 20 28 28 68 65 64 20 28 63 61 72 20 74 65 73 74   ((hed (car test
6030: 2d 6e 61 6d 65 73 29 29 0a 09 09 20 20 20 28 74  -names))...   (t
6040: 61 6c 20 28 63 64 72 20 74 65 73 74 2d 6e 61 6d  al (cdr test-nam
6050: 65 73 29 29 29 0a 09 20 20 28 6c 65 74 2a 20 28  es)))..  (let* (
6060: 28 63 6f 6e 66 69 67 20 20 28 74 65 73 74 3a 67  (config  (test:g
6070: 65 74 2d 74 65 73 74 63 6f 6e 66 69 67 20 68 65  et-testconfig he
6080: 64 20 23 66 29 29 0a 09 09 20 28 77 61 69 74 6f  d #f))... (waito
6090: 6e 73 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74  ns (string-split
60a0: 20 28 6c 65 74 20 28 28 77 20 28 63 6f 6e 66 69   (let ((w (confi
60b0: 67 2d 6c 6f 6f 6b 75 70 20 63 6f 6e 66 69 67 20  g-lookup config 
60c0: 22 72 65 71 75 69 72 65 6d 65 6e 74 73 22 20 22  "requirements" "
60d0: 77 61 69 74 6f 6e 22 29 29 29 0a 09 09 09 09 09  waiton")))......
60e0: 20 20 28 69 66 20 77 20 77 20 22 22 29 29 29 29    (if w w ""))))
60f0: 29 0a 09 20 20 20 20 28 66 6f 72 2d 65 61 63 68  )..    (for-each
6100: 20 0a 09 20 20 20 20 20 28 6c 61 6d 62 64 61 20   ..     (lambda 
6110: 28 77 61 69 74 6f 6e 29 0a 09 20 20 20 20 20 20  (waiton)..      
6120: 20 28 69 66 20 28 61 6e 64 20 77 61 69 74 6f 6e   (if (and waiton
6130: 20 28 6e 6f 74 20 28 6d 65 6d 62 65 72 20 77 61   (not (member wa
6140: 69 74 6f 6e 20 74 65 73 74 2d 6e 61 6d 65 73 29  iton test-names)
6150: 29 29 0a 09 09 20 20 20 28 62 65 67 69 6e 0a 09  ))...   (begin..
6160: 09 20 20 20 20 20 28 73 65 74 21 20 72 65 71 75  .     (set! requ
6170: 69 72 65 64 2d 74 65 73 74 73 20 28 63 6f 6e 73  ired-tests (cons
6180: 20 77 61 69 74 6f 6e 20 72 65 71 75 69 72 65 64   waiton required
6190: 2d 74 65 73 74 73 29 29 0a 09 09 20 20 20 20 20  -tests))...     
61a0: 28 73 65 74 21 20 74 65 73 74 2d 6e 61 6d 65 73  (set! test-names
61b0: 20 28 61 70 70 65 6e 64 20 74 65 73 74 2d 6e 61   (append test-na
61c0: 6d 65 73 20 28 6c 69 73 74 20 77 61 69 74 6f 6e  mes (list waiton
61d0: 29 29 29 29 29 29 0a 09 20 20 20 20 20 77 61 69  ))))))..     wai
61e0: 74 6f 6e 73 29 0a 09 20 20 20 20 28 6c 65 74 20  tons)..    (let 
61f0: 28 28 72 65 6d 74 65 73 74 73 20 28 64 65 6c 65  ((remtests (dele
6200: 74 65 2d 64 75 70 6c 69 63 61 74 65 73 20 28 61  te-duplicates (a
6210: 70 70 65 6e 64 20 77 61 69 74 6f 6e 73 20 74 61  ppend waitons ta
6220: 6c 29 29 29 29 0a 09 20 20 20 20 20 20 28 69 66  l))))..      (if
6230: 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 72 65 6d   (not (null? rem
6240: 74 65 73 74 73 29 29 0a 09 09 20 20 28 6c 6f 6f  tests))...  (loo
6250: 70 20 28 63 61 72 20 72 65 6d 74 65 73 74 73 29  p (car remtests)
6260: 28 63 64 72 20 72 65 6d 74 65 73 74 73 29 29 29  (cdr remtests)))
6270: 29 29 29 29 0a 0a 20 20 20 20 28 69 66 20 28 6e  ))))..    (if (n
6280: 6f 74 20 28 6e 75 6c 6c 3f 20 72 65 71 75 69 72  ot (null? requir
6290: 65 64 2d 74 65 73 74 73 29 29 0a 09 28 64 65 62  ed-tests))..(deb
62a0: 75 67 3a 70 72 69 6e 74 20 31 20 22 49 4e 46 4f  ug:print 1 "INFO
62b0: 3a 20 41 64 64 69 6e 67 20 22 20 72 65 71 75 69  : Adding " requi
62c0: 72 65 64 2d 74 65 73 74 73 20 22 20 74 6f 20 74  red-tests " to t
62d0: 68 65 20 72 75 6e 20 71 75 65 75 65 22 29 0a 09  he run queue")..
62e0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22  (debug:print 1 "
62f0: 49 4e 46 4f 3a 20 4e 6f 20 70 72 65 72 65 71 75  INFO: No prerequ
6300: 69 73 69 74 65 73 20 61 64 64 65 64 22 29 29 0a  isites added")).
6310: 0a 20 20 20 20 3b 3b 20 6f 6e 20 74 68 65 20 66  .    ;; on the f
6320: 69 72 73 74 20 70 61 73 73 20 6f 72 20 63 61 6c  irst pass or cal
6330: 6c 20 74 6f 20 72 75 6e 2d 74 65 73 74 73 20 73  l to run-tests s
6340: 65 74 20 46 41 49 4c 53 20 74 6f 20 4e 4f 54 5f  et FAILS to NOT_
6350: 53 54 41 52 54 45 44 20 69 66 0a 20 20 20 20 3b  STARTED if.    ;
6360: 3b 20 2d 6b 65 65 70 67 6f 69 6e 67 20 69 73 20  ; -keepgoing is 
6370: 73 70 65 63 69 66 69 65 64 0a 0a 20 20 20 20 28  specified..    (
6380: 73 65 74 2d 6d 65 67 61 74 65 73 74 2d 65 6e 76  set-megatest-env
6390: 2d 76 61 72 73 20 64 62 20 72 75 6e 2d 69 64 29  -vars db run-id)
63a0: 20 3b 3b 20 74 68 65 73 65 20 6d 61 79 20 62 65   ;; these may be
63b0: 20 6e 65 65 64 65 64 20 62 79 20 74 68 65 20 6c   needed by the l
63c0: 61 75 6e 63 68 69 6e 67 20 70 72 6f 63 65 73 73  aunching process
63d0: 0a 20 20 20 20 0a 20 20 20 20 28 69 66 20 28 66  .    .    (if (f
63e0: 69 6c 65 2d 65 78 69 73 74 73 3f 20 72 75 6e 63  ile-exists? runc
63f0: 6f 6e 66 69 67 66 29 0a 09 28 73 65 74 75 70 2d  onfigf)..(setup-
6400: 65 6e 76 2d 64 65 66 61 75 6c 74 73 20 64 62 20  env-defaults db 
6410: 72 75 6e 63 6f 6e 66 69 67 66 20 72 75 6e 2d 69  runconfigf run-i
6420: 64 20 2a 61 6c 72 65 61 64 79 2d 73 65 65 6e 2d  d *already-seen-
6430: 72 75 6e 63 6f 6e 66 69 67 2d 69 6e 66 6f 2a 20  runconfig-info* 
6440: 65 6e 76 69 72 6f 6e 2d 70 61 74 74 3a 20 22 2e  environ-patt: ".
6450: 2a 22 29 0a 09 28 64 65 62 75 67 3a 70 72 69 6e  *")..(debug:prin
6460: 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 59 6f  t 0 "WARNING: Yo
6470: 75 20 64 6f 20 6e 6f 74 20 68 61 76 65 20 61 20  u do not have a 
6480: 72 75 6e 20 63 6f 6e 66 69 67 20 66 69 6c 65 3a  run config file:
6490: 20 22 20 72 75 6e 63 6f 6e 66 69 67 66 29 29 0a   " runconfigf)).
64a0: 0a 20 20 20 20 28 69 66 20 28 61 6e 64 20 28 65  .    (if (and (e
64b0: 71 3f 20 2a 70 61 73 73 6e 75 6d 2a 20 30 29 0a  q? *passnum* 0).
64c0: 09 20 20 20 20 20 28 61 72 67 73 3a 67 65 74 2d  .     (args:get-
64d0: 61 72 67 20 22 2d 6b 65 65 70 67 6f 69 6e 67 22  arg "-keepgoing"
64e0: 29 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 3b 3b  ))..(begin..  ;;
64f0: 20 68 61 76 65 20 74 6f 20 64 65 6c 65 74 65 20   have to delete 
6500: 74 65 73 74 20 72 65 63 6f 72 64 73 20 77 68 65  test records whe
6510: 72 65 20 4e 4f 54 5f 53 54 41 52 54 45 44 20 73  re NOT_STARTED s
6520: 69 6e 63 65 20 74 68 65 79 20 63 61 6e 20 63 61  ince they can ca
6530: 75 73 65 20 2d 6b 65 65 70 67 6f 69 6e 67 20 74  use -keepgoing t
6540: 6f 20 0a 09 20 20 3b 3b 20 67 65 74 20 73 74 75  o ..  ;; get stu
6550: 63 6b 20 64 75 65 20 74 6f 20 62 65 63 6f 6d 69  ck due to becomi
6560: 6e 67 20 69 6e 61 63 63 65 73 73 69 62 6c 65 20  ng inaccessible 
6570: 66 72 6f 6d 20 61 20 66 61 69 6c 65 64 20 74 65  from a failed te
6580: 73 74 2e 20 49 2e 65 2e 20 69 66 20 74 65 73 74  st. I.e. if test
6590: 20 42 20 64 65 70 65 6e 64 73 20 0a 09 20 20 3b   B depends ..  ;
65a0: 3b 20 6f 6e 20 74 65 73 74 20 41 20 62 75 74 20  ; on test A but 
65b0: 74 65 73 74 20 42 20 72 65 61 63 68 65 64 20 74  test B reached t
65c0: 68 65 20 70 6f 69 6e 74 20 6f 6e 20 62 65 69 6e  he point on bein
65d0: 67 20 72 65 67 69 73 74 65 72 65 64 20 61 73 20  g registered as 
65e0: 4e 4f 54 5f 53 54 41 52 54 45 44 20 61 6e 64 20  NOT_STARTED and 
65f0: 74 65 73 74 0a 09 20 20 3b 3b 20 41 20 66 61 69  test..  ;; A fai
6600: 6c 65 64 20 66 6f 72 20 73 6f 6d 65 20 72 65 61  led for some rea
6610: 73 6f 6e 20 74 68 65 6e 20 6f 6e 20 72 65 2d 72  son then on re-r
6620: 75 6e 20 75 73 69 6e 67 20 2d 6b 65 65 70 67 6f  un using -keepgo
6630: 69 6e 67 20 74 68 65 20 72 75 6e 20 63 61 6e 20  ing the run can 
6640: 6e 65 76 65 72 20 63 6f 6d 70 6c 65 74 65 2e 0a  never complete..
6650: 09 20 20 28 64 62 3a 64 65 6c 65 74 65 2d 74 65  .  (db:delete-te
6660: 73 74 73 2d 69 6e 2d 73 74 61 74 65 20 64 62 20  sts-in-state db 
6670: 72 75 6e 2d 69 64 20 22 4e 4f 54 5f 53 54 41 52  run-id "NOT_STAR
6680: 54 45 44 22 29 0a 09 20 20 28 64 62 3a 73 65 74  TED")..  (db:set
6690: 2d 74 65 73 74 73 2d 73 74 61 74 65 2d 73 74 61  -tests-state-sta
66a0: 74 75 73 20 64 62 20 72 75 6e 2d 69 64 20 74 65  tus db run-id te
66b0: 73 74 2d 6e 61 6d 65 73 20 23 66 20 22 46 41 49  st-names #f "FAI
66c0: 4c 22 20 22 4e 4f 54 5f 53 54 41 52 54 45 44 22  L" "NOT_STARTED"
66d0: 20 22 46 41 49 4c 22 29 29 29 0a 20 20 20 20 28   "FAIL"))).    (
66e0: 73 65 74 21 20 2a 70 61 73 73 6e 75 6d 2a 20 28  set! *passnum* (
66f0: 2b 20 2a 70 61 73 73 6e 75 6d 2a 20 31 29 29 0a  + *passnum* 1)).
6700: 20 20 20 20 28 6c 65 74 20 6c 6f 6f 70 20 28 28      (let loop ((
6710: 6e 75 6d 74 69 6d 65 73 20 30 29 29 0a 20 20 20  numtimes 0)).   
6720: 20 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 20     (for-each .  
6730: 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 74 65       (lambda (te
6740: 73 74 2d 6e 61 6d 65 29 0a 09 20 28 69 66 20 28  st-name).. (if (
6750: 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72  runs:can-run-mor
6760: 65 2d 74 65 73 74 73 20 64 62 29 0a 09 20 20 20  e-tests db)..   
6770: 20 20 28 72 75 6e 2d 6f 6e 65 2d 74 65 73 74 20    (run-one-test 
6780: 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e  db run-id test-n
6790: 61 6d 65 20 6b 65 79 76 61 6c 6c 73 74 29 0a 09  ame keyvallst)..
67a0: 20 20 20 20 20 3b 3b 20 61 64 64 20 73 6f 6d 65       ;; add some
67b0: 20 64 65 6c 61 79 20 0a 09 20 20 20 20 20 3b 28   delay ..     ;(
67c0: 73 6c 65 65 70 20 32 29 0a 09 20 20 20 20 20 29  sleep 2)..     )
67d0: 29 0a 20 20 20 20 20 20 20 28 74 65 73 74 73 3a  ).       (tests:
67e0: 73 6f 72 74 2d 62 79 2d 70 72 69 6f 72 69 74 79  sort-by-priority
67f0: 2d 61 6e 64 2d 77 61 69 74 6f 6e 20 74 65 73 74  -and-waiton test
6800: 2d 6e 61 6d 65 73 29 29 0a 20 20 20 20 20 20 3b  -names)).      ;
6810: 3b 20 28 72 75 6e 2d 77 61 69 74 69 6e 67 2d 74  ; (run-waiting-t
6820: 65 73 74 73 20 64 62 29 0a 20 20 20 20 20 20 28  ests db).      (
6830: 69 66 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67  if (args:get-arg
6840: 20 22 2d 6b 65 65 70 67 6f 69 6e 67 22 29 0a 09   "-keepgoing")..
6850: 20 20 28 6c 65 74 20 28 28 65 73 74 72 65 6d 20    (let ((estrem 
6860: 28 64 62 3a 65 73 74 69 6d 61 74 65 64 2d 74 65  (db:estimated-te
6870: 73 74 73 2d 72 65 6d 61 69 6e 69 6e 67 20 64 62  sts-remaining db
6880: 20 72 75 6e 2d 69 64 29 29 29 0a 09 20 20 20 20   run-id)))..    
6890: 28 69 66 20 28 61 6e 64 20 28 3e 20 65 73 74 72  (if (and (> estr
68a0: 65 6d 20 30 29 0a 09 09 20 20 20 20 20 28 65 71  em 0)...     (eq
68b0: 3f 20 2a 67 6c 6f 62 61 6c 65 78 69 74 73 74 61  ? *globalexitsta
68c0: 74 75 73 2a 20 30 29 29 0a 09 09 28 62 65 67 69  tus* 0))...(begi
68d0: 6e 0a 09 09 20 20 28 64 65 62 75 67 3a 70 72 69  n...  (debug:pri
68e0: 6e 74 20 31 20 22 4b 65 65 70 20 67 6f 69 6e 67  nt 1 "Keep going
68f0: 2c 20 65 73 74 69 6d 61 74 65 64 20 22 20 65 73  , estimated " es
6900: 74 72 65 6d 20 22 20 74 65 73 74 73 20 72 65 6d  trem " tests rem
6910: 61 69 6e 69 6e 67 20 74 6f 20 72 75 6e 2c 20 77  aining to run, w
6920: 69 6c 6c 20 63 6f 6e 74 69 6e 75 65 20 69 6e 20  ill continue in 
6930: 33 20 73 65 63 6f 6e 64 73 20 2e 2e 2e 22 29 0a  3 seconds ...").
6940: 09 09 20 20 28 74 68 72 65 61 64 2d 73 6c 65 65  ..  (thread-slee
6950: 70 21 20 33 29 0a 09 09 20 20 28 72 75 6e 2d 77  p! 3)...  (run-w
6960: 61 69 74 69 6e 67 2d 74 65 73 74 73 20 64 62 29  aiting-tests db)
6970: 0a 09 09 20 20 28 6c 6f 6f 70 20 28 2b 20 6e 75  ...  (loop (+ nu
6980: 6d 74 69 6d 65 73 20 31 29 29 29 29 29 29 29 29  mtimes 1))))))))
6990: 29 0a 09 20 20 0a 3b 3b 20 56 45 52 59 20 49 4e  )..  .;; VERY IN
69a0: 45 46 46 49 43 49 45 4e 54 21 20 4d 6f 76 65 20  EFFICIENT! Move 
69b0: 73 74 75 66 66 20 74 68 61 74 20 73 68 6f 75 6c  stuff that shoul
69c0: 64 20 62 65 20 64 6f 6e 65 20 6f 6e 63 65 20 75  d be done once u
69d0: 70 20 74 6f 20 63 61 6c 6c 69 6e 67 20 70 72 6f  p to calling pro
69e0: 63 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 2d 6f  c.(define (run-o
69f0: 6e 65 2d 74 65 73 74 20 64 62 20 72 75 6e 2d 69  ne-test db run-i
6a00: 64 20 74 65 73 74 2d 6e 61 6d 65 20 6b 65 79 76  d test-name keyv
6a10: 61 6c 6c 73 74 29 0a 20 20 28 64 65 62 75 67 3a  allst).  (debug:
6a20: 70 72 69 6e 74 20 31 20 22 4c 61 75 6e 63 68 69  print 1 "Launchi
6a30: 6e 67 20 74 65 73 74 20 22 20 74 65 73 74 2d 6e  ng test " test-n
6a40: 61 6d 65 29 0a 20 20 3b 3b 20 41 6c 6c 20 74 68  ame).  ;; All th
6a50: 65 73 65 20 76 61 72 73 20 6d 69 67 68 74 20 62  ese vars might b
6a60: 65 20 72 65 66 65 72 65 6e 63 65 64 20 62 79 20  e referenced by 
6a70: 74 68 65 20 74 65 73 74 63 6f 6e 66 69 67 20 66  the testconfig f
6a80: 69 6c 65 20 72 65 61 64 65 72 0a 20 20 28 73 65  ile reader.  (se
6a90: 74 65 6e 76 20 22 4d 54 5f 54 45 53 54 5f 4e 41  tenv "MT_TEST_NA
6aa0: 4d 45 22 20 74 65 73 74 2d 6e 61 6d 65 29 20 3b  ME" test-name) ;
6ab0: 3b 20 0a 20 20 28 73 65 74 65 6e 76 20 22 4d 54  ; .  (setenv "MT
6ac0: 5f 52 55 4e 4e 41 4d 45 22 20 20 20 28 61 72 67  _RUNNAME"   (arg
6ad0: 73 3a 67 65 74 2d 61 72 67 20 22 3a 72 75 6e 6e  s:get-arg ":runn
6ae0: 61 6d 65 22 29 29 0a 0a 20 20 3b 3b 20 28 73 65  ame"))..  ;; (se
6af0: 74 2d 6d 65 67 61 74 65 73 74 2d 65 6e 76 2d 76  t-megatest-env-v
6b00: 61 72 73 20 64 62 20 72 75 6e 2d 69 64 29 20 3b  ars db run-id) ;
6b10: 3b 20 74 68 65 73 65 20 6d 61 79 20 62 65 20 6e  ; these may be n
6b20: 65 65 64 65 64 20 62 79 20 74 68 65 20 6c 61 75  eeded by the lau
6b30: 6e 63 68 69 6e 67 20 70 72 6f 63 65 73 73 0a 0a  nching process..
6b40: 20 20 28 63 68 61 6e 67 65 2d 64 69 72 65 63 74    (change-direct
6b50: 6f 72 79 20 2a 74 6f 70 70 61 74 68 2a 29 0a 20  ory *toppath*). 
6b60: 20 28 6c 65 74 2a 20 28 28 74 65 73 74 2d 70 61   (let* ((test-pa
6b70: 74 68 20 20 20 20 28 63 6f 6e 63 20 2a 74 6f 70  th    (conc *top
6b80: 70 61 74 68 2a 20 22 2f 74 65 73 74 73 2f 22 20  path* "/tests/" 
6b90: 74 65 73 74 2d 6e 61 6d 65 29 29 20 3b 3b 20 63  test-name)) ;; c
6ba0: 6f 75 6c 64 20 75 73 65 20 74 65 73 74 3a 67 65  ould use test:ge
6bb0: 74 2d 74 65 73 74 63 6f 6e 66 69 67 20 68 65 72  t-testconfig her
6bc0: 65 20 2e 2e 2e 0a 09 20 28 74 65 73 74 2d 63 6f  e ..... (test-co
6bd0: 6e 66 69 67 66 20 28 63 6f 6e 63 20 74 65 73 74  nfigf (conc test
6be0: 2d 70 61 74 68 20 22 2f 74 65 73 74 63 6f 6e 66  -path "/testconf
6bf0: 69 67 22 29 29 0a 09 20 28 74 65 73 74 65 78 69  ig")).. (testexi
6c00: 73 74 73 20 20 20 28 61 6e 64 20 28 66 69 6c 65  sts   (and (file
6c10: 2d 65 78 69 73 74 73 3f 20 74 65 73 74 2d 63 6f  -exists? test-co
6c20: 6e 66 69 67 66 29 28 66 69 6c 65 2d 72 65 61 64  nfigf)(file-read
6c30: 2d 61 63 63 65 73 73 3f 20 74 65 73 74 2d 63 6f  -access? test-co
6c40: 6e 66 69 67 66 29 29 29 0a 09 20 28 74 65 73 74  nfigf))).. (test
6c50: 2d 63 6f 6e 66 20 20 20 20 28 69 66 20 74 65 73  -conf    (if tes
6c60: 74 65 78 69 73 74 73 20 28 72 65 61 64 2d 63 6f  texists (read-co
6c70: 6e 66 69 67 20 74 65 73 74 2d 63 6f 6e 66 69 67  nfig test-config
6c80: 66 20 23 66 20 23 74 29 20 28 6d 61 6b 65 2d 68  f #f #t) (make-h
6c90: 61 73 68 2d 74 61 62 6c 65 29 29 29 0a 09 20 28  ash-table))).. (
6ca0: 77 61 69 74 6f 6e 20 20 20 20 20 20 20 28 6c 65  waiton       (le
6cb0: 74 20 28 28 77 20 28 63 6f 6e 66 69 67 2d 6c 6f  t ((w (config-lo
6cc0: 6f 6b 75 70 20 74 65 73 74 2d 63 6f 6e 66 20 22  okup test-conf "
6cd0: 72 65 71 75 69 72 65 6d 65 6e 74 73 22 20 22 77  requirements" "w
6ce0: 61 69 74 6f 6e 22 29 29 29 0a 09 09 09 20 28 69  aiton"))).... (i
6cf0: 66 20 28 73 74 72 69 6e 67 3f 20 77 29 28 73 74  f (string? w)(st
6d00: 72 69 6e 67 2d 73 70 6c 69 74 20 77 29 27 28 29  ring-split w)'()
6d10: 29 29 29 0a 09 20 28 74 61 67 73 20 20 20 20 20  ))).. (tags     
6d20: 20 20 20 20 28 6c 65 74 20 28 28 74 20 28 63 6f      (let ((t (co
6d30: 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 74 65 73 74  nfig-lookup test
6d40: 2d 63 6f 6e 66 20 22 73 65 74 75 70 22 20 22 74  -conf "setup" "t
6d50: 61 67 73 22 29 29 29 0a 09 09 09 20 3b 3b 20 77  ags"))).... ;; w
6d60: 65 20 77 61 6e 74 20 6f 75 72 20 74 61 67 73 20  e want our tags 
6d70: 74 6f 20 62 65 20 73 65 70 61 72 61 74 65 64 20  to be separated 
6d80: 62 79 20 63 6f 6d 6d 61 73 20 61 6e 64 20 66 75  by commas and fu
6d90: 6c 6c 79 20 64 65 6c 69 6d 69 74 65 64 20 62 79  lly delimited by
6da0: 20 63 6f 6d 6d 61 73 0a 09 09 09 20 3b 3b 20 73   commas.... ;; s
6db0: 6f 20 74 68 61 74 20 71 75 65 72 69 65 73 20 77  o that queries w
6dc0: 69 74 68 20 22 6c 69 6b 65 22 20 63 61 6e 20 74  ith "like" can t
6dd0: 69 65 20 74 6f 20 74 68 65 20 63 6f 6d 6d 61 73  ie to the commas
6de0: 20 61 74 20 65 69 74 68 65 72 20 65 6e 64 20 6f   at either end o
6df0: 66 20 65 61 63 68 20 74 61 67 0a 09 09 09 20 3b  f each tag.... ;
6e00: 3b 20 77 68 69 6c 65 20 61 6c 73 6f 20 61 6c 6c  ; while also all
6e10: 6f 77 69 6e 67 20 74 68 65 20 65 6e 64 20 75 73  owing the end us
6e20: 65 72 20 74 6f 20 66 72 65 65 6c 79 20 75 73 65  er to freely use
6e30: 20 73 70 61 63 65 73 20 61 6e 64 20 63 6f 6d 6d   spaces and comm
6e40: 61 73 20 74 6f 20 73 65 70 61 72 61 74 65 20 74  as to separate t
6e50: 61 67 73 0a 09 09 09 20 28 69 66 20 28 73 74 72  ags.... (if (str
6e60: 69 6e 67 3f 20 74 29 28 73 74 72 69 6e 67 2d 73  ing? t)(string-s
6e70: 75 62 73 74 69 74 75 74 65 20 28 72 65 67 65 78  ubstitute (regex
6e80: 70 20 22 5b 2c 5c 5c 73 5d 2b 22 29 20 22 2c 22  p "[,\\s]+") ","
6e90: 20 28 63 6f 6e 63 20 22 2c 22 20 74 20 22 2c 22   (conc "," t ","
6ea0: 29 20 23 74 29 0a 09 09 09 20 20 20 20 20 27 28  ) #t)....     '(
6eb0: 29 29 29 29 29 0a 20 20 20 20 28 69 66 20 28 6e  ))))).    (if (n
6ec0: 6f 74 20 74 65 73 74 65 78 69 73 74 73 29 0a 09  ot testexists)..
6ed0: 28 62 65 67 69 6e 0a 09 20 20 28 64 65 62 75 67  (begin..  (debug
6ee0: 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a  :print 0 "ERROR:
6ef0: 20 43 61 6e 27 74 20 66 69 6e 64 20 63 6f 6e 66   Can't find conf
6f00: 69 67 20 66 69 6c 65 20 22 20 74 65 73 74 2d 63  ig file " test-c
6f10: 6f 6e 66 69 67 66 29 0a 09 20 20 28 65 78 69 74  onfigf)..  (exit
6f20: 20 32 29 29 0a 09 3b 3b 20 70 75 74 20 74 6f 70   2))..;; put top
6f30: 20 76 61 72 73 20 69 6e 74 6f 20 63 6f 6e 76 65   vars into conve
6f40: 6e 69 65 6e 74 20 76 61 72 69 61 62 6c 65 73 20  nient variables 
6f50: 61 6e 64 20 6f 70 65 6e 20 74 68 65 20 64 62 0a  and open the db.
6f60: 09 28 6c 65 74 2a 20 28 3b 3b 20 64 62 20 69 73  .(let* (;; db is
6f70: 20 61 6c 77 61 79 73 20 61 74 20 2a 74 6f 70 70   always at *topp
6f80: 61 74 68 2a 2f 64 62 2f 6d 65 67 61 74 65 73 74  ath*/db/megatest
6f90: 2e 64 62 0a 09 20 20 20 20 20 20 20 28 69 74 65  .db..       (ite
6fa0: 6d 73 20 20 20 20 20 20 20 28 68 61 73 68 2d 74  ms       (hash-t
6fb0: 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74  able-ref/default
6fc0: 20 74 65 73 74 2d 63 6f 6e 66 20 22 69 74 65 6d   test-conf "item
6fd0: 73 22 20 27 28 29 29 29 0a 09 20 20 20 20 20 20  s" '()))..      
6fe0: 20 28 69 74 65 6d 73 74 61 62 6c 65 20 20 28 68   (itemstable  (h
6ff0: 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65  ash-table-ref/de
7000: 66 61 75 6c 74 20 74 65 73 74 2d 63 6f 6e 66 20  fault test-conf 
7010: 22 69 74 65 6d 73 74 61 62 6c 65 22 20 27 28 29  "itemstable" '()
7020: 29 29 0a 09 20 20 20 20 20 20 20 28 61 6c 6c 69  ))..       (alli
7030: 74 65 6d 73 20 20 20 20 28 69 66 20 28 6f 72 20  tems    (if (or 
7040: 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 69 74 65 6d  (not (null? item
7050: 73 29 29 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 69  s))(not (null? i
7060: 74 65 6d 73 74 61 62 6c 65 29 29 29 0a 09 09 09  temstable)))....
7070: 09 28 61 70 70 65 6e 64 20 28 69 74 65 6d 2d 61  .(append (item-a
7080: 73 73 6f 63 2d 3e 69 74 65 6d 2d 6c 69 73 74 20  ssoc->item-list 
7090: 69 74 65 6d 73 29 0a 09 09 09 09 09 28 69 74 65  items)......(ite
70a0: 6d 2d 74 61 62 6c 65 2d 3e 69 74 65 6d 2d 6c 69  m-table->item-li
70b0: 73 74 20 69 74 65 6d 73 74 61 62 6c 65 29 29 0a  st itemstable)).
70c0: 09 09 09 09 27 28 28 29 29 29 29 29 20 3b 3b 20  ....'(())))) ;; 
70d0: 61 20 6c 69 73 74 20 77 69 74 68 20 6f 6e 65 20  a list with one 
70e0: 6e 75 6c 6c 20 6c 69 73 74 20 69 73 20 61 20 74  null list is a t
70f0: 65 73 74 20 77 69 74 68 20 6e 6f 20 69 74 65 6d  est with no item
7100: 73 0a 3b 3b 20 09 20 20 28 72 75 6e 63 6f 6e 66  s.;; .  (runconf
7110: 69 67 66 20 20 28 63 6f 6e 63 20 20 2a 74 6f 70  igf  (conc  *top
7120: 70 61 74 68 2a 20 22 2f 72 75 6e 63 6f 6e 66 69  path* "/runconfi
7130: 67 73 2e 63 6f 6e 66 69 67 22 29 29 29 0a 09 20  gs.config"))).. 
7140: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20   (debug:print 1 
7150: 22 69 74 65 6d 73 3a 20 22 29 0a 09 20 20 28 69  "items: ")..  (i
7160: 66 20 28 3e 3d 20 2a 76 65 72 62 6f 73 69 74 79  f (>= *verbosity
7170: 2a 20 31 29 28 70 70 20 61 6c 6c 69 74 65 6d 73  * 1)(pp allitems
7180: 29 29 0a 09 20 20 28 69 66 20 28 3e 3d 20 2a 76  ))..  (if (>= *v
7190: 65 72 62 6f 73 69 74 79 2a 20 35 29 0a 09 20 20  erbosity* 5)..  
71a0: 20 20 20 20 28 62 65 67 69 6e 0a 09 09 28 70 72      (begin...(pr
71b0: 69 6e 74 20 22 69 74 65 6d 73 3a 20 22 29 28 70  int "items: ")(p
71c0: 70 20 28 69 74 65 6d 2d 61 73 73 6f 63 2d 3e 69  p (item-assoc->i
71d0: 74 65 6d 2d 6c 69 73 74 20 69 74 65 6d 73 29 29  tem-list items))
71e0: 0a 09 09 28 70 72 69 6e 74 20 22 69 74 65 73 74  ...(print "itest
71f0: 61 62 6c 65 3a 20 22 29 28 70 70 20 28 69 74 65  able: ")(pp (ite
7200: 6d 2d 74 61 62 6c 65 2d 3e 69 74 65 6d 2d 6c 69  m-table->item-li
7210: 73 74 20 69 74 65 6d 73 74 61 62 6c 65 29 29 29  st itemstable)))
7220: 29 0a 09 20 20 28 69 66 20 28 61 72 67 73 3a 67  )..  (if (args:g
7230: 65 74 2d 61 72 67 20 22 2d 6d 22 29 0a 09 20 20  et-arg "-m")..  
7240: 20 20 20 20 28 64 62 3a 73 65 74 2d 63 6f 6d 6d      (db:set-comm
7250: 65 6e 74 2d 66 6f 72 2d 72 75 6e 20 64 62 20 72  ent-for-run db r
7260: 75 6e 2d 69 64 20 28 61 72 67 73 3a 67 65 74 2d  un-id (args:get-
7270: 61 72 67 20 22 2d 6d 22 29 29 29 0a 0a 09 20 20  arg "-m")))...  
7280: 3b 3b 20 48 65 72 65 20 69 73 20 77 68 65 72 65  ;; Here is where
7290: 20 74 68 65 20 74 65 73 74 5f 6d 65 74 61 20 74   the test_meta t
72a0: 61 62 6c 65 20 69 73 20 62 65 73 74 20 75 70 64  able is best upd
72b0: 61 74 65 64 0a 09 20 20 28 72 75 6e 73 3a 75 70  ated..  (runs:up
72c0: 64 61 74 65 2d 74 65 73 74 5f 6d 65 74 61 20 64  date-test_meta d
72d0: 62 20 74 65 73 74 2d 6e 61 6d 65 20 74 65 73 74  b test-name test
72e0: 2d 63 6f 6e 66 29 0a 0a 09 20 20 3b 3b 20 62 72  -conf)...  ;; br
72f0: 61 69 6e 64 65 61 64 20 77 6f 72 6b 2d 61 72 6f  aindead work-aro
7300: 75 6e 64 20 66 6f 72 20 70 6f 6f 72 6c 79 20 73  und for poorly s
7310: 70 65 63 69 66 69 65 64 20 61 6c 6c 69 74 65 6d  pecified allitem
7320: 73 20 6c 69 73 74 20 42 55 47 21 21 21 20 46 49  s list BUG!!! FI
7330: 58 4d 45 0a 09 20 20 28 69 66 20 28 6e 75 6c 6c  XME..  (if (null
7340: 3f 20 61 6c 6c 69 74 65 6d 73 29 28 73 65 74 21  ? allitems)(set!
7350: 20 61 6c 6c 69 74 65 6d 73 20 27 28 28 29 29 29   allitems '(()))
7360: 29 0a 09 20 20 28 6c 65 74 20 6c 6f 6f 70 20 28  )..  (let loop (
7370: 28 69 74 65 6d 64 61 74 20 28 63 61 72 20 61 6c  (itemdat (car al
7380: 6c 69 74 65 6d 73 29 29 0a 09 09 20 20 20 20 20  litems))...     
7390: 28 74 61 6c 20 20 20 20 20 28 63 64 72 20 61 6c  (tal     (cdr al
73a0: 6c 69 74 65 6d 73 29 29 29 0a 09 20 20 20 20 3b  litems)))..    ;
73b0: 3b 20 28 6c 61 6d 62 64 61 20 28 69 74 65 6d 64  ; (lambda (itemd
73c0: 61 74 29 20 3b 3b 3b 20 28 28 72 69 70 65 6e 65  at) ;;; ((ripene
73d0: 73 73 20 22 6f 76 65 72 72 69 70 65 22 29 20 28  ss "overripe") (
73e0: 74 65 6d 70 65 72 61 74 75 72 65 20 22 63 6f 6f  temperature "coo
73f0: 6c 22 29 20 28 73 65 61 73 6f 6e 20 22 73 75 6d  l") (season "sum
7400: 6d 65 72 22 29 29 0a 09 20 20 20 20 3b 3b 20 48  mer"))..    ;; H
7410: 61 6e 64 6c 65 20 6c 69 73 74 73 20 6f 66 20 69  andle lists of i
7420: 74 65 6d 73 0a 09 20 20 20 20 28 6c 65 74 2a 20  tems..    (let* 
7430: 28 28 69 74 65 6d 2d 70 61 74 68 20 20 20 20 20  ((item-path     
7440: 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68  (item-list->path
7450: 20 69 74 65 6d 64 61 74 29 29 20 3b 3b 20 28 73   itemdat)) ;; (s
7460: 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73  tring-interspers
7470: 65 20 28 6d 61 70 20 63 61 64 72 20 69 74 65 6d  e (map cadr item
7480: 64 61 74 29 20 22 2f 22 29 29 0a 09 09 20 20 20  dat) "/"))...   
7490: 28 6e 65 77 2d 74 65 73 74 2d 70 61 74 68 20 28  (new-test-path (
74a0: 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72  string-intersper
74b0: 73 65 20 28 63 6f 6e 73 20 74 65 73 74 2d 70 61  se (cons test-pa
74c0: 74 68 20 28 6d 61 70 20 63 61 64 72 20 69 74 65  th (map cadr ite
74d0: 6d 64 61 74 29 29 20 22 2f 22 29 29 0a 09 09 20  mdat)) "/"))... 
74e0: 20 20 28 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65    (new-test-name
74f0: 20 28 69 66 20 28 65 71 75 61 6c 3f 20 69 74 65   (if (equal? ite
7500: 6d 2d 70 61 74 68 20 22 22 29 20 74 65 73 74 2d  m-path "") test-
7510: 6e 61 6d 65 20 28 63 6f 6e 63 20 74 65 73 74 2d  name (conc test-
7520: 6e 61 6d 65 20 22 2f 22 20 69 74 65 6d 2d 70 61  name "/" item-pa
7530: 74 68 29 29 29 20 3b 3b 20 6a 75 73 74 20 6e 65  th))) ;; just ne
7540: 65 64 20 69 74 20 74 6f 20 62 65 20 75 6e 69 71  ed it to be uniq
7550: 75 65 0a 09 09 20 20 20 28 74 65 73 74 64 61 74  ue...   (testdat
7560: 20 20 20 23 66 29 0a 09 09 20 20 20 28 6e 75 6d     #f)...   (num
7570: 2d 72 75 6e 6e 69 6e 67 20 28 64 62 3a 67 65 74  -running (db:get
7580: 2d 63 6f 75 6e 74 2d 74 65 73 74 73 2d 72 75 6e  -count-tests-run
7590: 6e 69 6e 67 20 64 62 29 29 0a 09 09 20 20 20 28  ning db))...   (
75a0: 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a  max-concurrent-j
75b0: 6f 62 73 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b  obs (config-look
75c0: 75 70 20 2a 63 6f 6e 66 69 67 64 61 74 2a 20 22  up *configdat* "
75d0: 73 65 74 75 70 22 20 22 6d 61 78 5f 63 6f 6e 63  setup" "max_conc
75e0: 75 72 72 65 6e 74 5f 6a 6f 62 73 22 29 29 0a 09  urrent_jobs"))..
75f0: 09 20 20 20 28 70 61 72 65 6e 74 2d 74 65 73 74  .   (parent-test
7600: 20 28 61 6e 64 20 28 6e 6f 74 20 28 6e 75 6c 6c   (and (not (null
7610: 3f 20 69 74 65 6d 73 29 29 28 65 71 75 61 6c 3f  ? items))(equal?
7620: 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29 29 29   item-path "")))
7630: 0a 09 09 20 20 20 28 73 69 6e 67 6c 65 2d 74 65  ...   (single-te
7640: 73 74 20 28 61 6e 64 20 28 6e 75 6c 6c 3f 20 69  st (and (null? i
7650: 74 65 6d 73 29 20 28 65 71 75 61 6c 3f 20 69 74  tems) (equal? it
7660: 65 6d 2d 70 61 74 68 20 22 22 29 29 29 0a 09 09  em-path "")))...
7670: 20 20 20 28 69 74 65 6d 2d 74 65 73 74 20 20 20     (item-test   
7680: 28 6e 6f 74 20 28 65 71 75 61 6c 3f 20 69 74 65  (not (equal? ite
7690: 6d 2d 70 61 74 68 20 22 22 29 29 29 0a 09 09 20  m-path "")))... 
76a0: 20 20 28 69 74 65 6d 2d 70 61 74 74 20 20 20 28    (item-patt   (
76b0: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 69  args:get-arg "-i
76c0: 74 65 6d 70 61 74 74 22 29 29 0a 09 09 20 20 20  tempatt"))...   
76d0: 28 70 61 74 74 2d 6d 61 74 63 68 20 20 28 69 66  (patt-match  (if
76e0: 20 69 74 65 6d 2d 70 61 74 74 0a 09 09 09 09 20   item-patt..... 
76f0: 20 20 20 28 73 74 72 69 6e 67 2d 73 65 61 72 63     (string-searc
7700: 68 20 28 67 6c 6f 62 2d 3e 72 65 67 65 78 70 0a  h (glob->regexp.
7710: 09 09 09 09 09 09 20 20 20 28 73 74 72 69 6e 67  ......   (string
7720: 2d 74 72 61 6e 73 6c 61 74 65 20 69 74 65 6d 2d  -translate item-
7730: 70 61 74 74 20 22 25 22 20 22 2a 22 29 29 0a 09  patt "%" "*"))..
7740: 09 09 09 09 09 20 20 69 74 65 6d 2d 70 61 74 68  .....  item-path
7750: 29 0a 09 09 09 09 20 20 20 20 23 74 29 29 29 0a  ).....    #t))).
7760: 09 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72  .      (debug:pr
7770: 69 6e 74 20 33 20 22 6d 61 78 2d 63 6f 6e 63 75  int 3 "max-concu
7780: 72 72 65 6e 74 2d 6a 6f 62 73 3a 20 22 20 6d 61  rrent-jobs: " ma
7790: 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62  x-concurrent-job
77a0: 73 20 22 2c 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67  s ", num-running
77b0: 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67 29  : " num-running)
77c0: 0a 09 20 20 20 20 20 20 28 69 66 20 28 61 6e 64  ..      (if (and
77d0: 20 70 61 74 74 2d 6d 61 74 63 68 20 28 72 75 6e   patt-match (run
77e0: 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65 2d 74  s:can-run-more-t
77f0: 65 73 74 73 20 64 62 29 29 0a 09 09 20 20 28 62  ests db))...  (b
7800: 65 67 69 6e 0a 09 09 20 20 20 20 28 6c 65 74 20  egin...    (let 
7810: 6c 6f 6f 70 32 20 28 28 74 73 20 28 64 62 3a 67  loop2 ((ts (db:g
7820: 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 20  et-test-info db 
7830: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
7840: 20 69 74 65 6d 2d 70 61 74 68 29 29 20 3b 3b 20   item-path)) ;; 
7850: 23 66 29 0a 09 09 09 09 28 63 74 20 30 29 29 0a  #f).....(ct 0)).
7860: 09 09 20 20 20 20 20 20 28 69 66 20 28 61 6e 64  ..      (if (and
7870: 20 28 6e 6f 74 20 74 73 29 0a 09 09 09 20 20 20   (not ts)....   
7880: 20 20 20 20 28 3c 20 63 74 20 31 30 29 29 0a 09      (< ct 10))..
7890: 09 09 20 20 28 62 65 67 69 6e 0a 09 09 09 20 20  ..  (begin....  
78a0: 20 20 28 72 65 67 69 73 74 65 72 2d 74 65 73 74    (register-test
78b0: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d   db run-id test-
78c0: 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 0a  name item-path).
78d0: 09 09 09 20 20 20 20 28 64 62 3a 74 65 73 74 2d  ...    (db:test-
78e0: 73 65 74 2d 63 6f 6d 6d 65 6e 74 20 64 62 20 72  set-comment db r
78f0: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
7900: 69 74 65 6d 2d 70 61 74 68 20 22 22 29 0a 09 09  item-path "")...
7910: 09 20 20 20 20 28 6c 6f 6f 70 32 20 28 64 62 3a  .    (loop2 (db:
7920: 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62  get-test-info db
7930: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
7940: 65 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 09 09  e item-path)....
7950: 09 20 20 20 28 2b 20 63 74 20 31 29 29 29 0a 09  .   (+ ct 1)))..
7960: 09 09 20 20 28 69 66 20 74 73 0a 09 09 09 20 20  ..  (if ts....  
7970: 20 20 20 20 28 73 65 74 21 20 74 65 73 74 64 61      (set! testda
7980: 74 20 74 73 29 0a 09 09 09 20 20 20 20 20 20 28  t ts)....      (
7990: 62 65 67 69 6e 0a 09 09 09 09 28 64 65 62 75 67  begin.....(debug
79a0: 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e  :print 0 "WARNIN
79b0: 47 3a 20 43 6f 75 6c 64 6e 27 74 20 72 65 67 69  G: Couldn't regi
79c0: 73 74 65 72 20 74 65 73 74 20 22 20 74 65 73 74  ster test " test
79d0: 2d 6e 61 6d 65 20 22 20 77 69 74 68 20 69 74 65  -name " with ite
79e0: 6d 20 70 61 74 68 20 22 20 69 74 65 6d 2d 70 61  m path " item-pa
79f0: 74 68 20 22 2c 20 73 6b 69 70 70 69 6e 67 22 29  th ", skipping")
7a00: 0a 09 09 09 09 28 69 66 20 28 6e 6f 74 20 28 6e  .....(if (not (n
7a10: 75 6c 6c 3f 20 74 61 6c 29 29 0a 09 09 09 09 20  ull? tal))..... 
7a20: 20 20 20 28 6c 6f 6f 70 20 28 63 61 72 20 74 61     (loop (car ta
7a30: 6c 29 28 63 64 72 20 74 61 6c 29 29 29 29 29 29  l)(cdr tal))))))
7a40: 29 0a 09 09 20 20 20 20 28 63 68 61 6e 67 65 2d  )...    (change-
7a50: 64 69 72 65 63 74 6f 72 79 20 74 65 73 74 2d 70  directory test-p
7a60: 61 74 68 29 0a 09 09 20 20 20 20 3b 3b 20 74 68  ath)...    ;; th
7a70: 69 73 20 62 6c 6f 63 6b 20 69 73 20 68 65 72 65  is block is here
7a80: 20 6f 6e 6c 79 20 74 6f 20 69 6e 66 6f 72 6d 20   only to inform 
7a90: 74 68 65 20 75 73 65 72 20 65 61 72 6c 79 20 6f  the user early o
7aa0: 6e 0a 09 09 20 20 20 20 0a 09 09 20 20 20 20 3b  n...    ...    ;
7ab0: 3b 20 4e 42 2f 2f 20 4d 6f 76 69 6e 67 20 74 68  ; NB// Moving th
7ac0: 65 20 73 65 74 74 69 6e 67 20 6f 66 20 72 75 6e  e setting of run
7ad0: 63 6f 6e 66 69 67 2e 63 6f 6e 66 69 67 20 76 61  config.config va
7ae0: 72 73 20 74 6f 20 2a 62 65 66 6f 72 65 2a 20 74  rs to *before* t
7af0: 68 65 20 0a 09 09 20 20 20 20 3b 3b 20 74 68 65  he ...    ;; the
7b00: 20 63 61 6c 6c 69 6e 67 20 6f 66 20 65 61 63 68   calling of each
7b10: 20 74 65 73 74 2e 0a 09 09 20 20 20 20 3b 3b 20   test....    ;; 
7b20: 28 69 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73  (if (file-exists
7b30: 3f 20 72 75 6e 63 6f 6e 66 69 67 66 29 0a 09 09  ? runconfigf)...
7b40: 20 20 20 20 3b 3b 20 20 20 20 20 28 73 65 74 75      ;;     (setu
7b50: 70 2d 65 6e 76 2d 64 65 66 61 75 6c 74 73 20 64  p-env-defaults d
7b60: 62 20 72 75 6e 63 6f 6e 66 69 67 66 20 72 75 6e  b runconfigf run
7b70: 2d 69 64 20 2a 61 6c 72 65 61 64 79 2d 73 65 65  -id *already-see
7b80: 6e 2d 72 75 6e 63 6f 6e 66 69 67 2d 69 6e 66 6f  n-runconfig-info
7b90: 2a 29 0a 09 09 20 20 20 20 3b 3b 20 20 20 20 20  *)...    ;;     
7ba0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
7bb0: 57 41 52 4e 49 4e 47 3a 20 59 6f 75 20 64 6f 20  WARNING: You do 
7bc0: 6e 6f 74 20 68 61 76 65 20 61 20 72 75 6e 20 63  not have a run c
7bd0: 6f 6e 66 69 67 20 66 69 6c 65 3a 20 22 20 72 75  onfig file: " ru
7be0: 6e 63 6f 6e 66 69 67 66 29 29 0a 09 09 20 20 20  nconfigf))...   
7bf0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20   (debug:print 4 
7c00: 22 72 75 6e 2d 69 64 3a 20 22 20 72 75 6e 2d 69  "run-id: " run-i
7c10: 64 20 22 20 74 65 73 74 2d 6e 61 6d 65 3a 20 22  d " test-name: "
7c20: 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 69 74 65   test-name " ite
7c30: 6d 2d 70 61 74 68 3a 20 22 20 69 74 65 6d 2d 70  m-path: " item-p
7c40: 61 74 68 20 22 20 74 65 73 74 64 61 74 3a 20 22  ath " testdat: "
7c50: 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75   (test:get-statu
7c60: 73 20 74 65 73 74 64 61 74 29 20 22 20 74 65 73  s testdat) " tes
7c70: 74 2d 73 74 61 74 65 3a 20 22 20 28 74 65 73 74  t-state: " (test
7c80: 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64  :get-state testd
7c90: 61 74 29 29 0a 09 09 20 20 20 20 28 63 61 73 65  at))...    (case
7ca0: 20 28 69 66 20 28 61 72 67 73 3a 67 65 74 2d 61   (if (args:get-a
7cb0: 72 67 20 22 2d 66 6f 72 63 65 22 29 0a 09 09 09  rg "-force")....
7cc0: 20 20 20 20 20 20 27 4e 4f 54 5f 53 54 41 52 54        'NOT_START
7cd0: 45 44 0a 09 09 09 20 20 20 20 20 20 28 69 66 20  ED....      (if 
7ce0: 74 65 73 74 64 61 74 0a 09 09 09 09 20 20 28 73  testdat.....  (s
7cf0: 74 72 69 6e 67 2d 3e 73 79 6d 62 6f 6c 20 28 74  tring->symbol (t
7d00: 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65  est:get-state te
7d10: 73 74 64 61 74 29 29 0a 09 09 09 09 20 20 27 66  stdat)).....  'f
7d20: 61 69 6c 65 64 2d 74 6f 2d 69 6e 73 65 72 74 29  ailed-to-insert)
7d30: 29 0a 09 09 20 20 20 20 20 20 28 28 66 61 69 6c  )...      ((fail
7d40: 65 64 2d 74 6f 2d 69 6e 73 65 72 74 29 0a 09 09  ed-to-insert)...
7d50: 20 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72         (debug:pr
7d60: 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 46 61  int 0 "ERROR: Fa
7d70: 69 6c 65 64 20 74 6f 20 69 6e 73 65 72 74 20 74  iled to insert t
7d80: 68 65 20 72 65 63 6f 72 64 20 69 6e 74 6f 20 74  he record into t
7d90: 68 65 20 64 62 22 29 29 0a 09 09 20 20 20 20 20  he db"))...     
7da0: 20 28 28 4e 4f 54 5f 53 54 41 52 54 45 44 20 43   ((NOT_STARTED C
7db0: 4f 4d 50 4c 45 54 45 44 29 0a 09 09 20 20 20 20  OMPLETED)...    
7dc0: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
7dd0: 36 20 22 47 6f 74 20 68 65 72 65 2c 20 22 20 28  6 "Got here, " (
7de0: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74  test:get-state t
7df0: 65 73 74 64 61 74 29 29 0a 09 09 20 20 20 20 20  estdat))...     
7e00: 20 20 28 6c 65 74 20 28 28 72 75 6e 66 6c 61 67    (let ((runflag
7e10: 20 23 66 29 29 0a 09 09 09 20 28 63 6f 6e 64 0a   #f)).... (cond.
7e20: 09 09 09 20 20 3b 3b 20 69 2e 65 2e 20 74 68 69  ...  ;; i.e. thi
7e30: 73 20 69 73 20 74 68 65 20 70 61 72 65 6e 74 20  s is the parent 
7e40: 74 65 73 74 20 74 6f 20 61 20 73 75 69 74 65 20  test to a suite 
7e50: 6f 66 20 69 74 65 6d 73 2c 20 6e 65 76 65 72 20  of items, never 
7e60: 22 72 75 6e 22 20 69 74 0a 09 09 09 20 20 28 70  "run" it....  (p
7e70: 61 72 65 6e 74 2d 74 65 73 74 0a 09 09 09 20 20  arent-test....  
7e80: 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23   (set! runflag #
7e90: 66 29 29 0a 09 09 09 20 20 3b 3b 20 2d 66 6f 72  f))....  ;; -for
7ea0: 63 65 2c 20 72 75 6e 20 6e 6f 20 6d 61 74 74 65  ce, run no matte
7eb0: 72 20 77 68 61 74 0a 09 09 09 20 20 28 28 61 72  r what....  ((ar
7ec0: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 66 6f 72  gs:get-arg "-for
7ed0: 63 65 22 29 28 73 65 74 21 20 72 75 6e 66 6c 61  ce")(set! runfla
7ee0: 67 20 23 74 29 29 0a 09 09 09 20 20 3b 3b 20 4e  g #t))....  ;; N
7ef0: 4f 54 5f 53 54 41 52 54 45 44 2c 20 72 75 6e 20  OT_STARTED, run 
7f00: 6e 6f 20 6d 61 74 74 65 72 20 77 68 61 74 0a 09  no matter what..
7f10: 09 09 20 20 28 28 65 71 75 61 6c 3f 20 28 74 65  ..  ((equal? (te
7f20: 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73  st:get-state tes
7f30: 74 64 61 74 29 20 22 4e 4f 54 5f 53 54 41 52 54  tdat) "NOT_START
7f40: 45 44 22 29 28 73 65 74 21 20 72 75 6e 66 6c 61  ED")(set! runfla
7f50: 67 20 23 74 29 29 0a 09 09 09 20 20 3b 3b 20 6e  g #t))....  ;; n
7f60: 6f 74 20 2d 72 65 72 75 6e 20 61 6e 64 20 50 41  ot -rerun and PA
7f70: 53 53 2c 20 57 41 52 4e 20 6f 72 20 43 48 45 43  SS, WARN or CHEC
7f80: 4b 2c 20 64 6f 20 6e 6f 20 72 75 6e 0a 09 09 09  K, do no run....
7f90: 20 20 28 28 61 6e 64 20 28 6f 72 20 28 6e 6f 74    ((and (or (not
7fa0: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22   (args:get-arg "
7fb0: 2d 72 65 72 75 6e 22 29 29 0a 09 09 09 09 20 20  -rerun")).....  
7fc0: 20 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20    (args:get-arg 
7fd0: 22 2d 6b 65 65 70 67 6f 69 6e 67 22 29 29 0a 09  "-keepgoing"))..
7fe0: 09 09 09 28 6d 65 6d 62 65 72 20 28 74 65 73 74  ...(member (test
7ff0: 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74  :get-status test
8000: 64 61 74 29 20 27 28 22 50 41 53 53 22 20 22 57  dat) '("PASS" "W
8010: 41 52 4e 22 20 22 43 48 45 43 4b 22 29 29 29 0a  ARN" "CHECK"))).
8020: 09 09 09 20 20 20 28 73 65 74 21 20 72 75 6e 66  ...   (set! runf
8030: 6c 61 67 20 23 66 29 29 0a 09 09 09 20 20 3b 3b  lag #f))....  ;;
8040: 20 2d 72 65 72 75 6e 20 61 6e 64 20 73 74 61 74   -rerun and stat
8050: 75 73 20 69 73 20 6f 6e 65 20 6f 66 20 74 68 65  us is one of the
8060: 20 73 70 65 63 69 66 65 64 2c 20 72 75 6e 20 69   specifed, run i
8070: 74 0a 09 09 09 20 20 28 28 61 6e 64 20 28 61 72  t....  ((and (ar
8080: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65 72  gs:get-arg "-rer
8090: 75 6e 22 29 0a 09 09 09 09 28 6c 65 74 20 28 28  un").....(let ((
80a0: 72 65 72 75 6e 6c 73 74 20 28 73 74 72 69 6e 67  rerunlst (string
80b0: 2d 73 70 6c 69 74 20 28 61 72 67 73 3a 67 65 74  -split (args:get
80c0: 2d 61 72 67 20 22 2d 72 65 72 75 6e 22 29 20 22  -arg "-rerun") "
80d0: 2c 22 29 29 29 20 3b 3b 20 46 41 49 4c 2c 0a 09  ,"))) ;; FAIL,..
80e0: 09 09 09 20 20 28 6d 65 6d 62 65 72 20 28 74 65  ...  (member (te
80f0: 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65  st:get-status te
8100: 73 74 64 61 74 29 20 72 65 72 75 6e 6c 73 74 29  stdat) rerunlst)
8110: 29 29 0a 09 09 09 20 20 20 28 73 65 74 21 20 72  ))....   (set! r
8120: 75 6e 66 6c 61 67 20 23 74 29 29 0a 09 09 09 20  unflag #t)).... 
8130: 20 3b 3b 20 2d 6b 65 65 70 67 6f 69 6e 67 2c 20   ;; -keepgoing, 
8140: 64 6f 20 6e 6f 74 20 72 65 72 75 6e 20 46 41 49  do not rerun FAI
8150: 4c 0a 09 09 09 20 20 28 28 61 6e 64 20 28 61 72  L....  ((and (ar
8160: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 6b 65 65  gs:get-arg "-kee
8170: 70 67 6f 69 6e 67 22 29 0a 09 09 09 09 28 6d 65  pgoing").....(me
8180: 6d 62 65 72 20 28 74 65 73 74 3a 67 65 74 2d 73  mber (test:get-s
8190: 74 61 74 75 73 20 74 65 73 74 64 61 74 29 20 27  tatus testdat) '
81a0: 28 22 46 41 49 4c 22 29 29 29 0a 09 09 09 20 20  ("FAIL")))....  
81b0: 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23   (set! runflag #
81c0: 66 29 29 0a 09 09 09 20 20 28 28 61 6e 64 20 28  f))....  ((and (
81d0: 6e 6f 74 20 28 61 72 67 73 3a 67 65 74 2d 61 72  not (args:get-ar
81e0: 67 20 22 2d 72 65 72 75 6e 22 29 29 0a 09 09 09  g "-rerun"))....
81f0: 09 28 6d 65 6d 62 65 72 20 28 74 65 73 74 3a 67  .(member (test:g
8200: 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61  et-status testda
8210: 74 29 20 27 28 22 46 41 49 4c 22 20 22 6e 2f 61  t) '("FAIL" "n/a
8220: 22 29 29 29 0a 09 09 09 20 20 20 28 73 65 74 21  ")))....   (set!
8230: 20 72 75 6e 66 6c 61 67 20 23 74 29 29 0a 09 09   runflag #t))...
8240: 09 20 20 28 65 6c 73 65 20 28 73 65 74 21 20 72  .  (else (set! r
8250: 75 6e 66 6c 61 67 20 23 66 29 29 29 0a 09 09 09  unflag #f)))....
8260: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 36 20   (debug:print 6 
8270: 22 52 55 4e 4e 49 4e 47 20 3d 3e 20 72 75 6e 66  "RUNNING => runf
8280: 6c 61 67 3a 20 22 20 72 75 6e 66 6c 61 67 20 22  lag: " runflag "
8290: 20 53 54 41 54 45 3a 20 22 20 28 74 65 73 74 3a   STATE: " (test:
82a0: 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61  get-state testda
82b0: 74 29 20 22 20 53 54 41 54 55 53 3a 20 22 20 28  t) " STATUS: " (
82c0: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20  test:get-status 
82d0: 74 65 73 74 64 61 74 29 29 0a 09 09 09 20 28 69  testdat)).... (i
82e0: 66 20 28 6e 6f 74 20 72 75 6e 66 6c 61 67 29 0a  f (not runflag).
82f0: 09 09 09 20 20 20 20 20 28 69 66 20 28 6e 6f 74  ...     (if (not
8300: 20 70 61 72 65 6e 74 2d 74 65 73 74 29 0a 09 09   parent-test)...
8310: 09 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20  .. (debug:print 
8320: 31 20 22 4e 4f 54 45 3a 20 4e 6f 74 20 73 74 61  1 "NOTE: Not sta
8330: 72 74 69 6e 67 20 74 65 73 74 20 22 20 6e 65 77  rting test " new
8340: 2d 74 65 73 74 2d 6e 61 6d 65 20 22 20 61 73 20  -test-name " as 
8350: 69 74 20 69 73 20 73 74 61 74 65 20 5c 22 43 4f  it is state \"CO
8360: 4d 50 4c 45 54 45 44 5c 22 20 61 6e 64 20 73 74  MPLETED\" and st
8370: 61 74 75 73 20 5c 22 22 20 28 74 65 73 74 3a 67  atus \"" (test:g
8380: 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61  et-status testda
8390: 74 29 20 22 5c 22 2c 20 75 73 65 20 2d 66 6f 72  t) "\", use -for
83a0: 63 65 20 74 6f 20 6f 76 65 72 72 69 64 65 22 29  ce to override")
83b0: 29 0a 09 09 09 20 20 20 20 20 28 6c 65 74 2a 20  )....     (let* 
83c0: 28 28 67 65 74 2d 70 72 65 72 65 71 73 2d 63 6d  ((get-prereqs-cm
83d0: 64 20 28 6c 61 6d 62 64 61 20 28 29 0a 09 09 09  d (lambda ()....
83e0: 09 09 09 20 20 20 20 20 20 20 28 64 62 2d 67 65  ...       (db-ge
83f0: 74 2d 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65  t-prereqs-not-me
8400: 74 20 64 62 20 72 75 6e 2d 69 64 20 77 61 69 74  t db run-id wait
8410: 6f 6e 29 29 29 20 3b 3b 20 63 68 65 63 6b 20 62  on))) ;; check b
8420: 65 66 6f 72 65 20 72 75 6e 6e 69 6e 67 20 2e 2e  efore running ..
8430: 2e 2e 0a 09 09 09 09 20 20 20 20 28 6c 61 75 6e  .......    (laun
8440: 63 68 2d 63 6d 64 20 20 20 20 20 20 28 6c 61 6d  ch-cmd      (lam
8450: 62 64 61 20 28 29 0a 09 09 09 09 09 09 20 20 20  bda ().......   
8460: 20 20 20 20 28 6c 61 75 6e 63 68 2d 74 65 73 74      (launch-test
8470: 20 64 62 20 72 75 6e 2d 69 64 20 28 61 72 67 73   db run-id (args
8480: 3a 67 65 74 2d 61 72 67 20 22 3a 72 75 6e 6e 61  :get-arg ":runna
8490: 6d 65 22 29 20 74 65 73 74 2d 63 6f 6e 66 20 6b  me") test-conf k
84a0: 65 79 76 61 6c 6c 73 74 20 74 65 73 74 2d 6e 61  eyvallst test-na
84b0: 6d 65 20 74 65 73 74 2d 70 61 74 68 20 69 74 65  me test-path ite
84c0: 6d 64 61 74 20 61 72 67 73 3a 61 72 67 2d 68 61  mdat args:arg-ha
84d0: 73 68 29 29 29 0a 09 09 09 09 20 20 20 20 28 74  sh))).....    (t
84e0: 65 73 74 72 75 6e 64 61 74 20 20 20 20 20 20 28  estrundat      (
84f0: 6c 69 73 74 20 67 65 74 2d 70 72 65 72 65 71 73  list get-prereqs
8500: 2d 63 6d 64 20 6c 61 75 6e 63 68 2d 63 6d 64 29  -cmd launch-cmd)
8510: 29 29 0a 09 09 09 20 20 20 20 20 20 20 28 69 66  ))....       (if
8520: 20 28 6f 72 20 28 61 72 67 73 3a 67 65 74 2d 61   (or (args:get-a
8530: 72 67 20 22 2d 66 6f 72 63 65 22 29 0a 09 09 09  rg "-force")....
8540: 09 20 20 20 20 20 20 20 28 6c 65 74 20 28 28 70  .       (let ((p
8550: 72 65 71 73 2d 6e 6f 74 2d 79 65 74 2d 6d 65 74  reqs-not-yet-met
8560: 20 28 28 63 61 72 20 74 65 73 74 72 75 6e 64 61   ((car testrunda
8570: 74 29 29 29 29 0a 09 09 09 09 09 20 28 64 65 62  t))))...... (deb
8580: 75 67 3a 70 72 69 6e 74 20 32 20 22 50 72 65 71  ug:print 2 "Preq
8590: 72 65 71 75 65 73 69 74 65 73 20 66 6f 72 20 22  requesites for "
85a0: 20 74 65 73 74 2d 6e 61 6d 65 20 22 3a 20 22 20   test-name ": " 
85b0: 70 72 65 71 73 2d 6e 6f 74 2d 79 65 74 2d 6d 65  preqs-not-yet-me
85c0: 74 29 0a 09 09 09 09 09 20 28 6e 75 6c 6c 3f 20  t)...... (null? 
85d0: 70 72 65 71 73 2d 6e 6f 74 2d 79 65 74 2d 6d 65  preqs-not-yet-me
85e0: 74 29 29 29 20 3b 3b 20 61 72 65 20 74 68 65 72  t))) ;; are ther
85f0: 65 20 61 6e 79 20 74 65 73 74 73 20 74 68 61 74  e any tests that
8600: 20 6d 75 73 74 20 62 65 20 72 75 6e 20 62 65 66   must be run bef
8610: 6f 72 65 20 74 68 69 73 20 6f 6e 65 2e 2e 2e 0a  ore this one....
8620: 09 09 09 09 20 20 20 28 69 66 20 28 6e 6f 74 20  ....   (if (not 
8630: 28 28 63 61 64 72 20 74 65 73 74 72 75 6e 64 61  ((cadr testrunda
8640: 74 29 29 29 20 3b 3b 20 74 68 69 73 20 69 73 20  t))) ;; this is 
8650: 74 68 65 20 6c 69 6e 65 20 74 68 61 74 20 6c 61  the line that la
8660: 75 6e 63 68 65 73 20 74 68 65 20 74 65 73 74 20  unches the test 
8670: 74 6f 20 74 68 65 20 72 65 6d 6f 74 65 20 68 6f  to the remote ho
8680: 73 74 0a 09 09 09 09 20 20 20 20 20 20 20 28 62  st.....       (b
8690: 65 67 69 6e 0a 09 09 09 09 09 20 28 70 72 69 6e  egin...... (prin
86a0: 74 20 22 45 52 52 4f 52 3a 20 46 61 69 6c 65 64  t "ERROR: Failed
86b0: 20 74 6f 20 6c 61 75 6e 63 68 20 74 68 65 20 74   to launch the t
86c0: 65 73 74 2e 20 45 78 69 74 69 6e 67 20 61 73 20  est. Exiting as 
86d0: 73 6f 6f 6e 20 61 73 20 70 6f 73 73 69 62 6c 65  soon as possible
86e0: 22 29 0a 09 09 09 09 09 20 28 73 65 74 21 20 2a  ")...... (set! *
86f0: 67 6c 6f 62 61 6c 65 78 69 74 73 74 61 74 75 73  globalexitstatus
8700: 2a 20 31 29 20 3b 3b 20 0a 09 09 09 09 09 20 28  * 1) ;; ...... (
8710: 70 72 6f 63 65 73 73 2d 73 69 67 6e 61 6c 20 28  process-signal (
8720: 63 75 72 72 65 6e 74 2d 70 72 6f 63 65 73 73 2d  current-process-
8730: 69 64 29 20 73 69 67 6e 61 6c 2f 6b 69 6c 6c 29  id) signal/kill)
8740: 0a 09 09 09 09 09 20 3b 28 65 78 69 74 20 31 29  ...... ;(exit 1)
8750: 0a 09 09 09 09 09 20 29 29 0a 09 09 09 09 20 20  ...... )).....  
8760: 20 28 69 66 20 28 6e 6f 74 20 28 61 72 67 73 3a   (if (not (args:
8770: 67 65 74 2d 61 72 67 20 22 2d 6b 65 65 70 67 6f  get-arg "-keepgo
8780: 69 6e 67 22 29 29 0a 09 09 09 09 20 20 20 20 20  ing")).....     
8790: 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65    (hash-table-se
87a0: 74 21 20 2a 77 61 69 74 69 6e 67 2d 71 75 65 75  t! *waiting-queu
87b0: 65 2a 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65  e* new-test-name
87c0: 20 74 65 73 74 72 75 6e 64 61 74 29 29 29 29 29   testrundat)))))
87d0: 29 29 0a 09 09 20 20 20 20 20 20 28 28 4b 49 4c  ))...      ((KIL
87e0: 4c 45 44 29 20 0a 09 09 20 20 20 20 20 20 20 28  LED) ...       (
87f0: 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 4e  debug:print 1 "N
8800: 4f 54 45 3a 20 22 20 6e 65 77 2d 74 65 73 74 2d  OTE: " new-test-
8810: 6e 61 6d 65 20 22 20 69 73 20 61 6c 72 65 61 64  name " is alread
8820: 79 20 72 75 6e 6e 69 6e 67 20 6f 72 20 77 61 73  y running or was
8830: 20 65 78 70 6c 69 63 74 6c 79 20 6b 69 6c 6c 65   explictly kille
8840: 64 2c 20 75 73 65 20 2d 66 6f 72 63 65 20 74 6f  d, use -force to
8850: 20 6c 61 75 6e 63 68 20 69 74 2e 22 29 29 0a 09   launch it."))..
8860: 09 20 20 20 20 20 20 28 28 4c 41 55 4e 43 48 45  .      ((LAUNCHE
8870: 44 20 52 45 4d 4f 54 45 48 4f 53 54 53 54 41 52  D REMOTEHOSTSTAR
8880: 54 20 52 55 4e 4e 49 4e 47 29 20 20 0a 09 09 20  T RUNNING)  ... 
8890: 20 20 20 20 20 20 28 69 66 20 28 3e 20 28 2d 20        (if (> (- 
88a0: 28 63 75 72 72 65 6e 74 2d 73 65 63 6f 6e 64 73  (current-seconds
88b0: 29 28 2b 20 28 64 62 3a 74 65 73 74 2d 67 65 74  )(+ (db:test-get
88c0: 2d 65 76 65 6e 74 5f 74 69 6d 65 20 74 65 73 74  -event_time test
88d0: 64 61 74 29 0a 09 09 09 09 09 09 20 20 20 20 20  dat).......     
88e0: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 72 75 6e  (db:test-get-run
88f0: 5f 64 75 72 61 74 69 6f 6e 20 74 65 73 74 64 61  _duration testda
8900: 74 29 29 29 0a 09 09 09 20 20 20 20 20 20 31 30  t)))....      10
8910: 30 29 20 3b 3b 20 69 2e 65 2e 20 6e 6f 20 75 70  0) ;; i.e. no up
8920: 64 61 74 65 20 66 6f 72 20 6d 6f 72 65 20 74 68  date for more th
8930: 61 6e 20 31 30 30 20 73 65 63 6f 6e 64 73 0a 09  an 100 seconds..
8940: 09 09 20 20 20 28 62 65 67 69 6e 0a 09 09 09 20  ..   (begin.... 
8950: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
8960: 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 54 65 73   0 "WARNING: Tes
8970: 74 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20  t " test-name " 
8980: 61 70 70 65 61 72 73 20 74 6f 20 62 65 20 64 65  appears to be de
8990: 61 64 2e 20 46 6f 72 63 69 6e 67 20 69 74 20 74  ad. Forcing it t
89a0: 6f 20 73 74 61 74 65 20 49 4e 43 4f 4d 50 4c 45  o state INCOMPLE
89b0: 54 45 20 61 6e 64 20 73 74 61 74 75 73 20 53 54  TE and status ST
89c0: 55 43 4b 2f 44 45 41 44 22 29 0a 09 09 09 20 20  UCK/DEAD")....  
89d0: 20 20 20 28 74 65 73 74 2d 73 65 74 2d 73 74 61     (test-set-sta
89e0: 74 75 73 21 20 64 62 20 72 75 6e 2d 69 64 20 74  tus! db run-id t
89f0: 65 73 74 2d 6e 61 6d 65 20 22 49 4e 43 4f 4d 50  est-name "INCOMP
8a00: 4c 45 54 45 22 20 22 53 54 55 43 4b 2f 44 45 41  LETE" "STUCK/DEA
8a10: 44 22 20 69 74 65 6d 64 61 74 20 22 54 65 73 74  D" itemdat "Test
8a20: 20 69 73 20 73 74 75 63 6b 20 6f 72 20 64 65 61   is stuck or dea
8a30: 64 22 20 23 66 29 29 0a 09 09 09 20 20 20 28 64  d" #f))....   (d
8a40: 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 4e 4f  ebug:print 2 "NO
8a50: 54 45 3a 20 22 20 74 65 73 74 2d 6e 61 6d 65 20  TE: " test-name 
8a60: 22 20 69 73 20 61 6c 72 65 61 64 79 20 72 75 6e  " is already run
8a70: 6e 69 6e 67 22 29 29 29 0a 09 09 20 20 20 20 20  ning")))...     
8a80: 20 28 65 6c 73 65 20 20 20 20 20 20 20 28 64 65   (else       (de
8a90: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52  bug:print 0 "ERR
8aa0: 4f 52 3a 20 46 61 69 6c 65 64 20 74 6f 20 6c 61  OR: Failed to la
8ab0: 75 6e 63 68 20 74 65 73 74 20 22 20 6e 65 77 2d  unch test " new-
8ac0: 74 65 73 74 2d 6e 61 6d 65 20 22 2e 20 55 6e 72  test-name ". Unr
8ad0: 65 63 6f 67 6e 69 73 65 64 20 73 74 61 74 65 20  ecognised state 
8ae0: 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74  " (test:get-stat
8af0: 65 20 74 65 73 74 64 61 74 29 29 29 29 29 29 0a  e testdat)))))).
8b00: 09 20 20 20 20 20 20 28 69 66 20 28 6e 6f 74 20  .      (if (not 
8b10: 28 6e 75 6c 6c 3f 20 74 61 6c 29 29 0a 09 09 20  (null? tal))... 
8b20: 20 28 6c 6f 6f 70 20 28 63 61 72 20 74 61 6c 29   (loop (car tal)
8b30: 28 63 64 72 20 74 61 6c 29 29 29 29 29 29 29 29  (cdr tal))))))))
8b40: 29 0a 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 2d  )..(define (run-
8b50: 77 61 69 74 69 6e 67 2d 74 65 73 74 73 20 64 62  waiting-tests db
8b60: 29 0a 20 20 28 6c 65 74 20 28 28 6e 75 6d 74 72  ).  (let ((numtr
8b70: 69 65 73 20 20 20 20 20 20 20 20 20 20 20 30 29  ies           0)
8b80: 0a 09 28 6c 61 73 74 2d 74 72 79 2d 74 69 6d 65  ..(last-try-time
8b90: 20 20 20 20 20 20 28 63 75 72 72 65 6e 74 2d 73        (current-s
8ba0: 65 63 6f 6e 64 73 29 29 0a 09 28 74 69 6d 65 73  econds))..(times
8bb0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 6c                (l
8bc0: 69 73 74 20 31 29 29 29 20 3b 3b 20 6d 69 6e 75  ist 1))) ;; minu
8bd0: 74 65 73 20 74 6f 20 77 61 69 74 20 62 65 66 6f  tes to wait befo
8be0: 72 65 20 74 72 79 69 6e 67 20 61 67 61 69 6e 20  re trying again 
8bf0: 74 6f 20 6b 69 63 6b 20 6f 66 66 20 72 75 6e 73  to kick off runs
8c00: 0a 20 20 20 20 3b 3b 20 42 55 47 20 74 68 69 73  .    ;; BUG this
8c10: 20 68 61 63 6b 20 6f 66 20 62 72 75 74 65 20 66   hack of brute f
8c20: 6f 72 63 65 20 72 65 74 72 79 69 6e 67 20 77 6f  orce retrying wo
8c30: 72 6b 73 20 71 75 69 74 65 20 77 65 6c 6c 20 66  rks quite well f
8c40: 6f 72 20 6d 61 6e 79 20 63 61 73 65 73 20 62 75  or many cases bu
8c50: 74 20 0a 20 20 20 20 3b 3b 20 20 20 20 20 77 68  t .    ;;     wh
8c60: 61 74 20 69 73 20 6e 65 65 64 65 64 20 69 73 20  at is needed is 
8c70: 74 6f 20 63 68 65 63 6b 20 74 68 65 20 64 62 20  to check the db 
8c80: 66 6f 72 20 74 65 73 74 73 20 74 68 61 74 20 68  for tests that h
8c90: 61 76 65 20 66 61 69 6c 65 64 20 6c 65 73 73 20  ave failed less 
8ca0: 74 68 61 6e 0a 20 20 20 20 3b 3b 20 20 20 20 20  than.    ;;     
8cb0: 4e 20 74 69 6d 65 73 20 6f 72 20 6e 65 76 65 72  N times or never
8cc0: 20 62 65 65 6e 20 73 74 61 72 74 65 64 20 61 6e   been started an
8cd0: 64 20 6b 69 63 6b 20 74 68 65 6d 20 6f 66 66 20  d kick them off 
8ce0: 61 67 61 69 6e 0a 20 20 20 20 28 6c 65 74 20 6c  again.    (let l
8cf0: 6f 6f 70 20 28 28 77 61 69 74 69 6e 67 2d 74 65  oop ((waiting-te
8d00: 73 74 2d 6e 61 6d 65 73 20 28 68 61 73 68 2d 74  st-names (hash-t
8d10: 61 62 6c 65 2d 6b 65 79 73 20 2a 77 61 69 74 69  able-keys *waiti
8d20: 6e 67 2d 71 75 65 75 65 2a 29 29 29 0a 20 20 20  ng-queue*))).   
8d30: 20 20 20 28 63 6f 6e 64 0a 20 20 20 20 20 20 20     (cond.       
8d40: 28 28 6e 6f 74 20 28 72 75 6e 73 3a 63 61 6e 2d  ((not (runs:can-
8d50: 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64  run-more-tests d
8d60: 62 29 29 0a 09 28 74 68 72 65 61 64 2d 73 6c 65  b))..(thread-sle
8d70: 65 70 21 20 32 29 0a 09 28 6c 6f 6f 70 20 77 61  ep! 2)..(loop wa
8d80: 69 74 69 6e 67 2d 74 65 73 74 2d 6e 61 6d 65 73  iting-test-names
8d90: 29 29 0a 20 20 20 20 20 20 20 28 28 6e 75 6c 6c  )).       ((null
8da0: 3f 20 77 61 69 74 69 6e 67 2d 74 65 73 74 2d 6e  ? waiting-test-n
8db0: 61 6d 65 73 29 0a 09 28 64 65 62 75 67 3a 70 72  ames)..(debug:pr
8dc0: 69 6e 74 20 31 20 22 41 6c 6c 20 74 65 73 74 73  int 1 "All tests
8dd0: 20 6c 61 75 6e 63 68 65 64 22 29 29 0a 20 20 20   launched")).   
8de0: 20 20 20 20 28 65 6c 73 65 0a 09 28 73 65 74 21      (else..(set!
8df0: 20 6e 75 6d 74 72 69 65 73 20 28 2b 20 6e 75 6d   numtries (+ num
8e00: 74 72 69 65 73 20 31 29 29 0a 09 28 66 6f 72 2d  tries 1))..(for-
8e10: 65 61 63 68 20 28 6c 61 6d 62 64 61 20 28 74 65  each (lambda (te
8e20: 73 74 6e 61 6d 65 29 0a 09 09 20 20 20 20 28 69  stname)...    (i
8e30: 66 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d  f (runs:can-run-
8e40: 6d 6f 72 65 2d 74 65 73 74 73 20 64 62 29 0a 09  more-tests db)..
8e50: 09 09 28 6c 65 74 2a 20 28 28 74 65 73 74 64 61  ..(let* ((testda
8e60: 74 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65  t (hash-table-re
8e70: 66 20 2a 77 61 69 74 69 6e 67 2d 71 75 65 75 65  f *waiting-queue
8e80: 2a 20 74 65 73 74 6e 61 6d 65 29 29 0a 09 09 09  * testname))....
8e90: 20 20 20 20 20 20 20 28 70 72 65 72 65 71 73 20         (prereqs 
8ea0: 28 28 63 61 72 20 74 65 73 74 64 61 74 29 29 29  ((car testdat)))
8eb0: 0a 09 09 09 20 20 20 20 20 20 20 28 6c 64 62 20  ....       (ldb 
8ec0: 20 20 20 20 28 69 66 20 64 62 20 64 62 20 28 6f      (if db db (o
8ed0: 70 65 6e 2d 64 62 29 29 29 29 0a 09 09 09 20 20  pen-db))))....  
8ee0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22  (debug:print 2 "
8ef0: 70 72 65 72 65 71 73 20 72 65 6d 61 69 6e 69 6e  prereqs remainin
8f00: 67 3a 20 22 20 70 72 65 72 65 71 73 29 0a 09 09  g: " prereqs)...
8f10: 09 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 70 72  .  (if (null? pr
8f20: 65 72 65 71 73 29 0a 09 09 09 20 20 20 20 20 20  ereqs)....      
8f30: 28 62 65 67 69 6e 0a 09 09 09 09 28 64 65 62 75  (begin.....(debu
8f40: 67 3a 70 72 69 6e 74 20 32 20 22 50 72 65 72 65  g:print 2 "Prere
8f50: 71 75 69 73 69 74 65 73 20 6d 65 74 2c 20 6c 61  quisites met, la
8f60: 75 6e 63 68 69 6e 67 20 22 20 74 65 73 74 6e 61  unching " testna
8f70: 6d 65 29 0a 09 09 09 09 28 28 63 61 64 72 20 74  me).....((cadr t
8f80: 65 73 74 64 61 74 29 29 0a 09 09 09 09 28 68 61  estdat)).....(ha
8f90: 73 68 2d 74 61 62 6c 65 2d 64 65 6c 65 74 65 21  sh-table-delete!
8fa0: 20 2a 77 61 69 74 69 6e 67 2d 71 75 65 75 65 2a   *waiting-queue*
8fb0: 20 74 65 73 74 6e 61 6d 65 29 29 29 0a 09 09 09   testname)))....
8fc0: 20 20 28 69 66 20 28 6e 6f 74 20 64 62 29 0a 09    (if (not db)..
8fd0: 09 09 20 20 20 20 20 20 28 73 71 6c 69 74 65 33  ..      (sqlite3
8fe0: 3a 66 69 6e 61 6c 69 7a 65 21 20 6c 64 62 29 29  :finalize! ldb))
8ff0: 29 29 29 0a 09 09 20 20 77 61 69 74 69 6e 67 2d  )))...  waiting-
9000: 74 65 73 74 2d 6e 61 6d 65 73 29 0a 09 3b 3b 20  test-names)..;; 
9010: 28 73 6c 65 65 70 20 31 30 29 20 3b 3b 20 6e 6f  (sleep 10) ;; no
9020: 20 70 6f 69 6e 74 20 69 6e 20 72 75 73 68 69 6e   point in rushin
9030: 67 20 74 68 69 6e 67 73 20 61 74 20 74 68 69 73  g things at this
9040: 20 73 74 61 67 65 3f 0a 09 28 6c 6f 6f 70 20 28   stage?..(loop (
9050: 68 61 73 68 2d 74 61 62 6c 65 2d 6b 65 79 73 20  hash-table-keys 
9060: 2a 77 61 69 74 69 6e 67 2d 71 75 65 75 65 2a 29  *waiting-queue*)
9070: 29 29 29 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d  ))))))..;;======
9080: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9090: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
90a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
90b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
90c0: 0a 3b 3b 20 4e 65 77 20 6d 65 74 68 6f 64 6f 6c  .;; New methodol
90d0: 6f 67 79 2e 20 54 68 65 73 65 20 72 6f 75 74 69  ogy. These routi
90e0: 6e 65 73 20 77 69 6c 6c 20 72 65 70 6c 61 63 65  nes will replace
90f0: 20 74 68 65 20 61 62 6f 76 65 20 69 6e 20 74 69   the above in ti
9100: 6d 65 2e 20 46 6f 72 0a 3b 3b 20 6e 6f 77 20 74  me. For.;; now t
9110: 68 65 20 63 6f 64 65 20 69 73 20 64 75 70 6c 69  he code is dupli
9120: 63 61 74 65 64 2e 20 54 68 69 73 20 73 74 75 66  cated. This stuf
9130: 66 20 69 73 20 69 6e 69 74 69 61 6c 6c 79 20 75  f is initially u
9140: 73 65 64 20 69 6e 20 74 68 65 20 6d 6f 6e 69 74  sed in the monit
9150: 6f 72 0a 3b 3b 20 62 61 73 65 64 20 63 6f 64 65  or.;; based code
9160: 2e 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ..;;============
9170: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9180: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9190: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
91a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 72  ==========..;; r
91b0: 65 67 69 73 74 65 72 20 61 20 74 65 73 74 20 72  egister a test r
91c0: 75 6e 20 77 69 74 68 20 74 68 65 20 64 62 0a 28  un with the db.(
91d0: 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 72 65 67  define (runs:reg
91e0: 69 73 74 65 72 2d 72 75 6e 20 64 62 20 6b 65 79  ister-run db key
91f0: 73 20 6b 65 79 76 61 6c 6c 73 74 20 72 75 6e 6e  s keyvallst runn
9200: 61 6d 65 20 73 74 61 74 65 20 73 74 61 74 75 73  ame state status
9210: 20 75 73 65 72 29 0a 20 20 28 64 65 62 75 67 3a   user).  (debug:
9220: 70 72 69 6e 74 20 33 20 22 72 75 6e 73 3a 72 65  print 3 "runs:re
9230: 67 69 73 74 65 72 2d 72 75 6e 2c 20 6b 65 79 73  gister-run, keys
9240: 3a 20 22 20 6b 65 79 73 20 22 20 6b 65 79 76 61  : " keys " keyva
9250: 6c 6c 73 74 3a 20 22 20 6b 65 79 76 61 6c 6c 73  llst: " keyvalls
9260: 74 20 22 20 72 75 6e 6e 61 6d 65 3a 20 22 20 72  t " runname: " r
9270: 75 6e 6e 61 6d 65 20 22 20 73 74 61 74 65 3a 20  unname " state: 
9280: 22 20 73 74 61 74 65 20 22 20 73 74 61 74 75 73  " state " status
9290: 3a 20 22 20 73 74 61 74 75 73 20 22 20 75 73 65  : " status " use
92a0: 72 3a 20 22 20 75 73 65 72 29 0a 20 20 28 6c 65  r: " user).  (le
92b0: 74 2a 20 28 28 6b 65 79 73 74 72 20 20 20 20 28  t* ((keystr    (
92c0: 6b 65 79 73 2d 3e 6b 65 79 73 74 72 20 6b 65 79  keys->keystr key
92d0: 73 29 29 0a 09 20 28 63 6f 6d 6d 61 20 20 20 20  s)).. (comma    
92e0: 20 28 69 66 20 28 3e 20 28 6c 65 6e 67 74 68 20   (if (> (length 
92f0: 6b 65 79 73 29 20 30 29 20 22 2c 22 20 22 22 29  keys) 0) "," "")
9300: 29 0a 09 20 28 61 6e 64 73 74 72 20 20 20 20 28  ).. (andstr    (
9310: 69 66 20 28 3e 20 28 6c 65 6e 67 74 68 20 6b 65  if (> (length ke
9320: 79 73 29 20 30 29 20 22 20 41 4e 44 20 22 20 22  ys) 0) " AND " "
9330: 22 29 29 0a 09 20 28 76 61 6c 73 6c 6f 74 73 20  ")).. (valslots 
9340: 20 28 6b 65 79 73 2d 3e 76 61 6c 73 6c 6f 74 73   (keys->valslots
9350: 20 6b 65 79 73 29 29 20 3b 3b 20 3f 2c 3f 2c 3f   keys)) ;; ?,?,?
9360: 20 2e 2e 2e 0a 09 20 28 6b 65 79 76 61 6c 73 20   ..... (keyvals 
9370: 20 20 28 6d 61 70 20 63 61 64 72 20 6b 65 79 76    (map cadr keyv
9380: 61 6c 6c 73 74 29 29 0a 09 20 28 61 6c 6c 76 61  allst)).. (allva
9390: 6c 73 20 20 20 28 61 70 70 65 6e 64 20 28 6c 69  ls   (append (li
93a0: 73 74 20 72 75 6e 6e 61 6d 65 20 73 74 61 74 65  st runname state
93b0: 20 73 74 61 74 75 73 20 75 73 65 72 29 20 6b 65   status user) ke
93c0: 79 76 61 6c 73 29 29 0a 09 20 28 71 72 79 76 61  yvals)).. (qryva
93d0: 6c 73 20 20 20 28 61 70 70 65 6e 64 20 28 6c 69  ls   (append (li
93e0: 73 74 20 72 75 6e 6e 61 6d 65 29 20 6b 65 79 76  st runname) keyv
93f0: 61 6c 73 29 29 0a 09 20 28 6b 65 79 3d 3f 73 74  als)).. (key=?st
9400: 72 20 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72  r  (string-inter
9410: 73 70 65 72 73 65 20 28 6d 61 70 20 28 6c 61 6d  sperse (map (lam
9420: 62 64 61 20 28 6b 29 28 63 6f 6e 63 20 28 6b 65  bda (k)(conc (ke
9430: 79 3a 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20  y:get-fieldname 
9440: 6b 29 20 22 3d 3f 22 29 29 20 6b 65 79 73 29 20  k) "=?")) keys) 
9450: 22 20 41 4e 44 20 22 29 29 29 0a 20 20 20 20 28  " AND "))).    (
9460: 64 65 62 75 67 3a 70 72 69 6e 74 20 33 20 22 6b  debug:print 3 "k
9470: 65 79 73 3a 20 22 20 6b 65 79 73 20 22 20 61 6c  eys: " keys " al
9480: 6c 76 61 6c 73 3a 20 22 20 61 6c 6c 76 61 6c 73  lvals: " allvals
9490: 20 22 20 6b 65 79 76 61 6c 73 3a 20 22 20 6b 65   " keyvals: " ke
94a0: 79 76 61 6c 73 29 0a 20 20 20 20 28 64 65 62 75  yvals).    (debu
94b0: 67 3a 70 72 69 6e 74 20 32 20 22 4e 4f 54 45 3a  g:print 2 "NOTE:
94c0: 20 75 73 69 6e 67 20 74 61 72 67 65 74 20 22 20   using target " 
94d0: 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65  (string-interspe
94e0: 72 73 65 20 6b 65 79 76 61 6c 73 20 22 2f 22 29  rse keyvals "/")
94f0: 20 22 20 66 6f 72 20 74 68 69 73 20 72 75 6e 22   " for this run"
9500: 29 0a 20 20 20 20 28 69 66 20 28 61 6e 64 20 72  ).    (if (and r
9510: 75 6e 6e 61 6d 65 20 28 6e 75 6c 6c 3f 20 28 66  unname (null? (f
9520: 69 6c 74 65 72 20 28 6c 61 6d 62 64 61 20 28 78  ilter (lambda (x
9530: 29 28 6e 6f 74 20 78 29 29 20 6b 65 79 76 61 6c  )(not x)) keyval
9540: 73 29 29 29 20 3b 3b 20 74 68 65 72 65 20 6d 75  s))) ;; there mu
9550: 73 74 20 62 65 20 61 20 62 65 74 74 65 72 20 77  st be a better w
9560: 61 79 20 74 6f 20 22 61 70 70 6c 79 20 61 6e 64  ay to "apply and
9570: 22 0a 09 28 6c 65 74 20 28 28 72 65 73 20 23 66  "..(let ((res #f
9580: 29 29 0a 09 20 20 28 61 70 70 6c 79 20 73 71 6c  ))..  (apply sql
9590: 69 74 65 33 3a 65 78 65 63 75 74 65 20 64 62 20  ite3:execute db 
95a0: 28 63 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f 52  (conc "INSERT OR
95b0: 20 49 47 4e 4f 52 45 20 49 4e 54 4f 20 72 75 6e   IGNORE INTO run
95c0: 73 20 28 72 75 6e 6e 61 6d 65 2c 73 74 61 74 65  s (runname,state
95d0: 2c 73 74 61 74 75 73 2c 6f 77 6e 65 72 2c 65 76  ,status,owner,ev
95e0: 65 6e 74 5f 74 69 6d 65 22 20 63 6f 6d 6d 61 20  ent_time" comma 
95f0: 6b 65 79 73 74 72 20 22 29 20 56 41 4c 55 45 53  keystr ") VALUES
9600: 20 28 3f 2c 3f 2c 3f 2c 3f 2c 73 74 72 66 74 69   (?,?,?,?,strfti
9610: 6d 65 28 27 25 73 27 2c 27 6e 6f 77 27 29 22 20  me('%s','now')" 
9620: 63 6f 6d 6d 61 20 76 61 6c 73 6c 6f 74 73 20 22  comma valslots "
9630: 29 3b 22 29 0a 09 09 20 61 6c 6c 76 61 6c 73 29  );")... allvals)
9640: 0a 09 20 20 28 61 70 70 6c 79 20 73 71 6c 69 74  ..  (apply sqlit
9650: 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77 20  e3:for-each-row 
9660: 0a 09 20 20 20 28 6c 61 6d 62 64 61 20 28 69 64  ..   (lambda (id
9670: 29 0a 09 20 20 20 20 20 28 73 65 74 21 20 72 65  )..     (set! re
9680: 73 20 69 64 29 29 0a 09 20 20 20 64 62 0a 09 20  s id))..   db.. 
9690: 20 20 28 6c 65 74 20 28 28 71 72 79 20 28 63 6f    (let ((qry (co
96a0: 6e 63 20 22 53 45 4c 45 43 54 20 69 64 20 46 52  nc "SELECT id FR
96b0: 4f 4d 20 72 75 6e 73 20 57 48 45 52 45 20 28 72  OM runs WHERE (r
96c0: 75 6e 6e 61 6d 65 3d 3f 20 22 20 61 6e 64 73 74  unname=? " andst
96d0: 72 20 6b 65 79 3d 3f 73 74 72 20 22 29 3b 22 29  r key=?str ");")
96e0: 29 29 0a 09 20 20 20 20 20 3b 28 64 65 62 75 67  ))..     ;(debug
96f0: 3a 70 72 69 6e 74 20 34 20 22 71 72 79 3a 20 22  :print 4 "qry: "
9700: 20 71 72 79 29 20 0a 09 20 20 20 20 20 71 72 79   qry) ..     qry
9710: 29 0a 09 20 20 20 71 72 79 76 61 6c 73 29 0a 09  )..   qryvals)..
9720: 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75    (sqlite3:execu
9730: 74 65 20 64 62 20 22 55 50 44 41 54 45 20 72 75  te db "UPDATE ru
9740: 6e 73 20 53 45 54 20 73 74 61 74 65 3d 3f 2c 73  ns SET state=?,s
9750: 74 61 74 75 73 3d 3f 20 57 48 45 52 45 20 69 64  tatus=? WHERE id
9760: 3d 3f 3b 22 20 73 74 61 74 65 20 73 74 61 74 75  =?;" state statu
9770: 73 20 72 65 73 29 0a 09 20 20 72 65 73 29 20 0a  s res)..  res) .
9780: 09 28 62 65 67 69 6e 0a 09 20 20 28 64 65 62 75  .(begin..  (debu
9790: 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52  g:print 0 "ERROR
97a0: 3a 20 43 61 6c 6c 65 64 20 77 69 74 68 6f 75 74  : Called without
97b0: 20 61 6c 6c 20 6e 65 63 65 73 73 61 72 79 20 6b   all necessary k
97c0: 65 79 73 22 29 0a 09 20 20 23 66 29 29 29 29 0a  eys")..  #f)))).
97d0: 0a 3b 3b 20 54 68 69 73 20 69 73 20 61 20 64 75  .;; This is a du
97e0: 70 6c 69 63 61 74 65 20 6f 66 20 72 75 6e 2d 74  plicate of run-t
97f0: 65 73 74 73 20 28 77 68 69 63 68 20 68 61 73 20  ests (which has 
9800: 62 65 65 6e 20 64 65 70 72 65 63 61 74 65 64 29  been deprecated)
9810: 2e 20 55 73 65 20 74 68 69 73 20 6f 6e 65 20 69  . Use this one i
9820: 6e 73 74 65 61 64 20 6f 66 20 72 75 6e 20 74 65  nstead of run te
9830: 73 74 73 2e 0a 3b 3b 20 6b 65 79 76 61 6c 73 0a  sts..;; keyvals.
9840: 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 72 75  (define (runs:ru
9850: 6e 2d 74 65 73 74 73 20 64 62 20 74 61 72 67 65  n-tests db targe
9860: 74 20 72 75 6e 6e 61 6d 65 20 74 65 73 74 2d 70  t runname test-p
9870: 61 74 74 73 20 69 74 65 6d 2d 70 61 74 74 73 20  atts item-patts 
9880: 75 73 65 72 20 66 6c 61 67 73 29 0a 20 20 28 6c  user flags).  (l
9890: 65 74 2a 20 28 28 6b 65 79 73 20 20 20 20 20 20  et* ((keys      
98a0: 20 20 28 64 62 2d 67 65 74 2d 6b 65 79 73 20 64    (db-get-keys d
98b0: 62 29 29 0a 09 20 28 6b 65 79 76 61 6c 6c 73 74  b)).. (keyvallst
98c0: 20 20 20 28 6b 65 79 73 3a 74 61 72 67 65 74 2d     (keys:target-
98d0: 3e 6b 65 79 76 61 6c 20 6b 65 79 73 20 74 61 72  >keyval keys tar
98e0: 67 65 74 29 29 0a 09 20 28 72 75 6e 2d 69 64 20  get)).. (run-id 
98f0: 20 20 20 20 20 28 72 75 6e 73 3a 72 65 67 69 73       (runs:regis
9900: 74 65 72 2d 72 75 6e 20 64 62 20 6b 65 79 73 20  ter-run db keys 
9910: 6b 65 79 76 61 6c 6c 73 74 20 72 75 6e 6e 61 6d  keyvallst runnam
9920: 65 20 22 6e 65 77 22 20 22 6e 2f 61 22 20 75 73  e "new" "n/a" us
9930: 65 72 29 29 20 20 3b 3b 20 20 74 65 73 74 2d 6e  er))  ;;  test-n
9940: 61 6d 65 29 29 29 0a 09 20 28 64 65 66 65 72 72  ame))).. (deferr
9950: 65 64 20 20 20 20 27 28 29 29 20 3b 3b 20 64 65  ed    '()) ;; de
9960: 6c 61 79 20 72 75 6e 6e 69 6e 67 20 74 68 65 73  lay running thes
9970: 65 20 73 69 6e 63 65 20 74 68 65 79 20 68 61 76  e since they hav
9980: 65 20 61 20 77 61 69 74 6f 6e 20 63 6c 61 75 73  e a waiton claus
9990: 65 0a 09 20 28 6b 65 65 70 67 6f 69 6e 67 20 20  e.. (keepgoing  
99a0: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
99b0: 2f 64 65 66 61 75 6c 74 20 66 6c 61 67 73 20 22  /default flags "
99c0: 2d 6b 65 65 70 67 6f 69 6e 67 22 20 23 66 29 29  -keepgoing" #f))
99d0: 0a 09 20 28 74 65 73 74 2d 6e 61 6d 65 73 20 20  .. (test-names  
99e0: 27 28 29 29 0a 09 20 28 72 75 6e 63 6f 6e 66 69  '()).. (runconfi
99f0: 67 66 20 20 20 28 63 6f 6e 63 20 20 2a 74 6f 70  gf   (conc  *top
9a00: 70 61 74 68 2a 20 22 2f 72 75 6e 63 6f 6e 66 69  path* "/runconfi
9a10: 67 73 2e 63 6f 6e 66 69 67 22 29 29 0a 09 20 28  gs.config")).. (
9a20: 72 65 71 75 69 72 65 64 2d 74 65 73 74 73 20 27  required-tests '
9a30: 28 29 29 29 0a 0a 20 20 20 20 28 73 65 74 2d 6d  ()))..    (set-m
9a40: 65 67 61 74 65 73 74 2d 65 6e 76 2d 76 61 72 73  egatest-env-vars
9a50: 20 64 62 20 72 75 6e 2d 69 64 29 20 3b 3b 20 74   db run-id) ;; t
9a60: 68 65 73 65 20 6d 61 79 20 62 65 20 6e 65 65 64  hese may be need
9a70: 65 64 20 62 79 20 74 68 65 20 6c 61 75 6e 63 68  ed by the launch
9a80: 69 6e 67 20 70 72 6f 63 65 73 73 0a 0a 20 20 20  ing process..   
9a90: 20 28 69 66 20 28 66 69 6c 65 2d 65 78 69 73 74   (if (file-exist
9aa0: 73 3f 20 72 75 6e 63 6f 6e 66 69 67 66 29 0a 09  s? runconfigf)..
9ab0: 28 73 65 74 75 70 2d 65 6e 76 2d 64 65 66 61 75  (setup-env-defau
9ac0: 6c 74 73 20 64 62 20 72 75 6e 63 6f 6e 66 69 67  lts db runconfig
9ad0: 66 20 72 75 6e 2d 69 64 20 2a 61 6c 72 65 61 64  f run-id *alread
9ae0: 79 2d 73 65 65 6e 2d 72 75 6e 63 6f 6e 66 69 67  y-seen-runconfig
9af0: 2d 69 6e 66 6f 2a 20 22 70 72 65 2d 6c 61 75 6e  -info* "pre-laun
9b00: 63 68 2d 65 6e 76 2d 76 61 72 73 22 29 0a 09 28  ch-env-vars")..(
9b10: 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 57  debug:print 0 "W
9b20: 41 52 4e 49 4e 47 3a 20 59 6f 75 20 64 6f 20 6e  ARNING: You do n
9b30: 6f 74 20 68 61 76 65 20 61 20 72 75 6e 20 63 6f  ot have a run co
9b40: 6e 66 69 67 20 66 69 6c 65 3a 20 22 20 72 75 6e  nfig file: " run
9b50: 63 6f 6e 66 69 67 66 29 29 0a 20 20 20 20 0a 20  configf)).    . 
9b60: 20 20 20 3b 3b 20 6c 6f 6f 6b 20 75 70 20 61 6c     ;; look up al
9b70: 6c 20 74 65 73 74 73 20 6d 61 74 63 68 69 6e 67  l tests matching
9b80: 20 74 68 65 20 63 6f 6d 6d 61 20 73 65 70 61 72   the comma separ
9b90: 61 74 65 64 20 6c 69 73 74 20 6f 66 20 67 6c 6f  ated list of glo
9ba0: 62 73 20 69 6e 0a 20 20 20 20 3b 3b 20 74 65 73  bs in.    ;; tes
9bb0: 74 2d 70 61 74 74 73 20 28 75 73 69 6e 67 20 25  t-patts (using %
9bc0: 20 61 73 20 77 69 6c 64 63 61 72 64 29 0a 20 20   as wildcard).  
9bd0: 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 20 20    (for-each .   
9be0: 20 20 28 6c 61 6d 62 64 61 20 28 70 61 74 74 29    (lambda (patt)
9bf0: 0a 20 20 20 20 20 20 20 28 6c 65 74 20 28 28 74  .       (let ((t
9c00: 65 73 74 73 20 28 67 6c 6f 62 20 28 63 6f 6e 63  ests (glob (conc
9c10: 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f 74 65 73   *toppath* "/tes
9c20: 74 73 2f 22 20 28 73 74 72 69 6e 67 2d 74 72 61  ts/" (string-tra
9c30: 6e 73 6c 61 74 65 20 70 61 74 74 20 22 25 22 20  nslate patt "%" 
9c40: 22 2a 22 29 29 29 29 29 0a 09 20 28 73 65 74 21  "*"))))).. (set!
9c50: 20 74 65 73 74 73 20 28 66 69 6c 74 65 72 20 28   tests (filter (
9c60: 6c 61 6d 62 64 61 20 28 74 65 73 74 29 28 66 69  lambda (test)(fi
9c70: 6c 65 2d 65 78 69 73 74 73 3f 20 28 63 6f 6e 63  le-exists? (conc
9c80: 20 74 65 73 74 20 22 2f 74 65 73 74 63 6f 6e 66   test "/testconf
9c90: 69 67 22 29 29 29 20 74 65 73 74 73 29 29 0a 09  ig"))) tests))..
9ca0: 20 28 73 65 74 21 20 74 65 73 74 2d 6e 61 6d 65   (set! test-name
9cb0: 73 20 28 61 70 70 65 6e 64 20 74 65 73 74 2d 6e  s (append test-n
9cc0: 61 6d 65 73 20 0a 09 09 09 09 20 20 28 6d 61 70  ames .....  (map
9cd0: 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74 70 29   (lambda (testp)
9ce0: 0a 09 09 09 09 09 20 28 6c 61 73 74 20 28 73 74  ...... (last (st
9cf0: 72 69 6e 67 2d 73 70 6c 69 74 20 74 65 73 74 70  ring-split testp
9d00: 20 22 2f 22 29 29 29 0a 09 09 09 09 20 20 20 20   "/"))).....    
9d10: 20 20 20 74 65 73 74 73 29 29 29 29 29 0a 20 20     tests))))).  
9d20: 20 20 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74     (string-split
9d30: 20 74 65 73 74 2d 70 61 74 74 73 20 22 2c 22 29   test-patts ",")
9d40: 29 0a 0a 20 20 20 20 20 3b 3b 20 6e 6f 77 20 72  )..     ;; now r
9d50: 65 6d 6f 76 65 20 64 75 70 6c 69 63 61 74 65 73  emove duplicates
9d60: 0a 20 20 20 20 28 73 65 74 21 20 74 65 73 74 2d  .    (set! test-
9d70: 6e 61 6d 65 73 20 28 64 65 6c 65 74 65 2d 64 75  names (delete-du
9d80: 70 6c 69 63 61 74 65 73 20 74 65 73 74 2d 6e 61  plicates test-na
9d90: 6d 65 73 29 29 0a 0a 20 20 20 20 28 64 65 62 75  mes))..    (debu
9da0: 67 3a 70 72 69 6e 74 20 30 20 22 49 4e 46 4f 3a  g:print 0 "INFO:
9db0: 20 74 65 73 74 20 6e 61 6d 65 73 20 22 20 74 65   test names " te
9dc0: 73 74 2d 6e 61 6d 65 73 29 0a 0a 20 20 20 20 3b  st-names)..    ;
9dd0: 3b 20 6e 6f 77 20 61 64 64 20 6e 6f 6e 2d 64 69  ; now add non-di
9de0: 72 65 63 74 6c 79 20 72 65 66 65 72 65 6e 63 65  rectly reference
9df0: 64 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20 28  d dependencies (
9e00: 69 2e 65 2e 20 77 61 69 74 6f 6e 29 0a 20 20 20  i.e. waiton).   
9e10: 20 3b 3b 20 63 6f 75 6c 64 20 63 61 63 68 65 20   ;; could cache 
9e20: 61 6c 6c 20 74 68 65 73 65 20 73 69 6e 63 65 20  all these since 
9e30: 74 68 65 79 20 6e 65 65 64 20 74 6f 20 62 65 20  they need to be 
9e40: 72 65 61 64 20 61 67 61 69 6e 20 2e 2e 2e 0a 20  read again .... 
9e50: 20 20 20 3b 3b 20 46 49 58 4d 45 20 53 4f 4d 45     ;; FIXME SOME
9e60: 44 41 59 0a 20 20 20 20 28 69 66 20 28 6e 6f 74  DAY.    (if (not
9e70: 20 28 6e 75 6c 6c 3f 20 74 65 73 74 2d 6e 61 6d   (null? test-nam
9e80: 65 73 29 29 0a 09 28 6c 65 74 20 6c 6f 6f 70 20  es))..(let loop 
9e90: 28 28 68 65 64 20 28 63 61 72 20 74 65 73 74 2d  ((hed (car test-
9ea0: 6e 61 6d 65 73 29 29 0a 09 09 20 20 20 28 74 61  names))...   (ta
9eb0: 6c 20 28 63 64 72 20 74 65 73 74 2d 6e 61 6d 65  l (cdr test-name
9ec0: 73 29 29 29 0a 09 20 20 28 6c 65 74 2a 20 28 28  s)))..  (let* ((
9ed0: 63 6f 6e 66 69 67 20 20 28 74 65 73 74 3a 67 65  config  (test:ge
9ee0: 74 2d 74 65 73 74 63 6f 6e 66 69 67 20 68 65 64  t-testconfig hed
9ef0: 20 23 66 29 29 0a 09 09 20 28 77 61 69 74 6f 6e   #f))... (waiton
9f00: 73 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20  s (string-split 
9f10: 28 6c 65 74 20 28 28 77 20 28 63 6f 6e 66 69 67  (let ((w (config
9f20: 2d 6c 6f 6f 6b 75 70 20 63 6f 6e 66 69 67 20 22  -lookup config "
9f30: 72 65 71 75 69 72 65 6d 65 6e 74 73 22 20 22 77  requirements" "w
9f40: 61 69 74 6f 6e 22 29 29 29 0a 09 09 09 09 09 20  aiton")))...... 
9f50: 20 28 69 66 20 77 20 77 20 22 22 29 29 29 29 29   (if w w "")))))
9f60: 0a 09 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20  ..    (for-each 
9f70: 0a 09 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28  ..     (lambda (
9f80: 77 61 69 74 6f 6e 29 0a 09 20 20 20 20 20 20 20  waiton)..       
9f90: 28 69 66 20 28 61 6e 64 20 77 61 69 74 6f 6e 20  (if (and waiton 
9fa0: 28 6e 6f 74 20 28 6d 65 6d 62 65 72 20 77 61 69  (not (member wai
9fb0: 74 6f 6e 20 74 65 73 74 2d 6e 61 6d 65 73 29 29  ton test-names))
9fc0: 29 0a 09 09 20 20 20 28 62 65 67 69 6e 0a 09 09  )...   (begin...
9fd0: 20 20 20 20 20 28 73 65 74 21 20 72 65 71 75 69       (set! requi
9fe0: 72 65 64 2d 74 65 73 74 73 20 28 63 6f 6e 73 20  red-tests (cons 
9ff0: 77 61 69 74 6f 6e 20 72 65 71 75 69 72 65 64 2d  waiton required-
a000: 74 65 73 74 73 29 29 0a 09 09 20 20 20 20 20 28  tests))...     (
a010: 73 65 74 21 20 74 65 73 74 2d 6e 61 6d 65 73 20  set! test-names 
a020: 28 61 70 70 65 6e 64 20 74 65 73 74 2d 6e 61 6d  (append test-nam
a030: 65 73 20 28 6c 69 73 74 20 77 61 69 74 6f 6e 29  es (list waiton)
a040: 29 29 29 29 29 0a 09 20 20 20 20 20 77 61 69 74  )))))..     wait
a050: 6f 6e 73 29 0a 09 20 20 20 20 28 6c 65 74 20 28  ons)..    (let (
a060: 28 72 65 6d 74 65 73 74 73 20 28 64 65 6c 65 74  (remtests (delet
a070: 65 2d 64 75 70 6c 69 63 61 74 65 73 20 28 61 70  e-duplicates (ap
a080: 70 65 6e 64 20 77 61 69 74 6f 6e 73 20 74 61 6c  pend waitons tal
a090: 29 29 29 29 0a 09 20 20 20 20 20 20 28 69 66 20  ))))..      (if 
a0a0: 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 72 65 6d 74  (not (null? remt
a0b0: 65 73 74 73 29 29 0a 09 09 20 20 28 6c 6f 6f 70  ests))...  (loop
a0c0: 20 28 63 61 72 20 72 65 6d 74 65 73 74 73 29 28   (car remtests)(
a0d0: 63 64 72 20 72 65 6d 74 65 73 74 73 29 29 29 29  cdr remtests))))
a0e0: 29 29 29 0a 0a 20 20 20 20 28 69 66 20 28 6e 6f  )))..    (if (no
a0f0: 74 20 28 6e 75 6c 6c 3f 20 72 65 71 75 69 72 65  t (null? require
a100: 64 2d 74 65 73 74 73 29 29 0a 09 28 64 65 62 75  d-tests))..(debu
a110: 67 3a 70 72 69 6e 74 20 31 20 22 49 4e 46 4f 3a  g:print 1 "INFO:
a120: 20 41 64 64 69 6e 67 20 22 20 72 65 71 75 69 72   Adding " requir
a130: 65 64 2d 74 65 73 74 73 20 22 20 74 6f 20 74 68  ed-tests " to th
a140: 65 20 72 75 6e 20 71 75 65 75 65 22 29 29 0a 0a  e run queue"))..
a150: 20 20 20 20 3b 3b 20 6f 6e 20 74 68 65 20 66 69      ;; on the fi
a160: 72 73 74 20 70 61 73 73 20 6f 72 20 63 61 6c 6c  rst pass or call
a170: 20 74 6f 20 72 75 6e 2d 74 65 73 74 73 20 73 65   to run-tests se
a180: 74 20 46 41 49 4c 53 20 74 6f 20 4e 4f 54 5f 53  t FAILS to NOT_S
a190: 54 41 52 54 45 44 20 69 66 0a 20 20 20 20 3b 3b  TARTED if.    ;;
a1a0: 20 2d 6b 65 65 70 67 6f 69 6e 67 20 69 73 20 73   -keepgoing is s
a1b0: 70 65 63 69 66 69 65 64 0a 20 20 20 20 28 69 66  pecified.    (if
a1c0: 20 28 61 6e 64 20 28 65 71 3f 20 2a 70 61 73 73   (and (eq? *pass
a1d0: 6e 75 6d 2a 20 30 29 0a 09 20 20 20 20 20 6b 65  num* 0)..     ke
a1e0: 65 70 67 6f 69 6e 67 29 0a 09 28 62 65 67 69 6e  epgoing)..(begin
a1f0: 0a 09 20 20 3b 3b 20 68 61 76 65 20 74 6f 20 64  ..  ;; have to d
a200: 65 6c 65 74 65 20 74 65 73 74 20 72 65 63 6f 72  elete test recor
a210: 64 73 20 77 68 65 72 65 20 4e 4f 54 5f 53 54 41  ds where NOT_STA
a220: 52 54 45 44 20 73 69 6e 63 65 20 74 68 65 79 20  RTED since they 
a230: 63 61 6e 20 63 61 75 73 65 20 2d 6b 65 65 70 67  can cause -keepg
a240: 6f 69 6e 67 20 74 6f 20 0a 09 20 20 3b 3b 20 67  oing to ..  ;; g
a250: 65 74 20 73 74 75 63 6b 20 64 75 65 20 74 6f 20  et stuck due to 
a260: 62 65 63 6f 6d 69 6e 67 20 69 6e 61 63 63 65 73  becoming inacces
a270: 73 69 62 6c 65 20 66 72 6f 6d 20 61 20 66 61 69  sible from a fai
a280: 6c 65 64 20 74 65 73 74 2e 20 49 2e 65 2e 20 69  led test. I.e. i
a290: 66 20 74 65 73 74 20 42 20 64 65 70 65 6e 64 73  f test B depends
a2a0: 20 0a 09 20 20 3b 3b 20 6f 6e 20 74 65 73 74 20   ..  ;; on test 
a2b0: 41 20 62 75 74 20 74 65 73 74 20 42 20 72 65 61  A but test B rea
a2c0: 63 68 65 64 20 74 68 65 20 70 6f 69 6e 74 20 6f  ched the point o
a2d0: 6e 20 62 65 69 6e 67 20 72 65 67 69 73 74 65 72  n being register
a2e0: 65 64 20 61 73 20 4e 4f 54 5f 53 54 41 52 54 45  ed as NOT_STARTE
a2f0: 44 20 61 6e 64 20 74 65 73 74 0a 09 20 20 3b 3b  D and test..  ;;
a300: 20 41 20 66 61 69 6c 65 64 20 66 6f 72 20 73 6f   A failed for so
a310: 6d 65 20 72 65 61 73 6f 6e 20 74 68 65 6e 20 6f  me reason then o
a320: 6e 20 72 65 2d 72 75 6e 20 75 73 69 6e 67 20 2d  n re-run using -
a330: 6b 65 65 70 67 6f 69 6e 67 20 74 68 65 20 72 75  keepgoing the ru
a340: 6e 20 63 61 6e 20 6e 65 76 65 72 20 63 6f 6d 70  n can never comp
a350: 6c 65 74 65 2e 0a 09 20 20 28 64 62 3a 64 65 6c  lete...  (db:del
a360: 65 74 65 2d 74 65 73 74 73 2d 69 6e 2d 73 74 61  ete-tests-in-sta
a370: 74 65 20 64 62 20 72 75 6e 2d 69 64 20 22 4e 4f  te db run-id "NO
a380: 54 5f 53 54 41 52 54 45 44 22 29 0a 09 20 20 28  T_STARTED")..  (
a390: 64 62 3a 73 65 74 2d 74 65 73 74 73 2d 73 74 61  db:set-tests-sta
a3a0: 74 65 2d 73 74 61 74 75 73 20 64 62 20 72 75 6e  te-status db run
a3b0: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 73 20 23  -id test-names #
a3c0: 66 20 22 46 41 49 4c 22 20 22 4e 4f 54 5f 53 54  f "FAIL" "NOT_ST
a3d0: 41 52 54 45 44 22 20 22 46 41 49 4c 22 29 29 29  ARTED" "FAIL")))
a3e0: 0a 20 20 20 20 28 73 65 74 21 20 2a 70 61 73 73  .    (set! *pass
a3f0: 6e 75 6d 2a 20 28 2b 20 2a 70 61 73 73 6e 75 6d  num* (+ *passnum
a400: 2a 20 31 29 29 0a 20 20 20 20 28 6c 65 74 20 6c  * 1)).    (let l
a410: 6f 6f 70 20 28 28 6e 75 6d 74 69 6d 65 73 20 30  oop ((numtimes 0
a420: 29 29 0a 20 20 20 20 20 20 28 66 6f 72 2d 65 61  )).      (for-ea
a430: 63 68 20 0a 20 20 20 20 20 20 20 28 6c 61 6d 62  ch .       (lamb
a440: 64 61 20 28 74 65 73 74 2d 6e 61 6d 65 29 0a 09  da (test-name)..
a450: 20 28 69 66 20 28 72 75 6e 73 3a 63 61 6e 2d 72   (if (runs:can-r
a460: 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64 62  un-more-tests db
a470: 29 0a 09 20 20 20 20 20 28 72 75 6e 3a 74 65 73  )..     (run:tes
a480: 74 20 64 62 20 72 75 6e 2d 69 64 20 72 75 6e 6e  t db run-id runn
a490: 61 6d 65 20 74 65 73 74 2d 6e 61 6d 65 20 6b 65  ame test-name ke
a4a0: 79 76 61 6c 6c 73 74 20 69 74 65 6d 2d 70 61 74  yvallst item-pat
a4b0: 74 73 20 66 6c 61 67 73 29 0a 09 20 20 20 20 20  ts flags)..     
a4c0: 29 29 0a 20 20 20 20 20 20 20 28 74 65 73 74 73  )).       (tests
a4d0: 3a 73 6f 72 74 2d 62 79 2d 70 72 69 6f 72 69 74  :sort-by-priorit
a4e0: 79 2d 61 6e 64 2d 77 61 69 74 6f 6e 20 74 65 73  y-and-waiton tes
a4f0: 74 2d 6e 61 6d 65 73 29 29 0a 20 20 20 20 20 20  t-names)).      
a500: 3b 3b 20 28 72 75 6e 2d 77 61 69 74 69 6e 67 2d  ;; (run-waiting-
a510: 74 65 73 74 73 20 64 62 29 0a 20 20 20 20 20 20  tests db).      
a520: 28 69 66 20 6b 65 65 70 67 6f 69 6e 67 0a 09 20  (if keepgoing.. 
a530: 20 28 6c 65 74 20 28 28 65 73 74 72 65 6d 20 28   (let ((estrem (
a540: 64 62 3a 65 73 74 69 6d 61 74 65 64 2d 74 65 73  db:estimated-tes
a550: 74 73 2d 72 65 6d 61 69 6e 69 6e 67 20 64 62 20  ts-remaining db 
a560: 72 75 6e 2d 69 64 29 29 29 0a 09 20 20 20 20 28  run-id)))..    (
a570: 69 66 20 28 61 6e 64 20 28 3e 20 65 73 74 72 65  if (and (> estre
a580: 6d 20 30 29 0a 09 09 20 20 20 20 20 28 65 71 3f  m 0)...     (eq?
a590: 20 2a 67 6c 6f 62 61 6c 65 78 69 74 73 74 61 74   *globalexitstat
a5a0: 75 73 2a 20 30 29 29 0a 09 09 28 62 65 67 69 6e  us* 0))...(begin
a5b0: 0a 09 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e  ...  (debug:prin
a5c0: 74 20 31 20 22 4b 65 65 70 20 67 6f 69 6e 67 2c  t 1 "Keep going,
a5d0: 20 65 73 74 69 6d 61 74 65 64 20 22 20 65 73 74   estimated " est
a5e0: 72 65 6d 20 22 20 74 65 73 74 73 20 72 65 6d 61  rem " tests rema
a5f0: 69 6e 69 6e 67 20 74 6f 20 72 75 6e 2c 20 77 69  ining to run, wi
a600: 6c 6c 20 63 6f 6e 74 69 6e 75 65 20 69 6e 20 33  ll continue in 3
a610: 20 73 65 63 6f 6e 64 73 20 2e 2e 2e 22 29 0a 09   seconds ...")..
a620: 09 20 20 28 74 68 72 65 61 64 2d 73 6c 65 65 70  .  (thread-sleep
a630: 21 20 33 29 0a 09 09 20 20 28 72 75 6e 2d 77 61  ! 3)...  (run-wa
a640: 69 74 69 6e 67 2d 74 65 73 74 73 20 64 62 29 0a  iting-tests db).
a650: 09 09 20 20 28 6c 6f 6f 70 20 28 2b 20 6e 75 6d  ..  (loop (+ num
a660: 74 69 6d 65 73 20 31 29 29 29 29 29 29 29 29 29  times 1)))))))))
a670: 0a 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 3a 74  ..(define (run:t
a680: 65 73 74 20 64 62 20 72 75 6e 2d 69 64 20 72 75  est db run-id ru
a690: 6e 6e 61 6d 65 20 74 65 73 74 2d 6e 61 6d 65 20  nname test-name 
a6a0: 6b 65 79 76 61 6c 6c 73 74 20 69 74 65 6d 2d 70  keyvallst item-p
a6b0: 61 74 74 73 20 66 6c 61 67 73 29 0a 20 20 28 64  atts flags).  (d
a6c0: 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 4c 61  ebug:print 1 "La
a6d0: 75 6e 63 68 69 6e 67 20 74 65 73 74 20 22 20 74  unching test " t
a6e0: 65 73 74 2d 6e 61 6d 65 29 0a 20 20 3b 3b 20 41  est-name).  ;; A
a6f0: 6c 6c 20 74 68 65 73 65 20 76 61 72 73 20 6d 69  ll these vars mi
a700: 67 68 74 20 62 65 20 72 65 66 65 72 65 6e 63 65  ght be reference
a710: 64 20 62 79 20 74 68 65 20 74 65 73 74 63 6f 6e  d by the testcon
a720: 66 69 67 20 66 69 6c 65 20 72 65 61 64 65 72 0a  fig file reader.
a730: 20 20 28 73 65 74 65 6e 76 20 22 4d 54 5f 54 45    (setenv "MT_TE
a740: 53 54 5f 4e 41 4d 45 22 20 74 65 73 74 2d 6e 61  ST_NAME" test-na
a750: 6d 65 29 20 3b 3b 20 0a 20 20 28 73 65 74 65 6e  me) ;; .  (seten
a760: 76 20 22 4d 54 5f 52 55 4e 4e 41 4d 45 22 20 20  v "MT_RUNNAME"  
a770: 20 72 75 6e 6e 61 6d 65 29 0a 20 20 28 73 65 74   runname).  (set
a780: 2d 6d 65 67 61 74 65 73 74 2d 65 6e 76 2d 76 61  -megatest-env-va
a790: 72 73 20 64 62 20 72 75 6e 2d 69 64 29 20 3b 3b  rs db run-id) ;;
a7a0: 20 74 68 65 73 65 20 6d 61 79 20 62 65 20 6e 65   these may be ne
a7b0: 65 64 65 64 20 62 79 20 74 68 65 20 6c 61 75 6e  eded by the laun
a7c0: 63 68 69 6e 67 20 70 72 6f 63 65 73 73 0a 20 20  ching process.  
a7d0: 28 63 68 61 6e 67 65 2d 64 69 72 65 63 74 6f 72  (change-director
a7e0: 79 20 2a 74 6f 70 70 61 74 68 2a 29 0a 20 20 28  y *toppath*).  (
a7f0: 6c 65 74 2a 20 28 28 74 65 73 74 2d 70 61 74 68  let* ((test-path
a800: 20 20 20 20 28 63 6f 6e 63 20 2a 74 6f 70 70 61      (conc *toppa
a810: 74 68 2a 20 22 2f 74 65 73 74 73 2f 22 20 74 65  th* "/tests/" te
a820: 73 74 2d 6e 61 6d 65 29 29 20 3b 3b 20 63 6f 75  st-name)) ;; cou
a830: 6c 64 20 75 73 65 20 74 65 73 74 3a 67 65 74 2d  ld use test:get-
a840: 74 65 73 74 63 6f 6e 66 69 67 20 68 65 72 65 20  testconfig here 
a850: 2e 2e 2e 0a 09 20 28 74 65 73 74 2d 63 6f 6e 66  ..... (test-conf
a860: 69 67 66 20 28 63 6f 6e 63 20 74 65 73 74 2d 70  igf (conc test-p
a870: 61 74 68 20 22 2f 74 65 73 74 63 6f 6e 66 69 67  ath "/testconfig
a880: 22 29 29 0a 09 20 28 74 65 73 74 65 78 69 73 74  ")).. (testexist
a890: 73 20 20 20 28 61 6e 64 20 28 66 69 6c 65 2d 65  s   (and (file-e
a8a0: 78 69 73 74 73 3f 20 74 65 73 74 2d 63 6f 6e 66  xists? test-conf
a8b0: 69 67 66 29 28 66 69 6c 65 2d 72 65 61 64 2d 61  igf)(file-read-a
a8c0: 63 63 65 73 73 3f 20 74 65 73 74 2d 63 6f 6e 66  ccess? test-conf
a8d0: 69 67 66 29 29 29 0a 09 20 28 74 65 73 74 2d 63  igf))).. (test-c
a8e0: 6f 6e 66 20 20 20 20 28 69 66 20 74 65 73 74 65  onf    (if teste
a8f0: 78 69 73 74 73 20 28 72 65 61 64 2d 63 6f 6e 66  xists (read-conf
a900: 69 67 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 20  ig test-configf 
a910: 23 66 20 23 74 29 20 28 6d 61 6b 65 2d 68 61 73  #f #t) (make-has
a920: 68 2d 74 61 62 6c 65 29 29 29 0a 09 20 28 77 61  h-table))).. (wa
a930: 69 74 6f 6e 20 20 20 20 20 20 20 28 6c 65 74 20  iton       (let 
a940: 28 28 77 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b  ((w (config-look
a950: 75 70 20 74 65 73 74 2d 63 6f 6e 66 20 22 72 65  up test-conf "re
a960: 71 75 69 72 65 6d 65 6e 74 73 22 20 22 77 61 69  quirements" "wai
a970: 74 6f 6e 22 29 29 29 0a 09 09 09 20 28 69 66 20  ton"))).... (if 
a980: 28 73 74 72 69 6e 67 3f 20 77 29 28 73 74 72 69  (string? w)(stri
a990: 6e 67 2d 73 70 6c 69 74 20 77 29 27 28 29 29 29  ng-split w)'()))
a9a0: 29 0a 09 20 28 66 6f 72 63 65 20 20 20 20 20 20  ).. (force      
a9b0: 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65    (hash-table-re
a9c0: 66 2f 64 65 66 61 75 6c 74 20 66 6c 61 67 73 20  f/default flags 
a9d0: 22 2d 66 6f 72 63 65 22 20 23 66 29 29 0a 09 20  "-force" #f)).. 
a9e0: 28 72 65 72 75 6e 20 20 20 20 20 20 20 20 28 68  (rerun        (h
a9f0: 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65  ash-table-ref/de
aa00: 66 61 75 6c 74 20 66 6c 61 67 73 20 22 2d 72 65  fault flags "-re
aa10: 72 75 6e 22 20 23 66 29 29 0a 09 20 28 6b 65 65  run" #f)).. (kee
aa20: 70 67 6f 69 6e 67 20 20 20 20 28 68 61 73 68 2d  pgoing    (hash-
aa30: 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c  table-ref/defaul
aa40: 74 20 66 6c 61 67 73 20 22 2d 6b 65 65 70 67 6f  t flags "-keepgo
aa50: 69 6e 67 22 20 23 66 29 29 0a 09 20 3b 3b 20 41  ing" #f)).. ;; A
aa60: 72 65 20 74 68 65 73 65 20 74 61 67 73 20 73 74  re these tags st
aa70: 69 6c 6c 20 75 73 65 64 3f 20 49 20 64 6f 6e 27  ill used? I don'
aa80: 74 20 74 68 69 6e 6b 20 73 6f 2e 2e 2e 0a 09 20  t think so..... 
aa90: 3b 3b 28 74 61 67 73 20 20 20 20 20 20 20 20 20  ;;(tags         
aaa0: 28 6c 65 74 20 28 28 74 20 28 63 6f 6e 66 69 67  (let ((t (config
aab0: 2d 6c 6f 6f 6b 75 70 20 74 65 73 74 2d 63 6f 6e  -lookup test-con
aac0: 66 20 22 73 65 74 75 70 22 20 22 74 61 67 73 22  f "setup" "tags"
aad0: 29 29 29 0a 09 20 3b 3b 20 20 20 20 20 20 20 09  ))).. ;;       .
aae0: 20 3b 3b 20 77 65 20 77 61 6e 74 20 6f 75 72 20   ;; we want our 
aaf0: 74 61 67 73 20 74 6f 20 62 65 20 73 65 70 61 72  tags to be separ
ab00: 61 74 65 64 20 62 79 20 63 6f 6d 6d 61 73 20 61  ated by commas a
ab10: 6e 64 20 66 75 6c 6c 79 20 64 65 6c 69 6d 69 74  nd fully delimit
ab20: 65 64 20 62 79 20 63 6f 6d 6d 61 73 0a 09 20 3b  ed by commas.. ;
ab30: 3b 20 20 20 20 20 20 20 09 20 3b 3b 20 73 6f 20  ;       . ;; so 
ab40: 74 68 61 74 20 71 75 65 72 69 65 73 20 77 69 74  that queries wit
ab50: 68 20 22 6c 69 6b 65 22 20 63 61 6e 20 74 69 65  h "like" can tie
ab60: 20 74 6f 20 74 68 65 20 63 6f 6d 6d 61 73 20 61   to the commas a
ab70: 74 20 65 69 74 68 65 72 20 65 6e 64 20 6f 66 20  t either end of 
ab80: 65 61 63 68 20 74 61 67 0a 09 20 3b 3b 20 20 20  each tag.. ;;   
ab90: 20 20 20 20 09 20 3b 3b 20 77 68 69 6c 65 20 61      . ;; while a
aba0: 6c 73 6f 20 61 6c 6c 6f 77 69 6e 67 20 74 68 65  lso allowing the
abb0: 20 65 6e 64 20 75 73 65 72 20 74 6f 20 66 72 65   end user to fre
abc0: 65 6c 79 20 75 73 65 20 73 70 61 63 65 73 20 61  ely use spaces a
abd0: 6e 64 20 63 6f 6d 6d 61 73 20 74 6f 20 73 65 70  nd commas to sep
abe0: 61 72 61 74 65 20 74 61 67 73 0a 09 20 3b 3b 20  arate tags.. ;; 
abf0: 20 20 20 20 20 20 09 20 28 69 66 20 28 73 74 72        . (if (str
ac00: 69 6e 67 3f 20 74 29 28 73 74 72 69 6e 67 2d 73  ing? t)(string-s
ac10: 75 62 73 74 69 74 75 74 65 20 28 72 65 67 65 78  ubstitute (regex
ac20: 70 20 22 5b 2c 5c 5c 73 5d 2b 22 29 20 22 2c 22  p "[,\\s]+") ","
ac30: 20 28 63 6f 6e 63 20 22 2c 22 20 74 20 22 2c 22   (conc "," t ","
ac40: 29 20 23 74 29 0a 09 20 3b 3b 20 20 20 20 20 20  ) #t).. ;;      
ac50: 20 09 20 20 20 20 20 27 28 29 29 29 29 29 0a 09   .     '()))))..
ac60: 20 29 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20   ).    (if (not 
ac70: 74 65 73 74 65 78 69 73 74 73 29 0a 09 3b 3b 20  testexists)..;; 
ac80: 69 66 20 74 68 65 20 74 65 73 74 20 69 73 20 69  if the test is i
ac90: 6c 6c 20 64 65 66 69 6e 65 64 20 73 70 69 74 20  ll defined spit 
aca0: 6f 75 74 20 61 6e 20 65 72 72 6f 72 20 62 75 74  out an error but
acb0: 20 6b 65 65 70 20 67 6f 69 6e 67 20 28 64 69 66   keep going (dif
acc0: 66 65 72 65 6e 74 20 66 72 6f 6d 20 68 6f 77 20  ferent from how 
acd0: 64 6f 6e 65 20 70 72 65 76 69 6f 75 73 6c 79 0a  done previously.
ace0: 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20  .(debug:print 0 
acf0: 22 45 52 52 4f 52 3a 20 43 61 6e 27 74 20 66 69  "ERROR: Can't fi
ad00: 6e 64 20 63 6f 6e 66 69 67 20 66 69 6c 65 20 22  nd config file "
ad10: 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 29 0a 09   test-configf)..
ad20: 3b 3b 20 70 75 74 20 74 6f 70 20 76 61 72 73 20  ;; put top vars 
ad30: 69 6e 74 6f 20 63 6f 6e 76 65 6e 69 65 6e 74 20  into convenient 
ad40: 76 61 72 69 61 62 6c 65 73 20 61 6e 64 20 6f 70  variables and op
ad50: 65 6e 20 74 68 65 20 64 62 0a 09 28 6c 65 74 2a  en the db..(let*
ad60: 20 28 3b 3b 20 64 62 20 69 73 20 61 6c 77 61 79   (;; db is alway
ad70: 73 20 61 74 20 2a 74 6f 70 70 61 74 68 2a 2f 64  s at *toppath*/d
ad80: 62 2f 6d 65 67 61 74 65 73 74 2e 64 62 0a 09 20  b/megatest.db.. 
ad90: 20 20 20 20 20 20 28 69 74 65 6d 73 20 20 20 20        (items    
ada0: 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72     (hash-table-r
adb0: 65 66 2f 64 65 66 61 75 6c 74 20 74 65 73 74 2d  ef/default test-
adc0: 63 6f 6e 66 20 22 69 74 65 6d 73 22 20 27 28 29  conf "items" '()
add0: 29 29 0a 09 20 20 20 20 20 20 20 28 69 74 65 6d  ))..       (item
ade0: 73 74 61 62 6c 65 20 20 28 68 61 73 68 2d 74 61  stable  (hash-ta
adf0: 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20  ble-ref/default 
ae00: 74 65 73 74 2d 63 6f 6e 66 20 22 69 74 65 6d 73  test-conf "items
ae10: 74 61 62 6c 65 22 20 27 28 29 29 29 0a 09 20 20  table" '()))..  
ae20: 20 20 20 20 20 28 61 6c 6c 69 74 65 6d 73 20 20       (allitems  
ae30: 20 20 28 69 66 20 28 6f 72 20 28 6e 6f 74 20 28    (if (or (not (
ae40: 6e 75 6c 6c 3f 20 69 74 65 6d 73 29 29 28 6e 6f  null? items))(no
ae50: 74 20 28 6e 75 6c 6c 3f 20 69 74 65 6d 73 74 61  t (null? itemsta
ae60: 62 6c 65 29 29 29 0a 09 09 09 09 28 61 70 70 65  ble))).....(appe
ae70: 6e 64 20 28 69 74 65 6d 2d 61 73 73 6f 63 2d 3e  nd (item-assoc->
ae80: 69 74 65 6d 2d 6c 69 73 74 20 69 74 65 6d 73 29  item-list items)
ae90: 0a 09 09 09 09 09 28 69 74 65 6d 2d 74 61 62 6c  ......(item-tabl
aea0: 65 2d 3e 69 74 65 6d 2d 6c 69 73 74 20 69 74 65  e->item-list ite
aeb0: 6d 73 74 61 62 6c 65 29 29 0a 09 09 09 09 27 28  mstable)).....'(
aec0: 28 29 29 29 29 29 20 3b 3b 20 61 20 6c 69 73 74  ())))) ;; a list
aed0: 20 77 69 74 68 20 6f 6e 65 20 6e 75 6c 6c 20 6c   with one null l
aee0: 69 73 74 20 69 73 20 61 20 74 65 73 74 20 77 69  ist is a test wi
aef0: 74 68 20 6e 6f 20 69 74 65 6d 73 0a 09 20 20 3b  th no items..  ;
af00: 3b 20 28 72 75 6e 63 6f 6e 66 69 67 66 20 20 28  ; (runconfigf  (
af10: 63 6f 6e 63 20 20 2a 74 6f 70 70 61 74 68 2a 20  conc  *toppath* 
af20: 22 2f 72 75 6e 63 6f 6e 66 69 67 73 2e 63 6f 6e  "/runconfigs.con
af30: 66 69 67 22 29 29 29 0a 09 20 20 28 64 65 62 75  fig")))..  (debu
af40: 67 3a 70 72 69 6e 74 20 31 20 22 69 74 65 6d 73  g:print 1 "items
af50: 3a 20 22 29 0a 09 20 20 28 69 66 20 28 3e 3d 20  : ")..  (if (>= 
af60: 2a 76 65 72 62 6f 73 69 74 79 2a 20 31 29 28 70  *verbosity* 1)(p
af70: 70 20 61 6c 6c 69 74 65 6d 73 29 29 0a 09 20 20  p allitems))..  
af80: 28 69 66 20 28 3e 3d 20 2a 76 65 72 62 6f 73 69  (if (>= *verbosi
af90: 74 79 2a 20 35 29 0a 09 20 20 20 20 20 20 28 62  ty* 5)..      (b
afa0: 65 67 69 6e 0a 09 09 28 70 72 69 6e 74 20 22 69  egin...(print "i
afb0: 74 65 6d 73 3a 20 22 29 28 70 70 20 28 69 74 65  tems: ")(pp (ite
afc0: 6d 2d 61 73 73 6f 63 2d 3e 69 74 65 6d 2d 6c 69  m-assoc->item-li
afd0: 73 74 20 69 74 65 6d 73 29 29 0a 09 09 28 70 72  st items))...(pr
afe0: 69 6e 74 20 22 69 74 65 6d 73 74 61 62 6c 65 3a  int "itemstable:
aff0: 20 22 29 28 70 70 20 28 69 74 65 6d 2d 74 61 62   ")(pp (item-tab
b000: 6c 65 2d 3e 69 74 65 6d 2d 6c 69 73 74 20 69 74  le->item-list it
b010: 65 6d 73 74 61 62 6c 65 29 29 29 29 0a 0a 09 20  emstable))))... 
b020: 20 3b 3b 20 43 6f 6d 6d 65 6e 74 73 20 61 72 65   ;; Comments are
b030: 20 6c 6f 61 64 65 64 20 62 79 20 74 68 65 20 74   loaded by the t
b040: 65 73 74 20 72 75 6e 2c 20 6e 6f 74 20 61 74 20  est run, not at 
b050: 6c 61 75 6e 63 68 20 74 69 6d 65 20 28 69 6e 20  launch time (in 
b060: 67 65 6e 65 72 61 6c 29 0a 09 20 20 3b 3b 28 69  general)..  ;;(i
b070: 66 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20  f (args:get-arg 
b080: 22 2d 6d 22 29 0a 09 20 20 3b 3b 20 20 20 20 28  "-m")..  ;;    (
b090: 64 62 3a 73 65 74 2d 63 6f 6d 6d 65 6e 74 2d 66  db:set-comment-f
b0a0: 6f 72 2d 72 75 6e 20 64 62 20 72 75 6e 2d 69 64  or-run db run-id
b0b0: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22   (args:get-arg "
b0c0: 2d 6d 22 29 29 29 0a 0a 09 20 20 3b 3b 20 48 65  -m")))...  ;; He
b0d0: 72 65 20 69 73 20 77 68 65 72 65 20 74 68 65 20  re is where the 
b0e0: 74 65 73 74 5f 6d 65 74 61 20 74 61 62 6c 65 20  test_meta table 
b0f0: 69 73 20 62 65 73 74 20 75 70 64 61 74 65 64 0a  is best updated.
b100: 09 20 20 28 72 75 6e 73 3a 75 70 64 61 74 65 2d  .  (runs:update-
b110: 74 65 73 74 5f 6d 65 74 61 20 64 62 20 74 65 73  test_meta db tes
b120: 74 2d 6e 61 6d 65 20 74 65 73 74 2d 63 6f 6e 66  t-name test-conf
b130: 29 0a 0a 09 20 20 3b 3b 20 62 72 61 69 6e 64 65  )...  ;; brainde
b140: 61 64 20 77 6f 72 6b 2d 61 72 6f 75 6e 64 20 66  ad work-around f
b150: 6f 72 20 70 6f 6f 72 6c 79 20 73 70 65 63 69 66  or poorly specif
b160: 69 65 64 20 61 6c 6c 69 74 65 6d 73 20 6c 69 73  ied allitems lis
b170: 74 20 42 55 47 21 21 21 20 46 49 58 4d 45 0a 09  t BUG!!! FIXME..
b180: 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 61 6c 6c    (if (null? all
b190: 69 74 65 6d 73 29 28 73 65 74 21 20 61 6c 6c 69  items)(set! alli
b1a0: 74 65 6d 73 20 27 28 28 29 29 29 29 0a 09 20 20  tems '(())))..  
b1b0: 28 6c 65 74 20 6c 6f 6f 70 20 28 28 69 74 65 6d  (let loop ((item
b1c0: 64 61 74 20 28 63 61 72 20 61 6c 6c 69 74 65 6d  dat (car allitem
b1d0: 73 29 29 0a 09 09 20 20 20 20 20 28 74 61 6c 20  s))...     (tal 
b1e0: 20 20 20 20 28 63 64 72 20 61 6c 6c 69 74 65 6d      (cdr allitem
b1f0: 73 29 29 29 0a 09 20 20 20 20 3b 3b 20 28 6c 61  s)))..    ;; (la
b200: 6d 62 64 61 20 28 69 74 65 6d 64 61 74 29 20 3b  mbda (itemdat) ;
b210: 3b 3b 20 28 28 72 69 70 65 6e 65 73 73 20 22 6f  ;; ((ripeness "o
b220: 76 65 72 72 69 70 65 22 29 20 28 74 65 6d 70 65  verripe") (tempe
b230: 72 61 74 75 72 65 20 22 63 6f 6f 6c 22 29 20 28  rature "cool") (
b240: 73 65 61 73 6f 6e 20 22 73 75 6d 6d 65 72 22 29  season "summer")
b250: 29 0a 09 20 20 20 20 3b 3b 20 48 61 6e 64 6c 65  )..    ;; Handle
b260: 20 6c 69 73 74 73 20 6f 66 20 69 74 65 6d 73 0a   lists of items.
b270: 09 20 20 20 20 28 6c 65 74 2a 20 28 28 69 74 65  .    (let* ((ite
b280: 6d 2d 70 61 74 68 20 20 20 20 20 28 69 74 65 6d  m-path     (item
b290: 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69 74 65 6d  -list->path item
b2a0: 64 61 74 29 29 20 3b 3b 20 28 73 74 72 69 6e 67  dat)) ;; (string
b2b0: 2d 69 6e 74 65 72 73 70 65 72 73 65 20 28 6d 61  -intersperse (ma
b2c0: 70 20 63 61 64 72 20 69 74 65 6d 64 61 74 29 20  p cadr itemdat) 
b2d0: 22 2f 22 29 29 0a 09 09 20 20 20 28 6e 65 77 2d  "/"))...   (new-
b2e0: 74 65 73 74 2d 70 61 74 68 20 28 73 74 72 69 6e  test-path (strin
b2f0: 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 28 63  g-intersperse (c
b300: 6f 6e 73 20 74 65 73 74 2d 70 61 74 68 20 28 6d  ons test-path (m
b310: 61 70 20 63 61 64 72 20 69 74 65 6d 64 61 74 29  ap cadr itemdat)
b320: 29 20 22 2f 22 29 29 0a 09 09 20 20 20 28 6e 65  ) "/"))...   (ne
b330: 77 2d 74 65 73 74 2d 6e 61 6d 65 20 28 69 66 20  w-test-name (if 
b340: 28 65 71 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74  (equal? item-pat
b350: 68 20 22 22 29 20 74 65 73 74 2d 6e 61 6d 65 20  h "") test-name 
b360: 28 63 6f 6e 63 20 74 65 73 74 2d 6e 61 6d 65 20  (conc test-name 
b370: 22 2f 22 20 69 74 65 6d 2d 70 61 74 68 29 29 29  "/" item-path)))
b380: 20 3b 3b 20 6a 75 73 74 20 6e 65 65 64 20 69 74   ;; just need it
b390: 20 74 6f 20 62 65 20 75 6e 69 71 75 65 0a 09 09   to be unique...
b3a0: 20 20 20 28 74 65 73 74 64 61 74 20 20 20 23 66     (testdat   #f
b3b0: 29 0a 09 09 20 20 20 28 6e 75 6d 2d 72 75 6e 6e  )...   (num-runn
b3c0: 69 6e 67 20 28 64 62 3a 67 65 74 2d 63 6f 75 6e  ing (db:get-coun
b3d0: 74 2d 74 65 73 74 73 2d 72 75 6e 6e 69 6e 67 20  t-tests-running 
b3e0: 64 62 29 29 0a 09 09 20 20 20 28 6d 61 78 2d 63  db))...   (max-c
b3f0: 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 20 28  oncurrent-jobs (
b400: 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 2a 63  config-lookup *c
b410: 6f 6e 66 69 67 64 61 74 2a 20 22 73 65 74 75 70  onfigdat* "setup
b420: 22 20 22 6d 61 78 5f 63 6f 6e 63 75 72 72 65 6e  " "max_concurren
b430: 74 5f 6a 6f 62 73 22 29 29 0a 09 09 20 20 20 28  t_jobs"))...   (
b440: 70 61 72 65 6e 74 2d 74 65 73 74 20 28 61 6e 64  parent-test (and
b450: 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 69 74 65   (not (null? ite
b460: 6d 73 29 29 28 65 71 75 61 6c 3f 20 69 74 65 6d  ms))(equal? item
b470: 2d 70 61 74 68 20 22 22 29 29 29 0a 09 09 20 20  -path "")))...  
b480: 20 28 73 69 6e 67 6c 65 2d 74 65 73 74 20 28 61   (single-test (a
b490: 6e 64 20 28 6e 75 6c 6c 3f 20 69 74 65 6d 73 29  nd (null? items)
b4a0: 20 28 65 71 75 61 6c 3f 20 69 74 65 6d 2d 70 61   (equal? item-pa
b4b0: 74 68 20 22 22 29 29 29 0a 09 09 20 20 20 28 69  th "")))...   (i
b4c0: 74 65 6d 2d 74 65 73 74 20 20 20 28 6e 6f 74 20  tem-test   (not 
b4d0: 28 65 71 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74  (equal? item-pat
b4e0: 68 20 22 22 29 29 29 0a 09 09 20 20 20 3b 3b 20  h "")))...   ;; 
b4f0: 6c 6f 6f 6b 20 74 68 72 6f 75 67 68 20 61 6c 6c  look through all
b500: 20 74 68 65 20 69 74 65 6d 2d 70 61 74 74 73 20   the item-patts 
b510: 69 66 20 64 65 66 69 6e 65 64 2c 20 66 6f 72 6d  if defined, form
b520: 61 74 20 69 73 20 70 61 74 74 31 2c 70 61 74 74  at is patt1,patt
b530: 32 2c 70 61 74 74 33 20 2e 2e 2e 20 77 69 6c 64  2,patt3 ... wild
b540: 63 61 72 64 20 69 73 20 25 0a 09 09 20 20 20 28  card is %...   (
b550: 69 74 65 6d 2d 6d 61 74 63 68 65 73 20 28 69 66  item-matches (if
b560: 20 69 74 65 6d 2d 70 61 74 74 73 0a 09 09 09 09   item-patts.....
b570: 20 20 20 20 20 28 6c 65 74 20 28 28 72 65 73 20       (let ((res 
b580: 23 66 29 29 0a 09 09 09 09 20 20 20 20 20 20 20  #f)).....       
b590: 28 66 6f 72 2d 65 61 63 68 20 0a 09 09 09 09 09  (for-each ......
b5a0: 28 6c 61 6d 62 64 61 20 28 70 61 74 74 29 0a 09  (lambda (patt)..
b5b0: 09 09 09 09 20 20 28 69 66 20 28 73 74 72 69 6e  ....  (if (strin
b5c0: 67 2d 73 65 61 72 63 68 20 28 67 6c 6f 62 2d 3e  g-search (glob->
b5d0: 72 65 67 65 78 70 0a 09 09 09 09 09 09 09 20 20  regexp........  
b5e0: 20 20 20 20 28 73 74 72 69 6e 67 2d 74 72 61 6e      (string-tran
b5f0: 73 6c 61 74 65 20 70 61 74 74 20 22 25 22 20 22  slate patt "%" "
b600: 2a 22 29 29 0a 09 09 09 09 09 09 09 20 20 20 20  *"))........    
b610: 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 09 09 09   item-path).....
b620: 09 20 20 20 20 20 20 28 73 65 74 21 20 72 65 73  .      (set! res
b630: 20 23 74 29 29 29 0a 09 09 09 09 09 28 73 74 72   #t)))......(str
b640: 69 6e 67 2d 73 70 6c 69 74 20 69 74 65 6d 2d 70  ing-split item-p
b650: 61 74 74 73 20 22 2c 22 29 29 0a 09 09 09 09 20  atts ","))..... 
b660: 20 20 20 20 20 20 72 65 73 29 0a 09 09 09 09 20        res)..... 
b670: 20 20 20 20 23 74 29 29 29 0a 09 20 20 20 20 20      #t)))..     
b680: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 33 20   (debug:print 3 
b690: 22 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d  "max-concurrent-
b6a0: 6a 6f 62 73 3a 20 22 20 6d 61 78 2d 63 6f 6e 63  jobs: " max-conc
b6b0: 75 72 72 65 6e 74 2d 6a 6f 62 73 20 22 2c 20 6e  urrent-jobs ", n
b6c0: 75 6d 2d 72 75 6e 6e 69 6e 67 3a 20 22 20 6e 75  um-running: " nu
b6d0: 6d 2d 72 75 6e 6e 69 6e 67 29 0a 09 20 20 20 20  m-running)..    
b6e0: 20 20 28 69 66 20 28 61 6e 64 20 69 74 65 6d 2d    (if (and item-
b6f0: 6d 61 74 63 68 65 73 20 28 72 75 6e 73 3a 63 61  matches (runs:ca
b700: 6e 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73  n-run-more-tests
b710: 20 64 62 29 29 0a 09 09 20 20 28 62 65 67 69 6e   db))...  (begin
b720: 0a 09 09 20 20 20 20 28 6c 65 74 20 6c 6f 6f 70  ...    (let loop
b730: 32 20 28 28 74 73 20 28 64 62 3a 67 65 74 2d 74  2 ((ts (db:get-t
b740: 65 73 74 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d  est-info db run-
b750: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65  id test-name ite
b760: 6d 2d 70 61 74 68 29 29 20 3b 3b 20 23 66 29 0a  m-path)) ;; #f).
b770: 09 09 09 09 28 63 74 20 30 29 29 0a 09 09 20 20  ....(ct 0))...  
b780: 20 20 20 20 28 69 66 20 28 61 6e 64 20 28 6e 6f      (if (and (no
b790: 74 20 74 73 29 0a 09 09 09 20 20 20 20 20 20 20  t ts)....       
b7a0: 28 3c 20 63 74 20 31 30 29 29 0a 09 09 09 20 20  (< ct 10))....  
b7b0: 28 62 65 67 69 6e 0a 09 09 09 20 20 20 20 28 72  (begin....    (r
b7c0: 65 67 69 73 74 65 72 2d 74 65 73 74 20 64 62 20  egister-test db 
b7d0: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
b7e0: 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 09 09 20   item-path).... 
b7f0: 20 20 20 3b 3b 20 57 68 79 20 64 69 64 20 49 20     ;; Why did I 
b800: 73 65 74 20 74 68 65 20 63 6f 6d 6d 65 6e 74 20  set the comment 
b810: 68 65 72 65 3f 21 3f 20 50 4f 53 53 49 42 4c 45  here?!? POSSIBLE
b820: 20 42 55 47 20 42 55 54 20 49 27 4d 20 52 45 4d   BUG BUT I'M REM
b830: 4f 56 49 4e 47 20 49 54 20 46 4f 52 20 4e 4f 57  OVING IT FOR NOW
b840: 20 31 30 2f 32 33 2f 32 30 31 31 0a 09 09 09 20   10/23/2011.... 
b850: 20 20 20 3b 3b 20 28 64 62 3a 74 65 73 74 2d 73     ;; (db:test-s
b860: 65 74 2d 63 6f 6d 6d 65 6e 74 20 64 62 20 72 75  et-comment db ru
b870: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69  n-id test-name i
b880: 74 65 6d 2d 70 61 74 68 20 22 22 29 0a 09 09 09  tem-path "")....
b890: 20 20 20 20 28 6c 6f 6f 70 32 20 28 64 62 3a 67      (loop2 (db:g
b8a0: 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 20  et-test-info db 
b8b0: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
b8c0: 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 09 09 09   item-path).....
b8d0: 20 20 20 28 2b 20 63 74 20 31 29 29 29 0a 09 09     (+ ct 1)))...
b8e0: 09 20 20 28 69 66 20 74 73 0a 09 09 09 20 20 20  .  (if ts....   
b8f0: 20 20 20 28 73 65 74 21 20 74 65 73 74 64 61 74     (set! testdat
b900: 20 74 73 29 0a 09 09 09 20 20 20 20 20 20 28 62   ts)....      (b
b910: 65 67 69 6e 0a 09 09 09 09 28 64 65 62 75 67 3a  egin.....(debug:
b920: 70 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e 47  print 0 "WARNING
b930: 3a 20 43 6f 75 6c 64 6e 27 74 20 72 65 67 69 73  : Couldn't regis
b940: 74 65 72 20 74 65 73 74 20 22 20 74 65 73 74 2d  ter test " test-
b950: 6e 61 6d 65 20 22 20 77 69 74 68 20 69 74 65 6d  name " with item
b960: 20 70 61 74 68 20 22 20 69 74 65 6d 2d 70 61 74   path " item-pat
b970: 68 20 22 2c 20 73 6b 69 70 70 69 6e 67 22 29 0a  h ", skipping").
b980: 09 09 09 09 28 69 66 20 28 6e 6f 74 20 28 6e 75  ....(if (not (nu
b990: 6c 6c 3f 20 74 61 6c 29 29 0a 09 09 09 09 20 20  ll? tal)).....  
b9a0: 20 20 28 6c 6f 6f 70 20 28 63 61 72 20 74 61 6c    (loop (car tal
b9b0: 29 28 63 64 72 20 74 61 6c 29 29 29 29 29 29 29  )(cdr tal)))))))
b9c0: 0a 09 09 20 20 20 20 28 63 68 61 6e 67 65 2d 64  ...    (change-d
b9d0: 69 72 65 63 74 6f 72 79 20 74 65 73 74 2d 70 61  irectory test-pa
b9e0: 74 68 29 0a 09 09 20 20 20 20 3b 3b 20 74 68 69  th)...    ;; thi
b9f0: 73 20 62 6c 6f 63 6b 20 69 73 20 68 65 72 65 20  s block is here 
ba00: 6f 6e 6c 79 20 74 6f 20 69 6e 66 6f 72 6d 20 74  only to inform t
ba10: 68 65 20 75 73 65 72 20 65 61 72 6c 79 20 6f 6e  he user early on
ba20: 0a 09 09 20 20 20 20 0a 09 09 20 20 20 20 3b 3b  ...    ...    ;;
ba30: 20 4d 6f 76 69 6e 67 20 74 68 69 73 20 74 6f 20   Moving this to 
ba40: 74 68 65 20 72 75 6e 20 63 61 6c 6c 69 6e 67 20  the run calling 
ba50: 62 6c 6f 63 6b 0a 0a 09 09 20 20 20 20 3b 3b 20  block....    ;; 
ba60: 28 69 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73  (if (file-exists
ba70: 3f 20 72 75 6e 63 6f 6e 66 69 67 66 29 0a 09 09  ? runconfigf)...
ba80: 20 20 20 20 3b 3b 20 20 20 20 20 28 73 65 74 75      ;;     (setu
ba90: 70 2d 65 6e 76 2d 64 65 66 61 75 6c 74 73 20 64  p-env-defaults d
baa0: 62 20 72 75 6e 63 6f 6e 66 69 67 66 20 72 75 6e  b runconfigf run
bab0: 2d 69 64 20 2a 61 6c 72 65 61 64 79 2d 73 65 65  -id *already-see
bac0: 6e 2d 72 75 6e 63 6f 6e 66 69 67 2d 69 6e 66 6f  n-runconfig-info
bad0: 2a 29 0a 09 09 20 20 20 20 3b 3b 20 20 20 20 20  *)...    ;;     
bae0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
baf0: 57 41 52 4e 49 4e 47 3a 20 59 6f 75 20 64 6f 20  WARNING: You do 
bb00: 6e 6f 74 20 68 61 76 65 20 61 20 72 75 6e 20 63  not have a run c
bb10: 6f 6e 66 69 67 20 66 69 6c 65 3a 20 22 20 72 75  onfig file: " ru
bb20: 6e 63 6f 6e 66 69 67 66 29 29 0a 09 09 20 20 20  nconfigf))...   
bb30: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20   (debug:print 4 
bb40: 22 72 75 6e 2d 69 64 3a 20 22 20 72 75 6e 2d 69  "run-id: " run-i
bb50: 64 20 22 20 74 65 73 74 2d 6e 61 6d 65 3a 20 22  d " test-name: "
bb60: 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 69 74 65   test-name " ite
bb70: 6d 2d 70 61 74 68 3a 20 22 20 69 74 65 6d 2d 70  m-path: " item-p
bb80: 61 74 68 20 22 20 74 65 73 74 64 61 74 3a 20 22  ath " testdat: "
bb90: 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75   (test:get-statu
bba0: 73 20 74 65 73 74 64 61 74 29 20 22 20 74 65 73  s testdat) " tes
bbb0: 74 2d 73 74 61 74 65 3a 20 22 20 28 74 65 73 74  t-state: " (test
bbc0: 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64  :get-state testd
bbd0: 61 74 29 29 0a 09 09 20 20 20 20 28 63 61 73 65  at))...    (case
bbe0: 20 28 69 66 20 66 6f 72 63 65 20 3b 3b 20 28 61   (if force ;; (a
bbf0: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 66 6f  rgs:get-arg "-fo
bc00: 72 63 65 22 29 0a 09 09 09 20 20 20 20 20 20 27  rce")....      '
bc10: 4e 4f 54 5f 53 54 41 52 54 45 44 0a 09 09 09 20  NOT_STARTED.... 
bc20: 20 20 20 20 20 28 69 66 20 74 65 73 74 64 61 74       (if testdat
bc30: 0a 09 09 09 09 20 20 28 73 74 72 69 6e 67 2d 3e  .....  (string->
bc40: 73 79 6d 62 6f 6c 20 28 74 65 73 74 3a 67 65 74  symbol (test:get
bc50: 2d 73 74 61 74 65 20 74 65 73 74 64 61 74 29 29  -state testdat))
bc60: 0a 09 09 09 09 20 20 27 66 61 69 6c 65 64 2d 74  .....  'failed-t
bc70: 6f 2d 69 6e 73 65 72 74 29 29 0a 09 09 20 20 20  o-insert))...   
bc80: 20 20 20 28 28 66 61 69 6c 65 64 2d 74 6f 2d 69     ((failed-to-i
bc90: 6e 73 65 72 74 29 0a 09 09 20 20 20 20 20 20 20  nsert)...       
bca0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
bcb0: 45 52 52 4f 52 3a 20 46 61 69 6c 65 64 20 74 6f  ERROR: Failed to
bcc0: 20 69 6e 73 65 72 74 20 74 68 65 20 72 65 63 6f   insert the reco
bcd0: 72 64 20 69 6e 74 6f 20 74 68 65 20 64 62 22 29  rd into the db")
bce0: 29 0a 09 09 20 20 20 20 20 20 28 28 4e 4f 54 5f  )...      ((NOT_
bcf0: 53 54 41 52 54 45 44 20 43 4f 4d 50 4c 45 54 45  STARTED COMPLETE
bd00: 44 29 0a 09 09 20 20 20 20 20 20 20 28 64 65 62  D)...       (deb
bd10: 75 67 3a 70 72 69 6e 74 20 36 20 22 47 6f 74 20  ug:print 6 "Got 
bd20: 68 65 72 65 2c 20 22 20 28 74 65 73 74 3a 67 65  here, " (test:ge
bd30: 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 74 29  t-state testdat)
bd40: 29 0a 09 09 20 20 20 20 20 20 20 28 6c 65 74 20  )...       (let 
bd50: 28 28 72 75 6e 66 6c 61 67 20 23 66 29 29 0a 09  ((runflag #f))..
bd60: 09 09 20 28 63 6f 6e 64 0a 09 09 09 20 20 3b 3b  .. (cond....  ;;
bd70: 20 69 2e 65 2e 20 74 68 69 73 20 69 73 20 74 68   i.e. this is th
bd80: 65 20 70 61 72 65 6e 74 20 74 65 73 74 20 74 6f  e parent test to
bd90: 20 61 20 73 75 69 74 65 20 6f 66 20 69 74 65 6d   a suite of item
bda0: 73 2c 20 6e 65 76 65 72 20 22 72 75 6e 22 20 69  s, never "run" i
bdb0: 74 0a 09 09 09 20 20 28 70 61 72 65 6e 74 2d 74  t....  (parent-t
bdc0: 65 73 74 0a 09 09 09 20 20 20 28 73 65 74 21 20  est....   (set! 
bdd0: 72 75 6e 66 6c 61 67 20 23 66 29 29 0a 09 09 09  runflag #f))....
bde0: 20 20 3b 3b 20 2d 66 6f 72 63 65 2c 20 72 75 6e    ;; -force, run
bdf0: 20 6e 6f 20 6d 61 74 74 65 72 20 77 68 61 74 0a   no matter what.
be00: 09 09 09 20 20 28 66 6f 72 63 65 20 28 73 65 74  ...  (force (set
be10: 21 20 72 75 6e 66 6c 61 67 20 23 74 29 29 0a 09  ! runflag #t))..
be20: 09 09 20 20 3b 3b 20 4e 4f 54 5f 53 54 41 52 54  ..  ;; NOT_START
be30: 45 44 2c 20 72 75 6e 20 6e 6f 20 6d 61 74 74 65  ED, run no matte
be40: 72 20 77 68 61 74 0a 09 09 09 20 20 28 28 65 71  r what....  ((eq
be50: 75 61 6c 3f 20 28 74 65 73 74 3a 67 65 74 2d 73  ual? (test:get-s
be60: 74 61 74 65 20 74 65 73 74 64 61 74 29 20 22 4e  tate testdat) "N
be70: 4f 54 5f 53 54 41 52 54 45 44 22 29 28 73 65 74  OT_STARTED")(set
be80: 21 20 72 75 6e 66 6c 61 67 20 23 74 29 29 0a 09  ! runflag #t))..
be90: 09 09 20 20 3b 3b 20 6e 6f 74 20 2d 72 65 72 75  ..  ;; not -reru
bea0: 6e 20 61 6e 64 20 50 41 53 53 2c 20 57 41 52 4e  n and PASS, WARN
beb0: 20 6f 72 20 43 48 45 43 4b 2c 20 64 6f 20 6e 6f   or CHECK, do no
bec0: 20 72 75 6e 0a 09 09 09 20 20 28 28 61 6e 64 20   run....  ((and 
bed0: 28 6f 72 20 28 6e 6f 74 20 72 65 72 75 6e 29 0a  (or (not rerun).
bee0: 09 09 09 09 20 20 20 20 6b 65 65 70 67 6f 69 6e  ....    keepgoin
bef0: 67 29 0a 09 09 09 09 28 6d 65 6d 62 65 72 20 28  g).....(member (
bf00: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20  test:get-status 
bf10: 74 65 73 74 64 61 74 29 20 27 28 22 50 41 53 53  testdat) '("PASS
bf20: 22 20 22 57 41 52 4e 22 20 22 43 48 45 43 4b 22  " "WARN" "CHECK"
bf30: 29 29 29 0a 09 09 09 20 20 20 28 73 65 74 21 20  )))....   (set! 
bf40: 72 75 6e 66 6c 61 67 20 23 66 29 29 0a 09 09 09  runflag #f))....
bf50: 20 20 3b 3b 20 2d 72 65 72 75 6e 20 61 6e 64 20    ;; -rerun and 
bf60: 73 74 61 74 75 73 20 69 73 20 6f 6e 65 20 6f 66  status is one of
bf70: 20 74 68 65 20 73 70 65 63 69 66 65 64 2c 20 72   the specifed, r
bf80: 75 6e 20 69 74 0a 09 09 09 20 20 28 28 61 6e 64  un it....  ((and
bf90: 20 72 65 72 75 6e 0a 09 09 09 09 28 6c 65 74 20   rerun.....(let 
bfa0: 28 28 72 65 72 75 6e 6c 73 74 20 28 73 74 72 69  ((rerunlst (stri
bfb0: 6e 67 2d 73 70 6c 69 74 20 72 65 72 75 6e 20 22  ng-split rerun "
bfc0: 2c 22 29 29 29 20 3b 3b 20 46 41 49 4c 2c 0a 09  ,"))) ;; FAIL,..
bfd0: 09 09 09 20 20 28 6d 65 6d 62 65 72 20 28 74 65  ...  (member (te
bfe0: 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65  st:get-status te
bff0: 73 74 64 61 74 29 20 72 65 72 75 6e 6c 73 74 29  stdat) rerunlst)
c000: 29 29 0a 09 09 09 20 20 20 28 73 65 74 21 20 72  ))....   (set! r
c010: 75 6e 66 6c 61 67 20 23 74 29 29 0a 09 09 09 20  unflag #t)).... 
c020: 20 3b 3b 20 2d 6b 65 65 70 67 6f 69 6e 67 2c 20   ;; -keepgoing, 
c030: 64 6f 20 6e 6f 74 20 72 65 72 75 6e 20 46 41 49  do not rerun FAI
c040: 4c 0a 09 09 09 20 20 28 28 61 6e 64 20 6b 65 65  L....  ((and kee
c050: 70 67 6f 69 6e 67 0a 09 09 09 09 28 6d 65 6d 62  pgoing.....(memb
c060: 65 72 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61  er (test:get-sta
c070: 74 75 73 20 74 65 73 74 64 61 74 29 20 27 28 22  tus testdat) '("
c080: 46 41 49 4c 22 29 29 29 0a 09 09 09 20 20 20 28  FAIL")))....   (
c090: 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 66 29  set! runflag #f)
c0a0: 29 0a 09 09 09 20 20 28 28 61 6e 64 20 28 6e 6f  )....  ((and (no
c0b0: 74 20 72 65 72 75 6e 29 0a 09 09 09 09 28 6d 65  t rerun).....(me
c0c0: 6d 62 65 72 20 28 74 65 73 74 3a 67 65 74 2d 73  mber (test:get-s
c0d0: 74 61 74 75 73 20 74 65 73 74 64 61 74 29 20 27  tatus testdat) '
c0e0: 28 22 46 41 49 4c 22 20 22 6e 2f 61 22 29 29 29  ("FAIL" "n/a")))
c0f0: 0a 09 09 09 20 20 20 28 73 65 74 21 20 72 75 6e  ....   (set! run
c100: 66 6c 61 67 20 23 74 29 29 0a 09 09 09 20 20 28  flag #t))....  (
c110: 65 6c 73 65 20 28 73 65 74 21 20 72 75 6e 66 6c  else (set! runfl
c120: 61 67 20 23 66 29 29 29 0a 09 09 09 20 28 64 65  ag #f))).... (de
c130: 62 75 67 3a 70 72 69 6e 74 20 36 20 22 52 55 4e  bug:print 6 "RUN
c140: 4e 49 4e 47 20 3d 3e 20 72 75 6e 66 6c 61 67 3a  NING => runflag:
c150: 20 22 20 72 75 6e 66 6c 61 67 20 22 20 53 54 41   " runflag " STA
c160: 54 45 3a 20 22 20 28 74 65 73 74 3a 67 65 74 2d  TE: " (test:get-
c170: 73 74 61 74 65 20 74 65 73 74 64 61 74 29 20 22  state testdat) "
c180: 20 53 54 41 54 55 53 3a 20 22 20 28 74 65 73 74   STATUS: " (test
c190: 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74  :get-status test
c1a0: 64 61 74 29 29 0a 09 09 09 20 28 69 66 20 28 6e  dat)).... (if (n
c1b0: 6f 74 20 72 75 6e 66 6c 61 67 29 0a 09 09 09 20  ot runflag).... 
c1c0: 20 20 20 20 28 69 66 20 28 6e 6f 74 20 70 61 72      (if (not par
c1d0: 65 6e 74 2d 74 65 73 74 29 0a 09 09 09 09 20 28  ent-test)..... (
c1e0: 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 4e  debug:print 1 "N
c1f0: 4f 54 45 3a 20 4e 6f 74 20 73 74 61 72 74 69 6e  OTE: Not startin
c200: 67 20 74 65 73 74 20 22 20 6e 65 77 2d 74 65 73  g test " new-tes
c210: 74 2d 6e 61 6d 65 20 22 20 61 73 20 69 74 20 69  t-name " as it i
c220: 73 20 73 74 61 74 65 20 5c 22 43 4f 4d 50 4c 45  s state \"COMPLE
c230: 54 45 44 5c 22 20 61 6e 64 20 73 74 61 74 75 73  TED\" and status
c240: 20 5c 22 22 20 28 74 65 73 74 3a 67 65 74 2d 73   \"" (test:get-s
c250: 74 61 74 75 73 20 74 65 73 74 64 61 74 29 20 22  tatus testdat) "
c260: 5c 22 2c 20 75 73 65 20 2d 66 6f 72 63 65 20 74  \", use -force t
c270: 6f 20 6f 76 65 72 72 69 64 65 22 29 29 0a 09 09  o override"))...
c280: 09 20 20 20 20 20 28 6c 65 74 2a 20 28 28 67 65  .     (let* ((ge
c290: 74 2d 70 72 65 72 65 71 73 2d 63 6d 64 20 28 6c  t-prereqs-cmd (l
c2a0: 61 6d 62 64 61 20 28 29 0a 09 09 09 09 09 09 20  ambda ()....... 
c2b0: 20 20 20 20 20 20 28 64 62 2d 67 65 74 2d 70 72        (db-get-pr
c2c0: 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 20 64 62  ereqs-not-met db
c2d0: 20 72 75 6e 2d 69 64 20 77 61 69 74 6f 6e 29 29   run-id waiton))
c2e0: 29 20 3b 3b 20 63 68 65 63 6b 20 62 65 66 6f 72  ) ;; check befor
c2f0: 65 20 72 75 6e 6e 69 6e 67 20 2e 2e 2e 2e 0a 09  e running ......
c300: 09 09 09 20 20 20 20 28 6c 61 75 6e 63 68 2d 63  ...    (launch-c
c310: 6d 64 20 20 20 20 20 20 28 6c 61 6d 62 64 61 20  md      (lambda 
c320: 28 29 0a 09 09 09 09 09 09 20 20 20 20 20 20 20  ().......       
c330: 28 6c 61 75 6e 63 68 2d 74 65 73 74 20 64 62 20  (launch-test db 
c340: 72 75 6e 2d 69 64 20 72 75 6e 6e 61 6d 65 20 74  run-id runname t
c350: 65 73 74 2d 63 6f 6e 66 20 6b 65 79 76 61 6c 6c  est-conf keyvall
c360: 73 74 20 74 65 73 74 2d 6e 61 6d 65 20 74 65 73  st test-name tes
c370: 74 2d 70 61 74 68 20 69 74 65 6d 64 61 74 20 66  t-path itemdat f
c380: 6c 61 67 73 29 29 29 0a 09 09 09 09 20 20 20 20  lags))).....    
c390: 28 74 65 73 74 72 75 6e 64 61 74 20 20 20 20 20  (testrundat     
c3a0: 20 28 6c 69 73 74 20 67 65 74 2d 70 72 65 72 65   (list get-prere
c3b0: 71 73 2d 63 6d 64 20 6c 61 75 6e 63 68 2d 63 6d  qs-cmd launch-cm
c3c0: 64 29 29 29 0a 09 09 09 20 20 20 20 20 20 20 28  d)))....       (
c3d0: 69 66 20 28 6f 72 20 66 6f 72 63 65 0a 09 09 09  if (or force....
c3e0: 09 20 20 20 20 20 20 20 28 6c 65 74 20 28 28 70  .       (let ((p
c3f0: 72 65 71 73 2d 6e 6f 74 2d 79 65 74 2d 6d 65 74  reqs-not-yet-met
c400: 20 28 28 63 61 72 20 74 65 73 74 72 75 6e 64 61   ((car testrunda
c410: 74 29 29 29 29 0a 09 09 09 09 09 20 28 64 65 62  t))))...... (deb
c420: 75 67 3a 70 72 69 6e 74 20 32 20 22 50 72 65 71  ug:print 2 "Preq
c430: 72 65 71 75 65 73 69 74 65 73 20 66 6f 72 20 22  requesites for "
c440: 20 74 65 73 74 2d 6e 61 6d 65 20 22 3a 20 22 20   test-name ": " 
c450: 70 72 65 71 73 2d 6e 6f 74 2d 79 65 74 2d 6d 65  preqs-not-yet-me
c460: 74 29 0a 09 09 09 09 09 20 28 6e 75 6c 6c 3f 20  t)...... (null? 
c470: 70 72 65 71 73 2d 6e 6f 74 2d 79 65 74 2d 6d 65  preqs-not-yet-me
c480: 74 29 29 29 20 3b 3b 20 61 72 65 20 74 68 65 72  t))) ;; are ther
c490: 65 20 61 6e 79 20 74 65 73 74 73 20 74 68 61 74  e any tests that
c4a0: 20 6d 75 73 74 20 62 65 20 72 75 6e 20 62 65 66   must be run bef
c4b0: 6f 72 65 20 74 68 69 73 20 6f 6e 65 2e 2e 2e 0a  ore this one....
c4c0: 09 09 09 09 20 20 20 28 69 66 20 28 6e 6f 74 20  ....   (if (not 
c4d0: 28 28 63 61 64 72 20 74 65 73 74 72 75 6e 64 61  ((cadr testrunda
c4e0: 74 29 29 29 20 3b 3b 20 74 68 69 73 20 69 73 20  t))) ;; this is 
c4f0: 74 68 65 20 6c 69 6e 65 20 74 68 61 74 20 6c 61  the line that la
c500: 75 6e 63 68 65 73 20 74 68 65 20 74 65 73 74 20  unches the test 
c510: 74 6f 20 74 68 65 20 72 65 6d 6f 74 65 20 68 6f  to the remote ho
c520: 73 74 0a 09 09 09 09 20 20 20 20 20 20 20 28 62  st.....       (b
c530: 65 67 69 6e 0a 09 09 09 09 09 20 28 70 72 69 6e  egin...... (prin
c540: 74 20 22 45 52 52 4f 52 3a 20 46 61 69 6c 65 64  t "ERROR: Failed
c550: 20 74 6f 20 6c 61 75 6e 63 68 20 74 68 65 20 74   to launch the t
c560: 65 73 74 2e 20 45 78 69 74 69 6e 67 20 61 73 20  est. Exiting as 
c570: 73 6f 6f 6e 20 61 73 20 70 6f 73 73 69 62 6c 65  soon as possible
c580: 22 29 0a 09 09 09 09 09 20 28 73 65 74 21 20 2a  ")...... (set! *
c590: 67 6c 6f 62 61 6c 65 78 69 74 73 74 61 74 75 73  globalexitstatus
c5a0: 2a 20 31 29 20 3b 3b 20 0a 09 09 09 09 09 20 28  * 1) ;; ...... (
c5b0: 70 72 6f 63 65 73 73 2d 73 69 67 6e 61 6c 20 28  process-signal (
c5c0: 63 75 72 72 65 6e 74 2d 70 72 6f 63 65 73 73 2d  current-process-
c5d0: 69 64 29 20 73 69 67 6e 61 6c 2f 6b 69 6c 6c 29  id) signal/kill)
c5e0: 0a 09 09 09 09 09 20 3b 28 65 78 69 74 20 31 29  ...... ;(exit 1)
c5f0: 0a 09 09 09 09 09 20 29 29 0a 09 09 09 09 20 20  ...... )).....  
c600: 20 28 69 66 20 28 6e 6f 74 20 6b 65 65 70 67 6f   (if (not keepgo
c610: 69 6e 67 29 0a 09 09 09 09 20 20 20 20 20 20 20  ing).....       
c620: 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74 21  (hash-table-set!
c630: 20 2a 77 61 69 74 69 6e 67 2d 71 75 65 75 65 2a   *waiting-queue*
c640: 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20 74   new-test-name t
c650: 65 73 74 72 75 6e 64 61 74 29 29 29 29 29 29 29  estrundat)))))))
c660: 0a 09 09 20 20 20 20 20 20 28 28 4b 49 4c 4c 45  ...      ((KILLE
c670: 44 29 20 0a 09 09 20 20 20 20 20 20 20 28 64 65  D) ...       (de
c680: 62 75 67 3a 70 72 69 6e 74 20 31 20 22 4e 4f 54  bug:print 1 "NOT
c690: 45 3a 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61  E: " new-test-na
c6a0: 6d 65 20 22 20 69 73 20 61 6c 72 65 61 64 79 20  me " is already 
c6b0: 72 75 6e 6e 69 6e 67 20 6f 72 20 77 61 73 20 65  running or was e
c6c0: 78 70 6c 69 63 74 6c 79 20 6b 69 6c 6c 65 64 2c  xplictly killed,
c6d0: 20 75 73 65 20 2d 66 6f 72 63 65 20 74 6f 20 6c   use -force to l
c6e0: 61 75 6e 63 68 20 69 74 2e 22 29 29 0a 09 09 20  aunch it."))... 
c6f0: 20 20 20 20 20 28 28 4c 41 55 4e 43 48 45 44 20       ((LAUNCHED 
c700: 52 45 4d 4f 54 45 48 4f 53 54 53 54 41 52 54 20  REMOTEHOSTSTART 
c710: 52 55 4e 4e 49 4e 47 29 20 20 0a 09 09 20 20 20  RUNNING)  ...   
c720: 20 20 20 20 28 69 66 20 28 3e 20 28 2d 20 28 63      (if (> (- (c
c730: 75 72 72 65 6e 74 2d 73 65 63 6f 6e 64 73 29 28  urrent-seconds)(
c740: 2b 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 65  + (db:test-get-e
c750: 76 65 6e 74 5f 74 69 6d 65 20 74 65 73 74 64 61  vent_time testda
c760: 74 29 0a 09 09 09 09 09 09 20 20 20 20 20 28 64  t).......     (d
c770: 62 3a 74 65 73 74 2d 67 65 74 2d 72 75 6e 5f 64  b:test-get-run_d
c780: 75 72 61 74 69 6f 6e 20 74 65 73 74 64 61 74 29  uration testdat)
c790: 29 29 0a 09 09 09 20 20 20 20 20 20 31 30 30 29  ))....      100)
c7a0: 20 3b 3b 20 69 2e 65 2e 20 6e 6f 20 75 70 64 61   ;; i.e. no upda
c7b0: 74 65 20 66 6f 72 20 6d 6f 72 65 20 74 68 61 6e  te for more than
c7c0: 20 31 30 30 20 73 65 63 6f 6e 64 73 0a 09 09 09   100 seconds....
c7d0: 20 20 20 28 62 65 67 69 6e 0a 09 09 09 20 20 20     (begin....   
c7e0: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30    (debug:print 0
c7f0: 20 22 57 41 52 4e 49 4e 47 3a 20 54 65 73 74 20   "WARNING: Test 
c800: 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 61 70  " test-name " ap
c810: 70 65 61 72 73 20 74 6f 20 62 65 20 64 65 61 64  pears to be dead
c820: 2e 20 46 6f 72 63 69 6e 67 20 69 74 20 74 6f 20  . Forcing it to 
c830: 73 74 61 74 65 20 49 4e 43 4f 4d 50 4c 45 54 45  state INCOMPLETE
c840: 20 61 6e 64 20 73 74 61 74 75 73 20 53 54 55 43   and status STUC
c850: 4b 2f 44 45 41 44 22 29 0a 09 09 09 20 20 20 20  K/DEAD")....    
c860: 20 28 74 65 73 74 2d 73 65 74 2d 73 74 61 74 75   (test-set-statu
c870: 73 21 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  s! db run-id tes
c880: 74 2d 6e 61 6d 65 20 22 49 4e 43 4f 4d 50 4c 45  t-name "INCOMPLE
c890: 54 45 22 20 22 53 54 55 43 4b 2f 44 45 41 44 22  TE" "STUCK/DEAD"
c8a0: 20 69 74 65 6d 64 61 74 20 22 54 65 73 74 20 69   itemdat "Test i
c8b0: 73 20 73 74 75 63 6b 20 6f 72 20 64 65 61 64 22  s stuck or dead"
c8c0: 20 23 66 29 29 0a 09 09 09 20 20 20 28 64 65 62   #f))....   (deb
c8d0: 75 67 3a 70 72 69 6e 74 20 32 20 22 4e 4f 54 45  ug:print 2 "NOTE
c8e0: 3a 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20  : " test-name " 
c8f0: 69 73 20 61 6c 72 65 61 64 79 20 72 75 6e 6e 69  is already runni
c900: 6e 67 22 29 29 29 0a 09 09 20 20 20 20 20 20 28  ng")))...      (
c910: 65 6c 73 65 20 20 20 20 20 20 20 28 64 65 62 75  else       (debu
c920: 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52  g:print 0 "ERROR
c930: 3a 20 46 61 69 6c 65 64 20 74 6f 20 6c 61 75 6e  : Failed to laun
c940: 63 68 20 74 65 73 74 20 22 20 6e 65 77 2d 74 65  ch test " new-te
c950: 73 74 2d 6e 61 6d 65 20 22 2e 20 55 6e 72 65 63  st-name ". Unrec
c960: 6f 67 6e 69 73 65 64 20 73 74 61 74 65 20 22 20  ognised state " 
c970: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20  (test:get-state 
c980: 74 65 73 74 64 61 74 29 29 29 29 29 29 0a 09 20  testdat)))))).. 
c990: 20 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28 6e       (if (not (n
c9a0: 75 6c 6c 3f 20 74 61 6c 29 29 0a 09 09 20 20 28  ull? tal))...  (
c9b0: 6c 6f 6f 70 20 28 63 61 72 20 74 61 6c 29 28 63  loop (car tal)(c
c9c0: 64 72 20 74 61 6c 29 29 29 29 29 29 29 29 29 0a  dr tal))))))))).
c9d0: 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  .;;=============
c9e0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
c9f0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
ca00: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
ca10: 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 45 4e 44  =========.;; END
ca20: 20 4f 46 20 4e 45 57 20 53 54 55 46 46 0a 3b 3b   OF NEW STUFF.;;
ca30: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
ca40: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
ca50: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
ca60: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
ca70: 3d 3d 3d 3d 3d 3d 0a 0a 28 64 65 66 69 6e 65 20  ======..(define 
ca80: 28 67 65 74 2d 64 69 72 2d 75 70 2d 6e 20 64 69  (get-dir-up-n di
ca90: 72 20 2e 20 70 61 72 61 6d 73 29 20 0a 20 20 28  r . params) .  (
caa0: 6c 65 74 20 28 28 64 70 61 72 74 73 20 20 28 73  let ((dparts  (s
cab0: 74 72 69 6e 67 2d 73 70 6c 69 74 20 64 69 72 20  tring-split dir 
cac0: 22 2f 22 29 29 0a 09 28 63 6f 75 6e 74 20 20 20  "/"))..(count   
cad0: 28 69 66 20 28 6e 75 6c 6c 3f 20 70 61 72 61 6d  (if (null? param
cae0: 73 29 20 31 20 28 63 61 72 20 70 61 72 61 6d 73  s) 1 (car params
caf0: 29 29 29 29 0a 20 20 20 20 28 63 6f 6e 63 20 22  )))).    (conc "
cb00: 2f 22 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72  /" (string-inter
cb10: 73 70 65 72 73 65 20 0a 09 20 20 20 20 20 20 20  sperse ..       
cb20: 28 74 61 6b 65 20 64 70 61 72 74 73 20 28 2d 20  (take dparts (- 
cb30: 28 6c 65 6e 67 74 68 20 64 70 61 72 74 73 29 20  (length dparts) 
cb40: 63 6f 75 6e 74 29 29 0a 09 20 20 20 20 20 20 20  count))..       
cb50: 22 2f 22 29 29 29 29 0a 3b 3b 20 52 65 6d 6f 76  "/")))).;; Remov
cb60: 65 20 72 75 6e 73 0a 3b 3b 20 66 69 65 6c 64 73  e runs.;; fields
cb70: 20 61 72 65 20 70 61 73 73 69 6e 67 20 69 6e 20   are passing in 
cb80: 74 68 72 6f 75 67 68 20 0a 28 64 65 66 69 6e 65  through .(define
cb90: 20 28 72 75 6e 73 3a 72 65 6d 6f 76 65 2d 72 75   (runs:remove-ru
cba0: 6e 73 20 64 62 20 72 75 6e 6e 61 6d 65 70 61 74  ns db runnamepat
cbb0: 74 20 74 65 73 74 70 61 74 74 20 69 74 65 6d 70  t testpatt itemp
cbc0: 61 74 74 29 0a 20 20 28 6c 65 74 2a 20 28 28 6b  att).  (let* ((k
cbd0: 65 79 73 20 20 20 20 20 20 20 20 28 64 62 2d 67  eys        (db-g
cbe0: 65 74 2d 6b 65 79 73 20 64 62 29 29 0a 09 20 28  et-keys db)).. (
cbf0: 72 75 6e 64 61 74 20 20 20 20 20 20 28 72 75 6e  rundat      (run
cc00: 73 3a 67 65 74 2d 72 75 6e 73 2d 62 79 2d 70 61  s:get-runs-by-pa
cc10: 74 74 20 64 62 20 6b 65 79 73 20 72 75 6e 6e 61  tt db keys runna
cc20: 6d 65 70 61 74 74 29 29 0a 09 20 28 68 65 61 64  mepatt)).. (head
cc30: 65 72 20 20 20 20 20 20 28 76 65 63 74 6f 72 2d  er      (vector-
cc40: 72 65 66 20 72 75 6e 64 61 74 20 30 29 29 0a 09  ref rundat 0))..
cc50: 20 28 72 75 6e 73 20 20 20 20 20 20 20 20 28 76   (runs        (v
cc60: 65 63 74 6f 72 2d 72 65 66 20 72 75 6e 64 61 74  ector-ref rundat
cc70: 20 31 29 29 29 0a 20 20 20 20 28 64 65 62 75 67   1))).    (debug
cc80: 3a 70 72 69 6e 74 20 31 20 22 48 65 61 64 65 72  :print 1 "Header
cc90: 3a 20 22 20 68 65 61 64 65 72 29 0a 20 20 20 20  : " header).    
cca0: 28 66 6f 72 2d 65 61 63 68 0a 20 20 20 20 20 28  (for-each.     (
ccb0: 6c 61 6d 62 64 61 20 28 72 75 6e 29 0a 20 20 20  lambda (run).   
ccc0: 20 20 20 20 28 6c 65 74 20 28 28 72 75 6e 6b 65      (let ((runke
ccd0: 79 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73  y (string-inters
cce0: 70 65 72 73 65 20 28 6d 61 70 20 28 6c 61 6d 62  perse (map (lamb
ccf0: 64 61 20 28 6b 29 0a 09 09 09 09 09 09 28 64 62  da (k).......(db
cd00: 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65  :get-value-by-he
cd10: 61 64 65 72 20 72 75 6e 20 68 65 61 64 65 72 20  ader run header 
cd20: 28 76 65 63 74 6f 72 2d 72 65 66 20 6b 20 30 29  (vector-ref k 0)
cd30: 29 29 20 6b 65 79 73 29 20 22 2f 22 29 29 0a 09  )) keys) "/"))..
cd40: 20 20 20 20 20 28 64 69 72 73 2d 74 6f 2d 72 65       (dirs-to-re
cd50: 6d 6f 76 65 20 28 6d 61 6b 65 2d 68 61 73 68 2d  move (make-hash-
cd60: 74 61 62 6c 65 29 29 29 0a 09 20 28 6c 65 74 2a  table))).. (let*
cd70: 20 28 28 72 75 6e 2d 69 64 20 28 64 62 3a 67 65   ((run-id (db:ge
cd80: 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65  t-value-by-heade
cd90: 72 20 72 75 6e 20 68 65 61 64 65 72 20 22 69 64  r run header "id
cda0: 22 29 20 29 0a 09 09 28 74 65 73 74 73 20 20 28  ") )...(tests  (
cdb0: 64 62 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f 72  db-get-tests-for
cdc0: 2d 72 75 6e 20 64 62 20 28 64 62 3a 67 65 74 2d  -run db (db:get-
cdd0: 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20  value-by-header 
cde0: 72 75 6e 20 68 65 61 64 65 72 20 22 69 64 22 29  run header "id")
cdf0: 20 74 65 73 74 70 61 74 74 20 69 74 65 6d 70 61   testpatt itempa
ce00: 74 74 20 27 28 29 20 27 28 29 29 29 0a 09 09 28  tt '() '()))...(
ce10: 6c 61 73 74 74 70 61 74 68 20 22 2f 64 6f 65 73  lasttpath "/does
ce20: 2f 6e 6f 74 2f 65 78 69 73 74 2f 49 2f 68 6f 70  /not/exist/I/hop
ce30: 65 22 29 29 0a 0a 09 20 20 20 28 69 66 20 28 6e  e"))...   (if (n
ce40: 6f 74 20 28 6e 75 6c 6c 3f 20 74 65 73 74 73 29  ot (null? tests)
ce50: 29 0a 09 20 20 20 20 20 20 20 28 62 65 67 69 6e  )..       (begin
ce60: 0a 09 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ... (debug:print
ce70: 20 31 20 22 52 65 6d 6f 76 69 6e 67 20 74 65 73   1 "Removing tes
ce80: 74 73 20 66 6f 72 20 72 75 6e 3a 20 22 20 72 75  ts for run: " ru
ce90: 6e 6b 65 79 20 22 20 22 20 28 64 62 3a 67 65 74  nkey " " (db:get
cea0: 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72  -value-by-header
ceb0: 20 72 75 6e 20 68 65 61 64 65 72 20 22 72 75 6e   run header "run
cec0: 6e 61 6d 65 22 29 29 0a 09 09 20 28 66 6f 72 2d  name"))... (for-
ced0: 65 61 63 68 0a 09 09 20 20 28 6c 61 6d 62 64 61  each...  (lambda
cee0: 20 28 74 65 73 74 29 0a 09 09 20 20 20 20 28 6c   (test)...    (l
cef0: 65 74 2a 20 28 28 69 74 65 6d 2d 70 61 74 68 20  et* ((item-path 
cf00: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65  (db:test-get-ite
cf10: 6d 2d 70 61 74 68 20 74 65 73 74 29 29 0a 09 09  m-path test))...
cf20: 09 20 20 20 28 74 65 73 74 2d 6e 61 6d 65 20 28  .   (test-name (
cf30: 64 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74  db:test-get-test
cf40: 6e 61 6d 65 20 74 65 73 74 29 29 0a 09 09 09 20  name test)).... 
cf50: 20 20 28 72 75 6e 2d 64 69 72 20 20 20 28 64 62    (run-dir   (db
cf60: 3a 74 65 73 74 2d 67 65 74 2d 72 75 6e 64 69 72  :test-get-rundir
cf70: 20 74 65 73 74 29 29 29 0a 09 09 20 20 20 20 20   test)))...     
cf80: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20   (debug:print 1 
cf90: 22 20 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65  "  " (db:test-ge
cfa0: 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 29  t-testname test)
cfb0: 20 22 20 69 64 3a 20 22 20 28 64 62 3a 74 65 73   " id: " (db:tes
cfc0: 74 2d 67 65 74 2d 69 64 20 74 65 73 74 29 20 22  t-get-id test) "
cfd0: 20 22 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 09   " item-path)...
cfe0: 20 20 20 20 20 20 28 64 62 3a 64 65 6c 65 74 65        (db:delete
cff0: 2d 74 65 73 74 2d 72 65 63 6f 72 64 73 20 64 62  -test-records db
d000: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64   (db:test-get-id
d010: 20 74 65 73 74 29 29 0a 09 09 20 20 20 20 20 20   test))...      
d020: 28 69 66 20 28 3e 20 28 73 74 72 69 6e 67 2d 6c  (if (> (string-l
d030: 65 6e 67 74 68 20 72 75 6e 2d 64 69 72 29 20 35  ength run-dir) 5
d040: 29 20 3b 3b 20 62 61 64 20 68 65 75 72 69 73 74  ) ;; bad heurist
d050: 69 63 20 62 75 74 20 73 68 6f 75 6c 64 20 70 72  ic but should pr
d060: 65 76 65 6e 74 20 2f 74 6d 70 20 2f 68 6f 6d 65  event /tmp /home
d070: 20 65 74 63 2e 0a 09 09 09 20 20 28 6c 65 74 20   etc.....  (let 
d080: 28 28 66 75 6c 6c 70 61 74 68 20 72 75 6e 2d 64  ((fullpath run-d
d090: 69 72 29 29 20 3b 3b 20 22 2f 22 20 28 64 62 3a  ir)) ;; "/" (db:
d0a0: 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61  test-get-item-pa
d0b0: 74 68 20 74 65 73 74 29 29 29 29 0a 09 09 09 20  th test)))).... 
d0c0: 20 20 20 28 73 65 74 21 20 6c 61 73 74 74 70 61     (set! lasttpa
d0d0: 74 68 20 66 75 6c 6c 70 61 74 68 29 0a 09 09 09  th fullpath)....
d0e0: 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d      (hash-table-
d0f0: 73 65 74 21 20 64 69 72 73 2d 74 6f 2d 72 65 6d  set! dirs-to-rem
d100: 6f 76 65 20 66 75 6c 6c 70 61 74 68 20 23 74 29  ove fullpath #t)
d110: 0a 09 09 09 20 20 20 20 3b 3b 20 54 68 65 20 66  ....    ;; The f
d120: 6f 6c 6c 6f 77 69 6e 67 20 77 61 73 20 74 68 65  ollowing was the
d130: 20 73 61 66 65 20 64 65 6c 65 74 65 20 63 6f 64   safe delete cod
d140: 65 20 62 75 74 20 69 74 20 77 61 73 20 6e 6f 74  e but it was not
d150: 20 62 65 69 6e 67 20 65 78 65 63 74 75 74 65 64   being exectuted
d160: 2e 0a 09 09 09 20 20 20 20 3b 3b 20 28 6c 65 74  .....    ;; (let
d170: 2a 20 28 28 64 69 72 73 2d 63 6f 75 6e 74 20 28  * ((dirs-count (
d180: 2b 20 31 20 28 6c 65 6e 67 74 68 20 6b 65 79 73  + 1 (length keys
d190: 29 28 6c 65 6e 67 74 68 20 28 73 74 72 69 6e 67  )(length (string
d1a0: 2d 73 70 6c 69 74 20 69 74 65 6d 2d 70 61 74 68  -split item-path
d1b0: 20 22 2f 22 29 29 29 29 0a 09 09 09 20 20 20 20   "/"))))....    
d1c0: 3b 3b 20 20 20 20 20 20 20 20 28 64 69 72 2d 74  ;;        (dir-t
d1d0: 6f 2d 72 65 6d 20 28 67 65 74 2d 64 69 72 2d 75  o-rem (get-dir-u
d1e0: 70 2d 6e 20 66 75 6c 6c 70 61 74 68 20 64 69 72  p-n fullpath dir
d1f0: 73 2d 63 6f 75 6e 74 29 29 0a 09 09 09 20 20 20  s-count))....   
d200: 20 3b 3b 20 20 20 20 20 20 20 20 28 72 65 6d 61   ;;        (rema
d210: 69 6e 69 6e 67 64 20 28 73 74 72 69 6e 67 2d 73  iningd (string-s
d220: 75 62 73 74 69 74 75 74 65 20 28 72 65 67 65 78  ubstitute (regex
d230: 70 20 28 63 6f 6e 63 20 22 5e 22 20 64 69 72 2d  p (conc "^" dir-
d240: 74 6f 2d 72 65 6d 20 22 2f 22 29 29 20 22 22 20  to-rem "/")) "" 
d250: 66 75 6c 6c 70 61 74 68 29 29 0a 09 09 09 20 20  fullpath))....  
d260: 20 20 3b 3b 20 20 20 20 20 20 20 20 28 63 6d 64    ;;        (cmd
d270: 20 28 63 6f 6e 63 20 22 63 64 20 22 20 64 69 72   (conc "cd " dir
d280: 2d 74 6f 2d 72 65 6d 20 22 3b 20 72 6d 64 69 72  -to-rem "; rmdir
d290: 20 2d 70 20 22 20 72 65 6d 61 69 6e 69 6e 67 64   -p " remainingd
d2a0: 20 29 29 29 0a 09 09 09 20 20 20 20 3b 3b 20 20   )))....    ;;  
d2b0: 20 28 69 66 20 28 66 69 6c 65 2d 65 78 69 73 74   (if (file-exist
d2c0: 73 3f 20 66 75 6c 6c 70 61 74 68 29 0a 09 09 09  s? fullpath)....
d2d0: 20 20 20 20 3b 3b 20 20 20 20 20 20 20 28 62 65      ;;       (be
d2e0: 67 69 6e 0a 09 09 09 20 20 20 20 3b 3b 20 20 20  gin....    ;;   
d2f0: 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69        (debug:pri
d300: 6e 74 20 31 20 63 6d 64 29 0a 09 09 09 20 20 20  nt 1 cmd)....   
d310: 20 3b 3b 20 20 20 20 20 20 20 20 20 28 73 79 73   ;;         (sys
d320: 74 65 6d 20 63 6d 64 29 29 29 0a 09 09 09 20 20  tem cmd)))....  
d330: 20 20 3b 3b 20 20 20 29 29 0a 09 09 09 20 20 20    ;;   ))....   
d340: 20 29 29 29 29 0a 09 09 20 20 20 20 74 65 73 74   ))))...    test
d350: 73 29 29 29 0a 0a 09 20 20 20 3b 3b 20 6c 6f 6f  s)))...   ;; loo
d360: 6b 20 74 68 6f 75 67 68 20 74 68 65 20 64 69 72  k though the dir
d370: 73 2d 74 6f 2d 72 65 6d 6f 76 65 20 66 6f 72 20  s-to-remove for 
d380: 63 61 6e 64 69 64 61 74 65 73 20 66 6f 72 20 72  candidates for r
d390: 65 6d 6f 76 61 6c 2e 20 44 6f 20 74 68 69 73 20  emoval. Do this 
d3a0: 61 66 74 65 72 20 64 65 6c 65 74 69 6e 67 20 74  after deleting t
d3b0: 68 65 20 72 65 63 6f 72 64 73 0a 09 20 20 20 3b  he records..   ;
d3c0: 3b 20 66 6f 72 20 65 61 63 68 20 74 65 73 74 20  ; for each test 
d3d0: 69 6e 20 63 61 73 65 20 77 65 20 67 65 74 20 6b  in case we get k
d3e0: 69 6c 6c 65 64 2e 20 54 68 61 74 20 73 68 6f 75  illed. That shou
d3f0: 6c 64 20 6d 69 6e 69 6d 69 7a 65 20 74 68 65 20  ld minimize the 
d400: 64 65 74 72 69 74 75 73 20 6c 65 66 74 20 6f 6e  detritus left on
d410: 20 64 69 73 6b 0a 09 20 20 20 3b 3b 20 70 72 6f   disk..   ;; pro
d420: 63 65 73 73 20 74 68 65 20 64 69 72 73 20 66 72  cess the dirs fr
d430: 6f 6d 20 6c 6f 6e 67 65 73 74 20 73 74 72 69 6e  om longest strin
d440: 67 20 6c 65 6e 67 74 68 20 74 6f 20 73 68 6f 72  g length to shor
d450: 74 65 73 74 0a 09 20 20 20 28 66 6f 72 2d 65 61  test..   (for-ea
d460: 63 68 20 0a 09 20 20 20 20 28 6c 61 6d 62 64 61  ch ..    (lambda
d470: 20 28 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29   (dir-to-remove)
d480: 0a 09 20 20 20 20 20 20 28 69 66 20 28 66 69 6c  ..      (if (fil
d490: 65 2d 65 78 69 73 74 73 3f 20 64 69 72 2d 74 6f  e-exists? dir-to
d4a0: 2d 72 65 6d 6f 76 65 29 0a 09 09 20 20 28 6c 65  -remove)...  (le
d4b0: 74 20 28 28 64 69 72 2d 69 6e 2d 64 62 20 27 28  t ((dir-in-db '(
d4c0: 29 29 29 0a 09 09 20 20 20 20 28 73 71 6c 69 74  )))...    (sqlit
d4d0: 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77 0a  e3:for-each-row.
d4e0: 09 09 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28  ..     (lambda (
d4f0: 64 69 72 29 0a 09 09 20 20 20 20 20 20 20 28 73  dir)...       (s
d500: 65 74 21 20 64 69 72 2d 69 6e 2d 64 62 20 28 63  et! dir-in-db (c
d510: 6f 6e 73 20 64 69 72 20 64 69 72 2d 69 6e 2d 64  ons dir dir-in-d
d520: 62 29 29 29 0a 09 09 20 20 20 20 20 64 62 20 22  b)))...     db "
d530: 53 45 4c 45 43 54 20 72 75 6e 64 69 72 20 46 52  SELECT rundir FR
d540: 4f 4d 20 74 65 73 74 73 20 57 48 45 52 45 20 72  OM tests WHERE r
d550: 75 6e 64 69 72 20 4c 49 4b 45 20 3f 3b 22 20 0a  undir LIKE ?;" .
d560: 09 09 20 20 20 20 20 28 63 6f 6e 63 20 22 25 22  ..     (conc "%"
d570: 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 20 22   dir-to-remove "
d580: 25 22 29 29 20 3b 3b 20 79 65 73 2c 20 49 27 6d  %")) ;; yes, I'm
d590: 20 67 6f 69 6e 67 20 74 6f 20 62 61 69 6c 20 69   going to bail i
d5a0: 66 20 74 68 65 72 65 20 69 73 20 61 6e 79 74 68  f there is anyth
d5b0: 69 6e 67 20 6c 69 6b 65 20 74 68 69 73 20 64 69  ing like this di
d5c0: 72 20 69 6e 20 74 68 65 20 64 62 0a 09 09 20 20  r in the db...  
d5d0: 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 64 69 72    (if (null? dir
d5e0: 2d 69 6e 2d 64 62 29 0a 09 09 09 28 62 65 67 69  -in-db)....(begi
d5f0: 6e 0a 09 09 09 20 20 28 64 65 62 75 67 3a 70 72  n....  (debug:pr
d600: 69 6e 74 20 32 20 22 52 65 6d 6f 76 69 6e 67 20  int 2 "Removing 
d610: 64 69 72 65 63 74 6f 72 79 20 77 69 74 68 20 7a  directory with z
d620: 65 72 6f 20 64 62 20 72 65 66 65 72 65 6e 63 65  ero db reference
d630: 73 3a 20 22 20 64 69 72 2d 74 6f 2d 72 65 6d 6f  s: " dir-to-remo
d640: 76 65 29 0a 09 09 09 20 20 28 73 79 73 74 65 6d  ve)....  (system
d650: 20 28 63 6f 6e 63 20 22 72 6d 20 2d 72 66 20 22   (conc "rm -rf "
d660: 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 29   dir-to-remove))
d670: 0a 09 09 09 20 20 28 68 61 73 68 2d 74 61 62 6c  ....  (hash-tabl
d680: 65 2d 64 65 6c 65 74 65 21 20 64 69 72 73 2d 74  e-delete! dirs-t
d690: 6f 2d 72 65 6d 6f 76 65 20 64 69 72 2d 74 6f 2d  o-remove dir-to-
d6a0: 72 65 6d 6f 76 65 29 29 0a 09 09 09 28 64 65 62  remove))....(deb
d6b0: 75 67 3a 70 72 69 6e 74 20 32 20 22 53 6b 69 70  ug:print 2 "Skip
d6c0: 70 69 6e 67 20 72 65 6d 6f 76 61 6c 20 6f 66 20  ping removal of 
d6d0: 22 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 20  " dir-to-remove 
d6e0: 22 20 66 6f 72 20 6e 6f 77 20 61 73 20 69 74 20  " for now as it 
d6f0: 73 74 69 6c 6c 20 68 61 73 20 72 65 66 65 72 65  still has refere
d700: 6e 63 65 73 20 69 6e 20 74 68 65 20 64 61 74 61  nces in the data
d710: 62 61 73 65 22 29 29 29 29 29 0a 09 20 20 20 20  base")))))..    
d720: 28 73 6f 72 74 20 28 68 61 73 68 2d 74 61 62 6c  (sort (hash-tabl
d730: 65 2d 6b 65 79 73 20 64 69 72 73 2d 74 6f 2d 72  e-keys dirs-to-r
d740: 65 6d 6f 76 65 29 20 28 6c 61 6d 62 64 61 20 28  emove) (lambda (
d750: 61 20 62 29 28 3e 20 28 73 74 72 69 6e 67 2d 6c  a b)(> (string-l
d760: 65 6e 67 74 68 20 61 29 28 73 74 72 69 6e 67 2d  ength a)(string-
d770: 6c 65 6e 67 74 68 20 62 29 29 29 29 29 0a 0a 09  length b)))))...
d780: 20 20 20 3b 3b 20 72 65 6d 6f 76 65 20 74 68 65     ;; remove the
d790: 20 72 75 6e 20 69 66 20 7a 65 72 6f 20 74 65 73   run if zero tes
d7a0: 74 73 20 72 65 6d 61 69 6e 0a 09 20 20 20 28 6c  ts remain..   (l
d7b0: 65 74 20 28 28 72 65 6d 74 65 73 74 73 20 28 64  et ((remtests (d
d7c0: 62 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d  b-get-tests-for-
d7d0: 72 75 6e 20 64 62 20 28 64 62 3a 67 65 74 2d 76  run db (db:get-v
d7e0: 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72  alue-by-header r
d7f0: 75 6e 20 68 65 61 64 65 72 20 22 69 64 22 29 20  un header "id") 
d800: 23 66 20 23 66 20 27 28 29 20 27 28 29 29 29 29  #f #f '() '())))
d810: 0a 09 20 20 20 20 20 28 69 66 20 28 6e 75 6c 6c  ..     (if (null
d820: 3f 20 72 65 6d 74 65 73 74 73 29 20 3b 3b 20 6e  ? remtests) ;; n
d830: 6f 20 6d 6f 72 65 20 74 65 73 74 73 20 72 65 6d  o more tests rem
d840: 61 69 6e 69 6e 67 0a 09 09 20 28 6c 65 74 2a 20  aining... (let* 
d850: 28 28 64 70 61 72 74 73 20 20 28 73 74 72 69 6e  ((dparts  (strin
d860: 67 2d 73 70 6c 69 74 20 6c 61 73 74 74 70 61 74  g-split lasttpat
d870: 68 20 22 2f 22 29 29 0a 09 09 09 28 72 75 6e 70  h "/"))....(runp
d880: 61 74 68 20 28 63 6f 6e 63 20 22 2f 22 20 28 73  ath (conc "/" (s
d890: 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73  tring-interspers
d8a0: 65 20 0a 09 09 09 09 09 20 20 20 20 28 74 61 6b  e ......    (tak
d8b0: 65 20 64 70 61 72 74 73 20 28 2d 20 28 6c 65 6e  e dparts (- (len
d8c0: 67 74 68 20 64 70 61 72 74 73 29 20 31 29 29 0a  gth dparts) 1)).
d8d0: 09 09 09 09 09 20 20 20 20 22 2f 22 29 29 29 29  .....    "/"))))
d8e0: 0a 09 09 20 20 20 28 64 65 62 75 67 3a 70 72 69  ...   (debug:pri
d8f0: 6e 74 20 31 20 22 52 65 6d 6f 76 69 6e 67 20 72  nt 1 "Removing r
d900: 75 6e 3a 20 22 20 72 75 6e 6b 65 79 20 22 20 22  un: " runkey " "
d910: 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62   (db:get-value-b
d920: 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61  y-header run hea
d930: 64 65 72 20 22 72 75 6e 6e 61 6d 65 22 29 29 0a  der "runname")).
d940: 09 09 20 20 20 28 64 62 3a 64 65 6c 65 74 65 2d  ..   (db:delete-
d950: 72 75 6e 20 64 62 20 72 75 6e 2d 69 64 29 0a 09  run db run-id)..
d960: 09 20 20 20 3b 3b 20 6e 65 65 64 20 74 6f 20 66  .   ;; need to f
d970: 69 67 75 72 65 20 6f 75 74 20 74 68 65 20 70 61  igure out the pa
d980: 74 68 20 74 6f 20 74 68 65 20 72 75 6e 20 64 69  th to the run di
d990: 72 20 61 6e 64 20 72 65 6d 6f 76 65 20 69 74 20  r and remove it 
d9a0: 69 66 20 65 6d 70 74 79 0a 09 09 20 20 20 3b 3b  if empty...   ;;
d9b0: 20 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 28      (if (null? (
d9c0: 67 6c 6f 62 20 28 63 6f 6e 63 20 72 75 6e 70 61  glob (conc runpa
d9d0: 74 68 20 22 2f 2a 22 29 29 29 0a 09 09 20 20 20  th "/*")))...   
d9e0: 3b 3b 20 20 20 20 20 20 20 20 28 62 65 67 69 6e  ;;        (begin
d9f0: 0a 09 09 20 20 20 3b 3b 20 09 20 28 64 65 62 75  ...   ;; . (debu
da00: 67 3a 70 72 69 6e 74 20 31 20 22 52 65 6d 6f 76  g:print 1 "Remov
da10: 69 6e 67 20 72 75 6e 20 64 69 72 20 22 20 72 75  ing run dir " ru
da20: 6e 70 61 74 68 29 0a 09 09 20 20 20 3b 3b 20 09  npath)...   ;; .
da30: 20 28 73 79 73 74 65 6d 20 28 63 6f 6e 63 20 22   (system (conc "
da40: 72 6d 64 69 72 20 2d 70 20 22 20 72 75 6e 70 61  rmdir -p " runpa
da50: 74 68 29 29 29 29 0a 09 09 20 20 20 29 29 29 29  th))))...   ))))
da60: 0a 09 20 29 29 0a 20 20 20 20 20 72 75 6e 73 29  .. )).     runs)
da70: 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ))..;;==========
da80: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
da90: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
daa0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
dab0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20  ============.;; 
dac0: 52 6f 75 74 69 6e 65 73 20 66 6f 72 20 6d 61 6e  Routines for man
dad0: 69 70 75 6c 61 74 69 6e 67 20 72 75 6e 73 0a 3b  ipulating runs.;
dae0: 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ;===============
daf0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
db00: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
db10: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
db20: 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 53 69 6e 63  =======..;; Sinc
db30: 65 20 6d 61 6e 79 20 63 61 6c 6c 73 20 74 6f 20  e many calls to 
db40: 61 20 72 75 6e 20 72 65 71 75 69 72 65 20 70 72  a run require pr
db50: 65 74 74 79 20 6d 75 63 68 20 74 68 65 20 73 61  etty much the sa
db60: 6d 65 20 73 65 74 75 70 20 0a 3b 3b 20 74 68 69  me setup .;; thi
db70: 73 20 77 72 61 70 70 65 72 20 69 73 20 75 73 65  s wrapper is use
db80: 64 20 74 6f 20 72 65 64 75 63 65 20 74 68 65 20  d to reduce the 
db90: 72 65 70 6c 69 63 61 74 69 6f 6e 20 6f 66 20 63  replication of c
dba0: 6f 64 65 0a 28 64 65 66 69 6e 65 20 28 67 65 6e  ode.(define (gen
dbb0: 65 72 61 6c 2d 72 75 6e 2d 63 61 6c 6c 20 73 77  eral-run-call sw
dbc0: 69 74 63 68 6e 61 6d 65 20 61 63 74 69 6f 6e 2d  itchname action-
dbd0: 64 65 73 63 20 70 72 6f 63 29 0a 20 20 28 69 66  desc proc).  (if
dbe0: 20 28 6e 6f 74 20 28 61 72 67 73 3a 67 65 74 2d   (not (args:get-
dbf0: 61 72 67 20 22 3a 72 75 6e 6e 61 6d 65 22 29 29  arg ":runname"))
dc00: 0a 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09 28  .      (begin..(
dc10: 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45  debug:print 0 "E
dc20: 52 52 4f 52 3a 20 4d 69 73 73 69 6e 67 20 72 65  RROR: Missing re
dc30: 71 75 69 72 65 64 20 70 61 72 61 6d 65 74 65 72  quired parameter
dc40: 20 66 6f 72 20 22 20 73 77 69 74 63 68 6e 61 6d   for " switchnam
dc50: 65 20 22 2c 20 79 6f 75 20 6d 75 73 74 20 73 70  e ", you must sp
dc60: 65 63 69 66 79 20 74 68 65 20 72 75 6e 20 6e 61  ecify the run na
dc70: 6d 65 20 77 69 74 68 20 3a 72 75 6e 6e 61 6d 65  me with :runname
dc80: 20 72 75 6e 6e 61 6d 65 22 29 0a 09 28 65 78 69   runname")..(exi
dc90: 74 20 32 29 29 0a 20 20 20 20 20 20 28 6c 65 74  t 2)).      (let
dca0: 20 28 28 64 62 20 20 20 23 66 29 0a 09 20 20 20   ((db   #f)..   
dcb0: 20 28 6b 65 79 73 20 23 66 29 29 0a 09 28 69 66   (keys #f))..(if
dcc0: 20 28 6e 6f 74 20 28 73 65 74 75 70 2d 66 6f 72   (not (setup-for
dcd0: 2d 72 75 6e 29 29 0a 09 20 20 20 20 28 62 65 67  -run))..    (beg
dce0: 69 6e 20 0a 09 20 20 20 20 20 20 28 64 65 62 75  in ..      (debu
dcf0: 67 3a 70 72 69 6e 74 20 30 20 22 46 61 69 6c 65  g:print 0 "Faile
dd00: 64 20 74 6f 20 73 65 74 75 70 2c 20 65 78 69 74  d to setup, exit
dd10: 69 6e 67 22 29 0a 09 20 20 20 20 20 20 28 65 78  ing")..      (ex
dd20: 69 74 20 31 29 29 29 0a 09 28 73 65 74 21 20 64  it 1)))..(set! d
dd30: 62 20 20 20 28 6f 70 65 6e 2d 64 62 29 29 0a 09  b   (open-db))..
dd40: 28 73 65 74 21 20 6b 65 79 73 20 28 64 62 2d 67  (set! keys (db-g
dd50: 65 74 2d 6b 65 79 73 20 64 62 29 29 0a 09 3b 3b  et-keys db))..;;
dd60: 20 68 61 76 65 20 65 6e 6f 75 67 68 20 74 6f 20   have enough to 
dd70: 70 72 6f 63 65 73 73 20 2d 74 61 72 67 65 74 20  process -target 
dd80: 6f 72 20 2d 72 65 71 74 61 72 67 20 68 65 72 65  or -reqtarg here
dd90: 0a 09 28 69 66 20 28 61 72 67 73 3a 67 65 74 2d  ..(if (args:get-
dda0: 61 72 67 20 22 2d 72 65 71 74 61 72 67 22 29 0a  arg "-reqtarg").
ddb0: 09 20 20 20 20 28 6c 65 74 2a 20 28 28 72 75 6e  .    (let* ((run
ddc0: 63 6f 6e 66 69 67 66 20 28 63 6f 6e 63 20 20 2a  configf (conc  *
ddd0: 74 6f 70 70 61 74 68 2a 20 22 2f 72 75 6e 63 6f  toppath* "/runco
dde0: 6e 66 69 67 73 2e 63 6f 6e 66 69 67 22 29 29 20  nfigs.config")) 
ddf0: 3b 3b 20 44 4f 20 4e 4f 54 20 45 56 41 4c 55 41  ;; DO NOT EVALUA
de00: 54 45 20 41 4c 4c 20 0a 09 09 20 20 20 28 72 75  TE ALL ...   (ru
de10: 6e 63 6f 6e 66 69 67 20 20 28 72 65 61 64 2d 63  nconfig  (read-c
de20: 6f 6e 66 69 67 20 72 75 6e 63 6f 6e 66 69 67 66  onfig runconfigf
de30: 20 23 66 20 23 66 20 65 6e 76 69 72 6f 6e 2d 70   #f #f environ-p
de40: 61 74 74 3a 20 23 66 29 29 29 20 0a 09 20 20 20  att: #f))) ..   
de50: 20 20 20 28 69 66 20 28 68 61 73 68 2d 74 61 62     (if (hash-tab
de60: 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 72  le-ref/default r
de70: 75 6e 63 6f 6e 66 69 67 20 28 61 72 67 73 3a 67  unconfig (args:g
de80: 65 74 2d 61 72 67 20 22 2d 72 65 71 74 61 72 67  et-arg "-reqtarg
de90: 22 29 20 23 66 29 0a 09 09 20 20 28 6b 65 79 73  ") #f)...  (keys
dea0: 3a 74 61 72 67 65 74 2d 73 65 74 2d 61 72 67 73  :target-set-args
deb0: 20 6b 65 79 73 20 28 61 72 67 73 3a 67 65 74 2d   keys (args:get-
dec0: 61 72 67 20 22 2d 72 65 71 74 61 72 67 22 29 20  arg "-reqtarg") 
ded0: 61 72 67 73 3a 61 72 67 2d 68 61 73 68 29 0a 09  args:arg-hash)..
dee0: 09 20 20 28 62 65 67 69 6e 0a 09 09 20 20 20 20  .  (begin...    
def0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
df00: 45 52 52 4f 52 3a 20 5b 22 20 28 61 72 67 73 3a  ERROR: [" (args:
df10: 67 65 74 2d 61 72 67 20 22 2d 72 65 71 74 61 72  get-arg "-reqtar
df20: 67 22 29 20 22 5d 20 6e 6f 74 20 66 6f 75 6e 64  g") "] not found
df30: 20 69 6e 20 22 20 72 75 6e 63 6f 6e 66 69 67 66   in " runconfigf
df40: 29 0a 09 09 20 20 20 20 28 73 71 6c 69 74 65 33  )...    (sqlite3
df50: 3a 66 69 6e 61 6c 69 7a 65 21 20 64 62 29 0a 09  :finalize! db)..
df60: 09 20 20 20 20 28 65 78 69 74 20 31 29 29 29 29  .    (exit 1))))
df70: 0a 09 20 20 20 20 28 69 66 20 28 61 72 67 73 3a  ..    (if (args:
df80: 67 65 74 2d 61 72 67 20 22 2d 74 61 72 67 65 74  get-arg "-target
df90: 22 29 0a 09 09 28 6b 65 79 73 3a 74 61 72 67 65  ")...(keys:targe
dfa0: 74 2d 73 65 74 2d 61 72 67 73 20 6b 65 79 73 20  t-set-args keys 
dfb0: 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d  (args:get-arg "-
dfc0: 74 61 72 67 65 74 22 20 61 72 67 73 3a 61 72 67  target" args:arg
dfd0: 2d 68 61 73 68 29 20 61 72 67 73 3a 61 72 67 2d  -hash) args:arg-
dfe0: 68 61 73 68 29 29 29 0a 09 28 69 66 20 28 6e 6f  hash)))..(if (no
dff0: 74 20 28 63 61 72 20 2a 63 6f 6e 66 69 67 69 6e  t (car *configin
e000: 66 6f 2a 29 29 0a 09 20 20 20 20 28 62 65 67 69  fo*))..    (begi
e010: 6e 0a 09 20 20 20 20 20 20 28 64 65 62 75 67 3a  n..      (debug:
e020: 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20  print 0 "ERROR: 
e030: 41 74 74 65 6d 70 74 65 64 20 74 6f 20 22 20 61  Attempted to " a
e040: 63 74 69 6f 6e 2d 64 65 73 63 20 22 20 62 75 74  ction-desc " but
e050: 20 72 75 6e 20 61 72 65 61 20 63 6f 6e 66 69 67   run area config
e060: 20 66 69 6c 65 20 6e 6f 74 20 66 6f 75 6e 64 22   file not found"
e070: 29 0a 09 20 20 20 20 20 20 28 65 78 69 74 20 31  )..      (exit 1
e080: 29 29 0a 09 20 20 20 20 3b 3b 20 45 78 74 72 61  ))..    ;; Extra
e090: 63 74 20 6f 75 74 20 73 74 75 66 66 20 6e 65 65  ct out stuff nee
e0a0: 64 65 64 20 69 6e 20 6d 6f 73 74 20 6f 72 20 6d  ded in most or m
e0b0: 61 6e 79 20 63 61 6c 6c 73 0a 09 20 20 20 20 3b  any calls..    ;
e0c0: 3b 20 68 65 72 65 20 74 68 65 6e 20 63 61 6c 6c  ; here then call
e0d0: 20 70 72 6f 63 0a 09 20 20 20 20 28 6c 65 74 2a   proc..    (let*
e0e0: 20 28 28 6b 65 79 6e 61 6d 65 73 20 20 20 28 6d   ((keynames   (m
e0f0: 61 70 20 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64  ap key:get-field
e100: 6e 61 6d 65 20 6b 65 79 73 29 29 0a 09 09 20 20  name keys))...  
e110: 20 28 6b 65 79 76 61 6c 6c 73 74 20 20 28 6b 65   (keyvallst  (ke
e120: 79 73 2d 3e 76 61 6c 6c 69 73 74 20 6b 65 79 73  ys->vallist keys
e130: 20 23 74 29 29 29 0a 09 20 20 20 20 20 20 28 70   #t)))..      (p
e140: 72 6f 63 20 64 62 20 6b 65 79 73 20 6b 65 79 6e  roc db keys keyn
e150: 61 6d 65 73 20 6b 65 79 76 61 6c 6c 73 74 29 29  ames keyvallst))
e160: 29 0a 09 28 73 71 6c 69 74 65 33 3a 66 69 6e 61  )..(sqlite3:fina
e170: 6c 69 7a 65 21 20 64 62 29 0a 09 28 73 65 74 21  lize! db)..(set!
e180: 20 2a 64 69 64 73 6f 6d 65 74 68 69 6e 67 2a 20   *didsomething* 
e190: 23 74 29 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d  #t))))..;;======
e1a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
e1b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
e1c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
e1d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
e1e0: 0a 3b 3b 20 52 6f 6c 6c 75 70 20 72 75 6e 73 0a  .;; Rollup runs.
e1f0: 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ;;==============
e200: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
e210: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
e220: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
e230: 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 55 70 64  ========..;; Upd
e240: 61 74 65 20 74 68 65 20 74 65 73 74 5f 6d 65 74  ate the test_met
e250: 61 20 74 61 62 6c 65 20 66 6f 72 20 74 68 69 73  a table for this
e260: 20 74 65 73 74 0a 28 64 65 66 69 6e 65 20 28 72   test.(define (r
e270: 75 6e 73 3a 75 70 64 61 74 65 2d 74 65 73 74 5f  uns:update-test_
e280: 6d 65 74 61 20 64 62 20 74 65 73 74 2d 6e 61 6d  meta db test-nam
e290: 65 20 74 65 73 74 2d 63 6f 6e 66 29 0a 20 20 28  e test-conf).  (
e2a0: 6c 65 74 20 28 28 63 75 72 72 72 65 63 6f 72 64  let ((currrecord
e2b0: 20 28 64 62 3a 74 65 73 74 6d 65 74 61 2d 67 65   (db:testmeta-ge
e2c0: 74 2d 72 65 63 6f 72 64 20 64 62 20 74 65 73 74  t-record db test
e2d0: 2d 6e 61 6d 65 29 29 29 0a 20 20 20 20 28 69 66  -name))).    (if
e2e0: 20 28 6e 6f 74 20 63 75 72 72 72 65 63 6f 72 64   (not currrecord
e2f0: 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 28 73 65  )..(begin..  (se
e300: 74 21 20 63 75 72 72 72 65 63 6f 72 64 20 28 6d  t! currrecord (m
e310: 61 6b 65 2d 76 65 63 74 6f 72 20 31 30 20 23 66  ake-vector 10 #f
e320: 29 29 0a 09 20 20 28 64 62 3a 74 65 73 74 6d 65  ))..  (db:testme
e330: 74 61 2d 61 64 64 2d 72 65 63 6f 72 64 20 64 62  ta-add-record db
e340: 20 74 65 73 74 2d 6e 61 6d 65 29 29 29 0a 20 20   test-name))).  
e350: 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 20 20    (for-each .   
e360: 20 20 28 6c 61 6d 62 64 61 20 28 6b 65 79 29 0a    (lambda (key).
e370: 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28 28 69         (let* ((i
e380: 64 78 20 28 63 61 64 72 20 6b 65 79 29 29 0a 09  dx (cadr key))..
e390: 20 20 20 20 20 20 28 66 6c 64 20 28 63 61 72 20        (fld (car 
e3a0: 20 6b 65 79 29 29 0a 09 20 20 20 20 20 20 28 76   key))..      (v
e3b0: 61 6c 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75  al (config-looku
e3c0: 70 20 74 65 73 74 2d 63 6f 6e 66 20 22 74 65 73  p test-conf "tes
e3d0: 74 5f 6d 65 74 61 22 20 66 6c 64 29 29 29 0a 09  t_meta" fld)))..
e3e0: 20 28 69 66 20 28 61 6e 64 20 76 61 6c 20 28 6e   (if (and val (n
e3f0: 6f 74 20 28 65 71 75 61 6c 3f 20 28 76 65 63 74  ot (equal? (vect
e400: 6f 72 2d 72 65 66 20 63 75 72 72 72 65 63 6f 72  or-ref currrecor
e410: 64 20 69 64 78 29 20 76 61 6c 29 29 29 0a 09 20  d idx) val))).. 
e420: 20 20 20 20 28 62 65 67 69 6e 0a 09 20 20 20 20      (begin..    
e430: 20 20 20 28 70 72 69 6e 74 20 22 55 70 64 61 74     (print "Updat
e440: 69 6e 67 20 22 20 74 65 73 74 2d 6e 61 6d 65 20  ing " test-name 
e450: 22 20 22 20 66 6c 64 20 22 20 74 6f 20 22 20 76  " " fld " to " v
e460: 61 6c 29 0a 09 20 20 20 20 20 20 20 28 64 62 3a  al)..       (db:
e470: 74 65 73 74 6d 65 74 61 2d 75 70 64 61 74 65 2d  testmeta-update-
e480: 66 69 65 6c 64 20 64 62 20 74 65 73 74 2d 6e 61  field db test-na
e490: 6d 65 20 66 6c 64 20 76 61 6c 29 29 29 29 29 0a  me fld val))))).
e4a0: 20 20 20 20 20 27 28 28 22 61 75 74 68 6f 72 22       '(("author"
e4b0: 20 32 29 28 22 6f 77 6e 65 72 22 20 33 29 28 22   2)("owner" 3)("
e4c0: 64 65 73 63 72 69 70 74 69 6f 6e 22 20 34 29 28  description" 4)(
e4d0: 22 72 65 76 69 65 77 65 64 22 20 35 29 28 22 74  "reviewed" 5)("t
e4e0: 61 67 73 22 20 39 29 29 29 29 29 0a 0a 3b 3b 20  ags" 9)))))..;; 
e4f0: 55 70 64 61 74 65 20 74 65 73 74 5f 6d 65 74 61  Update test_meta
e500: 20 66 6f 72 20 61 6c 6c 20 74 65 73 74 73 0a 28   for all tests.(
e510: 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 75 70 64  define (runs:upd
e520: 61 74 65 2d 61 6c 6c 2d 74 65 73 74 5f 6d 65 74  ate-all-test_met
e530: 61 20 64 62 29 0a 20 20 28 6c 65 74 20 28 28 74  a db).  (let ((t
e540: 65 73 74 2d 6e 61 6d 65 73 20 28 67 65 74 2d 61  est-names (get-a
e550: 6c 6c 2d 6c 65 67 61 6c 2d 74 65 73 74 73 29 29  ll-legal-tests))
e560: 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20  ).    (for-each 
e570: 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 74  .     (lambda (t
e580: 65 73 74 2d 6e 61 6d 65 29 0a 20 20 20 20 20 20  est-name).      
e590: 20 28 6c 65 74 2a 20 28 28 74 65 73 74 2d 70 61   (let* ((test-pa
e5a0: 74 68 20 20 20 20 28 63 6f 6e 63 20 2a 74 6f 70  th    (conc *top
e5b0: 70 61 74 68 2a 20 22 2f 74 65 73 74 73 2f 22 20  path* "/tests/" 
e5c0: 74 65 73 74 2d 6e 61 6d 65 29 29 0a 09 20 20 20  test-name))..   
e5d0: 20 20 20 28 74 65 73 74 2d 63 6f 6e 66 69 67 66     (test-configf
e5e0: 20 28 63 6f 6e 63 20 74 65 73 74 2d 70 61 74 68   (conc test-path
e5f0: 20 22 2f 74 65 73 74 63 6f 6e 66 69 67 22 29 29   "/testconfig"))
e600: 0a 09 20 20 20 20 20 20 28 74 65 73 74 65 78 69  ..      (testexi
e610: 73 74 73 20 20 20 28 61 6e 64 20 28 66 69 6c 65  sts   (and (file
e620: 2d 65 78 69 73 74 73 3f 20 74 65 73 74 2d 63 6f  -exists? test-co
e630: 6e 66 69 67 66 29 28 66 69 6c 65 2d 72 65 61 64  nfigf)(file-read
e640: 2d 61 63 63 65 73 73 3f 20 74 65 73 74 2d 63 6f  -access? test-co
e650: 6e 66 69 67 66 29 29 29 0a 09 20 20 20 20 20 20  nfigf)))..      
e660: 3b 3b 20 72 65 61 64 20 63 6f 6e 66 69 67 73 20  ;; read configs 
e670: 77 69 74 68 20 74 72 69 63 6b 73 20 74 75 72 6e  with tricks turn
e680: 65 64 20 6f 66 66 20 28 69 2e 65 2e 20 6e 6f 20  ed off (i.e. no 
e690: 73 79 73 74 65 6d 29 0a 09 20 20 20 20 20 20 28  system)..      (
e6a0: 74 65 73 74 2d 63 6f 6e 66 20 20 20 20 28 69 66  test-conf    (if
e6b0: 20 74 65 73 74 65 78 69 73 74 73 20 28 72 65 61   testexists (rea
e6c0: 64 2d 63 6f 6e 66 69 67 20 74 65 73 74 2d 63 6f  d-config test-co
e6d0: 6e 66 69 67 66 20 23 66 20 23 66 29 28 6d 61 6b  nfigf #f #f)(mak
e6e0: 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29 29 29  e-hash-table))))
e6f0: 0a 09 20 28 72 75 6e 73 3a 75 70 64 61 74 65 2d  .. (runs:update-
e700: 74 65 73 74 5f 6d 65 74 61 20 64 62 20 74 65 73  test_meta db tes
e710: 74 2d 6e 61 6d 65 20 74 65 73 74 2d 63 6f 6e 66  t-name test-conf
e720: 29 29 29 0a 20 20 20 20 20 74 65 73 74 2d 6e 61  ))).     test-na
e730: 6d 65 73 29 29 29 0a 0a 3b 3b 20 54 68 69 73 20  mes)))..;; This 
e740: 63 6f 75 6c 64 20 70 72 6f 62 61 62 6c 79 20 62  could probably b
e750: 65 20 72 65 66 61 63 74 6f 72 65 64 20 69 6e 74  e refactored int
e760: 6f 20 6f 6e 65 20 63 6f 6d 70 6c 65 78 20 71 75  o one complex qu
e770: 65 72 79 20 2e 2e 2e 0a 28 64 65 66 69 6e 65 20  ery ....(define 
e780: 28 72 75 6e 73 3a 72 6f 6c 6c 75 70 2d 72 75 6e  (runs:rollup-run
e790: 20 64 62 20 6b 65 79 73 20 6b 65 79 76 61 6c 6c   db keys keyvall
e7a0: 73 74 20 72 75 6e 6e 61 6d 65 20 75 73 65 72 29  st runname user)
e7b0: 20 3b 3b 20 77 61 73 20 74 61 72 67 65 74 2c 20   ;; was target, 
e7c0: 6e 6f 77 20 6b 65 79 76 61 6c 6c 73 74 0a 20 20  now keyvallst.  
e7d0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22  (debug:print 4 "
e7e0: 72 75 6e 73 3a 72 6f 6c 6c 75 70 2d 72 75 6e 2c  runs:rollup-run,
e7f0: 20 6b 65 79 73 3a 20 22 20 6b 65 79 73 20 22 20   keys: " keys " 
e800: 6b 65 79 76 61 6c 6c 73 74 3a 20 22 20 6b 65 79  keyvallst: " key
e810: 76 61 6c 6c 73 74 20 22 20 3a 72 75 6e 6e 61 6d  vallst " :runnam
e820: 65 20 22 20 72 75 6e 6e 61 6d 65 20 22 20 75 73  e " runname " us
e830: 65 72 3a 20 22 20 75 73 65 72 29 0a 20 20 28 6c  er: " user).  (l
e840: 65 74 2a 20 28 3b 20 28 6b 65 79 76 61 6c 6c 6c  et* (; (keyvalll
e850: 73 74 20 20 20 20 20 20 28 6b 65 79 73 3a 74 61  st      (keys:ta
e860: 72 67 65 74 2d 3e 6b 65 79 76 61 6c 20 6b 65 79  rget->keyval key
e870: 73 20 74 61 72 67 65 74 29 29 0a 09 20 28 6e 65  s target)).. (ne
e880: 77 2d 72 75 6e 2d 69 64 20 20 20 20 20 20 28 72  w-run-id      (r
e890: 75 6e 73 3a 72 65 67 69 73 74 65 72 2d 72 75 6e  uns:register-run
e8a0: 20 64 62 20 6b 65 79 73 20 6b 65 79 76 61 6c 6c   db keys keyvall
e8b0: 73 74 20 72 75 6e 6e 61 6d 65 20 22 6e 65 77 22  st runname "new"
e8c0: 20 22 6e 2f 61 22 20 75 73 65 72 29 29 0a 09 20   "n/a" user)).. 
e8d0: 28 70 72 65 76 2d 74 65 73 74 73 20 20 20 20 20  (prev-tests     
e8e0: 20 28 74 65 73 74 3a 67 65 74 2d 6d 61 74 63 68   (test:get-match
e8f0: 69 6e 67 2d 70 72 65 76 69 6f 75 73 2d 74 65 73  ing-previous-tes
e900: 74 2d 72 75 6e 2d 72 65 63 6f 72 64 73 20 64 62  t-run-records db
e910: 20 6e 65 77 2d 72 75 6e 2d 69 64 20 22 25 22 20   new-run-id "%" 
e920: 22 25 22 29 29 0a 09 20 28 63 75 72 72 2d 74 65  "%")).. (curr-te
e930: 73 74 73 20 20 20 20 20 20 28 64 62 2d 67 65 74  sts      (db-get
e940: 2d 74 65 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64  -tests-for-run d
e950: 62 20 6e 65 77 2d 72 75 6e 2d 69 64 20 22 25 22  b new-run-id "%"
e960: 20 22 25 22 20 27 28 29 20 27 28 29 29 29 0a 09   "%" '() '()))..
e970: 20 28 63 75 72 72 2d 74 65 73 74 73 2d 68 61 73   (curr-tests-has
e980: 68 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62  h (make-hash-tab
e990: 6c 65 29 29 29 0a 20 20 20 20 28 64 62 3a 75 70  le))).    (db:up
e9a0: 64 61 74 65 2d 72 75 6e 2d 65 76 65 6e 74 5f 74  date-run-event_t
e9b0: 69 6d 65 20 64 62 20 6e 65 77 2d 72 75 6e 2d 69  ime db new-run-i
e9c0: 64 29 0a 20 20 20 20 3b 3b 20 69 6e 64 65 78 20  d).    ;; index 
e9d0: 74 68 65 20 61 6c 72 65 61 64 79 20 73 61 76 65  the already save
e9e0: 64 20 74 65 73 74 73 20 62 79 20 74 65 73 74 6e  d tests by testn
e9f0: 61 6d 65 20 61 6e 64 20 69 74 65 6d 70 61 74 68  ame and itempath
ea00: 20 69 6e 20 63 75 72 72 2d 74 65 73 74 73 2d 68   in curr-tests-h
ea10: 61 73 68 0a 20 20 20 20 28 66 6f 72 2d 65 61 63  ash.    (for-eac
ea20: 68 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28  h.     (lambda (
ea30: 74 65 73 74 64 61 74 29 0a 20 20 20 20 20 20 20  testdat).       
ea40: 28 6c 65 74 2a 20 28 28 74 65 73 74 6e 61 6d 65  (let* ((testname
ea50: 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 74    (db:test-get-t
ea60: 65 73 74 6e 61 6d 65 20 74 65 73 74 64 61 74 29  estname testdat)
ea70: 29 0a 09 20 20 20 20 20 20 28 69 74 65 6d 2d 70  )..      (item-p
ea80: 61 74 68 20 28 64 62 3a 74 65 73 74 2d 67 65 74  ath (db:test-get
ea90: 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 64  -item-path testd
eaa0: 61 74 29 29 0a 09 20 20 20 20 20 20 28 66 75 6c  at))..      (ful
eab0: 6c 2d 6e 61 6d 65 20 28 63 6f 6e 63 20 74 65 73  l-name (conc tes
eac0: 74 6e 61 6d 65 20 22 2f 22 20 69 74 65 6d 2d 70  tname "/" item-p
ead0: 61 74 68 29 29 29 0a 09 20 28 68 61 73 68 2d 74  ath))).. (hash-t
eae0: 61 62 6c 65 2d 73 65 74 21 20 63 75 72 72 2d 74  able-set! curr-t
eaf0: 65 73 74 73 2d 68 61 73 68 20 66 75 6c 6c 2d 6e  ests-hash full-n
eb00: 61 6d 65 20 74 65 73 74 64 61 74 29 29 29 0a 20  ame testdat))). 
eb10: 20 20 20 20 63 75 72 72 2d 74 65 73 74 73 29 0a      curr-tests).
eb20: 20 20 20 20 3b 3b 20 4e 4f 50 45 3a 20 4e 6f 6e      ;; NOPE: Non
eb30: 2d 6f 70 74 69 6d 61 6c 20 61 70 70 72 6f 61 63  -optimal approac
eb40: 68 2e 20 54 72 79 20 74 68 69 73 20 69 6e 73 74  h. Try this inst
eb50: 65 61 64 2e 0a 20 20 20 20 3b 3b 20 20 20 31 2e  ead..    ;;   1.
eb60: 20 74 65 73 74 73 20 61 72 65 20 72 65 63 65 69   tests are recei
eb70: 76 65 64 20 69 6e 20 61 20 6c 69 73 74 2c 20 6d  ved in a list, m
eb80: 6f 73 74 20 72 65 63 65 6e 74 20 66 69 72 73 74  ost recent first
eb90: 0a 20 20 20 20 3b 3b 20 20 20 32 2e 20 72 65 70  .    ;;   2. rep
eba0: 6c 61 63 65 20 74 68 65 20 72 6f 6c 6c 75 70 20  lace the rollup 
ebb0: 74 65 73 74 20 77 69 74 68 20 74 68 65 20 6e 65  test with the ne
ebc0: 77 20 2a 61 6c 77 61 79 73 2a 0a 20 20 20 20 28  w *always*.    (
ebd0: 66 6f 72 2d 65 61 63 68 20 0a 20 20 20 20 20 28  for-each .     (
ebe0: 6c 61 6d 62 64 61 20 28 74 65 73 74 64 61 74 29  lambda (testdat)
ebf0: 0a 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28 28  .       (let* ((
ec00: 74 65 73 74 6e 61 6d 65 20 20 28 64 62 3a 74 65  testname  (db:te
ec10: 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20  st-get-testname 
ec20: 74 65 73 74 64 61 74 29 29 0a 09 20 20 20 20 20  testdat))..     
ec30: 20 28 69 74 65 6d 2d 70 61 74 68 20 28 64 62 3a   (item-path (db:
ec40: 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61  test-get-item-pa
ec50: 74 68 20 74 65 73 74 64 61 74 29 29 0a 09 20 20  th testdat))..  
ec60: 20 20 20 20 28 66 75 6c 6c 2d 6e 61 6d 65 20 28      (full-name (
ec70: 63 6f 6e 63 20 74 65 73 74 6e 61 6d 65 20 22 2f  conc testname "/
ec80: 22 20 69 74 65 6d 2d 70 61 74 68 29 29 0a 09 20  " item-path)).. 
ec90: 20 20 20 20 20 28 70 72 65 76 2d 74 65 73 74 2d       (prev-test-
eca0: 64 61 74 20 28 68 61 73 68 2d 74 61 62 6c 65 2d  dat (hash-table-
ecb0: 72 65 66 2f 64 65 66 61 75 6c 74 20 63 75 72 72  ref/default curr
ecc0: 2d 74 65 73 74 73 2d 68 61 73 68 20 66 75 6c 6c  -tests-hash full
ecd0: 2d 6e 61 6d 65 20 23 66 29 29 0a 09 20 20 20 20  -name #f))..    
ece0: 20 20 28 74 65 73 74 2d 73 74 65 70 73 20 20 20    (test-steps   
ecf0: 20 20 20 28 64 62 3a 67 65 74 2d 73 74 65 70 73     (db:get-steps
ed00: 2d 66 6f 72 2d 74 65 73 74 20 64 62 20 28 64 62  -for-test db (db
ed10: 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73  :test-get-id tes
ed20: 74 64 61 74 29 29 29 0a 09 20 20 20 20 20 20 28  tdat)))..      (
ed30: 6e 65 77 2d 74 65 73 74 2d 72 65 63 6f 72 64 20  new-test-record 
ed40: 23 66 29 29 0a 09 20 3b 3b 20 72 65 70 6c 61 63  #f)).. ;; replac
ed50: 65 20 74 68 65 73 65 20 77 69 74 68 20 69 6e 73  e these with ins
ed60: 65 72 74 20 2e 2e 2e 20 73 65 6c 65 63 74 0a 09  ert ... select..
ed70: 20 28 61 70 70 6c 79 20 73 71 6c 69 74 65 33 3a   (apply sqlite3:
ed80: 65 78 65 63 75 74 65 20 0a 09 09 64 62 20 0a 09  execute ...db ..
ed90: 09 28 63 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f  .(conc "INSERT O
eda0: 52 20 52 45 50 4c 41 43 45 20 49 4e 54 4f 20 74  R REPLACE INTO t
edb0: 65 73 74 73 20 28 72 75 6e 5f 69 64 2c 74 65 73  ests (run_id,tes
edc0: 74 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 61 74  tname,state,stat
edd0: 75 73 2c 65 76 65 6e 74 5f 74 69 6d 65 2c 68 6f  us,event_time,ho
ede0: 73 74 2c 63 70 75 6c 6f 61 64 2c 64 69 73 6b 66  st,cpuload,diskf
edf0: 72 65 65 2c 75 6e 61 6d 65 2c 72 75 6e 64 69 72  ree,uname,rundir
ee00: 2c 69 74 65 6d 5f 70 61 74 68 2c 72 75 6e 5f 64  ,item_path,run_d
ee10: 75 72 61 74 69 6f 6e 2c 66 69 6e 61 6c 5f 6c 6f  uration,final_lo
ee20: 67 66 2c 63 6f 6d 6d 65 6e 74 29 20 22 0a 09 09  gf,comment) "...
ee30: 20 20 20 20 20 20 22 56 41 4c 55 45 53 20 28 3f        "VALUES (?
ee40: 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f  ,?,?,?,?,?,?,?,?
ee50: 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 29 3b 22 29 0a 09  ,?,?,?,?,?);")..
ee60: 09 6e 65 77 2d 72 75 6e 2d 69 64 20 28 63 64 64  .new-run-id (cdd
ee70: 72 20 28 76 65 63 74 6f 72 2d 3e 6c 69 73 74 20  r (vector->list 
ee80: 74 65 73 74 64 61 74 29 29 29 0a 09 20 28 73 65  testdat))).. (se
ee90: 74 21 20 6e 65 77 2d 74 65 73 74 64 61 74 20 28  t! new-testdat (
eea0: 63 61 72 20 28 64 62 2d 67 65 74 2d 74 65 73 74  car (db-get-test
eeb0: 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 6e 65 77  s-for-run db new
eec0: 2d 72 75 6e 2d 69 64 20 74 65 73 74 6e 61 6d 65  -run-id testname
eed0: 20 69 74 65 6d 2d 70 61 74 68 20 27 28 29 20 27   item-path '() '
eee0: 28 29 29 29 29 0a 09 20 28 68 61 73 68 2d 74 61  ()))).. (hash-ta
eef0: 62 6c 65 2d 73 65 74 21 20 63 75 72 72 2d 74 65  ble-set! curr-te
ef00: 73 74 73 2d 68 61 73 68 20 66 75 6c 6c 2d 6e 61  sts-hash full-na
ef10: 6d 65 20 6e 65 77 2d 74 65 73 74 64 61 74 29 20  me new-testdat) 
ef20: 3b 3b 20 74 68 69 73 20 63 6f 75 6c 64 20 62 65  ;; this could be
ef30: 20 63 6f 6e 66 75 73 69 6e 67 2c 20 77 68 69 63   confusing, whic
ef40: 68 20 72 65 63 6f 72 64 20 73 68 6f 75 6c 64 20  h record should 
ef50: 67 6f 20 69 6e 74 6f 20 74 68 65 20 6c 6f 6f 6b  go into the look
ef60: 75 70 20 74 61 62 6c 65 3f 0a 09 20 3b 3b 20 4e  up table?.. ;; N
ef70: 6f 77 20 64 75 70 6c 69 63 61 74 65 20 74 68 65  ow duplicate the
ef80: 20 74 65 73 74 20 73 74 65 70 73 0a 09 20 28 64   test steps.. (d
ef90: 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 43 6f  ebug:print 4 "Co
efa0: 70 79 69 6e 67 20 72 65 63 6f 72 64 73 20 69 6e  pying records in
efb0: 20 74 65 73 74 5f 73 74 65 70 73 20 66 72 6f 6d   test_steps from
efc0: 20 74 65 73 74 5f 69 64 3d 22 20 28 64 62 3a 74   test_id=" (db:t
efd0: 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74 64  est-get-id testd
efe0: 61 74 29 20 22 20 74 6f 20 22 20 28 64 62 3a 74  at) " to " (db:t
eff0: 65 73 74 2d 67 65 74 2d 69 64 20 6e 65 77 2d 74  est-get-id new-t
f000: 65 73 74 64 61 74 29 29 0a 09 20 28 73 71 6c 69  estdat)).. (sqli
f010: 74 65 33 3a 65 78 65 63 75 74 65 20 0a 09 20 20  te3:execute ..  
f020: 64 62 20 0a 09 20 20 28 63 6f 6e 63 20 22 49 4e  db ..  (conc "IN
f030: 53 45 52 54 20 4f 52 20 52 45 50 4c 41 43 45 20  SERT OR REPLACE 
f040: 49 4e 54 4f 20 74 65 73 74 5f 73 74 65 70 73 20  INTO test_steps 
f050: 28 74 65 73 74 5f 69 64 2c 73 74 65 70 6e 61 6d  (test_id,stepnam
f060: 65 2c 73 74 61 74 65 2c 73 74 61 74 75 73 2c 65  e,state,status,e
f070: 76 65 6e 74 5f 74 69 6d 65 2c 63 6f 6d 6d 65 6e  vent_time,commen
f080: 74 29 20 22 0a 09 09 22 53 45 4c 45 43 54 20 22  t) "..."SELECT "
f090: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64   (db:test-get-id
f0a0: 20 6e 65 77 2d 74 65 73 74 64 61 74 29 20 22 2c   new-testdat) ",
f0b0: 73 74 65 70 6e 61 6d 65 2c 73 74 61 74 65 2c 73  stepname,state,s
f0c0: 74 61 74 75 73 2c 65 76 65 6e 74 5f 74 69 6d 65  tatus,event_time
f0d0: 2c 63 6f 6d 6d 65 6e 74 20 46 52 4f 4d 20 74 65  ,comment FROM te
f0e0: 73 74 5f 73 74 65 70 73 20 57 48 45 52 45 20 74  st_steps WHERE t
f0f0: 65 73 74 5f 69 64 3d 3f 3b 22 29 0a 09 20 20 28  est_id=?;")..  (
f100: 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74  db:test-get-id t
f110: 65 73 74 64 61 74 29 29 0a 09 20 3b 3b 20 4e 6f  estdat)).. ;; No
f120: 77 20 64 75 70 6c 69 63 61 74 65 20 74 68 65 20  w duplicate the 
f130: 74 65 73 74 20 64 61 74 61 0a 09 20 28 64 65 62  test data.. (deb
f140: 75 67 3a 70 72 69 6e 74 20 34 20 22 43 6f 70 79  ug:print 4 "Copy
f150: 69 6e 67 20 72 65 63 6f 72 64 73 20 69 6e 20 74  ing records in t
f160: 65 73 74 5f 64 61 74 61 20 66 72 6f 6d 20 74 65  est_data from te
f170: 73 74 5f 69 64 3d 22 20 28 64 62 3a 74 65 73 74  st_id=" (db:test
f180: 2d 67 65 74 2d 69 64 20 74 65 73 74 64 61 74 29  -get-id testdat)
f190: 20 22 20 74 6f 20 22 20 28 64 62 3a 74 65 73 74   " to " (db:test
f1a0: 2d 67 65 74 2d 69 64 20 6e 65 77 2d 74 65 73 74  -get-id new-test
f1b0: 64 61 74 29 29 0a 09 20 28 73 71 6c 69 74 65 33  dat)).. (sqlite3
f1c0: 3a 65 78 65 63 75 74 65 20 0a 09 20 20 64 62 20  :execute ..  db 
f1d0: 0a 09 20 20 28 63 6f 6e 63 20 22 49 4e 53 45 52  ..  (conc "INSER
f1e0: 54 20 4f 52 20 52 45 50 4c 41 43 45 20 49 4e 54  T OR REPLACE INT
f1f0: 4f 20 74 65 73 74 5f 64 61 74 61 20 28 74 65 73  O test_data (tes
f200: 74 5f 69 64 2c 63 61 74 65 67 6f 72 79 2c 76 61  t_id,category,va
f210: 72 69 61 62 6c 65 2c 76 61 6c 75 65 2c 65 78 70  riable,value,exp
f220: 65 63 74 65 64 2c 74 6f 6c 2c 75 6e 69 74 73 2c  ected,tol,units,
f230: 63 6f 6d 6d 65 6e 74 29 20 22 0a 09 09 22 53 45  comment) "..."SE
f240: 4c 45 43 54 20 22 20 28 64 62 3a 74 65 73 74 2d  LECT " (db:test-
f250: 67 65 74 2d 69 64 20 6e 65 77 2d 74 65 73 74 64  get-id new-testd
f260: 61 74 29 20 22 2c 63 61 74 65 67 6f 72 79 2c 76  at) ",category,v
f270: 61 72 69 61 62 6c 65 2c 76 61 6c 75 65 2c 65 78  ariable,value,ex
f280: 70 65 63 74 65 64 2c 74 6f 6c 2c 75 6e 69 74 73  pected,tol,units
f290: 2c 63 6f 6d 6d 65 6e 74 20 46 52 4f 4d 20 74 65  ,comment FROM te
f2a0: 73 74 5f 64 61 74 61 20 57 48 45 52 45 20 74 65  st_data WHERE te
f2b0: 73 74 5f 69 64 3d 3f 3b 22 29 0a 09 20 20 28 64  st_id=?;")..  (d
f2c0: 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65  b:test-get-id te
f2d0: 73 74 64 61 74 29 29 0a 09 20 29 29 0a 20 20 20  stdat)).. )).   
f2e0: 20 20 70 72 65 76 2d 74 65 73 74 73 29 29 29 0a    prev-tests))).
f2f0: 09 20 0a 20 20 20 20 20 0a                       . .     .