Megatest

Hex Artifact Content
Login

Artifact 41259c2446f957fe1e07e384d11cdd3f912733c1:


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 29 0a  69 dot-locking).
01c0: 28 69 6d 70 6f 72 74 20 28 70 72 65 66 69 78 20  (import (prefix 
01d0: 73 71 6c 69 74 65 33 20 73 71 6c 69 74 65 33 3a  sqlite3 sqlite3:
01e0: 29 29 0a 0a 28 64 65 63 6c 61 72 65 20 28 75 6e  ))..(declare (un
01f0: 69 74 20 72 75 6e 73 29 29 0a 28 64 65 63 6c 61  it runs)).(decla
0200: 72 65 20 28 75 73 65 73 20 64 62 29 29 0a 28 64  re (uses db)).(d
0210: 65 63 6c 61 72 65 20 28 75 73 65 73 20 63 6f 6d  eclare (uses com
0220: 6d 6f 6e 29 29 0a 28 64 65 63 6c 61 72 65 20 28  mon)).(declare (
0230: 75 73 65 73 20 69 74 65 6d 73 29 29 0a 28 64 65  uses items)).(de
0240: 63 6c 61 72 65 20 28 75 73 65 73 20 72 75 6e 63  clare (uses runc
0250: 6f 6e 66 69 67 29 29 0a 28 64 65 63 6c 61 72 65  onfig)).(declare
0260: 20 28 75 73 65 73 20 74 65 73 74 73 29 29 0a 0a   (uses tests))..
0270: 28 69 6e 63 6c 75 64 65 20 22 63 6f 6d 6d 6f 6e  (include "common
0280: 5f 72 65 63 6f 72 64 73 2e 73 63 6d 22 29 0a 28  _records.scm").(
0290: 69 6e 63 6c 75 64 65 20 22 6b 65 79 5f 72 65 63  include "key_rec
02a0: 6f 72 64 73 2e 73 63 6d 22 29 0a 28 69 6e 63 6c  ords.scm").(incl
02b0: 75 64 65 20 22 64 62 5f 72 65 63 6f 72 64 73 2e  ude "db_records.
02c0: 73 63 6d 22 29 0a 28 69 6e 63 6c 75 64 65 20 22  scm").(include "
02d0: 72 75 6e 5f 72 65 63 6f 72 64 73 2e 73 63 6d 22  run_records.scm"
02e0: 29 0a 28 69 6e 63 6c 75 64 65 20 22 74 65 73 74  ).(include "test
02f0: 5f 72 65 63 6f 72 64 73 2e 73 63 6d 22 29 0a 0a  _records.scm")..
0300: 3b 3b 20 72 75 6e 73 3a 67 65 74 2d 72 75 6e 73  ;; runs:get-runs
0310: 2d 62 79 2d 70 61 74 74 0a 3b 3b 20 67 65 74 20  -by-patt.;; get 
0320: 72 75 6e 73 20 62 79 20 6c 69 73 74 20 6f 66 20  runs by list of 
0330: 63 72 69 74 65 72 69 61 0a 3b 3b 20 72 65 67 69  criteria.;; regi
0340: 73 74 65 72 20 61 20 74 65 73 74 20 72 75 6e 20  ster a test run 
0350: 77 69 74 68 20 74 68 65 20 64 62 0a 3b 3b 0a 3b  with the db.;;.;
0360: 3b 20 55 73 65 3a 20 28 64 62 2d 67 65 74 2d 76  ; Use: (db-get-v
0370: 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 28  alue-by-header (
0380: 64 62 3a 67 65 74 2d 68 65 61 64 65 72 20 72 75  db:get-header ru
0390: 6e 69 6e 66 6f 29 28 64 62 3a 67 65 74 2d 72 6f  ninfo)(db:get-ro
03a0: 77 20 72 75 6e 69 6e 66 6f 29 29 0a 3b 3b 20 20  w runinfo)).;;  
03b0: 74 6f 20 65 78 74 72 61 63 74 20 69 6e 66 6f 20  to extract info 
03c0: 66 72 6f 6d 20 74 68 65 20 73 74 72 75 63 74 75  from the structu
03d0: 72 65 20 72 65 74 75 72 6e 65 64 0a 3b 3b 0a 28  re returned.;;.(
03e0: 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 67 65 74  define (runs:get
03f0: 2d 72 75 6e 73 2d 62 79 2d 70 61 74 74 20 64 62  -runs-by-patt db
0400: 20 6b 65 79 73 20 72 75 6e 6e 61 6d 65 70 61 74   keys runnamepat
0410: 74 20 2e 20 70 61 72 61 6d 73 29 20 3b 3b 20 74  t . params) ;; t
0420: 65 73 74 2d 6e 61 6d 65 29 0a 20 20 28 6c 65 74  est-name).  (let
0430: 2a 20 28 28 6b 65 79 76 61 6c 6c 73 74 20 28 6b  * ((keyvallst (k
0440: 65 79 73 2d 3e 76 61 6c 6c 69 73 74 20 6b 65 79  eys->vallist key
0450: 73 29 29 0a 09 20 28 74 6d 70 20 20 20 20 20 20  s)).. (tmp      
0460: 28 72 75 6e 73 3a 67 65 74 2d 73 74 64 2d 72 75  (runs:get-std-ru
0470: 6e 2d 66 69 65 6c 64 73 20 6b 65 79 73 20 27 28  n-fields keys '(
0480: 22 69 64 22 20 22 72 75 6e 6e 61 6d 65 22 20 22  "id" "runname" "
0490: 73 74 61 74 65 22 20 22 73 74 61 74 75 73 22 20  state" "status" 
04a0: 22 6f 77 6e 65 72 22 20 22 65 76 65 6e 74 5f 74  "owner" "event_t
04b0: 69 6d 65 22 29 29 29 0a 09 20 28 6b 65 79 73 74  ime"))).. (keyst
04c0: 72 20 20 20 28 63 61 72 20 74 6d 70 29 29 0a 09  r   (car tmp))..
04d0: 20 28 68 65 61 64 65 72 20 20 20 28 63 61 64 72   (header   (cadr
04e0: 20 74 6d 70 29 29 0a 09 20 28 72 65 73 20 20 20   tmp)).. (res   
04f0: 20 20 27 28 29 29 0a 09 20 28 6b 65 79 2d 70 61    '()).. (key-pa
0500: 74 74 20 22 22 29 29 0a 20 20 20 20 28 66 6f 72  tt "")).    (for
0510: 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 20 28 6b  -each (lambda (k
0520: 65 79 76 61 6c 29 0a 09 09 28 6c 65 74 2a 20 28  eyval)...(let* (
0530: 28 6b 65 79 20 20 20 20 28 76 65 63 74 6f 72 2d  (key    (vector-
0540: 72 65 66 20 6b 65 79 76 61 6c 20 30 29 29 0a 09  ref keyval 0))..
0550: 09 20 20 20 20 20 20 20 28 66 75 6c 6b 65 79 20  .       (fulkey 
0560: 28 63 6f 6e 63 20 22 3a 22 20 6b 65 79 29 29 0a  (conc ":" key)).
0570: 09 09 20 20 20 20 20 20 20 28 70 61 74 74 20 20  ..       (patt  
0580: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 66   (args:get-arg f
0590: 75 6c 6b 65 79 29 29 29 0a 09 09 20 20 28 69 66  ulkey)))...  (if
05a0: 20 70 61 74 74 0a 09 09 20 20 20 20 20 20 28 73   patt...      (s
05b0: 65 74 21 20 6b 65 79 2d 70 61 74 74 20 28 63 6f  et! key-patt (co
05c0: 6e 63 20 6b 65 79 2d 70 61 74 74 20 22 20 41 4e  nc key-patt " AN
05d0: 44 20 22 20 6b 65 79 20 22 20 6c 69 6b 65 20 27  D " key " like '
05e0: 22 20 70 61 74 74 20 22 27 22 29 29 0a 09 09 20  " patt "'"))... 
05f0: 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09 09 28       (begin....(
0600: 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45  debug:print 0 "E
0610: 52 52 4f 52 3a 20 73 65 61 72 63 68 69 6e 67 20  RROR: searching 
0620: 66 6f 72 20 72 75 6e 73 20 77 69 74 68 20 6e 6f  for runs with no
0630: 20 70 61 74 74 65 72 6e 20 73 65 74 20 66 6f 72   pattern set for
0640: 20 22 20 66 75 6c 6b 65 79 29 0a 09 09 09 28 65   " fulkey)....(e
0650: 78 69 74 20 36 29 29 29 29 29 0a 09 20 20 20 20  xit 6)))))..    
0660: 20 20 6b 65 79 73 29 0a 20 20 20 20 28 73 71 6c    keys).    (sql
0670: 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f  ite3:for-each-ro
0680: 77 20 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20  w .     (lambda 
0690: 28 61 20 2e 20 72 29 0a 20 20 20 20 20 20 20 28  (a . r).       (
06a0: 73 65 74 21 20 72 65 73 20 28 63 6f 6e 73 20 28  set! res (cons (
06b0: 6c 69 73 74 2d 3e 76 65 63 74 6f 72 20 28 63 6f  list->vector (co
06c0: 6e 73 20 61 20 72 29 29 20 72 65 73 29 29 29 0a  ns a r)) res))).
06d0: 20 20 20 20 20 64 62 20 0a 20 20 20 20 20 28 63       db .     (c
06e0: 6f 6e 63 20 22 53 45 4c 45 43 54 20 22 20 6b 65  onc "SELECT " ke
06f0: 79 73 74 72 20 22 20 46 52 4f 4d 20 72 75 6e 73  ystr " FROM runs
0700: 20 57 48 45 52 45 20 72 75 6e 6e 61 6d 65 20 6c   WHERE runname l
0710: 69 6b 65 20 3f 20 22 20 6b 65 79 2d 70 61 74 74  ike ? " key-patt
0720: 20 22 3b 22 29 0a 20 20 20 20 20 72 75 6e 6e 61   ";").     runna
0730: 6d 65 70 61 74 74 29 0a 20 20 20 20 28 76 65 63  mepatt).    (vec
0740: 74 6f 72 20 68 65 61 64 65 72 20 72 65 73 29 29  tor header res))
0750: 29 0a 0a 3b 3b 20 3b 3b 20 54 4f 44 4f 3a 20 43  )..;; ;; TODO: C
0760: 6f 6e 76 65 72 67 65 20 74 68 69 73 20 77 69 74  onverge this wit
0770: 68 20 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e  h db:get-test-in
0780: 66 6f 0a 3b 3b 20 28 64 65 66 69 6e 65 20 28 72  fo.;; (define (r
0790: 75 6e 73 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66  uns:get-test-inf
07a0: 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  o db run-id test
07b0: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  -name item-path)
07c0: 0a 3b 3b 20 20 20 28 6c 65 74 20 28 28 72 65 73  .;;   (let ((res
07d0: 20 23 66 29 29 20 3b 3b 20 28 76 65 63 74 6f 72   #f)) ;; (vector
07e0: 20 23 66 20 23 66 20 23 66 20 23 66 20 23 66 20   #f #f #f #f #f 
07f0: 23 66 29 29 29 0a 3b 3b 20 20 20 20 20 28 73 71  #f))).;;     (sq
0800: 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72  lite3:for-each-r
0810: 6f 77 20 0a 3b 3b 20 20 20 20 20 20 28 6c 61 6d  ow .;;      (lam
0820: 62 64 61 20 28 69 64 20 72 75 6e 2d 69 64 20 74  bda (id run-id t
0830: 65 73 74 2d 6e 61 6d 65 20 73 74 61 74 65 20 73  est-name state s
0840: 74 61 74 75 73 29 0a 3b 3b 20 20 20 20 20 20 20  tatus).;;       
0850: 20 28 73 65 74 21 20 72 65 73 20 28 76 65 63 74   (set! res (vect
0860: 6f 72 20 69 64 20 72 75 6e 2d 69 64 20 74 65 73  or id run-id tes
0870: 74 2d 6e 61 6d 65 20 73 74 61 74 65 20 73 74 61  t-name state sta
0880: 74 75 73 20 69 74 65 6d 2d 70 61 74 68 29 29 29  tus item-path)))
0890: 0a 3b 3b 20 20 20 20 20 20 64 62 20 22 53 45 4c  .;;      db "SEL
08a0: 45 43 54 20 69 64 2c 72 75 6e 5f 69 64 2c 74 65  ECT id,run_id,te
08b0: 73 74 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 61  stname,state,sta
08c0: 74 75 73 20 46 52 4f 4d 20 74 65 73 74 73 20 57  tus FROM tests W
08d0: 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e  HERE run_id=? AN
08e0: 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44  D testname=? AND
08f0: 20 69 74 65 6d 5f 70 61 74 68 3d 3f 3b 22 0a 3b   item_path=?;".;
0900: 3b 20 20 20 20 20 20 72 75 6e 2d 69 64 20 74 65  ;      run-id te
0910: 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74  st-name item-pat
0920: 68 29 0a 3b 3b 20 20 20 20 20 72 65 73 29 29 0a  h).;;     res)).
0930: 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 74  .(define (runs:t
0940: 65 73 74 2d 67 65 74 2d 66 75 6c 6c 2d 70 61 74  est-get-full-pat
0950: 68 20 74 65 73 74 29 0a 20 20 28 6c 65 74 2a 20  h test).  (let* 
0960: 28 28 74 65 73 74 6e 61 6d 65 20 28 64 62 3a 74  ((testname (db:t
0970: 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65  est-get-testname
0980: 20 20 20 74 65 73 74 29 29 0a 09 20 28 69 74 65     test)).. (ite
0990: 6d 70 61 74 68 20 28 64 62 3a 74 65 73 74 2d 67  mpath (db:test-g
09a0: 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73  et-item-path tes
09b0: 74 29 29 29 0a 20 20 20 20 28 63 6f 6e 63 20 74  t))).    (conc t
09c0: 65 73 74 6e 61 6d 65 20 28 69 66 20 28 65 71 75  estname (if (equ
09d0: 61 6c 3f 20 69 74 65 6d 70 61 74 68 20 22 22 29  al? itempath "")
09e0: 20 22 22 20 28 63 6f 6e 63 20 22 28 22 20 69 74   "" (conc "(" it
09f0: 65 6d 70 61 74 68 20 22 29 22 29 29 29 29 29 0a  empath ")"))))).
0a00: 0a 0a 28 64 65 66 69 6e 65 20 28 73 65 74 2d 6d  ..(define (set-m
0a10: 65 67 61 74 65 73 74 2d 65 6e 76 2d 76 61 72 73  egatest-env-vars
0a20: 20 64 62 20 72 75 6e 2d 69 64 29 0a 20 20 28 6c   db run-id).  (l
0a30: 65 74 20 28 28 6b 65 79 73 20 28 64 62 2d 67 65  et ((keys (db-ge
0a40: 74 2d 6b 65 79 73 20 64 62 29 29 29 0a 20 20 20  t-keys db))).   
0a50: 20 28 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62   (for-each (lamb
0a60: 64 61 20 28 6b 65 79 29 0a 09 09 28 73 71 6c 69  da (key)...(sqli
0a70: 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77  te3:for-each-row
0a80: 0a 09 09 20 28 6c 61 6d 62 64 61 20 28 76 61 6c  ... (lambda (val
0a90: 29 0a 09 09 20 20 20 28 64 65 62 75 67 3a 70 72  )...   (debug:pr
0aa0: 69 6e 74 20 32 20 22 73 65 74 65 6e 76 20 22 20  int 2 "setenv " 
0ab0: 28 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64 6e 61  (key:get-fieldna
0ac0: 6d 65 20 6b 65 79 29 20 22 20 22 20 76 61 6c 29  me key) " " val)
0ad0: 0a 09 09 20 20 20 28 73 65 74 65 6e 76 20 28 6b  ...   (setenv (k
0ae0: 65 79 3a 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65  ey:get-fieldname
0af0: 20 6b 65 79 29 20 76 61 6c 29 29 0a 09 09 20 64   key) val))... d
0b00: 62 20 0a 09 09 20 28 63 6f 6e 63 20 22 53 45 4c  b ... (conc "SEL
0b10: 45 43 54 20 22 20 28 6b 65 79 3a 67 65 74 2d 66  ECT " (key:get-f
0b20: 69 65 6c 64 6e 61 6d 65 20 6b 65 79 29 20 22 20  ieldname key) " 
0b30: 46 52 4f 4d 20 72 75 6e 73 20 57 48 45 52 45 20  FROM runs WHERE 
0b40: 69 64 3d 3f 3b 22 29 0a 09 09 20 72 75 6e 2d 69  id=?;")... run-i
0b50: 64 29 29 0a 09 20 20 20 20 20 20 6b 65 79 73 29  d))..      keys)
0b60: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 73 65 74  ))..(define (set
0b70: 2d 69 74 65 6d 2d 65 6e 76 2d 76 61 72 73 20 69  -item-env-vars i
0b80: 74 65 6d 64 61 74 29 0a 20 20 28 66 6f 72 2d 65  temdat).  (for-e
0b90: 61 63 68 20 28 6c 61 6d 62 64 61 20 28 69 74 65  ach (lambda (ite
0ba0: 6d 29 0a 09 20 20 20 20 20 20 28 64 65 62 75 67  m)..      (debug
0bb0: 3a 70 72 69 6e 74 20 32 20 22 73 65 74 65 6e 76  :print 2 "setenv
0bc0: 20 22 20 28 63 61 72 20 69 74 65 6d 29 20 22 20   " (car item) " 
0bd0: 22 20 28 63 61 64 72 20 69 74 65 6d 29 29 0a 09  " (cadr item))..
0be0: 20 20 20 20 20 20 28 73 65 74 65 6e 76 20 28 63        (setenv (c
0bf0: 61 72 20 69 74 65 6d 29 20 28 63 61 64 72 20 69  ar item) (cadr i
0c00: 74 65 6d 29 29 29 0a 09 20 20 20 20 69 74 65 6d  tem)))..    item
0c10: 64 61 74 29 29 0a 0a 28 64 65 66 69 6e 65 20 28  dat))..(define (
0c20: 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72  runs:can-run-mor
0c30: 65 2d 74 65 73 74 73 20 64 62 20 74 65 73 74 2d  e-tests db test-
0c40: 72 65 63 6f 72 64 29 0a 20 20 28 6c 65 74 2a 20  record).  (let* 
0c50: 28 28 74 63 6f 6e 66 69 67 20 20 20 20 20 20 20  ((tconfig       
0c60: 20 20 20 20 20 20 20 20 20 20 28 74 65 73 74 73            (tests
0c70: 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d 74  :testqueue-get-t
0c80: 65 73 74 63 6f 6e 66 69 67 20 74 65 73 74 2d 72  estconfig test-r
0c90: 65 63 6f 72 64 29 29 0a 09 20 28 6a 6f 62 67 72  ecord)).. (jobgr
0ca0: 6f 75 70 20 20 20 20 20 20 20 20 20 20 20 20 20  oup             
0cb0: 20 20 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75     (config-looku
0cc0: 70 20 74 63 6f 6e 66 69 67 20 22 72 65 71 75 69  p tconfig "requi
0cd0: 72 65 6d 65 6e 74 73 22 20 22 6a 6f 62 67 72 6f  rements" "jobgro
0ce0: 75 70 22 29 29 0a 09 20 28 6e 75 6d 2d 72 75 6e  up")).. (num-run
0cf0: 6e 69 6e 67 20 20 20 20 20 20 20 20 20 20 20 20  ning            
0d00: 20 28 64 62 3a 67 65 74 2d 63 6f 75 6e 74 2d 74   (db:get-count-t
0d10: 65 73 74 73 2d 72 75 6e 6e 69 6e 67 20 64 62 29  ests-running db)
0d20: 29 0a 09 20 28 6e 75 6d 2d 72 75 6e 6e 69 6e 67  ).. (num-running
0d30: 2d 69 6e 2d 6a 6f 62 67 72 6f 75 70 20 28 64 62  -in-jobgroup (db
0d40: 3a 67 65 74 2d 63 6f 75 6e 74 2d 74 65 73 74 73  :get-count-tests
0d50: 2d 72 75 6e 6e 69 6e 67 2d 69 6e 2d 6a 6f 62 67  -running-in-jobg
0d60: 72 6f 75 70 20 64 62 20 6a 6f 62 67 72 6f 75 70  roup db jobgroup
0d70: 29 29 0a 09 20 28 6d 61 78 2d 63 6f 6e 63 75 72  )).. (max-concur
0d80: 72 65 6e 74 2d 6a 6f 62 73 20 20 20 20 20 28 63  rent-jobs     (c
0d90: 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f  onfig-lookup *co
0da0: 6e 66 69 67 64 61 74 2a 20 22 73 65 74 75 70 22  nfigdat* "setup"
0db0: 20 20 20 20 20 22 6d 61 78 5f 63 6f 6e 63 75 72       "max_concur
0dc0: 72 65 6e 74 5f 6a 6f 62 73 22 29 29 0a 09 20 28  rent_jobs")).. (
0dd0: 6a 6f 62 2d 67 72 6f 75 70 2d 6c 69 6d 69 74 20  job-group-limit 
0de0: 20 20 20 20 20 20 20 20 28 63 6f 6e 66 69 67 2d          (config-
0df0: 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67 64 61  lookup *configda
0e00: 74 2a 20 22 6a 6f 62 67 72 6f 75 70 73 22 20 6a  t* "jobgroups" j
0e10: 6f 62 67 72 6f 75 70 29 29 29 0a 20 20 20 20 28  obgroup))).    (
0e20: 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 6d  debug:print 2 "m
0e30: 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f  ax-concurrent-jo
0e40: 62 73 3a 20 22 20 6d 61 78 2d 63 6f 6e 63 75 72  bs: " max-concur
0e50: 72 65 6e 74 2d 6a 6f 62 73 20 22 2c 20 6e 75 6d  rent-jobs ", num
0e60: 2d 72 75 6e 6e 69 6e 67 3a 20 22 20 6e 75 6d 2d  -running: " num-
0e70: 72 75 6e 6e 69 6e 67 29 0a 20 20 20 20 28 69 66  running).    (if
0e80: 20 28 6e 6f 74 20 28 65 71 3f 20 30 20 2a 67 6c   (not (eq? 0 *gl
0e90: 6f 62 61 6c 65 78 69 74 73 74 61 74 75 73 2a 29  obalexitstatus*)
0ea0: 29 0a 09 23 66 0a 09 28 6c 65 74 20 28 28 63 61  )..#f..(let ((ca
0eb0: 6e 2d 6e 6f 74 2d 72 75 6e 2d 6d 6f 72 65 20 28  n-not-run-more (
0ec0: 63 6f 6e 64 0a 09 09 09 09 20 3b 3b 20 69 66 20  cond..... ;; if 
0ed0: 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a  max-concurrent-j
0ee0: 6f 62 73 20 69 73 20 73 65 74 20 61 6e 64 20 74  obs is set and t
0ef0: 68 65 20 6e 75 6d 62 65 72 20 72 75 6e 6e 69 6e  he number runnin
0f00: 67 20 69 73 20 67 72 65 61 74 65 72 20 0a 09 09  g is greater ...
0f10: 09 09 20 3b 3b 20 74 68 61 6e 20 69 74 20 74 68  .. ;; than it th
0f20: 61 6e 20 63 61 6e 6e 6f 74 20 72 75 6e 20 6d 6f  an cannot run mo
0f30: 72 65 20 6a 6f 62 73 0a 09 09 09 09 20 28 28 61  re jobs..... ((a
0f40: 6e 64 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e  nd max-concurren
0f50: 74 2d 6a 6f 62 73 0a 09 09 09 09 20 20 20 20 20  t-jobs.....     
0f60: 20 20 28 73 74 72 69 6e 67 2d 3e 6e 75 6d 62 65    (string->numbe
0f70: 72 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74  r max-concurrent
0f80: 2d 6a 6f 62 73 29 0a 09 09 09 09 20 20 20 20 20  -jobs).....     
0f90: 20 20 28 3e 3d 20 6e 75 6d 2d 72 75 6e 6e 69 6e    (>= num-runnin
0fa0: 67 20 28 73 74 72 69 6e 67 2d 3e 6e 75 6d 62 65  g (string->numbe
0fb0: 72 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74  r max-concurrent
0fc0: 2d 6a 6f 62 73 29 29 29 0a 09 09 09 09 20 20 28  -jobs))).....  (
0fd0: 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 57  debug:print 0 "W
0fe0: 41 52 4e 49 4e 47 3a 20 4d 61 78 20 72 75 6e 6e  ARNING: Max runn
0ff0: 69 6e 67 20 6a 6f 62 73 20 65 78 63 65 65 64 65  ing jobs exceede
1000: 64 2c 20 63 75 72 72 65 6e 74 20 6e 75 6d 62 65  d, current numbe
1010: 72 20 72 75 6e 6e 69 6e 67 3a 20 22 20 6e 75 6d  r running: " num
1020: 2d 72 75 6e 6e 69 6e 67 20 0a 09 09 09 09 09 20  -running ...... 
1030: 20 20 20 20 20 20 22 2c 20 6d 61 78 5f 63 6f 6e        ", max_con
1040: 63 75 72 72 65 6e 74 5f 6a 6f 62 73 3a 20 22 20  current_jobs: " 
1050: 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a  max-concurrent-j
1060: 6f 62 73 29 0a 09 09 09 09 20 20 23 74 29 0a 09  obs).....  #t)..
1070: 09 09 09 20 3b 3b 20 69 66 20 6a 6f 62 2d 67 72  ... ;; if job-gr
1080: 6f 75 70 2d 6c 69 6d 69 74 20 69 73 20 73 65 74  oup-limit is set
1090: 20 61 6e 64 20 6e 75 6d 62 65 72 20 6f 66 20 6a   and number of j
10a0: 6f 62 73 20 69 6e 20 74 68 65 20 67 72 6f 75 70  obs in the group
10b0: 20 69 73 20 67 72 65 61 74 65 72 0a 09 09 09 09   is greater.....
10c0: 20 3b 3b 20 74 68 61 6e 20 74 68 65 20 6c 69 6d   ;; than the lim
10d0: 69 74 20 74 68 65 6e 20 63 61 6e 6e 6f 74 20 72  it then cannot r
10e0: 75 6e 20 6d 6f 72 65 20 6a 6f 62 73 20 6f 66 20  un more jobs of 
10f0: 74 68 69 73 20 6b 69 6e 64 0a 09 09 09 09 20 28  this kind..... (
1100: 28 61 6e 64 20 6a 6f 62 2d 67 72 6f 75 70 2d 6c  (and job-group-l
1110: 69 6d 69 74 0a 09 09 09 09 20 20 20 20 20 20 20  imit.....       
1120: 28 3e 3d 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67 2d  (>= num-running-
1130: 69 6e 2d 6a 6f 62 67 72 6f 75 70 20 6a 6f 62 2d  in-jobgroup job-
1140: 67 72 6f 75 70 2d 6c 69 6d 69 74 29 29 0a 09 09  group-limit))...
1150: 09 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ..  (debug:print
1160: 20 31 20 22 57 41 52 4e 49 4e 47 3a 20 6e 75 6d   1 "WARNING: num
1170: 62 65 72 20 6f 66 20 6a 6f 62 73 20 22 20 6e 75  ber of jobs " nu
1180: 6d 2d 72 75 6e 6e 69 6e 67 2d 69 6e 2d 6a 6f 62  m-running-in-job
1190: 67 72 6f 75 70 20 0a 09 09 09 09 09 20 20 20 20  group ......    
11a0: 20 20 20 22 20 69 6e 20 22 20 6a 6f 62 67 72 6f     " in " jobgro
11b0: 75 70 20 22 20 65 78 63 65 65 64 65 64 2c 20 77  up " exceeded, w
11c0: 69 6c 6c 20 6e 6f 74 20 72 75 6e 20 22 20 28 74  ill not run " (t
11d0: 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67  ests:testqueue-g
11e0: 65 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74  et-testname test
11f0: 2d 72 65 63 6f 72 64 29 29 0a 09 09 09 09 20 20  -record)).....  
1200: 23 74 29 0a 09 09 09 09 20 28 65 6c 73 65 20 23  #t)..... (else #
1210: 66 29 29 29 29 0a 09 20 20 28 6e 6f 74 20 63 61  f))))..  (not ca
1220: 6e 2d 6e 6f 74 2d 72 75 6e 2d 6d 6f 72 65 29 29  n-not-run-more))
1230: 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d  )))..;;=========
1240: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1250: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1260: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1270: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b  =============.;;
1280: 20 4e 65 77 20 6d 65 74 68 6f 64 6f 6c 6f 67 79   New methodology
1290: 2e 20 54 68 65 73 65 20 72 6f 75 74 69 6e 65 73  . These routines
12a0: 20 77 69 6c 6c 20 72 65 70 6c 61 63 65 20 74 68   will replace th
12b0: 65 20 61 62 6f 76 65 20 69 6e 20 74 69 6d 65 2e  e above in time.
12c0: 20 46 6f 72 0a 3b 3b 20 6e 6f 77 20 74 68 65 20   For.;; now the 
12d0: 63 6f 64 65 20 69 73 20 64 75 70 6c 69 63 61 74  code is duplicat
12e0: 65 64 2e 20 54 68 69 73 20 73 74 75 66 66 20 69  ed. This stuff i
12f0: 73 20 69 6e 69 74 69 61 6c 6c 79 20 75 73 65 64  s initially used
1300: 20 69 6e 20 74 68 65 20 6d 6f 6e 69 74 6f 72 0a   in the monitor.
1310: 3b 3b 20 62 61 73 65 64 20 63 6f 64 65 2e 0a 3b  ;; based code..;
1320: 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ;===============
1330: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1340: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1350: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1360: 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 72 65 67 69  =======..;; regi
1370: 73 74 65 72 20 61 20 74 65 73 74 20 72 75 6e 20  ster a test run 
1380: 77 69 74 68 20 74 68 65 20 64 62 0a 28 64 65 66  with the db.(def
1390: 69 6e 65 20 28 72 75 6e 73 3a 72 65 67 69 73 74  ine (runs:regist
13a0: 65 72 2d 72 75 6e 20 64 62 20 6b 65 79 73 20 6b  er-run db keys k
13b0: 65 79 76 61 6c 6c 73 74 20 72 75 6e 6e 61 6d 65  eyvallst runname
13c0: 20 73 74 61 74 65 20 73 74 61 74 75 73 20 75 73   state status us
13d0: 65 72 29 0a 20 20 28 64 65 62 75 67 3a 70 72 69  er).  (debug:pri
13e0: 6e 74 20 33 20 22 72 75 6e 73 3a 72 65 67 69 73  nt 3 "runs:regis
13f0: 74 65 72 2d 72 75 6e 2c 20 6b 65 79 73 3a 20 22  ter-run, keys: "
1400: 20 6b 65 79 73 20 22 20 6b 65 79 76 61 6c 6c 73   keys " keyvalls
1410: 74 3a 20 22 20 6b 65 79 76 61 6c 6c 73 74 20 22  t: " keyvallst "
1420: 20 72 75 6e 6e 61 6d 65 3a 20 22 20 72 75 6e 6e   runname: " runn
1430: 61 6d 65 20 22 20 73 74 61 74 65 3a 20 22 20 73  ame " state: " s
1440: 74 61 74 65 20 22 20 73 74 61 74 75 73 3a 20 22  tate " status: "
1450: 20 73 74 61 74 75 73 20 22 20 75 73 65 72 3a 20   status " user: 
1460: 22 20 75 73 65 72 29 0a 20 20 28 6c 65 74 2a 20  " user).  (let* 
1470: 28 28 6b 65 79 73 74 72 20 20 20 20 28 6b 65 79  ((keystr    (key
1480: 73 2d 3e 6b 65 79 73 74 72 20 6b 65 79 73 29 29  s->keystr keys))
1490: 0a 09 20 28 63 6f 6d 6d 61 20 20 20 20 20 28 69  .. (comma     (i
14a0: 66 20 28 3e 20 28 6c 65 6e 67 74 68 20 6b 65 79  f (> (length key
14b0: 73 29 20 30 29 20 22 2c 22 20 22 22 29 29 0a 09  s) 0) "," ""))..
14c0: 20 28 61 6e 64 73 74 72 20 20 20 20 28 69 66 20   (andstr    (if 
14d0: 28 3e 20 28 6c 65 6e 67 74 68 20 6b 65 79 73 29  (> (length keys)
14e0: 20 30 29 20 22 20 41 4e 44 20 22 20 22 22 29 29   0) " AND " ""))
14f0: 0a 09 20 28 76 61 6c 73 6c 6f 74 73 20 20 28 6b  .. (valslots  (k
1500: 65 79 73 2d 3e 76 61 6c 73 6c 6f 74 73 20 6b 65  eys->valslots ke
1510: 79 73 29 29 20 3b 3b 20 3f 2c 3f 2c 3f 20 2e 2e  ys)) ;; ?,?,? ..
1520: 2e 0a 09 20 28 6b 65 79 76 61 6c 73 20 20 20 28  ... (keyvals   (
1530: 6d 61 70 20 63 61 64 72 20 6b 65 79 76 61 6c 6c  map cadr keyvall
1540: 73 74 29 29 0a 09 20 28 61 6c 6c 76 61 6c 73 20  st)).. (allvals 
1550: 20 20 28 61 70 70 65 6e 64 20 28 6c 69 73 74 20    (append (list 
1560: 72 75 6e 6e 61 6d 65 20 73 74 61 74 65 20 73 74  runname state st
1570: 61 74 75 73 20 75 73 65 72 29 20 6b 65 79 76 61  atus user) keyva
1580: 6c 73 29 29 0a 09 20 28 71 72 79 76 61 6c 73 20  ls)).. (qryvals 
1590: 20 20 28 61 70 70 65 6e 64 20 28 6c 69 73 74 20    (append (list 
15a0: 72 75 6e 6e 61 6d 65 29 20 6b 65 79 76 61 6c 73  runname) keyvals
15b0: 29 29 0a 09 20 28 6b 65 79 3d 3f 73 74 72 20 20  )).. (key=?str  
15c0: 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65  (string-interspe
15d0: 72 73 65 20 28 6d 61 70 20 28 6c 61 6d 62 64 61  rse (map (lambda
15e0: 20 28 6b 29 28 63 6f 6e 63 20 28 6b 65 79 3a 67   (k)(conc (key:g
15f0: 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 29 20  et-fieldname k) 
1600: 22 3d 3f 22 29 29 20 6b 65 79 73 29 20 22 20 41  "=?")) keys) " A
1610: 4e 44 20 22 29 29 29 0a 20 20 20 20 28 64 65 62  ND "))).    (deb
1620: 75 67 3a 70 72 69 6e 74 20 33 20 22 6b 65 79 73  ug:print 3 "keys
1630: 3a 20 22 20 6b 65 79 73 20 22 20 61 6c 6c 76 61  : " keys " allva
1640: 6c 73 3a 20 22 20 61 6c 6c 76 61 6c 73 20 22 20  ls: " allvals " 
1650: 6b 65 79 76 61 6c 73 3a 20 22 20 6b 65 79 76 61  keyvals: " keyva
1660: 6c 73 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70  ls).    (debug:p
1670: 72 69 6e 74 20 32 20 22 4e 4f 54 45 3a 20 75 73  rint 2 "NOTE: us
1680: 69 6e 67 20 74 61 72 67 65 74 20 22 20 28 73 74  ing target " (st
1690: 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65  ring-intersperse
16a0: 20 6b 65 79 76 61 6c 73 20 22 2f 22 29 20 22 20   keyvals "/") " 
16b0: 66 6f 72 20 74 68 69 73 20 72 75 6e 22 29 0a 20  for this run"). 
16c0: 20 20 20 28 69 66 20 28 61 6e 64 20 72 75 6e 6e     (if (and runn
16d0: 61 6d 65 20 28 6e 75 6c 6c 3f 20 28 66 69 6c 74  ame (null? (filt
16e0: 65 72 20 28 6c 61 6d 62 64 61 20 28 78 29 28 6e  er (lambda (x)(n
16f0: 6f 74 20 78 29 29 20 6b 65 79 76 61 6c 73 29 29  ot x)) keyvals))
1700: 29 20 3b 3b 20 74 68 65 72 65 20 6d 75 73 74 20  ) ;; there must 
1710: 62 65 20 61 20 62 65 74 74 65 72 20 77 61 79 20  be a better way 
1720: 74 6f 20 22 61 70 70 6c 79 20 61 6e 64 22 0a 09  to "apply and"..
1730: 28 6c 65 74 20 28 28 72 65 73 20 23 66 29 29 0a  (let ((res #f)).
1740: 09 20 20 28 61 70 70 6c 79 20 73 71 6c 69 74 65  .  (apply sqlite
1750: 33 3a 65 78 65 63 75 74 65 20 64 62 20 28 63 6f  3:execute db (co
1760: 6e 63 20 22 49 4e 53 45 52 54 20 4f 52 20 49 47  nc "INSERT OR IG
1770: 4e 4f 52 45 20 49 4e 54 4f 20 72 75 6e 73 20 28  NORE INTO runs (
1780: 72 75 6e 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74  runname,state,st
1790: 61 74 75 73 2c 6f 77 6e 65 72 2c 65 76 65 6e 74  atus,owner,event
17a0: 5f 74 69 6d 65 22 20 63 6f 6d 6d 61 20 6b 65 79  _time" comma key
17b0: 73 74 72 20 22 29 20 56 41 4c 55 45 53 20 28 3f  str ") VALUES (?
17c0: 2c 3f 2c 3f 2c 3f 2c 73 74 72 66 74 69 6d 65 28  ,?,?,?,strftime(
17d0: 27 25 73 27 2c 27 6e 6f 77 27 29 22 20 63 6f 6d  '%s','now')" com
17e0: 6d 61 20 76 61 6c 73 6c 6f 74 73 20 22 29 3b 22  ma valslots ");"
17f0: 29 0a 09 09 20 61 6c 6c 76 61 6c 73 29 0a 09 20  )... allvals).. 
1800: 20 28 61 70 70 6c 79 20 73 71 6c 69 74 65 33 3a   (apply sqlite3:
1810: 66 6f 72 2d 65 61 63 68 2d 72 6f 77 20 0a 09 20  for-each-row .. 
1820: 20 20 28 6c 61 6d 62 64 61 20 28 69 64 29 0a 09    (lambda (id)..
1830: 20 20 20 20 20 28 73 65 74 21 20 72 65 73 20 69       (set! res i
1840: 64 29 29 0a 09 20 20 20 64 62 0a 09 20 20 20 28  d))..   db..   (
1850: 6c 65 74 20 28 28 71 72 79 20 28 63 6f 6e 63 20  let ((qry (conc 
1860: 22 53 45 4c 45 43 54 20 69 64 20 46 52 4f 4d 20  "SELECT id FROM 
1870: 72 75 6e 73 20 57 48 45 52 45 20 28 72 75 6e 6e  runs WHERE (runn
1880: 61 6d 65 3d 3f 20 22 20 61 6e 64 73 74 72 20 6b  ame=? " andstr k
1890: 65 79 3d 3f 73 74 72 20 22 29 3b 22 29 29 29 0a  ey=?str ");"))).
18a0: 09 20 20 20 20 20 3b 28 64 65 62 75 67 3a 70 72  .     ;(debug:pr
18b0: 69 6e 74 20 34 20 22 71 72 79 3a 20 22 20 71 72  int 4 "qry: " qr
18c0: 79 29 20 0a 09 20 20 20 20 20 71 72 79 29 0a 09  y) ..     qry)..
18d0: 20 20 20 71 72 79 76 61 6c 73 29 0a 09 20 20 28     qryvals)..  (
18e0: 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20  sqlite3:execute 
18f0: 64 62 20 22 55 50 44 41 54 45 20 72 75 6e 73 20  db "UPDATE runs 
1900: 53 45 54 20 73 74 61 74 65 3d 3f 2c 73 74 61 74  SET state=?,stat
1910: 75 73 3d 3f 20 57 48 45 52 45 20 69 64 3d 3f 3b  us=? WHERE id=?;
1920: 22 20 73 74 61 74 65 20 73 74 61 74 75 73 20 72  " state status r
1930: 65 73 29 0a 09 20 20 72 65 73 29 20 0a 09 28 62  es)..  res) ..(b
1940: 65 67 69 6e 0a 09 20 20 28 64 65 62 75 67 3a 70  egin..  (debug:p
1950: 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 43  rint 0 "ERROR: C
1960: 61 6c 6c 65 64 20 77 69 74 68 6f 75 74 20 61 6c  alled without al
1970: 6c 20 6e 65 63 65 73 73 61 72 79 20 6b 65 79 73  l necessary keys
1980: 22 29 0a 09 20 20 23 66 29 29 29 29 0a 0a 3b 3b  ")..  #f))))..;;
1990: 20 54 68 69 73 20 69 73 20 61 20 64 75 70 6c 69   This is a dupli
19a0: 63 61 74 65 20 6f 66 20 72 75 6e 2d 74 65 73 74  cate of run-test
19b0: 73 20 28 77 68 69 63 68 20 68 61 73 20 62 65 65  s (which has bee
19c0: 6e 20 64 65 70 72 65 63 61 74 65 64 29 2e 20 55  n deprecated). U
19d0: 73 65 20 74 68 69 73 20 6f 6e 65 20 69 6e 73 74  se this one inst
19e0: 65 61 64 20 6f 66 20 72 75 6e 20 74 65 73 74 73  ead of run tests
19f0: 2e 0a 3b 3b 20 6b 65 79 76 61 6c 73 0a 28 64 65  ..;; keyvals.(de
1a00: 66 69 6e 65 20 28 72 75 6e 73 3a 72 75 6e 2d 74  fine (runs:run-t
1a10: 65 73 74 73 20 64 62 20 74 61 72 67 65 74 20 72  ests db target r
1a20: 75 6e 6e 61 6d 65 20 74 65 73 74 2d 70 61 74 74  unname test-patt
1a30: 73 20 69 74 65 6d 2d 70 61 74 74 73 20 75 73 65  s item-patts use
1a40: 72 20 66 6c 61 67 73 29 0a 20 20 28 6c 65 74 2a  r flags).  (let*
1a50: 20 28 28 6b 65 79 73 20 20 20 20 20 20 20 20 28   ((keys        (
1a60: 64 62 2d 67 65 74 2d 6b 65 79 73 20 64 62 29 29  db-get-keys db))
1a70: 0a 09 20 28 6b 65 79 76 61 6c 6c 73 74 20 20 20  .. (keyvallst   
1a80: 28 6b 65 79 73 3a 74 61 72 67 65 74 2d 3e 6b 65  (keys:target->ke
1a90: 79 76 61 6c 20 6b 65 79 73 20 74 61 72 67 65 74  yval keys target
1aa0: 29 29 0a 09 20 28 72 75 6e 2d 69 64 20 20 20 20  )).. (run-id    
1ab0: 20 20 28 72 75 6e 73 3a 72 65 67 69 73 74 65 72    (runs:register
1ac0: 2d 72 75 6e 20 64 62 20 6b 65 79 73 20 6b 65 79  -run db keys key
1ad0: 76 61 6c 6c 73 74 20 72 75 6e 6e 61 6d 65 20 22  vallst runname "
1ae0: 6e 65 77 22 20 22 6e 2f 61 22 20 75 73 65 72 29  new" "n/a" user)
1af0: 29 20 20 3b 3b 20 20 74 65 73 74 2d 6e 61 6d 65  )  ;;  test-name
1b00: 29 29 29 0a 09 20 28 64 65 66 65 72 72 65 64 20  ))).. (deferred 
1b10: 20 20 20 27 28 29 29 20 3b 3b 20 64 65 6c 61 79     '()) ;; delay
1b20: 20 72 75 6e 6e 69 6e 67 20 74 68 65 73 65 20 73   running these s
1b30: 69 6e 63 65 20 74 68 65 79 20 68 61 76 65 20 61  ince they have a
1b40: 20 77 61 69 74 6f 6e 20 63 6c 61 75 73 65 0a 09   waiton clause..
1b50: 20 3b 3b 20 6b 65 65 70 67 6f 69 6e 67 20 69 73   ;; keepgoing is
1b60: 20 74 68 65 20 64 65 66 61 63 74 6f 20 6d 6f 64   the defacto mod
1b70: 61 6c 69 74 79 20 6e 6f 77 2c 20 77 69 6c 6c 20  ality now, will 
1b80: 61 64 64 20 68 69 74 2d 6e 2d 72 75 6e 20 61 20  add hit-n-run a 
1b90: 62 69 74 20 6c 61 74 65 72 0a 09 20 3b 3b 20 28  bit later.. ;; (
1ba0: 6b 65 65 70 67 6f 69 6e 67 20 20 20 28 68 61 73  keepgoing   (has
1bb0: 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61  h-table-ref/defa
1bc0: 75 6c 74 20 66 6c 61 67 73 20 22 2d 6b 65 65 70  ult flags "-keep
1bd0: 67 6f 69 6e 67 22 20 23 66 29 29 0a 09 20 28 74  going" #f)).. (t
1be0: 65 73 74 2d 6e 61 6d 65 73 20 20 27 28 29 29 0a  est-names  '()).
1bf0: 09 20 28 72 75 6e 63 6f 6e 66 69 67 66 20 20 20  . (runconfigf   
1c00: 28 63 6f 6e 63 20 20 2a 74 6f 70 70 61 74 68 2a  (conc  *toppath*
1c10: 20 22 2f 72 75 6e 63 6f 6e 66 69 67 73 2e 63 6f   "/runconfigs.co
1c20: 6e 66 69 67 22 29 29 0a 09 20 28 72 65 71 75 69  nfig")).. (requi
1c30: 72 65 64 2d 74 65 73 74 73 20 27 28 29 29 0a 09  red-tests '())..
1c40: 20 28 74 65 73 74 2d 72 65 63 6f 72 64 73 20 28   (test-records (
1c50: 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 29  make-hash-table)
1c60: 29 29 0a 0a 20 20 20 20 28 73 65 74 2d 6d 65 67  ))..    (set-meg
1c70: 61 74 65 73 74 2d 65 6e 76 2d 76 61 72 73 20 64  atest-env-vars d
1c80: 62 20 72 75 6e 2d 69 64 29 20 3b 3b 20 74 68 65  b run-id) ;; the
1c90: 73 65 20 6d 61 79 20 62 65 20 6e 65 65 64 65 64  se may be needed
1ca0: 20 62 79 20 74 68 65 20 6c 61 75 6e 63 68 69 6e   by the launchin
1cb0: 67 20 70 72 6f 63 65 73 73 0a 0a 20 20 20 20 28  g process..    (
1cc0: 69 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f  if (file-exists?
1cd0: 20 72 75 6e 63 6f 6e 66 69 67 66 29 0a 09 28 73   runconfigf)..(s
1ce0: 65 74 75 70 2d 65 6e 76 2d 64 65 66 61 75 6c 74  etup-env-default
1cf0: 73 20 64 62 20 72 75 6e 63 6f 6e 66 69 67 66 20  s db runconfigf 
1d00: 72 75 6e 2d 69 64 20 2a 61 6c 72 65 61 64 79 2d  run-id *already-
1d10: 73 65 65 6e 2d 72 75 6e 63 6f 6e 66 69 67 2d 69  seen-runconfig-i
1d20: 6e 66 6f 2a 20 22 70 72 65 2d 6c 61 75 6e 63 68  nfo* "pre-launch
1d30: 2d 65 6e 76 2d 76 61 72 73 22 29 0a 09 28 64 65  -env-vars")..(de
1d40: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52  bug:print 0 "WAR
1d50: 4e 49 4e 47 3a 20 59 6f 75 20 64 6f 20 6e 6f 74  NING: You do not
1d60: 20 68 61 76 65 20 61 20 72 75 6e 20 63 6f 6e 66   have a run conf
1d70: 69 67 20 66 69 6c 65 3a 20 22 20 72 75 6e 63 6f  ig file: " runco
1d80: 6e 66 69 67 66 29 29 0a 20 20 20 20 0a 20 20 20  nfigf)).    .   
1d90: 20 3b 3b 20 6c 6f 6f 6b 20 75 70 20 61 6c 6c 20   ;; look up all 
1da0: 74 65 73 74 73 20 6d 61 74 63 68 69 6e 67 20 74  tests matching t
1db0: 68 65 20 63 6f 6d 6d 61 20 73 65 70 61 72 61 74  he comma separat
1dc0: 65 64 20 6c 69 73 74 20 6f 66 20 67 6c 6f 62 73  ed list of globs
1dd0: 20 69 6e 0a 20 20 20 20 3b 3b 20 74 65 73 74 2d   in.    ;; test-
1de0: 70 61 74 74 73 20 28 75 73 69 6e 67 20 25 20 61  patts (using % a
1df0: 73 20 77 69 6c 64 63 61 72 64 29 0a 20 20 20 20  s wildcard).    
1e00: 28 66 6f 72 2d 65 61 63 68 20 0a 20 20 20 20 20  (for-each .     
1e10: 28 6c 61 6d 62 64 61 20 28 70 61 74 74 29 0a 20  (lambda (patt). 
1e20: 20 20 20 20 20 20 28 6c 65 74 20 28 28 74 65 73        (let ((tes
1e30: 74 73 20 28 67 6c 6f 62 20 28 63 6f 6e 63 20 2a  ts (glob (conc *
1e40: 74 6f 70 70 61 74 68 2a 20 22 2f 74 65 73 74 73  toppath* "/tests
1e50: 2f 22 20 28 73 74 72 69 6e 67 2d 74 72 61 6e 73  /" (string-trans
1e60: 6c 61 74 65 20 70 61 74 74 20 22 25 22 20 22 2a  late patt "%" "*
1e70: 22 29 29 29 29 29 0a 09 20 28 73 65 74 21 20 74  "))))).. (set! t
1e80: 65 73 74 73 20 28 66 69 6c 74 65 72 20 28 6c 61  ests (filter (la
1e90: 6d 62 64 61 20 28 74 65 73 74 29 28 66 69 6c 65  mbda (test)(file
1ea0: 2d 65 78 69 73 74 73 3f 20 28 63 6f 6e 63 20 74  -exists? (conc t
1eb0: 65 73 74 20 22 2f 74 65 73 74 63 6f 6e 66 69 67  est "/testconfig
1ec0: 22 29 29 29 20 74 65 73 74 73 29 29 0a 09 20 28  "))) tests)).. (
1ed0: 73 65 74 21 20 74 65 73 74 2d 6e 61 6d 65 73 20  set! test-names 
1ee0: 28 61 70 70 65 6e 64 20 74 65 73 74 2d 6e 61 6d  (append test-nam
1ef0: 65 73 20 0a 09 09 09 09 20 20 28 6d 61 70 20 28  es .....  (map (
1f00: 6c 61 6d 62 64 61 20 28 74 65 73 74 70 29 0a 09  lambda (testp)..
1f10: 09 09 09 09 20 28 6c 61 73 74 20 28 73 74 72 69  .... (last (stri
1f20: 6e 67 2d 73 70 6c 69 74 20 74 65 73 74 70 20 22  ng-split testp "
1f30: 2f 22 29 29 29 0a 09 09 09 09 20 20 20 20 20 20  /"))).....      
1f40: 20 74 65 73 74 73 29 29 29 29 29 0a 20 20 20 20   tests))))).    
1f50: 20 28 69 66 20 74 65 73 74 2d 70 61 74 74 73 20   (if test-patts 
1f60: 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 74 65  (string-split te
1f70: 73 74 2d 70 61 74 74 73 20 22 2c 22 29 28 6c 69  st-patts ",")(li
1f80: 73 74 20 22 25 22 29 29 29 0a 0a 20 20 20 20 20  st "%")))..     
1f90: 3b 3b 20 6e 6f 77 20 72 65 6d 6f 76 65 20 64 75  ;; now remove du
1fa0: 70 6c 69 63 61 74 65 73 0a 20 20 20 20 28 73 65  plicates.    (se
1fb0: 74 21 20 74 65 73 74 2d 6e 61 6d 65 73 20 28 64  t! test-names (d
1fc0: 65 6c 65 74 65 2d 64 75 70 6c 69 63 61 74 65 73  elete-duplicates
1fd0: 20 74 65 73 74 2d 6e 61 6d 65 73 29 29 0a 0a 20   test-names)).. 
1fe0: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
1ff0: 30 20 22 49 4e 46 4f 3a 20 74 65 73 74 20 6e 61  0 "INFO: test na
2000: 6d 65 73 20 22 20 74 65 73 74 2d 6e 61 6d 65 73  mes " test-names
2010: 29 0a 0a 20 20 20 20 3b 3b 20 6f 6e 20 74 68 65  )..    ;; on the
2020: 20 66 69 72 73 74 20 70 61 73 73 20 6f 72 20 63   first pass or c
2030: 61 6c 6c 20 74 6f 20 72 75 6e 2d 74 65 73 74 73  all to run-tests
2040: 20 73 65 74 20 46 41 49 4c 53 20 74 6f 20 4e 4f   set FAILS to NO
2050: 54 5f 53 54 41 52 54 45 44 20 69 66 0a 20 20 20  T_STARTED if.   
2060: 20 3b 3b 20 2d 6b 65 65 70 67 6f 69 6e 67 20 69   ;; -keepgoing i
2070: 73 20 73 70 65 63 69 66 69 65 64 0a 20 20 20 20  s specified.    
2080: 28 69 66 20 28 65 71 3f 20 2a 70 61 73 73 6e 75  (if (eq? *passnu
2090: 6d 2a 20 30 29 0a 09 28 62 65 67 69 6e 0a 09 20  m* 0)..(begin.. 
20a0: 20 3b 3b 20 68 61 76 65 20 74 6f 20 64 65 6c 65   ;; have to dele
20b0: 74 65 20 74 65 73 74 20 72 65 63 6f 72 64 73 20  te test records 
20c0: 77 68 65 72 65 20 4e 4f 54 5f 53 54 41 52 54 45  where NOT_STARTE
20d0: 44 20 73 69 6e 63 65 20 74 68 65 79 20 63 61 6e  D since they can
20e0: 20 63 61 75 73 65 20 2d 6b 65 65 70 67 6f 69 6e   cause -keepgoin
20f0: 67 20 74 6f 20 0a 09 20 20 3b 3b 20 67 65 74 20  g to ..  ;; get 
2100: 73 74 75 63 6b 20 64 75 65 20 74 6f 20 62 65 63  stuck due to bec
2110: 6f 6d 69 6e 67 20 69 6e 61 63 63 65 73 73 69 62  oming inaccessib
2120: 6c 65 20 66 72 6f 6d 20 61 20 66 61 69 6c 65 64  le from a failed
2130: 20 74 65 73 74 2e 20 49 2e 65 2e 20 69 66 20 74   test. I.e. if t
2140: 65 73 74 20 42 20 64 65 70 65 6e 64 73 20 0a 09  est B depends ..
2150: 20 20 3b 3b 20 6f 6e 20 74 65 73 74 20 41 20 62    ;; on test A b
2160: 75 74 20 74 65 73 74 20 42 20 72 65 61 63 68 65  ut test B reache
2170: 64 20 74 68 65 20 70 6f 69 6e 74 20 6f 6e 20 62  d the point on b
2180: 65 69 6e 67 20 72 65 67 69 73 74 65 72 65 64 20  eing registered 
2190: 61 73 20 4e 4f 54 5f 53 54 41 52 54 45 44 20 61  as NOT_STARTED a
21a0: 6e 64 20 74 65 73 74 0a 09 20 20 3b 3b 20 41 20  nd test..  ;; A 
21b0: 66 61 69 6c 65 64 20 66 6f 72 20 73 6f 6d 65 20  failed for some 
21c0: 72 65 61 73 6f 6e 20 74 68 65 6e 20 6f 6e 20 72  reason then on r
21d0: 65 2d 72 75 6e 20 75 73 69 6e 67 20 2d 6b 65 65  e-run using -kee
21e0: 70 67 6f 69 6e 67 20 74 68 65 20 72 75 6e 20 63  pgoing the run c
21f0: 61 6e 20 6e 65 76 65 72 20 63 6f 6d 70 6c 65 74  an never complet
2200: 65 2e 0a 09 20 20 28 64 62 3a 64 65 6c 65 74 65  e...  (db:delete
2210: 2d 74 65 73 74 73 2d 69 6e 2d 73 74 61 74 65 20  -tests-in-state 
2220: 64 62 20 72 75 6e 2d 69 64 20 22 4e 4f 54 5f 53  db run-id "NOT_S
2230: 54 41 52 54 45 44 22 29 0a 09 20 20 28 64 62 3a  TARTED")..  (db:
2240: 73 65 74 2d 74 65 73 74 73 2d 73 74 61 74 65 2d  set-tests-state-
2250: 73 74 61 74 75 73 20 64 62 20 72 75 6e 2d 69 64  status db run-id
2260: 20 74 65 73 74 2d 6e 61 6d 65 73 20 23 66 20 22   test-names #f "
2270: 46 41 49 4c 22 20 22 4e 4f 54 5f 53 54 41 52 54  FAIL" "NOT_START
2280: 45 44 22 20 22 46 41 49 4c 22 29 29 29 0a 0a 20  ED" "FAIL"))).. 
2290: 20 20 20 3b 3b 20 6e 6f 77 20 61 64 64 20 6e 6f     ;; now add no
22a0: 6e 2d 64 69 72 65 63 74 6c 79 20 72 65 66 65 72  n-directly refer
22b0: 65 6e 63 65 64 20 64 65 70 65 6e 64 65 6e 63 69  enced dependenci
22c0: 65 73 20 28 69 2e 65 2e 20 77 61 69 74 6f 6e 29  es (i.e. waiton)
22d0: 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28 6e  .    (if (not (n
22e0: 75 6c 6c 3f 20 74 65 73 74 2d 6e 61 6d 65 73 29  ull? test-names)
22f0: 29 0a 09 28 6c 65 74 20 6c 6f 6f 70 20 28 28 68  )..(let loop ((h
2300: 65 64 20 28 63 61 72 20 74 65 73 74 2d 6e 61 6d  ed (car test-nam
2310: 65 73 29 29 0a 09 09 20 20 20 28 74 61 6c 20 28  es))...   (tal (
2320: 63 64 72 20 74 65 73 74 2d 6e 61 6d 65 73 29 29  cdr test-names))
2330: 29 20 20 20 20 20 20 20 20 20 3b 3b 20 27 72 65  )         ;; 're
2340: 74 75 72 6e 2d 70 72 6f 63 73 20 74 65 6c 6c 73  turn-procs tells
2350: 20 74 68 65 20 63 6f 6e 66 69 67 20 72 65 61 64   the config read
2360: 65 72 20 74 6f 20 70 72 65 70 20 72 75 6e 6e 69  er to prep runni
2370: 6e 67 20 73 79 73 74 65 6d 20 62 75 74 20 72 65  ng system but re
2380: 74 75 72 6e 20 61 20 70 72 6f 63 0a 09 20 20 28  turn a proc..  (
2390: 6c 65 74 2a 20 28 28 63 6f 6e 66 69 67 20 20 28  let* ((config  (
23a0: 74 65 73 74 3a 67 65 74 2d 74 65 73 74 63 6f 6e  test:get-testcon
23b0: 66 69 67 20 68 65 64 20 27 72 65 74 75 72 6e 2d  fig hed 'return-
23c0: 70 72 6f 63 73 29 29 0a 09 09 20 28 77 61 69 74  procs))... (wait
23d0: 6f 6e 73 20 28 73 74 72 69 6e 67 2d 73 70 6c 69  ons (string-spli
23e0: 74 20 28 6c 65 74 20 28 28 77 20 28 63 6f 6e 66  t (let ((w (conf
23f0: 69 67 2d 6c 6f 6f 6b 75 70 20 63 6f 6e 66 69 67  ig-lookup config
2400: 20 22 72 65 71 75 69 72 65 6d 65 6e 74 73 22 20   "requirements" 
2410: 22 77 61 69 74 6f 6e 22 29 29 29 0a 09 09 09 09  "waiton"))).....
2420: 09 20 20 28 69 66 20 77 20 77 20 22 22 29 29 29  .  (if w w "")))
2430: 29 29 0a 3b 3b 09 09 20 28 69 74 65 6d 73 20 20  )).;;.. (items  
2440: 20 28 69 74 65 6d 73 3a 67 65 74 2d 69 74 65 6d   (items:get-item
2450: 73 2d 66 72 6f 6d 2d 63 6f 6e 66 69 67 20 63 6f  s-from-config co
2460: 6e 66 69 67 29 29 29 0a 09 20 20 20 20 28 69 66  nfig)))..    (if
2470: 20 28 6e 6f 74 20 28 68 61 73 68 2d 74 61 62 6c   (not (hash-tabl
2480: 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 74 65  e-ref/default te
2490: 73 74 2d 72 65 63 6f 72 64 73 20 68 65 64 20 23  st-records hed #
24a0: 66 29 29 0a 09 09 28 68 61 73 68 2d 74 61 62 6c  f))...(hash-tabl
24b0: 65 2d 73 65 74 21 20 74 65 73 74 2d 72 65 63 6f  e-set! test-reco
24c0: 72 64 73 0a 09 09 09 09 20 68 65 64 20 28 76 65  rds..... hed (ve
24d0: 63 74 6f 72 20 68 65 64 20 20 20 20 20 3b 3b 20  ctor hed     ;; 
24e0: 30 0a 09 09 09 09 09 20 20 20 20 20 63 6f 6e 66  0......     conf
24f0: 69 67 20 20 3b 3b 20 31 0a 09 09 09 09 09 20 20  ig  ;; 1......  
2500: 20 20 20 77 61 69 74 6f 6e 73 20 3b 3b 20 32 0a     waitons ;; 2.
2510: 09 09 09 09 09 20 20 20 20 20 28 63 6f 6e 66 69  .....     (confi
2520: 67 2d 6c 6f 6f 6b 75 70 20 63 6f 6e 66 69 67 20  g-lookup config 
2530: 22 72 65 71 75 69 72 65 6d 65 6e 74 73 22 20 22  "requirements" "
2540: 70 72 69 6f 72 69 74 79 22 29 20 20 20 20 20 3b  priority")     ;
2550: 3b 20 70 72 69 6f 72 69 74 79 20 33 0a 09 09 09  ; priority 3....
2560: 09 09 20 20 20 20 20 28 6c 65 74 20 28 28 69 74  ..     (let ((it
2570: 65 6d 73 20 20 20 20 20 20 28 68 61 73 68 2d 74  ems      (hash-t
2580: 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74  able-ref/default
2590: 20 63 6f 6e 66 69 67 20 22 69 74 65 6d 73 22 20   config "items" 
25a0: 23 66 29 29 20 3b 3b 20 69 74 65 6d 73 20 34 0a  #f)) ;; items 4.
25b0: 09 09 09 09 09 09 20 20 20 28 69 74 65 6d 73 74  ......   (itemst
25c0: 61 62 6c 65 20 28 68 61 73 68 2d 74 61 62 6c 65  able (hash-table
25d0: 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 63 6f 6e  -ref/default con
25e0: 66 69 67 20 22 69 74 65 6d 73 74 61 62 6c 65 22  fig "itemstable"
25f0: 20 23 66 29 29 29 20 0a 09 09 09 09 09 20 20 20   #f))) ......   
2600: 20 20 20 20 3b 3b 20 69 66 20 65 69 74 68 65 72      ;; if either
2610: 20 69 74 65 6d 73 20 6f 72 20 69 74 65 6d 73 20   items or items 
2620: 74 61 62 6c 65 20 69 73 20 61 20 70 72 6f 63 20  table is a proc 
2630: 72 65 74 75 72 6e 20 69 74 20 73 6f 20 74 65 73  return it so tes
2640: 74 20 72 75 6e 6e 69 6e 67 0a 09 09 09 09 09 20  t running...... 
2650: 20 20 20 20 20 20 3b 3b 20 70 72 6f 63 65 73 73        ;; process
2660: 20 63 61 6e 20 6b 6e 6f 77 20 74 6f 20 63 61 6c   can know to cal
2670: 6c 20 69 74 65 6d 73 3a 67 65 74 2d 69 74 65 6d  l items:get-item
2680: 73 2d 66 72 6f 6d 2d 63 6f 6e 66 69 67 0a 09 09  s-from-config...
2690: 09 09 09 20 20 20 20 20 20 20 3b 3b 20 69 66 20  ...       ;; if 
26a0: 65 69 74 68 65 72 20 69 73 20 61 20 6c 69 73 74  either is a list
26b0: 20 61 6e 64 20 6e 6f 6e 65 20 69 73 20 61 20 70   and none is a p
26c0: 72 6f 63 20 67 6f 20 61 68 65 61 64 20 61 6e 64  roc go ahead and
26d0: 20 63 61 6c 6c 20 67 65 74 2d 69 74 65 6d 73 0a   call get-items.
26e0: 09 09 09 09 09 20 20 20 20 20 20 20 3b 3b 20 6f  .....       ;; o
26f0: 74 68 65 72 77 69 73 65 20 72 65 74 75 72 6e 20  therwise return 
2700: 23 66 20 2d 20 74 68 69 73 20 69 73 20 6e 6f 74  #f - this is not
2710: 20 61 6e 20 69 74 65 72 61 74 65 64 20 74 65 73   an iterated tes
2720: 74 0a 09 09 09 09 09 20 20 20 20 20 20 20 28 63  t......       (c
2730: 6f 6e 64 0a 09 09 09 09 09 09 28 28 70 72 6f 63  ond.......((proc
2740: 65 64 75 72 65 3f 20 69 74 65 6d 73 29 20 20 20  edure? items)   
2750: 20 20 20 69 74 65 6d 73 29 20 20 20 20 20 20 20     items)       
2760: 20 20 20 20 20 3b 3b 20 63 61 6c 63 20 6c 61 74       ;; calc lat
2770: 65 72 0a 09 09 09 09 09 09 28 28 70 72 6f 63 65  er.......((proce
2780: 64 75 72 65 3f 20 69 74 65 6d 73 74 61 62 6c 65  dure? itemstable
2790: 29 20 69 74 65 6d 73 74 61 62 6c 65 29 20 20 20  ) itemstable)   
27a0: 20 20 20 20 3b 3b 20 63 61 6c 63 20 6c 61 74 65      ;; calc late
27b0: 72 0a 09 09 09 09 09 09 28 28 6f 72 20 28 6c 69  r.......((or (li
27c0: 73 74 3f 20 69 74 65 6d 73 29 28 6c 69 73 74 3f  st? items)(list?
27d0: 20 69 74 65 6d 73 74 61 62 6c 65 29 29 20 3b 3b   itemstable)) ;;
27e0: 20 63 61 6c 63 20 6e 6f 77 0a 09 09 09 09 09 09   calc now.......
27f0: 20 28 69 74 65 6d 73 3a 67 65 74 2d 69 74 65 6d   (items:get-item
2800: 73 2d 66 72 6f 6d 2d 63 6f 6e 66 69 67 20 63 6f  s-from-config co
2810: 6e 66 69 67 29 29 0a 09 09 09 09 09 09 28 65 6c  nfig)).......(el
2820: 73 65 20 23 66 29 29 29 20 20 20 20 20 20 20 20  se #f)))        
2830: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2840: 20 20 20 3b 3b 20 6e 6f 74 20 69 74 65 72 61 74     ;; not iterat
2850: 65 64 0a 09 09 09 09 09 20 20 20 20 20 23 66 20  ed......     #f 
2860: 20 20 20 20 20 3b 3b 20 69 74 65 6d 73 64 61 74       ;; itemsdat
2870: 20 35 0a 09 09 09 09 09 20 20 20 20 20 3b 3b 20   5......     ;; 
2880: 23 66 20 20 20 20 20 20 3b 3b 20 73 70 61 72 65  #f      ;; spare
2890: 0a 09 09 09 09 09 20 20 20 20 20 29 29 29 0a 09  ......     )))..
28a0: 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 09      (for-each ..
28b0: 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 77 61       (lambda (wa
28c0: 69 74 6f 6e 29 0a 09 20 20 20 20 20 20 20 28 69  iton)..       (i
28d0: 66 20 28 61 6e 64 20 77 61 69 74 6f 6e 20 28 6e  f (and waiton (n
28e0: 6f 74 20 28 6d 65 6d 62 65 72 20 77 61 69 74 6f  ot (member waito
28f0: 6e 20 74 65 73 74 2d 6e 61 6d 65 73 29 29 29 0a  n test-names))).
2900: 09 09 20 20 20 28 62 65 67 69 6e 0a 09 09 20 20  ..   (begin...  
2910: 20 20 20 28 73 65 74 21 20 72 65 71 75 69 72 65     (set! require
2920: 64 2d 74 65 73 74 73 20 28 63 6f 6e 73 20 77 61  d-tests (cons wa
2930: 69 74 6f 6e 20 72 65 71 75 69 72 65 64 2d 74 65  iton required-te
2940: 73 74 73 29 29 0a 09 09 20 20 20 20 20 28 73 65  sts))...     (se
2950: 74 21 20 74 65 73 74 2d 6e 61 6d 65 73 20 28 61  t! test-names (a
2960: 70 70 65 6e 64 20 74 65 73 74 2d 6e 61 6d 65 73  ppend test-names
2970: 20 28 6c 69 73 74 20 77 61 69 74 6f 6e 29 29 29   (list waiton)))
2980: 29 29 29 0a 09 20 20 20 20 20 77 61 69 74 6f 6e  )))..     waiton
2990: 73 29 0a 09 20 20 20 20 28 6c 65 74 20 28 28 72  s)..    (let ((r
29a0: 65 6d 74 65 73 74 73 20 28 64 65 6c 65 74 65 2d  emtests (delete-
29b0: 64 75 70 6c 69 63 61 74 65 73 20 28 61 70 70 65  duplicates (appe
29c0: 6e 64 20 77 61 69 74 6f 6e 73 20 74 61 6c 29 29  nd waitons tal))
29d0: 29 29 0a 09 20 20 20 20 20 20 28 69 66 20 28 6e  ))..      (if (n
29e0: 6f 74 20 28 6e 75 6c 6c 3f 20 72 65 6d 74 65 73  ot (null? remtes
29f0: 74 73 29 29 0a 09 09 20 20 28 6c 6f 6f 70 20 28  ts))...  (loop (
2a00: 63 61 72 20 72 65 6d 74 65 73 74 73 29 28 63 64  car remtests)(cd
2a10: 72 20 72 65 6d 74 65 73 74 73 29 29 29 29 29 29  r remtests))))))
2a20: 29 0a 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20  )..    (if (not 
2a30: 28 6e 75 6c 6c 3f 20 72 65 71 75 69 72 65 64 2d  (null? required-
2a40: 74 65 73 74 73 29 29 0a 09 28 64 65 62 75 67 3a  tests))..(debug:
2a50: 70 72 69 6e 74 20 31 20 22 49 4e 46 4f 3a 20 41  print 1 "INFO: A
2a60: 64 64 69 6e 67 20 22 20 72 65 71 75 69 72 65 64  dding " required
2a70: 2d 74 65 73 74 73 20 22 20 74 6f 20 74 68 65 20  -tests " to the 
2a80: 72 75 6e 20 71 75 65 75 65 22 29 29 0a 20 20 20  run queue")).   
2a90: 20 3b 3b 20 4e 4f 54 45 3a 20 74 68 65 73 65 20   ;; NOTE: these 
2aa0: 61 72 65 20 61 6c 6c 20 70 61 72 65 6e 74 20 74  are all parent t
2ab0: 65 73 74 73 2c 20 69 74 65 6d 73 20 61 72 65 20  ests, items are 
2ac0: 6e 6f 74 20 65 78 70 61 6e 64 65 64 20 79 65 74  not expanded yet
2ad0: 2e 0a 20 20 20 20 28 72 75 6e 73 3a 72 75 6e 2d  ..    (runs:run-
2ae0: 74 65 73 74 73 2d 71 75 65 75 65 20 64 62 20 72  tests-queue db r
2af0: 75 6e 2d 69 64 20 72 75 6e 6e 61 6d 65 20 74 65  un-id runname te
2b00: 73 74 2d 72 65 63 6f 72 64 73 20 6b 65 79 76 61  st-records keyva
2b10: 6c 6c 73 74 20 66 6c 61 67 73 29 29 29 0a 0a 28  llst flags)))..(
2b20: 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 72 75 6e  define (runs:run
2b30: 2d 74 65 73 74 73 2d 71 75 65 75 65 20 64 62 20  -tests-queue db 
2b40: 72 75 6e 2d 69 64 20 72 75 6e 6e 61 6d 65 20 74  run-id runname t
2b50: 65 73 74 2d 72 65 63 6f 72 64 73 20 6b 65 79 76  est-records keyv
2b60: 61 6c 6c 73 74 20 66 6c 61 67 73 29 0a 20 20 20  allst flags).   
2b70: 20 3b 3b 20 41 74 20 74 68 69 73 20 70 6f 69 6e   ;; At this poin
2b80: 74 20 74 68 65 20 6c 69 73 74 20 6f 66 20 70 61  t the list of pa
2b90: 72 65 6e 74 20 74 65 73 74 73 20 69 73 20 65 78  rent tests is ex
2ba0: 70 61 6e 64 65 64 20 0a 20 20 20 20 3b 3b 20 4e  panded .    ;; N
2bb0: 42 2f 2f 20 53 68 6f 75 6c 64 20 65 78 70 61 6e  B// Should expan
2bc0: 64 20 69 74 65 6d 73 20 68 65 72 65 20 61 6e 64  d items here and
2bd0: 20 74 68 65 6e 20 69 6e 73 65 72 74 20 69 6e 74   then insert int
2be0: 6f 20 74 68 65 20 72 75 6e 20 71 75 65 75 65 2e  o the run queue.
2bf0: 0a 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20  .  (debug:print 
2c00: 35 20 22 74 65 73 74 2d 72 65 63 6f 72 64 73 3a  5 "test-records:
2c10: 20 22 20 74 65 73 74 2d 72 65 63 6f 72 64 73 20   " test-records 
2c20: 22 2c 20 6b 65 79 76 61 6c 6c 73 74 3a 20 22 20  ", keyvallst: " 
2c30: 6b 65 79 76 61 6c 6c 73 74 29 0a 20 20 28 6c 65  keyvallst).  (le
2c40: 74 20 28 28 73 6f 72 74 65 64 2d 74 65 73 74 2d  t ((sorted-test-
2c50: 6e 61 6d 65 73 20 28 74 65 73 74 73 3a 73 6f 72  names (tests:sor
2c60: 74 2d 62 79 2d 70 72 69 6f 72 69 74 79 2d 61 6e  t-by-priority-an
2c70: 64 2d 77 61 69 74 6f 6e 20 74 65 73 74 2d 72 65  d-waiton test-re
2c80: 63 6f 72 64 73 29 29 0a 09 28 69 74 65 6d 2d 70  cords))..(item-p
2c90: 61 74 74 73 20 20 20 20 20 20 20 20 28 68 61 73  atts        (has
2ca0: 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61  h-table-ref/defa
2cb0: 75 6c 74 20 66 6c 61 67 73 20 22 2d 69 74 65 6d  ult flags "-item
2cc0: 70 61 74 74 22 20 23 66 29 29 29 0a 20 20 20 20  patt" #f))).    
2cd0: 28 6c 65 74 20 6c 6f 6f 70 20 28 3b 20 28 6e 75  (let loop (; (nu
2ce0: 6d 74 69 6d 65 73 20 30 29 20 3b 3b 20 73 68 6f  mtimes 0) ;; sho
2cf0: 75 6c 64 6e 27 74 20 6e 65 65 64 20 74 68 69 73  uldn't need this
2d00: 0a 09 20 20 20 20 20 20 20 28 68 65 64 20 20 20  ..       (hed   
2d10: 20 20 20 20 20 20 28 63 61 72 20 73 6f 72 74 65        (car sorte
2d20: 64 2d 74 65 73 74 2d 6e 61 6d 65 73 29 29 0a 09  d-test-names))..
2d30: 20 20 20 20 20 20 20 28 74 61 6c 20 20 20 20 20         (tal     
2d40: 20 20 20 20 28 63 64 72 20 73 6f 72 74 65 64 2d      (cdr sorted-
2d50: 74 65 73 74 2d 6e 61 6d 65 73 29 29 29 0a 20 20  test-names))).  
2d60: 20 20 20 20 28 6c 65 74 2a 20 28 28 74 65 73 74      (let* ((test
2d70: 2d 72 65 63 6f 72 64 20 28 68 61 73 68 2d 74 61  -record (hash-ta
2d80: 62 6c 65 2d 72 65 66 20 74 65 73 74 2d 72 65 63  ble-ref test-rec
2d90: 6f 72 64 73 20 68 65 64 29 29 0a 09 20 20 20 20  ords hed))..    
2da0: 20 28 74 63 6f 6e 66 69 67 20 20 20 20 20 28 74   (tconfig     (t
2db0: 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67  ests:testqueue-g
2dc0: 65 74 2d 74 65 73 74 63 6f 6e 66 69 67 20 74 65  et-testconfig te
2dd0: 73 74 2d 72 65 63 6f 72 64 29 29 0a 09 20 20 20  st-record))..   
2de0: 20 20 28 77 61 69 74 6f 6e 73 20 20 20 20 20 28    (waitons     (
2df0: 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d  tests:testqueue-
2e00: 67 65 74 2d 77 61 69 74 6f 6e 73 20 20 20 20 74  get-waitons    t
2e10: 65 73 74 2d 72 65 63 6f 72 64 29 29 0a 09 20 20  est-record))..  
2e20: 20 20 20 28 70 72 69 6f 72 69 74 79 20 20 20 20     (priority    
2e30: 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65  (tests:testqueue
2e40: 2d 67 65 74 2d 70 72 69 6f 72 69 74 79 20 20 20  -get-priority   
2e50: 74 65 73 74 2d 72 65 63 6f 72 64 29 29 0a 09 20  test-record)).. 
2e60: 20 20 20 20 28 69 74 65 6d 64 61 74 20 20 20 20      (itemdat    
2e70: 20 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75   (tests:testqueu
2e80: 65 2d 67 65 74 2d 69 74 65 6d 64 61 74 20 20 20  e-get-itemdat   
2e90: 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29 0a 09   test-record))..
2ea0: 20 20 20 20 20 28 69 74 65 6d 73 20 20 20 20 20       (items     
2eb0: 20 20 28 74 65 73 74 73 3a 74 65 73 74 71 75 65    (tests:testque
2ec0: 75 65 2d 67 65 74 2d 69 74 65 6d 73 20 20 20 20  ue-get-items    
2ed0: 20 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29 0a    test-record)).
2ee0: 09 20 20 20 20 20 28 69 74 65 6d 2d 70 61 74 68  .     (item-path
2ef0: 20 20 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70     (item-list->p
2f00: 61 74 68 20 69 74 65 6d 64 61 74 29 29 29 0a 09  ath itemdat)))..
2f10: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
2f20: 57 48 45 52 45 20 54 4f 20 44 4f 3a 20 28 69 74  WHERE TO DO: (it
2f30: 65 6d 73 3a 67 65 74 2d 69 74 65 6d 73 2d 66 72  ems:get-items-fr
2f40: 6f 6d 2d 63 6f 6e 66 69 67 20 63 6f 6e 66 69 67  om-config config
2f50: 29 22 29 0a 09 28 64 65 62 75 67 3a 70 72 69 6e  )")..(debug:prin
2f60: 74 20 36 0a 09 09 20 20 20 20 20 22 69 74 65 6d  t 6...     "item
2f70: 64 61 74 3a 20 20 20 20 20 22 20 69 74 65 6d 64  dat:     " itemd
2f80: 61 74 0a 09 09 20 20 20 20 20 22 5c 6e 20 20 69  at...     "\n  i
2f90: 74 65 6d 73 3a 20 20 20 20 20 22 20 69 74 65 6d  tems:     " item
2fa0: 73 0a 09 09 20 20 20 20 20 22 5c 6e 20 20 69 74  s...     "\n  it
2fb0: 65 6d 2d 70 61 74 68 3a 20 22 20 69 74 65 6d 2d  em-path: " item-
2fc0: 70 61 74 68 29 0a 09 28 63 6f 6e 64 0a 09 20 28  path)..(cond.. (
2fd0: 28 6e 6f 74 20 69 74 65 6d 73 29 20 3b 3b 20 77  (not items) ;; w
2fe0: 68 65 6e 20 66 61 6c 73 65 20 74 68 65 20 74 65  hen false the te
2ff0: 73 74 20 69 73 20 6f 6b 20 74 6f 20 62 65 20 68  st is ok to be h
3000: 61 6e 64 65 64 20 6f 66 66 20 74 6f 20 6c 61 75  anded off to lau
3010: 6e 63 68 20 28 62 75 74 20 6e 6f 74 20 62 65 66  nch (but not bef
3020: 6f 72 65 29 0a 09 20 20 28 6c 65 74 20 28 28 68  ore)..  (let ((h
3030: 61 76 65 2d 72 65 73 6f 75 72 63 65 73 20 20 28  ave-resources  (
3040: 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72  runs:can-run-mor
3050: 65 2d 74 65 73 74 73 20 64 62 20 74 65 73 74 2d  e-tests db test-
3060: 72 65 63 6f 72 64 29 29 20 3b 3b 20 6c 6f 6f 6b  record)) ;; look
3070: 20 61 74 20 74 68 65 20 74 65 73 74 20 6a 6f 62   at the test job
3080: 67 72 6f 75 70 20 61 6e 64 20 74 6f 74 20 6a 6f  group and tot jo
3090: 62 73 20 72 75 6e 6e 69 6e 67 0a 09 09 28 70 72  bs running...(pr
30a0: 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 20 28 64  ereqs-not-met (d
30b0: 62 3a 67 65 74 2d 70 72 65 72 65 71 73 2d 6e 6f  b:get-prereqs-no
30c0: 74 2d 6d 65 74 20 64 62 20 72 75 6e 2d 69 64 20  t-met db run-id 
30d0: 77 61 69 74 6f 6e 73 20 69 74 65 6d 2d 70 61 74  waitons item-pat
30e0: 68 29 29 29 0a 09 20 20 20 20 28 69 66 20 28 61  h)))..    (if (a
30f0: 6e 64 20 68 61 76 65 2d 72 65 73 6f 75 72 63 65  nd have-resource
3100: 73 0a 09 09 20 20 20 20 20 28 6e 75 6c 6c 3f 20  s...     (null? 
3110: 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 29  prereqs-not-met)
3120: 29 0a 09 09 3b 3b 20 6e 6f 20 6c 6f 6f 70 20 2d  )...;; no loop -
3130: 20 64 72 6f 70 20 74 68 6f 75 67 68 20 61 6e 64   drop though and
3140: 20 75 73 65 20 74 68 65 20 6c 6f 6f 70 20 61 74   use the loop at
3150: 20 74 68 65 20 62 6f 74 74 6f 6d 20 0a 09 09 28   the bottom ...(
3160: 72 75 6e 3a 74 65 73 74 20 64 62 20 72 75 6e 2d  run:test db run-
3170: 69 64 20 72 75 6e 6e 61 6d 65 20 6b 65 79 76 61  id runname keyva
3180: 6c 6c 73 74 20 74 65 73 74 2d 72 65 63 6f 72 64  llst test-record
3190: 20 66 6c 61 67 73 20 23 66 29 0a 09 09 3b 3b 20   flags #f)...;; 
31a0: 65 6c 73 65 20 74 68 65 20 72 75 6e 20 69 73 20  else the run is 
31b0: 73 74 75 63 6b 2c 20 74 65 6d 70 6f 72 61 72 69  stuck, temporari
31c0: 6c 79 20 6f 72 20 70 65 72 6d 61 6e 65 6e 74 6c  ly or permanentl
31d0: 79 0a 09 09 28 6c 65 74 20 28 28 6e 65 77 74 61  y...(let ((newta
31e0: 6c 20 28 61 70 70 65 6e 64 20 74 61 6c 20 28 6c  l (append tal (l
31f0: 69 73 74 20 68 65 64 29 29 29 29 0a 09 09 20 20  ist hed))))...  
3200: 3b 3b 20 63 6f 75 6c 64 6e 27 74 20 72 75 6e 2c  ;; couldn't run,
3210: 20 74 61 6b 65 20 61 20 62 72 65 61 74 68 65 72   take a breather
3220: 0a 09 09 20 20 28 74 68 72 65 61 64 2d 73 6c 65  ...  (thread-sle
3230: 65 70 21 20 31 29 0a 09 09 20 20 28 6c 6f 6f 70  ep! 1)...  (loop
3240: 20 28 63 61 72 20 74 61 6c 29 28 63 64 72 20 74   (car tal)(cdr t
3250: 61 6c 29 29 29 29 29 29 0a 09 20 0a 09 20 3b 3b  al)))))).. .. ;;
3260: 20 63 61 73 65 20 77 68 65 72 65 20 61 6e 20 69   case where an i
3270: 74 65 6d 73 20 63 61 6d 65 20 69 6e 20 61 73 20  tems came in as 
3280: 61 20 6c 69 73 74 20 62 65 65 6e 20 70 72 6f 63  a list been proc
3290: 65 73 73 65 64 0a 09 20 28 28 61 6e 64 20 28 6c  essed.. ((and (l
32a0: 69 73 74 3f 20 69 74 65 6d 73 29 20 20 20 20 20  ist? items)     
32b0: 3b 3b 20 74 68 75 73 20 77 65 20 6b 6e 6f 77 20  ;; thus we know 
32c0: 6f 75 72 20 69 74 65 6d 73 20 61 72 65 20 61 6c  our items are al
32d0: 72 65 61 64 79 20 63 61 6c 63 75 6c 61 74 65 64  ready calculated
32e0: 0a 09 20 20 20 20 20 20 20 28 6e 6f 74 20 20 20  ..       (not   
32f0: 69 74 65 6d 64 61 74 29 29 20 3b 3b 20 61 6e 64  itemdat)) ;; and
3300: 20 6e 6f 74 20 79 65 74 20 65 78 70 61 6e 64 65   not yet expande
3310: 64 20 69 6e 74 6f 20 74 68 65 20 6c 69 73 74 20  d into the list 
3320: 6f 66 20 74 68 69 6e 67 73 20 74 6f 20 62 65 20  of things to be 
3330: 64 6f 6e 65 0a 09 20 20 28 69 66 20 28 3e 3d 20  done..  (if (>= 
3340: 2a 76 65 72 62 6f 73 69 74 79 2a 20 31 29 28 70  *verbosity* 1)(p
3350: 70 20 69 74 65 6d 73 29 29 0a 09 20 20 3b 3b 20  p items))..  ;; 
3360: 28 69 66 20 28 3e 3d 20 2a 76 65 72 62 6f 73 69  (if (>= *verbosi
3370: 74 79 2a 20 35 29 0a 09 20 20 3b 3b 20 20 20 20  ty* 5)..  ;;    
3380: 20 28 62 65 67 69 6e 0a 09 20 20 3b 3b 20 20 20   (begin..  ;;   
3390: 20 20 20 20 28 70 72 69 6e 74 20 22 69 74 65 6d      (print "item
33a0: 73 3a 20 22 29 20 20 20 20 20 28 70 70 20 28 69  s: ")     (pp (i
33b0: 74 65 6d 2d 61 73 73 6f 63 2d 3e 69 74 65 6d 2d  tem-assoc->item-
33c0: 6c 69 73 74 20 69 74 65 6d 73 29 29 0a 09 20 20  list items))..  
33d0: 3b 3b 20 20 20 20 20 20 20 28 70 72 69 6e 74 20  ;;       (print 
33e0: 22 69 74 65 6d 73 74 61 62 6c 65 3a 20 22 29 28  "itemstable: ")(
33f0: 70 70 20 28 69 74 65 6d 2d 74 61 62 6c 65 2d 3e  pp (item-table->
3400: 69 74 65 6d 2d 6c 69 73 74 20 69 74 65 6d 73 74  item-list itemst
3410: 61 62 6c 65 29 29 29 29 0a 09 20 20 28 66 6f 72  able))))..  (for
3420: 2d 65 61 63 68 0a 09 20 20 20 28 6c 61 6d 62 64  -each..   (lambd
3430: 61 20 28 6d 79 2d 69 74 65 6d 64 61 74 29 0a 09  a (my-itemdat)..
3440: 20 20 20 20 20 28 6c 65 74 2a 20 28 28 6e 65 77       (let* ((new
3450: 2d 74 65 73 74 2d 72 65 63 6f 72 64 20 28 6c 65  -test-record (le
3460: 74 20 28 28 6e 65 77 72 65 63 20 28 6d 61 6b 65  t ((newrec (make
3470: 2d 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65  -tests:testqueue
3480: 29 29 29 0a 09 09 09 09 20 20 20 20 20 20 20 28  ))).....       (
3490: 76 65 63 74 6f 72 2d 63 6f 70 79 21 20 74 65 73  vector-copy! tes
34a0: 74 2d 72 65 63 6f 72 64 20 6e 65 77 72 65 63 29  t-record newrec)
34b0: 0a 09 09 09 09 20 20 20 20 20 20 20 6e 65 77 72  .....       newr
34c0: 65 63 29 29 0a 09 09 20 20 20 20 28 6d 79 2d 69  ec))...    (my-i
34d0: 74 65 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c  tem-path (item-l
34e0: 69 73 74 2d 3e 70 61 74 68 20 6d 79 2d 69 74 65  ist->path my-ite
34f0: 6d 64 61 74 29 29 0a 09 09 20 20 20 20 28 69 74  mdat))...    (it
3500: 65 6d 2d 6d 61 74 63 68 65 73 20 28 69 66 20 69  em-matches (if i
3510: 74 65 6d 2d 70 61 74 74 73 20 20 20 20 20 20 20  tem-patts       
3520: 3b 3b 20 68 65 72 65 20 77 65 20 61 72 65 20 66  ;; here we are f
3530: 69 6c 74 65 72 69 6e 67 20 66 6f 72 20 6d 61 74  iltering for mat
3540: 63 68 65 73 20 77 69 74 68 20 2d 69 74 65 6d 70  ches with -itemp
3550: 61 74 74 0a 09 09 09 09 20 20 20 20 20 20 28 6c  att.....      (l
3560: 65 74 20 28 28 72 65 73 20 23 66 29 29 09 20 3b  et ((res #f)). ;
3570: 3b 20 6c 6f 6f 6b 20 74 68 72 6f 75 67 68 20 61  ; look through a
3580: 6c 6c 20 74 68 65 20 69 74 65 6d 2d 70 61 74 74  ll the item-patt
3590: 73 20 69 66 20 64 65 66 69 6e 65 64 2c 20 66 6f  s if defined, fo
35a0: 72 6d 61 74 20 69 73 20 70 61 74 74 31 2c 70 61  rmat is patt1,pa
35b0: 74 74 32 2c 70 61 74 74 33 20 2e 2e 2e 20 77 69  tt2,patt3 ... wi
35c0: 6c 64 63 61 72 64 20 69 73 20 25 0a 09 09 09 09  ldcard is %.....
35d0: 09 28 66 6f 72 2d 65 61 63 68 20 0a 09 09 09 09  .(for-each .....
35e0: 09 20 28 6c 61 6d 62 64 61 20 28 70 61 74 74 29  . (lambda (patt)
35f0: 0a 09 09 09 09 09 20 20 20 28 69 66 20 28 73 74  ......   (if (st
3600: 72 69 6e 67 2d 73 65 61 72 63 68 20 28 67 6c 6f  ring-search (glo
3610: 62 2d 3e 72 65 67 65 78 70 0a 09 09 09 09 09 09  b->regexp.......
3620: 09 20 20 20 20 20 20 20 28 73 74 72 69 6e 67 2d  .       (string-
3630: 74 72 61 6e 73 6c 61 74 65 20 70 61 74 74 20 22  translate patt "
3640: 25 22 20 22 2a 22 29 29 0a 09 09 09 09 09 09 09  %" "*"))........
3650: 20 20 20 20 20 20 69 74 65 6d 2d 70 61 74 68 29        item-path)
3660: 0a 09 09 09 09 09 20 20 20 20 20 20 20 28 73 65  ......       (se
3670: 74 21 20 72 65 73 20 23 74 29 29 29 0a 09 09 09  t! res #t)))....
3680: 09 09 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74  .. (string-split
3690: 20 69 74 65 6d 2d 70 61 74 74 73 20 22 2c 22 29   item-patts ",")
36a0: 29 0a 09 09 09 09 09 72 65 73 29 0a 09 09 09 09  )......res).....
36b0: 20 20 20 20 20 20 23 74 29 29 29 0a 09 20 20 20        #t)))..   
36c0: 20 20 20 20 28 69 66 20 69 74 65 6d 2d 6d 61 74      (if item-mat
36d0: 63 68 65 73 20 3b 3b 20 79 65 73 2c 20 77 65 20  ches ;; yes, we 
36e0: 77 61 6e 74 20 74 6f 20 70 72 6f 63 65 73 73 20  want to process 
36f0: 74 68 69 73 20 69 74 65 6d 0a 09 09 20 20 20 28  this item...   (
3700: 6c 65 74 20 28 28 6e 65 77 74 65 73 74 6e 61 6d  let ((newtestnam
3710: 65 20 28 63 6f 6e 63 20 68 65 64 20 22 2f 22 20  e (conc hed "/" 
3720: 6d 79 2d 69 74 65 6d 2d 70 61 74 68 29 29 29 20  my-item-path))) 
3730: 0a 09 09 20 20 20 20 20 28 74 65 73 74 73 3a 74  ...     (tests:t
3740: 65 73 74 71 75 65 75 65 2d 73 65 74 2d 69 74 65  estqueue-set-ite
3750: 6d 73 21 20 20 20 6e 65 77 2d 74 65 73 74 2d 72  ms!   new-test-r
3760: 65 63 6f 72 64 20 23 66 29 0a 09 09 20 20 20 20  ecord #f)...    
3770: 20 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75   (tests:testqueu
3780: 65 2d 73 65 74 2d 69 74 65 6d 64 61 74 21 20 6e  e-set-itemdat! n
3790: 65 77 2d 74 65 73 74 2d 72 65 63 6f 72 64 20 6d  ew-test-record m
37a0: 79 2d 69 74 65 6d 64 61 74 29 0a 09 09 20 20 20  y-itemdat)...   
37b0: 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65    (hash-table-se
37c0: 74 21 20 74 65 73 74 2d 72 65 63 6f 72 64 73 20  t! test-records 
37d0: 6e 65 77 74 65 73 74 6e 61 6d 65 20 6e 65 77 2d  newtestname new-
37e0: 74 65 73 74 2d 72 65 63 6f 72 64 29 0a 09 09 20  test-record)... 
37f0: 20 20 20 20 28 73 65 74 21 20 74 61 6c 20 28 63      (set! tal (c
3800: 6f 6e 73 20 6e 65 77 74 65 73 74 6e 61 6d 65 20  ons newtestname 
3810: 74 61 6c 29 29 29 29 29 29 20 3b 3b 20 73 69 6e  tal)))))) ;; sin
3820: 63 65 20 74 68 65 73 65 20 61 72 65 20 69 74 65  ce these are ite
3830: 6d 69 7a 65 64 20 63 72 65 61 74 65 20 6e 65 77  mized create new
3840: 20 74 65 73 74 20 6e 61 6d 65 73 20 74 65 73 74   test names test
3850: 6e 61 6d 65 2f 69 74 65 6d 70 61 74 68 0a 09 20  name/itempath.. 
3860: 20 20 69 74 65 6d 73 29 0a 09 20 20 28 6c 6f 6f    items)..  (loo
3870: 70 20 28 63 61 72 20 74 61 6c 29 28 63 64 72 20  p (car tal)(cdr 
3880: 74 61 6c 29 29 29 0a 0a 09 20 3b 3b 20 69 66 20  tal)))... ;; if 
3890: 69 74 65 6d 73 20 69 73 20 61 20 70 72 6f 63 20  items is a proc 
38a0: 74 68 65 6e 20 6e 65 65 64 20 74 6f 20 72 75 6e  then need to run
38b0: 20 69 74 65 6d 73 3a 67 65 74 2d 69 74 65 6d 73   items:get-items
38c0: 2d 66 72 6f 6d 2d 63 6f 6e 66 69 67 2c 20 67 65  -from-config, ge
38d0: 74 20 74 68 65 20 6c 69 73 74 20 61 6e 64 20 6c  t the list and l
38e0: 6f 6f 70 20 0a 09 20 3b 3b 20 20 20 20 2d 20 62  oop .. ;;    - b
38f0: 75 74 20 6f 6e 6c 79 20 64 6f 20 74 68 61 74 20  ut only do that 
3900: 69 66 20 72 65 73 6f 75 72 63 65 73 20 65 78 69  if resources exi
3910: 73 74 20 74 6f 20 6b 69 63 6b 20 6f 66 66 20 74  st to kick off t
3920: 68 65 20 6a 6f 62 0a 09 20 28 28 70 72 6f 63 65  he job.. ((proce
3930: 64 75 72 65 3f 20 69 74 65 6d 73 29 0a 09 20 20  dure? items)..  
3940: 28 69 66 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75  (if (runs:can-ru
3950: 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64 62 20  n-more-tests db 
3960: 74 65 73 74 2d 72 65 63 6f 72 64 29 0a 09 20 20  test-record)..  
3970: 20 20 20 20 28 6c 65 74 20 28 28 69 74 65 6d 73      (let ((items
3980: 2d 6c 69 73 74 20 28 69 74 65 6d 73 3a 67 65 74  -list (items:get
3990: 2d 69 74 65 6d 73 2d 66 72 6f 6d 2d 63 6f 6e 66  -items-from-conf
39a0: 69 67 20 74 63 6f 6e 66 69 67 29 29 29 0a 09 09  ig tconfig)))...
39b0: 28 69 66 20 28 6c 69 73 74 3f 20 69 74 65 6d 73  (if (list? items
39c0: 2d 6c 69 73 74 29 0a 09 09 20 20 20 20 28 62 65  -list)...    (be
39d0: 67 69 6e 0a 09 09 20 20 20 20 20 20 28 74 65 73  gin...      (tes
39e0: 74 73 3a 74 65 73 74 71 75 65 75 65 2d 73 65 74  ts:testqueue-set
39f0: 2d 69 74 65 6d 73 20 74 65 73 74 2d 72 65 63 6f  -items test-reco
3a00: 72 64 20 69 74 65 6d 73 2d 6c 69 73 74 29 0a 09  rd items-list)..
3a10: 09 20 20 20 20 20 20 28 6c 6f 6f 70 20 68 65 64  .      (loop hed
3a20: 20 74 61 6c 29 29 0a 09 09 20 20 20 20 28 62 65   tal))...    (be
3a30: 67 69 6e 0a 09 09 20 20 20 20 20 20 28 64 65 62  gin...      (deb
3a40: 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f  ug:print 0 "ERRO
3a50: 52 3a 20 54 68 65 20 70 72 6f 63 20 66 72 6f 6d  R: The proc from
3a60: 20 72 65 61 64 69 6e 67 20 74 68 65 20 73 65 74   reading the set
3a70: 75 70 20 64 69 64 20 6e 6f 74 20 79 69 65 6c 64  up did not yield
3a80: 20 61 20 6c 69 73 74 20 2d 20 70 6c 65 61 73 65   a list - please
3a90: 20 72 65 70 6f 72 74 20 74 68 69 73 22 29 0a 09   report this")..
3aa0: 09 20 20 20 20 20 20 28 65 78 69 74 20 31 29 29  .      (exit 1))
3ab0: 29 29 0a 09 20 20 20 20 20 20 28 6c 65 74 20 28  ))..      (let (
3ac0: 28 6e 65 77 74 61 6c 20 28 61 70 70 65 6e 64 20  (newtal (append 
3ad0: 74 61 6c 20 28 6c 69 73 74 20 68 65 64 29 29 29  tal (list hed)))
3ae0: 29 0a 09 09 3b 3b 20 69 66 20 63 61 6e 27 74 20  )...;; if can't 
3af0: 72 75 6e 20 6d 6f 72 65 20 74 65 73 74 73 2c 20  run more tests, 
3b00: 6c 65 74 73 20 74 61 6b 65 20 61 20 62 72 65 61  lets take a brea
3b10: 74 68 65 72 0a 09 09 28 74 68 72 65 61 64 2d 73  ther...(thread-s
3b20: 6c 65 65 70 21 20 31 29 0a 09 09 28 6c 6f 6f 70  leep! 1)...(loop
3b30: 20 28 63 61 72 20 6e 65 77 74 61 6c 29 28 63 64   (car newtal)(cd
3b40: 72 20 6e 65 77 74 61 6c 29 29 29 29 29 0a 0a 09  r newtal)))))...
3b50: 20 3b 3b 20 74 68 69 73 20 63 61 73 65 20 73 68   ;; this case sh
3b60: 6f 75 6c 64 20 6e 6f 74 20 68 61 70 70 65 6e 2c  ould not happen,
3b70: 20 61 64 64 65 64 20 74 6f 20 68 65 6c 70 20 63   added to help c
3b80: 61 74 63 68 20 61 6e 79 20 62 75 67 73 0a 09 20  atch any bugs.. 
3b90: 28 28 61 6e 64 20 28 6c 69 73 74 3f 20 69 74 65  ((and (list? ite
3ba0: 6d 73 29 20 69 74 65 6d 64 61 74 29 0a 09 20 20  ms) itemdat)..  
3bb0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
3bc0: 45 52 52 4f 52 3a 20 53 68 6f 75 6c 64 20 6e 6f  ERROR: Should no
3bd0: 74 20 68 61 76 65 20 61 20 6c 69 73 74 20 6f 66  t have a list of
3be0: 20 69 74 65 6d 73 20 69 6e 20 61 20 74 65 73 74   items in a test
3bf0: 20 61 6e 64 20 74 68 65 20 69 74 65 6d 73 70 61   and the itemspa
3c00: 74 68 20 73 65 74 20 2d 20 70 6c 65 61 73 65 20  th set - please 
3c10: 72 65 70 6f 72 74 20 74 68 69 73 22 29 0a 09 20  report this").. 
3c20: 20 28 65 78 69 74 20 31 29 29 29 0a 09 0a 09 3b   (exit 1)))....;
3c30: 3b 20 77 65 20 67 65 74 20 68 65 72 65 20 6f 6e  ; we get here on
3c40: 20 22 64 72 6f 70 20 74 68 72 6f 75 67 68 22 20   "drop through" 
3c50: 2d 20 6c 6f 6f 70 20 66 6f 72 20 6e 65 78 74 20  - loop for next 
3c60: 74 65 73 74 20 69 6e 20 71 75 65 75 65 0a 09 28  test in queue..(
3c70: 69 66 20 28 6e 75 6c 6c 3f 20 74 61 6c 29 0a 09  if (null? tal)..
3c80: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
3c90: 20 31 20 22 49 4e 46 4f 3a 20 41 6c 6c 20 74 65   1 "INFO: All te
3ca0: 73 74 73 20 6c 61 75 6e 63 68 65 64 22 29 0a 09  sts launched")..
3cb0: 20 20 20 20 28 6c 6f 6f 70 20 28 63 61 72 20 74      (loop (car t
3cc0: 61 6c 29 28 63 64 72 20 74 61 6c 29 29 29 29 29  al)(cdr tal)))))
3cd0: 29 29 0a 0a 3b 3b 20 70 61 72 65 6e 74 2d 74 65  ))..;; parent-te
3ce0: 73 74 20 69 73 20 74 68 65 72 65 20 61 73 20 61  st is there as a
3cf0: 20 70 6c 61 63 65 68 6f 6c 64 65 72 20 66 6f 72   placeholder for
3d00: 20 77 68 65 6e 20 70 61 72 65 6e 74 2d 74 65 73   when parent-tes
3d10: 74 73 20 63 61 6e 20 62 65 20 72 75 6e 20 61 73  ts can be run as
3d20: 20 61 20 73 65 74 75 70 20 73 74 65 70 0a 28 64   a setup step.(d
3d30: 65 66 69 6e 65 20 28 72 75 6e 3a 74 65 73 74 20  efine (run:test 
3d40: 64 62 20 72 75 6e 2d 69 64 20 72 75 6e 6e 61 6d  db run-id runnam
3d50: 65 20 6b 65 79 76 61 6c 6c 73 74 20 74 65 73 74  e keyvallst test
3d60: 2d 72 65 63 6f 72 64 20 66 6c 61 67 73 20 70 61  -record flags pa
3d70: 72 65 6e 74 2d 74 65 73 74 29 0a 20 20 3b 3b 20  rent-test).  ;; 
3d80: 41 6c 6c 20 74 68 65 73 65 20 76 61 72 73 20 6d  All these vars m
3d90: 69 67 68 74 20 62 65 20 72 65 66 65 72 65 6e 63  ight be referenc
3da0: 65 64 20 62 79 20 74 68 65 20 74 65 73 74 63 6f  ed by the testco
3db0: 6e 66 69 67 20 66 69 6c 65 20 72 65 61 64 65 72  nfig file reader
3dc0: 0a 20 20 28 6c 65 74 2a 20 28 28 74 65 73 74 2d  .  (let* ((test-
3dd0: 6e 61 6d 65 20 20 20 20 28 74 65 73 74 73 3a 74  name    (tests:t
3de0: 65 73 74 71 75 65 75 65 2d 67 65 74 2d 74 65 73  estqueue-get-tes
3df0: 74 6e 61 6d 65 20 20 20 74 65 73 74 2d 72 65 63  tname   test-rec
3e00: 6f 72 64 29 29 0a 09 20 28 74 65 73 74 2d 77 61  ord)).. (test-wa
3e10: 69 74 6f 6e 73 20 28 74 65 73 74 73 3a 74 65 73  itons (tests:tes
3e20: 74 71 75 65 75 65 2d 67 65 74 2d 77 61 69 74 6f  tqueue-get-waito
3e30: 6e 73 20 20 20 20 74 65 73 74 2d 72 65 63 6f 72  ns    test-recor
3e40: 64 29 29 0a 09 20 28 74 65 73 74 2d 63 6f 6e 66  d)).. (test-conf
3e50: 20 20 20 20 28 74 65 73 74 73 3a 74 65 73 74 71      (tests:testq
3e60: 75 65 75 65 2d 67 65 74 2d 74 65 73 74 63 6f 6e  ueue-get-testcon
3e70: 66 69 67 20 74 65 73 74 2d 72 65 63 6f 72 64 29  fig test-record)
3e80: 29 0a 09 20 28 69 74 65 6d 64 61 74 20 20 20 20  ).. (itemdat    
3e90: 20 20 28 74 65 73 74 73 3a 74 65 73 74 71 75 65    (tests:testque
3ea0: 75 65 2d 67 65 74 2d 69 74 65 6d 64 61 74 20 20  ue-get-itemdat  
3eb0: 20 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29 0a    test-record)).
3ec0: 09 20 28 74 65 73 74 2d 70 61 74 68 20 20 20 20  . (test-path    
3ed0: 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74 68 2a 20  (conc *toppath* 
3ee0: 22 2f 74 65 73 74 73 2f 22 20 74 65 73 74 2d 6e  "/tests/" test-n
3ef0: 61 6d 65 29 29 20 3b 3b 20 63 6f 75 6c 64 20 75  ame)) ;; could u
3f00: 73 65 20 74 65 73 74 3a 67 65 74 2d 74 65 73 74  se test:get-test
3f10: 63 6f 6e 66 69 67 20 68 65 72 65 20 2e 2e 2e 0a  config here ....
3f20: 09 20 28 66 6f 72 63 65 20 20 20 20 20 20 20 20  . (force        
3f30: 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f  (hash-table-ref/
3f40: 64 65 66 61 75 6c 74 20 66 6c 61 67 73 20 22 2d  default flags "-
3f50: 66 6f 72 63 65 22 20 23 66 29 29 0a 09 20 28 72  force" #f)).. (r
3f60: 65 72 75 6e 20 20 20 20 20 20 20 20 28 68 61 73  erun        (has
3f70: 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61  h-table-ref/defa
3f80: 75 6c 74 20 66 6c 61 67 73 20 22 2d 72 65 72 75  ult flags "-reru
3f90: 6e 22 20 23 66 29 29 0a 09 20 28 6b 65 65 70 67  n" #f)).. (keepg
3fa0: 6f 69 6e 67 20 20 20 20 28 68 61 73 68 2d 74 61  oing    (hash-ta
3fb0: 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20  ble-ref/default 
3fc0: 66 6c 61 67 73 20 22 2d 6b 65 65 70 67 6f 69 6e  flags "-keepgoin
3fd0: 67 22 20 23 66 29 29 29 0a 20 20 20 20 28 64 65  g" #f))).    (de
3fe0: 62 75 67 3a 70 72 69 6e 74 20 31 20 22 4c 61 75  bug:print 1 "Lau
3ff0: 6e 63 68 69 6e 67 20 74 65 73 74 20 22 20 74 65  nching test " te
4000: 73 74 2d 6e 61 6d 65 29 0a 20 20 20 20 28 64 65  st-name).    (de
4010: 62 75 67 3a 70 72 69 6e 74 20 35 0a 09 09 20 22  bug:print 5... "
4020: 74 65 73 74 2d 63 6f 6e 66 69 67 3a 20 22 20 28  test-config: " (
4030: 68 61 73 68 2d 74 61 62 6c 65 2d 3e 61 6c 69 73  hash-table->alis
4040: 74 20 74 65 73 74 2d 63 6f 6e 66 29 0a 09 09 20  t test-conf)... 
4050: 22 5c 6e 20 20 20 69 74 65 6d 64 61 74 3a 20 22  "\n   itemdat: "
4060: 20 69 74 65 6d 64 61 74 0a 09 09 20 29 0a 20 20   itemdat... ).  
4070: 20 20 3b 3b 20 73 65 74 74 69 6e 67 20 69 74 65    ;; setting ite
4080: 6d 64 61 74 20 74 6f 20 61 20 6c 69 73 74 20 69  mdat to a list i
4090: 66 20 69 74 20 69 73 20 23 66 0a 20 20 20 20 28  f it is #f.    (
40a0: 69 66 20 28 6e 6f 74 20 69 74 65 6d 64 61 74 29  if (not itemdat)
40b0: 28 73 65 74 21 20 69 74 65 6d 64 61 74 20 27 28  (set! itemdat '(
40c0: 29 29 29 0a 20 20 20 20 28 73 65 74 65 6e 76 20  ))).    (setenv 
40d0: 22 4d 54 5f 54 45 53 54 5f 4e 41 4d 45 22 20 74  "MT_TEST_NAME" t
40e0: 65 73 74 2d 6e 61 6d 65 29 20 3b 3b 20 0a 20 20  est-name) ;; .  
40f0: 20 20 28 73 65 74 65 6e 76 20 22 4d 54 5f 52 55    (setenv "MT_RU
4100: 4e 4e 41 4d 45 22 20 20 20 72 75 6e 6e 61 6d 65  NNAME"   runname
4110: 29 0a 20 20 20 20 28 73 65 74 2d 6d 65 67 61 74  ).    (set-megat
4120: 65 73 74 2d 65 6e 76 2d 76 61 72 73 20 64 62 20  est-env-vars db 
4130: 72 75 6e 2d 69 64 29 20 3b 3b 20 74 68 65 73 65  run-id) ;; these
4140: 20 6d 61 79 20 62 65 20 6e 65 65 64 65 64 20 62   may be needed b
4150: 79 20 74 68 65 20 6c 61 75 6e 63 68 69 6e 67 20  y the launching 
4160: 70 72 6f 63 65 73 73 0a 20 20 20 20 28 63 68 61  process.    (cha
4170: 6e 67 65 2d 64 69 72 65 63 74 6f 72 79 20 2a 74  nge-directory *t
4180: 6f 70 70 61 74 68 2a 29 0a 0a 20 20 20 20 3b 3b  oppath*)..    ;;
4190: 20 48 65 72 65 20 69 73 20 77 68 65 72 65 20 74   Here is where t
41a0: 68 65 20 74 65 73 74 5f 6d 65 74 61 20 74 61 62  he test_meta tab
41b0: 6c 65 20 69 73 20 62 65 73 74 20 75 70 64 61 74  le is best updat
41c0: 65 64 0a 20 20 20 20 28 72 75 6e 73 3a 75 70 64  ed.    (runs:upd
41d0: 61 74 65 2d 74 65 73 74 5f 6d 65 74 61 20 64 62  ate-test_meta db
41e0: 20 74 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 2d   test-name test-
41f0: 63 6f 6e 66 29 0a 20 20 20 20 0a 20 20 20 20 3b  conf).    .    ;
4200: 3b 20 28 6c 61 6d 62 64 61 20 28 69 74 65 6d 64  ; (lambda (itemd
4210: 61 74 29 20 3b 3b 3b 20 28 28 72 69 70 65 6e 65  at) ;;; ((ripene
4220: 73 73 20 22 6f 76 65 72 72 69 70 65 22 29 20 28  ss "overripe") (
4230: 74 65 6d 70 65 72 61 74 75 72 65 20 22 63 6f 6f  temperature "coo
4240: 6c 22 29 20 28 73 65 61 73 6f 6e 20 22 73 75 6d  l") (season "sum
4250: 6d 65 72 22 29 29 0a 20 20 20 20 28 6c 65 74 2a  mer")).    (let*
4260: 20 28 28 69 74 65 6d 2d 70 61 74 68 20 20 20 20   ((item-path    
4270: 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74   (item-list->pat
4280: 68 20 69 74 65 6d 64 61 74 29 29 20 3b 3b 20 28  h itemdat)) ;; (
4290: 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72  string-intersper
42a0: 73 65 20 28 6d 61 70 20 63 61 64 72 20 69 74 65  se (map cadr ite
42b0: 6d 64 61 74 29 20 22 2f 22 29 29 0a 09 20 20 20  mdat) "/"))..   
42c0: 28 6e 65 77 2d 74 65 73 74 2d 70 61 74 68 20 28  (new-test-path (
42d0: 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72  string-intersper
42e0: 73 65 20 28 63 6f 6e 73 20 74 65 73 74 2d 70 61  se (cons test-pa
42f0: 74 68 20 28 6d 61 70 20 63 61 64 72 20 69 74 65  th (map cadr ite
4300: 6d 64 61 74 29 29 20 22 2f 22 29 29 0a 09 20 20  mdat)) "/"))..  
4310: 20 28 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20   (new-test-name 
4320: 28 69 66 20 28 65 71 75 61 6c 3f 20 69 74 65 6d  (if (equal? item
4330: 2d 70 61 74 68 20 22 22 29 20 74 65 73 74 2d 6e  -path "") test-n
4340: 61 6d 65 20 28 63 6f 6e 63 20 74 65 73 74 2d 6e  ame (conc test-n
4350: 61 6d 65 20 22 2f 22 20 69 74 65 6d 2d 70 61 74  ame "/" item-pat
4360: 68 29 29 29 20 3b 3b 20 6a 75 73 74 20 6e 65 65  h))) ;; just nee
4370: 64 20 69 74 20 74 6f 20 62 65 20 75 6e 69 71 75  d it to be uniqu
4380: 65 0a 09 20 20 20 28 74 65 73 74 64 61 74 20 20  e..   (testdat  
4390: 20 20 20 20 20 28 64 62 3a 67 65 74 2d 74 65 73       (db:get-tes
43a0: 74 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64  t-info db run-id
43b0: 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d   test-name item-
43c0: 70 61 74 68 29 29 29 0a 20 20 20 20 20 20 28 69  path))).      (i
43d0: 66 20 28 6e 6f 74 20 74 65 73 74 64 61 74 29 0a  f (not testdat).
43e0: 09 20 20 28 62 65 67 69 6e 0a 09 20 20 20 20 28  .  (begin..    (
43f0: 72 65 67 69 73 74 65 72 2d 74 65 73 74 20 64 62  register-test db
4400: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
4410: 65 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 20 20  e item-path)..  
4420: 20 20 28 73 65 74 21 20 74 65 73 74 64 61 74 20    (set! testdat 
4430: 28 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66  (db:get-test-inf
4440: 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  o db run-id test
4450: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  -name item-path)
4460: 29 29 29 0a 20 20 20 20 20 20 28 63 68 61 6e 67  ))).      (chang
4470: 65 2d 64 69 72 65 63 74 6f 72 79 20 74 65 73 74  e-directory test
4480: 2d 70 61 74 68 29 0a 20 20 20 20 20 20 28 63 61  -path).      (ca
4490: 73 65 20 28 69 66 20 66 6f 72 63 65 20 3b 3b 20  se (if force ;; 
44a0: 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d  (args:get-arg "-
44b0: 66 6f 72 63 65 22 29 0a 09 09 27 4e 4f 54 5f 53  force")...'NOT_S
44c0: 54 41 52 54 45 44 0a 09 09 28 69 66 20 74 65 73  TARTED...(if tes
44d0: 74 64 61 74 0a 09 09 20 20 20 20 28 73 74 72 69  tdat...    (stri
44e0: 6e 67 2d 3e 73 79 6d 62 6f 6c 20 28 74 65 73 74  ng->symbol (test
44f0: 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64  :get-state testd
4500: 61 74 29 29 0a 09 09 20 20 20 20 27 66 61 69 6c  at))...    'fail
4510: 65 64 2d 74 6f 2d 69 6e 73 65 72 74 29 29 0a 09  ed-to-insert))..
4520: 28 28 66 61 69 6c 65 64 2d 74 6f 2d 69 6e 73 65  ((failed-to-inse
4530: 72 74 29 0a 09 20 28 64 65 62 75 67 3a 70 72 69  rt).. (debug:pri
4540: 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 46 61 69  nt 0 "ERROR: Fai
4550: 6c 65 64 20 74 6f 20 69 6e 73 65 72 74 20 74 68  led to insert th
4560: 65 20 72 65 63 6f 72 64 20 69 6e 74 6f 20 74 68  e record into th
4570: 65 20 64 62 22 29 29 0a 09 28 28 4e 4f 54 5f 53  e db"))..((NOT_S
4580: 54 41 52 54 45 44 20 43 4f 4d 50 4c 45 54 45 44  TARTED COMPLETED
4590: 29 0a 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ).. (debug:print
45a0: 20 36 20 22 47 6f 74 20 68 65 72 65 2c 20 22 20   6 "Got here, " 
45b0: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20  (test:get-state 
45c0: 74 65 73 74 64 61 74 29 29 0a 09 20 28 6c 65 74  testdat)).. (let
45d0: 20 28 28 72 75 6e 66 6c 61 67 20 23 66 29 29 0a   ((runflag #f)).
45e0: 09 20 20 20 28 63 6f 6e 64 0a 09 20 20 20 20 3b  .   (cond..    ;
45f0: 3b 20 2d 66 6f 72 63 65 2c 20 72 75 6e 20 6e 6f  ; -force, run no
4600: 20 6d 61 74 74 65 72 20 77 68 61 74 0a 09 20 20   matter what..  
4610: 20 20 28 66 6f 72 63 65 20 28 73 65 74 21 20 72    (force (set! r
4620: 75 6e 66 6c 61 67 20 23 74 29 29 0a 09 20 20 20  unflag #t))..   
4630: 20 3b 3b 20 4e 4f 54 5f 53 54 41 52 54 45 44 2c   ;; NOT_STARTED,
4640: 20 72 75 6e 20 6e 6f 20 6d 61 74 74 65 72 20 77   run no matter w
4650: 68 61 74 0a 09 20 20 20 20 28 28 65 71 75 61 6c  hat..    ((equal
4660: 3f 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74  ? (test:get-stat
4670: 65 20 74 65 73 74 64 61 74 29 20 22 4e 4f 54 5f  e testdat) "NOT_
4680: 53 54 41 52 54 45 44 22 29 28 73 65 74 21 20 72  STARTED")(set! r
4690: 75 6e 66 6c 61 67 20 23 74 29 29 0a 09 20 20 20  unflag #t))..   
46a0: 20 3b 3b 20 6e 6f 74 20 2d 72 65 72 75 6e 20 61   ;; not -rerun a
46b0: 6e 64 20 50 41 53 53 2c 20 57 41 52 4e 20 6f 72  nd PASS, WARN or
46c0: 20 43 48 45 43 4b 2c 20 64 6f 20 6e 6f 20 72 75   CHECK, do no ru
46d0: 6e 0a 09 20 20 20 20 28 28 61 6e 64 20 28 6f 72  n..    ((and (or
46e0: 20 28 6e 6f 74 20 72 65 72 75 6e 29 0a 09 09 20   (not rerun)... 
46f0: 20 20 20 20 20 6b 65 65 70 67 6f 69 6e 67 29 0a       keepgoing).
4700: 09 09 20 20 28 6d 65 6d 62 65 72 20 28 74 65 73  ..  (member (tes
4710: 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73  t:get-status tes
4720: 74 64 61 74 29 20 27 28 22 50 41 53 53 22 20 22  tdat) '("PASS" "
4730: 57 41 52 4e 22 20 22 43 48 45 43 4b 22 29 29 29  WARN" "CHECK")))
4740: 0a 09 20 20 20 20 20 28 73 65 74 21 20 72 75 6e  ..     (set! run
4750: 66 6c 61 67 20 23 66 29 29 0a 09 20 20 20 20 3b  flag #f))..    ;
4760: 3b 20 2d 72 65 72 75 6e 20 61 6e 64 20 73 74 61  ; -rerun and sta
4770: 74 75 73 20 69 73 20 6f 6e 65 20 6f 66 20 74 68  tus is one of th
4780: 65 20 73 70 65 63 69 66 65 64 2c 20 72 75 6e 20  e specifed, run 
4790: 69 74 0a 09 20 20 20 20 28 28 61 6e 64 20 72 65  it..    ((and re
47a0: 72 75 6e 0a 09 09 20 20 28 6c 65 74 20 28 28 72  run...  (let ((r
47b0: 65 72 75 6e 6c 73 74 20 28 73 74 72 69 6e 67 2d  erunlst (string-
47c0: 73 70 6c 69 74 20 72 65 72 75 6e 20 22 2c 22 29  split rerun ",")
47d0: 29 29 20 3b 3b 20 46 41 49 4c 2c 0a 09 09 20 20  )) ;; FAIL,...  
47e0: 20 20 28 6d 65 6d 62 65 72 20 28 74 65 73 74 3a    (member (test:
47f0: 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64  get-status testd
4800: 61 74 29 20 72 65 72 75 6e 6c 73 74 29 29 29 0a  at) rerunlst))).
4810: 09 20 20 20 20 20 28 73 65 74 21 20 72 75 6e 66  .     (set! runf
4820: 6c 61 67 20 23 74 29 29 0a 09 20 20 20 20 3b 3b  lag #t))..    ;;
4830: 20 2d 6b 65 65 70 67 6f 69 6e 67 2c 20 64 6f 20   -keepgoing, do 
4840: 6e 6f 74 20 72 65 72 75 6e 20 46 41 49 4c 0a 09  not rerun FAIL..
4850: 20 20 20 20 28 28 61 6e 64 20 6b 65 65 70 67 6f      ((and keepgo
4860: 69 6e 67 0a 09 09 20 20 28 6d 65 6d 62 65 72 20  ing...  (member 
4870: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73  (test:get-status
4880: 20 74 65 73 74 64 61 74 29 20 27 28 22 46 41 49   testdat) '("FAI
4890: 4c 22 29 29 29 0a 09 20 20 20 20 20 28 73 65 74  L")))..     (set
48a0: 21 20 72 75 6e 66 6c 61 67 20 23 66 29 29 0a 09  ! runflag #f))..
48b0: 20 20 20 20 28 28 61 6e 64 20 28 6e 6f 74 20 72      ((and (not r
48c0: 65 72 75 6e 29 0a 09 09 20 20 28 6d 65 6d 62 65  erun)...  (membe
48d0: 72 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74  r (test:get-stat
48e0: 75 73 20 74 65 73 74 64 61 74 29 20 27 28 22 46  us testdat) '("F
48f0: 41 49 4c 22 20 22 6e 2f 61 22 29 29 29 0a 09 20  AIL" "n/a"))).. 
4900: 20 20 20 20 28 73 65 74 21 20 72 75 6e 66 6c 61      (set! runfla
4910: 67 20 23 74 29 29 0a 09 20 20 20 20 28 65 6c 73  g #t))..    (els
4920: 65 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20  e (set! runflag 
4930: 23 66 29 29 29 0a 09 20 20 20 28 64 65 62 75 67  #f)))..   (debug
4940: 3a 70 72 69 6e 74 20 36 20 22 52 55 4e 4e 49 4e  :print 6 "RUNNIN
4950: 47 20 3d 3e 20 72 75 6e 66 6c 61 67 3a 20 22 20  G => runflag: " 
4960: 72 75 6e 66 6c 61 67 20 22 20 53 54 41 54 45 3a  runflag " STATE:
4970: 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61   " (test:get-sta
4980: 74 65 20 74 65 73 74 64 61 74 29 20 22 20 53 54  te testdat) " ST
4990: 41 54 55 53 3a 20 22 20 28 74 65 73 74 3a 67 65  ATUS: " (test:ge
49a0: 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61 74  t-status testdat
49b0: 29 29 0a 09 20 20 20 28 69 66 20 28 6e 6f 74 20  ))..   (if (not 
49c0: 72 75 6e 66 6c 61 67 29 0a 09 20 20 20 20 20 20  runflag)..      
49d0: 20 28 69 66 20 28 6e 6f 74 20 70 61 72 65 6e 74   (if (not parent
49e0: 2d 74 65 73 74 29 0a 09 09 20 20 20 28 64 65 62  -test)...   (deb
49f0: 75 67 3a 70 72 69 6e 74 20 31 20 22 4e 4f 54 45  ug:print 1 "NOTE
4a00: 3a 20 4e 6f 74 20 73 74 61 72 74 69 6e 67 20 74  : Not starting t
4a10: 65 73 74 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e  est " new-test-n
4a20: 61 6d 65 20 22 20 61 73 20 69 74 20 69 73 20 73  ame " as it is s
4a30: 74 61 74 65 20 5c 22 43 4f 4d 50 4c 45 54 45 44  tate \"COMPLETED
4a40: 5c 22 20 61 6e 64 20 73 74 61 74 75 73 20 5c 22  \" and status \"
4a50: 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74  " (test:get-stat
4a60: 75 73 20 74 65 73 74 64 61 74 29 20 22 5c 22 2c  us testdat) "\",
4a70: 20 75 73 65 20 2d 66 6f 72 63 65 20 74 6f 20 6f   use -force to o
4a80: 76 65 72 72 69 64 65 22 29 29 0a 09 20 20 20 20  verride"))..    
4a90: 20 20 20 3b 3b 20 4e 4f 54 45 3a 20 4e 6f 20 6c     ;; NOTE: No l
4aa0: 6f 6e 67 65 72 20 62 65 20 63 68 65 63 6b 69 6e  onger be checkin
4ab0: 67 20 70 72 65 72 65 71 75 69 73 69 74 65 73 20  g prerequisites 
4ac0: 68 65 72 65 21 20 57 69 6c 6c 20 6e 65 76 65 72  here! Will never
4ad0: 20 67 65 74 20 68 65 72 65 20 75 6e 6c 65 73 73   get here unless
4ae0: 20 70 72 65 72 65 71 73 20 61 72 65 0a 09 20 20   prereqs are..  
4af0: 20 20 20 20 20 3b 3b 20 20 20 20 20 20 20 61 6c       ;;       al
4b00: 72 65 61 64 79 20 6d 65 74 2e 0a 09 20 20 20 20  ready met...    
4b10: 20 20 20 28 69 66 20 28 6e 6f 74 20 28 6c 61 75     (if (not (lau
4b20: 6e 63 68 2d 74 65 73 74 20 64 62 20 72 75 6e 2d  nch-test db run-
4b30: 69 64 20 72 75 6e 6e 61 6d 65 20 74 65 73 74 2d  id runname test-
4b40: 63 6f 6e 66 20 6b 65 79 76 61 6c 6c 73 74 20 74  conf keyvallst t
4b50: 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 2d 70 61  est-name test-pa
4b60: 74 68 20 69 74 65 6d 64 61 74 20 66 6c 61 67 73  th itemdat flags
4b70: 29 29 0a 09 09 20 20 20 28 62 65 67 69 6e 0a 09  ))...   (begin..
4b80: 09 20 20 20 20 20 28 70 72 69 6e 74 20 22 45 52  .     (print "ER
4b90: 52 4f 52 3a 20 46 61 69 6c 65 64 20 74 6f 20 6c  ROR: Failed to l
4ba0: 61 75 6e 63 68 20 74 68 65 20 74 65 73 74 2e 20  aunch the test. 
4bb0: 45 78 69 74 69 6e 67 20 61 73 20 73 6f 6f 6e 20  Exiting as soon 
4bc0: 61 73 20 70 6f 73 73 69 62 6c 65 22 29 0a 09 09  as possible")...
4bd0: 20 20 20 20 20 28 73 65 74 21 20 2a 67 6c 6f 62       (set! *glob
4be0: 61 6c 65 78 69 74 73 74 61 74 75 73 2a 20 31 29  alexitstatus* 1)
4bf0: 20 3b 3b 20 0a 09 09 20 20 20 20 20 28 70 72 6f   ;; ...     (pro
4c00: 63 65 73 73 2d 73 69 67 6e 61 6c 20 28 63 75 72  cess-signal (cur
4c10: 72 65 6e 74 2d 70 72 6f 63 65 73 73 2d 69 64 29  rent-process-id)
4c20: 20 73 69 67 6e 61 6c 2f 6b 69 6c 6c 29 29 29 29   signal/kill))))
4c30: 29 29 0a 09 28 28 4b 49 4c 4c 45 44 29 20 0a 09  ))..((KILLED) ..
4c40: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20   (debug:print 1 
4c50: 22 4e 4f 54 45 3a 20 22 20 6e 65 77 2d 74 65 73  "NOTE: " new-tes
4c60: 74 2d 6e 61 6d 65 20 22 20 69 73 20 61 6c 72 65  t-name " is alre
4c70: 61 64 79 20 72 75 6e 6e 69 6e 67 20 6f 72 20 77  ady running or w
4c80: 61 73 20 65 78 70 6c 69 63 74 6c 79 20 6b 69 6c  as explictly kil
4c90: 6c 65 64 2c 20 75 73 65 20 2d 66 6f 72 63 65 20  led, use -force 
4ca0: 74 6f 20 6c 61 75 6e 63 68 20 69 74 2e 22 29 29  to launch it."))
4cb0: 0a 09 28 28 4c 41 55 4e 43 48 45 44 20 52 45 4d  ..((LAUNCHED REM
4cc0: 4f 54 45 48 4f 53 54 53 54 41 52 54 20 52 55 4e  OTEHOSTSTART RUN
4cd0: 4e 49 4e 47 29 20 20 0a 09 20 28 69 66 20 28 3e  NING)  .. (if (>
4ce0: 20 28 2d 20 28 63 75 72 72 65 6e 74 2d 73 65 63   (- (current-sec
4cf0: 6f 6e 64 73 29 28 2b 20 28 64 62 3a 74 65 73 74  onds)(+ (db:test
4d00: 2d 67 65 74 2d 65 76 65 6e 74 5f 74 69 6d 65 20  -get-event_time 
4d10: 74 65 73 74 64 61 74 29 0a 09 09 09 09 20 20 20  testdat).....   
4d20: 20 20 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74      (db:test-get
4d30: 2d 72 75 6e 5f 64 75 72 61 74 69 6f 6e 20 74 65  -run_duration te
4d40: 73 74 64 61 74 29 29 29 0a 09 09 36 30 30 29 20  stdat)))...600) 
4d50: 3b 3b 20 69 2e 65 2e 20 6e 6f 20 75 70 64 61 74  ;; i.e. no updat
4d60: 65 20 66 6f 72 20 6d 6f 72 65 20 74 68 61 6e 20  e for more than 
4d70: 36 30 30 20 73 65 63 6f 6e 64 73 0a 09 20 20 20  600 seconds..   
4d80: 20 20 28 62 65 67 69 6e 0a 09 20 20 20 20 20 20    (begin..      
4d90: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
4da0: 22 57 41 52 4e 49 4e 47 3a 20 54 65 73 74 20 22  "WARNING: Test "
4db0: 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 61 70 70   test-name " app
4dc0: 65 61 72 73 20 74 6f 20 62 65 20 64 65 61 64 2e  ears to be dead.
4dd0: 20 46 6f 72 63 69 6e 67 20 69 74 20 74 6f 20 73   Forcing it to s
4de0: 74 61 74 65 20 49 4e 43 4f 4d 50 4c 45 54 45 20  tate INCOMPLETE 
4df0: 61 6e 64 20 73 74 61 74 75 73 20 53 54 55 43 4b  and status STUCK
4e00: 2f 44 45 41 44 22 29 0a 09 20 20 20 20 20 20 20  /DEAD")..       
4e10: 28 74 65 73 74 2d 73 65 74 2d 73 74 61 74 75 73  (test-set-status
4e20: 21 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  ! db run-id test
4e30: 2d 6e 61 6d 65 20 22 49 4e 43 4f 4d 50 4c 45 54  -name "INCOMPLET
4e40: 45 22 20 22 53 54 55 43 4b 2f 44 45 41 44 22 20  E" "STUCK/DEAD" 
4e50: 69 74 65 6d 64 61 74 20 22 54 65 73 74 20 69 73  itemdat "Test is
4e60: 20 73 74 75 63 6b 20 6f 72 20 64 65 61 64 22 20   stuck or dead" 
4e70: 23 66 29 29 0a 09 20 20 20 20 20 28 64 65 62 75  #f))..     (debu
4e80: 67 3a 70 72 69 6e 74 20 32 20 22 4e 4f 54 45 3a  g:print 2 "NOTE:
4e90: 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 69   " test-name " i
4ea0: 73 20 61 6c 72 65 61 64 79 20 72 75 6e 6e 69 6e  s already runnin
4eb0: 67 22 29 29 29 0a 09 28 65 6c 73 65 20 20 20 20  g")))..(else    
4ec0: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
4ed0: 30 20 22 45 52 52 4f 52 3a 20 46 61 69 6c 65 64  0 "ERROR: Failed
4ee0: 20 74 6f 20 6c 61 75 6e 63 68 20 74 65 73 74 20   to launch test 
4ef0: 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20  " new-test-name 
4f00: 22 2e 20 55 6e 72 65 63 6f 67 6e 69 73 65 64 20  ". Unrecognised 
4f10: 73 74 61 74 65 20 22 20 28 74 65 73 74 3a 67 65  state " (test:ge
4f20: 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 74 29  t-state testdat)
4f30: 29 29 29 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d  ))))))..;;======
4f40: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
4f50: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
4f60: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
4f70: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
4f80: 0a 3b 3b 20 45 4e 44 20 4f 46 20 4e 45 57 20 53  .;; END OF NEW S
4f90: 54 55 46 46 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d  TUFF.;;=========
4fa0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
4fb0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
4fc0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
4fd0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 28  =============..(
4fe0: 64 65 66 69 6e 65 20 28 67 65 74 2d 64 69 72 2d  define (get-dir-
4ff0: 75 70 2d 6e 20 64 69 72 20 2e 20 70 61 72 61 6d  up-n dir . param
5000: 73 29 20 0a 20 20 28 6c 65 74 20 28 28 64 70 61  s) .  (let ((dpa
5010: 72 74 73 20 20 28 73 74 72 69 6e 67 2d 73 70 6c  rts  (string-spl
5020: 69 74 20 64 69 72 20 22 2f 22 29 29 0a 09 28 63  it dir "/"))..(c
5030: 6f 75 6e 74 20 20 20 28 69 66 20 28 6e 75 6c 6c  ount   (if (null
5040: 3f 20 70 61 72 61 6d 73 29 20 31 20 28 63 61 72  ? params) 1 (car
5050: 20 70 61 72 61 6d 73 29 29 29 29 0a 20 20 20 20   params)))).    
5060: 28 63 6f 6e 63 20 22 2f 22 20 28 73 74 72 69 6e  (conc "/" (strin
5070: 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 0a 09  g-intersperse ..
5080: 20 20 20 20 20 20 20 28 74 61 6b 65 20 64 70 61         (take dpa
5090: 72 74 73 20 28 2d 20 28 6c 65 6e 67 74 68 20 64  rts (- (length d
50a0: 70 61 72 74 73 29 20 63 6f 75 6e 74 29 29 0a 09  parts) count))..
50b0: 20 20 20 20 20 20 20 22 2f 22 29 29 29 29 0a 3b         "/")))).;
50c0: 3b 20 52 65 6d 6f 76 65 20 72 75 6e 73 0a 3b 3b  ; Remove runs.;;
50d0: 20 66 69 65 6c 64 73 20 61 72 65 20 70 61 73 73   fields are pass
50e0: 69 6e 67 20 69 6e 20 74 68 72 6f 75 67 68 20 0a  ing in through .
50f0: 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 72 65  (define (runs:re
5100: 6d 6f 76 65 2d 72 75 6e 73 20 64 62 20 72 75 6e  move-runs db run
5110: 6e 61 6d 65 70 61 74 74 20 74 65 73 74 70 61 74  namepatt testpat
5120: 74 20 69 74 65 6d 70 61 74 74 29 0a 20 20 28 6c  t itempatt).  (l
5130: 65 74 2a 20 28 28 6b 65 79 73 20 20 20 20 20 20  et* ((keys      
5140: 20 20 28 64 62 2d 67 65 74 2d 6b 65 79 73 20 64    (db-get-keys d
5150: 62 29 29 0a 09 20 28 72 75 6e 64 61 74 20 20 20  b)).. (rundat   
5160: 20 20 20 28 72 75 6e 73 3a 67 65 74 2d 72 75 6e     (runs:get-run
5170: 73 2d 62 79 2d 70 61 74 74 20 64 62 20 6b 65 79  s-by-patt db key
5180: 73 20 72 75 6e 6e 61 6d 65 70 61 74 74 29 29 0a  s runnamepatt)).
5190: 09 20 28 68 65 61 64 65 72 20 20 20 20 20 20 28  . (header      (
51a0: 76 65 63 74 6f 72 2d 72 65 66 20 72 75 6e 64 61  vector-ref runda
51b0: 74 20 30 29 29 0a 09 20 28 72 75 6e 73 20 20 20  t 0)).. (runs   
51c0: 20 20 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66       (vector-ref
51d0: 20 72 75 6e 64 61 74 20 31 29 29 29 0a 20 20 20   rundat 1))).   
51e0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20   (debug:print 1 
51f0: 22 48 65 61 64 65 72 3a 20 22 20 68 65 61 64 65  "Header: " heade
5200: 72 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68  r).    (for-each
5210: 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 72  .     (lambda (r
5220: 75 6e 29 0a 20 20 20 20 20 20 20 28 6c 65 74 20  un).       (let 
5230: 28 28 72 75 6e 6b 65 79 20 28 73 74 72 69 6e 67  ((runkey (string
5240: 2d 69 6e 74 65 72 73 70 65 72 73 65 20 28 6d 61  -intersperse (ma
5250: 70 20 28 6c 61 6d 62 64 61 20 28 6b 29 0a 09 09  p (lambda (k)...
5260: 09 09 09 09 28 64 62 3a 67 65 74 2d 76 61 6c 75  ....(db:get-valu
5270: 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20  e-by-header run 
5280: 68 65 61 64 65 72 20 28 76 65 63 74 6f 72 2d 72  header (vector-r
5290: 65 66 20 6b 20 30 29 29 29 20 6b 65 79 73 29 20  ef k 0))) keys) 
52a0: 22 2f 22 29 29 0a 09 20 20 20 20 20 28 64 69 72  "/"))..     (dir
52b0: 73 2d 74 6f 2d 72 65 6d 6f 76 65 20 28 6d 61 6b  s-to-remove (mak
52c0: 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29 29 0a  e-hash-table))).
52d0: 09 20 28 6c 65 74 2a 20 28 28 72 75 6e 2d 69 64  . (let* ((run-id
52e0: 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62   (db:get-value-b
52f0: 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61  y-header run hea
5300: 64 65 72 20 22 69 64 22 29 20 29 0a 09 09 28 74  der "id") )...(t
5310: 65 73 74 73 20 20 28 64 62 2d 67 65 74 2d 74 65  ests  (db-get-te
5320: 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 28  sts-for-run db (
5330: 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d  db:get-value-by-
5340: 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65  header run heade
5350: 72 20 22 69 64 22 29 20 74 65 73 74 70 61 74 74  r "id") testpatt
5360: 20 69 74 65 6d 70 61 74 74 20 27 28 29 20 27 28   itempatt '() '(
5370: 29 29 29 0a 09 09 28 6c 61 73 74 74 70 61 74 68  )))...(lasttpath
5380: 20 22 2f 64 6f 65 73 2f 6e 6f 74 2f 65 78 69 73   "/does/not/exis
5390: 74 2f 49 2f 68 6f 70 65 22 29 29 0a 0a 09 20 20  t/I/hope"))...  
53a0: 20 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f   (if (not (null?
53b0: 20 74 65 73 74 73 29 29 0a 09 20 20 20 20 20 20   tests))..      
53c0: 20 28 62 65 67 69 6e 0a 09 09 20 28 64 65 62 75   (begin... (debu
53d0: 67 3a 70 72 69 6e 74 20 31 20 22 52 65 6d 6f 76  g:print 1 "Remov
53e0: 69 6e 67 20 74 65 73 74 73 20 66 6f 72 20 72 75  ing tests for ru
53f0: 6e 3a 20 22 20 72 75 6e 6b 65 79 20 22 20 22 20  n: " runkey " " 
5400: 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79  (db:get-value-by
5410: 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64  -header run head
5420: 65 72 20 22 72 75 6e 6e 61 6d 65 22 29 29 0a 09  er "runname"))..
5430: 09 20 28 66 6f 72 2d 65 61 63 68 0a 09 09 20 20  . (for-each...  
5440: 28 6c 61 6d 62 64 61 20 28 74 65 73 74 29 0a 09  (lambda (test)..
5450: 09 20 20 20 20 28 6c 65 74 2a 20 28 28 69 74 65  .    (let* ((ite
5460: 6d 2d 70 61 74 68 20 28 64 62 3a 74 65 73 74 2d  m-path (db:test-
5470: 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74 65  get-item-path te
5480: 73 74 29 29 0a 09 09 09 20 20 20 28 74 65 73 74  st))....   (test
5490: 2d 6e 61 6d 65 20 28 64 62 3a 74 65 73 74 2d 67  -name (db:test-g
54a0: 65 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74  et-testname test
54b0: 29 29 0a 09 09 09 20 20 20 28 72 75 6e 2d 64 69  ))....   (run-di
54c0: 72 20 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74  r   (db:test-get
54d0: 2d 72 75 6e 64 69 72 20 74 65 73 74 29 29 29 0a  -rundir test))).
54e0: 09 09 20 20 20 20 20 20 28 64 65 62 75 67 3a 70  ..      (debug:p
54f0: 72 69 6e 74 20 31 20 22 20 20 22 20 28 64 62 3a  rint 1 "  " (db:
5500: 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d  test-get-testnam
5510: 65 20 74 65 73 74 29 20 22 20 69 64 3a 20 22 20  e test) " id: " 
5520: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20  (db:test-get-id 
5530: 74 65 73 74 29 20 22 20 22 20 69 74 65 6d 2d 70  test) " " item-p
5540: 61 74 68 29 0a 09 09 20 20 20 20 20 20 28 64 62  ath)...      (db
5550: 3a 64 65 6c 65 74 65 2d 74 65 73 74 2d 72 65 63  :delete-test-rec
5560: 6f 72 64 73 20 64 62 20 28 64 62 3a 74 65 73 74  ords db (db:test
5570: 2d 67 65 74 2d 69 64 20 74 65 73 74 29 29 0a 09  -get-id test))..
5580: 09 20 20 20 20 20 20 28 69 66 20 28 3e 20 28 73  .      (if (> (s
5590: 74 72 69 6e 67 2d 6c 65 6e 67 74 68 20 72 75 6e  tring-length run
55a0: 2d 64 69 72 29 20 35 29 20 3b 3b 20 62 61 64 20  -dir) 5) ;; bad 
55b0: 68 65 75 72 69 73 74 69 63 20 62 75 74 20 73 68  heuristic but sh
55c0: 6f 75 6c 64 20 70 72 65 76 65 6e 74 20 2f 74 6d  ould prevent /tm
55d0: 70 20 2f 68 6f 6d 65 20 65 74 63 2e 0a 09 09 09  p /home etc.....
55e0: 20 20 28 6c 65 74 20 28 28 66 75 6c 6c 70 61 74    (let ((fullpat
55f0: 68 20 72 75 6e 2d 64 69 72 29 29 20 3b 3b 20 22  h run-dir)) ;; "
5600: 2f 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  /" (db:test-get-
5610: 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 29 29  item-path test))
5620: 29 29 0a 09 09 09 20 20 20 20 28 73 65 74 21 20  ))....    (set! 
5630: 6c 61 73 74 74 70 61 74 68 20 66 75 6c 6c 70 61  lasttpath fullpa
5640: 74 68 29 0a 09 09 09 20 20 20 20 28 68 61 73 68  th)....    (hash
5650: 2d 74 61 62 6c 65 2d 73 65 74 21 20 64 69 72 73  -table-set! dirs
5660: 2d 74 6f 2d 72 65 6d 6f 76 65 20 66 75 6c 6c 70  -to-remove fullp
5670: 61 74 68 20 23 74 29 0a 09 09 09 20 20 20 20 3b  ath #t)....    ;
5680: 3b 20 54 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20  ; The following 
5690: 77 61 73 20 74 68 65 20 73 61 66 65 20 64 65 6c  was the safe del
56a0: 65 74 65 20 63 6f 64 65 20 62 75 74 20 69 74 20  ete code but it 
56b0: 77 61 73 20 6e 6f 74 20 62 65 69 6e 67 20 65 78  was not being ex
56c0: 65 63 74 75 74 65 64 2e 0a 09 09 09 20 20 20 20  ectuted.....    
56d0: 3b 3b 20 28 6c 65 74 2a 20 28 28 64 69 72 73 2d  ;; (let* ((dirs-
56e0: 63 6f 75 6e 74 20 28 2b 20 31 20 28 6c 65 6e 67  count (+ 1 (leng
56f0: 74 68 20 6b 65 79 73 29 28 6c 65 6e 67 74 68 20  th keys)(length 
5700: 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 69 74  (string-split it
5710: 65 6d 2d 70 61 74 68 20 22 2f 22 29 29 29 29 0a  em-path "/")))).
5720: 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20 20 20  ...    ;;       
5730: 20 28 64 69 72 2d 74 6f 2d 72 65 6d 20 28 67 65   (dir-to-rem (ge
5740: 74 2d 64 69 72 2d 75 70 2d 6e 20 66 75 6c 6c 70  t-dir-up-n fullp
5750: 61 74 68 20 64 69 72 73 2d 63 6f 75 6e 74 29 29  ath dirs-count))
5760: 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20 20  ....    ;;      
5770: 20 20 28 72 65 6d 61 69 6e 69 6e 67 64 20 28 73    (remainingd (s
5780: 74 72 69 6e 67 2d 73 75 62 73 74 69 74 75 74 65  tring-substitute
5790: 20 28 72 65 67 65 78 70 20 28 63 6f 6e 63 20 22   (regexp (conc "
57a0: 5e 22 20 64 69 72 2d 74 6f 2d 72 65 6d 20 22 2f  ^" dir-to-rem "/
57b0: 22 29 29 20 22 22 20 66 75 6c 6c 70 61 74 68 29  ")) "" fullpath)
57c0: 29 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20  )....    ;;     
57d0: 20 20 20 28 63 6d 64 20 28 63 6f 6e 63 20 22 63     (cmd (conc "c
57e0: 64 20 22 20 64 69 72 2d 74 6f 2d 72 65 6d 20 22  d " dir-to-rem "
57f0: 3b 20 72 6d 64 69 72 20 2d 70 20 22 20 72 65 6d  ; rmdir -p " rem
5800: 61 69 6e 69 6e 67 64 20 29 29 29 0a 09 09 09 20  ainingd ))).... 
5810: 20 20 20 3b 3b 20 20 20 28 69 66 20 28 66 69 6c     ;;   (if (fil
5820: 65 2d 65 78 69 73 74 73 3f 20 66 75 6c 6c 70 61  e-exists? fullpa
5830: 74 68 29 0a 09 09 09 20 20 20 20 3b 3b 20 20 20  th)....    ;;   
5840: 20 20 20 20 28 62 65 67 69 6e 0a 09 09 09 20 20      (begin....  
5850: 20 20 3b 3b 20 20 20 20 20 20 20 20 20 28 64 65    ;;         (de
5860: 62 75 67 3a 70 72 69 6e 74 20 31 20 63 6d 64 29  bug:print 1 cmd)
5870: 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20 20  ....    ;;      
5880: 20 20 20 28 73 79 73 74 65 6d 20 63 6d 64 29 29     (system cmd))
5890: 29 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 29 29  )....    ;;   ))
58a0: 0a 09 09 09 20 20 20 20 29 29 29 29 0a 09 09 20  ....    ))))... 
58b0: 20 20 20 74 65 73 74 73 29 29 29 0a 0a 09 20 20     tests)))...  
58c0: 20 3b 3b 20 6c 6f 6f 6b 20 74 68 6f 75 67 68 20   ;; look though 
58d0: 74 68 65 20 64 69 72 73 2d 74 6f 2d 72 65 6d 6f  the dirs-to-remo
58e0: 76 65 20 66 6f 72 20 63 61 6e 64 69 64 61 74 65  ve for candidate
58f0: 73 20 66 6f 72 20 72 65 6d 6f 76 61 6c 2e 20 44  s for removal. D
5900: 6f 20 74 68 69 73 20 61 66 74 65 72 20 64 65 6c  o this after del
5910: 65 74 69 6e 67 20 74 68 65 20 72 65 63 6f 72 64  eting the record
5920: 73 0a 09 20 20 20 3b 3b 20 66 6f 72 20 65 61 63  s..   ;; for eac
5930: 68 20 74 65 73 74 20 69 6e 20 63 61 73 65 20 77  h test in case w
5940: 65 20 67 65 74 20 6b 69 6c 6c 65 64 2e 20 54 68  e get killed. Th
5950: 61 74 20 73 68 6f 75 6c 64 20 6d 69 6e 69 6d 69  at should minimi
5960: 7a 65 20 74 68 65 20 64 65 74 72 69 74 75 73 20  ze the detritus 
5970: 6c 65 66 74 20 6f 6e 20 64 69 73 6b 0a 09 20 20  left on disk..  
5980: 20 3b 3b 20 70 72 6f 63 65 73 73 20 74 68 65 20   ;; process the 
5990: 64 69 72 73 20 66 72 6f 6d 20 6c 6f 6e 67 65 73  dirs from longes
59a0: 74 20 73 74 72 69 6e 67 20 6c 65 6e 67 74 68 20  t string length 
59b0: 74 6f 20 73 68 6f 72 74 65 73 74 0a 09 20 20 20  to shortest..   
59c0: 28 66 6f 72 2d 65 61 63 68 20 0a 09 20 20 20 20  (for-each ..    
59d0: 28 6c 61 6d 62 64 61 20 28 64 69 72 2d 74 6f 2d  (lambda (dir-to-
59e0: 72 65 6d 6f 76 65 29 0a 09 20 20 20 20 20 20 28  remove)..      (
59f0: 69 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f  if (file-exists?
5a00: 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 0a   dir-to-remove).
5a10: 09 09 20 20 28 6c 65 74 20 28 28 64 69 72 2d 69  ..  (let ((dir-i
5a20: 6e 2d 64 62 20 27 28 29 29 29 0a 09 09 20 20 20  n-db '()))...   
5a30: 20 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61   (sqlite3:for-ea
5a40: 63 68 2d 72 6f 77 0a 09 09 20 20 20 20 20 28 6c  ch-row...     (l
5a50: 61 6d 62 64 61 20 28 64 69 72 29 0a 09 09 20 20  ambda (dir)...  
5a60: 20 20 20 20 20 28 73 65 74 21 20 64 69 72 2d 69       (set! dir-i
5a70: 6e 2d 64 62 20 28 63 6f 6e 73 20 64 69 72 20 64  n-db (cons dir d
5a80: 69 72 2d 69 6e 2d 64 62 29 29 29 0a 09 09 20 20  ir-in-db)))...  
5a90: 20 20 20 64 62 20 22 53 45 4c 45 43 54 20 72 75     db "SELECT ru
5aa0: 6e 64 69 72 20 46 52 4f 4d 20 74 65 73 74 73 20  ndir FROM tests 
5ab0: 57 48 45 52 45 20 72 75 6e 64 69 72 20 4c 49 4b  WHERE rundir LIK
5ac0: 45 20 3f 3b 22 20 0a 09 09 20 20 20 20 20 28 63  E ?;" ...     (c
5ad0: 6f 6e 63 20 22 25 22 20 64 69 72 2d 74 6f 2d 72  onc "%" dir-to-r
5ae0: 65 6d 6f 76 65 20 22 25 22 29 29 20 3b 3b 20 79  emove "%")) ;; y
5af0: 65 73 2c 20 49 27 6d 20 67 6f 69 6e 67 20 74 6f  es, I'm going to
5b00: 20 62 61 69 6c 20 69 66 20 74 68 65 72 65 20 69   bail if there i
5b10: 73 20 61 6e 79 74 68 69 6e 67 20 6c 69 6b 65 20  s anything like 
5b20: 74 68 69 73 20 64 69 72 20 69 6e 20 74 68 65 20  this dir in the 
5b30: 64 62 0a 09 09 20 20 20 20 28 69 66 20 28 6e 75  db...    (if (nu
5b40: 6c 6c 3f 20 64 69 72 2d 69 6e 2d 64 62 29 0a 09  ll? dir-in-db)..
5b50: 09 09 28 62 65 67 69 6e 0a 09 09 09 20 20 28 64  ..(begin....  (d
5b60: 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 52 65  ebug:print 2 "Re
5b70: 6d 6f 76 69 6e 67 20 64 69 72 65 63 74 6f 72 79  moving directory
5b80: 20 77 69 74 68 20 7a 65 72 6f 20 64 62 20 72 65   with zero db re
5b90: 66 65 72 65 6e 63 65 73 3a 20 22 20 64 69 72 2d  ferences: " dir-
5ba0: 74 6f 2d 72 65 6d 6f 76 65 29 0a 09 09 09 20 20  to-remove)....  
5bb0: 28 73 79 73 74 65 6d 20 28 63 6f 6e 63 20 22 72  (system (conc "r
5bc0: 6d 20 2d 72 66 20 22 20 64 69 72 2d 74 6f 2d 72  m -rf " dir-to-r
5bd0: 65 6d 6f 76 65 29 29 0a 09 09 09 20 20 28 68 61  emove))....  (ha
5be0: 73 68 2d 74 61 62 6c 65 2d 64 65 6c 65 74 65 21  sh-table-delete!
5bf0: 20 64 69 72 73 2d 74 6f 2d 72 65 6d 6f 76 65 20   dirs-to-remove 
5c00: 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 29 0a  dir-to-remove)).
5c10: 09 09 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20  ...(debug:print 
5c20: 32 20 22 53 6b 69 70 70 69 6e 67 20 72 65 6d 6f  2 "Skipping remo
5c30: 76 61 6c 20 6f 66 20 22 20 64 69 72 2d 74 6f 2d  val of " dir-to-
5c40: 72 65 6d 6f 76 65 20 22 20 66 6f 72 20 6e 6f 77  remove " for now
5c50: 20 61 73 20 69 74 20 73 74 69 6c 6c 20 68 61 73   as it still has
5c60: 20 72 65 66 65 72 65 6e 63 65 73 20 69 6e 20 74   references in t
5c70: 68 65 20 64 61 74 61 62 61 73 65 22 29 29 29 29  he database"))))
5c80: 29 0a 09 20 20 20 20 28 73 6f 72 74 20 28 68 61  )..    (sort (ha
5c90: 73 68 2d 74 61 62 6c 65 2d 6b 65 79 73 20 64 69  sh-table-keys di
5ca0: 72 73 2d 74 6f 2d 72 65 6d 6f 76 65 29 20 28 6c  rs-to-remove) (l
5cb0: 61 6d 62 64 61 20 28 61 20 62 29 28 3e 20 28 73  ambda (a b)(> (s
5cc0: 74 72 69 6e 67 2d 6c 65 6e 67 74 68 20 61 29 28  tring-length a)(
5cd0: 73 74 72 69 6e 67 2d 6c 65 6e 67 74 68 20 62 29  string-length b)
5ce0: 29 29 29 29 0a 0a 09 20 20 20 3b 3b 20 72 65 6d  ))))...   ;; rem
5cf0: 6f 76 65 20 74 68 65 20 72 75 6e 20 69 66 20 7a  ove the run if z
5d00: 65 72 6f 20 74 65 73 74 73 20 72 65 6d 61 69 6e  ero tests remain
5d10: 0a 09 20 20 20 28 6c 65 74 20 28 28 72 65 6d 74  ..   (let ((remt
5d20: 65 73 74 73 20 28 64 62 2d 67 65 74 2d 74 65 73  ests (db-get-tes
5d30: 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 28 64  ts-for-run db (d
5d40: 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68  b:get-value-by-h
5d50: 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65 72  eader run header
5d60: 20 22 69 64 22 29 20 23 66 20 23 66 20 27 28 29   "id") #f #f '()
5d70: 20 27 28 29 29 29 29 0a 09 20 20 20 20 20 28 69   '())))..     (i
5d80: 66 20 28 6e 75 6c 6c 3f 20 72 65 6d 74 65 73 74  f (null? remtest
5d90: 73 29 20 3b 3b 20 6e 6f 20 6d 6f 72 65 20 74 65  s) ;; no more te
5da0: 73 74 73 20 72 65 6d 61 69 6e 69 6e 67 0a 09 09  sts remaining...
5db0: 20 28 6c 65 74 2a 20 28 28 64 70 61 72 74 73 20   (let* ((dparts 
5dc0: 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 6c   (string-split l
5dd0: 61 73 74 74 70 61 74 68 20 22 2f 22 29 29 0a 09  asttpath "/"))..
5de0: 09 09 28 72 75 6e 70 61 74 68 20 28 63 6f 6e 63  ..(runpath (conc
5df0: 20 22 2f 22 20 28 73 74 72 69 6e 67 2d 69 6e 74   "/" (string-int
5e00: 65 72 73 70 65 72 73 65 20 0a 09 09 09 09 09 20  ersperse ...... 
5e10: 20 20 20 28 74 61 6b 65 20 64 70 61 72 74 73 20     (take dparts 
5e20: 28 2d 20 28 6c 65 6e 67 74 68 20 64 70 61 72 74  (- (length dpart
5e30: 73 29 20 31 29 29 0a 09 09 09 09 09 20 20 20 20  s) 1))......    
5e40: 22 2f 22 29 29 29 29 0a 09 09 20 20 20 28 64 65  "/"))))...   (de
5e50: 62 75 67 3a 70 72 69 6e 74 20 31 20 22 52 65 6d  bug:print 1 "Rem
5e60: 6f 76 69 6e 67 20 72 75 6e 3a 20 22 20 72 75 6e  oving run: " run
5e70: 6b 65 79 20 22 20 22 20 28 64 62 3a 67 65 74 2d  key " " (db:get-
5e80: 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20  value-by-header 
5e90: 72 75 6e 20 68 65 61 64 65 72 20 22 72 75 6e 6e  run header "runn
5ea0: 61 6d 65 22 29 29 0a 09 09 20 20 20 28 64 62 3a  ame"))...   (db:
5eb0: 64 65 6c 65 74 65 2d 72 75 6e 20 64 62 20 72 75  delete-run db ru
5ec0: 6e 2d 69 64 29 0a 09 09 20 20 20 3b 3b 20 6e 65  n-id)...   ;; ne
5ed0: 65 64 20 74 6f 20 66 69 67 75 72 65 20 6f 75 74  ed to figure out
5ee0: 20 74 68 65 20 70 61 74 68 20 74 6f 20 74 68 65   the path to the
5ef0: 20 72 75 6e 20 64 69 72 20 61 6e 64 20 72 65 6d   run dir and rem
5f00: 6f 76 65 20 69 74 20 69 66 20 65 6d 70 74 79 0a  ove it if empty.
5f10: 09 09 20 20 20 3b 3b 20 20 20 20 28 69 66 20 28  ..   ;;    (if (
5f20: 6e 75 6c 6c 3f 20 28 67 6c 6f 62 20 28 63 6f 6e  null? (glob (con
5f30: 63 20 72 75 6e 70 61 74 68 20 22 2f 2a 22 29 29  c runpath "/*"))
5f40: 29 0a 09 09 20 20 20 3b 3b 20 20 20 20 20 20 20  )...   ;;       
5f50: 20 28 62 65 67 69 6e 0a 09 09 20 20 20 3b 3b 20   (begin...   ;; 
5f60: 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31  . (debug:print 1
5f70: 20 22 52 65 6d 6f 76 69 6e 67 20 72 75 6e 20 64   "Removing run d
5f80: 69 72 20 22 20 72 75 6e 70 61 74 68 29 0a 09 09  ir " runpath)...
5f90: 20 20 20 3b 3b 20 09 20 28 73 79 73 74 65 6d 20     ;; . (system 
5fa0: 28 63 6f 6e 63 20 22 72 6d 64 69 72 20 2d 70 20  (conc "rmdir -p 
5fb0: 22 20 72 75 6e 70 61 74 68 29 29 29 29 0a 09 09  " runpath))))...
5fc0: 20 20 20 29 29 29 29 0a 09 20 29 29 0a 20 20 20     )))).. )).   
5fd0: 20 20 72 75 6e 73 29 29 29 0a 0a 3b 3b 3d 3d 3d    runs)))..;;===
5fe0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5ff0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6000: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6010: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6020: 3d 3d 3d 0a 3b 3b 20 52 6f 75 74 69 6e 65 73 20  ===.;; Routines 
6030: 66 6f 72 20 6d 61 6e 69 70 75 6c 61 74 69 6e 67  for manipulating
6040: 20 72 75 6e 73 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d   runs.;;========
6050: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6060: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6070: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6080: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a  ==============..
6090: 3b 3b 20 53 69 6e 63 65 20 6d 61 6e 79 20 63 61  ;; Since many ca
60a0: 6c 6c 73 20 74 6f 20 61 20 72 75 6e 20 72 65 71  lls to a run req
60b0: 75 69 72 65 20 70 72 65 74 74 79 20 6d 75 63 68  uire pretty much
60c0: 20 74 68 65 20 73 61 6d 65 20 73 65 74 75 70 20   the same setup 
60d0: 0a 3b 3b 20 74 68 69 73 20 77 72 61 70 70 65 72  .;; this wrapper
60e0: 20 69 73 20 75 73 65 64 20 74 6f 20 72 65 64 75   is used to redu
60f0: 63 65 20 74 68 65 20 72 65 70 6c 69 63 61 74 69  ce the replicati
6100: 6f 6e 20 6f 66 20 63 6f 64 65 0a 28 64 65 66 69  on of code.(defi
6110: 6e 65 20 28 67 65 6e 65 72 61 6c 2d 72 75 6e 2d  ne (general-run-
6120: 63 61 6c 6c 20 73 77 69 74 63 68 6e 61 6d 65 20  call switchname 
6130: 61 63 74 69 6f 6e 2d 64 65 73 63 20 70 72 6f 63  action-desc proc
6140: 29 0a 20 20 28 6c 65 74 20 28 28 72 75 6e 6e 61  ).  (let ((runna
6150: 6d 65 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67  me (args:get-arg
6160: 20 22 3a 72 75 6e 6e 61 6d 65 22 29 29 0a 09 28   ":runname"))..(
6170: 74 61 72 67 65 74 20 20 28 69 66 20 28 61 72 67  target  (if (arg
6180: 73 3a 67 65 74 2d 61 72 67 20 22 2d 74 61 72 67  s:get-arg "-targ
6190: 65 74 22 29 0a 09 09 20 20 20 20 20 28 61 72 67  et")...     (arg
61a0: 73 3a 67 65 74 2d 61 72 67 20 22 2d 74 61 72 67  s:get-arg "-targ
61b0: 65 74 22 29 0a 09 09 20 20 20 20 20 28 61 72 67  et")...     (arg
61c0: 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65 71 74  s:get-arg "-reqt
61d0: 61 72 67 22 29 29 29 29 0a 20 20 20 20 28 63 6f  arg")))).    (co
61e0: 6e 64 0a 20 20 20 20 20 28 28 6e 6f 74 20 74 61  nd.     ((not ta
61f0: 72 67 65 74 29 0a 20 20 20 20 20 20 28 64 65 62  rget).      (deb
6200: 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f  ug:print 0 "ERRO
6210: 52 3a 20 4d 69 73 73 69 6e 67 20 72 65 71 75 69  R: Missing requi
6220: 72 65 64 20 70 61 72 61 6d 65 74 65 72 20 66 6f  red parameter fo
6230: 72 20 22 20 73 77 69 74 63 68 6e 61 6d 65 20 22  r " switchname "
6240: 2c 20 79 6f 75 20 6d 75 73 74 20 73 70 65 63 69  , you must speci
6250: 66 79 20 74 68 65 20 74 61 72 67 65 74 20 77 69  fy the target wi
6260: 74 68 20 2d 74 61 72 67 65 74 22 29 0a 20 20 20  th -target").   
6270: 20 20 20 28 65 78 69 74 20 33 29 29 0a 20 20 20     (exit 3)).   
6280: 20 20 28 28 6e 6f 74 20 72 75 6e 6e 61 6d 65 29    ((not runname)
6290: 0a 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72  .      (debug:pr
62a0: 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 4d 69  int 0 "ERROR: Mi
62b0: 73 73 69 6e 67 20 72 65 71 75 69 72 65 64 20 70  ssing required p
62c0: 61 72 61 6d 65 74 65 72 20 66 6f 72 20 22 20 73  arameter for " s
62d0: 77 69 74 63 68 6e 61 6d 65 20 22 2c 20 79 6f 75  witchname ", you
62e0: 20 6d 75 73 74 20 73 70 65 63 69 66 79 20 74 68   must specify th
62f0: 65 20 72 75 6e 20 6e 61 6d 65 20 77 69 74 68 20  e run name with 
6300: 3a 72 75 6e 6e 61 6d 65 20 72 75 6e 6e 61 6d 65  :runname runname
6310: 22 29 0a 20 20 20 20 20 20 28 65 78 69 74 20 33  ").      (exit 3
6320: 29 29 0a 20 20 20 20 20 28 65 6c 73 65 0a 20 20  )).     (else.  
6330: 20 20 20 20 28 6c 65 74 20 28 28 64 62 20 20 20      (let ((db   
6340: 23 66 29 0a 09 20 20 20 20 28 6b 65 79 73 20 23  #f)..    (keys #
6350: 66 29 29 0a 09 28 69 66 20 28 6e 6f 74 20 28 73  f))..(if (not (s
6360: 65 74 75 70 2d 66 6f 72 2d 72 75 6e 29 29 0a 09  etup-for-run))..
6370: 20 20 20 20 28 62 65 67 69 6e 20 0a 09 20 20 20      (begin ..   
6380: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
6390: 30 20 22 46 61 69 6c 65 64 20 74 6f 20 73 65 74  0 "Failed to set
63a0: 75 70 2c 20 65 78 69 74 69 6e 67 22 29 0a 09 20  up, exiting").. 
63b0: 20 20 20 20 20 28 65 78 69 74 20 31 29 29 29 0a       (exit 1))).
63c0: 09 28 73 65 74 21 20 64 62 20 20 20 28 6f 70 65  .(set! db   (ope
63d0: 6e 2d 64 62 29 29 0a 09 28 73 65 74 21 20 6b 65  n-db))..(set! ke
63e0: 79 73 20 28 64 62 2d 67 65 74 2d 6b 65 79 73 20  ys (db-get-keys 
63f0: 64 62 29 29 0a 09 3b 3b 20 68 61 76 65 20 65 6e  db))..;; have en
6400: 6f 75 67 68 20 74 6f 20 70 72 6f 63 65 73 73 20  ough to process 
6410: 2d 74 61 72 67 65 74 20 6f 72 20 2d 72 65 71 74  -target or -reqt
6420: 61 72 67 20 68 65 72 65 0a 09 28 69 66 20 28 61  arg here..(if (a
6430: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65  rgs:get-arg "-re
6440: 71 74 61 72 67 22 29 0a 09 20 20 20 20 28 6c 65  qtarg")..    (le
6450: 74 2a 20 28 28 72 75 6e 63 6f 6e 66 69 67 66 20  t* ((runconfigf 
6460: 28 63 6f 6e 63 20 20 2a 74 6f 70 70 61 74 68 2a  (conc  *toppath*
6470: 20 22 2f 72 75 6e 63 6f 6e 66 69 67 73 2e 63 6f   "/runconfigs.co
6480: 6e 66 69 67 22 29 29 20 3b 3b 20 44 4f 20 4e 4f  nfig")) ;; DO NO
6490: 54 20 45 56 41 4c 55 41 54 45 20 41 4c 4c 20 0a  T EVALUATE ALL .
64a0: 09 09 20 20 20 28 72 75 6e 63 6f 6e 66 69 67 20  ..   (runconfig 
64b0: 20 28 72 65 61 64 2d 63 6f 6e 66 69 67 20 72 75   (read-config ru
64c0: 6e 63 6f 6e 66 69 67 66 20 23 66 20 23 66 20 65  nconfigf #f #f e
64d0: 6e 76 69 72 6f 6e 2d 70 61 74 74 3a 20 23 66 29  nviron-patt: #f)
64e0: 29 29 20 0a 09 20 20 20 20 20 20 28 69 66 20 28  )) ..      (if (
64f0: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64  hash-table-ref/d
6500: 65 66 61 75 6c 74 20 72 75 6e 63 6f 6e 66 69 67  efault runconfig
6510: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22   (args:get-arg "
6520: 2d 72 65 71 74 61 72 67 22 29 20 23 66 29 0a 09  -reqtarg") #f)..
6530: 09 20 20 28 6b 65 79 73 3a 74 61 72 67 65 74 2d  .  (keys:target-
6540: 73 65 74 2d 61 72 67 73 20 6b 65 79 73 20 28 61  set-args keys (a
6550: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65  rgs:get-arg "-re
6560: 71 74 61 72 67 22 29 20 61 72 67 73 3a 61 72 67  qtarg") args:arg
6570: 2d 68 61 73 68 29 0a 09 09 20 20 28 62 65 67 69  -hash)...  (begi
6580: 6e 0a 09 09 20 20 20 20 28 64 65 62 75 67 3a 70  n...    (debug:p
6590: 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 5b  rint 0 "ERROR: [
65a0: 22 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20  " (args:get-arg 
65b0: 22 2d 72 65 71 74 61 72 67 22 29 20 22 5d 20 6e  "-reqtarg") "] n
65c0: 6f 74 20 66 6f 75 6e 64 20 69 6e 20 22 20 72 75  ot found in " ru
65d0: 6e 63 6f 6e 66 69 67 66 29 0a 09 09 20 20 20 20  nconfigf)...    
65e0: 28 73 71 6c 69 74 65 33 3a 66 69 6e 61 6c 69 7a  (sqlite3:finaliz
65f0: 65 21 20 64 62 29 0a 09 09 20 20 20 20 28 65 78  e! db)...    (ex
6600: 69 74 20 31 29 29 29 29 0a 09 20 20 20 20 28 69  it 1))))..    (i
6610: 66 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20  f (args:get-arg 
6620: 22 2d 74 61 72 67 65 74 22 29 0a 09 09 28 6b 65  "-target")...(ke
6630: 79 73 3a 74 61 72 67 65 74 2d 73 65 74 2d 61 72  ys:target-set-ar
6640: 67 73 20 6b 65 79 73 20 28 61 72 67 73 3a 67 65  gs keys (args:ge
6650: 74 2d 61 72 67 20 22 2d 74 61 72 67 65 74 22 20  t-arg "-target" 
6660: 61 72 67 73 3a 61 72 67 2d 68 61 73 68 29 20 61  args:arg-hash) a
6670: 72 67 73 3a 61 72 67 2d 68 61 73 68 29 29 29 0a  rgs:arg-hash))).
6680: 09 28 69 66 20 28 6e 6f 74 20 28 63 61 72 20 2a  .(if (not (car *
6690: 63 6f 6e 66 69 67 69 6e 66 6f 2a 29 29 0a 09 20  configinfo*)).. 
66a0: 20 20 20 28 62 65 67 69 6e 0a 09 20 20 20 20 20     (begin..     
66b0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
66c0: 22 45 52 52 4f 52 3a 20 41 74 74 65 6d 70 74 65  "ERROR: Attempte
66d0: 64 20 74 6f 20 22 20 61 63 74 69 6f 6e 2d 64 65  d to " action-de
66e0: 73 63 20 22 20 62 75 74 20 72 75 6e 20 61 72 65  sc " but run are
66f0: 61 20 63 6f 6e 66 69 67 20 66 69 6c 65 20 6e 6f  a config file no
6700: 74 20 66 6f 75 6e 64 22 29 0a 09 20 20 20 20 20  t found")..     
6710: 20 28 65 78 69 74 20 31 29 29 0a 09 20 20 20 20   (exit 1))..    
6720: 3b 3b 20 45 78 74 72 61 63 74 20 6f 75 74 20 73  ;; Extract out s
6730: 74 75 66 66 20 6e 65 65 64 65 64 20 69 6e 20 6d  tuff needed in m
6740: 6f 73 74 20 6f 72 20 6d 61 6e 79 20 63 61 6c 6c  ost or many call
6750: 73 0a 09 20 20 20 20 3b 3b 20 68 65 72 65 20 74  s..    ;; here t
6760: 68 65 6e 20 63 61 6c 6c 20 70 72 6f 63 0a 09 20  hen call proc.. 
6770: 20 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 6e 61     (let* ((keyna
6780: 6d 65 73 20 20 20 28 6d 61 70 20 6b 65 79 3a 67  mes   (map key:g
6790: 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65 79  et-fieldname key
67a0: 73 29 29 0a 09 09 20 20 20 28 6b 65 79 76 61 6c  s))...   (keyval
67b0: 6c 73 74 20 20 28 6b 65 79 73 2d 3e 76 61 6c 6c  lst  (keys->vall
67c0: 69 73 74 20 6b 65 79 73 20 23 74 29 29 29 0a 09  ist keys #t)))..
67d0: 20 20 20 20 20 20 28 70 72 6f 63 20 64 62 20 74        (proc db t
67e0: 61 72 67 65 74 20 72 75 6e 6e 61 6d 65 20 6b 65  arget runname ke
67f0: 79 73 20 6b 65 79 6e 61 6d 65 73 20 6b 65 79 76  ys keynames keyv
6800: 61 6c 6c 73 74 29 29 29 0a 09 28 73 71 6c 69 74  allst)))..(sqlit
6810: 65 33 3a 66 69 6e 61 6c 69 7a 65 21 20 64 62 29  e3:finalize! db)
6820: 0a 09 28 73 65 74 21 20 2a 64 69 64 73 6f 6d 65  ..(set! *didsome
6830: 74 68 69 6e 67 2a 20 23 74 29 29 29 29 29 29 0a  thing* #t)))))).
6840: 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  .;;=============
6850: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6860: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6870: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6880: 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 52 6f 6c  =========.;; Rol
6890: 6c 75 70 20 72 75 6e 73 0a 3b 3b 3d 3d 3d 3d 3d  lup runs.;;=====
68a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
68b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
68c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
68d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
68e0: 3d 0a 0a 3b 3b 20 55 70 64 61 74 65 20 74 68 65  =..;; Update the
68f0: 20 74 65 73 74 5f 6d 65 74 61 20 74 61 62 6c 65   test_meta table
6900: 20 66 6f 72 20 74 68 69 73 20 74 65 73 74 0a 28   for this test.(
6910: 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 75 70 64  define (runs:upd
6920: 61 74 65 2d 74 65 73 74 5f 6d 65 74 61 20 64 62  ate-test_meta db
6930: 20 74 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 2d   test-name test-
6940: 63 6f 6e 66 29 0a 20 20 28 6c 65 74 20 28 28 63  conf).  (let ((c
6950: 75 72 72 72 65 63 6f 72 64 20 28 64 62 3a 74 65  urrrecord (db:te
6960: 73 74 6d 65 74 61 2d 67 65 74 2d 72 65 63 6f 72  stmeta-get-recor
6970: 64 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 29 29  d db test-name))
6980: 29 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 63  ).    (if (not c
6990: 75 72 72 72 65 63 6f 72 64 29 0a 09 28 62 65 67  urrrecord)..(beg
69a0: 69 6e 0a 09 20 20 28 73 65 74 21 20 63 75 72 72  in..  (set! curr
69b0: 72 65 63 6f 72 64 20 28 6d 61 6b 65 2d 76 65 63  record (make-vec
69c0: 74 6f 72 20 31 30 20 23 66 29 29 0a 09 20 20 28  tor 10 #f))..  (
69d0: 64 62 3a 74 65 73 74 6d 65 74 61 2d 61 64 64 2d  db:testmeta-add-
69e0: 72 65 63 6f 72 64 20 64 62 20 74 65 73 74 2d 6e  record db test-n
69f0: 61 6d 65 29 29 29 0a 20 20 20 20 28 66 6f 72 2d  ame))).    (for-
6a00: 65 61 63 68 20 0a 20 20 20 20 20 28 6c 61 6d 62  each .     (lamb
6a10: 64 61 20 28 6b 65 79 29 0a 20 20 20 20 20 20 20  da (key).       
6a20: 28 6c 65 74 2a 20 28 28 69 64 78 20 28 63 61 64  (let* ((idx (cad
6a30: 72 20 6b 65 79 29 29 0a 09 20 20 20 20 20 20 28  r key))..      (
6a40: 66 6c 64 20 28 63 61 72 20 20 6b 65 79 29 29 0a  fld (car  key)).
6a50: 09 20 20 20 20 20 20 28 76 61 6c 20 28 63 6f 6e  .      (val (con
6a60: 66 69 67 2d 6c 6f 6f 6b 75 70 20 74 65 73 74 2d  fig-lookup test-
6a70: 63 6f 6e 66 20 22 74 65 73 74 5f 6d 65 74 61 22  conf "test_meta"
6a80: 20 66 6c 64 29 29 29 0a 09 20 3b 3b 20 28 64 65   fld))).. ;; (de
6a90: 62 75 67 3a 70 72 69 6e 74 20 35 20 22 69 64 78  bug:print 5 "idx
6aa0: 3a 20 22 20 69 64 78 20 22 20 66 6c 64 3a 20 22  : " idx " fld: "
6ab0: 20 66 6c 64 20 22 20 76 61 6c 3a 20 22 20 76 61   fld " val: " va
6ac0: 6c 29 0a 09 20 28 69 66 20 28 61 6e 64 20 76 61  l).. (if (and va
6ad0: 6c 20 28 6e 6f 74 20 28 65 71 75 61 6c 3f 20 28  l (not (equal? (
6ae0: 76 65 63 74 6f 72 2d 72 65 66 20 63 75 72 72 72  vector-ref currr
6af0: 65 63 6f 72 64 20 69 64 78 29 20 76 61 6c 29 29  ecord idx) val))
6b00: 29 0a 09 20 20 20 20 20 28 62 65 67 69 6e 0a 09  )..     (begin..
6b10: 20 20 20 20 20 20 20 28 70 72 69 6e 74 20 22 55         (print "U
6b20: 70 64 61 74 69 6e 67 20 22 20 74 65 73 74 2d 6e  pdating " test-n
6b30: 61 6d 65 20 22 20 22 20 66 6c 64 20 22 20 74 6f  ame " " fld " to
6b40: 20 22 20 76 61 6c 29 0a 09 20 20 20 20 20 20 20   " val)..       
6b50: 28 64 62 3a 74 65 73 74 6d 65 74 61 2d 75 70 64  (db:testmeta-upd
6b60: 61 74 65 2d 66 69 65 6c 64 20 64 62 20 74 65 73  ate-field db tes
6b70: 74 2d 6e 61 6d 65 20 66 6c 64 20 76 61 6c 29 29  t-name fld val))
6b80: 29 29 29 0a 20 20 20 20 20 27 28 28 22 61 75 74  ))).     '(("aut
6b90: 68 6f 72 22 20 32 29 28 22 6f 77 6e 65 72 22 20  hor" 2)("owner" 
6ba0: 33 29 28 22 64 65 73 63 72 69 70 74 69 6f 6e 22  3)("description"
6bb0: 20 34 29 28 22 72 65 76 69 65 77 65 64 22 20 35   4)("reviewed" 5
6bc0: 29 28 22 74 61 67 73 22 20 39 29 29 29 29 29 0a  )("tags" 9))))).
6bd0: 0a 3b 3b 20 55 70 64 61 74 65 20 74 65 73 74 5f  .;; Update test_
6be0: 6d 65 74 61 20 66 6f 72 20 61 6c 6c 20 74 65 73  meta for all tes
6bf0: 74 73 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73  ts.(define (runs
6c00: 3a 75 70 64 61 74 65 2d 61 6c 6c 2d 74 65 73 74  :update-all-test
6c10: 5f 6d 65 74 61 20 64 62 29 0a 20 20 28 6c 65 74  _meta db).  (let
6c20: 20 28 28 74 65 73 74 2d 6e 61 6d 65 73 20 28 67   ((test-names (g
6c30: 65 74 2d 61 6c 6c 2d 6c 65 67 61 6c 2d 74 65 73  et-all-legal-tes
6c40: 74 73 29 29 29 0a 20 20 20 20 28 66 6f 72 2d 65  ts))).    (for-e
6c50: 61 63 68 20 0a 20 20 20 20 20 28 6c 61 6d 62 64  ach .     (lambd
6c60: 61 20 28 74 65 73 74 2d 6e 61 6d 65 29 0a 20 20  a (test-name).  
6c70: 20 20 20 20 20 28 6c 65 74 2a 20 28 28 74 65 73       (let* ((tes
6c80: 74 2d 70 61 74 68 20 20 20 20 28 63 6f 6e 63 20  t-path    (conc 
6c90: 2a 74 6f 70 70 61 74 68 2a 20 22 2f 74 65 73 74  *toppath* "/test
6ca0: 73 2f 22 20 74 65 73 74 2d 6e 61 6d 65 29 29 0a  s/" test-name)).
6cb0: 09 20 20 20 20 20 20 28 74 65 73 74 2d 63 6f 6e  .      (test-con
6cc0: 66 69 67 66 20 28 63 6f 6e 63 20 74 65 73 74 2d  figf (conc test-
6cd0: 70 61 74 68 20 22 2f 74 65 73 74 63 6f 6e 66 69  path "/testconfi
6ce0: 67 22 29 29 0a 09 20 20 20 20 20 20 28 74 65 73  g"))..      (tes
6cf0: 74 65 78 69 73 74 73 20 20 20 28 61 6e 64 20 28  texists   (and (
6d00: 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 74 65 73  file-exists? tes
6d10: 74 2d 63 6f 6e 66 69 67 66 29 28 66 69 6c 65 2d  t-configf)(file-
6d20: 72 65 61 64 2d 61 63 63 65 73 73 3f 20 74 65 73  read-access? tes
6d30: 74 2d 63 6f 6e 66 69 67 66 29 29 29 0a 09 20 20  t-configf)))..  
6d40: 20 20 20 20 3b 3b 20 72 65 61 64 20 63 6f 6e 66      ;; read conf
6d50: 69 67 73 20 77 69 74 68 20 74 72 69 63 6b 73 20  igs with tricks 
6d60: 74 75 72 6e 65 64 20 6f 66 66 20 28 69 2e 65 2e  turned off (i.e.
6d70: 20 6e 6f 20 73 79 73 74 65 6d 29 0a 09 20 20 20   no system)..   
6d80: 20 20 20 28 74 65 73 74 2d 63 6f 6e 66 20 20 20     (test-conf   
6d90: 20 28 69 66 20 74 65 73 74 65 78 69 73 74 73 20   (if testexists 
6da0: 28 72 65 61 64 2d 63 6f 6e 66 69 67 20 74 65 73  (read-config tes
6db0: 74 2d 63 6f 6e 66 69 67 66 20 23 66 20 23 66 29  t-configf #f #f)
6dc0: 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65  (make-hash-table
6dd0: 29 29 29 29 0a 09 20 28 72 75 6e 73 3a 75 70 64  )))).. (runs:upd
6de0: 61 74 65 2d 74 65 73 74 5f 6d 65 74 61 20 64 62  ate-test_meta db
6df0: 20 74 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 2d   test-name test-
6e00: 63 6f 6e 66 29 29 29 0a 20 20 20 20 20 74 65 73  conf))).     tes
6e10: 74 2d 6e 61 6d 65 73 29 29 29 0a 0a 3b 3b 20 54  t-names)))..;; T
6e20: 68 69 73 20 63 6f 75 6c 64 20 70 72 6f 62 61 62  his could probab
6e30: 6c 79 20 62 65 20 72 65 66 61 63 74 6f 72 65 64  ly be refactored
6e40: 20 69 6e 74 6f 20 6f 6e 65 20 63 6f 6d 70 6c 65   into one comple
6e50: 78 20 71 75 65 72 79 20 2e 2e 2e 0a 28 64 65 66  x query ....(def
6e60: 69 6e 65 20 28 72 75 6e 73 3a 72 6f 6c 6c 75 70  ine (runs:rollup
6e70: 2d 72 75 6e 20 64 62 20 6b 65 79 73 20 6b 65 79  -run db keys key
6e80: 76 61 6c 6c 73 74 20 72 75 6e 6e 61 6d 65 20 75  vallst runname u
6e90: 73 65 72 29 20 3b 3b 20 77 61 73 20 74 61 72 67  ser) ;; was targ
6ea0: 65 74 2c 20 6e 6f 77 20 6b 65 79 76 61 6c 6c 73  et, now keyvalls
6eb0: 74 0a 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74  t.  (debug:print
6ec0: 20 34 20 22 72 75 6e 73 3a 72 6f 6c 6c 75 70 2d   4 "runs:rollup-
6ed0: 72 75 6e 2c 20 6b 65 79 73 3a 20 22 20 6b 65 79  run, keys: " key
6ee0: 73 20 22 20 6b 65 79 76 61 6c 6c 73 74 3a 20 22  s " keyvallst: "
6ef0: 20 6b 65 79 76 61 6c 6c 73 74 20 22 20 3a 72 75   keyvallst " :ru
6f00: 6e 6e 61 6d 65 20 22 20 72 75 6e 6e 61 6d 65 20  nname " runname 
6f10: 22 20 75 73 65 72 3a 20 22 20 75 73 65 72 29 0a  " user: " user).
6f20: 20 20 28 6c 65 74 2a 20 28 3b 20 28 6b 65 79 76    (let* (; (keyv
6f30: 61 6c 6c 6c 73 74 20 20 20 20 20 20 28 6b 65 79  alllst      (key
6f40: 73 3a 74 61 72 67 65 74 2d 3e 6b 65 79 76 61 6c  s:target->keyval
6f50: 20 6b 65 79 73 20 74 61 72 67 65 74 29 29 0a 09   keys target))..
6f60: 20 28 6e 65 77 2d 72 75 6e 2d 69 64 20 20 20 20   (new-run-id    
6f70: 20 20 28 72 75 6e 73 3a 72 65 67 69 73 74 65 72    (runs:register
6f80: 2d 72 75 6e 20 64 62 20 6b 65 79 73 20 6b 65 79  -run db keys key
6f90: 76 61 6c 6c 73 74 20 72 75 6e 6e 61 6d 65 20 22  vallst runname "
6fa0: 6e 65 77 22 20 22 6e 2f 61 22 20 75 73 65 72 29  new" "n/a" user)
6fb0: 29 0a 09 20 28 70 72 65 76 2d 74 65 73 74 73 20  ).. (prev-tests 
6fc0: 20 20 20 20 20 28 74 65 73 74 3a 67 65 74 2d 6d       (test:get-m
6fd0: 61 74 63 68 69 6e 67 2d 70 72 65 76 69 6f 75 73  atching-previous
6fe0: 2d 74 65 73 74 2d 72 75 6e 2d 72 65 63 6f 72 64  -test-run-record
6ff0: 73 20 64 62 20 6e 65 77 2d 72 75 6e 2d 69 64 20  s db new-run-id 
7000: 22 25 22 20 22 25 22 29 29 0a 09 20 28 63 75 72  "%" "%")).. (cur
7010: 72 2d 74 65 73 74 73 20 20 20 20 20 20 28 64 62  r-tests      (db
7020: 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d 72  -get-tests-for-r
7030: 75 6e 20 64 62 20 6e 65 77 2d 72 75 6e 2d 69 64  un db new-run-id
7040: 20 22 25 22 20 22 25 22 20 27 28 29 20 27 28 29   "%" "%" '() '()
7050: 29 29 0a 09 20 28 63 75 72 72 2d 74 65 73 74 73  )).. (curr-tests
7060: 2d 68 61 73 68 20 28 6d 61 6b 65 2d 68 61 73 68  -hash (make-hash
7070: 2d 74 61 62 6c 65 29 29 29 0a 20 20 20 20 28 64  -table))).    (d
7080: 62 3a 75 70 64 61 74 65 2d 72 75 6e 2d 65 76 65  b:update-run-eve
7090: 6e 74 5f 74 69 6d 65 20 64 62 20 6e 65 77 2d 72  nt_time db new-r
70a0: 75 6e 2d 69 64 29 0a 20 20 20 20 3b 3b 20 69 6e  un-id).    ;; in
70b0: 64 65 78 20 74 68 65 20 61 6c 72 65 61 64 79 20  dex the already 
70c0: 73 61 76 65 64 20 74 65 73 74 73 20 62 79 20 74  saved tests by t
70d0: 65 73 74 6e 61 6d 65 20 61 6e 64 20 69 74 65 6d  estname and item
70e0: 64 61 74 20 69 6e 20 63 75 72 72 2d 74 65 73 74  dat in curr-test
70f0: 73 2d 68 61 73 68 0a 20 20 20 20 28 66 6f 72 2d  s-hash.    (for-
7100: 65 61 63 68 0a 20 20 20 20 20 28 6c 61 6d 62 64  each.     (lambd
7110: 61 20 28 74 65 73 74 64 61 74 29 0a 20 20 20 20  a (testdat).    
7120: 20 20 20 28 6c 65 74 2a 20 28 28 74 65 73 74 6e     (let* ((testn
7130: 61 6d 65 20 20 28 64 62 3a 74 65 73 74 2d 67 65  ame  (db:test-ge
7140: 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 64  t-testname testd
7150: 61 74 29 29 0a 09 20 20 20 20 20 20 28 69 74 65  at))..      (ite
7160: 6d 2d 70 61 74 68 20 28 64 62 3a 74 65 73 74 2d  m-path (db:test-
7170: 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74 65  get-item-path te
7180: 73 74 64 61 74 29 29 0a 09 20 20 20 20 20 20 28  stdat))..      (
7190: 66 75 6c 6c 2d 6e 61 6d 65 20 28 63 6f 6e 63 20  full-name (conc 
71a0: 74 65 73 74 6e 61 6d 65 20 22 2f 22 20 69 74 65  testname "/" ite
71b0: 6d 2d 70 61 74 68 29 29 29 0a 09 20 28 68 61 73  m-path))).. (has
71c0: 68 2d 74 61 62 6c 65 2d 73 65 74 21 20 63 75 72  h-table-set! cur
71d0: 72 2d 74 65 73 74 73 2d 68 61 73 68 20 66 75 6c  r-tests-hash ful
71e0: 6c 2d 6e 61 6d 65 20 74 65 73 74 64 61 74 29 29  l-name testdat))
71f0: 29 0a 20 20 20 20 20 63 75 72 72 2d 74 65 73 74  ).     curr-test
7200: 73 29 0a 20 20 20 20 3b 3b 20 4e 4f 50 45 3a 20  s).    ;; NOPE: 
7210: 4e 6f 6e 2d 6f 70 74 69 6d 61 6c 20 61 70 70 72  Non-optimal appr
7220: 6f 61 63 68 2e 20 54 72 79 20 74 68 69 73 20 69  oach. Try this i
7230: 6e 73 74 65 61 64 2e 0a 20 20 20 20 3b 3b 20 20  nstead..    ;;  
7240: 20 31 2e 20 74 65 73 74 73 20 61 72 65 20 72 65   1. tests are re
7250: 63 65 69 76 65 64 20 69 6e 20 61 20 6c 69 73 74  ceived in a list
7260: 2c 20 6d 6f 73 74 20 72 65 63 65 6e 74 20 66 69  , most recent fi
7270: 72 73 74 0a 20 20 20 20 3b 3b 20 20 20 32 2e 20  rst.    ;;   2. 
7280: 72 65 70 6c 61 63 65 20 74 68 65 20 72 6f 6c 6c  replace the roll
7290: 75 70 20 74 65 73 74 20 77 69 74 68 20 74 68 65  up test with the
72a0: 20 6e 65 77 20 2a 61 6c 77 61 79 73 2a 0a 20 20   new *always*.  
72b0: 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 20 20    (for-each .   
72c0: 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74 64    (lambda (testd
72d0: 61 74 29 0a 20 20 20 20 20 20 20 28 6c 65 74 2a  at).       (let*
72e0: 20 28 28 74 65 73 74 6e 61 6d 65 20 20 28 64 62   ((testname  (db
72f0: 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61  :test-get-testna
7300: 6d 65 20 74 65 73 74 64 61 74 29 29 0a 09 20 20  me testdat))..  
7310: 20 20 20 20 28 69 74 65 6d 2d 70 61 74 68 20 28      (item-path (
7320: 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d  db:test-get-item
7330: 2d 70 61 74 68 20 74 65 73 74 64 61 74 29 29 0a  -path testdat)).
7340: 09 20 20 20 20 20 20 28 66 75 6c 6c 2d 6e 61 6d  .      (full-nam
7350: 65 20 28 63 6f 6e 63 20 74 65 73 74 6e 61 6d 65  e (conc testname
7360: 20 22 2f 22 20 69 74 65 6d 2d 70 61 74 68 29 29   "/" item-path))
7370: 0a 09 20 20 20 20 20 20 28 70 72 65 76 2d 74 65  ..      (prev-te
7380: 73 74 2d 64 61 74 20 28 68 61 73 68 2d 74 61 62  st-dat (hash-tab
7390: 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 63  le-ref/default c
73a0: 75 72 72 2d 74 65 73 74 73 2d 68 61 73 68 20 66  urr-tests-hash f
73b0: 75 6c 6c 2d 6e 61 6d 65 20 23 66 29 29 0a 09 20  ull-name #f)).. 
73c0: 20 20 20 20 20 28 74 65 73 74 2d 73 74 65 70 73       (test-steps
73d0: 20 20 20 20 20 20 28 64 62 3a 67 65 74 2d 73 74        (db:get-st
73e0: 65 70 73 2d 66 6f 72 2d 74 65 73 74 20 64 62 20  eps-for-test db 
73f0: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20  (db:test-get-id 
7400: 74 65 73 74 64 61 74 29 29 29 0a 09 20 20 20 20  testdat)))..    
7410: 20 20 28 6e 65 77 2d 74 65 73 74 2d 72 65 63 6f    (new-test-reco
7420: 72 64 20 23 66 29 29 0a 09 20 3b 3b 20 72 65 70  rd #f)).. ;; rep
7430: 6c 61 63 65 20 74 68 65 73 65 20 77 69 74 68 20  lace these with 
7440: 69 6e 73 65 72 74 20 2e 2e 2e 20 73 65 6c 65 63  insert ... selec
7450: 74 0a 09 20 28 61 70 70 6c 79 20 73 71 6c 69 74  t.. (apply sqlit
7460: 65 33 3a 65 78 65 63 75 74 65 20 0a 09 09 64 62  e3:execute ...db
7470: 20 0a 09 09 28 63 6f 6e 63 20 22 49 4e 53 45 52   ...(conc "INSER
7480: 54 20 4f 52 20 52 45 50 4c 41 43 45 20 49 4e 54  T OR REPLACE INT
7490: 4f 20 74 65 73 74 73 20 28 72 75 6e 5f 69 64 2c  O tests (run_id,
74a0: 74 65 73 74 6e 61 6d 65 2c 73 74 61 74 65 2c 73  testname,state,s
74b0: 74 61 74 75 73 2c 65 76 65 6e 74 5f 74 69 6d 65  tatus,event_time
74c0: 2c 68 6f 73 74 2c 63 70 75 6c 6f 61 64 2c 64 69  ,host,cpuload,di
74d0: 73 6b 66 72 65 65 2c 75 6e 61 6d 65 2c 72 75 6e  skfree,uname,run
74e0: 64 69 72 2c 69 74 65 6d 5f 70 61 74 68 2c 72 75  dir,item_path,ru
74f0: 6e 5f 64 75 72 61 74 69 6f 6e 2c 66 69 6e 61 6c  n_duration,final
7500: 5f 6c 6f 67 66 2c 63 6f 6d 6d 65 6e 74 29 20 22  _logf,comment) "
7510: 0a 09 09 20 20 20 20 20 20 22 56 41 4c 55 45 53  ...      "VALUES
7520: 20 28 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c   (?,?,?,?,?,?,?,
7530: 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 29 3b 22  ?,?,?,?,?,?,?);"
7540: 29 0a 09 09 6e 65 77 2d 72 75 6e 2d 69 64 20 28  )...new-run-id (
7550: 63 64 64 72 20 28 76 65 63 74 6f 72 2d 3e 6c 69  cddr (vector->li
7560: 73 74 20 74 65 73 74 64 61 74 29 29 29 0a 09 20  st testdat))).. 
7570: 28 73 65 74 21 20 6e 65 77 2d 74 65 73 74 64 61  (set! new-testda
7580: 74 20 28 63 61 72 20 28 64 62 2d 67 65 74 2d 74  t (car (db-get-t
7590: 65 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20  ests-for-run db 
75a0: 6e 65 77 2d 72 75 6e 2d 69 64 20 74 65 73 74 6e  new-run-id testn
75b0: 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 20 27 28  ame item-path '(
75c0: 29 20 27 28 29 29 29 29 0a 09 20 28 68 61 73 68  ) '()))).. (hash
75d0: 2d 74 61 62 6c 65 2d 73 65 74 21 20 63 75 72 72  -table-set! curr
75e0: 2d 74 65 73 74 73 2d 68 61 73 68 20 66 75 6c 6c  -tests-hash full
75f0: 2d 6e 61 6d 65 20 6e 65 77 2d 74 65 73 74 64 61  -name new-testda
7600: 74 29 20 3b 3b 20 74 68 69 73 20 63 6f 75 6c 64  t) ;; this could
7610: 20 62 65 20 63 6f 6e 66 75 73 69 6e 67 2c 20 77   be confusing, w
7620: 68 69 63 68 20 72 65 63 6f 72 64 20 73 68 6f 75  hich record shou
7630: 6c 64 20 67 6f 20 69 6e 74 6f 20 74 68 65 20 6c  ld go into the l
7640: 6f 6f 6b 75 70 20 74 61 62 6c 65 3f 0a 09 20 3b  ookup table?.. ;
7650: 3b 20 4e 6f 77 20 64 75 70 6c 69 63 61 74 65 20  ; Now duplicate 
7660: 74 68 65 20 74 65 73 74 20 73 74 65 70 73 0a 09  the test steps..
7670: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20   (debug:print 4 
7680: 22 43 6f 70 79 69 6e 67 20 72 65 63 6f 72 64 73  "Copying records
7690: 20 69 6e 20 74 65 73 74 5f 73 74 65 70 73 20 66   in test_steps f
76a0: 72 6f 6d 20 74 65 73 74 5f 69 64 3d 22 20 28 64  rom test_id=" (d
76b0: 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65  b:test-get-id te
76c0: 73 74 64 61 74 29 20 22 20 74 6f 20 22 20 28 64  stdat) " to " (d
76d0: 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 6e 65  b:test-get-id ne
76e0: 77 2d 74 65 73 74 64 61 74 29 29 0a 09 20 28 73  w-testdat)).. (s
76f0: 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 0a  qlite3:execute .
7700: 09 20 20 64 62 20 0a 09 20 20 28 63 6f 6e 63 20  .  db ..  (conc 
7710: 22 49 4e 53 45 52 54 20 4f 52 20 52 45 50 4c 41  "INSERT OR REPLA
7720: 43 45 20 49 4e 54 4f 20 74 65 73 74 5f 73 74 65  CE INTO test_ste
7730: 70 73 20 28 74 65 73 74 5f 69 64 2c 73 74 65 70  ps (test_id,step
7740: 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 61 74 75  name,state,statu
7750: 73 2c 65 76 65 6e 74 5f 74 69 6d 65 2c 63 6f 6d  s,event_time,com
7760: 6d 65 6e 74 29 20 22 0a 09 09 22 53 45 4c 45 43  ment) "..."SELEC
7770: 54 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74  T " (db:test-get
7780: 2d 69 64 20 6e 65 77 2d 74 65 73 74 64 61 74 29  -id new-testdat)
7790: 20 22 2c 73 74 65 70 6e 61 6d 65 2c 73 74 61 74   ",stepname,stat
77a0: 65 2c 73 74 61 74 75 73 2c 65 76 65 6e 74 5f 74  e,status,event_t
77b0: 69 6d 65 2c 63 6f 6d 6d 65 6e 74 20 46 52 4f 4d  ime,comment FROM
77c0: 20 74 65 73 74 5f 73 74 65 70 73 20 57 48 45 52   test_steps WHER
77d0: 45 20 74 65 73 74 5f 69 64 3d 3f 3b 22 29 0a 09  E test_id=?;")..
77e0: 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69    (db:test-get-i
77f0: 64 20 74 65 73 74 64 61 74 29 29 0a 09 20 3b 3b  d testdat)).. ;;
7800: 20 4e 6f 77 20 64 75 70 6c 69 63 61 74 65 20 74   Now duplicate t
7810: 68 65 20 74 65 73 74 20 64 61 74 61 0a 09 20 28  he test data.. (
7820: 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 43  debug:print 4 "C
7830: 6f 70 79 69 6e 67 20 72 65 63 6f 72 64 73 20 69  opying records i
7840: 6e 20 74 65 73 74 5f 64 61 74 61 20 66 72 6f 6d  n test_data from
7850: 20 74 65 73 74 5f 69 64 3d 22 20 28 64 62 3a 74   test_id=" (db:t
7860: 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74 64  est-get-id testd
7870: 61 74 29 20 22 20 74 6f 20 22 20 28 64 62 3a 74  at) " to " (db:t
7880: 65 73 74 2d 67 65 74 2d 69 64 20 6e 65 77 2d 74  est-get-id new-t
7890: 65 73 74 64 61 74 29 29 0a 09 20 28 73 71 6c 69  estdat)).. (sqli
78a0: 74 65 33 3a 65 78 65 63 75 74 65 20 0a 09 20 20  te3:execute ..  
78b0: 64 62 20 0a 09 20 20 28 63 6f 6e 63 20 22 49 4e  db ..  (conc "IN
78c0: 53 45 52 54 20 4f 52 20 52 45 50 4c 41 43 45 20  SERT OR REPLACE 
78d0: 49 4e 54 4f 20 74 65 73 74 5f 64 61 74 61 20 28  INTO test_data (
78e0: 74 65 73 74 5f 69 64 2c 63 61 74 65 67 6f 72 79  test_id,category
78f0: 2c 76 61 72 69 61 62 6c 65 2c 76 61 6c 75 65 2c  ,variable,value,
7900: 65 78 70 65 63 74 65 64 2c 74 6f 6c 2c 75 6e 69  expected,tol,uni
7910: 74 73 2c 63 6f 6d 6d 65 6e 74 29 20 22 0a 09 09  ts,comment) "...
7920: 22 53 45 4c 45 43 54 20 22 20 28 64 62 3a 74 65  "SELECT " (db:te
7930: 73 74 2d 67 65 74 2d 69 64 20 6e 65 77 2d 74 65  st-get-id new-te
7940: 73 74 64 61 74 29 20 22 2c 63 61 74 65 67 6f 72  stdat) ",categor
7950: 79 2c 76 61 72 69 61 62 6c 65 2c 76 61 6c 75 65  y,variable,value
7960: 2c 65 78 70 65 63 74 65 64 2c 74 6f 6c 2c 75 6e  ,expected,tol,un
7970: 69 74 73 2c 63 6f 6d 6d 65 6e 74 20 46 52 4f 4d  its,comment FROM
7980: 20 74 65 73 74 5f 64 61 74 61 20 57 48 45 52 45   test_data WHERE
7990: 20 74 65 73 74 5f 69 64 3d 3f 3b 22 29 0a 09 20   test_id=?;").. 
79a0: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64   (db:test-get-id
79b0: 20 74 65 73 74 64 61 74 29 29 0a 09 20 29 29 0a   testdat)).. )).
79c0: 20 20 20 20 20 70 72 65 76 2d 74 65 73 74 73 29       prev-tests)
79d0: 29 29 0a 09 20 0a 20 20 20 20 20 0a              )).. .     .