Megatest

Hex Artifact Content
Login

Artifact 757a50bdebe50a416b6d5e18b490be1639d93c1d:


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 28 61 6c 69 73 74  keys).    (alist
09b0: 2d 3e 65 6e 76 2d 76 61 72 73 20 28 68 61 73 68  ->env-vars (hash
09c0: 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75  -table-ref/defau
09d0: 6c 74 20 2a 63 6f 6e 66 69 67 64 61 74 2a 20 22  lt *configdat* "
09e0: 65 6e 76 2d 6f 76 65 72 72 69 64 65 22 20 27 28  env-override" '(
09f0: 29 29 29 0a 20 20 20 20 3b 3b 20 4c 65 74 73 20  ))).    ;; Lets 
0a00: 75 73 65 20 74 68 69 73 20 61 73 20 61 6e 20 6f  use this as an o
0a10: 70 70 6f 72 74 75 6e 69 74 79 20 74 6f 20 70 75  pportunity to pu
0a20: 74 20 4d 54 5f 52 55 4e 4e 41 4d 45 20 69 6e 20  t MT_RUNNAME in 
0a30: 74 68 65 20 65 6e 76 69 72 6f 6e 6d 65 6e 74 0a  the environment.
0a40: 20 20 20 20 28 73 71 6c 69 74 65 33 3a 66 6f 72      (sqlite3:for
0a50: 2d 65 61 63 68 2d 72 6f 77 0a 20 20 20 20 20 28  -each-row.     (
0a60: 6c 61 6d 62 64 61 20 28 72 75 6e 6e 61 6d 65 29  lambda (runname)
0a70: 0a 20 20 20 20 20 20 20 28 73 65 74 65 6e 76 20  .       (setenv 
0a80: 22 4d 54 5f 52 55 4e 4e 41 4d 45 22 20 72 75 6e  "MT_RUNNAME" run
0a90: 6e 61 6d 65 29 29 0a 20 20 20 20 20 64 62 0a 20  name)).     db. 
0aa0: 20 20 20 20 22 53 45 4c 45 43 54 20 72 75 6e 6e      "SELECT runn
0ab0: 61 6d 65 20 46 52 4f 4d 20 72 75 6e 73 20 57 48  ame FROM runs WH
0ac0: 45 52 45 20 69 64 3d 3f 3b 22 0a 20 20 20 20 20  ERE id=?;".     
0ad0: 72 75 6e 2d 69 64 29 0a 20 20 20 20 29 29 0a 0a  run-id).    ))..
0ae0: 28 64 65 66 69 6e 65 20 28 73 65 74 2d 69 74 65  (define (set-ite
0af0: 6d 2d 65 6e 76 2d 76 61 72 73 20 69 74 65 6d 64  m-env-vars itemd
0b00: 61 74 29 0a 20 20 28 66 6f 72 2d 65 61 63 68 20  at).  (for-each 
0b10: 28 6c 61 6d 62 64 61 20 28 69 74 65 6d 29 0a 09  (lambda (item)..
0b20: 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69        (debug:pri
0b30: 6e 74 20 32 20 22 73 65 74 65 6e 76 20 22 20 28  nt 2 "setenv " (
0b40: 63 61 72 20 69 74 65 6d 29 20 22 20 22 20 28 63  car item) " " (c
0b50: 61 64 72 20 69 74 65 6d 29 29 0a 09 20 20 20 20  adr item))..    
0b60: 20 20 28 73 65 74 65 6e 76 20 28 63 61 72 20 69    (setenv (car i
0b70: 74 65 6d 29 20 28 63 61 64 72 20 69 74 65 6d 29  tem) (cadr item)
0b80: 29 29 0a 09 20 20 20 20 69 74 65 6d 64 61 74 29  ))..    itemdat)
0b90: 29 0a 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73  )..(define (runs
0ba0: 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65  :can-run-more-te
0bb0: 73 74 73 20 64 62 20 74 65 73 74 2d 72 65 63 6f  sts db test-reco
0bc0: 72 64 29 0a 20 20 28 6c 65 74 2a 20 28 28 74 63  rd).  (let* ((tc
0bd0: 6f 6e 66 69 67 20 20 20 20 20 20 20 20 20 20 20  onfig           
0be0: 20 20 20 20 20 20 28 74 65 73 74 73 3a 74 65 73        (tests:tes
0bf0: 74 71 75 65 75 65 2d 67 65 74 2d 74 65 73 74 63  tqueue-get-testc
0c00: 6f 6e 66 69 67 20 74 65 73 74 2d 72 65 63 6f 72  onfig test-recor
0c10: 64 29 29 0a 09 20 28 6a 6f 62 67 72 6f 75 70 20  d)).. (jobgroup 
0c20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28                 (
0c30: 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 74 63  config-lookup tc
0c40: 6f 6e 66 69 67 20 22 72 65 71 75 69 72 65 6d 65  onfig "requireme
0c50: 6e 74 73 22 20 22 6a 6f 62 67 72 6f 75 70 22 29  nts" "jobgroup")
0c60: 29 0a 09 20 28 6e 75 6d 2d 72 75 6e 6e 69 6e 67  ).. (num-running
0c70: 20 20 20 20 20 20 20 20 20 20 20 20 20 28 64 62               (db
0c80: 3a 67 65 74 2d 63 6f 75 6e 74 2d 74 65 73 74 73  :get-count-tests
0c90: 2d 72 75 6e 6e 69 6e 67 20 64 62 29 29 0a 09 20  -running db)).. 
0ca0: 28 6e 75 6d 2d 72 75 6e 6e 69 6e 67 2d 69 6e 2d  (num-running-in-
0cb0: 6a 6f 62 67 72 6f 75 70 20 28 64 62 3a 67 65 74  jobgroup (db:get
0cc0: 2d 63 6f 75 6e 74 2d 74 65 73 74 73 2d 72 75 6e  -count-tests-run
0cd0: 6e 69 6e 67 2d 69 6e 2d 6a 6f 62 67 72 6f 75 70  ning-in-jobgroup
0ce0: 20 64 62 20 6a 6f 62 67 72 6f 75 70 29 29 0a 09   db jobgroup))..
0cf0: 20 28 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74   (max-concurrent
0d00: 2d 6a 6f 62 73 20 20 20 20 20 28 63 6f 6e 66 69  -jobs     (confi
0d10: 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67  g-lookup *config
0d20: 64 61 74 2a 20 22 73 65 74 75 70 22 20 20 20 20  dat* "setup"    
0d30: 20 22 6d 61 78 5f 63 6f 6e 63 75 72 72 65 6e 74   "max_concurrent
0d40: 5f 6a 6f 62 73 22 29 29 0a 09 20 28 6a 6f 62 2d  _jobs")).. (job-
0d50: 67 72 6f 75 70 2d 6c 69 6d 69 74 20 20 20 20 20  group-limit     
0d60: 20 20 20 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b      (config-look
0d70: 75 70 20 2a 63 6f 6e 66 69 67 64 61 74 2a 20 22  up *configdat* "
0d80: 6a 6f 62 67 72 6f 75 70 73 22 20 6a 6f 62 67 72  jobgroups" jobgr
0d90: 6f 75 70 29 29 29 0a 20 20 20 20 28 64 65 62 75  oup))).    (debu
0da0: 67 3a 70 72 69 6e 74 20 32 20 22 6d 61 78 2d 63  g:print 2 "max-c
0db0: 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 3a 20  oncurrent-jobs: 
0dc0: 22 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74  " max-concurrent
0dd0: 2d 6a 6f 62 73 20 22 2c 20 6e 75 6d 2d 72 75 6e  -jobs ", num-run
0de0: 6e 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e  ning: " num-runn
0df0: 69 6e 67 29 0a 20 20 20 20 28 69 66 20 28 6e 6f  ing).    (if (no
0e00: 74 20 28 65 71 3f 20 30 20 2a 67 6c 6f 62 61 6c  t (eq? 0 *global
0e10: 65 78 69 74 73 74 61 74 75 73 2a 29 29 0a 09 23  exitstatus*))..#
0e20: 66 0a 09 28 6c 65 74 20 28 28 63 61 6e 2d 6e 6f  f..(let ((can-no
0e30: 74 2d 72 75 6e 2d 6d 6f 72 65 20 28 63 6f 6e 64  t-run-more (cond
0e40: 0a 09 09 09 09 20 3b 3b 20 69 66 20 6d 61 78 2d  ..... ;; if max-
0e50: 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 20  concurrent-jobs 
0e60: 69 73 20 73 65 74 20 61 6e 64 20 74 68 65 20 6e  is set and the n
0e70: 75 6d 62 65 72 20 72 75 6e 6e 69 6e 67 20 69 73  umber running is
0e80: 20 67 72 65 61 74 65 72 20 0a 09 09 09 09 20 3b   greater ..... ;
0e90: 3b 20 74 68 61 6e 20 69 74 20 74 68 61 6e 20 63  ; than it than c
0ea0: 61 6e 6e 6f 74 20 72 75 6e 20 6d 6f 72 65 20 6a  annot run more j
0eb0: 6f 62 73 0a 09 09 09 09 20 28 28 61 6e 64 20 6d  obs..... ((and m
0ec0: 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f  ax-concurrent-jo
0ed0: 62 73 0a 09 09 09 09 20 20 20 20 20 20 20 28 73  bs.....       (s
0ee0: 74 72 69 6e 67 2d 3e 6e 75 6d 62 65 72 20 6d 61  tring->number ma
0ef0: 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62  x-concurrent-job
0f00: 73 29 0a 09 09 09 09 20 20 20 20 20 20 20 28 3e  s).....       (>
0f10: 3d 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67 20 28 73  = num-running (s
0f20: 74 72 69 6e 67 2d 3e 6e 75 6d 62 65 72 20 6d 61  tring->number ma
0f30: 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62  x-concurrent-job
0f40: 73 29 29 29 0a 09 09 09 09 20 20 28 64 65 62 75  s))).....  (debu
0f50: 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e 49  g:print 0 "WARNI
0f60: 4e 47 3a 20 4d 61 78 20 72 75 6e 6e 69 6e 67 20  NG: Max running 
0f70: 6a 6f 62 73 20 65 78 63 65 65 64 65 64 2c 20 63  jobs exceeded, c
0f80: 75 72 72 65 6e 74 20 6e 75 6d 62 65 72 20 72 75  urrent number ru
0f90: 6e 6e 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e  nning: " num-run
0fa0: 6e 69 6e 67 20 0a 09 09 09 09 09 20 20 20 20 20  ning ......     
0fb0: 20 20 22 2c 20 6d 61 78 5f 63 6f 6e 63 75 72 72    ", max_concurr
0fc0: 65 6e 74 5f 6a 6f 62 73 3a 20 22 20 6d 61 78 2d  ent_jobs: " max-
0fd0: 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29  concurrent-jobs)
0fe0: 0a 09 09 09 09 20 20 23 74 29 0a 09 09 09 09 20  .....  #t)..... 
0ff0: 3b 3b 20 69 66 20 6a 6f 62 2d 67 72 6f 75 70 2d  ;; if job-group-
1000: 6c 69 6d 69 74 20 69 73 20 73 65 74 20 61 6e 64  limit is set and
1010: 20 6e 75 6d 62 65 72 20 6f 66 20 6a 6f 62 73 20   number of jobs 
1020: 69 6e 20 74 68 65 20 67 72 6f 75 70 20 69 73 20  in the group is 
1030: 67 72 65 61 74 65 72 0a 09 09 09 09 20 3b 3b 20  greater..... ;; 
1040: 74 68 61 6e 20 74 68 65 20 6c 69 6d 69 74 20 74  than the limit t
1050: 68 65 6e 20 63 61 6e 6e 6f 74 20 72 75 6e 20 6d  hen cannot run m
1060: 6f 72 65 20 6a 6f 62 73 20 6f 66 20 74 68 69 73  ore jobs of this
1070: 20 6b 69 6e 64 0a 09 09 09 09 20 28 28 61 6e 64   kind..... ((and
1080: 20 6a 6f 62 2d 67 72 6f 75 70 2d 6c 69 6d 69 74   job-group-limit
1090: 0a 09 09 09 09 20 20 20 20 20 20 20 28 3e 3d 20  .....       (>= 
10a0: 6e 75 6d 2d 72 75 6e 6e 69 6e 67 2d 69 6e 2d 6a  num-running-in-j
10b0: 6f 62 67 72 6f 75 70 20 6a 6f 62 2d 67 72 6f 75  obgroup job-grou
10c0: 70 2d 6c 69 6d 69 74 29 29 0a 09 09 09 09 20 20  p-limit)).....  
10d0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22  (debug:print 1 "
10e0: 57 41 52 4e 49 4e 47 3a 20 6e 75 6d 62 65 72 20  WARNING: number 
10f0: 6f 66 20 6a 6f 62 73 20 22 20 6e 75 6d 2d 72 75  of jobs " num-ru
1100: 6e 6e 69 6e 67 2d 69 6e 2d 6a 6f 62 67 72 6f 75  nning-in-jobgrou
1110: 70 20 0a 09 09 09 09 09 20 20 20 20 20 20 20 22  p ......       "
1120: 20 69 6e 20 22 20 6a 6f 62 67 72 6f 75 70 20 22   in " jobgroup "
1130: 20 65 78 63 65 65 64 65 64 2c 20 77 69 6c 6c 20   exceeded, will 
1140: 6e 6f 74 20 72 75 6e 20 22 20 28 74 65 73 74 73  not run " (tests
1150: 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d 74  :testqueue-get-t
1160: 65 73 74 6e 61 6d 65 20 74 65 73 74 2d 72 65 63  estname test-rec
1170: 6f 72 64 29 29 0a 09 09 09 09 20 20 23 74 29 0a  ord)).....  #t).
1180: 09 09 09 09 20 28 65 6c 73 65 20 23 66 29 29 29  .... (else #f)))
1190: 29 0a 09 20 20 28 6e 6f 74 20 63 61 6e 2d 6e 6f  )..  (not can-no
11a0: 74 2d 72 75 6e 2d 6d 6f 72 65 29 29 29 29 29 0a  t-run-more))))).
11b0: 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  .;;=============
11c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
11d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
11e0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
11f0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 4e 65 77  =========.;; New
1200: 20 6d 65 74 68 6f 64 6f 6c 6f 67 79 2e 20 54 68   methodology. Th
1210: 65 73 65 20 72 6f 75 74 69 6e 65 73 20 77 69 6c  ese routines wil
1220: 6c 20 72 65 70 6c 61 63 65 20 74 68 65 20 61 62  l replace the ab
1230: 6f 76 65 20 69 6e 20 74 69 6d 65 2e 20 46 6f 72  ove in time. For
1240: 0a 3b 3b 20 6e 6f 77 20 74 68 65 20 63 6f 64 65  .;; now the code
1250: 20 69 73 20 64 75 70 6c 69 63 61 74 65 64 2e 20   is duplicated. 
1260: 54 68 69 73 20 73 74 75 66 66 20 69 73 20 69 6e  This stuff is in
1270: 69 74 69 61 6c 6c 79 20 75 73 65 64 20 69 6e 20  itially used in 
1280: 74 68 65 20 6d 6f 6e 69 74 6f 72 0a 3b 3b 20 62  the monitor.;; b
1290: 61 73 65 64 20 63 6f 64 65 2e 0a 3b 3b 3d 3d 3d  ased code..;;===
12a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
12b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
12c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
12d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
12e0: 3d 3d 3d 0a 0a 3b 3b 20 72 65 67 69 73 74 65 72  ===..;; register
12f0: 20 61 20 74 65 73 74 20 72 75 6e 20 77 69 74 68   a test run with
1300: 20 74 68 65 20 64 62 0a 28 64 65 66 69 6e 65 20   the db.(define 
1310: 28 72 75 6e 73 3a 72 65 67 69 73 74 65 72 2d 72  (runs:register-r
1320: 75 6e 20 64 62 20 6b 65 79 73 20 6b 65 79 76 61  un db keys keyva
1330: 6c 6c 73 74 20 72 75 6e 6e 61 6d 65 20 73 74 61  llst runname sta
1340: 74 65 20 73 74 61 74 75 73 20 75 73 65 72 29 0a  te status user).
1350: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 33    (debug:print 3
1360: 20 22 72 75 6e 73 3a 72 65 67 69 73 74 65 72 2d   "runs:register-
1370: 72 75 6e 2c 20 6b 65 79 73 3a 20 22 20 6b 65 79  run, keys: " key
1380: 73 20 22 20 6b 65 79 76 61 6c 6c 73 74 3a 20 22  s " keyvallst: "
1390: 20 6b 65 79 76 61 6c 6c 73 74 20 22 20 72 75 6e   keyvallst " run
13a0: 6e 61 6d 65 3a 20 22 20 72 75 6e 6e 61 6d 65 20  name: " runname 
13b0: 22 20 73 74 61 74 65 3a 20 22 20 73 74 61 74 65  " state: " state
13c0: 20 22 20 73 74 61 74 75 73 3a 20 22 20 73 74 61   " status: " sta
13d0: 74 75 73 20 22 20 75 73 65 72 3a 20 22 20 75 73  tus " user: " us
13e0: 65 72 29 0a 20 20 28 6c 65 74 2a 20 28 28 6b 65  er).  (let* ((ke
13f0: 79 73 74 72 20 20 20 20 28 6b 65 79 73 2d 3e 6b  ystr    (keys->k
1400: 65 79 73 74 72 20 6b 65 79 73 29 29 0a 09 20 28  eystr keys)).. (
1410: 63 6f 6d 6d 61 20 20 20 20 20 28 69 66 20 28 3e  comma     (if (>
1420: 20 28 6c 65 6e 67 74 68 20 6b 65 79 73 29 20 30   (length keys) 0
1430: 29 20 22 2c 22 20 22 22 29 29 0a 09 20 28 61 6e  ) "," "")).. (an
1440: 64 73 74 72 20 20 20 20 28 69 66 20 28 3e 20 28  dstr    (if (> (
1450: 6c 65 6e 67 74 68 20 6b 65 79 73 29 20 30 29 20  length keys) 0) 
1460: 22 20 41 4e 44 20 22 20 22 22 29 29 0a 09 20 28  " AND " "")).. (
1470: 76 61 6c 73 6c 6f 74 73 20 20 28 6b 65 79 73 2d  valslots  (keys-
1480: 3e 76 61 6c 73 6c 6f 74 73 20 6b 65 79 73 29 29  >valslots keys))
1490: 20 3b 3b 20 3f 2c 3f 2c 3f 20 2e 2e 2e 0a 09 20   ;; ?,?,? ..... 
14a0: 28 6b 65 79 76 61 6c 73 20 20 20 28 6d 61 70 20  (keyvals   (map 
14b0: 63 61 64 72 20 6b 65 79 76 61 6c 6c 73 74 29 29  cadr keyvallst))
14c0: 0a 09 20 28 61 6c 6c 76 61 6c 73 20 20 20 28 61  .. (allvals   (a
14d0: 70 70 65 6e 64 20 28 6c 69 73 74 20 72 75 6e 6e  ppend (list runn
14e0: 61 6d 65 20 73 74 61 74 65 20 73 74 61 74 75 73  ame state status
14f0: 20 75 73 65 72 29 20 6b 65 79 76 61 6c 73 29 29   user) keyvals))
1500: 0a 09 20 28 71 72 79 76 61 6c 73 20 20 20 28 61  .. (qryvals   (a
1510: 70 70 65 6e 64 20 28 6c 69 73 74 20 72 75 6e 6e  ppend (list runn
1520: 61 6d 65 29 20 6b 65 79 76 61 6c 73 29 29 0a 09  ame) keyvals))..
1530: 20 28 6b 65 79 3d 3f 73 74 72 20 20 28 73 74 72   (key=?str  (str
1540: 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20  ing-intersperse 
1550: 28 6d 61 70 20 28 6c 61 6d 62 64 61 20 28 6b 29  (map (lambda (k)
1560: 28 63 6f 6e 63 20 28 6b 65 79 3a 67 65 74 2d 66  (conc (key:get-f
1570: 69 65 6c 64 6e 61 6d 65 20 6b 29 20 22 3d 3f 22  ieldname k) "=?"
1580: 29 29 20 6b 65 79 73 29 20 22 20 41 4e 44 20 22  )) keys) " AND "
1590: 29 29 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70  ))).    (debug:p
15a0: 72 69 6e 74 20 33 20 22 6b 65 79 73 3a 20 22 20  rint 3 "keys: " 
15b0: 6b 65 79 73 20 22 20 61 6c 6c 76 61 6c 73 3a 20  keys " allvals: 
15c0: 22 20 61 6c 6c 76 61 6c 73 20 22 20 6b 65 79 76  " allvals " keyv
15d0: 61 6c 73 3a 20 22 20 6b 65 79 76 61 6c 73 29 0a  als: " keyvals).
15e0: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
15f0: 20 32 20 22 4e 4f 54 45 3a 20 75 73 69 6e 67 20   2 "NOTE: using 
1600: 74 61 72 67 65 74 20 22 20 28 73 74 72 69 6e 67  target " (string
1610: 2d 69 6e 74 65 72 73 70 65 72 73 65 20 6b 65 79  -intersperse key
1620: 76 61 6c 73 20 22 2f 22 29 20 22 20 66 6f 72 20  vals "/") " for 
1630: 74 68 69 73 20 72 75 6e 22 29 0a 20 20 20 20 28  this run").    (
1640: 69 66 20 28 61 6e 64 20 72 75 6e 6e 61 6d 65 20  if (and runname 
1650: 28 6e 75 6c 6c 3f 20 28 66 69 6c 74 65 72 20 28  (null? (filter (
1660: 6c 61 6d 62 64 61 20 28 78 29 28 6e 6f 74 20 78  lambda (x)(not x
1670: 29 29 20 6b 65 79 76 61 6c 73 29 29 29 20 3b 3b  )) keyvals))) ;;
1680: 20 74 68 65 72 65 20 6d 75 73 74 20 62 65 20 61   there must be a
1690: 20 62 65 74 74 65 72 20 77 61 79 20 74 6f 20 22   better way to "
16a0: 61 70 70 6c 79 20 61 6e 64 22 0a 09 28 6c 65 74  apply and"..(let
16b0: 20 28 28 72 65 73 20 23 66 29 29 0a 09 20 20 28   ((res #f))..  (
16c0: 61 70 70 6c 79 20 73 71 6c 69 74 65 33 3a 65 78  apply sqlite3:ex
16d0: 65 63 75 74 65 20 64 62 20 28 63 6f 6e 63 20 22  ecute db (conc "
16e0: 49 4e 53 45 52 54 20 4f 52 20 49 47 4e 4f 52 45  INSERT OR IGNORE
16f0: 20 49 4e 54 4f 20 72 75 6e 73 20 28 72 75 6e 6e   INTO runs (runn
1700: 61 6d 65 2c 73 74 61 74 65 2c 73 74 61 74 75 73  ame,state,status
1710: 2c 6f 77 6e 65 72 2c 65 76 65 6e 74 5f 74 69 6d  ,owner,event_tim
1720: 65 22 20 63 6f 6d 6d 61 20 6b 65 79 73 74 72 20  e" comma keystr 
1730: 22 29 20 56 41 4c 55 45 53 20 28 3f 2c 3f 2c 3f  ") VALUES (?,?,?
1740: 2c 3f 2c 73 74 72 66 74 69 6d 65 28 27 25 73 27  ,?,strftime('%s'
1750: 2c 27 6e 6f 77 27 29 22 20 63 6f 6d 6d 61 20 76  ,'now')" comma v
1760: 61 6c 73 6c 6f 74 73 20 22 29 3b 22 29 0a 09 09  alslots ");")...
1770: 20 61 6c 6c 76 61 6c 73 29 0a 09 20 20 28 61 70   allvals)..  (ap
1780: 70 6c 79 20 73 71 6c 69 74 65 33 3a 66 6f 72 2d  ply sqlite3:for-
1790: 65 61 63 68 2d 72 6f 77 20 0a 09 20 20 20 28 6c  each-row ..   (l
17a0: 61 6d 62 64 61 20 28 69 64 29 0a 09 20 20 20 20  ambda (id)..    
17b0: 20 28 73 65 74 21 20 72 65 73 20 69 64 29 29 0a   (set! res id)).
17c0: 09 20 20 20 64 62 0a 09 20 20 20 28 6c 65 74 20  .   db..   (let 
17d0: 28 28 71 72 79 20 28 63 6f 6e 63 20 22 53 45 4c  ((qry (conc "SEL
17e0: 45 43 54 20 69 64 20 46 52 4f 4d 20 72 75 6e 73  ECT id FROM runs
17f0: 20 57 48 45 52 45 20 28 72 75 6e 6e 61 6d 65 3d   WHERE (runname=
1800: 3f 20 22 20 61 6e 64 73 74 72 20 6b 65 79 3d 3f  ? " andstr key=?
1810: 73 74 72 20 22 29 3b 22 29 29 29 0a 09 20 20 20  str ");")))..   
1820: 20 20 3b 28 64 65 62 75 67 3a 70 72 69 6e 74 20    ;(debug:print 
1830: 34 20 22 71 72 79 3a 20 22 20 71 72 79 29 20 0a  4 "qry: " qry) .
1840: 09 20 20 20 20 20 71 72 79 29 0a 09 20 20 20 71  .     qry)..   q
1850: 72 79 76 61 6c 73 29 0a 09 20 20 28 73 71 6c 69  ryvals)..  (sqli
1860: 74 65 33 3a 65 78 65 63 75 74 65 20 64 62 20 22  te3:execute db "
1870: 55 50 44 41 54 45 20 72 75 6e 73 20 53 45 54 20  UPDATE runs SET 
1880: 73 74 61 74 65 3d 3f 2c 73 74 61 74 75 73 3d 3f  state=?,status=?
1890: 20 57 48 45 52 45 20 69 64 3d 3f 3b 22 20 73 74   WHERE id=?;" st
18a0: 61 74 65 20 73 74 61 74 75 73 20 72 65 73 29 0a  ate status res).
18b0: 09 20 20 72 65 73 29 20 0a 09 28 62 65 67 69 6e  .  res) ..(begin
18c0: 0a 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ..  (debug:print
18d0: 20 30 20 22 45 52 52 4f 52 3a 20 43 61 6c 6c 65   0 "ERROR: Calle
18e0: 64 20 77 69 74 68 6f 75 74 20 61 6c 6c 20 6e 65  d without all ne
18f0: 63 65 73 73 61 72 79 20 6b 65 79 73 22 29 0a 09  cessary keys")..
1900: 20 20 23 66 29 29 29 29 0a 0a 3b 3b 20 54 68 69    #f))))..;; Thi
1910: 73 20 69 73 20 61 20 64 75 70 6c 69 63 61 74 65  s is a duplicate
1920: 20 6f 66 20 72 75 6e 2d 74 65 73 74 73 20 28 77   of run-tests (w
1930: 68 69 63 68 20 68 61 73 20 62 65 65 6e 20 64 65  hich has been de
1940: 70 72 65 63 61 74 65 64 29 2e 20 55 73 65 20 74  precated). Use t
1950: 68 69 73 20 6f 6e 65 20 69 6e 73 74 65 61 64 20  his one instead 
1960: 6f 66 20 72 75 6e 20 74 65 73 74 73 2e 0a 3b 3b  of run tests..;;
1970: 20 6b 65 79 76 61 6c 73 0a 28 64 65 66 69 6e 65   keyvals.(define
1980: 20 28 72 75 6e 73 3a 72 75 6e 2d 74 65 73 74 73   (runs:run-tests
1990: 20 64 62 20 74 61 72 67 65 74 20 72 75 6e 6e 61   db target runna
19a0: 6d 65 20 74 65 73 74 2d 70 61 74 74 73 20 75 73  me test-patts us
19b0: 65 72 20 66 6c 61 67 73 29 0a 20 20 28 6c 65 74  er flags).  (let
19c0: 2a 20 28 28 6b 65 79 73 20 20 20 20 20 20 20 20  * ((keys        
19d0: 28 72 64 62 3a 67 65 74 2d 6b 65 79 73 20 64 62  (rdb:get-keys db
19e0: 29 29 0a 09 20 28 6b 65 79 76 61 6c 6c 73 74 20  )).. (keyvallst 
19f0: 20 20 28 6b 65 79 73 3a 74 61 72 67 65 74 2d 3e    (keys:target->
1a00: 6b 65 79 76 61 6c 20 6b 65 79 73 20 74 61 72 67  keyval keys targ
1a10: 65 74 29 29 0a 09 20 28 72 75 6e 2d 69 64 20 20  et)).. (run-id  
1a20: 20 20 20 20 28 72 75 6e 73 3a 72 65 67 69 73 74      (runs:regist
1a30: 65 72 2d 72 75 6e 20 64 62 20 6b 65 79 73 20 6b  er-run db keys k
1a40: 65 79 76 61 6c 6c 73 74 20 72 75 6e 6e 61 6d 65  eyvallst runname
1a50: 20 22 6e 65 77 22 20 22 6e 2f 61 22 20 75 73 65   "new" "n/a" use
1a60: 72 29 29 20 20 3b 3b 20 20 74 65 73 74 2d 6e 61  r))  ;;  test-na
1a70: 6d 65 29 29 29 0a 09 20 28 64 65 66 65 72 72 65  me))).. (deferre
1a80: 64 20 20 20 20 27 28 29 29 20 3b 3b 20 64 65 6c  d    '()) ;; del
1a90: 61 79 20 72 75 6e 6e 69 6e 67 20 74 68 65 73 65  ay running these
1aa0: 20 73 69 6e 63 65 20 74 68 65 79 20 68 61 76 65   since they have
1ab0: 20 61 20 77 61 69 74 6f 6e 20 63 6c 61 75 73 65   a waiton clause
1ac0: 0a 09 20 3b 3b 20 6b 65 65 70 67 6f 69 6e 67 20  .. ;; keepgoing 
1ad0: 69 73 20 74 68 65 20 64 65 66 61 63 74 6f 20 6d  is the defacto m
1ae0: 6f 64 61 6c 69 74 79 20 6e 6f 77 2c 20 77 69 6c  odality now, wil
1af0: 6c 20 61 64 64 20 68 69 74 2d 6e 2d 72 75 6e 20  l add hit-n-run 
1b00: 61 20 62 69 74 20 6c 61 74 65 72 0a 09 20 3b 3b  a bit later.. ;;
1b10: 20 28 6b 65 65 70 67 6f 69 6e 67 20 20 20 28 68   (keepgoing   (h
1b20: 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65  ash-table-ref/de
1b30: 66 61 75 6c 74 20 66 6c 61 67 73 20 22 2d 6b 65  fault flags "-ke
1b40: 65 70 67 6f 69 6e 67 22 20 23 66 29 29 0a 09 20  epgoing" #f)).. 
1b50: 28 74 65 73 74 2d 6e 61 6d 65 73 20 20 27 28 29  (test-names  '()
1b60: 29 0a 09 20 28 72 75 6e 63 6f 6e 66 69 67 66 20  ).. (runconfigf 
1b70: 20 20 28 63 6f 6e 63 20 20 2a 74 6f 70 70 61 74    (conc  *toppat
1b80: 68 2a 20 22 2f 72 75 6e 63 6f 6e 66 69 67 73 2e  h* "/runconfigs.
1b90: 63 6f 6e 66 69 67 22 29 29 0a 09 20 28 72 65 71  config")).. (req
1ba0: 75 69 72 65 64 2d 74 65 73 74 73 20 27 28 29 29  uired-tests '())
1bb0: 0a 09 20 28 74 65 73 74 2d 72 65 63 6f 72 64 73  .. (test-records
1bc0: 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c   (make-hash-tabl
1bd0: 65 29 29 29 0a 0a 20 20 20 20 28 73 65 74 2d 6d  e)))..    (set-m
1be0: 65 67 61 74 65 73 74 2d 65 6e 76 2d 76 61 72 73  egatest-env-vars
1bf0: 20 64 62 20 72 75 6e 2d 69 64 29 20 3b 3b 20 74   db run-id) ;; t
1c00: 68 65 73 65 20 6d 61 79 20 62 65 20 6e 65 65 64  hese may be need
1c10: 65 64 20 62 79 20 74 68 65 20 6c 61 75 6e 63 68  ed by the launch
1c20: 69 6e 67 20 70 72 6f 63 65 73 73 0a 0a 20 20 20  ing process..   
1c30: 20 28 69 66 20 28 66 69 6c 65 2d 65 78 69 73 74   (if (file-exist
1c40: 73 3f 20 72 75 6e 63 6f 6e 66 69 67 66 29 0a 09  s? runconfigf)..
1c50: 28 73 65 74 75 70 2d 65 6e 76 2d 64 65 66 61 75  (setup-env-defau
1c60: 6c 74 73 20 64 62 20 72 75 6e 63 6f 6e 66 69 67  lts db runconfig
1c70: 66 20 72 75 6e 2d 69 64 20 2a 61 6c 72 65 61 64  f run-id *alread
1c80: 79 2d 73 65 65 6e 2d 72 75 6e 63 6f 6e 66 69 67  y-seen-runconfig
1c90: 2d 69 6e 66 6f 2a 20 22 70 72 65 2d 6c 61 75 6e  -info* "pre-laun
1ca0: 63 68 2d 65 6e 76 2d 76 61 72 73 22 29 0a 09 28  ch-env-vars")..(
1cb0: 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 57  debug:print 0 "W
1cc0: 41 52 4e 49 4e 47 3a 20 59 6f 75 20 64 6f 20 6e  ARNING: You do n
1cd0: 6f 74 20 68 61 76 65 20 61 20 72 75 6e 20 63 6f  ot have a run co
1ce0: 6e 66 69 67 20 66 69 6c 65 3a 20 22 20 72 75 6e  nfig file: " run
1cf0: 63 6f 6e 66 69 67 66 29 29 0a 20 20 20 20 0a 20  configf)).    . 
1d00: 20 20 20 3b 3b 20 6c 6f 6f 6b 20 75 70 20 61 6c     ;; look up al
1d10: 6c 20 74 65 73 74 73 20 6d 61 74 63 68 69 6e 67  l tests matching
1d20: 20 74 68 65 20 63 6f 6d 6d 61 20 73 65 70 61 72   the comma separ
1d30: 61 74 65 64 20 6c 69 73 74 20 6f 66 20 67 6c 6f  ated list of glo
1d40: 62 73 20 69 6e 0a 20 20 20 20 3b 3b 20 74 65 73  bs in.    ;; tes
1d50: 74 2d 70 61 74 74 73 20 28 75 73 69 6e 67 20 25  t-patts (using %
1d60: 20 61 73 20 77 69 6c 64 63 61 72 64 29 0a 20 20   as wildcard).  
1d70: 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 20 20    (for-each .   
1d80: 20 20 28 6c 61 6d 62 64 61 20 28 70 61 74 74 29    (lambda (patt)
1d90: 0a 20 20 20 20 20 20 20 28 6c 65 74 20 28 28 74  .       (let ((t
1da0: 65 73 74 73 20 28 67 6c 6f 62 20 28 63 6f 6e 63  ests (glob (conc
1db0: 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f 74 65 73   *toppath* "/tes
1dc0: 74 73 2f 22 20 28 73 74 72 69 6e 67 2d 74 72 61  ts/" (string-tra
1dd0: 6e 73 6c 61 74 65 20 70 61 74 74 20 22 25 22 20  nslate patt "%" 
1de0: 22 2a 22 29 29 29 29 29 0a 09 20 28 73 65 74 21  "*"))))).. (set!
1df0: 20 74 65 73 74 73 20 28 66 69 6c 74 65 72 20 28   tests (filter (
1e00: 6c 61 6d 62 64 61 20 28 74 65 73 74 29 28 66 69  lambda (test)(fi
1e10: 6c 65 2d 65 78 69 73 74 73 3f 20 28 63 6f 6e 63  le-exists? (conc
1e20: 20 74 65 73 74 20 22 2f 74 65 73 74 63 6f 6e 66   test "/testconf
1e30: 69 67 22 29 29 29 20 74 65 73 74 73 29 29 0a 09  ig"))) tests))..
1e40: 20 28 73 65 74 21 20 74 65 73 74 2d 6e 61 6d 65   (set! test-name
1e50: 73 20 28 61 70 70 65 6e 64 20 74 65 73 74 2d 6e  s (append test-n
1e60: 61 6d 65 73 20 0a 09 09 09 09 20 20 28 6d 61 70  ames .....  (map
1e70: 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74 70 29   (lambda (testp)
1e80: 0a 09 09 09 09 09 20 28 6c 61 73 74 20 28 73 74  ...... (last (st
1e90: 72 69 6e 67 2d 73 70 6c 69 74 20 74 65 73 74 70  ring-split testp
1ea0: 20 22 2f 22 29 29 29 0a 09 09 09 09 20 20 20 20   "/"))).....    
1eb0: 20 20 20 74 65 73 74 73 29 29 29 29 29 0a 20 20     tests))))).  
1ec0: 20 20 20 28 69 66 20 74 65 73 74 2d 70 61 74 74     (if test-patt
1ed0: 73 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20  s (string-split 
1ee0: 74 65 73 74 2d 70 61 74 74 73 20 22 2c 22 29 28  test-patts ",")(
1ef0: 6c 69 73 74 20 22 25 22 29 29 29 0a 0a 20 20 20  list "%")))..   
1f00: 20 20 3b 3b 20 6e 6f 77 20 72 65 6d 6f 76 65 20    ;; now remove 
1f10: 64 75 70 6c 69 63 61 74 65 73 0a 20 20 20 20 28  duplicates.    (
1f20: 73 65 74 21 20 74 65 73 74 2d 6e 61 6d 65 73 20  set! test-names 
1f30: 28 64 65 6c 65 74 65 2d 64 75 70 6c 69 63 61 74  (delete-duplicat
1f40: 65 73 20 74 65 73 74 2d 6e 61 6d 65 73 29 29 0a  es test-names)).
1f50: 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e  .    (debug:prin
1f60: 74 20 30 20 22 49 4e 46 4f 3a 20 74 65 73 74 20  t 0 "INFO: test 
1f70: 6e 61 6d 65 73 20 22 20 74 65 73 74 2d 6e 61 6d  names " test-nam
1f80: 65 73 29 0a 0a 20 20 20 20 3b 3b 20 6f 6e 20 74  es)..    ;; on t
1f90: 68 65 20 66 69 72 73 74 20 70 61 73 73 20 6f 72  he first pass or
1fa0: 20 63 61 6c 6c 20 74 6f 20 72 75 6e 2d 74 65 73   call to run-tes
1fb0: 74 73 20 73 65 74 20 46 41 49 4c 53 20 74 6f 20  ts set FAILS to 
1fc0: 4e 4f 54 5f 53 54 41 52 54 45 44 20 69 66 0a 20  NOT_STARTED if. 
1fd0: 20 20 20 3b 3b 20 2d 6b 65 65 70 67 6f 69 6e 67     ;; -keepgoing
1fe0: 20 69 73 20 73 70 65 63 69 66 69 65 64 0a 20 20   is specified.  
1ff0: 20 20 28 69 66 20 28 65 71 3f 20 2a 70 61 73 73    (if (eq? *pass
2000: 6e 75 6d 2a 20 30 29 0a 09 28 62 65 67 69 6e 0a  num* 0)..(begin.
2010: 09 20 20 3b 3b 20 68 61 76 65 20 74 6f 20 64 65  .  ;; have to de
2020: 6c 65 74 65 20 74 65 73 74 20 72 65 63 6f 72 64  lete test record
2030: 73 20 77 68 65 72 65 20 4e 4f 54 5f 53 54 41 52  s where NOT_STAR
2040: 54 45 44 20 73 69 6e 63 65 20 74 68 65 79 20 63  TED since they c
2050: 61 6e 20 63 61 75 73 65 20 2d 6b 65 65 70 67 6f  an cause -keepgo
2060: 69 6e 67 20 74 6f 20 0a 09 20 20 3b 3b 20 67 65  ing to ..  ;; ge
2070: 74 20 73 74 75 63 6b 20 64 75 65 20 74 6f 20 62  t stuck due to b
2080: 65 63 6f 6d 69 6e 67 20 69 6e 61 63 63 65 73 73  ecoming inaccess
2090: 69 62 6c 65 20 66 72 6f 6d 20 61 20 66 61 69 6c  ible from a fail
20a0: 65 64 20 74 65 73 74 2e 20 49 2e 65 2e 20 69 66  ed test. I.e. if
20b0: 20 74 65 73 74 20 42 20 64 65 70 65 6e 64 73 20   test B depends 
20c0: 0a 09 20 20 3b 3b 20 6f 6e 20 74 65 73 74 20 41  ..  ;; on test A
20d0: 20 62 75 74 20 74 65 73 74 20 42 20 72 65 61 63   but test B reac
20e0: 68 65 64 20 74 68 65 20 70 6f 69 6e 74 20 6f 6e  hed the point on
20f0: 20 62 65 69 6e 67 20 72 65 67 69 73 74 65 72 65   being registere
2100: 64 20 61 73 20 4e 4f 54 5f 53 54 41 52 54 45 44  d as NOT_STARTED
2110: 20 61 6e 64 20 74 65 73 74 0a 09 20 20 3b 3b 20   and test..  ;; 
2120: 41 20 66 61 69 6c 65 64 20 66 6f 72 20 73 6f 6d  A failed for som
2130: 65 20 72 65 61 73 6f 6e 20 74 68 65 6e 20 6f 6e  e reason then on
2140: 20 72 65 2d 72 75 6e 20 75 73 69 6e 67 20 2d 6b   re-run using -k
2150: 65 65 70 67 6f 69 6e 67 20 74 68 65 20 72 75 6e  eepgoing the run
2160: 20 63 61 6e 20 6e 65 76 65 72 20 63 6f 6d 70 6c   can never compl
2170: 65 74 65 2e 0a 09 20 20 28 64 62 3a 64 65 6c 65  ete...  (db:dele
2180: 74 65 2d 74 65 73 74 73 2d 69 6e 2d 73 74 61 74  te-tests-in-stat
2190: 65 20 64 62 20 72 75 6e 2d 69 64 20 22 4e 4f 54  e db run-id "NOT
21a0: 5f 53 54 41 52 54 45 44 22 29 0a 09 20 20 28 72  _STARTED")..  (r
21b0: 64 62 3a 73 65 74 2d 74 65 73 74 73 2d 73 74 61  db:set-tests-sta
21c0: 74 65 2d 73 74 61 74 75 73 20 64 62 20 72 75 6e  te-status db run
21d0: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 73 20 23  -id test-names #
21e0: 66 20 22 46 41 49 4c 22 20 22 4e 4f 54 5f 53 54  f "FAIL" "NOT_ST
21f0: 41 52 54 45 44 22 20 22 46 41 49 4c 22 29 29 29  ARTED" "FAIL")))
2200: 0a 0a 20 20 20 20 3b 3b 20 6e 6f 77 20 61 64 64  ..    ;; now add
2210: 20 6e 6f 6e 2d 64 69 72 65 63 74 6c 79 20 72 65   non-directly re
2220: 66 65 72 65 6e 63 65 64 20 64 65 70 65 6e 64 65  ferenced depende
2230: 6e 63 69 65 73 20 28 69 2e 65 2e 20 77 61 69 74  ncies (i.e. wait
2240: 6f 6e 29 0a 20 20 20 20 28 69 66 20 28 6e 6f 74  on).    (if (not
2250: 20 28 6e 75 6c 6c 3f 20 74 65 73 74 2d 6e 61 6d   (null? test-nam
2260: 65 73 29 29 0a 09 28 6c 65 74 20 6c 6f 6f 70 20  es))..(let loop 
2270: 28 28 68 65 64 20 28 63 61 72 20 74 65 73 74 2d  ((hed (car test-
2280: 6e 61 6d 65 73 29 29 0a 09 09 20 20 20 28 74 61  names))...   (ta
2290: 6c 20 28 63 64 72 20 74 65 73 74 2d 6e 61 6d 65  l (cdr test-name
22a0: 73 29 29 29 20 20 20 20 20 20 20 20 20 3b 3b 20  s)))         ;; 
22b0: 27 72 65 74 75 72 6e 2d 70 72 6f 63 73 20 74 65  'return-procs te
22c0: 6c 6c 73 20 74 68 65 20 63 6f 6e 66 69 67 20 72  lls the config r
22d0: 65 61 64 65 72 20 74 6f 20 70 72 65 70 20 72 75  eader to prep ru
22e0: 6e 6e 69 6e 67 20 73 79 73 74 65 6d 20 62 75 74  nning system but
22f0: 20 72 65 74 75 72 6e 20 61 20 70 72 6f 63 0a 09   return a proc..
2300: 20 20 28 6c 65 74 2a 20 28 28 63 6f 6e 66 69 67    (let* ((config
2310: 20 20 28 74 65 73 74 73 3a 67 65 74 2d 74 65 73    (tests:get-tes
2320: 74 63 6f 6e 66 69 67 20 68 65 64 20 27 72 65 74  tconfig hed 'ret
2330: 75 72 6e 2d 70 72 6f 63 73 29 29 0a 09 09 20 28  urn-procs))... (
2340: 77 61 69 74 6f 6e 73 20 28 73 74 72 69 6e 67 2d  waitons (string-
2350: 73 70 6c 69 74 20 28 6c 65 74 20 28 28 77 20 28  split (let ((w (
2360: 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 63 6f  config-lookup co
2370: 6e 66 69 67 20 22 72 65 71 75 69 72 65 6d 65 6e  nfig "requiremen
2380: 74 73 22 20 22 77 61 69 74 6f 6e 22 29 29 29 0a  ts" "waiton"))).
2390: 09 09 09 09 09 20 20 28 69 66 20 77 20 77 20 22  .....  (if w w "
23a0: 22 29 29 29 29 29 0a 09 20 20 20 20 3b 3b 20 28  ")))))..    ;; (
23b0: 69 74 65 6d 73 20 20 20 28 69 74 65 6d 73 3a 67  items   (items:g
23c0: 65 74 2d 69 74 65 6d 73 2d 66 72 6f 6d 2d 63 6f  et-items-from-co
23d0: 6e 66 69 67 20 63 6f 6e 66 69 67 29 29 29 0a 09  nfig config)))..
23e0: 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28 68 61      (if (not (ha
23f0: 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66  sh-table-ref/def
2400: 61 75 6c 74 20 74 65 73 74 2d 72 65 63 6f 72 64  ault test-record
2410: 73 20 68 65 64 20 23 66 29 29 0a 09 09 28 68 61  s hed #f))...(ha
2420: 73 68 2d 74 61 62 6c 65 2d 73 65 74 21 20 74 65  sh-table-set! te
2430: 73 74 2d 72 65 63 6f 72 64 73 0a 09 09 09 09 20  st-records..... 
2440: 68 65 64 20 28 76 65 63 74 6f 72 20 68 65 64 20  hed (vector hed 
2450: 20 20 20 20 3b 3b 20 30 0a 09 09 09 09 09 20 20      ;; 0......  
2460: 20 20 20 63 6f 6e 66 69 67 20 20 3b 3b 20 31 0a     config  ;; 1.
2470: 09 09 09 09 09 20 20 20 20 20 77 61 69 74 6f 6e  .....     waiton
2480: 73 20 3b 3b 20 32 0a 09 09 09 09 09 20 20 20 20  s ;; 2......    
2490: 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20   (config-lookup 
24a0: 63 6f 6e 66 69 67 20 22 72 65 71 75 69 72 65 6d  config "requirem
24b0: 65 6e 74 73 22 20 22 70 72 69 6f 72 69 74 79 22  ents" "priority"
24c0: 29 20 20 20 20 20 3b 3b 20 70 72 69 6f 72 69 74  )     ;; priorit
24d0: 79 20 33 0a 09 09 09 09 09 20 20 20 20 20 28 6c  y 3......     (l
24e0: 65 74 20 28 28 69 74 65 6d 73 20 20 20 20 20 20  et ((items      
24f0: 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f  (hash-table-ref/
2500: 64 65 66 61 75 6c 74 20 63 6f 6e 66 69 67 20 22  default config "
2510: 69 74 65 6d 73 22 20 23 66 29 29 20 3b 3b 20 69  items" #f)) ;; i
2520: 74 65 6d 73 20 34 0a 09 09 09 09 09 09 20 20 20  tems 4.......   
2530: 28 69 74 65 6d 73 74 61 62 6c 65 20 28 68 61 73  (itemstable (has
2540: 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61  h-table-ref/defa
2550: 75 6c 74 20 63 6f 6e 66 69 67 20 22 69 74 65 6d  ult config "item
2560: 73 74 61 62 6c 65 22 20 23 66 29 29 29 20 0a 09  stable" #f))) ..
2570: 09 09 09 09 20 20 20 20 20 20 20 3b 3b 20 69 66  ....       ;; if
2580: 20 65 69 74 68 65 72 20 69 74 65 6d 73 20 6f 72   either items or
2590: 20 69 74 65 6d 73 20 74 61 62 6c 65 20 69 73 20   items table is 
25a0: 61 20 70 72 6f 63 20 72 65 74 75 72 6e 20 69 74  a proc return it
25b0: 20 73 6f 20 74 65 73 74 20 72 75 6e 6e 69 6e 67   so test running
25c0: 0a 09 09 09 09 09 20 20 20 20 20 20 20 3b 3b 20  ......       ;; 
25d0: 70 72 6f 63 65 73 73 20 63 61 6e 20 6b 6e 6f 77  process can know
25e0: 20 74 6f 20 63 61 6c 6c 20 69 74 65 6d 73 3a 67   to call items:g
25f0: 65 74 2d 69 74 65 6d 73 2d 66 72 6f 6d 2d 63 6f  et-items-from-co
2600: 6e 66 69 67 0a 09 09 09 09 09 20 20 20 20 20 20  nfig......      
2610: 20 3b 3b 20 69 66 20 65 69 74 68 65 72 20 69 73   ;; if either is
2620: 20 61 20 6c 69 73 74 20 61 6e 64 20 6e 6f 6e 65   a list and none
2630: 20 69 73 20 61 20 70 72 6f 63 20 67 6f 20 61 68   is a proc go ah
2640: 65 61 64 20 61 6e 64 20 63 61 6c 6c 20 67 65 74  ead and call get
2650: 2d 69 74 65 6d 73 0a 09 09 09 09 09 20 20 20 20  -items......    
2660: 20 20 20 3b 3b 20 6f 74 68 65 72 77 69 73 65 20     ;; otherwise 
2670: 72 65 74 75 72 6e 20 23 66 20 2d 20 74 68 69 73  return #f - this
2680: 20 69 73 20 6e 6f 74 20 61 6e 20 69 74 65 72 61   is not an itera
2690: 74 65 64 20 74 65 73 74 0a 09 09 09 09 09 20 20  ted test......  
26a0: 20 20 20 20 20 28 63 6f 6e 64 0a 09 09 09 09 09       (cond......
26b0: 09 28 28 70 72 6f 63 65 64 75 72 65 3f 20 69 74  .((procedure? it
26c0: 65 6d 73 29 20 20 20 20 20 20 0a 09 09 09 09 09  ems)      ......
26d0: 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34  . (debug:print 4
26e0: 20 22 49 4e 46 4f 3a 20 69 74 65 6d 73 20 69 73   "INFO: items is
26f0: 20 61 20 70 72 6f 63 65 64 75 72 65 2c 20 77 69   a procedure, wi
2700: 6c 6c 20 63 61 6c 63 20 6c 61 74 65 72 22 29 0a  ll calc later").
2710: 09 09 09 09 09 09 20 69 74 65 6d 73 29 20 20 20  ...... items)   
2720: 20 20 20 20 20 20 20 20 20 3b 3b 20 63 61 6c 63           ;; calc
2730: 20 6c 61 74 65 72 0a 09 09 09 09 09 09 28 28 70   later.......((p
2740: 72 6f 63 65 64 75 72 65 3f 20 69 74 65 6d 73 74  rocedure? itemst
2750: 61 62 6c 65 29 0a 09 09 09 09 09 09 20 28 64 65  able)....... (de
2760: 62 75 67 3a 70 72 69 6e 74 20 34 20 22 49 4e 46  bug:print 4 "INF
2770: 4f 3a 20 69 74 65 6d 73 74 61 62 6c 65 20 69 73  O: itemstable is
2780: 20 61 20 70 72 6f 63 65 64 75 72 65 2c 20 77 69   a procedure, wi
2790: 6c 6c 20 63 61 6c 63 20 6c 61 74 65 72 22 29 0a  ll calc later").
27a0: 09 09 09 09 09 09 20 69 74 65 6d 73 74 61 62 6c  ...... itemstabl
27b0: 65 29 20 20 20 20 20 20 20 3b 3b 20 63 61 6c 63  e)       ;; calc
27c0: 20 6c 61 74 65 72 0a 09 09 09 09 09 09 28 28 66   later.......((f
27d0: 69 6c 74 65 72 20 28 6c 61 6d 62 64 61 20 28 78  ilter (lambda (x
27e0: 29 0a 09 09 09 09 09 09 09 20 20 20 28 6c 65 74  )........   (let
27f0: 20 28 28 76 61 6c 20 28 63 61 72 20 78 29 29 29   ((val (car x)))
2800: 0a 09 09 09 09 09 09 09 20 20 20 20 20 28 69 66  ........     (if
2810: 20 28 70 72 6f 63 65 64 75 72 65 3f 20 76 61 6c   (procedure? val
2820: 29 20 76 61 6c 20 23 66 29 29 29 0a 09 09 09 09  ) val #f))).....
2830: 09 09 09 20 28 61 70 70 65 6e 64 20 28 69 66 20  ... (append (if 
2840: 28 6c 69 73 74 3f 20 69 74 65 6d 73 29 20 69 74  (list? items) it
2850: 65 6d 73 20 27 28 29 29 0a 09 09 09 09 09 09 09  ems '())........
2860: 09 20 28 69 66 20 28 6c 69 73 74 3f 20 69 74 65  . (if (list? ite
2870: 6d 73 74 61 62 6c 65 29 20 69 74 65 6d 73 74 61  mstable) itemsta
2880: 62 6c 65 20 27 28 29 29 29 29 0a 09 09 09 09 09  ble '())))......
2890: 09 20 27 68 61 76 65 2d 70 72 6f 63 65 64 75 72  . 'have-procedur
28a0: 65 29 0a 09 09 09 09 09 09 28 28 6f 72 20 28 6c  e).......((or (l
28b0: 69 73 74 3f 20 69 74 65 6d 73 29 28 6c 69 73 74  ist? items)(list
28c0: 3f 20 69 74 65 6d 73 74 61 62 6c 65 29 29 20 3b  ? itemstable)) ;
28d0: 3b 20 63 61 6c 63 20 6e 6f 77 0a 09 09 09 09 09  ; calc now......
28e0: 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34  . (debug:print 4
28f0: 20 22 49 4e 46 4f 3a 20 69 74 65 6d 73 20 61 6e   "INFO: items an
2900: 64 20 69 74 65 6d 73 74 61 62 6c 65 20 61 72 65  d itemstable are
2910: 20 6c 69 73 74 73 2c 20 63 61 6c 63 20 6e 6f 77   lists, calc now
2920: 5c 6e 22 0a 09 09 09 09 09 09 09 20 20 20 20 20  \n"........     
2930: 20 22 20 20 20 20 69 74 65 6d 73 3a 20 22 20 69   "    items: " i
2940: 74 65 6d 73 20 22 20 69 74 65 6d 73 74 61 62 6c  tems " itemstabl
2950: 65 3a 20 22 20 69 74 65 6d 73 74 61 62 6c 65 29  e: " itemstable)
2960: 0a 09 09 09 09 09 09 20 28 69 74 65 6d 73 3a 67  ....... (items:g
2970: 65 74 2d 69 74 65 6d 73 2d 66 72 6f 6d 2d 63 6f  et-items-from-co
2980: 6e 66 69 67 20 63 6f 6e 66 69 67 29 29 0a 09 09  nfig config))...
2990: 09 09 09 09 28 65 6c 73 65 20 23 66 29 29 29 20  ....(else #f))) 
29a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
29b0: 20 20 20 20 20 20 20 20 20 20 3b 3b 20 6e 6f 74            ;; not
29c0: 20 69 74 65 72 61 74 65 64 0a 09 09 09 09 09 20   iterated...... 
29d0: 20 20 20 20 23 66 20 20 20 20 20 20 3b 3b 20 69      #f      ;; i
29e0: 74 65 6d 73 64 61 74 20 35 0a 09 09 09 09 09 20  temsdat 5...... 
29f0: 20 20 20 20 23 66 20 20 20 20 20 20 3b 3b 20 73      #f      ;; s
2a00: 70 61 72 65 20 2d 20 75 73 65 64 20 66 6f 72 20  pare - used for 
2a10: 69 74 65 6d 2d 70 61 74 68 0a 09 09 09 09 09 20  item-path...... 
2a20: 20 20 20 20 29 29 29 0a 09 20 20 20 20 28 66 6f      )))..    (fo
2a30: 72 2d 65 61 63 68 20 0a 09 20 20 20 20 20 28 6c  r-each ..     (l
2a40: 61 6d 62 64 61 20 28 77 61 69 74 6f 6e 29 0a 09  ambda (waiton)..
2a50: 20 20 20 20 20 20 20 28 69 66 20 28 61 6e 64 20         (if (and 
2a60: 77 61 69 74 6f 6e 20 28 6e 6f 74 20 28 6d 65 6d  waiton (not (mem
2a70: 62 65 72 20 77 61 69 74 6f 6e 20 74 65 73 74 2d  ber waiton test-
2a80: 6e 61 6d 65 73 29 29 29 0a 09 09 20 20 20 28 62  names)))...   (b
2a90: 65 67 69 6e 0a 09 09 20 20 20 20 20 28 73 65 74  egin...     (set
2aa0: 21 20 72 65 71 75 69 72 65 64 2d 74 65 73 74 73  ! required-tests
2ab0: 20 28 63 6f 6e 73 20 77 61 69 74 6f 6e 20 72 65   (cons waiton re
2ac0: 71 75 69 72 65 64 2d 74 65 73 74 73 29 29 0a 09  quired-tests))..
2ad0: 09 20 20 20 20 20 28 73 65 74 21 20 74 65 73 74  .     (set! test
2ae0: 2d 6e 61 6d 65 73 20 28 63 6f 6e 73 20 77 61 69  -names (cons wai
2af0: 74 6f 6e 20 74 65 73 74 2d 6e 61 6d 65 73 29 29  ton test-names))
2b00: 29 29 29 20 3b 3b 20 77 61 73 20 61 6e 20 61 70  ))) ;; was an ap
2b10: 70 65 6e 64 2c 20 6e 6f 77 20 61 20 63 6f 6e 73  pend, now a cons
2b20: 0a 09 20 20 20 20 20 77 61 69 74 6f 6e 73 29 0a  ..     waitons).
2b30: 09 20 20 20 20 28 6c 65 74 20 28 28 72 65 6d 74  .    (let ((remt
2b40: 65 73 74 73 20 28 64 65 6c 65 74 65 2d 64 75 70  ests (delete-dup
2b50: 6c 69 63 61 74 65 73 20 28 61 70 70 65 6e 64 20  licates (append 
2b60: 77 61 69 74 6f 6e 73 20 74 61 6c 29 29 29 29 0a  waitons tal)))).
2b70: 09 20 20 20 20 20 20 28 69 66 20 28 6e 6f 74 20  .      (if (not 
2b80: 28 6e 75 6c 6c 3f 20 72 65 6d 74 65 73 74 73 29  (null? remtests)
2b90: 29 0a 09 09 20 20 28 6c 6f 6f 70 20 28 63 61 72  )...  (loop (car
2ba0: 20 72 65 6d 74 65 73 74 73 29 28 63 64 72 20 72   remtests)(cdr r
2bb0: 65 6d 74 65 73 74 73 29 29 29 29 29 29 29 0a 0a  emtests)))))))..
2bc0: 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28 6e 75      (if (not (nu
2bd0: 6c 6c 3f 20 72 65 71 75 69 72 65 64 2d 74 65 73  ll? required-tes
2be0: 74 73 29 29 0a 09 28 64 65 62 75 67 3a 70 72 69  ts))..(debug:pri
2bf0: 6e 74 20 31 20 22 49 4e 46 4f 3a 20 41 64 64 69  nt 1 "INFO: Addi
2c00: 6e 67 20 22 20 72 65 71 75 69 72 65 64 2d 74 65  ng " required-te
2c10: 73 74 73 20 22 20 74 6f 20 74 68 65 20 72 75 6e  sts " to the run
2c20: 20 71 75 65 75 65 22 29 29 0a 20 20 20 20 3b 3b   queue")).    ;;
2c30: 20 4e 4f 54 45 3a 20 74 68 65 73 65 20 61 72 65   NOTE: these are
2c40: 20 61 6c 6c 20 70 61 72 65 6e 74 20 74 65 73 74   all parent test
2c50: 73 2c 20 69 74 65 6d 73 20 61 72 65 20 6e 6f 74  s, items are not
2c60: 20 65 78 70 61 6e 64 65 64 20 79 65 74 2e 0a 20   expanded yet.. 
2c70: 20 20 20 28 72 75 6e 73 3a 72 75 6e 2d 74 65 73     (runs:run-tes
2c80: 74 73 2d 71 75 65 75 65 20 64 62 20 72 75 6e 2d  ts-queue db run-
2c90: 69 64 20 72 75 6e 6e 61 6d 65 20 74 65 73 74 2d  id runname test-
2ca0: 72 65 63 6f 72 64 73 20 6b 65 79 76 61 6c 6c 73  records keyvalls
2cb0: 74 20 66 6c 61 67 73 29 0a 20 20 20 20 28 69 66  t flags).    (if
2cc0: 20 2a 72 70 63 3a 6c 69 73 74 65 6e 65 72 2a 20   *rpc:listener* 
2cd0: 28 73 65 72 76 65 72 3a 6b 65 65 70 2d 72 75 6e  (server:keep-run
2ce0: 6e 69 6e 67 20 64 62 29 29 0a 20 20 20 20 28 64  ning db)).    (d
2cf0: 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 49 4e  ebug:print 4 "IN
2d00: 46 4f 3a 20 41 6c 6c 20 64 6f 6e 65 20 62 79 20  FO: All done by 
2d10: 68 65 72 65 22 29 29 29 0a 0a 3b 3b 20 74 65 73  here")))..;; tes
2d20: 74 2d 72 65 63 6f 72 64 73 20 69 73 20 61 20 68  t-records is a h
2d30: 61 73 68 20 74 61 62 6c 65 20 74 65 73 74 6e 61  ash table testna
2d40: 6d 65 3a 69 74 65 6d 5f 70 61 74 68 20 3d 3e 20  me:item_path => 
2d50: 76 65 63 74 6f 72 20 3c 20 74 65 73 74 6e 61 6d  vector < testnam
2d60: 65 20 74 65 73 74 63 6f 6e 66 69 67 20 77 61 69  e testconfig wai
2d70: 74 6f 6e 73 20 70 72 69 6f 72 69 74 79 20 69 74  tons priority it
2d80: 65 6d 73 2d 69 6e 66 6f 20 2e 2e 2e 20 3e 0a 28  ems-info ... >.(
2d90: 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 72 75 6e  define (runs:run
2da0: 2d 74 65 73 74 73 2d 71 75 65 75 65 20 64 62 20  -tests-queue db 
2db0: 72 75 6e 2d 69 64 20 72 75 6e 6e 61 6d 65 20 74  run-id runname t
2dc0: 65 73 74 2d 72 65 63 6f 72 64 73 20 6b 65 79 76  est-records keyv
2dd0: 61 6c 6c 73 74 20 66 6c 61 67 73 29 0a 20 20 20  allst flags).   
2de0: 20 3b 3b 20 41 74 20 74 68 69 73 20 70 6f 69 6e   ;; At this poin
2df0: 74 20 74 68 65 20 6c 69 73 74 20 6f 66 20 70 61  t the list of pa
2e00: 72 65 6e 74 20 74 65 73 74 73 20 69 73 20 65 78  rent tests is ex
2e10: 70 61 6e 64 65 64 20 0a 20 20 20 20 3b 3b 20 4e  panded .    ;; N
2e20: 42 2f 2f 20 53 68 6f 75 6c 64 20 65 78 70 61 6e  B// Should expan
2e30: 64 20 69 74 65 6d 73 20 68 65 72 65 20 61 6e 64  d items here and
2e40: 20 74 68 65 6e 20 69 6e 73 65 72 74 20 69 6e 74   then insert int
2e50: 6f 20 74 68 65 20 72 75 6e 20 71 75 65 75 65 2e  o the run queue.
2e60: 0a 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20  .  (debug:print 
2e70: 35 20 22 74 65 73 74 2d 72 65 63 6f 72 64 73 3a  5 "test-records:
2e80: 20 22 20 74 65 73 74 2d 72 65 63 6f 72 64 73 20   " test-records 
2e90: 22 2c 20 6b 65 79 76 61 6c 6c 73 74 3a 20 22 20  ", keyvallst: " 
2ea0: 6b 65 79 76 61 6c 6c 73 74 20 22 20 66 6c 61 67  keyvallst " flag
2eb0: 73 3a 20 22 20 28 68 61 73 68 2d 74 61 62 6c 65  s: " (hash-table
2ec0: 2d 3e 61 6c 69 73 74 20 66 6c 61 67 73 29 29 0a  ->alist flags)).
2ed0: 20 20 28 6c 65 74 20 28 28 73 6f 72 74 65 64 2d    (let ((sorted-
2ee0: 74 65 73 74 2d 6e 61 6d 65 73 20 28 74 65 73 74  test-names (test
2ef0: 73 3a 73 6f 72 74 2d 62 79 2d 70 72 69 6f 72 69  s:sort-by-priori
2f00: 74 79 2d 61 6e 64 2d 77 61 69 74 6f 6e 20 74 65  ty-and-waiton te
2f10: 73 74 2d 72 65 63 6f 72 64 73 29 29 0a 09 28 69  st-records))..(i
2f20: 74 65 6d 2d 70 61 74 74 73 20 20 20 20 20 20 20  tem-patts       
2f30: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
2f40: 2f 64 65 66 61 75 6c 74 20 66 6c 61 67 73 20 22  /default flags "
2f50: 2d 69 74 65 6d 70 61 74 74 22 20 23 66 29 29 29  -itempatt" #f)))
2f60: 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28 6e  .    (if (not (n
2f70: 75 6c 6c 3f 20 73 6f 72 74 65 64 2d 74 65 73 74  ull? sorted-test
2f80: 2d 6e 61 6d 65 73 29 29 0a 09 28 6c 65 74 20 6c  -names))..(let l
2f90: 6f 6f 70 20 28 3b 20 28 6e 75 6d 74 69 6d 65 73  oop (; (numtimes
2fa0: 20 30 29 20 3b 3b 20 73 68 6f 75 6c 64 6e 27 74   0) ;; shouldn't
2fb0: 20 6e 65 65 64 20 74 68 69 73 0a 09 09 20 20 20   need this...   
2fc0: 28 68 65 64 20 20 20 20 20 20 20 20 20 28 63 61  (hed         (ca
2fd0: 72 20 73 6f 72 74 65 64 2d 74 65 73 74 2d 6e 61  r sorted-test-na
2fe0: 6d 65 73 29 29 0a 09 09 20 20 20 28 74 61 6c 20  mes))...   (tal 
2ff0: 20 20 20 20 20 20 20 20 28 63 64 72 20 73 6f 72          (cdr sor
3000: 74 65 64 2d 74 65 73 74 2d 6e 61 6d 65 73 29 29  ted-test-names))
3010: 29 0a 09 20 20 28 6c 65 74 2a 20 28 28 74 65 73  )..  (let* ((tes
3020: 74 2d 72 65 63 6f 72 64 20 28 68 61 73 68 2d 74  t-record (hash-t
3030: 61 62 6c 65 2d 72 65 66 20 74 65 73 74 2d 72 65  able-ref test-re
3040: 63 6f 72 64 73 20 68 65 64 29 29 0a 09 09 20 28  cords hed))... (
3050: 74 63 6f 6e 66 69 67 20 20 20 20 20 28 74 65 73  tconfig     (tes
3060: 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74  ts:testqueue-get
3070: 2d 74 65 73 74 63 6f 6e 66 69 67 20 74 65 73 74  -testconfig test
3080: 2d 72 65 63 6f 72 64 29 29 0a 09 09 20 28 77 61  -record))... (wa
3090: 69 74 6f 6e 73 20 20 20 20 20 28 74 65 73 74 73  itons     (tests
30a0: 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d 77  :testqueue-get-w
30b0: 61 69 74 6f 6e 73 20 20 20 20 74 65 73 74 2d 72  aitons    test-r
30c0: 65 63 6f 72 64 29 29 0a 09 09 20 28 70 72 69 6f  ecord))... (prio
30d0: 72 69 74 79 20 20 20 20 28 74 65 73 74 73 3a 74  rity    (tests:t
30e0: 65 73 74 71 75 65 75 65 2d 67 65 74 2d 70 72 69  estqueue-get-pri
30f0: 6f 72 69 74 79 20 20 20 74 65 73 74 2d 72 65 63  ority   test-rec
3100: 6f 72 64 29 29 0a 09 09 20 28 69 74 65 6d 64 61  ord))... (itemda
3110: 74 20 20 20 20 20 28 74 65 73 74 73 3a 74 65 73  t     (tests:tes
3120: 74 71 75 65 75 65 2d 67 65 74 2d 69 74 65 6d 64  tqueue-get-itemd
3130: 61 74 20 20 20 20 74 65 73 74 2d 72 65 63 6f 72  at    test-recor
3140: 64 29 29 20 3b 3b 20 69 74 65 6d 64 61 74 20 63  d)) ;; itemdat c
3150: 61 6e 20 62 65 20 61 20 73 74 72 69 6e 67 2c 20  an be a string, 
3160: 6c 69 73 74 20 6f 72 20 23 66 0a 09 09 20 28 69  list or #f... (i
3170: 74 65 6d 73 20 20 20 20 20 20 20 28 74 65 73 74  tems       (test
3180: 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d  s:testqueue-get-
3190: 69 74 65 6d 73 20 20 20 20 20 20 74 65 73 74 2d  items      test-
31a0: 72 65 63 6f 72 64 29 29 0a 09 09 20 28 69 74 65  record))... (ite
31b0: 6d 2d 70 61 74 68 20 20 20 28 69 74 65 6d 2d 6c  m-path   (item-l
31c0: 69 73 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61  ist->path itemda
31d0: 74 29 29 29 0a 09 20 20 20 20 28 64 65 62 75 67  t)))..    (debug
31e0: 3a 70 72 69 6e 74 20 36 0a 09 09 09 20 22 69 74  :print 6.... "it
31f0: 65 6d 64 61 74 3a 20 20 20 20 20 22 20 69 74 65  emdat:     " ite
3200: 6d 64 61 74 0a 09 09 09 20 22 5c 6e 20 20 69 74  mdat.... "\n  it
3210: 65 6d 73 3a 20 20 20 20 20 22 20 69 74 65 6d 73  ems:     " items
3220: 0a 09 09 09 20 22 5c 6e 20 20 69 74 65 6d 2d 70  .... "\n  item-p
3230: 61 74 68 3a 20 22 20 69 74 65 6d 2d 70 61 74 68  ath: " item-path
3240: 29 0a 09 20 20 20 20 28 63 6f 6e 64 0a 09 20 20  )..    (cond..  
3250: 20 20 20 28 28 6e 6f 74 20 69 74 65 6d 73 29 20     ((not items) 
3260: 3b 3b 20 77 68 65 6e 20 66 61 6c 73 65 20 74 68  ;; when false th
3270: 65 20 74 65 73 74 20 69 73 20 6f 6b 20 74 6f 20  e test is ok to 
3280: 62 65 20 68 61 6e 64 65 64 20 6f 66 66 20 74 6f  be handed off to
3290: 20 6c 61 75 6e 63 68 20 28 62 75 74 20 6e 6f 74   launch (but not
32a0: 20 62 65 66 6f 72 65 29 0a 09 20 20 20 20 20 20   before)..      
32b0: 28 6c 65 74 20 28 28 68 61 76 65 2d 72 65 73 6f  (let ((have-reso
32c0: 75 72 63 65 73 20 20 28 72 75 6e 73 3a 63 61 6e  urces  (runs:can
32d0: 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20  -run-more-tests 
32e0: 64 62 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29  db test-record))
32f0: 20 3b 3b 20 6c 6f 6f 6b 20 61 74 20 74 68 65 20   ;; look at the 
3300: 74 65 73 74 20 6a 6f 62 67 72 6f 75 70 20 61 6e  test jobgroup an
3310: 64 20 74 6f 74 20 6a 6f 62 73 20 72 75 6e 6e 69  d tot jobs runni
3320: 6e 67 0a 09 09 20 20 20 20 28 70 72 65 72 65 71  ng...    (prereq
3330: 73 2d 6e 6f 74 2d 6d 65 74 20 28 64 62 3a 67 65  s-not-met (db:ge
3340: 74 2d 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65  t-prereqs-not-me
3350: 74 20 64 62 20 72 75 6e 2d 69 64 20 77 61 69 74  t db run-id wait
3360: 6f 6e 73 20 69 74 65 6d 2d 70 61 74 68 29 29 29  ons item-path)))
3370: 0a 09 09 3b 3b 20 44 6f 6e 27 74 20 6b 6e 6f 77  ...;; Don't know
3380: 20 61 74 20 74 68 69 73 20 74 69 6d 65 20 69 66   at this time if
3390: 20 74 68 65 20 74 65 73 74 20 68 61 76 65 20 62   the test have b
33a0: 65 65 6e 20 6c 61 75 6e 63 68 65 64 20 61 74 20  een launched at 
33b0: 73 6f 6d 65 20 74 69 6d 65 20 69 6e 20 74 68 65  some time in the
33c0: 20 70 61 73 74 0a 09 09 3b 3b 20 69 2e 65 2e 20   past...;; i.e. 
33d0: 69 73 20 74 68 69 73 20 61 20 72 65 2d 6c 61 75  is this a re-lau
33e0: 6e 63 68 3f 0a 09 09 28 69 66 20 28 61 6e 64 20  nch?...(if (and 
33f0: 68 61 76 65 2d 72 65 73 6f 75 72 63 65 73 0a 09  have-resources..
3400: 09 09 20 28 6e 75 6c 6c 3f 20 70 72 65 72 65 71  .. (null? prereq
3410: 73 2d 6e 6f 74 2d 6d 65 74 29 29 0a 09 09 20 20  s-not-met))...  
3420: 20 20 3b 3b 20 6e 6f 20 6c 6f 6f 70 20 2d 20 64    ;; no loop - d
3430: 72 6f 70 20 74 68 6f 75 67 68 20 61 6e 64 20 75  rop though and u
3440: 73 65 20 74 68 65 20 6c 6f 6f 70 20 61 74 20 74  se the loop at t
3450: 68 65 20 62 6f 74 74 6f 6d 20 0a 09 09 20 20 20  he bottom ...   
3460: 20 28 69 66 20 28 70 61 74 74 2d 6c 69 73 74 2d   (if (patt-list-
3470: 6d 61 74 63 68 20 69 74 65 6d 2d 70 61 74 68 20  match item-path 
3480: 69 74 65 6d 2d 70 61 74 74 73 29 0a 09 09 09 28  item-patts)....(
3490: 72 75 6e 3a 74 65 73 74 20 64 62 20 72 75 6e 2d  run:test db run-
34a0: 69 64 20 72 75 6e 6e 61 6d 65 20 6b 65 79 76 61  id runname keyva
34b0: 6c 6c 73 74 20 74 65 73 74 2d 72 65 63 6f 72 64  llst test-record
34c0: 20 66 6c 61 67 73 20 23 66 29 0a 09 09 09 28 64   flags #f)....(d
34d0: 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 49 4e  ebug:print 1 "IN
34e0: 46 4f 3a 20 53 6b 69 70 70 69 6e 67 20 22 20 28  FO: Skipping " (
34f0: 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d  tests:testqueue-
3500: 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73  get-testname tes
3510: 74 2d 72 65 63 6f 72 64 29 20 22 20 22 20 69 74  t-record) " " it
3520: 65 6d 2d 70 61 74 68 20 22 20 61 73 20 69 74 20  em-path " as it 
3530: 64 6f 65 73 6e 27 74 20 6d 61 74 63 68 20 22 20  doesn't match " 
3540: 69 74 65 6d 2d 70 61 74 74 73 29 29 0a 09 09 20  item-patts))... 
3550: 20 20 20 3b 3b 20 65 6c 73 65 20 74 68 65 20 72     ;; else the r
3560: 75 6e 20 69 73 20 73 74 75 63 6b 2c 20 74 65 6d  un is stuck, tem
3570: 70 6f 72 61 72 69 6c 79 20 6f 72 20 70 65 72 6d  porarily or perm
3580: 61 6e 65 6e 74 6c 79 0a 09 09 20 20 20 20 28 6c  anently...    (l
3590: 65 74 20 28 28 6e 65 77 74 61 6c 20 28 61 70 70  et ((newtal (app
35a0: 65 6e 64 20 74 61 6c 20 28 6c 69 73 74 20 68 65  end tal (list he
35b0: 64 29 29 29 29 0a 09 09 20 20 20 20 20 20 3b 3b  d))))...      ;;
35c0: 20 63 6f 75 6c 64 6e 27 74 20 72 75 6e 2c 20 74   couldn't run, t
35d0: 61 6b 65 20 61 20 62 72 65 61 74 68 65 72 0a 09  ake a breather..
35e0: 09 20 20 20 20 20 20 28 74 68 72 65 61 64 2d 73  .      (thread-s
35f0: 6c 65 65 70 21 20 30 2e 31 29 20 3b 3b 20 6c 6f  leep! 0.1) ;; lo
3600: 6e 67 20 73 6c 65 65 70 20 68 65 72 65 20 2d 20  ng sleep here - 
3610: 6e 6f 20 72 65 73 6f 75 72 63 65 73 2c 20 6d 61  no resources, ma
3620: 79 20 61 73 20 77 65 6c 6c 20 62 65 20 70 61 74  y as well be pat
3630: 69 65 6e 74 0a 09 09 20 20 20 20 20 20 28 6c 6f  ient...      (lo
3640: 6f 70 20 28 63 61 72 20 6e 65 77 74 61 6c 29 28  op (car newtal)(
3650: 63 64 72 20 6e 65 77 74 61 6c 29 29 29 29 29 29  cdr newtal))))))
3660: 0a 09 20 20 20 20 20 0a 09 20 20 20 20 20 3b 3b  ..     ..     ;;
3670: 20 63 61 73 65 20 77 68 65 72 65 20 61 6e 20 69   case where an i
3680: 74 65 6d 73 20 63 61 6d 65 20 69 6e 20 61 73 20  tems came in as 
3690: 61 20 6c 69 73 74 20 62 65 65 6e 20 70 72 6f 63  a list been proc
36a0: 65 73 73 65 64 0a 09 20 20 20 20 20 28 28 61 6e  essed..     ((an
36b0: 64 20 28 6c 69 73 74 3f 20 69 74 65 6d 73 29 20  d (list? items) 
36c0: 20 20 20 20 3b 3b 20 74 68 75 73 20 77 65 20 6b      ;; thus we k
36d0: 6e 6f 77 20 6f 75 72 20 69 74 65 6d 73 20 61 72  now our items ar
36e0: 65 20 61 6c 72 65 61 64 79 20 63 61 6c 63 75 6c  e already calcul
36f0: 61 74 65 64 0a 09 09 20 20 20 28 6e 6f 74 20 20  ated...   (not  
3700: 20 69 74 65 6d 64 61 74 29 29 20 3b 3b 20 61 6e   itemdat)) ;; an
3710: 64 20 6e 6f 74 20 79 65 74 20 65 78 70 61 6e 64  d not yet expand
3720: 65 64 20 69 6e 74 6f 20 74 68 65 20 6c 69 73 74  ed into the list
3730: 20 6f 66 20 74 68 69 6e 67 73 20 74 6f 20 62 65   of things to be
3740: 20 64 6f 6e 65 0a 09 20 20 20 20 20 20 28 69 66   done..      (if
3750: 20 28 61 6e 64 20 28 3e 3d 20 2a 76 65 72 62 6f   (and (>= *verbo
3760: 73 69 74 79 2a 20 31 29 0a 09 09 20 20 20 20 20  sity* 1)...     
3770: 20 20 28 3e 20 28 6c 65 6e 67 74 68 20 69 74 65    (> (length ite
3780: 6d 73 29 20 30 29 0a 09 09 20 20 20 20 20 20 20  ms) 0)...       
3790: 28 3e 20 28 6c 65 6e 67 74 68 20 28 63 61 72 20  (> (length (car 
37a0: 69 74 65 6d 73 29 29 20 30 29 29 0a 09 09 20 20  items)) 0))...  
37b0: 28 70 70 20 69 74 65 6d 73 29 29 0a 09 20 20 20  (pp items))..   
37c0: 20 20 20 3b 3b 20 28 69 66 20 28 3e 3d 20 2a 76     ;; (if (>= *v
37d0: 65 72 62 6f 73 69 74 79 2a 20 35 29 0a 09 20 20  erbosity* 5)..  
37e0: 20 20 20 20 3b 3b 20 20 20 20 20 28 62 65 67 69      ;;     (begi
37f0: 6e 0a 09 20 20 20 20 20 20 3b 3b 20 20 20 20 20  n..      ;;     
3800: 20 20 28 70 72 69 6e 74 20 22 69 74 65 6d 73 3a    (print "items:
3810: 20 22 29 20 20 20 20 20 28 70 70 20 28 69 74 65   ")     (pp (ite
3820: 6d 2d 61 73 73 6f 63 2d 3e 69 74 65 6d 2d 6c 69  m-assoc->item-li
3830: 73 74 20 69 74 65 6d 73 29 29 0a 09 20 20 20 20  st items))..    
3840: 20 20 3b 3b 20 20 20 20 20 20 20 28 70 72 69 6e    ;;       (prin
3850: 74 20 22 69 74 65 6d 73 74 61 62 6c 65 3a 20 22  t "itemstable: "
3860: 29 28 70 70 20 28 69 74 65 6d 2d 74 61 62 6c 65  )(pp (item-table
3870: 2d 3e 69 74 65 6d 2d 6c 69 73 74 20 69 74 65 6d  ->item-list item
3880: 73 74 61 62 6c 65 29 29 29 29 0a 09 20 20 20 20  stable))))..    
3890: 20 20 28 66 6f 72 2d 65 61 63 68 0a 09 20 20 20    (for-each..   
38a0: 20 20 20 20 28 6c 61 6d 62 64 61 20 28 6d 79 2d      (lambda (my-
38b0: 69 74 65 6d 64 61 74 29 0a 09 09 20 28 6c 65 74  itemdat)... (let
38c0: 2a 20 28 28 6e 65 77 2d 74 65 73 74 2d 72 65 63  * ((new-test-rec
38d0: 6f 72 64 20 28 6c 65 74 20 28 28 6e 65 77 72 65  ord (let ((newre
38e0: 63 20 28 6d 61 6b 65 2d 74 65 73 74 73 3a 74 65  c (make-tests:te
38f0: 73 74 71 75 65 75 65 29 29 29 0a 09 09 09 09 09  stqueue)))......
3900: 20 20 20 28 76 65 63 74 6f 72 2d 63 6f 70 79 21     (vector-copy!
3910: 20 74 65 73 74 2d 72 65 63 6f 72 64 20 6e 65 77   test-record new
3920: 72 65 63 29 0a 09 09 09 09 09 20 20 20 6e 65 77  rec)......   new
3930: 72 65 63 29 29 0a 09 09 09 28 6d 79 2d 69 74 65  rec))....(my-ite
3940: 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c 69 73  m-path (item-lis
3950: 74 2d 3e 70 61 74 68 20 6d 79 2d 69 74 65 6d 64  t->path my-itemd
3960: 61 74 29 29 29 0a 09 09 20 20 20 28 69 66 20 28  at)))...   (if (
3970: 70 61 74 74 2d 6c 69 73 74 2d 6d 61 74 63 68 20  patt-list-match 
3980: 6d 79 2d 69 74 65 6d 2d 70 61 74 68 20 69 74 65  my-item-path ite
3990: 6d 2d 70 61 74 74 73 29 20 20 20 20 20 20 20 20  m-patts)        
39a0: 20 20 20 3b 3b 20 79 65 73 2c 20 77 65 20 77 61     ;; yes, we wa
39b0: 6e 74 20 74 6f 20 70 72 6f 63 65 73 73 20 74 68  nt to process th
39c0: 69 73 20 69 74 65 6d 2c 20 4e 4f 54 45 3a 20 53  is item, NOTE: S
39d0: 68 6f 75 6c 64 20 6e 6f 74 20 6e 65 65 64 20 74  hould not need t
39e0: 68 69 73 20 63 68 65 63 6b 20 68 65 72 65 21 0a  his check here!.
39f0: 09 09 20 20 20 20 20 20 20 28 6c 65 74 20 28 28  ..       (let ((
3a00: 6e 65 77 74 65 73 74 6e 61 6d 65 20 28 63 6f 6e  newtestname (con
3a10: 63 20 68 65 64 20 22 2f 22 20 6d 79 2d 69 74 65  c hed "/" my-ite
3a20: 6d 2d 70 61 74 68 29 29 29 20 20 20 20 3b 3b 20  m-path)))    ;; 
3a30: 74 65 73 74 20 6e 61 6d 65 73 20 61 72 65 20 75  test names are u
3a40: 6e 69 71 75 65 20 6f 6e 20 74 65 73 74 6e 61 6d  nique on testnam
3a50: 65 2f 69 74 65 6d 2d 70 61 74 68 0a 09 09 09 20  e/item-path.... 
3a60: 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65  (tests:testqueue
3a70: 2d 73 65 74 2d 69 74 65 6d 73 21 20 20 20 20 20  -set-items!     
3a80: 6e 65 77 2d 74 65 73 74 2d 72 65 63 6f 72 64 20  new-test-record 
3a90: 23 66 29 0a 09 09 09 20 28 74 65 73 74 73 3a 74  #f).... (tests:t
3aa0: 65 73 74 71 75 65 75 65 2d 73 65 74 2d 69 74 65  estqueue-set-ite
3ab0: 6d 64 61 74 21 20 20 20 6e 65 77 2d 74 65 73 74  mdat!   new-test
3ac0: 2d 72 65 63 6f 72 64 20 6d 79 2d 69 74 65 6d 64  -record my-itemd
3ad0: 61 74 29 0a 09 09 09 20 28 74 65 73 74 73 3a 74  at).... (tests:t
3ae0: 65 73 74 71 75 65 75 65 2d 73 65 74 2d 69 74 65  estqueue-set-ite
3af0: 6d 5f 70 61 74 68 21 20 6e 65 77 2d 74 65 73 74  m_path! new-test
3b00: 2d 72 65 63 6f 72 64 20 6d 79 2d 69 74 65 6d 2d  -record my-item-
3b10: 70 61 74 68 29 0a 09 09 09 20 28 68 61 73 68 2d  path).... (hash-
3b20: 74 61 62 6c 65 2d 73 65 74 21 20 74 65 73 74 2d  table-set! test-
3b30: 72 65 63 6f 72 64 73 20 6e 65 77 74 65 73 74 6e  records newtestn
3b40: 61 6d 65 20 6e 65 77 2d 74 65 73 74 2d 72 65 63  ame new-test-rec
3b50: 6f 72 64 29 0a 09 09 09 20 28 73 65 74 21 20 74  ord).... (set! t
3b60: 61 6c 20 28 63 6f 6e 73 20 6e 65 77 74 65 73 74  al (cons newtest
3b70: 6e 61 6d 65 20 74 61 6c 29 29 29 29 29 29 20 3b  name tal)))))) ;
3b80: 3b 20 73 69 6e 63 65 20 74 68 65 73 65 20 61 72  ; since these ar
3b90: 65 20 69 74 65 6d 69 7a 65 64 20 63 72 65 61 74  e itemized creat
3ba0: 65 20 6e 65 77 20 74 65 73 74 20 6e 61 6d 65 73  e new test names
3bb0: 20 74 65 73 74 6e 61 6d 65 2f 69 74 65 6d 70 61   testname/itempa
3bc0: 74 68 0a 09 20 20 20 20 20 20 20 69 74 65 6d 73  th..       items
3bd0: 29 0a 09 20 20 20 20 20 20 28 69 66 20 28 6e 6f  )..      (if (no
3be0: 74 20 28 6e 75 6c 6c 3f 20 74 61 6c 29 29 0a 09  t (null? tal))..
3bf0: 09 20 20 28 6c 6f 6f 70 20 28 63 61 72 20 74 61  .  (loop (car ta
3c00: 6c 29 28 63 64 72 20 74 61 6c 29 29 29 29 0a 0a  l)(cdr tal))))..
3c10: 09 20 20 20 20 20 3b 3b 20 69 66 20 69 74 65 6d  .     ;; if item
3c20: 73 20 69 73 20 61 20 70 72 6f 63 20 74 68 65 6e  s is a proc then
3c30: 20 6e 65 65 64 20 74 6f 20 72 75 6e 20 69 74 65   need to run ite
3c40: 6d 73 3a 67 65 74 2d 69 74 65 6d 73 2d 66 72 6f  ms:get-items-fro
3c50: 6d 2d 63 6f 6e 66 69 67 2c 20 67 65 74 20 74 68  m-config, get th
3c60: 65 20 6c 69 73 74 20 61 6e 64 20 6c 6f 6f 70 20  e list and loop 
3c70: 0a 09 20 20 20 20 20 3b 3b 20 20 20 20 2d 20 62  ..     ;;    - b
3c80: 75 74 20 6f 6e 6c 79 20 64 6f 20 74 68 61 74 20  ut only do that 
3c90: 69 66 20 72 65 73 6f 75 72 63 65 73 20 65 78 69  if resources exi
3ca0: 73 74 20 74 6f 20 6b 69 63 6b 20 6f 66 66 20 74  st to kick off t
3cb0: 68 65 20 6a 6f 62 0a 09 20 20 20 20 20 28 28 6f  he job..     ((o
3cc0: 72 20 28 70 72 6f 63 65 64 75 72 65 3f 20 69 74  r (procedure? it
3cd0: 65 6d 73 29 28 65 71 3f 20 69 74 65 6d 73 20 27  ems)(eq? items '
3ce0: 68 61 76 65 2d 70 72 6f 63 65 64 75 72 65 29 29  have-procedure))
3cf0: 0a 09 20 20 20 20 20 20 28 69 66 20 28 61 6e 64  ..      (if (and
3d00: 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d   (runs:can-run-m
3d10: 6f 72 65 2d 74 65 73 74 73 20 64 62 20 74 65 73  ore-tests db tes
3d20: 74 2d 72 65 63 6f 72 64 29 0a 09 09 20 20 20 20  t-record)...    
3d30: 20 20 20 28 6e 75 6c 6c 3f 20 28 64 62 3a 67 65     (null? (db:ge
3d40: 74 2d 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65  t-prereqs-not-me
3d50: 74 20 64 62 20 72 75 6e 2d 69 64 20 77 61 69 74  t db run-id wait
3d60: 6f 6e 73 20 69 74 65 6d 2d 70 61 74 68 29 29 29  ons item-path)))
3d70: 0a 09 09 20 20 28 6c 65 74 20 28 28 74 65 73 74  ...  (let ((test
3d80: 2d 6e 61 6d 65 20 28 74 65 73 74 73 3a 74 65 73  -name (tests:tes
3d90: 74 71 75 65 75 65 2d 67 65 74 2d 74 65 73 74 6e  tqueue-get-testn
3da0: 61 6d 65 20 74 65 73 74 2d 72 65 63 6f 72 64 29  ame test-record)
3db0: 29 29 0a 09 09 20 20 20 20 28 73 65 74 65 6e 76  ))...    (setenv
3dc0: 20 22 4d 54 5f 54 45 53 54 5f 4e 41 4d 45 22 20   "MT_TEST_NAME" 
3dd0: 74 65 73 74 2d 6e 61 6d 65 29 20 3b 3b 20 0a 09  test-name) ;; ..
3de0: 09 20 20 20 20 28 73 65 74 65 6e 76 20 22 4d 54  .    (setenv "MT
3df0: 5f 52 55 4e 4e 41 4d 45 22 20 20 20 72 75 6e 6e  _RUNNAME"   runn
3e00: 61 6d 65 29 0a 09 09 20 20 20 20 28 73 65 74 2d  ame)...    (set-
3e10: 6d 65 67 61 74 65 73 74 2d 65 6e 76 2d 76 61 72  megatest-env-var
3e20: 73 20 64 62 20 72 75 6e 2d 69 64 29 20 3b 3b 20  s db run-id) ;; 
3e30: 74 68 65 73 65 20 6d 61 79 20 62 65 20 6e 65 65  these may be nee
3e40: 64 65 64 20 62 79 20 74 68 65 20 6c 61 75 6e 63  ded by the launc
3e50: 68 69 6e 67 20 70 72 6f 63 65 73 73 0a 09 09 20  hing process... 
3e60: 20 20 20 28 6c 65 74 20 28 28 69 74 65 6d 73 2d     (let ((items-
3e70: 6c 69 73 74 20 28 69 74 65 6d 73 3a 67 65 74 2d  list (items:get-
3e80: 69 74 65 6d 73 2d 66 72 6f 6d 2d 63 6f 6e 66 69  items-from-confi
3e90: 67 20 74 63 6f 6e 66 69 67 29 29 29 0a 09 09 20  g tconfig)))... 
3ea0: 20 20 20 20 20 28 69 66 20 28 6c 69 73 74 3f 20       (if (list? 
3eb0: 69 74 65 6d 73 2d 6c 69 73 74 29 0a 09 09 09 20  items-list).... 
3ec0: 20 28 62 65 67 69 6e 0a 09 09 09 20 20 20 20 28   (begin....    (
3ed0: 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d  tests:testqueue-
3ee0: 73 65 74 2d 69 74 65 6d 73 21 20 74 65 73 74 2d  set-items! test-
3ef0: 72 65 63 6f 72 64 20 69 74 65 6d 73 2d 6c 69 73  record items-lis
3f00: 74 29 0a 09 09 09 20 20 20 20 28 6c 6f 6f 70 20  t)....    (loop 
3f10: 68 65 64 20 74 61 6c 29 29 0a 09 09 09 20 20 28  hed tal))....  (
3f20: 62 65 67 69 6e 0a 09 09 09 20 20 20 20 28 64 65  begin....    (de
3f30: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52  bug:print 0 "ERR
3f40: 4f 52 3a 20 54 68 65 20 70 72 6f 63 20 66 72 6f  OR: The proc fro
3f50: 6d 20 72 65 61 64 69 6e 67 20 74 68 65 20 73 65  m reading the se
3f60: 74 75 70 20 64 69 64 20 6e 6f 74 20 79 69 65 6c  tup did not yiel
3f70: 64 20 61 20 6c 69 73 74 20 2d 20 70 6c 65 61 73  d a list - pleas
3f80: 65 20 72 65 70 6f 72 74 20 74 68 69 73 22 29 0a  e report this").
3f90: 09 09 09 20 20 20 20 28 65 78 69 74 20 31 29 29  ...    (exit 1))
3fa0: 29 29 29 0a 09 09 20 20 28 6c 65 74 20 28 28 6e  )))...  (let ((n
3fb0: 65 77 74 61 6c 20 28 61 70 70 65 6e 64 20 74 61  ewtal (append ta
3fc0: 6c 20 28 6c 69 73 74 20 68 65 64 29 29 29 29 0a  l (list hed)))).
3fd0: 09 09 20 20 20 20 3b 3b 20 69 66 20 63 61 6e 27  ..    ;; if can'
3fe0: 74 20 72 75 6e 20 6d 6f 72 65 20 74 65 73 74 73  t run more tests
3ff0: 2c 20 6c 65 74 73 20 74 61 6b 65 20 61 20 62 72  , lets take a br
4000: 65 61 74 68 65 72 0a 09 09 20 20 20 20 28 74 68  eather...    (th
4010: 72 65 61 64 2d 73 6c 65 65 70 21 20 30 2e 31 29  read-sleep! 0.1)
4020: 20 3b 3b 20 6d 61 79 20 61 73 20 77 65 6c 6c 20   ;; may as well 
4030: 77 61 69 74 20 61 20 77 68 69 6c 65 20 66 6f 72  wait a while for
4040: 20 72 65 73 6f 75 72 63 65 73 20 74 6f 20 66 72   resources to fr
4050: 65 65 20 75 70 0a 09 09 20 20 20 20 28 6c 6f 6f  ee up...    (loo
4060: 70 20 28 63 61 72 20 6e 65 77 74 61 6c 29 28 63  p (car newtal)(c
4070: 64 72 20 6e 65 77 74 61 6c 29 29 29 29 29 0a 0a  dr newtal)))))..
4080: 09 20 20 20 20 20 3b 3b 20 74 68 69 73 20 63 61  .     ;; this ca
4090: 73 65 20 73 68 6f 75 6c 64 20 6e 6f 74 20 68 61  se should not ha
40a0: 70 70 65 6e 2c 20 61 64 64 65 64 20 74 6f 20 68  ppen, added to h
40b0: 65 6c 70 20 63 61 74 63 68 20 61 6e 79 20 62 75  elp catch any bu
40c0: 67 73 0a 09 20 20 20 20 20 28 28 61 6e 64 20 28  gs..     ((and (
40d0: 6c 69 73 74 3f 20 69 74 65 6d 73 29 20 69 74 65  list? items) ite
40e0: 6d 64 61 74 29 0a 09 20 20 20 20 20 20 28 64 65  mdat)..      (de
40f0: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52  bug:print 0 "ERR
4100: 4f 52 3a 20 53 68 6f 75 6c 64 20 6e 6f 74 20 68  OR: Should not h
4110: 61 76 65 20 61 20 6c 69 73 74 20 6f 66 20 69 74  ave a list of it
4120: 65 6d 73 20 69 6e 20 61 20 74 65 73 74 20 61 6e  ems in a test an
4130: 64 20 74 68 65 20 69 74 65 6d 73 70 61 74 68 20  d the itemspath 
4140: 73 65 74 20 2d 20 70 6c 65 61 73 65 20 72 65 70  set - please rep
4150: 6f 72 74 20 74 68 69 73 22 29 0a 09 20 20 20 20  ort this")..    
4160: 20 20 28 65 78 69 74 20 31 29 29 29 29 0a 09 20    (exit 1)))).. 
4170: 20 0a 09 20 20 3b 3b 20 77 65 20 67 65 74 20 68   ..  ;; we get h
4180: 65 72 65 20 6f 6e 20 22 64 72 6f 70 20 74 68 72  ere on "drop thr
4190: 6f 75 67 68 22 20 2d 20 6c 6f 6f 70 20 66 6f 72  ough" - loop for
41a0: 20 6e 65 78 74 20 74 65 73 74 20 69 6e 20 71 75   next test in qu
41b0: 65 75 65 0a 09 20 20 28 69 66 20 28 6e 75 6c 6c  eue..  (if (null
41c0: 3f 20 74 61 6c 29 0a 09 20 20 20 20 20 20 28 62  ? tal)..      (b
41d0: 65 67 69 6e 0a 09 09 3b 3b 20 46 49 58 4d 45 21  egin...;; FIXME!
41e0: 21 21 21 20 54 48 49 53 20 53 48 4f 55 4c 44 20  !!! THIS SHOULD 
41f0: 4e 4f 54 20 52 45 51 55 49 52 45 20 41 4e 20 45  NOT REQUIRE AN E
4200: 58 49 54 21 21 21 21 21 21 21 0a 09 09 28 64 65  XIT!!!!!!!...(de
4210: 62 75 67 3a 70 72 69 6e 74 20 31 20 22 49 4e 46  bug:print 1 "INF
4220: 4f 3a 20 41 6c 6c 20 74 65 73 74 73 20 6c 61 75  O: All tests lau
4230: 6e 63 68 65 64 22 29 0a 09 09 28 74 68 72 65 61  nched")...(threa
4240: 64 2d 73 6c 65 65 70 21 20 30 2e 35 29 0a 09 09  d-sleep! 0.5)...
4250: 3b 3b 20 46 49 58 4d 45 21 20 54 68 69 73 20 68  ;; FIXME! This h
4260: 61 72 73 68 20 65 78 69 74 20 73 68 6f 75 6c 64  arsh exit should
4270: 20 6e 6f 74 20 62 65 20 6e 65 63 65 73 73 61 72   not be necessar
4280: 79 2e 2e 2e 2e 0a 09 09 28 69 66 20 28 6e 6f 74  y.......(if (not
4290: 20 2a 72 75 6e 72 65 6d 6f 74 65 2a 29 28 65 78   *runremote*)(ex
42a0: 69 74 29 29 20 3b 3b 20 0a 09 09 23 66 29 20 3b  it)) ;; ...#f) ;
42b0: 3b 20 72 65 74 75 72 6e 20 61 20 23 66 20 61 73  ; return a #f as
42c0: 20 61 20 68 69 6e 74 20 74 68 61 74 20 77 65 20   a hint that we 
42d0: 61 72 65 20 64 6f 6e 65 0a 09 20 20 20 20 20 20  are done..      
42e0: 3b 3b 20 48 65 72 65 20 77 65 20 6e 65 65 64 20  ;; Here we need 
42f0: 74 6f 20 63 68 65 63 6b 20 74 68 61 74 20 61 6c  to check that al
4300: 6c 20 74 68 65 20 74 65 73 74 73 20 72 65 6d 61  l the tests rema
4310: 69 6e 69 6e 67 20 74 6f 20 62 65 20 72 75 6e 20  ining to be run 
4320: 61 72 65 20 65 6c 69 67 69 62 6c 65 20 74 6f 20  are eligible to 
4330: 72 75 6e 0a 09 20 20 20 20 20 20 3b 3b 20 61 6e  run..      ;; an
4340: 64 20 61 72 65 20 6e 6f 74 20 62 6c 6f 63 6b 65  d are not blocke
4350: 64 20 62 79 20 66 61 69 6c 65 64 0a 09 20 20 20  d by failed..   
4360: 20 20 20 28 6c 65 74 20 28 28 6e 65 77 6c 73 74     (let ((newlst
4370: 20 28 74 65 73 74 73 3a 66 69 6c 74 65 72 2d 6e   (tests:filter-n
4380: 6f 6e 2d 72 75 6e 6e 61 62 6c 65 20 64 62 20 72  on-runnable db r
4390: 75 6e 2d 69 64 20 74 61 6c 20 74 65 73 74 2d 72  un-id tal test-r
43a0: 65 63 6f 72 64 73 29 29 29 20 3b 3b 20 69 2e 65  ecords))) ;; i.e
43b0: 2e 20 6e 6f 74 20 46 41 49 4c 2c 20 57 41 49 56  . not FAIL, WAIV
43c0: 45 44 2c 20 49 4e 43 4f 4d 50 4c 45 54 45 2c 20  ED, INCOMPLETE, 
43d0: 50 41 53 53 2c 20 4b 49 4c 4c 45 44 2c 0a 09 09  PASS, KILLED,...
43e0: 28 74 68 72 65 61 64 2d 73 6c 65 65 70 21 20 30  (thread-sleep! 0
43f0: 2e 31 29 0a 09 09 28 69 66 20 28 6e 6f 74 20 28  .1)...(if (not (
4400: 6e 75 6c 6c 3f 20 6e 65 77 6c 73 74 29 29 0a 09  null? newlst))..
4410: 09 20 20 20 20 28 6c 6f 6f 70 20 28 63 61 72 20  .    (loop (car 
4420: 6e 65 77 6c 73 74 29 28 63 64 72 20 6e 65 77 6c  newlst)(cdr newl
4430: 73 74 29 29 29 29 29 29 29 29 29 0a 0a 3b 3b 20  st)))))))))..;; 
4440: 70 61 72 65 6e 74 2d 74 65 73 74 20 69 73 20 74  parent-test is t
4450: 68 65 72 65 20 61 73 20 61 20 70 6c 61 63 65 68  here as a placeh
4460: 6f 6c 64 65 72 20 66 6f 72 20 77 68 65 6e 20 70  older for when p
4470: 61 72 65 6e 74 2d 74 65 73 74 73 20 63 61 6e 20  arent-tests can 
4480: 62 65 20 72 75 6e 20 61 73 20 61 20 73 65 74 75  be run as a setu
4490: 70 20 73 74 65 70 0a 28 64 65 66 69 6e 65 20 28  p step.(define (
44a0: 72 75 6e 3a 74 65 73 74 20 64 62 20 72 75 6e 2d  run:test db run-
44b0: 69 64 20 72 75 6e 6e 61 6d 65 20 6b 65 79 76 61  id runname keyva
44c0: 6c 6c 73 74 20 74 65 73 74 2d 72 65 63 6f 72 64  llst test-record
44d0: 20 66 6c 61 67 73 20 70 61 72 65 6e 74 2d 74 65   flags parent-te
44e0: 73 74 29 0a 20 20 3b 3b 20 41 6c 6c 20 74 68 65  st).  ;; All the
44f0: 73 65 20 76 61 72 73 20 6d 69 67 68 74 20 62 65  se vars might be
4500: 20 72 65 66 65 72 65 6e 63 65 64 20 62 79 20 74   referenced by t
4510: 68 65 20 74 65 73 74 63 6f 6e 66 69 67 20 66 69  he testconfig fi
4520: 6c 65 20 72 65 61 64 65 72 0a 20 20 28 6c 65 74  le reader.  (let
4530: 2a 20 28 28 74 65 73 74 2d 6e 61 6d 65 20 20 20  * ((test-name   
4540: 20 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75   (tests:testqueu
4550: 65 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 20  e-get-testname  
4560: 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29 0a 09   test-record))..
4570: 20 28 74 65 73 74 2d 77 61 69 74 6f 6e 73 20 28   (test-waitons (
4580: 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d  tests:testqueue-
4590: 67 65 74 2d 77 61 69 74 6f 6e 73 20 20 20 20 74  get-waitons    t
45a0: 65 73 74 2d 72 65 63 6f 72 64 29 29 0a 09 20 28  est-record)).. (
45b0: 74 65 73 74 2d 63 6f 6e 66 20 20 20 20 28 74 65  test-conf    (te
45c0: 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65  sts:testqueue-ge
45d0: 74 2d 74 65 73 74 63 6f 6e 66 69 67 20 74 65 73  t-testconfig tes
45e0: 74 2d 72 65 63 6f 72 64 29 29 0a 09 20 28 69 74  t-record)).. (it
45f0: 65 6d 64 61 74 20 20 20 20 20 20 28 74 65 73 74  emdat      (test
4600: 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d  s:testqueue-get-
4610: 69 74 65 6d 64 61 74 20 20 20 20 74 65 73 74 2d  itemdat    test-
4620: 72 65 63 6f 72 64 29 29 0a 09 20 28 74 65 73 74  record)).. (test
4630: 2d 70 61 74 68 20 20 20 20 28 63 6f 6e 63 20 2a  -path    (conc *
4640: 74 6f 70 70 61 74 68 2a 20 22 2f 74 65 73 74 73  toppath* "/tests
4650: 2f 22 20 74 65 73 74 2d 6e 61 6d 65 29 29 20 3b  /" test-name)) ;
4660: 3b 20 63 6f 75 6c 64 20 75 73 65 20 74 65 73 74  ; could use test
4670: 73 3a 67 65 74 2d 74 65 73 74 63 6f 6e 66 69 67  s:get-testconfig
4680: 20 68 65 72 65 20 2e 2e 2e 0a 09 20 28 66 6f 72   here ..... (for
4690: 63 65 20 20 20 20 20 20 20 20 28 68 61 73 68 2d  ce        (hash-
46a0: 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c  table-ref/defaul
46b0: 74 20 66 6c 61 67 73 20 22 2d 66 6f 72 63 65 22  t flags "-force"
46c0: 20 23 66 29 29 0a 09 20 28 72 65 72 75 6e 20 20   #f)).. (rerun  
46d0: 20 20 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c        (hash-tabl
46e0: 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 66 6c  e-ref/default fl
46f0: 61 67 73 20 22 2d 72 65 72 75 6e 22 20 23 66 29  ags "-rerun" #f)
4700: 29 0a 09 20 28 6b 65 65 70 67 6f 69 6e 67 20 20  ).. (keepgoing  
4710: 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65    (hash-table-re
4720: 66 2f 64 65 66 61 75 6c 74 20 66 6c 61 67 73 20  f/default flags 
4730: 22 2d 6b 65 65 70 67 6f 69 6e 67 22 20 23 66 29  "-keepgoing" #f)
4740: 29 0a 09 20 28 69 74 65 6d 2d 70 61 74 68 20 20  ).. (item-path  
4750: 20 20 20 22 22 29 29 0a 20 20 20 20 28 64 65 62     "")).    (deb
4760: 75 67 3a 70 72 69 6e 74 20 35 0a 09 09 20 22 74  ug:print 5... "t
4770: 65 73 74 2d 63 6f 6e 66 69 67 3a 20 22 20 28 68  est-config: " (h
4780: 61 73 68 2d 74 61 62 6c 65 2d 3e 61 6c 69 73 74  ash-table->alist
4790: 20 74 65 73 74 2d 63 6f 6e 66 29 0a 09 09 20 22   test-conf)... "
47a0: 5c 6e 20 20 20 69 74 65 6d 64 61 74 3a 20 22 20  \n   itemdat: " 
47b0: 69 74 65 6d 64 61 74 0a 09 09 20 29 0a 20 20 20  itemdat... ).   
47c0: 20 3b 3b 20 73 65 74 74 69 6e 67 20 69 74 65 6d   ;; setting item
47d0: 64 61 74 20 74 6f 20 61 20 6c 69 73 74 20 69 66  dat to a list if
47e0: 20 69 74 20 69 73 20 23 66 0a 20 20 20 20 28 69   it is #f.    (i
47f0: 66 20 28 6e 6f 74 20 69 74 65 6d 64 61 74 29 28  f (not itemdat)(
4800: 73 65 74 21 20 69 74 65 6d 64 61 74 20 27 28 29  set! itemdat '()
4810: 29 29 0a 20 20 20 20 28 73 65 74 21 20 69 74 65  )).    (set! ite
4820: 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c 69 73  m-path (item-lis
4830: 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74 29  t->path itemdat)
4840: 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72 69  ).    (debug:pri
4850: 6e 74 20 32 20 22 41 74 74 65 6d 70 74 69 6e 67  nt 2 "Attempting
4860: 20 74 6f 20 6c 61 75 6e 63 68 20 74 65 73 74 20   to launch test 
4870: 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 2f 22 20  " test-name "/" 
4880: 69 74 65 6d 2d 70 61 74 68 29 0a 20 20 20 20 28  item-path).    (
4890: 73 65 74 65 6e 76 20 22 4d 54 5f 54 45 53 54 5f  setenv "MT_TEST_
48a0: 4e 41 4d 45 22 20 74 65 73 74 2d 6e 61 6d 65 29  NAME" test-name)
48b0: 20 3b 3b 20 0a 20 20 20 20 28 73 65 74 65 6e 76   ;; .    (setenv
48c0: 20 22 4d 54 5f 52 55 4e 4e 41 4d 45 22 20 20 20   "MT_RUNNAME"   
48d0: 72 75 6e 6e 61 6d 65 29 0a 20 20 20 20 28 73 65  runname).    (se
48e0: 74 2d 6d 65 67 61 74 65 73 74 2d 65 6e 76 2d 76  t-megatest-env-v
48f0: 61 72 73 20 64 62 20 72 75 6e 2d 69 64 29 20 3b  ars db run-id) ;
4900: 3b 20 74 68 65 73 65 20 6d 61 79 20 62 65 20 6e  ; these may be n
4910: 65 65 64 65 64 20 62 79 20 74 68 65 20 6c 61 75  eeded by the lau
4920: 6e 63 68 69 6e 67 20 70 72 6f 63 65 73 73 0a 20  nching process. 
4930: 20 20 20 28 63 68 61 6e 67 65 2d 64 69 72 65 63     (change-direc
4940: 74 6f 72 79 20 2a 74 6f 70 70 61 74 68 2a 29 0a  tory *toppath*).
4950: 0a 20 20 20 20 3b 3b 20 48 65 72 65 20 69 73 20  .    ;; Here is 
4960: 77 68 65 72 65 20 74 68 65 20 74 65 73 74 5f 6d  where the test_m
4970: 65 74 61 20 74 61 62 6c 65 20 69 73 20 62 65 73  eta table is bes
4980: 74 20 75 70 64 61 74 65 64 0a 20 20 20 20 3b 3b  t updated.    ;;
4990: 20 59 65 73 2c 20 61 6e 6f 74 68 65 72 20 75 73   Yes, another us
49a0: 65 20 6f 66 20 61 20 67 6c 6f 62 61 6c 20 66 6f  e of a global fo
49b0: 72 20 63 61 63 68 69 6e 67 2e 20 4e 65 65 64 20  r caching. Need 
49c0: 61 20 62 65 74 74 65 72 20 77 61 79 3f 0a 20 20  a better way?.  
49d0: 20 20 28 69 66 20 28 6e 6f 74 20 28 68 61 73 68    (if (not (hash
49e0: 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75  -table-ref/defau
49f0: 6c 74 20 2a 74 65 73 74 2d 6d 65 74 61 2d 75 70  lt *test-meta-up
4a00: 64 61 74 65 64 2a 20 74 65 73 74 2d 6e 61 6d 65  dated* test-name
4a10: 20 23 66 29 29 0a 20 20 20 20 20 20 20 20 28 62   #f)).        (b
4a20: 65 67 69 6e 0a 09 20 20 20 28 68 61 73 68 2d 74  egin..   (hash-t
4a30: 61 62 6c 65 2d 73 65 74 21 20 2a 74 65 73 74 2d  able-set! *test-
4a40: 6d 65 74 61 2d 75 70 64 61 74 65 64 2a 20 74 65  meta-updated* te
4a50: 73 74 2d 6e 61 6d 65 20 23 74 29 0a 20 20 20 20  st-name #t).    
4a60: 20 20 20 20 20 20 20 28 72 75 6e 73 3a 75 70 64         (runs:upd
4a70: 61 74 65 2d 74 65 73 74 5f 6d 65 74 61 20 64 62  ate-test_meta db
4a80: 20 74 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 2d   test-name test-
4a90: 63 6f 6e 66 29 29 29 0a 20 20 20 20 0a 20 20 20  conf))).    .   
4aa0: 20 3b 3b 20 28 6c 61 6d 62 64 61 20 28 69 74 65   ;; (lambda (ite
4ab0: 6d 64 61 74 29 20 3b 3b 3b 20 28 28 72 69 70 65  mdat) ;;; ((ripe
4ac0: 6e 65 73 73 20 22 6f 76 65 72 72 69 70 65 22 29  ness "overripe")
4ad0: 20 28 74 65 6d 70 65 72 61 74 75 72 65 20 22 63   (temperature "c
4ae0: 6f 6f 6c 22 29 20 28 73 65 61 73 6f 6e 20 22 73  ool") (season "s
4af0: 75 6d 6d 65 72 22 29 29 0a 20 20 20 20 28 6c 65  ummer")).    (le
4b00: 74 2a 20 28 28 6e 65 77 2d 74 65 73 74 2d 70 61  t* ((new-test-pa
4b10: 74 68 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72  th (string-inter
4b20: 73 70 65 72 73 65 20 28 63 6f 6e 73 20 74 65 73  sperse (cons tes
4b30: 74 2d 70 61 74 68 20 28 6d 61 70 20 63 61 64 72  t-path (map cadr
4b40: 20 69 74 65 6d 64 61 74 29 29 20 22 2f 22 29 29   itemdat)) "/"))
4b50: 0a 09 20 20 20 28 6e 65 77 2d 74 65 73 74 2d 6e  ..   (new-test-n
4b60: 61 6d 65 20 28 69 66 20 28 65 71 75 61 6c 3f 20  ame (if (equal? 
4b70: 69 74 65 6d 2d 70 61 74 68 20 22 22 29 20 74 65  item-path "") te
4b80: 73 74 2d 6e 61 6d 65 20 28 63 6f 6e 63 20 74 65  st-name (conc te
4b90: 73 74 2d 6e 61 6d 65 20 22 2f 22 20 69 74 65 6d  st-name "/" item
4ba0: 2d 70 61 74 68 29 29 29 20 3b 3b 20 6a 75 73 74  -path))) ;; just
4bb0: 20 6e 65 65 64 20 69 74 20 74 6f 20 62 65 20 75   need it to be u
4bc0: 6e 69 71 75 65 0a 09 20 20 20 28 74 65 73 74 64  nique..   (testd
4bd0: 61 74 20 20 20 20 20 20 20 28 64 62 3a 67 65 74  at       (db:get
4be0: 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 20 72 75  -test-info db ru
4bf0: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69  n-id test-name i
4c00: 74 65 6d 2d 70 61 74 68 29 29 0a 09 20 20 20 28  tem-path))..   (
4c10: 74 65 73 74 2d 69 64 20 20 20 20 20 20 20 23 66  test-id       #f
4c20: 29 29 0a 20 20 20 20 20 20 28 69 66 20 28 6e 6f  )).      (if (no
4c30: 74 20 74 65 73 74 64 61 74 29 0a 09 20 20 28 62  t testdat)..  (b
4c40: 65 67 69 6e 0a 09 20 20 20 20 3b 3b 20 65 6e 73  egin..    ;; ens
4c50: 75 72 65 20 74 68 61 74 20 74 68 65 20 70 61 74  ure that the pat
4c60: 68 20 65 78 69 73 74 73 20 62 65 66 6f 72 65 20  h exists before 
4c70: 72 65 67 69 73 74 65 72 69 6e 67 20 74 68 65 20  registering the 
4c80: 74 65 73 74 0a 09 20 20 20 20 3b 3b 20 4e 4f 50  test..    ;; NOP
4c90: 45 3a 20 43 61 6e 6e 6f 74 21 20 44 6f 6e 27 74  E: Cannot! Don't
4ca0: 20 6b 6e 6f 77 20 79 65 74 20 77 68 69 63 68 20   know yet which 
4cb0: 64 69 73 6b 20 61 72 65 61 20 77 69 6c 6c 20 62  disk area will b
4cc0: 65 20 61 73 73 69 67 6e 65 64 2e 2e 2e 2e 0a 09  e assigned......
4cd0: 20 20 20 20 3b 3b 20 28 73 79 73 74 65 6d 20 28      ;; (system (
4ce0: 63 6f 6e 63 20 22 6d 6b 64 69 72 20 2d 70 20 22  conc "mkdir -p "
4cf0: 20 6e 65 77 2d 74 65 73 74 2d 70 61 74 68 29 29   new-test-path))
4d00: 0a 09 20 20 20 20 28 72 74 65 73 74 73 3a 72 65  ..    (rtests:re
4d10: 67 69 73 74 65 72 2d 74 65 73 74 20 64 62 20 72  gister-test db r
4d20: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
4d30: 69 74 65 6d 2d 70 61 74 68 29 0a 09 20 20 20 20  item-path)..    
4d40: 28 73 65 74 21 20 74 65 73 74 64 61 74 20 28 64  (set! testdat (d
4d50: 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20  b:get-test-info 
4d60: 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e  db run-id test-n
4d70: 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29 29  ame item-path)))
4d80: 29 0a 20 20 20 20 20 20 28 73 65 74 21 20 74 65  ).      (set! te
4d90: 73 74 2d 69 64 20 28 64 62 3a 74 65 73 74 2d 67  st-id (db:test-g
4da0: 65 74 2d 69 64 20 74 65 73 74 64 61 74 29 29 0a  et-id testdat)).
4db0: 20 20 20 20 20 20 28 63 68 61 6e 67 65 2d 64 69        (change-di
4dc0: 72 65 63 74 6f 72 79 20 74 65 73 74 2d 70 61 74  rectory test-pat
4dd0: 68 29 0a 20 20 20 20 20 20 28 63 61 73 65 20 28  h).      (case (
4de0: 69 66 20 66 6f 72 63 65 20 3b 3b 20 28 61 72 67  if force ;; (arg
4df0: 73 3a 67 65 74 2d 61 72 67 20 22 2d 66 6f 72 63  s:get-arg "-forc
4e00: 65 22 29 0a 09 09 27 4e 4f 54 5f 53 54 41 52 54  e")...'NOT_START
4e10: 45 44 0a 09 09 28 69 66 20 74 65 73 74 64 61 74  ED...(if testdat
4e20: 0a 09 09 20 20 20 20 28 73 74 72 69 6e 67 2d 3e  ...    (string->
4e30: 73 79 6d 62 6f 6c 20 28 74 65 73 74 3a 67 65 74  symbol (test:get
4e40: 2d 73 74 61 74 65 20 74 65 73 74 64 61 74 29 29  -state testdat))
4e50: 0a 09 09 20 20 20 20 27 66 61 69 6c 65 64 2d 74  ...    'failed-t
4e60: 6f 2d 69 6e 73 65 72 74 29 29 0a 09 28 28 66 61  o-insert))..((fa
4e70: 69 6c 65 64 2d 74 6f 2d 69 6e 73 65 72 74 29 0a  iled-to-insert).
4e80: 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30  . (debug:print 0
4e90: 20 22 45 52 52 4f 52 3a 20 46 61 69 6c 65 64 20   "ERROR: Failed 
4ea0: 74 6f 20 69 6e 73 65 72 74 20 74 68 65 20 72 65  to insert the re
4eb0: 63 6f 72 64 20 69 6e 74 6f 20 74 68 65 20 64 62  cord into the db
4ec0: 22 29 29 0a 09 28 28 4e 4f 54 5f 53 54 41 52 54  "))..((NOT_START
4ed0: 45 44 20 43 4f 4d 50 4c 45 54 45 44 29 0a 09 20  ED COMPLETED).. 
4ee0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 36 20 22  (debug:print 6 "
4ef0: 47 6f 74 20 68 65 72 65 2c 20 22 20 28 74 65 73  Got here, " (tes
4f00: 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74  t:get-state test
4f10: 64 61 74 29 29 0a 09 20 28 6c 65 74 20 28 28 72  dat)).. (let ((r
4f20: 75 6e 66 6c 61 67 20 23 66 29 29 0a 09 20 20 20  unflag #f))..   
4f30: 28 63 6f 6e 64 0a 09 20 20 20 20 3b 3b 20 2d 66  (cond..    ;; -f
4f40: 6f 72 63 65 2c 20 72 75 6e 20 6e 6f 20 6d 61 74  orce, run no mat
4f50: 74 65 72 20 77 68 61 74 0a 09 20 20 20 20 28 66  ter what..    (f
4f60: 6f 72 63 65 20 28 73 65 74 21 20 72 75 6e 66 6c  orce (set! runfl
4f70: 61 67 20 23 74 29 29 0a 09 20 20 20 20 3b 3b 20  ag #t))..    ;; 
4f80: 4e 4f 54 5f 53 54 41 52 54 45 44 2c 20 72 75 6e  NOT_STARTED, run
4f90: 20 6e 6f 20 6d 61 74 74 65 72 20 77 68 61 74 0a   no matter what.
4fa0: 09 20 20 20 20 28 28 65 71 75 61 6c 3f 20 28 74  .    ((equal? (t
4fb0: 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65  est:get-state te
4fc0: 73 74 64 61 74 29 20 22 4e 4f 54 5f 53 54 41 52  stdat) "NOT_STAR
4fd0: 54 45 44 22 29 28 73 65 74 21 20 72 75 6e 66 6c  TED")(set! runfl
4fe0: 61 67 20 23 74 29 29 0a 09 20 20 20 20 3b 3b 20  ag #t))..    ;; 
4ff0: 6e 6f 74 20 2d 72 65 72 75 6e 20 61 6e 64 20 50  not -rerun and P
5000: 41 53 53 2c 20 57 41 52 4e 20 6f 72 20 43 48 45  ASS, WARN or CHE
5010: 43 4b 2c 20 64 6f 20 6e 6f 20 72 75 6e 0a 09 20  CK, do no run.. 
5020: 20 20 20 28 28 61 6e 64 20 28 6f 72 20 28 6e 6f     ((and (or (no
5030: 74 20 72 65 72 75 6e 29 0a 09 09 20 20 20 20 20  t rerun)...     
5040: 20 6b 65 65 70 67 6f 69 6e 67 29 0a 09 09 20 20   keepgoing)...  
5050: 3b 3b 20 52 65 71 75 69 72 65 20 74 6f 20 66 6f  ;; Require to fo
5060: 72 63 65 20 72 65 2d 72 75 6e 20 66 6f 72 20 43  rce re-run for C
5070: 4f 4d 50 4c 45 54 45 44 20 6f 72 20 2a 61 6e 79  OMPLETED or *any
5080: 74 68 69 6e 67 2a 20 2b 20 50 41 53 53 2c 57 41  thing* + PASS,WA
5090: 52 4e 20 6f 72 20 43 48 45 43 4b 0a 09 09 20 20  RN or CHECK...  
50a0: 28 6f 72 20 28 6d 65 6d 62 65 72 20 28 74 65 73  (or (member (tes
50b0: 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73  t:get-status tes
50c0: 74 64 61 74 29 20 27 28 22 50 41 53 53 22 20 22  tdat) '("PASS" "
50d0: 57 41 52 4e 22 20 22 43 48 45 43 4b 22 29 29 0a  WARN" "CHECK")).
50e0: 09 09 20 20 20 20 20 20 28 6d 65 6d 62 65 72 20  ..      (member 
50f0: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20  (test:get-state 
5100: 20 74 65 73 74 64 61 74 29 20 27 28 22 43 4f 4d   testdat) '("COM
5110: 50 4c 45 54 45 44 22 29 29 29 29 20 0a 09 20 20  PLETED")))) ..  
5120: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
5130: 32 20 22 49 4e 46 4f 3a 20 72 75 6e 6e 69 6e 67  2 "INFO: running
5140: 20 74 65 73 74 20 22 20 74 65 73 74 2d 6e 61 6d   test " test-nam
5150: 65 20 22 2f 22 20 69 74 65 6d 2d 70 61 74 68 20  e "/" item-path 
5160: 22 20 73 75 70 70 72 65 73 73 65 64 20 61 73 20  " suppressed as 
5170: 69 74 20 69 73 20 43 4f 4d 50 4c 45 54 45 44 20  it is COMPLETED 
5180: 61 6e 64 20 22 20 28 74 65 73 74 3a 67 65 74 2d  and " (test:get-
5190: 73 74 61 74 65 20 74 65 73 74 64 61 74 29 29 0a  state testdat)).
51a0: 09 20 20 20 20 20 28 73 65 74 21 20 72 75 6e 66  .     (set! runf
51b0: 6c 61 67 20 23 66 29 29 0a 09 20 20 20 20 3b 3b  lag #f))..    ;;
51c0: 20 2d 72 65 72 75 6e 20 61 6e 64 20 73 74 61 74   -rerun and stat
51d0: 75 73 20 69 73 20 6f 6e 65 20 6f 66 20 74 68 65  us is one of the
51e0: 20 73 70 65 63 69 66 65 64 2c 20 72 75 6e 20 69   specifed, run i
51f0: 74 0a 09 20 20 20 20 28 28 61 6e 64 20 72 65 72  t..    ((and rer
5200: 75 6e 0a 09 09 20 20 28 6c 65 74 2a 20 28 28 72  un...  (let* ((r
5210: 65 72 75 6e 6c 73 74 20 20 20 28 73 74 72 69 6e  erunlst   (strin
5220: 67 2d 73 70 6c 69 74 20 72 65 72 75 6e 20 22 2c  g-split rerun ",
5230: 22 29 29 0a 09 09 09 20 28 6d 75 73 74 2d 72 65  ")).... (must-re
5240: 72 75 6e 20 28 6d 65 6d 62 65 72 20 28 74 65 73  run (member (tes
5250: 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73  t:get-status tes
5260: 74 64 61 74 29 20 72 65 72 75 6e 6c 73 74 29 29  tdat) rerunlst))
5270: 29 0a 09 09 20 20 20 20 28 64 65 62 75 67 3a 70  )...    (debug:p
5280: 72 69 6e 74 20 33 20 22 49 4e 46 4f 3a 20 2d 72  rint 3 "INFO: -r
5290: 65 72 75 6e 20 6c 69 73 74 3a 20 22 20 72 65 72  erun list: " rer
52a0: 75 6e 20 22 2c 20 74 65 73 74 2d 73 74 61 74 75  un ", test-statu
52b0: 73 3a 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73  s: " (test:get-s
52c0: 74 61 74 75 73 20 74 65 73 74 64 61 74 29 22 2c  tatus testdat)",
52d0: 20 6d 75 73 74 2d 72 65 72 75 6e 3a 20 22 20 6d   must-rerun: " m
52e0: 75 73 74 2d 72 65 72 75 6e 29 0a 09 09 20 20 20  ust-rerun)...   
52f0: 20 6d 75 73 74 2d 72 65 72 75 6e 29 29 0a 09 20   must-rerun)).. 
5300: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
5310: 20 32 20 22 49 4e 46 4f 3a 20 52 65 72 75 6e 20   2 "INFO: Rerun 
5320: 66 6f 72 63 65 64 20 66 6f 72 20 74 65 73 74 20  forced for test 
5330: 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 2f 22 20  " test-name "/" 
5340: 69 74 65 6d 2d 70 61 74 68 29 0a 09 20 20 20 20  item-path)..    
5350: 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23   (set! runflag #
5360: 74 29 29 0a 09 20 20 20 20 3b 3b 20 2d 6b 65 65  t))..    ;; -kee
5370: 70 67 6f 69 6e 67 2c 20 64 6f 20 6e 6f 74 20 72  pgoing, do not r
5380: 65 72 75 6e 20 46 41 49 4c 0a 09 20 20 20 20 28  erun FAIL..    (
5390: 28 61 6e 64 20 6b 65 65 70 67 6f 69 6e 67 0a 09  (and keepgoing..
53a0: 09 20 20 28 6d 65 6d 62 65 72 20 28 74 65 73 74  .  (member (test
53b0: 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74  :get-status test
53c0: 64 61 74 29 20 27 28 22 46 41 49 4c 22 29 29 29  dat) '("FAIL")))
53d0: 0a 09 20 20 20 20 20 28 73 65 74 21 20 72 75 6e  ..     (set! run
53e0: 66 6c 61 67 20 23 66 29 29 0a 09 20 20 20 20 28  flag #f))..    (
53f0: 28 61 6e 64 20 28 6e 6f 74 20 72 65 72 75 6e 29  (and (not rerun)
5400: 0a 09 09 20 20 28 6d 65 6d 62 65 72 20 28 74 65  ...  (member (te
5410: 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65  st:get-status te
5420: 73 74 64 61 74 29 20 27 28 22 46 41 49 4c 22 20  stdat) '("FAIL" 
5430: 22 6e 2f 61 22 29 29 29 0a 09 20 20 20 20 20 28  "n/a")))..     (
5440: 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 74 29  set! runflag #t)
5450: 29 0a 09 20 20 20 20 28 65 6c 73 65 20 28 73 65  )..    (else (se
5460: 74 21 20 72 75 6e 66 6c 61 67 20 23 66 29 29 29  t! runflag #f)))
5470: 0a 09 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e  ..   (debug:prin
5480: 74 20 36 20 22 52 55 4e 4e 49 4e 47 20 3d 3e 20  t 6 "RUNNING => 
5490: 72 75 6e 66 6c 61 67 3a 20 22 20 72 75 6e 66 6c  runflag: " runfl
54a0: 61 67 20 22 20 53 54 41 54 45 3a 20 22 20 28 74  ag " STATE: " (t
54b0: 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65  est:get-state te
54c0: 73 74 64 61 74 29 20 22 20 53 54 41 54 55 53 3a  stdat) " STATUS:
54d0: 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61   " (test:get-sta
54e0: 74 75 73 20 74 65 73 74 64 61 74 29 29 0a 09 20  tus testdat)).. 
54f0: 20 20 28 69 66 20 28 6e 6f 74 20 72 75 6e 66 6c    (if (not runfl
5500: 61 67 29 0a 09 20 20 20 20 20 20 20 28 69 66 20  ag)..       (if 
5510: 28 6e 6f 74 20 70 61 72 65 6e 74 2d 74 65 73 74  (not parent-test
5520: 29 0a 09 09 20 20 20 28 64 65 62 75 67 3a 70 72  )...   (debug:pr
5530: 69 6e 74 20 31 20 22 4e 4f 54 45 3a 20 4e 6f 74  int 1 "NOTE: Not
5540: 20 73 74 61 72 74 69 6e 67 20 74 65 73 74 20 22   starting test "
5550: 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20 22   new-test-name "
5560: 20 61 73 20 69 74 20 69 73 20 73 74 61 74 65 20   as it is state 
5570: 5c 22 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74  \"" (test:get-st
5580: 61 74 65 20 74 65 73 74 64 61 74 29 20 0a 09 09  ate testdat) ...
5590: 09 09 22 5c 22 20 61 6e 64 20 73 74 61 74 75 73  .."\" and status
55a0: 20 5c 22 22 20 28 74 65 73 74 3a 67 65 74 2d 73   \"" (test:get-s
55b0: 74 61 74 75 73 20 74 65 73 74 64 61 74 29 20 22  tatus testdat) "
55c0: 5c 22 2c 20 75 73 65 20 2d 72 65 72 75 6e 20 5c  \", use -rerun \
55d0: 22 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61  "" (test:get-sta
55e0: 74 75 73 20 74 65 73 74 64 61 74 29 0a 20 20 20  tus testdat).   
55f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
5600: 20 20 20 20 20 20 20 20 20 20 20 20 20 22 5c 22               "\"
5610: 20 6f 72 20 2d 66 6f 72 63 65 20 74 6f 20 6f 76   or -force to ov
5620: 65 72 72 69 64 65 22 29 29 0a 09 20 20 20 20 20  erride"))..     
5630: 20 20 3b 3b 20 4e 4f 54 45 3a 20 4e 6f 20 6c 6f    ;; NOTE: No lo
5640: 6e 67 65 72 20 62 65 20 63 68 65 63 6b 69 6e 67  nger be checking
5650: 20 70 72 65 72 65 71 75 69 73 69 74 65 73 20 68   prerequisites h
5660: 65 72 65 21 20 57 69 6c 6c 20 6e 65 76 65 72 20  ere! Will never 
5670: 67 65 74 20 68 65 72 65 20 75 6e 6c 65 73 73 20  get here unless 
5680: 70 72 65 72 65 71 73 20 61 72 65 0a 09 20 20 20  prereqs are..   
5690: 20 20 20 20 3b 3b 20 20 20 20 20 20 20 61 6c 72      ;;       alr
56a0: 65 61 64 79 20 6d 65 74 2e 0a 09 20 20 20 20 20  eady met...     
56b0: 20 20 28 69 66 20 28 6e 6f 74 20 28 6c 61 75 6e    (if (not (laun
56c0: 63 68 2d 74 65 73 74 20 64 62 20 72 75 6e 2d 69  ch-test db run-i
56d0: 64 20 72 75 6e 6e 61 6d 65 20 74 65 73 74 2d 63  d runname test-c
56e0: 6f 6e 66 20 6b 65 79 76 61 6c 6c 73 74 20 74 65  onf keyvallst te
56f0: 73 74 2d 6e 61 6d 65 20 74 65 73 74 2d 70 61 74  st-name test-pat
5700: 68 20 69 74 65 6d 64 61 74 20 66 6c 61 67 73 29  h itemdat flags)
5710: 29 0a 09 09 20 20 20 28 62 65 67 69 6e 0a 09 09  )...   (begin...
5720: 20 20 20 20 20 28 70 72 69 6e 74 20 22 45 52 52       (print "ERR
5730: 4f 52 3a 20 46 61 69 6c 65 64 20 74 6f 20 6c 61  OR: Failed to la
5740: 75 6e 63 68 20 74 68 65 20 74 65 73 74 2e 20 45  unch the test. E
5750: 78 69 74 69 6e 67 20 61 73 20 73 6f 6f 6e 20 61  xiting as soon a
5760: 73 20 70 6f 73 73 69 62 6c 65 22 29 0a 09 09 20  s possible")... 
5770: 20 20 20 20 28 73 65 74 21 20 2a 67 6c 6f 62 61      (set! *globa
5780: 6c 65 78 69 74 73 74 61 74 75 73 2a 20 31 29 20  lexitstatus* 1) 
5790: 3b 3b 20 0a 09 09 20 20 20 20 20 28 70 72 6f 63  ;; ...     (proc
57a0: 65 73 73 2d 73 69 67 6e 61 6c 20 28 63 75 72 72  ess-signal (curr
57b0: 65 6e 74 2d 70 72 6f 63 65 73 73 2d 69 64 29 20  ent-process-id) 
57c0: 73 69 67 6e 61 6c 2f 6b 69 6c 6c 29 29 29 29 29  signal/kill)))))
57d0: 29 0a 09 28 28 4b 49 4c 4c 45 44 29 20 0a 09 20  )..((KILLED) .. 
57e0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22  (debug:print 1 "
57f0: 4e 4f 54 45 3a 20 22 20 6e 65 77 2d 74 65 73 74  NOTE: " new-test
5800: 2d 6e 61 6d 65 20 22 20 69 73 20 61 6c 72 65 61  -name " is alrea
5810: 64 79 20 72 75 6e 6e 69 6e 67 20 6f 72 20 77 61  dy running or wa
5820: 73 20 65 78 70 6c 69 63 74 6c 79 20 6b 69 6c 6c  s explictly kill
5830: 65 64 2c 20 75 73 65 20 2d 66 6f 72 63 65 20 74  ed, use -force t
5840: 6f 20 6c 61 75 6e 63 68 20 69 74 2e 22 29 29 0a  o launch it.")).
5850: 09 28 28 4c 41 55 4e 43 48 45 44 20 52 45 4d 4f  .((LAUNCHED REMO
5860: 54 45 48 4f 53 54 53 54 41 52 54 20 52 55 4e 4e  TEHOSTSTART RUNN
5870: 49 4e 47 29 20 20 0a 09 20 28 69 66 20 28 3e 20  ING)  .. (if (> 
5880: 28 2d 20 28 63 75 72 72 65 6e 74 2d 73 65 63 6f  (- (current-seco
5890: 6e 64 73 29 28 2b 20 28 64 62 3a 74 65 73 74 2d  nds)(+ (db:test-
58a0: 67 65 74 2d 65 76 65 6e 74 5f 74 69 6d 65 20 74  get-event_time t
58b0: 65 73 74 64 61 74 29 0a 09 09 09 09 20 20 20 20  estdat).....    
58c0: 20 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d     (db:test-get-
58d0: 72 75 6e 5f 64 75 72 61 74 69 6f 6e 20 74 65 73  run_duration tes
58e0: 74 64 61 74 29 29 29 0a 09 09 36 30 30 29 20 3b  tdat)))...600) ;
58f0: 3b 20 69 2e 65 2e 20 6e 6f 20 75 70 64 61 74 65  ; i.e. no update
5900: 20 66 6f 72 20 6d 6f 72 65 20 74 68 61 6e 20 36   for more than 6
5910: 30 30 20 73 65 63 6f 6e 64 73 0a 09 20 20 20 20  00 seconds..    
5920: 20 28 62 65 67 69 6e 0a 09 20 20 20 20 20 20 20   (begin..       
5930: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
5940: 57 41 52 4e 49 4e 47 3a 20 54 65 73 74 20 22 20  WARNING: Test " 
5950: 74 65 73 74 2d 6e 61 6d 65 20 22 20 61 70 70 65  test-name " appe
5960: 61 72 73 20 74 6f 20 62 65 20 64 65 61 64 2e 20  ars to be dead. 
5970: 46 6f 72 63 69 6e 67 20 69 74 20 74 6f 20 73 74  Forcing it to st
5980: 61 74 65 20 49 4e 43 4f 4d 50 4c 45 54 45 20 61  ate INCOMPLETE a
5990: 6e 64 20 73 74 61 74 75 73 20 53 54 55 43 4b 2f  nd status STUCK/
59a0: 44 45 41 44 22 29 0a 09 20 20 20 20 20 20 20 28  DEAD")..       (
59b0: 74 65 73 74 2d 73 65 74 2d 73 74 61 74 75 73 21  test-set-status!
59c0: 20 64 62 20 74 65 73 74 2d 69 64 20 22 49 4e 43   db test-id "INC
59d0: 4f 4d 50 4c 45 54 45 22 20 22 53 54 55 43 4b 2f  OMPLETE" "STUCK/
59e0: 44 45 41 44 22 20 22 54 65 73 74 20 69 73 20 73  DEAD" "Test is s
59f0: 74 75 63 6b 20 6f 72 20 64 65 61 64 22 20 23 66  tuck or dead" #f
5a00: 29 29 0a 09 20 20 20 20 20 28 64 65 62 75 67 3a  ))..     (debug:
5a10: 70 72 69 6e 74 20 32 20 22 4e 4f 54 45 3a 20 22  print 2 "NOTE: "
5a20: 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 69 73 20   test-name " is 
5a30: 61 6c 72 65 61 64 79 20 72 75 6e 6e 69 6e 67 22  already running"
5a40: 29 29 29 0a 09 28 65 6c 73 65 20 20 20 20 20 20  )))..(else      
5a50: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
5a60: 22 45 52 52 4f 52 3a 20 46 61 69 6c 65 64 20 74  "ERROR: Failed t
5a70: 6f 20 6c 61 75 6e 63 68 20 74 65 73 74 20 22 20  o launch test " 
5a80: 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20 22 2e  new-test-name ".
5a90: 20 55 6e 72 65 63 6f 67 6e 69 73 65 64 20 73 74   Unrecognised st
5aa0: 61 74 65 20 22 20 28 74 65 73 74 3a 67 65 74 2d  ate " (test:get-
5ab0: 73 74 61 74 65 20 74 65 73 74 64 61 74 29 29 29  state testdat)))
5ac0: 29 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d  ))))..;;========
5ad0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5ae0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5af0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5b00: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b  ==============.;
5b10: 3b 20 45 4e 44 20 4f 46 20 4e 45 57 20 53 54 55  ; END OF NEW STU
5b20: 46 46 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  FF.;;===========
5b30: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5b40: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5b50: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5b60: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 28 64 65  ===========..(de
5b70: 66 69 6e 65 20 28 67 65 74 2d 64 69 72 2d 75 70  fine (get-dir-up
5b80: 2d 6e 20 64 69 72 20 2e 20 70 61 72 61 6d 73 29  -n dir . params)
5b90: 20 0a 20 20 28 6c 65 74 20 28 28 64 70 61 72 74   .  (let ((dpart
5ba0: 73 20 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74  s  (string-split
5bb0: 20 64 69 72 20 22 2f 22 29 29 0a 09 28 63 6f 75   dir "/"))..(cou
5bc0: 6e 74 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20  nt   (if (null? 
5bd0: 70 61 72 61 6d 73 29 20 31 20 28 63 61 72 20 70  params) 1 (car p
5be0: 61 72 61 6d 73 29 29 29 29 0a 20 20 20 20 28 63  arams)))).    (c
5bf0: 6f 6e 63 20 22 2f 22 20 28 73 74 72 69 6e 67 2d  onc "/" (string-
5c00: 69 6e 74 65 72 73 70 65 72 73 65 20 0a 09 20 20  intersperse ..  
5c10: 20 20 20 20 20 28 74 61 6b 65 20 64 70 61 72 74       (take dpart
5c20: 73 20 28 2d 20 28 6c 65 6e 67 74 68 20 64 70 61  s (- (length dpa
5c30: 72 74 73 29 20 63 6f 75 6e 74 29 29 0a 09 20 20  rts) count))..  
5c40: 20 20 20 20 20 22 2f 22 29 29 29 29 0a 3b 3b 20       "/")))).;; 
5c50: 52 65 6d 6f 76 65 20 72 75 6e 73 0a 3b 3b 20 66  Remove runs.;; f
5c60: 69 65 6c 64 73 20 61 72 65 20 70 61 73 73 69 6e  ields are passin
5c70: 67 20 69 6e 20 74 68 72 6f 75 67 68 20 0a 3b 3b  g in through .;;
5c80: 20 61 63 74 69 6f 6e 3a 0a 3b 3b 20 20 20 20 27   action:.;;    '
5c90: 72 65 6d 6f 76 65 2d 72 75 6e 73 0a 3b 3b 20 20  remove-runs.;;  
5ca0: 20 20 27 73 65 74 2d 73 74 61 74 65 2d 73 74 61    'set-state-sta
5cb0: 74 75 73 0a 28 64 65 66 69 6e 65 20 28 72 75 6e  tus.(define (run
5cc0: 73 3a 6f 70 65 72 61 74 65 2d 6f 6e 20 64 62 20  s:operate-on db 
5cd0: 61 63 74 69 6f 6e 20 72 75 6e 6e 61 6d 65 70 61  action runnamepa
5ce0: 74 74 20 74 65 73 74 70 61 74 74 20 69 74 65 6d  tt testpatt item
5cf0: 70 61 74 74 20 23 21 6b 65 79 20 28 73 74 61 74  patt #!key (stat
5d00: 65 20 23 66 29 28 73 74 61 74 75 73 20 23 66 29  e #f)(status #f)
5d10: 28 6e 65 77 2d 73 74 61 74 65 2d 73 74 61 74 75  (new-state-statu
5d20: 73 20 23 66 29 29 0a 20 20 28 6c 65 74 2a 20 28  s #f)).  (let* (
5d30: 28 6b 65 79 73 20 20 20 20 20 20 20 20 20 28 72  (keys         (r
5d40: 64 62 3a 67 65 74 2d 6b 65 79 73 20 64 62 29 29  db:get-keys db))
5d50: 0a 09 20 28 72 75 6e 64 61 74 20 20 20 20 20 20  .. (rundat      
5d60: 20 28 72 75 6e 73 3a 67 65 74 2d 72 75 6e 73 2d   (runs:get-runs-
5d70: 62 79 2d 70 61 74 74 20 64 62 20 6b 65 79 73 20  by-patt db keys 
5d80: 72 75 6e 6e 61 6d 65 70 61 74 74 29 29 0a 09 20  runnamepatt)).. 
5d90: 28 68 65 61 64 65 72 20 20 20 20 20 20 20 28 76  (header       (v
5da0: 65 63 74 6f 72 2d 72 65 66 20 72 75 6e 64 61 74  ector-ref rundat
5db0: 20 30 29 29 0a 09 20 28 72 75 6e 73 20 20 20 20   0)).. (runs    
5dc0: 20 20 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66       (vector-ref
5dd0: 20 72 75 6e 64 61 74 20 31 29 29 0a 09 20 28 73   rundat 1)).. (s
5de0: 74 61 74 65 73 20 20 20 20 20 20 20 28 69 66 20  tates       (if 
5df0: 73 74 61 74 65 20 20 28 73 74 72 69 6e 67 2d 73  state  (string-s
5e00: 70 6c 69 74 20 73 74 61 74 65 20 20 22 2c 22 29  plit state  ",")
5e10: 20 27 28 29 29 29 0a 09 20 28 73 74 61 74 75 73   '())).. (status
5e20: 65 73 20 20 20 20 20 28 69 66 20 73 74 61 74 75  es     (if statu
5e30: 73 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20  s (string-split 
5e40: 73 74 61 74 75 73 20 22 2c 22 29 20 27 28 29 29  status ",") '())
5e50: 29 0a 09 20 28 73 74 61 74 65 2d 73 74 61 74 75  ).. (state-statu
5e60: 73 20 28 69 66 20 28 73 74 72 69 6e 67 3f 20 6e  s (if (string? n
5e70: 65 77 2d 73 74 61 74 65 2d 73 74 61 74 75 73 29  ew-state-status)
5e80: 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 6e   (string-split n
5e90: 65 77 2d 73 74 61 74 65 2d 73 74 61 74 75 73 20  ew-state-status 
5ea0: 22 2c 22 29 20 27 28 23 66 20 23 66 29 29 29 29  ",") '(#f #f))))
5eb0: 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e  .    (debug:prin
5ec0: 74 20 32 20 22 48 65 61 64 65 72 3a 20 22 20 68  t 2 "Header: " h
5ed0: 65 61 64 65 72 20 22 20 61 63 74 69 6f 6e 3a 20  eader " action: 
5ee0: 22 20 61 63 74 69 6f 6e 20 22 20 6e 65 77 2d 73  " action " new-s
5ef0: 74 61 74 65 2d 73 74 61 74 75 73 3a 20 22 20 6e  tate-status: " n
5f00: 65 77 2d 73 74 61 74 65 2d 73 74 61 74 75 73 29  ew-state-status)
5f10: 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 0a 20  .    (for-each. 
5f20: 20 20 20 20 28 6c 61 6d 62 64 61 20 28 72 75 6e      (lambda (run
5f30: 29 0a 20 20 20 20 20 20 20 28 6c 65 74 20 28 28  ).       (let ((
5f40: 72 75 6e 6b 65 79 20 28 73 74 72 69 6e 67 2d 69  runkey (string-i
5f50: 6e 74 65 72 73 70 65 72 73 65 20 28 6d 61 70 20  ntersperse (map 
5f60: 28 6c 61 6d 62 64 61 20 28 6b 29 0a 09 09 09 09  (lambda (k).....
5f70: 09 09 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d  ..(db:get-value-
5f80: 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65  by-header run he
5f90: 61 64 65 72 20 28 76 65 63 74 6f 72 2d 72 65 66  ader (vector-ref
5fa0: 20 6b 20 30 29 29 29 20 6b 65 79 73 29 20 22 2f   k 0))) keys) "/
5fb0: 22 29 29 0a 09 20 20 20 20 20 28 64 69 72 73 2d  "))..     (dirs-
5fc0: 74 6f 2d 72 65 6d 6f 76 65 20 28 6d 61 6b 65 2d  to-remove (make-
5fd0: 68 61 73 68 2d 74 61 62 6c 65 29 29 29 0a 09 20  hash-table))).. 
5fe0: 28 6c 65 74 2a 20 28 28 72 75 6e 2d 69 64 20 20  (let* ((run-id  
5ff0: 20 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d    (db:get-value-
6000: 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65  by-header run he
6010: 61 64 65 72 20 22 69 64 22 29 29 0a 09 09 28 72  ader "id"))...(r
6020: 75 6e 2d 73 74 61 74 65 20 28 64 62 3a 67 65 74  un-state (db:get
6030: 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72  -value-by-header
6040: 20 72 75 6e 20 68 65 61 64 65 72 20 22 73 74 61   run header "sta
6050: 74 65 22 29 29 0a 09 09 28 74 65 73 74 73 20 20  te"))...(tests  
6060: 20 20 20 28 69 66 20 28 6e 6f 74 20 28 65 71 75     (if (not (equ
6070: 61 6c 3f 20 72 75 6e 2d 73 74 61 74 65 20 22 6c  al? run-state "l
6080: 6f 63 6b 65 64 22 29 29 0a 09 09 09 20 20 20 20  ocked"))....    
6090: 20 20 20 28 72 64 62 3a 67 65 74 2d 74 65 73 74     (rdb:get-test
60a0: 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 28 64 62  s-for-run db (db
60b0: 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65  :get-value-by-he
60c0: 61 64 65 72 20 72 75 6e 20 68 65 61 64 65 72 20  ader run header 
60d0: 22 69 64 22 29 20 74 65 73 74 70 61 74 74 20 69  "id") testpatt i
60e0: 74 65 6d 70 61 74 74 20 73 74 61 74 65 73 20 73  tempatt states s
60f0: 74 61 74 75 73 65 73 20 6e 6f 74 2d 69 6e 3a 20  tatuses not-in: 
6100: 23 66 29 0a 09 09 09 20 20 20 20 20 20 20 27 28  #f)....       '(
6110: 29 29 29 0a 09 09 28 6c 61 73 74 74 70 61 74 68  )))...(lasttpath
6120: 20 22 2f 64 6f 65 73 2f 6e 6f 74 2f 65 78 69 73   "/does/not/exis
6130: 74 2f 49 2f 68 6f 70 65 22 29 29 0a 0a 09 20 20  t/I/hope"))...  
6140: 20 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f   (if (not (null?
6150: 20 74 65 73 74 73 29 29 0a 09 20 20 20 20 20 20   tests))..      
6160: 20 28 62 65 67 69 6e 0a 09 09 20 28 63 61 73 65   (begin... (case
6170: 20 61 63 74 69 6f 6e 0a 09 09 20 20 20 28 28 72   action...   ((r
6180: 65 6d 6f 76 65 2d 72 75 6e 73 29 0a 09 09 20 20  emove-runs)...  
6190: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31    (debug:print 1
61a0: 20 22 52 65 6d 6f 76 69 6e 67 20 74 65 73 74 73   "Removing tests
61b0: 20 66 6f 72 20 72 75 6e 3a 20 22 20 72 75 6e 6b   for run: " runk
61c0: 65 79 20 22 20 22 20 28 64 62 3a 67 65 74 2d 76  ey " " (db:get-v
61d0: 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72  alue-by-header r
61e0: 75 6e 20 68 65 61 64 65 72 20 22 72 75 6e 6e 61  un header "runna
61f0: 6d 65 22 29 29 29 0a 09 09 20 20 20 28 28 73 65  me")))...   ((se
6200: 74 2d 73 74 61 74 65 2d 73 74 61 74 75 73 29 0a  t-state-status).
6210: 09 09 20 20 20 20 28 64 65 62 75 67 3a 70 72 69  ..    (debug:pri
6220: 6e 74 20 31 20 22 4d 6f 64 69 66 79 69 6e 67 20  nt 1 "Modifying 
6230: 73 74 61 74 65 20 61 6e 64 20 73 74 61 75 73 20  state and staus 
6240: 66 6f 72 20 74 65 73 74 73 20 66 6f 72 20 72 75  for tests for ru
6250: 6e 3a 20 22 20 72 75 6e 6b 65 79 20 22 20 22 20  n: " runkey " " 
6260: 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79  (db:get-value-by
6270: 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64  -header run head
6280: 65 72 20 22 72 75 6e 6e 61 6d 65 22 29 29 29 0a  er "runname"))).
6290: 09 09 20 20 20 28 65 6c 73 65 0a 09 09 20 20 20  ..   (else...   
62a0: 20 28 70 72 69 6e 74 20 22 49 4e 46 4f 3a 20 61   (print "INFO: a
62b0: 63 74 69 6f 6e 20 6e 6f 74 20 72 65 63 6f 67 6e  ction not recogn
62c0: 69 73 65 64 20 22 20 61 63 74 69 6f 6e 29 29 29  ised " action)))
62d0: 0a 09 09 20 28 66 6f 72 2d 65 61 63 68 0a 09 09  ... (for-each...
62e0: 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74 29    (lambda (test)
62f0: 0a 09 09 20 20 20 20 28 6c 65 74 2a 20 28 28 69  ...    (let* ((i
6300: 74 65 6d 2d 70 61 74 68 20 28 64 62 3a 74 65 73  tem-path (db:tes
6310: 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20  t-get-item-path 
6320: 74 65 73 74 29 29 0a 09 09 09 20 20 20 28 74 65  test))....   (te
6330: 73 74 2d 6e 61 6d 65 20 28 64 62 3a 74 65 73 74  st-name (db:test
6340: 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 74 65  -get-testname te
6350: 73 74 29 29 0a 09 09 09 20 20 20 28 72 75 6e 2d  st))....   (run-
6360: 64 69 72 20 20 20 28 64 62 3a 74 65 73 74 2d 67  dir   (db:test-g
6370: 65 74 2d 72 75 6e 64 69 72 20 74 65 73 74 29 29  et-rundir test))
6380: 29 0a 09 09 20 20 20 20 20 20 28 64 65 62 75 67  )...      (debug
6390: 3a 70 72 69 6e 74 20 31 20 22 20 20 22 20 28 64  :print 1 "  " (d
63a0: 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e  b:test-get-testn
63b0: 61 6d 65 20 74 65 73 74 29 20 22 20 69 64 3a 20  ame test) " id: 
63c0: 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69  " (db:test-get-i
63d0: 64 20 74 65 73 74 29 20 22 20 22 20 69 74 65 6d  d test) " " item
63e0: 2d 70 61 74 68 29 0a 09 09 20 20 20 20 20 20 28  -path)...      (
63f0: 63 61 73 65 20 61 63 74 69 6f 6e 0a 09 09 09 28  case action....(
6400: 28 72 65 6d 6f 76 65 2d 72 75 6e 73 29 0a 09 09  (remove-runs)...
6410: 09 20 28 72 64 62 3a 64 65 6c 65 74 65 2d 74 65  . (rdb:delete-te
6420: 73 74 2d 72 65 63 6f 72 64 73 20 64 62 20 28 64  st-records db (d
6430: 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65  b:test-get-id te
6440: 73 74 29 29 0a 09 09 09 20 28 69 66 20 28 3e 20  st)).... (if (> 
6450: 28 73 74 72 69 6e 67 2d 6c 65 6e 67 74 68 20 72  (string-length r
6460: 75 6e 2d 64 69 72 29 20 35 29 20 3b 3b 20 62 61  un-dir) 5) ;; ba
6470: 64 20 68 65 75 72 69 73 74 69 63 20 62 75 74 20  d heuristic but 
6480: 73 68 6f 75 6c 64 20 70 72 65 76 65 6e 74 20 2f  should prevent /
6490: 74 6d 70 20 2f 68 6f 6d 65 20 65 74 63 2e 0a 09  tmp /home etc...
64a0: 09 09 20 20 20 20 20 28 6c 65 74 20 28 28 66 75  ..     (let ((fu
64b0: 6c 6c 70 61 74 68 20 72 75 6e 2d 64 69 72 29 29  llpath run-dir))
64c0: 20 3b 3b 20 22 2f 22 20 28 64 62 3a 74 65 73 74   ;; "/" (db:test
64d0: 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74  -get-item-path t
64e0: 65 73 74 29 29 29 29 0a 09 09 09 20 20 20 20 20  est))))....     
64f0: 20 20 28 73 65 74 21 20 6c 61 73 74 74 70 61 74    (set! lasttpat
6500: 68 20 66 75 6c 6c 70 61 74 68 29 0a 09 09 09 20  h fullpath).... 
6510: 20 20 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c        (hash-tabl
6520: 65 2d 73 65 74 21 20 64 69 72 73 2d 74 6f 2d 72  e-set! dirs-to-r
6530: 65 6d 6f 76 65 20 66 75 6c 6c 70 61 74 68 20 23  emove fullpath #
6540: 74 29 0a 09 09 09 20 20 20 20 20 20 20 3b 3b 20  t)....       ;; 
6550: 54 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 77 61  The following wa
6560: 73 20 74 68 65 20 73 61 66 65 20 64 65 6c 65 74  s the safe delet
6570: 65 20 63 6f 64 65 20 62 75 74 20 69 74 20 77 61  e code but it wa
6580: 73 20 6e 6f 74 20 62 65 69 6e 67 20 65 78 65 63  s not being exec
6590: 74 75 74 65 64 2e 0a 09 09 09 20 20 20 20 20 20  tuted.....      
65a0: 20 3b 3b 20 28 6c 65 74 2a 20 28 28 64 69 72 73   ;; (let* ((dirs
65b0: 2d 63 6f 75 6e 74 20 28 2b 20 31 20 28 6c 65 6e  -count (+ 1 (len
65c0: 67 74 68 20 6b 65 79 73 29 28 6c 65 6e 67 74 68  gth keys)(length
65d0: 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 69   (string-split i
65e0: 74 65 6d 2d 70 61 74 68 20 22 2f 22 29 29 29 29  tem-path "/"))))
65f0: 0a 09 09 09 20 20 20 20 20 20 20 3b 3b 20 20 20  ....       ;;   
6600: 20 20 20 20 20 28 64 69 72 2d 74 6f 2d 72 65 6d       (dir-to-rem
6610: 20 28 67 65 74 2d 64 69 72 2d 75 70 2d 6e 20 66   (get-dir-up-n f
6620: 75 6c 6c 70 61 74 68 20 64 69 72 73 2d 63 6f 75  ullpath dirs-cou
6630: 6e 74 29 29 0a 09 09 09 20 20 20 20 20 20 20 3b  nt))....       ;
6640: 3b 20 20 20 20 20 20 20 20 28 72 65 6d 61 69 6e  ;        (remain
6650: 69 6e 67 64 20 28 73 74 72 69 6e 67 2d 73 75 62  ingd (string-sub
6660: 73 74 69 74 75 74 65 20 28 72 65 67 65 78 70 20  stitute (regexp 
6670: 28 63 6f 6e 63 20 22 5e 22 20 64 69 72 2d 74 6f  (conc "^" dir-to
6680: 2d 72 65 6d 20 22 2f 22 29 29 20 22 22 20 66 75  -rem "/")) "" fu
6690: 6c 6c 70 61 74 68 29 29 0a 09 09 09 20 20 20 20  llpath))....    
66a0: 20 20 20 3b 3b 20 20 20 20 20 20 20 20 28 63 6d     ;;        (cm
66b0: 64 20 28 63 6f 6e 63 20 22 63 64 20 22 20 64 69  d (conc "cd " di
66c0: 72 2d 74 6f 2d 72 65 6d 20 22 3b 20 72 6d 64 69  r-to-rem "; rmdi
66d0: 72 20 2d 70 20 22 20 72 65 6d 61 69 6e 69 6e 67  r -p " remaining
66e0: 64 20 29 29 29 0a 09 09 09 20 20 20 20 20 20 20  d )))....       
66f0: 3b 3b 20 20 20 28 69 66 20 28 66 69 6c 65 2d 65  ;;   (if (file-e
6700: 78 69 73 74 73 3f 20 66 75 6c 6c 70 61 74 68 29  xists? fullpath)
6710: 0a 09 09 09 20 20 20 20 20 20 20 3b 3b 20 20 20  ....       ;;   
6720: 20 20 20 20 28 62 65 67 69 6e 0a 09 09 09 20 20      (begin....  
6730: 20 20 20 20 20 3b 3b 20 20 20 20 20 20 20 20 20       ;;         
6740: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 63  (debug:print 1 c
6750: 6d 64 29 0a 09 09 09 20 20 20 20 20 20 20 3b 3b  md)....       ;;
6760: 20 20 20 20 20 20 20 20 20 28 73 79 73 74 65 6d           (system
6770: 20 63 6d 64 29 29 29 0a 09 09 09 20 20 20 20 20   cmd)))....     
6780: 20 20 3b 3b 20 20 20 29 29 0a 09 09 09 20 20 20    ;;   ))....   
6790: 20 20 20 20 29 29 29 0a 09 09 09 28 28 73 65 74      )))....((set
67a0: 2d 73 74 61 74 65 2d 73 74 61 74 75 73 29 0a 09  -state-status)..
67b0: 09 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20  .. (debug:print 
67c0: 34 20 22 49 4e 46 4f 3a 20 6e 65 77 20 73 74 61  4 "INFO: new sta
67d0: 74 65 20 22 20 28 63 61 72 20 73 74 61 74 65 2d  te " (car state-
67e0: 73 74 61 74 75 73 29 20 22 2c 20 6e 65 77 20 73  status) ", new s
67f0: 74 61 74 75 73 20 22 20 28 63 61 64 72 20 73 74  tatus " (cadr st
6800: 61 74 65 2d 73 74 61 74 75 73 29 29 0a 09 09 09  ate-status))....
6810: 20 28 64 62 3a 74 65 73 74 2d 73 65 74 2d 73 74   (db:test-set-st
6820: 61 74 65 2d 73 74 61 74 75 73 2d 62 79 2d 69 64  ate-status-by-id
6830: 20 64 62 20 28 64 62 3a 74 65 73 74 2d 67 65 74   db (db:test-get
6840: 2d 69 64 20 74 65 73 74 29 20 28 63 61 72 20 73  -id test) (car s
6850: 74 61 74 65 2d 73 74 61 74 75 73 29 28 63 61 64  tate-status)(cad
6860: 72 20 73 74 61 74 65 2d 73 74 61 74 75 73 29 20  r state-status) 
6870: 23 66 29 29 29 29 29 0a 09 09 20 20 74 65 73 74  #f)))))...  test
6880: 73 29 29 29 0a 0a 09 20 20 20 3b 3b 20 6c 6f 6f  s)))...   ;; loo
6890: 6b 20 74 68 6f 75 67 68 20 74 68 65 20 64 69 72  k though the dir
68a0: 73 2d 74 6f 2d 72 65 6d 6f 76 65 20 66 6f 72 20  s-to-remove for 
68b0: 63 61 6e 64 69 64 61 74 65 73 20 66 6f 72 20 72  candidates for r
68c0: 65 6d 6f 76 61 6c 2e 20 44 6f 20 74 68 69 73 20  emoval. Do this 
68d0: 61 66 74 65 72 20 64 65 6c 65 74 69 6e 67 20 74  after deleting t
68e0: 68 65 20 72 65 63 6f 72 64 73 0a 09 20 20 20 3b  he records..   ;
68f0: 3b 20 66 6f 72 20 65 61 63 68 20 74 65 73 74 20  ; for each test 
6900: 69 6e 20 63 61 73 65 20 77 65 20 67 65 74 20 6b  in case we get k
6910: 69 6c 6c 65 64 2e 20 54 68 61 74 20 73 68 6f 75  illed. That shou
6920: 6c 64 20 6d 69 6e 69 6d 69 7a 65 20 74 68 65 20  ld minimize the 
6930: 64 65 74 72 69 74 75 73 20 6c 65 66 74 20 6f 6e  detritus left on
6940: 20 64 69 73 6b 0a 09 20 20 20 3b 3b 20 70 72 6f   disk..   ;; pro
6950: 63 65 73 73 20 74 68 65 20 64 69 72 73 20 66 72  cess the dirs fr
6960: 6f 6d 20 6c 6f 6e 67 65 73 74 20 73 74 72 69 6e  om longest strin
6970: 67 20 6c 65 6e 67 74 68 20 74 6f 20 73 68 6f 72  g length to shor
6980: 74 65 73 74 0a 09 20 20 20 28 69 66 20 28 65 71  test..   (if (eq
6990: 3f 20 61 63 74 69 6f 6e 20 27 72 65 6d 6f 76 65  ? action 'remove
69a0: 2d 72 75 6e 73 29 0a 09 20 20 20 20 20 20 20 28  -runs)..       (
69b0: 66 6f 72 2d 65 61 63 68 20 0a 09 09 28 6c 61 6d  for-each ...(lam
69c0: 62 64 61 20 28 64 69 72 2d 74 6f 2d 72 65 6d 6f  bda (dir-to-remo
69d0: 76 65 29 0a 09 09 20 20 28 69 66 20 28 66 69 6c  ve)...  (if (fil
69e0: 65 2d 65 78 69 73 74 73 3f 20 64 69 72 2d 74 6f  e-exists? dir-to
69f0: 2d 72 65 6d 6f 76 65 29 0a 09 09 20 20 20 20 20  -remove)...     
6a00: 20 28 6c 65 74 20 28 28 64 69 72 2d 69 6e 2d 64   (let ((dir-in-d
6a10: 62 20 27 28 29 29 29 0a 09 09 09 28 73 71 6c 69  b '()))....(sqli
6a20: 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77  te3:for-each-row
6a30: 0a 09 09 09 20 28 6c 61 6d 62 64 61 20 28 64 69  .... (lambda (di
6a40: 72 29 0a 09 09 09 20 20 20 28 73 65 74 21 20 64  r)....   (set! d
6a50: 69 72 2d 69 6e 2d 64 62 20 28 63 6f 6e 73 20 64  ir-in-db (cons d
6a60: 69 72 20 64 69 72 2d 69 6e 2d 64 62 29 29 29 0a  ir dir-in-db))).
6a70: 09 09 09 20 64 62 20 22 53 45 4c 45 43 54 20 72  ... db "SELECT r
6a80: 75 6e 64 69 72 20 46 52 4f 4d 20 74 65 73 74 73  undir FROM tests
6a90: 20 57 48 45 52 45 20 72 75 6e 64 69 72 20 4c 49   WHERE rundir LI
6aa0: 4b 45 20 3f 3b 22 20 0a 09 09 09 20 28 63 6f 6e  KE ?;" .... (con
6ab0: 63 20 22 25 22 20 64 69 72 2d 74 6f 2d 72 65 6d  c "%" dir-to-rem
6ac0: 6f 76 65 20 22 25 22 29 29 20 3b 3b 20 79 65 73  ove "%")) ;; yes
6ad0: 2c 20 49 27 6d 20 67 6f 69 6e 67 20 74 6f 20 62  , I'm going to b
6ae0: 61 69 6c 20 69 66 20 74 68 65 72 65 20 69 73 20  ail if there is 
6af0: 61 6e 79 74 68 69 6e 67 20 6c 69 6b 65 20 74 68  anything like th
6b00: 69 73 20 64 69 72 20 69 6e 20 74 68 65 20 64 62  is dir in the db
6b10: 0a 09 09 09 28 69 66 20 28 6e 75 6c 6c 3f 20 64  ....(if (null? d
6b20: 69 72 2d 69 6e 2d 64 62 29 0a 09 09 09 20 20 20  ir-in-db)....   
6b30: 20 28 62 65 67 69 6e 0a 09 09 09 20 20 20 20 20   (begin....     
6b40: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20   (debug:print 2 
6b50: 22 52 65 6d 6f 76 69 6e 67 20 64 69 72 65 63 74  "Removing direct
6b60: 6f 72 79 20 77 69 74 68 20 7a 65 72 6f 20 64 62  ory with zero db
6b70: 20 72 65 66 65 72 65 6e 63 65 73 3a 20 22 20 64   references: " d
6b80: 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 0a 09 09  ir-to-remove)...
6b90: 09 20 20 20 20 20 20 28 73 79 73 74 65 6d 20 28  .      (system (
6ba0: 63 6f 6e 63 20 22 72 6d 20 2d 72 66 20 22 20 64  conc "rm -rf " d
6bb0: 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 29 0a 09  ir-to-remove))..
6bc0: 09 09 20 20 20 20 20 20 28 68 61 73 68 2d 74 61  ..      (hash-ta
6bd0: 62 6c 65 2d 64 65 6c 65 74 65 21 20 64 69 72 73  ble-delete! dirs
6be0: 2d 74 6f 2d 72 65 6d 6f 76 65 20 64 69 72 2d 74  -to-remove dir-t
6bf0: 6f 2d 72 65 6d 6f 76 65 29 29 0a 09 09 09 20 20  o-remove))....  
6c00: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32    (debug:print 2
6c10: 20 22 53 6b 69 70 70 69 6e 67 20 72 65 6d 6f 76   "Skipping remov
6c20: 61 6c 20 6f 66 20 22 20 64 69 72 2d 74 6f 2d 72  al of " dir-to-r
6c30: 65 6d 6f 76 65 20 22 20 66 6f 72 20 6e 6f 77 20  emove " for now 
6c40: 61 73 20 69 74 20 73 74 69 6c 6c 20 68 61 73 20  as it still has 
6c50: 72 65 66 65 72 65 6e 63 65 73 20 69 6e 20 74 68  references in th
6c60: 65 20 64 61 74 61 62 61 73 65 22 29 29 29 29 29  e database")))))
6c70: 0a 09 09 28 73 6f 72 74 20 28 68 61 73 68 2d 74  ...(sort (hash-t
6c80: 61 62 6c 65 2d 6b 65 79 73 20 64 69 72 73 2d 74  able-keys dirs-t
6c90: 6f 2d 72 65 6d 6f 76 65 29 20 28 6c 61 6d 62 64  o-remove) (lambd
6ca0: 61 20 28 61 20 62 29 28 3e 20 28 73 74 72 69 6e  a (a b)(> (strin
6cb0: 67 2d 6c 65 6e 67 74 68 20 61 29 28 73 74 72 69  g-length a)(stri
6cc0: 6e 67 2d 6c 65 6e 67 74 68 20 62 29 29 29 29 29  ng-length b)))))
6cd0: 29 0a 0a 09 20 20 20 3b 3b 20 72 65 6d 6f 76 65  )...   ;; remove
6ce0: 20 74 68 65 20 72 75 6e 20 69 66 20 7a 65 72 6f   the run if zero
6cf0: 20 74 65 73 74 73 20 72 65 6d 61 69 6e 0a 09 20   tests remain.. 
6d00: 20 20 28 69 66 20 28 65 71 3f 20 61 63 74 69 6f    (if (eq? actio
6d10: 6e 20 27 72 65 6d 6f 76 65 2d 72 75 6e 73 29 0a  n 'remove-runs).
6d20: 09 20 20 20 20 20 20 20 28 6c 65 74 20 28 28 72  .       (let ((r
6d30: 65 6d 74 65 73 74 73 20 28 72 64 62 3a 67 65 74  emtests (rdb:get
6d40: 2d 74 65 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64  -tests-for-run d
6d50: 62 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d  b (db:get-value-
6d60: 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65  by-header run he
6d70: 61 64 65 72 20 22 69 64 22 29 20 23 66 20 23 66  ader "id") #f #f
6d80: 20 27 28 29 20 27 28 29 29 29 29 0a 09 09 20 28   '() '())))... (
6d90: 69 66 20 28 6e 75 6c 6c 3f 20 72 65 6d 74 65 73  if (null? remtes
6da0: 74 73 29 20 3b 3b 20 6e 6f 20 6d 6f 72 65 20 74  ts) ;; no more t
6db0: 65 73 74 73 20 72 65 6d 61 69 6e 69 6e 67 0a 09  ests remaining..
6dc0: 09 20 20 20 20 20 28 6c 65 74 2a 20 28 28 64 70  .     (let* ((dp
6dd0: 61 72 74 73 20 20 28 73 74 72 69 6e 67 2d 73 70  arts  (string-sp
6de0: 6c 69 74 20 6c 61 73 74 74 70 61 74 68 20 22 2f  lit lasttpath "/
6df0: 22 29 29 0a 09 09 09 20 20 20 20 28 72 75 6e 70  "))....    (runp
6e00: 61 74 68 20 28 63 6f 6e 63 20 22 2f 22 20 28 73  ath (conc "/" (s
6e10: 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73  tring-interspers
6e20: 65 20 0a 09 09 09 09 09 09 28 74 61 6b 65 20 64  e .......(take d
6e30: 70 61 72 74 73 20 28 2d 20 28 6c 65 6e 67 74 68  parts (- (length
6e40: 20 64 70 61 72 74 73 29 20 31 29 29 0a 09 09 09   dparts) 1))....
6e50: 09 09 09 22 2f 22 29 29 29 29 0a 09 09 20 20 20  ..."/"))))...   
6e60: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
6e70: 20 31 20 22 52 65 6d 6f 76 69 6e 67 20 72 75 6e   1 "Removing run
6e80: 3a 20 22 20 72 75 6e 6b 65 79 20 22 20 22 20 28  : " runkey " " (
6e90: 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d  db:get-value-by-
6ea0: 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65  header run heade
6eb0: 72 20 22 72 75 6e 6e 61 6d 65 22 29 29 0a 09 09  r "runname"))...
6ec0: 20 20 20 20 20 20 20 28 64 62 3a 64 65 6c 65 74         (db:delet
6ed0: 65 2d 72 75 6e 20 64 62 20 72 75 6e 2d 69 64 29  e-run db run-id)
6ee0: 0a 09 09 20 20 20 20 20 20 20 3b 3b 20 6e 65 65  ...       ;; nee
6ef0: 64 20 74 6f 20 66 69 67 75 72 65 20 6f 75 74 20  d to figure out 
6f00: 74 68 65 20 70 61 74 68 20 74 6f 20 74 68 65 20  the path to the 
6f10: 72 75 6e 20 64 69 72 20 61 6e 64 20 72 65 6d 6f  run dir and remo
6f20: 76 65 20 69 74 20 69 66 20 65 6d 70 74 79 0a 09  ve it if empty..
6f30: 09 20 20 20 20 20 20 20 3b 3b 20 20 20 20 28 69  .       ;;    (i
6f40: 66 20 28 6e 75 6c 6c 3f 20 28 67 6c 6f 62 20 28  f (null? (glob (
6f50: 63 6f 6e 63 20 72 75 6e 70 61 74 68 20 22 2f 2a  conc runpath "/*
6f60: 22 29 29 29 0a 09 09 20 20 20 20 20 20 20 3b 3b  ")))...       ;;
6f70: 20 20 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09          (begin..
6f80: 09 20 20 20 20 20 20 20 3b 3b 20 09 20 28 64 65  .       ;; . (de
6f90: 62 75 67 3a 70 72 69 6e 74 20 31 20 22 52 65 6d  bug:print 1 "Rem
6fa0: 6f 76 69 6e 67 20 72 75 6e 20 64 69 72 20 22 20  oving run dir " 
6fb0: 72 75 6e 70 61 74 68 29 0a 09 09 20 20 20 20 20  runpath)...     
6fc0: 20 20 3b 3b 20 09 20 28 73 79 73 74 65 6d 20 28    ;; . (system (
6fd0: 63 6f 6e 63 20 22 72 6d 64 69 72 20 2d 70 20 22  conc "rmdir -p "
6fe0: 20 72 75 6e 70 61 74 68 29 29 29 29 0a 09 09 20   runpath))))... 
6ff0: 20 20 20 20 20 20 29 29 29 29 29 0a 09 20 29 29        ))))).. ))
7000: 0a 20 20 20 20 20 72 75 6e 73 29 29 29 0a 0a 3b  .     runs)))..;
7010: 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ;===============
7020: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7030: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7040: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7050: 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 52 6f 75 74 69  =======.;; Routi
7060: 6e 65 73 20 66 6f 72 20 6d 61 6e 69 70 75 6c 61  nes for manipula
7070: 74 69 6e 67 20 72 75 6e 73 0a 3b 3b 3d 3d 3d 3d  ting runs.;;====
7080: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7090: 3d 3d 3d 3d 3d 3d 3d 3d 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 0a 0a 3b 3b 20 53 69 6e 63 65 20 6d 61 6e  ==..;; Since man
70d0: 79 20 63 61 6c 6c 73 20 74 6f 20 61 20 72 75 6e  y calls to a run
70e0: 20 72 65 71 75 69 72 65 20 70 72 65 74 74 79 20   require pretty 
70f0: 6d 75 63 68 20 74 68 65 20 73 61 6d 65 20 73 65  much the same se
7100: 74 75 70 20 0a 3b 3b 20 74 68 69 73 20 77 72 61  tup .;; this wra
7110: 70 70 65 72 20 69 73 20 75 73 65 64 20 74 6f 20  pper is used to 
7120: 72 65 64 75 63 65 20 74 68 65 20 72 65 70 6c 69  reduce the repli
7130: 63 61 74 69 6f 6e 20 6f 66 20 63 6f 64 65 0a 28  cation of code.(
7140: 64 65 66 69 6e 65 20 28 67 65 6e 65 72 61 6c 2d  define (general-
7150: 72 75 6e 2d 63 61 6c 6c 20 73 77 69 74 63 68 6e  run-call switchn
7160: 61 6d 65 20 61 63 74 69 6f 6e 2d 64 65 73 63 20  ame action-desc 
7170: 70 72 6f 63 29 0a 20 20 28 6c 65 74 20 28 28 72  proc).  (let ((r
7180: 75 6e 6e 61 6d 65 20 28 61 72 67 73 3a 67 65 74  unname (args:get
7190: 2d 61 72 67 20 22 3a 72 75 6e 6e 61 6d 65 22 29  -arg ":runname")
71a0: 29 0a 09 28 74 61 72 67 65 74 20 20 28 69 66 20  )..(target  (if 
71b0: 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d  (args:get-arg "-
71c0: 74 61 72 67 65 74 22 29 0a 09 09 20 20 20 20 20  target")...     
71d0: 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d  (args:get-arg "-
71e0: 74 61 72 67 65 74 22 29 0a 09 09 20 20 20 20 20  target")...     
71f0: 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d  (args:get-arg "-
7200: 72 65 71 74 61 72 67 22 29 29 29 0a 09 28 74 68  reqtarg")))..(th
7210: 31 20 20 20 20 20 23 66 29 29 0a 20 20 20 20 28  1     #f)).    (
7220: 63 6f 6e 64 0a 20 20 20 20 20 28 28 6e 6f 74 20  cond.     ((not 
7230: 74 61 72 67 65 74 29 0a 20 20 20 20 20 20 28 64  target).      (d
7240: 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52  ebug:print 0 "ER
7250: 52 4f 52 3a 20 4d 69 73 73 69 6e 67 20 72 65 71  ROR: Missing req
7260: 75 69 72 65 64 20 70 61 72 61 6d 65 74 65 72 20  uired parameter 
7270: 66 6f 72 20 22 20 73 77 69 74 63 68 6e 61 6d 65  for " switchname
7280: 20 22 2c 20 79 6f 75 20 6d 75 73 74 20 73 70 65   ", you must spe
7290: 63 69 66 79 20 74 68 65 20 74 61 72 67 65 74 20  cify the target 
72a0: 77 69 74 68 20 2d 74 61 72 67 65 74 22 29 0a 20  with -target"). 
72b0: 20 20 20 20 20 28 65 78 69 74 20 33 29 29 0a 20       (exit 3)). 
72c0: 20 20 20 20 28 28 6e 6f 74 20 72 75 6e 6e 61 6d      ((not runnam
72d0: 65 29 0a 20 20 20 20 20 20 28 64 65 62 75 67 3a  e).      (debug:
72e0: 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20  print 0 "ERROR: 
72f0: 4d 69 73 73 69 6e 67 20 72 65 71 75 69 72 65 64  Missing required
7300: 20 70 61 72 61 6d 65 74 65 72 20 66 6f 72 20 22   parameter for "
7310: 20 73 77 69 74 63 68 6e 61 6d 65 20 22 2c 20 79   switchname ", y
7320: 6f 75 20 6d 75 73 74 20 73 70 65 63 69 66 79 20  ou must specify 
7330: 74 68 65 20 72 75 6e 20 6e 61 6d 65 20 77 69 74  the run name wit
7340: 68 20 3a 72 75 6e 6e 61 6d 65 20 72 75 6e 6e 61  h :runname runna
7350: 6d 65 22 29 0a 20 20 20 20 20 20 28 65 78 69 74  me").      (exit
7360: 20 33 29 29 0a 20 20 20 20 20 28 65 6c 73 65 0a   3)).     (else.
7370: 20 20 20 20 20 20 28 6c 65 74 20 28 28 64 62 20        (let ((db 
7380: 20 20 23 66 29 0a 09 20 20 20 20 28 6b 65 79 73    #f)..    (keys
7390: 20 23 66 29 29 0a 09 28 69 66 20 28 6e 6f 74 20   #f))..(if (not 
73a0: 28 73 65 74 75 70 2d 66 6f 72 2d 72 75 6e 29 29  (setup-for-run))
73b0: 0a 09 20 20 20 20 28 62 65 67 69 6e 20 0a 09 20  ..    (begin .. 
73c0: 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e       (debug:prin
73d0: 74 20 30 20 22 46 61 69 6c 65 64 20 74 6f 20 73  t 0 "Failed to s
73e0: 65 74 75 70 2c 20 65 78 69 74 69 6e 67 22 29 0a  etup, exiting").
73f0: 09 20 20 20 20 20 20 28 65 78 69 74 20 31 29 29  .      (exit 1))
7400: 29 0a 09 28 73 65 74 21 20 64 62 20 20 20 28 6f  )..(set! db   (o
7410: 70 65 6e 2d 64 62 29 29 0a 09 28 69 66 20 28 61  pen-db))..(if (a
7420: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 73 65  rgs:get-arg "-se
7430: 72 76 65 72 22 29 0a 09 20 20 20 20 28 73 65 72  rver")..    (ser
7440: 76 65 72 3a 73 74 61 72 74 20 64 62 20 28 61 72  ver:start db (ar
7450: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 73 65 72  gs:get-arg "-ser
7460: 76 65 72 22 29 29 0a 09 20 20 20 20 28 69 66 20  ver"))..    (if 
7470: 28 6e 6f 74 20 28 6f 72 20 28 61 72 67 73 3a 67  (not (or (args:g
7480: 65 74 2d 61 72 67 20 22 2d 72 75 6e 61 6c 6c 22  et-arg "-runall"
7490: 29 0a 09 09 09 20 20 28 61 72 67 73 3a 67 65 74  )....  (args:get
74a0: 2d 61 72 67 20 22 2d 72 75 6e 74 65 73 74 73 22  -arg "-runtests"
74b0: 29 29 29 0a 09 09 28 73 65 72 76 65 72 3a 63 6c  )))...(server:cl
74c0: 69 65 6e 74 2d 73 65 74 75 70 20 64 62 29 29 29  ient-setup db)))
74d0: 0a 09 28 73 65 74 21 20 6b 65 79 73 20 28 72 64  ..(set! keys (rd
74e0: 62 3a 67 65 74 2d 6b 65 79 73 20 64 62 29 29 0a  b:get-keys db)).
74f0: 09 3b 3b 20 68 61 76 65 20 65 6e 6f 75 67 68 20  .;; have enough 
7500: 74 6f 20 70 72 6f 63 65 73 73 20 2d 74 61 72 67  to process -targ
7510: 65 74 20 6f 72 20 2d 72 65 71 74 61 72 67 20 68  et or -reqtarg h
7520: 65 72 65 0a 09 28 69 66 20 28 61 72 67 73 3a 67  ere..(if (args:g
7530: 65 74 2d 61 72 67 20 22 2d 72 65 71 74 61 72 67  et-arg "-reqtarg
7540: 22 29 0a 09 20 20 20 20 28 6c 65 74 2a 20 28 28  ")..    (let* ((
7550: 72 75 6e 63 6f 6e 66 69 67 66 20 28 63 6f 6e 63  runconfigf (conc
7560: 20 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f 72 75    *toppath* "/ru
7570: 6e 63 6f 6e 66 69 67 73 2e 63 6f 6e 66 69 67 22  nconfigs.config"
7580: 29 29 20 3b 3b 20 44 4f 20 4e 4f 54 20 45 56 41  )) ;; DO NOT EVA
7590: 4c 55 41 54 45 20 41 4c 4c 20 0a 09 09 20 20 20  LUATE ALL ...   
75a0: 28 72 75 6e 63 6f 6e 66 69 67 20 20 28 72 65 61  (runconfig  (rea
75b0: 64 2d 63 6f 6e 66 69 67 20 72 75 6e 63 6f 6e 66  d-config runconf
75c0: 69 67 66 20 23 66 20 23 66 20 65 6e 76 69 72 6f  igf #f #f enviro
75d0: 6e 2d 70 61 74 74 3a 20 23 66 29 29 29 20 0a 09  n-patt: #f))) ..
75e0: 20 20 20 20 20 20 28 69 66 20 28 68 61 73 68 2d        (if (hash-
75f0: 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c  table-ref/defaul
7600: 74 20 72 75 6e 63 6f 6e 66 69 67 20 28 61 72 67  t runconfig (arg
7610: 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65 71 74  s:get-arg "-reqt
7620: 61 72 67 22 29 20 23 66 29 0a 09 09 20 20 28 6b  arg") #f)...  (k
7630: 65 79 73 3a 74 61 72 67 65 74 2d 73 65 74 2d 61  eys:target-set-a
7640: 72 67 73 20 6b 65 79 73 20 28 61 72 67 73 3a 67  rgs keys (args:g
7650: 65 74 2d 61 72 67 20 22 2d 72 65 71 74 61 72 67  et-arg "-reqtarg
7660: 22 29 20 61 72 67 73 3a 61 72 67 2d 68 61 73 68  ") args:arg-hash
7670: 29 0a 09 09 20 20 28 62 65 67 69 6e 0a 09 09 20  )...  (begin... 
7680: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
7690: 30 20 22 45 52 52 4f 52 3a 20 5b 22 20 28 61 72  0 "ERROR: [" (ar
76a0: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65 71  gs:get-arg "-req
76b0: 74 61 72 67 22 29 20 22 5d 20 6e 6f 74 20 66 6f  targ") "] not fo
76c0: 75 6e 64 20 69 6e 20 22 20 72 75 6e 63 6f 6e 66  und in " runconf
76d0: 69 67 66 29 0a 09 09 20 20 20 20 28 73 71 6c 69  igf)...    (sqli
76e0: 74 65 33 3a 66 69 6e 61 6c 69 7a 65 21 20 64 62  te3:finalize! db
76f0: 29 0a 09 09 20 20 20 20 28 65 78 69 74 20 31 29  )...    (exit 1)
7700: 29 29 29 0a 09 20 20 20 20 28 69 66 20 28 61 72  )))..    (if (ar
7710: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 74 61 72  gs:get-arg "-tar
7720: 67 65 74 22 29 0a 09 09 28 6b 65 79 73 3a 74 61  get")...(keys:ta
7730: 72 67 65 74 2d 73 65 74 2d 61 72 67 73 20 6b 65  rget-set-args ke
7740: 79 73 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67  ys (args:get-arg
7750: 20 22 2d 74 61 72 67 65 74 22 20 61 72 67 73 3a   "-target" args:
7760: 61 72 67 2d 68 61 73 68 29 20 61 72 67 73 3a 61  arg-hash) args:a
7770: 72 67 2d 68 61 73 68 29 29 29 0a 09 28 69 66 20  rg-hash)))..(if 
7780: 28 6e 6f 74 20 28 63 61 72 20 2a 63 6f 6e 66 69  (not (car *confi
7790: 67 69 6e 66 6f 2a 29 29 0a 09 20 20 20 20 28 62  ginfo*))..    (b
77a0: 65 67 69 6e 0a 09 20 20 20 20 20 20 28 64 65 62  egin..      (deb
77b0: 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f  ug:print 0 "ERRO
77c0: 52 3a 20 41 74 74 65 6d 70 74 65 64 20 74 6f 20  R: Attempted to 
77d0: 22 20 61 63 74 69 6f 6e 2d 64 65 73 63 20 22 20  " action-desc " 
77e0: 62 75 74 20 72 75 6e 20 61 72 65 61 20 63 6f 6e  but run area con
77f0: 66 69 67 20 66 69 6c 65 20 6e 6f 74 20 66 6f 75  fig file not fou
7800: 6e 64 22 29 0a 09 20 20 20 20 20 20 28 65 78 69  nd")..      (exi
7810: 74 20 31 29 29 0a 09 20 20 20 20 3b 3b 20 45 78  t 1))..    ;; Ex
7820: 74 72 61 63 74 20 6f 75 74 20 73 74 75 66 66 20  tract out stuff 
7830: 6e 65 65 64 65 64 20 69 6e 20 6d 6f 73 74 20 6f  needed in most o
7840: 72 20 6d 61 6e 79 20 63 61 6c 6c 73 0a 09 20 20  r many calls..  
7850: 20 20 3b 3b 20 68 65 72 65 20 74 68 65 6e 20 63    ;; here then c
7860: 61 6c 6c 20 70 72 6f 63 0a 09 20 20 20 20 28 6c  all proc..    (l
7870: 65 74 2a 20 28 28 6b 65 79 6e 61 6d 65 73 20 20  et* ((keynames  
7880: 20 28 6d 61 70 20 6b 65 79 3a 67 65 74 2d 66 69   (map key:get-fi
7890: 65 6c 64 6e 61 6d 65 20 6b 65 79 73 29 29 0a 09  eldname keys))..
78a0: 09 20 20 20 28 6b 65 79 76 61 6c 6c 73 74 20 20  .   (keyvallst  
78b0: 28 6b 65 79 73 2d 3e 76 61 6c 6c 69 73 74 20 6b  (keys->vallist k
78c0: 65 79 73 20 23 74 29 29 29 0a 09 20 20 20 20 20  eys #t)))..     
78d0: 20 28 70 72 6f 63 20 64 62 20 74 61 72 67 65 74   (proc db target
78e0: 20 72 75 6e 6e 61 6d 65 20 6b 65 79 73 20 6b 65   runname keys ke
78f0: 79 6e 61 6d 65 73 20 6b 65 79 76 61 6c 6c 73 74  ynames keyvallst
7900: 29 29 29 0a 09 28 69 66 20 74 68 31 20 28 74 68  )))..(if th1 (th
7910: 72 65 61 64 2d 6a 6f 69 6e 21 20 74 68 31 29 29  read-join! th1))
7920: 0a 09 28 73 71 6c 69 74 65 33 3a 66 69 6e 61 6c  ..(sqlite3:final
7930: 69 7a 65 21 20 64 62 29 0a 09 28 73 65 74 21 20  ize! db)..(set! 
7940: 2a 64 69 64 73 6f 6d 65 74 68 69 6e 67 2a 20 23  *didsomething* #
7950: 74 29 29 29 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d  t))))))..;;=====
7960: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7970: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7980: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7990: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
79a0: 3d 0a 3b 3b 20 52 6f 6c 6c 75 70 20 72 75 6e 73  =.;; Rollup runs
79b0: 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  .;;=============
79c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
79d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
79e0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
79f0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 55 70  =========..;; Up
7a00: 64 61 74 65 20 74 68 65 20 74 65 73 74 5f 6d 65  date the test_me
7a10: 74 61 20 74 61 62 6c 65 20 66 6f 72 20 74 68 69  ta table for thi
7a20: 73 20 74 65 73 74 0a 28 64 65 66 69 6e 65 20 28  s test.(define (
7a30: 72 75 6e 73 3a 75 70 64 61 74 65 2d 74 65 73 74  runs:update-test
7a40: 5f 6d 65 74 61 20 64 62 20 74 65 73 74 2d 6e 61  _meta db test-na
7a50: 6d 65 20 74 65 73 74 2d 63 6f 6e 66 29 0a 20 20  me test-conf).  
7a60: 28 6c 65 74 20 28 28 63 75 72 72 72 65 63 6f 72  (let ((currrecor
7a70: 64 20 28 64 62 3a 74 65 73 74 6d 65 74 61 2d 67  d (db:testmeta-g
7a80: 65 74 2d 72 65 63 6f 72 64 20 64 62 20 74 65 73  et-record db tes
7a90: 74 2d 6e 61 6d 65 29 29 29 0a 20 20 20 20 28 69  t-name))).    (i
7aa0: 66 20 28 6e 6f 74 20 63 75 72 72 72 65 63 6f 72  f (not currrecor
7ab0: 64 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 28 73  d)..(begin..  (s
7ac0: 65 74 21 20 63 75 72 72 72 65 63 6f 72 64 20 28  et! currrecord (
7ad0: 6d 61 6b 65 2d 76 65 63 74 6f 72 20 31 30 20 23  make-vector 10 #
7ae0: 66 29 29 0a 09 20 20 28 64 62 3a 74 65 73 74 6d  f))..  (db:testm
7af0: 65 74 61 2d 61 64 64 2d 72 65 63 6f 72 64 20 64  eta-add-record d
7b00: 62 20 74 65 73 74 2d 6e 61 6d 65 29 29 29 0a 20  b test-name))). 
7b10: 20 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 20     (for-each .  
7b20: 20 20 20 28 6c 61 6d 62 64 61 20 28 6b 65 79 29     (lambda (key)
7b30: 0a 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28 28  .       (let* ((
7b40: 69 64 78 20 28 63 61 64 72 20 6b 65 79 29 29 0a  idx (cadr key)).
7b50: 09 20 20 20 20 20 20 28 66 6c 64 20 28 63 61 72  .      (fld (car
7b60: 20 20 6b 65 79 29 29 0a 09 20 20 20 20 20 20 28    key))..      (
7b70: 76 61 6c 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b  val (config-look
7b80: 75 70 20 74 65 73 74 2d 63 6f 6e 66 20 22 74 65  up test-conf "te
7b90: 73 74 5f 6d 65 74 61 22 20 66 6c 64 29 29 29 0a  st_meta" fld))).
7ba0: 09 20 3b 3b 20 28 64 65 62 75 67 3a 70 72 69 6e  . ;; (debug:prin
7bb0: 74 20 35 20 22 69 64 78 3a 20 22 20 69 64 78 20  t 5 "idx: " idx 
7bc0: 22 20 66 6c 64 3a 20 22 20 66 6c 64 20 22 20 76  " fld: " fld " v
7bd0: 61 6c 3a 20 22 20 76 61 6c 29 0a 09 20 28 69 66  al: " val).. (if
7be0: 20 28 61 6e 64 20 76 61 6c 20 28 6e 6f 74 20 28   (and val (not (
7bf0: 65 71 75 61 6c 3f 20 28 76 65 63 74 6f 72 2d 72  equal? (vector-r
7c00: 65 66 20 63 75 72 72 72 65 63 6f 72 64 20 69 64  ef currrecord id
7c10: 78 29 20 76 61 6c 29 29 29 0a 09 20 20 20 20 20  x) val)))..     
7c20: 28 62 65 67 69 6e 0a 09 20 20 20 20 20 20 20 28  (begin..       (
7c30: 70 72 69 6e 74 20 22 55 70 64 61 74 69 6e 67 20  print "Updating 
7c40: 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 22 20  " test-name " " 
7c50: 66 6c 64 20 22 20 74 6f 20 22 20 76 61 6c 29 0a  fld " to " val).
7c60: 09 20 20 20 20 20 20 20 28 64 62 3a 74 65 73 74  .       (db:test
7c70: 6d 65 74 61 2d 75 70 64 61 74 65 2d 66 69 65 6c  meta-update-fiel
7c80: 64 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 20 66  d db test-name f
7c90: 6c 64 20 76 61 6c 29 29 29 29 29 0a 20 20 20 20  ld val))))).    
7ca0: 20 27 28 28 22 61 75 74 68 6f 72 22 20 32 29 28   '(("author" 2)(
7cb0: 22 6f 77 6e 65 72 22 20 33 29 28 22 64 65 73 63  "owner" 3)("desc
7cc0: 72 69 70 74 69 6f 6e 22 20 34 29 28 22 72 65 76  ription" 4)("rev
7cd0: 69 65 77 65 64 22 20 35 29 28 22 74 61 67 73 22  iewed" 5)("tags"
7ce0: 20 39 29 29 29 29 29 0a 0a 3b 3b 20 55 70 64 61   9)))))..;; Upda
7cf0: 74 65 20 74 65 73 74 5f 6d 65 74 61 20 66 6f 72  te test_meta for
7d00: 20 61 6c 6c 20 74 65 73 74 73 0a 28 64 65 66 69   all tests.(defi
7d10: 6e 65 20 28 72 75 6e 73 3a 75 70 64 61 74 65 2d  ne (runs:update-
7d20: 61 6c 6c 2d 74 65 73 74 5f 6d 65 74 61 20 64 62  all-test_meta db
7d30: 29 0a 20 20 28 6c 65 74 20 28 28 74 65 73 74 2d  ).  (let ((test-
7d40: 6e 61 6d 65 73 20 28 67 65 74 2d 61 6c 6c 2d 6c  names (get-all-l
7d50: 65 67 61 6c 2d 74 65 73 74 73 29 29 29 0a 20 20  egal-tests))).  
7d60: 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 20 20    (for-each .   
7d70: 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74 2d    (lambda (test-
7d80: 6e 61 6d 65 29 0a 20 20 20 20 20 20 20 28 6c 65  name).       (le
7d90: 74 2a 20 28 28 74 65 73 74 2d 70 61 74 68 20 20  t* ((test-path  
7da0: 20 20 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74 68    (conc *toppath
7db0: 2a 20 22 2f 74 65 73 74 73 2f 22 20 74 65 73 74  * "/tests/" test
7dc0: 2d 6e 61 6d 65 29 29 0a 09 20 20 20 20 20 20 28  -name))..      (
7dd0: 74 65 73 74 2d 63 6f 6e 66 69 67 66 20 28 63 6f  test-configf (co
7de0: 6e 63 20 74 65 73 74 2d 70 61 74 68 20 22 2f 74  nc test-path "/t
7df0: 65 73 74 63 6f 6e 66 69 67 22 29 29 0a 09 20 20  estconfig"))..  
7e00: 20 20 20 20 28 74 65 73 74 65 78 69 73 74 73 20      (testexists 
7e10: 20 20 28 61 6e 64 20 28 66 69 6c 65 2d 65 78 69    (and (file-exi
7e20: 73 74 73 3f 20 74 65 73 74 2d 63 6f 6e 66 69 67  sts? test-config
7e30: 66 29 28 66 69 6c 65 2d 72 65 61 64 2d 61 63 63  f)(file-read-acc
7e40: 65 73 73 3f 20 74 65 73 74 2d 63 6f 6e 66 69 67  ess? test-config
7e50: 66 29 29 29 0a 09 20 20 20 20 20 20 3b 3b 20 72  f)))..      ;; r
7e60: 65 61 64 20 63 6f 6e 66 69 67 73 20 77 69 74 68  ead configs with
7e70: 20 74 72 69 63 6b 73 20 74 75 72 6e 65 64 20 6f   tricks turned o
7e80: 66 66 20 28 69 2e 65 2e 20 6e 6f 20 73 79 73 74  ff (i.e. no syst
7e90: 65 6d 29 0a 09 20 20 20 20 20 20 28 74 65 73 74  em)..      (test
7ea0: 2d 63 6f 6e 66 20 20 20 20 28 69 66 20 74 65 73  -conf    (if tes
7eb0: 74 65 78 69 73 74 73 20 28 72 65 61 64 2d 63 6f  texists (read-co
7ec0: 6e 66 69 67 20 74 65 73 74 2d 63 6f 6e 66 69 67  nfig test-config
7ed0: 66 20 23 66 20 23 66 29 28 6d 61 6b 65 2d 68 61  f #f #f)(make-ha
7ee0: 73 68 2d 74 61 62 6c 65 29 29 29 29 0a 09 20 28  sh-table)))).. (
7ef0: 72 75 6e 73 3a 75 70 64 61 74 65 2d 74 65 73 74  runs:update-test
7f00: 5f 6d 65 74 61 20 64 62 20 74 65 73 74 2d 6e 61  _meta db test-na
7f10: 6d 65 20 74 65 73 74 2d 63 6f 6e 66 29 29 29 0a  me test-conf))).
7f20: 20 20 20 20 20 74 65 73 74 2d 6e 61 6d 65 73 29       test-names)
7f30: 29 29 0a 0a 3b 3b 20 54 68 69 73 20 63 6f 75 6c  ))..;; This coul
7f40: 64 20 70 72 6f 62 61 62 6c 79 20 62 65 20 72 65  d probably be re
7f50: 66 61 63 74 6f 72 65 64 20 69 6e 74 6f 20 6f 6e  factored into on
7f60: 65 20 63 6f 6d 70 6c 65 78 20 71 75 65 72 79 20  e complex query 
7f70: 2e 2e 2e 0a 28 64 65 66 69 6e 65 20 28 72 75 6e  ....(define (run
7f80: 73 3a 72 6f 6c 6c 75 70 2d 72 75 6e 20 64 62 20  s:rollup-run db 
7f90: 6b 65 79 73 20 6b 65 79 76 61 6c 6c 73 74 20 72  keys keyvallst r
7fa0: 75 6e 6e 61 6d 65 20 75 73 65 72 29 20 3b 3b 20  unname user) ;; 
7fb0: 77 61 73 20 74 61 72 67 65 74 2c 20 6e 6f 77 20  was target, now 
7fc0: 6b 65 79 76 61 6c 6c 73 74 0a 20 20 28 64 65 62  keyvallst.  (deb
7fd0: 75 67 3a 70 72 69 6e 74 20 34 20 22 72 75 6e 73  ug:print 4 "runs
7fe0: 3a 72 6f 6c 6c 75 70 2d 72 75 6e 2c 20 6b 65 79  :rollup-run, key
7ff0: 73 3a 20 22 20 6b 65 79 73 20 22 20 6b 65 79 76  s: " keys " keyv
8000: 61 6c 6c 73 74 3a 20 22 20 6b 65 79 76 61 6c 6c  allst: " keyvall
8010: 73 74 20 22 20 3a 72 75 6e 6e 61 6d 65 20 22 20  st " :runname " 
8020: 72 75 6e 6e 61 6d 65 20 22 20 75 73 65 72 3a 20  runname " user: 
8030: 22 20 75 73 65 72 29 0a 20 20 28 6c 65 74 2a 20  " user).  (let* 
8040: 28 3b 20 28 6b 65 79 76 61 6c 6c 6c 73 74 20 20  (; (keyvalllst  
8050: 20 20 20 20 28 6b 65 79 73 3a 74 61 72 67 65 74      (keys:target
8060: 2d 3e 6b 65 79 76 61 6c 20 6b 65 79 73 20 74 61  ->keyval keys ta
8070: 72 67 65 74 29 29 0a 09 20 28 6e 65 77 2d 72 75  rget)).. (new-ru
8080: 6e 2d 69 64 20 20 20 20 20 20 28 72 75 6e 73 3a  n-id      (runs:
8090: 72 65 67 69 73 74 65 72 2d 72 75 6e 20 64 62 20  register-run db 
80a0: 6b 65 79 73 20 6b 65 79 76 61 6c 6c 73 74 20 72  keys keyvallst r
80b0: 75 6e 6e 61 6d 65 20 22 6e 65 77 22 20 22 6e 2f  unname "new" "n/
80c0: 61 22 20 75 73 65 72 29 29 0a 09 20 28 70 72 65  a" user)).. (pre
80d0: 76 2d 74 65 73 74 73 20 20 20 20 20 20 28 74 65  v-tests      (te
80e0: 73 74 3a 67 65 74 2d 6d 61 74 63 68 69 6e 67 2d  st:get-matching-
80f0: 70 72 65 76 69 6f 75 73 2d 74 65 73 74 2d 72 75  previous-test-ru
8100: 6e 2d 72 65 63 6f 72 64 73 20 64 62 20 6e 65 77  n-records db new
8110: 2d 72 75 6e 2d 69 64 20 22 25 22 20 22 25 22 29  -run-id "%" "%")
8120: 29 0a 09 20 28 63 75 72 72 2d 74 65 73 74 73 20  ).. (curr-tests 
8130: 20 20 20 20 20 28 72 64 62 3a 67 65 74 2d 74 65       (rdb:get-te
8140: 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 6e  sts-for-run db n
8150: 65 77 2d 72 75 6e 2d 69 64 20 22 25 22 20 22 25  ew-run-id "%" "%
8160: 22 20 27 28 29 20 27 28 29 29 29 0a 09 20 28 63  " '() '())).. (c
8170: 75 72 72 2d 74 65 73 74 73 2d 68 61 73 68 20 28  urr-tests-hash (
8180: 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 29  make-hash-table)
8190: 29 29 0a 20 20 20 20 28 64 62 3a 75 70 64 61 74  )).    (db:updat
81a0: 65 2d 72 75 6e 2d 65 76 65 6e 74 5f 74 69 6d 65  e-run-event_time
81b0: 20 64 62 20 6e 65 77 2d 72 75 6e 2d 69 64 29 0a   db new-run-id).
81c0: 20 20 20 20 3b 3b 20 69 6e 64 65 78 20 74 68 65      ;; index the
81d0: 20 61 6c 72 65 61 64 79 20 73 61 76 65 64 20 74   already saved t
81e0: 65 73 74 73 20 62 79 20 74 65 73 74 6e 61 6d 65  ests by testname
81f0: 20 61 6e 64 20 69 74 65 6d 64 61 74 20 69 6e 20   and itemdat in 
8200: 63 75 72 72 2d 74 65 73 74 73 2d 68 61 73 68 0a  curr-tests-hash.
8210: 20 20 20 20 28 66 6f 72 2d 65 61 63 68 0a 20 20      (for-each.  
8220: 20 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74     (lambda (test
8230: 64 61 74 29 0a 20 20 20 20 20 20 20 28 6c 65 74  dat).       (let
8240: 2a 20 28 28 74 65 73 74 6e 61 6d 65 20 20 28 64  * ((testname  (d
8250: 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e  b:test-get-testn
8260: 61 6d 65 20 74 65 73 74 64 61 74 29 29 0a 09 20  ame testdat)).. 
8270: 20 20 20 20 20 28 69 74 65 6d 2d 70 61 74 68 20       (item-path 
8280: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65  (db:test-get-ite
8290: 6d 2d 70 61 74 68 20 74 65 73 74 64 61 74 29 29  m-path testdat))
82a0: 0a 09 20 20 20 20 20 20 28 66 75 6c 6c 2d 6e 61  ..      (full-na
82b0: 6d 65 20 28 63 6f 6e 63 20 74 65 73 74 6e 61 6d  me (conc testnam
82c0: 65 20 22 2f 22 20 69 74 65 6d 2d 70 61 74 68 29  e "/" item-path)
82d0: 29 29 0a 09 20 28 68 61 73 68 2d 74 61 62 6c 65  )).. (hash-table
82e0: 2d 73 65 74 21 20 63 75 72 72 2d 74 65 73 74 73  -set! curr-tests
82f0: 2d 68 61 73 68 20 66 75 6c 6c 2d 6e 61 6d 65 20  -hash full-name 
8300: 74 65 73 74 64 61 74 29 29 29 0a 20 20 20 20 20  testdat))).     
8310: 63 75 72 72 2d 74 65 73 74 73 29 0a 20 20 20 20  curr-tests).    
8320: 3b 3b 20 4e 4f 50 45 3a 20 4e 6f 6e 2d 6f 70 74  ;; NOPE: Non-opt
8330: 69 6d 61 6c 20 61 70 70 72 6f 61 63 68 2e 20 54  imal approach. T
8340: 72 79 20 74 68 69 73 20 69 6e 73 74 65 61 64 2e  ry this instead.
8350: 0a 20 20 20 20 3b 3b 20 20 20 31 2e 20 74 65 73  .    ;;   1. tes
8360: 74 73 20 61 72 65 20 72 65 63 65 69 76 65 64 20  ts are received 
8370: 69 6e 20 61 20 6c 69 73 74 2c 20 6d 6f 73 74 20  in a list, most 
8380: 72 65 63 65 6e 74 20 66 69 72 73 74 0a 20 20 20  recent first.   
8390: 20 3b 3b 20 20 20 32 2e 20 72 65 70 6c 61 63 65   ;;   2. replace
83a0: 20 74 68 65 20 72 6f 6c 6c 75 70 20 74 65 73 74   the rollup test
83b0: 20 77 69 74 68 20 74 68 65 20 6e 65 77 20 2a 61   with the new *a
83c0: 6c 77 61 79 73 2a 0a 20 20 20 20 28 66 6f 72 2d  lways*.    (for-
83d0: 65 61 63 68 20 0a 20 20 20 20 20 28 6c 61 6d 62  each .     (lamb
83e0: 64 61 20 28 74 65 73 74 64 61 74 29 0a 20 20 20  da (testdat).   
83f0: 20 20 20 20 28 6c 65 74 2a 20 28 28 74 65 73 74      (let* ((test
8400: 6e 61 6d 65 20 20 28 64 62 3a 74 65 73 74 2d 67  name  (db:test-g
8410: 65 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74  et-testname test
8420: 64 61 74 29 29 0a 09 20 20 20 20 20 20 28 69 74  dat))..      (it
8430: 65 6d 2d 70 61 74 68 20 28 64 62 3a 74 65 73 74  em-path (db:test
8440: 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74  -get-item-path t
8450: 65 73 74 64 61 74 29 29 0a 09 20 20 20 20 20 20  estdat))..      
8460: 28 66 75 6c 6c 2d 6e 61 6d 65 20 28 63 6f 6e 63  (full-name (conc
8470: 20 74 65 73 74 6e 61 6d 65 20 22 2f 22 20 69 74   testname "/" it
8480: 65 6d 2d 70 61 74 68 29 29 0a 09 20 20 20 20 20  em-path))..     
8490: 20 28 70 72 65 76 2d 74 65 73 74 2d 64 61 74 20   (prev-test-dat 
84a0: 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f  (hash-table-ref/
84b0: 64 65 66 61 75 6c 74 20 63 75 72 72 2d 74 65 73  default curr-tes
84c0: 74 73 2d 68 61 73 68 20 66 75 6c 6c 2d 6e 61 6d  ts-hash full-nam
84d0: 65 20 23 66 29 29 0a 09 20 20 20 20 20 20 28 74  e #f))..      (t
84e0: 65 73 74 2d 73 74 65 70 73 20 20 20 20 20 20 28  est-steps      (
84f0: 64 62 3a 67 65 74 2d 73 74 65 70 73 2d 66 6f 72  db:get-steps-for
8500: 2d 74 65 73 74 20 64 62 20 28 64 62 3a 74 65 73  -test db (db:tes
8510: 74 2d 67 65 74 2d 69 64 20 74 65 73 74 64 61 74  t-get-id testdat
8520: 29 29 29 0a 09 20 20 20 20 20 20 28 6e 65 77 2d  )))..      (new-
8530: 74 65 73 74 2d 72 65 63 6f 72 64 20 23 66 29 29  test-record #f))
8540: 0a 09 20 3b 3b 20 72 65 70 6c 61 63 65 20 74 68  .. ;; replace th
8550: 65 73 65 20 77 69 74 68 20 69 6e 73 65 72 74 20  ese with insert 
8560: 2e 2e 2e 20 73 65 6c 65 63 74 0a 09 20 28 61 70  ... select.. (ap
8570: 70 6c 79 20 73 71 6c 69 74 65 33 3a 65 78 65 63  ply sqlite3:exec
8580: 75 74 65 20 0a 09 09 64 62 20 0a 09 09 28 63 6f  ute ...db ...(co
8590: 6e 63 20 22 49 4e 53 45 52 54 20 4f 52 20 52 45  nc "INSERT OR RE
85a0: 50 4c 41 43 45 20 49 4e 54 4f 20 74 65 73 74 73  PLACE INTO tests
85b0: 20 28 72 75 6e 5f 69 64 2c 74 65 73 74 6e 61 6d   (run_id,testnam
85c0: 65 2c 73 74 61 74 65 2c 73 74 61 74 75 73 2c 65  e,state,status,e
85d0: 76 65 6e 74 5f 74 69 6d 65 2c 68 6f 73 74 2c 63  vent_time,host,c
85e0: 70 75 6c 6f 61 64 2c 64 69 73 6b 66 72 65 65 2c  puload,diskfree,
85f0: 75 6e 61 6d 65 2c 72 75 6e 64 69 72 2c 69 74 65  uname,rundir,ite
8600: 6d 5f 70 61 74 68 2c 72 75 6e 5f 64 75 72 61 74  m_path,run_durat
8610: 69 6f 6e 2c 66 69 6e 61 6c 5f 6c 6f 67 66 2c 63  ion,final_logf,c
8620: 6f 6d 6d 65 6e 74 29 20 22 0a 09 09 20 20 20 20  omment) "...    
8630: 20 20 22 56 41 4c 55 45 53 20 28 3f 2c 3f 2c 3f    "VALUES (?,?,?
8640: 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f  ,?,?,?,?,?,?,?,?
8650: 2c 3f 2c 3f 2c 3f 29 3b 22 29 0a 09 09 6e 65 77  ,?,?,?);")...new
8660: 2d 72 75 6e 2d 69 64 20 28 63 64 64 72 20 28 76  -run-id (cddr (v
8670: 65 63 74 6f 72 2d 3e 6c 69 73 74 20 74 65 73 74  ector->list test
8680: 64 61 74 29 29 29 0a 09 20 28 73 65 74 21 20 6e  dat))).. (set! n
8690: 65 77 2d 74 65 73 74 64 61 74 20 28 63 61 72 20  ew-testdat (car 
86a0: 28 72 64 62 3a 67 65 74 2d 74 65 73 74 73 2d 66  (rdb:get-tests-f
86b0: 6f 72 2d 72 75 6e 20 64 62 20 6e 65 77 2d 72 75  or-run db new-ru
86c0: 6e 2d 69 64 20 74 65 73 74 6e 61 6d 65 20 69 74  n-id testname it
86d0: 65 6d 2d 70 61 74 68 20 27 28 29 20 27 28 29 29  em-path '() '())
86e0: 29 29 0a 09 20 28 68 61 73 68 2d 74 61 62 6c 65  )).. (hash-table
86f0: 2d 73 65 74 21 20 63 75 72 72 2d 74 65 73 74 73  -set! curr-tests
8700: 2d 68 61 73 68 20 66 75 6c 6c 2d 6e 61 6d 65 20  -hash full-name 
8710: 6e 65 77 2d 74 65 73 74 64 61 74 29 20 3b 3b 20  new-testdat) ;; 
8720: 74 68 69 73 20 63 6f 75 6c 64 20 62 65 20 63 6f  this could be co
8730: 6e 66 75 73 69 6e 67 2c 20 77 68 69 63 68 20 72  nfusing, which r
8740: 65 63 6f 72 64 20 73 68 6f 75 6c 64 20 67 6f 20  ecord should go 
8750: 69 6e 74 6f 20 74 68 65 20 6c 6f 6f 6b 75 70 20  into the lookup 
8760: 74 61 62 6c 65 3f 0a 09 20 3b 3b 20 4e 6f 77 20  table?.. ;; Now 
8770: 64 75 70 6c 69 63 61 74 65 20 74 68 65 20 74 65  duplicate the te
8780: 73 74 20 73 74 65 70 73 0a 09 20 28 64 65 62 75  st steps.. (debu
8790: 67 3a 70 72 69 6e 74 20 34 20 22 43 6f 70 79 69  g:print 4 "Copyi
87a0: 6e 67 20 72 65 63 6f 72 64 73 20 69 6e 20 74 65  ng records in te
87b0: 73 74 5f 73 74 65 70 73 20 66 72 6f 6d 20 74 65  st_steps from te
87c0: 73 74 5f 69 64 3d 22 20 28 64 62 3a 74 65 73 74  st_id=" (db:test
87d0: 2d 67 65 74 2d 69 64 20 74 65 73 74 64 61 74 29  -get-id testdat)
87e0: 20 22 20 74 6f 20 22 20 28 64 62 3a 74 65 73 74   " to " (db:test
87f0: 2d 67 65 74 2d 69 64 20 6e 65 77 2d 74 65 73 74  -get-id new-test
8800: 64 61 74 29 29 0a 09 20 28 73 71 6c 69 74 65 33  dat)).. (sqlite3
8810: 3a 65 78 65 63 75 74 65 20 0a 09 20 20 64 62 20  :execute ..  db 
8820: 0a 09 20 20 28 63 6f 6e 63 20 22 49 4e 53 45 52  ..  (conc "INSER
8830: 54 20 4f 52 20 52 45 50 4c 41 43 45 20 49 4e 54  T OR REPLACE INT
8840: 4f 20 74 65 73 74 5f 73 74 65 70 73 20 28 74 65  O test_steps (te
8850: 73 74 5f 69 64 2c 73 74 65 70 6e 61 6d 65 2c 73  st_id,stepname,s
8860: 74 61 74 65 2c 73 74 61 74 75 73 2c 65 76 65 6e  tate,status,even
8870: 74 5f 74 69 6d 65 2c 63 6f 6d 6d 65 6e 74 29 20  t_time,comment) 
8880: 22 0a 09 09 22 53 45 4c 45 43 54 20 22 20 28 64  "..."SELECT " (d
8890: 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 6e 65  b:test-get-id ne
88a0: 77 2d 74 65 73 74 64 61 74 29 20 22 2c 73 74 65  w-testdat) ",ste
88b0: 70 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 61 74  pname,state,stat
88c0: 75 73 2c 65 76 65 6e 74 5f 74 69 6d 65 2c 63 6f  us,event_time,co
88d0: 6d 6d 65 6e 74 20 46 52 4f 4d 20 74 65 73 74 5f  mment FROM test_
88e0: 73 74 65 70 73 20 57 48 45 52 45 20 74 65 73 74  steps WHERE test
88f0: 5f 69 64 3d 3f 3b 22 29 0a 09 20 20 28 64 62 3a  _id=?;")..  (db:
8900: 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74  test-get-id test
8910: 64 61 74 29 29 0a 09 20 3b 3b 20 4e 6f 77 20 64  dat)).. ;; Now d
8920: 75 70 6c 69 63 61 74 65 20 74 68 65 20 74 65 73  uplicate the tes
8930: 74 20 64 61 74 61 0a 09 20 28 64 65 62 75 67 3a  t data.. (debug:
8940: 70 72 69 6e 74 20 34 20 22 43 6f 70 79 69 6e 67  print 4 "Copying
8950: 20 72 65 63 6f 72 64 73 20 69 6e 20 74 65 73 74   records in test
8960: 5f 64 61 74 61 20 66 72 6f 6d 20 74 65 73 74 5f  _data from test_
8970: 69 64 3d 22 20 28 64 62 3a 74 65 73 74 2d 67 65  id=" (db:test-ge
8980: 74 2d 69 64 20 74 65 73 74 64 61 74 29 20 22 20  t-id testdat) " 
8990: 74 6f 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65  to " (db:test-ge
89a0: 74 2d 69 64 20 6e 65 77 2d 74 65 73 74 64 61 74  t-id new-testdat
89b0: 29 29 0a 09 20 28 73 71 6c 69 74 65 33 3a 65 78  )).. (sqlite3:ex
89c0: 65 63 75 74 65 20 0a 09 20 20 64 62 20 0a 09 20  ecute ..  db .. 
89d0: 20 28 63 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f   (conc "INSERT O
89e0: 52 20 52 45 50 4c 41 43 45 20 49 4e 54 4f 20 74  R REPLACE INTO t
89f0: 65 73 74 5f 64 61 74 61 20 28 74 65 73 74 5f 69  est_data (test_i
8a00: 64 2c 63 61 74 65 67 6f 72 79 2c 76 61 72 69 61  d,category,varia
8a10: 62 6c 65 2c 76 61 6c 75 65 2c 65 78 70 65 63 74  ble,value,expect
8a20: 65 64 2c 74 6f 6c 2c 75 6e 69 74 73 2c 63 6f 6d  ed,tol,units,com
8a30: 6d 65 6e 74 29 20 22 0a 09 09 22 53 45 4c 45 43  ment) "..."SELEC
8a40: 54 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74  T " (db:test-get
8a50: 2d 69 64 20 6e 65 77 2d 74 65 73 74 64 61 74 29  -id new-testdat)
8a60: 20 22 2c 63 61 74 65 67 6f 72 79 2c 76 61 72 69   ",category,vari
8a70: 61 62 6c 65 2c 76 61 6c 75 65 2c 65 78 70 65 63  able,value,expec
8a80: 74 65 64 2c 74 6f 6c 2c 75 6e 69 74 73 2c 63 6f  ted,tol,units,co
8a90: 6d 6d 65 6e 74 20 46 52 4f 4d 20 74 65 73 74 5f  mment FROM test_
8aa0: 64 61 74 61 20 57 48 45 52 45 20 74 65 73 74 5f  data WHERE test_
8ab0: 69 64 3d 3f 3b 22 29 0a 09 20 20 28 64 62 3a 74  id=?;")..  (db:t
8ac0: 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74 64  est-get-id testd
8ad0: 61 74 29 29 0a 09 20 29 29 0a 20 20 20 20 20 70  at)).. )).     p
8ae0: 72 65 76 2d 74 65 73 74 73 29 29 29 0a 09 20 0a  rev-tests))).. .
8af0: 20 20 20 20 20 0a                                     .