Megatest

Hex Artifact Content
Login

Artifact f7b1ada7848fa22bda0acfe7930bc2935a820508:


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 28 64 65 63 6c 61 72 65  onfig)).(declare
0260: 20 28 75 73 65 73 20 74 65 73 74 73 29 29 0a 28   (uses tests)).(
0270: 64 65 63 6c 61 72 65 20 28 75 73 65 73 20 73 65  declare (uses se
0280: 72 76 65 72 29 29 0a 0a 28 69 6e 63 6c 75 64 65  rver))..(include
0290: 20 22 63 6f 6d 6d 6f 6e 5f 72 65 63 6f 72 64 73   "common_records
02a0: 2e 73 63 6d 22 29 0a 28 69 6e 63 6c 75 64 65 20  .scm").(include 
02b0: 22 6b 65 79 5f 72 65 63 6f 72 64 73 2e 73 63 6d  "key_records.scm
02c0: 22 29 0a 28 69 6e 63 6c 75 64 65 20 22 64 62 5f  ").(include "db_
02d0: 72 65 63 6f 72 64 73 2e 73 63 6d 22 29 0a 28 69  records.scm").(i
02e0: 6e 63 6c 75 64 65 20 22 72 75 6e 5f 72 65 63 6f  nclude "run_reco
02f0: 72 64 73 2e 73 63 6d 22 29 0a 28 69 6e 63 6c 75  rds.scm").(inclu
0300: 64 65 20 22 74 65 73 74 5f 72 65 63 6f 72 64 73  de "test_records
0310: 2e 73 63 6d 22 29 0a 0a 3b 3b 20 72 75 6e 73 3a  .scm")..;; runs:
0320: 67 65 74 2d 72 75 6e 73 2d 62 79 2d 70 61 74 74  get-runs-by-patt
0330: 0a 3b 3b 20 67 65 74 20 72 75 6e 73 20 62 79 20  .;; get runs by 
0340: 6c 69 73 74 20 6f 66 20 63 72 69 74 65 72 69 61  list of criteria
0350: 0a 3b 3b 20 72 65 67 69 73 74 65 72 20 61 20 74  .;; register a t
0360: 65 73 74 20 72 75 6e 20 77 69 74 68 20 74 68 65  est run with the
0370: 20 64 62 0a 3b 3b 0a 3b 3b 20 55 73 65 3a 20 28   db.;;.;; Use: (
0380: 64 62 2d 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d  db-get-value-by-
0390: 68 65 61 64 65 72 20 28 64 62 3a 67 65 74 2d 68  header (db:get-h
03a0: 65 61 64 65 72 20 72 75 6e 69 6e 66 6f 29 28 64  eader runinfo)(d
03b0: 62 3a 67 65 74 2d 72 6f 77 20 72 75 6e 69 6e 66  b:get-row runinf
03c0: 6f 29 29 0a 3b 3b 20 20 74 6f 20 65 78 74 72 61  o)).;;  to extra
03d0: 63 74 20 69 6e 66 6f 20 66 72 6f 6d 20 74 68 65  ct info from the
03e0: 20 73 74 72 75 63 74 75 72 65 20 72 65 74 75 72   structure retur
03f0: 6e 65 64 0a 3b 3b 0a 28 64 65 66 69 6e 65 20 28  ned.;;.(define (
0400: 72 75 6e 73 3a 67 65 74 2d 72 75 6e 73 2d 62 79  runs:get-runs-by
0410: 2d 70 61 74 74 20 64 62 20 6b 65 79 73 20 72 75  -patt db keys ru
0420: 6e 6e 61 6d 65 70 61 74 74 20 2e 20 70 61 72 61  nnamepatt . para
0430: 6d 73 29 20 3b 3b 20 74 65 73 74 2d 6e 61 6d 65  ms) ;; test-name
0440: 29 0a 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 76  ).  (let* ((keyv
0450: 61 6c 6c 73 74 20 28 6b 65 79 73 2d 3e 76 61 6c  allst (keys->val
0460: 6c 69 73 74 20 6b 65 79 73 29 29 0a 09 20 28 74  list keys)).. (t
0470: 6d 70 20 20 20 20 20 20 28 72 75 6e 73 3a 67 65  mp      (runs:ge
0480: 74 2d 73 74 64 2d 72 75 6e 2d 66 69 65 6c 64 73  t-std-run-fields
0490: 20 6b 65 79 73 20 27 28 22 69 64 22 20 22 72 75   keys '("id" "ru
04a0: 6e 6e 61 6d 65 22 20 22 73 74 61 74 65 22 20 22  nname" "state" "
04b0: 73 74 61 74 75 73 22 20 22 6f 77 6e 65 72 22 20  status" "owner" 
04c0: 22 65 76 65 6e 74 5f 74 69 6d 65 22 29 29 29 0a  "event_time"))).
04d0: 09 20 28 6b 65 79 73 74 72 20 20 20 28 63 61 72  . (keystr   (car
04e0: 20 74 6d 70 29 29 0a 09 20 28 68 65 61 64 65 72   tmp)).. (header
04f0: 20 20 20 28 63 61 64 72 20 74 6d 70 29 29 0a 09     (cadr tmp))..
0500: 20 28 72 65 73 20 20 20 20 20 27 28 29 29 0a 09   (res     '())..
0510: 20 28 6b 65 79 2d 70 61 74 74 20 22 22 29 29 0a   (key-patt "")).
0520: 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20 28 6c      (for-each (l
0530: 61 6d 62 64 61 20 28 6b 65 79 76 61 6c 29 0a 09  ambda (keyval)..
0540: 09 28 6c 65 74 2a 20 28 28 6b 65 79 20 20 20 20  .(let* ((key    
0550: 28 76 65 63 74 6f 72 2d 72 65 66 20 6b 65 79 76  (vector-ref keyv
0560: 61 6c 20 30 29 29 0a 09 09 20 20 20 20 20 20 20  al 0))...       
0570: 28 66 75 6c 6b 65 79 20 28 63 6f 6e 63 20 22 3a  (fulkey (conc ":
0580: 22 20 6b 65 79 29 29 0a 09 09 20 20 20 20 20 20  " key))...      
0590: 20 28 70 61 74 74 20 20 20 28 61 72 67 73 3a 67   (patt   (args:g
05a0: 65 74 2d 61 72 67 20 66 75 6c 6b 65 79 29 29 29  et-arg fulkey)))
05b0: 0a 09 09 20 20 28 69 66 20 70 61 74 74 0a 09 09  ...  (if patt...
05c0: 20 20 20 20 20 20 28 73 65 74 21 20 6b 65 79 2d        (set! key-
05d0: 70 61 74 74 20 28 63 6f 6e 63 20 6b 65 79 2d 70  patt (conc key-p
05e0: 61 74 74 20 22 20 41 4e 44 20 22 20 6b 65 79 20  att " AND " key 
05f0: 22 20 6c 69 6b 65 20 27 22 20 70 61 74 74 20 22  " like '" patt "
0600: 27 22 29 29 0a 09 09 20 20 20 20 20 20 28 62 65  '"))...      (be
0610: 67 69 6e 0a 09 09 09 28 64 65 62 75 67 3a 70 72  gin....(debug:pr
0620: 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 73 65  int 0 "ERROR: se
0630: 61 72 63 68 69 6e 67 20 66 6f 72 20 72 75 6e 73  arching for runs
0640: 20 77 69 74 68 20 6e 6f 20 70 61 74 74 65 72 6e   with no pattern
0650: 20 73 65 74 20 66 6f 72 20 22 20 66 75 6c 6b 65   set for " fulke
0660: 79 29 0a 09 09 09 28 65 78 69 74 20 36 29 29 29  y)....(exit 6)))
0670: 29 29 0a 09 20 20 20 20 20 20 6b 65 79 73 29 0a  ))..      keys).
0680: 20 20 20 20 28 73 71 6c 69 74 65 33 3a 66 6f 72      (sqlite3:for
0690: 2d 65 61 63 68 2d 72 6f 77 20 0a 20 20 20 20 20  -each-row .     
06a0: 28 6c 61 6d 62 64 61 20 28 61 20 2e 20 72 29 0a  (lambda (a . r).
06b0: 20 20 20 20 20 20 20 28 73 65 74 21 20 72 65 73         (set! res
06c0: 20 28 63 6f 6e 73 20 28 6c 69 73 74 2d 3e 76 65   (cons (list->ve
06d0: 63 74 6f 72 20 28 63 6f 6e 73 20 61 20 72 29 29  ctor (cons a r))
06e0: 20 72 65 73 29 29 29 0a 20 20 20 20 20 64 62 20   res))).     db 
06f0: 0a 20 20 20 20 20 28 63 6f 6e 63 20 22 53 45 4c  .     (conc "SEL
0700: 45 43 54 20 22 20 6b 65 79 73 74 72 20 22 20 46  ECT " keystr " F
0710: 52 4f 4d 20 72 75 6e 73 20 57 48 45 52 45 20 72  ROM runs WHERE r
0720: 75 6e 6e 61 6d 65 20 6c 69 6b 65 20 3f 20 22 20  unname like ? " 
0730: 6b 65 79 2d 70 61 74 74 20 22 3b 22 29 0a 20 20  key-patt ";").  
0740: 20 20 20 72 75 6e 6e 61 6d 65 70 61 74 74 29 0a     runnamepatt).
0750: 20 20 20 20 28 76 65 63 74 6f 72 20 68 65 61 64      (vector head
0760: 65 72 20 72 65 73 29 29 29 0a 0a 28 64 65 66 69  er res)))..(defi
0770: 6e 65 20 28 72 75 6e 73 3a 74 65 73 74 2d 67 65  ne (runs:test-ge
0780: 74 2d 66 75 6c 6c 2d 70 61 74 68 20 74 65 73 74  t-full-path test
0790: 29 0a 20 20 28 6c 65 74 2a 20 28 28 74 65 73 74  ).  (let* ((test
07a0: 6e 61 6d 65 20 28 64 62 3a 74 65 73 74 2d 67 65  name (db:test-ge
07b0: 74 2d 74 65 73 74 6e 61 6d 65 20 20 20 74 65 73  t-testname   tes
07c0: 74 29 29 0a 09 20 28 69 74 65 6d 70 61 74 68 20  t)).. (itempath 
07d0: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65  (db:test-get-ite
07e0: 6d 2d 70 61 74 68 20 74 65 73 74 29 29 29 0a 20  m-path test))). 
07f0: 20 20 20 28 63 6f 6e 63 20 74 65 73 74 6e 61 6d     (conc testnam
0800: 65 20 28 69 66 20 28 65 71 75 61 6c 3f 20 69 74  e (if (equal? it
0810: 65 6d 70 61 74 68 20 22 22 29 20 22 22 20 28 63  empath "") "" (c
0820: 6f 6e 63 20 22 28 22 20 69 74 65 6d 70 61 74 68  onc "(" itempath
0830: 20 22 29 22 29 29 29 29 29 0a 0a 0a 28 64 65 66   ")")))))...(def
0840: 69 6e 65 20 28 73 65 74 2d 6d 65 67 61 74 65 73  ine (set-megates
0850: 74 2d 65 6e 76 2d 76 61 72 73 20 64 62 20 72 75  t-env-vars db ru
0860: 6e 2d 69 64 29 0a 20 20 28 6c 65 74 20 28 28 6b  n-id).  (let ((k
0870: 65 79 73 20 28 72 64 62 3a 67 65 74 2d 6b 65 79  eys (rdb:get-key
0880: 73 20 64 62 29 29 29 0a 20 20 20 20 28 66 6f 72  s db))).    (for
0890: 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 20 28 6b  -each (lambda (k
08a0: 65 79 29 0a 09 09 28 73 71 6c 69 74 65 33 3a 66  ey)...(sqlite3:f
08b0: 6f 72 2d 65 61 63 68 2d 72 6f 77 0a 09 09 20 28  or-each-row... (
08c0: 6c 61 6d 62 64 61 20 28 76 61 6c 29 0a 09 09 20  lambda (val)... 
08d0: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32    (debug:print 2
08e0: 20 22 73 65 74 65 6e 76 20 22 20 28 6b 65 79 3a   "setenv " (key:
08f0: 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65  get-fieldname ke
0900: 79 29 20 22 20 22 20 76 61 6c 29 0a 09 09 20 20  y) " " val)...  
0910: 20 28 73 65 74 65 6e 76 20 28 6b 65 79 3a 67 65   (setenv (key:ge
0920: 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65 79 29  t-fieldname key)
0930: 20 76 61 6c 29 29 0a 09 09 20 64 62 20 0a 09 09   val))... db ...
0940: 20 28 63 6f 6e 63 20 22 53 45 4c 45 43 54 20 22   (conc "SELECT "
0950: 20 28 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64 6e   (key:get-fieldn
0960: 61 6d 65 20 6b 65 79 29 20 22 20 46 52 4f 4d 20  ame key) " FROM 
0970: 72 75 6e 73 20 57 48 45 52 45 20 69 64 3d 3f 3b  runs WHERE id=?;
0980: 22 29 0a 09 09 20 72 75 6e 2d 69 64 29 29 0a 09  ")... run-id))..
0990: 20 20 20 20 20 20 6b 65 79 73 29 0a 20 20 20 20        keys).    
09a0: 3b 3b 20 4c 65 74 73 20 75 73 65 20 74 68 69 73  ;; Lets use this
09b0: 20 61 73 20 61 6e 20 6f 70 70 6f 72 74 75 6e 69   as an opportuni
09c0: 74 79 20 74 6f 20 70 75 74 20 4d 54 5f 52 55 4e  ty to put MT_RUN
09d0: 4e 41 4d 45 20 69 6e 20 74 68 65 20 65 6e 76 69  NAME in the envi
09e0: 72 6f 6e 6d 65 6e 74 0a 20 20 20 20 28 73 71 6c  ronment.    (sql
09f0: 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f  ite3:for-each-ro
0a00: 77 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28  w.     (lambda (
0a10: 72 75 6e 6e 61 6d 65 29 0a 20 20 20 20 20 20 20  runname).       
0a20: 28 73 65 74 65 6e 76 20 22 4d 54 5f 52 55 4e 4e  (setenv "MT_RUNN
0a30: 41 4d 45 22 20 72 75 6e 6e 61 6d 65 29 29 0a 20  AME" runname)). 
0a40: 20 20 20 20 64 62 0a 20 20 20 20 20 22 53 45 4c      db.     "SEL
0a50: 45 43 54 20 72 75 6e 6e 61 6d 65 20 46 52 4f 4d  ECT runname FROM
0a60: 20 72 75 6e 73 20 57 48 45 52 45 20 69 64 3d 3f   runs WHERE id=?
0a70: 3b 22 0a 20 20 20 20 20 72 75 6e 2d 69 64 29 0a  ;".     run-id).
0a80: 20 20 20 20 29 29 0a 0a 28 64 65 66 69 6e 65 20      ))..(define 
0a90: 28 73 65 74 2d 69 74 65 6d 2d 65 6e 76 2d 76 61  (set-item-env-va
0aa0: 72 73 20 69 74 65 6d 64 61 74 29 0a 20 20 28 66  rs itemdat).  (f
0ab0: 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 20  or-each (lambda 
0ac0: 28 69 74 65 6d 29 0a 09 20 20 20 20 20 20 28 64  (item)..      (d
0ad0: 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 73 65  ebug:print 2 "se
0ae0: 74 65 6e 76 20 22 20 28 63 61 72 20 69 74 65 6d  tenv " (car item
0af0: 29 20 22 20 22 20 28 63 61 64 72 20 69 74 65 6d  ) " " (cadr item
0b00: 29 29 0a 09 20 20 20 20 20 20 28 73 65 74 65 6e  ))..      (seten
0b10: 76 20 28 63 61 72 20 69 74 65 6d 29 20 28 63 61  v (car item) (ca
0b20: 64 72 20 69 74 65 6d 29 29 29 0a 09 20 20 20 20  dr item)))..    
0b30: 69 74 65 6d 64 61 74 29 29 0a 0a 28 64 65 66 69  itemdat))..(defi
0b40: 6e 65 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e  ne (runs:can-run
0b50: 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64 62 20 74  -more-tests db t
0b60: 65 73 74 2d 72 65 63 6f 72 64 29 0a 20 20 28 6c  est-record).  (l
0b70: 65 74 2a 20 28 28 74 63 6f 6e 66 69 67 20 20 20  et* ((tconfig   
0b80: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 74                (t
0b90: 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67  ests:testqueue-g
0ba0: 65 74 2d 74 65 73 74 63 6f 6e 66 69 67 20 74 65  et-testconfig te
0bb0: 73 74 2d 72 65 63 6f 72 64 29 29 0a 09 20 28 6a  st-record)).. (j
0bc0: 6f 62 67 72 6f 75 70 20 20 20 20 20 20 20 20 20  obgroup         
0bd0: 20 20 20 20 20 20 20 28 63 6f 6e 66 69 67 2d 6c         (config-l
0be0: 6f 6f 6b 75 70 20 74 63 6f 6e 66 69 67 20 22 72  ookup tconfig "r
0bf0: 65 71 75 69 72 65 6d 65 6e 74 73 22 20 22 6a 6f  equirements" "jo
0c00: 62 67 72 6f 75 70 22 29 29 0a 09 20 28 6e 75 6d  bgroup")).. (num
0c10: 2d 72 75 6e 6e 69 6e 67 20 20 20 20 20 20 20 20  -running        
0c20: 20 20 20 20 20 28 64 62 3a 67 65 74 2d 63 6f 75       (db:get-cou
0c30: 6e 74 2d 74 65 73 74 73 2d 72 75 6e 6e 69 6e 67  nt-tests-running
0c40: 20 64 62 29 29 0a 09 20 28 6e 75 6d 2d 72 75 6e   db)).. (num-run
0c50: 6e 69 6e 67 2d 69 6e 2d 6a 6f 62 67 72 6f 75 70  ning-in-jobgroup
0c60: 20 28 64 62 3a 67 65 74 2d 63 6f 75 6e 74 2d 74   (db:get-count-t
0c70: 65 73 74 73 2d 72 75 6e 6e 69 6e 67 2d 69 6e 2d  ests-running-in-
0c80: 6a 6f 62 67 72 6f 75 70 20 64 62 20 6a 6f 62 67  jobgroup db jobg
0c90: 72 6f 75 70 29 29 0a 09 20 28 6d 61 78 2d 63 6f  roup)).. (max-co
0ca0: 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 20 20 20  ncurrent-jobs   
0cb0: 20 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70    (config-lookup
0cc0: 20 2a 63 6f 6e 66 69 67 64 61 74 2a 20 22 73 65   *configdat* "se
0cd0: 74 75 70 22 20 20 20 20 20 22 6d 61 78 5f 63 6f  tup"     "max_co
0ce0: 6e 63 75 72 72 65 6e 74 5f 6a 6f 62 73 22 29 29  ncurrent_jobs"))
0cf0: 0a 09 20 28 6a 6f 62 2d 67 72 6f 75 70 2d 6c 69  .. (job-group-li
0d00: 6d 69 74 20 20 20 20 20 20 20 20 20 28 63 6f 6e  mit         (con
0d10: 66 69 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66  fig-lookup *conf
0d20: 69 67 64 61 74 2a 20 22 6a 6f 62 67 72 6f 75 70  igdat* "jobgroup
0d30: 73 22 20 6a 6f 62 67 72 6f 75 70 29 29 29 0a 20  s" jobgroup))). 
0d40: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
0d50: 32 20 22 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e  2 "max-concurren
0d60: 74 2d 6a 6f 62 73 3a 20 22 20 6d 61 78 2d 63 6f  t-jobs: " max-co
0d70: 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 20 22 2c  ncurrent-jobs ",
0d80: 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67 3a 20 22 20   num-running: " 
0d90: 6e 75 6d 2d 72 75 6e 6e 69 6e 67 29 0a 20 20 20  num-running).   
0da0: 20 28 69 66 20 28 6e 6f 74 20 28 65 71 3f 20 30   (if (not (eq? 0
0db0: 20 2a 67 6c 6f 62 61 6c 65 78 69 74 73 74 61 74   *globalexitstat
0dc0: 75 73 2a 29 29 0a 09 23 66 0a 09 28 6c 65 74 20  us*))..#f..(let 
0dd0: 28 28 63 61 6e 2d 6e 6f 74 2d 72 75 6e 2d 6d 6f  ((can-not-run-mo
0de0: 72 65 20 28 63 6f 6e 64 0a 09 09 09 09 20 3b 3b  re (cond..... ;;
0df0: 20 69 66 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65   if max-concurre
0e00: 6e 74 2d 6a 6f 62 73 20 69 73 20 73 65 74 20 61  nt-jobs is set a
0e10: 6e 64 20 74 68 65 20 6e 75 6d 62 65 72 20 72 75  nd the number ru
0e20: 6e 6e 69 6e 67 20 69 73 20 67 72 65 61 74 65 72  nning is greater
0e30: 20 0a 09 09 09 09 20 3b 3b 20 74 68 61 6e 20 69   ..... ;; than i
0e40: 74 20 74 68 61 6e 20 63 61 6e 6e 6f 74 20 72 75  t than cannot ru
0e50: 6e 20 6d 6f 72 65 20 6a 6f 62 73 0a 09 09 09 09  n more jobs.....
0e60: 20 28 28 61 6e 64 20 6d 61 78 2d 63 6f 6e 63 75   ((and max-concu
0e70: 72 72 65 6e 74 2d 6a 6f 62 73 0a 09 09 09 09 20  rrent-jobs..... 
0e80: 20 20 20 20 20 20 28 73 74 72 69 6e 67 2d 3e 6e        (string->n
0e90: 75 6d 62 65 72 20 6d 61 78 2d 63 6f 6e 63 75 72  umber max-concur
0ea0: 72 65 6e 74 2d 6a 6f 62 73 29 0a 09 09 09 09 20  rent-jobs)..... 
0eb0: 20 20 20 20 20 20 28 3e 3d 20 6e 75 6d 2d 72 75        (>= num-ru
0ec0: 6e 6e 69 6e 67 20 28 73 74 72 69 6e 67 2d 3e 6e  nning (string->n
0ed0: 75 6d 62 65 72 20 6d 61 78 2d 63 6f 6e 63 75 72  umber max-concur
0ee0: 72 65 6e 74 2d 6a 6f 62 73 29 29 29 0a 09 09 09  rent-jobs)))....
0ef0: 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20  .  (debug:print 
0f00: 30 20 22 57 41 52 4e 49 4e 47 3a 20 4d 61 78 20  0 "WARNING: Max 
0f10: 72 75 6e 6e 69 6e 67 20 6a 6f 62 73 20 65 78 63  running jobs exc
0f20: 65 65 64 65 64 2c 20 63 75 72 72 65 6e 74 20 6e  eeded, current n
0f30: 75 6d 62 65 72 20 72 75 6e 6e 69 6e 67 3a 20 22  umber running: "
0f40: 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67 20 0a 09 09   num-running ...
0f50: 09 09 09 20 20 20 20 20 20 20 22 2c 20 6d 61 78  ...       ", max
0f60: 5f 63 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f 62 73  _concurrent_jobs
0f70: 3a 20 22 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65  : " max-concurre
0f80: 6e 74 2d 6a 6f 62 73 29 0a 09 09 09 09 20 20 23  nt-jobs).....  #
0f90: 74 29 0a 09 09 09 09 20 3b 3b 20 69 66 20 6a 6f  t)..... ;; if jo
0fa0: 62 2d 67 72 6f 75 70 2d 6c 69 6d 69 74 20 69 73  b-group-limit is
0fb0: 20 73 65 74 20 61 6e 64 20 6e 75 6d 62 65 72 20   set and number 
0fc0: 6f 66 20 6a 6f 62 73 20 69 6e 20 74 68 65 20 67  of jobs in the g
0fd0: 72 6f 75 70 20 69 73 20 67 72 65 61 74 65 72 0a  roup is greater.
0fe0: 09 09 09 09 20 3b 3b 20 74 68 61 6e 20 74 68 65  .... ;; than the
0ff0: 20 6c 69 6d 69 74 20 74 68 65 6e 20 63 61 6e 6e   limit then cann
1000: 6f 74 20 72 75 6e 20 6d 6f 72 65 20 6a 6f 62 73  ot run more jobs
1010: 20 6f 66 20 74 68 69 73 20 6b 69 6e 64 0a 09 09   of this kind...
1020: 09 09 20 28 28 61 6e 64 20 6a 6f 62 2d 67 72 6f  .. ((and job-gro
1030: 75 70 2d 6c 69 6d 69 74 0a 09 09 09 09 20 20 20  up-limit.....   
1040: 20 20 20 20 28 3e 3d 20 6e 75 6d 2d 72 75 6e 6e      (>= num-runn
1050: 69 6e 67 2d 69 6e 2d 6a 6f 62 67 72 6f 75 70 20  ing-in-jobgroup 
1060: 6a 6f 62 2d 67 72 6f 75 70 2d 6c 69 6d 69 74 29  job-group-limit)
1070: 29 0a 09 09 09 09 20 20 28 64 65 62 75 67 3a 70  ).....  (debug:p
1080: 72 69 6e 74 20 31 20 22 57 41 52 4e 49 4e 47 3a  rint 1 "WARNING:
1090: 20 6e 75 6d 62 65 72 20 6f 66 20 6a 6f 62 73 20   number of jobs 
10a0: 22 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67 2d 69 6e  " num-running-in
10b0: 2d 6a 6f 62 67 72 6f 75 70 20 0a 09 09 09 09 09  -jobgroup ......
10c0: 20 20 20 20 20 20 20 22 20 69 6e 20 22 20 6a 6f         " in " jo
10d0: 62 67 72 6f 75 70 20 22 20 65 78 63 65 65 64 65  bgroup " exceede
10e0: 64 2c 20 77 69 6c 6c 20 6e 6f 74 20 72 75 6e 20  d, will not run 
10f0: 22 20 28 74 65 73 74 73 3a 74 65 73 74 71 75 65  " (tests:testque
1100: 75 65 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20  ue-get-testname 
1110: 74 65 73 74 2d 72 65 63 6f 72 64 29 29 0a 09 09  test-record))...
1120: 09 09 20 20 23 74 29 0a 09 09 09 09 20 28 65 6c  ..  #t)..... (el
1130: 73 65 20 23 66 29 29 29 29 0a 09 20 20 28 6e 6f  se #f))))..  (no
1140: 74 20 63 61 6e 2d 6e 6f 74 2d 72 75 6e 2d 6d 6f  t can-not-run-mo
1150: 72 65 29 29 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d  re)))))..;;=====
1160: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1170: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1180: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1190: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
11a0: 3d 0a 3b 3b 20 4e 65 77 20 6d 65 74 68 6f 64 6f  =.;; New methodo
11b0: 6c 6f 67 79 2e 20 54 68 65 73 65 20 72 6f 75 74  logy. These rout
11c0: 69 6e 65 73 20 77 69 6c 6c 20 72 65 70 6c 61 63  ines will replac
11d0: 65 20 74 68 65 20 61 62 6f 76 65 20 69 6e 20 74  e the above in t
11e0: 69 6d 65 2e 20 46 6f 72 0a 3b 3b 20 6e 6f 77 20  ime. For.;; now 
11f0: 74 68 65 20 63 6f 64 65 20 69 73 20 64 75 70 6c  the code is dupl
1200: 69 63 61 74 65 64 2e 20 54 68 69 73 20 73 74 75  icated. This stu
1210: 66 66 20 69 73 20 69 6e 69 74 69 61 6c 6c 79 20  ff is initially 
1220: 75 73 65 64 20 69 6e 20 74 68 65 20 6d 6f 6e 69  used in the moni
1230: 74 6f 72 0a 3b 3b 20 62 61 73 65 64 20 63 6f 64  tor.;; based cod
1240: 65 2e 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  e..;;===========
1250: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1260: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1270: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1280: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b 20  ===========..;; 
1290: 72 65 67 69 73 74 65 72 20 61 20 74 65 73 74 20  register a test 
12a0: 72 75 6e 20 77 69 74 68 20 74 68 65 20 64 62 0a  run with the db.
12b0: 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 72 65  (define (runs:re
12c0: 67 69 73 74 65 72 2d 72 75 6e 20 64 62 20 6b 65  gister-run db ke
12d0: 79 73 20 6b 65 79 76 61 6c 6c 73 74 20 72 75 6e  ys keyvallst run
12e0: 6e 61 6d 65 20 73 74 61 74 65 20 73 74 61 74 75  name state statu
12f0: 73 20 75 73 65 72 29 0a 20 20 28 64 65 62 75 67  s user).  (debug
1300: 3a 70 72 69 6e 74 20 33 20 22 72 75 6e 73 3a 72  :print 3 "runs:r
1310: 65 67 69 73 74 65 72 2d 72 75 6e 2c 20 6b 65 79  egister-run, key
1320: 73 3a 20 22 20 6b 65 79 73 20 22 20 6b 65 79 76  s: " keys " keyv
1330: 61 6c 6c 73 74 3a 20 22 20 6b 65 79 76 61 6c 6c  allst: " keyvall
1340: 73 74 20 22 20 72 75 6e 6e 61 6d 65 3a 20 22 20  st " runname: " 
1350: 72 75 6e 6e 61 6d 65 20 22 20 73 74 61 74 65 3a  runname " state:
1360: 20 22 20 73 74 61 74 65 20 22 20 73 74 61 74 75   " state " statu
1370: 73 3a 20 22 20 73 74 61 74 75 73 20 22 20 75 73  s: " status " us
1380: 65 72 3a 20 22 20 75 73 65 72 29 0a 20 20 28 6c  er: " user).  (l
1390: 65 74 2a 20 28 28 6b 65 79 73 74 72 20 20 20 20  et* ((keystr    
13a0: 28 6b 65 79 73 2d 3e 6b 65 79 73 74 72 20 6b 65  (keys->keystr ke
13b0: 79 73 29 29 0a 09 20 28 63 6f 6d 6d 61 20 20 20  ys)).. (comma   
13c0: 20 20 28 69 66 20 28 3e 20 28 6c 65 6e 67 74 68    (if (> (length
13d0: 20 6b 65 79 73 29 20 30 29 20 22 2c 22 20 22 22   keys) 0) "," ""
13e0: 29 29 0a 09 20 28 61 6e 64 73 74 72 20 20 20 20  )).. (andstr    
13f0: 28 69 66 20 28 3e 20 28 6c 65 6e 67 74 68 20 6b  (if (> (length k
1400: 65 79 73 29 20 30 29 20 22 20 41 4e 44 20 22 20  eys) 0) " AND " 
1410: 22 22 29 29 0a 09 20 28 76 61 6c 73 6c 6f 74 73  "")).. (valslots
1420: 20 20 28 6b 65 79 73 2d 3e 76 61 6c 73 6c 6f 74    (keys->valslot
1430: 73 20 6b 65 79 73 29 29 20 3b 3b 20 3f 2c 3f 2c  s keys)) ;; ?,?,
1440: 3f 20 2e 2e 2e 0a 09 20 28 6b 65 79 76 61 6c 73  ? ..... (keyvals
1450: 20 20 20 28 6d 61 70 20 63 61 64 72 20 6b 65 79     (map cadr key
1460: 76 61 6c 6c 73 74 29 29 0a 09 20 28 61 6c 6c 76  vallst)).. (allv
1470: 61 6c 73 20 20 20 28 61 70 70 65 6e 64 20 28 6c  als   (append (l
1480: 69 73 74 20 72 75 6e 6e 61 6d 65 20 73 74 61 74  ist runname stat
1490: 65 20 73 74 61 74 75 73 20 75 73 65 72 29 20 6b  e status user) k
14a0: 65 79 76 61 6c 73 29 29 0a 09 20 28 71 72 79 76  eyvals)).. (qryv
14b0: 61 6c 73 20 20 20 28 61 70 70 65 6e 64 20 28 6c  als   (append (l
14c0: 69 73 74 20 72 75 6e 6e 61 6d 65 29 20 6b 65 79  ist runname) key
14d0: 76 61 6c 73 29 29 0a 09 20 28 6b 65 79 3d 3f 73  vals)).. (key=?s
14e0: 74 72 20 20 28 73 74 72 69 6e 67 2d 69 6e 74 65  tr  (string-inte
14f0: 72 73 70 65 72 73 65 20 28 6d 61 70 20 28 6c 61  rsperse (map (la
1500: 6d 62 64 61 20 28 6b 29 28 63 6f 6e 63 20 28 6b  mbda (k)(conc (k
1510: 65 79 3a 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65  ey:get-fieldname
1520: 20 6b 29 20 22 3d 3f 22 29 29 20 6b 65 79 73 29   k) "=?")) keys)
1530: 20 22 20 41 4e 44 20 22 29 29 29 0a 20 20 20 20   " AND "))).    
1540: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 33 20 22  (debug:print 3 "
1550: 6b 65 79 73 3a 20 22 20 6b 65 79 73 20 22 20 61  keys: " keys " a
1560: 6c 6c 76 61 6c 73 3a 20 22 20 61 6c 6c 76 61 6c  llvals: " allval
1570: 73 20 22 20 6b 65 79 76 61 6c 73 3a 20 22 20 6b  s " keyvals: " k
1580: 65 79 76 61 6c 73 29 0a 20 20 20 20 28 64 65 62  eyvals).    (deb
1590: 75 67 3a 70 72 69 6e 74 20 32 20 22 4e 4f 54 45  ug:print 2 "NOTE
15a0: 3a 20 75 73 69 6e 67 20 74 61 72 67 65 74 20 22  : using target "
15b0: 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70   (string-intersp
15c0: 65 72 73 65 20 6b 65 79 76 61 6c 73 20 22 2f 22  erse keyvals "/"
15d0: 29 20 22 20 66 6f 72 20 74 68 69 73 20 72 75 6e  ) " for this run
15e0: 22 29 0a 20 20 20 20 28 69 66 20 28 61 6e 64 20  ").    (if (and 
15f0: 72 75 6e 6e 61 6d 65 20 28 6e 75 6c 6c 3f 20 28  runname (null? (
1600: 66 69 6c 74 65 72 20 28 6c 61 6d 62 64 61 20 28  filter (lambda (
1610: 78 29 28 6e 6f 74 20 78 29 29 20 6b 65 79 76 61  x)(not x)) keyva
1620: 6c 73 29 29 29 20 3b 3b 20 74 68 65 72 65 20 6d  ls))) ;; there m
1630: 75 73 74 20 62 65 20 61 20 62 65 74 74 65 72 20  ust be a better 
1640: 77 61 79 20 74 6f 20 22 61 70 70 6c 79 20 61 6e  way to "apply an
1650: 64 22 0a 09 28 6c 65 74 20 28 28 72 65 73 20 23  d"..(let ((res #
1660: 66 29 29 0a 09 20 20 28 61 70 70 6c 79 20 73 71  f))..  (apply sq
1670: 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 64 62  lite3:execute db
1680: 20 28 63 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f   (conc "INSERT O
1690: 52 20 49 47 4e 4f 52 45 20 49 4e 54 4f 20 72 75  R IGNORE INTO ru
16a0: 6e 73 20 28 72 75 6e 6e 61 6d 65 2c 73 74 61 74  ns (runname,stat
16b0: 65 2c 73 74 61 74 75 73 2c 6f 77 6e 65 72 2c 65  e,status,owner,e
16c0: 76 65 6e 74 5f 74 69 6d 65 22 20 63 6f 6d 6d 61  vent_time" comma
16d0: 20 6b 65 79 73 74 72 20 22 29 20 56 41 4c 55 45   keystr ") VALUE
16e0: 53 20 28 3f 2c 3f 2c 3f 2c 3f 2c 73 74 72 66 74  S (?,?,?,?,strft
16f0: 69 6d 65 28 27 25 73 27 2c 27 6e 6f 77 27 29 22  ime('%s','now')"
1700: 20 63 6f 6d 6d 61 20 76 61 6c 73 6c 6f 74 73 20   comma valslots 
1710: 22 29 3b 22 29 0a 09 09 20 61 6c 6c 76 61 6c 73  ");")... allvals
1720: 29 0a 09 20 20 28 61 70 70 6c 79 20 73 71 6c 69  )..  (apply sqli
1730: 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77  te3:for-each-row
1740: 20 0a 09 20 20 20 28 6c 61 6d 62 64 61 20 28 69   ..   (lambda (i
1750: 64 29 0a 09 20 20 20 20 20 28 73 65 74 21 20 72  d)..     (set! r
1760: 65 73 20 69 64 29 29 0a 09 20 20 20 64 62 0a 09  es id))..   db..
1770: 20 20 20 28 6c 65 74 20 28 28 71 72 79 20 28 63     (let ((qry (c
1780: 6f 6e 63 20 22 53 45 4c 45 43 54 20 69 64 20 46  onc "SELECT id F
1790: 52 4f 4d 20 72 75 6e 73 20 57 48 45 52 45 20 28  ROM runs WHERE (
17a0: 72 75 6e 6e 61 6d 65 3d 3f 20 22 20 61 6e 64 73  runname=? " ands
17b0: 74 72 20 6b 65 79 3d 3f 73 74 72 20 22 29 3b 22  tr key=?str ");"
17c0: 29 29 29 0a 09 20 20 20 20 20 3b 28 64 65 62 75  )))..     ;(debu
17d0: 67 3a 70 72 69 6e 74 20 34 20 22 71 72 79 3a 20  g:print 4 "qry: 
17e0: 22 20 71 72 79 29 20 0a 09 20 20 20 20 20 71 72  " qry) ..     qr
17f0: 79 29 0a 09 20 20 20 71 72 79 76 61 6c 73 29 0a  y)..   qryvals).
1800: 09 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63  .  (sqlite3:exec
1810: 75 74 65 20 64 62 20 22 55 50 44 41 54 45 20 72  ute db "UPDATE r
1820: 75 6e 73 20 53 45 54 20 73 74 61 74 65 3d 3f 2c  uns SET state=?,
1830: 73 74 61 74 75 73 3d 3f 20 57 48 45 52 45 20 69  status=? WHERE i
1840: 64 3d 3f 3b 22 20 73 74 61 74 65 20 73 74 61 74  d=?;" state stat
1850: 75 73 20 72 65 73 29 0a 09 20 20 72 65 73 29 20  us res)..  res) 
1860: 0a 09 28 62 65 67 69 6e 0a 09 20 20 28 64 65 62  ..(begin..  (deb
1870: 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f  ug:print 0 "ERRO
1880: 52 3a 20 43 61 6c 6c 65 64 20 77 69 74 68 6f 75  R: Called withou
1890: 74 20 61 6c 6c 20 6e 65 63 65 73 73 61 72 79 20  t all necessary 
18a0: 6b 65 79 73 22 29 0a 09 20 20 23 66 29 29 29 29  keys")..  #f))))
18b0: 0a 0a 3b 3b 20 54 68 69 73 20 69 73 20 61 20 64  ..;; This is a d
18c0: 75 70 6c 69 63 61 74 65 20 6f 66 20 72 75 6e 2d  uplicate of run-
18d0: 74 65 73 74 73 20 28 77 68 69 63 68 20 68 61 73  tests (which has
18e0: 20 62 65 65 6e 20 64 65 70 72 65 63 61 74 65 64   been deprecated
18f0: 29 2e 20 55 73 65 20 74 68 69 73 20 6f 6e 65 20  ). Use this one 
1900: 69 6e 73 74 65 61 64 20 6f 66 20 72 75 6e 20 74  instead of run t
1910: 65 73 74 73 2e 0a 3b 3b 20 6b 65 79 76 61 6c 73  ests..;; keyvals
1920: 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 72  .(define (runs:r
1930: 75 6e 2d 74 65 73 74 73 20 64 62 20 74 61 72 67  un-tests db targ
1940: 65 74 20 72 75 6e 6e 61 6d 65 20 74 65 73 74 2d  et runname test-
1950: 70 61 74 74 73 20 69 74 65 6d 2d 70 61 74 74 73  patts item-patts
1960: 20 75 73 65 72 20 66 6c 61 67 73 29 0a 20 20 28   user flags).  (
1970: 6c 65 74 2a 20 28 28 6b 65 79 73 20 20 20 20 20  let* ((keys     
1980: 20 20 20 28 72 64 62 3a 67 65 74 2d 6b 65 79 73     (rdb:get-keys
1990: 20 64 62 29 29 0a 09 20 28 6b 65 79 76 61 6c 6c   db)).. (keyvall
19a0: 73 74 20 20 20 28 6b 65 79 73 3a 74 61 72 67 65  st   (keys:targe
19b0: 74 2d 3e 6b 65 79 76 61 6c 20 6b 65 79 73 20 74  t->keyval keys t
19c0: 61 72 67 65 74 29 29 0a 09 20 28 72 75 6e 2d 69  arget)).. (run-i
19d0: 64 20 20 20 20 20 20 28 72 75 6e 73 3a 72 65 67  d      (runs:reg
19e0: 69 73 74 65 72 2d 72 75 6e 20 64 62 20 6b 65 79  ister-run db key
19f0: 73 20 6b 65 79 76 61 6c 6c 73 74 20 72 75 6e 6e  s keyvallst runn
1a00: 61 6d 65 20 22 6e 65 77 22 20 22 6e 2f 61 22 20  ame "new" "n/a" 
1a10: 75 73 65 72 29 29 20 20 3b 3b 20 20 74 65 73 74  user))  ;;  test
1a20: 2d 6e 61 6d 65 29 29 29 0a 09 20 28 64 65 66 65  -name))).. (defe
1a30: 72 72 65 64 20 20 20 20 27 28 29 29 20 3b 3b 20  rred    '()) ;; 
1a40: 64 65 6c 61 79 20 72 75 6e 6e 69 6e 67 20 74 68  delay running th
1a50: 65 73 65 20 73 69 6e 63 65 20 74 68 65 79 20 68  ese since they h
1a60: 61 76 65 20 61 20 77 61 69 74 6f 6e 20 63 6c 61  ave a waiton cla
1a70: 75 73 65 0a 09 20 3b 3b 20 6b 65 65 70 67 6f 69  use.. ;; keepgoi
1a80: 6e 67 20 69 73 20 74 68 65 20 64 65 66 61 63 74  ng is the defact
1a90: 6f 20 6d 6f 64 61 6c 69 74 79 20 6e 6f 77 2c 20  o modality now, 
1aa0: 77 69 6c 6c 20 61 64 64 20 68 69 74 2d 6e 2d 72  will add hit-n-r
1ab0: 75 6e 20 61 20 62 69 74 20 6c 61 74 65 72 0a 09  un a bit later..
1ac0: 20 3b 3b 20 28 6b 65 65 70 67 6f 69 6e 67 20 20   ;; (keepgoing  
1ad0: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
1ae0: 2f 64 65 66 61 75 6c 74 20 66 6c 61 67 73 20 22  /default flags "
1af0: 2d 6b 65 65 70 67 6f 69 6e 67 22 20 23 66 29 29  -keepgoing" #f))
1b00: 0a 09 20 28 74 65 73 74 2d 6e 61 6d 65 73 20 20  .. (test-names  
1b10: 27 28 29 29 0a 09 20 28 72 75 6e 63 6f 6e 66 69  '()).. (runconfi
1b20: 67 66 20 20 20 28 63 6f 6e 63 20 20 2a 74 6f 70  gf   (conc  *top
1b30: 70 61 74 68 2a 20 22 2f 72 75 6e 63 6f 6e 66 69  path* "/runconfi
1b40: 67 73 2e 63 6f 6e 66 69 67 22 29 29 0a 09 20 28  gs.config")).. (
1b50: 72 65 71 75 69 72 65 64 2d 74 65 73 74 73 20 27  required-tests '
1b60: 28 29 29 0a 09 20 28 74 65 73 74 2d 72 65 63 6f  ()).. (test-reco
1b70: 72 64 73 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74  rds (make-hash-t
1b80: 61 62 6c 65 29 29 29 0a 0a 20 20 20 20 28 73 65  able)))..    (se
1b90: 74 2d 6d 65 67 61 74 65 73 74 2d 65 6e 76 2d 76  t-megatest-env-v
1ba0: 61 72 73 20 64 62 20 72 75 6e 2d 69 64 29 20 3b  ars db run-id) ;
1bb0: 3b 20 74 68 65 73 65 20 6d 61 79 20 62 65 20 6e  ; these may be n
1bc0: 65 65 64 65 64 20 62 79 20 74 68 65 20 6c 61 75  eeded by the lau
1bd0: 6e 63 68 69 6e 67 20 70 72 6f 63 65 73 73 0a 0a  nching process..
1be0: 20 20 20 20 28 69 66 20 28 66 69 6c 65 2d 65 78      (if (file-ex
1bf0: 69 73 74 73 3f 20 72 75 6e 63 6f 6e 66 69 67 66  ists? runconfigf
1c00: 29 0a 09 28 73 65 74 75 70 2d 65 6e 76 2d 64 65  )..(setup-env-de
1c10: 66 61 75 6c 74 73 20 64 62 20 72 75 6e 63 6f 6e  faults db runcon
1c20: 66 69 67 66 20 72 75 6e 2d 69 64 20 2a 61 6c 72  figf run-id *alr
1c30: 65 61 64 79 2d 73 65 65 6e 2d 72 75 6e 63 6f 6e  eady-seen-runcon
1c40: 66 69 67 2d 69 6e 66 6f 2a 20 22 70 72 65 2d 6c  fig-info* "pre-l
1c50: 61 75 6e 63 68 2d 65 6e 76 2d 76 61 72 73 22 29  aunch-env-vars")
1c60: 0a 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30  ..(debug:print 0
1c70: 20 22 57 41 52 4e 49 4e 47 3a 20 59 6f 75 20 64   "WARNING: You d
1c80: 6f 20 6e 6f 74 20 68 61 76 65 20 61 20 72 75 6e  o not have a run
1c90: 20 63 6f 6e 66 69 67 20 66 69 6c 65 3a 20 22 20   config file: " 
1ca0: 72 75 6e 63 6f 6e 66 69 67 66 29 29 0a 20 20 20  runconfigf)).   
1cb0: 20 0a 20 20 20 20 3b 3b 20 6c 6f 6f 6b 20 75 70   .    ;; look up
1cc0: 20 61 6c 6c 20 74 65 73 74 73 20 6d 61 74 63 68   all tests match
1cd0: 69 6e 67 20 74 68 65 20 63 6f 6d 6d 61 20 73 65  ing the comma se
1ce0: 70 61 72 61 74 65 64 20 6c 69 73 74 20 6f 66 20  parated list of 
1cf0: 67 6c 6f 62 73 20 69 6e 0a 20 20 20 20 3b 3b 20  globs in.    ;; 
1d00: 74 65 73 74 2d 70 61 74 74 73 20 28 75 73 69 6e  test-patts (usin
1d10: 67 20 25 20 61 73 20 77 69 6c 64 63 61 72 64 29  g % as wildcard)
1d20: 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20 0a  .    (for-each .
1d30: 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 70 61       (lambda (pa
1d40: 74 74 29 0a 20 20 20 20 20 20 20 28 6c 65 74 20  tt).       (let 
1d50: 28 28 74 65 73 74 73 20 28 67 6c 6f 62 20 28 63  ((tests (glob (c
1d60: 6f 6e 63 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f  onc *toppath* "/
1d70: 74 65 73 74 73 2f 22 20 28 73 74 72 69 6e 67 2d  tests/" (string-
1d80: 74 72 61 6e 73 6c 61 74 65 20 70 61 74 74 20 22  translate patt "
1d90: 25 22 20 22 2a 22 29 29 29 29 29 0a 09 20 28 73  %" "*"))))).. (s
1da0: 65 74 21 20 74 65 73 74 73 20 28 66 69 6c 74 65  et! tests (filte
1db0: 72 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74 29  r (lambda (test)
1dc0: 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 28 63  (file-exists? (c
1dd0: 6f 6e 63 20 74 65 73 74 20 22 2f 74 65 73 74 63  onc test "/testc
1de0: 6f 6e 66 69 67 22 29 29 29 20 74 65 73 74 73 29  onfig"))) tests)
1df0: 29 0a 09 20 28 73 65 74 21 20 74 65 73 74 2d 6e  ).. (set! test-n
1e00: 61 6d 65 73 20 28 61 70 70 65 6e 64 20 74 65 73  ames (append tes
1e10: 74 2d 6e 61 6d 65 73 20 0a 09 09 09 09 20 20 28  t-names .....  (
1e20: 6d 61 70 20 28 6c 61 6d 62 64 61 20 28 74 65 73  map (lambda (tes
1e30: 74 70 29 0a 09 09 09 09 09 20 28 6c 61 73 74 20  tp)...... (last 
1e40: 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 74 65  (string-split te
1e50: 73 74 70 20 22 2f 22 29 29 29 0a 09 09 09 09 20  stp "/")))..... 
1e60: 20 20 20 20 20 20 74 65 73 74 73 29 29 29 29 29        tests)))))
1e70: 0a 20 20 20 20 20 28 69 66 20 74 65 73 74 2d 70  .     (if test-p
1e80: 61 74 74 73 20 28 73 74 72 69 6e 67 2d 73 70 6c  atts (string-spl
1e90: 69 74 20 74 65 73 74 2d 70 61 74 74 73 20 22 2c  it test-patts ",
1ea0: 22 29 28 6c 69 73 74 20 22 25 22 29 29 29 0a 0a  ")(list "%")))..
1eb0: 20 20 20 20 20 3b 3b 20 6e 6f 77 20 72 65 6d 6f       ;; now remo
1ec0: 76 65 20 64 75 70 6c 69 63 61 74 65 73 0a 20 20  ve duplicates.  
1ed0: 20 20 28 73 65 74 21 20 74 65 73 74 2d 6e 61 6d    (set! test-nam
1ee0: 65 73 20 28 64 65 6c 65 74 65 2d 64 75 70 6c 69  es (delete-dupli
1ef0: 63 61 74 65 73 20 74 65 73 74 2d 6e 61 6d 65 73  cates test-names
1f00: 29 29 0a 0a 20 20 20 20 28 64 65 62 75 67 3a 70  ))..    (debug:p
1f10: 72 69 6e 74 20 30 20 22 49 4e 46 4f 3a 20 74 65  rint 0 "INFO: te
1f20: 73 74 20 6e 61 6d 65 73 20 22 20 74 65 73 74 2d  st names " test-
1f30: 6e 61 6d 65 73 29 0a 0a 20 20 20 20 3b 3b 20 6f  names)..    ;; o
1f40: 6e 20 74 68 65 20 66 69 72 73 74 20 70 61 73 73  n the first pass
1f50: 20 6f 72 20 63 61 6c 6c 20 74 6f 20 72 75 6e 2d   or call to run-
1f60: 74 65 73 74 73 20 73 65 74 20 46 41 49 4c 53 20  tests set FAILS 
1f70: 74 6f 20 4e 4f 54 5f 53 54 41 52 54 45 44 20 69  to NOT_STARTED i
1f80: 66 0a 20 20 20 20 3b 3b 20 2d 6b 65 65 70 67 6f  f.    ;; -keepgo
1f90: 69 6e 67 20 69 73 20 73 70 65 63 69 66 69 65 64  ing is specified
1fa0: 0a 20 20 20 20 28 69 66 20 28 65 71 3f 20 2a 70  .    (if (eq? *p
1fb0: 61 73 73 6e 75 6d 2a 20 30 29 0a 09 28 62 65 67  assnum* 0)..(beg
1fc0: 69 6e 0a 09 20 20 3b 3b 20 68 61 76 65 20 74 6f  in..  ;; have to
1fd0: 20 64 65 6c 65 74 65 20 74 65 73 74 20 72 65 63   delete test rec
1fe0: 6f 72 64 73 20 77 68 65 72 65 20 4e 4f 54 5f 53  ords where NOT_S
1ff0: 54 41 52 54 45 44 20 73 69 6e 63 65 20 74 68 65  TARTED since the
2000: 79 20 63 61 6e 20 63 61 75 73 65 20 2d 6b 65 65  y can cause -kee
2010: 70 67 6f 69 6e 67 20 74 6f 20 0a 09 20 20 3b 3b  pgoing to ..  ;;
2020: 20 67 65 74 20 73 74 75 63 6b 20 64 75 65 20 74   get stuck due t
2030: 6f 20 62 65 63 6f 6d 69 6e 67 20 69 6e 61 63 63  o becoming inacc
2040: 65 73 73 69 62 6c 65 20 66 72 6f 6d 20 61 20 66  essible from a f
2050: 61 69 6c 65 64 20 74 65 73 74 2e 20 49 2e 65 2e  ailed test. I.e.
2060: 20 69 66 20 74 65 73 74 20 42 20 64 65 70 65 6e   if test B depen
2070: 64 73 20 0a 09 20 20 3b 3b 20 6f 6e 20 74 65 73  ds ..  ;; on tes
2080: 74 20 41 20 62 75 74 20 74 65 73 74 20 42 20 72  t A but test B r
2090: 65 61 63 68 65 64 20 74 68 65 20 70 6f 69 6e 74  eached the point
20a0: 20 6f 6e 20 62 65 69 6e 67 20 72 65 67 69 73 74   on being regist
20b0: 65 72 65 64 20 61 73 20 4e 4f 54 5f 53 54 41 52  ered as NOT_STAR
20c0: 54 45 44 20 61 6e 64 20 74 65 73 74 0a 09 20 20  TED and test..  
20d0: 3b 3b 20 41 20 66 61 69 6c 65 64 20 66 6f 72 20  ;; A failed for 
20e0: 73 6f 6d 65 20 72 65 61 73 6f 6e 20 74 68 65 6e  some reason then
20f0: 20 6f 6e 20 72 65 2d 72 75 6e 20 75 73 69 6e 67   on re-run using
2100: 20 2d 6b 65 65 70 67 6f 69 6e 67 20 74 68 65 20   -keepgoing the 
2110: 72 75 6e 20 63 61 6e 20 6e 65 76 65 72 20 63 6f  run can never co
2120: 6d 70 6c 65 74 65 2e 0a 09 20 20 28 64 62 3a 64  mplete...  (db:d
2130: 65 6c 65 74 65 2d 74 65 73 74 73 2d 69 6e 2d 73  elete-tests-in-s
2140: 74 61 74 65 20 64 62 20 72 75 6e 2d 69 64 20 22  tate db run-id "
2150: 4e 4f 54 5f 53 54 41 52 54 45 44 22 29 0a 09 20  NOT_STARTED").. 
2160: 20 28 72 64 62 3a 73 65 74 2d 74 65 73 74 73 2d   (rdb:set-tests-
2170: 73 74 61 74 65 2d 73 74 61 74 75 73 20 64 62 20  state-status db 
2180: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
2190: 73 20 23 66 20 22 46 41 49 4c 22 20 22 4e 4f 54  s #f "FAIL" "NOT
21a0: 5f 53 54 41 52 54 45 44 22 20 22 46 41 49 4c 22  _STARTED" "FAIL"
21b0: 29 29 29 0a 0a 20 20 20 20 3b 3b 20 6e 6f 77 20  )))..    ;; now 
21c0: 61 64 64 20 6e 6f 6e 2d 64 69 72 65 63 74 6c 79  add non-directly
21d0: 20 72 65 66 65 72 65 6e 63 65 64 20 64 65 70 65   referenced depe
21e0: 6e 64 65 6e 63 69 65 73 20 28 69 2e 65 2e 20 77  ndencies (i.e. w
21f0: 61 69 74 6f 6e 29 0a 20 20 20 20 28 69 66 20 28  aiton).    (if (
2200: 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 65 73 74 2d  not (null? test-
2210: 6e 61 6d 65 73 29 29 0a 09 28 6c 65 74 20 6c 6f  names))..(let lo
2220: 6f 70 20 28 28 68 65 64 20 28 63 61 72 20 74 65  op ((hed (car te
2230: 73 74 2d 6e 61 6d 65 73 29 29 0a 09 09 20 20 20  st-names))...   
2240: 28 74 61 6c 20 28 63 64 72 20 74 65 73 74 2d 6e  (tal (cdr test-n
2250: 61 6d 65 73 29 29 29 20 20 20 20 20 20 20 20 20  ames)))         
2260: 3b 3b 20 27 72 65 74 75 72 6e 2d 70 72 6f 63 73  ;; 'return-procs
2270: 20 74 65 6c 6c 73 20 74 68 65 20 63 6f 6e 66 69   tells the confi
2280: 67 20 72 65 61 64 65 72 20 74 6f 20 70 72 65 70  g reader to prep
2290: 20 72 75 6e 6e 69 6e 67 20 73 79 73 74 65 6d 20   running system 
22a0: 62 75 74 20 72 65 74 75 72 6e 20 61 20 70 72 6f  but return a pro
22b0: 63 0a 09 20 20 28 6c 65 74 2a 20 28 28 63 6f 6e  c..  (let* ((con
22c0: 66 69 67 20 20 28 74 65 73 74 3a 67 65 74 2d 74  fig  (test:get-t
22d0: 65 73 74 63 6f 6e 66 69 67 20 68 65 64 20 27 72  estconfig hed 'r
22e0: 65 74 75 72 6e 2d 70 72 6f 63 73 29 29 0a 09 09  eturn-procs))...
22f0: 20 28 77 61 69 74 6f 6e 73 20 28 73 74 72 69 6e   (waitons (strin
2300: 67 2d 73 70 6c 69 74 20 28 6c 65 74 20 28 28 77  g-split (let ((w
2310: 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20   (config-lookup 
2320: 63 6f 6e 66 69 67 20 22 72 65 71 75 69 72 65 6d  config "requirem
2330: 65 6e 74 73 22 20 22 77 61 69 74 6f 6e 22 29 29  ents" "waiton"))
2340: 29 0a 09 09 09 09 09 20 20 28 69 66 20 77 20 77  )......  (if w w
2350: 20 22 22 29 29 29 29 29 0a 09 20 20 20 20 3b 3b   "")))))..    ;;
2360: 20 28 69 74 65 6d 73 20 20 20 28 69 74 65 6d 73   (items   (items
2370: 3a 67 65 74 2d 69 74 65 6d 73 2d 66 72 6f 6d 2d  :get-items-from-
2380: 63 6f 6e 66 69 67 20 63 6f 6e 66 69 67 29 29 29  config config)))
2390: 0a 09 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28  ..    (if (not (
23a0: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64  hash-table-ref/d
23b0: 65 66 61 75 6c 74 20 74 65 73 74 2d 72 65 63 6f  efault test-reco
23c0: 72 64 73 20 68 65 64 20 23 66 29 29 0a 09 09 28  rds hed #f))...(
23d0: 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74 21 20  hash-table-set! 
23e0: 74 65 73 74 2d 72 65 63 6f 72 64 73 0a 09 09 09  test-records....
23f0: 09 20 68 65 64 20 28 76 65 63 74 6f 72 20 68 65  . hed (vector he
2400: 64 20 20 20 20 20 3b 3b 20 30 0a 09 09 09 09 09  d     ;; 0......
2410: 20 20 20 20 20 63 6f 6e 66 69 67 20 20 3b 3b 20       config  ;; 
2420: 31 0a 09 09 09 09 09 20 20 20 20 20 77 61 69 74  1......     wait
2430: 6f 6e 73 20 3b 3b 20 32 0a 09 09 09 09 09 20 20  ons ;; 2......  
2440: 20 20 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75     (config-looku
2450: 70 20 63 6f 6e 66 69 67 20 22 72 65 71 75 69 72  p config "requir
2460: 65 6d 65 6e 74 73 22 20 22 70 72 69 6f 72 69 74  ements" "priorit
2470: 79 22 29 20 20 20 20 20 3b 3b 20 70 72 69 6f 72  y")     ;; prior
2480: 69 74 79 20 33 0a 09 09 09 09 09 20 20 20 20 20  ity 3......     
2490: 28 6c 65 74 20 28 28 69 74 65 6d 73 20 20 20 20  (let ((items    
24a0: 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65    (hash-table-re
24b0: 66 2f 64 65 66 61 75 6c 74 20 63 6f 6e 66 69 67  f/default config
24c0: 20 22 69 74 65 6d 73 22 20 23 66 29 29 20 3b 3b   "items" #f)) ;;
24d0: 20 69 74 65 6d 73 20 34 0a 09 09 09 09 09 09 20   items 4....... 
24e0: 20 20 28 69 74 65 6d 73 74 61 62 6c 65 20 28 68    (itemstable (h
24f0: 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65  ash-table-ref/de
2500: 66 61 75 6c 74 20 63 6f 6e 66 69 67 20 22 69 74  fault config "it
2510: 65 6d 73 74 61 62 6c 65 22 20 23 66 29 29 29 20  emstable" #f))) 
2520: 0a 09 09 09 09 09 20 20 20 20 20 20 20 3b 3b 20  ......       ;; 
2530: 69 66 20 65 69 74 68 65 72 20 69 74 65 6d 73 20  if either items 
2540: 6f 72 20 69 74 65 6d 73 20 74 61 62 6c 65 20 69  or items table i
2550: 73 20 61 20 70 72 6f 63 20 72 65 74 75 72 6e 20  s a proc return 
2560: 69 74 20 73 6f 20 74 65 73 74 20 72 75 6e 6e 69  it so test runni
2570: 6e 67 0a 09 09 09 09 09 20 20 20 20 20 20 20 3b  ng......       ;
2580: 3b 20 70 72 6f 63 65 73 73 20 63 61 6e 20 6b 6e  ; process can kn
2590: 6f 77 20 74 6f 20 63 61 6c 6c 20 69 74 65 6d 73  ow to call items
25a0: 3a 67 65 74 2d 69 74 65 6d 73 2d 66 72 6f 6d 2d  :get-items-from-
25b0: 63 6f 6e 66 69 67 0a 09 09 09 09 09 20 20 20 20  config......    
25c0: 20 20 20 3b 3b 20 69 66 20 65 69 74 68 65 72 20     ;; if either 
25d0: 69 73 20 61 20 6c 69 73 74 20 61 6e 64 20 6e 6f  is a list and no
25e0: 6e 65 20 69 73 20 61 20 70 72 6f 63 20 67 6f 20  ne is a proc go 
25f0: 61 68 65 61 64 20 61 6e 64 20 63 61 6c 6c 20 67  ahead and call g
2600: 65 74 2d 69 74 65 6d 73 0a 09 09 09 09 09 20 20  et-items......  
2610: 20 20 20 20 20 3b 3b 20 6f 74 68 65 72 77 69 73       ;; otherwis
2620: 65 20 72 65 74 75 72 6e 20 23 66 20 2d 20 74 68  e return #f - th
2630: 69 73 20 69 73 20 6e 6f 74 20 61 6e 20 69 74 65  is is not an ite
2640: 72 61 74 65 64 20 74 65 73 74 0a 09 09 09 09 09  rated test......
2650: 20 20 20 20 20 20 20 28 63 6f 6e 64 0a 09 09 09         (cond....
2660: 09 09 09 28 28 70 72 6f 63 65 64 75 72 65 3f 20  ...((procedure? 
2670: 69 74 65 6d 73 29 20 20 20 20 20 20 0a 09 09 09  items)      ....
2680: 09 09 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ... (debug:print
2690: 20 34 20 22 49 4e 46 4f 3a 20 69 74 65 6d 73 20   4 "INFO: items 
26a0: 69 73 20 61 20 70 72 6f 63 65 64 75 72 65 2c 20  is a procedure, 
26b0: 77 69 6c 6c 20 63 61 6c 63 20 6c 61 74 65 72 22  will calc later"
26c0: 29 0a 09 09 09 09 09 09 20 69 74 65 6d 73 29 20  )....... items) 
26d0: 20 20 20 20 20 20 20 20 20 20 20 3b 3b 20 63 61             ;; ca
26e0: 6c 63 20 6c 61 74 65 72 0a 09 09 09 09 09 09 28  lc later.......(
26f0: 28 70 72 6f 63 65 64 75 72 65 3f 20 69 74 65 6d  (procedure? item
2700: 73 74 61 62 6c 65 29 0a 09 09 09 09 09 09 20 28  stable)....... (
2710: 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 49  debug:print 4 "I
2720: 4e 46 4f 3a 20 69 74 65 6d 73 74 61 62 6c 65 20  NFO: itemstable 
2730: 69 73 20 61 20 70 72 6f 63 65 64 75 72 65 2c 20  is a procedure, 
2740: 77 69 6c 6c 20 63 61 6c 63 20 6c 61 74 65 72 22  will calc later"
2750: 29 0a 09 09 09 09 09 09 20 69 74 65 6d 73 74 61  )....... itemsta
2760: 62 6c 65 29 20 20 20 20 20 20 20 3b 3b 20 63 61  ble)       ;; ca
2770: 6c 63 20 6c 61 74 65 72 0a 09 09 09 09 09 09 28  lc later.......(
2780: 28 66 69 6c 74 65 72 20 28 6c 61 6d 62 64 61 20  (filter (lambda 
2790: 28 78 29 0a 09 09 09 09 09 09 09 20 20 20 28 6c  (x)........   (l
27a0: 65 74 20 28 28 76 61 6c 20 28 63 61 72 20 78 29  et ((val (car x)
27b0: 29 29 0a 09 09 09 09 09 09 09 20 20 20 20 20 28  ))........     (
27c0: 69 66 20 28 70 72 6f 63 65 64 75 72 65 3f 20 76  if (procedure? v
27d0: 61 6c 29 20 76 61 6c 20 23 66 29 29 29 0a 09 09  al) val #f)))...
27e0: 09 09 09 09 09 20 28 61 70 70 65 6e 64 20 28 69  ..... (append (i
27f0: 66 20 28 6c 69 73 74 3f 20 69 74 65 6d 73 29 20  f (list? items) 
2800: 69 74 65 6d 73 20 27 28 29 29 0a 09 09 09 09 09  items '())......
2810: 09 09 09 20 28 69 66 20 28 6c 69 73 74 3f 20 69  ... (if (list? i
2820: 74 65 6d 73 74 61 62 6c 65 29 20 69 74 65 6d 73  temstable) items
2830: 74 61 62 6c 65 20 27 28 29 29 29 29 0a 09 09 09  table '())))....
2840: 09 09 09 20 27 68 61 76 65 2d 70 72 6f 63 65 64  ... 'have-proced
2850: 75 72 65 29 0a 09 09 09 09 09 09 28 28 6f 72 20  ure).......((or 
2860: 28 6c 69 73 74 3f 20 69 74 65 6d 73 29 28 6c 69  (list? items)(li
2870: 73 74 3f 20 69 74 65 6d 73 74 61 62 6c 65 29 29  st? itemstable))
2880: 20 3b 3b 20 63 61 6c 63 20 6e 6f 77 0a 09 09 09   ;; calc now....
2890: 09 09 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ... (debug:print
28a0: 20 34 20 22 49 4e 46 4f 3a 20 69 74 65 6d 73 20   4 "INFO: items 
28b0: 61 6e 64 20 69 74 65 6d 73 74 61 62 6c 65 20 61  and itemstable a
28c0: 72 65 20 6c 69 73 74 73 2c 20 63 61 6c 63 20 6e  re lists, calc n
28d0: 6f 77 5c 6e 22 0a 09 09 09 09 09 09 09 20 20 20  ow\n"........   
28e0: 20 20 20 22 20 20 20 20 69 74 65 6d 73 3a 20 22     "    items: "
28f0: 20 69 74 65 6d 73 20 22 20 69 74 65 6d 73 74 61   items " itemsta
2900: 62 6c 65 3a 20 22 20 69 74 65 6d 73 74 61 62 6c  ble: " itemstabl
2910: 65 29 0a 09 09 09 09 09 09 20 28 69 74 65 6d 73  e)....... (items
2920: 3a 67 65 74 2d 69 74 65 6d 73 2d 66 72 6f 6d 2d  :get-items-from-
2930: 63 6f 6e 66 69 67 20 63 6f 6e 66 69 67 29 29 0a  config config)).
2940: 09 09 09 09 09 09 28 65 6c 73 65 20 23 66 29 29  ......(else #f))
2950: 29 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  )               
2960: 20 20 20 20 20 20 20 20 20 20 20 20 3b 3b 20 6e              ;; n
2970: 6f 74 20 69 74 65 72 61 74 65 64 0a 09 09 09 09  ot iterated.....
2980: 09 20 20 20 20 20 23 66 20 20 20 20 20 20 3b 3b  .     #f      ;;
2990: 20 69 74 65 6d 73 64 61 74 20 35 0a 09 09 09 09   itemsdat 5.....
29a0: 09 20 20 20 20 20 3b 3b 20 23 66 20 20 20 20 20  .     ;; #f     
29b0: 20 3b 3b 20 73 70 61 72 65 0a 09 09 09 09 09 20   ;; spare...... 
29c0: 20 20 20 20 29 29 29 0a 09 20 20 20 20 28 66 6f      )))..    (fo
29d0: 72 2d 65 61 63 68 20 0a 09 20 20 20 20 20 28 6c  r-each ..     (l
29e0: 61 6d 62 64 61 20 28 77 61 69 74 6f 6e 29 0a 09  ambda (waiton)..
29f0: 20 20 20 20 20 20 20 28 69 66 20 28 61 6e 64 20         (if (and 
2a00: 77 61 69 74 6f 6e 20 28 6e 6f 74 20 28 6d 65 6d  waiton (not (mem
2a10: 62 65 72 20 77 61 69 74 6f 6e 20 74 65 73 74 2d  ber waiton test-
2a20: 6e 61 6d 65 73 29 29 29 0a 09 09 20 20 20 28 62  names)))...   (b
2a30: 65 67 69 6e 0a 09 09 20 20 20 20 20 28 73 65 74  egin...     (set
2a40: 21 20 72 65 71 75 69 72 65 64 2d 74 65 73 74 73  ! required-tests
2a50: 20 28 63 6f 6e 73 20 77 61 69 74 6f 6e 20 72 65   (cons waiton re
2a60: 71 75 69 72 65 64 2d 74 65 73 74 73 29 29 0a 09  quired-tests))..
2a70: 09 20 20 20 20 20 28 73 65 74 21 20 74 65 73 74  .     (set! test
2a80: 2d 6e 61 6d 65 73 20 28 63 6f 6e 73 20 77 61 69  -names (cons wai
2a90: 74 6f 6e 20 74 65 73 74 2d 6e 61 6d 65 73 29 29  ton test-names))
2aa0: 29 29 29 20 3b 3b 20 77 61 73 20 61 6e 20 61 70  ))) ;; was an ap
2ab0: 70 65 6e 64 2c 20 6e 6f 77 20 61 20 63 6f 6e 73  pend, now a cons
2ac0: 0a 09 20 20 20 20 20 77 61 69 74 6f 6e 73 29 0a  ..     waitons).
2ad0: 09 20 20 20 20 28 6c 65 74 20 28 28 72 65 6d 74  .    (let ((remt
2ae0: 65 73 74 73 20 28 64 65 6c 65 74 65 2d 64 75 70  ests (delete-dup
2af0: 6c 69 63 61 74 65 73 20 28 61 70 70 65 6e 64 20  licates (append 
2b00: 77 61 69 74 6f 6e 73 20 74 61 6c 29 29 29 29 0a  waitons tal)))).
2b10: 09 20 20 20 20 20 20 28 69 66 20 28 6e 6f 74 20  .      (if (not 
2b20: 28 6e 75 6c 6c 3f 20 72 65 6d 74 65 73 74 73 29  (null? remtests)
2b30: 29 0a 09 09 20 20 28 6c 6f 6f 70 20 28 63 61 72  )...  (loop (car
2b40: 20 72 65 6d 74 65 73 74 73 29 28 63 64 72 20 72   remtests)(cdr r
2b50: 65 6d 74 65 73 74 73 29 29 29 29 29 29 29 0a 0a  emtests)))))))..
2b60: 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28 6e 75      (if (not (nu
2b70: 6c 6c 3f 20 72 65 71 75 69 72 65 64 2d 74 65 73  ll? required-tes
2b80: 74 73 29 29 0a 09 28 64 65 62 75 67 3a 70 72 69  ts))..(debug:pri
2b90: 6e 74 20 31 20 22 49 4e 46 4f 3a 20 41 64 64 69  nt 1 "INFO: Addi
2ba0: 6e 67 20 22 20 72 65 71 75 69 72 65 64 2d 74 65  ng " required-te
2bb0: 73 74 73 20 22 20 74 6f 20 74 68 65 20 72 75 6e  sts " to the run
2bc0: 20 71 75 65 75 65 22 29 29 0a 20 20 20 20 3b 3b   queue")).    ;;
2bd0: 20 4e 4f 54 45 3a 20 74 68 65 73 65 20 61 72 65   NOTE: these are
2be0: 20 61 6c 6c 20 70 61 72 65 6e 74 20 74 65 73 74   all parent test
2bf0: 73 2c 20 69 74 65 6d 73 20 61 72 65 20 6e 6f 74  s, items are not
2c00: 20 65 78 70 61 6e 64 65 64 20 79 65 74 2e 0a 20   expanded yet.. 
2c10: 20 20 20 28 72 75 6e 73 3a 72 75 6e 2d 74 65 73     (runs:run-tes
2c20: 74 73 2d 71 75 65 75 65 20 64 62 20 72 75 6e 2d  ts-queue db run-
2c30: 69 64 20 72 75 6e 6e 61 6d 65 20 74 65 73 74 2d  id runname test-
2c40: 72 65 63 6f 72 64 73 20 6b 65 79 76 61 6c 6c 73  records keyvalls
2c50: 74 20 66 6c 61 67 73 29 0a 20 20 20 20 28 64 65  t flags).    (de
2c60: 62 75 67 3a 70 72 69 6e 74 20 34 20 22 49 4e 46  bug:print 4 "INF
2c70: 4f 3a 20 41 6c 6c 20 64 6f 6e 65 20 62 79 20 68  O: All done by h
2c80: 65 72 65 22 29 29 29 0a 0a 28 64 65 66 69 6e 65  ere")))..(define
2c90: 20 28 72 75 6e 73 3a 72 75 6e 2d 74 65 73 74 73   (runs:run-tests
2ca0: 2d 71 75 65 75 65 20 64 62 20 72 75 6e 2d 69 64  -queue db run-id
2cb0: 20 72 75 6e 6e 61 6d 65 20 74 65 73 74 2d 72 65   runname test-re
2cc0: 63 6f 72 64 73 20 6b 65 79 76 61 6c 6c 73 74 20  cords keyvallst 
2cd0: 66 6c 61 67 73 29 0a 20 20 20 20 3b 3b 20 41 74  flags).    ;; At
2ce0: 20 74 68 69 73 20 70 6f 69 6e 74 20 74 68 65 20   this point the 
2cf0: 6c 69 73 74 20 6f 66 20 70 61 72 65 6e 74 20 74  list of parent t
2d00: 65 73 74 73 20 69 73 20 65 78 70 61 6e 64 65 64  ests is expanded
2d10: 20 0a 20 20 20 20 3b 3b 20 4e 42 2f 2f 20 53 68   .    ;; NB// Sh
2d20: 6f 75 6c 64 20 65 78 70 61 6e 64 20 69 74 65 6d  ould expand item
2d30: 73 20 68 65 72 65 20 61 6e 64 20 74 68 65 6e 20  s here and then 
2d40: 69 6e 73 65 72 74 20 69 6e 74 6f 20 74 68 65 20  insert into the 
2d50: 72 75 6e 20 71 75 65 75 65 2e 0a 20 20 28 64 65  run queue..  (de
2d60: 62 75 67 3a 70 72 69 6e 74 20 35 20 22 74 65 73  bug:print 5 "tes
2d70: 74 2d 72 65 63 6f 72 64 73 3a 20 22 20 74 65 73  t-records: " tes
2d80: 74 2d 72 65 63 6f 72 64 73 20 22 2c 20 6b 65 79  t-records ", key
2d90: 76 61 6c 6c 73 74 3a 20 22 20 6b 65 79 76 61 6c  vallst: " keyval
2da0: 6c 73 74 29 0a 20 20 28 6c 65 74 20 28 28 73 6f  lst).  (let ((so
2db0: 72 74 65 64 2d 74 65 73 74 2d 6e 61 6d 65 73 20  rted-test-names 
2dc0: 28 74 65 73 74 73 3a 73 6f 72 74 2d 62 79 2d 70  (tests:sort-by-p
2dd0: 72 69 6f 72 69 74 79 2d 61 6e 64 2d 77 61 69 74  riority-and-wait
2de0: 6f 6e 20 74 65 73 74 2d 72 65 63 6f 72 64 73 29  on test-records)
2df0: 29 0a 09 28 69 74 65 6d 2d 70 61 74 74 73 20 20  )..(item-patts  
2e00: 20 20 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c        (hash-tabl
2e10: 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 66 6c  e-ref/default fl
2e20: 61 67 73 20 22 2d 69 74 65 6d 70 61 74 74 22 20  ags "-itempatt" 
2e30: 23 66 29 29 29 0a 20 20 20 20 28 6c 65 74 20 6c  #f))).    (let l
2e40: 6f 6f 70 20 28 3b 20 28 6e 75 6d 74 69 6d 65 73  oop (; (numtimes
2e50: 20 30 29 20 3b 3b 20 73 68 6f 75 6c 64 6e 27 74   0) ;; shouldn't
2e60: 20 6e 65 65 64 20 74 68 69 73 0a 09 20 20 20 20   need this..    
2e70: 20 20 20 28 68 65 64 20 20 20 20 20 20 20 20 20     (hed         
2e80: 28 63 61 72 20 73 6f 72 74 65 64 2d 74 65 73 74  (car sorted-test
2e90: 2d 6e 61 6d 65 73 29 29 0a 09 20 20 20 20 20 20  -names))..      
2ea0: 20 28 74 61 6c 20 20 20 20 20 20 20 20 20 28 63   (tal         (c
2eb0: 64 72 20 73 6f 72 74 65 64 2d 74 65 73 74 2d 6e  dr sorted-test-n
2ec0: 61 6d 65 73 29 29 29 0a 20 20 20 20 20 20 28 6c  ames))).      (l
2ed0: 65 74 2a 20 28 28 74 65 73 74 2d 72 65 63 6f 72  et* ((test-recor
2ee0: 64 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65  d (hash-table-re
2ef0: 66 20 74 65 73 74 2d 72 65 63 6f 72 64 73 20 68  f test-records h
2f00: 65 64 29 29 0a 09 20 20 20 20 20 28 74 63 6f 6e  ed))..     (tcon
2f10: 66 69 67 20 20 20 20 20 28 74 65 73 74 73 3a 74  fig     (tests:t
2f20: 65 73 74 71 75 65 75 65 2d 67 65 74 2d 74 65 73  estqueue-get-tes
2f30: 74 63 6f 6e 66 69 67 20 74 65 73 74 2d 72 65 63  tconfig test-rec
2f40: 6f 72 64 29 29 0a 09 20 20 20 20 20 28 77 61 69  ord))..     (wai
2f50: 74 6f 6e 73 20 20 20 20 20 28 74 65 73 74 73 3a  tons     (tests:
2f60: 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d 77 61  testqueue-get-wa
2f70: 69 74 6f 6e 73 20 20 20 20 74 65 73 74 2d 72 65  itons    test-re
2f80: 63 6f 72 64 29 29 0a 09 20 20 20 20 20 28 70 72  cord))..     (pr
2f90: 69 6f 72 69 74 79 20 20 20 20 28 74 65 73 74 73  iority    (tests
2fa0: 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d 70  :testqueue-get-p
2fb0: 72 69 6f 72 69 74 79 20 20 20 74 65 73 74 2d 72  riority   test-r
2fc0: 65 63 6f 72 64 29 29 0a 09 20 20 20 20 20 28 69  ecord))..     (i
2fd0: 74 65 6d 64 61 74 20 20 20 20 20 28 74 65 73 74  temdat     (test
2fe0: 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d  s:testqueue-get-
2ff0: 69 74 65 6d 64 61 74 20 20 20 20 74 65 73 74 2d  itemdat    test-
3000: 72 65 63 6f 72 64 29 29 0a 09 20 20 20 20 20 28  record))..     (
3010: 69 74 65 6d 73 20 20 20 20 20 20 20 28 74 65 73  items       (tes
3020: 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74  ts:testqueue-get
3030: 2d 69 74 65 6d 73 20 20 20 20 20 20 74 65 73 74  -items      test
3040: 2d 72 65 63 6f 72 64 29 29 0a 09 20 20 20 20 20  -record))..     
3050: 28 69 74 65 6d 2d 70 61 74 68 20 20 20 28 69 74  (item-path   (it
3060: 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69 74  em-list->path it
3070: 65 6d 64 61 74 29 29 29 0a 09 28 64 65 62 75 67  emdat)))..(debug
3080: 3a 70 72 69 6e 74 20 36 0a 09 09 20 20 20 20 20  :print 6...     
3090: 22 69 74 65 6d 64 61 74 3a 20 20 20 20 20 22 20  "itemdat:     " 
30a0: 69 74 65 6d 64 61 74 0a 09 09 20 20 20 20 20 22  itemdat...     "
30b0: 5c 6e 20 20 69 74 65 6d 73 3a 20 20 20 20 20 22  \n  items:     "
30c0: 20 69 74 65 6d 73 0a 09 09 20 20 20 20 20 22 5c   items...     "\
30d0: 6e 20 20 69 74 65 6d 2d 70 61 74 68 3a 20 22 20  n  item-path: " 
30e0: 69 74 65 6d 2d 70 61 74 68 29 0a 09 28 63 6f 6e  item-path)..(con
30f0: 64 0a 09 20 28 28 6e 6f 74 20 69 74 65 6d 73 29  d.. ((not items)
3100: 20 3b 3b 20 77 68 65 6e 20 66 61 6c 73 65 20 74   ;; when false t
3110: 68 65 20 74 65 73 74 20 69 73 20 6f 6b 20 74 6f  he test is ok to
3120: 20 62 65 20 68 61 6e 64 65 64 20 6f 66 66 20 74   be handed off t
3130: 6f 20 6c 61 75 6e 63 68 20 28 62 75 74 20 6e 6f  o launch (but no
3140: 74 20 62 65 66 6f 72 65 29 0a 09 20 20 28 6c 65  t before)..  (le
3150: 74 20 28 28 68 61 76 65 2d 72 65 73 6f 75 72 63  t ((have-resourc
3160: 65 73 20 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75  es  (runs:can-ru
3170: 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64 62 20  n-more-tests db 
3180: 74 65 73 74 2d 72 65 63 6f 72 64 29 29 20 3b 3b  test-record)) ;;
3190: 20 6c 6f 6f 6b 20 61 74 20 74 68 65 20 74 65 73   look at the tes
31a0: 74 20 6a 6f 62 67 72 6f 75 70 20 61 6e 64 20 74  t jobgroup and t
31b0: 6f 74 20 6a 6f 62 73 20 72 75 6e 6e 69 6e 67 0a  ot jobs running.
31c0: 09 09 28 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d  ..(prereqs-not-m
31d0: 65 74 20 28 64 62 3a 67 65 74 2d 70 72 65 72 65  et (db:get-prere
31e0: 71 73 2d 6e 6f 74 2d 6d 65 74 20 64 62 20 72 75  qs-not-met db ru
31f0: 6e 2d 69 64 20 77 61 69 74 6f 6e 73 20 69 74 65  n-id waitons ite
3200: 6d 2d 70 61 74 68 29 29 29 0a 09 20 20 20 20 3b  m-path)))..    ;
3210: 3b 20 44 6f 6e 27 74 20 6b 6e 6f 77 20 61 74 20  ; Don't know at 
3220: 74 68 69 73 20 74 69 6d 65 20 69 66 20 74 68 65  this time if the
3230: 20 74 65 73 74 20 68 61 76 65 20 62 65 65 6e 20   test have been 
3240: 6c 61 75 6e 63 68 65 64 20 61 74 20 73 6f 6d 65  launched at some
3250: 20 74 69 6d 65 20 69 6e 20 74 68 65 20 70 61 73   time in the pas
3260: 74 0a 09 20 20 20 20 3b 3b 20 69 2e 65 2e 20 69  t..    ;; i.e. i
3270: 73 20 74 68 69 73 20 61 20 72 65 2d 6c 61 75 6e  s this a re-laun
3280: 63 68 3f 0a 09 20 20 20 20 28 69 66 20 28 61 6e  ch?..    (if (an
3290: 64 20 68 61 76 65 2d 72 65 73 6f 75 72 63 65 73  d have-resources
32a0: 0a 09 09 20 20 20 20 20 28 6e 75 6c 6c 3f 20 70  ...     (null? p
32b0: 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 29 29  rereqs-not-met))
32c0: 0a 09 09 3b 3b 20 6e 6f 20 6c 6f 6f 70 20 2d 20  ...;; no loop - 
32d0: 64 72 6f 70 20 74 68 6f 75 67 68 20 61 6e 64 20  drop though and 
32e0: 75 73 65 20 74 68 65 20 6c 6f 6f 70 20 61 74 20  use the loop at 
32f0: 74 68 65 20 62 6f 74 74 6f 6d 20 0a 09 09 28 72  the bottom ...(r
3300: 75 6e 3a 74 65 73 74 20 64 62 20 72 75 6e 2d 69  un:test db run-i
3310: 64 20 72 75 6e 6e 61 6d 65 20 6b 65 79 76 61 6c  d runname keyval
3320: 6c 73 74 20 74 65 73 74 2d 72 65 63 6f 72 64 20  lst test-record 
3330: 66 6c 61 67 73 20 23 66 29 0a 09 09 3b 3b 20 65  flags #f)...;; e
3340: 6c 73 65 20 74 68 65 20 72 75 6e 20 69 73 20 73  lse the run is s
3350: 74 75 63 6b 2c 20 74 65 6d 70 6f 72 61 72 69 6c  tuck, temporaril
3360: 79 20 6f 72 20 70 65 72 6d 61 6e 65 6e 74 6c 79  y or permanently
3370: 0a 09 09 28 6c 65 74 20 28 28 6e 65 77 74 61 6c  ...(let ((newtal
3380: 20 28 61 70 70 65 6e 64 20 74 61 6c 20 28 6c 69   (append tal (li
3390: 73 74 20 68 65 64 29 29 29 29 0a 09 09 20 20 3b  st hed))))...  ;
33a0: 3b 20 63 6f 75 6c 64 6e 27 74 20 72 75 6e 2c 20  ; couldn't run, 
33b0: 74 61 6b 65 20 61 20 62 72 65 61 74 68 65 72 0a  take a breather.
33c0: 09 09 20 20 28 74 68 72 65 61 64 2d 73 6c 65 65  ..  (thread-slee
33d0: 70 21 20 34 29 0a 09 09 20 20 28 6c 6f 6f 70 20  p! 4)...  (loop 
33e0: 28 63 61 72 20 6e 65 77 74 61 6c 29 28 63 64 72  (car newtal)(cdr
33f0: 20 6e 65 77 74 61 6c 29 29 29 29 29 29 0a 09 20   newtal)))))).. 
3400: 0a 09 20 3b 3b 20 63 61 73 65 20 77 68 65 72 65  .. ;; case where
3410: 20 61 6e 20 69 74 65 6d 73 20 63 61 6d 65 20 69   an items came i
3420: 6e 20 61 73 20 61 20 6c 69 73 74 20 62 65 65 6e  n as a list been
3430: 20 70 72 6f 63 65 73 73 65 64 0a 09 20 28 28 61   processed.. ((a
3440: 6e 64 20 28 6c 69 73 74 3f 20 69 74 65 6d 73 29  nd (list? items)
3450: 20 20 20 20 20 3b 3b 20 74 68 75 73 20 77 65 20       ;; thus we 
3460: 6b 6e 6f 77 20 6f 75 72 20 69 74 65 6d 73 20 61  know our items a
3470: 72 65 20 61 6c 72 65 61 64 79 20 63 61 6c 63 75  re already calcu
3480: 6c 61 74 65 64 0a 09 20 20 20 20 20 20 20 28 6e  lated..       (n
3490: 6f 74 20 20 20 69 74 65 6d 64 61 74 29 29 20 3b  ot   itemdat)) ;
34a0: 3b 20 61 6e 64 20 6e 6f 74 20 79 65 74 20 65 78  ; and not yet ex
34b0: 70 61 6e 64 65 64 20 69 6e 74 6f 20 74 68 65 20  panded into the 
34c0: 6c 69 73 74 20 6f 66 20 74 68 69 6e 67 73 20 74  list of things t
34d0: 6f 20 62 65 20 64 6f 6e 65 0a 09 20 20 28 69 66  o be done..  (if
34e0: 20 28 3e 3d 20 2a 76 65 72 62 6f 73 69 74 79 2a   (>= *verbosity*
34f0: 20 31 29 28 70 70 20 69 74 65 6d 73 29 29 0a 09   1)(pp items))..
3500: 20 20 3b 3b 20 28 69 66 20 28 3e 3d 20 2a 76 65    ;; (if (>= *ve
3510: 72 62 6f 73 69 74 79 2a 20 35 29 0a 09 20 20 3b  rbosity* 5)..  ;
3520: 3b 20 20 20 20 20 28 62 65 67 69 6e 0a 09 20 20  ;     (begin..  
3530: 3b 3b 20 20 20 20 20 20 20 28 70 72 69 6e 74 20  ;;       (print 
3540: 22 69 74 65 6d 73 3a 20 22 29 20 20 20 20 20 28  "items: ")     (
3550: 70 70 20 28 69 74 65 6d 2d 61 73 73 6f 63 2d 3e  pp (item-assoc->
3560: 69 74 65 6d 2d 6c 69 73 74 20 69 74 65 6d 73 29  item-list items)
3570: 29 0a 09 20 20 3b 3b 20 20 20 20 20 20 20 28 70  )..  ;;       (p
3580: 72 69 6e 74 20 22 69 74 65 6d 73 74 61 62 6c 65  rint "itemstable
3590: 3a 20 22 29 28 70 70 20 28 69 74 65 6d 2d 74 61  : ")(pp (item-ta
35a0: 62 6c 65 2d 3e 69 74 65 6d 2d 6c 69 73 74 20 69  ble->item-list i
35b0: 74 65 6d 73 74 61 62 6c 65 29 29 29 29 0a 09 20  temstable)))).. 
35c0: 20 28 66 6f 72 2d 65 61 63 68 0a 09 20 20 20 28   (for-each..   (
35d0: 6c 61 6d 62 64 61 20 28 6d 79 2d 69 74 65 6d 64  lambda (my-itemd
35e0: 61 74 29 0a 09 20 20 20 20 20 28 6c 65 74 2a 20  at)..     (let* 
35f0: 28 28 6e 65 77 2d 74 65 73 74 2d 72 65 63 6f 72  ((new-test-recor
3600: 64 20 28 6c 65 74 20 28 28 6e 65 77 72 65 63 20  d (let ((newrec 
3610: 28 6d 61 6b 65 2d 74 65 73 74 73 3a 74 65 73 74  (make-tests:test
3620: 71 75 65 75 65 29 29 29 0a 09 09 09 09 20 20 20  queue))).....   
3630: 20 20 20 20 28 76 65 63 74 6f 72 2d 63 6f 70 79      (vector-copy
3640: 21 20 74 65 73 74 2d 72 65 63 6f 72 64 20 6e 65  ! test-record ne
3650: 77 72 65 63 29 0a 09 09 09 09 20 20 20 20 20 20  wrec).....      
3660: 20 6e 65 77 72 65 63 29 29 0a 09 09 20 20 20 20   newrec))...    
3670: 28 6d 79 2d 69 74 65 6d 2d 70 61 74 68 20 28 69  (my-item-path (i
3680: 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 6d  tem-list->path m
3690: 79 2d 69 74 65 6d 64 61 74 29 29 0a 09 09 20 20  y-itemdat))...  
36a0: 20 20 28 69 74 65 6d 2d 6d 61 74 63 68 65 73 20    (item-matches 
36b0: 28 69 66 20 69 74 65 6d 2d 70 61 74 74 73 20 20  (if item-patts  
36c0: 20 20 20 20 20 3b 3b 20 68 65 72 65 20 77 65 20       ;; here we 
36d0: 61 72 65 20 66 69 6c 74 65 72 69 6e 67 20 66 6f  are filtering fo
36e0: 72 20 6d 61 74 63 68 65 73 20 77 69 74 68 20 2d  r matches with -
36f0: 69 74 65 6d 70 61 74 74 0a 09 09 09 09 20 20 20  itempatt.....   
3700: 20 20 20 28 6c 65 74 20 28 28 72 65 73 20 23 66     (let ((res #f
3710: 29 29 09 20 3b 3b 20 6c 6f 6f 6b 20 74 68 72 6f  )). ;; look thro
3720: 75 67 68 20 61 6c 6c 20 74 68 65 20 69 74 65 6d  ugh all the item
3730: 2d 70 61 74 74 73 20 69 66 20 64 65 66 69 6e 65  -patts if define
3740: 64 2c 20 66 6f 72 6d 61 74 20 69 73 20 70 61 74  d, format is pat
3750: 74 31 2c 70 61 74 74 32 2c 70 61 74 74 33 20 2e  t1,patt2,patt3 .
3760: 2e 2e 20 77 69 6c 64 63 61 72 64 20 69 73 20 25  .. wildcard is %
3770: 0a 09 09 09 09 09 28 66 6f 72 2d 65 61 63 68 20  ......(for-each 
3780: 0a 09 09 09 09 09 20 28 6c 61 6d 62 64 61 20 28  ...... (lambda (
3790: 70 61 74 74 29 0a 09 09 09 09 09 20 20 20 28 69  patt)......   (i
37a0: 66 20 28 73 74 72 69 6e 67 2d 73 65 61 72 63 68  f (string-search
37b0: 20 28 67 6c 6f 62 2d 3e 72 65 67 65 78 70 0a 09   (glob->regexp..
37c0: 09 09 09 09 09 09 20 20 20 20 20 20 20 28 73 74  ......       (st
37d0: 72 69 6e 67 2d 74 72 61 6e 73 6c 61 74 65 20 70  ring-translate p
37e0: 61 74 74 20 22 25 22 20 22 2a 22 29 29 0a 09 09  att "%" "*"))...
37f0: 09 09 09 09 09 20 20 20 20 20 20 69 74 65 6d 2d  .....      item-
3800: 70 61 74 68 29 0a 09 09 09 09 09 20 20 20 20 20  path)......     
3810: 20 20 28 73 65 74 21 20 72 65 73 20 23 74 29 29    (set! res #t))
3820: 29 0a 09 09 09 09 09 20 28 73 74 72 69 6e 67 2d  )...... (string-
3830: 73 70 6c 69 74 20 69 74 65 6d 2d 70 61 74 74 73  split item-patts
3840: 20 22 2c 22 29 29 0a 09 09 09 09 09 72 65 73 29   ","))......res)
3850: 0a 09 09 09 09 20 20 20 20 20 20 23 74 29 29 29  .....      #t)))
3860: 0a 09 20 20 20 20 20 20 20 28 69 66 20 69 74 65  ..       (if ite
3870: 6d 2d 6d 61 74 63 68 65 73 20 3b 3b 20 79 65 73  m-matches ;; yes
3880: 2c 20 77 65 20 77 61 6e 74 20 74 6f 20 70 72 6f  , we want to pro
3890: 63 65 73 73 20 74 68 69 73 20 69 74 65 6d 0a 09  cess this item..
38a0: 09 20 20 20 28 6c 65 74 20 28 28 6e 65 77 74 65  .   (let ((newte
38b0: 73 74 6e 61 6d 65 20 28 63 6f 6e 63 20 68 65 64  stname (conc hed
38c0: 20 22 2f 22 20 6d 79 2d 69 74 65 6d 2d 70 61 74   "/" my-item-pat
38d0: 68 29 29 29 20 0a 09 09 20 20 20 20 20 28 74 65  h))) ...     (te
38e0: 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d 73 65  sts:testqueue-se
38f0: 74 2d 69 74 65 6d 73 21 20 20 20 6e 65 77 2d 74  t-items!   new-t
3900: 65 73 74 2d 72 65 63 6f 72 64 20 23 66 29 0a 09  est-record #f)..
3910: 09 20 20 20 20 20 28 74 65 73 74 73 3a 74 65 73  .     (tests:tes
3920: 74 71 75 65 75 65 2d 73 65 74 2d 69 74 65 6d 64  tqueue-set-itemd
3930: 61 74 21 20 6e 65 77 2d 74 65 73 74 2d 72 65 63  at! new-test-rec
3940: 6f 72 64 20 6d 79 2d 69 74 65 6d 64 61 74 29 0a  ord my-itemdat).
3950: 09 09 20 20 20 20 20 28 68 61 73 68 2d 74 61 62  ..     (hash-tab
3960: 6c 65 2d 73 65 74 21 20 74 65 73 74 2d 72 65 63  le-set! test-rec
3970: 6f 72 64 73 20 6e 65 77 74 65 73 74 6e 61 6d 65  ords newtestname
3980: 20 6e 65 77 2d 74 65 73 74 2d 72 65 63 6f 72 64   new-test-record
3990: 29 0a 09 09 20 20 20 20 20 28 73 65 74 21 20 74  )...     (set! t
39a0: 61 6c 20 28 63 6f 6e 73 20 6e 65 77 74 65 73 74  al (cons newtest
39b0: 6e 61 6d 65 20 74 61 6c 29 29 29 29 29 29 20 3b  name tal)))))) ;
39c0: 3b 20 73 69 6e 63 65 20 74 68 65 73 65 20 61 72  ; since these ar
39d0: 65 20 69 74 65 6d 69 7a 65 64 20 63 72 65 61 74  e itemized creat
39e0: 65 20 6e 65 77 20 74 65 73 74 20 6e 61 6d 65 73  e new test names
39f0: 20 74 65 73 74 6e 61 6d 65 2f 69 74 65 6d 70 61   testname/itempa
3a00: 74 68 0a 09 20 20 20 69 74 65 6d 73 29 0a 09 20  th..   items).. 
3a10: 20 28 6c 6f 6f 70 20 28 63 61 72 20 74 61 6c 29   (loop (car tal)
3a20: 28 63 64 72 20 74 61 6c 29 29 29 0a 0a 09 20 3b  (cdr tal)))... ;
3a30: 3b 20 69 66 20 69 74 65 6d 73 20 69 73 20 61 20  ; if items is a 
3a40: 70 72 6f 63 20 74 68 65 6e 20 6e 65 65 64 20 74  proc then need t
3a50: 6f 20 72 75 6e 20 69 74 65 6d 73 3a 67 65 74 2d  o run items:get-
3a60: 69 74 65 6d 73 2d 66 72 6f 6d 2d 63 6f 6e 66 69  items-from-confi
3a70: 67 2c 20 67 65 74 20 74 68 65 20 6c 69 73 74 20  g, get the list 
3a80: 61 6e 64 20 6c 6f 6f 70 20 0a 09 20 3b 3b 20 20  and loop .. ;;  
3a90: 20 20 2d 20 62 75 74 20 6f 6e 6c 79 20 64 6f 20    - but only do 
3aa0: 74 68 61 74 20 69 66 20 72 65 73 6f 75 72 63 65  that if resource
3ab0: 73 20 65 78 69 73 74 20 74 6f 20 6b 69 63 6b 20  s exist to kick 
3ac0: 6f 66 66 20 74 68 65 20 6a 6f 62 0a 09 20 28 28  off the job.. ((
3ad0: 6f 72 20 28 70 72 6f 63 65 64 75 72 65 3f 20 69  or (procedure? i
3ae0: 74 65 6d 73 29 28 65 71 3f 20 69 74 65 6d 73 20  tems)(eq? items 
3af0: 27 68 61 76 65 2d 70 72 6f 63 65 64 75 72 65 29  'have-procedure)
3b00: 29 0a 09 20 20 28 69 66 20 28 61 6e 64 20 28 72  )..  (if (and (r
3b10: 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65  uns:can-run-more
3b20: 2d 74 65 73 74 73 20 64 62 20 74 65 73 74 2d 72  -tests db test-r
3b30: 65 63 6f 72 64 29 0a 09 09 20 20 20 28 6e 75 6c  ecord)...   (nul
3b40: 6c 3f 20 28 64 62 3a 67 65 74 2d 70 72 65 72 65  l? (db:get-prere
3b50: 71 73 2d 6e 6f 74 2d 6d 65 74 20 64 62 20 72 75  qs-not-met db ru
3b60: 6e 2d 69 64 20 77 61 69 74 6f 6e 73 20 69 74 65  n-id waitons ite
3b70: 6d 2d 70 61 74 68 29 29 29 0a 09 20 20 20 20 20  m-path)))..     
3b80: 20 28 6c 65 74 20 28 28 74 65 73 74 2d 6e 61 6d   (let ((test-nam
3b90: 65 20 28 74 65 73 74 73 3a 74 65 73 74 71 75 65  e (tests:testque
3ba0: 75 65 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20  ue-get-testname 
3bb0: 74 65 73 74 2d 72 65 63 6f 72 64 29 29 29 0a 09  test-record)))..
3bc0: 09 28 73 65 74 65 6e 76 20 22 4d 54 5f 54 45 53  .(setenv "MT_TES
3bd0: 54 5f 4e 41 4d 45 22 20 74 65 73 74 2d 6e 61 6d  T_NAME" test-nam
3be0: 65 29 20 3b 3b 20 0a 09 09 28 73 65 74 65 6e 76  e) ;; ...(setenv
3bf0: 20 22 4d 54 5f 52 55 4e 4e 41 4d 45 22 20 20 20   "MT_RUNNAME"   
3c00: 72 75 6e 6e 61 6d 65 29 0a 09 09 28 73 65 74 2d  runname)...(set-
3c10: 6d 65 67 61 74 65 73 74 2d 65 6e 76 2d 76 61 72  megatest-env-var
3c20: 73 20 64 62 20 72 75 6e 2d 69 64 29 20 3b 3b 20  s db run-id) ;; 
3c30: 74 68 65 73 65 20 6d 61 79 20 62 65 20 6e 65 65  these may be nee
3c40: 64 65 64 20 62 79 20 74 68 65 20 6c 61 75 6e 63  ded by the launc
3c50: 68 69 6e 67 20 70 72 6f 63 65 73 73 0a 09 09 28  hing process...(
3c60: 6c 65 74 20 28 28 69 74 65 6d 73 2d 6c 69 73 74  let ((items-list
3c70: 20 28 69 74 65 6d 73 3a 67 65 74 2d 69 74 65 6d   (items:get-item
3c80: 73 2d 66 72 6f 6d 2d 63 6f 6e 66 69 67 20 74 63  s-from-config tc
3c90: 6f 6e 66 69 67 29 29 29 0a 09 09 20 20 28 69 66  onfig)))...  (if
3ca0: 20 28 6c 69 73 74 3f 20 69 74 65 6d 73 2d 6c 69   (list? items-li
3cb0: 73 74 29 0a 09 09 20 20 20 20 20 20 28 62 65 67  st)...      (beg
3cc0: 69 6e 0a 09 09 09 28 74 65 73 74 73 3a 74 65 73  in....(tests:tes
3cd0: 74 71 75 65 75 65 2d 73 65 74 2d 69 74 65 6d 73  tqueue-set-items
3ce0: 21 20 74 65 73 74 2d 72 65 63 6f 72 64 20 69 74  ! test-record it
3cf0: 65 6d 73 2d 6c 69 73 74 29 0a 09 09 09 28 6c 6f  ems-list)....(lo
3d00: 6f 70 20 68 65 64 20 74 61 6c 29 29 0a 09 09 20  op hed tal))... 
3d10: 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09 09 28       (begin....(
3d20: 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45  debug:print 0 "E
3d30: 52 52 4f 52 3a 20 54 68 65 20 70 72 6f 63 20 66  RROR: The proc f
3d40: 72 6f 6d 20 72 65 61 64 69 6e 67 20 74 68 65 20  rom reading the 
3d50: 73 65 74 75 70 20 64 69 64 20 6e 6f 74 20 79 69  setup did not yi
3d60: 65 6c 64 20 61 20 6c 69 73 74 20 2d 20 70 6c 65  eld a list - ple
3d70: 61 73 65 20 72 65 70 6f 72 74 20 74 68 69 73 22  ase report this"
3d80: 29 0a 09 09 09 28 65 78 69 74 20 31 29 29 29 29  )....(exit 1))))
3d90: 29 0a 09 20 20 20 20 20 20 28 6c 65 74 20 28 28  )..      (let ((
3da0: 6e 65 77 74 61 6c 20 28 61 70 70 65 6e 64 20 74  newtal (append t
3db0: 61 6c 20 28 6c 69 73 74 20 68 65 64 29 29 29 29  al (list hed))))
3dc0: 0a 09 09 3b 3b 20 69 66 20 63 61 6e 27 74 20 72  ...;; if can't r
3dd0: 75 6e 20 6d 6f 72 65 20 74 65 73 74 73 2c 20 6c  un more tests, l
3de0: 65 74 73 20 74 61 6b 65 20 61 20 62 72 65 61 74  ets take a breat
3df0: 68 65 72 0a 09 09 28 74 68 72 65 61 64 2d 73 6c  her...(thread-sl
3e00: 65 65 70 21 20 31 29 0a 09 09 28 6c 6f 6f 70 20  eep! 1)...(loop 
3e10: 28 63 61 72 20 6e 65 77 74 61 6c 29 28 63 64 72  (car newtal)(cdr
3e20: 20 6e 65 77 74 61 6c 29 29 29 29 29 0a 0a 09 20   newtal)))))... 
3e30: 3b 3b 20 74 68 69 73 20 63 61 73 65 20 73 68 6f  ;; this case sho
3e40: 75 6c 64 20 6e 6f 74 20 68 61 70 70 65 6e 2c 20  uld not happen, 
3e50: 61 64 64 65 64 20 74 6f 20 68 65 6c 70 20 63 61  added to help ca
3e60: 74 63 68 20 61 6e 79 20 62 75 67 73 0a 09 20 28  tch any bugs.. (
3e70: 28 61 6e 64 20 28 6c 69 73 74 3f 20 69 74 65 6d  (and (list? item
3e80: 73 29 20 69 74 65 6d 64 61 74 29 0a 09 20 20 28  s) itemdat)..  (
3e90: 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45  debug:print 0 "E
3ea0: 52 52 4f 52 3a 20 53 68 6f 75 6c 64 20 6e 6f 74  RROR: Should not
3eb0: 20 68 61 76 65 20 61 20 6c 69 73 74 20 6f 66 20   have a list of 
3ec0: 69 74 65 6d 73 20 69 6e 20 61 20 74 65 73 74 20  items in a test 
3ed0: 61 6e 64 20 74 68 65 20 69 74 65 6d 73 70 61 74  and the itemspat
3ee0: 68 20 73 65 74 20 2d 20 70 6c 65 61 73 65 20 72  h set - please r
3ef0: 65 70 6f 72 74 20 74 68 69 73 22 29 0a 09 20 20  eport this")..  
3f00: 28 65 78 69 74 20 31 29 29 29 29 0a 09 0a 20 20  (exit 1))))...  
3f10: 20 20 20 20 3b 3b 20 77 65 20 67 65 74 20 68 65      ;; we get he
3f20: 72 65 20 6f 6e 20 22 64 72 6f 70 20 74 68 72 6f  re on "drop thro
3f30: 75 67 68 22 20 2d 20 6c 6f 6f 70 20 66 6f 72 20  ugh" - loop for 
3f40: 6e 65 78 74 20 74 65 73 74 20 69 6e 20 71 75 65  next test in que
3f50: 75 65 0a 20 20 20 20 20 20 28 69 66 20 28 6e 75  ue.      (if (nu
3f60: 6c 6c 3f 20 74 61 6c 29 0a 09 20 20 28 62 65 67  ll? tal)..  (beg
3f70: 69 6e 0a 09 20 20 20 20 3b 3b 20 46 49 58 4d 45  in..    ;; FIXME
3f80: 21 21 21 21 20 54 48 49 53 20 53 48 4f 55 4c 44  !!!! THIS SHOULD
3f90: 20 4e 4f 54 20 52 45 51 55 49 52 45 20 41 4e 20   NOT REQUIRE AN 
3fa0: 45 58 49 54 21 21 21 21 21 21 21 0a 09 20 20 20  EXIT!!!!!!!..   
3fb0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20   (debug:print 1 
3fc0: 22 49 4e 46 4f 3a 20 41 6c 6c 20 74 65 73 74 73  "INFO: All tests
3fd0: 20 6c 61 75 6e 63 68 65 64 2c 20 65 78 69 74 69   launched, exiti
3fe0: 6e 67 22 29 0a 09 20 20 20 20 28 65 78 69 74 20  ng")..    (exit 
3ff0: 30 29 29 0a 09 20 20 28 6c 6f 6f 70 20 28 63 61  0))..  (loop (ca
4000: 72 20 74 61 6c 29 28 63 64 72 20 74 61 6c 29 29  r tal)(cdr tal))
4010: 29 29 29 29 0a 0a 3b 3b 20 70 61 72 65 6e 74 2d  ))))..;; parent-
4020: 74 65 73 74 20 69 73 20 74 68 65 72 65 20 61 73  test is there as
4030: 20 61 20 70 6c 61 63 65 68 6f 6c 64 65 72 20 66   a placeholder f
4040: 6f 72 20 77 68 65 6e 20 70 61 72 65 6e 74 2d 74  or when parent-t
4050: 65 73 74 73 20 63 61 6e 20 62 65 20 72 75 6e 20  ests can be run 
4060: 61 73 20 61 20 73 65 74 75 70 20 73 74 65 70 0a  as a setup step.
4070: 28 64 65 66 69 6e 65 20 28 72 75 6e 3a 74 65 73  (define (run:tes
4080: 74 20 64 62 20 72 75 6e 2d 69 64 20 72 75 6e 6e  t db run-id runn
4090: 61 6d 65 20 6b 65 79 76 61 6c 6c 73 74 20 74 65  ame keyvallst te
40a0: 73 74 2d 72 65 63 6f 72 64 20 66 6c 61 67 73 20  st-record flags 
40b0: 70 61 72 65 6e 74 2d 74 65 73 74 29 0a 20 20 3b  parent-test).  ;
40c0: 3b 20 41 6c 6c 20 74 68 65 73 65 20 76 61 72 73  ; All these vars
40d0: 20 6d 69 67 68 74 20 62 65 20 72 65 66 65 72 65   might be refere
40e0: 6e 63 65 64 20 62 79 20 74 68 65 20 74 65 73 74  nced by the test
40f0: 63 6f 6e 66 69 67 20 66 69 6c 65 20 72 65 61 64  config file read
4100: 65 72 0a 20 20 28 6c 65 74 2a 20 28 28 74 65 73  er.  (let* ((tes
4110: 74 2d 6e 61 6d 65 20 20 20 20 28 74 65 73 74 73  t-name    (tests
4120: 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d 74  :testqueue-get-t
4130: 65 73 74 6e 61 6d 65 20 20 20 74 65 73 74 2d 72  estname   test-r
4140: 65 63 6f 72 64 29 29 0a 09 20 28 74 65 73 74 2d  ecord)).. (test-
4150: 77 61 69 74 6f 6e 73 20 28 74 65 73 74 73 3a 74  waitons (tests:t
4160: 65 73 74 71 75 65 75 65 2d 67 65 74 2d 77 61 69  estqueue-get-wai
4170: 74 6f 6e 73 20 20 20 20 74 65 73 74 2d 72 65 63  tons    test-rec
4180: 6f 72 64 29 29 0a 09 20 28 74 65 73 74 2d 63 6f  ord)).. (test-co
4190: 6e 66 20 20 20 20 28 74 65 73 74 73 3a 74 65 73  nf    (tests:tes
41a0: 74 71 75 65 75 65 2d 67 65 74 2d 74 65 73 74 63  tqueue-get-testc
41b0: 6f 6e 66 69 67 20 74 65 73 74 2d 72 65 63 6f 72  onfig test-recor
41c0: 64 29 29 0a 09 20 28 69 74 65 6d 64 61 74 20 20  d)).. (itemdat  
41d0: 20 20 20 20 28 74 65 73 74 73 3a 74 65 73 74 71      (tests:testq
41e0: 75 65 75 65 2d 67 65 74 2d 69 74 65 6d 64 61 74  ueue-get-itemdat
41f0: 20 20 20 20 74 65 73 74 2d 72 65 63 6f 72 64 29      test-record)
4200: 29 0a 09 20 28 74 65 73 74 2d 70 61 74 68 20 20  ).. (test-path  
4210: 20 20 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74 68    (conc *toppath
4220: 2a 20 22 2f 74 65 73 74 73 2f 22 20 74 65 73 74  * "/tests/" test
4230: 2d 6e 61 6d 65 29 29 20 3b 3b 20 63 6f 75 6c 64  -name)) ;; could
4240: 20 75 73 65 20 74 65 73 74 3a 67 65 74 2d 74 65   use test:get-te
4250: 73 74 63 6f 6e 66 69 67 20 68 65 72 65 20 2e 2e  stconfig here ..
4260: 2e 0a 09 20 28 66 6f 72 63 65 20 20 20 20 20 20  ... (force      
4270: 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65    (hash-table-re
4280: 66 2f 64 65 66 61 75 6c 74 20 66 6c 61 67 73 20  f/default flags 
4290: 22 2d 66 6f 72 63 65 22 20 23 66 29 29 0a 09 20  "-force" #f)).. 
42a0: 28 72 65 72 75 6e 20 20 20 20 20 20 20 20 28 68  (rerun        (h
42b0: 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65  ash-table-ref/de
42c0: 66 61 75 6c 74 20 66 6c 61 67 73 20 22 2d 72 65  fault flags "-re
42d0: 72 75 6e 22 20 23 66 29 29 0a 09 20 28 6b 65 65  run" #f)).. (kee
42e0: 70 67 6f 69 6e 67 20 20 20 20 28 68 61 73 68 2d  pgoing    (hash-
42f0: 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c  table-ref/defaul
4300: 74 20 66 6c 61 67 73 20 22 2d 6b 65 65 70 67 6f  t flags "-keepgo
4310: 69 6e 67 22 20 23 66 29 29 0a 09 20 28 69 74 65  ing" #f)).. (ite
4320: 6d 2d 70 61 74 68 20 20 20 20 20 22 22 29 29 0a  m-path     "")).
4330: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
4340: 20 35 0a 09 09 20 22 74 65 73 74 2d 63 6f 6e 66   5... "test-conf
4350: 69 67 3a 20 22 20 28 68 61 73 68 2d 74 61 62 6c  ig: " (hash-tabl
4360: 65 2d 3e 61 6c 69 73 74 20 74 65 73 74 2d 63 6f  e->alist test-co
4370: 6e 66 29 0a 09 09 20 22 5c 6e 20 20 20 69 74 65  nf)... "\n   ite
4380: 6d 64 61 74 3a 20 22 20 69 74 65 6d 64 61 74 0a  mdat: " itemdat.
4390: 09 09 20 29 0a 20 20 20 20 3b 3b 20 73 65 74 74  .. ).    ;; sett
43a0: 69 6e 67 20 69 74 65 6d 64 61 74 20 74 6f 20 61  ing itemdat to a
43b0: 20 6c 69 73 74 20 69 66 20 69 74 20 69 73 20 23   list if it is #
43c0: 66 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 69  f.    (if (not i
43d0: 74 65 6d 64 61 74 29 28 73 65 74 21 20 69 74 65  temdat)(set! ite
43e0: 6d 64 61 74 20 27 28 29 29 29 0a 20 20 20 20 28  mdat '())).    (
43f0: 73 65 74 21 20 69 74 65 6d 2d 70 61 74 68 20 28  set! item-path (
4400: 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20  item-list->path 
4410: 69 74 65 6d 64 61 74 29 29 0a 20 20 20 20 28 64  itemdat)).    (d
4420: 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 41 74  ebug:print 2 "At
4430: 74 65 6d 70 74 69 6e 67 20 74 6f 20 6c 61 75 6e  tempting to laun
4440: 63 68 20 74 65 73 74 20 22 20 74 65 73 74 2d 6e  ch test " test-n
4450: 61 6d 65 20 22 2f 22 20 69 74 65 6d 2d 70 61 74  ame "/" item-pat
4460: 68 29 0a 20 20 20 20 28 73 65 74 65 6e 76 20 22  h).    (setenv "
4470: 4d 54 5f 54 45 53 54 5f 4e 41 4d 45 22 20 74 65  MT_TEST_NAME" te
4480: 73 74 2d 6e 61 6d 65 29 20 3b 3b 20 0a 20 20 20  st-name) ;; .   
4490: 20 28 73 65 74 65 6e 76 20 22 4d 54 5f 52 55 4e   (setenv "MT_RUN
44a0: 4e 41 4d 45 22 20 20 20 72 75 6e 6e 61 6d 65 29  NAME"   runname)
44b0: 0a 20 20 20 20 28 73 65 74 2d 6d 65 67 61 74 65  .    (set-megate
44c0: 73 74 2d 65 6e 76 2d 76 61 72 73 20 64 62 20 72  st-env-vars db r
44d0: 75 6e 2d 69 64 29 20 3b 3b 20 74 68 65 73 65 20  un-id) ;; these 
44e0: 6d 61 79 20 62 65 20 6e 65 65 64 65 64 20 62 79  may be needed by
44f0: 20 74 68 65 20 6c 61 75 6e 63 68 69 6e 67 20 70   the launching p
4500: 72 6f 63 65 73 73 0a 20 20 20 20 28 63 68 61 6e  rocess.    (chan
4510: 67 65 2d 64 69 72 65 63 74 6f 72 79 20 2a 74 6f  ge-directory *to
4520: 70 70 61 74 68 2a 29 0a 0a 20 20 20 20 3b 3b 20  ppath*)..    ;; 
4530: 48 65 72 65 20 69 73 20 77 68 65 72 65 20 74 68  Here is where th
4540: 65 20 74 65 73 74 5f 6d 65 74 61 20 74 61 62 6c  e test_meta tabl
4550: 65 20 69 73 20 62 65 73 74 20 75 70 64 61 74 65  e is best update
4560: 64 0a 20 20 20 20 28 72 75 6e 73 3a 75 70 64 61  d.    (runs:upda
4570: 74 65 2d 74 65 73 74 5f 6d 65 74 61 20 64 62 20  te-test_meta db 
4580: 74 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 2d 63  test-name test-c
4590: 6f 6e 66 29 0a 20 20 20 20 0a 20 20 20 20 3b 3b  onf).    .    ;;
45a0: 20 28 6c 61 6d 62 64 61 20 28 69 74 65 6d 64 61   (lambda (itemda
45b0: 74 29 20 3b 3b 3b 20 28 28 72 69 70 65 6e 65 73  t) ;;; ((ripenes
45c0: 73 20 22 6f 76 65 72 72 69 70 65 22 29 20 28 74  s "overripe") (t
45d0: 65 6d 70 65 72 61 74 75 72 65 20 22 63 6f 6f 6c  emperature "cool
45e0: 22 29 20 28 73 65 61 73 6f 6e 20 22 73 75 6d 6d  ") (season "summ
45f0: 65 72 22 29 29 0a 20 20 20 20 28 6c 65 74 2a 20  er")).    (let* 
4600: 28 28 6e 65 77 2d 74 65 73 74 2d 70 61 74 68 20  ((new-test-path 
4610: 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65  (string-interspe
4620: 72 73 65 20 28 63 6f 6e 73 20 74 65 73 74 2d 70  rse (cons test-p
4630: 61 74 68 20 28 6d 61 70 20 63 61 64 72 20 69 74  ath (map cadr it
4640: 65 6d 64 61 74 29 29 20 22 2f 22 29 29 0a 09 20  emdat)) "/")).. 
4650: 20 20 28 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65    (new-test-name
4660: 20 28 69 66 20 28 65 71 75 61 6c 3f 20 69 74 65   (if (equal? ite
4670: 6d 2d 70 61 74 68 20 22 22 29 20 74 65 73 74 2d  m-path "") test-
4680: 6e 61 6d 65 20 28 63 6f 6e 63 20 74 65 73 74 2d  name (conc test-
4690: 6e 61 6d 65 20 22 2f 22 20 69 74 65 6d 2d 70 61  name "/" item-pa
46a0: 74 68 29 29 29 20 3b 3b 20 6a 75 73 74 20 6e 65  th))) ;; just ne
46b0: 65 64 20 69 74 20 74 6f 20 62 65 20 75 6e 69 71  ed it to be uniq
46c0: 75 65 0a 09 20 20 20 28 74 65 73 74 64 61 74 20  ue..   (testdat 
46d0: 20 20 20 20 20 20 28 72 64 62 3a 67 65 74 2d 74        (rdb:get-t
46e0: 65 73 74 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d  est-info db run-
46f0: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65  id test-name ite
4700: 6d 2d 70 61 74 68 29 29 29 0a 20 20 20 20 20 20  m-path))).      
4710: 28 69 66 20 28 6e 6f 74 20 74 65 73 74 64 61 74  (if (not testdat
4720: 29 0a 09 20 20 28 62 65 67 69 6e 0a 09 20 20 20  )..  (begin..   
4730: 20 3b 3b 20 65 6e 73 75 72 65 20 74 68 61 74 20   ;; ensure that 
4740: 74 68 65 20 70 61 74 68 20 65 78 69 73 74 73 20  the path exists 
4750: 62 65 66 6f 72 65 20 72 65 67 69 73 74 65 72 69  before registeri
4760: 6e 67 20 74 68 65 20 74 65 73 74 0a 09 20 20 20  ng the test..   
4770: 20 28 73 79 73 74 65 6d 20 28 63 6f 6e 63 20 22   (system (conc "
4780: 6d 6b 64 69 72 20 2d 70 20 22 20 6e 65 77 2d 74  mkdir -p " new-t
4790: 65 73 74 2d 70 61 74 68 29 29 0a 09 20 20 20 20  est-path))..    
47a0: 28 72 65 67 69 73 74 65 72 2d 74 65 73 74 20 64  (register-test d
47b0: 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  b run-id test-na
47c0: 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 20  me item-path).. 
47d0: 20 20 20 28 73 65 74 21 20 74 65 73 74 64 61 74     (set! testdat
47e0: 20 28 72 64 62 3a 67 65 74 2d 74 65 73 74 2d 69   (rdb:get-test-i
47f0: 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65  nfo db run-id te
4800: 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74  st-name item-pat
4810: 68 29 29 29 29 0a 20 20 20 20 20 20 28 63 68 61  h)))).      (cha
4820: 6e 67 65 2d 64 69 72 65 63 74 6f 72 79 20 74 65  nge-directory te
4830: 73 74 2d 70 61 74 68 29 0a 20 20 20 20 20 20 28  st-path).      (
4840: 63 61 73 65 20 28 69 66 20 66 6f 72 63 65 20 3b  case (if force ;
4850: 3b 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20  ; (args:get-arg 
4860: 22 2d 66 6f 72 63 65 22 29 0a 09 09 27 4e 4f 54  "-force")...'NOT
4870: 5f 53 54 41 52 54 45 44 0a 09 09 28 69 66 20 74  _STARTED...(if t
4880: 65 73 74 64 61 74 0a 09 09 20 20 20 20 28 73 74  estdat...    (st
4890: 72 69 6e 67 2d 3e 73 79 6d 62 6f 6c 20 28 74 65  ring->symbol (te
48a0: 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73  st:get-state tes
48b0: 74 64 61 74 29 29 0a 09 09 20 20 20 20 27 66 61  tdat))...    'fa
48c0: 69 6c 65 64 2d 74 6f 2d 69 6e 73 65 72 74 29 29  iled-to-insert))
48d0: 0a 09 28 28 66 61 69 6c 65 64 2d 74 6f 2d 69 6e  ..((failed-to-in
48e0: 73 65 72 74 29 0a 09 20 28 64 65 62 75 67 3a 70  sert).. (debug:p
48f0: 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 46  rint 0 "ERROR: F
4900: 61 69 6c 65 64 20 74 6f 20 69 6e 73 65 72 74 20  ailed to insert 
4910: 74 68 65 20 72 65 63 6f 72 64 20 69 6e 74 6f 20  the record into 
4920: 74 68 65 20 64 62 22 29 29 0a 09 28 28 4e 4f 54  the db"))..((NOT
4930: 5f 53 54 41 52 54 45 44 20 43 4f 4d 50 4c 45 54  _STARTED COMPLET
4940: 45 44 29 0a 09 20 28 64 65 62 75 67 3a 70 72 69  ED).. (debug:pri
4950: 6e 74 20 36 20 22 47 6f 74 20 68 65 72 65 2c 20  nt 6 "Got here, 
4960: 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74  " (test:get-stat
4970: 65 20 74 65 73 74 64 61 74 29 29 0a 09 20 28 6c  e testdat)).. (l
4980: 65 74 20 28 28 72 75 6e 66 6c 61 67 20 23 66 29  et ((runflag #f)
4990: 29 0a 09 20 20 20 28 63 6f 6e 64 0a 09 20 20 20  )..   (cond..   
49a0: 20 3b 3b 20 2d 66 6f 72 63 65 2c 20 72 75 6e 20   ;; -force, run 
49b0: 6e 6f 20 6d 61 74 74 65 72 20 77 68 61 74 0a 09  no matter what..
49c0: 20 20 20 20 28 66 6f 72 63 65 20 28 73 65 74 21      (force (set!
49d0: 20 72 75 6e 66 6c 61 67 20 23 74 29 29 0a 09 20   runflag #t)).. 
49e0: 20 20 20 3b 3b 20 4e 4f 54 5f 53 54 41 52 54 45     ;; NOT_STARTE
49f0: 44 2c 20 72 75 6e 20 6e 6f 20 6d 61 74 74 65 72  D, run no matter
4a00: 20 77 68 61 74 0a 09 20 20 20 20 28 28 65 71 75   what..    ((equ
4a10: 61 6c 3f 20 28 74 65 73 74 3a 67 65 74 2d 73 74  al? (test:get-st
4a20: 61 74 65 20 74 65 73 74 64 61 74 29 20 22 4e 4f  ate testdat) "NO
4a30: 54 5f 53 54 41 52 54 45 44 22 29 28 73 65 74 21  T_STARTED")(set!
4a40: 20 72 75 6e 66 6c 61 67 20 23 74 29 29 0a 09 20   runflag #t)).. 
4a50: 20 20 20 3b 3b 20 6e 6f 74 20 2d 72 65 72 75 6e     ;; not -rerun
4a60: 20 61 6e 64 20 50 41 53 53 2c 20 57 41 52 4e 20   and PASS, WARN 
4a70: 6f 72 20 43 48 45 43 4b 2c 20 64 6f 20 6e 6f 20  or CHECK, do no 
4a80: 72 75 6e 0a 09 20 20 20 20 28 28 61 6e 64 20 28  run..    ((and (
4a90: 6f 72 20 28 6e 6f 74 20 72 65 72 75 6e 29 0a 09  or (not rerun)..
4aa0: 09 20 20 20 20 20 20 6b 65 65 70 67 6f 69 6e 67  .      keepgoing
4ab0: 29 0a 09 09 20 20 3b 3b 20 52 65 71 75 69 72 65  )...  ;; Require
4ac0: 20 74 6f 20 66 6f 72 63 65 20 72 65 2d 72 75 6e   to force re-run
4ad0: 20 66 6f 72 20 43 4f 4d 50 4c 45 54 45 44 20 6f   for COMPLETED o
4ae0: 72 20 2a 61 6e 79 74 68 69 6e 67 2a 20 2b 20 50  r *anything* + P
4af0: 41 53 53 2c 57 41 52 4e 20 6f 72 20 43 48 45 43  ASS,WARN or CHEC
4b00: 4b 0a 09 09 20 20 28 6f 72 20 28 6d 65 6d 62 65  K...  (or (membe
4b10: 72 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74  r (test:get-stat
4b20: 75 73 20 74 65 73 74 64 61 74 29 20 27 28 22 50  us testdat) '("P
4b30: 41 53 53 22 20 22 57 41 52 4e 22 20 22 43 48 45  ASS" "WARN" "CHE
4b40: 43 4b 22 29 29 0a 09 09 20 20 20 20 20 20 28 6d  CK"))...      (m
4b50: 65 6d 62 65 72 20 28 74 65 73 74 3a 67 65 74 2d  ember (test:get-
4b60: 73 74 61 74 65 20 20 74 65 73 74 64 61 74 29 20  state  testdat) 
4b70: 27 28 22 43 4f 4d 50 4c 45 54 45 44 22 29 29 29  '("COMPLETED")))
4b80: 29 20 0a 09 20 20 20 20 20 28 73 65 74 21 20 72  ) ..     (set! r
4b90: 75 6e 66 6c 61 67 20 23 66 29 29 0a 09 20 20 20  unflag #f))..   
4ba0: 20 3b 3b 20 2d 72 65 72 75 6e 20 61 6e 64 20 73   ;; -rerun and s
4bb0: 74 61 74 75 73 20 69 73 20 6f 6e 65 20 6f 66 20  tatus is one of 
4bc0: 74 68 65 20 73 70 65 63 69 66 65 64 2c 20 72 75  the specifed, ru
4bd0: 6e 20 69 74 0a 09 20 20 20 20 28 28 61 6e 64 20  n it..    ((and 
4be0: 72 65 72 75 6e 0a 09 09 20 20 28 6c 65 74 20 28  rerun...  (let (
4bf0: 28 72 65 72 75 6e 6c 73 74 20 28 73 74 72 69 6e  (rerunlst (strin
4c00: 67 2d 73 70 6c 69 74 20 72 65 72 75 6e 20 22 2c  g-split rerun ",
4c10: 22 29 29 29 20 3b 3b 20 46 41 49 4c 2c 0a 09 09  "))) ;; FAIL,...
4c20: 20 20 20 20 28 6d 65 6d 62 65 72 20 28 74 65 73      (member (tes
4c30: 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73  t:get-status tes
4c40: 74 64 61 74 29 20 72 65 72 75 6e 6c 73 74 29 29  tdat) rerunlst))
4c50: 29 0a 09 20 20 20 20 20 28 73 65 74 21 20 72 75  )..     (set! ru
4c60: 6e 66 6c 61 67 20 23 74 29 29 0a 09 20 20 20 20  nflag #t))..    
4c70: 3b 3b 20 2d 6b 65 65 70 67 6f 69 6e 67 2c 20 64  ;; -keepgoing, d
4c80: 6f 20 6e 6f 74 20 72 65 72 75 6e 20 46 41 49 4c  o not rerun FAIL
4c90: 0a 09 20 20 20 20 28 28 61 6e 64 20 6b 65 65 70  ..    ((and keep
4ca0: 67 6f 69 6e 67 0a 09 09 20 20 28 6d 65 6d 62 65  going...  (membe
4cb0: 72 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74  r (test:get-stat
4cc0: 75 73 20 74 65 73 74 64 61 74 29 20 27 28 22 46  us testdat) '("F
4cd0: 41 49 4c 22 29 29 29 0a 09 20 20 20 20 20 28 73  AIL")))..     (s
4ce0: 65 74 21 20 72 75 6e 66 6c 61 67 20 23 66 29 29  et! runflag #f))
4cf0: 0a 09 20 20 20 20 28 28 61 6e 64 20 28 6e 6f 74  ..    ((and (not
4d00: 20 72 65 72 75 6e 29 0a 09 09 20 20 28 6d 65 6d   rerun)...  (mem
4d10: 62 65 72 20 28 74 65 73 74 3a 67 65 74 2d 73 74  ber (test:get-st
4d20: 61 74 75 73 20 74 65 73 74 64 61 74 29 20 27 28  atus testdat) '(
4d30: 22 46 41 49 4c 22 20 22 6e 2f 61 22 29 29 29 0a  "FAIL" "n/a"))).
4d40: 09 20 20 20 20 20 28 73 65 74 21 20 72 75 6e 66  .     (set! runf
4d50: 6c 61 67 20 23 74 29 29 0a 09 20 20 20 20 28 65  lag #t))..    (e
4d60: 6c 73 65 20 28 73 65 74 21 20 72 75 6e 66 6c 61  lse (set! runfla
4d70: 67 20 23 66 29 29 29 0a 09 20 20 20 28 64 65 62  g #f)))..   (deb
4d80: 75 67 3a 70 72 69 6e 74 20 36 20 22 52 55 4e 4e  ug:print 6 "RUNN
4d90: 49 4e 47 20 3d 3e 20 72 75 6e 66 6c 61 67 3a 20  ING => runflag: 
4da0: 22 20 72 75 6e 66 6c 61 67 20 22 20 53 54 41 54  " runflag " STAT
4db0: 45 3a 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73  E: " (test:get-s
4dc0: 74 61 74 65 20 74 65 73 74 64 61 74 29 20 22 20  tate testdat) " 
4dd0: 53 54 41 54 55 53 3a 20 22 20 28 74 65 73 74 3a  STATUS: " (test:
4de0: 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64  get-status testd
4df0: 61 74 29 29 0a 09 20 20 20 28 69 66 20 28 6e 6f  at))..   (if (no
4e00: 74 20 72 75 6e 66 6c 61 67 29 0a 09 20 20 20 20  t runflag)..    
4e10: 20 20 20 28 69 66 20 28 6e 6f 74 20 70 61 72 65     (if (not pare
4e20: 6e 74 2d 74 65 73 74 29 0a 09 09 20 20 20 28 64  nt-test)...   (d
4e30: 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 4e 4f  ebug:print 1 "NO
4e40: 54 45 3a 20 4e 6f 74 20 73 74 61 72 74 69 6e 67  TE: Not starting
4e50: 20 74 65 73 74 20 22 20 6e 65 77 2d 74 65 73 74   test " new-test
4e60: 2d 6e 61 6d 65 20 22 20 61 73 20 69 74 20 69 73  -name " as it is
4e70: 20 73 74 61 74 65 20 5c 22 22 20 28 74 65 73 74   state \"" (test
4e80: 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64  :get-state testd
4e90: 61 74 29 20 0a 09 09 09 09 22 5c 22 20 61 6e 64  at) ....."\" and
4ea0: 20 73 74 61 74 75 73 20 5c 22 22 20 28 74 65 73   status \"" (tes
4eb0: 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73  t:get-status tes
4ec0: 74 64 61 74 29 20 22 5c 22 2c 20 75 73 65 20 2d  tdat) "\", use -
4ed0: 72 65 72 75 6e 20 5c 22 22 20 28 74 65 73 74 3a  rerun \"" (test:
4ee0: 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61  get-state testda
4ef0: 74 29 20 22 5c 22 20 6f 72 20 2d 66 6f 72 63 65  t) "\" or -force
4f00: 20 74 6f 20 6f 76 65 72 72 69 64 65 22 29 29 0a   to override")).
4f10: 09 20 20 20 20 20 20 20 3b 3b 20 4e 4f 54 45 3a  .       ;; NOTE:
4f20: 20 4e 6f 20 6c 6f 6e 67 65 72 20 62 65 20 63 68   No longer be ch
4f30: 65 63 6b 69 6e 67 20 70 72 65 72 65 71 75 69 73  ecking prerequis
4f40: 69 74 65 73 20 68 65 72 65 21 20 57 69 6c 6c 20  ites here! Will 
4f50: 6e 65 76 65 72 20 67 65 74 20 68 65 72 65 20 75  never get here u
4f60: 6e 6c 65 73 73 20 70 72 65 72 65 71 73 20 61 72  nless prereqs ar
4f70: 65 0a 09 20 20 20 20 20 20 20 3b 3b 20 20 20 20  e..       ;;    
4f80: 20 20 20 61 6c 72 65 61 64 79 20 6d 65 74 2e 0a     already met..
4f90: 09 20 20 20 20 20 20 20 28 69 66 20 28 6e 6f 74  .       (if (not
4fa0: 20 28 6c 61 75 6e 63 68 2d 74 65 73 74 20 64 62   (launch-test db
4fb0: 20 72 75 6e 2d 69 64 20 72 75 6e 6e 61 6d 65 20   run-id runname 
4fc0: 74 65 73 74 2d 63 6f 6e 66 20 6b 65 79 76 61 6c  test-conf keyval
4fd0: 6c 73 74 20 74 65 73 74 2d 6e 61 6d 65 20 74 65  lst test-name te
4fe0: 73 74 2d 70 61 74 68 20 69 74 65 6d 64 61 74 20  st-path itemdat 
4ff0: 66 6c 61 67 73 29 29 0a 09 09 20 20 20 28 62 65  flags))...   (be
5000: 67 69 6e 0a 09 09 20 20 20 20 20 28 70 72 69 6e  gin...     (prin
5010: 74 20 22 45 52 52 4f 52 3a 20 46 61 69 6c 65 64  t "ERROR: Failed
5020: 20 74 6f 20 6c 61 75 6e 63 68 20 74 68 65 20 74   to launch the t
5030: 65 73 74 2e 20 45 78 69 74 69 6e 67 20 61 73 20  est. Exiting as 
5040: 73 6f 6f 6e 20 61 73 20 70 6f 73 73 69 62 6c 65  soon as possible
5050: 22 29 0a 09 09 20 20 20 20 20 28 73 65 74 21 20  ")...     (set! 
5060: 2a 67 6c 6f 62 61 6c 65 78 69 74 73 74 61 74 75  *globalexitstatu
5070: 73 2a 20 31 29 20 3b 3b 20 0a 09 09 20 20 20 20  s* 1) ;; ...    
5080: 20 28 70 72 6f 63 65 73 73 2d 73 69 67 6e 61 6c   (process-signal
5090: 20 28 63 75 72 72 65 6e 74 2d 70 72 6f 63 65 73   (current-proces
50a0: 73 2d 69 64 29 20 73 69 67 6e 61 6c 2f 6b 69 6c  s-id) signal/kil
50b0: 6c 29 29 29 29 29 29 0a 09 28 28 4b 49 4c 4c 45  l))))))..((KILLE
50c0: 44 29 20 0a 09 20 28 64 65 62 75 67 3a 70 72 69  D) .. (debug:pri
50d0: 6e 74 20 31 20 22 4e 4f 54 45 3a 20 22 20 6e 65  nt 1 "NOTE: " ne
50e0: 77 2d 74 65 73 74 2d 6e 61 6d 65 20 22 20 69 73  w-test-name " is
50f0: 20 61 6c 72 65 61 64 79 20 72 75 6e 6e 69 6e 67   already running
5100: 20 6f 72 20 77 61 73 20 65 78 70 6c 69 63 74 6c   or was explictl
5110: 79 20 6b 69 6c 6c 65 64 2c 20 75 73 65 20 2d 66  y killed, use -f
5120: 6f 72 63 65 20 74 6f 20 6c 61 75 6e 63 68 20 69  orce to launch i
5130: 74 2e 22 29 29 0a 09 28 28 4c 41 55 4e 43 48 45  t."))..((LAUNCHE
5140: 44 20 52 45 4d 4f 54 45 48 4f 53 54 53 54 41 52  D REMOTEHOSTSTAR
5150: 54 20 52 55 4e 4e 49 4e 47 29 20 20 0a 09 20 28  T RUNNING)  .. (
5160: 69 66 20 28 3e 20 28 2d 20 28 63 75 72 72 65 6e  if (> (- (curren
5170: 74 2d 73 65 63 6f 6e 64 73 29 28 2b 20 28 64 62  t-seconds)(+ (db
5180: 3a 74 65 73 74 2d 67 65 74 2d 65 76 65 6e 74 5f  :test-get-event_
5190: 74 69 6d 65 20 74 65 73 74 64 61 74 29 0a 09 09  time testdat)...
51a0: 09 09 20 20 20 20 20 20 20 28 64 62 3a 74 65 73  ..       (db:tes
51b0: 74 2d 67 65 74 2d 72 75 6e 5f 64 75 72 61 74 69  t-get-run_durati
51c0: 6f 6e 20 74 65 73 74 64 61 74 29 29 29 0a 09 09  on testdat)))...
51d0: 36 30 30 29 20 3b 3b 20 69 2e 65 2e 20 6e 6f 20  600) ;; i.e. no 
51e0: 75 70 64 61 74 65 20 66 6f 72 20 6d 6f 72 65 20  update for more 
51f0: 74 68 61 6e 20 36 30 30 20 73 65 63 6f 6e 64 73  than 600 seconds
5200: 0a 09 20 20 20 20 20 28 62 65 67 69 6e 0a 09 20  ..     (begin.. 
5210: 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69        (debug:pri
5220: 6e 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 54  nt 0 "WARNING: T
5230: 65 73 74 20 22 20 74 65 73 74 2d 6e 61 6d 65 20  est " test-name 
5240: 22 20 61 70 70 65 61 72 73 20 74 6f 20 62 65 20  " appears to be 
5250: 64 65 61 64 2e 20 46 6f 72 63 69 6e 67 20 69 74  dead. Forcing it
5260: 20 74 6f 20 73 74 61 74 65 20 49 4e 43 4f 4d 50   to state INCOMP
5270: 4c 45 54 45 20 61 6e 64 20 73 74 61 74 75 73 20  LETE and status 
5280: 53 54 55 43 4b 2f 44 45 41 44 22 29 0a 09 20 20  STUCK/DEAD")..  
5290: 20 20 20 20 20 28 74 65 73 74 2d 73 65 74 2d 73       (test-set-s
52a0: 74 61 74 75 73 21 20 64 62 20 72 75 6e 2d 69 64  tatus! db run-id
52b0: 20 74 65 73 74 2d 6e 61 6d 65 20 22 49 4e 43 4f   test-name "INCO
52c0: 4d 50 4c 45 54 45 22 20 22 53 54 55 43 4b 2f 44  MPLETE" "STUCK/D
52d0: 45 41 44 22 20 69 74 65 6d 64 61 74 20 22 54 65  EAD" itemdat "Te
52e0: 73 74 20 69 73 20 73 74 75 63 6b 20 6f 72 20 64  st is stuck or d
52f0: 65 61 64 22 20 23 66 29 29 0a 09 20 20 20 20 20  ead" #f))..     
5300: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22  (debug:print 2 "
5310: 4e 4f 54 45 3a 20 22 20 74 65 73 74 2d 6e 61 6d  NOTE: " test-nam
5320: 65 20 22 20 69 73 20 61 6c 72 65 61 64 79 20 72  e " is already r
5330: 75 6e 6e 69 6e 67 22 29 29 29 0a 09 28 65 6c 73  unning")))..(els
5340: 65 20 20 20 20 20 20 20 28 64 65 62 75 67 3a 70  e       (debug:p
5350: 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 46  rint 0 "ERROR: F
5360: 61 69 6c 65 64 20 74 6f 20 6c 61 75 6e 63 68 20  ailed to launch 
5370: 74 65 73 74 20 22 20 6e 65 77 2d 74 65 73 74 2d  test " new-test-
5380: 6e 61 6d 65 20 22 2e 20 55 6e 72 65 63 6f 67 6e  name ". Unrecogn
5390: 69 73 65 64 20 73 74 61 74 65 20 22 20 28 74 65  ised state " (te
53a0: 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73  st:get-state tes
53b0: 74 64 61 74 29 29 29 29 29 29 29 0a 0a 3b 3b 3d  tdat)))))))..;;=
53c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
53d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
53e0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
53f0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5400: 3d 3d 3d 3d 3d 0a 3b 3b 20 45 4e 44 20 4f 46 20  =====.;; END OF 
5410: 4e 45 57 20 53 54 55 46 46 0a 3b 3b 3d 3d 3d 3d  NEW STUFF.;;====
5420: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5430: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5440: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5450: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5460: 3d 3d 0a 0a 28 64 65 66 69 6e 65 20 28 67 65 74  ==..(define (get
5470: 2d 64 69 72 2d 75 70 2d 6e 20 64 69 72 20 2e 20  -dir-up-n dir . 
5480: 70 61 72 61 6d 73 29 20 0a 20 20 28 6c 65 74 20  params) .  (let 
5490: 28 28 64 70 61 72 74 73 20 20 28 73 74 72 69 6e  ((dparts  (strin
54a0: 67 2d 73 70 6c 69 74 20 64 69 72 20 22 2f 22 29  g-split dir "/")
54b0: 29 0a 09 28 63 6f 75 6e 74 20 20 20 28 69 66 20  )..(count   (if 
54c0: 28 6e 75 6c 6c 3f 20 70 61 72 61 6d 73 29 20 31  (null? params) 1
54d0: 20 28 63 61 72 20 70 61 72 61 6d 73 29 29 29 29   (car params))))
54e0: 0a 20 20 20 20 28 63 6f 6e 63 20 22 2f 22 20 28  .    (conc "/" (
54f0: 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72  string-intersper
5500: 73 65 20 0a 09 20 20 20 20 20 20 20 28 74 61 6b  se ..       (tak
5510: 65 20 64 70 61 72 74 73 20 28 2d 20 28 6c 65 6e  e dparts (- (len
5520: 67 74 68 20 64 70 61 72 74 73 29 20 63 6f 75 6e  gth dparts) coun
5530: 74 29 29 0a 09 20 20 20 20 20 20 20 22 2f 22 29  t))..       "/")
5540: 29 29 29 0a 3b 3b 20 52 65 6d 6f 76 65 20 72 75  ))).;; Remove ru
5550: 6e 73 0a 3b 3b 20 66 69 65 6c 64 73 20 61 72 65  ns.;; fields are
5560: 20 70 61 73 73 69 6e 67 20 69 6e 20 74 68 72 6f   passing in thro
5570: 75 67 68 20 0a 28 64 65 66 69 6e 65 20 28 72 75  ugh .(define (ru
5580: 6e 73 3a 72 65 6d 6f 76 65 2d 72 75 6e 73 20 64  ns:remove-runs d
5590: 62 20 72 75 6e 6e 61 6d 65 70 61 74 74 20 74 65  b runnamepatt te
55a0: 73 74 70 61 74 74 20 69 74 65 6d 70 61 74 74 29  stpatt itempatt)
55b0: 0a 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 73 20  .  (let* ((keys 
55c0: 20 20 20 20 20 20 20 28 72 64 62 3a 67 65 74 2d         (rdb:get-
55d0: 6b 65 79 73 20 64 62 29 29 0a 09 20 28 72 75 6e  keys db)).. (run
55e0: 64 61 74 20 20 20 20 20 20 28 72 75 6e 73 3a 67  dat      (runs:g
55f0: 65 74 2d 72 75 6e 73 2d 62 79 2d 70 61 74 74 20  et-runs-by-patt 
5600: 64 62 20 6b 65 79 73 20 72 75 6e 6e 61 6d 65 70  db keys runnamep
5610: 61 74 74 29 29 0a 09 20 28 68 65 61 64 65 72 20  att)).. (header 
5620: 20 20 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66       (vector-ref
5630: 20 72 75 6e 64 61 74 20 30 29 29 0a 09 20 28 72   rundat 0)).. (r
5640: 75 6e 73 20 20 20 20 20 20 20 20 28 76 65 63 74  uns        (vect
5650: 6f 72 2d 72 65 66 20 72 75 6e 64 61 74 20 31 29  or-ref rundat 1)
5660: 29 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72  )).    (debug:pr
5670: 69 6e 74 20 31 20 22 48 65 61 64 65 72 3a 20 22  int 1 "Header: "
5680: 20 68 65 61 64 65 72 29 0a 20 20 20 20 28 66 6f   header).    (fo
5690: 72 2d 65 61 63 68 0a 20 20 20 20 20 28 6c 61 6d  r-each.     (lam
56a0: 62 64 61 20 28 72 75 6e 29 0a 20 20 20 20 20 20  bda (run).      
56b0: 20 28 6c 65 74 20 28 28 72 75 6e 6b 65 79 20 28   (let ((runkey (
56c0: 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72  string-intersper
56d0: 73 65 20 28 6d 61 70 20 28 6c 61 6d 62 64 61 20  se (map (lambda 
56e0: 28 6b 29 0a 09 09 09 09 09 09 28 64 62 3a 67 65  (k).......(db:ge
56f0: 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65  t-value-by-heade
5700: 72 20 72 75 6e 20 68 65 61 64 65 72 20 28 76 65  r run header (ve
5710: 63 74 6f 72 2d 72 65 66 20 6b 20 30 29 29 29 20  ctor-ref k 0))) 
5720: 6b 65 79 73 29 20 22 2f 22 29 29 0a 09 20 20 20  keys) "/"))..   
5730: 20 20 28 64 69 72 73 2d 74 6f 2d 72 65 6d 6f 76    (dirs-to-remov
5740: 65 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62  e (make-hash-tab
5750: 6c 65 29 29 29 0a 09 20 28 6c 65 74 2a 20 28 28  le))).. (let* ((
5760: 72 75 6e 2d 69 64 20 28 64 62 3a 67 65 74 2d 76  run-id (db:get-v
5770: 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72  alue-by-header r
5780: 75 6e 20 68 65 61 64 65 72 20 22 69 64 22 29 20  un header "id") 
5790: 29 0a 09 09 28 74 65 73 74 73 20 20 28 64 62 2d  )...(tests  (db-
57a0: 67 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d 72 75  get-tests-for-ru
57b0: 6e 20 64 62 20 28 64 62 3a 67 65 74 2d 76 61 6c  n db (db:get-val
57c0: 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e  ue-by-header run
57d0: 20 68 65 61 64 65 72 20 22 69 64 22 29 20 74 65   header "id") te
57e0: 73 74 70 61 74 74 20 69 74 65 6d 70 61 74 74 20  stpatt itempatt 
57f0: 27 28 29 20 27 28 29 29 29 0a 09 09 28 6c 61 73  '() '()))...(las
5800: 74 74 70 61 74 68 20 22 2f 64 6f 65 73 2f 6e 6f  ttpath "/does/no
5810: 74 2f 65 78 69 73 74 2f 49 2f 68 6f 70 65 22 29  t/exist/I/hope")
5820: 29 0a 0a 09 20 20 20 28 69 66 20 28 6e 6f 74 20  )...   (if (not 
5830: 28 6e 75 6c 6c 3f 20 74 65 73 74 73 29 29 0a 09  (null? tests))..
5840: 20 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09         (begin...
5850: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20   (debug:print 1 
5860: 22 52 65 6d 6f 76 69 6e 67 20 74 65 73 74 73 20  "Removing tests 
5870: 66 6f 72 20 72 75 6e 3a 20 22 20 72 75 6e 6b 65  for run: " runke
5880: 79 20 22 20 22 20 28 64 62 3a 67 65 74 2d 76 61  y " " (db:get-va
5890: 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75  lue-by-header ru
58a0: 6e 20 68 65 61 64 65 72 20 22 72 75 6e 6e 61 6d  n header "runnam
58b0: 65 22 29 29 0a 09 09 20 28 66 6f 72 2d 65 61 63  e"))... (for-eac
58c0: 68 0a 09 09 20 20 28 6c 61 6d 62 64 61 20 28 74  h...  (lambda (t
58d0: 65 73 74 29 0a 09 09 20 20 20 20 28 6c 65 74 2a  est)...    (let*
58e0: 20 28 28 69 74 65 6d 2d 70 61 74 68 20 28 64 62   ((item-path (db
58f0: 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70  :test-get-item-p
5900: 61 74 68 20 74 65 73 74 29 29 0a 09 09 09 20 20  ath test))....  
5910: 20 28 74 65 73 74 2d 6e 61 6d 65 20 28 64 62 3a   (test-name (db:
5920: 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d  test-get-testnam
5930: 65 20 74 65 73 74 29 29 0a 09 09 09 20 20 20 28  e test))....   (
5940: 72 75 6e 2d 64 69 72 20 20 20 28 64 62 3a 74 65  run-dir   (db:te
5950: 73 74 2d 67 65 74 2d 72 75 6e 64 69 72 20 74 65  st-get-rundir te
5960: 73 74 29 29 29 0a 09 09 20 20 20 20 20 20 28 64  st)))...      (d
5970: 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 20 20  ebug:print 1 "  
5980: 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 74  " (db:test-get-t
5990: 65 73 74 6e 61 6d 65 20 74 65 73 74 29 20 22 20  estname test) " 
59a0: 69 64 3a 20 22 20 28 64 62 3a 74 65 73 74 2d 67  id: " (db:test-g
59b0: 65 74 2d 69 64 20 74 65 73 74 29 20 22 20 22 20  et-id test) " " 
59c0: 69 74 65 6d 2d 70 61 74 68 29 0a 09 09 20 20 20  item-path)...   
59d0: 20 20 20 28 72 64 62 3a 64 65 6c 65 74 65 2d 74     (rdb:delete-t
59e0: 65 73 74 2d 72 65 63 6f 72 64 73 20 64 62 20 28  est-records db (
59f0: 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74  db:test-get-id t
5a00: 65 73 74 29 29 0a 09 09 20 20 20 20 20 20 28 69  est))...      (i
5a10: 66 20 28 3e 20 28 73 74 72 69 6e 67 2d 6c 65 6e  f (> (string-len
5a20: 67 74 68 20 72 75 6e 2d 64 69 72 29 20 35 29 20  gth run-dir) 5) 
5a30: 3b 3b 20 62 61 64 20 68 65 75 72 69 73 74 69 63  ;; bad heuristic
5a40: 20 62 75 74 20 73 68 6f 75 6c 64 20 70 72 65 76   but should prev
5a50: 65 6e 74 20 2f 74 6d 70 20 2f 68 6f 6d 65 20 65  ent /tmp /home e
5a60: 74 63 2e 0a 09 09 09 20 20 28 6c 65 74 20 28 28  tc.....  (let ((
5a70: 66 75 6c 6c 70 61 74 68 20 72 75 6e 2d 64 69 72  fullpath run-dir
5a80: 29 29 20 3b 3b 20 22 2f 22 20 28 64 62 3a 74 65  )) ;; "/" (db:te
5a90: 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68  st-get-item-path
5aa0: 20 74 65 73 74 29 29 29 29 0a 09 09 09 20 20 20   test))))....   
5ab0: 20 28 73 65 74 21 20 6c 61 73 74 74 70 61 74 68   (set! lasttpath
5ac0: 20 66 75 6c 6c 70 61 74 68 29 0a 09 09 09 20 20   fullpath)....  
5ad0: 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65    (hash-table-se
5ae0: 74 21 20 64 69 72 73 2d 74 6f 2d 72 65 6d 6f 76  t! dirs-to-remov
5af0: 65 20 66 75 6c 6c 70 61 74 68 20 23 74 29 0a 09  e fullpath #t)..
5b00: 09 09 20 20 20 20 3b 3b 20 54 68 65 20 66 6f 6c  ..    ;; The fol
5b10: 6c 6f 77 69 6e 67 20 77 61 73 20 74 68 65 20 73  lowing was the s
5b20: 61 66 65 20 64 65 6c 65 74 65 20 63 6f 64 65 20  afe delete code 
5b30: 62 75 74 20 69 74 20 77 61 73 20 6e 6f 74 20 62  but it was not b
5b40: 65 69 6e 67 20 65 78 65 63 74 75 74 65 64 2e 0a  eing exectuted..
5b50: 09 09 09 20 20 20 20 3b 3b 20 28 6c 65 74 2a 20  ...    ;; (let* 
5b60: 28 28 64 69 72 73 2d 63 6f 75 6e 74 20 28 2b 20  ((dirs-count (+ 
5b70: 31 20 28 6c 65 6e 67 74 68 20 6b 65 79 73 29 28  1 (length keys)(
5b80: 6c 65 6e 67 74 68 20 28 73 74 72 69 6e 67 2d 73  length (string-s
5b90: 70 6c 69 74 20 69 74 65 6d 2d 70 61 74 68 20 22  plit item-path "
5ba0: 2f 22 29 29 29 29 0a 09 09 09 20 20 20 20 3b 3b  /"))))....    ;;
5bb0: 20 20 20 20 20 20 20 20 28 64 69 72 2d 74 6f 2d          (dir-to-
5bc0: 72 65 6d 20 28 67 65 74 2d 64 69 72 2d 75 70 2d  rem (get-dir-up-
5bd0: 6e 20 66 75 6c 6c 70 61 74 68 20 64 69 72 73 2d  n fullpath dirs-
5be0: 63 6f 75 6e 74 29 29 0a 09 09 09 20 20 20 20 3b  count))....    ;
5bf0: 3b 20 20 20 20 20 20 20 20 28 72 65 6d 61 69 6e  ;        (remain
5c00: 69 6e 67 64 20 28 73 74 72 69 6e 67 2d 73 75 62  ingd (string-sub
5c10: 73 74 69 74 75 74 65 20 28 72 65 67 65 78 70 20  stitute (regexp 
5c20: 28 63 6f 6e 63 20 22 5e 22 20 64 69 72 2d 74 6f  (conc "^" dir-to
5c30: 2d 72 65 6d 20 22 2f 22 29 29 20 22 22 20 66 75  -rem "/")) "" fu
5c40: 6c 6c 70 61 74 68 29 29 0a 09 09 09 20 20 20 20  llpath))....    
5c50: 3b 3b 20 20 20 20 20 20 20 20 28 63 6d 64 20 28  ;;        (cmd (
5c60: 63 6f 6e 63 20 22 63 64 20 22 20 64 69 72 2d 74  conc "cd " dir-t
5c70: 6f 2d 72 65 6d 20 22 3b 20 72 6d 64 69 72 20 2d  o-rem "; rmdir -
5c80: 70 20 22 20 72 65 6d 61 69 6e 69 6e 67 64 20 29  p " remainingd )
5c90: 29 29 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 28  ))....    ;;   (
5ca0: 69 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f  if (file-exists?
5cb0: 20 66 75 6c 6c 70 61 74 68 29 0a 09 09 09 20 20   fullpath)....  
5cc0: 20 20 3b 3b 20 20 20 20 20 20 20 28 62 65 67 69    ;;       (begi
5cd0: 6e 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20  n....    ;;     
5ce0: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
5cf0: 20 31 20 63 6d 64 29 0a 09 09 09 20 20 20 20 3b   1 cmd)....    ;
5d00: 3b 20 20 20 20 20 20 20 20 20 28 73 79 73 74 65  ;         (syste
5d10: 6d 20 63 6d 64 29 29 29 0a 09 09 09 20 20 20 20  m cmd)))....    
5d20: 3b 3b 20 20 20 29 29 0a 09 09 09 20 20 20 20 29  ;;   ))....    )
5d30: 29 29 29 0a 09 09 20 20 20 20 74 65 73 74 73 29  )))...    tests)
5d40: 29 29 0a 0a 09 20 20 20 3b 3b 20 6c 6f 6f 6b 20  ))...   ;; look 
5d50: 74 68 6f 75 67 68 20 74 68 65 20 64 69 72 73 2d  though the dirs-
5d60: 74 6f 2d 72 65 6d 6f 76 65 20 66 6f 72 20 63 61  to-remove for ca
5d70: 6e 64 69 64 61 74 65 73 20 66 6f 72 20 72 65 6d  ndidates for rem
5d80: 6f 76 61 6c 2e 20 44 6f 20 74 68 69 73 20 61 66  oval. Do this af
5d90: 74 65 72 20 64 65 6c 65 74 69 6e 67 20 74 68 65  ter deleting the
5da0: 20 72 65 63 6f 72 64 73 0a 09 20 20 20 3b 3b 20   records..   ;; 
5db0: 66 6f 72 20 65 61 63 68 20 74 65 73 74 20 69 6e  for each test in
5dc0: 20 63 61 73 65 20 77 65 20 67 65 74 20 6b 69 6c   case we get kil
5dd0: 6c 65 64 2e 20 54 68 61 74 20 73 68 6f 75 6c 64  led. That should
5de0: 20 6d 69 6e 69 6d 69 7a 65 20 74 68 65 20 64 65   minimize the de
5df0: 74 72 69 74 75 73 20 6c 65 66 74 20 6f 6e 20 64  tritus left on d
5e00: 69 73 6b 0a 09 20 20 20 3b 3b 20 70 72 6f 63 65  isk..   ;; proce
5e10: 73 73 20 74 68 65 20 64 69 72 73 20 66 72 6f 6d  ss the dirs from
5e20: 20 6c 6f 6e 67 65 73 74 20 73 74 72 69 6e 67 20   longest string 
5e30: 6c 65 6e 67 74 68 20 74 6f 20 73 68 6f 72 74 65  length to shorte
5e40: 73 74 0a 09 20 20 20 28 66 6f 72 2d 65 61 63 68  st..   (for-each
5e50: 20 0a 09 20 20 20 20 28 6c 61 6d 62 64 61 20 28   ..    (lambda (
5e60: 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 0a 09  dir-to-remove)..
5e70: 20 20 20 20 20 20 28 69 66 20 28 66 69 6c 65 2d        (if (file-
5e80: 65 78 69 73 74 73 3f 20 64 69 72 2d 74 6f 2d 72  exists? dir-to-r
5e90: 65 6d 6f 76 65 29 0a 09 09 20 20 28 6c 65 74 20  emove)...  (let 
5ea0: 28 28 64 69 72 2d 69 6e 2d 64 62 20 27 28 29 29  ((dir-in-db '())
5eb0: 29 0a 09 09 20 20 20 20 28 73 71 6c 69 74 65 33  )...    (sqlite3
5ec0: 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77 0a 09 09  :for-each-row...
5ed0: 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 64 69       (lambda (di
5ee0: 72 29 0a 09 09 20 20 20 20 20 20 20 28 73 65 74  r)...       (set
5ef0: 21 20 64 69 72 2d 69 6e 2d 64 62 20 28 63 6f 6e  ! dir-in-db (con
5f00: 73 20 64 69 72 20 64 69 72 2d 69 6e 2d 64 62 29  s dir dir-in-db)
5f10: 29 29 0a 09 09 20 20 20 20 20 64 62 20 22 53 45  ))...     db "SE
5f20: 4c 45 43 54 20 72 75 6e 64 69 72 20 46 52 4f 4d  LECT rundir FROM
5f30: 20 74 65 73 74 73 20 57 48 45 52 45 20 72 75 6e   tests WHERE run
5f40: 64 69 72 20 4c 49 4b 45 20 3f 3b 22 20 0a 09 09  dir LIKE ?;" ...
5f50: 20 20 20 20 20 28 63 6f 6e 63 20 22 25 22 20 64       (conc "%" d
5f60: 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 20 22 25 22  ir-to-remove "%"
5f70: 29 29 20 3b 3b 20 79 65 73 2c 20 49 27 6d 20 67  )) ;; yes, I'm g
5f80: 6f 69 6e 67 20 74 6f 20 62 61 69 6c 20 69 66 20  oing to bail if 
5f90: 74 68 65 72 65 20 69 73 20 61 6e 79 74 68 69 6e  there is anythin
5fa0: 67 20 6c 69 6b 65 20 74 68 69 73 20 64 69 72 20  g like this dir 
5fb0: 69 6e 20 74 68 65 20 64 62 0a 09 09 20 20 20 20  in the db...    
5fc0: 28 69 66 20 28 6e 75 6c 6c 3f 20 64 69 72 2d 69  (if (null? dir-i
5fd0: 6e 2d 64 62 29 0a 09 09 09 28 62 65 67 69 6e 0a  n-db)....(begin.
5fe0: 09 09 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e  ...  (debug:prin
5ff0: 74 20 32 20 22 52 65 6d 6f 76 69 6e 67 20 64 69  t 2 "Removing di
6000: 72 65 63 74 6f 72 79 20 77 69 74 68 20 7a 65 72  rectory with zer
6010: 6f 20 64 62 20 72 65 66 65 72 65 6e 63 65 73 3a  o db references:
6020: 20 22 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65   " dir-to-remove
6030: 29 0a 09 09 09 20 20 28 73 79 73 74 65 6d 20 28  )....  (system (
6040: 63 6f 6e 63 20 22 72 6d 20 2d 72 66 20 22 20 64  conc "rm -rf " d
6050: 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 29 0a 09  ir-to-remove))..
6060: 09 09 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d  ..  (hash-table-
6070: 64 65 6c 65 74 65 21 20 64 69 72 73 2d 74 6f 2d  delete! dirs-to-
6080: 72 65 6d 6f 76 65 20 64 69 72 2d 74 6f 2d 72 65  remove dir-to-re
6090: 6d 6f 76 65 29 29 0a 09 09 09 28 64 65 62 75 67  move))....(debug
60a0: 3a 70 72 69 6e 74 20 32 20 22 53 6b 69 70 70 69  :print 2 "Skippi
60b0: 6e 67 20 72 65 6d 6f 76 61 6c 20 6f 66 20 22 20  ng removal of " 
60c0: 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 20 22 20  dir-to-remove " 
60d0: 66 6f 72 20 6e 6f 77 20 61 73 20 69 74 20 73 74  for now as it st
60e0: 69 6c 6c 20 68 61 73 20 72 65 66 65 72 65 6e 63  ill has referenc
60f0: 65 73 20 69 6e 20 74 68 65 20 64 61 74 61 62 61  es in the databa
6100: 73 65 22 29 29 29 29 29 0a 09 20 20 20 20 28 73  se")))))..    (s
6110: 6f 72 74 20 28 68 61 73 68 2d 74 61 62 6c 65 2d  ort (hash-table-
6120: 6b 65 79 73 20 64 69 72 73 2d 74 6f 2d 72 65 6d  keys dirs-to-rem
6130: 6f 76 65 29 20 28 6c 61 6d 62 64 61 20 28 61 20  ove) (lambda (a 
6140: 62 29 28 3e 20 28 73 74 72 69 6e 67 2d 6c 65 6e  b)(> (string-len
6150: 67 74 68 20 61 29 28 73 74 72 69 6e 67 2d 6c 65  gth a)(string-le
6160: 6e 67 74 68 20 62 29 29 29 29 29 0a 0a 09 20 20  ngth b)))))...  
6170: 20 3b 3b 20 72 65 6d 6f 76 65 20 74 68 65 20 72   ;; remove the r
6180: 75 6e 20 69 66 20 7a 65 72 6f 20 74 65 73 74 73  un if zero tests
6190: 20 72 65 6d 61 69 6e 0a 09 20 20 20 28 6c 65 74   remain..   (let
61a0: 20 28 28 72 65 6d 74 65 73 74 73 20 28 64 62 2d   ((remtests (db-
61b0: 67 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d 72 75  get-tests-for-ru
61c0: 6e 20 64 62 20 28 64 62 3a 67 65 74 2d 76 61 6c  n db (db:get-val
61d0: 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e  ue-by-header run
61e0: 20 68 65 61 64 65 72 20 22 69 64 22 29 20 23 66   header "id") #f
61f0: 20 23 66 20 27 28 29 20 27 28 29 29 29 29 0a 09   #f '() '())))..
6200: 20 20 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20       (if (null? 
6210: 72 65 6d 74 65 73 74 73 29 20 3b 3b 20 6e 6f 20  remtests) ;; no 
6220: 6d 6f 72 65 20 74 65 73 74 73 20 72 65 6d 61 69  more tests remai
6230: 6e 69 6e 67 0a 09 09 20 28 6c 65 74 2a 20 28 28  ning... (let* ((
6240: 64 70 61 72 74 73 20 20 28 73 74 72 69 6e 67 2d  dparts  (string-
6250: 73 70 6c 69 74 20 6c 61 73 74 74 70 61 74 68 20  split lasttpath 
6260: 22 2f 22 29 29 0a 09 09 09 28 72 75 6e 70 61 74  "/"))....(runpat
6270: 68 20 28 63 6f 6e 63 20 22 2f 22 20 28 73 74 72  h (conc "/" (str
6280: 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20  ing-intersperse 
6290: 0a 09 09 09 09 09 20 20 20 20 28 74 61 6b 65 20  ......    (take 
62a0: 64 70 61 72 74 73 20 28 2d 20 28 6c 65 6e 67 74  dparts (- (lengt
62b0: 68 20 64 70 61 72 74 73 29 20 31 29 29 0a 09 09  h dparts) 1))...
62c0: 09 09 09 20 20 20 20 22 2f 22 29 29 29 29 0a 09  ...    "/"))))..
62d0: 09 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74  .   (debug:print
62e0: 20 31 20 22 52 65 6d 6f 76 69 6e 67 20 72 75 6e   1 "Removing run
62f0: 3a 20 22 20 72 75 6e 6b 65 79 20 22 20 22 20 28  : " runkey " " (
6300: 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d  db:get-value-by-
6310: 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65  header run heade
6320: 72 20 22 72 75 6e 6e 61 6d 65 22 29 29 0a 09 09  r "runname"))...
6330: 20 20 20 28 64 62 3a 64 65 6c 65 74 65 2d 72 75     (db:delete-ru
6340: 6e 20 64 62 20 72 75 6e 2d 69 64 29 0a 09 09 20  n db run-id)... 
6350: 20 20 3b 3b 20 6e 65 65 64 20 74 6f 20 66 69 67    ;; need to fig
6360: 75 72 65 20 6f 75 74 20 74 68 65 20 70 61 74 68  ure out the path
6370: 20 74 6f 20 74 68 65 20 72 75 6e 20 64 69 72 20   to the run dir 
6380: 61 6e 64 20 72 65 6d 6f 76 65 20 69 74 20 69 66  and remove it if
6390: 20 65 6d 70 74 79 0a 09 09 20 20 20 3b 3b 20 20   empty...   ;;  
63a0: 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 28 67 6c    (if (null? (gl
63b0: 6f 62 20 28 63 6f 6e 63 20 72 75 6e 70 61 74 68  ob (conc runpath
63c0: 20 22 2f 2a 22 29 29 29 0a 09 09 20 20 20 3b 3b   "/*")))...   ;;
63d0: 20 20 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09          (begin..
63e0: 09 20 20 20 3b 3b 20 09 20 28 64 65 62 75 67 3a  .   ;; . (debug:
63f0: 70 72 69 6e 74 20 31 20 22 52 65 6d 6f 76 69 6e  print 1 "Removin
6400: 67 20 72 75 6e 20 64 69 72 20 22 20 72 75 6e 70  g run dir " runp
6410: 61 74 68 29 0a 09 09 20 20 20 3b 3b 20 09 20 28  ath)...   ;; . (
6420: 73 79 73 74 65 6d 20 28 63 6f 6e 63 20 22 72 6d  system (conc "rm
6430: 64 69 72 20 2d 70 20 22 20 72 75 6e 70 61 74 68  dir -p " runpath
6440: 29 29 29 29 0a 09 09 20 20 20 29 29 29 29 0a 09  ))))...   ))))..
6450: 20 29 29 0a 20 20 20 20 20 72 75 6e 73 29 29 29   )).     runs)))
6460: 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ..;;============
6470: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6480: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6490: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
64a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 52 6f  ==========.;; Ro
64b0: 75 74 69 6e 65 73 20 66 6f 72 20 6d 61 6e 69 70  utines for manip
64c0: 75 6c 61 74 69 6e 67 20 72 75 6e 73 0a 3b 3b 3d  ulating runs.;;=
64d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
64e0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
64f0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6500: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6510: 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 53 69 6e 63 65 20  =====..;; Since 
6520: 6d 61 6e 79 20 63 61 6c 6c 73 20 74 6f 20 61 20  many calls to a 
6530: 72 75 6e 20 72 65 71 75 69 72 65 20 70 72 65 74  run require pret
6540: 74 79 20 6d 75 63 68 20 74 68 65 20 73 61 6d 65  ty much the same
6550: 20 73 65 74 75 70 20 0a 3b 3b 20 74 68 69 73 20   setup .;; this 
6560: 77 72 61 70 70 65 72 20 69 73 20 75 73 65 64 20  wrapper is used 
6570: 74 6f 20 72 65 64 75 63 65 20 74 68 65 20 72 65  to reduce the re
6580: 70 6c 69 63 61 74 69 6f 6e 20 6f 66 20 63 6f 64  plication of cod
6590: 65 0a 28 64 65 66 69 6e 65 20 28 67 65 6e 65 72  e.(define (gener
65a0: 61 6c 2d 72 75 6e 2d 63 61 6c 6c 20 73 77 69 74  al-run-call swit
65b0: 63 68 6e 61 6d 65 20 61 63 74 69 6f 6e 2d 64 65  chname action-de
65c0: 73 63 20 70 72 6f 63 29 0a 20 20 28 6c 65 74 20  sc proc).  (let 
65d0: 28 28 72 75 6e 6e 61 6d 65 20 28 61 72 67 73 3a  ((runname (args:
65e0: 67 65 74 2d 61 72 67 20 22 3a 72 75 6e 6e 61 6d  get-arg ":runnam
65f0: 65 22 29 29 0a 09 28 74 61 72 67 65 74 20 20 28  e"))..(target  (
6600: 69 66 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67  if (args:get-arg
6610: 20 22 2d 74 61 72 67 65 74 22 29 0a 09 09 20 20   "-target")...  
6620: 20 20 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67     (args:get-arg
6630: 20 22 2d 74 61 72 67 65 74 22 29 0a 09 09 20 20   "-target")...  
6640: 20 20 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67     (args:get-arg
6650: 20 22 2d 72 65 71 74 61 72 67 22 29 29 29 29 0a   "-reqtarg")))).
6660: 20 20 20 20 28 63 6f 6e 64 0a 20 20 20 20 20 28      (cond.     (
6670: 28 6e 6f 74 20 74 61 72 67 65 74 29 0a 20 20 20  (not target).   
6680: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
6690: 30 20 22 45 52 52 4f 52 3a 20 4d 69 73 73 69 6e  0 "ERROR: Missin
66a0: 67 20 72 65 71 75 69 72 65 64 20 70 61 72 61 6d  g required param
66b0: 65 74 65 72 20 66 6f 72 20 22 20 73 77 69 74 63  eter for " switc
66c0: 68 6e 61 6d 65 20 22 2c 20 79 6f 75 20 6d 75 73  hname ", you mus
66d0: 74 20 73 70 65 63 69 66 79 20 74 68 65 20 74 61  t specify the ta
66e0: 72 67 65 74 20 77 69 74 68 20 2d 74 61 72 67 65  rget with -targe
66f0: 74 22 29 0a 20 20 20 20 20 20 28 65 78 69 74 20  t").      (exit 
6700: 33 29 29 0a 20 20 20 20 20 28 28 6e 6f 74 20 72  3)).     ((not r
6710: 75 6e 6e 61 6d 65 29 0a 20 20 20 20 20 20 28 64  unname).      (d
6720: 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52  ebug:print 0 "ER
6730: 52 4f 52 3a 20 4d 69 73 73 69 6e 67 20 72 65 71  ROR: Missing req
6740: 75 69 72 65 64 20 70 61 72 61 6d 65 74 65 72 20  uired parameter 
6750: 66 6f 72 20 22 20 73 77 69 74 63 68 6e 61 6d 65  for " switchname
6760: 20 22 2c 20 79 6f 75 20 6d 75 73 74 20 73 70 65   ", you must spe
6770: 63 69 66 79 20 74 68 65 20 72 75 6e 20 6e 61 6d  cify the run nam
6780: 65 20 77 69 74 68 20 3a 72 75 6e 6e 61 6d 65 20  e with :runname 
6790: 72 75 6e 6e 61 6d 65 22 29 0a 20 20 20 20 20 20  runname").      
67a0: 28 65 78 69 74 20 33 29 29 0a 20 20 20 20 20 28  (exit 3)).     (
67b0: 65 6c 73 65 0a 20 20 20 20 20 20 28 6c 65 74 20  else.      (let 
67c0: 28 28 64 62 20 20 20 23 66 29 0a 09 20 20 20 20  ((db   #f)..    
67d0: 28 6b 65 79 73 20 23 66 29 29 0a 09 28 69 66 20  (keys #f))..(if 
67e0: 28 6e 6f 74 20 28 73 65 74 75 70 2d 66 6f 72 2d  (not (setup-for-
67f0: 72 75 6e 29 29 0a 09 20 20 20 20 28 62 65 67 69  run))..    (begi
6800: 6e 20 0a 09 20 20 20 20 20 20 28 64 65 62 75 67  n ..      (debug
6810: 3a 70 72 69 6e 74 20 30 20 22 46 61 69 6c 65 64  :print 0 "Failed
6820: 20 74 6f 20 73 65 74 75 70 2c 20 65 78 69 74 69   to setup, exiti
6830: 6e 67 22 29 0a 09 20 20 20 20 20 20 28 65 78 69  ng")..      (exi
6840: 74 20 31 29 29 29 0a 09 28 73 65 74 21 20 64 62  t 1)))..(set! db
6850: 20 20 20 28 6f 70 65 6e 2d 64 62 29 29 0a 09 28     (open-db))..(
6860: 73 65 74 21 20 6b 65 79 73 20 28 64 62 3a 67 65  set! keys (db:ge
6870: 74 2d 6b 65 79 73 20 64 62 29 29 0a 09 3b 3b 20  t-keys db))..;; 
6880: 68 61 76 65 20 65 6e 6f 75 67 68 20 74 6f 20 70  have enough to p
6890: 72 6f 63 65 73 73 20 2d 74 61 72 67 65 74 20 6f  rocess -target o
68a0: 72 20 2d 72 65 71 74 61 72 67 20 68 65 72 65 0a  r -reqtarg here.
68b0: 09 28 69 66 20 28 61 72 67 73 3a 67 65 74 2d 61  .(if (args:get-a
68c0: 72 67 20 22 2d 72 65 71 74 61 72 67 22 29 0a 09  rg "-reqtarg")..
68d0: 20 20 20 20 28 6c 65 74 2a 20 28 28 72 75 6e 63      (let* ((runc
68e0: 6f 6e 66 69 67 66 20 28 63 6f 6e 63 20 20 2a 74  onfigf (conc  *t
68f0: 6f 70 70 61 74 68 2a 20 22 2f 72 75 6e 63 6f 6e  oppath* "/runcon
6900: 66 69 67 73 2e 63 6f 6e 66 69 67 22 29 29 20 3b  figs.config")) ;
6910: 3b 20 44 4f 20 4e 4f 54 20 45 56 41 4c 55 41 54  ; DO NOT EVALUAT
6920: 45 20 41 4c 4c 20 0a 09 09 20 20 20 28 72 75 6e  E ALL ...   (run
6930: 63 6f 6e 66 69 67 20 20 28 72 65 61 64 2d 63 6f  config  (read-co
6940: 6e 66 69 67 20 72 75 6e 63 6f 6e 66 69 67 66 20  nfig runconfigf 
6950: 23 66 20 23 66 20 65 6e 76 69 72 6f 6e 2d 70 61  #f #f environ-pa
6960: 74 74 3a 20 23 66 29 29 29 20 0a 09 20 20 20 20  tt: #f))) ..    
6970: 20 20 28 69 66 20 28 68 61 73 68 2d 74 61 62 6c    (if (hash-tabl
6980: 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 72 75  e-ref/default ru
6990: 6e 63 6f 6e 66 69 67 20 28 61 72 67 73 3a 67 65  nconfig (args:ge
69a0: 74 2d 61 72 67 20 22 2d 72 65 71 74 61 72 67 22  t-arg "-reqtarg"
69b0: 29 20 23 66 29 0a 09 09 20 20 28 6b 65 79 73 3a  ) #f)...  (keys:
69c0: 74 61 72 67 65 74 2d 73 65 74 2d 61 72 67 73 20  target-set-args 
69d0: 6b 65 79 73 20 28 61 72 67 73 3a 67 65 74 2d 61  keys (args:get-a
69e0: 72 67 20 22 2d 72 65 71 74 61 72 67 22 29 20 61  rg "-reqtarg") a
69f0: 72 67 73 3a 61 72 67 2d 68 61 73 68 29 0a 09 09  rgs:arg-hash)...
6a00: 20 20 28 62 65 67 69 6e 0a 09 09 20 20 20 20 28    (begin...    (
6a10: 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45  debug:print 0 "E
6a20: 52 52 4f 52 3a 20 5b 22 20 28 61 72 67 73 3a 67  RROR: [" (args:g
6a30: 65 74 2d 61 72 67 20 22 2d 72 65 71 74 61 72 67  et-arg "-reqtarg
6a40: 22 29 20 22 5d 20 6e 6f 74 20 66 6f 75 6e 64 20  ") "] not found 
6a50: 69 6e 20 22 20 72 75 6e 63 6f 6e 66 69 67 66 29  in " runconfigf)
6a60: 0a 09 09 20 20 20 20 28 73 71 6c 69 74 65 33 3a  ...    (sqlite3:
6a70: 66 69 6e 61 6c 69 7a 65 21 20 64 62 29 0a 09 09  finalize! db)...
6a80: 20 20 20 20 28 65 78 69 74 20 31 29 29 29 29 0a      (exit 1)))).
6a90: 09 20 20 20 20 28 69 66 20 28 61 72 67 73 3a 67  .    (if (args:g
6aa0: 65 74 2d 61 72 67 20 22 2d 74 61 72 67 65 74 22  et-arg "-target"
6ab0: 29 0a 09 09 28 6b 65 79 73 3a 74 61 72 67 65 74  )...(keys:target
6ac0: 2d 73 65 74 2d 61 72 67 73 20 6b 65 79 73 20 28  -set-args keys (
6ad0: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 74  args:get-arg "-t
6ae0: 61 72 67 65 74 22 20 61 72 67 73 3a 61 72 67 2d  arget" args:arg-
6af0: 68 61 73 68 29 20 61 72 67 73 3a 61 72 67 2d 68  hash) args:arg-h
6b00: 61 73 68 29 29 29 0a 09 28 69 66 20 28 6e 6f 74  ash)))..(if (not
6b10: 20 28 63 61 72 20 2a 63 6f 6e 66 69 67 69 6e 66   (car *configinf
6b20: 6f 2a 29 29 0a 09 20 20 20 20 28 62 65 67 69 6e  o*))..    (begin
6b30: 0a 09 20 20 20 20 20 20 28 64 65 62 75 67 3a 70  ..      (debug:p
6b40: 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 41  rint 0 "ERROR: A
6b50: 74 74 65 6d 70 74 65 64 20 74 6f 20 22 20 61 63  ttempted to " ac
6b60: 74 69 6f 6e 2d 64 65 73 63 20 22 20 62 75 74 20  tion-desc " but 
6b70: 72 75 6e 20 61 72 65 61 20 63 6f 6e 66 69 67 20  run area config 
6b80: 66 69 6c 65 20 6e 6f 74 20 66 6f 75 6e 64 22 29  file not found")
6b90: 0a 09 20 20 20 20 20 20 28 65 78 69 74 20 31 29  ..      (exit 1)
6ba0: 29 0a 09 20 20 20 20 3b 3b 20 45 78 74 72 61 63  )..    ;; Extrac
6bb0: 74 20 6f 75 74 20 73 74 75 66 66 20 6e 65 65 64  t out stuff need
6bc0: 65 64 20 69 6e 20 6d 6f 73 74 20 6f 72 20 6d 61  ed in most or ma
6bd0: 6e 79 20 63 61 6c 6c 73 0a 09 20 20 20 20 3b 3b  ny calls..    ;;
6be0: 20 68 65 72 65 20 74 68 65 6e 20 63 61 6c 6c 20   here then call 
6bf0: 70 72 6f 63 0a 09 20 20 20 20 28 6c 65 74 2a 20  proc..    (let* 
6c00: 28 28 6b 65 79 6e 61 6d 65 73 20 20 20 28 6d 61  ((keynames   (ma
6c10: 70 20 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64 6e  p key:get-fieldn
6c20: 61 6d 65 20 6b 65 79 73 29 29 0a 09 09 20 20 20  ame keys))...   
6c30: 28 6b 65 79 76 61 6c 6c 73 74 20 20 28 6b 65 79  (keyvallst  (key
6c40: 73 2d 3e 76 61 6c 6c 69 73 74 20 6b 65 79 73 20  s->vallist keys 
6c50: 23 74 29 29 29 0a 09 20 20 20 20 20 20 28 70 72  #t)))..      (pr
6c60: 6f 63 20 64 62 20 74 61 72 67 65 74 20 72 75 6e  oc db target run
6c70: 6e 61 6d 65 20 6b 65 79 73 20 6b 65 79 6e 61 6d  name keys keynam
6c80: 65 73 20 6b 65 79 76 61 6c 6c 73 74 29 29 29 0a  es keyvallst))).
6c90: 09 28 73 71 6c 69 74 65 33 3a 66 69 6e 61 6c 69  .(sqlite3:finali
6ca0: 7a 65 21 20 64 62 29 0a 09 28 73 65 74 21 20 2a  ze! db)..(set! *
6cb0: 64 69 64 73 6f 6d 65 74 68 69 6e 67 2a 20 23 74  didsomething* #t
6cc0: 29 29 29 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d  ))))))..;;======
6cd0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6ce0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6cf0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6d00: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6d10: 0a 3b 3b 20 52 6f 6c 6c 75 70 20 72 75 6e 73 0a  .;; Rollup runs.
6d20: 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ;;==============
6d30: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6d40: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6d50: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6d60: 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 55 70 64  ========..;; Upd
6d70: 61 74 65 20 74 68 65 20 74 65 73 74 5f 6d 65 74  ate the test_met
6d80: 61 20 74 61 62 6c 65 20 66 6f 72 20 74 68 69 73  a table for this
6d90: 20 74 65 73 74 0a 28 64 65 66 69 6e 65 20 28 72   test.(define (r
6da0: 75 6e 73 3a 75 70 64 61 74 65 2d 74 65 73 74 5f  uns:update-test_
6db0: 6d 65 74 61 20 64 62 20 74 65 73 74 2d 6e 61 6d  meta db test-nam
6dc0: 65 20 74 65 73 74 2d 63 6f 6e 66 29 0a 20 20 28  e test-conf).  (
6dd0: 6c 65 74 20 28 28 63 75 72 72 72 65 63 6f 72 64  let ((currrecord
6de0: 20 28 72 64 62 3a 74 65 73 74 6d 65 74 61 2d 67   (rdb:testmeta-g
6df0: 65 74 2d 72 65 63 6f 72 64 20 64 62 20 74 65 73  et-record db tes
6e00: 74 2d 6e 61 6d 65 29 29 29 0a 20 20 20 20 28 69  t-name))).    (i
6e10: 66 20 28 6e 6f 74 20 63 75 72 72 72 65 63 6f 72  f (not currrecor
6e20: 64 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 28 73  d)..(begin..  (s
6e30: 65 74 21 20 63 75 72 72 72 65 63 6f 72 64 20 28  et! currrecord (
6e40: 6d 61 6b 65 2d 76 65 63 74 6f 72 20 31 30 20 23  make-vector 10 #
6e50: 66 29 29 0a 09 20 20 28 72 64 62 3a 74 65 73 74  f))..  (rdb:test
6e60: 6d 65 74 61 2d 61 64 64 2d 72 65 63 6f 72 64 20  meta-add-record 
6e70: 64 62 20 74 65 73 74 2d 6e 61 6d 65 29 29 29 0a  db test-name))).
6e80: 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20      (for-each . 
6e90: 20 20 20 20 28 6c 61 6d 62 64 61 20 28 6b 65 79      (lambda (key
6ea0: 29 0a 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28  ).       (let* (
6eb0: 28 69 64 78 20 28 63 61 64 72 20 6b 65 79 29 29  (idx (cadr key))
6ec0: 0a 09 20 20 20 20 20 20 28 66 6c 64 20 28 63 61  ..      (fld (ca
6ed0: 72 20 20 6b 65 79 29 29 0a 09 20 20 20 20 20 20  r  key))..      
6ee0: 28 76 61 6c 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f  (val (config-loo
6ef0: 6b 75 70 20 74 65 73 74 2d 63 6f 6e 66 20 22 74  kup test-conf "t
6f00: 65 73 74 5f 6d 65 74 61 22 20 66 6c 64 29 29 29  est_meta" fld)))
6f10: 0a 09 20 3b 3b 20 28 64 65 62 75 67 3a 70 72 69  .. ;; (debug:pri
6f20: 6e 74 20 35 20 22 69 64 78 3a 20 22 20 69 64 78  nt 5 "idx: " idx
6f30: 20 22 20 66 6c 64 3a 20 22 20 66 6c 64 20 22 20   " fld: " fld " 
6f40: 76 61 6c 3a 20 22 20 76 61 6c 29 0a 09 20 28 69  val: " val).. (i
6f50: 66 20 28 61 6e 64 20 76 61 6c 20 28 6e 6f 74 20  f (and val (not 
6f60: 28 65 71 75 61 6c 3f 20 28 76 65 63 74 6f 72 2d  (equal? (vector-
6f70: 72 65 66 20 63 75 72 72 72 65 63 6f 72 64 20 69  ref currrecord i
6f80: 64 78 29 20 76 61 6c 29 29 29 0a 09 20 20 20 20  dx) val)))..    
6f90: 20 28 62 65 67 69 6e 0a 09 20 20 20 20 20 20 20   (begin..       
6fa0: 28 70 72 69 6e 74 20 22 55 70 64 61 74 69 6e 67  (print "Updating
6fb0: 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 22   " test-name " "
6fc0: 20 66 6c 64 20 22 20 74 6f 20 22 20 76 61 6c 29   fld " to " val)
6fd0: 0a 09 20 20 20 20 20 20 20 28 64 62 3a 74 65 73  ..       (db:tes
6fe0: 74 6d 65 74 61 2d 75 70 64 61 74 65 2d 66 69 65  tmeta-update-fie
6ff0: 6c 64 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 20  ld db test-name 
7000: 66 6c 64 20 76 61 6c 29 29 29 29 29 0a 20 20 20  fld val))))).   
7010: 20 20 27 28 28 22 61 75 74 68 6f 72 22 20 32 29    '(("author" 2)
7020: 28 22 6f 77 6e 65 72 22 20 33 29 28 22 64 65 73  ("owner" 3)("des
7030: 63 72 69 70 74 69 6f 6e 22 20 34 29 28 22 72 65  cription" 4)("re
7040: 76 69 65 77 65 64 22 20 35 29 28 22 74 61 67 73  viewed" 5)("tags
7050: 22 20 39 29 29 29 29 29 0a 0a 3b 3b 20 55 70 64  " 9)))))..;; Upd
7060: 61 74 65 20 74 65 73 74 5f 6d 65 74 61 20 66 6f  ate test_meta fo
7070: 72 20 61 6c 6c 20 74 65 73 74 73 0a 28 64 65 66  r all tests.(def
7080: 69 6e 65 20 28 72 75 6e 73 3a 75 70 64 61 74 65  ine (runs:update
7090: 2d 61 6c 6c 2d 74 65 73 74 5f 6d 65 74 61 20 64  -all-test_meta d
70a0: 62 29 0a 20 20 28 6c 65 74 20 28 28 74 65 73 74  b).  (let ((test
70b0: 2d 6e 61 6d 65 73 20 28 67 65 74 2d 61 6c 6c 2d  -names (get-all-
70c0: 6c 65 67 61 6c 2d 74 65 73 74 73 29 29 29 0a 20  legal-tests))). 
70d0: 20 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 20     (for-each .  
70e0: 20 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74     (lambda (test
70f0: 2d 6e 61 6d 65 29 0a 20 20 20 20 20 20 20 28 6c  -name).       (l
7100: 65 74 2a 20 28 28 74 65 73 74 2d 70 61 74 68 20  et* ((test-path 
7110: 20 20 20 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74     (conc *toppat
7120: 68 2a 20 22 2f 74 65 73 74 73 2f 22 20 74 65 73  h* "/tests/" tes
7130: 74 2d 6e 61 6d 65 29 29 0a 09 20 20 20 20 20 20  t-name))..      
7140: 28 74 65 73 74 2d 63 6f 6e 66 69 67 66 20 28 63  (test-configf (c
7150: 6f 6e 63 20 74 65 73 74 2d 70 61 74 68 20 22 2f  onc test-path "/
7160: 74 65 73 74 63 6f 6e 66 69 67 22 29 29 0a 09 20  testconfig")).. 
7170: 20 20 20 20 20 28 74 65 73 74 65 78 69 73 74 73       (testexists
7180: 20 20 20 28 61 6e 64 20 28 66 69 6c 65 2d 65 78     (and (file-ex
7190: 69 73 74 73 3f 20 74 65 73 74 2d 63 6f 6e 66 69  ists? test-confi
71a0: 67 66 29 28 66 69 6c 65 2d 72 65 61 64 2d 61 63  gf)(file-read-ac
71b0: 63 65 73 73 3f 20 74 65 73 74 2d 63 6f 6e 66 69  cess? test-confi
71c0: 67 66 29 29 29 0a 09 20 20 20 20 20 20 3b 3b 20  gf)))..      ;; 
71d0: 72 65 61 64 20 63 6f 6e 66 69 67 73 20 77 69 74  read configs wit
71e0: 68 20 74 72 69 63 6b 73 20 74 75 72 6e 65 64 20  h tricks turned 
71f0: 6f 66 66 20 28 69 2e 65 2e 20 6e 6f 20 73 79 73  off (i.e. no sys
7200: 74 65 6d 29 0a 09 20 20 20 20 20 20 28 74 65 73  tem)..      (tes
7210: 74 2d 63 6f 6e 66 20 20 20 20 28 69 66 20 74 65  t-conf    (if te
7220: 73 74 65 78 69 73 74 73 20 28 72 65 61 64 2d 63  stexists (read-c
7230: 6f 6e 66 69 67 20 74 65 73 74 2d 63 6f 6e 66 69  onfig test-confi
7240: 67 66 20 23 66 20 23 66 29 28 6d 61 6b 65 2d 68  gf #f #f)(make-h
7250: 61 73 68 2d 74 61 62 6c 65 29 29 29 29 0a 09 20  ash-table)))).. 
7260: 28 72 75 6e 73 3a 75 70 64 61 74 65 2d 74 65 73  (runs:update-tes
7270: 74 5f 6d 65 74 61 20 64 62 20 74 65 73 74 2d 6e  t_meta db test-n
7280: 61 6d 65 20 74 65 73 74 2d 63 6f 6e 66 29 29 29  ame test-conf)))
7290: 0a 20 20 20 20 20 74 65 73 74 2d 6e 61 6d 65 73  .     test-names
72a0: 29 29 29 0a 0a 3b 3b 20 54 68 69 73 20 63 6f 75  )))..;; This cou
72b0: 6c 64 20 70 72 6f 62 61 62 6c 79 20 62 65 20 72  ld probably be r
72c0: 65 66 61 63 74 6f 72 65 64 20 69 6e 74 6f 20 6f  efactored into o
72d0: 6e 65 20 63 6f 6d 70 6c 65 78 20 71 75 65 72 79  ne complex query
72e0: 20 2e 2e 2e 0a 28 64 65 66 69 6e 65 20 28 72 75   ....(define (ru
72f0: 6e 73 3a 72 6f 6c 6c 75 70 2d 72 75 6e 20 64 62  ns:rollup-run db
7300: 20 6b 65 79 73 20 6b 65 79 76 61 6c 6c 73 74 20   keys keyvallst 
7310: 72 75 6e 6e 61 6d 65 20 75 73 65 72 29 20 3b 3b  runname user) ;;
7320: 20 77 61 73 20 74 61 72 67 65 74 2c 20 6e 6f 77   was target, now
7330: 20 6b 65 79 76 61 6c 6c 73 74 0a 20 20 28 64 65   keyvallst.  (de
7340: 62 75 67 3a 70 72 69 6e 74 20 34 20 22 72 75 6e  bug:print 4 "run
7350: 73 3a 72 6f 6c 6c 75 70 2d 72 75 6e 2c 20 6b 65  s:rollup-run, ke
7360: 79 73 3a 20 22 20 6b 65 79 73 20 22 20 6b 65 79  ys: " keys " key
7370: 76 61 6c 6c 73 74 3a 20 22 20 6b 65 79 76 61 6c  vallst: " keyval
7380: 6c 73 74 20 22 20 3a 72 75 6e 6e 61 6d 65 20 22  lst " :runname "
7390: 20 72 75 6e 6e 61 6d 65 20 22 20 75 73 65 72 3a   runname " user:
73a0: 20 22 20 75 73 65 72 29 0a 20 20 28 6c 65 74 2a   " user).  (let*
73b0: 20 28 3b 20 28 6b 65 79 76 61 6c 6c 6c 73 74 20   (; (keyvalllst 
73c0: 20 20 20 20 20 28 6b 65 79 73 3a 74 61 72 67 65       (keys:targe
73d0: 74 2d 3e 6b 65 79 76 61 6c 20 6b 65 79 73 20 74  t->keyval keys t
73e0: 61 72 67 65 74 29 29 0a 09 20 28 6e 65 77 2d 72  arget)).. (new-r
73f0: 75 6e 2d 69 64 20 20 20 20 20 20 28 72 75 6e 73  un-id      (runs
7400: 3a 72 65 67 69 73 74 65 72 2d 72 75 6e 20 64 62  :register-run db
7410: 20 6b 65 79 73 20 6b 65 79 76 61 6c 6c 73 74 20   keys keyvallst 
7420: 72 75 6e 6e 61 6d 65 20 22 6e 65 77 22 20 22 6e  runname "new" "n
7430: 2f 61 22 20 75 73 65 72 29 29 0a 09 20 28 70 72  /a" user)).. (pr
7440: 65 76 2d 74 65 73 74 73 20 20 20 20 20 20 28 74  ev-tests      (t
7450: 65 73 74 3a 67 65 74 2d 6d 61 74 63 68 69 6e 67  est:get-matching
7460: 2d 70 72 65 76 69 6f 75 73 2d 74 65 73 74 2d 72  -previous-test-r
7470: 75 6e 2d 72 65 63 6f 72 64 73 20 64 62 20 6e 65  un-records db ne
7480: 77 2d 72 75 6e 2d 69 64 20 22 25 22 20 22 25 22  w-run-id "%" "%"
7490: 29 29 0a 09 20 28 63 75 72 72 2d 74 65 73 74 73  )).. (curr-tests
74a0: 20 20 20 20 20 20 28 64 62 2d 67 65 74 2d 74 65        (db-get-te
74b0: 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 6e  sts-for-run db n
74c0: 65 77 2d 72 75 6e 2d 69 64 20 22 25 22 20 22 25  ew-run-id "%" "%
74d0: 22 20 27 28 29 20 27 28 29 29 29 0a 09 20 28 63  " '() '())).. (c
74e0: 75 72 72 2d 74 65 73 74 73 2d 68 61 73 68 20 28  urr-tests-hash (
74f0: 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 29  make-hash-table)
7500: 29 29 0a 20 20 20 20 28 64 62 3a 75 70 64 61 74  )).    (db:updat
7510: 65 2d 72 75 6e 2d 65 76 65 6e 74 5f 74 69 6d 65  e-run-event_time
7520: 20 64 62 20 6e 65 77 2d 72 75 6e 2d 69 64 29 0a   db new-run-id).
7530: 20 20 20 20 3b 3b 20 69 6e 64 65 78 20 74 68 65      ;; index the
7540: 20 61 6c 72 65 61 64 79 20 73 61 76 65 64 20 74   already saved t
7550: 65 73 74 73 20 62 79 20 74 65 73 74 6e 61 6d 65  ests by testname
7560: 20 61 6e 64 20 69 74 65 6d 64 61 74 20 69 6e 20   and itemdat in 
7570: 63 75 72 72 2d 74 65 73 74 73 2d 68 61 73 68 0a  curr-tests-hash.
7580: 20 20 20 20 28 66 6f 72 2d 65 61 63 68 0a 20 20      (for-each.  
7590: 20 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74     (lambda (test
75a0: 64 61 74 29 0a 20 20 20 20 20 20 20 28 6c 65 74  dat).       (let
75b0: 2a 20 28 28 74 65 73 74 6e 61 6d 65 20 20 28 64  * ((testname  (d
75c0: 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e  b:test-get-testn
75d0: 61 6d 65 20 74 65 73 74 64 61 74 29 29 0a 09 20  ame testdat)).. 
75e0: 20 20 20 20 20 28 69 74 65 6d 2d 70 61 74 68 20       (item-path 
75f0: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65  (db:test-get-ite
7600: 6d 2d 70 61 74 68 20 74 65 73 74 64 61 74 29 29  m-path testdat))
7610: 0a 09 20 20 20 20 20 20 28 66 75 6c 6c 2d 6e 61  ..      (full-na
7620: 6d 65 20 28 63 6f 6e 63 20 74 65 73 74 6e 61 6d  me (conc testnam
7630: 65 20 22 2f 22 20 69 74 65 6d 2d 70 61 74 68 29  e "/" item-path)
7640: 29 29 0a 09 20 28 68 61 73 68 2d 74 61 62 6c 65  )).. (hash-table
7650: 2d 73 65 74 21 20 63 75 72 72 2d 74 65 73 74 73  -set! curr-tests
7660: 2d 68 61 73 68 20 66 75 6c 6c 2d 6e 61 6d 65 20  -hash full-name 
7670: 74 65 73 74 64 61 74 29 29 29 0a 20 20 20 20 20  testdat))).     
7680: 63 75 72 72 2d 74 65 73 74 73 29 0a 20 20 20 20  curr-tests).    
7690: 3b 3b 20 4e 4f 50 45 3a 20 4e 6f 6e 2d 6f 70 74  ;; NOPE: Non-opt
76a0: 69 6d 61 6c 20 61 70 70 72 6f 61 63 68 2e 20 54  imal approach. T
76b0: 72 79 20 74 68 69 73 20 69 6e 73 74 65 61 64 2e  ry this instead.
76c0: 0a 20 20 20 20 3b 3b 20 20 20 31 2e 20 74 65 73  .    ;;   1. tes
76d0: 74 73 20 61 72 65 20 72 65 63 65 69 76 65 64 20  ts are received 
76e0: 69 6e 20 61 20 6c 69 73 74 2c 20 6d 6f 73 74 20  in a list, most 
76f0: 72 65 63 65 6e 74 20 66 69 72 73 74 0a 20 20 20  recent first.   
7700: 20 3b 3b 20 20 20 32 2e 20 72 65 70 6c 61 63 65   ;;   2. replace
7710: 20 74 68 65 20 72 6f 6c 6c 75 70 20 74 65 73 74   the rollup test
7720: 20 77 69 74 68 20 74 68 65 20 6e 65 77 20 2a 61   with the new *a
7730: 6c 77 61 79 73 2a 0a 20 20 20 20 28 66 6f 72 2d  lways*.    (for-
7740: 65 61 63 68 20 0a 20 20 20 20 20 28 6c 61 6d 62  each .     (lamb
7750: 64 61 20 28 74 65 73 74 64 61 74 29 0a 20 20 20  da (testdat).   
7760: 20 20 20 20 28 6c 65 74 2a 20 28 28 74 65 73 74      (let* ((test
7770: 6e 61 6d 65 20 20 28 64 62 3a 74 65 73 74 2d 67  name  (db:test-g
7780: 65 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74  et-testname test
7790: 64 61 74 29 29 0a 09 20 20 20 20 20 20 28 69 74  dat))..      (it
77a0: 65 6d 2d 70 61 74 68 20 28 64 62 3a 74 65 73 74  em-path (db:test
77b0: 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74  -get-item-path t
77c0: 65 73 74 64 61 74 29 29 0a 09 20 20 20 20 20 20  estdat))..      
77d0: 28 66 75 6c 6c 2d 6e 61 6d 65 20 28 63 6f 6e 63  (full-name (conc
77e0: 20 74 65 73 74 6e 61 6d 65 20 22 2f 22 20 69 74   testname "/" it
77f0: 65 6d 2d 70 61 74 68 29 29 0a 09 20 20 20 20 20  em-path))..     
7800: 20 28 70 72 65 76 2d 74 65 73 74 2d 64 61 74 20   (prev-test-dat 
7810: 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f  (hash-table-ref/
7820: 64 65 66 61 75 6c 74 20 63 75 72 72 2d 74 65 73  default curr-tes
7830: 74 73 2d 68 61 73 68 20 66 75 6c 6c 2d 6e 61 6d  ts-hash full-nam
7840: 65 20 23 66 29 29 0a 09 20 20 20 20 20 20 28 74  e #f))..      (t
7850: 65 73 74 2d 73 74 65 70 73 20 20 20 20 20 20 28  est-steps      (
7860: 64 62 3a 67 65 74 2d 73 74 65 70 73 2d 66 6f 72  db:get-steps-for
7870: 2d 74 65 73 74 20 64 62 20 28 64 62 3a 74 65 73  -test db (db:tes
7880: 74 2d 67 65 74 2d 69 64 20 74 65 73 74 64 61 74  t-get-id testdat
7890: 29 29 29 0a 09 20 20 20 20 20 20 28 6e 65 77 2d  )))..      (new-
78a0: 74 65 73 74 2d 72 65 63 6f 72 64 20 23 66 29 29  test-record #f))
78b0: 0a 09 20 3b 3b 20 72 65 70 6c 61 63 65 20 74 68  .. ;; replace th
78c0: 65 73 65 20 77 69 74 68 20 69 6e 73 65 72 74 20  ese with insert 
78d0: 2e 2e 2e 20 73 65 6c 65 63 74 0a 09 20 28 61 70  ... select.. (ap
78e0: 70 6c 79 20 73 71 6c 69 74 65 33 3a 65 78 65 63  ply sqlite3:exec
78f0: 75 74 65 20 0a 09 09 64 62 20 0a 09 09 28 63 6f  ute ...db ...(co
7900: 6e 63 20 22 49 4e 53 45 52 54 20 4f 52 20 52 45  nc "INSERT OR RE
7910: 50 4c 41 43 45 20 49 4e 54 4f 20 74 65 73 74 73  PLACE INTO tests
7920: 20 28 72 75 6e 5f 69 64 2c 74 65 73 74 6e 61 6d   (run_id,testnam
7930: 65 2c 73 74 61 74 65 2c 73 74 61 74 75 73 2c 65  e,state,status,e
7940: 76 65 6e 74 5f 74 69 6d 65 2c 68 6f 73 74 2c 63  vent_time,host,c
7950: 70 75 6c 6f 61 64 2c 64 69 73 6b 66 72 65 65 2c  puload,diskfree,
7960: 75 6e 61 6d 65 2c 72 75 6e 64 69 72 2c 69 74 65  uname,rundir,ite
7970: 6d 5f 70 61 74 68 2c 72 75 6e 5f 64 75 72 61 74  m_path,run_durat
7980: 69 6f 6e 2c 66 69 6e 61 6c 5f 6c 6f 67 66 2c 63  ion,final_logf,c
7990: 6f 6d 6d 65 6e 74 29 20 22 0a 09 09 20 20 20 20  omment) "...    
79a0: 20 20 22 56 41 4c 55 45 53 20 28 3f 2c 3f 2c 3f    "VALUES (?,?,?
79b0: 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f  ,?,?,?,?,?,?,?,?
79c0: 2c 3f 2c 3f 2c 3f 29 3b 22 29 0a 09 09 6e 65 77  ,?,?,?);")...new
79d0: 2d 72 75 6e 2d 69 64 20 28 63 64 64 72 20 28 76  -run-id (cddr (v
79e0: 65 63 74 6f 72 2d 3e 6c 69 73 74 20 74 65 73 74  ector->list test
79f0: 64 61 74 29 29 29 0a 09 20 28 73 65 74 21 20 6e  dat))).. (set! n
7a00: 65 77 2d 74 65 73 74 64 61 74 20 28 63 61 72 20  ew-testdat (car 
7a10: 28 64 62 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f  (db-get-tests-fo
7a20: 72 2d 72 75 6e 20 64 62 20 6e 65 77 2d 72 75 6e  r-run db new-run
7a30: 2d 69 64 20 74 65 73 74 6e 61 6d 65 20 69 74 65  -id testname ite
7a40: 6d 2d 70 61 74 68 20 27 28 29 20 27 28 29 29 29  m-path '() '()))
7a50: 29 0a 09 20 28 68 61 73 68 2d 74 61 62 6c 65 2d  ).. (hash-table-
7a60: 73 65 74 21 20 63 75 72 72 2d 74 65 73 74 73 2d  set! curr-tests-
7a70: 68 61 73 68 20 66 75 6c 6c 2d 6e 61 6d 65 20 6e  hash full-name n
7a80: 65 77 2d 74 65 73 74 64 61 74 29 20 3b 3b 20 74  ew-testdat) ;; t
7a90: 68 69 73 20 63 6f 75 6c 64 20 62 65 20 63 6f 6e  his could be con
7aa0: 66 75 73 69 6e 67 2c 20 77 68 69 63 68 20 72 65  fusing, which re
7ab0: 63 6f 72 64 20 73 68 6f 75 6c 64 20 67 6f 20 69  cord should go i
7ac0: 6e 74 6f 20 74 68 65 20 6c 6f 6f 6b 75 70 20 74  nto the lookup t
7ad0: 61 62 6c 65 3f 0a 09 20 3b 3b 20 4e 6f 77 20 64  able?.. ;; Now d
7ae0: 75 70 6c 69 63 61 74 65 20 74 68 65 20 74 65 73  uplicate the tes
7af0: 74 20 73 74 65 70 73 0a 09 20 28 64 65 62 75 67  t steps.. (debug
7b00: 3a 70 72 69 6e 74 20 34 20 22 43 6f 70 79 69 6e  :print 4 "Copyin
7b10: 67 20 72 65 63 6f 72 64 73 20 69 6e 20 74 65 73  g records in tes
7b20: 74 5f 73 74 65 70 73 20 66 72 6f 6d 20 74 65 73  t_steps from tes
7b30: 74 5f 69 64 3d 22 20 28 64 62 3a 74 65 73 74 2d  t_id=" (db:test-
7b40: 67 65 74 2d 69 64 20 74 65 73 74 64 61 74 29 20  get-id testdat) 
7b50: 22 20 74 6f 20 22 20 28 64 62 3a 74 65 73 74 2d  " to " (db:test-
7b60: 67 65 74 2d 69 64 20 6e 65 77 2d 74 65 73 74 64  get-id new-testd
7b70: 61 74 29 29 0a 09 20 28 73 71 6c 69 74 65 33 3a  at)).. (sqlite3:
7b80: 65 78 65 63 75 74 65 20 0a 09 20 20 64 62 20 0a  execute ..  db .
7b90: 09 20 20 28 63 6f 6e 63 20 22 49 4e 53 45 52 54  .  (conc "INSERT
7ba0: 20 4f 52 20 52 45 50 4c 41 43 45 20 49 4e 54 4f   OR REPLACE INTO
7bb0: 20 74 65 73 74 5f 73 74 65 70 73 20 28 74 65 73   test_steps (tes
7bc0: 74 5f 69 64 2c 73 74 65 70 6e 61 6d 65 2c 73 74  t_id,stepname,st
7bd0: 61 74 65 2c 73 74 61 74 75 73 2c 65 76 65 6e 74  ate,status,event
7be0: 5f 74 69 6d 65 2c 63 6f 6d 6d 65 6e 74 29 20 22  _time,comment) "
7bf0: 0a 09 09 22 53 45 4c 45 43 54 20 22 20 28 64 62  ..."SELECT " (db
7c00: 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 6e 65 77  :test-get-id new
7c10: 2d 74 65 73 74 64 61 74 29 20 22 2c 73 74 65 70  -testdat) ",step
7c20: 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 61 74 75  name,state,statu
7c30: 73 2c 65 76 65 6e 74 5f 74 69 6d 65 2c 63 6f 6d  s,event_time,com
7c40: 6d 65 6e 74 20 46 52 4f 4d 20 74 65 73 74 5f 73  ment FROM test_s
7c50: 74 65 70 73 20 57 48 45 52 45 20 74 65 73 74 5f  teps WHERE test_
7c60: 69 64 3d 3f 3b 22 29 0a 09 20 20 28 64 62 3a 74  id=?;")..  (db:t
7c70: 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74 64  est-get-id testd
7c80: 61 74 29 29 0a 09 20 3b 3b 20 4e 6f 77 20 64 75  at)).. ;; Now du
7c90: 70 6c 69 63 61 74 65 20 74 68 65 20 74 65 73 74  plicate the test
7ca0: 20 64 61 74 61 0a 09 20 28 64 65 62 75 67 3a 70   data.. (debug:p
7cb0: 72 69 6e 74 20 34 20 22 43 6f 70 79 69 6e 67 20  rint 4 "Copying 
7cc0: 72 65 63 6f 72 64 73 20 69 6e 20 74 65 73 74 5f  records in test_
7cd0: 64 61 74 61 20 66 72 6f 6d 20 74 65 73 74 5f 69  data from test_i
7ce0: 64 3d 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74  d=" (db:test-get
7cf0: 2d 69 64 20 74 65 73 74 64 61 74 29 20 22 20 74  -id testdat) " t
7d00: 6f 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74  o " (db:test-get
7d10: 2d 69 64 20 6e 65 77 2d 74 65 73 74 64 61 74 29  -id new-testdat)
7d20: 29 0a 09 20 28 73 71 6c 69 74 65 33 3a 65 78 65  ).. (sqlite3:exe
7d30: 63 75 74 65 20 0a 09 20 20 64 62 20 0a 09 20 20  cute ..  db ..  
7d40: 28 63 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f 52  (conc "INSERT OR
7d50: 20 52 45 50 4c 41 43 45 20 49 4e 54 4f 20 74 65   REPLACE INTO te
7d60: 73 74 5f 64 61 74 61 20 28 74 65 73 74 5f 69 64  st_data (test_id
7d70: 2c 63 61 74 65 67 6f 72 79 2c 76 61 72 69 61 62  ,category,variab
7d80: 6c 65 2c 76 61 6c 75 65 2c 65 78 70 65 63 74 65  le,value,expecte
7d90: 64 2c 74 6f 6c 2c 75 6e 69 74 73 2c 63 6f 6d 6d  d,tol,units,comm
7da0: 65 6e 74 29 20 22 0a 09 09 22 53 45 4c 45 43 54  ent) "..."SELECT
7db0: 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d   " (db:test-get-
7dc0: 69 64 20 6e 65 77 2d 74 65 73 74 64 61 74 29 20  id new-testdat) 
7dd0: 22 2c 63 61 74 65 67 6f 72 79 2c 76 61 72 69 61  ",category,varia
7de0: 62 6c 65 2c 76 61 6c 75 65 2c 65 78 70 65 63 74  ble,value,expect
7df0: 65 64 2c 74 6f 6c 2c 75 6e 69 74 73 2c 63 6f 6d  ed,tol,units,com
7e00: 6d 65 6e 74 20 46 52 4f 4d 20 74 65 73 74 5f 64  ment FROM test_d
7e10: 61 74 61 20 57 48 45 52 45 20 74 65 73 74 5f 69  ata WHERE test_i
7e20: 64 3d 3f 3b 22 29 0a 09 20 20 28 64 62 3a 74 65  d=?;")..  (db:te
7e30: 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74 64 61  st-get-id testda
7e40: 74 29 29 0a 09 20 29 29 0a 20 20 20 20 20 70 72  t)).. )).     pr
7e50: 65 76 2d 74 65 73 74 73 29 29 29 0a 09 20 0a 20  ev-tests))).. . 
7e60: 20 20 20 20 0a                                       .