Megatest

Hex Artifact Content
Login

Artifact 0beb742b485c8783e62b7478200bb2af7e400d66:


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 20 70 6f 73 69 78 2d 65  srfi 18) posix-e
01d0: 78 74 72 61 73 20 64 69 72 65 63 74 6f 72 79 2d  xtras directory-
01e0: 75 74 69 6c 73 29 0a 28 69 6d 70 6f 72 74 20 28  utils).(import (
01f0: 70 72 65 66 69 78 20 73 71 6c 69 74 65 33 20 73  prefix sqlite3 s
0200: 71 6c 69 74 65 33 3a 29 29 0a 0a 28 64 65 63 6c  qlite3:))..(decl
0210: 61 72 65 20 28 75 6e 69 74 20 72 75 6e 73 29 29  are (unit runs))
0220: 0a 28 64 65 63 6c 61 72 65 20 28 75 73 65 73 20  .(declare (uses 
0230: 64 62 29 29 0a 28 64 65 63 6c 61 72 65 20 28 75  db)).(declare (u
0240: 73 65 73 20 63 6f 6d 6d 6f 6e 29 29 0a 28 64 65  ses common)).(de
0250: 63 6c 61 72 65 20 28 75 73 65 73 20 69 74 65 6d  clare (uses item
0260: 73 29 29 0a 28 64 65 63 6c 61 72 65 20 28 75 73  s)).(declare (us
0270: 65 73 20 72 75 6e 63 6f 6e 66 69 67 29 29 0a 28  es runconfig)).(
0280: 64 65 63 6c 61 72 65 20 28 75 73 65 73 20 74 65  declare (uses te
0290: 73 74 73 29 29 0a 28 64 65 63 6c 61 72 65 20 28  sts)).(declare (
02a0: 75 73 65 73 20 73 65 72 76 65 72 29 29 0a 0a 28  uses server))..(
02b0: 69 6e 63 6c 75 64 65 20 22 63 6f 6d 6d 6f 6e 5f  include "common_
02c0: 72 65 63 6f 72 64 73 2e 73 63 6d 22 29 0a 28 69  records.scm").(i
02d0: 6e 63 6c 75 64 65 20 22 6b 65 79 5f 72 65 63 6f  nclude "key_reco
02e0: 72 64 73 2e 73 63 6d 22 29 0a 28 69 6e 63 6c 75  rds.scm").(inclu
02f0: 64 65 20 22 64 62 5f 72 65 63 6f 72 64 73 2e 73  de "db_records.s
0300: 63 6d 22 29 0a 28 69 6e 63 6c 75 64 65 20 22 72  cm").(include "r
0310: 75 6e 5f 72 65 63 6f 72 64 73 2e 73 63 6d 22 29  un_records.scm")
0320: 0a 28 69 6e 63 6c 75 64 65 20 22 74 65 73 74 5f  .(include "test_
0330: 72 65 63 6f 72 64 73 2e 73 63 6d 22 29 0a 0a 3b  records.scm")..;
0340: 3b 20 72 75 6e 73 3a 67 65 74 2d 72 75 6e 73 2d  ; runs:get-runs-
0350: 62 79 2d 70 61 74 74 0a 3b 3b 20 67 65 74 20 72  by-patt.;; get r
0360: 75 6e 73 20 62 79 20 6c 69 73 74 20 6f 66 20 63  uns by list of c
0370: 72 69 74 65 72 69 61 0a 3b 3b 20 72 65 67 69 73  riteria.;; regis
0380: 74 65 72 20 61 20 74 65 73 74 20 72 75 6e 20 77  ter a test run w
0390: 69 74 68 20 74 68 65 20 64 62 0a 3b 3b 0a 3b 3b  ith the db.;;.;;
03a0: 20 55 73 65 3a 20 28 64 62 2d 67 65 74 2d 76 61   Use: (db-get-va
03b0: 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 28 64  lue-by-header (d
03c0: 62 3a 67 65 74 2d 68 65 61 64 65 72 20 72 75 6e  b:get-header run
03d0: 69 6e 66 6f 29 28 64 62 3a 67 65 74 2d 72 6f 77  info)(db:get-row
03e0: 20 72 75 6e 69 6e 66 6f 29 29 0a 3b 3b 20 20 74   runinfo)).;;  t
03f0: 6f 20 65 78 74 72 61 63 74 20 69 6e 66 6f 20 66  o extract info f
0400: 72 6f 6d 20 74 68 65 20 73 74 72 75 63 74 75 72  rom the structur
0410: 65 20 72 65 74 75 72 6e 65 64 0a 3b 3b 0a 28 64  e returned.;;.(d
0420: 65 66 69 6e 65 20 28 72 75 6e 73 3a 67 65 74 2d  efine (runs:get-
0430: 72 75 6e 73 2d 62 79 2d 70 61 74 74 20 64 62 20  runs-by-patt db 
0440: 6b 65 79 73 20 72 75 6e 6e 61 6d 65 70 61 74 74  keys runnamepatt
0450: 20 2e 20 70 61 72 61 6d 73 29 20 3b 3b 20 74 65   . params) ;; te
0460: 73 74 2d 6e 61 6d 65 29 0a 20 20 28 6c 65 74 2a  st-name).  (let*
0470: 20 28 28 6b 65 79 76 61 6c 6c 73 74 20 28 6b 65   ((keyvallst (ke
0480: 79 73 2d 3e 76 61 6c 6c 69 73 74 20 6b 65 79 73  ys->vallist keys
0490: 29 29 0a 09 20 28 74 6d 70 20 20 20 20 20 20 28  )).. (tmp      (
04a0: 72 75 6e 73 3a 67 65 74 2d 73 74 64 2d 72 75 6e  runs:get-std-run
04b0: 2d 66 69 65 6c 64 73 20 6b 65 79 73 20 27 28 22  -fields keys '("
04c0: 69 64 22 20 22 72 75 6e 6e 61 6d 65 22 20 22 73  id" "runname" "s
04d0: 74 61 74 65 22 20 22 73 74 61 74 75 73 22 20 22  tate" "status" "
04e0: 6f 77 6e 65 72 22 20 22 65 76 65 6e 74 5f 74 69  owner" "event_ti
04f0: 6d 65 22 29 29 29 0a 09 20 28 6b 65 79 73 74 72  me"))).. (keystr
0500: 20 20 20 28 63 61 72 20 74 6d 70 29 29 0a 09 20     (car tmp)).. 
0510: 28 68 65 61 64 65 72 20 20 20 28 63 61 64 72 20  (header   (cadr 
0520: 74 6d 70 29 29 0a 09 20 28 72 65 73 20 20 20 20  tmp)).. (res    
0530: 20 27 28 29 29 0a 09 20 28 6b 65 79 2d 70 61 74   '()).. (key-pat
0540: 74 20 22 22 29 29 0a 20 20 20 20 28 66 6f 72 2d  t "")).    (for-
0550: 65 61 63 68 20 28 6c 61 6d 62 64 61 20 28 6b 65  each (lambda (ke
0560: 79 76 61 6c 29 0a 09 09 28 6c 65 74 2a 20 28 28  yval)...(let* ((
0570: 6b 65 79 20 20 20 20 28 76 65 63 74 6f 72 2d 72  key    (vector-r
0580: 65 66 20 6b 65 79 76 61 6c 20 30 29 29 0a 09 09  ef keyval 0))...
0590: 20 20 20 20 20 20 20 28 66 75 6c 6b 65 79 20 28         (fulkey (
05a0: 63 6f 6e 63 20 22 3a 22 20 6b 65 79 29 29 0a 09  conc ":" key))..
05b0: 09 20 20 20 20 20 20 20 28 70 61 74 74 20 20 20  .       (patt   
05c0: 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 66 75  (args:get-arg fu
05d0: 6c 6b 65 79 29 29 29 0a 09 09 20 20 28 69 66 20  lkey)))...  (if 
05e0: 70 61 74 74 0a 09 09 20 20 20 20 20 20 28 73 65  patt...      (se
05f0: 74 21 20 6b 65 79 2d 70 61 74 74 20 28 63 6f 6e  t! key-patt (con
0600: 63 20 6b 65 79 2d 70 61 74 74 20 22 20 41 4e 44  c key-patt " AND
0610: 20 22 20 6b 65 79 20 22 20 6c 69 6b 65 20 27 22   " key " like '"
0620: 20 70 61 74 74 20 22 27 22 29 29 0a 09 09 20 20   patt "'"))...  
0630: 20 20 20 20 28 62 65 67 69 6e 0a 09 09 09 28 64      (begin....(d
0640: 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52  ebug:print 0 "ER
0650: 52 4f 52 3a 20 73 65 61 72 63 68 69 6e 67 20 66  ROR: searching f
0660: 6f 72 20 72 75 6e 73 20 77 69 74 68 20 6e 6f 20  or runs with no 
0670: 70 61 74 74 65 72 6e 20 73 65 74 20 66 6f 72 20  pattern set for 
0680: 22 20 66 75 6c 6b 65 79 29 0a 09 09 09 28 65 78  " fulkey)....(ex
0690: 69 74 20 36 29 29 29 29 29 0a 09 20 20 20 20 20  it 6)))))..     
06a0: 20 6b 65 79 73 29 0a 20 20 20 20 28 73 71 6c 69   keys).    (sqli
06b0: 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77  te3:for-each-row
06c0: 20 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28   .     (lambda (
06d0: 61 20 2e 20 72 29 0a 20 20 20 20 20 20 20 28 73  a . r).       (s
06e0: 65 74 21 20 72 65 73 20 28 63 6f 6e 73 20 28 6c  et! res (cons (l
06f0: 69 73 74 2d 3e 76 65 63 74 6f 72 20 28 63 6f 6e  ist->vector (con
0700: 73 20 61 20 72 29 29 20 72 65 73 29 29 29 0a 20  s a r)) res))). 
0710: 20 20 20 20 64 62 20 0a 20 20 20 20 20 28 63 6f      db .     (co
0720: 6e 63 20 22 53 45 4c 45 43 54 20 22 20 6b 65 79  nc "SELECT " key
0730: 73 74 72 20 22 20 46 52 4f 4d 20 72 75 6e 73 20  str " FROM runs 
0740: 57 48 45 52 45 20 72 75 6e 6e 61 6d 65 20 6c 69  WHERE runname li
0750: 6b 65 20 3f 20 22 20 6b 65 79 2d 70 61 74 74 20  ke ? " key-patt 
0760: 22 3b 22 29 0a 20 20 20 20 20 72 75 6e 6e 61 6d  ";").     runnam
0770: 65 70 61 74 74 29 0a 20 20 20 20 28 76 65 63 74  epatt).    (vect
0780: 6f 72 20 68 65 61 64 65 72 20 72 65 73 29 29 29  or header res)))
0790: 0a 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a  ..(define (runs:
07a0: 74 65 73 74 2d 67 65 74 2d 66 75 6c 6c 2d 70 61  test-get-full-pa
07b0: 74 68 20 74 65 73 74 29 0a 20 20 28 6c 65 74 2a  th test).  (let*
07c0: 20 28 28 74 65 73 74 6e 61 6d 65 20 28 64 62 3a   ((testname (db:
07d0: 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d  test-get-testnam
07e0: 65 20 20 20 74 65 73 74 29 29 0a 09 20 28 69 74  e   test)).. (it
07f0: 65 6d 70 61 74 68 20 28 64 62 3a 74 65 73 74 2d  empath (db:test-
0800: 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74 65  get-item-path te
0810: 73 74 29 29 29 0a 20 20 20 20 28 63 6f 6e 63 20  st))).    (conc 
0820: 74 65 73 74 6e 61 6d 65 20 28 69 66 20 28 65 71  testname (if (eq
0830: 75 61 6c 3f 20 69 74 65 6d 70 61 74 68 20 22 22  ual? itempath ""
0840: 29 20 22 22 20 28 63 6f 6e 63 20 22 28 22 20 69  ) "" (conc "(" i
0850: 74 65 6d 70 61 74 68 20 22 29 22 29 29 29 29 29  tempath ")")))))
0860: 0a 0a 3b 3b 20 41 77 66 75 6c 2e 20 50 6c 65 61  ..;; Awful. Plea
0870: 73 65 20 46 49 58 4d 45 0a 28 64 65 66 69 6e 65  se FIXME.(define
0880: 20 2a 65 6e 76 2d 76 61 72 73 2d 62 79 2d 72 75   *env-vars-by-ru
0890: 6e 2d 69 64 2a 20 28 6d 61 6b 65 2d 68 61 73 68  n-id* (make-hash
08a0: 2d 74 61 62 6c 65 29 29 0a 28 64 65 66 69 6e 65  -table)).(define
08b0: 20 2a 63 75 72 72 65 6e 74 2d 72 75 6e 2d 6e 61   *current-run-na
08c0: 6d 65 2a 20 20 20 23 66 29 0a 0a 28 64 65 66 69  me*   #f)..(defi
08d0: 6e 65 20 28 73 65 74 2d 6d 65 67 61 74 65 73 74  ne (set-megatest
08e0: 2d 65 6e 76 2d 76 61 72 73 20 64 62 20 72 75 6e  -env-vars db run
08f0: 2d 69 64 29 0a 20 20 28 6c 65 74 20 28 28 6b 65  -id).  (let ((ke
0900: 79 73 20 28 64 62 3a 67 65 74 2d 6b 65 79 73 20  ys (db:get-keys 
0910: 64 62 29 29 0a 09 28 76 61 6c 73 20 28 68 61 73  db))..(vals (has
0920: 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61  h-table-ref/defa
0930: 75 6c 74 20 2a 65 6e 76 2d 76 61 72 73 2d 62 79  ult *env-vars-by
0940: 2d 72 75 6e 2d 69 64 2a 20 72 75 6e 2d 69 64 20  -run-id* run-id 
0950: 23 66 29 29 29 0a 20 20 20 20 3b 3b 20 67 65 74  #f))).    ;; get
0960: 20 74 68 65 20 69 6e 66 6f 20 66 72 6f 6d 20 74   the info from t
0970: 68 65 20 64 62 20 61 6e 64 20 70 75 74 20 69 74  he db and put it
0980: 20 69 6e 20 74 68 65 20 63 61 63 68 65 0a 20 20   in the cache.  
0990: 20 20 28 69 66 20 28 6e 6f 74 20 76 61 6c 73 29    (if (not vals)
09a0: 0a 09 28 6c 65 74 20 28 28 68 74 20 28 6d 61 6b  ..(let ((ht (mak
09b0: 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29 29 0a  e-hash-table))).
09c0: 09 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73  .  (hash-table-s
09d0: 65 74 21 20 2a 65 6e 76 2d 76 61 72 73 2d 62 79  et! *env-vars-by
09e0: 2d 72 75 6e 2d 69 64 2a 20 72 75 6e 2d 69 64 20  -run-id* run-id 
09f0: 68 74 29 0a 09 20 20 28 73 65 74 21 20 76 61 6c  ht)..  (set! val
0a00: 73 20 68 74 29 0a 09 20 20 28 66 6f 72 2d 65 61  s ht)..  (for-ea
0a10: 63 68 0a 09 20 20 20 28 6c 61 6d 62 64 61 20 28  ch..   (lambda (
0a20: 6b 65 79 29 0a 09 20 20 20 20 20 28 73 71 6c 69  key)..     (sqli
0a30: 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77  te3:for-each-row
0a40: 0a 09 20 20 20 20 20 20 28 6c 61 6d 62 64 61 20  ..      (lambda 
0a50: 28 76 61 6c 29 0a 09 09 28 68 61 73 68 2d 74 61  (val)...(hash-ta
0a60: 62 6c 65 2d 73 65 74 21 20 76 61 6c 73 20 6b 65  ble-set! vals ke
0a70: 79 20 76 61 6c 29 29 0a 09 20 20 20 20 20 20 64  y val))..      d
0a80: 62 20 0a 09 20 20 20 20 20 20 28 63 6f 6e 63 20  b ..      (conc 
0a90: 22 53 45 4c 45 43 54 20 22 20 28 6b 65 79 3a 67  "SELECT " (key:g
0aa0: 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65 79  et-fieldname key
0ab0: 29 20 22 20 46 52 4f 4d 20 72 75 6e 73 20 57 48  ) " FROM runs WH
0ac0: 45 52 45 20 69 64 3d 3f 3b 22 29 0a 09 20 20 20  ERE id=?;")..   
0ad0: 20 20 20 72 75 6e 2d 69 64 29 29 0a 09 20 20 20     run-id))..   
0ae0: 6b 65 79 73 29 29 29 0a 20 20 20 20 3b 3b 20 66  keys))).    ;; f
0af0: 72 6f 6d 20 74 68 65 20 63 61 63 68 65 64 20 64  rom the cached d
0b00: 61 74 61 20 73 65 74 20 74 68 65 20 76 61 72 73  ata set the vars
0b10: 0a 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65  .    (hash-table
0b20: 2d 66 6f 72 2d 65 61 63 68 0a 20 20 20 20 20 76  -for-each.     v
0b30: 61 6c 73 0a 20 20 20 20 20 28 6c 61 6d 62 64 61  als.     (lambda
0b40: 20 28 6b 65 79 20 76 61 6c 29 0a 20 20 20 20 20   (key val).     
0b50: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32    (debug:print 2
0b60: 20 22 73 65 74 65 6e 76 20 22 20 28 6b 65 79 3a   "setenv " (key:
0b70: 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65  get-fieldname ke
0b80: 79 29 20 22 20 22 20 76 61 6c 29 0a 20 20 20 20  y) " " val).    
0b90: 20 20 20 28 73 65 74 65 6e 76 20 28 6b 65 79 3a     (setenv (key:
0ba0: 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65  get-fieldname ke
0bb0: 79 29 20 76 61 6c 29 29 29 0a 20 20 20 20 28 61  y) val))).    (a
0bc0: 6c 69 73 74 2d 3e 65 6e 76 2d 76 61 72 73 20 28  list->env-vars (
0bd0: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64  hash-table-ref/d
0be0: 65 66 61 75 6c 74 20 2a 63 6f 6e 66 69 67 64 61  efault *configda
0bf0: 74 2a 20 22 65 6e 76 2d 6f 76 65 72 72 69 64 65  t* "env-override
0c00: 22 20 27 28 29 29 29 0a 20 20 20 20 3b 3b 20 4c  " '())).    ;; L
0c10: 65 74 73 20 75 73 65 20 74 68 69 73 20 61 73 20  ets use this as 
0c20: 61 6e 20 6f 70 70 6f 72 74 75 6e 69 74 79 20 74  an opportunity t
0c30: 6f 20 70 75 74 20 4d 54 5f 52 55 4e 4e 41 4d 45  o put MT_RUNNAME
0c40: 20 69 6e 20 74 68 65 20 65 6e 76 69 72 6f 6e 6d   in the environm
0c50: 65 6e 74 0a 20 20 20 20 28 69 66 20 28 6e 6f 74  ent.    (if (not
0c60: 20 2a 63 75 72 72 65 6e 74 2d 72 75 6e 2d 6e 61   *current-run-na
0c70: 6d 65 2a 29 0a 09 28 73 71 6c 69 74 65 33 3a 66  me*)..(sqlite3:f
0c80: 6f 72 2d 65 61 63 68 2d 72 6f 77 0a 09 20 28 6c  or-each-row.. (l
0c90: 61 6d 62 64 61 20 28 72 75 6e 6e 61 6d 65 29 0a  ambda (runname).
0ca0: 09 20 20 20 28 73 65 74 21 20 2a 63 75 72 72 65  .   (set! *curre
0cb0: 6e 74 2d 72 75 6e 2d 6e 61 6d 65 2a 20 72 75 6e  nt-run-name* run
0cc0: 6e 61 6d 65 29 29 0a 0a 09 20 64 62 0a 09 20 22  name))... db.. "
0cd0: 53 45 4c 45 43 54 20 72 75 6e 6e 61 6d 65 20 46  SELECT runname F
0ce0: 52 4f 4d 20 72 75 6e 73 20 57 48 45 52 45 20 69  ROM runs WHERE i
0cf0: 64 3d 3f 3b 22 0a 09 20 72 75 6e 2d 69 64 29 29  d=?;".. run-id))
0d00: 0a 20 20 20 20 28 73 65 74 65 6e 76 20 22 4d 54  .    (setenv "MT
0d10: 5f 52 55 4e 4e 41 4d 45 22 20 2a 63 75 72 72 65  _RUNNAME" *curre
0d20: 6e 74 2d 72 75 6e 2d 6e 61 6d 65 2a 29 0a 20 20  nt-run-name*).  
0d30: 20 20 28 73 65 74 65 6e 76 20 22 4d 54 5f 52 55    (setenv "MT_RU
0d40: 4e 5f 41 52 45 41 5f 48 4f 4d 45 22 20 2a 74 6f  N_AREA_HOME" *to
0d50: 70 70 61 74 68 2a 29 0a 20 20 20 20 29 29 0a 0a  ppath*).    ))..
0d60: 28 64 65 66 69 6e 65 20 28 73 65 74 2d 69 74 65  (define (set-ite
0d70: 6d 2d 65 6e 76 2d 76 61 72 73 20 69 74 65 6d 64  m-env-vars itemd
0d80: 61 74 29 0a 20 20 28 66 6f 72 2d 65 61 63 68 20  at).  (for-each 
0d90: 28 6c 61 6d 62 64 61 20 28 69 74 65 6d 29 0a 09  (lambda (item)..
0da0: 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69        (debug:pri
0db0: 6e 74 20 32 20 22 73 65 74 65 6e 76 20 22 20 28  nt 2 "setenv " (
0dc0: 63 61 72 20 69 74 65 6d 29 20 22 20 22 20 28 63  car item) " " (c
0dd0: 61 64 72 20 69 74 65 6d 29 29 0a 09 20 20 20 20  adr item))..    
0de0: 20 20 28 73 65 74 65 6e 76 20 28 63 61 72 20 69    (setenv (car i
0df0: 74 65 6d 29 20 28 63 61 64 72 20 69 74 65 6d 29  tem) (cadr item)
0e00: 29 29 0a 09 20 20 20 20 69 74 65 6d 64 61 74 29  ))..    itemdat)
0e10: 29 0a 0a 28 64 65 66 69 6e 65 20 2a 6c 61 73 74  )..(define *last
0e20: 2d 6e 75 6d 2d 72 75 6e 6e 69 6e 67 2d 74 65 73  -num-running-tes
0e30: 74 73 2a 20 30 29 0a 28 64 65 66 69 6e 65 20 28  ts* 0).(define (
0e40: 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72  runs:can-run-mor
0e50: 65 2d 74 65 73 74 73 20 64 62 20 74 65 73 74 2d  e-tests db test-
0e60: 72 65 63 6f 72 64 29 0a 20 20 28 6c 65 74 2a 20  record).  (let* 
0e70: 28 28 74 63 6f 6e 66 69 67 20 20 20 20 20 20 20  ((tconfig       
0e80: 20 20 20 20 20 20 20 20 20 20 28 74 65 73 74 73            (tests
0e90: 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d 74  :testqueue-get-t
0ea0: 65 73 74 63 6f 6e 66 69 67 20 74 65 73 74 2d 72  estconfig test-r
0eb0: 65 63 6f 72 64 29 29 0a 09 20 28 6a 6f 62 67 72  ecord)).. (jobgr
0ec0: 6f 75 70 20 20 20 20 20 20 20 20 20 20 20 20 20  oup             
0ed0: 20 20 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75     (config-looku
0ee0: 70 20 74 63 6f 6e 66 69 67 20 22 72 65 71 75 69  p tconfig "requi
0ef0: 72 65 6d 65 6e 74 73 22 20 22 6a 6f 62 67 72 6f  rements" "jobgro
0f00: 75 70 22 29 29 0a 09 20 28 6e 75 6d 2d 72 75 6e  up")).. (num-run
0f10: 6e 69 6e 67 20 20 20 20 20 20 20 20 20 20 20 20  ning            
0f20: 20 28 64 62 3a 67 65 74 2d 63 6f 75 6e 74 2d 74   (db:get-count-t
0f30: 65 73 74 73 2d 72 75 6e 6e 69 6e 67 20 64 62 29  ests-running db)
0f40: 29 0a 09 20 28 6e 75 6d 2d 72 75 6e 6e 69 6e 67  ).. (num-running
0f50: 2d 69 6e 2d 6a 6f 62 67 72 6f 75 70 20 28 64 62  -in-jobgroup (db
0f60: 3a 67 65 74 2d 63 6f 75 6e 74 2d 74 65 73 74 73  :get-count-tests
0f70: 2d 72 75 6e 6e 69 6e 67 2d 69 6e 2d 6a 6f 62 67  -running-in-jobg
0f80: 72 6f 75 70 20 64 62 20 6a 6f 62 67 72 6f 75 70  roup db jobgroup
0f90: 29 29 0a 09 20 28 6d 61 78 2d 63 6f 6e 63 75 72  )).. (max-concur
0fa0: 72 65 6e 74 2d 6a 6f 62 73 20 20 20 20 20 28 63  rent-jobs     (c
0fb0: 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f  onfig-lookup *co
0fc0: 6e 66 69 67 64 61 74 2a 20 22 73 65 74 75 70 22  nfigdat* "setup"
0fd0: 20 20 20 20 20 22 6d 61 78 5f 63 6f 6e 63 75 72       "max_concur
0fe0: 72 65 6e 74 5f 6a 6f 62 73 22 29 29 0a 09 20 28  rent_jobs")).. (
0ff0: 6a 6f 62 2d 67 72 6f 75 70 2d 6c 69 6d 69 74 20  job-group-limit 
1000: 20 20 20 20 20 20 20 20 28 63 6f 6e 66 69 67 2d          (config-
1010: 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67 64 61  lookup *configda
1020: 74 2a 20 22 6a 6f 62 67 72 6f 75 70 73 22 20 6a  t* "jobgroups" j
1030: 6f 62 67 72 6f 75 70 29 29 29 0a 20 20 20 20 28  obgroup))).    (
1040: 69 66 20 28 6e 6f 74 20 28 65 71 3f 20 2a 6c 61  if (not (eq? *la
1050: 73 74 2d 6e 75 6d 2d 72 75 6e 6e 69 6e 67 2d 74  st-num-running-t
1060: 65 73 74 73 2a 20 6e 75 6d 2d 72 75 6e 6e 69 6e  ests* num-runnin
1070: 67 29 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 28  g))..(begin..  (
1080: 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 6d  debug:print 2 "m
1090: 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f  ax-concurrent-jo
10a0: 62 73 3a 20 22 20 6d 61 78 2d 63 6f 6e 63 75 72  bs: " max-concur
10b0: 72 65 6e 74 2d 6a 6f 62 73 20 22 2c 20 6e 75 6d  rent-jobs ", num
10c0: 2d 72 75 6e 6e 69 6e 67 3a 20 22 20 6e 75 6d 2d  -running: " num-
10d0: 72 75 6e 6e 69 6e 67 29 0a 09 20 20 28 73 65 74  running)..  (set
10e0: 21 20 2a 6c 61 73 74 2d 6e 75 6d 2d 72 75 6e 6e  ! *last-num-runn
10f0: 69 6e 67 2d 74 65 73 74 73 2a 20 6e 75 6d 2d 72  ing-tests* num-r
1100: 75 6e 6e 69 6e 67 29 29 29 0a 20 20 20 20 28 69  unning))).    (i
1110: 66 20 28 6e 6f 74 20 28 65 71 3f 20 30 20 2a 67  f (not (eq? 0 *g
1120: 6c 6f 62 61 6c 65 78 69 74 73 74 61 74 75 73 2a  lobalexitstatus*
1130: 29 29 0a 09 23 66 0a 09 28 6c 65 74 20 28 28 63  ))..#f..(let ((c
1140: 61 6e 2d 6e 6f 74 2d 72 75 6e 2d 6d 6f 72 65 20  an-not-run-more 
1150: 28 63 6f 6e 64 0a 09 09 09 09 20 3b 3b 20 69 66  (cond..... ;; if
1160: 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d   max-concurrent-
1170: 6a 6f 62 73 20 69 73 20 73 65 74 20 61 6e 64 20  jobs is set and 
1180: 74 68 65 20 6e 75 6d 62 65 72 20 72 75 6e 6e 69  the number runni
1190: 6e 67 20 69 73 20 67 72 65 61 74 65 72 20 0a 09  ng is greater ..
11a0: 09 09 09 20 3b 3b 20 74 68 61 6e 20 69 74 20 74  ... ;; than it t
11b0: 68 61 6e 20 63 61 6e 6e 6f 74 20 72 75 6e 20 6d  han cannot run m
11c0: 6f 72 65 20 6a 6f 62 73 0a 09 09 09 09 20 28 28  ore jobs..... ((
11d0: 61 6e 64 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65  and max-concurre
11e0: 6e 74 2d 6a 6f 62 73 0a 09 09 09 09 20 20 20 20  nt-jobs.....    
11f0: 20 20 20 28 73 74 72 69 6e 67 2d 3e 6e 75 6d 62     (string->numb
1200: 65 72 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e  er max-concurren
1210: 74 2d 6a 6f 62 73 29 0a 09 09 09 09 20 20 20 20  t-jobs).....    
1220: 20 20 20 28 3e 3d 20 6e 75 6d 2d 72 75 6e 6e 69     (>= num-runni
1230: 6e 67 20 28 73 74 72 69 6e 67 2d 3e 6e 75 6d 62  ng (string->numb
1240: 65 72 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e  er max-concurren
1250: 74 2d 6a 6f 62 73 29 29 29 0a 09 09 09 09 20 20  t-jobs))).....  
1260: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
1270: 57 41 52 4e 49 4e 47 3a 20 4d 61 78 20 72 75 6e  WARNING: Max run
1280: 6e 69 6e 67 20 6a 6f 62 73 20 65 78 63 65 65 64  ning jobs exceed
1290: 65 64 2c 20 63 75 72 72 65 6e 74 20 6e 75 6d 62  ed, current numb
12a0: 65 72 20 72 75 6e 6e 69 6e 67 3a 20 22 20 6e 75  er running: " nu
12b0: 6d 2d 72 75 6e 6e 69 6e 67 20 0a 09 09 09 09 09  m-running ......
12c0: 20 20 20 20 20 20 20 22 2c 20 6d 61 78 5f 63 6f         ", max_co
12d0: 6e 63 75 72 72 65 6e 74 5f 6a 6f 62 73 3a 20 22  ncurrent_jobs: "
12e0: 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d   max-concurrent-
12f0: 6a 6f 62 73 29 0a 09 09 09 09 20 20 23 74 29 0a  jobs).....  #t).
1300: 09 09 09 09 20 3b 3b 20 69 66 20 6a 6f 62 2d 67  .... ;; if job-g
1310: 72 6f 75 70 2d 6c 69 6d 69 74 20 69 73 20 73 65  roup-limit is se
1320: 74 20 61 6e 64 20 6e 75 6d 62 65 72 20 6f 66 20  t and number of 
1330: 6a 6f 62 73 20 69 6e 20 74 68 65 20 67 72 6f 75  jobs in the grou
1340: 70 20 69 73 20 67 72 65 61 74 65 72 0a 09 09 09  p is greater....
1350: 09 20 3b 3b 20 74 68 61 6e 20 74 68 65 20 6c 69  . ;; than the li
1360: 6d 69 74 20 74 68 65 6e 20 63 61 6e 6e 6f 74 20  mit then cannot 
1370: 72 75 6e 20 6d 6f 72 65 20 6a 6f 62 73 20 6f 66  run more jobs of
1380: 20 74 68 69 73 20 6b 69 6e 64 0a 09 09 09 09 20   this kind..... 
1390: 28 28 61 6e 64 20 6a 6f 62 2d 67 72 6f 75 70 2d  ((and job-group-
13a0: 6c 69 6d 69 74 0a 09 09 09 09 20 20 20 20 20 20  limit.....      
13b0: 20 28 3e 3d 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67   (>= num-running
13c0: 2d 69 6e 2d 6a 6f 62 67 72 6f 75 70 20 6a 6f 62  -in-jobgroup job
13d0: 2d 67 72 6f 75 70 2d 6c 69 6d 69 74 29 29 0a 09  -group-limit))..
13e0: 09 09 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e  ...  (debug:prin
13f0: 74 20 31 20 22 57 41 52 4e 49 4e 47 3a 20 6e 75  t 1 "WARNING: nu
1400: 6d 62 65 72 20 6f 66 20 6a 6f 62 73 20 22 20 6e  mber of jobs " n
1410: 75 6d 2d 72 75 6e 6e 69 6e 67 2d 69 6e 2d 6a 6f  um-running-in-jo
1420: 62 67 72 6f 75 70 20 0a 09 09 09 09 09 20 20 20  bgroup ......   
1430: 20 20 20 20 22 20 69 6e 20 22 20 6a 6f 62 67 72      " in " jobgr
1440: 6f 75 70 20 22 20 65 78 63 65 65 64 65 64 2c 20  oup " exceeded, 
1450: 77 69 6c 6c 20 6e 6f 74 20 72 75 6e 20 22 20 28  will not run " (
1460: 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d  tests:testqueue-
1470: 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73  get-testname tes
1480: 74 2d 72 65 63 6f 72 64 29 29 0a 09 09 09 09 20  t-record))..... 
1490: 20 23 74 29 0a 09 09 09 09 20 28 65 6c 73 65 20   #t)..... (else 
14a0: 23 66 29 29 29 29 0a 09 20 20 28 6e 6f 74 20 63  #f))))..  (not c
14b0: 61 6e 2d 6e 6f 74 2d 72 75 6e 2d 6d 6f 72 65 29  an-not-run-more)
14c0: 29 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d  ))))..;;========
14d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
14e0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
14f0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1500: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b  ==============.;
1510: 3b 20 4e 65 77 20 6d 65 74 68 6f 64 6f 6c 6f 67  ; New methodolog
1520: 79 2e 20 54 68 65 73 65 20 72 6f 75 74 69 6e 65  y. These routine
1530: 73 20 77 69 6c 6c 20 72 65 70 6c 61 63 65 20 74  s will replace t
1540: 68 65 20 61 62 6f 76 65 20 69 6e 20 74 69 6d 65  he above in time
1550: 2e 20 46 6f 72 0a 3b 3b 20 6e 6f 77 20 74 68 65  . For.;; now the
1560: 20 63 6f 64 65 20 69 73 20 64 75 70 6c 69 63 61   code is duplica
1570: 74 65 64 2e 20 54 68 69 73 20 73 74 75 66 66 20  ted. This stuff 
1580: 69 73 20 69 6e 69 74 69 61 6c 6c 79 20 75 73 65  is initially use
1590: 64 20 69 6e 20 74 68 65 20 6d 6f 6e 69 74 6f 72  d in the monitor
15a0: 0a 3b 3b 20 62 61 73 65 64 20 63 6f 64 65 2e 0a  .;; based code..
15b0: 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ;;==============
15c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
15d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
15e0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
15f0: 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 72 65 67  ========..;; reg
1600: 69 73 74 65 72 20 61 20 74 65 73 74 20 72 75 6e  ister a test run
1610: 20 77 69 74 68 20 74 68 65 20 64 62 0a 28 64 65   with the db.(de
1620: 66 69 6e 65 20 28 72 75 6e 73 3a 72 65 67 69 73  fine (runs:regis
1630: 74 65 72 2d 72 75 6e 20 64 62 20 6b 65 79 73 20  ter-run db keys 
1640: 6b 65 79 76 61 6c 6c 73 74 20 72 75 6e 6e 61 6d  keyvallst runnam
1650: 65 20 73 74 61 74 65 20 73 74 61 74 75 73 20 75  e state status u
1660: 73 65 72 29 0a 20 20 28 64 65 62 75 67 3a 70 72  ser).  (debug:pr
1670: 69 6e 74 20 33 20 22 72 75 6e 73 3a 72 65 67 69  int 3 "runs:regi
1680: 73 74 65 72 2d 72 75 6e 2c 20 6b 65 79 73 3a 20  ster-run, keys: 
1690: 22 20 6b 65 79 73 20 22 20 6b 65 79 76 61 6c 6c  " keys " keyvall
16a0: 73 74 3a 20 22 20 6b 65 79 76 61 6c 6c 73 74 20  st: " keyvallst 
16b0: 22 20 72 75 6e 6e 61 6d 65 3a 20 22 20 72 75 6e  " runname: " run
16c0: 6e 61 6d 65 20 22 20 73 74 61 74 65 3a 20 22 20  name " state: " 
16d0: 73 74 61 74 65 20 22 20 73 74 61 74 75 73 3a 20  state " status: 
16e0: 22 20 73 74 61 74 75 73 20 22 20 75 73 65 72 3a  " status " user:
16f0: 20 22 20 75 73 65 72 29 0a 20 20 28 6c 65 74 2a   " user).  (let*
1700: 20 28 28 6b 65 79 73 74 72 20 20 20 20 28 6b 65   ((keystr    (ke
1710: 79 73 2d 3e 6b 65 79 73 74 72 20 6b 65 79 73 29  ys->keystr keys)
1720: 29 0a 09 20 28 63 6f 6d 6d 61 20 20 20 20 20 28  ).. (comma     (
1730: 69 66 20 28 3e 20 28 6c 65 6e 67 74 68 20 6b 65  if (> (length ke
1740: 79 73 29 20 30 29 20 22 2c 22 20 22 22 29 29 0a  ys) 0) "," "")).
1750: 09 20 28 61 6e 64 73 74 72 20 20 20 20 28 69 66  . (andstr    (if
1760: 20 28 3e 20 28 6c 65 6e 67 74 68 20 6b 65 79 73   (> (length keys
1770: 29 20 30 29 20 22 20 41 4e 44 20 22 20 22 22 29  ) 0) " AND " "")
1780: 29 0a 09 20 28 76 61 6c 73 6c 6f 74 73 20 20 28  ).. (valslots  (
1790: 6b 65 79 73 2d 3e 76 61 6c 73 6c 6f 74 73 20 6b  keys->valslots k
17a0: 65 79 73 29 29 20 3b 3b 20 3f 2c 3f 2c 3f 20 2e  eys)) ;; ?,?,? .
17b0: 2e 2e 0a 09 20 28 6b 65 79 76 61 6c 73 20 20 20  .... (keyvals   
17c0: 28 6d 61 70 20 63 61 64 72 20 6b 65 79 76 61 6c  (map cadr keyval
17d0: 6c 73 74 29 29 0a 09 20 28 61 6c 6c 76 61 6c 73  lst)).. (allvals
17e0: 20 20 20 28 61 70 70 65 6e 64 20 28 6c 69 73 74     (append (list
17f0: 20 72 75 6e 6e 61 6d 65 20 73 74 61 74 65 20 73   runname state s
1800: 74 61 74 75 73 20 75 73 65 72 29 20 6b 65 79 76  tatus user) keyv
1810: 61 6c 73 29 29 0a 09 20 28 71 72 79 76 61 6c 73  als)).. (qryvals
1820: 20 20 20 28 61 70 70 65 6e 64 20 28 6c 69 73 74     (append (list
1830: 20 72 75 6e 6e 61 6d 65 29 20 6b 65 79 76 61 6c   runname) keyval
1840: 73 29 29 0a 09 20 28 6b 65 79 3d 3f 73 74 72 20  s)).. (key=?str 
1850: 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70   (string-intersp
1860: 65 72 73 65 20 28 6d 61 70 20 28 6c 61 6d 62 64  erse (map (lambd
1870: 61 20 28 6b 29 28 63 6f 6e 63 20 28 6b 65 79 3a  a (k)(conc (key:
1880: 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 29  get-fieldname k)
1890: 20 22 3d 3f 22 29 29 20 6b 65 79 73 29 20 22 20   "=?")) keys) " 
18a0: 41 4e 44 20 22 29 29 29 0a 20 20 20 20 28 64 65  AND "))).    (de
18b0: 62 75 67 3a 70 72 69 6e 74 20 33 20 22 6b 65 79  bug:print 3 "key
18c0: 73 3a 20 22 20 6b 65 79 73 20 22 20 61 6c 6c 76  s: " keys " allv
18d0: 61 6c 73 3a 20 22 20 61 6c 6c 76 61 6c 73 20 22  als: " allvals "
18e0: 20 6b 65 79 76 61 6c 73 3a 20 22 20 6b 65 79 76   keyvals: " keyv
18f0: 61 6c 73 29 0a 20 20 20 20 28 64 65 62 75 67 3a  als).    (debug:
1900: 70 72 69 6e 74 20 32 20 22 4e 4f 54 45 3a 20 75  print 2 "NOTE: u
1910: 73 69 6e 67 20 74 61 72 67 65 74 20 22 20 28 73  sing target " (s
1920: 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73  tring-interspers
1930: 65 20 6b 65 79 76 61 6c 73 20 22 2f 22 29 20 22  e keyvals "/") "
1940: 20 66 6f 72 20 74 68 69 73 20 72 75 6e 22 29 0a   for this run").
1950: 20 20 20 20 28 69 66 20 28 61 6e 64 20 72 75 6e      (if (and run
1960: 6e 61 6d 65 20 28 6e 75 6c 6c 3f 20 28 66 69 6c  name (null? (fil
1970: 74 65 72 20 28 6c 61 6d 62 64 61 20 28 78 29 28  ter (lambda (x)(
1980: 6e 6f 74 20 78 29 29 20 6b 65 79 76 61 6c 73 29  not x)) keyvals)
1990: 29 29 20 3b 3b 20 74 68 65 72 65 20 6d 75 73 74  )) ;; there must
19a0: 20 62 65 20 61 20 62 65 74 74 65 72 20 77 61 79   be a better way
19b0: 20 74 6f 20 22 61 70 70 6c 79 20 61 6e 64 22 0a   to "apply and".
19c0: 09 28 6c 65 74 20 28 28 72 65 73 20 23 66 29 29  .(let ((res #f))
19d0: 0a 09 20 20 28 61 70 70 6c 79 20 73 71 6c 69 74  ..  (apply sqlit
19e0: 65 33 3a 65 78 65 63 75 74 65 20 64 62 20 28 63  e3:execute db (c
19f0: 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f 52 20 49  onc "INSERT OR I
1a00: 47 4e 4f 52 45 20 49 4e 54 4f 20 72 75 6e 73 20  GNORE INTO runs 
1a10: 28 72 75 6e 6e 61 6d 65 2c 73 74 61 74 65 2c 73  (runname,state,s
1a20: 74 61 74 75 73 2c 6f 77 6e 65 72 2c 65 76 65 6e  tatus,owner,even
1a30: 74 5f 74 69 6d 65 22 20 63 6f 6d 6d 61 20 6b 65  t_time" comma ke
1a40: 79 73 74 72 20 22 29 20 56 41 4c 55 45 53 20 28  ystr ") VALUES (
1a50: 3f 2c 3f 2c 3f 2c 3f 2c 73 74 72 66 74 69 6d 65  ?,?,?,?,strftime
1a60: 28 27 25 73 27 2c 27 6e 6f 77 27 29 22 20 63 6f  ('%s','now')" co
1a70: 6d 6d 61 20 76 61 6c 73 6c 6f 74 73 20 22 29 3b  mma valslots ");
1a80: 22 29 0a 09 09 20 61 6c 6c 76 61 6c 73 29 0a 09  ")... allvals)..
1a90: 20 20 28 61 70 70 6c 79 20 73 71 6c 69 74 65 33    (apply sqlite3
1aa0: 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77 20 0a 09  :for-each-row ..
1ab0: 20 20 20 28 6c 61 6d 62 64 61 20 28 69 64 29 0a     (lambda (id).
1ac0: 09 20 20 20 20 20 28 73 65 74 21 20 72 65 73 20  .     (set! res 
1ad0: 69 64 29 29 0a 09 20 20 20 64 62 0a 09 20 20 20  id))..   db..   
1ae0: 28 6c 65 74 20 28 28 71 72 79 20 28 63 6f 6e 63  (let ((qry (conc
1af0: 20 22 53 45 4c 45 43 54 20 69 64 20 46 52 4f 4d   "SELECT id FROM
1b00: 20 72 75 6e 73 20 57 48 45 52 45 20 28 72 75 6e   runs WHERE (run
1b10: 6e 61 6d 65 3d 3f 20 22 20 61 6e 64 73 74 72 20  name=? " andstr 
1b20: 6b 65 79 3d 3f 73 74 72 20 22 29 3b 22 29 29 29  key=?str ");")))
1b30: 0a 09 20 20 20 20 20 3b 28 64 65 62 75 67 3a 70  ..     ;(debug:p
1b40: 72 69 6e 74 20 34 20 22 71 72 79 3a 20 22 20 71  rint 4 "qry: " q
1b50: 72 79 29 20 0a 09 20 20 20 20 20 71 72 79 29 0a  ry) ..     qry).
1b60: 09 20 20 20 71 72 79 76 61 6c 73 29 0a 09 20 20  .   qryvals)..  
1b70: 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65  (sqlite3:execute
1b80: 20 64 62 20 22 55 50 44 41 54 45 20 72 75 6e 73   db "UPDATE runs
1b90: 20 53 45 54 20 73 74 61 74 65 3d 3f 2c 73 74 61   SET state=?,sta
1ba0: 74 75 73 3d 3f 20 57 48 45 52 45 20 69 64 3d 3f  tus=? WHERE id=?
1bb0: 3b 22 20 73 74 61 74 65 20 73 74 61 74 75 73 20  ;" state status 
1bc0: 72 65 73 29 0a 09 20 20 72 65 73 29 20 0a 09 28  res)..  res) ..(
1bd0: 62 65 67 69 6e 0a 09 20 20 28 64 65 62 75 67 3a  begin..  (debug:
1be0: 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20  print 0 "ERROR: 
1bf0: 43 61 6c 6c 65 64 20 77 69 74 68 6f 75 74 20 61  Called without a
1c00: 6c 6c 20 6e 65 63 65 73 73 61 72 79 20 6b 65 79  ll necessary key
1c10: 73 22 29 0a 09 20 20 23 66 29 29 29 29 0a 0a 3b  s")..  #f))))..;
1c20: 3b 20 54 68 69 73 20 69 73 20 61 20 64 75 70 6c  ; This is a dupl
1c30: 69 63 61 74 65 20 6f 66 20 72 75 6e 2d 74 65 73  icate of run-tes
1c40: 74 73 20 28 77 68 69 63 68 20 68 61 73 20 62 65  ts (which has be
1c50: 65 6e 20 64 65 70 72 65 63 61 74 65 64 29 2e 20  en deprecated). 
1c60: 55 73 65 20 74 68 69 73 20 6f 6e 65 20 69 6e 73  Use this one ins
1c70: 74 65 61 64 20 6f 66 20 72 75 6e 20 74 65 73 74  tead of run test
1c80: 73 2e 0a 3b 3b 20 6b 65 79 76 61 6c 73 0a 28 64  s..;; keyvals.(d
1c90: 65 66 69 6e 65 20 28 72 75 6e 73 3a 72 75 6e 2d  efine (runs:run-
1ca0: 74 65 73 74 73 20 74 61 72 67 65 74 20 72 75 6e  tests target run
1cb0: 6e 61 6d 65 20 74 65 73 74 2d 70 61 74 74 73 20  name test-patts 
1cc0: 75 73 65 72 20 66 6c 61 67 73 29 0a 20 20 28 6c  user flags).  (l
1cd0: 65 74 2a 20 28 28 64 62 20 20 20 20 20 20 20 20  et* ((db        
1ce0: 20 20 23 66 29 0a 09 20 28 6b 65 79 73 20 20 20    #f).. (keys   
1cf0: 20 20 20 20 20 28 6f 70 65 6e 2d 72 75 6e 2d 63       (open-run-c
1d00: 6c 6f 73 65 20 64 62 3a 67 65 74 2d 6b 65 79 73  lose db:get-keys
1d10: 20 64 62 29 29 0a 09 20 28 6b 65 79 76 61 6c 6c   db)).. (keyvall
1d20: 73 74 20 20 20 28 6b 65 79 73 3a 74 61 72 67 65  st   (keys:targe
1d30: 74 2d 3e 6b 65 79 76 61 6c 20 6b 65 79 73 20 74  t->keyval keys t
1d40: 61 72 67 65 74 29 29 0a 09 20 28 72 75 6e 2d 69  arget)).. (run-i
1d50: 64 20 20 20 20 20 20 28 6f 70 65 6e 2d 72 75 6e  d      (open-run
1d60: 2d 63 6c 6f 73 65 20 72 75 6e 73 3a 72 65 67 69  -close runs:regi
1d70: 73 74 65 72 2d 72 75 6e 20 64 62 20 6b 65 79 73  ster-run db keys
1d80: 20 6b 65 79 76 61 6c 6c 73 74 20 72 75 6e 6e 61   keyvallst runna
1d90: 6d 65 20 22 6e 65 77 22 20 22 6e 2f 61 22 20 75  me "new" "n/a" u
1da0: 73 65 72 29 29 20 20 3b 3b 20 20 74 65 73 74 2d  ser))  ;;  test-
1db0: 6e 61 6d 65 29 29 29 0a 09 20 28 64 65 66 65 72  name))).. (defer
1dc0: 72 65 64 20 20 20 20 27 28 29 29 20 3b 3b 20 64  red    '()) ;; d
1dd0: 65 6c 61 79 20 72 75 6e 6e 69 6e 67 20 74 68 65  elay running the
1de0: 73 65 20 73 69 6e 63 65 20 74 68 65 79 20 68 61  se since they ha
1df0: 76 65 20 61 20 77 61 69 74 6f 6e 20 63 6c 61 75  ve a waiton clau
1e00: 73 65 0a 09 20 3b 3b 20 6b 65 65 70 67 6f 69 6e  se.. ;; keepgoin
1e10: 67 20 69 73 20 74 68 65 20 64 65 66 61 63 74 6f  g is the defacto
1e20: 20 6d 6f 64 61 6c 69 74 79 20 6e 6f 77 2c 20 77   modality now, w
1e30: 69 6c 6c 20 61 64 64 20 68 69 74 2d 6e 2d 72 75  ill add hit-n-ru
1e40: 6e 20 61 20 62 69 74 20 6c 61 74 65 72 0a 09 20  n a bit later.. 
1e50: 3b 3b 20 28 6b 65 65 70 67 6f 69 6e 67 20 20 20  ;; (keepgoing   
1e60: 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f  (hash-table-ref/
1e70: 64 65 66 61 75 6c 74 20 66 6c 61 67 73 20 22 2d  default flags "-
1e80: 6b 65 65 70 67 6f 69 6e 67 22 20 23 66 29 29 0a  keepgoing" #f)).
1e90: 09 20 28 74 65 73 74 2d 6e 61 6d 65 73 20 20 27  . (test-names  '
1ea0: 28 29 29 0a 09 20 28 72 75 6e 63 6f 6e 66 69 67  ()).. (runconfig
1eb0: 66 20 20 20 28 63 6f 6e 63 20 20 2a 74 6f 70 70  f   (conc  *topp
1ec0: 61 74 68 2a 20 22 2f 72 75 6e 63 6f 6e 66 69 67  ath* "/runconfig
1ed0: 73 2e 63 6f 6e 66 69 67 22 29 29 0a 09 20 28 72  s.config")).. (r
1ee0: 65 71 75 69 72 65 64 2d 74 65 73 74 73 20 27 28  equired-tests '(
1ef0: 29 29 0a 09 20 28 74 65 73 74 2d 72 65 63 6f 72  )).. (test-recor
1f00: 64 73 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61  ds (make-hash-ta
1f10: 62 6c 65 29 29 29 0a 0a 20 20 20 20 28 6f 70 65  ble)))..    (ope
1f20: 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 73 65 74 2d  n-run-close set-
1f30: 6d 65 67 61 74 65 73 74 2d 65 6e 76 2d 76 61 72  megatest-env-var
1f40: 73 20 64 62 20 72 75 6e 2d 69 64 29 20 3b 3b 20  s db run-id) ;; 
1f50: 74 68 65 73 65 20 6d 61 79 20 62 65 20 6e 65 65  these may be nee
1f60: 64 65 64 20 62 79 20 74 68 65 20 6c 61 75 6e 63  ded by the launc
1f70: 68 69 6e 67 20 70 72 6f 63 65 73 73 0a 0a 20 20  hing process..  
1f80: 20 20 28 69 66 20 28 66 69 6c 65 2d 65 78 69 73    (if (file-exis
1f90: 74 73 3f 20 72 75 6e 63 6f 6e 66 69 67 66 29 0a  ts? runconfigf).
1fa0: 09 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65  .(open-run-close
1fb0: 20 73 65 74 75 70 2d 65 6e 76 2d 64 65 66 61 75   setup-env-defau
1fc0: 6c 74 73 20 64 62 20 72 75 6e 63 6f 6e 66 69 67  lts db runconfig
1fd0: 66 20 72 75 6e 2d 69 64 20 2a 61 6c 72 65 61 64  f run-id *alread
1fe0: 79 2d 73 65 65 6e 2d 72 75 6e 63 6f 6e 66 69 67  y-seen-runconfig
1ff0: 2d 69 6e 66 6f 2a 20 22 70 72 65 2d 6c 61 75 6e  -info* "pre-laun
2000: 63 68 2d 65 6e 76 2d 76 61 72 73 22 29 0a 09 28  ch-env-vars")..(
2010: 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 57  debug:print 0 "W
2020: 41 52 4e 49 4e 47 3a 20 59 6f 75 20 64 6f 20 6e  ARNING: You do n
2030: 6f 74 20 68 61 76 65 20 61 20 72 75 6e 20 63 6f  ot have a run co
2040: 6e 66 69 67 20 66 69 6c 65 3a 20 22 20 72 75 6e  nfig file: " run
2050: 63 6f 6e 66 69 67 66 29 29 0a 20 20 20 20 0a 20  configf)).    . 
2060: 20 20 20 3b 3b 20 6c 6f 6f 6b 20 75 70 20 61 6c     ;; look up al
2070: 6c 20 74 65 73 74 73 20 6d 61 74 63 68 69 6e 67  l tests matching
2080: 20 74 68 65 20 63 6f 6d 6d 61 20 73 65 70 61 72   the comma separ
2090: 61 74 65 64 20 6c 69 73 74 20 6f 66 20 67 6c 6f  ated list of glo
20a0: 62 73 20 69 6e 0a 20 20 20 20 3b 3b 20 74 65 73  bs in.    ;; tes
20b0: 74 2d 70 61 74 74 73 20 28 75 73 69 6e 67 20 25  t-patts (using %
20c0: 20 61 73 20 77 69 6c 64 63 61 72 64 29 0a 20 20   as wildcard).  
20d0: 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 20 20    (for-each .   
20e0: 20 20 28 6c 61 6d 62 64 61 20 28 70 61 74 74 29    (lambda (patt)
20f0: 0a 20 20 20 20 20 20 20 28 6c 65 74 20 28 28 74  .       (let ((t
2100: 65 73 74 73 20 28 67 6c 6f 62 20 28 63 6f 6e 63  ests (glob (conc
2110: 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f 74 65 73   *toppath* "/tes
2120: 74 73 2f 22 20 28 73 74 72 69 6e 67 2d 74 72 61  ts/" (string-tra
2130: 6e 73 6c 61 74 65 20 70 61 74 74 20 22 25 22 20  nslate patt "%" 
2140: 22 2a 22 29 29 29 29 29 0a 09 20 28 73 65 74 21  "*"))))).. (set!
2150: 20 74 65 73 74 73 20 28 66 69 6c 74 65 72 20 28   tests (filter (
2160: 6c 61 6d 62 64 61 20 28 74 65 73 74 29 28 66 69  lambda (test)(fi
2170: 6c 65 2d 65 78 69 73 74 73 3f 20 28 63 6f 6e 63  le-exists? (conc
2180: 20 74 65 73 74 20 22 2f 74 65 73 74 63 6f 6e 66   test "/testconf
2190: 69 67 22 29 29 29 20 74 65 73 74 73 29 29 0a 09  ig"))) tests))..
21a0: 20 28 73 65 74 21 20 74 65 73 74 2d 6e 61 6d 65   (set! test-name
21b0: 73 20 28 61 70 70 65 6e 64 20 74 65 73 74 2d 6e  s (append test-n
21c0: 61 6d 65 73 20 0a 09 09 09 09 20 20 28 6d 61 70  ames .....  (map
21d0: 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74 70 29   (lambda (testp)
21e0: 0a 09 09 09 09 09 20 28 6c 61 73 74 20 28 73 74  ...... (last (st
21f0: 72 69 6e 67 2d 73 70 6c 69 74 20 74 65 73 74 70  ring-split testp
2200: 20 22 2f 22 29 29 29 0a 09 09 09 09 20 20 20 20   "/"))).....    
2210: 20 20 20 74 65 73 74 73 29 29 29 29 29 0a 20 20     tests))))).  
2220: 20 20 20 28 69 66 20 74 65 73 74 2d 70 61 74 74     (if test-patt
2230: 73 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20  s (string-split 
2240: 74 65 73 74 2d 70 61 74 74 73 20 22 2c 22 29 28  test-patts ",")(
2250: 6c 69 73 74 20 22 25 22 29 29 29 0a 0a 20 20 20  list "%")))..   
2260: 20 20 3b 3b 20 6e 6f 77 20 72 65 6d 6f 76 65 20    ;; now remove 
2270: 64 75 70 6c 69 63 61 74 65 73 0a 20 20 20 20 28  duplicates.    (
2280: 73 65 74 21 20 74 65 73 74 2d 6e 61 6d 65 73 20  set! test-names 
2290: 28 64 65 6c 65 74 65 2d 64 75 70 6c 69 63 61 74  (delete-duplicat
22a0: 65 73 20 74 65 73 74 2d 6e 61 6d 65 73 29 29 0a  es test-names)).
22b0: 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e  .    (debug:prin
22c0: 74 20 30 20 22 49 4e 46 4f 3a 20 74 65 73 74 20  t 0 "INFO: test 
22d0: 6e 61 6d 65 73 20 22 20 74 65 73 74 2d 6e 61 6d  names " test-nam
22e0: 65 73 29 0a 0a 20 20 20 20 3b 3b 20 6f 6e 20 74  es)..    ;; on t
22f0: 68 65 20 66 69 72 73 74 20 70 61 73 73 20 6f 72  he first pass or
2300: 20 63 61 6c 6c 20 74 6f 20 72 75 6e 2d 74 65 73   call to run-tes
2310: 74 73 20 73 65 74 20 46 41 49 4c 53 20 74 6f 20  ts set FAILS to 
2320: 4e 4f 54 5f 53 54 41 52 54 45 44 20 69 66 0a 20  NOT_STARTED if. 
2330: 20 20 20 3b 3b 20 2d 6b 65 65 70 67 6f 69 6e 67     ;; -keepgoing
2340: 20 69 73 20 73 70 65 63 69 66 69 65 64 0a 20 20   is specified.  
2350: 20 20 28 69 66 20 28 65 71 3f 20 2a 70 61 73 73    (if (eq? *pass
2360: 6e 75 6d 2a 20 30 29 0a 09 28 62 65 67 69 6e 0a  num* 0)..(begin.
2370: 09 20 20 3b 3b 20 68 61 76 65 20 74 6f 20 64 65  .  ;; have to de
2380: 6c 65 74 65 20 74 65 73 74 20 72 65 63 6f 72 64  lete test record
2390: 73 20 77 68 65 72 65 20 4e 4f 54 5f 53 54 41 52  s where NOT_STAR
23a0: 54 45 44 20 73 69 6e 63 65 20 74 68 65 79 20 63  TED since they c
23b0: 61 6e 20 63 61 75 73 65 20 2d 6b 65 65 70 67 6f  an cause -keepgo
23c0: 69 6e 67 20 74 6f 20 0a 09 20 20 3b 3b 20 67 65  ing to ..  ;; ge
23d0: 74 20 73 74 75 63 6b 20 64 75 65 20 74 6f 20 62  t stuck due to b
23e0: 65 63 6f 6d 69 6e 67 20 69 6e 61 63 63 65 73 73  ecoming inaccess
23f0: 69 62 6c 65 20 66 72 6f 6d 20 61 20 66 61 69 6c  ible from a fail
2400: 65 64 20 74 65 73 74 2e 20 49 2e 65 2e 20 69 66  ed test. I.e. if
2410: 20 74 65 73 74 20 42 20 64 65 70 65 6e 64 73 20   test B depends 
2420: 0a 09 20 20 3b 3b 20 6f 6e 20 74 65 73 74 20 41  ..  ;; on test A
2430: 20 62 75 74 20 74 65 73 74 20 42 20 72 65 61 63   but test B reac
2440: 68 65 64 20 74 68 65 20 70 6f 69 6e 74 20 6f 6e  hed the point on
2450: 20 62 65 69 6e 67 20 72 65 67 69 73 74 65 72 65   being registere
2460: 64 20 61 73 20 4e 4f 54 5f 53 54 41 52 54 45 44  d as NOT_STARTED
2470: 20 61 6e 64 20 74 65 73 74 0a 09 20 20 3b 3b 20   and test..  ;; 
2480: 41 20 66 61 69 6c 65 64 20 66 6f 72 20 73 6f 6d  A failed for som
2490: 65 20 72 65 61 73 6f 6e 20 74 68 65 6e 20 6f 6e  e reason then on
24a0: 20 72 65 2d 72 75 6e 20 75 73 69 6e 67 20 2d 6b   re-run using -k
24b0: 65 65 70 67 6f 69 6e 67 20 74 68 65 20 72 75 6e  eepgoing the run
24c0: 20 63 61 6e 20 6e 65 76 65 72 20 63 6f 6d 70 6c   can never compl
24d0: 65 74 65 2e 0a 09 20 20 28 6f 70 65 6e 2d 72 75  ete...  (open-ru
24e0: 6e 2d 63 6c 6f 73 65 20 64 62 3a 64 65 6c 65 74  n-close db:delet
24f0: 65 2d 74 65 73 74 73 2d 69 6e 2d 73 74 61 74 65  e-tests-in-state
2500: 20 64 62 20 72 75 6e 2d 69 64 20 22 4e 4f 54 5f   db run-id "NOT_
2510: 53 54 41 52 54 45 44 22 29 0a 09 20 20 28 6f 70  STARTED")..  (op
2520: 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 64 62 3a  en-run-close db:
2530: 73 65 74 2d 74 65 73 74 73 2d 73 74 61 74 65 2d  set-tests-state-
2540: 73 74 61 74 75 73 20 64 62 20 72 75 6e 2d 69 64  status db run-id
2550: 20 74 65 73 74 2d 6e 61 6d 65 73 20 23 66 20 22   test-names #f "
2560: 46 41 49 4c 22 20 22 4e 4f 54 5f 53 54 41 52 54  FAIL" "NOT_START
2570: 45 44 22 20 22 46 41 49 4c 22 29 29 29 0a 0a 20  ED" "FAIL"))).. 
2580: 20 20 20 3b 3b 20 66 72 6f 6d 20 68 65 72 65 20     ;; from here 
2590: 6f 6e 20 6f 75 74 20 74 68 65 20 64 62 20 77 69  on out the db wi
25a0: 6c 6c 20 62 65 20 6f 70 65 6e 65 64 20 61 6e 64  ll be opened and
25b0: 20 63 6c 6f 73 65 64 20 6f 6e 20 65 76 65 72 79   closed on every
25c0: 20 63 61 6c 6c 20 72 75 6e 73 3a 72 75 6e 2d 74   call runs:run-t
25d0: 65 73 74 73 2d 71 75 65 75 65 0a 20 20 20 20 3b  ests-queue.    ;
25e0: 3b 20 28 73 71 6c 69 74 65 33 3a 66 69 6e 61 6c  ; (sqlite3:final
25f0: 69 7a 65 21 20 64 62 29 20 0a 20 20 20 20 3b 3b  ize! db) .    ;;
2600: 20 6e 6f 77 20 61 64 64 20 6e 6f 6e 2d 64 69 72   now add non-dir
2610: 65 63 74 6c 79 20 72 65 66 65 72 65 6e 63 65 64  ectly referenced
2620: 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20 28 69   dependencies (i
2630: 2e 65 2e 20 77 61 69 74 6f 6e 29 0a 20 20 20 20  .e. waiton).    
2640: 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20  (if (not (null? 
2650: 74 65 73 74 2d 6e 61 6d 65 73 29 29 0a 09 28 6c  test-names))..(l
2660: 65 74 20 6c 6f 6f 70 20 28 28 68 65 64 20 28 63  et loop ((hed (c
2670: 61 72 20 74 65 73 74 2d 6e 61 6d 65 73 29 29 0a  ar test-names)).
2680: 09 09 20 20 20 28 74 61 6c 20 28 63 64 72 20 74  ..   (tal (cdr t
2690: 65 73 74 2d 6e 61 6d 65 73 29 29 29 20 20 20 20  est-names)))    
26a0: 20 20 20 20 20 3b 3b 20 27 72 65 74 75 72 6e 2d       ;; 'return-
26b0: 70 72 6f 63 73 20 74 65 6c 6c 73 20 74 68 65 20  procs tells the 
26c0: 63 6f 6e 66 69 67 20 72 65 61 64 65 72 20 74 6f  config reader to
26d0: 20 70 72 65 70 20 72 75 6e 6e 69 6e 67 20 73 79   prep running sy
26e0: 73 74 65 6d 20 62 75 74 20 72 65 74 75 72 6e 20  stem but return 
26f0: 61 20 70 72 6f 63 0a 09 20 20 28 64 65 62 75 67  a proc..  (debug
2700: 3a 70 72 69 6e 74 20 34 20 22 49 4e 46 4f 3a 20  :print 4 "INFO: 
2710: 68 65 64 3d 22 20 68 65 64 20 22 20 61 74 20 74  hed=" hed " at t
2720: 6f 70 20 6f 66 20 6c 6f 6f 70 22 29 0a 09 20 20  op of loop")..  
2730: 28 6c 65 74 2a 20 28 28 63 6f 6e 66 69 67 20 20  (let* ((config  
2740: 28 74 65 73 74 73 3a 67 65 74 2d 74 65 73 74 63  (tests:get-testc
2750: 6f 6e 66 69 67 20 68 65 64 20 27 72 65 74 75 72  onfig hed 'retur
2760: 6e 2d 70 72 6f 63 73 29 29 0a 09 09 20 28 77 61  n-procs))... (wa
2770: 69 74 6f 6e 73 20 28 69 66 20 63 6f 6e 66 69 67  itons (if config
2780: 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 28   (string-split (
2790: 6c 65 74 20 28 28 77 20 28 63 6f 6e 66 69 67 2d  let ((w (config-
27a0: 6c 6f 6f 6b 75 70 20 63 6f 6e 66 69 67 20 22 72  lookup config "r
27b0: 65 71 75 69 72 65 6d 65 6e 74 73 22 20 22 77 61  equirements" "wa
27c0: 69 74 6f 6e 22 29 29 29 0a 09 09 09 09 09 09 20  iton")))....... 
27d0: 20 20 20 20 28 69 66 20 77 20 77 20 22 22 29 29      (if w w ""))
27e0: 29 0a 09 09 09 20 20 20 20 20 20 28 62 65 67 69  )....      (begi
27f0: 6e 0a 09 09 09 09 28 64 65 62 75 67 3a 70 72 69  n.....(debug:pri
2800: 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 6e 6f 6e  nt 0 "ERROR: non
2810: 2d 65 78 69 73 74 65 6e 74 20 72 65 71 75 69 72  -existent requir
2820: 65 64 20 74 65 73 74 20 5c 22 22 20 68 65 64 20  ed test \"" hed 
2830: 22 5c 22 22 29 0a 20 20 20 20 20 20 20 20 20 20  "\"").          
2840: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2850: 20 20 20 20 20 20 28 69 66 20 64 62 20 28 73 71        (if db (sq
2860: 6c 69 74 65 33 3a 66 69 6e 61 6c 69 7a 65 21 20  lite3:finalize! 
2870: 64 62 29 29 0a 09 09 09 09 28 65 78 69 74 20 31  db)).....(exit 1
2880: 29 29 29 29 29 0a 09 20 20 20 20 3b 3b 20 63 68  )))))..    ;; ch
2890: 65 63 6b 20 66 6f 72 20 68 65 64 20 69 6e 20 77  eck for hed in w
28a0: 61 69 74 6f 6e 73 20 3d 3e 20 74 68 69 73 20 77  aitons => this w
28b0: 6f 75 6c 64 20 62 65 20 63 69 72 63 75 6c 61 72  ould be circular
28c0: 2c 20 72 65 6d 6f 76 65 20 69 74 20 61 6e 64 20  , remove it and 
28d0: 69 73 73 75 65 20 61 6e 0a 09 20 20 20 20 3b 3b  issue an..    ;;
28e0: 20 65 72 72 6f 72 0a 09 20 20 20 20 28 69 66 20   error..    (if 
28f0: 28 6d 65 6d 62 65 72 20 68 65 64 20 77 61 69 74  (member hed wait
2900: 6f 6e 73 29 0a 09 09 28 62 65 67 69 6e 0a 09 09  ons)...(begin...
2910: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30    (debug:print 0
2920: 20 22 45 52 52 4f 52 3a 20 74 65 73 74 20 22 20   "ERROR: test " 
2930: 68 65 64 20 22 20 68 61 73 20 6c 69 73 74 65 64  hed " has listed
2940: 20 69 74 73 65 6c 66 20 61 73 20 61 20 77 61 69   itself as a wai
2950: 74 6f 6e 2c 20 70 6c 65 61 73 65 20 63 6f 72 72  ton, please corr
2960: 65 63 74 20 74 68 69 73 21 22 29 0a 09 09 20 20  ect this!")...  
2970: 28 73 65 74 21 20 77 61 69 74 6f 6e 73 20 28 66  (set! waitons (f
2980: 69 6c 74 65 72 20 28 6c 61 6d 62 64 61 20 28 78  ilter (lambda (x
2990: 29 28 6e 6f 74 20 28 65 71 75 61 6c 3f 20 78 20  )(not (equal? x 
29a0: 68 65 64 29 29 29 20 77 61 69 74 6f 6e 73 29 29  hed))) waitons))
29b0: 29 29 0a 09 20 20 20 20 0a 09 20 20 20 20 3b 3b  ))..    ..    ;;
29c0: 20 28 69 74 65 6d 73 20 20 20 28 69 74 65 6d 73   (items   (items
29d0: 3a 67 65 74 2d 69 74 65 6d 73 2d 66 72 6f 6d 2d  :get-items-from-
29e0: 63 6f 6e 66 69 67 20 63 6f 6e 66 69 67 29 29 29  config config)))
29f0: 0a 09 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28  ..    (if (not (
2a00: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64  hash-table-ref/d
2a10: 65 66 61 75 6c 74 20 74 65 73 74 2d 72 65 63 6f  efault test-reco
2a20: 72 64 73 20 68 65 64 20 23 66 29 29 0a 09 09 28  rds hed #f))...(
2a30: 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74 21 20  hash-table-set! 
2a40: 74 65 73 74 2d 72 65 63 6f 72 64 73 0a 09 09 09  test-records....
2a50: 09 20 68 65 64 20 28 76 65 63 74 6f 72 20 68 65  . hed (vector he
2a60: 64 20 20 20 20 20 3b 3b 20 30 0a 09 09 09 09 09  d     ;; 0......
2a70: 20 20 20 20 20 63 6f 6e 66 69 67 20 20 3b 3b 20       config  ;; 
2a80: 31 0a 09 09 09 09 09 20 20 20 20 20 77 61 69 74  1......     wait
2a90: 6f 6e 73 20 3b 3b 20 32 0a 09 09 09 09 09 20 20  ons ;; 2......  
2aa0: 20 20 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75     (config-looku
2ab0: 70 20 63 6f 6e 66 69 67 20 22 72 65 71 75 69 72  p config "requir
2ac0: 65 6d 65 6e 74 73 22 20 22 70 72 69 6f 72 69 74  ements" "priorit
2ad0: 79 22 29 20 20 20 20 20 3b 3b 20 70 72 69 6f 72  y")     ;; prior
2ae0: 69 74 79 20 33 0a 09 09 09 09 09 20 20 20 20 20  ity 3......     
2af0: 28 6c 65 74 20 28 28 69 74 65 6d 73 20 20 20 20  (let ((items    
2b00: 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65    (hash-table-re
2b10: 66 2f 64 65 66 61 75 6c 74 20 63 6f 6e 66 69 67  f/default config
2b20: 20 22 69 74 65 6d 73 22 20 23 66 29 29 20 3b 3b   "items" #f)) ;;
2b30: 20 69 74 65 6d 73 20 34 0a 09 09 09 09 09 09 20   items 4....... 
2b40: 20 20 28 69 74 65 6d 73 74 61 62 6c 65 20 28 68    (itemstable (h
2b50: 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65  ash-table-ref/de
2b60: 66 61 75 6c 74 20 63 6f 6e 66 69 67 20 22 69 74  fault config "it
2b70: 65 6d 73 74 61 62 6c 65 22 20 23 66 29 29 29 20  emstable" #f))) 
2b80: 0a 09 09 09 09 09 20 20 20 20 20 20 20 3b 3b 20  ......       ;; 
2b90: 69 66 20 65 69 74 68 65 72 20 69 74 65 6d 73 20  if either items 
2ba0: 6f 72 20 69 74 65 6d 73 20 74 61 62 6c 65 20 69  or items table i
2bb0: 73 20 61 20 70 72 6f 63 20 72 65 74 75 72 6e 20  s a proc return 
2bc0: 69 74 20 73 6f 20 74 65 73 74 20 72 75 6e 6e 69  it so test runni
2bd0: 6e 67 0a 09 09 09 09 09 20 20 20 20 20 20 20 3b  ng......       ;
2be0: 3b 20 70 72 6f 63 65 73 73 20 63 61 6e 20 6b 6e  ; process can kn
2bf0: 6f 77 20 74 6f 20 63 61 6c 6c 20 69 74 65 6d 73  ow to call items
2c00: 3a 67 65 74 2d 69 74 65 6d 73 2d 66 72 6f 6d 2d  :get-items-from-
2c10: 63 6f 6e 66 69 67 0a 09 09 09 09 09 20 20 20 20  config......    
2c20: 20 20 20 3b 3b 20 69 66 20 65 69 74 68 65 72 20     ;; if either 
2c30: 69 73 20 61 20 6c 69 73 74 20 61 6e 64 20 6e 6f  is a list and no
2c40: 6e 65 20 69 73 20 61 20 70 72 6f 63 20 67 6f 20  ne is a proc go 
2c50: 61 68 65 61 64 20 61 6e 64 20 63 61 6c 6c 20 67  ahead and call g
2c60: 65 74 2d 69 74 65 6d 73 0a 09 09 09 09 09 20 20  et-items......  
2c70: 20 20 20 20 20 3b 3b 20 6f 74 68 65 72 77 69 73       ;; otherwis
2c80: 65 20 72 65 74 75 72 6e 20 23 66 20 2d 20 74 68  e return #f - th
2c90: 69 73 20 69 73 20 6e 6f 74 20 61 6e 20 69 74 65  is is not an ite
2ca0: 72 61 74 65 64 20 74 65 73 74 0a 09 09 09 09 09  rated test......
2cb0: 20 20 20 20 20 20 20 28 63 6f 6e 64 0a 09 09 09         (cond....
2cc0: 09 09 09 28 28 70 72 6f 63 65 64 75 72 65 3f 20  ...((procedure? 
2cd0: 69 74 65 6d 73 29 20 20 20 20 20 20 0a 09 09 09  items)      ....
2ce0: 09 09 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ... (debug:print
2cf0: 20 34 20 22 49 4e 46 4f 3a 20 69 74 65 6d 73 20   4 "INFO: items 
2d00: 69 73 20 61 20 70 72 6f 63 65 64 75 72 65 2c 20  is a procedure, 
2d10: 77 69 6c 6c 20 63 61 6c 63 20 6c 61 74 65 72 22  will calc later"
2d20: 29 0a 09 09 09 09 09 09 20 69 74 65 6d 73 29 20  )....... items) 
2d30: 20 20 20 20 20 20 20 20 20 20 20 3b 3b 20 63 61             ;; ca
2d40: 6c 63 20 6c 61 74 65 72 0a 09 09 09 09 09 09 28  lc later.......(
2d50: 28 70 72 6f 63 65 64 75 72 65 3f 20 69 74 65 6d  (procedure? item
2d60: 73 74 61 62 6c 65 29 0a 09 09 09 09 09 09 20 28  stable)....... (
2d70: 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 49  debug:print 4 "I
2d80: 4e 46 4f 3a 20 69 74 65 6d 73 74 61 62 6c 65 20  NFO: itemstable 
2d90: 69 73 20 61 20 70 72 6f 63 65 64 75 72 65 2c 20  is a procedure, 
2da0: 77 69 6c 6c 20 63 61 6c 63 20 6c 61 74 65 72 22  will calc later"
2db0: 29 0a 09 09 09 09 09 09 20 69 74 65 6d 73 74 61  )....... itemsta
2dc0: 62 6c 65 29 20 20 20 20 20 20 20 3b 3b 20 63 61  ble)       ;; ca
2dd0: 6c 63 20 6c 61 74 65 72 0a 09 09 09 09 09 09 28  lc later.......(
2de0: 28 66 69 6c 74 65 72 20 28 6c 61 6d 62 64 61 20  (filter (lambda 
2df0: 28 78 29 0a 09 09 09 09 09 09 09 20 20 20 28 6c  (x)........   (l
2e00: 65 74 20 28 28 76 61 6c 20 28 63 61 72 20 78 29  et ((val (car x)
2e10: 29 29 0a 09 09 09 09 09 09 09 20 20 20 20 20 28  ))........     (
2e20: 69 66 20 28 70 72 6f 63 65 64 75 72 65 3f 20 76  if (procedure? v
2e30: 61 6c 29 20 76 61 6c 20 23 66 29 29 29 0a 09 09  al) val #f)))...
2e40: 09 09 09 09 09 20 28 61 70 70 65 6e 64 20 28 69  ..... (append (i
2e50: 66 20 28 6c 69 73 74 3f 20 69 74 65 6d 73 29 20  f (list? items) 
2e60: 69 74 65 6d 73 20 27 28 29 29 0a 09 09 09 09 09  items '())......
2e70: 09 09 09 20 28 69 66 20 28 6c 69 73 74 3f 20 69  ... (if (list? i
2e80: 74 65 6d 73 74 61 62 6c 65 29 20 69 74 65 6d 73  temstable) items
2e90: 74 61 62 6c 65 20 27 28 29 29 29 29 0a 09 09 09  table '())))....
2ea0: 09 09 09 20 27 68 61 76 65 2d 70 72 6f 63 65 64  ... 'have-proced
2eb0: 75 72 65 29 0a 09 09 09 09 09 09 28 28 6f 72 20  ure).......((or 
2ec0: 28 6c 69 73 74 3f 20 69 74 65 6d 73 29 28 6c 69  (list? items)(li
2ed0: 73 74 3f 20 69 74 65 6d 73 74 61 62 6c 65 29 29  st? itemstable))
2ee0: 20 3b 3b 20 63 61 6c 63 20 6e 6f 77 0a 09 09 09   ;; calc now....
2ef0: 09 09 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ... (debug:print
2f00: 20 34 20 22 49 4e 46 4f 3a 20 69 74 65 6d 73 20   4 "INFO: items 
2f10: 61 6e 64 20 69 74 65 6d 73 74 61 62 6c 65 20 61  and itemstable a
2f20: 72 65 20 6c 69 73 74 73 2c 20 63 61 6c 63 20 6e  re lists, calc n
2f30: 6f 77 5c 6e 22 0a 09 09 09 09 09 09 09 20 20 20  ow\n"........   
2f40: 20 20 20 22 20 20 20 20 69 74 65 6d 73 3a 20 22     "    items: "
2f50: 20 69 74 65 6d 73 20 22 20 69 74 65 6d 73 74 61   items " itemsta
2f60: 62 6c 65 3a 20 22 20 69 74 65 6d 73 74 61 62 6c  ble: " itemstabl
2f70: 65 29 0a 09 09 09 09 09 09 20 28 69 74 65 6d 73  e)....... (items
2f80: 3a 67 65 74 2d 69 74 65 6d 73 2d 66 72 6f 6d 2d  :get-items-from-
2f90: 63 6f 6e 66 69 67 20 63 6f 6e 66 69 67 29 29 0a  config config)).
2fa0: 09 09 09 09 09 09 28 65 6c 73 65 20 23 66 29 29  ......(else #f))
2fb0: 29 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  )               
2fc0: 20 20 20 20 20 20 20 20 20 20 20 20 3b 3b 20 6e              ;; n
2fd0: 6f 74 20 69 74 65 72 61 74 65 64 0a 09 09 09 09  ot iterated.....
2fe0: 09 20 20 20 20 20 23 66 20 20 20 20 20 20 3b 3b  .     #f      ;;
2ff0: 20 69 74 65 6d 73 64 61 74 20 35 0a 09 09 09 09   itemsdat 5.....
3000: 09 20 20 20 20 20 23 66 20 20 20 20 20 20 3b 3b  .     #f      ;;
3010: 20 73 70 61 72 65 20 2d 20 75 73 65 64 20 66 6f   spare - used fo
3020: 72 20 69 74 65 6d 2d 70 61 74 68 0a 09 09 09 09  r item-path.....
3030: 09 20 20 20 20 20 29 29 29 0a 09 20 20 20 20 28  .     )))..    (
3040: 66 6f 72 2d 65 61 63 68 20 0a 09 20 20 20 20 20  for-each ..     
3050: 28 6c 61 6d 62 64 61 20 28 77 61 69 74 6f 6e 29  (lambda (waiton)
3060: 0a 09 20 20 20 20 20 20 20 28 69 66 20 28 61 6e  ..       (if (an
3070: 64 20 77 61 69 74 6f 6e 20 28 6e 6f 74 20 28 6d  d waiton (not (m
3080: 65 6d 62 65 72 20 77 61 69 74 6f 6e 20 74 65 73  ember waiton tes
3090: 74 2d 6e 61 6d 65 73 29 29 29 0a 09 09 20 20 20  t-names)))...   
30a0: 28 62 65 67 69 6e 0a 09 09 20 20 20 20 20 28 73  (begin...     (s
30b0: 65 74 21 20 72 65 71 75 69 72 65 64 2d 74 65 73  et! required-tes
30c0: 74 73 20 28 63 6f 6e 73 20 77 61 69 74 6f 6e 20  ts (cons waiton 
30d0: 72 65 71 75 69 72 65 64 2d 74 65 73 74 73 29 29  required-tests))
30e0: 0a 09 09 20 20 20 20 20 28 73 65 74 21 20 74 65  ...     (set! te
30f0: 73 74 2d 6e 61 6d 65 73 20 28 63 6f 6e 73 20 77  st-names (cons w
3100: 61 69 74 6f 6e 20 74 65 73 74 2d 6e 61 6d 65 73  aiton test-names
3110: 29 29 29 29 29 20 3b 3b 20 77 61 73 20 61 6e 20  ))))) ;; was an 
3120: 61 70 70 65 6e 64 2c 20 6e 6f 77 20 61 20 63 6f  append, now a co
3130: 6e 73 0a 09 20 20 20 20 20 77 61 69 74 6f 6e 73  ns..     waitons
3140: 29 0a 09 20 20 20 20 28 6c 65 74 20 28 28 72 65  )..    (let ((re
3150: 6d 74 65 73 74 73 20 28 64 65 6c 65 74 65 2d 64  mtests (delete-d
3160: 75 70 6c 69 63 61 74 65 73 20 28 61 70 70 65 6e  uplicates (appen
3170: 64 20 77 61 69 74 6f 6e 73 20 74 61 6c 29 29 29  d waitons tal)))
3180: 29 0a 09 20 20 20 20 20 20 28 69 66 20 28 6e 6f  )..      (if (no
3190: 74 20 28 6e 75 6c 6c 3f 20 72 65 6d 74 65 73 74  t (null? remtest
31a0: 73 29 29 0a 09 09 20 20 28 6c 6f 6f 70 20 28 63  s))...  (loop (c
31b0: 61 72 20 72 65 6d 74 65 73 74 73 29 28 63 64 72  ar remtests)(cdr
31c0: 20 72 65 6d 74 65 73 74 73 29 29 29 29 29 29 29   remtests)))))))
31d0: 0a 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28  ..    (if (not (
31e0: 6e 75 6c 6c 3f 20 72 65 71 75 69 72 65 64 2d 74  null? required-t
31f0: 65 73 74 73 29 29 0a 09 28 64 65 62 75 67 3a 70  ests))..(debug:p
3200: 72 69 6e 74 20 31 20 22 49 4e 46 4f 3a 20 41 64  rint 1 "INFO: Ad
3210: 64 69 6e 67 20 22 20 72 65 71 75 69 72 65 64 2d  ding " required-
3220: 74 65 73 74 73 20 22 20 74 6f 20 74 68 65 20 72  tests " to the r
3230: 75 6e 20 71 75 65 75 65 22 29 29 0a 20 20 20 20  un queue")).    
3240: 3b 3b 20 4e 4f 54 45 3a 20 74 68 65 73 65 20 61  ;; NOTE: these a
3250: 72 65 20 61 6c 6c 20 70 61 72 65 6e 74 20 74 65  re all parent te
3260: 73 74 73 2c 20 69 74 65 6d 73 20 61 72 65 20 6e  sts, items are n
3270: 6f 74 20 65 78 70 61 6e 64 65 64 20 79 65 74 2e  ot expanded yet.
3280: 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e  .    (debug:prin
3290: 74 20 34 20 22 49 4e 46 4f 3a 20 74 65 73 74 2d  t 4 "INFO: test-
32a0: 72 65 63 6f 72 64 73 3d 22 20 28 68 61 73 68 2d  records=" (hash-
32b0: 74 61 62 6c 65 2d 3e 61 6c 69 73 74 20 74 65 73  table->alist tes
32c0: 74 2d 72 65 63 6f 72 64 73 29 29 0a 20 20 20 20  t-records)).    
32d0: 28 72 75 6e 73 3a 72 75 6e 2d 74 65 73 74 73 2d  (runs:run-tests-
32e0: 71 75 65 75 65 20 72 75 6e 2d 69 64 20 72 75 6e  queue run-id run
32f0: 6e 61 6d 65 20 74 65 73 74 2d 72 65 63 6f 72 64  name test-record
3300: 73 20 6b 65 79 76 61 6c 6c 73 74 20 66 6c 61 67  s keyvallst flag
3310: 73 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72  s).    (debug:pr
3320: 69 6e 74 20 34 20 22 49 4e 46 4f 3a 20 41 6c 6c  int 4 "INFO: All
3330: 20 64 6f 6e 65 20 62 79 20 68 65 72 65 22 29 29   done by here"))
3340: 29 0a 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73  )..(define (runs
3350: 3a 63 61 6c 63 2d 66 61 69 6c 73 20 70 72 65 72  :calc-fails prer
3360: 65 71 73 2d 6e 6f 74 2d 6d 65 74 29 0a 20 20 28  eqs-not-met).  (
3370: 66 69 6c 74 65 72 20 28 6c 61 6d 62 64 61 20 28  filter (lambda (
3380: 74 65 73 74 29 0a 09 20 20 20 20 28 61 6e 64 20  test)..    (and 
3390: 28 76 65 63 74 6f 72 3f 20 74 65 73 74 29 20 3b  (vector? test) ;
33a0: 3b 20 6e 6f 74 20 28 73 74 72 69 6e 67 3f 20 74  ; not (string? t
33b0: 65 73 74 29 29 0a 09 09 20 28 65 71 75 61 6c 3f  est))... (equal?
33c0: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 73 74   (db:test-get-st
33d0: 61 74 65 20 74 65 73 74 29 20 22 43 4f 4d 50 4c  ate test) "COMPL
33e0: 45 54 45 44 22 29 0a 09 09 20 28 6e 6f 74 20 28  ETED")... (not (
33f0: 6d 65 6d 62 65 72 20 28 64 62 3a 74 65 73 74 2d  member (db:test-
3400: 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 29  get-status test)
3410: 0a 09 09 09 20 20 20 20 20 20 27 28 22 50 41 53  ....      '("PAS
3420: 53 22 20 22 57 41 52 4e 22 20 22 43 48 45 43 4b  S" "WARN" "CHECK
3430: 22 20 22 57 41 49 56 45 44 22 29 29 29 29 29 0a  " "WAIVED"))))).
3440: 09 20 20 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d  .  prereqs-not-m
3450: 65 74 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 72  et))..(define (r
3460: 75 6e 73 3a 63 61 6c 63 2d 6e 6f 74 2d 63 6f 6d  uns:calc-not-com
3470: 70 6c 65 74 65 64 20 70 72 65 72 65 71 73 2d 6e  pleted prereqs-n
3480: 6f 74 2d 6d 65 74 29 0a 20 20 28 66 69 6c 74 65  ot-met).  (filte
3490: 72 0a 20 20 20 28 6c 61 6d 62 64 61 20 28 74 29  r.   (lambda (t)
34a0: 0a 20 20 20 20 20 28 6f 72 20 28 6e 6f 74 20 28  .     (or (not (
34b0: 76 65 63 74 6f 72 3f 20 74 29 29 0a 09 20 28 6e  vector? t)).. (n
34c0: 6f 74 20 28 65 71 75 61 6c 3f 20 22 43 4f 4d 50  ot (equal? "COMP
34d0: 4c 45 54 45 44 22 20 28 64 62 3a 74 65 73 74 2d  LETED" (db:test-
34e0: 67 65 74 2d 73 74 61 74 65 20 74 29 29 29 29 29  get-state t)))))
34f0: 0a 20 20 20 70 72 65 72 65 71 73 2d 6e 6f 74 2d  .   prereqs-not-
3500: 6d 65 74 29 29 0a 0a 28 64 65 66 69 6e 65 20 28  met))..(define (
3510: 72 75 6e 73 3a 70 72 65 74 74 79 2d 73 74 72 69  runs:pretty-stri
3520: 6e 67 20 6c 73 74 29 0a 20 20 28 6d 61 70 20 28  ng lst).  (map (
3530: 6c 61 6d 62 64 61 20 28 74 29 0a 09 20 28 69 66  lambda (t).. (if
3540: 20 28 6e 6f 74 20 28 76 65 63 74 6f 72 3f 20 74   (not (vector? t
3550: 29 29 0a 09 20 20 20 20 20 28 63 6f 6e 63 20 74  ))..     (conc t
3560: 29 0a 09 20 20 20 20 20 28 63 6f 6e 63 20 28 64  )..     (conc (d
3570: 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e  b:test-get-testn
3580: 61 6d 65 20 74 29 20 22 3a 22 20 28 64 62 3a 74  ame t) ":" (db:t
3590: 65 73 74 2d 67 65 74 2d 73 74 61 74 65 20 74 29  est-get-state t)
35a0: 20 22 2f 22 20 28 64 62 3a 74 65 73 74 2d 67 65   "/" (db:test-ge
35b0: 74 2d 73 74 61 74 75 73 20 74 29 29 29 29 0a 20  t-status t)))). 
35c0: 20 20 20 20 20 20 6c 73 74 29 29 0a 0a 28 64 65        lst))..(de
35d0: 66 69 6e 65 20 28 72 75 6e 73 3a 6d 61 6b 65 2d  fine (runs:make-
35e0: 66 75 6c 6c 2d 74 65 73 74 2d 6e 61 6d 65 20 74  full-test-name t
35f0: 65 73 74 6e 61 6d 65 20 69 74 65 6d 70 61 74 68  estname itempath
3600: 29 0a 20 20 28 69 66 20 28 65 71 75 61 6c 3f 20  ).  (if (equal? 
3610: 69 74 65 6d 70 61 74 68 20 22 22 29 20 74 65 73  itempath "") tes
3620: 74 6e 61 6d 65 20 28 63 6f 6e 63 20 74 65 73 74  tname (conc test
3630: 6e 61 6d 65 20 22 2f 22 20 69 74 65 6d 70 61 74  name "/" itempat
3640: 68 29 29 29 0a 0a 3b 3b 20 74 65 73 74 2d 72 65  h)))..;; test-re
3650: 63 6f 72 64 73 20 69 73 20 61 20 68 61 73 68 20  cords is a hash 
3660: 74 61 62 6c 65 20 74 65 73 74 6e 61 6d 65 3a 69  table testname:i
3670: 74 65 6d 5f 70 61 74 68 20 3d 3e 20 76 65 63 74  tem_path => vect
3680: 6f 72 20 3c 20 74 65 73 74 6e 61 6d 65 20 74 65  or < testname te
3690: 73 74 63 6f 6e 66 69 67 20 77 61 69 74 6f 6e 73  stconfig waitons
36a0: 20 70 72 69 6f 72 69 74 79 20 69 74 65 6d 73 2d   priority items-
36b0: 69 6e 66 6f 20 2e 2e 2e 20 3e 0a 28 64 65 66 69  info ... >.(defi
36c0: 6e 65 20 28 72 75 6e 73 3a 72 75 6e 2d 74 65 73  ne (runs:run-tes
36d0: 74 73 2d 71 75 65 75 65 20 72 75 6e 2d 69 64 20  ts-queue run-id 
36e0: 72 75 6e 6e 61 6d 65 20 74 65 73 74 2d 72 65 63  runname test-rec
36f0: 6f 72 64 73 20 6b 65 79 76 61 6c 6c 73 74 20 66  ords keyvallst f
3700: 6c 61 67 73 29 0a 20 20 20 20 3b 3b 20 41 74 20  lags).    ;; At 
3710: 74 68 69 73 20 70 6f 69 6e 74 20 74 68 65 20 6c  this point the l
3720: 69 73 74 20 6f 66 20 70 61 72 65 6e 74 20 74 65  ist of parent te
3730: 73 74 73 20 69 73 20 65 78 70 61 6e 64 65 64 20  sts is expanded 
3740: 0a 20 20 20 20 3b 3b 20 4e 42 2f 2f 20 53 68 6f  .    ;; NB// Sho
3750: 75 6c 64 20 65 78 70 61 6e 64 20 69 74 65 6d 73  uld expand items
3760: 20 68 65 72 65 20 61 6e 64 20 74 68 65 6e 20 69   here and then i
3770: 6e 73 65 72 74 20 69 6e 74 6f 20 74 68 65 20 72  nsert into the r
3780: 75 6e 20 71 75 65 75 65 2e 0a 20 20 28 64 65 62  un queue..  (deb
3790: 75 67 3a 70 72 69 6e 74 20 35 20 22 74 65 73 74  ug:print 5 "test
37a0: 2d 72 65 63 6f 72 64 73 3a 20 22 20 74 65 73 74  -records: " test
37b0: 2d 72 65 63 6f 72 64 73 20 22 2c 20 6b 65 79 76  -records ", keyv
37c0: 61 6c 6c 73 74 3a 20 22 20 6b 65 79 76 61 6c 6c  allst: " keyvall
37d0: 73 74 20 22 20 66 6c 61 67 73 3a 20 22 20 28 68  st " flags: " (h
37e0: 61 73 68 2d 74 61 62 6c 65 2d 3e 61 6c 69 73 74  ash-table->alist
37f0: 20 66 6c 61 67 73 29 29 0a 20 20 28 6c 65 74 20   flags)).  (let 
3800: 28 28 73 6f 72 74 65 64 2d 74 65 73 74 2d 6e 61  ((sorted-test-na
3810: 6d 65 73 20 28 74 65 73 74 73 3a 73 6f 72 74 2d  mes (tests:sort-
3820: 62 79 2d 70 72 69 6f 72 69 74 79 2d 61 6e 64 2d  by-priority-and-
3830: 77 61 69 74 6f 6e 20 74 65 73 74 2d 72 65 63 6f  waiton test-reco
3840: 72 64 73 29 29 0a 09 28 69 74 65 6d 2d 70 61 74  rds))..(item-pat
3850: 74 73 20 20 20 20 20 20 20 20 28 68 61 73 68 2d  ts        (hash-
3860: 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c  table-ref/defaul
3870: 74 20 66 6c 61 67 73 20 22 2d 69 74 65 6d 70 61  t flags "-itempa
3880: 74 74 22 20 23 66 29 29 0a 09 28 74 65 73 74 2d  tt" #f))..(test-
3890: 72 65 67 69 73 74 65 72 79 20 20 20 20 28 6d 61  registery    (ma
38a0: 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29 0a  ke-hash-table)).
38b0: 09 28 6e 75 6d 2d 72 65 74 72 69 65 73 20 20 20  .(num-retries   
38c0: 20 20 20 20 20 30 29 0a 09 28 6d 61 78 2d 72 65       0)..(max-re
38d0: 74 72 69 65 73 20 20 20 20 20 20 20 28 63 6f 6e  tries       (con
38e0: 66 69 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66  fig-lookup *conf
38f0: 69 67 64 61 74 2a 20 22 73 65 74 75 70 22 20 22  igdat* "setup" "
3900: 6d 61 78 72 65 74 72 69 65 73 22 29 29 29 0a 20  maxretries"))). 
3910: 20 20 20 28 73 65 74 21 20 6d 61 78 2d 72 65 74     (set! max-ret
3920: 72 69 65 73 20 28 69 66 20 28 61 6e 64 20 6d 61  ries (if (and ma
3930: 78 2d 72 65 74 72 69 65 73 20 28 73 74 72 69 6e  x-retries (strin
3940: 67 2d 3e 6e 75 6d 62 65 72 20 6d 61 78 2d 72 65  g->number max-re
3950: 74 72 69 65 73 29 29 28 73 74 72 69 6e 67 2d 3e  tries))(string->
3960: 6e 75 6d 62 65 72 20 6d 61 78 2d 72 65 74 72 69  number max-retri
3970: 65 73 29 20 31 30 30 29 29 0a 20 20 20 20 28 69  es) 100)).    (i
3980: 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 73 6f  f (not (null? so
3990: 72 74 65 64 2d 74 65 73 74 2d 6e 61 6d 65 73 29  rted-test-names)
39a0: 29 0a 09 28 6c 65 74 20 6c 6f 6f 70 20 28 28 68  )..(let loop ((h
39b0: 65 64 20 20 20 20 20 20 20 20 20 28 63 61 72 20  ed         (car 
39c0: 73 6f 72 74 65 64 2d 74 65 73 74 2d 6e 61 6d 65  sorted-test-name
39d0: 73 29 29 0a 09 09 20 20 20 28 74 61 6c 20 20 20  s))...   (tal   
39e0: 20 20 20 20 20 20 28 63 64 72 20 73 6f 72 74 65        (cdr sorte
39f0: 64 2d 74 65 73 74 2d 6e 61 6d 65 73 29 29 0a 09  d-test-names))..
3a00: 09 20 20 20 28 72 65 72 75 6e 73 20 20 20 20 20  .   (reruns     
3a10: 20 27 28 29 29 29 0a 09 20 20 28 69 66 20 28 6e   '()))..  (if (n
3a20: 6f 74 20 28 6e 75 6c 6c 3f 20 72 65 72 75 6e 73  ot (null? reruns
3a30: 29 29 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34  ))(debug:print 4
3a40: 20 22 49 4e 46 4f 3a 20 72 65 72 75 6e 73 3d 22   "INFO: reruns="
3a50: 20 72 65 72 75 6e 73 29 29 0a 09 20 20 3b 3b 20   reruns))..  ;; 
3a60: 28 70 72 69 6e 74 20 22 54 6f 70 20 6f 66 20 6c  (print "Top of l
3a70: 6f 6f 70 2c 20 68 65 64 3d 22 20 68 65 64 20 22  oop, hed=" hed "
3a80: 2c 20 74 61 6c 3d 22 20 74 61 6c 20 22 20 2c 72  , tal=" tal " ,r
3a90: 65 72 75 6e 73 3d 22 20 72 65 72 75 6e 73 29 0a  eruns=" reruns).
3aa0: 09 20 20 28 6c 65 74 2a 20 28 28 74 65 73 74 2d  .  (let* ((test-
3ab0: 72 65 63 6f 72 64 20 28 68 61 73 68 2d 74 61 62  record (hash-tab
3ac0: 6c 65 2d 72 65 66 20 74 65 73 74 2d 72 65 63 6f  le-ref test-reco
3ad0: 72 64 73 20 68 65 64 29 29 0a 09 09 20 28 74 65  rds hed))... (te
3ae0: 73 74 2d 6e 61 6d 65 20 20 20 28 74 65 73 74 73  st-name   (tests
3af0: 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d 74  :testqueue-get-t
3b00: 65 73 74 6e 61 6d 65 20 74 65 73 74 2d 72 65 63  estname test-rec
3b10: 6f 72 64 29 29 0a 09 09 20 28 74 63 6f 6e 66 69  ord))... (tconfi
3b20: 67 20 20 20 20 20 28 74 65 73 74 73 3a 74 65 73  g     (tests:tes
3b30: 74 71 75 65 75 65 2d 67 65 74 2d 74 65 73 74 63  tqueue-get-testc
3b40: 6f 6e 66 69 67 20 74 65 73 74 2d 72 65 63 6f 72  onfig test-recor
3b50: 64 29 29 0a 09 09 20 28 74 65 73 74 6d 6f 64 65  d))... (testmode
3b60: 20 20 20 20 28 6c 65 74 20 28 28 6d 20 28 63 6f      (let ((m (co
3b70: 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 74 63 6f 6e  nfig-lookup tcon
3b80: 66 69 67 20 22 72 65 71 75 69 72 65 6d 65 6e 74  fig "requirement
3b90: 73 22 20 22 6d 6f 64 65 22 29 29 29 0a 09 09 09  s" "mode")))....
3ba0: 09 28 69 66 20 6d 20 28 73 74 72 69 6e 67 2d 3e  .(if m (string->
3bb0: 73 79 6d 62 6f 6c 20 6d 29 20 27 6e 6f 72 6d 61  symbol m) 'norma
3bc0: 6c 29 29 29 0a 09 09 20 28 77 61 69 74 6f 6e 73  l)))... (waitons
3bd0: 20 20 20 20 20 28 74 65 73 74 73 3a 74 65 73 74       (tests:test
3be0: 71 75 65 75 65 2d 67 65 74 2d 77 61 69 74 6f 6e  queue-get-waiton
3bf0: 73 20 20 20 20 74 65 73 74 2d 72 65 63 6f 72 64  s    test-record
3c00: 29 29 0a 09 09 20 28 70 72 69 6f 72 69 74 79 20  ))... (priority 
3c10: 20 20 20 28 74 65 73 74 73 3a 74 65 73 74 71 75     (tests:testqu
3c20: 65 75 65 2d 67 65 74 2d 70 72 69 6f 72 69 74 79  eue-get-priority
3c30: 20 20 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29     test-record))
3c40: 0a 09 09 20 28 69 74 65 6d 64 61 74 20 20 20 20  ... (itemdat    
3c50: 20 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75   (tests:testqueu
3c60: 65 2d 67 65 74 2d 69 74 65 6d 64 61 74 20 20 20  e-get-itemdat   
3c70: 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29 20 3b   test-record)) ;
3c80: 3b 20 69 74 65 6d 64 61 74 20 63 61 6e 20 62 65  ; itemdat can be
3c90: 20 61 20 73 74 72 69 6e 67 2c 20 6c 69 73 74 20   a string, list 
3ca0: 6f 72 20 23 66 0a 09 09 20 28 69 74 65 6d 73 20  or #f... (items 
3cb0: 20 20 20 20 20 20 28 74 65 73 74 73 3a 74 65 73        (tests:tes
3cc0: 74 71 75 65 75 65 2d 67 65 74 2d 69 74 65 6d 73  tqueue-get-items
3cd0: 20 20 20 20 20 20 74 65 73 74 2d 72 65 63 6f 72        test-recor
3ce0: 64 29 29 0a 09 09 20 28 69 74 65 6d 2d 70 61 74  d))... (item-pat
3cf0: 68 20 20 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e  h   (item-list->
3d00: 70 61 74 68 20 69 74 65 6d 64 61 74 29 29 0a 09  path itemdat))..
3d10: 09 20 28 6e 65 77 74 61 6c 20 20 20 20 20 20 28  . (newtal      (
3d20: 61 70 70 65 6e 64 20 74 61 6c 20 28 6c 69 73 74  append tal (list
3d30: 20 68 65 64 29 29 29 29 0a 09 20 20 20 20 0a 09   hed))))..    ..
3d40: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
3d50: 20 36 0a 09 09 09 20 22 74 65 73 74 2d 6e 61 6d   6.... "test-nam
3d60: 65 3a 20 22 20 74 65 73 74 2d 6e 61 6d 65 0a 09  e: " test-name..
3d70: 09 09 20 22 5c 6e 20 20 68 65 64 3a 20 20 20 20  .. "\n  hed:    
3d80: 20 20 20 20 20 22 20 68 65 64 0a 09 09 09 20 22       " hed.... "
3d90: 5c 6e 20 20 69 74 65 6d 64 61 74 3a 20 20 20 20  \n  itemdat:    
3da0: 20 22 20 69 74 65 6d 64 61 74 0a 09 09 09 20 22   " itemdat.... "
3db0: 5c 6e 20 20 69 74 65 6d 73 3a 20 20 20 20 20 20  \n  items:      
3dc0: 20 22 20 69 74 65 6d 73 0a 09 09 09 20 22 5c 6e   " items.... "\n
3dd0: 20 20 69 74 65 6d 2d 70 61 74 68 3a 20 20 20 22    item-path:   "
3de0: 20 69 74 65 6d 2d 70 61 74 68 0a 09 09 09 20 22   item-path.... "
3df0: 5c 6e 20 20 77 61 69 74 6f 6e 73 3a 20 20 20 20  \n  waitons:    
3e00: 20 22 20 77 61 69 74 6f 6e 73 0a 09 09 09 20 22   " waitons.... "
3e10: 5c 6e 20 20 6e 75 6d 2d 72 65 74 72 69 65 73 3a  \n  num-retries:
3e20: 20 22 20 6e 75 6d 2d 72 65 74 72 69 65 73 0a 09   " num-retries..
3e30: 09 09 20 22 5c 6e 20 20 74 61 6c 3a 20 20 20 20  .. "\n  tal:    
3e40: 20 20 20 20 20 22 20 74 61 6c 0a 09 09 09 20 22       " tal.... "
3e50: 5c 6e 20 20 72 65 72 75 6e 73 3a 20 20 20 20 20  \n  reruns:     
3e60: 20 22 20 72 65 72 75 6e 73 29 0a 0a 09 20 20 20   " reruns)...   
3e70: 20 3b 3b 20 63 68 65 63 6b 20 66 6f 72 20 68 65   ;; check for he
3e80: 64 20 69 6e 20 77 61 69 74 6f 6e 73 20 3d 3e 20  d in waitons => 
3e90: 74 68 69 73 20 77 6f 75 6c 64 20 62 65 20 63 69  this would be ci
3ea0: 72 63 75 6c 61 72 2c 20 72 65 6d 6f 76 65 20 69  rcular, remove i
3eb0: 74 20 61 6e 64 20 69 73 73 75 65 20 61 6e 0a 09  t and issue an..
3ec0: 20 20 20 20 3b 3b 20 65 72 72 6f 72 0a 09 20 20      ;; error..  
3ed0: 20 20 28 69 66 20 28 6d 65 6d 62 65 72 20 74 65    (if (member te
3ee0: 73 74 2d 6e 61 6d 65 20 77 61 69 74 6f 6e 73 29  st-name waitons)
3ef0: 0a 09 09 28 62 65 67 69 6e 0a 09 09 20 20 28 64  ...(begin...  (d
3f00: 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52  ebug:print 0 "ER
3f10: 52 4f 52 3a 20 74 65 73 74 20 22 20 74 65 73 74  ROR: test " test
3f20: 2d 6e 61 6d 65 20 22 20 68 61 73 20 6c 69 73 74  -name " has list
3f30: 65 64 20 69 74 73 65 6c 66 20 61 73 20 61 20 77  ed itself as a w
3f40: 61 69 74 6f 6e 2c 20 70 6c 65 61 73 65 20 63 6f  aiton, please co
3f50: 72 72 65 63 74 20 74 68 69 73 21 22 29 0a 09 09  rrect this!")...
3f60: 20 20 28 73 65 74 21 20 77 61 69 74 6f 6e 20 28    (set! waiton (
3f70: 66 69 6c 74 65 72 20 28 6c 61 6d 62 64 61 20 28  filter (lambda (
3f80: 78 29 28 6e 6f 74 20 28 65 71 75 61 6c 3f 20 78  x)(not (equal? x
3f90: 20 68 65 64 29 29 29 20 77 61 69 74 6f 6e 73 29   hed))) waitons)
3fa0: 29 29 29 0a 0a 09 20 20 20 20 28 63 6f 6e 64 20  )))...    (cond 
3fb0: 3b 3b 20 4f 55 54 45 52 20 43 4f 4e 44 0a 09 20  ;; OUTER COND.. 
3fc0: 20 20 20 20 28 28 6e 6f 74 20 69 74 65 6d 73 29      ((not items)
3fd0: 20 3b 3b 20 77 68 65 6e 20 66 61 6c 73 65 20 74   ;; when false t
3fe0: 68 65 20 74 65 73 74 20 69 73 20 6f 6b 20 74 6f  he test is ok to
3ff0: 20 62 65 20 68 61 6e 64 65 64 20 6f 66 66 20 74   be handed off t
4000: 6f 20 6c 61 75 6e 63 68 20 28 62 75 74 20 6e 6f  o launch (but no
4010: 74 20 62 65 66 6f 72 65 29 0a 09 20 20 20 20 20  t before)..     
4020: 20 28 6c 65 74 2a 20 28 28 68 61 76 65 2d 72 65   (let* ((have-re
4030: 73 6f 75 72 63 65 73 20 20 28 6f 70 65 6e 2d 72  sources  (open-r
4040: 75 6e 2d 63 6c 6f 73 65 20 72 75 6e 73 3a 63 61  un-close runs:ca
4050: 6e 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73  n-run-more-tests
4060: 20 23 66 20 74 65 73 74 2d 72 65 63 6f 72 64 29   #f test-record)
4070: 29 20 3b 3b 20 6c 6f 6f 6b 20 61 74 20 74 68 65  ) ;; look at the
4080: 20 74 65 73 74 20 6a 6f 62 67 72 6f 75 70 20 61   test jobgroup a
4090: 6e 64 20 74 6f 74 20 6a 6f 62 73 20 72 75 6e 6e  nd tot jobs runn
40a0: 69 6e 67 0a 09 09 20 20 20 20 20 28 70 72 65 72  ing...     (prer
40b0: 65 71 73 2d 6e 6f 74 2d 6d 65 74 20 28 6f 70 65  eqs-not-met (ope
40c0: 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 64 62 3a 67  n-run-close db:g
40d0: 65 74 2d 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d  et-prereqs-not-m
40e0: 65 74 20 23 66 20 72 75 6e 2d 69 64 20 77 61 69  et #f run-id wai
40f0: 74 6f 6e 73 20 69 74 65 6d 2d 70 61 74 68 20 6d  tons item-path m
4100: 6f 64 65 3a 20 74 65 73 74 6d 6f 64 65 29 29 0a  ode: testmode)).
4110: 09 09 20 20 20 20 20 28 66 61 69 6c 73 20 20 20  ..     (fails   
4120: 20 20 20 20 20 20 20 20 28 72 75 6e 73 3a 63 61          (runs:ca
4130: 6c 63 2d 66 61 69 6c 73 20 70 72 65 72 65 71 73  lc-fails prereqs
4140: 2d 6e 6f 74 2d 6d 65 74 29 29 0a 09 09 20 20 20  -not-met))...   
4150: 20 20 28 6e 6f 6e 2d 63 6f 6d 70 6c 65 74 65 64    (non-completed
4160: 20 20 20 28 72 75 6e 73 3a 63 61 6c 63 2d 6e 6f     (runs:calc-no
4170: 74 2d 63 6f 6d 70 6c 65 74 65 64 20 70 72 65 72  t-completed prer
4180: 65 71 73 2d 6e 6f 74 2d 6d 65 74 29 29 29 0a 09  eqs-not-met)))..
4190: 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20 38 20  .(debug:print 8 
41a0: 22 49 4e 46 4f 3a 20 68 61 76 65 2d 72 65 73 6f  "INFO: have-reso
41b0: 75 72 63 65 73 3a 20 22 20 68 61 76 65 2d 72 65  urces: " have-re
41c0: 73 6f 75 72 63 65 73 20 22 20 70 72 65 72 65 71  sources " prereq
41d0: 73 2d 6e 6f 74 2d 6d 65 74 3a 20 22 20 0a 09 09  s-not-met: " ...
41e0: 09 20 20 20 20 20 28 73 74 72 69 6e 67 2d 69 6e  .     (string-in
41f0: 74 65 72 73 70 65 72 73 65 20 0a 09 09 09 20 20  tersperse ....  
4200: 20 20 20 20 28 6d 61 70 20 28 6c 61 6d 62 64 61      (map (lambda
4210: 20 28 74 29 0a 09 09 09 09 20 20 20 20 20 28 69   (t).....     (i
4220: 66 20 28 76 65 63 74 6f 72 3f 20 74 29 0a 09 09  f (vector? t)...
4230: 09 09 09 20 28 63 6f 6e 63 20 28 64 62 3a 74 65  ... (conc (db:te
4240: 73 74 2d 67 65 74 2d 73 74 61 74 65 20 74 29 20  st-get-state t) 
4250: 22 2f 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74  "/" (db:test-get
4260: 2d 73 74 61 74 75 73 20 74 29 29 0a 09 09 09 09  -status t)).....
4270: 09 20 28 63 6f 6e 63 20 22 20 57 41 52 4e 49 4e  . (conc " WARNIN
4280: 47 3a 20 74 20 69 73 20 6e 6f 74 20 61 20 76 65  G: t is not a ve
4290: 63 74 6f 72 3d 22 20 74 20 29 29 29 0a 09 09 09  ctor=" t )))....
42a0: 09 20 20 20 70 72 65 72 65 71 73 2d 6e 6f 74 2d  .   prereqs-not-
42b0: 6d 65 74 29 20 22 2c 20 22 29 20 22 20 66 61 69  met) ", ") " fai
42c0: 6c 73 3a 20 22 20 66 61 69 6c 73 29 0a 09 09 28  ls: " fails)...(
42d0: 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 49  debug:print 4 "I
42e0: 4e 46 4f 3a 20 68 65 64 3d 22 20 68 65 64 29 0a  NFO: hed=" hed).
42f0: 0a 09 09 3b 3b 20 44 6f 6e 27 74 20 6b 6e 6f 77  ...;; Don't know
4300: 20 61 74 20 74 68 69 73 20 74 69 6d 65 20 69 66   at this time if
4310: 20 74 68 65 20 74 65 73 74 20 68 61 76 65 20 62   the test have b
4320: 65 65 6e 20 6c 61 75 6e 63 68 65 64 20 61 74 20  een launched at 
4330: 73 6f 6d 65 20 74 69 6d 65 20 69 6e 20 74 68 65  some time in the
4340: 20 70 61 73 74 0a 09 09 3b 3b 20 69 2e 65 2e 20   past...;; i.e. 
4350: 69 73 20 74 68 69 73 20 61 20 72 65 2d 6c 61 75  is this a re-lau
4360: 6e 63 68 3f 0a 0a 09 09 28 63 6f 6e 64 20 3b 3b  nch?....(cond ;;
4370: 20 49 4e 4e 45 52 20 43 4f 4e 44 20 23 31 20 66   INNER COND #1 f
4380: 6f 72 20 61 20 6c 61 75 6e 63 68 61 62 6c 65 20  or a launchable 
4390: 74 65 73 74 0a 09 09 20 3b 3b 20 43 68 65 63 6b  test... ;; Check
43a0: 20 69 74 65 6d 20 70 61 74 68 20 61 67 61 69 6e   item path again
43b0: 73 74 20 69 74 65 6d 2d 70 61 74 74 73 0a 09 09  st item-patts...
43c0: 20 28 28 61 6e 64 20 28 6e 6f 74 20 28 70 61 74   ((and (not (pat
43d0: 74 2d 6c 69 73 74 2d 6d 61 74 63 68 20 69 74 65  t-list-match ite
43e0: 6d 2d 70 61 74 68 20 69 74 65 6d 2d 70 61 74 74  m-path item-patt
43f0: 73 29 29 0a 09 09 20 20 20 20 20 20 20 28 6e 6f  s))...       (no
4400: 74 20 28 65 71 75 61 6c 3f 20 69 74 65 6d 2d 70  t (equal? item-p
4410: 61 74 68 20 22 22 29 29 29 0a 09 09 20 20 3b 3b  ath "")))...  ;;
4420: 20 65 6c 73 65 20 74 68 65 20 72 75 6e 20 69 73   else the run is
4430: 20 73 74 75 63 6b 2c 20 74 65 6d 70 6f 72 61 72   stuck, temporar
4440: 69 6c 79 20 6f 72 20 70 65 72 6d 61 6e 65 6e 74  ily or permanent
4450: 6c 79 0a 09 09 20 20 3b 3b 20 62 75 74 20 73 68  ly...  ;; but sh
4460: 6f 75 6c 64 20 63 68 65 63 6b 20 69 66 20 69 74  ould check if it
4470: 20 69 73 20 64 75 65 20 74 6f 20 6c 61 63 6b 20   is due to lack 
4480: 6f 66 20 72 65 73 6f 75 72 63 65 73 20 76 73 2e  of resources vs.
4490: 20 70 72 65 72 65 71 75 69 73 69 74 65 73 0a 09   prerequisites..
44a0: 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20  .  (debug:print 
44b0: 31 20 22 49 4e 46 4f 3a 20 53 6b 69 70 70 69 6e  1 "INFO: Skippin
44c0: 67 20 22 20 28 74 65 73 74 73 3a 74 65 73 74 71  g " (tests:testq
44d0: 75 65 75 65 2d 67 65 74 2d 74 65 73 74 6e 61 6d  ueue-get-testnam
44e0: 65 20 74 65 73 74 2d 72 65 63 6f 72 64 29 20 22  e test-record) "
44f0: 20 22 20 69 74 65 6d 2d 70 61 74 68 20 22 20 61   " item-path " a
4500: 73 20 69 74 20 64 6f 65 73 6e 27 74 20 6d 61 74  s it doesn't mat
4510: 63 68 20 22 20 69 74 65 6d 2d 70 61 74 74 73 29  ch " item-patts)
4520: 0a 09 09 20 20 28 74 68 72 65 61 64 2d 73 6c 65  ...  (thread-sle
4530: 65 70 21 20 2a 67 6c 6f 62 61 6c 2d 64 65 6c 74  ep! *global-delt
4540: 61 2a 29 0a 09 09 20 20 28 69 66 20 28 6e 6f 74  a*)...  (if (not
4550: 20 28 6e 75 6c 6c 3f 20 74 61 6c 29 29 0a 09 09   (null? tal))...
4560: 20 20 20 20 20 20 28 6c 6f 6f 70 20 28 63 61 72        (loop (car
4570: 20 74 61 6c 29 28 63 64 72 20 74 61 6c 29 20 72   tal)(cdr tal) r
4580: 65 72 75 6e 73 29 29 29 0a 09 09 20 28 28 6e 6f  eruns)))... ((no
4590: 74 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65  t (hash-table-re
45a0: 66 2f 64 65 66 61 75 6c 74 20 74 65 73 74 2d 72  f/default test-r
45b0: 65 67 69 73 74 65 72 79 20 28 72 75 6e 73 3a 6d  egistery (runs:m
45c0: 61 6b 65 2d 66 75 6c 6c 2d 74 65 73 74 2d 6e 61  ake-full-test-na
45d0: 6d 65 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65  me test-name ite
45e0: 6d 2d 70 61 74 68 29 20 23 66 29 29 0a 09 09 20  m-path) #f))... 
45f0: 20 3b 3b 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c   ;; (open-run-cl
4600: 6f 73 65 20 64 62 3a 74 65 73 74 73 2d 72 65 67  ose db:tests-reg
4610: 69 73 74 65 72 2d 74 65 73 74 20 23 66 20 72 75  ister-test #f ru
4620: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69  n-id test-name i
4630: 74 65 6d 2d 70 61 74 68 29 0a 09 09 20 20 28 72  tem-path)...  (r
4640: 64 62 3a 74 65 73 74 73 2d 72 65 67 69 73 74 65  db:tests-registe
4650: 72 2d 74 65 73 74 20 72 75 6e 2d 69 64 20 74 65  r-test run-id te
4660: 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74  st-name item-pat
4670: 68 29 0a 09 09 20 20 28 72 64 62 3a 66 6c 75 73  h)...  (rdb:flus
4680: 68 2d 71 75 65 75 65 29 0a 09 09 20 20 28 68 61  h-queue)...  (ha
4690: 73 68 2d 74 61 62 6c 65 2d 73 65 74 21 20 74 65  sh-table-set! te
46a0: 73 74 2d 72 65 67 69 73 74 65 72 79 20 28 72 75  st-registery (ru
46b0: 6e 73 3a 6d 61 6b 65 2d 66 75 6c 6c 2d 74 65 73  ns:make-full-tes
46c0: 74 2d 6e 61 6d 65 20 74 65 73 74 2d 6e 61 6d 65  t-name test-name
46d0: 20 69 74 65 6d 2d 70 61 74 68 29 20 23 74 29 0a   item-path) #t).
46e0: 09 09 20 20 28 74 68 72 65 61 64 2d 73 6c 65 65  ..  (thread-slee
46f0: 70 21 20 2a 67 6c 6f 62 61 6c 2d 64 65 6c 74 61  p! *global-delta
4700: 2a 29 0a 09 09 20 20 28 6c 6f 6f 70 20 28 63 61  *)...  (loop (ca
4710: 72 20 6e 65 77 74 61 6c 29 28 63 64 72 20 6e 65  r newtal)(cdr ne
4720: 77 74 61 6c 29 20 72 65 72 75 6e 73 29 29 0a 09  wtal) reruns))..
4730: 09 20 28 28 6e 6f 74 20 68 61 76 65 2d 72 65 73  . ((not have-res
4740: 6f 75 72 63 65 73 29 20 3b 3b 20 73 69 6d 70 6c  ources) ;; simpl
4750: 79 20 74 72 79 20 61 67 61 69 6e 20 61 66 74 65  y try again afte
4760: 72 20 77 61 69 74 69 6e 67 20 61 20 73 65 63 6f  r waiting a seco
4770: 6e 64 0a 09 09 20 20 28 74 68 72 65 61 64 2d 73  nd...  (thread-s
4780: 6c 65 65 70 21 20 28 2b 20 31 20 2a 67 6c 6f 62  leep! (+ 1 *glob
4790: 61 6c 2d 64 65 6c 74 61 2a 29 29 0a 09 09 20 20  al-delta*))...  
47a0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22  (debug:print 1 "
47b0: 49 4e 46 4f 3a 20 6e 6f 20 72 65 73 6f 75 72 63  INFO: no resourc
47c0: 65 73 20 74 6f 20 72 75 6e 20 6e 65 77 20 74 65  es to run new te
47d0: 73 74 73 2c 20 77 61 69 74 69 6e 67 20 2e 2e 2e  sts, waiting ...
47e0: 22 29 0a 09 09 20 20 3b 3b 20 63 6f 75 6c 64 20  ")...  ;; could 
47f0: 68 61 76 65 20 64 6f 6e 65 20 68 65 64 20 74 61  have done hed ta
4800: 6c 20 68 65 72 65 20 62 75 74 20 64 6f 69 6e 67  l here but doing
4810: 20 63 61 72 2f 63 64 72 20 6f 66 20 6e 65 77 74   car/cdr of newt
4820: 61 6c 20 74 6f 20 72 6f 74 61 74 65 20 74 65 73  al to rotate tes
4830: 74 73 0a 09 09 20 20 28 6c 6f 6f 70 20 28 63 61  ts...  (loop (ca
4840: 72 20 6e 65 77 74 61 6c 29 28 63 64 72 20 6e 65  r newtal)(cdr ne
4850: 77 74 61 6c 29 20 72 65 72 75 6e 73 29 29 0a 09  wtal) reruns))..
4860: 09 20 28 28 61 6e 64 20 68 61 76 65 2d 72 65 73  . ((and have-res
4870: 6f 75 72 63 65 73 0a 09 09 20 20 20 20 20 20 20  ources...       
4880: 28 6f 72 20 28 6e 75 6c 6c 3f 20 70 72 65 72 65  (or (null? prere
4890: 71 73 2d 6e 6f 74 2d 6d 65 74 29 0a 09 09 09 20  qs-not-met).... 
48a0: 20 20 28 61 6e 64 20 28 65 71 3f 20 74 65 73 74    (and (eq? test
48b0: 6d 6f 64 65 20 27 74 6f 70 6c 65 76 65 6c 29 0a  mode 'toplevel).
48c0: 09 09 09 09 28 6e 75 6c 6c 3f 20 6e 6f 6e 2d 63  ....(null? non-c
48d0: 6f 6d 70 6c 65 74 65 64 29 29 29 29 0a 09 09 20  ompleted))))... 
48e0: 20 28 72 75 6e 3a 74 65 73 74 20 72 75 6e 2d 69   (run:test run-i
48f0: 64 20 72 75 6e 6e 61 6d 65 20 6b 65 79 76 61 6c  d runname keyval
4900: 6c 73 74 20 74 65 73 74 2d 72 65 63 6f 72 64 20  lst test-record 
4910: 66 6c 61 67 73 20 23 66 29 0a 09 09 20 20 28 74  flags #f)...  (t
4920: 68 72 65 61 64 2d 73 6c 65 65 70 21 20 2a 67 6c  hread-sleep! *gl
4930: 6f 62 61 6c 2d 64 65 6c 74 61 2a 29 0a 09 09 20  obal-delta*)... 
4940: 20 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f   (if (not (null?
4950: 20 74 61 6c 29 29 0a 09 09 20 20 20 20 20 20 28   tal))...      (
4960: 6c 6f 6f 70 20 28 63 61 72 20 74 61 6c 29 28 63  loop (car tal)(c
4970: 64 72 20 74 61 6c 29 20 72 65 72 75 6e 73 29 29  dr tal) reruns))
4980: 29 0a 09 09 20 28 65 6c 73 65 20 3b 3b 20 6d 75  )... (else ;; mu
4990: 73 74 20 62 65 20 77 65 20 68 61 76 65 20 75 6e  st be we have un
49a0: 6d 65 74 20 70 72 65 72 65 71 75 69 73 69 74 65  met prerequisite
49b0: 73 0a 09 09 20 20 20 20 28 64 65 62 75 67 3a 70  s...    (debug:p
49c0: 72 69 6e 74 20 34 20 22 46 41 49 4c 53 3a 20 22  rint 4 "FAILS: "
49d0: 20 66 61 69 6c 73 29 0a 09 09 20 20 20 20 3b 3b   fails)...    ;;
49e0: 20 49 66 20 6f 6e 65 20 6f 72 20 6d 6f 72 65 20   If one or more 
49f0: 6f 66 20 74 68 65 20 70 72 65 72 65 71 73 2d 6e  of the prereqs-n
4a00: 6f 74 2d 6d 65 74 20 61 72 65 20 46 41 49 4c 20  ot-met are FAIL 
4a10: 74 68 65 6e 20 77 65 20 63 61 6e 20 69 73 73 75  then we can issu
4a20: 65 0a 09 09 20 20 20 20 3b 3b 20 61 20 6d 65 73  e...    ;; a mes
4a30: 73 61 67 65 20 61 6e 64 20 64 72 6f 70 20 68 65  sage and drop he
4a40: 64 20 66 72 6f 6d 20 74 68 65 20 69 74 65 6d 73  d from the items
4a50: 20 74 6f 20 62 65 20 70 72 6f 63 65 73 73 65 64   to be processed
4a60: 2e 0a 09 09 20 20 20 20 28 69 66 20 28 6e 75 6c  ....    (if (nul
4a70: 6c 3f 20 66 61 69 6c 73 29 0a 09 09 09 28 62 65  l? fails)....(be
4a80: 67 69 6e 0a 09 09 09 20 20 3b 3b 20 63 6f 75 6c  gin....  ;; coul
4a90: 64 6e 27 74 20 72 75 6e 2c 20 74 61 6b 65 20 61  dn't run, take a
4aa0: 20 62 72 65 61 74 68 65 72 0a 09 09 09 20 20 28   breather....  (
4ab0: 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 49  debug:print 4 "I
4ac0: 4e 46 4f 3a 20 53 68 6f 75 6c 64 6e 27 74 20 72  NFO: Shouldn't r
4ad0: 65 61 6c 6c 79 20 67 65 74 20 68 65 72 65 2c 20  eally get here, 
4ae0: 72 61 63 65 20 63 6f 6e 64 69 74 69 6f 6e 3f 20  race condition? 
4af0: 55 6e 61 62 6c 65 20 74 6f 20 6c 61 75 6e 63 68  Unable to launch
4b00: 20 6d 6f 72 65 20 74 65 73 74 73 20 61 74 20 74   more tests at t
4b10: 68 69 73 20 6d 6f 6d 65 6e 74 2c 20 6b 69 6c 6c  his moment, kill
4b20: 69 6e 67 20 74 69 6d 65 20 2e 2e 2e 22 29 0a 09  ing time ...")..
4b30: 09 09 20 20 28 74 68 72 65 61 64 2d 73 6c 65 65  ..  (thread-slee
4b40: 70 21 20 28 2b 20 31 20 2a 67 6c 6f 62 61 6c 2d  p! (+ 1 *global-
4b50: 64 65 6c 74 61 2a 29 29 20 3b 3b 20 6c 6f 6e 67  delta*)) ;; long
4b60: 20 73 6c 65 65 70 20 68 65 72 65 20 2d 20 6e 6f   sleep here - no
4b70: 20 72 65 73 6f 75 72 63 65 73 2c 20 6d 61 79 20   resources, may 
4b80: 61 73 20 77 65 6c 6c 20 62 65 20 70 61 74 69 65  as well be patie
4b90: 6e 74 0a 09 09 09 20 20 3b 3b 20 77 65 20 6d 61  nt....  ;; we ma
4ba0: 64 65 20 6e 65 77 20 74 61 6c 20 62 79 20 73 74  de new tal by st
4bb0: 69 63 6b 69 6e 67 20 68 65 64 20 61 74 20 74 68  icking hed at th
4bc0: 65 20 62 61 63 6b 20 6f 66 20 74 68 65 20 6c 69  e back of the li
4bd0: 73 74 0a 09 09 09 20 20 28 6c 6f 6f 70 20 28 63  st....  (loop (c
4be0: 61 72 20 6e 65 77 74 61 6c 29 28 63 64 72 20 6e  ar newtal)(cdr n
4bf0: 65 77 74 61 6c 29 20 72 65 72 75 6e 73 29 29 0a  ewtal) reruns)).
4c00: 09 09 09 3b 3b 20 74 68 65 20 77 61 69 74 6f 6e  ...;; the waiton
4c10: 20 69 73 20 46 41 49 4c 20 73 6f 20 6e 6f 20 70   is FAIL so no p
4c20: 6f 69 6e 74 20 69 6e 20 74 72 79 69 6e 67 20 74  oint in trying t
4c30: 6f 20 72 75 6e 20 68 65 64 20 65 76 65 72 20 61  o run hed ever a
4c40: 67 61 69 6e 0a 09 09 09 28 69 66 20 28 6e 6f 74  gain....(if (not
4c50: 20 28 6e 75 6c 6c 3f 20 74 61 6c 29 29 0a 09 09   (null? tal))...
4c60: 09 20 20 20 20 28 69 66 20 28 76 65 63 74 6f 72  .    (if (vector
4c70: 3f 20 68 65 64 29 0a 09 09 09 09 28 62 65 67 69  ? hed).....(begi
4c80: 6e 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31  n (debug:print 1
4c90: 20 22 57 41 52 4e 3a 20 44 72 6f 70 70 69 6e 67   "WARN: Dropping
4ca0: 20 74 65 73 74 20 22 20 28 64 62 3a 74 65 73 74   test " (db:test
4cb0: 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 68 65  -get-testname he
4cc0: 64 29 20 22 2f 22 20 28 64 62 3a 74 65 73 74 2d  d) "/" (db:test-
4cd0: 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 68 65  get-item-path he
4ce0: 64 29 0a 09 09 09 09 09 09 20 20 20 20 22 20 66  d).......    " f
4cf0: 72 6f 6d 20 74 68 65 20 6c 61 75 6e 63 68 20 6c  rom the launch l
4d00: 69 73 74 20 61 73 20 69 74 20 68 61 73 20 70 72  ist as it has pr
4d10: 65 72 65 71 75 69 73 74 65 73 20 74 68 61 74 20  erequistes that 
4d20: 61 72 65 20 46 41 49 4c 22 29 0a 09 09 09 09 20  are FAIL")..... 
4d30: 20 20 20 20 20 20 28 74 68 72 65 61 64 2d 73 6c        (thread-sl
4d40: 65 65 70 21 20 2a 67 6c 6f 62 61 6c 2d 64 65 6c  eep! *global-del
4d50: 74 61 2a 29 0a 09 09 09 09 20 20 20 20 20 20 20  ta*).....       
4d60: 28 6c 6f 6f 70 20 28 63 61 72 20 74 61 6c 29 28  (loop (car tal)(
4d70: 63 64 72 20 74 61 6c 29 20 28 63 6f 6e 73 20 68  cdr tal) (cons h
4d80: 65 64 20 72 65 72 75 6e 73 29 29 29 0a 09 09 09  ed reruns)))....
4d90: 09 28 62 65 67 69 6e 0a 09 09 09 09 20 20 28 64  .(begin.....  (d
4da0: 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 57 41  ebug:print 1 "WA
4db0: 52 4e 3a 20 54 65 73 74 20 6e 6f 74 20 70 72 6f  RN: Test not pro
4dc0: 63 65 73 73 65 64 20 63 6f 72 72 65 63 74 6c 79  cessed correctly
4dd0: 2e 20 43 6f 75 6c 64 20 62 65 20 61 20 72 61 63  . Could be a rac
4de0: 65 20 63 6f 6e 64 69 74 69 6f 6e 20 69 6e 20 79  e condition in y
4df0: 6f 75 72 20 74 65 73 74 20 69 6d 70 6c 65 6d 65  our test impleme
4e00: 6e 74 61 74 69 6f 6e 3f 20 22 20 68 65 64 29 20  ntation? " hed) 
4e10: 3b 3b 20 20 22 20 61 73 20 69 74 20 68 61 73 20  ;;  " as it has 
4e20: 70 72 65 72 65 71 75 69 73 74 65 73 20 74 68 61  prerequistes tha
4e30: 74 20 61 72 65 20 46 41 49 4c 2e 20 28 4e 4f 54  t are FAIL. (NOT
4e40: 45 3a 20 68 65 64 20 69 73 20 6e 6f 74 20 61 20  E: hed is not a 
4e50: 76 65 63 74 6f 72 29 22 29 0a 09 09 09 09 20 20  vector)").....  
4e60: 28 74 68 72 65 61 64 2d 73 6c 65 65 70 21 20 2a  (thread-sleep! *
4e70: 67 6c 6f 62 61 6c 2d 64 65 6c 74 61 2a 29 0a 09  global-delta*)..
4e80: 09 09 09 20 20 28 6c 6f 6f 70 20 68 65 64 20 74  ...  (loop hed t
4e90: 61 6c 20 72 65 72 75 6e 73 29 29 29 29 29 29 29  al reruns)))))))
4ea0: 29 29 20 3b 3b 20 45 4e 44 20 4f 46 20 49 4e 4e  )) ;; END OF INN
4eb0: 45 52 20 43 4f 4e 44 0a 09 20 20 20 20 20 0a 09  ER COND..     ..
4ec0: 20 20 20 20 20 3b 3b 20 63 61 73 65 20 77 68 65       ;; case whe
4ed0: 72 65 20 61 6e 20 69 74 65 6d 73 20 63 61 6d 65  re an items came
4ee0: 20 69 6e 20 61 73 20 61 20 6c 69 73 74 20 62 65   in as a list be
4ef0: 65 6e 20 70 72 6f 63 65 73 73 65 64 0a 09 20 20  en processed..  
4f00: 20 20 20 28 28 61 6e 64 20 28 6c 69 73 74 3f 20     ((and (list? 
4f10: 69 74 65 6d 73 29 20 20 20 20 20 3b 3b 20 74 68  items)     ;; th
4f20: 75 73 20 77 65 20 6b 6e 6f 77 20 6f 75 72 20 69  us we know our i
4f30: 74 65 6d 73 20 61 72 65 20 61 6c 72 65 61 64 79  tems are already
4f40: 20 63 61 6c 63 75 6c 61 74 65 64 0a 09 09 20 20   calculated...  
4f50: 20 28 6e 6f 74 20 20 20 69 74 65 6d 64 61 74 29   (not   itemdat)
4f60: 29 20 3b 3b 20 61 6e 64 20 6e 6f 74 20 79 65 74  ) ;; and not yet
4f70: 20 65 78 70 61 6e 64 65 64 20 69 6e 74 6f 20 74   expanded into t
4f80: 68 65 20 6c 69 73 74 20 6f 66 20 74 68 69 6e 67  he list of thing
4f90: 73 20 74 6f 20 62 65 20 64 6f 6e 65 0a 09 20 20  s to be done..  
4fa0: 20 20 20 20 28 69 66 20 28 61 6e 64 20 28 3e 3d      (if (and (>=
4fb0: 20 2a 76 65 72 62 6f 73 69 74 79 2a 20 31 29 0a   *verbosity* 1).
4fc0: 09 09 20 20 20 20 20 20 20 28 3e 20 28 6c 65 6e  ..       (> (len
4fd0: 67 74 68 20 69 74 65 6d 73 29 20 30 29 0a 09 09  gth items) 0)...
4fe0: 20 20 20 20 20 20 20 28 3e 20 28 6c 65 6e 67 74         (> (lengt
4ff0: 68 20 28 63 61 72 20 69 74 65 6d 73 29 29 20 30  h (car items)) 0
5000: 29 29 0a 09 09 20 20 28 70 70 20 69 74 65 6d 73  ))...  (pp items
5010: 29 29 0a 09 20 20 20 20 20 20 28 66 6f 72 2d 65  ))..      (for-e
5020: 61 63 68 0a 09 20 20 20 20 20 20 20 28 6c 61 6d  ach..       (lam
5030: 62 64 61 20 28 6d 79 2d 69 74 65 6d 64 61 74 29  bda (my-itemdat)
5040: 0a 09 09 20 28 6c 65 74 2a 20 28 28 6e 65 77 2d  ... (let* ((new-
5050: 74 65 73 74 2d 72 65 63 6f 72 64 20 28 6c 65 74  test-record (let
5060: 20 28 28 6e 65 77 72 65 63 20 28 6d 61 6b 65 2d   ((newrec (make-
5070: 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 29  tests:testqueue)
5080: 29 29 0a 09 09 09 09 09 20 20 20 28 76 65 63 74  ))......   (vect
5090: 6f 72 2d 63 6f 70 79 21 20 74 65 73 74 2d 72 65  or-copy! test-re
50a0: 63 6f 72 64 20 6e 65 77 72 65 63 29 0a 09 09 09  cord newrec)....
50b0: 09 09 20 20 20 6e 65 77 72 65 63 29 29 0a 09 09  ..   newrec))...
50c0: 09 28 6d 79 2d 69 74 65 6d 2d 70 61 74 68 20 28  .(my-item-path (
50d0: 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20  item-list->path 
50e0: 6d 79 2d 69 74 65 6d 64 61 74 29 29 29 0a 09 09  my-itemdat)))...
50f0: 20 20 20 28 69 66 20 28 70 61 74 74 2d 6c 69 73     (if (patt-lis
5100: 74 2d 6d 61 74 63 68 20 6d 79 2d 69 74 65 6d 2d  t-match my-item-
5110: 70 61 74 68 20 69 74 65 6d 2d 70 61 74 74 73 29  path item-patts)
5120: 20 20 20 20 20 20 20 20 20 20 20 3b 3b 20 79 65             ;; ye
5130: 73 2c 20 77 65 20 77 61 6e 74 20 74 6f 20 70 72  s, we want to pr
5140: 6f 63 65 73 73 20 74 68 69 73 20 69 74 65 6d 2c  ocess this item,
5150: 20 4e 4f 54 45 3a 20 53 68 6f 75 6c 64 20 6e 6f   NOTE: Should no
5160: 74 20 6e 65 65 64 20 74 68 69 73 20 63 68 65 63  t need this chec
5170: 6b 20 68 65 72 65 21 0a 09 09 20 20 20 20 20 20  k here!...      
5180: 20 28 6c 65 74 20 28 28 6e 65 77 74 65 73 74 6e   (let ((newtestn
5190: 61 6d 65 20 28 72 75 6e 73 3a 6d 61 6b 65 2d 66  ame (runs:make-f
51a0: 75 6c 6c 2d 74 65 73 74 2d 6e 61 6d 65 20 68 65  ull-test-name he
51b0: 64 20 6d 79 2d 69 74 65 6d 2d 70 61 74 68 29 29  d my-item-path))
51c0: 29 20 20 20 20 3b 3b 20 74 65 73 74 20 6e 61 6d  )    ;; test nam
51d0: 65 73 20 61 72 65 20 75 6e 69 71 75 65 20 6f 6e  es are unique on
51e0: 20 74 65 73 74 6e 61 6d 65 2f 69 74 65 6d 2d 70   testname/item-p
51f0: 61 74 68 0a 09 09 09 20 28 74 65 73 74 73 3a 74  ath.... (tests:t
5200: 65 73 74 71 75 65 75 65 2d 73 65 74 2d 69 74 65  estqueue-set-ite
5210: 6d 73 21 20 20 20 20 20 6e 65 77 2d 74 65 73 74  ms!     new-test
5220: 2d 72 65 63 6f 72 64 20 23 66 29 0a 09 09 09 20  -record #f).... 
5230: 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65  (tests:testqueue
5240: 2d 73 65 74 2d 69 74 65 6d 64 61 74 21 20 20 20  -set-itemdat!   
5250: 6e 65 77 2d 74 65 73 74 2d 72 65 63 6f 72 64 20  new-test-record 
5260: 6d 79 2d 69 74 65 6d 64 61 74 29 0a 09 09 09 20  my-itemdat).... 
5270: 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65  (tests:testqueue
5280: 2d 73 65 74 2d 69 74 65 6d 5f 70 61 74 68 21 20  -set-item_path! 
5290: 6e 65 77 2d 74 65 73 74 2d 72 65 63 6f 72 64 20  new-test-record 
52a0: 6d 79 2d 69 74 65 6d 2d 70 61 74 68 29 0a 09 09  my-item-path)...
52b0: 09 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65  . (hash-table-se
52c0: 74 21 20 74 65 73 74 2d 72 65 63 6f 72 64 73 20  t! test-records 
52d0: 6e 65 77 74 65 73 74 6e 61 6d 65 20 6e 65 77 2d  newtestname new-
52e0: 74 65 73 74 2d 72 65 63 6f 72 64 29 0a 09 09 09  test-record)....
52f0: 20 28 73 65 74 21 20 74 61 6c 20 28 63 6f 6e 73   (set! tal (cons
5300: 20 6e 65 77 74 65 73 74 6e 61 6d 65 20 74 61 6c   newtestname tal
5310: 29 29 29 29 29 29 20 3b 3b 20 73 69 6e 63 65 20  )))))) ;; since 
5320: 74 68 65 73 65 20 61 72 65 20 69 74 65 6d 69 7a  these are itemiz
5330: 65 64 20 63 72 65 61 74 65 20 6e 65 77 20 74 65  ed create new te
5340: 73 74 20 6e 61 6d 65 73 20 74 65 73 74 6e 61 6d  st names testnam
5350: 65 2f 69 74 65 6d 70 61 74 68 0a 09 20 20 20 20  e/itempath..    
5360: 20 20 20 69 74 65 6d 73 29 0a 09 20 20 20 20 20     items)..     
5370: 20 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f   (if (not (null?
5380: 20 74 61 6c 29 29 0a 09 09 20 20 28 62 65 67 69   tal))...  (begi
5390: 6e 0a 09 09 20 20 20 20 28 74 68 72 65 61 64 2d  n...    (thread-
53a0: 73 6c 65 65 70 21 20 2a 67 6c 6f 62 61 6c 2d 64  sleep! *global-d
53b0: 65 6c 74 61 2a 29 0a 09 09 20 20 20 20 28 64 65  elta*)...    (de
53c0: 62 75 67 3a 70 72 69 6e 74 20 34 20 22 49 4e 46  bug:print 4 "INF
53d0: 4f 3a 20 45 6e 64 20 6f 66 20 69 74 65 6d 73 20  O: End of items 
53e0: 6c 69 73 74 2c 20 6c 6f 6f 70 69 6e 67 20 77 69  list, looping wi
53f0: 74 68 20 6e 65 78 74 22 29 0a 09 09 20 20 20 20  th next")...    
5400: 28 6c 6f 6f 70 20 28 63 61 72 20 74 61 6c 29 28  (loop (car tal)(
5410: 63 64 72 20 74 61 6c 29 20 72 65 72 75 6e 73 29  cdr tal) reruns)
5420: 29 29 29 0a 0a 09 20 20 20 20 20 3b 3b 20 69 66  )))...     ;; if
5430: 20 69 74 65 6d 73 20 69 73 20 61 20 70 72 6f 63   items is a proc
5440: 20 74 68 65 6e 20 6e 65 65 64 20 74 6f 20 72 75   then need to ru
5450: 6e 20 69 74 65 6d 73 3a 67 65 74 2d 69 74 65 6d  n items:get-item
5460: 73 2d 66 72 6f 6d 2d 63 6f 6e 66 69 67 2c 20 67  s-from-config, g
5470: 65 74 20 74 68 65 20 6c 69 73 74 20 61 6e 64 20  et the list and 
5480: 6c 6f 6f 70 20 0a 09 20 20 20 20 20 3b 3b 20 20  loop ..     ;;  
5490: 20 20 2d 20 62 75 74 20 6f 6e 6c 79 20 64 6f 20    - but only do 
54a0: 74 68 61 74 20 69 66 20 72 65 73 6f 75 72 63 65  that if resource
54b0: 73 20 65 78 69 73 74 20 74 6f 20 6b 69 63 6b 20  s exist to kick 
54c0: 6f 66 66 20 74 68 65 20 6a 6f 62 0a 09 20 20 20  off the job..   
54d0: 20 20 28 28 6f 72 20 28 70 72 6f 63 65 64 75 72    ((or (procedur
54e0: 65 3f 20 69 74 65 6d 73 29 28 65 71 3f 20 69 74  e? items)(eq? it
54f0: 65 6d 73 20 27 68 61 76 65 2d 70 72 6f 63 65 64  ems 'have-proced
5500: 75 72 65 29 29 0a 09 20 20 20 20 20 20 28 6c 65  ure))..      (le
5510: 74 20 28 28 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65  t ((can-run-more
5520: 20 20 20 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c      (open-run-cl
5530: 6f 73 65 20 72 75 6e 73 3a 63 61 6e 2d 72 75 6e  ose runs:can-run
5540: 2d 6d 6f 72 65 2d 74 65 73 74 73 20 23 66 20 74  -more-tests #f t
5550: 65 73 74 2d 72 65 63 6f 72 64 29 29 29 0a 09 09  est-record)))...
5560: 28 69 66 20 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65  (if can-run-more
5570: 0a 09 09 20 20 20 20 28 6c 65 74 2a 20 28 28 70  ...    (let* ((p
5580: 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 20 28  rereqs-not-met (
5590: 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 64  open-run-close d
55a0: 62 3a 67 65 74 2d 70 72 65 72 65 71 73 2d 6e 6f  b:get-prereqs-no
55b0: 74 2d 6d 65 74 20 23 66 20 72 75 6e 2d 69 64 20  t-met #f run-id 
55c0: 77 61 69 74 6f 6e 73 20 69 74 65 6d 2d 70 61 74  waitons item-pat
55d0: 68 20 6d 6f 64 65 3a 20 74 65 73 74 6d 6f 64 65  h mode: testmode
55e0: 29 29 0a 09 09 09 20 20 20 28 66 61 69 6c 73 20  ))....   (fails 
55f0: 20 20 20 20 20 20 20 20 20 20 28 72 75 6e 73 3a            (runs:
5600: 63 61 6c 63 2d 66 61 69 6c 73 20 70 72 65 72 65  calc-fails prere
5610: 71 73 2d 6e 6f 74 2d 6d 65 74 29 29 0a 09 09 09  qs-not-met))....
5620: 20 20 20 28 6e 6f 6e 2d 63 6f 6d 70 6c 65 74 65     (non-complete
5630: 64 20 20 20 28 72 75 6e 73 3a 63 61 6c 63 2d 6e  d   (runs:calc-n
5640: 6f 74 2d 63 6f 6d 70 6c 65 74 65 64 20 70 72 65  ot-completed pre
5650: 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 29 29 29 0a  reqs-not-met))).
5660: 09 09 20 20 20 20 20 20 28 64 65 62 75 67 3a 70  ..      (debug:p
5670: 72 69 6e 74 20 38 20 22 49 4e 46 4f 3a 20 63 61  rint 8 "INFO: ca
5680: 6e 2d 72 75 6e 2d 6d 6f 72 65 3a 20 22 20 63 61  n-run-more: " ca
5690: 6e 2d 72 75 6e 2d 6d 6f 72 65 0a 09 09 09 09 20  n-run-more..... 
56a0: 20 20 22 5c 6e 20 74 65 73 74 6e 61 6d 65 3a 20    "\n testname: 
56b0: 20 20 20 20 20 20 20 22 20 68 65 64 0a 09 09 09         " hed....
56c0: 09 20 20 20 22 5c 6e 20 70 72 65 72 65 71 73 2d  .   "\n prereqs-
56d0: 6e 6f 74 2d 6d 65 74 3a 20 22 20 28 72 75 6e 73  not-met: " (runs
56e0: 3a 70 72 65 74 74 79 2d 73 74 72 69 6e 67 20 70  :pretty-string p
56f0: 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 29 0a  rereqs-not-met).
5700: 09 09 09 09 20 20 20 22 5c 6e 20 6e 6f 6e 2d 63  ....   "\n non-c
5710: 6f 6d 70 6c 65 74 65 64 3a 20 20 20 22 20 28 72  ompleted:   " (r
5720: 75 6e 73 3a 70 72 65 74 74 79 2d 73 74 72 69 6e  uns:pretty-strin
5730: 67 20 6e 6f 6e 2d 63 6f 6d 70 6c 65 74 65 64 29  g non-completed)
5740: 20 0a 09 09 09 09 20 20 20 22 5c 6e 20 66 61 69   .....   "\n fai
5750: 6c 73 3a 20 20 20 20 20 20 20 20 20 20 20 22 20  ls:           " 
5760: 28 72 75 6e 73 3a 70 72 65 74 74 79 2d 73 74 72  (runs:pretty-str
5770: 69 6e 67 20 66 61 69 6c 73 29 0a 09 09 09 09 20  ing fails)..... 
5780: 20 20 22 5c 6e 20 74 65 73 74 6d 6f 64 65 3a 20    "\n testmode: 
5790: 20 20 20 20 20 20 20 22 20 74 65 73 74 6d 6f 64         " testmod
57a0: 65 0a 09 09 09 09 20 20 20 22 5c 6e 20 6e 75 6d  e.....   "\n num
57b0: 2d 72 65 74 72 69 65 73 3a 20 20 20 20 20 22 20  -retries:     " 
57c0: 6e 75 6d 2d 72 65 74 72 69 65 73 0a 09 09 09 09  num-retries.....
57d0: 20 20 20 22 5c 6e 20 28 65 71 3f 20 74 65 73 74     "\n (eq? test
57e0: 6d 6f 64 65 20 27 74 6f 70 6c 65 76 65 6c 29 3a  mode 'toplevel):
57f0: 20 22 20 28 65 71 3f 20 74 65 73 74 6d 6f 64 65   " (eq? testmode
5800: 20 27 74 6f 70 6c 65 76 65 6c 29 0a 09 09 09 09   'toplevel).....
5810: 20 20 20 22 5c 6e 20 28 6e 75 6c 6c 3f 20 6e 6f     "\n (null? no
5820: 6e 2d 63 6f 6d 70 6c 65 74 65 64 29 3a 20 20 20  n-completed):   
5830: 20 22 20 28 6e 75 6c 6c 3f 20 6e 6f 6e 2d 63 6f   " (null? non-co
5840: 6d 70 6c 65 74 65 64 29 0a 09 09 09 09 20 20 20  mpleted).....   
5850: 22 5c 6e 20 72 65 72 75 6e 73 3a 20 22 20 72 65  "\n reruns: " re
5860: 72 75 6e 73 29 0a 0a 09 09 20 20 20 20 20 20 28  runs)....      (
5870: 63 6f 6e 64 20 3b 3b 20 49 4e 4e 45 52 20 43 4f  cond ;; INNER CO
5880: 4e 44 20 23 32 0a 09 09 20 20 20 20 20 20 20 28  ND #2...       (
5890: 28 6f 72 20 28 6e 75 6c 6c 3f 20 70 72 65 72 65  (or (null? prere
58a0: 71 73 2d 6e 6f 74 2d 6d 65 74 29 20 3b 3b 20 61  qs-not-met) ;; a
58b0: 6c 6c 20 70 72 65 72 65 71 73 20 6d 65 74 2c 20  ll prereqs met, 
58c0: 66 69 72 65 20 6f 66 66 20 74 68 65 20 74 65 73  fire off the tes
58d0: 74 0a 09 09 09 20 20 20 20 3b 3b 20 6f 72 2c 20  t....    ;; or, 
58e0: 69 66 20 69 74 20 69 73 20 61 20 27 74 6f 70 6c  if it is a 'topl
58f0: 65 76 65 6c 20 74 65 73 74 20 61 6e 64 20 61 6c  evel test and al
5900: 6c 20 70 72 65 72 65 71 73 20 6e 6f 74 20 6d 65  l prereqs not me
5910: 74 20 61 72 65 20 43 4f 4d 50 4c 45 54 45 44 20  t are COMPLETED 
5920: 74 68 65 6e 20 6c 61 75 6e 63 68 0a 09 09 09 20  then launch.... 
5930: 20 20 20 28 61 6e 64 20 28 65 71 3f 20 74 65 73     (and (eq? tes
5940: 74 6d 6f 64 65 20 27 74 6f 70 6c 65 76 65 6c 29  tmode 'toplevel)
5950: 0a 09 09 09 09 20 28 6e 75 6c 6c 3f 20 6e 6f 6e  ..... (null? non
5960: 2d 63 6f 6d 70 6c 65 74 65 64 29 29 29 0a 09 09  -completed)))...
5970: 09 28 6c 65 74 20 28 28 74 65 73 74 2d 6e 61 6d  .(let ((test-nam
5980: 65 20 28 74 65 73 74 73 3a 74 65 73 74 71 75 65  e (tests:testque
5990: 75 65 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20  ue-get-testname 
59a0: 74 65 73 74 2d 72 65 63 6f 72 64 29 29 29 0a 09  test-record)))..
59b0: 09 09 20 20 28 73 65 74 65 6e 76 20 22 4d 54 5f  ..  (setenv "MT_
59c0: 54 45 53 54 5f 4e 41 4d 45 22 20 74 65 73 74 2d  TEST_NAME" test-
59d0: 6e 61 6d 65 29 20 3b 3b 20 0a 09 09 09 20 20 28  name) ;; ....  (
59e0: 73 65 74 65 6e 76 20 22 4d 54 5f 52 55 4e 4e 41  setenv "MT_RUNNA
59f0: 4d 45 22 20 20 20 72 75 6e 6e 61 6d 65 29 0a 09  ME"   runname)..
5a00: 09 09 20 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c  ..  (open-run-cl
5a10: 6f 73 65 20 73 65 74 2d 6d 65 67 61 74 65 73 74  ose set-megatest
5a20: 2d 65 6e 76 2d 76 61 72 73 20 23 66 20 72 75 6e  -env-vars #f run
5a30: 2d 69 64 29 20 3b 3b 20 74 68 65 73 65 20 6d 61  -id) ;; these ma
5a40: 79 20 62 65 20 6e 65 65 64 65 64 20 62 79 20 74  y be needed by t
5a50: 68 65 20 6c 61 75 6e 63 68 69 6e 67 20 70 72 6f  he launching pro
5a60: 63 65 73 73 0a 09 09 09 20 20 28 6c 65 74 20 28  cess....  (let (
5a70: 28 69 74 65 6d 73 2d 6c 69 73 74 20 28 69 74 65  (items-list (ite
5a80: 6d 73 3a 67 65 74 2d 69 74 65 6d 73 2d 66 72 6f  ms:get-items-fro
5a90: 6d 2d 63 6f 6e 66 69 67 20 74 63 6f 6e 66 69 67  m-config tconfig
5aa0: 29 29 29 0a 09 09 09 20 20 20 20 28 69 66 20 28  )))....    (if (
5ab0: 6c 69 73 74 3f 20 69 74 65 6d 73 2d 6c 69 73 74  list? items-list
5ac0: 29 0a 09 09 09 09 28 62 65 67 69 6e 0a 09 09 09  ).....(begin....
5ad0: 09 20 20 28 74 65 73 74 73 3a 74 65 73 74 71 75  .  (tests:testqu
5ae0: 65 75 65 2d 73 65 74 2d 69 74 65 6d 73 21 20 74  eue-set-items! t
5af0: 65 73 74 2d 72 65 63 6f 72 64 20 69 74 65 6d 73  est-record items
5b00: 2d 6c 69 73 74 29 0a 09 09 09 09 20 20 28 74 68  -list).....  (th
5b10: 72 65 61 64 2d 73 6c 65 65 70 21 20 2a 67 6c 6f  read-sleep! *glo
5b20: 62 61 6c 2d 64 65 6c 74 61 2a 29 0a 09 09 09 09  bal-delta*).....
5b30: 20 20 28 6c 6f 6f 70 20 68 65 64 20 74 61 6c 20    (loop hed tal 
5b40: 72 65 72 75 6e 73 29 29 0a 09 09 09 09 28 62 65  reruns)).....(be
5b50: 67 69 6e 0a 09 09 09 09 20 20 28 64 65 62 75 67  gin.....  (debug
5b60: 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a  :print 0 "ERROR:
5b70: 20 54 68 65 20 70 72 6f 63 20 66 72 6f 6d 20 72   The proc from r
5b80: 65 61 64 69 6e 67 20 74 68 65 20 73 65 74 75 70  eading the setup
5b90: 20 64 69 64 20 6e 6f 74 20 79 69 65 6c 64 20 61   did not yield a
5ba0: 20 6c 69 73 74 20 2d 20 70 6c 65 61 73 65 20 72   list - please r
5bb0: 65 70 6f 72 74 20 74 68 69 73 22 29 0a 09 09 09  eport this")....
5bc0: 09 20 20 28 65 78 69 74 20 31 29 29 29 29 29 29  .  (exit 1))))))
5bd0: 0a 09 09 20 20 20 20 20 20 20 28 28 6e 75 6c 6c  ...       ((null
5be0: 3f 20 66 61 69 6c 73 29 0a 09 09 09 28 64 65 62  ? fails)....(deb
5bf0: 75 67 3a 70 72 69 6e 74 20 34 20 22 49 4e 46 4f  ug:print 4 "INFO
5c00: 3a 20 66 61 69 6c 73 20 69 73 20 6e 75 6c 6c 2c  : fails is null,
5c10: 20 6d 6f 76 69 6e 67 20 6f 6e 20 69 6e 20 74 68   moving on in th
5c20: 65 20 71 75 65 75 65 20 62 75 74 20 6b 65 65 70  e queue but keep
5c30: 69 6e 67 20 22 20 68 65 64 20 22 20 66 6f 72 20  ing " hed " for 
5c40: 6e 6f 77 22 29 0a 09 09 09 28 74 68 72 65 61 64  now")....(thread
5c50: 2d 73 6c 65 65 70 21 20 2a 67 6c 6f 62 61 6c 2d  -sleep! *global-
5c60: 64 65 6c 74 61 2a 29 0a 09 09 09 28 6c 6f 6f 70  delta*)....(loop
5c70: 20 28 63 61 72 20 6e 65 77 74 61 6c 29 28 63 64   (car newtal)(cd
5c80: 72 20 6e 65 77 74 61 6c 29 20 72 65 72 75 6e 73  r newtal) reruns
5c90: 29 29 20 3b 3b 20 61 6e 20 69 73 73 75 65 20 77  )) ;; an issue w
5ca0: 69 74 68 20 70 72 65 72 65 71 73 20 6e 6f 74 20  ith prereqs not 
5cb0: 79 65 74 20 6d 65 74 3f 0a 09 09 20 20 20 20 20  yet met?...     
5cc0: 20 20 28 28 61 6e 64 20 28 6e 6f 74 20 28 6e 75    ((and (not (nu
5cd0: 6c 6c 3f 20 66 61 69 6c 73 29 29 28 65 71 3f 20  ll? fails))(eq? 
5ce0: 74 65 73 74 6d 6f 64 65 20 27 6e 6f 72 6d 61 6c  testmode 'normal
5cf0: 29 29 0a 09 09 09 28 64 65 62 75 67 3a 70 72 69  ))....(debug:pri
5d00: 6e 74 20 31 20 22 49 4e 46 4f 3a 20 74 65 73 74  nt 1 "INFO: test
5d10: 20 22 20 20 68 65 64 20 22 20 28 6d 6f 64 65 3d   "  hed " (mode=
5d20: 22 20 74 65 73 74 6d 6f 64 65 20 22 29 20 68 61  " testmode ") ha
5d30: 73 20 66 61 69 6c 65 64 20 70 72 65 72 65 71 75  s failed prerequ
5d40: 69 73 69 74 65 28 73 29 3b 20 22 0a 09 09 09 09  isite(s); ".....
5d50: 20 20 20 20 20 28 73 74 72 69 6e 67 2d 69 6e 74       (string-int
5d60: 65 72 73 70 65 72 73 65 20 28 6d 61 70 20 28 6c  ersperse (map (l
5d70: 61 6d 62 64 61 20 28 74 29 28 63 6f 6e 63 20 28  ambda (t)(conc (
5d80: 64 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74  db:test-get-test
5d90: 6e 61 6d 65 20 74 29 20 22 3a 22 20 28 64 62 3a  name t) ":" (db:
5da0: 74 65 73 74 2d 67 65 74 2d 73 74 61 74 65 20 74  test-get-state t
5db0: 29 22 2f 22 28 64 62 3a 74 65 73 74 2d 67 65 74  )"/"(db:test-get
5dc0: 2d 73 74 61 74 75 73 20 74 29 29 29 20 66 61 69  -status t))) fai
5dd0: 6c 73 29 20 22 2c 20 22 29 0a 09 09 09 09 20 20  ls) ", ").....  
5de0: 20 20 20 22 2c 20 72 65 6d 6f 76 69 6e 67 20 69     ", removing i
5df0: 74 20 66 72 6f 6d 20 74 6f 2d 64 6f 20 6c 69 73  t from to-do lis
5e00: 74 22 29 0a 09 09 09 28 69 66 20 28 6e 6f 74 20  t")....(if (not 
5e10: 28 6e 75 6c 6c 3f 20 74 61 6c 29 29 0a 09 09 09  (null? tal))....
5e20: 20 20 20 20 28 62 65 67 69 6e 0a 09 09 09 20 20      (begin....  
5e30: 20 20 20 20 28 74 68 72 65 61 64 2d 73 6c 65 65      (thread-slee
5e40: 70 21 20 2a 67 6c 6f 62 61 6c 2d 64 65 6c 74 61  p! *global-delta
5e50: 2a 29 0a 09 09 09 20 20 20 20 20 20 28 6c 6f 6f  *)....      (loo
5e60: 70 20 28 63 61 72 20 74 61 6c 29 28 63 64 72 20  p (car tal)(cdr 
5e70: 74 61 6c 29 28 63 6f 6e 73 20 68 65 64 20 72 65  tal)(cons hed re
5e80: 72 75 6e 73 29 29 29 29 29 0a 09 09 20 20 20 20  runs)))))...    
5e90: 20 20 20 28 65 6c 73 65 0a 09 09 09 28 64 65 62     (else....(deb
5ea0: 75 67 3a 70 72 69 6e 74 20 38 20 22 45 52 52 4f  ug:print 8 "ERRO
5eb0: 52 3a 20 4e 6f 20 68 61 6e 64 6c 65 72 20 66 6f  R: No handler fo
5ec0: 72 20 74 68 69 73 20 63 6f 6e 64 69 74 69 6f 6e  r this condition
5ed0: 2e 22 29 0a 09 09 09 28 74 68 72 65 61 64 2d 73  .")....(thread-s
5ee0: 6c 65 65 70 21 20 2a 67 6c 6f 62 61 6c 2d 64 65  leep! *global-de
5ef0: 6c 74 61 2a 29 0a 09 09 09 28 6c 6f 6f 70 20 28  lta*)....(loop (
5f00: 63 61 72 20 6e 65 77 74 61 6c 29 28 63 64 72 20  car newtal)(cdr 
5f10: 6e 65 77 74 61 6c 29 20 72 65 72 75 6e 73 29 29  newtal) reruns))
5f20: 29 29 20 3b 3b 20 45 4e 44 20 4f 46 20 49 46 20  )) ;; END OF IF 
5f30: 43 41 4e 20 52 55 4e 20 4d 4f 52 45 0a 0a 09 09  CAN RUN MORE....
5f40: 20 20 20 20 3b 3b 20 69 66 20 63 61 6e 27 74 20      ;; if can't 
5f50: 72 75 6e 20 6d 6f 72 65 20 6a 75 73 74 20 6c 6f  run more just lo
5f60: 6f 70 20 77 69 74 68 20 6e 65 78 74 20 70 6f 73  op with next pos
5f70: 73 69 62 6c 65 20 74 65 73 74 0a 09 09 20 20 20  sible test...   
5f80: 20 28 62 65 67 69 6e 0a 09 09 20 20 20 20 20 20   (begin...      
5f90: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22  (debug:print 4 "
5fa0: 49 4e 46 4f 3a 20 70 72 6f 63 65 73 73 69 6e 67  INFO: processing
5fb0: 20 74 68 65 20 63 61 73 65 20 77 69 74 68 20 61   the case with a
5fc0: 20 6c 61 6d 62 64 61 20 66 6f 72 20 69 74 65 6d   lambda for item
5fd0: 73 20 6f 72 20 27 68 61 76 65 2d 70 72 6f 63 65  s or 'have-proce
5fe0: 64 75 72 65 2e 20 4d 6f 76 69 6e 67 20 74 68 72  dure. Moving thr
5ff0: 6f 75 67 68 20 74 68 65 20 71 75 65 75 65 20 77  ough the queue w
6000: 69 74 68 6f 75 74 20 64 72 6f 70 70 69 6e 67 20  ithout dropping 
6010: 22 20 68 65 64 29 0a 09 09 20 20 20 20 20 20 28  " hed)...      (
6020: 74 68 72 65 61 64 2d 73 6c 65 65 70 21 20 28 2b  thread-sleep! (+
6030: 20 31 20 2a 67 6c 6f 62 61 6c 2d 64 65 6c 74 61   1 *global-delta
6040: 2a 29 29 0a 09 09 20 20 20 20 20 20 28 6c 6f 6f  *))...      (loo
6050: 70 20 28 63 61 72 20 6e 65 77 74 61 6c 29 28 63  p (car newtal)(c
6060: 64 72 20 6e 65 77 74 61 6c 29 20 72 65 72 75 6e  dr newtal) rerun
6070: 73 29 29 29 29 29 20 3b 3b 20 45 4e 44 20 4f 46  s))))) ;; END OF
6080: 20 28 6f 72 20 28 70 72 6f 63 65 64 75 72 65 3f   (or (procedure?
6090: 20 69 74 65 6d 73 29 28 65 71 3f 20 69 74 65 6d   items)(eq? item
60a0: 73 20 27 68 61 76 65 2d 70 72 6f 63 65 64 75 72  s 'have-procedur
60b0: 65 29 29 0a 09 20 20 20 20 20 0a 09 20 20 20 20  e))..     ..    
60c0: 20 3b 3b 20 74 68 69 73 20 63 61 73 65 20 73 68   ;; this case sh
60d0: 6f 75 6c 64 20 6e 6f 74 20 68 61 70 70 65 6e 2c  ould not happen,
60e0: 20 61 64 64 65 64 20 74 6f 20 68 65 6c 70 20 63   added to help c
60f0: 61 74 63 68 20 61 6e 79 20 62 75 67 73 0a 09 20  atch any bugs.. 
6100: 20 20 20 20 28 28 61 6e 64 20 28 6c 69 73 74 3f      ((and (list?
6110: 20 69 74 65 6d 73 29 20 69 74 65 6d 64 61 74 29   items) itemdat)
6120: 0a 09 20 20 20 20 20 20 28 64 65 62 75 67 3a 70  ..      (debug:p
6130: 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 53  rint 0 "ERROR: S
6140: 68 6f 75 6c 64 20 6e 6f 74 20 68 61 76 65 20 61  hould not have a
6150: 20 6c 69 73 74 20 6f 66 20 69 74 65 6d 73 20 69   list of items i
6160: 6e 20 61 20 74 65 73 74 20 61 6e 64 20 74 68 65  n a test and the
6170: 20 69 74 65 6d 73 70 61 74 68 20 73 65 74 20 2d   itemspath set -
6180: 20 70 6c 65 61 73 65 20 72 65 70 6f 72 74 20 74   please report t
6190: 68 69 73 22 29 0a 09 20 20 20 20 20 20 28 65 78  his")..      (ex
61a0: 69 74 20 31 29 29 0a 09 20 20 20 20 20 28 28 6e  it 1))..     ((n
61b0: 6f 74 20 28 6e 75 6c 6c 3f 20 72 65 72 75 6e 73  ot (null? reruns
61c0: 29 29 0a 09 20 20 20 20 20 20 28 6c 65 74 2a 20  ))..      (let* 
61d0: 28 28 6e 65 77 6c 73 74 20 28 6f 70 65 6e 2d 72  ((newlst (open-r
61e0: 75 6e 2d 63 6c 6f 73 65 20 74 65 73 74 73 3a 66  un-close tests:f
61f0: 69 6c 74 65 72 2d 6e 6f 6e 2d 72 75 6e 6e 61 62  ilter-non-runnab
6200: 6c 65 20 23 66 20 72 75 6e 2d 69 64 20 74 61 6c  le #f run-id tal
6210: 20 74 65 73 74 2d 72 65 63 6f 72 64 73 29 29 20   test-records)) 
6220: 3b 3b 20 69 2e 65 2e 20 6e 6f 74 20 46 41 49 4c  ;; i.e. not FAIL
6230: 2c 20 57 41 49 56 45 44 2c 20 49 4e 43 4f 4d 50  , WAIVED, INCOMP
6240: 4c 45 54 45 2c 20 50 41 53 53 2c 20 4b 49 4c 4c  LETE, PASS, KILL
6250: 45 44 2c 0a 09 09 20 20 20 20 20 28 6a 75 6e 6b  ED,...     (junk
6260: 65 64 20 28 6c 73 65 74 2d 64 69 66 66 65 72 65  ed (lset-differe
6270: 6e 63 65 20 65 71 75 61 6c 3f 20 74 61 6c 20 6e  nce equal? tal n
6280: 65 77 6c 73 74 29 29 29 0a 09 09 28 64 65 62 75  ewlst)))...(debu
6290: 67 3a 70 72 69 6e 74 20 34 20 22 49 4e 46 4f 3a  g:print 4 "INFO:
62a0: 20 66 75 6c 6c 20 64 72 6f 70 20 74 68 72 6f 75   full drop throu
62b0: 67 68 2c 20 69 66 20 72 65 72 75 6e 73 20 69 73  gh, if reruns is
62c0: 20 6c 65 73 73 20 74 68 61 6e 20 31 30 30 20 77   less than 100 w
62d0: 65 20 77 69 6c 6c 20 66 6f 72 63 65 20 72 65 74  e will force ret
62e0: 72 79 20 74 68 65 6d 2c 20 72 65 72 75 6e 73 3d  ry them, reruns=
62f0: 22 20 72 65 72 75 6e 73 20 22 2c 20 74 61 6c 3d  " reruns ", tal=
6300: 22 20 74 61 6c 29 0a 09 09 28 69 66 20 28 3c 20  " tal)...(if (< 
6310: 6e 75 6d 2d 72 65 74 72 69 65 73 20 6d 61 78 2d  num-retries max-
6320: 72 65 74 72 69 65 73 29 0a 09 09 20 20 20 20 28  retries)...    (
6330: 73 65 74 21 20 6e 65 77 6c 73 74 20 28 61 70 70  set! newlst (app
6340: 65 6e 64 20 72 65 72 75 6e 73 20 6e 65 77 6c 73  end reruns newls
6350: 74 29 29 29 0a 09 09 28 73 65 74 21 20 6e 75 6d  t)))...(set! num
6360: 2d 72 65 74 72 69 65 73 20 28 2b 20 6e 75 6d 2d  -retries (+ num-
6370: 72 65 74 72 69 65 73 20 31 29 29 0a 09 09 28 74  retries 1))...(t
6380: 68 72 65 61 64 2d 73 6c 65 65 70 21 20 2a 67 6c  hread-sleep! *gl
6390: 6f 62 61 6c 2d 64 65 6c 74 61 2a 29 0a 09 09 28  obal-delta*)...(
63a0: 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 6e  if (not (null? n
63b0: 65 77 6c 73 74 29 29 0a 09 09 20 20 20 20 3b 3b  ewlst))...    ;;
63c0: 20 73 69 6e 63 65 20 72 65 72 75 6e 73 20 68 61   since reruns ha
63d0: 76 65 20 62 65 65 6e 20 74 61 63 6b 65 64 20 6f  ve been tacked o
63e0: 6e 20 74 6f 20 6e 65 77 6c 73 74 20 63 72 65 61  n to newlst crea
63f0: 74 65 20 6e 65 77 20 72 65 72 75 6e 73 20 66 72  te new reruns fr
6400: 6f 6d 20 6a 75 6e 6b 65 64 0a 09 09 20 20 20 20  om junked...    
6410: 28 6c 6f 6f 70 20 28 63 61 72 20 6e 65 77 6c 73  (loop (car newls
6420: 74 29 28 63 64 72 20 6e 65 77 6c 73 74 29 28 64  t)(cdr newlst)(d
6430: 65 6c 65 74 65 2d 64 75 70 6c 69 63 61 74 65 73  elete-duplicates
6440: 20 6a 75 6e 6b 65 64 29 29 29 29 29 0a 09 20 20   junked)))))..  
6450: 20 20 20 28 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20     ((not (null? 
6460: 74 61 6c 29 29 0a 09 20 20 20 20 20 20 28 64 65  tal))..      (de
6470: 62 75 67 3a 70 72 69 6e 74 20 34 20 22 49 4e 46  bug:print 4 "INF
6480: 4f 3a 20 49 27 6d 20 70 72 65 74 74 79 20 73 75  O: I'm pretty su
6490: 72 65 20 49 20 73 68 6f 75 6c 64 6e 27 74 20 67  re I shouldn't g
64a0: 65 74 20 68 65 72 65 2e 22 29 29 0a 09 20 20 20  et here."))..   
64b0: 20 20 28 65 6c 73 65 0a 09 20 20 20 20 20 20 28    (else..      (
64c0: 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 49  debug:print 4 "I
64d0: 4e 46 4f 3a 20 45 78 69 74 69 6e 67 20 6c 6f 6f  NFO: Exiting loo
64e0: 70 20 77 69 74 68 2e 2e 2e 5c 6e 20 20 68 65 64  p with...\n  hed
64f0: 3d 22 20 68 65 64 20 22 5c 6e 20 20 74 61 6c 3d  =" hed "\n  tal=
6500: 22 20 74 61 6c 20 22 5c 6e 20 20 72 65 72 75 6e  " tal "\n  rerun
6510: 73 3d 22 20 72 65 72 75 6e 73 29 29 0a 09 20 20  s=" reruns))..  
6520: 20 20 20 29 29 29 29 20 3b 3b 20 4c 45 54 2a 20     )))) ;; LET* 
6530: 28 28 74 65 73 74 2d 72 65 63 6f 72 64 0a 0a 20  ((test-record.. 
6540: 20 20 20 3b 3b 20 77 65 20 67 65 74 20 68 65 72     ;; we get her
6550: 65 20 6f 6e 20 22 64 72 6f 70 20 74 68 72 6f 75  e on "drop throu
6560: 67 68 22 20 2d 20 6c 6f 6f 70 20 66 6f 72 20 6e  gh" - loop for n
6570: 65 78 74 20 74 65 73 74 20 69 6e 20 71 75 65 75  ext test in queu
6580: 65 0a 20 20 20 20 3b 3b 20 46 49 58 4d 45 21 21  e.    ;; FIXME!!
6590: 21 21 20 54 48 49 53 20 53 48 4f 55 4c 44 20 4e  !! THIS SHOULD N
65a0: 4f 54 20 52 45 51 55 49 52 45 20 41 4e 20 45 58  OT REQUIRE AN EX
65b0: 49 54 21 21 21 21 21 21 21 0a 20 20 20 20 0a 20  IT!!!!!!!.    . 
65c0: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
65d0: 31 20 22 49 4e 46 4f 3a 20 41 6c 6c 20 74 65 73  1 "INFO: All tes
65e0: 74 73 20 6c 61 75 6e 63 68 65 64 22 29 0a 20 20  ts launched").  
65f0: 20 20 28 74 68 72 65 61 64 2d 73 6c 65 65 70 21    (thread-sleep!
6600: 20 30 2e 35 29 0a 20 20 20 20 3b 3b 20 46 49 58   0.5).    ;; FIX
6610: 4d 45 21 20 54 68 69 73 20 68 61 72 73 68 20 65  ME! This harsh e
6620: 78 69 74 20 73 68 6f 75 6c 64 20 6e 6f 74 20 62  xit should not b
6630: 65 20 6e 65 63 65 73 73 61 72 79 2e 2e 2e 2e 0a  e necessary.....
6640: 20 20 20 20 3b 3b 20 28 69 66 20 28 6e 6f 74 20      ;; (if (not 
6650: 2a 72 75 6e 72 65 6d 6f 74 65 2a 29 28 65 78 69  *runremote*)(exi
6660: 74 29 29 20 3b 3b 20 0a 20 20 20 20 23 66 29 29  t)) ;; .    #f))
6670: 20 3b 3b 20 72 65 74 75 72 6e 20 61 20 23 66 20   ;; return a #f 
6680: 61 73 20 61 20 68 69 6e 74 20 74 68 61 74 20 77  as a hint that w
6690: 65 20 61 72 65 20 64 6f 6e 65 0a 20 20 3b 3b 20  e are done.  ;; 
66a0: 48 65 72 65 20 77 65 20 6e 65 65 64 20 74 6f 20  Here we need to 
66b0: 63 68 65 63 6b 20 74 68 61 74 20 61 6c 6c 20 74  check that all t
66c0: 68 65 20 74 65 73 74 73 20 72 65 6d 61 69 6e 69  he tests remaini
66d0: 6e 67 20 74 6f 20 62 65 20 72 75 6e 20 61 72 65  ng to be run are
66e0: 20 65 6c 69 67 69 62 6c 65 20 74 6f 20 72 75 6e   eligible to run
66f0: 0a 20 20 3b 3b 20 61 6e 64 20 61 72 65 20 6e 6f  .  ;; and are no
6700: 74 20 62 6c 6f 63 6b 65 64 20 62 79 20 66 61 69  t blocked by fai
6710: 6c 65 64 0a 20 20 0a 0a 3b 3b 20 70 61 72 65 6e  led.  ..;; paren
6720: 74 2d 74 65 73 74 20 69 73 20 74 68 65 72 65 20  t-test is there 
6730: 61 73 20 61 20 70 6c 61 63 65 68 6f 6c 64 65 72  as a placeholder
6740: 20 66 6f 72 20 77 68 65 6e 20 70 61 72 65 6e 74   for when parent
6750: 2d 74 65 73 74 73 20 63 61 6e 20 62 65 20 72 75  -tests can be ru
6760: 6e 20 61 73 20 61 20 73 65 74 75 70 20 73 74 65  n as a setup ste
6770: 70 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 3a 74  p.(define (run:t
6780: 65 73 74 20 72 75 6e 2d 69 64 20 72 75 6e 6e 61  est run-id runna
6790: 6d 65 20 6b 65 79 76 61 6c 6c 73 74 20 74 65 73  me keyvallst tes
67a0: 74 2d 72 65 63 6f 72 64 20 66 6c 61 67 73 20 70  t-record flags p
67b0: 61 72 65 6e 74 2d 74 65 73 74 29 0a 20 20 3b 3b  arent-test).  ;;
67c0: 20 41 6c 6c 20 74 68 65 73 65 20 76 61 72 73 20   All these vars 
67d0: 6d 69 67 68 74 20 62 65 20 72 65 66 65 72 65 6e  might be referen
67e0: 63 65 64 20 62 79 20 74 68 65 20 74 65 73 74 63  ced by the testc
67f0: 6f 6e 66 69 67 20 66 69 6c 65 20 72 65 61 64 65  onfig file reade
6800: 72 0a 20 20 28 6c 65 74 2a 20 28 28 74 65 73 74  r.  (let* ((test
6810: 2d 6e 61 6d 65 20 20 20 20 28 74 65 73 74 73 3a  -name    (tests:
6820: 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d 74 65  testqueue-get-te
6830: 73 74 6e 61 6d 65 20 20 20 74 65 73 74 2d 72 65  stname   test-re
6840: 63 6f 72 64 29 29 0a 09 20 28 74 65 73 74 2d 77  cord)).. (test-w
6850: 61 69 74 6f 6e 73 20 28 74 65 73 74 73 3a 74 65  aitons (tests:te
6860: 73 74 71 75 65 75 65 2d 67 65 74 2d 77 61 69 74  stqueue-get-wait
6870: 6f 6e 73 20 20 20 20 74 65 73 74 2d 72 65 63 6f  ons    test-reco
6880: 72 64 29 29 0a 09 20 28 74 65 73 74 2d 63 6f 6e  rd)).. (test-con
6890: 66 20 20 20 20 28 74 65 73 74 73 3a 74 65 73 74  f    (tests:test
68a0: 71 75 65 75 65 2d 67 65 74 2d 74 65 73 74 63 6f  queue-get-testco
68b0: 6e 66 69 67 20 74 65 73 74 2d 72 65 63 6f 72 64  nfig test-record
68c0: 29 29 0a 09 20 28 69 74 65 6d 64 61 74 20 20 20  )).. (itemdat   
68d0: 20 20 20 28 74 65 73 74 73 3a 74 65 73 74 71 75     (tests:testqu
68e0: 65 75 65 2d 67 65 74 2d 69 74 65 6d 64 61 74 20  eue-get-itemdat 
68f0: 20 20 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29     test-record))
6900: 0a 09 20 28 74 65 73 74 2d 70 61 74 68 20 20 20  .. (test-path   
6910: 20 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74 68 2a   (conc *toppath*
6920: 20 22 2f 74 65 73 74 73 2f 22 20 74 65 73 74 2d   "/tests/" test-
6930: 6e 61 6d 65 29 29 20 3b 3b 20 63 6f 75 6c 64 20  name)) ;; could 
6940: 75 73 65 20 74 65 73 74 73 3a 67 65 74 2d 74 65  use tests:get-te
6950: 73 74 63 6f 6e 66 69 67 20 68 65 72 65 20 2e 2e  stconfig here ..
6960: 2e 0a 09 20 28 66 6f 72 63 65 20 20 20 20 20 20  ... (force      
6970: 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65    (hash-table-re
6980: 66 2f 64 65 66 61 75 6c 74 20 66 6c 61 67 73 20  f/default flags 
6990: 22 2d 66 6f 72 63 65 22 20 23 66 29 29 0a 09 20  "-force" #f)).. 
69a0: 28 72 65 72 75 6e 20 20 20 20 20 20 20 20 28 68  (rerun        (h
69b0: 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65  ash-table-ref/de
69c0: 66 61 75 6c 74 20 66 6c 61 67 73 20 22 2d 72 65  fault flags "-re
69d0: 72 75 6e 22 20 23 66 29 29 0a 09 20 28 6b 65 65  run" #f)).. (kee
69e0: 70 67 6f 69 6e 67 20 20 20 20 28 68 61 73 68 2d  pgoing    (hash-
69f0: 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c  table-ref/defaul
6a00: 74 20 66 6c 61 67 73 20 22 2d 6b 65 65 70 67 6f  t flags "-keepgo
6a10: 69 6e 67 22 20 23 66 29 29 0a 09 20 28 69 74 65  ing" #f)).. (ite
6a20: 6d 2d 70 61 74 68 20 20 20 20 20 22 22 29 0a 09  m-path     "")..
6a30: 20 28 64 62 20 20 20 20 20 20 20 20 20 20 20 23   (db           #
6a40: 66 29 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70  f)).    (debug:p
6a50: 72 69 6e 74 20 34 0a 09 09 20 22 74 65 73 74 2d  rint 4... "test-
6a60: 63 6f 6e 66 69 67 3a 20 22 20 28 68 61 73 68 2d  config: " (hash-
6a70: 74 61 62 6c 65 2d 3e 61 6c 69 73 74 20 74 65 73  table->alist tes
6a80: 74 2d 63 6f 6e 66 29 0a 09 09 20 22 5c 6e 20 20  t-conf)... "\n  
6a90: 20 69 74 65 6d 64 61 74 3a 20 22 20 69 74 65 6d   itemdat: " item
6aa0: 64 61 74 0a 09 09 20 29 0a 20 20 20 20 3b 3b 20  dat... ).    ;; 
6ab0: 73 65 74 74 69 6e 67 20 69 74 65 6d 64 61 74 20  setting itemdat 
6ac0: 74 6f 20 61 20 6c 69 73 74 20 69 66 20 69 74 20  to a list if it 
6ad0: 69 73 20 23 66 0a 20 20 20 20 28 69 66 20 28 6e  is #f.    (if (n
6ae0: 6f 74 20 69 74 65 6d 64 61 74 29 28 73 65 74 21  ot itemdat)(set!
6af0: 20 69 74 65 6d 64 61 74 20 27 28 29 29 29 0a 20   itemdat '())). 
6b00: 20 20 20 28 73 65 74 21 20 69 74 65 6d 2d 70 61     (set! item-pa
6b10: 74 68 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70  th (item-list->p
6b20: 61 74 68 20 69 74 65 6d 64 61 74 29 29 0a 20 20  ath itemdat)).  
6b30: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32    (debug:print 2
6b40: 20 22 41 74 74 65 6d 70 74 69 6e 67 20 74 6f 20   "Attempting to 
6b50: 6c 61 75 6e 63 68 20 74 65 73 74 20 22 20 74 65  launch test " te
6b60: 73 74 2d 6e 61 6d 65 20 28 69 66 20 28 65 71 75  st-name (if (equ
6b70: 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 2f  al? item-path "/
6b80: 22 29 20 22 2f 22 20 69 74 65 6d 2d 70 61 74 68  ") "/" item-path
6b90: 29 29 0a 20 20 20 20 28 73 65 74 65 6e 76 20 22  )).    (setenv "
6ba0: 4d 54 5f 54 45 53 54 5f 4e 41 4d 45 22 20 74 65  MT_TEST_NAME" te
6bb0: 73 74 2d 6e 61 6d 65 29 20 3b 3b 20 0a 20 20 20  st-name) ;; .   
6bc0: 20 28 73 65 74 65 6e 76 20 22 4d 54 5f 52 55 4e   (setenv "MT_RUN
6bd0: 4e 41 4d 45 22 20 20 20 72 75 6e 6e 61 6d 65 29  NAME"   runname)
6be0: 0a 20 20 20 20 28 6f 70 65 6e 2d 72 75 6e 2d 63  .    (open-run-c
6bf0: 6c 6f 73 65 20 73 65 74 2d 6d 65 67 61 74 65 73  lose set-megates
6c00: 74 2d 65 6e 76 2d 76 61 72 73 20 64 62 20 72 75  t-env-vars db ru
6c10: 6e 2d 69 64 29 20 3b 3b 20 74 68 65 73 65 20 6d  n-id) ;; these m
6c20: 61 79 20 62 65 20 6e 65 65 64 65 64 20 62 79 20  ay be needed by 
6c30: 74 68 65 20 6c 61 75 6e 63 68 69 6e 67 20 70 72  the launching pr
6c40: 6f 63 65 73 73 0a 20 20 20 20 28 63 68 61 6e 67  ocess.    (chang
6c50: 65 2d 64 69 72 65 63 74 6f 72 79 20 2a 74 6f 70  e-directory *top
6c60: 70 61 74 68 2a 29 0a 0a 20 20 20 20 3b 3b 20 48  path*)..    ;; H
6c70: 65 72 65 20 69 73 20 77 68 65 72 65 20 74 68 65  ere is where the
6c80: 20 74 65 73 74 5f 6d 65 74 61 20 74 61 62 6c 65   test_meta table
6c90: 20 69 73 20 62 65 73 74 20 75 70 64 61 74 65 64   is best updated
6ca0: 0a 20 20 20 20 3b 3b 20 59 65 73 2c 20 61 6e 6f  .    ;; Yes, ano
6cb0: 74 68 65 72 20 75 73 65 20 6f 66 20 61 20 67 6c  ther use of a gl
6cc0: 6f 62 61 6c 20 66 6f 72 20 63 61 63 68 69 6e 67  obal for caching
6cd0: 2e 20 4e 65 65 64 20 61 20 62 65 74 74 65 72 20  . Need a better 
6ce0: 77 61 79 3f 0a 20 20 20 20 28 69 66 20 28 6e 6f  way?.    (if (no
6cf0: 74 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65  t (hash-table-re
6d00: 66 2f 64 65 66 61 75 6c 74 20 2a 74 65 73 74 2d  f/default *test-
6d10: 6d 65 74 61 2d 75 70 64 61 74 65 64 2a 20 74 65  meta-updated* te
6d20: 73 74 2d 6e 61 6d 65 20 23 66 29 29 0a 20 20 20  st-name #f)).   
6d30: 20 20 20 20 20 28 62 65 67 69 6e 0a 09 20 20 20       (begin..   
6d40: 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74 21  (hash-table-set!
6d50: 20 2a 74 65 73 74 2d 6d 65 74 61 2d 75 70 64 61   *test-meta-upda
6d60: 74 65 64 2a 20 74 65 73 74 2d 6e 61 6d 65 20 23  ted* test-name #
6d70: 74 29 0a 20 20 20 20 20 20 20 20 20 20 20 28 6f  t).           (o
6d80: 70 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 72 75  pen-run-close ru
6d90: 6e 73 3a 75 70 64 61 74 65 2d 74 65 73 74 5f 6d  ns:update-test_m
6da0: 65 74 61 20 64 62 20 74 65 73 74 2d 6e 61 6d 65  eta db test-name
6db0: 20 74 65 73 74 2d 63 6f 6e 66 29 29 29 0a 20 20   test-conf))).  
6dc0: 20 20 0a 20 20 20 20 3b 3b 20 28 6c 61 6d 62 64    .    ;; (lambd
6dd0: 61 20 28 69 74 65 6d 64 61 74 29 20 3b 3b 3b 20  a (itemdat) ;;; 
6de0: 28 28 72 69 70 65 6e 65 73 73 20 22 6f 76 65 72  ((ripeness "over
6df0: 72 69 70 65 22 29 20 28 74 65 6d 70 65 72 61 74  ripe") (temperat
6e00: 75 72 65 20 22 63 6f 6f 6c 22 29 20 28 73 65 61  ure "cool") (sea
6e10: 73 6f 6e 20 22 73 75 6d 6d 65 72 22 29 29 0a 20  son "summer")). 
6e20: 20 20 20 28 6c 65 74 2a 20 28 28 6e 65 77 2d 74     (let* ((new-t
6e30: 65 73 74 2d 70 61 74 68 20 28 73 74 72 69 6e 67  est-path (string
6e40: 2d 69 6e 74 65 72 73 70 65 72 73 65 20 28 63 6f  -intersperse (co
6e50: 6e 73 20 74 65 73 74 2d 70 61 74 68 20 28 6d 61  ns test-path (ma
6e60: 70 20 63 61 64 72 20 69 74 65 6d 64 61 74 29 29  p cadr itemdat))
6e70: 20 22 2f 22 29 29 0a 09 20 20 20 28 6e 65 77 2d   "/"))..   (new-
6e80: 74 65 73 74 2d 6e 61 6d 65 20 28 69 66 20 28 65  test-name (if (e
6e90: 71 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20  qual? item-path 
6ea0: 22 22 29 20 74 65 73 74 2d 6e 61 6d 65 20 28 63  "") test-name (c
6eb0: 6f 6e 63 20 74 65 73 74 2d 6e 61 6d 65 20 22 2f  onc test-name "/
6ec0: 22 20 69 74 65 6d 2d 70 61 74 68 29 29 29 20 3b  " item-path))) ;
6ed0: 3b 20 6a 75 73 74 20 6e 65 65 64 20 69 74 20 74  ; just need it t
6ee0: 6f 20 62 65 20 75 6e 69 71 75 65 0a 09 20 20 20  o be unique..   
6ef0: 28 74 65 73 74 2d 69 64 20 20 20 20 20 20 20 28  (test-id       (
6f00: 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 64  open-run-close d
6f10: 62 3a 67 65 74 2d 74 65 73 74 2d 69 64 20 64 62  b:get-test-id db
6f20: 20 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61    run-id test-na
6f30: 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29 0a 09  me item-path))..
6f40: 20 20 20 28 74 65 73 74 64 61 74 20 20 20 20 20     (testdat     
6f50: 20 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f 73    (open-run-clos
6f60: 65 20 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e  e db:get-test-in
6f70: 66 6f 2d 62 79 2d 69 64 20 64 62 20 74 65 73 74  fo-by-id db test
6f80: 2d 69 64 29 29 29 0a 20 20 20 20 20 20 28 69 66  -id))).      (if
6f90: 20 28 6e 6f 74 20 74 65 73 74 64 61 74 29 0a 09   (not testdat)..
6fa0: 20 20 28 62 65 67 69 6e 0a 09 20 20 20 20 3b 3b    (begin..    ;;
6fb0: 20 65 6e 73 75 72 65 20 74 68 61 74 20 74 68 65   ensure that the
6fc0: 20 70 61 74 68 20 65 78 69 73 74 73 20 62 65 66   path exists bef
6fd0: 6f 72 65 20 72 65 67 69 73 74 65 72 69 6e 67 20  ore registering 
6fe0: 74 68 65 20 74 65 73 74 0a 09 20 20 20 20 3b 3b  the test..    ;;
6ff0: 20 4e 4f 50 45 3a 20 43 61 6e 6e 6f 74 21 20 44   NOPE: Cannot! D
7000: 6f 6e 27 74 20 6b 6e 6f 77 20 79 65 74 20 77 68  on't know yet wh
7010: 69 63 68 20 64 69 73 6b 20 61 72 65 61 20 77 69  ich disk area wi
7020: 6c 6c 20 62 65 20 61 73 73 69 67 6e 65 64 2e 2e  ll be assigned..
7030: 2e 2e 0a 09 20 20 20 20 3b 3b 20 28 73 79 73 74  ....    ;; (syst
7040: 65 6d 20 28 63 6f 6e 63 20 22 6d 6b 64 69 72 20  em (conc "mkdir 
7050: 2d 70 20 22 20 6e 65 77 2d 74 65 73 74 2d 70 61  -p " new-test-pa
7060: 74 68 29 29 0a 09 20 20 20 20 3b 3b 0a 09 20 20  th))..    ;;..  
7070: 20 20 3b 3b 20 28 6f 70 65 6e 2d 72 75 6e 2d 63    ;; (open-run-c
7080: 6c 6f 73 65 20 74 65 73 74 73 3a 72 65 67 69 73  lose tests:regis
7090: 74 65 72 2d 74 65 73 74 20 64 62 20 72 75 6e 2d  ter-test db run-
70a0: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65  id test-name ite
70b0: 6d 2d 70 61 74 68 29 0a 09 20 20 20 20 3b 3b 0a  m-path)..    ;;.
70c0: 09 20 20 20 20 3b 3b 20 4e 42 2f 2f 20 66 6f 72  .    ;; NB// for
70d0: 20 74 68 65 20 61 62 6f 76 65 20 6c 69 6e 65 2e   the above line.
70e0: 20 49 20 77 61 6e 74 20 74 68 65 20 74 65 73 74   I want the test
70f0: 20 74 6f 20 62 65 20 72 65 67 69 73 74 65 72 65   to be registere
7100: 64 20 6c 6f 6e 67 20 62 65 66 6f 72 65 20 74 68  d long before th
7110: 69 73 20 72 6f 75 74 69 6e 65 20 67 65 74 73 20  is routine gets 
7120: 63 61 6c 6c 65 64 21 0a 09 20 20 20 20 3b 3b 0a  called!..    ;;.
7130: 09 20 20 20 20 28 73 65 74 21 20 74 65 73 74 2d  .    (set! test-
7140: 69 64 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f  id (open-run-clo
7150: 73 65 20 64 62 3a 67 65 74 2d 74 65 73 74 2d 69  se db:get-test-i
7160: 64 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  d db run-id test
7170: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  -name item-path)
7180: 29 0a 09 20 20 20 20 28 69 66 20 28 6e 6f 74 20  )..    (if (not 
7190: 74 65 73 74 2d 69 64 29 0a 09 09 28 62 65 67 69  test-id)...(begi
71a0: 6e 0a 09 09 20 20 28 64 65 62 75 67 3a 70 72 69  n...  (debug:pri
71b0: 6e 74 20 32 20 22 57 41 52 4e 3a 20 54 65 73 74  nt 2 "WARN: Test
71c0: 20 6e 6f 74 20 70 72 65 2d 63 72 65 61 74 65 64   not pre-created
71d0: 3f 20 74 65 73 74 2d 6e 61 6d 65 3d 22 20 74 65  ? test-name=" te
71e0: 73 74 2d 6e 61 6d 65 20 22 2c 20 69 74 65 6d 2d  st-name ", item-
71f0: 70 61 74 68 3d 22 20 69 74 65 6d 2d 70 61 74 68  path=" item-path
7200: 20 22 2c 20 72 75 6e 2d 69 64 3d 22 20 72 75 6e   ", run-id=" run
7210: 2d 69 64 29 0a 09 09 20 20 3b 3b 20 28 6f 70 65  -id)...  ;; (ope
7220: 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 64 62 3a 74  n-run-close db:t
7230: 65 73 74 73 2d 72 65 67 69 73 74 65 72 2d 74 65  ests-register-te
7240: 73 74 20 23 66 20 72 75 6e 2d 69 64 20 74 65 73  st #f run-id tes
7250: 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68  t-name item-path
7260: 29 0a 09 09 20 20 28 72 64 62 3a 74 65 73 74 73  )...  (rdb:tests
7270: 2d 72 65 67 69 73 74 65 72 2d 74 65 73 74 20 72  -register-test r
7280: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
7290: 69 74 65 6d 2d 70 61 74 68 29 0a 09 09 20 20 28  item-path)...  (
72a0: 72 64 62 3a 66 6c 75 73 68 2d 71 75 65 75 65 29  rdb:flush-queue)
72b0: 0a 09 09 20 20 28 73 65 74 21 20 74 65 73 74 2d  ...  (set! test-
72c0: 69 64 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f  id (open-run-clo
72d0: 73 65 20 64 62 3a 67 65 74 2d 74 65 73 74 2d 69  se db:get-test-i
72e0: 64 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  d db run-id test
72f0: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  -name item-path)
7300: 29 29 29 0a 09 20 20 20 20 28 64 65 62 75 67 3a  )))..    (debug:
7310: 70 72 69 6e 74 20 34 20 22 49 4e 46 4f 3a 20 74  print 4 "INFO: t
7320: 65 73 74 2d 69 64 3d 22 20 74 65 73 74 2d 69 64  est-id=" test-id
7330: 20 22 2c 20 72 75 6e 2d 69 64 3d 22 20 72 75 6e   ", run-id=" run
7340: 2d 69 64 20 22 2c 20 74 65 73 74 2d 6e 61 6d 65  -id ", test-name
7350: 3d 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 2c 20  =" test-name ", 
7360: 69 74 65 6d 2d 70 61 74 68 3d 5c 22 22 20 69 74  item-path=\"" it
7370: 65 6d 2d 70 61 74 68 20 22 5c 22 22 29 0a 09 20  em-path "\"").. 
7380: 20 20 20 28 73 65 74 21 20 74 65 73 74 64 61 74     (set! testdat
7390: 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65   (open-run-close
73a0: 20 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66   db:get-test-inf
73b0: 6f 2d 62 79 2d 69 64 20 64 62 20 74 65 73 74 2d  o-by-id db test-
73c0: 69 64 29 29 29 29 0a 20 20 20 20 20 20 28 73 65  id)))).      (se
73d0: 74 21 20 74 65 73 74 2d 69 64 20 28 64 62 3a 74  t! test-id (db:t
73e0: 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74 64  est-get-id testd
73f0: 61 74 29 29 0a 20 20 20 20 20 20 28 63 68 61 6e  at)).      (chan
7400: 67 65 2d 64 69 72 65 63 74 6f 72 79 20 74 65 73  ge-directory tes
7410: 74 2d 70 61 74 68 29 0a 20 20 20 20 20 20 28 63  t-path).      (c
7420: 61 73 65 20 28 69 66 20 66 6f 72 63 65 20 3b 3b  ase (if force ;;
7430: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22   (args:get-arg "
7440: 2d 66 6f 72 63 65 22 29 0a 09 09 27 4e 4f 54 5f  -force")...'NOT_
7450: 53 54 41 52 54 45 44 0a 09 09 28 69 66 20 74 65  STARTED...(if te
7460: 73 74 64 61 74 0a 09 09 20 20 20 20 28 73 74 72  stdat...    (str
7470: 69 6e 67 2d 3e 73 79 6d 62 6f 6c 20 28 74 65 73  ing->symbol (tes
7480: 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74  t:get-state test
7490: 64 61 74 29 29 0a 09 09 20 20 20 20 27 66 61 69  dat))...    'fai
74a0: 6c 65 64 2d 74 6f 2d 69 6e 73 65 72 74 29 29 0a  led-to-insert)).
74b0: 09 28 28 66 61 69 6c 65 64 2d 74 6f 2d 69 6e 73  .((failed-to-ins
74c0: 65 72 74 29 0a 09 20 28 64 65 62 75 67 3a 70 72  ert).. (debug:pr
74d0: 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 46 61  int 0 "ERROR: Fa
74e0: 69 6c 65 64 20 74 6f 20 69 6e 73 65 72 74 20 74  iled to insert t
74f0: 68 65 20 72 65 63 6f 72 64 20 69 6e 74 6f 20 74  he record into t
7500: 68 65 20 64 62 22 29 29 0a 09 28 28 4e 4f 54 5f  he db"))..((NOT_
7510: 53 54 41 52 54 45 44 20 43 4f 4d 50 4c 45 54 45  STARTED COMPLETE
7520: 44 29 0a 09 20 28 6c 65 74 20 28 28 72 75 6e 66  D).. (let ((runf
7530: 6c 61 67 20 23 66 29 29 0a 09 20 20 20 28 63 6f  lag #f))..   (co
7540: 6e 64 0a 09 20 20 20 20 3b 3b 20 2d 66 6f 72 63  nd..    ;; -forc
7550: 65 2c 20 72 75 6e 20 6e 6f 20 6d 61 74 74 65 72  e, run no matter
7560: 20 77 68 61 74 0a 09 20 20 20 20 28 66 6f 72 63   what..    (forc
7570: 65 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20  e (set! runflag 
7580: 23 74 29 29 0a 09 20 20 20 20 3b 3b 20 4e 4f 54  #t))..    ;; NOT
7590: 5f 53 54 41 52 54 45 44 2c 20 72 75 6e 20 6e 6f  _STARTED, run no
75a0: 20 6d 61 74 74 65 72 20 77 68 61 74 0a 09 20 20   matter what..  
75b0: 20 20 28 28 65 71 75 61 6c 3f 20 28 74 65 73 74    ((equal? (test
75c0: 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64  :get-state testd
75d0: 61 74 29 20 22 4e 4f 54 5f 53 54 41 52 54 45 44  at) "NOT_STARTED
75e0: 22 29 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20  ")(set! runflag 
75f0: 23 74 29 29 0a 09 20 20 20 20 3b 3b 20 6e 6f 74  #t))..    ;; not
7600: 20 2d 72 65 72 75 6e 20 61 6e 64 20 50 41 53 53   -rerun and PASS
7610: 2c 20 57 41 52 4e 20 6f 72 20 43 48 45 43 4b 2c  , WARN or CHECK,
7620: 20 64 6f 20 6e 6f 20 72 75 6e 0a 09 20 20 20 20   do no run..    
7630: 28 28 61 6e 64 20 28 6f 72 20 28 6e 6f 74 20 72  ((and (or (not r
7640: 65 72 75 6e 29 0a 09 09 20 20 20 20 20 20 6b 65  erun)...      ke
7650: 65 70 67 6f 69 6e 67 29 0a 09 09 20 20 3b 3b 20  epgoing)...  ;; 
7660: 52 65 71 75 69 72 65 20 74 6f 20 66 6f 72 63 65  Require to force
7670: 20 72 65 2d 72 75 6e 20 66 6f 72 20 43 4f 4d 50   re-run for COMP
7680: 4c 45 54 45 44 20 6f 72 20 2a 61 6e 79 74 68 69  LETED or *anythi
7690: 6e 67 2a 20 2b 20 50 41 53 53 2c 57 41 52 4e 20  ng* + PASS,WARN 
76a0: 6f 72 20 43 48 45 43 4b 0a 09 09 20 20 28 6f 72  or CHECK...  (or
76b0: 20 28 6d 65 6d 62 65 72 20 28 74 65 73 74 3a 67   (member (test:g
76c0: 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61  et-status testda
76d0: 74 29 20 27 28 22 50 41 53 53 22 20 22 57 41 52  t) '("PASS" "WAR
76e0: 4e 22 20 22 43 48 45 43 4b 22 29 29 0a 09 09 20  N" "CHECK"))... 
76f0: 20 20 20 20 20 28 6d 65 6d 62 65 72 20 28 74 65       (member (te
7700: 73 74 3a 67 65 74 2d 73 74 61 74 65 20 20 74 65  st:get-state  te
7710: 73 74 64 61 74 29 20 27 28 22 43 4f 4d 50 4c 45  stdat) '("COMPLE
7720: 54 45 44 22 29 29 29 29 20 0a 09 20 20 20 20 20  TED")))) ..     
7730: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22  (debug:print 2 "
7740: 49 4e 46 4f 3a 20 72 75 6e 6e 69 6e 67 20 74 65  INFO: running te
7750: 73 74 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22  st " test-name "
7760: 2f 22 20 69 74 65 6d 2d 70 61 74 68 20 22 20 73  /" item-path " s
7770: 75 70 70 72 65 73 73 65 64 20 61 73 20 69 74 20  uppressed as it 
7780: 69 73 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73  is " (test:get-s
7790: 74 61 74 65 20 74 65 73 74 64 61 74 29 20 22 20  tate testdat) " 
77a0: 61 6e 64 20 22 20 28 74 65 73 74 3a 67 65 74 2d  and " (test:get-
77b0: 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29 29  status testdat))
77c0: 0a 09 20 20 20 20 20 28 73 65 74 21 20 72 75 6e  ..     (set! run
77d0: 66 6c 61 67 20 23 66 29 29 0a 09 20 20 20 20 3b  flag #f))..    ;
77e0: 3b 20 2d 72 65 72 75 6e 20 61 6e 64 20 73 74 61  ; -rerun and sta
77f0: 74 75 73 20 69 73 20 6f 6e 65 20 6f 66 20 74 68  tus is one of th
7800: 65 20 73 70 65 63 69 66 65 64 2c 20 72 75 6e 20  e specifed, run 
7810: 69 74 0a 09 20 20 20 20 28 28 61 6e 64 20 72 65  it..    ((and re
7820: 72 75 6e 0a 09 09 20 20 28 6c 65 74 2a 20 28 28  run...  (let* ((
7830: 72 65 72 75 6e 6c 73 74 20 20 20 28 73 74 72 69  rerunlst   (stri
7840: 6e 67 2d 73 70 6c 69 74 20 72 65 72 75 6e 20 22  ng-split rerun "
7850: 2c 22 29 29 0a 09 09 09 20 28 6d 75 73 74 2d 72  ,")).... (must-r
7860: 65 72 75 6e 20 28 6d 65 6d 62 65 72 20 28 74 65  erun (member (te
7870: 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65  st:get-status te
7880: 73 74 64 61 74 29 20 72 65 72 75 6e 6c 73 74 29  stdat) rerunlst)
7890: 29 29 0a 09 09 20 20 20 20 28 64 65 62 75 67 3a  ))...    (debug:
78a0: 70 72 69 6e 74 20 33 20 22 49 4e 46 4f 3a 20 2d  print 3 "INFO: -
78b0: 72 65 72 75 6e 20 6c 69 73 74 3a 20 22 20 72 65  rerun list: " re
78c0: 72 75 6e 20 22 2c 20 74 65 73 74 2d 73 74 61 74  run ", test-stat
78d0: 75 73 3a 20 22 20 28 74 65 73 74 3a 67 65 74 2d  us: " (test:get-
78e0: 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29 22  status testdat)"
78f0: 2c 20 6d 75 73 74 2d 72 65 72 75 6e 3a 20 22 20  , must-rerun: " 
7900: 6d 75 73 74 2d 72 65 72 75 6e 29 0a 09 09 20 20  must-rerun)...  
7910: 20 20 6d 75 73 74 2d 72 65 72 75 6e 29 29 0a 09    must-rerun))..
7920: 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e       (debug:prin
7930: 74 20 32 20 22 49 4e 46 4f 3a 20 52 65 72 75 6e  t 2 "INFO: Rerun
7940: 20 66 6f 72 63 65 64 20 66 6f 72 20 74 65 73 74   forced for test
7950: 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 2f 22   " test-name "/"
7960: 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 20 20 20   item-path)..   
7970: 20 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20    (set! runflag 
7980: 23 74 29 29 0a 09 20 20 20 20 3b 3b 20 2d 6b 65  #t))..    ;; -ke
7990: 65 70 67 6f 69 6e 67 2c 20 64 6f 20 6e 6f 74 20  epgoing, do not 
79a0: 72 65 72 75 6e 20 46 41 49 4c 0a 09 20 20 20 20  rerun FAIL..    
79b0: 28 28 61 6e 64 20 6b 65 65 70 67 6f 69 6e 67 0a  ((and keepgoing.
79c0: 09 09 20 20 28 6d 65 6d 62 65 72 20 28 74 65 73  ..  (member (tes
79d0: 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73  t:get-status tes
79e0: 74 64 61 74 29 20 27 28 22 46 41 49 4c 22 29 29  tdat) '("FAIL"))
79f0: 29 0a 09 20 20 20 20 20 28 73 65 74 21 20 72 75  )..     (set! ru
7a00: 6e 66 6c 61 67 20 23 66 29 29 0a 09 20 20 20 20  nflag #f))..    
7a10: 28 28 61 6e 64 20 28 6e 6f 74 20 72 65 72 75 6e  ((and (not rerun
7a20: 29 0a 09 09 20 20 28 6d 65 6d 62 65 72 20 28 74  )...  (member (t
7a30: 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74  est:get-status t
7a40: 65 73 74 64 61 74 29 20 27 28 22 46 41 49 4c 22  estdat) '("FAIL"
7a50: 20 22 6e 2f 61 22 29 29 29 0a 09 20 20 20 20 20   "n/a")))..     
7a60: 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 74  (set! runflag #t
7a70: 29 29 0a 09 20 20 20 20 28 65 6c 73 65 20 28 73  ))..    (else (s
7a80: 65 74 21 20 72 75 6e 66 6c 61 67 20 23 66 29 29  et! runflag #f))
7a90: 29 0a 09 20 20 20 28 64 65 62 75 67 3a 70 72 69  )..   (debug:pri
7aa0: 6e 74 20 36 20 22 52 55 4e 4e 49 4e 47 20 3d 3e  nt 6 "RUNNING =>
7ab0: 20 72 75 6e 66 6c 61 67 3a 20 22 20 72 75 6e 66   runflag: " runf
7ac0: 6c 61 67 20 22 20 53 54 41 54 45 3a 20 22 20 28  lag " STATE: " (
7ad0: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74  test:get-state t
7ae0: 65 73 74 64 61 74 29 20 22 20 53 54 41 54 55 53  estdat) " STATUS
7af0: 3a 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74  : " (test:get-st
7b00: 61 74 75 73 20 74 65 73 74 64 61 74 29 29 0a 09  atus testdat))..
7b10: 20 20 20 28 69 66 20 28 6e 6f 74 20 72 75 6e 66     (if (not runf
7b20: 6c 61 67 29 0a 09 20 20 20 20 20 20 20 28 69 66  lag)..       (if
7b30: 20 28 6e 6f 74 20 70 61 72 65 6e 74 2d 74 65 73   (not parent-tes
7b40: 74 29 0a 09 09 20 20 20 28 64 65 62 75 67 3a 70  t)...   (debug:p
7b50: 72 69 6e 74 20 31 20 22 4e 4f 54 45 3a 20 4e 6f  rint 1 "NOTE: No
7b60: 74 20 73 74 61 72 74 69 6e 67 20 74 65 73 74 20  t starting test 
7b70: 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20  " new-test-name 
7b80: 22 20 61 73 20 69 74 20 69 73 20 73 74 61 74 65  " as it is state
7b90: 20 5c 22 22 20 28 74 65 73 74 3a 67 65 74 2d 73   \"" (test:get-s
7ba0: 74 61 74 65 20 74 65 73 74 64 61 74 29 20 0a 09  tate testdat) ..
7bb0: 09 09 09 22 5c 22 20 61 6e 64 20 73 74 61 74 75  ..."\" and statu
7bc0: 73 20 5c 22 22 20 28 74 65 73 74 3a 67 65 74 2d  s \"" (test:get-
7bd0: 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29 20  status testdat) 
7be0: 22 5c 22 2c 20 75 73 65 20 2d 72 65 72 75 6e 20  "\", use -rerun 
7bf0: 5c 22 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74  \"" (test:get-st
7c00: 61 74 75 73 20 74 65 73 74 64 61 74 29 0a 20 20  atus testdat).  
7c10: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
7c20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 22 5c                "\
7c30: 22 20 6f 72 20 2d 66 6f 72 63 65 20 74 6f 20 6f  " or -force to o
7c40: 76 65 72 72 69 64 65 22 29 29 0a 09 20 20 20 20  verride"))..    
7c50: 20 20 20 3b 3b 20 4e 4f 54 45 3a 20 4e 6f 20 6c     ;; NOTE: No l
7c60: 6f 6e 67 65 72 20 62 65 20 63 68 65 63 6b 69 6e  onger be checkin
7c70: 67 20 70 72 65 72 65 71 75 69 73 69 74 65 73 20  g prerequisites 
7c80: 68 65 72 65 21 20 57 69 6c 6c 20 6e 65 76 65 72  here! Will never
7c90: 20 67 65 74 20 68 65 72 65 20 75 6e 6c 65 73 73   get here unless
7ca0: 20 70 72 65 72 65 71 73 20 61 72 65 0a 09 20 20   prereqs are..  
7cb0: 20 20 20 20 20 3b 3b 20 20 20 20 20 20 20 61 6c       ;;       al
7cc0: 72 65 61 64 79 20 6d 65 74 2e 0a 09 20 20 20 20  ready met...    
7cd0: 20 20 20 28 69 66 20 28 6e 6f 74 20 28 6c 61 75     (if (not (lau
7ce0: 6e 63 68 2d 74 65 73 74 20 23 66 20 72 75 6e 2d  nch-test #f run-
7cf0: 69 64 20 72 75 6e 6e 61 6d 65 20 74 65 73 74 2d  id runname test-
7d00: 63 6f 6e 66 20 6b 65 79 76 61 6c 6c 73 74 20 74  conf keyvallst t
7d10: 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 2d 70 61  est-name test-pa
7d20: 74 68 20 69 74 65 6d 64 61 74 20 66 6c 61 67 73  th itemdat flags
7d30: 29 29 0a 09 09 20 20 20 28 62 65 67 69 6e 0a 09  ))...   (begin..
7d40: 09 20 20 20 20 20 28 70 72 69 6e 74 20 22 45 52  .     (print "ER
7d50: 52 4f 52 3a 20 46 61 69 6c 65 64 20 74 6f 20 6c  ROR: Failed to l
7d60: 61 75 6e 63 68 20 74 68 65 20 74 65 73 74 2e 20  aunch the test. 
7d70: 45 78 69 74 69 6e 67 20 61 73 20 73 6f 6f 6e 20  Exiting as soon 
7d80: 61 73 20 70 6f 73 73 69 62 6c 65 22 29 0a 09 09  as possible")...
7d90: 20 20 20 20 20 28 73 65 74 21 20 2a 67 6c 6f 62       (set! *glob
7da0: 61 6c 65 78 69 74 73 74 61 74 75 73 2a 20 31 29  alexitstatus* 1)
7db0: 20 3b 3b 20 0a 09 09 20 20 20 20 20 28 70 72 6f   ;; ...     (pro
7dc0: 63 65 73 73 2d 73 69 67 6e 61 6c 20 28 63 75 72  cess-signal (cur
7dd0: 72 65 6e 74 2d 70 72 6f 63 65 73 73 2d 69 64 29  rent-process-id)
7de0: 20 73 69 67 6e 61 6c 2f 6b 69 6c 6c 29 29 29 29   signal/kill))))
7df0: 29 29 0a 09 28 28 4b 49 4c 4c 45 44 29 20 0a 09  ))..((KILLED) ..
7e00: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20   (debug:print 1 
7e10: 22 4e 4f 54 45 3a 20 22 20 6e 65 77 2d 74 65 73  "NOTE: " new-tes
7e20: 74 2d 6e 61 6d 65 20 22 20 69 73 20 61 6c 72 65  t-name " is alre
7e30: 61 64 79 20 72 75 6e 6e 69 6e 67 20 6f 72 20 77  ady running or w
7e40: 61 73 20 65 78 70 6c 69 63 74 6c 79 20 6b 69 6c  as explictly kil
7e50: 6c 65 64 2c 20 75 73 65 20 2d 66 6f 72 63 65 20  led, use -force 
7e60: 74 6f 20 6c 61 75 6e 63 68 20 69 74 2e 22 29 29  to launch it."))
7e70: 0a 09 28 28 4c 41 55 4e 43 48 45 44 20 52 45 4d  ..((LAUNCHED REM
7e80: 4f 54 45 48 4f 53 54 53 54 41 52 54 20 52 55 4e  OTEHOSTSTART RUN
7e90: 4e 49 4e 47 29 20 20 0a 09 20 28 69 66 20 28 3e  NING)  .. (if (>
7ea0: 20 28 2d 20 28 63 75 72 72 65 6e 74 2d 73 65 63   (- (current-sec
7eb0: 6f 6e 64 73 29 28 2b 20 28 64 62 3a 74 65 73 74  onds)(+ (db:test
7ec0: 2d 67 65 74 2d 65 76 65 6e 74 5f 74 69 6d 65 20  -get-event_time 
7ed0: 74 65 73 74 64 61 74 29 0a 09 09 09 09 20 20 20  testdat).....   
7ee0: 20 20 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74      (db:test-get
7ef0: 2d 72 75 6e 5f 64 75 72 61 74 69 6f 6e 20 74 65  -run_duration te
7f00: 73 74 64 61 74 29 29 29 0a 09 09 36 30 30 29 20  stdat)))...600) 
7f10: 3b 3b 20 69 2e 65 2e 20 6e 6f 20 75 70 64 61 74  ;; i.e. no updat
7f20: 65 20 66 6f 72 20 6d 6f 72 65 20 74 68 61 6e 20  e for more than 
7f30: 36 30 30 20 73 65 63 6f 6e 64 73 0a 09 20 20 20  600 seconds..   
7f40: 20 20 28 62 65 67 69 6e 0a 09 20 20 20 20 20 20    (begin..      
7f50: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
7f60: 22 57 41 52 4e 49 4e 47 3a 20 54 65 73 74 20 22  "WARNING: Test "
7f70: 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 61 70 70   test-name " app
7f80: 65 61 72 73 20 74 6f 20 62 65 20 64 65 61 64 2e  ears to be dead.
7f90: 20 46 6f 72 63 69 6e 67 20 69 74 20 74 6f 20 73   Forcing it to s
7fa0: 74 61 74 65 20 49 4e 43 4f 4d 50 4c 45 54 45 20  tate INCOMPLETE 
7fb0: 61 6e 64 20 73 74 61 74 75 73 20 53 54 55 43 4b  and status STUCK
7fc0: 2f 44 45 41 44 22 29 0a 09 20 20 20 20 20 20 20  /DEAD")..       
7fd0: 28 74 65 73 74 73 3a 74 65 73 74 2d 73 65 74 2d  (tests:test-set-
7fe0: 73 74 61 74 75 73 21 20 74 65 73 74 2d 69 64 20  status! test-id 
7ff0: 22 49 4e 43 4f 4d 50 4c 45 54 45 22 20 22 53 54  "INCOMPLETE" "ST
8000: 55 43 4b 2f 44 45 41 44 22 20 22 54 65 73 74 20  UCK/DEAD" "Test 
8010: 69 73 20 73 74 75 63 6b 20 6f 72 20 64 65 61 64  is stuck or dead
8020: 22 20 23 66 29 0a 09 20 20 20 20 20 20 20 3b 3b  " #f)..       ;;
8030: 20 28 72 64 62 3a 66 6c 75 73 68 2d 71 75 65 75   (rdb:flush-queu
8040: 65 29 0a 09 20 20 20 20 20 20 20 29 0a 09 20 20  e)..       )..  
8050: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
8060: 32 20 22 4e 4f 54 45 3a 20 22 20 74 65 73 74 2d  2 "NOTE: " test-
8070: 6e 61 6d 65 20 22 20 69 73 20 61 6c 72 65 61 64  name " is alread
8080: 79 20 72 75 6e 6e 69 6e 67 22 29 29 29 0a 09 28  y running")))..(
8090: 65 6c 73 65 20 20 20 20 20 20 20 28 64 65 62 75  else       (debu
80a0: 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52  g:print 0 "ERROR
80b0: 3a 20 46 61 69 6c 65 64 20 74 6f 20 6c 61 75 6e  : Failed to laun
80c0: 63 68 20 74 65 73 74 20 22 20 6e 65 77 2d 74 65  ch test " new-te
80d0: 73 74 2d 6e 61 6d 65 20 22 2e 20 55 6e 72 65 63  st-name ". Unrec
80e0: 6f 67 6e 69 73 65 64 20 73 74 61 74 65 20 22 20  ognised state " 
80f0: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20  (test:get-state 
8100: 74 65 73 74 64 61 74 29 29 29 29 29 29 29 0a 0a  testdat)))))))..
8110: 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ;;==============
8120: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
8130: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
8140: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
8150: 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 45 4e 44 20  ========.;; END 
8160: 4f 46 20 4e 45 57 20 53 54 55 46 46 0a 3b 3b 3d  OF NEW STUFF.;;=
8170: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
8180: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
8190: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
81a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
81b0: 3d 3d 3d 3d 3d 0a 0a 28 64 65 66 69 6e 65 20 28  =====..(define (
81c0: 67 65 74 2d 64 69 72 2d 75 70 2d 6e 20 64 69 72  get-dir-up-n dir
81d0: 20 2e 20 70 61 72 61 6d 73 29 20 0a 20 20 28 6c   . params) .  (l
81e0: 65 74 20 28 28 64 70 61 72 74 73 20 20 28 73 74  et ((dparts  (st
81f0: 72 69 6e 67 2d 73 70 6c 69 74 20 64 69 72 20 22  ring-split dir "
8200: 2f 22 29 29 0a 09 28 63 6f 75 6e 74 20 20 20 28  /"))..(count   (
8210: 69 66 20 28 6e 75 6c 6c 3f 20 70 61 72 61 6d 73  if (null? params
8220: 29 20 31 20 28 63 61 72 20 70 61 72 61 6d 73 29  ) 1 (car params)
8230: 29 29 29 0a 20 20 20 20 28 63 6f 6e 63 20 22 2f  ))).    (conc "/
8240: 22 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73  " (string-inters
8250: 70 65 72 73 65 20 0a 09 20 20 20 20 20 20 20 28  perse ..       (
8260: 74 61 6b 65 20 64 70 61 72 74 73 20 28 2d 20 28  take dparts (- (
8270: 6c 65 6e 67 74 68 20 64 70 61 72 74 73 29 20 63  length dparts) c
8280: 6f 75 6e 74 29 29 0a 09 20 20 20 20 20 20 20 22  ount))..       "
8290: 2f 22 29 29 29 29 0a 3b 3b 20 52 65 6d 6f 76 65  /")))).;; Remove
82a0: 20 72 75 6e 73 0a 3b 3b 20 66 69 65 6c 64 73 20   runs.;; fields 
82b0: 61 72 65 20 70 61 73 73 69 6e 67 20 69 6e 20 74  are passing in t
82c0: 68 72 6f 75 67 68 20 0a 3b 3b 20 61 63 74 69 6f  hrough .;; actio
82d0: 6e 3a 0a 3b 3b 20 20 20 20 27 72 65 6d 6f 76 65  n:.;;    'remove
82e0: 2d 72 75 6e 73 0a 3b 3b 20 20 20 20 27 73 65 74  -runs.;;    'set
82f0: 2d 73 74 61 74 65 2d 73 74 61 74 75 73 0a 3b 3b  -state-status.;;
8300: 0a 3b 3b 20 4e 42 2f 2f 20 73 68 6f 75 6c 64 20  .;; NB// should 
8310: 70 61 73 73 20 69 6e 20 6b 65 79 73 3f 0a 3b 3b  pass in keys?.;;
8320: 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 6f  .(define (runs:o
8330: 70 65 72 61 74 65 2d 6f 6e 20 61 63 74 69 6f 6e  perate-on action
8340: 20 72 75 6e 6e 61 6d 65 70 61 74 74 20 74 65 73   runnamepatt tes
8350: 74 70 61 74 74 20 69 74 65 6d 70 61 74 74 20 23  tpatt itempatt #
8360: 21 6b 65 79 20 28 73 74 61 74 65 20 23 66 29 28  !key (state #f)(
8370: 73 74 61 74 75 73 20 23 66 29 28 6e 65 77 2d 73  status #f)(new-s
8380: 74 61 74 65 2d 73 74 61 74 75 73 20 23 66 29 29  tate-status #f))
8390: 0a 20 20 28 6c 65 74 2a 20 28 28 64 62 20 20 20  .  (let* ((db   
83a0: 20 20 20 20 20 20 20 20 23 66 29 0a 09 20 28 6b          #f).. (k
83b0: 65 79 73 20 20 20 20 20 20 20 20 20 28 6f 70 65  eys         (ope
83c0: 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 64 62 3a 67  n-run-close db:g
83d0: 65 74 2d 6b 65 79 73 20 64 62 29 29 0a 09 20 28  et-keys db)).. (
83e0: 72 75 6e 64 61 74 20 20 20 20 20 20 20 28 6f 70  rundat       (op
83f0: 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 72 75 6e  en-run-close run
8400: 73 3a 67 65 74 2d 72 75 6e 73 2d 62 79 2d 70 61  s:get-runs-by-pa
8410: 74 74 20 64 62 20 6b 65 79 73 20 72 75 6e 6e 61  tt db keys runna
8420: 6d 65 70 61 74 74 29 29 0a 09 20 28 68 65 61 64  mepatt)).. (head
8430: 65 72 20 20 20 20 20 20 20 28 76 65 63 74 6f 72  er       (vector
8440: 2d 72 65 66 20 72 75 6e 64 61 74 20 30 29 29 0a  -ref rundat 0)).
8450: 09 20 28 72 75 6e 73 20 20 20 20 20 20 20 20 20  . (runs         
8460: 28 76 65 63 74 6f 72 2d 72 65 66 20 72 75 6e 64  (vector-ref rund
8470: 61 74 20 31 29 29 0a 09 20 28 73 74 61 74 65 73  at 1)).. (states
8480: 20 20 20 20 20 20 20 28 69 66 20 73 74 61 74 65         (if state
8490: 20 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20    (string-split 
84a0: 73 74 61 74 65 20 20 22 2c 22 29 20 27 28 29 29  state  ",") '())
84b0: 29 0a 09 20 28 73 74 61 74 75 73 65 73 20 20 20  ).. (statuses   
84c0: 20 20 28 69 66 20 73 74 61 74 75 73 20 28 73 74    (if status (st
84d0: 72 69 6e 67 2d 73 70 6c 69 74 20 73 74 61 74 75  ring-split statu
84e0: 73 20 22 2c 22 29 20 27 28 29 29 29 0a 09 20 28  s ",") '())).. (
84f0: 73 74 61 74 65 2d 73 74 61 74 75 73 20 28 69 66  state-status (if
8500: 20 28 73 74 72 69 6e 67 3f 20 6e 65 77 2d 73 74   (string? new-st
8510: 61 74 65 2d 73 74 61 74 75 73 29 20 28 73 74 72  ate-status) (str
8520: 69 6e 67 2d 73 70 6c 69 74 20 6e 65 77 2d 73 74  ing-split new-st
8530: 61 74 65 2d 73 74 61 74 75 73 20 22 2c 22 29 20  ate-status ",") 
8540: 27 28 23 66 20 23 66 29 29 29 29 0a 20 20 20 20  '(#f #f)))).    
8550: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22  (debug:print 2 "
8560: 48 65 61 64 65 72 3a 20 22 20 68 65 61 64 65 72  Header: " header
8570: 20 22 20 61 63 74 69 6f 6e 3a 20 22 20 61 63 74   " action: " act
8580: 69 6f 6e 20 22 20 6e 65 77 2d 73 74 61 74 65 2d  ion " new-state-
8590: 73 74 61 74 75 73 3a 20 22 20 6e 65 77 2d 73 74  status: " new-st
85a0: 61 74 65 2d 73 74 61 74 75 73 29 0a 20 20 20 20  ate-status).    
85b0: 28 66 6f 72 2d 65 61 63 68 0a 20 20 20 20 20 28  (for-each.     (
85c0: 6c 61 6d 62 64 61 20 28 72 75 6e 29 0a 20 20 20  lambda (run).   
85d0: 20 20 20 20 28 6c 65 74 20 28 28 72 75 6e 6b 65      (let ((runke
85e0: 79 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73  y (string-inters
85f0: 70 65 72 73 65 20 28 6d 61 70 20 28 6c 61 6d 62  perse (map (lamb
8600: 64 61 20 28 6b 29 0a 09 09 09 09 09 09 28 64 62  da (k).......(db
8610: 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65  :get-value-by-he
8620: 61 64 65 72 20 72 75 6e 20 68 65 61 64 65 72 20  ader run header 
8630: 28 76 65 63 74 6f 72 2d 72 65 66 20 6b 20 30 29  (vector-ref k 0)
8640: 29 29 20 6b 65 79 73 29 20 22 2f 22 29 29 0a 09  )) keys) "/"))..
8650: 20 20 20 20 20 28 64 69 72 73 2d 74 6f 2d 72 65       (dirs-to-re
8660: 6d 6f 76 65 20 28 6d 61 6b 65 2d 68 61 73 68 2d  move (make-hash-
8670: 74 61 62 6c 65 29 29 29 0a 09 20 28 6c 65 74 2a  table))).. (let*
8680: 20 28 28 72 75 6e 2d 69 64 20 20 20 20 28 64 62   ((run-id    (db
8690: 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65  :get-value-by-he
86a0: 61 64 65 72 20 72 75 6e 20 68 65 61 64 65 72 20  ader run header 
86b0: 22 69 64 22 29 29 0a 09 09 28 72 75 6e 2d 73 74  "id"))...(run-st
86c0: 61 74 65 20 28 64 62 3a 67 65 74 2d 76 61 6c 75  ate (db:get-valu
86d0: 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20  e-by-header run 
86e0: 68 65 61 64 65 72 20 22 73 74 61 74 65 22 29 29  header "state"))
86f0: 0a 09 09 28 74 65 73 74 73 20 20 20 20 20 28 69  ...(tests     (i
8700: 66 20 28 6e 6f 74 20 28 65 71 75 61 6c 3f 20 72  f (not (equal? r
8710: 75 6e 2d 73 74 61 74 65 20 22 6c 6f 63 6b 65 64  un-state "locked
8720: 22 29 29 0a 09 09 09 20 20 20 20 20 20 20 28 6f  "))....       (o
8730: 70 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 64 62  pen-run-close db
8740: 3a 67 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d 72  :get-tests-for-r
8750: 75 6e 20 64 62 20 28 64 62 3a 67 65 74 2d 76 61  un db (db:get-va
8760: 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75  lue-by-header ru
8770: 6e 20 68 65 61 64 65 72 20 22 69 64 22 29 0a 09  n header "id")..
8780: 09 09 09 09 09 20 20 20 20 20 20 74 65 73 74 70  .....      testp
8790: 61 74 74 20 69 74 65 6d 70 61 74 74 20 73 74 61  att itempatt sta
87a0: 74 65 73 20 73 74 61 74 75 73 65 73 0a 09 09 09  tes statuses....
87b0: 09 09 09 20 20 20 20 20 20 6e 6f 74 2d 69 6e 3a  ...      not-in:
87c0: 20 20 23 66 0a 09 09 09 09 09 09 20 20 20 20 20    #f.......     
87d0: 20 73 6f 72 74 2d 62 79 3a 20 28 63 61 73 65 20   sort-by: (case 
87e0: 61 63 74 69 6f 6e 0a 09 09 09 09 09 09 09 09 20  action......... 
87f0: 28 28 72 65 6d 6f 76 65 2d 72 75 6e 73 29 20 27  ((remove-runs) '
8800: 72 75 6e 64 69 72 29 0a 09 09 09 09 09 09 09 09  rundir).........
8810: 20 28 65 6c 73 65 20 20 20 20 20 20 20 20 20 20   (else          
8820: 27 65 76 65 6e 74 5f 74 69 6d 65 29 29 29 0a 09  'event_time)))..
8830: 09 09 20 20 20 20 20 20 20 27 28 29 29 29 0a 09  ..       '()))..
8840: 09 28 6c 61 73 74 74 70 61 74 68 20 22 2f 64 6f  .(lasttpath "/do
8850: 65 73 2f 6e 6f 74 2f 65 78 69 73 74 2f 49 2f 68  es/not/exist/I/h
8860: 6f 70 65 22 29 29 0a 0a 09 20 20 20 28 69 66 20  ope"))...   (if 
8870: 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 65 73 74  (not (null? test
8880: 73 29 29 0a 09 20 20 20 20 20 20 20 28 62 65 67  s))..       (beg
8890: 69 6e 0a 09 09 20 28 63 61 73 65 20 61 63 74 69  in... (case acti
88a0: 6f 6e 0a 09 09 20 20 20 28 28 72 65 6d 6f 76 65  on...   ((remove
88b0: 2d 72 75 6e 73 29 0a 09 09 20 20 20 20 28 64 65  -runs)...    (de
88c0: 62 75 67 3a 70 72 69 6e 74 20 31 20 22 52 65 6d  bug:print 1 "Rem
88d0: 6f 76 69 6e 67 20 74 65 73 74 73 20 66 6f 72 20  oving tests for 
88e0: 72 75 6e 3a 20 22 20 72 75 6e 6b 65 79 20 22 20  run: " runkey " 
88f0: 22 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d  " (db:get-value-
8900: 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65  by-header run he
8910: 61 64 65 72 20 22 72 75 6e 6e 61 6d 65 22 29 29  ader "runname"))
8920: 29 0a 09 09 20 20 20 28 28 73 65 74 2d 73 74 61  )...   ((set-sta
8930: 74 65 2d 73 74 61 74 75 73 29 0a 09 09 20 20 20  te-status)...   
8940: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20   (debug:print 1 
8950: 22 4d 6f 64 69 66 79 69 6e 67 20 73 74 61 74 65  "Modifying state
8960: 20 61 6e 64 20 73 74 61 75 73 20 66 6f 72 20 74   and staus for t
8970: 65 73 74 73 20 66 6f 72 20 72 75 6e 3a 20 22 20  ests for run: " 
8980: 72 75 6e 6b 65 79 20 22 20 22 20 28 64 62 3a 67  runkey " " (db:g
8990: 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64  et-value-by-head
89a0: 65 72 20 72 75 6e 20 68 65 61 64 65 72 20 22 72  er run header "r
89b0: 75 6e 6e 61 6d 65 22 29 29 29 0a 09 09 20 20 20  unname")))...   
89c0: 28 65 6c 73 65 0a 09 09 20 20 20 20 28 70 72 69  (else...    (pri
89d0: 6e 74 20 22 49 4e 46 4f 3a 20 61 63 74 69 6f 6e  nt "INFO: action
89e0: 20 6e 6f 74 20 72 65 63 6f 67 6e 69 73 65 64 20   not recognised 
89f0: 22 20 61 63 74 69 6f 6e 29 29 29 0a 09 09 20 28  " action)))... (
8a00: 66 6f 72 2d 65 61 63 68 0a 09 09 20 20 28 6c 61  for-each...  (la
8a10: 6d 62 64 61 20 28 74 65 73 74 29 0a 09 09 20 20  mbda (test)...  
8a20: 20 20 28 6c 65 74 2a 20 28 28 69 74 65 6d 2d 70    (let* ((item-p
8a30: 61 74 68 20 28 64 62 3a 74 65 73 74 2d 67 65 74  ath (db:test-get
8a40: 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 29  -item-path test)
8a50: 29 0a 09 09 09 20 20 20 28 74 65 73 74 2d 6e 61  )....   (test-na
8a60: 6d 65 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  me (db:test-get-
8a70: 74 65 73 74 6e 61 6d 65 20 74 65 73 74 29 29 0a  testname test)).
8a80: 09 09 09 20 20 20 28 72 75 6e 2d 64 69 72 20 20  ...   (run-dir  
8a90: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 72 75   (db:test-get-ru
8aa0: 6e 64 69 72 20 74 65 73 74 29 29 0a 09 09 09 20  ndir test)).... 
8ab0: 20 20 28 74 65 73 74 2d 69 64 20 20 20 28 64 62    (test-id   (db
8ac0: 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73  :test-get-id tes
8ad0: 74 29 29 29 0a 09 09 20 20 20 20 20 20 3b 3b 20  t)))...      ;; 
8ae0: 20 20 28 74 64 62 20 20 20 20 20 20 20 28 64 62    (tdb       (db
8af0: 3a 6f 70 65 6e 2d 74 65 73 74 2d 64 62 20 72 75  :open-test-db ru
8b00: 6e 2d 64 69 72 29 29 29 0a 09 09 20 20 20 20 20  n-dir)))...     
8b10: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20   (debug:print 1 
8b20: 22 20 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65  "  " (db:test-ge
8b30: 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 29  t-testname test)
8b40: 20 22 20 69 64 3a 20 22 20 28 64 62 3a 74 65 73   " id: " (db:tes
8b50: 74 2d 67 65 74 2d 69 64 20 74 65 73 74 29 20 22  t-get-id test) "
8b60: 20 22 20 69 74 65 6d 2d 70 61 74 68 20 22 20 61   " item-path " a
8b70: 63 74 69 6f 6e 3a 20 22 20 61 63 74 69 6f 6e 29  ction: " action)
8b80: 0a 09 09 20 20 20 20 20 20 28 63 61 73 65 20 61  ...      (case a
8b90: 63 74 69 6f 6e 0a 09 09 09 28 28 72 65 6d 6f 76  ction....((remov
8ba0: 65 2d 72 75 6e 73 29 20 3b 3b 20 74 68 65 20 74  e-runs) ;; the t
8bb0: 64 62 20 69 73 20 66 6f 72 20 66 75 74 75 72 65  db is for future
8bc0: 20 70 6f 73 73 69 62 6c 65 2e 20 0a 09 09 09 20   possible. .... 
8bd0: 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20  (open-run-close 
8be0: 64 62 3a 64 65 6c 65 74 65 2d 74 65 73 74 2d 72  db:delete-test-r
8bf0: 65 63 6f 72 64 73 20 64 62 20 23 66 20 28 64 62  ecords db #f (db
8c00: 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73  :test-get-id tes
8c10: 74 29 29 0a 09 09 09 20 28 64 65 62 75 67 3a 70  t)).... (debug:p
8c20: 72 69 6e 74 20 31 20 22 49 4e 46 4f 3a 20 41 74  rint 1 "INFO: At
8c30: 74 65 6d 70 74 69 6e 67 20 74 6f 20 72 65 6d 6f  tempting to remo
8c40: 76 65 20 64 69 72 20 22 20 72 75 6e 2d 64 69 72  ve dir " run-dir
8c50: 29 0a 09 09 09 20 28 69 66 20 28 61 6e 64 20 28  ).... (if (and (
8c60: 3e 20 28 73 74 72 69 6e 67 2d 6c 65 6e 67 74 68  > (string-length
8c70: 20 72 75 6e 2d 64 69 72 29 20 35 29 0a 09 09 09   run-dir) 5)....
8c80: 09 20 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f  .  (file-exists?
8c90: 20 72 75 6e 2d 64 69 72 29 29 20 3b 3b 20 62 61   run-dir)) ;; ba
8ca0: 64 20 68 65 75 72 69 73 74 69 63 20 62 75 74 20  d heuristic but 
8cb0: 73 68 6f 75 6c 64 20 70 72 65 76 65 6e 74 20 2f  should prevent /
8cc0: 74 6d 70 20 2f 68 6f 6d 65 20 65 74 63 2e 0a 09  tmp /home etc...
8cd0: 09 09 20 20 20 20 20 28 6c 65 74 2a 20 28 28 72  ..     (let* ((r
8ce0: 65 61 6c 70 61 74 68 20 28 72 65 73 6f 6c 76 65  ealpath (resolve
8cf0: 2d 70 61 74 68 6e 61 6d 65 20 72 75 6e 2d 64 69  -pathname run-di
8d00: 72 29 29 29 0a 09 09 09 20 20 20 20 20 20 20 28  r)))....       (
8d10: 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 49  debug:print 1 "I
8d20: 4e 46 4f 3a 20 52 65 61 6c 20 70 61 74 68 20 6f  NFO: Real path o
8d30: 66 20 69 73 20 22 20 72 65 61 6c 70 61 74 68 29  f is " realpath)
8d40: 0a 09 09 09 20 20 20 20 20 20 20 28 69 66 20 28  ....       (if (
8d50: 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 72 65 61  file-exists? rea
8d60: 6c 70 61 74 68 29 0a 09 09 09 09 20 20 20 28 69  lpath).....   (i
8d70: 66 20 28 3e 20 28 73 79 73 74 65 6d 20 28 63 6f  f (> (system (co
8d80: 6e 63 20 22 72 6d 20 2d 72 66 20 22 20 72 65 61  nc "rm -rf " rea
8d90: 6c 70 61 74 68 29 29 20 30 29 0a 09 09 09 09 20  lpath)) 0)..... 
8da0: 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69        (debug:pri
8db0: 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 54 68 65  nt 0 "ERROR: The
8dc0: 72 65 20 77 61 73 20 61 20 70 72 6f 62 6c 65 6d  re was a problem
8dd0: 20 72 65 6d 6f 76 69 6e 67 20 22 20 72 65 61 6c   removing " real
8de0: 70 61 74 68 20 22 20 77 69 74 68 20 72 6d 20 2d  path " with rm -
8df0: 66 22 29 29 0a 09 09 09 09 20 20 20 28 64 65 62  f")).....   (deb
8e00: 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e  ug:print 0 "WARN
8e10: 49 4e 47 3a 20 74 65 73 74 20 72 75 6e 20 64 69  ING: test run di
8e20: 72 20 22 20 72 65 61 6c 70 61 74 68 20 22 20 61  r " realpath " a
8e30: 70 70 65 61 72 73 20 74 6f 20 6e 6f 74 20 65 78  ppears to not ex
8e40: 69 73 74 22 29 29 0a 09 09 09 20 20 20 20 20 20  ist"))....      
8e50: 20 28 69 66 20 28 66 69 6c 65 2d 65 78 69 73 74   (if (file-exist
8e60: 73 3f 20 72 75 6e 2d 64 69 72 29 20 3b 3b 20 74  s? run-dir) ;; t
8e70: 68 65 20 6c 69 6e 6b 0a 09 09 09 09 20 20 20 28  he link.....   (
8e80: 69 66 20 28 73 79 6d 62 6f 6c 69 63 2d 6c 69 6e  if (symbolic-lin
8e90: 6b 3f 20 72 75 6e 2d 64 69 72 29 0a 09 09 09 09  k? run-dir).....
8ea0: 20 20 20 20 20 20 20 28 64 65 6c 65 74 65 2d 66         (delete-f
8eb0: 69 6c 65 20 72 75 6e 2d 64 69 72 29 0a 09 09 09  ile run-dir)....
8ec0: 09 20 20 20 20 20 20 20 28 69 66 20 28 64 69 72  .       (if (dir
8ed0: 65 63 74 6f 72 79 3f 20 72 75 6e 2d 64 69 72 29  ectory? run-dir)
8ee0: 0a 09 09 09 09 09 20 20 20 28 69 66 20 28 3e 20  ......   (if (> 
8ef0: 28 64 69 72 65 63 74 6f 72 79 2d 66 6f 6c 64 20  (directory-fold 
8f00: 28 6c 61 6d 62 64 61 20 28 66 20 78 29 28 2b 20  (lambda (f x)(+ 
8f10: 31 20 78 29 29 20 30 20 72 75 6e 2d 64 69 72 29  1 x)) 0 run-dir)
8f20: 20 30 29 0a 09 09 09 09 09 20 20 20 20 20 20 20   0)......       
8f30: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
8f40: 57 41 52 4e 49 4e 47 3a 20 72 65 66 75 73 69 6e  WARNING: refusin
8f50: 67 20 74 6f 20 72 65 6d 6f 76 65 20 22 20 72 75  g to remove " ru
8f60: 6e 2d 64 69 72 20 22 20 61 73 20 69 74 20 69 73  n-dir " as it is
8f70: 20 6e 6f 74 20 65 6d 70 74 79 22 29 0a 09 09 09   not empty")....
8f80: 09 09 20 20 20 20 20 20 20 28 64 65 6c 65 74 65  ..       (delete
8f90: 2d 64 69 72 65 63 74 6f 72 79 20 72 75 6e 2d 64  -directory run-d
8fa0: 69 72 29 29 20 3b 3b 20 69 74 20 73 68 6f 75 6c  ir)) ;; it shoul
8fb0: 64 20 62 65 20 65 6d 70 74 79 20 62 79 20 68 65  d be empty by he
8fc0: 72 65 20 42 55 47 20 42 55 47 2c 20 61 64 64 20  re BUG BUG, add 
8fd0: 65 72 72 6f 72 20 63 61 74 63 68 0a 09 09 09 09  error catch.....
8fe0: 09 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74  .   (debug:print
8ff0: 20 30 20 22 45 52 52 4f 52 3a 20 72 65 66 75 73   0 "ERROR: refus
9000: 69 6e 67 20 74 6f 20 72 65 6d 6f 76 65 20 22 20  ing to remove " 
9010: 72 75 6e 2d 64 69 72 20 22 20 61 73 20 69 74 20  run-dir " as it 
9020: 69 73 20 6e 65 69 74 68 65 72 20 61 20 73 79 6d  is neither a sym
9030: 6c 69 6e 6b 20 6e 6f 72 20 61 20 64 69 72 65 63  link nor a direc
9040: 74 6f 72 79 22 29 0a 09 09 09 09 09 20 20 20 29  tory")......   )
9050: 29 29 29 0a 09 09 09 20 20 20 20 20 28 64 65 62  )))....     (deb
9060: 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e  ug:print 0 "WARN
9070: 49 4e 47 3a 20 64 69 72 65 63 74 6f 72 79 20 61  ING: directory a
9080: 6c 72 65 61 64 79 20 72 65 6d 6f 76 65 64 20 22  lready removed "
9090: 20 72 75 6e 2d 64 69 72 29 29 29 0a 09 09 09 28   run-dir)))....(
90a0: 28 73 65 74 2d 73 74 61 74 65 2d 73 74 61 74 75  (set-state-statu
90b0: 73 29 0a 09 09 09 20 28 64 65 62 75 67 3a 70 72  s).... (debug:pr
90c0: 69 6e 74 20 32 20 22 49 4e 46 4f 3a 20 6e 65 77  int 2 "INFO: new
90d0: 20 73 74 61 74 65 20 22 20 28 63 61 72 20 73 74   state " (car st
90e0: 61 74 65 2d 73 74 61 74 75 73 29 20 22 2c 20 6e  ate-status) ", n
90f0: 65 77 20 73 74 61 74 75 73 20 22 20 28 63 61 64  ew status " (cad
9100: 72 20 73 74 61 74 65 2d 73 74 61 74 75 73 29 29  r state-status))
9110: 0a 09 09 09 20 28 6f 70 65 6e 2d 72 75 6e 2d 63  .... (open-run-c
9120: 6c 6f 73 65 20 64 62 3a 74 65 73 74 2d 73 65 74  lose db:test-set
9130: 2d 73 74 61 74 65 2d 73 74 61 74 75 73 2d 62 79  -state-status-by
9140: 2d 69 64 20 64 62 20 28 64 62 3a 74 65 73 74 2d  -id db (db:test-
9150: 67 65 74 2d 69 64 20 74 65 73 74 29 20 28 63 61  get-id test) (ca
9160: 72 20 73 74 61 74 65 2d 73 74 61 74 75 73 29 28  r state-status)(
9170: 63 61 64 72 20 73 74 61 74 65 2d 73 74 61 74 75  cadr state-statu
9180: 73 29 20 23 66 29 29 29 29 29 0a 09 09 20 20 74  s) #f)))))...  t
9190: 65 73 74 73 29 29 29 0a 09 20 20 20 0a 09 20 20  ests)))..   ..  
91a0: 20 3b 3b 20 72 65 6d 6f 76 65 20 74 68 65 20 72   ;; remove the r
91b0: 75 6e 20 69 66 20 7a 65 72 6f 20 74 65 73 74 73  un if zero tests
91c0: 20 72 65 6d 61 69 6e 0a 09 20 20 20 28 69 66 20   remain..   (if 
91d0: 28 65 71 3f 20 61 63 74 69 6f 6e 20 27 72 65 6d  (eq? action 'rem
91e0: 6f 76 65 2d 72 75 6e 73 29 0a 09 20 20 20 20 20  ove-runs)..     
91f0: 20 20 28 6c 65 74 20 28 28 72 65 6d 74 65 73 74    (let ((remtest
9200: 73 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f 73  s (open-run-clos
9210: 65 20 64 62 3a 67 65 74 2d 74 65 73 74 73 2d 66  e db:get-tests-f
9220: 6f 72 2d 72 75 6e 20 64 62 20 28 64 62 3a 67 65  or-run db (db:ge
9230: 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65  t-value-by-heade
9240: 72 20 72 75 6e 20 68 65 61 64 65 72 20 22 69 64  r run header "id
9250: 22 29 20 23 66 20 23 66 20 27 28 22 44 45 4c 45  ") #f #f '("DELE
9260: 54 45 44 22 29 20 27 28 22 6e 2f 61 22 29 20 6e  TED") '("n/a") n
9270: 6f 74 2d 69 6e 3a 20 23 74 29 29 29 0a 09 09 20  ot-in: #t)))... 
9280: 28 69 66 20 28 6e 75 6c 6c 3f 20 72 65 6d 74 65  (if (null? remte
9290: 73 74 73 29 20 3b 3b 20 6e 6f 20 6d 6f 72 65 20  sts) ;; no more 
92a0: 74 65 73 74 73 20 72 65 6d 61 69 6e 69 6e 67 0a  tests remaining.
92b0: 09 09 20 20 20 20 20 28 6c 65 74 2a 20 28 28 64  ..     (let* ((d
92c0: 70 61 72 74 73 20 20 28 73 74 72 69 6e 67 2d 73  parts  (string-s
92d0: 70 6c 69 74 20 6c 61 73 74 74 70 61 74 68 20 22  plit lasttpath "
92e0: 2f 22 29 29 0a 09 09 09 20 20 20 20 28 72 75 6e  /"))....    (run
92f0: 70 61 74 68 20 28 63 6f 6e 63 20 22 2f 22 20 28  path (conc "/" (
9300: 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72  string-intersper
9310: 73 65 20 0a 09 09 09 09 09 09 28 74 61 6b 65 20  se .......(take 
9320: 64 70 61 72 74 73 20 28 2d 20 28 6c 65 6e 67 74  dparts (- (lengt
9330: 68 20 64 70 61 72 74 73 29 20 31 29 29 0a 09 09  h dparts) 1))...
9340: 09 09 09 09 22 2f 22 29 29 29 29 0a 09 09 20 20  ...."/"))))...  
9350: 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e       (debug:prin
9360: 74 20 31 20 22 52 65 6d 6f 76 69 6e 67 20 72 75  t 1 "Removing ru
9370: 6e 3a 20 22 20 72 75 6e 6b 65 79 20 22 20 22 20  n: " runkey " " 
9380: 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79  (db:get-value-by
9390: 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64  -header run head
93a0: 65 72 20 22 72 75 6e 6e 61 6d 65 22 29 20 22 20  er "runname") " 
93b0: 61 6e 64 20 72 65 6c 61 74 65 64 20 72 65 63 6f  and related reco
93c0: 72 64 22 29 0a 09 09 20 20 20 20 20 20 20 28 6f  rd")...       (o
93d0: 70 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 64 62  pen-run-close db
93e0: 3a 64 65 6c 65 74 65 2d 72 75 6e 20 64 62 20 72  :delete-run db r
93f0: 75 6e 2d 69 64 29 0a 09 09 20 20 20 20 20 20 20  un-id)...       
9400: 3b 3b 20 54 68 69 73 20 69 73 20 61 20 70 72 65  ;; This is a pre
9410: 74 74 79 20 67 6f 6f 64 20 70 6c 61 63 65 20 74  tty good place t
9420: 6f 20 70 75 72 67 65 20 6f 6c 64 20 44 45 4c 45  o purge old DELE
9430: 54 45 44 20 74 65 73 74 73 0a 09 09 20 20 20 20  TED tests...    
9440: 20 20 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f     (open-run-clo
9450: 73 65 20 64 62 3a 64 65 6c 65 74 65 2d 74 65 73  se db:delete-tes
9460: 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 72 75  ts-for-run db ru
9470: 6e 2d 69 64 29 0a 09 09 20 20 20 20 20 20 20 28  n-id)...       (
9480: 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 64  open-run-close d
9490: 62 3a 64 65 6c 65 74 65 2d 6f 6c 64 2d 64 65 6c  b:delete-old-del
94a0: 65 74 65 64 2d 74 65 73 74 2d 72 65 63 6f 72 64  eted-test-record
94b0: 73 20 64 62 29 0a 09 09 20 20 20 20 20 20 20 28  s db)...       (
94c0: 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 64  open-run-close d
94d0: 62 3a 73 65 74 2d 76 61 72 20 64 62 20 22 44 45  b:set-var db "DE
94e0: 4c 45 54 45 44 5f 54 45 53 54 53 22 20 28 63 75  LETED_TESTS" (cu
94f0: 72 72 65 6e 74 2d 73 65 63 6f 6e 64 73 29 29 0a  rrent-seconds)).
9500: 09 09 20 20 20 20 20 20 20 3b 3b 20 6e 65 65 64  ..       ;; need
9510: 20 74 6f 20 66 69 67 75 72 65 20 6f 75 74 20 74   to figure out t
9520: 68 65 20 70 61 74 68 20 74 6f 20 74 68 65 20 72  he path to the r
9530: 75 6e 20 64 69 72 20 61 6e 64 20 72 65 6d 6f 76  un dir and remov
9540: 65 20 69 74 20 69 66 20 65 6d 70 74 79 0a 09 09  e it if empty...
9550: 20 20 20 20 20 20 20 3b 3b 20 20 20 20 28 69 66         ;;    (if
9560: 20 28 6e 75 6c 6c 3f 20 28 67 6c 6f 62 20 28 63   (null? (glob (c
9570: 6f 6e 63 20 72 75 6e 70 61 74 68 20 22 2f 2a 22  onc runpath "/*"
9580: 29 29 29 0a 09 09 20 20 20 20 20 20 20 3b 3b 20  )))...       ;; 
9590: 20 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09         (begin...
95a0: 20 20 20 20 20 20 20 3b 3b 20 09 20 28 64 65 62         ;; . (deb
95b0: 75 67 3a 70 72 69 6e 74 20 31 20 22 52 65 6d 6f  ug:print 1 "Remo
95c0: 76 69 6e 67 20 72 75 6e 20 64 69 72 20 22 20 72  ving run dir " r
95d0: 75 6e 70 61 74 68 29 0a 09 09 20 20 20 20 20 20  unpath)...      
95e0: 20 3b 3b 20 09 20 28 73 79 73 74 65 6d 20 28 63   ;; . (system (c
95f0: 6f 6e 63 20 22 72 6d 64 69 72 20 2d 70 20 22 20  onc "rmdir -p " 
9600: 72 75 6e 70 61 74 68 29 29 29 29 0a 09 09 20 20  runpath))))...  
9610: 20 20 20 20 20 29 29 29 29 29 0a 09 20 29 29 0a       ))))).. )).
9620: 20 20 20 20 20 72 75 6e 73 29 29 29 0a 0a 3b 3b       runs)))..;;
9630: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9640: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9650: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9660: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9670: 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 52 6f 75 74 69 6e  ======.;; Routin
9680: 65 73 20 66 6f 72 20 6d 61 6e 69 70 75 6c 61 74  es for manipulat
9690: 69 6e 67 20 72 75 6e 73 0a 3b 3b 3d 3d 3d 3d 3d  ing runs.;;=====
96a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
96b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
96c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
96d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
96e0: 3d 0a 0a 3b 3b 20 53 69 6e 63 65 20 6d 61 6e 79  =..;; Since many
96f0: 20 63 61 6c 6c 73 20 74 6f 20 61 20 72 75 6e 20   calls to a run 
9700: 72 65 71 75 69 72 65 20 70 72 65 74 74 79 20 6d  require pretty m
9710: 75 63 68 20 74 68 65 20 73 61 6d 65 20 73 65 74  uch the same set
9720: 75 70 20 0a 3b 3b 20 74 68 69 73 20 77 72 61 70  up .;; this wrap
9730: 70 65 72 20 69 73 20 75 73 65 64 20 74 6f 20 72  per is used to r
9740: 65 64 75 63 65 20 74 68 65 20 72 65 70 6c 69 63  educe the replic
9750: 61 74 69 6f 6e 20 6f 66 20 63 6f 64 65 0a 28 64  ation of code.(d
9760: 65 66 69 6e 65 20 28 67 65 6e 65 72 61 6c 2d 72  efine (general-r
9770: 75 6e 2d 63 61 6c 6c 20 73 77 69 74 63 68 6e 61  un-call switchna
9780: 6d 65 20 61 63 74 69 6f 6e 2d 64 65 73 63 20 70  me action-desc p
9790: 72 6f 63 29 0a 20 20 28 6c 65 74 20 28 28 72 75  roc).  (let ((ru
97a0: 6e 6e 61 6d 65 20 28 61 72 67 73 3a 67 65 74 2d  nname (args:get-
97b0: 61 72 67 20 22 3a 72 75 6e 6e 61 6d 65 22 29 29  arg ":runname"))
97c0: 0a 09 28 74 61 72 67 65 74 20 20 28 69 66 20 28  ..(target  (if (
97d0: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 74  args:get-arg "-t
97e0: 61 72 67 65 74 22 29 0a 09 09 20 20 20 20 20 28  arget")...     (
97f0: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 74  args:get-arg "-t
9800: 61 72 67 65 74 22 29 0a 09 09 20 20 20 20 20 28  arget")...     (
9810: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72  args:get-arg "-r
9820: 65 71 74 61 72 67 22 29 29 29 0a 09 28 74 68 31  eqtarg")))..(th1
9830: 20 20 20 20 20 23 66 29 29 0a 20 20 20 20 28 63       #f)).    (c
9840: 6f 6e 64 0a 20 20 20 20 20 28 28 6e 6f 74 20 74  ond.     ((not t
9850: 61 72 67 65 74 29 0a 20 20 20 20 20 20 28 64 65  arget).      (de
9860: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52  bug:print 0 "ERR
9870: 4f 52 3a 20 4d 69 73 73 69 6e 67 20 72 65 71 75  OR: Missing requ
9880: 69 72 65 64 20 70 61 72 61 6d 65 74 65 72 20 66  ired parameter f
9890: 6f 72 20 22 20 73 77 69 74 63 68 6e 61 6d 65 20  or " switchname 
98a0: 22 2c 20 79 6f 75 20 6d 75 73 74 20 73 70 65 63  ", you must spec
98b0: 69 66 79 20 74 68 65 20 74 61 72 67 65 74 20 77  ify the target w
98c0: 69 74 68 20 2d 74 61 72 67 65 74 22 29 0a 20 20  ith -target").  
98d0: 20 20 20 20 28 65 78 69 74 20 33 29 29 0a 20 20      (exit 3)).  
98e0: 20 20 20 28 28 6e 6f 74 20 72 75 6e 6e 61 6d 65     ((not runname
98f0: 29 0a 20 20 20 20 20 20 28 64 65 62 75 67 3a 70  ).      (debug:p
9900: 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 4d  rint 0 "ERROR: M
9910: 69 73 73 69 6e 67 20 72 65 71 75 69 72 65 64 20  issing required 
9920: 70 61 72 61 6d 65 74 65 72 20 66 6f 72 20 22 20  parameter for " 
9930: 73 77 69 74 63 68 6e 61 6d 65 20 22 2c 20 79 6f  switchname ", yo
9940: 75 20 6d 75 73 74 20 73 70 65 63 69 66 79 20 74  u must specify t
9950: 68 65 20 72 75 6e 20 6e 61 6d 65 20 77 69 74 68  he run name with
9960: 20 3a 72 75 6e 6e 61 6d 65 20 72 75 6e 6e 61 6d   :runname runnam
9970: 65 22 29 0a 20 20 20 20 20 20 28 65 78 69 74 20  e").      (exit 
9980: 33 29 29 0a 20 20 20 20 20 28 65 6c 73 65 0a 20  3)).     (else. 
9990: 20 20 20 20 20 28 6c 65 74 20 28 28 64 62 20 20       (let ((db  
99a0: 20 23 66 29 0a 09 20 20 20 20 28 6b 65 79 73 20   #f)..    (keys 
99b0: 23 66 29 29 0a 09 28 69 66 20 28 6e 6f 74 20 28  #f))..(if (not (
99c0: 73 65 74 75 70 2d 66 6f 72 2d 72 75 6e 29 29 0a  setup-for-run)).
99d0: 09 20 20 20 20 28 62 65 67 69 6e 20 0a 09 20 20  .    (begin ..  
99e0: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
99f0: 20 30 20 22 46 61 69 6c 65 64 20 74 6f 20 73 65   0 "Failed to se
9a00: 74 75 70 2c 20 65 78 69 74 69 6e 67 22 29 0a 09  tup, exiting")..
9a10: 20 20 20 20 20 20 28 65 78 69 74 20 31 29 29 29        (exit 1)))
9a20: 0a 09 28 69 66 20 28 61 72 67 73 3a 67 65 74 2d  ..(if (args:get-
9a30: 61 72 67 20 22 2d 73 65 72 76 65 72 22 29 0a 09  arg "-server")..
9a40: 20 20 20 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c      (open-run-cl
9a50: 6f 73 65 20 73 65 72 76 65 72 3a 73 74 61 72 74  ose server:start
9a60: 20 64 62 20 28 61 72 67 73 3a 67 65 74 2d 61 72   db (args:get-ar
9a70: 67 20 22 2d 73 65 72 76 65 72 22 29 29 0a 20 09  g "-server")). .
9a80: 20 20 20 20 3b 3b 28 69 66 20 28 6e 6f 74 20 28      ;;(if (not (
9a90: 6f 72 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67  or (args:get-arg
9aa0: 20 22 2d 72 75 6e 61 6c 6c 22 29 20 20 20 20 20   "-runall")     
9ab0: 3b 3b 20 72 75 6e 61 6c 6c 20 61 6e 64 20 72 75  ;; runall and ru
9ac0: 6e 74 65 73 74 73 20 61 72 65 20 61 6c 6c 6f 77  ntests are allow
9ad0: 65 64 20 74 6f 20 62 65 20 73 65 72 76 65 72 73  ed to be servers
9ae0: 0a 20 09 20 20 20 20 3b 3b 20 20 20 20 09 20 28  . .    ;;    . (
9af0: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72  args:get-arg "-r
9b00: 75 6e 74 65 73 74 73 22 29 29 29 0a 09 20 20 20  untests")))..   
9b10: 20 28 73 65 72 76 65 72 3a 63 6c 69 65 6e 74 2d   (server:client-
9b20: 73 65 74 75 70 29 29 0a 09 3b 3b 20 29 0a 09 28  setup))..;; )..(
9b30: 73 65 74 21 20 6b 65 79 73 20 28 6f 70 65 6e 2d  set! keys (open-
9b40: 72 75 6e 2d 63 6c 6f 73 65 20 64 62 3a 67 65 74  run-close db:get
9b50: 2d 6b 65 79 73 20 64 62 29 29 0a 09 3b 3b 20 68  -keys db))..;; h
9b60: 61 76 65 20 65 6e 6f 75 67 68 20 74 6f 20 70 72  ave enough to pr
9b70: 6f 63 65 73 73 20 2d 74 61 72 67 65 74 20 6f 72  ocess -target or
9b80: 20 2d 72 65 71 74 61 72 67 20 68 65 72 65 0a 09   -reqtarg here..
9b90: 28 69 66 20 28 61 72 67 73 3a 67 65 74 2d 61 72  (if (args:get-ar
9ba0: 67 20 22 2d 72 65 71 74 61 72 67 22 29 0a 09 20  g "-reqtarg").. 
9bb0: 20 20 20 28 6c 65 74 2a 20 28 28 72 75 6e 63 6f     (let* ((runco
9bc0: 6e 66 69 67 66 20 28 63 6f 6e 63 20 20 2a 74 6f  nfigf (conc  *to
9bd0: 70 70 61 74 68 2a 20 22 2f 72 75 6e 63 6f 6e 66  ppath* "/runconf
9be0: 69 67 73 2e 63 6f 6e 66 69 67 22 29 29 20 3b 3b  igs.config")) ;;
9bf0: 20 44 4f 20 4e 4f 54 20 45 56 41 4c 55 41 54 45   DO NOT EVALUATE
9c00: 20 41 4c 4c 20 0a 09 09 20 20 20 28 72 75 6e 63   ALL ...   (runc
9c10: 6f 6e 66 69 67 20 20 28 72 65 61 64 2d 63 6f 6e  onfig  (read-con
9c20: 66 69 67 20 72 75 6e 63 6f 6e 66 69 67 66 20 23  fig runconfigf #
9c30: 66 20 23 66 20 65 6e 76 69 72 6f 6e 2d 70 61 74  f #f environ-pat
9c40: 74 3a 20 23 66 29 29 29 20 0a 09 20 20 20 20 20  t: #f))) ..     
9c50: 20 28 69 66 20 28 68 61 73 68 2d 74 61 62 6c 65   (if (hash-table
9c60: 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 72 75 6e  -ref/default run
9c70: 63 6f 6e 66 69 67 20 28 61 72 67 73 3a 67 65 74  config (args:get
9c80: 2d 61 72 67 20 22 2d 72 65 71 74 61 72 67 22 29  -arg "-reqtarg")
9c90: 20 23 66 29 0a 09 09 20 20 28 6b 65 79 73 3a 74   #f)...  (keys:t
9ca0: 61 72 67 65 74 2d 73 65 74 2d 61 72 67 73 20 6b  arget-set-args k
9cb0: 65 79 73 20 28 61 72 67 73 3a 67 65 74 2d 61 72  eys (args:get-ar
9cc0: 67 20 22 2d 72 65 71 74 61 72 67 22 29 20 61 72  g "-reqtarg") ar
9cd0: 67 73 3a 61 72 67 2d 68 61 73 68 29 0a 09 09 20  gs:arg-hash)... 
9ce0: 20 28 62 65 67 69 6e 0a 09 09 20 20 20 20 28 64   (begin...    (d
9cf0: 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52  ebug:print 0 "ER
9d00: 52 4f 52 3a 20 5b 22 20 28 61 72 67 73 3a 67 65  ROR: [" (args:ge
9d10: 74 2d 61 72 67 20 22 2d 72 65 71 74 61 72 67 22  t-arg "-reqtarg"
9d20: 29 20 22 5d 20 6e 6f 74 20 66 6f 75 6e 64 20 69  ) "] not found i
9d30: 6e 20 22 20 72 75 6e 63 6f 6e 66 69 67 66 29 0a  n " runconfigf).
9d40: 09 09 20 20 20 20 28 69 66 20 64 62 20 28 73 71  ..    (if db (sq
9d50: 6c 69 74 65 33 3a 66 69 6e 61 6c 69 7a 65 21 20  lite3:finalize! 
9d60: 64 62 29 29 0a 09 09 20 20 20 20 28 65 78 69 74  db))...    (exit
9d70: 20 31 29 29 29 29 0a 09 20 20 20 20 28 69 66 20   1))))..    (if 
9d80: 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d  (args:get-arg "-
9d90: 74 61 72 67 65 74 22 29 0a 09 09 28 6b 65 79 73  target")...(keys
9da0: 3a 74 61 72 67 65 74 2d 73 65 74 2d 61 72 67 73  :target-set-args
9db0: 20 6b 65 79 73 20 28 61 72 67 73 3a 67 65 74 2d   keys (args:get-
9dc0: 61 72 67 20 22 2d 74 61 72 67 65 74 22 20 61 72  arg "-target" ar
9dd0: 67 73 3a 61 72 67 2d 68 61 73 68 29 20 61 72 67  gs:arg-hash) arg
9de0: 73 3a 61 72 67 2d 68 61 73 68 29 29 29 0a 09 28  s:arg-hash)))..(
9df0: 69 66 20 28 6e 6f 74 20 28 63 61 72 20 2a 63 6f  if (not (car *co
9e00: 6e 66 69 67 69 6e 66 6f 2a 29 29 0a 09 20 20 20  nfiginfo*))..   
9e10: 20 28 62 65 67 69 6e 0a 09 20 20 20 20 20 20 28   (begin..      (
9e20: 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45  debug:print 0 "E
9e30: 52 52 4f 52 3a 20 41 74 74 65 6d 70 74 65 64 20  RROR: Attempted 
9e40: 74 6f 20 22 20 61 63 74 69 6f 6e 2d 64 65 73 63  to " action-desc
9e50: 20 22 20 62 75 74 20 72 75 6e 20 61 72 65 61 20   " but run area 
9e60: 63 6f 6e 66 69 67 20 66 69 6c 65 20 6e 6f 74 20  config file not 
9e70: 66 6f 75 6e 64 22 29 0a 09 20 20 20 20 20 20 28  found")..      (
9e80: 65 78 69 74 20 31 29 29 0a 09 20 20 20 20 3b 3b  exit 1))..    ;;
9e90: 20 45 78 74 72 61 63 74 20 6f 75 74 20 73 74 75   Extract out stu
9ea0: 66 66 20 6e 65 65 64 65 64 20 69 6e 20 6d 6f 73  ff needed in mos
9eb0: 74 20 6f 72 20 6d 61 6e 79 20 63 61 6c 6c 73 0a  t or many calls.
9ec0: 09 20 20 20 20 3b 3b 20 68 65 72 65 20 74 68 65  .    ;; here the
9ed0: 6e 20 63 61 6c 6c 20 70 72 6f 63 0a 09 20 20 20  n call proc..   
9ee0: 20 28 6c 65 74 2a 20 28 28 6b 65 79 6e 61 6d 65   (let* ((keyname
9ef0: 73 20 20 20 28 6d 61 70 20 6b 65 79 3a 67 65 74  s   (map key:get
9f00: 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65 79 73 29  -fieldname keys)
9f10: 29 0a 09 09 20 20 20 28 6b 65 79 76 61 6c 6c 73  )...   (keyvalls
9f20: 74 20 20 28 6b 65 79 73 2d 3e 76 61 6c 6c 69 73  t  (keys->vallis
9f30: 74 20 6b 65 79 73 20 23 74 29 29 29 0a 09 20 20  t keys #t)))..  
9f40: 20 20 20 20 28 70 72 6f 63 20 74 61 72 67 65 74      (proc target
9f50: 20 72 75 6e 6e 61 6d 65 20 6b 65 79 73 20 6b 65   runname keys ke
9f60: 79 6e 61 6d 65 73 20 6b 65 79 76 61 6c 6c 73 74  ynames keyvallst
9f70: 29 29 29 0a 09 28 69 66 20 74 68 31 20 28 74 68  )))..(if th1 (th
9f80: 72 65 61 64 2d 6a 6f 69 6e 21 20 74 68 31 29 29  read-join! th1))
9f90: 0a 09 28 69 66 20 64 62 20 28 73 71 6c 69 74 65  ..(if db (sqlite
9fa0: 33 3a 66 69 6e 61 6c 69 7a 65 21 20 64 62 29 29  3:finalize! db))
9fb0: 0a 09 28 73 65 74 21 20 2a 64 69 64 73 6f 6d 65  ..(set! *didsome
9fc0: 74 68 69 6e 67 2a 20 23 74 29 29 29 29 29 29 0a  thing* #t)))))).
9fd0: 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  .;;=============
9fe0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9ff0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
a000: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
a010: 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 4c 6f 63  =========.;; Loc
a020: 6b 2f 75 6e 6c 6f 63 6b 20 72 75 6e 73 0a 3b 3b  k/unlock runs.;;
a030: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
a040: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
a050: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
a060: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
a070: 3d 3d 3d 3d 3d 3d 0a 0a 28 64 65 66 69 6e 65 20  ======..(define 
a080: 28 72 75 6e 73 3a 68 61 6e 64 6c 65 2d 6c 6f 63  (runs:handle-loc
a090: 6b 69 6e 67 20 74 61 72 67 65 74 20 6b 65 79 73  king target keys
a0a0: 20 72 75 6e 6e 61 6d 65 20 6c 6f 63 6b 20 75 6e   runname lock un
a0b0: 6c 6f 63 6b 20 75 73 65 72 29 0a 20 20 28 6c 65  lock user).  (le
a0c0: 74 2a 20 28 28 64 62 20 20 20 20 20 20 20 23 66  t* ((db       #f
a0d0: 29 0a 09 20 28 72 75 6e 64 61 74 20 20 20 28 6f  ).. (rundat   (o
a0e0: 70 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 72 75  pen-run-close ru
a0f0: 6e 73 3a 67 65 74 2d 72 75 6e 73 2d 62 79 2d 70  ns:get-runs-by-p
a100: 61 74 74 20 64 62 20 6b 65 79 73 20 72 75 6e 6e  att db keys runn
a110: 61 6d 65 29 29 0a 09 20 28 68 65 61 64 65 72 20  ame)).. (header 
a120: 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20 72 75    (vector-ref ru
a130: 6e 64 61 74 20 30 29 29 0a 09 20 28 72 75 6e 73  ndat 0)).. (runs
a140: 20 20 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66       (vector-ref
a150: 20 72 75 6e 64 61 74 20 31 29 29 29 0a 20 20 20   rundat 1))).   
a160: 20 28 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62   (for-each (lamb
a170: 64 61 20 28 72 75 6e 29 0a 09 09 28 6c 65 74 20  da (run)...(let 
a180: 28 28 72 75 6e 2d 69 64 20 28 64 62 3a 67 65 74  ((run-id (db:get
a190: 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72  -value-by-header
a1a0: 20 72 75 6e 20 68 65 61 64 65 72 20 22 69 64 22   run header "id"
a1b0: 29 29 29 0a 09 09 20 20 28 69 66 20 28 6f 72 20  )))...  (if (or 
a1c0: 6c 6f 63 6b 0a 09 09 09 20 20 28 61 6e 64 20 75  lock....  (and u
a1d0: 6e 6c 6f 63 6b 0a 09 09 09 20 20 20 20 20 20 20  nlock....       
a1e0: 28 62 65 67 69 6e 0a 09 09 09 09 20 28 70 72 69  (begin..... (pri
a1f0: 6e 74 20 22 44 6f 20 79 6f 75 20 72 65 61 6c 6c  nt "Do you reall
a200: 79 20 77 69 73 68 20 74 6f 20 75 6e 6c 6f 63 6b  y wish to unlock
a210: 20 72 75 6e 20 22 20 72 75 6e 2d 69 64 20 22 3f   run " run-id "?
a220: 5c 6e 20 20 20 79 2f 6e 3a 20 22 29 0a 09 09 09  \n   y/n: ")....
a230: 09 20 28 65 71 75 61 6c 3f 20 22 79 22 20 28 72  . (equal? "y" (r
a240: 65 61 64 2d 6c 69 6e 65 29 29 29 29 29 0a 09 09  ead-line)))))...
a250: 20 20 20 20 20 20 28 6f 70 65 6e 2d 72 75 6e 2d        (open-run-
a260: 63 6c 6f 73 65 20 64 62 3a 6c 6f 63 6b 2f 75 6e  close db:lock/un
a270: 6c 6f 63 6b 2d 72 75 6e 20 64 62 20 72 75 6e 2d  lock-run db run-
a280: 69 64 20 6c 6f 63 6b 20 75 6e 6c 6f 63 6b 20 75  id lock unlock u
a290: 73 65 72 29 0a 09 09 20 20 20 20 20 20 28 64 65  ser)...      (de
a2a0: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 49 4e 46  bug:print 0 "INF
a2b0: 4f 3a 20 53 6b 69 70 70 69 6e 67 20 6c 6f 63 6b  O: Skipping lock
a2c0: 2f 75 6e 6c 6f 63 6b 20 6f 6e 20 22 20 72 75 6e  /unlock on " run
a2d0: 2d 69 64 29 29 29 29 0a 09 20 20 20 20 20 20 72  -id))))..      r
a2e0: 75 6e 73 29 29 29 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d  uns))).;;=======
a2f0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
a300: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
a310: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
a320: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a  ===============.
a330: 3b 3b 20 52 6f 6c 6c 75 70 20 72 75 6e 73 0a 3b  ;; Rollup runs.;
a340: 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ;===============
a350: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
a360: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
a370: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
a380: 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 55 70 64 61  =======..;; Upda
a390: 74 65 20 74 68 65 20 74 65 73 74 5f 6d 65 74 61  te the test_meta
a3a0: 20 74 61 62 6c 65 20 66 6f 72 20 74 68 69 73 20   table for this 
a3b0: 74 65 73 74 0a 28 64 65 66 69 6e 65 20 28 72 75  test.(define (ru
a3c0: 6e 73 3a 75 70 64 61 74 65 2d 74 65 73 74 5f 6d  ns:update-test_m
a3d0: 65 74 61 20 64 62 20 74 65 73 74 2d 6e 61 6d 65  eta db test-name
a3e0: 20 74 65 73 74 2d 63 6f 6e 66 29 0a 20 20 28 6c   test-conf).  (l
a3f0: 65 74 20 28 28 63 75 72 72 72 65 63 6f 72 64 20  et ((currrecord 
a400: 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20  (open-run-close 
a410: 64 62 3a 74 65 73 74 6d 65 74 61 2d 67 65 74 2d  db:testmeta-get-
a420: 72 65 63 6f 72 64 20 64 62 20 74 65 73 74 2d 6e  record db test-n
a430: 61 6d 65 29 29 29 0a 20 20 20 20 28 69 66 20 28  ame))).    (if (
a440: 6e 6f 74 20 63 75 72 72 72 65 63 6f 72 64 29 0a  not currrecord).
a450: 09 28 62 65 67 69 6e 0a 09 20 20 28 73 65 74 21  .(begin..  (set!
a460: 20 63 75 72 72 72 65 63 6f 72 64 20 28 6d 61 6b   currrecord (mak
a470: 65 2d 76 65 63 74 6f 72 20 31 30 20 23 66 29 29  e-vector 10 #f))
a480: 0a 09 20 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c  ..  (open-run-cl
a490: 6f 73 65 20 64 62 3a 74 65 73 74 6d 65 74 61 2d  ose db:testmeta-
a4a0: 61 64 64 2d 72 65 63 6f 72 64 20 64 62 20 74 65  add-record db te
a4b0: 73 74 2d 6e 61 6d 65 29 29 29 0a 20 20 20 20 28  st-name))).    (
a4c0: 66 6f 72 2d 65 61 63 68 20 0a 20 20 20 20 20 28  for-each .     (
a4d0: 6c 61 6d 62 64 61 20 28 6b 65 79 29 0a 20 20 20  lambda (key).   
a4e0: 20 20 20 20 28 6c 65 74 2a 20 28 28 69 64 78 20      (let* ((idx 
a4f0: 28 63 61 64 72 20 6b 65 79 29 29 0a 09 20 20 20  (cadr key))..   
a500: 20 20 20 28 66 6c 64 20 28 63 61 72 20 20 6b 65     (fld (car  ke
a510: 79 29 29 0a 09 20 20 20 20 20 20 28 76 61 6c 20  y))..      (val 
a520: 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 74  (config-lookup t
a530: 65 73 74 2d 63 6f 6e 66 20 22 74 65 73 74 5f 6d  est-conf "test_m
a540: 65 74 61 22 20 66 6c 64 29 29 29 0a 09 20 3b 3b  eta" fld))).. ;;
a550: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 35 20   (debug:print 5 
a560: 22 69 64 78 3a 20 22 20 69 64 78 20 22 20 66 6c  "idx: " idx " fl
a570: 64 3a 20 22 20 66 6c 64 20 22 20 76 61 6c 3a 20  d: " fld " val: 
a580: 22 20 76 61 6c 29 0a 09 20 28 69 66 20 28 61 6e  " val).. (if (an
a590: 64 20 76 61 6c 20 28 6e 6f 74 20 28 65 71 75 61  d val (not (equa
a5a0: 6c 3f 20 28 76 65 63 74 6f 72 2d 72 65 66 20 63  l? (vector-ref c
a5b0: 75 72 72 72 65 63 6f 72 64 20 69 64 78 29 20 76  urrrecord idx) v
a5c0: 61 6c 29 29 29 0a 09 20 20 20 20 20 28 62 65 67  al)))..     (beg
a5d0: 69 6e 0a 09 20 20 20 20 20 20 20 28 70 72 69 6e  in..       (prin
a5e0: 74 20 22 55 70 64 61 74 69 6e 67 20 22 20 74 65  t "Updating " te
a5f0: 73 74 2d 6e 61 6d 65 20 22 20 22 20 66 6c 64 20  st-name " " fld 
a600: 22 20 74 6f 20 22 20 76 61 6c 29 0a 09 20 20 20  " to " val)..   
a610: 20 20 20 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c      (open-run-cl
a620: 6f 73 65 20 64 62 3a 74 65 73 74 6d 65 74 61 2d  ose db:testmeta-
a630: 75 70 64 61 74 65 2d 66 69 65 6c 64 20 64 62 20  update-field db 
a640: 74 65 73 74 2d 6e 61 6d 65 20 66 6c 64 20 76 61  test-name fld va
a650: 6c 29 29 29 29 29 0a 20 20 20 20 20 27 28 28 22  l))))).     '(("
a660: 61 75 74 68 6f 72 22 20 32 29 28 22 6f 77 6e 65  author" 2)("owne
a670: 72 22 20 33 29 28 22 64 65 73 63 72 69 70 74 69  r" 3)("descripti
a680: 6f 6e 22 20 34 29 28 22 72 65 76 69 65 77 65 64  on" 4)("reviewed
a690: 22 20 35 29 28 22 74 61 67 73 22 20 39 29 29 29  " 5)("tags" 9)))
a6a0: 29 29 0a 0a 3b 3b 20 55 70 64 61 74 65 20 74 65  ))..;; Update te
a6b0: 73 74 5f 6d 65 74 61 20 66 6f 72 20 61 6c 6c 20  st_meta for all 
a6c0: 74 65 73 74 73 0a 28 64 65 66 69 6e 65 20 28 72  tests.(define (r
a6d0: 75 6e 73 3a 75 70 64 61 74 65 2d 61 6c 6c 2d 74  uns:update-all-t
a6e0: 65 73 74 5f 6d 65 74 61 20 64 62 29 0a 20 20 28  est_meta db).  (
a6f0: 6c 65 74 20 28 28 74 65 73 74 2d 6e 61 6d 65 73  let ((test-names
a700: 20 28 67 65 74 2d 61 6c 6c 2d 6c 65 67 61 6c 2d   (get-all-legal-
a710: 74 65 73 74 73 29 29 29 0a 20 20 20 20 28 66 6f  tests))).    (fo
a720: 72 2d 65 61 63 68 20 0a 20 20 20 20 20 28 6c 61  r-each .     (la
a730: 6d 62 64 61 20 28 74 65 73 74 2d 6e 61 6d 65 29  mbda (test-name)
a740: 0a 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28 28  .       (let* ((
a750: 74 65 73 74 2d 70 61 74 68 20 20 20 20 28 63 6f  test-path    (co
a760: 6e 63 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f 74  nc *toppath* "/t
a770: 65 73 74 73 2f 22 20 74 65 73 74 2d 6e 61 6d 65  ests/" test-name
a780: 29 29 0a 09 20 20 20 20 20 20 28 74 65 73 74 2d  ))..      (test-
a790: 63 6f 6e 66 69 67 66 20 28 63 6f 6e 63 20 74 65  configf (conc te
a7a0: 73 74 2d 70 61 74 68 20 22 2f 74 65 73 74 63 6f  st-path "/testco
a7b0: 6e 66 69 67 22 29 29 0a 09 20 20 20 20 20 20 28  nfig"))..      (
a7c0: 74 65 73 74 65 78 69 73 74 73 20 20 20 28 61 6e  testexists   (an
a7d0: 64 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20  d (file-exists? 
a7e0: 74 65 73 74 2d 63 6f 6e 66 69 67 66 29 28 66 69  test-configf)(fi
a7f0: 6c 65 2d 72 65 61 64 2d 61 63 63 65 73 73 3f 20  le-read-access? 
a800: 74 65 73 74 2d 63 6f 6e 66 69 67 66 29 29 29 0a  test-configf))).
a810: 09 20 20 20 20 20 20 3b 3b 20 72 65 61 64 20 63  .      ;; read c
a820: 6f 6e 66 69 67 73 20 77 69 74 68 20 74 72 69 63  onfigs with tric
a830: 6b 73 20 74 75 72 6e 65 64 20 6f 66 66 20 28 69  ks turned off (i
a840: 2e 65 2e 20 6e 6f 20 73 79 73 74 65 6d 29 0a 09  .e. no system)..
a850: 20 20 20 20 20 20 28 74 65 73 74 2d 63 6f 6e 66        (test-conf
a860: 20 20 20 20 28 69 66 20 74 65 73 74 65 78 69 73      (if testexis
a870: 74 73 20 28 72 65 61 64 2d 63 6f 6e 66 69 67 20  ts (read-config 
a880: 74 65 73 74 2d 63 6f 6e 66 69 67 66 20 23 66 20  test-configf #f 
a890: 23 66 29 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61  #f)(make-hash-ta
a8a0: 62 6c 65 29 29 29 29 0a 09 20 3b 3b 20 75 73 65  ble)))).. ;; use
a8b0: 20 74 68 65 20 6f 70 65 6e 2d 72 75 6e 2d 63 6c   the open-run-cl
a8c0: 6f 73 65 20 69 6e 73 74 65 61 64 20 6f 66 20 70  ose instead of p
a8d0: 61 73 73 69 6e 67 20 69 6e 20 64 62 0a 09 20 28  assing in db.. (
a8e0: 72 75 6e 73 3a 75 70 64 61 74 65 2d 74 65 73 74  runs:update-test
a8f0: 5f 6d 65 74 61 20 23 66 20 74 65 73 74 2d 6e 61  _meta #f test-na
a900: 6d 65 20 74 65 73 74 2d 63 6f 6e 66 29 29 29 0a  me test-conf))).
a910: 20 20 20 20 20 74 65 73 74 2d 6e 61 6d 65 73 29       test-names)
a920: 29 29 0a 0a 3b 3b 20 54 68 69 73 20 63 6f 75 6c  ))..;; This coul
a930: 64 20 70 72 6f 62 61 62 6c 79 20 62 65 20 72 65  d probably be re
a940: 66 61 63 74 6f 72 65 64 20 69 6e 74 6f 20 6f 6e  factored into on
a950: 65 20 63 6f 6d 70 6c 65 78 20 71 75 65 72 79 20  e complex query 
a960: 2e 2e 2e 0a 28 64 65 66 69 6e 65 20 28 72 75 6e  ....(define (run
a970: 73 3a 72 6f 6c 6c 75 70 2d 72 75 6e 20 6b 65 79  s:rollup-run key
a980: 73 20 6b 65 79 76 61 6c 6c 73 74 20 72 75 6e 6e  s keyvallst runn
a990: 61 6d 65 20 75 73 65 72 29 20 3b 3b 20 77 61 73  ame user) ;; was
a9a0: 20 74 61 72 67 65 74 2c 20 6e 6f 77 20 6b 65 79   target, now key
a9b0: 76 61 6c 6c 73 74 0a 20 20 28 64 65 62 75 67 3a  vallst.  (debug:
a9c0: 70 72 69 6e 74 20 34 20 22 72 75 6e 73 3a 72 6f  print 4 "runs:ro
a9d0: 6c 6c 75 70 2d 72 75 6e 2c 20 6b 65 79 73 3a 20  llup-run, keys: 
a9e0: 22 20 6b 65 79 73 20 22 20 6b 65 79 76 61 6c 6c  " keys " keyvall
a9f0: 73 74 3a 20 22 20 6b 65 79 76 61 6c 6c 73 74 20  st: " keyvallst 
aa00: 22 20 3a 72 75 6e 6e 61 6d 65 20 22 20 72 75 6e  " :runname " run
aa10: 6e 61 6d 65 20 22 20 75 73 65 72 3a 20 22 20 75  name " user: " u
aa20: 73 65 72 29 0a 20 20 28 6c 65 74 2a 20 28 28 64  ser).  (let* ((d
aa30: 62 20 20 20 20 20 20 20 20 20 20 20 20 20 20 23  b              #
aa40: 66 29 20 3b 3b 20 28 6b 65 79 76 61 6c 6c 6c 73  f) ;; (keyvallls
aa50: 74 20 20 20 20 20 20 28 6b 65 79 73 3a 74 61 72  t      (keys:tar
aa60: 67 65 74 2d 3e 6b 65 79 76 61 6c 20 6b 65 79 73  get->keyval keys
aa70: 20 74 61 72 67 65 74 29 29 0a 09 20 28 6e 65 77   target)).. (new
aa80: 2d 72 75 6e 2d 69 64 20 20 20 20 20 20 28 6f 70  -run-id      (op
aa90: 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 72 75 6e  en-run-close run
aaa0: 73 3a 72 65 67 69 73 74 65 72 2d 72 75 6e 20 64  s:register-run d
aab0: 62 20 6b 65 79 73 20 6b 65 79 76 61 6c 6c 73 74  b keys keyvallst
aac0: 20 72 75 6e 6e 61 6d 65 20 22 6e 65 77 22 20 22   runname "new" "
aad0: 6e 2f 61 22 20 75 73 65 72 29 29 0a 09 20 28 70  n/a" user)).. (p
aae0: 72 65 76 2d 74 65 73 74 73 20 20 20 20 20 20 28  rev-tests      (
aaf0: 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 74  open-run-close t
ab00: 65 73 74 3a 67 65 74 2d 6d 61 74 63 68 69 6e 67  est:get-matching
ab10: 2d 70 72 65 76 69 6f 75 73 2d 74 65 73 74 2d 72  -previous-test-r
ab20: 75 6e 2d 72 65 63 6f 72 64 73 20 64 62 20 6e 65  un-records db ne
ab30: 77 2d 72 75 6e 2d 69 64 20 22 25 22 20 22 25 22  w-run-id "%" "%"
ab40: 29 29 0a 09 20 28 63 75 72 72 2d 74 65 73 74 73  )).. (curr-tests
ab50: 20 20 20 20 20 20 28 6f 70 65 6e 2d 72 75 6e 2d        (open-run-
ab60: 63 6c 6f 73 65 20 64 62 3a 67 65 74 2d 74 65 73  close db:get-tes
ab70: 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 6e 65  ts-for-run db ne
ab80: 77 2d 72 75 6e 2d 69 64 20 22 25 22 20 22 25 22  w-run-id "%" "%"
ab90: 20 27 28 29 20 27 28 29 29 29 0a 09 20 28 63 75   '() '())).. (cu
aba0: 72 72 2d 74 65 73 74 73 2d 68 61 73 68 20 28 6d  rr-tests-hash (m
abb0: 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29  ake-hash-table))
abc0: 29 0a 20 20 20 20 28 6f 70 65 6e 2d 72 75 6e 2d  ).    (open-run-
abd0: 63 6c 6f 73 65 20 64 62 3a 75 70 64 61 74 65 2d  close db:update-
abe0: 72 75 6e 2d 65 76 65 6e 74 5f 74 69 6d 65 20 64  run-event_time d
abf0: 62 20 6e 65 77 2d 72 75 6e 2d 69 64 29 0a 20 20  b new-run-id).  
ac00: 20 20 3b 3b 20 69 6e 64 65 78 20 74 68 65 20 61    ;; index the a
ac10: 6c 72 65 61 64 79 20 73 61 76 65 64 20 74 65 73  lready saved tes
ac20: 74 73 20 62 79 20 74 65 73 74 6e 61 6d 65 20 61  ts by testname a
ac30: 6e 64 20 69 74 65 6d 64 61 74 20 69 6e 20 63 75  nd itemdat in cu
ac40: 72 72 2d 74 65 73 74 73 2d 68 61 73 68 0a 20 20  rr-tests-hash.  
ac50: 20 20 28 66 6f 72 2d 65 61 63 68 0a 20 20 20 20    (for-each.    
ac60: 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74 64 61   (lambda (testda
ac70: 74 29 0a 20 20 20 20 20 20 20 28 6c 65 74 2a 20  t).       (let* 
ac80: 28 28 74 65 73 74 6e 61 6d 65 20 20 28 64 62 3a  ((testname  (db:
ac90: 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d  test-get-testnam
aca0: 65 20 74 65 73 74 64 61 74 29 29 0a 09 20 20 20  e testdat))..   
acb0: 20 20 20 28 69 74 65 6d 2d 70 61 74 68 20 28 64     (item-path (d
acc0: 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d  b:test-get-item-
acd0: 70 61 74 68 20 74 65 73 74 64 61 74 29 29 0a 09  path testdat))..
ace0: 20 20 20 20 20 20 28 66 75 6c 6c 2d 6e 61 6d 65        (full-name
acf0: 20 28 63 6f 6e 63 20 74 65 73 74 6e 61 6d 65 20   (conc testname 
ad00: 22 2f 22 20 69 74 65 6d 2d 70 61 74 68 29 29 29  "/" item-path)))
ad10: 0a 09 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73  .. (hash-table-s
ad20: 65 74 21 20 63 75 72 72 2d 74 65 73 74 73 2d 68  et! curr-tests-h
ad30: 61 73 68 20 66 75 6c 6c 2d 6e 61 6d 65 20 74 65  ash full-name te
ad40: 73 74 64 61 74 29 29 29 0a 20 20 20 20 20 63 75  stdat))).     cu
ad50: 72 72 2d 74 65 73 74 73 29 0a 20 20 20 20 3b 3b  rr-tests).    ;;
ad60: 20 4e 4f 50 45 3a 20 4e 6f 6e 2d 6f 70 74 69 6d   NOPE: Non-optim
ad70: 61 6c 20 61 70 70 72 6f 61 63 68 2e 20 54 72 79  al approach. Try
ad80: 20 74 68 69 73 20 69 6e 73 74 65 61 64 2e 0a 20   this instead.. 
ad90: 20 20 20 3b 3b 20 20 20 31 2e 20 74 65 73 74 73     ;;   1. tests
ada0: 20 61 72 65 20 72 65 63 65 69 76 65 64 20 69 6e   are received in
adb0: 20 61 20 6c 69 73 74 2c 20 6d 6f 73 74 20 72 65   a list, most re
adc0: 63 65 6e 74 20 66 69 72 73 74 0a 20 20 20 20 3b  cent first.    ;
add0: 3b 20 20 20 32 2e 20 72 65 70 6c 61 63 65 20 74  ;   2. replace t
ade0: 68 65 20 72 6f 6c 6c 75 70 20 74 65 73 74 20 77  he rollup test w
adf0: 69 74 68 20 74 68 65 20 6e 65 77 20 2a 61 6c 77  ith the new *alw
ae00: 61 79 73 2a 0a 20 20 20 20 28 66 6f 72 2d 65 61  ays*.    (for-ea
ae10: 63 68 20 0a 20 20 20 20 20 28 6c 61 6d 62 64 61  ch .     (lambda
ae20: 20 28 74 65 73 74 64 61 74 29 0a 20 20 20 20 20   (testdat).     
ae30: 20 20 28 6c 65 74 2a 20 28 28 74 65 73 74 6e 61    (let* ((testna
ae40: 6d 65 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74  me  (db:test-get
ae50: 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 64 61  -testname testda
ae60: 74 29 29 0a 09 20 20 20 20 20 20 28 69 74 65 6d  t))..      (item
ae70: 2d 70 61 74 68 20 28 64 62 3a 74 65 73 74 2d 67  -path (db:test-g
ae80: 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73  et-item-path tes
ae90: 74 64 61 74 29 29 0a 09 20 20 20 20 20 20 28 66  tdat))..      (f
aea0: 75 6c 6c 2d 6e 61 6d 65 20 28 63 6f 6e 63 20 74  ull-name (conc t
aeb0: 65 73 74 6e 61 6d 65 20 22 2f 22 20 69 74 65 6d  estname "/" item
aec0: 2d 70 61 74 68 29 29 0a 09 20 20 20 20 20 20 28  -path))..      (
aed0: 70 72 65 76 2d 74 65 73 74 2d 64 61 74 20 28 68  prev-test-dat (h
aee0: 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65  ash-table-ref/de
aef0: 66 61 75 6c 74 20 63 75 72 72 2d 74 65 73 74 73  fault curr-tests
af00: 2d 68 61 73 68 20 66 75 6c 6c 2d 6e 61 6d 65 20  -hash full-name 
af10: 23 66 29 29 0a 09 20 20 20 20 20 20 28 74 65 73  #f))..      (tes
af20: 74 2d 73 74 65 70 73 20 20 20 20 20 20 28 6f 70  t-steps      (op
af30: 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 64 62 3a  en-run-close db:
af40: 67 65 74 2d 73 74 65 70 73 2d 66 6f 72 2d 74 65  get-steps-for-te
af50: 73 74 20 64 62 20 28 64 62 3a 74 65 73 74 2d 67  st db (db:test-g
af60: 65 74 2d 69 64 20 74 65 73 74 64 61 74 29 29 29  et-id testdat)))
af70: 0a 09 20 20 20 20 20 20 28 6e 65 77 2d 74 65 73  ..      (new-tes
af80: 74 2d 72 65 63 6f 72 64 20 23 66 29 29 0a 09 20  t-record #f)).. 
af90: 3b 3b 20 72 65 70 6c 61 63 65 20 74 68 65 73 65  ;; replace these
afa0: 20 77 69 74 68 20 69 6e 73 65 72 74 20 2e 2e 2e   with insert ...
afb0: 20 73 65 6c 65 63 74 0a 09 20 28 61 70 70 6c 79   select.. (apply
afc0: 20 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65   sqlite3:execute
afd0: 20 0a 09 09 64 62 20 0a 09 09 28 63 6f 6e 63 20   ...db ...(conc 
afe0: 22 49 4e 53 45 52 54 20 4f 52 20 52 45 50 4c 41  "INSERT OR REPLA
aff0: 43 45 20 49 4e 54 4f 20 74 65 73 74 73 20 28 72  CE INTO tests (r
b000: 75 6e 5f 69 64 2c 74 65 73 74 6e 61 6d 65 2c 73  un_id,testname,s
b010: 74 61 74 65 2c 73 74 61 74 75 73 2c 65 76 65 6e  tate,status,even
b020: 74 5f 74 69 6d 65 2c 68 6f 73 74 2c 63 70 75 6c  t_time,host,cpul
b030: 6f 61 64 2c 64 69 73 6b 66 72 65 65 2c 75 6e 61  oad,diskfree,una
b040: 6d 65 2c 72 75 6e 64 69 72 2c 69 74 65 6d 5f 70  me,rundir,item_p
b050: 61 74 68 2c 72 75 6e 5f 64 75 72 61 74 69 6f 6e  ath,run_duration
b060: 2c 66 69 6e 61 6c 5f 6c 6f 67 66 2c 63 6f 6d 6d  ,final_logf,comm
b070: 65 6e 74 29 20 22 0a 09 09 20 20 20 20 20 20 22  ent) "...      "
b080: 56 41 4c 55 45 53 20 28 3f 2c 3f 2c 3f 2c 3f 2c  VALUES (?,?,?,?,
b090: 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c  ?,?,?,?,?,?,?,?,
b0a0: 3f 2c 3f 29 3b 22 29 0a 09 09 6e 65 77 2d 72 75  ?,?);")...new-ru
b0b0: 6e 2d 69 64 20 28 63 64 64 72 20 28 76 65 63 74  n-id (cddr (vect
b0c0: 6f 72 2d 3e 6c 69 73 74 20 74 65 73 74 64 61 74  or->list testdat
b0d0: 29 29 29 0a 09 20 28 73 65 74 21 20 6e 65 77 2d  ))).. (set! new-
b0e0: 74 65 73 74 64 61 74 20 28 63 61 72 20 28 6f 70  testdat (car (op
b0f0: 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 64 62 3a  en-run-close db:
b100: 67 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d 72 75  get-tests-for-ru
b110: 6e 20 64 62 20 6e 65 77 2d 72 75 6e 2d 69 64 20  n db new-run-id 
b120: 74 65 73 74 6e 61 6d 65 20 69 74 65 6d 2d 70 61  testname item-pa
b130: 74 68 20 27 28 29 20 27 28 29 29 29 29 0a 09 20  th '() '()))).. 
b140: 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74 21  (hash-table-set!
b150: 20 63 75 72 72 2d 74 65 73 74 73 2d 68 61 73 68   curr-tests-hash
b160: 20 66 75 6c 6c 2d 6e 61 6d 65 20 6e 65 77 2d 74   full-name new-t
b170: 65 73 74 64 61 74 29 20 3b 3b 20 74 68 69 73 20  estdat) ;; this 
b180: 63 6f 75 6c 64 20 62 65 20 63 6f 6e 66 75 73 69  could be confusi
b190: 6e 67 2c 20 77 68 69 63 68 20 72 65 63 6f 72 64  ng, which record
b1a0: 20 73 68 6f 75 6c 64 20 67 6f 20 69 6e 74 6f 20   should go into 
b1b0: 74 68 65 20 6c 6f 6f 6b 75 70 20 74 61 62 6c 65  the lookup table
b1c0: 3f 0a 09 20 3b 3b 20 4e 6f 77 20 64 75 70 6c 69  ?.. ;; Now dupli
b1d0: 63 61 74 65 20 74 68 65 20 74 65 73 74 20 73 74  cate the test st
b1e0: 65 70 73 0a 09 20 28 64 65 62 75 67 3a 70 72 69  eps.. (debug:pri
b1f0: 6e 74 20 34 20 22 43 6f 70 79 69 6e 67 20 72 65  nt 4 "Copying re
b200: 63 6f 72 64 73 20 69 6e 20 74 65 73 74 5f 73 74  cords in test_st
b210: 65 70 73 20 66 72 6f 6d 20 74 65 73 74 5f 69 64  eps from test_id
b220: 3d 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  =" (db:test-get-
b230: 69 64 20 74 65 73 74 64 61 74 29 20 22 20 74 6f  id testdat) " to
b240: 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d   " (db:test-get-
b250: 69 64 20 6e 65 77 2d 74 65 73 74 64 61 74 29 29  id new-testdat))
b260: 0a 09 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f  .. (open-run-clo
b270: 73 65 20 0a 09 20 20 28 6c 61 6d 62 64 61 20 28  se ..  (lambda (
b280: 29 0a 09 20 20 20 20 28 73 71 6c 69 74 65 33 3a  )..    (sqlite3:
b290: 65 78 65 63 75 74 65 20 0a 09 20 20 20 20 20 64  execute ..     d
b2a0: 62 20 0a 09 20 20 20 20 20 28 63 6f 6e 63 20 22  b ..     (conc "
b2b0: 49 4e 53 45 52 54 20 4f 52 20 52 45 50 4c 41 43  INSERT OR REPLAC
b2c0: 45 20 49 4e 54 4f 20 74 65 73 74 5f 73 74 65 70  E INTO test_step
b2d0: 73 20 28 74 65 73 74 5f 69 64 2c 73 74 65 70 6e  s (test_id,stepn
b2e0: 61 6d 65 2c 73 74 61 74 65 2c 73 74 61 74 75 73  ame,state,status
b2f0: 2c 65 76 65 6e 74 5f 74 69 6d 65 2c 63 6f 6d 6d  ,event_time,comm
b300: 65 6e 74 29 20 22 0a 09 09 20 20 20 22 53 45 4c  ent) "...   "SEL
b310: 45 43 54 20 22 20 28 64 62 3a 74 65 73 74 2d 67  ECT " (db:test-g
b320: 65 74 2d 69 64 20 6e 65 77 2d 74 65 73 74 64 61  et-id new-testda
b330: 74 29 20 22 2c 73 74 65 70 6e 61 6d 65 2c 73 74  t) ",stepname,st
b340: 61 74 65 2c 73 74 61 74 75 73 2c 65 76 65 6e 74  ate,status,event
b350: 5f 74 69 6d 65 2c 63 6f 6d 6d 65 6e 74 20 46 52  _time,comment FR
b360: 4f 4d 20 74 65 73 74 5f 73 74 65 70 73 20 57 48  OM test_steps WH
b370: 45 52 45 20 74 65 73 74 5f 69 64 3d 3f 3b 22 29  ERE test_id=?;")
b380: 0a 09 20 20 20 20 20 28 64 62 3a 74 65 73 74 2d  ..     (db:test-
b390: 67 65 74 2d 69 64 20 74 65 73 74 64 61 74 29 29  get-id testdat))
b3a0: 0a 09 20 20 20 20 3b 3b 20 4e 6f 77 20 64 75 70  ..    ;; Now dup
b3b0: 6c 69 63 61 74 65 20 74 68 65 20 74 65 73 74 20  licate the test 
b3c0: 64 61 74 61 0a 09 20 20 20 20 28 64 65 62 75 67  data..    (debug
b3d0: 3a 70 72 69 6e 74 20 34 20 22 43 6f 70 79 69 6e  :print 4 "Copyin
b3e0: 67 20 72 65 63 6f 72 64 73 20 69 6e 20 74 65 73  g records in tes
b3f0: 74 5f 64 61 74 61 20 66 72 6f 6d 20 74 65 73 74  t_data from test
b400: 5f 69 64 3d 22 20 28 64 62 3a 74 65 73 74 2d 67  _id=" (db:test-g
b410: 65 74 2d 69 64 20 74 65 73 74 64 61 74 29 20 22  et-id testdat) "
b420: 20 74 6f 20 22 20 28 64 62 3a 74 65 73 74 2d 67   to " (db:test-g
b430: 65 74 2d 69 64 20 6e 65 77 2d 74 65 73 74 64 61  et-id new-testda
b440: 74 29 29 0a 09 20 20 20 20 28 73 71 6c 69 74 65  t))..    (sqlite
b450: 33 3a 65 78 65 63 75 74 65 20 0a 09 20 20 20 20  3:execute ..    
b460: 20 64 62 20 0a 09 20 20 20 20 20 28 63 6f 6e 63   db ..     (conc
b470: 20 22 49 4e 53 45 52 54 20 4f 52 20 52 45 50 4c   "INSERT OR REPL
b480: 41 43 45 20 49 4e 54 4f 20 74 65 73 74 5f 64 61  ACE INTO test_da
b490: 74 61 20 28 74 65 73 74 5f 69 64 2c 63 61 74 65  ta (test_id,cate
b4a0: 67 6f 72 79 2c 76 61 72 69 61 62 6c 65 2c 76 61  gory,variable,va
b4b0: 6c 75 65 2c 65 78 70 65 63 74 65 64 2c 74 6f 6c  lue,expected,tol
b4c0: 2c 75 6e 69 74 73 2c 63 6f 6d 6d 65 6e 74 29 20  ,units,comment) 
b4d0: 22 0a 09 09 20 20 20 22 53 45 4c 45 43 54 20 22  "...   "SELECT "
b4e0: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64   (db:test-get-id
b4f0: 20 6e 65 77 2d 74 65 73 74 64 61 74 29 20 22 2c   new-testdat) ",
b500: 63 61 74 65 67 6f 72 79 2c 76 61 72 69 61 62 6c  category,variabl
b510: 65 2c 76 61 6c 75 65 2c 65 78 70 65 63 74 65 64  e,value,expected
b520: 2c 74 6f 6c 2c 75 6e 69 74 73 2c 63 6f 6d 6d 65  ,tol,units,comme
b530: 6e 74 20 46 52 4f 4d 20 74 65 73 74 5f 64 61 74  nt FROM test_dat
b540: 61 20 57 48 45 52 45 20 74 65 73 74 5f 69 64 3d  a WHERE test_id=
b550: 3f 3b 22 29 0a 09 20 20 20 20 20 28 64 62 3a 74  ?;")..     (db:t
b560: 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74 64  est-get-id testd
b570: 61 74 29 29 29 29 0a 09 20 29 29 0a 20 20 20 20  at)))).. )).    
b580: 20 70 72 65 76 2d 74 65 73 74 73 29 29 29 0a 09   prev-tests)))..
b590: 20 0a 20 20 20 20 20 0a                           .     .