Megatest

Hex Artifact Content
Login

Artifact 82d8e33935b0242134cfe6641e950142db451c01:


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: 0a 20 20 20 20 3b 3b 20 4c 65 74 73 20 75 73 65  .    ;; Lets use
0b70: 20 74 68 69 73 20 61 73 20 61 6e 20 6f 70 70 6f   this as an oppo
0b80: 72 74 75 6e 69 74 79 20 74 6f 20 70 75 74 20 4d  rtunity to put M
0b90: 54 5f 52 55 4e 4e 41 4d 45 20 69 6e 20 74 68 65  T_RUNNAME in the
0ba0: 20 65 6e 76 69 72 6f 6e 6d 65 6e 74 0a 20 20 20   environment.   
0bb0: 20 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61   (sqlite3:for-ea
0bc0: 63 68 2d 72 6f 77 0a 20 20 20 20 20 28 6c 61 6d  ch-row.     (lam
0bd0: 62 64 61 20 28 72 75 6e 6e 61 6d 65 29 0a 20 20  bda (runname).  
0be0: 20 20 20 20 20 28 73 65 74 65 6e 76 20 22 4d 54       (setenv "MT
0bf0: 5f 52 55 4e 4e 41 4d 45 22 20 72 75 6e 6e 61 6d  _RUNNAME" runnam
0c00: 65 29 29 0a 20 20 20 20 20 64 62 0a 20 20 20 20  e)).     db.    
0c10: 20 22 53 45 4c 45 43 54 20 72 75 6e 6e 61 6d 65   "SELECT runname
0c20: 20 46 52 4f 4d 20 72 75 6e 73 20 57 48 45 52 45   FROM runs WHERE
0c30: 20 69 64 3d 3f 3b 22 0a 20 20 20 20 20 72 75 6e   id=?;".     run
0c40: 2d 69 64 29 0a 20 20 20 20 29 29 0a 0a 28 64 65  -id).    ))..(de
0c50: 66 69 6e 65 20 28 73 65 74 2d 69 74 65 6d 2d 65  fine (set-item-e
0c60: 6e 76 2d 76 61 72 73 20 69 74 65 6d 64 61 74 29  nv-vars itemdat)
0c70: 0a 20 20 28 66 6f 72 2d 65 61 63 68 20 28 6c 61  .  (for-each (la
0c80: 6d 62 64 61 20 28 69 74 65 6d 29 0a 09 20 20 20  mbda (item)..   
0c90: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
0ca0: 32 20 22 73 65 74 65 6e 76 20 22 20 28 63 61 72  2 "setenv " (car
0cb0: 20 69 74 65 6d 29 20 22 20 22 20 28 63 61 64 72   item) " " (cadr
0cc0: 20 69 74 65 6d 29 29 0a 09 20 20 20 20 20 20 28   item))..      (
0cd0: 73 65 74 65 6e 76 20 28 63 61 72 20 69 74 65 6d  setenv (car item
0ce0: 29 20 28 63 61 64 72 20 69 74 65 6d 29 29 29 0a  ) (cadr item))).
0cf0: 09 20 20 20 20 69 74 65 6d 64 61 74 29 29 0a 0a  .    itemdat))..
0d00: 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 63 61  (define (runs:ca
0d10: 6e 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73  n-run-more-tests
0d20: 20 64 62 20 74 65 73 74 2d 72 65 63 6f 72 64 29   db test-record)
0d30: 0a 20 20 28 6c 65 74 2a 20 28 28 74 63 6f 6e 66  .  (let* ((tconf
0d40: 69 67 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ig              
0d50: 20 20 20 28 74 65 73 74 73 3a 74 65 73 74 71 75     (tests:testqu
0d60: 65 75 65 2d 67 65 74 2d 74 65 73 74 63 6f 6e 66  eue-get-testconf
0d70: 69 67 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29  ig test-record))
0d80: 0a 09 20 28 6a 6f 62 67 72 6f 75 70 20 20 20 20  .. (jobgroup    
0d90: 20 20 20 20 20 20 20 20 20 20 20 20 28 63 6f 6e              (con
0da0: 66 69 67 2d 6c 6f 6f 6b 75 70 20 74 63 6f 6e 66  fig-lookup tconf
0db0: 69 67 20 22 72 65 71 75 69 72 65 6d 65 6e 74 73  ig "requirements
0dc0: 22 20 22 6a 6f 62 67 72 6f 75 70 22 29 29 0a 09  " "jobgroup"))..
0dd0: 20 28 6e 75 6d 2d 72 75 6e 6e 69 6e 67 20 20 20   (num-running   
0de0: 20 20 20 20 20 20 20 20 20 20 28 64 62 3a 67 65            (db:ge
0df0: 74 2d 63 6f 75 6e 74 2d 74 65 73 74 73 2d 72 75  t-count-tests-ru
0e00: 6e 6e 69 6e 67 20 64 62 29 29 0a 09 20 28 6e 75  nning db)).. (nu
0e10: 6d 2d 72 75 6e 6e 69 6e 67 2d 69 6e 2d 6a 6f 62  m-running-in-job
0e20: 67 72 6f 75 70 20 28 64 62 3a 67 65 74 2d 63 6f  group (db:get-co
0e30: 75 6e 74 2d 74 65 73 74 73 2d 72 75 6e 6e 69 6e  unt-tests-runnin
0e40: 67 2d 69 6e 2d 6a 6f 62 67 72 6f 75 70 20 64 62  g-in-jobgroup db
0e50: 20 6a 6f 62 67 72 6f 75 70 29 29 0a 09 20 28 6d   jobgroup)).. (m
0e60: 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f  ax-concurrent-jo
0e70: 62 73 20 20 20 20 20 28 63 6f 6e 66 69 67 2d 6c  bs     (config-l
0e80: 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67 64 61 74  ookup *configdat
0e90: 2a 20 22 73 65 74 75 70 22 20 20 20 20 20 22 6d  * "setup"     "m
0ea0: 61 78 5f 63 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f  ax_concurrent_jo
0eb0: 62 73 22 29 29 0a 09 20 28 6a 6f 62 2d 67 72 6f  bs")).. (job-gro
0ec0: 75 70 2d 6c 69 6d 69 74 20 20 20 20 20 20 20 20  up-limit        
0ed0: 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20   (config-lookup 
0ee0: 2a 63 6f 6e 66 69 67 64 61 74 2a 20 22 6a 6f 62  *configdat* "job
0ef0: 67 72 6f 75 70 73 22 20 6a 6f 62 67 72 6f 75 70  groups" jobgroup
0f00: 29 29 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70  ))).    (debug:p
0f10: 72 69 6e 74 20 32 20 22 6d 61 78 2d 63 6f 6e 63  rint 2 "max-conc
0f20: 75 72 72 65 6e 74 2d 6a 6f 62 73 3a 20 22 20 6d  urrent-jobs: " m
0f30: 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f  ax-concurrent-jo
0f40: 62 73 20 22 2c 20 6e 75 6d 2d 72 75 6e 6e 69 6e  bs ", num-runnin
0f50: 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67  g: " num-running
0f60: 29 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28  ).    (if (not (
0f70: 65 71 3f 20 30 20 2a 67 6c 6f 62 61 6c 65 78 69  eq? 0 *globalexi
0f80: 74 73 74 61 74 75 73 2a 29 29 0a 09 23 66 0a 09  tstatus*))..#f..
0f90: 28 6c 65 74 20 28 28 63 61 6e 2d 6e 6f 74 2d 72  (let ((can-not-r
0fa0: 75 6e 2d 6d 6f 72 65 20 28 63 6f 6e 64 0a 09 09  un-more (cond...
0fb0: 09 09 20 3b 3b 20 69 66 20 6d 61 78 2d 63 6f 6e  .. ;; if max-con
0fc0: 63 75 72 72 65 6e 74 2d 6a 6f 62 73 20 69 73 20  current-jobs is 
0fd0: 73 65 74 20 61 6e 64 20 74 68 65 20 6e 75 6d 62  set and the numb
0fe0: 65 72 20 72 75 6e 6e 69 6e 67 20 69 73 20 67 72  er running is gr
0ff0: 65 61 74 65 72 20 0a 09 09 09 09 20 3b 3b 20 74  eater ..... ;; t
1000: 68 61 6e 20 69 74 20 74 68 61 6e 20 63 61 6e 6e  han it than cann
1010: 6f 74 20 72 75 6e 20 6d 6f 72 65 20 6a 6f 62 73  ot run more jobs
1020: 0a 09 09 09 09 20 28 28 61 6e 64 20 6d 61 78 2d  ..... ((and max-
1030: 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 0a  concurrent-jobs.
1040: 09 09 09 09 20 20 20 20 20 20 20 28 73 74 72 69  ....       (stri
1050: 6e 67 2d 3e 6e 75 6d 62 65 72 20 6d 61 78 2d 63  ng->number max-c
1060: 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29 0a  oncurrent-jobs).
1070: 09 09 09 09 20 20 20 20 20 20 20 28 3e 3d 20 6e  ....       (>= n
1080: 75 6d 2d 72 75 6e 6e 69 6e 67 20 28 73 74 72 69  um-running (stri
1090: 6e 67 2d 3e 6e 75 6d 62 65 72 20 6d 61 78 2d 63  ng->number max-c
10a0: 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29 29  oncurrent-jobs))
10b0: 29 0a 09 09 09 09 20 20 28 64 65 62 75 67 3a 70  ).....  (debug:p
10c0: 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e 47 3a  rint 0 "WARNING:
10d0: 20 4d 61 78 20 72 75 6e 6e 69 6e 67 20 6a 6f 62   Max running job
10e0: 73 20 65 78 63 65 65 64 65 64 2c 20 63 75 72 72  s exceeded, curr
10f0: 65 6e 74 20 6e 75 6d 62 65 72 20 72 75 6e 6e 69  ent number runni
1100: 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69 6e  ng: " num-runnin
1110: 67 20 0a 09 09 09 09 09 20 20 20 20 20 20 20 22  g ......       "
1120: 2c 20 6d 61 78 5f 63 6f 6e 63 75 72 72 65 6e 74  , max_concurrent
1130: 5f 6a 6f 62 73 3a 20 22 20 6d 61 78 2d 63 6f 6e  _jobs: " max-con
1140: 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29 0a 09 09  current-jobs)...
1150: 09 09 20 20 23 74 29 0a 09 09 09 09 20 3b 3b 20  ..  #t)..... ;; 
1160: 69 66 20 6a 6f 62 2d 67 72 6f 75 70 2d 6c 69 6d  if job-group-lim
1170: 69 74 20 69 73 20 73 65 74 20 61 6e 64 20 6e 75  it is set and nu
1180: 6d 62 65 72 20 6f 66 20 6a 6f 62 73 20 69 6e 20  mber of jobs in 
1190: 74 68 65 20 67 72 6f 75 70 20 69 73 20 67 72 65  the group is gre
11a0: 61 74 65 72 0a 09 09 09 09 20 3b 3b 20 74 68 61  ater..... ;; tha
11b0: 6e 20 74 68 65 20 6c 69 6d 69 74 20 74 68 65 6e  n the limit then
11c0: 20 63 61 6e 6e 6f 74 20 72 75 6e 20 6d 6f 72 65   cannot run more
11d0: 20 6a 6f 62 73 20 6f 66 20 74 68 69 73 20 6b 69   jobs of this ki
11e0: 6e 64 0a 09 09 09 09 20 28 28 61 6e 64 20 6a 6f  nd..... ((and jo
11f0: 62 2d 67 72 6f 75 70 2d 6c 69 6d 69 74 0a 09 09  b-group-limit...
1200: 09 09 20 20 20 20 20 20 20 28 3e 3d 20 6e 75 6d  ..       (>= num
1210: 2d 72 75 6e 6e 69 6e 67 2d 69 6e 2d 6a 6f 62 67  -running-in-jobg
1220: 72 6f 75 70 20 6a 6f 62 2d 67 72 6f 75 70 2d 6c  roup job-group-l
1230: 69 6d 69 74 29 29 0a 09 09 09 09 20 20 28 64 65  imit)).....  (de
1240: 62 75 67 3a 70 72 69 6e 74 20 31 20 22 57 41 52  bug:print 1 "WAR
1250: 4e 49 4e 47 3a 20 6e 75 6d 62 65 72 20 6f 66 20  NING: number of 
1260: 6a 6f 62 73 20 22 20 6e 75 6d 2d 72 75 6e 6e 69  jobs " num-runni
1270: 6e 67 2d 69 6e 2d 6a 6f 62 67 72 6f 75 70 20 0a  ng-in-jobgroup .
1280: 09 09 09 09 09 20 20 20 20 20 20 20 22 20 69 6e  .....       " in
1290: 20 22 20 6a 6f 62 67 72 6f 75 70 20 22 20 65 78   " jobgroup " ex
12a0: 63 65 65 64 65 64 2c 20 77 69 6c 6c 20 6e 6f 74  ceeded, will not
12b0: 20 72 75 6e 20 22 20 28 74 65 73 74 73 3a 74 65   run " (tests:te
12c0: 73 74 71 75 65 75 65 2d 67 65 74 2d 74 65 73 74  stqueue-get-test
12d0: 6e 61 6d 65 20 74 65 73 74 2d 72 65 63 6f 72 64  name test-record
12e0: 29 29 0a 09 09 09 09 20 20 23 74 29 0a 09 09 09  )).....  #t)....
12f0: 09 20 28 65 6c 73 65 20 23 66 29 29 29 29 0a 09  . (else #f))))..
1300: 20 20 28 6e 6f 74 20 63 61 6e 2d 6e 6f 74 2d 72    (not can-not-r
1310: 75 6e 2d 6d 6f 72 65 29 29 29 29 29 0a 0a 3b 3b  un-more)))))..;;
1320: 3d 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 0a 3b 3b 20 4e 65 77 20 6d 65  ======.;; New me
1370: 74 68 6f 64 6f 6c 6f 67 79 2e 20 54 68 65 73 65  thodology. These
1380: 20 72 6f 75 74 69 6e 65 73 20 77 69 6c 6c 20 72   routines will r
1390: 65 70 6c 61 63 65 20 74 68 65 20 61 62 6f 76 65  eplace the above
13a0: 20 69 6e 20 74 69 6d 65 2e 20 46 6f 72 0a 3b 3b   in time. For.;;
13b0: 20 6e 6f 77 20 74 68 65 20 63 6f 64 65 20 69 73   now the code is
13c0: 20 64 75 70 6c 69 63 61 74 65 64 2e 20 54 68 69   duplicated. Thi
13d0: 73 20 73 74 75 66 66 20 69 73 20 69 6e 69 74 69  s stuff is initi
13e0: 61 6c 6c 79 20 75 73 65 64 20 69 6e 20 74 68 65  ally used in the
13f0: 20 6d 6f 6e 69 74 6f 72 0a 3b 3b 20 62 61 73 65   monitor.;; base
1400: 64 20 63 6f 64 65 2e 0a 3b 3b 3d 3d 3d 3d 3d 3d  d code..;;======
1410: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1420: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1430: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1440: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1450: 0a 0a 3b 3b 20 72 65 67 69 73 74 65 72 20 61 20  ..;; register a 
1460: 74 65 73 74 20 72 75 6e 20 77 69 74 68 20 74 68  test run with th
1470: 65 20 64 62 0a 28 64 65 66 69 6e 65 20 28 72 75  e db.(define (ru
1480: 6e 73 3a 72 65 67 69 73 74 65 72 2d 72 75 6e 20  ns:register-run 
1490: 64 62 20 6b 65 79 73 20 6b 65 79 76 61 6c 6c 73  db keys keyvalls
14a0: 74 20 72 75 6e 6e 61 6d 65 20 73 74 61 74 65 20  t runname state 
14b0: 73 74 61 74 75 73 20 75 73 65 72 29 0a 20 20 28  status user).  (
14c0: 64 65 62 75 67 3a 70 72 69 6e 74 20 33 20 22 72  debug:print 3 "r
14d0: 75 6e 73 3a 72 65 67 69 73 74 65 72 2d 72 75 6e  uns:register-run
14e0: 2c 20 6b 65 79 73 3a 20 22 20 6b 65 79 73 20 22  , keys: " keys "
14f0: 20 6b 65 79 76 61 6c 6c 73 74 3a 20 22 20 6b 65   keyvallst: " ke
1500: 79 76 61 6c 6c 73 74 20 22 20 72 75 6e 6e 61 6d  yvallst " runnam
1510: 65 3a 20 22 20 72 75 6e 6e 61 6d 65 20 22 20 73  e: " runname " s
1520: 74 61 74 65 3a 20 22 20 73 74 61 74 65 20 22 20  tate: " state " 
1530: 73 74 61 74 75 73 3a 20 22 20 73 74 61 74 75 73  status: " status
1540: 20 22 20 75 73 65 72 3a 20 22 20 75 73 65 72 29   " user: " user)
1550: 0a 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 73 74  .  (let* ((keyst
1560: 72 20 20 20 20 28 6b 65 79 73 2d 3e 6b 65 79 73  r    (keys->keys
1570: 74 72 20 6b 65 79 73 29 29 0a 09 20 28 63 6f 6d  tr keys)).. (com
1580: 6d 61 20 20 20 20 20 28 69 66 20 28 3e 20 28 6c  ma     (if (> (l
1590: 65 6e 67 74 68 20 6b 65 79 73 29 20 30 29 20 22  ength keys) 0) "
15a0: 2c 22 20 22 22 29 29 0a 09 20 28 61 6e 64 73 74  ," "")).. (andst
15b0: 72 20 20 20 20 28 69 66 20 28 3e 20 28 6c 65 6e  r    (if (> (len
15c0: 67 74 68 20 6b 65 79 73 29 20 30 29 20 22 20 41  gth keys) 0) " A
15d0: 4e 44 20 22 20 22 22 29 29 0a 09 20 28 76 61 6c  ND " "")).. (val
15e0: 73 6c 6f 74 73 20 20 28 6b 65 79 73 2d 3e 76 61  slots  (keys->va
15f0: 6c 73 6c 6f 74 73 20 6b 65 79 73 29 29 20 3b 3b  lslots keys)) ;;
1600: 20 3f 2c 3f 2c 3f 20 2e 2e 2e 0a 09 20 28 6b 65   ?,?,? ..... (ke
1610: 79 76 61 6c 73 20 20 20 28 6d 61 70 20 63 61 64  yvals   (map cad
1620: 72 20 6b 65 79 76 61 6c 6c 73 74 29 29 0a 09 20  r keyvallst)).. 
1630: 28 61 6c 6c 76 61 6c 73 20 20 20 28 61 70 70 65  (allvals   (appe
1640: 6e 64 20 28 6c 69 73 74 20 72 75 6e 6e 61 6d 65  nd (list runname
1650: 20 73 74 61 74 65 20 73 74 61 74 75 73 20 75 73   state status us
1660: 65 72 29 20 6b 65 79 76 61 6c 73 29 29 0a 09 20  er) keyvals)).. 
1670: 28 71 72 79 76 61 6c 73 20 20 20 28 61 70 70 65  (qryvals   (appe
1680: 6e 64 20 28 6c 69 73 74 20 72 75 6e 6e 61 6d 65  nd (list runname
1690: 29 20 6b 65 79 76 61 6c 73 29 29 0a 09 20 28 6b  ) keyvals)).. (k
16a0: 65 79 3d 3f 73 74 72 20 20 28 73 74 72 69 6e 67  ey=?str  (string
16b0: 2d 69 6e 74 65 72 73 70 65 72 73 65 20 28 6d 61  -intersperse (ma
16c0: 70 20 28 6c 61 6d 62 64 61 20 28 6b 29 28 63 6f  p (lambda (k)(co
16d0: 6e 63 20 28 6b 65 79 3a 67 65 74 2d 66 69 65 6c  nc (key:get-fiel
16e0: 64 6e 61 6d 65 20 6b 29 20 22 3d 3f 22 29 29 20  dname k) "=?")) 
16f0: 6b 65 79 73 29 20 22 20 41 4e 44 20 22 29 29 29  keys) " AND ")))
1700: 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e  .    (debug:prin
1710: 74 20 33 20 22 6b 65 79 73 3a 20 22 20 6b 65 79  t 3 "keys: " key
1720: 73 20 22 20 61 6c 6c 76 61 6c 73 3a 20 22 20 61  s " allvals: " a
1730: 6c 6c 76 61 6c 73 20 22 20 6b 65 79 76 61 6c 73  llvals " keyvals
1740: 3a 20 22 20 6b 65 79 76 61 6c 73 29 0a 20 20 20  : " keyvals).   
1750: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20   (debug:print 2 
1760: 22 4e 4f 54 45 3a 20 75 73 69 6e 67 20 74 61 72  "NOTE: using tar
1770: 67 65 74 20 22 20 28 73 74 72 69 6e 67 2d 69 6e  get " (string-in
1780: 74 65 72 73 70 65 72 73 65 20 6b 65 79 76 61 6c  tersperse keyval
1790: 73 20 22 2f 22 29 20 22 20 66 6f 72 20 74 68 69  s "/") " for thi
17a0: 73 20 72 75 6e 22 29 0a 20 20 20 20 28 69 66 20  s run").    (if 
17b0: 28 61 6e 64 20 72 75 6e 6e 61 6d 65 20 28 6e 75  (and runname (nu
17c0: 6c 6c 3f 20 28 66 69 6c 74 65 72 20 28 6c 61 6d  ll? (filter (lam
17d0: 62 64 61 20 28 78 29 28 6e 6f 74 20 78 29 29 20  bda (x)(not x)) 
17e0: 6b 65 79 76 61 6c 73 29 29 29 20 3b 3b 20 74 68  keyvals))) ;; th
17f0: 65 72 65 20 6d 75 73 74 20 62 65 20 61 20 62 65  ere must be a be
1800: 74 74 65 72 20 77 61 79 20 74 6f 20 22 61 70 70  tter way to "app
1810: 6c 79 20 61 6e 64 22 0a 09 28 6c 65 74 20 28 28  ly and"..(let ((
1820: 72 65 73 20 23 66 29 29 0a 09 20 20 28 61 70 70  res #f))..  (app
1830: 6c 79 20 73 71 6c 69 74 65 33 3a 65 78 65 63 75  ly sqlite3:execu
1840: 74 65 20 64 62 20 28 63 6f 6e 63 20 22 49 4e 53  te db (conc "INS
1850: 45 52 54 20 4f 52 20 49 47 4e 4f 52 45 20 49 4e  ERT OR IGNORE IN
1860: 54 4f 20 72 75 6e 73 20 28 72 75 6e 6e 61 6d 65  TO runs (runname
1870: 2c 73 74 61 74 65 2c 73 74 61 74 75 73 2c 6f 77  ,state,status,ow
1880: 6e 65 72 2c 65 76 65 6e 74 5f 74 69 6d 65 22 20  ner,event_time" 
1890: 63 6f 6d 6d 61 20 6b 65 79 73 74 72 20 22 29 20  comma keystr ") 
18a0: 56 41 4c 55 45 53 20 28 3f 2c 3f 2c 3f 2c 3f 2c  VALUES (?,?,?,?,
18b0: 73 74 72 66 74 69 6d 65 28 27 25 73 27 2c 27 6e  strftime('%s','n
18c0: 6f 77 27 29 22 20 63 6f 6d 6d 61 20 76 61 6c 73  ow')" comma vals
18d0: 6c 6f 74 73 20 22 29 3b 22 29 0a 09 09 20 61 6c  lots ");")... al
18e0: 6c 76 61 6c 73 29 0a 09 20 20 28 61 70 70 6c 79  lvals)..  (apply
18f0: 20 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63   sqlite3:for-eac
1900: 68 2d 72 6f 77 20 0a 09 20 20 20 28 6c 61 6d 62  h-row ..   (lamb
1910: 64 61 20 28 69 64 29 0a 09 20 20 20 20 20 28 73  da (id)..     (s
1920: 65 74 21 20 72 65 73 20 69 64 29 29 0a 09 20 20  et! res id))..  
1930: 20 64 62 0a 09 20 20 20 28 6c 65 74 20 28 28 71   db..   (let ((q
1940: 72 79 20 28 63 6f 6e 63 20 22 53 45 4c 45 43 54  ry (conc "SELECT
1950: 20 69 64 20 46 52 4f 4d 20 72 75 6e 73 20 57 48   id FROM runs WH
1960: 45 52 45 20 28 72 75 6e 6e 61 6d 65 3d 3f 20 22  ERE (runname=? "
1970: 20 61 6e 64 73 74 72 20 6b 65 79 3d 3f 73 74 72   andstr key=?str
1980: 20 22 29 3b 22 29 29 29 0a 09 20 20 20 20 20 3b   ");")))..     ;
1990: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22  (debug:print 4 "
19a0: 71 72 79 3a 20 22 20 71 72 79 29 20 0a 09 20 20  qry: " qry) ..  
19b0: 20 20 20 71 72 79 29 0a 09 20 20 20 71 72 79 76     qry)..   qryv
19c0: 61 6c 73 29 0a 09 20 20 28 73 71 6c 69 74 65 33  als)..  (sqlite3
19d0: 3a 65 78 65 63 75 74 65 20 64 62 20 22 55 50 44  :execute db "UPD
19e0: 41 54 45 20 72 75 6e 73 20 53 45 54 20 73 74 61  ATE runs SET sta
19f0: 74 65 3d 3f 2c 73 74 61 74 75 73 3d 3f 20 57 48  te=?,status=? WH
1a00: 45 52 45 20 69 64 3d 3f 3b 22 20 73 74 61 74 65  ERE id=?;" state
1a10: 20 73 74 61 74 75 73 20 72 65 73 29 0a 09 20 20   status res)..  
1a20: 72 65 73 29 20 0a 09 28 62 65 67 69 6e 0a 09 20  res) ..(begin.. 
1a30: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
1a40: 22 45 52 52 4f 52 3a 20 43 61 6c 6c 65 64 20 77  "ERROR: Called w
1a50: 69 74 68 6f 75 74 20 61 6c 6c 20 6e 65 63 65 73  ithout all neces
1a60: 73 61 72 79 20 6b 65 79 73 22 29 0a 09 20 20 23  sary keys")..  #
1a70: 66 29 29 29 29 0a 0a 3b 3b 20 54 68 69 73 20 69  f))))..;; This i
1a80: 73 20 61 20 64 75 70 6c 69 63 61 74 65 20 6f 66  s a duplicate of
1a90: 20 72 75 6e 2d 74 65 73 74 73 20 28 77 68 69 63   run-tests (whic
1aa0: 68 20 68 61 73 20 62 65 65 6e 20 64 65 70 72 65  h has been depre
1ab0: 63 61 74 65 64 29 2e 20 55 73 65 20 74 68 69 73  cated). Use this
1ac0: 20 6f 6e 65 20 69 6e 73 74 65 61 64 20 6f 66 20   one instead of 
1ad0: 72 75 6e 20 74 65 73 74 73 2e 0a 3b 3b 20 6b 65  run tests..;; ke
1ae0: 79 76 61 6c 73 0a 28 64 65 66 69 6e 65 20 28 72  yvals.(define (r
1af0: 75 6e 73 3a 72 75 6e 2d 74 65 73 74 73 20 64 62  uns:run-tests db
1b00: 20 74 61 72 67 65 74 20 72 75 6e 6e 61 6d 65 20   target runname 
1b10: 74 65 73 74 2d 70 61 74 74 73 20 69 74 65 6d 2d  test-patts item-
1b20: 70 61 74 74 73 20 75 73 65 72 20 66 6c 61 67 73  patts user flags
1b30: 29 0a 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 73  ).  (let* ((keys
1b40: 20 20 20 20 20 20 20 20 28 64 62 2d 67 65 74 2d          (db-get-
1b50: 6b 65 79 73 20 64 62 29 29 0a 09 20 28 6b 65 79  keys db)).. (key
1b60: 76 61 6c 6c 73 74 20 20 20 28 6b 65 79 73 3a 74  vallst   (keys:t
1b70: 61 72 67 65 74 2d 3e 6b 65 79 76 61 6c 20 6b 65  arget->keyval ke
1b80: 79 73 20 74 61 72 67 65 74 29 29 0a 09 20 28 72  ys target)).. (r
1b90: 75 6e 2d 69 64 20 20 20 20 20 20 28 72 75 6e 73  un-id      (runs
1ba0: 3a 72 65 67 69 73 74 65 72 2d 72 75 6e 20 64 62  :register-run db
1bb0: 20 6b 65 79 73 20 6b 65 79 76 61 6c 6c 73 74 20   keys keyvallst 
1bc0: 72 75 6e 6e 61 6d 65 20 22 6e 65 77 22 20 22 6e  runname "new" "n
1bd0: 2f 61 22 20 75 73 65 72 29 29 20 20 3b 3b 20 20  /a" user))  ;;  
1be0: 74 65 73 74 2d 6e 61 6d 65 29 29 29 0a 09 20 28  test-name))).. (
1bf0: 64 65 66 65 72 72 65 64 20 20 20 20 27 28 29 29  deferred    '())
1c00: 20 3b 3b 20 64 65 6c 61 79 20 72 75 6e 6e 69 6e   ;; delay runnin
1c10: 67 20 74 68 65 73 65 20 73 69 6e 63 65 20 74 68  g these since th
1c20: 65 79 20 68 61 76 65 20 61 20 77 61 69 74 6f 6e  ey have a waiton
1c30: 20 63 6c 61 75 73 65 0a 09 20 3b 3b 20 6b 65 65   clause.. ;; kee
1c40: 70 67 6f 69 6e 67 20 69 73 20 74 68 65 20 64 65  pgoing is the de
1c50: 66 61 63 74 6f 20 6d 6f 64 61 6c 69 74 79 20 6e  facto modality n
1c60: 6f 77 2c 20 77 69 6c 6c 20 61 64 64 20 68 69 74  ow, will add hit
1c70: 2d 6e 2d 72 75 6e 20 61 20 62 69 74 20 6c 61 74  -n-run a bit lat
1c80: 65 72 0a 09 20 3b 3b 20 28 6b 65 65 70 67 6f 69  er.. ;; (keepgoi
1c90: 6e 67 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65  ng   (hash-table
1ca0: 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 66 6c 61  -ref/default fla
1cb0: 67 73 20 22 2d 6b 65 65 70 67 6f 69 6e 67 22 20  gs "-keepgoing" 
1cc0: 23 66 29 29 0a 09 20 28 74 65 73 74 2d 6e 61 6d  #f)).. (test-nam
1cd0: 65 73 20 20 27 28 29 29 0a 09 20 28 72 75 6e 63  es  '()).. (runc
1ce0: 6f 6e 66 69 67 66 20 20 20 28 63 6f 6e 63 20 20  onfigf   (conc  
1cf0: 2a 74 6f 70 70 61 74 68 2a 20 22 2f 72 75 6e 63  *toppath* "/runc
1d00: 6f 6e 66 69 67 73 2e 63 6f 6e 66 69 67 22 29 29  onfigs.config"))
1d10: 0a 09 20 28 72 65 71 75 69 72 65 64 2d 74 65 73  .. (required-tes
1d20: 74 73 20 27 28 29 29 0a 09 20 28 74 65 73 74 2d  ts '()).. (test-
1d30: 72 65 63 6f 72 64 73 20 28 6d 61 6b 65 2d 68 61  records (make-ha
1d40: 73 68 2d 74 61 62 6c 65 29 29 29 0a 0a 20 20 20  sh-table)))..   
1d50: 20 28 73 65 74 2d 6d 65 67 61 74 65 73 74 2d 65   (set-megatest-e
1d60: 6e 76 2d 76 61 72 73 20 64 62 20 72 75 6e 2d 69  nv-vars db run-i
1d70: 64 29 20 3b 3b 20 74 68 65 73 65 20 6d 61 79 20  d) ;; these may 
1d80: 62 65 20 6e 65 65 64 65 64 20 62 79 20 74 68 65  be needed by the
1d90: 20 6c 61 75 6e 63 68 69 6e 67 20 70 72 6f 63 65   launching proce
1da0: 73 73 0a 0a 20 20 20 20 28 69 66 20 28 66 69 6c  ss..    (if (fil
1db0: 65 2d 65 78 69 73 74 73 3f 20 72 75 6e 63 6f 6e  e-exists? runcon
1dc0: 66 69 67 66 29 0a 09 28 73 65 74 75 70 2d 65 6e  figf)..(setup-en
1dd0: 76 2d 64 65 66 61 75 6c 74 73 20 64 62 20 72 75  v-defaults db ru
1de0: 6e 63 6f 6e 66 69 67 66 20 72 75 6e 2d 69 64 20  nconfigf run-id 
1df0: 2a 61 6c 72 65 61 64 79 2d 73 65 65 6e 2d 72 75  *already-seen-ru
1e00: 6e 63 6f 6e 66 69 67 2d 69 6e 66 6f 2a 20 22 70  nconfig-info* "p
1e10: 72 65 2d 6c 61 75 6e 63 68 2d 65 6e 76 2d 76 61  re-launch-env-va
1e20: 72 73 22 29 0a 09 28 64 65 62 75 67 3a 70 72 69  rs")..(debug:pri
1e30: 6e 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 59  nt 0 "WARNING: Y
1e40: 6f 75 20 64 6f 20 6e 6f 74 20 68 61 76 65 20 61  ou do not have a
1e50: 20 72 75 6e 20 63 6f 6e 66 69 67 20 66 69 6c 65   run config file
1e60: 3a 20 22 20 72 75 6e 63 6f 6e 66 69 67 66 29 29  : " runconfigf))
1e70: 0a 20 20 20 20 0a 20 20 20 20 3b 3b 20 6c 6f 6f  .    .    ;; loo
1e80: 6b 20 75 70 20 61 6c 6c 20 74 65 73 74 73 20 6d  k up all tests m
1e90: 61 74 63 68 69 6e 67 20 74 68 65 20 63 6f 6d 6d  atching the comm
1ea0: 61 20 73 65 70 61 72 61 74 65 64 20 6c 69 73 74  a separated list
1eb0: 20 6f 66 20 67 6c 6f 62 73 20 69 6e 0a 20 20 20   of globs in.   
1ec0: 20 3b 3b 20 74 65 73 74 2d 70 61 74 74 73 20 28   ;; test-patts (
1ed0: 75 73 69 6e 67 20 25 20 61 73 20 77 69 6c 64 63  using % as wildc
1ee0: 61 72 64 29 0a 20 20 20 20 28 66 6f 72 2d 65 61  ard).    (for-ea
1ef0: 63 68 20 0a 20 20 20 20 20 28 6c 61 6d 62 64 61  ch .     (lambda
1f00: 20 28 70 61 74 74 29 0a 20 20 20 20 20 20 20 28   (patt).       (
1f10: 6c 65 74 20 28 28 74 65 73 74 73 20 28 67 6c 6f  let ((tests (glo
1f20: 62 20 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74 68  b (conc *toppath
1f30: 2a 20 22 2f 74 65 73 74 73 2f 22 20 28 73 74 72  * "/tests/" (str
1f40: 69 6e 67 2d 74 72 61 6e 73 6c 61 74 65 20 70 61  ing-translate pa
1f50: 74 74 20 22 25 22 20 22 2a 22 29 29 29 29 29 0a  tt "%" "*"))))).
1f60: 09 20 28 73 65 74 21 20 74 65 73 74 73 20 28 66  . (set! tests (f
1f70: 69 6c 74 65 72 20 28 6c 61 6d 62 64 61 20 28 74  ilter (lambda (t
1f80: 65 73 74 29 28 66 69 6c 65 2d 65 78 69 73 74 73  est)(file-exists
1f90: 3f 20 28 63 6f 6e 63 20 74 65 73 74 20 22 2f 74  ? (conc test "/t
1fa0: 65 73 74 63 6f 6e 66 69 67 22 29 29 29 20 74 65  estconfig"))) te
1fb0: 73 74 73 29 29 0a 09 20 28 73 65 74 21 20 74 65  sts)).. (set! te
1fc0: 73 74 2d 6e 61 6d 65 73 20 28 61 70 70 65 6e 64  st-names (append
1fd0: 20 74 65 73 74 2d 6e 61 6d 65 73 20 0a 09 09 09   test-names ....
1fe0: 09 20 20 28 6d 61 70 20 28 6c 61 6d 62 64 61 20  .  (map (lambda 
1ff0: 28 74 65 73 74 70 29 0a 09 09 09 09 09 20 28 6c  (testp)...... (l
2000: 61 73 74 20 28 73 74 72 69 6e 67 2d 73 70 6c 69  ast (string-spli
2010: 74 20 74 65 73 74 70 20 22 2f 22 29 29 29 0a 09  t testp "/")))..
2020: 09 09 09 20 20 20 20 20 20 20 74 65 73 74 73 29  ...       tests)
2030: 29 29 29 29 0a 20 20 20 20 20 28 69 66 20 74 65  )))).     (if te
2040: 73 74 2d 70 61 74 74 73 20 28 73 74 72 69 6e 67  st-patts (string
2050: 2d 73 70 6c 69 74 20 74 65 73 74 2d 70 61 74 74  -split test-patt
2060: 73 20 22 2c 22 29 28 6c 69 73 74 20 22 25 22 29  s ",")(list "%")
2070: 29 29 0a 0a 20 20 20 20 20 3b 3b 20 6e 6f 77 20  ))..     ;; now 
2080: 72 65 6d 6f 76 65 20 64 75 70 6c 69 63 61 74 65  remove duplicate
2090: 73 0a 20 20 20 20 28 73 65 74 21 20 74 65 73 74  s.    (set! test
20a0: 2d 6e 61 6d 65 73 20 28 64 65 6c 65 74 65 2d 64  -names (delete-d
20b0: 75 70 6c 69 63 61 74 65 73 20 74 65 73 74 2d 6e  uplicates test-n
20c0: 61 6d 65 73 29 29 0a 0a 20 20 20 20 28 64 65 62  ames))..    (deb
20d0: 75 67 3a 70 72 69 6e 74 20 30 20 22 49 4e 46 4f  ug:print 0 "INFO
20e0: 3a 20 74 65 73 74 20 6e 61 6d 65 73 20 22 20 74  : test names " t
20f0: 65 73 74 2d 6e 61 6d 65 73 29 0a 0a 20 20 20 20  est-names)..    
2100: 3b 3b 20 6f 6e 20 74 68 65 20 66 69 72 73 74 20  ;; on the first 
2110: 70 61 73 73 20 6f 72 20 63 61 6c 6c 20 74 6f 20  pass or call to 
2120: 72 75 6e 2d 74 65 73 74 73 20 73 65 74 20 46 41  run-tests set FA
2130: 49 4c 53 20 74 6f 20 4e 4f 54 5f 53 54 41 52 54  ILS to NOT_START
2140: 45 44 20 69 66 0a 20 20 20 20 3b 3b 20 2d 6b 65  ED if.    ;; -ke
2150: 65 70 67 6f 69 6e 67 20 69 73 20 73 70 65 63 69  epgoing is speci
2160: 66 69 65 64 0a 20 20 20 20 28 69 66 20 28 65 71  fied.    (if (eq
2170: 3f 20 2a 70 61 73 73 6e 75 6d 2a 20 30 29 0a 09  ? *passnum* 0)..
2180: 28 62 65 67 69 6e 0a 09 20 20 3b 3b 20 68 61 76  (begin..  ;; hav
2190: 65 20 74 6f 20 64 65 6c 65 74 65 20 74 65 73 74  e to delete test
21a0: 20 72 65 63 6f 72 64 73 20 77 68 65 72 65 20 4e   records where N
21b0: 4f 54 5f 53 54 41 52 54 45 44 20 73 69 6e 63 65  OT_STARTED since
21c0: 20 74 68 65 79 20 63 61 6e 20 63 61 75 73 65 20   they can cause 
21d0: 2d 6b 65 65 70 67 6f 69 6e 67 20 74 6f 20 0a 09  -keepgoing to ..
21e0: 20 20 3b 3b 20 67 65 74 20 73 74 75 63 6b 20 64    ;; get stuck d
21f0: 75 65 20 74 6f 20 62 65 63 6f 6d 69 6e 67 20 69  ue to becoming i
2200: 6e 61 63 63 65 73 73 69 62 6c 65 20 66 72 6f 6d  naccessible from
2210: 20 61 20 66 61 69 6c 65 64 20 74 65 73 74 2e 20   a failed test. 
2220: 49 2e 65 2e 20 69 66 20 74 65 73 74 20 42 20 64  I.e. if test B d
2230: 65 70 65 6e 64 73 20 0a 09 20 20 3b 3b 20 6f 6e  epends ..  ;; on
2240: 20 74 65 73 74 20 41 20 62 75 74 20 74 65 73 74   test A but test
2250: 20 42 20 72 65 61 63 68 65 64 20 74 68 65 20 70   B reached the p
2260: 6f 69 6e 74 20 6f 6e 20 62 65 69 6e 67 20 72 65  oint on being re
2270: 67 69 73 74 65 72 65 64 20 61 73 20 4e 4f 54 5f  gistered as NOT_
2280: 53 54 41 52 54 45 44 20 61 6e 64 20 74 65 73 74  STARTED and test
2290: 0a 09 20 20 3b 3b 20 41 20 66 61 69 6c 65 64 20  ..  ;; A failed 
22a0: 66 6f 72 20 73 6f 6d 65 20 72 65 61 73 6f 6e 20  for some reason 
22b0: 74 68 65 6e 20 6f 6e 20 72 65 2d 72 75 6e 20 75  then on re-run u
22c0: 73 69 6e 67 20 2d 6b 65 65 70 67 6f 69 6e 67 20  sing -keepgoing 
22d0: 74 68 65 20 72 75 6e 20 63 61 6e 20 6e 65 76 65  the run can neve
22e0: 72 20 63 6f 6d 70 6c 65 74 65 2e 0a 09 20 20 28  r complete...  (
22f0: 64 62 3a 64 65 6c 65 74 65 2d 74 65 73 74 73 2d  db:delete-tests-
2300: 69 6e 2d 73 74 61 74 65 20 64 62 20 72 75 6e 2d  in-state db run-
2310: 69 64 20 22 4e 4f 54 5f 53 54 41 52 54 45 44 22  id "NOT_STARTED"
2320: 29 0a 09 20 20 28 64 62 3a 73 65 74 2d 74 65 73  )..  (db:set-tes
2330: 74 73 2d 73 74 61 74 65 2d 73 74 61 74 75 73 20  ts-state-status 
2340: 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e  db run-id test-n
2350: 61 6d 65 73 20 23 66 20 22 46 41 49 4c 22 20 22  ames #f "FAIL" "
2360: 4e 4f 54 5f 53 54 41 52 54 45 44 22 20 22 46 41  NOT_STARTED" "FA
2370: 49 4c 22 29 29 29 0a 0a 20 20 20 20 3b 3b 20 6e  IL")))..    ;; n
2380: 6f 77 20 61 64 64 20 6e 6f 6e 2d 64 69 72 65 63  ow add non-direc
2390: 74 6c 79 20 72 65 66 65 72 65 6e 63 65 64 20 64  tly referenced d
23a0: 65 70 65 6e 64 65 6e 63 69 65 73 20 28 69 2e 65  ependencies (i.e
23b0: 2e 20 77 61 69 74 6f 6e 29 0a 20 20 20 20 28 69  . waiton).    (i
23c0: 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 65  f (not (null? te
23d0: 73 74 2d 6e 61 6d 65 73 29 29 0a 09 28 6c 65 74  st-names))..(let
23e0: 20 6c 6f 6f 70 20 28 28 68 65 64 20 28 63 61 72   loop ((hed (car
23f0: 20 74 65 73 74 2d 6e 61 6d 65 73 29 29 0a 09 09   test-names))...
2400: 20 20 20 28 74 61 6c 20 28 63 64 72 20 74 65 73     (tal (cdr tes
2410: 74 2d 6e 61 6d 65 73 29 29 29 20 20 20 20 20 20  t-names)))      
2420: 20 20 20 3b 3b 20 27 72 65 74 75 72 6e 2d 70 72     ;; 'return-pr
2430: 6f 63 73 20 74 65 6c 6c 73 20 74 68 65 20 63 6f  ocs tells the co
2440: 6e 66 69 67 20 72 65 61 64 65 72 20 74 6f 20 70  nfig reader to p
2450: 72 65 70 20 72 75 6e 6e 69 6e 67 20 73 79 73 74  rep running syst
2460: 65 6d 20 62 75 74 20 72 65 74 75 72 6e 20 61 20  em but return a 
2470: 70 72 6f 63 0a 09 20 20 28 6c 65 74 2a 20 28 28  proc..  (let* ((
2480: 63 6f 6e 66 69 67 20 20 28 74 65 73 74 3a 67 65  config  (test:ge
2490: 74 2d 74 65 73 74 63 6f 6e 66 69 67 20 68 65 64  t-testconfig hed
24a0: 20 27 72 65 74 75 72 6e 2d 70 72 6f 63 73 29 29   'return-procs))
24b0: 0a 09 09 20 28 77 61 69 74 6f 6e 73 20 28 73 74  ... (waitons (st
24c0: 72 69 6e 67 2d 73 70 6c 69 74 20 28 6c 65 74 20  ring-split (let 
24d0: 28 28 77 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b  ((w (config-look
24e0: 75 70 20 63 6f 6e 66 69 67 20 22 72 65 71 75 69  up config "requi
24f0: 72 65 6d 65 6e 74 73 22 20 22 77 61 69 74 6f 6e  rements" "waiton
2500: 22 29 29 29 0a 09 09 09 09 09 20 20 28 69 66 20  ")))......  (if 
2510: 77 20 77 20 22 22 29 29 29 29 29 0a 09 20 20 20  w w "")))))..   
2520: 20 3b 3b 20 28 69 74 65 6d 73 20 20 20 28 69 74   ;; (items   (it
2530: 65 6d 73 3a 67 65 74 2d 69 74 65 6d 73 2d 66 72  ems:get-items-fr
2540: 6f 6d 2d 63 6f 6e 66 69 67 20 63 6f 6e 66 69 67  om-config config
2550: 29 29 29 0a 09 20 20 20 20 28 69 66 20 28 6e 6f  )))..    (if (no
2560: 74 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65  t (hash-table-re
2570: 66 2f 64 65 66 61 75 6c 74 20 74 65 73 74 2d 72  f/default test-r
2580: 65 63 6f 72 64 73 20 68 65 64 20 23 66 29 29 0a  ecords hed #f)).
2590: 09 09 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65  ..(hash-table-se
25a0: 74 21 20 74 65 73 74 2d 72 65 63 6f 72 64 73 0a  t! test-records.
25b0: 09 09 09 09 20 68 65 64 20 28 76 65 63 74 6f 72  .... hed (vector
25c0: 20 68 65 64 20 20 20 20 20 3b 3b 20 30 0a 09 09   hed     ;; 0...
25d0: 09 09 09 20 20 20 20 20 63 6f 6e 66 69 67 20 20  ...     config  
25e0: 3b 3b 20 31 0a 09 09 09 09 09 20 20 20 20 20 77  ;; 1......     w
25f0: 61 69 74 6f 6e 73 20 3b 3b 20 32 0a 09 09 09 09  aitons ;; 2.....
2600: 09 20 20 20 20 20 28 63 6f 6e 66 69 67 2d 6c 6f  .     (config-lo
2610: 6f 6b 75 70 20 63 6f 6e 66 69 67 20 22 72 65 71  okup config "req
2620: 75 69 72 65 6d 65 6e 74 73 22 20 22 70 72 69 6f  uirements" "prio
2630: 72 69 74 79 22 29 20 20 20 20 20 3b 3b 20 70 72  rity")     ;; pr
2640: 69 6f 72 69 74 79 20 33 0a 09 09 09 09 09 20 20  iority 3......  
2650: 20 20 20 28 6c 65 74 20 28 28 69 74 65 6d 73 20     (let ((items 
2660: 20 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65       (hash-table
2670: 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 63 6f 6e  -ref/default con
2680: 66 69 67 20 22 69 74 65 6d 73 22 20 23 66 29 29  fig "items" #f))
2690: 20 3b 3b 20 69 74 65 6d 73 20 34 0a 09 09 09 09   ;; items 4.....
26a0: 09 09 20 20 20 28 69 74 65 6d 73 74 61 62 6c 65  ..   (itemstable
26b0: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
26c0: 2f 64 65 66 61 75 6c 74 20 63 6f 6e 66 69 67 20  /default config 
26d0: 22 69 74 65 6d 73 74 61 62 6c 65 22 20 23 66 29  "itemstable" #f)
26e0: 29 29 20 0a 09 09 09 09 09 20 20 20 20 20 20 20  )) ......       
26f0: 3b 3b 20 69 66 20 65 69 74 68 65 72 20 69 74 65  ;; if either ite
2700: 6d 73 20 6f 72 20 69 74 65 6d 73 20 74 61 62 6c  ms or items tabl
2710: 65 20 69 73 20 61 20 70 72 6f 63 20 72 65 74 75  e is a proc retu
2720: 72 6e 20 69 74 20 73 6f 20 74 65 73 74 20 72 75  rn it so test ru
2730: 6e 6e 69 6e 67 0a 09 09 09 09 09 20 20 20 20 20  nning......     
2740: 20 20 3b 3b 20 70 72 6f 63 65 73 73 20 63 61 6e    ;; process can
2750: 20 6b 6e 6f 77 20 74 6f 20 63 61 6c 6c 20 69 74   know to call it
2760: 65 6d 73 3a 67 65 74 2d 69 74 65 6d 73 2d 66 72  ems:get-items-fr
2770: 6f 6d 2d 63 6f 6e 66 69 67 0a 09 09 09 09 09 20  om-config...... 
2780: 20 20 20 20 20 20 3b 3b 20 69 66 20 65 69 74 68        ;; if eith
2790: 65 72 20 69 73 20 61 20 6c 69 73 74 20 61 6e 64  er is a list and
27a0: 20 6e 6f 6e 65 20 69 73 20 61 20 70 72 6f 63 20   none is a proc 
27b0: 67 6f 20 61 68 65 61 64 20 61 6e 64 20 63 61 6c  go ahead and cal
27c0: 6c 20 67 65 74 2d 69 74 65 6d 73 0a 09 09 09 09  l get-items.....
27d0: 09 20 20 20 20 20 20 20 3b 3b 20 6f 74 68 65 72  .       ;; other
27e0: 77 69 73 65 20 72 65 74 75 72 6e 20 23 66 20 2d  wise return #f -
27f0: 20 74 68 69 73 20 69 73 20 6e 6f 74 20 61 6e 20   this is not an 
2800: 69 74 65 72 61 74 65 64 20 74 65 73 74 0a 09 09  iterated test...
2810: 09 09 09 20 20 20 20 20 20 20 28 63 6f 6e 64 0a  ...       (cond.
2820: 09 09 09 09 09 09 28 28 70 72 6f 63 65 64 75 72  ......((procedur
2830: 65 3f 20 69 74 65 6d 73 29 20 20 20 20 20 20 69  e? items)      i
2840: 74 65 6d 73 29 20 20 20 20 20 20 20 20 20 20 20  tems)           
2850: 20 3b 3b 20 63 61 6c 63 20 6c 61 74 65 72 0a 09   ;; calc later..
2860: 09 09 09 09 09 28 28 70 72 6f 63 65 64 75 72 65  .....((procedure
2870: 3f 20 69 74 65 6d 73 74 61 62 6c 65 29 20 69 74  ? itemstable) it
2880: 65 6d 73 74 61 62 6c 65 29 20 20 20 20 20 20 20  emstable)       
2890: 3b 3b 20 63 61 6c 63 20 6c 61 74 65 72 0a 09 09  ;; calc later...
28a0: 09 09 09 09 28 28 6f 72 20 28 6c 69 73 74 3f 20  ....((or (list? 
28b0: 69 74 65 6d 73 29 28 6c 69 73 74 3f 20 69 74 65  items)(list? ite
28c0: 6d 73 74 61 62 6c 65 29 29 20 3b 3b 20 63 61 6c  mstable)) ;; cal
28d0: 63 20 6e 6f 77 0a 09 09 09 09 09 09 20 28 69 74  c now....... (it
28e0: 65 6d 73 3a 67 65 74 2d 69 74 65 6d 73 2d 66 72  ems:get-items-fr
28f0: 6f 6d 2d 63 6f 6e 66 69 67 20 63 6f 6e 66 69 67  om-config config
2900: 29 29 0a 09 09 09 09 09 09 28 65 6c 73 65 20 23  )).......(else #
2910: 66 29 29 29 20 20 20 20 20 20 20 20 20 20 20 20  f)))            
2920: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b                 ;
2930: 3b 20 6e 6f 74 20 69 74 65 72 61 74 65 64 0a 09  ; not iterated..
2940: 09 09 09 09 20 20 20 20 20 23 66 20 20 20 20 20  ....     #f     
2950: 20 3b 3b 20 69 74 65 6d 73 64 61 74 20 35 0a 09   ;; itemsdat 5..
2960: 09 09 09 09 20 20 20 20 20 3b 3b 20 23 66 20 20  ....     ;; #f  
2970: 20 20 20 20 3b 3b 20 73 70 61 72 65 0a 09 09 09      ;; spare....
2980: 09 09 20 20 20 20 20 29 29 29 0a 09 20 20 20 20  ..     )))..    
2990: 28 66 6f 72 2d 65 61 63 68 20 0a 09 20 20 20 20  (for-each ..    
29a0: 20 28 6c 61 6d 62 64 61 20 28 77 61 69 74 6f 6e   (lambda (waiton
29b0: 29 0a 09 20 20 20 20 20 20 20 28 69 66 20 28 61  )..       (if (a
29c0: 6e 64 20 77 61 69 74 6f 6e 20 28 6e 6f 74 20 28  nd waiton (not (
29d0: 6d 65 6d 62 65 72 20 77 61 69 74 6f 6e 20 74 65  member waiton te
29e0: 73 74 2d 6e 61 6d 65 73 29 29 29 0a 09 09 20 20  st-names)))...  
29f0: 20 28 62 65 67 69 6e 0a 09 09 20 20 20 20 20 28   (begin...     (
2a00: 73 65 74 21 20 72 65 71 75 69 72 65 64 2d 74 65  set! required-te
2a10: 73 74 73 20 28 63 6f 6e 73 20 77 61 69 74 6f 6e  sts (cons waiton
2a20: 20 72 65 71 75 69 72 65 64 2d 74 65 73 74 73 29   required-tests)
2a30: 29 0a 09 09 20 20 20 20 20 28 73 65 74 21 20 74  )...     (set! t
2a40: 65 73 74 2d 6e 61 6d 65 73 20 28 61 70 70 65 6e  est-names (appen
2a50: 64 20 74 65 73 74 2d 6e 61 6d 65 73 20 28 6c 69  d test-names (li
2a60: 73 74 20 77 61 69 74 6f 6e 29 29 29 29 29 29 0a  st waiton)))))).
2a70: 09 20 20 20 20 20 77 61 69 74 6f 6e 73 29 0a 09  .     waitons)..
2a80: 20 20 20 20 28 6c 65 74 20 28 28 72 65 6d 74 65      (let ((remte
2a90: 73 74 73 20 28 64 65 6c 65 74 65 2d 64 75 70 6c  sts (delete-dupl
2aa0: 69 63 61 74 65 73 20 28 61 70 70 65 6e 64 20 77  icates (append w
2ab0: 61 69 74 6f 6e 73 20 74 61 6c 29 29 29 29 0a 09  aitons tal))))..
2ac0: 20 20 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28        (if (not (
2ad0: 6e 75 6c 6c 3f 20 72 65 6d 74 65 73 74 73 29 29  null? remtests))
2ae0: 0a 09 09 20 20 28 6c 6f 6f 70 20 28 63 61 72 20  ...  (loop (car 
2af0: 72 65 6d 74 65 73 74 73 29 28 63 64 72 20 72 65  remtests)(cdr re
2b00: 6d 74 65 73 74 73 29 29 29 29 29 29 29 0a 0a 20  mtests))))))).. 
2b10: 20 20 20 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c     (if (not (nul
2b20: 6c 3f 20 72 65 71 75 69 72 65 64 2d 74 65 73 74  l? required-test
2b30: 73 29 29 0a 09 28 64 65 62 75 67 3a 70 72 69 6e  s))..(debug:prin
2b40: 74 20 31 20 22 49 4e 46 4f 3a 20 41 64 64 69 6e  t 1 "INFO: Addin
2b50: 67 20 22 20 72 65 71 75 69 72 65 64 2d 74 65 73  g " required-tes
2b60: 74 73 20 22 20 74 6f 20 74 68 65 20 72 75 6e 20  ts " to the run 
2b70: 71 75 65 75 65 22 29 29 0a 20 20 20 20 3b 3b 20  queue")).    ;; 
2b80: 4e 4f 54 45 3a 20 74 68 65 73 65 20 61 72 65 20  NOTE: these are 
2b90: 61 6c 6c 20 70 61 72 65 6e 74 20 74 65 73 74 73  all parent tests
2ba0: 2c 20 69 74 65 6d 73 20 61 72 65 20 6e 6f 74 20  , items are not 
2bb0: 65 78 70 61 6e 64 65 64 20 79 65 74 2e 0a 20 20  expanded yet..  
2bc0: 20 20 28 72 75 6e 73 3a 72 75 6e 2d 74 65 73 74    (runs:run-test
2bd0: 73 2d 71 75 65 75 65 20 64 62 20 72 75 6e 2d 69  s-queue db run-i
2be0: 64 20 72 75 6e 6e 61 6d 65 20 74 65 73 74 2d 72  d runname test-r
2bf0: 65 63 6f 72 64 73 20 6b 65 79 76 61 6c 6c 73 74  ecords keyvallst
2c00: 20 66 6c 61 67 73 29 29 29 0a 0a 28 64 65 66 69   flags)))..(defi
2c10: 6e 65 20 28 72 75 6e 73 3a 72 75 6e 2d 74 65 73  ne (runs:run-tes
2c20: 74 73 2d 71 75 65 75 65 20 64 62 20 72 75 6e 2d  ts-queue db run-
2c30: 69 64 20 72 75 6e 6e 61 6d 65 20 74 65 73 74 2d  id runname test-
2c40: 72 65 63 6f 72 64 73 20 6b 65 79 76 61 6c 6c 73  records keyvalls
2c50: 74 20 66 6c 61 67 73 29 0a 20 20 20 20 3b 3b 20  t flags).    ;; 
2c60: 41 74 20 74 68 69 73 20 70 6f 69 6e 74 20 74 68  At this point th
2c70: 65 20 6c 69 73 74 20 6f 66 20 70 61 72 65 6e 74  e list of parent
2c80: 20 74 65 73 74 73 20 69 73 20 65 78 70 61 6e 64   tests is expand
2c90: 65 64 20 0a 20 20 20 20 3b 3b 20 4e 42 2f 2f 20  ed .    ;; NB// 
2ca0: 53 68 6f 75 6c 64 20 65 78 70 61 6e 64 20 69 74  Should expand it
2cb0: 65 6d 73 20 68 65 72 65 20 61 6e 64 20 74 68 65  ems here and the
2cc0: 6e 20 69 6e 73 65 72 74 20 69 6e 74 6f 20 74 68  n insert into th
2cd0: 65 20 72 75 6e 20 71 75 65 75 65 2e 0a 20 20 28  e run queue..  (
2ce0: 64 65 62 75 67 3a 70 72 69 6e 74 20 35 20 22 74  debug:print 5 "t
2cf0: 65 73 74 2d 72 65 63 6f 72 64 73 3a 20 22 20 74  est-records: " t
2d00: 65 73 74 2d 72 65 63 6f 72 64 73 20 22 2c 20 6b  est-records ", k
2d10: 65 79 76 61 6c 6c 73 74 3a 20 22 20 6b 65 79 76  eyvallst: " keyv
2d20: 61 6c 6c 73 74 29 0a 20 20 28 6c 65 74 20 28 28  allst).  (let ((
2d30: 73 6f 72 74 65 64 2d 74 65 73 74 2d 6e 61 6d 65  sorted-test-name
2d40: 73 20 28 74 65 73 74 73 3a 73 6f 72 74 2d 62 79  s (tests:sort-by
2d50: 2d 70 72 69 6f 72 69 74 79 2d 61 6e 64 2d 77 61  -priority-and-wa
2d60: 69 74 6f 6e 20 74 65 73 74 2d 72 65 63 6f 72 64  iton test-record
2d70: 73 29 29 0a 09 28 69 74 65 6d 2d 70 61 74 74 73  s))..(item-patts
2d80: 20 20 20 20 20 20 20 20 28 68 61 73 68 2d 74 61          (hash-ta
2d90: 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20  ble-ref/default 
2da0: 66 6c 61 67 73 20 22 2d 69 74 65 6d 70 61 74 74  flags "-itempatt
2db0: 22 20 23 66 29 29 29 0a 20 20 20 20 28 6c 65 74  " #f))).    (let
2dc0: 20 6c 6f 6f 70 20 28 3b 20 28 6e 75 6d 74 69 6d   loop (; (numtim
2dd0: 65 73 20 30 29 20 3b 3b 20 73 68 6f 75 6c 64 6e  es 0) ;; shouldn
2de0: 27 74 20 6e 65 65 64 20 74 68 69 73 0a 09 20 20  't need this..  
2df0: 20 20 20 20 20 28 68 65 64 20 20 20 20 20 20 20       (hed       
2e00: 20 20 28 63 61 72 20 73 6f 72 74 65 64 2d 74 65    (car sorted-te
2e10: 73 74 2d 6e 61 6d 65 73 29 29 0a 09 20 20 20 20  st-names))..    
2e20: 20 20 20 28 74 61 6c 20 20 20 20 20 20 20 20 20     (tal         
2e30: 28 63 64 72 20 73 6f 72 74 65 64 2d 74 65 73 74  (cdr sorted-test
2e40: 2d 6e 61 6d 65 73 29 29 29 0a 20 20 20 20 20 20  -names))).      
2e50: 28 6c 65 74 2a 20 28 28 74 65 73 74 2d 72 65 63  (let* ((test-rec
2e60: 6f 72 64 20 28 68 61 73 68 2d 74 61 62 6c 65 2d  ord (hash-table-
2e70: 72 65 66 20 74 65 73 74 2d 72 65 63 6f 72 64 73  ref test-records
2e80: 20 68 65 64 29 29 0a 09 20 20 20 20 20 28 74 63   hed))..     (tc
2e90: 6f 6e 66 69 67 20 20 20 20 20 28 74 65 73 74 73  onfig     (tests
2ea0: 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d 74  :testqueue-get-t
2eb0: 65 73 74 63 6f 6e 66 69 67 20 74 65 73 74 2d 72  estconfig test-r
2ec0: 65 63 6f 72 64 29 29 0a 09 20 20 20 20 20 28 77  ecord))..     (w
2ed0: 61 69 74 6f 6e 73 20 20 20 20 20 28 74 65 73 74  aitons     (test
2ee0: 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d  s:testqueue-get-
2ef0: 77 61 69 74 6f 6e 73 20 20 20 20 74 65 73 74 2d  waitons    test-
2f00: 72 65 63 6f 72 64 29 29 0a 09 20 20 20 20 20 28  record))..     (
2f10: 70 72 69 6f 72 69 74 79 20 20 20 20 28 74 65 73  priority    (tes
2f20: 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74  ts:testqueue-get
2f30: 2d 70 72 69 6f 72 69 74 79 20 20 20 74 65 73 74  -priority   test
2f40: 2d 72 65 63 6f 72 64 29 29 0a 09 20 20 20 20 20  -record))..     
2f50: 28 69 74 65 6d 64 61 74 20 20 20 20 20 28 74 65  (itemdat     (te
2f60: 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65  sts:testqueue-ge
2f70: 74 2d 69 74 65 6d 64 61 74 20 20 20 20 74 65 73  t-itemdat    tes
2f80: 74 2d 72 65 63 6f 72 64 29 29 0a 09 20 20 20 20  t-record))..    
2f90: 20 28 69 74 65 6d 73 20 20 20 20 20 20 20 28 74   (items       (t
2fa0: 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67  ests:testqueue-g
2fb0: 65 74 2d 69 74 65 6d 73 20 20 20 20 20 20 74 65  et-items      te
2fc0: 73 74 2d 72 65 63 6f 72 64 29 29 0a 09 20 20 20  st-record))..   
2fd0: 20 20 28 69 74 65 6d 2d 70 61 74 68 20 20 20 28    (item-path   (
2fe0: 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20  item-list->path 
2ff0: 69 74 65 6d 64 61 74 29 29 29 0a 09 28 64 65 62  itemdat)))..(deb
3000: 75 67 3a 70 72 69 6e 74 20 36 0a 09 09 20 20 20  ug:print 6...   
3010: 20 20 22 69 74 65 6d 64 61 74 3a 20 20 20 20 20    "itemdat:     
3020: 22 20 69 74 65 6d 64 61 74 0a 09 09 20 20 20 20  " itemdat...    
3030: 20 22 5c 6e 20 20 69 74 65 6d 73 3a 20 20 20 20   "\n  items:    
3040: 20 22 20 69 74 65 6d 73 0a 09 09 20 20 20 20 20   " items...     
3050: 22 5c 6e 20 20 69 74 65 6d 2d 70 61 74 68 3a 20  "\n  item-path: 
3060: 22 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 28 63  " item-path)..(c
3070: 6f 6e 64 0a 09 20 28 28 6e 6f 74 20 69 74 65 6d  ond.. ((not item
3080: 73 29 20 3b 3b 20 77 68 65 6e 20 66 61 6c 73 65  s) ;; when false
3090: 20 74 68 65 20 74 65 73 74 20 69 73 20 6f 6b 20   the test is ok 
30a0: 74 6f 20 62 65 20 68 61 6e 64 65 64 20 6f 66 66  to be handed off
30b0: 20 74 6f 20 6c 61 75 6e 63 68 20 28 62 75 74 20   to launch (but 
30c0: 6e 6f 74 20 62 65 66 6f 72 65 29 0a 09 20 20 28  not before)..  (
30d0: 6c 65 74 20 28 28 68 61 76 65 2d 72 65 73 6f 75  let ((have-resou
30e0: 72 63 65 73 20 20 28 72 75 6e 73 3a 63 61 6e 2d  rces  (runs:can-
30f0: 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64  run-more-tests d
3100: 62 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29 20  b test-record)) 
3110: 3b 3b 20 6c 6f 6f 6b 20 61 74 20 74 68 65 20 74  ;; look at the t
3120: 65 73 74 20 6a 6f 62 67 72 6f 75 70 20 61 6e 64  est jobgroup and
3130: 20 74 6f 74 20 6a 6f 62 73 20 72 75 6e 6e 69 6e   tot jobs runnin
3140: 67 0a 09 09 28 70 72 65 72 65 71 73 2d 6e 6f 74  g...(prereqs-not
3150: 2d 6d 65 74 20 28 64 62 3a 67 65 74 2d 70 72 65  -met (db:get-pre
3160: 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 20 64 62 20  reqs-not-met db 
3170: 72 75 6e 2d 69 64 20 77 61 69 74 6f 6e 73 20 69  run-id waitons i
3180: 74 65 6d 2d 70 61 74 68 29 29 29 0a 09 20 20 20  tem-path)))..   
3190: 20 3b 3b 20 44 6f 6e 27 74 20 6b 6e 6f 77 20 61   ;; Don't know a
31a0: 74 20 74 68 69 73 20 74 69 6d 65 20 69 66 20 74  t this time if t
31b0: 68 65 20 74 65 73 74 20 68 61 76 65 20 62 65 65  he test have bee
31c0: 6e 20 6c 61 75 6e 63 68 65 64 20 61 74 20 73 6f  n launched at so
31d0: 6d 65 20 74 69 6d 65 20 69 6e 20 74 68 65 20 70  me time in the p
31e0: 61 73 74 0a 09 20 20 20 20 3b 3b 20 69 2e 65 2e  ast..    ;; i.e.
31f0: 20 69 73 20 74 68 69 73 20 61 20 72 65 2d 6c 61   is this a re-la
3200: 75 6e 63 68 3f 0a 09 20 20 20 20 28 69 66 20 28  unch?..    (if (
3210: 61 6e 64 20 68 61 76 65 2d 72 65 73 6f 75 72 63  and have-resourc
3220: 65 73 0a 09 09 20 20 20 20 20 28 6e 75 6c 6c 3f  es...     (null?
3230: 20 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74   prereqs-not-met
3240: 29 29 0a 09 09 3b 3b 20 6e 6f 20 6c 6f 6f 70 20  ))...;; no loop 
3250: 2d 20 64 72 6f 70 20 74 68 6f 75 67 68 20 61 6e  - drop though an
3260: 64 20 75 73 65 20 74 68 65 20 6c 6f 6f 70 20 61  d use the loop a
3270: 74 20 74 68 65 20 62 6f 74 74 6f 6d 20 0a 09 09  t the bottom ...
3280: 28 72 75 6e 3a 74 65 73 74 20 64 62 20 72 75 6e  (run:test db run
3290: 2d 69 64 20 72 75 6e 6e 61 6d 65 20 6b 65 79 76  -id runname keyv
32a0: 61 6c 6c 73 74 20 74 65 73 74 2d 72 65 63 6f 72  allst test-recor
32b0: 64 20 66 6c 61 67 73 20 23 66 29 0a 09 09 3b 3b  d flags #f)...;;
32c0: 20 65 6c 73 65 20 74 68 65 20 72 75 6e 20 69 73   else the run is
32d0: 20 73 74 75 63 6b 2c 20 74 65 6d 70 6f 72 61 72   stuck, temporar
32e0: 69 6c 79 20 6f 72 20 70 65 72 6d 61 6e 65 6e 74  ily or permanent
32f0: 6c 79 0a 09 09 28 6c 65 74 20 28 28 6e 65 77 74  ly...(let ((newt
3300: 61 6c 20 28 61 70 70 65 6e 64 20 74 61 6c 20 28  al (append tal (
3310: 6c 69 73 74 20 68 65 64 29 29 29 29 0a 09 09 20  list hed))))... 
3320: 20 3b 3b 20 63 6f 75 6c 64 6e 27 74 20 72 75 6e   ;; couldn't run
3330: 2c 20 74 61 6b 65 20 61 20 62 72 65 61 74 68 65  , take a breathe
3340: 72 0a 09 09 20 20 28 74 68 72 65 61 64 2d 73 6c  r...  (thread-sl
3350: 65 65 70 21 20 31 29 0a 09 09 20 20 28 6c 6f 6f  eep! 1)...  (loo
3360: 70 20 28 63 61 72 20 6e 65 77 74 61 6c 29 28 63  p (car newtal)(c
3370: 64 72 20 6e 65 77 74 61 6c 29 29 29 29 29 29 0a  dr newtal)))))).
3380: 09 20 0a 09 20 3b 3b 20 63 61 73 65 20 77 68 65  . .. ;; case whe
3390: 72 65 20 61 6e 20 69 74 65 6d 73 20 63 61 6d 65  re an items came
33a0: 20 69 6e 20 61 73 20 61 20 6c 69 73 74 20 62 65   in as a list be
33b0: 65 6e 20 70 72 6f 63 65 73 73 65 64 0a 09 20 28  en processed.. (
33c0: 28 61 6e 64 20 28 6c 69 73 74 3f 20 69 74 65 6d  (and (list? item
33d0: 73 29 20 20 20 20 20 3b 3b 20 74 68 75 73 20 77  s)     ;; thus w
33e0: 65 20 6b 6e 6f 77 20 6f 75 72 20 69 74 65 6d 73  e know our items
33f0: 20 61 72 65 20 61 6c 72 65 61 64 79 20 63 61 6c   are already cal
3400: 63 75 6c 61 74 65 64 0a 09 20 20 20 20 20 20 20  culated..       
3410: 28 6e 6f 74 20 20 20 69 74 65 6d 64 61 74 29 29  (not   itemdat))
3420: 20 3b 3b 20 61 6e 64 20 6e 6f 74 20 79 65 74 20   ;; and not yet 
3430: 65 78 70 61 6e 64 65 64 20 69 6e 74 6f 20 74 68  expanded into th
3440: 65 20 6c 69 73 74 20 6f 66 20 74 68 69 6e 67 73  e list of things
3450: 20 74 6f 20 62 65 20 64 6f 6e 65 0a 09 20 20 28   to be done..  (
3460: 69 66 20 28 3e 3d 20 2a 76 65 72 62 6f 73 69 74  if (>= *verbosit
3470: 79 2a 20 31 29 28 70 70 20 69 74 65 6d 73 29 29  y* 1)(pp items))
3480: 0a 09 20 20 3b 3b 20 28 69 66 20 28 3e 3d 20 2a  ..  ;; (if (>= *
3490: 76 65 72 62 6f 73 69 74 79 2a 20 35 29 0a 09 20  verbosity* 5).. 
34a0: 20 3b 3b 20 20 20 20 20 28 62 65 67 69 6e 0a 09   ;;     (begin..
34b0: 20 20 3b 3b 20 20 20 20 20 20 20 28 70 72 69 6e    ;;       (prin
34c0: 74 20 22 69 74 65 6d 73 3a 20 22 29 20 20 20 20  t "items: ")    
34d0: 20 28 70 70 20 28 69 74 65 6d 2d 61 73 73 6f 63   (pp (item-assoc
34e0: 2d 3e 69 74 65 6d 2d 6c 69 73 74 20 69 74 65 6d  ->item-list item
34f0: 73 29 29 0a 09 20 20 3b 3b 20 20 20 20 20 20 20  s))..  ;;       
3500: 28 70 72 69 6e 74 20 22 69 74 65 6d 73 74 61 62  (print "itemstab
3510: 6c 65 3a 20 22 29 28 70 70 20 28 69 74 65 6d 2d  le: ")(pp (item-
3520: 74 61 62 6c 65 2d 3e 69 74 65 6d 2d 6c 69 73 74  table->item-list
3530: 20 69 74 65 6d 73 74 61 62 6c 65 29 29 29 29 0a   itemstable)))).
3540: 09 20 20 28 66 6f 72 2d 65 61 63 68 0a 09 20 20  .  (for-each..  
3550: 20 28 6c 61 6d 62 64 61 20 28 6d 79 2d 69 74 65   (lambda (my-ite
3560: 6d 64 61 74 29 0a 09 20 20 20 20 20 28 6c 65 74  mdat)..     (let
3570: 2a 20 28 28 6e 65 77 2d 74 65 73 74 2d 72 65 63  * ((new-test-rec
3580: 6f 72 64 20 28 6c 65 74 20 28 28 6e 65 77 72 65  ord (let ((newre
3590: 63 20 28 6d 61 6b 65 2d 74 65 73 74 73 3a 74 65  c (make-tests:te
35a0: 73 74 71 75 65 75 65 29 29 29 0a 09 09 09 09 20  stqueue)))..... 
35b0: 20 20 20 20 20 20 28 76 65 63 74 6f 72 2d 63 6f        (vector-co
35c0: 70 79 21 20 74 65 73 74 2d 72 65 63 6f 72 64 20  py! test-record 
35d0: 6e 65 77 72 65 63 29 0a 09 09 09 09 20 20 20 20  newrec).....    
35e0: 20 20 20 6e 65 77 72 65 63 29 29 0a 09 09 20 20     newrec))...  
35f0: 20 20 28 6d 79 2d 69 74 65 6d 2d 70 61 74 68 20    (my-item-path 
3600: 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68  (item-list->path
3610: 20 6d 79 2d 69 74 65 6d 64 61 74 29 29 0a 09 09   my-itemdat))...
3620: 20 20 20 20 28 69 74 65 6d 2d 6d 61 74 63 68 65      (item-matche
3630: 73 20 28 69 66 20 69 74 65 6d 2d 70 61 74 74 73  s (if item-patts
3640: 20 20 20 20 20 20 20 3b 3b 20 68 65 72 65 20 77         ;; here w
3650: 65 20 61 72 65 20 66 69 6c 74 65 72 69 6e 67 20  e are filtering 
3660: 66 6f 72 20 6d 61 74 63 68 65 73 20 77 69 74 68  for matches with
3670: 20 2d 69 74 65 6d 70 61 74 74 0a 09 09 09 09 20   -itempatt..... 
3680: 20 20 20 20 20 28 6c 65 74 20 28 28 72 65 73 20       (let ((res 
3690: 23 66 29 29 09 20 3b 3b 20 6c 6f 6f 6b 20 74 68  #f)). ;; look th
36a0: 72 6f 75 67 68 20 61 6c 6c 20 74 68 65 20 69 74  rough all the it
36b0: 65 6d 2d 70 61 74 74 73 20 69 66 20 64 65 66 69  em-patts if defi
36c0: 6e 65 64 2c 20 66 6f 72 6d 61 74 20 69 73 20 70  ned, format is p
36d0: 61 74 74 31 2c 70 61 74 74 32 2c 70 61 74 74 33  att1,patt2,patt3
36e0: 20 2e 2e 2e 20 77 69 6c 64 63 61 72 64 20 69 73   ... wildcard is
36f0: 20 25 0a 09 09 09 09 09 28 66 6f 72 2d 65 61 63   %......(for-eac
3700: 68 20 0a 09 09 09 09 09 20 28 6c 61 6d 62 64 61  h ...... (lambda
3710: 20 28 70 61 74 74 29 0a 09 09 09 09 09 20 20 20   (patt)......   
3720: 28 69 66 20 28 73 74 72 69 6e 67 2d 73 65 61 72  (if (string-sear
3730: 63 68 20 28 67 6c 6f 62 2d 3e 72 65 67 65 78 70  ch (glob->regexp
3740: 0a 09 09 09 09 09 09 09 20 20 20 20 20 20 20 28  ........       (
3750: 73 74 72 69 6e 67 2d 74 72 61 6e 73 6c 61 74 65  string-translate
3760: 20 70 61 74 74 20 22 25 22 20 22 2a 22 29 29 0a   patt "%" "*")).
3770: 09 09 09 09 09 09 09 20 20 20 20 20 20 69 74 65  .......      ite
3780: 6d 2d 70 61 74 68 29 0a 09 09 09 09 09 20 20 20  m-path)......   
3790: 20 20 20 20 28 73 65 74 21 20 72 65 73 20 23 74      (set! res #t
37a0: 29 29 29 0a 09 09 09 09 09 20 28 73 74 72 69 6e  )))...... (strin
37b0: 67 2d 73 70 6c 69 74 20 69 74 65 6d 2d 70 61 74  g-split item-pat
37c0: 74 73 20 22 2c 22 29 29 0a 09 09 09 09 09 72 65  ts ","))......re
37d0: 73 29 0a 09 09 09 09 20 20 20 20 20 20 23 74 29  s).....      #t)
37e0: 29 29 0a 09 20 20 20 20 20 20 20 28 69 66 20 69  ))..       (if i
37f0: 74 65 6d 2d 6d 61 74 63 68 65 73 20 3b 3b 20 79  tem-matches ;; y
3800: 65 73 2c 20 77 65 20 77 61 6e 74 20 74 6f 20 70  es, we want to p
3810: 72 6f 63 65 73 73 20 74 68 69 73 20 69 74 65 6d  rocess this item
3820: 0a 09 09 20 20 20 28 6c 65 74 20 28 28 6e 65 77  ...   (let ((new
3830: 74 65 73 74 6e 61 6d 65 20 28 63 6f 6e 63 20 68  testname (conc h
3840: 65 64 20 22 2f 22 20 6d 79 2d 69 74 65 6d 2d 70  ed "/" my-item-p
3850: 61 74 68 29 29 29 20 0a 09 09 20 20 20 20 20 28  ath))) ...     (
3860: 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d  tests:testqueue-
3870: 73 65 74 2d 69 74 65 6d 73 21 20 20 20 6e 65 77  set-items!   new
3880: 2d 74 65 73 74 2d 72 65 63 6f 72 64 20 23 66 29  -test-record #f)
3890: 0a 09 09 20 20 20 20 20 28 74 65 73 74 73 3a 74  ...     (tests:t
38a0: 65 73 74 71 75 65 75 65 2d 73 65 74 2d 69 74 65  estqueue-set-ite
38b0: 6d 64 61 74 21 20 6e 65 77 2d 74 65 73 74 2d 72  mdat! new-test-r
38c0: 65 63 6f 72 64 20 6d 79 2d 69 74 65 6d 64 61 74  ecord my-itemdat
38d0: 29 0a 09 09 20 20 20 20 20 28 68 61 73 68 2d 74  )...     (hash-t
38e0: 61 62 6c 65 2d 73 65 74 21 20 74 65 73 74 2d 72  able-set! test-r
38f0: 65 63 6f 72 64 73 20 6e 65 77 74 65 73 74 6e 61  ecords newtestna
3900: 6d 65 20 6e 65 77 2d 74 65 73 74 2d 72 65 63 6f  me new-test-reco
3910: 72 64 29 0a 09 09 20 20 20 20 20 28 73 65 74 21  rd)...     (set!
3920: 20 74 61 6c 20 28 63 6f 6e 73 20 6e 65 77 74 65   tal (cons newte
3930: 73 74 6e 61 6d 65 20 74 61 6c 29 29 29 29 29 29  stname tal))))))
3940: 20 3b 3b 20 73 69 6e 63 65 20 74 68 65 73 65 20   ;; since these 
3950: 61 72 65 20 69 74 65 6d 69 7a 65 64 20 63 72 65  are itemized cre
3960: 61 74 65 20 6e 65 77 20 74 65 73 74 20 6e 61 6d  ate new test nam
3970: 65 73 20 74 65 73 74 6e 61 6d 65 2f 69 74 65 6d  es testname/item
3980: 70 61 74 68 0a 09 20 20 20 69 74 65 6d 73 29 0a  path..   items).
3990: 09 20 20 28 6c 6f 6f 70 20 28 63 61 72 20 74 61  .  (loop (car ta
39a0: 6c 29 28 63 64 72 20 74 61 6c 29 29 29 0a 0a 09  l)(cdr tal)))...
39b0: 20 3b 3b 20 69 66 20 69 74 65 6d 73 20 69 73 20   ;; if items is 
39c0: 61 20 70 72 6f 63 20 74 68 65 6e 20 6e 65 65 64  a proc then need
39d0: 20 74 6f 20 72 75 6e 20 69 74 65 6d 73 3a 67 65   to run items:ge
39e0: 74 2d 69 74 65 6d 73 2d 66 72 6f 6d 2d 63 6f 6e  t-items-from-con
39f0: 66 69 67 2c 20 67 65 74 20 74 68 65 20 6c 69 73  fig, get the lis
3a00: 74 20 61 6e 64 20 6c 6f 6f 70 20 0a 09 20 3b 3b  t and loop .. ;;
3a10: 20 20 20 20 2d 20 62 75 74 20 6f 6e 6c 79 20 64      - but only d
3a20: 6f 20 74 68 61 74 20 69 66 20 72 65 73 6f 75 72  o that if resour
3a30: 63 65 73 20 65 78 69 73 74 20 74 6f 20 6b 69 63  ces exist to kic
3a40: 6b 20 6f 66 66 20 74 68 65 20 6a 6f 62 0a 09 20  k off the job.. 
3a50: 28 28 70 72 6f 63 65 64 75 72 65 3f 20 69 74 65  ((procedure? ite
3a60: 6d 73 29 0a 09 20 20 28 69 66 20 28 72 75 6e 73  ms)..  (if (runs
3a70: 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65  :can-run-more-te
3a80: 73 74 73 20 64 62 20 74 65 73 74 2d 72 65 63 6f  sts db test-reco
3a90: 72 64 29 0a 09 20 20 20 20 20 20 28 6c 65 74 20  rd)..      (let 
3aa0: 28 28 69 74 65 6d 73 2d 6c 69 73 74 20 28 69 74  ((items-list (it
3ab0: 65 6d 73 3a 67 65 74 2d 69 74 65 6d 73 2d 66 72  ems:get-items-fr
3ac0: 6f 6d 2d 63 6f 6e 66 69 67 20 74 63 6f 6e 66 69  om-config tconfi
3ad0: 67 29 29 29 0a 09 09 28 69 66 20 28 6c 69 73 74  g)))...(if (list
3ae0: 3f 20 69 74 65 6d 73 2d 6c 69 73 74 29 0a 09 09  ? items-list)...
3af0: 20 20 20 20 28 62 65 67 69 6e 0a 09 09 20 20 20      (begin...   
3b00: 20 20 20 28 74 65 73 74 73 3a 74 65 73 74 71 75     (tests:testqu
3b10: 65 75 65 2d 73 65 74 2d 69 74 65 6d 73 20 74 65  eue-set-items te
3b20: 73 74 2d 72 65 63 6f 72 64 20 69 74 65 6d 73 2d  st-record items-
3b30: 6c 69 73 74 29 0a 09 09 20 20 20 20 20 20 28 6c  list)...      (l
3b40: 6f 6f 70 20 68 65 64 20 74 61 6c 29 29 0a 09 09  oop hed tal))...
3b50: 20 20 20 20 28 62 65 67 69 6e 0a 09 09 20 20 20      (begin...   
3b60: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
3b70: 30 20 22 45 52 52 4f 52 3a 20 54 68 65 20 70 72  0 "ERROR: The pr
3b80: 6f 63 20 66 72 6f 6d 20 72 65 61 64 69 6e 67 20  oc from reading 
3b90: 74 68 65 20 73 65 74 75 70 20 64 69 64 20 6e 6f  the setup did no
3ba0: 74 20 79 69 65 6c 64 20 61 20 6c 69 73 74 20 2d  t yield a list -
3bb0: 20 70 6c 65 61 73 65 20 72 65 70 6f 72 74 20 74   please report t
3bc0: 68 69 73 22 29 0a 09 09 20 20 20 20 20 20 28 65  his")...      (e
3bd0: 78 69 74 20 31 29 29 29 29 0a 09 20 20 20 20 20  xit 1))))..     
3be0: 20 28 6c 65 74 20 28 28 6e 65 77 74 61 6c 20 28   (let ((newtal (
3bf0: 61 70 70 65 6e 64 20 74 61 6c 20 28 6c 69 73 74  append tal (list
3c00: 20 68 65 64 29 29 29 29 0a 09 09 3b 3b 20 69 66   hed))))...;; if
3c10: 20 63 61 6e 27 74 20 72 75 6e 20 6d 6f 72 65 20   can't run more 
3c20: 74 65 73 74 73 2c 20 6c 65 74 73 20 74 61 6b 65  tests, lets take
3c30: 20 61 20 62 72 65 61 74 68 65 72 0a 09 09 28 74   a breather...(t
3c40: 68 72 65 61 64 2d 73 6c 65 65 70 21 20 31 29 0a  hread-sleep! 1).
3c50: 09 09 28 6c 6f 6f 70 20 28 63 61 72 20 6e 65 77  ..(loop (car new
3c60: 74 61 6c 29 28 63 64 72 20 6e 65 77 74 61 6c 29  tal)(cdr newtal)
3c70: 29 29 29 29 0a 0a 09 20 3b 3b 20 74 68 69 73 20  ))))... ;; this 
3c80: 63 61 73 65 20 73 68 6f 75 6c 64 20 6e 6f 74 20  case should not 
3c90: 68 61 70 70 65 6e 2c 20 61 64 64 65 64 20 74 6f  happen, added to
3ca0: 20 68 65 6c 70 20 63 61 74 63 68 20 61 6e 79 20   help catch any 
3cb0: 62 75 67 73 0a 09 20 28 28 61 6e 64 20 28 6c 69  bugs.. ((and (li
3cc0: 73 74 3f 20 69 74 65 6d 73 29 20 69 74 65 6d 64  st? items) itemd
3cd0: 61 74 29 0a 09 20 20 28 64 65 62 75 67 3a 70 72  at)..  (debug:pr
3ce0: 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 53 68  int 0 "ERROR: Sh
3cf0: 6f 75 6c 64 20 6e 6f 74 20 68 61 76 65 20 61 20  ould not have a 
3d00: 6c 69 73 74 20 6f 66 20 69 74 65 6d 73 20 69 6e  list of items in
3d10: 20 61 20 74 65 73 74 20 61 6e 64 20 74 68 65 20   a test and the 
3d20: 69 74 65 6d 73 70 61 74 68 20 73 65 74 20 2d 20  itemspath set - 
3d30: 70 6c 65 61 73 65 20 72 65 70 6f 72 74 20 74 68  please report th
3d40: 69 73 22 29 0a 09 20 20 28 65 78 69 74 20 31 29  is")..  (exit 1)
3d50: 29 29 0a 09 0a 09 3b 3b 20 77 65 20 67 65 74 20  ))....;; we get 
3d60: 68 65 72 65 20 6f 6e 20 22 64 72 6f 70 20 74 68  here on "drop th
3d70: 72 6f 75 67 68 22 20 2d 20 6c 6f 6f 70 20 66 6f  rough" - loop fo
3d80: 72 20 6e 65 78 74 20 74 65 73 74 20 69 6e 20 71  r next test in q
3d90: 75 65 75 65 0a 09 28 69 66 20 28 6e 75 6c 6c 3f  ueue..(if (null?
3da0: 20 74 61 6c 29 0a 09 20 20 20 20 28 64 65 62 75   tal)..    (debu
3db0: 67 3a 70 72 69 6e 74 20 31 20 22 49 4e 46 4f 3a  g:print 1 "INFO:
3dc0: 20 41 6c 6c 20 74 65 73 74 73 20 6c 61 75 6e 63   All tests launc
3dd0: 68 65 64 22 29 0a 09 20 20 20 20 28 6c 6f 6f 70  hed")..    (loop
3de0: 20 28 63 61 72 20 74 61 6c 29 28 63 64 72 20 74   (car tal)(cdr t
3df0: 61 6c 29 29 29 29 29 29 29 0a 0a 3b 3b 20 70 61  al)))))))..;; pa
3e00: 72 65 6e 74 2d 74 65 73 74 20 69 73 20 74 68 65  rent-test is the
3e10: 72 65 20 61 73 20 61 20 70 6c 61 63 65 68 6f 6c  re as a placehol
3e20: 64 65 72 20 66 6f 72 20 77 68 65 6e 20 70 61 72  der for when par
3e30: 65 6e 74 2d 74 65 73 74 73 20 63 61 6e 20 62 65  ent-tests can be
3e40: 20 72 75 6e 20 61 73 20 61 20 73 65 74 75 70 20   run as a setup 
3e50: 73 74 65 70 0a 28 64 65 66 69 6e 65 20 28 72 75  step.(define (ru
3e60: 6e 3a 74 65 73 74 20 64 62 20 72 75 6e 2d 69 64  n:test db run-id
3e70: 20 72 75 6e 6e 61 6d 65 20 6b 65 79 76 61 6c 6c   runname keyvall
3e80: 73 74 20 74 65 73 74 2d 72 65 63 6f 72 64 20 66  st test-record f
3e90: 6c 61 67 73 20 70 61 72 65 6e 74 2d 74 65 73 74  lags parent-test
3ea0: 29 0a 20 20 3b 3b 20 41 6c 6c 20 74 68 65 73 65  ).  ;; All these
3eb0: 20 76 61 72 73 20 6d 69 67 68 74 20 62 65 20 72   vars might be r
3ec0: 65 66 65 72 65 6e 63 65 64 20 62 79 20 74 68 65  eferenced by the
3ed0: 20 74 65 73 74 63 6f 6e 66 69 67 20 66 69 6c 65   testconfig file
3ee0: 20 72 65 61 64 65 72 0a 20 20 28 6c 65 74 2a 20   reader.  (let* 
3ef0: 28 28 74 65 73 74 2d 6e 61 6d 65 20 20 20 20 28  ((test-name    (
3f00: 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d  tests:testqueue-
3f10: 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 20 20 74  get-testname   t
3f20: 65 73 74 2d 72 65 63 6f 72 64 29 29 0a 09 20 28  est-record)).. (
3f30: 74 65 73 74 2d 77 61 69 74 6f 6e 73 20 28 74 65  test-waitons (te
3f40: 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65  sts:testqueue-ge
3f50: 74 2d 77 61 69 74 6f 6e 73 20 20 20 20 74 65 73  t-waitons    tes
3f60: 74 2d 72 65 63 6f 72 64 29 29 0a 09 20 28 74 65  t-record)).. (te
3f70: 73 74 2d 63 6f 6e 66 20 20 20 20 28 74 65 73 74  st-conf    (test
3f80: 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d  s:testqueue-get-
3f90: 74 65 73 74 63 6f 6e 66 69 67 20 74 65 73 74 2d  testconfig test-
3fa0: 72 65 63 6f 72 64 29 29 0a 09 20 28 69 74 65 6d  record)).. (item
3fb0: 64 61 74 20 20 20 20 20 20 28 74 65 73 74 73 3a  dat      (tests:
3fc0: 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d 69 74  testqueue-get-it
3fd0: 65 6d 64 61 74 20 20 20 20 74 65 73 74 2d 72 65  emdat    test-re
3fe0: 63 6f 72 64 29 29 0a 09 20 28 74 65 73 74 2d 70  cord)).. (test-p
3ff0: 61 74 68 20 20 20 20 28 63 6f 6e 63 20 2a 74 6f  ath    (conc *to
4000: 70 70 61 74 68 2a 20 22 2f 74 65 73 74 73 2f 22  ppath* "/tests/"
4010: 20 74 65 73 74 2d 6e 61 6d 65 29 29 20 3b 3b 20   test-name)) ;; 
4020: 63 6f 75 6c 64 20 75 73 65 20 74 65 73 74 3a 67  could use test:g
4030: 65 74 2d 74 65 73 74 63 6f 6e 66 69 67 20 68 65  et-testconfig he
4040: 72 65 20 2e 2e 2e 0a 09 20 28 66 6f 72 63 65 20  re ..... (force 
4050: 20 20 20 20 20 20 20 28 68 61 73 68 2d 74 61 62         (hash-tab
4060: 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 66  le-ref/default f
4070: 6c 61 67 73 20 22 2d 66 6f 72 63 65 22 20 23 66  lags "-force" #f
4080: 29 29 0a 09 20 28 72 65 72 75 6e 20 20 20 20 20  )).. (rerun     
4090: 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72     (hash-table-r
40a0: 65 66 2f 64 65 66 61 75 6c 74 20 66 6c 61 67 73  ef/default flags
40b0: 20 22 2d 72 65 72 75 6e 22 20 23 66 29 29 0a 09   "-rerun" #f))..
40c0: 20 28 6b 65 65 70 67 6f 69 6e 67 20 20 20 20 28   (keepgoing    (
40d0: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64  hash-table-ref/d
40e0: 65 66 61 75 6c 74 20 66 6c 61 67 73 20 22 2d 6b  efault flags "-k
40f0: 65 65 70 67 6f 69 6e 67 22 20 23 66 29 29 0a 09  eepgoing" #f))..
4100: 20 28 69 74 65 6d 2d 70 61 74 68 20 20 20 20 20   (item-path     
4110: 22 22 29 29 0a 20 20 20 20 28 64 65 62 75 67 3a  "")).    (debug:
4120: 70 72 69 6e 74 20 35 0a 09 09 20 22 74 65 73 74  print 5... "test
4130: 2d 63 6f 6e 66 69 67 3a 20 22 20 28 68 61 73 68  -config: " (hash
4140: 2d 74 61 62 6c 65 2d 3e 61 6c 69 73 74 20 74 65  -table->alist te
4150: 73 74 2d 63 6f 6e 66 29 0a 09 09 20 22 5c 6e 20  st-conf)... "\n 
4160: 20 20 69 74 65 6d 64 61 74 3a 20 22 20 69 74 65    itemdat: " ite
4170: 6d 64 61 74 0a 09 09 20 29 0a 20 20 20 20 3b 3b  mdat... ).    ;;
4180: 20 73 65 74 74 69 6e 67 20 69 74 65 6d 64 61 74   setting itemdat
4190: 20 74 6f 20 61 20 6c 69 73 74 20 69 66 20 69 74   to a list if it
41a0: 20 69 73 20 23 66 0a 20 20 20 20 28 69 66 20 28   is #f.    (if (
41b0: 6e 6f 74 20 69 74 65 6d 64 61 74 29 28 73 65 74  not itemdat)(set
41c0: 21 20 69 74 65 6d 64 61 74 20 27 28 29 29 29 0a  ! itemdat '())).
41d0: 20 20 20 20 28 73 65 74 21 20 69 74 65 6d 2d 70      (set! item-p
41e0: 61 74 68 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e  ath (item-list->
41f0: 70 61 74 68 20 69 74 65 6d 64 61 74 29 29 0a 20  path itemdat)). 
4200: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
4210: 32 20 22 41 74 74 65 6d 70 74 69 6e 67 20 74 6f  2 "Attempting to
4220: 20 6c 61 75 6e 63 68 20 74 65 73 74 20 22 20 74   launch test " t
4230: 65 73 74 2d 6e 61 6d 65 20 22 2f 22 20 69 74 65  est-name "/" ite
4240: 6d 2d 70 61 74 68 29 0a 20 20 20 20 28 73 65 74  m-path).    (set
4250: 65 6e 76 20 22 4d 54 5f 54 45 53 54 5f 4e 41 4d  env "MT_TEST_NAM
4260: 45 22 20 74 65 73 74 2d 6e 61 6d 65 29 20 3b 3b  E" test-name) ;;
4270: 20 0a 20 20 20 20 28 73 65 74 65 6e 76 20 22 4d   .    (setenv "M
4280: 54 5f 52 55 4e 4e 41 4d 45 22 20 20 20 72 75 6e  T_RUNNAME"   run
4290: 6e 61 6d 65 29 0a 20 20 20 20 28 73 65 74 2d 6d  name).    (set-m
42a0: 65 67 61 74 65 73 74 2d 65 6e 76 2d 76 61 72 73  egatest-env-vars
42b0: 20 64 62 20 72 75 6e 2d 69 64 29 20 3b 3b 20 74   db run-id) ;; t
42c0: 68 65 73 65 20 6d 61 79 20 62 65 20 6e 65 65 64  hese may be need
42d0: 65 64 20 62 79 20 74 68 65 20 6c 61 75 6e 63 68  ed by the launch
42e0: 69 6e 67 20 70 72 6f 63 65 73 73 0a 20 20 20 20  ing process.    
42f0: 28 63 68 61 6e 67 65 2d 64 69 72 65 63 74 6f 72  (change-director
4300: 79 20 2a 74 6f 70 70 61 74 68 2a 29 0a 0a 20 20  y *toppath*)..  
4310: 20 20 3b 3b 20 48 65 72 65 20 69 73 20 77 68 65    ;; Here is whe
4320: 72 65 20 74 68 65 20 74 65 73 74 5f 6d 65 74 61  re the test_meta
4330: 20 74 61 62 6c 65 20 69 73 20 62 65 73 74 20 75   table is best u
4340: 70 64 61 74 65 64 0a 20 20 20 20 28 72 75 6e 73  pdated.    (runs
4350: 3a 75 70 64 61 74 65 2d 74 65 73 74 5f 6d 65 74  :update-test_met
4360: 61 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 20 74  a db test-name t
4370: 65 73 74 2d 63 6f 6e 66 29 0a 20 20 20 20 0a 20  est-conf).    . 
4380: 20 20 20 3b 3b 20 28 6c 61 6d 62 64 61 20 28 69     ;; (lambda (i
4390: 74 65 6d 64 61 74 29 20 3b 3b 3b 20 28 28 72 69  temdat) ;;; ((ri
43a0: 70 65 6e 65 73 73 20 22 6f 76 65 72 72 69 70 65  peness "overripe
43b0: 22 29 20 28 74 65 6d 70 65 72 61 74 75 72 65 20  ") (temperature 
43c0: 22 63 6f 6f 6c 22 29 20 28 73 65 61 73 6f 6e 20  "cool") (season 
43d0: 22 73 75 6d 6d 65 72 22 29 29 0a 20 20 20 20 28  "summer")).    (
43e0: 6c 65 74 2a 20 28 28 6e 65 77 2d 74 65 73 74 2d  let* ((new-test-
43f0: 70 61 74 68 20 28 73 74 72 69 6e 67 2d 69 6e 74  path (string-int
4400: 65 72 73 70 65 72 73 65 20 28 63 6f 6e 73 20 74  ersperse (cons t
4410: 65 73 74 2d 70 61 74 68 20 28 6d 61 70 20 63 61  est-path (map ca
4420: 64 72 20 69 74 65 6d 64 61 74 29 29 20 22 2f 22  dr itemdat)) "/"
4430: 29 29 0a 09 20 20 20 28 6e 65 77 2d 74 65 73 74  ))..   (new-test
4440: 2d 6e 61 6d 65 20 28 69 66 20 28 65 71 75 61 6c  -name (if (equal
4450: 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29 20  ? item-path "") 
4460: 74 65 73 74 2d 6e 61 6d 65 20 28 63 6f 6e 63 20  test-name (conc 
4470: 74 65 73 74 2d 6e 61 6d 65 20 22 2f 22 20 69 74  test-name "/" it
4480: 65 6d 2d 70 61 74 68 29 29 29 20 3b 3b 20 6a 75  em-path))) ;; ju
4490: 73 74 20 6e 65 65 64 20 69 74 20 74 6f 20 62 65  st need it to be
44a0: 20 75 6e 69 71 75 65 0a 09 20 20 20 28 74 65 73   unique..   (tes
44b0: 74 64 61 74 20 20 20 20 20 20 20 28 64 62 3a 67  tdat       (db:g
44c0: 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 20  et-test-info db 
44d0: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
44e0: 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 20 20   item-path))).  
44f0: 20 20 20 20 28 69 66 20 28 6e 6f 74 20 74 65 73      (if (not tes
4500: 74 64 61 74 29 0a 09 20 20 28 62 65 67 69 6e 0a  tdat)..  (begin.
4510: 09 20 20 20 20 28 72 65 67 69 73 74 65 72 2d 74  .    (register-t
4520: 65 73 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65  est db run-id te
4530: 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74  st-name item-pat
4540: 68 29 0a 09 20 20 20 20 28 73 65 74 21 20 74 65  h)..    (set! te
4550: 73 74 64 61 74 20 28 64 62 3a 67 65 74 2d 74 65  stdat (db:get-te
4560: 73 74 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69  st-info db run-i
4570: 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d  d test-name item
4580: 2d 70 61 74 68 29 29 29 29 0a 20 20 20 20 20 20  -path)))).      
4590: 28 63 68 61 6e 67 65 2d 64 69 72 65 63 74 6f 72  (change-director
45a0: 79 20 74 65 73 74 2d 70 61 74 68 29 0a 20 20 20  y test-path).   
45b0: 20 20 20 28 63 61 73 65 20 28 69 66 20 66 6f 72     (case (if for
45c0: 63 65 20 3b 3b 20 28 61 72 67 73 3a 67 65 74 2d  ce ;; (args:get-
45d0: 61 72 67 20 22 2d 66 6f 72 63 65 22 29 0a 09 09  arg "-force")...
45e0: 27 4e 4f 54 5f 53 54 41 52 54 45 44 0a 09 09 28  'NOT_STARTED...(
45f0: 69 66 20 74 65 73 74 64 61 74 0a 09 09 20 20 20  if testdat...   
4600: 20 28 73 74 72 69 6e 67 2d 3e 73 79 6d 62 6f 6c   (string->symbol
4610: 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65   (test:get-state
4620: 20 74 65 73 74 64 61 74 29 29 0a 09 09 20 20 20   testdat))...   
4630: 20 27 66 61 69 6c 65 64 2d 74 6f 2d 69 6e 73 65   'failed-to-inse
4640: 72 74 29 29 0a 09 28 28 66 61 69 6c 65 64 2d 74  rt))..((failed-t
4650: 6f 2d 69 6e 73 65 72 74 29 0a 09 20 28 64 65 62  o-insert).. (deb
4660: 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f  ug:print 0 "ERRO
4670: 52 3a 20 46 61 69 6c 65 64 20 74 6f 20 69 6e 73  R: Failed to ins
4680: 65 72 74 20 74 68 65 20 72 65 63 6f 72 64 20 69  ert the record i
4690: 6e 74 6f 20 74 68 65 20 64 62 22 29 29 0a 09 28  nto the db"))..(
46a0: 28 4e 4f 54 5f 53 54 41 52 54 45 44 20 43 4f 4d  (NOT_STARTED COM
46b0: 50 4c 45 54 45 44 29 0a 09 20 28 64 65 62 75 67  PLETED).. (debug
46c0: 3a 70 72 69 6e 74 20 36 20 22 47 6f 74 20 68 65  :print 6 "Got he
46d0: 72 65 2c 20 22 20 28 74 65 73 74 3a 67 65 74 2d  re, " (test:get-
46e0: 73 74 61 74 65 20 74 65 73 74 64 61 74 29 29 0a  state testdat)).
46f0: 09 20 28 6c 65 74 20 28 28 72 75 6e 66 6c 61 67  . (let ((runflag
4700: 20 23 66 29 29 0a 09 20 20 20 28 63 6f 6e 64 0a   #f))..   (cond.
4710: 09 20 20 20 20 3b 3b 20 2d 66 6f 72 63 65 2c 20  .    ;; -force, 
4720: 72 75 6e 20 6e 6f 20 6d 61 74 74 65 72 20 77 68  run no matter wh
4730: 61 74 0a 09 20 20 20 20 28 66 6f 72 63 65 20 28  at..    (force (
4740: 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 74 29  set! runflag #t)
4750: 29 0a 09 20 20 20 20 3b 3b 20 4e 4f 54 5f 53 54  )..    ;; NOT_ST
4760: 41 52 54 45 44 2c 20 72 75 6e 20 6e 6f 20 6d 61  ARTED, run no ma
4770: 74 74 65 72 20 77 68 61 74 0a 09 20 20 20 20 28  tter what..    (
4780: 28 65 71 75 61 6c 3f 20 28 74 65 73 74 3a 67 65  (equal? (test:ge
4790: 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 74 29  t-state testdat)
47a0: 20 22 4e 4f 54 5f 53 54 41 52 54 45 44 22 29 28   "NOT_STARTED")(
47b0: 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 74 29  set! runflag #t)
47c0: 29 0a 09 20 20 20 20 3b 3b 20 6e 6f 74 20 2d 72  )..    ;; not -r
47d0: 65 72 75 6e 20 61 6e 64 20 50 41 53 53 2c 20 57  erun and PASS, W
47e0: 41 52 4e 20 6f 72 20 43 48 45 43 4b 2c 20 64 6f  ARN or CHECK, do
47f0: 20 6e 6f 20 72 75 6e 0a 09 20 20 20 20 28 28 61   no run..    ((a
4800: 6e 64 20 28 6f 72 20 28 6e 6f 74 20 72 65 72 75  nd (or (not reru
4810: 6e 29 0a 09 09 20 20 20 20 20 20 6b 65 65 70 67  n)...      keepg
4820: 6f 69 6e 67 29 0a 09 09 20 20 3b 3b 20 52 65 71  oing)...  ;; Req
4830: 75 69 72 65 20 74 6f 20 66 6f 72 63 65 20 72 65  uire to force re
4840: 2d 72 75 6e 20 66 6f 72 20 43 4f 4d 50 4c 45 54  -run for COMPLET
4850: 45 44 20 6f 72 20 2a 61 6e 79 74 68 69 6e 67 2a  ED or *anything*
4860: 20 2b 20 50 41 53 53 2c 57 41 52 4e 20 6f 72 20   + PASS,WARN or 
4870: 43 48 45 43 4b 0a 09 09 20 20 28 6f 72 20 28 6d  CHECK...  (or (m
4880: 65 6d 62 65 72 20 28 74 65 73 74 3a 67 65 74 2d  ember (test:get-
4890: 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29 20  status testdat) 
48a0: 27 28 22 50 41 53 53 22 20 22 57 41 52 4e 22 20  '("PASS" "WARN" 
48b0: 22 43 48 45 43 4b 22 29 29 0a 09 09 20 20 20 20  "CHECK"))...    
48c0: 20 20 28 6d 65 6d 62 65 72 20 28 74 65 73 74 3a    (member (test:
48d0: 67 65 74 2d 73 74 61 74 65 20 20 74 65 73 74 64  get-state  testd
48e0: 61 74 29 20 27 28 22 43 4f 4d 50 4c 45 54 45 44  at) '("COMPLETED
48f0: 22 29 29 29 29 20 0a 09 20 20 20 20 20 28 73 65  ")))) ..     (se
4900: 74 21 20 72 75 6e 66 6c 61 67 20 23 66 29 29 0a  t! runflag #f)).
4910: 09 20 20 20 20 3b 3b 20 2d 72 65 72 75 6e 20 61  .    ;; -rerun a
4920: 6e 64 20 73 74 61 74 75 73 20 69 73 20 6f 6e 65  nd status is one
4930: 20 6f 66 20 74 68 65 20 73 70 65 63 69 66 65 64   of the specifed
4940: 2c 20 72 75 6e 20 69 74 0a 09 20 20 20 20 28 28  , run it..    ((
4950: 61 6e 64 20 72 65 72 75 6e 0a 09 09 20 20 28 6c  and rerun...  (l
4960: 65 74 20 28 28 72 65 72 75 6e 6c 73 74 20 28 73  et ((rerunlst (s
4970: 74 72 69 6e 67 2d 73 70 6c 69 74 20 72 65 72 75  tring-split reru
4980: 6e 20 22 2c 22 29 29 29 20 3b 3b 20 46 41 49 4c  n ","))) ;; FAIL
4990: 2c 0a 09 09 20 20 20 20 28 6d 65 6d 62 65 72 20  ,...    (member 
49a0: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73  (test:get-status
49b0: 20 74 65 73 74 64 61 74 29 20 72 65 72 75 6e 6c   testdat) rerunl
49c0: 73 74 29 29 29 0a 09 20 20 20 20 20 28 73 65 74  st)))..     (set
49d0: 21 20 72 75 6e 66 6c 61 67 20 23 74 29 29 0a 09  ! runflag #t))..
49e0: 20 20 20 20 3b 3b 20 2d 6b 65 65 70 67 6f 69 6e      ;; -keepgoin
49f0: 67 2c 20 64 6f 20 6e 6f 74 20 72 65 72 75 6e 20  g, do not rerun 
4a00: 46 41 49 4c 0a 09 20 20 20 20 28 28 61 6e 64 20  FAIL..    ((and 
4a10: 6b 65 65 70 67 6f 69 6e 67 0a 09 09 20 20 28 6d  keepgoing...  (m
4a20: 65 6d 62 65 72 20 28 74 65 73 74 3a 67 65 74 2d  ember (test:get-
4a30: 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29 20  status testdat) 
4a40: 27 28 22 46 41 49 4c 22 29 29 29 0a 09 20 20 20  '("FAIL")))..   
4a50: 20 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20    (set! runflag 
4a60: 23 66 29 29 0a 09 20 20 20 20 28 28 61 6e 64 20  #f))..    ((and 
4a70: 28 6e 6f 74 20 72 65 72 75 6e 29 0a 09 09 20 20  (not rerun)...  
4a80: 28 6d 65 6d 62 65 72 20 28 74 65 73 74 3a 67 65  (member (test:ge
4a90: 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61 74  t-status testdat
4aa0: 29 20 27 28 22 46 41 49 4c 22 20 22 6e 2f 61 22  ) '("FAIL" "n/a"
4ab0: 29 29 29 0a 09 20 20 20 20 20 28 73 65 74 21 20  )))..     (set! 
4ac0: 72 75 6e 66 6c 61 67 20 23 74 29 29 0a 09 20 20  runflag #t))..  
4ad0: 20 20 28 65 6c 73 65 20 28 73 65 74 21 20 72 75    (else (set! ru
4ae0: 6e 66 6c 61 67 20 23 66 29 29 29 0a 09 20 20 20  nflag #f)))..   
4af0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 36 20 22  (debug:print 6 "
4b00: 52 55 4e 4e 49 4e 47 20 3d 3e 20 72 75 6e 66 6c  RUNNING => runfl
4b10: 61 67 3a 20 22 20 72 75 6e 66 6c 61 67 20 22 20  ag: " runflag " 
4b20: 53 54 41 54 45 3a 20 22 20 28 74 65 73 74 3a 67  STATE: " (test:g
4b30: 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 74  et-state testdat
4b40: 29 20 22 20 53 54 41 54 55 53 3a 20 22 20 28 74  ) " STATUS: " (t
4b50: 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74  est:get-status t
4b60: 65 73 74 64 61 74 29 29 0a 09 20 20 20 28 69 66  estdat))..   (if
4b70: 20 28 6e 6f 74 20 72 75 6e 66 6c 61 67 29 0a 09   (not runflag)..
4b80: 20 20 20 20 20 20 20 28 69 66 20 28 6e 6f 74 20         (if (not 
4b90: 70 61 72 65 6e 74 2d 74 65 73 74 29 0a 09 09 20  parent-test)... 
4ba0: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31    (debug:print 1
4bb0: 20 22 4e 4f 54 45 3a 20 4e 6f 74 20 73 74 61 72   "NOTE: Not star
4bc0: 74 69 6e 67 20 74 65 73 74 20 22 20 6e 65 77 2d  ting test " new-
4bd0: 74 65 73 74 2d 6e 61 6d 65 20 22 20 61 73 20 69  test-name " as i
4be0: 74 20 69 73 20 73 74 61 74 65 20 5c 22 22 20 28  t is state \"" (
4bf0: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74  test:get-state t
4c00: 65 73 74 64 61 74 29 20 0a 09 09 09 09 22 5c 22  estdat) ....."\"
4c10: 20 61 6e 64 20 73 74 61 74 75 73 20 5c 22 22 20   and status \"" 
4c20: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73  (test:get-status
4c30: 20 74 65 73 74 64 61 74 29 20 22 5c 22 2c 20 75   testdat) "\", u
4c40: 73 65 20 2d 72 65 72 75 6e 20 5c 22 22 20 28 74  se -rerun \"" (t
4c50: 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65  est:get-state te
4c60: 73 74 64 61 74 29 20 22 5c 22 20 6f 72 20 2d 66  stdat) "\" or -f
4c70: 6f 72 63 65 20 74 6f 20 6f 76 65 72 72 69 64 65  orce to override
4c80: 22 29 29 0a 09 20 20 20 20 20 20 20 3b 3b 20 4e  "))..       ;; N
4c90: 4f 54 45 3a 20 4e 6f 20 6c 6f 6e 67 65 72 20 62  OTE: No longer b
4ca0: 65 20 63 68 65 63 6b 69 6e 67 20 70 72 65 72 65  e checking prere
4cb0: 71 75 69 73 69 74 65 73 20 68 65 72 65 21 20 57  quisites here! W
4cc0: 69 6c 6c 20 6e 65 76 65 72 20 67 65 74 20 68 65  ill never get he
4cd0: 72 65 20 75 6e 6c 65 73 73 20 70 72 65 72 65 71  re unless prereq
4ce0: 73 20 61 72 65 0a 09 20 20 20 20 20 20 20 3b 3b  s are..       ;;
4cf0: 20 20 20 20 20 20 20 61 6c 72 65 61 64 79 20 6d         already m
4d00: 65 74 2e 0a 09 20 20 20 20 20 20 20 28 69 66 20  et...       (if 
4d10: 28 6e 6f 74 20 28 6c 61 75 6e 63 68 2d 74 65 73  (not (launch-tes
4d20: 74 20 64 62 20 72 75 6e 2d 69 64 20 72 75 6e 6e  t db run-id runn
4d30: 61 6d 65 20 74 65 73 74 2d 63 6f 6e 66 20 6b 65  ame test-conf ke
4d40: 79 76 61 6c 6c 73 74 20 74 65 73 74 2d 6e 61 6d  yvallst test-nam
4d50: 65 20 74 65 73 74 2d 70 61 74 68 20 69 74 65 6d  e test-path item
4d60: 64 61 74 20 66 6c 61 67 73 29 29 0a 09 09 20 20  dat flags))...  
4d70: 20 28 62 65 67 69 6e 0a 09 09 20 20 20 20 20 28   (begin...     (
4d80: 70 72 69 6e 74 20 22 45 52 52 4f 52 3a 20 46 61  print "ERROR: Fa
4d90: 69 6c 65 64 20 74 6f 20 6c 61 75 6e 63 68 20 74  iled to launch t
4da0: 68 65 20 74 65 73 74 2e 20 45 78 69 74 69 6e 67  he test. Exiting
4db0: 20 61 73 20 73 6f 6f 6e 20 61 73 20 70 6f 73 73   as soon as poss
4dc0: 69 62 6c 65 22 29 0a 09 09 20 20 20 20 20 28 73  ible")...     (s
4dd0: 65 74 21 20 2a 67 6c 6f 62 61 6c 65 78 69 74 73  et! *globalexits
4de0: 74 61 74 75 73 2a 20 31 29 20 3b 3b 20 0a 09 09  tatus* 1) ;; ...
4df0: 20 20 20 20 20 28 70 72 6f 63 65 73 73 2d 73 69       (process-si
4e00: 67 6e 61 6c 20 28 63 75 72 72 65 6e 74 2d 70 72  gnal (current-pr
4e10: 6f 63 65 73 73 2d 69 64 29 20 73 69 67 6e 61 6c  ocess-id) signal
4e20: 2f 6b 69 6c 6c 29 29 29 29 29 29 0a 09 28 28 4b  /kill))))))..((K
4e30: 49 4c 4c 45 44 29 20 0a 09 20 28 64 65 62 75 67  ILLED) .. (debug
4e40: 3a 70 72 69 6e 74 20 31 20 22 4e 4f 54 45 3a 20  :print 1 "NOTE: 
4e50: 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20  " new-test-name 
4e60: 22 20 69 73 20 61 6c 72 65 61 64 79 20 72 75 6e  " is already run
4e70: 6e 69 6e 67 20 6f 72 20 77 61 73 20 65 78 70 6c  ning or was expl
4e80: 69 63 74 6c 79 20 6b 69 6c 6c 65 64 2c 20 75 73  ictly killed, us
4e90: 65 20 2d 66 6f 72 63 65 20 74 6f 20 6c 61 75 6e  e -force to laun
4ea0: 63 68 20 69 74 2e 22 29 29 0a 09 28 28 4c 41 55  ch it."))..((LAU
4eb0: 4e 43 48 45 44 20 52 45 4d 4f 54 45 48 4f 53 54  NCHED REMOTEHOST
4ec0: 53 54 41 52 54 20 52 55 4e 4e 49 4e 47 29 20 20  START RUNNING)  
4ed0: 0a 09 20 28 69 66 20 28 3e 20 28 2d 20 28 63 75  .. (if (> (- (cu
4ee0: 72 72 65 6e 74 2d 73 65 63 6f 6e 64 73 29 28 2b  rrent-seconds)(+
4ef0: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 65 76   (db:test-get-ev
4f00: 65 6e 74 5f 74 69 6d 65 20 74 65 73 74 64 61 74  ent_time testdat
4f10: 29 0a 09 09 09 09 20 20 20 20 20 20 20 28 64 62  ).....       (db
4f20: 3a 74 65 73 74 2d 67 65 74 2d 72 75 6e 5f 64 75  :test-get-run_du
4f30: 72 61 74 69 6f 6e 20 74 65 73 74 64 61 74 29 29  ration testdat))
4f40: 29 0a 09 09 36 30 30 29 20 3b 3b 20 69 2e 65 2e  )...600) ;; i.e.
4f50: 20 6e 6f 20 75 70 64 61 74 65 20 66 6f 72 20 6d   no update for m
4f60: 6f 72 65 20 74 68 61 6e 20 36 30 30 20 73 65 63  ore than 600 sec
4f70: 6f 6e 64 73 0a 09 20 20 20 20 20 28 62 65 67 69  onds..     (begi
4f80: 6e 0a 09 20 20 20 20 20 20 20 28 64 65 62 75 67  n..       (debug
4f90: 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e  :print 0 "WARNIN
4fa0: 47 3a 20 54 65 73 74 20 22 20 74 65 73 74 2d 6e  G: Test " test-n
4fb0: 61 6d 65 20 22 20 61 70 70 65 61 72 73 20 74 6f  ame " appears to
4fc0: 20 62 65 20 64 65 61 64 2e 20 46 6f 72 63 69 6e   be dead. Forcin
4fd0: 67 20 69 74 20 74 6f 20 73 74 61 74 65 20 49 4e  g it to state IN
4fe0: 43 4f 4d 50 4c 45 54 45 20 61 6e 64 20 73 74 61  COMPLETE and sta
4ff0: 74 75 73 20 53 54 55 43 4b 2f 44 45 41 44 22 29  tus STUCK/DEAD")
5000: 0a 09 20 20 20 20 20 20 20 28 74 65 73 74 2d 73  ..       (test-s
5010: 65 74 2d 73 74 61 74 75 73 21 20 64 62 20 72 75  et-status! db ru
5020: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 22  n-id test-name "
5030: 49 4e 43 4f 4d 50 4c 45 54 45 22 20 22 53 54 55  INCOMPLETE" "STU
5040: 43 4b 2f 44 45 41 44 22 20 69 74 65 6d 64 61 74  CK/DEAD" itemdat
5050: 20 22 54 65 73 74 20 69 73 20 73 74 75 63 6b 20   "Test is stuck 
5060: 6f 72 20 64 65 61 64 22 20 23 66 29 29 0a 09 20  or dead" #f)).. 
5070: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
5080: 20 32 20 22 4e 4f 54 45 3a 20 22 20 74 65 73 74   2 "NOTE: " test
5090: 2d 6e 61 6d 65 20 22 20 69 73 20 61 6c 72 65 61  -name " is alrea
50a0: 64 79 20 72 75 6e 6e 69 6e 67 22 29 29 29 0a 09  dy running")))..
50b0: 28 65 6c 73 65 20 20 20 20 20 20 20 28 64 65 62  (else       (deb
50c0: 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f  ug:print 0 "ERRO
50d0: 52 3a 20 46 61 69 6c 65 64 20 74 6f 20 6c 61 75  R: Failed to lau
50e0: 6e 63 68 20 74 65 73 74 20 22 20 6e 65 77 2d 74  nch test " new-t
50f0: 65 73 74 2d 6e 61 6d 65 20 22 2e 20 55 6e 72 65  est-name ". Unre
5100: 63 6f 67 6e 69 73 65 64 20 73 74 61 74 65 20 22  cognised state "
5110: 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65   (test:get-state
5120: 20 74 65 73 74 64 61 74 29 29 29 29 29 29 29 0a   testdat))))))).
5130: 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  .;;=============
5140: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5150: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5160: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5170: 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 45 4e 44  =========.;; END
5180: 20 4f 46 20 4e 45 57 20 53 54 55 46 46 0a 3b 3b   OF NEW STUFF.;;
5190: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
51a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
51b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
51c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
51d0: 3d 3d 3d 3d 3d 3d 0a 0a 28 64 65 66 69 6e 65 20  ======..(define 
51e0: 28 67 65 74 2d 64 69 72 2d 75 70 2d 6e 20 64 69  (get-dir-up-n di
51f0: 72 20 2e 20 70 61 72 61 6d 73 29 20 0a 20 20 28  r . params) .  (
5200: 6c 65 74 20 28 28 64 70 61 72 74 73 20 20 28 73  let ((dparts  (s
5210: 74 72 69 6e 67 2d 73 70 6c 69 74 20 64 69 72 20  tring-split dir 
5220: 22 2f 22 29 29 0a 09 28 63 6f 75 6e 74 20 20 20  "/"))..(count   
5230: 28 69 66 20 28 6e 75 6c 6c 3f 20 70 61 72 61 6d  (if (null? param
5240: 73 29 20 31 20 28 63 61 72 20 70 61 72 61 6d 73  s) 1 (car params
5250: 29 29 29 29 0a 20 20 20 20 28 63 6f 6e 63 20 22  )))).    (conc "
5260: 2f 22 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72  /" (string-inter
5270: 73 70 65 72 73 65 20 0a 09 20 20 20 20 20 20 20  sperse ..       
5280: 28 74 61 6b 65 20 64 70 61 72 74 73 20 28 2d 20  (take dparts (- 
5290: 28 6c 65 6e 67 74 68 20 64 70 61 72 74 73 29 20  (length dparts) 
52a0: 63 6f 75 6e 74 29 29 0a 09 20 20 20 20 20 20 20  count))..       
52b0: 22 2f 22 29 29 29 29 0a 3b 3b 20 52 65 6d 6f 76  "/")))).;; Remov
52c0: 65 20 72 75 6e 73 0a 3b 3b 20 66 69 65 6c 64 73  e runs.;; fields
52d0: 20 61 72 65 20 70 61 73 73 69 6e 67 20 69 6e 20   are passing in 
52e0: 74 68 72 6f 75 67 68 20 0a 28 64 65 66 69 6e 65  through .(define
52f0: 20 28 72 75 6e 73 3a 72 65 6d 6f 76 65 2d 72 75   (runs:remove-ru
5300: 6e 73 20 64 62 20 72 75 6e 6e 61 6d 65 70 61 74  ns db runnamepat
5310: 74 20 74 65 73 74 70 61 74 74 20 69 74 65 6d 70  t testpatt itemp
5320: 61 74 74 29 0a 20 20 28 6c 65 74 2a 20 28 28 6b  att).  (let* ((k
5330: 65 79 73 20 20 20 20 20 20 20 20 28 64 62 2d 67  eys        (db-g
5340: 65 74 2d 6b 65 79 73 20 64 62 29 29 0a 09 20 28  et-keys db)).. (
5350: 72 75 6e 64 61 74 20 20 20 20 20 20 28 72 75 6e  rundat      (run
5360: 73 3a 67 65 74 2d 72 75 6e 73 2d 62 79 2d 70 61  s:get-runs-by-pa
5370: 74 74 20 64 62 20 6b 65 79 73 20 72 75 6e 6e 61  tt db keys runna
5380: 6d 65 70 61 74 74 29 29 0a 09 20 28 68 65 61 64  mepatt)).. (head
5390: 65 72 20 20 20 20 20 20 28 76 65 63 74 6f 72 2d  er      (vector-
53a0: 72 65 66 20 72 75 6e 64 61 74 20 30 29 29 0a 09  ref rundat 0))..
53b0: 20 28 72 75 6e 73 20 20 20 20 20 20 20 20 28 76   (runs        (v
53c0: 65 63 74 6f 72 2d 72 65 66 20 72 75 6e 64 61 74  ector-ref rundat
53d0: 20 31 29 29 29 0a 20 20 20 20 28 64 65 62 75 67   1))).    (debug
53e0: 3a 70 72 69 6e 74 20 31 20 22 48 65 61 64 65 72  :print 1 "Header
53f0: 3a 20 22 20 68 65 61 64 65 72 29 0a 20 20 20 20  : " header).    
5400: 28 66 6f 72 2d 65 61 63 68 0a 20 20 20 20 20 28  (for-each.     (
5410: 6c 61 6d 62 64 61 20 28 72 75 6e 29 0a 20 20 20  lambda (run).   
5420: 20 20 20 20 28 6c 65 74 20 28 28 72 75 6e 6b 65      (let ((runke
5430: 79 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73  y (string-inters
5440: 70 65 72 73 65 20 28 6d 61 70 20 28 6c 61 6d 62  perse (map (lamb
5450: 64 61 20 28 6b 29 0a 09 09 09 09 09 09 28 64 62  da (k).......(db
5460: 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65  :get-value-by-he
5470: 61 64 65 72 20 72 75 6e 20 68 65 61 64 65 72 20  ader run header 
5480: 28 76 65 63 74 6f 72 2d 72 65 66 20 6b 20 30 29  (vector-ref k 0)
5490: 29 29 20 6b 65 79 73 29 20 22 2f 22 29 29 0a 09  )) keys) "/"))..
54a0: 20 20 20 20 20 28 64 69 72 73 2d 74 6f 2d 72 65       (dirs-to-re
54b0: 6d 6f 76 65 20 28 6d 61 6b 65 2d 68 61 73 68 2d  move (make-hash-
54c0: 74 61 62 6c 65 29 29 29 0a 09 20 28 6c 65 74 2a  table))).. (let*
54d0: 20 28 28 72 75 6e 2d 69 64 20 28 64 62 3a 67 65   ((run-id (db:ge
54e0: 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65  t-value-by-heade
54f0: 72 20 72 75 6e 20 68 65 61 64 65 72 20 22 69 64  r run header "id
5500: 22 29 20 29 0a 09 09 28 74 65 73 74 73 20 20 28  ") )...(tests  (
5510: 64 62 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f 72  db-get-tests-for
5520: 2d 72 75 6e 20 64 62 20 28 64 62 3a 67 65 74 2d  -run db (db:get-
5530: 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20  value-by-header 
5540: 72 75 6e 20 68 65 61 64 65 72 20 22 69 64 22 29  run header "id")
5550: 20 74 65 73 74 70 61 74 74 20 69 74 65 6d 70 61   testpatt itempa
5560: 74 74 20 27 28 29 20 27 28 29 29 29 0a 09 09 28  tt '() '()))...(
5570: 6c 61 73 74 74 70 61 74 68 20 22 2f 64 6f 65 73  lasttpath "/does
5580: 2f 6e 6f 74 2f 65 78 69 73 74 2f 49 2f 68 6f 70  /not/exist/I/hop
5590: 65 22 29 29 0a 0a 09 20 20 20 28 69 66 20 28 6e  e"))...   (if (n
55a0: 6f 74 20 28 6e 75 6c 6c 3f 20 74 65 73 74 73 29  ot (null? tests)
55b0: 29 0a 09 20 20 20 20 20 20 20 28 62 65 67 69 6e  )..       (begin
55c0: 0a 09 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ... (debug:print
55d0: 20 31 20 22 52 65 6d 6f 76 69 6e 67 20 74 65 73   1 "Removing tes
55e0: 74 73 20 66 6f 72 20 72 75 6e 3a 20 22 20 72 75  ts for run: " ru
55f0: 6e 6b 65 79 20 22 20 22 20 28 64 62 3a 67 65 74  nkey " " (db:get
5600: 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72  -value-by-header
5610: 20 72 75 6e 20 68 65 61 64 65 72 20 22 72 75 6e   run header "run
5620: 6e 61 6d 65 22 29 29 0a 09 09 20 28 66 6f 72 2d  name"))... (for-
5630: 65 61 63 68 0a 09 09 20 20 28 6c 61 6d 62 64 61  each...  (lambda
5640: 20 28 74 65 73 74 29 0a 09 09 20 20 20 20 28 6c   (test)...    (l
5650: 65 74 2a 20 28 28 69 74 65 6d 2d 70 61 74 68 20  et* ((item-path 
5660: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65  (db:test-get-ite
5670: 6d 2d 70 61 74 68 20 74 65 73 74 29 29 0a 09 09  m-path test))...
5680: 09 20 20 20 28 74 65 73 74 2d 6e 61 6d 65 20 28  .   (test-name (
5690: 64 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74  db:test-get-test
56a0: 6e 61 6d 65 20 74 65 73 74 29 29 0a 09 09 09 20  name test)).... 
56b0: 20 20 28 72 75 6e 2d 64 69 72 20 20 20 28 64 62    (run-dir   (db
56c0: 3a 74 65 73 74 2d 67 65 74 2d 72 75 6e 64 69 72  :test-get-rundir
56d0: 20 74 65 73 74 29 29 29 0a 09 09 20 20 20 20 20   test)))...     
56e0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20   (debug:print 1 
56f0: 22 20 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65  "  " (db:test-ge
5700: 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 29  t-testname test)
5710: 20 22 20 69 64 3a 20 22 20 28 64 62 3a 74 65 73   " id: " (db:tes
5720: 74 2d 67 65 74 2d 69 64 20 74 65 73 74 29 20 22  t-get-id test) "
5730: 20 22 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 09   " item-path)...
5740: 20 20 20 20 20 20 28 64 62 3a 64 65 6c 65 74 65        (db:delete
5750: 2d 74 65 73 74 2d 72 65 63 6f 72 64 73 20 64 62  -test-records db
5760: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64   (db:test-get-id
5770: 20 74 65 73 74 29 29 0a 09 09 20 20 20 20 20 20   test))...      
5780: 28 69 66 20 28 3e 20 28 73 74 72 69 6e 67 2d 6c  (if (> (string-l
5790: 65 6e 67 74 68 20 72 75 6e 2d 64 69 72 29 20 35  ength run-dir) 5
57a0: 29 20 3b 3b 20 62 61 64 20 68 65 75 72 69 73 74  ) ;; bad heurist
57b0: 69 63 20 62 75 74 20 73 68 6f 75 6c 64 20 70 72  ic but should pr
57c0: 65 76 65 6e 74 20 2f 74 6d 70 20 2f 68 6f 6d 65  event /tmp /home
57d0: 20 65 74 63 2e 0a 09 09 09 20 20 28 6c 65 74 20   etc.....  (let 
57e0: 28 28 66 75 6c 6c 70 61 74 68 20 72 75 6e 2d 64  ((fullpath run-d
57f0: 69 72 29 29 20 3b 3b 20 22 2f 22 20 28 64 62 3a  ir)) ;; "/" (db:
5800: 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61  test-get-item-pa
5810: 74 68 20 74 65 73 74 29 29 29 29 0a 09 09 09 20  th test)))).... 
5820: 20 20 20 28 73 65 74 21 20 6c 61 73 74 74 70 61     (set! lasttpa
5830: 74 68 20 66 75 6c 6c 70 61 74 68 29 0a 09 09 09  th fullpath)....
5840: 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d      (hash-table-
5850: 73 65 74 21 20 64 69 72 73 2d 74 6f 2d 72 65 6d  set! dirs-to-rem
5860: 6f 76 65 20 66 75 6c 6c 70 61 74 68 20 23 74 29  ove fullpath #t)
5870: 0a 09 09 09 20 20 20 20 3b 3b 20 54 68 65 20 66  ....    ;; The f
5880: 6f 6c 6c 6f 77 69 6e 67 20 77 61 73 20 74 68 65  ollowing was the
5890: 20 73 61 66 65 20 64 65 6c 65 74 65 20 63 6f 64   safe delete cod
58a0: 65 20 62 75 74 20 69 74 20 77 61 73 20 6e 6f 74  e but it was not
58b0: 20 62 65 69 6e 67 20 65 78 65 63 74 75 74 65 64   being exectuted
58c0: 2e 0a 09 09 09 20 20 20 20 3b 3b 20 28 6c 65 74  .....    ;; (let
58d0: 2a 20 28 28 64 69 72 73 2d 63 6f 75 6e 74 20 28  * ((dirs-count (
58e0: 2b 20 31 20 28 6c 65 6e 67 74 68 20 6b 65 79 73  + 1 (length keys
58f0: 29 28 6c 65 6e 67 74 68 20 28 73 74 72 69 6e 67  )(length (string
5900: 2d 73 70 6c 69 74 20 69 74 65 6d 2d 70 61 74 68  -split item-path
5910: 20 22 2f 22 29 29 29 29 0a 09 09 09 20 20 20 20   "/"))))....    
5920: 3b 3b 20 20 20 20 20 20 20 20 28 64 69 72 2d 74  ;;        (dir-t
5930: 6f 2d 72 65 6d 20 28 67 65 74 2d 64 69 72 2d 75  o-rem (get-dir-u
5940: 70 2d 6e 20 66 75 6c 6c 70 61 74 68 20 64 69 72  p-n fullpath dir
5950: 73 2d 63 6f 75 6e 74 29 29 0a 09 09 09 20 20 20  s-count))....   
5960: 20 3b 3b 20 20 20 20 20 20 20 20 28 72 65 6d 61   ;;        (rema
5970: 69 6e 69 6e 67 64 20 28 73 74 72 69 6e 67 2d 73  iningd (string-s
5980: 75 62 73 74 69 74 75 74 65 20 28 72 65 67 65 78  ubstitute (regex
5990: 70 20 28 63 6f 6e 63 20 22 5e 22 20 64 69 72 2d  p (conc "^" dir-
59a0: 74 6f 2d 72 65 6d 20 22 2f 22 29 29 20 22 22 20  to-rem "/")) "" 
59b0: 66 75 6c 6c 70 61 74 68 29 29 0a 09 09 09 20 20  fullpath))....  
59c0: 20 20 3b 3b 20 20 20 20 20 20 20 20 28 63 6d 64    ;;        (cmd
59d0: 20 28 63 6f 6e 63 20 22 63 64 20 22 20 64 69 72   (conc "cd " dir
59e0: 2d 74 6f 2d 72 65 6d 20 22 3b 20 72 6d 64 69 72  -to-rem "; rmdir
59f0: 20 2d 70 20 22 20 72 65 6d 61 69 6e 69 6e 67 64   -p " remainingd
5a00: 20 29 29 29 0a 09 09 09 20 20 20 20 3b 3b 20 20   )))....    ;;  
5a10: 20 28 69 66 20 28 66 69 6c 65 2d 65 78 69 73 74   (if (file-exist
5a20: 73 3f 20 66 75 6c 6c 70 61 74 68 29 0a 09 09 09  s? fullpath)....
5a30: 20 20 20 20 3b 3b 20 20 20 20 20 20 20 28 62 65      ;;       (be
5a40: 67 69 6e 0a 09 09 09 20 20 20 20 3b 3b 20 20 20  gin....    ;;   
5a50: 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69        (debug:pri
5a60: 6e 74 20 31 20 63 6d 64 29 0a 09 09 09 20 20 20  nt 1 cmd)....   
5a70: 20 3b 3b 20 20 20 20 20 20 20 20 20 28 73 79 73   ;;         (sys
5a80: 74 65 6d 20 63 6d 64 29 29 29 0a 09 09 09 20 20  tem cmd)))....  
5a90: 20 20 3b 3b 20 20 20 29 29 0a 09 09 09 20 20 20    ;;   ))....   
5aa0: 20 29 29 29 29 0a 09 09 20 20 20 20 74 65 73 74   ))))...    test
5ab0: 73 29 29 29 0a 0a 09 20 20 20 3b 3b 20 6c 6f 6f  s)))...   ;; loo
5ac0: 6b 20 74 68 6f 75 67 68 20 74 68 65 20 64 69 72  k though the dir
5ad0: 73 2d 74 6f 2d 72 65 6d 6f 76 65 20 66 6f 72 20  s-to-remove for 
5ae0: 63 61 6e 64 69 64 61 74 65 73 20 66 6f 72 20 72  candidates for r
5af0: 65 6d 6f 76 61 6c 2e 20 44 6f 20 74 68 69 73 20  emoval. Do this 
5b00: 61 66 74 65 72 20 64 65 6c 65 74 69 6e 67 20 74  after deleting t
5b10: 68 65 20 72 65 63 6f 72 64 73 0a 09 20 20 20 3b  he records..   ;
5b20: 3b 20 66 6f 72 20 65 61 63 68 20 74 65 73 74 20  ; for each test 
5b30: 69 6e 20 63 61 73 65 20 77 65 20 67 65 74 20 6b  in case we get k
5b40: 69 6c 6c 65 64 2e 20 54 68 61 74 20 73 68 6f 75  illed. That shou
5b50: 6c 64 20 6d 69 6e 69 6d 69 7a 65 20 74 68 65 20  ld minimize the 
5b60: 64 65 74 72 69 74 75 73 20 6c 65 66 74 20 6f 6e  detritus left on
5b70: 20 64 69 73 6b 0a 09 20 20 20 3b 3b 20 70 72 6f   disk..   ;; pro
5b80: 63 65 73 73 20 74 68 65 20 64 69 72 73 20 66 72  cess the dirs fr
5b90: 6f 6d 20 6c 6f 6e 67 65 73 74 20 73 74 72 69 6e  om longest strin
5ba0: 67 20 6c 65 6e 67 74 68 20 74 6f 20 73 68 6f 72  g length to shor
5bb0: 74 65 73 74 0a 09 20 20 20 28 66 6f 72 2d 65 61  test..   (for-ea
5bc0: 63 68 20 0a 09 20 20 20 20 28 6c 61 6d 62 64 61  ch ..    (lambda
5bd0: 20 28 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29   (dir-to-remove)
5be0: 0a 09 20 20 20 20 20 20 28 69 66 20 28 66 69 6c  ..      (if (fil
5bf0: 65 2d 65 78 69 73 74 73 3f 20 64 69 72 2d 74 6f  e-exists? dir-to
5c00: 2d 72 65 6d 6f 76 65 29 0a 09 09 20 20 28 6c 65  -remove)...  (le
5c10: 74 20 28 28 64 69 72 2d 69 6e 2d 64 62 20 27 28  t ((dir-in-db '(
5c20: 29 29 29 0a 09 09 20 20 20 20 28 73 71 6c 69 74  )))...    (sqlit
5c30: 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77 0a  e3:for-each-row.
5c40: 09 09 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28  ..     (lambda (
5c50: 64 69 72 29 0a 09 09 20 20 20 20 20 20 20 28 73  dir)...       (s
5c60: 65 74 21 20 64 69 72 2d 69 6e 2d 64 62 20 28 63  et! dir-in-db (c
5c70: 6f 6e 73 20 64 69 72 20 64 69 72 2d 69 6e 2d 64  ons dir dir-in-d
5c80: 62 29 29 29 0a 09 09 20 20 20 20 20 64 62 20 22  b)))...     db "
5c90: 53 45 4c 45 43 54 20 72 75 6e 64 69 72 20 46 52  SELECT rundir FR
5ca0: 4f 4d 20 74 65 73 74 73 20 57 48 45 52 45 20 72  OM tests WHERE r
5cb0: 75 6e 64 69 72 20 4c 49 4b 45 20 3f 3b 22 20 0a  undir LIKE ?;" .
5cc0: 09 09 20 20 20 20 20 28 63 6f 6e 63 20 22 25 22  ..     (conc "%"
5cd0: 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 20 22   dir-to-remove "
5ce0: 25 22 29 29 20 3b 3b 20 79 65 73 2c 20 49 27 6d  %")) ;; yes, I'm
5cf0: 20 67 6f 69 6e 67 20 74 6f 20 62 61 69 6c 20 69   going to bail i
5d00: 66 20 74 68 65 72 65 20 69 73 20 61 6e 79 74 68  f there is anyth
5d10: 69 6e 67 20 6c 69 6b 65 20 74 68 69 73 20 64 69  ing like this di
5d20: 72 20 69 6e 20 74 68 65 20 64 62 0a 09 09 20 20  r in the db...  
5d30: 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 64 69 72    (if (null? dir
5d40: 2d 69 6e 2d 64 62 29 0a 09 09 09 28 62 65 67 69  -in-db)....(begi
5d50: 6e 0a 09 09 09 20 20 28 64 65 62 75 67 3a 70 72  n....  (debug:pr
5d60: 69 6e 74 20 32 20 22 52 65 6d 6f 76 69 6e 67 20  int 2 "Removing 
5d70: 64 69 72 65 63 74 6f 72 79 20 77 69 74 68 20 7a  directory with z
5d80: 65 72 6f 20 64 62 20 72 65 66 65 72 65 6e 63 65  ero db reference
5d90: 73 3a 20 22 20 64 69 72 2d 74 6f 2d 72 65 6d 6f  s: " dir-to-remo
5da0: 76 65 29 0a 09 09 09 20 20 28 73 79 73 74 65 6d  ve)....  (system
5db0: 20 28 63 6f 6e 63 20 22 72 6d 20 2d 72 66 20 22   (conc "rm -rf "
5dc0: 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 29   dir-to-remove))
5dd0: 0a 09 09 09 20 20 28 68 61 73 68 2d 74 61 62 6c  ....  (hash-tabl
5de0: 65 2d 64 65 6c 65 74 65 21 20 64 69 72 73 2d 74  e-delete! dirs-t
5df0: 6f 2d 72 65 6d 6f 76 65 20 64 69 72 2d 74 6f 2d  o-remove dir-to-
5e00: 72 65 6d 6f 76 65 29 29 0a 09 09 09 28 64 65 62  remove))....(deb
5e10: 75 67 3a 70 72 69 6e 74 20 32 20 22 53 6b 69 70  ug:print 2 "Skip
5e20: 70 69 6e 67 20 72 65 6d 6f 76 61 6c 20 6f 66 20  ping removal of 
5e30: 22 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 20  " dir-to-remove 
5e40: 22 20 66 6f 72 20 6e 6f 77 20 61 73 20 69 74 20  " for now as it 
5e50: 73 74 69 6c 6c 20 68 61 73 20 72 65 66 65 72 65  still has refere
5e60: 6e 63 65 73 20 69 6e 20 74 68 65 20 64 61 74 61  nces in the data
5e70: 62 61 73 65 22 29 29 29 29 29 0a 09 20 20 20 20  base")))))..    
5e80: 28 73 6f 72 74 20 28 68 61 73 68 2d 74 61 62 6c  (sort (hash-tabl
5e90: 65 2d 6b 65 79 73 20 64 69 72 73 2d 74 6f 2d 72  e-keys dirs-to-r
5ea0: 65 6d 6f 76 65 29 20 28 6c 61 6d 62 64 61 20 28  emove) (lambda (
5eb0: 61 20 62 29 28 3e 20 28 73 74 72 69 6e 67 2d 6c  a b)(> (string-l
5ec0: 65 6e 67 74 68 20 61 29 28 73 74 72 69 6e 67 2d  ength a)(string-
5ed0: 6c 65 6e 67 74 68 20 62 29 29 29 29 29 0a 0a 09  length b)))))...
5ee0: 20 20 20 3b 3b 20 72 65 6d 6f 76 65 20 74 68 65     ;; remove the
5ef0: 20 72 75 6e 20 69 66 20 7a 65 72 6f 20 74 65 73   run if zero tes
5f00: 74 73 20 72 65 6d 61 69 6e 0a 09 20 20 20 28 6c  ts remain..   (l
5f10: 65 74 20 28 28 72 65 6d 74 65 73 74 73 20 28 64  et ((remtests (d
5f20: 62 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d  b-get-tests-for-
5f30: 72 75 6e 20 64 62 20 28 64 62 3a 67 65 74 2d 76  run db (db:get-v
5f40: 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72  alue-by-header r
5f50: 75 6e 20 68 65 61 64 65 72 20 22 69 64 22 29 20  un header "id") 
5f60: 23 66 20 23 66 20 27 28 29 20 27 28 29 29 29 29  #f #f '() '())))
5f70: 0a 09 20 20 20 20 20 28 69 66 20 28 6e 75 6c 6c  ..     (if (null
5f80: 3f 20 72 65 6d 74 65 73 74 73 29 20 3b 3b 20 6e  ? remtests) ;; n
5f90: 6f 20 6d 6f 72 65 20 74 65 73 74 73 20 72 65 6d  o more tests rem
5fa0: 61 69 6e 69 6e 67 0a 09 09 20 28 6c 65 74 2a 20  aining... (let* 
5fb0: 28 28 64 70 61 72 74 73 20 20 28 73 74 72 69 6e  ((dparts  (strin
5fc0: 67 2d 73 70 6c 69 74 20 6c 61 73 74 74 70 61 74  g-split lasttpat
5fd0: 68 20 22 2f 22 29 29 0a 09 09 09 28 72 75 6e 70  h "/"))....(runp
5fe0: 61 74 68 20 28 63 6f 6e 63 20 22 2f 22 20 28 73  ath (conc "/" (s
5ff0: 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73  tring-interspers
6000: 65 20 0a 09 09 09 09 09 20 20 20 20 28 74 61 6b  e ......    (tak
6010: 65 20 64 70 61 72 74 73 20 28 2d 20 28 6c 65 6e  e dparts (- (len
6020: 67 74 68 20 64 70 61 72 74 73 29 20 31 29 29 0a  gth dparts) 1)).
6030: 09 09 09 09 09 20 20 20 20 22 2f 22 29 29 29 29  .....    "/"))))
6040: 0a 09 09 20 20 20 28 64 65 62 75 67 3a 70 72 69  ...   (debug:pri
6050: 6e 74 20 31 20 22 52 65 6d 6f 76 69 6e 67 20 72  nt 1 "Removing r
6060: 75 6e 3a 20 22 20 72 75 6e 6b 65 79 20 22 20 22  un: " runkey " "
6070: 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62   (db:get-value-b
6080: 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61  y-header run hea
6090: 64 65 72 20 22 72 75 6e 6e 61 6d 65 22 29 29 0a  der "runname")).
60a0: 09 09 20 20 20 28 64 62 3a 64 65 6c 65 74 65 2d  ..   (db:delete-
60b0: 72 75 6e 20 64 62 20 72 75 6e 2d 69 64 29 0a 09  run db run-id)..
60c0: 09 20 20 20 3b 3b 20 6e 65 65 64 20 74 6f 20 66  .   ;; need to f
60d0: 69 67 75 72 65 20 6f 75 74 20 74 68 65 20 70 61  igure out the pa
60e0: 74 68 20 74 6f 20 74 68 65 20 72 75 6e 20 64 69  th to the run di
60f0: 72 20 61 6e 64 20 72 65 6d 6f 76 65 20 69 74 20  r and remove it 
6100: 69 66 20 65 6d 70 74 79 0a 09 09 20 20 20 3b 3b  if empty...   ;;
6110: 20 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 28      (if (null? (
6120: 67 6c 6f 62 20 28 63 6f 6e 63 20 72 75 6e 70 61  glob (conc runpa
6130: 74 68 20 22 2f 2a 22 29 29 29 0a 09 09 20 20 20  th "/*")))...   
6140: 3b 3b 20 20 20 20 20 20 20 20 28 62 65 67 69 6e  ;;        (begin
6150: 0a 09 09 20 20 20 3b 3b 20 09 20 28 64 65 62 75  ...   ;; . (debu
6160: 67 3a 70 72 69 6e 74 20 31 20 22 52 65 6d 6f 76  g:print 1 "Remov
6170: 69 6e 67 20 72 75 6e 20 64 69 72 20 22 20 72 75  ing run dir " ru
6180: 6e 70 61 74 68 29 0a 09 09 20 20 20 3b 3b 20 09  npath)...   ;; .
6190: 20 28 73 79 73 74 65 6d 20 28 63 6f 6e 63 20 22   (system (conc "
61a0: 72 6d 64 69 72 20 2d 70 20 22 20 72 75 6e 70 61  rmdir -p " runpa
61b0: 74 68 29 29 29 29 0a 09 09 20 20 20 29 29 29 29  th))))...   ))))
61c0: 0a 09 20 29 29 0a 20 20 20 20 20 72 75 6e 73 29  .. )).     runs)
61d0: 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ))..;;==========
61e0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
61f0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6200: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6210: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20  ============.;; 
6220: 52 6f 75 74 69 6e 65 73 20 66 6f 72 20 6d 61 6e  Routines for man
6230: 69 70 75 6c 61 74 69 6e 67 20 72 75 6e 73 0a 3b  ipulating runs.;
6240: 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ;===============
6250: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6260: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6270: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6280: 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 53 69 6e 63  =======..;; Sinc
6290: 65 20 6d 61 6e 79 20 63 61 6c 6c 73 20 74 6f 20  e many calls to 
62a0: 61 20 72 75 6e 20 72 65 71 75 69 72 65 20 70 72  a run require pr
62b0: 65 74 74 79 20 6d 75 63 68 20 74 68 65 20 73 61  etty much the sa
62c0: 6d 65 20 73 65 74 75 70 20 0a 3b 3b 20 74 68 69  me setup .;; thi
62d0: 73 20 77 72 61 70 70 65 72 20 69 73 20 75 73 65  s wrapper is use
62e0: 64 20 74 6f 20 72 65 64 75 63 65 20 74 68 65 20  d to reduce the 
62f0: 72 65 70 6c 69 63 61 74 69 6f 6e 20 6f 66 20 63  replication of c
6300: 6f 64 65 0a 28 64 65 66 69 6e 65 20 28 67 65 6e  ode.(define (gen
6310: 65 72 61 6c 2d 72 75 6e 2d 63 61 6c 6c 20 73 77  eral-run-call sw
6320: 69 74 63 68 6e 61 6d 65 20 61 63 74 69 6f 6e 2d  itchname action-
6330: 64 65 73 63 20 70 72 6f 63 29 0a 20 20 28 6c 65  desc proc).  (le
6340: 74 20 28 28 72 75 6e 6e 61 6d 65 20 28 61 72 67  t ((runname (arg
6350: 73 3a 67 65 74 2d 61 72 67 20 22 3a 72 75 6e 6e  s:get-arg ":runn
6360: 61 6d 65 22 29 29 0a 09 28 74 61 72 67 65 74 20  ame"))..(target 
6370: 20 28 69 66 20 28 61 72 67 73 3a 67 65 74 2d 61   (if (args:get-a
6380: 72 67 20 22 2d 74 61 72 67 65 74 22 29 0a 09 09  rg "-target")...
6390: 20 20 20 20 20 28 61 72 67 73 3a 67 65 74 2d 61       (args:get-a
63a0: 72 67 20 22 2d 74 61 72 67 65 74 22 29 0a 09 09  rg "-target")...
63b0: 20 20 20 20 20 28 61 72 67 73 3a 67 65 74 2d 61       (args:get-a
63c0: 72 67 20 22 2d 72 65 71 74 61 72 67 22 29 29 29  rg "-reqtarg")))
63d0: 29 0a 20 20 20 20 28 63 6f 6e 64 0a 20 20 20 20  ).    (cond.    
63e0: 20 28 28 6e 6f 74 20 74 61 72 67 65 74 29 0a 20   ((not target). 
63f0: 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e       (debug:prin
6400: 74 20 30 20 22 45 52 52 4f 52 3a 20 4d 69 73 73  t 0 "ERROR: Miss
6410: 69 6e 67 20 72 65 71 75 69 72 65 64 20 70 61 72  ing required par
6420: 61 6d 65 74 65 72 20 66 6f 72 20 22 20 73 77 69  ameter for " swi
6430: 74 63 68 6e 61 6d 65 20 22 2c 20 79 6f 75 20 6d  tchname ", you m
6440: 75 73 74 20 73 70 65 63 69 66 79 20 74 68 65 20  ust specify the 
6450: 74 61 72 67 65 74 20 77 69 74 68 20 2d 74 61 72  target with -tar
6460: 67 65 74 22 29 0a 20 20 20 20 20 20 28 65 78 69  get").      (exi
6470: 74 20 33 29 29 0a 20 20 20 20 20 28 28 6e 6f 74  t 3)).     ((not
6480: 20 72 75 6e 6e 61 6d 65 29 0a 20 20 20 20 20 20   runname).      
6490: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
64a0: 45 52 52 4f 52 3a 20 4d 69 73 73 69 6e 67 20 72  ERROR: Missing r
64b0: 65 71 75 69 72 65 64 20 70 61 72 61 6d 65 74 65  equired paramete
64c0: 72 20 66 6f 72 20 22 20 73 77 69 74 63 68 6e 61  r for " switchna
64d0: 6d 65 20 22 2c 20 79 6f 75 20 6d 75 73 74 20 73  me ", you must s
64e0: 70 65 63 69 66 79 20 74 68 65 20 72 75 6e 20 6e  pecify the run n
64f0: 61 6d 65 20 77 69 74 68 20 3a 72 75 6e 6e 61 6d  ame with :runnam
6500: 65 20 72 75 6e 6e 61 6d 65 22 29 0a 20 20 20 20  e runname").    
6510: 20 20 28 65 78 69 74 20 33 29 29 0a 20 20 20 20    (exit 3)).    
6520: 20 28 65 6c 73 65 0a 20 20 20 20 20 20 28 6c 65   (else.      (le
6530: 74 20 28 28 64 62 20 20 20 23 66 29 0a 09 20 20  t ((db   #f)..  
6540: 20 20 28 6b 65 79 73 20 23 66 29 29 0a 09 28 69    (keys #f))..(i
6550: 66 20 28 6e 6f 74 20 28 73 65 74 75 70 2d 66 6f  f (not (setup-fo
6560: 72 2d 72 75 6e 29 29 0a 09 20 20 20 20 28 62 65  r-run))..    (be
6570: 67 69 6e 20 0a 09 20 20 20 20 20 20 28 64 65 62  gin ..      (deb
6580: 75 67 3a 70 72 69 6e 74 20 30 20 22 46 61 69 6c  ug:print 0 "Fail
6590: 65 64 20 74 6f 20 73 65 74 75 70 2c 20 65 78 69  ed to setup, exi
65a0: 74 69 6e 67 22 29 0a 09 20 20 20 20 20 20 28 65  ting")..      (e
65b0: 78 69 74 20 31 29 29 29 0a 09 28 73 65 74 21 20  xit 1)))..(set! 
65c0: 64 62 20 20 20 28 6f 70 65 6e 2d 64 62 29 29 0a  db   (open-db)).
65d0: 09 28 73 65 74 21 20 6b 65 79 73 20 28 64 62 2d  .(set! keys (db-
65e0: 67 65 74 2d 6b 65 79 73 20 64 62 29 29 0a 09 3b  get-keys db))..;
65f0: 3b 20 68 61 76 65 20 65 6e 6f 75 67 68 20 74 6f  ; have enough to
6600: 20 70 72 6f 63 65 73 73 20 2d 74 61 72 67 65 74   process -target
6610: 20 6f 72 20 2d 72 65 71 74 61 72 67 20 68 65 72   or -reqtarg her
6620: 65 0a 09 28 69 66 20 28 61 72 67 73 3a 67 65 74  e..(if (args:get
6630: 2d 61 72 67 20 22 2d 72 65 71 74 61 72 67 22 29  -arg "-reqtarg")
6640: 0a 09 20 20 20 20 28 6c 65 74 2a 20 28 28 72 75  ..    (let* ((ru
6650: 6e 63 6f 6e 66 69 67 66 20 28 63 6f 6e 63 20 20  nconfigf (conc  
6660: 2a 74 6f 70 70 61 74 68 2a 20 22 2f 72 75 6e 63  *toppath* "/runc
6670: 6f 6e 66 69 67 73 2e 63 6f 6e 66 69 67 22 29 29  onfigs.config"))
6680: 20 3b 3b 20 44 4f 20 4e 4f 54 20 45 56 41 4c 55   ;; DO NOT EVALU
6690: 41 54 45 20 41 4c 4c 20 0a 09 09 20 20 20 28 72  ATE ALL ...   (r
66a0: 75 6e 63 6f 6e 66 69 67 20 20 28 72 65 61 64 2d  unconfig  (read-
66b0: 63 6f 6e 66 69 67 20 72 75 6e 63 6f 6e 66 69 67  config runconfig
66c0: 66 20 23 66 20 23 66 20 65 6e 76 69 72 6f 6e 2d  f #f #f environ-
66d0: 70 61 74 74 3a 20 23 66 29 29 29 20 0a 09 20 20  patt: #f))) ..  
66e0: 20 20 20 20 28 69 66 20 28 68 61 73 68 2d 74 61      (if (hash-ta
66f0: 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20  ble-ref/default 
6700: 72 75 6e 63 6f 6e 66 69 67 20 28 61 72 67 73 3a  runconfig (args:
6710: 67 65 74 2d 61 72 67 20 22 2d 72 65 71 74 61 72  get-arg "-reqtar
6720: 67 22 29 20 23 66 29 0a 09 09 20 20 28 6b 65 79  g") #f)...  (key
6730: 73 3a 74 61 72 67 65 74 2d 73 65 74 2d 61 72 67  s:target-set-arg
6740: 73 20 6b 65 79 73 20 28 61 72 67 73 3a 67 65 74  s keys (args:get
6750: 2d 61 72 67 20 22 2d 72 65 71 74 61 72 67 22 29  -arg "-reqtarg")
6760: 20 61 72 67 73 3a 61 72 67 2d 68 61 73 68 29 0a   args:arg-hash).
6770: 09 09 20 20 28 62 65 67 69 6e 0a 09 09 20 20 20  ..  (begin...   
6780: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
6790: 22 45 52 52 4f 52 3a 20 5b 22 20 28 61 72 67 73  "ERROR: [" (args
67a0: 3a 67 65 74 2d 61 72 67 20 22 2d 72 65 71 74 61  :get-arg "-reqta
67b0: 72 67 22 29 20 22 5d 20 6e 6f 74 20 66 6f 75 6e  rg") "] not foun
67c0: 64 20 69 6e 20 22 20 72 75 6e 63 6f 6e 66 69 67  d in " runconfig
67d0: 66 29 0a 09 09 20 20 20 20 28 73 71 6c 69 74 65  f)...    (sqlite
67e0: 33 3a 66 69 6e 61 6c 69 7a 65 21 20 64 62 29 0a  3:finalize! db).
67f0: 09 09 20 20 20 20 28 65 78 69 74 20 31 29 29 29  ..    (exit 1)))
6800: 29 0a 09 20 20 20 20 28 69 66 20 28 61 72 67 73  )..    (if (args
6810: 3a 67 65 74 2d 61 72 67 20 22 2d 74 61 72 67 65  :get-arg "-targe
6820: 74 22 29 0a 09 09 28 6b 65 79 73 3a 74 61 72 67  t")...(keys:targ
6830: 65 74 2d 73 65 74 2d 61 72 67 73 20 6b 65 79 73  et-set-args keys
6840: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22   (args:get-arg "
6850: 2d 74 61 72 67 65 74 22 20 61 72 67 73 3a 61 72  -target" args:ar
6860: 67 2d 68 61 73 68 29 20 61 72 67 73 3a 61 72 67  g-hash) args:arg
6870: 2d 68 61 73 68 29 29 29 0a 09 28 69 66 20 28 6e  -hash)))..(if (n
6880: 6f 74 20 28 63 61 72 20 2a 63 6f 6e 66 69 67 69  ot (car *configi
6890: 6e 66 6f 2a 29 29 0a 09 20 20 20 20 28 62 65 67  nfo*))..    (beg
68a0: 69 6e 0a 09 20 20 20 20 20 20 28 64 65 62 75 67  in..      (debug
68b0: 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a  :print 0 "ERROR:
68c0: 20 41 74 74 65 6d 70 74 65 64 20 74 6f 20 22 20   Attempted to " 
68d0: 61 63 74 69 6f 6e 2d 64 65 73 63 20 22 20 62 75  action-desc " bu
68e0: 74 20 72 75 6e 20 61 72 65 61 20 63 6f 6e 66 69  t run area confi
68f0: 67 20 66 69 6c 65 20 6e 6f 74 20 66 6f 75 6e 64  g file not found
6900: 22 29 0a 09 20 20 20 20 20 20 28 65 78 69 74 20  ")..      (exit 
6910: 31 29 29 0a 09 20 20 20 20 3b 3b 20 45 78 74 72  1))..    ;; Extr
6920: 61 63 74 20 6f 75 74 20 73 74 75 66 66 20 6e 65  act out stuff ne
6930: 65 64 65 64 20 69 6e 20 6d 6f 73 74 20 6f 72 20  eded in most or 
6940: 6d 61 6e 79 20 63 61 6c 6c 73 0a 09 20 20 20 20  many calls..    
6950: 3b 3b 20 68 65 72 65 20 74 68 65 6e 20 63 61 6c  ;; here then cal
6960: 6c 20 70 72 6f 63 0a 09 20 20 20 20 28 6c 65 74  l proc..    (let
6970: 2a 20 28 28 6b 65 79 6e 61 6d 65 73 20 20 20 28  * ((keynames   (
6980: 6d 61 70 20 6b 65 79 3a 67 65 74 2d 66 69 65 6c  map key:get-fiel
6990: 64 6e 61 6d 65 20 6b 65 79 73 29 29 0a 09 09 20  dname keys))... 
69a0: 20 20 28 6b 65 79 76 61 6c 6c 73 74 20 20 28 6b    (keyvallst  (k
69b0: 65 79 73 2d 3e 76 61 6c 6c 69 73 74 20 6b 65 79  eys->vallist key
69c0: 73 20 23 74 29 29 29 0a 09 20 20 20 20 20 20 28  s #t)))..      (
69d0: 70 72 6f 63 20 64 62 20 74 61 72 67 65 74 20 72  proc db target r
69e0: 75 6e 6e 61 6d 65 20 6b 65 79 73 20 6b 65 79 6e  unname keys keyn
69f0: 61 6d 65 73 20 6b 65 79 76 61 6c 6c 73 74 29 29  ames keyvallst))
6a00: 29 0a 09 28 73 71 6c 69 74 65 33 3a 66 69 6e 61  )..(sqlite3:fina
6a10: 6c 69 7a 65 21 20 64 62 29 0a 09 28 73 65 74 21  lize! db)..(set!
6a20: 20 2a 64 69 64 73 6f 6d 65 74 68 69 6e 67 2a 20   *didsomething* 
6a30: 23 74 29 29 29 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d  #t))))))..;;====
6a40: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6a50: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6a60: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6a70: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6a80: 3d 3d 0a 3b 3b 20 52 6f 6c 6c 75 70 20 72 75 6e  ==.;; Rollup run
6a90: 73 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  s.;;============
6aa0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6ab0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6ac0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6ad0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 55  ==========..;; U
6ae0: 70 64 61 74 65 20 74 68 65 20 74 65 73 74 5f 6d  pdate the test_m
6af0: 65 74 61 20 74 61 62 6c 65 20 66 6f 72 20 74 68  eta table for th
6b00: 69 73 20 74 65 73 74 0a 28 64 65 66 69 6e 65 20  is test.(define 
6b10: 28 72 75 6e 73 3a 75 70 64 61 74 65 2d 74 65 73  (runs:update-tes
6b20: 74 5f 6d 65 74 61 20 64 62 20 74 65 73 74 2d 6e  t_meta db test-n
6b30: 61 6d 65 20 74 65 73 74 2d 63 6f 6e 66 29 0a 20  ame test-conf). 
6b40: 20 28 6c 65 74 20 28 28 63 75 72 72 72 65 63 6f   (let ((currreco
6b50: 72 64 20 28 64 62 3a 74 65 73 74 6d 65 74 61 2d  rd (db:testmeta-
6b60: 67 65 74 2d 72 65 63 6f 72 64 20 64 62 20 74 65  get-record db te
6b70: 73 74 2d 6e 61 6d 65 29 29 29 0a 20 20 20 20 28  st-name))).    (
6b80: 69 66 20 28 6e 6f 74 20 63 75 72 72 72 65 63 6f  if (not currreco
6b90: 72 64 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 28  rd)..(begin..  (
6ba0: 73 65 74 21 20 63 75 72 72 72 65 63 6f 72 64 20  set! currrecord 
6bb0: 28 6d 61 6b 65 2d 76 65 63 74 6f 72 20 31 30 20  (make-vector 10 
6bc0: 23 66 29 29 0a 09 20 20 28 64 62 3a 74 65 73 74  #f))..  (db:test
6bd0: 6d 65 74 61 2d 61 64 64 2d 72 65 63 6f 72 64 20  meta-add-record 
6be0: 64 62 20 74 65 73 74 2d 6e 61 6d 65 29 29 29 0a  db test-name))).
6bf0: 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20      (for-each . 
6c00: 20 20 20 20 28 6c 61 6d 62 64 61 20 28 6b 65 79      (lambda (key
6c10: 29 0a 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28  ).       (let* (
6c20: 28 69 64 78 20 28 63 61 64 72 20 6b 65 79 29 29  (idx (cadr key))
6c30: 0a 09 20 20 20 20 20 20 28 66 6c 64 20 28 63 61  ..      (fld (ca
6c40: 72 20 20 6b 65 79 29 29 0a 09 20 20 20 20 20 20  r  key))..      
6c50: 28 76 61 6c 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f  (val (config-loo
6c60: 6b 75 70 20 74 65 73 74 2d 63 6f 6e 66 20 22 74  kup test-conf "t
6c70: 65 73 74 5f 6d 65 74 61 22 20 66 6c 64 29 29 29  est_meta" fld)))
6c80: 0a 09 20 3b 3b 20 28 64 65 62 75 67 3a 70 72 69  .. ;; (debug:pri
6c90: 6e 74 20 35 20 22 69 64 78 3a 20 22 20 69 64 78  nt 5 "idx: " idx
6ca0: 20 22 20 66 6c 64 3a 20 22 20 66 6c 64 20 22 20   " fld: " fld " 
6cb0: 76 61 6c 3a 20 22 20 76 61 6c 29 0a 09 20 28 69  val: " val).. (i
6cc0: 66 20 28 61 6e 64 20 76 61 6c 20 28 6e 6f 74 20  f (and val (not 
6cd0: 28 65 71 75 61 6c 3f 20 28 76 65 63 74 6f 72 2d  (equal? (vector-
6ce0: 72 65 66 20 63 75 72 72 72 65 63 6f 72 64 20 69  ref currrecord i
6cf0: 64 78 29 20 76 61 6c 29 29 29 0a 09 20 20 20 20  dx) val)))..    
6d00: 20 28 62 65 67 69 6e 0a 09 20 20 20 20 20 20 20   (begin..       
6d10: 28 70 72 69 6e 74 20 22 55 70 64 61 74 69 6e 67  (print "Updating
6d20: 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 22   " test-name " "
6d30: 20 66 6c 64 20 22 20 74 6f 20 22 20 76 61 6c 29   fld " to " val)
6d40: 0a 09 20 20 20 20 20 20 20 28 64 62 3a 74 65 73  ..       (db:tes
6d50: 74 6d 65 74 61 2d 75 70 64 61 74 65 2d 66 69 65  tmeta-update-fie
6d60: 6c 64 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 20  ld db test-name 
6d70: 66 6c 64 20 76 61 6c 29 29 29 29 29 0a 20 20 20  fld val))))).   
6d80: 20 20 27 28 28 22 61 75 74 68 6f 72 22 20 32 29    '(("author" 2)
6d90: 28 22 6f 77 6e 65 72 22 20 33 29 28 22 64 65 73  ("owner" 3)("des
6da0: 63 72 69 70 74 69 6f 6e 22 20 34 29 28 22 72 65  cription" 4)("re
6db0: 76 69 65 77 65 64 22 20 35 29 28 22 74 61 67 73  viewed" 5)("tags
6dc0: 22 20 39 29 29 29 29 29 0a 0a 3b 3b 20 55 70 64  " 9)))))..;; Upd
6dd0: 61 74 65 20 74 65 73 74 5f 6d 65 74 61 20 66 6f  ate test_meta fo
6de0: 72 20 61 6c 6c 20 74 65 73 74 73 0a 28 64 65 66  r all tests.(def
6df0: 69 6e 65 20 28 72 75 6e 73 3a 75 70 64 61 74 65  ine (runs:update
6e00: 2d 61 6c 6c 2d 74 65 73 74 5f 6d 65 74 61 20 64  -all-test_meta d
6e10: 62 29 0a 20 20 28 6c 65 74 20 28 28 74 65 73 74  b).  (let ((test
6e20: 2d 6e 61 6d 65 73 20 28 67 65 74 2d 61 6c 6c 2d  -names (get-all-
6e30: 6c 65 67 61 6c 2d 74 65 73 74 73 29 29 29 0a 20  legal-tests))). 
6e40: 20 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 20     (for-each .  
6e50: 20 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74     (lambda (test
6e60: 2d 6e 61 6d 65 29 0a 20 20 20 20 20 20 20 28 6c  -name).       (l
6e70: 65 74 2a 20 28 28 74 65 73 74 2d 70 61 74 68 20  et* ((test-path 
6e80: 20 20 20 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74     (conc *toppat
6e90: 68 2a 20 22 2f 74 65 73 74 73 2f 22 20 74 65 73  h* "/tests/" tes
6ea0: 74 2d 6e 61 6d 65 29 29 0a 09 20 20 20 20 20 20  t-name))..      
6eb0: 28 74 65 73 74 2d 63 6f 6e 66 69 67 66 20 28 63  (test-configf (c
6ec0: 6f 6e 63 20 74 65 73 74 2d 70 61 74 68 20 22 2f  onc test-path "/
6ed0: 74 65 73 74 63 6f 6e 66 69 67 22 29 29 0a 09 20  testconfig")).. 
6ee0: 20 20 20 20 20 28 74 65 73 74 65 78 69 73 74 73       (testexists
6ef0: 20 20 20 28 61 6e 64 20 28 66 69 6c 65 2d 65 78     (and (file-ex
6f00: 69 73 74 73 3f 20 74 65 73 74 2d 63 6f 6e 66 69  ists? test-confi
6f10: 67 66 29 28 66 69 6c 65 2d 72 65 61 64 2d 61 63  gf)(file-read-ac
6f20: 63 65 73 73 3f 20 74 65 73 74 2d 63 6f 6e 66 69  cess? test-confi
6f30: 67 66 29 29 29 0a 09 20 20 20 20 20 20 3b 3b 20  gf)))..      ;; 
6f40: 72 65 61 64 20 63 6f 6e 66 69 67 73 20 77 69 74  read configs wit
6f50: 68 20 74 72 69 63 6b 73 20 74 75 72 6e 65 64 20  h tricks turned 
6f60: 6f 66 66 20 28 69 2e 65 2e 20 6e 6f 20 73 79 73  off (i.e. no sys
6f70: 74 65 6d 29 0a 09 20 20 20 20 20 20 28 74 65 73  tem)..      (tes
6f80: 74 2d 63 6f 6e 66 20 20 20 20 28 69 66 20 74 65  t-conf    (if te
6f90: 73 74 65 78 69 73 74 73 20 28 72 65 61 64 2d 63  stexists (read-c
6fa0: 6f 6e 66 69 67 20 74 65 73 74 2d 63 6f 6e 66 69  onfig test-confi
6fb0: 67 66 20 23 66 20 23 66 29 28 6d 61 6b 65 2d 68  gf #f #f)(make-h
6fc0: 61 73 68 2d 74 61 62 6c 65 29 29 29 29 0a 09 20  ash-table)))).. 
6fd0: 28 72 75 6e 73 3a 75 70 64 61 74 65 2d 74 65 73  (runs:update-tes
6fe0: 74 5f 6d 65 74 61 20 64 62 20 74 65 73 74 2d 6e  t_meta db test-n
6ff0: 61 6d 65 20 74 65 73 74 2d 63 6f 6e 66 29 29 29  ame test-conf)))
7000: 0a 20 20 20 20 20 74 65 73 74 2d 6e 61 6d 65 73  .     test-names
7010: 29 29 29 0a 0a 3b 3b 20 54 68 69 73 20 63 6f 75  )))..;; This cou
7020: 6c 64 20 70 72 6f 62 61 62 6c 79 20 62 65 20 72  ld probably be r
7030: 65 66 61 63 74 6f 72 65 64 20 69 6e 74 6f 20 6f  efactored into o
7040: 6e 65 20 63 6f 6d 70 6c 65 78 20 71 75 65 72 79  ne complex query
7050: 20 2e 2e 2e 0a 28 64 65 66 69 6e 65 20 28 72 75   ....(define (ru
7060: 6e 73 3a 72 6f 6c 6c 75 70 2d 72 75 6e 20 64 62  ns:rollup-run db
7070: 20 6b 65 79 73 20 6b 65 79 76 61 6c 6c 73 74 20   keys keyvallst 
7080: 72 75 6e 6e 61 6d 65 20 75 73 65 72 29 20 3b 3b  runname user) ;;
7090: 20 77 61 73 20 74 61 72 67 65 74 2c 20 6e 6f 77   was target, now
70a0: 20 6b 65 79 76 61 6c 6c 73 74 0a 20 20 28 64 65   keyvallst.  (de
70b0: 62 75 67 3a 70 72 69 6e 74 20 34 20 22 72 75 6e  bug:print 4 "run
70c0: 73 3a 72 6f 6c 6c 75 70 2d 72 75 6e 2c 20 6b 65  s:rollup-run, ke
70d0: 79 73 3a 20 22 20 6b 65 79 73 20 22 20 6b 65 79  ys: " keys " key
70e0: 76 61 6c 6c 73 74 3a 20 22 20 6b 65 79 76 61 6c  vallst: " keyval
70f0: 6c 73 74 20 22 20 3a 72 75 6e 6e 61 6d 65 20 22  lst " :runname "
7100: 20 72 75 6e 6e 61 6d 65 20 22 20 75 73 65 72 3a   runname " user:
7110: 20 22 20 75 73 65 72 29 0a 20 20 28 6c 65 74 2a   " user).  (let*
7120: 20 28 3b 20 28 6b 65 79 76 61 6c 6c 6c 73 74 20   (; (keyvalllst 
7130: 20 20 20 20 20 28 6b 65 79 73 3a 74 61 72 67 65       (keys:targe
7140: 74 2d 3e 6b 65 79 76 61 6c 20 6b 65 79 73 20 74  t->keyval keys t
7150: 61 72 67 65 74 29 29 0a 09 20 28 6e 65 77 2d 72  arget)).. (new-r
7160: 75 6e 2d 69 64 20 20 20 20 20 20 28 72 75 6e 73  un-id      (runs
7170: 3a 72 65 67 69 73 74 65 72 2d 72 75 6e 20 64 62  :register-run db
7180: 20 6b 65 79 73 20 6b 65 79 76 61 6c 6c 73 74 20   keys keyvallst 
7190: 72 75 6e 6e 61 6d 65 20 22 6e 65 77 22 20 22 6e  runname "new" "n
71a0: 2f 61 22 20 75 73 65 72 29 29 0a 09 20 28 70 72  /a" user)).. (pr
71b0: 65 76 2d 74 65 73 74 73 20 20 20 20 20 20 28 74  ev-tests      (t
71c0: 65 73 74 3a 67 65 74 2d 6d 61 74 63 68 69 6e 67  est:get-matching
71d0: 2d 70 72 65 76 69 6f 75 73 2d 74 65 73 74 2d 72  -previous-test-r
71e0: 75 6e 2d 72 65 63 6f 72 64 73 20 64 62 20 6e 65  un-records db ne
71f0: 77 2d 72 75 6e 2d 69 64 20 22 25 22 20 22 25 22  w-run-id "%" "%"
7200: 29 29 0a 09 20 28 63 75 72 72 2d 74 65 73 74 73  )).. (curr-tests
7210: 20 20 20 20 20 20 28 64 62 2d 67 65 74 2d 74 65        (db-get-te
7220: 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 6e  sts-for-run db n
7230: 65 77 2d 72 75 6e 2d 69 64 20 22 25 22 20 22 25  ew-run-id "%" "%
7240: 22 20 27 28 29 20 27 28 29 29 29 0a 09 20 28 63  " '() '())).. (c
7250: 75 72 72 2d 74 65 73 74 73 2d 68 61 73 68 20 28  urr-tests-hash (
7260: 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 29  make-hash-table)
7270: 29 29 0a 20 20 20 20 28 64 62 3a 75 70 64 61 74  )).    (db:updat
7280: 65 2d 72 75 6e 2d 65 76 65 6e 74 5f 74 69 6d 65  e-run-event_time
7290: 20 64 62 20 6e 65 77 2d 72 75 6e 2d 69 64 29 0a   db new-run-id).
72a0: 20 20 20 20 3b 3b 20 69 6e 64 65 78 20 74 68 65      ;; index the
72b0: 20 61 6c 72 65 61 64 79 20 73 61 76 65 64 20 74   already saved t
72c0: 65 73 74 73 20 62 79 20 74 65 73 74 6e 61 6d 65  ests by testname
72d0: 20 61 6e 64 20 69 74 65 6d 64 61 74 20 69 6e 20   and itemdat in 
72e0: 63 75 72 72 2d 74 65 73 74 73 2d 68 61 73 68 0a  curr-tests-hash.
72f0: 20 20 20 20 28 66 6f 72 2d 65 61 63 68 0a 20 20      (for-each.  
7300: 20 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74     (lambda (test
7310: 64 61 74 29 0a 20 20 20 20 20 20 20 28 6c 65 74  dat).       (let
7320: 2a 20 28 28 74 65 73 74 6e 61 6d 65 20 20 28 64  * ((testname  (d
7330: 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e  b:test-get-testn
7340: 61 6d 65 20 74 65 73 74 64 61 74 29 29 0a 09 20  ame testdat)).. 
7350: 20 20 20 20 20 28 69 74 65 6d 2d 70 61 74 68 20       (item-path 
7360: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65  (db:test-get-ite
7370: 6d 2d 70 61 74 68 20 74 65 73 74 64 61 74 29 29  m-path testdat))
7380: 0a 09 20 20 20 20 20 20 28 66 75 6c 6c 2d 6e 61  ..      (full-na
7390: 6d 65 20 28 63 6f 6e 63 20 74 65 73 74 6e 61 6d  me (conc testnam
73a0: 65 20 22 2f 22 20 69 74 65 6d 2d 70 61 74 68 29  e "/" item-path)
73b0: 29 29 0a 09 20 28 68 61 73 68 2d 74 61 62 6c 65  )).. (hash-table
73c0: 2d 73 65 74 21 20 63 75 72 72 2d 74 65 73 74 73  -set! curr-tests
73d0: 2d 68 61 73 68 20 66 75 6c 6c 2d 6e 61 6d 65 20  -hash full-name 
73e0: 74 65 73 74 64 61 74 29 29 29 0a 20 20 20 20 20  testdat))).     
73f0: 63 75 72 72 2d 74 65 73 74 73 29 0a 20 20 20 20  curr-tests).    
7400: 3b 3b 20 4e 4f 50 45 3a 20 4e 6f 6e 2d 6f 70 74  ;; NOPE: Non-opt
7410: 69 6d 61 6c 20 61 70 70 72 6f 61 63 68 2e 20 54  imal approach. T
7420: 72 79 20 74 68 69 73 20 69 6e 73 74 65 61 64 2e  ry this instead.
7430: 0a 20 20 20 20 3b 3b 20 20 20 31 2e 20 74 65 73  .    ;;   1. tes
7440: 74 73 20 61 72 65 20 72 65 63 65 69 76 65 64 20  ts are received 
7450: 69 6e 20 61 20 6c 69 73 74 2c 20 6d 6f 73 74 20  in a list, most 
7460: 72 65 63 65 6e 74 20 66 69 72 73 74 0a 20 20 20  recent first.   
7470: 20 3b 3b 20 20 20 32 2e 20 72 65 70 6c 61 63 65   ;;   2. replace
7480: 20 74 68 65 20 72 6f 6c 6c 75 70 20 74 65 73 74   the rollup test
7490: 20 77 69 74 68 20 74 68 65 20 6e 65 77 20 2a 61   with the new *a
74a0: 6c 77 61 79 73 2a 0a 20 20 20 20 28 66 6f 72 2d  lways*.    (for-
74b0: 65 61 63 68 20 0a 20 20 20 20 20 28 6c 61 6d 62  each .     (lamb
74c0: 64 61 20 28 74 65 73 74 64 61 74 29 0a 20 20 20  da (testdat).   
74d0: 20 20 20 20 28 6c 65 74 2a 20 28 28 74 65 73 74      (let* ((test
74e0: 6e 61 6d 65 20 20 28 64 62 3a 74 65 73 74 2d 67  name  (db:test-g
74f0: 65 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74  et-testname test
7500: 64 61 74 29 29 0a 09 20 20 20 20 20 20 28 69 74  dat))..      (it
7510: 65 6d 2d 70 61 74 68 20 28 64 62 3a 74 65 73 74  em-path (db:test
7520: 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74  -get-item-path t
7530: 65 73 74 64 61 74 29 29 0a 09 20 20 20 20 20 20  estdat))..      
7540: 28 66 75 6c 6c 2d 6e 61 6d 65 20 28 63 6f 6e 63  (full-name (conc
7550: 20 74 65 73 74 6e 61 6d 65 20 22 2f 22 20 69 74   testname "/" it
7560: 65 6d 2d 70 61 74 68 29 29 0a 09 20 20 20 20 20  em-path))..     
7570: 20 28 70 72 65 76 2d 74 65 73 74 2d 64 61 74 20   (prev-test-dat 
7580: 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f  (hash-table-ref/
7590: 64 65 66 61 75 6c 74 20 63 75 72 72 2d 74 65 73  default curr-tes
75a0: 74 73 2d 68 61 73 68 20 66 75 6c 6c 2d 6e 61 6d  ts-hash full-nam
75b0: 65 20 23 66 29 29 0a 09 20 20 20 20 20 20 28 74  e #f))..      (t
75c0: 65 73 74 2d 73 74 65 70 73 20 20 20 20 20 20 28  est-steps      (
75d0: 64 62 3a 67 65 74 2d 73 74 65 70 73 2d 66 6f 72  db:get-steps-for
75e0: 2d 74 65 73 74 20 64 62 20 28 64 62 3a 74 65 73  -test db (db:tes
75f0: 74 2d 67 65 74 2d 69 64 20 74 65 73 74 64 61 74  t-get-id testdat
7600: 29 29 29 0a 09 20 20 20 20 20 20 28 6e 65 77 2d  )))..      (new-
7610: 74 65 73 74 2d 72 65 63 6f 72 64 20 23 66 29 29  test-record #f))
7620: 0a 09 20 3b 3b 20 72 65 70 6c 61 63 65 20 74 68  .. ;; replace th
7630: 65 73 65 20 77 69 74 68 20 69 6e 73 65 72 74 20  ese with insert 
7640: 2e 2e 2e 20 73 65 6c 65 63 74 0a 09 20 28 61 70  ... select.. (ap
7650: 70 6c 79 20 73 71 6c 69 74 65 33 3a 65 78 65 63  ply sqlite3:exec
7660: 75 74 65 20 0a 09 09 64 62 20 0a 09 09 28 63 6f  ute ...db ...(co
7670: 6e 63 20 22 49 4e 53 45 52 54 20 4f 52 20 52 45  nc "INSERT OR RE
7680: 50 4c 41 43 45 20 49 4e 54 4f 20 74 65 73 74 73  PLACE INTO tests
7690: 20 28 72 75 6e 5f 69 64 2c 74 65 73 74 6e 61 6d   (run_id,testnam
76a0: 65 2c 73 74 61 74 65 2c 73 74 61 74 75 73 2c 65  e,state,status,e
76b0: 76 65 6e 74 5f 74 69 6d 65 2c 68 6f 73 74 2c 63  vent_time,host,c
76c0: 70 75 6c 6f 61 64 2c 64 69 73 6b 66 72 65 65 2c  puload,diskfree,
76d0: 75 6e 61 6d 65 2c 72 75 6e 64 69 72 2c 69 74 65  uname,rundir,ite
76e0: 6d 5f 70 61 74 68 2c 72 75 6e 5f 64 75 72 61 74  m_path,run_durat
76f0: 69 6f 6e 2c 66 69 6e 61 6c 5f 6c 6f 67 66 2c 63  ion,final_logf,c
7700: 6f 6d 6d 65 6e 74 29 20 22 0a 09 09 20 20 20 20  omment) "...    
7710: 20 20 22 56 41 4c 55 45 53 20 28 3f 2c 3f 2c 3f    "VALUES (?,?,?
7720: 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f  ,?,?,?,?,?,?,?,?
7730: 2c 3f 2c 3f 2c 3f 29 3b 22 29 0a 09 09 6e 65 77  ,?,?,?);")...new
7740: 2d 72 75 6e 2d 69 64 20 28 63 64 64 72 20 28 76  -run-id (cddr (v
7750: 65 63 74 6f 72 2d 3e 6c 69 73 74 20 74 65 73 74  ector->list test
7760: 64 61 74 29 29 29 0a 09 20 28 73 65 74 21 20 6e  dat))).. (set! n
7770: 65 77 2d 74 65 73 74 64 61 74 20 28 63 61 72 20  ew-testdat (car 
7780: 28 64 62 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f  (db-get-tests-fo
7790: 72 2d 72 75 6e 20 64 62 20 6e 65 77 2d 72 75 6e  r-run db new-run
77a0: 2d 69 64 20 74 65 73 74 6e 61 6d 65 20 69 74 65  -id testname ite
77b0: 6d 2d 70 61 74 68 20 27 28 29 20 27 28 29 29 29  m-path '() '()))
77c0: 29 0a 09 20 28 68 61 73 68 2d 74 61 62 6c 65 2d  ).. (hash-table-
77d0: 73 65 74 21 20 63 75 72 72 2d 74 65 73 74 73 2d  set! curr-tests-
77e0: 68 61 73 68 20 66 75 6c 6c 2d 6e 61 6d 65 20 6e  hash full-name n
77f0: 65 77 2d 74 65 73 74 64 61 74 29 20 3b 3b 20 74  ew-testdat) ;; t
7800: 68 69 73 20 63 6f 75 6c 64 20 62 65 20 63 6f 6e  his could be con
7810: 66 75 73 69 6e 67 2c 20 77 68 69 63 68 20 72 65  fusing, which re
7820: 63 6f 72 64 20 73 68 6f 75 6c 64 20 67 6f 20 69  cord should go i
7830: 6e 74 6f 20 74 68 65 20 6c 6f 6f 6b 75 70 20 74  nto the lookup t
7840: 61 62 6c 65 3f 0a 09 20 3b 3b 20 4e 6f 77 20 64  able?.. ;; Now d
7850: 75 70 6c 69 63 61 74 65 20 74 68 65 20 74 65 73  uplicate the tes
7860: 74 20 73 74 65 70 73 0a 09 20 28 64 65 62 75 67  t steps.. (debug
7870: 3a 70 72 69 6e 74 20 34 20 22 43 6f 70 79 69 6e  :print 4 "Copyin
7880: 67 20 72 65 63 6f 72 64 73 20 69 6e 20 74 65 73  g records in tes
7890: 74 5f 73 74 65 70 73 20 66 72 6f 6d 20 74 65 73  t_steps from tes
78a0: 74 5f 69 64 3d 22 20 28 64 62 3a 74 65 73 74 2d  t_id=" (db:test-
78b0: 67 65 74 2d 69 64 20 74 65 73 74 64 61 74 29 20  get-id testdat) 
78c0: 22 20 74 6f 20 22 20 28 64 62 3a 74 65 73 74 2d  " to " (db:test-
78d0: 67 65 74 2d 69 64 20 6e 65 77 2d 74 65 73 74 64  get-id new-testd
78e0: 61 74 29 29 0a 09 20 28 73 71 6c 69 74 65 33 3a  at)).. (sqlite3:
78f0: 65 78 65 63 75 74 65 20 0a 09 20 20 64 62 20 0a  execute ..  db .
7900: 09 20 20 28 63 6f 6e 63 20 22 49 4e 53 45 52 54  .  (conc "INSERT
7910: 20 4f 52 20 52 45 50 4c 41 43 45 20 49 4e 54 4f   OR REPLACE INTO
7920: 20 74 65 73 74 5f 73 74 65 70 73 20 28 74 65 73   test_steps (tes
7930: 74 5f 69 64 2c 73 74 65 70 6e 61 6d 65 2c 73 74  t_id,stepname,st
7940: 61 74 65 2c 73 74 61 74 75 73 2c 65 76 65 6e 74  ate,status,event
7950: 5f 74 69 6d 65 2c 63 6f 6d 6d 65 6e 74 29 20 22  _time,comment) "
7960: 0a 09 09 22 53 45 4c 45 43 54 20 22 20 28 64 62  ..."SELECT " (db
7970: 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 6e 65 77  :test-get-id new
7980: 2d 74 65 73 74 64 61 74 29 20 22 2c 73 74 65 70  -testdat) ",step
7990: 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 61 74 75  name,state,statu
79a0: 73 2c 65 76 65 6e 74 5f 74 69 6d 65 2c 63 6f 6d  s,event_time,com
79b0: 6d 65 6e 74 20 46 52 4f 4d 20 74 65 73 74 5f 73  ment FROM test_s
79c0: 74 65 70 73 20 57 48 45 52 45 20 74 65 73 74 5f  teps WHERE test_
79d0: 69 64 3d 3f 3b 22 29 0a 09 20 20 28 64 62 3a 74  id=?;")..  (db:t
79e0: 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74 64  est-get-id testd
79f0: 61 74 29 29 0a 09 20 3b 3b 20 4e 6f 77 20 64 75  at)).. ;; Now du
7a00: 70 6c 69 63 61 74 65 20 74 68 65 20 74 65 73 74  plicate the test
7a10: 20 64 61 74 61 0a 09 20 28 64 65 62 75 67 3a 70   data.. (debug:p
7a20: 72 69 6e 74 20 34 20 22 43 6f 70 79 69 6e 67 20  rint 4 "Copying 
7a30: 72 65 63 6f 72 64 73 20 69 6e 20 74 65 73 74 5f  records in test_
7a40: 64 61 74 61 20 66 72 6f 6d 20 74 65 73 74 5f 69  data from test_i
7a50: 64 3d 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74  d=" (db:test-get
7a60: 2d 69 64 20 74 65 73 74 64 61 74 29 20 22 20 74  -id testdat) " t
7a70: 6f 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74  o " (db:test-get
7a80: 2d 69 64 20 6e 65 77 2d 74 65 73 74 64 61 74 29  -id new-testdat)
7a90: 29 0a 09 20 28 73 71 6c 69 74 65 33 3a 65 78 65  ).. (sqlite3:exe
7aa0: 63 75 74 65 20 0a 09 20 20 64 62 20 0a 09 20 20  cute ..  db ..  
7ab0: 28 63 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f 52  (conc "INSERT OR
7ac0: 20 52 45 50 4c 41 43 45 20 49 4e 54 4f 20 74 65   REPLACE INTO te
7ad0: 73 74 5f 64 61 74 61 20 28 74 65 73 74 5f 69 64  st_data (test_id
7ae0: 2c 63 61 74 65 67 6f 72 79 2c 76 61 72 69 61 62  ,category,variab
7af0: 6c 65 2c 76 61 6c 75 65 2c 65 78 70 65 63 74 65  le,value,expecte
7b00: 64 2c 74 6f 6c 2c 75 6e 69 74 73 2c 63 6f 6d 6d  d,tol,units,comm
7b10: 65 6e 74 29 20 22 0a 09 09 22 53 45 4c 45 43 54  ent) "..."SELECT
7b20: 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d   " (db:test-get-
7b30: 69 64 20 6e 65 77 2d 74 65 73 74 64 61 74 29 20  id new-testdat) 
7b40: 22 2c 63 61 74 65 67 6f 72 79 2c 76 61 72 69 61  ",category,varia
7b50: 62 6c 65 2c 76 61 6c 75 65 2c 65 78 70 65 63 74  ble,value,expect
7b60: 65 64 2c 74 6f 6c 2c 75 6e 69 74 73 2c 63 6f 6d  ed,tol,units,com
7b70: 6d 65 6e 74 20 46 52 4f 4d 20 74 65 73 74 5f 64  ment FROM test_d
7b80: 61 74 61 20 57 48 45 52 45 20 74 65 73 74 5f 69  ata WHERE test_i
7b90: 64 3d 3f 3b 22 29 0a 09 20 20 28 64 62 3a 74 65  d=?;")..  (db:te
7ba0: 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74 64 61  st-get-id testda
7bb0: 74 29 29 0a 09 20 29 29 0a 20 20 20 20 20 70 72  t)).. )).     pr
7bc0: 65 76 2d 74 65 73 74 73 29 29 29 0a 09 20 0a 20  ev-tests))).. . 
7bd0: 20 20 20 20 0a                                       .