Megatest

Hex Artifact Content
Login

Artifact 6923ee1d253879108b7b72b041c35a43bfc3779e:


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 32 2c 20 4d 61 74 74 68 65 77  06-2012, 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: 29 20 3b 3b 20 74 65 73 74 2d 6e 61 6d 65 29 0a  ) ;; test-name).
0460: 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 76 61 6c    (let* ((keyval
0470: 6c 73 74 20 28 6b 65 79 73 2d 3e 76 61 6c 6c 69  lst (keys->valli
0480: 73 74 20 6b 65 79 73 29 29 0a 09 20 28 74 6d 70  st keys)).. (tmp
0490: 20 20 20 20 20 20 28 72 75 6e 73 3a 67 65 74 2d        (runs:get-
04a0: 73 74 64 2d 72 75 6e 2d 66 69 65 6c 64 73 20 6b  std-run-fields k
04b0: 65 79 73 20 27 28 22 69 64 22 20 22 72 75 6e 6e  eys '("id" "runn
04c0: 61 6d 65 22 20 22 73 74 61 74 65 22 20 22 73 74  ame" "state" "st
04d0: 61 74 75 73 22 20 22 6f 77 6e 65 72 22 20 22 65  atus" "owner" "e
04e0: 76 65 6e 74 5f 74 69 6d 65 22 29 29 29 0a 09 20  vent_time"))).. 
04f0: 28 6b 65 79 73 74 72 20 20 20 28 63 61 72 20 74  (keystr   (car t
0500: 6d 70 29 29 0a 09 20 28 68 65 61 64 65 72 20 20  mp)).. (header  
0510: 20 28 63 61 64 72 20 74 6d 70 29 29 0a 09 20 28   (cadr tmp)).. (
0520: 72 65 73 20 20 20 20 20 27 28 29 29 0a 09 20 28  res     '()).. (
0530: 6b 65 79 2d 70 61 74 74 20 22 22 29 0a 09 20 28  key-patt "").. (
0540: 72 75 6e 77 69 6c 64 74 79 70 65 20 28 69 66 20  runwildtype (if 
0550: 28 73 75 62 73 74 72 69 6e 67 2d 69 6e 64 65 78  (substring-index
0560: 20 22 25 22 20 72 75 6e 6e 61 6d 65 70 61 74 74   "%" runnamepatt
0570: 29 20 22 6c 69 6b 65 22 20 22 67 6c 6f 62 22 29  ) "like" "glob")
0580: 29 0a 09 20 28 71 72 79 2d 73 74 72 20 20 23 66  ).. (qry-str  #f
0590: 29 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68  )).    (for-each
05a0: 20 28 6c 61 6d 62 64 61 20 28 6b 65 79 76 61 6c   (lambda (keyval
05b0: 29 0a 09 09 28 6c 65 74 2a 20 28 28 6b 65 79 20  )...(let* ((key 
05c0: 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20 6b     (vector-ref k
05d0: 65 79 76 61 6c 20 30 29 29 0a 09 09 20 20 20 20  eyval 0))...    
05e0: 20 20 20 28 66 75 6c 6b 65 79 20 28 63 6f 6e 63     (fulkey (conc
05f0: 20 22 3a 22 20 6b 65 79 29 29 0a 09 09 20 20 20   ":" key))...   
0600: 20 20 20 20 28 70 61 74 74 20 20 20 28 61 72 67      (patt   (arg
0610: 73 3a 67 65 74 2d 61 72 67 20 66 75 6c 6b 65 79  s:get-arg fulkey
0620: 29 29 0a 09 09 20 20 20 20 20 20 20 28 77 69 6c  ))...       (wil
0630: 64 74 79 70 65 20 28 69 66 20 28 73 75 62 73 74  dtype (if (subst
0640: 72 69 6e 67 2d 69 6e 64 65 78 20 22 25 22 20 70  ring-index "%" p
0650: 61 74 74 29 20 22 6c 69 6b 65 22 20 22 67 6c 6f  att) "like" "glo
0660: 62 22 29 29 29 0a 09 09 20 20 28 69 66 20 70 61  b")))...  (if pa
0670: 74 74 0a 09 09 20 20 20 20 20 20 28 73 65 74 21  tt...      (set!
0680: 20 6b 65 79 2d 70 61 74 74 20 28 63 6f 6e 63 20   key-patt (conc 
0690: 6b 65 79 2d 70 61 74 74 20 22 20 41 4e 44 20 22  key-patt " AND "
06a0: 20 6b 65 79 20 22 20 22 20 77 69 6c 64 74 79 70   key " " wildtyp
06b0: 65 20 22 20 27 22 20 70 61 74 74 20 22 27 22 29  e " '" patt "'")
06c0: 29 0a 09 09 20 20 20 20 20 20 28 62 65 67 69 6e  )...      (begin
06d0: 0a 09 09 09 28 64 65 62 75 67 3a 70 72 69 6e 74  ....(debug:print
06e0: 20 30 20 22 45 52 52 4f 52 3a 20 73 65 61 72 63   0 "ERROR: searc
06f0: 68 69 6e 67 20 66 6f 72 20 72 75 6e 73 20 77 69  hing for runs wi
0700: 74 68 20 6e 6f 20 70 61 74 74 65 72 6e 20 73 65  th no pattern se
0710: 74 20 66 6f 72 20 22 20 66 75 6c 6b 65 79 29 0a  t for " fulkey).
0720: 09 09 09 28 65 78 69 74 20 36 29 29 29 29 29 0a  ...(exit 6))))).
0730: 09 20 20 20 20 20 20 6b 65 79 73 29 0a 20 20 20  .      keys).   
0740: 20 28 73 65 74 21 20 71 72 79 2d 73 74 72 20 28   (set! qry-str (
0750: 63 6f 6e 63 20 22 53 45 4c 45 43 54 20 22 20 6b  conc "SELECT " k
0760: 65 79 73 74 72 20 22 20 46 52 4f 4d 20 72 75 6e  eystr " FROM run
0770: 73 20 57 48 45 52 45 20 72 75 6e 6e 61 6d 65 20  s WHERE runname 
0780: 22 20 72 75 6e 77 69 6c 64 74 79 70 65 20 22 20  " runwildtype " 
0790: 3f 20 22 20 6b 65 79 2d 70 61 74 74 20 22 3b 22  ? " key-patt ";"
07a0: 29 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72  )).    (debug:pr
07b0: 69 6e 74 2d 69 6e 66 6f 20 34 20 22 72 75 6e 73  int-info 4 "runs
07c0: 3a 67 65 74 2d 72 75 6e 73 2d 62 79 2d 70 61 74  :get-runs-by-pat
07d0: 74 20 71 72 79 3d 22 20 71 72 79 2d 73 74 72 20  t qry=" qry-str 
07e0: 22 20 22 20 72 75 6e 6e 61 6d 65 70 61 74 74 29  " " runnamepatt)
07f0: 0a 20 20 20 20 28 73 71 6c 69 74 65 33 3a 66 6f  .    (sqlite3:fo
0800: 72 2d 65 61 63 68 2d 72 6f 77 20 0a 20 20 20 20  r-each-row .    
0810: 20 28 6c 61 6d 62 64 61 20 28 61 20 2e 20 72 29   (lambda (a . r)
0820: 0a 20 20 20 20 20 20 20 28 73 65 74 21 20 72 65  .       (set! re
0830: 73 20 28 63 6f 6e 73 20 28 6c 69 73 74 2d 3e 76  s (cons (list->v
0840: 65 63 74 6f 72 20 28 63 6f 6e 73 20 61 20 72 29  ector (cons a r)
0850: 29 20 72 65 73 29 29 29 0a 20 20 20 20 20 64 62  ) res))).     db
0860: 20 0a 20 20 20 20 20 71 72 79 2d 73 74 72 0a 20   .     qry-str. 
0870: 20 20 20 20 72 75 6e 6e 61 6d 65 70 61 74 74 29      runnamepatt)
0880: 0a 20 20 20 20 28 76 65 63 74 6f 72 20 68 65 61  .    (vector hea
0890: 64 65 72 20 72 65 73 29 29 29 0a 0a 28 64 65 66  der res)))..(def
08a0: 69 6e 65 20 28 72 75 6e 73 3a 74 65 73 74 2d 67  ine (runs:test-g
08b0: 65 74 2d 66 75 6c 6c 2d 70 61 74 68 20 74 65 73  et-full-path tes
08c0: 74 29 0a 20 20 28 6c 65 74 2a 20 28 28 74 65 73  t).  (let* ((tes
08d0: 74 6e 61 6d 65 20 28 64 62 3a 74 65 73 74 2d 67  tname (db:test-g
08e0: 65 74 2d 74 65 73 74 6e 61 6d 65 20 20 20 74 65  et-testname   te
08f0: 73 74 29 29 0a 09 20 28 69 74 65 6d 70 61 74 68  st)).. (itempath
0900: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74   (db:test-get-it
0910: 65 6d 2d 70 61 74 68 20 74 65 73 74 29 29 29 0a  em-path test))).
0920: 20 20 20 20 28 63 6f 6e 63 20 74 65 73 74 6e 61      (conc testna
0930: 6d 65 20 28 69 66 20 28 65 71 75 61 6c 3f 20 69  me (if (equal? i
0940: 74 65 6d 70 61 74 68 20 22 22 29 20 22 22 20 28  tempath "") "" (
0950: 63 6f 6e 63 20 22 28 22 20 69 74 65 6d 70 61 74  conc "(" itempat
0960: 68 20 22 29 22 29 29 29 29 29 0a 0a 3b 3b 20 41  h ")")))))..;; A
0970: 77 66 75 6c 2e 20 50 6c 65 61 73 65 20 46 49 58  wful. Please FIX
0980: 4d 45 0a 28 64 65 66 69 6e 65 20 2a 65 6e 76 2d  ME.(define *env-
0990: 76 61 72 73 2d 62 79 2d 72 75 6e 2d 69 64 2a 20  vars-by-run-id* 
09a0: 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65  (make-hash-table
09b0: 29 29 0a 28 64 65 66 69 6e 65 20 2a 63 75 72 72  )).(define *curr
09c0: 65 6e 74 2d 72 75 6e 2d 6e 61 6d 65 2a 20 20 20  ent-run-name*   
09d0: 23 66 29 0a 0a 28 64 65 66 69 6e 65 20 28 64 62  #f)..(define (db
09e0: 3a 67 65 74 2d 72 75 6e 2d 6b 65 79 2d 76 61 6c  :get-run-key-val
09f0: 20 64 62 20 72 75 6e 2d 69 64 20 6b 65 79 29 0a   db run-id key).
0a00: 20 20 28 6c 65 74 20 28 28 72 65 73 20 23 66 29    (let ((res #f)
0a10: 29 0a 20 20 20 20 28 73 71 6c 69 74 65 33 3a 66  ).    (sqlite3:f
0a20: 6f 72 2d 65 61 63 68 2d 72 6f 77 0a 20 20 20 20  or-each-row.    
0a30: 20 28 6c 61 6d 62 64 61 20 28 76 61 6c 29 0a 20   (lambda (val). 
0a40: 20 20 20 20 20 20 28 73 65 74 21 20 72 65 73 20        (set! res 
0a50: 76 61 6c 29 29 0a 20 20 20 20 20 64 62 20 0a 20  val)).     db . 
0a60: 20 20 20 20 28 63 6f 6e 63 20 22 53 45 4c 45 43      (conc "SELEC
0a70: 54 20 22 20 28 6b 65 79 3a 67 65 74 2d 66 69 65  T " (key:get-fie
0a80: 6c 64 6e 61 6d 65 20 6b 65 79 29 20 22 20 46 52  ldname key) " FR
0a90: 4f 4d 20 72 75 6e 73 20 57 48 45 52 45 20 69 64  OM runs WHERE id
0aa0: 3d 3f 3b 22 29 0a 20 20 20 20 20 72 75 6e 2d 69  =?;").     run-i
0ab0: 64 29 0a 20 20 20 20 72 65 73 29 29 0a 0a 28 64  d).    res))..(d
0ac0: 65 66 69 6e 65 20 28 64 62 3a 67 65 74 2d 72 75  efine (db:get-ru
0ad0: 6e 2d 6e 61 6d 65 2d 66 72 6f 6d 2d 69 64 20 64  n-name-from-id d
0ae0: 62 20 72 75 6e 2d 69 64 29 0a 20 20 28 6c 65 74  b run-id).  (let
0af0: 20 28 28 72 65 73 20 23 66 29 29 0a 20 20 20 20   ((res #f)).    
0b00: 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63  (sqlite3:for-eac
0b10: 68 2d 72 6f 77 0a 20 20 20 20 20 28 6c 61 6d 62  h-row.     (lamb
0b20: 64 61 20 28 72 75 6e 6e 61 6d 65 29 0a 20 20 20  da (runname).   
0b30: 20 20 20 20 28 73 65 74 21 20 72 65 73 20 72 75      (set! res ru
0b40: 6e 6e 61 6d 65 29 29 0a 20 20 20 20 20 64 62 0a  nname)).     db.
0b50: 20 20 20 20 20 22 53 45 4c 45 43 54 20 72 75 6e       "SELECT run
0b60: 6e 61 6d 65 20 46 52 4f 4d 20 72 75 6e 73 20 57  name FROM runs W
0b70: 48 45 52 45 20 69 64 3d 3f 3b 22 0a 20 20 20 20  HERE id=?;".    
0b80: 20 72 75 6e 2d 69 64 29 0a 20 20 20 20 72 65 73   run-id).    res
0b90: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 73 65 74  ))..(define (set
0ba0: 2d 6d 65 67 61 74 65 73 74 2d 65 6e 76 2d 76 61  -megatest-env-va
0bb0: 72 73 20 72 75 6e 2d 69 64 29 0a 20 20 28 6c 65  rs run-id).  (le
0bc0: 74 20 28 28 6b 65 79 73 20 28 63 64 62 3a 72 65  t ((keys (cdb:re
0bd0: 6d 6f 74 65 2d 72 75 6e 20 64 62 3a 67 65 74 2d  mote-run db:get-
0be0: 6b 65 79 73 20 23 66 29 29 0a 09 28 76 61 6c 73  keys #f))..(vals
0bf0: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
0c00: 2f 64 65 66 61 75 6c 74 20 2a 65 6e 76 2d 76 61  /default *env-va
0c10: 72 73 2d 62 79 2d 72 75 6e 2d 69 64 2a 20 72 75  rs-by-run-id* ru
0c20: 6e 2d 69 64 20 23 66 29 29 29 0a 20 20 20 20 3b  n-id #f))).    ;
0c30: 3b 20 67 65 74 20 74 68 65 20 69 6e 66 6f 20 66  ; get the info f
0c40: 72 6f 6d 20 74 68 65 20 64 62 20 61 6e 64 20 70  rom the db and p
0c50: 75 74 20 69 74 20 69 6e 20 74 68 65 20 63 61 63  ut it in the cac
0c60: 68 65 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20  he.    (if (not 
0c70: 76 61 6c 73 29 0a 09 28 6c 65 74 20 28 28 68 74  vals)..(let ((ht
0c80: 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c   (make-hash-tabl
0c90: 65 29 29 29 0a 09 20 20 28 68 61 73 68 2d 74 61  e)))..  (hash-ta
0ca0: 62 6c 65 2d 73 65 74 21 20 2a 65 6e 76 2d 76 61  ble-set! *env-va
0cb0: 72 73 2d 62 79 2d 72 75 6e 2d 69 64 2a 20 72 75  rs-by-run-id* ru
0cc0: 6e 2d 69 64 20 68 74 29 0a 09 20 20 28 73 65 74  n-id ht)..  (set
0cd0: 21 20 76 61 6c 73 20 68 74 29 0a 09 20 20 28 66  ! vals ht)..  (f
0ce0: 6f 72 2d 65 61 63 68 0a 09 20 20 20 28 6c 61 6d  or-each..   (lam
0cf0: 62 64 61 20 28 6b 65 79 29 0a 09 20 20 20 20 20  bda (key)..     
0d00: 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74 21  (hash-table-set!
0d10: 20 76 61 6c 73 20 6b 65 79 20 28 63 64 62 3a 72   vals key (cdb:r
0d20: 65 6d 6f 74 65 2d 72 75 6e 20 64 62 3a 67 65 74  emote-run db:get
0d30: 2d 72 75 6e 2d 6b 65 79 2d 76 61 6c 20 23 66 20  -run-key-val #f 
0d40: 72 75 6e 2d 69 64 20 6b 65 79 29 29 29 0a 09 20  run-id key))).. 
0d50: 20 20 6b 65 79 73 29 29 29 0a 20 20 20 20 3b 3b    keys))).    ;;
0d60: 20 66 72 6f 6d 20 74 68 65 20 63 61 63 68 65 64   from the cached
0d70: 20 64 61 74 61 20 73 65 74 20 74 68 65 20 76 61   data set the va
0d80: 72 73 0a 20 20 20 20 28 68 61 73 68 2d 74 61 62  rs.    (hash-tab
0d90: 6c 65 2d 66 6f 72 2d 65 61 63 68 0a 20 20 20 20  le-for-each.    
0da0: 20 76 61 6c 73 0a 20 20 20 20 20 28 6c 61 6d 62   vals.     (lamb
0db0: 64 61 20 28 6b 65 79 20 76 61 6c 29 0a 20 20 20  da (key val).   
0dc0: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
0dd0: 20 32 20 22 73 65 74 65 6e 76 20 22 20 28 6b 65   2 "setenv " (ke
0de0: 79 3a 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20  y:get-fieldname 
0df0: 6b 65 79 29 20 22 20 22 20 76 61 6c 29 0a 20 20  key) " " val).  
0e00: 20 20 20 20 20 28 73 65 74 65 6e 76 20 28 6b 65       (setenv (ke
0e10: 79 3a 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20  y:get-fieldname 
0e20: 6b 65 79 29 20 76 61 6c 29 29 29 0a 20 20 20 20  key) val))).    
0e30: 28 61 6c 69 73 74 2d 3e 65 6e 76 2d 76 61 72 73  (alist->env-vars
0e40: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
0e50: 2f 64 65 66 61 75 6c 74 20 2a 63 6f 6e 66 69 67  /default *config
0e60: 64 61 74 2a 20 22 65 6e 76 2d 6f 76 65 72 72 69  dat* "env-overri
0e70: 64 65 22 20 27 28 29 29 29 0a 20 20 20 20 3b 3b  de" '())).    ;;
0e80: 20 4c 65 74 73 20 75 73 65 20 74 68 69 73 20 61   Lets use this a
0e90: 73 20 61 6e 20 6f 70 70 6f 72 74 75 6e 69 74 79  s an opportunity
0ea0: 20 74 6f 20 70 75 74 20 4d 54 5f 52 55 4e 4e 41   to put MT_RUNNA
0eb0: 4d 45 20 69 6e 20 74 68 65 20 65 6e 76 69 72 6f  ME in the enviro
0ec0: 6e 6d 65 6e 74 0a 20 20 20 20 28 73 65 74 65 6e  nment.    (seten
0ed0: 76 20 22 4d 54 5f 52 55 4e 4e 41 4d 45 22 20 28  v "MT_RUNNAME" (
0ee0: 63 64 62 3a 72 65 6d 6f 74 65 2d 72 75 6e 20 64  cdb:remote-run d
0ef0: 62 3a 67 65 74 2d 72 75 6e 2d 6e 61 6d 65 2d 66  b:get-run-name-f
0f00: 72 6f 6d 2d 69 64 20 23 66 20 72 75 6e 2d 69 64  rom-id #f run-id
0f10: 29 29 0a 20 20 20 20 28 73 65 74 65 6e 76 20 22  )).    (setenv "
0f20: 4d 54 5f 52 55 4e 5f 41 52 45 41 5f 48 4f 4d 45  MT_RUN_AREA_HOME
0f30: 22 20 2a 74 6f 70 70 61 74 68 2a 29 0a 20 20 20  " *toppath*).   
0f40: 20 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 73 65   ))..(define (se
0f50: 74 2d 69 74 65 6d 2d 65 6e 76 2d 76 61 72 73 20  t-item-env-vars 
0f60: 69 74 65 6d 64 61 74 29 0a 20 20 28 66 6f 72 2d  itemdat).  (for-
0f70: 65 61 63 68 20 28 6c 61 6d 62 64 61 20 28 69 74  each (lambda (it
0f80: 65 6d 29 0a 09 20 20 20 20 20 20 28 64 65 62 75  em)..      (debu
0f90: 67 3a 70 72 69 6e 74 20 32 20 22 73 65 74 65 6e  g:print 2 "seten
0fa0: 76 20 22 20 28 63 61 72 20 69 74 65 6d 29 20 22  v " (car item) "
0fb0: 20 22 20 28 63 61 64 72 20 69 74 65 6d 29 29 0a   " (cadr item)).
0fc0: 09 20 20 20 20 20 20 28 73 65 74 65 6e 76 20 28  .      (setenv (
0fd0: 63 61 72 20 69 74 65 6d 29 20 28 63 61 64 72 20  car item) (cadr 
0fe0: 69 74 65 6d 29 29 29 0a 09 20 20 20 20 69 74 65  item)))..    ite
0ff0: 6d 64 61 74 29 29 0a 0a 28 64 65 66 69 6e 65 20  mdat))..(define 
1000: 2a 6c 61 73 74 2d 6e 75 6d 2d 72 75 6e 6e 69 6e  *last-num-runnin
1010: 67 2d 74 65 73 74 73 2a 20 30 29 0a 28 64 65 66  g-tests* 0).(def
1020: 69 6e 65 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75  ine (runs:can-ru
1030: 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20 74 65 73  n-more-tests tes
1040: 74 2d 72 65 63 6f 72 64 29 0a 20 20 28 6c 65 74  t-record).  (let
1050: 2a 20 28 28 74 63 6f 6e 66 69 67 20 20 20 20 20  * ((tconfig     
1060: 20 20 20 20 20 20 20 20 20 20 20 20 28 74 65 73              (tes
1070: 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74  ts:testqueue-get
1080: 2d 74 65 73 74 63 6f 6e 66 69 67 20 74 65 73 74  -testconfig test
1090: 2d 72 65 63 6f 72 64 29 29 0a 09 20 28 6a 6f 62  -record)).. (job
10a0: 67 72 6f 75 70 20 20 20 20 20 20 20 20 20 20 20  group           
10b0: 20 20 20 20 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f       (config-loo
10c0: 6b 75 70 20 74 63 6f 6e 66 69 67 20 22 72 65 71  kup tconfig "req
10d0: 75 69 72 65 6d 65 6e 74 73 22 20 22 6a 6f 62 67  uirements" "jobg
10e0: 72 6f 75 70 22 29 29 0a 09 20 28 6e 75 6d 2d 72  roup")).. (num-r
10f0: 75 6e 6e 69 6e 67 20 20 20 20 20 20 20 20 20 20  unning          
1100: 20 20 20 28 63 64 62 3a 72 65 6d 6f 74 65 2d 72     (cdb:remote-r
1110: 75 6e 20 64 62 3a 67 65 74 2d 63 6f 75 6e 74 2d  un db:get-count-
1120: 74 65 73 74 73 2d 72 75 6e 6e 69 6e 67 20 23 66  tests-running #f
1130: 29 29 0a 09 20 28 6e 75 6d 2d 72 75 6e 6e 69 6e  )).. (num-runnin
1140: 67 2d 69 6e 2d 6a 6f 62 67 72 6f 75 70 20 28 63  g-in-jobgroup (c
1150: 64 62 3a 72 65 6d 6f 74 65 2d 72 75 6e 20 64 62  db:remote-run db
1160: 3a 67 65 74 2d 63 6f 75 6e 74 2d 74 65 73 74 73  :get-count-tests
1170: 2d 72 75 6e 6e 69 6e 67 2d 69 6e 2d 6a 6f 62 67  -running-in-jobg
1180: 72 6f 75 70 20 23 66 20 6a 6f 62 67 72 6f 75 70  roup #f jobgroup
1190: 29 29 0a 09 20 28 6d 61 78 2d 63 6f 6e 63 75 72  )).. (max-concur
11a0: 72 65 6e 74 2d 6a 6f 62 73 20 20 20 20 20 28 6c  rent-jobs     (l
11b0: 65 74 20 28 28 6d 63 6a 20 28 63 6f 6e 66 69 67  et ((mcj (config
11c0: 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67 64  -lookup *configd
11d0: 61 74 2a 20 22 73 65 74 75 70 22 20 20 20 20 20  at* "setup"     
11e0: 22 6d 61 78 5f 63 6f 6e 63 75 72 72 65 6e 74 5f  "max_concurrent_
11f0: 6a 6f 62 73 22 29 29 29 0a 09 09 09 09 20 20 20  jobs"))).....   
1200: 20 28 69 66 20 28 61 6e 64 20 6d 63 6a 20 28 73   (if (and mcj (s
1210: 74 72 69 6e 67 2d 3e 6e 75 6d 62 65 72 20 6d 63  tring->number mc
1220: 6a 29 29 0a 09 09 09 09 09 28 73 74 72 69 6e 67  j))......(string
1230: 2d 3e 6e 75 6d 62 65 72 20 6d 63 6a 29 0a 09 09  ->number mcj)...
1240: 09 09 09 31 29 29 29 0a 09 20 28 6a 6f 62 2d 67  ...1))).. (job-g
1250: 72 6f 75 70 2d 6c 69 6d 69 74 20 20 20 20 20 20  roup-limit      
1260: 20 20 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75     (config-looku
1270: 70 20 2a 63 6f 6e 66 69 67 64 61 74 2a 20 22 6a  p *configdat* "j
1280: 6f 62 67 72 6f 75 70 73 22 20 6a 6f 62 67 72 6f  obgroups" jobgro
1290: 75 70 29 29 29 0a 20 20 20 20 28 69 66 20 28 6e  up))).    (if (n
12a0: 6f 74 20 28 65 71 3f 20 2a 6c 61 73 74 2d 6e 75  ot (eq? *last-nu
12b0: 6d 2d 72 75 6e 6e 69 6e 67 2d 74 65 73 74 73 2a  m-running-tests*
12c0: 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67 29 29 0a 09   num-running))..
12d0: 28 62 65 67 69 6e 0a 09 20 20 28 64 65 62 75 67  (begin..  (debug
12e0: 3a 70 72 69 6e 74 20 32 20 22 6d 61 78 2d 63 6f  :print 2 "max-co
12f0: 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 3a 20 22  ncurrent-jobs: "
1300: 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d   max-concurrent-
1310: 6a 6f 62 73 20 22 2c 20 6e 75 6d 2d 72 75 6e 6e  jobs ", num-runn
1320: 69 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69  ing: " num-runni
1330: 6e 67 29 0a 09 20 20 28 73 65 74 21 20 2a 6c 61  ng)..  (set! *la
1340: 73 74 2d 6e 75 6d 2d 72 75 6e 6e 69 6e 67 2d 74  st-num-running-t
1350: 65 73 74 73 2a 20 6e 75 6d 2d 72 75 6e 6e 69 6e  ests* num-runnin
1360: 67 29 29 29 0a 20 20 20 20 28 69 66 20 28 6e 6f  g))).    (if (no
1370: 74 20 28 65 71 3f 20 30 20 2a 67 6c 6f 62 61 6c  t (eq? 0 *global
1380: 65 78 69 74 73 74 61 74 75 73 2a 29 29 0a 09 28  exitstatus*))..(
1390: 6c 69 73 74 20 23 66 20 6e 75 6d 2d 72 75 6e 6e  list #f num-runn
13a0: 69 6e 67 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67 2d  ing num-running-
13b0: 69 6e 2d 6a 6f 62 67 72 6f 75 70 20 6d 61 78 2d  in-jobgroup max-
13c0: 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 20  concurrent-jobs 
13d0: 6a 6f 62 2d 67 72 6f 75 70 2d 6c 69 6d 69 74 29  job-group-limit)
13e0: 0a 09 28 6c 65 74 20 28 28 63 61 6e 2d 6e 6f 74  ..(let ((can-not
13f0: 2d 72 75 6e 2d 6d 6f 72 65 20 28 63 6f 6e 64 0a  -run-more (cond.
1400: 09 09 09 09 20 3b 3b 20 69 66 20 6d 61 78 2d 63  .... ;; if max-c
1410: 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 20 69  oncurrent-jobs i
1420: 73 20 73 65 74 20 61 6e 64 20 74 68 65 20 6e 75  s set and the nu
1430: 6d 62 65 72 20 72 75 6e 6e 69 6e 67 20 69 73 20  mber running is 
1440: 67 72 65 61 74 65 72 20 0a 09 09 09 09 20 3b 3b  greater ..... ;;
1450: 20 74 68 61 6e 20 69 74 20 74 68 61 6e 20 63 61   than it than ca
1460: 6e 6e 6f 74 20 72 75 6e 20 6d 6f 72 65 20 6a 6f  nnot run more jo
1470: 62 73 0a 09 09 09 09 20 28 28 61 6e 64 20 6d 61  bs..... ((and ma
1480: 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62  x-concurrent-job
1490: 73 20 28 3e 3d 20 6e 75 6d 2d 72 75 6e 6e 69 6e  s (>= num-runnin
14a0: 67 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74  g max-concurrent
14b0: 2d 6a 6f 62 73 29 29 0a 09 09 09 09 20 20 28 64  -jobs)).....  (d
14c0: 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41  ebug:print 0 "WA
14d0: 52 4e 49 4e 47 3a 20 4d 61 78 20 72 75 6e 6e 69  RNING: Max runni
14e0: 6e 67 20 6a 6f 62 73 20 65 78 63 65 65 64 65 64  ng jobs exceeded
14f0: 2c 20 63 75 72 72 65 6e 74 20 6e 75 6d 62 65 72  , current number
1500: 20 72 75 6e 6e 69 6e 67 3a 20 22 20 6e 75 6d 2d   running: " num-
1510: 72 75 6e 6e 69 6e 67 20 0a 09 09 09 09 09 20 20  running ......  
1520: 20 20 20 20 20 22 2c 20 6d 61 78 5f 63 6f 6e 63       ", max_conc
1530: 75 72 72 65 6e 74 5f 6a 6f 62 73 3a 20 22 20 6d  urrent_jobs: " m
1540: 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f  ax-concurrent-jo
1550: 62 73 29 0a 09 09 09 09 20 20 23 74 29 0a 09 09  bs).....  #t)...
1560: 09 09 20 3b 3b 20 69 66 20 6a 6f 62 2d 67 72 6f  .. ;; if job-gro
1570: 75 70 2d 6c 69 6d 69 74 20 69 73 20 73 65 74 20  up-limit is set 
1580: 61 6e 64 20 6e 75 6d 62 65 72 20 6f 66 20 6a 6f  and number of jo
1590: 62 73 20 69 6e 20 74 68 65 20 67 72 6f 75 70 20  bs in the group 
15a0: 69 73 20 67 72 65 61 74 65 72 0a 09 09 09 09 20  is greater..... 
15b0: 3b 3b 20 74 68 61 6e 20 74 68 65 20 6c 69 6d 69  ;; than the limi
15c0: 74 20 74 68 65 6e 20 63 61 6e 6e 6f 74 20 72 75  t then cannot ru
15d0: 6e 20 6d 6f 72 65 20 6a 6f 62 73 20 6f 66 20 74  n more jobs of t
15e0: 68 69 73 20 6b 69 6e 64 0a 09 09 09 09 20 28 28  his kind..... ((
15f0: 61 6e 64 20 6a 6f 62 2d 67 72 6f 75 70 2d 6c 69  and job-group-li
1600: 6d 69 74 0a 09 09 09 09 20 20 20 20 20 20 20 28  mit.....       (
1610: 3e 3d 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67 2d 69  >= num-running-i
1620: 6e 2d 6a 6f 62 67 72 6f 75 70 20 6a 6f 62 2d 67  n-jobgroup job-g
1630: 72 6f 75 70 2d 6c 69 6d 69 74 29 29 0a 09 09 09  roup-limit))....
1640: 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20  .  (debug:print 
1650: 31 20 22 57 41 52 4e 49 4e 47 3a 20 6e 75 6d 62  1 "WARNING: numb
1660: 65 72 20 6f 66 20 6a 6f 62 73 20 22 20 6e 75 6d  er of jobs " num
1670: 2d 72 75 6e 6e 69 6e 67 2d 69 6e 2d 6a 6f 62 67  -running-in-jobg
1680: 72 6f 75 70 20 0a 09 09 09 09 09 20 20 20 20 20  roup ......     
1690: 20 20 22 20 69 6e 20 22 20 6a 6f 62 67 72 6f 75    " in " jobgrou
16a0: 70 20 22 20 65 78 63 65 65 64 65 64 2c 20 77 69  p " exceeded, wi
16b0: 6c 6c 20 6e 6f 74 20 72 75 6e 20 22 20 28 74 65  ll not run " (te
16c0: 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65  sts:testqueue-ge
16d0: 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 2d  t-testname test-
16e0: 72 65 63 6f 72 64 29 29 0a 09 09 09 09 20 20 23  record)).....  #
16f0: 74 29 0a 09 09 09 09 20 28 65 6c 73 65 20 23 66  t)..... (else #f
1700: 29 29 29 29 0a 09 20 20 28 6c 69 73 74 20 28 6e  ))))..  (list (n
1710: 6f 74 20 63 61 6e 2d 6e 6f 74 2d 72 75 6e 2d 6d  ot can-not-run-m
1720: 6f 72 65 29 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67  ore) num-running
1730: 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67 2d 69 6e 2d   num-running-in-
1740: 6a 6f 62 67 72 6f 75 70 20 6d 61 78 2d 63 6f 6e  jobgroup max-con
1750: 63 75 72 72 65 6e 74 2d 6a 6f 62 73 20 6a 6f 62  current-jobs job
1760: 2d 67 72 6f 75 70 2d 6c 69 6d 69 74 29 29 29 29  -group-limit))))
1770: 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  )..;;===========
1780: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1790: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
17a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
17b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 4e  ===========.;; N
17c0: 65 77 20 6d 65 74 68 6f 64 6f 6c 6f 67 79 2e 20  ew methodology. 
17d0: 54 68 65 73 65 20 72 6f 75 74 69 6e 65 73 20 77  These routines w
17e0: 69 6c 6c 20 72 65 70 6c 61 63 65 20 74 68 65 20  ill replace the 
17f0: 61 62 6f 76 65 20 69 6e 20 74 69 6d 65 2e 20 46  above in time. F
1800: 6f 72 0a 3b 3b 20 6e 6f 77 20 74 68 65 20 63 6f  or.;; now the co
1810: 64 65 20 69 73 20 64 75 70 6c 69 63 61 74 65 64  de is duplicated
1820: 2e 20 54 68 69 73 20 73 74 75 66 66 20 69 73 20  . This stuff is 
1830: 69 6e 69 74 69 61 6c 6c 79 20 75 73 65 64 20 69  initially used i
1840: 6e 20 74 68 65 20 6d 6f 6e 69 74 6f 72 0a 3b 3b  n the monitor.;;
1850: 20 62 61 73 65 64 20 63 6f 64 65 2e 0a 3b 3b 3d   based code..;;=
1860: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1870: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1880: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1890: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
18a0: 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 72 65 67 69 73 74  =====..;; regist
18b0: 65 72 20 61 20 74 65 73 74 20 72 75 6e 20 77 69  er a test run wi
18c0: 74 68 20 74 68 65 20 64 62 0a 28 64 65 66 69 6e  th the db.(defin
18d0: 65 20 28 72 75 6e 73 3a 72 65 67 69 73 74 65 72  e (runs:register
18e0: 2d 72 75 6e 20 64 62 20 6b 65 79 73 20 6b 65 79  -run db keys key
18f0: 76 61 6c 6c 73 74 20 72 75 6e 6e 61 6d 65 20 73  vallst runname s
1900: 74 61 74 65 20 73 74 61 74 75 73 20 75 73 65 72  tate status user
1910: 29 0a 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ).  (debug:print
1920: 20 33 20 22 72 75 6e 73 3a 72 65 67 69 73 74 65   3 "runs:registe
1930: 72 2d 72 75 6e 2c 20 6b 65 79 73 3a 20 22 20 6b  r-run, keys: " k
1940: 65 79 73 20 22 20 6b 65 79 76 61 6c 6c 73 74 3a  eys " keyvallst:
1950: 20 22 20 6b 65 79 76 61 6c 6c 73 74 20 22 20 72   " keyvallst " r
1960: 75 6e 6e 61 6d 65 3a 20 22 20 72 75 6e 6e 61 6d  unname: " runnam
1970: 65 20 22 20 73 74 61 74 65 3a 20 22 20 73 74 61  e " state: " sta
1980: 74 65 20 22 20 73 74 61 74 75 73 3a 20 22 20 73  te " status: " s
1990: 74 61 74 75 73 20 22 20 75 73 65 72 3a 20 22 20  tatus " user: " 
19a0: 75 73 65 72 29 0a 20 20 28 6c 65 74 2a 20 28 28  user).  (let* ((
19b0: 6b 65 79 73 74 72 20 20 20 20 28 6b 65 79 73 2d  keystr    (keys-
19c0: 3e 6b 65 79 73 74 72 20 6b 65 79 73 29 29 0a 09  >keystr keys))..
19d0: 20 28 63 6f 6d 6d 61 20 20 20 20 20 28 69 66 20   (comma     (if 
19e0: 28 3e 20 28 6c 65 6e 67 74 68 20 6b 65 79 73 29  (> (length keys)
19f0: 20 30 29 20 22 2c 22 20 22 22 29 29 0a 09 20 28   0) "," "")).. (
1a00: 61 6e 64 73 74 72 20 20 20 20 28 69 66 20 28 3e  andstr    (if (>
1a10: 20 28 6c 65 6e 67 74 68 20 6b 65 79 73 29 20 30   (length keys) 0
1a20: 29 20 22 20 41 4e 44 20 22 20 22 22 29 29 0a 09  ) " AND " ""))..
1a30: 20 28 76 61 6c 73 6c 6f 74 73 20 20 28 6b 65 79   (valslots  (key
1a40: 73 2d 3e 76 61 6c 73 6c 6f 74 73 20 6b 65 79 73  s->valslots keys
1a50: 29 29 20 3b 3b 20 3f 2c 3f 2c 3f 20 2e 2e 2e 0a  )) ;; ?,?,? ....
1a60: 09 20 28 6b 65 79 76 61 6c 73 20 20 20 28 6d 61  . (keyvals   (ma
1a70: 70 20 63 61 64 72 20 6b 65 79 76 61 6c 6c 73 74  p cadr keyvallst
1a80: 29 29 0a 09 20 28 61 6c 6c 76 61 6c 73 20 20 20  )).. (allvals   
1a90: 28 61 70 70 65 6e 64 20 28 6c 69 73 74 20 72 75  (append (list ru
1aa0: 6e 6e 61 6d 65 20 73 74 61 74 65 20 73 74 61 74  nname state stat
1ab0: 75 73 20 75 73 65 72 29 20 6b 65 79 76 61 6c 73  us user) keyvals
1ac0: 29 29 0a 09 20 28 71 72 79 76 61 6c 73 20 20 20  )).. (qryvals   
1ad0: 28 61 70 70 65 6e 64 20 28 6c 69 73 74 20 72 75  (append (list ru
1ae0: 6e 6e 61 6d 65 29 20 6b 65 79 76 61 6c 73 29 29  nname) keyvals))
1af0: 0a 09 20 28 6b 65 79 3d 3f 73 74 72 20 20 28 73  .. (key=?str  (s
1b00: 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73  tring-interspers
1b10: 65 20 28 6d 61 70 20 28 6c 61 6d 62 64 61 20 28  e (map (lambda (
1b20: 6b 29 28 63 6f 6e 63 20 28 6b 65 79 3a 67 65 74  k)(conc (key:get
1b30: 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 29 20 22 3d  -fieldname k) "=
1b40: 3f 22 29 29 20 6b 65 79 73 29 20 22 20 41 4e 44  ?")) keys) " AND
1b50: 20 22 29 29 29 0a 20 20 20 20 28 64 65 62 75 67   "))).    (debug
1b60: 3a 70 72 69 6e 74 20 33 20 22 6b 65 79 73 3a 20  :print 3 "keys: 
1b70: 22 20 6b 65 79 73 20 22 20 61 6c 6c 76 61 6c 73  " keys " allvals
1b80: 3a 20 22 20 61 6c 6c 76 61 6c 73 20 22 20 6b 65  : " allvals " ke
1b90: 79 76 61 6c 73 3a 20 22 20 6b 65 79 76 61 6c 73  yvals: " keyvals
1ba0: 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72 69  ).    (debug:pri
1bb0: 6e 74 20 32 20 22 4e 4f 54 45 3a 20 75 73 69 6e  nt 2 "NOTE: usin
1bc0: 67 20 74 61 72 67 65 74 20 22 20 28 73 74 72 69  g target " (stri
1bd0: 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 6b  ng-intersperse k
1be0: 65 79 76 61 6c 73 20 22 2f 22 29 20 22 20 66 6f  eyvals "/") " fo
1bf0: 72 20 74 68 69 73 20 72 75 6e 22 29 0a 20 20 20  r this run").   
1c00: 20 28 69 66 20 28 61 6e 64 20 72 75 6e 6e 61 6d   (if (and runnam
1c10: 65 20 28 6e 75 6c 6c 3f 20 28 66 69 6c 74 65 72  e (null? (filter
1c20: 20 28 6c 61 6d 62 64 61 20 28 78 29 28 6e 6f 74   (lambda (x)(not
1c30: 20 78 29 29 20 6b 65 79 76 61 6c 73 29 29 29 20   x)) keyvals))) 
1c40: 3b 3b 20 74 68 65 72 65 20 6d 75 73 74 20 62 65  ;; there must be
1c50: 20 61 20 62 65 74 74 65 72 20 77 61 79 20 74 6f   a better way to
1c60: 20 22 61 70 70 6c 79 20 61 6e 64 22 0a 09 28 6c   "apply and"..(l
1c70: 65 74 20 28 28 72 65 73 20 23 66 29 29 0a 09 20  et ((res #f)).. 
1c80: 20 28 61 70 70 6c 79 20 73 71 6c 69 74 65 33 3a   (apply sqlite3:
1c90: 65 78 65 63 75 74 65 20 64 62 20 28 63 6f 6e 63  execute db (conc
1ca0: 20 22 49 4e 53 45 52 54 20 4f 52 20 49 47 4e 4f   "INSERT OR IGNO
1cb0: 52 45 20 49 4e 54 4f 20 72 75 6e 73 20 28 72 75  RE INTO runs (ru
1cc0: 6e 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 61 74  nname,state,stat
1cd0: 75 73 2c 6f 77 6e 65 72 2c 65 76 65 6e 74 5f 74  us,owner,event_t
1ce0: 69 6d 65 22 20 63 6f 6d 6d 61 20 6b 65 79 73 74  ime" comma keyst
1cf0: 72 20 22 29 20 56 41 4c 55 45 53 20 28 3f 2c 3f  r ") VALUES (?,?
1d00: 2c 3f 2c 3f 2c 73 74 72 66 74 69 6d 65 28 27 25  ,?,?,strftime('%
1d10: 73 27 2c 27 6e 6f 77 27 29 22 20 63 6f 6d 6d 61  s','now')" comma
1d20: 20 76 61 6c 73 6c 6f 74 73 20 22 29 3b 22 29 0a   valslots ");").
1d30: 09 09 20 61 6c 6c 76 61 6c 73 29 0a 09 20 20 28  .. allvals)..  (
1d40: 61 70 70 6c 79 20 73 71 6c 69 74 65 33 3a 66 6f  apply sqlite3:fo
1d50: 72 2d 65 61 63 68 2d 72 6f 77 20 0a 09 20 20 20  r-each-row ..   
1d60: 28 6c 61 6d 62 64 61 20 28 69 64 29 0a 09 20 20  (lambda (id)..  
1d70: 20 20 20 28 73 65 74 21 20 72 65 73 20 69 64 29     (set! res id)
1d80: 29 0a 09 20 20 20 64 62 0a 09 20 20 20 28 6c 65  )..   db..   (le
1d90: 74 20 28 28 71 72 79 20 28 63 6f 6e 63 20 22 53  t ((qry (conc "S
1da0: 45 4c 45 43 54 20 69 64 20 46 52 4f 4d 20 72 75  ELECT id FROM ru
1db0: 6e 73 20 57 48 45 52 45 20 28 72 75 6e 6e 61 6d  ns WHERE (runnam
1dc0: 65 3d 3f 20 22 20 61 6e 64 73 74 72 20 6b 65 79  e=? " andstr key
1dd0: 3d 3f 73 74 72 20 22 29 3b 22 29 29 29 0a 09 20  =?str ");"))).. 
1de0: 20 20 20 20 3b 28 64 65 62 75 67 3a 70 72 69 6e      ;(debug:prin
1df0: 74 20 34 20 22 71 72 79 3a 20 22 20 71 72 79 29  t 4 "qry: " qry)
1e00: 20 0a 09 20 20 20 20 20 71 72 79 29 0a 09 20 20   ..     qry)..  
1e10: 20 71 72 79 76 61 6c 73 29 0a 09 20 20 28 73 71   qryvals)..  (sq
1e20: 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 64 62  lite3:execute db
1e30: 20 22 55 50 44 41 54 45 20 72 75 6e 73 20 53 45   "UPDATE runs SE
1e40: 54 20 73 74 61 74 65 3d 3f 2c 73 74 61 74 75 73  T state=?,status
1e50: 3d 3f 20 57 48 45 52 45 20 69 64 3d 3f 3b 22 20  =? WHERE id=?;" 
1e60: 73 74 61 74 65 20 73 74 61 74 75 73 20 72 65 73  state status res
1e70: 29 0a 09 20 20 72 65 73 29 20 0a 09 28 62 65 67  )..  res) ..(beg
1e80: 69 6e 0a 09 20 20 28 64 65 62 75 67 3a 70 72 69  in..  (debug:pri
1e90: 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 43 61 6c  nt 0 "ERROR: Cal
1ea0: 6c 65 64 20 77 69 74 68 6f 75 74 20 61 6c 6c 20  led without all 
1eb0: 6e 65 63 65 73 73 61 72 79 20 6b 65 79 73 22 29  necessary keys")
1ec0: 0a 09 20 20 23 66 29 29 29 29 0a 0a 3b 3b 20 54  ..  #f))))..;; T
1ed0: 68 69 73 20 69 73 20 61 20 64 75 70 6c 69 63 61  his is a duplica
1ee0: 74 65 20 6f 66 20 72 75 6e 2d 74 65 73 74 73 20  te of run-tests 
1ef0: 28 77 68 69 63 68 20 68 61 73 20 62 65 65 6e 20  (which has been 
1f00: 64 65 70 72 65 63 61 74 65 64 29 2e 20 55 73 65  deprecated). Use
1f10: 20 74 68 69 73 20 6f 6e 65 20 69 6e 73 74 65 61   this one instea
1f20: 64 20 6f 66 20 72 75 6e 20 74 65 73 74 73 2e 0a  d of run tests..
1f30: 3b 3b 20 6b 65 79 76 61 6c 73 0a 28 64 65 66 69  ;; keyvals.(defi
1f40: 6e 65 20 28 72 75 6e 73 3a 72 75 6e 2d 74 65 73  ne (runs:run-tes
1f50: 74 73 20 74 61 72 67 65 74 20 72 75 6e 6e 61 6d  ts target runnam
1f60: 65 20 74 65 73 74 2d 70 61 74 74 73 20 75 73 65  e test-patts use
1f70: 72 20 66 6c 61 67 73 29 0a 20 20 28 6c 65 74 2a  r flags).  (let*
1f80: 20 28 28 64 62 20 20 20 20 20 20 20 20 20 20 23   ((db          #
1f90: 66 29 0a 09 20 28 6b 65 79 73 20 20 20 20 20 20  f).. (keys      
1fa0: 20 20 28 63 64 62 3a 72 65 6d 6f 74 65 2d 72 75    (cdb:remote-ru
1fb0: 6e 20 64 62 3a 67 65 74 2d 6b 65 79 73 20 23 66  n db:get-keys #f
1fc0: 29 29 0a 09 20 28 6b 65 79 76 61 6c 6c 73 74 20  )).. (keyvallst 
1fd0: 20 20 28 6b 65 79 73 3a 74 61 72 67 65 74 2d 3e    (keys:target->
1fe0: 6b 65 79 76 61 6c 20 6b 65 79 73 20 74 61 72 67  keyval keys targ
1ff0: 65 74 29 29 0a 09 20 28 72 75 6e 2d 69 64 20 20  et)).. (run-id  
2000: 20 20 20 20 28 63 64 62 3a 72 65 6d 6f 74 65 2d      (cdb:remote-
2010: 72 75 6e 20 72 75 6e 73 3a 72 65 67 69 73 74 65  run runs:registe
2020: 72 2d 72 75 6e 20 23 66 20 6b 65 79 73 20 6b 65  r-run #f keys ke
2030: 79 76 61 6c 6c 73 74 20 72 75 6e 6e 61 6d 65 20  yvallst runname 
2040: 22 6e 65 77 22 20 22 6e 2f 61 22 20 75 73 65 72  "new" "n/a" user
2050: 29 29 20 20 3b 3b 20 20 74 65 73 74 2d 6e 61 6d  ))  ;;  test-nam
2060: 65 29 29 29 0a 09 20 28 64 65 66 65 72 72 65 64  e))).. (deferred
2070: 20 20 20 20 27 28 29 29 20 3b 3b 20 64 65 6c 61      '()) ;; dela
2080: 79 20 72 75 6e 6e 69 6e 67 20 74 68 65 73 65 20  y running these 
2090: 73 69 6e 63 65 20 74 68 65 79 20 68 61 76 65 20  since they have 
20a0: 61 20 77 61 69 74 6f 6e 20 63 6c 61 75 73 65 0a  a waiton clause.
20b0: 09 20 3b 3b 20 6b 65 65 70 67 6f 69 6e 67 20 69  . ;; keepgoing i
20c0: 73 20 74 68 65 20 64 65 66 61 63 74 6f 20 6d 6f  s the defacto mo
20d0: 64 61 6c 69 74 79 20 6e 6f 77 2c 20 77 69 6c 6c  dality now, will
20e0: 20 61 64 64 20 68 69 74 2d 6e 2d 72 75 6e 20 61   add hit-n-run a
20f0: 20 62 69 74 20 6c 61 74 65 72 0a 09 20 3b 3b 20   bit later.. ;; 
2100: 28 6b 65 65 70 67 6f 69 6e 67 20 20 20 28 68 61  (keepgoing   (ha
2110: 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66  sh-table-ref/def
2120: 61 75 6c 74 20 66 6c 61 67 73 20 22 2d 6b 65 65  ault flags "-kee
2130: 70 67 6f 69 6e 67 22 20 23 66 29 29 0a 09 20 28  pgoing" #f)).. (
2140: 74 65 73 74 2d 6e 61 6d 65 73 20 20 27 28 29 29  test-names  '())
2150: 0a 09 20 28 72 75 6e 63 6f 6e 66 69 67 66 20 20  .. (runconfigf  
2160: 20 28 63 6f 6e 63 20 20 2a 74 6f 70 70 61 74 68   (conc  *toppath
2170: 2a 20 22 2f 72 75 6e 63 6f 6e 66 69 67 73 2e 63  * "/runconfigs.c
2180: 6f 6e 66 69 67 22 29 29 0a 09 20 28 72 65 71 75  onfig")).. (requ
2190: 69 72 65 64 2d 74 65 73 74 73 20 27 28 29 29 0a  ired-tests '()).
21a0: 09 20 28 74 65 73 74 2d 72 65 63 6f 72 64 73 20  . (test-records 
21b0: 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65  (make-hash-table
21c0: 29 29 29 0a 0a 20 20 20 20 28 73 65 74 2d 6d 65  )))..    (set-me
21d0: 67 61 74 65 73 74 2d 65 6e 76 2d 76 61 72 73 20  gatest-env-vars 
21e0: 72 75 6e 2d 69 64 29 20 3b 3b 20 74 68 65 73 65  run-id) ;; these
21f0: 20 6d 61 79 20 62 65 20 6e 65 65 64 65 64 20 62   may be needed b
2200: 79 20 74 68 65 20 6c 61 75 6e 63 68 69 6e 67 20  y the launching 
2210: 70 72 6f 63 65 73 73 0a 0a 20 20 20 20 28 69 66  process..    (if
2220: 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 72   (file-exists? r
2230: 75 6e 63 6f 6e 66 69 67 66 29 0a 09 28 6f 70 65  unconfigf)..(ope
2240: 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 73 65 74 75  n-run-close setu
2250: 70 2d 65 6e 76 2d 64 65 66 61 75 6c 74 73 20 64  p-env-defaults d
2260: 62 20 72 75 6e 63 6f 6e 66 69 67 66 20 72 75 6e  b runconfigf run
2270: 2d 69 64 20 2a 61 6c 72 65 61 64 79 2d 73 65 65  -id *already-see
2280: 6e 2d 72 75 6e 63 6f 6e 66 69 67 2d 69 6e 66 6f  n-runconfig-info
2290: 2a 20 22 70 72 65 2d 6c 61 75 6e 63 68 2d 65 6e  * "pre-launch-en
22a0: 76 2d 76 61 72 73 22 29 0a 09 28 64 65 62 75 67  v-vars")..(debug
22b0: 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e  :print 0 "WARNIN
22c0: 47 3a 20 59 6f 75 20 64 6f 20 6e 6f 74 20 68 61  G: You do not ha
22d0: 76 65 20 61 20 72 75 6e 20 63 6f 6e 66 69 67 20  ve a run config 
22e0: 66 69 6c 65 3a 20 22 20 72 75 6e 63 6f 6e 66 69  file: " runconfi
22f0: 67 66 29 29 0a 20 20 20 20 0a 20 20 20 20 3b 3b  gf)).    .    ;;
2300: 20 6c 6f 6f 6b 20 75 70 20 61 6c 6c 20 74 65 73   look up all tes
2310: 74 73 20 6d 61 74 63 68 69 6e 67 20 74 68 65 20  ts matching the 
2320: 63 6f 6d 6d 61 20 73 65 70 61 72 61 74 65 64 20  comma separated 
2330: 6c 69 73 74 20 6f 66 20 67 6c 6f 62 73 20 69 6e  list of globs in
2340: 0a 20 20 20 20 3b 3b 20 74 65 73 74 2d 70 61 74  .    ;; test-pat
2350: 74 73 20 28 75 73 69 6e 67 20 25 20 61 73 20 77  ts (using % as w
2360: 69 6c 64 63 61 72 64 29 0a 0a 20 20 20 20 28 73  ildcard)..    (s
2370: 65 74 21 20 74 65 73 74 2d 6e 61 6d 65 73 20 28  et! test-names (
2380: 74 65 73 74 73 3a 67 65 74 2d 76 61 6c 69 64 2d  tests:get-valid-
2390: 74 65 73 74 73 20 2a 74 6f 70 70 61 74 68 2a 20  tests *toppath* 
23a0: 74 65 73 74 2d 70 61 74 74 73 20 74 65 73 74 2d  test-patts test-
23b0: 6e 61 6d 65 73 3a 20 74 65 73 74 2d 6e 61 6d 65  names: test-name
23c0: 73 29 29 0a 20 20 20 20 28 73 65 74 21 20 74 65  s)).    (set! te
23d0: 73 74 2d 6e 61 6d 65 73 20 28 64 65 6c 65 74 65  st-names (delete
23e0: 2d 64 75 70 6c 69 63 61 74 65 73 20 74 65 73 74  -duplicates test
23f0: 2d 6e 61 6d 65 73 29 29 0a 0a 20 20 20 20 28 64  -names))..    (d
2400: 65 62 75 67 3a 70 72 69 6e 74 2d 69 6e 66 6f 20  ebug:print-info 
2410: 30 20 22 74 65 73 74 20 6e 61 6d 65 73 20 22 20  0 "test names " 
2420: 74 65 73 74 2d 6e 61 6d 65 73 29 0a 0a 20 20 20  test-names)..   
2430: 20 3b 3b 20 6f 6e 20 74 68 65 20 66 69 72 73 74   ;; on the first
2440: 20 70 61 73 73 20 6f 72 20 63 61 6c 6c 20 74 6f   pass or call to
2450: 20 72 75 6e 2d 74 65 73 74 73 20 73 65 74 20 46   run-tests set F
2460: 41 49 4c 53 20 74 6f 20 4e 4f 54 5f 53 54 41 52  AILS to NOT_STAR
2470: 54 45 44 20 69 66 0a 20 20 20 20 3b 3b 20 2d 6b  TED if.    ;; -k
2480: 65 65 70 67 6f 69 6e 67 20 69 73 20 73 70 65 63  eepgoing is spec
2490: 69 66 69 65 64 0a 20 20 20 20 28 69 66 20 28 65  ified.    (if (e
24a0: 71 3f 20 2a 70 61 73 73 6e 75 6d 2a 20 30 29 0a  q? *passnum* 0).
24b0: 09 28 62 65 67 69 6e 0a 09 20 20 3b 3b 20 68 61  .(begin..  ;; ha
24c0: 76 65 20 74 6f 20 64 65 6c 65 74 65 20 74 65 73  ve to delete tes
24d0: 74 20 72 65 63 6f 72 64 73 20 77 68 65 72 65 20  t records where 
24e0: 4e 4f 54 5f 53 54 41 52 54 45 44 20 73 69 6e 63  NOT_STARTED sinc
24f0: 65 20 74 68 65 79 20 63 61 6e 20 63 61 75 73 65  e they can cause
2500: 20 2d 6b 65 65 70 67 6f 69 6e 67 20 74 6f 20 0a   -keepgoing to .
2510: 09 20 20 3b 3b 20 67 65 74 20 73 74 75 63 6b 20  .  ;; get stuck 
2520: 64 75 65 20 74 6f 20 62 65 63 6f 6d 69 6e 67 20  due to becoming 
2530: 69 6e 61 63 63 65 73 73 69 62 6c 65 20 66 72 6f  inaccessible fro
2540: 6d 20 61 20 66 61 69 6c 65 64 20 74 65 73 74 2e  m a failed test.
2550: 20 49 2e 65 2e 20 69 66 20 74 65 73 74 20 42 20   I.e. if test B 
2560: 64 65 70 65 6e 64 73 20 0a 09 20 20 3b 3b 20 6f  depends ..  ;; o
2570: 6e 20 74 65 73 74 20 41 20 62 75 74 20 74 65 73  n test A but tes
2580: 74 20 42 20 72 65 61 63 68 65 64 20 74 68 65 20  t B reached the 
2590: 70 6f 69 6e 74 20 6f 6e 20 62 65 69 6e 67 20 72  point on being r
25a0: 65 67 69 73 74 65 72 65 64 20 61 73 20 4e 4f 54  egistered as NOT
25b0: 5f 53 54 41 52 54 45 44 20 61 6e 64 20 74 65 73  _STARTED and tes
25c0: 74 0a 09 20 20 3b 3b 20 41 20 66 61 69 6c 65 64  t..  ;; A failed
25d0: 20 66 6f 72 20 73 6f 6d 65 20 72 65 61 73 6f 6e   for some reason
25e0: 20 74 68 65 6e 20 6f 6e 20 72 65 2d 72 75 6e 20   then on re-run 
25f0: 75 73 69 6e 67 20 2d 6b 65 65 70 67 6f 69 6e 67  using -keepgoing
2600: 20 74 68 65 20 72 75 6e 20 63 61 6e 20 6e 65 76   the run can nev
2610: 65 72 20 63 6f 6d 70 6c 65 74 65 2e 0a 09 20 20  er complete...  
2620: 28 63 64 62 3a 64 65 6c 65 74 65 2d 74 65 73 74  (cdb:delete-test
2630: 73 2d 69 6e 2d 73 74 61 74 65 20 2a 72 75 6e 72  s-in-state *runr
2640: 65 6d 6f 74 65 2a 20 72 75 6e 2d 69 64 20 22 4e  emote* run-id "N
2650: 4f 54 5f 53 54 41 52 54 45 44 22 29 0a 09 20 20  OT_STARTED")..  
2660: 28 63 64 62 3a 72 65 6d 6f 74 65 2d 72 75 6e 20  (cdb:remote-run 
2670: 64 62 3a 73 65 74 2d 74 65 73 74 73 2d 73 74 61  db:set-tests-sta
2680: 74 65 2d 73 74 61 74 75 73 20 23 66 20 72 75 6e  te-status #f run
2690: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 73 20 23  -id test-names #
26a0: 66 20 22 46 41 49 4c 22 20 22 4e 4f 54 5f 53 54  f "FAIL" "NOT_ST
26b0: 41 52 54 45 44 22 20 22 46 41 49 4c 22 29 29 29  ARTED" "FAIL")))
26c0: 0a 0a 20 20 20 20 3b 3b 20 66 72 6f 6d 20 68 65  ..    ;; from he
26d0: 72 65 20 6f 6e 20 6f 75 74 20 74 68 65 20 64 62  re on out the db
26e0: 20 77 69 6c 6c 20 62 65 20 6f 70 65 6e 65 64 20   will be opened 
26f0: 61 6e 64 20 63 6c 6f 73 65 64 20 6f 6e 20 65 76  and closed on ev
2700: 65 72 79 20 63 61 6c 6c 20 72 75 6e 73 3a 72 75  ery call runs:ru
2710: 6e 2d 74 65 73 74 73 2d 71 75 65 75 65 0a 20 20  n-tests-queue.  
2720: 20 20 3b 3b 20 28 73 71 6c 69 74 65 33 3a 66 69    ;; (sqlite3:fi
2730: 6e 61 6c 69 7a 65 21 20 64 62 29 20 0a 20 20 20  nalize! db) .   
2740: 20 3b 3b 20 6e 6f 77 20 61 64 64 20 6e 6f 6e 2d   ;; now add non-
2750: 64 69 72 65 63 74 6c 79 20 72 65 66 65 72 65 6e  directly referen
2760: 63 65 64 20 64 65 70 65 6e 64 65 6e 63 69 65 73  ced dependencies
2770: 20 28 69 2e 65 2e 20 77 61 69 74 6f 6e 29 0a 20   (i.e. waiton). 
2780: 20 20 20 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c     (if (not (nul
2790: 6c 3f 20 74 65 73 74 2d 6e 61 6d 65 73 29 29 0a  l? test-names)).
27a0: 09 28 6c 65 74 20 6c 6f 6f 70 20 28 28 68 65 64  .(let loop ((hed
27b0: 20 28 63 61 72 20 74 65 73 74 2d 6e 61 6d 65 73   (car test-names
27c0: 29 29 0a 09 09 20 20 20 28 74 61 6c 20 28 63 64  ))...   (tal (cd
27d0: 72 20 74 65 73 74 2d 6e 61 6d 65 73 29 29 29 20  r test-names))) 
27e0: 20 20 20 20 20 20 20 20 3b 3b 20 27 72 65 74 75          ;; 'retu
27f0: 72 6e 2d 70 72 6f 63 73 20 74 65 6c 6c 73 20 74  rn-procs tells t
2800: 68 65 20 63 6f 6e 66 69 67 20 72 65 61 64 65 72  he config reader
2810: 20 74 6f 20 70 72 65 70 20 72 75 6e 6e 69 6e 67   to prep running
2820: 20 73 79 73 74 65 6d 20 62 75 74 20 72 65 74 75   system but retu
2830: 72 6e 20 61 20 70 72 6f 63 0a 09 20 20 28 64 65  rn a proc..  (de
2840: 62 75 67 3a 70 72 69 6e 74 2d 69 6e 66 6f 20 34  bug:print-info 4
2850: 20 22 68 65 64 3d 22 20 68 65 64 20 22 20 61 74   "hed=" hed " at
2860: 20 74 6f 70 20 6f 66 20 6c 6f 6f 70 22 29 0a 09   top of loop")..
2870: 20 20 28 6c 65 74 2a 20 28 28 63 6f 6e 66 69 67    (let* ((config
2880: 20 20 28 74 65 73 74 73 3a 67 65 74 2d 74 65 73    (tests:get-tes
2890: 74 63 6f 6e 66 69 67 20 68 65 64 20 27 72 65 74  tconfig hed 'ret
28a0: 75 72 6e 2d 70 72 6f 63 73 29 29 0a 09 09 20 28  urn-procs))... (
28b0: 77 61 69 74 6f 6e 73 20 28 69 66 20 63 6f 6e 66  waitons (if conf
28c0: 69 67 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74  ig (string-split
28d0: 20 28 6c 65 74 20 28 28 77 20 28 63 6f 6e 66 69   (let ((w (confi
28e0: 67 2d 6c 6f 6f 6b 75 70 20 63 6f 6e 66 69 67 20  g-lookup config 
28f0: 22 72 65 71 75 69 72 65 6d 65 6e 74 73 22 20 22  "requirements" "
2900: 77 61 69 74 6f 6e 22 29 29 29 0a 09 09 09 09 09  waiton")))......
2910: 09 20 20 20 20 20 28 69 66 20 77 20 77 20 22 22  .     (if w w ""
2920: 29 29 29 0a 09 09 09 20 20 20 20 20 20 28 62 65  )))....      (be
2930: 67 69 6e 0a 09 09 09 09 28 64 65 62 75 67 3a 70  gin.....(debug:p
2940: 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 6e  rint 0 "ERROR: n
2950: 6f 6e 2d 65 78 69 73 74 65 6e 74 20 72 65 71 75  on-existent requ
2960: 69 72 65 64 20 74 65 73 74 20 5c 22 22 20 68 65  ired test \"" he
2970: 64 20 22 5c 22 22 29 0a 20 20 20 20 20 20 20 20  d "\"").        
2980: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2990: 20 20 20 20 20 20 20 20 28 69 66 20 64 62 20 28          (if db (
29a0: 73 71 6c 69 74 65 33 3a 66 69 6e 61 6c 69 7a 65  sqlite3:finalize
29b0: 21 20 64 62 29 29 0a 09 09 09 09 28 65 78 69 74  ! db)).....(exit
29c0: 20 31 29 29 29 29 29 0a 09 20 20 20 20 3b 3b 20   1)))))..    ;; 
29d0: 63 68 65 63 6b 20 66 6f 72 20 68 65 64 20 69 6e  check for hed in
29e0: 20 77 61 69 74 6f 6e 73 20 3d 3e 20 74 68 69 73   waitons => this
29f0: 20 77 6f 75 6c 64 20 62 65 20 63 69 72 63 75 6c   would be circul
2a00: 61 72 2c 20 72 65 6d 6f 76 65 20 69 74 20 61 6e  ar, remove it an
2a10: 64 20 69 73 73 75 65 20 61 6e 0a 09 20 20 20 20  d issue an..    
2a20: 3b 3b 20 65 72 72 6f 72 0a 09 20 20 20 20 28 69  ;; error..    (i
2a30: 66 20 28 6d 65 6d 62 65 72 20 68 65 64 20 77 61  f (member hed wa
2a40: 69 74 6f 6e 73 29 0a 09 09 28 62 65 67 69 6e 0a  itons)...(begin.
2a50: 09 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ..  (debug:print
2a60: 20 30 20 22 45 52 52 4f 52 3a 20 74 65 73 74 20   0 "ERROR: test 
2a70: 22 20 68 65 64 20 22 20 68 61 73 20 6c 69 73 74  " hed " has list
2a80: 65 64 20 69 74 73 65 6c 66 20 61 73 20 61 20 77  ed itself as a w
2a90: 61 69 74 6f 6e 2c 20 70 6c 65 61 73 65 20 63 6f  aiton, please co
2aa0: 72 72 65 63 74 20 74 68 69 73 21 22 29 0a 09 09  rrect this!")...
2ab0: 20 20 28 73 65 74 21 20 77 61 69 74 6f 6e 73 20    (set! waitons 
2ac0: 28 66 69 6c 74 65 72 20 28 6c 61 6d 62 64 61 20  (filter (lambda 
2ad0: 28 78 29 28 6e 6f 74 20 28 65 71 75 61 6c 3f 20  (x)(not (equal? 
2ae0: 78 20 68 65 64 29 29 29 20 77 61 69 74 6f 6e 73  x hed))) waitons
2af0: 29 29 29 29 0a 09 20 20 20 20 0a 09 20 20 20 20  ))))..    ..    
2b00: 3b 3b 20 28 69 74 65 6d 73 20 20 20 28 69 74 65  ;; (items   (ite
2b10: 6d 73 3a 67 65 74 2d 69 74 65 6d 73 2d 66 72 6f  ms:get-items-fro
2b20: 6d 2d 63 6f 6e 66 69 67 20 63 6f 6e 66 69 67 29  m-config config)
2b30: 29 29 0a 09 20 20 20 20 28 69 66 20 28 6e 6f 74  ))..    (if (not
2b40: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
2b50: 2f 64 65 66 61 75 6c 74 20 74 65 73 74 2d 72 65  /default test-re
2b60: 63 6f 72 64 73 20 68 65 64 20 23 66 29 29 0a 09  cords hed #f))..
2b70: 09 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74  .(hash-table-set
2b80: 21 20 74 65 73 74 2d 72 65 63 6f 72 64 73 0a 09  ! test-records..
2b90: 09 09 09 20 68 65 64 20 28 76 65 63 74 6f 72 20  ... hed (vector 
2ba0: 68 65 64 20 20 20 20 20 3b 3b 20 30 0a 09 09 09  hed     ;; 0....
2bb0: 09 09 20 20 20 20 20 63 6f 6e 66 69 67 20 20 3b  ..     config  ;
2bc0: 3b 20 31 0a 09 09 09 09 09 20 20 20 20 20 77 61  ; 1......     wa
2bd0: 69 74 6f 6e 73 20 3b 3b 20 32 0a 09 09 09 09 09  itons ;; 2......
2be0: 20 20 20 20 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f       (config-loo
2bf0: 6b 75 70 20 63 6f 6e 66 69 67 20 22 72 65 71 75  kup config "requ
2c00: 69 72 65 6d 65 6e 74 73 22 20 22 70 72 69 6f 72  irements" "prior
2c10: 69 74 79 22 29 20 20 20 20 20 3b 3b 20 70 72 69  ity")     ;; pri
2c20: 6f 72 69 74 79 20 33 0a 09 09 09 09 09 20 20 20  ority 3......   
2c30: 20 20 28 6c 65 74 20 28 28 69 74 65 6d 73 20 20    (let ((items  
2c40: 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d      (hash-table-
2c50: 72 65 66 2f 64 65 66 61 75 6c 74 20 63 6f 6e 66  ref/default conf
2c60: 69 67 20 22 69 74 65 6d 73 22 20 23 66 29 29 20  ig "items" #f)) 
2c70: 3b 3b 20 69 74 65 6d 73 20 34 0a 09 09 09 09 09  ;; items 4......
2c80: 09 20 20 20 28 69 74 65 6d 73 74 61 62 6c 65 20  .   (itemstable 
2c90: 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f  (hash-table-ref/
2ca0: 64 65 66 61 75 6c 74 20 63 6f 6e 66 69 67 20 22  default config "
2cb0: 69 74 65 6d 73 74 61 62 6c 65 22 20 23 66 29 29  itemstable" #f))
2cc0: 29 20 0a 09 09 09 09 09 20 20 20 20 20 20 20 3b  ) ......       ;
2cd0: 3b 20 69 66 20 65 69 74 68 65 72 20 69 74 65 6d  ; if either item
2ce0: 73 20 6f 72 20 69 74 65 6d 73 20 74 61 62 6c 65  s or items table
2cf0: 20 69 73 20 61 20 70 72 6f 63 20 72 65 74 75 72   is a proc retur
2d00: 6e 20 69 74 20 73 6f 20 74 65 73 74 20 72 75 6e  n it so test run
2d10: 6e 69 6e 67 0a 09 09 09 09 09 20 20 20 20 20 20  ning......      
2d20: 20 3b 3b 20 70 72 6f 63 65 73 73 20 63 61 6e 20   ;; process can 
2d30: 6b 6e 6f 77 20 74 6f 20 63 61 6c 6c 20 69 74 65  know to call ite
2d40: 6d 73 3a 67 65 74 2d 69 74 65 6d 73 2d 66 72 6f  ms:get-items-fro
2d50: 6d 2d 63 6f 6e 66 69 67 0a 09 09 09 09 09 20 20  m-config......  
2d60: 20 20 20 20 20 3b 3b 20 69 66 20 65 69 74 68 65       ;; if eithe
2d70: 72 20 69 73 20 61 20 6c 69 73 74 20 61 6e 64 20  r is a list and 
2d80: 6e 6f 6e 65 20 69 73 20 61 20 70 72 6f 63 20 67  none is a proc g
2d90: 6f 20 61 68 65 61 64 20 61 6e 64 20 63 61 6c 6c  o ahead and call
2da0: 20 67 65 74 2d 69 74 65 6d 73 0a 09 09 09 09 09   get-items......
2db0: 20 20 20 20 20 20 20 3b 3b 20 6f 74 68 65 72 77         ;; otherw
2dc0: 69 73 65 20 72 65 74 75 72 6e 20 23 66 20 2d 20  ise return #f - 
2dd0: 74 68 69 73 20 69 73 20 6e 6f 74 20 61 6e 20 69  this is not an i
2de0: 74 65 72 61 74 65 64 20 74 65 73 74 0a 09 09 09  terated test....
2df0: 09 09 20 20 20 20 20 20 20 28 63 6f 6e 64 0a 09  ..       (cond..
2e00: 09 09 09 09 09 28 28 70 72 6f 63 65 64 75 72 65  .....((procedure
2e10: 3f 20 69 74 65 6d 73 29 20 20 20 20 20 20 0a 09  ? items)      ..
2e20: 09 09 09 09 09 20 28 64 65 62 75 67 3a 70 72 69  ..... (debug:pri
2e30: 6e 74 2d 69 6e 66 6f 20 34 20 22 69 74 65 6d 73  nt-info 4 "items
2e40: 20 69 73 20 61 20 70 72 6f 63 65 64 75 72 65 2c   is a procedure,
2e50: 20 77 69 6c 6c 20 63 61 6c 63 20 6c 61 74 65 72   will calc later
2e60: 22 29 0a 09 09 09 09 09 09 20 69 74 65 6d 73 29  ")....... items)
2e70: 20 20 20 20 20 20 20 20 20 20 20 20 3b 3b 20 63              ;; c
2e80: 61 6c 63 20 6c 61 74 65 72 0a 09 09 09 09 09 09  alc later.......
2e90: 28 28 70 72 6f 63 65 64 75 72 65 3f 20 69 74 65  ((procedure? ite
2ea0: 6d 73 74 61 62 6c 65 29 0a 09 09 09 09 09 09 20  mstable)....... 
2eb0: 28 64 65 62 75 67 3a 70 72 69 6e 74 2d 69 6e 66  (debug:print-inf
2ec0: 6f 20 34 20 22 69 74 65 6d 73 74 61 62 6c 65 20  o 4 "itemstable 
2ed0: 69 73 20 61 20 70 72 6f 63 65 64 75 72 65 2c 20  is a procedure, 
2ee0: 77 69 6c 6c 20 63 61 6c 63 20 6c 61 74 65 72 22  will calc later"
2ef0: 29 0a 09 09 09 09 09 09 20 69 74 65 6d 73 74 61  )....... itemsta
2f00: 62 6c 65 29 20 20 20 20 20 20 20 3b 3b 20 63 61  ble)       ;; ca
2f10: 6c 63 20 6c 61 74 65 72 0a 09 09 09 09 09 09 28  lc later.......(
2f20: 28 66 69 6c 74 65 72 20 28 6c 61 6d 62 64 61 20  (filter (lambda 
2f30: 28 78 29 0a 09 09 09 09 09 09 09 20 20 20 28 6c  (x)........   (l
2f40: 65 74 20 28 28 76 61 6c 20 28 63 61 72 20 78 29  et ((val (car x)
2f50: 29 29 0a 09 09 09 09 09 09 09 20 20 20 20 20 28  ))........     (
2f60: 69 66 20 28 70 72 6f 63 65 64 75 72 65 3f 20 76  if (procedure? v
2f70: 61 6c 29 20 76 61 6c 20 23 66 29 29 29 0a 09 09  al) val #f)))...
2f80: 09 09 09 09 09 20 28 61 70 70 65 6e 64 20 28 69  ..... (append (i
2f90: 66 20 28 6c 69 73 74 3f 20 69 74 65 6d 73 29 20  f (list? items) 
2fa0: 69 74 65 6d 73 20 27 28 29 29 0a 09 09 09 09 09  items '())......
2fb0: 09 09 09 20 28 69 66 20 28 6c 69 73 74 3f 20 69  ... (if (list? i
2fc0: 74 65 6d 73 74 61 62 6c 65 29 20 69 74 65 6d 73  temstable) items
2fd0: 74 61 62 6c 65 20 27 28 29 29 29 29 0a 09 09 09  table '())))....
2fe0: 09 09 09 20 27 68 61 76 65 2d 70 72 6f 63 65 64  ... 'have-proced
2ff0: 75 72 65 29 0a 09 09 09 09 09 09 28 28 6f 72 20  ure).......((or 
3000: 28 6c 69 73 74 3f 20 69 74 65 6d 73 29 28 6c 69  (list? items)(li
3010: 73 74 3f 20 69 74 65 6d 73 74 61 62 6c 65 29 29  st? itemstable))
3020: 20 3b 3b 20 63 61 6c 63 20 6e 6f 77 0a 09 09 09   ;; calc now....
3030: 09 09 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ... (debug:print
3040: 2d 69 6e 66 6f 20 34 20 22 69 74 65 6d 73 20 61  -info 4 "items a
3050: 6e 64 20 69 74 65 6d 73 74 61 62 6c 65 20 61 72  nd itemstable ar
3060: 65 20 6c 69 73 74 73 2c 20 63 61 6c 63 20 6e 6f  e lists, calc no
3070: 77 5c 6e 22 0a 09 09 09 09 09 09 09 20 20 20 20  w\n"........    
3080: 20 20 22 20 20 20 20 69 74 65 6d 73 3a 20 22 20    "    items: " 
3090: 69 74 65 6d 73 20 22 20 69 74 65 6d 73 74 61 62  items " itemstab
30a0: 6c 65 3a 20 22 20 69 74 65 6d 73 74 61 62 6c 65  le: " itemstable
30b0: 29 0a 09 09 09 09 09 09 20 28 69 74 65 6d 73 3a  )....... (items:
30c0: 67 65 74 2d 69 74 65 6d 73 2d 66 72 6f 6d 2d 63  get-items-from-c
30d0: 6f 6e 66 69 67 20 63 6f 6e 66 69 67 29 29 0a 09  onfig config))..
30e0: 09 09 09 09 09 28 65 6c 73 65 20 23 66 29 29 29  .....(else #f)))
30f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
3100: 20 20 20 20 20 20 20 20 20 20 20 3b 3b 20 6e 6f             ;; no
3110: 74 20 69 74 65 72 61 74 65 64 0a 09 09 09 09 09  t iterated......
3120: 20 20 20 20 20 23 66 20 20 20 20 20 20 3b 3b 20       #f      ;; 
3130: 69 74 65 6d 73 64 61 74 20 35 0a 09 09 09 09 09  itemsdat 5......
3140: 20 20 20 20 20 23 66 20 20 20 20 20 20 3b 3b 20       #f      ;; 
3150: 73 70 61 72 65 20 2d 20 75 73 65 64 20 66 6f 72  spare - used for
3160: 20 69 74 65 6d 2d 70 61 74 68 0a 09 09 09 09 09   item-path......
3170: 20 20 20 20 20 29 29 29 0a 09 20 20 20 20 28 66       )))..    (f
3180: 6f 72 2d 65 61 63 68 20 0a 09 20 20 20 20 20 28  or-each ..     (
3190: 6c 61 6d 62 64 61 20 28 77 61 69 74 6f 6e 29 0a  lambda (waiton).
31a0: 09 20 20 20 20 20 20 20 28 69 66 20 28 61 6e 64  .       (if (and
31b0: 20 77 61 69 74 6f 6e 20 28 6e 6f 74 20 28 6d 65   waiton (not (me
31c0: 6d 62 65 72 20 77 61 69 74 6f 6e 20 74 65 73 74  mber waiton test
31d0: 2d 6e 61 6d 65 73 29 29 29 0a 09 09 20 20 20 28  -names)))...   (
31e0: 62 65 67 69 6e 0a 09 09 20 20 20 20 20 28 73 65  begin...     (se
31f0: 74 21 20 72 65 71 75 69 72 65 64 2d 74 65 73 74  t! required-test
3200: 73 20 28 63 6f 6e 73 20 77 61 69 74 6f 6e 20 72  s (cons waiton r
3210: 65 71 75 69 72 65 64 2d 74 65 73 74 73 29 29 0a  equired-tests)).
3220: 09 09 20 20 20 20 20 28 73 65 74 21 20 74 65 73  ..     (set! tes
3230: 74 2d 6e 61 6d 65 73 20 28 63 6f 6e 73 20 77 61  t-names (cons wa
3240: 69 74 6f 6e 20 74 65 73 74 2d 6e 61 6d 65 73 29  iton test-names)
3250: 29 29 29 29 20 3b 3b 20 77 61 73 20 61 6e 20 61  )))) ;; was an a
3260: 70 70 65 6e 64 2c 20 6e 6f 77 20 61 20 63 6f 6e  ppend, now a con
3270: 73 0a 09 20 20 20 20 20 77 61 69 74 6f 6e 73 29  s..     waitons)
3280: 0a 09 20 20 20 20 28 6c 65 74 20 28 28 72 65 6d  ..    (let ((rem
3290: 74 65 73 74 73 20 28 64 65 6c 65 74 65 2d 64 75  tests (delete-du
32a0: 70 6c 69 63 61 74 65 73 20 28 61 70 70 65 6e 64  plicates (append
32b0: 20 77 61 69 74 6f 6e 73 20 74 61 6c 29 29 29 29   waitons tal))))
32c0: 0a 09 20 20 20 20 20 20 28 69 66 20 28 6e 6f 74  ..      (if (not
32d0: 20 28 6e 75 6c 6c 3f 20 72 65 6d 74 65 73 74 73   (null? remtests
32e0: 29 29 0a 09 09 20 20 28 6c 6f 6f 70 20 28 63 61  ))...  (loop (ca
32f0: 72 20 72 65 6d 74 65 73 74 73 29 28 63 64 72 20  r remtests)(cdr 
3300: 72 65 6d 74 65 73 74 73 29 29 29 29 29 29 29 0a  remtests))))))).
3310: 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28 6e  .    (if (not (n
3320: 75 6c 6c 3f 20 72 65 71 75 69 72 65 64 2d 74 65  ull? required-te
3330: 73 74 73 29 29 0a 09 28 64 65 62 75 67 3a 70 72  sts))..(debug:pr
3340: 69 6e 74 2d 69 6e 66 6f 20 31 20 22 41 64 64 69  int-info 1 "Addi
3350: 6e 67 20 22 20 72 65 71 75 69 72 65 64 2d 74 65  ng " required-te
3360: 73 74 73 20 22 20 74 6f 20 74 68 65 20 72 75 6e  sts " to the run
3370: 20 71 75 65 75 65 22 29 29 0a 20 20 20 20 3b 3b   queue")).    ;;
3380: 20 4e 4f 54 45 3a 20 74 68 65 73 65 20 61 72 65   NOTE: these are
3390: 20 61 6c 6c 20 70 61 72 65 6e 74 20 74 65 73 74   all parent test
33a0: 73 2c 20 69 74 65 6d 73 20 61 72 65 20 6e 6f 74  s, items are not
33b0: 20 65 78 70 61 6e 64 65 64 20 79 65 74 2e 0a 20   expanded yet.. 
33c0: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 2d     (debug:print-
33d0: 69 6e 66 6f 20 34 20 22 74 65 73 74 2d 72 65 63  info 4 "test-rec
33e0: 6f 72 64 73 3d 22 20 28 68 61 73 68 2d 74 61 62  ords=" (hash-tab
33f0: 6c 65 2d 3e 61 6c 69 73 74 20 74 65 73 74 2d 72  le->alist test-r
3400: 65 63 6f 72 64 73 29 29 0a 20 20 20 20 28 72 75  ecords)).    (ru
3410: 6e 73 3a 72 75 6e 2d 74 65 73 74 73 2d 71 75 65  ns:run-tests-que
3420: 75 65 20 72 75 6e 2d 69 64 20 72 75 6e 6e 61 6d  ue run-id runnam
3430: 65 20 74 65 73 74 2d 72 65 63 6f 72 64 73 20 6b  e test-records k
3440: 65 79 76 61 6c 6c 73 74 20 66 6c 61 67 73 20 74  eyvallst flags t
3450: 65 73 74 2d 70 61 74 74 73 29 0a 20 20 20 20 28  est-patts).    (
3460: 64 65 62 75 67 3a 70 72 69 6e 74 2d 69 6e 66 6f  debug:print-info
3470: 20 34 20 22 41 6c 6c 20 64 6f 6e 65 20 62 79 20   4 "All done by 
3480: 68 65 72 65 22 29 29 29 0a 0a 28 64 65 66 69 6e  here")))..(defin
3490: 65 20 28 72 75 6e 73 3a 63 61 6c 63 2d 66 61 69  e (runs:calc-fai
34a0: 6c 73 20 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d  ls prereqs-not-m
34b0: 65 74 29 0a 20 20 28 66 69 6c 74 65 72 20 28 6c  et).  (filter (l
34c0: 61 6d 62 64 61 20 28 74 65 73 74 29 0a 09 20 20  ambda (test)..  
34d0: 20 20 28 61 6e 64 20 28 76 65 63 74 6f 72 3f 20    (and (vector? 
34e0: 74 65 73 74 29 20 3b 3b 20 6e 6f 74 20 28 73 74  test) ;; not (st
34f0: 72 69 6e 67 3f 20 74 65 73 74 29 29 0a 09 09 20  ring? test))... 
3500: 28 65 71 75 61 6c 3f 20 28 64 62 3a 74 65 73 74  (equal? (db:test
3510: 2d 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 29  -get-state test)
3520: 20 22 43 4f 4d 50 4c 45 54 45 44 22 29 0a 09 09   "COMPLETED")...
3530: 20 28 6e 6f 74 20 28 6d 65 6d 62 65 72 20 28 64   (not (member (d
3540: 62 3a 74 65 73 74 2d 67 65 74 2d 73 74 61 74 75  b:test-get-statu
3550: 73 20 74 65 73 74 29 0a 09 09 09 20 20 20 20 20  s test)....     
3560: 20 27 28 22 50 41 53 53 22 20 22 57 41 52 4e 22   '("PASS" "WARN"
3570: 20 22 43 48 45 43 4b 22 20 22 57 41 49 56 45 44   "CHECK" "WAIVED
3580: 22 29 29 29 29 29 0a 09 20 20 70 72 65 72 65 71  ")))))..  prereq
3590: 73 2d 6e 6f 74 2d 6d 65 74 29 29 0a 0a 28 64 65  s-not-met))..(de
35a0: 66 69 6e 65 20 28 72 75 6e 73 3a 63 61 6c 63 2d  fine (runs:calc-
35b0: 6e 6f 74 2d 63 6f 6d 70 6c 65 74 65 64 20 70 72  not-completed pr
35c0: 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 29 0a 20  ereqs-not-met). 
35d0: 20 28 66 69 6c 74 65 72 0a 20 20 20 28 6c 61 6d   (filter.   (lam
35e0: 62 64 61 20 28 74 29 0a 20 20 20 20 20 28 6f 72  bda (t).     (or
35f0: 20 28 6e 6f 74 20 28 76 65 63 74 6f 72 3f 20 74   (not (vector? t
3600: 29 29 0a 09 20 28 6e 6f 74 20 28 65 71 75 61 6c  )).. (not (equal
3610: 3f 20 22 43 4f 4d 50 4c 45 54 45 44 22 20 28 64  ? "COMPLETED" (d
3620: 62 3a 74 65 73 74 2d 67 65 74 2d 73 74 61 74 65  b:test-get-state
3630: 20 74 29 29 29 29 29 0a 20 20 20 70 72 65 72 65   t))))).   prere
3640: 71 73 2d 6e 6f 74 2d 6d 65 74 29 29 0a 0a 28 64  qs-not-met))..(d
3650: 65 66 69 6e 65 20 28 72 75 6e 73 3a 70 72 65 74  efine (runs:pret
3660: 74 79 2d 73 74 72 69 6e 67 20 6c 73 74 29 0a 20  ty-string lst). 
3670: 20 28 6d 61 70 20 28 6c 61 6d 62 64 61 20 28 74   (map (lambda (t
3680: 29 0a 09 20 28 69 66 20 28 6e 6f 74 20 28 76 65  ).. (if (not (ve
3690: 63 74 6f 72 3f 20 74 29 29 0a 09 20 20 20 20 20  ctor? t))..     
36a0: 28 63 6f 6e 63 20 74 29 0a 09 20 20 20 20 20 28  (conc t)..     (
36b0: 63 6f 6e 63 20 28 64 62 3a 74 65 73 74 2d 67 65  conc (db:test-ge
36c0: 74 2d 74 65 73 74 6e 61 6d 65 20 74 29 20 22 3a  t-testname t) ":
36d0: 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 73  " (db:test-get-s
36e0: 74 61 74 65 20 74 29 20 22 2f 22 20 28 64 62 3a  tate t) "/" (db:
36f0: 74 65 73 74 2d 67 65 74 2d 73 74 61 74 75 73 20  test-get-status 
3700: 74 29 29 29 29 0a 20 20 20 20 20 20 20 6c 73 74  t)))).       lst
3710: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 72 75 6e  ))..(define (run
3720: 73 3a 6d 61 6b 65 2d 66 75 6c 6c 2d 74 65 73 74  s:make-full-test
3730: 2d 6e 61 6d 65 20 74 65 73 74 6e 61 6d 65 20 69  -name testname i
3740: 74 65 6d 70 61 74 68 29 0a 20 20 28 69 66 20 28  tempath).  (if (
3750: 65 71 75 61 6c 3f 20 69 74 65 6d 70 61 74 68 20  equal? itempath 
3760: 22 22 29 20 74 65 73 74 6e 61 6d 65 20 28 63 6f  "") testname (co
3770: 6e 63 20 74 65 73 74 6e 61 6d 65 20 22 2f 22 20  nc testname "/" 
3780: 69 74 65 6d 70 61 74 68 29 29 29 0a 0a 3b 3b 20  itempath)))..;; 
3790: 74 65 73 74 2d 72 65 63 6f 72 64 73 20 69 73 20  test-records is 
37a0: 61 20 68 61 73 68 20 74 61 62 6c 65 20 74 65 73  a hash table tes
37b0: 74 6e 61 6d 65 3a 69 74 65 6d 5f 70 61 74 68 20  tname:item_path 
37c0: 3d 3e 20 76 65 63 74 6f 72 20 3c 20 74 65 73 74  => vector < test
37d0: 6e 61 6d 65 20 74 65 73 74 63 6f 6e 66 69 67 20  name testconfig 
37e0: 77 61 69 74 6f 6e 73 20 70 72 69 6f 72 69 74 79  waitons priority
37f0: 20 69 74 65 6d 73 2d 69 6e 66 6f 20 2e 2e 2e 20   items-info ... 
3800: 3e 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a  >.(define (runs:
3810: 72 75 6e 2d 74 65 73 74 73 2d 71 75 65 75 65 20  run-tests-queue 
3820: 72 75 6e 2d 69 64 20 72 75 6e 6e 61 6d 65 20 74  run-id runname t
3830: 65 73 74 2d 72 65 63 6f 72 64 73 20 6b 65 79 76  est-records keyv
3840: 61 6c 6c 73 74 20 66 6c 61 67 73 20 74 65 73 74  allst flags test
3850: 2d 70 61 74 74 73 29 0a 20 20 20 20 3b 3b 20 41  -patts).    ;; A
3860: 74 20 74 68 69 73 20 70 6f 69 6e 74 20 74 68 65  t this point the
3870: 20 6c 69 73 74 20 6f 66 20 70 61 72 65 6e 74 20   list of parent 
3880: 74 65 73 74 73 20 69 73 20 65 78 70 61 6e 64 65  tests is expande
3890: 64 20 0a 20 20 20 20 3b 3b 20 4e 42 2f 2f 20 53  d .    ;; NB// S
38a0: 68 6f 75 6c 64 20 65 78 70 61 6e 64 20 69 74 65  hould expand ite
38b0: 6d 73 20 68 65 72 65 20 61 6e 64 20 74 68 65 6e  ms here and then
38c0: 20 69 6e 73 65 72 74 20 69 6e 74 6f 20 74 68 65   insert into the
38d0: 20 72 75 6e 20 71 75 65 75 65 2e 0a 20 20 28 64   run queue..  (d
38e0: 65 62 75 67 3a 70 72 69 6e 74 20 35 20 22 74 65  ebug:print 5 "te
38f0: 73 74 2d 72 65 63 6f 72 64 73 3a 20 22 20 74 65  st-records: " te
3900: 73 74 2d 72 65 63 6f 72 64 73 20 22 2c 20 6b 65  st-records ", ke
3910: 79 76 61 6c 6c 73 74 3a 20 22 20 6b 65 79 76 61  yvallst: " keyva
3920: 6c 6c 73 74 20 22 20 66 6c 61 67 73 3a 20 22 20  llst " flags: " 
3930: 28 68 61 73 68 2d 74 61 62 6c 65 2d 3e 61 6c 69  (hash-table->ali
3940: 73 74 20 66 6c 61 67 73 29 29 0a 20 20 28 6c 65  st flags)).  (le
3950: 74 20 28 28 73 6f 72 74 65 64 2d 74 65 73 74 2d  t ((sorted-test-
3960: 6e 61 6d 65 73 20 28 74 65 73 74 73 3a 73 6f 72  names (tests:sor
3970: 74 2d 62 79 2d 70 72 69 6f 72 69 74 79 2d 61 6e  t-by-priority-an
3980: 64 2d 77 61 69 74 6f 6e 20 74 65 73 74 2d 72 65  d-waiton test-re
3990: 63 6f 72 64 73 29 29 0a 09 28 74 65 73 74 2d 72  cords))..(test-r
39a0: 65 67 69 73 74 65 72 79 20 20 20 20 28 6d 61 6b  egistery    (mak
39b0: 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29 0a 09  e-hash-table))..
39c0: 28 6e 75 6d 2d 72 65 74 72 69 65 73 20 20 20 20  (num-retries    
39d0: 20 20 20 20 30 29 0a 09 28 6d 61 78 2d 72 65 74      0)..(max-ret
39e0: 72 69 65 73 20 20 20 20 20 20 20 28 63 6f 6e 66  ries       (conf
39f0: 69 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69  ig-lookup *confi
3a00: 67 64 61 74 2a 20 22 73 65 74 75 70 22 20 22 6d  gdat* "setup" "m
3a10: 61 78 72 65 74 72 69 65 73 22 29 29 29 0a 20 20  axretries"))).  
3a20: 20 20 28 73 65 74 21 20 6d 61 78 2d 72 65 74 72    (set! max-retr
3a30: 69 65 73 20 28 69 66 20 28 61 6e 64 20 6d 61 78  ies (if (and max
3a40: 2d 72 65 74 72 69 65 73 20 28 73 74 72 69 6e 67  -retries (string
3a50: 2d 3e 6e 75 6d 62 65 72 20 6d 61 78 2d 72 65 74  ->number max-ret
3a60: 72 69 65 73 29 29 28 73 74 72 69 6e 67 2d 3e 6e  ries))(string->n
3a70: 75 6d 62 65 72 20 6d 61 78 2d 72 65 74 72 69 65  umber max-retrie
3a80: 73 29 20 31 30 30 29 29 0a 20 20 20 20 28 69 66  s) 100)).    (if
3a90: 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 73 6f 72   (not (null? sor
3aa0: 74 65 64 2d 74 65 73 74 2d 6e 61 6d 65 73 29 29  ted-test-names))
3ab0: 0a 09 28 6c 65 74 20 6c 6f 6f 70 20 28 28 68 65  ..(let loop ((he
3ac0: 64 20 20 20 20 20 20 20 20 20 28 63 61 72 20 73  d         (car s
3ad0: 6f 72 74 65 64 2d 74 65 73 74 2d 6e 61 6d 65 73  orted-test-names
3ae0: 29 29 0a 09 09 20 20 20 28 74 61 6c 20 20 20 20  ))...   (tal    
3af0: 20 20 20 20 20 28 63 64 72 20 73 6f 72 74 65 64       (cdr sorted
3b00: 2d 74 65 73 74 2d 6e 61 6d 65 73 29 29 0a 09 09  -test-names))...
3b10: 20 20 20 28 72 65 72 75 6e 73 20 20 20 20 20 20     (reruns      
3b20: 27 28 29 29 29 0a 09 20 20 28 69 66 20 28 6e 6f  '()))..  (if (no
3b30: 74 20 28 6e 75 6c 6c 3f 20 72 65 72 75 6e 73 29  t (null? reruns)
3b40: 29 28 64 65 62 75 67 3a 70 72 69 6e 74 2d 69 6e  )(debug:print-in
3b50: 66 6f 20 34 20 22 72 65 72 75 6e 73 3d 22 20 72  fo 4 "reruns=" r
3b60: 65 72 75 6e 73 29 29 0a 09 20 20 3b 3b 20 28 70  eruns))..  ;; (p
3b70: 72 69 6e 74 20 22 54 6f 70 20 6f 66 20 6c 6f 6f  rint "Top of loo
3b80: 70 2c 20 68 65 64 3d 22 20 68 65 64 20 22 2c 20  p, hed=" hed ", 
3b90: 74 61 6c 3d 22 20 74 61 6c 20 22 20 2c 72 65 72  tal=" tal " ,rer
3ba0: 75 6e 73 3d 22 20 72 65 72 75 6e 73 29 0a 09 20  uns=" reruns).. 
3bb0: 20 28 6c 65 74 2a 20 28 28 74 65 73 74 2d 72 65   (let* ((test-re
3bc0: 63 6f 72 64 20 28 68 61 73 68 2d 74 61 62 6c 65  cord (hash-table
3bd0: 2d 72 65 66 20 74 65 73 74 2d 72 65 63 6f 72 64  -ref test-record
3be0: 73 20 68 65 64 29 29 0a 09 09 20 28 74 65 73 74  s hed))... (test
3bf0: 2d 6e 61 6d 65 20 20 20 28 74 65 73 74 73 3a 74  -name   (tests:t
3c00: 65 73 74 71 75 65 75 65 2d 67 65 74 2d 74 65 73  estqueue-get-tes
3c10: 74 6e 61 6d 65 20 74 65 73 74 2d 72 65 63 6f 72  tname test-recor
3c20: 64 29 29 0a 09 09 20 28 74 63 6f 6e 66 69 67 20  d))... (tconfig 
3c30: 20 20 20 20 28 74 65 73 74 73 3a 74 65 73 74 71      (tests:testq
3c40: 75 65 75 65 2d 67 65 74 2d 74 65 73 74 63 6f 6e  ueue-get-testcon
3c50: 66 69 67 20 74 65 73 74 2d 72 65 63 6f 72 64 29  fig test-record)
3c60: 29 0a 09 09 20 28 74 65 73 74 6d 6f 64 65 20 20  )... (testmode  
3c70: 20 20 28 6c 65 74 20 28 28 6d 20 28 63 6f 6e 66    (let ((m (conf
3c80: 69 67 2d 6c 6f 6f 6b 75 70 20 74 63 6f 6e 66 69  ig-lookup tconfi
3c90: 67 20 22 72 65 71 75 69 72 65 6d 65 6e 74 73 22  g "requirements"
3ca0: 20 22 6d 6f 64 65 22 29 29 29 0a 09 09 09 09 28   "mode"))).....(
3cb0: 69 66 20 6d 20 28 73 74 72 69 6e 67 2d 3e 73 79  if m (string->sy
3cc0: 6d 62 6f 6c 20 6d 29 20 27 6e 6f 72 6d 61 6c 29  mbol m) 'normal)
3cd0: 29 29 0a 09 09 20 28 77 61 69 74 6f 6e 73 20 20  ))... (waitons  
3ce0: 20 20 20 28 74 65 73 74 73 3a 74 65 73 74 71 75     (tests:testqu
3cf0: 65 75 65 2d 67 65 74 2d 77 61 69 74 6f 6e 73 20  eue-get-waitons 
3d00: 20 20 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29     test-record))
3d10: 0a 09 09 20 28 70 72 69 6f 72 69 74 79 20 20 20  ... (priority   
3d20: 20 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75   (tests:testqueu
3d30: 65 2d 67 65 74 2d 70 72 69 6f 72 69 74 79 20 20  e-get-priority  
3d40: 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29 0a 09   test-record))..
3d50: 09 20 28 69 74 65 6d 64 61 74 20 20 20 20 20 28  . (itemdat     (
3d60: 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d  tests:testqueue-
3d70: 67 65 74 2d 69 74 65 6d 64 61 74 20 20 20 20 74  get-itemdat    t
3d80: 65 73 74 2d 72 65 63 6f 72 64 29 29 20 3b 3b 20  est-record)) ;; 
3d90: 69 74 65 6d 64 61 74 20 63 61 6e 20 62 65 20 61  itemdat can be a
3da0: 20 73 74 72 69 6e 67 2c 20 6c 69 73 74 20 6f 72   string, list or
3db0: 20 23 66 0a 09 09 20 28 69 74 65 6d 73 20 20 20   #f... (items   
3dc0: 20 20 20 20 28 74 65 73 74 73 3a 74 65 73 74 71      (tests:testq
3dd0: 75 65 75 65 2d 67 65 74 2d 69 74 65 6d 73 20 20  ueue-get-items  
3de0: 20 20 20 20 74 65 73 74 2d 72 65 63 6f 72 64 29      test-record)
3df0: 29 0a 09 09 20 28 69 74 65 6d 2d 70 61 74 68 20  )... (item-path 
3e00: 20 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61    (item-list->pa
3e10: 74 68 20 69 74 65 6d 64 61 74 29 29 0a 09 09 20  th itemdat))... 
3e20: 28 6e 65 77 74 61 6c 20 20 20 20 20 20 28 61 70  (newtal      (ap
3e30: 70 65 6e 64 20 74 61 6c 20 28 6c 69 73 74 20 68  pend tal (list h
3e40: 65 64 29 29 29 29 0a 09 20 20 20 20 0a 09 20 20  ed))))..    ..  
3e50: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 36    (debug:print 6
3e60: 0a 09 09 09 20 22 74 65 73 74 2d 6e 61 6d 65 3a  .... "test-name:
3e70: 20 22 20 74 65 73 74 2d 6e 61 6d 65 0a 09 09 09   " test-name....
3e80: 20 22 5c 6e 20 20 68 65 64 3a 20 20 20 20 20 20   "\n  hed:      
3e90: 20 20 20 22 20 68 65 64 0a 09 09 09 20 22 5c 6e     " hed.... "\n
3ea0: 20 20 69 74 65 6d 64 61 74 3a 20 20 20 20 20 22    itemdat:     "
3eb0: 20 69 74 65 6d 64 61 74 0a 09 09 09 20 22 5c 6e   itemdat.... "\n
3ec0: 20 20 69 74 65 6d 73 3a 20 20 20 20 20 20 20 22    items:       "
3ed0: 20 69 74 65 6d 73 0a 09 09 09 20 22 5c 6e 20 20   items.... "\n  
3ee0: 69 74 65 6d 2d 70 61 74 68 3a 20 20 20 22 20 69  item-path:   " i
3ef0: 74 65 6d 2d 70 61 74 68 0a 09 09 09 20 22 5c 6e  tem-path.... "\n
3f00: 20 20 77 61 69 74 6f 6e 73 3a 20 20 20 20 20 22    waitons:     "
3f10: 20 77 61 69 74 6f 6e 73 0a 09 09 09 20 22 5c 6e   waitons.... "\n
3f20: 20 20 6e 75 6d 2d 72 65 74 72 69 65 73 3a 20 22    num-retries: "
3f30: 20 6e 75 6d 2d 72 65 74 72 69 65 73 0a 09 09 09   num-retries....
3f40: 20 22 5c 6e 20 20 74 61 6c 3a 20 20 20 20 20 20   "\n  tal:      
3f50: 20 20 20 22 20 74 61 6c 0a 09 09 09 20 22 5c 6e     " tal.... "\n
3f60: 20 20 72 65 72 75 6e 73 3a 20 20 20 20 20 20 22    reruns:      "
3f70: 20 72 65 72 75 6e 73 29 0a 0a 09 20 20 20 20 3b   reruns)...    ;
3f80: 3b 20 63 68 65 63 6b 20 66 6f 72 20 68 65 64 20  ; check for hed 
3f90: 69 6e 20 77 61 69 74 6f 6e 73 20 3d 3e 20 74 68  in waitons => th
3fa0: 69 73 20 77 6f 75 6c 64 20 62 65 20 63 69 72 63  is would be circ
3fb0: 75 6c 61 72 2c 20 72 65 6d 6f 76 65 20 69 74 20  ular, remove it 
3fc0: 61 6e 64 20 69 73 73 75 65 20 61 6e 0a 09 20 20  and issue an..  
3fd0: 20 20 3b 3b 20 65 72 72 6f 72 0a 09 20 20 20 20    ;; error..    
3fe0: 28 69 66 20 28 6d 65 6d 62 65 72 20 74 65 73 74  (if (member test
3ff0: 2d 6e 61 6d 65 20 77 61 69 74 6f 6e 73 29 0a 09  -name waitons)..
4000: 09 28 62 65 67 69 6e 0a 09 09 20 20 28 64 65 62  .(begin...  (deb
4010: 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f  ug:print 0 "ERRO
4020: 52 3a 20 74 65 73 74 20 22 20 74 65 73 74 2d 6e  R: test " test-n
4030: 61 6d 65 20 22 20 68 61 73 20 6c 69 73 74 65 64  ame " has listed
4040: 20 69 74 73 65 6c 66 20 61 73 20 61 20 77 61 69   itself as a wai
4050: 74 6f 6e 2c 20 70 6c 65 61 73 65 20 63 6f 72 72  ton, please corr
4060: 65 63 74 20 74 68 69 73 21 22 29 0a 09 09 20 20  ect this!")...  
4070: 28 73 65 74 21 20 77 61 69 74 6f 6e 20 28 66 69  (set! waiton (fi
4080: 6c 74 65 72 20 28 6c 61 6d 62 64 61 20 28 78 29  lter (lambda (x)
4090: 28 6e 6f 74 20 28 65 71 75 61 6c 3f 20 78 20 68  (not (equal? x h
40a0: 65 64 29 29 29 20 77 61 69 74 6f 6e 73 29 29 29  ed))) waitons)))
40b0: 29 0a 0a 09 20 20 20 20 28 63 6f 6e 64 20 3b 3b  )...    (cond ;;
40c0: 20 4f 55 54 45 52 20 43 4f 4e 44 0a 09 20 20 20   OUTER COND..   
40d0: 20 20 28 28 6e 6f 74 20 69 74 65 6d 73 29 20 3b    ((not items) ;
40e0: 3b 20 77 68 65 6e 20 66 61 6c 73 65 20 74 68 65  ; when false the
40f0: 20 74 65 73 74 20 69 73 20 6f 6b 20 74 6f 20 62   test is ok to b
4100: 65 20 68 61 6e 64 65 64 20 6f 66 66 20 74 6f 20  e handed off to 
4110: 6c 61 75 6e 63 68 20 28 62 75 74 20 6e 6f 74 20  launch (but not 
4120: 62 65 66 6f 72 65 29 0a 09 20 20 20 20 20 20 28  before)..      (
4130: 6c 65 74 2a 20 28 28 72 75 6e 2d 6c 69 6d 69 74  let* ((run-limit
4140: 73 2d 69 6e 66 6f 20 20 20 20 20 20 20 20 20 28  s-info         (
4150: 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 72  open-run-close r
4160: 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65  uns:can-run-more
4170: 2d 74 65 73 74 73 20 74 65 73 74 2d 72 65 63 6f  -tests test-reco
4180: 72 64 29 29 20 3b 3b 20 6c 6f 6f 6b 20 61 74 20  rd)) ;; look at 
4190: 74 68 65 20 74 65 73 74 20 6a 6f 62 67 72 6f 75  the test jobgrou
41a0: 70 20 61 6e 64 20 74 6f 74 20 6a 6f 62 73 20 72  p and tot jobs r
41b0: 75 6e 6e 69 6e 67 0a 09 09 20 20 20 20 20 28 68  unning...     (h
41c0: 61 76 65 2d 72 65 73 6f 75 72 63 65 73 20 20 20  ave-resources   
41d0: 20 20 20 20 20 20 20 28 63 61 72 20 72 75 6e 2d         (car run-
41e0: 6c 69 6d 69 74 73 2d 69 6e 66 6f 29 29 0a 09 09  limits-info))...
41f0: 20 20 20 20 20 28 6e 75 6d 2d 72 75 6e 6e 69 6e       (num-runnin
4200: 67 20 20 20 20 20 20 20 20 20 20 20 20 20 28 6c  g             (l
4210: 69 73 74 2d 72 65 66 20 72 75 6e 2d 6c 69 6d 69  ist-ref run-limi
4220: 74 73 2d 69 6e 66 6f 20 31 29 29 0a 09 09 20 20  ts-info 1))...  
4230: 20 20 20 28 6e 75 6d 2d 72 75 6e 6e 69 6e 67 2d     (num-running-
4240: 69 6e 2d 6a 6f 62 67 72 6f 75 70 20 28 6c 69 73  in-jobgroup (lis
4250: 74 2d 72 65 66 20 72 75 6e 2d 6c 69 6d 69 74 73  t-ref run-limits
4260: 2d 69 6e 66 6f 20 32 29 29 0a 09 09 20 20 20 20  -info 2))...    
4270: 20 28 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74   (max-concurrent
4280: 2d 6a 6f 62 73 20 20 20 20 20 28 6c 69 73 74 2d  -jobs     (list-
4290: 72 65 66 20 72 75 6e 2d 6c 69 6d 69 74 73 2d 69  ref run-limits-i
42a0: 6e 66 6f 20 33 29 29 0a 09 09 20 20 20 20 20 28  nfo 3))...     (
42b0: 6a 6f 62 2d 67 72 6f 75 70 2d 6c 69 6d 69 74 20  job-group-limit 
42c0: 20 20 20 20 20 20 20 20 28 6c 69 73 74 2d 72 65          (list-re
42d0: 66 20 72 75 6e 2d 6c 69 6d 69 74 73 2d 69 6e 66  f run-limits-inf
42e0: 6f 20 34 29 29 0a 09 09 20 20 20 20 20 28 70 72  o 4))...     (pr
42f0: 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 20 20 20  ereqs-not-met   
4300: 20 20 20 20 20 20 28 6f 70 65 6e 2d 72 75 6e 2d        (open-run-
4310: 63 6c 6f 73 65 20 64 62 3a 67 65 74 2d 70 72 65  close db:get-pre
4320: 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 20 23 66 20  reqs-not-met #f 
4330: 72 75 6e 2d 69 64 20 77 61 69 74 6f 6e 73 20 69  run-id waitons i
4340: 74 65 6d 2d 70 61 74 68 20 6d 6f 64 65 3a 20 74  tem-path mode: t
4350: 65 73 74 6d 6f 64 65 29 29 0a 09 09 20 20 20 20  estmode))...    
4360: 20 28 66 61 69 6c 73 20 20 20 20 20 20 20 20 20   (fails         
4370: 20 20 20 20 20 20 20 20 20 20 28 72 75 6e 73 3a            (runs:
4380: 63 61 6c 63 2d 66 61 69 6c 73 20 70 72 65 72 65  calc-fails prere
4390: 71 73 2d 6e 6f 74 2d 6d 65 74 29 29 0a 09 09 20  qs-not-met))... 
43a0: 20 20 20 20 28 6e 6f 6e 2d 63 6f 6d 70 6c 65 74      (non-complet
43b0: 65 64 20 20 20 20 20 20 20 20 20 20 20 28 72 75  ed           (ru
43c0: 6e 73 3a 63 61 6c 63 2d 6e 6f 74 2d 63 6f 6d 70  ns:calc-not-comp
43d0: 6c 65 74 65 64 20 70 72 65 72 65 71 73 2d 6e 6f  leted prereqs-no
43e0: 74 2d 6d 65 74 29 29 29 0a 09 09 28 64 65 62 75  t-met)))...(debu
43f0: 67 3a 70 72 69 6e 74 2d 69 6e 66 6f 20 38 20 22  g:print-info 8 "
4400: 68 61 76 65 2d 72 65 73 6f 75 72 63 65 73 3a 20  have-resources: 
4410: 22 20 68 61 76 65 2d 72 65 73 6f 75 72 63 65 73  " have-resources
4420: 20 22 20 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d   " prereqs-not-m
4430: 65 74 3a 20 22 20 0a 09 09 09 20 20 20 20 20 28  et: " ....     (
4440: 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72  string-intersper
4450: 73 65 20 0a 09 09 09 20 20 20 20 20 20 28 6d 61  se ....      (ma
4460: 70 20 28 6c 61 6d 62 64 61 20 28 74 29 0a 09 09  p (lambda (t)...
4470: 09 09 20 20 20 20 20 28 69 66 20 28 76 65 63 74  ..     (if (vect
4480: 6f 72 3f 20 74 29 0a 09 09 09 09 09 20 28 63 6f  or? t)...... (co
4490: 6e 63 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  nc (db:test-get-
44a0: 73 74 61 74 65 20 74 29 20 22 2f 22 20 28 64 62  state t) "/" (db
44b0: 3a 74 65 73 74 2d 67 65 74 2d 73 74 61 74 75 73  :test-get-status
44c0: 20 74 29 29 0a 09 09 09 09 09 20 28 63 6f 6e 63   t))...... (conc
44d0: 20 22 20 57 41 52 4e 49 4e 47 3a 20 74 20 69 73   " WARNING: t is
44e0: 20 6e 6f 74 20 61 20 76 65 63 74 6f 72 3d 22 20   not a vector=" 
44f0: 74 20 29 29 29 0a 09 09 09 09 20 20 20 70 72 65  t ))).....   pre
4500: 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 29 20 22 2c  reqs-not-met) ",
4510: 20 22 29 20 22 20 66 61 69 6c 73 3a 20 22 20 66   ") " fails: " f
4520: 61 69 6c 73 29 0a 09 09 28 64 65 62 75 67 3a 70  ails)...(debug:p
4530: 72 69 6e 74 2d 69 6e 66 6f 20 34 20 22 68 65 64  rint-info 4 "hed
4540: 3d 22 20 68 65 64 20 22 5c 6e 20 20 74 65 73 74  =" hed "\n  test
4550: 2d 72 65 63 6f 72 64 3d 22 20 74 65 73 74 2d 72  -record=" test-r
4560: 65 63 6f 72 64 20 22 5c 6e 20 20 74 65 73 74 2d  ecord "\n  test-
4570: 6e 61 6d 65 3a 20 22 20 74 65 73 74 2d 6e 61 6d  name: " test-nam
4580: 65 20 22 5c 6e 20 20 69 74 65 6d 2d 70 61 74 68  e "\n  item-path
4590: 3a 20 22 20 69 74 65 6d 2d 70 61 74 68 20 22 5c  : " item-path "\
45a0: 6e 20 20 74 65 73 74 2d 70 61 74 74 73 3a 20 22  n  test-patts: "
45b0: 20 74 65 73 74 2d 70 61 74 74 73 29 0a 0a 09 09   test-patts)....
45c0: 3b 3b 20 44 6f 6e 27 74 20 6b 6e 6f 77 20 61 74  ;; Don't know at
45d0: 20 74 68 69 73 20 74 69 6d 65 20 69 66 20 74 68   this time if th
45e0: 65 20 74 65 73 74 20 68 61 76 65 20 62 65 65 6e  e test have been
45f0: 20 6c 61 75 6e 63 68 65 64 20 61 74 20 73 6f 6d   launched at som
4600: 65 20 74 69 6d 65 20 69 6e 20 74 68 65 20 70 61  e time in the pa
4610: 73 74 0a 09 09 3b 3b 20 69 2e 65 2e 20 69 73 20  st...;; i.e. is 
4620: 74 68 69 73 20 61 20 72 65 2d 6c 61 75 6e 63 68  this a re-launch
4630: 3f 0a 09 09 28 64 65 62 75 67 3a 70 72 69 6e 74  ?...(debug:print
4640: 2d 69 6e 66 6f 20 34 20 22 72 75 6e 2d 6c 69 6d  -info 4 "run-lim
4650: 69 74 73 2d 69 6e 66 6f 20 3d 20 22 20 72 75 6e  its-info = " run
4660: 2d 6c 69 6d 69 74 73 2d 69 6e 66 6f 29 0a 09 09  -limits-info)...
4670: 28 63 6f 6e 64 20 3b 3b 20 49 4e 4e 45 52 20 43  (cond ;; INNER C
4680: 4f 4e 44 20 23 31 20 66 6f 72 20 61 20 6c 61 75  OND #1 for a lau
4690: 6e 63 68 61 62 6c 65 20 74 65 73 74 0a 09 09 20  nchable test... 
46a0: 3b 3b 20 43 68 65 63 6b 20 69 74 65 6d 20 70 61  ;; Check item pa
46b0: 74 68 20 61 67 61 69 6e 73 74 20 69 74 65 6d 2d  th against item-
46c0: 70 61 74 74 73 0a 09 09 20 28 28 6e 6f 74 20 28  patts... ((not (
46d0: 74 65 73 74 73 3a 6d 61 74 63 68 20 74 65 73 74  tests:match test
46e0: 2d 70 61 74 74 73 20 28 74 65 73 74 73 3a 74 65  -patts (tests:te
46f0: 73 74 71 75 65 75 65 2d 67 65 74 2d 74 65 73 74  stqueue-get-test
4700: 6e 61 6d 65 20 74 65 73 74 2d 72 65 63 6f 72 64  name test-record
4710: 29 20 69 74 65 6d 2d 70 61 74 68 29 29 20 3b 3b  ) item-path)) ;;
4720: 20 54 68 69 73 20 74 65 73 74 2f 69 74 65 6d 70   This test/itemp
4730: 61 74 68 20 69 73 20 6e 6f 74 20 74 6f 20 62 65  ath is not to be
4740: 20 72 75 6e 0a 09 09 20 20 3b 3b 20 65 6c 73 65   run...  ;; else
4750: 20 74 68 65 20 72 75 6e 20 69 73 20 73 74 75 63   the run is stuc
4760: 6b 2c 20 74 65 6d 70 6f 72 61 72 69 6c 79 20 6f  k, temporarily o
4770: 72 20 70 65 72 6d 61 6e 65 6e 74 6c 79 0a 09 09  r permanently...
4780: 20 20 3b 3b 20 62 75 74 20 73 68 6f 75 6c 64 20    ;; but should 
4790: 63 68 65 63 6b 20 69 66 20 69 74 20 69 73 20 64  check if it is d
47a0: 75 65 20 74 6f 20 6c 61 63 6b 20 6f 66 20 72 65  ue to lack of re
47b0: 73 6f 75 72 63 65 73 20 76 73 2e 20 70 72 65 72  sources vs. prer
47c0: 65 71 75 69 73 69 74 65 73 0a 09 09 20 20 28 64  equisites...  (d
47d0: 65 62 75 67 3a 70 72 69 6e 74 2d 69 6e 66 6f 20  ebug:print-info 
47e0: 31 20 22 53 6b 69 70 70 69 6e 67 20 22 20 28 74  1 "Skipping " (t
47f0: 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67  ests:testqueue-g
4800: 65 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74  et-testname test
4810: 2d 72 65 63 6f 72 64 29 20 22 20 22 20 69 74 65  -record) " " ite
4820: 6d 2d 70 61 74 68 20 22 20 61 73 20 69 74 20 64  m-path " as it d
4830: 6f 65 73 6e 27 74 20 6d 61 74 63 68 20 22 20 74  oesn't match " t
4840: 65 73 74 2d 70 61 74 74 73 29 0a 09 09 20 20 28  est-patts)...  (
4850: 74 68 72 65 61 64 2d 73 6c 65 65 70 21 20 2a 67  thread-sleep! *g
4860: 6c 6f 62 61 6c 2d 64 65 6c 74 61 2a 29 0a 09 09  lobal-delta*)...
4870: 20 20 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c    (if (not (null
4880: 3f 20 74 61 6c 29 29 0a 09 09 20 20 20 20 20 20  ? tal))...      
4890: 28 6c 6f 6f 70 20 28 63 61 72 20 74 61 6c 29 28  (loop (car tal)(
48a0: 63 64 72 20 74 61 6c 29 20 72 65 72 75 6e 73 29  cdr tal) reruns)
48b0: 29 29 0a 09 09 20 28 20 3b 3b 20 28 61 6e 64 0a  ))... ( ;; (and.
48c0: 09 09 20 20 28 6e 6f 74 20 28 68 61 73 68 2d 74  ..  (not (hash-t
48d0: 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74  able-ref/default
48e0: 20 74 65 73 74 2d 72 65 67 69 73 74 65 72 79 20   test-registery 
48f0: 28 72 75 6e 73 3a 6d 61 6b 65 2d 66 75 6c 6c 2d  (runs:make-full-
4900: 74 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 2d 6e  test-name test-n
4910: 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 20 23  ame item-path) #
4920: 66 29 29 0a 09 09 20 20 20 20 20 20 3b 3b 20 28  f))...      ;; (
4930: 61 6e 64 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65  and max-concurre
4940: 6e 74 2d 6a 6f 62 73 20 28 3e 20 28 2d 20 6d 61  nt-jobs (> (- ma
4950: 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62  x-concurrent-job
4960: 73 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67 29 20 35  s num-running) 5
4970: 29 29 29 0a 09 09 20 20 28 64 65 62 75 67 3a 70  )))...  (debug:p
4980: 72 69 6e 74 2d 69 6e 66 6f 20 34 20 22 50 72 65  rint-info 4 "Pre
4990: 2d 72 65 67 69 73 74 65 72 69 6e 67 20 74 65 73  -registering tes
49a0: 74 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 2f  t " test-name "/
49b0: 22 20 69 74 65 6d 2d 70 61 74 68 20 22 20 74 6f  " item-path " to
49c0: 20 63 72 65 61 74 65 20 70 6c 61 63 65 68 6f 6c   create placehol
49d0: 64 65 72 22 20 29 0a 09 09 20 20 28 6f 70 65 6e  der" )...  (open
49e0: 2d 72 75 6e 2d 63 6c 6f 73 65 20 64 62 3a 74 65  -run-close db:te
49f0: 73 74 73 2d 72 65 67 69 73 74 65 72 2d 74 65 73  sts-register-tes
4a00: 74 20 23 66 20 72 75 6e 2d 69 64 20 74 65 73 74  t #f run-id test
4a10: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  -name item-path)
4a20: 0a 09 09 20 20 28 68 61 73 68 2d 74 61 62 6c 65  ...  (hash-table
4a30: 2d 73 65 74 21 20 74 65 73 74 2d 72 65 67 69 73  -set! test-regis
4a40: 74 65 72 79 20 28 72 75 6e 73 3a 6d 61 6b 65 2d  tery (runs:make-
4a50: 66 75 6c 6c 2d 74 65 73 74 2d 6e 61 6d 65 20 74  full-test-name t
4a60: 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61  est-name item-pa
4a70: 74 68 29 20 23 74 29 0a 09 09 20 20 28 74 68 72  th) #t)...  (thr
4a80: 65 61 64 2d 73 6c 65 65 70 21 20 2a 67 6c 6f 62  ead-sleep! *glob
4a90: 61 6c 2d 64 65 6c 74 61 2a 29 0a 09 09 20 20 28  al-delta*)...  (
4aa0: 6c 6f 6f 70 20 28 63 61 72 20 6e 65 77 74 61 6c  loop (car newtal
4ab0: 29 28 63 64 72 20 6e 65 77 74 61 6c 29 20 72 65  )(cdr newtal) re
4ac0: 72 75 6e 73 29 29 0a 09 09 20 28 28 6e 6f 74 20  runs))... ((not 
4ad0: 68 61 76 65 2d 72 65 73 6f 75 72 63 65 73 29 20  have-resources) 
4ae0: 3b 3b 20 73 69 6d 70 6c 79 20 74 72 79 20 61 67  ;; simply try ag
4af0: 61 69 6e 20 61 66 74 65 72 20 77 61 69 74 69 6e  ain after waitin
4b00: 67 20 61 20 73 65 63 6f 6e 64 0a 09 09 20 20 28  g a second...  (
4b10: 64 65 62 75 67 3a 70 72 69 6e 74 2d 69 6e 66 6f  debug:print-info
4b20: 20 31 20 22 6e 6f 20 72 65 73 6f 75 72 63 65 73   1 "no resources
4b30: 20 74 6f 20 72 75 6e 20 6e 65 77 20 74 65 73 74   to run new test
4b40: 73 2c 20 77 61 69 74 69 6e 67 20 2e 2e 2e 22 29  s, waiting ...")
4b50: 0a 09 09 20 20 28 74 68 72 65 61 64 2d 73 6c 65  ...  (thread-sle
4b60: 65 70 21 20 28 2b 20 32 20 2a 67 6c 6f 62 61 6c  ep! (+ 2 *global
4b70: 2d 64 65 6c 74 61 2a 29 29 0a 09 09 20 20 3b 3b  -delta*))...  ;;
4b80: 20 63 6f 75 6c 64 20 68 61 76 65 20 64 6f 6e 65   could have done
4b90: 20 68 65 64 20 74 61 6c 20 68 65 72 65 20 62 75   hed tal here bu
4ba0: 74 20 64 6f 69 6e 67 20 63 61 72 2f 63 64 72 20  t doing car/cdr 
4bb0: 6f 66 20 6e 65 77 74 61 6c 20 74 6f 20 72 6f 74  of newtal to rot
4bc0: 61 74 65 20 74 65 73 74 73 0a 09 09 20 20 28 6c  ate tests...  (l
4bd0: 6f 6f 70 20 28 63 61 72 20 6e 65 77 74 61 6c 29  oop (car newtal)
4be0: 28 63 64 72 20 6e 65 77 74 61 6c 29 20 72 65 72  (cdr newtal) rer
4bf0: 75 6e 73 29 29 0a 09 09 20 28 28 61 6e 64 20 68  uns))... ((and h
4c00: 61 76 65 2d 72 65 73 6f 75 72 63 65 73 0a 09 09  ave-resources...
4c10: 20 20 20 20 20 20 20 28 6f 72 20 28 6e 75 6c 6c         (or (null
4c20: 3f 20 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65  ? prereqs-not-me
4c30: 74 29 0a 09 09 09 20 20 20 28 61 6e 64 20 28 65  t)....   (and (e
4c40: 71 3f 20 74 65 73 74 6d 6f 64 65 20 27 74 6f 70  q? testmode 'top
4c50: 6c 65 76 65 6c 29 0a 09 09 09 09 28 6e 75 6c 6c  level).....(null
4c60: 3f 20 6e 6f 6e 2d 63 6f 6d 70 6c 65 74 65 64 29  ? non-completed)
4c70: 29 29 29 0a 09 09 20 20 28 72 75 6e 3a 74 65 73  )))...  (run:tes
4c80: 74 20 72 75 6e 2d 69 64 20 72 75 6e 6e 61 6d 65  t run-id runname
4c90: 20 6b 65 79 76 61 6c 6c 73 74 20 74 65 73 74 2d   keyvallst test-
4ca0: 72 65 63 6f 72 64 20 66 6c 61 67 73 20 23 66 29  record flags #f)
4cb0: 0a 09 09 20 20 28 74 68 72 65 61 64 2d 73 6c 65  ...  (thread-sle
4cc0: 65 70 21 20 2a 67 6c 6f 62 61 6c 2d 64 65 6c 74  ep! *global-delt
4cd0: 61 2a 29 0a 09 09 20 20 28 69 66 20 28 6e 6f 74  a*)...  (if (not
4ce0: 20 28 6e 75 6c 6c 3f 20 74 61 6c 29 29 0a 09 09   (null? tal))...
4cf0: 20 20 20 20 20 20 28 6c 6f 6f 70 20 28 63 61 72        (loop (car
4d00: 20 74 61 6c 29 28 63 64 72 20 74 61 6c 29 20 72   tal)(cdr tal) r
4d10: 65 72 75 6e 73 29 29 29 0a 09 09 20 28 65 6c 73  eruns)))... (els
4d20: 65 20 3b 3b 20 6d 75 73 74 20 62 65 20 77 65 20  e ;; must be we 
4d30: 68 61 76 65 20 75 6e 6d 65 74 20 70 72 65 72 65  have unmet prere
4d40: 71 75 69 73 69 74 65 73 0a 09 09 20 20 20 20 28  quisites...    (
4d50: 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 46  debug:print 4 "F
4d60: 41 49 4c 53 3a 20 22 20 66 61 69 6c 73 29 0a 09  AILS: " fails)..
4d70: 09 20 20 20 20 3b 3b 20 49 66 20 6f 6e 65 20 6f  .    ;; If one o
4d80: 72 20 6d 6f 72 65 20 6f 66 20 74 68 65 20 70 72  r more of the pr
4d90: 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 20 61 72  ereqs-not-met ar
4da0: 65 20 46 41 49 4c 20 74 68 65 6e 20 77 65 20 63  e FAIL then we c
4db0: 61 6e 20 69 73 73 75 65 0a 09 09 20 20 20 20 3b  an issue...    ;
4dc0: 3b 20 61 20 6d 65 73 73 61 67 65 20 61 6e 64 20  ; a message and 
4dd0: 64 72 6f 70 20 68 65 64 20 66 72 6f 6d 20 74 68  drop hed from th
4de0: 65 20 69 74 65 6d 73 20 74 6f 20 62 65 20 70 72  e items to be pr
4df0: 6f 63 65 73 73 65 64 2e 0a 09 09 20 20 20 20 28  ocessed....    (
4e00: 69 66 20 28 6e 75 6c 6c 3f 20 66 61 69 6c 73 29  if (null? fails)
4e10: 0a 09 09 09 28 62 65 67 69 6e 0a 09 09 09 20 20  ....(begin....  
4e20: 3b 3b 20 63 6f 75 6c 64 6e 27 74 20 72 75 6e 2c  ;; couldn't run,
4e30: 20 74 61 6b 65 20 61 20 62 72 65 61 74 68 65 72   take a breather
4e40: 0a 09 09 09 20 20 28 64 65 62 75 67 3a 70 72 69  ....  (debug:pri
4e50: 6e 74 2d 69 6e 66 6f 20 34 20 22 53 68 6f 75 6c  nt-info 4 "Shoul
4e60: 64 6e 27 74 20 72 65 61 6c 6c 79 20 67 65 74 20  dn't really get 
4e70: 68 65 72 65 2c 20 72 61 63 65 20 63 6f 6e 64 69  here, race condi
4e80: 74 69 6f 6e 3f 20 55 6e 61 62 6c 65 20 74 6f 20  tion? Unable to 
4e90: 6c 61 75 6e 63 68 20 6d 6f 72 65 20 74 65 73 74  launch more test
4ea0: 73 20 61 74 20 74 68 69 73 20 6d 6f 6d 65 6e 74  s at this moment
4eb0: 2c 20 6b 69 6c 6c 69 6e 67 20 74 69 6d 65 20 2e  , killing time .
4ec0: 2e 2e 22 29 0a 09 09 09 20 20 28 74 68 72 65 61  ..")....  (threa
4ed0: 64 2d 73 6c 65 65 70 21 20 28 2b 20 30 2e 30 31  d-sleep! (+ 0.01
4ee0: 20 2a 67 6c 6f 62 61 6c 2d 64 65 6c 74 61 2a 29   *global-delta*)
4ef0: 29 20 3b 3b 20 6c 6f 6e 67 20 73 6c 65 65 70 20  ) ;; long sleep 
4f00: 68 65 72 65 20 2d 20 6e 6f 20 72 65 73 6f 75 72  here - no resour
4f10: 63 65 73 2c 20 6d 61 79 20 61 73 20 77 65 6c 6c  ces, may as well
4f20: 20 62 65 20 70 61 74 69 65 6e 74 0a 09 09 09 20   be patient.... 
4f30: 20 3b 3b 20 77 65 20 6d 61 64 65 20 6e 65 77 20   ;; we made new 
4f40: 74 61 6c 20 62 79 20 73 74 69 63 6b 69 6e 67 20  tal by sticking 
4f50: 68 65 64 20 61 74 20 74 68 65 20 62 61 63 6b 20  hed at the back 
4f60: 6f 66 20 74 68 65 20 6c 69 73 74 0a 09 09 09 20  of the list.... 
4f70: 20 28 6c 6f 6f 70 20 28 63 61 72 20 6e 65 77 74   (loop (car newt
4f80: 61 6c 29 28 63 64 72 20 6e 65 77 74 61 6c 29 20  al)(cdr newtal) 
4f90: 72 65 72 75 6e 73 29 29 0a 09 09 09 3b 3b 20 74  reruns))....;; t
4fa0: 68 65 20 77 61 69 74 6f 6e 20 69 73 20 46 41 49  he waiton is FAI
4fb0: 4c 20 73 6f 20 6e 6f 20 70 6f 69 6e 74 20 69 6e  L so no point in
4fc0: 20 74 72 79 69 6e 67 20 74 6f 20 72 75 6e 20 68   trying to run h
4fd0: 65 64 20 65 76 65 72 20 61 67 61 69 6e 0a 09 09  ed ever again...
4fe0: 09 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f  .(if (not (null?
4ff0: 20 74 61 6c 29 29 0a 09 09 09 20 20 20 20 28 69   tal))....    (i
5000: 66 20 28 76 65 63 74 6f 72 3f 20 68 65 64 29 0a  f (vector? hed).
5010: 09 09 09 09 28 62 65 67 69 6e 20 28 64 65 62 75  ....(begin (debu
5020: 67 3a 70 72 69 6e 74 20 31 20 22 57 41 52 4e 3a  g:print 1 "WARN:
5030: 20 44 72 6f 70 70 69 6e 67 20 74 65 73 74 20 22   Dropping test "
5040: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 74 65   (db:test-get-te
5050: 73 74 6e 61 6d 65 20 68 65 64 29 20 22 2f 22 20  stname hed) "/" 
5060: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65  (db:test-get-ite
5070: 6d 2d 70 61 74 68 20 68 65 64 29 0a 09 09 09 09  m-path hed).....
5080: 09 09 20 20 20 20 22 20 66 72 6f 6d 20 74 68 65  ..    " from the
5090: 20 6c 61 75 6e 63 68 20 6c 69 73 74 20 61 73 20   launch list as 
50a0: 69 74 20 68 61 73 20 70 72 65 72 65 71 75 69 73  it has prerequis
50b0: 74 65 73 20 74 68 61 74 20 61 72 65 20 46 41 49  tes that are FAI
50c0: 4c 22 29 0a 09 09 09 09 20 20 20 20 20 20 20 28  L").....       (
50d0: 74 68 72 65 61 64 2d 73 6c 65 65 70 21 20 2a 67  thread-sleep! *g
50e0: 6c 6f 62 61 6c 2d 64 65 6c 74 61 2a 29 0a 09 09  lobal-delta*)...
50f0: 09 09 20 20 20 20 20 20 20 28 6c 6f 6f 70 20 28  ..       (loop (
5100: 63 61 72 20 74 61 6c 29 28 63 64 72 20 74 61 6c  car tal)(cdr tal
5110: 29 20 28 63 6f 6e 73 20 68 65 64 20 72 65 72 75  ) (cons hed reru
5120: 6e 73 29 29 29 0a 09 09 09 09 28 62 65 67 69 6e  ns))).....(begin
5130: 0a 09 09 09 09 20 20 28 64 65 62 75 67 3a 70 72  .....  (debug:pr
5140: 69 6e 74 20 31 20 22 57 41 52 4e 3a 20 54 65 73  int 1 "WARN: Tes
5150: 74 20 6e 6f 74 20 70 72 6f 63 65 73 73 65 64 20  t not processed 
5160: 63 6f 72 72 65 63 74 6c 79 2e 20 43 6f 75 6c 64  correctly. Could
5170: 20 62 65 20 61 20 72 61 63 65 20 63 6f 6e 64 69   be a race condi
5180: 74 69 6f 6e 20 69 6e 20 79 6f 75 72 20 74 65 73  tion in your tes
5190: 74 20 69 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e  t implementation
51a0: 3f 20 22 20 68 65 64 29 20 3b 3b 20 20 22 20 61  ? " hed) ;;  " a
51b0: 73 20 69 74 20 68 61 73 20 70 72 65 72 65 71 75  s it has prerequ
51c0: 69 73 74 65 73 20 74 68 61 74 20 61 72 65 20 46  istes that are F
51d0: 41 49 4c 2e 20 28 4e 4f 54 45 3a 20 68 65 64 20  AIL. (NOTE: hed 
51e0: 69 73 20 6e 6f 74 20 61 20 76 65 63 74 6f 72 29  is not a vector)
51f0: 22 29 0a 09 09 09 09 20 20 28 74 68 72 65 61 64  ").....  (thread
5200: 2d 73 6c 65 65 70 21 20 28 2b 20 30 2e 30 31 20  -sleep! (+ 0.01 
5210: 2a 67 6c 6f 62 61 6c 2d 64 65 6c 74 61 2a 29 29  *global-delta*))
5220: 0a 09 09 09 09 20 20 28 6c 6f 6f 70 20 68 65 64  .....  (loop hed
5230: 20 74 61 6c 20 72 65 72 75 6e 73 29 29 29 29 29   tal reruns)))))
5240: 29 29 29 29 20 3b 3b 20 45 4e 44 20 4f 46 20 49  )))) ;; END OF I
5250: 4e 4e 45 52 20 43 4f 4e 44 0a 09 20 20 20 20 20  NNER COND..     
5260: 0a 09 20 20 20 20 20 3b 3b 20 63 61 73 65 20 77  ..     ;; case w
5270: 68 65 72 65 20 61 6e 20 69 74 65 6d 73 20 63 61  here an items ca
5280: 6d 65 20 69 6e 20 61 73 20 61 20 6c 69 73 74 20  me in as a list 
5290: 62 65 65 6e 20 70 72 6f 63 65 73 73 65 64 0a 09  been processed..
52a0: 20 20 20 20 20 28 28 61 6e 64 20 28 6c 69 73 74       ((and (list
52b0: 3f 20 69 74 65 6d 73 29 20 20 20 20 20 3b 3b 20  ? items)     ;; 
52c0: 74 68 75 73 20 77 65 20 6b 6e 6f 77 20 6f 75 72  thus we know our
52d0: 20 69 74 65 6d 73 20 61 72 65 20 61 6c 72 65 61   items are alrea
52e0: 64 79 20 63 61 6c 63 75 6c 61 74 65 64 0a 09 09  dy calculated...
52f0: 20 20 20 28 6e 6f 74 20 20 20 69 74 65 6d 64 61     (not   itemda
5300: 74 29 29 20 3b 3b 20 61 6e 64 20 6e 6f 74 20 79  t)) ;; and not y
5310: 65 74 20 65 78 70 61 6e 64 65 64 20 69 6e 74 6f  et expanded into
5320: 20 74 68 65 20 6c 69 73 74 20 6f 66 20 74 68 69   the list of thi
5330: 6e 67 73 20 74 6f 20 62 65 20 64 6f 6e 65 0a 09  ngs to be done..
5340: 20 20 20 20 20 20 28 69 66 20 28 61 6e 64 20 28        (if (and (
5350: 64 65 62 75 67 3a 64 65 62 75 67 2d 6d 6f 64 65  debug:debug-mode
5360: 20 31 29 20 3b 3b 20 28 3e 3d 20 2a 76 65 72 62   1) ;; (>= *verb
5370: 6f 73 69 74 79 2a 20 31 29 0a 09 09 20 20 20 20  osity* 1)...    
5380: 20 20 20 28 3e 20 28 6c 65 6e 67 74 68 20 69 74     (> (length it
5390: 65 6d 73 29 20 30 29 0a 09 09 20 20 20 20 20 20  ems) 0)...      
53a0: 20 28 3e 20 28 6c 65 6e 67 74 68 20 28 63 61 72   (> (length (car
53b0: 20 69 74 65 6d 73 29 29 20 30 29 29 0a 09 09 20   items)) 0))... 
53c0: 20 28 70 70 20 69 74 65 6d 73 29 29 0a 09 20 20   (pp items))..  
53d0: 20 20 20 20 28 66 6f 72 2d 65 61 63 68 0a 09 20      (for-each.. 
53e0: 20 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 6d        (lambda (m
53f0: 79 2d 69 74 65 6d 64 61 74 29 0a 09 09 20 28 6c  y-itemdat)... (l
5400: 65 74 2a 20 28 28 6e 65 77 2d 74 65 73 74 2d 72  et* ((new-test-r
5410: 65 63 6f 72 64 20 28 6c 65 74 20 28 28 6e 65 77  ecord (let ((new
5420: 72 65 63 20 28 6d 61 6b 65 2d 74 65 73 74 73 3a  rec (make-tests:
5430: 74 65 73 74 71 75 65 75 65 29 29 29 0a 09 09 09  testqueue)))....
5440: 09 09 20 20 20 28 76 65 63 74 6f 72 2d 63 6f 70  ..   (vector-cop
5450: 79 21 20 74 65 73 74 2d 72 65 63 6f 72 64 20 6e  y! test-record n
5460: 65 77 72 65 63 29 0a 09 09 09 09 09 20 20 20 6e  ewrec)......   n
5470: 65 77 72 65 63 29 29 0a 09 09 09 28 6d 79 2d 69  ewrec))....(my-i
5480: 74 65 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c  tem-path (item-l
5490: 69 73 74 2d 3e 70 61 74 68 20 6d 79 2d 69 74 65  ist->path my-ite
54a0: 6d 64 61 74 29 29 29 0a 09 09 20 20 20 28 69 66  mdat)))...   (if
54b0: 20 28 74 65 73 74 73 3a 6d 61 74 63 68 20 74 65   (tests:match te
54c0: 73 74 2d 70 61 74 74 73 20 68 65 64 20 6d 79 2d  st-patts hed my-
54d0: 69 74 65 6d 2d 70 61 74 68 29 20 3b 3b 20 28 70  item-path) ;; (p
54e0: 61 74 74 2d 6c 69 73 74 2d 6d 61 74 63 68 20 6d  att-list-match m
54f0: 79 2d 69 74 65 6d 2d 70 61 74 68 20 69 74 65 6d  y-item-path item
5500: 2d 70 61 74 74 73 29 20 20 20 20 20 20 20 20 20  -patts)         
5510: 20 20 3b 3b 20 79 65 73 2c 20 77 65 20 77 61 6e    ;; yes, we wan
5520: 74 20 74 6f 20 70 72 6f 63 65 73 73 20 74 68 69  t to process thi
5530: 73 20 69 74 65 6d 2c 20 4e 4f 54 45 3a 20 53 68  s item, NOTE: Sh
5540: 6f 75 6c 64 20 6e 6f 74 20 6e 65 65 64 20 74 68  ould not need th
5550: 69 73 20 63 68 65 63 6b 20 68 65 72 65 21 0a 09  is check here!..
5560: 09 20 20 20 20 20 20 20 28 6c 65 74 20 28 28 6e  .       (let ((n
5570: 65 77 74 65 73 74 6e 61 6d 65 20 28 72 75 6e 73  ewtestname (runs
5580: 3a 6d 61 6b 65 2d 66 75 6c 6c 2d 74 65 73 74 2d  :make-full-test-
5590: 6e 61 6d 65 20 68 65 64 20 6d 79 2d 69 74 65 6d  name hed my-item
55a0: 2d 70 61 74 68 29 29 29 20 20 20 20 3b 3b 20 74  -path)))    ;; t
55b0: 65 73 74 20 6e 61 6d 65 73 20 61 72 65 20 75 6e  est names are un
55c0: 69 71 75 65 20 6f 6e 20 74 65 73 74 6e 61 6d 65  ique on testname
55d0: 2f 69 74 65 6d 2d 70 61 74 68 0a 09 09 09 20 28  /item-path.... (
55e0: 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d  tests:testqueue-
55f0: 73 65 74 2d 69 74 65 6d 73 21 20 20 20 20 20 6e  set-items!     n
5600: 65 77 2d 74 65 73 74 2d 72 65 63 6f 72 64 20 23  ew-test-record #
5610: 66 29 0a 09 09 09 20 28 74 65 73 74 73 3a 74 65  f).... (tests:te
5620: 73 74 71 75 65 75 65 2d 73 65 74 2d 69 74 65 6d  stqueue-set-item
5630: 64 61 74 21 20 20 20 6e 65 77 2d 74 65 73 74 2d  dat!   new-test-
5640: 72 65 63 6f 72 64 20 6d 79 2d 69 74 65 6d 64 61  record my-itemda
5650: 74 29 0a 09 09 09 20 28 74 65 73 74 73 3a 74 65  t).... (tests:te
5660: 73 74 71 75 65 75 65 2d 73 65 74 2d 69 74 65 6d  stqueue-set-item
5670: 5f 70 61 74 68 21 20 6e 65 77 2d 74 65 73 74 2d  _path! new-test-
5680: 72 65 63 6f 72 64 20 6d 79 2d 69 74 65 6d 2d 70  record my-item-p
5690: 61 74 68 29 0a 09 09 09 20 28 68 61 73 68 2d 74  ath).... (hash-t
56a0: 61 62 6c 65 2d 73 65 74 21 20 74 65 73 74 2d 72  able-set! test-r
56b0: 65 63 6f 72 64 73 20 6e 65 77 74 65 73 74 6e 61  ecords newtestna
56c0: 6d 65 20 6e 65 77 2d 74 65 73 74 2d 72 65 63 6f  me new-test-reco
56d0: 72 64 29 0a 09 09 09 20 28 73 65 74 21 20 74 61  rd).... (set! ta
56e0: 6c 20 28 63 6f 6e 73 20 6e 65 77 74 65 73 74 6e  l (cons newtestn
56f0: 61 6d 65 20 74 61 6c 29 29 29 29 29 29 20 3b 3b  ame tal)))))) ;;
5700: 20 73 69 6e 63 65 20 74 68 65 73 65 20 61 72 65   since these are
5710: 20 69 74 65 6d 69 7a 65 64 20 63 72 65 61 74 65   itemized create
5720: 20 6e 65 77 20 74 65 73 74 20 6e 61 6d 65 73 20   new test names 
5730: 74 65 73 74 6e 61 6d 65 2f 69 74 65 6d 70 61 74  testname/itempat
5740: 68 0a 09 20 20 20 20 20 20 20 69 74 65 6d 73 29  h..       items)
5750: 0a 09 20 20 20 20 20 20 28 69 66 20 28 6e 6f 74  ..      (if (not
5760: 20 28 6e 75 6c 6c 3f 20 74 61 6c 29 29 0a 09 09   (null? tal))...
5770: 20 20 28 62 65 67 69 6e 0a 09 09 20 20 20 20 28    (begin...    (
5780: 64 65 62 75 67 3a 70 72 69 6e 74 2d 69 6e 66 6f  debug:print-info
5790: 20 34 20 22 45 6e 64 20 6f 66 20 69 74 65 6d 73   4 "End of items
57a0: 20 6c 69 73 74 2c 20 6c 6f 6f 70 69 6e 67 20 77   list, looping w
57b0: 69 74 68 20 6e 65 78 74 20 61 66 74 65 72 20 73  ith next after s
57c0: 68 6f 72 74 20 64 65 6c 61 79 22 29 0a 09 09 20  hort delay")... 
57d0: 20 20 20 28 74 68 72 65 61 64 2d 73 6c 65 65 70     (thread-sleep
57e0: 21 20 28 2b 20 30 2e 30 31 20 2a 67 6c 6f 62 61  ! (+ 0.01 *globa
57f0: 6c 2d 64 65 6c 74 61 2a 29 29 0a 09 09 20 20 20  l-delta*))...   
5800: 20 28 6c 6f 6f 70 20 28 63 61 72 20 74 61 6c 29   (loop (car tal)
5810: 28 63 64 72 20 74 61 6c 29 20 72 65 72 75 6e 73  (cdr tal) reruns
5820: 29 29 29 29 0a 0a 09 20 20 20 20 20 3b 3b 20 69  ))))...     ;; i
5830: 66 20 69 74 65 6d 73 20 69 73 20 61 20 70 72 6f  f items is a pro
5840: 63 20 74 68 65 6e 20 6e 65 65 64 20 74 6f 20 72  c then need to r
5850: 75 6e 20 69 74 65 6d 73 3a 67 65 74 2d 69 74 65  un items:get-ite
5860: 6d 73 2d 66 72 6f 6d 2d 63 6f 6e 66 69 67 2c 20  ms-from-config, 
5870: 67 65 74 20 74 68 65 20 6c 69 73 74 20 61 6e 64  get the list and
5880: 20 6c 6f 6f 70 20 0a 09 20 20 20 20 20 3b 3b 20   loop ..     ;; 
5890: 20 20 20 2d 20 62 75 74 20 6f 6e 6c 79 20 64 6f     - but only do
58a0: 20 74 68 61 74 20 69 66 20 72 65 73 6f 75 72 63   that if resourc
58b0: 65 73 20 65 78 69 73 74 20 74 6f 20 6b 69 63 6b  es exist to kick
58c0: 20 6f 66 66 20 74 68 65 20 6a 6f 62 0a 09 20 20   off the job..  
58d0: 20 20 20 28 28 6f 72 20 28 70 72 6f 63 65 64 75     ((or (procedu
58e0: 72 65 3f 20 69 74 65 6d 73 29 28 65 71 3f 20 69  re? items)(eq? i
58f0: 74 65 6d 73 20 27 68 61 76 65 2d 70 72 6f 63 65  tems 'have-proce
5900: 64 75 72 65 29 29 0a 09 20 20 20 20 20 20 28 6c  dure))..      (l
5910: 65 74 20 28 28 63 61 6e 2d 72 75 6e 2d 6d 6f 72  et ((can-run-mor
5920: 65 20 20 20 20 28 72 75 6e 73 3a 63 61 6e 2d 72  e    (runs:can-r
5930: 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20 74 65  un-more-tests te
5940: 73 74 2d 72 65 63 6f 72 64 29 29 29 0a 09 09 28  st-record)))...(
5950: 69 66 20 28 61 6e 64 20 28 6c 69 73 74 3f 20 63  if (and (list? c
5960: 61 6e 2d 72 75 6e 2d 6d 6f 72 65 29 0a 09 09 09  an-run-more)....
5970: 20 28 63 61 72 20 63 61 6e 2d 72 75 6e 2d 6d 6f   (car can-run-mo
5980: 72 65 29 29 0a 09 09 20 20 20 20 28 6c 65 74 2a  re))...    (let*
5990: 20 28 28 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d   ((prereqs-not-m
59a0: 65 74 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f  et (open-run-clo
59b0: 73 65 20 64 62 3a 67 65 74 2d 70 72 65 72 65 71  se db:get-prereq
59c0: 73 2d 6e 6f 74 2d 6d 65 74 20 23 66 20 72 75 6e  s-not-met #f run
59d0: 2d 69 64 20 77 61 69 74 6f 6e 73 20 69 74 65 6d  -id waitons item
59e0: 2d 70 61 74 68 20 6d 6f 64 65 3a 20 74 65 73 74  -path mode: test
59f0: 6d 6f 64 65 29 29 0a 09 09 09 20 20 20 28 66 61  mode))....   (fa
5a00: 69 6c 73 20 20 20 20 20 20 20 20 20 20 20 28 72  ils           (r
5a10: 75 6e 73 3a 63 61 6c 63 2d 66 61 69 6c 73 20 70  uns:calc-fails p
5a20: 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 29 29  rereqs-not-met))
5a30: 0a 09 09 09 20 20 20 28 6e 6f 6e 2d 63 6f 6d 70  ....   (non-comp
5a40: 6c 65 74 65 64 20 20 20 28 72 75 6e 73 3a 63 61  leted   (runs:ca
5a50: 6c 63 2d 6e 6f 74 2d 63 6f 6d 70 6c 65 74 65 64  lc-not-completed
5a60: 20 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74   prereqs-not-met
5a70: 29 29 29 0a 09 09 20 20 20 20 20 20 28 64 65 62  )))...      (deb
5a80: 75 67 3a 70 72 69 6e 74 2d 69 6e 66 6f 20 38 20  ug:print-info 8 
5a90: 22 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65 3a 20 22  "can-run-more: "
5aa0: 20 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65 0a 09 09   can-run-more...
5ab0: 09 09 20 20 20 22 5c 6e 20 74 65 73 74 6e 61 6d  ..   "\n testnam
5ac0: 65 3a 20 20 20 20 20 20 20 20 22 20 68 65 64 0a  e:        " hed.
5ad0: 09 09 09 09 20 20 20 22 5c 6e 20 70 72 65 72 65  ....   "\n prere
5ae0: 71 73 2d 6e 6f 74 2d 6d 65 74 3a 20 22 20 28 72  qs-not-met: " (r
5af0: 75 6e 73 3a 70 72 65 74 74 79 2d 73 74 72 69 6e  uns:pretty-strin
5b00: 67 20 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65  g prereqs-not-me
5b10: 74 29 0a 09 09 09 09 20 20 20 22 5c 6e 20 6e 6f  t).....   "\n no
5b20: 6e 2d 63 6f 6d 70 6c 65 74 65 64 3a 20 20 20 22  n-completed:   "
5b30: 20 28 72 75 6e 73 3a 70 72 65 74 74 79 2d 73 74   (runs:pretty-st
5b40: 72 69 6e 67 20 6e 6f 6e 2d 63 6f 6d 70 6c 65 74  ring non-complet
5b50: 65 64 29 20 0a 09 09 09 09 20 20 20 22 5c 6e 20  ed) .....   "\n 
5b60: 66 61 69 6c 73 3a 20 20 20 20 20 20 20 20 20 20  fails:          
5b70: 20 22 20 28 72 75 6e 73 3a 70 72 65 74 74 79 2d   " (runs:pretty-
5b80: 73 74 72 69 6e 67 20 66 61 69 6c 73 29 0a 09 09  string fails)...
5b90: 09 09 20 20 20 22 5c 6e 20 74 65 73 74 6d 6f 64  ..   "\n testmod
5ba0: 65 3a 20 20 20 20 20 20 20 20 22 20 74 65 73 74  e:        " test
5bb0: 6d 6f 64 65 0a 09 09 09 09 20 20 20 22 5c 6e 20  mode.....   "\n 
5bc0: 6e 75 6d 2d 72 65 74 72 69 65 73 3a 20 20 20 20  num-retries:    
5bd0: 20 22 20 6e 75 6d 2d 72 65 74 72 69 65 73 0a 09   " num-retries..
5be0: 09 09 09 20 20 20 22 5c 6e 20 28 65 71 3f 20 74  ...   "\n (eq? t
5bf0: 65 73 74 6d 6f 64 65 20 27 74 6f 70 6c 65 76 65  estmode 'topleve
5c00: 6c 29 3a 20 22 20 28 65 71 3f 20 74 65 73 74 6d  l): " (eq? testm
5c10: 6f 64 65 20 27 74 6f 70 6c 65 76 65 6c 29 0a 09  ode 'toplevel)..
5c20: 09 09 09 20 20 20 22 5c 6e 20 28 6e 75 6c 6c 3f  ...   "\n (null?
5c30: 20 6e 6f 6e 2d 63 6f 6d 70 6c 65 74 65 64 29 3a   non-completed):
5c40: 20 20 20 20 22 20 28 6e 75 6c 6c 3f 20 6e 6f 6e      " (null? non
5c50: 2d 63 6f 6d 70 6c 65 74 65 64 29 0a 09 09 09 09  -completed).....
5c60: 20 20 20 22 5c 6e 20 72 65 72 75 6e 73 3a 20 20     "\n reruns:  
5c70: 20 20 20 20 20 20 20 20 22 20 72 65 72 75 6e 73          " reruns
5c80: 0a 09 09 09 09 20 20 20 22 5c 6e 20 69 74 65 6d  .....   "\n item
5c90: 73 3a 20 20 20 20 20 20 20 20 20 20 20 22 20 69  s:           " i
5ca0: 74 65 6d 73 0a 09 09 09 09 20 20 20 22 5c 6e 20  tems.....   "\n 
5cb0: 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65 3a 20 20 20  can-run-more:   
5cc0: 20 22 20 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65 29   " can-run-more)
5cd0: 0a 09 09 20 20 20 20 20 20 3b 3b 20 28 74 68 72  ...      ;; (thr
5ce0: 65 61 64 2d 73 6c 65 65 70 21 20 28 2b 20 30 2e  ead-sleep! (+ 0.
5cf0: 30 31 20 2a 67 6c 6f 62 61 6c 2d 64 65 6c 74 61  01 *global-delta
5d00: 2a 29 29 0a 09 09 20 20 20 20 20 20 28 63 6f 6e  *))...      (con
5d10: 64 20 3b 3b 20 49 4e 4e 45 52 20 43 4f 4e 44 20  d ;; INNER COND 
5d20: 23 32 0a 09 09 20 20 20 20 20 20 20 28 28 6f 72  #2...       ((or
5d30: 20 28 6e 75 6c 6c 3f 20 70 72 65 72 65 71 73 2d   (null? prereqs-
5d40: 6e 6f 74 2d 6d 65 74 29 20 3b 3b 20 61 6c 6c 20  not-met) ;; all 
5d50: 70 72 65 72 65 71 73 20 6d 65 74 2c 20 66 69 72  prereqs met, fir
5d60: 65 20 6f 66 66 20 74 68 65 20 74 65 73 74 0a 09  e off the test..
5d70: 09 09 20 20 20 20 3b 3b 20 6f 72 2c 20 69 66 20  ..    ;; or, if 
5d80: 69 74 20 69 73 20 61 20 27 74 6f 70 6c 65 76 65  it is a 'topleve
5d90: 6c 20 74 65 73 74 20 61 6e 64 20 61 6c 6c 20 70  l test and all p
5da0: 72 65 72 65 71 73 20 6e 6f 74 20 6d 65 74 20 61  rereqs not met a
5db0: 72 65 20 43 4f 4d 50 4c 45 54 45 44 20 74 68 65  re COMPLETED the
5dc0: 6e 20 6c 61 75 6e 63 68 0a 09 09 09 20 20 20 20  n launch....    
5dd0: 28 61 6e 64 20 28 65 71 3f 20 74 65 73 74 6d 6f  (and (eq? testmo
5de0: 64 65 20 27 74 6f 70 6c 65 76 65 6c 29 0a 09 09  de 'toplevel)...
5df0: 09 09 20 28 6e 75 6c 6c 3f 20 6e 6f 6e 2d 63 6f  .. (null? non-co
5e00: 6d 70 6c 65 74 65 64 29 29 29 0a 09 09 09 28 6c  mpleted)))....(l
5e10: 65 74 20 28 28 74 65 73 74 2d 6e 61 6d 65 20 28  et ((test-name (
5e20: 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d  tests:testqueue-
5e30: 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73  get-testname tes
5e40: 74 2d 72 65 63 6f 72 64 29 29 29 0a 09 09 09 20  t-record))).... 
5e50: 20 28 73 65 74 65 6e 76 20 22 4d 54 5f 54 45 53   (setenv "MT_TES
5e60: 54 5f 4e 41 4d 45 22 20 74 65 73 74 2d 6e 61 6d  T_NAME" test-nam
5e70: 65 29 20 3b 3b 20 0a 09 09 09 20 20 28 73 65 74  e) ;; ....  (set
5e80: 65 6e 76 20 22 4d 54 5f 52 55 4e 4e 41 4d 45 22  env "MT_RUNNAME"
5e90: 20 20 20 72 75 6e 6e 61 6d 65 29 0a 09 09 09 20     runname).... 
5ea0: 20 28 73 65 74 2d 6d 65 67 61 74 65 73 74 2d 65   (set-megatest-e
5eb0: 6e 76 2d 76 61 72 73 20 72 75 6e 2d 69 64 29 20  nv-vars run-id) 
5ec0: 3b 3b 20 74 68 65 73 65 20 6d 61 79 20 62 65 20  ;; these may be 
5ed0: 6e 65 65 64 65 64 20 62 79 20 74 68 65 20 6c 61  needed by the la
5ee0: 75 6e 63 68 69 6e 67 20 70 72 6f 63 65 73 73 0a  unching process.
5ef0: 09 09 09 20 20 28 6c 65 74 20 28 28 69 74 65 6d  ...  (let ((item
5f00: 73 2d 6c 69 73 74 20 28 69 74 65 6d 73 3a 67 65  s-list (items:ge
5f10: 74 2d 69 74 65 6d 73 2d 66 72 6f 6d 2d 63 6f 6e  t-items-from-con
5f20: 66 69 67 20 74 63 6f 6e 66 69 67 29 29 29 0a 09  fig tconfig)))..
5f30: 09 09 20 20 20 20 28 69 66 20 28 6c 69 73 74 3f  ..    (if (list?
5f40: 20 69 74 65 6d 73 2d 6c 69 73 74 29 0a 09 09 09   items-list)....
5f50: 09 28 62 65 67 69 6e 0a 09 09 09 09 20 20 28 74  .(begin.....  (t
5f60: 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d 73  ests:testqueue-s
5f70: 65 74 2d 69 74 65 6d 73 21 20 74 65 73 74 2d 72  et-items! test-r
5f80: 65 63 6f 72 64 20 69 74 65 6d 73 2d 6c 69 73 74  ecord items-list
5f90: 29 0a 09 09 09 09 20 20 28 74 68 72 65 61 64 2d  ).....  (thread-
5fa0: 73 6c 65 65 70 21 20 2a 67 6c 6f 62 61 6c 2d 64  sleep! *global-d
5fb0: 65 6c 74 61 2a 29 0a 09 09 09 09 20 20 28 6c 6f  elta*).....  (lo
5fc0: 6f 70 20 68 65 64 20 74 61 6c 20 72 65 72 75 6e  op hed tal rerun
5fd0: 73 29 29 0a 09 09 09 09 28 62 65 67 69 6e 0a 09  s)).....(begin..
5fe0: 09 09 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e  ...  (debug:prin
5ff0: 74 20 30 20 22 45 52 52 4f 52 3a 20 54 68 65 20  t 0 "ERROR: The 
6000: 70 72 6f 63 20 66 72 6f 6d 20 72 65 61 64 69 6e  proc from readin
6010: 67 20 74 68 65 20 73 65 74 75 70 20 64 69 64 20  g the setup did 
6020: 6e 6f 74 20 79 69 65 6c 64 20 61 20 6c 69 73 74  not yield a list
6030: 20 2d 20 70 6c 65 61 73 65 20 72 65 70 6f 72 74   - please report
6040: 20 74 68 69 73 22 29 0a 09 09 09 09 20 20 28 65   this").....  (e
6050: 78 69 74 20 31 29 29 29 29 29 29 0a 09 09 20 20  xit 1))))))...  
6060: 20 20 20 20 20 28 28 6e 75 6c 6c 3f 20 66 61 69       ((null? fai
6070: 6c 73 29 0a 09 09 09 28 64 65 62 75 67 3a 70 72  ls)....(debug:pr
6080: 69 6e 74 2d 69 6e 66 6f 20 34 20 22 66 61 69 6c  int-info 4 "fail
6090: 73 20 69 73 20 6e 75 6c 6c 2c 20 6d 6f 76 69 6e  s is null, movin
60a0: 67 20 6f 6e 20 69 6e 20 74 68 65 20 71 75 65 75  g on in the queu
60b0: 65 20 62 75 74 20 6b 65 65 70 69 6e 67 20 22 20  e but keeping " 
60c0: 68 65 64 20 22 20 66 6f 72 20 6e 6f 77 22 29 0a  hed " for now").
60d0: 09 09 09 3b 3b 20 6f 6e 6c 79 20 69 6e 63 72 65  ...;; only incre
60e0: 6d 65 6e 74 20 6e 75 6d 2d 72 65 74 72 69 65 73  ment num-retries
60f0: 20 77 68 65 6e 20 74 68 65 72 65 20 61 72 65 20   when there are 
6100: 6e 6f 20 74 65 73 74 73 20 72 75 6e 69 6e 67 0a  no tests runing.
6110: 09 09 09 28 69 66 20 28 65 71 3f 20 30 20 28 6c  ...(if (eq? 0 (l
6120: 69 73 74 2d 72 65 66 20 63 61 6e 2d 72 75 6e 2d  ist-ref can-run-
6130: 6d 6f 72 65 20 31 29 29 0a 09 09 09 20 20 20 20  more 1))....    
6140: 28 62 65 67 69 6e 0a 09 09 09 20 20 20 20 20 20  (begin....      
6150: 28 69 66 20 28 3e 20 6e 75 6d 2d 72 65 74 72 69  (if (> num-retri
6160: 65 73 20 31 30 30 29 20 3b 3b 20 66 69 72 73 74  es 100) ;; first
6170: 20 31 30 30 20 72 65 74 72 69 65 73 20 61 72 65   100 retries are
6180: 20 6c 6f 77 20 74 69 6d 65 20 63 6f 73 74 0a 09   low time cost..
6190: 09 09 09 20 20 28 74 68 72 65 61 64 2d 73 6c 65  ...  (thread-sle
61a0: 65 70 21 20 28 2b 20 32 20 2a 67 6c 6f 62 61 6c  ep! (+ 2 *global
61b0: 2d 64 65 6c 74 61 2a 29 29 0a 09 09 09 09 20 20  -delta*)).....  
61c0: 28 74 68 72 65 61 64 2d 73 6c 65 65 70 21 20 28  (thread-sleep! (
61d0: 2b 20 30 2e 30 31 20 2a 67 6c 6f 62 61 6c 2d 64  + 0.01 *global-d
61e0: 65 6c 74 61 2a 29 29 29 0a 09 09 09 20 20 20 20  elta*)))....    
61f0: 20 20 28 73 65 74 21 20 6e 75 6d 2d 72 65 74 72    (set! num-retr
6200: 69 65 73 20 28 2b 20 6e 75 6d 2d 72 65 74 72 69  ies (+ num-retri
6210: 65 73 20 31 29 29 29 29 0a 09 09 09 28 69 66 20  es 1))))....(if 
6220: 28 3e 20 6e 75 6d 2d 72 65 74 72 69 65 73 20 20  (> num-retries  
6230: 6d 61 78 2d 72 65 74 72 69 65 73 29 0a 09 09 09  max-retries)....
6240: 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28 6e 75      (if (not (nu
6250: 6c 6c 3f 20 74 61 6c 29 29 0a 09 09 09 09 28 6c  ll? tal)).....(l
6260: 6f 6f 70 20 28 63 61 72 20 74 61 6c 29 28 63 64  oop (car tal)(cd
6270: 72 20 74 61 6c 29 20 72 65 72 75 6e 73 29 29 0a  r tal) reruns)).
6280: 09 09 09 20 20 20 20 28 6c 6f 6f 70 20 28 63 61  ...    (loop (ca
6290: 72 20 6e 65 77 74 61 6c 29 28 63 64 72 20 6e 65  r newtal)(cdr ne
62a0: 77 74 61 6c 29 20 72 65 72 75 6e 73 29 29 29 20  wtal) reruns))) 
62b0: 3b 3b 20 61 6e 20 69 73 73 75 65 20 77 69 74 68  ;; an issue with
62c0: 20 70 72 65 72 65 71 73 20 6e 6f 74 20 79 65 74   prereqs not yet
62d0: 20 6d 65 74 3f 0a 09 09 20 20 20 20 20 20 20 28   met?...       (
62e0: 28 61 6e 64 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f  (and (not (null?
62f0: 20 66 61 69 6c 73 29 29 28 65 71 3f 20 74 65 73   fails))(eq? tes
6300: 74 6d 6f 64 65 20 27 6e 6f 72 6d 61 6c 29 29 0a  tmode 'normal)).
6310: 09 09 09 28 64 65 62 75 67 3a 70 72 69 6e 74 2d  ...(debug:print-
6320: 69 6e 66 6f 20 31 20 22 74 65 73 74 20 22 20 20  info 1 "test "  
6330: 68 65 64 20 22 20 28 6d 6f 64 65 3d 22 20 74 65  hed " (mode=" te
6340: 73 74 6d 6f 64 65 20 22 29 20 68 61 73 20 66 61  stmode ") has fa
6350: 69 6c 65 64 20 70 72 65 72 65 71 75 69 73 69 74  iled prerequisit
6360: 65 28 73 29 3b 20 22 0a 09 09 09 09 20 20 20 20  e(s); ".....    
6370: 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70   (string-intersp
6380: 65 72 73 65 20 28 6d 61 70 20 28 6c 61 6d 62 64  erse (map (lambd
6390: 61 20 28 74 29 28 63 6f 6e 63 20 28 64 62 3a 74  a (t)(conc (db:t
63a0: 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65  est-get-testname
63b0: 20 74 29 20 22 3a 22 20 28 64 62 3a 74 65 73 74   t) ":" (db:test
63c0: 2d 67 65 74 2d 73 74 61 74 65 20 74 29 22 2f 22  -get-state t)"/"
63d0: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 73 74 61  (db:test-get-sta
63e0: 74 75 73 20 74 29 29 29 20 66 61 69 6c 73 29 20  tus t))) fails) 
63f0: 22 2c 20 22 29 0a 09 09 09 09 20 20 20 20 20 22  ", ").....     "
6400: 2c 20 72 65 6d 6f 76 69 6e 67 20 69 74 20 66 72  , removing it fr
6410: 6f 6d 20 74 6f 2d 64 6f 20 6c 69 73 74 22 29 0a  om to-do list").
6420: 09 09 09 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c  ...(if (not (nul
6430: 6c 3f 20 74 61 6c 29 29 0a 09 09 09 20 20 20 20  l? tal))....    
6440: 28 62 65 67 69 6e 0a 09 09 09 20 20 20 20 20 20  (begin....      
6450: 28 74 68 72 65 61 64 2d 73 6c 65 65 70 21 20 2a  (thread-sleep! *
6460: 67 6c 6f 62 61 6c 2d 64 65 6c 74 61 2a 29 0a 09  global-delta*)..
6470: 09 09 20 20 20 20 20 20 28 6c 6f 6f 70 20 28 63  ..      (loop (c
6480: 61 72 20 74 61 6c 29 28 63 64 72 20 74 61 6c 29  ar tal)(cdr tal)
6490: 28 63 6f 6e 73 20 68 65 64 20 72 65 72 75 6e 73  (cons hed reruns
64a0: 29 29 29 29 29 0a 09 09 20 20 20 20 20 20 20 28  )))))...       (
64b0: 65 6c 73 65 0a 09 09 09 28 64 65 62 75 67 3a 70  else....(debug:p
64c0: 72 69 6e 74 20 38 20 22 45 52 52 4f 52 3a 20 4e  rint 8 "ERROR: N
64d0: 6f 20 68 61 6e 64 6c 65 72 20 66 6f 72 20 74 68  o handler for th
64e0: 69 73 20 63 6f 6e 64 69 74 69 6f 6e 2e 22 29 0a  is condition.").
64f0: 09 09 09 28 74 68 72 65 61 64 2d 73 6c 65 65 70  ...(thread-sleep
6500: 21 20 28 2b 20 31 20 2a 67 6c 6f 62 61 6c 2d 64  ! (+ 1 *global-d
6510: 65 6c 74 61 2a 29 29 0a 09 09 09 28 6c 6f 6f 70  elta*))....(loop
6520: 20 28 63 61 72 20 6e 65 77 74 61 6c 29 28 63 64   (car newtal)(cd
6530: 72 20 6e 65 77 74 61 6c 29 20 72 65 72 75 6e 73  r newtal) reruns
6540: 29 29 29 29 20 3b 3b 20 45 4e 44 20 4f 46 20 49  )))) ;; END OF I
6550: 46 20 43 41 4e 20 52 55 4e 20 4d 4f 52 45 0a 0a  F CAN RUN MORE..
6560: 09 09 20 20 20 20 3b 3b 20 69 66 20 63 61 6e 27  ..    ;; if can'
6570: 74 20 72 75 6e 20 6d 6f 72 65 20 6a 75 73 74 20  t run more just 
6580: 6c 6f 6f 70 20 77 69 74 68 20 6e 65 78 74 20 70  loop with next p
6590: 6f 73 73 69 62 6c 65 20 74 65 73 74 0a 09 09 20  ossible test... 
65a0: 20 20 20 28 62 65 67 69 6e 0a 09 09 20 20 20 20     (begin...    
65b0: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 2d 69    (debug:print-i
65c0: 6e 66 6f 20 34 20 22 70 72 6f 63 65 73 73 69 6e  nfo 4 "processin
65d0: 67 20 74 68 65 20 63 61 73 65 20 77 69 74 68 20  g the case with 
65e0: 61 20 6c 61 6d 62 64 61 20 66 6f 72 20 69 74 65  a lambda for ite
65f0: 6d 73 20 6f 72 20 27 68 61 76 65 2d 70 72 6f 63  ms or 'have-proc
6600: 65 64 75 72 65 2e 20 4d 6f 76 69 6e 67 20 74 68  edure. Moving th
6610: 72 6f 75 67 68 20 74 68 65 20 71 75 65 75 65 20  rough the queue 
6620: 77 69 74 68 6f 75 74 20 64 72 6f 70 70 69 6e 67  without dropping
6630: 20 22 20 68 65 64 29 0a 09 09 20 20 20 20 20 20   " hed)...      
6640: 28 74 68 72 65 61 64 2d 73 6c 65 65 70 21 20 28  (thread-sleep! (
6650: 2b 20 32 20 2a 67 6c 6f 62 61 6c 2d 64 65 6c 74  + 2 *global-delt
6660: 61 2a 29 29 0a 09 09 20 20 20 20 20 20 28 6c 6f  a*))...      (lo
6670: 6f 70 20 28 63 61 72 20 6e 65 77 74 61 6c 29 28  op (car newtal)(
6680: 63 64 72 20 6e 65 77 74 61 6c 29 20 72 65 72 75  cdr newtal) reru
6690: 6e 73 29 29 29 29 29 20 3b 3b 20 45 4e 44 20 4f  ns))))) ;; END O
66a0: 46 20 28 6f 72 20 28 70 72 6f 63 65 64 75 72 65  F (or (procedure
66b0: 3f 20 69 74 65 6d 73 29 28 65 71 3f 20 69 74 65  ? items)(eq? ite
66c0: 6d 73 20 27 68 61 76 65 2d 70 72 6f 63 65 64 75  ms 'have-procedu
66d0: 72 65 29 29 0a 09 20 20 20 20 20 0a 09 20 20 20  re))..     ..   
66e0: 20 20 3b 3b 20 74 68 69 73 20 63 61 73 65 20 73    ;; this case s
66f0: 68 6f 75 6c 64 20 6e 6f 74 20 68 61 70 70 65 6e  hould not happen
6700: 2c 20 61 64 64 65 64 20 74 6f 20 68 65 6c 70 20  , added to help 
6710: 63 61 74 63 68 20 61 6e 79 20 62 75 67 73 0a 09  catch any bugs..
6720: 20 20 20 20 20 28 28 61 6e 64 20 28 6c 69 73 74       ((and (list
6730: 3f 20 69 74 65 6d 73 29 20 69 74 65 6d 64 61 74  ? items) itemdat
6740: 29 0a 09 20 20 20 20 20 20 28 64 65 62 75 67 3a  )..      (debug:
6750: 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20  print 0 "ERROR: 
6760: 53 68 6f 75 6c 64 20 6e 6f 74 20 68 61 76 65 20  Should not have 
6770: 61 20 6c 69 73 74 20 6f 66 20 69 74 65 6d 73 20  a list of items 
6780: 69 6e 20 61 20 74 65 73 74 20 61 6e 64 20 74 68  in a test and th
6790: 65 20 69 74 65 6d 73 70 61 74 68 20 73 65 74 20  e itemspath set 
67a0: 2d 20 70 6c 65 61 73 65 20 72 65 70 6f 72 74 20  - please report 
67b0: 74 68 69 73 22 29 0a 09 20 20 20 20 20 20 28 65  this")..      (e
67c0: 78 69 74 20 31 29 29 0a 09 20 20 20 20 20 28 28  xit 1))..     ((
67d0: 6e 6f 74 20 28 6e 75 6c 6c 3f 20 72 65 72 75 6e  not (null? rerun
67e0: 73 29 29 0a 09 20 20 20 20 20 20 28 6c 65 74 2a  s))..      (let*
67f0: 20 28 28 6e 65 77 6c 73 74 20 28 74 65 73 74 73   ((newlst (tests
6800: 3a 66 69 6c 74 65 72 2d 6e 6f 6e 2d 72 75 6e 6e  :filter-non-runn
6810: 61 62 6c 65 20 72 75 6e 2d 69 64 20 74 61 6c 20  able run-id tal 
6820: 74 65 73 74 2d 72 65 63 6f 72 64 73 29 29 20 3b  test-records)) ;
6830: 3b 20 69 2e 65 2e 20 6e 6f 74 20 46 41 49 4c 2c  ; i.e. not FAIL,
6840: 20 57 41 49 56 45 44 2c 20 49 4e 43 4f 4d 50 4c   WAIVED, INCOMPL
6850: 45 54 45 2c 20 50 41 53 53 2c 20 4b 49 4c 4c 45  ETE, PASS, KILLE
6860: 44 2c 0a 09 09 20 20 20 20 20 28 6a 75 6e 6b 65  D,...     (junke
6870: 64 20 28 6c 73 65 74 2d 64 69 66 66 65 72 65 6e  d (lset-differen
6880: 63 65 20 65 71 75 61 6c 3f 20 74 61 6c 20 6e 65  ce equal? tal ne
6890: 77 6c 73 74 29 29 29 0a 09 09 28 64 65 62 75 67  wlst)))...(debug
68a0: 3a 70 72 69 6e 74 2d 69 6e 66 6f 20 34 20 22 66  :print-info 4 "f
68b0: 75 6c 6c 20 64 72 6f 70 20 74 68 72 6f 75 67 68  ull drop through
68c0: 2c 20 69 66 20 72 65 72 75 6e 73 20 69 73 20 6c  , if reruns is l
68d0: 65 73 73 20 74 68 61 6e 20 31 30 30 20 77 65 20  ess than 100 we 
68e0: 77 69 6c 6c 20 66 6f 72 63 65 20 72 65 74 72 79  will force retry
68f0: 20 74 68 65 6d 2c 20 72 65 72 75 6e 73 3d 22 20   them, reruns=" 
6900: 72 65 72 75 6e 73 20 22 2c 20 74 61 6c 3d 22 20  reruns ", tal=" 
6910: 74 61 6c 29 0a 09 09 28 69 66 20 28 3c 20 6e 75  tal)...(if (< nu
6920: 6d 2d 72 65 74 72 69 65 73 20 6d 61 78 2d 72 65  m-retries max-re
6930: 74 72 69 65 73 29 0a 09 09 20 20 20 20 28 73 65  tries)...    (se
6940: 74 21 20 6e 65 77 6c 73 74 20 28 61 70 70 65 6e  t! newlst (appen
6950: 64 20 72 65 72 75 6e 73 20 6e 65 77 6c 73 74 29  d reruns newlst)
6960: 29 29 0a 09 09 28 73 65 74 21 20 6e 75 6d 2d 72  ))...(set! num-r
6970: 65 74 72 69 65 73 20 28 2b 20 6e 75 6d 2d 72 65  etries (+ num-re
6980: 74 72 69 65 73 20 31 29 29 0a 09 09 28 74 68 72  tries 1))...(thr
6990: 65 61 64 2d 73 6c 65 65 70 21 20 28 2b 20 31 20  ead-sleep! (+ 1 
69a0: 2a 67 6c 6f 62 61 6c 2d 64 65 6c 74 61 2a 29 29  *global-delta*))
69b0: 0a 09 09 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c  ...(if (not (nul
69c0: 6c 3f 20 6e 65 77 6c 73 74 29 29 0a 09 09 20 20  l? newlst))...  
69d0: 20 20 3b 3b 20 73 69 6e 63 65 20 72 65 72 75 6e    ;; since rerun
69e0: 73 20 68 61 76 65 20 62 65 65 6e 20 74 61 63 6b  s have been tack
69f0: 65 64 20 6f 6e 20 74 6f 20 6e 65 77 6c 73 74 20  ed on to newlst 
6a00: 63 72 65 61 74 65 20 6e 65 77 20 72 65 72 75 6e  create new rerun
6a10: 73 20 66 72 6f 6d 20 6a 75 6e 6b 65 64 0a 09 09  s from junked...
6a20: 20 20 20 20 28 6c 6f 6f 70 20 28 63 61 72 20 6e      (loop (car n
6a30: 65 77 6c 73 74 29 28 63 64 72 20 6e 65 77 6c 73  ewlst)(cdr newls
6a40: 74 29 28 64 65 6c 65 74 65 2d 64 75 70 6c 69 63  t)(delete-duplic
6a50: 61 74 65 73 20 6a 75 6e 6b 65 64 29 29 29 29 29  ates junked)))))
6a60: 0a 09 20 20 20 20 20 28 28 6e 6f 74 20 28 6e 75  ..     ((not (nu
6a70: 6c 6c 3f 20 74 61 6c 29 29 0a 09 20 20 20 20 20  ll? tal))..     
6a80: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 2d 69 6e   (debug:print-in
6a90: 66 6f 20 34 20 22 49 27 6d 20 70 72 65 74 74 79  fo 4 "I'm pretty
6aa0: 20 73 75 72 65 20 49 20 73 68 6f 75 6c 64 6e 27   sure I shouldn'
6ab0: 74 20 67 65 74 20 68 65 72 65 2e 22 29 29 0a 09  t get here."))..
6ac0: 20 20 20 20 20 28 65 6c 73 65 0a 09 20 20 20 20       (else..    
6ad0: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 2d 69    (debug:print-i
6ae0: 6e 66 6f 20 34 20 22 45 78 69 74 69 6e 67 20 6c  nfo 4 "Exiting l
6af0: 6f 6f 70 20 77 69 74 68 2e 2e 2e 5c 6e 20 20 68  oop with...\n  h
6b00: 65 64 3d 22 20 68 65 64 20 22 5c 6e 20 20 74 61  ed=" hed "\n  ta
6b10: 6c 3d 22 20 74 61 6c 20 22 5c 6e 20 20 72 65 72  l=" tal "\n  rer
6b20: 75 6e 73 3d 22 20 72 65 72 75 6e 73 29 29 0a 09  uns=" reruns))..
6b30: 20 20 20 20 20 29 29 29 29 20 3b 3b 20 4c 45 54       )))) ;; LET
6b40: 2a 20 28 28 74 65 73 74 2d 72 65 63 6f 72 64 0a  * ((test-record.
6b50: 0a 20 20 20 20 3b 3b 20 77 65 20 67 65 74 20 68  .    ;; we get h
6b60: 65 72 65 20 6f 6e 20 22 64 72 6f 70 20 74 68 72  ere on "drop thr
6b70: 6f 75 67 68 22 20 2d 20 6c 6f 6f 70 20 66 6f 72  ough" - loop for
6b80: 20 6e 65 78 74 20 74 65 73 74 20 69 6e 20 71 75   next test in qu
6b90: 65 75 65 0a 20 20 20 20 3b 3b 20 46 49 58 4d 45  eue.    ;; FIXME
6ba0: 21 21 21 21 20 54 48 49 53 20 53 48 4f 55 4c 44  !!!! THIS SHOULD
6bb0: 20 4e 4f 54 20 52 45 51 55 49 52 45 20 41 4e 20   NOT REQUIRE AN 
6bc0: 45 58 49 54 21 21 21 21 21 21 21 0a 20 20 20 20  EXIT!!!!!!!.    
6bd0: 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e  .    (debug:prin
6be0: 74 2d 69 6e 66 6f 20 31 20 22 41 6c 6c 20 74 65  t-info 1 "All te
6bf0: 73 74 73 20 6c 61 75 6e 63 68 65 64 22 29 0a 20  sts launched"). 
6c00: 20 20 20 28 74 68 72 65 61 64 2d 73 6c 65 65 70     (thread-sleep
6c10: 21 20 30 2e 35 29 0a 20 20 20 20 3b 3b 20 46 49  ! 0.5).    ;; FI
6c20: 58 4d 45 21 20 54 68 69 73 20 68 61 72 73 68 20  XME! This harsh 
6c30: 65 78 69 74 20 73 68 6f 75 6c 64 20 6e 6f 74 20  exit should not 
6c40: 62 65 20 6e 65 63 65 73 73 61 72 79 2e 2e 2e 2e  be necessary....
6c50: 0a 20 20 20 20 3b 3b 20 28 69 66 20 28 6e 6f 74  .    ;; (if (not
6c60: 20 2a 72 75 6e 72 65 6d 6f 74 65 2a 29 28 65 78   *runremote*)(ex
6c70: 69 74 29 29 20 3b 3b 20 0a 20 20 20 20 23 66 29  it)) ;; .    #f)
6c80: 29 20 3b 3b 20 72 65 74 75 72 6e 20 61 20 23 66  ) ;; return a #f
6c90: 20 61 73 20 61 20 68 69 6e 74 20 74 68 61 74 20   as a hint that 
6ca0: 77 65 20 61 72 65 20 64 6f 6e 65 0a 20 20 3b 3b  we are done.  ;;
6cb0: 20 48 65 72 65 20 77 65 20 6e 65 65 64 20 74 6f   Here we need to
6cc0: 20 63 68 65 63 6b 20 74 68 61 74 20 61 6c 6c 20   check that all 
6cd0: 74 68 65 20 74 65 73 74 73 20 72 65 6d 61 69 6e  the tests remain
6ce0: 69 6e 67 20 74 6f 20 62 65 20 72 75 6e 20 61 72  ing to be run ar
6cf0: 65 20 65 6c 69 67 69 62 6c 65 20 74 6f 20 72 75  e eligible to ru
6d00: 6e 0a 20 20 3b 3b 20 61 6e 64 20 61 72 65 20 6e  n.  ;; and are n
6d10: 6f 74 20 62 6c 6f 63 6b 65 64 20 62 79 20 66 61  ot blocked by fa
6d20: 69 6c 65 64 0a 20 20 0a 0a 3b 3b 20 70 61 72 65  iled.  ..;; pare
6d30: 6e 74 2d 74 65 73 74 20 69 73 20 74 68 65 72 65  nt-test is there
6d40: 20 61 73 20 61 20 70 6c 61 63 65 68 6f 6c 64 65   as a placeholde
6d50: 72 20 66 6f 72 20 77 68 65 6e 20 70 61 72 65 6e  r for when paren
6d60: 74 2d 74 65 73 74 73 20 63 61 6e 20 62 65 20 72  t-tests can be r
6d70: 75 6e 20 61 73 20 61 20 73 65 74 75 70 20 73 74  un as a setup st
6d80: 65 70 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 3a  ep.(define (run:
6d90: 74 65 73 74 20 72 75 6e 2d 69 64 20 72 75 6e 6e  test run-id runn
6da0: 61 6d 65 20 6b 65 79 76 61 6c 6c 73 74 20 74 65  ame keyvallst te
6db0: 73 74 2d 72 65 63 6f 72 64 20 66 6c 61 67 73 20  st-record flags 
6dc0: 70 61 72 65 6e 74 2d 74 65 73 74 29 0a 20 20 3b  parent-test).  ;
6dd0: 3b 20 41 6c 6c 20 74 68 65 73 65 20 76 61 72 73  ; All these vars
6de0: 20 6d 69 67 68 74 20 62 65 20 72 65 66 65 72 65   might be refere
6df0: 6e 63 65 64 20 62 79 20 74 68 65 20 74 65 73 74  nced by the test
6e00: 63 6f 6e 66 69 67 20 66 69 6c 65 20 72 65 61 64  config file read
6e10: 65 72 0a 20 20 28 6c 65 74 2a 20 28 28 74 65 73  er.  (let* ((tes
6e20: 74 2d 6e 61 6d 65 20 20 20 20 28 74 65 73 74 73  t-name    (tests
6e30: 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d 74  :testqueue-get-t
6e40: 65 73 74 6e 61 6d 65 20 20 20 74 65 73 74 2d 72  estname   test-r
6e50: 65 63 6f 72 64 29 29 0a 09 20 28 74 65 73 74 2d  ecord)).. (test-
6e60: 77 61 69 74 6f 6e 73 20 28 74 65 73 74 73 3a 74  waitons (tests:t
6e70: 65 73 74 71 75 65 75 65 2d 67 65 74 2d 77 61 69  estqueue-get-wai
6e80: 74 6f 6e 73 20 20 20 20 74 65 73 74 2d 72 65 63  tons    test-rec
6e90: 6f 72 64 29 29 0a 09 20 28 74 65 73 74 2d 63 6f  ord)).. (test-co
6ea0: 6e 66 20 20 20 20 28 74 65 73 74 73 3a 74 65 73  nf    (tests:tes
6eb0: 74 71 75 65 75 65 2d 67 65 74 2d 74 65 73 74 63  tqueue-get-testc
6ec0: 6f 6e 66 69 67 20 74 65 73 74 2d 72 65 63 6f 72  onfig test-recor
6ed0: 64 29 29 0a 09 20 28 69 74 65 6d 64 61 74 20 20  d)).. (itemdat  
6ee0: 20 20 20 20 28 74 65 73 74 73 3a 74 65 73 74 71      (tests:testq
6ef0: 75 65 75 65 2d 67 65 74 2d 69 74 65 6d 64 61 74  ueue-get-itemdat
6f00: 20 20 20 20 74 65 73 74 2d 72 65 63 6f 72 64 29      test-record)
6f10: 29 0a 09 20 28 74 65 73 74 2d 70 61 74 68 20 20  ).. (test-path  
6f20: 20 20 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74 68    (conc *toppath
6f30: 2a 20 22 2f 74 65 73 74 73 2f 22 20 74 65 73 74  * "/tests/" test
6f40: 2d 6e 61 6d 65 29 29 20 3b 3b 20 63 6f 75 6c 64  -name)) ;; could
6f50: 20 75 73 65 20 74 65 73 74 73 3a 67 65 74 2d 74   use tests:get-t
6f60: 65 73 74 63 6f 6e 66 69 67 20 68 65 72 65 20 2e  estconfig here .
6f70: 2e 2e 0a 09 20 28 66 6f 72 63 65 20 20 20 20 20  .... (force     
6f80: 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72     (hash-table-r
6f90: 65 66 2f 64 65 66 61 75 6c 74 20 66 6c 61 67 73  ef/default flags
6fa0: 20 22 2d 66 6f 72 63 65 22 20 23 66 29 29 0a 09   "-force" #f))..
6fb0: 20 28 72 65 72 75 6e 20 20 20 20 20 20 20 20 28   (rerun        (
6fc0: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64  hash-table-ref/d
6fd0: 65 66 61 75 6c 74 20 66 6c 61 67 73 20 22 2d 72  efault flags "-r
6fe0: 65 72 75 6e 22 20 23 66 29 29 0a 09 20 28 6b 65  erun" #f)).. (ke
6ff0: 65 70 67 6f 69 6e 67 20 20 20 20 28 68 61 73 68  epgoing    (hash
7000: 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75  -table-ref/defau
7010: 6c 74 20 66 6c 61 67 73 20 22 2d 6b 65 65 70 67  lt flags "-keepg
7020: 6f 69 6e 67 22 20 23 66 29 29 0a 09 20 28 69 74  oing" #f)).. (it
7030: 65 6d 2d 70 61 74 68 20 20 20 20 20 22 22 29 0a  em-path     "").
7040: 09 20 28 64 62 20 20 20 20 20 20 20 20 20 20 20  . (db           
7050: 23 66 29 29 0a 20 20 20 20 28 64 65 62 75 67 3a  #f)).    (debug:
7060: 70 72 69 6e 74 20 34 0a 09 09 20 22 74 65 73 74  print 4... "test
7070: 2d 63 6f 6e 66 69 67 3a 20 22 20 28 68 61 73 68  -config: " (hash
7080: 2d 74 61 62 6c 65 2d 3e 61 6c 69 73 74 20 74 65  -table->alist te
7090: 73 74 2d 63 6f 6e 66 29 0a 09 09 20 22 5c 6e 20  st-conf)... "\n 
70a0: 20 20 69 74 65 6d 64 61 74 3a 20 22 20 69 74 65    itemdat: " ite
70b0: 6d 64 61 74 0a 09 09 20 29 0a 20 20 20 20 3b 3b  mdat... ).    ;;
70c0: 20 73 65 74 74 69 6e 67 20 69 74 65 6d 64 61 74   setting itemdat
70d0: 20 74 6f 20 61 20 6c 69 73 74 20 69 66 20 69 74   to a list if it
70e0: 20 69 73 20 23 66 0a 20 20 20 20 28 69 66 20 28   is #f.    (if (
70f0: 6e 6f 74 20 69 74 65 6d 64 61 74 29 28 73 65 74  not itemdat)(set
7100: 21 20 69 74 65 6d 64 61 74 20 27 28 29 29 29 0a  ! itemdat '())).
7110: 20 20 20 20 28 73 65 74 21 20 69 74 65 6d 2d 70      (set! item-p
7120: 61 74 68 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e  ath (item-list->
7130: 70 61 74 68 20 69 74 65 6d 64 61 74 29 29 0a 20  path itemdat)). 
7140: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
7150: 32 20 22 41 74 74 65 6d 70 74 69 6e 67 20 74 6f  2 "Attempting to
7160: 20 6c 61 75 6e 63 68 20 74 65 73 74 20 22 20 74   launch test " t
7170: 65 73 74 2d 6e 61 6d 65 20 28 69 66 20 28 65 71  est-name (if (eq
7180: 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22  ual? item-path "
7190: 2f 22 29 20 22 2f 22 20 69 74 65 6d 2d 70 61 74  /") "/" item-pat
71a0: 68 29 29 0a 20 20 20 20 28 73 65 74 65 6e 76 20  h)).    (setenv 
71b0: 22 4d 54 5f 54 45 53 54 5f 4e 41 4d 45 22 20 74  "MT_TEST_NAME" t
71c0: 65 73 74 2d 6e 61 6d 65 29 20 3b 3b 20 0a 20 20  est-name) ;; .  
71d0: 20 20 28 73 65 74 65 6e 76 20 22 4d 54 5f 52 55    (setenv "MT_RU
71e0: 4e 4e 41 4d 45 22 20 20 20 72 75 6e 6e 61 6d 65  NNAME"   runname
71f0: 29 0a 20 20 20 20 28 73 65 74 2d 6d 65 67 61 74  ).    (set-megat
7200: 65 73 74 2d 65 6e 76 2d 76 61 72 73 20 72 75 6e  est-env-vars run
7210: 2d 69 64 29 20 3b 3b 20 74 68 65 73 65 20 6d 61  -id) ;; these ma
7220: 79 20 62 65 20 6e 65 65 64 65 64 20 62 79 20 74  y be needed by t
7230: 68 65 20 6c 61 75 6e 63 68 69 6e 67 20 70 72 6f  he launching pro
7240: 63 65 73 73 0a 20 20 20 20 28 63 68 61 6e 67 65  cess.    (change
7250: 2d 64 69 72 65 63 74 6f 72 79 20 2a 74 6f 70 70  -directory *topp
7260: 61 74 68 2a 29 0a 0a 20 20 20 20 3b 3b 20 48 65  ath*)..    ;; He
7270: 72 65 20 69 73 20 77 68 65 72 65 20 74 68 65 20  re is where the 
7280: 74 65 73 74 5f 6d 65 74 61 20 74 61 62 6c 65 20  test_meta table 
7290: 69 73 20 62 65 73 74 20 75 70 64 61 74 65 64 0a  is best updated.
72a0: 20 20 20 20 3b 3b 20 59 65 73 2c 20 61 6e 6f 74      ;; Yes, anot
72b0: 68 65 72 20 75 73 65 20 6f 66 20 61 20 67 6c 6f  her use of a glo
72c0: 62 61 6c 20 66 6f 72 20 63 61 63 68 69 6e 67 2e  bal for caching.
72d0: 20 4e 65 65 64 20 61 20 62 65 74 74 65 72 20 77   Need a better w
72e0: 61 79 3f 0a 20 20 20 20 28 69 66 20 28 6e 6f 74  ay?.    (if (not
72f0: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
7300: 2f 64 65 66 61 75 6c 74 20 2a 74 65 73 74 2d 6d  /default *test-m
7310: 65 74 61 2d 75 70 64 61 74 65 64 2a 20 74 65 73  eta-updated* tes
7320: 74 2d 6e 61 6d 65 20 23 66 29 29 0a 20 20 20 20  t-name #f)).    
7330: 20 20 20 20 28 62 65 67 69 6e 0a 09 20 20 20 28      (begin..   (
7340: 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74 21 20  hash-table-set! 
7350: 2a 74 65 73 74 2d 6d 65 74 61 2d 75 70 64 61 74  *test-meta-updat
7360: 65 64 2a 20 74 65 73 74 2d 6e 61 6d 65 20 23 74  ed* test-name #t
7370: 29 0a 20 20 20 20 20 20 20 20 20 20 20 28 6f 70  ).           (op
7380: 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 72 75 6e  en-run-close run
7390: 73 3a 75 70 64 61 74 65 2d 74 65 73 74 5f 6d 65  s:update-test_me
73a0: 74 61 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 20  ta db test-name 
73b0: 74 65 73 74 2d 63 6f 6e 66 29 29 29 0a 20 20 20  test-conf))).   
73c0: 20 0a 20 20 20 20 3b 3b 20 28 6c 61 6d 62 64 61   .    ;; (lambda
73d0: 20 28 69 74 65 6d 64 61 74 29 20 3b 3b 3b 20 28   (itemdat) ;;; (
73e0: 28 72 69 70 65 6e 65 73 73 20 22 6f 76 65 72 72  (ripeness "overr
73f0: 69 70 65 22 29 20 28 74 65 6d 70 65 72 61 74 75  ipe") (temperatu
7400: 72 65 20 22 63 6f 6f 6c 22 29 20 28 73 65 61 73  re "cool") (seas
7410: 6f 6e 20 22 73 75 6d 6d 65 72 22 29 29 0a 20 20  on "summer")).  
7420: 20 20 28 6c 65 74 2a 20 28 28 6e 65 77 2d 74 65    (let* ((new-te
7430: 73 74 2d 70 61 74 68 20 28 73 74 72 69 6e 67 2d  st-path (string-
7440: 69 6e 74 65 72 73 70 65 72 73 65 20 28 63 6f 6e  intersperse (con
7450: 73 20 74 65 73 74 2d 70 61 74 68 20 28 6d 61 70  s test-path (map
7460: 20 63 61 64 72 20 69 74 65 6d 64 61 74 29 29 20   cadr itemdat)) 
7470: 22 2f 22 29 29 0a 09 20 20 20 28 6e 65 77 2d 74  "/"))..   (new-t
7480: 65 73 74 2d 6e 61 6d 65 20 28 69 66 20 28 65 71  est-name (if (eq
7490: 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22  ual? item-path "
74a0: 22 29 20 74 65 73 74 2d 6e 61 6d 65 20 28 63 6f  ") test-name (co
74b0: 6e 63 20 74 65 73 74 2d 6e 61 6d 65 20 22 2f 22  nc test-name "/"
74c0: 20 69 74 65 6d 2d 70 61 74 68 29 29 29 20 3b 3b   item-path))) ;;
74d0: 20 6a 75 73 74 20 6e 65 65 64 20 69 74 20 74 6f   just need it to
74e0: 20 62 65 20 75 6e 69 71 75 65 0a 09 20 20 20 28   be unique..   (
74f0: 74 65 73 74 2d 69 64 20 20 20 20 20 20 20 28 63  test-id       (c
7500: 64 62 3a 72 65 6d 6f 74 65 2d 72 75 6e 20 64 62  db:remote-run db
7510: 3a 67 65 74 2d 74 65 73 74 2d 69 64 20 23 66 20  :get-test-id #f 
7520: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
7530: 65 20 69 74 65 6d 2d 70 61 74 68 29 29 0a 09 20  e item-path)).. 
7540: 20 20 28 74 65 73 74 64 61 74 20 20 20 20 20 20    (testdat      
7550: 20 28 63 64 62 3a 67 65 74 2d 74 65 73 74 2d 69   (cdb:get-test-i
7560: 6e 66 6f 2d 62 79 2d 69 64 20 2a 72 75 6e 72 65  nfo-by-id *runre
7570: 6d 6f 74 65 2a 20 74 65 73 74 2d 69 64 29 29 29  mote* test-id)))
7580: 0a 20 20 20 20 20 20 28 69 66 20 28 6e 6f 74 20  .      (if (not 
7590: 74 65 73 74 64 61 74 29 0a 09 20 20 28 62 65 67  testdat)..  (beg
75a0: 69 6e 0a 09 20 20 20 20 3b 3b 20 65 6e 73 75 72  in..    ;; ensur
75b0: 65 20 74 68 61 74 20 74 68 65 20 70 61 74 68 20  e that the path 
75c0: 65 78 69 73 74 73 20 62 65 66 6f 72 65 20 72 65  exists before re
75d0: 67 69 73 74 65 72 69 6e 67 20 74 68 65 20 74 65  gistering the te
75e0: 73 74 0a 09 20 20 20 20 3b 3b 20 4e 4f 50 45 3a  st..    ;; NOPE:
75f0: 20 43 61 6e 6e 6f 74 21 20 44 6f 6e 27 74 20 6b   Cannot! Don't k
7600: 6e 6f 77 20 79 65 74 20 77 68 69 63 68 20 64 69  now yet which di
7610: 73 6b 20 61 72 65 61 20 77 69 6c 6c 20 62 65 20  sk area will be 
7620: 61 73 73 69 67 6e 65 64 2e 2e 2e 2e 0a 09 20 20  assigned......  
7630: 20 20 3b 3b 20 28 73 79 73 74 65 6d 20 28 63 6f    ;; (system (co
7640: 6e 63 20 22 6d 6b 64 69 72 20 2d 70 20 22 20 6e  nc "mkdir -p " n
7650: 65 77 2d 74 65 73 74 2d 70 61 74 68 29 29 0a 09  ew-test-path))..
7660: 20 20 20 20 3b 3b 0a 09 20 20 20 20 3b 3b 20 28      ;;..    ;; (
7670: 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 74  open-run-close t
7680: 65 73 74 73 3a 72 65 67 69 73 74 65 72 2d 74 65  ests:register-te
7690: 73 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  st db run-id tes
76a0: 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68  t-name item-path
76b0: 29 0a 09 20 20 20 20 3b 3b 0a 09 20 20 20 20 3b  )..    ;;..    ;
76c0: 3b 20 4e 42 2f 2f 20 66 6f 72 20 74 68 65 20 61  ; NB// for the a
76d0: 62 6f 76 65 20 6c 69 6e 65 2e 20 49 20 77 61 6e  bove line. I wan
76e0: 74 20 74 68 65 20 74 65 73 74 20 74 6f 20 62 65  t the test to be
76f0: 20 72 65 67 69 73 74 65 72 65 64 20 6c 6f 6e 67   registered long
7700: 20 62 65 66 6f 72 65 20 74 68 69 73 20 72 6f 75   before this rou
7710: 74 69 6e 65 20 67 65 74 73 20 63 61 6c 6c 65 64  tine gets called
7720: 21 0a 09 20 20 20 20 3b 3b 0a 09 20 20 20 20 28  !..    ;;..    (
7730: 73 65 74 21 20 74 65 73 74 2d 69 64 20 28 6f 70  set! test-id (op
7740: 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 64 62 3a  en-run-close db:
7750: 67 65 74 2d 74 65 73 74 2d 69 64 20 64 62 20 72  get-test-id db r
7760: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
7770: 69 74 65 6d 2d 70 61 74 68 29 29 0a 09 20 20 20  item-path))..   
7780: 20 28 69 66 20 28 6e 6f 74 20 74 65 73 74 2d 69   (if (not test-i
7790: 64 29 0a 09 09 28 62 65 67 69 6e 0a 09 09 20 20  d)...(begin...  
77a0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22  (debug:print 2 "
77b0: 57 41 52 4e 3a 20 54 65 73 74 20 6e 6f 74 20 70  WARN: Test not p
77c0: 72 65 2d 63 72 65 61 74 65 64 3f 20 74 65 73 74  re-created? test
77d0: 2d 6e 61 6d 65 3d 22 20 74 65 73 74 2d 6e 61 6d  -name=" test-nam
77e0: 65 20 22 2c 20 69 74 65 6d 2d 70 61 74 68 3d 22  e ", item-path="
77f0: 20 69 74 65 6d 2d 70 61 74 68 20 22 2c 20 72 75   item-path ", ru
7800: 6e 2d 69 64 3d 22 20 72 75 6e 2d 69 64 29 0a 09  n-id=" run-id)..
7810: 09 20 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f  .  (open-run-clo
7820: 73 65 20 64 62 3a 74 65 73 74 73 2d 72 65 67 69  se db:tests-regi
7830: 73 74 65 72 2d 74 65 73 74 20 23 66 20 72 75 6e  ster-test #f run
7840: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74  -id test-name it
7850: 65 6d 2d 70 61 74 68 29 0a 09 09 20 20 28 73 65  em-path)...  (se
7860: 74 21 20 74 65 73 74 2d 69 64 20 28 6f 70 65 6e  t! test-id (open
7870: 2d 72 75 6e 2d 63 6c 6f 73 65 20 64 62 3a 67 65  -run-close db:ge
7880: 74 2d 74 65 73 74 2d 69 64 20 64 62 20 72 75 6e  t-test-id db run
7890: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74  -id test-name it
78a0: 65 6d 2d 70 61 74 68 29 29 29 29 0a 09 20 20 20  em-path))))..   
78b0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 2d 69 6e   (debug:print-in
78c0: 66 6f 20 34 20 22 74 65 73 74 2d 69 64 3d 22 20  fo 4 "test-id=" 
78d0: 74 65 73 74 2d 69 64 20 22 2c 20 72 75 6e 2d 69  test-id ", run-i
78e0: 64 3d 22 20 72 75 6e 2d 69 64 20 22 2c 20 74 65  d=" run-id ", te
78f0: 73 74 2d 6e 61 6d 65 3d 22 20 74 65 73 74 2d 6e  st-name=" test-n
7900: 61 6d 65 20 22 2c 20 69 74 65 6d 2d 70 61 74 68  ame ", item-path
7910: 3d 5c 22 22 20 69 74 65 6d 2d 70 61 74 68 20 22  =\"" item-path "
7920: 5c 22 22 29 0a 09 20 20 20 20 28 73 65 74 21 20  \"")..    (set! 
7930: 74 65 73 74 64 61 74 20 28 63 64 62 3a 67 65 74  testdat (cdb:get
7940: 2d 74 65 73 74 2d 69 6e 66 6f 2d 62 79 2d 69 64  -test-info-by-id
7950: 20 2a 72 75 6e 72 65 6d 6f 74 65 2a 20 74 65 73   *runremote* tes
7960: 74 2d 69 64 29 29 29 29 0a 20 20 20 20 20 20 28  t-id)))).      (
7970: 73 65 74 21 20 74 65 73 74 2d 69 64 20 28 64 62  set! test-id (db
7980: 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73  :test-get-id tes
7990: 74 64 61 74 29 29 0a 20 20 20 20 20 20 28 63 68  tdat)).      (ch
79a0: 61 6e 67 65 2d 64 69 72 65 63 74 6f 72 79 20 74  ange-directory t
79b0: 65 73 74 2d 70 61 74 68 29 0a 20 20 20 20 20 20  est-path).      
79c0: 28 63 61 73 65 20 28 69 66 20 66 6f 72 63 65 20  (case (if force 
79d0: 3b 3b 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67  ;; (args:get-arg
79e0: 20 22 2d 66 6f 72 63 65 22 29 0a 09 09 27 4e 4f   "-force")...'NO
79f0: 54 5f 53 54 41 52 54 45 44 0a 09 09 28 69 66 20  T_STARTED...(if 
7a00: 74 65 73 74 64 61 74 0a 09 09 20 20 20 20 28 73  testdat...    (s
7a10: 74 72 69 6e 67 2d 3e 73 79 6d 62 6f 6c 20 28 74  tring->symbol (t
7a20: 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65  est:get-state te
7a30: 73 74 64 61 74 29 29 0a 09 09 20 20 20 20 27 66  stdat))...    'f
7a40: 61 69 6c 65 64 2d 74 6f 2d 69 6e 73 65 72 74 29  ailed-to-insert)
7a50: 29 0a 09 28 28 66 61 69 6c 65 64 2d 74 6f 2d 69  )..((failed-to-i
7a60: 6e 73 65 72 74 29 0a 09 20 28 64 65 62 75 67 3a  nsert).. (debug:
7a70: 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20  print 0 "ERROR: 
7a80: 46 61 69 6c 65 64 20 74 6f 20 69 6e 73 65 72 74  Failed to insert
7a90: 20 74 68 65 20 72 65 63 6f 72 64 20 69 6e 74 6f   the record into
7aa0: 20 74 68 65 20 64 62 22 29 29 0a 09 28 28 4e 4f   the db"))..((NO
7ab0: 54 5f 53 54 41 52 54 45 44 20 43 4f 4d 50 4c 45  T_STARTED COMPLE
7ac0: 54 45 44 20 44 45 4c 45 54 45 44 29 0a 09 20 28  TED DELETED).. (
7ad0: 6c 65 74 20 28 28 72 75 6e 66 6c 61 67 20 23 66  let ((runflag #f
7ae0: 29 29 0a 09 20 20 20 28 63 6f 6e 64 0a 09 20 20  ))..   (cond..  
7af0: 20 20 3b 3b 20 2d 66 6f 72 63 65 2c 20 72 75 6e    ;; -force, run
7b00: 20 6e 6f 20 6d 61 74 74 65 72 20 77 68 61 74 0a   no matter what.
7b10: 09 20 20 20 20 28 66 6f 72 63 65 20 28 73 65 74  .    (force (set
7b20: 21 20 72 75 6e 66 6c 61 67 20 23 74 29 29 0a 09  ! runflag #t))..
7b30: 20 20 20 20 3b 3b 20 4e 4f 54 5f 53 54 41 52 54      ;; NOT_START
7b40: 45 44 2c 20 72 75 6e 20 6e 6f 20 6d 61 74 74 65  ED, run no matte
7b50: 72 20 77 68 61 74 0a 09 20 20 20 20 28 28 6d 65  r what..    ((me
7b60: 6d 62 65 72 20 28 74 65 73 74 3a 67 65 74 2d 73  mber (test:get-s
7b70: 74 61 74 65 20 74 65 73 74 64 61 74 29 20 27 28  tate testdat) '(
7b80: 22 44 45 4c 45 54 45 44 22 20 22 4e 4f 54 5f 53  "DELETED" "NOT_S
7b90: 54 41 52 54 45 44 22 29 29 28 73 65 74 21 20 72  TARTED"))(set! r
7ba0: 75 6e 66 6c 61 67 20 23 74 29 29 0a 09 20 20 20  unflag #t))..   
7bb0: 20 3b 3b 20 6e 6f 74 20 2d 72 65 72 75 6e 20 61   ;; not -rerun a
7bc0: 6e 64 20 50 41 53 53 2c 20 57 41 52 4e 20 6f 72  nd PASS, WARN or
7bd0: 20 43 48 45 43 4b 2c 20 64 6f 20 6e 6f 20 72 75   CHECK, do no ru
7be0: 6e 0a 09 20 20 20 20 28 28 61 6e 64 20 28 6f 72  n..    ((and (or
7bf0: 20 28 6e 6f 74 20 72 65 72 75 6e 29 0a 09 09 20   (not rerun)... 
7c00: 20 20 20 20 20 6b 65 65 70 67 6f 69 6e 67 29 0a       keepgoing).
7c10: 09 09 20 20 3b 3b 20 52 65 71 75 69 72 65 20 74  ..  ;; Require t
7c20: 6f 20 66 6f 72 63 65 20 72 65 2d 72 75 6e 20 66  o force re-run f
7c30: 6f 72 20 43 4f 4d 50 4c 45 54 45 44 20 6f 72 20  or COMPLETED or 
7c40: 2a 61 6e 79 74 68 69 6e 67 2a 20 2b 20 50 41 53  *anything* + PAS
7c50: 53 2c 57 41 52 4e 20 6f 72 20 43 48 45 43 4b 0a  S,WARN or CHECK.
7c60: 09 09 20 20 28 6f 72 20 28 6d 65 6d 62 65 72 20  ..  (or (member 
7c70: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73  (test:get-status
7c80: 20 74 65 73 74 64 61 74 29 20 27 28 22 50 41 53   testdat) '("PAS
7c90: 53 22 20 22 57 41 52 4e 22 20 22 43 48 45 43 4b  S" "WARN" "CHECK
7ca0: 22 29 29 0a 09 09 20 20 20 20 20 20 28 6d 65 6d  "))...      (mem
7cb0: 62 65 72 20 28 74 65 73 74 3a 67 65 74 2d 73 74  ber (test:get-st
7cc0: 61 74 65 20 20 74 65 73 74 64 61 74 29 20 27 28  ate  testdat) '(
7cd0: 22 43 4f 4d 50 4c 45 54 45 44 22 29 29 29 29 20  "COMPLETED")))) 
7ce0: 0a 09 20 20 20 20 20 28 64 65 62 75 67 3a 70 72  ..     (debug:pr
7cf0: 69 6e 74 2d 69 6e 66 6f 20 32 20 22 72 75 6e 6e  int-info 2 "runn
7d00: 69 6e 67 20 74 65 73 74 20 22 20 74 65 73 74 2d  ing test " test-
7d10: 6e 61 6d 65 20 22 2f 22 20 69 74 65 6d 2d 70 61  name "/" item-pa
7d20: 74 68 20 22 20 73 75 70 70 72 65 73 73 65 64 20  th " suppressed 
7d30: 61 73 20 69 74 20 69 73 20 22 20 28 74 65 73 74  as it is " (test
7d40: 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64  :get-state testd
7d50: 61 74 29 20 22 20 61 6e 64 20 22 20 28 74 65 73  at) " and " (tes
7d60: 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73  t:get-status tes
7d70: 74 64 61 74 29 29 0a 09 20 20 20 20 20 28 73 65  tdat))..     (se
7d80: 74 21 20 72 75 6e 66 6c 61 67 20 23 66 29 29 0a  t! runflag #f)).
7d90: 09 20 20 20 20 3b 3b 20 2d 72 65 72 75 6e 20 61  .    ;; -rerun a
7da0: 6e 64 20 73 74 61 74 75 73 20 69 73 20 6f 6e 65  nd status is one
7db0: 20 6f 66 20 74 68 65 20 73 70 65 63 69 66 65 64   of the specifed
7dc0: 2c 20 72 75 6e 20 69 74 0a 09 20 20 20 20 28 28  , run it..    ((
7dd0: 61 6e 64 20 72 65 72 75 6e 0a 09 09 20 20 28 6c  and rerun...  (l
7de0: 65 74 2a 20 28 28 72 65 72 75 6e 6c 73 74 20 20  et* ((rerunlst  
7df0: 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 72   (string-split r
7e00: 65 72 75 6e 20 22 2c 22 29 29 0a 09 09 09 20 28  erun ",")).... (
7e10: 6d 75 73 74 2d 72 65 72 75 6e 20 28 6d 65 6d 62  must-rerun (memb
7e20: 65 72 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61  er (test:get-sta
7e30: 74 75 73 20 74 65 73 74 64 61 74 29 20 72 65 72  tus testdat) rer
7e40: 75 6e 6c 73 74 29 29 29 0a 09 09 20 20 20 20 28  unlst)))...    (
7e50: 64 65 62 75 67 3a 70 72 69 6e 74 2d 69 6e 66 6f  debug:print-info
7e60: 20 33 20 22 2d 72 65 72 75 6e 20 6c 69 73 74 3a   3 "-rerun list:
7e70: 20 22 20 72 65 72 75 6e 20 22 2c 20 74 65 73 74   " rerun ", test
7e80: 2d 73 74 61 74 75 73 3a 20 22 20 28 74 65 73 74  -status: " (test
7e90: 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74  :get-status test
7ea0: 64 61 74 29 22 2c 20 6d 75 73 74 2d 72 65 72 75  dat)", must-reru
7eb0: 6e 3a 20 22 20 6d 75 73 74 2d 72 65 72 75 6e 29  n: " must-rerun)
7ec0: 0a 09 09 20 20 20 20 6d 75 73 74 2d 72 65 72 75  ...    must-reru
7ed0: 6e 29 29 0a 09 20 20 20 20 20 28 64 65 62 75 67  n))..     (debug
7ee0: 3a 70 72 69 6e 74 2d 69 6e 66 6f 20 32 20 22 52  :print-info 2 "R
7ef0: 65 72 75 6e 20 66 6f 72 63 65 64 20 66 6f 72 20  erun forced for 
7f00: 74 65 73 74 20 22 20 74 65 73 74 2d 6e 61 6d 65  test " test-name
7f10: 20 22 2f 22 20 69 74 65 6d 2d 70 61 74 68 29 0a   "/" item-path).
7f20: 09 20 20 20 20 20 28 73 65 74 21 20 72 75 6e 66  .     (set! runf
7f30: 6c 61 67 20 23 74 29 29 0a 09 20 20 20 20 3b 3b  lag #t))..    ;;
7f40: 20 2d 6b 65 65 70 67 6f 69 6e 67 2c 20 64 6f 20   -keepgoing, do 
7f50: 6e 6f 74 20 72 65 72 75 6e 20 46 41 49 4c 0a 09  not rerun FAIL..
7f60: 20 20 20 20 28 28 61 6e 64 20 6b 65 65 70 67 6f      ((and keepgo
7f70: 69 6e 67 0a 09 09 20 20 28 6d 65 6d 62 65 72 20  ing...  (member 
7f80: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73  (test:get-status
7f90: 20 74 65 73 74 64 61 74 29 20 27 28 22 46 41 49   testdat) '("FAI
7fa0: 4c 22 29 29 29 0a 09 20 20 20 20 20 28 73 65 74  L")))..     (set
7fb0: 21 20 72 75 6e 66 6c 61 67 20 23 66 29 29 0a 09  ! runflag #f))..
7fc0: 20 20 20 20 28 28 61 6e 64 20 28 6e 6f 74 20 72      ((and (not r
7fd0: 65 72 75 6e 29 0a 09 09 20 20 28 6d 65 6d 62 65  erun)...  (membe
7fe0: 72 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74  r (test:get-stat
7ff0: 75 73 20 74 65 73 74 64 61 74 29 20 27 28 22 46  us testdat) '("F
8000: 41 49 4c 22 20 22 6e 2f 61 22 29 29 29 0a 09 20  AIL" "n/a"))).. 
8010: 20 20 20 20 28 73 65 74 21 20 72 75 6e 66 6c 61      (set! runfla
8020: 67 20 23 74 29 29 0a 09 20 20 20 20 28 65 6c 73  g #t))..    (els
8030: 65 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20  e (set! runflag 
8040: 23 66 29 29 29 0a 09 20 20 20 28 64 65 62 75 67  #f)))..   (debug
8050: 3a 70 72 69 6e 74 20 36 20 22 52 55 4e 4e 49 4e  :print 6 "RUNNIN
8060: 47 20 3d 3e 20 72 75 6e 66 6c 61 67 3a 20 22 20  G => runflag: " 
8070: 72 75 6e 66 6c 61 67 20 22 20 53 54 41 54 45 3a  runflag " STATE:
8080: 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61   " (test:get-sta
8090: 74 65 20 74 65 73 74 64 61 74 29 20 22 20 53 54  te testdat) " ST
80a0: 41 54 55 53 3a 20 22 20 28 74 65 73 74 3a 67 65  ATUS: " (test:ge
80b0: 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61 74  t-status testdat
80c0: 29 29 0a 09 20 20 20 28 69 66 20 28 6e 6f 74 20  ))..   (if (not 
80d0: 72 75 6e 66 6c 61 67 29 0a 09 20 20 20 20 20 20  runflag)..      
80e0: 20 28 69 66 20 28 6e 6f 74 20 70 61 72 65 6e 74   (if (not parent
80f0: 2d 74 65 73 74 29 0a 09 09 20 20 20 28 64 65 62  -test)...   (deb
8100: 75 67 3a 70 72 69 6e 74 20 31 20 22 4e 4f 54 45  ug:print 1 "NOTE
8110: 3a 20 4e 6f 74 20 73 74 61 72 74 69 6e 67 20 74  : Not starting t
8120: 65 73 74 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e  est " new-test-n
8130: 61 6d 65 20 22 20 61 73 20 69 74 20 69 73 20 73  ame " as it is s
8140: 74 61 74 65 20 5c 22 22 20 28 74 65 73 74 3a 67  tate \"" (test:g
8150: 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 74  et-state testdat
8160: 29 20 0a 09 09 09 09 22 5c 22 20 61 6e 64 20 73  ) ....."\" and s
8170: 74 61 74 75 73 20 5c 22 22 20 28 74 65 73 74 3a  tatus \"" (test:
8180: 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64  get-status testd
8190: 61 74 29 20 22 5c 22 2c 20 75 73 65 20 2d 72 65  at) "\", use -re
81a0: 72 75 6e 20 5c 22 22 20 28 74 65 73 74 3a 67 65  run \"" (test:ge
81b0: 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61 74  t-status testdat
81c0: 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ).              
81d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
81e0: 20 20 22 5c 22 20 6f 72 20 2d 66 6f 72 63 65 20    "\" or -force 
81f0: 74 6f 20 6f 76 65 72 72 69 64 65 22 29 29 0a 09  to override"))..
8200: 20 20 20 20 20 20 20 3b 3b 20 4e 4f 54 45 3a 20         ;; NOTE: 
8210: 4e 6f 20 6c 6f 6e 67 65 72 20 62 65 20 63 68 65  No longer be che
8220: 63 6b 69 6e 67 20 70 72 65 72 65 71 75 69 73 69  cking prerequisi
8230: 74 65 73 20 68 65 72 65 21 20 57 69 6c 6c 20 6e  tes here! Will n
8240: 65 76 65 72 20 67 65 74 20 68 65 72 65 20 75 6e  ever get here un
8250: 6c 65 73 73 20 70 72 65 72 65 71 73 20 61 72 65  less prereqs are
8260: 0a 09 20 20 20 20 20 20 20 3b 3b 20 20 20 20 20  ..       ;;     
8270: 20 20 61 6c 72 65 61 64 79 20 6d 65 74 2e 0a 09    already met...
8280: 20 20 20 20 20 20 20 28 69 66 20 28 6e 6f 74 20         (if (not 
8290: 28 6c 61 75 6e 63 68 2d 74 65 73 74 20 23 66 20  (launch-test #f 
82a0: 72 75 6e 2d 69 64 20 72 75 6e 6e 61 6d 65 20 74  run-id runname t
82b0: 65 73 74 2d 63 6f 6e 66 20 6b 65 79 76 61 6c 6c  est-conf keyvall
82c0: 73 74 20 74 65 73 74 2d 6e 61 6d 65 20 74 65 73  st test-name tes
82d0: 74 2d 70 61 74 68 20 69 74 65 6d 64 61 74 20 66  t-path itemdat f
82e0: 6c 61 67 73 29 29 0a 09 09 20 20 20 28 62 65 67  lags))...   (beg
82f0: 69 6e 0a 09 09 20 20 20 20 20 28 70 72 69 6e 74  in...     (print
8300: 20 22 45 52 52 4f 52 3a 20 46 61 69 6c 65 64 20   "ERROR: Failed 
8310: 74 6f 20 6c 61 75 6e 63 68 20 74 68 65 20 74 65  to launch the te
8320: 73 74 2e 20 45 78 69 74 69 6e 67 20 61 73 20 73  st. Exiting as s
8330: 6f 6f 6e 20 61 73 20 70 6f 73 73 69 62 6c 65 22  oon as possible"
8340: 29 0a 09 09 20 20 20 20 20 28 73 65 74 21 20 2a  )...     (set! *
8350: 67 6c 6f 62 61 6c 65 78 69 74 73 74 61 74 75 73  globalexitstatus
8360: 2a 20 31 29 20 3b 3b 20 0a 09 09 20 20 20 20 20  * 1) ;; ...     
8370: 28 70 72 6f 63 65 73 73 2d 73 69 67 6e 61 6c 20  (process-signal 
8380: 28 63 75 72 72 65 6e 74 2d 70 72 6f 63 65 73 73  (current-process
8390: 2d 69 64 29 20 73 69 67 6e 61 6c 2f 6b 69 6c 6c  -id) signal/kill
83a0: 29 29 29 29 29 29 0a 09 28 28 4b 49 4c 4c 45 44  ))))))..((KILLED
83b0: 29 20 0a 09 20 28 64 65 62 75 67 3a 70 72 69 6e  ) .. (debug:prin
83c0: 74 20 31 20 22 4e 4f 54 45 3a 20 22 20 6e 65 77  t 1 "NOTE: " new
83d0: 2d 74 65 73 74 2d 6e 61 6d 65 20 22 20 69 73 20  -test-name " is 
83e0: 61 6c 72 65 61 64 79 20 72 75 6e 6e 69 6e 67 20  already running 
83f0: 6f 72 20 77 61 73 20 65 78 70 6c 69 63 74 6c 79  or was explictly
8400: 20 6b 69 6c 6c 65 64 2c 20 75 73 65 20 2d 66 6f   killed, use -fo
8410: 72 63 65 20 74 6f 20 6c 61 75 6e 63 68 20 69 74  rce to launch it
8420: 2e 22 29 29 0a 09 28 28 4c 41 55 4e 43 48 45 44  ."))..((LAUNCHED
8430: 20 52 45 4d 4f 54 45 48 4f 53 54 53 54 41 52 54   REMOTEHOSTSTART
8440: 20 52 55 4e 4e 49 4e 47 29 20 20 0a 09 20 28 69   RUNNING)  .. (i
8450: 66 20 28 3e 20 28 2d 20 28 63 75 72 72 65 6e 74  f (> (- (current
8460: 2d 73 65 63 6f 6e 64 73 29 28 2b 20 28 64 62 3a  -seconds)(+ (db:
8470: 74 65 73 74 2d 67 65 74 2d 65 76 65 6e 74 5f 74  test-get-event_t
8480: 69 6d 65 20 74 65 73 74 64 61 74 29 0a 09 09 09  ime testdat)....
8490: 09 20 20 20 20 20 20 20 28 64 62 3a 74 65 73 74  .       (db:test
84a0: 2d 67 65 74 2d 72 75 6e 5f 64 75 72 61 74 69 6f  -get-run_duratio
84b0: 6e 20 74 65 73 74 64 61 74 29 29 29 0a 09 09 36  n testdat)))...6
84c0: 30 30 29 20 3b 3b 20 69 2e 65 2e 20 6e 6f 20 75  00) ;; i.e. no u
84d0: 70 64 61 74 65 20 66 6f 72 20 6d 6f 72 65 20 74  pdate for more t
84e0: 68 61 6e 20 36 30 30 20 73 65 63 6f 6e 64 73 0a  han 600 seconds.
84f0: 09 20 20 20 20 20 28 62 65 67 69 6e 0a 09 20 20  .     (begin..  
8500: 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e       (debug:prin
8510: 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 54 65  t 0 "WARNING: Te
8520: 73 74 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22  st " test-name "
8530: 20 61 70 70 65 61 72 73 20 74 6f 20 62 65 20 64   appears to be d
8540: 65 61 64 2e 20 46 6f 72 63 69 6e 67 20 69 74 20  ead. Forcing it 
8550: 74 6f 20 73 74 61 74 65 20 49 4e 43 4f 4d 50 4c  to state INCOMPL
8560: 45 54 45 20 61 6e 64 20 73 74 61 74 75 73 20 53  ETE and status S
8570: 54 55 43 4b 2f 44 45 41 44 22 29 0a 09 20 20 20  TUCK/DEAD")..   
8580: 20 20 20 20 28 74 65 73 74 73 3a 74 65 73 74 2d      (tests:test-
8590: 73 65 74 2d 73 74 61 74 75 73 21 20 74 65 73 74  set-status! test
85a0: 2d 69 64 20 22 49 4e 43 4f 4d 50 4c 45 54 45 22  -id "INCOMPLETE"
85b0: 20 22 53 54 55 43 4b 2f 44 45 41 44 22 20 22 54   "STUCK/DEAD" "T
85c0: 65 73 74 20 69 73 20 73 74 75 63 6b 20 6f 72 20  est is stuck or 
85d0: 64 65 61 64 22 20 23 66 29 29 0a 09 20 20 20 20  dead" #f))..    
85e0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20   (debug:print 2 
85f0: 22 4e 4f 54 45 3a 20 22 20 74 65 73 74 2d 6e 61  "NOTE: " test-na
8600: 6d 65 20 22 20 69 73 20 61 6c 72 65 61 64 79 20  me " is already 
8610: 72 75 6e 6e 69 6e 67 22 29 29 29 0a 09 28 65 6c  running")))..(el
8620: 73 65 20 20 20 20 20 20 20 28 64 65 62 75 67 3a  se       (debug:
8630: 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20  print 0 "ERROR: 
8640: 46 61 69 6c 65 64 20 74 6f 20 6c 61 75 6e 63 68  Failed to launch
8650: 20 74 65 73 74 20 22 20 6e 65 77 2d 74 65 73 74   test " new-test
8660: 2d 6e 61 6d 65 20 22 2e 20 55 6e 72 65 63 6f 67  -name ". Unrecog
8670: 6e 69 73 65 64 20 73 74 61 74 65 20 22 20 28 74  nised state " (t
8680: 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65  est:get-state te
8690: 73 74 64 61 74 29 29 29 29 29 29 29 0a 0a 3b 3b  stdat)))))))..;;
86a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
86b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
86c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
86d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
86e0: 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 45 4e 44 20 4f 46  ======.;; END OF
86f0: 20 4e 45 57 20 53 54 55 46 46 0a 3b 3b 3d 3d 3d   NEW STUFF.;;===
8700: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
8710: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
8720: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
8730: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
8740: 3d 3d 3d 0a 0a 28 64 65 66 69 6e 65 20 28 67 65  ===..(define (ge
8750: 74 2d 64 69 72 2d 75 70 2d 6e 20 64 69 72 20 2e  t-dir-up-n dir .
8760: 20 70 61 72 61 6d 73 29 20 0a 20 20 28 6c 65 74   params) .  (let
8770: 20 28 28 64 70 61 72 74 73 20 20 28 73 74 72 69   ((dparts  (stri
8780: 6e 67 2d 73 70 6c 69 74 20 64 69 72 20 22 2f 22  ng-split dir "/"
8790: 29 29 0a 09 28 63 6f 75 6e 74 20 20 20 28 69 66  ))..(count   (if
87a0: 20 28 6e 75 6c 6c 3f 20 70 61 72 61 6d 73 29 20   (null? params) 
87b0: 31 20 28 63 61 72 20 70 61 72 61 6d 73 29 29 29  1 (car params)))
87c0: 29 0a 20 20 20 20 28 63 6f 6e 63 20 22 2f 22 20  ).    (conc "/" 
87d0: 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65  (string-interspe
87e0: 72 73 65 20 0a 09 20 20 20 20 20 20 20 28 74 61  rse ..       (ta
87f0: 6b 65 20 64 70 61 72 74 73 20 28 2d 20 28 6c 65  ke dparts (- (le
8800: 6e 67 74 68 20 64 70 61 72 74 73 29 20 63 6f 75  ngth dparts) cou
8810: 6e 74 29 29 0a 09 20 20 20 20 20 20 20 22 2f 22  nt))..       "/"
8820: 29 29 29 29 0a 3b 3b 20 52 65 6d 6f 76 65 20 72  )))).;; Remove r
8830: 75 6e 73 0a 3b 3b 20 66 69 65 6c 64 73 20 61 72  uns.;; fields ar
8840: 65 20 70 61 73 73 69 6e 67 20 69 6e 20 74 68 72  e passing in thr
8850: 6f 75 67 68 20 0a 3b 3b 20 61 63 74 69 6f 6e 3a  ough .;; action:
8860: 0a 3b 3b 20 20 20 20 27 72 65 6d 6f 76 65 2d 72  .;;    'remove-r
8870: 75 6e 73 0a 3b 3b 20 20 20 20 27 73 65 74 2d 73  uns.;;    'set-s
8880: 74 61 74 65 2d 73 74 61 74 75 73 0a 3b 3b 0a 3b  tate-status.;;.;
8890: 3b 20 4e 42 2f 2f 20 73 68 6f 75 6c 64 20 70 61  ; NB// should pa
88a0: 73 73 20 69 6e 20 6b 65 79 73 3f 0a 3b 3b 0a 28  ss in keys?.;;.(
88b0: 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 6f 70 65  define (runs:ope
88c0: 72 61 74 65 2d 6f 6e 20 61 63 74 69 6f 6e 20 72  rate-on action r
88d0: 75 6e 6e 61 6d 65 70 61 74 74 20 74 65 73 74 70  unnamepatt testp
88e0: 61 74 74 20 23 21 6b 65 79 20 28 73 74 61 74 65  att #!key (state
88f0: 20 23 66 29 28 73 74 61 74 75 73 20 23 66 29 28   #f)(status #f)(
8900: 6e 65 77 2d 73 74 61 74 65 2d 73 74 61 74 75 73  new-state-status
8910: 20 23 66 29 29 0a 20 20 28 6c 65 74 2a 20 28 28   #f)).  (let* ((
8920: 64 62 20 20 20 20 20 20 20 20 20 20 20 23 66 29  db           #f)
8930: 0a 09 20 28 6b 65 79 73 20 20 20 20 20 20 20 20  .. (keys        
8940: 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65   (open-run-close
8950: 20 64 62 3a 67 65 74 2d 6b 65 79 73 20 64 62 29   db:get-keys db)
8960: 29 0a 09 20 28 72 75 6e 64 61 74 20 20 20 20 20  ).. (rundat     
8970: 20 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f 73    (open-run-clos
8980: 65 20 72 75 6e 73 3a 67 65 74 2d 72 75 6e 73 2d  e runs:get-runs-
8990: 62 79 2d 70 61 74 74 20 64 62 20 6b 65 79 73 20  by-patt db keys 
89a0: 72 75 6e 6e 61 6d 65 70 61 74 74 29 29 0a 09 20  runnamepatt)).. 
89b0: 28 68 65 61 64 65 72 20 20 20 20 20 20 20 28 76  (header       (v
89c0: 65 63 74 6f 72 2d 72 65 66 20 72 75 6e 64 61 74  ector-ref rundat
89d0: 20 30 29 29 0a 09 20 28 72 75 6e 73 20 20 20 20   0)).. (runs    
89e0: 20 20 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66       (vector-ref
89f0: 20 72 75 6e 64 61 74 20 31 29 29 0a 09 20 28 73   rundat 1)).. (s
8a00: 74 61 74 65 73 20 20 20 20 20 20 20 28 69 66 20  tates       (if 
8a10: 73 74 61 74 65 20 20 28 73 74 72 69 6e 67 2d 73  state  (string-s
8a20: 70 6c 69 74 20 73 74 61 74 65 20 20 22 2c 22 29  plit state  ",")
8a30: 20 27 28 29 29 29 0a 09 20 28 73 74 61 74 75 73   '())).. (status
8a40: 65 73 20 20 20 20 20 28 69 66 20 73 74 61 74 75  es     (if statu
8a50: 73 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20  s (string-split 
8a60: 73 74 61 74 75 73 20 22 2c 22 29 20 27 28 29 29  status ",") '())
8a70: 29 0a 09 20 28 73 74 61 74 65 2d 73 74 61 74 75  ).. (state-statu
8a80: 73 20 28 69 66 20 28 73 74 72 69 6e 67 3f 20 6e  s (if (string? n
8a90: 65 77 2d 73 74 61 74 65 2d 73 74 61 74 75 73 29  ew-state-status)
8aa0: 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 6e   (string-split n
8ab0: 65 77 2d 73 74 61 74 65 2d 73 74 61 74 75 73 20  ew-state-status 
8ac0: 22 2c 22 29 20 27 28 23 66 20 23 66 29 29 29 29  ",") '(#f #f))))
8ad0: 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e  .    (debug:prin
8ae0: 74 2d 69 6e 66 6f 20 34 20 22 72 75 6e 73 3a 6f  t-info 4 "runs:o
8af0: 70 65 72 61 74 65 2d 6f 6e 20 3d 3e 20 48 65 61  perate-on => Hea
8b00: 64 65 72 3a 20 22 20 68 65 61 64 65 72 20 22 20  der: " header " 
8b10: 61 63 74 69 6f 6e 3a 20 22 20 61 63 74 69 6f 6e  action: " action
8b20: 20 22 20 6e 65 77 2d 73 74 61 74 65 2d 73 74 61   " new-state-sta
8b30: 74 75 73 3a 20 22 20 6e 65 77 2d 73 74 61 74 65  tus: " new-state
8b40: 2d 73 74 61 74 75 73 29 0a 20 20 20 20 28 69 66  -status).    (if
8b50: 20 28 3e 20 32 20 28 6c 65 6e 67 74 68 20 73 74   (> 2 (length st
8b60: 61 74 65 2d 73 74 61 74 75 73 29 29 0a 09 28 62  ate-status))..(b
8b70: 65 67 69 6e 0a 09 20 20 28 64 65 62 75 67 3a 70  egin..  (debug:p
8b80: 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 74  rint 0 "ERROR: t
8b90: 68 65 20 70 61 72 61 6d 65 74 65 72 20 74 6f 20  he parameter to 
8ba0: 2d 73 65 74 2d 73 74 61 74 65 2d 73 74 61 74 75  -set-state-statu
8bb0: 73 20 69 73 20 61 20 63 6f 6d 6d 61 20 64 65 6c  s is a comma del
8bc0: 69 6d 69 74 65 64 20 73 74 72 69 6e 67 2e 20 45  imited string. E
8bd0: 2e 67 2e 20 43 4f 4d 50 4c 45 54 45 44 2c 46 41  .g. COMPLETED,FA
8be0: 49 4c 22 29 0a 09 20 20 28 65 78 69 74 29 29 29  IL")..  (exit)))
8bf0: 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 0a 20  .    (for-each. 
8c00: 20 20 20 20 28 6c 61 6d 62 64 61 20 28 72 75 6e      (lambda (run
8c10: 29 0a 20 20 20 20 20 20 20 28 6c 65 74 20 28 28  ).       (let ((
8c20: 72 75 6e 6b 65 79 20 28 73 74 72 69 6e 67 2d 69  runkey (string-i
8c30: 6e 74 65 72 73 70 65 72 73 65 20 28 6d 61 70 20  ntersperse (map 
8c40: 28 6c 61 6d 62 64 61 20 28 6b 29 0a 09 09 09 09  (lambda (k).....
8c50: 09 09 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d  ..(db:get-value-
8c60: 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65  by-header run he
8c70: 61 64 65 72 20 28 76 65 63 74 6f 72 2d 72 65 66  ader (vector-ref
8c80: 20 6b 20 30 29 29 29 20 6b 65 79 73 29 20 22 2f   k 0))) keys) "/
8c90: 22 29 29 0a 09 20 20 20 20 20 28 64 69 72 73 2d  "))..     (dirs-
8ca0: 74 6f 2d 72 65 6d 6f 76 65 20 28 6d 61 6b 65 2d  to-remove (make-
8cb0: 68 61 73 68 2d 74 61 62 6c 65 29 29 29 0a 09 20  hash-table))).. 
8cc0: 28 6c 65 74 2a 20 28 28 72 75 6e 2d 69 64 20 20  (let* ((run-id  
8cd0: 20 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d    (db:get-value-
8ce0: 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65  by-header run he
8cf0: 61 64 65 72 20 22 69 64 22 29 29 0a 09 09 28 72  ader "id"))...(r
8d00: 75 6e 2d 73 74 61 74 65 20 28 64 62 3a 67 65 74  un-state (db:get
8d10: 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72  -value-by-header
8d20: 20 72 75 6e 20 68 65 61 64 65 72 20 22 73 74 61   run header "sta
8d30: 74 65 22 29 29 0a 09 09 28 74 65 73 74 73 20 20  te"))...(tests  
8d40: 20 20 20 28 69 66 20 28 6e 6f 74 20 28 65 71 75     (if (not (equ
8d50: 61 6c 3f 20 72 75 6e 2d 73 74 61 74 65 20 22 6c  al? run-state "l
8d60: 6f 63 6b 65 64 22 29 29 0a 09 09 09 20 20 20 20  ocked"))....    
8d70: 20 20 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f     (open-run-clo
8d80: 73 65 20 64 62 3a 67 65 74 2d 74 65 73 74 73 2d  se db:get-tests-
8d90: 66 6f 72 2d 72 75 6e 20 64 62 20 72 75 6e 2d 69  for-run db run-i
8da0: 64 0a 09 09 09 09 09 09 20 20 20 20 20 20 74 65  d.......      te
8db0: 73 74 70 61 74 74 20 73 74 61 74 65 73 20 73 74  stpatt states st
8dc0: 61 74 75 73 65 73 0a 09 09 09 09 09 09 20 20 20  atuses.......   
8dd0: 20 20 20 6e 6f 74 2d 69 6e 3a 20 20 23 66 0a 09     not-in:  #f..
8de0: 09 09 09 09 09 20 20 20 20 20 20 73 6f 72 74 2d  .....      sort-
8df0: 62 79 3a 20 28 63 61 73 65 20 61 63 74 69 6f 6e  by: (case action
8e00: 0a 09 09 09 09 09 09 09 09 20 28 28 72 65 6d 6f  ......... ((remo
8e10: 76 65 2d 72 75 6e 73 29 20 27 72 75 6e 64 69 72  ve-runs) 'rundir
8e20: 29 0a 09 09 09 09 09 09 09 09 20 28 65 6c 73 65  )......... (else
8e30: 20 20 20 20 20 20 20 20 20 20 27 65 76 65 6e 74            'event
8e40: 5f 74 69 6d 65 29 29 29 0a 09 09 09 20 20 20 20  _time)))....    
8e50: 20 20 20 27 28 29 29 29 0a 09 09 28 6c 61 73 74     '()))...(last
8e60: 74 70 61 74 68 20 22 2f 64 6f 65 73 2f 6e 6f 74  tpath "/does/not
8e70: 2f 65 78 69 73 74 2f 49 2f 68 6f 70 65 22 29 29  /exist/I/hope"))
8e80: 0a 09 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e  ..   (debug:prin
8e90: 74 2d 69 6e 66 6f 20 34 20 22 72 75 6e 73 3a 6f  t-info 4 "runs:o
8ea0: 70 65 72 61 74 65 2d 6f 6e 20 72 75 6e 3d 22 20  perate-on run=" 
8eb0: 72 75 6e 20 22 2c 20 68 65 61 64 65 72 3d 22 20  run ", header=" 
8ec0: 68 65 61 64 65 72 29 0a 09 20 20 20 28 69 66 20  header)..   (if 
8ed0: 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 65 73 74  (not (null? test
8ee0: 73 29 29 0a 09 20 20 20 20 20 20 20 28 62 65 67  s))..       (beg
8ef0: 69 6e 0a 09 09 20 28 63 61 73 65 20 61 63 74 69  in... (case acti
8f00: 6f 6e 0a 09 09 20 20 20 28 28 72 65 6d 6f 76 65  on...   ((remove
8f10: 2d 72 75 6e 73 29 0a 09 09 20 20 20 20 28 64 65  -runs)...    (de
8f20: 62 75 67 3a 70 72 69 6e 74 20 31 20 22 52 65 6d  bug:print 1 "Rem
8f30: 6f 76 69 6e 67 20 74 65 73 74 73 20 66 6f 72 20  oving tests for 
8f40: 72 75 6e 3a 20 22 20 72 75 6e 6b 65 79 20 22 20  run: " runkey " 
8f50: 22 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d  " (db:get-value-
8f60: 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65  by-header run he
8f70: 61 64 65 72 20 22 72 75 6e 6e 61 6d 65 22 29 29  ader "runname"))
8f80: 29 0a 09 09 20 20 20 28 28 73 65 74 2d 73 74 61  )...   ((set-sta
8f90: 74 65 2d 73 74 61 74 75 73 29 0a 09 09 20 20 20  te-status)...   
8fa0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20   (debug:print 1 
8fb0: 22 4d 6f 64 69 66 79 69 6e 67 20 73 74 61 74 65  "Modifying state
8fc0: 20 61 6e 64 20 73 74 61 75 73 20 66 6f 72 20 74   and staus for t
8fd0: 65 73 74 73 20 66 6f 72 20 72 75 6e 3a 20 22 20  ests for run: " 
8fe0: 72 75 6e 6b 65 79 20 22 20 22 20 28 64 62 3a 67  runkey " " (db:g
8ff0: 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64  et-value-by-head
9000: 65 72 20 72 75 6e 20 68 65 61 64 65 72 20 22 72  er run header "r
9010: 75 6e 6e 61 6d 65 22 29 29 29 0a 09 09 20 20 20  unname")))...   
9020: 28 28 70 72 69 6e 74 2d 72 75 6e 29 0a 09 09 20  ((print-run)... 
9030: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
9040: 31 20 22 50 72 69 6e 74 69 6e 67 20 69 6e 66 6f  1 "Printing info
9050: 20 66 6f 72 20 72 75 6e 20 22 20 72 75 6e 6b 65   for run " runke
9060: 79 20 22 2c 20 72 75 6e 3d 22 20 72 75 6e 20 22  y ", run=" run "
9070: 2c 20 74 65 73 74 73 3d 22 20 74 65 73 74 73 20  , tests=" tests 
9080: 22 2c 20 68 65 61 64 65 72 3d 22 20 68 65 61 64  ", header=" head
9090: 65 72 29 0a 09 09 20 20 20 20 61 63 74 69 6f 6e  er)...    action
90a0: 29 0a 09 09 20 20 20 28 65 6c 73 65 0a 09 09 20  )...   (else... 
90b0: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 2d     (debug:print-
90c0: 69 6e 66 6f 20 30 20 22 61 63 74 69 6f 6e 20 6e  info 0 "action n
90d0: 6f 74 20 72 65 63 6f 67 6e 69 73 65 64 20 22 20  ot recognised " 
90e0: 61 63 74 69 6f 6e 29 29 29 0a 09 09 20 28 66 6f  action)))... (fo
90f0: 72 2d 65 61 63 68 0a 09 09 20 20 28 6c 61 6d 62  r-each...  (lamb
9100: 64 61 20 28 74 65 73 74 29 0a 09 09 20 20 20 20  da (test)...    
9110: 28 6c 65 74 2a 20 28 28 69 74 65 6d 2d 70 61 74  (let* ((item-pat
9120: 68 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69  h (db:test-get-i
9130: 74 65 6d 2d 70 61 74 68 20 74 65 73 74 29 29 0a  tem-path test)).
9140: 09 09 09 20 20 20 28 74 65 73 74 2d 6e 61 6d 65  ...   (test-name
9150: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 74 65   (db:test-get-te
9160: 73 74 6e 61 6d 65 20 74 65 73 74 29 29 0a 09 09  stname test))...
9170: 09 20 20 20 28 72 75 6e 2d 64 69 72 20 20 20 28  .   (run-dir   (
9180: 64 62 3a 74 65 73 74 2d 67 65 74 2d 72 75 6e 64  db:test-get-rund
9190: 69 72 20 74 65 73 74 29 29 20 20 20 20 3b 3b 20  ir test))    ;; 
91a0: 72 75 6e 20 64 69 72 20 69 73 20 66 72 6f 6d 20  run dir is from 
91b0: 74 68 65 20 6c 69 6e 6b 20 74 72 65 65 0a 09 09  the link tree...
91c0: 09 20 20 20 28 72 65 61 6c 2d 64 69 72 20 20 28  .   (real-dir  (
91d0: 69 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f  if (file-exists?
91e0: 20 72 75 6e 2d 64 69 72 29 0a 09 09 09 09 09 20   run-dir)...... 
91f0: 20 28 72 65 73 6f 6c 76 65 2d 70 61 74 68 6e 61   (resolve-pathna
9200: 6d 65 20 72 75 6e 2d 64 69 72 29 0a 09 09 09 09  me run-dir).....
9210: 09 20 20 23 66 29 29 0a 09 09 09 20 20 20 28 74  .  #f))....   (t
9220: 65 73 74 2d 69 64 20 20 20 28 64 62 3a 74 65 73  est-id   (db:tes
9230: 74 2d 67 65 74 2d 69 64 20 74 65 73 74 29 29 29  t-get-id test)))
9240: 0a 09 09 20 20 20 20 20 20 3b 3b 20 20 20 28 74  ...      ;;   (t
9250: 64 62 20 20 20 20 20 20 20 28 64 62 3a 6f 70 65  db       (db:ope
9260: 6e 2d 74 65 73 74 2d 64 62 20 72 75 6e 2d 64 69  n-test-db run-di
9270: 72 29 29 29 0a 09 09 20 20 20 20 20 20 28 64 65  r)))...      (de
9280: 62 75 67 3a 70 72 69 6e 74 2d 69 6e 66 6f 20 34  bug:print-info 4
9290: 20 22 74 65 73 74 3d 22 20 74 65 73 74 29 20 3b   "test=" test) ;
92a0: 3b 20 20 20 22 20 28 64 62 3a 74 65 73 74 2d 67  ;   " (db:test-g
92b0: 65 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74  et-testname test
92c0: 29 20 22 20 69 64 3a 20 22 20 28 64 62 3a 74 65  ) " id: " (db:te
92d0: 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74 29 20  st-get-id test) 
92e0: 22 20 22 20 69 74 65 6d 2d 70 61 74 68 20 22 20  " " item-path " 
92f0: 61 63 74 69 6f 6e 3a 20 22 20 61 63 74 69 6f 6e  action: " action
9300: 29 0a 09 09 20 20 20 20 20 20 28 63 61 73 65 20  )...      (case 
9310: 61 63 74 69 6f 6e 0a 09 09 09 28 28 72 65 6d 6f  action....((remo
9320: 76 65 2d 72 75 6e 73 29 20 3b 3b 20 74 68 65 20  ve-runs) ;; the 
9330: 74 64 62 20 69 73 20 66 6f 72 20 66 75 74 75 72  tdb is for futur
9340: 65 20 70 6f 73 73 69 62 6c 65 2e 20 0a 09 09 09  e possible. ....
9350: 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65   (open-run-close
9360: 20 64 62 3a 64 65 6c 65 74 65 2d 74 65 73 74 2d   db:delete-test-
9370: 72 65 63 6f 72 64 73 20 64 62 20 23 66 20 28 64  records db #f (d
9380: 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65  b:test-get-id te
9390: 73 74 29 29 0a 09 09 09 20 28 64 65 62 75 67 3a  st)).... (debug:
93a0: 70 72 69 6e 74 2d 69 6e 66 6f 20 31 20 22 41 74  print-info 1 "At
93b0: 74 65 6d 70 74 69 6e 67 20 74 6f 20 72 65 6d 6f  tempting to remo
93c0: 76 65 20 22 20 28 69 66 20 72 65 61 6c 2d 64 69  ve " (if real-di
93d0: 72 20 28 63 6f 6e 63 20 22 20 64 69 72 20 22 20  r (conc " dir " 
93e0: 72 65 61 6c 2d 64 69 72 20 22 20 61 6e 64 20 22  real-dir " and "
93f0: 29 20 22 22 29 20 22 20 6c 69 6e 6b 20 22 20 72  ) "") " link " r
9400: 75 6e 2d 64 69 72 29 0a 09 09 09 20 28 69 66 20  un-dir).... (if 
9410: 28 61 6e 64 20 72 65 61 6c 2d 64 69 72 20 0a 09  (and real-dir ..
9420: 09 09 09 20 20 28 3e 20 28 73 74 72 69 6e 67 2d  ...  (> (string-
9430: 6c 65 6e 67 74 68 20 72 65 61 6c 2d 64 69 72 29  length real-dir)
9440: 20 35 29 0a 09 09 09 09 20 20 28 66 69 6c 65 2d   5).....  (file-
9450: 65 78 69 73 74 73 3f 20 72 65 61 6c 2d 64 69 72  exists? real-dir
9460: 29 29 20 3b 3b 20 62 61 64 20 68 65 75 72 69 73  )) ;; bad heuris
9470: 74 69 63 20 62 75 74 20 73 68 6f 75 6c 64 20 70  tic but should p
9480: 72 65 76 65 6e 74 20 2f 74 6d 70 20 2f 68 6f 6d  revent /tmp /hom
9490: 65 20 65 74 63 2e 0a 09 09 09 20 20 20 20 20 28  e etc.....     (
94a0: 62 65 67 69 6e 20 3b 3b 20 6c 65 74 2a 20 28 28  begin ;; let* ((
94b0: 72 65 61 6c 70 61 74 68 20 28 72 65 73 6f 6c 76  realpath (resolv
94c0: 65 2d 70 61 74 68 6e 61 6d 65 20 72 75 6e 2d 64  e-pathname run-d
94d0: 69 72 29 29 29 0a 09 09 09 20 20 20 20 20 20 20  ir)))....       
94e0: 28 64 65 62 75 67 3a 70 72 69 6e 74 2d 69 6e 66  (debug:print-inf
94f0: 6f 20 31 20 22 52 65 63 75 72 73 69 76 65 6c 79  o 1 "Recursively
9500: 20 72 65 6d 6f 76 69 6e 67 20 22 20 72 65 61 6c   removing " real
9510: 2d 64 69 72 29 0a 09 09 09 20 20 20 20 20 20 20  -dir)....       
9520: 28 69 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73  (if (file-exists
9530: 3f 20 72 65 61 6c 2d 64 69 72 29 0a 09 09 09 09  ? real-dir).....
9540: 20 20 20 28 69 66 20 28 3e 20 28 73 79 73 74 65     (if (> (syste
9550: 6d 20 28 63 6f 6e 63 20 22 72 6d 20 2d 72 66 20  m (conc "rm -rf 
9560: 22 20 72 65 61 6c 2d 64 69 72 29 29 20 30 29 0a  " real-dir)) 0).
9570: 09 09 09 09 20 20 20 20 20 20 20 28 64 65 62 75  ....       (debu
9580: 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52  g:print 0 "ERROR
9590: 3a 20 54 68 65 72 65 20 77 61 73 20 61 20 70 72  : There was a pr
95a0: 6f 62 6c 65 6d 20 72 65 6d 6f 76 69 6e 67 20 22  oblem removing "
95b0: 20 72 65 61 6c 2d 64 69 72 20 22 20 77 69 74 68   real-dir " with
95c0: 20 72 6d 20 2d 66 22 29 29 0a 09 09 09 09 20 20   rm -f")).....  
95d0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
95e0: 22 57 41 52 4e 49 4e 47 3a 20 74 65 73 74 20 64  "WARNING: test d
95f0: 69 72 20 22 20 72 65 61 6c 2d 64 69 72 20 22 20  ir " real-dir " 
9600: 61 70 70 65 61 72 73 20 74 6f 20 6e 6f 74 20 65  appears to not e
9610: 78 69 73 74 20 6f 72 20 69 73 20 6e 6f 74 20 72  xist or is not r
9620: 65 61 64 61 62 6c 65 22 29 29 29 0a 09 09 09 20  eadable"))).... 
9630: 20 20 20 20 28 69 66 20 72 65 61 6c 2d 64 69 72      (if real-dir
9640: 20 0a 09 09 09 09 20 28 64 65 62 75 67 3a 70 72   ..... (debug:pr
9650: 69 6e 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20  int 0 "WARNING: 
9660: 64 69 72 65 63 74 6f 72 79 20 22 20 72 65 61 6c  directory " real
9670: 2d 64 69 72 20 22 20 64 6f 65 73 20 6e 6f 74 20  -dir " does not 
9680: 65 78 69 73 74 22 29 0a 09 09 09 09 20 28 64 65  exist")..... (de
9690: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52  bug:print 0 "WAR
96a0: 4e 49 4e 47 3a 20 6e 6f 20 72 65 61 6c 20 64 69  NING: no real di
96b0: 72 65 63 74 6f 72 79 20 63 6f 72 72 6f 73 70 6f  rectory corrospo
96c0: 6e 64 69 6e 67 20 74 6f 20 6c 69 6e 6b 20 22 20  nding to link " 
96d0: 72 75 6e 2d 64 69 72 20 22 2c 20 6e 6f 74 68 69  run-dir ", nothi
96e0: 6e 67 20 64 6f 6e 65 22 29 29 29 0a 09 09 09 20  ng done"))).... 
96f0: 28 69 66 20 28 73 79 6d 62 6f 6c 69 63 2d 6c 69  (if (symbolic-li
9700: 6e 6b 3f 20 72 75 6e 2d 64 69 72 29 0a 09 09 09  nk? run-dir)....
9710: 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09 09 20       (begin.... 
9720: 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69        (debug:pri
9730: 6e 74 2d 69 6e 66 6f 20 31 20 22 52 65 6d 6f 76  nt-info 1 "Remov
9740: 69 6e 67 20 73 79 6d 6c 69 6e 6b 20 22 20 72 75  ing symlink " ru
9750: 6e 2d 64 69 72 29 0a 09 09 09 20 20 20 20 20 20  n-dir)....      
9760: 20 28 64 65 6c 65 74 65 2d 66 69 6c 65 20 72 75   (delete-file ru
9770: 6e 2d 64 69 72 29 29 0a 09 09 09 20 20 20 20 20  n-dir))....     
9780: 28 69 66 20 28 64 69 72 65 63 74 6f 72 79 3f 20  (if (directory? 
9790: 72 75 6e 2d 64 69 72 29 0a 09 09 09 09 20 28 69  run-dir)..... (i
97a0: 66 20 28 3e 20 28 64 69 72 65 63 74 6f 72 79 2d  f (> (directory-
97b0: 66 6f 6c 64 20 28 6c 61 6d 62 64 61 20 28 66 20  fold (lambda (f 
97c0: 78 29 28 2b 20 31 20 78 29 29 20 30 20 72 75 6e  x)(+ 1 x)) 0 run
97d0: 2d 64 69 72 29 20 30 29 0a 09 09 09 09 20 20 20  -dir) 0).....   
97e0: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30    (debug:print 0
97f0: 20 22 57 41 52 4e 49 4e 47 3a 20 72 65 66 75 73   "WARNING: refus
9800: 69 6e 67 20 74 6f 20 72 65 6d 6f 76 65 20 22 20  ing to remove " 
9810: 72 75 6e 2d 64 69 72 20 22 20 61 73 20 69 74 20  run-dir " as it 
9820: 69 73 20 6e 6f 74 20 65 6d 70 74 79 22 29 0a 09  is not empty")..
9830: 09 09 09 20 20 20 20 20 28 64 65 6c 65 74 65 2d  ...     (delete-
9840: 64 69 72 65 63 74 6f 72 79 20 72 75 6e 2d 64 69  directory run-di
9850: 72 29 29 20 3b 3b 20 69 74 20 73 68 6f 75 6c 64  r)) ;; it should
9860: 20 62 65 20 65 6d 70 74 79 20 62 79 20 68 65 72   be empty by her
9870: 65 20 42 55 47 20 42 55 47 2c 20 61 64 64 20 65  e BUG BUG, add e
9880: 72 72 6f 72 20 63 61 74 63 68 0a 09 09 09 09 20  rror catch..... 
9890: 28 69 66 20 72 75 6e 2d 64 69 72 0a 09 09 09 09  (if run-dir.....
98a0: 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e       (debug:prin
98b0: 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 6e 6f  t 0 "WARNING: no
98c0: 74 20 72 65 6d 6f 76 69 6e 67 20 22 20 72 75 6e  t removing " run
98d0: 2d 64 69 72 20 22 20 61 73 20 69 74 20 65 69 74  -dir " as it eit
98e0: 68 65 72 20 64 6f 65 73 6e 27 74 20 65 78 69 73  her doesn't exis
98f0: 74 20 6f 72 20 69 73 20 6e 6f 74 20 61 20 73 79  t or is not a sy
9900: 6d 6c 69 6e 6b 22 29 0a 09 09 09 09 20 20 20 20  mlink").....    
9910: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
9920: 22 4e 4f 54 45 3a 20 74 68 65 20 72 75 6e 20 64  "NOTE: the run d
9930: 69 72 20 66 6f 72 20 74 68 69 73 20 74 65 73 74  ir for this test
9940: 20 69 73 20 75 6e 64 65 66 69 6e 65 64 2e 20 54   is undefined. T
9950: 65 73 74 20 6d 61 79 20 68 61 76 65 20 61 6c 72  est may have alr
9960: 65 61 64 79 20 62 65 65 6e 20 64 65 6c 65 74 65  eady been delete
9970: 64 2e 22 29 29 0a 09 09 09 09 20 29 29 29 0a 09  d."))..... )))..
9980: 09 09 28 28 73 65 74 2d 73 74 61 74 65 2d 73 74  ..((set-state-st
9990: 61 74 75 73 29 0a 09 09 09 20 28 64 65 62 75 67  atus).... (debug
99a0: 3a 70 72 69 6e 74 2d 69 6e 66 6f 20 32 20 22 6e  :print-info 2 "n
99b0: 65 77 20 73 74 61 74 65 20 22 20 28 63 61 72 20  ew state " (car 
99c0: 73 74 61 74 65 2d 73 74 61 74 75 73 29 20 22 2c  state-status) ",
99d0: 20 6e 65 77 20 73 74 61 74 75 73 20 22 20 28 63   new status " (c
99e0: 61 64 72 20 73 74 61 74 65 2d 73 74 61 74 75 73  adr state-status
99f0: 29 29 0a 09 09 09 20 28 6f 70 65 6e 2d 72 75 6e  )).... (open-run
9a00: 2d 63 6c 6f 73 65 20 64 62 3a 74 65 73 74 2d 73  -close db:test-s
9a10: 65 74 2d 73 74 61 74 65 2d 73 74 61 74 75 73 2d  et-state-status-
9a20: 62 79 2d 69 64 20 64 62 20 28 64 62 3a 74 65 73  by-id db (db:tes
9a30: 74 2d 67 65 74 2d 69 64 20 74 65 73 74 29 20 28  t-get-id test) (
9a40: 63 61 72 20 73 74 61 74 65 2d 73 74 61 74 75 73  car state-status
9a50: 29 28 63 61 64 72 20 73 74 61 74 65 2d 73 74 61  )(cadr state-sta
9a60: 74 75 73 29 20 23 66 29 29 29 29 29 0a 09 09 20  tus) #f)))))... 
9a70: 20 28 73 6f 72 74 20 74 65 73 74 73 20 28 6c 61   (sort tests (la
9a80: 6d 62 64 61 20 28 61 20 62 29 28 6c 65 74 20 28  mbda (a b)(let (
9a90: 28 64 69 72 61 20 28 64 62 3a 74 65 73 74 2d 67  (dira (db:test-g
9aa0: 65 74 2d 72 75 6e 64 69 72 20 61 29 29 0a 09 09  et-rundir a))...
9ab0: 09 09 09 09 20 28 64 69 72 62 20 28 64 62 3a 74  .... (dirb (db:t
9ac0: 65 73 74 2d 67 65 74 2d 72 75 6e 64 69 72 20 62  est-get-rundir b
9ad0: 29 29 29 0a 09 09 09 09 09 20 20 20 20 20 28 69  )))......     (i
9ae0: 66 20 28 61 6e 64 20 28 73 74 72 69 6e 67 3f 20  f (and (string? 
9af0: 64 69 72 61 29 28 73 74 72 69 6e 67 3f 20 64 69  dira)(string? di
9b00: 72 62 29 29 0a 09 09 09 09 09 09 20 28 3e 20 28  rb))....... (> (
9b10: 73 74 72 69 6e 67 2d 6c 65 6e 67 74 68 20 64 69  string-length di
9b20: 72 61 29 28 73 74 72 69 6e 67 2d 6c 65 6e 67 74  ra)(string-lengt
9b30: 68 20 64 69 72 62 29 29 0a 09 09 09 09 09 09 20  h dirb))....... 
9b40: 23 66 29 29 29 29 29 29 29 0a 09 20 20 20 3b 3b  #f)))))))..   ;;
9b50: 20 72 65 6d 6f 76 65 20 74 68 65 20 72 75 6e 20   remove the run 
9b60: 69 66 20 7a 65 72 6f 20 74 65 73 74 73 20 72 65  if zero tests re
9b70: 6d 61 69 6e 0a 09 20 20 20 28 69 66 20 28 65 71  main..   (if (eq
9b80: 3f 20 61 63 74 69 6f 6e 20 27 72 65 6d 6f 76 65  ? action 'remove
9b90: 2d 72 75 6e 73 29 0a 09 20 20 20 20 20 20 20 28  -runs)..       (
9ba0: 6c 65 74 20 28 28 72 65 6d 74 65 73 74 73 20 28  let ((remtests (
9bb0: 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 64  open-run-close d
9bc0: 62 3a 67 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d  b:get-tests-for-
9bd0: 72 75 6e 20 64 62 20 28 64 62 3a 67 65 74 2d 76  run db (db:get-v
9be0: 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72  alue-by-header r
9bf0: 75 6e 20 68 65 61 64 65 72 20 22 69 64 22 29 20  un header "id") 
9c00: 23 66 20 27 28 22 44 45 4c 45 54 45 44 22 29 20  #f '("DELETED") 
9c10: 27 28 22 6e 2f 61 22 29 20 6e 6f 74 2d 69 6e 3a  '("n/a") not-in:
9c20: 20 23 74 29 29 29 0a 09 09 20 28 69 66 20 28 6e   #t)))... (if (n
9c30: 75 6c 6c 3f 20 72 65 6d 74 65 73 74 73 29 20 3b  ull? remtests) ;
9c40: 3b 20 6e 6f 20 6d 6f 72 65 20 74 65 73 74 73 20  ; no more tests 
9c50: 72 65 6d 61 69 6e 69 6e 67 0a 09 09 20 20 20 20  remaining...    
9c60: 20 28 6c 65 74 2a 20 28 28 64 70 61 72 74 73 20   (let* ((dparts 
9c70: 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 6c   (string-split l
9c80: 61 73 74 74 70 61 74 68 20 22 2f 22 29 29 0a 09  asttpath "/"))..
9c90: 09 09 20 20 20 20 28 72 75 6e 70 61 74 68 20 28  ..    (runpath (
9ca0: 63 6f 6e 63 20 22 2f 22 20 28 73 74 72 69 6e 67  conc "/" (string
9cb0: 2d 69 6e 74 65 72 73 70 65 72 73 65 20 0a 09 09  -intersperse ...
9cc0: 09 09 09 09 28 74 61 6b 65 20 64 70 61 72 74 73  ....(take dparts
9cd0: 20 28 2d 20 28 6c 65 6e 67 74 68 20 64 70 61 72   (- (length dpar
9ce0: 74 73 29 20 31 29 29 0a 09 09 09 09 09 09 22 2f  ts) 1))......."/
9cf0: 22 29 29 29 29 0a 09 09 20 20 20 20 20 20 20 28  "))))...       (
9d00: 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 52  debug:print 1 "R
9d10: 65 6d 6f 76 69 6e 67 20 72 75 6e 3a 20 22 20 72  emoving run: " r
9d20: 75 6e 6b 65 79 20 22 20 22 20 28 64 62 3a 67 65  unkey " " (db:ge
9d30: 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65  t-value-by-heade
9d40: 72 20 72 75 6e 20 68 65 61 64 65 72 20 22 72 75  r run header "ru
9d50: 6e 6e 61 6d 65 22 29 20 22 20 61 6e 64 20 72 65  nname") " and re
9d60: 6c 61 74 65 64 20 72 65 63 6f 72 64 22 29 0a 09  lated record")..
9d70: 09 20 20 20 20 20 20 20 28 6f 70 65 6e 2d 72 75  .       (open-ru
9d80: 6e 2d 63 6c 6f 73 65 20 64 62 3a 64 65 6c 65 74  n-close db:delet
9d90: 65 2d 72 75 6e 20 64 62 20 72 75 6e 2d 69 64 29  e-run db run-id)
9da0: 0a 09 09 20 20 20 20 20 20 20 3b 3b 20 54 68 69  ...       ;; Thi
9db0: 73 20 69 73 20 61 20 70 72 65 74 74 79 20 67 6f  s is a pretty go
9dc0: 6f 64 20 70 6c 61 63 65 20 74 6f 20 70 75 72 67  od place to purg
9dd0: 65 20 6f 6c 64 20 44 45 4c 45 54 45 44 20 74 65  e old DELETED te
9de0: 73 74 73 0a 09 09 20 20 20 20 20 20 20 28 6f 70  sts...       (op
9df0: 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 64 62 3a  en-run-close db:
9e00: 64 65 6c 65 74 65 2d 74 65 73 74 73 2d 66 6f 72  delete-tests-for
9e10: 2d 72 75 6e 20 64 62 20 72 75 6e 2d 69 64 29 0a  -run db run-id).
9e20: 09 09 20 20 20 20 20 20 20 28 6f 70 65 6e 2d 72  ..       (open-r
9e30: 75 6e 2d 63 6c 6f 73 65 20 64 62 3a 64 65 6c 65  un-close db:dele
9e40: 74 65 2d 6f 6c 64 2d 64 65 6c 65 74 65 64 2d 74  te-old-deleted-t
9e50: 65 73 74 2d 72 65 63 6f 72 64 73 20 64 62 29 0a  est-records db).
9e60: 09 09 20 20 20 20 20 20 20 28 6f 70 65 6e 2d 72  ..       (open-r
9e70: 75 6e 2d 63 6c 6f 73 65 20 64 62 3a 73 65 74 2d  un-close db:set-
9e80: 76 61 72 20 64 62 20 22 44 45 4c 45 54 45 44 5f  var db "DELETED_
9e90: 54 45 53 54 53 22 20 28 63 75 72 72 65 6e 74 2d  TESTS" (current-
9ea0: 73 65 63 6f 6e 64 73 29 29 0a 09 09 20 20 20 20  seconds))...    
9eb0: 20 20 20 3b 3b 20 6e 65 65 64 20 74 6f 20 66 69     ;; need to fi
9ec0: 67 75 72 65 20 6f 75 74 20 74 68 65 20 70 61 74  gure out the pat
9ed0: 68 20 74 6f 20 74 68 65 20 72 75 6e 20 64 69 72  h to the run dir
9ee0: 20 61 6e 64 20 72 65 6d 6f 76 65 20 69 74 20 69   and remove it i
9ef0: 66 20 65 6d 70 74 79 0a 09 09 20 20 20 20 20 20  f empty...      
9f00: 20 3b 3b 20 20 20 20 28 69 66 20 28 6e 75 6c 6c   ;;    (if (null
9f10: 3f 20 28 67 6c 6f 62 20 28 63 6f 6e 63 20 72 75  ? (glob (conc ru
9f20: 6e 70 61 74 68 20 22 2f 2a 22 29 29 29 0a 09 09  npath "/*")))...
9f30: 20 20 20 20 20 20 20 3b 3b 20 20 20 20 20 20 20         ;;       
9f40: 20 28 62 65 67 69 6e 0a 09 09 20 20 20 20 20 20   (begin...      
9f50: 20 3b 3b 20 09 20 28 64 65 62 75 67 3a 70 72 69   ;; . (debug:pri
9f60: 6e 74 20 31 20 22 52 65 6d 6f 76 69 6e 67 20 72  nt 1 "Removing r
9f70: 75 6e 20 64 69 72 20 22 20 72 75 6e 70 61 74 68  un dir " runpath
9f80: 29 0a 09 09 20 20 20 20 20 20 20 3b 3b 20 09 20  )...       ;; . 
9f90: 28 73 79 73 74 65 6d 20 28 63 6f 6e 63 20 22 72  (system (conc "r
9fa0: 6d 64 69 72 20 2d 70 20 22 20 72 75 6e 70 61 74  mdir -p " runpat
9fb0: 68 29 29 29 29 0a 09 09 20 20 20 20 20 20 20 29  h))))...       )
9fc0: 29 29 29 29 0a 09 20 29 29 0a 20 20 20 20 20 72  )))).. )).     r
9fd0: 75 6e 73 29 29 0a 20 20 23 74 29 0a 0a 3b 3b 3d  uns)).  #t)..;;=
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 3d 3d 3d 3d 3d 3d 3d  ================
a020: 3d 3d 3d 3d 3d 0a 3b 3b 20 52 6f 75 74 69 6e 65  =====.;; Routine
a030: 73 20 66 6f 72 20 6d 61 6e 69 70 75 6c 61 74 69  s for manipulati
a040: 6e 67 20 72 75 6e 73 0a 3b 3b 3d 3d 3d 3d 3d 3d  ng runs.;;======
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 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
a080: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
a090: 0a 0a 3b 3b 20 53 69 6e 63 65 20 6d 61 6e 79 20  ..;; Since many 
a0a0: 63 61 6c 6c 73 20 74 6f 20 61 20 72 75 6e 20 72  calls to a run r
a0b0: 65 71 75 69 72 65 20 70 72 65 74 74 79 20 6d 75  equire pretty mu
a0c0: 63 68 20 74 68 65 20 73 61 6d 65 20 73 65 74 75  ch the same setu
a0d0: 70 20 0a 3b 3b 20 74 68 69 73 20 77 72 61 70 70  p .;; this wrapp
a0e0: 65 72 20 69 73 20 75 73 65 64 20 74 6f 20 72 65  er is used to re
a0f0: 64 75 63 65 20 74 68 65 20 72 65 70 6c 69 63 61  duce the replica
a100: 74 69 6f 6e 20 6f 66 20 63 6f 64 65 0a 28 64 65  tion of code.(de
a110: 66 69 6e 65 20 28 67 65 6e 65 72 61 6c 2d 72 75  fine (general-ru
a120: 6e 2d 63 61 6c 6c 20 73 77 69 74 63 68 6e 61 6d  n-call switchnam
a130: 65 20 61 63 74 69 6f 6e 2d 64 65 73 63 20 70 72  e action-desc pr
a140: 6f 63 29 0a 20 20 28 6c 65 74 20 28 28 72 75 6e  oc).  (let ((run
a150: 6e 61 6d 65 20 28 61 72 67 73 3a 67 65 74 2d 61  name (args:get-a
a160: 72 67 20 22 3a 72 75 6e 6e 61 6d 65 22 29 29 0a  rg ":runname")).
a170: 09 28 74 61 72 67 65 74 20 20 28 69 66 20 28 61  .(target  (if (a
a180: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 74 61  rgs:get-arg "-ta
a190: 72 67 65 74 22 29 0a 09 09 20 20 20 20 20 28 61  rget")...     (a
a1a0: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 74 61  rgs:get-arg "-ta
a1b0: 72 67 65 74 22 29 0a 09 09 20 20 20 20 20 28 61  rget")...     (a
a1c0: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65  rgs:get-arg "-re
a1d0: 71 74 61 72 67 22 29 29 29 0a 09 28 74 68 31 20  qtarg")))..(th1 
a1e0: 20 20 20 20 23 66 29 29 0a 20 20 20 20 28 63 6f      #f)).    (co
a1f0: 6e 64 0a 20 20 20 20 20 28 28 6e 6f 74 20 74 61  nd.     ((not ta
a200: 72 67 65 74 29 0a 20 20 20 20 20 20 28 64 65 62  rget).      (deb
a210: 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f  ug:print 0 "ERRO
a220: 52 3a 20 4d 69 73 73 69 6e 67 20 72 65 71 75 69  R: Missing requi
a230: 72 65 64 20 70 61 72 61 6d 65 74 65 72 20 66 6f  red parameter fo
a240: 72 20 22 20 73 77 69 74 63 68 6e 61 6d 65 20 22  r " switchname "
a250: 2c 20 79 6f 75 20 6d 75 73 74 20 73 70 65 63 69  , you must speci
a260: 66 79 20 74 68 65 20 74 61 72 67 65 74 20 77 69  fy the target wi
a270: 74 68 20 2d 74 61 72 67 65 74 22 29 0a 20 20 20  th -target").   
a280: 20 20 20 28 65 78 69 74 20 33 29 29 0a 20 20 20     (exit 3)).   
a290: 20 20 28 28 6e 6f 74 20 72 75 6e 6e 61 6d 65 29    ((not runname)
a2a0: 0a 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72  .      (debug:pr
a2b0: 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 4d 69  int 0 "ERROR: Mi
a2c0: 73 73 69 6e 67 20 72 65 71 75 69 72 65 64 20 70  ssing required p
a2d0: 61 72 61 6d 65 74 65 72 20 66 6f 72 20 22 20 73  arameter for " s
a2e0: 77 69 74 63 68 6e 61 6d 65 20 22 2c 20 79 6f 75  witchname ", you
a2f0: 20 6d 75 73 74 20 73 70 65 63 69 66 79 20 74 68   must specify th
a300: 65 20 72 75 6e 20 6e 61 6d 65 20 77 69 74 68 20  e run name with 
a310: 3a 72 75 6e 6e 61 6d 65 20 72 75 6e 6e 61 6d 65  :runname runname
a320: 22 29 0a 20 20 20 20 20 20 28 65 78 69 74 20 33  ").      (exit 3
a330: 29 29 0a 20 20 20 20 20 28 65 6c 73 65 0a 20 20  )).     (else.  
a340: 20 20 20 20 28 6c 65 74 20 28 28 64 62 20 20 20      (let ((db   
a350: 23 66 29 0a 09 20 20 20 20 28 6b 65 79 73 20 23  #f)..    (keys #
a360: 66 29 29 0a 09 28 69 66 20 28 6e 6f 74 20 28 73  f))..(if (not (s
a370: 65 74 75 70 2d 66 6f 72 2d 72 75 6e 29 29 0a 09  etup-for-run))..
a380: 20 20 20 20 28 62 65 67 69 6e 20 0a 09 20 20 20      (begin ..   
a390: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
a3a0: 30 20 22 46 61 69 6c 65 64 20 74 6f 20 73 65 74  0 "Failed to set
a3b0: 75 70 2c 20 65 78 69 74 69 6e 67 22 29 0a 09 20  up, exiting").. 
a3c0: 20 20 20 20 20 28 65 78 69 74 20 31 29 29 29 0a       (exit 1))).
a3d0: 09 28 69 66 20 28 61 72 67 73 3a 67 65 74 2d 61  .(if (args:get-a
a3e0: 72 67 20 22 2d 73 65 72 76 65 72 22 29 0a 09 20  rg "-server").. 
a3f0: 20 20 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f     (open-run-clo
a400: 73 65 20 73 65 72 76 65 72 3a 73 74 61 72 74 20  se server:start 
a410: 64 62 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67  db (args:get-arg
a420: 20 22 2d 73 65 72 76 65 72 22 29 29 0a 20 09 20   "-server")). . 
a430: 20 20 20 28 69 66 20 28 6e 6f 74 20 28 6f 72 20     (if (not (or 
a440: 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d  (args:get-arg "-
a450: 72 75 6e 61 6c 6c 22 29 20 20 20 20 20 3b 3b 20  runall")     ;; 
a460: 72 75 6e 61 6c 6c 20 61 6e 64 20 72 75 6e 74 65  runall and runte
a470: 73 74 73 20 61 72 65 20 61 6c 6c 6f 77 65 64 20  sts are allowed 
a480: 74 6f 20 62 65 20 73 65 72 76 65 72 73 0a 20 09  to be servers. .
a490: 09 09 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67  .. (args:get-arg
a4a0: 20 22 2d 72 75 6e 74 65 73 74 73 22 29 29 29 0a   "-runtests"))).
a4b0: 09 09 28 73 65 72 76 65 72 3a 63 6c 69 65 6e 74  ..(server:client
a4c0: 2d 73 65 74 75 70 29 20 3b 3b 20 54 68 69 73 20  -setup) ;; This 
a4d0: 69 73 20 61 20 64 75 70 6c 69 63 61 74 65 20 73  is a duplicate s
a4e0: 74 61 72 74 75 70 21 21 21 3f 3f 3f 20 42 55 47  tartup!!!??? BUG
a4f0: 3f 0a 09 09 29 29 0a 09 28 73 65 74 21 20 6b 65  ?...))..(set! ke
a500: 79 73 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f  ys (open-run-clo
a510: 73 65 20 64 62 3a 67 65 74 2d 6b 65 79 73 20 64  se db:get-keys d
a520: 62 29 29 0a 09 3b 3b 20 68 61 76 65 20 65 6e 6f  b))..;; have eno
a530: 75 67 68 20 74 6f 20 70 72 6f 63 65 73 73 20 2d  ugh to process -
a540: 74 61 72 67 65 74 20 6f 72 20 2d 72 65 71 74 61  target or -reqta
a550: 72 67 20 68 65 72 65 0a 09 28 69 66 20 28 61 72  rg here..(if (ar
a560: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65 71  gs:get-arg "-req
a570: 74 61 72 67 22 29 0a 09 20 20 20 20 28 6c 65 74  targ")..    (let
a580: 2a 20 28 28 72 75 6e 63 6f 6e 66 69 67 66 20 28  * ((runconfigf (
a590: 63 6f 6e 63 20 20 2a 74 6f 70 70 61 74 68 2a 20  conc  *toppath* 
a5a0: 22 2f 72 75 6e 63 6f 6e 66 69 67 73 2e 63 6f 6e  "/runconfigs.con
a5b0: 66 69 67 22 29 29 20 3b 3b 20 44 4f 20 4e 4f 54  fig")) ;; DO NOT
a5c0: 20 45 56 41 4c 55 41 54 45 20 41 4c 4c 20 0a 09   EVALUATE ALL ..
a5d0: 09 20 20 20 28 72 75 6e 63 6f 6e 66 69 67 20 20  .   (runconfig  
a5e0: 28 72 65 61 64 2d 63 6f 6e 66 69 67 20 72 75 6e  (read-config run
a5f0: 63 6f 6e 66 69 67 66 20 23 66 20 23 66 20 65 6e  configf #f #f en
a600: 76 69 72 6f 6e 2d 70 61 74 74 3a 20 23 66 29 29  viron-patt: #f))
a610: 29 20 0a 09 20 20 20 20 20 20 28 69 66 20 28 68  ) ..      (if (h
a620: 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65  ash-table-ref/de
a630: 66 61 75 6c 74 20 72 75 6e 63 6f 6e 66 69 67 20  fault runconfig 
a640: 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d  (args:get-arg "-
a650: 72 65 71 74 61 72 67 22 29 20 23 66 29 0a 09 09  reqtarg") #f)...
a660: 20 20 28 6b 65 79 73 3a 74 61 72 67 65 74 2d 73    (keys:target-s
a670: 65 74 2d 61 72 67 73 20 6b 65 79 73 20 28 61 72  et-args keys (ar
a680: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65 71  gs:get-arg "-req
a690: 74 61 72 67 22 29 20 61 72 67 73 3a 61 72 67 2d  targ") args:arg-
a6a0: 68 61 73 68 29 0a 09 09 20 20 28 62 65 67 69 6e  hash)...  (begin
a6b0: 0a 09 09 20 20 20 20 28 64 65 62 75 67 3a 70 72  ...    (debug:pr
a6c0: 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 5b 22  int 0 "ERROR: ["
a6d0: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22   (args:get-arg "
a6e0: 2d 72 65 71 74 61 72 67 22 29 20 22 5d 20 6e 6f  -reqtarg") "] no
a6f0: 74 20 66 6f 75 6e 64 20 69 6e 20 22 20 72 75 6e  t found in " run
a700: 63 6f 6e 66 69 67 66 29 0a 09 09 20 20 20 20 28  configf)...    (
a710: 69 66 20 64 62 20 28 73 71 6c 69 74 65 33 3a 66  if db (sqlite3:f
a720: 69 6e 61 6c 69 7a 65 21 20 64 62 29 29 0a 09 09  inalize! db))...
a730: 20 20 20 20 28 65 78 69 74 20 31 29 29 29 29 0a      (exit 1)))).
a740: 09 20 20 20 20 28 69 66 20 28 61 72 67 73 3a 67  .    (if (args:g
a750: 65 74 2d 61 72 67 20 22 2d 74 61 72 67 65 74 22  et-arg "-target"
a760: 29 0a 09 09 28 6b 65 79 73 3a 74 61 72 67 65 74  )...(keys:target
a770: 2d 73 65 74 2d 61 72 67 73 20 6b 65 79 73 20 28  -set-args keys (
a780: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 74  args:get-arg "-t
a790: 61 72 67 65 74 22 20 61 72 67 73 3a 61 72 67 2d  arget" args:arg-
a7a0: 68 61 73 68 29 20 61 72 67 73 3a 61 72 67 2d 68  hash) args:arg-h
a7b0: 61 73 68 29 29 29 0a 09 28 69 66 20 28 6e 6f 74  ash)))..(if (not
a7c0: 20 28 63 61 72 20 2a 63 6f 6e 66 69 67 69 6e 66   (car *configinf
a7d0: 6f 2a 29 29 0a 09 20 20 20 20 28 62 65 67 69 6e  o*))..    (begin
a7e0: 0a 09 20 20 20 20 20 20 28 64 65 62 75 67 3a 70  ..      (debug:p
a7f0: 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 41  rint 0 "ERROR: A
a800: 74 74 65 6d 70 74 65 64 20 74 6f 20 22 20 61 63  ttempted to " ac
a810: 74 69 6f 6e 2d 64 65 73 63 20 22 20 62 75 74 20  tion-desc " but 
a820: 72 75 6e 20 61 72 65 61 20 63 6f 6e 66 69 67 20  run area config 
a830: 66 69 6c 65 20 6e 6f 74 20 66 6f 75 6e 64 22 29  file not found")
a840: 0a 09 20 20 20 20 20 20 28 65 78 69 74 20 31 29  ..      (exit 1)
a850: 29 0a 09 20 20 20 20 3b 3b 20 45 78 74 72 61 63  )..    ;; Extrac
a860: 74 20 6f 75 74 20 73 74 75 66 66 20 6e 65 65 64  t out stuff need
a870: 65 64 20 69 6e 20 6d 6f 73 74 20 6f 72 20 6d 61  ed in most or ma
a880: 6e 79 20 63 61 6c 6c 73 0a 09 20 20 20 20 3b 3b  ny calls..    ;;
a890: 20 68 65 72 65 20 74 68 65 6e 20 63 61 6c 6c 20   here then call 
a8a0: 70 72 6f 63 0a 09 20 20 20 20 28 6c 65 74 2a 20  proc..    (let* 
a8b0: 28 28 6b 65 79 6e 61 6d 65 73 20 20 20 28 6d 61  ((keynames   (ma
a8c0: 70 20 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64 6e  p key:get-fieldn
a8d0: 61 6d 65 20 6b 65 79 73 29 29 0a 09 09 20 20 20  ame keys))...   
a8e0: 28 6b 65 79 76 61 6c 6c 73 74 20 20 28 6b 65 79  (keyvallst  (key
a8f0: 73 2d 3e 76 61 6c 6c 69 73 74 20 6b 65 79 73 20  s->vallist keys 
a900: 23 74 29 29 29 0a 09 20 20 20 20 20 20 28 70 72  #t)))..      (pr
a910: 6f 63 20 74 61 72 67 65 74 20 72 75 6e 6e 61 6d  oc target runnam
a920: 65 20 6b 65 79 73 20 6b 65 79 6e 61 6d 65 73 20  e keys keynames 
a930: 6b 65 79 76 61 6c 6c 73 74 29 29 29 0a 09 28 69  keyvallst)))..(i
a940: 66 20 74 68 31 20 28 74 68 72 65 61 64 2d 6a 6f  f th1 (thread-jo
a950: 69 6e 21 20 74 68 31 29 29 0a 09 28 69 66 20 64  in! th1))..(if d
a960: 62 20 28 73 71 6c 69 74 65 33 3a 66 69 6e 61 6c  b (sqlite3:final
a970: 69 7a 65 21 20 64 62 29 29 0a 09 28 73 65 74 21  ize! db))..(set!
a980: 20 2a 64 69 64 73 6f 6d 65 74 68 69 6e 67 2a 20   *didsomething* 
a990: 23 74 29 29 29 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d  #t))))))..;;====
a9a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
a9b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
a9c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
a9d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
a9e0: 3d 3d 0a 3b 3b 20 4c 6f 63 6b 2f 75 6e 6c 6f 63  ==.;; Lock/unloc
a9f0: 6b 20 72 75 6e 73 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d  k runs.;;=======
aa00: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
aa10: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
aa20: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
aa30: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a  ===============.
aa40: 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 68  .(define (runs:h
aa50: 61 6e 64 6c 65 2d 6c 6f 63 6b 69 6e 67 20 74 61  andle-locking ta
aa60: 72 67 65 74 20 6b 65 79 73 20 72 75 6e 6e 61 6d  rget keys runnam
aa70: 65 20 6c 6f 63 6b 20 75 6e 6c 6f 63 6b 20 75 73  e lock unlock us
aa80: 65 72 29 0a 20 20 28 6c 65 74 2a 20 28 28 64 62  er).  (let* ((db
aa90: 20 20 20 20 20 20 20 23 66 29 0a 09 20 28 72 75         #f).. (ru
aaa0: 6e 64 61 74 20 20 20 28 6f 70 65 6e 2d 72 75 6e  ndat   (open-run
aab0: 2d 63 6c 6f 73 65 20 72 75 6e 73 3a 67 65 74 2d  -close runs:get-
aac0: 72 75 6e 73 2d 62 79 2d 70 61 74 74 20 64 62 20  runs-by-patt db 
aad0: 6b 65 79 73 20 72 75 6e 6e 61 6d 65 29 29 0a 09  keys runname))..
aae0: 20 28 68 65 61 64 65 72 20 20 20 28 76 65 63 74   (header   (vect
aaf0: 6f 72 2d 72 65 66 20 72 75 6e 64 61 74 20 30 29  or-ref rundat 0)
ab00: 29 0a 09 20 28 72 75 6e 73 20 20 20 20 20 28 76  ).. (runs     (v
ab10: 65 63 74 6f 72 2d 72 65 66 20 72 75 6e 64 61 74  ector-ref rundat
ab20: 20 31 29 29 29 0a 20 20 20 20 28 66 6f 72 2d 65   1))).    (for-e
ab30: 61 63 68 20 28 6c 61 6d 62 64 61 20 28 72 75 6e  ach (lambda (run
ab40: 29 0a 09 09 28 6c 65 74 20 28 28 72 75 6e 2d 69  )...(let ((run-i
ab50: 64 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d  d (db:get-value-
ab60: 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65  by-header run he
ab70: 61 64 65 72 20 22 69 64 22 29 29 29 0a 09 09 20  ader "id")))... 
ab80: 20 28 69 66 20 28 6f 72 20 6c 6f 63 6b 0a 09 09   (if (or lock...
ab90: 09 20 20 28 61 6e 64 20 75 6e 6c 6f 63 6b 0a 09  .  (and unlock..
aba0: 09 09 20 20 20 20 20 20 20 28 62 65 67 69 6e 0a  ..       (begin.
abb0: 09 09 09 09 20 28 70 72 69 6e 74 20 22 44 6f 20  .... (print "Do 
abc0: 79 6f 75 20 72 65 61 6c 6c 79 20 77 69 73 68 20  you really wish 
abd0: 74 6f 20 75 6e 6c 6f 63 6b 20 72 75 6e 20 22 20  to unlock run " 
abe0: 72 75 6e 2d 69 64 20 22 3f 5c 6e 20 20 20 79 2f  run-id "?\n   y/
abf0: 6e 3a 20 22 29 0a 09 09 09 09 20 28 65 71 75 61  n: ")..... (equa
ac00: 6c 3f 20 22 79 22 20 28 72 65 61 64 2d 6c 69 6e  l? "y" (read-lin
ac10: 65 29 29 29 29 29 0a 09 09 20 20 20 20 20 20 28  e)))))...      (
ac20: 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 64  open-run-close d
ac30: 62 3a 6c 6f 63 6b 2f 75 6e 6c 6f 63 6b 2d 72 75  b:lock/unlock-ru
ac40: 6e 20 64 62 20 72 75 6e 2d 69 64 20 6c 6f 63 6b  n db run-id lock
ac50: 20 75 6e 6c 6f 63 6b 20 75 73 65 72 29 0a 09 09   unlock user)...
ac60: 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69        (debug:pri
ac70: 6e 74 2d 69 6e 66 6f 20 30 20 22 53 6b 69 70 70  nt-info 0 "Skipp
ac80: 69 6e 67 20 6c 6f 63 6b 2f 75 6e 6c 6f 63 6b 20  ing lock/unlock 
ac90: 6f 6e 20 22 20 72 75 6e 2d 69 64 29 29 29 29 0a  on " run-id)))).
aca0: 09 20 20 20 20 20 20 72 75 6e 73 29 29 29 0a 3b  .      runs))).;
acb0: 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ;===============
acc0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
acd0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
ace0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
acf0: 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 52 6f 6c 6c 75  =======.;; Rollu
ad00: 70 20 72 75 6e 73 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d  p runs.;;=======
ad10: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
ad20: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
ad30: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
ad40: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a  ===============.
ad50: 0a 3b 3b 20 55 70 64 61 74 65 20 74 68 65 20 74  .;; Update the t
ad60: 65 73 74 5f 6d 65 74 61 20 74 61 62 6c 65 20 66  est_meta table f
ad70: 6f 72 20 74 68 69 73 20 74 65 73 74 0a 28 64 65  or this test.(de
ad80: 66 69 6e 65 20 28 72 75 6e 73 3a 75 70 64 61 74  fine (runs:updat
ad90: 65 2d 74 65 73 74 5f 6d 65 74 61 20 64 62 20 74  e-test_meta db t
ada0: 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 2d 63 6f  est-name test-co
adb0: 6e 66 29 0a 20 20 28 6c 65 74 20 28 28 63 75 72  nf).  (let ((cur
adc0: 72 72 65 63 6f 72 64 20 28 6f 70 65 6e 2d 72 75  rrecord (open-ru
add0: 6e 2d 63 6c 6f 73 65 20 64 62 3a 74 65 73 74 6d  n-close db:testm
ade0: 65 74 61 2d 67 65 74 2d 72 65 63 6f 72 64 20 64  eta-get-record d
adf0: 62 20 74 65 73 74 2d 6e 61 6d 65 29 29 29 0a 20  b test-name))). 
ae00: 20 20 20 28 69 66 20 28 6e 6f 74 20 63 75 72 72     (if (not curr
ae10: 72 65 63 6f 72 64 29 0a 09 28 62 65 67 69 6e 0a  record)..(begin.
ae20: 09 20 20 28 73 65 74 21 20 63 75 72 72 72 65 63  .  (set! currrec
ae30: 6f 72 64 20 28 6d 61 6b 65 2d 76 65 63 74 6f 72  ord (make-vector
ae40: 20 31 30 20 23 66 29 29 0a 09 20 20 28 6f 70 65   10 #f))..  (ope
ae50: 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 64 62 3a 74  n-run-close db:t
ae60: 65 73 74 6d 65 74 61 2d 61 64 64 2d 72 65 63 6f  estmeta-add-reco
ae70: 72 64 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 29  rd db test-name)
ae80: 29 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68  )).    (for-each
ae90: 20 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28   .     (lambda (
aea0: 6b 65 79 29 0a 20 20 20 20 20 20 20 28 6c 65 74  key).       (let
aeb0: 2a 20 28 28 69 64 78 20 28 63 61 64 72 20 6b 65  * ((idx (cadr ke
aec0: 79 29 29 0a 09 20 20 20 20 20 20 28 66 6c 64 20  y))..      (fld 
aed0: 28 63 61 72 20 20 6b 65 79 29 29 0a 09 20 20 20  (car  key))..   
aee0: 20 20 20 28 76 61 6c 20 28 63 6f 6e 66 69 67 2d     (val (config-
aef0: 6c 6f 6f 6b 75 70 20 74 65 73 74 2d 63 6f 6e 66  lookup test-conf
af00: 20 22 74 65 73 74 5f 6d 65 74 61 22 20 66 6c 64   "test_meta" fld
af10: 29 29 29 0a 09 20 3b 3b 20 28 64 65 62 75 67 3a  ))).. ;; (debug:
af20: 70 72 69 6e 74 20 35 20 22 69 64 78 3a 20 22 20  print 5 "idx: " 
af30: 69 64 78 20 22 20 66 6c 64 3a 20 22 20 66 6c 64  idx " fld: " fld
af40: 20 22 20 76 61 6c 3a 20 22 20 76 61 6c 29 0a 09   " val: " val)..
af50: 20 28 69 66 20 28 61 6e 64 20 76 61 6c 20 28 6e   (if (and val (n
af60: 6f 74 20 28 65 71 75 61 6c 3f 20 28 76 65 63 74  ot (equal? (vect
af70: 6f 72 2d 72 65 66 20 63 75 72 72 72 65 63 6f 72  or-ref currrecor
af80: 64 20 69 64 78 29 20 76 61 6c 29 29 29 0a 09 20  d idx) val))).. 
af90: 20 20 20 20 28 62 65 67 69 6e 0a 09 20 20 20 20      (begin..    
afa0: 20 20 20 28 70 72 69 6e 74 20 22 55 70 64 61 74     (print "Updat
afb0: 69 6e 67 20 22 20 74 65 73 74 2d 6e 61 6d 65 20  ing " test-name 
afc0: 22 20 22 20 66 6c 64 20 22 20 74 6f 20 22 20 76  " " fld " to " v
afd0: 61 6c 29 0a 09 20 20 20 20 20 20 20 28 6f 70 65  al)..       (ope
afe0: 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 64 62 3a 74  n-run-close db:t
aff0: 65 73 74 6d 65 74 61 2d 75 70 64 61 74 65 2d 66  estmeta-update-f
b000: 69 65 6c 64 20 64 62 20 74 65 73 74 2d 6e 61 6d  ield db test-nam
b010: 65 20 66 6c 64 20 76 61 6c 29 29 29 29 29 0a 20  e fld val))))). 
b020: 20 20 20 20 27 28 28 22 61 75 74 68 6f 72 22 20      '(("author" 
b030: 32 29 28 22 6f 77 6e 65 72 22 20 33 29 28 22 64  2)("owner" 3)("d
b040: 65 73 63 72 69 70 74 69 6f 6e 22 20 34 29 28 22  escription" 4)("
b050: 72 65 76 69 65 77 65 64 22 20 35 29 28 22 74 61  reviewed" 5)("ta
b060: 67 73 22 20 39 29 29 29 29 29 0a 0a 3b 3b 20 55  gs" 9)))))..;; U
b070: 70 64 61 74 65 20 74 65 73 74 5f 6d 65 74 61 20  pdate test_meta 
b080: 66 6f 72 20 61 6c 6c 20 74 65 73 74 73 0a 28 64  for all tests.(d
b090: 65 66 69 6e 65 20 28 72 75 6e 73 3a 75 70 64 61  efine (runs:upda
b0a0: 74 65 2d 61 6c 6c 2d 74 65 73 74 5f 6d 65 74 61  te-all-test_meta
b0b0: 20 64 62 29 0a 20 20 28 6c 65 74 20 28 28 74 65   db).  (let ((te
b0c0: 73 74 2d 6e 61 6d 65 73 20 28 67 65 74 2d 61 6c  st-names (get-al
b0d0: 6c 2d 6c 65 67 61 6c 2d 74 65 73 74 73 29 29 29  l-legal-tests)))
b0e0: 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20 0a  .    (for-each .
b0f0: 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 74 65       (lambda (te
b100: 73 74 2d 6e 61 6d 65 29 0a 20 20 20 20 20 20 20  st-name).       
b110: 28 6c 65 74 2a 20 28 28 74 65 73 74 2d 70 61 74  (let* ((test-pat
b120: 68 20 20 20 20 28 63 6f 6e 63 20 2a 74 6f 70 70  h    (conc *topp
b130: 61 74 68 2a 20 22 2f 74 65 73 74 73 2f 22 20 74  ath* "/tests/" t
b140: 65 73 74 2d 6e 61 6d 65 29 29 0a 09 20 20 20 20  est-name))..    
b150: 20 20 28 74 65 73 74 2d 63 6f 6e 66 69 67 66 20    (test-configf 
b160: 28 63 6f 6e 63 20 74 65 73 74 2d 70 61 74 68 20  (conc test-path 
b170: 22 2f 74 65 73 74 63 6f 6e 66 69 67 22 29 29 0a  "/testconfig")).
b180: 09 20 20 20 20 20 20 28 74 65 73 74 65 78 69 73  .      (testexis
b190: 74 73 20 20 20 28 61 6e 64 20 28 66 69 6c 65 2d  ts   (and (file-
b1a0: 65 78 69 73 74 73 3f 20 74 65 73 74 2d 63 6f 6e  exists? test-con
b1b0: 66 69 67 66 29 28 66 69 6c 65 2d 72 65 61 64 2d  figf)(file-read-
b1c0: 61 63 63 65 73 73 3f 20 74 65 73 74 2d 63 6f 6e  access? test-con
b1d0: 66 69 67 66 29 29 29 0a 09 20 20 20 20 20 20 3b  figf)))..      ;
b1e0: 3b 20 72 65 61 64 20 63 6f 6e 66 69 67 73 20 77  ; read configs w
b1f0: 69 74 68 20 74 72 69 63 6b 73 20 74 75 72 6e 65  ith tricks turne
b200: 64 20 6f 66 66 20 28 69 2e 65 2e 20 6e 6f 20 73  d off (i.e. no s
b210: 79 73 74 65 6d 29 0a 09 20 20 20 20 20 20 28 74  ystem)..      (t
b220: 65 73 74 2d 63 6f 6e 66 20 20 20 20 28 69 66 20  est-conf    (if 
b230: 74 65 73 74 65 78 69 73 74 73 20 28 72 65 61 64  testexists (read
b240: 2d 63 6f 6e 66 69 67 20 74 65 73 74 2d 63 6f 6e  -config test-con
b250: 66 69 67 66 20 23 66 20 23 66 29 28 6d 61 6b 65  figf #f #f)(make
b260: 2d 68 61 73 68 2d 74 61 62 6c 65 29 29 29 29 0a  -hash-table)))).
b270: 09 20 3b 3b 20 75 73 65 20 74 68 65 20 6f 70 65  . ;; use the ope
b280: 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 69 6e 73 74  n-run-close inst
b290: 65 61 64 20 6f 66 20 70 61 73 73 69 6e 67 20 69  ead of passing i
b2a0: 6e 20 64 62 0a 09 20 28 72 75 6e 73 3a 75 70 64  n db.. (runs:upd
b2b0: 61 74 65 2d 74 65 73 74 5f 6d 65 74 61 20 23 66  ate-test_meta #f
b2c0: 20 74 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 2d   test-name test-
b2d0: 63 6f 6e 66 29 29 29 0a 20 20 20 20 20 74 65 73  conf))).     tes
b2e0: 74 2d 6e 61 6d 65 73 29 29 29 0a 0a 3b 3b 20 54  t-names)))..;; T
b2f0: 68 69 73 20 63 6f 75 6c 64 20 70 72 6f 62 61 62  his could probab
b300: 6c 79 20 62 65 20 72 65 66 61 63 74 6f 72 65 64  ly be refactored
b310: 20 69 6e 74 6f 20 6f 6e 65 20 63 6f 6d 70 6c 65   into one comple
b320: 78 20 71 75 65 72 79 20 2e 2e 2e 0a 28 64 65 66  x query ....(def
b330: 69 6e 65 20 28 72 75 6e 73 3a 72 6f 6c 6c 75 70  ine (runs:rollup
b340: 2d 72 75 6e 20 6b 65 79 73 20 6b 65 79 76 61 6c  -run keys keyval
b350: 6c 73 74 20 72 75 6e 6e 61 6d 65 20 75 73 65 72  lst runname user
b360: 29 20 3b 3b 20 77 61 73 20 74 61 72 67 65 74 2c  ) ;; was target,
b370: 20 6e 6f 77 20 6b 65 79 76 61 6c 6c 73 74 0a 20   now keyvallst. 
b380: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20   (debug:print 4 
b390: 22 72 75 6e 73 3a 72 6f 6c 6c 75 70 2d 72 75 6e  "runs:rollup-run
b3a0: 2c 20 6b 65 79 73 3a 20 22 20 6b 65 79 73 20 22  , keys: " keys "
b3b0: 20 6b 65 79 76 61 6c 6c 73 74 3a 20 22 20 6b 65   keyvallst: " ke
b3c0: 79 76 61 6c 6c 73 74 20 22 20 3a 72 75 6e 6e 61  yvallst " :runna
b3d0: 6d 65 20 22 20 72 75 6e 6e 61 6d 65 20 22 20 75  me " runname " u
b3e0: 73 65 72 3a 20 22 20 75 73 65 72 29 0a 20 20 28  ser: " user).  (
b3f0: 6c 65 74 2a 20 28 28 64 62 20 20 20 20 20 20 20  let* ((db       
b400: 20 20 20 20 20 20 20 23 66 29 20 3b 3b 20 28 6b         #f) ;; (k
b410: 65 79 76 61 6c 6c 6c 73 74 20 20 20 20 20 20 28  eyvalllst      (
b420: 6b 65 79 73 3a 74 61 72 67 65 74 2d 3e 6b 65 79  keys:target->key
b430: 76 61 6c 20 6b 65 79 73 20 74 61 72 67 65 74 29  val keys target)
b440: 29 0a 09 20 28 6e 65 77 2d 72 75 6e 2d 69 64 20  ).. (new-run-id 
b450: 20 20 20 20 20 28 6f 70 65 6e 2d 72 75 6e 2d 63       (open-run-c
b460: 6c 6f 73 65 20 72 75 6e 73 3a 72 65 67 69 73 74  lose runs:regist
b470: 65 72 2d 72 75 6e 20 64 62 20 6b 65 79 73 20 6b  er-run db keys k
b480: 65 79 76 61 6c 6c 73 74 20 72 75 6e 6e 61 6d 65  eyvallst runname
b490: 20 22 6e 65 77 22 20 22 6e 2f 61 22 20 75 73 65   "new" "n/a" use
b4a0: 72 29 29 0a 09 20 28 70 72 65 76 2d 74 65 73 74  r)).. (prev-test
b4b0: 73 20 20 20 20 20 20 28 6f 70 65 6e 2d 72 75 6e  s      (open-run
b4c0: 2d 63 6c 6f 73 65 20 74 65 73 74 3a 67 65 74 2d  -close test:get-
b4d0: 6d 61 74 63 68 69 6e 67 2d 70 72 65 76 69 6f 75  matching-previou
b4e0: 73 2d 74 65 73 74 2d 72 75 6e 2d 72 65 63 6f 72  s-test-run-recor
b4f0: 64 73 20 64 62 20 6e 65 77 2d 72 75 6e 2d 69 64  ds db new-run-id
b500: 20 22 25 22 20 22 25 22 29 29 0a 09 20 28 63 75   "%" "%")).. (cu
b510: 72 72 2d 74 65 73 74 73 20 20 20 20 20 20 28 6f  rr-tests      (o
b520: 70 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 64 62  pen-run-close db
b530: 3a 67 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d 72  :get-tests-for-r
b540: 75 6e 20 64 62 20 6e 65 77 2d 72 75 6e 2d 69 64  un db new-run-id
b550: 20 22 25 2f 25 22 20 27 28 29 20 27 28 29 29 29   "%/%" '() '()))
b560: 0a 09 20 28 63 75 72 72 2d 74 65 73 74 73 2d 68  .. (curr-tests-h
b570: 61 73 68 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74  ash (make-hash-t
b580: 61 62 6c 65 29 29 29 0a 20 20 20 20 28 6f 70 65  able))).    (ope
b590: 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 64 62 3a 75  n-run-close db:u
b5a0: 70 64 61 74 65 2d 72 75 6e 2d 65 76 65 6e 74 5f  pdate-run-event_
b5b0: 74 69 6d 65 20 64 62 20 6e 65 77 2d 72 75 6e 2d  time db new-run-
b5c0: 69 64 29 0a 20 20 20 20 3b 3b 20 69 6e 64 65 78  id).    ;; index
b5d0: 20 74 68 65 20 61 6c 72 65 61 64 79 20 73 61 76   the already sav
b5e0: 65 64 20 74 65 73 74 73 20 62 79 20 74 65 73 74  ed tests by test
b5f0: 6e 61 6d 65 20 61 6e 64 20 69 74 65 6d 64 61 74  name and itemdat
b600: 20 69 6e 20 63 75 72 72 2d 74 65 73 74 73 2d 68   in curr-tests-h
b610: 61 73 68 0a 20 20 20 20 28 66 6f 72 2d 65 61 63  ash.    (for-eac
b620: 68 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28  h.     (lambda (
b630: 74 65 73 74 64 61 74 29 0a 20 20 20 20 20 20 20  testdat).       
b640: 28 6c 65 74 2a 20 28 28 74 65 73 74 6e 61 6d 65  (let* ((testname
b650: 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 74    (db:test-get-t
b660: 65 73 74 6e 61 6d 65 20 74 65 73 74 64 61 74 29  estname testdat)
b670: 29 0a 09 20 20 20 20 20 20 28 69 74 65 6d 2d 70  )..      (item-p
b680: 61 74 68 20 28 64 62 3a 74 65 73 74 2d 67 65 74  ath (db:test-get
b690: 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 64  -item-path testd
b6a0: 61 74 29 29 0a 09 20 20 20 20 20 20 28 66 75 6c  at))..      (ful
b6b0: 6c 2d 6e 61 6d 65 20 28 63 6f 6e 63 20 74 65 73  l-name (conc tes
b6c0: 74 6e 61 6d 65 20 22 2f 22 20 69 74 65 6d 2d 70  tname "/" item-p
b6d0: 61 74 68 29 29 29 0a 09 20 28 68 61 73 68 2d 74  ath))).. (hash-t
b6e0: 61 62 6c 65 2d 73 65 74 21 20 63 75 72 72 2d 74  able-set! curr-t
b6f0: 65 73 74 73 2d 68 61 73 68 20 66 75 6c 6c 2d 6e  ests-hash full-n
b700: 61 6d 65 20 74 65 73 74 64 61 74 29 29 29 0a 20  ame testdat))). 
b710: 20 20 20 20 63 75 72 72 2d 74 65 73 74 73 29 0a      curr-tests).
b720: 20 20 20 20 3b 3b 20 4e 4f 50 45 3a 20 4e 6f 6e      ;; NOPE: Non
b730: 2d 6f 70 74 69 6d 61 6c 20 61 70 70 72 6f 61 63  -optimal approac
b740: 68 2e 20 54 72 79 20 74 68 69 73 20 69 6e 73 74  h. Try this inst
b750: 65 61 64 2e 0a 20 20 20 20 3b 3b 20 20 20 31 2e  ead..    ;;   1.
b760: 20 74 65 73 74 73 20 61 72 65 20 72 65 63 65 69   tests are recei
b770: 76 65 64 20 69 6e 20 61 20 6c 69 73 74 2c 20 6d  ved in a list, m
b780: 6f 73 74 20 72 65 63 65 6e 74 20 66 69 72 73 74  ost recent first
b790: 0a 20 20 20 20 3b 3b 20 20 20 32 2e 20 72 65 70  .    ;;   2. rep
b7a0: 6c 61 63 65 20 74 68 65 20 72 6f 6c 6c 75 70 20  lace the rollup 
b7b0: 74 65 73 74 20 77 69 74 68 20 74 68 65 20 6e 65  test with the ne
b7c0: 77 20 2a 61 6c 77 61 79 73 2a 0a 20 20 20 20 28  w *always*.    (
b7d0: 66 6f 72 2d 65 61 63 68 20 0a 20 20 20 20 20 28  for-each .     (
b7e0: 6c 61 6d 62 64 61 20 28 74 65 73 74 64 61 74 29  lambda (testdat)
b7f0: 0a 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28 28  .       (let* ((
b800: 74 65 73 74 6e 61 6d 65 20 20 28 64 62 3a 74 65  testname  (db:te
b810: 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20  st-get-testname 
b820: 74 65 73 74 64 61 74 29 29 0a 09 20 20 20 20 20  testdat))..     
b830: 20 28 69 74 65 6d 2d 70 61 74 68 20 28 64 62 3a   (item-path (db:
b840: 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61  test-get-item-pa
b850: 74 68 20 74 65 73 74 64 61 74 29 29 0a 09 20 20  th testdat))..  
b860: 20 20 20 20 28 66 75 6c 6c 2d 6e 61 6d 65 20 28      (full-name (
b870: 63 6f 6e 63 20 74 65 73 74 6e 61 6d 65 20 22 2f  conc testname "/
b880: 22 20 69 74 65 6d 2d 70 61 74 68 29 29 0a 09 20  " item-path)).. 
b890: 20 20 20 20 20 28 70 72 65 76 2d 74 65 73 74 2d       (prev-test-
b8a0: 64 61 74 20 28 68 61 73 68 2d 74 61 62 6c 65 2d  dat (hash-table-
b8b0: 72 65 66 2f 64 65 66 61 75 6c 74 20 63 75 72 72  ref/default curr
b8c0: 2d 74 65 73 74 73 2d 68 61 73 68 20 66 75 6c 6c  -tests-hash full
b8d0: 2d 6e 61 6d 65 20 23 66 29 29 0a 09 20 20 20 20  -name #f))..    
b8e0: 20 20 28 74 65 73 74 2d 73 74 65 70 73 20 20 20    (test-steps   
b8f0: 20 20 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f     (open-run-clo
b900: 73 65 20 64 62 3a 67 65 74 2d 73 74 65 70 73 2d  se db:get-steps-
b910: 66 6f 72 2d 74 65 73 74 20 64 62 20 28 64 62 3a  for-test db (db:
b920: 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74  test-get-id test
b930: 64 61 74 29 29 29 0a 09 20 20 20 20 20 20 28 6e  dat)))..      (n
b940: 65 77 2d 74 65 73 74 2d 72 65 63 6f 72 64 20 23  ew-test-record #
b950: 66 29 29 0a 09 20 3b 3b 20 72 65 70 6c 61 63 65  f)).. ;; replace
b960: 20 74 68 65 73 65 20 77 69 74 68 20 69 6e 73 65   these with inse
b970: 72 74 20 2e 2e 2e 20 73 65 6c 65 63 74 0a 09 20  rt ... select.. 
b980: 28 61 70 70 6c 79 20 73 71 6c 69 74 65 33 3a 65  (apply sqlite3:e
b990: 78 65 63 75 74 65 20 0a 09 09 64 62 20 0a 09 09  xecute ...db ...
b9a0: 28 63 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f 52  (conc "INSERT OR
b9b0: 20 52 45 50 4c 41 43 45 20 49 4e 54 4f 20 74 65   REPLACE INTO te
b9c0: 73 74 73 20 28 72 75 6e 5f 69 64 2c 74 65 73 74  sts (run_id,test
b9d0: 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 61 74 75  name,state,statu
b9e0: 73 2c 65 76 65 6e 74 5f 74 69 6d 65 2c 68 6f 73  s,event_time,hos
b9f0: 74 2c 63 70 75 6c 6f 61 64 2c 64 69 73 6b 66 72  t,cpuload,diskfr
ba00: 65 65 2c 75 6e 61 6d 65 2c 72 75 6e 64 69 72 2c  ee,uname,rundir,
ba10: 69 74 65 6d 5f 70 61 74 68 2c 72 75 6e 5f 64 75  item_path,run_du
ba20: 72 61 74 69 6f 6e 2c 66 69 6e 61 6c 5f 6c 6f 67  ration,final_log
ba30: 66 2c 63 6f 6d 6d 65 6e 74 29 20 22 0a 09 09 20  f,comment) "... 
ba40: 20 20 20 20 20 22 56 41 4c 55 45 53 20 28 3f 2c       "VALUES (?,
ba50: 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c  ?,?,?,?,?,?,?,?,
ba60: 3f 2c 3f 2c 3f 2c 3f 2c 3f 29 3b 22 29 0a 09 09  ?,?,?,?,?);")...
ba70: 6e 65 77 2d 72 75 6e 2d 69 64 20 28 63 64 64 72  new-run-id (cddr
ba80: 20 28 76 65 63 74 6f 72 2d 3e 6c 69 73 74 20 74   (vector->list t
ba90: 65 73 74 64 61 74 29 29 29 0a 09 20 28 73 65 74  estdat))).. (set
baa0: 21 20 6e 65 77 2d 74 65 73 74 64 61 74 20 28 63  ! new-testdat (c
bab0: 61 72 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f  ar (open-run-clo
bac0: 73 65 20 64 62 3a 67 65 74 2d 74 65 73 74 73 2d  se db:get-tests-
bad0: 66 6f 72 2d 72 75 6e 20 64 62 20 6e 65 77 2d 72  for-run db new-r
bae0: 75 6e 2d 69 64 20 28 63 6f 6e 63 20 74 65 73 74  un-id (conc test
baf0: 6e 61 6d 65 20 22 2f 22 20 69 74 65 6d 2d 70 61  name "/" item-pa
bb00: 74 68 29 20 27 28 29 20 27 28 29 29 29 29 0a 09  th) '() '())))..
bb10: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74   (hash-table-set
bb20: 21 20 63 75 72 72 2d 74 65 73 74 73 2d 68 61 73  ! curr-tests-has
bb30: 68 20 66 75 6c 6c 2d 6e 61 6d 65 20 6e 65 77 2d  h full-name new-
bb40: 74 65 73 74 64 61 74 29 20 3b 3b 20 74 68 69 73  testdat) ;; this
bb50: 20 63 6f 75 6c 64 20 62 65 20 63 6f 6e 66 75 73   could be confus
bb60: 69 6e 67 2c 20 77 68 69 63 68 20 72 65 63 6f 72  ing, which recor
bb70: 64 20 73 68 6f 75 6c 64 20 67 6f 20 69 6e 74 6f  d should go into
bb80: 20 74 68 65 20 6c 6f 6f 6b 75 70 20 74 61 62 6c   the lookup tabl
bb90: 65 3f 0a 09 20 3b 3b 20 4e 6f 77 20 64 75 70 6c  e?.. ;; Now dupl
bba0: 69 63 61 74 65 20 74 68 65 20 74 65 73 74 20 73  icate the test s
bbb0: 74 65 70 73 0a 09 20 28 64 65 62 75 67 3a 70 72  teps.. (debug:pr
bbc0: 69 6e 74 20 34 20 22 43 6f 70 79 69 6e 67 20 72  int 4 "Copying r
bbd0: 65 63 6f 72 64 73 20 69 6e 20 74 65 73 74 5f 73  ecords in test_s
bbe0: 74 65 70 73 20 66 72 6f 6d 20 74 65 73 74 5f 69  teps from test_i
bbf0: 64 3d 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74  d=" (db:test-get
bc00: 2d 69 64 20 74 65 73 74 64 61 74 29 20 22 20 74  -id testdat) " t
bc10: 6f 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74  o " (db:test-get
bc20: 2d 69 64 20 6e 65 77 2d 74 65 73 74 64 61 74 29  -id new-testdat)
bc30: 29 0a 09 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c  ).. (open-run-cl
bc40: 6f 73 65 20 0a 09 20 20 28 6c 61 6d 62 64 61 20  ose ..  (lambda 
bc50: 28 29 0a 09 20 20 20 20 28 73 71 6c 69 74 65 33  ()..    (sqlite3
bc60: 3a 65 78 65 63 75 74 65 20 0a 09 20 20 20 20 20  :execute ..     
bc70: 64 62 20 0a 09 20 20 20 20 20 28 63 6f 6e 63 20  db ..     (conc 
bc80: 22 49 4e 53 45 52 54 20 4f 52 20 52 45 50 4c 41  "INSERT OR REPLA
bc90: 43 45 20 49 4e 54 4f 20 74 65 73 74 5f 73 74 65  CE INTO test_ste
bca0: 70 73 20 28 74 65 73 74 5f 69 64 2c 73 74 65 70  ps (test_id,step
bcb0: 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 61 74 75  name,state,statu
bcc0: 73 2c 65 76 65 6e 74 5f 74 69 6d 65 2c 63 6f 6d  s,event_time,com
bcd0: 6d 65 6e 74 29 20 22 0a 09 09 20 20 20 22 53 45  ment) "...   "SE
bce0: 4c 45 43 54 20 22 20 28 64 62 3a 74 65 73 74 2d  LECT " (db:test-
bcf0: 67 65 74 2d 69 64 20 6e 65 77 2d 74 65 73 74 64  get-id new-testd
bd00: 61 74 29 20 22 2c 73 74 65 70 6e 61 6d 65 2c 73  at) ",stepname,s
bd10: 74 61 74 65 2c 73 74 61 74 75 73 2c 65 76 65 6e  tate,status,even
bd20: 74 5f 74 69 6d 65 2c 63 6f 6d 6d 65 6e 74 20 46  t_time,comment F
bd30: 52 4f 4d 20 74 65 73 74 5f 73 74 65 70 73 20 57  ROM test_steps W
bd40: 48 45 52 45 20 74 65 73 74 5f 69 64 3d 3f 3b 22  HERE test_id=?;"
bd50: 29 0a 09 20 20 20 20 20 28 64 62 3a 74 65 73 74  )..     (db:test
bd60: 2d 67 65 74 2d 69 64 20 74 65 73 74 64 61 74 29  -get-id testdat)
bd70: 29 0a 09 20 20 20 20 3b 3b 20 4e 6f 77 20 64 75  )..    ;; Now du
bd80: 70 6c 69 63 61 74 65 20 74 68 65 20 74 65 73 74  plicate the test
bd90: 20 64 61 74 61 0a 09 20 20 20 20 28 64 65 62 75   data..    (debu
bda0: 67 3a 70 72 69 6e 74 20 34 20 22 43 6f 70 79 69  g:print 4 "Copyi
bdb0: 6e 67 20 72 65 63 6f 72 64 73 20 69 6e 20 74 65  ng records in te
bdc0: 73 74 5f 64 61 74 61 20 66 72 6f 6d 20 74 65 73  st_data from tes
bdd0: 74 5f 69 64 3d 22 20 28 64 62 3a 74 65 73 74 2d  t_id=" (db:test-
bde0: 67 65 74 2d 69 64 20 74 65 73 74 64 61 74 29 20  get-id testdat) 
bdf0: 22 20 74 6f 20 22 20 28 64 62 3a 74 65 73 74 2d  " to " (db:test-
be00: 67 65 74 2d 69 64 20 6e 65 77 2d 74 65 73 74 64  get-id new-testd
be10: 61 74 29 29 0a 09 20 20 20 20 28 73 71 6c 69 74  at))..    (sqlit
be20: 65 33 3a 65 78 65 63 75 74 65 20 0a 09 20 20 20  e3:execute ..   
be30: 20 20 64 62 20 0a 09 20 20 20 20 20 28 63 6f 6e    db ..     (con
be40: 63 20 22 49 4e 53 45 52 54 20 4f 52 20 52 45 50  c "INSERT OR REP
be50: 4c 41 43 45 20 49 4e 54 4f 20 74 65 73 74 5f 64  LACE INTO test_d
be60: 61 74 61 20 28 74 65 73 74 5f 69 64 2c 63 61 74  ata (test_id,cat
be70: 65 67 6f 72 79 2c 76 61 72 69 61 62 6c 65 2c 76  egory,variable,v
be80: 61 6c 75 65 2c 65 78 70 65 63 74 65 64 2c 74 6f  alue,expected,to
be90: 6c 2c 75 6e 69 74 73 2c 63 6f 6d 6d 65 6e 74 29  l,units,comment)
bea0: 20 22 0a 09 09 20 20 20 22 53 45 4c 45 43 54 20   "...   "SELECT 
beb0: 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69  " (db:test-get-i
bec0: 64 20 6e 65 77 2d 74 65 73 74 64 61 74 29 20 22  d new-testdat) "
bed0: 2c 63 61 74 65 67 6f 72 79 2c 76 61 72 69 61 62  ,category,variab
bee0: 6c 65 2c 76 61 6c 75 65 2c 65 78 70 65 63 74 65  le,value,expecte
bef0: 64 2c 74 6f 6c 2c 75 6e 69 74 73 2c 63 6f 6d 6d  d,tol,units,comm
bf00: 65 6e 74 20 46 52 4f 4d 20 74 65 73 74 5f 64 61  ent FROM test_da
bf10: 74 61 20 57 48 45 52 45 20 74 65 73 74 5f 69 64  ta WHERE test_id
bf20: 3d 3f 3b 22 29 0a 09 20 20 20 20 20 28 64 62 3a  =?;")..     (db:
bf30: 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74  test-get-id test
bf40: 64 61 74 29 29 29 29 0a 09 20 29 29 0a 20 20 20  dat)))).. )).   
bf50: 20 20 70 72 65 76 2d 74 65 73 74 73 29 29 29 0a    prev-tests))).
bf60: 09 20 0a 20 20 20 20 20 0a                       . .     .