Megatest

Hex Artifact Content
Login

Artifact ad5fa6c5533454ab07b823a0391988557e197978:


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 28 64 65 66 69 6e 65 20 28 73 65 74 2d 6d  ..(define (set-m
0870: 65 67 61 74 65 73 74 2d 65 6e 76 2d 76 61 72 73  egatest-env-vars
0880: 20 64 62 20 72 75 6e 2d 69 64 29 0a 20 20 28 6c   db run-id).  (l
0890: 65 74 20 28 28 6b 65 79 73 20 28 64 62 3a 67 65  et ((keys (db:ge
08a0: 74 2d 6b 65 79 73 20 64 62 29 29 29 0a 20 20 20  t-keys db))).   
08b0: 20 28 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62   (for-each (lamb
08c0: 64 61 20 28 6b 65 79 29 0a 09 09 28 73 71 6c 69  da (key)...(sqli
08d0: 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77  te3:for-each-row
08e0: 0a 09 09 20 28 6c 61 6d 62 64 61 20 28 76 61 6c  ... (lambda (val
08f0: 29 0a 09 09 20 20 20 28 64 65 62 75 67 3a 70 72  )...   (debug:pr
0900: 69 6e 74 20 32 20 22 73 65 74 65 6e 76 20 22 20  int 2 "setenv " 
0910: 28 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64 6e 61  (key:get-fieldna
0920: 6d 65 20 6b 65 79 29 20 22 20 22 20 76 61 6c 29  me key) " " val)
0930: 0a 09 09 20 20 20 28 73 65 74 65 6e 76 20 28 6b  ...   (setenv (k
0940: 65 79 3a 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65  ey:get-fieldname
0950: 20 6b 65 79 29 20 76 61 6c 29 29 0a 09 09 20 64   key) val))... d
0960: 62 20 0a 09 09 20 28 63 6f 6e 63 20 22 53 45 4c  b ... (conc "SEL
0970: 45 43 54 20 22 20 28 6b 65 79 3a 67 65 74 2d 66  ECT " (key:get-f
0980: 69 65 6c 64 6e 61 6d 65 20 6b 65 79 29 20 22 20  ieldname key) " 
0990: 46 52 4f 4d 20 72 75 6e 73 20 57 48 45 52 45 20  FROM runs WHERE 
09a0: 69 64 3d 3f 3b 22 29 0a 09 09 20 72 75 6e 2d 69  id=?;")... run-i
09b0: 64 29 29 0a 09 20 20 20 20 20 20 6b 65 79 73 29  d))..      keys)
09c0: 0a 20 20 20 20 28 61 6c 69 73 74 2d 3e 65 6e 76  .    (alist->env
09d0: 2d 76 61 72 73 20 28 68 61 73 68 2d 74 61 62 6c  -vars (hash-tabl
09e0: 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 2a 63  e-ref/default *c
09f0: 6f 6e 66 69 67 64 61 74 2a 20 22 65 6e 76 2d 6f  onfigdat* "env-o
0a00: 76 65 72 72 69 64 65 22 20 27 28 29 29 29 0a 20  verride" '())). 
0a10: 20 20 20 3b 3b 20 4c 65 74 73 20 75 73 65 20 74     ;; Lets use t
0a20: 68 69 73 20 61 73 20 61 6e 20 6f 70 70 6f 72 74  his as an opport
0a30: 75 6e 69 74 79 20 74 6f 20 70 75 74 20 4d 54 5f  unity to put MT_
0a40: 52 55 4e 4e 41 4d 45 20 69 6e 20 74 68 65 20 65  RUNNAME in the e
0a50: 6e 76 69 72 6f 6e 6d 65 6e 74 0a 20 20 20 20 28  nvironment.    (
0a60: 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68  sqlite3:for-each
0a70: 2d 72 6f 77 0a 20 20 20 20 20 28 6c 61 6d 62 64  -row.     (lambd
0a80: 61 20 28 72 75 6e 6e 61 6d 65 29 0a 20 20 20 20  a (runname).    
0a90: 20 20 20 28 73 65 74 65 6e 76 20 22 4d 54 5f 52     (setenv "MT_R
0aa0: 55 4e 4e 41 4d 45 22 20 72 75 6e 6e 61 6d 65 29  UNNAME" runname)
0ab0: 29 0a 20 20 20 20 20 64 62 0a 20 20 20 20 20 22  ).     db.     "
0ac0: 53 45 4c 45 43 54 20 72 75 6e 6e 61 6d 65 20 46  SELECT runname F
0ad0: 52 4f 4d 20 72 75 6e 73 20 57 48 45 52 45 20 69  ROM runs WHERE i
0ae0: 64 3d 3f 3b 22 0a 20 20 20 20 20 72 75 6e 2d 69  d=?;".     run-i
0af0: 64 29 0a 20 20 20 20 29 29 0a 0a 28 64 65 66 69  d).    ))..(defi
0b00: 6e 65 20 28 73 65 74 2d 69 74 65 6d 2d 65 6e 76  ne (set-item-env
0b10: 2d 76 61 72 73 20 69 74 65 6d 64 61 74 29 0a 20  -vars itemdat). 
0b20: 20 28 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62   (for-each (lamb
0b30: 64 61 20 28 69 74 65 6d 29 0a 09 20 20 20 20 20  da (item)..     
0b40: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20   (debug:print 2 
0b50: 22 73 65 74 65 6e 76 20 22 20 28 63 61 72 20 69  "setenv " (car i
0b60: 74 65 6d 29 20 22 20 22 20 28 63 61 64 72 20 69  tem) " " (cadr i
0b70: 74 65 6d 29 29 0a 09 20 20 20 20 20 20 28 73 65  tem))..      (se
0b80: 74 65 6e 76 20 28 63 61 72 20 69 74 65 6d 29 20  tenv (car item) 
0b90: 28 63 61 64 72 20 69 74 65 6d 29 29 29 0a 09 20  (cadr item))).. 
0ba0: 20 20 20 69 74 65 6d 64 61 74 29 29 0a 0a 28 64     itemdat))..(d
0bb0: 65 66 69 6e 65 20 28 72 75 6e 73 3a 63 61 6e 2d  efine (runs:can-
0bc0: 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64  run-more-tests d
0bd0: 62 20 74 65 73 74 2d 72 65 63 6f 72 64 29 0a 20  b test-record). 
0be0: 20 28 6c 65 74 2a 20 28 28 74 63 6f 6e 66 69 67   (let* ((tconfig
0bf0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0c00: 20 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75   (tests:testqueu
0c10: 65 2d 67 65 74 2d 74 65 73 74 63 6f 6e 66 69 67  e-get-testconfig
0c20: 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29 0a 09   test-record))..
0c30: 20 28 6a 6f 62 67 72 6f 75 70 20 20 20 20 20 20   (jobgroup      
0c40: 20 20 20 20 20 20 20 20 20 20 28 63 6f 6e 66 69            (confi
0c50: 67 2d 6c 6f 6f 6b 75 70 20 74 63 6f 6e 66 69 67  g-lookup tconfig
0c60: 20 22 72 65 71 75 69 72 65 6d 65 6e 74 73 22 20   "requirements" 
0c70: 22 6a 6f 62 67 72 6f 75 70 22 29 29 0a 09 20 28  "jobgroup")).. (
0c80: 6e 75 6d 2d 72 75 6e 6e 69 6e 67 20 20 20 20 20  num-running     
0c90: 20 20 20 20 20 20 20 20 28 64 62 3a 67 65 74 2d          (db:get-
0ca0: 63 6f 75 6e 74 2d 74 65 73 74 73 2d 72 75 6e 6e  count-tests-runn
0cb0: 69 6e 67 20 64 62 29 29 0a 09 20 28 6e 75 6d 2d  ing db)).. (num-
0cc0: 72 75 6e 6e 69 6e 67 2d 69 6e 2d 6a 6f 62 67 72  running-in-jobgr
0cd0: 6f 75 70 20 28 64 62 3a 67 65 74 2d 63 6f 75 6e  oup (db:get-coun
0ce0: 74 2d 74 65 73 74 73 2d 72 75 6e 6e 69 6e 67 2d  t-tests-running-
0cf0: 69 6e 2d 6a 6f 62 67 72 6f 75 70 20 64 62 20 6a  in-jobgroup db j
0d00: 6f 62 67 72 6f 75 70 29 29 0a 09 20 28 6d 61 78  obgroup)).. (max
0d10: 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73  -concurrent-jobs
0d20: 20 20 20 20 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f       (config-loo
0d30: 6b 75 70 20 2a 63 6f 6e 66 69 67 64 61 74 2a 20  kup *configdat* 
0d40: 22 73 65 74 75 70 22 20 20 20 20 20 22 6d 61 78  "setup"     "max
0d50: 5f 63 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f 62 73  _concurrent_jobs
0d60: 22 29 29 0a 09 20 28 6a 6f 62 2d 67 72 6f 75 70  ")).. (job-group
0d70: 2d 6c 69 6d 69 74 20 20 20 20 20 20 20 20 20 28  -limit         (
0d80: 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 2a 63  config-lookup *c
0d90: 6f 6e 66 69 67 64 61 74 2a 20 22 6a 6f 62 67 72  onfigdat* "jobgr
0da0: 6f 75 70 73 22 20 6a 6f 62 67 72 6f 75 70 29 29  oups" jobgroup))
0db0: 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72 69  ).    (debug:pri
0dc0: 6e 74 20 32 20 22 6d 61 78 2d 63 6f 6e 63 75 72  nt 2 "max-concur
0dd0: 72 65 6e 74 2d 6a 6f 62 73 3a 20 22 20 6d 61 78  rent-jobs: " max
0de0: 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73  -concurrent-jobs
0df0: 20 22 2c 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67 3a   ", num-running:
0e00: 20 22 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67 29 0a   " num-running).
0e10: 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28 65 71      (if (not (eq
0e20: 3f 20 30 20 2a 67 6c 6f 62 61 6c 65 78 69 74 73  ? 0 *globalexits
0e30: 74 61 74 75 73 2a 29 29 0a 09 23 66 0a 09 28 6c  tatus*))..#f..(l
0e40: 65 74 20 28 28 63 61 6e 2d 6e 6f 74 2d 72 75 6e  et ((can-not-run
0e50: 2d 6d 6f 72 65 20 28 63 6f 6e 64 0a 09 09 09 09  -more (cond.....
0e60: 20 3b 3b 20 69 66 20 6d 61 78 2d 63 6f 6e 63 75   ;; if max-concu
0e70: 72 72 65 6e 74 2d 6a 6f 62 73 20 69 73 20 73 65  rrent-jobs is se
0e80: 74 20 61 6e 64 20 74 68 65 20 6e 75 6d 62 65 72  t and the number
0e90: 20 72 75 6e 6e 69 6e 67 20 69 73 20 67 72 65 61   running is grea
0ea0: 74 65 72 20 0a 09 09 09 09 20 3b 3b 20 74 68 61  ter ..... ;; tha
0eb0: 6e 20 69 74 20 74 68 61 6e 20 63 61 6e 6e 6f 74  n it than cannot
0ec0: 20 72 75 6e 20 6d 6f 72 65 20 6a 6f 62 73 0a 09   run more jobs..
0ed0: 09 09 09 20 28 28 61 6e 64 20 6d 61 78 2d 63 6f  ... ((and max-co
0ee0: 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 0a 09 09  ncurrent-jobs...
0ef0: 09 09 20 20 20 20 20 20 20 28 73 74 72 69 6e 67  ..       (string
0f00: 2d 3e 6e 75 6d 62 65 72 20 6d 61 78 2d 63 6f 6e  ->number max-con
0f10: 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29 0a 09 09  current-jobs)...
0f20: 09 09 20 20 20 20 20 20 20 28 3e 3d 20 6e 75 6d  ..       (>= num
0f30: 2d 72 75 6e 6e 69 6e 67 20 28 73 74 72 69 6e 67  -running (string
0f40: 2d 3e 6e 75 6d 62 65 72 20 6d 61 78 2d 63 6f 6e  ->number max-con
0f50: 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29 29 29 0a  current-jobs))).
0f60: 09 09 09 09 20 20 28 64 65 62 75 67 3a 70 72 69  ....  (debug:pri
0f70: 6e 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 4d  nt 0 "WARNING: M
0f80: 61 78 20 72 75 6e 6e 69 6e 67 20 6a 6f 62 73 20  ax running jobs 
0f90: 65 78 63 65 65 64 65 64 2c 20 63 75 72 72 65 6e  exceeded, curren
0fa0: 74 20 6e 75 6d 62 65 72 20 72 75 6e 6e 69 6e 67  t number running
0fb0: 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67 20  : " num-running 
0fc0: 0a 09 09 09 09 09 20 20 20 20 20 20 20 22 2c 20  ......       ", 
0fd0: 6d 61 78 5f 63 6f 6e 63 75 72 72 65 6e 74 5f 6a  max_concurrent_j
0fe0: 6f 62 73 3a 20 22 20 6d 61 78 2d 63 6f 6e 63 75  obs: " max-concu
0ff0: 72 72 65 6e 74 2d 6a 6f 62 73 29 0a 09 09 09 09  rrent-jobs).....
1000: 20 20 23 74 29 0a 09 09 09 09 20 3b 3b 20 69 66    #t)..... ;; if
1010: 20 6a 6f 62 2d 67 72 6f 75 70 2d 6c 69 6d 69 74   job-group-limit
1020: 20 69 73 20 73 65 74 20 61 6e 64 20 6e 75 6d 62   is set and numb
1030: 65 72 20 6f 66 20 6a 6f 62 73 20 69 6e 20 74 68  er of jobs in th
1040: 65 20 67 72 6f 75 70 20 69 73 20 67 72 65 61 74  e group is great
1050: 65 72 0a 09 09 09 09 20 3b 3b 20 74 68 61 6e 20  er..... ;; than 
1060: 74 68 65 20 6c 69 6d 69 74 20 74 68 65 6e 20 63  the limit then c
1070: 61 6e 6e 6f 74 20 72 75 6e 20 6d 6f 72 65 20 6a  annot run more j
1080: 6f 62 73 20 6f 66 20 74 68 69 73 20 6b 69 6e 64  obs of this kind
1090: 0a 09 09 09 09 20 28 28 61 6e 64 20 6a 6f 62 2d  ..... ((and job-
10a0: 67 72 6f 75 70 2d 6c 69 6d 69 74 0a 09 09 09 09  group-limit.....
10b0: 20 20 20 20 20 20 20 28 3e 3d 20 6e 75 6d 2d 72         (>= num-r
10c0: 75 6e 6e 69 6e 67 2d 69 6e 2d 6a 6f 62 67 72 6f  unning-in-jobgro
10d0: 75 70 20 6a 6f 62 2d 67 72 6f 75 70 2d 6c 69 6d  up job-group-lim
10e0: 69 74 29 29 0a 09 09 09 09 20 20 28 64 65 62 75  it)).....  (debu
10f0: 67 3a 70 72 69 6e 74 20 31 20 22 57 41 52 4e 49  g:print 1 "WARNI
1100: 4e 47 3a 20 6e 75 6d 62 65 72 20 6f 66 20 6a 6f  NG: number of jo
1110: 62 73 20 22 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67  bs " num-running
1120: 2d 69 6e 2d 6a 6f 62 67 72 6f 75 70 20 0a 09 09  -in-jobgroup ...
1130: 09 09 09 20 20 20 20 20 20 20 22 20 69 6e 20 22  ...       " in "
1140: 20 6a 6f 62 67 72 6f 75 70 20 22 20 65 78 63 65   jobgroup " exce
1150: 65 64 65 64 2c 20 77 69 6c 6c 20 6e 6f 74 20 72  eded, will not r
1160: 75 6e 20 22 20 28 74 65 73 74 73 3a 74 65 73 74  un " (tests:test
1170: 71 75 65 75 65 2d 67 65 74 2d 74 65 73 74 6e 61  queue-get-testna
1180: 6d 65 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29  me test-record))
1190: 0a 09 09 09 09 20 20 23 74 29 0a 09 09 09 09 20  .....  #t)..... 
11a0: 28 65 6c 73 65 20 23 66 29 29 29 29 0a 09 20 20  (else #f))))..  
11b0: 28 6e 6f 74 20 63 61 6e 2d 6e 6f 74 2d 72 75 6e  (not can-not-run
11c0: 2d 6d 6f 72 65 29 29 29 29 29 0a 0a 3b 3b 3d 3d  -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 0a 3b 3b 20 4e 65 77 20 6d 65 74 68  ====.;; New meth
1220: 6f 64 6f 6c 6f 67 79 2e 20 54 68 65 73 65 20 72  odology. These r
1230: 6f 75 74 69 6e 65 73 20 77 69 6c 6c 20 72 65 70  outines will rep
1240: 6c 61 63 65 20 74 68 65 20 61 62 6f 76 65 20 69  lace the above i
1250: 6e 20 74 69 6d 65 2e 20 46 6f 72 0a 3b 3b 20 6e  n time. For.;; n
1260: 6f 77 20 74 68 65 20 63 6f 64 65 20 69 73 20 64  ow the code is d
1270: 75 70 6c 69 63 61 74 65 64 2e 20 54 68 69 73 20  uplicated. This 
1280: 73 74 75 66 66 20 69 73 20 69 6e 69 74 69 61 6c  stuff is initial
1290: 6c 79 20 75 73 65 64 20 69 6e 20 74 68 65 20 6d  ly used in the m
12a0: 6f 6e 69 74 6f 72 0a 3b 3b 20 62 61 73 65 64 20  onitor.;; based 
12b0: 63 6f 64 65 2e 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d  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 0a 0a  ==============..
1300: 3b 3b 20 72 65 67 69 73 74 65 72 20 61 20 74 65  ;; register a te
1310: 73 74 20 72 75 6e 20 77 69 74 68 20 74 68 65 20  st run with the 
1320: 64 62 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73  db.(define (runs
1330: 3a 72 65 67 69 73 74 65 72 2d 72 75 6e 20 64 62  :register-run db
1340: 20 6b 65 79 73 20 6b 65 79 76 61 6c 6c 73 74 20   keys keyvallst 
1350: 72 75 6e 6e 61 6d 65 20 73 74 61 74 65 20 73 74  runname state st
1360: 61 74 75 73 20 75 73 65 72 29 0a 20 20 28 64 65  atus user).  (de
1370: 62 75 67 3a 70 72 69 6e 74 20 33 20 22 72 75 6e  bug:print 3 "run
1380: 73 3a 72 65 67 69 73 74 65 72 2d 72 75 6e 2c 20  s:register-run, 
1390: 6b 65 79 73 3a 20 22 20 6b 65 79 73 20 22 20 6b  keys: " keys " k
13a0: 65 79 76 61 6c 6c 73 74 3a 20 22 20 6b 65 79 76  eyvallst: " keyv
13b0: 61 6c 6c 73 74 20 22 20 72 75 6e 6e 61 6d 65 3a  allst " runname:
13c0: 20 22 20 72 75 6e 6e 61 6d 65 20 22 20 73 74 61   " runname " sta
13d0: 74 65 3a 20 22 20 73 74 61 74 65 20 22 20 73 74  te: " state " st
13e0: 61 74 75 73 3a 20 22 20 73 74 61 74 75 73 20 22  atus: " status "
13f0: 20 75 73 65 72 3a 20 22 20 75 73 65 72 29 0a 20   user: " user). 
1400: 20 28 6c 65 74 2a 20 28 28 6b 65 79 73 74 72 20   (let* ((keystr 
1410: 20 20 20 28 6b 65 79 73 2d 3e 6b 65 79 73 74 72     (keys->keystr
1420: 20 6b 65 79 73 29 29 0a 09 20 28 63 6f 6d 6d 61   keys)).. (comma
1430: 20 20 20 20 20 28 69 66 20 28 3e 20 28 6c 65 6e       (if (> (len
1440: 67 74 68 20 6b 65 79 73 29 20 30 29 20 22 2c 22  gth keys) 0) ","
1450: 20 22 22 29 29 0a 09 20 28 61 6e 64 73 74 72 20   "")).. (andstr 
1460: 20 20 20 28 69 66 20 28 3e 20 28 6c 65 6e 67 74     (if (> (lengt
1470: 68 20 6b 65 79 73 29 20 30 29 20 22 20 41 4e 44  h keys) 0) " AND
1480: 20 22 20 22 22 29 29 0a 09 20 28 76 61 6c 73 6c   " "")).. (valsl
1490: 6f 74 73 20 20 28 6b 65 79 73 2d 3e 76 61 6c 73  ots  (keys->vals
14a0: 6c 6f 74 73 20 6b 65 79 73 29 29 20 3b 3b 20 3f  lots keys)) ;; ?
14b0: 2c 3f 2c 3f 20 2e 2e 2e 0a 09 20 28 6b 65 79 76  ,?,? ..... (keyv
14c0: 61 6c 73 20 20 20 28 6d 61 70 20 63 61 64 72 20  als   (map cadr 
14d0: 6b 65 79 76 61 6c 6c 73 74 29 29 0a 09 20 28 61  keyvallst)).. (a
14e0: 6c 6c 76 61 6c 73 20 20 20 28 61 70 70 65 6e 64  llvals   (append
14f0: 20 28 6c 69 73 74 20 72 75 6e 6e 61 6d 65 20 73   (list runname s
1500: 74 61 74 65 20 73 74 61 74 75 73 20 75 73 65 72  tate status user
1510: 29 20 6b 65 79 76 61 6c 73 29 29 0a 09 20 28 71  ) keyvals)).. (q
1520: 72 79 76 61 6c 73 20 20 20 28 61 70 70 65 6e 64  ryvals   (append
1530: 20 28 6c 69 73 74 20 72 75 6e 6e 61 6d 65 29 20   (list runname) 
1540: 6b 65 79 76 61 6c 73 29 29 0a 09 20 28 6b 65 79  keyvals)).. (key
1550: 3d 3f 73 74 72 20 20 28 73 74 72 69 6e 67 2d 69  =?str  (string-i
1560: 6e 74 65 72 73 70 65 72 73 65 20 28 6d 61 70 20  ntersperse (map 
1570: 28 6c 61 6d 62 64 61 20 28 6b 29 28 63 6f 6e 63  (lambda (k)(conc
1580: 20 28 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64 6e   (key:get-fieldn
1590: 61 6d 65 20 6b 29 20 22 3d 3f 22 29 29 20 6b 65  ame k) "=?")) ke
15a0: 79 73 29 20 22 20 41 4e 44 20 22 29 29 29 0a 20  ys) " AND "))). 
15b0: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
15c0: 33 20 22 6b 65 79 73 3a 20 22 20 6b 65 79 73 20  3 "keys: " keys 
15d0: 22 20 61 6c 6c 76 61 6c 73 3a 20 22 20 61 6c 6c  " allvals: " all
15e0: 76 61 6c 73 20 22 20 6b 65 79 76 61 6c 73 3a 20  vals " keyvals: 
15f0: 22 20 6b 65 79 76 61 6c 73 29 0a 20 20 20 20 28  " keyvals).    (
1600: 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 4e  debug:print 2 "N
1610: 4f 54 45 3a 20 75 73 69 6e 67 20 74 61 72 67 65  OTE: using targe
1620: 74 20 22 20 28 73 74 72 69 6e 67 2d 69 6e 74 65  t " (string-inte
1630: 72 73 70 65 72 73 65 20 6b 65 79 76 61 6c 73 20  rsperse keyvals 
1640: 22 2f 22 29 20 22 20 66 6f 72 20 74 68 69 73 20  "/") " for this 
1650: 72 75 6e 22 29 0a 20 20 20 20 28 69 66 20 28 61  run").    (if (a
1660: 6e 64 20 72 75 6e 6e 61 6d 65 20 28 6e 75 6c 6c  nd runname (null
1670: 3f 20 28 66 69 6c 74 65 72 20 28 6c 61 6d 62 64  ? (filter (lambd
1680: 61 20 28 78 29 28 6e 6f 74 20 78 29 29 20 6b 65  a (x)(not x)) ke
1690: 79 76 61 6c 73 29 29 29 20 3b 3b 20 74 68 65 72  yvals))) ;; ther
16a0: 65 20 6d 75 73 74 20 62 65 20 61 20 62 65 74 74  e must be a bett
16b0: 65 72 20 77 61 79 20 74 6f 20 22 61 70 70 6c 79  er way to "apply
16c0: 20 61 6e 64 22 0a 09 28 6c 65 74 20 28 28 72 65   and"..(let ((re
16d0: 73 20 23 66 29 29 0a 09 20 20 28 61 70 70 6c 79  s #f))..  (apply
16e0: 20 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65   sqlite3:execute
16f0: 20 64 62 20 28 63 6f 6e 63 20 22 49 4e 53 45 52   db (conc "INSER
1700: 54 20 4f 52 20 49 47 4e 4f 52 45 20 49 4e 54 4f  T OR IGNORE INTO
1710: 20 72 75 6e 73 20 28 72 75 6e 6e 61 6d 65 2c 73   runs (runname,s
1720: 74 61 74 65 2c 73 74 61 74 75 73 2c 6f 77 6e 65  tate,status,owne
1730: 72 2c 65 76 65 6e 74 5f 74 69 6d 65 22 20 63 6f  r,event_time" co
1740: 6d 6d 61 20 6b 65 79 73 74 72 20 22 29 20 56 41  mma keystr ") VA
1750: 4c 55 45 53 20 28 3f 2c 3f 2c 3f 2c 3f 2c 73 74  LUES (?,?,?,?,st
1760: 72 66 74 69 6d 65 28 27 25 73 27 2c 27 6e 6f 77  rftime('%s','now
1770: 27 29 22 20 63 6f 6d 6d 61 20 76 61 6c 73 6c 6f  ')" comma valslo
1780: 74 73 20 22 29 3b 22 29 0a 09 09 20 61 6c 6c 76  ts ");")... allv
1790: 61 6c 73 29 0a 09 20 20 28 61 70 70 6c 79 20 73  als)..  (apply s
17a0: 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d  qlite3:for-each-
17b0: 72 6f 77 20 0a 09 20 20 20 28 6c 61 6d 62 64 61  row ..   (lambda
17c0: 20 28 69 64 29 0a 09 20 20 20 20 20 28 73 65 74   (id)..     (set
17d0: 21 20 72 65 73 20 69 64 29 29 0a 09 20 20 20 64  ! res id))..   d
17e0: 62 0a 09 20 20 20 28 6c 65 74 20 28 28 71 72 79  b..   (let ((qry
17f0: 20 28 63 6f 6e 63 20 22 53 45 4c 45 43 54 20 69   (conc "SELECT i
1800: 64 20 46 52 4f 4d 20 72 75 6e 73 20 57 48 45 52  d FROM runs WHER
1810: 45 20 28 72 75 6e 6e 61 6d 65 3d 3f 20 22 20 61  E (runname=? " a
1820: 6e 64 73 74 72 20 6b 65 79 3d 3f 73 74 72 20 22  ndstr key=?str "
1830: 29 3b 22 29 29 29 0a 09 20 20 20 20 20 3b 28 64  );")))..     ;(d
1840: 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 71 72  ebug:print 4 "qr
1850: 79 3a 20 22 20 71 72 79 29 20 0a 09 20 20 20 20  y: " qry) ..    
1860: 20 71 72 79 29 0a 09 20 20 20 71 72 79 76 61 6c   qry)..   qryval
1870: 73 29 0a 09 20 20 28 73 71 6c 69 74 65 33 3a 65  s)..  (sqlite3:e
1880: 78 65 63 75 74 65 20 64 62 20 22 55 50 44 41 54  xecute db "UPDAT
1890: 45 20 72 75 6e 73 20 53 45 54 20 73 74 61 74 65  E runs SET state
18a0: 3d 3f 2c 73 74 61 74 75 73 3d 3f 20 57 48 45 52  =?,status=? WHER
18b0: 45 20 69 64 3d 3f 3b 22 20 73 74 61 74 65 20 73  E id=?;" state s
18c0: 74 61 74 75 73 20 72 65 73 29 0a 09 20 20 72 65  tatus res)..  re
18d0: 73 29 20 0a 09 28 62 65 67 69 6e 0a 09 20 20 28  s) ..(begin..  (
18e0: 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45  debug:print 0 "E
18f0: 52 52 4f 52 3a 20 43 61 6c 6c 65 64 20 77 69 74  RROR: Called wit
1900: 68 6f 75 74 20 61 6c 6c 20 6e 65 63 65 73 73 61  hout all necessa
1910: 72 79 20 6b 65 79 73 22 29 0a 09 20 20 23 66 29  ry keys")..  #f)
1920: 29 29 29 0a 0a 3b 3b 20 54 68 69 73 20 69 73 20  )))..;; This is 
1930: 61 20 64 75 70 6c 69 63 61 74 65 20 6f 66 20 72  a duplicate of r
1940: 75 6e 2d 74 65 73 74 73 20 28 77 68 69 63 68 20  un-tests (which 
1950: 68 61 73 20 62 65 65 6e 20 64 65 70 72 65 63 61  has been depreca
1960: 74 65 64 29 2e 20 55 73 65 20 74 68 69 73 20 6f  ted). Use this o
1970: 6e 65 20 69 6e 73 74 65 61 64 20 6f 66 20 72 75  ne instead of ru
1980: 6e 20 74 65 73 74 73 2e 0a 3b 3b 20 6b 65 79 76  n tests..;; keyv
1990: 61 6c 73 0a 28 64 65 66 69 6e 65 20 28 72 75 6e  als.(define (run
19a0: 73 3a 72 75 6e 2d 74 65 73 74 73 20 64 62 20 74  s:run-tests db t
19b0: 61 72 67 65 74 20 72 75 6e 6e 61 6d 65 20 74 65  arget runname te
19c0: 73 74 2d 70 61 74 74 73 20 75 73 65 72 20 66 6c  st-patts user fl
19d0: 61 67 73 29 0a 20 20 28 6c 65 74 2a 20 28 28 6b  ags).  (let* ((k
19e0: 65 79 73 20 20 20 20 20 20 20 20 28 72 64 62 3a  eys        (rdb:
19f0: 67 65 74 2d 6b 65 79 73 20 64 62 29 29 0a 09 20  get-keys db)).. 
1a00: 28 6b 65 79 76 61 6c 6c 73 74 20 20 20 28 6b 65  (keyvallst   (ke
1a10: 79 73 3a 74 61 72 67 65 74 2d 3e 6b 65 79 76 61  ys:target->keyva
1a20: 6c 20 6b 65 79 73 20 74 61 72 67 65 74 29 29 0a  l keys target)).
1a30: 09 20 28 72 75 6e 2d 69 64 20 20 20 20 20 20 28  . (run-id      (
1a40: 72 75 6e 73 3a 72 65 67 69 73 74 65 72 2d 72 75  runs:register-ru
1a50: 6e 20 64 62 20 6b 65 79 73 20 6b 65 79 76 61 6c  n db keys keyval
1a60: 6c 73 74 20 72 75 6e 6e 61 6d 65 20 22 6e 65 77  lst runname "new
1a70: 22 20 22 6e 2f 61 22 20 75 73 65 72 29 29 20 20  " "n/a" user))  
1a80: 3b 3b 20 20 74 65 73 74 2d 6e 61 6d 65 29 29 29  ;;  test-name)))
1a90: 0a 09 20 28 64 65 66 65 72 72 65 64 20 20 20 20  .. (deferred    
1aa0: 27 28 29 29 20 3b 3b 20 64 65 6c 61 79 20 72 75  '()) ;; delay ru
1ab0: 6e 6e 69 6e 67 20 74 68 65 73 65 20 73 69 6e 63  nning these sinc
1ac0: 65 20 74 68 65 79 20 68 61 76 65 20 61 20 77 61  e they have a wa
1ad0: 69 74 6f 6e 20 63 6c 61 75 73 65 0a 09 20 3b 3b  iton clause.. ;;
1ae0: 20 6b 65 65 70 67 6f 69 6e 67 20 69 73 20 74 68   keepgoing is th
1af0: 65 20 64 65 66 61 63 74 6f 20 6d 6f 64 61 6c 69  e defacto modali
1b00: 74 79 20 6e 6f 77 2c 20 77 69 6c 6c 20 61 64 64  ty now, will add
1b10: 20 68 69 74 2d 6e 2d 72 75 6e 20 61 20 62 69 74   hit-n-run a bit
1b20: 20 6c 61 74 65 72 0a 09 20 3b 3b 20 28 6b 65 65   later.. ;; (kee
1b30: 70 67 6f 69 6e 67 20 20 20 28 68 61 73 68 2d 74  pgoing   (hash-t
1b40: 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74  able-ref/default
1b50: 20 66 6c 61 67 73 20 22 2d 6b 65 65 70 67 6f 69   flags "-keepgoi
1b60: 6e 67 22 20 23 66 29 29 0a 09 20 28 74 65 73 74  ng" #f)).. (test
1b70: 2d 6e 61 6d 65 73 20 20 27 28 29 29 0a 09 20 28  -names  '()).. (
1b80: 72 75 6e 63 6f 6e 66 69 67 66 20 20 20 28 63 6f  runconfigf   (co
1b90: 6e 63 20 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f  nc  *toppath* "/
1ba0: 72 75 6e 63 6f 6e 66 69 67 73 2e 63 6f 6e 66 69  runconfigs.confi
1bb0: 67 22 29 29 0a 09 20 28 72 65 71 75 69 72 65 64  g")).. (required
1bc0: 2d 74 65 73 74 73 20 27 28 29 29 0a 09 20 28 74  -tests '()).. (t
1bd0: 65 73 74 2d 72 65 63 6f 72 64 73 20 28 6d 61 6b  est-records (mak
1be0: 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29 29 0a  e-hash-table))).
1bf0: 0a 20 20 20 20 28 73 65 74 2d 6d 65 67 61 74 65  .    (set-megate
1c00: 73 74 2d 65 6e 76 2d 76 61 72 73 20 64 62 20 72  st-env-vars db r
1c10: 75 6e 2d 69 64 29 20 3b 3b 20 74 68 65 73 65 20  un-id) ;; these 
1c20: 6d 61 79 20 62 65 20 6e 65 65 64 65 64 20 62 79  may be needed by
1c30: 20 74 68 65 20 6c 61 75 6e 63 68 69 6e 67 20 70   the launching p
1c40: 72 6f 63 65 73 73 0a 0a 20 20 20 20 28 69 66 20  rocess..    (if 
1c50: 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 72 75  (file-exists? ru
1c60: 6e 63 6f 6e 66 69 67 66 29 0a 09 28 73 65 74 75  nconfigf)..(setu
1c70: 70 2d 65 6e 76 2d 64 65 66 61 75 6c 74 73 20 64  p-env-defaults d
1c80: 62 20 72 75 6e 63 6f 6e 66 69 67 66 20 72 75 6e  b runconfigf run
1c90: 2d 69 64 20 2a 61 6c 72 65 61 64 79 2d 73 65 65  -id *already-see
1ca0: 6e 2d 72 75 6e 63 6f 6e 66 69 67 2d 69 6e 66 6f  n-runconfig-info
1cb0: 2a 20 22 70 72 65 2d 6c 61 75 6e 63 68 2d 65 6e  * "pre-launch-en
1cc0: 76 2d 76 61 72 73 22 29 0a 09 28 64 65 62 75 67  v-vars")..(debug
1cd0: 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e  :print 0 "WARNIN
1ce0: 47 3a 20 59 6f 75 20 64 6f 20 6e 6f 74 20 68 61  G: You do not ha
1cf0: 76 65 20 61 20 72 75 6e 20 63 6f 6e 66 69 67 20  ve a run config 
1d00: 66 69 6c 65 3a 20 22 20 72 75 6e 63 6f 6e 66 69  file: " runconfi
1d10: 67 66 29 29 0a 20 20 20 20 0a 20 20 20 20 3b 3b  gf)).    .    ;;
1d20: 20 6c 6f 6f 6b 20 75 70 20 61 6c 6c 20 74 65 73   look up all tes
1d30: 74 73 20 6d 61 74 63 68 69 6e 67 20 74 68 65 20  ts matching the 
1d40: 63 6f 6d 6d 61 20 73 65 70 61 72 61 74 65 64 20  comma separated 
1d50: 6c 69 73 74 20 6f 66 20 67 6c 6f 62 73 20 69 6e  list of globs in
1d60: 0a 20 20 20 20 3b 3b 20 74 65 73 74 2d 70 61 74  .    ;; test-pat
1d70: 74 73 20 28 75 73 69 6e 67 20 25 20 61 73 20 77  ts (using % as w
1d80: 69 6c 64 63 61 72 64 29 0a 20 20 20 20 28 66 6f  ildcard).    (fo
1d90: 72 2d 65 61 63 68 20 0a 20 20 20 20 20 28 6c 61  r-each .     (la
1da0: 6d 62 64 61 20 28 70 61 74 74 29 0a 20 20 20 20  mbda (patt).    
1db0: 20 20 20 28 6c 65 74 20 28 28 74 65 73 74 73 20     (let ((tests 
1dc0: 28 67 6c 6f 62 20 28 63 6f 6e 63 20 2a 74 6f 70  (glob (conc *top
1dd0: 70 61 74 68 2a 20 22 2f 74 65 73 74 73 2f 22 20  path* "/tests/" 
1de0: 28 73 74 72 69 6e 67 2d 74 72 61 6e 73 6c 61 74  (string-translat
1df0: 65 20 70 61 74 74 20 22 25 22 20 22 2a 22 29 29  e patt "%" "*"))
1e00: 29 29 29 0a 09 20 28 73 65 74 21 20 74 65 73 74  ))).. (set! test
1e10: 73 20 28 66 69 6c 74 65 72 20 28 6c 61 6d 62 64  s (filter (lambd
1e20: 61 20 28 74 65 73 74 29 28 66 69 6c 65 2d 65 78  a (test)(file-ex
1e30: 69 73 74 73 3f 20 28 63 6f 6e 63 20 74 65 73 74  ists? (conc test
1e40: 20 22 2f 74 65 73 74 63 6f 6e 66 69 67 22 29 29   "/testconfig"))
1e50: 29 20 74 65 73 74 73 29 29 0a 09 20 28 73 65 74  ) tests)).. (set
1e60: 21 20 74 65 73 74 2d 6e 61 6d 65 73 20 28 61 70  ! test-names (ap
1e70: 70 65 6e 64 20 74 65 73 74 2d 6e 61 6d 65 73 20  pend test-names 
1e80: 0a 09 09 09 09 20 20 28 6d 61 70 20 28 6c 61 6d  .....  (map (lam
1e90: 62 64 61 20 28 74 65 73 74 70 29 0a 09 09 09 09  bda (testp).....
1ea0: 09 20 28 6c 61 73 74 20 28 73 74 72 69 6e 67 2d  . (last (string-
1eb0: 73 70 6c 69 74 20 74 65 73 74 70 20 22 2f 22 29  split testp "/")
1ec0: 29 29 0a 09 09 09 09 20 20 20 20 20 20 20 74 65  )).....       te
1ed0: 73 74 73 29 29 29 29 29 0a 20 20 20 20 20 28 69  sts))))).     (i
1ee0: 66 20 74 65 73 74 2d 70 61 74 74 73 20 28 73 74  f test-patts (st
1ef0: 72 69 6e 67 2d 73 70 6c 69 74 20 74 65 73 74 2d  ring-split test-
1f00: 70 61 74 74 73 20 22 2c 22 29 28 6c 69 73 74 20  patts ",")(list 
1f10: 22 25 22 29 29 29 0a 0a 20 20 20 20 20 3b 3b 20  "%")))..     ;; 
1f20: 6e 6f 77 20 72 65 6d 6f 76 65 20 64 75 70 6c 69  now remove dupli
1f30: 63 61 74 65 73 0a 20 20 20 20 28 73 65 74 21 20  cates.    (set! 
1f40: 74 65 73 74 2d 6e 61 6d 65 73 20 28 64 65 6c 65  test-names (dele
1f50: 74 65 2d 64 75 70 6c 69 63 61 74 65 73 20 74 65  te-duplicates te
1f60: 73 74 2d 6e 61 6d 65 73 29 29 0a 0a 20 20 20 20  st-names))..    
1f70: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
1f80: 49 4e 46 4f 3a 20 74 65 73 74 20 6e 61 6d 65 73  INFO: test names
1f90: 20 22 20 74 65 73 74 2d 6e 61 6d 65 73 29 0a 0a   " test-names)..
1fa0: 20 20 20 20 3b 3b 20 6f 6e 20 74 68 65 20 66 69      ;; on the fi
1fb0: 72 73 74 20 70 61 73 73 20 6f 72 20 63 61 6c 6c  rst pass or call
1fc0: 20 74 6f 20 72 75 6e 2d 74 65 73 74 73 20 73 65   to run-tests se
1fd0: 74 20 46 41 49 4c 53 20 74 6f 20 4e 4f 54 5f 53  t FAILS to NOT_S
1fe0: 54 41 52 54 45 44 20 69 66 0a 20 20 20 20 3b 3b  TARTED if.    ;;
1ff0: 20 2d 6b 65 65 70 67 6f 69 6e 67 20 69 73 20 73   -keepgoing is s
2000: 70 65 63 69 66 69 65 64 0a 20 20 20 20 28 69 66  pecified.    (if
2010: 20 28 65 71 3f 20 2a 70 61 73 73 6e 75 6d 2a 20   (eq? *passnum* 
2020: 30 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 3b 3b  0)..(begin..  ;;
2030: 20 68 61 76 65 20 74 6f 20 64 65 6c 65 74 65 20   have to delete 
2040: 74 65 73 74 20 72 65 63 6f 72 64 73 20 77 68 65  test records whe
2050: 72 65 20 4e 4f 54 5f 53 54 41 52 54 45 44 20 73  re NOT_STARTED s
2060: 69 6e 63 65 20 74 68 65 79 20 63 61 6e 20 63 61  ince they can ca
2070: 75 73 65 20 2d 6b 65 65 70 67 6f 69 6e 67 20 74  use -keepgoing t
2080: 6f 20 0a 09 20 20 3b 3b 20 67 65 74 20 73 74 75  o ..  ;; get stu
2090: 63 6b 20 64 75 65 20 74 6f 20 62 65 63 6f 6d 69  ck due to becomi
20a0: 6e 67 20 69 6e 61 63 63 65 73 73 69 62 6c 65 20  ng inaccessible 
20b0: 66 72 6f 6d 20 61 20 66 61 69 6c 65 64 20 74 65  from a failed te
20c0: 73 74 2e 20 49 2e 65 2e 20 69 66 20 74 65 73 74  st. I.e. if test
20d0: 20 42 20 64 65 70 65 6e 64 73 20 0a 09 20 20 3b   B depends ..  ;
20e0: 3b 20 6f 6e 20 74 65 73 74 20 41 20 62 75 74 20  ; on test A but 
20f0: 74 65 73 74 20 42 20 72 65 61 63 68 65 64 20 74  test B reached t
2100: 68 65 20 70 6f 69 6e 74 20 6f 6e 20 62 65 69 6e  he point on bein
2110: 67 20 72 65 67 69 73 74 65 72 65 64 20 61 73 20  g registered as 
2120: 4e 4f 54 5f 53 54 41 52 54 45 44 20 61 6e 64 20  NOT_STARTED and 
2130: 74 65 73 74 0a 09 20 20 3b 3b 20 41 20 66 61 69  test..  ;; A fai
2140: 6c 65 64 20 66 6f 72 20 73 6f 6d 65 20 72 65 61  led for some rea
2150: 73 6f 6e 20 74 68 65 6e 20 6f 6e 20 72 65 2d 72  son then on re-r
2160: 75 6e 20 75 73 69 6e 67 20 2d 6b 65 65 70 67 6f  un using -keepgo
2170: 69 6e 67 20 74 68 65 20 72 75 6e 20 63 61 6e 20  ing the run can 
2180: 6e 65 76 65 72 20 63 6f 6d 70 6c 65 74 65 2e 0a  never complete..
2190: 09 20 20 28 64 62 3a 64 65 6c 65 74 65 2d 74 65  .  (db:delete-te
21a0: 73 74 73 2d 69 6e 2d 73 74 61 74 65 20 64 62 20  sts-in-state db 
21b0: 72 75 6e 2d 69 64 20 22 4e 4f 54 5f 53 54 41 52  run-id "NOT_STAR
21c0: 54 45 44 22 29 0a 09 20 20 28 72 64 62 3a 73 65  TED")..  (rdb:se
21d0: 74 2d 74 65 73 74 73 2d 73 74 61 74 65 2d 73 74  t-tests-state-st
21e0: 61 74 75 73 20 64 62 20 72 75 6e 2d 69 64 20 74  atus db run-id t
21f0: 65 73 74 2d 6e 61 6d 65 73 20 23 66 20 22 46 41  est-names #f "FA
2200: 49 4c 22 20 22 4e 4f 54 5f 53 54 41 52 54 45 44  IL" "NOT_STARTED
2210: 22 20 22 46 41 49 4c 22 29 29 29 0a 0a 20 20 20  " "FAIL")))..   
2220: 20 3b 3b 20 66 72 6f 6d 20 68 65 72 65 20 6f 6e   ;; from here on
2230: 20 6f 75 74 20 74 68 65 20 64 62 20 77 69 6c 6c   out the db will
2240: 20 62 65 20 6f 70 65 6e 65 64 20 61 6e 64 20 63   be opened and c
2250: 6c 6f 73 65 64 20 6f 6e 20 65 76 65 72 79 20 63  losed on every c
2260: 61 6c 6c 20 72 75 6e 73 3a 72 75 6e 2d 74 65 73  all runs:run-tes
2270: 74 73 2d 71 75 65 75 65 0a 20 20 20 20 28 73 71  ts-queue.    (sq
2280: 6c 69 74 65 33 3a 66 69 6e 61 6c 69 7a 65 21 20  lite3:finalize! 
2290: 64 62 29 20 0a 20 20 20 20 3b 3b 20 6e 6f 77 20  db) .    ;; now 
22a0: 61 64 64 20 6e 6f 6e 2d 64 69 72 65 63 74 6c 79  add non-directly
22b0: 20 72 65 66 65 72 65 6e 63 65 64 20 64 65 70 65   referenced depe
22c0: 6e 64 65 6e 63 69 65 73 20 28 69 2e 65 2e 20 77  ndencies (i.e. w
22d0: 61 69 74 6f 6e 29 0a 20 20 20 20 28 69 66 20 28  aiton).    (if (
22e0: 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 65 73 74 2d  not (null? test-
22f0: 6e 61 6d 65 73 29 29 0a 09 28 6c 65 74 20 6c 6f  names))..(let lo
2300: 6f 70 20 28 28 68 65 64 20 28 63 61 72 20 74 65  op ((hed (car te
2310: 73 74 2d 6e 61 6d 65 73 29 29 0a 09 09 20 20 20  st-names))...   
2320: 28 74 61 6c 20 28 63 64 72 20 74 65 73 74 2d 6e  (tal (cdr test-n
2330: 61 6d 65 73 29 29 29 20 20 20 20 20 20 20 20 20  ames)))         
2340: 3b 3b 20 27 72 65 74 75 72 6e 2d 70 72 6f 63 73  ;; 'return-procs
2350: 20 74 65 6c 6c 73 20 74 68 65 20 63 6f 6e 66 69   tells the confi
2360: 67 20 72 65 61 64 65 72 20 74 6f 20 70 72 65 70  g reader to prep
2370: 20 72 75 6e 6e 69 6e 67 20 73 79 73 74 65 6d 20   running system 
2380: 62 75 74 20 72 65 74 75 72 6e 20 61 20 70 72 6f  but return a pro
2390: 63 0a 09 20 20 28 6c 65 74 2a 20 28 28 63 6f 6e  c..  (let* ((con
23a0: 66 69 67 20 20 28 74 65 73 74 73 3a 67 65 74 2d  fig  (tests:get-
23b0: 74 65 73 74 63 6f 6e 66 69 67 20 68 65 64 20 27  testconfig hed '
23c0: 72 65 74 75 72 6e 2d 70 72 6f 63 73 29 29 0a 09  return-procs))..
23d0: 09 20 28 77 61 69 74 6f 6e 73 20 28 69 66 20 63  . (waitons (if c
23e0: 6f 6e 66 69 67 20 28 73 74 72 69 6e 67 2d 73 70  onfig (string-sp
23f0: 6c 69 74 20 28 6c 65 74 20 28 28 77 20 28 63 6f  lit (let ((w (co
2400: 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 63 6f 6e 66  nfig-lookup conf
2410: 69 67 20 22 72 65 71 75 69 72 65 6d 65 6e 74 73  ig "requirements
2420: 22 20 22 77 61 69 74 6f 6e 22 29 29 29 0a 09 09  " "waiton")))...
2430: 09 09 09 09 20 20 20 20 20 28 69 66 20 77 20 77  ....     (if w w
2440: 20 22 22 29 29 29 0a 09 09 09 20 20 20 20 20 20   "")))....      
2450: 28 62 65 67 69 6e 0a 09 09 09 09 28 64 65 62 75  (begin.....(debu
2460: 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52  g:print 0 "ERROR
2470: 3a 20 6e 6f 6e 2d 65 78 69 73 74 65 6e 74 20 72  : non-existent r
2480: 65 71 75 69 72 65 64 20 74 65 73 74 20 5c 22 22  equired test \""
2490: 20 68 65 64 20 22 5c 22 22 29 0a 20 20 20 20 20   hed "\"").     
24a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
24b0: 20 20 20 20 20 20 20 20 20 20 20 28 73 71 6c 69             (sqli
24c0: 74 65 33 3a 66 69 6e 61 6c 69 7a 65 21 20 64 62  te3:finalize! db
24d0: 29 0a 09 09 09 09 28 65 78 69 74 20 31 29 29 29  ).....(exit 1)))
24e0: 29 29 0a 09 20 20 20 20 3b 3b 20 63 68 65 63 6b  ))..    ;; check
24f0: 20 66 6f 72 20 68 65 64 20 69 6e 20 77 61 69 74   for hed in wait
2500: 6f 6e 73 20 3d 3e 20 74 68 69 73 20 77 6f 75 6c  ons => this woul
2510: 64 20 62 65 20 63 69 72 63 75 6c 61 72 2c 20 72  d be circular, r
2520: 65 6d 6f 76 65 20 69 74 20 61 6e 64 20 69 73 73  emove it and iss
2530: 75 65 20 61 6e 0a 09 20 20 20 20 3b 3b 20 65 72  ue an..    ;; er
2540: 72 6f 72 0a 09 20 20 20 20 28 69 66 20 28 6d 65  ror..    (if (me
2550: 6d 62 65 72 20 68 65 64 20 77 61 69 74 6f 6e 73  mber hed waitons
2560: 29 0a 09 09 28 62 65 67 69 6e 0a 09 09 20 20 28  )...(begin...  (
2570: 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45  debug:print 0 "E
2580: 52 52 4f 52 3a 20 74 65 73 74 20 22 20 68 65 64  RROR: test " hed
2590: 20 22 20 68 61 73 20 6c 69 73 74 65 64 20 69 74   " has listed it
25a0: 73 65 6c 66 20 61 73 20 61 20 77 61 69 74 6f 6e  self as a waiton
25b0: 2c 20 70 6c 65 61 73 65 20 63 6f 72 72 65 63 74  , please correct
25c0: 20 74 68 69 73 21 22 29 0a 09 09 20 20 28 73 65   this!")...  (se
25d0: 74 21 20 77 61 69 74 6f 6e 73 20 28 66 69 6c 74  t! waitons (filt
25e0: 65 72 20 28 6c 61 6d 62 64 61 20 28 78 29 28 6e  er (lambda (x)(n
25f0: 6f 74 20 28 65 71 75 61 6c 3f 20 78 20 68 65 64  ot (equal? x hed
2600: 29 29 29 20 77 61 69 74 6f 6e 73 29 29 29 29 0a  ))) waitons)))).
2610: 09 20 20 20 20 0a 09 20 20 20 20 3b 3b 20 28 69  .    ..    ;; (i
2620: 74 65 6d 73 20 20 20 28 69 74 65 6d 73 3a 67 65  tems   (items:ge
2630: 74 2d 69 74 65 6d 73 2d 66 72 6f 6d 2d 63 6f 6e  t-items-from-con
2640: 66 69 67 20 63 6f 6e 66 69 67 29 29 29 0a 09 20  fig config))).. 
2650: 20 20 20 28 69 66 20 28 6e 6f 74 20 28 68 61 73     (if (not (has
2660: 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61  h-table-ref/defa
2670: 75 6c 74 20 74 65 73 74 2d 72 65 63 6f 72 64 73  ult test-records
2680: 20 68 65 64 20 23 66 29 29 0a 09 09 28 68 61 73   hed #f))...(has
2690: 68 2d 74 61 62 6c 65 2d 73 65 74 21 20 74 65 73  h-table-set! tes
26a0: 74 2d 72 65 63 6f 72 64 73 0a 09 09 09 09 20 68  t-records..... h
26b0: 65 64 20 28 76 65 63 74 6f 72 20 68 65 64 20 20  ed (vector hed  
26c0: 20 20 20 3b 3b 20 30 0a 09 09 09 09 09 20 20 20     ;; 0......   
26d0: 20 20 63 6f 6e 66 69 67 20 20 3b 3b 20 31 0a 09    config  ;; 1..
26e0: 09 09 09 09 20 20 20 20 20 77 61 69 74 6f 6e 73  ....     waitons
26f0: 20 3b 3b 20 32 0a 09 09 09 09 09 20 20 20 20 20   ;; 2......     
2700: 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 63  (config-lookup c
2710: 6f 6e 66 69 67 20 22 72 65 71 75 69 72 65 6d 65  onfig "requireme
2720: 6e 74 73 22 20 22 70 72 69 6f 72 69 74 79 22 29  nts" "priority")
2730: 20 20 20 20 20 3b 3b 20 70 72 69 6f 72 69 74 79       ;; priority
2740: 20 33 0a 09 09 09 09 09 20 20 20 20 20 28 6c 65   3......     (le
2750: 74 20 28 28 69 74 65 6d 73 20 20 20 20 20 20 28  t ((items      (
2760: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64  hash-table-ref/d
2770: 65 66 61 75 6c 74 20 63 6f 6e 66 69 67 20 22 69  efault config "i
2780: 74 65 6d 73 22 20 23 66 29 29 20 3b 3b 20 69 74  tems" #f)) ;; it
2790: 65 6d 73 20 34 0a 09 09 09 09 09 09 20 20 20 28  ems 4.......   (
27a0: 69 74 65 6d 73 74 61 62 6c 65 20 28 68 61 73 68  itemstable (hash
27b0: 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75  -table-ref/defau
27c0: 6c 74 20 63 6f 6e 66 69 67 20 22 69 74 65 6d 73  lt config "items
27d0: 74 61 62 6c 65 22 20 23 66 29 29 29 20 0a 09 09  table" #f))) ...
27e0: 09 09 09 20 20 20 20 20 20 20 3b 3b 20 69 66 20  ...       ;; if 
27f0: 65 69 74 68 65 72 20 69 74 65 6d 73 20 6f 72 20  either items or 
2800: 69 74 65 6d 73 20 74 61 62 6c 65 20 69 73 20 61  items table is a
2810: 20 70 72 6f 63 20 72 65 74 75 72 6e 20 69 74 20   proc return it 
2820: 73 6f 20 74 65 73 74 20 72 75 6e 6e 69 6e 67 0a  so test running.
2830: 09 09 09 09 09 20 20 20 20 20 20 20 3b 3b 20 70  .....       ;; p
2840: 72 6f 63 65 73 73 20 63 61 6e 20 6b 6e 6f 77 20  rocess can know 
2850: 74 6f 20 63 61 6c 6c 20 69 74 65 6d 73 3a 67 65  to call items:ge
2860: 74 2d 69 74 65 6d 73 2d 66 72 6f 6d 2d 63 6f 6e  t-items-from-con
2870: 66 69 67 0a 09 09 09 09 09 20 20 20 20 20 20 20  fig......       
2880: 3b 3b 20 69 66 20 65 69 74 68 65 72 20 69 73 20  ;; if either is 
2890: 61 20 6c 69 73 74 20 61 6e 64 20 6e 6f 6e 65 20  a list and none 
28a0: 69 73 20 61 20 70 72 6f 63 20 67 6f 20 61 68 65  is a proc go ahe
28b0: 61 64 20 61 6e 64 20 63 61 6c 6c 20 67 65 74 2d  ad and call get-
28c0: 69 74 65 6d 73 0a 09 09 09 09 09 20 20 20 20 20  items......     
28d0: 20 20 3b 3b 20 6f 74 68 65 72 77 69 73 65 20 72    ;; otherwise r
28e0: 65 74 75 72 6e 20 23 66 20 2d 20 74 68 69 73 20  eturn #f - this 
28f0: 69 73 20 6e 6f 74 20 61 6e 20 69 74 65 72 61 74  is not an iterat
2900: 65 64 20 74 65 73 74 0a 09 09 09 09 09 20 20 20  ed test......   
2910: 20 20 20 20 28 63 6f 6e 64 0a 09 09 09 09 09 09      (cond.......
2920: 28 28 70 72 6f 63 65 64 75 72 65 3f 20 69 74 65  ((procedure? ite
2930: 6d 73 29 20 20 20 20 20 20 0a 09 09 09 09 09 09  ms)      .......
2940: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20   (debug:print 4 
2950: 22 49 4e 46 4f 3a 20 69 74 65 6d 73 20 69 73 20  "INFO: items is 
2960: 61 20 70 72 6f 63 65 64 75 72 65 2c 20 77 69 6c  a procedure, wil
2970: 6c 20 63 61 6c 63 20 6c 61 74 65 72 22 29 0a 09  l calc later")..
2980: 09 09 09 09 09 20 69 74 65 6d 73 29 20 20 20 20  ..... items)    
2990: 20 20 20 20 20 20 20 20 3b 3b 20 63 61 6c 63 20          ;; calc 
29a0: 6c 61 74 65 72 0a 09 09 09 09 09 09 28 28 70 72  later.......((pr
29b0: 6f 63 65 64 75 72 65 3f 20 69 74 65 6d 73 74 61  ocedure? itemsta
29c0: 62 6c 65 29 0a 09 09 09 09 09 09 20 28 64 65 62  ble)....... (deb
29d0: 75 67 3a 70 72 69 6e 74 20 34 20 22 49 4e 46 4f  ug:print 4 "INFO
29e0: 3a 20 69 74 65 6d 73 74 61 62 6c 65 20 69 73 20  : itemstable is 
29f0: 61 20 70 72 6f 63 65 64 75 72 65 2c 20 77 69 6c  a procedure, wil
2a00: 6c 20 63 61 6c 63 20 6c 61 74 65 72 22 29 0a 09  l calc later")..
2a10: 09 09 09 09 09 20 69 74 65 6d 73 74 61 62 6c 65  ..... itemstable
2a20: 29 20 20 20 20 20 20 20 3b 3b 20 63 61 6c 63 20  )       ;; calc 
2a30: 6c 61 74 65 72 0a 09 09 09 09 09 09 28 28 66 69  later.......((fi
2a40: 6c 74 65 72 20 28 6c 61 6d 62 64 61 20 28 78 29  lter (lambda (x)
2a50: 0a 09 09 09 09 09 09 09 20 20 20 28 6c 65 74 20  ........   (let 
2a60: 28 28 76 61 6c 20 28 63 61 72 20 78 29 29 29 0a  ((val (car x))).
2a70: 09 09 09 09 09 09 09 20 20 20 20 20 28 69 66 20  .......     (if 
2a80: 28 70 72 6f 63 65 64 75 72 65 3f 20 76 61 6c 29  (procedure? val)
2a90: 20 76 61 6c 20 23 66 29 29 29 0a 09 09 09 09 09   val #f)))......
2aa0: 09 09 20 28 61 70 70 65 6e 64 20 28 69 66 20 28  .. (append (if (
2ab0: 6c 69 73 74 3f 20 69 74 65 6d 73 29 20 69 74 65  list? items) ite
2ac0: 6d 73 20 27 28 29 29 0a 09 09 09 09 09 09 09 09  ms '()).........
2ad0: 20 28 69 66 20 28 6c 69 73 74 3f 20 69 74 65 6d   (if (list? item
2ae0: 73 74 61 62 6c 65 29 20 69 74 65 6d 73 74 61 62  stable) itemstab
2af0: 6c 65 20 27 28 29 29 29 29 0a 09 09 09 09 09 09  le '()))).......
2b00: 20 27 68 61 76 65 2d 70 72 6f 63 65 64 75 72 65   'have-procedure
2b10: 29 0a 09 09 09 09 09 09 28 28 6f 72 20 28 6c 69  ).......((or (li
2b20: 73 74 3f 20 69 74 65 6d 73 29 28 6c 69 73 74 3f  st? items)(list?
2b30: 20 69 74 65 6d 73 74 61 62 6c 65 29 29 20 3b 3b   itemstable)) ;;
2b40: 20 63 61 6c 63 20 6e 6f 77 0a 09 09 09 09 09 09   calc now.......
2b50: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20   (debug:print 4 
2b60: 22 49 4e 46 4f 3a 20 69 74 65 6d 73 20 61 6e 64  "INFO: items and
2b70: 20 69 74 65 6d 73 74 61 62 6c 65 20 61 72 65 20   itemstable are 
2b80: 6c 69 73 74 73 2c 20 63 61 6c 63 20 6e 6f 77 5c  lists, calc now\
2b90: 6e 22 0a 09 09 09 09 09 09 09 20 20 20 20 20 20  n"........      
2ba0: 22 20 20 20 20 69 74 65 6d 73 3a 20 22 20 69 74  "    items: " it
2bb0: 65 6d 73 20 22 20 69 74 65 6d 73 74 61 62 6c 65  ems " itemstable
2bc0: 3a 20 22 20 69 74 65 6d 73 74 61 62 6c 65 29 0a  : " itemstable).
2bd0: 09 09 09 09 09 09 20 28 69 74 65 6d 73 3a 67 65  ...... (items:ge
2be0: 74 2d 69 74 65 6d 73 2d 66 72 6f 6d 2d 63 6f 6e  t-items-from-con
2bf0: 66 69 67 20 63 6f 6e 66 69 67 29 29 0a 09 09 09  fig config))....
2c00: 09 09 09 28 65 6c 73 65 20 23 66 29 29 29 20 20  ...(else #f)))  
2c10: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2c20: 20 20 20 20 20 20 20 20 20 3b 3b 20 6e 6f 74 20           ;; not 
2c30: 69 74 65 72 61 74 65 64 0a 09 09 09 09 09 20 20  iterated......  
2c40: 20 20 20 23 66 20 20 20 20 20 20 3b 3b 20 69 74     #f      ;; it
2c50: 65 6d 73 64 61 74 20 35 0a 09 09 09 09 09 20 20  emsdat 5......  
2c60: 20 20 20 23 66 20 20 20 20 20 20 3b 3b 20 73 70     #f      ;; sp
2c70: 61 72 65 20 2d 20 75 73 65 64 20 66 6f 72 20 69  are - used for i
2c80: 74 65 6d 2d 70 61 74 68 0a 09 09 09 09 09 20 20  tem-path......  
2c90: 20 20 20 29 29 29 0a 09 20 20 20 20 28 66 6f 72     )))..    (for
2ca0: 2d 65 61 63 68 20 0a 09 20 20 20 20 20 28 6c 61  -each ..     (la
2cb0: 6d 62 64 61 20 28 77 61 69 74 6f 6e 29 0a 09 20  mbda (waiton).. 
2cc0: 20 20 20 20 20 20 28 69 66 20 28 61 6e 64 20 77        (if (and w
2cd0: 61 69 74 6f 6e 20 28 6e 6f 74 20 28 6d 65 6d 62  aiton (not (memb
2ce0: 65 72 20 77 61 69 74 6f 6e 20 74 65 73 74 2d 6e  er waiton test-n
2cf0: 61 6d 65 73 29 29 29 0a 09 09 20 20 20 28 62 65  ames)))...   (be
2d00: 67 69 6e 0a 09 09 20 20 20 20 20 28 73 65 74 21  gin...     (set!
2d10: 20 72 65 71 75 69 72 65 64 2d 74 65 73 74 73 20   required-tests 
2d20: 28 63 6f 6e 73 20 77 61 69 74 6f 6e 20 72 65 71  (cons waiton req
2d30: 75 69 72 65 64 2d 74 65 73 74 73 29 29 0a 09 09  uired-tests))...
2d40: 20 20 20 20 20 28 73 65 74 21 20 74 65 73 74 2d       (set! test-
2d50: 6e 61 6d 65 73 20 28 63 6f 6e 73 20 77 61 69 74  names (cons wait
2d60: 6f 6e 20 74 65 73 74 2d 6e 61 6d 65 73 29 29 29  on test-names)))
2d70: 29 29 20 3b 3b 20 77 61 73 20 61 6e 20 61 70 70  )) ;; was an app
2d80: 65 6e 64 2c 20 6e 6f 77 20 61 20 63 6f 6e 73 0a  end, now a cons.
2d90: 09 20 20 20 20 20 77 61 69 74 6f 6e 73 29 0a 09  .     waitons)..
2da0: 20 20 20 20 28 6c 65 74 20 28 28 72 65 6d 74 65      (let ((remte
2db0: 73 74 73 20 28 64 65 6c 65 74 65 2d 64 75 70 6c  sts (delete-dupl
2dc0: 69 63 61 74 65 73 20 28 61 70 70 65 6e 64 20 77  icates (append w
2dd0: 61 69 74 6f 6e 73 20 74 61 6c 29 29 29 29 0a 09  aitons tal))))..
2de0: 20 20 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28        (if (not (
2df0: 6e 75 6c 6c 3f 20 72 65 6d 74 65 73 74 73 29 29  null? remtests))
2e00: 0a 09 09 20 20 28 6c 6f 6f 70 20 28 63 61 72 20  ...  (loop (car 
2e10: 72 65 6d 74 65 73 74 73 29 28 63 64 72 20 72 65  remtests)(cdr re
2e20: 6d 74 65 73 74 73 29 29 29 29 29 29 29 0a 0a 20  mtests))))))).. 
2e30: 20 20 20 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c     (if (not (nul
2e40: 6c 3f 20 72 65 71 75 69 72 65 64 2d 74 65 73 74  l? required-test
2e50: 73 29 29 0a 09 28 64 65 62 75 67 3a 70 72 69 6e  s))..(debug:prin
2e60: 74 20 31 20 22 49 4e 46 4f 3a 20 41 64 64 69 6e  t 1 "INFO: Addin
2e70: 67 20 22 20 72 65 71 75 69 72 65 64 2d 74 65 73  g " required-tes
2e80: 74 73 20 22 20 74 6f 20 74 68 65 20 72 75 6e 20  ts " to the run 
2e90: 71 75 65 75 65 22 29 29 0a 20 20 20 20 3b 3b 20  queue")).    ;; 
2ea0: 4e 4f 54 45 3a 20 74 68 65 73 65 20 61 72 65 20  NOTE: these are 
2eb0: 61 6c 6c 20 70 61 72 65 6e 74 20 74 65 73 74 73  all parent tests
2ec0: 2c 20 69 74 65 6d 73 20 61 72 65 20 6e 6f 74 20  , items are not 
2ed0: 65 78 70 61 6e 64 65 64 20 79 65 74 2e 0a 20 20  expanded yet..  
2ee0: 20 20 28 72 75 6e 73 3a 72 75 6e 2d 74 65 73 74    (runs:run-test
2ef0: 73 2d 71 75 65 75 65 20 72 75 6e 2d 69 64 20 72  s-queue run-id r
2f00: 75 6e 6e 61 6d 65 20 74 65 73 74 2d 72 65 63 6f  unname test-reco
2f10: 72 64 73 20 6b 65 79 76 61 6c 6c 73 74 20 66 6c  rds keyvallst fl
2f20: 61 67 73 29 0a 20 20 20 20 28 64 65 62 75 67 3a  ags).    (debug:
2f30: 70 72 69 6e 74 20 34 20 22 49 4e 46 4f 3a 20 41  print 4 "INFO: A
2f40: 6c 6c 20 64 6f 6e 65 20 62 79 20 68 65 72 65 22  ll done by here"
2f50: 29 29 29 0a 0a 3b 3b 20 74 65 73 74 2d 72 65 63  )))..;; test-rec
2f60: 6f 72 64 73 20 69 73 20 61 20 68 61 73 68 20 74  ords is a hash t
2f70: 61 62 6c 65 20 74 65 73 74 6e 61 6d 65 3a 69 74  able testname:it
2f80: 65 6d 5f 70 61 74 68 20 3d 3e 20 76 65 63 74 6f  em_path => vecto
2f90: 72 20 3c 20 74 65 73 74 6e 61 6d 65 20 74 65 73  r < testname tes
2fa0: 74 63 6f 6e 66 69 67 20 77 61 69 74 6f 6e 73 20  tconfig waitons 
2fb0: 70 72 69 6f 72 69 74 79 20 69 74 65 6d 73 2d 69  priority items-i
2fc0: 6e 66 6f 20 2e 2e 2e 20 3e 0a 28 64 65 66 69 6e  nfo ... >.(defin
2fd0: 65 20 28 72 75 6e 73 3a 72 75 6e 2d 74 65 73 74  e (runs:run-test
2fe0: 73 2d 71 75 65 75 65 20 72 75 6e 2d 69 64 20 72  s-queue run-id r
2ff0: 75 6e 6e 61 6d 65 20 74 65 73 74 2d 72 65 63 6f  unname test-reco
3000: 72 64 73 20 6b 65 79 76 61 6c 6c 73 74 20 66 6c  rds keyvallst fl
3010: 61 67 73 29 0a 20 20 20 20 3b 3b 20 41 74 20 74  ags).    ;; At t
3020: 68 69 73 20 70 6f 69 6e 74 20 74 68 65 20 6c 69  his point the li
3030: 73 74 20 6f 66 20 70 61 72 65 6e 74 20 74 65 73  st of parent tes
3040: 74 73 20 69 73 20 65 78 70 61 6e 64 65 64 20 0a  ts is expanded .
3050: 20 20 20 20 3b 3b 20 4e 42 2f 2f 20 53 68 6f 75      ;; NB// Shou
3060: 6c 64 20 65 78 70 61 6e 64 20 69 74 65 6d 73 20  ld expand items 
3070: 68 65 72 65 20 61 6e 64 20 74 68 65 6e 20 69 6e  here and then in
3080: 73 65 72 74 20 69 6e 74 6f 20 74 68 65 20 72 75  sert into the ru
3090: 6e 20 71 75 65 75 65 2e 0a 20 20 28 64 65 62 75  n queue..  (debu
30a0: 67 3a 70 72 69 6e 74 20 35 20 22 74 65 73 74 2d  g:print 5 "test-
30b0: 72 65 63 6f 72 64 73 3a 20 22 20 74 65 73 74 2d  records: " test-
30c0: 72 65 63 6f 72 64 73 20 22 2c 20 6b 65 79 76 61  records ", keyva
30d0: 6c 6c 73 74 3a 20 22 20 6b 65 79 76 61 6c 6c 73  llst: " keyvalls
30e0: 74 20 22 20 66 6c 61 67 73 3a 20 22 20 28 68 61  t " flags: " (ha
30f0: 73 68 2d 74 61 62 6c 65 2d 3e 61 6c 69 73 74 20  sh-table->alist 
3100: 66 6c 61 67 73 29 29 0a 20 20 28 6c 65 74 20 28  flags)).  (let (
3110: 28 73 6f 72 74 65 64 2d 74 65 73 74 2d 6e 61 6d  (sorted-test-nam
3120: 65 73 20 28 74 65 73 74 73 3a 73 6f 72 74 2d 62  es (tests:sort-b
3130: 79 2d 70 72 69 6f 72 69 74 79 2d 61 6e 64 2d 77  y-priority-and-w
3140: 61 69 74 6f 6e 20 74 65 73 74 2d 72 65 63 6f 72  aiton test-recor
3150: 64 73 29 29 0a 09 28 69 74 65 6d 2d 70 61 74 74  ds))..(item-patt
3160: 73 20 20 20 20 20 20 20 20 28 68 61 73 68 2d 74  s        (hash-t
3170: 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74  able-ref/default
3180: 20 66 6c 61 67 73 20 22 2d 69 74 65 6d 70 61 74   flags "-itempat
3190: 74 22 20 23 66 29 29 29 0a 20 20 20 20 28 69 66  t" #f))).    (if
31a0: 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 73 6f 72   (not (null? sor
31b0: 74 65 64 2d 74 65 73 74 2d 6e 61 6d 65 73 29 29  ted-test-names))
31c0: 0a 09 28 6c 65 74 20 6c 6f 6f 70 20 28 28 68 65  ..(let loop ((he
31d0: 64 20 20 20 20 20 20 20 20 20 28 63 61 72 20 73  d         (car s
31e0: 6f 72 74 65 64 2d 74 65 73 74 2d 6e 61 6d 65 73  orted-test-names
31f0: 29 29 0a 09 09 20 20 20 28 74 61 6c 20 20 20 20  ))...   (tal    
3200: 20 20 20 20 20 28 63 64 72 20 73 6f 72 74 65 64       (cdr sorted
3210: 2d 74 65 73 74 2d 6e 61 6d 65 73 29 29 29 0a 09  -test-names)))..
3220: 20 20 28 74 68 72 65 61 64 2d 73 6c 65 65 70 21    (thread-sleep!
3230: 20 2a 67 6c 6f 62 61 6c 2d 64 65 6c 74 61 2a 29   *global-delta*)
3240: 20 3b 3b 20 67 69 76 65 20 6f 74 68 65 72 20 61   ;; give other a
3250: 70 70 6c 69 63 61 74 69 6f 6e 73 20 73 6f 6d 65  pplications some
3260: 20 74 69 6d 65 20 77 69 74 68 20 74 68 65 20 64   time with the d
3270: 62 0a 09 20 20 28 6c 65 74 2a 20 28 28 74 65 73  b..  (let* ((tes
3280: 74 2d 72 65 63 6f 72 64 20 28 68 61 73 68 2d 74  t-record (hash-t
3290: 61 62 6c 65 2d 72 65 66 20 74 65 73 74 2d 72 65  able-ref test-re
32a0: 63 6f 72 64 73 20 68 65 64 29 29 0a 09 09 20 28  cords hed))... (
32b0: 74 63 6f 6e 66 69 67 20 20 20 20 20 28 74 65 73  tconfig     (tes
32c0: 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74  ts:testqueue-get
32d0: 2d 74 65 73 74 63 6f 6e 66 69 67 20 74 65 73 74  -testconfig test
32e0: 2d 72 65 63 6f 72 64 29 29 0a 09 09 20 28 74 65  -record))... (te
32f0: 73 74 6d 6f 64 65 20 20 20 20 28 6c 65 74 20 28  stmode    (let (
3300: 28 6d 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75  (m (config-looku
3310: 70 20 74 63 6f 6e 66 69 67 20 22 72 65 71 75 69  p tconfig "requi
3320: 72 65 6d 65 6e 74 73 22 20 22 6d 6f 64 65 22 29  rements" "mode")
3330: 29 29 0a 09 09 09 09 28 69 66 20 6d 20 28 73 74  )).....(if m (st
3340: 72 69 6e 67 2d 3e 73 79 6d 62 6f 6c 20 6d 29 20  ring->symbol m) 
3350: 27 6e 6f 72 6d 61 6c 29 29 29 0a 09 09 20 28 77  'normal)))... (w
3360: 61 69 74 6f 6e 73 20 20 20 20 20 28 74 65 73 74  aitons     (test
3370: 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d  s:testqueue-get-
3380: 77 61 69 74 6f 6e 73 20 20 20 20 74 65 73 74 2d  waitons    test-
3390: 72 65 63 6f 72 64 29 29 0a 09 09 20 28 70 72 69  record))... (pri
33a0: 6f 72 69 74 79 20 20 20 20 28 74 65 73 74 73 3a  ority    (tests:
33b0: 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d 70 72  testqueue-get-pr
33c0: 69 6f 72 69 74 79 20 20 20 74 65 73 74 2d 72 65  iority   test-re
33d0: 63 6f 72 64 29 29 0a 09 09 20 28 69 74 65 6d 64  cord))... (itemd
33e0: 61 74 20 20 20 20 20 28 74 65 73 74 73 3a 74 65  at     (tests:te
33f0: 73 74 71 75 65 75 65 2d 67 65 74 2d 69 74 65 6d  stqueue-get-item
3400: 64 61 74 20 20 20 20 74 65 73 74 2d 72 65 63 6f  dat    test-reco
3410: 72 64 29 29 20 3b 3b 20 69 74 65 6d 64 61 74 20  rd)) ;; itemdat 
3420: 63 61 6e 20 62 65 20 61 20 73 74 72 69 6e 67 2c  can be a string,
3430: 20 6c 69 73 74 20 6f 72 20 23 66 0a 09 09 20 28   list or #f... (
3440: 69 74 65 6d 73 20 20 20 20 20 20 20 28 74 65 73  items       (tes
3450: 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74  ts:testqueue-get
3460: 2d 69 74 65 6d 73 20 20 20 20 20 20 74 65 73 74  -items      test
3470: 2d 72 65 63 6f 72 64 29 29 0a 09 09 20 28 69 74  -record))... (it
3480: 65 6d 2d 70 61 74 68 20 20 20 28 69 74 65 6d 2d  em-path   (item-
3490: 6c 69 73 74 2d 3e 70 61 74 68 20 69 74 65 6d 64  list->path itemd
34a0: 61 74 29 29 0a 09 09 20 28 6e 65 77 74 61 6c 20  at))... (newtal 
34b0: 20 20 20 20 20 28 61 70 70 65 6e 64 20 74 61 6c       (append tal
34c0: 20 28 6c 69 73 74 20 68 65 64 29 29 29 0a 09 09   (list hed)))...
34d0: 20 28 63 61 6c 63 2d 66 61 69 6c 73 20 20 28 6c   (calc-fails  (l
34e0: 61 6d 62 64 61 20 28 70 72 65 72 65 71 73 2d 6e  ambda (prereqs-n
34f0: 6f 74 2d 6d 65 74 29 0a 09 09 09 09 28 66 69 6c  ot-met).....(fil
3500: 74 65 72 20 28 6c 61 6d 62 64 61 20 28 74 65 73  ter (lambda (tes
3510: 74 29 0a 09 09 09 09 09 20 20 28 64 65 62 75 67  t)......  (debug
3520: 3a 70 72 69 6e 74 20 39 20 22 74 65 73 74 3a 20  :print 9 "test: 
3530: 22 20 74 65 73 74 29 0a 09 09 09 09 09 20 20 28  " test)......  (
3540: 61 6e 64 20 28 76 65 63 74 6f 72 3f 20 74 65 73  and (vector? tes
3550: 74 29 20 3b 3b 20 6e 6f 74 20 28 73 74 72 69 6e  t) ;; not (strin
3560: 67 3f 20 74 65 73 74 29 29 0a 09 09 09 09 09 20  g? test))...... 
3570: 20 20 20 20 20 20 28 65 71 75 61 6c 3f 20 28 64        (equal? (d
3580: 62 3a 74 65 73 74 2d 67 65 74 2d 73 74 61 74 65  b:test-get-state
3590: 20 74 65 73 74 29 20 22 43 4f 4d 50 4c 45 54 45   test) "COMPLETE
35a0: 44 22 29 0a 09 09 09 09 09 20 20 20 20 20 20 20  D")......       
35b0: 28 6e 6f 74 20 28 6d 65 6d 62 65 72 20 28 64 62  (not (member (db
35c0: 3a 74 65 73 74 2d 67 65 74 2d 73 74 61 74 75 73  :test-get-status
35d0: 20 74 65 73 74 29 0a 09 09 09 09 09 09 09 20 20   test)........  
35e0: 20 20 27 28 22 50 41 53 53 22 20 22 57 41 52 4e    '("PASS" "WARN
35f0: 22 20 22 43 48 45 43 4b 22 20 22 57 41 49 56 45  " "CHECK" "WAIVE
3600: 44 22 29 29 29 29 29 0a 09 09 09 09 09 70 72 65  D")))))......pre
3610: 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 29 29 29 0a  reqs-not-met))).
3620: 09 09 20 28 63 61 6c 63 2d 6e 6f 74 2d 63 6f 6d  .. (calc-not-com
3630: 70 6c 65 74 65 64 20 28 6c 61 6d 62 64 61 20 28  pleted (lambda (
3640: 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 29  prereqs-not-met)
3650: 0a 09 09 09 09 20 20 20 20 20 20 20 28 66 69 6c  .....       (fil
3660: 74 65 72 0a 09 09 09 09 09 28 6c 61 6d 62 64 61  ter......(lambda
3670: 20 28 74 29 0a 09 09 09 09 09 20 20 28 6f 72 20   (t)......  (or 
3680: 28 6e 6f 74 20 28 76 65 63 74 6f 72 3f 20 74 29  (not (vector? t)
3690: 29 0a 09 09 09 09 09 20 20 20 20 20 20 28 6e 6f  )......      (no
36a0: 74 20 28 65 71 75 61 6c 3f 20 22 43 4f 4d 50 4c  t (equal? "COMPL
36b0: 45 54 45 44 22 20 28 64 62 3a 74 65 73 74 2d 67  ETED" (db:test-g
36c0: 65 74 2d 73 74 61 74 65 20 74 29 29 29 29 29 0a  et-state t))))).
36d0: 09 09 09 09 09 70 72 65 72 65 71 73 2d 6e 6f 74  .....prereqs-not
36e0: 2d 6d 65 74 29 29 29 0a 09 09 20 28 70 72 65 74  -met)))... (pret
36f0: 74 79 2d 73 74 72 69 6e 67 20 28 6c 61 6d 62 64  ty-string (lambd
3700: 61 20 28 6c 73 74 29 0a 09 09 09 09 20 20 28 6d  a (lst).....  (m
3710: 61 70 20 28 6c 61 6d 62 64 61 20 28 74 29 0a 09  ap (lambda (t)..
3720: 09 09 09 09 20 28 69 66 20 28 6e 6f 74 20 28 76  .... (if (not (v
3730: 65 63 74 6f 72 3f 20 74 29 29 0a 09 09 09 09 09  ector? t))......
3740: 20 20 20 20 20 28 63 6f 6e 63 20 74 29 0a 09 09       (conc t)...
3750: 09 09 09 20 20 20 20 20 28 63 6f 6e 63 20 28 64  ...     (conc (d
3760: 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e  b:test-get-testn
3770: 61 6d 65 20 74 29 20 22 3a 22 20 28 64 62 3a 74  ame t) ":" (db:t
3780: 65 73 74 2d 67 65 74 2d 73 74 61 74 65 20 74 29  est-get-state t)
3790: 20 22 2f 22 20 28 64 62 3a 74 65 73 74 2d 67 65   "/" (db:test-ge
37a0: 74 2d 73 74 61 74 75 73 20 74 29 29 29 29 0a 09  t-status t))))..
37b0: 09 09 09 20 20 20 20 20 20 20 6c 73 74 29 29 29  ...       lst)))
37c0: 29 0a 09 20 20 20 20 28 64 65 62 75 67 3a 70 72  )..    (debug:pr
37d0: 69 6e 74 20 36 0a 09 09 09 20 22 69 74 65 6d 64  int 6.... "itemd
37e0: 61 74 3a 20 20 20 20 20 22 20 69 74 65 6d 64 61  at:     " itemda
37f0: 74 0a 09 09 09 20 22 5c 6e 20 20 69 74 65 6d 73  t.... "\n  items
3800: 3a 20 20 20 20 20 22 20 69 74 65 6d 73 0a 09 09  :     " items...
3810: 09 20 22 5c 6e 20 20 69 74 65 6d 2d 70 61 74 68  . "\n  item-path
3820: 3a 20 22 20 69 74 65 6d 2d 70 61 74 68 0a 09 09  : " item-path...
3830: 09 20 22 5c 6e 20 20 77 61 69 74 6f 6e 73 3a 20  . "\n  waitons: 
3840: 20 20 22 20 77 61 69 74 6f 6e 73 29 0a 0a 09 20    " waitons)... 
3850: 20 20 20 3b 3b 20 63 68 65 63 6b 20 66 6f 72 20     ;; check for 
3860: 68 65 64 20 69 6e 20 77 61 69 74 6f 6e 73 20 3d  hed in waitons =
3870: 3e 20 74 68 69 73 20 77 6f 75 6c 64 20 62 65 20  > this would be 
3880: 63 69 72 63 75 6c 61 72 2c 20 72 65 6d 6f 76 65  circular, remove
3890: 20 69 74 20 61 6e 64 20 69 73 73 75 65 20 61 6e   it and issue an
38a0: 0a 09 20 20 20 20 3b 3b 20 65 72 72 6f 72 0a 09  ..    ;; error..
38b0: 20 20 20 20 28 69 66 20 28 6d 65 6d 62 65 72 20      (if (member 
38c0: 68 65 64 20 77 61 69 74 6f 6e 73 29 0a 09 09 28  hed waitons)...(
38d0: 62 65 67 69 6e 0a 09 09 20 20 28 64 65 62 75 67  begin...  (debug
38e0: 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a  :print 0 "ERROR:
38f0: 20 74 65 73 74 20 22 20 68 65 64 20 22 20 68 61   test " hed " ha
3900: 73 20 6c 69 73 74 65 64 20 69 74 73 65 6c 66 20  s listed itself 
3910: 61 73 20 61 20 77 61 69 74 6f 6e 2c 20 70 6c 65  as a waiton, ple
3920: 61 73 65 20 63 6f 72 72 65 63 74 20 74 68 69 73  ase correct this
3930: 21 22 29 0a 09 09 20 20 28 73 65 74 21 20 77 61  !")...  (set! wa
3940: 69 74 6f 6e 20 28 66 69 6c 74 65 72 20 28 6c 61  iton (filter (la
3950: 6d 62 64 61 20 28 78 29 28 6e 6f 74 20 28 65 71  mbda (x)(not (eq
3960: 75 61 6c 3f 20 78 20 68 65 64 29 29 29 20 77 61  ual? x hed))) wa
3970: 69 74 6f 6e 73 29 29 29 29 0a 0a 09 20 20 20 20  itons))))...    
3980: 28 63 6f 6e 64 0a 09 20 20 20 20 20 28 28 6e 6f  (cond..     ((no
3990: 74 20 69 74 65 6d 73 29 20 3b 3b 20 77 68 65 6e  t items) ;; when
39a0: 20 66 61 6c 73 65 20 74 68 65 20 74 65 73 74 20   false the test 
39b0: 69 73 20 6f 6b 20 74 6f 20 62 65 20 68 61 6e 64  is ok to be hand
39c0: 65 64 20 6f 66 66 20 74 6f 20 6c 61 75 6e 63 68  ed off to launch
39d0: 20 28 62 75 74 20 6e 6f 74 20 62 65 66 6f 72 65   (but not before
39e0: 29 0a 09 20 20 20 20 20 20 28 6c 65 74 2a 20 28  )..      (let* (
39f0: 28 68 61 76 65 2d 72 65 73 6f 75 72 63 65 73 20  (have-resources 
3a00: 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65   (open-run-close
3a10: 20 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f   runs:can-run-mo
3a20: 72 65 2d 74 65 73 74 73 20 23 66 20 74 65 73 74  re-tests #f test
3a30: 2d 72 65 63 6f 72 64 29 29 20 3b 3b 20 6c 6f 6f  -record)) ;; loo
3a40: 6b 20 61 74 20 74 68 65 20 74 65 73 74 20 6a 6f  k at the test jo
3a50: 62 67 72 6f 75 70 20 61 6e 64 20 74 6f 74 20 6a  bgroup and tot j
3a60: 6f 62 73 20 72 75 6e 6e 69 6e 67 0a 09 09 20 20  obs running...  
3a70: 20 20 20 28 70 72 65 72 65 71 73 2d 6e 6f 74 2d     (prereqs-not-
3a80: 6d 65 74 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c  met (open-run-cl
3a90: 6f 73 65 20 64 62 3a 67 65 74 2d 70 72 65 72 65  ose db:get-prere
3aa0: 71 73 2d 6e 6f 74 2d 6d 65 74 20 23 66 20 72 75  qs-not-met #f ru
3ab0: 6e 2d 69 64 20 77 61 69 74 6f 6e 73 20 69 74 65  n-id waitons ite
3ac0: 6d 2d 70 61 74 68 20 6d 6f 64 65 3a 20 74 65 73  m-path mode: tes
3ad0: 74 6d 6f 64 65 29 29 0a 09 09 20 20 20 20 20 28  tmode))...     (
3ae0: 66 61 69 6c 73 20 20 20 20 20 20 20 20 20 20 20  fails           
3af0: 28 63 61 6c 63 2d 66 61 69 6c 73 20 70 72 65 72  (calc-fails prer
3b00: 65 71 73 2d 6e 6f 74 2d 6d 65 74 29 29 0a 09 09  eqs-not-met))...
3b10: 20 20 20 20 20 28 6e 6f 6e 2d 63 6f 6d 70 6c 65       (non-comple
3b20: 74 65 64 20 20 20 28 63 61 6c 63 2d 6e 6f 74 2d  ted   (calc-not-
3b30: 63 6f 6d 70 6c 65 74 65 64 20 70 72 65 72 65 71  completed prereq
3b40: 73 2d 6e 6f 74 2d 6d 65 74 29 29 29 0a 09 09 28  s-not-met)))...(
3b50: 64 65 62 75 67 3a 70 72 69 6e 74 20 38 20 22 49  debug:print 8 "I
3b60: 4e 46 4f 3a 20 68 61 76 65 2d 72 65 73 6f 75 72  NFO: have-resour
3b70: 63 65 73 3a 20 22 20 68 61 76 65 2d 72 65 73 6f  ces: " have-reso
3b80: 75 72 63 65 73 20 22 20 70 72 65 72 65 71 73 2d  urces " prereqs-
3b90: 6e 6f 74 2d 6d 65 74 3a 20 22 20 0a 09 09 09 20  not-met: " .... 
3ba0: 20 20 20 20 28 73 74 72 69 6e 67 2d 69 6e 74 65      (string-inte
3bb0: 72 73 70 65 72 73 65 20 0a 09 09 09 20 20 20 20  rsperse ....    
3bc0: 20 20 28 6d 61 70 20 28 6c 61 6d 62 64 61 20 28    (map (lambda (
3bd0: 74 29 0a 09 09 09 09 20 20 20 20 20 28 69 66 20  t).....     (if 
3be0: 28 76 65 63 74 6f 72 3f 20 74 29 0a 09 09 09 09  (vector? t).....
3bf0: 09 20 28 63 6f 6e 63 20 28 64 62 3a 74 65 73 74  . (conc (db:test
3c00: 2d 67 65 74 2d 73 74 61 74 65 20 74 29 20 22 2f  -get-state t) "/
3c10: 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 73  " (db:test-get-s
3c20: 74 61 74 75 73 20 74 29 29 0a 09 09 09 09 09 20  tatus t))...... 
3c30: 28 63 6f 6e 63 20 22 20 57 41 52 4e 49 4e 47 3a  (conc " WARNING:
3c40: 20 74 20 69 73 20 6e 6f 74 20 61 20 76 65 63 74   t is not a vect
3c50: 6f 72 3d 22 20 74 20 29 29 29 0a 09 09 09 09 20  or=" t )))..... 
3c60: 20 20 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65    prereqs-not-me
3c70: 74 29 20 22 2c 20 22 29 20 22 20 66 61 69 6c 73  t) ", ") " fails
3c80: 3a 20 22 20 66 61 69 6c 73 29 0a 09 09 3b 3b 20  : " fails)...;; 
3c90: 44 6f 6e 27 74 20 6b 6e 6f 77 20 61 74 20 74 68  Don't know at th
3ca0: 69 73 20 74 69 6d 65 20 69 66 20 74 68 65 20 74  is time if the t
3cb0: 65 73 74 20 68 61 76 65 20 62 65 65 6e 20 6c 61  est have been la
3cc0: 75 6e 63 68 65 64 20 61 74 20 73 6f 6d 65 20 74  unched at some t
3cd0: 69 6d 65 20 69 6e 20 74 68 65 20 70 61 73 74 0a  ime in the past.
3ce0: 09 09 3b 3b 20 69 2e 65 2e 20 69 73 20 74 68 69  ..;; i.e. is thi
3cf0: 73 20 61 20 72 65 2d 6c 61 75 6e 63 68 3f 0a 09  s a re-launch?..
3d00: 09 28 63 6f 6e 64 0a 09 09 20 28 28 61 6e 64 20  .(cond... ((and 
3d10: 68 61 76 65 2d 72 65 73 6f 75 72 63 65 73 0a 09  have-resources..
3d20: 09 20 20 20 20 20 20 20 28 6f 72 20 28 6e 75 6c  .       (or (nul
3d30: 6c 3f 20 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d  l? prereqs-not-m
3d40: 65 74 29 0a 09 09 09 20 20 20 28 61 6e 64 20 28  et)....   (and (
3d50: 65 71 3f 20 74 65 73 74 6d 6f 64 65 20 27 74 6f  eq? testmode 'to
3d60: 70 6c 65 76 65 6c 29 0a 09 09 09 09 28 6e 75 6c  plevel).....(nul
3d70: 6c 3f 20 6e 6f 6e 2d 63 6f 6d 70 6c 65 74 65 64  l? non-completed
3d80: 29 29 29 29 0a 09 09 20 20 3b 3b 20 6e 6f 20 6c  ))))...  ;; no l
3d90: 6f 6f 70 20 68 65 72 65 2c 20 6a 75 73 74 20 64  oop here, just d
3da0: 72 6f 70 20 74 68 6f 75 67 68 20 61 6e 64 20 75  rop though and u
3db0: 73 65 20 74 68 65 20 6c 6f 6f 70 20 61 74 20 74  se the loop at t
3dc0: 68 65 20 62 6f 74 74 6f 6d 20 0a 09 09 20 20 28  he bottom ...  (
3dd0: 69 66 20 28 70 61 74 74 2d 6c 69 73 74 2d 6d 61  if (patt-list-ma
3de0: 74 63 68 20 69 74 65 6d 2d 70 61 74 68 20 69 74  tch item-path it
3df0: 65 6d 2d 70 61 74 74 73 29 0a 09 09 20 20 20 20  em-patts)...    
3e00: 20 20 28 72 75 6e 3a 74 65 73 74 20 72 75 6e 2d    (run:test run-
3e10: 69 64 20 72 75 6e 6e 61 6d 65 20 6b 65 79 76 61  id runname keyva
3e20: 6c 6c 73 74 20 74 65 73 74 2d 72 65 63 6f 72 64  llst test-record
3e30: 20 66 6c 61 67 73 20 23 66 29 0a 09 09 20 20 20   flags #f)...   
3e40: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
3e50: 31 20 22 49 4e 46 4f 3a 20 53 6b 69 70 70 69 6e  1 "INFO: Skippin
3e60: 67 20 22 20 28 74 65 73 74 73 3a 74 65 73 74 71  g " (tests:testq
3e70: 75 65 75 65 2d 67 65 74 2d 74 65 73 74 6e 61 6d  ueue-get-testnam
3e80: 65 20 74 65 73 74 2d 72 65 63 6f 72 64 29 20 22  e test-record) "
3e90: 20 22 20 69 74 65 6d 2d 70 61 74 68 20 22 20 61   " item-path " a
3ea0: 73 20 69 74 20 64 6f 65 73 6e 27 74 20 6d 61 74  s it doesn't mat
3eb0: 63 68 20 22 20 69 74 65 6d 2d 70 61 74 74 73 29  ch " item-patts)
3ec0: 29 0a 09 09 20 20 3b 3b 20 65 6c 73 65 20 74 68  )...  ;; else th
3ed0: 65 20 72 75 6e 20 69 73 20 73 74 75 63 6b 2c 20  e run is stuck, 
3ee0: 74 65 6d 70 6f 72 61 72 69 6c 79 20 6f 72 20 70  temporarily or p
3ef0: 65 72 6d 61 6e 65 6e 74 6c 79 0a 09 09 20 20 3b  ermanently...  ;
3f00: 3b 20 62 75 74 20 73 68 6f 75 6c 64 20 63 68 65  ; but should che
3f10: 63 6b 20 69 66 20 69 74 20 69 73 20 64 75 65 20  ck if it is due 
3f20: 74 6f 20 6c 61 63 6b 20 6f 66 20 72 65 73 6f 75  to lack of resou
3f30: 72 63 65 73 20 76 73 2e 20 70 72 65 72 65 71 75  rces vs. prerequ
3f40: 69 73 69 74 65 73 0a 09 09 20 20 29 0a 09 09 20  isites...  )... 
3f50: 28 28 6e 6f 74 20 68 61 76 65 2d 72 65 73 6f 75  ((not have-resou
3f60: 72 63 65 73 29 20 3b 3b 20 73 69 6d 70 6c 79 20  rces) ;; simply 
3f70: 74 72 79 20 61 67 61 69 6e 20 61 66 74 65 72 20  try again after 
3f80: 77 61 69 74 69 6e 67 20 61 20 73 65 63 6f 6e 64  waiting a second
3f90: 0a 09 09 20 20 28 74 68 72 65 61 64 2d 73 6c 65  ...  (thread-sle
3fa0: 65 70 21 20 28 2b 20 31 20 2a 67 6c 6f 62 61 6c  ep! (+ 1 *global
3fb0: 2d 64 65 6c 74 61 2a 29 29 0a 09 09 20 20 28 64  -delta*))...  (d
3fc0: 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 49 4e  ebug:print 1 "IN
3fd0: 46 4f 3a 20 6e 6f 20 72 65 73 6f 75 72 63 65 73  FO: no resources
3fe0: 20 74 6f 20 72 75 6e 20 6e 65 77 20 74 65 73 74   to run new test
3ff0: 73 2c 20 77 61 69 74 69 6e 67 20 2e 2e 2e 22 29  s, waiting ...")
4000: 0a 09 09 20 20 3b 3b 20 63 6f 75 6c 64 20 68 61  ...  ;; could ha
4010: 76 65 20 64 6f 6e 65 20 68 65 64 20 74 61 6c 20  ve done hed tal 
4020: 68 65 72 65 20 62 75 74 20 64 6f 69 6e 67 20 63  here but doing c
4030: 61 72 2f 63 64 72 20 6f 66 20 6e 65 77 74 61 6c  ar/cdr of newtal
4040: 20 74 6f 20 72 6f 74 61 74 65 20 74 65 73 74 73   to rotate tests
4050: 0a 09 09 20 20 28 6c 6f 6f 70 20 28 63 61 72 20  ...  (loop (car 
4060: 6e 65 77 74 61 6c 29 28 63 64 72 20 6e 65 77 74  newtal)(cdr newt
4070: 61 6c 29 29 29 0a 09 09 20 28 65 6c 73 65 20 3b  al)))... (else ;
4080: 3b 20 6d 75 73 74 20 62 65 20 77 65 20 68 61 76  ; must be we hav
4090: 65 20 75 6e 6d 65 74 20 70 72 65 72 65 71 75 69  e unmet prerequi
40a0: 73 69 74 65 73 0a 09 09 20 20 20 20 28 64 65 62  sites...    (deb
40b0: 75 67 3a 70 72 69 6e 74 20 34 20 22 46 41 49 4c  ug:print 4 "FAIL
40c0: 53 3a 20 22 20 66 61 69 6c 73 29 0a 09 09 20 20  S: " fails)...  
40d0: 20 20 3b 3b 20 49 66 20 6f 6e 65 20 6f 72 20 6d    ;; If one or m
40e0: 6f 72 65 20 6f 66 20 74 68 65 20 70 72 65 72 65  ore of the prere
40f0: 71 73 2d 6e 6f 74 2d 6d 65 74 20 61 72 65 20 46  qs-not-met are F
4100: 41 49 4c 20 74 68 65 6e 20 77 65 20 63 61 6e 20  AIL then we can 
4110: 69 73 73 75 65 0a 09 09 20 20 20 20 3b 3b 20 61  issue...    ;; a
4120: 20 6d 65 73 73 61 67 65 20 61 6e 64 20 64 72 6f   message and dro
4130: 70 20 68 65 64 20 66 72 6f 6d 20 74 68 65 20 69  p hed from the i
4140: 74 65 6d 73 20 74 6f 20 62 65 20 70 72 6f 63 65  tems to be proce
4150: 73 73 65 64 2e 0a 09 09 20 20 20 20 28 69 66 20  ssed....    (if 
4160: 28 6e 75 6c 6c 3f 20 66 61 69 6c 73 29 0a 09 09  (null? fails)...
4170: 09 28 62 65 67 69 6e 0a 09 09 09 20 20 3b 3b 20  .(begin....  ;; 
4180: 63 6f 75 6c 64 6e 27 74 20 72 75 6e 2c 20 74 61  couldn't run, ta
4190: 6b 65 20 61 20 62 72 65 61 74 68 65 72 0a 09 09  ke a breather...
41a0: 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20  .  (debug:print 
41b0: 34 20 22 49 4e 46 4f 3a 20 53 68 6f 75 6c 64 6e  4 "INFO: Shouldn
41c0: 27 74 20 72 65 61 6c 6c 79 20 67 65 74 20 68 65  't really get he
41d0: 72 65 2c 20 72 61 63 65 20 63 6f 6e 64 69 74 69  re, race conditi
41e0: 6f 6e 3f 20 55 6e 61 62 6c 65 20 74 6f 20 6c 61  on? Unable to la
41f0: 75 6e 63 68 20 6d 6f 72 65 20 74 65 73 74 73 20  unch more tests 
4200: 61 74 20 74 68 69 73 20 6d 6f 6d 65 6e 74 2c 20  at this moment, 
4210: 6b 69 6c 6c 69 6e 67 20 74 69 6d 65 20 2e 2e 2e  killing time ...
4220: 22 29 0a 09 09 09 20 20 28 74 68 72 65 61 64 2d  ")....  (thread-
4230: 73 6c 65 65 70 21 20 28 2b 20 31 20 2a 67 6c 6f  sleep! (+ 1 *glo
4240: 62 61 6c 2d 64 65 6c 74 61 2a 29 29 20 3b 3b 20  bal-delta*)) ;; 
4250: 6c 6f 6e 67 20 73 6c 65 65 70 20 68 65 72 65 20  long sleep here 
4260: 2d 20 6e 6f 20 72 65 73 6f 75 72 63 65 73 2c 20  - no resources, 
4270: 6d 61 79 20 61 73 20 77 65 6c 6c 20 62 65 20 70  may as well be p
4280: 61 74 69 65 6e 74 0a 09 09 09 20 20 3b 3b 20 77  atient....  ;; w
4290: 65 20 6d 61 64 65 20 6e 65 77 20 74 61 6c 20 62  e made new tal b
42a0: 79 20 73 74 69 63 6b 69 6e 67 20 68 65 64 20 61  y sticking hed a
42b0: 74 20 74 68 65 20 62 61 63 6b 20 6f 66 20 74 68  t the back of th
42c0: 65 20 6c 69 73 74 0a 09 09 09 20 20 28 6c 6f 6f  e list....  (loo
42d0: 70 20 28 63 61 72 20 6e 65 77 74 61 6c 29 28 63  p (car newtal)(c
42e0: 64 72 20 6e 65 77 74 61 6c 29 29 29 0a 09 09 09  dr newtal)))....
42f0: 3b 3b 20 74 68 65 20 77 61 69 74 6f 6e 20 69 73  ;; the waiton is
4300: 20 46 41 49 4c 20 73 6f 20 6e 6f 20 70 6f 69 6e   FAIL so no poin
4310: 74 20 69 6e 20 74 72 79 69 6e 67 20 74 6f 20 72  t in trying to r
4320: 75 6e 20 68 65 64 20 65 76 65 72 20 61 67 61 69  un hed ever agai
4330: 6e 0a 09 09 09 28 69 66 20 28 6e 6f 74 20 28 6e  n....(if (not (n
4340: 75 6c 6c 3f 20 74 61 6c 29 29 0a 09 09 09 20 20  ull? tal))....  
4350: 20 20 28 69 66 20 28 76 65 63 74 6f 72 3f 20 68    (if (vector? h
4360: 65 64 29 0a 09 09 09 09 28 62 65 67 69 6e 20 28  ed).....(begin (
4370: 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 57  debug:print 1 "W
4380: 41 52 4e 3a 20 44 72 6f 70 70 69 6e 67 20 74 65  ARN: Dropping te
4390: 73 74 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65  st " (db:test-ge
43a0: 74 2d 74 65 73 74 6e 61 6d 65 20 68 65 64 29 20  t-testname hed) 
43b0: 22 2f 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74  "/" (db:test-get
43c0: 2d 69 74 65 6d 2d 70 61 74 68 20 68 65 64 29 0a  -item-path hed).
43d0: 09 09 09 09 09 09 20 20 20 20 22 20 66 72 6f 6d  ......    " from
43e0: 20 74 68 65 20 6c 61 75 6e 63 68 20 6c 69 73 74   the launch list
43f0: 20 61 73 20 69 74 20 68 61 73 20 70 72 65 72 65   as it has prere
4400: 71 75 69 73 74 65 73 20 74 68 61 74 20 61 72 65  quistes that are
4410: 20 46 41 49 4c 22 29 0a 09 09 09 09 20 20 20 20   FAIL").....    
4420: 20 20 20 28 6c 6f 6f 70 20 28 63 61 72 20 74 61     (loop (car ta
4430: 6c 29 28 63 64 72 20 74 61 6c 29 29 29 0a 09 09  l)(cdr tal)))...
4440: 09 09 28 62 65 67 69 6e 0a 09 09 09 09 20 20 28  ..(begin.....  (
4450: 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 57  debug:print 1 "W
4460: 41 52 4e 3a 20 54 65 73 74 20 6e 6f 74 20 70 72  ARN: Test not pr
4470: 6f 63 65 73 73 65 64 20 63 6f 72 72 65 63 74 6c  ocessed correctl
4480: 79 3f 20 22 20 68 65 64 29 20 3b 3b 20 20 22 20  y? " hed) ;;  " 
4490: 61 73 20 69 74 20 68 61 73 20 70 72 65 72 65 71  as it has prereq
44a0: 75 69 73 74 65 73 20 74 68 61 74 20 61 72 65 20  uistes that are 
44b0: 46 41 49 4c 2e 20 28 4e 4f 54 45 3a 20 68 65 64  FAIL. (NOTE: hed
44c0: 20 69 73 20 6e 6f 74 20 61 20 76 65 63 74 6f 72   is not a vector
44d0: 29 22 29 0a 09 09 09 09 20 20 28 6c 6f 6f 70 20  )").....  (loop 
44e0: 68 65 64 20 74 61 6c 29 29 29 29 29 29 29 29 29  hed tal)))))))))
44f0: 0a 09 20 20 20 20 20 0a 09 20 20 20 20 20 3b 3b  ..     ..     ;;
4500: 20 63 61 73 65 20 77 68 65 72 65 20 61 6e 20 69   case where an i
4510: 74 65 6d 73 20 63 61 6d 65 20 69 6e 20 61 73 20  tems came in as 
4520: 61 20 6c 69 73 74 20 62 65 65 6e 20 70 72 6f 63  a list been proc
4530: 65 73 73 65 64 0a 09 20 20 20 20 20 28 28 61 6e  essed..     ((an
4540: 64 20 28 6c 69 73 74 3f 20 69 74 65 6d 73 29 20  d (list? items) 
4550: 20 20 20 20 3b 3b 20 74 68 75 73 20 77 65 20 6b      ;; thus we k
4560: 6e 6f 77 20 6f 75 72 20 69 74 65 6d 73 20 61 72  now our items ar
4570: 65 20 61 6c 72 65 61 64 79 20 63 61 6c 63 75 6c  e already calcul
4580: 61 74 65 64 0a 09 09 20 20 20 28 6e 6f 74 20 20  ated...   (not  
4590: 20 69 74 65 6d 64 61 74 29 29 20 3b 3b 20 61 6e   itemdat)) ;; an
45a0: 64 20 6e 6f 74 20 79 65 74 20 65 78 70 61 6e 64  d not yet expand
45b0: 65 64 20 69 6e 74 6f 20 74 68 65 20 6c 69 73 74  ed into the list
45c0: 20 6f 66 20 74 68 69 6e 67 73 20 74 6f 20 62 65   of things to be
45d0: 20 64 6f 6e 65 0a 09 20 20 20 20 20 20 28 69 66   done..      (if
45e0: 20 28 61 6e 64 20 28 3e 3d 20 2a 76 65 72 62 6f   (and (>= *verbo
45f0: 73 69 74 79 2a 20 31 29 0a 09 09 20 20 20 20 20  sity* 1)...     
4600: 20 20 28 3e 20 28 6c 65 6e 67 74 68 20 69 74 65    (> (length ite
4610: 6d 73 29 20 30 29 0a 09 09 20 20 20 20 20 20 20  ms) 0)...       
4620: 28 3e 20 28 6c 65 6e 67 74 68 20 28 63 61 72 20  (> (length (car 
4630: 69 74 65 6d 73 29 29 20 30 29 29 0a 09 09 20 20  items)) 0))...  
4640: 28 70 70 20 69 74 65 6d 73 29 29 0a 09 20 20 20  (pp items))..   
4650: 20 20 20 3b 3b 20 28 69 66 20 28 3e 3d 20 2a 76     ;; (if (>= *v
4660: 65 72 62 6f 73 69 74 79 2a 20 35 29 0a 09 20 20  erbosity* 5)..  
4670: 20 20 20 20 3b 3b 20 20 20 20 20 28 62 65 67 69      ;;     (begi
4680: 6e 0a 09 20 20 20 20 20 20 3b 3b 20 20 20 20 20  n..      ;;     
4690: 20 20 28 70 72 69 6e 74 20 22 69 74 65 6d 73 3a    (print "items:
46a0: 20 22 29 20 20 20 20 20 28 70 70 20 28 69 74 65   ")     (pp (ite
46b0: 6d 2d 61 73 73 6f 63 2d 3e 69 74 65 6d 2d 6c 69  m-assoc->item-li
46c0: 73 74 20 69 74 65 6d 73 29 29 0a 09 20 20 20 20  st items))..    
46d0: 20 20 3b 3b 20 20 20 20 20 20 20 28 70 72 69 6e    ;;       (prin
46e0: 74 20 22 69 74 65 6d 73 74 61 62 6c 65 3a 20 22  t "itemstable: "
46f0: 29 28 70 70 20 28 69 74 65 6d 2d 74 61 62 6c 65  )(pp (item-table
4700: 2d 3e 69 74 65 6d 2d 6c 69 73 74 20 69 74 65 6d  ->item-list item
4710: 73 74 61 62 6c 65 29 29 29 29 0a 09 20 20 20 20  stable))))..    
4720: 20 20 28 66 6f 72 2d 65 61 63 68 0a 09 20 20 20    (for-each..   
4730: 20 20 20 20 28 6c 61 6d 62 64 61 20 28 6d 79 2d      (lambda (my-
4740: 69 74 65 6d 64 61 74 29 0a 09 09 20 28 6c 65 74  itemdat)... (let
4750: 2a 20 28 28 6e 65 77 2d 74 65 73 74 2d 72 65 63  * ((new-test-rec
4760: 6f 72 64 20 28 6c 65 74 20 28 28 6e 65 77 72 65  ord (let ((newre
4770: 63 20 28 6d 61 6b 65 2d 74 65 73 74 73 3a 74 65  c (make-tests:te
4780: 73 74 71 75 65 75 65 29 29 29 0a 09 09 09 09 09  stqueue)))......
4790: 20 20 20 28 76 65 63 74 6f 72 2d 63 6f 70 79 21     (vector-copy!
47a0: 20 74 65 73 74 2d 72 65 63 6f 72 64 20 6e 65 77   test-record new
47b0: 72 65 63 29 0a 09 09 09 09 09 20 20 20 6e 65 77  rec)......   new
47c0: 72 65 63 29 29 0a 09 09 09 28 6d 79 2d 69 74 65  rec))....(my-ite
47d0: 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c 69 73  m-path (item-lis
47e0: 74 2d 3e 70 61 74 68 20 6d 79 2d 69 74 65 6d 64  t->path my-itemd
47f0: 61 74 29 29 29 0a 09 09 20 20 20 28 69 66 20 28  at)))...   (if (
4800: 70 61 74 74 2d 6c 69 73 74 2d 6d 61 74 63 68 20  patt-list-match 
4810: 6d 79 2d 69 74 65 6d 2d 70 61 74 68 20 69 74 65  my-item-path ite
4820: 6d 2d 70 61 74 74 73 29 20 20 20 20 20 20 20 20  m-patts)        
4830: 20 20 20 3b 3b 20 79 65 73 2c 20 77 65 20 77 61     ;; yes, we wa
4840: 6e 74 20 74 6f 20 70 72 6f 63 65 73 73 20 74 68  nt to process th
4850: 69 73 20 69 74 65 6d 2c 20 4e 4f 54 45 3a 20 53  is item, NOTE: S
4860: 68 6f 75 6c 64 20 6e 6f 74 20 6e 65 65 64 20 74  hould not need t
4870: 68 69 73 20 63 68 65 63 6b 20 68 65 72 65 21 0a  his check here!.
4880: 09 09 20 20 20 20 20 20 20 28 6c 65 74 20 28 28  ..       (let ((
4890: 6e 65 77 74 65 73 74 6e 61 6d 65 20 28 63 6f 6e  newtestname (con
48a0: 63 20 68 65 64 20 22 2f 22 20 6d 79 2d 69 74 65  c hed "/" my-ite
48b0: 6d 2d 70 61 74 68 29 29 29 20 20 20 20 3b 3b 20  m-path)))    ;; 
48c0: 74 65 73 74 20 6e 61 6d 65 73 20 61 72 65 20 75  test names are u
48d0: 6e 69 71 75 65 20 6f 6e 20 74 65 73 74 6e 61 6d  nique on testnam
48e0: 65 2f 69 74 65 6d 2d 70 61 74 68 0a 09 09 09 20  e/item-path.... 
48f0: 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65  (tests:testqueue
4900: 2d 73 65 74 2d 69 74 65 6d 73 21 20 20 20 20 20  -set-items!     
4910: 6e 65 77 2d 74 65 73 74 2d 72 65 63 6f 72 64 20  new-test-record 
4920: 23 66 29 0a 09 09 09 20 28 74 65 73 74 73 3a 74  #f).... (tests:t
4930: 65 73 74 71 75 65 75 65 2d 73 65 74 2d 69 74 65  estqueue-set-ite
4940: 6d 64 61 74 21 20 20 20 6e 65 77 2d 74 65 73 74  mdat!   new-test
4950: 2d 72 65 63 6f 72 64 20 6d 79 2d 69 74 65 6d 64  -record my-itemd
4960: 61 74 29 0a 09 09 09 20 28 74 65 73 74 73 3a 74  at).... (tests:t
4970: 65 73 74 71 75 65 75 65 2d 73 65 74 2d 69 74 65  estqueue-set-ite
4980: 6d 5f 70 61 74 68 21 20 6e 65 77 2d 74 65 73 74  m_path! new-test
4990: 2d 72 65 63 6f 72 64 20 6d 79 2d 69 74 65 6d 2d  -record my-item-
49a0: 70 61 74 68 29 0a 09 09 09 20 28 68 61 73 68 2d  path).... (hash-
49b0: 74 61 62 6c 65 2d 73 65 74 21 20 74 65 73 74 2d  table-set! test-
49c0: 72 65 63 6f 72 64 73 20 6e 65 77 74 65 73 74 6e  records newtestn
49d0: 61 6d 65 20 6e 65 77 2d 74 65 73 74 2d 72 65 63  ame new-test-rec
49e0: 6f 72 64 29 0a 09 09 09 20 28 73 65 74 21 20 74  ord).... (set! t
49f0: 61 6c 20 28 63 6f 6e 73 20 6e 65 77 74 65 73 74  al (cons newtest
4a00: 6e 61 6d 65 20 74 61 6c 29 29 29 29 29 29 20 3b  name tal)))))) ;
4a10: 3b 20 73 69 6e 63 65 20 74 68 65 73 65 20 61 72  ; since these ar
4a20: 65 20 69 74 65 6d 69 7a 65 64 20 63 72 65 61 74  e itemized creat
4a30: 65 20 6e 65 77 20 74 65 73 74 20 6e 61 6d 65 73  e new test names
4a40: 20 74 65 73 74 6e 61 6d 65 2f 69 74 65 6d 70 61   testname/itempa
4a50: 74 68 0a 09 20 20 20 20 20 20 20 69 74 65 6d 73  th..       items
4a60: 29 0a 09 20 20 20 20 20 20 28 69 66 20 28 6e 6f  )..      (if (no
4a70: 74 20 28 6e 75 6c 6c 3f 20 74 61 6c 29 29 0a 09  t (null? tal))..
4a80: 09 20 20 28 6c 6f 6f 70 20 28 63 61 72 20 74 61  .  (loop (car ta
4a90: 6c 29 28 63 64 72 20 74 61 6c 29 29 29 29 0a 0a  l)(cdr tal))))..
4aa0: 09 20 20 20 20 20 3b 3b 20 69 66 20 69 74 65 6d  .     ;; if item
4ab0: 73 20 69 73 20 61 20 70 72 6f 63 20 74 68 65 6e  s is a proc then
4ac0: 20 6e 65 65 64 20 74 6f 20 72 75 6e 20 69 74 65   need to run ite
4ad0: 6d 73 3a 67 65 74 2d 69 74 65 6d 73 2d 66 72 6f  ms:get-items-fro
4ae0: 6d 2d 63 6f 6e 66 69 67 2c 20 67 65 74 20 74 68  m-config, get th
4af0: 65 20 6c 69 73 74 20 61 6e 64 20 6c 6f 6f 70 20  e list and loop 
4b00: 0a 09 20 20 20 20 20 3b 3b 20 20 20 20 2d 20 62  ..     ;;    - b
4b10: 75 74 20 6f 6e 6c 79 20 64 6f 20 74 68 61 74 20  ut only do that 
4b20: 69 66 20 72 65 73 6f 75 72 63 65 73 20 65 78 69  if resources exi
4b30: 73 74 20 74 6f 20 6b 69 63 6b 20 6f 66 66 20 74  st to kick off t
4b40: 68 65 20 6a 6f 62 0a 09 20 20 20 20 20 28 28 6f  he job..     ((o
4b50: 72 20 28 70 72 6f 63 65 64 75 72 65 3f 20 69 74  r (procedure? it
4b60: 65 6d 73 29 28 65 71 3f 20 69 74 65 6d 73 20 27  ems)(eq? items '
4b70: 68 61 76 65 2d 70 72 6f 63 65 64 75 72 65 29 29  have-procedure))
4b80: 0a 09 20 20 20 20 20 20 28 6c 65 74 20 28 28 63  ..      (let ((c
4b90: 61 6e 2d 72 75 6e 2d 6d 6f 72 65 20 20 20 20 28  an-run-more    (
4ba0: 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 72  open-run-close r
4bb0: 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65  uns:can-run-more
4bc0: 2d 74 65 73 74 73 20 23 66 20 74 65 73 74 2d 72  -tests #f test-r
4bd0: 65 63 6f 72 64 29 29 29 0a 09 09 28 69 66 20 63  ecord)))...(if c
4be0: 61 6e 2d 72 75 6e 2d 6d 6f 72 65 0a 09 09 20 20  an-run-more...  
4bf0: 20 20 28 6c 65 74 2a 20 28 28 70 72 65 72 65 71    (let* ((prereq
4c00: 73 2d 6e 6f 74 2d 6d 65 74 20 28 6f 70 65 6e 2d  s-not-met (open-
4c10: 72 75 6e 2d 63 6c 6f 73 65 20 64 62 3a 67 65 74  run-close db:get
4c20: 2d 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74  -prereqs-not-met
4c30: 20 23 66 20 72 75 6e 2d 69 64 20 77 61 69 74 6f   #f run-id waito
4c40: 6e 73 20 69 74 65 6d 2d 70 61 74 68 20 6d 6f 64  ns item-path mod
4c50: 65 3a 20 74 65 73 74 6d 6f 64 65 29 29 0a 09 09  e: testmode))...
4c60: 09 20 20 20 28 66 61 69 6c 73 20 20 20 20 20 20  .   (fails      
4c70: 20 20 20 20 20 28 63 61 6c 63 2d 66 61 69 6c 73       (calc-fails
4c80: 20 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74   prereqs-not-met
4c90: 29 29 0a 09 09 09 20 20 20 28 6e 6f 6e 2d 63 6f  ))....   (non-co
4ca0: 6d 70 6c 65 74 65 64 20 20 20 28 63 61 6c 63 2d  mpleted   (calc-
4cb0: 6e 6f 74 2d 63 6f 6d 70 6c 65 74 65 64 20 70 72  not-completed pr
4cc0: 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 29 29 29  ereqs-not-met)))
4cd0: 0a 09 09 20 20 20 20 20 20 28 64 65 62 75 67 3a  ...      (debug:
4ce0: 70 72 69 6e 74 20 38 20 22 49 4e 46 4f 3a 20 63  print 8 "INFO: c
4cf0: 61 6e 2d 72 75 6e 2d 6d 6f 72 65 3a 20 22 20 63  an-run-more: " c
4d00: 61 6e 2d 72 75 6e 2d 6d 6f 72 65 0a 09 09 09 09  an-run-more.....
4d10: 20 20 20 22 5c 6e 20 70 72 65 72 65 71 73 2d 6e     "\n prereqs-n
4d20: 6f 74 2d 6d 65 74 3a 20 22 20 28 70 72 65 74 74  ot-met: " (prett
4d30: 79 2d 73 74 72 69 6e 67 20 70 72 65 72 65 71 73  y-string prereqs
4d40: 2d 6e 6f 74 2d 6d 65 74 29 0a 09 09 09 09 20 20  -not-met).....  
4d50: 20 22 5c 6e 20 6e 6f 6e 2d 63 6f 6d 70 6c 65 74   "\n non-complet
4d60: 65 64 3a 20 20 20 22 20 28 70 72 65 74 74 79 2d  ed:   " (pretty-
4d70: 73 74 72 69 6e 67 20 6e 6f 6e 2d 63 6f 6d 70 6c  string non-compl
4d80: 65 74 65 64 29 20 0a 09 09 09 09 20 20 20 22 5c  eted) .....   "\
4d90: 6e 20 66 61 69 6c 73 3a 20 20 20 20 20 20 20 20  n fails:        
4da0: 20 20 20 22 20 28 70 72 65 74 74 79 2d 73 74 72     " (pretty-str
4db0: 69 6e 67 20 66 61 69 6c 73 29 0a 09 09 09 09 20  ing fails)..... 
4dc0: 20 20 22 5c 6e 20 74 65 73 74 6d 6f 64 65 3a 20    "\n testmode: 
4dd0: 20 20 20 20 20 20 20 22 20 74 65 73 74 6d 6f 64         " testmod
4de0: 65 0a 09 09 09 09 20 20 20 22 5c 6e 20 28 65 71  e.....   "\n (eq
4df0: 3f 20 74 65 73 74 6d 6f 64 65 20 27 74 6f 70 6c  ? testmode 'topl
4e00: 65 76 65 6c 29 20 22 20 28 65 71 3f 20 74 65 73  evel) " (eq? tes
4e10: 74 6d 6f 64 65 20 27 74 6f 70 6c 65 76 65 6c 29  tmode 'toplevel)
4e20: 0a 09 09 09 09 20 20 20 22 5c 6e 20 28 6e 75 6c  .....   "\n (nul
4e30: 6c 3f 20 6e 6f 6e 2d 63 6f 6d 70 6c 65 74 65 64  l? non-completed
4e40: 29 20 20 20 20 22 20 28 6e 75 6c 6c 3f 20 6e 6f  )    " (null? no
4e50: 6e 2d 63 6f 6d 70 6c 65 74 65 64 29 29 0a 09 09  n-completed))...
4e60: 20 20 20 20 20 20 28 63 6f 6e 64 20 0a 09 09 20        (cond ... 
4e70: 20 20 20 20 20 20 28 28 6f 72 20 28 6e 75 6c 6c        ((or (null
4e80: 3f 20 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65  ? prereqs-not-me
4e90: 74 29 20 3b 3b 20 61 6c 6c 20 70 72 65 72 65 71  t) ;; all prereq
4ea0: 73 20 6d 65 74 2c 20 66 69 72 65 20 6f 66 66 20  s met, fire off 
4eb0: 74 68 65 20 74 65 73 74 0a 09 09 09 20 20 20 20  the test....    
4ec0: 3b 3b 20 6f 72 2c 20 69 66 20 69 74 20 69 73 20  ;; or, if it is 
4ed0: 61 20 27 74 6f 70 6c 65 76 65 6c 20 74 65 73 74  a 'toplevel test
4ee0: 20 61 6e 64 20 61 6c 6c 20 70 72 65 72 65 71 73   and all prereqs
4ef0: 20 6e 6f 74 20 6d 65 74 20 61 72 65 20 43 4f 4d   not met are COM
4f00: 50 4c 45 54 45 44 20 74 68 65 6e 20 6c 61 75 6e  PLETED then laun
4f10: 63 68 0a 09 09 09 20 20 20 20 28 61 6e 64 20 28  ch....    (and (
4f20: 65 71 3f 20 74 65 73 74 6d 6f 64 65 20 27 74 6f  eq? testmode 'to
4f30: 70 6c 65 76 65 6c 29 0a 09 09 09 09 20 28 6e 75  plevel)..... (nu
4f40: 6c 6c 3f 20 6e 6f 6e 2d 63 6f 6d 70 6c 65 74 65  ll? non-complete
4f50: 64 29 29 29 0a 09 09 09 28 6c 65 74 20 28 28 74  d)))....(let ((t
4f60: 65 73 74 2d 6e 61 6d 65 20 28 74 65 73 74 73 3a  est-name (tests:
4f70: 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d 74 65  testqueue-get-te
4f80: 73 74 6e 61 6d 65 20 74 65 73 74 2d 72 65 63 6f  stname test-reco
4f90: 72 64 29 29 29 0a 09 09 09 20 20 28 73 65 74 65  rd)))....  (sete
4fa0: 6e 76 20 22 4d 54 5f 54 45 53 54 5f 4e 41 4d 45  nv "MT_TEST_NAME
4fb0: 22 20 74 65 73 74 2d 6e 61 6d 65 29 20 3b 3b 20  " test-name) ;; 
4fc0: 0a 09 09 09 20 20 28 73 65 74 65 6e 76 20 22 4d  ....  (setenv "M
4fd0: 54 5f 52 55 4e 4e 41 4d 45 22 20 20 20 72 75 6e  T_RUNNAME"   run
4fe0: 6e 61 6d 65 29 0a 09 09 09 20 20 28 6f 70 65 6e  name)....  (open
4ff0: 2d 72 75 6e 2d 63 6c 6f 73 65 2d 6d 65 61 73 75  -run-close-measu
5000: 72 65 20 73 65 74 2d 6d 65 67 61 74 65 73 74 2d  re set-megatest-
5010: 65 6e 76 2d 76 61 72 73 20 23 66 20 72 75 6e 2d  env-vars #f run-
5020: 69 64 29 20 3b 3b 20 74 68 65 73 65 20 6d 61 79  id) ;; these may
5030: 20 62 65 20 6e 65 65 64 65 64 20 62 79 20 74 68   be needed by th
5040: 65 20 6c 61 75 6e 63 68 69 6e 67 20 70 72 6f 63  e launching proc
5050: 65 73 73 0a 09 09 09 20 20 28 6c 65 74 20 28 28  ess....  (let ((
5060: 69 74 65 6d 73 2d 6c 69 73 74 20 28 69 74 65 6d  items-list (item
5070: 73 3a 67 65 74 2d 69 74 65 6d 73 2d 66 72 6f 6d  s:get-items-from
5080: 2d 63 6f 6e 66 69 67 20 74 63 6f 6e 66 69 67 29  -config tconfig)
5090: 29 29 0a 09 09 09 20 20 20 20 28 69 66 20 28 6c  ))....    (if (l
50a0: 69 73 74 3f 20 69 74 65 6d 73 2d 6c 69 73 74 29  ist? items-list)
50b0: 0a 09 09 09 09 28 62 65 67 69 6e 0a 09 09 09 09  .....(begin.....
50c0: 20 20 28 74 65 73 74 73 3a 74 65 73 74 71 75 65    (tests:testque
50d0: 75 65 2d 73 65 74 2d 69 74 65 6d 73 21 20 74 65  ue-set-items! te
50e0: 73 74 2d 72 65 63 6f 72 64 20 69 74 65 6d 73 2d  st-record items-
50f0: 6c 69 73 74 29 0a 09 09 09 09 20 20 28 6c 6f 6f  list).....  (loo
5100: 70 20 68 65 64 20 74 61 6c 29 29 0a 09 09 09 09  p hed tal)).....
5110: 28 62 65 67 69 6e 0a 09 09 09 09 20 20 28 64 65  (begin.....  (de
5120: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52  bug:print 0 "ERR
5130: 4f 52 3a 20 54 68 65 20 70 72 6f 63 20 66 72 6f  OR: The proc fro
5140: 6d 20 72 65 61 64 69 6e 67 20 74 68 65 20 73 65  m reading the se
5150: 74 75 70 20 64 69 64 20 6e 6f 74 20 79 69 65 6c  tup did not yiel
5160: 64 20 61 20 6c 69 73 74 20 2d 20 70 6c 65 61 73  d a list - pleas
5170: 65 20 72 65 70 6f 72 74 20 74 68 69 73 22 29 0a  e report this").
5180: 09 09 09 09 20 20 28 65 78 69 74 20 31 29 29 29  ....  (exit 1)))
5190: 29 29 29 0a 09 09 20 20 20 20 20 20 20 28 28 6e  )))...       ((n
51a0: 75 6c 6c 3f 20 66 61 69 6c 73 29 0a 09 09 09 28  ull? fails)....(
51b0: 6c 6f 6f 70 20 28 63 61 72 20 6e 65 77 74 61 6c  loop (car newtal
51c0: 29 28 63 64 72 20 6e 65 77 74 61 6c 29 29 29 20  )(cdr newtal))) 
51d0: 3b 3b 20 61 6e 20 69 73 73 75 65 20 77 69 74 68  ;; an issue with
51e0: 20 70 72 65 72 65 71 73 20 6e 6f 74 20 79 65 74   prereqs not yet
51f0: 20 6d 65 74 3f 0a 09 09 20 20 20 20 20 20 20 28   met?...       (
5200: 28 61 6e 64 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f  (and (not (null?
5210: 20 66 61 69 6c 73 29 29 28 65 71 3f 20 74 65 73   fails))(eq? tes
5220: 74 6d 6f 64 65 20 27 6e 6f 72 6d 61 6c 29 29 0a  tmode 'normal)).
5230: 09 09 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20  ...(debug:print 
5240: 31 20 22 49 4e 46 4f 3a 20 74 65 73 74 20 22 20  1 "INFO: test " 
5250: 20 68 65 64 20 22 20 28 6d 6f 64 65 3d 22 20 74   hed " (mode=" t
5260: 65 73 74 6d 6f 64 65 20 22 29 20 68 61 73 20 66  estmode ") has f
5270: 61 69 6c 65 64 20 70 72 65 72 65 71 75 69 73 69  ailed prerequisi
5280: 74 65 28 73 29 3b 20 22 0a 09 09 09 09 20 20 20  te(s); ".....   
5290: 20 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73    (string-inters
52a0: 70 65 72 73 65 20 28 6d 61 70 20 28 6c 61 6d 62  perse (map (lamb
52b0: 64 61 20 28 74 29 28 63 6f 6e 63 20 28 64 62 3a  da (t)(conc (db:
52c0: 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d  test-get-testnam
52d0: 65 20 74 29 20 22 3a 22 20 28 64 62 3a 74 65 73  e t) ":" (db:tes
52e0: 74 2d 67 65 74 2d 73 74 61 74 65 20 74 29 22 2f  t-get-state t)"/
52f0: 22 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 73 74  "(db:test-get-st
5300: 61 74 75 73 20 74 29 29 29 20 66 61 69 6c 73 29  atus t))) fails)
5310: 20 22 2c 20 22 29 0a 09 09 09 09 20 20 20 20 20   ", ").....     
5320: 22 2c 20 72 65 6d 6f 76 69 6e 67 20 69 74 20 66  ", removing it f
5330: 72 6f 6d 20 74 6f 2d 64 6f 20 6c 69 73 74 22 29  rom to-do list")
5340: 0a 09 09 09 28 69 66 20 28 6e 6f 74 20 28 6e 75  ....(if (not (nu
5350: 6c 6c 3f 20 74 61 6c 29 29 0a 09 09 09 20 20 20  ll? tal))....   
5360: 20 28 6c 6f 6f 70 20 28 63 61 72 20 74 61 6c 29   (loop (car tal)
5370: 28 63 64 72 20 74 61 6c 29 29 29 29 0a 09 09 20  (cdr tal))))... 
5380: 20 20 20 20 20 20 28 65 6c 73 65 0a 09 09 09 28        (else....(
5390: 64 65 62 75 67 3a 70 72 69 6e 74 20 38 20 22 45  debug:print 8 "E
53a0: 52 52 4f 52 3a 20 4e 6f 20 68 61 6e 64 6c 65 72  RROR: No handler
53b0: 20 66 6f 72 20 74 68 69 73 20 63 6f 6e 64 69 74   for this condit
53c0: 69 6f 6e 2e 22 29 0a 09 09 09 3b 3b 20 09 20 20  ion.")....;; .  
53d0: 20 20 20 22 5c 6e 20 20 68 65 64 3a 20 20 20 20     "\n  hed:    
53e0: 20 20 20 20 20 20 20 20 22 20 68 65 64 20 0a 09          " hed ..
53f0: 09 09 3b 3b 20 09 20 20 20 20 20 22 5c 6e 20 66  ..;; .     "\n f
5400: 61 69 6c 73 3a 20 20 20 20 20 20 20 20 20 20 20  ails:           
5410: 22 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73  " (string-inters
5420: 70 65 72 73 65 20 28 6d 61 70 20 64 62 3a 74 65  perse (map db:te
5430: 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20  st-get-testname 
5440: 66 61 69 6c 73 29 20 22 2c 22 29 0a 09 09 09 3b  fails) ",")....;
5450: 3b 20 09 20 20 20 20 20 22 5c 6e 20 74 65 73 74  ; .     "\n test
5460: 6d 6f 64 65 3a 20 20 20 20 20 20 20 20 22 20 74  mode:        " t
5470: 65 73 74 6d 6f 64 65 0a 09 09 09 3b 3b 20 09 20  estmode....;; . 
5480: 20 20 20 20 22 5c 6e 20 70 72 65 72 65 71 73 2d      "\n prereqs-
5490: 6e 6f 74 2d 6d 65 74 3a 20 22 20 28 70 72 65 74  not-met: " (pret
54a0: 74 79 2d 73 74 72 69 6e 67 20 70 72 65 72 65 71  ty-string prereq
54b0: 73 2d 6e 6f 74 2d 6d 65 74 29 0a 09 09 09 3b 3b  s-not-met)....;;
54c0: 20 09 20 20 20 20 20 22 5c 6e 20 69 74 65 6d 73   .     "\n items
54d0: 3a 20 20 20 20 20 20 20 20 20 20 20 22 20 69 74  :           " it
54e0: 65 6d 73 29 0a 09 09 09 28 6c 6f 6f 70 20 28 63  ems)....(loop (c
54f0: 61 72 20 6e 65 77 74 61 6c 29 28 63 64 72 20 6e  ar newtal)(cdr n
5500: 65 77 74 61 6c 29 29 29 29 29 0a 09 09 20 20 20  ewtal)))))...   
5510: 20 3b 3b 20 69 66 20 63 61 6e 27 74 20 72 75 6e   ;; if can't run
5520: 20 6d 6f 72 65 20 6a 75 73 74 20 6c 6f 6f 70 20   more just loop 
5530: 77 69 74 68 20 6e 65 78 74 20 70 6f 73 73 69 62  with next possib
5540: 6c 65 20 74 65 73 74 0a 09 09 20 20 20 20 28 6c  le test...    (l
5550: 6f 6f 70 20 28 63 61 72 20 6e 65 77 74 61 6c 29  oop (car newtal)
5560: 28 63 64 72 20 6e 65 77 74 61 6c 29 29 29 29 29  (cdr newtal)))))
5570: 0a 09 20 20 20 20 20 0a 09 20 20 20 20 20 3b 3b  ..     ..     ;;
5580: 20 74 68 69 73 20 63 61 73 65 20 73 68 6f 75 6c   this case shoul
5590: 64 20 6e 6f 74 20 68 61 70 70 65 6e 2c 20 61 64  d not happen, ad
55a0: 64 65 64 20 74 6f 20 68 65 6c 70 20 63 61 74 63  ded to help catc
55b0: 68 20 61 6e 79 20 62 75 67 73 0a 09 20 20 20 20  h any bugs..    
55c0: 20 28 28 61 6e 64 20 28 6c 69 73 74 3f 20 69 74   ((and (list? it
55d0: 65 6d 73 29 20 69 74 65 6d 64 61 74 29 0a 09 20  ems) itemdat).. 
55e0: 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e       (debug:prin
55f0: 74 20 30 20 22 45 52 52 4f 52 3a 20 53 68 6f 75  t 0 "ERROR: Shou
5600: 6c 64 20 6e 6f 74 20 68 61 76 65 20 61 20 6c 69  ld not have a li
5610: 73 74 20 6f 66 20 69 74 65 6d 73 20 69 6e 20 61  st of items in a
5620: 20 74 65 73 74 20 61 6e 64 20 74 68 65 20 69 74   test and the it
5630: 65 6d 73 70 61 74 68 20 73 65 74 20 2d 20 70 6c  emspath set - pl
5640: 65 61 73 65 20 72 65 70 6f 72 74 20 74 68 69 73  ease report this
5650: 22 29 0a 09 20 20 20 20 20 20 28 65 78 69 74 20  ")..      (exit 
5660: 31 29 29 29 29 0a 09 20 20 0a 09 20 20 3b 3b 20  1))))..  ..  ;; 
5670: 77 65 20 67 65 74 20 68 65 72 65 20 6f 6e 20 22  we get here on "
5680: 64 72 6f 70 20 74 68 72 6f 75 67 68 22 20 2d 20  drop through" - 
5690: 6c 6f 6f 70 20 66 6f 72 20 6e 65 78 74 20 74 65  loop for next te
56a0: 73 74 20 69 6e 20 71 75 65 75 65 0a 09 20 20 28  st in queue..  (
56b0: 69 66 20 28 6e 75 6c 6c 3f 20 74 61 6c 29 0a 09  if (null? tal)..
56c0: 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09 3b        (begin...;
56d0: 3b 20 46 49 58 4d 45 21 21 21 21 20 54 48 49 53  ; FIXME!!!! THIS
56e0: 20 53 48 4f 55 4c 44 20 4e 4f 54 20 52 45 51 55   SHOULD NOT REQU
56f0: 49 52 45 20 41 4e 20 45 58 49 54 21 21 21 21 21  IRE AN EXIT!!!!!
5700: 21 21 0a 09 09 28 64 65 62 75 67 3a 70 72 69 6e  !!...(debug:prin
5710: 74 20 31 20 22 49 4e 46 4f 3a 20 41 6c 6c 20 74  t 1 "INFO: All t
5720: 65 73 74 73 20 6c 61 75 6e 63 68 65 64 22 29 0a  ests launched").
5730: 09 09 28 74 68 72 65 61 64 2d 73 6c 65 65 70 21  ..(thread-sleep!
5740: 20 30 2e 35 29 0a 09 09 3b 3b 20 46 49 58 4d 45   0.5)...;; FIXME
5750: 21 20 54 68 69 73 20 68 61 72 73 68 20 65 78 69  ! This harsh exi
5760: 74 20 73 68 6f 75 6c 64 20 6e 6f 74 20 62 65 20  t should not be 
5770: 6e 65 63 65 73 73 61 72 79 2e 2e 2e 2e 0a 09 09  necessary.......
5780: 28 69 66 20 28 6e 6f 74 20 2a 72 75 6e 72 65 6d  (if (not *runrem
5790: 6f 74 65 2a 29 28 65 78 69 74 29 29 20 3b 3b 20  ote*)(exit)) ;; 
57a0: 0a 09 09 23 66 29 20 3b 3b 20 72 65 74 75 72 6e  ...#f) ;; return
57b0: 20 61 20 23 66 20 61 73 20 61 20 68 69 6e 74 20   a #f as a hint 
57c0: 74 68 61 74 20 77 65 20 61 72 65 20 64 6f 6e 65  that we are done
57d0: 0a 09 20 20 20 20 20 20 3b 3b 20 48 65 72 65 20  ..      ;; Here 
57e0: 77 65 20 6e 65 65 64 20 74 6f 20 63 68 65 63 6b  we need to check
57f0: 20 74 68 61 74 20 61 6c 6c 20 74 68 65 20 74 65   that all the te
5800: 73 74 73 20 72 65 6d 61 69 6e 69 6e 67 20 74 6f  sts remaining to
5810: 20 62 65 20 72 75 6e 20 61 72 65 20 65 6c 69 67   be run are elig
5820: 69 62 6c 65 20 74 6f 20 72 75 6e 0a 09 20 20 20  ible to run..   
5830: 20 20 20 3b 3b 20 61 6e 64 20 61 72 65 20 6e 6f     ;; and are no
5840: 74 20 62 6c 6f 63 6b 65 64 20 62 79 20 66 61 69  t blocked by fai
5850: 6c 65 64 0a 09 20 20 20 20 20 20 28 6c 65 74 20  led..      (let 
5860: 28 28 6e 65 77 6c 73 74 20 28 6f 70 65 6e 2d 72  ((newlst (open-r
5870: 75 6e 2d 63 6c 6f 73 65 20 74 65 73 74 73 3a 66  un-close tests:f
5880: 69 6c 74 65 72 2d 6e 6f 6e 2d 72 75 6e 6e 61 62  ilter-non-runnab
5890: 6c 65 20 23 66 20 72 75 6e 2d 69 64 20 74 61 6c  le #f run-id tal
58a0: 20 74 65 73 74 2d 72 65 63 6f 72 64 73 29 29 29   test-records)))
58b0: 20 3b 3b 20 69 2e 65 2e 20 6e 6f 74 20 46 41 49   ;; i.e. not FAI
58c0: 4c 2c 20 57 41 49 56 45 44 2c 20 49 4e 43 4f 4d  L, WAIVED, INCOM
58d0: 50 4c 45 54 45 2c 20 50 41 53 53 2c 20 4b 49 4c  PLETE, PASS, KIL
58e0: 4c 45 44 2c 0a 09 09 28 74 68 72 65 61 64 2d 73  LED,...(thread-s
58f0: 6c 65 65 70 21 20 2a 67 6c 6f 62 61 6c 2d 64 65  leep! *global-de
5900: 6c 74 61 2a 29 0a 09 09 28 69 66 20 28 6e 6f 74  lta*)...(if (not
5910: 20 28 6e 75 6c 6c 3f 20 6e 65 77 6c 73 74 29 29   (null? newlst))
5920: 0a 09 09 20 20 20 20 28 6c 6f 6f 70 20 28 63 61  ...    (loop (ca
5930: 72 20 6e 65 77 6c 73 74 29 28 63 64 72 20 6e 65  r newlst)(cdr ne
5940: 77 6c 73 74 29 29 29 29 29 29 29 29 29 0a 0a 3b  wlst)))))))))..;
5950: 3b 20 70 61 72 65 6e 74 2d 74 65 73 74 20 69 73  ; parent-test is
5960: 20 74 68 65 72 65 20 61 73 20 61 20 70 6c 61 63   there as a plac
5970: 65 68 6f 6c 64 65 72 20 66 6f 72 20 77 68 65 6e  eholder for when
5980: 20 70 61 72 65 6e 74 2d 74 65 73 74 73 20 63 61   parent-tests ca
5990: 6e 20 62 65 20 72 75 6e 20 61 73 20 61 20 73 65  n be run as a se
59a0: 74 75 70 20 73 74 65 70 0a 28 64 65 66 69 6e 65  tup step.(define
59b0: 20 28 72 75 6e 3a 74 65 73 74 20 72 75 6e 2d 69   (run:test run-i
59c0: 64 20 72 75 6e 6e 61 6d 65 20 6b 65 79 76 61 6c  d runname keyval
59d0: 6c 73 74 20 74 65 73 74 2d 72 65 63 6f 72 64 20  lst test-record 
59e0: 66 6c 61 67 73 20 70 61 72 65 6e 74 2d 74 65 73  flags parent-tes
59f0: 74 29 0a 20 20 3b 3b 20 41 6c 6c 20 74 68 65 73  t).  ;; All thes
5a00: 65 20 76 61 72 73 20 6d 69 67 68 74 20 62 65 20  e vars might be 
5a10: 72 65 66 65 72 65 6e 63 65 64 20 62 79 20 74 68  referenced by th
5a20: 65 20 74 65 73 74 63 6f 6e 66 69 67 20 66 69 6c  e testconfig fil
5a30: 65 20 72 65 61 64 65 72 0a 20 20 28 6c 65 74 2a  e reader.  (let*
5a40: 20 28 28 74 65 73 74 2d 6e 61 6d 65 20 20 20 20   ((test-name    
5a50: 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65  (tests:testqueue
5a60: 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 20 20  -get-testname   
5a70: 74 65 73 74 2d 72 65 63 6f 72 64 29 29 0a 09 20  test-record)).. 
5a80: 28 74 65 73 74 2d 77 61 69 74 6f 6e 73 20 28 74  (test-waitons (t
5a90: 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67  ests:testqueue-g
5aa0: 65 74 2d 77 61 69 74 6f 6e 73 20 20 20 20 74 65  et-waitons    te
5ab0: 73 74 2d 72 65 63 6f 72 64 29 29 0a 09 20 28 74  st-record)).. (t
5ac0: 65 73 74 2d 63 6f 6e 66 20 20 20 20 28 74 65 73  est-conf    (tes
5ad0: 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74  ts:testqueue-get
5ae0: 2d 74 65 73 74 63 6f 6e 66 69 67 20 74 65 73 74  -testconfig test
5af0: 2d 72 65 63 6f 72 64 29 29 0a 09 20 28 69 74 65  -record)).. (ite
5b00: 6d 64 61 74 20 20 20 20 20 20 28 74 65 73 74 73  mdat      (tests
5b10: 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d 69  :testqueue-get-i
5b20: 74 65 6d 64 61 74 20 20 20 20 74 65 73 74 2d 72  temdat    test-r
5b30: 65 63 6f 72 64 29 29 0a 09 20 28 74 65 73 74 2d  ecord)).. (test-
5b40: 70 61 74 68 20 20 20 20 28 63 6f 6e 63 20 2a 74  path    (conc *t
5b50: 6f 70 70 61 74 68 2a 20 22 2f 74 65 73 74 73 2f  oppath* "/tests/
5b60: 22 20 74 65 73 74 2d 6e 61 6d 65 29 29 20 3b 3b  " test-name)) ;;
5b70: 20 63 6f 75 6c 64 20 75 73 65 20 74 65 73 74 73   could use tests
5b80: 3a 67 65 74 2d 74 65 73 74 63 6f 6e 66 69 67 20  :get-testconfig 
5b90: 68 65 72 65 20 2e 2e 2e 0a 09 20 28 66 6f 72 63  here ..... (forc
5ba0: 65 20 20 20 20 20 20 20 20 28 68 61 73 68 2d 74  e        (hash-t
5bb0: 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74  able-ref/default
5bc0: 20 66 6c 61 67 73 20 22 2d 66 6f 72 63 65 22 20   flags "-force" 
5bd0: 23 66 29 29 0a 09 20 28 72 65 72 75 6e 20 20 20  #f)).. (rerun   
5be0: 20 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65       (hash-table
5bf0: 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 66 6c 61  -ref/default fla
5c00: 67 73 20 22 2d 72 65 72 75 6e 22 20 23 66 29 29  gs "-rerun" #f))
5c10: 0a 09 20 28 6b 65 65 70 67 6f 69 6e 67 20 20 20  .. (keepgoing   
5c20: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
5c30: 2f 64 65 66 61 75 6c 74 20 66 6c 61 67 73 20 22  /default flags "
5c40: 2d 6b 65 65 70 67 6f 69 6e 67 22 20 23 66 29 29  -keepgoing" #f))
5c50: 0a 09 20 28 69 74 65 6d 2d 70 61 74 68 20 20 20  .. (item-path   
5c60: 20 20 22 22 29 0a 09 20 28 64 62 20 20 20 20 20    "").. (db     
5c70: 20 20 20 20 20 20 23 66 29 29 0a 20 20 20 20 28        #f)).    (
5c80: 64 65 62 75 67 3a 70 72 69 6e 74 20 35 0a 09 09  debug:print 5...
5c90: 20 22 74 65 73 74 2d 63 6f 6e 66 69 67 3a 20 22   "test-config: "
5ca0: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 3e 61 6c   (hash-table->al
5cb0: 69 73 74 20 74 65 73 74 2d 63 6f 6e 66 29 0a 09  ist test-conf)..
5cc0: 09 20 22 5c 6e 20 20 20 69 74 65 6d 64 61 74 3a  . "\n   itemdat:
5cd0: 20 22 20 69 74 65 6d 64 61 74 0a 09 09 20 29 0a   " itemdat... ).
5ce0: 20 20 20 20 3b 3b 20 73 65 74 74 69 6e 67 20 69      ;; setting i
5cf0: 74 65 6d 64 61 74 20 74 6f 20 61 20 6c 69 73 74  temdat to a list
5d00: 20 69 66 20 69 74 20 69 73 20 23 66 0a 20 20 20   if it is #f.   
5d10: 20 28 69 66 20 28 6e 6f 74 20 69 74 65 6d 64 61   (if (not itemda
5d20: 74 29 28 73 65 74 21 20 69 74 65 6d 64 61 74 20  t)(set! itemdat 
5d30: 27 28 29 29 29 0a 20 20 20 20 28 73 65 74 21 20  '())).    (set! 
5d40: 69 74 65 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d  item-path (item-
5d50: 6c 69 73 74 2d 3e 70 61 74 68 20 69 74 65 6d 64  list->path itemd
5d60: 61 74 29 29 0a 20 20 20 20 28 64 65 62 75 67 3a  at)).    (debug:
5d70: 70 72 69 6e 74 20 32 20 22 41 74 74 65 6d 70 74  print 2 "Attempt
5d80: 69 6e 67 20 74 6f 20 6c 61 75 6e 63 68 20 74 65  ing to launch te
5d90: 73 74 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22  st " test-name "
5da0: 2f 22 20 69 74 65 6d 2d 70 61 74 68 29 0a 20 20  /" item-path).  
5db0: 20 20 28 73 65 74 65 6e 76 20 22 4d 54 5f 54 45    (setenv "MT_TE
5dc0: 53 54 5f 4e 41 4d 45 22 20 74 65 73 74 2d 6e 61  ST_NAME" test-na
5dd0: 6d 65 29 20 3b 3b 20 0a 20 20 20 20 28 73 65 74  me) ;; .    (set
5de0: 65 6e 76 20 22 4d 54 5f 52 55 4e 4e 41 4d 45 22  env "MT_RUNNAME"
5df0: 20 20 20 72 75 6e 6e 61 6d 65 29 0a 20 20 20 20     runname).    
5e00: 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65 2d  (open-run-close-
5e10: 6d 65 61 73 75 72 65 20 73 65 74 2d 6d 65 67 61  measure set-mega
5e20: 74 65 73 74 2d 65 6e 76 2d 76 61 72 73 20 64 62  test-env-vars db
5e30: 20 72 75 6e 2d 69 64 29 20 3b 3b 20 74 68 65 73   run-id) ;; thes
5e40: 65 20 6d 61 79 20 62 65 20 6e 65 65 64 65 64 20  e may be needed 
5e50: 62 79 20 74 68 65 20 6c 61 75 6e 63 68 69 6e 67  by the launching
5e60: 20 70 72 6f 63 65 73 73 0a 20 20 20 20 28 63 68   process.    (ch
5e70: 61 6e 67 65 2d 64 69 72 65 63 74 6f 72 79 20 2a  ange-directory *
5e80: 74 6f 70 70 61 74 68 2a 29 0a 0a 20 20 20 20 3b  toppath*)..    ;
5e90: 3b 20 48 65 72 65 20 69 73 20 77 68 65 72 65 20  ; Here is where 
5ea0: 74 68 65 20 74 65 73 74 5f 6d 65 74 61 20 74 61  the test_meta ta
5eb0: 62 6c 65 20 69 73 20 62 65 73 74 20 75 70 64 61  ble is best upda
5ec0: 74 65 64 0a 20 20 20 20 3b 3b 20 59 65 73 2c 20  ted.    ;; Yes, 
5ed0: 61 6e 6f 74 68 65 72 20 75 73 65 20 6f 66 20 61  another use of a
5ee0: 20 67 6c 6f 62 61 6c 20 66 6f 72 20 63 61 63 68   global for cach
5ef0: 69 6e 67 2e 20 4e 65 65 64 20 61 20 62 65 74 74  ing. Need a bett
5f00: 65 72 20 77 61 79 3f 0a 20 20 20 20 28 69 66 20  er way?.    (if 
5f10: 28 6e 6f 74 20 28 68 61 73 68 2d 74 61 62 6c 65  (not (hash-table
5f20: 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 2a 74 65  -ref/default *te
5f30: 73 74 2d 6d 65 74 61 2d 75 70 64 61 74 65 64 2a  st-meta-updated*
5f40: 20 74 65 73 74 2d 6e 61 6d 65 20 23 66 29 29 0a   test-name #f)).
5f50: 20 20 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09          (begin..
5f60: 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73     (hash-table-s
5f70: 65 74 21 20 2a 74 65 73 74 2d 6d 65 74 61 2d 75  et! *test-meta-u
5f80: 70 64 61 74 65 64 2a 20 74 65 73 74 2d 6e 61 6d  pdated* test-nam
5f90: 65 20 23 74 29 0a 20 20 20 20 20 20 20 20 20 20  e #t).          
5fa0: 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65   (open-run-close
5fb0: 20 72 75 6e 73 3a 75 70 64 61 74 65 2d 74 65 73   runs:update-tes
5fc0: 74 5f 6d 65 74 61 20 64 62 20 74 65 73 74 2d 6e  t_meta db test-n
5fd0: 61 6d 65 20 74 65 73 74 2d 63 6f 6e 66 29 29 29  ame test-conf)))
5fe0: 0a 20 20 20 20 0a 20 20 20 20 3b 3b 20 28 6c 61  .    .    ;; (la
5ff0: 6d 62 64 61 20 28 69 74 65 6d 64 61 74 29 20 3b  mbda (itemdat) ;
6000: 3b 3b 20 28 28 72 69 70 65 6e 65 73 73 20 22 6f  ;; ((ripeness "o
6010: 76 65 72 72 69 70 65 22 29 20 28 74 65 6d 70 65  verripe") (tempe
6020: 72 61 74 75 72 65 20 22 63 6f 6f 6c 22 29 20 28  rature "cool") (
6030: 73 65 61 73 6f 6e 20 22 73 75 6d 6d 65 72 22 29  season "summer")
6040: 29 0a 20 20 20 20 28 6c 65 74 2a 20 28 28 6e 65  ).    (let* ((ne
6050: 77 2d 74 65 73 74 2d 70 61 74 68 20 28 73 74 72  w-test-path (str
6060: 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20  ing-intersperse 
6070: 28 63 6f 6e 73 20 74 65 73 74 2d 70 61 74 68 20  (cons test-path 
6080: 28 6d 61 70 20 63 61 64 72 20 69 74 65 6d 64 61  (map cadr itemda
6090: 74 29 29 20 22 2f 22 29 29 0a 09 20 20 20 28 6e  t)) "/"))..   (n
60a0: 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20 28 69 66  ew-test-name (if
60b0: 20 28 65 71 75 61 6c 3f 20 69 74 65 6d 2d 70 61   (equal? item-pa
60c0: 74 68 20 22 22 29 20 74 65 73 74 2d 6e 61 6d 65  th "") test-name
60d0: 20 28 63 6f 6e 63 20 74 65 73 74 2d 6e 61 6d 65   (conc test-name
60e0: 20 22 2f 22 20 69 74 65 6d 2d 70 61 74 68 29 29   "/" item-path))
60f0: 29 20 3b 3b 20 6a 75 73 74 20 6e 65 65 64 20 69  ) ;; just need i
6100: 74 20 74 6f 20 62 65 20 75 6e 69 71 75 65 0a 09  t to be unique..
6110: 20 20 20 28 74 65 73 74 2d 69 64 20 20 20 20 20     (test-id     
6120: 20 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f 73    (open-run-clos
6130: 65 20 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 64  e db:get-test-id
6140: 20 64 62 20 20 72 75 6e 2d 69 64 20 74 65 73 74   db  run-id test
6150: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  -name item-path)
6160: 29 0a 09 20 20 20 28 74 65 73 74 64 61 74 20 20  )..   (testdat  
6170: 20 20 20 20 20 28 6f 70 65 6e 2d 72 75 6e 2d 63       (open-run-c
6180: 6c 6f 73 65 20 64 62 3a 67 65 74 2d 74 65 73 74  lose db:get-test
6190: 2d 69 6e 66 6f 2d 62 79 2d 69 64 20 64 62 20 74  -info-by-id db t
61a0: 65 73 74 2d 69 64 29 29 29 0a 20 20 20 20 20 20  est-id))).      
61b0: 28 69 66 20 28 6e 6f 74 20 74 65 73 74 64 61 74  (if (not testdat
61c0: 29 0a 09 20 20 28 62 65 67 69 6e 0a 09 20 20 20  )..  (begin..   
61d0: 20 3b 3b 20 65 6e 73 75 72 65 20 74 68 61 74 20   ;; ensure that 
61e0: 74 68 65 20 70 61 74 68 20 65 78 69 73 74 73 20  the path exists 
61f0: 62 65 66 6f 72 65 20 72 65 67 69 73 74 65 72 69  before registeri
6200: 6e 67 20 74 68 65 20 74 65 73 74 0a 09 20 20 20  ng the test..   
6210: 20 3b 3b 20 4e 4f 50 45 3a 20 43 61 6e 6e 6f 74   ;; NOPE: Cannot
6220: 21 20 44 6f 6e 27 74 20 6b 6e 6f 77 20 79 65 74  ! Don't know yet
6230: 20 77 68 69 63 68 20 64 69 73 6b 20 61 72 65 61   which disk area
6240: 20 77 69 6c 6c 20 62 65 20 61 73 73 69 67 6e 65   will be assigne
6250: 64 2e 2e 2e 2e 0a 09 20 20 20 20 3b 3b 20 28 73  d......    ;; (s
6260: 79 73 74 65 6d 20 28 63 6f 6e 63 20 22 6d 6b 64  ystem (conc "mkd
6270: 69 72 20 2d 70 20 22 20 6e 65 77 2d 74 65 73 74  ir -p " new-test
6280: 2d 70 61 74 68 29 29 0a 09 20 20 20 20 28 6f 70  -path))..    (op
6290: 65 6e 2d 72 75 6e 2d 63 6c 6f 73 65 20 74 65 73  en-run-close tes
62a0: 74 73 3a 72 65 67 69 73 74 65 72 2d 74 65 73 74  ts:register-test
62b0: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d   db run-id test-
62c0: 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 0a  name item-path).
62d0: 09 20 20 20 20 28 73 65 74 21 20 74 65 73 74 2d  .    (set! test-
62e0: 69 64 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c 6f  id (open-run-clo
62f0: 73 65 20 64 62 3a 67 65 74 2d 74 65 73 74 2d 69  se db:get-test-i
6300: 64 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  d db run-id test
6310: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  -name item-path)
6320: 29 0a 09 20 20 20 20 28 73 65 74 21 20 74 65 73  )..    (set! tes
6330: 74 64 61 74 20 28 6f 70 65 6e 2d 72 75 6e 2d 63  tdat (open-run-c
6340: 6c 6f 73 65 20 64 62 3a 67 65 74 2d 74 65 73 74  lose db:get-test
6350: 2d 69 6e 66 6f 2d 62 79 2d 69 64 20 64 62 20 74  -info-by-id db t
6360: 65 73 74 2d 69 64 29 29 29 29 0a 20 20 20 20 20  est-id)))).     
6370: 20 28 73 65 74 21 20 74 65 73 74 2d 69 64 20 28   (set! test-id (
6380: 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74  db:test-get-id t
6390: 65 73 74 64 61 74 29 29 0a 20 20 20 20 20 20 28  estdat)).      (
63a0: 63 68 61 6e 67 65 2d 64 69 72 65 63 74 6f 72 79  change-directory
63b0: 20 74 65 73 74 2d 70 61 74 68 29 0a 20 20 20 20   test-path).    
63c0: 20 20 28 63 61 73 65 20 28 69 66 20 66 6f 72 63    (case (if forc
63d0: 65 20 3b 3b 20 28 61 72 67 73 3a 67 65 74 2d 61  e ;; (args:get-a
63e0: 72 67 20 22 2d 66 6f 72 63 65 22 29 0a 09 09 27  rg "-force")...'
63f0: 4e 4f 54 5f 53 54 41 52 54 45 44 0a 09 09 28 69  NOT_STARTED...(i
6400: 66 20 74 65 73 74 64 61 74 0a 09 09 20 20 20 20  f testdat...    
6410: 28 73 74 72 69 6e 67 2d 3e 73 79 6d 62 6f 6c 20  (string->symbol 
6420: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20  (test:get-state 
6430: 74 65 73 74 64 61 74 29 29 0a 09 09 20 20 20 20  testdat))...    
6440: 27 66 61 69 6c 65 64 2d 74 6f 2d 69 6e 73 65 72  'failed-to-inser
6450: 74 29 29 0a 09 28 28 66 61 69 6c 65 64 2d 74 6f  t))..((failed-to
6460: 2d 69 6e 73 65 72 74 29 0a 09 20 28 64 65 62 75  -insert).. (debu
6470: 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52  g:print 0 "ERROR
6480: 3a 20 46 61 69 6c 65 64 20 74 6f 20 69 6e 73 65  : Failed to inse
6490: 72 74 20 74 68 65 20 72 65 63 6f 72 64 20 69 6e  rt the record in
64a0: 74 6f 20 74 68 65 20 64 62 22 29 29 0a 09 28 28  to the db"))..((
64b0: 4e 4f 54 5f 53 54 41 52 54 45 44 20 43 4f 4d 50  NOT_STARTED COMP
64c0: 4c 45 54 45 44 29 0a 09 20 28 6c 65 74 20 28 28  LETED).. (let ((
64d0: 72 75 6e 66 6c 61 67 20 23 66 29 29 0a 09 20 20  runflag #f))..  
64e0: 20 28 63 6f 6e 64 0a 09 20 20 20 20 3b 3b 20 2d   (cond..    ;; -
64f0: 66 6f 72 63 65 2c 20 72 75 6e 20 6e 6f 20 6d 61  force, run no ma
6500: 74 74 65 72 20 77 68 61 74 0a 09 20 20 20 20 28  tter what..    (
6510: 66 6f 72 63 65 20 28 73 65 74 21 20 72 75 6e 66  force (set! runf
6520: 6c 61 67 20 23 74 29 29 0a 09 20 20 20 20 3b 3b  lag #t))..    ;;
6530: 20 4e 4f 54 5f 53 54 41 52 54 45 44 2c 20 72 75   NOT_STARTED, ru
6540: 6e 20 6e 6f 20 6d 61 74 74 65 72 20 77 68 61 74  n no matter what
6550: 0a 09 20 20 20 20 28 28 65 71 75 61 6c 3f 20 28  ..    ((equal? (
6560: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74  test:get-state t
6570: 65 73 74 64 61 74 29 20 22 4e 4f 54 5f 53 54 41  estdat) "NOT_STA
6580: 52 54 45 44 22 29 28 73 65 74 21 20 72 75 6e 66  RTED")(set! runf
6590: 6c 61 67 20 23 74 29 29 0a 09 20 20 20 20 3b 3b  lag #t))..    ;;
65a0: 20 6e 6f 74 20 2d 72 65 72 75 6e 20 61 6e 64 20   not -rerun and 
65b0: 50 41 53 53 2c 20 57 41 52 4e 20 6f 72 20 43 48  PASS, WARN or CH
65c0: 45 43 4b 2c 20 64 6f 20 6e 6f 20 72 75 6e 0a 09  ECK, do no run..
65d0: 20 20 20 20 28 28 61 6e 64 20 28 6f 72 20 28 6e      ((and (or (n
65e0: 6f 74 20 72 65 72 75 6e 29 0a 09 09 20 20 20 20  ot rerun)...    
65f0: 20 20 6b 65 65 70 67 6f 69 6e 67 29 0a 09 09 20    keepgoing)... 
6600: 20 3b 3b 20 52 65 71 75 69 72 65 20 74 6f 20 66   ;; Require to f
6610: 6f 72 63 65 20 72 65 2d 72 75 6e 20 66 6f 72 20  orce re-run for 
6620: 43 4f 4d 50 4c 45 54 45 44 20 6f 72 20 2a 61 6e  COMPLETED or *an
6630: 79 74 68 69 6e 67 2a 20 2b 20 50 41 53 53 2c 57  ything* + PASS,W
6640: 41 52 4e 20 6f 72 20 43 48 45 43 4b 0a 09 09 20  ARN or CHECK... 
6650: 20 28 6f 72 20 28 6d 65 6d 62 65 72 20 28 74 65   (or (member (te
6660: 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65  st:get-status te
6670: 73 74 64 61 74 29 20 27 28 22 50 41 53 53 22 20  stdat) '("PASS" 
6680: 22 57 41 52 4e 22 20 22 43 48 45 43 4b 22 29 29  "WARN" "CHECK"))
6690: 0a 09 09 20 20 20 20 20 20 28 6d 65 6d 62 65 72  ...      (member
66a0: 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65   (test:get-state
66b0: 20 20 74 65 73 74 64 61 74 29 20 27 28 22 43 4f    testdat) '("CO
66c0: 4d 50 4c 45 54 45 44 22 29 29 29 29 20 0a 09 20  MPLETED")))) .. 
66d0: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
66e0: 20 32 20 22 49 4e 46 4f 3a 20 72 75 6e 6e 69 6e   2 "INFO: runnin
66f0: 67 20 74 65 73 74 20 22 20 74 65 73 74 2d 6e 61  g test " test-na
6700: 6d 65 20 22 2f 22 20 69 74 65 6d 2d 70 61 74 68  me "/" item-path
6710: 20 22 20 73 75 70 70 72 65 73 73 65 64 20 61 73   " suppressed as
6720: 20 69 74 20 69 73 20 22 20 28 74 65 73 74 3a 67   it is " (test:g
6730: 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 74  et-state testdat
6740: 29 20 22 20 61 6e 64 20 22 20 28 74 65 73 74 3a  ) " and " (test:
6750: 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64  get-status testd
6760: 61 74 29 29 0a 09 20 20 20 20 20 28 73 65 74 21  at))..     (set!
6770: 20 72 75 6e 66 6c 61 67 20 23 66 29 29 0a 09 20   runflag #f)).. 
6780: 20 20 20 3b 3b 20 2d 72 65 72 75 6e 20 61 6e 64     ;; -rerun and
6790: 20 73 74 61 74 75 73 20 69 73 20 6f 6e 65 20 6f   status is one o
67a0: 66 20 74 68 65 20 73 70 65 63 69 66 65 64 2c 20  f the specifed, 
67b0: 72 75 6e 20 69 74 0a 09 20 20 20 20 28 28 61 6e  run it..    ((an
67c0: 64 20 72 65 72 75 6e 0a 09 09 20 20 28 6c 65 74  d rerun...  (let
67d0: 2a 20 28 28 72 65 72 75 6e 6c 73 74 20 20 20 28  * ((rerunlst   (
67e0: 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 72 65 72  string-split rer
67f0: 75 6e 20 22 2c 22 29 29 0a 09 09 09 20 28 6d 75  un ",")).... (mu
6800: 73 74 2d 72 65 72 75 6e 20 28 6d 65 6d 62 65 72  st-rerun (member
6810: 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75   (test:get-statu
6820: 73 20 74 65 73 74 64 61 74 29 20 72 65 72 75 6e  s testdat) rerun
6830: 6c 73 74 29 29 29 0a 09 09 20 20 20 20 28 64 65  lst)))...    (de
6840: 62 75 67 3a 70 72 69 6e 74 20 33 20 22 49 4e 46  bug:print 3 "INF
6850: 4f 3a 20 2d 72 65 72 75 6e 20 6c 69 73 74 3a 20  O: -rerun list: 
6860: 22 20 72 65 72 75 6e 20 22 2c 20 74 65 73 74 2d  " rerun ", test-
6870: 73 74 61 74 75 73 3a 20 22 20 28 74 65 73 74 3a  status: " (test:
6880: 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64  get-status testd
6890: 61 74 29 22 2c 20 6d 75 73 74 2d 72 65 72 75 6e  at)", must-rerun
68a0: 3a 20 22 20 6d 75 73 74 2d 72 65 72 75 6e 29 0a  : " must-rerun).
68b0: 09 09 20 20 20 20 6d 75 73 74 2d 72 65 72 75 6e  ..    must-rerun
68c0: 29 29 0a 09 20 20 20 20 20 28 64 65 62 75 67 3a  ))..     (debug:
68d0: 70 72 69 6e 74 20 32 20 22 49 4e 46 4f 3a 20 52  print 2 "INFO: R
68e0: 65 72 75 6e 20 66 6f 72 63 65 64 20 66 6f 72 20  erun forced for 
68f0: 74 65 73 74 20 22 20 74 65 73 74 2d 6e 61 6d 65  test " test-name
6900: 20 22 2f 22 20 69 74 65 6d 2d 70 61 74 68 29 0a   "/" item-path).
6910: 09 20 20 20 20 20 28 73 65 74 21 20 72 75 6e 66  .     (set! runf
6920: 6c 61 67 20 23 74 29 29 0a 09 20 20 20 20 3b 3b  lag #t))..    ;;
6930: 20 2d 6b 65 65 70 67 6f 69 6e 67 2c 20 64 6f 20   -keepgoing, do 
6940: 6e 6f 74 20 72 65 72 75 6e 20 46 41 49 4c 0a 09  not rerun FAIL..
6950: 20 20 20 20 28 28 61 6e 64 20 6b 65 65 70 67 6f      ((and keepgo
6960: 69 6e 67 0a 09 09 20 20 28 6d 65 6d 62 65 72 20  ing...  (member 
6970: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73  (test:get-status
6980: 20 74 65 73 74 64 61 74 29 20 27 28 22 46 41 49   testdat) '("FAI
6990: 4c 22 29 29 29 0a 09 20 20 20 20 20 28 73 65 74  L")))..     (set
69a0: 21 20 72 75 6e 66 6c 61 67 20 23 66 29 29 0a 09  ! runflag #f))..
69b0: 20 20 20 20 28 28 61 6e 64 20 28 6e 6f 74 20 72      ((and (not r
69c0: 65 72 75 6e 29 0a 09 09 20 20 28 6d 65 6d 62 65  erun)...  (membe
69d0: 72 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74  r (test:get-stat
69e0: 75 73 20 74 65 73 74 64 61 74 29 20 27 28 22 46  us testdat) '("F
69f0: 41 49 4c 22 20 22 6e 2f 61 22 29 29 29 0a 09 20  AIL" "n/a"))).. 
6a00: 20 20 20 20 28 73 65 74 21 20 72 75 6e 66 6c 61      (set! runfla
6a10: 67 20 23 74 29 29 0a 09 20 20 20 20 28 65 6c 73  g #t))..    (els
6a20: 65 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20  e (set! runflag 
6a30: 23 66 29 29 29 0a 09 20 20 20 28 64 65 62 75 67  #f)))..   (debug
6a40: 3a 70 72 69 6e 74 20 36 20 22 52 55 4e 4e 49 4e  :print 6 "RUNNIN
6a50: 47 20 3d 3e 20 72 75 6e 66 6c 61 67 3a 20 22 20  G => runflag: " 
6a60: 72 75 6e 66 6c 61 67 20 22 20 53 54 41 54 45 3a  runflag " STATE:
6a70: 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61   " (test:get-sta
6a80: 74 65 20 74 65 73 74 64 61 74 29 20 22 20 53 54  te testdat) " ST
6a90: 41 54 55 53 3a 20 22 20 28 74 65 73 74 3a 67 65  ATUS: " (test:ge
6aa0: 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61 74  t-status testdat
6ab0: 29 29 0a 09 20 20 20 28 69 66 20 28 6e 6f 74 20  ))..   (if (not 
6ac0: 72 75 6e 66 6c 61 67 29 0a 09 20 20 20 20 20 20  runflag)..      
6ad0: 20 28 69 66 20 28 6e 6f 74 20 70 61 72 65 6e 74   (if (not parent
6ae0: 2d 74 65 73 74 29 0a 09 09 20 20 20 28 64 65 62  -test)...   (deb
6af0: 75 67 3a 70 72 69 6e 74 20 31 20 22 4e 4f 54 45  ug:print 1 "NOTE
6b00: 3a 20 4e 6f 74 20 73 74 61 72 74 69 6e 67 20 74  : Not starting t
6b10: 65 73 74 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e  est " new-test-n
6b20: 61 6d 65 20 22 20 61 73 20 69 74 20 69 73 20 73  ame " as it is s
6b30: 74 61 74 65 20 5c 22 22 20 28 74 65 73 74 3a 67  tate \"" (test:g
6b40: 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 74  et-state testdat
6b50: 29 20 0a 09 09 09 09 22 5c 22 20 61 6e 64 20 73  ) ....."\" and s
6b60: 74 61 74 75 73 20 5c 22 22 20 28 74 65 73 74 3a  tatus \"" (test:
6b70: 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64  get-status testd
6b80: 61 74 29 20 22 5c 22 2c 20 75 73 65 20 2d 72 65  at) "\", use -re
6b90: 72 75 6e 20 5c 22 22 20 28 74 65 73 74 3a 67 65  run \"" (test:ge
6ba0: 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61 74  t-status testdat
6bb0: 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ).              
6bc0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
6bd0: 20 20 22 5c 22 20 6f 72 20 2d 66 6f 72 63 65 20    "\" or -force 
6be0: 74 6f 20 6f 76 65 72 72 69 64 65 22 29 29 0a 09  to override"))..
6bf0: 20 20 20 20 20 20 20 3b 3b 20 4e 4f 54 45 3a 20         ;; NOTE: 
6c00: 4e 6f 20 6c 6f 6e 67 65 72 20 62 65 20 63 68 65  No longer be che
6c10: 63 6b 69 6e 67 20 70 72 65 72 65 71 75 69 73 69  cking prerequisi
6c20: 74 65 73 20 68 65 72 65 21 20 57 69 6c 6c 20 6e  tes here! Will n
6c30: 65 76 65 72 20 67 65 74 20 68 65 72 65 20 75 6e  ever get here un
6c40: 6c 65 73 73 20 70 72 65 72 65 71 73 20 61 72 65  less prereqs are
6c50: 0a 09 20 20 20 20 20 20 20 3b 3b 20 20 20 20 20  ..       ;;     
6c60: 20 20 61 6c 72 65 61 64 79 20 6d 65 74 2e 0a 09    already met...
6c70: 20 20 20 20 20 20 20 28 69 66 20 28 6e 6f 74 20         (if (not 
6c80: 28 6c 61 75 6e 63 68 2d 74 65 73 74 20 23 66 20  (launch-test #f 
6c90: 72 75 6e 2d 69 64 20 72 75 6e 6e 61 6d 65 20 74  run-id runname t
6ca0: 65 73 74 2d 63 6f 6e 66 20 6b 65 79 76 61 6c 6c  est-conf keyvall
6cb0: 73 74 20 74 65 73 74 2d 6e 61 6d 65 20 74 65 73  st test-name tes
6cc0: 74 2d 70 61 74 68 20 69 74 65 6d 64 61 74 20 66  t-path itemdat f
6cd0: 6c 61 67 73 29 29 0a 09 09 20 20 20 28 62 65 67  lags))...   (beg
6ce0: 69 6e 0a 09 09 20 20 20 20 20 28 70 72 69 6e 74  in...     (print
6cf0: 20 22 45 52 52 4f 52 3a 20 46 61 69 6c 65 64 20   "ERROR: Failed 
6d00: 74 6f 20 6c 61 75 6e 63 68 20 74 68 65 20 74 65  to launch the te
6d10: 73 74 2e 20 45 78 69 74 69 6e 67 20 61 73 20 73  st. Exiting as s
6d20: 6f 6f 6e 20 61 73 20 70 6f 73 73 69 62 6c 65 22  oon as possible"
6d30: 29 0a 09 09 20 20 20 20 20 28 73 65 74 21 20 2a  )...     (set! *
6d40: 67 6c 6f 62 61 6c 65 78 69 74 73 74 61 74 75 73  globalexitstatus
6d50: 2a 20 31 29 20 3b 3b 20 0a 09 09 20 20 20 20 20  * 1) ;; ...     
6d60: 28 70 72 6f 63 65 73 73 2d 73 69 67 6e 61 6c 20  (process-signal 
6d70: 28 63 75 72 72 65 6e 74 2d 70 72 6f 63 65 73 73  (current-process
6d80: 2d 69 64 29 20 73 69 67 6e 61 6c 2f 6b 69 6c 6c  -id) signal/kill
6d90: 29 29 29 29 29 29 0a 09 28 28 4b 49 4c 4c 45 44  ))))))..((KILLED
6da0: 29 20 0a 09 20 28 64 65 62 75 67 3a 70 72 69 6e  ) .. (debug:prin
6db0: 74 20 31 20 22 4e 4f 54 45 3a 20 22 20 6e 65 77  t 1 "NOTE: " new
6dc0: 2d 74 65 73 74 2d 6e 61 6d 65 20 22 20 69 73 20  -test-name " is 
6dd0: 61 6c 72 65 61 64 79 20 72 75 6e 6e 69 6e 67 20  already running 
6de0: 6f 72 20 77 61 73 20 65 78 70 6c 69 63 74 6c 79  or was explictly
6df0: 20 6b 69 6c 6c 65 64 2c 20 75 73 65 20 2d 66 6f   killed, use -fo
6e00: 72 63 65 20 74 6f 20 6c 61 75 6e 63 68 20 69 74  rce to launch it
6e10: 2e 22 29 29 0a 09 28 28 4c 41 55 4e 43 48 45 44  ."))..((LAUNCHED
6e20: 20 52 45 4d 4f 54 45 48 4f 53 54 53 54 41 52 54   REMOTEHOSTSTART
6e30: 20 52 55 4e 4e 49 4e 47 29 20 20 0a 09 20 28 69   RUNNING)  .. (i
6e40: 66 20 28 3e 20 28 2d 20 28 63 75 72 72 65 6e 74  f (> (- (current
6e50: 2d 73 65 63 6f 6e 64 73 29 28 2b 20 28 64 62 3a  -seconds)(+ (db:
6e60: 74 65 73 74 2d 67 65 74 2d 65 76 65 6e 74 5f 74  test-get-event_t
6e70: 69 6d 65 20 74 65 73 74 64 61 74 29 0a 09 09 09  ime testdat)....
6e80: 09 20 20 20 20 20 20 20 28 64 62 3a 74 65 73 74  .       (db:test
6e90: 2d 67 65 74 2d 72 75 6e 5f 64 75 72 61 74 69 6f  -get-run_duratio
6ea0: 6e 20 74 65 73 74 64 61 74 29 29 29 0a 09 09 36  n testdat)))...6
6eb0: 30 30 29 20 3b 3b 20 69 2e 65 2e 20 6e 6f 20 75  00) ;; i.e. no u
6ec0: 70 64 61 74 65 20 66 6f 72 20 6d 6f 72 65 20 74  pdate for more t
6ed0: 68 61 6e 20 36 30 30 20 73 65 63 6f 6e 64 73 0a  han 600 seconds.
6ee0: 09 20 20 20 20 20 28 62 65 67 69 6e 0a 09 20 20  .     (begin..  
6ef0: 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e       (debug:prin
6f00: 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 54 65  t 0 "WARNING: Te
6f10: 73 74 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22  st " test-name "
6f20: 20 61 70 70 65 61 72 73 20 74 6f 20 62 65 20 64   appears to be d
6f30: 65 61 64 2e 20 46 6f 72 63 69 6e 67 20 69 74 20  ead. Forcing it 
6f40: 74 6f 20 73 74 61 74 65 20 49 4e 43 4f 4d 50 4c  to state INCOMPL
6f50: 45 54 45 20 61 6e 64 20 73 74 61 74 75 73 20 53  ETE and status S
6f60: 54 55 43 4b 2f 44 45 41 44 22 29 0a 09 20 20 20  TUCK/DEAD")..   
6f70: 20 20 20 20 28 6f 70 65 6e 2d 72 75 6e 2d 63 6c      (open-run-cl
6f80: 6f 73 65 20 74 65 73 74 2d 73 65 74 2d 73 74 61  ose test-set-sta
6f90: 74 75 73 21 20 64 62 20 74 65 73 74 2d 69 64 20  tus! db test-id 
6fa0: 22 49 4e 43 4f 4d 50 4c 45 54 45 22 20 22 53 54  "INCOMPLETE" "ST
6fb0: 55 43 4b 2f 44 45 41 44 22 20 22 54 65 73 74 20  UCK/DEAD" "Test 
6fc0: 69 73 20 73 74 75 63 6b 20 6f 72 20 64 65 61 64  is stuck or dead
6fd0: 22 20 23 66 29 29 0a 09 20 20 20 20 20 28 64 65  " #f))..     (de
6fe0: 62 75 67 3a 70 72 69 6e 74 20 32 20 22 4e 4f 54  bug:print 2 "NOT
6ff0: 45 3a 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22  E: " test-name "
7000: 20 69 73 20 61 6c 72 65 61 64 79 20 72 75 6e 6e   is already runn
7010: 69 6e 67 22 29 29 29 0a 09 28 65 6c 73 65 20 20  ing")))..(else  
7020: 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e       (debug:prin
7030: 74 20 30 20 22 45 52 52 4f 52 3a 20 46 61 69 6c  t 0 "ERROR: Fail
7040: 65 64 20 74 6f 20 6c 61 75 6e 63 68 20 74 65 73  ed to launch tes
7050: 74 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d  t " new-test-nam
7060: 65 20 22 2e 20 55 6e 72 65 63 6f 67 6e 69 73 65  e ". Unrecognise
7070: 64 20 73 74 61 74 65 20 22 20 28 74 65 73 74 3a  d state " (test:
7080: 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61  get-state testda
7090: 74 29 29 29 29 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d  t)))))))..;;====
70a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
70b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
70c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
70d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
70e0: 3d 3d 0a 3b 3b 20 45 4e 44 20 4f 46 20 4e 45 57  ==.;; END OF NEW
70f0: 20 53 54 55 46 46 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d   STUFF.;;=======
7100: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7110: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7120: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
7130: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a  ===============.
7140: 0a 28 64 65 66 69 6e 65 20 28 67 65 74 2d 64 69  .(define (get-di
7150: 72 2d 75 70 2d 6e 20 64 69 72 20 2e 20 70 61 72  r-up-n dir . par
7160: 61 6d 73 29 20 0a 20 20 28 6c 65 74 20 28 28 64  ams) .  (let ((d
7170: 70 61 72 74 73 20 20 28 73 74 72 69 6e 67 2d 73  parts  (string-s
7180: 70 6c 69 74 20 64 69 72 20 22 2f 22 29 29 0a 09  plit dir "/"))..
7190: 28 63 6f 75 6e 74 20 20 20 28 69 66 20 28 6e 75  (count   (if (nu
71a0: 6c 6c 3f 20 70 61 72 61 6d 73 29 20 31 20 28 63  ll? params) 1 (c
71b0: 61 72 20 70 61 72 61 6d 73 29 29 29 29 0a 20 20  ar params)))).  
71c0: 20 20 28 63 6f 6e 63 20 22 2f 22 20 28 73 74 72    (conc "/" (str
71d0: 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20  ing-intersperse 
71e0: 0a 09 20 20 20 20 20 20 20 28 74 61 6b 65 20 64  ..       (take d
71f0: 70 61 72 74 73 20 28 2d 20 28 6c 65 6e 67 74 68  parts (- (length
7200: 20 64 70 61 72 74 73 29 20 63 6f 75 6e 74 29 29   dparts) count))
7210: 0a 09 20 20 20 20 20 20 20 22 2f 22 29 29 29 29  ..       "/"))))
7220: 0a 3b 3b 20 52 65 6d 6f 76 65 20 72 75 6e 73 0a  .;; Remove runs.
7230: 3b 3b 20 66 69 65 6c 64 73 20 61 72 65 20 70 61  ;; fields are pa
7240: 73 73 69 6e 67 20 69 6e 20 74 68 72 6f 75 67 68  ssing in through
7250: 20 0a 3b 3b 20 61 63 74 69 6f 6e 3a 0a 3b 3b 20   .;; action:.;; 
7260: 20 20 20 27 72 65 6d 6f 76 65 2d 72 75 6e 73 0a     'remove-runs.
7270: 3b 3b 20 20 20 20 27 73 65 74 2d 73 74 61 74 65  ;;    'set-state
7280: 2d 73 74 61 74 75 73 0a 3b 3b 0a 3b 3b 20 4e 42  -status.;;.;; NB
7290: 2f 2f 20 73 68 6f 75 6c 64 20 70 61 73 73 20 69  // should pass i
72a0: 6e 20 6b 65 79 73 3f 0a 3b 3b 0a 28 64 65 66 69  n keys?.;;.(defi
72b0: 6e 65 20 28 72 75 6e 73 3a 6f 70 65 72 61 74 65  ne (runs:operate
72c0: 2d 6f 6e 20 64 62 20 61 63 74 69 6f 6e 20 72 75  -on db action ru
72d0: 6e 6e 61 6d 65 70 61 74 74 20 74 65 73 74 70 61  nnamepatt testpa
72e0: 74 74 20 69 74 65 6d 70 61 74 74 20 23 21 6b 65  tt itempatt #!ke
72f0: 79 20 28 73 74 61 74 65 20 23 66 29 28 73 74 61  y (state #f)(sta
7300: 74 75 73 20 23 66 29 28 6e 65 77 2d 73 74 61 74  tus #f)(new-stat
7310: 65 2d 73 74 61 74 75 73 20 23 66 29 29 0a 20 20  e-status #f)).  
7320: 28 6c 65 74 2a 20 28 28 6b 65 79 73 20 20 20 20  (let* ((keys    
7330: 20 20 20 20 20 28 72 64 62 3a 67 65 74 2d 6b 65       (rdb:get-ke
7340: 79 73 20 64 62 29 29 0a 09 20 28 72 75 6e 64 61  ys db)).. (runda
7350: 74 20 20 20 20 20 20 20 28 72 75 6e 73 3a 67 65  t       (runs:ge
7360: 74 2d 72 75 6e 73 2d 62 79 2d 70 61 74 74 20 64  t-runs-by-patt d
7370: 62 20 6b 65 79 73 20 72 75 6e 6e 61 6d 65 70 61  b keys runnamepa
7380: 74 74 29 29 0a 09 20 28 68 65 61 64 65 72 20 20  tt)).. (header  
7390: 20 20 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66       (vector-ref
73a0: 20 72 75 6e 64 61 74 20 30 29 29 0a 09 20 28 72   rundat 0)).. (r
73b0: 75 6e 73 20 20 20 20 20 20 20 20 20 28 76 65 63  uns         (vec
73c0: 74 6f 72 2d 72 65 66 20 72 75 6e 64 61 74 20 31  tor-ref rundat 1
73d0: 29 29 0a 09 20 28 73 74 61 74 65 73 20 20 20 20  )).. (states    
73e0: 20 20 20 28 69 66 20 73 74 61 74 65 20 20 28 73     (if state  (s
73f0: 74 72 69 6e 67 2d 73 70 6c 69 74 20 73 74 61 74  tring-split stat
7400: 65 20 20 22 2c 22 29 20 27 28 29 29 29 0a 09 20  e  ",") '())).. 
7410: 28 73 74 61 74 75 73 65 73 20 20 20 20 20 28 69  (statuses     (i
7420: 66 20 73 74 61 74 75 73 20 28 73 74 72 69 6e 67  f status (string
7430: 2d 73 70 6c 69 74 20 73 74 61 74 75 73 20 22 2c  -split status ",
7440: 22 29 20 27 28 29 29 29 0a 09 20 28 73 74 61 74  ") '())).. (stat
7450: 65 2d 73 74 61 74 75 73 20 28 69 66 20 28 73 74  e-status (if (st
7460: 72 69 6e 67 3f 20 6e 65 77 2d 73 74 61 74 65 2d  ring? new-state-
7470: 73 74 61 74 75 73 29 20 28 73 74 72 69 6e 67 2d  status) (string-
7480: 73 70 6c 69 74 20 6e 65 77 2d 73 74 61 74 65 2d  split new-state-
7490: 73 74 61 74 75 73 20 22 2c 22 29 20 27 28 23 66  status ",") '(#f
74a0: 20 23 66 29 29 29 29 0a 20 20 20 20 28 64 65 62   #f)))).    (deb
74b0: 75 67 3a 70 72 69 6e 74 20 32 20 22 48 65 61 64  ug:print 2 "Head
74c0: 65 72 3a 20 22 20 68 65 61 64 65 72 20 22 20 61  er: " header " a
74d0: 63 74 69 6f 6e 3a 20 22 20 61 63 74 69 6f 6e 20  ction: " action 
74e0: 22 20 6e 65 77 2d 73 74 61 74 65 2d 73 74 61 74  " new-state-stat
74f0: 75 73 3a 20 22 20 6e 65 77 2d 73 74 61 74 65 2d  us: " new-state-
7500: 73 74 61 74 75 73 29 0a 20 20 20 20 28 66 6f 72  status).    (for
7510: 2d 65 61 63 68 0a 20 20 20 20 20 28 6c 61 6d 62  -each.     (lamb
7520: 64 61 20 28 72 75 6e 29 0a 20 20 20 20 20 20 20  da (run).       
7530: 28 6c 65 74 20 28 28 72 75 6e 6b 65 79 20 28 73  (let ((runkey (s
7540: 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73  tring-interspers
7550: 65 20 28 6d 61 70 20 28 6c 61 6d 62 64 61 20 28  e (map (lambda (
7560: 6b 29 0a 09 09 09 09 09 09 28 64 62 3a 67 65 74  k).......(db:get
7570: 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72  -value-by-header
7580: 20 72 75 6e 20 68 65 61 64 65 72 20 28 76 65 63   run header (vec
7590: 74 6f 72 2d 72 65 66 20 6b 20 30 29 29 29 20 6b  tor-ref k 0))) k
75a0: 65 79 73 29 20 22 2f 22 29 29 0a 09 20 20 20 20  eys) "/"))..    
75b0: 20 28 64 69 72 73 2d 74 6f 2d 72 65 6d 6f 76 65   (dirs-to-remove
75c0: 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c   (make-hash-tabl
75d0: 65 29 29 29 0a 09 20 28 6c 65 74 2a 20 28 28 72  e))).. (let* ((r
75e0: 75 6e 2d 69 64 20 20 20 20 28 64 62 3a 67 65 74  un-id    (db:get
75f0: 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72  -value-by-header
7600: 20 72 75 6e 20 68 65 61 64 65 72 20 22 69 64 22   run header "id"
7610: 29 29 0a 09 09 28 72 75 6e 2d 73 74 61 74 65 20  ))...(run-state 
7620: 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79  (db:get-value-by
7630: 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64  -header run head
7640: 65 72 20 22 73 74 61 74 65 22 29 29 0a 09 09 28  er "state"))...(
7650: 74 65 73 74 73 20 20 20 20 20 28 69 66 20 28 6e  tests     (if (n
7660: 6f 74 20 28 65 71 75 61 6c 3f 20 72 75 6e 2d 73  ot (equal? run-s
7670: 74 61 74 65 20 22 6c 6f 63 6b 65 64 22 29 29 0a  tate "locked")).
7680: 09 09 09 20 20 20 20 20 20 20 28 72 64 62 3a 67  ...       (rdb:g
7690: 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d 72 75 6e  et-tests-for-run
76a0: 20 64 62 20 28 64 62 3a 67 65 74 2d 76 61 6c 75   db (db:get-valu
76b0: 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20  e-by-header run 
76c0: 68 65 61 64 65 72 20 22 69 64 22 29 0a 09 09 09  header "id")....
76d0: 09 09 09 20 20 20 20 20 20 74 65 73 74 70 61 74  ...      testpat
76e0: 74 20 69 74 65 6d 70 61 74 74 20 73 74 61 74 65  t itempatt state
76f0: 73 20 73 74 61 74 75 73 65 73 0a 09 09 09 09 09  s statuses......
7700: 09 20 20 20 20 20 20 6e 6f 74 2d 69 6e 3a 20 20  .      not-in:  
7710: 23 66 0a 09 09 09 09 09 09 20 20 20 20 20 20 73  #f.......      s
7720: 6f 72 74 2d 62 79 3a 20 28 63 61 73 65 20 61 63  ort-by: (case ac
7730: 74 69 6f 6e 0a 09 09 09 09 09 09 09 09 20 28 28  tion......... ((
7740: 72 65 6d 6f 76 65 2d 72 75 6e 73 29 20 27 72 75  remove-runs) 'ru
7750: 6e 64 69 72 29 0a 09 09 09 09 09 09 09 09 20 28  ndir)......... (
7760: 65 6c 73 65 20 20 20 20 20 20 20 20 20 20 27 65  else          'e
7770: 76 65 6e 74 5f 74 69 6d 65 29 29 29 0a 09 09 09  vent_time)))....
7780: 20 20 20 20 20 20 20 27 28 29 29 29 0a 09 09 28         '()))...(
7790: 6c 61 73 74 74 70 61 74 68 20 22 2f 64 6f 65 73  lasttpath "/does
77a0: 2f 6e 6f 74 2f 65 78 69 73 74 2f 49 2f 68 6f 70  /not/exist/I/hop
77b0: 65 22 29 29 0a 0a 09 20 20 20 28 69 66 20 28 6e  e"))...   (if (n
77c0: 6f 74 20 28 6e 75 6c 6c 3f 20 74 65 73 74 73 29  ot (null? tests)
77d0: 29 0a 09 20 20 20 20 20 20 20 28 62 65 67 69 6e  )..       (begin
77e0: 0a 09 09 20 28 63 61 73 65 20 61 63 74 69 6f 6e  ... (case action
77f0: 0a 09 09 20 20 20 28 28 72 65 6d 6f 76 65 2d 72  ...   ((remove-r
7800: 75 6e 73 29 0a 09 09 20 20 20 20 28 64 65 62 75  uns)...    (debu
7810: 67 3a 70 72 69 6e 74 20 31 20 22 52 65 6d 6f 76  g:print 1 "Remov
7820: 69 6e 67 20 74 65 73 74 73 20 66 6f 72 20 72 75  ing tests for ru
7830: 6e 3a 20 22 20 72 75 6e 6b 65 79 20 22 20 22 20  n: " runkey " " 
7840: 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79  (db:get-value-by
7850: 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64  -header run head
7860: 65 72 20 22 72 75 6e 6e 61 6d 65 22 29 29 29 0a  er "runname"))).
7870: 09 09 20 20 20 28 28 73 65 74 2d 73 74 61 74 65  ..   ((set-state
7880: 2d 73 74 61 74 75 73 29 0a 09 09 20 20 20 20 28  -status)...    (
7890: 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 4d  debug:print 1 "M
78a0: 6f 64 69 66 79 69 6e 67 20 73 74 61 74 65 20 61  odifying state a
78b0: 6e 64 20 73 74 61 75 73 20 66 6f 72 20 74 65 73  nd staus for tes
78c0: 74 73 20 66 6f 72 20 72 75 6e 3a 20 22 20 72 75  ts for run: " ru
78d0: 6e 6b 65 79 20 22 20 22 20 28 64 62 3a 67 65 74  nkey " " (db:get
78e0: 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72  -value-by-header
78f0: 20 72 75 6e 20 68 65 61 64 65 72 20 22 72 75 6e   run header "run
7900: 6e 61 6d 65 22 29 29 29 0a 09 09 20 20 20 28 65  name")))...   (e
7910: 6c 73 65 0a 09 09 20 20 20 20 28 70 72 69 6e 74  lse...    (print
7920: 20 22 49 4e 46 4f 3a 20 61 63 74 69 6f 6e 20 6e   "INFO: action n
7930: 6f 74 20 72 65 63 6f 67 6e 69 73 65 64 20 22 20  ot recognised " 
7940: 61 63 74 69 6f 6e 29 29 29 0a 09 09 20 28 66 6f  action)))... (fo
7950: 72 2d 65 61 63 68 0a 09 09 20 20 28 6c 61 6d 62  r-each...  (lamb
7960: 64 61 20 28 74 65 73 74 29 0a 09 09 20 20 20 20  da (test)...    
7970: 28 6c 65 74 2a 20 28 28 69 74 65 6d 2d 70 61 74  (let* ((item-pat
7980: 68 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69  h (db:test-get-i
7990: 74 65 6d 2d 70 61 74 68 20 74 65 73 74 29 29 0a  tem-path test)).
79a0: 09 09 09 20 20 20 28 74 65 73 74 2d 6e 61 6d 65  ...   (test-name
79b0: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 74 65   (db:test-get-te
79c0: 73 74 6e 61 6d 65 20 74 65 73 74 29 29 0a 09 09  stname test))...
79d0: 09 20 20 20 28 72 75 6e 2d 64 69 72 20 20 20 28  .   (run-dir   (
79e0: 64 62 3a 74 65 73 74 2d 67 65 74 2d 72 75 6e 64  db:test-get-rund
79f0: 69 72 20 74 65 73 74 29 29 29 0a 09 09 20 20 20  ir test)))...   
7a00: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
7a10: 31 20 22 20 20 22 20 28 64 62 3a 74 65 73 74 2d  1 "  " (db:test-
7a20: 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73  get-testname tes
7a30: 74 29 20 22 20 69 64 3a 20 22 20 28 64 62 3a 74  t) " id: " (db:t
7a40: 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74 29  est-get-id test)
7a50: 20 22 20 22 20 69 74 65 6d 2d 70 61 74 68 20 22   " " item-path "
7a60: 20 61 63 74 69 6f 6e 3a 20 22 20 61 63 74 69 6f   action: " actio
7a70: 6e 29 0a 09 09 20 20 20 20 20 20 28 63 61 73 65  n)...      (case
7a80: 20 61 63 74 69 6f 6e 0a 09 09 09 28 28 72 65 6d   action....((rem
7a90: 6f 76 65 2d 72 75 6e 73 29 0a 09 09 09 20 28 72  ove-runs).... (r
7aa0: 64 62 3a 64 65 6c 65 74 65 2d 74 65 73 74 2d 72  db:delete-test-r
7ab0: 65 63 6f 72 64 73 20 64 62 20 28 64 62 3a 74 65  ecords db (db:te
7ac0: 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74 29 29  st-get-id test))
7ad0: 0a 09 09 09 20 28 64 65 62 75 67 3a 70 72 69 6e  .... (debug:prin
7ae0: 74 20 31 20 22 49 4e 46 4f 3a 20 41 74 74 65 6d  t 1 "INFO: Attem
7af0: 70 74 69 6e 67 20 74 6f 20 72 65 6d 6f 76 65 20  pting to remove 
7b00: 64 69 72 20 22 20 72 75 6e 2d 64 69 72 29 0a 09  dir " run-dir)..
7b10: 09 09 20 28 69 66 20 28 61 6e 64 20 28 3e 20 28  .. (if (and (> (
7b20: 73 74 72 69 6e 67 2d 6c 65 6e 67 74 68 20 72 75  string-length ru
7b30: 6e 2d 64 69 72 29 20 35 29 0a 09 09 09 09 20 20  n-dir) 5).....  
7b40: 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 72 75  (file-exists? ru
7b50: 6e 2d 64 69 72 29 29 20 3b 3b 20 62 61 64 20 68  n-dir)) ;; bad h
7b60: 65 75 72 69 73 74 69 63 20 62 75 74 20 73 68 6f  euristic but sho
7b70: 75 6c 64 20 70 72 65 76 65 6e 74 20 2f 74 6d 70  uld prevent /tmp
7b80: 20 2f 68 6f 6d 65 20 65 74 63 2e 0a 09 09 09 20   /home etc..... 
7b90: 20 20 20 20 28 6c 65 74 2a 20 28 28 72 65 61 6c      (let* ((real
7ba0: 70 61 74 68 20 28 72 65 73 6f 6c 76 65 2d 70 61  path (resolve-pa
7bb0: 74 68 6e 61 6d 65 20 72 75 6e 2d 64 69 72 29 29  thname run-dir))
7bc0: 29 0a 09 09 09 20 20 20 20 20 20 20 28 64 65 62  )....       (deb
7bd0: 75 67 3a 70 72 69 6e 74 20 31 20 22 49 4e 46 4f  ug:print 1 "INFO
7be0: 3a 20 52 65 61 6c 20 70 61 74 68 20 6f 66 20 69  : Real path of i
7bf0: 73 20 22 20 72 65 61 6c 70 61 74 68 29 0a 09 09  s " realpath)...
7c00: 09 20 20 20 20 20 20 20 28 69 66 20 28 66 69 6c  .       (if (fil
7c10: 65 2d 65 78 69 73 74 73 3f 20 72 65 61 6c 70 61  e-exists? realpa
7c20: 74 68 29 0a 09 09 09 09 20 20 20 28 69 66 20 28  th).....   (if (
7c30: 3e 20 28 73 79 73 74 65 6d 20 28 63 6f 6e 63 20  > (system (conc 
7c40: 22 72 6d 20 2d 72 66 20 22 20 72 65 61 6c 70 61  "rm -rf " realpa
7c50: 74 68 29 29 20 30 29 0a 09 09 09 09 20 20 20 20  th)) 0).....    
7c60: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
7c70: 30 20 22 45 52 52 4f 52 3a 20 54 68 65 72 65 20  0 "ERROR: There 
7c80: 77 61 73 20 61 20 70 72 6f 62 6c 65 6d 20 72 65  was a problem re
7c90: 6d 6f 76 69 6e 67 20 22 20 72 65 61 6c 70 61 74  moving " realpat
7ca0: 68 20 22 20 77 69 74 68 20 72 6d 20 2d 66 22 29  h " with rm -f")
7cb0: 29 0a 09 09 09 09 20 20 20 28 64 65 62 75 67 3a  ).....   (debug:
7cc0: 70 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e 47  print 0 "WARNING
7cd0: 3a 20 74 65 73 74 20 72 75 6e 20 64 69 72 20 22  : test run dir "
7ce0: 20 72 65 61 6c 70 61 74 68 20 22 20 61 70 70 65   realpath " appe
7cf0: 61 72 73 20 74 6f 20 6e 6f 74 20 65 78 69 73 74  ars to not exist
7d00: 22 29 29 0a 09 09 09 20 20 20 20 20 20 20 28 69  "))....       (i
7d10: 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20  f (file-exists? 
7d20: 72 75 6e 2d 64 69 72 29 20 3b 3b 20 74 68 65 20  run-dir) ;; the 
7d30: 6c 69 6e 6b 0a 09 09 09 09 20 20 20 28 69 66 20  link.....   (if 
7d40: 28 73 79 6d 62 6f 6c 69 63 2d 6c 69 6e 6b 3f 20  (symbolic-link? 
7d50: 72 75 6e 2d 64 69 72 29 0a 09 09 09 09 20 20 20  run-dir).....   
7d60: 20 20 20 20 28 64 65 6c 65 74 65 2d 66 69 6c 65      (delete-file
7d70: 20 72 75 6e 2d 64 69 72 29 0a 09 09 09 09 20 20   run-dir).....  
7d80: 20 20 20 20 20 28 69 66 20 28 64 69 72 65 63 74       (if (direct
7d90: 6f 72 79 3f 20 72 75 6e 2d 64 69 72 29 0a 09 09  ory? run-dir)...
7da0: 09 09 09 20 20 20 28 69 66 20 28 3e 20 28 64 69  ...   (if (> (di
7db0: 72 65 63 74 6f 72 79 2d 66 6f 6c 64 20 28 6c 61  rectory-fold (la
7dc0: 6d 62 64 61 20 28 66 20 78 29 28 2b 20 31 20 78  mbda (f x)(+ 1 x
7dd0: 29 29 20 30 20 72 75 6e 2d 64 69 72 29 20 30 29  )) 0 run-dir) 0)
7de0: 0a 09 09 09 09 09 20 20 20 20 20 20 20 28 64 65  ......       (de
7df0: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52  bug:print 0 "WAR
7e00: 4e 49 4e 47 3a 20 72 65 66 75 73 69 6e 67 20 74  NING: refusing t
7e10: 6f 20 72 65 6d 6f 76 65 20 22 20 72 75 6e 2d 64  o remove " run-d
7e20: 69 72 20 22 20 61 73 20 69 74 20 69 73 20 6e 6f  ir " as it is no
7e30: 74 20 65 6d 70 74 79 22 29 0a 09 09 09 09 09 20  t empty")...... 
7e40: 20 20 20 20 20 20 28 64 65 6c 65 74 65 2d 64 69        (delete-di
7e50: 72 65 63 74 6f 72 79 20 72 75 6e 2d 64 69 72 29  rectory run-dir)
7e60: 29 20 3b 3b 20 69 74 20 73 68 6f 75 6c 64 20 62  ) ;; it should b
7e70: 65 20 65 6d 70 74 79 20 62 79 20 68 65 72 65 20  e empty by here 
7e80: 42 55 47 20 42 55 47 2c 20 61 64 64 20 65 72 72  BUG BUG, add err
7e90: 6f 72 20 63 61 74 63 68 0a 09 09 09 09 09 20 20  or catch......  
7ea0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
7eb0: 22 45 52 52 4f 52 3a 20 72 65 66 75 73 69 6e 67  "ERROR: refusing
7ec0: 20 74 6f 20 72 65 6d 6f 76 65 20 22 20 72 75 6e   to remove " run
7ed0: 2d 64 69 72 20 22 20 61 73 20 69 74 20 69 73 20  -dir " as it is 
7ee0: 6e 65 69 74 68 65 72 20 61 20 73 79 6d 6c 69 6e  neither a symlin
7ef0: 6b 20 6e 6f 72 20 61 20 64 69 72 65 63 74 6f 72  k nor a director
7f00: 79 22 29 0a 09 09 09 09 09 20 20 20 29 29 29 29  y")......   ))))
7f10: 0a 09 09 09 20 20 20 20 20 28 64 65 62 75 67 3a  ....     (debug:
7f20: 70 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e 47  print 0 "WARNING
7f30: 3a 20 64 69 72 65 63 74 6f 72 79 20 61 6c 72 65  : directory alre
7f40: 61 64 79 20 72 65 6d 6f 76 65 64 20 22 20 72 75  ady removed " ru
7f50: 6e 2d 64 69 72 29 29 29 0a 09 09 09 28 28 73 65  n-dir)))....((se
7f60: 74 2d 73 74 61 74 65 2d 73 74 61 74 75 73 29 0a  t-state-status).
7f70: 09 09 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ... (debug:print
7f80: 20 32 20 22 49 4e 46 4f 3a 20 6e 65 77 20 73 74   2 "INFO: new st
7f90: 61 74 65 20 22 20 28 63 61 72 20 73 74 61 74 65  ate " (car state
7fa0: 2d 73 74 61 74 75 73 29 20 22 2c 20 6e 65 77 20  -status) ", new 
7fb0: 73 74 61 74 75 73 20 22 20 28 63 61 64 72 20 73  status " (cadr s
7fc0: 74 61 74 65 2d 73 74 61 74 75 73 29 29 0a 09 09  tate-status))...
7fd0: 09 20 28 64 62 3a 74 65 73 74 2d 73 65 74 2d 73  . (db:test-set-s
7fe0: 74 61 74 65 2d 73 74 61 74 75 73 2d 62 79 2d 69  tate-status-by-i
7ff0: 64 20 64 62 20 28 64 62 3a 74 65 73 74 2d 67 65  d db (db:test-ge
8000: 74 2d 69 64 20 74 65 73 74 29 20 28 63 61 72 20  t-id test) (car 
8010: 73 74 61 74 65 2d 73 74 61 74 75 73 29 28 63 61  state-status)(ca
8020: 64 72 20 73 74 61 74 65 2d 73 74 61 74 75 73 29  dr state-status)
8030: 20 23 66 29 29 29 29 29 0a 09 09 20 20 74 65 73   #f)))))...  tes
8040: 74 73 29 29 29 0a 09 20 20 20 0a 09 20 20 20 3b  ts)))..   ..   ;
8050: 3b 20 72 65 6d 6f 76 65 20 74 68 65 20 72 75 6e  ; remove the run
8060: 20 69 66 20 7a 65 72 6f 20 74 65 73 74 73 20 72   if zero tests r
8070: 65 6d 61 69 6e 0a 09 20 20 20 28 69 66 20 28 65  emain..   (if (e
8080: 71 3f 20 61 63 74 69 6f 6e 20 27 72 65 6d 6f 76  q? action 'remov
8090: 65 2d 72 75 6e 73 29 0a 09 20 20 20 20 20 20 20  e-runs)..       
80a0: 28 6c 65 74 20 28 28 72 65 6d 74 65 73 74 73 20  (let ((remtests 
80b0: 28 72 64 62 3a 67 65 74 2d 74 65 73 74 73 2d 66  (rdb:get-tests-f
80c0: 6f 72 2d 72 75 6e 20 64 62 20 28 64 62 3a 67 65  or-run db (db:ge
80d0: 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65  t-value-by-heade
80e0: 72 20 72 75 6e 20 68 65 61 64 65 72 20 22 69 64  r run header "id
80f0: 22 29 20 23 66 20 23 66 20 27 28 29 20 27 28 29  ") #f #f '() '()
8100: 29 29 29 0a 09 09 20 28 69 66 20 28 6e 75 6c 6c  )))... (if (null
8110: 3f 20 72 65 6d 74 65 73 74 73 29 20 3b 3b 20 6e  ? remtests) ;; n
8120: 6f 20 6d 6f 72 65 20 74 65 73 74 73 20 72 65 6d  o more tests rem
8130: 61 69 6e 69 6e 67 0a 09 09 20 20 20 20 20 28 6c  aining...     (l
8140: 65 74 2a 20 28 28 64 70 61 72 74 73 20 20 28 73  et* ((dparts  (s
8150: 74 72 69 6e 67 2d 73 70 6c 69 74 20 6c 61 73 74  tring-split last
8160: 74 70 61 74 68 20 22 2f 22 29 29 0a 09 09 09 20  tpath "/")).... 
8170: 20 20 20 28 72 75 6e 70 61 74 68 20 28 63 6f 6e     (runpath (con
8180: 63 20 22 2f 22 20 28 73 74 72 69 6e 67 2d 69 6e  c "/" (string-in
8190: 74 65 72 73 70 65 72 73 65 20 0a 09 09 09 09 09  tersperse ......
81a0: 09 28 74 61 6b 65 20 64 70 61 72 74 73 20 28 2d  .(take dparts (-
81b0: 20 28 6c 65 6e 67 74 68 20 64 70 61 72 74 73 29   (length dparts)
81c0: 20 31 29 29 0a 09 09 09 09 09 09 22 2f 22 29 29   1))......."/"))
81d0: 29 29 0a 09 09 20 20 20 20 20 20 20 28 64 65 62  ))...       (deb
81e0: 75 67 3a 70 72 69 6e 74 20 31 20 22 52 65 6d 6f  ug:print 1 "Remo
81f0: 76 69 6e 67 20 72 75 6e 3a 20 22 20 72 75 6e 6b  ving run: " runk
8200: 65 79 20 22 20 22 20 28 64 62 3a 67 65 74 2d 76  ey " " (db:get-v
8210: 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72  alue-by-header r
8220: 75 6e 20 68 65 61 64 65 72 20 22 72 75 6e 6e 61  un header "runna
8230: 6d 65 22 29 29 0a 09 09 20 20 20 20 20 20 20 28  me"))...       (
8240: 64 62 3a 64 65 6c 65 74 65 2d 72 75 6e 20 64 62  db:delete-run db
8250: 20 72 75 6e 2d 69 64 29 0a 09 09 20 20 20 20 20   run-id)...     
8260: 20 20 3b 3b 20 6e 65 65 64 20 74 6f 20 66 69 67    ;; need to fig
8270: 75 72 65 20 6f 75 74 20 74 68 65 20 70 61 74 68  ure out the path
8280: 20 74 6f 20 74 68 65 20 72 75 6e 20 64 69 72 20   to the run dir 
8290: 61 6e 64 20 72 65 6d 6f 76 65 20 69 74 20 69 66  and remove it if
82a0: 20 65 6d 70 74 79 0a 09 09 20 20 20 20 20 20 20   empty...       
82b0: 3b 3b 20 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f  ;;    (if (null?
82c0: 20 28 67 6c 6f 62 20 28 63 6f 6e 63 20 72 75 6e   (glob (conc run
82d0: 70 61 74 68 20 22 2f 2a 22 29 29 29 0a 09 09 20  path "/*")))... 
82e0: 20 20 20 20 20 20 3b 3b 20 20 20 20 20 20 20 20        ;;        
82f0: 28 62 65 67 69 6e 0a 09 09 20 20 20 20 20 20 20  (begin...       
8300: 3b 3b 20 09 20 28 64 65 62 75 67 3a 70 72 69 6e  ;; . (debug:prin
8310: 74 20 31 20 22 52 65 6d 6f 76 69 6e 67 20 72 75  t 1 "Removing ru
8320: 6e 20 64 69 72 20 22 20 72 75 6e 70 61 74 68 29  n dir " runpath)
8330: 0a 09 09 20 20 20 20 20 20 20 3b 3b 20 09 20 28  ...       ;; . (
8340: 73 79 73 74 65 6d 20 28 63 6f 6e 63 20 22 72 6d  system (conc "rm
8350: 64 69 72 20 2d 70 20 22 20 72 75 6e 70 61 74 68  dir -p " runpath
8360: 29 29 29 29 0a 09 09 20 20 20 20 20 20 20 29 29  ))))...       ))
8370: 29 29 29 0a 09 20 29 29 0a 20 20 20 20 20 72 75  ))).. )).     ru
8380: 6e 73 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d  ns)))..;;=======
8390: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
83a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
83b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
83c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a  ===============.
83d0: 3b 3b 20 52 6f 75 74 69 6e 65 73 20 66 6f 72 20  ;; Routines for 
83e0: 6d 61 6e 69 70 75 6c 61 74 69 6e 67 20 72 75 6e  manipulating run
83f0: 73 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  s.;;============
8400: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
8410: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
8420: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
8430: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 53  ==========..;; S
8440: 69 6e 63 65 20 6d 61 6e 79 20 63 61 6c 6c 73 20  ince many calls 
8450: 74 6f 20 61 20 72 75 6e 20 72 65 71 75 69 72 65  to a run require
8460: 20 70 72 65 74 74 79 20 6d 75 63 68 20 74 68 65   pretty much the
8470: 20 73 61 6d 65 20 73 65 74 75 70 20 0a 3b 3b 20   same setup .;; 
8480: 74 68 69 73 20 77 72 61 70 70 65 72 20 69 73 20  this wrapper is 
8490: 75 73 65 64 20 74 6f 20 72 65 64 75 63 65 20 74  used to reduce t
84a0: 68 65 20 72 65 70 6c 69 63 61 74 69 6f 6e 20 6f  he replication o
84b0: 66 20 63 6f 64 65 0a 28 64 65 66 69 6e 65 20 28  f code.(define (
84c0: 67 65 6e 65 72 61 6c 2d 72 75 6e 2d 63 61 6c 6c  general-run-call
84d0: 20 73 77 69 74 63 68 6e 61 6d 65 20 61 63 74 69   switchname acti
84e0: 6f 6e 2d 64 65 73 63 20 70 72 6f 63 29 0a 20 20  on-desc proc).  
84f0: 28 6c 65 74 20 28 28 72 75 6e 6e 61 6d 65 20 28  (let ((runname (
8500: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 3a 72  args:get-arg ":r
8510: 75 6e 6e 61 6d 65 22 29 29 0a 09 28 74 61 72 67  unname"))..(targ
8520: 65 74 20 20 28 69 66 20 28 61 72 67 73 3a 67 65  et  (if (args:ge
8530: 74 2d 61 72 67 20 22 2d 74 61 72 67 65 74 22 29  t-arg "-target")
8540: 0a 09 09 20 20 20 20 20 28 61 72 67 73 3a 67 65  ...     (args:ge
8550: 74 2d 61 72 67 20 22 2d 74 61 72 67 65 74 22 29  t-arg "-target")
8560: 0a 09 09 20 20 20 20 20 28 61 72 67 73 3a 67 65  ...     (args:ge
8570: 74 2d 61 72 67 20 22 2d 72 65 71 74 61 72 67 22  t-arg "-reqtarg"
8580: 29 29 29 0a 09 28 74 68 31 20 20 20 20 20 23 66  )))..(th1     #f
8590: 29 29 0a 20 20 20 20 28 63 6f 6e 64 0a 20 20 20  )).    (cond.   
85a0: 20 20 28 28 6e 6f 74 20 74 61 72 67 65 74 29 0a    ((not target).
85b0: 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69        (debug:pri
85c0: 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 4d 69 73  nt 0 "ERROR: Mis
85d0: 73 69 6e 67 20 72 65 71 75 69 72 65 64 20 70 61  sing required pa
85e0: 72 61 6d 65 74 65 72 20 66 6f 72 20 22 20 73 77  rameter for " sw
85f0: 69 74 63 68 6e 61 6d 65 20 22 2c 20 79 6f 75 20  itchname ", you 
8600: 6d 75 73 74 20 73 70 65 63 69 66 79 20 74 68 65  must specify the
8610: 20 74 61 72 67 65 74 20 77 69 74 68 20 2d 74 61   target with -ta
8620: 72 67 65 74 22 29 0a 20 20 20 20 20 20 28 65 78  rget").      (ex
8630: 69 74 20 33 29 29 0a 20 20 20 20 20 28 28 6e 6f  it 3)).     ((no
8640: 74 20 72 75 6e 6e 61 6d 65 29 0a 20 20 20 20 20  t runname).     
8650: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
8660: 22 45 52 52 4f 52 3a 20 4d 69 73 73 69 6e 67 20  "ERROR: Missing 
8670: 72 65 71 75 69 72 65 64 20 70 61 72 61 6d 65 74  required paramet
8680: 65 72 20 66 6f 72 20 22 20 73 77 69 74 63 68 6e  er for " switchn
8690: 61 6d 65 20 22 2c 20 79 6f 75 20 6d 75 73 74 20  ame ", you must 
86a0: 73 70 65 63 69 66 79 20 74 68 65 20 72 75 6e 20  specify the run 
86b0: 6e 61 6d 65 20 77 69 74 68 20 3a 72 75 6e 6e 61  name with :runna
86c0: 6d 65 20 72 75 6e 6e 61 6d 65 22 29 0a 20 20 20  me runname").   
86d0: 20 20 20 28 65 78 69 74 20 33 29 29 0a 20 20 20     (exit 3)).   
86e0: 20 20 28 65 6c 73 65 0a 20 20 20 20 20 20 28 6c    (else.      (l
86f0: 65 74 20 28 28 64 62 20 20 20 23 66 29 0a 09 20  et ((db   #f).. 
8700: 20 20 20 28 6b 65 79 73 20 23 66 29 29 0a 09 28     (keys #f))..(
8710: 69 66 20 28 6e 6f 74 20 28 73 65 74 75 70 2d 66  if (not (setup-f
8720: 6f 72 2d 72 75 6e 29 29 0a 09 20 20 20 20 28 62  or-run))..    (b
8730: 65 67 69 6e 20 0a 09 20 20 20 20 20 20 28 64 65  egin ..      (de
8740: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 46 61 69  bug:print 0 "Fai
8750: 6c 65 64 20 74 6f 20 73 65 74 75 70 2c 20 65 78  led to setup, ex
8760: 69 74 69 6e 67 22 29 0a 09 20 20 20 20 20 20 28  iting")..      (
8770: 65 78 69 74 20 31 29 29 29 0a 09 28 73 65 74 21  exit 1)))..(set!
8780: 20 64 62 20 20 20 28 6f 70 65 6e 2d 64 62 29 29   db   (open-db))
8790: 0a 09 28 69 66 20 28 61 72 67 73 3a 67 65 74 2d  ..(if (args:get-
87a0: 61 72 67 20 22 2d 73 65 72 76 65 72 22 29 0a 09  arg "-server")..
87b0: 20 20 20 20 28 73 65 72 76 65 72 3a 73 74 61 72      (server:star
87c0: 74 20 64 62 20 28 61 72 67 73 3a 67 65 74 2d 61  t db (args:get-a
87d0: 72 67 20 22 2d 73 65 72 76 65 72 22 29 29 0a 09  rg "-server"))..
87e0: 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28 6f 72      (if (not (or
87f0: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22   (args:get-arg "
8800: 2d 72 75 6e 61 6c 6c 22 29 0a 09 09 09 20 20 28  -runall")....  (
8810: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72  args:get-arg "-r
8820: 75 6e 74 65 73 74 73 22 29 29 29 0a 09 09 28 73  untests")))...(s
8830: 65 72 76 65 72 3a 63 6c 69 65 6e 74 2d 73 65 74  erver:client-set
8840: 75 70 20 64 62 29 29 29 0a 09 28 73 65 74 21 20  up db)))..(set! 
8850: 6b 65 79 73 20 28 72 64 62 3a 67 65 74 2d 6b 65  keys (rdb:get-ke
8860: 79 73 20 64 62 29 29 0a 09 3b 3b 20 68 61 76 65  ys db))..;; have
8870: 20 65 6e 6f 75 67 68 20 74 6f 20 70 72 6f 63 65   enough to proce
8880: 73 73 20 2d 74 61 72 67 65 74 20 6f 72 20 2d 72  ss -target or -r
8890: 65 71 74 61 72 67 20 68 65 72 65 0a 09 28 69 66  eqtarg here..(if
88a0: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22   (args:get-arg "
88b0: 2d 72 65 71 74 61 72 67 22 29 0a 09 20 20 20 20  -reqtarg")..    
88c0: 28 6c 65 74 2a 20 28 28 72 75 6e 63 6f 6e 66 69  (let* ((runconfi
88d0: 67 66 20 28 63 6f 6e 63 20 20 2a 74 6f 70 70 61  gf (conc  *toppa
88e0: 74 68 2a 20 22 2f 72 75 6e 63 6f 6e 66 69 67 73  th* "/runconfigs
88f0: 2e 63 6f 6e 66 69 67 22 29 29 20 3b 3b 20 44 4f  .config")) ;; DO
8900: 20 4e 4f 54 20 45 56 41 4c 55 41 54 45 20 41 4c   NOT EVALUATE AL
8910: 4c 20 0a 09 09 20 20 20 28 72 75 6e 63 6f 6e 66  L ...   (runconf
8920: 69 67 20 20 28 72 65 61 64 2d 63 6f 6e 66 69 67  ig  (read-config
8930: 20 72 75 6e 63 6f 6e 66 69 67 66 20 23 66 20 23   runconfigf #f #
8940: 66 20 65 6e 76 69 72 6f 6e 2d 70 61 74 74 3a 20  f environ-patt: 
8950: 23 66 29 29 29 20 0a 09 20 20 20 20 20 20 28 69  #f))) ..      (i
8960: 66 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65  f (hash-table-re
8970: 66 2f 64 65 66 61 75 6c 74 20 72 75 6e 63 6f 6e  f/default runcon
8980: 66 69 67 20 28 61 72 67 73 3a 67 65 74 2d 61 72  fig (args:get-ar
8990: 67 20 22 2d 72 65 71 74 61 72 67 22 29 20 23 66  g "-reqtarg") #f
89a0: 29 0a 09 09 20 20 28 6b 65 79 73 3a 74 61 72 67  )...  (keys:targ
89b0: 65 74 2d 73 65 74 2d 61 72 67 73 20 6b 65 79 73  et-set-args keys
89c0: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22   (args:get-arg "
89d0: 2d 72 65 71 74 61 72 67 22 29 20 61 72 67 73 3a  -reqtarg") args:
89e0: 61 72 67 2d 68 61 73 68 29 0a 09 09 20 20 28 62  arg-hash)...  (b
89f0: 65 67 69 6e 0a 09 09 20 20 20 20 28 64 65 62 75  egin...    (debu
8a00: 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52  g:print 0 "ERROR
8a10: 3a 20 5b 22 20 28 61 72 67 73 3a 67 65 74 2d 61  : [" (args:get-a
8a20: 72 67 20 22 2d 72 65 71 74 61 72 67 22 29 20 22  rg "-reqtarg") "
8a30: 5d 20 6e 6f 74 20 66 6f 75 6e 64 20 69 6e 20 22  ] not found in "
8a40: 20 72 75 6e 63 6f 6e 66 69 67 66 29 0a 09 09 20   runconfigf)... 
8a50: 20 20 20 28 73 71 6c 69 74 65 33 3a 66 69 6e 61     (sqlite3:fina
8a60: 6c 69 7a 65 21 20 64 62 29 0a 09 09 20 20 20 20  lize! db)...    
8a70: 28 65 78 69 74 20 31 29 29 29 29 0a 09 20 20 20  (exit 1))))..   
8a80: 20 28 69 66 20 28 61 72 67 73 3a 67 65 74 2d 61   (if (args:get-a
8a90: 72 67 20 22 2d 74 61 72 67 65 74 22 29 0a 09 09  rg "-target")...
8aa0: 28 6b 65 79 73 3a 74 61 72 67 65 74 2d 73 65 74  (keys:target-set
8ab0: 2d 61 72 67 73 20 6b 65 79 73 20 28 61 72 67 73  -args keys (args
8ac0: 3a 67 65 74 2d 61 72 67 20 22 2d 74 61 72 67 65  :get-arg "-targe
8ad0: 74 22 20 61 72 67 73 3a 61 72 67 2d 68 61 73 68  t" args:arg-hash
8ae0: 29 20 61 72 67 73 3a 61 72 67 2d 68 61 73 68 29  ) args:arg-hash)
8af0: 29 29 0a 09 28 69 66 20 28 6e 6f 74 20 28 63 61  ))..(if (not (ca
8b00: 72 20 2a 63 6f 6e 66 69 67 69 6e 66 6f 2a 29 29  r *configinfo*))
8b10: 0a 09 20 20 20 20 28 62 65 67 69 6e 0a 09 20 20  ..    (begin..  
8b20: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
8b30: 20 30 20 22 45 52 52 4f 52 3a 20 41 74 74 65 6d   0 "ERROR: Attem
8b40: 70 74 65 64 20 74 6f 20 22 20 61 63 74 69 6f 6e  pted to " action
8b50: 2d 64 65 73 63 20 22 20 62 75 74 20 72 75 6e 20  -desc " but run 
8b60: 61 72 65 61 20 63 6f 6e 66 69 67 20 66 69 6c 65  area config file
8b70: 20 6e 6f 74 20 66 6f 75 6e 64 22 29 0a 09 20 20   not found")..  
8b80: 20 20 20 20 28 65 78 69 74 20 31 29 29 0a 09 20      (exit 1)).. 
8b90: 20 20 20 3b 3b 20 45 78 74 72 61 63 74 20 6f 75     ;; Extract ou
8ba0: 74 20 73 74 75 66 66 20 6e 65 65 64 65 64 20 69  t stuff needed i
8bb0: 6e 20 6d 6f 73 74 20 6f 72 20 6d 61 6e 79 20 63  n most or many c
8bc0: 61 6c 6c 73 0a 09 20 20 20 20 3b 3b 20 68 65 72  alls..    ;; her
8bd0: 65 20 74 68 65 6e 20 63 61 6c 6c 20 70 72 6f 63  e then call proc
8be0: 0a 09 20 20 20 20 28 6c 65 74 2a 20 28 28 6b 65  ..    (let* ((ke
8bf0: 79 6e 61 6d 65 73 20 20 20 28 6d 61 70 20 6b 65  ynames   (map ke
8c00: 79 3a 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20  y:get-fieldname 
8c10: 6b 65 79 73 29 29 0a 09 09 20 20 20 28 6b 65 79  keys))...   (key
8c20: 76 61 6c 6c 73 74 20 20 28 6b 65 79 73 2d 3e 76  vallst  (keys->v
8c30: 61 6c 6c 69 73 74 20 6b 65 79 73 20 23 74 29 29  allist keys #t))
8c40: 29 0a 09 20 20 20 20 20 20 28 70 72 6f 63 20 64  )..      (proc d
8c50: 62 20 74 61 72 67 65 74 20 72 75 6e 6e 61 6d 65  b target runname
8c60: 20 6b 65 79 73 20 6b 65 79 6e 61 6d 65 73 20 6b   keys keynames k
8c70: 65 79 76 61 6c 6c 73 74 29 29 29 0a 09 28 69 66  eyvallst)))..(if
8c80: 20 74 68 31 20 28 74 68 72 65 61 64 2d 6a 6f 69   th1 (thread-joi
8c90: 6e 21 20 74 68 31 29 29 0a 09 28 73 71 6c 69 74  n! th1))..(sqlit
8ca0: 65 33 3a 66 69 6e 61 6c 69 7a 65 21 20 64 62 29  e3:finalize! db)
8cb0: 0a 09 28 73 65 74 21 20 2a 64 69 64 73 6f 6d 65  ..(set! *didsome
8cc0: 74 68 69 6e 67 2a 20 23 74 29 29 29 29 29 29 0a  thing* #t)))))).
8cd0: 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  .;;=============
8ce0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
8cf0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
8d00: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
8d10: 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 4c 6f 63  =========.;; Loc
8d20: 6b 2f 75 6e 6c 6f 63 6b 20 72 75 6e 73 0a 3b 3b  k/unlock runs.;;
8d30: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
8d40: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
8d50: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
8d60: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
8d70: 3d 3d 3d 3d 3d 3d 0a 0a 28 64 65 66 69 6e 65 20  ======..(define 
8d80: 28 72 75 6e 73 3a 68 61 6e 64 6c 65 2d 6c 6f 63  (runs:handle-loc
8d90: 6b 69 6e 67 20 64 62 20 74 61 72 67 65 74 20 6b  king db target k
8da0: 65 79 73 20 72 75 6e 6e 61 6d 65 20 6c 6f 63 6b  eys runname lock
8db0: 20 75 6e 6c 6f 63 6b 20 75 73 65 72 29 0a 20 20   unlock user).  
8dc0: 28 6c 65 74 2a 20 28 28 72 75 6e 64 61 74 20 20  (let* ((rundat  
8dd0: 20 28 72 75 6e 73 3a 67 65 74 2d 72 75 6e 73 2d   (runs:get-runs-
8de0: 62 79 2d 70 61 74 74 20 64 62 20 6b 65 79 73 20  by-patt db keys 
8df0: 72 75 6e 6e 61 6d 65 29 29 0a 09 20 28 68 65 61  runname)).. (hea
8e00: 64 65 72 20 20 20 28 76 65 63 74 6f 72 2d 72 65  der   (vector-re
8e10: 66 20 72 75 6e 64 61 74 20 30 29 29 0a 09 20 28  f rundat 0)).. (
8e20: 72 75 6e 73 20 20 20 20 20 28 76 65 63 74 6f 72  runs     (vector
8e30: 2d 72 65 66 20 72 75 6e 64 61 74 20 31 29 29 29  -ref rundat 1)))
8e40: 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20 28  .    (for-each (
8e50: 6c 61 6d 62 64 61 20 28 72 75 6e 29 0a 09 09 28  lambda (run)...(
8e60: 6c 65 74 20 28 28 72 75 6e 2d 69 64 20 28 64 62  let ((run-id (db
8e70: 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65  :get-value-by-he
8e80: 61 64 65 72 20 72 75 6e 20 68 65 61 64 65 72 20  ader run header 
8e90: 22 69 64 22 29 29 29 0a 09 09 20 20 28 69 66 20  "id")))...  (if 
8ea0: 28 6f 72 20 6c 6f 63 6b 0a 09 09 09 20 20 28 61  (or lock....  (a
8eb0: 6e 64 20 75 6e 6c 6f 63 6b 0a 09 09 09 20 20 20  nd unlock....   
8ec0: 20 20 20 20 28 62 65 67 69 6e 0a 09 09 09 09 20      (begin..... 
8ed0: 28 70 72 69 6e 74 20 22 44 6f 20 79 6f 75 20 72  (print "Do you r
8ee0: 65 61 6c 6c 79 20 77 69 73 68 20 74 6f 20 75 6e  eally wish to un
8ef0: 6c 6f 63 6b 20 72 75 6e 20 22 20 72 75 6e 2d 69  lock run " run-i
8f00: 64 20 22 3f 5c 6e 20 20 20 79 2f 6e 3a 20 22 29  d "?\n   y/n: ")
8f10: 0a 09 09 09 09 20 28 65 71 75 61 6c 3f 20 22 79  ..... (equal? "y
8f20: 22 20 28 72 65 61 64 2d 6c 69 6e 65 29 29 29 29  " (read-line))))
8f30: 29 0a 09 09 20 20 20 20 20 20 28 64 62 3a 6c 6f  )...      (db:lo
8f40: 63 6b 2f 75 6e 6c 6f 63 6b 2d 72 75 6e 20 64 62  ck/unlock-run db
8f50: 20 72 75 6e 2d 69 64 20 6c 6f 63 6b 20 75 6e 6c   run-id lock unl
8f60: 6f 63 6b 20 75 73 65 72 29 0a 09 09 20 20 20 20  ock user)...    
8f70: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30    (debug:print 0
8f80: 20 22 49 4e 46 4f 3a 20 53 6b 69 70 70 69 6e 67   "INFO: Skipping
8f90: 20 6c 6f 63 6b 2f 75 6e 6c 6f 63 6b 20 6f 6e 20   lock/unlock on 
8fa0: 22 20 72 75 6e 2d 69 64 29 29 29 29 0a 09 20 20  " run-id))))..  
8fb0: 20 20 20 20 72 75 6e 73 29 29 29 0a 3b 3b 3d 3d      runs))).;;==
8fc0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
8fd0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
8fe0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
8ff0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9000: 3d 3d 3d 3d 0a 3b 3b 20 52 6f 6c 6c 75 70 20 72  ====.;; Rollup r
9010: 75 6e 73 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  uns.;;==========
9020: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9030: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9040: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9050: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b  ============..;;
9060: 20 55 70 64 61 74 65 20 74 68 65 20 74 65 73 74   Update the test
9070: 5f 6d 65 74 61 20 74 61 62 6c 65 20 66 6f 72 20  _meta table for 
9080: 74 68 69 73 20 74 65 73 74 0a 28 64 65 66 69 6e  this test.(defin
9090: 65 20 28 72 75 6e 73 3a 75 70 64 61 74 65 2d 74  e (runs:update-t
90a0: 65 73 74 5f 6d 65 74 61 20 64 62 20 74 65 73 74  est_meta db test
90b0: 2d 6e 61 6d 65 20 74 65 73 74 2d 63 6f 6e 66 29  -name test-conf)
90c0: 0a 20 20 28 6c 65 74 20 28 28 63 75 72 72 72 65  .  (let ((currre
90d0: 63 6f 72 64 20 28 64 62 3a 74 65 73 74 6d 65 74  cord (db:testmet
90e0: 61 2d 67 65 74 2d 72 65 63 6f 72 64 20 64 62 20  a-get-record db 
90f0: 74 65 73 74 2d 6e 61 6d 65 29 29 29 0a 20 20 20  test-name))).   
9100: 20 28 69 66 20 28 6e 6f 74 20 63 75 72 72 72 65   (if (not currre
9110: 63 6f 72 64 29 0a 09 28 62 65 67 69 6e 0a 09 20  cord)..(begin.. 
9120: 20 28 73 65 74 21 20 63 75 72 72 72 65 63 6f 72   (set! currrecor
9130: 64 20 28 6d 61 6b 65 2d 76 65 63 74 6f 72 20 31  d (make-vector 1
9140: 30 20 23 66 29 29 0a 09 20 20 28 64 62 3a 74 65  0 #f))..  (db:te
9150: 73 74 6d 65 74 61 2d 61 64 64 2d 72 65 63 6f 72  stmeta-add-recor
9160: 64 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 29 29  d db test-name))
9170: 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20  ).    (for-each 
9180: 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 6b  .     (lambda (k
9190: 65 79 29 0a 20 20 20 20 20 20 20 28 6c 65 74 2a  ey).       (let*
91a0: 20 28 28 69 64 78 20 28 63 61 64 72 20 6b 65 79   ((idx (cadr key
91b0: 29 29 0a 09 20 20 20 20 20 20 28 66 6c 64 20 28  ))..      (fld (
91c0: 63 61 72 20 20 6b 65 79 29 29 0a 09 20 20 20 20  car  key))..    
91d0: 20 20 28 76 61 6c 20 28 63 6f 6e 66 69 67 2d 6c    (val (config-l
91e0: 6f 6f 6b 75 70 20 74 65 73 74 2d 63 6f 6e 66 20  ookup test-conf 
91f0: 22 74 65 73 74 5f 6d 65 74 61 22 20 66 6c 64 29  "test_meta" fld)
9200: 29 29 0a 09 20 3b 3b 20 28 64 65 62 75 67 3a 70  )).. ;; (debug:p
9210: 72 69 6e 74 20 35 20 22 69 64 78 3a 20 22 20 69  rint 5 "idx: " i
9220: 64 78 20 22 20 66 6c 64 3a 20 22 20 66 6c 64 20  dx " fld: " fld 
9230: 22 20 76 61 6c 3a 20 22 20 76 61 6c 29 0a 09 20  " val: " val).. 
9240: 28 69 66 20 28 61 6e 64 20 76 61 6c 20 28 6e 6f  (if (and val (no
9250: 74 20 28 65 71 75 61 6c 3f 20 28 76 65 63 74 6f  t (equal? (vecto
9260: 72 2d 72 65 66 20 63 75 72 72 72 65 63 6f 72 64  r-ref currrecord
9270: 20 69 64 78 29 20 76 61 6c 29 29 29 0a 09 20 20   idx) val)))..  
9280: 20 20 20 28 62 65 67 69 6e 0a 09 20 20 20 20 20     (begin..     
9290: 20 20 28 70 72 69 6e 74 20 22 55 70 64 61 74 69    (print "Updati
92a0: 6e 67 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22  ng " test-name "
92b0: 20 22 20 66 6c 64 20 22 20 74 6f 20 22 20 76 61   " fld " to " va
92c0: 6c 29 0a 09 20 20 20 20 20 20 20 28 64 62 3a 74  l)..       (db:t
92d0: 65 73 74 6d 65 74 61 2d 75 70 64 61 74 65 2d 66  estmeta-update-f
92e0: 69 65 6c 64 20 64 62 20 74 65 73 74 2d 6e 61 6d  ield db test-nam
92f0: 65 20 66 6c 64 20 76 61 6c 29 29 29 29 29 0a 20  e fld val))))). 
9300: 20 20 20 20 27 28 28 22 61 75 74 68 6f 72 22 20      '(("author" 
9310: 32 29 28 22 6f 77 6e 65 72 22 20 33 29 28 22 64  2)("owner" 3)("d
9320: 65 73 63 72 69 70 74 69 6f 6e 22 20 34 29 28 22  escription" 4)("
9330: 72 65 76 69 65 77 65 64 22 20 35 29 28 22 74 61  reviewed" 5)("ta
9340: 67 73 22 20 39 29 29 29 29 29 0a 0a 3b 3b 20 55  gs" 9)))))..;; U
9350: 70 64 61 74 65 20 74 65 73 74 5f 6d 65 74 61 20  pdate test_meta 
9360: 66 6f 72 20 61 6c 6c 20 74 65 73 74 73 0a 28 64  for all tests.(d
9370: 65 66 69 6e 65 20 28 72 75 6e 73 3a 75 70 64 61  efine (runs:upda
9380: 74 65 2d 61 6c 6c 2d 74 65 73 74 5f 6d 65 74 61  te-all-test_meta
9390: 20 64 62 29 0a 20 20 28 6c 65 74 20 28 28 74 65   db).  (let ((te
93a0: 73 74 2d 6e 61 6d 65 73 20 28 67 65 74 2d 61 6c  st-names (get-al
93b0: 6c 2d 6c 65 67 61 6c 2d 74 65 73 74 73 29 29 29  l-legal-tests)))
93c0: 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20 0a  .    (for-each .
93d0: 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 74 65       (lambda (te
93e0: 73 74 2d 6e 61 6d 65 29 0a 20 20 20 20 20 20 20  st-name).       
93f0: 28 6c 65 74 2a 20 28 28 74 65 73 74 2d 70 61 74  (let* ((test-pat
9400: 68 20 20 20 20 28 63 6f 6e 63 20 2a 74 6f 70 70  h    (conc *topp
9410: 61 74 68 2a 20 22 2f 74 65 73 74 73 2f 22 20 74  ath* "/tests/" t
9420: 65 73 74 2d 6e 61 6d 65 29 29 0a 09 20 20 20 20  est-name))..    
9430: 20 20 28 74 65 73 74 2d 63 6f 6e 66 69 67 66 20    (test-configf 
9440: 28 63 6f 6e 63 20 74 65 73 74 2d 70 61 74 68 20  (conc test-path 
9450: 22 2f 74 65 73 74 63 6f 6e 66 69 67 22 29 29 0a  "/testconfig")).
9460: 09 20 20 20 20 20 20 28 74 65 73 74 65 78 69 73  .      (testexis
9470: 74 73 20 20 20 28 61 6e 64 20 28 66 69 6c 65 2d  ts   (and (file-
9480: 65 78 69 73 74 73 3f 20 74 65 73 74 2d 63 6f 6e  exists? test-con
9490: 66 69 67 66 29 28 66 69 6c 65 2d 72 65 61 64 2d  figf)(file-read-
94a0: 61 63 63 65 73 73 3f 20 74 65 73 74 2d 63 6f 6e  access? test-con
94b0: 66 69 67 66 29 29 29 0a 09 20 20 20 20 20 20 3b  figf)))..      ;
94c0: 3b 20 72 65 61 64 20 63 6f 6e 66 69 67 73 20 77  ; read configs w
94d0: 69 74 68 20 74 72 69 63 6b 73 20 74 75 72 6e 65  ith tricks turne
94e0: 64 20 6f 66 66 20 28 69 2e 65 2e 20 6e 6f 20 73  d off (i.e. no s
94f0: 79 73 74 65 6d 29 0a 09 20 20 20 20 20 20 28 74  ystem)..      (t
9500: 65 73 74 2d 63 6f 6e 66 20 20 20 20 28 69 66 20  est-conf    (if 
9510: 74 65 73 74 65 78 69 73 74 73 20 28 72 65 61 64  testexists (read
9520: 2d 63 6f 6e 66 69 67 20 74 65 73 74 2d 63 6f 6e  -config test-con
9530: 66 69 67 66 20 23 66 20 23 66 29 28 6d 61 6b 65  figf #f #f)(make
9540: 2d 68 61 73 68 2d 74 61 62 6c 65 29 29 29 29 0a  -hash-table)))).
9550: 09 20 28 72 75 6e 73 3a 75 70 64 61 74 65 2d 74  . (runs:update-t
9560: 65 73 74 5f 6d 65 74 61 20 64 62 20 74 65 73 74  est_meta db test
9570: 2d 6e 61 6d 65 20 74 65 73 74 2d 63 6f 6e 66 29  -name test-conf)
9580: 29 29 0a 20 20 20 20 20 74 65 73 74 2d 6e 61 6d  )).     test-nam
9590: 65 73 29 29 29 0a 0a 3b 3b 20 54 68 69 73 20 63  es)))..;; This c
95a0: 6f 75 6c 64 20 70 72 6f 62 61 62 6c 79 20 62 65  ould probably be
95b0: 20 72 65 66 61 63 74 6f 72 65 64 20 69 6e 74 6f   refactored into
95c0: 20 6f 6e 65 20 63 6f 6d 70 6c 65 78 20 71 75 65   one complex que
95d0: 72 79 20 2e 2e 2e 0a 28 64 65 66 69 6e 65 20 28  ry ....(define (
95e0: 72 75 6e 73 3a 72 6f 6c 6c 75 70 2d 72 75 6e 20  runs:rollup-run 
95f0: 64 62 20 6b 65 79 73 20 6b 65 79 76 61 6c 6c 73  db keys keyvalls
9600: 74 20 72 75 6e 6e 61 6d 65 20 75 73 65 72 29 20  t runname user) 
9610: 3b 3b 20 77 61 73 20 74 61 72 67 65 74 2c 20 6e  ;; was target, n
9620: 6f 77 20 6b 65 79 76 61 6c 6c 73 74 0a 20 20 28  ow keyvallst.  (
9630: 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 72  debug:print 4 "r
9640: 75 6e 73 3a 72 6f 6c 6c 75 70 2d 72 75 6e 2c 20  uns:rollup-run, 
9650: 6b 65 79 73 3a 20 22 20 6b 65 79 73 20 22 20 6b  keys: " keys " k
9660: 65 79 76 61 6c 6c 73 74 3a 20 22 20 6b 65 79 76  eyvallst: " keyv
9670: 61 6c 6c 73 74 20 22 20 3a 72 75 6e 6e 61 6d 65  allst " :runname
9680: 20 22 20 72 75 6e 6e 61 6d 65 20 22 20 75 73 65   " runname " use
9690: 72 3a 20 22 20 75 73 65 72 29 0a 20 20 28 6c 65  r: " user).  (le
96a0: 74 2a 20 28 3b 20 28 6b 65 79 76 61 6c 6c 6c 73  t* (; (keyvallls
96b0: 74 20 20 20 20 20 20 28 6b 65 79 73 3a 74 61 72  t      (keys:tar
96c0: 67 65 74 2d 3e 6b 65 79 76 61 6c 20 6b 65 79 73  get->keyval keys
96d0: 20 74 61 72 67 65 74 29 29 0a 09 20 28 6e 65 77   target)).. (new
96e0: 2d 72 75 6e 2d 69 64 20 20 20 20 20 20 28 72 75  -run-id      (ru
96f0: 6e 73 3a 72 65 67 69 73 74 65 72 2d 72 75 6e 20  ns:register-run 
9700: 64 62 20 6b 65 79 73 20 6b 65 79 76 61 6c 6c 73  db keys keyvalls
9710: 74 20 72 75 6e 6e 61 6d 65 20 22 6e 65 77 22 20  t runname "new" 
9720: 22 6e 2f 61 22 20 75 73 65 72 29 29 0a 09 20 28  "n/a" user)).. (
9730: 70 72 65 76 2d 74 65 73 74 73 20 20 20 20 20 20  prev-tests      
9740: 28 74 65 73 74 3a 67 65 74 2d 6d 61 74 63 68 69  (test:get-matchi
9750: 6e 67 2d 70 72 65 76 69 6f 75 73 2d 74 65 73 74  ng-previous-test
9760: 2d 72 75 6e 2d 72 65 63 6f 72 64 73 20 64 62 20  -run-records db 
9770: 6e 65 77 2d 72 75 6e 2d 69 64 20 22 25 22 20 22  new-run-id "%" "
9780: 25 22 29 29 0a 09 20 28 63 75 72 72 2d 74 65 73  %")).. (curr-tes
9790: 74 73 20 20 20 20 20 20 28 72 64 62 3a 67 65 74  ts      (rdb:get
97a0: 2d 74 65 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64  -tests-for-run d
97b0: 62 20 6e 65 77 2d 72 75 6e 2d 69 64 20 22 25 22  b new-run-id "%"
97c0: 20 22 25 22 20 27 28 29 20 27 28 29 29 29 0a 09   "%" '() '()))..
97d0: 20 28 63 75 72 72 2d 74 65 73 74 73 2d 68 61 73   (curr-tests-has
97e0: 68 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62  h (make-hash-tab
97f0: 6c 65 29 29 29 0a 20 20 20 20 28 64 62 3a 75 70  le))).    (db:up
9800: 64 61 74 65 2d 72 75 6e 2d 65 76 65 6e 74 5f 74  date-run-event_t
9810: 69 6d 65 20 64 62 20 6e 65 77 2d 72 75 6e 2d 69  ime db new-run-i
9820: 64 29 0a 20 20 20 20 3b 3b 20 69 6e 64 65 78 20  d).    ;; index 
9830: 74 68 65 20 61 6c 72 65 61 64 79 20 73 61 76 65  the already save
9840: 64 20 74 65 73 74 73 20 62 79 20 74 65 73 74 6e  d tests by testn
9850: 61 6d 65 20 61 6e 64 20 69 74 65 6d 64 61 74 20  ame and itemdat 
9860: 69 6e 20 63 75 72 72 2d 74 65 73 74 73 2d 68 61  in curr-tests-ha
9870: 73 68 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68  sh.    (for-each
9880: 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 74  .     (lambda (t
9890: 65 73 74 64 61 74 29 0a 20 20 20 20 20 20 20 28  estdat).       (
98a0: 6c 65 74 2a 20 28 28 74 65 73 74 6e 61 6d 65 20  let* ((testname 
98b0: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 74 65   (db:test-get-te
98c0: 73 74 6e 61 6d 65 20 74 65 73 74 64 61 74 29 29  stname testdat))
98d0: 0a 09 20 20 20 20 20 20 28 69 74 65 6d 2d 70 61  ..      (item-pa
98e0: 74 68 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  th (db:test-get-
98f0: 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 64 61  item-path testda
9900: 74 29 29 0a 09 20 20 20 20 20 20 28 66 75 6c 6c  t))..      (full
9910: 2d 6e 61 6d 65 20 28 63 6f 6e 63 20 74 65 73 74  -name (conc test
9920: 6e 61 6d 65 20 22 2f 22 20 69 74 65 6d 2d 70 61  name "/" item-pa
9930: 74 68 29 29 29 0a 09 20 28 68 61 73 68 2d 74 61  th))).. (hash-ta
9940: 62 6c 65 2d 73 65 74 21 20 63 75 72 72 2d 74 65  ble-set! curr-te
9950: 73 74 73 2d 68 61 73 68 20 66 75 6c 6c 2d 6e 61  sts-hash full-na
9960: 6d 65 20 74 65 73 74 64 61 74 29 29 29 0a 20 20  me testdat))).  
9970: 20 20 20 63 75 72 72 2d 74 65 73 74 73 29 0a 20     curr-tests). 
9980: 20 20 20 3b 3b 20 4e 4f 50 45 3a 20 4e 6f 6e 2d     ;; NOPE: Non-
9990: 6f 70 74 69 6d 61 6c 20 61 70 70 72 6f 61 63 68  optimal approach
99a0: 2e 20 54 72 79 20 74 68 69 73 20 69 6e 73 74 65  . Try this inste
99b0: 61 64 2e 0a 20 20 20 20 3b 3b 20 20 20 31 2e 20  ad..    ;;   1. 
99c0: 74 65 73 74 73 20 61 72 65 20 72 65 63 65 69 76  tests are receiv
99d0: 65 64 20 69 6e 20 61 20 6c 69 73 74 2c 20 6d 6f  ed in a list, mo
99e0: 73 74 20 72 65 63 65 6e 74 20 66 69 72 73 74 0a  st recent first.
99f0: 20 20 20 20 3b 3b 20 20 20 32 2e 20 72 65 70 6c      ;;   2. repl
9a00: 61 63 65 20 74 68 65 20 72 6f 6c 6c 75 70 20 74  ace the rollup t
9a10: 65 73 74 20 77 69 74 68 20 74 68 65 20 6e 65 77  est with the new
9a20: 20 2a 61 6c 77 61 79 73 2a 0a 20 20 20 20 28 66   *always*.    (f
9a30: 6f 72 2d 65 61 63 68 20 0a 20 20 20 20 20 28 6c  or-each .     (l
9a40: 61 6d 62 64 61 20 28 74 65 73 74 64 61 74 29 0a  ambda (testdat).
9a50: 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28 28 74         (let* ((t
9a60: 65 73 74 6e 61 6d 65 20 20 28 64 62 3a 74 65 73  estname  (db:tes
9a70: 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 74  t-get-testname t
9a80: 65 73 74 64 61 74 29 29 0a 09 20 20 20 20 20 20  estdat))..      
9a90: 28 69 74 65 6d 2d 70 61 74 68 20 28 64 62 3a 74  (item-path (db:t
9aa0: 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74  est-get-item-pat
9ab0: 68 20 74 65 73 74 64 61 74 29 29 0a 09 20 20 20  h testdat))..   
9ac0: 20 20 20 28 66 75 6c 6c 2d 6e 61 6d 65 20 28 63     (full-name (c
9ad0: 6f 6e 63 20 74 65 73 74 6e 61 6d 65 20 22 2f 22  onc testname "/"
9ae0: 20 69 74 65 6d 2d 70 61 74 68 29 29 0a 09 20 20   item-path))..  
9af0: 20 20 20 20 28 70 72 65 76 2d 74 65 73 74 2d 64      (prev-test-d
9b00: 61 74 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72  at (hash-table-r
9b10: 65 66 2f 64 65 66 61 75 6c 74 20 63 75 72 72 2d  ef/default curr-
9b20: 74 65 73 74 73 2d 68 61 73 68 20 66 75 6c 6c 2d  tests-hash full-
9b30: 6e 61 6d 65 20 23 66 29 29 0a 09 20 20 20 20 20  name #f))..     
9b40: 20 28 74 65 73 74 2d 73 74 65 70 73 20 20 20 20   (test-steps    
9b50: 20 20 28 64 62 3a 67 65 74 2d 73 74 65 70 73 2d    (db:get-steps-
9b60: 66 6f 72 2d 74 65 73 74 20 64 62 20 28 64 62 3a  for-test db (db:
9b70: 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74  test-get-id test
9b80: 64 61 74 29 29 29 0a 09 20 20 20 20 20 20 28 6e  dat)))..      (n
9b90: 65 77 2d 74 65 73 74 2d 72 65 63 6f 72 64 20 23  ew-test-record #
9ba0: 66 29 29 0a 09 20 3b 3b 20 72 65 70 6c 61 63 65  f)).. ;; replace
9bb0: 20 74 68 65 73 65 20 77 69 74 68 20 69 6e 73 65   these with inse
9bc0: 72 74 20 2e 2e 2e 20 73 65 6c 65 63 74 0a 09 20  rt ... select.. 
9bd0: 28 61 70 70 6c 79 20 73 71 6c 69 74 65 33 3a 65  (apply sqlite3:e
9be0: 78 65 63 75 74 65 20 0a 09 09 64 62 20 0a 09 09  xecute ...db ...
9bf0: 28 63 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f 52  (conc "INSERT OR
9c00: 20 52 45 50 4c 41 43 45 20 49 4e 54 4f 20 74 65   REPLACE INTO te
9c10: 73 74 73 20 28 72 75 6e 5f 69 64 2c 74 65 73 74  sts (run_id,test
9c20: 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 61 74 75  name,state,statu
9c30: 73 2c 65 76 65 6e 74 5f 74 69 6d 65 2c 68 6f 73  s,event_time,hos
9c40: 74 2c 63 70 75 6c 6f 61 64 2c 64 69 73 6b 66 72  t,cpuload,diskfr
9c50: 65 65 2c 75 6e 61 6d 65 2c 72 75 6e 64 69 72 2c  ee,uname,rundir,
9c60: 69 74 65 6d 5f 70 61 74 68 2c 72 75 6e 5f 64 75  item_path,run_du
9c70: 72 61 74 69 6f 6e 2c 66 69 6e 61 6c 5f 6c 6f 67  ration,final_log
9c80: 66 2c 63 6f 6d 6d 65 6e 74 29 20 22 0a 09 09 20  f,comment) "... 
9c90: 20 20 20 20 20 22 56 41 4c 55 45 53 20 28 3f 2c       "VALUES (?,
9ca0: 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c  ?,?,?,?,?,?,?,?,
9cb0: 3f 2c 3f 2c 3f 2c 3f 2c 3f 29 3b 22 29 0a 09 09  ?,?,?,?,?);")...
9cc0: 6e 65 77 2d 72 75 6e 2d 69 64 20 28 63 64 64 72  new-run-id (cddr
9cd0: 20 28 76 65 63 74 6f 72 2d 3e 6c 69 73 74 20 74   (vector->list t
9ce0: 65 73 74 64 61 74 29 29 29 0a 09 20 28 73 65 74  estdat))).. (set
9cf0: 21 20 6e 65 77 2d 74 65 73 74 64 61 74 20 28 63  ! new-testdat (c
9d00: 61 72 20 28 72 64 62 3a 67 65 74 2d 74 65 73 74  ar (rdb:get-test
9d10: 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 6e 65 77  s-for-run db new
9d20: 2d 72 75 6e 2d 69 64 20 74 65 73 74 6e 61 6d 65  -run-id testname
9d30: 20 69 74 65 6d 2d 70 61 74 68 20 27 28 29 20 27   item-path '() '
9d40: 28 29 29 29 29 0a 09 20 28 68 61 73 68 2d 74 61  ()))).. (hash-ta
9d50: 62 6c 65 2d 73 65 74 21 20 63 75 72 72 2d 74 65  ble-set! curr-te
9d60: 73 74 73 2d 68 61 73 68 20 66 75 6c 6c 2d 6e 61  sts-hash full-na
9d70: 6d 65 20 6e 65 77 2d 74 65 73 74 64 61 74 29 20  me new-testdat) 
9d80: 3b 3b 20 74 68 69 73 20 63 6f 75 6c 64 20 62 65  ;; this could be
9d90: 20 63 6f 6e 66 75 73 69 6e 67 2c 20 77 68 69 63   confusing, whic
9da0: 68 20 72 65 63 6f 72 64 20 73 68 6f 75 6c 64 20  h record should 
9db0: 67 6f 20 69 6e 74 6f 20 74 68 65 20 6c 6f 6f 6b  go into the look
9dc0: 75 70 20 74 61 62 6c 65 3f 0a 09 20 3b 3b 20 4e  up table?.. ;; N
9dd0: 6f 77 20 64 75 70 6c 69 63 61 74 65 20 74 68 65  ow duplicate the
9de0: 20 74 65 73 74 20 73 74 65 70 73 0a 09 20 28 64   test steps.. (d
9df0: 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 43 6f  ebug:print 4 "Co
9e00: 70 79 69 6e 67 20 72 65 63 6f 72 64 73 20 69 6e  pying records in
9e10: 20 74 65 73 74 5f 73 74 65 70 73 20 66 72 6f 6d   test_steps from
9e20: 20 74 65 73 74 5f 69 64 3d 22 20 28 64 62 3a 74   test_id=" (db:t
9e30: 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74 64  est-get-id testd
9e40: 61 74 29 20 22 20 74 6f 20 22 20 28 64 62 3a 74  at) " to " (db:t
9e50: 65 73 74 2d 67 65 74 2d 69 64 20 6e 65 77 2d 74  est-get-id new-t
9e60: 65 73 74 64 61 74 29 29 0a 09 20 28 73 71 6c 69  estdat)).. (sqli
9e70: 74 65 33 3a 65 78 65 63 75 74 65 20 0a 09 20 20  te3:execute ..  
9e80: 64 62 20 0a 09 20 20 28 63 6f 6e 63 20 22 49 4e  db ..  (conc "IN
9e90: 53 45 52 54 20 4f 52 20 52 45 50 4c 41 43 45 20  SERT OR REPLACE 
9ea0: 49 4e 54 4f 20 74 65 73 74 5f 73 74 65 70 73 20  INTO test_steps 
9eb0: 28 74 65 73 74 5f 69 64 2c 73 74 65 70 6e 61 6d  (test_id,stepnam
9ec0: 65 2c 73 74 61 74 65 2c 73 74 61 74 75 73 2c 65  e,state,status,e
9ed0: 76 65 6e 74 5f 74 69 6d 65 2c 63 6f 6d 6d 65 6e  vent_time,commen
9ee0: 74 29 20 22 0a 09 09 22 53 45 4c 45 43 54 20 22  t) "..."SELECT "
9ef0: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64   (db:test-get-id
9f00: 20 6e 65 77 2d 74 65 73 74 64 61 74 29 20 22 2c   new-testdat) ",
9f10: 73 74 65 70 6e 61 6d 65 2c 73 74 61 74 65 2c 73  stepname,state,s
9f20: 74 61 74 75 73 2c 65 76 65 6e 74 5f 74 69 6d 65  tatus,event_time
9f30: 2c 63 6f 6d 6d 65 6e 74 20 46 52 4f 4d 20 74 65  ,comment FROM te
9f40: 73 74 5f 73 74 65 70 73 20 57 48 45 52 45 20 74  st_steps WHERE t
9f50: 65 73 74 5f 69 64 3d 3f 3b 22 29 0a 09 20 20 28  est_id=?;")..  (
9f60: 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74  db:test-get-id t
9f70: 65 73 74 64 61 74 29 29 0a 09 20 3b 3b 20 4e 6f  estdat)).. ;; No
9f80: 77 20 64 75 70 6c 69 63 61 74 65 20 74 68 65 20  w duplicate the 
9f90: 74 65 73 74 20 64 61 74 61 0a 09 20 28 64 65 62  test data.. (deb
9fa0: 75 67 3a 70 72 69 6e 74 20 34 20 22 43 6f 70 79  ug:print 4 "Copy
9fb0: 69 6e 67 20 72 65 63 6f 72 64 73 20 69 6e 20 74  ing records in t
9fc0: 65 73 74 5f 64 61 74 61 20 66 72 6f 6d 20 74 65  est_data from te
9fd0: 73 74 5f 69 64 3d 22 20 28 64 62 3a 74 65 73 74  st_id=" (db:test
9fe0: 2d 67 65 74 2d 69 64 20 74 65 73 74 64 61 74 29  -get-id testdat)
9ff0: 20 22 20 74 6f 20 22 20 28 64 62 3a 74 65 73 74   " to " (db:test
a000: 2d 67 65 74 2d 69 64 20 6e 65 77 2d 74 65 73 74  -get-id new-test
a010: 64 61 74 29 29 0a 09 20 28 73 71 6c 69 74 65 33  dat)).. (sqlite3
a020: 3a 65 78 65 63 75 74 65 20 0a 09 20 20 64 62 20  :execute ..  db 
a030: 0a 09 20 20 28 63 6f 6e 63 20 22 49 4e 53 45 52  ..  (conc "INSER
a040: 54 20 4f 52 20 52 45 50 4c 41 43 45 20 49 4e 54  T OR REPLACE INT
a050: 4f 20 74 65 73 74 5f 64 61 74 61 20 28 74 65 73  O test_data (tes
a060: 74 5f 69 64 2c 63 61 74 65 67 6f 72 79 2c 76 61  t_id,category,va
a070: 72 69 61 62 6c 65 2c 76 61 6c 75 65 2c 65 78 70  riable,value,exp
a080: 65 63 74 65 64 2c 74 6f 6c 2c 75 6e 69 74 73 2c  ected,tol,units,
a090: 63 6f 6d 6d 65 6e 74 29 20 22 0a 09 09 22 53 45  comment) "..."SE
a0a0: 4c 45 43 54 20 22 20 28 64 62 3a 74 65 73 74 2d  LECT " (db:test-
a0b0: 67 65 74 2d 69 64 20 6e 65 77 2d 74 65 73 74 64  get-id new-testd
a0c0: 61 74 29 20 22 2c 63 61 74 65 67 6f 72 79 2c 76  at) ",category,v
a0d0: 61 72 69 61 62 6c 65 2c 76 61 6c 75 65 2c 65 78  ariable,value,ex
a0e0: 70 65 63 74 65 64 2c 74 6f 6c 2c 75 6e 69 74 73  pected,tol,units
a0f0: 2c 63 6f 6d 6d 65 6e 74 20 46 52 4f 4d 20 74 65  ,comment FROM te
a100: 73 74 5f 64 61 74 61 20 57 48 45 52 45 20 74 65  st_data WHERE te
a110: 73 74 5f 69 64 3d 3f 3b 22 29 0a 09 20 20 28 64  st_id=?;")..  (d
a120: 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65  b:test-get-id te
a130: 73 74 64 61 74 29 29 0a 09 20 29 29 0a 20 20 20  stdat)).. )).   
a140: 20 20 70 72 65 76 2d 74 65 73 74 73 29 29 29 0a    prev-tests))).
a150: 09 20 0a 20 20 20 20 20 0a                       . .     .