Megatest

Hex Artifact Content
Login

Artifact 4ae48c4de9333322f6bf1e314d2417fb02070857:


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 20 28  69 dot-locking (
01c0: 73 72 66 69 20 31 38 29 29 0a 28 69 6d 70 6f 72  srfi 18)).(impor
01d0: 74 20 28 70 72 65 66 69 78 20 73 71 6c 69 74 65  t (prefix sqlite
01e0: 33 20 73 71 6c 69 74 65 33 3a 29 29 0a 0a 28 64  3 sqlite3:))..(d
01f0: 65 63 6c 61 72 65 20 28 75 6e 69 74 20 72 75 6e  eclare (unit run
0200: 73 29 29 0a 28 64 65 63 6c 61 72 65 20 28 75 73  s)).(declare (us
0210: 65 73 20 64 62 29 29 0a 28 64 65 63 6c 61 72 65  es db)).(declare
0220: 20 28 75 73 65 73 20 63 6f 6d 6d 6f 6e 29 29 0a   (uses common)).
0230: 28 64 65 63 6c 61 72 65 20 28 75 73 65 73 20 69  (declare (uses i
0240: 74 65 6d 73 29 29 0a 28 64 65 63 6c 61 72 65 20  tems)).(declare 
0250: 28 75 73 65 73 20 72 75 6e 63 6f 6e 66 69 67 29  (uses runconfig)
0260: 29 0a 28 64 65 63 6c 61 72 65 20 28 75 73 65 73  ).(declare (uses
0270: 20 74 65 73 74 73 29 29 0a 28 64 65 63 6c 61 72   tests)).(declar
0280: 65 20 28 75 73 65 73 20 73 65 72 76 65 72 29 29  e (uses server))
0290: 0a 0a 28 69 6e 63 6c 75 64 65 20 22 63 6f 6d 6d  ..(include "comm
02a0: 6f 6e 5f 72 65 63 6f 72 64 73 2e 73 63 6d 22 29  on_records.scm")
02b0: 0a 28 69 6e 63 6c 75 64 65 20 22 6b 65 79 5f 72  .(include "key_r
02c0: 65 63 6f 72 64 73 2e 73 63 6d 22 29 0a 28 69 6e  ecords.scm").(in
02d0: 63 6c 75 64 65 20 22 64 62 5f 72 65 63 6f 72 64  clude "db_record
02e0: 73 2e 73 63 6d 22 29 0a 28 69 6e 63 6c 75 64 65  s.scm").(include
02f0: 20 22 72 75 6e 5f 72 65 63 6f 72 64 73 2e 73 63   "run_records.sc
0300: 6d 22 29 0a 28 69 6e 63 6c 75 64 65 20 22 74 65  m").(include "te
0310: 73 74 5f 72 65 63 6f 72 64 73 2e 73 63 6d 22 29  st_records.scm")
0320: 0a 0a 3b 3b 20 72 75 6e 73 3a 67 65 74 2d 72 75  ..;; runs:get-ru
0330: 6e 73 2d 62 79 2d 70 61 74 74 0a 3b 3b 20 67 65  ns-by-patt.;; ge
0340: 74 20 72 75 6e 73 20 62 79 20 6c 69 73 74 20 6f  t runs by list o
0350: 66 20 63 72 69 74 65 72 69 61 0a 3b 3b 20 72 65  f criteria.;; re
0360: 67 69 73 74 65 72 20 61 20 74 65 73 74 20 72 75  gister a test ru
0370: 6e 20 77 69 74 68 20 74 68 65 20 64 62 0a 3b 3b  n with the db.;;
0380: 0a 3b 3b 20 55 73 65 3a 20 28 64 62 2d 67 65 74  .;; Use: (db-get
0390: 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72  -value-by-header
03a0: 20 28 64 62 3a 67 65 74 2d 68 65 61 64 65 72 20   (db:get-header 
03b0: 72 75 6e 69 6e 66 6f 29 28 64 62 3a 67 65 74 2d  runinfo)(db:get-
03c0: 72 6f 77 20 72 75 6e 69 6e 66 6f 29 29 0a 3b 3b  row runinfo)).;;
03d0: 20 20 74 6f 20 65 78 74 72 61 63 74 20 69 6e 66    to extract inf
03e0: 6f 20 66 72 6f 6d 20 74 68 65 20 73 74 72 75 63  o from the struc
03f0: 74 75 72 65 20 72 65 74 75 72 6e 65 64 0a 3b 3b  ture returned.;;
0400: 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 67  .(define (runs:g
0410: 65 74 2d 72 75 6e 73 2d 62 79 2d 70 61 74 74 20  et-runs-by-patt 
0420: 64 62 20 6b 65 79 73 20 72 75 6e 6e 61 6d 65 70  db keys runnamep
0430: 61 74 74 20 2e 20 70 61 72 61 6d 73 29 20 3b 3b  att . params) ;;
0440: 20 74 65 73 74 2d 6e 61 6d 65 29 0a 20 20 28 6c   test-name).  (l
0450: 65 74 2a 20 28 28 6b 65 79 76 61 6c 6c 73 74 20  et* ((keyvallst 
0460: 28 6b 65 79 73 2d 3e 76 61 6c 6c 69 73 74 20 6b  (keys->vallist k
0470: 65 79 73 29 29 0a 09 20 28 74 6d 70 20 20 20 20  eys)).. (tmp    
0480: 20 20 28 72 75 6e 73 3a 67 65 74 2d 73 74 64 2d    (runs:get-std-
0490: 72 75 6e 2d 66 69 65 6c 64 73 20 6b 65 79 73 20  run-fields keys 
04a0: 27 28 22 69 64 22 20 22 72 75 6e 6e 61 6d 65 22  '("id" "runname"
04b0: 20 22 73 74 61 74 65 22 20 22 73 74 61 74 75 73   "state" "status
04c0: 22 20 22 6f 77 6e 65 72 22 20 22 65 76 65 6e 74  " "owner" "event
04d0: 5f 74 69 6d 65 22 29 29 29 0a 09 20 28 6b 65 79  _time"))).. (key
04e0: 73 74 72 20 20 20 28 63 61 72 20 74 6d 70 29 29  str   (car tmp))
04f0: 0a 09 20 28 68 65 61 64 65 72 20 20 20 28 63 61  .. (header   (ca
0500: 64 72 20 74 6d 70 29 29 0a 09 20 28 72 65 73 20  dr tmp)).. (res 
0510: 20 20 20 20 27 28 29 29 0a 09 20 28 6b 65 79 2d      '()).. (key-
0520: 70 61 74 74 20 22 22 29 29 0a 20 20 20 20 28 66  patt "")).    (f
0530: 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 20  or-each (lambda 
0540: 28 6b 65 79 76 61 6c 29 0a 09 09 28 6c 65 74 2a  (keyval)...(let*
0550: 20 28 28 6b 65 79 20 20 20 20 28 76 65 63 74 6f   ((key    (vecto
0560: 72 2d 72 65 66 20 6b 65 79 76 61 6c 20 30 29 29  r-ref keyval 0))
0570: 0a 09 09 20 20 20 20 20 20 20 28 66 75 6c 6b 65  ...       (fulke
0580: 79 20 28 63 6f 6e 63 20 22 3a 22 20 6b 65 79 29  y (conc ":" key)
0590: 29 0a 09 09 20 20 20 20 20 20 20 28 70 61 74 74  )...       (patt
05a0: 20 20 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67     (args:get-arg
05b0: 20 66 75 6c 6b 65 79 29 29 29 0a 09 09 20 20 28   fulkey)))...  (
05c0: 69 66 20 70 61 74 74 0a 09 09 20 20 20 20 20 20  if patt...      
05d0: 28 73 65 74 21 20 6b 65 79 2d 70 61 74 74 20 28  (set! key-patt (
05e0: 63 6f 6e 63 20 6b 65 79 2d 70 61 74 74 20 22 20  conc key-patt " 
05f0: 41 4e 44 20 22 20 6b 65 79 20 22 20 6c 69 6b 65  AND " key " like
0600: 20 27 22 20 70 61 74 74 20 22 27 22 29 29 0a 09   '" patt "'"))..
0610: 09 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09  .      (begin...
0620: 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20  .(debug:print 0 
0630: 22 45 52 52 4f 52 3a 20 73 65 61 72 63 68 69 6e  "ERROR: searchin
0640: 67 20 66 6f 72 20 72 75 6e 73 20 77 69 74 68 20  g for runs with 
0650: 6e 6f 20 70 61 74 74 65 72 6e 20 73 65 74 20 66  no pattern set f
0660: 6f 72 20 22 20 66 75 6c 6b 65 79 29 0a 09 09 09  or " fulkey)....
0670: 28 65 78 69 74 20 36 29 29 29 29 29 0a 09 20 20  (exit 6)))))..  
0680: 20 20 20 20 6b 65 79 73 29 0a 20 20 20 20 28 73      keys).    (s
0690: 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d  qlite3:for-each-
06a0: 72 6f 77 20 0a 20 20 20 20 20 28 6c 61 6d 62 64  row .     (lambd
06b0: 61 20 28 61 20 2e 20 72 29 0a 20 20 20 20 20 20  a (a . r).      
06c0: 20 28 73 65 74 21 20 72 65 73 20 28 63 6f 6e 73   (set! res (cons
06d0: 20 28 6c 69 73 74 2d 3e 76 65 63 74 6f 72 20 28   (list->vector (
06e0: 63 6f 6e 73 20 61 20 72 29 29 20 72 65 73 29 29  cons a r)) res))
06f0: 29 0a 20 20 20 20 20 64 62 20 0a 20 20 20 20 20  ).     db .     
0700: 28 63 6f 6e 63 20 22 53 45 4c 45 43 54 20 22 20  (conc "SELECT " 
0710: 6b 65 79 73 74 72 20 22 20 46 52 4f 4d 20 72 75  keystr " FROM ru
0720: 6e 73 20 57 48 45 52 45 20 72 75 6e 6e 61 6d 65  ns WHERE runname
0730: 20 6c 69 6b 65 20 3f 20 22 20 6b 65 79 2d 70 61   like ? " key-pa
0740: 74 74 20 22 3b 22 29 0a 20 20 20 20 20 72 75 6e  tt ";").     run
0750: 6e 61 6d 65 70 61 74 74 29 0a 20 20 20 20 28 76  namepatt).    (v
0760: 65 63 74 6f 72 20 68 65 61 64 65 72 20 72 65 73  ector header res
0770: 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 72 75  )))..(define (ru
0780: 6e 73 3a 74 65 73 74 2d 67 65 74 2d 66 75 6c 6c  ns:test-get-full
0790: 2d 70 61 74 68 20 74 65 73 74 29 0a 20 20 28 6c  -path test).  (l
07a0: 65 74 2a 20 28 28 74 65 73 74 6e 61 6d 65 20 28  et* ((testname (
07b0: 64 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74  db:test-get-test
07c0: 6e 61 6d 65 20 20 20 74 65 73 74 29 29 0a 09 20  name   test)).. 
07d0: 28 69 74 65 6d 70 61 74 68 20 28 64 62 3a 74 65  (itempath (db:te
07e0: 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68  st-get-item-path
07f0: 20 74 65 73 74 29 29 29 0a 20 20 20 20 28 63 6f   test))).    (co
0800: 6e 63 20 74 65 73 74 6e 61 6d 65 20 28 69 66 20  nc testname (if 
0810: 28 65 71 75 61 6c 3f 20 69 74 65 6d 70 61 74 68  (equal? itempath
0820: 20 22 22 29 20 22 22 20 28 63 6f 6e 63 20 22 28   "") "" (conc "(
0830: 22 20 69 74 65 6d 70 61 74 68 20 22 29 22 29 29  " itempath ")"))
0840: 29 29 29 0a 0a 0a 28 64 65 66 69 6e 65 20 28 73  )))...(define (s
0850: 65 74 2d 6d 65 67 61 74 65 73 74 2d 65 6e 76 2d  et-megatest-env-
0860: 76 61 72 73 20 64 62 20 72 75 6e 2d 69 64 29 0a  vars db run-id).
0870: 20 20 28 6c 65 74 20 28 28 6b 65 79 73 20 28 72    (let ((keys (r
0880: 64 62 3a 67 65 74 2d 6b 65 79 73 20 64 62 29 29  db:get-keys db))
0890: 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20  ).    (for-each 
08a0: 28 6c 61 6d 62 64 61 20 28 6b 65 79 29 0a 09 09  (lambda (key)...
08b0: 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63  (sqlite3:for-eac
08c0: 68 2d 72 6f 77 0a 09 09 20 28 6c 61 6d 62 64 61  h-row... (lambda
08d0: 20 28 76 61 6c 29 0a 09 09 20 20 20 28 64 65 62   (val)...   (deb
08e0: 75 67 3a 70 72 69 6e 74 20 32 20 22 73 65 74 65  ug:print 2 "sete
08f0: 6e 76 20 22 20 28 6b 65 79 3a 67 65 74 2d 66 69  nv " (key:get-fi
0900: 65 6c 64 6e 61 6d 65 20 6b 65 79 29 20 22 20 22  eldname key) " "
0910: 20 76 61 6c 29 0a 09 09 20 20 20 28 73 65 74 65   val)...   (sete
0920: 6e 76 20 28 6b 65 79 3a 67 65 74 2d 66 69 65 6c  nv (key:get-fiel
0930: 64 6e 61 6d 65 20 6b 65 79 29 20 76 61 6c 29 29  dname key) val))
0940: 0a 09 09 20 64 62 20 0a 09 09 20 28 63 6f 6e 63  ... db ... (conc
0950: 20 22 53 45 4c 45 43 54 20 22 20 28 6b 65 79 3a   "SELECT " (key:
0960: 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65  get-fieldname ke
0970: 79 29 20 22 20 46 52 4f 4d 20 72 75 6e 73 20 57  y) " FROM runs W
0980: 48 45 52 45 20 69 64 3d 3f 3b 22 29 0a 09 09 20  HERE id=?;")... 
0990: 72 75 6e 2d 69 64 29 29 0a 09 20 20 20 20 20 20  run-id))..      
09a0: 6b 65 79 73 29 0a 20 20 20 20 3b 3b 20 4c 65 74  keys).    ;; Let
09b0: 73 20 75 73 65 20 74 68 69 73 20 61 73 20 61 6e  s use this as an
09c0: 20 6f 70 70 6f 72 74 75 6e 69 74 79 20 74 6f 20   opportunity to 
09d0: 70 75 74 20 4d 54 5f 52 55 4e 4e 41 4d 45 20 69  put MT_RUNNAME i
09e0: 6e 20 74 68 65 20 65 6e 76 69 72 6f 6e 6d 65 6e  n the environmen
09f0: 74 0a 20 20 20 20 28 73 71 6c 69 74 65 33 3a 66  t.    (sqlite3:f
0a00: 6f 72 2d 65 61 63 68 2d 72 6f 77 0a 20 20 20 20  or-each-row.    
0a10: 20 28 6c 61 6d 62 64 61 20 28 72 75 6e 6e 61 6d   (lambda (runnam
0a20: 65 29 0a 20 20 20 20 20 20 20 28 73 65 74 65 6e  e).       (seten
0a30: 76 20 22 4d 54 5f 52 55 4e 4e 41 4d 45 22 20 72  v "MT_RUNNAME" r
0a40: 75 6e 6e 61 6d 65 29 29 0a 20 20 20 20 20 64 62  unname)).     db
0a50: 0a 20 20 20 20 20 22 53 45 4c 45 43 54 20 72 75  .     "SELECT ru
0a60: 6e 6e 61 6d 65 20 46 52 4f 4d 20 72 75 6e 73 20  nname FROM runs 
0a70: 57 48 45 52 45 20 69 64 3d 3f 3b 22 0a 20 20 20  WHERE id=?;".   
0a80: 20 20 72 75 6e 2d 69 64 29 0a 20 20 20 20 29 29    run-id).    ))
0a90: 0a 0a 28 64 65 66 69 6e 65 20 28 73 65 74 2d 69  ..(define (set-i
0aa0: 74 65 6d 2d 65 6e 76 2d 76 61 72 73 20 69 74 65  tem-env-vars ite
0ab0: 6d 64 61 74 29 0a 20 20 28 66 6f 72 2d 65 61 63  mdat).  (for-eac
0ac0: 68 20 28 6c 61 6d 62 64 61 20 28 69 74 65 6d 29  h (lambda (item)
0ad0: 0a 09 20 20 20 20 20 20 28 64 65 62 75 67 3a 70  ..      (debug:p
0ae0: 72 69 6e 74 20 32 20 22 73 65 74 65 6e 76 20 22  rint 2 "setenv "
0af0: 20 28 63 61 72 20 69 74 65 6d 29 20 22 20 22 20   (car item) " " 
0b00: 28 63 61 64 72 20 69 74 65 6d 29 29 0a 09 20 20  (cadr item))..  
0b10: 20 20 20 20 28 73 65 74 65 6e 76 20 28 63 61 72      (setenv (car
0b20: 20 69 74 65 6d 29 20 28 63 61 64 72 20 69 74 65   item) (cadr ite
0b30: 6d 29 29 29 0a 09 20 20 20 20 69 74 65 6d 64 61  m)))..    itemda
0b40: 74 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 72 75  t))..(define (ru
0b50: 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65 2d  ns:can-run-more-
0b60: 74 65 73 74 73 20 64 62 20 74 65 73 74 2d 72 65  tests db test-re
0b70: 63 6f 72 64 29 0a 20 20 28 6c 65 74 2a 20 28 28  cord).  (let* ((
0b80: 74 63 6f 6e 66 69 67 20 20 20 20 20 20 20 20 20  tconfig         
0b90: 20 20 20 20 20 20 20 20 28 74 65 73 74 73 3a 74          (tests:t
0ba0: 65 73 74 71 75 65 75 65 2d 67 65 74 2d 74 65 73  estqueue-get-tes
0bb0: 74 63 6f 6e 66 69 67 20 74 65 73 74 2d 72 65 63  tconfig test-rec
0bc0: 6f 72 64 29 29 0a 09 20 28 6a 6f 62 67 72 6f 75  ord)).. (jobgrou
0bd0: 70 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  p               
0be0: 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20   (config-lookup 
0bf0: 74 63 6f 6e 66 69 67 20 22 72 65 71 75 69 72 65  tconfig "require
0c00: 6d 65 6e 74 73 22 20 22 6a 6f 62 67 72 6f 75 70  ments" "jobgroup
0c10: 22 29 29 0a 09 20 28 6e 75 6d 2d 72 75 6e 6e 69  ")).. (num-runni
0c20: 6e 67 20 20 20 20 20 20 20 20 20 20 20 20 20 28  ng             (
0c30: 64 62 3a 67 65 74 2d 63 6f 75 6e 74 2d 74 65 73  db:get-count-tes
0c40: 74 73 2d 72 75 6e 6e 69 6e 67 20 64 62 29 29 0a  ts-running db)).
0c50: 09 20 28 6e 75 6d 2d 72 75 6e 6e 69 6e 67 2d 69  . (num-running-i
0c60: 6e 2d 6a 6f 62 67 72 6f 75 70 20 28 64 62 3a 67  n-jobgroup (db:g
0c70: 65 74 2d 63 6f 75 6e 74 2d 74 65 73 74 73 2d 72  et-count-tests-r
0c80: 75 6e 6e 69 6e 67 2d 69 6e 2d 6a 6f 62 67 72 6f  unning-in-jobgro
0c90: 75 70 20 64 62 20 6a 6f 62 67 72 6f 75 70 29 29  up db jobgroup))
0ca0: 0a 09 20 28 6d 61 78 2d 63 6f 6e 63 75 72 72 65  .. (max-concurre
0cb0: 6e 74 2d 6a 6f 62 73 20 20 20 20 20 28 63 6f 6e  nt-jobs     (con
0cc0: 66 69 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66  fig-lookup *conf
0cd0: 69 67 64 61 74 2a 20 22 73 65 74 75 70 22 20 20  igdat* "setup"  
0ce0: 20 20 20 22 6d 61 78 5f 63 6f 6e 63 75 72 72 65     "max_concurre
0cf0: 6e 74 5f 6a 6f 62 73 22 29 29 0a 09 20 28 6a 6f  nt_jobs")).. (jo
0d00: 62 2d 67 72 6f 75 70 2d 6c 69 6d 69 74 20 20 20  b-group-limit   
0d10: 20 20 20 20 20 20 28 63 6f 6e 66 69 67 2d 6c 6f        (config-lo
0d20: 6f 6b 75 70 20 2a 63 6f 6e 66 69 67 64 61 74 2a  okup *configdat*
0d30: 20 22 6a 6f 62 67 72 6f 75 70 73 22 20 6a 6f 62   "jobgroups" job
0d40: 67 72 6f 75 70 29 29 29 0a 20 20 20 20 28 64 65  group))).    (de
0d50: 62 75 67 3a 70 72 69 6e 74 20 32 20 22 6d 61 78  bug:print 2 "max
0d60: 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73  -concurrent-jobs
0d70: 3a 20 22 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65  : " max-concurre
0d80: 6e 74 2d 6a 6f 62 73 20 22 2c 20 6e 75 6d 2d 72  nt-jobs ", num-r
0d90: 75 6e 6e 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75  unning: " num-ru
0da0: 6e 6e 69 6e 67 29 0a 20 20 20 20 28 69 66 20 28  nning).    (if (
0db0: 6e 6f 74 20 28 65 71 3f 20 30 20 2a 67 6c 6f 62  not (eq? 0 *glob
0dc0: 61 6c 65 78 69 74 73 74 61 74 75 73 2a 29 29 0a  alexitstatus*)).
0dd0: 09 23 66 0a 09 28 6c 65 74 20 28 28 63 61 6e 2d  .#f..(let ((can-
0de0: 6e 6f 74 2d 72 75 6e 2d 6d 6f 72 65 20 28 63 6f  not-run-more (co
0df0: 6e 64 0a 09 09 09 09 20 3b 3b 20 69 66 20 6d 61  nd..... ;; if ma
0e00: 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62  x-concurrent-job
0e10: 73 20 69 73 20 73 65 74 20 61 6e 64 20 74 68 65  s is set and the
0e20: 20 6e 75 6d 62 65 72 20 72 75 6e 6e 69 6e 67 20   number running 
0e30: 69 73 20 67 72 65 61 74 65 72 20 0a 09 09 09 09  is greater .....
0e40: 20 3b 3b 20 74 68 61 6e 20 69 74 20 74 68 61 6e   ;; than it than
0e50: 20 63 61 6e 6e 6f 74 20 72 75 6e 20 6d 6f 72 65   cannot run more
0e60: 20 6a 6f 62 73 0a 09 09 09 09 20 28 28 61 6e 64   jobs..... ((and
0e70: 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d   max-concurrent-
0e80: 6a 6f 62 73 0a 09 09 09 09 20 20 20 20 20 20 20  jobs.....       
0e90: 28 73 74 72 69 6e 67 2d 3e 6e 75 6d 62 65 72 20  (string->number 
0ea0: 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a  max-concurrent-j
0eb0: 6f 62 73 29 0a 09 09 09 09 20 20 20 20 20 20 20  obs).....       
0ec0: 28 3e 3d 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67 20  (>= num-running 
0ed0: 28 73 74 72 69 6e 67 2d 3e 6e 75 6d 62 65 72 20  (string->number 
0ee0: 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a  max-concurrent-j
0ef0: 6f 62 73 29 29 29 0a 09 09 09 09 20 20 28 64 65  obs))).....  (de
0f00: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52  bug:print 0 "WAR
0f10: 4e 49 4e 47 3a 20 4d 61 78 20 72 75 6e 6e 69 6e  NING: Max runnin
0f20: 67 20 6a 6f 62 73 20 65 78 63 65 65 64 65 64 2c  g jobs exceeded,
0f30: 20 63 75 72 72 65 6e 74 20 6e 75 6d 62 65 72 20   current number 
0f40: 72 75 6e 6e 69 6e 67 3a 20 22 20 6e 75 6d 2d 72  running: " num-r
0f50: 75 6e 6e 69 6e 67 20 0a 09 09 09 09 09 20 20 20  unning ......   
0f60: 20 20 20 20 22 2c 20 6d 61 78 5f 63 6f 6e 63 75      ", max_concu
0f70: 72 72 65 6e 74 5f 6a 6f 62 73 3a 20 22 20 6d 61  rrent_jobs: " ma
0f80: 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62  x-concurrent-job
0f90: 73 29 0a 09 09 09 09 20 20 23 74 29 0a 09 09 09  s).....  #t)....
0fa0: 09 20 3b 3b 20 69 66 20 6a 6f 62 2d 67 72 6f 75  . ;; if job-grou
0fb0: 70 2d 6c 69 6d 69 74 20 69 73 20 73 65 74 20 61  p-limit is set a
0fc0: 6e 64 20 6e 75 6d 62 65 72 20 6f 66 20 6a 6f 62  nd number of job
0fd0: 73 20 69 6e 20 74 68 65 20 67 72 6f 75 70 20 69  s in the group i
0fe0: 73 20 67 72 65 61 74 65 72 0a 09 09 09 09 20 3b  s greater..... ;
0ff0: 3b 20 74 68 61 6e 20 74 68 65 20 6c 69 6d 69 74  ; than the limit
1000: 20 74 68 65 6e 20 63 61 6e 6e 6f 74 20 72 75 6e   then cannot run
1010: 20 6d 6f 72 65 20 6a 6f 62 73 20 6f 66 20 74 68   more jobs of th
1020: 69 73 20 6b 69 6e 64 0a 09 09 09 09 20 28 28 61  is kind..... ((a
1030: 6e 64 20 6a 6f 62 2d 67 72 6f 75 70 2d 6c 69 6d  nd job-group-lim
1040: 69 74 0a 09 09 09 09 20 20 20 20 20 20 20 28 3e  it.....       (>
1050: 3d 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67 2d 69 6e  = num-running-in
1060: 2d 6a 6f 62 67 72 6f 75 70 20 6a 6f 62 2d 67 72  -jobgroup job-gr
1070: 6f 75 70 2d 6c 69 6d 69 74 29 29 0a 09 09 09 09  oup-limit)).....
1080: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31    (debug:print 1
1090: 20 22 57 41 52 4e 49 4e 47 3a 20 6e 75 6d 62 65   "WARNING: numbe
10a0: 72 20 6f 66 20 6a 6f 62 73 20 22 20 6e 75 6d 2d  r of jobs " num-
10b0: 72 75 6e 6e 69 6e 67 2d 69 6e 2d 6a 6f 62 67 72  running-in-jobgr
10c0: 6f 75 70 20 0a 09 09 09 09 09 20 20 20 20 20 20  oup ......      
10d0: 20 22 20 69 6e 20 22 20 6a 6f 62 67 72 6f 75 70   " in " jobgroup
10e0: 20 22 20 65 78 63 65 65 64 65 64 2c 20 77 69 6c   " exceeded, wil
10f0: 6c 20 6e 6f 74 20 72 75 6e 20 22 20 28 74 65 73  l not run " (tes
1100: 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74  ts:testqueue-get
1110: 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 2d 72  -testname test-r
1120: 65 63 6f 72 64 29 29 0a 09 09 09 09 20 20 23 74  ecord)).....  #t
1130: 29 0a 09 09 09 09 20 28 65 6c 73 65 20 23 66 29  )..... (else #f)
1140: 29 29 29 0a 09 20 20 28 6e 6f 74 20 63 61 6e 2d  )))..  (not can-
1150: 6e 6f 74 2d 72 75 6e 2d 6d 6f 72 65 29 29 29 29  not-run-more))))
1160: 29 0a 0a 3b 3b 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 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 4e  ===========.;; N
11b0: 65 77 20 6d 65 74 68 6f 64 6f 6c 6f 67 79 2e 20  ew methodology. 
11c0: 54 68 65 73 65 20 72 6f 75 74 69 6e 65 73 20 77  These routines w
11d0: 69 6c 6c 20 72 65 70 6c 61 63 65 20 74 68 65 20  ill replace the 
11e0: 61 62 6f 76 65 20 69 6e 20 74 69 6d 65 2e 20 46  above in time. F
11f0: 6f 72 0a 3b 3b 20 6e 6f 77 20 74 68 65 20 63 6f  or.;; now the co
1200: 64 65 20 69 73 20 64 75 70 6c 69 63 61 74 65 64  de is duplicated
1210: 2e 20 54 68 69 73 20 73 74 75 66 66 20 69 73 20  . This stuff is 
1220: 69 6e 69 74 69 61 6c 6c 79 20 75 73 65 64 20 69  initially used i
1230: 6e 20 74 68 65 20 6d 6f 6e 69 74 6f 72 0a 3b 3b  n the monitor.;;
1240: 20 62 61 73 65 64 20 63 6f 64 65 2e 0a 3b 3b 3d   based code..;;=
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 3d 3d 3d 3d 3d  ================
1290: 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 72 65 67 69 73 74  =====..;; regist
12a0: 65 72 20 61 20 74 65 73 74 20 72 75 6e 20 77 69  er a test run wi
12b0: 74 68 20 74 68 65 20 64 62 0a 28 64 65 66 69 6e  th the db.(defin
12c0: 65 20 28 72 75 6e 73 3a 72 65 67 69 73 74 65 72  e (runs:register
12d0: 2d 72 75 6e 20 64 62 20 6b 65 79 73 20 6b 65 79  -run db keys key
12e0: 76 61 6c 6c 73 74 20 72 75 6e 6e 61 6d 65 20 73  vallst runname s
12f0: 74 61 74 65 20 73 74 61 74 75 73 20 75 73 65 72  tate status user
1300: 29 0a 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ).  (debug:print
1310: 20 33 20 22 72 75 6e 73 3a 72 65 67 69 73 74 65   3 "runs:registe
1320: 72 2d 72 75 6e 2c 20 6b 65 79 73 3a 20 22 20 6b  r-run, keys: " k
1330: 65 79 73 20 22 20 6b 65 79 76 61 6c 6c 73 74 3a  eys " keyvallst:
1340: 20 22 20 6b 65 79 76 61 6c 6c 73 74 20 22 20 72   " keyvallst " r
1350: 75 6e 6e 61 6d 65 3a 20 22 20 72 75 6e 6e 61 6d  unname: " runnam
1360: 65 20 22 20 73 74 61 74 65 3a 20 22 20 73 74 61  e " state: " sta
1370: 74 65 20 22 20 73 74 61 74 75 73 3a 20 22 20 73  te " status: " s
1380: 74 61 74 75 73 20 22 20 75 73 65 72 3a 20 22 20  tatus " user: " 
1390: 75 73 65 72 29 0a 20 20 28 6c 65 74 2a 20 28 28  user).  (let* ((
13a0: 6b 65 79 73 74 72 20 20 20 20 28 6b 65 79 73 2d  keystr    (keys-
13b0: 3e 6b 65 79 73 74 72 20 6b 65 79 73 29 29 0a 09  >keystr keys))..
13c0: 20 28 63 6f 6d 6d 61 20 20 20 20 20 28 69 66 20   (comma     (if 
13d0: 28 3e 20 28 6c 65 6e 67 74 68 20 6b 65 79 73 29  (> (length keys)
13e0: 20 30 29 20 22 2c 22 20 22 22 29 29 0a 09 20 28   0) "," "")).. (
13f0: 61 6e 64 73 74 72 20 20 20 20 28 69 66 20 28 3e  andstr    (if (>
1400: 20 28 6c 65 6e 67 74 68 20 6b 65 79 73 29 20 30   (length keys) 0
1410: 29 20 22 20 41 4e 44 20 22 20 22 22 29 29 0a 09  ) " AND " ""))..
1420: 20 28 76 61 6c 73 6c 6f 74 73 20 20 28 6b 65 79   (valslots  (key
1430: 73 2d 3e 76 61 6c 73 6c 6f 74 73 20 6b 65 79 73  s->valslots keys
1440: 29 29 20 3b 3b 20 3f 2c 3f 2c 3f 20 2e 2e 2e 0a  )) ;; ?,?,? ....
1450: 09 20 28 6b 65 79 76 61 6c 73 20 20 20 28 6d 61  . (keyvals   (ma
1460: 70 20 63 61 64 72 20 6b 65 79 76 61 6c 6c 73 74  p cadr keyvallst
1470: 29 29 0a 09 20 28 61 6c 6c 76 61 6c 73 20 20 20  )).. (allvals   
1480: 28 61 70 70 65 6e 64 20 28 6c 69 73 74 20 72 75  (append (list ru
1490: 6e 6e 61 6d 65 20 73 74 61 74 65 20 73 74 61 74  nname state stat
14a0: 75 73 20 75 73 65 72 29 20 6b 65 79 76 61 6c 73  us user) keyvals
14b0: 29 29 0a 09 20 28 71 72 79 76 61 6c 73 20 20 20  )).. (qryvals   
14c0: 28 61 70 70 65 6e 64 20 28 6c 69 73 74 20 72 75  (append (list ru
14d0: 6e 6e 61 6d 65 29 20 6b 65 79 76 61 6c 73 29 29  nname) keyvals))
14e0: 0a 09 20 28 6b 65 79 3d 3f 73 74 72 20 20 28 73  .. (key=?str  (s
14f0: 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73  tring-interspers
1500: 65 20 28 6d 61 70 20 28 6c 61 6d 62 64 61 20 28  e (map (lambda (
1510: 6b 29 28 63 6f 6e 63 20 28 6b 65 79 3a 67 65 74  k)(conc (key:get
1520: 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 29 20 22 3d  -fieldname k) "=
1530: 3f 22 29 29 20 6b 65 79 73 29 20 22 20 41 4e 44  ?")) keys) " AND
1540: 20 22 29 29 29 0a 20 20 20 20 28 64 65 62 75 67   "))).    (debug
1550: 3a 70 72 69 6e 74 20 33 20 22 6b 65 79 73 3a 20  :print 3 "keys: 
1560: 22 20 6b 65 79 73 20 22 20 61 6c 6c 76 61 6c 73  " keys " allvals
1570: 3a 20 22 20 61 6c 6c 76 61 6c 73 20 22 20 6b 65  : " allvals " ke
1580: 79 76 61 6c 73 3a 20 22 20 6b 65 79 76 61 6c 73  yvals: " keyvals
1590: 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72 69  ).    (debug:pri
15a0: 6e 74 20 32 20 22 4e 4f 54 45 3a 20 75 73 69 6e  nt 2 "NOTE: usin
15b0: 67 20 74 61 72 67 65 74 20 22 20 28 73 74 72 69  g target " (stri
15c0: 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 6b  ng-intersperse k
15d0: 65 79 76 61 6c 73 20 22 2f 22 29 20 22 20 66 6f  eyvals "/") " fo
15e0: 72 20 74 68 69 73 20 72 75 6e 22 29 0a 20 20 20  r this run").   
15f0: 20 28 69 66 20 28 61 6e 64 20 72 75 6e 6e 61 6d   (if (and runnam
1600: 65 20 28 6e 75 6c 6c 3f 20 28 66 69 6c 74 65 72  e (null? (filter
1610: 20 28 6c 61 6d 62 64 61 20 28 78 29 28 6e 6f 74   (lambda (x)(not
1620: 20 78 29 29 20 6b 65 79 76 61 6c 73 29 29 29 20   x)) keyvals))) 
1630: 3b 3b 20 74 68 65 72 65 20 6d 75 73 74 20 62 65  ;; there must be
1640: 20 61 20 62 65 74 74 65 72 20 77 61 79 20 74 6f   a better way to
1650: 20 22 61 70 70 6c 79 20 61 6e 64 22 0a 09 28 6c   "apply and"..(l
1660: 65 74 20 28 28 72 65 73 20 23 66 29 29 0a 09 20  et ((res #f)).. 
1670: 20 28 61 70 70 6c 79 20 73 71 6c 69 74 65 33 3a   (apply sqlite3:
1680: 65 78 65 63 75 74 65 20 64 62 20 28 63 6f 6e 63  execute db (conc
1690: 20 22 49 4e 53 45 52 54 20 4f 52 20 49 47 4e 4f   "INSERT OR IGNO
16a0: 52 45 20 49 4e 54 4f 20 72 75 6e 73 20 28 72 75  RE INTO runs (ru
16b0: 6e 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 61 74  nname,state,stat
16c0: 75 73 2c 6f 77 6e 65 72 2c 65 76 65 6e 74 5f 74  us,owner,event_t
16d0: 69 6d 65 22 20 63 6f 6d 6d 61 20 6b 65 79 73 74  ime" comma keyst
16e0: 72 20 22 29 20 56 41 4c 55 45 53 20 28 3f 2c 3f  r ") VALUES (?,?
16f0: 2c 3f 2c 3f 2c 73 74 72 66 74 69 6d 65 28 27 25  ,?,?,strftime('%
1700: 73 27 2c 27 6e 6f 77 27 29 22 20 63 6f 6d 6d 61  s','now')" comma
1710: 20 76 61 6c 73 6c 6f 74 73 20 22 29 3b 22 29 0a   valslots ");").
1720: 09 09 20 61 6c 6c 76 61 6c 73 29 0a 09 20 20 28  .. allvals)..  (
1730: 61 70 70 6c 79 20 73 71 6c 69 74 65 33 3a 66 6f  apply sqlite3:fo
1740: 72 2d 65 61 63 68 2d 72 6f 77 20 0a 09 20 20 20  r-each-row ..   
1750: 28 6c 61 6d 62 64 61 20 28 69 64 29 0a 09 20 20  (lambda (id)..  
1760: 20 20 20 28 73 65 74 21 20 72 65 73 20 69 64 29     (set! res id)
1770: 29 0a 09 20 20 20 64 62 0a 09 20 20 20 28 6c 65  )..   db..   (le
1780: 74 20 28 28 71 72 79 20 28 63 6f 6e 63 20 22 53  t ((qry (conc "S
1790: 45 4c 45 43 54 20 69 64 20 46 52 4f 4d 20 72 75  ELECT id FROM ru
17a0: 6e 73 20 57 48 45 52 45 20 28 72 75 6e 6e 61 6d  ns WHERE (runnam
17b0: 65 3d 3f 20 22 20 61 6e 64 73 74 72 20 6b 65 79  e=? " andstr key
17c0: 3d 3f 73 74 72 20 22 29 3b 22 29 29 29 0a 09 20  =?str ");"))).. 
17d0: 20 20 20 20 3b 28 64 65 62 75 67 3a 70 72 69 6e      ;(debug:prin
17e0: 74 20 34 20 22 71 72 79 3a 20 22 20 71 72 79 29  t 4 "qry: " qry)
17f0: 20 0a 09 20 20 20 20 20 71 72 79 29 0a 09 20 20   ..     qry)..  
1800: 20 71 72 79 76 61 6c 73 29 0a 09 20 20 28 73 71   qryvals)..  (sq
1810: 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 64 62  lite3:execute db
1820: 20 22 55 50 44 41 54 45 20 72 75 6e 73 20 53 45   "UPDATE runs SE
1830: 54 20 73 74 61 74 65 3d 3f 2c 73 74 61 74 75 73  T state=?,status
1840: 3d 3f 20 57 48 45 52 45 20 69 64 3d 3f 3b 22 20  =? WHERE id=?;" 
1850: 73 74 61 74 65 20 73 74 61 74 75 73 20 72 65 73  state status res
1860: 29 0a 09 20 20 72 65 73 29 20 0a 09 28 62 65 67  )..  res) ..(beg
1870: 69 6e 0a 09 20 20 28 64 65 62 75 67 3a 70 72 69  in..  (debug:pri
1880: 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 43 61 6c  nt 0 "ERROR: Cal
1890: 6c 65 64 20 77 69 74 68 6f 75 74 20 61 6c 6c 20  led without all 
18a0: 6e 65 63 65 73 73 61 72 79 20 6b 65 79 73 22 29  necessary keys")
18b0: 0a 09 20 20 23 66 29 29 29 29 0a 0a 3b 3b 20 54  ..  #f))))..;; T
18c0: 68 69 73 20 69 73 20 61 20 64 75 70 6c 69 63 61  his is a duplica
18d0: 74 65 20 6f 66 20 72 75 6e 2d 74 65 73 74 73 20  te of run-tests 
18e0: 28 77 68 69 63 68 20 68 61 73 20 62 65 65 6e 20  (which has been 
18f0: 64 65 70 72 65 63 61 74 65 64 29 2e 20 55 73 65  deprecated). Use
1900: 20 74 68 69 73 20 6f 6e 65 20 69 6e 73 74 65 61   this one instea
1910: 64 20 6f 66 20 72 75 6e 20 74 65 73 74 73 2e 0a  d of run tests..
1920: 3b 3b 20 6b 65 79 76 61 6c 73 0a 28 64 65 66 69  ;; keyvals.(defi
1930: 6e 65 20 28 72 75 6e 73 3a 72 75 6e 2d 74 65 73  ne (runs:run-tes
1940: 74 73 20 64 62 20 74 61 72 67 65 74 20 72 75 6e  ts db target run
1950: 6e 61 6d 65 20 74 65 73 74 2d 70 61 74 74 73 20  name test-patts 
1960: 69 74 65 6d 2d 70 61 74 74 73 20 75 73 65 72 20  item-patts user 
1970: 66 6c 61 67 73 29 0a 20 20 28 6c 65 74 2a 20 28  flags).  (let* (
1980: 28 6b 65 79 73 20 20 20 20 20 20 20 20 28 72 64  (keys        (rd
1990: 62 3a 67 65 74 2d 6b 65 79 73 20 64 62 29 29 0a  b:get-keys db)).
19a0: 09 20 28 6b 65 79 76 61 6c 6c 73 74 20 20 20 28  . (keyvallst   (
19b0: 6b 65 79 73 3a 74 61 72 67 65 74 2d 3e 6b 65 79  keys:target->key
19c0: 76 61 6c 20 6b 65 79 73 20 74 61 72 67 65 74 29  val keys target)
19d0: 29 0a 09 20 28 72 75 6e 2d 69 64 20 20 20 20 20  ).. (run-id     
19e0: 20 28 72 75 6e 73 3a 72 65 67 69 73 74 65 72 2d   (runs:register-
19f0: 72 75 6e 20 64 62 20 6b 65 79 73 20 6b 65 79 76  run db keys keyv
1a00: 61 6c 6c 73 74 20 72 75 6e 6e 61 6d 65 20 22 6e  allst runname "n
1a10: 65 77 22 20 22 6e 2f 61 22 20 75 73 65 72 29 29  ew" "n/a" user))
1a20: 20 20 3b 3b 20 20 74 65 73 74 2d 6e 61 6d 65 29    ;;  test-name)
1a30: 29 29 0a 09 20 28 64 65 66 65 72 72 65 64 20 20  )).. (deferred  
1a40: 20 20 27 28 29 29 20 3b 3b 20 64 65 6c 61 79 20    '()) ;; delay 
1a50: 72 75 6e 6e 69 6e 67 20 74 68 65 73 65 20 73 69  running these si
1a60: 6e 63 65 20 74 68 65 79 20 68 61 76 65 20 61 20  nce they have a 
1a70: 77 61 69 74 6f 6e 20 63 6c 61 75 73 65 0a 09 20  waiton clause.. 
1a80: 3b 3b 20 6b 65 65 70 67 6f 69 6e 67 20 69 73 20  ;; keepgoing is 
1a90: 74 68 65 20 64 65 66 61 63 74 6f 20 6d 6f 64 61  the defacto moda
1aa0: 6c 69 74 79 20 6e 6f 77 2c 20 77 69 6c 6c 20 61  lity now, will a
1ab0: 64 64 20 68 69 74 2d 6e 2d 72 75 6e 20 61 20 62  dd hit-n-run a b
1ac0: 69 74 20 6c 61 74 65 72 0a 09 20 3b 3b 20 28 6b  it later.. ;; (k
1ad0: 65 65 70 67 6f 69 6e 67 20 20 20 28 68 61 73 68  eepgoing   (hash
1ae0: 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75  -table-ref/defau
1af0: 6c 74 20 66 6c 61 67 73 20 22 2d 6b 65 65 70 67  lt flags "-keepg
1b00: 6f 69 6e 67 22 20 23 66 29 29 0a 09 20 28 74 65  oing" #f)).. (te
1b10: 73 74 2d 6e 61 6d 65 73 20 20 27 28 29 29 0a 09  st-names  '())..
1b20: 20 28 72 75 6e 63 6f 6e 66 69 67 66 20 20 20 28   (runconfigf   (
1b30: 63 6f 6e 63 20 20 2a 74 6f 70 70 61 74 68 2a 20  conc  *toppath* 
1b40: 22 2f 72 75 6e 63 6f 6e 66 69 67 73 2e 63 6f 6e  "/runconfigs.con
1b50: 66 69 67 22 29 29 0a 09 20 28 72 65 71 75 69 72  fig")).. (requir
1b60: 65 64 2d 74 65 73 74 73 20 27 28 29 29 0a 09 20  ed-tests '()).. 
1b70: 28 74 65 73 74 2d 72 65 63 6f 72 64 73 20 28 6d  (test-records (m
1b80: 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29  ake-hash-table))
1b90: 29 0a 0a 20 20 20 20 28 73 65 74 2d 6d 65 67 61  )..    (set-mega
1ba0: 74 65 73 74 2d 65 6e 76 2d 76 61 72 73 20 64 62  test-env-vars db
1bb0: 20 72 75 6e 2d 69 64 29 20 3b 3b 20 74 68 65 73   run-id) ;; thes
1bc0: 65 20 6d 61 79 20 62 65 20 6e 65 65 64 65 64 20  e may be needed 
1bd0: 62 79 20 74 68 65 20 6c 61 75 6e 63 68 69 6e 67  by the launching
1be0: 20 70 72 6f 63 65 73 73 0a 0a 20 20 20 20 28 69   process..    (i
1bf0: 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20  f (file-exists? 
1c00: 72 75 6e 63 6f 6e 66 69 67 66 29 0a 09 28 73 65  runconfigf)..(se
1c10: 74 75 70 2d 65 6e 76 2d 64 65 66 61 75 6c 74 73  tup-env-defaults
1c20: 20 64 62 20 72 75 6e 63 6f 6e 66 69 67 66 20 72   db runconfigf r
1c30: 75 6e 2d 69 64 20 2a 61 6c 72 65 61 64 79 2d 73  un-id *already-s
1c40: 65 65 6e 2d 72 75 6e 63 6f 6e 66 69 67 2d 69 6e  een-runconfig-in
1c50: 66 6f 2a 20 22 70 72 65 2d 6c 61 75 6e 63 68 2d  fo* "pre-launch-
1c60: 65 6e 76 2d 76 61 72 73 22 29 0a 09 28 64 65 62  env-vars")..(deb
1c70: 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e  ug:print 0 "WARN
1c80: 49 4e 47 3a 20 59 6f 75 20 64 6f 20 6e 6f 74 20  ING: You do not 
1c90: 68 61 76 65 20 61 20 72 75 6e 20 63 6f 6e 66 69  have a run confi
1ca0: 67 20 66 69 6c 65 3a 20 22 20 72 75 6e 63 6f 6e  g file: " runcon
1cb0: 66 69 67 66 29 29 0a 20 20 20 20 0a 20 20 20 20  figf)).    .    
1cc0: 3b 3b 20 6c 6f 6f 6b 20 75 70 20 61 6c 6c 20 74  ;; look up all t
1cd0: 65 73 74 73 20 6d 61 74 63 68 69 6e 67 20 74 68  ests matching th
1ce0: 65 20 63 6f 6d 6d 61 20 73 65 70 61 72 61 74 65  e comma separate
1cf0: 64 20 6c 69 73 74 20 6f 66 20 67 6c 6f 62 73 20  d list of globs 
1d00: 69 6e 0a 20 20 20 20 3b 3b 20 74 65 73 74 2d 70  in.    ;; test-p
1d10: 61 74 74 73 20 28 75 73 69 6e 67 20 25 20 61 73  atts (using % as
1d20: 20 77 69 6c 64 63 61 72 64 29 0a 20 20 20 20 28   wildcard).    (
1d30: 66 6f 72 2d 65 61 63 68 20 0a 20 20 20 20 20 28  for-each .     (
1d40: 6c 61 6d 62 64 61 20 28 70 61 74 74 29 0a 20 20  lambda (patt).  
1d50: 20 20 20 20 20 28 6c 65 74 20 28 28 74 65 73 74       (let ((test
1d60: 73 20 28 67 6c 6f 62 20 28 63 6f 6e 63 20 2a 74  s (glob (conc *t
1d70: 6f 70 70 61 74 68 2a 20 22 2f 74 65 73 74 73 2f  oppath* "/tests/
1d80: 22 20 28 73 74 72 69 6e 67 2d 74 72 61 6e 73 6c  " (string-transl
1d90: 61 74 65 20 70 61 74 74 20 22 25 22 20 22 2a 22  ate patt "%" "*"
1da0: 29 29 29 29 29 0a 09 20 28 73 65 74 21 20 74 65  ))))).. (set! te
1db0: 73 74 73 20 28 66 69 6c 74 65 72 20 28 6c 61 6d  sts (filter (lam
1dc0: 62 64 61 20 28 74 65 73 74 29 28 66 69 6c 65 2d  bda (test)(file-
1dd0: 65 78 69 73 74 73 3f 20 28 63 6f 6e 63 20 74 65  exists? (conc te
1de0: 73 74 20 22 2f 74 65 73 74 63 6f 6e 66 69 67 22  st "/testconfig"
1df0: 29 29 29 20 74 65 73 74 73 29 29 0a 09 20 28 73  ))) tests)).. (s
1e00: 65 74 21 20 74 65 73 74 2d 6e 61 6d 65 73 20 28  et! test-names (
1e10: 61 70 70 65 6e 64 20 74 65 73 74 2d 6e 61 6d 65  append test-name
1e20: 73 20 0a 09 09 09 09 20 20 28 6d 61 70 20 28 6c  s .....  (map (l
1e30: 61 6d 62 64 61 20 28 74 65 73 74 70 29 0a 09 09  ambda (testp)...
1e40: 09 09 09 20 28 6c 61 73 74 20 28 73 74 72 69 6e  ... (last (strin
1e50: 67 2d 73 70 6c 69 74 20 74 65 73 74 70 20 22 2f  g-split testp "/
1e60: 22 29 29 29 0a 09 09 09 09 20 20 20 20 20 20 20  "))).....       
1e70: 74 65 73 74 73 29 29 29 29 29 0a 20 20 20 20 20  tests))))).     
1e80: 28 69 66 20 74 65 73 74 2d 70 61 74 74 73 20 28  (if test-patts (
1e90: 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 74 65 73  string-split tes
1ea0: 74 2d 70 61 74 74 73 20 22 2c 22 29 28 6c 69 73  t-patts ",")(lis
1eb0: 74 20 22 25 22 29 29 29 0a 0a 20 20 20 20 20 3b  t "%")))..     ;
1ec0: 3b 20 6e 6f 77 20 72 65 6d 6f 76 65 20 64 75 70  ; now remove dup
1ed0: 6c 69 63 61 74 65 73 0a 20 20 20 20 28 73 65 74  licates.    (set
1ee0: 21 20 74 65 73 74 2d 6e 61 6d 65 73 20 28 64 65  ! test-names (de
1ef0: 6c 65 74 65 2d 64 75 70 6c 69 63 61 74 65 73 20  lete-duplicates 
1f00: 74 65 73 74 2d 6e 61 6d 65 73 29 29 0a 0a 20 20  test-names))..  
1f10: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30    (debug:print 0
1f20: 20 22 49 4e 46 4f 3a 20 74 65 73 74 20 6e 61 6d   "INFO: test nam
1f30: 65 73 20 22 20 74 65 73 74 2d 6e 61 6d 65 73 29  es " test-names)
1f40: 0a 0a 20 20 20 20 3b 3b 20 6f 6e 20 74 68 65 20  ..    ;; on the 
1f50: 66 69 72 73 74 20 70 61 73 73 20 6f 72 20 63 61  first pass or ca
1f60: 6c 6c 20 74 6f 20 72 75 6e 2d 74 65 73 74 73 20  ll to run-tests 
1f70: 73 65 74 20 46 41 49 4c 53 20 74 6f 20 4e 4f 54  set FAILS to NOT
1f80: 5f 53 54 41 52 54 45 44 20 69 66 0a 20 20 20 20  _STARTED if.    
1f90: 3b 3b 20 2d 6b 65 65 70 67 6f 69 6e 67 20 69 73  ;; -keepgoing is
1fa0: 20 73 70 65 63 69 66 69 65 64 0a 20 20 20 20 28   specified.    (
1fb0: 69 66 20 28 65 71 3f 20 2a 70 61 73 73 6e 75 6d  if (eq? *passnum
1fc0: 2a 20 30 29 0a 09 28 62 65 67 69 6e 0a 09 20 20  * 0)..(begin..  
1fd0: 3b 3b 20 68 61 76 65 20 74 6f 20 64 65 6c 65 74  ;; have to delet
1fe0: 65 20 74 65 73 74 20 72 65 63 6f 72 64 73 20 77  e test records w
1ff0: 68 65 72 65 20 4e 4f 54 5f 53 54 41 52 54 45 44  here NOT_STARTED
2000: 20 73 69 6e 63 65 20 74 68 65 79 20 63 61 6e 20   since they can 
2010: 63 61 75 73 65 20 2d 6b 65 65 70 67 6f 69 6e 67  cause -keepgoing
2020: 20 74 6f 20 0a 09 20 20 3b 3b 20 67 65 74 20 73   to ..  ;; get s
2030: 74 75 63 6b 20 64 75 65 20 74 6f 20 62 65 63 6f  tuck due to beco
2040: 6d 69 6e 67 20 69 6e 61 63 63 65 73 73 69 62 6c  ming inaccessibl
2050: 65 20 66 72 6f 6d 20 61 20 66 61 69 6c 65 64 20  e from a failed 
2060: 74 65 73 74 2e 20 49 2e 65 2e 20 69 66 20 74 65  test. I.e. if te
2070: 73 74 20 42 20 64 65 70 65 6e 64 73 20 0a 09 20  st B depends .. 
2080: 20 3b 3b 20 6f 6e 20 74 65 73 74 20 41 20 62 75   ;; on test A bu
2090: 74 20 74 65 73 74 20 42 20 72 65 61 63 68 65 64  t test B reached
20a0: 20 74 68 65 20 70 6f 69 6e 74 20 6f 6e 20 62 65   the point on be
20b0: 69 6e 67 20 72 65 67 69 73 74 65 72 65 64 20 61  ing registered a
20c0: 73 20 4e 4f 54 5f 53 54 41 52 54 45 44 20 61 6e  s NOT_STARTED an
20d0: 64 20 74 65 73 74 0a 09 20 20 3b 3b 20 41 20 66  d test..  ;; A f
20e0: 61 69 6c 65 64 20 66 6f 72 20 73 6f 6d 65 20 72  ailed for some r
20f0: 65 61 73 6f 6e 20 74 68 65 6e 20 6f 6e 20 72 65  eason then on re
2100: 2d 72 75 6e 20 75 73 69 6e 67 20 2d 6b 65 65 70  -run using -keep
2110: 67 6f 69 6e 67 20 74 68 65 20 72 75 6e 20 63 61  going the run ca
2120: 6e 20 6e 65 76 65 72 20 63 6f 6d 70 6c 65 74 65  n never complete
2130: 2e 0a 09 20 20 28 64 62 3a 64 65 6c 65 74 65 2d  ...  (db:delete-
2140: 74 65 73 74 73 2d 69 6e 2d 73 74 61 74 65 20 64  tests-in-state d
2150: 62 20 72 75 6e 2d 69 64 20 22 4e 4f 54 5f 53 54  b run-id "NOT_ST
2160: 41 52 54 45 44 22 29 0a 09 20 20 28 72 64 62 3a  ARTED")..  (rdb:
2170: 73 65 74 2d 74 65 73 74 73 2d 73 74 61 74 65 2d  set-tests-state-
2180: 73 74 61 74 75 73 20 64 62 20 72 75 6e 2d 69 64  status db run-id
2190: 20 74 65 73 74 2d 6e 61 6d 65 73 20 23 66 20 22   test-names #f "
21a0: 46 41 49 4c 22 20 22 4e 4f 54 5f 53 54 41 52 54  FAIL" "NOT_START
21b0: 45 44 22 20 22 46 41 49 4c 22 29 29 29 0a 0a 20  ED" "FAIL"))).. 
21c0: 20 20 20 3b 3b 20 6e 6f 77 20 61 64 64 20 6e 6f     ;; now add no
21d0: 6e 2d 64 69 72 65 63 74 6c 79 20 72 65 66 65 72  n-directly refer
21e0: 65 6e 63 65 64 20 64 65 70 65 6e 64 65 6e 63 69  enced dependenci
21f0: 65 73 20 28 69 2e 65 2e 20 77 61 69 74 6f 6e 29  es (i.e. waiton)
2200: 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28 6e  .    (if (not (n
2210: 75 6c 6c 3f 20 74 65 73 74 2d 6e 61 6d 65 73 29  ull? test-names)
2220: 29 0a 09 28 6c 65 74 20 6c 6f 6f 70 20 28 28 68  )..(let loop ((h
2230: 65 64 20 28 63 61 72 20 74 65 73 74 2d 6e 61 6d  ed (car test-nam
2240: 65 73 29 29 0a 09 09 20 20 20 28 74 61 6c 20 28  es))...   (tal (
2250: 63 64 72 20 74 65 73 74 2d 6e 61 6d 65 73 29 29  cdr test-names))
2260: 29 20 20 20 20 20 20 20 20 20 3b 3b 20 27 72 65  )         ;; 're
2270: 74 75 72 6e 2d 70 72 6f 63 73 20 74 65 6c 6c 73  turn-procs tells
2280: 20 74 68 65 20 63 6f 6e 66 69 67 20 72 65 61 64   the config read
2290: 65 72 20 74 6f 20 70 72 65 70 20 72 75 6e 6e 69  er to prep runni
22a0: 6e 67 20 73 79 73 74 65 6d 20 62 75 74 20 72 65  ng system but re
22b0: 74 75 72 6e 20 61 20 70 72 6f 63 0a 09 20 20 28  turn a proc..  (
22c0: 6c 65 74 2a 20 28 28 63 6f 6e 66 69 67 20 20 28  let* ((config  (
22d0: 74 65 73 74 3a 67 65 74 2d 74 65 73 74 63 6f 6e  test:get-testcon
22e0: 66 69 67 20 68 65 64 20 27 72 65 74 75 72 6e 2d  fig hed 'return-
22f0: 70 72 6f 63 73 29 29 0a 09 09 20 28 77 61 69 74  procs))... (wait
2300: 6f 6e 73 20 28 73 74 72 69 6e 67 2d 73 70 6c 69  ons (string-spli
2310: 74 20 28 6c 65 74 20 28 28 77 20 28 63 6f 6e 66  t (let ((w (conf
2320: 69 67 2d 6c 6f 6f 6b 75 70 20 63 6f 6e 66 69 67  ig-lookup config
2330: 20 22 72 65 71 75 69 72 65 6d 65 6e 74 73 22 20   "requirements" 
2340: 22 77 61 69 74 6f 6e 22 29 29 29 0a 09 09 09 09  "waiton"))).....
2350: 09 20 20 28 69 66 20 77 20 77 20 22 22 29 29 29  .  (if w w "")))
2360: 29 29 0a 09 20 20 20 20 3b 3b 20 28 69 74 65 6d  ))..    ;; (item
2370: 73 20 20 20 28 69 74 65 6d 73 3a 67 65 74 2d 69  s   (items:get-i
2380: 74 65 6d 73 2d 66 72 6f 6d 2d 63 6f 6e 66 69 67  tems-from-config
2390: 20 63 6f 6e 66 69 67 29 29 29 0a 09 20 20 20 20   config)))..    
23a0: 28 69 66 20 28 6e 6f 74 20 28 68 61 73 68 2d 74  (if (not (hash-t
23b0: 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74  able-ref/default
23c0: 20 74 65 73 74 2d 72 65 63 6f 72 64 73 20 68 65   test-records he
23d0: 64 20 23 66 29 29 0a 09 09 28 68 61 73 68 2d 74  d #f))...(hash-t
23e0: 61 62 6c 65 2d 73 65 74 21 20 74 65 73 74 2d 72  able-set! test-r
23f0: 65 63 6f 72 64 73 0a 09 09 09 09 20 68 65 64 20  ecords..... hed 
2400: 28 76 65 63 74 6f 72 20 68 65 64 20 20 20 20 20  (vector hed     
2410: 3b 3b 20 30 0a 09 09 09 09 09 20 20 20 20 20 63  ;; 0......     c
2420: 6f 6e 66 69 67 20 20 3b 3b 20 31 0a 09 09 09 09  onfig  ;; 1.....
2430: 09 20 20 20 20 20 77 61 69 74 6f 6e 73 20 3b 3b  .     waitons ;;
2440: 20 32 0a 09 09 09 09 09 20 20 20 20 20 28 63 6f   2......     (co
2450: 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 63 6f 6e 66  nfig-lookup conf
2460: 69 67 20 22 72 65 71 75 69 72 65 6d 65 6e 74 73  ig "requirements
2470: 22 20 22 70 72 69 6f 72 69 74 79 22 29 20 20 20  " "priority")   
2480: 20 20 3b 3b 20 70 72 69 6f 72 69 74 79 20 33 0a    ;; priority 3.
2490: 09 09 09 09 09 20 20 20 20 20 28 6c 65 74 20 28  .....     (let (
24a0: 28 69 74 65 6d 73 20 20 20 20 20 20 28 68 61 73  (items      (has
24b0: 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61  h-table-ref/defa
24c0: 75 6c 74 20 63 6f 6e 66 69 67 20 22 69 74 65 6d  ult config "item
24d0: 73 22 20 23 66 29 29 20 3b 3b 20 69 74 65 6d 73  s" #f)) ;; items
24e0: 20 34 0a 09 09 09 09 09 09 20 20 20 28 69 74 65   4.......   (ite
24f0: 6d 73 74 61 62 6c 65 20 28 68 61 73 68 2d 74 61  mstable (hash-ta
2500: 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20  ble-ref/default 
2510: 63 6f 6e 66 69 67 20 22 69 74 65 6d 73 74 61 62  config "itemstab
2520: 6c 65 22 20 23 66 29 29 29 20 0a 09 09 09 09 09  le" #f))) ......
2530: 20 20 20 20 20 20 20 3b 3b 20 69 66 20 65 69 74         ;; if eit
2540: 68 65 72 20 69 74 65 6d 73 20 6f 72 20 69 74 65  her items or ite
2550: 6d 73 20 74 61 62 6c 65 20 69 73 20 61 20 70 72  ms table is a pr
2560: 6f 63 20 72 65 74 75 72 6e 20 69 74 20 73 6f 20  oc return it so 
2570: 74 65 73 74 20 72 75 6e 6e 69 6e 67 0a 09 09 09  test running....
2580: 09 09 20 20 20 20 20 20 20 3b 3b 20 70 72 6f 63  ..       ;; proc
2590: 65 73 73 20 63 61 6e 20 6b 6e 6f 77 20 74 6f 20  ess can know to 
25a0: 63 61 6c 6c 20 69 74 65 6d 73 3a 67 65 74 2d 69  call items:get-i
25b0: 74 65 6d 73 2d 66 72 6f 6d 2d 63 6f 6e 66 69 67  tems-from-config
25c0: 0a 09 09 09 09 09 20 20 20 20 20 20 20 3b 3b 20  ......       ;; 
25d0: 69 66 20 65 69 74 68 65 72 20 69 73 20 61 20 6c  if either is a l
25e0: 69 73 74 20 61 6e 64 20 6e 6f 6e 65 20 69 73 20  ist and none is 
25f0: 61 20 70 72 6f 63 20 67 6f 20 61 68 65 61 64 20  a proc go ahead 
2600: 61 6e 64 20 63 61 6c 6c 20 67 65 74 2d 69 74 65  and call get-ite
2610: 6d 73 0a 09 09 09 09 09 20 20 20 20 20 20 20 3b  ms......       ;
2620: 3b 20 6f 74 68 65 72 77 69 73 65 20 72 65 74 75  ; otherwise retu
2630: 72 6e 20 23 66 20 2d 20 74 68 69 73 20 69 73 20  rn #f - this is 
2640: 6e 6f 74 20 61 6e 20 69 74 65 72 61 74 65 64 20  not an iterated 
2650: 74 65 73 74 0a 09 09 09 09 09 20 20 20 20 20 20  test......      
2660: 20 28 63 6f 6e 64 0a 09 09 09 09 09 09 28 28 70   (cond.......((p
2670: 72 6f 63 65 64 75 72 65 3f 20 69 74 65 6d 73 29  rocedure? items)
2680: 20 20 20 20 20 20 0a 09 09 09 09 09 09 20 28 64        ....... (d
2690: 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 49 4e  ebug:print 4 "IN
26a0: 46 4f 3a 20 69 74 65 6d 73 20 69 73 20 61 20 70  FO: items is a p
26b0: 72 6f 63 65 64 75 72 65 2c 20 77 69 6c 6c 20 63  rocedure, will c
26c0: 61 6c 63 20 6c 61 74 65 72 22 29 0a 09 09 09 09  alc later").....
26d0: 09 09 20 69 74 65 6d 73 29 20 20 20 20 20 20 20  .. items)       
26e0: 20 20 20 20 20 3b 3b 20 63 61 6c 63 20 6c 61 74       ;; calc lat
26f0: 65 72 0a 09 09 09 09 09 09 28 28 70 72 6f 63 65  er.......((proce
2700: 64 75 72 65 3f 20 69 74 65 6d 73 74 61 62 6c 65  dure? itemstable
2710: 29 0a 09 09 09 09 09 09 20 28 64 65 62 75 67 3a  )....... (debug:
2720: 70 72 69 6e 74 20 34 20 22 49 4e 46 4f 3a 20 69  print 4 "INFO: i
2730: 74 65 6d 73 74 61 62 6c 65 20 69 73 20 61 20 70  temstable is a p
2740: 72 6f 63 65 64 75 72 65 2c 20 77 69 6c 6c 20 63  rocedure, will c
2750: 61 6c 63 20 6c 61 74 65 72 22 29 0a 09 09 09 09  alc later").....
2760: 09 09 20 69 74 65 6d 73 74 61 62 6c 65 29 20 20  .. itemstable)  
2770: 20 20 20 20 20 3b 3b 20 63 61 6c 63 20 6c 61 74       ;; calc lat
2780: 65 72 0a 09 09 09 09 09 09 28 28 66 69 6c 74 65  er.......((filte
2790: 72 20 28 6c 61 6d 62 64 61 20 28 78 29 0a 09 09  r (lambda (x)...
27a0: 09 09 09 09 09 20 20 20 28 6c 65 74 20 28 28 76  .....   (let ((v
27b0: 61 6c 20 28 63 61 72 20 78 29 29 29 0a 09 09 09  al (car x)))....
27c0: 09 09 09 09 20 20 20 20 20 28 69 66 20 28 70 72  ....     (if (pr
27d0: 6f 63 65 64 75 72 65 3f 20 76 61 6c 29 20 76 61  ocedure? val) va
27e0: 6c 20 23 66 29 29 29 0a 09 09 09 09 09 09 09 20  l #f)))........ 
27f0: 28 61 70 70 65 6e 64 20 28 69 66 20 28 6c 69 73  (append (if (lis
2800: 74 3f 20 69 74 65 6d 73 29 20 69 74 65 6d 73 20  t? items) items 
2810: 27 28 29 29 0a 09 09 09 09 09 09 09 09 20 28 69  '())......... (i
2820: 66 20 28 6c 69 73 74 3f 20 69 74 65 6d 73 74 61  f (list? itemsta
2830: 62 6c 65 29 20 69 74 65 6d 73 74 61 62 6c 65 20  ble) itemstable 
2840: 27 28 29 29 29 29 0a 09 09 09 09 09 09 20 27 68  '())))....... 'h
2850: 61 76 65 2d 70 72 6f 63 65 64 75 72 65 29 0a 09  ave-procedure)..
2860: 09 09 09 09 09 28 28 6f 72 20 28 6c 69 73 74 3f  .....((or (list?
2870: 20 69 74 65 6d 73 29 28 6c 69 73 74 3f 20 69 74   items)(list? it
2880: 65 6d 73 74 61 62 6c 65 29 29 20 3b 3b 20 63 61  emstable)) ;; ca
2890: 6c 63 20 6e 6f 77 0a 09 09 09 09 09 09 20 28 64  lc now....... (d
28a0: 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 49 4e  ebug:print 4 "IN
28b0: 46 4f 3a 20 69 74 65 6d 73 20 61 6e 64 20 69 74  FO: items and it
28c0: 65 6d 73 74 61 62 6c 65 20 61 72 65 20 6c 69 73  emstable are lis
28d0: 74 73 2c 20 63 61 6c 63 20 6e 6f 77 5c 6e 22 0a  ts, calc now\n".
28e0: 09 09 09 09 09 09 09 20 20 20 20 20 20 22 20 20  .......      "  
28f0: 20 20 69 74 65 6d 73 3a 20 22 20 69 74 65 6d 73    items: " items
2900: 20 22 20 69 74 65 6d 73 74 61 62 6c 65 3a 20 22   " itemstable: "
2910: 20 69 74 65 6d 73 74 61 62 6c 65 29 0a 09 09 09   itemstable)....
2920: 09 09 09 20 28 69 74 65 6d 73 3a 67 65 74 2d 69  ... (items:get-i
2930: 74 65 6d 73 2d 66 72 6f 6d 2d 63 6f 6e 66 69 67  tems-from-config
2940: 20 63 6f 6e 66 69 67 29 29 0a 09 09 09 09 09 09   config)).......
2950: 28 65 6c 73 65 20 23 66 29 29 29 20 20 20 20 20  (else #f)))     
2960: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2970: 20 20 20 20 20 20 3b 3b 20 6e 6f 74 20 69 74 65        ;; not ite
2980: 72 61 74 65 64 0a 09 09 09 09 09 20 20 20 20 20  rated......     
2990: 23 66 20 20 20 20 20 20 3b 3b 20 69 74 65 6d 73  #f      ;; items
29a0: 64 61 74 20 35 0a 09 09 09 09 09 20 20 20 20 20  dat 5......     
29b0: 3b 3b 20 23 66 20 20 20 20 20 20 3b 3b 20 73 70  ;; #f      ;; sp
29c0: 61 72 65 0a 09 09 09 09 09 20 20 20 20 20 29 29  are......     ))
29d0: 29 0a 09 20 20 20 20 28 66 6f 72 2d 65 61 63 68  )..    (for-each
29e0: 20 0a 09 20 20 20 20 20 28 6c 61 6d 62 64 61 20   ..     (lambda 
29f0: 28 77 61 69 74 6f 6e 29 0a 09 20 20 20 20 20 20  (waiton)..      
2a00: 20 28 69 66 20 28 61 6e 64 20 77 61 69 74 6f 6e   (if (and waiton
2a10: 20 28 6e 6f 74 20 28 6d 65 6d 62 65 72 20 77 61   (not (member wa
2a20: 69 74 6f 6e 20 74 65 73 74 2d 6e 61 6d 65 73 29  iton test-names)
2a30: 29 29 0a 09 09 20 20 20 28 62 65 67 69 6e 0a 09  ))...   (begin..
2a40: 09 20 20 20 20 20 28 73 65 74 21 20 72 65 71 75  .     (set! requ
2a50: 69 72 65 64 2d 74 65 73 74 73 20 28 63 6f 6e 73  ired-tests (cons
2a60: 20 77 61 69 74 6f 6e 20 72 65 71 75 69 72 65 64   waiton required
2a70: 2d 74 65 73 74 73 29 29 0a 09 09 20 20 20 20 20  -tests))...     
2a80: 28 73 65 74 21 20 74 65 73 74 2d 6e 61 6d 65 73  (set! test-names
2a90: 20 28 63 6f 6e 73 20 77 61 69 74 6f 6e 20 74 65   (cons waiton te
2aa0: 73 74 2d 6e 61 6d 65 73 29 29 29 29 29 20 3b 3b  st-names))))) ;;
2ab0: 20 77 61 73 20 61 6e 20 61 70 70 65 6e 64 2c 20   was an append, 
2ac0: 6e 6f 77 20 61 20 63 6f 6e 73 0a 09 20 20 20 20  now a cons..    
2ad0: 20 77 61 69 74 6f 6e 73 29 0a 09 20 20 20 20 28   waitons)..    (
2ae0: 6c 65 74 20 28 28 72 65 6d 74 65 73 74 73 20 28  let ((remtests (
2af0: 64 65 6c 65 74 65 2d 64 75 70 6c 69 63 61 74 65  delete-duplicate
2b00: 73 20 28 61 70 70 65 6e 64 20 77 61 69 74 6f 6e  s (append waiton
2b10: 73 20 74 61 6c 29 29 29 29 0a 09 20 20 20 20 20  s tal))))..     
2b20: 20 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f   (if (not (null?
2b30: 20 72 65 6d 74 65 73 74 73 29 29 0a 09 09 20 20   remtests))...  
2b40: 28 6c 6f 6f 70 20 28 63 61 72 20 72 65 6d 74 65  (loop (car remte
2b50: 73 74 73 29 28 63 64 72 20 72 65 6d 74 65 73 74  sts)(cdr remtest
2b60: 73 29 29 29 29 29 29 29 0a 0a 20 20 20 20 28 69  s)))))))..    (i
2b70: 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 72 65  f (not (null? re
2b80: 71 75 69 72 65 64 2d 74 65 73 74 73 29 29 0a 09  quired-tests))..
2b90: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22  (debug:print 1 "
2ba0: 49 4e 46 4f 3a 20 41 64 64 69 6e 67 20 22 20 72  INFO: Adding " r
2bb0: 65 71 75 69 72 65 64 2d 74 65 73 74 73 20 22 20  equired-tests " 
2bc0: 74 6f 20 74 68 65 20 72 75 6e 20 71 75 65 75 65  to the run queue
2bd0: 22 29 29 0a 20 20 20 20 3b 3b 20 4e 4f 54 45 3a  ")).    ;; NOTE:
2be0: 20 74 68 65 73 65 20 61 72 65 20 61 6c 6c 20 70   these are all p
2bf0: 61 72 65 6e 74 20 74 65 73 74 73 2c 20 69 74 65  arent tests, ite
2c00: 6d 73 20 61 72 65 20 6e 6f 74 20 65 78 70 61 6e  ms are not expan
2c10: 64 65 64 20 79 65 74 2e 0a 20 20 20 20 28 72 75  ded yet..    (ru
2c20: 6e 73 3a 72 75 6e 2d 74 65 73 74 73 2d 71 75 65  ns:run-tests-que
2c30: 75 65 20 64 62 20 72 75 6e 2d 69 64 20 72 75 6e  ue db run-id run
2c40: 6e 61 6d 65 20 74 65 73 74 2d 72 65 63 6f 72 64  name test-record
2c50: 73 20 6b 65 79 76 61 6c 6c 73 74 20 66 6c 61 67  s keyvallst flag
2c60: 73 29 0a 20 20 20 20 28 69 66 20 2a 72 70 63 3a  s).    (if *rpc:
2c70: 6c 69 73 74 65 6e 65 72 2a 20 28 73 65 72 76 65  listener* (serve
2c80: 72 3a 6b 65 65 70 2d 72 75 6e 6e 69 6e 67 20 64  r:keep-running d
2c90: 62 29 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70  b)).    (debug:p
2ca0: 72 69 6e 74 20 34 20 22 49 4e 46 4f 3a 20 41 6c  rint 4 "INFO: Al
2cb0: 6c 20 64 6f 6e 65 20 62 79 20 68 65 72 65 22 29  l done by here")
2cc0: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 72 75 6e  ))..(define (run
2cd0: 73 3a 72 75 6e 2d 74 65 73 74 73 2d 71 75 65 75  s:run-tests-queu
2ce0: 65 20 64 62 20 72 75 6e 2d 69 64 20 72 75 6e 6e  e db run-id runn
2cf0: 61 6d 65 20 74 65 73 74 2d 72 65 63 6f 72 64 73  ame test-records
2d00: 20 6b 65 79 76 61 6c 6c 73 74 20 66 6c 61 67 73   keyvallst flags
2d10: 29 0a 20 20 20 20 3b 3b 20 41 74 20 74 68 69 73  ).    ;; At this
2d20: 20 70 6f 69 6e 74 20 74 68 65 20 6c 69 73 74 20   point the list 
2d30: 6f 66 20 70 61 72 65 6e 74 20 74 65 73 74 73 20  of parent tests 
2d40: 69 73 20 65 78 70 61 6e 64 65 64 20 0a 20 20 20  is expanded .   
2d50: 20 3b 3b 20 4e 42 2f 2f 20 53 68 6f 75 6c 64 20   ;; NB// Should 
2d60: 65 78 70 61 6e 64 20 69 74 65 6d 73 20 68 65 72  expand items her
2d70: 65 20 61 6e 64 20 74 68 65 6e 20 69 6e 73 65 72  e and then inser
2d80: 74 20 69 6e 74 6f 20 74 68 65 20 72 75 6e 20 71  t into the run q
2d90: 75 65 75 65 2e 0a 20 20 28 64 65 62 75 67 3a 70  ueue..  (debug:p
2da0: 72 69 6e 74 20 35 20 22 74 65 73 74 2d 72 65 63  rint 5 "test-rec
2db0: 6f 72 64 73 3a 20 22 20 74 65 73 74 2d 72 65 63  ords: " test-rec
2dc0: 6f 72 64 73 20 22 2c 20 6b 65 79 76 61 6c 6c 73  ords ", keyvalls
2dd0: 74 3a 20 22 20 6b 65 79 76 61 6c 6c 73 74 29 0a  t: " keyvallst).
2de0: 20 20 28 6c 65 74 20 28 28 73 6f 72 74 65 64 2d    (let ((sorted-
2df0: 74 65 73 74 2d 6e 61 6d 65 73 20 28 74 65 73 74  test-names (test
2e00: 73 3a 73 6f 72 74 2d 62 79 2d 70 72 69 6f 72 69  s:sort-by-priori
2e10: 74 79 2d 61 6e 64 2d 77 61 69 74 6f 6e 20 74 65  ty-and-waiton te
2e20: 73 74 2d 72 65 63 6f 72 64 73 29 29 0a 09 28 69  st-records))..(i
2e30: 74 65 6d 2d 70 61 74 74 73 20 20 20 20 20 20 20  tem-patts       
2e40: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
2e50: 2f 64 65 66 61 75 6c 74 20 66 6c 61 67 73 20 22  /default flags "
2e60: 2d 69 74 65 6d 70 61 74 74 22 20 23 66 29 29 29  -itempatt" #f)))
2e70: 0a 20 20 20 20 28 6c 65 74 20 6c 6f 6f 70 20 28  .    (let loop (
2e80: 3b 20 28 6e 75 6d 74 69 6d 65 73 20 30 29 20 3b  ; (numtimes 0) ;
2e90: 3b 20 73 68 6f 75 6c 64 6e 27 74 20 6e 65 65 64  ; shouldn't need
2ea0: 20 74 68 69 73 0a 09 20 20 20 20 20 20 20 28 68   this..       (h
2eb0: 65 64 20 20 20 20 20 20 20 20 20 28 63 61 72 20  ed         (car 
2ec0: 73 6f 72 74 65 64 2d 74 65 73 74 2d 6e 61 6d 65  sorted-test-name
2ed0: 73 29 29 0a 09 20 20 20 20 20 20 20 28 74 61 6c  s))..       (tal
2ee0: 20 20 20 20 20 20 20 20 20 28 63 64 72 20 73 6f           (cdr so
2ef0: 72 74 65 64 2d 74 65 73 74 2d 6e 61 6d 65 73 29  rted-test-names)
2f00: 29 29 0a 20 20 20 20 20 20 28 6c 65 74 2a 20 28  )).      (let* (
2f10: 28 74 65 73 74 2d 72 65 63 6f 72 64 20 28 68 61  (test-record (ha
2f20: 73 68 2d 74 61 62 6c 65 2d 72 65 66 20 74 65 73  sh-table-ref tes
2f30: 74 2d 72 65 63 6f 72 64 73 20 68 65 64 29 29 0a  t-records hed)).
2f40: 09 20 20 20 20 20 28 74 63 6f 6e 66 69 67 20 20  .     (tconfig  
2f50: 20 20 20 28 74 65 73 74 73 3a 74 65 73 74 71 75     (tests:testqu
2f60: 65 75 65 2d 67 65 74 2d 74 65 73 74 63 6f 6e 66  eue-get-testconf
2f70: 69 67 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29  ig test-record))
2f80: 0a 09 20 20 20 20 20 28 77 61 69 74 6f 6e 73 20  ..     (waitons 
2f90: 20 20 20 20 28 74 65 73 74 73 3a 74 65 73 74 71      (tests:testq
2fa0: 75 65 75 65 2d 67 65 74 2d 77 61 69 74 6f 6e 73  ueue-get-waitons
2fb0: 20 20 20 20 74 65 73 74 2d 72 65 63 6f 72 64 29      test-record)
2fc0: 29 0a 09 20 20 20 20 20 28 70 72 69 6f 72 69 74  )..     (priorit
2fd0: 79 20 20 20 20 28 74 65 73 74 73 3a 74 65 73 74  y    (tests:test
2fe0: 71 75 65 75 65 2d 67 65 74 2d 70 72 69 6f 72 69  queue-get-priori
2ff0: 74 79 20 20 20 74 65 73 74 2d 72 65 63 6f 72 64  ty   test-record
3000: 29 29 0a 09 20 20 20 20 20 28 69 74 65 6d 64 61  ))..     (itemda
3010: 74 20 20 20 20 20 28 74 65 73 74 73 3a 74 65 73  t     (tests:tes
3020: 74 71 75 65 75 65 2d 67 65 74 2d 69 74 65 6d 64  tqueue-get-itemd
3030: 61 74 20 20 20 20 74 65 73 74 2d 72 65 63 6f 72  at    test-recor
3040: 64 29 29 0a 09 20 20 20 20 20 28 69 74 65 6d 73  d))..     (items
3050: 20 20 20 20 20 20 20 28 74 65 73 74 73 3a 74 65         (tests:te
3060: 73 74 71 75 65 75 65 2d 67 65 74 2d 69 74 65 6d  stqueue-get-item
3070: 73 20 20 20 20 20 20 74 65 73 74 2d 72 65 63 6f  s      test-reco
3080: 72 64 29 29 0a 09 20 20 20 20 20 28 69 74 65 6d  rd))..     (item
3090: 2d 70 61 74 68 20 20 20 28 69 74 65 6d 2d 6c 69  -path   (item-li
30a0: 73 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74  st->path itemdat
30b0: 29 29 29 0a 09 28 64 65 62 75 67 3a 70 72 69 6e  )))..(debug:prin
30c0: 74 20 36 0a 09 09 20 20 20 20 20 22 69 74 65 6d  t 6...     "item
30d0: 64 61 74 3a 20 20 20 20 20 22 20 69 74 65 6d 64  dat:     " itemd
30e0: 61 74 0a 09 09 20 20 20 20 20 22 5c 6e 20 20 69  at...     "\n  i
30f0: 74 65 6d 73 3a 20 20 20 20 20 22 20 69 74 65 6d  tems:     " item
3100: 73 0a 09 09 20 20 20 20 20 22 5c 6e 20 20 69 74  s...     "\n  it
3110: 65 6d 2d 70 61 74 68 3a 20 22 20 69 74 65 6d 2d  em-path: " item-
3120: 70 61 74 68 29 0a 09 28 63 6f 6e 64 0a 09 20 28  path)..(cond.. (
3130: 28 6e 6f 74 20 69 74 65 6d 73 29 20 3b 3b 20 77  (not items) ;; w
3140: 68 65 6e 20 66 61 6c 73 65 20 74 68 65 20 74 65  hen false the te
3150: 73 74 20 69 73 20 6f 6b 20 74 6f 20 62 65 20 68  st is ok to be h
3160: 61 6e 64 65 64 20 6f 66 66 20 74 6f 20 6c 61 75  anded off to lau
3170: 6e 63 68 20 28 62 75 74 20 6e 6f 74 20 62 65 66  nch (but not bef
3180: 6f 72 65 29 0a 09 20 20 28 6c 65 74 20 28 28 68  ore)..  (let ((h
3190: 61 76 65 2d 72 65 73 6f 75 72 63 65 73 20 20 28  ave-resources  (
31a0: 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72  runs:can-run-mor
31b0: 65 2d 74 65 73 74 73 20 64 62 20 74 65 73 74 2d  e-tests db test-
31c0: 72 65 63 6f 72 64 29 29 20 3b 3b 20 6c 6f 6f 6b  record)) ;; look
31d0: 20 61 74 20 74 68 65 20 74 65 73 74 20 6a 6f 62   at the test job
31e0: 67 72 6f 75 70 20 61 6e 64 20 74 6f 74 20 6a 6f  group and tot jo
31f0: 62 73 20 72 75 6e 6e 69 6e 67 0a 09 09 28 70 72  bs running...(pr
3200: 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 20 28 64  ereqs-not-met (d
3210: 62 3a 67 65 74 2d 70 72 65 72 65 71 73 2d 6e 6f  b:get-prereqs-no
3220: 74 2d 6d 65 74 20 64 62 20 72 75 6e 2d 69 64 20  t-met db run-id 
3230: 77 61 69 74 6f 6e 73 20 69 74 65 6d 2d 70 61 74  waitons item-pat
3240: 68 29 29 29 0a 09 20 20 20 20 3b 3b 20 44 6f 6e  h)))..    ;; Don
3250: 27 74 20 6b 6e 6f 77 20 61 74 20 74 68 69 73 20  't know at this 
3260: 74 69 6d 65 20 69 66 20 74 68 65 20 74 65 73 74  time if the test
3270: 20 68 61 76 65 20 62 65 65 6e 20 6c 61 75 6e 63   have been launc
3280: 68 65 64 20 61 74 20 73 6f 6d 65 20 74 69 6d 65  hed at some time
3290: 20 69 6e 20 74 68 65 20 70 61 73 74 0a 09 20 20   in the past..  
32a0: 20 20 3b 3b 20 69 2e 65 2e 20 69 73 20 74 68 69    ;; i.e. is thi
32b0: 73 20 61 20 72 65 2d 6c 61 75 6e 63 68 3f 0a 09  s a re-launch?..
32c0: 20 20 20 20 28 69 66 20 28 61 6e 64 20 68 61 76      (if (and hav
32d0: 65 2d 72 65 73 6f 75 72 63 65 73 0a 09 09 20 20  e-resources...  
32e0: 20 20 20 28 6e 75 6c 6c 3f 20 70 72 65 72 65 71     (null? prereq
32f0: 73 2d 6e 6f 74 2d 6d 65 74 29 29 0a 09 09 3b 3b  s-not-met))...;;
3300: 20 6e 6f 20 6c 6f 6f 70 20 2d 20 64 72 6f 70 20   no loop - drop 
3310: 74 68 6f 75 67 68 20 61 6e 64 20 75 73 65 20 74  though and use t
3320: 68 65 20 6c 6f 6f 70 20 61 74 20 74 68 65 20 62  he loop at the b
3330: 6f 74 74 6f 6d 20 0a 09 09 28 72 75 6e 3a 74 65  ottom ...(run:te
3340: 73 74 20 64 62 20 72 75 6e 2d 69 64 20 72 75 6e  st db run-id run
3350: 6e 61 6d 65 20 6b 65 79 76 61 6c 6c 73 74 20 74  name keyvallst t
3360: 65 73 74 2d 72 65 63 6f 72 64 20 66 6c 61 67 73  est-record flags
3370: 20 23 66 29 0a 09 09 3b 3b 20 65 6c 73 65 20 74   #f)...;; else t
3380: 68 65 20 72 75 6e 20 69 73 20 73 74 75 63 6b 2c  he run is stuck,
3390: 20 74 65 6d 70 6f 72 61 72 69 6c 79 20 6f 72 20   temporarily or 
33a0: 70 65 72 6d 61 6e 65 6e 74 6c 79 0a 09 09 28 6c  permanently...(l
33b0: 65 74 20 28 28 6e 65 77 74 61 6c 20 28 61 70 70  et ((newtal (app
33c0: 65 6e 64 20 74 61 6c 20 28 6c 69 73 74 20 68 65  end tal (list he
33d0: 64 29 29 29 29 0a 09 09 20 20 3b 3b 20 63 6f 75  d))))...  ;; cou
33e0: 6c 64 6e 27 74 20 72 75 6e 2c 20 74 61 6b 65 20  ldn't run, take 
33f0: 61 20 62 72 65 61 74 68 65 72 0a 09 09 20 20 28  a breather...  (
3400: 74 68 72 65 61 64 2d 73 6c 65 65 70 21 20 34 29  thread-sleep! 4)
3410: 0a 09 09 20 20 28 6c 6f 6f 70 20 28 63 61 72 20  ...  (loop (car 
3420: 6e 65 77 74 61 6c 29 28 63 64 72 20 6e 65 77 74  newtal)(cdr newt
3430: 61 6c 29 29 29 29 29 29 0a 09 20 0a 09 20 3b 3b  al)))))).. .. ;;
3440: 20 63 61 73 65 20 77 68 65 72 65 20 61 6e 20 69   case where an i
3450: 74 65 6d 73 20 63 61 6d 65 20 69 6e 20 61 73 20  tems came in as 
3460: 61 20 6c 69 73 74 20 62 65 65 6e 20 70 72 6f 63  a list been proc
3470: 65 73 73 65 64 0a 09 20 28 28 61 6e 64 20 28 6c  essed.. ((and (l
3480: 69 73 74 3f 20 69 74 65 6d 73 29 20 20 20 20 20  ist? items)     
3490: 3b 3b 20 74 68 75 73 20 77 65 20 6b 6e 6f 77 20  ;; thus we know 
34a0: 6f 75 72 20 69 74 65 6d 73 20 61 72 65 20 61 6c  our items are al
34b0: 72 65 61 64 79 20 63 61 6c 63 75 6c 61 74 65 64  ready calculated
34c0: 0a 09 20 20 20 20 20 20 20 28 6e 6f 74 20 20 20  ..       (not   
34d0: 69 74 65 6d 64 61 74 29 29 20 3b 3b 20 61 6e 64  itemdat)) ;; and
34e0: 20 6e 6f 74 20 79 65 74 20 65 78 70 61 6e 64 65   not yet expande
34f0: 64 20 69 6e 74 6f 20 74 68 65 20 6c 69 73 74 20  d into the list 
3500: 6f 66 20 74 68 69 6e 67 73 20 74 6f 20 62 65 20  of things to be 
3510: 64 6f 6e 65 0a 09 20 20 28 69 66 20 28 3e 3d 20  done..  (if (>= 
3520: 2a 76 65 72 62 6f 73 69 74 79 2a 20 31 29 28 70  *verbosity* 1)(p
3530: 70 20 69 74 65 6d 73 29 29 0a 09 20 20 3b 3b 20  p items))..  ;; 
3540: 28 69 66 20 28 3e 3d 20 2a 76 65 72 62 6f 73 69  (if (>= *verbosi
3550: 74 79 2a 20 35 29 0a 09 20 20 3b 3b 20 20 20 20  ty* 5)..  ;;    
3560: 20 28 62 65 67 69 6e 0a 09 20 20 3b 3b 20 20 20   (begin..  ;;   
3570: 20 20 20 20 28 70 72 69 6e 74 20 22 69 74 65 6d      (print "item
3580: 73 3a 20 22 29 20 20 20 20 20 28 70 70 20 28 69  s: ")     (pp (i
3590: 74 65 6d 2d 61 73 73 6f 63 2d 3e 69 74 65 6d 2d  tem-assoc->item-
35a0: 6c 69 73 74 20 69 74 65 6d 73 29 29 0a 09 20 20  list items))..  
35b0: 3b 3b 20 20 20 20 20 20 20 28 70 72 69 6e 74 20  ;;       (print 
35c0: 22 69 74 65 6d 73 74 61 62 6c 65 3a 20 22 29 28  "itemstable: ")(
35d0: 70 70 20 28 69 74 65 6d 2d 74 61 62 6c 65 2d 3e  pp (item-table->
35e0: 69 74 65 6d 2d 6c 69 73 74 20 69 74 65 6d 73 74  item-list itemst
35f0: 61 62 6c 65 29 29 29 29 0a 09 20 20 28 66 6f 72  able))))..  (for
3600: 2d 65 61 63 68 0a 09 20 20 20 28 6c 61 6d 62 64  -each..   (lambd
3610: 61 20 28 6d 79 2d 69 74 65 6d 64 61 74 29 0a 09  a (my-itemdat)..
3620: 20 20 20 20 20 28 6c 65 74 2a 20 28 28 6e 65 77       (let* ((new
3630: 2d 74 65 73 74 2d 72 65 63 6f 72 64 20 28 6c 65  -test-record (le
3640: 74 20 28 28 6e 65 77 72 65 63 20 28 6d 61 6b 65  t ((newrec (make
3650: 2d 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65  -tests:testqueue
3660: 29 29 29 0a 09 09 09 09 20 20 20 20 20 20 20 28  ))).....       (
3670: 76 65 63 74 6f 72 2d 63 6f 70 79 21 20 74 65 73  vector-copy! tes
3680: 74 2d 72 65 63 6f 72 64 20 6e 65 77 72 65 63 29  t-record newrec)
3690: 0a 09 09 09 09 20 20 20 20 20 20 20 6e 65 77 72  .....       newr
36a0: 65 63 29 29 0a 09 09 20 20 20 20 28 6d 79 2d 69  ec))...    (my-i
36b0: 74 65 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c  tem-path (item-l
36c0: 69 73 74 2d 3e 70 61 74 68 20 6d 79 2d 69 74 65  ist->path my-ite
36d0: 6d 64 61 74 29 29 0a 09 09 20 20 20 20 28 69 74  mdat))...    (it
36e0: 65 6d 2d 6d 61 74 63 68 65 73 20 28 69 66 20 69  em-matches (if i
36f0: 74 65 6d 2d 70 61 74 74 73 20 20 20 20 20 20 20  tem-patts       
3700: 3b 3b 20 68 65 72 65 20 77 65 20 61 72 65 20 66  ;; here we are f
3710: 69 6c 74 65 72 69 6e 67 20 66 6f 72 20 6d 61 74  iltering for mat
3720: 63 68 65 73 20 77 69 74 68 20 2d 69 74 65 6d 70  ches with -itemp
3730: 61 74 74 0a 09 09 09 09 20 20 20 20 20 20 28 6c  att.....      (l
3740: 65 74 20 28 28 72 65 73 20 23 66 29 29 09 20 3b  et ((res #f)). ;
3750: 3b 20 6c 6f 6f 6b 20 74 68 72 6f 75 67 68 20 61  ; look through a
3760: 6c 6c 20 74 68 65 20 69 74 65 6d 2d 70 61 74 74  ll the item-patt
3770: 73 20 69 66 20 64 65 66 69 6e 65 64 2c 20 66 6f  s if defined, fo
3780: 72 6d 61 74 20 69 73 20 70 61 74 74 31 2c 70 61  rmat is patt1,pa
3790: 74 74 32 2c 70 61 74 74 33 20 2e 2e 2e 20 77 69  tt2,patt3 ... wi
37a0: 6c 64 63 61 72 64 20 69 73 20 25 0a 09 09 09 09  ldcard is %.....
37b0: 09 28 66 6f 72 2d 65 61 63 68 20 0a 09 09 09 09  .(for-each .....
37c0: 09 20 28 6c 61 6d 62 64 61 20 28 70 61 74 74 29  . (lambda (patt)
37d0: 0a 09 09 09 09 09 20 20 20 28 69 66 20 28 73 74  ......   (if (st
37e0: 72 69 6e 67 2d 73 65 61 72 63 68 20 28 67 6c 6f  ring-search (glo
37f0: 62 2d 3e 72 65 67 65 78 70 0a 09 09 09 09 09 09  b->regexp.......
3800: 09 20 20 20 20 20 20 20 28 73 74 72 69 6e 67 2d  .       (string-
3810: 74 72 61 6e 73 6c 61 74 65 20 70 61 74 74 20 22  translate patt "
3820: 25 22 20 22 2a 22 29 29 0a 09 09 09 09 09 09 09  %" "*"))........
3830: 20 20 20 20 20 20 69 74 65 6d 2d 70 61 74 68 29        item-path)
3840: 0a 09 09 09 09 09 20 20 20 20 20 20 20 28 73 65  ......       (se
3850: 74 21 20 72 65 73 20 23 74 29 29 29 0a 09 09 09  t! res #t)))....
3860: 09 09 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74  .. (string-split
3870: 20 69 74 65 6d 2d 70 61 74 74 73 20 22 2c 22 29   item-patts ",")
3880: 29 0a 09 09 09 09 09 72 65 73 29 0a 09 09 09 09  )......res).....
3890: 20 20 20 20 20 20 23 74 29 29 29 0a 09 20 20 20        #t)))..   
38a0: 20 20 20 20 28 69 66 20 69 74 65 6d 2d 6d 61 74      (if item-mat
38b0: 63 68 65 73 20 3b 3b 20 79 65 73 2c 20 77 65 20  ches ;; yes, we 
38c0: 77 61 6e 74 20 74 6f 20 70 72 6f 63 65 73 73 20  want to process 
38d0: 74 68 69 73 20 69 74 65 6d 0a 09 09 20 20 20 28  this item...   (
38e0: 6c 65 74 20 28 28 6e 65 77 74 65 73 74 6e 61 6d  let ((newtestnam
38f0: 65 20 28 63 6f 6e 63 20 68 65 64 20 22 2f 22 20  e (conc hed "/" 
3900: 6d 79 2d 69 74 65 6d 2d 70 61 74 68 29 29 29 20  my-item-path))) 
3910: 0a 09 09 20 20 20 20 20 28 74 65 73 74 73 3a 74  ...     (tests:t
3920: 65 73 74 71 75 65 75 65 2d 73 65 74 2d 69 74 65  estqueue-set-ite
3930: 6d 73 21 20 20 20 6e 65 77 2d 74 65 73 74 2d 72  ms!   new-test-r
3940: 65 63 6f 72 64 20 23 66 29 0a 09 09 20 20 20 20  ecord #f)...    
3950: 20 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75   (tests:testqueu
3960: 65 2d 73 65 74 2d 69 74 65 6d 64 61 74 21 20 6e  e-set-itemdat! n
3970: 65 77 2d 74 65 73 74 2d 72 65 63 6f 72 64 20 6d  ew-test-record m
3980: 79 2d 69 74 65 6d 64 61 74 29 0a 09 09 20 20 20  y-itemdat)...   
3990: 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65    (hash-table-se
39a0: 74 21 20 74 65 73 74 2d 72 65 63 6f 72 64 73 20  t! test-records 
39b0: 6e 65 77 74 65 73 74 6e 61 6d 65 20 6e 65 77 2d  newtestname new-
39c0: 74 65 73 74 2d 72 65 63 6f 72 64 29 0a 09 09 20  test-record)... 
39d0: 20 20 20 20 28 73 65 74 21 20 74 61 6c 20 28 63      (set! tal (c
39e0: 6f 6e 73 20 6e 65 77 74 65 73 74 6e 61 6d 65 20  ons newtestname 
39f0: 74 61 6c 29 29 29 29 29 29 20 3b 3b 20 73 69 6e  tal)))))) ;; sin
3a00: 63 65 20 74 68 65 73 65 20 61 72 65 20 69 74 65  ce these are ite
3a10: 6d 69 7a 65 64 20 63 72 65 61 74 65 20 6e 65 77  mized create new
3a20: 20 74 65 73 74 20 6e 61 6d 65 73 20 74 65 73 74   test names test
3a30: 6e 61 6d 65 2f 69 74 65 6d 70 61 74 68 0a 09 20  name/itempath.. 
3a40: 20 20 69 74 65 6d 73 29 0a 09 20 20 28 6c 6f 6f    items)..  (loo
3a50: 70 20 28 63 61 72 20 74 61 6c 29 28 63 64 72 20  p (car tal)(cdr 
3a60: 74 61 6c 29 29 29 0a 0a 09 20 3b 3b 20 69 66 20  tal)))... ;; if 
3a70: 69 74 65 6d 73 20 69 73 20 61 20 70 72 6f 63 20  items is a proc 
3a80: 74 68 65 6e 20 6e 65 65 64 20 74 6f 20 72 75 6e  then need to run
3a90: 20 69 74 65 6d 73 3a 67 65 74 2d 69 74 65 6d 73   items:get-items
3aa0: 2d 66 72 6f 6d 2d 63 6f 6e 66 69 67 2c 20 67 65  -from-config, ge
3ab0: 74 20 74 68 65 20 6c 69 73 74 20 61 6e 64 20 6c  t the list and l
3ac0: 6f 6f 70 20 0a 09 20 3b 3b 20 20 20 20 2d 20 62  oop .. ;;    - b
3ad0: 75 74 20 6f 6e 6c 79 20 64 6f 20 74 68 61 74 20  ut only do that 
3ae0: 69 66 20 72 65 73 6f 75 72 63 65 73 20 65 78 69  if resources exi
3af0: 73 74 20 74 6f 20 6b 69 63 6b 20 6f 66 66 20 74  st to kick off t
3b00: 68 65 20 6a 6f 62 0a 09 20 28 28 6f 72 20 28 70  he job.. ((or (p
3b10: 72 6f 63 65 64 75 72 65 3f 20 69 74 65 6d 73 29  rocedure? items)
3b20: 28 65 71 3f 20 69 74 65 6d 73 20 27 68 61 76 65  (eq? items 'have
3b30: 2d 70 72 6f 63 65 64 75 72 65 29 29 0a 09 20 20  -procedure))..  
3b40: 28 69 66 20 28 61 6e 64 20 28 72 75 6e 73 3a 63  (if (and (runs:c
3b50: 61 6e 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74  an-run-more-test
3b60: 73 20 64 62 20 74 65 73 74 2d 72 65 63 6f 72 64  s db test-record
3b70: 29 0a 09 09 20 20 20 28 6e 75 6c 6c 3f 20 28 64  )...   (null? (d
3b80: 62 3a 67 65 74 2d 70 72 65 72 65 71 73 2d 6e 6f  b:get-prereqs-no
3b90: 74 2d 6d 65 74 20 64 62 20 72 75 6e 2d 69 64 20  t-met db run-id 
3ba0: 77 61 69 74 6f 6e 73 20 69 74 65 6d 2d 70 61 74  waitons item-pat
3bb0: 68 29 29 29 0a 09 20 20 20 20 20 20 28 6c 65 74  h)))..      (let
3bc0: 20 28 28 74 65 73 74 2d 6e 61 6d 65 20 28 74 65   ((test-name (te
3bd0: 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65  sts:testqueue-ge
3be0: 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 2d  t-testname test-
3bf0: 72 65 63 6f 72 64 29 29 29 0a 09 09 28 73 65 74  record)))...(set
3c00: 65 6e 76 20 22 4d 54 5f 54 45 53 54 5f 4e 41 4d  env "MT_TEST_NAM
3c10: 45 22 20 74 65 73 74 2d 6e 61 6d 65 29 20 3b 3b  E" test-name) ;;
3c20: 20 0a 09 09 28 73 65 74 65 6e 76 20 22 4d 54 5f   ...(setenv "MT_
3c30: 52 55 4e 4e 41 4d 45 22 20 20 20 72 75 6e 6e 61  RUNNAME"   runna
3c40: 6d 65 29 0a 09 09 28 73 65 74 2d 6d 65 67 61 74  me)...(set-megat
3c50: 65 73 74 2d 65 6e 76 2d 76 61 72 73 20 64 62 20  est-env-vars db 
3c60: 72 75 6e 2d 69 64 29 20 3b 3b 20 74 68 65 73 65  run-id) ;; these
3c70: 20 6d 61 79 20 62 65 20 6e 65 65 64 65 64 20 62   may be needed b
3c80: 79 20 74 68 65 20 6c 61 75 6e 63 68 69 6e 67 20  y the launching 
3c90: 70 72 6f 63 65 73 73 0a 09 09 28 6c 65 74 20 28  process...(let (
3ca0: 28 69 74 65 6d 73 2d 6c 69 73 74 20 28 69 74 65  (items-list (ite
3cb0: 6d 73 3a 67 65 74 2d 69 74 65 6d 73 2d 66 72 6f  ms:get-items-fro
3cc0: 6d 2d 63 6f 6e 66 69 67 20 74 63 6f 6e 66 69 67  m-config tconfig
3cd0: 29 29 29 0a 09 09 20 20 28 69 66 20 28 6c 69 73  )))...  (if (lis
3ce0: 74 3f 20 69 74 65 6d 73 2d 6c 69 73 74 29 0a 09  t? items-list)..
3cf0: 09 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09  .      (begin...
3d00: 09 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75  .(tests:testqueu
3d10: 65 2d 73 65 74 2d 69 74 65 6d 73 21 20 74 65 73  e-set-items! tes
3d20: 74 2d 72 65 63 6f 72 64 20 69 74 65 6d 73 2d 6c  t-record items-l
3d30: 69 73 74 29 0a 09 09 09 28 6c 6f 6f 70 20 68 65  ist)....(loop he
3d40: 64 20 74 61 6c 29 29 0a 09 09 20 20 20 20 20 20  d tal))...      
3d50: 28 62 65 67 69 6e 0a 09 09 09 28 64 65 62 75 67  (begin....(debug
3d60: 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a  :print 0 "ERROR:
3d70: 20 54 68 65 20 70 72 6f 63 20 66 72 6f 6d 20 72   The proc from r
3d80: 65 61 64 69 6e 67 20 74 68 65 20 73 65 74 75 70  eading the setup
3d90: 20 64 69 64 20 6e 6f 74 20 79 69 65 6c 64 20 61   did not yield a
3da0: 20 6c 69 73 74 20 2d 20 70 6c 65 61 73 65 20 72   list - please r
3db0: 65 70 6f 72 74 20 74 68 69 73 22 29 0a 09 09 09  eport this")....
3dc0: 28 65 78 69 74 20 31 29 29 29 29 29 0a 09 20 20  (exit 1)))))..  
3dd0: 20 20 20 20 28 6c 65 74 20 28 28 6e 65 77 74 61      (let ((newta
3de0: 6c 20 28 61 70 70 65 6e 64 20 74 61 6c 20 28 6c  l (append tal (l
3df0: 69 73 74 20 68 65 64 29 29 29 29 0a 09 09 3b 3b  ist hed))))...;;
3e00: 20 69 66 20 63 61 6e 27 74 20 72 75 6e 20 6d 6f   if can't run mo
3e10: 72 65 20 74 65 73 74 73 2c 20 6c 65 74 73 20 74  re tests, lets t
3e20: 61 6b 65 20 61 20 62 72 65 61 74 68 65 72 0a 09  ake a breather..
3e30: 09 28 74 68 72 65 61 64 2d 73 6c 65 65 70 21 20  .(thread-sleep! 
3e40: 31 29 0a 09 09 28 6c 6f 6f 70 20 28 63 61 72 20  1)...(loop (car 
3e50: 6e 65 77 74 61 6c 29 28 63 64 72 20 6e 65 77 74  newtal)(cdr newt
3e60: 61 6c 29 29 29 29 29 0a 0a 09 20 3b 3b 20 74 68  al)))))... ;; th
3e70: 69 73 20 63 61 73 65 20 73 68 6f 75 6c 64 20 6e  is case should n
3e80: 6f 74 20 68 61 70 70 65 6e 2c 20 61 64 64 65 64  ot happen, added
3e90: 20 74 6f 20 68 65 6c 70 20 63 61 74 63 68 20 61   to help catch a
3ea0: 6e 79 20 62 75 67 73 0a 09 20 28 28 61 6e 64 20  ny bugs.. ((and 
3eb0: 28 6c 69 73 74 3f 20 69 74 65 6d 73 29 20 69 74  (list? items) it
3ec0: 65 6d 64 61 74 29 0a 09 20 20 28 64 65 62 75 67  emdat)..  (debug
3ed0: 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a  :print 0 "ERROR:
3ee0: 20 53 68 6f 75 6c 64 20 6e 6f 74 20 68 61 76 65   Should not have
3ef0: 20 61 20 6c 69 73 74 20 6f 66 20 69 74 65 6d 73   a list of items
3f00: 20 69 6e 20 61 20 74 65 73 74 20 61 6e 64 20 74   in a test and t
3f10: 68 65 20 69 74 65 6d 73 70 61 74 68 20 73 65 74  he itemspath set
3f20: 20 2d 20 70 6c 65 61 73 65 20 72 65 70 6f 72 74   - please report
3f30: 20 74 68 69 73 22 29 0a 09 20 20 28 65 78 69 74   this")..  (exit
3f40: 20 31 29 29 29 29 0a 09 0a 20 20 20 20 20 20 3b   1))))...      ;
3f50: 3b 20 77 65 20 67 65 74 20 68 65 72 65 20 6f 6e  ; we get here on
3f60: 20 22 64 72 6f 70 20 74 68 72 6f 75 67 68 22 20   "drop through" 
3f70: 2d 20 6c 6f 6f 70 20 66 6f 72 20 6e 65 78 74 20  - loop for next 
3f80: 74 65 73 74 20 69 6e 20 71 75 65 75 65 0a 20 20  test in queue.  
3f90: 20 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 74      (if (null? t
3fa0: 61 6c 29 0a 09 20 20 28 62 65 67 69 6e 0a 09 20  al)..  (begin.. 
3fb0: 20 20 20 3b 3b 20 46 49 58 4d 45 21 21 21 21 20     ;; FIXME!!!! 
3fc0: 54 48 49 53 20 53 48 4f 55 4c 44 20 4e 4f 54 20  THIS SHOULD NOT 
3fd0: 52 45 51 55 49 52 45 20 41 4e 20 45 58 49 54 21  REQUIRE AN EXIT!
3fe0: 21 21 21 21 21 21 0a 09 20 20 20 20 28 64 65 62  !!!!!!..    (deb
3ff0: 75 67 3a 70 72 69 6e 74 20 31 20 22 49 4e 46 4f  ug:print 1 "INFO
4000: 3a 20 41 6c 6c 20 74 65 73 74 73 20 6c 61 75 6e  : All tests laun
4010: 63 68 65 64 22 29 0a 09 20 20 20 20 3b 3b 20 28  ched")..    ;; (
4020: 65 78 69 74 20 30 29 0a 09 20 20 20 20 29 0a 09  exit 0)..    )..
4030: 20 20 28 6c 6f 6f 70 20 28 63 61 72 20 74 61 6c    (loop (car tal
4040: 29 28 63 64 72 20 74 61 6c 29 29 29 29 29 29 0a  )(cdr tal)))))).
4050: 0a 3b 3b 20 70 61 72 65 6e 74 2d 74 65 73 74 20  .;; parent-test 
4060: 69 73 20 74 68 65 72 65 20 61 73 20 61 20 70 6c  is there as a pl
4070: 61 63 65 68 6f 6c 64 65 72 20 66 6f 72 20 77 68  aceholder for wh
4080: 65 6e 20 70 61 72 65 6e 74 2d 74 65 73 74 73 20  en parent-tests 
4090: 63 61 6e 20 62 65 20 72 75 6e 20 61 73 20 61 20  can be run as a 
40a0: 73 65 74 75 70 20 73 74 65 70 0a 28 64 65 66 69  setup step.(defi
40b0: 6e 65 20 28 72 75 6e 3a 74 65 73 74 20 64 62 20  ne (run:test db 
40c0: 72 75 6e 2d 69 64 20 72 75 6e 6e 61 6d 65 20 6b  run-id runname k
40d0: 65 79 76 61 6c 6c 73 74 20 74 65 73 74 2d 72 65  eyvallst test-re
40e0: 63 6f 72 64 20 66 6c 61 67 73 20 70 61 72 65 6e  cord flags paren
40f0: 74 2d 74 65 73 74 29 0a 20 20 3b 3b 20 41 6c 6c  t-test).  ;; All
4100: 20 74 68 65 73 65 20 76 61 72 73 20 6d 69 67 68   these vars migh
4110: 74 20 62 65 20 72 65 66 65 72 65 6e 63 65 64 20  t be referenced 
4120: 62 79 20 74 68 65 20 74 65 73 74 63 6f 6e 66 69  by the testconfi
4130: 67 20 66 69 6c 65 20 72 65 61 64 65 72 0a 20 20  g file reader.  
4140: 28 6c 65 74 2a 20 28 28 74 65 73 74 2d 6e 61 6d  (let* ((test-nam
4150: 65 20 20 20 20 28 74 65 73 74 73 3a 74 65 73 74  e    (tests:test
4160: 71 75 65 75 65 2d 67 65 74 2d 74 65 73 74 6e 61  queue-get-testna
4170: 6d 65 20 20 20 74 65 73 74 2d 72 65 63 6f 72 64  me   test-record
4180: 29 29 0a 09 20 28 74 65 73 74 2d 77 61 69 74 6f  )).. (test-waito
4190: 6e 73 20 28 74 65 73 74 73 3a 74 65 73 74 71 75  ns (tests:testqu
41a0: 65 75 65 2d 67 65 74 2d 77 61 69 74 6f 6e 73 20  eue-get-waitons 
41b0: 20 20 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29     test-record))
41c0: 0a 09 20 28 74 65 73 74 2d 63 6f 6e 66 20 20 20  .. (test-conf   
41d0: 20 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75   (tests:testqueu
41e0: 65 2d 67 65 74 2d 74 65 73 74 63 6f 6e 66 69 67  e-get-testconfig
41f0: 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29 0a 09   test-record))..
4200: 20 28 69 74 65 6d 64 61 74 20 20 20 20 20 20 28   (itemdat      (
4210: 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d  tests:testqueue-
4220: 67 65 74 2d 69 74 65 6d 64 61 74 20 20 20 20 74  get-itemdat    t
4230: 65 73 74 2d 72 65 63 6f 72 64 29 29 0a 09 20 28  est-record)).. (
4240: 74 65 73 74 2d 70 61 74 68 20 20 20 20 28 63 6f  test-path    (co
4250: 6e 63 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f 74  nc *toppath* "/t
4260: 65 73 74 73 2f 22 20 74 65 73 74 2d 6e 61 6d 65  ests/" test-name
4270: 29 29 20 3b 3b 20 63 6f 75 6c 64 20 75 73 65 20  )) ;; could use 
4280: 74 65 73 74 3a 67 65 74 2d 74 65 73 74 63 6f 6e  test:get-testcon
4290: 66 69 67 20 68 65 72 65 20 2e 2e 2e 0a 09 20 28  fig here ..... (
42a0: 66 6f 72 63 65 20 20 20 20 20 20 20 20 28 68 61  force        (ha
42b0: 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66  sh-table-ref/def
42c0: 61 75 6c 74 20 66 6c 61 67 73 20 22 2d 66 6f 72  ault flags "-for
42d0: 63 65 22 20 23 66 29 29 0a 09 20 28 72 65 72 75  ce" #f)).. (reru
42e0: 6e 20 20 20 20 20 20 20 20 28 68 61 73 68 2d 74  n        (hash-t
42f0: 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74  able-ref/default
4300: 20 66 6c 61 67 73 20 22 2d 72 65 72 75 6e 22 20   flags "-rerun" 
4310: 23 66 29 29 0a 09 20 28 6b 65 65 70 67 6f 69 6e  #f)).. (keepgoin
4320: 67 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65  g    (hash-table
4330: 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 66 6c 61  -ref/default fla
4340: 67 73 20 22 2d 6b 65 65 70 67 6f 69 6e 67 22 20  gs "-keepgoing" 
4350: 23 66 29 29 0a 09 20 28 69 74 65 6d 2d 70 61 74  #f)).. (item-pat
4360: 68 20 20 20 20 20 22 22 29 29 0a 20 20 20 20 28  h     "")).    (
4370: 64 65 62 75 67 3a 70 72 69 6e 74 20 35 0a 09 09  debug:print 5...
4380: 20 22 74 65 73 74 2d 63 6f 6e 66 69 67 3a 20 22   "test-config: "
4390: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 3e 61 6c   (hash-table->al
43a0: 69 73 74 20 74 65 73 74 2d 63 6f 6e 66 29 0a 09  ist test-conf)..
43b0: 09 20 22 5c 6e 20 20 20 69 74 65 6d 64 61 74 3a  . "\n   itemdat:
43c0: 20 22 20 69 74 65 6d 64 61 74 0a 09 09 20 29 0a   " itemdat... ).
43d0: 20 20 20 20 3b 3b 20 73 65 74 74 69 6e 67 20 69      ;; setting i
43e0: 74 65 6d 64 61 74 20 74 6f 20 61 20 6c 69 73 74  temdat to a list
43f0: 20 69 66 20 69 74 20 69 73 20 23 66 0a 20 20 20   if it is #f.   
4400: 20 28 69 66 20 28 6e 6f 74 20 69 74 65 6d 64 61   (if (not itemda
4410: 74 29 28 73 65 74 21 20 69 74 65 6d 64 61 74 20  t)(set! itemdat 
4420: 27 28 29 29 29 0a 20 20 20 20 28 73 65 74 21 20  '())).    (set! 
4430: 69 74 65 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d  item-path (item-
4440: 6c 69 73 74 2d 3e 70 61 74 68 20 69 74 65 6d 64  list->path itemd
4450: 61 74 29 29 0a 20 20 20 20 28 64 65 62 75 67 3a  at)).    (debug:
4460: 70 72 69 6e 74 20 32 20 22 41 74 74 65 6d 70 74  print 2 "Attempt
4470: 69 6e 67 20 74 6f 20 6c 61 75 6e 63 68 20 74 65  ing to launch te
4480: 73 74 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22  st " test-name "
4490: 2f 22 20 69 74 65 6d 2d 70 61 74 68 29 0a 20 20  /" item-path).  
44a0: 20 20 28 73 65 74 65 6e 76 20 22 4d 54 5f 54 45    (setenv "MT_TE
44b0: 53 54 5f 4e 41 4d 45 22 20 74 65 73 74 2d 6e 61  ST_NAME" test-na
44c0: 6d 65 29 20 3b 3b 20 0a 20 20 20 20 28 73 65 74  me) ;; .    (set
44d0: 65 6e 76 20 22 4d 54 5f 52 55 4e 4e 41 4d 45 22  env "MT_RUNNAME"
44e0: 20 20 20 72 75 6e 6e 61 6d 65 29 0a 20 20 20 20     runname).    
44f0: 28 73 65 74 2d 6d 65 67 61 74 65 73 74 2d 65 6e  (set-megatest-en
4500: 76 2d 76 61 72 73 20 64 62 20 72 75 6e 2d 69 64  v-vars db run-id
4510: 29 20 3b 3b 20 74 68 65 73 65 20 6d 61 79 20 62  ) ;; these may b
4520: 65 20 6e 65 65 64 65 64 20 62 79 20 74 68 65 20  e needed by the 
4530: 6c 61 75 6e 63 68 69 6e 67 20 70 72 6f 63 65 73  launching proces
4540: 73 0a 20 20 20 20 28 63 68 61 6e 67 65 2d 64 69  s.    (change-di
4550: 72 65 63 74 6f 72 79 20 2a 74 6f 70 70 61 74 68  rectory *toppath
4560: 2a 29 0a 0a 20 20 20 20 3b 3b 20 48 65 72 65 20  *)..    ;; Here 
4570: 69 73 20 77 68 65 72 65 20 74 68 65 20 74 65 73  is where the tes
4580: 74 5f 6d 65 74 61 20 74 61 62 6c 65 20 69 73 20  t_meta table is 
4590: 62 65 73 74 20 75 70 64 61 74 65 64 0a 20 20 20  best updated.   
45a0: 20 3b 3b 20 59 65 73 2c 20 61 6e 6f 74 68 65 72   ;; Yes, another
45b0: 20 75 73 65 20 6f 66 20 61 20 67 6c 6f 62 61 6c   use of a global
45c0: 20 66 6f 72 20 63 61 63 68 69 6e 67 2e 20 4e 65   for caching. Ne
45d0: 65 64 20 61 20 62 65 74 74 65 72 20 77 61 79 3f  ed a better way?
45e0: 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28 68  .    (if (not (h
45f0: 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65  ash-table-ref/de
4600: 66 61 75 6c 74 20 2a 74 65 73 74 2d 6d 65 74 61  fault *test-meta
4610: 2d 75 70 64 61 74 65 64 2a 20 74 65 73 74 2d 6e  -updated* test-n
4620: 61 6d 65 20 23 66 29 29 0a 20 20 20 20 20 20 20  ame #f)).       
4630: 20 28 62 65 67 69 6e 0a 09 20 20 20 28 68 61 73   (begin..   (has
4640: 68 2d 74 61 62 6c 65 2d 73 65 74 21 20 2a 74 65  h-table-set! *te
4650: 73 74 2d 6d 65 74 61 2d 75 70 64 61 74 65 64 2a  st-meta-updated*
4660: 20 74 65 73 74 2d 6e 61 6d 65 20 23 74 29 0a 20   test-name #t). 
4670: 20 20 20 20 20 20 20 20 20 20 28 72 75 6e 73 3a            (runs:
4680: 75 70 64 61 74 65 2d 74 65 73 74 5f 6d 65 74 61  update-test_meta
4690: 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 20 74 65   db test-name te
46a0: 73 74 2d 63 6f 6e 66 29 29 29 0a 20 20 20 20 0a  st-conf))).    .
46b0: 20 20 20 20 3b 3b 20 28 6c 61 6d 62 64 61 20 28      ;; (lambda (
46c0: 69 74 65 6d 64 61 74 29 20 3b 3b 3b 20 28 28 72  itemdat) ;;; ((r
46d0: 69 70 65 6e 65 73 73 20 22 6f 76 65 72 72 69 70  ipeness "overrip
46e0: 65 22 29 20 28 74 65 6d 70 65 72 61 74 75 72 65  e") (temperature
46f0: 20 22 63 6f 6f 6c 22 29 20 28 73 65 61 73 6f 6e   "cool") (season
4700: 20 22 73 75 6d 6d 65 72 22 29 29 0a 20 20 20 20   "summer")).    
4710: 28 6c 65 74 2a 20 28 28 6e 65 77 2d 74 65 73 74  (let* ((new-test
4720: 2d 70 61 74 68 20 28 73 74 72 69 6e 67 2d 69 6e  -path (string-in
4730: 74 65 72 73 70 65 72 73 65 20 28 63 6f 6e 73 20  tersperse (cons 
4740: 74 65 73 74 2d 70 61 74 68 20 28 6d 61 70 20 63  test-path (map c
4750: 61 64 72 20 69 74 65 6d 64 61 74 29 29 20 22 2f  adr itemdat)) "/
4760: 22 29 29 0a 09 20 20 20 28 6e 65 77 2d 74 65 73  "))..   (new-tes
4770: 74 2d 6e 61 6d 65 20 28 69 66 20 28 65 71 75 61  t-name (if (equa
4780: 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29  l? item-path "")
4790: 20 74 65 73 74 2d 6e 61 6d 65 20 28 63 6f 6e 63   test-name (conc
47a0: 20 74 65 73 74 2d 6e 61 6d 65 20 22 2f 22 20 69   test-name "/" i
47b0: 74 65 6d 2d 70 61 74 68 29 29 29 20 3b 3b 20 6a  tem-path))) ;; j
47c0: 75 73 74 20 6e 65 65 64 20 69 74 20 74 6f 20 62  ust need it to b
47d0: 65 20 75 6e 69 71 75 65 0a 09 20 20 20 28 74 65  e unique..   (te
47e0: 73 74 64 61 74 20 20 20 20 20 20 20 28 64 62 3a  stdat       (db:
47f0: 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62  get-test-info db
4800: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
4810: 65 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 20  e item-path))). 
4820: 20 20 20 20 20 28 69 66 20 28 6e 6f 74 20 74 65       (if (not te
4830: 73 74 64 61 74 29 0a 09 20 20 28 62 65 67 69 6e  stdat)..  (begin
4840: 0a 09 20 20 20 20 3b 3b 20 65 6e 73 75 72 65 20  ..    ;; ensure 
4850: 74 68 61 74 20 74 68 65 20 70 61 74 68 20 65 78  that the path ex
4860: 69 73 74 73 20 62 65 66 6f 72 65 20 72 65 67 69  ists before regi
4870: 73 74 65 72 69 6e 67 20 74 68 65 20 74 65 73 74  stering the test
4880: 0a 09 20 20 20 20 3b 3b 20 4e 4f 50 45 3a 20 43  ..    ;; NOPE: C
4890: 61 6e 6e 6f 74 21 20 44 6f 6e 27 74 20 6b 6e 6f  annot! Don't kno
48a0: 77 20 79 65 74 20 77 68 69 63 68 20 64 69 73 6b  w yet which disk
48b0: 20 61 72 65 61 20 77 69 6c 6c 20 62 65 20 61 73   area will be as
48c0: 73 69 67 6e 65 64 2e 2e 2e 2e 0a 09 20 20 20 20  signed......    
48d0: 3b 3b 20 28 73 79 73 74 65 6d 20 28 63 6f 6e 63  ;; (system (conc
48e0: 20 22 6d 6b 64 69 72 20 2d 70 20 22 20 6e 65 77   "mkdir -p " new
48f0: 2d 74 65 73 74 2d 70 61 74 68 29 29 0a 09 20 20  -test-path))..  
4900: 20 20 28 72 74 65 73 74 73 3a 72 65 67 69 73 74    (rtests:regist
4910: 65 72 2d 74 65 73 74 20 64 62 20 72 75 6e 2d 69  er-test db run-i
4920: 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d  d test-name item
4930: 2d 70 61 74 68 29 0a 09 20 20 20 20 28 73 65 74  -path)..    (set
4940: 21 20 74 65 73 74 64 61 74 20 28 64 62 3a 67 65  ! testdat (db:ge
4950: 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 20 72  t-test-info db r
4960: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
4970: 69 74 65 6d 2d 70 61 74 68 29 29 29 29 0a 20 20  item-path)))).  
4980: 20 20 20 20 28 63 68 61 6e 67 65 2d 64 69 72 65      (change-dire
4990: 63 74 6f 72 79 20 74 65 73 74 2d 70 61 74 68 29  ctory test-path)
49a0: 0a 20 20 20 20 20 20 28 63 61 73 65 20 28 69 66  .      (case (if
49b0: 20 66 6f 72 63 65 20 3b 3b 20 28 61 72 67 73 3a   force ;; (args:
49c0: 67 65 74 2d 61 72 67 20 22 2d 66 6f 72 63 65 22  get-arg "-force"
49d0: 29 0a 09 09 27 4e 4f 54 5f 53 54 41 52 54 45 44  )...'NOT_STARTED
49e0: 0a 09 09 28 69 66 20 74 65 73 74 64 61 74 0a 09  ...(if testdat..
49f0: 09 20 20 20 20 28 73 74 72 69 6e 67 2d 3e 73 79  .    (string->sy
4a00: 6d 62 6f 6c 20 28 74 65 73 74 3a 67 65 74 2d 73  mbol (test:get-s
4a10: 74 61 74 65 20 74 65 73 74 64 61 74 29 29 0a 09  tate testdat))..
4a20: 09 20 20 20 20 27 66 61 69 6c 65 64 2d 74 6f 2d  .    'failed-to-
4a30: 69 6e 73 65 72 74 29 29 0a 09 28 28 66 61 69 6c  insert))..((fail
4a40: 65 64 2d 74 6f 2d 69 6e 73 65 72 74 29 0a 09 20  ed-to-insert).. 
4a50: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
4a60: 45 52 52 4f 52 3a 20 46 61 69 6c 65 64 20 74 6f  ERROR: Failed to
4a70: 20 69 6e 73 65 72 74 20 74 68 65 20 72 65 63 6f   insert the reco
4a80: 72 64 20 69 6e 74 6f 20 74 68 65 20 64 62 22 29  rd into the db")
4a90: 29 0a 09 28 28 4e 4f 54 5f 53 54 41 52 54 45 44  )..((NOT_STARTED
4aa0: 20 43 4f 4d 50 4c 45 54 45 44 29 0a 09 20 28 64   COMPLETED).. (d
4ab0: 65 62 75 67 3a 70 72 69 6e 74 20 36 20 22 47 6f  ebug:print 6 "Go
4ac0: 74 20 68 65 72 65 2c 20 22 20 28 74 65 73 74 3a  t here, " (test:
4ad0: 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61  get-state testda
4ae0: 74 29 29 0a 09 20 28 6c 65 74 20 28 28 72 75 6e  t)).. (let ((run
4af0: 66 6c 61 67 20 23 66 29 29 0a 09 20 20 20 28 63  flag #f))..   (c
4b00: 6f 6e 64 0a 09 20 20 20 20 3b 3b 20 2d 66 6f 72  ond..    ;; -for
4b10: 63 65 2c 20 72 75 6e 20 6e 6f 20 6d 61 74 74 65  ce, run no matte
4b20: 72 20 77 68 61 74 0a 09 20 20 20 20 28 66 6f 72  r what..    (for
4b30: 63 65 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67  ce (set! runflag
4b40: 20 23 74 29 29 0a 09 20 20 20 20 3b 3b 20 4e 4f   #t))..    ;; NO
4b50: 54 5f 53 54 41 52 54 45 44 2c 20 72 75 6e 20 6e  T_STARTED, run n
4b60: 6f 20 6d 61 74 74 65 72 20 77 68 61 74 0a 09 20  o matter what.. 
4b70: 20 20 20 28 28 65 71 75 61 6c 3f 20 28 74 65 73     ((equal? (tes
4b80: 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74  t:get-state test
4b90: 64 61 74 29 20 22 4e 4f 54 5f 53 54 41 52 54 45  dat) "NOT_STARTE
4ba0: 44 22 29 28 73 65 74 21 20 72 75 6e 66 6c 61 67  D")(set! runflag
4bb0: 20 23 74 29 29 0a 09 20 20 20 20 3b 3b 20 6e 6f   #t))..    ;; no
4bc0: 74 20 2d 72 65 72 75 6e 20 61 6e 64 20 50 41 53  t -rerun and PAS
4bd0: 53 2c 20 57 41 52 4e 20 6f 72 20 43 48 45 43 4b  S, WARN or CHECK
4be0: 2c 20 64 6f 20 6e 6f 20 72 75 6e 0a 09 20 20 20  , do no run..   
4bf0: 20 28 28 61 6e 64 20 28 6f 72 20 28 6e 6f 74 20   ((and (or (not 
4c00: 72 65 72 75 6e 29 0a 09 09 20 20 20 20 20 20 6b  rerun)...      k
4c10: 65 65 70 67 6f 69 6e 67 29 0a 09 09 20 20 3b 3b  eepgoing)...  ;;
4c20: 20 52 65 71 75 69 72 65 20 74 6f 20 66 6f 72 63   Require to forc
4c30: 65 20 72 65 2d 72 75 6e 20 66 6f 72 20 43 4f 4d  e re-run for COM
4c40: 50 4c 45 54 45 44 20 6f 72 20 2a 61 6e 79 74 68  PLETED or *anyth
4c50: 69 6e 67 2a 20 2b 20 50 41 53 53 2c 57 41 52 4e  ing* + PASS,WARN
4c60: 20 6f 72 20 43 48 45 43 4b 0a 09 09 20 20 28 6f   or CHECK...  (o
4c70: 72 20 28 6d 65 6d 62 65 72 20 28 74 65 73 74 3a  r (member (test:
4c80: 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64  get-status testd
4c90: 61 74 29 20 27 28 22 50 41 53 53 22 20 22 57 41  at) '("PASS" "WA
4ca0: 52 4e 22 20 22 43 48 45 43 4b 22 29 29 0a 09 09  RN" "CHECK"))...
4cb0: 20 20 20 20 20 20 28 6d 65 6d 62 65 72 20 28 74        (member (t
4cc0: 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 20 74  est:get-state  t
4cd0: 65 73 74 64 61 74 29 20 27 28 22 43 4f 4d 50 4c  estdat) '("COMPL
4ce0: 45 54 45 44 22 29 29 29 29 20 0a 09 20 20 20 20  ETED")))) ..    
4cf0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20   (debug:print 2 
4d00: 22 49 4e 46 4f 3a 20 72 75 6e 6e 69 6e 67 20 74  "INFO: running t
4d10: 65 73 74 20 22 20 74 65 73 74 2d 6e 61 6d 65 20  est " test-name 
4d20: 22 2f 22 20 69 74 65 6d 2d 70 61 74 68 20 22 20  "/" item-path " 
4d30: 73 75 70 70 72 65 73 73 65 64 20 61 73 20 69 74  suppressed as it
4d40: 20 69 73 20 43 4f 4d 50 4c 45 54 45 44 20 61 6e   is COMPLETED an
4d50: 64 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74  d " (test:get-st
4d60: 61 74 65 20 74 65 73 74 64 61 74 29 29 0a 09 20  ate testdat)).. 
4d70: 20 20 20 20 28 73 65 74 21 20 72 75 6e 66 6c 61      (set! runfla
4d80: 67 20 23 66 29 29 0a 09 20 20 20 20 3b 3b 20 2d  g #f))..    ;; -
4d90: 72 65 72 75 6e 20 61 6e 64 20 73 74 61 74 75 73  rerun and status
4da0: 20 69 73 20 6f 6e 65 20 6f 66 20 74 68 65 20 73   is one of the s
4db0: 70 65 63 69 66 65 64 2c 20 72 75 6e 20 69 74 0a  pecifed, run it.
4dc0: 09 20 20 20 20 28 28 61 6e 64 20 72 65 72 75 6e  .    ((and rerun
4dd0: 0a 09 09 20 20 28 6c 65 74 2a 20 28 28 72 65 72  ...  (let* ((rer
4de0: 75 6e 6c 73 74 20 20 20 28 73 74 72 69 6e 67 2d  unlst   (string-
4df0: 73 70 6c 69 74 20 72 65 72 75 6e 20 22 2c 22 29  split rerun ",")
4e00: 29 0a 09 09 09 20 28 6d 75 73 74 2d 72 65 72 75  ).... (must-reru
4e10: 6e 20 28 6d 65 6d 62 65 72 20 28 74 65 73 74 3a  n (member (test:
4e20: 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64  get-status testd
4e30: 61 74 29 20 72 65 72 75 6e 6c 73 74 29 29 29 0a  at) rerunlst))).
4e40: 09 09 20 20 20 20 28 64 65 62 75 67 3a 70 72 69  ..    (debug:pri
4e50: 6e 74 20 33 20 22 49 4e 46 4f 3a 20 2d 72 65 72  nt 3 "INFO: -rer
4e60: 75 6e 20 6c 69 73 74 3a 20 22 20 72 65 72 75 6e  un list: " rerun
4e70: 20 22 2c 20 74 65 73 74 2d 73 74 61 74 75 73 3a   ", test-status:
4e80: 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61   " (test:get-sta
4e90: 74 75 73 20 74 65 73 74 64 61 74 29 22 2c 20 6d  tus testdat)", m
4ea0: 75 73 74 2d 72 65 72 75 6e 3a 20 22 20 6d 75 73  ust-rerun: " mus
4eb0: 74 2d 72 65 72 75 6e 29 0a 09 09 20 20 20 20 6d  t-rerun)...    m
4ec0: 75 73 74 2d 72 65 72 75 6e 29 29 0a 09 20 20 20  ust-rerun))..   
4ed0: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32    (debug:print 2
4ee0: 20 22 49 4e 46 4f 3a 20 52 65 72 75 6e 20 66 6f   "INFO: Rerun fo
4ef0: 72 63 65 64 20 66 6f 72 20 74 65 73 74 20 22 20  rced for test " 
4f00: 74 65 73 74 2d 6e 61 6d 65 20 22 2f 22 20 69 74  test-name "/" it
4f10: 65 6d 2d 70 61 74 68 29 0a 09 20 20 20 20 20 28  em-path)..     (
4f20: 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 74 29  set! runflag #t)
4f30: 29 0a 09 20 20 20 20 3b 3b 20 2d 6b 65 65 70 67  )..    ;; -keepg
4f40: 6f 69 6e 67 2c 20 64 6f 20 6e 6f 74 20 72 65 72  oing, do not rer
4f50: 75 6e 20 46 41 49 4c 0a 09 20 20 20 20 28 28 61  un FAIL..    ((a
4f60: 6e 64 20 6b 65 65 70 67 6f 69 6e 67 0a 09 09 20  nd keepgoing... 
4f70: 20 28 6d 65 6d 62 65 72 20 28 74 65 73 74 3a 67   (member (test:g
4f80: 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61  et-status testda
4f90: 74 29 20 27 28 22 46 41 49 4c 22 29 29 29 0a 09  t) '("FAIL")))..
4fa0: 20 20 20 20 20 28 73 65 74 21 20 72 75 6e 66 6c       (set! runfl
4fb0: 61 67 20 23 66 29 29 0a 09 20 20 20 20 28 28 61  ag #f))..    ((a
4fc0: 6e 64 20 28 6e 6f 74 20 72 65 72 75 6e 29 0a 09  nd (not rerun)..
4fd0: 09 20 20 28 6d 65 6d 62 65 72 20 28 74 65 73 74  .  (member (test
4fe0: 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74  :get-status test
4ff0: 64 61 74 29 20 27 28 22 46 41 49 4c 22 20 22 6e  dat) '("FAIL" "n
5000: 2f 61 22 29 29 29 0a 09 20 20 20 20 20 28 73 65  /a")))..     (se
5010: 74 21 20 72 75 6e 66 6c 61 67 20 23 74 29 29 0a  t! runflag #t)).
5020: 09 20 20 20 20 28 65 6c 73 65 20 28 73 65 74 21  .    (else (set!
5030: 20 72 75 6e 66 6c 61 67 20 23 66 29 29 29 0a 09   runflag #f)))..
5040: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
5050: 36 20 22 52 55 4e 4e 49 4e 47 20 3d 3e 20 72 75  6 "RUNNING => ru
5060: 6e 66 6c 61 67 3a 20 22 20 72 75 6e 66 6c 61 67  nflag: " runflag
5070: 20 22 20 53 54 41 54 45 3a 20 22 20 28 74 65 73   " STATE: " (tes
5080: 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74  t:get-state test
5090: 64 61 74 29 20 22 20 53 54 41 54 55 53 3a 20 22  dat) " STATUS: "
50a0: 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75   (test:get-statu
50b0: 73 20 74 65 73 74 64 61 74 29 29 0a 09 20 20 20  s testdat))..   
50c0: 28 69 66 20 28 6e 6f 74 20 72 75 6e 66 6c 61 67  (if (not runflag
50d0: 29 0a 09 20 20 20 20 20 20 20 28 69 66 20 28 6e  )..       (if (n
50e0: 6f 74 20 70 61 72 65 6e 74 2d 74 65 73 74 29 0a  ot parent-test).
50f0: 09 09 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e  ..   (debug:prin
5100: 74 20 31 20 22 4e 4f 54 45 3a 20 4e 6f 74 20 73  t 1 "NOTE: Not s
5110: 74 61 72 74 69 6e 67 20 74 65 73 74 20 22 20 6e  tarting test " n
5120: 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20 22 20 61  ew-test-name " a
5130: 73 20 69 74 20 69 73 20 73 74 61 74 65 20 5c 22  s it is state \"
5140: 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74  " (test:get-stat
5150: 65 20 74 65 73 74 64 61 74 29 20 0a 09 09 09 09  e testdat) .....
5160: 22 5c 22 20 61 6e 64 20 73 74 61 74 75 73 20 5c  "\" and status \
5170: 22 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61  "" (test:get-sta
5180: 74 75 73 20 74 65 73 74 64 61 74 29 20 22 5c 22  tus testdat) "\"
5190: 2c 20 75 73 65 20 2d 72 65 72 75 6e 20 5c 22 22  , use -rerun \""
51a0: 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75   (test:get-statu
51b0: 73 20 74 65 73 74 64 61 74 29 0a 20 20 20 20 20  s testdat).     
51c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
51d0: 20 20 20 20 20 20 20 20 20 20 20 22 5c 22 20 6f             "\" o
51e0: 72 20 2d 66 6f 72 63 65 20 74 6f 20 6f 76 65 72  r -force to over
51f0: 72 69 64 65 22 29 29 0a 09 20 20 20 20 20 20 20  ride"))..       
5200: 3b 3b 20 4e 4f 54 45 3a 20 4e 6f 20 6c 6f 6e 67  ;; NOTE: No long
5210: 65 72 20 62 65 20 63 68 65 63 6b 69 6e 67 20 70  er be checking p
5220: 72 65 72 65 71 75 69 73 69 74 65 73 20 68 65 72  rerequisites her
5230: 65 21 20 57 69 6c 6c 20 6e 65 76 65 72 20 67 65  e! Will never ge
5240: 74 20 68 65 72 65 20 75 6e 6c 65 73 73 20 70 72  t here unless pr
5250: 65 72 65 71 73 20 61 72 65 0a 09 20 20 20 20 20  ereqs are..     
5260: 20 20 3b 3b 20 20 20 20 20 20 20 61 6c 72 65 61    ;;       alrea
5270: 64 79 20 6d 65 74 2e 0a 09 20 20 20 20 20 20 20  dy met...       
5280: 28 69 66 20 28 6e 6f 74 20 28 6c 61 75 6e 63 68  (if (not (launch
5290: 2d 74 65 73 74 20 64 62 20 72 75 6e 2d 69 64 20  -test db run-id 
52a0: 72 75 6e 6e 61 6d 65 20 74 65 73 74 2d 63 6f 6e  runname test-con
52b0: 66 20 6b 65 79 76 61 6c 6c 73 74 20 74 65 73 74  f keyvallst test
52c0: 2d 6e 61 6d 65 20 74 65 73 74 2d 70 61 74 68 20  -name test-path 
52d0: 69 74 65 6d 64 61 74 20 66 6c 61 67 73 29 29 0a  itemdat flags)).
52e0: 09 09 20 20 20 28 62 65 67 69 6e 0a 09 09 20 20  ..   (begin...  
52f0: 20 20 20 28 70 72 69 6e 74 20 22 45 52 52 4f 52     (print "ERROR
5300: 3a 20 46 61 69 6c 65 64 20 74 6f 20 6c 61 75 6e  : Failed to laun
5310: 63 68 20 74 68 65 20 74 65 73 74 2e 20 45 78 69  ch the test. Exi
5320: 74 69 6e 67 20 61 73 20 73 6f 6f 6e 20 61 73 20  ting as soon as 
5330: 70 6f 73 73 69 62 6c 65 22 29 0a 09 09 20 20 20  possible")...   
5340: 20 20 28 73 65 74 21 20 2a 67 6c 6f 62 61 6c 65    (set! *globale
5350: 78 69 74 73 74 61 74 75 73 2a 20 31 29 20 3b 3b  xitstatus* 1) ;;
5360: 20 0a 09 09 20 20 20 20 20 28 70 72 6f 63 65 73   ...     (proces
5370: 73 2d 73 69 67 6e 61 6c 20 28 63 75 72 72 65 6e  s-signal (curren
5380: 74 2d 70 72 6f 63 65 73 73 2d 69 64 29 20 73 69  t-process-id) si
5390: 67 6e 61 6c 2f 6b 69 6c 6c 29 29 29 29 29 29 0a  gnal/kill)))))).
53a0: 09 28 28 4b 49 4c 4c 45 44 29 20 0a 09 20 28 64  .((KILLED) .. (d
53b0: 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 4e 4f  ebug:print 1 "NO
53c0: 54 45 3a 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e  TE: " new-test-n
53d0: 61 6d 65 20 22 20 69 73 20 61 6c 72 65 61 64 79  ame " is already
53e0: 20 72 75 6e 6e 69 6e 67 20 6f 72 20 77 61 73 20   running or was 
53f0: 65 78 70 6c 69 63 74 6c 79 20 6b 69 6c 6c 65 64  explictly killed
5400: 2c 20 75 73 65 20 2d 66 6f 72 63 65 20 74 6f 20  , use -force to 
5410: 6c 61 75 6e 63 68 20 69 74 2e 22 29 29 0a 09 28  launch it."))..(
5420: 28 4c 41 55 4e 43 48 45 44 20 52 45 4d 4f 54 45  (LAUNCHED REMOTE
5430: 48 4f 53 54 53 54 41 52 54 20 52 55 4e 4e 49 4e  HOSTSTART RUNNIN
5440: 47 29 20 20 0a 09 20 28 69 66 20 28 3e 20 28 2d  G)  .. (if (> (-
5450: 20 28 63 75 72 72 65 6e 74 2d 73 65 63 6f 6e 64   (current-second
5460: 73 29 28 2b 20 28 64 62 3a 74 65 73 74 2d 67 65  s)(+ (db:test-ge
5470: 74 2d 65 76 65 6e 74 5f 74 69 6d 65 20 74 65 73  t-event_time tes
5480: 74 64 61 74 29 0a 09 09 09 09 20 20 20 20 20 20  tdat).....      
5490: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 72 75   (db:test-get-ru
54a0: 6e 5f 64 75 72 61 74 69 6f 6e 20 74 65 73 74 64  n_duration testd
54b0: 61 74 29 29 29 0a 09 09 36 30 30 29 20 3b 3b 20  at)))...600) ;; 
54c0: 69 2e 65 2e 20 6e 6f 20 75 70 64 61 74 65 20 66  i.e. no update f
54d0: 6f 72 20 6d 6f 72 65 20 74 68 61 6e 20 36 30 30  or more than 600
54e0: 20 73 65 63 6f 6e 64 73 0a 09 20 20 20 20 20 28   seconds..     (
54f0: 62 65 67 69 6e 0a 09 20 20 20 20 20 20 20 28 64  begin..       (d
5500: 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41  ebug:print 0 "WA
5510: 52 4e 49 4e 47 3a 20 54 65 73 74 20 22 20 74 65  RNING: Test " te
5520: 73 74 2d 6e 61 6d 65 20 22 20 61 70 70 65 61 72  st-name " appear
5530: 73 20 74 6f 20 62 65 20 64 65 61 64 2e 20 46 6f  s to be dead. Fo
5540: 72 63 69 6e 67 20 69 74 20 74 6f 20 73 74 61 74  rcing it to stat
5550: 65 20 49 4e 43 4f 4d 50 4c 45 54 45 20 61 6e 64  e INCOMPLETE and
5560: 20 73 74 61 74 75 73 20 53 54 55 43 4b 2f 44 45   status STUCK/DE
5570: 41 44 22 29 0a 09 20 20 20 20 20 20 20 28 74 65  AD")..       (te
5580: 73 74 2d 73 65 74 2d 73 74 61 74 75 73 21 20 64  st-set-status! d
5590: 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  b run-id test-na
55a0: 6d 65 20 22 49 4e 43 4f 4d 50 4c 45 54 45 22 20  me "INCOMPLETE" 
55b0: 22 53 54 55 43 4b 2f 44 45 41 44 22 20 69 74 65  "STUCK/DEAD" ite
55c0: 6d 64 61 74 20 22 54 65 73 74 20 69 73 20 73 74  mdat "Test is st
55d0: 75 63 6b 20 6f 72 20 64 65 61 64 22 20 23 66 29  uck or dead" #f)
55e0: 29 0a 09 20 20 20 20 20 28 64 65 62 75 67 3a 70  )..     (debug:p
55f0: 72 69 6e 74 20 32 20 22 4e 4f 54 45 3a 20 22 20  rint 2 "NOTE: " 
5600: 74 65 73 74 2d 6e 61 6d 65 20 22 20 69 73 20 61  test-name " is a
5610: 6c 72 65 61 64 79 20 72 75 6e 6e 69 6e 67 22 29  lready running")
5620: 29 29 0a 09 28 65 6c 73 65 20 20 20 20 20 20 20  ))..(else       
5630: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
5640: 45 52 52 4f 52 3a 20 46 61 69 6c 65 64 20 74 6f  ERROR: Failed to
5650: 20 6c 61 75 6e 63 68 20 74 65 73 74 20 22 20 6e   launch test " n
5660: 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20 22 2e 20  ew-test-name ". 
5670: 55 6e 72 65 63 6f 67 6e 69 73 65 64 20 73 74 61  Unrecognised sta
5680: 74 65 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73  te " (test:get-s
5690: 74 61 74 65 20 74 65 73 74 64 61 74 29 29 29 29  tate testdat))))
56a0: 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d  )))..;;=========
56b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
56c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
56d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
56e0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b  =============.;;
56f0: 20 45 4e 44 20 4f 46 20 4e 45 57 20 53 54 55 46   END OF NEW STUF
5700: 46 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  F.;;============
5710: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5720: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5730: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5740: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 28 64 65 66  ==========..(def
5750: 69 6e 65 20 28 67 65 74 2d 64 69 72 2d 75 70 2d  ine (get-dir-up-
5760: 6e 20 64 69 72 20 2e 20 70 61 72 61 6d 73 29 20  n dir . params) 
5770: 0a 20 20 28 6c 65 74 20 28 28 64 70 61 72 74 73  .  (let ((dparts
5780: 20 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20    (string-split 
5790: 64 69 72 20 22 2f 22 29 29 0a 09 28 63 6f 75 6e  dir "/"))..(coun
57a0: 74 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 70  t   (if (null? p
57b0: 61 72 61 6d 73 29 20 31 20 28 63 61 72 20 70 61  arams) 1 (car pa
57c0: 72 61 6d 73 29 29 29 29 0a 20 20 20 20 28 63 6f  rams)))).    (co
57d0: 6e 63 20 22 2f 22 20 28 73 74 72 69 6e 67 2d 69  nc "/" (string-i
57e0: 6e 74 65 72 73 70 65 72 73 65 20 0a 09 20 20 20  ntersperse ..   
57f0: 20 20 20 20 28 74 61 6b 65 20 64 70 61 72 74 73      (take dparts
5800: 20 28 2d 20 28 6c 65 6e 67 74 68 20 64 70 61 72   (- (length dpar
5810: 74 73 29 20 63 6f 75 6e 74 29 29 0a 09 20 20 20  ts) count))..   
5820: 20 20 20 20 22 2f 22 29 29 29 29 0a 3b 3b 20 52      "/")))).;; R
5830: 65 6d 6f 76 65 20 72 75 6e 73 0a 3b 3b 20 66 69  emove runs.;; fi
5840: 65 6c 64 73 20 61 72 65 20 70 61 73 73 69 6e 67  elds are passing
5850: 20 69 6e 20 74 68 72 6f 75 67 68 20 0a 28 64 65   in through .(de
5860: 66 69 6e 65 20 28 72 75 6e 73 3a 72 65 6d 6f 76  fine (runs:remov
5870: 65 2d 72 75 6e 73 20 64 62 20 72 75 6e 6e 61 6d  e-runs db runnam
5880: 65 70 61 74 74 20 74 65 73 74 70 61 74 74 20 69  epatt testpatt i
5890: 74 65 6d 70 61 74 74 29 0a 20 20 28 6c 65 74 2a  tempatt).  (let*
58a0: 20 28 28 6b 65 79 73 20 20 20 20 20 20 20 20 28   ((keys        (
58b0: 72 64 62 3a 67 65 74 2d 6b 65 79 73 20 64 62 29  rdb:get-keys db)
58c0: 29 0a 09 20 28 72 75 6e 64 61 74 20 20 20 20 20  ).. (rundat     
58d0: 20 28 72 75 6e 73 3a 67 65 74 2d 72 75 6e 73 2d   (runs:get-runs-
58e0: 62 79 2d 70 61 74 74 20 64 62 20 6b 65 79 73 20  by-patt db keys 
58f0: 72 75 6e 6e 61 6d 65 70 61 74 74 29 29 0a 09 20  runnamepatt)).. 
5900: 28 68 65 61 64 65 72 20 20 20 20 20 20 28 76 65  (header      (ve
5910: 63 74 6f 72 2d 72 65 66 20 72 75 6e 64 61 74 20  ctor-ref rundat 
5920: 30 29 29 0a 09 20 28 72 75 6e 73 20 20 20 20 20  0)).. (runs     
5930: 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20 72     (vector-ref r
5940: 75 6e 64 61 74 20 31 29 29 29 0a 20 20 20 20 28  undat 1))).    (
5950: 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 48  debug:print 1 "H
5960: 65 61 64 65 72 3a 20 22 20 68 65 61 64 65 72 29  eader: " header)
5970: 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 0a 20  .    (for-each. 
5980: 20 20 20 20 28 6c 61 6d 62 64 61 20 28 72 75 6e      (lambda (run
5990: 29 0a 20 20 20 20 20 20 20 28 6c 65 74 20 28 28  ).       (let ((
59a0: 72 75 6e 6b 65 79 20 28 73 74 72 69 6e 67 2d 69  runkey (string-i
59b0: 6e 74 65 72 73 70 65 72 73 65 20 28 6d 61 70 20  ntersperse (map 
59c0: 28 6c 61 6d 62 64 61 20 28 6b 29 0a 09 09 09 09  (lambda (k).....
59d0: 09 09 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d  ..(db:get-value-
59e0: 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65  by-header run he
59f0: 61 64 65 72 20 28 76 65 63 74 6f 72 2d 72 65 66  ader (vector-ref
5a00: 20 6b 20 30 29 29 29 20 6b 65 79 73 29 20 22 2f   k 0))) keys) "/
5a10: 22 29 29 0a 09 20 20 20 20 20 28 64 69 72 73 2d  "))..     (dirs-
5a20: 74 6f 2d 72 65 6d 6f 76 65 20 28 6d 61 6b 65 2d  to-remove (make-
5a30: 68 61 73 68 2d 74 61 62 6c 65 29 29 29 0a 09 20  hash-table))).. 
5a40: 28 6c 65 74 2a 20 28 28 72 75 6e 2d 69 64 20 28  (let* ((run-id (
5a50: 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d  db:get-value-by-
5a60: 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65  header run heade
5a70: 72 20 22 69 64 22 29 20 29 0a 09 09 28 74 65 73  r "id") )...(tes
5a80: 74 73 20 20 28 72 64 62 3a 67 65 74 2d 74 65 73  ts  (rdb:get-tes
5a90: 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 28 64  ts-for-run db (d
5aa0: 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68  b:get-value-by-h
5ab0: 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65 72  eader run header
5ac0: 20 22 69 64 22 29 20 74 65 73 74 70 61 74 74 20   "id") testpatt 
5ad0: 69 74 65 6d 70 61 74 74 20 27 28 29 20 27 28 29  itempatt '() '()
5ae0: 29 29 0a 09 09 28 6c 61 73 74 74 70 61 74 68 20  ))...(lasttpath 
5af0: 22 2f 64 6f 65 73 2f 6e 6f 74 2f 65 78 69 73 74  "/does/not/exist
5b00: 2f 49 2f 68 6f 70 65 22 29 29 0a 0a 09 20 20 20  /I/hope"))...   
5b10: 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20  (if (not (null? 
5b20: 74 65 73 74 73 29 29 0a 09 20 20 20 20 20 20 20  tests))..       
5b30: 28 62 65 67 69 6e 0a 09 09 20 28 64 65 62 75 67  (begin... (debug
5b40: 3a 70 72 69 6e 74 20 31 20 22 52 65 6d 6f 76 69  :print 1 "Removi
5b50: 6e 67 20 74 65 73 74 73 20 66 6f 72 20 72 75 6e  ng tests for run
5b60: 3a 20 22 20 72 75 6e 6b 65 79 20 22 20 22 20 28  : " runkey " " (
5b70: 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d  db:get-value-by-
5b80: 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65  header run heade
5b90: 72 20 22 72 75 6e 6e 61 6d 65 22 29 29 0a 09 09  r "runname"))...
5ba0: 20 28 66 6f 72 2d 65 61 63 68 0a 09 09 20 20 28   (for-each...  (
5bb0: 6c 61 6d 62 64 61 20 28 74 65 73 74 29 0a 09 09  lambda (test)...
5bc0: 20 20 20 20 28 6c 65 74 2a 20 28 28 69 74 65 6d      (let* ((item
5bd0: 2d 70 61 74 68 20 28 64 62 3a 74 65 73 74 2d 67  -path (db:test-g
5be0: 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73  et-item-path tes
5bf0: 74 29 29 0a 09 09 09 20 20 20 28 74 65 73 74 2d  t))....   (test-
5c00: 6e 61 6d 65 20 28 64 62 3a 74 65 73 74 2d 67 65  name (db:test-ge
5c10: 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 29  t-testname test)
5c20: 29 0a 09 09 09 20 20 20 28 72 75 6e 2d 64 69 72  )....   (run-dir
5c30: 20 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d     (db:test-get-
5c40: 72 75 6e 64 69 72 20 74 65 73 74 29 29 29 0a 09  rundir test)))..
5c50: 09 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72  .      (debug:pr
5c60: 69 6e 74 20 31 20 22 20 20 22 20 28 64 62 3a 74  int 1 "  " (db:t
5c70: 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65  est-get-testname
5c80: 20 74 65 73 74 29 20 22 20 69 64 3a 20 22 20 28   test) " id: " (
5c90: 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74  db:test-get-id t
5ca0: 65 73 74 29 20 22 20 22 20 69 74 65 6d 2d 70 61  est) " " item-pa
5cb0: 74 68 29 0a 09 09 20 20 20 20 20 20 28 72 64 62  th)...      (rdb
5cc0: 3a 64 65 6c 65 74 65 2d 74 65 73 74 2d 72 65 63  :delete-test-rec
5cd0: 6f 72 64 73 20 64 62 20 28 64 62 3a 74 65 73 74  ords db (db:test
5ce0: 2d 67 65 74 2d 69 64 20 74 65 73 74 29 29 0a 09  -get-id test))..
5cf0: 09 20 20 20 20 20 20 28 69 66 20 28 3e 20 28 73  .      (if (> (s
5d00: 74 72 69 6e 67 2d 6c 65 6e 67 74 68 20 72 75 6e  tring-length run
5d10: 2d 64 69 72 29 20 35 29 20 3b 3b 20 62 61 64 20  -dir) 5) ;; bad 
5d20: 68 65 75 72 69 73 74 69 63 20 62 75 74 20 73 68  heuristic but sh
5d30: 6f 75 6c 64 20 70 72 65 76 65 6e 74 20 2f 74 6d  ould prevent /tm
5d40: 70 20 2f 68 6f 6d 65 20 65 74 63 2e 0a 09 09 09  p /home etc.....
5d50: 20 20 28 6c 65 74 20 28 28 66 75 6c 6c 70 61 74    (let ((fullpat
5d60: 68 20 72 75 6e 2d 64 69 72 29 29 20 3b 3b 20 22  h run-dir)) ;; "
5d70: 2f 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  /" (db:test-get-
5d80: 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 29 29  item-path test))
5d90: 29 29 0a 09 09 09 20 20 20 20 28 73 65 74 21 20  ))....    (set! 
5da0: 6c 61 73 74 74 70 61 74 68 20 66 75 6c 6c 70 61  lasttpath fullpa
5db0: 74 68 29 0a 09 09 09 20 20 20 20 28 68 61 73 68  th)....    (hash
5dc0: 2d 74 61 62 6c 65 2d 73 65 74 21 20 64 69 72 73  -table-set! dirs
5dd0: 2d 74 6f 2d 72 65 6d 6f 76 65 20 66 75 6c 6c 70  -to-remove fullp
5de0: 61 74 68 20 23 74 29 0a 09 09 09 20 20 20 20 3b  ath #t)....    ;
5df0: 3b 20 54 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20  ; The following 
5e00: 77 61 73 20 74 68 65 20 73 61 66 65 20 64 65 6c  was the safe del
5e10: 65 74 65 20 63 6f 64 65 20 62 75 74 20 69 74 20  ete code but it 
5e20: 77 61 73 20 6e 6f 74 20 62 65 69 6e 67 20 65 78  was not being ex
5e30: 65 63 74 75 74 65 64 2e 0a 09 09 09 20 20 20 20  ectuted.....    
5e40: 3b 3b 20 28 6c 65 74 2a 20 28 28 64 69 72 73 2d  ;; (let* ((dirs-
5e50: 63 6f 75 6e 74 20 28 2b 20 31 20 28 6c 65 6e 67  count (+ 1 (leng
5e60: 74 68 20 6b 65 79 73 29 28 6c 65 6e 67 74 68 20  th keys)(length 
5e70: 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 69 74  (string-split it
5e80: 65 6d 2d 70 61 74 68 20 22 2f 22 29 29 29 29 0a  em-path "/")))).
5e90: 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20 20 20  ...    ;;       
5ea0: 20 28 64 69 72 2d 74 6f 2d 72 65 6d 20 28 67 65   (dir-to-rem (ge
5eb0: 74 2d 64 69 72 2d 75 70 2d 6e 20 66 75 6c 6c 70  t-dir-up-n fullp
5ec0: 61 74 68 20 64 69 72 73 2d 63 6f 75 6e 74 29 29  ath dirs-count))
5ed0: 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20 20  ....    ;;      
5ee0: 20 20 28 72 65 6d 61 69 6e 69 6e 67 64 20 28 73    (remainingd (s
5ef0: 74 72 69 6e 67 2d 73 75 62 73 74 69 74 75 74 65  tring-substitute
5f00: 20 28 72 65 67 65 78 70 20 28 63 6f 6e 63 20 22   (regexp (conc "
5f10: 5e 22 20 64 69 72 2d 74 6f 2d 72 65 6d 20 22 2f  ^" dir-to-rem "/
5f20: 22 29 29 20 22 22 20 66 75 6c 6c 70 61 74 68 29  ")) "" fullpath)
5f30: 29 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20  )....    ;;     
5f40: 20 20 20 28 63 6d 64 20 28 63 6f 6e 63 20 22 63     (cmd (conc "c
5f50: 64 20 22 20 64 69 72 2d 74 6f 2d 72 65 6d 20 22  d " dir-to-rem "
5f60: 3b 20 72 6d 64 69 72 20 2d 70 20 22 20 72 65 6d  ; rmdir -p " rem
5f70: 61 69 6e 69 6e 67 64 20 29 29 29 0a 09 09 09 20  ainingd ))).... 
5f80: 20 20 20 3b 3b 20 20 20 28 69 66 20 28 66 69 6c     ;;   (if (fil
5f90: 65 2d 65 78 69 73 74 73 3f 20 66 75 6c 6c 70 61  e-exists? fullpa
5fa0: 74 68 29 0a 09 09 09 20 20 20 20 3b 3b 20 20 20  th)....    ;;   
5fb0: 20 20 20 20 28 62 65 67 69 6e 0a 09 09 09 20 20      (begin....  
5fc0: 20 20 3b 3b 20 20 20 20 20 20 20 20 20 28 64 65    ;;         (de
5fd0: 62 75 67 3a 70 72 69 6e 74 20 31 20 63 6d 64 29  bug:print 1 cmd)
5fe0: 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20 20  ....    ;;      
5ff0: 20 20 20 28 73 79 73 74 65 6d 20 63 6d 64 29 29     (system cmd))
6000: 29 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 29 29  )....    ;;   ))
6010: 0a 09 09 09 20 20 20 20 29 29 29 29 0a 09 09 20  ....    ))))... 
6020: 20 20 20 74 65 73 74 73 29 29 29 0a 0a 09 20 20     tests)))...  
6030: 20 3b 3b 20 6c 6f 6f 6b 20 74 68 6f 75 67 68 20   ;; look though 
6040: 74 68 65 20 64 69 72 73 2d 74 6f 2d 72 65 6d 6f  the dirs-to-remo
6050: 76 65 20 66 6f 72 20 63 61 6e 64 69 64 61 74 65  ve for candidate
6060: 73 20 66 6f 72 20 72 65 6d 6f 76 61 6c 2e 20 44  s for removal. D
6070: 6f 20 74 68 69 73 20 61 66 74 65 72 20 64 65 6c  o this after del
6080: 65 74 69 6e 67 20 74 68 65 20 72 65 63 6f 72 64  eting the record
6090: 73 0a 09 20 20 20 3b 3b 20 66 6f 72 20 65 61 63  s..   ;; for eac
60a0: 68 20 74 65 73 74 20 69 6e 20 63 61 73 65 20 77  h test in case w
60b0: 65 20 67 65 74 20 6b 69 6c 6c 65 64 2e 20 54 68  e get killed. Th
60c0: 61 74 20 73 68 6f 75 6c 64 20 6d 69 6e 69 6d 69  at should minimi
60d0: 7a 65 20 74 68 65 20 64 65 74 72 69 74 75 73 20  ze the detritus 
60e0: 6c 65 66 74 20 6f 6e 20 64 69 73 6b 0a 09 20 20  left on disk..  
60f0: 20 3b 3b 20 70 72 6f 63 65 73 73 20 74 68 65 20   ;; process the 
6100: 64 69 72 73 20 66 72 6f 6d 20 6c 6f 6e 67 65 73  dirs from longes
6110: 74 20 73 74 72 69 6e 67 20 6c 65 6e 67 74 68 20  t string length 
6120: 74 6f 20 73 68 6f 72 74 65 73 74 0a 09 20 20 20  to shortest..   
6130: 28 66 6f 72 2d 65 61 63 68 20 0a 09 20 20 20 20  (for-each ..    
6140: 28 6c 61 6d 62 64 61 20 28 64 69 72 2d 74 6f 2d  (lambda (dir-to-
6150: 72 65 6d 6f 76 65 29 0a 09 20 20 20 20 20 20 28  remove)..      (
6160: 69 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f  if (file-exists?
6170: 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 0a   dir-to-remove).
6180: 09 09 20 20 28 6c 65 74 20 28 28 64 69 72 2d 69  ..  (let ((dir-i
6190: 6e 2d 64 62 20 27 28 29 29 29 0a 09 09 20 20 20  n-db '()))...   
61a0: 20 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61   (sqlite3:for-ea
61b0: 63 68 2d 72 6f 77 0a 09 09 20 20 20 20 20 28 6c  ch-row...     (l
61c0: 61 6d 62 64 61 20 28 64 69 72 29 0a 09 09 20 20  ambda (dir)...  
61d0: 20 20 20 20 20 28 73 65 74 21 20 64 69 72 2d 69       (set! dir-i
61e0: 6e 2d 64 62 20 28 63 6f 6e 73 20 64 69 72 20 64  n-db (cons dir d
61f0: 69 72 2d 69 6e 2d 64 62 29 29 29 0a 09 09 20 20  ir-in-db)))...  
6200: 20 20 20 64 62 20 22 53 45 4c 45 43 54 20 72 75     db "SELECT ru
6210: 6e 64 69 72 20 46 52 4f 4d 20 74 65 73 74 73 20  ndir FROM tests 
6220: 57 48 45 52 45 20 72 75 6e 64 69 72 20 4c 49 4b  WHERE rundir LIK
6230: 45 20 3f 3b 22 20 0a 09 09 20 20 20 20 20 28 63  E ?;" ...     (c
6240: 6f 6e 63 20 22 25 22 20 64 69 72 2d 74 6f 2d 72  onc "%" dir-to-r
6250: 65 6d 6f 76 65 20 22 25 22 29 29 20 3b 3b 20 79  emove "%")) ;; y
6260: 65 73 2c 20 49 27 6d 20 67 6f 69 6e 67 20 74 6f  es, I'm going to
6270: 20 62 61 69 6c 20 69 66 20 74 68 65 72 65 20 69   bail if there i
6280: 73 20 61 6e 79 74 68 69 6e 67 20 6c 69 6b 65 20  s anything like 
6290: 74 68 69 73 20 64 69 72 20 69 6e 20 74 68 65 20  this dir in the 
62a0: 64 62 0a 09 09 20 20 20 20 28 69 66 20 28 6e 75  db...    (if (nu
62b0: 6c 6c 3f 20 64 69 72 2d 69 6e 2d 64 62 29 0a 09  ll? dir-in-db)..
62c0: 09 09 28 62 65 67 69 6e 0a 09 09 09 20 20 28 64  ..(begin....  (d
62d0: 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 52 65  ebug:print 2 "Re
62e0: 6d 6f 76 69 6e 67 20 64 69 72 65 63 74 6f 72 79  moving directory
62f0: 20 77 69 74 68 20 7a 65 72 6f 20 64 62 20 72 65   with zero db re
6300: 66 65 72 65 6e 63 65 73 3a 20 22 20 64 69 72 2d  ferences: " dir-
6310: 74 6f 2d 72 65 6d 6f 76 65 29 0a 09 09 09 20 20  to-remove)....  
6320: 28 73 79 73 74 65 6d 20 28 63 6f 6e 63 20 22 72  (system (conc "r
6330: 6d 20 2d 72 66 20 22 20 64 69 72 2d 74 6f 2d 72  m -rf " dir-to-r
6340: 65 6d 6f 76 65 29 29 0a 09 09 09 20 20 28 68 61  emove))....  (ha
6350: 73 68 2d 74 61 62 6c 65 2d 64 65 6c 65 74 65 21  sh-table-delete!
6360: 20 64 69 72 73 2d 74 6f 2d 72 65 6d 6f 76 65 20   dirs-to-remove 
6370: 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 29 0a  dir-to-remove)).
6380: 09 09 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20  ...(debug:print 
6390: 32 20 22 53 6b 69 70 70 69 6e 67 20 72 65 6d 6f  2 "Skipping remo
63a0: 76 61 6c 20 6f 66 20 22 20 64 69 72 2d 74 6f 2d  val of " dir-to-
63b0: 72 65 6d 6f 76 65 20 22 20 66 6f 72 20 6e 6f 77  remove " for now
63c0: 20 61 73 20 69 74 20 73 74 69 6c 6c 20 68 61 73   as it still has
63d0: 20 72 65 66 65 72 65 6e 63 65 73 20 69 6e 20 74   references in t
63e0: 68 65 20 64 61 74 61 62 61 73 65 22 29 29 29 29  he database"))))
63f0: 29 0a 09 20 20 20 20 28 73 6f 72 74 20 28 68 61  )..    (sort (ha
6400: 73 68 2d 74 61 62 6c 65 2d 6b 65 79 73 20 64 69  sh-table-keys di
6410: 72 73 2d 74 6f 2d 72 65 6d 6f 76 65 29 20 28 6c  rs-to-remove) (l
6420: 61 6d 62 64 61 20 28 61 20 62 29 28 3e 20 28 73  ambda (a b)(> (s
6430: 74 72 69 6e 67 2d 6c 65 6e 67 74 68 20 61 29 28  tring-length a)(
6440: 73 74 72 69 6e 67 2d 6c 65 6e 67 74 68 20 62 29  string-length b)
6450: 29 29 29 29 0a 0a 09 20 20 20 3b 3b 20 72 65 6d  ))))...   ;; rem
6460: 6f 76 65 20 74 68 65 20 72 75 6e 20 69 66 20 7a  ove the run if z
6470: 65 72 6f 20 74 65 73 74 73 20 72 65 6d 61 69 6e  ero tests remain
6480: 0a 09 20 20 20 28 6c 65 74 20 28 28 72 65 6d 74  ..   (let ((remt
6490: 65 73 74 73 20 28 72 64 62 3a 67 65 74 2d 74 65  ests (rdb:get-te
64a0: 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 28  sts-for-run db (
64b0: 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d  db:get-value-by-
64c0: 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65  header run heade
64d0: 72 20 22 69 64 22 29 20 23 66 20 23 66 20 27 28  r "id") #f #f '(
64e0: 29 20 27 28 29 29 29 29 0a 09 20 20 20 20 20 28  ) '())))..     (
64f0: 69 66 20 28 6e 75 6c 6c 3f 20 72 65 6d 74 65 73  if (null? remtes
6500: 74 73 29 20 3b 3b 20 6e 6f 20 6d 6f 72 65 20 74  ts) ;; no more t
6510: 65 73 74 73 20 72 65 6d 61 69 6e 69 6e 67 0a 09  ests remaining..
6520: 09 20 28 6c 65 74 2a 20 28 28 64 70 61 72 74 73  . (let* ((dparts
6530: 20 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20    (string-split 
6540: 6c 61 73 74 74 70 61 74 68 20 22 2f 22 29 29 0a  lasttpath "/")).
6550: 09 09 09 28 72 75 6e 70 61 74 68 20 28 63 6f 6e  ...(runpath (con
6560: 63 20 22 2f 22 20 28 73 74 72 69 6e 67 2d 69 6e  c "/" (string-in
6570: 74 65 72 73 70 65 72 73 65 20 0a 09 09 09 09 09  tersperse ......
6580: 20 20 20 20 28 74 61 6b 65 20 64 70 61 72 74 73      (take dparts
6590: 20 28 2d 20 28 6c 65 6e 67 74 68 20 64 70 61 72   (- (length dpar
65a0: 74 73 29 20 31 29 29 0a 09 09 09 09 09 20 20 20  ts) 1))......   
65b0: 20 22 2f 22 29 29 29 29 0a 09 09 20 20 20 28 64   "/"))))...   (d
65c0: 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 52 65  ebug:print 1 "Re
65d0: 6d 6f 76 69 6e 67 20 72 75 6e 3a 20 22 20 72 75  moving run: " ru
65e0: 6e 6b 65 79 20 22 20 22 20 28 64 62 3a 67 65 74  nkey " " (db:get
65f0: 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72  -value-by-header
6600: 20 72 75 6e 20 68 65 61 64 65 72 20 22 72 75 6e   run header "run
6610: 6e 61 6d 65 22 29 29 0a 09 09 20 20 20 28 64 62  name"))...   (db
6620: 3a 64 65 6c 65 74 65 2d 72 75 6e 20 64 62 20 72  :delete-run db r
6630: 75 6e 2d 69 64 29 0a 09 09 20 20 20 3b 3b 20 6e  un-id)...   ;; n
6640: 65 65 64 20 74 6f 20 66 69 67 75 72 65 20 6f 75  eed to figure ou
6650: 74 20 74 68 65 20 70 61 74 68 20 74 6f 20 74 68  t the path to th
6660: 65 20 72 75 6e 20 64 69 72 20 61 6e 64 20 72 65  e run dir and re
6670: 6d 6f 76 65 20 69 74 20 69 66 20 65 6d 70 74 79  move it if empty
6680: 0a 09 09 20 20 20 3b 3b 20 20 20 20 28 69 66 20  ...   ;;    (if 
6690: 28 6e 75 6c 6c 3f 20 28 67 6c 6f 62 20 28 63 6f  (null? (glob (co
66a0: 6e 63 20 72 75 6e 70 61 74 68 20 22 2f 2a 22 29  nc runpath "/*")
66b0: 29 29 0a 09 09 20 20 20 3b 3b 20 20 20 20 20 20  ))...   ;;      
66c0: 20 20 28 62 65 67 69 6e 0a 09 09 20 20 20 3b 3b    (begin...   ;;
66d0: 20 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20   . (debug:print 
66e0: 31 20 22 52 65 6d 6f 76 69 6e 67 20 72 75 6e 20  1 "Removing run 
66f0: 64 69 72 20 22 20 72 75 6e 70 61 74 68 29 0a 09  dir " runpath)..
6700: 09 20 20 20 3b 3b 20 09 20 28 73 79 73 74 65 6d  .   ;; . (system
6710: 20 28 63 6f 6e 63 20 22 72 6d 64 69 72 20 2d 70   (conc "rmdir -p
6720: 20 22 20 72 75 6e 70 61 74 68 29 29 29 29 0a 09   " runpath))))..
6730: 09 20 20 20 29 29 29 29 0a 09 20 29 29 0a 20 20  .   )))).. )).  
6740: 20 20 20 72 75 6e 73 29 29 29 0a 0a 3b 3b 3d 3d     runs)))..;;==
6750: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6760: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6770: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6780: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6790: 3d 3d 3d 3d 0a 3b 3b 20 52 6f 75 74 69 6e 65 73  ====.;; Routines
67a0: 20 66 6f 72 20 6d 61 6e 69 70 75 6c 61 74 69 6e   for manipulatin
67b0: 67 20 72 75 6e 73 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d  g runs.;;=======
67c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
67d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
67e0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
67f0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a  ===============.
6800: 0a 3b 3b 20 53 69 6e 63 65 20 6d 61 6e 79 20 63  .;; Since many c
6810: 61 6c 6c 73 20 74 6f 20 61 20 72 75 6e 20 72 65  alls to a run re
6820: 71 75 69 72 65 20 70 72 65 74 74 79 20 6d 75 63  quire pretty muc
6830: 68 20 74 68 65 20 73 61 6d 65 20 73 65 74 75 70  h the same setup
6840: 20 0a 3b 3b 20 74 68 69 73 20 77 72 61 70 70 65   .;; this wrappe
6850: 72 20 69 73 20 75 73 65 64 20 74 6f 20 72 65 64  r is used to red
6860: 75 63 65 20 74 68 65 20 72 65 70 6c 69 63 61 74  uce the replicat
6870: 69 6f 6e 20 6f 66 20 63 6f 64 65 0a 28 64 65 66  ion of code.(def
6880: 69 6e 65 20 28 67 65 6e 65 72 61 6c 2d 72 75 6e  ine (general-run
6890: 2d 63 61 6c 6c 20 73 77 69 74 63 68 6e 61 6d 65  -call switchname
68a0: 20 61 63 74 69 6f 6e 2d 64 65 73 63 20 70 72 6f   action-desc pro
68b0: 63 29 0a 20 20 28 6c 65 74 20 28 28 72 75 6e 6e  c).  (let ((runn
68c0: 61 6d 65 20 28 61 72 67 73 3a 67 65 74 2d 61 72  ame (args:get-ar
68d0: 67 20 22 3a 72 75 6e 6e 61 6d 65 22 29 29 0a 09  g ":runname"))..
68e0: 28 74 61 72 67 65 74 20 20 28 69 66 20 28 61 72  (target  (if (ar
68f0: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 74 61 72  gs:get-arg "-tar
6900: 67 65 74 22 29 0a 09 09 20 20 20 20 20 28 61 72  get")...     (ar
6910: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 74 61 72  gs:get-arg "-tar
6920: 67 65 74 22 29 0a 09 09 20 20 20 20 20 28 61 72  get")...     (ar
6930: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65 71  gs:get-arg "-req
6940: 74 61 72 67 22 29 29 29 0a 09 28 74 68 31 20 20  targ")))..(th1  
6950: 20 20 20 23 66 29 29 0a 20 20 20 20 28 63 6f 6e     #f)).    (con
6960: 64 0a 20 20 20 20 20 28 28 6e 6f 74 20 74 61 72  d.     ((not tar
6970: 67 65 74 29 0a 20 20 20 20 20 20 28 64 65 62 75  get).      (debu
6980: 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52  g:print 0 "ERROR
6990: 3a 20 4d 69 73 73 69 6e 67 20 72 65 71 75 69 72  : Missing requir
69a0: 65 64 20 70 61 72 61 6d 65 74 65 72 20 66 6f 72  ed parameter for
69b0: 20 22 20 73 77 69 74 63 68 6e 61 6d 65 20 22 2c   " switchname ",
69c0: 20 79 6f 75 20 6d 75 73 74 20 73 70 65 63 69 66   you must specif
69d0: 79 20 74 68 65 20 74 61 72 67 65 74 20 77 69 74  y the target wit
69e0: 68 20 2d 74 61 72 67 65 74 22 29 0a 20 20 20 20  h -target").    
69f0: 20 20 28 65 78 69 74 20 33 29 29 0a 20 20 20 20    (exit 3)).    
6a00: 20 28 28 6e 6f 74 20 72 75 6e 6e 61 6d 65 29 0a   ((not runname).
6a10: 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69        (debug:pri
6a20: 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 4d 69 73  nt 0 "ERROR: Mis
6a30: 73 69 6e 67 20 72 65 71 75 69 72 65 64 20 70 61  sing required pa
6a40: 72 61 6d 65 74 65 72 20 66 6f 72 20 22 20 73 77  rameter for " sw
6a50: 69 74 63 68 6e 61 6d 65 20 22 2c 20 79 6f 75 20  itchname ", you 
6a60: 6d 75 73 74 20 73 70 65 63 69 66 79 20 74 68 65  must specify the
6a70: 20 72 75 6e 20 6e 61 6d 65 20 77 69 74 68 20 3a   run name with :
6a80: 72 75 6e 6e 61 6d 65 20 72 75 6e 6e 61 6d 65 22  runname runname"
6a90: 29 0a 20 20 20 20 20 20 28 65 78 69 74 20 33 29  ).      (exit 3)
6aa0: 29 0a 20 20 20 20 20 28 65 6c 73 65 0a 20 20 20  ).     (else.   
6ab0: 20 20 20 28 6c 65 74 20 28 28 64 62 20 20 20 23     (let ((db   #
6ac0: 66 29 0a 09 20 20 20 20 28 6b 65 79 73 20 23 66  f)..    (keys #f
6ad0: 29 29 0a 09 28 69 66 20 28 6e 6f 74 20 28 73 65  ))..(if (not (se
6ae0: 74 75 70 2d 66 6f 72 2d 72 75 6e 29 29 0a 09 20  tup-for-run)).. 
6af0: 20 20 20 28 62 65 67 69 6e 20 0a 09 20 20 20 20     (begin ..    
6b00: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30    (debug:print 0
6b10: 20 22 46 61 69 6c 65 64 20 74 6f 20 73 65 74 75   "Failed to setu
6b20: 70 2c 20 65 78 69 74 69 6e 67 22 29 0a 09 20 20  p, exiting")..  
6b30: 20 20 20 20 28 65 78 69 74 20 31 29 29 29 0a 09      (exit 1)))..
6b40: 28 73 65 74 21 20 64 62 20 20 20 28 6f 70 65 6e  (set! db   (open
6b50: 2d 64 62 29 29 0a 09 28 69 66 20 28 61 72 67 73  -db))..(if (args
6b60: 3a 67 65 74 2d 61 72 67 20 22 2d 73 65 72 76 65  :get-arg "-serve
6b70: 72 22 29 0a 09 20 20 20 20 28 73 65 72 76 65 72  r")..    (server
6b80: 3a 73 74 61 72 74 20 64 62 20 28 61 72 67 73 3a  :start db (args:
6b90: 67 65 74 2d 61 72 67 20 22 2d 73 65 72 76 65 72  get-arg "-server
6ba0: 22 29 29 0a 09 20 20 20 20 28 69 66 20 28 6e 6f  "))..    (if (no
6bb0: 74 20 28 6f 72 20 28 61 72 67 73 3a 67 65 74 2d  t (or (args:get-
6bc0: 61 72 67 20 22 2d 72 75 6e 61 6c 6c 22 29 0a 09  arg "-runall")..
6bd0: 09 09 20 20 28 61 72 67 73 3a 67 65 74 2d 61 72  ..  (args:get-ar
6be0: 67 20 22 2d 72 75 6e 74 65 73 74 73 22 29 29 29  g "-runtests")))
6bf0: 0a 09 09 28 73 65 72 76 65 72 3a 63 6c 69 65 6e  ...(server:clien
6c00: 74 2d 73 65 74 75 70 20 64 62 29 29 29 0a 09 28  t-setup db)))..(
6c10: 73 65 74 21 20 6b 65 79 73 20 28 72 64 62 3a 67  set! keys (rdb:g
6c20: 65 74 2d 6b 65 79 73 20 64 62 29 29 0a 09 3b 3b  et-keys db))..;;
6c30: 20 68 61 76 65 20 65 6e 6f 75 67 68 20 74 6f 20   have enough to 
6c40: 70 72 6f 63 65 73 73 20 2d 74 61 72 67 65 74 20  process -target 
6c50: 6f 72 20 2d 72 65 71 74 61 72 67 20 68 65 72 65  or -reqtarg here
6c60: 0a 09 28 69 66 20 28 61 72 67 73 3a 67 65 74 2d  ..(if (args:get-
6c70: 61 72 67 20 22 2d 72 65 71 74 61 72 67 22 29 0a  arg "-reqtarg").
6c80: 09 20 20 20 20 28 6c 65 74 2a 20 28 28 72 75 6e  .    (let* ((run
6c90: 63 6f 6e 66 69 67 66 20 28 63 6f 6e 63 20 20 2a  configf (conc  *
6ca0: 74 6f 70 70 61 74 68 2a 20 22 2f 72 75 6e 63 6f  toppath* "/runco
6cb0: 6e 66 69 67 73 2e 63 6f 6e 66 69 67 22 29 29 20  nfigs.config")) 
6cc0: 3b 3b 20 44 4f 20 4e 4f 54 20 45 56 41 4c 55 41  ;; DO NOT EVALUA
6cd0: 54 45 20 41 4c 4c 20 0a 09 09 20 20 20 28 72 75  TE ALL ...   (ru
6ce0: 6e 63 6f 6e 66 69 67 20 20 28 72 65 61 64 2d 63  nconfig  (read-c
6cf0: 6f 6e 66 69 67 20 72 75 6e 63 6f 6e 66 69 67 66  onfig runconfigf
6d00: 20 23 66 20 23 66 20 65 6e 76 69 72 6f 6e 2d 70   #f #f environ-p
6d10: 61 74 74 3a 20 23 66 29 29 29 20 0a 09 20 20 20  att: #f))) ..   
6d20: 20 20 20 28 69 66 20 28 68 61 73 68 2d 74 61 62     (if (hash-tab
6d30: 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 72  le-ref/default r
6d40: 75 6e 63 6f 6e 66 69 67 20 28 61 72 67 73 3a 67  unconfig (args:g
6d50: 65 74 2d 61 72 67 20 22 2d 72 65 71 74 61 72 67  et-arg "-reqtarg
6d60: 22 29 20 23 66 29 0a 09 09 20 20 28 6b 65 79 73  ") #f)...  (keys
6d70: 3a 74 61 72 67 65 74 2d 73 65 74 2d 61 72 67 73  :target-set-args
6d80: 20 6b 65 79 73 20 28 61 72 67 73 3a 67 65 74 2d   keys (args:get-
6d90: 61 72 67 20 22 2d 72 65 71 74 61 72 67 22 29 20  arg "-reqtarg") 
6da0: 61 72 67 73 3a 61 72 67 2d 68 61 73 68 29 0a 09  args:arg-hash)..
6db0: 09 20 20 28 62 65 67 69 6e 0a 09 09 20 20 20 20  .  (begin...    
6dc0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
6dd0: 45 52 52 4f 52 3a 20 5b 22 20 28 61 72 67 73 3a  ERROR: [" (args:
6de0: 67 65 74 2d 61 72 67 20 22 2d 72 65 71 74 61 72  get-arg "-reqtar
6df0: 67 22 29 20 22 5d 20 6e 6f 74 20 66 6f 75 6e 64  g") "] not found
6e00: 20 69 6e 20 22 20 72 75 6e 63 6f 6e 66 69 67 66   in " runconfigf
6e10: 29 0a 09 09 20 20 20 20 28 73 71 6c 69 74 65 33  )...    (sqlite3
6e20: 3a 66 69 6e 61 6c 69 7a 65 21 20 64 62 29 0a 09  :finalize! db)..
6e30: 09 20 20 20 20 28 65 78 69 74 20 31 29 29 29 29  .    (exit 1))))
6e40: 0a 09 20 20 20 20 28 69 66 20 28 61 72 67 73 3a  ..    (if (args:
6e50: 67 65 74 2d 61 72 67 20 22 2d 74 61 72 67 65 74  get-arg "-target
6e60: 22 29 0a 09 09 28 6b 65 79 73 3a 74 61 72 67 65  ")...(keys:targe
6e70: 74 2d 73 65 74 2d 61 72 67 73 20 6b 65 79 73 20  t-set-args keys 
6e80: 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d  (args:get-arg "-
6e90: 74 61 72 67 65 74 22 20 61 72 67 73 3a 61 72 67  target" args:arg
6ea0: 2d 68 61 73 68 29 20 61 72 67 73 3a 61 72 67 2d  -hash) args:arg-
6eb0: 68 61 73 68 29 29 29 0a 09 28 69 66 20 28 6e 6f  hash)))..(if (no
6ec0: 74 20 28 63 61 72 20 2a 63 6f 6e 66 69 67 69 6e  t (car *configin
6ed0: 66 6f 2a 29 29 0a 09 20 20 20 20 28 62 65 67 69  fo*))..    (begi
6ee0: 6e 0a 09 20 20 20 20 20 20 28 64 65 62 75 67 3a  n..      (debug:
6ef0: 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20  print 0 "ERROR: 
6f00: 41 74 74 65 6d 70 74 65 64 20 74 6f 20 22 20 61  Attempted to " a
6f10: 63 74 69 6f 6e 2d 64 65 73 63 20 22 20 62 75 74  ction-desc " but
6f20: 20 72 75 6e 20 61 72 65 61 20 63 6f 6e 66 69 67   run area config
6f30: 20 66 69 6c 65 20 6e 6f 74 20 66 6f 75 6e 64 22   file not found"
6f40: 29 0a 09 20 20 20 20 20 20 28 65 78 69 74 20 31  )..      (exit 1
6f50: 29 29 0a 09 20 20 20 20 3b 3b 20 45 78 74 72 61  ))..    ;; Extra
6f60: 63 74 20 6f 75 74 20 73 74 75 66 66 20 6e 65 65  ct out stuff nee
6f70: 64 65 64 20 69 6e 20 6d 6f 73 74 20 6f 72 20 6d  ded in most or m
6f80: 61 6e 79 20 63 61 6c 6c 73 0a 09 20 20 20 20 3b  any calls..    ;
6f90: 3b 20 68 65 72 65 20 74 68 65 6e 20 63 61 6c 6c  ; here then call
6fa0: 20 70 72 6f 63 0a 09 20 20 20 20 28 6c 65 74 2a   proc..    (let*
6fb0: 20 28 28 6b 65 79 6e 61 6d 65 73 20 20 20 28 6d   ((keynames   (m
6fc0: 61 70 20 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64  ap key:get-field
6fd0: 6e 61 6d 65 20 6b 65 79 73 29 29 0a 09 09 20 20  name keys))...  
6fe0: 20 28 6b 65 79 76 61 6c 6c 73 74 20 20 28 6b 65   (keyvallst  (ke
6ff0: 79 73 2d 3e 76 61 6c 6c 69 73 74 20 6b 65 79 73  ys->vallist keys
7000: 20 23 74 29 29 29 0a 09 20 20 20 20 20 20 28 70   #t)))..      (p
7010: 72 6f 63 20 64 62 20 74 61 72 67 65 74 20 72 75  roc db target ru
7020: 6e 6e 61 6d 65 20 6b 65 79 73 20 6b 65 79 6e 61  nname keys keyna
7030: 6d 65 73 20 6b 65 79 76 61 6c 6c 73 74 29 29 29  mes keyvallst)))
7040: 0a 09 28 69 66 20 74 68 31 20 28 74 68 72 65 61  ..(if th1 (threa
7050: 64 2d 6a 6f 69 6e 21 20 74 68 31 29 29 0a 09 28  d-join! th1))..(
7060: 73 71 6c 69 74 65 33 3a 66 69 6e 61 6c 69 7a 65  sqlite3:finalize
7070: 21 20 64 62 29 0a 09 28 73 65 74 21 20 2a 64 69  ! db)..(set! *di
7080: 64 73 6f 6d 65 74 68 69 6e 67 2a 20 23 74 29 29  dsomething* #t))
7090: 29 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d  ))))..;;========
70a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
70b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
70c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
70d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b  ==============.;
70e0: 3b 20 52 6f 6c 6c 75 70 20 72 75 6e 73 0a 3b 3b  ; Rollup runs.;;
70f0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7100: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7110: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7120: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7130: 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 55 70 64 61 74  ======..;; Updat
7140: 65 20 74 68 65 20 74 65 73 74 5f 6d 65 74 61 20  e the test_meta 
7150: 74 61 62 6c 65 20 66 6f 72 20 74 68 69 73 20 74  table for this t
7160: 65 73 74 0a 28 64 65 66 69 6e 65 20 28 72 75 6e  est.(define (run
7170: 73 3a 75 70 64 61 74 65 2d 74 65 73 74 5f 6d 65  s:update-test_me
7180: 74 61 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 20  ta db test-name 
7190: 74 65 73 74 2d 63 6f 6e 66 29 0a 20 20 28 6c 65  test-conf).  (le
71a0: 74 20 28 28 63 75 72 72 72 65 63 6f 72 64 20 28  t ((currrecord (
71b0: 64 62 3a 74 65 73 74 6d 65 74 61 2d 67 65 74 2d  db:testmeta-get-
71c0: 72 65 63 6f 72 64 20 64 62 20 74 65 73 74 2d 6e  record db test-n
71d0: 61 6d 65 29 29 29 0a 20 20 20 20 28 69 66 20 28  ame))).    (if (
71e0: 6e 6f 74 20 63 75 72 72 72 65 63 6f 72 64 29 0a  not currrecord).
71f0: 09 28 62 65 67 69 6e 0a 09 20 20 28 73 65 74 21  .(begin..  (set!
7200: 20 63 75 72 72 72 65 63 6f 72 64 20 28 6d 61 6b   currrecord (mak
7210: 65 2d 76 65 63 74 6f 72 20 31 30 20 23 66 29 29  e-vector 10 #f))
7220: 0a 09 20 20 28 64 62 3a 74 65 73 74 6d 65 74 61  ..  (db:testmeta
7230: 2d 61 64 64 2d 72 65 63 6f 72 64 20 64 62 20 74  -add-record db t
7240: 65 73 74 2d 6e 61 6d 65 29 29 29 0a 20 20 20 20  est-name))).    
7250: 28 66 6f 72 2d 65 61 63 68 20 0a 20 20 20 20 20  (for-each .     
7260: 28 6c 61 6d 62 64 61 20 28 6b 65 79 29 0a 20 20  (lambda (key).  
7270: 20 20 20 20 20 28 6c 65 74 2a 20 28 28 69 64 78       (let* ((idx
7280: 20 28 63 61 64 72 20 6b 65 79 29 29 0a 09 20 20   (cadr key))..  
7290: 20 20 20 20 28 66 6c 64 20 28 63 61 72 20 20 6b      (fld (car  k
72a0: 65 79 29 29 0a 09 20 20 20 20 20 20 28 76 61 6c  ey))..      (val
72b0: 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20   (config-lookup 
72c0: 74 65 73 74 2d 63 6f 6e 66 20 22 74 65 73 74 5f  test-conf "test_
72d0: 6d 65 74 61 22 20 66 6c 64 29 29 29 0a 09 20 3b  meta" fld))).. ;
72e0: 3b 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 35  ; (debug:print 5
72f0: 20 22 69 64 78 3a 20 22 20 69 64 78 20 22 20 66   "idx: " idx " f
7300: 6c 64 3a 20 22 20 66 6c 64 20 22 20 76 61 6c 3a  ld: " fld " val:
7310: 20 22 20 76 61 6c 29 0a 09 20 28 69 66 20 28 61   " val).. (if (a
7320: 6e 64 20 76 61 6c 20 28 6e 6f 74 20 28 65 71 75  nd val (not (equ
7330: 61 6c 3f 20 28 76 65 63 74 6f 72 2d 72 65 66 20  al? (vector-ref 
7340: 63 75 72 72 72 65 63 6f 72 64 20 69 64 78 29 20  currrecord idx) 
7350: 76 61 6c 29 29 29 0a 09 20 20 20 20 20 28 62 65  val)))..     (be
7360: 67 69 6e 0a 09 20 20 20 20 20 20 20 28 70 72 69  gin..       (pri
7370: 6e 74 20 22 55 70 64 61 74 69 6e 67 20 22 20 74  nt "Updating " t
7380: 65 73 74 2d 6e 61 6d 65 20 22 20 22 20 66 6c 64  est-name " " fld
7390: 20 22 20 74 6f 20 22 20 76 61 6c 29 0a 09 20 20   " to " val)..  
73a0: 20 20 20 20 20 28 64 62 3a 74 65 73 74 6d 65 74       (db:testmet
73b0: 61 2d 75 70 64 61 74 65 2d 66 69 65 6c 64 20 64  a-update-field d
73c0: 62 20 74 65 73 74 2d 6e 61 6d 65 20 66 6c 64 20  b test-name fld 
73d0: 76 61 6c 29 29 29 29 29 0a 20 20 20 20 20 27 28  val))))).     '(
73e0: 28 22 61 75 74 68 6f 72 22 20 32 29 28 22 6f 77  ("author" 2)("ow
73f0: 6e 65 72 22 20 33 29 28 22 64 65 73 63 72 69 70  ner" 3)("descrip
7400: 74 69 6f 6e 22 20 34 29 28 22 72 65 76 69 65 77  tion" 4)("review
7410: 65 64 22 20 35 29 28 22 74 61 67 73 22 20 39 29  ed" 5)("tags" 9)
7420: 29 29 29 29 0a 0a 3b 3b 20 55 70 64 61 74 65 20  ))))..;; Update 
7430: 74 65 73 74 5f 6d 65 74 61 20 66 6f 72 20 61 6c  test_meta for al
7440: 6c 20 74 65 73 74 73 0a 28 64 65 66 69 6e 65 20  l tests.(define 
7450: 28 72 75 6e 73 3a 75 70 64 61 74 65 2d 61 6c 6c  (runs:update-all
7460: 2d 74 65 73 74 5f 6d 65 74 61 20 64 62 29 0a 20  -test_meta db). 
7470: 20 28 6c 65 74 20 28 28 74 65 73 74 2d 6e 61 6d   (let ((test-nam
7480: 65 73 20 28 67 65 74 2d 61 6c 6c 2d 6c 65 67 61  es (get-all-lega
7490: 6c 2d 74 65 73 74 73 29 29 29 0a 20 20 20 20 28  l-tests))).    (
74a0: 66 6f 72 2d 65 61 63 68 20 0a 20 20 20 20 20 28  for-each .     (
74b0: 6c 61 6d 62 64 61 20 28 74 65 73 74 2d 6e 61 6d  lambda (test-nam
74c0: 65 29 0a 20 20 20 20 20 20 20 28 6c 65 74 2a 20  e).       (let* 
74d0: 28 28 74 65 73 74 2d 70 61 74 68 20 20 20 20 28  ((test-path    (
74e0: 63 6f 6e 63 20 2a 74 6f 70 70 61 74 68 2a 20 22  conc *toppath* "
74f0: 2f 74 65 73 74 73 2f 22 20 74 65 73 74 2d 6e 61  /tests/" test-na
7500: 6d 65 29 29 0a 09 20 20 20 20 20 20 28 74 65 73  me))..      (tes
7510: 74 2d 63 6f 6e 66 69 67 66 20 28 63 6f 6e 63 20  t-configf (conc 
7520: 74 65 73 74 2d 70 61 74 68 20 22 2f 74 65 73 74  test-path "/test
7530: 63 6f 6e 66 69 67 22 29 29 0a 09 20 20 20 20 20  config"))..     
7540: 20 28 74 65 73 74 65 78 69 73 74 73 20 20 20 28   (testexists   (
7550: 61 6e 64 20 28 66 69 6c 65 2d 65 78 69 73 74 73  and (file-exists
7560: 3f 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 29 28  ? test-configf)(
7570: 66 69 6c 65 2d 72 65 61 64 2d 61 63 63 65 73 73  file-read-access
7580: 3f 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 29 29  ? test-configf))
7590: 29 0a 09 20 20 20 20 20 20 3b 3b 20 72 65 61 64  )..      ;; read
75a0: 20 63 6f 6e 66 69 67 73 20 77 69 74 68 20 74 72   configs with tr
75b0: 69 63 6b 73 20 74 75 72 6e 65 64 20 6f 66 66 20  icks turned off 
75c0: 28 69 2e 65 2e 20 6e 6f 20 73 79 73 74 65 6d 29  (i.e. no system)
75d0: 0a 09 20 20 20 20 20 20 28 74 65 73 74 2d 63 6f  ..      (test-co
75e0: 6e 66 20 20 20 20 28 69 66 20 74 65 73 74 65 78  nf    (if testex
75f0: 69 73 74 73 20 28 72 65 61 64 2d 63 6f 6e 66 69  ists (read-confi
7600: 67 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 20 23  g test-configf #
7610: 66 20 23 66 29 28 6d 61 6b 65 2d 68 61 73 68 2d  f #f)(make-hash-
7620: 74 61 62 6c 65 29 29 29 29 0a 09 20 28 72 75 6e  table)))).. (run
7630: 73 3a 75 70 64 61 74 65 2d 74 65 73 74 5f 6d 65  s:update-test_me
7640: 74 61 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 20  ta db test-name 
7650: 74 65 73 74 2d 63 6f 6e 66 29 29 29 0a 20 20 20  test-conf))).   
7660: 20 20 74 65 73 74 2d 6e 61 6d 65 73 29 29 29 0a    test-names))).
7670: 0a 3b 3b 20 54 68 69 73 20 63 6f 75 6c 64 20 70  .;; This could p
7680: 72 6f 62 61 62 6c 79 20 62 65 20 72 65 66 61 63  robably be refac
7690: 74 6f 72 65 64 20 69 6e 74 6f 20 6f 6e 65 20 63  tored into one c
76a0: 6f 6d 70 6c 65 78 20 71 75 65 72 79 20 2e 2e 2e  omplex query ...
76b0: 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 72  .(define (runs:r
76c0: 6f 6c 6c 75 70 2d 72 75 6e 20 64 62 20 6b 65 79  ollup-run db key
76d0: 73 20 6b 65 79 76 61 6c 6c 73 74 20 72 75 6e 6e  s keyvallst runn
76e0: 61 6d 65 20 75 73 65 72 29 20 3b 3b 20 77 61 73  ame user) ;; was
76f0: 20 74 61 72 67 65 74 2c 20 6e 6f 77 20 6b 65 79   target, now key
7700: 76 61 6c 6c 73 74 0a 20 20 28 64 65 62 75 67 3a  vallst.  (debug:
7710: 70 72 69 6e 74 20 34 20 22 72 75 6e 73 3a 72 6f  print 4 "runs:ro
7720: 6c 6c 75 70 2d 72 75 6e 2c 20 6b 65 79 73 3a 20  llup-run, keys: 
7730: 22 20 6b 65 79 73 20 22 20 6b 65 79 76 61 6c 6c  " keys " keyvall
7740: 73 74 3a 20 22 20 6b 65 79 76 61 6c 6c 73 74 20  st: " keyvallst 
7750: 22 20 3a 72 75 6e 6e 61 6d 65 20 22 20 72 75 6e  " :runname " run
7760: 6e 61 6d 65 20 22 20 75 73 65 72 3a 20 22 20 75  name " user: " u
7770: 73 65 72 29 0a 20 20 28 6c 65 74 2a 20 28 3b 20  ser).  (let* (; 
7780: 28 6b 65 79 76 61 6c 6c 6c 73 74 20 20 20 20 20  (keyvalllst     
7790: 20 28 6b 65 79 73 3a 74 61 72 67 65 74 2d 3e 6b   (keys:target->k
77a0: 65 79 76 61 6c 20 6b 65 79 73 20 74 61 72 67 65  eyval keys targe
77b0: 74 29 29 0a 09 20 28 6e 65 77 2d 72 75 6e 2d 69  t)).. (new-run-i
77c0: 64 20 20 20 20 20 20 28 72 75 6e 73 3a 72 65 67  d      (runs:reg
77d0: 69 73 74 65 72 2d 72 75 6e 20 64 62 20 6b 65 79  ister-run db key
77e0: 73 20 6b 65 79 76 61 6c 6c 73 74 20 72 75 6e 6e  s keyvallst runn
77f0: 61 6d 65 20 22 6e 65 77 22 20 22 6e 2f 61 22 20  ame "new" "n/a" 
7800: 75 73 65 72 29 29 0a 09 20 28 70 72 65 76 2d 74  user)).. (prev-t
7810: 65 73 74 73 20 20 20 20 20 20 28 74 65 73 74 3a  ests      (test:
7820: 67 65 74 2d 6d 61 74 63 68 69 6e 67 2d 70 72 65  get-matching-pre
7830: 76 69 6f 75 73 2d 74 65 73 74 2d 72 75 6e 2d 72  vious-test-run-r
7840: 65 63 6f 72 64 73 20 64 62 20 6e 65 77 2d 72 75  ecords db new-ru
7850: 6e 2d 69 64 20 22 25 22 20 22 25 22 29 29 0a 09  n-id "%" "%"))..
7860: 20 28 63 75 72 72 2d 74 65 73 74 73 20 20 20 20   (curr-tests    
7870: 20 20 28 72 64 62 3a 67 65 74 2d 74 65 73 74 73    (rdb:get-tests
7880: 2d 66 6f 72 2d 72 75 6e 20 64 62 20 6e 65 77 2d  -for-run db new-
7890: 72 75 6e 2d 69 64 20 22 25 22 20 22 25 22 20 27  run-id "%" "%" '
78a0: 28 29 20 27 28 29 29 29 0a 09 20 28 63 75 72 72  () '())).. (curr
78b0: 2d 74 65 73 74 73 2d 68 61 73 68 20 28 6d 61 6b  -tests-hash (mak
78c0: 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29 29 0a  e-hash-table))).
78d0: 20 20 20 20 28 64 62 3a 75 70 64 61 74 65 2d 72      (db:update-r
78e0: 75 6e 2d 65 76 65 6e 74 5f 74 69 6d 65 20 64 62  un-event_time db
78f0: 20 6e 65 77 2d 72 75 6e 2d 69 64 29 0a 20 20 20   new-run-id).   
7900: 20 3b 3b 20 69 6e 64 65 78 20 74 68 65 20 61 6c   ;; index the al
7910: 72 65 61 64 79 20 73 61 76 65 64 20 74 65 73 74  ready saved test
7920: 73 20 62 79 20 74 65 73 74 6e 61 6d 65 20 61 6e  s by testname an
7930: 64 20 69 74 65 6d 64 61 74 20 69 6e 20 63 75 72  d itemdat in cur
7940: 72 2d 74 65 73 74 73 2d 68 61 73 68 0a 20 20 20  r-tests-hash.   
7950: 20 28 66 6f 72 2d 65 61 63 68 0a 20 20 20 20 20   (for-each.     
7960: 28 6c 61 6d 62 64 61 20 28 74 65 73 74 64 61 74  (lambda (testdat
7970: 29 0a 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28  ).       (let* (
7980: 28 74 65 73 74 6e 61 6d 65 20 20 28 64 62 3a 74  (testname  (db:t
7990: 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65  est-get-testname
79a0: 20 74 65 73 74 64 61 74 29 29 0a 09 20 20 20 20   testdat))..    
79b0: 20 20 28 69 74 65 6d 2d 70 61 74 68 20 28 64 62    (item-path (db
79c0: 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70  :test-get-item-p
79d0: 61 74 68 20 74 65 73 74 64 61 74 29 29 0a 09 20  ath testdat)).. 
79e0: 20 20 20 20 20 28 66 75 6c 6c 2d 6e 61 6d 65 20       (full-name 
79f0: 28 63 6f 6e 63 20 74 65 73 74 6e 61 6d 65 20 22  (conc testname "
7a00: 2f 22 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a  /" item-path))).
7a10: 09 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65  . (hash-table-se
7a20: 74 21 20 63 75 72 72 2d 74 65 73 74 73 2d 68 61  t! curr-tests-ha
7a30: 73 68 20 66 75 6c 6c 2d 6e 61 6d 65 20 74 65 73  sh full-name tes
7a40: 74 64 61 74 29 29 29 0a 20 20 20 20 20 63 75 72  tdat))).     cur
7a50: 72 2d 74 65 73 74 73 29 0a 20 20 20 20 3b 3b 20  r-tests).    ;; 
7a60: 4e 4f 50 45 3a 20 4e 6f 6e 2d 6f 70 74 69 6d 61  NOPE: Non-optima
7a70: 6c 20 61 70 70 72 6f 61 63 68 2e 20 54 72 79 20  l approach. Try 
7a80: 74 68 69 73 20 69 6e 73 74 65 61 64 2e 0a 20 20  this instead..  
7a90: 20 20 3b 3b 20 20 20 31 2e 20 74 65 73 74 73 20    ;;   1. tests 
7aa0: 61 72 65 20 72 65 63 65 69 76 65 64 20 69 6e 20  are received in 
7ab0: 61 20 6c 69 73 74 2c 20 6d 6f 73 74 20 72 65 63  a list, most rec
7ac0: 65 6e 74 20 66 69 72 73 74 0a 20 20 20 20 3b 3b  ent first.    ;;
7ad0: 20 20 20 32 2e 20 72 65 70 6c 61 63 65 20 74 68     2. replace th
7ae0: 65 20 72 6f 6c 6c 75 70 20 74 65 73 74 20 77 69  e rollup test wi
7af0: 74 68 20 74 68 65 20 6e 65 77 20 2a 61 6c 77 61  th the new *alwa
7b00: 79 73 2a 0a 20 20 20 20 28 66 6f 72 2d 65 61 63  ys*.    (for-eac
7b10: 68 20 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20  h .     (lambda 
7b20: 28 74 65 73 74 64 61 74 29 0a 20 20 20 20 20 20  (testdat).      
7b30: 20 28 6c 65 74 2a 20 28 28 74 65 73 74 6e 61 6d   (let* ((testnam
7b40: 65 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  e  (db:test-get-
7b50: 74 65 73 74 6e 61 6d 65 20 74 65 73 74 64 61 74  testname testdat
7b60: 29 29 0a 09 20 20 20 20 20 20 28 69 74 65 6d 2d  ))..      (item-
7b70: 70 61 74 68 20 28 64 62 3a 74 65 73 74 2d 67 65  path (db:test-ge
7b80: 74 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74  t-item-path test
7b90: 64 61 74 29 29 0a 09 20 20 20 20 20 20 28 66 75  dat))..      (fu
7ba0: 6c 6c 2d 6e 61 6d 65 20 28 63 6f 6e 63 20 74 65  ll-name (conc te
7bb0: 73 74 6e 61 6d 65 20 22 2f 22 20 69 74 65 6d 2d  stname "/" item-
7bc0: 70 61 74 68 29 29 0a 09 20 20 20 20 20 20 28 70  path))..      (p
7bd0: 72 65 76 2d 74 65 73 74 2d 64 61 74 20 28 68 61  rev-test-dat (ha
7be0: 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66  sh-table-ref/def
7bf0: 61 75 6c 74 20 63 75 72 72 2d 74 65 73 74 73 2d  ault curr-tests-
7c00: 68 61 73 68 20 66 75 6c 6c 2d 6e 61 6d 65 20 23  hash full-name #
7c10: 66 29 29 0a 09 20 20 20 20 20 20 28 74 65 73 74  f))..      (test
7c20: 2d 73 74 65 70 73 20 20 20 20 20 20 28 64 62 3a  -steps      (db:
7c30: 67 65 74 2d 73 74 65 70 73 2d 66 6f 72 2d 74 65  get-steps-for-te
7c40: 73 74 20 64 62 20 28 64 62 3a 74 65 73 74 2d 67  st db (db:test-g
7c50: 65 74 2d 69 64 20 74 65 73 74 64 61 74 29 29 29  et-id testdat)))
7c60: 0a 09 20 20 20 20 20 20 28 6e 65 77 2d 74 65 73  ..      (new-tes
7c70: 74 2d 72 65 63 6f 72 64 20 23 66 29 29 0a 09 20  t-record #f)).. 
7c80: 3b 3b 20 72 65 70 6c 61 63 65 20 74 68 65 73 65  ;; replace these
7c90: 20 77 69 74 68 20 69 6e 73 65 72 74 20 2e 2e 2e   with insert ...
7ca0: 20 73 65 6c 65 63 74 0a 09 20 28 61 70 70 6c 79   select.. (apply
7cb0: 20 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65   sqlite3:execute
7cc0: 20 0a 09 09 64 62 20 0a 09 09 28 63 6f 6e 63 20   ...db ...(conc 
7cd0: 22 49 4e 53 45 52 54 20 4f 52 20 52 45 50 4c 41  "INSERT OR REPLA
7ce0: 43 45 20 49 4e 54 4f 20 74 65 73 74 73 20 28 72  CE INTO tests (r
7cf0: 75 6e 5f 69 64 2c 74 65 73 74 6e 61 6d 65 2c 73  un_id,testname,s
7d00: 74 61 74 65 2c 73 74 61 74 75 73 2c 65 76 65 6e  tate,status,even
7d10: 74 5f 74 69 6d 65 2c 68 6f 73 74 2c 63 70 75 6c  t_time,host,cpul
7d20: 6f 61 64 2c 64 69 73 6b 66 72 65 65 2c 75 6e 61  oad,diskfree,una
7d30: 6d 65 2c 72 75 6e 64 69 72 2c 69 74 65 6d 5f 70  me,rundir,item_p
7d40: 61 74 68 2c 72 75 6e 5f 64 75 72 61 74 69 6f 6e  ath,run_duration
7d50: 2c 66 69 6e 61 6c 5f 6c 6f 67 66 2c 63 6f 6d 6d  ,final_logf,comm
7d60: 65 6e 74 29 20 22 0a 09 09 20 20 20 20 20 20 22  ent) "...      "
7d70: 56 41 4c 55 45 53 20 28 3f 2c 3f 2c 3f 2c 3f 2c  VALUES (?,?,?,?,
7d80: 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c  ?,?,?,?,?,?,?,?,
7d90: 3f 2c 3f 29 3b 22 29 0a 09 09 6e 65 77 2d 72 75  ?,?);")...new-ru
7da0: 6e 2d 69 64 20 28 63 64 64 72 20 28 76 65 63 74  n-id (cddr (vect
7db0: 6f 72 2d 3e 6c 69 73 74 20 74 65 73 74 64 61 74  or->list testdat
7dc0: 29 29 29 0a 09 20 28 73 65 74 21 20 6e 65 77 2d  ))).. (set! new-
7dd0: 74 65 73 74 64 61 74 20 28 63 61 72 20 28 72 64  testdat (car (rd
7de0: 62 3a 67 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d  b:get-tests-for-
7df0: 72 75 6e 20 64 62 20 6e 65 77 2d 72 75 6e 2d 69  run db new-run-i
7e00: 64 20 74 65 73 74 6e 61 6d 65 20 69 74 65 6d 2d  d testname item-
7e10: 70 61 74 68 20 27 28 29 20 27 28 29 29 29 29 0a  path '() '()))).
7e20: 09 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65  . (hash-table-se
7e30: 74 21 20 63 75 72 72 2d 74 65 73 74 73 2d 68 61  t! curr-tests-ha
7e40: 73 68 20 66 75 6c 6c 2d 6e 61 6d 65 20 6e 65 77  sh full-name new
7e50: 2d 74 65 73 74 64 61 74 29 20 3b 3b 20 74 68 69  -testdat) ;; thi
7e60: 73 20 63 6f 75 6c 64 20 62 65 20 63 6f 6e 66 75  s could be confu
7e70: 73 69 6e 67 2c 20 77 68 69 63 68 20 72 65 63 6f  sing, which reco
7e80: 72 64 20 73 68 6f 75 6c 64 20 67 6f 20 69 6e 74  rd should go int
7e90: 6f 20 74 68 65 20 6c 6f 6f 6b 75 70 20 74 61 62  o the lookup tab
7ea0: 6c 65 3f 0a 09 20 3b 3b 20 4e 6f 77 20 64 75 70  le?.. ;; Now dup
7eb0: 6c 69 63 61 74 65 20 74 68 65 20 74 65 73 74 20  licate the test 
7ec0: 73 74 65 70 73 0a 09 20 28 64 65 62 75 67 3a 70  steps.. (debug:p
7ed0: 72 69 6e 74 20 34 20 22 43 6f 70 79 69 6e 67 20  rint 4 "Copying 
7ee0: 72 65 63 6f 72 64 73 20 69 6e 20 74 65 73 74 5f  records in test_
7ef0: 73 74 65 70 73 20 66 72 6f 6d 20 74 65 73 74 5f  steps from test_
7f00: 69 64 3d 22 20 28 64 62 3a 74 65 73 74 2d 67 65  id=" (db:test-ge
7f10: 74 2d 69 64 20 74 65 73 74 64 61 74 29 20 22 20  t-id testdat) " 
7f20: 74 6f 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65  to " (db:test-ge
7f30: 74 2d 69 64 20 6e 65 77 2d 74 65 73 74 64 61 74  t-id new-testdat
7f40: 29 29 0a 09 20 28 73 71 6c 69 74 65 33 3a 65 78  )).. (sqlite3:ex
7f50: 65 63 75 74 65 20 0a 09 20 20 64 62 20 0a 09 20  ecute ..  db .. 
7f60: 20 28 63 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f   (conc "INSERT O
7f70: 52 20 52 45 50 4c 41 43 45 20 49 4e 54 4f 20 74  R REPLACE INTO t
7f80: 65 73 74 5f 73 74 65 70 73 20 28 74 65 73 74 5f  est_steps (test_
7f90: 69 64 2c 73 74 65 70 6e 61 6d 65 2c 73 74 61 74  id,stepname,stat
7fa0: 65 2c 73 74 61 74 75 73 2c 65 76 65 6e 74 5f 74  e,status,event_t
7fb0: 69 6d 65 2c 63 6f 6d 6d 65 6e 74 29 20 22 0a 09  ime,comment) "..
7fc0: 09 22 53 45 4c 45 43 54 20 22 20 28 64 62 3a 74  ."SELECT " (db:t
7fd0: 65 73 74 2d 67 65 74 2d 69 64 20 6e 65 77 2d 74  est-get-id new-t
7fe0: 65 73 74 64 61 74 29 20 22 2c 73 74 65 70 6e 61  estdat) ",stepna
7ff0: 6d 65 2c 73 74 61 74 65 2c 73 74 61 74 75 73 2c  me,state,status,
8000: 65 76 65 6e 74 5f 74 69 6d 65 2c 63 6f 6d 6d 65  event_time,comme
8010: 6e 74 20 46 52 4f 4d 20 74 65 73 74 5f 73 74 65  nt FROM test_ste
8020: 70 73 20 57 48 45 52 45 20 74 65 73 74 5f 69 64  ps WHERE test_id
8030: 3d 3f 3b 22 29 0a 09 20 20 28 64 62 3a 74 65 73  =?;")..  (db:tes
8040: 74 2d 67 65 74 2d 69 64 20 74 65 73 74 64 61 74  t-get-id testdat
8050: 29 29 0a 09 20 3b 3b 20 4e 6f 77 20 64 75 70 6c  )).. ;; Now dupl
8060: 69 63 61 74 65 20 74 68 65 20 74 65 73 74 20 64  icate the test d
8070: 61 74 61 0a 09 20 28 64 65 62 75 67 3a 70 72 69  ata.. (debug:pri
8080: 6e 74 20 34 20 22 43 6f 70 79 69 6e 67 20 72 65  nt 4 "Copying re
8090: 63 6f 72 64 73 20 69 6e 20 74 65 73 74 5f 64 61  cords in test_da
80a0: 74 61 20 66 72 6f 6d 20 74 65 73 74 5f 69 64 3d  ta from test_id=
80b0: 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69  " (db:test-get-i
80c0: 64 20 74 65 73 74 64 61 74 29 20 22 20 74 6f 20  d testdat) " to 
80d0: 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69  " (db:test-get-i
80e0: 64 20 6e 65 77 2d 74 65 73 74 64 61 74 29 29 0a  d new-testdat)).
80f0: 09 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75  . (sqlite3:execu
8100: 74 65 20 0a 09 20 20 64 62 20 0a 09 20 20 28 63  te ..  db ..  (c
8110: 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f 52 20 52  onc "INSERT OR R
8120: 45 50 4c 41 43 45 20 49 4e 54 4f 20 74 65 73 74  EPLACE INTO test
8130: 5f 64 61 74 61 20 28 74 65 73 74 5f 69 64 2c 63  _data (test_id,c
8140: 61 74 65 67 6f 72 79 2c 76 61 72 69 61 62 6c 65  ategory,variable
8150: 2c 76 61 6c 75 65 2c 65 78 70 65 63 74 65 64 2c  ,value,expected,
8160: 74 6f 6c 2c 75 6e 69 74 73 2c 63 6f 6d 6d 65 6e  tol,units,commen
8170: 74 29 20 22 0a 09 09 22 53 45 4c 45 43 54 20 22  t) "..."SELECT "
8180: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64   (db:test-get-id
8190: 20 6e 65 77 2d 74 65 73 74 64 61 74 29 20 22 2c   new-testdat) ",
81a0: 63 61 74 65 67 6f 72 79 2c 76 61 72 69 61 62 6c  category,variabl
81b0: 65 2c 76 61 6c 75 65 2c 65 78 70 65 63 74 65 64  e,value,expected
81c0: 2c 74 6f 6c 2c 75 6e 69 74 73 2c 63 6f 6d 6d 65  ,tol,units,comme
81d0: 6e 74 20 46 52 4f 4d 20 74 65 73 74 5f 64 61 74  nt FROM test_dat
81e0: 61 20 57 48 45 52 45 20 74 65 73 74 5f 69 64 3d  a WHERE test_id=
81f0: 3f 3b 22 29 0a 09 20 20 28 64 62 3a 74 65 73 74  ?;")..  (db:test
8200: 2d 67 65 74 2d 69 64 20 74 65 73 74 64 61 74 29  -get-id testdat)
8210: 29 0a 09 20 29 29 0a 20 20 20 20 20 70 72 65 76  ).. )).     prev
8220: 2d 74 65 73 74 73 29 29 29 0a 09 20 0a 20 20 20  -tests))).. .   
8230: 20 20 0a                                           .