Megatest

Hex Artifact Content
Login

Artifact dff7b1b28151d2aca7dda55c99fdcf03b88d8562:


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 61 70 70 65 6e  est-names (appen
2c50: 64 20 74 65 73 74 2d 6e 61 6d 65 73 20 28 6c 69  d test-names (li
2c60: 73 74 20 77 61 69 74 6f 6e 29 29 29 29 29 29 0a  st waiton)))))).
2c70: 09 20 20 20 20 20 77 61 69 74 6f 6e 73 29 0a 09  .     waitons)..
2c80: 20 20 20 20 28 6c 65 74 20 28 28 72 65 6d 74 65      (let ((remte
2c90: 73 74 73 20 28 64 65 6c 65 74 65 2d 64 75 70 6c  sts (delete-dupl
2ca0: 69 63 61 74 65 73 20 28 61 70 70 65 6e 64 20 77  icates (append w
2cb0: 61 69 74 6f 6e 73 20 74 61 6c 29 29 29 29 0a 09  aitons tal))))..
2cc0: 20 20 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28        (if (not (
2cd0: 6e 75 6c 6c 3f 20 72 65 6d 74 65 73 74 73 29 29  null? remtests))
2ce0: 0a 09 09 20 20 28 6c 6f 6f 70 20 28 63 61 72 20  ...  (loop (car 
2cf0: 72 65 6d 74 65 73 74 73 29 28 63 64 72 20 72 65  remtests)(cdr re
2d00: 6d 74 65 73 74 73 29 29 29 29 29 29 29 0a 0a 20  mtests))))))).. 
2d10: 20 20 20 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c     (if (not (nul
2d20: 6c 3f 20 72 65 71 75 69 72 65 64 2d 74 65 73 74  l? required-test
2d30: 73 29 29 0a 09 28 64 65 62 75 67 3a 70 72 69 6e  s))..(debug:prin
2d40: 74 20 31 20 22 49 4e 46 4f 3a 20 41 64 64 69 6e  t 1 "INFO: Addin
2d50: 67 20 22 20 72 65 71 75 69 72 65 64 2d 74 65 73  g " required-tes
2d60: 74 73 20 22 20 74 6f 20 74 68 65 20 72 75 6e 20  ts " to the run 
2d70: 71 75 65 75 65 22 29 29 0a 20 20 20 20 3b 3b 20  queue")).    ;; 
2d80: 4e 4f 54 45 3a 20 74 68 65 73 65 20 61 72 65 20  NOTE: these are 
2d90: 61 6c 6c 20 70 61 72 65 6e 74 20 74 65 73 74 73  all parent tests
2da0: 2c 20 69 74 65 6d 73 20 61 72 65 20 6e 6f 74 20  , items are not 
2db0: 65 78 70 61 6e 64 65 64 20 79 65 74 2e 0a 20 20  expanded yet..  
2dc0: 20 20 28 72 75 6e 73 3a 72 75 6e 2d 74 65 73 74    (runs:run-test
2dd0: 73 2d 71 75 65 75 65 20 64 62 20 72 75 6e 2d 69  s-queue db run-i
2de0: 64 20 72 75 6e 6e 61 6d 65 20 74 65 73 74 2d 72  d runname test-r
2df0: 65 63 6f 72 64 73 20 6b 65 79 76 61 6c 6c 73 74  ecords keyvallst
2e00: 20 66 6c 61 67 73 29 0a 20 20 20 20 28 64 65 62   flags).    (deb
2e10: 75 67 3a 70 72 69 6e 74 20 34 20 22 49 4e 46 4f  ug:print 4 "INFO
2e20: 3a 20 41 6c 6c 20 64 6f 6e 65 20 62 79 20 68 65  : All done by he
2e30: 72 65 22 29 29 29 0a 0a 28 64 65 66 69 6e 65 20  re")))..(define 
2e40: 28 72 75 6e 73 3a 72 75 6e 2d 74 65 73 74 73 2d  (runs:run-tests-
2e50: 71 75 65 75 65 20 64 62 20 72 75 6e 2d 69 64 20  queue db run-id 
2e60: 72 75 6e 6e 61 6d 65 20 74 65 73 74 2d 72 65 63  runname test-rec
2e70: 6f 72 64 73 20 6b 65 79 76 61 6c 6c 73 74 20 66  ords keyvallst f
2e80: 6c 61 67 73 29 0a 20 20 20 20 3b 3b 20 41 74 20  lags).    ;; At 
2e90: 74 68 69 73 20 70 6f 69 6e 74 20 74 68 65 20 6c  this point the l
2ea0: 69 73 74 20 6f 66 20 70 61 72 65 6e 74 20 74 65  ist of parent te
2eb0: 73 74 73 20 69 73 20 65 78 70 61 6e 64 65 64 20  sts is expanded 
2ec0: 0a 20 20 20 20 3b 3b 20 4e 42 2f 2f 20 53 68 6f  .    ;; NB// Sho
2ed0: 75 6c 64 20 65 78 70 61 6e 64 20 69 74 65 6d 73  uld expand items
2ee0: 20 68 65 72 65 20 61 6e 64 20 74 68 65 6e 20 69   here and then i
2ef0: 6e 73 65 72 74 20 69 6e 74 6f 20 74 68 65 20 72  nsert into the r
2f00: 75 6e 20 71 75 65 75 65 2e 0a 20 20 28 64 65 62  un queue..  (deb
2f10: 75 67 3a 70 72 69 6e 74 20 35 20 22 74 65 73 74  ug:print 5 "test
2f20: 2d 72 65 63 6f 72 64 73 3a 20 22 20 74 65 73 74  -records: " test
2f30: 2d 72 65 63 6f 72 64 73 20 22 2c 20 6b 65 79 76  -records ", keyv
2f40: 61 6c 6c 73 74 3a 20 22 20 6b 65 79 76 61 6c 6c  allst: " keyvall
2f50: 73 74 29 0a 20 20 28 6c 65 74 20 28 28 73 6f 72  st).  (let ((sor
2f60: 74 65 64 2d 74 65 73 74 2d 6e 61 6d 65 73 20 28  ted-test-names (
2f70: 74 65 73 74 73 3a 73 6f 72 74 2d 62 79 2d 70 72  tests:sort-by-pr
2f80: 69 6f 72 69 74 79 2d 61 6e 64 2d 77 61 69 74 6f  iority-and-waito
2f90: 6e 20 74 65 73 74 2d 72 65 63 6f 72 64 73 29 29  n test-records))
2fa0: 0a 09 28 69 74 65 6d 2d 70 61 74 74 73 20 20 20  ..(item-patts   
2fb0: 20 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65       (hash-table
2fc0: 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 66 6c 61  -ref/default fla
2fd0: 67 73 20 22 2d 69 74 65 6d 70 61 74 74 22 20 23  gs "-itempatt" #
2fe0: 66 29 29 29 0a 20 20 20 20 28 6c 65 74 20 6c 6f  f))).    (let lo
2ff0: 6f 70 20 28 3b 20 28 6e 75 6d 74 69 6d 65 73 20  op (; (numtimes 
3000: 30 29 20 3b 3b 20 73 68 6f 75 6c 64 6e 27 74 20  0) ;; shouldn't 
3010: 6e 65 65 64 20 74 68 69 73 0a 09 20 20 20 20 20  need this..     
3020: 20 20 28 68 65 64 20 20 20 20 20 20 20 20 20 28    (hed         (
3030: 63 61 72 20 73 6f 72 74 65 64 2d 74 65 73 74 2d  car sorted-test-
3040: 6e 61 6d 65 73 29 29 0a 09 20 20 20 20 20 20 20  names))..       
3050: 28 74 61 6c 20 20 20 20 20 20 20 20 20 28 63 64  (tal         (cd
3060: 72 20 73 6f 72 74 65 64 2d 74 65 73 74 2d 6e 61  r sorted-test-na
3070: 6d 65 73 29 29 29 0a 20 20 20 20 20 20 28 6c 65  mes))).      (le
3080: 74 2a 20 28 28 74 65 73 74 2d 72 65 63 6f 72 64  t* ((test-record
3090: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
30a0: 20 74 65 73 74 2d 72 65 63 6f 72 64 73 20 68 65   test-records he
30b0: 64 29 29 0a 09 20 20 20 20 20 28 74 63 6f 6e 66  d))..     (tconf
30c0: 69 67 20 20 20 20 20 28 74 65 73 74 73 3a 74 65  ig     (tests:te
30d0: 73 74 71 75 65 75 65 2d 67 65 74 2d 74 65 73 74  stqueue-get-test
30e0: 63 6f 6e 66 69 67 20 74 65 73 74 2d 72 65 63 6f  config test-reco
30f0: 72 64 29 29 0a 09 20 20 20 20 20 28 77 61 69 74  rd))..     (wait
3100: 6f 6e 73 20 20 20 20 20 28 74 65 73 74 73 3a 74  ons     (tests:t
3110: 65 73 74 71 75 65 75 65 2d 67 65 74 2d 77 61 69  estqueue-get-wai
3120: 74 6f 6e 73 20 20 20 20 74 65 73 74 2d 72 65 63  tons    test-rec
3130: 6f 72 64 29 29 0a 09 20 20 20 20 20 28 70 72 69  ord))..     (pri
3140: 6f 72 69 74 79 20 20 20 20 28 74 65 73 74 73 3a  ority    (tests:
3150: 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d 70 72  testqueue-get-pr
3160: 69 6f 72 69 74 79 20 20 20 74 65 73 74 2d 72 65  iority   test-re
3170: 63 6f 72 64 29 29 0a 09 20 20 20 20 20 28 69 74  cord))..     (it
3180: 65 6d 64 61 74 20 20 20 20 20 28 74 65 73 74 73  emdat     (tests
3190: 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d 69  :testqueue-get-i
31a0: 74 65 6d 64 61 74 20 20 20 20 74 65 73 74 2d 72  temdat    test-r
31b0: 65 63 6f 72 64 29 29 0a 09 20 20 20 20 20 28 69  ecord))..     (i
31c0: 74 65 6d 73 20 20 20 20 20 20 20 28 74 65 73 74  tems       (test
31d0: 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d  s:testqueue-get-
31e0: 69 74 65 6d 73 20 20 20 20 20 20 74 65 73 74 2d  items      test-
31f0: 72 65 63 6f 72 64 29 29 0a 09 20 20 20 20 20 28  record))..     (
3200: 69 74 65 6d 2d 70 61 74 68 20 20 20 28 69 74 65  item-path   (ite
3210: 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69 74 65  m-list->path ite
3220: 6d 64 61 74 29 29 29 0a 09 28 64 65 62 75 67 3a  mdat)))..(debug:
3230: 70 72 69 6e 74 20 36 0a 09 09 20 20 20 20 20 22  print 6...     "
3240: 69 74 65 6d 64 61 74 3a 20 20 20 20 20 22 20 69  itemdat:     " i
3250: 74 65 6d 64 61 74 0a 09 09 20 20 20 20 20 22 5c  temdat...     "\
3260: 6e 20 20 69 74 65 6d 73 3a 20 20 20 20 20 22 20  n  items:     " 
3270: 69 74 65 6d 73 0a 09 09 20 20 20 20 20 22 5c 6e  items...     "\n
3280: 20 20 69 74 65 6d 2d 70 61 74 68 3a 20 22 20 69    item-path: " i
3290: 74 65 6d 2d 70 61 74 68 29 0a 09 28 63 6f 6e 64  tem-path)..(cond
32a0: 0a 09 20 28 28 6e 6f 74 20 69 74 65 6d 73 29 20  .. ((not items) 
32b0: 3b 3b 20 77 68 65 6e 20 66 61 6c 73 65 20 74 68  ;; when false th
32c0: 65 20 74 65 73 74 20 69 73 20 6f 6b 20 74 6f 20  e test is ok to 
32d0: 62 65 20 68 61 6e 64 65 64 20 6f 66 66 20 74 6f  be handed off to
32e0: 20 6c 61 75 6e 63 68 20 28 62 75 74 20 6e 6f 74   launch (but not
32f0: 20 62 65 66 6f 72 65 29 0a 09 20 20 28 6c 65 74   before)..  (let
3300: 20 28 28 68 61 76 65 2d 72 65 73 6f 75 72 63 65   ((have-resource
3310: 73 20 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e  s  (runs:can-run
3320: 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64 62 20 74  -more-tests db t
3330: 65 73 74 2d 72 65 63 6f 72 64 29 29 20 3b 3b 20  est-record)) ;; 
3340: 6c 6f 6f 6b 20 61 74 20 74 68 65 20 74 65 73 74  look at the test
3350: 20 6a 6f 62 67 72 6f 75 70 20 61 6e 64 20 74 6f   jobgroup and to
3360: 74 20 6a 6f 62 73 20 72 75 6e 6e 69 6e 67 0a 09  t jobs running..
3370: 09 28 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65  .(prereqs-not-me
3380: 74 20 28 64 62 3a 67 65 74 2d 70 72 65 72 65 71  t (db:get-prereq
3390: 73 2d 6e 6f 74 2d 6d 65 74 20 64 62 20 72 75 6e  s-not-met db run
33a0: 2d 69 64 20 77 61 69 74 6f 6e 73 20 69 74 65 6d  -id waitons item
33b0: 2d 70 61 74 68 29 29 29 0a 09 20 20 20 20 3b 3b  -path)))..    ;;
33c0: 20 44 6f 6e 27 74 20 6b 6e 6f 77 20 61 74 20 74   Don't know at t
33d0: 68 69 73 20 74 69 6d 65 20 69 66 20 74 68 65 20  his time if the 
33e0: 74 65 73 74 20 68 61 76 65 20 62 65 65 6e 20 6c  test have been l
33f0: 61 75 6e 63 68 65 64 20 61 74 20 73 6f 6d 65 20  aunched at some 
3400: 74 69 6d 65 20 69 6e 20 74 68 65 20 70 61 73 74  time in the past
3410: 0a 09 20 20 20 20 3b 3b 20 69 2e 65 2e 20 69 73  ..    ;; i.e. is
3420: 20 74 68 69 73 20 61 20 72 65 2d 6c 61 75 6e 63   this a re-launc
3430: 68 3f 0a 09 20 20 20 20 28 69 66 20 28 61 6e 64  h?..    (if (and
3440: 20 68 61 76 65 2d 72 65 73 6f 75 72 63 65 73 0a   have-resources.
3450: 09 09 20 20 20 20 20 28 6e 75 6c 6c 3f 20 70 72  ..     (null? pr
3460: 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 29 29 0a  ereqs-not-met)).
3470: 09 09 3b 3b 20 6e 6f 20 6c 6f 6f 70 20 2d 20 64  ..;; no loop - d
3480: 72 6f 70 20 74 68 6f 75 67 68 20 61 6e 64 20 75  rop though and u
3490: 73 65 20 74 68 65 20 6c 6f 6f 70 20 61 74 20 74  se the loop at t
34a0: 68 65 20 62 6f 74 74 6f 6d 20 0a 09 09 28 72 75  he bottom ...(ru
34b0: 6e 3a 74 65 73 74 20 64 62 20 72 75 6e 2d 69 64  n:test db run-id
34c0: 20 72 75 6e 6e 61 6d 65 20 6b 65 79 76 61 6c 6c   runname keyvall
34d0: 73 74 20 74 65 73 74 2d 72 65 63 6f 72 64 20 66  st test-record f
34e0: 6c 61 67 73 20 23 66 29 0a 09 09 3b 3b 20 65 6c  lags #f)...;; el
34f0: 73 65 20 74 68 65 20 72 75 6e 20 69 73 20 73 74  se the run is st
3500: 75 63 6b 2c 20 74 65 6d 70 6f 72 61 72 69 6c 79  uck, temporarily
3510: 20 6f 72 20 70 65 72 6d 61 6e 65 6e 74 6c 79 0a   or permanently.
3520: 09 09 28 6c 65 74 20 28 28 6e 65 77 74 61 6c 20  ..(let ((newtal 
3530: 28 61 70 70 65 6e 64 20 74 61 6c 20 28 6c 69 73  (append tal (lis
3540: 74 20 68 65 64 29 29 29 29 0a 09 09 20 20 3b 3b  t hed))))...  ;;
3550: 20 63 6f 75 6c 64 6e 27 74 20 72 75 6e 2c 20 74   couldn't run, t
3560: 61 6b 65 20 61 20 62 72 65 61 74 68 65 72 0a 09  ake a breather..
3570: 09 20 20 28 74 68 72 65 61 64 2d 73 6c 65 65 70  .  (thread-sleep
3580: 21 20 31 29 0a 09 09 20 20 28 6c 6f 6f 70 20 28  ! 1)...  (loop (
3590: 63 61 72 20 6e 65 77 74 61 6c 29 28 63 64 72 20  car newtal)(cdr 
35a0: 6e 65 77 74 61 6c 29 29 29 29 29 29 0a 09 20 0a  newtal)))))).. .
35b0: 09 20 3b 3b 20 63 61 73 65 20 77 68 65 72 65 20  . ;; case where 
35c0: 61 6e 20 69 74 65 6d 73 20 63 61 6d 65 20 69 6e  an items came in
35d0: 20 61 73 20 61 20 6c 69 73 74 20 62 65 65 6e 20   as a list been 
35e0: 70 72 6f 63 65 73 73 65 64 0a 09 20 28 28 61 6e  processed.. ((an
35f0: 64 20 28 6c 69 73 74 3f 20 69 74 65 6d 73 29 20  d (list? items) 
3600: 20 20 20 20 3b 3b 20 74 68 75 73 20 77 65 20 6b      ;; thus we k
3610: 6e 6f 77 20 6f 75 72 20 69 74 65 6d 73 20 61 72  now our items ar
3620: 65 20 61 6c 72 65 61 64 79 20 63 61 6c 63 75 6c  e already calcul
3630: 61 74 65 64 0a 09 20 20 20 20 20 20 20 28 6e 6f  ated..       (no
3640: 74 20 20 20 69 74 65 6d 64 61 74 29 29 20 3b 3b  t   itemdat)) ;;
3650: 20 61 6e 64 20 6e 6f 74 20 79 65 74 20 65 78 70   and not yet exp
3660: 61 6e 64 65 64 20 69 6e 74 6f 20 74 68 65 20 6c  anded into the l
3670: 69 73 74 20 6f 66 20 74 68 69 6e 67 73 20 74 6f  ist of things to
3680: 20 62 65 20 64 6f 6e 65 0a 09 20 20 28 69 66 20   be done..  (if 
3690: 28 3e 3d 20 2a 76 65 72 62 6f 73 69 74 79 2a 20  (>= *verbosity* 
36a0: 31 29 28 70 70 20 69 74 65 6d 73 29 29 0a 09 20  1)(pp items)).. 
36b0: 20 3b 3b 20 28 69 66 20 28 3e 3d 20 2a 76 65 72   ;; (if (>= *ver
36c0: 62 6f 73 69 74 79 2a 20 35 29 0a 09 20 20 3b 3b  bosity* 5)..  ;;
36d0: 20 20 20 20 20 28 62 65 67 69 6e 0a 09 20 20 3b       (begin..  ;
36e0: 3b 20 20 20 20 20 20 20 28 70 72 69 6e 74 20 22  ;       (print "
36f0: 69 74 65 6d 73 3a 20 22 29 20 20 20 20 20 28 70  items: ")     (p
3700: 70 20 28 69 74 65 6d 2d 61 73 73 6f 63 2d 3e 69  p (item-assoc->i
3710: 74 65 6d 2d 6c 69 73 74 20 69 74 65 6d 73 29 29  tem-list items))
3720: 0a 09 20 20 3b 3b 20 20 20 20 20 20 20 28 70 72  ..  ;;       (pr
3730: 69 6e 74 20 22 69 74 65 6d 73 74 61 62 6c 65 3a  int "itemstable:
3740: 20 22 29 28 70 70 20 28 69 74 65 6d 2d 74 61 62   ")(pp (item-tab
3750: 6c 65 2d 3e 69 74 65 6d 2d 6c 69 73 74 20 69 74  le->item-list it
3760: 65 6d 73 74 61 62 6c 65 29 29 29 29 0a 09 20 20  emstable))))..  
3770: 28 66 6f 72 2d 65 61 63 68 0a 09 20 20 20 28 6c  (for-each..   (l
3780: 61 6d 62 64 61 20 28 6d 79 2d 69 74 65 6d 64 61  ambda (my-itemda
3790: 74 29 0a 09 20 20 20 20 20 28 6c 65 74 2a 20 28  t)..     (let* (
37a0: 28 6e 65 77 2d 74 65 73 74 2d 72 65 63 6f 72 64  (new-test-record
37b0: 20 28 6c 65 74 20 28 28 6e 65 77 72 65 63 20 28   (let ((newrec (
37c0: 6d 61 6b 65 2d 74 65 73 74 73 3a 74 65 73 74 71  make-tests:testq
37d0: 75 65 75 65 29 29 29 0a 09 09 09 09 20 20 20 20  ueue))).....    
37e0: 20 20 20 28 76 65 63 74 6f 72 2d 63 6f 70 79 21     (vector-copy!
37f0: 20 74 65 73 74 2d 72 65 63 6f 72 64 20 6e 65 77   test-record new
3800: 72 65 63 29 0a 09 09 09 09 20 20 20 20 20 20 20  rec).....       
3810: 6e 65 77 72 65 63 29 29 0a 09 09 20 20 20 20 28  newrec))...    (
3820: 6d 79 2d 69 74 65 6d 2d 70 61 74 68 20 28 69 74  my-item-path (it
3830: 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 6d 79  em-list->path my
3840: 2d 69 74 65 6d 64 61 74 29 29 0a 09 09 20 20 20  -itemdat))...   
3850: 20 28 69 74 65 6d 2d 6d 61 74 63 68 65 73 20 28   (item-matches (
3860: 69 66 20 69 74 65 6d 2d 70 61 74 74 73 20 20 20  if item-patts   
3870: 20 20 20 20 3b 3b 20 68 65 72 65 20 77 65 20 61      ;; here we a
3880: 72 65 20 66 69 6c 74 65 72 69 6e 67 20 66 6f 72  re filtering for
3890: 20 6d 61 74 63 68 65 73 20 77 69 74 68 20 2d 69   matches with -i
38a0: 74 65 6d 70 61 74 74 0a 09 09 09 09 20 20 20 20  tempatt.....    
38b0: 20 20 28 6c 65 74 20 28 28 72 65 73 20 23 66 29    (let ((res #f)
38c0: 29 09 20 3b 3b 20 6c 6f 6f 6b 20 74 68 72 6f 75  ). ;; look throu
38d0: 67 68 20 61 6c 6c 20 74 68 65 20 69 74 65 6d 2d  gh all the item-
38e0: 70 61 74 74 73 20 69 66 20 64 65 66 69 6e 65 64  patts if defined
38f0: 2c 20 66 6f 72 6d 61 74 20 69 73 20 70 61 74 74  , format is patt
3900: 31 2c 70 61 74 74 32 2c 70 61 74 74 33 20 2e 2e  1,patt2,patt3 ..
3910: 2e 20 77 69 6c 64 63 61 72 64 20 69 73 20 25 0a  . wildcard is %.
3920: 09 09 09 09 09 28 66 6f 72 2d 65 61 63 68 20 0a  .....(for-each .
3930: 09 09 09 09 09 20 28 6c 61 6d 62 64 61 20 28 70  ..... (lambda (p
3940: 61 74 74 29 0a 09 09 09 09 09 20 20 20 28 69 66  att)......   (if
3950: 20 28 73 74 72 69 6e 67 2d 73 65 61 72 63 68 20   (string-search 
3960: 28 67 6c 6f 62 2d 3e 72 65 67 65 78 70 0a 09 09  (glob->regexp...
3970: 09 09 09 09 09 20 20 20 20 20 20 20 28 73 74 72  .....       (str
3980: 69 6e 67 2d 74 72 61 6e 73 6c 61 74 65 20 70 61  ing-translate pa
3990: 74 74 20 22 25 22 20 22 2a 22 29 29 0a 09 09 09  tt "%" "*"))....
39a0: 09 09 09 09 20 20 20 20 20 20 69 74 65 6d 2d 70  ....      item-p
39b0: 61 74 68 29 0a 09 09 09 09 09 20 20 20 20 20 20  ath)......      
39c0: 20 28 73 65 74 21 20 72 65 73 20 23 74 29 29 29   (set! res #t)))
39d0: 0a 09 09 09 09 09 20 28 73 74 72 69 6e 67 2d 73  ...... (string-s
39e0: 70 6c 69 74 20 69 74 65 6d 2d 70 61 74 74 73 20  plit item-patts 
39f0: 22 2c 22 29 29 0a 09 09 09 09 09 72 65 73 29 0a  ","))......res).
3a00: 09 09 09 09 20 20 20 20 20 20 23 74 29 29 29 0a  ....      #t))).
3a10: 09 20 20 20 20 20 20 20 28 69 66 20 69 74 65 6d  .       (if item
3a20: 2d 6d 61 74 63 68 65 73 20 3b 3b 20 79 65 73 2c  -matches ;; yes,
3a30: 20 77 65 20 77 61 6e 74 20 74 6f 20 70 72 6f 63   we want to proc
3a40: 65 73 73 20 74 68 69 73 20 69 74 65 6d 0a 09 09  ess this item...
3a50: 20 20 20 28 6c 65 74 20 28 28 6e 65 77 74 65 73     (let ((newtes
3a60: 74 6e 61 6d 65 20 28 63 6f 6e 63 20 68 65 64 20  tname (conc hed 
3a70: 22 2f 22 20 6d 79 2d 69 74 65 6d 2d 70 61 74 68  "/" my-item-path
3a80: 29 29 29 20 0a 09 09 20 20 20 20 20 28 74 65 73  ))) ...     (tes
3a90: 74 73 3a 74 65 73 74 71 75 65 75 65 2d 73 65 74  ts:testqueue-set
3aa0: 2d 69 74 65 6d 73 21 20 20 20 6e 65 77 2d 74 65  -items!   new-te
3ab0: 73 74 2d 72 65 63 6f 72 64 20 23 66 29 0a 09 09  st-record #f)...
3ac0: 20 20 20 20 20 28 74 65 73 74 73 3a 74 65 73 74       (tests:test
3ad0: 71 75 65 75 65 2d 73 65 74 2d 69 74 65 6d 64 61  queue-set-itemda
3ae0: 74 21 20 6e 65 77 2d 74 65 73 74 2d 72 65 63 6f  t! new-test-reco
3af0: 72 64 20 6d 79 2d 69 74 65 6d 64 61 74 29 0a 09  rd my-itemdat)..
3b00: 09 20 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c  .     (hash-tabl
3b10: 65 2d 73 65 74 21 20 74 65 73 74 2d 72 65 63 6f  e-set! test-reco
3b20: 72 64 73 20 6e 65 77 74 65 73 74 6e 61 6d 65 20  rds newtestname 
3b30: 6e 65 77 2d 74 65 73 74 2d 72 65 63 6f 72 64 29  new-test-record)
3b40: 0a 09 09 20 20 20 20 20 28 73 65 74 21 20 74 61  ...     (set! ta
3b50: 6c 20 28 63 6f 6e 73 20 6e 65 77 74 65 73 74 6e  l (cons newtestn
3b60: 61 6d 65 20 74 61 6c 29 29 29 29 29 29 20 3b 3b  ame tal)))))) ;;
3b70: 20 73 69 6e 63 65 20 74 68 65 73 65 20 61 72 65   since these are
3b80: 20 69 74 65 6d 69 7a 65 64 20 63 72 65 61 74 65   itemized create
3b90: 20 6e 65 77 20 74 65 73 74 20 6e 61 6d 65 73 20   new test names 
3ba0: 74 65 73 74 6e 61 6d 65 2f 69 74 65 6d 70 61 74  testname/itempat
3bb0: 68 0a 09 20 20 20 69 74 65 6d 73 29 0a 09 20 20  h..   items)..  
3bc0: 28 6c 6f 6f 70 20 28 63 61 72 20 74 61 6c 29 28  (loop (car tal)(
3bd0: 63 64 72 20 74 61 6c 29 29 29 0a 0a 09 20 3b 3b  cdr tal)))... ;;
3be0: 20 69 66 20 69 74 65 6d 73 20 69 73 20 61 20 70   if items is a p
3bf0: 72 6f 63 20 74 68 65 6e 20 6e 65 65 64 20 74 6f  roc then need to
3c00: 20 72 75 6e 20 69 74 65 6d 73 3a 67 65 74 2d 69   run items:get-i
3c10: 74 65 6d 73 2d 66 72 6f 6d 2d 63 6f 6e 66 69 67  tems-from-config
3c20: 2c 20 67 65 74 20 74 68 65 20 6c 69 73 74 20 61  , get the list a
3c30: 6e 64 20 6c 6f 6f 70 20 0a 09 20 3b 3b 20 20 20  nd loop .. ;;   
3c40: 20 2d 20 62 75 74 20 6f 6e 6c 79 20 64 6f 20 74   - but only do t
3c50: 68 61 74 20 69 66 20 72 65 73 6f 75 72 63 65 73  hat if resources
3c60: 20 65 78 69 73 74 20 74 6f 20 6b 69 63 6b 20 6f   exist to kick o
3c70: 66 66 20 74 68 65 20 6a 6f 62 0a 09 20 28 28 6f  ff the job.. ((o
3c80: 72 20 28 70 72 6f 63 65 64 75 72 65 3f 20 69 74  r (procedure? it
3c90: 65 6d 73 29 28 65 71 3f 20 69 74 65 6d 73 20 27  ems)(eq? items '
3ca0: 68 61 76 65 2d 70 72 6f 63 65 64 75 72 65 29 29  have-procedure))
3cb0: 0a 09 20 20 28 69 66 20 28 72 75 6e 73 3a 63 61  ..  (if (runs:ca
3cc0: 6e 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73  n-run-more-tests
3cd0: 20 64 62 20 74 65 73 74 2d 72 65 63 6f 72 64 29   db test-record)
3ce0: 0a 09 20 20 20 20 20 20 28 6c 65 74 20 28 28 69  ..      (let ((i
3cf0: 74 65 6d 73 2d 6c 69 73 74 20 28 69 74 65 6d 73  tems-list (items
3d00: 3a 67 65 74 2d 69 74 65 6d 73 2d 66 72 6f 6d 2d  :get-items-from-
3d10: 63 6f 6e 66 69 67 20 74 63 6f 6e 66 69 67 29 29  config tconfig))
3d20: 29 0a 09 09 28 69 66 20 28 6c 69 73 74 3f 20 69  )...(if (list? i
3d30: 74 65 6d 73 2d 6c 69 73 74 29 0a 09 09 20 20 20  tems-list)...   
3d40: 20 28 62 65 67 69 6e 0a 09 09 20 20 20 20 20 20   (begin...      
3d50: 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65  (tests:testqueue
3d60: 2d 73 65 74 2d 69 74 65 6d 73 21 20 74 65 73 74  -set-items! test
3d70: 2d 72 65 63 6f 72 64 20 69 74 65 6d 73 2d 6c 69  -record items-li
3d80: 73 74 29 0a 09 09 20 20 20 20 20 20 28 6c 6f 6f  st)...      (loo
3d90: 70 20 68 65 64 20 74 61 6c 29 29 0a 09 09 20 20  p hed tal))...  
3da0: 20 20 28 62 65 67 69 6e 0a 09 09 20 20 20 20 20    (begin...     
3db0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
3dc0: 22 45 52 52 4f 52 3a 20 54 68 65 20 70 72 6f 63  "ERROR: The proc
3dd0: 20 66 72 6f 6d 20 72 65 61 64 69 6e 67 20 74 68   from reading th
3de0: 65 20 73 65 74 75 70 20 64 69 64 20 6e 6f 74 20  e setup did not 
3df0: 79 69 65 6c 64 20 61 20 6c 69 73 74 20 2d 20 70  yield a list - p
3e00: 6c 65 61 73 65 20 72 65 70 6f 72 74 20 74 68 69  lease report thi
3e10: 73 22 29 0a 09 09 20 20 20 20 20 20 28 65 78 69  s")...      (exi
3e20: 74 20 31 29 29 29 29 0a 09 20 20 20 20 20 20 28  t 1))))..      (
3e30: 6c 65 74 20 28 28 6e 65 77 74 61 6c 20 28 61 70  let ((newtal (ap
3e40: 70 65 6e 64 20 74 61 6c 20 28 6c 69 73 74 20 68  pend tal (list h
3e50: 65 64 29 29 29 29 0a 09 09 3b 3b 20 69 66 20 63  ed))))...;; if c
3e60: 61 6e 27 74 20 72 75 6e 20 6d 6f 72 65 20 74 65  an't run more te
3e70: 73 74 73 2c 20 6c 65 74 73 20 74 61 6b 65 20 61  sts, lets take a
3e80: 20 62 72 65 61 74 68 65 72 0a 09 09 28 74 68 72   breather...(thr
3e90: 65 61 64 2d 73 6c 65 65 70 21 20 31 29 0a 09 09  ead-sleep! 1)...
3ea0: 28 6c 6f 6f 70 20 28 63 61 72 20 6e 65 77 74 61  (loop (car newta
3eb0: 6c 29 28 63 64 72 20 6e 65 77 74 61 6c 29 29 29  l)(cdr newtal)))
3ec0: 29 29 0a 0a 09 20 3b 3b 20 74 68 69 73 20 63 61  ))... ;; this ca
3ed0: 73 65 20 73 68 6f 75 6c 64 20 6e 6f 74 20 68 61  se should not ha
3ee0: 70 70 65 6e 2c 20 61 64 64 65 64 20 74 6f 20 68  ppen, added to h
3ef0: 65 6c 70 20 63 61 74 63 68 20 61 6e 79 20 62 75  elp catch any bu
3f00: 67 73 0a 09 20 28 28 61 6e 64 20 28 6c 69 73 74  gs.. ((and (list
3f10: 3f 20 69 74 65 6d 73 29 20 69 74 65 6d 64 61 74  ? items) itemdat
3f20: 29 0a 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e  )..  (debug:prin
3f30: 74 20 30 20 22 45 52 52 4f 52 3a 20 53 68 6f 75  t 0 "ERROR: Shou
3f40: 6c 64 20 6e 6f 74 20 68 61 76 65 20 61 20 6c 69  ld not have a li
3f50: 73 74 20 6f 66 20 69 74 65 6d 73 20 69 6e 20 61  st of items in a
3f60: 20 74 65 73 74 20 61 6e 64 20 74 68 65 20 69 74   test and the it
3f70: 65 6d 73 70 61 74 68 20 73 65 74 20 2d 20 70 6c  emspath set - pl
3f80: 65 61 73 65 20 72 65 70 6f 72 74 20 74 68 69 73  ease report this
3f90: 22 29 0a 09 20 20 28 65 78 69 74 20 31 29 29 29  ")..  (exit 1)))
3fa0: 29 0a 09 0a 20 20 20 20 20 20 3b 3b 20 77 65 20  )...      ;; we 
3fb0: 67 65 74 20 68 65 72 65 20 6f 6e 20 22 64 72 6f  get here on "dro
3fc0: 70 20 74 68 72 6f 75 67 68 22 20 2d 20 6c 6f 6f  p through" - loo
3fd0: 70 20 66 6f 72 20 6e 65 78 74 20 74 65 73 74 20  p for next test 
3fe0: 69 6e 20 71 75 65 75 65 0a 20 20 20 20 20 20 28  in queue.      (
3ff0: 69 66 20 28 6e 75 6c 6c 3f 20 74 61 6c 29 0a 09  if (null? tal)..
4000: 20 20 28 62 65 67 69 6e 0a 09 20 20 20 20 3b 3b    (begin..    ;;
4010: 20 46 49 58 4d 45 21 21 21 21 20 54 48 49 53 20   FIXME!!!! THIS 
4020: 53 48 4f 55 4c 44 20 4e 4f 54 20 52 45 51 55 49  SHOULD NOT REQUI
4030: 52 45 20 41 4e 20 45 58 49 54 21 21 21 21 21 21  RE AN EXIT!!!!!!
4040: 21 0a 09 20 20 20 20 28 64 65 62 75 67 3a 70 72  !..    (debug:pr
4050: 69 6e 74 20 31 20 22 49 4e 46 4f 3a 20 41 6c 6c  int 1 "INFO: All
4060: 20 74 65 73 74 73 20 6c 61 75 6e 63 68 65 64 2c   tests launched,
4070: 20 65 78 69 74 69 6e 67 22 29 0a 09 20 20 20 20   exiting")..    
4080: 28 65 78 69 74 20 30 29 29 0a 09 20 20 28 6c 6f  (exit 0))..  (lo
4090: 6f 70 20 28 63 61 72 20 74 61 6c 29 28 63 64 72  op (car tal)(cdr
40a0: 20 74 61 6c 29 29 29 29 29 29 0a 0a 3b 3b 20 70   tal))))))..;; p
40b0: 61 72 65 6e 74 2d 74 65 73 74 20 69 73 20 74 68  arent-test is th
40c0: 65 72 65 20 61 73 20 61 20 70 6c 61 63 65 68 6f  ere as a placeho
40d0: 6c 64 65 72 20 66 6f 72 20 77 68 65 6e 20 70 61  lder for when pa
40e0: 72 65 6e 74 2d 74 65 73 74 73 20 63 61 6e 20 62  rent-tests can b
40f0: 65 20 72 75 6e 20 61 73 20 61 20 73 65 74 75 70  e run as a setup
4100: 20 73 74 65 70 0a 28 64 65 66 69 6e 65 20 28 72   step.(define (r
4110: 75 6e 3a 74 65 73 74 20 64 62 20 72 75 6e 2d 69  un:test db run-i
4120: 64 20 72 75 6e 6e 61 6d 65 20 6b 65 79 76 61 6c  d runname keyval
4130: 6c 73 74 20 74 65 73 74 2d 72 65 63 6f 72 64 20  lst test-record 
4140: 66 6c 61 67 73 20 70 61 72 65 6e 74 2d 74 65 73  flags parent-tes
4150: 74 29 0a 20 20 3b 3b 20 41 6c 6c 20 74 68 65 73  t).  ;; All thes
4160: 65 20 76 61 72 73 20 6d 69 67 68 74 20 62 65 20  e vars might be 
4170: 72 65 66 65 72 65 6e 63 65 64 20 62 79 20 74 68  referenced by th
4180: 65 20 74 65 73 74 63 6f 6e 66 69 67 20 66 69 6c  e testconfig fil
4190: 65 20 72 65 61 64 65 72 0a 20 20 28 6c 65 74 2a  e reader.  (let*
41a0: 20 28 28 74 65 73 74 2d 6e 61 6d 65 20 20 20 20   ((test-name    
41b0: 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65  (tests:testqueue
41c0: 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 20 20  -get-testname   
41d0: 74 65 73 74 2d 72 65 63 6f 72 64 29 29 0a 09 20  test-record)).. 
41e0: 28 74 65 73 74 2d 77 61 69 74 6f 6e 73 20 28 74  (test-waitons (t
41f0: 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67  ests:testqueue-g
4200: 65 74 2d 77 61 69 74 6f 6e 73 20 20 20 20 74 65  et-waitons    te
4210: 73 74 2d 72 65 63 6f 72 64 29 29 0a 09 20 28 74  st-record)).. (t
4220: 65 73 74 2d 63 6f 6e 66 20 20 20 20 28 74 65 73  est-conf    (tes
4230: 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74  ts:testqueue-get
4240: 2d 74 65 73 74 63 6f 6e 66 69 67 20 74 65 73 74  -testconfig test
4250: 2d 72 65 63 6f 72 64 29 29 0a 09 20 28 69 74 65  -record)).. (ite
4260: 6d 64 61 74 20 20 20 20 20 20 28 74 65 73 74 73  mdat      (tests
4270: 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d 69  :testqueue-get-i
4280: 74 65 6d 64 61 74 20 20 20 20 74 65 73 74 2d 72  temdat    test-r
4290: 65 63 6f 72 64 29 29 0a 09 20 28 74 65 73 74 2d  ecord)).. (test-
42a0: 70 61 74 68 20 20 20 20 28 63 6f 6e 63 20 2a 74  path    (conc *t
42b0: 6f 70 70 61 74 68 2a 20 22 2f 74 65 73 74 73 2f  oppath* "/tests/
42c0: 22 20 74 65 73 74 2d 6e 61 6d 65 29 29 20 3b 3b  " test-name)) ;;
42d0: 20 63 6f 75 6c 64 20 75 73 65 20 74 65 73 74 3a   could use test:
42e0: 67 65 74 2d 74 65 73 74 63 6f 6e 66 69 67 20 68  get-testconfig h
42f0: 65 72 65 20 2e 2e 2e 0a 09 20 28 66 6f 72 63 65  ere ..... (force
4300: 20 20 20 20 20 20 20 20 28 68 61 73 68 2d 74 61          (hash-ta
4310: 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20  ble-ref/default 
4320: 66 6c 61 67 73 20 22 2d 66 6f 72 63 65 22 20 23  flags "-force" #
4330: 66 29 29 0a 09 20 28 72 65 72 75 6e 20 20 20 20  f)).. (rerun    
4340: 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d      (hash-table-
4350: 72 65 66 2f 64 65 66 61 75 6c 74 20 66 6c 61 67  ref/default flag
4360: 73 20 22 2d 72 65 72 75 6e 22 20 23 66 29 29 0a  s "-rerun" #f)).
4370: 09 20 28 6b 65 65 70 67 6f 69 6e 67 20 20 20 20  . (keepgoing    
4380: 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f  (hash-table-ref/
4390: 64 65 66 61 75 6c 74 20 66 6c 61 67 73 20 22 2d  default flags "-
43a0: 6b 65 65 70 67 6f 69 6e 67 22 20 23 66 29 29 0a  keepgoing" #f)).
43b0: 09 20 28 69 74 65 6d 2d 70 61 74 68 20 20 20 20  . (item-path    
43c0: 20 22 22 29 29 0a 20 20 20 20 28 64 65 62 75 67   "")).    (debug
43d0: 3a 70 72 69 6e 74 20 35 0a 09 09 20 22 74 65 73  :print 5... "tes
43e0: 74 2d 63 6f 6e 66 69 67 3a 20 22 20 28 68 61 73  t-config: " (has
43f0: 68 2d 74 61 62 6c 65 2d 3e 61 6c 69 73 74 20 74  h-table->alist t
4400: 65 73 74 2d 63 6f 6e 66 29 0a 09 09 20 22 5c 6e  est-conf)... "\n
4410: 20 20 20 69 74 65 6d 64 61 74 3a 20 22 20 69 74     itemdat: " it
4420: 65 6d 64 61 74 0a 09 09 20 29 0a 20 20 20 20 3b  emdat... ).    ;
4430: 3b 20 73 65 74 74 69 6e 67 20 69 74 65 6d 64 61  ; setting itemda
4440: 74 20 74 6f 20 61 20 6c 69 73 74 20 69 66 20 69  t to a list if i
4450: 74 20 69 73 20 23 66 0a 20 20 20 20 28 69 66 20  t is #f.    (if 
4460: 28 6e 6f 74 20 69 74 65 6d 64 61 74 29 28 73 65  (not itemdat)(se
4470: 74 21 20 69 74 65 6d 64 61 74 20 27 28 29 29 29  t! itemdat '()))
4480: 0a 20 20 20 20 28 73 65 74 21 20 69 74 65 6d 2d  .    (set! item-
4490: 70 61 74 68 20 28 69 74 65 6d 2d 6c 69 73 74 2d  path (item-list-
44a0: 3e 70 61 74 68 20 69 74 65 6d 64 61 74 29 29 0a  >path itemdat)).
44b0: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
44c0: 20 32 20 22 41 74 74 65 6d 70 74 69 6e 67 20 74   2 "Attempting t
44d0: 6f 20 6c 61 75 6e 63 68 20 74 65 73 74 20 22 20  o launch test " 
44e0: 74 65 73 74 2d 6e 61 6d 65 20 22 2f 22 20 69 74  test-name "/" it
44f0: 65 6d 2d 70 61 74 68 29 0a 20 20 20 20 28 73 65  em-path).    (se
4500: 74 65 6e 76 20 22 4d 54 5f 54 45 53 54 5f 4e 41  tenv "MT_TEST_NA
4510: 4d 45 22 20 74 65 73 74 2d 6e 61 6d 65 29 20 3b  ME" test-name) ;
4520: 3b 20 0a 20 20 20 20 28 73 65 74 65 6e 76 20 22  ; .    (setenv "
4530: 4d 54 5f 52 55 4e 4e 41 4d 45 22 20 20 20 72 75  MT_RUNNAME"   ru
4540: 6e 6e 61 6d 65 29 0a 20 20 20 20 28 73 65 74 2d  nname).    (set-
4550: 6d 65 67 61 74 65 73 74 2d 65 6e 76 2d 76 61 72  megatest-env-var
4560: 73 20 64 62 20 72 75 6e 2d 69 64 29 20 3b 3b 20  s db run-id) ;; 
4570: 74 68 65 73 65 20 6d 61 79 20 62 65 20 6e 65 65  these may be nee
4580: 64 65 64 20 62 79 20 74 68 65 20 6c 61 75 6e 63  ded by the launc
4590: 68 69 6e 67 20 70 72 6f 63 65 73 73 0a 20 20 20  hing process.   
45a0: 20 28 63 68 61 6e 67 65 2d 64 69 72 65 63 74 6f   (change-directo
45b0: 72 79 20 2a 74 6f 70 70 61 74 68 2a 29 0a 0a 20  ry *toppath*).. 
45c0: 20 20 20 3b 3b 20 48 65 72 65 20 69 73 20 77 68     ;; Here is wh
45d0: 65 72 65 20 74 68 65 20 74 65 73 74 5f 6d 65 74  ere the test_met
45e0: 61 20 74 61 62 6c 65 20 69 73 20 62 65 73 74 20  a table is best 
45f0: 75 70 64 61 74 65 64 0a 20 20 20 20 28 72 75 6e  updated.    (run
4600: 73 3a 75 70 64 61 74 65 2d 74 65 73 74 5f 6d 65  s:update-test_me
4610: 74 61 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 20  ta db test-name 
4620: 74 65 73 74 2d 63 6f 6e 66 29 0a 20 20 20 20 0a  test-conf).    .
4630: 20 20 20 20 3b 3b 20 28 6c 61 6d 62 64 61 20 28      ;; (lambda (
4640: 69 74 65 6d 64 61 74 29 20 3b 3b 3b 20 28 28 72  itemdat) ;;; ((r
4650: 69 70 65 6e 65 73 73 20 22 6f 76 65 72 72 69 70  ipeness "overrip
4660: 65 22 29 20 28 74 65 6d 70 65 72 61 74 75 72 65  e") (temperature
4670: 20 22 63 6f 6f 6c 22 29 20 28 73 65 61 73 6f 6e   "cool") (season
4680: 20 22 73 75 6d 6d 65 72 22 29 29 0a 20 20 20 20   "summer")).    
4690: 28 6c 65 74 2a 20 28 28 6e 65 77 2d 74 65 73 74  (let* ((new-test
46a0: 2d 70 61 74 68 20 28 73 74 72 69 6e 67 2d 69 6e  -path (string-in
46b0: 74 65 72 73 70 65 72 73 65 20 28 63 6f 6e 73 20  tersperse (cons 
46c0: 74 65 73 74 2d 70 61 74 68 20 28 6d 61 70 20 63  test-path (map c
46d0: 61 64 72 20 69 74 65 6d 64 61 74 29 29 20 22 2f  adr itemdat)) "/
46e0: 22 29 29 0a 09 20 20 20 28 6e 65 77 2d 74 65 73  "))..   (new-tes
46f0: 74 2d 6e 61 6d 65 20 28 69 66 20 28 65 71 75 61  t-name (if (equa
4700: 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29  l? item-path "")
4710: 20 74 65 73 74 2d 6e 61 6d 65 20 28 63 6f 6e 63   test-name (conc
4720: 20 74 65 73 74 2d 6e 61 6d 65 20 22 2f 22 20 69   test-name "/" i
4730: 74 65 6d 2d 70 61 74 68 29 29 29 20 3b 3b 20 6a  tem-path))) ;; j
4740: 75 73 74 20 6e 65 65 64 20 69 74 20 74 6f 20 62  ust need it to b
4750: 65 20 75 6e 69 71 75 65 0a 09 20 20 20 28 74 65  e unique..   (te
4760: 73 74 64 61 74 20 20 20 20 20 20 20 28 64 62 3a  stdat       (db:
4770: 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62  get-test-info db
4780: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
4790: 65 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 20  e item-path))). 
47a0: 20 20 20 20 20 28 69 66 20 28 6e 6f 74 20 74 65       (if (not te
47b0: 73 74 64 61 74 29 0a 09 20 20 28 62 65 67 69 6e  stdat)..  (begin
47c0: 0a 09 20 20 20 20 28 72 65 67 69 73 74 65 72 2d  ..    (register-
47d0: 74 65 73 74 20 64 62 20 72 75 6e 2d 69 64 20 74  test db run-id t
47e0: 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61  est-name item-pa
47f0: 74 68 29 0a 09 20 20 20 20 28 73 65 74 21 20 74  th)..    (set! t
4800: 65 73 74 64 61 74 20 28 64 62 3a 67 65 74 2d 74  estdat (db:get-t
4810: 65 73 74 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d  est-info db run-
4820: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65  id test-name ite
4830: 6d 2d 70 61 74 68 29 29 29 29 0a 20 20 20 20 20  m-path)))).     
4840: 20 28 63 68 61 6e 67 65 2d 64 69 72 65 63 74 6f   (change-directo
4850: 72 79 20 74 65 73 74 2d 70 61 74 68 29 0a 20 20  ry test-path).  
4860: 20 20 20 20 28 63 61 73 65 20 28 69 66 20 66 6f      (case (if fo
4870: 72 63 65 20 3b 3b 20 28 61 72 67 73 3a 67 65 74  rce ;; (args:get
4880: 2d 61 72 67 20 22 2d 66 6f 72 63 65 22 29 0a 09  -arg "-force")..
4890: 09 27 4e 4f 54 5f 53 54 41 52 54 45 44 0a 09 09  .'NOT_STARTED...
48a0: 28 69 66 20 74 65 73 74 64 61 74 0a 09 09 20 20  (if testdat...  
48b0: 20 20 28 73 74 72 69 6e 67 2d 3e 73 79 6d 62 6f    (string->symbo
48c0: 6c 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74  l (test:get-stat
48d0: 65 20 74 65 73 74 64 61 74 29 29 0a 09 09 20 20  e testdat))...  
48e0: 20 20 27 66 61 69 6c 65 64 2d 74 6f 2d 69 6e 73    'failed-to-ins
48f0: 65 72 74 29 29 0a 09 28 28 66 61 69 6c 65 64 2d  ert))..((failed-
4900: 74 6f 2d 69 6e 73 65 72 74 29 0a 09 20 28 64 65  to-insert).. (de
4910: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52  bug:print 0 "ERR
4920: 4f 52 3a 20 46 61 69 6c 65 64 20 74 6f 20 69 6e  OR: Failed to in
4930: 73 65 72 74 20 74 68 65 20 72 65 63 6f 72 64 20  sert the record 
4940: 69 6e 74 6f 20 74 68 65 20 64 62 22 29 29 0a 09  into the db"))..
4950: 28 28 4e 4f 54 5f 53 54 41 52 54 45 44 20 43 4f  ((NOT_STARTED CO
4960: 4d 50 4c 45 54 45 44 29 0a 09 20 28 64 65 62 75  MPLETED).. (debu
4970: 67 3a 70 72 69 6e 74 20 36 20 22 47 6f 74 20 68  g:print 6 "Got h
4980: 65 72 65 2c 20 22 20 28 74 65 73 74 3a 67 65 74  ere, " (test:get
4990: 2d 73 74 61 74 65 20 74 65 73 74 64 61 74 29 29  -state testdat))
49a0: 0a 09 20 28 6c 65 74 20 28 28 72 75 6e 66 6c 61  .. (let ((runfla
49b0: 67 20 23 66 29 29 0a 09 20 20 20 28 63 6f 6e 64  g #f))..   (cond
49c0: 0a 09 20 20 20 20 3b 3b 20 2d 66 6f 72 63 65 2c  ..    ;; -force,
49d0: 20 72 75 6e 20 6e 6f 20 6d 61 74 74 65 72 20 77   run no matter w
49e0: 68 61 74 0a 09 20 20 20 20 28 66 6f 72 63 65 20  hat..    (force 
49f0: 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 74  (set! runflag #t
4a00: 29 29 0a 09 20 20 20 20 3b 3b 20 4e 4f 54 5f 53  ))..    ;; NOT_S
4a10: 54 41 52 54 45 44 2c 20 72 75 6e 20 6e 6f 20 6d  TARTED, run no m
4a20: 61 74 74 65 72 20 77 68 61 74 0a 09 20 20 20 20  atter what..    
4a30: 28 28 65 71 75 61 6c 3f 20 28 74 65 73 74 3a 67  ((equal? (test:g
4a40: 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 74  et-state testdat
4a50: 29 20 22 4e 4f 54 5f 53 54 41 52 54 45 44 22 29  ) "NOT_STARTED")
4a60: 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 74  (set! runflag #t
4a70: 29 29 0a 09 20 20 20 20 3b 3b 20 6e 6f 74 20 2d  ))..    ;; not -
4a80: 72 65 72 75 6e 20 61 6e 64 20 50 41 53 53 2c 20  rerun and PASS, 
4a90: 57 41 52 4e 20 6f 72 20 43 48 45 43 4b 2c 20 64  WARN or CHECK, d
4aa0: 6f 20 6e 6f 20 72 75 6e 0a 09 20 20 20 20 28 28  o no run..    ((
4ab0: 61 6e 64 20 28 6f 72 20 28 6e 6f 74 20 72 65 72  and (or (not rer
4ac0: 75 6e 29 0a 09 09 20 20 20 20 20 20 6b 65 65 70  un)...      keep
4ad0: 67 6f 69 6e 67 29 0a 09 09 20 20 3b 3b 20 52 65  going)...  ;; Re
4ae0: 71 75 69 72 65 20 74 6f 20 66 6f 72 63 65 20 72  quire to force r
4af0: 65 2d 72 75 6e 20 66 6f 72 20 43 4f 4d 50 4c 45  e-run for COMPLE
4b00: 54 45 44 20 6f 72 20 2a 61 6e 79 74 68 69 6e 67  TED or *anything
4b10: 2a 20 2b 20 50 41 53 53 2c 57 41 52 4e 20 6f 72  * + PASS,WARN or
4b20: 20 43 48 45 43 4b 0a 09 09 20 20 28 6f 72 20 28   CHECK...  (or (
4b30: 6d 65 6d 62 65 72 20 28 74 65 73 74 3a 67 65 74  member (test:get
4b40: 2d 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29  -status testdat)
4b50: 20 27 28 22 50 41 53 53 22 20 22 57 41 52 4e 22   '("PASS" "WARN"
4b60: 20 22 43 48 45 43 4b 22 29 29 0a 09 09 20 20 20   "CHECK"))...   
4b70: 20 20 20 28 6d 65 6d 62 65 72 20 28 74 65 73 74     (member (test
4b80: 3a 67 65 74 2d 73 74 61 74 65 20 20 74 65 73 74  :get-state  test
4b90: 64 61 74 29 20 27 28 22 43 4f 4d 50 4c 45 54 45  dat) '("COMPLETE
4ba0: 44 22 29 29 29 29 20 0a 09 20 20 20 20 20 28 73  D")))) ..     (s
4bb0: 65 74 21 20 72 75 6e 66 6c 61 67 20 23 66 29 29  et! runflag #f))
4bc0: 0a 09 20 20 20 20 3b 3b 20 2d 72 65 72 75 6e 20  ..    ;; -rerun 
4bd0: 61 6e 64 20 73 74 61 74 75 73 20 69 73 20 6f 6e  and status is on
4be0: 65 20 6f 66 20 74 68 65 20 73 70 65 63 69 66 65  e of the specife
4bf0: 64 2c 20 72 75 6e 20 69 74 0a 09 20 20 20 20 28  d, run it..    (
4c00: 28 61 6e 64 20 72 65 72 75 6e 0a 09 09 20 20 28  (and rerun...  (
4c10: 6c 65 74 20 28 28 72 65 72 75 6e 6c 73 74 20 28  let ((rerunlst (
4c20: 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 72 65 72  string-split rer
4c30: 75 6e 20 22 2c 22 29 29 29 20 3b 3b 20 46 41 49  un ","))) ;; FAI
4c40: 4c 2c 0a 09 09 20 20 20 20 28 6d 65 6d 62 65 72  L,...    (member
4c50: 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75   (test:get-statu
4c60: 73 20 74 65 73 74 64 61 74 29 20 72 65 72 75 6e  s testdat) rerun
4c70: 6c 73 74 29 29 29 0a 09 20 20 20 20 20 28 73 65  lst)))..     (se
4c80: 74 21 20 72 75 6e 66 6c 61 67 20 23 74 29 29 0a  t! runflag #t)).
4c90: 09 20 20 20 20 3b 3b 20 2d 6b 65 65 70 67 6f 69  .    ;; -keepgoi
4ca0: 6e 67 2c 20 64 6f 20 6e 6f 74 20 72 65 72 75 6e  ng, do not rerun
4cb0: 20 46 41 49 4c 0a 09 20 20 20 20 28 28 61 6e 64   FAIL..    ((and
4cc0: 20 6b 65 65 70 67 6f 69 6e 67 0a 09 09 20 20 28   keepgoing...  (
4cd0: 6d 65 6d 62 65 72 20 28 74 65 73 74 3a 67 65 74  member (test:get
4ce0: 2d 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29  -status testdat)
4cf0: 20 27 28 22 46 41 49 4c 22 29 29 29 0a 09 20 20   '("FAIL")))..  
4d00: 20 20 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67     (set! runflag
4d10: 20 23 66 29 29 0a 09 20 20 20 20 28 28 61 6e 64   #f))..    ((and
4d20: 20 28 6e 6f 74 20 72 65 72 75 6e 29 0a 09 09 20   (not rerun)... 
4d30: 20 28 6d 65 6d 62 65 72 20 28 74 65 73 74 3a 67   (member (test:g
4d40: 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61  et-status testda
4d50: 74 29 20 27 28 22 46 41 49 4c 22 20 22 6e 2f 61  t) '("FAIL" "n/a
4d60: 22 29 29 29 0a 09 20 20 20 20 20 28 73 65 74 21  ")))..     (set!
4d70: 20 72 75 6e 66 6c 61 67 20 23 74 29 29 0a 09 20   runflag #t)).. 
4d80: 20 20 20 28 65 6c 73 65 20 28 73 65 74 21 20 72     (else (set! r
4d90: 75 6e 66 6c 61 67 20 23 66 29 29 29 0a 09 20 20  unflag #f)))..  
4da0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 36 20   (debug:print 6 
4db0: 22 52 55 4e 4e 49 4e 47 20 3d 3e 20 72 75 6e 66  "RUNNING => runf
4dc0: 6c 61 67 3a 20 22 20 72 75 6e 66 6c 61 67 20 22  lag: " runflag "
4dd0: 20 53 54 41 54 45 3a 20 22 20 28 74 65 73 74 3a   STATE: " (test:
4de0: 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61  get-state testda
4df0: 74 29 20 22 20 53 54 41 54 55 53 3a 20 22 20 28  t) " STATUS: " (
4e00: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20  test:get-status 
4e10: 74 65 73 74 64 61 74 29 29 0a 09 20 20 20 28 69  testdat))..   (i
4e20: 66 20 28 6e 6f 74 20 72 75 6e 66 6c 61 67 29 0a  f (not runflag).
4e30: 09 20 20 20 20 20 20 20 28 69 66 20 28 6e 6f 74  .       (if (not
4e40: 20 70 61 72 65 6e 74 2d 74 65 73 74 29 0a 09 09   parent-test)...
4e50: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
4e60: 31 20 22 4e 4f 54 45 3a 20 4e 6f 74 20 73 74 61  1 "NOTE: Not sta
4e70: 72 74 69 6e 67 20 74 65 73 74 20 22 20 6e 65 77  rting test " new
4e80: 2d 74 65 73 74 2d 6e 61 6d 65 20 22 20 61 73 20  -test-name " as 
4e90: 69 74 20 69 73 20 73 74 61 74 65 20 5c 22 22 20  it is state \"" 
4ea0: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20  (test:get-state 
4eb0: 74 65 73 74 64 61 74 29 20 0a 09 09 09 09 22 5c  testdat) ....."\
4ec0: 22 20 61 6e 64 20 73 74 61 74 75 73 20 5c 22 22  " and status \""
4ed0: 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75   (test:get-statu
4ee0: 73 20 74 65 73 74 64 61 74 29 20 22 5c 22 2c 20  s testdat) "\", 
4ef0: 75 73 65 20 2d 72 65 72 75 6e 20 5c 22 22 20 28  use -rerun \"" (
4f00: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74  test:get-state t
4f10: 65 73 74 64 61 74 29 20 22 5c 22 20 6f 72 20 2d  estdat) "\" or -
4f20: 66 6f 72 63 65 20 74 6f 20 6f 76 65 72 72 69 64  force to overrid
4f30: 65 22 29 29 0a 09 20 20 20 20 20 20 20 3b 3b 20  e"))..       ;; 
4f40: 4e 4f 54 45 3a 20 4e 6f 20 6c 6f 6e 67 65 72 20  NOTE: No longer 
4f50: 62 65 20 63 68 65 63 6b 69 6e 67 20 70 72 65 72  be checking prer
4f60: 65 71 75 69 73 69 74 65 73 20 68 65 72 65 21 20  equisites here! 
4f70: 57 69 6c 6c 20 6e 65 76 65 72 20 67 65 74 20 68  Will never get h
4f80: 65 72 65 20 75 6e 6c 65 73 73 20 70 72 65 72 65  ere unless prere
4f90: 71 73 20 61 72 65 0a 09 20 20 20 20 20 20 20 3b  qs are..       ;
4fa0: 3b 20 20 20 20 20 20 20 61 6c 72 65 61 64 79 20  ;       already 
4fb0: 6d 65 74 2e 0a 09 20 20 20 20 20 20 20 28 69 66  met...       (if
4fc0: 20 28 6e 6f 74 20 28 6c 61 75 6e 63 68 2d 74 65   (not (launch-te
4fd0: 73 74 20 64 62 20 72 75 6e 2d 69 64 20 72 75 6e  st db run-id run
4fe0: 6e 61 6d 65 20 74 65 73 74 2d 63 6f 6e 66 20 6b  name test-conf k
4ff0: 65 79 76 61 6c 6c 73 74 20 74 65 73 74 2d 6e 61  eyvallst test-na
5000: 6d 65 20 74 65 73 74 2d 70 61 74 68 20 69 74 65  me test-path ite
5010: 6d 64 61 74 20 66 6c 61 67 73 29 29 0a 09 09 20  mdat flags))... 
5020: 20 20 28 62 65 67 69 6e 0a 09 09 20 20 20 20 20    (begin...     
5030: 28 70 72 69 6e 74 20 22 45 52 52 4f 52 3a 20 46  (print "ERROR: F
5040: 61 69 6c 65 64 20 74 6f 20 6c 61 75 6e 63 68 20  ailed to launch 
5050: 74 68 65 20 74 65 73 74 2e 20 45 78 69 74 69 6e  the test. Exitin
5060: 67 20 61 73 20 73 6f 6f 6e 20 61 73 20 70 6f 73  g as soon as pos
5070: 73 69 62 6c 65 22 29 0a 09 09 20 20 20 20 20 28  sible")...     (
5080: 73 65 74 21 20 2a 67 6c 6f 62 61 6c 65 78 69 74  set! *globalexit
5090: 73 74 61 74 75 73 2a 20 31 29 20 3b 3b 20 0a 09  status* 1) ;; ..
50a0: 09 20 20 20 20 20 28 70 72 6f 63 65 73 73 2d 73  .     (process-s
50b0: 69 67 6e 61 6c 20 28 63 75 72 72 65 6e 74 2d 70  ignal (current-p
50c0: 72 6f 63 65 73 73 2d 69 64 29 20 73 69 67 6e 61  rocess-id) signa
50d0: 6c 2f 6b 69 6c 6c 29 29 29 29 29 29 0a 09 28 28  l/kill))))))..((
50e0: 4b 49 4c 4c 45 44 29 20 0a 09 20 28 64 65 62 75  KILLED) .. (debu
50f0: 67 3a 70 72 69 6e 74 20 31 20 22 4e 4f 54 45 3a  g:print 1 "NOTE:
5100: 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65   " new-test-name
5110: 20 22 20 69 73 20 61 6c 72 65 61 64 79 20 72 75   " is already ru
5120: 6e 6e 69 6e 67 20 6f 72 20 77 61 73 20 65 78 70  nning or was exp
5130: 6c 69 63 74 6c 79 20 6b 69 6c 6c 65 64 2c 20 75  lictly killed, u
5140: 73 65 20 2d 66 6f 72 63 65 20 74 6f 20 6c 61 75  se -force to lau
5150: 6e 63 68 20 69 74 2e 22 29 29 0a 09 28 28 4c 41  nch it."))..((LA
5160: 55 4e 43 48 45 44 20 52 45 4d 4f 54 45 48 4f 53  UNCHED REMOTEHOS
5170: 54 53 54 41 52 54 20 52 55 4e 4e 49 4e 47 29 20  TSTART RUNNING) 
5180: 20 0a 09 20 28 69 66 20 28 3e 20 28 2d 20 28 63   .. (if (> (- (c
5190: 75 72 72 65 6e 74 2d 73 65 63 6f 6e 64 73 29 28  urrent-seconds)(
51a0: 2b 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 65  + (db:test-get-e
51b0: 76 65 6e 74 5f 74 69 6d 65 20 74 65 73 74 64 61  vent_time testda
51c0: 74 29 0a 09 09 09 09 20 20 20 20 20 20 20 28 64  t).....       (d
51d0: 62 3a 74 65 73 74 2d 67 65 74 2d 72 75 6e 5f 64  b:test-get-run_d
51e0: 75 72 61 74 69 6f 6e 20 74 65 73 74 64 61 74 29  uration testdat)
51f0: 29 29 0a 09 09 36 30 30 29 20 3b 3b 20 69 2e 65  ))...600) ;; i.e
5200: 2e 20 6e 6f 20 75 70 64 61 74 65 20 66 6f 72 20  . no update for 
5210: 6d 6f 72 65 20 74 68 61 6e 20 36 30 30 20 73 65  more than 600 se
5220: 63 6f 6e 64 73 0a 09 20 20 20 20 20 28 62 65 67  conds..     (beg
5230: 69 6e 0a 09 20 20 20 20 20 20 20 28 64 65 62 75  in..       (debu
5240: 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e 49  g:print 0 "WARNI
5250: 4e 47 3a 20 54 65 73 74 20 22 20 74 65 73 74 2d  NG: Test " test-
5260: 6e 61 6d 65 20 22 20 61 70 70 65 61 72 73 20 74  name " appears t
5270: 6f 20 62 65 20 64 65 61 64 2e 20 46 6f 72 63 69  o be dead. Forci
5280: 6e 67 20 69 74 20 74 6f 20 73 74 61 74 65 20 49  ng it to state I
5290: 4e 43 4f 4d 50 4c 45 54 45 20 61 6e 64 20 73 74  NCOMPLETE and st
52a0: 61 74 75 73 20 53 54 55 43 4b 2f 44 45 41 44 22  atus STUCK/DEAD"
52b0: 29 0a 09 20 20 20 20 20 20 20 28 74 65 73 74 2d  )..       (test-
52c0: 73 65 74 2d 73 74 61 74 75 73 21 20 64 62 20 72  set-status! db r
52d0: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
52e0: 22 49 4e 43 4f 4d 50 4c 45 54 45 22 20 22 53 54  "INCOMPLETE" "ST
52f0: 55 43 4b 2f 44 45 41 44 22 20 69 74 65 6d 64 61  UCK/DEAD" itemda
5300: 74 20 22 54 65 73 74 20 69 73 20 73 74 75 63 6b  t "Test is stuck
5310: 20 6f 72 20 64 65 61 64 22 20 23 66 29 29 0a 09   or dead" #f))..
5320: 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e       (debug:prin
5330: 74 20 32 20 22 4e 4f 54 45 3a 20 22 20 74 65 73  t 2 "NOTE: " tes
5340: 74 2d 6e 61 6d 65 20 22 20 69 73 20 61 6c 72 65  t-name " is alre
5350: 61 64 79 20 72 75 6e 6e 69 6e 67 22 29 29 29 0a  ady running"))).
5360: 09 28 65 6c 73 65 20 20 20 20 20 20 20 28 64 65  .(else       (de
5370: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52  bug:print 0 "ERR
5380: 4f 52 3a 20 46 61 69 6c 65 64 20 74 6f 20 6c 61  OR: Failed to la
5390: 75 6e 63 68 20 74 65 73 74 20 22 20 6e 65 77 2d  unch test " new-
53a0: 74 65 73 74 2d 6e 61 6d 65 20 22 2e 20 55 6e 72  test-name ". Unr
53b0: 65 63 6f 67 6e 69 73 65 64 20 73 74 61 74 65 20  ecognised state 
53c0: 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74  " (test:get-stat
53d0: 65 20 74 65 73 74 64 61 74 29 29 29 29 29 29 29  e testdat)))))))
53e0: 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ..;;============
53f0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5400: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5410: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5420: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 45 4e  ==========.;; EN
5430: 44 20 4f 46 20 4e 45 57 20 53 54 55 46 46 0a 3b  D OF NEW STUFF.;
5440: 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ;===============
5450: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5460: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5470: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5480: 3d 3d 3d 3d 3d 3d 3d 0a 0a 28 64 65 66 69 6e 65  =======..(define
5490: 20 28 67 65 74 2d 64 69 72 2d 75 70 2d 6e 20 64   (get-dir-up-n d
54a0: 69 72 20 2e 20 70 61 72 61 6d 73 29 20 0a 20 20  ir . params) .  
54b0: 28 6c 65 74 20 28 28 64 70 61 72 74 73 20 20 28  (let ((dparts  (
54c0: 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 64 69 72  string-split dir
54d0: 20 22 2f 22 29 29 0a 09 28 63 6f 75 6e 74 20 20   "/"))..(count  
54e0: 20 28 69 66 20 28 6e 75 6c 6c 3f 20 70 61 72 61   (if (null? para
54f0: 6d 73 29 20 31 20 28 63 61 72 20 70 61 72 61 6d  ms) 1 (car param
5500: 73 29 29 29 29 0a 20 20 20 20 28 63 6f 6e 63 20  s)))).    (conc 
5510: 22 2f 22 20 28 73 74 72 69 6e 67 2d 69 6e 74 65  "/" (string-inte
5520: 72 73 70 65 72 73 65 20 0a 09 20 20 20 20 20 20  rsperse ..      
5530: 20 28 74 61 6b 65 20 64 70 61 72 74 73 20 28 2d   (take dparts (-
5540: 20 28 6c 65 6e 67 74 68 20 64 70 61 72 74 73 29   (length dparts)
5550: 20 63 6f 75 6e 74 29 29 0a 09 20 20 20 20 20 20   count))..      
5560: 20 22 2f 22 29 29 29 29 0a 3b 3b 20 52 65 6d 6f   "/")))).;; Remo
5570: 76 65 20 72 75 6e 73 0a 3b 3b 20 66 69 65 6c 64  ve runs.;; field
5580: 73 20 61 72 65 20 70 61 73 73 69 6e 67 20 69 6e  s are passing in
5590: 20 74 68 72 6f 75 67 68 20 0a 28 64 65 66 69 6e   through .(defin
55a0: 65 20 28 72 75 6e 73 3a 72 65 6d 6f 76 65 2d 72  e (runs:remove-r
55b0: 75 6e 73 20 64 62 20 72 75 6e 6e 61 6d 65 70 61  uns db runnamepa
55c0: 74 74 20 74 65 73 74 70 61 74 74 20 69 74 65 6d  tt testpatt item
55d0: 70 61 74 74 29 0a 20 20 28 6c 65 74 2a 20 28 28  patt).  (let* ((
55e0: 6b 65 79 73 20 20 20 20 20 20 20 20 28 64 62 2d  keys        (db-
55f0: 67 65 74 2d 6b 65 79 73 20 64 62 29 29 0a 09 20  get-keys db)).. 
5600: 28 72 75 6e 64 61 74 20 20 20 20 20 20 28 72 75  (rundat      (ru
5610: 6e 73 3a 67 65 74 2d 72 75 6e 73 2d 62 79 2d 70  ns:get-runs-by-p
5620: 61 74 74 20 64 62 20 6b 65 79 73 20 72 75 6e 6e  att db keys runn
5630: 61 6d 65 70 61 74 74 29 29 0a 09 20 28 68 65 61  amepatt)).. (hea
5640: 64 65 72 20 20 20 20 20 20 28 76 65 63 74 6f 72  der      (vector
5650: 2d 72 65 66 20 72 75 6e 64 61 74 20 30 29 29 0a  -ref rundat 0)).
5660: 09 20 28 72 75 6e 73 20 20 20 20 20 20 20 20 28  . (runs        (
5670: 76 65 63 74 6f 72 2d 72 65 66 20 72 75 6e 64 61  vector-ref runda
5680: 74 20 31 29 29 29 0a 20 20 20 20 28 64 65 62 75  t 1))).    (debu
5690: 67 3a 70 72 69 6e 74 20 31 20 22 48 65 61 64 65  g:print 1 "Heade
56a0: 72 3a 20 22 20 68 65 61 64 65 72 29 0a 20 20 20  r: " header).   
56b0: 20 28 66 6f 72 2d 65 61 63 68 0a 20 20 20 20 20   (for-each.     
56c0: 28 6c 61 6d 62 64 61 20 28 72 75 6e 29 0a 20 20  (lambda (run).  
56d0: 20 20 20 20 20 28 6c 65 74 20 28 28 72 75 6e 6b       (let ((runk
56e0: 65 79 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72  ey (string-inter
56f0: 73 70 65 72 73 65 20 28 6d 61 70 20 28 6c 61 6d  sperse (map (lam
5700: 62 64 61 20 28 6b 29 0a 09 09 09 09 09 09 28 64  bda (k).......(d
5710: 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68  b:get-value-by-h
5720: 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65 72  eader run header
5730: 20 28 76 65 63 74 6f 72 2d 72 65 66 20 6b 20 30   (vector-ref k 0
5740: 29 29 29 20 6b 65 79 73 29 20 22 2f 22 29 29 0a  ))) keys) "/")).
5750: 09 20 20 20 20 20 28 64 69 72 73 2d 74 6f 2d 72  .     (dirs-to-r
5760: 65 6d 6f 76 65 20 28 6d 61 6b 65 2d 68 61 73 68  emove (make-hash
5770: 2d 74 61 62 6c 65 29 29 29 0a 09 20 28 6c 65 74  -table))).. (let
5780: 2a 20 28 28 72 75 6e 2d 69 64 20 28 64 62 3a 67  * ((run-id (db:g
5790: 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64  et-value-by-head
57a0: 65 72 20 72 75 6e 20 68 65 61 64 65 72 20 22 69  er run header "i
57b0: 64 22 29 20 29 0a 09 09 28 74 65 73 74 73 20 20  d") )...(tests  
57c0: 28 64 62 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f  (db-get-tests-fo
57d0: 72 2d 72 75 6e 20 64 62 20 28 64 62 3a 67 65 74  r-run db (db:get
57e0: 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72  -value-by-header
57f0: 20 72 75 6e 20 68 65 61 64 65 72 20 22 69 64 22   run header "id"
5800: 29 20 74 65 73 74 70 61 74 74 20 69 74 65 6d 70  ) testpatt itemp
5810: 61 74 74 20 27 28 29 20 27 28 29 29 29 0a 09 09  att '() '()))...
5820: 28 6c 61 73 74 74 70 61 74 68 20 22 2f 64 6f 65  (lasttpath "/doe
5830: 73 2f 6e 6f 74 2f 65 78 69 73 74 2f 49 2f 68 6f  s/not/exist/I/ho
5840: 70 65 22 29 29 0a 0a 09 20 20 20 28 69 66 20 28  pe"))...   (if (
5850: 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 65 73 74 73  not (null? tests
5860: 29 29 0a 09 20 20 20 20 20 20 20 28 62 65 67 69  ))..       (begi
5870: 6e 0a 09 09 20 28 64 65 62 75 67 3a 70 72 69 6e  n... (debug:prin
5880: 74 20 31 20 22 52 65 6d 6f 76 69 6e 67 20 74 65  t 1 "Removing te
5890: 73 74 73 20 66 6f 72 20 72 75 6e 3a 20 22 20 72  sts for run: " r
58a0: 75 6e 6b 65 79 20 22 20 22 20 28 64 62 3a 67 65  unkey " " (db:ge
58b0: 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65  t-value-by-heade
58c0: 72 20 72 75 6e 20 68 65 61 64 65 72 20 22 72 75  r run header "ru
58d0: 6e 6e 61 6d 65 22 29 29 0a 09 09 20 28 66 6f 72  nname"))... (for
58e0: 2d 65 61 63 68 0a 09 09 20 20 28 6c 61 6d 62 64  -each...  (lambd
58f0: 61 20 28 74 65 73 74 29 0a 09 09 20 20 20 20 28  a (test)...    (
5900: 6c 65 74 2a 20 28 28 69 74 65 6d 2d 70 61 74 68  let* ((item-path
5910: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74   (db:test-get-it
5920: 65 6d 2d 70 61 74 68 20 74 65 73 74 29 29 0a 09  em-path test))..
5930: 09 09 20 20 20 28 74 65 73 74 2d 6e 61 6d 65 20  ..   (test-name 
5940: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73  (db:test-get-tes
5950: 74 6e 61 6d 65 20 74 65 73 74 29 29 0a 09 09 09  tname test))....
5960: 20 20 20 28 72 75 6e 2d 64 69 72 20 20 20 28 64     (run-dir   (d
5970: 62 3a 74 65 73 74 2d 67 65 74 2d 72 75 6e 64 69  b:test-get-rundi
5980: 72 20 74 65 73 74 29 29 29 0a 09 09 20 20 20 20  r test)))...    
5990: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31    (debug:print 1
59a0: 20 22 20 20 22 20 28 64 62 3a 74 65 73 74 2d 67   "  " (db:test-g
59b0: 65 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74  et-testname test
59c0: 29 20 22 20 69 64 3a 20 22 20 28 64 62 3a 74 65  ) " id: " (db:te
59d0: 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74 29 20  st-get-id test) 
59e0: 22 20 22 20 69 74 65 6d 2d 70 61 74 68 29 0a 09  " " item-path)..
59f0: 09 20 20 20 20 20 20 28 64 62 3a 64 65 6c 65 74  .      (db:delet
5a00: 65 2d 74 65 73 74 2d 72 65 63 6f 72 64 73 20 64  e-test-records d
5a10: 62 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69  b (db:test-get-i
5a20: 64 20 74 65 73 74 29 29 0a 09 09 20 20 20 20 20  d test))...     
5a30: 20 28 69 66 20 28 3e 20 28 73 74 72 69 6e 67 2d   (if (> (string-
5a40: 6c 65 6e 67 74 68 20 72 75 6e 2d 64 69 72 29 20  length run-dir) 
5a50: 35 29 20 3b 3b 20 62 61 64 20 68 65 75 72 69 73  5) ;; bad heuris
5a60: 74 69 63 20 62 75 74 20 73 68 6f 75 6c 64 20 70  tic but should p
5a70: 72 65 76 65 6e 74 20 2f 74 6d 70 20 2f 68 6f 6d  revent /tmp /hom
5a80: 65 20 65 74 63 2e 0a 09 09 09 20 20 28 6c 65 74  e etc.....  (let
5a90: 20 28 28 66 75 6c 6c 70 61 74 68 20 72 75 6e 2d   ((fullpath run-
5aa0: 64 69 72 29 29 20 3b 3b 20 22 2f 22 20 28 64 62  dir)) ;; "/" (db
5ab0: 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70  :test-get-item-p
5ac0: 61 74 68 20 74 65 73 74 29 29 29 29 0a 09 09 09  ath test))))....
5ad0: 20 20 20 20 28 73 65 74 21 20 6c 61 73 74 74 70      (set! lasttp
5ae0: 61 74 68 20 66 75 6c 6c 70 61 74 68 29 0a 09 09  ath fullpath)...
5af0: 09 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65  .    (hash-table
5b00: 2d 73 65 74 21 20 64 69 72 73 2d 74 6f 2d 72 65  -set! dirs-to-re
5b10: 6d 6f 76 65 20 66 75 6c 6c 70 61 74 68 20 23 74  move fullpath #t
5b20: 29 0a 09 09 09 20 20 20 20 3b 3b 20 54 68 65 20  )....    ;; The 
5b30: 66 6f 6c 6c 6f 77 69 6e 67 20 77 61 73 20 74 68  following was th
5b40: 65 20 73 61 66 65 20 64 65 6c 65 74 65 20 63 6f  e safe delete co
5b50: 64 65 20 62 75 74 20 69 74 20 77 61 73 20 6e 6f  de but it was no
5b60: 74 20 62 65 69 6e 67 20 65 78 65 63 74 75 74 65  t being exectute
5b70: 64 2e 0a 09 09 09 20 20 20 20 3b 3b 20 28 6c 65  d.....    ;; (le
5b80: 74 2a 20 28 28 64 69 72 73 2d 63 6f 75 6e 74 20  t* ((dirs-count 
5b90: 28 2b 20 31 20 28 6c 65 6e 67 74 68 20 6b 65 79  (+ 1 (length key
5ba0: 73 29 28 6c 65 6e 67 74 68 20 28 73 74 72 69 6e  s)(length (strin
5bb0: 67 2d 73 70 6c 69 74 20 69 74 65 6d 2d 70 61 74  g-split item-pat
5bc0: 68 20 22 2f 22 29 29 29 29 0a 09 09 09 20 20 20  h "/"))))....   
5bd0: 20 3b 3b 20 20 20 20 20 20 20 20 28 64 69 72 2d   ;;        (dir-
5be0: 74 6f 2d 72 65 6d 20 28 67 65 74 2d 64 69 72 2d  to-rem (get-dir-
5bf0: 75 70 2d 6e 20 66 75 6c 6c 70 61 74 68 20 64 69  up-n fullpath di
5c00: 72 73 2d 63 6f 75 6e 74 29 29 0a 09 09 09 20 20  rs-count))....  
5c10: 20 20 3b 3b 20 20 20 20 20 20 20 20 28 72 65 6d    ;;        (rem
5c20: 61 69 6e 69 6e 67 64 20 28 73 74 72 69 6e 67 2d  ainingd (string-
5c30: 73 75 62 73 74 69 74 75 74 65 20 28 72 65 67 65  substitute (rege
5c40: 78 70 20 28 63 6f 6e 63 20 22 5e 22 20 64 69 72  xp (conc "^" dir
5c50: 2d 74 6f 2d 72 65 6d 20 22 2f 22 29 29 20 22 22  -to-rem "/")) ""
5c60: 20 66 75 6c 6c 70 61 74 68 29 29 0a 09 09 09 20   fullpath)).... 
5c70: 20 20 20 3b 3b 20 20 20 20 20 20 20 20 28 63 6d     ;;        (cm
5c80: 64 20 28 63 6f 6e 63 20 22 63 64 20 22 20 64 69  d (conc "cd " di
5c90: 72 2d 74 6f 2d 72 65 6d 20 22 3b 20 72 6d 64 69  r-to-rem "; rmdi
5ca0: 72 20 2d 70 20 22 20 72 65 6d 61 69 6e 69 6e 67  r -p " remaining
5cb0: 64 20 29 29 29 0a 09 09 09 20 20 20 20 3b 3b 20  d )))....    ;; 
5cc0: 20 20 28 69 66 20 28 66 69 6c 65 2d 65 78 69 73    (if (file-exis
5cd0: 74 73 3f 20 66 75 6c 6c 70 61 74 68 29 0a 09 09  ts? fullpath)...
5ce0: 09 20 20 20 20 3b 3b 20 20 20 20 20 20 20 28 62  .    ;;       (b
5cf0: 65 67 69 6e 0a 09 09 09 20 20 20 20 3b 3b 20 20  egin....    ;;  
5d00: 20 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72         (debug:pr
5d10: 69 6e 74 20 31 20 63 6d 64 29 0a 09 09 09 20 20  int 1 cmd)....  
5d20: 20 20 3b 3b 20 20 20 20 20 20 20 20 20 28 73 79    ;;         (sy
5d30: 73 74 65 6d 20 63 6d 64 29 29 29 0a 09 09 09 20  stem cmd))).... 
5d40: 20 20 20 3b 3b 20 20 20 29 29 0a 09 09 09 20 20     ;;   ))....  
5d50: 20 20 29 29 29 29 0a 09 09 20 20 20 20 74 65 73    ))))...    tes
5d60: 74 73 29 29 29 0a 0a 09 20 20 20 3b 3b 20 6c 6f  ts)))...   ;; lo
5d70: 6f 6b 20 74 68 6f 75 67 68 20 74 68 65 20 64 69  ok though the di
5d80: 72 73 2d 74 6f 2d 72 65 6d 6f 76 65 20 66 6f 72  rs-to-remove for
5d90: 20 63 61 6e 64 69 64 61 74 65 73 20 66 6f 72 20   candidates for 
5da0: 72 65 6d 6f 76 61 6c 2e 20 44 6f 20 74 68 69 73  removal. Do this
5db0: 20 61 66 74 65 72 20 64 65 6c 65 74 69 6e 67 20   after deleting 
5dc0: 74 68 65 20 72 65 63 6f 72 64 73 0a 09 20 20 20  the records..   
5dd0: 3b 3b 20 66 6f 72 20 65 61 63 68 20 74 65 73 74  ;; for each test
5de0: 20 69 6e 20 63 61 73 65 20 77 65 20 67 65 74 20   in case we get 
5df0: 6b 69 6c 6c 65 64 2e 20 54 68 61 74 20 73 68 6f  killed. That sho
5e00: 75 6c 64 20 6d 69 6e 69 6d 69 7a 65 20 74 68 65  uld minimize the
5e10: 20 64 65 74 72 69 74 75 73 20 6c 65 66 74 20 6f   detritus left o
5e20: 6e 20 64 69 73 6b 0a 09 20 20 20 3b 3b 20 70 72  n disk..   ;; pr
5e30: 6f 63 65 73 73 20 74 68 65 20 64 69 72 73 20 66  ocess the dirs f
5e40: 72 6f 6d 20 6c 6f 6e 67 65 73 74 20 73 74 72 69  rom longest stri
5e50: 6e 67 20 6c 65 6e 67 74 68 20 74 6f 20 73 68 6f  ng length to sho
5e60: 72 74 65 73 74 0a 09 20 20 20 28 66 6f 72 2d 65  rtest..   (for-e
5e70: 61 63 68 20 0a 09 20 20 20 20 28 6c 61 6d 62 64  ach ..    (lambd
5e80: 61 20 28 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65  a (dir-to-remove
5e90: 29 0a 09 20 20 20 20 20 20 28 69 66 20 28 66 69  )..      (if (fi
5ea0: 6c 65 2d 65 78 69 73 74 73 3f 20 64 69 72 2d 74  le-exists? dir-t
5eb0: 6f 2d 72 65 6d 6f 76 65 29 0a 09 09 20 20 28 6c  o-remove)...  (l
5ec0: 65 74 20 28 28 64 69 72 2d 69 6e 2d 64 62 20 27  et ((dir-in-db '
5ed0: 28 29 29 29 0a 09 09 20 20 20 20 28 73 71 6c 69  ()))...    (sqli
5ee0: 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77  te3:for-each-row
5ef0: 0a 09 09 20 20 20 20 20 28 6c 61 6d 62 64 61 20  ...     (lambda 
5f00: 28 64 69 72 29 0a 09 09 20 20 20 20 20 20 20 28  (dir)...       (
5f10: 73 65 74 21 20 64 69 72 2d 69 6e 2d 64 62 20 28  set! dir-in-db (
5f20: 63 6f 6e 73 20 64 69 72 20 64 69 72 2d 69 6e 2d  cons dir dir-in-
5f30: 64 62 29 29 29 0a 09 09 20 20 20 20 20 64 62 20  db)))...     db 
5f40: 22 53 45 4c 45 43 54 20 72 75 6e 64 69 72 20 46  "SELECT rundir F
5f50: 52 4f 4d 20 74 65 73 74 73 20 57 48 45 52 45 20  ROM tests WHERE 
5f60: 72 75 6e 64 69 72 20 4c 49 4b 45 20 3f 3b 22 20  rundir LIKE ?;" 
5f70: 0a 09 09 20 20 20 20 20 28 63 6f 6e 63 20 22 25  ...     (conc "%
5f80: 22 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 20  " dir-to-remove 
5f90: 22 25 22 29 29 20 3b 3b 20 79 65 73 2c 20 49 27  "%")) ;; yes, I'
5fa0: 6d 20 67 6f 69 6e 67 20 74 6f 20 62 61 69 6c 20  m going to bail 
5fb0: 69 66 20 74 68 65 72 65 20 69 73 20 61 6e 79 74  if there is anyt
5fc0: 68 69 6e 67 20 6c 69 6b 65 20 74 68 69 73 20 64  hing like this d
5fd0: 69 72 20 69 6e 20 74 68 65 20 64 62 0a 09 09 20  ir in the db... 
5fe0: 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 64 69     (if (null? di
5ff0: 72 2d 69 6e 2d 64 62 29 0a 09 09 09 28 62 65 67  r-in-db)....(beg
6000: 69 6e 0a 09 09 09 20 20 28 64 65 62 75 67 3a 70  in....  (debug:p
6010: 72 69 6e 74 20 32 20 22 52 65 6d 6f 76 69 6e 67  rint 2 "Removing
6020: 20 64 69 72 65 63 74 6f 72 79 20 77 69 74 68 20   directory with 
6030: 7a 65 72 6f 20 64 62 20 72 65 66 65 72 65 6e 63  zero db referenc
6040: 65 73 3a 20 22 20 64 69 72 2d 74 6f 2d 72 65 6d  es: " dir-to-rem
6050: 6f 76 65 29 0a 09 09 09 20 20 28 73 79 73 74 65  ove)....  (syste
6060: 6d 20 28 63 6f 6e 63 20 22 72 6d 20 2d 72 66 20  m (conc "rm -rf 
6070: 22 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29  " dir-to-remove)
6080: 29 0a 09 09 09 20 20 28 68 61 73 68 2d 74 61 62  )....  (hash-tab
6090: 6c 65 2d 64 65 6c 65 74 65 21 20 64 69 72 73 2d  le-delete! dirs-
60a0: 74 6f 2d 72 65 6d 6f 76 65 20 64 69 72 2d 74 6f  to-remove dir-to
60b0: 2d 72 65 6d 6f 76 65 29 29 0a 09 09 09 28 64 65  -remove))....(de
60c0: 62 75 67 3a 70 72 69 6e 74 20 32 20 22 53 6b 69  bug:print 2 "Ski
60d0: 70 70 69 6e 67 20 72 65 6d 6f 76 61 6c 20 6f 66  pping removal of
60e0: 20 22 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65   " dir-to-remove
60f0: 20 22 20 66 6f 72 20 6e 6f 77 20 61 73 20 69 74   " for now as it
6100: 20 73 74 69 6c 6c 20 68 61 73 20 72 65 66 65 72   still has refer
6110: 65 6e 63 65 73 20 69 6e 20 74 68 65 20 64 61 74  ences in the dat
6120: 61 62 61 73 65 22 29 29 29 29 29 0a 09 20 20 20  abase")))))..   
6130: 20 28 73 6f 72 74 20 28 68 61 73 68 2d 74 61 62   (sort (hash-tab
6140: 6c 65 2d 6b 65 79 73 20 64 69 72 73 2d 74 6f 2d  le-keys dirs-to-
6150: 72 65 6d 6f 76 65 29 20 28 6c 61 6d 62 64 61 20  remove) (lambda 
6160: 28 61 20 62 29 28 3e 20 28 73 74 72 69 6e 67 2d  (a b)(> (string-
6170: 6c 65 6e 67 74 68 20 61 29 28 73 74 72 69 6e 67  length a)(string
6180: 2d 6c 65 6e 67 74 68 20 62 29 29 29 29 29 0a 0a  -length b)))))..
6190: 09 20 20 20 3b 3b 20 72 65 6d 6f 76 65 20 74 68  .   ;; remove th
61a0: 65 20 72 75 6e 20 69 66 20 7a 65 72 6f 20 74 65  e run if zero te
61b0: 73 74 73 20 72 65 6d 61 69 6e 0a 09 20 20 20 28  sts remain..   (
61c0: 6c 65 74 20 28 28 72 65 6d 74 65 73 74 73 20 28  let ((remtests (
61d0: 64 62 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f 72  db-get-tests-for
61e0: 2d 72 75 6e 20 64 62 20 28 64 62 3a 67 65 74 2d  -run db (db:get-
61f0: 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20  value-by-header 
6200: 72 75 6e 20 68 65 61 64 65 72 20 22 69 64 22 29  run header "id")
6210: 20 23 66 20 23 66 20 27 28 29 20 27 28 29 29 29   #f #f '() '()))
6220: 29 0a 09 20 20 20 20 20 28 69 66 20 28 6e 75 6c  )..     (if (nul
6230: 6c 3f 20 72 65 6d 74 65 73 74 73 29 20 3b 3b 20  l? remtests) ;; 
6240: 6e 6f 20 6d 6f 72 65 20 74 65 73 74 73 20 72 65  no more tests re
6250: 6d 61 69 6e 69 6e 67 0a 09 09 20 28 6c 65 74 2a  maining... (let*
6260: 20 28 28 64 70 61 72 74 73 20 20 28 73 74 72 69   ((dparts  (stri
6270: 6e 67 2d 73 70 6c 69 74 20 6c 61 73 74 74 70 61  ng-split lasttpa
6280: 74 68 20 22 2f 22 29 29 0a 09 09 09 28 72 75 6e  th "/"))....(run
6290: 70 61 74 68 20 28 63 6f 6e 63 20 22 2f 22 20 28  path (conc "/" (
62a0: 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72  string-intersper
62b0: 73 65 20 0a 09 09 09 09 09 20 20 20 20 28 74 61  se ......    (ta
62c0: 6b 65 20 64 70 61 72 74 73 20 28 2d 20 28 6c 65  ke dparts (- (le
62d0: 6e 67 74 68 20 64 70 61 72 74 73 29 20 31 29 29  ngth dparts) 1))
62e0: 0a 09 09 09 09 09 20 20 20 20 22 2f 22 29 29 29  ......    "/")))
62f0: 29 0a 09 09 20 20 20 28 64 65 62 75 67 3a 70 72  )...   (debug:pr
6300: 69 6e 74 20 31 20 22 52 65 6d 6f 76 69 6e 67 20  int 1 "Removing 
6310: 72 75 6e 3a 20 22 20 72 75 6e 6b 65 79 20 22 20  run: " runkey " 
6320: 22 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d  " (db:get-value-
6330: 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65  by-header run he
6340: 61 64 65 72 20 22 72 75 6e 6e 61 6d 65 22 29 29  ader "runname"))
6350: 0a 09 09 20 20 20 28 64 62 3a 64 65 6c 65 74 65  ...   (db:delete
6360: 2d 72 75 6e 20 64 62 20 72 75 6e 2d 69 64 29 0a  -run db run-id).
6370: 09 09 20 20 20 3b 3b 20 6e 65 65 64 20 74 6f 20  ..   ;; need to 
6380: 66 69 67 75 72 65 20 6f 75 74 20 74 68 65 20 70  figure out the p
6390: 61 74 68 20 74 6f 20 74 68 65 20 72 75 6e 20 64  ath to the run d
63a0: 69 72 20 61 6e 64 20 72 65 6d 6f 76 65 20 69 74  ir and remove it
63b0: 20 69 66 20 65 6d 70 74 79 0a 09 09 20 20 20 3b   if empty...   ;
63c0: 3b 20 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20  ;    (if (null? 
63d0: 28 67 6c 6f 62 20 28 63 6f 6e 63 20 72 75 6e 70  (glob (conc runp
63e0: 61 74 68 20 22 2f 2a 22 29 29 29 0a 09 09 20 20  ath "/*")))...  
63f0: 20 3b 3b 20 20 20 20 20 20 20 20 28 62 65 67 69   ;;        (begi
6400: 6e 0a 09 09 20 20 20 3b 3b 20 09 20 28 64 65 62  n...   ;; . (deb
6410: 75 67 3a 70 72 69 6e 74 20 31 20 22 52 65 6d 6f  ug:print 1 "Remo
6420: 76 69 6e 67 20 72 75 6e 20 64 69 72 20 22 20 72  ving run dir " r
6430: 75 6e 70 61 74 68 29 0a 09 09 20 20 20 3b 3b 20  unpath)...   ;; 
6440: 09 20 28 73 79 73 74 65 6d 20 28 63 6f 6e 63 20  . (system (conc 
6450: 22 72 6d 64 69 72 20 2d 70 20 22 20 72 75 6e 70  "rmdir -p " runp
6460: 61 74 68 29 29 29 29 0a 09 09 20 20 20 29 29 29  ath))))...   )))
6470: 29 0a 09 20 29 29 0a 20 20 20 20 20 72 75 6e 73  ).. )).     runs
6480: 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d  )))..;;=========
6490: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
64a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
64b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
64c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b  =============.;;
64d0: 20 52 6f 75 74 69 6e 65 73 20 66 6f 72 20 6d 61   Routines for ma
64e0: 6e 69 70 75 6c 61 74 69 6e 67 20 72 75 6e 73 0a  nipulating runs.
64f0: 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ;;==============
6500: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6510: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6520: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6530: 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 53 69 6e  ========..;; Sin
6540: 63 65 20 6d 61 6e 79 20 63 61 6c 6c 73 20 74 6f  ce many calls to
6550: 20 61 20 72 75 6e 20 72 65 71 75 69 72 65 20 70   a run require p
6560: 72 65 74 74 79 20 6d 75 63 68 20 74 68 65 20 73  retty much the s
6570: 61 6d 65 20 73 65 74 75 70 20 0a 3b 3b 20 74 68  ame setup .;; th
6580: 69 73 20 77 72 61 70 70 65 72 20 69 73 20 75 73  is wrapper is us
6590: 65 64 20 74 6f 20 72 65 64 75 63 65 20 74 68 65  ed to reduce the
65a0: 20 72 65 70 6c 69 63 61 74 69 6f 6e 20 6f 66 20   replication of 
65b0: 63 6f 64 65 0a 28 64 65 66 69 6e 65 20 28 67 65  code.(define (ge
65c0: 6e 65 72 61 6c 2d 72 75 6e 2d 63 61 6c 6c 20 73  neral-run-call s
65d0: 77 69 74 63 68 6e 61 6d 65 20 61 63 74 69 6f 6e  witchname action
65e0: 2d 64 65 73 63 20 70 72 6f 63 29 0a 20 20 28 6c  -desc proc).  (l
65f0: 65 74 20 28 28 72 75 6e 6e 61 6d 65 20 28 61 72  et ((runname (ar
6600: 67 73 3a 67 65 74 2d 61 72 67 20 22 3a 72 75 6e  gs:get-arg ":run
6610: 6e 61 6d 65 22 29 29 0a 09 28 74 61 72 67 65 74  name"))..(target
6620: 20 20 28 69 66 20 28 61 72 67 73 3a 67 65 74 2d    (if (args:get-
6630: 61 72 67 20 22 2d 74 61 72 67 65 74 22 29 0a 09  arg "-target")..
6640: 09 20 20 20 20 20 28 61 72 67 73 3a 67 65 74 2d  .     (args:get-
6650: 61 72 67 20 22 2d 74 61 72 67 65 74 22 29 0a 09  arg "-target")..
6660: 09 20 20 20 20 20 28 61 72 67 73 3a 67 65 74 2d  .     (args:get-
6670: 61 72 67 20 22 2d 72 65 71 74 61 72 67 22 29 29  arg "-reqtarg"))
6680: 29 29 0a 20 20 20 20 28 63 6f 6e 64 0a 20 20 20  )).    (cond.   
6690: 20 20 28 28 6e 6f 74 20 74 61 72 67 65 74 29 0a    ((not target).
66a0: 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69        (debug:pri
66b0: 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 4d 69 73  nt 0 "ERROR: Mis
66c0: 73 69 6e 67 20 72 65 71 75 69 72 65 64 20 70 61  sing required pa
66d0: 72 61 6d 65 74 65 72 20 66 6f 72 20 22 20 73 77  rameter for " sw
66e0: 69 74 63 68 6e 61 6d 65 20 22 2c 20 79 6f 75 20  itchname ", you 
66f0: 6d 75 73 74 20 73 70 65 63 69 66 79 20 74 68 65  must specify the
6700: 20 74 61 72 67 65 74 20 77 69 74 68 20 2d 74 61   target with -ta
6710: 72 67 65 74 22 29 0a 20 20 20 20 20 20 28 65 78  rget").      (ex
6720: 69 74 20 33 29 29 0a 20 20 20 20 20 28 28 6e 6f  it 3)).     ((no
6730: 74 20 72 75 6e 6e 61 6d 65 29 0a 20 20 20 20 20  t runname).     
6740: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
6750: 22 45 52 52 4f 52 3a 20 4d 69 73 73 69 6e 67 20  "ERROR: Missing 
6760: 72 65 71 75 69 72 65 64 20 70 61 72 61 6d 65 74  required paramet
6770: 65 72 20 66 6f 72 20 22 20 73 77 69 74 63 68 6e  er for " switchn
6780: 61 6d 65 20 22 2c 20 79 6f 75 20 6d 75 73 74 20  ame ", you must 
6790: 73 70 65 63 69 66 79 20 74 68 65 20 72 75 6e 20  specify the run 
67a0: 6e 61 6d 65 20 77 69 74 68 20 3a 72 75 6e 6e 61  name with :runna
67b0: 6d 65 20 72 75 6e 6e 61 6d 65 22 29 0a 20 20 20  me runname").   
67c0: 20 20 20 28 65 78 69 74 20 33 29 29 0a 20 20 20     (exit 3)).   
67d0: 20 20 28 65 6c 73 65 0a 20 20 20 20 20 20 28 6c    (else.      (l
67e0: 65 74 20 28 28 64 62 20 20 20 23 66 29 0a 09 20  et ((db   #f).. 
67f0: 20 20 20 28 6b 65 79 73 20 23 66 29 29 0a 09 28     (keys #f))..(
6800: 69 66 20 28 6e 6f 74 20 28 73 65 74 75 70 2d 66  if (not (setup-f
6810: 6f 72 2d 72 75 6e 29 29 0a 09 20 20 20 20 28 62  or-run))..    (b
6820: 65 67 69 6e 20 0a 09 20 20 20 20 20 20 28 64 65  egin ..      (de
6830: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 46 61 69  bug:print 0 "Fai
6840: 6c 65 64 20 74 6f 20 73 65 74 75 70 2c 20 65 78  led to setup, ex
6850: 69 74 69 6e 67 22 29 0a 09 20 20 20 20 20 20 28  iting")..      (
6860: 65 78 69 74 20 31 29 29 29 0a 09 28 73 65 74 21  exit 1)))..(set!
6870: 20 64 62 20 20 20 28 6f 70 65 6e 2d 64 62 29 29   db   (open-db))
6880: 0a 09 28 73 65 74 21 20 6b 65 79 73 20 28 64 62  ..(set! keys (db
6890: 2d 67 65 74 2d 6b 65 79 73 20 64 62 29 29 0a 09  -get-keys db))..
68a0: 3b 3b 20 68 61 76 65 20 65 6e 6f 75 67 68 20 74  ;; have enough t
68b0: 6f 20 70 72 6f 63 65 73 73 20 2d 74 61 72 67 65  o process -targe
68c0: 74 20 6f 72 20 2d 72 65 71 74 61 72 67 20 68 65  t or -reqtarg he
68d0: 72 65 0a 09 28 69 66 20 28 61 72 67 73 3a 67 65  re..(if (args:ge
68e0: 74 2d 61 72 67 20 22 2d 72 65 71 74 61 72 67 22  t-arg "-reqtarg"
68f0: 29 0a 09 20 20 20 20 28 6c 65 74 2a 20 28 28 72  )..    (let* ((r
6900: 75 6e 63 6f 6e 66 69 67 66 20 28 63 6f 6e 63 20  unconfigf (conc 
6910: 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f 72 75 6e   *toppath* "/run
6920: 63 6f 6e 66 69 67 73 2e 63 6f 6e 66 69 67 22 29  configs.config")
6930: 29 20 3b 3b 20 44 4f 20 4e 4f 54 20 45 56 41 4c  ) ;; DO NOT EVAL
6940: 55 41 54 45 20 41 4c 4c 20 0a 09 09 20 20 20 28  UATE ALL ...   (
6950: 72 75 6e 63 6f 6e 66 69 67 20 20 28 72 65 61 64  runconfig  (read
6960: 2d 63 6f 6e 66 69 67 20 72 75 6e 63 6f 6e 66 69  -config runconfi
6970: 67 66 20 23 66 20 23 66 20 65 6e 76 69 72 6f 6e  gf #f #f environ
6980: 2d 70 61 74 74 3a 20 23 66 29 29 29 20 0a 09 20  -patt: #f))) .. 
6990: 20 20 20 20 20 28 69 66 20 28 68 61 73 68 2d 74       (if (hash-t
69a0: 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74  able-ref/default
69b0: 20 72 75 6e 63 6f 6e 66 69 67 20 28 61 72 67 73   runconfig (args
69c0: 3a 67 65 74 2d 61 72 67 20 22 2d 72 65 71 74 61  :get-arg "-reqta
69d0: 72 67 22 29 20 23 66 29 0a 09 09 20 20 28 6b 65  rg") #f)...  (ke
69e0: 79 73 3a 74 61 72 67 65 74 2d 73 65 74 2d 61 72  ys:target-set-ar
69f0: 67 73 20 6b 65 79 73 20 28 61 72 67 73 3a 67 65  gs keys (args:ge
6a00: 74 2d 61 72 67 20 22 2d 72 65 71 74 61 72 67 22  t-arg "-reqtarg"
6a10: 29 20 61 72 67 73 3a 61 72 67 2d 68 61 73 68 29  ) args:arg-hash)
6a20: 0a 09 09 20 20 28 62 65 67 69 6e 0a 09 09 20 20  ...  (begin...  
6a30: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30    (debug:print 0
6a40: 20 22 45 52 52 4f 52 3a 20 5b 22 20 28 61 72 67   "ERROR: [" (arg
6a50: 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65 71 74  s:get-arg "-reqt
6a60: 61 72 67 22 29 20 22 5d 20 6e 6f 74 20 66 6f 75  arg") "] not fou
6a70: 6e 64 20 69 6e 20 22 20 72 75 6e 63 6f 6e 66 69  nd in " runconfi
6a80: 67 66 29 0a 09 09 20 20 20 20 28 73 71 6c 69 74  gf)...    (sqlit
6a90: 65 33 3a 66 69 6e 61 6c 69 7a 65 21 20 64 62 29  e3:finalize! db)
6aa0: 0a 09 09 20 20 20 20 28 65 78 69 74 20 31 29 29  ...    (exit 1))
6ab0: 29 29 0a 09 20 20 20 20 28 69 66 20 28 61 72 67  ))..    (if (arg
6ac0: 73 3a 67 65 74 2d 61 72 67 20 22 2d 74 61 72 67  s:get-arg "-targ
6ad0: 65 74 22 29 0a 09 09 28 6b 65 79 73 3a 74 61 72  et")...(keys:tar
6ae0: 67 65 74 2d 73 65 74 2d 61 72 67 73 20 6b 65 79  get-set-args key
6af0: 73 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20  s (args:get-arg 
6b00: 22 2d 74 61 72 67 65 74 22 20 61 72 67 73 3a 61  "-target" args:a
6b10: 72 67 2d 68 61 73 68 29 20 61 72 67 73 3a 61 72  rg-hash) args:ar
6b20: 67 2d 68 61 73 68 29 29 29 0a 09 28 69 66 20 28  g-hash)))..(if (
6b30: 6e 6f 74 20 28 63 61 72 20 2a 63 6f 6e 66 69 67  not (car *config
6b40: 69 6e 66 6f 2a 29 29 0a 09 20 20 20 20 28 62 65  info*))..    (be
6b50: 67 69 6e 0a 09 20 20 20 20 20 20 28 64 65 62 75  gin..      (debu
6b60: 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52  g:print 0 "ERROR
6b70: 3a 20 41 74 74 65 6d 70 74 65 64 20 74 6f 20 22  : Attempted to "
6b80: 20 61 63 74 69 6f 6e 2d 64 65 73 63 20 22 20 62   action-desc " b
6b90: 75 74 20 72 75 6e 20 61 72 65 61 20 63 6f 6e 66  ut run area conf
6ba0: 69 67 20 66 69 6c 65 20 6e 6f 74 20 66 6f 75 6e  ig file not foun
6bb0: 64 22 29 0a 09 20 20 20 20 20 20 28 65 78 69 74  d")..      (exit
6bc0: 20 31 29 29 0a 09 20 20 20 20 3b 3b 20 45 78 74   1))..    ;; Ext
6bd0: 72 61 63 74 20 6f 75 74 20 73 74 75 66 66 20 6e  ract out stuff n
6be0: 65 65 64 65 64 20 69 6e 20 6d 6f 73 74 20 6f 72  eeded in most or
6bf0: 20 6d 61 6e 79 20 63 61 6c 6c 73 0a 09 20 20 20   many calls..   
6c00: 20 3b 3b 20 68 65 72 65 20 74 68 65 6e 20 63 61   ;; here then ca
6c10: 6c 6c 20 70 72 6f 63 0a 09 20 20 20 20 28 6c 65  ll proc..    (le
6c20: 74 2a 20 28 28 6b 65 79 6e 61 6d 65 73 20 20 20  t* ((keynames   
6c30: 28 6d 61 70 20 6b 65 79 3a 67 65 74 2d 66 69 65  (map key:get-fie
6c40: 6c 64 6e 61 6d 65 20 6b 65 79 73 29 29 0a 09 09  ldname keys))...
6c50: 20 20 20 28 6b 65 79 76 61 6c 6c 73 74 20 20 28     (keyvallst  (
6c60: 6b 65 79 73 2d 3e 76 61 6c 6c 69 73 74 20 6b 65  keys->vallist ke
6c70: 79 73 20 23 74 29 29 29 0a 09 20 20 20 20 20 20  ys #t)))..      
6c80: 28 70 72 6f 63 20 64 62 20 74 61 72 67 65 74 20  (proc db target 
6c90: 72 75 6e 6e 61 6d 65 20 6b 65 79 73 20 6b 65 79  runname keys key
6ca0: 6e 61 6d 65 73 20 6b 65 79 76 61 6c 6c 73 74 29  names keyvallst)
6cb0: 29 29 0a 09 28 73 71 6c 69 74 65 33 3a 66 69 6e  ))..(sqlite3:fin
6cc0: 61 6c 69 7a 65 21 20 64 62 29 0a 09 28 73 65 74  alize! db)..(set
6cd0: 21 20 2a 64 69 64 73 6f 6d 65 74 68 69 6e 67 2a  ! *didsomething*
6ce0: 20 23 74 29 29 29 29 29 29 0a 0a 3b 3b 3d 3d 3d   #t))))))..;;===
6cf0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6d00: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6d10: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6d20: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6d30: 3d 3d 3d 0a 3b 3b 20 52 6f 6c 6c 75 70 20 72 75  ===.;; Rollup ru
6d40: 6e 73 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ns.;;===========
6d50: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6d60: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6d70: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6d80: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b 20  ===========..;; 
6d90: 55 70 64 61 74 65 20 74 68 65 20 74 65 73 74 5f  Update the test_
6da0: 6d 65 74 61 20 74 61 62 6c 65 20 66 6f 72 20 74  meta table for t
6db0: 68 69 73 20 74 65 73 74 0a 28 64 65 66 69 6e 65  his test.(define
6dc0: 20 28 72 75 6e 73 3a 75 70 64 61 74 65 2d 74 65   (runs:update-te
6dd0: 73 74 5f 6d 65 74 61 20 64 62 20 74 65 73 74 2d  st_meta db test-
6de0: 6e 61 6d 65 20 74 65 73 74 2d 63 6f 6e 66 29 0a  name test-conf).
6df0: 20 20 28 6c 65 74 20 28 28 63 75 72 72 72 65 63    (let ((currrec
6e00: 6f 72 64 20 28 64 62 3a 74 65 73 74 6d 65 74 61  ord (db:testmeta
6e10: 2d 67 65 74 2d 72 65 63 6f 72 64 20 64 62 20 74  -get-record db t
6e20: 65 73 74 2d 6e 61 6d 65 29 29 29 0a 20 20 20 20  est-name))).    
6e30: 28 69 66 20 28 6e 6f 74 20 63 75 72 72 72 65 63  (if (not currrec
6e40: 6f 72 64 29 0a 09 28 62 65 67 69 6e 0a 09 20 20  ord)..(begin..  
6e50: 28 73 65 74 21 20 63 75 72 72 72 65 63 6f 72 64  (set! currrecord
6e60: 20 28 6d 61 6b 65 2d 76 65 63 74 6f 72 20 31 30   (make-vector 10
6e70: 20 23 66 29 29 0a 09 20 20 28 64 62 3a 74 65 73   #f))..  (db:tes
6e80: 74 6d 65 74 61 2d 61 64 64 2d 72 65 63 6f 72 64  tmeta-add-record
6e90: 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 29 29 29   db test-name)))
6ea0: 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20 0a  .    (for-each .
6eb0: 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 6b 65       (lambda (ke
6ec0: 79 29 0a 20 20 20 20 20 20 20 28 6c 65 74 2a 20  y).       (let* 
6ed0: 28 28 69 64 78 20 28 63 61 64 72 20 6b 65 79 29  ((idx (cadr key)
6ee0: 29 0a 09 20 20 20 20 20 20 28 66 6c 64 20 28 63  )..      (fld (c
6ef0: 61 72 20 20 6b 65 79 29 29 0a 09 20 20 20 20 20  ar  key))..     
6f00: 20 28 76 61 6c 20 28 63 6f 6e 66 69 67 2d 6c 6f   (val (config-lo
6f10: 6f 6b 75 70 20 74 65 73 74 2d 63 6f 6e 66 20 22  okup test-conf "
6f20: 74 65 73 74 5f 6d 65 74 61 22 20 66 6c 64 29 29  test_meta" fld))
6f30: 29 0a 09 20 3b 3b 20 28 64 65 62 75 67 3a 70 72  ).. ;; (debug:pr
6f40: 69 6e 74 20 35 20 22 69 64 78 3a 20 22 20 69 64  int 5 "idx: " id
6f50: 78 20 22 20 66 6c 64 3a 20 22 20 66 6c 64 20 22  x " fld: " fld "
6f60: 20 76 61 6c 3a 20 22 20 76 61 6c 29 0a 09 20 28   val: " val).. (
6f70: 69 66 20 28 61 6e 64 20 76 61 6c 20 28 6e 6f 74  if (and val (not
6f80: 20 28 65 71 75 61 6c 3f 20 28 76 65 63 74 6f 72   (equal? (vector
6f90: 2d 72 65 66 20 63 75 72 72 72 65 63 6f 72 64 20  -ref currrecord 
6fa0: 69 64 78 29 20 76 61 6c 29 29 29 0a 09 20 20 20  idx) val)))..   
6fb0: 20 20 28 62 65 67 69 6e 0a 09 20 20 20 20 20 20    (begin..      
6fc0: 20 28 70 72 69 6e 74 20 22 55 70 64 61 74 69 6e   (print "Updatin
6fd0: 67 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20  g " test-name " 
6fe0: 22 20 66 6c 64 20 22 20 74 6f 20 22 20 76 61 6c  " fld " to " val
6ff0: 29 0a 09 20 20 20 20 20 20 20 28 64 62 3a 74 65  )..       (db:te
7000: 73 74 6d 65 74 61 2d 75 70 64 61 74 65 2d 66 69  stmeta-update-fi
7010: 65 6c 64 20 64 62 20 74 65 73 74 2d 6e 61 6d 65  eld db test-name
7020: 20 66 6c 64 20 76 61 6c 29 29 29 29 29 0a 20 20   fld val))))).  
7030: 20 20 20 27 28 28 22 61 75 74 68 6f 72 22 20 32     '(("author" 2
7040: 29 28 22 6f 77 6e 65 72 22 20 33 29 28 22 64 65  )("owner" 3)("de
7050: 73 63 72 69 70 74 69 6f 6e 22 20 34 29 28 22 72  scription" 4)("r
7060: 65 76 69 65 77 65 64 22 20 35 29 28 22 74 61 67  eviewed" 5)("tag
7070: 73 22 20 39 29 29 29 29 29 0a 0a 3b 3b 20 55 70  s" 9)))))..;; Up
7080: 64 61 74 65 20 74 65 73 74 5f 6d 65 74 61 20 66  date test_meta f
7090: 6f 72 20 61 6c 6c 20 74 65 73 74 73 0a 28 64 65  or all tests.(de
70a0: 66 69 6e 65 20 28 72 75 6e 73 3a 75 70 64 61 74  fine (runs:updat
70b0: 65 2d 61 6c 6c 2d 74 65 73 74 5f 6d 65 74 61 20  e-all-test_meta 
70c0: 64 62 29 0a 20 20 28 6c 65 74 20 28 28 74 65 73  db).  (let ((tes
70d0: 74 2d 6e 61 6d 65 73 20 28 67 65 74 2d 61 6c 6c  t-names (get-all
70e0: 2d 6c 65 67 61 6c 2d 74 65 73 74 73 29 29 29 0a  -legal-tests))).
70f0: 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20      (for-each . 
7100: 20 20 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73      (lambda (tes
7110: 74 2d 6e 61 6d 65 29 0a 20 20 20 20 20 20 20 28  t-name).       (
7120: 6c 65 74 2a 20 28 28 74 65 73 74 2d 70 61 74 68  let* ((test-path
7130: 20 20 20 20 28 63 6f 6e 63 20 2a 74 6f 70 70 61      (conc *toppa
7140: 74 68 2a 20 22 2f 74 65 73 74 73 2f 22 20 74 65  th* "/tests/" te
7150: 73 74 2d 6e 61 6d 65 29 29 0a 09 20 20 20 20 20  st-name))..     
7160: 20 28 74 65 73 74 2d 63 6f 6e 66 69 67 66 20 28   (test-configf (
7170: 63 6f 6e 63 20 74 65 73 74 2d 70 61 74 68 20 22  conc test-path "
7180: 2f 74 65 73 74 63 6f 6e 66 69 67 22 29 29 0a 09  /testconfig"))..
7190: 20 20 20 20 20 20 28 74 65 73 74 65 78 69 73 74        (testexist
71a0: 73 20 20 20 28 61 6e 64 20 28 66 69 6c 65 2d 65  s   (and (file-e
71b0: 78 69 73 74 73 3f 20 74 65 73 74 2d 63 6f 6e 66  xists? test-conf
71c0: 69 67 66 29 28 66 69 6c 65 2d 72 65 61 64 2d 61  igf)(file-read-a
71d0: 63 63 65 73 73 3f 20 74 65 73 74 2d 63 6f 6e 66  ccess? test-conf
71e0: 69 67 66 29 29 29 0a 09 20 20 20 20 20 20 3b 3b  igf)))..      ;;
71f0: 20 72 65 61 64 20 63 6f 6e 66 69 67 73 20 77 69   read configs wi
7200: 74 68 20 74 72 69 63 6b 73 20 74 75 72 6e 65 64  th tricks turned
7210: 20 6f 66 66 20 28 69 2e 65 2e 20 6e 6f 20 73 79   off (i.e. no sy
7220: 73 74 65 6d 29 0a 09 20 20 20 20 20 20 28 74 65  stem)..      (te
7230: 73 74 2d 63 6f 6e 66 20 20 20 20 28 69 66 20 74  st-conf    (if t
7240: 65 73 74 65 78 69 73 74 73 20 28 72 65 61 64 2d  estexists (read-
7250: 63 6f 6e 66 69 67 20 74 65 73 74 2d 63 6f 6e 66  config test-conf
7260: 69 67 66 20 23 66 20 23 66 29 28 6d 61 6b 65 2d  igf #f #f)(make-
7270: 68 61 73 68 2d 74 61 62 6c 65 29 29 29 29 0a 09  hash-table))))..
7280: 20 28 72 75 6e 73 3a 75 70 64 61 74 65 2d 74 65   (runs:update-te
7290: 73 74 5f 6d 65 74 61 20 64 62 20 74 65 73 74 2d  st_meta db test-
72a0: 6e 61 6d 65 20 74 65 73 74 2d 63 6f 6e 66 29 29  name test-conf))
72b0: 29 0a 20 20 20 20 20 74 65 73 74 2d 6e 61 6d 65  ).     test-name
72c0: 73 29 29 29 0a 0a 3b 3b 20 54 68 69 73 20 63 6f  s)))..;; This co
72d0: 75 6c 64 20 70 72 6f 62 61 62 6c 79 20 62 65 20  uld probably be 
72e0: 72 65 66 61 63 74 6f 72 65 64 20 69 6e 74 6f 20  refactored into 
72f0: 6f 6e 65 20 63 6f 6d 70 6c 65 78 20 71 75 65 72  one complex quer
7300: 79 20 2e 2e 2e 0a 28 64 65 66 69 6e 65 20 28 72  y ....(define (r
7310: 75 6e 73 3a 72 6f 6c 6c 75 70 2d 72 75 6e 20 64  uns:rollup-run d
7320: 62 20 6b 65 79 73 20 6b 65 79 76 61 6c 6c 73 74  b keys keyvallst
7330: 20 72 75 6e 6e 61 6d 65 20 75 73 65 72 29 20 3b   runname user) ;
7340: 3b 20 77 61 73 20 74 61 72 67 65 74 2c 20 6e 6f  ; was target, no
7350: 77 20 6b 65 79 76 61 6c 6c 73 74 0a 20 20 28 64  w keyvallst.  (d
7360: 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 72 75  ebug:print 4 "ru
7370: 6e 73 3a 72 6f 6c 6c 75 70 2d 72 75 6e 2c 20 6b  ns:rollup-run, k
7380: 65 79 73 3a 20 22 20 6b 65 79 73 20 22 20 6b 65  eys: " keys " ke
7390: 79 76 61 6c 6c 73 74 3a 20 22 20 6b 65 79 76 61  yvallst: " keyva
73a0: 6c 6c 73 74 20 22 20 3a 72 75 6e 6e 61 6d 65 20  llst " :runname 
73b0: 22 20 72 75 6e 6e 61 6d 65 20 22 20 75 73 65 72  " runname " user
73c0: 3a 20 22 20 75 73 65 72 29 0a 20 20 28 6c 65 74  : " user).  (let
73d0: 2a 20 28 3b 20 28 6b 65 79 76 61 6c 6c 6c 73 74  * (; (keyvalllst
73e0: 20 20 20 20 20 20 28 6b 65 79 73 3a 74 61 72 67        (keys:targ
73f0: 65 74 2d 3e 6b 65 79 76 61 6c 20 6b 65 79 73 20  et->keyval keys 
7400: 74 61 72 67 65 74 29 29 0a 09 20 28 6e 65 77 2d  target)).. (new-
7410: 72 75 6e 2d 69 64 20 20 20 20 20 20 28 72 75 6e  run-id      (run
7420: 73 3a 72 65 67 69 73 74 65 72 2d 72 75 6e 20 64  s:register-run d
7430: 62 20 6b 65 79 73 20 6b 65 79 76 61 6c 6c 73 74  b keys keyvallst
7440: 20 72 75 6e 6e 61 6d 65 20 22 6e 65 77 22 20 22   runname "new" "
7450: 6e 2f 61 22 20 75 73 65 72 29 29 0a 09 20 28 70  n/a" user)).. (p
7460: 72 65 76 2d 74 65 73 74 73 20 20 20 20 20 20 28  rev-tests      (
7470: 74 65 73 74 3a 67 65 74 2d 6d 61 74 63 68 69 6e  test:get-matchin
7480: 67 2d 70 72 65 76 69 6f 75 73 2d 74 65 73 74 2d  g-previous-test-
7490: 72 75 6e 2d 72 65 63 6f 72 64 73 20 64 62 20 6e  run-records db n
74a0: 65 77 2d 72 75 6e 2d 69 64 20 22 25 22 20 22 25  ew-run-id "%" "%
74b0: 22 29 29 0a 09 20 28 63 75 72 72 2d 74 65 73 74  ")).. (curr-test
74c0: 73 20 20 20 20 20 20 28 64 62 2d 67 65 74 2d 74  s      (db-get-t
74d0: 65 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20  ests-for-run db 
74e0: 6e 65 77 2d 72 75 6e 2d 69 64 20 22 25 22 20 22  new-run-id "%" "
74f0: 25 22 20 27 28 29 20 27 28 29 29 29 0a 09 20 28  %" '() '())).. (
7500: 63 75 72 72 2d 74 65 73 74 73 2d 68 61 73 68 20  curr-tests-hash 
7510: 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65  (make-hash-table
7520: 29 29 29 0a 20 20 20 20 28 64 62 3a 75 70 64 61  ))).    (db:upda
7530: 74 65 2d 72 75 6e 2d 65 76 65 6e 74 5f 74 69 6d  te-run-event_tim
7540: 65 20 64 62 20 6e 65 77 2d 72 75 6e 2d 69 64 29  e db new-run-id)
7550: 0a 20 20 20 20 3b 3b 20 69 6e 64 65 78 20 74 68  .    ;; index th
7560: 65 20 61 6c 72 65 61 64 79 20 73 61 76 65 64 20  e already saved 
7570: 74 65 73 74 73 20 62 79 20 74 65 73 74 6e 61 6d  tests by testnam
7580: 65 20 61 6e 64 20 69 74 65 6d 64 61 74 20 69 6e  e and itemdat in
7590: 20 63 75 72 72 2d 74 65 73 74 73 2d 68 61 73 68   curr-tests-hash
75a0: 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 0a 20  .    (for-each. 
75b0: 20 20 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73      (lambda (tes
75c0: 74 64 61 74 29 0a 20 20 20 20 20 20 20 28 6c 65  tdat).       (le
75d0: 74 2a 20 28 28 74 65 73 74 6e 61 6d 65 20 20 28  t* ((testname  (
75e0: 64 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74  db:test-get-test
75f0: 6e 61 6d 65 20 74 65 73 74 64 61 74 29 29 0a 09  name testdat))..
7600: 20 20 20 20 20 20 28 69 74 65 6d 2d 70 61 74 68        (item-path
7610: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74   (db:test-get-it
7620: 65 6d 2d 70 61 74 68 20 74 65 73 74 64 61 74 29  em-path testdat)
7630: 29 0a 09 20 20 20 20 20 20 28 66 75 6c 6c 2d 6e  )..      (full-n
7640: 61 6d 65 20 28 63 6f 6e 63 20 74 65 73 74 6e 61  ame (conc testna
7650: 6d 65 20 22 2f 22 20 69 74 65 6d 2d 70 61 74 68  me "/" item-path
7660: 29 29 29 0a 09 20 28 68 61 73 68 2d 74 61 62 6c  ))).. (hash-tabl
7670: 65 2d 73 65 74 21 20 63 75 72 72 2d 74 65 73 74  e-set! curr-test
7680: 73 2d 68 61 73 68 20 66 75 6c 6c 2d 6e 61 6d 65  s-hash full-name
7690: 20 74 65 73 74 64 61 74 29 29 29 0a 20 20 20 20   testdat))).    
76a0: 20 63 75 72 72 2d 74 65 73 74 73 29 0a 20 20 20   curr-tests).   
76b0: 20 3b 3b 20 4e 4f 50 45 3a 20 4e 6f 6e 2d 6f 70   ;; NOPE: Non-op
76c0: 74 69 6d 61 6c 20 61 70 70 72 6f 61 63 68 2e 20  timal approach. 
76d0: 54 72 79 20 74 68 69 73 20 69 6e 73 74 65 61 64  Try this instead
76e0: 2e 0a 20 20 20 20 3b 3b 20 20 20 31 2e 20 74 65  ..    ;;   1. te
76f0: 73 74 73 20 61 72 65 20 72 65 63 65 69 76 65 64  sts are received
7700: 20 69 6e 20 61 20 6c 69 73 74 2c 20 6d 6f 73 74   in a list, most
7710: 20 72 65 63 65 6e 74 20 66 69 72 73 74 0a 20 20   recent first.  
7720: 20 20 3b 3b 20 20 20 32 2e 20 72 65 70 6c 61 63    ;;   2. replac
7730: 65 20 74 68 65 20 72 6f 6c 6c 75 70 20 74 65 73  e the rollup tes
7740: 74 20 77 69 74 68 20 74 68 65 20 6e 65 77 20 2a  t with the new *
7750: 61 6c 77 61 79 73 2a 0a 20 20 20 20 28 66 6f 72  always*.    (for
7760: 2d 65 61 63 68 20 0a 20 20 20 20 20 28 6c 61 6d  -each .     (lam
7770: 62 64 61 20 28 74 65 73 74 64 61 74 29 0a 20 20  bda (testdat).  
7780: 20 20 20 20 20 28 6c 65 74 2a 20 28 28 74 65 73       (let* ((tes
7790: 74 6e 61 6d 65 20 20 28 64 62 3a 74 65 73 74 2d  tname  (db:test-
77a0: 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73  get-testname tes
77b0: 74 64 61 74 29 29 0a 09 20 20 20 20 20 20 28 69  tdat))..      (i
77c0: 74 65 6d 2d 70 61 74 68 20 28 64 62 3a 74 65 73  tem-path (db:tes
77d0: 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20  t-get-item-path 
77e0: 74 65 73 74 64 61 74 29 29 0a 09 20 20 20 20 20  testdat))..     
77f0: 20 28 66 75 6c 6c 2d 6e 61 6d 65 20 28 63 6f 6e   (full-name (con
7800: 63 20 74 65 73 74 6e 61 6d 65 20 22 2f 22 20 69  c testname "/" i
7810: 74 65 6d 2d 70 61 74 68 29 29 0a 09 20 20 20 20  tem-path))..    
7820: 20 20 28 70 72 65 76 2d 74 65 73 74 2d 64 61 74    (prev-test-dat
7830: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
7840: 2f 64 65 66 61 75 6c 74 20 63 75 72 72 2d 74 65  /default curr-te
7850: 73 74 73 2d 68 61 73 68 20 66 75 6c 6c 2d 6e 61  sts-hash full-na
7860: 6d 65 20 23 66 29 29 0a 09 20 20 20 20 20 20 28  me #f))..      (
7870: 74 65 73 74 2d 73 74 65 70 73 20 20 20 20 20 20  test-steps      
7880: 28 64 62 3a 67 65 74 2d 73 74 65 70 73 2d 66 6f  (db:get-steps-fo
7890: 72 2d 74 65 73 74 20 64 62 20 28 64 62 3a 74 65  r-test db (db:te
78a0: 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74 64 61  st-get-id testda
78b0: 74 29 29 29 0a 09 20 20 20 20 20 20 28 6e 65 77  t)))..      (new
78c0: 2d 74 65 73 74 2d 72 65 63 6f 72 64 20 23 66 29  -test-record #f)
78d0: 29 0a 09 20 3b 3b 20 72 65 70 6c 61 63 65 20 74  ).. ;; replace t
78e0: 68 65 73 65 20 77 69 74 68 20 69 6e 73 65 72 74  hese with insert
78f0: 20 2e 2e 2e 20 73 65 6c 65 63 74 0a 09 20 28 61   ... select.. (a
7900: 70 70 6c 79 20 73 71 6c 69 74 65 33 3a 65 78 65  pply sqlite3:exe
7910: 63 75 74 65 20 0a 09 09 64 62 20 0a 09 09 28 63  cute ...db ...(c
7920: 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f 52 20 52  onc "INSERT OR R
7930: 45 50 4c 41 43 45 20 49 4e 54 4f 20 74 65 73 74  EPLACE INTO test
7940: 73 20 28 72 75 6e 5f 69 64 2c 74 65 73 74 6e 61  s (run_id,testna
7950: 6d 65 2c 73 74 61 74 65 2c 73 74 61 74 75 73 2c  me,state,status,
7960: 65 76 65 6e 74 5f 74 69 6d 65 2c 68 6f 73 74 2c  event_time,host,
7970: 63 70 75 6c 6f 61 64 2c 64 69 73 6b 66 72 65 65  cpuload,diskfree
7980: 2c 75 6e 61 6d 65 2c 72 75 6e 64 69 72 2c 69 74  ,uname,rundir,it
7990: 65 6d 5f 70 61 74 68 2c 72 75 6e 5f 64 75 72 61  em_path,run_dura
79a0: 74 69 6f 6e 2c 66 69 6e 61 6c 5f 6c 6f 67 66 2c  tion,final_logf,
79b0: 63 6f 6d 6d 65 6e 74 29 20 22 0a 09 09 20 20 20  comment) "...   
79c0: 20 20 20 22 56 41 4c 55 45 53 20 28 3f 2c 3f 2c     "VALUES (?,?,
79d0: 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c  ?,?,?,?,?,?,?,?,
79e0: 3f 2c 3f 2c 3f 2c 3f 29 3b 22 29 0a 09 09 6e 65  ?,?,?,?);")...ne
79f0: 77 2d 72 75 6e 2d 69 64 20 28 63 64 64 72 20 28  w-run-id (cddr (
7a00: 76 65 63 74 6f 72 2d 3e 6c 69 73 74 20 74 65 73  vector->list tes
7a10: 74 64 61 74 29 29 29 0a 09 20 28 73 65 74 21 20  tdat))).. (set! 
7a20: 6e 65 77 2d 74 65 73 74 64 61 74 20 28 63 61 72  new-testdat (car
7a30: 20 28 64 62 2d 67 65 74 2d 74 65 73 74 73 2d 66   (db-get-tests-f
7a40: 6f 72 2d 72 75 6e 20 64 62 20 6e 65 77 2d 72 75  or-run db new-ru
7a50: 6e 2d 69 64 20 74 65 73 74 6e 61 6d 65 20 69 74  n-id testname it
7a60: 65 6d 2d 70 61 74 68 20 27 28 29 20 27 28 29 29  em-path '() '())
7a70: 29 29 0a 09 20 28 68 61 73 68 2d 74 61 62 6c 65  )).. (hash-table
7a80: 2d 73 65 74 21 20 63 75 72 72 2d 74 65 73 74 73  -set! curr-tests
7a90: 2d 68 61 73 68 20 66 75 6c 6c 2d 6e 61 6d 65 20  -hash full-name 
7aa0: 6e 65 77 2d 74 65 73 74 64 61 74 29 20 3b 3b 20  new-testdat) ;; 
7ab0: 74 68 69 73 20 63 6f 75 6c 64 20 62 65 20 63 6f  this could be co
7ac0: 6e 66 75 73 69 6e 67 2c 20 77 68 69 63 68 20 72  nfusing, which r
7ad0: 65 63 6f 72 64 20 73 68 6f 75 6c 64 20 67 6f 20  ecord should go 
7ae0: 69 6e 74 6f 20 74 68 65 20 6c 6f 6f 6b 75 70 20  into the lookup 
7af0: 74 61 62 6c 65 3f 0a 09 20 3b 3b 20 4e 6f 77 20  table?.. ;; Now 
7b00: 64 75 70 6c 69 63 61 74 65 20 74 68 65 20 74 65  duplicate the te
7b10: 73 74 20 73 74 65 70 73 0a 09 20 28 64 65 62 75  st steps.. (debu
7b20: 67 3a 70 72 69 6e 74 20 34 20 22 43 6f 70 79 69  g:print 4 "Copyi
7b30: 6e 67 20 72 65 63 6f 72 64 73 20 69 6e 20 74 65  ng records in te
7b40: 73 74 5f 73 74 65 70 73 20 66 72 6f 6d 20 74 65  st_steps from te
7b50: 73 74 5f 69 64 3d 22 20 28 64 62 3a 74 65 73 74  st_id=" (db:test
7b60: 2d 67 65 74 2d 69 64 20 74 65 73 74 64 61 74 29  -get-id testdat)
7b70: 20 22 20 74 6f 20 22 20 28 64 62 3a 74 65 73 74   " to " (db:test
7b80: 2d 67 65 74 2d 69 64 20 6e 65 77 2d 74 65 73 74  -get-id new-test
7b90: 64 61 74 29 29 0a 09 20 28 73 71 6c 69 74 65 33  dat)).. (sqlite3
7ba0: 3a 65 78 65 63 75 74 65 20 0a 09 20 20 64 62 20  :execute ..  db 
7bb0: 0a 09 20 20 28 63 6f 6e 63 20 22 49 4e 53 45 52  ..  (conc "INSER
7bc0: 54 20 4f 52 20 52 45 50 4c 41 43 45 20 49 4e 54  T OR REPLACE INT
7bd0: 4f 20 74 65 73 74 5f 73 74 65 70 73 20 28 74 65  O test_steps (te
7be0: 73 74 5f 69 64 2c 73 74 65 70 6e 61 6d 65 2c 73  st_id,stepname,s
7bf0: 74 61 74 65 2c 73 74 61 74 75 73 2c 65 76 65 6e  tate,status,even
7c00: 74 5f 74 69 6d 65 2c 63 6f 6d 6d 65 6e 74 29 20  t_time,comment) 
7c10: 22 0a 09 09 22 53 45 4c 45 43 54 20 22 20 28 64  "..."SELECT " (d
7c20: 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 6e 65  b:test-get-id ne
7c30: 77 2d 74 65 73 74 64 61 74 29 20 22 2c 73 74 65  w-testdat) ",ste
7c40: 70 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 61 74  pname,state,stat
7c50: 75 73 2c 65 76 65 6e 74 5f 74 69 6d 65 2c 63 6f  us,event_time,co
7c60: 6d 6d 65 6e 74 20 46 52 4f 4d 20 74 65 73 74 5f  mment FROM test_
7c70: 73 74 65 70 73 20 57 48 45 52 45 20 74 65 73 74  steps WHERE test
7c80: 5f 69 64 3d 3f 3b 22 29 0a 09 20 20 28 64 62 3a  _id=?;")..  (db:
7c90: 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74  test-get-id test
7ca0: 64 61 74 29 29 0a 09 20 3b 3b 20 4e 6f 77 20 64  dat)).. ;; Now d
7cb0: 75 70 6c 69 63 61 74 65 20 74 68 65 20 74 65 73  uplicate the tes
7cc0: 74 20 64 61 74 61 0a 09 20 28 64 65 62 75 67 3a  t data.. (debug:
7cd0: 70 72 69 6e 74 20 34 20 22 43 6f 70 79 69 6e 67  print 4 "Copying
7ce0: 20 72 65 63 6f 72 64 73 20 69 6e 20 74 65 73 74   records in test
7cf0: 5f 64 61 74 61 20 66 72 6f 6d 20 74 65 73 74 5f  _data from test_
7d00: 69 64 3d 22 20 28 64 62 3a 74 65 73 74 2d 67 65  id=" (db:test-ge
7d10: 74 2d 69 64 20 74 65 73 74 64 61 74 29 20 22 20  t-id testdat) " 
7d20: 74 6f 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65  to " (db:test-ge
7d30: 74 2d 69 64 20 6e 65 77 2d 74 65 73 74 64 61 74  t-id new-testdat
7d40: 29 29 0a 09 20 28 73 71 6c 69 74 65 33 3a 65 78  )).. (sqlite3:ex
7d50: 65 63 75 74 65 20 0a 09 20 20 64 62 20 0a 09 20  ecute ..  db .. 
7d60: 20 28 63 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f   (conc "INSERT O
7d70: 52 20 52 45 50 4c 41 43 45 20 49 4e 54 4f 20 74  R REPLACE INTO t
7d80: 65 73 74 5f 64 61 74 61 20 28 74 65 73 74 5f 69  est_data (test_i
7d90: 64 2c 63 61 74 65 67 6f 72 79 2c 76 61 72 69 61  d,category,varia
7da0: 62 6c 65 2c 76 61 6c 75 65 2c 65 78 70 65 63 74  ble,value,expect
7db0: 65 64 2c 74 6f 6c 2c 75 6e 69 74 73 2c 63 6f 6d  ed,tol,units,com
7dc0: 6d 65 6e 74 29 20 22 0a 09 09 22 53 45 4c 45 43  ment) "..."SELEC
7dd0: 54 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74  T " (db:test-get
7de0: 2d 69 64 20 6e 65 77 2d 74 65 73 74 64 61 74 29  -id new-testdat)
7df0: 20 22 2c 63 61 74 65 67 6f 72 79 2c 76 61 72 69   ",category,vari
7e00: 61 62 6c 65 2c 76 61 6c 75 65 2c 65 78 70 65 63  able,value,expec
7e10: 74 65 64 2c 74 6f 6c 2c 75 6e 69 74 73 2c 63 6f  ted,tol,units,co
7e20: 6d 6d 65 6e 74 20 46 52 4f 4d 20 74 65 73 74 5f  mment FROM test_
7e30: 64 61 74 61 20 57 48 45 52 45 20 74 65 73 74 5f  data WHERE test_
7e40: 69 64 3d 3f 3b 22 29 0a 09 20 20 28 64 62 3a 74  id=?;")..  (db:t
7e50: 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74 64  est-get-id testd
7e60: 61 74 29 29 0a 09 20 29 29 0a 20 20 20 20 20 70  at)).. )).     p
7e70: 72 65 76 2d 74 65 73 74 73 29 29 29 0a 09 20 0a  rev-tests))).. .
7e80: 20 20 20 20 20 0a                                     .