Megatest

Hex Artifact Content
Login

Artifact 6ee5dc7a4131aeb6cc06329bf32da8ae6fbecf16:


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 0a  e? items)      .
2840: 09 09 09 09 09 09 20 28 64 65 62 75 67 3a 70 72  ...... (debug:pr
2850: 69 6e 74 20 34 20 22 49 4e 46 4f 3a 20 69 74 65  int 4 "INFO: ite
2860: 6d 73 20 69 73 20 61 20 70 72 6f 63 65 64 75 72  ms is a procedur
2870: 65 2c 20 77 69 6c 6c 20 63 61 6c 63 20 6c 61 74  e, will calc lat
2880: 65 72 22 29 0a 09 09 09 09 09 09 20 69 74 65 6d  er")....... item
2890: 73 29 20 20 20 20 20 20 20 20 20 20 20 20 3b 3b  s)            ;;
28a0: 20 63 61 6c 63 20 6c 61 74 65 72 0a 09 09 09 09   calc later.....
28b0: 09 09 28 28 70 72 6f 63 65 64 75 72 65 3f 20 69  ..((procedure? i
28c0: 74 65 6d 73 74 61 62 6c 65 29 0a 09 09 09 09 09  temstable)......
28d0: 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34  . (debug:print 4
28e0: 20 22 49 4e 46 4f 3a 20 69 74 65 6d 73 74 61 62   "INFO: itemstab
28f0: 6c 65 20 69 73 20 61 20 70 72 6f 63 65 64 75 72  le is a procedur
2900: 65 2c 20 77 69 6c 6c 20 63 61 6c 63 20 6c 61 74  e, will calc lat
2910: 65 72 22 29 0a 09 09 09 09 09 09 20 69 74 65 6d  er")....... item
2920: 73 74 61 62 6c 65 29 20 20 20 20 20 20 20 3b 3b  stable)       ;;
2930: 20 63 61 6c 63 20 6c 61 74 65 72 0a 09 09 09 09   calc later.....
2940: 09 09 28 28 66 69 6c 74 65 72 20 28 6c 61 6d 62  ..((filter (lamb
2950: 64 61 20 28 78 29 0a 09 09 09 09 09 09 09 20 20  da (x)........  
2960: 20 28 6c 65 74 20 28 28 76 61 6c 20 28 63 61 72   (let ((val (car
2970: 20 78 29 29 29 0a 09 09 09 09 09 09 09 20 20 20   x)))........   
2980: 20 20 28 69 66 20 28 70 72 6f 63 65 64 75 72 65    (if (procedure
2990: 3f 20 76 61 6c 29 20 76 61 6c 20 23 66 29 29 29  ? val) val #f)))
29a0: 0a 09 09 09 09 09 09 09 20 28 61 70 70 65 6e 64  ........ (append
29b0: 20 28 69 66 20 28 6c 69 73 74 3f 20 69 74 65 6d   (if (list? item
29c0: 73 29 20 69 74 65 6d 73 20 27 28 29 29 0a 09 09  s) items '())...
29d0: 09 09 09 09 09 09 20 28 69 66 20 28 6c 69 73 74  ...... (if (list
29e0: 3f 20 69 74 65 6d 73 74 61 62 6c 65 29 20 69 74  ? itemstable) it
29f0: 65 6d 73 74 61 62 6c 65 20 27 28 29 29 29 29 0a  emstable '()))).
2a00: 09 09 09 09 09 09 20 27 68 61 76 65 2d 70 72 6f  ...... 'have-pro
2a10: 63 65 64 75 72 65 29 0a 09 09 09 09 09 09 28 28  cedure).......((
2a20: 6f 72 20 28 6c 69 73 74 3f 20 69 74 65 6d 73 29  or (list? items)
2a30: 28 6c 69 73 74 3f 20 69 74 65 6d 73 74 61 62 6c  (list? itemstabl
2a40: 65 29 29 20 3b 3b 20 63 61 6c 63 20 6e 6f 77 0a  e)) ;; calc now.
2a50: 09 09 09 09 09 09 20 28 64 65 62 75 67 3a 70 72  ...... (debug:pr
2a60: 69 6e 74 20 34 20 22 49 4e 46 4f 3a 20 69 74 65  int 4 "INFO: ite
2a70: 6d 73 20 61 6e 64 20 69 74 65 6d 73 74 61 62 6c  ms and itemstabl
2a80: 65 20 61 72 65 20 6c 69 73 74 73 2c 20 63 61 6c  e are lists, cal
2a90: 63 20 6e 6f 77 5c 6e 22 0a 09 09 09 09 09 09 09  c now\n"........
2aa0: 20 20 20 20 20 20 22 20 20 20 20 69 74 65 6d 73        "    items
2ab0: 3a 20 22 20 69 74 65 6d 73 20 22 20 69 74 65 6d  : " items " item
2ac0: 73 74 61 62 6c 65 3a 20 22 20 69 74 65 6d 73 74  stable: " itemst
2ad0: 61 62 6c 65 29 0a 09 09 09 09 09 09 20 28 69 74  able)....... (it
2ae0: 65 6d 73 3a 67 65 74 2d 69 74 65 6d 73 2d 66 72  ems:get-items-fr
2af0: 6f 6d 2d 63 6f 6e 66 69 67 20 63 6f 6e 66 69 67  om-config config
2b00: 29 29 0a 09 09 09 09 09 09 28 65 6c 73 65 20 23  )).......(else #
2b10: 66 29 29 29 20 20 20 20 20 20 20 20 20 20 20 20  f)))            
2b20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b                 ;
2b30: 3b 20 6e 6f 74 20 69 74 65 72 61 74 65 64 0a 09  ; not iterated..
2b40: 09 09 09 09 20 20 20 20 20 23 66 20 20 20 20 20  ....     #f     
2b50: 20 3b 3b 20 69 74 65 6d 73 64 61 74 20 35 0a 09   ;; itemsdat 5..
2b60: 09 09 09 09 20 20 20 20 20 3b 3b 20 23 66 20 20  ....     ;; #f  
2b70: 20 20 20 20 3b 3b 20 73 70 61 72 65 0a 09 09 09      ;; spare....
2b80: 09 09 20 20 20 20 20 29 29 29 0a 09 20 20 20 20  ..     )))..    
2b90: 28 66 6f 72 2d 65 61 63 68 20 0a 09 20 20 20 20  (for-each ..    
2ba0: 20 28 6c 61 6d 62 64 61 20 28 77 61 69 74 6f 6e   (lambda (waiton
2bb0: 29 0a 09 20 20 20 20 20 20 20 28 69 66 20 28 61  )..       (if (a
2bc0: 6e 64 20 77 61 69 74 6f 6e 20 28 6e 6f 74 20 28  nd waiton (not (
2bd0: 6d 65 6d 62 65 72 20 77 61 69 74 6f 6e 20 74 65  member waiton te
2be0: 73 74 2d 6e 61 6d 65 73 29 29 29 0a 09 09 20 20  st-names)))...  
2bf0: 20 28 62 65 67 69 6e 0a 09 09 20 20 20 20 20 28   (begin...     (
2c00: 73 65 74 21 20 72 65 71 75 69 72 65 64 2d 74 65  set! required-te
2c10: 73 74 73 20 28 63 6f 6e 73 20 77 61 69 74 6f 6e  sts (cons waiton
2c20: 20 72 65 71 75 69 72 65 64 2d 74 65 73 74 73 29   required-tests)
2c30: 29 0a 09 09 20 20 20 20 20 28 73 65 74 21 20 74  )...     (set! t
2c40: 65 73 74 2d 6e 61 6d 65 73 20 28 63 6f 6e 73 20  est-names (cons 
2c50: 77 61 69 74 6f 6e 20 74 65 73 74 2d 6e 61 6d 65  waiton test-name
2c60: 73 29 29 29 29 29 20 3b 3b 20 77 61 73 20 61 6e  s))))) ;; was an
2c70: 20 61 70 70 65 6e 64 2c 20 6e 6f 77 20 61 20 63   append, now a c
2c80: 6f 6e 73 0a 09 20 20 20 20 20 77 61 69 74 6f 6e  ons..     waiton
2c90: 73 29 0a 09 20 20 20 20 28 6c 65 74 20 28 28 72  s)..    (let ((r
2ca0: 65 6d 74 65 73 74 73 20 28 64 65 6c 65 74 65 2d  emtests (delete-
2cb0: 64 75 70 6c 69 63 61 74 65 73 20 28 61 70 70 65  duplicates (appe
2cc0: 6e 64 20 77 61 69 74 6f 6e 73 20 74 61 6c 29 29  nd waitons tal))
2cd0: 29 29 0a 09 20 20 20 20 20 20 28 69 66 20 28 6e  ))..      (if (n
2ce0: 6f 74 20 28 6e 75 6c 6c 3f 20 72 65 6d 74 65 73  ot (null? remtes
2cf0: 74 73 29 29 0a 09 09 20 20 28 6c 6f 6f 70 20 28  ts))...  (loop (
2d00: 63 61 72 20 72 65 6d 74 65 73 74 73 29 28 63 64  car remtests)(cd
2d10: 72 20 72 65 6d 74 65 73 74 73 29 29 29 29 29 29  r remtests))))))
2d20: 29 0a 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20  )..    (if (not 
2d30: 28 6e 75 6c 6c 3f 20 72 65 71 75 69 72 65 64 2d  (null? required-
2d40: 74 65 73 74 73 29 29 0a 09 28 64 65 62 75 67 3a  tests))..(debug:
2d50: 70 72 69 6e 74 20 31 20 22 49 4e 46 4f 3a 20 41  print 1 "INFO: A
2d60: 64 64 69 6e 67 20 22 20 72 65 71 75 69 72 65 64  dding " required
2d70: 2d 74 65 73 74 73 20 22 20 74 6f 20 74 68 65 20  -tests " to the 
2d80: 72 75 6e 20 71 75 65 75 65 22 29 29 0a 20 20 20  run queue")).   
2d90: 20 3b 3b 20 4e 4f 54 45 3a 20 74 68 65 73 65 20   ;; NOTE: these 
2da0: 61 72 65 20 61 6c 6c 20 70 61 72 65 6e 74 20 74  are all parent t
2db0: 65 73 74 73 2c 20 69 74 65 6d 73 20 61 72 65 20  ests, items are 
2dc0: 6e 6f 74 20 65 78 70 61 6e 64 65 64 20 79 65 74  not expanded yet
2dd0: 2e 0a 20 20 20 20 28 72 75 6e 73 3a 72 75 6e 2d  ..    (runs:run-
2de0: 74 65 73 74 73 2d 71 75 65 75 65 20 64 62 20 72  tests-queue db r
2df0: 75 6e 2d 69 64 20 72 75 6e 6e 61 6d 65 20 74 65  un-id runname te
2e00: 73 74 2d 72 65 63 6f 72 64 73 20 6b 65 79 76 61  st-records keyva
2e10: 6c 6c 73 74 20 66 6c 61 67 73 29 0a 20 20 20 20  llst flags).    
2e20: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22  (debug:print 4 "
2e30: 49 4e 46 4f 3a 20 41 6c 6c 20 64 6f 6e 65 20 62  INFO: All done b
2e40: 79 20 68 65 72 65 22 29 29 29 0a 0a 28 64 65 66  y here")))..(def
2e50: 69 6e 65 20 28 72 75 6e 73 3a 72 75 6e 2d 74 65  ine (runs:run-te
2e60: 73 74 73 2d 71 75 65 75 65 20 64 62 20 72 75 6e  sts-queue db run
2e70: 2d 69 64 20 72 75 6e 6e 61 6d 65 20 74 65 73 74  -id runname test
2e80: 2d 72 65 63 6f 72 64 73 20 6b 65 79 76 61 6c 6c  -records keyvall
2e90: 73 74 20 66 6c 61 67 73 29 0a 20 20 20 20 3b 3b  st flags).    ;;
2ea0: 20 41 74 20 74 68 69 73 20 70 6f 69 6e 74 20 74   At this point t
2eb0: 68 65 20 6c 69 73 74 20 6f 66 20 70 61 72 65 6e  he list of paren
2ec0: 74 20 74 65 73 74 73 20 69 73 20 65 78 70 61 6e  t tests is expan
2ed0: 64 65 64 20 0a 20 20 20 20 3b 3b 20 4e 42 2f 2f  ded .    ;; NB//
2ee0: 20 53 68 6f 75 6c 64 20 65 78 70 61 6e 64 20 69   Should expand i
2ef0: 74 65 6d 73 20 68 65 72 65 20 61 6e 64 20 74 68  tems here and th
2f00: 65 6e 20 69 6e 73 65 72 74 20 69 6e 74 6f 20 74  en insert into t
2f10: 68 65 20 72 75 6e 20 71 75 65 75 65 2e 0a 20 20  he run queue..  
2f20: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 35 20 22  (debug:print 5 "
2f30: 74 65 73 74 2d 72 65 63 6f 72 64 73 3a 20 22 20  test-records: " 
2f40: 74 65 73 74 2d 72 65 63 6f 72 64 73 20 22 2c 20  test-records ", 
2f50: 6b 65 79 76 61 6c 6c 73 74 3a 20 22 20 6b 65 79  keyvallst: " key
2f60: 76 61 6c 6c 73 74 29 0a 20 20 28 6c 65 74 20 28  vallst).  (let (
2f70: 28 73 6f 72 74 65 64 2d 74 65 73 74 2d 6e 61 6d  (sorted-test-nam
2f80: 65 73 20 28 74 65 73 74 73 3a 73 6f 72 74 2d 62  es (tests:sort-b
2f90: 79 2d 70 72 69 6f 72 69 74 79 2d 61 6e 64 2d 77  y-priority-and-w
2fa0: 61 69 74 6f 6e 20 74 65 73 74 2d 72 65 63 6f 72  aiton test-recor
2fb0: 64 73 29 29 0a 09 28 69 74 65 6d 2d 70 61 74 74  ds))..(item-patt
2fc0: 73 20 20 20 20 20 20 20 20 28 68 61 73 68 2d 74  s        (hash-t
2fd0: 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74  able-ref/default
2fe0: 20 66 6c 61 67 73 20 22 2d 69 74 65 6d 70 61 74   flags "-itempat
2ff0: 74 22 20 23 66 29 29 29 0a 20 20 20 20 28 6c 65  t" #f))).    (le
3000: 74 20 6c 6f 6f 70 20 28 3b 20 28 6e 75 6d 74 69  t loop (; (numti
3010: 6d 65 73 20 30 29 20 3b 3b 20 73 68 6f 75 6c 64  mes 0) ;; should
3020: 6e 27 74 20 6e 65 65 64 20 74 68 69 73 0a 09 20  n't need this.. 
3030: 20 20 20 20 20 20 28 68 65 64 20 20 20 20 20 20        (hed      
3040: 20 20 20 28 63 61 72 20 73 6f 72 74 65 64 2d 74     (car sorted-t
3050: 65 73 74 2d 6e 61 6d 65 73 29 29 0a 09 20 20 20  est-names))..   
3060: 20 20 20 20 28 74 61 6c 20 20 20 20 20 20 20 20      (tal        
3070: 20 28 63 64 72 20 73 6f 72 74 65 64 2d 74 65 73   (cdr sorted-tes
3080: 74 2d 6e 61 6d 65 73 29 29 29 0a 20 20 20 20 20  t-names))).     
3090: 20 28 6c 65 74 2a 20 28 28 74 65 73 74 2d 72 65   (let* ((test-re
30a0: 63 6f 72 64 20 28 68 61 73 68 2d 74 61 62 6c 65  cord (hash-table
30b0: 2d 72 65 66 20 74 65 73 74 2d 72 65 63 6f 72 64  -ref test-record
30c0: 73 20 68 65 64 29 29 0a 09 20 20 20 20 20 28 74  s hed))..     (t
30d0: 63 6f 6e 66 69 67 20 20 20 20 20 28 74 65 73 74  config     (test
30e0: 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d  s:testqueue-get-
30f0: 74 65 73 74 63 6f 6e 66 69 67 20 74 65 73 74 2d  testconfig test-
3100: 72 65 63 6f 72 64 29 29 0a 09 20 20 20 20 20 28  record))..     (
3110: 77 61 69 74 6f 6e 73 20 20 20 20 20 28 74 65 73  waitons     (tes
3120: 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74  ts:testqueue-get
3130: 2d 77 61 69 74 6f 6e 73 20 20 20 20 74 65 73 74  -waitons    test
3140: 2d 72 65 63 6f 72 64 29 29 0a 09 20 20 20 20 20  -record))..     
3150: 28 70 72 69 6f 72 69 74 79 20 20 20 20 28 74 65  (priority    (te
3160: 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65  sts:testqueue-ge
3170: 74 2d 70 72 69 6f 72 69 74 79 20 20 20 74 65 73  t-priority   tes
3180: 74 2d 72 65 63 6f 72 64 29 29 0a 09 20 20 20 20  t-record))..    
3190: 20 28 69 74 65 6d 64 61 74 20 20 20 20 20 28 74   (itemdat     (t
31a0: 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67  ests:testqueue-g
31b0: 65 74 2d 69 74 65 6d 64 61 74 20 20 20 20 74 65  et-itemdat    te
31c0: 73 74 2d 72 65 63 6f 72 64 29 29 0a 09 20 20 20  st-record))..   
31d0: 20 20 28 69 74 65 6d 73 20 20 20 20 20 20 20 28    (items       (
31e0: 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d  tests:testqueue-
31f0: 67 65 74 2d 69 74 65 6d 73 20 20 20 20 20 20 74  get-items      t
3200: 65 73 74 2d 72 65 63 6f 72 64 29 29 0a 09 20 20  est-record))..  
3210: 20 20 20 28 69 74 65 6d 2d 70 61 74 68 20 20 20     (item-path   
3220: 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68  (item-list->path
3230: 20 69 74 65 6d 64 61 74 29 29 29 0a 09 28 64 65   itemdat)))..(de
3240: 62 75 67 3a 70 72 69 6e 74 20 36 0a 09 09 20 20  bug:print 6...  
3250: 20 20 20 22 69 74 65 6d 64 61 74 3a 20 20 20 20     "itemdat:    
3260: 20 22 20 69 74 65 6d 64 61 74 0a 09 09 20 20 20   " itemdat...   
3270: 20 20 22 5c 6e 20 20 69 74 65 6d 73 3a 20 20 20    "\n  items:   
3280: 20 20 22 20 69 74 65 6d 73 0a 09 09 20 20 20 20    " items...    
3290: 20 22 5c 6e 20 20 69 74 65 6d 2d 70 61 74 68 3a   "\n  item-path:
32a0: 20 22 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 28   " item-path)..(
32b0: 63 6f 6e 64 0a 09 20 28 28 6e 6f 74 20 69 74 65  cond.. ((not ite
32c0: 6d 73 29 20 3b 3b 20 77 68 65 6e 20 66 61 6c 73  ms) ;; when fals
32d0: 65 20 74 68 65 20 74 65 73 74 20 69 73 20 6f 6b  e the test is ok
32e0: 20 74 6f 20 62 65 20 68 61 6e 64 65 64 20 6f 66   to be handed of
32f0: 66 20 74 6f 20 6c 61 75 6e 63 68 20 28 62 75 74  f to launch (but
3300: 20 6e 6f 74 20 62 65 66 6f 72 65 29 0a 09 20 20   not before)..  
3310: 28 6c 65 74 20 28 28 68 61 76 65 2d 72 65 73 6f  (let ((have-reso
3320: 75 72 63 65 73 20 20 28 72 75 6e 73 3a 63 61 6e  urces  (runs:can
3330: 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20  -run-more-tests 
3340: 64 62 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29  db test-record))
3350: 20 3b 3b 20 6c 6f 6f 6b 20 61 74 20 74 68 65 20   ;; look at the 
3360: 74 65 73 74 20 6a 6f 62 67 72 6f 75 70 20 61 6e  test jobgroup an
3370: 64 20 74 6f 74 20 6a 6f 62 73 20 72 75 6e 6e 69  d tot jobs runni
3380: 6e 67 0a 09 09 28 70 72 65 72 65 71 73 2d 6e 6f  ng...(prereqs-no
3390: 74 2d 6d 65 74 20 28 64 62 3a 67 65 74 2d 70 72  t-met (db:get-pr
33a0: 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 20 64 62  ereqs-not-met db
33b0: 20 72 75 6e 2d 69 64 20 77 61 69 74 6f 6e 73 20   run-id waitons 
33c0: 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 09 20 20  item-path)))..  
33d0: 20 20 3b 3b 20 44 6f 6e 27 74 20 6b 6e 6f 77 20    ;; Don't know 
33e0: 61 74 20 74 68 69 73 20 74 69 6d 65 20 69 66 20  at this time if 
33f0: 74 68 65 20 74 65 73 74 20 68 61 76 65 20 62 65  the test have be
3400: 65 6e 20 6c 61 75 6e 63 68 65 64 20 61 74 20 73  en launched at s
3410: 6f 6d 65 20 74 69 6d 65 20 69 6e 20 74 68 65 20  ome time in the 
3420: 70 61 73 74 0a 09 20 20 20 20 3b 3b 20 69 2e 65  past..    ;; i.e
3430: 2e 20 69 73 20 74 68 69 73 20 61 20 72 65 2d 6c  . is this a re-l
3440: 61 75 6e 63 68 3f 0a 09 20 20 20 20 28 69 66 20  aunch?..    (if 
3450: 28 61 6e 64 20 68 61 76 65 2d 72 65 73 6f 75 72  (and have-resour
3460: 63 65 73 0a 09 09 20 20 20 20 20 28 6e 75 6c 6c  ces...     (null
3470: 3f 20 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65  ? prereqs-not-me
3480: 74 29 29 0a 09 09 3b 3b 20 6e 6f 20 6c 6f 6f 70  t))...;; no loop
3490: 20 2d 20 64 72 6f 70 20 74 68 6f 75 67 68 20 61   - drop though a
34a0: 6e 64 20 75 73 65 20 74 68 65 20 6c 6f 6f 70 20  nd use the loop 
34b0: 61 74 20 74 68 65 20 62 6f 74 74 6f 6d 20 0a 09  at the bottom ..
34c0: 09 28 72 75 6e 3a 74 65 73 74 20 64 62 20 72 75  .(run:test db ru
34d0: 6e 2d 69 64 20 72 75 6e 6e 61 6d 65 20 6b 65 79  n-id runname key
34e0: 76 61 6c 6c 73 74 20 74 65 73 74 2d 72 65 63 6f  vallst test-reco
34f0: 72 64 20 66 6c 61 67 73 20 23 66 29 0a 09 09 3b  rd flags #f)...;
3500: 3b 20 65 6c 73 65 20 74 68 65 20 72 75 6e 20 69  ; else the run i
3510: 73 20 73 74 75 63 6b 2c 20 74 65 6d 70 6f 72 61  s stuck, tempora
3520: 72 69 6c 79 20 6f 72 20 70 65 72 6d 61 6e 65 6e  rily or permanen
3530: 74 6c 79 0a 09 09 28 6c 65 74 20 28 28 6e 65 77  tly...(let ((new
3540: 74 61 6c 20 28 61 70 70 65 6e 64 20 74 61 6c 20  tal (append tal 
3550: 28 6c 69 73 74 20 68 65 64 29 29 29 29 0a 09 09  (list hed))))...
3560: 20 20 3b 3b 20 63 6f 75 6c 64 6e 27 74 20 72 75    ;; couldn't ru
3570: 6e 2c 20 74 61 6b 65 20 61 20 62 72 65 61 74 68  n, take a breath
3580: 65 72 0a 09 09 20 20 28 74 68 72 65 61 64 2d 73  er...  (thread-s
3590: 6c 65 65 70 21 20 34 29 0a 09 09 20 20 28 6c 6f  leep! 4)...  (lo
35a0: 6f 70 20 28 63 61 72 20 6e 65 77 74 61 6c 29 28  op (car newtal)(
35b0: 63 64 72 20 6e 65 77 74 61 6c 29 29 29 29 29 29  cdr newtal))))))
35c0: 0a 09 20 0a 09 20 3b 3b 20 63 61 73 65 20 77 68  .. .. ;; case wh
35d0: 65 72 65 20 61 6e 20 69 74 65 6d 73 20 63 61 6d  ere an items cam
35e0: 65 20 69 6e 20 61 73 20 61 20 6c 69 73 74 20 62  e in as a list b
35f0: 65 65 6e 20 70 72 6f 63 65 73 73 65 64 0a 09 20  een processed.. 
3600: 28 28 61 6e 64 20 28 6c 69 73 74 3f 20 69 74 65  ((and (list? ite
3610: 6d 73 29 20 20 20 20 20 3b 3b 20 74 68 75 73 20  ms)     ;; thus 
3620: 77 65 20 6b 6e 6f 77 20 6f 75 72 20 69 74 65 6d  we know our item
3630: 73 20 61 72 65 20 61 6c 72 65 61 64 79 20 63 61  s are already ca
3640: 6c 63 75 6c 61 74 65 64 0a 09 20 20 20 20 20 20  lculated..      
3650: 20 28 6e 6f 74 20 20 20 69 74 65 6d 64 61 74 29   (not   itemdat)
3660: 29 20 3b 3b 20 61 6e 64 20 6e 6f 74 20 79 65 74  ) ;; and not yet
3670: 20 65 78 70 61 6e 64 65 64 20 69 6e 74 6f 20 74   expanded into t
3680: 68 65 20 6c 69 73 74 20 6f 66 20 74 68 69 6e 67  he list of thing
3690: 73 20 74 6f 20 62 65 20 64 6f 6e 65 0a 09 20 20  s to be done..  
36a0: 28 69 66 20 28 3e 3d 20 2a 76 65 72 62 6f 73 69  (if (>= *verbosi
36b0: 74 79 2a 20 31 29 28 70 70 20 69 74 65 6d 73 29  ty* 1)(pp items)
36c0: 29 0a 09 20 20 3b 3b 20 28 69 66 20 28 3e 3d 20  )..  ;; (if (>= 
36d0: 2a 76 65 72 62 6f 73 69 74 79 2a 20 35 29 0a 09  *verbosity* 5)..
36e0: 20 20 3b 3b 20 20 20 20 20 28 62 65 67 69 6e 0a    ;;     (begin.
36f0: 09 20 20 3b 3b 20 20 20 20 20 20 20 28 70 72 69  .  ;;       (pri
3700: 6e 74 20 22 69 74 65 6d 73 3a 20 22 29 20 20 20  nt "items: ")   
3710: 20 20 28 70 70 20 28 69 74 65 6d 2d 61 73 73 6f    (pp (item-asso
3720: 63 2d 3e 69 74 65 6d 2d 6c 69 73 74 20 69 74 65  c->item-list ite
3730: 6d 73 29 29 0a 09 20 20 3b 3b 20 20 20 20 20 20  ms))..  ;;      
3740: 20 28 70 72 69 6e 74 20 22 69 74 65 6d 73 74 61   (print "itemsta
3750: 62 6c 65 3a 20 22 29 28 70 70 20 28 69 74 65 6d  ble: ")(pp (item
3760: 2d 74 61 62 6c 65 2d 3e 69 74 65 6d 2d 6c 69 73  -table->item-lis
3770: 74 20 69 74 65 6d 73 74 61 62 6c 65 29 29 29 29  t itemstable))))
3780: 0a 09 20 20 28 66 6f 72 2d 65 61 63 68 0a 09 20  ..  (for-each.. 
3790: 20 20 28 6c 61 6d 62 64 61 20 28 6d 79 2d 69 74    (lambda (my-it
37a0: 65 6d 64 61 74 29 0a 09 20 20 20 20 20 28 6c 65  emdat)..     (le
37b0: 74 2a 20 28 28 6e 65 77 2d 74 65 73 74 2d 72 65  t* ((new-test-re
37c0: 63 6f 72 64 20 28 6c 65 74 20 28 28 6e 65 77 72  cord (let ((newr
37d0: 65 63 20 28 6d 61 6b 65 2d 74 65 73 74 73 3a 74  ec (make-tests:t
37e0: 65 73 74 71 75 65 75 65 29 29 29 0a 09 09 09 09  estqueue))).....
37f0: 20 20 20 20 20 20 20 28 76 65 63 74 6f 72 2d 63         (vector-c
3800: 6f 70 79 21 20 74 65 73 74 2d 72 65 63 6f 72 64  opy! test-record
3810: 20 6e 65 77 72 65 63 29 0a 09 09 09 09 20 20 20   newrec).....   
3820: 20 20 20 20 6e 65 77 72 65 63 29 29 0a 09 09 20      newrec))... 
3830: 20 20 20 28 6d 79 2d 69 74 65 6d 2d 70 61 74 68     (my-item-path
3840: 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74   (item-list->pat
3850: 68 20 6d 79 2d 69 74 65 6d 64 61 74 29 29 0a 09  h my-itemdat))..
3860: 09 20 20 20 20 28 69 74 65 6d 2d 6d 61 74 63 68  .    (item-match
3870: 65 73 20 28 69 66 20 69 74 65 6d 2d 70 61 74 74  es (if item-patt
3880: 73 20 20 20 20 20 20 20 3b 3b 20 68 65 72 65 20  s       ;; here 
3890: 77 65 20 61 72 65 20 66 69 6c 74 65 72 69 6e 67  we are filtering
38a0: 20 66 6f 72 20 6d 61 74 63 68 65 73 20 77 69 74   for matches wit
38b0: 68 20 2d 69 74 65 6d 70 61 74 74 0a 09 09 09 09  h -itempatt.....
38c0: 20 20 20 20 20 20 28 6c 65 74 20 28 28 72 65 73        (let ((res
38d0: 20 23 66 29 29 09 20 3b 3b 20 6c 6f 6f 6b 20 74   #f)). ;; look t
38e0: 68 72 6f 75 67 68 20 61 6c 6c 20 74 68 65 20 69  hrough all the i
38f0: 74 65 6d 2d 70 61 74 74 73 20 69 66 20 64 65 66  tem-patts if def
3900: 69 6e 65 64 2c 20 66 6f 72 6d 61 74 20 69 73 20  ined, format is 
3910: 70 61 74 74 31 2c 70 61 74 74 32 2c 70 61 74 74  patt1,patt2,patt
3920: 33 20 2e 2e 2e 20 77 69 6c 64 63 61 72 64 20 69  3 ... wildcard i
3930: 73 20 25 0a 09 09 09 09 09 28 66 6f 72 2d 65 61  s %......(for-ea
3940: 63 68 20 0a 09 09 09 09 09 20 28 6c 61 6d 62 64  ch ...... (lambd
3950: 61 20 28 70 61 74 74 29 0a 09 09 09 09 09 20 20  a (patt)......  
3960: 20 28 69 66 20 28 73 74 72 69 6e 67 2d 73 65 61   (if (string-sea
3970: 72 63 68 20 28 67 6c 6f 62 2d 3e 72 65 67 65 78  rch (glob->regex
3980: 70 0a 09 09 09 09 09 09 09 20 20 20 20 20 20 20  p........       
3990: 28 73 74 72 69 6e 67 2d 74 72 61 6e 73 6c 61 74  (string-translat
39a0: 65 20 70 61 74 74 20 22 25 22 20 22 2a 22 29 29  e patt "%" "*"))
39b0: 0a 09 09 09 09 09 09 09 20 20 20 20 20 20 69 74  ........      it
39c0: 65 6d 2d 70 61 74 68 29 0a 09 09 09 09 09 20 20  em-path)......  
39d0: 20 20 20 20 20 28 73 65 74 21 20 72 65 73 20 23       (set! res #
39e0: 74 29 29 29 0a 09 09 09 09 09 20 28 73 74 72 69  t)))...... (stri
39f0: 6e 67 2d 73 70 6c 69 74 20 69 74 65 6d 2d 70 61  ng-split item-pa
3a00: 74 74 73 20 22 2c 22 29 29 0a 09 09 09 09 09 72  tts ","))......r
3a10: 65 73 29 0a 09 09 09 09 20 20 20 20 20 20 23 74  es).....      #t
3a20: 29 29 29 0a 09 20 20 20 20 20 20 20 28 69 66 20  )))..       (if 
3a30: 69 74 65 6d 2d 6d 61 74 63 68 65 73 20 3b 3b 20  item-matches ;; 
3a40: 79 65 73 2c 20 77 65 20 77 61 6e 74 20 74 6f 20  yes, we want to 
3a50: 70 72 6f 63 65 73 73 20 74 68 69 73 20 69 74 65  process this ite
3a60: 6d 0a 09 09 20 20 20 28 6c 65 74 20 28 28 6e 65  m...   (let ((ne
3a70: 77 74 65 73 74 6e 61 6d 65 20 28 63 6f 6e 63 20  wtestname (conc 
3a80: 68 65 64 20 22 2f 22 20 6d 79 2d 69 74 65 6d 2d  hed "/" my-item-
3a90: 70 61 74 68 29 29 29 20 0a 09 09 20 20 20 20 20  path))) ...     
3aa0: 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65  (tests:testqueue
3ab0: 2d 73 65 74 2d 69 74 65 6d 73 21 20 20 20 6e 65  -set-items!   ne
3ac0: 77 2d 74 65 73 74 2d 72 65 63 6f 72 64 20 23 66  w-test-record #f
3ad0: 29 0a 09 09 20 20 20 20 20 28 74 65 73 74 73 3a  )...     (tests:
3ae0: 74 65 73 74 71 75 65 75 65 2d 73 65 74 2d 69 74  testqueue-set-it
3af0: 65 6d 64 61 74 21 20 6e 65 77 2d 74 65 73 74 2d  emdat! new-test-
3b00: 72 65 63 6f 72 64 20 6d 79 2d 69 74 65 6d 64 61  record my-itemda
3b10: 74 29 0a 09 09 20 20 20 20 20 28 68 61 73 68 2d  t)...     (hash-
3b20: 74 61 62 6c 65 2d 73 65 74 21 20 74 65 73 74 2d  table-set! test-
3b30: 72 65 63 6f 72 64 73 20 6e 65 77 74 65 73 74 6e  records newtestn
3b40: 61 6d 65 20 6e 65 77 2d 74 65 73 74 2d 72 65 63  ame new-test-rec
3b50: 6f 72 64 29 0a 09 09 20 20 20 20 20 28 73 65 74  ord)...     (set
3b60: 21 20 74 61 6c 20 28 63 6f 6e 73 20 6e 65 77 74  ! tal (cons newt
3b70: 65 73 74 6e 61 6d 65 20 74 61 6c 29 29 29 29 29  estname tal)))))
3b80: 29 20 3b 3b 20 73 69 6e 63 65 20 74 68 65 73 65  ) ;; since these
3b90: 20 61 72 65 20 69 74 65 6d 69 7a 65 64 20 63 72   are itemized cr
3ba0: 65 61 74 65 20 6e 65 77 20 74 65 73 74 20 6e 61  eate new test na
3bb0: 6d 65 73 20 74 65 73 74 6e 61 6d 65 2f 69 74 65  mes testname/ite
3bc0: 6d 70 61 74 68 0a 09 20 20 20 69 74 65 6d 73 29  mpath..   items)
3bd0: 0a 09 20 20 28 6c 6f 6f 70 20 28 63 61 72 20 74  ..  (loop (car t
3be0: 61 6c 29 28 63 64 72 20 74 61 6c 29 29 29 0a 0a  al)(cdr tal)))..
3bf0: 09 20 3b 3b 20 69 66 20 69 74 65 6d 73 20 69 73  . ;; if items is
3c00: 20 61 20 70 72 6f 63 20 74 68 65 6e 20 6e 65 65   a proc then nee
3c10: 64 20 74 6f 20 72 75 6e 20 69 74 65 6d 73 3a 67  d to run items:g
3c20: 65 74 2d 69 74 65 6d 73 2d 66 72 6f 6d 2d 63 6f  et-items-from-co
3c30: 6e 66 69 67 2c 20 67 65 74 20 74 68 65 20 6c 69  nfig, get the li
3c40: 73 74 20 61 6e 64 20 6c 6f 6f 70 20 0a 09 20 3b  st and loop .. ;
3c50: 3b 20 20 20 20 2d 20 62 75 74 20 6f 6e 6c 79 20  ;    - but only 
3c60: 64 6f 20 74 68 61 74 20 69 66 20 72 65 73 6f 75  do that if resou
3c70: 72 63 65 73 20 65 78 69 73 74 20 74 6f 20 6b 69  rces exist to ki
3c80: 63 6b 20 6f 66 66 20 74 68 65 20 6a 6f 62 0a 09  ck off the job..
3c90: 20 28 28 6f 72 20 28 70 72 6f 63 65 64 75 72 65   ((or (procedure
3ca0: 3f 20 69 74 65 6d 73 29 28 65 71 3f 20 69 74 65  ? items)(eq? ite
3cb0: 6d 73 20 27 68 61 76 65 2d 70 72 6f 63 65 64 75  ms 'have-procedu
3cc0: 72 65 29 29 0a 09 20 20 28 69 66 20 28 61 6e 64  re))..  (if (and
3cd0: 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d   (runs:can-run-m
3ce0: 6f 72 65 2d 74 65 73 74 73 20 64 62 20 74 65 73  ore-tests db tes
3cf0: 74 2d 72 65 63 6f 72 64 29 0a 09 09 20 20 20 28  t-record)...   (
3d00: 6e 75 6c 6c 3f 20 28 64 62 3a 67 65 74 2d 70 72  null? (db:get-pr
3d10: 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 20 64 62  ereqs-not-met db
3d20: 20 72 75 6e 2d 69 64 20 77 61 69 74 6f 6e 73 20   run-id waitons 
3d30: 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 09 20 20  item-path)))..  
3d40: 20 20 20 20 28 6c 65 74 20 28 28 74 65 73 74 2d      (let ((test-
3d50: 6e 61 6d 65 20 28 74 65 73 74 73 3a 74 65 73 74  name (tests:test
3d60: 71 75 65 75 65 2d 67 65 74 2d 74 65 73 74 6e 61  queue-get-testna
3d70: 6d 65 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29  me test-record))
3d80: 29 0a 09 09 28 73 65 74 65 6e 76 20 22 4d 54 5f  )...(setenv "MT_
3d90: 54 45 53 54 5f 4e 41 4d 45 22 20 74 65 73 74 2d  TEST_NAME" test-
3da0: 6e 61 6d 65 29 20 3b 3b 20 0a 09 09 28 73 65 74  name) ;; ...(set
3db0: 65 6e 76 20 22 4d 54 5f 52 55 4e 4e 41 4d 45 22  env "MT_RUNNAME"
3dc0: 20 20 20 72 75 6e 6e 61 6d 65 29 0a 09 09 28 73     runname)...(s
3dd0: 65 74 2d 6d 65 67 61 74 65 73 74 2d 65 6e 76 2d  et-megatest-env-
3de0: 76 61 72 73 20 64 62 20 72 75 6e 2d 69 64 29 20  vars db run-id) 
3df0: 3b 3b 20 74 68 65 73 65 20 6d 61 79 20 62 65 20  ;; these may be 
3e00: 6e 65 65 64 65 64 20 62 79 20 74 68 65 20 6c 61  needed by the la
3e10: 75 6e 63 68 69 6e 67 20 70 72 6f 63 65 73 73 0a  unching process.
3e20: 09 09 28 6c 65 74 20 28 28 69 74 65 6d 73 2d 6c  ..(let ((items-l
3e30: 69 73 74 20 28 69 74 65 6d 73 3a 67 65 74 2d 69  ist (items:get-i
3e40: 74 65 6d 73 2d 66 72 6f 6d 2d 63 6f 6e 66 69 67  tems-from-config
3e50: 20 74 63 6f 6e 66 69 67 29 29 29 0a 09 09 20 20   tconfig)))...  
3e60: 28 69 66 20 28 6c 69 73 74 3f 20 69 74 65 6d 73  (if (list? items
3e70: 2d 6c 69 73 74 29 0a 09 09 20 20 20 20 20 20 28  -list)...      (
3e80: 62 65 67 69 6e 0a 09 09 09 28 74 65 73 74 73 3a  begin....(tests:
3e90: 74 65 73 74 71 75 65 75 65 2d 73 65 74 2d 69 74  testqueue-set-it
3ea0: 65 6d 73 21 20 74 65 73 74 2d 72 65 63 6f 72 64  ems! test-record
3eb0: 20 69 74 65 6d 73 2d 6c 69 73 74 29 0a 09 09 09   items-list)....
3ec0: 28 6c 6f 6f 70 20 68 65 64 20 74 61 6c 29 29 0a  (loop hed tal)).
3ed0: 09 09 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09  ..      (begin..
3ee0: 09 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30  ..(debug:print 0
3ef0: 20 22 45 52 52 4f 52 3a 20 54 68 65 20 70 72 6f   "ERROR: The pro
3f00: 63 20 66 72 6f 6d 20 72 65 61 64 69 6e 67 20 74  c from reading t
3f10: 68 65 20 73 65 74 75 70 20 64 69 64 20 6e 6f 74  he setup did not
3f20: 20 79 69 65 6c 64 20 61 20 6c 69 73 74 20 2d 20   yield a list - 
3f30: 70 6c 65 61 73 65 20 72 65 70 6f 72 74 20 74 68  please report th
3f40: 69 73 22 29 0a 09 09 09 28 65 78 69 74 20 31 29  is")....(exit 1)
3f50: 29 29 29 29 0a 09 20 20 20 20 20 20 28 6c 65 74  ))))..      (let
3f60: 20 28 28 6e 65 77 74 61 6c 20 28 61 70 70 65 6e   ((newtal (appen
3f70: 64 20 74 61 6c 20 28 6c 69 73 74 20 68 65 64 29  d tal (list hed)
3f80: 29 29 29 0a 09 09 3b 3b 20 69 66 20 63 61 6e 27  )))...;; if can'
3f90: 74 20 72 75 6e 20 6d 6f 72 65 20 74 65 73 74 73  t run more tests
3fa0: 2c 20 6c 65 74 73 20 74 61 6b 65 20 61 20 62 72  , lets take a br
3fb0: 65 61 74 68 65 72 0a 09 09 28 74 68 72 65 61 64  eather...(thread
3fc0: 2d 73 6c 65 65 70 21 20 31 29 0a 09 09 28 6c 6f  -sleep! 1)...(lo
3fd0: 6f 70 20 28 63 61 72 20 6e 65 77 74 61 6c 29 28  op (car newtal)(
3fe0: 63 64 72 20 6e 65 77 74 61 6c 29 29 29 29 29 0a  cdr newtal))))).
3ff0: 0a 09 20 3b 3b 20 74 68 69 73 20 63 61 73 65 20  .. ;; this case 
4000: 73 68 6f 75 6c 64 20 6e 6f 74 20 68 61 70 70 65  should not happe
4010: 6e 2c 20 61 64 64 65 64 20 74 6f 20 68 65 6c 70  n, added to help
4020: 20 63 61 74 63 68 20 61 6e 79 20 62 75 67 73 0a   catch any bugs.
4030: 09 20 28 28 61 6e 64 20 28 6c 69 73 74 3f 20 69  . ((and (list? i
4040: 74 65 6d 73 29 20 69 74 65 6d 64 61 74 29 0a 09  tems) itemdat)..
4050: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30    (debug:print 0
4060: 20 22 45 52 52 4f 52 3a 20 53 68 6f 75 6c 64 20   "ERROR: Should 
4070: 6e 6f 74 20 68 61 76 65 20 61 20 6c 69 73 74 20  not have a list 
4080: 6f 66 20 69 74 65 6d 73 20 69 6e 20 61 20 74 65  of items in a te
4090: 73 74 20 61 6e 64 20 74 68 65 20 69 74 65 6d 73  st and the items
40a0: 70 61 74 68 20 73 65 74 20 2d 20 70 6c 65 61 73  path set - pleas
40b0: 65 20 72 65 70 6f 72 74 20 74 68 69 73 22 29 0a  e report this").
40c0: 09 20 20 28 65 78 69 74 20 31 29 29 29 29 0a 09  .  (exit 1))))..
40d0: 0a 20 20 20 20 20 20 3b 3b 20 77 65 20 67 65 74  .      ;; we get
40e0: 20 68 65 72 65 20 6f 6e 20 22 64 72 6f 70 20 74   here on "drop t
40f0: 68 72 6f 75 67 68 22 20 2d 20 6c 6f 6f 70 20 66  hrough" - loop f
4100: 6f 72 20 6e 65 78 74 20 74 65 73 74 20 69 6e 20  or next test in 
4110: 71 75 65 75 65 0a 20 20 20 20 20 20 28 69 66 20  queue.      (if 
4120: 28 6e 75 6c 6c 3f 20 74 61 6c 29 0a 09 20 20 28  (null? tal)..  (
4130: 62 65 67 69 6e 0a 09 20 20 20 20 3b 3b 20 46 49  begin..    ;; FI
4140: 58 4d 45 21 21 21 21 20 54 48 49 53 20 53 48 4f  XME!!!! THIS SHO
4150: 55 4c 44 20 4e 4f 54 20 52 45 51 55 49 52 45 20  ULD NOT REQUIRE 
4160: 41 4e 20 45 58 49 54 21 21 21 21 21 21 21 0a 09  AN EXIT!!!!!!!..
4170: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
4180: 20 31 20 22 49 4e 46 4f 3a 20 41 6c 6c 20 74 65   1 "INFO: All te
4190: 73 74 73 20 6c 61 75 6e 63 68 65 64 2c 20 65 78  sts launched, ex
41a0: 69 74 69 6e 67 22 29 0a 09 20 20 20 20 28 65 78  iting")..    (ex
41b0: 69 74 20 30 29 29 0a 09 20 20 28 6c 6f 6f 70 20  it 0))..  (loop 
41c0: 28 63 61 72 20 74 61 6c 29 28 63 64 72 20 74 61  (car tal)(cdr ta
41d0: 6c 29 29 29 29 29 29 0a 0a 3b 3b 20 70 61 72 65  l))))))..;; pare
41e0: 6e 74 2d 74 65 73 74 20 69 73 20 74 68 65 72 65  nt-test is there
41f0: 20 61 73 20 61 20 70 6c 61 63 65 68 6f 6c 64 65   as a placeholde
4200: 72 20 66 6f 72 20 77 68 65 6e 20 70 61 72 65 6e  r for when paren
4210: 74 2d 74 65 73 74 73 20 63 61 6e 20 62 65 20 72  t-tests can be r
4220: 75 6e 20 61 73 20 61 20 73 65 74 75 70 20 73 74  un as a setup st
4230: 65 70 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 3a  ep.(define (run:
4240: 74 65 73 74 20 64 62 20 72 75 6e 2d 69 64 20 72  test db run-id r
4250: 75 6e 6e 61 6d 65 20 6b 65 79 76 61 6c 6c 73 74  unname keyvallst
4260: 20 74 65 73 74 2d 72 65 63 6f 72 64 20 66 6c 61   test-record fla
4270: 67 73 20 70 61 72 65 6e 74 2d 74 65 73 74 29 0a  gs parent-test).
4280: 20 20 3b 3b 20 41 6c 6c 20 74 68 65 73 65 20 76    ;; All these v
4290: 61 72 73 20 6d 69 67 68 74 20 62 65 20 72 65 66  ars might be ref
42a0: 65 72 65 6e 63 65 64 20 62 79 20 74 68 65 20 74  erenced by the t
42b0: 65 73 74 63 6f 6e 66 69 67 20 66 69 6c 65 20 72  estconfig file r
42c0: 65 61 64 65 72 0a 20 20 28 6c 65 74 2a 20 28 28  eader.  (let* ((
42d0: 74 65 73 74 2d 6e 61 6d 65 20 20 20 20 28 74 65  test-name    (te
42e0: 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65  sts:testqueue-ge
42f0: 74 2d 74 65 73 74 6e 61 6d 65 20 20 20 74 65 73  t-testname   tes
4300: 74 2d 72 65 63 6f 72 64 29 29 0a 09 20 28 74 65  t-record)).. (te
4310: 73 74 2d 77 61 69 74 6f 6e 73 20 28 74 65 73 74  st-waitons (test
4320: 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d  s:testqueue-get-
4330: 77 61 69 74 6f 6e 73 20 20 20 20 74 65 73 74 2d  waitons    test-
4340: 72 65 63 6f 72 64 29 29 0a 09 20 28 74 65 73 74  record)).. (test
4350: 2d 63 6f 6e 66 20 20 20 20 28 74 65 73 74 73 3a  -conf    (tests:
4360: 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d 74 65  testqueue-get-te
4370: 73 74 63 6f 6e 66 69 67 20 74 65 73 74 2d 72 65  stconfig test-re
4380: 63 6f 72 64 29 29 0a 09 20 28 69 74 65 6d 64 61  cord)).. (itemda
4390: 74 20 20 20 20 20 20 28 74 65 73 74 73 3a 74 65  t      (tests:te
43a0: 73 74 71 75 65 75 65 2d 67 65 74 2d 69 74 65 6d  stqueue-get-item
43b0: 64 61 74 20 20 20 20 74 65 73 74 2d 72 65 63 6f  dat    test-reco
43c0: 72 64 29 29 0a 09 20 28 74 65 73 74 2d 70 61 74  rd)).. (test-pat
43d0: 68 20 20 20 20 28 63 6f 6e 63 20 2a 74 6f 70 70  h    (conc *topp
43e0: 61 74 68 2a 20 22 2f 74 65 73 74 73 2f 22 20 74  ath* "/tests/" t
43f0: 65 73 74 2d 6e 61 6d 65 29 29 20 3b 3b 20 63 6f  est-name)) ;; co
4400: 75 6c 64 20 75 73 65 20 74 65 73 74 3a 67 65 74  uld use test:get
4410: 2d 74 65 73 74 63 6f 6e 66 69 67 20 68 65 72 65  -testconfig here
4420: 20 2e 2e 2e 0a 09 20 28 66 6f 72 63 65 20 20 20   ..... (force   
4430: 20 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65       (hash-table
4440: 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 66 6c 61  -ref/default fla
4450: 67 73 20 22 2d 66 6f 72 63 65 22 20 23 66 29 29  gs "-force" #f))
4460: 0a 09 20 28 72 65 72 75 6e 20 20 20 20 20 20 20  .. (rerun       
4470: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
4480: 2f 64 65 66 61 75 6c 74 20 66 6c 61 67 73 20 22  /default flags "
4490: 2d 72 65 72 75 6e 22 20 23 66 29 29 0a 09 20 28  -rerun" #f)).. (
44a0: 6b 65 65 70 67 6f 69 6e 67 20 20 20 20 28 68 61  keepgoing    (ha
44b0: 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66  sh-table-ref/def
44c0: 61 75 6c 74 20 66 6c 61 67 73 20 22 2d 6b 65 65  ault flags "-kee
44d0: 70 67 6f 69 6e 67 22 20 23 66 29 29 0a 09 20 28  pgoing" #f)).. (
44e0: 69 74 65 6d 2d 70 61 74 68 20 20 20 20 20 22 22  item-path     ""
44f0: 29 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72  )).    (debug:pr
4500: 69 6e 74 20 35 0a 09 09 20 22 74 65 73 74 2d 63  int 5... "test-c
4510: 6f 6e 66 69 67 3a 20 22 20 28 68 61 73 68 2d 74  onfig: " (hash-t
4520: 61 62 6c 65 2d 3e 61 6c 69 73 74 20 74 65 73 74  able->alist test
4530: 2d 63 6f 6e 66 29 0a 09 09 20 22 5c 6e 20 20 20  -conf)... "\n   
4540: 69 74 65 6d 64 61 74 3a 20 22 20 69 74 65 6d 64  itemdat: " itemd
4550: 61 74 0a 09 09 20 29 0a 20 20 20 20 3b 3b 20 73  at... ).    ;; s
4560: 65 74 74 69 6e 67 20 69 74 65 6d 64 61 74 20 74  etting itemdat t
4570: 6f 20 61 20 6c 69 73 74 20 69 66 20 69 74 20 69  o a list if it i
4580: 73 20 23 66 0a 20 20 20 20 28 69 66 20 28 6e 6f  s #f.    (if (no
4590: 74 20 69 74 65 6d 64 61 74 29 28 73 65 74 21 20  t itemdat)(set! 
45a0: 69 74 65 6d 64 61 74 20 27 28 29 29 29 0a 20 20  itemdat '())).  
45b0: 20 20 28 73 65 74 21 20 69 74 65 6d 2d 70 61 74    (set! item-pat
45c0: 68 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61  h (item-list->pa
45d0: 74 68 20 69 74 65 6d 64 61 74 29 29 0a 20 20 20  th itemdat)).   
45e0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20   (debug:print 2 
45f0: 22 41 74 74 65 6d 70 74 69 6e 67 20 74 6f 20 6c  "Attempting to l
4600: 61 75 6e 63 68 20 74 65 73 74 20 22 20 74 65 73  aunch test " tes
4610: 74 2d 6e 61 6d 65 20 22 2f 22 20 69 74 65 6d 2d  t-name "/" item-
4620: 70 61 74 68 29 0a 20 20 20 20 28 73 65 74 65 6e  path).    (seten
4630: 76 20 22 4d 54 5f 54 45 53 54 5f 4e 41 4d 45 22  v "MT_TEST_NAME"
4640: 20 74 65 73 74 2d 6e 61 6d 65 29 20 3b 3b 20 0a   test-name) ;; .
4650: 20 20 20 20 28 73 65 74 65 6e 76 20 22 4d 54 5f      (setenv "MT_
4660: 52 55 4e 4e 41 4d 45 22 20 20 20 72 75 6e 6e 61  RUNNAME"   runna
4670: 6d 65 29 0a 20 20 20 20 28 73 65 74 2d 6d 65 67  me).    (set-meg
4680: 61 74 65 73 74 2d 65 6e 76 2d 76 61 72 73 20 64  atest-env-vars d
4690: 62 20 72 75 6e 2d 69 64 29 20 3b 3b 20 74 68 65  b run-id) ;; the
46a0: 73 65 20 6d 61 79 20 62 65 20 6e 65 65 64 65 64  se may be needed
46b0: 20 62 79 20 74 68 65 20 6c 61 75 6e 63 68 69 6e   by the launchin
46c0: 67 20 70 72 6f 63 65 73 73 0a 20 20 20 20 28 63  g process.    (c
46d0: 68 61 6e 67 65 2d 64 69 72 65 63 74 6f 72 79 20  hange-directory 
46e0: 2a 74 6f 70 70 61 74 68 2a 29 0a 0a 20 20 20 20  *toppath*)..    
46f0: 3b 3b 20 48 65 72 65 20 69 73 20 77 68 65 72 65  ;; Here is where
4700: 20 74 68 65 20 74 65 73 74 5f 6d 65 74 61 20 74   the test_meta t
4710: 61 62 6c 65 20 69 73 20 62 65 73 74 20 75 70 64  able is best upd
4720: 61 74 65 64 0a 20 20 20 20 28 72 75 6e 73 3a 75  ated.    (runs:u
4730: 70 64 61 74 65 2d 74 65 73 74 5f 6d 65 74 61 20  pdate-test_meta 
4740: 64 62 20 74 65 73 74 2d 6e 61 6d 65 20 74 65 73  db test-name tes
4750: 74 2d 63 6f 6e 66 29 0a 20 20 20 20 0a 20 20 20  t-conf).    .   
4760: 20 3b 3b 20 28 6c 61 6d 62 64 61 20 28 69 74 65   ;; (lambda (ite
4770: 6d 64 61 74 29 20 3b 3b 3b 20 28 28 72 69 70 65  mdat) ;;; ((ripe
4780: 6e 65 73 73 20 22 6f 76 65 72 72 69 70 65 22 29  ness "overripe")
4790: 20 28 74 65 6d 70 65 72 61 74 75 72 65 20 22 63   (temperature "c
47a0: 6f 6f 6c 22 29 20 28 73 65 61 73 6f 6e 20 22 73  ool") (season "s
47b0: 75 6d 6d 65 72 22 29 29 0a 20 20 20 20 28 6c 65  ummer")).    (le
47c0: 74 2a 20 28 28 6e 65 77 2d 74 65 73 74 2d 70 61  t* ((new-test-pa
47d0: 74 68 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72  th (string-inter
47e0: 73 70 65 72 73 65 20 28 63 6f 6e 73 20 74 65 73  sperse (cons tes
47f0: 74 2d 70 61 74 68 20 28 6d 61 70 20 63 61 64 72  t-path (map cadr
4800: 20 69 74 65 6d 64 61 74 29 29 20 22 2f 22 29 29   itemdat)) "/"))
4810: 0a 09 20 20 20 28 6e 65 77 2d 74 65 73 74 2d 6e  ..   (new-test-n
4820: 61 6d 65 20 28 69 66 20 28 65 71 75 61 6c 3f 20  ame (if (equal? 
4830: 69 74 65 6d 2d 70 61 74 68 20 22 22 29 20 74 65  item-path "") te
4840: 73 74 2d 6e 61 6d 65 20 28 63 6f 6e 63 20 74 65  st-name (conc te
4850: 73 74 2d 6e 61 6d 65 20 22 2f 22 20 69 74 65 6d  st-name "/" item
4860: 2d 70 61 74 68 29 29 29 20 3b 3b 20 6a 75 73 74  -path))) ;; just
4870: 20 6e 65 65 64 20 69 74 20 74 6f 20 62 65 20 75   need it to be u
4880: 6e 69 71 75 65 0a 09 20 20 20 28 74 65 73 74 64  nique..   (testd
4890: 61 74 20 20 20 20 20 20 20 28 64 62 3a 67 65 74  at       (db:get
48a0: 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 20 72 75  -test-info db ru
48b0: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69  n-id test-name i
48c0: 74 65 6d 2d 70 61 74 68 29 29 29 0a 20 20 20 20  tem-path))).    
48d0: 20 20 28 69 66 20 28 6e 6f 74 20 74 65 73 74 64    (if (not testd
48e0: 61 74 29 0a 09 20 20 28 62 65 67 69 6e 0a 09 20  at)..  (begin.. 
48f0: 20 20 20 28 72 65 67 69 73 74 65 72 2d 74 65 73     (register-tes
4900: 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  t db run-id test
4910: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  -name item-path)
4920: 0a 09 20 20 20 20 28 73 65 74 21 20 74 65 73 74  ..    (set! test
4930: 64 61 74 20 28 64 62 3a 67 65 74 2d 74 65 73 74  dat (db:get-test
4940: 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64 20  -info db run-id 
4950: 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70  test-name item-p
4960: 61 74 68 29 29 29 29 0a 20 20 20 20 20 20 28 63  ath)))).      (c
4970: 68 61 6e 67 65 2d 64 69 72 65 63 74 6f 72 79 20  hange-directory 
4980: 74 65 73 74 2d 70 61 74 68 29 0a 20 20 20 20 20  test-path).     
4990: 20 28 63 61 73 65 20 28 69 66 20 66 6f 72 63 65   (case (if force
49a0: 20 3b 3b 20 28 61 72 67 73 3a 67 65 74 2d 61 72   ;; (args:get-ar
49b0: 67 20 22 2d 66 6f 72 63 65 22 29 0a 09 09 27 4e  g "-force")...'N
49c0: 4f 54 5f 53 54 41 52 54 45 44 0a 09 09 28 69 66  OT_STARTED...(if
49d0: 20 74 65 73 74 64 61 74 0a 09 09 20 20 20 20 28   testdat...    (
49e0: 73 74 72 69 6e 67 2d 3e 73 79 6d 62 6f 6c 20 28  string->symbol (
49f0: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74  test:get-state t
4a00: 65 73 74 64 61 74 29 29 0a 09 09 20 20 20 20 27  estdat))...    '
4a10: 66 61 69 6c 65 64 2d 74 6f 2d 69 6e 73 65 72 74  failed-to-insert
4a20: 29 29 0a 09 28 28 66 61 69 6c 65 64 2d 74 6f 2d  ))..((failed-to-
4a30: 69 6e 73 65 72 74 29 0a 09 20 28 64 65 62 75 67  insert).. (debug
4a40: 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a  :print 0 "ERROR:
4a50: 20 46 61 69 6c 65 64 20 74 6f 20 69 6e 73 65 72   Failed to inser
4a60: 74 20 74 68 65 20 72 65 63 6f 72 64 20 69 6e 74  t the record int
4a70: 6f 20 74 68 65 20 64 62 22 29 29 0a 09 28 28 4e  o the db"))..((N
4a80: 4f 54 5f 53 54 41 52 54 45 44 20 43 4f 4d 50 4c  OT_STARTED COMPL
4a90: 45 54 45 44 29 0a 09 20 28 64 65 62 75 67 3a 70  ETED).. (debug:p
4aa0: 72 69 6e 74 20 36 20 22 47 6f 74 20 68 65 72 65  rint 6 "Got here
4ab0: 2c 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74  , " (test:get-st
4ac0: 61 74 65 20 74 65 73 74 64 61 74 29 29 0a 09 20  ate testdat)).. 
4ad0: 28 6c 65 74 20 28 28 72 75 6e 66 6c 61 67 20 23  (let ((runflag #
4ae0: 66 29 29 0a 09 20 20 20 28 63 6f 6e 64 0a 09 20  f))..   (cond.. 
4af0: 20 20 20 3b 3b 20 2d 66 6f 72 63 65 2c 20 72 75     ;; -force, ru
4b00: 6e 20 6e 6f 20 6d 61 74 74 65 72 20 77 68 61 74  n no matter what
4b10: 0a 09 20 20 20 20 28 66 6f 72 63 65 20 28 73 65  ..    (force (se
4b20: 74 21 20 72 75 6e 66 6c 61 67 20 23 74 29 29 0a  t! runflag #t)).
4b30: 09 20 20 20 20 3b 3b 20 4e 4f 54 5f 53 54 41 52  .    ;; NOT_STAR
4b40: 54 45 44 2c 20 72 75 6e 20 6e 6f 20 6d 61 74 74  TED, run no matt
4b50: 65 72 20 77 68 61 74 0a 09 20 20 20 20 28 28 65  er what..    ((e
4b60: 71 75 61 6c 3f 20 28 74 65 73 74 3a 67 65 74 2d  qual? (test:get-
4b70: 73 74 61 74 65 20 74 65 73 74 64 61 74 29 20 22  state testdat) "
4b80: 4e 4f 54 5f 53 54 41 52 54 45 44 22 29 28 73 65  NOT_STARTED")(se
4b90: 74 21 20 72 75 6e 66 6c 61 67 20 23 74 29 29 0a  t! runflag #t)).
4ba0: 09 20 20 20 20 3b 3b 20 6e 6f 74 20 2d 72 65 72  .    ;; not -rer
4bb0: 75 6e 20 61 6e 64 20 50 41 53 53 2c 20 57 41 52  un and PASS, WAR
4bc0: 4e 20 6f 72 20 43 48 45 43 4b 2c 20 64 6f 20 6e  N or CHECK, do n
4bd0: 6f 20 72 75 6e 0a 09 20 20 20 20 28 28 61 6e 64  o run..    ((and
4be0: 20 28 6f 72 20 28 6e 6f 74 20 72 65 72 75 6e 29   (or (not rerun)
4bf0: 0a 09 09 20 20 20 20 20 20 6b 65 65 70 67 6f 69  ...      keepgoi
4c00: 6e 67 29 0a 09 09 20 20 3b 3b 20 52 65 71 75 69  ng)...  ;; Requi
4c10: 72 65 20 74 6f 20 66 6f 72 63 65 20 72 65 2d 72  re to force re-r
4c20: 75 6e 20 66 6f 72 20 43 4f 4d 50 4c 45 54 45 44  un for COMPLETED
4c30: 20 6f 72 20 2a 61 6e 79 74 68 69 6e 67 2a 20 2b   or *anything* +
4c40: 20 50 41 53 53 2c 57 41 52 4e 20 6f 72 20 43 48   PASS,WARN or CH
4c50: 45 43 4b 0a 09 09 20 20 28 6f 72 20 28 6d 65 6d  ECK...  (or (mem
4c60: 62 65 72 20 28 74 65 73 74 3a 67 65 74 2d 73 74  ber (test:get-st
4c70: 61 74 75 73 20 74 65 73 74 64 61 74 29 20 27 28  atus testdat) '(
4c80: 22 50 41 53 53 22 20 22 57 41 52 4e 22 20 22 43  "PASS" "WARN" "C
4c90: 48 45 43 4b 22 29 29 0a 09 09 20 20 20 20 20 20  HECK"))...      
4ca0: 28 6d 65 6d 62 65 72 20 28 74 65 73 74 3a 67 65  (member (test:ge
4cb0: 74 2d 73 74 61 74 65 20 20 74 65 73 74 64 61 74  t-state  testdat
4cc0: 29 20 27 28 22 43 4f 4d 50 4c 45 54 45 44 22 29  ) '("COMPLETED")
4cd0: 29 29 29 20 0a 09 20 20 20 20 20 28 73 65 74 21  ))) ..     (set!
4ce0: 20 72 75 6e 66 6c 61 67 20 23 66 29 29 0a 09 20   runflag #f)).. 
4cf0: 20 20 20 3b 3b 20 2d 72 65 72 75 6e 20 61 6e 64     ;; -rerun and
4d00: 20 73 74 61 74 75 73 20 69 73 20 6f 6e 65 20 6f   status is one o
4d10: 66 20 74 68 65 20 73 70 65 63 69 66 65 64 2c 20  f the specifed, 
4d20: 72 75 6e 20 69 74 0a 09 20 20 20 20 28 28 61 6e  run it..    ((an
4d30: 64 20 72 65 72 75 6e 0a 09 09 20 20 28 6c 65 74  d rerun...  (let
4d40: 20 28 28 72 65 72 75 6e 6c 73 74 20 28 73 74 72   ((rerunlst (str
4d50: 69 6e 67 2d 73 70 6c 69 74 20 72 65 72 75 6e 20  ing-split rerun 
4d60: 22 2c 22 29 29 29 20 3b 3b 20 46 41 49 4c 2c 0a  ","))) ;; FAIL,.
4d70: 09 09 20 20 20 20 28 6d 65 6d 62 65 72 20 28 74  ..    (member (t
4d80: 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74  est:get-status t
4d90: 65 73 74 64 61 74 29 20 72 65 72 75 6e 6c 73 74  estdat) rerunlst
4da0: 29 29 29 0a 09 20 20 20 20 20 28 73 65 74 21 20  )))..     (set! 
4db0: 72 75 6e 66 6c 61 67 20 23 74 29 29 0a 09 20 20  runflag #t))..  
4dc0: 20 20 3b 3b 20 2d 6b 65 65 70 67 6f 69 6e 67 2c    ;; -keepgoing,
4dd0: 20 64 6f 20 6e 6f 74 20 72 65 72 75 6e 20 46 41   do not rerun FA
4de0: 49 4c 0a 09 20 20 20 20 28 28 61 6e 64 20 6b 65  IL..    ((and ke
4df0: 65 70 67 6f 69 6e 67 0a 09 09 20 20 28 6d 65 6d  epgoing...  (mem
4e00: 62 65 72 20 28 74 65 73 74 3a 67 65 74 2d 73 74  ber (test:get-st
4e10: 61 74 75 73 20 74 65 73 74 64 61 74 29 20 27 28  atus testdat) '(
4e20: 22 46 41 49 4c 22 29 29 29 0a 09 20 20 20 20 20  "FAIL")))..     
4e30: 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 66  (set! runflag #f
4e40: 29 29 0a 09 20 20 20 20 28 28 61 6e 64 20 28 6e  ))..    ((and (n
4e50: 6f 74 20 72 65 72 75 6e 29 0a 09 09 20 20 28 6d  ot rerun)...  (m
4e60: 65 6d 62 65 72 20 28 74 65 73 74 3a 67 65 74 2d  ember (test:get-
4e70: 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29 20  status testdat) 
4e80: 27 28 22 46 41 49 4c 22 20 22 6e 2f 61 22 29 29  '("FAIL" "n/a"))
4e90: 29 0a 09 20 20 20 20 20 28 73 65 74 21 20 72 75  )..     (set! ru
4ea0: 6e 66 6c 61 67 20 23 74 29 29 0a 09 20 20 20 20  nflag #t))..    
4eb0: 28 65 6c 73 65 20 28 73 65 74 21 20 72 75 6e 66  (else (set! runf
4ec0: 6c 61 67 20 23 66 29 29 29 0a 09 20 20 20 28 64  lag #f)))..   (d
4ed0: 65 62 75 67 3a 70 72 69 6e 74 20 36 20 22 52 55  ebug:print 6 "RU
4ee0: 4e 4e 49 4e 47 20 3d 3e 20 72 75 6e 66 6c 61 67  NNING => runflag
4ef0: 3a 20 22 20 72 75 6e 66 6c 61 67 20 22 20 53 54  : " runflag " ST
4f00: 41 54 45 3a 20 22 20 28 74 65 73 74 3a 67 65 74  ATE: " (test:get
4f10: 2d 73 74 61 74 65 20 74 65 73 74 64 61 74 29 20  -state testdat) 
4f20: 22 20 53 54 41 54 55 53 3a 20 22 20 28 74 65 73  " STATUS: " (tes
4f30: 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73  t:get-status tes
4f40: 74 64 61 74 29 29 0a 09 20 20 20 28 69 66 20 28  tdat))..   (if (
4f50: 6e 6f 74 20 72 75 6e 66 6c 61 67 29 0a 09 20 20  not runflag)..  
4f60: 20 20 20 20 20 28 69 66 20 28 6e 6f 74 20 70 61       (if (not pa
4f70: 72 65 6e 74 2d 74 65 73 74 29 0a 09 09 20 20 20  rent-test)...   
4f80: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22  (debug:print 1 "
4f90: 4e 4f 54 45 3a 20 4e 6f 74 20 73 74 61 72 74 69  NOTE: Not starti
4fa0: 6e 67 20 74 65 73 74 20 22 20 6e 65 77 2d 74 65  ng test " new-te
4fb0: 73 74 2d 6e 61 6d 65 20 22 20 61 73 20 69 74 20  st-name " as it 
4fc0: 69 73 20 73 74 61 74 65 20 5c 22 22 20 28 74 65  is state \"" (te
4fd0: 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73  st:get-state tes
4fe0: 74 64 61 74 29 20 0a 09 09 09 09 22 5c 22 20 61  tdat) ....."\" a
4ff0: 6e 64 20 73 74 61 74 75 73 20 5c 22 22 20 28 74  nd status \"" (t
5000: 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74  est:get-status t
5010: 65 73 74 64 61 74 29 20 22 5c 22 2c 20 75 73 65  estdat) "\", use
5020: 20 2d 72 65 72 75 6e 20 5c 22 22 20 28 74 65 73   -rerun \"" (tes
5030: 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74  t:get-state test
5040: 64 61 74 29 20 22 5c 22 20 6f 72 20 2d 66 6f 72  dat) "\" or -for
5050: 63 65 20 74 6f 20 6f 76 65 72 72 69 64 65 22 29  ce to override")
5060: 29 0a 09 20 20 20 20 20 20 20 3b 3b 20 4e 4f 54  )..       ;; NOT
5070: 45 3a 20 4e 6f 20 6c 6f 6e 67 65 72 20 62 65 20  E: No longer be 
5080: 63 68 65 63 6b 69 6e 67 20 70 72 65 72 65 71 75  checking prerequ
5090: 69 73 69 74 65 73 20 68 65 72 65 21 20 57 69 6c  isites here! Wil
50a0: 6c 20 6e 65 76 65 72 20 67 65 74 20 68 65 72 65  l never get here
50b0: 20 75 6e 6c 65 73 73 20 70 72 65 72 65 71 73 20   unless prereqs 
50c0: 61 72 65 0a 09 20 20 20 20 20 20 20 3b 3b 20 20  are..       ;;  
50d0: 20 20 20 20 20 61 6c 72 65 61 64 79 20 6d 65 74       already met
50e0: 2e 0a 09 20 20 20 20 20 20 20 28 69 66 20 28 6e  ...       (if (n
50f0: 6f 74 20 28 6c 61 75 6e 63 68 2d 74 65 73 74 20  ot (launch-test 
5100: 64 62 20 72 75 6e 2d 69 64 20 72 75 6e 6e 61 6d  db run-id runnam
5110: 65 20 74 65 73 74 2d 63 6f 6e 66 20 6b 65 79 76  e test-conf keyv
5120: 61 6c 6c 73 74 20 74 65 73 74 2d 6e 61 6d 65 20  allst test-name 
5130: 74 65 73 74 2d 70 61 74 68 20 69 74 65 6d 64 61  test-path itemda
5140: 74 20 66 6c 61 67 73 29 29 0a 09 09 20 20 20 28  t flags))...   (
5150: 62 65 67 69 6e 0a 09 09 20 20 20 20 20 28 70 72  begin...     (pr
5160: 69 6e 74 20 22 45 52 52 4f 52 3a 20 46 61 69 6c  int "ERROR: Fail
5170: 65 64 20 74 6f 20 6c 61 75 6e 63 68 20 74 68 65  ed to launch the
5180: 20 74 65 73 74 2e 20 45 78 69 74 69 6e 67 20 61   test. Exiting a
5190: 73 20 73 6f 6f 6e 20 61 73 20 70 6f 73 73 69 62  s soon as possib
51a0: 6c 65 22 29 0a 09 09 20 20 20 20 20 28 73 65 74  le")...     (set
51b0: 21 20 2a 67 6c 6f 62 61 6c 65 78 69 74 73 74 61  ! *globalexitsta
51c0: 74 75 73 2a 20 31 29 20 3b 3b 20 0a 09 09 20 20  tus* 1) ;; ...  
51d0: 20 20 20 28 70 72 6f 63 65 73 73 2d 73 69 67 6e     (process-sign
51e0: 61 6c 20 28 63 75 72 72 65 6e 74 2d 70 72 6f 63  al (current-proc
51f0: 65 73 73 2d 69 64 29 20 73 69 67 6e 61 6c 2f 6b  ess-id) signal/k
5200: 69 6c 6c 29 29 29 29 29 29 0a 09 28 28 4b 49 4c  ill))))))..((KIL
5210: 4c 45 44 29 20 0a 09 20 28 64 65 62 75 67 3a 70  LED) .. (debug:p
5220: 72 69 6e 74 20 31 20 22 4e 4f 54 45 3a 20 22 20  rint 1 "NOTE: " 
5230: 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20 22 20  new-test-name " 
5240: 69 73 20 61 6c 72 65 61 64 79 20 72 75 6e 6e 69  is already runni
5250: 6e 67 20 6f 72 20 77 61 73 20 65 78 70 6c 69 63  ng or was explic
5260: 74 6c 79 20 6b 69 6c 6c 65 64 2c 20 75 73 65 20  tly killed, use 
5270: 2d 66 6f 72 63 65 20 74 6f 20 6c 61 75 6e 63 68  -force to launch
5280: 20 69 74 2e 22 29 29 0a 09 28 28 4c 41 55 4e 43   it."))..((LAUNC
5290: 48 45 44 20 52 45 4d 4f 54 45 48 4f 53 54 53 54  HED REMOTEHOSTST
52a0: 41 52 54 20 52 55 4e 4e 49 4e 47 29 20 20 0a 09  ART RUNNING)  ..
52b0: 20 28 69 66 20 28 3e 20 28 2d 20 28 63 75 72 72   (if (> (- (curr
52c0: 65 6e 74 2d 73 65 63 6f 6e 64 73 29 28 2b 20 28  ent-seconds)(+ (
52d0: 64 62 3a 74 65 73 74 2d 67 65 74 2d 65 76 65 6e  db:test-get-even
52e0: 74 5f 74 69 6d 65 20 74 65 73 74 64 61 74 29 0a  t_time testdat).
52f0: 09 09 09 09 20 20 20 20 20 20 20 28 64 62 3a 74  ....       (db:t
5300: 65 73 74 2d 67 65 74 2d 72 75 6e 5f 64 75 72 61  est-get-run_dura
5310: 74 69 6f 6e 20 74 65 73 74 64 61 74 29 29 29 0a  tion testdat))).
5320: 09 09 36 30 30 29 20 3b 3b 20 69 2e 65 2e 20 6e  ..600) ;; i.e. n
5330: 6f 20 75 70 64 61 74 65 20 66 6f 72 20 6d 6f 72  o update for mor
5340: 65 20 74 68 61 6e 20 36 30 30 20 73 65 63 6f 6e  e than 600 secon
5350: 64 73 0a 09 20 20 20 20 20 28 62 65 67 69 6e 0a  ds..     (begin.
5360: 09 20 20 20 20 20 20 20 28 64 65 62 75 67 3a 70  .       (debug:p
5370: 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e 47 3a  rint 0 "WARNING:
5380: 20 54 65 73 74 20 22 20 74 65 73 74 2d 6e 61 6d   Test " test-nam
5390: 65 20 22 20 61 70 70 65 61 72 73 20 74 6f 20 62  e " appears to b
53a0: 65 20 64 65 61 64 2e 20 46 6f 72 63 69 6e 67 20  e dead. Forcing 
53b0: 69 74 20 74 6f 20 73 74 61 74 65 20 49 4e 43 4f  it to state INCO
53c0: 4d 50 4c 45 54 45 20 61 6e 64 20 73 74 61 74 75  MPLETE and statu
53d0: 73 20 53 54 55 43 4b 2f 44 45 41 44 22 29 0a 09  s STUCK/DEAD")..
53e0: 20 20 20 20 20 20 20 28 74 65 73 74 2d 73 65 74         (test-set
53f0: 2d 73 74 61 74 75 73 21 20 64 62 20 72 75 6e 2d  -status! db run-
5400: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 22 49 4e  id test-name "IN
5410: 43 4f 4d 50 4c 45 54 45 22 20 22 53 54 55 43 4b  COMPLETE" "STUCK
5420: 2f 44 45 41 44 22 20 69 74 65 6d 64 61 74 20 22  /DEAD" itemdat "
5430: 54 65 73 74 20 69 73 20 73 74 75 63 6b 20 6f 72  Test is stuck or
5440: 20 64 65 61 64 22 20 23 66 29 29 0a 09 20 20 20   dead" #f))..   
5450: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32    (debug:print 2
5460: 20 22 4e 4f 54 45 3a 20 22 20 74 65 73 74 2d 6e   "NOTE: " test-n
5470: 61 6d 65 20 22 20 69 73 20 61 6c 72 65 61 64 79  ame " is already
5480: 20 72 75 6e 6e 69 6e 67 22 29 29 29 0a 09 28 65   running")))..(e
5490: 6c 73 65 20 20 20 20 20 20 20 28 64 65 62 75 67  lse       (debug
54a0: 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a  :print 0 "ERROR:
54b0: 20 46 61 69 6c 65 64 20 74 6f 20 6c 61 75 6e 63   Failed to launc
54c0: 68 20 74 65 73 74 20 22 20 6e 65 77 2d 74 65 73  h test " new-tes
54d0: 74 2d 6e 61 6d 65 20 22 2e 20 55 6e 72 65 63 6f  t-name ". Unreco
54e0: 67 6e 69 73 65 64 20 73 74 61 74 65 20 22 20 28  gnised state " (
54f0: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74  test:get-state t
5500: 65 73 74 64 61 74 29 29 29 29 29 29 29 0a 0a 3b  estdat)))))))..;
5510: 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ;===============
5520: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5530: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5540: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5550: 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 45 4e 44 20 4f  =======.;; END O
5560: 46 20 4e 45 57 20 53 54 55 46 46 0a 3b 3b 3d 3d  F NEW STUFF.;;==
5570: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5580: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5590: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
55a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
55b0: 3d 3d 3d 3d 0a 0a 28 64 65 66 69 6e 65 20 28 67  ====..(define (g
55c0: 65 74 2d 64 69 72 2d 75 70 2d 6e 20 64 69 72 20  et-dir-up-n dir 
55d0: 2e 20 70 61 72 61 6d 73 29 20 0a 20 20 28 6c 65  . params) .  (le
55e0: 74 20 28 28 64 70 61 72 74 73 20 20 28 73 74 72  t ((dparts  (str
55f0: 69 6e 67 2d 73 70 6c 69 74 20 64 69 72 20 22 2f  ing-split dir "/
5600: 22 29 29 0a 09 28 63 6f 75 6e 74 20 20 20 28 69  "))..(count   (i
5610: 66 20 28 6e 75 6c 6c 3f 20 70 61 72 61 6d 73 29  f (null? params)
5620: 20 31 20 28 63 61 72 20 70 61 72 61 6d 73 29 29   1 (car params))
5630: 29 29 0a 20 20 20 20 28 63 6f 6e 63 20 22 2f 22  )).    (conc "/"
5640: 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70   (string-intersp
5650: 65 72 73 65 20 0a 09 20 20 20 20 20 20 20 28 74  erse ..       (t
5660: 61 6b 65 20 64 70 61 72 74 73 20 28 2d 20 28 6c  ake dparts (- (l
5670: 65 6e 67 74 68 20 64 70 61 72 74 73 29 20 63 6f  ength dparts) co
5680: 75 6e 74 29 29 0a 09 20 20 20 20 20 20 20 22 2f  unt))..       "/
5690: 22 29 29 29 29 0a 3b 3b 20 52 65 6d 6f 76 65 20  ")))).;; Remove 
56a0: 72 75 6e 73 0a 3b 3b 20 66 69 65 6c 64 73 20 61  runs.;; fields a
56b0: 72 65 20 70 61 73 73 69 6e 67 20 69 6e 20 74 68  re passing in th
56c0: 72 6f 75 67 68 20 0a 28 64 65 66 69 6e 65 20 28  rough .(define (
56d0: 72 75 6e 73 3a 72 65 6d 6f 76 65 2d 72 75 6e 73  runs:remove-runs
56e0: 20 64 62 20 72 75 6e 6e 61 6d 65 70 61 74 74 20   db runnamepatt 
56f0: 74 65 73 74 70 61 74 74 20 69 74 65 6d 70 61 74  testpatt itempat
5700: 74 29 0a 20 20 28 6c 65 74 2a 20 28 28 6b 65 79  t).  (let* ((key
5710: 73 20 20 20 20 20 20 20 20 28 64 62 2d 67 65 74  s        (db-get
5720: 2d 6b 65 79 73 20 64 62 29 29 0a 09 20 28 72 75  -keys db)).. (ru
5730: 6e 64 61 74 20 20 20 20 20 20 28 72 75 6e 73 3a  ndat      (runs:
5740: 67 65 74 2d 72 75 6e 73 2d 62 79 2d 70 61 74 74  get-runs-by-patt
5750: 20 64 62 20 6b 65 79 73 20 72 75 6e 6e 61 6d 65   db keys runname
5760: 70 61 74 74 29 29 0a 09 20 28 68 65 61 64 65 72  patt)).. (header
5770: 20 20 20 20 20 20 28 76 65 63 74 6f 72 2d 72 65        (vector-re
5780: 66 20 72 75 6e 64 61 74 20 30 29 29 0a 09 20 28  f rundat 0)).. (
5790: 72 75 6e 73 20 20 20 20 20 20 20 20 28 76 65 63  runs        (vec
57a0: 74 6f 72 2d 72 65 66 20 72 75 6e 64 61 74 20 31  tor-ref rundat 1
57b0: 29 29 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70  ))).    (debug:p
57c0: 72 69 6e 74 20 31 20 22 48 65 61 64 65 72 3a 20  rint 1 "Header: 
57d0: 22 20 68 65 61 64 65 72 29 0a 20 20 20 20 28 66  " header).    (f
57e0: 6f 72 2d 65 61 63 68 0a 20 20 20 20 20 28 6c 61  or-each.     (la
57f0: 6d 62 64 61 20 28 72 75 6e 29 0a 20 20 20 20 20  mbda (run).     
5800: 20 20 28 6c 65 74 20 28 28 72 75 6e 6b 65 79 20    (let ((runkey 
5810: 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65  (string-interspe
5820: 72 73 65 20 28 6d 61 70 20 28 6c 61 6d 62 64 61  rse (map (lambda
5830: 20 28 6b 29 0a 09 09 09 09 09 09 28 64 62 3a 67   (k).......(db:g
5840: 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64  et-value-by-head
5850: 65 72 20 72 75 6e 20 68 65 61 64 65 72 20 28 76  er run header (v
5860: 65 63 74 6f 72 2d 72 65 66 20 6b 20 30 29 29 29  ector-ref k 0)))
5870: 20 6b 65 79 73 29 20 22 2f 22 29 29 0a 09 20 20   keys) "/"))..  
5880: 20 20 20 28 64 69 72 73 2d 74 6f 2d 72 65 6d 6f     (dirs-to-remo
5890: 76 65 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61  ve (make-hash-ta
58a0: 62 6c 65 29 29 29 0a 09 20 28 6c 65 74 2a 20 28  ble))).. (let* (
58b0: 28 72 75 6e 2d 69 64 20 28 64 62 3a 67 65 74 2d  (run-id (db:get-
58c0: 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20  value-by-header 
58d0: 72 75 6e 20 68 65 61 64 65 72 20 22 69 64 22 29  run header "id")
58e0: 20 29 0a 09 09 28 74 65 73 74 73 20 20 28 64 62   )...(tests  (db
58f0: 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d 72  -get-tests-for-r
5900: 75 6e 20 64 62 20 28 64 62 3a 67 65 74 2d 76 61  un db (db:get-va
5910: 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75  lue-by-header ru
5920: 6e 20 68 65 61 64 65 72 20 22 69 64 22 29 20 74  n header "id") t
5930: 65 73 74 70 61 74 74 20 69 74 65 6d 70 61 74 74  estpatt itempatt
5940: 20 27 28 29 20 27 28 29 29 29 0a 09 09 28 6c 61   '() '()))...(la
5950: 73 74 74 70 61 74 68 20 22 2f 64 6f 65 73 2f 6e  sttpath "/does/n
5960: 6f 74 2f 65 78 69 73 74 2f 49 2f 68 6f 70 65 22  ot/exist/I/hope"
5970: 29 29 0a 0a 09 20 20 20 28 69 66 20 28 6e 6f 74  ))...   (if (not
5980: 20 28 6e 75 6c 6c 3f 20 74 65 73 74 73 29 29 0a   (null? tests)).
5990: 09 20 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09  .       (begin..
59a0: 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31  . (debug:print 1
59b0: 20 22 52 65 6d 6f 76 69 6e 67 20 74 65 73 74 73   "Removing tests
59c0: 20 66 6f 72 20 72 75 6e 3a 20 22 20 72 75 6e 6b   for run: " runk
59d0: 65 79 20 22 20 22 20 28 64 62 3a 67 65 74 2d 76  ey " " (db:get-v
59e0: 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72  alue-by-header r
59f0: 75 6e 20 68 65 61 64 65 72 20 22 72 75 6e 6e 61  un header "runna
5a00: 6d 65 22 29 29 0a 09 09 20 28 66 6f 72 2d 65 61  me"))... (for-ea
5a10: 63 68 0a 09 09 20 20 28 6c 61 6d 62 64 61 20 28  ch...  (lambda (
5a20: 74 65 73 74 29 0a 09 09 20 20 20 20 28 6c 65 74  test)...    (let
5a30: 2a 20 28 28 69 74 65 6d 2d 70 61 74 68 20 28 64  * ((item-path (d
5a40: 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d  b:test-get-item-
5a50: 70 61 74 68 20 74 65 73 74 29 29 0a 09 09 09 20  path test)).... 
5a60: 20 20 28 74 65 73 74 2d 6e 61 6d 65 20 28 64 62    (test-name (db
5a70: 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61  :test-get-testna
5a80: 6d 65 20 74 65 73 74 29 29 0a 09 09 09 20 20 20  me test))....   
5a90: 28 72 75 6e 2d 64 69 72 20 20 20 28 64 62 3a 74  (run-dir   (db:t
5aa0: 65 73 74 2d 67 65 74 2d 72 75 6e 64 69 72 20 74  est-get-rundir t
5ab0: 65 73 74 29 29 29 0a 09 09 20 20 20 20 20 20 28  est)))...      (
5ac0: 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 20  debug:print 1 " 
5ad0: 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d   " (db:test-get-
5ae0: 74 65 73 74 6e 61 6d 65 20 74 65 73 74 29 20 22  testname test) "
5af0: 20 69 64 3a 20 22 20 28 64 62 3a 74 65 73 74 2d   id: " (db:test-
5b00: 67 65 74 2d 69 64 20 74 65 73 74 29 20 22 20 22  get-id test) " "
5b10: 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 09 20 20   item-path)...  
5b20: 20 20 20 20 28 64 62 3a 64 65 6c 65 74 65 2d 74      (db:delete-t
5b30: 65 73 74 2d 72 65 63 6f 72 64 73 20 64 62 20 28  est-records db (
5b40: 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74  db:test-get-id t
5b50: 65 73 74 29 29 0a 09 09 20 20 20 20 20 20 28 69  est))...      (i
5b60: 66 20 28 3e 20 28 73 74 72 69 6e 67 2d 6c 65 6e  f (> (string-len
5b70: 67 74 68 20 72 75 6e 2d 64 69 72 29 20 35 29 20  gth run-dir) 5) 
5b80: 3b 3b 20 62 61 64 20 68 65 75 72 69 73 74 69 63  ;; bad heuristic
5b90: 20 62 75 74 20 73 68 6f 75 6c 64 20 70 72 65 76   but should prev
5ba0: 65 6e 74 20 2f 74 6d 70 20 2f 68 6f 6d 65 20 65  ent /tmp /home e
5bb0: 74 63 2e 0a 09 09 09 20 20 28 6c 65 74 20 28 28  tc.....  (let ((
5bc0: 66 75 6c 6c 70 61 74 68 20 72 75 6e 2d 64 69 72  fullpath run-dir
5bd0: 29 29 20 3b 3b 20 22 2f 22 20 28 64 62 3a 74 65  )) ;; "/" (db:te
5be0: 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68  st-get-item-path
5bf0: 20 74 65 73 74 29 29 29 29 0a 09 09 09 20 20 20   test))))....   
5c00: 20 28 73 65 74 21 20 6c 61 73 74 74 70 61 74 68   (set! lasttpath
5c10: 20 66 75 6c 6c 70 61 74 68 29 0a 09 09 09 20 20   fullpath)....  
5c20: 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65    (hash-table-se
5c30: 74 21 20 64 69 72 73 2d 74 6f 2d 72 65 6d 6f 76  t! dirs-to-remov
5c40: 65 20 66 75 6c 6c 70 61 74 68 20 23 74 29 0a 09  e fullpath #t)..
5c50: 09 09 20 20 20 20 3b 3b 20 54 68 65 20 66 6f 6c  ..    ;; The fol
5c60: 6c 6f 77 69 6e 67 20 77 61 73 20 74 68 65 20 73  lowing was the s
5c70: 61 66 65 20 64 65 6c 65 74 65 20 63 6f 64 65 20  afe delete code 
5c80: 62 75 74 20 69 74 20 77 61 73 20 6e 6f 74 20 62  but it was not b
5c90: 65 69 6e 67 20 65 78 65 63 74 75 74 65 64 2e 0a  eing exectuted..
5ca0: 09 09 09 20 20 20 20 3b 3b 20 28 6c 65 74 2a 20  ...    ;; (let* 
5cb0: 28 28 64 69 72 73 2d 63 6f 75 6e 74 20 28 2b 20  ((dirs-count (+ 
5cc0: 31 20 28 6c 65 6e 67 74 68 20 6b 65 79 73 29 28  1 (length keys)(
5cd0: 6c 65 6e 67 74 68 20 28 73 74 72 69 6e 67 2d 73  length (string-s
5ce0: 70 6c 69 74 20 69 74 65 6d 2d 70 61 74 68 20 22  plit item-path "
5cf0: 2f 22 29 29 29 29 0a 09 09 09 20 20 20 20 3b 3b  /"))))....    ;;
5d00: 20 20 20 20 20 20 20 20 28 64 69 72 2d 74 6f 2d          (dir-to-
5d10: 72 65 6d 20 28 67 65 74 2d 64 69 72 2d 75 70 2d  rem (get-dir-up-
5d20: 6e 20 66 75 6c 6c 70 61 74 68 20 64 69 72 73 2d  n fullpath dirs-
5d30: 63 6f 75 6e 74 29 29 0a 09 09 09 20 20 20 20 3b  count))....    ;
5d40: 3b 20 20 20 20 20 20 20 20 28 72 65 6d 61 69 6e  ;        (remain
5d50: 69 6e 67 64 20 28 73 74 72 69 6e 67 2d 73 75 62  ingd (string-sub
5d60: 73 74 69 74 75 74 65 20 28 72 65 67 65 78 70 20  stitute (regexp 
5d70: 28 63 6f 6e 63 20 22 5e 22 20 64 69 72 2d 74 6f  (conc "^" dir-to
5d80: 2d 72 65 6d 20 22 2f 22 29 29 20 22 22 20 66 75  -rem "/")) "" fu
5d90: 6c 6c 70 61 74 68 29 29 0a 09 09 09 20 20 20 20  llpath))....    
5da0: 3b 3b 20 20 20 20 20 20 20 20 28 63 6d 64 20 28  ;;        (cmd (
5db0: 63 6f 6e 63 20 22 63 64 20 22 20 64 69 72 2d 74  conc "cd " dir-t
5dc0: 6f 2d 72 65 6d 20 22 3b 20 72 6d 64 69 72 20 2d  o-rem "; rmdir -
5dd0: 70 20 22 20 72 65 6d 61 69 6e 69 6e 67 64 20 29  p " remainingd )
5de0: 29 29 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 28  ))....    ;;   (
5df0: 69 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f  if (file-exists?
5e00: 20 66 75 6c 6c 70 61 74 68 29 0a 09 09 09 20 20   fullpath)....  
5e10: 20 20 3b 3b 20 20 20 20 20 20 20 28 62 65 67 69    ;;       (begi
5e20: 6e 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20  n....    ;;     
5e30: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
5e40: 20 31 20 63 6d 64 29 0a 09 09 09 20 20 20 20 3b   1 cmd)....    ;
5e50: 3b 20 20 20 20 20 20 20 20 20 28 73 79 73 74 65  ;         (syste
5e60: 6d 20 63 6d 64 29 29 29 0a 09 09 09 20 20 20 20  m cmd)))....    
5e70: 3b 3b 20 20 20 29 29 0a 09 09 09 20 20 20 20 29  ;;   ))....    )
5e80: 29 29 29 0a 09 09 20 20 20 20 74 65 73 74 73 29  )))...    tests)
5e90: 29 29 0a 0a 09 20 20 20 3b 3b 20 6c 6f 6f 6b 20  ))...   ;; look 
5ea0: 74 68 6f 75 67 68 20 74 68 65 20 64 69 72 73 2d  though the dirs-
5eb0: 74 6f 2d 72 65 6d 6f 76 65 20 66 6f 72 20 63 61  to-remove for ca
5ec0: 6e 64 69 64 61 74 65 73 20 66 6f 72 20 72 65 6d  ndidates for rem
5ed0: 6f 76 61 6c 2e 20 44 6f 20 74 68 69 73 20 61 66  oval. Do this af
5ee0: 74 65 72 20 64 65 6c 65 74 69 6e 67 20 74 68 65  ter deleting the
5ef0: 20 72 65 63 6f 72 64 73 0a 09 20 20 20 3b 3b 20   records..   ;; 
5f00: 66 6f 72 20 65 61 63 68 20 74 65 73 74 20 69 6e  for each test in
5f10: 20 63 61 73 65 20 77 65 20 67 65 74 20 6b 69 6c   case we get kil
5f20: 6c 65 64 2e 20 54 68 61 74 20 73 68 6f 75 6c 64  led. That should
5f30: 20 6d 69 6e 69 6d 69 7a 65 20 74 68 65 20 64 65   minimize the de
5f40: 74 72 69 74 75 73 20 6c 65 66 74 20 6f 6e 20 64  tritus left on d
5f50: 69 73 6b 0a 09 20 20 20 3b 3b 20 70 72 6f 63 65  isk..   ;; proce
5f60: 73 73 20 74 68 65 20 64 69 72 73 20 66 72 6f 6d  ss the dirs from
5f70: 20 6c 6f 6e 67 65 73 74 20 73 74 72 69 6e 67 20   longest string 
5f80: 6c 65 6e 67 74 68 20 74 6f 20 73 68 6f 72 74 65  length to shorte
5f90: 73 74 0a 09 20 20 20 28 66 6f 72 2d 65 61 63 68  st..   (for-each
5fa0: 20 0a 09 20 20 20 20 28 6c 61 6d 62 64 61 20 28   ..    (lambda (
5fb0: 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 0a 09  dir-to-remove)..
5fc0: 20 20 20 20 20 20 28 69 66 20 28 66 69 6c 65 2d        (if (file-
5fd0: 65 78 69 73 74 73 3f 20 64 69 72 2d 74 6f 2d 72  exists? dir-to-r
5fe0: 65 6d 6f 76 65 29 0a 09 09 20 20 28 6c 65 74 20  emove)...  (let 
5ff0: 28 28 64 69 72 2d 69 6e 2d 64 62 20 27 28 29 29  ((dir-in-db '())
6000: 29 0a 09 09 20 20 20 20 28 73 71 6c 69 74 65 33  )...    (sqlite3
6010: 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77 0a 09 09  :for-each-row...
6020: 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 64 69       (lambda (di
6030: 72 29 0a 09 09 20 20 20 20 20 20 20 28 73 65 74  r)...       (set
6040: 21 20 64 69 72 2d 69 6e 2d 64 62 20 28 63 6f 6e  ! dir-in-db (con
6050: 73 20 64 69 72 20 64 69 72 2d 69 6e 2d 64 62 29  s dir dir-in-db)
6060: 29 29 0a 09 09 20 20 20 20 20 64 62 20 22 53 45  ))...     db "SE
6070: 4c 45 43 54 20 72 75 6e 64 69 72 20 46 52 4f 4d  LECT rundir FROM
6080: 20 74 65 73 74 73 20 57 48 45 52 45 20 72 75 6e   tests WHERE run
6090: 64 69 72 20 4c 49 4b 45 20 3f 3b 22 20 0a 09 09  dir LIKE ?;" ...
60a0: 20 20 20 20 20 28 63 6f 6e 63 20 22 25 22 20 64       (conc "%" d
60b0: 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 20 22 25 22  ir-to-remove "%"
60c0: 29 29 20 3b 3b 20 79 65 73 2c 20 49 27 6d 20 67  )) ;; yes, I'm g
60d0: 6f 69 6e 67 20 74 6f 20 62 61 69 6c 20 69 66 20  oing to bail if 
60e0: 74 68 65 72 65 20 69 73 20 61 6e 79 74 68 69 6e  there is anythin
60f0: 67 20 6c 69 6b 65 20 74 68 69 73 20 64 69 72 20  g like this dir 
6100: 69 6e 20 74 68 65 20 64 62 0a 09 09 20 20 20 20  in the db...    
6110: 28 69 66 20 28 6e 75 6c 6c 3f 20 64 69 72 2d 69  (if (null? dir-i
6120: 6e 2d 64 62 29 0a 09 09 09 28 62 65 67 69 6e 0a  n-db)....(begin.
6130: 09 09 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e  ...  (debug:prin
6140: 74 20 32 20 22 52 65 6d 6f 76 69 6e 67 20 64 69  t 2 "Removing di
6150: 72 65 63 74 6f 72 79 20 77 69 74 68 20 7a 65 72  rectory with zer
6160: 6f 20 64 62 20 72 65 66 65 72 65 6e 63 65 73 3a  o db references:
6170: 20 22 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65   " dir-to-remove
6180: 29 0a 09 09 09 20 20 28 73 79 73 74 65 6d 20 28  )....  (system (
6190: 63 6f 6e 63 20 22 72 6d 20 2d 72 66 20 22 20 64  conc "rm -rf " d
61a0: 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 29 0a 09  ir-to-remove))..
61b0: 09 09 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d  ..  (hash-table-
61c0: 64 65 6c 65 74 65 21 20 64 69 72 73 2d 74 6f 2d  delete! dirs-to-
61d0: 72 65 6d 6f 76 65 20 64 69 72 2d 74 6f 2d 72 65  remove dir-to-re
61e0: 6d 6f 76 65 29 29 0a 09 09 09 28 64 65 62 75 67  move))....(debug
61f0: 3a 70 72 69 6e 74 20 32 20 22 53 6b 69 70 70 69  :print 2 "Skippi
6200: 6e 67 20 72 65 6d 6f 76 61 6c 20 6f 66 20 22 20  ng removal of " 
6210: 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 20 22 20  dir-to-remove " 
6220: 66 6f 72 20 6e 6f 77 20 61 73 20 69 74 20 73 74  for now as it st
6230: 69 6c 6c 20 68 61 73 20 72 65 66 65 72 65 6e 63  ill has referenc
6240: 65 73 20 69 6e 20 74 68 65 20 64 61 74 61 62 61  es in the databa
6250: 73 65 22 29 29 29 29 29 0a 09 20 20 20 20 28 73  se")))))..    (s
6260: 6f 72 74 20 28 68 61 73 68 2d 74 61 62 6c 65 2d  ort (hash-table-
6270: 6b 65 79 73 20 64 69 72 73 2d 74 6f 2d 72 65 6d  keys dirs-to-rem
6280: 6f 76 65 29 20 28 6c 61 6d 62 64 61 20 28 61 20  ove) (lambda (a 
6290: 62 29 28 3e 20 28 73 74 72 69 6e 67 2d 6c 65 6e  b)(> (string-len
62a0: 67 74 68 20 61 29 28 73 74 72 69 6e 67 2d 6c 65  gth a)(string-le
62b0: 6e 67 74 68 20 62 29 29 29 29 29 0a 0a 09 20 20  ngth b)))))...  
62c0: 20 3b 3b 20 72 65 6d 6f 76 65 20 74 68 65 20 72   ;; remove the r
62d0: 75 6e 20 69 66 20 7a 65 72 6f 20 74 65 73 74 73  un if zero tests
62e0: 20 72 65 6d 61 69 6e 0a 09 20 20 20 28 6c 65 74   remain..   (let
62f0: 20 28 28 72 65 6d 74 65 73 74 73 20 28 64 62 2d   ((remtests (db-
6300: 67 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d 72 75  get-tests-for-ru
6310: 6e 20 64 62 20 28 64 62 3a 67 65 74 2d 76 61 6c  n db (db:get-val
6320: 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e  ue-by-header run
6330: 20 68 65 61 64 65 72 20 22 69 64 22 29 20 23 66   header "id") #f
6340: 20 23 66 20 27 28 29 20 27 28 29 29 29 29 0a 09   #f '() '())))..
6350: 20 20 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20       (if (null? 
6360: 72 65 6d 74 65 73 74 73 29 20 3b 3b 20 6e 6f 20  remtests) ;; no 
6370: 6d 6f 72 65 20 74 65 73 74 73 20 72 65 6d 61 69  more tests remai
6380: 6e 69 6e 67 0a 09 09 20 28 6c 65 74 2a 20 28 28  ning... (let* ((
6390: 64 70 61 72 74 73 20 20 28 73 74 72 69 6e 67 2d  dparts  (string-
63a0: 73 70 6c 69 74 20 6c 61 73 74 74 70 61 74 68 20  split lasttpath 
63b0: 22 2f 22 29 29 0a 09 09 09 28 72 75 6e 70 61 74  "/"))....(runpat
63c0: 68 20 28 63 6f 6e 63 20 22 2f 22 20 28 73 74 72  h (conc "/" (str
63d0: 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20  ing-intersperse 
63e0: 0a 09 09 09 09 09 20 20 20 20 28 74 61 6b 65 20  ......    (take 
63f0: 64 70 61 72 74 73 20 28 2d 20 28 6c 65 6e 67 74  dparts (- (lengt
6400: 68 20 64 70 61 72 74 73 29 20 31 29 29 0a 09 09  h dparts) 1))...
6410: 09 09 09 20 20 20 20 22 2f 22 29 29 29 29 0a 09  ...    "/"))))..
6420: 09 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74  .   (debug:print
6430: 20 31 20 22 52 65 6d 6f 76 69 6e 67 20 72 75 6e   1 "Removing run
6440: 3a 20 22 20 72 75 6e 6b 65 79 20 22 20 22 20 28  : " runkey " " (
6450: 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d  db:get-value-by-
6460: 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65  header run heade
6470: 72 20 22 72 75 6e 6e 61 6d 65 22 29 29 0a 09 09  r "runname"))...
6480: 20 20 20 28 64 62 3a 64 65 6c 65 74 65 2d 72 75     (db:delete-ru
6490: 6e 20 64 62 20 72 75 6e 2d 69 64 29 0a 09 09 20  n db run-id)... 
64a0: 20 20 3b 3b 20 6e 65 65 64 20 74 6f 20 66 69 67    ;; need to fig
64b0: 75 72 65 20 6f 75 74 20 74 68 65 20 70 61 74 68  ure out the path
64c0: 20 74 6f 20 74 68 65 20 72 75 6e 20 64 69 72 20   to the run dir 
64d0: 61 6e 64 20 72 65 6d 6f 76 65 20 69 74 20 69 66  and remove it if
64e0: 20 65 6d 70 74 79 0a 09 09 20 20 20 3b 3b 20 20   empty...   ;;  
64f0: 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 28 67 6c    (if (null? (gl
6500: 6f 62 20 28 63 6f 6e 63 20 72 75 6e 70 61 74 68  ob (conc runpath
6510: 20 22 2f 2a 22 29 29 29 0a 09 09 20 20 20 3b 3b   "/*")))...   ;;
6520: 20 20 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09          (begin..
6530: 09 20 20 20 3b 3b 20 09 20 28 64 65 62 75 67 3a  .   ;; . (debug:
6540: 70 72 69 6e 74 20 31 20 22 52 65 6d 6f 76 69 6e  print 1 "Removin
6550: 67 20 72 75 6e 20 64 69 72 20 22 20 72 75 6e 70  g run dir " runp
6560: 61 74 68 29 0a 09 09 20 20 20 3b 3b 20 09 20 28  ath)...   ;; . (
6570: 73 79 73 74 65 6d 20 28 63 6f 6e 63 20 22 72 6d  system (conc "rm
6580: 64 69 72 20 2d 70 20 22 20 72 75 6e 70 61 74 68  dir -p " runpath
6590: 29 29 29 29 0a 09 09 20 20 20 29 29 29 29 0a 09  ))))...   ))))..
65a0: 20 29 29 0a 20 20 20 20 20 72 75 6e 73 29 29 29   )).     runs)))
65b0: 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ..;;============
65c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
65d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
65e0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
65f0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 52 6f  ==========.;; Ro
6600: 75 74 69 6e 65 73 20 66 6f 72 20 6d 61 6e 69 70  utines for manip
6610: 75 6c 61 74 69 6e 67 20 72 75 6e 73 0a 3b 3b 3d  ulating runs.;;=
6620: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6630: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6640: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6650: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6660: 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 53 69 6e 63 65 20  =====..;; Since 
6670: 6d 61 6e 79 20 63 61 6c 6c 73 20 74 6f 20 61 20  many calls to a 
6680: 72 75 6e 20 72 65 71 75 69 72 65 20 70 72 65 74  run require pret
6690: 74 79 20 6d 75 63 68 20 74 68 65 20 73 61 6d 65  ty much the same
66a0: 20 73 65 74 75 70 20 0a 3b 3b 20 74 68 69 73 20   setup .;; this 
66b0: 77 72 61 70 70 65 72 20 69 73 20 75 73 65 64 20  wrapper is used 
66c0: 74 6f 20 72 65 64 75 63 65 20 74 68 65 20 72 65  to reduce the re
66d0: 70 6c 69 63 61 74 69 6f 6e 20 6f 66 20 63 6f 64  plication of cod
66e0: 65 0a 28 64 65 66 69 6e 65 20 28 67 65 6e 65 72  e.(define (gener
66f0: 61 6c 2d 72 75 6e 2d 63 61 6c 6c 20 73 77 69 74  al-run-call swit
6700: 63 68 6e 61 6d 65 20 61 63 74 69 6f 6e 2d 64 65  chname action-de
6710: 73 63 20 70 72 6f 63 29 0a 20 20 28 6c 65 74 20  sc proc).  (let 
6720: 28 28 72 75 6e 6e 61 6d 65 20 28 61 72 67 73 3a  ((runname (args:
6730: 67 65 74 2d 61 72 67 20 22 3a 72 75 6e 6e 61 6d  get-arg ":runnam
6740: 65 22 29 29 0a 09 28 74 61 72 67 65 74 20 20 28  e"))..(target  (
6750: 69 66 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67  if (args:get-arg
6760: 20 22 2d 74 61 72 67 65 74 22 29 0a 09 09 20 20   "-target")...  
6770: 20 20 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67     (args:get-arg
6780: 20 22 2d 74 61 72 67 65 74 22 29 0a 09 09 20 20   "-target")...  
6790: 20 20 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67     (args:get-arg
67a0: 20 22 2d 72 65 71 74 61 72 67 22 29 29 29 29 0a   "-reqtarg")))).
67b0: 20 20 20 20 28 63 6f 6e 64 0a 20 20 20 20 20 28      (cond.     (
67c0: 28 6e 6f 74 20 74 61 72 67 65 74 29 0a 20 20 20  (not target).   
67d0: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
67e0: 30 20 22 45 52 52 4f 52 3a 20 4d 69 73 73 69 6e  0 "ERROR: Missin
67f0: 67 20 72 65 71 75 69 72 65 64 20 70 61 72 61 6d  g required param
6800: 65 74 65 72 20 66 6f 72 20 22 20 73 77 69 74 63  eter for " switc
6810: 68 6e 61 6d 65 20 22 2c 20 79 6f 75 20 6d 75 73  hname ", you mus
6820: 74 20 73 70 65 63 69 66 79 20 74 68 65 20 74 61  t specify the ta
6830: 72 67 65 74 20 77 69 74 68 20 2d 74 61 72 67 65  rget with -targe
6840: 74 22 29 0a 20 20 20 20 20 20 28 65 78 69 74 20  t").      (exit 
6850: 33 29 29 0a 20 20 20 20 20 28 28 6e 6f 74 20 72  3)).     ((not r
6860: 75 6e 6e 61 6d 65 29 0a 20 20 20 20 20 20 28 64  unname).      (d
6870: 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52  ebug:print 0 "ER
6880: 52 4f 52 3a 20 4d 69 73 73 69 6e 67 20 72 65 71  ROR: Missing req
6890: 75 69 72 65 64 20 70 61 72 61 6d 65 74 65 72 20  uired parameter 
68a0: 66 6f 72 20 22 20 73 77 69 74 63 68 6e 61 6d 65  for " switchname
68b0: 20 22 2c 20 79 6f 75 20 6d 75 73 74 20 73 70 65   ", you must spe
68c0: 63 69 66 79 20 74 68 65 20 72 75 6e 20 6e 61 6d  cify the run nam
68d0: 65 20 77 69 74 68 20 3a 72 75 6e 6e 61 6d 65 20  e with :runname 
68e0: 72 75 6e 6e 61 6d 65 22 29 0a 20 20 20 20 20 20  runname").      
68f0: 28 65 78 69 74 20 33 29 29 0a 20 20 20 20 20 28  (exit 3)).     (
6900: 65 6c 73 65 0a 20 20 20 20 20 20 28 6c 65 74 20  else.      (let 
6910: 28 28 64 62 20 20 20 23 66 29 0a 09 20 20 20 20  ((db   #f)..    
6920: 28 6b 65 79 73 20 23 66 29 29 0a 09 28 69 66 20  (keys #f))..(if 
6930: 28 6e 6f 74 20 28 73 65 74 75 70 2d 66 6f 72 2d  (not (setup-for-
6940: 72 75 6e 29 29 0a 09 20 20 20 20 28 62 65 67 69  run))..    (begi
6950: 6e 20 0a 09 20 20 20 20 20 20 28 64 65 62 75 67  n ..      (debug
6960: 3a 70 72 69 6e 74 20 30 20 22 46 61 69 6c 65 64  :print 0 "Failed
6970: 20 74 6f 20 73 65 74 75 70 2c 20 65 78 69 74 69   to setup, exiti
6980: 6e 67 22 29 0a 09 20 20 20 20 20 20 28 65 78 69  ng")..      (exi
6990: 74 20 31 29 29 29 0a 09 28 73 65 74 21 20 64 62  t 1)))..(set! db
69a0: 20 20 20 28 6f 70 65 6e 2d 64 62 29 29 0a 09 28     (open-db))..(
69b0: 73 65 74 21 20 6b 65 79 73 20 28 64 62 2d 67 65  set! keys (db-ge
69c0: 74 2d 6b 65 79 73 20 64 62 29 29 0a 09 3b 3b 20  t-keys db))..;; 
69d0: 68 61 76 65 20 65 6e 6f 75 67 68 20 74 6f 20 70  have enough to p
69e0: 72 6f 63 65 73 73 20 2d 74 61 72 67 65 74 20 6f  rocess -target o
69f0: 72 20 2d 72 65 71 74 61 72 67 20 68 65 72 65 0a  r -reqtarg here.
6a00: 09 28 69 66 20 28 61 72 67 73 3a 67 65 74 2d 61  .(if (args:get-a
6a10: 72 67 20 22 2d 72 65 71 74 61 72 67 22 29 0a 09  rg "-reqtarg")..
6a20: 20 20 20 20 28 6c 65 74 2a 20 28 28 72 75 6e 63      (let* ((runc
6a30: 6f 6e 66 69 67 66 20 28 63 6f 6e 63 20 20 2a 74  onfigf (conc  *t
6a40: 6f 70 70 61 74 68 2a 20 22 2f 72 75 6e 63 6f 6e  oppath* "/runcon
6a50: 66 69 67 73 2e 63 6f 6e 66 69 67 22 29 29 20 3b  figs.config")) ;
6a60: 3b 20 44 4f 20 4e 4f 54 20 45 56 41 4c 55 41 54  ; DO NOT EVALUAT
6a70: 45 20 41 4c 4c 20 0a 09 09 20 20 20 28 72 75 6e  E ALL ...   (run
6a80: 63 6f 6e 66 69 67 20 20 28 72 65 61 64 2d 63 6f  config  (read-co
6a90: 6e 66 69 67 20 72 75 6e 63 6f 6e 66 69 67 66 20  nfig runconfigf 
6aa0: 23 66 20 23 66 20 65 6e 76 69 72 6f 6e 2d 70 61  #f #f environ-pa
6ab0: 74 74 3a 20 23 66 29 29 29 20 0a 09 20 20 20 20  tt: #f))) ..    
6ac0: 20 20 28 69 66 20 28 68 61 73 68 2d 74 61 62 6c    (if (hash-tabl
6ad0: 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 72 75  e-ref/default ru
6ae0: 6e 63 6f 6e 66 69 67 20 28 61 72 67 73 3a 67 65  nconfig (args:ge
6af0: 74 2d 61 72 67 20 22 2d 72 65 71 74 61 72 67 22  t-arg "-reqtarg"
6b00: 29 20 23 66 29 0a 09 09 20 20 28 6b 65 79 73 3a  ) #f)...  (keys:
6b10: 74 61 72 67 65 74 2d 73 65 74 2d 61 72 67 73 20  target-set-args 
6b20: 6b 65 79 73 20 28 61 72 67 73 3a 67 65 74 2d 61  keys (args:get-a
6b30: 72 67 20 22 2d 72 65 71 74 61 72 67 22 29 20 61  rg "-reqtarg") a
6b40: 72 67 73 3a 61 72 67 2d 68 61 73 68 29 0a 09 09  rgs:arg-hash)...
6b50: 20 20 28 62 65 67 69 6e 0a 09 09 20 20 20 20 28    (begin...    (
6b60: 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45  debug:print 0 "E
6b70: 52 52 4f 52 3a 20 5b 22 20 28 61 72 67 73 3a 67  RROR: [" (args:g
6b80: 65 74 2d 61 72 67 20 22 2d 72 65 71 74 61 72 67  et-arg "-reqtarg
6b90: 22 29 20 22 5d 20 6e 6f 74 20 66 6f 75 6e 64 20  ") "] not found 
6ba0: 69 6e 20 22 20 72 75 6e 63 6f 6e 66 69 67 66 29  in " runconfigf)
6bb0: 0a 09 09 20 20 20 20 28 73 71 6c 69 74 65 33 3a  ...    (sqlite3:
6bc0: 66 69 6e 61 6c 69 7a 65 21 20 64 62 29 0a 09 09  finalize! db)...
6bd0: 20 20 20 20 28 65 78 69 74 20 31 29 29 29 29 0a      (exit 1)))).
6be0: 09 20 20 20 20 28 69 66 20 28 61 72 67 73 3a 67  .    (if (args:g
6bf0: 65 74 2d 61 72 67 20 22 2d 74 61 72 67 65 74 22  et-arg "-target"
6c00: 29 0a 09 09 28 6b 65 79 73 3a 74 61 72 67 65 74  )...(keys:target
6c10: 2d 73 65 74 2d 61 72 67 73 20 6b 65 79 73 20 28  -set-args keys (
6c20: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 74  args:get-arg "-t
6c30: 61 72 67 65 74 22 20 61 72 67 73 3a 61 72 67 2d  arget" args:arg-
6c40: 68 61 73 68 29 20 61 72 67 73 3a 61 72 67 2d 68  hash) args:arg-h
6c50: 61 73 68 29 29 29 0a 09 28 69 66 20 28 6e 6f 74  ash)))..(if (not
6c60: 20 28 63 61 72 20 2a 63 6f 6e 66 69 67 69 6e 66   (car *configinf
6c70: 6f 2a 29 29 0a 09 20 20 20 20 28 62 65 67 69 6e  o*))..    (begin
6c80: 0a 09 20 20 20 20 20 20 28 64 65 62 75 67 3a 70  ..      (debug:p
6c90: 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 41  rint 0 "ERROR: A
6ca0: 74 74 65 6d 70 74 65 64 20 74 6f 20 22 20 61 63  ttempted to " ac
6cb0: 74 69 6f 6e 2d 64 65 73 63 20 22 20 62 75 74 20  tion-desc " but 
6cc0: 72 75 6e 20 61 72 65 61 20 63 6f 6e 66 69 67 20  run area config 
6cd0: 66 69 6c 65 20 6e 6f 74 20 66 6f 75 6e 64 22 29  file not found")
6ce0: 0a 09 20 20 20 20 20 20 28 65 78 69 74 20 31 29  ..      (exit 1)
6cf0: 29 0a 09 20 20 20 20 3b 3b 20 45 78 74 72 61 63  )..    ;; Extrac
6d00: 74 20 6f 75 74 20 73 74 75 66 66 20 6e 65 65 64  t out stuff need
6d10: 65 64 20 69 6e 20 6d 6f 73 74 20 6f 72 20 6d 61  ed in most or ma
6d20: 6e 79 20 63 61 6c 6c 73 0a 09 20 20 20 20 3b 3b  ny calls..    ;;
6d30: 20 68 65 72 65 20 74 68 65 6e 20 63 61 6c 6c 20   here then call 
6d40: 70 72 6f 63 0a 09 20 20 20 20 28 6c 65 74 2a 20  proc..    (let* 
6d50: 28 28 6b 65 79 6e 61 6d 65 73 20 20 20 28 6d 61  ((keynames   (ma
6d60: 70 20 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64 6e  p key:get-fieldn
6d70: 61 6d 65 20 6b 65 79 73 29 29 0a 09 09 20 20 20  ame keys))...   
6d80: 28 6b 65 79 76 61 6c 6c 73 74 20 20 28 6b 65 79  (keyvallst  (key
6d90: 73 2d 3e 76 61 6c 6c 69 73 74 20 6b 65 79 73 20  s->vallist keys 
6da0: 23 74 29 29 29 0a 09 20 20 20 20 20 20 28 70 72  #t)))..      (pr
6db0: 6f 63 20 64 62 20 74 61 72 67 65 74 20 72 75 6e  oc db target run
6dc0: 6e 61 6d 65 20 6b 65 79 73 20 6b 65 79 6e 61 6d  name keys keynam
6dd0: 65 73 20 6b 65 79 76 61 6c 6c 73 74 29 29 29 0a  es keyvallst))).
6de0: 09 28 73 71 6c 69 74 65 33 3a 66 69 6e 61 6c 69  .(sqlite3:finali
6df0: 7a 65 21 20 64 62 29 0a 09 28 73 65 74 21 20 2a  ze! db)..(set! *
6e00: 64 69 64 73 6f 6d 65 74 68 69 6e 67 2a 20 23 74  didsomething* #t
6e10: 29 29 29 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d  ))))))..;;======
6e20: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6e30: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6e40: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6e50: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6e60: 0a 3b 3b 20 52 6f 6c 6c 75 70 20 72 75 6e 73 0a  .;; Rollup runs.
6e70: 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ;;==============
6e80: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6e90: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6ea0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6eb0: 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 55 70 64  ========..;; Upd
6ec0: 61 74 65 20 74 68 65 20 74 65 73 74 5f 6d 65 74  ate the test_met
6ed0: 61 20 74 61 62 6c 65 20 66 6f 72 20 74 68 69 73  a table for this
6ee0: 20 74 65 73 74 0a 28 64 65 66 69 6e 65 20 28 72   test.(define (r
6ef0: 75 6e 73 3a 75 70 64 61 74 65 2d 74 65 73 74 5f  uns:update-test_
6f00: 6d 65 74 61 20 64 62 20 74 65 73 74 2d 6e 61 6d  meta db test-nam
6f10: 65 20 74 65 73 74 2d 63 6f 6e 66 29 0a 20 20 28  e test-conf).  (
6f20: 6c 65 74 20 28 28 63 75 72 72 72 65 63 6f 72 64  let ((currrecord
6f30: 20 28 64 62 3a 74 65 73 74 6d 65 74 61 2d 67 65   (db:testmeta-ge
6f40: 74 2d 72 65 63 6f 72 64 20 64 62 20 74 65 73 74  t-record db test
6f50: 2d 6e 61 6d 65 29 29 29 0a 20 20 20 20 28 69 66  -name))).    (if
6f60: 20 28 6e 6f 74 20 63 75 72 72 72 65 63 6f 72 64   (not currrecord
6f70: 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 28 73 65  )..(begin..  (se
6f80: 74 21 20 63 75 72 72 72 65 63 6f 72 64 20 28 6d  t! currrecord (m
6f90: 61 6b 65 2d 76 65 63 74 6f 72 20 31 30 20 23 66  ake-vector 10 #f
6fa0: 29 29 0a 09 20 20 28 64 62 3a 74 65 73 74 6d 65  ))..  (db:testme
6fb0: 74 61 2d 61 64 64 2d 72 65 63 6f 72 64 20 64 62  ta-add-record db
6fc0: 20 74 65 73 74 2d 6e 61 6d 65 29 29 29 0a 20 20   test-name))).  
6fd0: 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 20 20    (for-each .   
6fe0: 20 20 28 6c 61 6d 62 64 61 20 28 6b 65 79 29 0a    (lambda (key).
6ff0: 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28 28 69         (let* ((i
7000: 64 78 20 28 63 61 64 72 20 6b 65 79 29 29 0a 09  dx (cadr key))..
7010: 20 20 20 20 20 20 28 66 6c 64 20 28 63 61 72 20        (fld (car 
7020: 20 6b 65 79 29 29 0a 09 20 20 20 20 20 20 28 76   key))..      (v
7030: 61 6c 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75  al (config-looku
7040: 70 20 74 65 73 74 2d 63 6f 6e 66 20 22 74 65 73  p test-conf "tes
7050: 74 5f 6d 65 74 61 22 20 66 6c 64 29 29 29 0a 09  t_meta" fld)))..
7060: 20 3b 3b 20 28 64 65 62 75 67 3a 70 72 69 6e 74   ;; (debug:print
7070: 20 35 20 22 69 64 78 3a 20 22 20 69 64 78 20 22   5 "idx: " idx "
7080: 20 66 6c 64 3a 20 22 20 66 6c 64 20 22 20 76 61   fld: " fld " va
7090: 6c 3a 20 22 20 76 61 6c 29 0a 09 20 28 69 66 20  l: " val).. (if 
70a0: 28 61 6e 64 20 76 61 6c 20 28 6e 6f 74 20 28 65  (and val (not (e
70b0: 71 75 61 6c 3f 20 28 76 65 63 74 6f 72 2d 72 65  qual? (vector-re
70c0: 66 20 63 75 72 72 72 65 63 6f 72 64 20 69 64 78  f currrecord idx
70d0: 29 20 76 61 6c 29 29 29 0a 09 20 20 20 20 20 28  ) val)))..     (
70e0: 62 65 67 69 6e 0a 09 20 20 20 20 20 20 20 28 70  begin..       (p
70f0: 72 69 6e 74 20 22 55 70 64 61 74 69 6e 67 20 22  rint "Updating "
7100: 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 22 20 66   test-name " " f
7110: 6c 64 20 22 20 74 6f 20 22 20 76 61 6c 29 0a 09  ld " to " val)..
7120: 20 20 20 20 20 20 20 28 64 62 3a 74 65 73 74 6d         (db:testm
7130: 65 74 61 2d 75 70 64 61 74 65 2d 66 69 65 6c 64  eta-update-field
7140: 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 20 66 6c   db test-name fl
7150: 64 20 76 61 6c 29 29 29 29 29 0a 20 20 20 20 20  d val))))).     
7160: 27 28 28 22 61 75 74 68 6f 72 22 20 32 29 28 22  '(("author" 2)("
7170: 6f 77 6e 65 72 22 20 33 29 28 22 64 65 73 63 72  owner" 3)("descr
7180: 69 70 74 69 6f 6e 22 20 34 29 28 22 72 65 76 69  iption" 4)("revi
7190: 65 77 65 64 22 20 35 29 28 22 74 61 67 73 22 20  ewed" 5)("tags" 
71a0: 39 29 29 29 29 29 0a 0a 3b 3b 20 55 70 64 61 74  9)))))..;; Updat
71b0: 65 20 74 65 73 74 5f 6d 65 74 61 20 66 6f 72 20  e test_meta for 
71c0: 61 6c 6c 20 74 65 73 74 73 0a 28 64 65 66 69 6e  all tests.(defin
71d0: 65 20 28 72 75 6e 73 3a 75 70 64 61 74 65 2d 61  e (runs:update-a
71e0: 6c 6c 2d 74 65 73 74 5f 6d 65 74 61 20 64 62 29  ll-test_meta db)
71f0: 0a 20 20 28 6c 65 74 20 28 28 74 65 73 74 2d 6e  .  (let ((test-n
7200: 61 6d 65 73 20 28 67 65 74 2d 61 6c 6c 2d 6c 65  ames (get-all-le
7210: 67 61 6c 2d 74 65 73 74 73 29 29 29 0a 20 20 20  gal-tests))).   
7220: 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 20 20 20   (for-each .    
7230: 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74 2d 6e   (lambda (test-n
7240: 61 6d 65 29 0a 20 20 20 20 20 20 20 28 6c 65 74  ame).       (let
7250: 2a 20 28 28 74 65 73 74 2d 70 61 74 68 20 20 20  * ((test-path   
7260: 20 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74 68 2a   (conc *toppath*
7270: 20 22 2f 74 65 73 74 73 2f 22 20 74 65 73 74 2d   "/tests/" test-
7280: 6e 61 6d 65 29 29 0a 09 20 20 20 20 20 20 28 74  name))..      (t
7290: 65 73 74 2d 63 6f 6e 66 69 67 66 20 28 63 6f 6e  est-configf (con
72a0: 63 20 74 65 73 74 2d 70 61 74 68 20 22 2f 74 65  c test-path "/te
72b0: 73 74 63 6f 6e 66 69 67 22 29 29 0a 09 20 20 20  stconfig"))..   
72c0: 20 20 20 28 74 65 73 74 65 78 69 73 74 73 20 20     (testexists  
72d0: 20 28 61 6e 64 20 28 66 69 6c 65 2d 65 78 69 73   (and (file-exis
72e0: 74 73 3f 20 74 65 73 74 2d 63 6f 6e 66 69 67 66  ts? test-configf
72f0: 29 28 66 69 6c 65 2d 72 65 61 64 2d 61 63 63 65  )(file-read-acce
7300: 73 73 3f 20 74 65 73 74 2d 63 6f 6e 66 69 67 66  ss? test-configf
7310: 29 29 29 0a 09 20 20 20 20 20 20 3b 3b 20 72 65  )))..      ;; re
7320: 61 64 20 63 6f 6e 66 69 67 73 20 77 69 74 68 20  ad configs with 
7330: 74 72 69 63 6b 73 20 74 75 72 6e 65 64 20 6f 66  tricks turned of
7340: 66 20 28 69 2e 65 2e 20 6e 6f 20 73 79 73 74 65  f (i.e. no syste
7350: 6d 29 0a 09 20 20 20 20 20 20 28 74 65 73 74 2d  m)..      (test-
7360: 63 6f 6e 66 20 20 20 20 28 69 66 20 74 65 73 74  conf    (if test
7370: 65 78 69 73 74 73 20 28 72 65 61 64 2d 63 6f 6e  exists (read-con
7380: 66 69 67 20 74 65 73 74 2d 63 6f 6e 66 69 67 66  fig test-configf
7390: 20 23 66 20 23 66 29 28 6d 61 6b 65 2d 68 61 73   #f #f)(make-has
73a0: 68 2d 74 61 62 6c 65 29 29 29 29 0a 09 20 28 72  h-table)))).. (r
73b0: 75 6e 73 3a 75 70 64 61 74 65 2d 74 65 73 74 5f  uns:update-test_
73c0: 6d 65 74 61 20 64 62 20 74 65 73 74 2d 6e 61 6d  meta db test-nam
73d0: 65 20 74 65 73 74 2d 63 6f 6e 66 29 29 29 0a 20  e test-conf))). 
73e0: 20 20 20 20 74 65 73 74 2d 6e 61 6d 65 73 29 29      test-names))
73f0: 29 0a 0a 3b 3b 20 54 68 69 73 20 63 6f 75 6c 64  )..;; This could
7400: 20 70 72 6f 62 61 62 6c 79 20 62 65 20 72 65 66   probably be ref
7410: 61 63 74 6f 72 65 64 20 69 6e 74 6f 20 6f 6e 65  actored into one
7420: 20 63 6f 6d 70 6c 65 78 20 71 75 65 72 79 20 2e   complex query .
7430: 2e 2e 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73  ...(define (runs
7440: 3a 72 6f 6c 6c 75 70 2d 72 75 6e 20 64 62 20 6b  :rollup-run db k
7450: 65 79 73 20 6b 65 79 76 61 6c 6c 73 74 20 72 75  eys keyvallst ru
7460: 6e 6e 61 6d 65 20 75 73 65 72 29 20 3b 3b 20 77  nname user) ;; w
7470: 61 73 20 74 61 72 67 65 74 2c 20 6e 6f 77 20 6b  as target, now k
7480: 65 79 76 61 6c 6c 73 74 0a 20 20 28 64 65 62 75  eyvallst.  (debu
7490: 67 3a 70 72 69 6e 74 20 34 20 22 72 75 6e 73 3a  g:print 4 "runs:
74a0: 72 6f 6c 6c 75 70 2d 72 75 6e 2c 20 6b 65 79 73  rollup-run, keys
74b0: 3a 20 22 20 6b 65 79 73 20 22 20 6b 65 79 76 61  : " keys " keyva
74c0: 6c 6c 73 74 3a 20 22 20 6b 65 79 76 61 6c 6c 73  llst: " keyvalls
74d0: 74 20 22 20 3a 72 75 6e 6e 61 6d 65 20 22 20 72  t " :runname " r
74e0: 75 6e 6e 61 6d 65 20 22 20 75 73 65 72 3a 20 22  unname " user: "
74f0: 20 75 73 65 72 29 0a 20 20 28 6c 65 74 2a 20 28   user).  (let* (
7500: 3b 20 28 6b 65 79 76 61 6c 6c 6c 73 74 20 20 20  ; (keyvalllst   
7510: 20 20 20 28 6b 65 79 73 3a 74 61 72 67 65 74 2d     (keys:target-
7520: 3e 6b 65 79 76 61 6c 20 6b 65 79 73 20 74 61 72  >keyval keys tar
7530: 67 65 74 29 29 0a 09 20 28 6e 65 77 2d 72 75 6e  get)).. (new-run
7540: 2d 69 64 20 20 20 20 20 20 28 72 75 6e 73 3a 72  -id      (runs:r
7550: 65 67 69 73 74 65 72 2d 72 75 6e 20 64 62 20 6b  egister-run db k
7560: 65 79 73 20 6b 65 79 76 61 6c 6c 73 74 20 72 75  eys keyvallst ru
7570: 6e 6e 61 6d 65 20 22 6e 65 77 22 20 22 6e 2f 61  nname "new" "n/a
7580: 22 20 75 73 65 72 29 29 0a 09 20 28 70 72 65 76  " user)).. (prev
7590: 2d 74 65 73 74 73 20 20 20 20 20 20 28 74 65 73  -tests      (tes
75a0: 74 3a 67 65 74 2d 6d 61 74 63 68 69 6e 67 2d 70  t:get-matching-p
75b0: 72 65 76 69 6f 75 73 2d 74 65 73 74 2d 72 75 6e  revious-test-run
75c0: 2d 72 65 63 6f 72 64 73 20 64 62 20 6e 65 77 2d  -records db new-
75d0: 72 75 6e 2d 69 64 20 22 25 22 20 22 25 22 29 29  run-id "%" "%"))
75e0: 0a 09 20 28 63 75 72 72 2d 74 65 73 74 73 20 20  .. (curr-tests  
75f0: 20 20 20 20 28 64 62 2d 67 65 74 2d 74 65 73 74      (db-get-test
7600: 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 6e 65 77  s-for-run db new
7610: 2d 72 75 6e 2d 69 64 20 22 25 22 20 22 25 22 20  -run-id "%" "%" 
7620: 27 28 29 20 27 28 29 29 29 0a 09 20 28 63 75 72  '() '())).. (cur
7630: 72 2d 74 65 73 74 73 2d 68 61 73 68 20 28 6d 61  r-tests-hash (ma
7640: 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29 29  ke-hash-table)))
7650: 0a 20 20 20 20 28 64 62 3a 75 70 64 61 74 65 2d  .    (db:update-
7660: 72 75 6e 2d 65 76 65 6e 74 5f 74 69 6d 65 20 64  run-event_time d
7670: 62 20 6e 65 77 2d 72 75 6e 2d 69 64 29 0a 20 20  b new-run-id).  
7680: 20 20 3b 3b 20 69 6e 64 65 78 20 74 68 65 20 61    ;; index the a
7690: 6c 72 65 61 64 79 20 73 61 76 65 64 20 74 65 73  lready saved tes
76a0: 74 73 20 62 79 20 74 65 73 74 6e 61 6d 65 20 61  ts by testname a
76b0: 6e 64 20 69 74 65 6d 64 61 74 20 69 6e 20 63 75  nd itemdat in cu
76c0: 72 72 2d 74 65 73 74 73 2d 68 61 73 68 0a 20 20  rr-tests-hash.  
76d0: 20 20 28 66 6f 72 2d 65 61 63 68 0a 20 20 20 20    (for-each.    
76e0: 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74 64 61   (lambda (testda
76f0: 74 29 0a 20 20 20 20 20 20 20 28 6c 65 74 2a 20  t).       (let* 
7700: 28 28 74 65 73 74 6e 61 6d 65 20 20 28 64 62 3a  ((testname  (db:
7710: 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d  test-get-testnam
7720: 65 20 74 65 73 74 64 61 74 29 29 0a 09 20 20 20  e testdat))..   
7730: 20 20 20 28 69 74 65 6d 2d 70 61 74 68 20 28 64     (item-path (d
7740: 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d  b:test-get-item-
7750: 70 61 74 68 20 74 65 73 74 64 61 74 29 29 0a 09  path testdat))..
7760: 20 20 20 20 20 20 28 66 75 6c 6c 2d 6e 61 6d 65        (full-name
7770: 20 28 63 6f 6e 63 20 74 65 73 74 6e 61 6d 65 20   (conc testname 
7780: 22 2f 22 20 69 74 65 6d 2d 70 61 74 68 29 29 29  "/" item-path)))
7790: 0a 09 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73  .. (hash-table-s
77a0: 65 74 21 20 63 75 72 72 2d 74 65 73 74 73 2d 68  et! curr-tests-h
77b0: 61 73 68 20 66 75 6c 6c 2d 6e 61 6d 65 20 74 65  ash full-name te
77c0: 73 74 64 61 74 29 29 29 0a 20 20 20 20 20 63 75  stdat))).     cu
77d0: 72 72 2d 74 65 73 74 73 29 0a 20 20 20 20 3b 3b  rr-tests).    ;;
77e0: 20 4e 4f 50 45 3a 20 4e 6f 6e 2d 6f 70 74 69 6d   NOPE: Non-optim
77f0: 61 6c 20 61 70 70 72 6f 61 63 68 2e 20 54 72 79  al approach. Try
7800: 20 74 68 69 73 20 69 6e 73 74 65 61 64 2e 0a 20   this instead.. 
7810: 20 20 20 3b 3b 20 20 20 31 2e 20 74 65 73 74 73     ;;   1. tests
7820: 20 61 72 65 20 72 65 63 65 69 76 65 64 20 69 6e   are received in
7830: 20 61 20 6c 69 73 74 2c 20 6d 6f 73 74 20 72 65   a list, most re
7840: 63 65 6e 74 20 66 69 72 73 74 0a 20 20 20 20 3b  cent first.    ;
7850: 3b 20 20 20 32 2e 20 72 65 70 6c 61 63 65 20 74  ;   2. replace t
7860: 68 65 20 72 6f 6c 6c 75 70 20 74 65 73 74 20 77  he rollup test w
7870: 69 74 68 20 74 68 65 20 6e 65 77 20 2a 61 6c 77  ith the new *alw
7880: 61 79 73 2a 0a 20 20 20 20 28 66 6f 72 2d 65 61  ays*.    (for-ea
7890: 63 68 20 0a 20 20 20 20 20 28 6c 61 6d 62 64 61  ch .     (lambda
78a0: 20 28 74 65 73 74 64 61 74 29 0a 20 20 20 20 20   (testdat).     
78b0: 20 20 28 6c 65 74 2a 20 28 28 74 65 73 74 6e 61    (let* ((testna
78c0: 6d 65 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74  me  (db:test-get
78d0: 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 64 61  -testname testda
78e0: 74 29 29 0a 09 20 20 20 20 20 20 28 69 74 65 6d  t))..      (item
78f0: 2d 70 61 74 68 20 28 64 62 3a 74 65 73 74 2d 67  -path (db:test-g
7900: 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73  et-item-path tes
7910: 74 64 61 74 29 29 0a 09 20 20 20 20 20 20 28 66  tdat))..      (f
7920: 75 6c 6c 2d 6e 61 6d 65 20 28 63 6f 6e 63 20 74  ull-name (conc t
7930: 65 73 74 6e 61 6d 65 20 22 2f 22 20 69 74 65 6d  estname "/" item
7940: 2d 70 61 74 68 29 29 0a 09 20 20 20 20 20 20 28  -path))..      (
7950: 70 72 65 76 2d 74 65 73 74 2d 64 61 74 20 28 68  prev-test-dat (h
7960: 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65  ash-table-ref/de
7970: 66 61 75 6c 74 20 63 75 72 72 2d 74 65 73 74 73  fault curr-tests
7980: 2d 68 61 73 68 20 66 75 6c 6c 2d 6e 61 6d 65 20  -hash full-name 
7990: 23 66 29 29 0a 09 20 20 20 20 20 20 28 74 65 73  #f))..      (tes
79a0: 74 2d 73 74 65 70 73 20 20 20 20 20 20 28 64 62  t-steps      (db
79b0: 3a 67 65 74 2d 73 74 65 70 73 2d 66 6f 72 2d 74  :get-steps-for-t
79c0: 65 73 74 20 64 62 20 28 64 62 3a 74 65 73 74 2d  est db (db:test-
79d0: 67 65 74 2d 69 64 20 74 65 73 74 64 61 74 29 29  get-id testdat))
79e0: 29 0a 09 20 20 20 20 20 20 28 6e 65 77 2d 74 65  )..      (new-te
79f0: 73 74 2d 72 65 63 6f 72 64 20 23 66 29 29 0a 09  st-record #f))..
7a00: 20 3b 3b 20 72 65 70 6c 61 63 65 20 74 68 65 73   ;; replace thes
7a10: 65 20 77 69 74 68 20 69 6e 73 65 72 74 20 2e 2e  e with insert ..
7a20: 2e 20 73 65 6c 65 63 74 0a 09 20 28 61 70 70 6c  . select.. (appl
7a30: 79 20 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74  y sqlite3:execut
7a40: 65 20 0a 09 09 64 62 20 0a 09 09 28 63 6f 6e 63  e ...db ...(conc
7a50: 20 22 49 4e 53 45 52 54 20 4f 52 20 52 45 50 4c   "INSERT OR REPL
7a60: 41 43 45 20 49 4e 54 4f 20 74 65 73 74 73 20 28  ACE INTO tests (
7a70: 72 75 6e 5f 69 64 2c 74 65 73 74 6e 61 6d 65 2c  run_id,testname,
7a80: 73 74 61 74 65 2c 73 74 61 74 75 73 2c 65 76 65  state,status,eve
7a90: 6e 74 5f 74 69 6d 65 2c 68 6f 73 74 2c 63 70 75  nt_time,host,cpu
7aa0: 6c 6f 61 64 2c 64 69 73 6b 66 72 65 65 2c 75 6e  load,diskfree,un
7ab0: 61 6d 65 2c 72 75 6e 64 69 72 2c 69 74 65 6d 5f  ame,rundir,item_
7ac0: 70 61 74 68 2c 72 75 6e 5f 64 75 72 61 74 69 6f  path,run_duratio
7ad0: 6e 2c 66 69 6e 61 6c 5f 6c 6f 67 66 2c 63 6f 6d  n,final_logf,com
7ae0: 6d 65 6e 74 29 20 22 0a 09 09 20 20 20 20 20 20  ment) "...      
7af0: 22 56 41 4c 55 45 53 20 28 3f 2c 3f 2c 3f 2c 3f  "VALUES (?,?,?,?
7b00: 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f  ,?,?,?,?,?,?,?,?
7b10: 2c 3f 2c 3f 29 3b 22 29 0a 09 09 6e 65 77 2d 72  ,?,?);")...new-r
7b20: 75 6e 2d 69 64 20 28 63 64 64 72 20 28 76 65 63  un-id (cddr (vec
7b30: 74 6f 72 2d 3e 6c 69 73 74 20 74 65 73 74 64 61  tor->list testda
7b40: 74 29 29 29 0a 09 20 28 73 65 74 21 20 6e 65 77  t))).. (set! new
7b50: 2d 74 65 73 74 64 61 74 20 28 63 61 72 20 28 64  -testdat (car (d
7b60: 62 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d  b-get-tests-for-
7b70: 72 75 6e 20 64 62 20 6e 65 77 2d 72 75 6e 2d 69  run db new-run-i
7b80: 64 20 74 65 73 74 6e 61 6d 65 20 69 74 65 6d 2d  d testname item-
7b90: 70 61 74 68 20 27 28 29 20 27 28 29 29 29 29 0a  path '() '()))).
7ba0: 09 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65  . (hash-table-se
7bb0: 74 21 20 63 75 72 72 2d 74 65 73 74 73 2d 68 61  t! curr-tests-ha
7bc0: 73 68 20 66 75 6c 6c 2d 6e 61 6d 65 20 6e 65 77  sh full-name new
7bd0: 2d 74 65 73 74 64 61 74 29 20 3b 3b 20 74 68 69  -testdat) ;; thi
7be0: 73 20 63 6f 75 6c 64 20 62 65 20 63 6f 6e 66 75  s could be confu
7bf0: 73 69 6e 67 2c 20 77 68 69 63 68 20 72 65 63 6f  sing, which reco
7c00: 72 64 20 73 68 6f 75 6c 64 20 67 6f 20 69 6e 74  rd should go int
7c10: 6f 20 74 68 65 20 6c 6f 6f 6b 75 70 20 74 61 62  o the lookup tab
7c20: 6c 65 3f 0a 09 20 3b 3b 20 4e 6f 77 20 64 75 70  le?.. ;; Now dup
7c30: 6c 69 63 61 74 65 20 74 68 65 20 74 65 73 74 20  licate the test 
7c40: 73 74 65 70 73 0a 09 20 28 64 65 62 75 67 3a 70  steps.. (debug:p
7c50: 72 69 6e 74 20 34 20 22 43 6f 70 79 69 6e 67 20  rint 4 "Copying 
7c60: 72 65 63 6f 72 64 73 20 69 6e 20 74 65 73 74 5f  records in test_
7c70: 73 74 65 70 73 20 66 72 6f 6d 20 74 65 73 74 5f  steps from test_
7c80: 69 64 3d 22 20 28 64 62 3a 74 65 73 74 2d 67 65  id=" (db:test-ge
7c90: 74 2d 69 64 20 74 65 73 74 64 61 74 29 20 22 20  t-id testdat) " 
7ca0: 74 6f 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65  to " (db:test-ge
7cb0: 74 2d 69 64 20 6e 65 77 2d 74 65 73 74 64 61 74  t-id new-testdat
7cc0: 29 29 0a 09 20 28 73 71 6c 69 74 65 33 3a 65 78  )).. (sqlite3:ex
7cd0: 65 63 75 74 65 20 0a 09 20 20 64 62 20 0a 09 20  ecute ..  db .. 
7ce0: 20 28 63 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f   (conc "INSERT O
7cf0: 52 20 52 45 50 4c 41 43 45 20 49 4e 54 4f 20 74  R REPLACE INTO t
7d00: 65 73 74 5f 73 74 65 70 73 20 28 74 65 73 74 5f  est_steps (test_
7d10: 69 64 2c 73 74 65 70 6e 61 6d 65 2c 73 74 61 74  id,stepname,stat
7d20: 65 2c 73 74 61 74 75 73 2c 65 76 65 6e 74 5f 74  e,status,event_t
7d30: 69 6d 65 2c 63 6f 6d 6d 65 6e 74 29 20 22 0a 09  ime,comment) "..
7d40: 09 22 53 45 4c 45 43 54 20 22 20 28 64 62 3a 74  ."SELECT " (db:t
7d50: 65 73 74 2d 67 65 74 2d 69 64 20 6e 65 77 2d 74  est-get-id new-t
7d60: 65 73 74 64 61 74 29 20 22 2c 73 74 65 70 6e 61  estdat) ",stepna
7d70: 6d 65 2c 73 74 61 74 65 2c 73 74 61 74 75 73 2c  me,state,status,
7d80: 65 76 65 6e 74 5f 74 69 6d 65 2c 63 6f 6d 6d 65  event_time,comme
7d90: 6e 74 20 46 52 4f 4d 20 74 65 73 74 5f 73 74 65  nt FROM test_ste
7da0: 70 73 20 57 48 45 52 45 20 74 65 73 74 5f 69 64  ps WHERE test_id
7db0: 3d 3f 3b 22 29 0a 09 20 20 28 64 62 3a 74 65 73  =?;")..  (db:tes
7dc0: 74 2d 67 65 74 2d 69 64 20 74 65 73 74 64 61 74  t-get-id testdat
7dd0: 29 29 0a 09 20 3b 3b 20 4e 6f 77 20 64 75 70 6c  )).. ;; Now dupl
7de0: 69 63 61 74 65 20 74 68 65 20 74 65 73 74 20 64  icate the test d
7df0: 61 74 61 0a 09 20 28 64 65 62 75 67 3a 70 72 69  ata.. (debug:pri
7e00: 6e 74 20 34 20 22 43 6f 70 79 69 6e 67 20 72 65  nt 4 "Copying re
7e10: 63 6f 72 64 73 20 69 6e 20 74 65 73 74 5f 64 61  cords in test_da
7e20: 74 61 20 66 72 6f 6d 20 74 65 73 74 5f 69 64 3d  ta from test_id=
7e30: 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69  " (db:test-get-i
7e40: 64 20 74 65 73 74 64 61 74 29 20 22 20 74 6f 20  d testdat) " to 
7e50: 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69  " (db:test-get-i
7e60: 64 20 6e 65 77 2d 74 65 73 74 64 61 74 29 29 0a  d new-testdat)).
7e70: 09 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75  . (sqlite3:execu
7e80: 74 65 20 0a 09 20 20 64 62 20 0a 09 20 20 28 63  te ..  db ..  (c
7e90: 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f 52 20 52  onc "INSERT OR R
7ea0: 45 50 4c 41 43 45 20 49 4e 54 4f 20 74 65 73 74  EPLACE INTO test
7eb0: 5f 64 61 74 61 20 28 74 65 73 74 5f 69 64 2c 63  _data (test_id,c
7ec0: 61 74 65 67 6f 72 79 2c 76 61 72 69 61 62 6c 65  ategory,variable
7ed0: 2c 76 61 6c 75 65 2c 65 78 70 65 63 74 65 64 2c  ,value,expected,
7ee0: 74 6f 6c 2c 75 6e 69 74 73 2c 63 6f 6d 6d 65 6e  tol,units,commen
7ef0: 74 29 20 22 0a 09 09 22 53 45 4c 45 43 54 20 22  t) "..."SELECT "
7f00: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64   (db:test-get-id
7f10: 20 6e 65 77 2d 74 65 73 74 64 61 74 29 20 22 2c   new-testdat) ",
7f20: 63 61 74 65 67 6f 72 79 2c 76 61 72 69 61 62 6c  category,variabl
7f30: 65 2c 76 61 6c 75 65 2c 65 78 70 65 63 74 65 64  e,value,expected
7f40: 2c 74 6f 6c 2c 75 6e 69 74 73 2c 63 6f 6d 6d 65  ,tol,units,comme
7f50: 6e 74 20 46 52 4f 4d 20 74 65 73 74 5f 64 61 74  nt FROM test_dat
7f60: 61 20 57 48 45 52 45 20 74 65 73 74 5f 69 64 3d  a WHERE test_id=
7f70: 3f 3b 22 29 0a 09 20 20 28 64 62 3a 74 65 73 74  ?;")..  (db:test
7f80: 2d 67 65 74 2d 69 64 20 74 65 73 74 64 61 74 29  -get-id testdat)
7f90: 29 0a 09 20 29 29 0a 20 20 20 20 20 70 72 65 76  ).. )).     prev
7fa0: 2d 74 65 73 74 73 29 29 29 0a 09 20 0a 20 20 20  -tests))).. .   
7fb0: 20 20 0a                                           .