Megatest

Hex Artifact Content
Login

Artifact 6158fe06e1af99c214ad1ab7b412d41185d0c11a:


0000: 0a 3b 3b 20 43 6f 70 79 72 69 67 68 74 20 32 30  .;; Copyright 20
0010: 30 36 2d 32 30 31 31 2c 20 4d 61 74 74 68 65 77  06-2011, Matthew
0020: 20 57 65 6c 6c 61 6e 64 2e 0a 3b 3b 20 0a 3b 3b   Welland..;; .;;
0030: 20 20 54 68 69 73 20 70 72 6f 67 72 61 6d 20 69    This program i
0040: 73 20 6d 61 64 65 20 61 76 61 69 6c 61 62 6c 65  s made available
0050: 20 75 6e 64 65 72 20 74 68 65 20 47 4e 55 20 47   under the GNU G
0060: 50 4c 20 76 65 72 73 69 6f 6e 20 32 2e 30 20 6f  PL version 2.0 o
0070: 72 0a 3b 3b 20 20 67 72 65 61 74 65 72 2e 20 53  r.;;  greater. S
0080: 65 65 20 74 68 65 20 61 63 63 6f 6d 70 61 6e 79  ee the accompany
0090: 69 6e 67 20 66 69 6c 65 20 43 4f 50 59 49 4e 47  ing file COPYING
00a0: 20 66 6f 72 20 64 65 74 61 69 6c 73 2e 0a 3b 3b   for details..;;
00b0: 20 0a 3b 3b 20 20 54 68 69 73 20 70 72 6f 67 72   .;;  This progr
00c0: 61 6d 20 69 73 20 64 69 73 74 72 69 62 75 74 65  am is distribute
00d0: 64 20 57 49 54 48 4f 55 54 20 41 4e 59 20 57 41  d WITHOUT ANY WA
00e0: 52 52 41 4e 54 59 3b 20 77 69 74 68 6f 75 74 20  RRANTY; without 
00f0: 65 76 65 6e 20 74 68 65 0a 3b 3b 20 20 69 6d 70  even the.;;  imp
0100: 6c 69 65 64 20 77 61 72 72 61 6e 74 79 20 6f 66  lied warranty of
0110: 20 4d 45 52 43 48 41 4e 54 41 42 49 4c 49 54 59   MERCHANTABILITY
0120: 20 6f 72 20 46 49 54 4e 45 53 53 20 46 4f 52 20   or FITNESS FOR 
0130: 41 20 50 41 52 54 49 43 55 4c 41 52 0a 3b 3b 20  A PARTICULAR.;; 
0140: 20 50 55 52 50 4f 53 45 2e 0a 0a 3b 3b 20 20 73   PURPOSE...;;  s
0150: 74 72 66 74 69 6d 65 28 27 25 6d 2f 25 64 2f 25  trftime('%m/%d/%
0160: 59 20 25 48 3a 25 4d 3a 25 53 27 2c 27 6e 6f 77  Y %H:%M:%S','now
0170: 27 2c 27 6c 6f 63 61 6c 74 69 6d 65 27 29 0a 0a  ','localtime')..
0180: 28 75 73 65 20 73 71 6c 69 74 65 33 20 73 72 66  (use sqlite3 srf
0190: 69 2d 31 20 70 6f 73 69 78 20 72 65 67 65 78 20  i-1 posix regex 
01a0: 72 65 67 65 78 2d 63 61 73 65 20 73 72 66 69 2d  regex-case srfi-
01b0: 36 39 20 64 6f 74 2d 6c 6f 63 6b 69 6e 67 20 28  69 dot-locking (
01c0: 73 72 66 69 20 31 38 29 20 70 6f 73 69 78 2d 65  srfi 18) posix-e
01d0: 78 74 72 61 73 20 64 69 72 65 63 74 6f 72 79 2d  xtras directory-
01e0: 75 74 69 6c 73 29 0a 28 69 6d 70 6f 72 74 20 28  utils).(import (
01f0: 70 72 65 66 69 78 20 73 71 6c 69 74 65 33 20 73  prefix sqlite3 s
0200: 71 6c 69 74 65 33 3a 29 29 0a 0a 28 64 65 63 6c  qlite3:))..(decl
0210: 61 72 65 20 28 75 6e 69 74 20 72 75 6e 73 29 29  are (unit runs))
0220: 0a 28 64 65 63 6c 61 72 65 20 28 75 73 65 73 20  .(declare (uses 
0230: 64 62 29 29 0a 28 64 65 63 6c 61 72 65 20 28 75  db)).(declare (u
0240: 73 65 73 20 63 6f 6d 6d 6f 6e 29 29 0a 28 64 65  ses common)).(de
0250: 63 6c 61 72 65 20 28 75 73 65 73 20 69 74 65 6d  clare (uses item
0260: 73 29 29 0a 28 64 65 63 6c 61 72 65 20 28 75 73  s)).(declare (us
0270: 65 73 20 72 75 6e 63 6f 6e 66 69 67 29 29 0a 28  es runconfig)).(
0280: 64 65 63 6c 61 72 65 20 28 75 73 65 73 20 74 65  declare (uses te
0290: 73 74 73 29 29 0a 28 64 65 63 6c 61 72 65 20 28  sts)).(declare (
02a0: 75 73 65 73 20 73 65 72 76 65 72 29 29 0a 0a 28  uses server))..(
02b0: 69 6e 63 6c 75 64 65 20 22 63 6f 6d 6d 6f 6e 5f  include "common_
02c0: 72 65 63 6f 72 64 73 2e 73 63 6d 22 29 0a 28 69  records.scm").(i
02d0: 6e 63 6c 75 64 65 20 22 6b 65 79 5f 72 65 63 6f  nclude "key_reco
02e0: 72 64 73 2e 73 63 6d 22 29 0a 28 69 6e 63 6c 75  rds.scm").(inclu
02f0: 64 65 20 22 64 62 5f 72 65 63 6f 72 64 73 2e 73  de "db_records.s
0300: 63 6d 22 29 0a 28 69 6e 63 6c 75 64 65 20 22 72  cm").(include "r
0310: 75 6e 5f 72 65 63 6f 72 64 73 2e 73 63 6d 22 29  un_records.scm")
0320: 0a 28 69 6e 63 6c 75 64 65 20 22 74 65 73 74 5f  .(include "test_
0330: 72 65 63 6f 72 64 73 2e 73 63 6d 22 29 0a 0a 3b  records.scm")..;
0340: 3b 20 72 75 6e 73 3a 67 65 74 2d 72 75 6e 73 2d  ; runs:get-runs-
0350: 62 79 2d 70 61 74 74 0a 3b 3b 20 67 65 74 20 72  by-patt.;; get r
0360: 75 6e 73 20 62 79 20 6c 69 73 74 20 6f 66 20 63  uns by list of c
0370: 72 69 74 65 72 69 61 0a 3b 3b 20 72 65 67 69 73  riteria.;; regis
0380: 74 65 72 20 61 20 74 65 73 74 20 72 75 6e 20 77  ter a test run w
0390: 69 74 68 20 74 68 65 20 64 62 0a 3b 3b 0a 3b 3b  ith the db.;;.;;
03a0: 20 55 73 65 3a 20 28 64 62 2d 67 65 74 2d 76 61   Use: (db-get-va
03b0: 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 28 64  lue-by-header (d
03c0: 62 3a 67 65 74 2d 68 65 61 64 65 72 20 72 75 6e  b:get-header run
03d0: 69 6e 66 6f 29 28 64 62 3a 67 65 74 2d 72 6f 77  info)(db:get-row
03e0: 20 72 75 6e 69 6e 66 6f 29 29 0a 3b 3b 20 20 74   runinfo)).;;  t
03f0: 6f 20 65 78 74 72 61 63 74 20 69 6e 66 6f 20 66  o extract info f
0400: 72 6f 6d 20 74 68 65 20 73 74 72 75 63 74 75 72  rom the structur
0410: 65 20 72 65 74 75 72 6e 65 64 0a 3b 3b 0a 28 64  e returned.;;.(d
0420: 65 66 69 6e 65 20 28 72 75 6e 73 3a 67 65 74 2d  efine (runs:get-
0430: 72 75 6e 73 2d 62 79 2d 70 61 74 74 20 64 62 20  runs-by-patt db 
0440: 6b 65 79 73 20 72 75 6e 6e 61 6d 65 70 61 74 74  keys runnamepatt
0450: 20 2e 20 70 61 72 61 6d 73 29 20 3b 3b 20 74 65   . params) ;; te
0460: 73 74 2d 6e 61 6d 65 29 0a 20 20 28 6c 65 74 2a  st-name).  (let*
0470: 20 28 28 6b 65 79 76 61 6c 6c 73 74 20 28 6b 65   ((keyvallst (ke
0480: 79 73 2d 3e 76 61 6c 6c 69 73 74 20 6b 65 79 73  ys->vallist keys
0490: 29 29 0a 09 20 28 74 6d 70 20 20 20 20 20 20 28  )).. (tmp      (
04a0: 72 75 6e 73 3a 67 65 74 2d 73 74 64 2d 72 75 6e  runs:get-std-run
04b0: 2d 66 69 65 6c 64 73 20 6b 65 79 73 20 27 28 22  -fields keys '("
04c0: 69 64 22 20 22 72 75 6e 6e 61 6d 65 22 20 22 73  id" "runname" "s
04d0: 74 61 74 65 22 20 22 73 74 61 74 75 73 22 20 22  tate" "status" "
04e0: 6f 77 6e 65 72 22 20 22 65 76 65 6e 74 5f 74 69  owner" "event_ti
04f0: 6d 65 22 29 29 29 0a 09 20 28 6b 65 79 73 74 72  me"))).. (keystr
0500: 20 20 20 28 63 61 72 20 74 6d 70 29 29 0a 09 20     (car tmp)).. 
0510: 28 68 65 61 64 65 72 20 20 20 28 63 61 64 72 20  (header   (cadr 
0520: 74 6d 70 29 29 0a 09 20 28 72 65 73 20 20 20 20  tmp)).. (res    
0530: 20 27 28 29 29 0a 09 20 28 6b 65 79 2d 70 61 74   '()).. (key-pat
0540: 74 20 22 22 29 29 0a 20 20 20 20 28 66 6f 72 2d  t "")).    (for-
0550: 65 61 63 68 20 28 6c 61 6d 62 64 61 20 28 6b 65  each (lambda (ke
0560: 79 76 61 6c 29 0a 09 09 28 6c 65 74 2a 20 28 28  yval)...(let* ((
0570: 6b 65 79 20 20 20 20 28 76 65 63 74 6f 72 2d 72  key    (vector-r
0580: 65 66 20 6b 65 79 76 61 6c 20 30 29 29 0a 09 09  ef keyval 0))...
0590: 20 20 20 20 20 20 20 28 66 75 6c 6b 65 79 20 28         (fulkey (
05a0: 63 6f 6e 63 20 22 3a 22 20 6b 65 79 29 29 0a 09  conc ":" key))..
05b0: 09 20 20 20 20 20 20 20 28 70 61 74 74 20 20 20  .       (patt   
05c0: 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 66 75  (args:get-arg fu
05d0: 6c 6b 65 79 29 29 29 0a 09 09 20 20 28 69 66 20  lkey)))...  (if 
05e0: 70 61 74 74 0a 09 09 20 20 20 20 20 20 28 73 65  patt...      (se
05f0: 74 21 20 6b 65 79 2d 70 61 74 74 20 28 63 6f 6e  t! key-patt (con
0600: 63 20 6b 65 79 2d 70 61 74 74 20 22 20 41 4e 44  c key-patt " AND
0610: 20 22 20 6b 65 79 20 22 20 6c 69 6b 65 20 27 22   " key " like '"
0620: 20 70 61 74 74 20 22 27 22 29 29 0a 09 09 20 20   patt "'"))...  
0630: 20 20 20 20 28 62 65 67 69 6e 0a 09 09 09 28 64      (begin....(d
0640: 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52  ebug:print 0 "ER
0650: 52 4f 52 3a 20 73 65 61 72 63 68 69 6e 67 20 66  ROR: searching f
0660: 6f 72 20 72 75 6e 73 20 77 69 74 68 20 6e 6f 20  or runs with no 
0670: 70 61 74 74 65 72 6e 20 73 65 74 20 66 6f 72 20  pattern set for 
0680: 22 20 66 75 6c 6b 65 79 29 0a 09 09 09 28 65 78  " fulkey)....(ex
0690: 69 74 20 36 29 29 29 29 29 0a 09 20 20 20 20 20  it 6)))))..     
06a0: 20 6b 65 79 73 29 0a 20 20 20 20 28 73 71 6c 69   keys).    (sqli
06b0: 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77  te3:for-each-row
06c0: 20 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28   .     (lambda (
06d0: 61 20 2e 20 72 29 0a 20 20 20 20 20 20 20 28 73  a . r).       (s
06e0: 65 74 21 20 72 65 73 20 28 63 6f 6e 73 20 28 6c  et! res (cons (l
06f0: 69 73 74 2d 3e 76 65 63 74 6f 72 20 28 63 6f 6e  ist->vector (con
0700: 73 20 61 20 72 29 29 20 72 65 73 29 29 29 0a 20  s a r)) res))). 
0710: 20 20 20 20 64 62 20 0a 20 20 20 20 20 28 63 6f      db .     (co
0720: 6e 63 20 22 53 45 4c 45 43 54 20 22 20 6b 65 79  nc "SELECT " key
0730: 73 74 72 20 22 20 46 52 4f 4d 20 72 75 6e 73 20  str " FROM runs 
0740: 57 48 45 52 45 20 72 75 6e 6e 61 6d 65 20 6c 69  WHERE runname li
0750: 6b 65 20 3f 20 22 20 6b 65 79 2d 70 61 74 74 20  ke ? " key-patt 
0760: 22 3b 22 29 0a 20 20 20 20 20 72 75 6e 6e 61 6d  ";").     runnam
0770: 65 70 61 74 74 29 0a 20 20 20 20 28 76 65 63 74  epatt).    (vect
0780: 6f 72 20 68 65 61 64 65 72 20 72 65 73 29 29 29  or header res)))
0790: 0a 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a  ..(define (runs:
07a0: 74 65 73 74 2d 67 65 74 2d 66 75 6c 6c 2d 70 61  test-get-full-pa
07b0: 74 68 20 74 65 73 74 29 0a 20 20 28 6c 65 74 2a  th test).  (let*
07c0: 20 28 28 74 65 73 74 6e 61 6d 65 20 28 64 62 3a   ((testname (db:
07d0: 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d  test-get-testnam
07e0: 65 20 20 20 74 65 73 74 29 29 0a 09 20 28 69 74  e   test)).. (it
07f0: 65 6d 70 61 74 68 20 28 64 62 3a 74 65 73 74 2d  empath (db:test-
0800: 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74 65  get-item-path te
0810: 73 74 29 29 29 0a 20 20 20 20 28 63 6f 6e 63 20  st))).    (conc 
0820: 74 65 73 74 6e 61 6d 65 20 28 69 66 20 28 65 71  testname (if (eq
0830: 75 61 6c 3f 20 69 74 65 6d 70 61 74 68 20 22 22  ual? itempath ""
0840: 29 20 22 22 20 28 63 6f 6e 63 20 22 28 22 20 69  ) "" (conc "(" i
0850: 74 65 6d 70 61 74 68 20 22 29 22 29 29 29 29 29  tempath ")")))))
0860: 0a 0a 0a 28 64 65 66 69 6e 65 20 28 73 65 74 2d  ...(define (set-
0870: 6d 65 67 61 74 65 73 74 2d 65 6e 76 2d 76 61 72  megatest-env-var
0880: 73 20 64 62 20 72 75 6e 2d 69 64 29 0a 20 20 28  s db run-id).  (
0890: 6c 65 74 20 28 28 6b 65 79 73 20 28 72 64 62 3a  let ((keys (rdb:
08a0: 67 65 74 2d 6b 65 79 73 20 64 62 29 29 29 0a 20  get-keys db))). 
08b0: 20 20 20 28 66 6f 72 2d 65 61 63 68 20 28 6c 61     (for-each (la
08c0: 6d 62 64 61 20 28 6b 65 79 29 0a 09 09 28 73 71  mbda (key)...(sq
08d0: 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72  lite3:for-each-r
08e0: 6f 77 0a 09 09 20 28 6c 61 6d 62 64 61 20 28 76  ow... (lambda (v
08f0: 61 6c 29 0a 09 09 20 20 20 28 64 65 62 75 67 3a  al)...   (debug:
0900: 70 72 69 6e 74 20 32 20 22 73 65 74 65 6e 76 20  print 2 "setenv 
0910: 22 20 28 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64  " (key:get-field
0920: 6e 61 6d 65 20 6b 65 79 29 20 22 20 22 20 76 61  name key) " " va
0930: 6c 29 0a 09 09 20 20 20 28 73 65 74 65 6e 76 20  l)...   (setenv 
0940: 28 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64 6e 61  (key:get-fieldna
0950: 6d 65 20 6b 65 79 29 20 76 61 6c 29 29 0a 09 09  me key) val))...
0960: 20 64 62 20 0a 09 09 20 28 63 6f 6e 63 20 22 53   db ... (conc "S
0970: 45 4c 45 43 54 20 22 20 28 6b 65 79 3a 67 65 74  ELECT " (key:get
0980: 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65 79 29 20  -fieldname key) 
0990: 22 20 46 52 4f 4d 20 72 75 6e 73 20 57 48 45 52  " FROM runs WHER
09a0: 45 20 69 64 3d 3f 3b 22 29 0a 09 09 20 72 75 6e  E id=?;")... run
09b0: 2d 69 64 29 29 0a 09 20 20 20 20 20 20 6b 65 79  -id))..      key
09c0: 73 29 0a 20 20 20 20 28 61 6c 69 73 74 2d 3e 65  s).    (alist->e
09d0: 6e 76 2d 76 61 72 73 20 28 68 61 73 68 2d 74 61  nv-vars (hash-ta
09e0: 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20  ble-ref/default 
09f0: 2a 63 6f 6e 66 69 67 64 61 74 2a 20 22 65 6e 76  *configdat* "env
0a00: 2d 6f 76 65 72 72 69 64 65 22 20 27 28 29 29 29  -override" '()))
0a10: 0a 20 20 20 20 3b 3b 20 4c 65 74 73 20 75 73 65  .    ;; Lets use
0a20: 20 74 68 69 73 20 61 73 20 61 6e 20 6f 70 70 6f   this as an oppo
0a30: 72 74 75 6e 69 74 79 20 74 6f 20 70 75 74 20 4d  rtunity to put M
0a40: 54 5f 52 55 4e 4e 41 4d 45 20 69 6e 20 74 68 65  T_RUNNAME in the
0a50: 20 65 6e 76 69 72 6f 6e 6d 65 6e 74 0a 20 20 20   environment.   
0a60: 20 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61   (sqlite3:for-ea
0a70: 63 68 2d 72 6f 77 0a 20 20 20 20 20 28 6c 61 6d  ch-row.     (lam
0a80: 62 64 61 20 28 72 75 6e 6e 61 6d 65 29 0a 20 20  bda (runname).  
0a90: 20 20 20 20 20 28 73 65 74 65 6e 76 20 22 4d 54       (setenv "MT
0aa0: 5f 52 55 4e 4e 41 4d 45 22 20 72 75 6e 6e 61 6d  _RUNNAME" runnam
0ab0: 65 29 29 0a 20 20 20 20 20 64 62 0a 20 20 20 20  e)).     db.    
0ac0: 20 22 53 45 4c 45 43 54 20 72 75 6e 6e 61 6d 65   "SELECT runname
0ad0: 20 46 52 4f 4d 20 72 75 6e 73 20 57 48 45 52 45   FROM runs WHERE
0ae0: 20 69 64 3d 3f 3b 22 0a 20 20 20 20 20 72 75 6e   id=?;".     run
0af0: 2d 69 64 29 0a 20 20 20 20 29 29 0a 0a 28 64 65  -id).    ))..(de
0b00: 66 69 6e 65 20 28 73 65 74 2d 69 74 65 6d 2d 65  fine (set-item-e
0b10: 6e 76 2d 76 61 72 73 20 69 74 65 6d 64 61 74 29  nv-vars itemdat)
0b20: 0a 20 20 28 66 6f 72 2d 65 61 63 68 20 28 6c 61  .  (for-each (la
0b30: 6d 62 64 61 20 28 69 74 65 6d 29 0a 09 20 20 20  mbda (item)..   
0b40: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
0b50: 32 20 22 73 65 74 65 6e 76 20 22 20 28 63 61 72  2 "setenv " (car
0b60: 20 69 74 65 6d 29 20 22 20 22 20 28 63 61 64 72   item) " " (cadr
0b70: 20 69 74 65 6d 29 29 0a 09 20 20 20 20 20 20 28   item))..      (
0b80: 73 65 74 65 6e 76 20 28 63 61 72 20 69 74 65 6d  setenv (car item
0b90: 29 20 28 63 61 64 72 20 69 74 65 6d 29 29 29 0a  ) (cadr item))).
0ba0: 09 20 20 20 20 69 74 65 6d 64 61 74 29 29 0a 0a  .    itemdat))..
0bb0: 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 63 61  (define (runs:ca
0bc0: 6e 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73  n-run-more-tests
0bd0: 20 64 62 20 74 65 73 74 2d 72 65 63 6f 72 64 29   db test-record)
0be0: 0a 20 20 28 6c 65 74 2a 20 28 28 74 63 6f 6e 66  .  (let* ((tconf
0bf0: 69 67 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ig              
0c00: 20 20 20 28 74 65 73 74 73 3a 74 65 73 74 71 75     (tests:testqu
0c10: 65 75 65 2d 67 65 74 2d 74 65 73 74 63 6f 6e 66  eue-get-testconf
0c20: 69 67 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29  ig test-record))
0c30: 0a 09 20 28 6a 6f 62 67 72 6f 75 70 20 20 20 20  .. (jobgroup    
0c40: 20 20 20 20 20 20 20 20 20 20 20 20 28 63 6f 6e              (con
0c50: 66 69 67 2d 6c 6f 6f 6b 75 70 20 74 63 6f 6e 66  fig-lookup tconf
0c60: 69 67 20 22 72 65 71 75 69 72 65 6d 65 6e 74 73  ig "requirements
0c70: 22 20 22 6a 6f 62 67 72 6f 75 70 22 29 29 0a 09  " "jobgroup"))..
0c80: 20 28 6e 75 6d 2d 72 75 6e 6e 69 6e 67 20 20 20   (num-running   
0c90: 20 20 20 20 20 20 20 20 20 20 28 64 62 3a 67 65            (db:ge
0ca0: 74 2d 63 6f 75 6e 74 2d 74 65 73 74 73 2d 72 75  t-count-tests-ru
0cb0: 6e 6e 69 6e 67 20 64 62 29 29 0a 09 20 28 6e 75  nning db)).. (nu
0cc0: 6d 2d 72 75 6e 6e 69 6e 67 2d 69 6e 2d 6a 6f 62  m-running-in-job
0cd0: 67 72 6f 75 70 20 28 64 62 3a 67 65 74 2d 63 6f  group (db:get-co
0ce0: 75 6e 74 2d 74 65 73 74 73 2d 72 75 6e 6e 69 6e  unt-tests-runnin
0cf0: 67 2d 69 6e 2d 6a 6f 62 67 72 6f 75 70 20 64 62  g-in-jobgroup db
0d00: 20 6a 6f 62 67 72 6f 75 70 29 29 0a 09 20 28 6d   jobgroup)).. (m
0d10: 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f  ax-concurrent-jo
0d20: 62 73 20 20 20 20 20 28 63 6f 6e 66 69 67 2d 6c  bs     (config-l
0d30: 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67 64 61 74  ookup *configdat
0d40: 2a 20 22 73 65 74 75 70 22 20 20 20 20 20 22 6d  * "setup"     "m
0d50: 61 78 5f 63 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f  ax_concurrent_jo
0d60: 62 73 22 29 29 0a 09 20 28 6a 6f 62 2d 67 72 6f  bs")).. (job-gro
0d70: 75 70 2d 6c 69 6d 69 74 20 20 20 20 20 20 20 20  up-limit        
0d80: 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20   (config-lookup 
0d90: 2a 63 6f 6e 66 69 67 64 61 74 2a 20 22 6a 6f 62  *configdat* "job
0da0: 67 72 6f 75 70 73 22 20 6a 6f 62 67 72 6f 75 70  groups" jobgroup
0db0: 29 29 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70  ))).    (debug:p
0dc0: 72 69 6e 74 20 32 20 22 6d 61 78 2d 63 6f 6e 63  rint 2 "max-conc
0dd0: 75 72 72 65 6e 74 2d 6a 6f 62 73 3a 20 22 20 6d  urrent-jobs: " m
0de0: 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f  ax-concurrent-jo
0df0: 62 73 20 22 2c 20 6e 75 6d 2d 72 75 6e 6e 69 6e  bs ", num-runnin
0e00: 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67  g: " num-running
0e10: 29 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28  ).    (if (not (
0e20: 65 71 3f 20 30 20 2a 67 6c 6f 62 61 6c 65 78 69  eq? 0 *globalexi
0e30: 74 73 74 61 74 75 73 2a 29 29 0a 09 23 66 0a 09  tstatus*))..#f..
0e40: 28 6c 65 74 20 28 28 63 61 6e 2d 6e 6f 74 2d 72  (let ((can-not-r
0e50: 75 6e 2d 6d 6f 72 65 20 28 63 6f 6e 64 0a 09 09  un-more (cond...
0e60: 09 09 20 3b 3b 20 69 66 20 6d 61 78 2d 63 6f 6e  .. ;; if max-con
0e70: 63 75 72 72 65 6e 74 2d 6a 6f 62 73 20 69 73 20  current-jobs is 
0e80: 73 65 74 20 61 6e 64 20 74 68 65 20 6e 75 6d 62  set and the numb
0e90: 65 72 20 72 75 6e 6e 69 6e 67 20 69 73 20 67 72  er running is gr
0ea0: 65 61 74 65 72 20 0a 09 09 09 09 20 3b 3b 20 74  eater ..... ;; t
0eb0: 68 61 6e 20 69 74 20 74 68 61 6e 20 63 61 6e 6e  han it than cann
0ec0: 6f 74 20 72 75 6e 20 6d 6f 72 65 20 6a 6f 62 73  ot run more jobs
0ed0: 0a 09 09 09 09 20 28 28 61 6e 64 20 6d 61 78 2d  ..... ((and max-
0ee0: 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 0a  concurrent-jobs.
0ef0: 09 09 09 09 20 20 20 20 20 20 20 28 73 74 72 69  ....       (stri
0f00: 6e 67 2d 3e 6e 75 6d 62 65 72 20 6d 61 78 2d 63  ng->number max-c
0f10: 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29 0a  oncurrent-jobs).
0f20: 09 09 09 09 20 20 20 20 20 20 20 28 3e 3d 20 6e  ....       (>= n
0f30: 75 6d 2d 72 75 6e 6e 69 6e 67 20 28 73 74 72 69  um-running (stri
0f40: 6e 67 2d 3e 6e 75 6d 62 65 72 20 6d 61 78 2d 63  ng->number max-c
0f50: 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29 29  oncurrent-jobs))
0f60: 29 0a 09 09 09 09 20 20 28 64 65 62 75 67 3a 70  ).....  (debug:p
0f70: 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e 47 3a  rint 0 "WARNING:
0f80: 20 4d 61 78 20 72 75 6e 6e 69 6e 67 20 6a 6f 62   Max running job
0f90: 73 20 65 78 63 65 65 64 65 64 2c 20 63 75 72 72  s exceeded, curr
0fa0: 65 6e 74 20 6e 75 6d 62 65 72 20 72 75 6e 6e 69  ent number runni
0fb0: 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69 6e  ng: " num-runnin
0fc0: 67 20 0a 09 09 09 09 09 20 20 20 20 20 20 20 22  g ......       "
0fd0: 2c 20 6d 61 78 5f 63 6f 6e 63 75 72 72 65 6e 74  , max_concurrent
0fe0: 5f 6a 6f 62 73 3a 20 22 20 6d 61 78 2d 63 6f 6e  _jobs: " max-con
0ff0: 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29 0a 09 09  current-jobs)...
1000: 09 09 20 20 23 74 29 0a 09 09 09 09 20 3b 3b 20  ..  #t)..... ;; 
1010: 69 66 20 6a 6f 62 2d 67 72 6f 75 70 2d 6c 69 6d  if job-group-lim
1020: 69 74 20 69 73 20 73 65 74 20 61 6e 64 20 6e 75  it is set and nu
1030: 6d 62 65 72 20 6f 66 20 6a 6f 62 73 20 69 6e 20  mber of jobs in 
1040: 74 68 65 20 67 72 6f 75 70 20 69 73 20 67 72 65  the group is gre
1050: 61 74 65 72 0a 09 09 09 09 20 3b 3b 20 74 68 61  ater..... ;; tha
1060: 6e 20 74 68 65 20 6c 69 6d 69 74 20 74 68 65 6e  n the limit then
1070: 20 63 61 6e 6e 6f 74 20 72 75 6e 20 6d 6f 72 65   cannot run more
1080: 20 6a 6f 62 73 20 6f 66 20 74 68 69 73 20 6b 69   jobs of this ki
1090: 6e 64 0a 09 09 09 09 20 28 28 61 6e 64 20 6a 6f  nd..... ((and jo
10a0: 62 2d 67 72 6f 75 70 2d 6c 69 6d 69 74 0a 09 09  b-group-limit...
10b0: 09 09 20 20 20 20 20 20 20 28 3e 3d 20 6e 75 6d  ..       (>= num
10c0: 2d 72 75 6e 6e 69 6e 67 2d 69 6e 2d 6a 6f 62 67  -running-in-jobg
10d0: 72 6f 75 70 20 6a 6f 62 2d 67 72 6f 75 70 2d 6c  roup job-group-l
10e0: 69 6d 69 74 29 29 0a 09 09 09 09 20 20 28 64 65  imit)).....  (de
10f0: 62 75 67 3a 70 72 69 6e 74 20 31 20 22 57 41 52  bug:print 1 "WAR
1100: 4e 49 4e 47 3a 20 6e 75 6d 62 65 72 20 6f 66 20  NING: number of 
1110: 6a 6f 62 73 20 22 20 6e 75 6d 2d 72 75 6e 6e 69  jobs " num-runni
1120: 6e 67 2d 69 6e 2d 6a 6f 62 67 72 6f 75 70 20 0a  ng-in-jobgroup .
1130: 09 09 09 09 09 20 20 20 20 20 20 20 22 20 69 6e  .....       " in
1140: 20 22 20 6a 6f 62 67 72 6f 75 70 20 22 20 65 78   " jobgroup " ex
1150: 63 65 65 64 65 64 2c 20 77 69 6c 6c 20 6e 6f 74  ceeded, will not
1160: 20 72 75 6e 20 22 20 28 74 65 73 74 73 3a 74 65   run " (tests:te
1170: 73 74 71 75 65 75 65 2d 67 65 74 2d 74 65 73 74  stqueue-get-test
1180: 6e 61 6d 65 20 74 65 73 74 2d 72 65 63 6f 72 64  name test-record
1190: 29 29 0a 09 09 09 09 20 20 23 74 29 0a 09 09 09  )).....  #t)....
11a0: 09 20 28 65 6c 73 65 20 23 66 29 29 29 29 0a 09  . (else #f))))..
11b0: 20 20 28 6e 6f 74 20 63 61 6e 2d 6e 6f 74 2d 72    (not can-not-r
11c0: 75 6e 2d 6d 6f 72 65 29 29 29 29 29 0a 0a 3b 3b  un-more)))))..;;
11d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
11e0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
11f0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1200: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1210: 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 4e 65 77 20 6d 65  ======.;; New me
1220: 74 68 6f 64 6f 6c 6f 67 79 2e 20 54 68 65 73 65  thodology. These
1230: 20 72 6f 75 74 69 6e 65 73 20 77 69 6c 6c 20 72   routines will r
1240: 65 70 6c 61 63 65 20 74 68 65 20 61 62 6f 76 65  eplace the above
1250: 20 69 6e 20 74 69 6d 65 2e 20 46 6f 72 0a 3b 3b   in time. For.;;
1260: 20 6e 6f 77 20 74 68 65 20 63 6f 64 65 20 69 73   now the code is
1270: 20 64 75 70 6c 69 63 61 74 65 64 2e 20 54 68 69   duplicated. Thi
1280: 73 20 73 74 75 66 66 20 69 73 20 69 6e 69 74 69  s stuff is initi
1290: 61 6c 6c 79 20 75 73 65 64 20 69 6e 20 74 68 65  ally used in the
12a0: 20 6d 6f 6e 69 74 6f 72 0a 3b 3b 20 62 61 73 65   monitor.;; base
12b0: 64 20 63 6f 64 65 2e 0a 3b 3b 3d 3d 3d 3d 3d 3d  d code..;;======
12c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
12d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
12e0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
12f0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1300: 0a 0a 3b 3b 20 72 65 67 69 73 74 65 72 20 61 20  ..;; register a 
1310: 74 65 73 74 20 72 75 6e 20 77 69 74 68 20 74 68  test run with th
1320: 65 20 64 62 0a 28 64 65 66 69 6e 65 20 28 72 75  e db.(define (ru
1330: 6e 73 3a 72 65 67 69 73 74 65 72 2d 72 75 6e 20  ns:register-run 
1340: 64 62 20 6b 65 79 73 20 6b 65 79 76 61 6c 6c 73  db keys keyvalls
1350: 74 20 72 75 6e 6e 61 6d 65 20 73 74 61 74 65 20  t runname state 
1360: 73 74 61 74 75 73 20 75 73 65 72 29 0a 20 20 28  status user).  (
1370: 64 65 62 75 67 3a 70 72 69 6e 74 20 33 20 22 72  debug:print 3 "r
1380: 75 6e 73 3a 72 65 67 69 73 74 65 72 2d 72 75 6e  uns:register-run
1390: 2c 20 6b 65 79 73 3a 20 22 20 6b 65 79 73 20 22  , keys: " keys "
13a0: 20 6b 65 79 76 61 6c 6c 73 74 3a 20 22 20 6b 65   keyvallst: " ke
13b0: 79 76 61 6c 6c 73 74 20 22 20 72 75 6e 6e 61 6d  yvallst " runnam
13c0: 65 3a 20 22 20 72 75 6e 6e 61 6d 65 20 22 20 73  e: " runname " s
13d0: 74 61 74 65 3a 20 22 20 73 74 61 74 65 20 22 20  tate: " state " 
13e0: 73 74 61 74 75 73 3a 20 22 20 73 74 61 74 75 73  status: " status
13f0: 20 22 20 75 73 65 72 3a 20 22 20 75 73 65 72 29   " user: " user)
1400: 0a 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 73 74  .  (let* ((keyst
1410: 72 20 20 20 20 28 6b 65 79 73 2d 3e 6b 65 79 73  r    (keys->keys
1420: 74 72 20 6b 65 79 73 29 29 0a 09 20 28 63 6f 6d  tr keys)).. (com
1430: 6d 61 20 20 20 20 20 28 69 66 20 28 3e 20 28 6c  ma     (if (> (l
1440: 65 6e 67 74 68 20 6b 65 79 73 29 20 30 29 20 22  ength keys) 0) "
1450: 2c 22 20 22 22 29 29 0a 09 20 28 61 6e 64 73 74  ," "")).. (andst
1460: 72 20 20 20 20 28 69 66 20 28 3e 20 28 6c 65 6e  r    (if (> (len
1470: 67 74 68 20 6b 65 79 73 29 20 30 29 20 22 20 41  gth keys) 0) " A
1480: 4e 44 20 22 20 22 22 29 29 0a 09 20 28 76 61 6c  ND " "")).. (val
1490: 73 6c 6f 74 73 20 20 28 6b 65 79 73 2d 3e 76 61  slots  (keys->va
14a0: 6c 73 6c 6f 74 73 20 6b 65 79 73 29 29 20 3b 3b  lslots keys)) ;;
14b0: 20 3f 2c 3f 2c 3f 20 2e 2e 2e 0a 09 20 28 6b 65   ?,?,? ..... (ke
14c0: 79 76 61 6c 73 20 20 20 28 6d 61 70 20 63 61 64  yvals   (map cad
14d0: 72 20 6b 65 79 76 61 6c 6c 73 74 29 29 0a 09 20  r keyvallst)).. 
14e0: 28 61 6c 6c 76 61 6c 73 20 20 20 28 61 70 70 65  (allvals   (appe
14f0: 6e 64 20 28 6c 69 73 74 20 72 75 6e 6e 61 6d 65  nd (list runname
1500: 20 73 74 61 74 65 20 73 74 61 74 75 73 20 75 73   state status us
1510: 65 72 29 20 6b 65 79 76 61 6c 73 29 29 0a 09 20  er) keyvals)).. 
1520: 28 71 72 79 76 61 6c 73 20 20 20 28 61 70 70 65  (qryvals   (appe
1530: 6e 64 20 28 6c 69 73 74 20 72 75 6e 6e 61 6d 65  nd (list runname
1540: 29 20 6b 65 79 76 61 6c 73 29 29 0a 09 20 28 6b  ) keyvals)).. (k
1550: 65 79 3d 3f 73 74 72 20 20 28 73 74 72 69 6e 67  ey=?str  (string
1560: 2d 69 6e 74 65 72 73 70 65 72 73 65 20 28 6d 61  -intersperse (ma
1570: 70 20 28 6c 61 6d 62 64 61 20 28 6b 29 28 63 6f  p (lambda (k)(co
1580: 6e 63 20 28 6b 65 79 3a 67 65 74 2d 66 69 65 6c  nc (key:get-fiel
1590: 64 6e 61 6d 65 20 6b 29 20 22 3d 3f 22 29 29 20  dname k) "=?")) 
15a0: 6b 65 79 73 29 20 22 20 41 4e 44 20 22 29 29 29  keys) " AND ")))
15b0: 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e  .    (debug:prin
15c0: 74 20 33 20 22 6b 65 79 73 3a 20 22 20 6b 65 79  t 3 "keys: " key
15d0: 73 20 22 20 61 6c 6c 76 61 6c 73 3a 20 22 20 61  s " allvals: " a
15e0: 6c 6c 76 61 6c 73 20 22 20 6b 65 79 76 61 6c 73  llvals " keyvals
15f0: 3a 20 22 20 6b 65 79 76 61 6c 73 29 0a 20 20 20  : " keyvals).   
1600: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20   (debug:print 2 
1610: 22 4e 4f 54 45 3a 20 75 73 69 6e 67 20 74 61 72  "NOTE: using tar
1620: 67 65 74 20 22 20 28 73 74 72 69 6e 67 2d 69 6e  get " (string-in
1630: 74 65 72 73 70 65 72 73 65 20 6b 65 79 76 61 6c  tersperse keyval
1640: 73 20 22 2f 22 29 20 22 20 66 6f 72 20 74 68 69  s "/") " for thi
1650: 73 20 72 75 6e 22 29 0a 20 20 20 20 28 69 66 20  s run").    (if 
1660: 28 61 6e 64 20 72 75 6e 6e 61 6d 65 20 28 6e 75  (and runname (nu
1670: 6c 6c 3f 20 28 66 69 6c 74 65 72 20 28 6c 61 6d  ll? (filter (lam
1680: 62 64 61 20 28 78 29 28 6e 6f 74 20 78 29 29 20  bda (x)(not x)) 
1690: 6b 65 79 76 61 6c 73 29 29 29 20 3b 3b 20 74 68  keyvals))) ;; th
16a0: 65 72 65 20 6d 75 73 74 20 62 65 20 61 20 62 65  ere must be a be
16b0: 74 74 65 72 20 77 61 79 20 74 6f 20 22 61 70 70  tter way to "app
16c0: 6c 79 20 61 6e 64 22 0a 09 28 6c 65 74 20 28 28  ly and"..(let ((
16d0: 72 65 73 20 23 66 29 29 0a 09 20 20 28 61 70 70  res #f))..  (app
16e0: 6c 79 20 73 71 6c 69 74 65 33 3a 65 78 65 63 75  ly sqlite3:execu
16f0: 74 65 20 64 62 20 28 63 6f 6e 63 20 22 49 4e 53  te db (conc "INS
1700: 45 52 54 20 4f 52 20 49 47 4e 4f 52 45 20 49 4e  ERT OR IGNORE IN
1710: 54 4f 20 72 75 6e 73 20 28 72 75 6e 6e 61 6d 65  TO runs (runname
1720: 2c 73 74 61 74 65 2c 73 74 61 74 75 73 2c 6f 77  ,state,status,ow
1730: 6e 65 72 2c 65 76 65 6e 74 5f 74 69 6d 65 22 20  ner,event_time" 
1740: 63 6f 6d 6d 61 20 6b 65 79 73 74 72 20 22 29 20  comma keystr ") 
1750: 56 41 4c 55 45 53 20 28 3f 2c 3f 2c 3f 2c 3f 2c  VALUES (?,?,?,?,
1760: 73 74 72 66 74 69 6d 65 28 27 25 73 27 2c 27 6e  strftime('%s','n
1770: 6f 77 27 29 22 20 63 6f 6d 6d 61 20 76 61 6c 73  ow')" comma vals
1780: 6c 6f 74 73 20 22 29 3b 22 29 0a 09 09 20 61 6c  lots ");")... al
1790: 6c 76 61 6c 73 29 0a 09 20 20 28 61 70 70 6c 79  lvals)..  (apply
17a0: 20 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63   sqlite3:for-eac
17b0: 68 2d 72 6f 77 20 0a 09 20 20 20 28 6c 61 6d 62  h-row ..   (lamb
17c0: 64 61 20 28 69 64 29 0a 09 20 20 20 20 20 28 73  da (id)..     (s
17d0: 65 74 21 20 72 65 73 20 69 64 29 29 0a 09 20 20  et! res id))..  
17e0: 20 64 62 0a 09 20 20 20 28 6c 65 74 20 28 28 71   db..   (let ((q
17f0: 72 79 20 28 63 6f 6e 63 20 22 53 45 4c 45 43 54  ry (conc "SELECT
1800: 20 69 64 20 46 52 4f 4d 20 72 75 6e 73 20 57 48   id FROM runs WH
1810: 45 52 45 20 28 72 75 6e 6e 61 6d 65 3d 3f 20 22  ERE (runname=? "
1820: 20 61 6e 64 73 74 72 20 6b 65 79 3d 3f 73 74 72   andstr key=?str
1830: 20 22 29 3b 22 29 29 29 0a 09 20 20 20 20 20 3b   ");")))..     ;
1840: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22  (debug:print 4 "
1850: 71 72 79 3a 20 22 20 71 72 79 29 20 0a 09 20 20  qry: " qry) ..  
1860: 20 20 20 71 72 79 29 0a 09 20 20 20 71 72 79 76     qry)..   qryv
1870: 61 6c 73 29 0a 09 20 20 28 73 71 6c 69 74 65 33  als)..  (sqlite3
1880: 3a 65 78 65 63 75 74 65 20 64 62 20 22 55 50 44  :execute db "UPD
1890: 41 54 45 20 72 75 6e 73 20 53 45 54 20 73 74 61  ATE runs SET sta
18a0: 74 65 3d 3f 2c 73 74 61 74 75 73 3d 3f 20 57 48  te=?,status=? WH
18b0: 45 52 45 20 69 64 3d 3f 3b 22 20 73 74 61 74 65  ERE id=?;" state
18c0: 20 73 74 61 74 75 73 20 72 65 73 29 0a 09 20 20   status res)..  
18d0: 72 65 73 29 20 0a 09 28 62 65 67 69 6e 0a 09 20  res) ..(begin.. 
18e0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
18f0: 22 45 52 52 4f 52 3a 20 43 61 6c 6c 65 64 20 77  "ERROR: Called w
1900: 69 74 68 6f 75 74 20 61 6c 6c 20 6e 65 63 65 73  ithout all neces
1910: 73 61 72 79 20 6b 65 79 73 22 29 0a 09 20 20 23  sary keys")..  #
1920: 66 29 29 29 29 0a 0a 3b 3b 20 54 68 69 73 20 69  f))))..;; This i
1930: 73 20 61 20 64 75 70 6c 69 63 61 74 65 20 6f 66  s a duplicate of
1940: 20 72 75 6e 2d 74 65 73 74 73 20 28 77 68 69 63   run-tests (whic
1950: 68 20 68 61 73 20 62 65 65 6e 20 64 65 70 72 65  h has been depre
1960: 63 61 74 65 64 29 2e 20 55 73 65 20 74 68 69 73  cated). Use this
1970: 20 6f 6e 65 20 69 6e 73 74 65 61 64 20 6f 66 20   one instead of 
1980: 72 75 6e 20 74 65 73 74 73 2e 0a 3b 3b 20 6b 65  run tests..;; ke
1990: 79 76 61 6c 73 0a 28 64 65 66 69 6e 65 20 28 72  yvals.(define (r
19a0: 75 6e 73 3a 72 75 6e 2d 74 65 73 74 73 20 64 62  uns:run-tests db
19b0: 20 74 61 72 67 65 74 20 72 75 6e 6e 61 6d 65 20   target runname 
19c0: 74 65 73 74 2d 70 61 74 74 73 20 75 73 65 72 20  test-patts user 
19d0: 66 6c 61 67 73 29 0a 20 20 28 6c 65 74 2a 20 28  flags).  (let* (
19e0: 28 6b 65 79 73 20 20 20 20 20 20 20 20 28 72 64  (keys        (rd
19f0: 62 3a 67 65 74 2d 6b 65 79 73 20 64 62 29 29 0a  b:get-keys db)).
1a00: 09 20 28 6b 65 79 76 61 6c 6c 73 74 20 20 20 28  . (keyvallst   (
1a10: 6b 65 79 73 3a 74 61 72 67 65 74 2d 3e 6b 65 79  keys:target->key
1a20: 76 61 6c 20 6b 65 79 73 20 74 61 72 67 65 74 29  val keys target)
1a30: 29 0a 09 20 28 72 75 6e 2d 69 64 20 20 20 20 20  ).. (run-id     
1a40: 20 28 72 75 6e 73 3a 72 65 67 69 73 74 65 72 2d   (runs:register-
1a50: 72 75 6e 20 64 62 20 6b 65 79 73 20 6b 65 79 76  run db keys keyv
1a60: 61 6c 6c 73 74 20 72 75 6e 6e 61 6d 65 20 22 6e  allst runname "n
1a70: 65 77 22 20 22 6e 2f 61 22 20 75 73 65 72 29 29  ew" "n/a" user))
1a80: 20 20 3b 3b 20 20 74 65 73 74 2d 6e 61 6d 65 29    ;;  test-name)
1a90: 29 29 0a 09 20 28 64 65 66 65 72 72 65 64 20 20  )).. (deferred  
1aa0: 20 20 27 28 29 29 20 3b 3b 20 64 65 6c 61 79 20    '()) ;; delay 
1ab0: 72 75 6e 6e 69 6e 67 20 74 68 65 73 65 20 73 69  running these si
1ac0: 6e 63 65 20 74 68 65 79 20 68 61 76 65 20 61 20  nce they have a 
1ad0: 77 61 69 74 6f 6e 20 63 6c 61 75 73 65 0a 09 20  waiton clause.. 
1ae0: 3b 3b 20 6b 65 65 70 67 6f 69 6e 67 20 69 73 20  ;; keepgoing is 
1af0: 74 68 65 20 64 65 66 61 63 74 6f 20 6d 6f 64 61  the defacto moda
1b00: 6c 69 74 79 20 6e 6f 77 2c 20 77 69 6c 6c 20 61  lity now, will a
1b10: 64 64 20 68 69 74 2d 6e 2d 72 75 6e 20 61 20 62  dd hit-n-run a b
1b20: 69 74 20 6c 61 74 65 72 0a 09 20 3b 3b 20 28 6b  it later.. ;; (k
1b30: 65 65 70 67 6f 69 6e 67 20 20 20 28 68 61 73 68  eepgoing   (hash
1b40: 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75  -table-ref/defau
1b50: 6c 74 20 66 6c 61 67 73 20 22 2d 6b 65 65 70 67  lt flags "-keepg
1b60: 6f 69 6e 67 22 20 23 66 29 29 0a 09 20 28 74 65  oing" #f)).. (te
1b70: 73 74 2d 6e 61 6d 65 73 20 20 27 28 29 29 0a 09  st-names  '())..
1b80: 20 28 72 75 6e 63 6f 6e 66 69 67 66 20 20 20 28   (runconfigf   (
1b90: 63 6f 6e 63 20 20 2a 74 6f 70 70 61 74 68 2a 20  conc  *toppath* 
1ba0: 22 2f 72 75 6e 63 6f 6e 66 69 67 73 2e 63 6f 6e  "/runconfigs.con
1bb0: 66 69 67 22 29 29 0a 09 20 28 72 65 71 75 69 72  fig")).. (requir
1bc0: 65 64 2d 74 65 73 74 73 20 27 28 29 29 0a 09 20  ed-tests '()).. 
1bd0: 28 74 65 73 74 2d 72 65 63 6f 72 64 73 20 28 6d  (test-records (m
1be0: 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29  ake-hash-table))
1bf0: 29 0a 0a 20 20 20 20 28 73 65 74 2d 6d 65 67 61  )..    (set-mega
1c00: 74 65 73 74 2d 65 6e 76 2d 76 61 72 73 20 64 62  test-env-vars db
1c10: 20 72 75 6e 2d 69 64 29 20 3b 3b 20 74 68 65 73   run-id) ;; thes
1c20: 65 20 6d 61 79 20 62 65 20 6e 65 65 64 65 64 20  e may be needed 
1c30: 62 79 20 74 68 65 20 6c 61 75 6e 63 68 69 6e 67  by the launching
1c40: 20 70 72 6f 63 65 73 73 0a 0a 20 20 20 20 28 69   process..    (i
1c50: 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20  f (file-exists? 
1c60: 72 75 6e 63 6f 6e 66 69 67 66 29 0a 09 28 73 65  runconfigf)..(se
1c70: 74 75 70 2d 65 6e 76 2d 64 65 66 61 75 6c 74 73  tup-env-defaults
1c80: 20 64 62 20 72 75 6e 63 6f 6e 66 69 67 66 20 72   db runconfigf r
1c90: 75 6e 2d 69 64 20 2a 61 6c 72 65 61 64 79 2d 73  un-id *already-s
1ca0: 65 65 6e 2d 72 75 6e 63 6f 6e 66 69 67 2d 69 6e  een-runconfig-in
1cb0: 66 6f 2a 20 22 70 72 65 2d 6c 61 75 6e 63 68 2d  fo* "pre-launch-
1cc0: 65 6e 76 2d 76 61 72 73 22 29 0a 09 28 64 65 62  env-vars")..(deb
1cd0: 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e  ug:print 0 "WARN
1ce0: 49 4e 47 3a 20 59 6f 75 20 64 6f 20 6e 6f 74 20  ING: You do not 
1cf0: 68 61 76 65 20 61 20 72 75 6e 20 63 6f 6e 66 69  have a run confi
1d00: 67 20 66 69 6c 65 3a 20 22 20 72 75 6e 63 6f 6e  g file: " runcon
1d10: 66 69 67 66 29 29 0a 20 20 20 20 0a 20 20 20 20  figf)).    .    
1d20: 3b 3b 20 6c 6f 6f 6b 20 75 70 20 61 6c 6c 20 74  ;; look up all t
1d30: 65 73 74 73 20 6d 61 74 63 68 69 6e 67 20 74 68  ests matching th
1d40: 65 20 63 6f 6d 6d 61 20 73 65 70 61 72 61 74 65  e comma separate
1d50: 64 20 6c 69 73 74 20 6f 66 20 67 6c 6f 62 73 20  d list of globs 
1d60: 69 6e 0a 20 20 20 20 3b 3b 20 74 65 73 74 2d 70  in.    ;; test-p
1d70: 61 74 74 73 20 28 75 73 69 6e 67 20 25 20 61 73  atts (using % as
1d80: 20 77 69 6c 64 63 61 72 64 29 0a 20 20 20 20 28   wildcard).    (
1d90: 66 6f 72 2d 65 61 63 68 20 0a 20 20 20 20 20 28  for-each .     (
1da0: 6c 61 6d 62 64 61 20 28 70 61 74 74 29 0a 20 20  lambda (patt).  
1db0: 20 20 20 20 20 28 6c 65 74 20 28 28 74 65 73 74       (let ((test
1dc0: 73 20 28 67 6c 6f 62 20 28 63 6f 6e 63 20 2a 74  s (glob (conc *t
1dd0: 6f 70 70 61 74 68 2a 20 22 2f 74 65 73 74 73 2f  oppath* "/tests/
1de0: 22 20 28 73 74 72 69 6e 67 2d 74 72 61 6e 73 6c  " (string-transl
1df0: 61 74 65 20 70 61 74 74 20 22 25 22 20 22 2a 22  ate patt "%" "*"
1e00: 29 29 29 29 29 0a 09 20 28 73 65 74 21 20 74 65  ))))).. (set! te
1e10: 73 74 73 20 28 66 69 6c 74 65 72 20 28 6c 61 6d  sts (filter (lam
1e20: 62 64 61 20 28 74 65 73 74 29 28 66 69 6c 65 2d  bda (test)(file-
1e30: 65 78 69 73 74 73 3f 20 28 63 6f 6e 63 20 74 65  exists? (conc te
1e40: 73 74 20 22 2f 74 65 73 74 63 6f 6e 66 69 67 22  st "/testconfig"
1e50: 29 29 29 20 74 65 73 74 73 29 29 0a 09 20 28 73  ))) tests)).. (s
1e60: 65 74 21 20 74 65 73 74 2d 6e 61 6d 65 73 20 28  et! test-names (
1e70: 61 70 70 65 6e 64 20 74 65 73 74 2d 6e 61 6d 65  append test-name
1e80: 73 20 0a 09 09 09 09 20 20 28 6d 61 70 20 28 6c  s .....  (map (l
1e90: 61 6d 62 64 61 20 28 74 65 73 74 70 29 0a 09 09  ambda (testp)...
1ea0: 09 09 09 20 28 6c 61 73 74 20 28 73 74 72 69 6e  ... (last (strin
1eb0: 67 2d 73 70 6c 69 74 20 74 65 73 74 70 20 22 2f  g-split testp "/
1ec0: 22 29 29 29 0a 09 09 09 09 20 20 20 20 20 20 20  "))).....       
1ed0: 74 65 73 74 73 29 29 29 29 29 0a 20 20 20 20 20  tests))))).     
1ee0: 28 69 66 20 74 65 73 74 2d 70 61 74 74 73 20 28  (if test-patts (
1ef0: 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 74 65 73  string-split tes
1f00: 74 2d 70 61 74 74 73 20 22 2c 22 29 28 6c 69 73  t-patts ",")(lis
1f10: 74 20 22 25 22 29 29 29 0a 0a 20 20 20 20 20 3b  t "%")))..     ;
1f20: 3b 20 6e 6f 77 20 72 65 6d 6f 76 65 20 64 75 70  ; now remove dup
1f30: 6c 69 63 61 74 65 73 0a 20 20 20 20 28 73 65 74  licates.    (set
1f40: 21 20 74 65 73 74 2d 6e 61 6d 65 73 20 28 64 65  ! test-names (de
1f50: 6c 65 74 65 2d 64 75 70 6c 69 63 61 74 65 73 20  lete-duplicates 
1f60: 74 65 73 74 2d 6e 61 6d 65 73 29 29 0a 0a 20 20  test-names))..  
1f70: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30    (debug:print 0
1f80: 20 22 49 4e 46 4f 3a 20 74 65 73 74 20 6e 61 6d   "INFO: test nam
1f90: 65 73 20 22 20 74 65 73 74 2d 6e 61 6d 65 73 29  es " test-names)
1fa0: 0a 0a 20 20 20 20 3b 3b 20 6f 6e 20 74 68 65 20  ..    ;; on the 
1fb0: 66 69 72 73 74 20 70 61 73 73 20 6f 72 20 63 61  first pass or ca
1fc0: 6c 6c 20 74 6f 20 72 75 6e 2d 74 65 73 74 73 20  ll to run-tests 
1fd0: 73 65 74 20 46 41 49 4c 53 20 74 6f 20 4e 4f 54  set FAILS to NOT
1fe0: 5f 53 54 41 52 54 45 44 20 69 66 0a 20 20 20 20  _STARTED if.    
1ff0: 3b 3b 20 2d 6b 65 65 70 67 6f 69 6e 67 20 69 73  ;; -keepgoing is
2000: 20 73 70 65 63 69 66 69 65 64 0a 20 20 20 20 28   specified.    (
2010: 69 66 20 28 65 71 3f 20 2a 70 61 73 73 6e 75 6d  if (eq? *passnum
2020: 2a 20 30 29 0a 09 28 62 65 67 69 6e 0a 09 20 20  * 0)..(begin..  
2030: 3b 3b 20 68 61 76 65 20 74 6f 20 64 65 6c 65 74  ;; have to delet
2040: 65 20 74 65 73 74 20 72 65 63 6f 72 64 73 20 77  e test records w
2050: 68 65 72 65 20 4e 4f 54 5f 53 54 41 52 54 45 44  here NOT_STARTED
2060: 20 73 69 6e 63 65 20 74 68 65 79 20 63 61 6e 20   since they can 
2070: 63 61 75 73 65 20 2d 6b 65 65 70 67 6f 69 6e 67  cause -keepgoing
2080: 20 74 6f 20 0a 09 20 20 3b 3b 20 67 65 74 20 73   to ..  ;; get s
2090: 74 75 63 6b 20 64 75 65 20 74 6f 20 62 65 63 6f  tuck due to beco
20a0: 6d 69 6e 67 20 69 6e 61 63 63 65 73 73 69 62 6c  ming inaccessibl
20b0: 65 20 66 72 6f 6d 20 61 20 66 61 69 6c 65 64 20  e from a failed 
20c0: 74 65 73 74 2e 20 49 2e 65 2e 20 69 66 20 74 65  test. I.e. if te
20d0: 73 74 20 42 20 64 65 70 65 6e 64 73 20 0a 09 20  st B depends .. 
20e0: 20 3b 3b 20 6f 6e 20 74 65 73 74 20 41 20 62 75   ;; on test A bu
20f0: 74 20 74 65 73 74 20 42 20 72 65 61 63 68 65 64  t test B reached
2100: 20 74 68 65 20 70 6f 69 6e 74 20 6f 6e 20 62 65   the point on be
2110: 69 6e 67 20 72 65 67 69 73 74 65 72 65 64 20 61  ing registered a
2120: 73 20 4e 4f 54 5f 53 54 41 52 54 45 44 20 61 6e  s NOT_STARTED an
2130: 64 20 74 65 73 74 0a 09 20 20 3b 3b 20 41 20 66  d test..  ;; A f
2140: 61 69 6c 65 64 20 66 6f 72 20 73 6f 6d 65 20 72  ailed for some r
2150: 65 61 73 6f 6e 20 74 68 65 6e 20 6f 6e 20 72 65  eason then on re
2160: 2d 72 75 6e 20 75 73 69 6e 67 20 2d 6b 65 65 70  -run using -keep
2170: 67 6f 69 6e 67 20 74 68 65 20 72 75 6e 20 63 61  going the run ca
2180: 6e 20 6e 65 76 65 72 20 63 6f 6d 70 6c 65 74 65  n never complete
2190: 2e 0a 09 20 20 28 64 62 3a 64 65 6c 65 74 65 2d  ...  (db:delete-
21a0: 74 65 73 74 73 2d 69 6e 2d 73 74 61 74 65 20 64  tests-in-state d
21b0: 62 20 72 75 6e 2d 69 64 20 22 4e 4f 54 5f 53 54  b run-id "NOT_ST
21c0: 41 52 54 45 44 22 29 0a 09 20 20 28 72 64 62 3a  ARTED")..  (rdb:
21d0: 73 65 74 2d 74 65 73 74 73 2d 73 74 61 74 65 2d  set-tests-state-
21e0: 73 74 61 74 75 73 20 64 62 20 72 75 6e 2d 69 64  status db run-id
21f0: 20 74 65 73 74 2d 6e 61 6d 65 73 20 23 66 20 22   test-names #f "
2200: 46 41 49 4c 22 20 22 4e 4f 54 5f 53 54 41 52 54  FAIL" "NOT_START
2210: 45 44 22 20 22 46 41 49 4c 22 29 29 29 0a 0a 20  ED" "FAIL"))).. 
2220: 20 20 20 3b 3b 20 6e 6f 77 20 61 64 64 20 6e 6f     ;; now add no
2230: 6e 2d 64 69 72 65 63 74 6c 79 20 72 65 66 65 72  n-directly refer
2240: 65 6e 63 65 64 20 64 65 70 65 6e 64 65 6e 63 69  enced dependenci
2250: 65 73 20 28 69 2e 65 2e 20 77 61 69 74 6f 6e 29  es (i.e. waiton)
2260: 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28 6e  .    (if (not (n
2270: 75 6c 6c 3f 20 74 65 73 74 2d 6e 61 6d 65 73 29  ull? test-names)
2280: 29 0a 09 28 6c 65 74 20 6c 6f 6f 70 20 28 28 68  )..(let loop ((h
2290: 65 64 20 28 63 61 72 20 74 65 73 74 2d 6e 61 6d  ed (car test-nam
22a0: 65 73 29 29 0a 09 09 20 20 20 28 74 61 6c 20 28  es))...   (tal (
22b0: 63 64 72 20 74 65 73 74 2d 6e 61 6d 65 73 29 29  cdr test-names))
22c0: 29 20 20 20 20 20 20 20 20 20 3b 3b 20 27 72 65  )         ;; 're
22d0: 74 75 72 6e 2d 70 72 6f 63 73 20 74 65 6c 6c 73  turn-procs tells
22e0: 20 74 68 65 20 63 6f 6e 66 69 67 20 72 65 61 64   the config read
22f0: 65 72 20 74 6f 20 70 72 65 70 20 72 75 6e 6e 69  er to prep runni
2300: 6e 67 20 73 79 73 74 65 6d 20 62 75 74 20 72 65  ng system but re
2310: 74 75 72 6e 20 61 20 70 72 6f 63 0a 09 20 20 28  turn a proc..  (
2320: 6c 65 74 2a 20 28 28 63 6f 6e 66 69 67 20 20 28  let* ((config  (
2330: 74 65 73 74 73 3a 67 65 74 2d 74 65 73 74 63 6f  tests:get-testco
2340: 6e 66 69 67 20 68 65 64 20 27 72 65 74 75 72 6e  nfig hed 'return
2350: 2d 70 72 6f 63 73 29 29 0a 09 09 20 28 77 61 69  -procs))... (wai
2360: 74 6f 6e 73 20 28 73 74 72 69 6e 67 2d 73 70 6c  tons (string-spl
2370: 69 74 20 28 6c 65 74 20 28 28 77 20 28 63 6f 6e  it (let ((w (con
2380: 66 69 67 2d 6c 6f 6f 6b 75 70 20 63 6f 6e 66 69  fig-lookup confi
2390: 67 20 22 72 65 71 75 69 72 65 6d 65 6e 74 73 22  g "requirements"
23a0: 20 22 77 61 69 74 6f 6e 22 29 29 29 0a 09 09 09   "waiton")))....
23b0: 09 09 20 20 28 69 66 20 77 20 77 20 22 22 29 29  ..  (if w w ""))
23c0: 29 29 29 0a 09 20 20 20 20 3b 3b 20 28 69 74 65  )))..    ;; (ite
23d0: 6d 73 20 20 20 28 69 74 65 6d 73 3a 67 65 74 2d  ms   (items:get-
23e0: 69 74 65 6d 73 2d 66 72 6f 6d 2d 63 6f 6e 66 69  items-from-confi
23f0: 67 20 63 6f 6e 66 69 67 29 29 29 0a 09 20 20 20  g config)))..   
2400: 20 28 69 66 20 28 6e 6f 74 20 28 68 61 73 68 2d   (if (not (hash-
2410: 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c  table-ref/defaul
2420: 74 20 74 65 73 74 2d 72 65 63 6f 72 64 73 20 68  t test-records h
2430: 65 64 20 23 66 29 29 0a 09 09 28 68 61 73 68 2d  ed #f))...(hash-
2440: 74 61 62 6c 65 2d 73 65 74 21 20 74 65 73 74 2d  table-set! test-
2450: 72 65 63 6f 72 64 73 0a 09 09 09 09 20 68 65 64  records..... hed
2460: 20 28 76 65 63 74 6f 72 20 68 65 64 20 20 20 20   (vector hed    
2470: 20 3b 3b 20 30 0a 09 09 09 09 09 20 20 20 20 20   ;; 0......     
2480: 63 6f 6e 66 69 67 20 20 3b 3b 20 31 0a 09 09 09  config  ;; 1....
2490: 09 09 20 20 20 20 20 77 61 69 74 6f 6e 73 20 3b  ..     waitons ;
24a0: 3b 20 32 0a 09 09 09 09 09 20 20 20 20 20 28 63  ; 2......     (c
24b0: 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 63 6f 6e  onfig-lookup con
24c0: 66 69 67 20 22 72 65 71 75 69 72 65 6d 65 6e 74  fig "requirement
24d0: 73 22 20 22 70 72 69 6f 72 69 74 79 22 29 20 20  s" "priority")  
24e0: 20 20 20 3b 3b 20 70 72 69 6f 72 69 74 79 20 33     ;; priority 3
24f0: 0a 09 09 09 09 09 20 20 20 20 20 28 6c 65 74 20  ......     (let 
2500: 28 28 69 74 65 6d 73 20 20 20 20 20 20 28 68 61  ((items      (ha
2510: 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66  sh-table-ref/def
2520: 61 75 6c 74 20 63 6f 6e 66 69 67 20 22 69 74 65  ault config "ite
2530: 6d 73 22 20 23 66 29 29 20 3b 3b 20 69 74 65 6d  ms" #f)) ;; item
2540: 73 20 34 0a 09 09 09 09 09 09 20 20 20 28 69 74  s 4.......   (it
2550: 65 6d 73 74 61 62 6c 65 20 28 68 61 73 68 2d 74  emstable (hash-t
2560: 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74  able-ref/default
2570: 20 63 6f 6e 66 69 67 20 22 69 74 65 6d 73 74 61   config "itemsta
2580: 62 6c 65 22 20 23 66 29 29 29 20 0a 09 09 09 09  ble" #f))) .....
2590: 09 20 20 20 20 20 20 20 3b 3b 20 69 66 20 65 69  .       ;; if ei
25a0: 74 68 65 72 20 69 74 65 6d 73 20 6f 72 20 69 74  ther items or it
25b0: 65 6d 73 20 74 61 62 6c 65 20 69 73 20 61 20 70  ems table is a p
25c0: 72 6f 63 20 72 65 74 75 72 6e 20 69 74 20 73 6f  roc return it so
25d0: 20 74 65 73 74 20 72 75 6e 6e 69 6e 67 0a 09 09   test running...
25e0: 09 09 09 20 20 20 20 20 20 20 3b 3b 20 70 72 6f  ...       ;; pro
25f0: 63 65 73 73 20 63 61 6e 20 6b 6e 6f 77 20 74 6f  cess can know to
2600: 20 63 61 6c 6c 20 69 74 65 6d 73 3a 67 65 74 2d   call items:get-
2610: 69 74 65 6d 73 2d 66 72 6f 6d 2d 63 6f 6e 66 69  items-from-confi
2620: 67 0a 09 09 09 09 09 20 20 20 20 20 20 20 3b 3b  g......       ;;
2630: 20 69 66 20 65 69 74 68 65 72 20 69 73 20 61 20   if either is a 
2640: 6c 69 73 74 20 61 6e 64 20 6e 6f 6e 65 20 69 73  list and none is
2650: 20 61 20 70 72 6f 63 20 67 6f 20 61 68 65 61 64   a proc go ahead
2660: 20 61 6e 64 20 63 61 6c 6c 20 67 65 74 2d 69 74   and call get-it
2670: 65 6d 73 0a 09 09 09 09 09 20 20 20 20 20 20 20  ems......       
2680: 3b 3b 20 6f 74 68 65 72 77 69 73 65 20 72 65 74  ;; otherwise ret
2690: 75 72 6e 20 23 66 20 2d 20 74 68 69 73 20 69 73  urn #f - this is
26a0: 20 6e 6f 74 20 61 6e 20 69 74 65 72 61 74 65 64   not an iterated
26b0: 20 74 65 73 74 0a 09 09 09 09 09 20 20 20 20 20   test......     
26c0: 20 20 28 63 6f 6e 64 0a 09 09 09 09 09 09 28 28    (cond.......((
26d0: 70 72 6f 63 65 64 75 72 65 3f 20 69 74 65 6d 73  procedure? items
26e0: 29 20 20 20 20 20 20 0a 09 09 09 09 09 09 20 28  )      ....... (
26f0: 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 49  debug:print 4 "I
2700: 4e 46 4f 3a 20 69 74 65 6d 73 20 69 73 20 61 20  NFO: items is a 
2710: 70 72 6f 63 65 64 75 72 65 2c 20 77 69 6c 6c 20  procedure, will 
2720: 63 61 6c 63 20 6c 61 74 65 72 22 29 0a 09 09 09  calc later")....
2730: 09 09 09 20 69 74 65 6d 73 29 20 20 20 20 20 20  ... items)      
2740: 20 20 20 20 20 20 3b 3b 20 63 61 6c 63 20 6c 61        ;; calc la
2750: 74 65 72 0a 09 09 09 09 09 09 28 28 70 72 6f 63  ter.......((proc
2760: 65 64 75 72 65 3f 20 69 74 65 6d 73 74 61 62 6c  edure? itemstabl
2770: 65 29 0a 09 09 09 09 09 09 20 28 64 65 62 75 67  e)....... (debug
2780: 3a 70 72 69 6e 74 20 34 20 22 49 4e 46 4f 3a 20  :print 4 "INFO: 
2790: 69 74 65 6d 73 74 61 62 6c 65 20 69 73 20 61 20  itemstable is a 
27a0: 70 72 6f 63 65 64 75 72 65 2c 20 77 69 6c 6c 20  procedure, will 
27b0: 63 61 6c 63 20 6c 61 74 65 72 22 29 0a 09 09 09  calc later")....
27c0: 09 09 09 20 69 74 65 6d 73 74 61 62 6c 65 29 20  ... itemstable) 
27d0: 20 20 20 20 20 20 3b 3b 20 63 61 6c 63 20 6c 61        ;; calc la
27e0: 74 65 72 0a 09 09 09 09 09 09 28 28 66 69 6c 74  ter.......((filt
27f0: 65 72 20 28 6c 61 6d 62 64 61 20 28 78 29 0a 09  er (lambda (x)..
2800: 09 09 09 09 09 09 20 20 20 28 6c 65 74 20 28 28  ......   (let ((
2810: 76 61 6c 20 28 63 61 72 20 78 29 29 29 0a 09 09  val (car x)))...
2820: 09 09 09 09 09 20 20 20 20 20 28 69 66 20 28 70  .....     (if (p
2830: 72 6f 63 65 64 75 72 65 3f 20 76 61 6c 29 20 76  rocedure? val) v
2840: 61 6c 20 23 66 29 29 29 0a 09 09 09 09 09 09 09  al #f)))........
2850: 20 28 61 70 70 65 6e 64 20 28 69 66 20 28 6c 69   (append (if (li
2860: 73 74 3f 20 69 74 65 6d 73 29 20 69 74 65 6d 73  st? items) items
2870: 20 27 28 29 29 0a 09 09 09 09 09 09 09 09 20 28   '())......... (
2880: 69 66 20 28 6c 69 73 74 3f 20 69 74 65 6d 73 74  if (list? itemst
2890: 61 62 6c 65 29 20 69 74 65 6d 73 74 61 62 6c 65  able) itemstable
28a0: 20 27 28 29 29 29 29 0a 09 09 09 09 09 09 20 27   '())))....... '
28b0: 68 61 76 65 2d 70 72 6f 63 65 64 75 72 65 29 0a  have-procedure).
28c0: 09 09 09 09 09 09 28 28 6f 72 20 28 6c 69 73 74  ......((or (list
28d0: 3f 20 69 74 65 6d 73 29 28 6c 69 73 74 3f 20 69  ? items)(list? i
28e0: 74 65 6d 73 74 61 62 6c 65 29 29 20 3b 3b 20 63  temstable)) ;; c
28f0: 61 6c 63 20 6e 6f 77 0a 09 09 09 09 09 09 20 28  alc now....... (
2900: 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 49  debug:print 4 "I
2910: 4e 46 4f 3a 20 69 74 65 6d 73 20 61 6e 64 20 69  NFO: items and i
2920: 74 65 6d 73 74 61 62 6c 65 20 61 72 65 20 6c 69  temstable are li
2930: 73 74 73 2c 20 63 61 6c 63 20 6e 6f 77 5c 6e 22  sts, calc now\n"
2940: 0a 09 09 09 09 09 09 09 20 20 20 20 20 20 22 20  ........      " 
2950: 20 20 20 69 74 65 6d 73 3a 20 22 20 69 74 65 6d     items: " item
2960: 73 20 22 20 69 74 65 6d 73 74 61 62 6c 65 3a 20  s " itemstable: 
2970: 22 20 69 74 65 6d 73 74 61 62 6c 65 29 0a 09 09  " itemstable)...
2980: 09 09 09 09 20 28 69 74 65 6d 73 3a 67 65 74 2d  .... (items:get-
2990: 69 74 65 6d 73 2d 66 72 6f 6d 2d 63 6f 6e 66 69  items-from-confi
29a0: 67 20 63 6f 6e 66 69 67 29 29 0a 09 09 09 09 09  g config))......
29b0: 09 28 65 6c 73 65 20 23 66 29 29 29 20 20 20 20  .(else #f)))    
29c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
29d0: 20 20 20 20 20 20 20 3b 3b 20 6e 6f 74 20 69 74         ;; not it
29e0: 65 72 61 74 65 64 0a 09 09 09 09 09 20 20 20 20  erated......    
29f0: 20 23 66 20 20 20 20 20 20 3b 3b 20 69 74 65 6d   #f      ;; item
2a00: 73 64 61 74 20 35 0a 09 09 09 09 09 20 20 20 20  sdat 5......    
2a10: 20 23 66 20 20 20 20 20 20 3b 3b 20 73 70 61 72   #f      ;; spar
2a20: 65 20 2d 20 75 73 65 64 20 66 6f 72 20 69 74 65  e - used for ite
2a30: 6d 2d 70 61 74 68 0a 09 09 09 09 09 20 20 20 20  m-path......    
2a40: 20 29 29 29 0a 09 20 20 20 20 28 66 6f 72 2d 65   )))..    (for-e
2a50: 61 63 68 20 0a 09 20 20 20 20 20 28 6c 61 6d 62  ach ..     (lamb
2a60: 64 61 20 28 77 61 69 74 6f 6e 29 0a 09 20 20 20  da (waiton)..   
2a70: 20 20 20 20 28 69 66 20 28 61 6e 64 20 77 61 69      (if (and wai
2a80: 74 6f 6e 20 28 6e 6f 74 20 28 6d 65 6d 62 65 72  ton (not (member
2a90: 20 77 61 69 74 6f 6e 20 74 65 73 74 2d 6e 61 6d   waiton test-nam
2aa0: 65 73 29 29 29 0a 09 09 20 20 20 28 62 65 67 69  es)))...   (begi
2ab0: 6e 0a 09 09 20 20 20 20 20 28 73 65 74 21 20 72  n...     (set! r
2ac0: 65 71 75 69 72 65 64 2d 74 65 73 74 73 20 28 63  equired-tests (c
2ad0: 6f 6e 73 20 77 61 69 74 6f 6e 20 72 65 71 75 69  ons waiton requi
2ae0: 72 65 64 2d 74 65 73 74 73 29 29 0a 09 09 20 20  red-tests))...  
2af0: 20 20 20 28 73 65 74 21 20 74 65 73 74 2d 6e 61     (set! test-na
2b00: 6d 65 73 20 28 63 6f 6e 73 20 77 61 69 74 6f 6e  mes (cons waiton
2b10: 20 74 65 73 74 2d 6e 61 6d 65 73 29 29 29 29 29   test-names)))))
2b20: 20 3b 3b 20 77 61 73 20 61 6e 20 61 70 70 65 6e   ;; was an appen
2b30: 64 2c 20 6e 6f 77 20 61 20 63 6f 6e 73 0a 09 20  d, now a cons.. 
2b40: 20 20 20 20 77 61 69 74 6f 6e 73 29 0a 09 20 20      waitons)..  
2b50: 20 20 28 6c 65 74 20 28 28 72 65 6d 74 65 73 74    (let ((remtest
2b60: 73 20 28 64 65 6c 65 74 65 2d 64 75 70 6c 69 63  s (delete-duplic
2b70: 61 74 65 73 20 28 61 70 70 65 6e 64 20 77 61 69  ates (append wai
2b80: 74 6f 6e 73 20 74 61 6c 29 29 29 29 0a 09 20 20  tons tal))))..  
2b90: 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28 6e 75      (if (not (nu
2ba0: 6c 6c 3f 20 72 65 6d 74 65 73 74 73 29 29 0a 09  ll? remtests))..
2bb0: 09 20 20 28 6c 6f 6f 70 20 28 63 61 72 20 72 65  .  (loop (car re
2bc0: 6d 74 65 73 74 73 29 28 63 64 72 20 72 65 6d 74  mtests)(cdr remt
2bd0: 65 73 74 73 29 29 29 29 29 29 29 0a 0a 20 20 20  ests)))))))..   
2be0: 20 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f   (if (not (null?
2bf0: 20 72 65 71 75 69 72 65 64 2d 74 65 73 74 73 29   required-tests)
2c00: 29 0a 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20  )..(debug:print 
2c10: 31 20 22 49 4e 46 4f 3a 20 41 64 64 69 6e 67 20  1 "INFO: Adding 
2c20: 22 20 72 65 71 75 69 72 65 64 2d 74 65 73 74 73  " required-tests
2c30: 20 22 20 74 6f 20 74 68 65 20 72 75 6e 20 71 75   " to the run qu
2c40: 65 75 65 22 29 29 0a 20 20 20 20 3b 3b 20 4e 4f  eue")).    ;; NO
2c50: 54 45 3a 20 74 68 65 73 65 20 61 72 65 20 61 6c  TE: these are al
2c60: 6c 20 70 61 72 65 6e 74 20 74 65 73 74 73 2c 20  l parent tests, 
2c70: 69 74 65 6d 73 20 61 72 65 20 6e 6f 74 20 65 78  items are not ex
2c80: 70 61 6e 64 65 64 20 79 65 74 2e 0a 20 20 20 20  panded yet..    
2c90: 28 72 75 6e 73 3a 72 75 6e 2d 74 65 73 74 73 2d  (runs:run-tests-
2ca0: 71 75 65 75 65 20 64 62 20 72 75 6e 2d 69 64 20  queue db run-id 
2cb0: 72 75 6e 6e 61 6d 65 20 74 65 73 74 2d 72 65 63  runname test-rec
2cc0: 6f 72 64 73 20 6b 65 79 76 61 6c 6c 73 74 20 66  ords keyvallst f
2cd0: 6c 61 67 73 29 0a 20 20 20 20 28 69 66 20 2a 72  lags).    (if *r
2ce0: 70 63 3a 6c 69 73 74 65 6e 65 72 2a 20 28 73 65  pc:listener* (se
2cf0: 72 76 65 72 3a 6b 65 65 70 2d 72 75 6e 6e 69 6e  rver:keep-runnin
2d00: 67 20 64 62 29 29 0a 20 20 20 20 28 64 65 62 75  g db)).    (debu
2d10: 67 3a 70 72 69 6e 74 20 34 20 22 49 4e 46 4f 3a  g:print 4 "INFO:
2d20: 20 41 6c 6c 20 64 6f 6e 65 20 62 79 20 68 65 72   All done by her
2d30: 65 22 29 29 29 0a 0a 3b 3b 20 74 65 73 74 2d 72  e")))..;; test-r
2d40: 65 63 6f 72 64 73 20 69 73 20 61 20 68 61 73 68  ecords is a hash
2d50: 20 74 61 62 6c 65 20 74 65 73 74 6e 61 6d 65 3a   table testname:
2d60: 69 74 65 6d 5f 70 61 74 68 20 3d 3e 20 76 65 63  item_path => vec
2d70: 74 6f 72 20 3c 20 74 65 73 74 6e 61 6d 65 20 74  tor < testname t
2d80: 65 73 74 63 6f 6e 66 69 67 20 77 61 69 74 6f 6e  estconfig waiton
2d90: 73 20 70 72 69 6f 72 69 74 79 20 69 74 65 6d 73  s priority items
2da0: 2d 69 6e 66 6f 20 2e 2e 2e 20 3e 0a 28 64 65 66  -info ... >.(def
2db0: 69 6e 65 20 28 72 75 6e 73 3a 72 75 6e 2d 74 65  ine (runs:run-te
2dc0: 73 74 73 2d 71 75 65 75 65 20 64 62 20 72 75 6e  sts-queue db run
2dd0: 2d 69 64 20 72 75 6e 6e 61 6d 65 20 74 65 73 74  -id runname test
2de0: 2d 72 65 63 6f 72 64 73 20 6b 65 79 76 61 6c 6c  -records keyvall
2df0: 73 74 20 66 6c 61 67 73 29 0a 20 20 20 20 3b 3b  st flags).    ;;
2e00: 20 41 74 20 74 68 69 73 20 70 6f 69 6e 74 20 74   At this point t
2e10: 68 65 20 6c 69 73 74 20 6f 66 20 70 61 72 65 6e  he list of paren
2e20: 74 20 74 65 73 74 73 20 69 73 20 65 78 70 61 6e  t tests is expan
2e30: 64 65 64 20 0a 20 20 20 20 3b 3b 20 4e 42 2f 2f  ded .    ;; NB//
2e40: 20 53 68 6f 75 6c 64 20 65 78 70 61 6e 64 20 69   Should expand i
2e50: 74 65 6d 73 20 68 65 72 65 20 61 6e 64 20 74 68  tems here and th
2e60: 65 6e 20 69 6e 73 65 72 74 20 69 6e 74 6f 20 74  en insert into t
2e70: 68 65 20 72 75 6e 20 71 75 65 75 65 2e 0a 20 20  he run queue..  
2e80: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 35 20 22  (debug:print 5 "
2e90: 74 65 73 74 2d 72 65 63 6f 72 64 73 3a 20 22 20  test-records: " 
2ea0: 74 65 73 74 2d 72 65 63 6f 72 64 73 20 22 2c 20  test-records ", 
2eb0: 6b 65 79 76 61 6c 6c 73 74 3a 20 22 20 6b 65 79  keyvallst: " key
2ec0: 76 61 6c 6c 73 74 20 22 20 66 6c 61 67 73 3a 20  vallst " flags: 
2ed0: 22 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 3e 61  " (hash-table->a
2ee0: 6c 69 73 74 20 66 6c 61 67 73 29 29 0a 20 20 28  list flags)).  (
2ef0: 6c 65 74 20 28 28 73 6f 72 74 65 64 2d 74 65 73  let ((sorted-tes
2f00: 74 2d 6e 61 6d 65 73 20 28 74 65 73 74 73 3a 73  t-names (tests:s
2f10: 6f 72 74 2d 62 79 2d 70 72 69 6f 72 69 74 79 2d  ort-by-priority-
2f20: 61 6e 64 2d 77 61 69 74 6f 6e 20 74 65 73 74 2d  and-waiton test-
2f30: 72 65 63 6f 72 64 73 29 29 0a 09 28 69 74 65 6d  records))..(item
2f40: 2d 70 61 74 74 73 20 20 20 20 20 20 20 20 28 68  -patts        (h
2f50: 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65  ash-table-ref/de
2f60: 66 61 75 6c 74 20 66 6c 61 67 73 20 22 2d 69 74  fault flags "-it
2f70: 65 6d 70 61 74 74 22 20 23 66 29 29 29 0a 20 20  empatt" #f))).  
2f80: 20 20 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c    (if (not (null
2f90: 3f 20 73 6f 72 74 65 64 2d 74 65 73 74 2d 6e 61  ? sorted-test-na
2fa0: 6d 65 73 29 29 0a 09 28 6c 65 74 20 6c 6f 6f 70  mes))..(let loop
2fb0: 20 28 3b 20 28 6e 75 6d 74 69 6d 65 73 20 30 29   (; (numtimes 0)
2fc0: 20 3b 3b 20 73 68 6f 75 6c 64 6e 27 74 20 6e 65   ;; shouldn't ne
2fd0: 65 64 20 74 68 69 73 0a 09 09 20 20 20 28 68 65  ed this...   (he
2fe0: 64 20 20 20 20 20 20 20 20 20 28 63 61 72 20 73  d         (car s
2ff0: 6f 72 74 65 64 2d 74 65 73 74 2d 6e 61 6d 65 73  orted-test-names
3000: 29 29 0a 09 09 20 20 20 28 74 61 6c 20 20 20 20  ))...   (tal    
3010: 20 20 20 20 20 28 63 64 72 20 73 6f 72 74 65 64       (cdr sorted
3020: 2d 74 65 73 74 2d 6e 61 6d 65 73 29 29 29 0a 09  -test-names)))..
3030: 20 20 28 6c 65 74 2a 20 28 28 74 65 73 74 2d 72    (let* ((test-r
3040: 65 63 6f 72 64 20 28 68 61 73 68 2d 74 61 62 6c  ecord (hash-tabl
3050: 65 2d 72 65 66 20 74 65 73 74 2d 72 65 63 6f 72  e-ref test-recor
3060: 64 73 20 68 65 64 29 29 0a 09 09 20 28 74 63 6f  ds hed))... (tco
3070: 6e 66 69 67 20 20 20 20 20 28 74 65 73 74 73 3a  nfig     (tests:
3080: 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d 74 65  testqueue-get-te
3090: 73 74 63 6f 6e 66 69 67 20 74 65 73 74 2d 72 65  stconfig test-re
30a0: 63 6f 72 64 29 29 0a 09 09 20 28 77 61 69 74 6f  cord))... (waito
30b0: 6e 73 20 20 20 20 20 28 74 65 73 74 73 3a 74 65  ns     (tests:te
30c0: 73 74 71 75 65 75 65 2d 67 65 74 2d 77 61 69 74  stqueue-get-wait
30d0: 6f 6e 73 20 20 20 20 74 65 73 74 2d 72 65 63 6f  ons    test-reco
30e0: 72 64 29 29 0a 09 09 20 28 70 72 69 6f 72 69 74  rd))... (priorit
30f0: 79 20 20 20 20 28 74 65 73 74 73 3a 74 65 73 74  y    (tests:test
3100: 71 75 65 75 65 2d 67 65 74 2d 70 72 69 6f 72 69  queue-get-priori
3110: 74 79 20 20 20 74 65 73 74 2d 72 65 63 6f 72 64  ty   test-record
3120: 29 29 0a 09 09 20 28 69 74 65 6d 64 61 74 20 20  ))... (itemdat  
3130: 20 20 20 28 74 65 73 74 73 3a 74 65 73 74 71 75     (tests:testqu
3140: 65 75 65 2d 67 65 74 2d 69 74 65 6d 64 61 74 20  eue-get-itemdat 
3150: 20 20 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29     test-record))
3160: 20 3b 3b 20 69 74 65 6d 64 61 74 20 63 61 6e 20   ;; itemdat can 
3170: 62 65 20 61 20 73 74 72 69 6e 67 2c 20 6c 69 73  be a string, lis
3180: 74 20 6f 72 20 23 66 0a 09 09 20 28 69 74 65 6d  t or #f... (item
3190: 73 20 20 20 20 20 20 20 28 74 65 73 74 73 3a 74  s       (tests:t
31a0: 65 73 74 71 75 65 75 65 2d 67 65 74 2d 69 74 65  estqueue-get-ite
31b0: 6d 73 20 20 20 20 20 20 74 65 73 74 2d 72 65 63  ms      test-rec
31c0: 6f 72 64 29 29 0a 09 09 20 28 69 74 65 6d 2d 70  ord))... (item-p
31d0: 61 74 68 20 20 20 28 69 74 65 6d 2d 6c 69 73 74  ath   (item-list
31e0: 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74 29 29  ->path itemdat))
31f0: 29 0a 09 20 20 20 20 28 64 65 62 75 67 3a 70 72  )..    (debug:pr
3200: 69 6e 74 20 36 0a 09 09 09 20 22 69 74 65 6d 64  int 6.... "itemd
3210: 61 74 3a 20 20 20 20 20 22 20 69 74 65 6d 64 61  at:     " itemda
3220: 74 0a 09 09 09 20 22 5c 6e 20 20 69 74 65 6d 73  t.... "\n  items
3230: 3a 20 20 20 20 20 22 20 69 74 65 6d 73 0a 09 09  :     " items...
3240: 09 20 22 5c 6e 20 20 69 74 65 6d 2d 70 61 74 68  . "\n  item-path
3250: 3a 20 22 20 69 74 65 6d 2d 70 61 74 68 29 0a 09  : " item-path)..
3260: 20 20 20 20 28 63 6f 6e 64 0a 09 20 20 20 20 20      (cond..     
3270: 28 28 6e 6f 74 20 69 74 65 6d 73 29 20 3b 3b 20  ((not items) ;; 
3280: 77 68 65 6e 20 66 61 6c 73 65 20 74 68 65 20 74  when false the t
3290: 65 73 74 20 69 73 20 6f 6b 20 74 6f 20 62 65 20  est is ok to be 
32a0: 68 61 6e 64 65 64 20 6f 66 66 20 74 6f 20 6c 61  handed off to la
32b0: 75 6e 63 68 20 28 62 75 74 20 6e 6f 74 20 62 65  unch (but not be
32c0: 66 6f 72 65 29 0a 09 20 20 20 20 20 20 28 6c 65  fore)..      (le
32d0: 74 20 28 28 68 61 76 65 2d 72 65 73 6f 75 72 63  t ((have-resourc
32e0: 65 73 20 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75  es  (runs:can-ru
32f0: 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64 62 20  n-more-tests db 
3300: 74 65 73 74 2d 72 65 63 6f 72 64 29 29 20 3b 3b  test-record)) ;;
3310: 20 6c 6f 6f 6b 20 61 74 20 74 68 65 20 74 65 73   look at the tes
3320: 74 20 6a 6f 62 67 72 6f 75 70 20 61 6e 64 20 74  t jobgroup and t
3330: 6f 74 20 6a 6f 62 73 20 72 75 6e 6e 69 6e 67 0a  ot jobs running.
3340: 09 09 20 20 20 20 28 70 72 65 72 65 71 73 2d 6e  ..    (prereqs-n
3350: 6f 74 2d 6d 65 74 20 28 64 62 3a 67 65 74 2d 70  ot-met (db:get-p
3360: 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 20 64  rereqs-not-met d
3370: 62 20 72 75 6e 2d 69 64 20 77 61 69 74 6f 6e 73  b run-id waitons
3380: 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 09 09   item-path)))...
3390: 3b 3b 20 44 6f 6e 27 74 20 6b 6e 6f 77 20 61 74  ;; Don't know at
33a0: 20 74 68 69 73 20 74 69 6d 65 20 69 66 20 74 68   this time if th
33b0: 65 20 74 65 73 74 20 68 61 76 65 20 62 65 65 6e  e test have been
33c0: 20 6c 61 75 6e 63 68 65 64 20 61 74 20 73 6f 6d   launched at som
33d0: 65 20 74 69 6d 65 20 69 6e 20 74 68 65 20 70 61  e time in the pa
33e0: 73 74 0a 09 09 3b 3b 20 69 2e 65 2e 20 69 73 20  st...;; i.e. is 
33f0: 74 68 69 73 20 61 20 72 65 2d 6c 61 75 6e 63 68  this a re-launch
3400: 3f 0a 09 09 28 69 66 20 28 61 6e 64 20 68 61 76  ?...(if (and hav
3410: 65 2d 72 65 73 6f 75 72 63 65 73 0a 09 09 09 20  e-resources.... 
3420: 28 6e 75 6c 6c 3f 20 70 72 65 72 65 71 73 2d 6e  (null? prereqs-n
3430: 6f 74 2d 6d 65 74 29 29 0a 09 09 20 20 20 20 3b  ot-met))...    ;
3440: 3b 20 6e 6f 20 6c 6f 6f 70 20 2d 20 64 72 6f 70  ; no loop - drop
3450: 20 74 68 6f 75 67 68 20 61 6e 64 20 75 73 65 20   though and use 
3460: 74 68 65 20 6c 6f 6f 70 20 61 74 20 74 68 65 20  the loop at the 
3470: 62 6f 74 74 6f 6d 20 0a 09 09 20 20 20 20 28 69  bottom ...    (i
3480: 66 20 28 70 61 74 74 2d 6c 69 73 74 2d 6d 61 74  f (patt-list-mat
3490: 63 68 20 69 74 65 6d 2d 70 61 74 68 20 69 74 65  ch item-path ite
34a0: 6d 2d 70 61 74 74 73 29 0a 09 09 09 28 72 75 6e  m-patts)....(run
34b0: 3a 74 65 73 74 20 64 62 20 72 75 6e 2d 69 64 20  :test db run-id 
34c0: 72 75 6e 6e 61 6d 65 20 6b 65 79 76 61 6c 6c 73  runname keyvalls
34d0: 74 20 74 65 73 74 2d 72 65 63 6f 72 64 20 66 6c  t test-record fl
34e0: 61 67 73 20 23 66 29 0a 09 09 09 28 64 65 62 75  ags #f)....(debu
34f0: 67 3a 70 72 69 6e 74 20 31 20 22 49 4e 46 4f 3a  g:print 1 "INFO:
3500: 20 53 6b 69 70 70 69 6e 67 20 22 20 28 74 65 73   Skipping " (tes
3510: 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74  ts:testqueue-get
3520: 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 2d 72  -testname test-r
3530: 65 63 6f 72 64 29 20 22 20 22 20 69 74 65 6d 2d  ecord) " " item-
3540: 70 61 74 68 20 22 20 61 73 20 69 74 20 64 6f 65  path " as it doe
3550: 73 6e 27 74 20 6d 61 74 63 68 20 22 20 69 74 65  sn't match " ite
3560: 6d 2d 70 61 74 74 73 29 29 0a 09 09 20 20 20 20  m-patts))...    
3570: 3b 3b 20 65 6c 73 65 20 74 68 65 20 72 75 6e 20  ;; else the run 
3580: 69 73 20 73 74 75 63 6b 2c 20 74 65 6d 70 6f 72  is stuck, tempor
3590: 61 72 69 6c 79 20 6f 72 20 70 65 72 6d 61 6e 65  arily or permane
35a0: 6e 74 6c 79 0a 09 09 20 20 20 20 28 6c 65 74 20  ntly...    (let 
35b0: 28 28 6e 65 77 74 61 6c 20 28 61 70 70 65 6e 64  ((newtal (append
35c0: 20 74 61 6c 20 28 6c 69 73 74 20 68 65 64 29 29   tal (list hed))
35d0: 29 0a 09 09 09 20 20 28 66 61 69 6c 73 20 20 28  )....  (fails  (
35e0: 66 69 6c 74 65 72 20 28 6c 61 6d 62 64 61 20 28  filter (lambda (
35f0: 74 65 73 74 29 28 6e 6f 74 20 28 6d 65 6d 62 65  test)(not (membe
3600: 72 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 73  r (db:test-get-s
3610: 74 61 74 75 73 20 74 65 73 74 29 0a 09 09 09 09  tatus test).....
3620: 09 09 09 09 20 20 20 20 20 27 28 22 50 41 53 53  ....     '("PASS
3630: 22 20 22 57 41 52 4e 22 20 22 43 48 45 43 4b 22  " "WARN" "CHECK"
3640: 20 22 57 41 49 56 45 44 22 29 29 29 29 0a 09 09   "WAIVED"))))...
3650: 09 09 09 20 20 70 72 65 72 65 71 73 2d 6e 6f 74  ...  prereqs-not
3660: 2d 6d 65 74 29 29 29 0a 09 09 20 20 20 20 20 20  -met)))...      
3670: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22  (debug:print 4 "
3680: 46 41 49 4c 53 3a 20 22 20 66 61 69 6c 73 29 0a  FAILS: " fails).
3690: 09 09 20 20 20 20 20 20 3b 3b 20 49 66 20 6f 6e  ..      ;; If on
36a0: 65 20 6f 72 20 6d 6f 72 65 20 6f 66 20 74 68 65  e or more of the
36b0: 20 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74   prereqs-not-met
36c0: 20 61 72 65 20 46 41 49 4c 20 74 68 65 6e 20 77   are FAIL then w
36d0: 65 20 63 61 6e 20 69 73 73 75 65 0a 09 09 20 20  e can issue...  
36e0: 20 20 20 20 3b 3b 20 61 20 6d 65 73 73 61 67 65      ;; a message
36f0: 20 61 6e 64 20 64 72 6f 70 20 68 65 64 20 66 72   and drop hed fr
3700: 6f 6d 20 74 68 65 20 69 74 65 6d 73 20 74 6f 20  om the items to 
3710: 62 65 20 70 72 6f 63 65 73 73 65 64 2e 0a 09 09  be processed....
3720: 20 20 20 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f        (if (null?
3730: 20 66 61 69 6c 73 29 0a 09 09 09 20 20 28 62 65   fails)....  (be
3740: 67 69 6e 0a 09 09 09 20 20 20 20 3b 3b 20 63 6f  gin....    ;; co
3750: 75 6c 64 6e 27 74 20 72 75 6e 2c 20 74 61 6b 65  uldn't run, take
3760: 20 61 20 62 72 65 61 74 68 65 72 0a 09 09 09 20   a breather.... 
3770: 20 20 20 28 74 68 72 65 61 64 2d 73 6c 65 65 70     (thread-sleep
3780: 21 20 30 2e 31 29 20 3b 3b 20 6c 6f 6e 67 20 73  ! 0.1) ;; long s
3790: 6c 65 65 70 20 68 65 72 65 20 2d 20 6e 6f 20 72  leep here - no r
37a0: 65 73 6f 75 72 63 65 73 2c 20 6d 61 79 20 61 73  esources, may as
37b0: 20 77 65 6c 6c 20 62 65 20 70 61 74 69 65 6e 74   well be patient
37c0: 0a 09 09 09 20 20 20 20 28 6c 6f 6f 70 20 28 63  ....    (loop (c
37d0: 61 72 20 6e 65 77 74 61 6c 29 28 63 64 72 20 6e  ar newtal)(cdr n
37e0: 65 77 74 61 6c 29 29 29 0a 09 09 09 20 20 3b 3b  ewtal)))....  ;;
37f0: 20 74 68 65 20 77 61 69 74 6f 6e 20 69 73 20 46   the waiton is F
3800: 41 49 4c 20 73 6f 20 6e 6f 20 70 6f 69 6e 74 20  AIL so no point 
3810: 69 6e 20 74 72 79 69 6e 67 20 74 6f 20 72 75 6e  in trying to run
3820: 20 68 65 64 0a 09 09 09 20 20 28 69 66 20 28 6e   hed....  (if (n
3830: 6f 74 20 28 6e 75 6c 6c 3f 20 74 61 6c 29 29 0a  ot (null? tal)).
3840: 09 09 09 20 20 20 20 20 20 28 6c 6f 6f 70 20 28  ...      (loop (
3850: 63 61 72 20 74 61 6c 29 28 63 64 72 20 74 61 6c  car tal)(cdr tal
3860: 29 29 29 29 29 29 29 29 0a 09 20 20 20 20 20 0a  ))))))))..     .
3870: 09 20 20 20 20 20 3b 3b 20 63 61 73 65 20 77 68  .     ;; case wh
3880: 65 72 65 20 61 6e 20 69 74 65 6d 73 20 63 61 6d  ere an items cam
3890: 65 20 69 6e 20 61 73 20 61 20 6c 69 73 74 20 62  e in as a list b
38a0: 65 65 6e 20 70 72 6f 63 65 73 73 65 64 0a 09 20  een processed.. 
38b0: 20 20 20 20 28 28 61 6e 64 20 28 6c 69 73 74 3f      ((and (list?
38c0: 20 69 74 65 6d 73 29 20 20 20 20 20 3b 3b 20 74   items)     ;; t
38d0: 68 75 73 20 77 65 20 6b 6e 6f 77 20 6f 75 72 20  hus we know our 
38e0: 69 74 65 6d 73 20 61 72 65 20 61 6c 72 65 61 64  items are alread
38f0: 79 20 63 61 6c 63 75 6c 61 74 65 64 0a 09 09 20  y calculated... 
3900: 20 20 28 6e 6f 74 20 20 20 69 74 65 6d 64 61 74    (not   itemdat
3910: 29 29 20 3b 3b 20 61 6e 64 20 6e 6f 74 20 79 65  )) ;; and not ye
3920: 74 20 65 78 70 61 6e 64 65 64 20 69 6e 74 6f 20  t expanded into 
3930: 74 68 65 20 6c 69 73 74 20 6f 66 20 74 68 69 6e  the list of thin
3940: 67 73 20 74 6f 20 62 65 20 64 6f 6e 65 0a 09 20  gs to be done.. 
3950: 20 20 20 20 20 28 69 66 20 28 61 6e 64 20 28 3e       (if (and (>
3960: 3d 20 2a 76 65 72 62 6f 73 69 74 79 2a 20 31 29  = *verbosity* 1)
3970: 0a 09 09 20 20 20 20 20 20 20 28 3e 20 28 6c 65  ...       (> (le
3980: 6e 67 74 68 20 69 74 65 6d 73 29 20 30 29 0a 09  ngth items) 0)..
3990: 09 20 20 20 20 20 20 20 28 3e 20 28 6c 65 6e 67  .       (> (leng
39a0: 74 68 20 28 63 61 72 20 69 74 65 6d 73 29 29 20  th (car items)) 
39b0: 30 29 29 0a 09 09 20 20 28 70 70 20 69 74 65 6d  0))...  (pp item
39c0: 73 29 29 0a 09 20 20 20 20 20 20 3b 3b 20 28 69  s))..      ;; (i
39d0: 66 20 28 3e 3d 20 2a 76 65 72 62 6f 73 69 74 79  f (>= *verbosity
39e0: 2a 20 35 29 0a 09 20 20 20 20 20 20 3b 3b 20 20  * 5)..      ;;  
39f0: 20 20 20 28 62 65 67 69 6e 0a 09 20 20 20 20 20     (begin..     
3a00: 20 3b 3b 20 20 20 20 20 20 20 28 70 72 69 6e 74   ;;       (print
3a10: 20 22 69 74 65 6d 73 3a 20 22 29 20 20 20 20 20   "items: ")     
3a20: 28 70 70 20 28 69 74 65 6d 2d 61 73 73 6f 63 2d  (pp (item-assoc-
3a30: 3e 69 74 65 6d 2d 6c 69 73 74 20 69 74 65 6d 73  >item-list items
3a40: 29 29 0a 09 20 20 20 20 20 20 3b 3b 20 20 20 20  ))..      ;;    
3a50: 20 20 20 28 70 72 69 6e 74 20 22 69 74 65 6d 73     (print "items
3a60: 74 61 62 6c 65 3a 20 22 29 28 70 70 20 28 69 74  table: ")(pp (it
3a70: 65 6d 2d 74 61 62 6c 65 2d 3e 69 74 65 6d 2d 6c  em-table->item-l
3a80: 69 73 74 20 69 74 65 6d 73 74 61 62 6c 65 29 29  ist itemstable))
3a90: 29 29 0a 09 20 20 20 20 20 20 28 66 6f 72 2d 65  ))..      (for-e
3aa0: 61 63 68 0a 09 20 20 20 20 20 20 20 28 6c 61 6d  ach..       (lam
3ab0: 62 64 61 20 28 6d 79 2d 69 74 65 6d 64 61 74 29  bda (my-itemdat)
3ac0: 0a 09 09 20 28 6c 65 74 2a 20 28 28 6e 65 77 2d  ... (let* ((new-
3ad0: 74 65 73 74 2d 72 65 63 6f 72 64 20 28 6c 65 74  test-record (let
3ae0: 20 28 28 6e 65 77 72 65 63 20 28 6d 61 6b 65 2d   ((newrec (make-
3af0: 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 29  tests:testqueue)
3b00: 29 29 0a 09 09 09 09 09 20 20 20 28 76 65 63 74  ))......   (vect
3b10: 6f 72 2d 63 6f 70 79 21 20 74 65 73 74 2d 72 65  or-copy! test-re
3b20: 63 6f 72 64 20 6e 65 77 72 65 63 29 0a 09 09 09  cord newrec)....
3b30: 09 09 20 20 20 6e 65 77 72 65 63 29 29 0a 09 09  ..   newrec))...
3b40: 09 28 6d 79 2d 69 74 65 6d 2d 70 61 74 68 20 28  .(my-item-path (
3b50: 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20  item-list->path 
3b60: 6d 79 2d 69 74 65 6d 64 61 74 29 29 29 0a 09 09  my-itemdat)))...
3b70: 20 20 20 28 69 66 20 28 70 61 74 74 2d 6c 69 73     (if (patt-lis
3b80: 74 2d 6d 61 74 63 68 20 6d 79 2d 69 74 65 6d 2d  t-match my-item-
3b90: 70 61 74 68 20 69 74 65 6d 2d 70 61 74 74 73 29  path item-patts)
3ba0: 20 20 20 20 20 20 20 20 20 20 20 3b 3b 20 79 65             ;; ye
3bb0: 73 2c 20 77 65 20 77 61 6e 74 20 74 6f 20 70 72  s, we want to pr
3bc0: 6f 63 65 73 73 20 74 68 69 73 20 69 74 65 6d 2c  ocess this item,
3bd0: 20 4e 4f 54 45 3a 20 53 68 6f 75 6c 64 20 6e 6f   NOTE: Should no
3be0: 74 20 6e 65 65 64 20 74 68 69 73 20 63 68 65 63  t need this chec
3bf0: 6b 20 68 65 72 65 21 0a 09 09 20 20 20 20 20 20  k here!...      
3c00: 20 28 6c 65 74 20 28 28 6e 65 77 74 65 73 74 6e   (let ((newtestn
3c10: 61 6d 65 20 28 63 6f 6e 63 20 68 65 64 20 22 2f  ame (conc hed "/
3c20: 22 20 6d 79 2d 69 74 65 6d 2d 70 61 74 68 29 29  " my-item-path))
3c30: 29 20 20 20 20 3b 3b 20 74 65 73 74 20 6e 61 6d  )    ;; test nam
3c40: 65 73 20 61 72 65 20 75 6e 69 71 75 65 20 6f 6e  es are unique on
3c50: 20 74 65 73 74 6e 61 6d 65 2f 69 74 65 6d 2d 70   testname/item-p
3c60: 61 74 68 0a 09 09 09 20 28 74 65 73 74 73 3a 74  ath.... (tests:t
3c70: 65 73 74 71 75 65 75 65 2d 73 65 74 2d 69 74 65  estqueue-set-ite
3c80: 6d 73 21 20 20 20 20 20 6e 65 77 2d 74 65 73 74  ms!     new-test
3c90: 2d 72 65 63 6f 72 64 20 23 66 29 0a 09 09 09 20  -record #f).... 
3ca0: 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65  (tests:testqueue
3cb0: 2d 73 65 74 2d 69 74 65 6d 64 61 74 21 20 20 20  -set-itemdat!   
3cc0: 6e 65 77 2d 74 65 73 74 2d 72 65 63 6f 72 64 20  new-test-record 
3cd0: 6d 79 2d 69 74 65 6d 64 61 74 29 0a 09 09 09 20  my-itemdat).... 
3ce0: 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65  (tests:testqueue
3cf0: 2d 73 65 74 2d 69 74 65 6d 5f 70 61 74 68 21 20  -set-item_path! 
3d00: 6e 65 77 2d 74 65 73 74 2d 72 65 63 6f 72 64 20  new-test-record 
3d10: 6d 79 2d 69 74 65 6d 2d 70 61 74 68 29 0a 09 09  my-item-path)...
3d20: 09 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65  . (hash-table-se
3d30: 74 21 20 74 65 73 74 2d 72 65 63 6f 72 64 73 20  t! test-records 
3d40: 6e 65 77 74 65 73 74 6e 61 6d 65 20 6e 65 77 2d  newtestname new-
3d50: 74 65 73 74 2d 72 65 63 6f 72 64 29 0a 09 09 09  test-record)....
3d60: 20 28 73 65 74 21 20 74 61 6c 20 28 63 6f 6e 73   (set! tal (cons
3d70: 20 6e 65 77 74 65 73 74 6e 61 6d 65 20 74 61 6c   newtestname tal
3d80: 29 29 29 29 29 29 20 3b 3b 20 73 69 6e 63 65 20  )))))) ;; since 
3d90: 74 68 65 73 65 20 61 72 65 20 69 74 65 6d 69 7a  these are itemiz
3da0: 65 64 20 63 72 65 61 74 65 20 6e 65 77 20 74 65  ed create new te
3db0: 73 74 20 6e 61 6d 65 73 20 74 65 73 74 6e 61 6d  st names testnam
3dc0: 65 2f 69 74 65 6d 70 61 74 68 0a 09 20 20 20 20  e/itempath..    
3dd0: 20 20 20 69 74 65 6d 73 29 0a 09 20 20 20 20 20     items)..     
3de0: 20 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f   (if (not (null?
3df0: 20 74 61 6c 29 29 0a 09 09 20 20 28 6c 6f 6f 70   tal))...  (loop
3e00: 20 28 63 61 72 20 74 61 6c 29 28 63 64 72 20 74   (car tal)(cdr t
3e10: 61 6c 29 29 29 29 0a 0a 09 20 20 20 20 20 3b 3b  al))))...     ;;
3e20: 20 69 66 20 69 74 65 6d 73 20 69 73 20 61 20 70   if items is a p
3e30: 72 6f 63 20 74 68 65 6e 20 6e 65 65 64 20 74 6f  roc then need to
3e40: 20 72 75 6e 20 69 74 65 6d 73 3a 67 65 74 2d 69   run items:get-i
3e50: 74 65 6d 73 2d 66 72 6f 6d 2d 63 6f 6e 66 69 67  tems-from-config
3e60: 2c 20 67 65 74 20 74 68 65 20 6c 69 73 74 20 61  , get the list a
3e70: 6e 64 20 6c 6f 6f 70 20 0a 09 20 20 20 20 20 3b  nd loop ..     ;
3e80: 3b 20 20 20 20 2d 20 62 75 74 20 6f 6e 6c 79 20  ;    - but only 
3e90: 64 6f 20 74 68 61 74 20 69 66 20 72 65 73 6f 75  do that if resou
3ea0: 72 63 65 73 20 65 78 69 73 74 20 74 6f 20 6b 69  rces exist to ki
3eb0: 63 6b 20 6f 66 66 20 74 68 65 20 6a 6f 62 0a 09  ck off the job..
3ec0: 20 20 20 20 20 28 28 6f 72 20 28 70 72 6f 63 65       ((or (proce
3ed0: 64 75 72 65 3f 20 69 74 65 6d 73 29 28 65 71 3f  dure? items)(eq?
3ee0: 20 69 74 65 6d 73 20 27 68 61 76 65 2d 70 72 6f   items 'have-pro
3ef0: 63 65 64 75 72 65 29 29 0a 09 20 20 20 20 20 20  cedure))..      
3f00: 28 6c 65 74 20 28 28 63 61 6e 2d 72 75 6e 2d 6d  (let ((can-run-m
3f10: 6f 72 65 20 20 20 20 28 72 75 6e 73 3a 63 61 6e  ore    (runs:can
3f20: 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20  -run-more-tests 
3f30: 64 62 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29  db test-record))
3f40: 0a 09 09 20 20 20 20 28 70 72 65 72 65 71 73 2d  ...    (prereqs-
3f50: 6e 6f 74 2d 6d 65 74 20 28 64 62 3a 67 65 74 2d  not-met (db:get-
3f60: 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 20  prereqs-not-met 
3f70: 64 62 20 72 75 6e 2d 69 64 20 77 61 69 74 6f 6e  db run-id waiton
3f80: 73 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 09  s item-path)))..
3f90: 09 28 69 66 20 28 61 6e 64 20 63 61 6e 2d 72 75  .(if (and can-ru
3fa0: 6e 2d 6d 6f 72 65 20 28 6e 75 6c 6c 3f 20 70 72  n-more (null? pr
3fb0: 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 29 29 0a  ereqs-not-met)).
3fc0: 09 09 20 20 20 20 28 6c 65 74 20 28 28 74 65 73  ..    (let ((tes
3fd0: 74 2d 6e 61 6d 65 20 28 74 65 73 74 73 3a 74 65  t-name (tests:te
3fe0: 73 74 71 75 65 75 65 2d 67 65 74 2d 74 65 73 74  stqueue-get-test
3ff0: 6e 61 6d 65 20 74 65 73 74 2d 72 65 63 6f 72 64  name test-record
4000: 29 29 29 0a 09 09 20 20 20 20 20 20 28 73 65 74  )))...      (set
4010: 65 6e 76 20 22 4d 54 5f 54 45 53 54 5f 4e 41 4d  env "MT_TEST_NAM
4020: 45 22 20 74 65 73 74 2d 6e 61 6d 65 29 20 3b 3b  E" test-name) ;;
4030: 20 0a 09 09 20 20 20 20 20 20 28 73 65 74 65 6e   ...      (seten
4040: 76 20 22 4d 54 5f 52 55 4e 4e 41 4d 45 22 20 20  v "MT_RUNNAME"  
4050: 20 72 75 6e 6e 61 6d 65 29 0a 09 09 20 20 20 20   runname)...    
4060: 20 20 28 73 65 74 2d 6d 65 67 61 74 65 73 74 2d    (set-megatest-
4070: 65 6e 76 2d 76 61 72 73 20 64 62 20 72 75 6e 2d  env-vars db run-
4080: 69 64 29 20 3b 3b 20 74 68 65 73 65 20 6d 61 79  id) ;; these may
4090: 20 62 65 20 6e 65 65 64 65 64 20 62 79 20 74 68   be needed by th
40a0: 65 20 6c 61 75 6e 63 68 69 6e 67 20 70 72 6f 63  e launching proc
40b0: 65 73 73 0a 09 09 20 20 20 20 20 20 28 6c 65 74  ess...      (let
40c0: 20 28 28 69 74 65 6d 73 2d 6c 69 73 74 20 28 69   ((items-list (i
40d0: 74 65 6d 73 3a 67 65 74 2d 69 74 65 6d 73 2d 66  tems:get-items-f
40e0: 72 6f 6d 2d 63 6f 6e 66 69 67 20 74 63 6f 6e 66  rom-config tconf
40f0: 69 67 29 29 29 0a 09 09 09 28 69 66 20 28 6c 69  ig)))....(if (li
4100: 73 74 3f 20 69 74 65 6d 73 2d 6c 69 73 74 29 0a  st? items-list).
4110: 09 09 09 20 20 20 20 28 62 65 67 69 6e 0a 09 09  ...    (begin...
4120: 09 20 20 20 20 20 20 28 74 65 73 74 73 3a 74 65  .      (tests:te
4130: 73 74 71 75 65 75 65 2d 73 65 74 2d 69 74 65 6d  stqueue-set-item
4140: 73 21 20 74 65 73 74 2d 72 65 63 6f 72 64 20 69  s! test-record i
4150: 74 65 6d 73 2d 6c 69 73 74 29 0a 09 09 09 20 20  tems-list)....  
4160: 20 20 20 20 28 6c 6f 6f 70 20 68 65 64 20 74 61      (loop hed ta
4170: 6c 29 29 0a 09 09 09 20 20 20 20 28 62 65 67 69  l))....    (begi
4180: 6e 0a 09 09 09 20 20 20 20 20 20 28 64 65 62 75  n....      (debu
4190: 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52  g:print 0 "ERROR
41a0: 3a 20 54 68 65 20 70 72 6f 63 20 66 72 6f 6d 20  : The proc from 
41b0: 72 65 61 64 69 6e 67 20 74 68 65 20 73 65 74 75  reading the setu
41c0: 70 20 64 69 64 20 6e 6f 74 20 79 69 65 6c 64 20  p did not yield 
41d0: 61 20 6c 69 73 74 20 2d 20 70 6c 65 61 73 65 20  a list - please 
41e0: 72 65 70 6f 72 74 20 74 68 69 73 22 29 0a 09 09  report this")...
41f0: 09 20 20 20 20 20 20 28 65 78 69 74 20 31 29 29  .      (exit 1))
4200: 29 29 29 0a 09 09 20 20 20 20 28 6c 65 74 20 28  )))...    (let (
4210: 28 6e 65 77 74 61 6c 20 28 61 70 70 65 6e 64 20  (newtal (append 
4220: 74 61 6c 20 28 6c 69 73 74 20 68 65 64 29 29 29  tal (list hed)))
4230: 0a 09 09 09 20 20 28 66 61 69 6c 73 20 20 28 66  ....  (fails  (f
4240: 69 6c 74 65 72 20 28 6c 61 6d 62 64 61 20 28 74  ilter (lambda (t
4250: 65 73 74 29 28 6e 6f 74 20 28 6d 65 6d 62 65 72  est)(not (member
4260: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 73 74   (db:test-get-st
4270: 61 74 75 73 20 74 65 73 74 29 0a 09 09 09 09 09  atus test)......
4280: 09 09 09 20 20 20 20 20 27 28 22 50 41 53 53 22  ...     '("PASS"
4290: 20 22 57 41 52 4e 22 20 22 43 48 45 43 4b 22 20   "WARN" "CHECK" 
42a0: 22 57 41 49 56 45 44 22 29 29 29 29 0a 09 09 09  "WAIVED"))))....
42b0: 09 09 20 20 70 72 65 72 65 71 73 2d 6e 6f 74 2d  ..  prereqs-not-
42c0: 6d 65 74 29 29 29 0a 09 09 20 20 20 20 20 20 3b  met)))...      ;
42d0: 3b 20 69 66 20 63 61 6e 27 74 20 72 75 6e 20 6d  ; if can't run m
42e0: 6f 72 65 20 74 65 73 74 73 2c 20 6c 65 74 73 20  ore tests, lets 
42f0: 74 61 6b 65 20 61 20 62 72 65 61 74 68 65 72 0a  take a breather.
4300: 09 09 20 20 20 20 20 20 28 64 65 62 75 67 3a 70  ..      (debug:p
4310: 72 69 6e 74 20 34 20 22 46 41 49 4c 53 3a 20 22  rint 4 "FAILS: "
4320: 20 66 61 69 6c 73 29 0a 09 09 20 20 20 20 20 20   fails)...      
4330: 3b 3b 20 49 66 20 6f 6e 65 20 6f 72 20 6d 6f 72  ;; If one or mor
4340: 65 20 6f 66 20 74 68 65 20 70 72 65 72 65 71 73  e of the prereqs
4350: 2d 6e 6f 74 2d 6d 65 74 20 61 72 65 20 46 41 49  -not-met are FAI
4360: 4c 20 74 68 65 6e 20 77 65 20 63 61 6e 20 69 73  L then we can is
4370: 73 75 65 0a 09 09 20 20 20 20 20 20 3b 3b 20 61  sue...      ;; a
4380: 20 6d 65 73 73 61 67 65 20 61 6e 64 20 64 72 6f   message and dro
4390: 70 20 68 65 64 20 66 72 6f 6d 20 74 68 65 20 69  p hed from the i
43a0: 74 65 6d 73 20 74 6f 20 62 65 20 70 72 6f 63 65  tems to be proce
43b0: 73 73 65 64 2e 0a 09 09 20 20 20 20 20 20 28 69  ssed....      (i
43c0: 66 20 28 6e 75 6c 6c 3f 20 66 61 69 6c 73 29 0a  f (null? fails).
43d0: 09 09 09 20 20 28 62 65 67 69 6e 0a 09 09 09 20  ...  (begin.... 
43e0: 20 20 20 3b 3b 20 63 6f 75 6c 64 6e 27 74 20 72     ;; couldn't r
43f0: 75 6e 2c 20 74 61 6b 65 20 61 20 62 72 65 61 74  un, take a breat
4400: 68 65 72 0a 09 09 09 20 20 20 20 28 74 68 72 65  her....    (thre
4410: 61 64 2d 73 6c 65 65 70 21 20 30 2e 31 29 20 3b  ad-sleep! 0.1) ;
4420: 3b 20 6c 6f 6e 67 20 73 6c 65 65 70 20 68 65 72  ; long sleep her
4430: 65 20 2d 20 6e 6f 20 72 65 73 6f 75 72 63 65 73  e - no resources
4440: 2c 20 6d 61 79 20 61 73 20 77 65 6c 6c 20 62 65  , may as well be
4450: 20 70 61 74 69 65 6e 74 0a 09 09 09 20 20 20 20   patient....    
4460: 28 6c 6f 6f 70 20 28 63 61 72 20 6e 65 77 74 61  (loop (car newta
4470: 6c 29 28 63 64 72 20 6e 65 77 74 61 6c 29 29 29  l)(cdr newtal)))
4480: 0a 09 09 09 20 20 3b 3b 20 74 68 65 20 77 61 69  ....  ;; the wai
4490: 74 6f 6e 20 69 73 20 46 41 49 4c 20 73 6f 20 6e  ton is FAIL so n
44a0: 6f 20 70 6f 69 6e 74 20 69 6e 20 74 72 79 69 6e  o point in tryin
44b0: 67 20 74 6f 20 72 75 6e 20 68 65 64 0a 09 09 09  g to run hed....
44c0: 20 20 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c    (if (not (null
44d0: 3f 20 74 61 6c 29 29 0a 09 09 09 20 20 20 20 20  ? tal))....     
44e0: 20 28 6c 6f 6f 70 20 28 63 61 72 20 74 61 6c 29   (loop (car tal)
44f0: 28 63 64 72 20 74 61 6c 29 29 29 29 29 29 29 29  (cdr tal))))))))
4500: 0a 0a 09 20 20 20 20 20 3b 3b 20 74 68 69 73 20  ...     ;; this 
4510: 63 61 73 65 20 73 68 6f 75 6c 64 20 6e 6f 74 20  case should not 
4520: 68 61 70 70 65 6e 2c 20 61 64 64 65 64 20 74 6f  happen, added to
4530: 20 68 65 6c 70 20 63 61 74 63 68 20 61 6e 79 20   help catch any 
4540: 62 75 67 73 0a 09 20 20 20 20 20 28 28 61 6e 64  bugs..     ((and
4550: 20 28 6c 69 73 74 3f 20 69 74 65 6d 73 29 20 69   (list? items) i
4560: 74 65 6d 64 61 74 29 0a 09 20 20 20 20 20 20 28  temdat)..      (
4570: 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45  debug:print 0 "E
4580: 52 52 4f 52 3a 20 53 68 6f 75 6c 64 20 6e 6f 74  RROR: Should not
4590: 20 68 61 76 65 20 61 20 6c 69 73 74 20 6f 66 20   have a list of 
45a0: 69 74 65 6d 73 20 69 6e 20 61 20 74 65 73 74 20  items in a test 
45b0: 61 6e 64 20 74 68 65 20 69 74 65 6d 73 70 61 74  and the itemspat
45c0: 68 20 73 65 74 20 2d 20 70 6c 65 61 73 65 20 72  h set - please r
45d0: 65 70 6f 72 74 20 74 68 69 73 22 29 0a 09 20 20  eport this")..  
45e0: 20 20 20 20 28 65 78 69 74 20 31 29 29 29 29 0a      (exit 1)))).
45f0: 09 20 20 0a 09 20 20 3b 3b 20 77 65 20 67 65 74  .  ..  ;; we get
4600: 20 68 65 72 65 20 6f 6e 20 22 64 72 6f 70 20 74   here on "drop t
4610: 68 72 6f 75 67 68 22 20 2d 20 6c 6f 6f 70 20 66  hrough" - loop f
4620: 6f 72 20 6e 65 78 74 20 74 65 73 74 20 69 6e 20  or next test in 
4630: 71 75 65 75 65 0a 09 20 20 28 69 66 20 28 6e 75  queue..  (if (nu
4640: 6c 6c 3f 20 74 61 6c 29 0a 09 20 20 20 20 20 20  ll? tal)..      
4650: 28 62 65 67 69 6e 0a 09 09 3b 3b 20 46 49 58 4d  (begin...;; FIXM
4660: 45 21 21 21 21 20 54 48 49 53 20 53 48 4f 55 4c  E!!!! THIS SHOUL
4670: 44 20 4e 4f 54 20 52 45 51 55 49 52 45 20 41 4e  D NOT REQUIRE AN
4680: 20 45 58 49 54 21 21 21 21 21 21 21 0a 09 09 28   EXIT!!!!!!!...(
4690: 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 49  debug:print 1 "I
46a0: 4e 46 4f 3a 20 41 6c 6c 20 74 65 73 74 73 20 6c  NFO: All tests l
46b0: 61 75 6e 63 68 65 64 22 29 0a 09 09 28 74 68 72  aunched")...(thr
46c0: 65 61 64 2d 73 6c 65 65 70 21 20 30 2e 35 29 0a  ead-sleep! 0.5).
46d0: 09 09 3b 3b 20 46 49 58 4d 45 21 20 54 68 69 73  ..;; FIXME! This
46e0: 20 68 61 72 73 68 20 65 78 69 74 20 73 68 6f 75   harsh exit shou
46f0: 6c 64 20 6e 6f 74 20 62 65 20 6e 65 63 65 73 73  ld not be necess
4700: 61 72 79 2e 2e 2e 2e 0a 09 09 28 69 66 20 28 6e  ary.......(if (n
4710: 6f 74 20 2a 72 75 6e 72 65 6d 6f 74 65 2a 29 28  ot *runremote*)(
4720: 65 78 69 74 29 29 20 3b 3b 20 0a 09 09 23 66 29  exit)) ;; ...#f)
4730: 20 3b 3b 20 72 65 74 75 72 6e 20 61 20 23 66 20   ;; return a #f 
4740: 61 73 20 61 20 68 69 6e 74 20 74 68 61 74 20 77  as a hint that w
4750: 65 20 61 72 65 20 64 6f 6e 65 0a 09 20 20 20 20  e are done..    
4760: 20 20 3b 3b 20 48 65 72 65 20 77 65 20 6e 65 65    ;; Here we nee
4770: 64 20 74 6f 20 63 68 65 63 6b 20 74 68 61 74 20  d to check that 
4780: 61 6c 6c 20 74 68 65 20 74 65 73 74 73 20 72 65  all the tests re
4790: 6d 61 69 6e 69 6e 67 20 74 6f 20 62 65 20 72 75  maining to be ru
47a0: 6e 20 61 72 65 20 65 6c 69 67 69 62 6c 65 20 74  n are eligible t
47b0: 6f 20 72 75 6e 0a 09 20 20 20 20 20 20 3b 3b 20  o run..      ;; 
47c0: 61 6e 64 20 61 72 65 20 6e 6f 74 20 62 6c 6f 63  and are not bloc
47d0: 6b 65 64 20 62 79 20 66 61 69 6c 65 64 0a 09 20  ked by failed.. 
47e0: 20 20 20 20 20 28 6c 65 74 20 28 28 6e 65 77 6c       (let ((newl
47f0: 73 74 20 28 74 65 73 74 73 3a 66 69 6c 74 65 72  st (tests:filter
4800: 2d 6e 6f 6e 2d 72 75 6e 6e 61 62 6c 65 20 64 62  -non-runnable db
4810: 20 72 75 6e 2d 69 64 20 74 61 6c 20 74 65 73 74   run-id tal test
4820: 2d 72 65 63 6f 72 64 73 29 29 29 20 3b 3b 20 69  -records))) ;; i
4830: 2e 65 2e 20 6e 6f 74 20 46 41 49 4c 2c 20 57 41  .e. not FAIL, WA
4840: 49 56 45 44 2c 20 49 4e 43 4f 4d 50 4c 45 54 45  IVED, INCOMPLETE
4850: 2c 20 50 41 53 53 2c 20 4b 49 4c 4c 45 44 2c 0a  , PASS, KILLED,.
4860: 09 09 28 74 68 72 65 61 64 2d 73 6c 65 65 70 21  ..(thread-sleep!
4870: 20 30 2e 31 29 0a 09 09 28 69 66 20 28 6e 6f 74   0.1)...(if (not
4880: 20 28 6e 75 6c 6c 3f 20 6e 65 77 6c 73 74 29 29   (null? newlst))
4890: 0a 09 09 20 20 20 20 28 6c 6f 6f 70 20 28 63 61  ...    (loop (ca
48a0: 72 20 6e 65 77 6c 73 74 29 28 63 64 72 20 6e 65  r newlst)(cdr ne
48b0: 77 6c 73 74 29 29 29 29 29 29 29 29 29 0a 0a 3b  wlst)))))))))..;
48c0: 3b 20 70 61 72 65 6e 74 2d 74 65 73 74 20 69 73  ; parent-test is
48d0: 20 74 68 65 72 65 20 61 73 20 61 20 70 6c 61 63   there as a plac
48e0: 65 68 6f 6c 64 65 72 20 66 6f 72 20 77 68 65 6e  eholder for when
48f0: 20 70 61 72 65 6e 74 2d 74 65 73 74 73 20 63 61   parent-tests ca
4900: 6e 20 62 65 20 72 75 6e 20 61 73 20 61 20 73 65  n be run as a se
4910: 74 75 70 20 73 74 65 70 0a 28 64 65 66 69 6e 65  tup step.(define
4920: 20 28 72 75 6e 3a 74 65 73 74 20 64 62 20 72 75   (run:test db ru
4930: 6e 2d 69 64 20 72 75 6e 6e 61 6d 65 20 6b 65 79  n-id runname key
4940: 76 61 6c 6c 73 74 20 74 65 73 74 2d 72 65 63 6f  vallst test-reco
4950: 72 64 20 66 6c 61 67 73 20 70 61 72 65 6e 74 2d  rd flags parent-
4960: 74 65 73 74 29 0a 20 20 3b 3b 20 41 6c 6c 20 74  test).  ;; All t
4970: 68 65 73 65 20 76 61 72 73 20 6d 69 67 68 74 20  hese vars might 
4980: 62 65 20 72 65 66 65 72 65 6e 63 65 64 20 62 79  be referenced by
4990: 20 74 68 65 20 74 65 73 74 63 6f 6e 66 69 67 20   the testconfig 
49a0: 66 69 6c 65 20 72 65 61 64 65 72 0a 20 20 28 6c  file reader.  (l
49b0: 65 74 2a 20 28 28 74 65 73 74 2d 6e 61 6d 65 20  et* ((test-name 
49c0: 20 20 20 28 74 65 73 74 73 3a 74 65 73 74 71 75     (tests:testqu
49d0: 65 75 65 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65  eue-get-testname
49e0: 20 20 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29     test-record))
49f0: 0a 09 20 28 74 65 73 74 2d 77 61 69 74 6f 6e 73  .. (test-waitons
4a00: 20 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75   (tests:testqueu
4a10: 65 2d 67 65 74 2d 77 61 69 74 6f 6e 73 20 20 20  e-get-waitons   
4a20: 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29 0a 09   test-record))..
4a30: 20 28 74 65 73 74 2d 63 6f 6e 66 20 20 20 20 28   (test-conf    (
4a40: 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d  tests:testqueue-
4a50: 67 65 74 2d 74 65 73 74 63 6f 6e 66 69 67 20 74  get-testconfig t
4a60: 65 73 74 2d 72 65 63 6f 72 64 29 29 0a 09 20 28  est-record)).. (
4a70: 69 74 65 6d 64 61 74 20 20 20 20 20 20 28 74 65  itemdat      (te
4a80: 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65  sts:testqueue-ge
4a90: 74 2d 69 74 65 6d 64 61 74 20 20 20 20 74 65 73  t-itemdat    tes
4aa0: 74 2d 72 65 63 6f 72 64 29 29 0a 09 20 28 74 65  t-record)).. (te
4ab0: 73 74 2d 70 61 74 68 20 20 20 20 28 63 6f 6e 63  st-path    (conc
4ac0: 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f 74 65 73   *toppath* "/tes
4ad0: 74 73 2f 22 20 74 65 73 74 2d 6e 61 6d 65 29 29  ts/" test-name))
4ae0: 20 3b 3b 20 63 6f 75 6c 64 20 75 73 65 20 74 65   ;; could use te
4af0: 73 74 73 3a 67 65 74 2d 74 65 73 74 63 6f 6e 66  sts:get-testconf
4b00: 69 67 20 68 65 72 65 20 2e 2e 2e 0a 09 20 28 66  ig here ..... (f
4b10: 6f 72 63 65 20 20 20 20 20 20 20 20 28 68 61 73  orce        (has
4b20: 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61  h-table-ref/defa
4b30: 75 6c 74 20 66 6c 61 67 73 20 22 2d 66 6f 72 63  ult flags "-forc
4b40: 65 22 20 23 66 29 29 0a 09 20 28 72 65 72 75 6e  e" #f)).. (rerun
4b50: 20 20 20 20 20 20 20 20 28 68 61 73 68 2d 74 61          (hash-ta
4b60: 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20  ble-ref/default 
4b70: 66 6c 61 67 73 20 22 2d 72 65 72 75 6e 22 20 23  flags "-rerun" #
4b80: 66 29 29 0a 09 20 28 6b 65 65 70 67 6f 69 6e 67  f)).. (keepgoing
4b90: 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d      (hash-table-
4ba0: 72 65 66 2f 64 65 66 61 75 6c 74 20 66 6c 61 67  ref/default flag
4bb0: 73 20 22 2d 6b 65 65 70 67 6f 69 6e 67 22 20 23  s "-keepgoing" #
4bc0: 66 29 29 0a 09 20 28 69 74 65 6d 2d 70 61 74 68  f)).. (item-path
4bd0: 20 20 20 20 20 22 22 29 29 0a 20 20 20 20 28 64       "")).    (d
4be0: 65 62 75 67 3a 70 72 69 6e 74 20 35 0a 09 09 20  ebug:print 5... 
4bf0: 22 74 65 73 74 2d 63 6f 6e 66 69 67 3a 20 22 20  "test-config: " 
4c00: 28 68 61 73 68 2d 74 61 62 6c 65 2d 3e 61 6c 69  (hash-table->ali
4c10: 73 74 20 74 65 73 74 2d 63 6f 6e 66 29 0a 09 09  st test-conf)...
4c20: 20 22 5c 6e 20 20 20 69 74 65 6d 64 61 74 3a 20   "\n   itemdat: 
4c30: 22 20 69 74 65 6d 64 61 74 0a 09 09 20 29 0a 20  " itemdat... ). 
4c40: 20 20 20 3b 3b 20 73 65 74 74 69 6e 67 20 69 74     ;; setting it
4c50: 65 6d 64 61 74 20 74 6f 20 61 20 6c 69 73 74 20  emdat to a list 
4c60: 69 66 20 69 74 20 69 73 20 23 66 0a 20 20 20 20  if it is #f.    
4c70: 28 69 66 20 28 6e 6f 74 20 69 74 65 6d 64 61 74  (if (not itemdat
4c80: 29 28 73 65 74 21 20 69 74 65 6d 64 61 74 20 27  )(set! itemdat '
4c90: 28 29 29 29 0a 20 20 20 20 28 73 65 74 21 20 69  ())).    (set! i
4ca0: 74 65 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c  tem-path (item-l
4cb0: 69 73 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61  ist->path itemda
4cc0: 74 29 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70  t)).    (debug:p
4cd0: 72 69 6e 74 20 32 20 22 41 74 74 65 6d 70 74 69  rint 2 "Attempti
4ce0: 6e 67 20 74 6f 20 6c 61 75 6e 63 68 20 74 65 73  ng to launch tes
4cf0: 74 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 2f  t " test-name "/
4d00: 22 20 69 74 65 6d 2d 70 61 74 68 29 0a 20 20 20  " item-path).   
4d10: 20 28 73 65 74 65 6e 76 20 22 4d 54 5f 54 45 53   (setenv "MT_TES
4d20: 54 5f 4e 41 4d 45 22 20 74 65 73 74 2d 6e 61 6d  T_NAME" test-nam
4d30: 65 29 20 3b 3b 20 0a 20 20 20 20 28 73 65 74 65  e) ;; .    (sete
4d40: 6e 76 20 22 4d 54 5f 52 55 4e 4e 41 4d 45 22 20  nv "MT_RUNNAME" 
4d50: 20 20 72 75 6e 6e 61 6d 65 29 0a 20 20 20 20 28    runname).    (
4d60: 73 65 74 2d 6d 65 67 61 74 65 73 74 2d 65 6e 76  set-megatest-env
4d70: 2d 76 61 72 73 20 64 62 20 72 75 6e 2d 69 64 29  -vars db run-id)
4d80: 20 3b 3b 20 74 68 65 73 65 20 6d 61 79 20 62 65   ;; these may be
4d90: 20 6e 65 65 64 65 64 20 62 79 20 74 68 65 20 6c   needed by the l
4da0: 61 75 6e 63 68 69 6e 67 20 70 72 6f 63 65 73 73  aunching process
4db0: 0a 20 20 20 20 28 63 68 61 6e 67 65 2d 64 69 72  .    (change-dir
4dc0: 65 63 74 6f 72 79 20 2a 74 6f 70 70 61 74 68 2a  ectory *toppath*
4dd0: 29 0a 0a 20 20 20 20 3b 3b 20 48 65 72 65 20 69  )..    ;; Here i
4de0: 73 20 77 68 65 72 65 20 74 68 65 20 74 65 73 74  s where the test
4df0: 5f 6d 65 74 61 20 74 61 62 6c 65 20 69 73 20 62  _meta table is b
4e00: 65 73 74 20 75 70 64 61 74 65 64 0a 20 20 20 20  est updated.    
4e10: 3b 3b 20 59 65 73 2c 20 61 6e 6f 74 68 65 72 20  ;; Yes, another 
4e20: 75 73 65 20 6f 66 20 61 20 67 6c 6f 62 61 6c 20  use of a global 
4e30: 66 6f 72 20 63 61 63 68 69 6e 67 2e 20 4e 65 65  for caching. Nee
4e40: 64 20 61 20 62 65 74 74 65 72 20 77 61 79 3f 0a  d a better way?.
4e50: 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28 68 61      (if (not (ha
4e60: 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66  sh-table-ref/def
4e70: 61 75 6c 74 20 2a 74 65 73 74 2d 6d 65 74 61 2d  ault *test-meta-
4e80: 75 70 64 61 74 65 64 2a 20 74 65 73 74 2d 6e 61  updated* test-na
4e90: 6d 65 20 23 66 29 29 0a 20 20 20 20 20 20 20 20  me #f)).        
4ea0: 28 62 65 67 69 6e 0a 09 20 20 20 28 68 61 73 68  (begin..   (hash
4eb0: 2d 74 61 62 6c 65 2d 73 65 74 21 20 2a 74 65 73  -table-set! *tes
4ec0: 74 2d 6d 65 74 61 2d 75 70 64 61 74 65 64 2a 20  t-meta-updated* 
4ed0: 74 65 73 74 2d 6e 61 6d 65 20 23 74 29 0a 20 20  test-name #t).  
4ee0: 20 20 20 20 20 20 20 20 20 28 72 75 6e 73 3a 75           (runs:u
4ef0: 70 64 61 74 65 2d 74 65 73 74 5f 6d 65 74 61 20  pdate-test_meta 
4f00: 64 62 20 74 65 73 74 2d 6e 61 6d 65 20 74 65 73  db test-name tes
4f10: 74 2d 63 6f 6e 66 29 29 29 0a 20 20 20 20 0a 20  t-conf))).    . 
4f20: 20 20 20 3b 3b 20 28 6c 61 6d 62 64 61 20 28 69     ;; (lambda (i
4f30: 74 65 6d 64 61 74 29 20 3b 3b 3b 20 28 28 72 69  temdat) ;;; ((ri
4f40: 70 65 6e 65 73 73 20 22 6f 76 65 72 72 69 70 65  peness "overripe
4f50: 22 29 20 28 74 65 6d 70 65 72 61 74 75 72 65 20  ") (temperature 
4f60: 22 63 6f 6f 6c 22 29 20 28 73 65 61 73 6f 6e 20  "cool") (season 
4f70: 22 73 75 6d 6d 65 72 22 29 29 0a 20 20 20 20 28  "summer")).    (
4f80: 6c 65 74 2a 20 28 28 6e 65 77 2d 74 65 73 74 2d  let* ((new-test-
4f90: 70 61 74 68 20 28 73 74 72 69 6e 67 2d 69 6e 74  path (string-int
4fa0: 65 72 73 70 65 72 73 65 20 28 63 6f 6e 73 20 74  ersperse (cons t
4fb0: 65 73 74 2d 70 61 74 68 20 28 6d 61 70 20 63 61  est-path (map ca
4fc0: 64 72 20 69 74 65 6d 64 61 74 29 29 20 22 2f 22  dr itemdat)) "/"
4fd0: 29 29 0a 09 20 20 20 28 6e 65 77 2d 74 65 73 74  ))..   (new-test
4fe0: 2d 6e 61 6d 65 20 28 69 66 20 28 65 71 75 61 6c  -name (if (equal
4ff0: 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29 20  ? item-path "") 
5000: 74 65 73 74 2d 6e 61 6d 65 20 28 63 6f 6e 63 20  test-name (conc 
5010: 74 65 73 74 2d 6e 61 6d 65 20 22 2f 22 20 69 74  test-name "/" it
5020: 65 6d 2d 70 61 74 68 29 29 29 20 3b 3b 20 6a 75  em-path))) ;; ju
5030: 73 74 20 6e 65 65 64 20 69 74 20 74 6f 20 62 65  st need it to be
5040: 20 75 6e 69 71 75 65 0a 09 20 20 20 28 74 65 73   unique..   (tes
5050: 74 64 61 74 20 20 20 20 20 20 20 28 64 62 3a 67  tdat       (db:g
5060: 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 20  et-test-info db 
5070: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
5080: 20 69 74 65 6d 2d 70 61 74 68 29 29 0a 09 20 20   item-path))..  
5090: 20 28 74 65 73 74 2d 69 64 20 20 20 20 20 20 20   (test-id       
50a0: 23 66 29 29 0a 20 20 20 20 20 20 28 69 66 20 28  #f)).      (if (
50b0: 6e 6f 74 20 74 65 73 74 64 61 74 29 0a 09 20 20  not testdat)..  
50c0: 28 62 65 67 69 6e 0a 09 20 20 20 20 3b 3b 20 65  (begin..    ;; e
50d0: 6e 73 75 72 65 20 74 68 61 74 20 74 68 65 20 70  nsure that the p
50e0: 61 74 68 20 65 78 69 73 74 73 20 62 65 66 6f 72  ath exists befor
50f0: 65 20 72 65 67 69 73 74 65 72 69 6e 67 20 74 68  e registering th
5100: 65 20 74 65 73 74 0a 09 20 20 20 20 3b 3b 20 4e  e test..    ;; N
5110: 4f 50 45 3a 20 43 61 6e 6e 6f 74 21 20 44 6f 6e  OPE: Cannot! Don
5120: 27 74 20 6b 6e 6f 77 20 79 65 74 20 77 68 69 63  't know yet whic
5130: 68 20 64 69 73 6b 20 61 72 65 61 20 77 69 6c 6c  h disk area will
5140: 20 62 65 20 61 73 73 69 67 6e 65 64 2e 2e 2e 2e   be assigned....
5150: 0a 09 20 20 20 20 3b 3b 20 28 73 79 73 74 65 6d  ..    ;; (system
5160: 20 28 63 6f 6e 63 20 22 6d 6b 64 69 72 20 2d 70   (conc "mkdir -p
5170: 20 22 20 6e 65 77 2d 74 65 73 74 2d 70 61 74 68   " new-test-path
5180: 29 29 0a 09 20 20 20 20 28 72 74 65 73 74 73 3a  ))..    (rtests:
5190: 72 65 67 69 73 74 65 72 2d 74 65 73 74 20 64 62  register-test db
51a0: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
51b0: 65 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 20 20  e item-path)..  
51c0: 20 20 28 73 65 74 21 20 74 65 73 74 64 61 74 20    (set! testdat 
51d0: 28 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66  (db:get-test-inf
51e0: 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  o db run-id test
51f0: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  -name item-path)
5200: 29 29 29 0a 20 20 20 20 20 20 28 73 65 74 21 20  ))).      (set! 
5210: 74 65 73 74 2d 69 64 20 28 64 62 3a 74 65 73 74  test-id (db:test
5220: 2d 67 65 74 2d 69 64 20 74 65 73 74 64 61 74 29  -get-id testdat)
5230: 29 0a 20 20 20 20 20 20 28 63 68 61 6e 67 65 2d  ).      (change-
5240: 64 69 72 65 63 74 6f 72 79 20 74 65 73 74 2d 70  directory test-p
5250: 61 74 68 29 0a 20 20 20 20 20 20 28 63 61 73 65  ath).      (case
5260: 20 28 69 66 20 66 6f 72 63 65 20 3b 3b 20 28 61   (if force ;; (a
5270: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 66 6f  rgs:get-arg "-fo
5280: 72 63 65 22 29 0a 09 09 27 4e 4f 54 5f 53 54 41  rce")...'NOT_STA
5290: 52 54 45 44 0a 09 09 28 69 66 20 74 65 73 74 64  RTED...(if testd
52a0: 61 74 0a 09 09 20 20 20 20 28 73 74 72 69 6e 67  at...    (string
52b0: 2d 3e 73 79 6d 62 6f 6c 20 28 74 65 73 74 3a 67  ->symbol (test:g
52c0: 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 74  et-state testdat
52d0: 29 29 0a 09 09 20 20 20 20 27 66 61 69 6c 65 64  ))...    'failed
52e0: 2d 74 6f 2d 69 6e 73 65 72 74 29 29 0a 09 28 28  -to-insert))..((
52f0: 66 61 69 6c 65 64 2d 74 6f 2d 69 6e 73 65 72 74  failed-to-insert
5300: 29 0a 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ).. (debug:print
5310: 20 30 20 22 45 52 52 4f 52 3a 20 46 61 69 6c 65   0 "ERROR: Faile
5320: 64 20 74 6f 20 69 6e 73 65 72 74 20 74 68 65 20  d to insert the 
5330: 72 65 63 6f 72 64 20 69 6e 74 6f 20 74 68 65 20  record into the 
5340: 64 62 22 29 29 0a 09 28 28 4e 4f 54 5f 53 54 41  db"))..((NOT_STA
5350: 52 54 45 44 20 43 4f 4d 50 4c 45 54 45 44 29 0a  RTED COMPLETED).
5360: 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 36  . (debug:print 6
5370: 20 22 47 6f 74 20 68 65 72 65 2c 20 22 20 28 74   "Got here, " (t
5380: 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65  est:get-state te
5390: 73 74 64 61 74 29 29 0a 09 20 28 6c 65 74 20 28  stdat)).. (let (
53a0: 28 72 75 6e 66 6c 61 67 20 23 66 29 29 0a 09 20  (runflag #f)).. 
53b0: 20 20 28 63 6f 6e 64 0a 09 20 20 20 20 3b 3b 20    (cond..    ;; 
53c0: 2d 66 6f 72 63 65 2c 20 72 75 6e 20 6e 6f 20 6d  -force, run no m
53d0: 61 74 74 65 72 20 77 68 61 74 0a 09 20 20 20 20  atter what..    
53e0: 28 66 6f 72 63 65 20 28 73 65 74 21 20 72 75 6e  (force (set! run
53f0: 66 6c 61 67 20 23 74 29 29 0a 09 20 20 20 20 3b  flag #t))..    ;
5400: 3b 20 4e 4f 54 5f 53 54 41 52 54 45 44 2c 20 72  ; NOT_STARTED, r
5410: 75 6e 20 6e 6f 20 6d 61 74 74 65 72 20 77 68 61  un no matter wha
5420: 74 0a 09 20 20 20 20 28 28 65 71 75 61 6c 3f 20  t..    ((equal? 
5430: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20  (test:get-state 
5440: 74 65 73 74 64 61 74 29 20 22 4e 4f 54 5f 53 54  testdat) "NOT_ST
5450: 41 52 54 45 44 22 29 28 73 65 74 21 20 72 75 6e  ARTED")(set! run
5460: 66 6c 61 67 20 23 74 29 29 0a 09 20 20 20 20 3b  flag #t))..    ;
5470: 3b 20 6e 6f 74 20 2d 72 65 72 75 6e 20 61 6e 64  ; not -rerun and
5480: 20 50 41 53 53 2c 20 57 41 52 4e 20 6f 72 20 43   PASS, WARN or C
5490: 48 45 43 4b 2c 20 64 6f 20 6e 6f 20 72 75 6e 0a  HECK, do no run.
54a0: 09 20 20 20 20 28 28 61 6e 64 20 28 6f 72 20 28  .    ((and (or (
54b0: 6e 6f 74 20 72 65 72 75 6e 29 0a 09 09 20 20 20  not rerun)...   
54c0: 20 20 20 6b 65 65 70 67 6f 69 6e 67 29 0a 09 09     keepgoing)...
54d0: 20 20 3b 3b 20 52 65 71 75 69 72 65 20 74 6f 20    ;; Require to 
54e0: 66 6f 72 63 65 20 72 65 2d 72 75 6e 20 66 6f 72  force re-run for
54f0: 20 43 4f 4d 50 4c 45 54 45 44 20 6f 72 20 2a 61   COMPLETED or *a
5500: 6e 79 74 68 69 6e 67 2a 20 2b 20 50 41 53 53 2c  nything* + PASS,
5510: 57 41 52 4e 20 6f 72 20 43 48 45 43 4b 0a 09 09  WARN or CHECK...
5520: 20 20 28 6f 72 20 28 6d 65 6d 62 65 72 20 28 74    (or (member (t
5530: 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74  est:get-status t
5540: 65 73 74 64 61 74 29 20 27 28 22 50 41 53 53 22  estdat) '("PASS"
5550: 20 22 57 41 52 4e 22 20 22 43 48 45 43 4b 22 29   "WARN" "CHECK")
5560: 29 0a 09 09 20 20 20 20 20 20 28 6d 65 6d 62 65  )...      (membe
5570: 72 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74  r (test:get-stat
5580: 65 20 20 74 65 73 74 64 61 74 29 20 27 28 22 43  e  testdat) '("C
5590: 4f 4d 50 4c 45 54 45 44 22 29 29 29 29 20 0a 09  OMPLETED")))) ..
55a0: 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e       (debug:prin
55b0: 74 20 32 20 22 49 4e 46 4f 3a 20 72 75 6e 6e 69  t 2 "INFO: runni
55c0: 6e 67 20 74 65 73 74 20 22 20 74 65 73 74 2d 6e  ng test " test-n
55d0: 61 6d 65 20 22 2f 22 20 69 74 65 6d 2d 70 61 74  ame "/" item-pat
55e0: 68 20 22 20 73 75 70 70 72 65 73 73 65 64 20 61  h " suppressed a
55f0: 73 20 69 74 20 69 73 20 43 4f 4d 50 4c 45 54 45  s it is COMPLETE
5600: 44 20 61 6e 64 20 22 20 28 74 65 73 74 3a 67 65  D and " (test:ge
5610: 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 74 29  t-state testdat)
5620: 29 0a 09 20 20 20 20 20 28 73 65 74 21 20 72 75  )..     (set! ru
5630: 6e 66 6c 61 67 20 23 66 29 29 0a 09 20 20 20 20  nflag #f))..    
5640: 3b 3b 20 2d 72 65 72 75 6e 20 61 6e 64 20 73 74  ;; -rerun and st
5650: 61 74 75 73 20 69 73 20 6f 6e 65 20 6f 66 20 74  atus is one of t
5660: 68 65 20 73 70 65 63 69 66 65 64 2c 20 72 75 6e  he specifed, run
5670: 20 69 74 0a 09 20 20 20 20 28 28 61 6e 64 20 72   it..    ((and r
5680: 65 72 75 6e 0a 09 09 20 20 28 6c 65 74 2a 20 28  erun...  (let* (
5690: 28 72 65 72 75 6e 6c 73 74 20 20 20 28 73 74 72  (rerunlst   (str
56a0: 69 6e 67 2d 73 70 6c 69 74 20 72 65 72 75 6e 20  ing-split rerun 
56b0: 22 2c 22 29 29 0a 09 09 09 20 28 6d 75 73 74 2d  ",")).... (must-
56c0: 72 65 72 75 6e 20 28 6d 65 6d 62 65 72 20 28 74  rerun (member (t
56d0: 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74  est:get-status t
56e0: 65 73 74 64 61 74 29 20 72 65 72 75 6e 6c 73 74  estdat) rerunlst
56f0: 29 29 29 0a 09 09 20 20 20 20 28 64 65 62 75 67  )))...    (debug
5700: 3a 70 72 69 6e 74 20 33 20 22 49 4e 46 4f 3a 20  :print 3 "INFO: 
5710: 2d 72 65 72 75 6e 20 6c 69 73 74 3a 20 22 20 72  -rerun list: " r
5720: 65 72 75 6e 20 22 2c 20 74 65 73 74 2d 73 74 61  erun ", test-sta
5730: 74 75 73 3a 20 22 20 28 74 65 73 74 3a 67 65 74  tus: " (test:get
5740: 2d 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29  -status testdat)
5750: 22 2c 20 6d 75 73 74 2d 72 65 72 75 6e 3a 20 22  ", must-rerun: "
5760: 20 6d 75 73 74 2d 72 65 72 75 6e 29 0a 09 09 20   must-rerun)... 
5770: 20 20 20 6d 75 73 74 2d 72 65 72 75 6e 29 29 0a     must-rerun)).
5780: 09 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69  .     (debug:pri
5790: 6e 74 20 32 20 22 49 4e 46 4f 3a 20 52 65 72 75  nt 2 "INFO: Reru
57a0: 6e 20 66 6f 72 63 65 64 20 66 6f 72 20 74 65 73  n forced for tes
57b0: 74 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 2f  t " test-name "/
57c0: 22 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 20 20  " item-path)..  
57d0: 20 20 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67     (set! runflag
57e0: 20 23 74 29 29 0a 09 20 20 20 20 3b 3b 20 2d 6b   #t))..    ;; -k
57f0: 65 65 70 67 6f 69 6e 67 2c 20 64 6f 20 6e 6f 74  eepgoing, do not
5800: 20 72 65 72 75 6e 20 46 41 49 4c 0a 09 20 20 20   rerun FAIL..   
5810: 20 28 28 61 6e 64 20 6b 65 65 70 67 6f 69 6e 67   ((and keepgoing
5820: 0a 09 09 20 20 28 6d 65 6d 62 65 72 20 28 74 65  ...  (member (te
5830: 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65  st:get-status te
5840: 73 74 64 61 74 29 20 27 28 22 46 41 49 4c 22 29  stdat) '("FAIL")
5850: 29 29 0a 09 20 20 20 20 20 28 73 65 74 21 20 72  ))..     (set! r
5860: 75 6e 66 6c 61 67 20 23 66 29 29 0a 09 20 20 20  unflag #f))..   
5870: 20 28 28 61 6e 64 20 28 6e 6f 74 20 72 65 72 75   ((and (not reru
5880: 6e 29 0a 09 09 20 20 28 6d 65 6d 62 65 72 20 28  n)...  (member (
5890: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20  test:get-status 
58a0: 74 65 73 74 64 61 74 29 20 27 28 22 46 41 49 4c  testdat) '("FAIL
58b0: 22 20 22 6e 2f 61 22 29 29 29 0a 09 20 20 20 20  " "n/a")))..    
58c0: 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23   (set! runflag #
58d0: 74 29 29 0a 09 20 20 20 20 28 65 6c 73 65 20 28  t))..    (else (
58e0: 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 66 29  set! runflag #f)
58f0: 29 29 0a 09 20 20 20 28 64 65 62 75 67 3a 70 72  ))..   (debug:pr
5900: 69 6e 74 20 36 20 22 52 55 4e 4e 49 4e 47 20 3d  int 6 "RUNNING =
5910: 3e 20 72 75 6e 66 6c 61 67 3a 20 22 20 72 75 6e  > runflag: " run
5920: 66 6c 61 67 20 22 20 53 54 41 54 45 3a 20 22 20  flag " STATE: " 
5930: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20  (test:get-state 
5940: 74 65 73 74 64 61 74 29 20 22 20 53 54 41 54 55  testdat) " STATU
5950: 53 3a 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73  S: " (test:get-s
5960: 74 61 74 75 73 20 74 65 73 74 64 61 74 29 29 0a  tatus testdat)).
5970: 09 20 20 20 28 69 66 20 28 6e 6f 74 20 72 75 6e  .   (if (not run
5980: 66 6c 61 67 29 0a 09 20 20 20 20 20 20 20 28 69  flag)..       (i
5990: 66 20 28 6e 6f 74 20 70 61 72 65 6e 74 2d 74 65  f (not parent-te
59a0: 73 74 29 0a 09 09 20 20 20 28 64 65 62 75 67 3a  st)...   (debug:
59b0: 70 72 69 6e 74 20 31 20 22 4e 4f 54 45 3a 20 4e  print 1 "NOTE: N
59c0: 6f 74 20 73 74 61 72 74 69 6e 67 20 74 65 73 74  ot starting test
59d0: 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65   " new-test-name
59e0: 20 22 20 61 73 20 69 74 20 69 73 20 73 74 61 74   " as it is stat
59f0: 65 20 5c 22 22 20 28 74 65 73 74 3a 67 65 74 2d  e \"" (test:get-
5a00: 73 74 61 74 65 20 74 65 73 74 64 61 74 29 20 0a  state testdat) .
5a10: 09 09 09 09 22 5c 22 20 61 6e 64 20 73 74 61 74  ...."\" and stat
5a20: 75 73 20 5c 22 22 20 28 74 65 73 74 3a 67 65 74  us \"" (test:get
5a30: 2d 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29  -status testdat)
5a40: 20 22 5c 22 2c 20 75 73 65 20 2d 72 65 72 75 6e   "\", use -rerun
5a50: 20 5c 22 22 20 28 74 65 73 74 3a 67 65 74 2d 73   \"" (test:get-s
5a60: 74 61 74 75 73 20 74 65 73 74 64 61 74 29 0a 20  tatus testdat). 
5a70: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
5a80: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 22                 "
5a90: 5c 22 20 6f 72 20 2d 66 6f 72 63 65 20 74 6f 20  \" or -force to 
5aa0: 6f 76 65 72 72 69 64 65 22 29 29 0a 09 20 20 20  override"))..   
5ab0: 20 20 20 20 3b 3b 20 4e 4f 54 45 3a 20 4e 6f 20      ;; NOTE: No 
5ac0: 6c 6f 6e 67 65 72 20 62 65 20 63 68 65 63 6b 69  longer be checki
5ad0: 6e 67 20 70 72 65 72 65 71 75 69 73 69 74 65 73  ng prerequisites
5ae0: 20 68 65 72 65 21 20 57 69 6c 6c 20 6e 65 76 65   here! Will neve
5af0: 72 20 67 65 74 20 68 65 72 65 20 75 6e 6c 65 73  r get here unles
5b00: 73 20 70 72 65 72 65 71 73 20 61 72 65 0a 09 20  s prereqs are.. 
5b10: 20 20 20 20 20 20 3b 3b 20 20 20 20 20 20 20 61        ;;       a
5b20: 6c 72 65 61 64 79 20 6d 65 74 2e 0a 09 20 20 20  lready met...   
5b30: 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28 6c 61      (if (not (la
5b40: 75 6e 63 68 2d 74 65 73 74 20 64 62 20 72 75 6e  unch-test db run
5b50: 2d 69 64 20 72 75 6e 6e 61 6d 65 20 74 65 73 74  -id runname test
5b60: 2d 63 6f 6e 66 20 6b 65 79 76 61 6c 6c 73 74 20  -conf keyvallst 
5b70: 74 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 2d 70  test-name test-p
5b80: 61 74 68 20 69 74 65 6d 64 61 74 20 66 6c 61 67  ath itemdat flag
5b90: 73 29 29 0a 09 09 20 20 20 28 62 65 67 69 6e 0a  s))...   (begin.
5ba0: 09 09 20 20 20 20 20 28 70 72 69 6e 74 20 22 45  ..     (print "E
5bb0: 52 52 4f 52 3a 20 46 61 69 6c 65 64 20 74 6f 20  RROR: Failed to 
5bc0: 6c 61 75 6e 63 68 20 74 68 65 20 74 65 73 74 2e  launch the test.
5bd0: 20 45 78 69 74 69 6e 67 20 61 73 20 73 6f 6f 6e   Exiting as soon
5be0: 20 61 73 20 70 6f 73 73 69 62 6c 65 22 29 0a 09   as possible")..
5bf0: 09 20 20 20 20 20 28 73 65 74 21 20 2a 67 6c 6f  .     (set! *glo
5c00: 62 61 6c 65 78 69 74 73 74 61 74 75 73 2a 20 31  balexitstatus* 1
5c10: 29 20 3b 3b 20 0a 09 09 20 20 20 20 20 28 70 72  ) ;; ...     (pr
5c20: 6f 63 65 73 73 2d 73 69 67 6e 61 6c 20 28 63 75  ocess-signal (cu
5c30: 72 72 65 6e 74 2d 70 72 6f 63 65 73 73 2d 69 64  rrent-process-id
5c40: 29 20 73 69 67 6e 61 6c 2f 6b 69 6c 6c 29 29 29  ) signal/kill)))
5c50: 29 29 29 0a 09 28 28 4b 49 4c 4c 45 44 29 20 0a  )))..((KILLED) .
5c60: 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31  . (debug:print 1
5c70: 20 22 4e 4f 54 45 3a 20 22 20 6e 65 77 2d 74 65   "NOTE: " new-te
5c80: 73 74 2d 6e 61 6d 65 20 22 20 69 73 20 61 6c 72  st-name " is alr
5c90: 65 61 64 79 20 72 75 6e 6e 69 6e 67 20 6f 72 20  eady running or 
5ca0: 77 61 73 20 65 78 70 6c 69 63 74 6c 79 20 6b 69  was explictly ki
5cb0: 6c 6c 65 64 2c 20 75 73 65 20 2d 66 6f 72 63 65  lled, use -force
5cc0: 20 74 6f 20 6c 61 75 6e 63 68 20 69 74 2e 22 29   to launch it.")
5cd0: 29 0a 09 28 28 4c 41 55 4e 43 48 45 44 20 52 45  )..((LAUNCHED RE
5ce0: 4d 4f 54 45 48 4f 53 54 53 54 41 52 54 20 52 55  MOTEHOSTSTART RU
5cf0: 4e 4e 49 4e 47 29 20 20 0a 09 20 28 69 66 20 28  NNING)  .. (if (
5d00: 3e 20 28 2d 20 28 63 75 72 72 65 6e 74 2d 73 65  > (- (current-se
5d10: 63 6f 6e 64 73 29 28 2b 20 28 64 62 3a 74 65 73  conds)(+ (db:tes
5d20: 74 2d 67 65 74 2d 65 76 65 6e 74 5f 74 69 6d 65  t-get-event_time
5d30: 20 74 65 73 74 64 61 74 29 0a 09 09 09 09 20 20   testdat).....  
5d40: 20 20 20 20 20 28 64 62 3a 74 65 73 74 2d 67 65       (db:test-ge
5d50: 74 2d 72 75 6e 5f 64 75 72 61 74 69 6f 6e 20 74  t-run_duration t
5d60: 65 73 74 64 61 74 29 29 29 0a 09 09 36 30 30 29  estdat)))...600)
5d70: 20 3b 3b 20 69 2e 65 2e 20 6e 6f 20 75 70 64 61   ;; i.e. no upda
5d80: 74 65 20 66 6f 72 20 6d 6f 72 65 20 74 68 61 6e  te for more than
5d90: 20 36 30 30 20 73 65 63 6f 6e 64 73 0a 09 20 20   600 seconds..  
5da0: 20 20 20 28 62 65 67 69 6e 0a 09 20 20 20 20 20     (begin..     
5db0: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30    (debug:print 0
5dc0: 20 22 57 41 52 4e 49 4e 47 3a 20 54 65 73 74 20   "WARNING: Test 
5dd0: 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 61 70  " test-name " ap
5de0: 70 65 61 72 73 20 74 6f 20 62 65 20 64 65 61 64  pears to be dead
5df0: 2e 20 46 6f 72 63 69 6e 67 20 69 74 20 74 6f 20  . Forcing it to 
5e00: 73 74 61 74 65 20 49 4e 43 4f 4d 50 4c 45 54 45  state INCOMPLETE
5e10: 20 61 6e 64 20 73 74 61 74 75 73 20 53 54 55 43   and status STUC
5e20: 4b 2f 44 45 41 44 22 29 0a 09 20 20 20 20 20 20  K/DEAD")..      
5e30: 20 28 74 65 73 74 2d 73 65 74 2d 73 74 61 74 75   (test-set-statu
5e40: 73 21 20 64 62 20 74 65 73 74 2d 69 64 20 22 49  s! db test-id "I
5e50: 4e 43 4f 4d 50 4c 45 54 45 22 20 22 53 54 55 43  NCOMPLETE" "STUC
5e60: 4b 2f 44 45 41 44 22 20 22 54 65 73 74 20 69 73  K/DEAD" "Test is
5e70: 20 73 74 75 63 6b 20 6f 72 20 64 65 61 64 22 20   stuck or dead" 
5e80: 23 66 29 29 0a 09 20 20 20 20 20 28 64 65 62 75  #f))..     (debu
5e90: 67 3a 70 72 69 6e 74 20 32 20 22 4e 4f 54 45 3a  g:print 2 "NOTE:
5ea0: 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 69   " test-name " i
5eb0: 73 20 61 6c 72 65 61 64 79 20 72 75 6e 6e 69 6e  s already runnin
5ec0: 67 22 29 29 29 0a 09 28 65 6c 73 65 20 20 20 20  g")))..(else    
5ed0: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
5ee0: 30 20 22 45 52 52 4f 52 3a 20 46 61 69 6c 65 64  0 "ERROR: Failed
5ef0: 20 74 6f 20 6c 61 75 6e 63 68 20 74 65 73 74 20   to launch test 
5f00: 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20  " new-test-name 
5f10: 22 2e 20 55 6e 72 65 63 6f 67 6e 69 73 65 64 20  ". Unrecognised 
5f20: 73 74 61 74 65 20 22 20 28 74 65 73 74 3a 67 65  state " (test:ge
5f30: 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 74 29  t-state testdat)
5f40: 29 29 29 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d  ))))))..;;======
5f50: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5f60: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5f70: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5f80: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5f90: 0a 3b 3b 20 45 4e 44 20 4f 46 20 4e 45 57 20 53  .;; END OF NEW S
5fa0: 54 55 46 46 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d  TUFF.;;=========
5fb0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5fc0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5fd0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5fe0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 28  =============..(
5ff0: 64 65 66 69 6e 65 20 28 67 65 74 2d 64 69 72 2d  define (get-dir-
6000: 75 70 2d 6e 20 64 69 72 20 2e 20 70 61 72 61 6d  up-n dir . param
6010: 73 29 20 0a 20 20 28 6c 65 74 20 28 28 64 70 61  s) .  (let ((dpa
6020: 72 74 73 20 20 28 73 74 72 69 6e 67 2d 73 70 6c  rts  (string-spl
6030: 69 74 20 64 69 72 20 22 2f 22 29 29 0a 09 28 63  it dir "/"))..(c
6040: 6f 75 6e 74 20 20 20 28 69 66 20 28 6e 75 6c 6c  ount   (if (null
6050: 3f 20 70 61 72 61 6d 73 29 20 31 20 28 63 61 72  ? params) 1 (car
6060: 20 70 61 72 61 6d 73 29 29 29 29 0a 20 20 20 20   params)))).    
6070: 28 63 6f 6e 63 20 22 2f 22 20 28 73 74 72 69 6e  (conc "/" (strin
6080: 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 0a 09  g-intersperse ..
6090: 20 20 20 20 20 20 20 28 74 61 6b 65 20 64 70 61         (take dpa
60a0: 72 74 73 20 28 2d 20 28 6c 65 6e 67 74 68 20 64  rts (- (length d
60b0: 70 61 72 74 73 29 20 63 6f 75 6e 74 29 29 0a 09  parts) count))..
60c0: 20 20 20 20 20 20 20 22 2f 22 29 29 29 29 0a 3b         "/")))).;
60d0: 3b 20 52 65 6d 6f 76 65 20 72 75 6e 73 0a 3b 3b  ; Remove runs.;;
60e0: 20 66 69 65 6c 64 73 20 61 72 65 20 70 61 73 73   fields are pass
60f0: 69 6e 67 20 69 6e 20 74 68 72 6f 75 67 68 20 0a  ing in through .
6100: 3b 3b 20 61 63 74 69 6f 6e 3a 0a 3b 3b 20 20 20  ;; action:.;;   
6110: 20 27 72 65 6d 6f 76 65 2d 72 75 6e 73 0a 3b 3b   'remove-runs.;;
6120: 20 20 20 20 27 73 65 74 2d 73 74 61 74 65 2d 73      'set-state-s
6130: 74 61 74 75 73 0a 3b 3b 0a 3b 3b 20 4e 42 2f 2f  tatus.;;.;; NB//
6140: 20 73 68 6f 75 6c 64 20 70 61 73 73 20 69 6e 20   should pass in 
6150: 6b 65 79 73 3f 0a 3b 3b 0a 28 64 65 66 69 6e 65  keys?.;;.(define
6160: 20 28 72 75 6e 73 3a 6f 70 65 72 61 74 65 2d 6f   (runs:operate-o
6170: 6e 20 64 62 20 61 63 74 69 6f 6e 20 72 75 6e 6e  n db action runn
6180: 61 6d 65 70 61 74 74 20 74 65 73 74 70 61 74 74  amepatt testpatt
6190: 20 69 74 65 6d 70 61 74 74 20 23 21 6b 65 79 20   itempatt #!key 
61a0: 28 73 74 61 74 65 20 23 66 29 28 73 74 61 74 75  (state #f)(statu
61b0: 73 20 23 66 29 28 6e 65 77 2d 73 74 61 74 65 2d  s #f)(new-state-
61c0: 73 74 61 74 75 73 20 23 66 29 29 0a 20 20 28 6c  status #f)).  (l
61d0: 65 74 2a 20 28 28 6b 65 79 73 20 20 20 20 20 20  et* ((keys      
61e0: 20 20 20 28 72 64 62 3a 67 65 74 2d 6b 65 79 73     (rdb:get-keys
61f0: 20 64 62 29 29 0a 09 20 28 72 75 6e 64 61 74 20   db)).. (rundat 
6200: 20 20 20 20 20 20 28 72 75 6e 73 3a 67 65 74 2d        (runs:get-
6210: 72 75 6e 73 2d 62 79 2d 70 61 74 74 20 64 62 20  runs-by-patt db 
6220: 6b 65 79 73 20 72 75 6e 6e 61 6d 65 70 61 74 74  keys runnamepatt
6230: 29 29 0a 09 20 28 68 65 61 64 65 72 20 20 20 20  )).. (header    
6240: 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20 72     (vector-ref r
6250: 75 6e 64 61 74 20 30 29 29 0a 09 20 28 72 75 6e  undat 0)).. (run
6260: 73 20 20 20 20 20 20 20 20 20 28 76 65 63 74 6f  s         (vecto
6270: 72 2d 72 65 66 20 72 75 6e 64 61 74 20 31 29 29  r-ref rundat 1))
6280: 0a 09 20 28 73 74 61 74 65 73 20 20 20 20 20 20  .. (states      
6290: 20 28 69 66 20 73 74 61 74 65 20 20 28 73 74 72   (if state  (str
62a0: 69 6e 67 2d 73 70 6c 69 74 20 73 74 61 74 65 20  ing-split state 
62b0: 20 22 2c 22 29 20 27 28 29 29 29 0a 09 20 28 73   ",") '())).. (s
62c0: 74 61 74 75 73 65 73 20 20 20 20 20 28 69 66 20  tatuses     (if 
62d0: 73 74 61 74 75 73 20 28 73 74 72 69 6e 67 2d 73  status (string-s
62e0: 70 6c 69 74 20 73 74 61 74 75 73 20 22 2c 22 29  plit status ",")
62f0: 20 27 28 29 29 29 0a 09 20 28 73 74 61 74 65 2d   '())).. (state-
6300: 73 74 61 74 75 73 20 28 69 66 20 28 73 74 72 69  status (if (stri
6310: 6e 67 3f 20 6e 65 77 2d 73 74 61 74 65 2d 73 74  ng? new-state-st
6320: 61 74 75 73 29 20 28 73 74 72 69 6e 67 2d 73 70  atus) (string-sp
6330: 6c 69 74 20 6e 65 77 2d 73 74 61 74 65 2d 73 74  lit new-state-st
6340: 61 74 75 73 20 22 2c 22 29 20 27 28 23 66 20 23  atus ",") '(#f #
6350: 66 29 29 29 29 0a 20 20 20 20 28 64 65 62 75 67  f)))).    (debug
6360: 3a 70 72 69 6e 74 20 32 20 22 48 65 61 64 65 72  :print 2 "Header
6370: 3a 20 22 20 68 65 61 64 65 72 20 22 20 61 63 74  : " header " act
6380: 69 6f 6e 3a 20 22 20 61 63 74 69 6f 6e 20 22 20  ion: " action " 
6390: 6e 65 77 2d 73 74 61 74 65 2d 73 74 61 74 75 73  new-state-status
63a0: 3a 20 22 20 6e 65 77 2d 73 74 61 74 65 2d 73 74  : " new-state-st
63b0: 61 74 75 73 29 0a 20 20 20 20 28 66 6f 72 2d 65  atus).    (for-e
63c0: 61 63 68 0a 20 20 20 20 20 28 6c 61 6d 62 64 61  ach.     (lambda
63d0: 20 28 72 75 6e 29 0a 20 20 20 20 20 20 20 28 6c   (run).       (l
63e0: 65 74 20 28 28 72 75 6e 6b 65 79 20 28 73 74 72  et ((runkey (str
63f0: 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20  ing-intersperse 
6400: 28 6d 61 70 20 28 6c 61 6d 62 64 61 20 28 6b 29  (map (lambda (k)
6410: 0a 09 09 09 09 09 09 28 64 62 3a 67 65 74 2d 76  .......(db:get-v
6420: 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72  alue-by-header r
6430: 75 6e 20 68 65 61 64 65 72 20 28 76 65 63 74 6f  un header (vecto
6440: 72 2d 72 65 66 20 6b 20 30 29 29 29 20 6b 65 79  r-ref k 0))) key
6450: 73 29 20 22 2f 22 29 29 0a 09 20 20 20 20 20 28  s) "/"))..     (
6460: 64 69 72 73 2d 74 6f 2d 72 65 6d 6f 76 65 20 28  dirs-to-remove (
6470: 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 29  make-hash-table)
6480: 29 29 0a 09 20 28 6c 65 74 2a 20 28 28 72 75 6e  )).. (let* ((run
6490: 2d 69 64 20 20 20 20 28 64 62 3a 67 65 74 2d 76  -id    (db:get-v
64a0: 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72  alue-by-header r
64b0: 75 6e 20 68 65 61 64 65 72 20 22 69 64 22 29 29  un header "id"))
64c0: 0a 09 09 28 72 75 6e 2d 73 74 61 74 65 20 28 64  ...(run-state (d
64d0: 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68  b:get-value-by-h
64e0: 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65 72  eader run header
64f0: 20 22 73 74 61 74 65 22 29 29 0a 09 09 28 74 65   "state"))...(te
6500: 73 74 73 20 20 20 20 20 28 69 66 20 28 6e 6f 74  sts     (if (not
6510: 20 28 65 71 75 61 6c 3f 20 72 75 6e 2d 73 74 61   (equal? run-sta
6520: 74 65 20 22 6c 6f 63 6b 65 64 22 29 29 0a 09 09  te "locked"))...
6530: 09 20 20 20 20 20 20 20 28 72 64 62 3a 67 65 74  .       (rdb:get
6540: 2d 74 65 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64  -tests-for-run d
6550: 62 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d  b (db:get-value-
6560: 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65  by-header run he
6570: 61 64 65 72 20 22 69 64 22 29 0a 09 09 09 09 09  ader "id")......
6580: 09 20 20 20 20 20 20 74 65 73 74 70 61 74 74 20  .      testpatt 
6590: 69 74 65 6d 70 61 74 74 20 73 74 61 74 65 73 20  itempatt states 
65a0: 73 74 61 74 75 73 65 73 0a 09 09 09 09 09 09 20  statuses....... 
65b0: 20 20 20 20 20 6e 6f 74 2d 69 6e 3a 20 20 23 66       not-in:  #f
65c0: 0a 09 09 09 09 09 09 20 20 20 20 20 20 73 6f 72  .......      sor
65d0: 74 2d 62 79 3a 20 28 63 61 73 65 20 61 63 74 69  t-by: (case acti
65e0: 6f 6e 0a 09 09 09 09 09 09 09 09 20 28 28 72 65  on......... ((re
65f0: 6d 6f 76 65 2d 72 75 6e 73 29 20 27 72 75 6e 64  move-runs) 'rund
6600: 69 72 29 0a 09 09 09 09 09 09 09 09 20 28 65 6c  ir)......... (el
6610: 73 65 20 20 20 20 20 20 20 20 20 20 27 65 76 65  se          'eve
6620: 6e 74 5f 74 69 6d 65 29 29 29 0a 09 09 09 20 20  nt_time)))....  
6630: 20 20 20 20 20 27 28 29 29 29 0a 09 09 28 6c 61       '()))...(la
6640: 73 74 74 70 61 74 68 20 22 2f 64 6f 65 73 2f 6e  sttpath "/does/n
6650: 6f 74 2f 65 78 69 73 74 2f 49 2f 68 6f 70 65 22  ot/exist/I/hope"
6660: 29 29 0a 0a 09 20 20 20 28 69 66 20 28 6e 6f 74  ))...   (if (not
6670: 20 28 6e 75 6c 6c 3f 20 74 65 73 74 73 29 29 0a   (null? tests)).
6680: 09 20 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09  .       (begin..
6690: 09 20 28 63 61 73 65 20 61 63 74 69 6f 6e 0a 09  . (case action..
66a0: 09 20 20 20 28 28 72 65 6d 6f 76 65 2d 72 75 6e  .   ((remove-run
66b0: 73 29 0a 09 09 20 20 20 20 28 64 65 62 75 67 3a  s)...    (debug:
66c0: 70 72 69 6e 74 20 31 20 22 52 65 6d 6f 76 69 6e  print 1 "Removin
66d0: 67 20 74 65 73 74 73 20 66 6f 72 20 72 75 6e 3a  g tests for run:
66e0: 20 22 20 72 75 6e 6b 65 79 20 22 20 22 20 28 64   " runkey " " (d
66f0: 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68  b:get-value-by-h
6700: 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65 72  eader run header
6710: 20 22 72 75 6e 6e 61 6d 65 22 29 29 29 0a 09 09   "runname")))...
6720: 20 20 20 28 28 73 65 74 2d 73 74 61 74 65 2d 73     ((set-state-s
6730: 74 61 74 75 73 29 0a 09 09 20 20 20 20 28 64 65  tatus)...    (de
6740: 62 75 67 3a 70 72 69 6e 74 20 31 20 22 4d 6f 64  bug:print 1 "Mod
6750: 69 66 79 69 6e 67 20 73 74 61 74 65 20 61 6e 64  ifying state and
6760: 20 73 74 61 75 73 20 66 6f 72 20 74 65 73 74 73   staus for tests
6770: 20 66 6f 72 20 72 75 6e 3a 20 22 20 72 75 6e 6b   for run: " runk
6780: 65 79 20 22 20 22 20 28 64 62 3a 67 65 74 2d 76  ey " " (db:get-v
6790: 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72  alue-by-header r
67a0: 75 6e 20 68 65 61 64 65 72 20 22 72 75 6e 6e 61  un header "runna
67b0: 6d 65 22 29 29 29 0a 09 09 20 20 20 28 65 6c 73  me")))...   (els
67c0: 65 0a 09 09 20 20 20 20 28 70 72 69 6e 74 20 22  e...    (print "
67d0: 49 4e 46 4f 3a 20 61 63 74 69 6f 6e 20 6e 6f 74  INFO: action not
67e0: 20 72 65 63 6f 67 6e 69 73 65 64 20 22 20 61 63   recognised " ac
67f0: 74 69 6f 6e 29 29 29 0a 09 09 20 28 66 6f 72 2d  tion)))... (for-
6800: 65 61 63 68 0a 09 09 20 20 28 6c 61 6d 62 64 61  each...  (lambda
6810: 20 28 74 65 73 74 29 0a 09 09 20 20 20 20 28 6c   (test)...    (l
6820: 65 74 2a 20 28 28 69 74 65 6d 2d 70 61 74 68 20  et* ((item-path 
6830: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65  (db:test-get-ite
6840: 6d 2d 70 61 74 68 20 74 65 73 74 29 29 0a 09 09  m-path test))...
6850: 09 20 20 20 28 74 65 73 74 2d 6e 61 6d 65 20 28  .   (test-name (
6860: 64 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74  db:test-get-test
6870: 6e 61 6d 65 20 74 65 73 74 29 29 0a 09 09 09 20  name test)).... 
6880: 20 20 28 72 75 6e 2d 64 69 72 20 20 20 28 64 62    (run-dir   (db
6890: 3a 74 65 73 74 2d 67 65 74 2d 72 75 6e 64 69 72  :test-get-rundir
68a0: 20 74 65 73 74 29 29 29 0a 09 09 20 20 20 20 20   test)))...     
68b0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20   (debug:print 1 
68c0: 22 20 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65  "  " (db:test-ge
68d0: 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 29  t-testname test)
68e0: 20 22 20 69 64 3a 20 22 20 28 64 62 3a 74 65 73   " id: " (db:tes
68f0: 74 2d 67 65 74 2d 69 64 20 74 65 73 74 29 20 22  t-get-id test) "
6900: 20 22 20 69 74 65 6d 2d 70 61 74 68 20 22 20 61   " item-path " a
6910: 63 74 69 6f 6e 3a 20 22 20 61 63 74 69 6f 6e 29  ction: " action)
6920: 0a 09 09 20 20 20 20 20 20 28 63 61 73 65 20 61  ...      (case a
6930: 63 74 69 6f 6e 0a 09 09 09 28 28 72 65 6d 6f 76  ction....((remov
6940: 65 2d 72 75 6e 73 29 0a 09 09 09 20 28 72 64 62  e-runs).... (rdb
6950: 3a 64 65 6c 65 74 65 2d 74 65 73 74 2d 72 65 63  :delete-test-rec
6960: 6f 72 64 73 20 64 62 20 28 64 62 3a 74 65 73 74  ords db (db:test
6970: 2d 67 65 74 2d 69 64 20 74 65 73 74 29 29 0a 09  -get-id test))..
6980: 09 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20  .. (debug:print 
6990: 31 20 22 49 4e 46 4f 3a 20 41 74 74 65 6d 70 74  1 "INFO: Attempt
69a0: 69 6e 67 20 74 6f 20 72 65 6d 6f 76 65 20 64 69  ing to remove di
69b0: 72 20 22 20 72 75 6e 2d 64 69 72 29 0a 09 09 09  r " run-dir)....
69c0: 20 28 69 66 20 28 61 6e 64 20 28 3e 20 28 73 74   (if (and (> (st
69d0: 72 69 6e 67 2d 6c 65 6e 67 74 68 20 72 75 6e 2d  ring-length run-
69e0: 64 69 72 29 20 35 29 0a 09 09 09 09 20 20 28 66  dir) 5).....  (f
69f0: 69 6c 65 2d 65 78 69 73 74 73 3f 20 72 75 6e 2d  ile-exists? run-
6a00: 64 69 72 29 29 20 3b 3b 20 62 61 64 20 68 65 75  dir)) ;; bad heu
6a10: 72 69 73 74 69 63 20 62 75 74 20 73 68 6f 75 6c  ristic but shoul
6a20: 64 20 70 72 65 76 65 6e 74 20 2f 74 6d 70 20 2f  d prevent /tmp /
6a30: 68 6f 6d 65 20 65 74 63 2e 0a 09 09 09 20 20 20  home etc.....   
6a40: 20 20 28 6c 65 74 2a 20 28 28 72 65 61 6c 70 61    (let* ((realpa
6a50: 74 68 20 28 72 65 73 6f 6c 76 65 2d 70 61 74 68  th (resolve-path
6a60: 6e 61 6d 65 20 72 75 6e 2d 64 69 72 29 29 29 0a  name run-dir))).
6a70: 09 09 09 20 20 20 20 20 20 20 28 64 65 62 75 67  ...       (debug
6a80: 3a 70 72 69 6e 74 20 31 20 22 49 4e 46 4f 3a 20  :print 1 "INFO: 
6a90: 52 65 61 6c 20 70 61 74 68 20 6f 66 20 69 73 20  Real path of is 
6aa0: 22 20 72 65 61 6c 70 61 74 68 29 0a 09 09 09 20  " realpath).... 
6ab0: 20 20 20 20 20 20 28 69 66 20 28 66 69 6c 65 2d        (if (file-
6ac0: 65 78 69 73 74 73 3f 20 72 65 61 6c 70 61 74 68  exists? realpath
6ad0: 29 0a 09 09 09 09 20 20 20 28 69 66 20 28 3e 20  ).....   (if (> 
6ae0: 28 73 79 73 74 65 6d 20 28 63 6f 6e 63 20 22 72  (system (conc "r
6af0: 6d 20 2d 72 66 20 22 20 72 65 61 6c 70 61 74 68  m -rf " realpath
6b00: 29 29 20 30 29 0a 09 09 09 09 20 20 20 20 20 20  )) 0).....      
6b10: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
6b20: 22 45 52 52 4f 52 3a 20 54 68 65 72 65 20 77 61  "ERROR: There wa
6b30: 73 20 61 20 70 72 6f 62 6c 65 6d 20 72 65 6d 6f  s a problem remo
6b40: 76 69 6e 67 20 22 20 72 65 61 6c 70 61 74 68 20  ving " realpath 
6b50: 22 20 77 69 74 68 20 72 6d 20 2d 66 22 29 29 0a  " with rm -f")).
6b60: 09 09 09 09 20 20 20 28 64 65 62 75 67 3a 70 72  ....   (debug:pr
6b70: 69 6e 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20  int 0 "WARNING: 
6b80: 74 65 73 74 20 72 75 6e 20 64 69 72 20 22 20 72  test run dir " r
6b90: 65 61 6c 70 61 74 68 20 22 20 61 70 70 65 61 72  ealpath " appear
6ba0: 73 20 74 6f 20 6e 6f 74 20 65 78 69 73 74 22 29  s to not exist")
6bb0: 29 0a 09 09 09 20 20 20 20 20 20 20 28 69 66 20  )....       (if 
6bc0: 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 72 75  (file-exists? ru
6bd0: 6e 2d 64 69 72 29 20 3b 3b 20 74 68 65 20 6c 69  n-dir) ;; the li
6be0: 6e 6b 0a 09 09 09 09 20 20 20 28 69 66 20 28 73  nk.....   (if (s
6bf0: 79 6d 62 6f 6c 69 63 2d 6c 69 6e 6b 3f 20 72 75  ymbolic-link? ru
6c00: 6e 2d 64 69 72 29 0a 09 09 09 09 20 20 20 20 20  n-dir).....     
6c10: 20 20 28 64 65 6c 65 74 65 2d 66 69 6c 65 20 72    (delete-file r
6c20: 75 6e 2d 64 69 72 29 0a 09 09 09 09 20 20 20 20  un-dir).....    
6c30: 20 20 20 28 69 66 20 28 64 69 72 65 63 74 6f 72     (if (director
6c40: 79 3f 20 72 75 6e 2d 64 69 72 29 0a 09 09 09 09  y? run-dir).....
6c50: 09 20 20 20 28 69 66 20 28 3e 20 28 64 69 72 65  .   (if (> (dire
6c60: 63 74 6f 72 79 2d 66 6f 6c 64 20 28 6c 61 6d 62  ctory-fold (lamb
6c70: 64 61 20 28 66 20 78 29 28 2b 20 31 20 78 29 29  da (f x)(+ 1 x))
6c80: 20 30 20 72 75 6e 2d 64 69 72 29 20 30 29 0a 09   0 run-dir) 0)..
6c90: 09 09 09 09 20 20 20 20 20 20 20 28 64 65 62 75  ....       (debu
6ca0: 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e 49  g:print 0 "WARNI
6cb0: 4e 47 3a 20 72 65 66 75 73 69 6e 67 20 74 6f 20  NG: refusing to 
6cc0: 72 65 6d 6f 76 65 20 22 20 72 75 6e 2d 64 69 72  remove " run-dir
6cd0: 20 22 20 61 73 20 69 74 20 69 73 20 6e 6f 74 20   " as it is not 
6ce0: 65 6d 70 74 79 22 29 0a 09 09 09 09 09 20 20 20  empty")......   
6cf0: 20 20 20 20 28 64 65 6c 65 74 65 2d 64 69 72 65      (delete-dire
6d00: 63 74 6f 72 79 20 72 75 6e 2d 64 69 72 29 29 20  ctory run-dir)) 
6d10: 3b 3b 20 69 74 20 73 68 6f 75 6c 64 20 62 65 20  ;; it should be 
6d20: 65 6d 70 74 79 20 62 79 20 68 65 72 65 20 42 55  empty by here BU
6d30: 47 20 42 55 47 2c 20 61 64 64 20 65 72 72 6f 72  G BUG, add error
6d40: 20 63 61 74 63 68 0a 09 09 09 09 09 20 20 20 28   catch......   (
6d50: 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45  debug:print 0 "E
6d60: 52 52 4f 52 3a 20 72 65 66 75 73 69 6e 67 20 74  RROR: refusing t
6d70: 6f 20 72 65 6d 6f 76 65 20 22 20 72 75 6e 2d 64  o remove " run-d
6d80: 69 72 20 22 20 61 73 20 69 74 20 69 73 20 6e 65  ir " as it is ne
6d90: 69 74 68 65 72 20 61 20 73 79 6d 6c 69 6e 6b 20  ither a symlink 
6da0: 6e 6f 72 20 61 20 64 69 72 65 63 74 6f 72 79 22  nor a directory"
6db0: 29 0a 09 09 09 09 09 20 20 20 29 29 29 29 0a 09  )......   ))))..
6dc0: 09 09 20 20 20 20 20 28 64 65 62 75 67 3a 70 72  ..     (debug:pr
6dd0: 69 6e 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20  int 0 "WARNING: 
6de0: 64 69 72 65 63 74 6f 72 79 20 61 6c 72 65 61 64  directory alread
6df0: 79 20 72 65 6d 6f 76 65 64 20 22 20 72 75 6e 2d  y removed " run-
6e00: 64 69 72 29 29 29 0a 09 09 09 28 28 73 65 74 2d  dir)))....((set-
6e10: 73 74 61 74 65 2d 73 74 61 74 75 73 29 0a 09 09  state-status)...
6e20: 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32  . (debug:print 2
6e30: 20 22 49 4e 46 4f 3a 20 6e 65 77 20 73 74 61 74   "INFO: new stat
6e40: 65 20 22 20 28 63 61 72 20 73 74 61 74 65 2d 73  e " (car state-s
6e50: 74 61 74 75 73 29 20 22 2c 20 6e 65 77 20 73 74  tatus) ", new st
6e60: 61 74 75 73 20 22 20 28 63 61 64 72 20 73 74 61  atus " (cadr sta
6e70: 74 65 2d 73 74 61 74 75 73 29 29 0a 09 09 09 20  te-status)).... 
6e80: 28 64 62 3a 74 65 73 74 2d 73 65 74 2d 73 74 61  (db:test-set-sta
6e90: 74 65 2d 73 74 61 74 75 73 2d 62 79 2d 69 64 20  te-status-by-id 
6ea0: 64 62 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  db (db:test-get-
6eb0: 69 64 20 74 65 73 74 29 20 28 63 61 72 20 73 74  id test) (car st
6ec0: 61 74 65 2d 73 74 61 74 75 73 29 28 63 61 64 72  ate-status)(cadr
6ed0: 20 73 74 61 74 65 2d 73 74 61 74 75 73 29 20 23   state-status) #
6ee0: 66 29 29 29 29 29 0a 09 09 20 20 74 65 73 74 73  f)))))...  tests
6ef0: 29 29 29 0a 09 20 20 20 0a 09 20 20 20 3b 3b 20  )))..   ..   ;; 
6f00: 72 65 6d 6f 76 65 20 74 68 65 20 72 75 6e 20 69  remove the run i
6f10: 66 20 7a 65 72 6f 20 74 65 73 74 73 20 72 65 6d  f zero tests rem
6f20: 61 69 6e 0a 09 20 20 20 28 69 66 20 28 65 71 3f  ain..   (if (eq?
6f30: 20 61 63 74 69 6f 6e 20 27 72 65 6d 6f 76 65 2d   action 'remove-
6f40: 72 75 6e 73 29 0a 09 20 20 20 20 20 20 20 28 6c  runs)..       (l
6f50: 65 74 20 28 28 72 65 6d 74 65 73 74 73 20 28 72  et ((remtests (r
6f60: 64 62 3a 67 65 74 2d 74 65 73 74 73 2d 66 6f 72  db:get-tests-for
6f70: 2d 72 75 6e 20 64 62 20 28 64 62 3a 67 65 74 2d  -run db (db:get-
6f80: 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20  value-by-header 
6f90: 72 75 6e 20 68 65 61 64 65 72 20 22 69 64 22 29  run header "id")
6fa0: 20 23 66 20 23 66 20 27 28 29 20 27 28 29 29 29   #f #f '() '()))
6fb0: 29 0a 09 09 20 28 69 66 20 28 6e 75 6c 6c 3f 20  )... (if (null? 
6fc0: 72 65 6d 74 65 73 74 73 29 20 3b 3b 20 6e 6f 20  remtests) ;; no 
6fd0: 6d 6f 72 65 20 74 65 73 74 73 20 72 65 6d 61 69  more tests remai
6fe0: 6e 69 6e 67 0a 09 09 20 20 20 20 20 28 6c 65 74  ning...     (let
6ff0: 2a 20 28 28 64 70 61 72 74 73 20 20 28 73 74 72  * ((dparts  (str
7000: 69 6e 67 2d 73 70 6c 69 74 20 6c 61 73 74 74 70  ing-split lasttp
7010: 61 74 68 20 22 2f 22 29 29 0a 09 09 09 20 20 20  ath "/"))....   
7020: 20 28 72 75 6e 70 61 74 68 20 28 63 6f 6e 63 20   (runpath (conc 
7030: 22 2f 22 20 28 73 74 72 69 6e 67 2d 69 6e 74 65  "/" (string-inte
7040: 72 73 70 65 72 73 65 20 0a 09 09 09 09 09 09 28  rsperse .......(
7050: 74 61 6b 65 20 64 70 61 72 74 73 20 28 2d 20 28  take dparts (- (
7060: 6c 65 6e 67 74 68 20 64 70 61 72 74 73 29 20 31  length dparts) 1
7070: 29 29 0a 09 09 09 09 09 09 22 2f 22 29 29 29 29  ))......."/"))))
7080: 0a 09 09 20 20 20 20 20 20 20 28 64 65 62 75 67  ...       (debug
7090: 3a 70 72 69 6e 74 20 31 20 22 52 65 6d 6f 76 69  :print 1 "Removi
70a0: 6e 67 20 72 75 6e 3a 20 22 20 72 75 6e 6b 65 79  ng run: " runkey
70b0: 20 22 20 22 20 28 64 62 3a 67 65 74 2d 76 61 6c   " " (db:get-val
70c0: 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e  ue-by-header run
70d0: 20 68 65 61 64 65 72 20 22 72 75 6e 6e 61 6d 65   header "runname
70e0: 22 29 29 0a 09 09 20 20 20 20 20 20 20 28 64 62  "))...       (db
70f0: 3a 64 65 6c 65 74 65 2d 72 75 6e 20 64 62 20 72  :delete-run db r
7100: 75 6e 2d 69 64 29 0a 09 09 20 20 20 20 20 20 20  un-id)...       
7110: 3b 3b 20 6e 65 65 64 20 74 6f 20 66 69 67 75 72  ;; need to figur
7120: 65 20 6f 75 74 20 74 68 65 20 70 61 74 68 20 74  e out the path t
7130: 6f 20 74 68 65 20 72 75 6e 20 64 69 72 20 61 6e  o the run dir an
7140: 64 20 72 65 6d 6f 76 65 20 69 74 20 69 66 20 65  d remove it if e
7150: 6d 70 74 79 0a 09 09 20 20 20 20 20 20 20 3b 3b  mpty...       ;;
7160: 20 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 28      (if (null? (
7170: 67 6c 6f 62 20 28 63 6f 6e 63 20 72 75 6e 70 61  glob (conc runpa
7180: 74 68 20 22 2f 2a 22 29 29 29 0a 09 09 20 20 20  th "/*")))...   
7190: 20 20 20 20 3b 3b 20 20 20 20 20 20 20 20 28 62      ;;        (b
71a0: 65 67 69 6e 0a 09 09 20 20 20 20 20 20 20 3b 3b  egin...       ;;
71b0: 20 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20   . (debug:print 
71c0: 31 20 22 52 65 6d 6f 76 69 6e 67 20 72 75 6e 20  1 "Removing run 
71d0: 64 69 72 20 22 20 72 75 6e 70 61 74 68 29 0a 09  dir " runpath)..
71e0: 09 20 20 20 20 20 20 20 3b 3b 20 09 20 28 73 79  .       ;; . (sy
71f0: 73 74 65 6d 20 28 63 6f 6e 63 20 22 72 6d 64 69  stem (conc "rmdi
7200: 72 20 2d 70 20 22 20 72 75 6e 70 61 74 68 29 29  r -p " runpath))
7210: 29 29 0a 09 09 20 20 20 20 20 20 20 29 29 29 29  ))...       ))))
7220: 29 0a 09 20 29 29 0a 20 20 20 20 20 72 75 6e 73  ).. )).     runs
7230: 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d  )))..;;=========
7240: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7250: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7260: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7270: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b  =============.;;
7280: 20 52 6f 75 74 69 6e 65 73 20 66 6f 72 20 6d 61   Routines for ma
7290: 6e 69 70 75 6c 61 74 69 6e 67 20 72 75 6e 73 0a  nipulating runs.
72a0: 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ;;==============
72b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
72c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
72d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
72e0: 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 53 69 6e  ========..;; Sin
72f0: 63 65 20 6d 61 6e 79 20 63 61 6c 6c 73 20 74 6f  ce many calls to
7300: 20 61 20 72 75 6e 20 72 65 71 75 69 72 65 20 70   a run require p
7310: 72 65 74 74 79 20 6d 75 63 68 20 74 68 65 20 73  retty much the s
7320: 61 6d 65 20 73 65 74 75 70 20 0a 3b 3b 20 74 68  ame setup .;; th
7330: 69 73 20 77 72 61 70 70 65 72 20 69 73 20 75 73  is wrapper is us
7340: 65 64 20 74 6f 20 72 65 64 75 63 65 20 74 68 65  ed to reduce the
7350: 20 72 65 70 6c 69 63 61 74 69 6f 6e 20 6f 66 20   replication of 
7360: 63 6f 64 65 0a 28 64 65 66 69 6e 65 20 28 67 65  code.(define (ge
7370: 6e 65 72 61 6c 2d 72 75 6e 2d 63 61 6c 6c 20 73  neral-run-call s
7380: 77 69 74 63 68 6e 61 6d 65 20 61 63 74 69 6f 6e  witchname action
7390: 2d 64 65 73 63 20 70 72 6f 63 29 0a 20 20 28 6c  -desc proc).  (l
73a0: 65 74 20 28 28 72 75 6e 6e 61 6d 65 20 28 61 72  et ((runname (ar
73b0: 67 73 3a 67 65 74 2d 61 72 67 20 22 3a 72 75 6e  gs:get-arg ":run
73c0: 6e 61 6d 65 22 29 29 0a 09 28 74 61 72 67 65 74  name"))..(target
73d0: 20 20 28 69 66 20 28 61 72 67 73 3a 67 65 74 2d    (if (args:get-
73e0: 61 72 67 20 22 2d 74 61 72 67 65 74 22 29 0a 09  arg "-target")..
73f0: 09 20 20 20 20 20 28 61 72 67 73 3a 67 65 74 2d  .     (args:get-
7400: 61 72 67 20 22 2d 74 61 72 67 65 74 22 29 0a 09  arg "-target")..
7410: 09 20 20 20 20 20 28 61 72 67 73 3a 67 65 74 2d  .     (args:get-
7420: 61 72 67 20 22 2d 72 65 71 74 61 72 67 22 29 29  arg "-reqtarg"))
7430: 29 0a 09 28 74 68 31 20 20 20 20 20 23 66 29 29  )..(th1     #f))
7440: 0a 20 20 20 20 28 63 6f 6e 64 0a 20 20 20 20 20  .    (cond.     
7450: 28 28 6e 6f 74 20 74 61 72 67 65 74 29 0a 20 20  ((not target).  
7460: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
7470: 20 30 20 22 45 52 52 4f 52 3a 20 4d 69 73 73 69   0 "ERROR: Missi
7480: 6e 67 20 72 65 71 75 69 72 65 64 20 70 61 72 61  ng required para
7490: 6d 65 74 65 72 20 66 6f 72 20 22 20 73 77 69 74  meter for " swit
74a0: 63 68 6e 61 6d 65 20 22 2c 20 79 6f 75 20 6d 75  chname ", you mu
74b0: 73 74 20 73 70 65 63 69 66 79 20 74 68 65 20 74  st specify the t
74c0: 61 72 67 65 74 20 77 69 74 68 20 2d 74 61 72 67  arget with -targ
74d0: 65 74 22 29 0a 20 20 20 20 20 20 28 65 78 69 74  et").      (exit
74e0: 20 33 29 29 0a 20 20 20 20 20 28 28 6e 6f 74 20   3)).     ((not 
74f0: 72 75 6e 6e 61 6d 65 29 0a 20 20 20 20 20 20 28  runname).      (
7500: 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45  debug:print 0 "E
7510: 52 52 4f 52 3a 20 4d 69 73 73 69 6e 67 20 72 65  RROR: Missing re
7520: 71 75 69 72 65 64 20 70 61 72 61 6d 65 74 65 72  quired parameter
7530: 20 66 6f 72 20 22 20 73 77 69 74 63 68 6e 61 6d   for " switchnam
7540: 65 20 22 2c 20 79 6f 75 20 6d 75 73 74 20 73 70  e ", you must sp
7550: 65 63 69 66 79 20 74 68 65 20 72 75 6e 20 6e 61  ecify the run na
7560: 6d 65 20 77 69 74 68 20 3a 72 75 6e 6e 61 6d 65  me with :runname
7570: 20 72 75 6e 6e 61 6d 65 22 29 0a 20 20 20 20 20   runname").     
7580: 20 28 65 78 69 74 20 33 29 29 0a 20 20 20 20 20   (exit 3)).     
7590: 28 65 6c 73 65 0a 20 20 20 20 20 20 28 6c 65 74  (else.      (let
75a0: 20 28 28 64 62 20 20 20 23 66 29 0a 09 20 20 20   ((db   #f)..   
75b0: 20 28 6b 65 79 73 20 23 66 29 29 0a 09 28 69 66   (keys #f))..(if
75c0: 20 28 6e 6f 74 20 28 73 65 74 75 70 2d 66 6f 72   (not (setup-for
75d0: 2d 72 75 6e 29 29 0a 09 20 20 20 20 28 62 65 67  -run))..    (beg
75e0: 69 6e 20 0a 09 20 20 20 20 20 20 28 64 65 62 75  in ..      (debu
75f0: 67 3a 70 72 69 6e 74 20 30 20 22 46 61 69 6c 65  g:print 0 "Faile
7600: 64 20 74 6f 20 73 65 74 75 70 2c 20 65 78 69 74  d to setup, exit
7610: 69 6e 67 22 29 0a 09 20 20 20 20 20 20 28 65 78  ing")..      (ex
7620: 69 74 20 31 29 29 29 0a 09 28 73 65 74 21 20 64  it 1)))..(set! d
7630: 62 20 20 20 28 6f 70 65 6e 2d 64 62 29 29 0a 09  b   (open-db))..
7640: 28 69 66 20 28 61 72 67 73 3a 67 65 74 2d 61 72  (if (args:get-ar
7650: 67 20 22 2d 73 65 72 76 65 72 22 29 0a 09 20 20  g "-server")..  
7660: 20 20 28 73 65 72 76 65 72 3a 73 74 61 72 74 20    (server:start 
7670: 64 62 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67  db (args:get-arg
7680: 20 22 2d 73 65 72 76 65 72 22 29 29 0a 09 20 20   "-server"))..  
7690: 20 20 28 69 66 20 28 6e 6f 74 20 28 6f 72 20 28    (if (not (or (
76a0: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72  args:get-arg "-r
76b0: 75 6e 61 6c 6c 22 29 0a 09 09 09 20 20 28 61 72  unall")....  (ar
76c0: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 75 6e  gs:get-arg "-run
76d0: 74 65 73 74 73 22 29 29 29 0a 09 09 28 73 65 72  tests")))...(ser
76e0: 76 65 72 3a 63 6c 69 65 6e 74 2d 73 65 74 75 70  ver:client-setup
76f0: 20 64 62 29 29 29 0a 09 28 73 65 74 21 20 6b 65   db)))..(set! ke
7700: 79 73 20 28 72 64 62 3a 67 65 74 2d 6b 65 79 73  ys (rdb:get-keys
7710: 20 64 62 29 29 0a 09 3b 3b 20 68 61 76 65 20 65   db))..;; have e
7720: 6e 6f 75 67 68 20 74 6f 20 70 72 6f 63 65 73 73  nough to process
7730: 20 2d 74 61 72 67 65 74 20 6f 72 20 2d 72 65 71   -target or -req
7740: 74 61 72 67 20 68 65 72 65 0a 09 28 69 66 20 28  targ here..(if (
7750: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72  args:get-arg "-r
7760: 65 71 74 61 72 67 22 29 0a 09 20 20 20 20 28 6c  eqtarg")..    (l
7770: 65 74 2a 20 28 28 72 75 6e 63 6f 6e 66 69 67 66  et* ((runconfigf
7780: 20 28 63 6f 6e 63 20 20 2a 74 6f 70 70 61 74 68   (conc  *toppath
7790: 2a 20 22 2f 72 75 6e 63 6f 6e 66 69 67 73 2e 63  * "/runconfigs.c
77a0: 6f 6e 66 69 67 22 29 29 20 3b 3b 20 44 4f 20 4e  onfig")) ;; DO N
77b0: 4f 54 20 45 56 41 4c 55 41 54 45 20 41 4c 4c 20  OT EVALUATE ALL 
77c0: 0a 09 09 20 20 20 28 72 75 6e 63 6f 6e 66 69 67  ...   (runconfig
77d0: 20 20 28 72 65 61 64 2d 63 6f 6e 66 69 67 20 72    (read-config r
77e0: 75 6e 63 6f 6e 66 69 67 66 20 23 66 20 23 66 20  unconfigf #f #f 
77f0: 65 6e 76 69 72 6f 6e 2d 70 61 74 74 3a 20 23 66  environ-patt: #f
7800: 29 29 29 20 0a 09 20 20 20 20 20 20 28 69 66 20  ))) ..      (if 
7810: 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f  (hash-table-ref/
7820: 64 65 66 61 75 6c 74 20 72 75 6e 63 6f 6e 66 69  default runconfi
7830: 67 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20  g (args:get-arg 
7840: 22 2d 72 65 71 74 61 72 67 22 29 20 23 66 29 0a  "-reqtarg") #f).
7850: 09 09 20 20 28 6b 65 79 73 3a 74 61 72 67 65 74  ..  (keys:target
7860: 2d 73 65 74 2d 61 72 67 73 20 6b 65 79 73 20 28  -set-args keys (
7870: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72  args:get-arg "-r
7880: 65 71 74 61 72 67 22 29 20 61 72 67 73 3a 61 72  eqtarg") args:ar
7890: 67 2d 68 61 73 68 29 0a 09 09 20 20 28 62 65 67  g-hash)...  (beg
78a0: 69 6e 0a 09 09 20 20 20 20 28 64 65 62 75 67 3a  in...    (debug:
78b0: 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20  print 0 "ERROR: 
78c0: 5b 22 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67  [" (args:get-arg
78d0: 20 22 2d 72 65 71 74 61 72 67 22 29 20 22 5d 20   "-reqtarg") "] 
78e0: 6e 6f 74 20 66 6f 75 6e 64 20 69 6e 20 22 20 72  not found in " r
78f0: 75 6e 63 6f 6e 66 69 67 66 29 0a 09 09 20 20 20  unconfigf)...   
7900: 20 28 73 71 6c 69 74 65 33 3a 66 69 6e 61 6c 69   (sqlite3:finali
7910: 7a 65 21 20 64 62 29 0a 09 09 20 20 20 20 28 65  ze! db)...    (e
7920: 78 69 74 20 31 29 29 29 29 0a 09 20 20 20 20 28  xit 1))))..    (
7930: 69 66 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67  if (args:get-arg
7940: 20 22 2d 74 61 72 67 65 74 22 29 0a 09 09 28 6b   "-target")...(k
7950: 65 79 73 3a 74 61 72 67 65 74 2d 73 65 74 2d 61  eys:target-set-a
7960: 72 67 73 20 6b 65 79 73 20 28 61 72 67 73 3a 67  rgs keys (args:g
7970: 65 74 2d 61 72 67 20 22 2d 74 61 72 67 65 74 22  et-arg "-target"
7980: 20 61 72 67 73 3a 61 72 67 2d 68 61 73 68 29 20   args:arg-hash) 
7990: 61 72 67 73 3a 61 72 67 2d 68 61 73 68 29 29 29  args:arg-hash)))
79a0: 0a 09 28 69 66 20 28 6e 6f 74 20 28 63 61 72 20  ..(if (not (car 
79b0: 2a 63 6f 6e 66 69 67 69 6e 66 6f 2a 29 29 0a 09  *configinfo*))..
79c0: 20 20 20 20 28 62 65 67 69 6e 0a 09 20 20 20 20      (begin..    
79d0: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30    (debug:print 0
79e0: 20 22 45 52 52 4f 52 3a 20 41 74 74 65 6d 70 74   "ERROR: Attempt
79f0: 65 64 20 74 6f 20 22 20 61 63 74 69 6f 6e 2d 64  ed to " action-d
7a00: 65 73 63 20 22 20 62 75 74 20 72 75 6e 20 61 72  esc " but run ar
7a10: 65 61 20 63 6f 6e 66 69 67 20 66 69 6c 65 20 6e  ea config file n
7a20: 6f 74 20 66 6f 75 6e 64 22 29 0a 09 20 20 20 20  ot found")..    
7a30: 20 20 28 65 78 69 74 20 31 29 29 0a 09 20 20 20    (exit 1))..   
7a40: 20 3b 3b 20 45 78 74 72 61 63 74 20 6f 75 74 20   ;; Extract out 
7a50: 73 74 75 66 66 20 6e 65 65 64 65 64 20 69 6e 20  stuff needed in 
7a60: 6d 6f 73 74 20 6f 72 20 6d 61 6e 79 20 63 61 6c  most or many cal
7a70: 6c 73 0a 09 20 20 20 20 3b 3b 20 68 65 72 65 20  ls..    ;; here 
7a80: 74 68 65 6e 20 63 61 6c 6c 20 70 72 6f 63 0a 09  then call proc..
7a90: 20 20 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 6e      (let* ((keyn
7aa0: 61 6d 65 73 20 20 20 28 6d 61 70 20 6b 65 79 3a  ames   (map key:
7ab0: 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65  get-fieldname ke
7ac0: 79 73 29 29 0a 09 09 20 20 20 28 6b 65 79 76 61  ys))...   (keyva
7ad0: 6c 6c 73 74 20 20 28 6b 65 79 73 2d 3e 76 61 6c  llst  (keys->val
7ae0: 6c 69 73 74 20 6b 65 79 73 20 23 74 29 29 29 0a  list keys #t))).
7af0: 09 20 20 20 20 20 20 28 70 72 6f 63 20 64 62 20  .      (proc db 
7b00: 74 61 72 67 65 74 20 72 75 6e 6e 61 6d 65 20 6b  target runname k
7b10: 65 79 73 20 6b 65 79 6e 61 6d 65 73 20 6b 65 79  eys keynames key
7b20: 76 61 6c 6c 73 74 29 29 29 0a 09 28 69 66 20 74  vallst)))..(if t
7b30: 68 31 20 28 74 68 72 65 61 64 2d 6a 6f 69 6e 21  h1 (thread-join!
7b40: 20 74 68 31 29 29 0a 09 28 73 71 6c 69 74 65 33   th1))..(sqlite3
7b50: 3a 66 69 6e 61 6c 69 7a 65 21 20 64 62 29 0a 09  :finalize! db)..
7b60: 28 73 65 74 21 20 2a 64 69 64 73 6f 6d 65 74 68  (set! *didsometh
7b70: 69 6e 67 2a 20 23 74 29 29 29 29 29 29 0a 0a 3b  ing* #t))))))..;
7b80: 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ;===============
7b90: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7ba0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7bb0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7bc0: 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 4c 6f 63 6b 2f  =======.;; Lock/
7bd0: 75 6e 6c 6f 63 6b 20 72 75 6e 73 0a 3b 3b 3d 3d  unlock runs.;;==
7be0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7bf0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7c00: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7c10: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7c20: 3d 3d 3d 3d 0a 0a 28 64 65 66 69 6e 65 20 28 72  ====..(define (r
7c30: 75 6e 73 3a 68 61 6e 64 6c 65 2d 6c 6f 63 6b 69  uns:handle-locki
7c40: 6e 67 20 64 62 20 74 61 72 67 65 74 20 6b 65 79  ng db target key
7c50: 73 20 72 75 6e 6e 61 6d 65 20 6c 6f 63 6b 20 75  s runname lock u
7c60: 6e 6c 6f 63 6b 20 75 73 65 72 29 0a 20 20 28 6c  nlock user).  (l
7c70: 65 74 2a 20 28 28 72 75 6e 64 61 74 20 20 20 28  et* ((rundat   (
7c80: 72 75 6e 73 3a 67 65 74 2d 72 75 6e 73 2d 62 79  runs:get-runs-by
7c90: 2d 70 61 74 74 20 64 62 20 6b 65 79 73 20 72 75  -patt db keys ru
7ca0: 6e 6e 61 6d 65 29 29 0a 09 20 28 68 65 61 64 65  nname)).. (heade
7cb0: 72 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20  r   (vector-ref 
7cc0: 72 75 6e 64 61 74 20 30 29 29 0a 09 20 28 72 75  rundat 0)).. (ru
7cd0: 6e 73 20 20 20 20 20 28 76 65 63 74 6f 72 2d 72  ns     (vector-r
7ce0: 65 66 20 72 75 6e 64 61 74 20 31 29 29 29 0a 20  ef rundat 1))). 
7cf0: 20 20 20 28 66 6f 72 2d 65 61 63 68 20 28 6c 61     (for-each (la
7d00: 6d 62 64 61 20 28 72 75 6e 29 0a 09 09 28 6c 65  mbda (run)...(le
7d10: 74 20 28 28 72 75 6e 2d 69 64 20 28 64 62 3a 67  t ((run-id (db:g
7d20: 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64  et-value-by-head
7d30: 65 72 20 72 75 6e 20 68 65 61 64 65 72 20 22 69  er run header "i
7d40: 64 22 29 29 29 0a 09 09 20 20 28 69 66 20 28 6f  d")))...  (if (o
7d50: 72 20 6c 6f 63 6b 0a 09 09 09 20 20 28 61 6e 64  r lock....  (and
7d60: 20 75 6e 6c 6f 63 6b 0a 09 09 09 20 20 20 20 20   unlock....     
7d70: 20 20 28 62 65 67 69 6e 0a 09 09 09 09 20 28 70    (begin..... (p
7d80: 72 69 6e 74 20 22 44 6f 20 79 6f 75 20 72 65 61  rint "Do you rea
7d90: 6c 6c 79 20 77 69 73 68 20 74 6f 20 75 6e 6c 6f  lly wish to unlo
7da0: 63 6b 20 72 75 6e 20 22 20 72 75 6e 2d 69 64 20  ck run " run-id 
7db0: 22 3f 5c 6e 20 20 20 79 2f 6e 3a 20 22 29 0a 09  "?\n   y/n: ")..
7dc0: 09 09 09 20 28 65 71 75 61 6c 3f 20 22 79 22 20  ... (equal? "y" 
7dd0: 28 72 65 61 64 2d 6c 69 6e 65 29 29 29 29 29 0a  (read-line))))).
7de0: 09 09 20 20 20 20 20 20 28 64 62 3a 6c 6f 63 6b  ..      (db:lock
7df0: 2f 75 6e 6c 6f 63 6b 2d 72 75 6e 20 64 62 20 72  /unlock-run db r
7e00: 75 6e 2d 69 64 20 6c 6f 63 6b 20 75 6e 6c 6f 63  un-id lock unloc
7e10: 6b 20 75 73 65 72 29 0a 09 09 20 20 20 20 20 20  k user)...      
7e20: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
7e30: 49 4e 46 4f 3a 20 53 6b 69 70 70 69 6e 67 20 6c  INFO: Skipping l
7e40: 6f 63 6b 2f 75 6e 6c 6f 63 6b 20 6f 6e 20 22 20  ock/unlock on " 
7e50: 72 75 6e 2d 69 64 29 29 29 29 0a 09 20 20 20 20  run-id))))..    
7e60: 20 20 72 75 6e 73 29 29 29 0a 3b 3b 3d 3d 3d 3d    runs))).;;====
7e70: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7e80: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7e90: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7ea0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7eb0: 3d 3d 0a 3b 3b 20 52 6f 6c 6c 75 70 20 72 75 6e  ==.;; Rollup run
7ec0: 73 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  s.;;============
7ed0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7ee0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7ef0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7f00: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 55  ==========..;; U
7f10: 70 64 61 74 65 20 74 68 65 20 74 65 73 74 5f 6d  pdate the test_m
7f20: 65 74 61 20 74 61 62 6c 65 20 66 6f 72 20 74 68  eta table for th
7f30: 69 73 20 74 65 73 74 0a 28 64 65 66 69 6e 65 20  is test.(define 
7f40: 28 72 75 6e 73 3a 75 70 64 61 74 65 2d 74 65 73  (runs:update-tes
7f50: 74 5f 6d 65 74 61 20 64 62 20 74 65 73 74 2d 6e  t_meta db test-n
7f60: 61 6d 65 20 74 65 73 74 2d 63 6f 6e 66 29 0a 20  ame test-conf). 
7f70: 20 28 6c 65 74 20 28 28 63 75 72 72 72 65 63 6f   (let ((currreco
7f80: 72 64 20 28 64 62 3a 74 65 73 74 6d 65 74 61 2d  rd (db:testmeta-
7f90: 67 65 74 2d 72 65 63 6f 72 64 20 64 62 20 74 65  get-record db te
7fa0: 73 74 2d 6e 61 6d 65 29 29 29 0a 20 20 20 20 28  st-name))).    (
7fb0: 69 66 20 28 6e 6f 74 20 63 75 72 72 72 65 63 6f  if (not currreco
7fc0: 72 64 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 28  rd)..(begin..  (
7fd0: 73 65 74 21 20 63 75 72 72 72 65 63 6f 72 64 20  set! currrecord 
7fe0: 28 6d 61 6b 65 2d 76 65 63 74 6f 72 20 31 30 20  (make-vector 10 
7ff0: 23 66 29 29 0a 09 20 20 28 64 62 3a 74 65 73 74  #f))..  (db:test
8000: 6d 65 74 61 2d 61 64 64 2d 72 65 63 6f 72 64 20  meta-add-record 
8010: 64 62 20 74 65 73 74 2d 6e 61 6d 65 29 29 29 0a  db test-name))).
8020: 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20      (for-each . 
8030: 20 20 20 20 28 6c 61 6d 62 64 61 20 28 6b 65 79      (lambda (key
8040: 29 0a 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28  ).       (let* (
8050: 28 69 64 78 20 28 63 61 64 72 20 6b 65 79 29 29  (idx (cadr key))
8060: 0a 09 20 20 20 20 20 20 28 66 6c 64 20 28 63 61  ..      (fld (ca
8070: 72 20 20 6b 65 79 29 29 0a 09 20 20 20 20 20 20  r  key))..      
8080: 28 76 61 6c 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f  (val (config-loo
8090: 6b 75 70 20 74 65 73 74 2d 63 6f 6e 66 20 22 74  kup test-conf "t
80a0: 65 73 74 5f 6d 65 74 61 22 20 66 6c 64 29 29 29  est_meta" fld)))
80b0: 0a 09 20 3b 3b 20 28 64 65 62 75 67 3a 70 72 69  .. ;; (debug:pri
80c0: 6e 74 20 35 20 22 69 64 78 3a 20 22 20 69 64 78  nt 5 "idx: " idx
80d0: 20 22 20 66 6c 64 3a 20 22 20 66 6c 64 20 22 20   " fld: " fld " 
80e0: 76 61 6c 3a 20 22 20 76 61 6c 29 0a 09 20 28 69  val: " val).. (i
80f0: 66 20 28 61 6e 64 20 76 61 6c 20 28 6e 6f 74 20  f (and val (not 
8100: 28 65 71 75 61 6c 3f 20 28 76 65 63 74 6f 72 2d  (equal? (vector-
8110: 72 65 66 20 63 75 72 72 72 65 63 6f 72 64 20 69  ref currrecord i
8120: 64 78 29 20 76 61 6c 29 29 29 0a 09 20 20 20 20  dx) val)))..    
8130: 20 28 62 65 67 69 6e 0a 09 20 20 20 20 20 20 20   (begin..       
8140: 28 70 72 69 6e 74 20 22 55 70 64 61 74 69 6e 67  (print "Updating
8150: 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 22   " test-name " "
8160: 20 66 6c 64 20 22 20 74 6f 20 22 20 76 61 6c 29   fld " to " val)
8170: 0a 09 20 20 20 20 20 20 20 28 64 62 3a 74 65 73  ..       (db:tes
8180: 74 6d 65 74 61 2d 75 70 64 61 74 65 2d 66 69 65  tmeta-update-fie
8190: 6c 64 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 20  ld db test-name 
81a0: 66 6c 64 20 76 61 6c 29 29 29 29 29 0a 20 20 20  fld val))))).   
81b0: 20 20 27 28 28 22 61 75 74 68 6f 72 22 20 32 29    '(("author" 2)
81c0: 28 22 6f 77 6e 65 72 22 20 33 29 28 22 64 65 73  ("owner" 3)("des
81d0: 63 72 69 70 74 69 6f 6e 22 20 34 29 28 22 72 65  cription" 4)("re
81e0: 76 69 65 77 65 64 22 20 35 29 28 22 74 61 67 73  viewed" 5)("tags
81f0: 22 20 39 29 29 29 29 29 0a 0a 3b 3b 20 55 70 64  " 9)))))..;; Upd
8200: 61 74 65 20 74 65 73 74 5f 6d 65 74 61 20 66 6f  ate test_meta fo
8210: 72 20 61 6c 6c 20 74 65 73 74 73 0a 28 64 65 66  r all tests.(def
8220: 69 6e 65 20 28 72 75 6e 73 3a 75 70 64 61 74 65  ine (runs:update
8230: 2d 61 6c 6c 2d 74 65 73 74 5f 6d 65 74 61 20 64  -all-test_meta d
8240: 62 29 0a 20 20 28 6c 65 74 20 28 28 74 65 73 74  b).  (let ((test
8250: 2d 6e 61 6d 65 73 20 28 67 65 74 2d 61 6c 6c 2d  -names (get-all-
8260: 6c 65 67 61 6c 2d 74 65 73 74 73 29 29 29 0a 20  legal-tests))). 
8270: 20 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 20     (for-each .  
8280: 20 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74     (lambda (test
8290: 2d 6e 61 6d 65 29 0a 20 20 20 20 20 20 20 28 6c  -name).       (l
82a0: 65 74 2a 20 28 28 74 65 73 74 2d 70 61 74 68 20  et* ((test-path 
82b0: 20 20 20 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74     (conc *toppat
82c0: 68 2a 20 22 2f 74 65 73 74 73 2f 22 20 74 65 73  h* "/tests/" tes
82d0: 74 2d 6e 61 6d 65 29 29 0a 09 20 20 20 20 20 20  t-name))..      
82e0: 28 74 65 73 74 2d 63 6f 6e 66 69 67 66 20 28 63  (test-configf (c
82f0: 6f 6e 63 20 74 65 73 74 2d 70 61 74 68 20 22 2f  onc test-path "/
8300: 74 65 73 74 63 6f 6e 66 69 67 22 29 29 0a 09 20  testconfig")).. 
8310: 20 20 20 20 20 28 74 65 73 74 65 78 69 73 74 73       (testexists
8320: 20 20 20 28 61 6e 64 20 28 66 69 6c 65 2d 65 78     (and (file-ex
8330: 69 73 74 73 3f 20 74 65 73 74 2d 63 6f 6e 66 69  ists? test-confi
8340: 67 66 29 28 66 69 6c 65 2d 72 65 61 64 2d 61 63  gf)(file-read-ac
8350: 63 65 73 73 3f 20 74 65 73 74 2d 63 6f 6e 66 69  cess? test-confi
8360: 67 66 29 29 29 0a 09 20 20 20 20 20 20 3b 3b 20  gf)))..      ;; 
8370: 72 65 61 64 20 63 6f 6e 66 69 67 73 20 77 69 74  read configs wit
8380: 68 20 74 72 69 63 6b 73 20 74 75 72 6e 65 64 20  h tricks turned 
8390: 6f 66 66 20 28 69 2e 65 2e 20 6e 6f 20 73 79 73  off (i.e. no sys
83a0: 74 65 6d 29 0a 09 20 20 20 20 20 20 28 74 65 73  tem)..      (tes
83b0: 74 2d 63 6f 6e 66 20 20 20 20 28 69 66 20 74 65  t-conf    (if te
83c0: 73 74 65 78 69 73 74 73 20 28 72 65 61 64 2d 63  stexists (read-c
83d0: 6f 6e 66 69 67 20 74 65 73 74 2d 63 6f 6e 66 69  onfig test-confi
83e0: 67 66 20 23 66 20 23 66 29 28 6d 61 6b 65 2d 68  gf #f #f)(make-h
83f0: 61 73 68 2d 74 61 62 6c 65 29 29 29 29 0a 09 20  ash-table)))).. 
8400: 28 72 75 6e 73 3a 75 70 64 61 74 65 2d 74 65 73  (runs:update-tes
8410: 74 5f 6d 65 74 61 20 64 62 20 74 65 73 74 2d 6e  t_meta db test-n
8420: 61 6d 65 20 74 65 73 74 2d 63 6f 6e 66 29 29 29  ame test-conf)))
8430: 0a 20 20 20 20 20 74 65 73 74 2d 6e 61 6d 65 73  .     test-names
8440: 29 29 29 0a 0a 3b 3b 20 54 68 69 73 20 63 6f 75  )))..;; This cou
8450: 6c 64 20 70 72 6f 62 61 62 6c 79 20 62 65 20 72  ld probably be r
8460: 65 66 61 63 74 6f 72 65 64 20 69 6e 74 6f 20 6f  efactored into o
8470: 6e 65 20 63 6f 6d 70 6c 65 78 20 71 75 65 72 79  ne complex query
8480: 20 2e 2e 2e 0a 28 64 65 66 69 6e 65 20 28 72 75   ....(define (ru
8490: 6e 73 3a 72 6f 6c 6c 75 70 2d 72 75 6e 20 64 62  ns:rollup-run db
84a0: 20 6b 65 79 73 20 6b 65 79 76 61 6c 6c 73 74 20   keys keyvallst 
84b0: 72 75 6e 6e 61 6d 65 20 75 73 65 72 29 20 3b 3b  runname user) ;;
84c0: 20 77 61 73 20 74 61 72 67 65 74 2c 20 6e 6f 77   was target, now
84d0: 20 6b 65 79 76 61 6c 6c 73 74 0a 20 20 28 64 65   keyvallst.  (de
84e0: 62 75 67 3a 70 72 69 6e 74 20 34 20 22 72 75 6e  bug:print 4 "run
84f0: 73 3a 72 6f 6c 6c 75 70 2d 72 75 6e 2c 20 6b 65  s:rollup-run, ke
8500: 79 73 3a 20 22 20 6b 65 79 73 20 22 20 6b 65 79  ys: " keys " key
8510: 76 61 6c 6c 73 74 3a 20 22 20 6b 65 79 76 61 6c  vallst: " keyval
8520: 6c 73 74 20 22 20 3a 72 75 6e 6e 61 6d 65 20 22  lst " :runname "
8530: 20 72 75 6e 6e 61 6d 65 20 22 20 75 73 65 72 3a   runname " user:
8540: 20 22 20 75 73 65 72 29 0a 20 20 28 6c 65 74 2a   " user).  (let*
8550: 20 28 3b 20 28 6b 65 79 76 61 6c 6c 6c 73 74 20   (; (keyvalllst 
8560: 20 20 20 20 20 28 6b 65 79 73 3a 74 61 72 67 65       (keys:targe
8570: 74 2d 3e 6b 65 79 76 61 6c 20 6b 65 79 73 20 74  t->keyval keys t
8580: 61 72 67 65 74 29 29 0a 09 20 28 6e 65 77 2d 72  arget)).. (new-r
8590: 75 6e 2d 69 64 20 20 20 20 20 20 28 72 75 6e 73  un-id      (runs
85a0: 3a 72 65 67 69 73 74 65 72 2d 72 75 6e 20 64 62  :register-run db
85b0: 20 6b 65 79 73 20 6b 65 79 76 61 6c 6c 73 74 20   keys keyvallst 
85c0: 72 75 6e 6e 61 6d 65 20 22 6e 65 77 22 20 22 6e  runname "new" "n
85d0: 2f 61 22 20 75 73 65 72 29 29 0a 09 20 28 70 72  /a" user)).. (pr
85e0: 65 76 2d 74 65 73 74 73 20 20 20 20 20 20 28 74  ev-tests      (t
85f0: 65 73 74 3a 67 65 74 2d 6d 61 74 63 68 69 6e 67  est:get-matching
8600: 2d 70 72 65 76 69 6f 75 73 2d 74 65 73 74 2d 72  -previous-test-r
8610: 75 6e 2d 72 65 63 6f 72 64 73 20 64 62 20 6e 65  un-records db ne
8620: 77 2d 72 75 6e 2d 69 64 20 22 25 22 20 22 25 22  w-run-id "%" "%"
8630: 29 29 0a 09 20 28 63 75 72 72 2d 74 65 73 74 73  )).. (curr-tests
8640: 20 20 20 20 20 20 28 72 64 62 3a 67 65 74 2d 74        (rdb:get-t
8650: 65 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20  ests-for-run db 
8660: 6e 65 77 2d 72 75 6e 2d 69 64 20 22 25 22 20 22  new-run-id "%" "
8670: 25 22 20 27 28 29 20 27 28 29 29 29 0a 09 20 28  %" '() '())).. (
8680: 63 75 72 72 2d 74 65 73 74 73 2d 68 61 73 68 20  curr-tests-hash 
8690: 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65  (make-hash-table
86a0: 29 29 29 0a 20 20 20 20 28 64 62 3a 75 70 64 61  ))).    (db:upda
86b0: 74 65 2d 72 75 6e 2d 65 76 65 6e 74 5f 74 69 6d  te-run-event_tim
86c0: 65 20 64 62 20 6e 65 77 2d 72 75 6e 2d 69 64 29  e db new-run-id)
86d0: 0a 20 20 20 20 3b 3b 20 69 6e 64 65 78 20 74 68  .    ;; index th
86e0: 65 20 61 6c 72 65 61 64 79 20 73 61 76 65 64 20  e already saved 
86f0: 74 65 73 74 73 20 62 79 20 74 65 73 74 6e 61 6d  tests by testnam
8700: 65 20 61 6e 64 20 69 74 65 6d 64 61 74 20 69 6e  e and itemdat in
8710: 20 63 75 72 72 2d 74 65 73 74 73 2d 68 61 73 68   curr-tests-hash
8720: 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 0a 20  .    (for-each. 
8730: 20 20 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73      (lambda (tes
8740: 74 64 61 74 29 0a 20 20 20 20 20 20 20 28 6c 65  tdat).       (le
8750: 74 2a 20 28 28 74 65 73 74 6e 61 6d 65 20 20 28  t* ((testname  (
8760: 64 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74  db:test-get-test
8770: 6e 61 6d 65 20 74 65 73 74 64 61 74 29 29 0a 09  name testdat))..
8780: 20 20 20 20 20 20 28 69 74 65 6d 2d 70 61 74 68        (item-path
8790: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74   (db:test-get-it
87a0: 65 6d 2d 70 61 74 68 20 74 65 73 74 64 61 74 29  em-path testdat)
87b0: 29 0a 09 20 20 20 20 20 20 28 66 75 6c 6c 2d 6e  )..      (full-n
87c0: 61 6d 65 20 28 63 6f 6e 63 20 74 65 73 74 6e 61  ame (conc testna
87d0: 6d 65 20 22 2f 22 20 69 74 65 6d 2d 70 61 74 68  me "/" item-path
87e0: 29 29 29 0a 09 20 28 68 61 73 68 2d 74 61 62 6c  ))).. (hash-tabl
87f0: 65 2d 73 65 74 21 20 63 75 72 72 2d 74 65 73 74  e-set! curr-test
8800: 73 2d 68 61 73 68 20 66 75 6c 6c 2d 6e 61 6d 65  s-hash full-name
8810: 20 74 65 73 74 64 61 74 29 29 29 0a 20 20 20 20   testdat))).    
8820: 20 63 75 72 72 2d 74 65 73 74 73 29 0a 20 20 20   curr-tests).   
8830: 20 3b 3b 20 4e 4f 50 45 3a 20 4e 6f 6e 2d 6f 70   ;; NOPE: Non-op
8840: 74 69 6d 61 6c 20 61 70 70 72 6f 61 63 68 2e 20  timal approach. 
8850: 54 72 79 20 74 68 69 73 20 69 6e 73 74 65 61 64  Try this instead
8860: 2e 0a 20 20 20 20 3b 3b 20 20 20 31 2e 20 74 65  ..    ;;   1. te
8870: 73 74 73 20 61 72 65 20 72 65 63 65 69 76 65 64  sts are received
8880: 20 69 6e 20 61 20 6c 69 73 74 2c 20 6d 6f 73 74   in a list, most
8890: 20 72 65 63 65 6e 74 20 66 69 72 73 74 0a 20 20   recent first.  
88a0: 20 20 3b 3b 20 20 20 32 2e 20 72 65 70 6c 61 63    ;;   2. replac
88b0: 65 20 74 68 65 20 72 6f 6c 6c 75 70 20 74 65 73  e the rollup tes
88c0: 74 20 77 69 74 68 20 74 68 65 20 6e 65 77 20 2a  t with the new *
88d0: 61 6c 77 61 79 73 2a 0a 20 20 20 20 28 66 6f 72  always*.    (for
88e0: 2d 65 61 63 68 20 0a 20 20 20 20 20 28 6c 61 6d  -each .     (lam
88f0: 62 64 61 20 28 74 65 73 74 64 61 74 29 0a 20 20  bda (testdat).  
8900: 20 20 20 20 20 28 6c 65 74 2a 20 28 28 74 65 73       (let* ((tes
8910: 74 6e 61 6d 65 20 20 28 64 62 3a 74 65 73 74 2d  tname  (db:test-
8920: 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73  get-testname tes
8930: 74 64 61 74 29 29 0a 09 20 20 20 20 20 20 28 69  tdat))..      (i
8940: 74 65 6d 2d 70 61 74 68 20 28 64 62 3a 74 65 73  tem-path (db:tes
8950: 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20  t-get-item-path 
8960: 74 65 73 74 64 61 74 29 29 0a 09 20 20 20 20 20  testdat))..     
8970: 20 28 66 75 6c 6c 2d 6e 61 6d 65 20 28 63 6f 6e   (full-name (con
8980: 63 20 74 65 73 74 6e 61 6d 65 20 22 2f 22 20 69  c testname "/" i
8990: 74 65 6d 2d 70 61 74 68 29 29 0a 09 20 20 20 20  tem-path))..    
89a0: 20 20 28 70 72 65 76 2d 74 65 73 74 2d 64 61 74    (prev-test-dat
89b0: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
89c0: 2f 64 65 66 61 75 6c 74 20 63 75 72 72 2d 74 65  /default curr-te
89d0: 73 74 73 2d 68 61 73 68 20 66 75 6c 6c 2d 6e 61  sts-hash full-na
89e0: 6d 65 20 23 66 29 29 0a 09 20 20 20 20 20 20 28  me #f))..      (
89f0: 74 65 73 74 2d 73 74 65 70 73 20 20 20 20 20 20  test-steps      
8a00: 28 64 62 3a 67 65 74 2d 73 74 65 70 73 2d 66 6f  (db:get-steps-fo
8a10: 72 2d 74 65 73 74 20 64 62 20 28 64 62 3a 74 65  r-test db (db:te
8a20: 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74 64 61  st-get-id testda
8a30: 74 29 29 29 0a 09 20 20 20 20 20 20 28 6e 65 77  t)))..      (new
8a40: 2d 74 65 73 74 2d 72 65 63 6f 72 64 20 23 66 29  -test-record #f)
8a50: 29 0a 09 20 3b 3b 20 72 65 70 6c 61 63 65 20 74  ).. ;; replace t
8a60: 68 65 73 65 20 77 69 74 68 20 69 6e 73 65 72 74  hese with insert
8a70: 20 2e 2e 2e 20 73 65 6c 65 63 74 0a 09 20 28 61   ... select.. (a
8a80: 70 70 6c 79 20 73 71 6c 69 74 65 33 3a 65 78 65  pply sqlite3:exe
8a90: 63 75 74 65 20 0a 09 09 64 62 20 0a 09 09 28 63  cute ...db ...(c
8aa0: 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f 52 20 52  onc "INSERT OR R
8ab0: 45 50 4c 41 43 45 20 49 4e 54 4f 20 74 65 73 74  EPLACE INTO test
8ac0: 73 20 28 72 75 6e 5f 69 64 2c 74 65 73 74 6e 61  s (run_id,testna
8ad0: 6d 65 2c 73 74 61 74 65 2c 73 74 61 74 75 73 2c  me,state,status,
8ae0: 65 76 65 6e 74 5f 74 69 6d 65 2c 68 6f 73 74 2c  event_time,host,
8af0: 63 70 75 6c 6f 61 64 2c 64 69 73 6b 66 72 65 65  cpuload,diskfree
8b00: 2c 75 6e 61 6d 65 2c 72 75 6e 64 69 72 2c 69 74  ,uname,rundir,it
8b10: 65 6d 5f 70 61 74 68 2c 72 75 6e 5f 64 75 72 61  em_path,run_dura
8b20: 74 69 6f 6e 2c 66 69 6e 61 6c 5f 6c 6f 67 66 2c  tion,final_logf,
8b30: 63 6f 6d 6d 65 6e 74 29 20 22 0a 09 09 20 20 20  comment) "...   
8b40: 20 20 20 22 56 41 4c 55 45 53 20 28 3f 2c 3f 2c     "VALUES (?,?,
8b50: 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c  ?,?,?,?,?,?,?,?,
8b60: 3f 2c 3f 2c 3f 2c 3f 29 3b 22 29 0a 09 09 6e 65  ?,?,?,?);")...ne
8b70: 77 2d 72 75 6e 2d 69 64 20 28 63 64 64 72 20 28  w-run-id (cddr (
8b80: 76 65 63 74 6f 72 2d 3e 6c 69 73 74 20 74 65 73  vector->list tes
8b90: 74 64 61 74 29 29 29 0a 09 20 28 73 65 74 21 20  tdat))).. (set! 
8ba0: 6e 65 77 2d 74 65 73 74 64 61 74 20 28 63 61 72  new-testdat (car
8bb0: 20 28 72 64 62 3a 67 65 74 2d 74 65 73 74 73 2d   (rdb:get-tests-
8bc0: 66 6f 72 2d 72 75 6e 20 64 62 20 6e 65 77 2d 72  for-run db new-r
8bd0: 75 6e 2d 69 64 20 74 65 73 74 6e 61 6d 65 20 69  un-id testname i
8be0: 74 65 6d 2d 70 61 74 68 20 27 28 29 20 27 28 29  tem-path '() '()
8bf0: 29 29 29 0a 09 20 28 68 61 73 68 2d 74 61 62 6c  ))).. (hash-tabl
8c00: 65 2d 73 65 74 21 20 63 75 72 72 2d 74 65 73 74  e-set! curr-test
8c10: 73 2d 68 61 73 68 20 66 75 6c 6c 2d 6e 61 6d 65  s-hash full-name
8c20: 20 6e 65 77 2d 74 65 73 74 64 61 74 29 20 3b 3b   new-testdat) ;;
8c30: 20 74 68 69 73 20 63 6f 75 6c 64 20 62 65 20 63   this could be c
8c40: 6f 6e 66 75 73 69 6e 67 2c 20 77 68 69 63 68 20  onfusing, which 
8c50: 72 65 63 6f 72 64 20 73 68 6f 75 6c 64 20 67 6f  record should go
8c60: 20 69 6e 74 6f 20 74 68 65 20 6c 6f 6f 6b 75 70   into the lookup
8c70: 20 74 61 62 6c 65 3f 0a 09 20 3b 3b 20 4e 6f 77   table?.. ;; Now
8c80: 20 64 75 70 6c 69 63 61 74 65 20 74 68 65 20 74   duplicate the t
8c90: 65 73 74 20 73 74 65 70 73 0a 09 20 28 64 65 62  est steps.. (deb
8ca0: 75 67 3a 70 72 69 6e 74 20 34 20 22 43 6f 70 79  ug:print 4 "Copy
8cb0: 69 6e 67 20 72 65 63 6f 72 64 73 20 69 6e 20 74  ing records in t
8cc0: 65 73 74 5f 73 74 65 70 73 20 66 72 6f 6d 20 74  est_steps from t
8cd0: 65 73 74 5f 69 64 3d 22 20 28 64 62 3a 74 65 73  est_id=" (db:tes
8ce0: 74 2d 67 65 74 2d 69 64 20 74 65 73 74 64 61 74  t-get-id testdat
8cf0: 29 20 22 20 74 6f 20 22 20 28 64 62 3a 74 65 73  ) " to " (db:tes
8d00: 74 2d 67 65 74 2d 69 64 20 6e 65 77 2d 74 65 73  t-get-id new-tes
8d10: 74 64 61 74 29 29 0a 09 20 28 73 71 6c 69 74 65  tdat)).. (sqlite
8d20: 33 3a 65 78 65 63 75 74 65 20 0a 09 20 20 64 62  3:execute ..  db
8d30: 20 0a 09 20 20 28 63 6f 6e 63 20 22 49 4e 53 45   ..  (conc "INSE
8d40: 52 54 20 4f 52 20 52 45 50 4c 41 43 45 20 49 4e  RT OR REPLACE IN
8d50: 54 4f 20 74 65 73 74 5f 73 74 65 70 73 20 28 74  TO test_steps (t
8d60: 65 73 74 5f 69 64 2c 73 74 65 70 6e 61 6d 65 2c  est_id,stepname,
8d70: 73 74 61 74 65 2c 73 74 61 74 75 73 2c 65 76 65  state,status,eve
8d80: 6e 74 5f 74 69 6d 65 2c 63 6f 6d 6d 65 6e 74 29  nt_time,comment)
8d90: 20 22 0a 09 09 22 53 45 4c 45 43 54 20 22 20 28   "..."SELECT " (
8da0: 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 6e  db:test-get-id n
8db0: 65 77 2d 74 65 73 74 64 61 74 29 20 22 2c 73 74  ew-testdat) ",st
8dc0: 65 70 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 61  epname,state,sta
8dd0: 74 75 73 2c 65 76 65 6e 74 5f 74 69 6d 65 2c 63  tus,event_time,c
8de0: 6f 6d 6d 65 6e 74 20 46 52 4f 4d 20 74 65 73 74  omment FROM test
8df0: 5f 73 74 65 70 73 20 57 48 45 52 45 20 74 65 73  _steps WHERE tes
8e00: 74 5f 69 64 3d 3f 3b 22 29 0a 09 20 20 28 64 62  t_id=?;")..  (db
8e10: 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73  :test-get-id tes
8e20: 74 64 61 74 29 29 0a 09 20 3b 3b 20 4e 6f 77 20  tdat)).. ;; Now 
8e30: 64 75 70 6c 69 63 61 74 65 20 74 68 65 20 74 65  duplicate the te
8e40: 73 74 20 64 61 74 61 0a 09 20 28 64 65 62 75 67  st data.. (debug
8e50: 3a 70 72 69 6e 74 20 34 20 22 43 6f 70 79 69 6e  :print 4 "Copyin
8e60: 67 20 72 65 63 6f 72 64 73 20 69 6e 20 74 65 73  g records in tes
8e70: 74 5f 64 61 74 61 20 66 72 6f 6d 20 74 65 73 74  t_data from test
8e80: 5f 69 64 3d 22 20 28 64 62 3a 74 65 73 74 2d 67  _id=" (db:test-g
8e90: 65 74 2d 69 64 20 74 65 73 74 64 61 74 29 20 22  et-id testdat) "
8ea0: 20 74 6f 20 22 20 28 64 62 3a 74 65 73 74 2d 67   to " (db:test-g
8eb0: 65 74 2d 69 64 20 6e 65 77 2d 74 65 73 74 64 61  et-id new-testda
8ec0: 74 29 29 0a 09 20 28 73 71 6c 69 74 65 33 3a 65  t)).. (sqlite3:e
8ed0: 78 65 63 75 74 65 20 0a 09 20 20 64 62 20 0a 09  xecute ..  db ..
8ee0: 20 20 28 63 6f 6e 63 20 22 49 4e 53 45 52 54 20    (conc "INSERT 
8ef0: 4f 52 20 52 45 50 4c 41 43 45 20 49 4e 54 4f 20  OR REPLACE INTO 
8f00: 74 65 73 74 5f 64 61 74 61 20 28 74 65 73 74 5f  test_data (test_
8f10: 69 64 2c 63 61 74 65 67 6f 72 79 2c 76 61 72 69  id,category,vari
8f20: 61 62 6c 65 2c 76 61 6c 75 65 2c 65 78 70 65 63  able,value,expec
8f30: 74 65 64 2c 74 6f 6c 2c 75 6e 69 74 73 2c 63 6f  ted,tol,units,co
8f40: 6d 6d 65 6e 74 29 20 22 0a 09 09 22 53 45 4c 45  mment) "..."SELE
8f50: 43 54 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65  CT " (db:test-ge
8f60: 74 2d 69 64 20 6e 65 77 2d 74 65 73 74 64 61 74  t-id new-testdat
8f70: 29 20 22 2c 63 61 74 65 67 6f 72 79 2c 76 61 72  ) ",category,var
8f80: 69 61 62 6c 65 2c 76 61 6c 75 65 2c 65 78 70 65  iable,value,expe
8f90: 63 74 65 64 2c 74 6f 6c 2c 75 6e 69 74 73 2c 63  cted,tol,units,c
8fa0: 6f 6d 6d 65 6e 74 20 46 52 4f 4d 20 74 65 73 74  omment FROM test
8fb0: 5f 64 61 74 61 20 57 48 45 52 45 20 74 65 73 74  _data WHERE test
8fc0: 5f 69 64 3d 3f 3b 22 29 0a 09 20 20 28 64 62 3a  _id=?;")..  (db:
8fd0: 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74  test-get-id test
8fe0: 64 61 74 29 29 0a 09 20 29 29 0a 20 20 20 20 20  dat)).. )).     
8ff0: 70 72 65 76 2d 74 65 73 74 73 29 29 29 0a 09 20  prev-tests))).. 
9000: 0a 20 20 20 20 20 0a                             .     .