Megatest

Hex Artifact Content
Login

Artifact bf2ea0777435e7e1a70aa31496626a36e794d7de:


0000: 0a 3b 3b 20 43 6f 70 79 72 69 67 68 74 20 32 30  .;; Copyright 20
0010: 30 36 2d 32 30 31 31 2c 20 4d 61 74 74 68 65 77  06-2011, Matthew
0020: 20 57 65 6c 6c 61 6e 64 2e 0a 3b 3b 20 0a 3b 3b   Welland..;; .;;
0030: 20 20 54 68 69 73 20 70 72 6f 67 72 61 6d 20 69    This program i
0040: 73 20 6d 61 64 65 20 61 76 61 69 6c 61 62 6c 65  s made available
0050: 20 75 6e 64 65 72 20 74 68 65 20 47 4e 55 20 47   under the GNU G
0060: 50 4c 20 76 65 72 73 69 6f 6e 20 32 2e 30 20 6f  PL version 2.0 o
0070: 72 0a 3b 3b 20 20 67 72 65 61 74 65 72 2e 20 53  r.;;  greater. S
0080: 65 65 20 74 68 65 20 61 63 63 6f 6d 70 61 6e 79  ee the accompany
0090: 69 6e 67 20 66 69 6c 65 20 43 4f 50 59 49 4e 47  ing file COPYING
00a0: 20 66 6f 72 20 64 65 74 61 69 6c 73 2e 0a 3b 3b   for details..;;
00b0: 20 0a 3b 3b 20 20 54 68 69 73 20 70 72 6f 67 72   .;;  This progr
00c0: 61 6d 20 69 73 20 64 69 73 74 72 69 62 75 74 65  am is distribute
00d0: 64 20 57 49 54 48 4f 55 54 20 41 4e 59 20 57 41  d WITHOUT ANY WA
00e0: 52 52 41 4e 54 59 3b 20 77 69 74 68 6f 75 74 20  RRANTY; without 
00f0: 65 76 65 6e 20 74 68 65 0a 3b 3b 20 20 69 6d 70  even the.;;  imp
0100: 6c 69 65 64 20 77 61 72 72 61 6e 74 79 20 6f 66  lied warranty of
0110: 20 4d 45 52 43 48 41 4e 54 41 42 49 4c 49 54 59   MERCHANTABILITY
0120: 20 6f 72 20 46 49 54 4e 45 53 53 20 46 4f 52 20   or FITNESS FOR 
0130: 41 20 50 41 52 54 49 43 55 4c 41 52 0a 3b 3b 20  A PARTICULAR.;; 
0140: 20 50 55 52 50 4f 53 45 2e 0a 0a 3b 3b 20 20 73   PURPOSE...;;  s
0150: 74 72 66 74 69 6d 65 28 27 25 6d 2f 25 64 2f 25  trftime('%m/%d/%
0160: 59 20 25 48 3a 25 4d 3a 25 53 27 2c 27 6e 6f 77  Y %H:%M:%S','now
0170: 27 2c 27 6c 6f 63 61 6c 74 69 6d 65 27 29 0a 0a  ','localtime')..
0180: 28 75 73 65 20 73 71 6c 69 74 65 33 20 73 72 66  (use sqlite3 srf
0190: 69 2d 31 20 70 6f 73 69 78 20 72 65 67 65 78 20  i-1 posix regex 
01a0: 72 65 67 65 78 2d 63 61 73 65 20 73 72 66 69 2d  regex-case srfi-
01b0: 36 39 20 64 6f 74 2d 6c 6f 63 6b 69 6e 67 29 0a  69 dot-locking).
01c0: 28 69 6d 70 6f 72 74 20 28 70 72 65 66 69 78 20  (import (prefix 
01d0: 73 71 6c 69 74 65 33 20 73 71 6c 69 74 65 33 3a  sqlite3 sqlite3:
01e0: 29 29 0a 0a 28 64 65 63 6c 61 72 65 20 28 75 6e  ))..(declare (un
01f0: 69 74 20 72 75 6e 73 29 29 0a 28 64 65 63 6c 61  it runs)).(decla
0200: 72 65 20 28 75 73 65 73 20 64 62 29 29 0a 28 64  re (uses db)).(d
0210: 65 63 6c 61 72 65 20 28 75 73 65 73 20 63 6f 6d  eclare (uses com
0220: 6d 6f 6e 29 29 0a 28 64 65 63 6c 61 72 65 20 28  mon)).(declare (
0230: 75 73 65 73 20 69 74 65 6d 73 29 29 0a 28 64 65  uses items)).(de
0240: 63 6c 61 72 65 20 28 75 73 65 73 20 72 75 6e 63  clare (uses runc
0250: 6f 6e 66 69 67 29 29 0a 28 64 65 63 6c 61 72 65  onfig)).(declare
0260: 20 28 75 73 65 73 20 74 65 73 74 73 29 29 0a 0a   (uses tests))..
0270: 28 69 6e 63 6c 75 64 65 20 22 63 6f 6d 6d 6f 6e  (include "common
0280: 5f 72 65 63 6f 72 64 73 2e 73 63 6d 22 29 0a 28  _records.scm").(
0290: 69 6e 63 6c 75 64 65 20 22 6b 65 79 5f 72 65 63  include "key_rec
02a0: 6f 72 64 73 2e 73 63 6d 22 29 0a 28 69 6e 63 6c  ords.scm").(incl
02b0: 75 64 65 20 22 64 62 5f 72 65 63 6f 72 64 73 2e  ude "db_records.
02c0: 73 63 6d 22 29 0a 28 69 6e 63 6c 75 64 65 20 22  scm").(include "
02d0: 72 75 6e 5f 72 65 63 6f 72 64 73 2e 73 63 6d 22  run_records.scm"
02e0: 29 0a 28 69 6e 63 6c 75 64 65 20 22 74 65 73 74  ).(include "test
02f0: 5f 72 65 63 6f 72 64 73 2e 73 63 6d 22 29 0a 0a  _records.scm")..
0300: 3b 3b 20 72 75 6e 73 3a 67 65 74 2d 72 75 6e 73  ;; runs:get-runs
0310: 2d 62 79 2d 70 61 74 74 0a 3b 3b 20 67 65 74 20  -by-patt.;; get 
0320: 72 75 6e 73 20 62 79 20 6c 69 73 74 20 6f 66 20  runs by list of 
0330: 63 72 69 74 65 72 69 61 0a 3b 3b 20 72 65 67 69  criteria.;; regi
0340: 73 74 65 72 20 61 20 74 65 73 74 20 72 75 6e 20  ster a test run 
0350: 77 69 74 68 20 74 68 65 20 64 62 0a 3b 3b 0a 3b  with the db.;;.;
0360: 3b 20 55 73 65 3a 20 28 64 62 2d 67 65 74 2d 76  ; Use: (db-get-v
0370: 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 28  alue-by-header (
0380: 64 62 3a 67 65 74 2d 68 65 61 64 65 72 20 72 75  db:get-header ru
0390: 6e 69 6e 66 6f 29 28 64 62 3a 67 65 74 2d 72 6f  ninfo)(db:get-ro
03a0: 77 20 72 75 6e 69 6e 66 6f 29 29 0a 3b 3b 20 20  w runinfo)).;;  
03b0: 74 6f 20 65 78 74 72 61 63 74 20 69 6e 66 6f 20  to extract info 
03c0: 66 72 6f 6d 20 74 68 65 20 73 74 72 75 63 74 75  from the structu
03d0: 72 65 20 72 65 74 75 72 6e 65 64 0a 3b 3b 0a 28  re returned.;;.(
03e0: 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 67 65 74  define (runs:get
03f0: 2d 72 75 6e 73 2d 62 79 2d 70 61 74 74 20 64 62  -runs-by-patt db
0400: 20 6b 65 79 73 20 72 75 6e 6e 61 6d 65 70 61 74   keys runnamepat
0410: 74 20 2e 20 70 61 72 61 6d 73 29 20 3b 3b 20 74  t . params) ;; t
0420: 65 73 74 2d 6e 61 6d 65 29 0a 20 20 28 6c 65 74  est-name).  (let
0430: 2a 20 28 28 6b 65 79 76 61 6c 6c 73 74 20 28 6b  * ((keyvallst (k
0440: 65 79 73 2d 3e 76 61 6c 6c 69 73 74 20 6b 65 79  eys->vallist key
0450: 73 29 29 0a 09 20 28 74 6d 70 20 20 20 20 20 20  s)).. (tmp      
0460: 28 72 75 6e 73 3a 67 65 74 2d 73 74 64 2d 72 75  (runs:get-std-ru
0470: 6e 2d 66 69 65 6c 64 73 20 6b 65 79 73 20 27 28  n-fields keys '(
0480: 22 69 64 22 20 22 72 75 6e 6e 61 6d 65 22 20 22  "id" "runname" "
0490: 73 74 61 74 65 22 20 22 73 74 61 74 75 73 22 20  state" "status" 
04a0: 22 6f 77 6e 65 72 22 20 22 65 76 65 6e 74 5f 74  "owner" "event_t
04b0: 69 6d 65 22 29 29 29 0a 09 20 28 6b 65 79 73 74  ime"))).. (keyst
04c0: 72 20 20 20 28 63 61 72 20 74 6d 70 29 29 0a 09  r   (car tmp))..
04d0: 20 28 68 65 61 64 65 72 20 20 20 28 63 61 64 72   (header   (cadr
04e0: 20 74 6d 70 29 29 0a 09 20 28 72 65 73 20 20 20   tmp)).. (res   
04f0: 20 20 27 28 29 29 0a 09 20 28 6b 65 79 2d 70 61    '()).. (key-pa
0500: 74 74 20 22 22 29 29 0a 20 20 20 20 28 66 6f 72  tt "")).    (for
0510: 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 20 28 6b  -each (lambda (k
0520: 65 79 76 61 6c 29 0a 09 09 28 6c 65 74 2a 20 28  eyval)...(let* (
0530: 28 6b 65 79 20 20 20 20 28 76 65 63 74 6f 72 2d  (key    (vector-
0540: 72 65 66 20 6b 65 79 76 61 6c 20 30 29 29 0a 09  ref keyval 0))..
0550: 09 20 20 20 20 20 20 20 28 66 75 6c 6b 65 79 20  .       (fulkey 
0560: 28 63 6f 6e 63 20 22 3a 22 20 6b 65 79 29 29 0a  (conc ":" key)).
0570: 09 09 20 20 20 20 20 20 20 28 70 61 74 74 20 20  ..       (patt  
0580: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 66   (args:get-arg f
0590: 75 6c 6b 65 79 29 29 29 0a 09 09 20 20 28 69 66  ulkey)))...  (if
05a0: 20 70 61 74 74 0a 09 09 20 20 20 20 20 20 28 73   patt...      (s
05b0: 65 74 21 20 6b 65 79 2d 70 61 74 74 20 28 63 6f  et! key-patt (co
05c0: 6e 63 20 6b 65 79 2d 70 61 74 74 20 22 20 41 4e  nc key-patt " AN
05d0: 44 20 22 20 6b 65 79 20 22 20 6c 69 6b 65 20 27  D " key " like '
05e0: 22 20 70 61 74 74 20 22 27 22 29 29 0a 09 09 20  " patt "'"))... 
05f0: 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09 09 28       (begin....(
0600: 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45  debug:print 0 "E
0610: 52 52 4f 52 3a 20 73 65 61 72 63 68 69 6e 67 20  RROR: searching 
0620: 66 6f 72 20 72 75 6e 73 20 77 69 74 68 20 6e 6f  for runs with no
0630: 20 70 61 74 74 65 72 6e 20 73 65 74 20 66 6f 72   pattern set for
0640: 20 22 20 66 75 6c 6b 65 79 29 0a 09 09 09 28 65   " fulkey)....(e
0650: 78 69 74 20 36 29 29 29 29 29 0a 09 20 20 20 20  xit 6)))))..    
0660: 20 20 6b 65 79 73 29 0a 20 20 20 20 28 73 71 6c    keys).    (sql
0670: 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f  ite3:for-each-ro
0680: 77 20 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20  w .     (lambda 
0690: 28 61 20 2e 20 72 29 0a 20 20 20 20 20 20 20 28  (a . r).       (
06a0: 73 65 74 21 20 72 65 73 20 28 63 6f 6e 73 20 28  set! res (cons (
06b0: 6c 69 73 74 2d 3e 76 65 63 74 6f 72 20 28 63 6f  list->vector (co
06c0: 6e 73 20 61 20 72 29 29 20 72 65 73 29 29 29 0a  ns a r)) res))).
06d0: 20 20 20 20 20 64 62 20 0a 20 20 20 20 20 28 63       db .     (c
06e0: 6f 6e 63 20 22 53 45 4c 45 43 54 20 22 20 6b 65  onc "SELECT " ke
06f0: 79 73 74 72 20 22 20 46 52 4f 4d 20 72 75 6e 73  ystr " FROM runs
0700: 20 57 48 45 52 45 20 72 75 6e 6e 61 6d 65 20 6c   WHERE runname l
0710: 69 6b 65 20 3f 20 22 20 6b 65 79 2d 70 61 74 74  ike ? " key-patt
0720: 20 22 3b 22 29 0a 20 20 20 20 20 72 75 6e 6e 61   ";").     runna
0730: 6d 65 70 61 74 74 29 0a 20 20 20 20 28 76 65 63  mepatt).    (vec
0740: 74 6f 72 20 68 65 61 64 65 72 20 72 65 73 29 29  tor header res))
0750: 29 0a 0a 3b 3b 20 3b 3b 20 54 4f 44 4f 3a 20 43  )..;; ;; TODO: C
0760: 6f 6e 76 65 72 67 65 20 74 68 69 73 20 77 69 74  onverge this wit
0770: 68 20 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e  h db:get-test-in
0780: 66 6f 0a 3b 3b 20 28 64 65 66 69 6e 65 20 28 72  fo.;; (define (r
0790: 75 6e 73 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66  uns:get-test-inf
07a0: 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  o db run-id test
07b0: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  -name item-path)
07c0: 0a 3b 3b 20 20 20 28 6c 65 74 20 28 28 72 65 73  .;;   (let ((res
07d0: 20 23 66 29 29 20 3b 3b 20 28 76 65 63 74 6f 72   #f)) ;; (vector
07e0: 20 23 66 20 23 66 20 23 66 20 23 66 20 23 66 20   #f #f #f #f #f 
07f0: 23 66 29 29 29 0a 3b 3b 20 20 20 20 20 28 73 71  #f))).;;     (sq
0800: 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72  lite3:for-each-r
0810: 6f 77 20 0a 3b 3b 20 20 20 20 20 20 28 6c 61 6d  ow .;;      (lam
0820: 62 64 61 20 28 69 64 20 72 75 6e 2d 69 64 20 74  bda (id run-id t
0830: 65 73 74 2d 6e 61 6d 65 20 73 74 61 74 65 20 73  est-name state s
0840: 74 61 74 75 73 29 0a 3b 3b 20 20 20 20 20 20 20  tatus).;;       
0850: 20 28 73 65 74 21 20 72 65 73 20 28 76 65 63 74   (set! res (vect
0860: 6f 72 20 69 64 20 72 75 6e 2d 69 64 20 74 65 73  or id run-id tes
0870: 74 2d 6e 61 6d 65 20 73 74 61 74 65 20 73 74 61  t-name state sta
0880: 74 75 73 20 69 74 65 6d 2d 70 61 74 68 29 29 29  tus item-path)))
0890: 0a 3b 3b 20 20 20 20 20 20 64 62 20 22 53 45 4c  .;;      db "SEL
08a0: 45 43 54 20 69 64 2c 72 75 6e 5f 69 64 2c 74 65  ECT id,run_id,te
08b0: 73 74 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 61  stname,state,sta
08c0: 74 75 73 20 46 52 4f 4d 20 74 65 73 74 73 20 57  tus FROM tests W
08d0: 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e  HERE run_id=? AN
08e0: 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44  D testname=? AND
08f0: 20 69 74 65 6d 5f 70 61 74 68 3d 3f 3b 22 0a 3b   item_path=?;".;
0900: 3b 20 20 20 20 20 20 72 75 6e 2d 69 64 20 74 65  ;      run-id te
0910: 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74  st-name item-pat
0920: 68 29 0a 3b 3b 20 20 20 20 20 72 65 73 29 29 0a  h).;;     res)).
0930: 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 74  .(define (runs:t
0940: 65 73 74 2d 67 65 74 2d 66 75 6c 6c 2d 70 61 74  est-get-full-pat
0950: 68 20 74 65 73 74 29 0a 20 20 28 6c 65 74 2a 20  h test).  (let* 
0960: 28 28 74 65 73 74 6e 61 6d 65 20 28 64 62 3a 74  ((testname (db:t
0970: 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65  est-get-testname
0980: 20 20 20 74 65 73 74 29 29 0a 09 20 28 69 74 65     test)).. (ite
0990: 6d 70 61 74 68 20 28 64 62 3a 74 65 73 74 2d 67  mpath (db:test-g
09a0: 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73  et-item-path tes
09b0: 74 29 29 29 0a 20 20 20 20 28 63 6f 6e 63 20 74  t))).    (conc t
09c0: 65 73 74 6e 61 6d 65 20 28 69 66 20 28 65 71 75  estname (if (equ
09d0: 61 6c 3f 20 69 74 65 6d 70 61 74 68 20 22 22 29  al? itempath "")
09e0: 20 22 22 20 28 63 6f 6e 63 20 22 28 22 20 69 74   "" (conc "(" it
09f0: 65 6d 70 61 74 68 20 22 29 22 29 29 29 29 29 0a  empath ")"))))).
0a00: 0a 0a 28 64 65 66 69 6e 65 20 28 73 65 74 2d 6d  ..(define (set-m
0a10: 65 67 61 74 65 73 74 2d 65 6e 76 2d 76 61 72 73  egatest-env-vars
0a20: 20 64 62 20 72 75 6e 2d 69 64 29 0a 20 20 28 6c   db run-id).  (l
0a30: 65 74 20 28 28 6b 65 79 73 20 28 64 62 2d 67 65  et ((keys (db-ge
0a40: 74 2d 6b 65 79 73 20 64 62 29 29 29 0a 20 20 20  t-keys db))).   
0a50: 20 28 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62   (for-each (lamb
0a60: 64 61 20 28 6b 65 79 29 0a 09 09 28 73 71 6c 69  da (key)...(sqli
0a70: 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77  te3:for-each-row
0a80: 0a 09 09 20 28 6c 61 6d 62 64 61 20 28 76 61 6c  ... (lambda (val
0a90: 29 0a 09 09 20 20 20 28 64 65 62 75 67 3a 70 72  )...   (debug:pr
0aa0: 69 6e 74 20 32 20 22 73 65 74 65 6e 76 20 22 20  int 2 "setenv " 
0ab0: 28 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64 6e 61  (key:get-fieldna
0ac0: 6d 65 20 6b 65 79 29 20 22 20 22 20 76 61 6c 29  me key) " " val)
0ad0: 0a 09 09 20 20 20 28 73 65 74 65 6e 76 20 28 6b  ...   (setenv (k
0ae0: 65 79 3a 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65  ey:get-fieldname
0af0: 20 6b 65 79 29 20 76 61 6c 29 29 0a 09 09 20 64   key) val))... d
0b00: 62 20 0a 09 09 20 28 63 6f 6e 63 20 22 53 45 4c  b ... (conc "SEL
0b10: 45 43 54 20 22 20 28 6b 65 79 3a 67 65 74 2d 66  ECT " (key:get-f
0b20: 69 65 6c 64 6e 61 6d 65 20 6b 65 79 29 20 22 20  ieldname key) " 
0b30: 46 52 4f 4d 20 72 75 6e 73 20 57 48 45 52 45 20  FROM runs WHERE 
0b40: 69 64 3d 3f 3b 22 29 0a 09 09 20 72 75 6e 2d 69  id=?;")... run-i
0b50: 64 29 29 0a 09 20 20 20 20 20 20 6b 65 79 73 29  d))..      keys)
0b60: 0a 20 20 20 20 3b 3b 20 4c 65 74 73 20 75 73 65  .    ;; Lets use
0b70: 20 74 68 69 73 20 61 73 20 61 6e 20 6f 70 70 6f   this as an oppo
0b80: 72 74 75 6e 69 74 79 20 74 6f 20 70 75 74 20 4d  rtunity to put M
0b90: 54 5f 52 55 4e 4e 41 4d 45 20 69 6e 20 74 68 65  T_RUNNAME in the
0ba0: 20 65 6e 76 69 72 6f 6e 6d 65 6e 74 0a 20 20 20   environment.   
0bb0: 20 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61   (sqlite3:for-ea
0bc0: 63 68 2d 72 6f 77 0a 20 20 20 20 20 28 6c 61 6d  ch-row.     (lam
0bd0: 62 64 61 20 28 72 75 6e 6e 61 6d 65 29 0a 20 20  bda (runname).  
0be0: 20 20 20 20 20 28 73 65 74 65 6e 76 20 22 4d 54       (setenv "MT
0bf0: 5f 52 55 4e 4e 41 4d 45 22 20 72 75 6e 6e 61 6d  _RUNNAME" runnam
0c00: 65 29 29 0a 20 20 20 20 20 64 62 0a 20 20 20 20  e)).     db.    
0c10: 20 22 53 45 4c 45 43 54 20 72 75 6e 6e 61 6d 65   "SELECT runname
0c20: 20 46 52 4f 4d 20 72 75 6e 73 20 57 48 45 52 45   FROM runs WHERE
0c30: 20 69 64 3d 3f 3b 22 0a 20 20 20 20 20 72 75 6e   id=?;".     run
0c40: 2d 69 64 29 0a 20 20 20 20 29 29 0a 0a 28 64 65  -id).    ))..(de
0c50: 66 69 6e 65 20 28 73 65 74 2d 69 74 65 6d 2d 65  fine (set-item-e
0c60: 6e 76 2d 76 61 72 73 20 69 74 65 6d 64 61 74 29  nv-vars itemdat)
0c70: 0a 20 20 28 66 6f 72 2d 65 61 63 68 20 28 6c 61  .  (for-each (la
0c80: 6d 62 64 61 20 28 69 74 65 6d 29 0a 09 20 20 20  mbda (item)..   
0c90: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
0ca0: 32 20 22 73 65 74 65 6e 76 20 22 20 28 63 61 72  2 "setenv " (car
0cb0: 20 69 74 65 6d 29 20 22 20 22 20 28 63 61 64 72   item) " " (cadr
0cc0: 20 69 74 65 6d 29 29 0a 09 20 20 20 20 20 20 28   item))..      (
0cd0: 73 65 74 65 6e 76 20 28 63 61 72 20 69 74 65 6d  setenv (car item
0ce0: 29 20 28 63 61 64 72 20 69 74 65 6d 29 29 29 0a  ) (cadr item))).
0cf0: 09 20 20 20 20 69 74 65 6d 64 61 74 29 29 0a 0a  .    itemdat))..
0d00: 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 63 61  (define (runs:ca
0d10: 6e 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73  n-run-more-tests
0d20: 20 64 62 20 74 65 73 74 2d 72 65 63 6f 72 64 29   db test-record)
0d30: 0a 20 20 28 6c 65 74 2a 20 28 28 74 63 6f 6e 66  .  (let* ((tconf
0d40: 69 67 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ig              
0d50: 20 20 20 28 74 65 73 74 73 3a 74 65 73 74 71 75     (tests:testqu
0d60: 65 75 65 2d 67 65 74 2d 74 65 73 74 63 6f 6e 66  eue-get-testconf
0d70: 69 67 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29  ig test-record))
0d80: 0a 09 20 28 6a 6f 62 67 72 6f 75 70 20 20 20 20  .. (jobgroup    
0d90: 20 20 20 20 20 20 20 20 20 20 20 20 28 63 6f 6e              (con
0da0: 66 69 67 2d 6c 6f 6f 6b 75 70 20 74 63 6f 6e 66  fig-lookup tconf
0db0: 69 67 20 22 72 65 71 75 69 72 65 6d 65 6e 74 73  ig "requirements
0dc0: 22 20 22 6a 6f 62 67 72 6f 75 70 22 29 29 0a 09  " "jobgroup"))..
0dd0: 20 28 6e 75 6d 2d 72 75 6e 6e 69 6e 67 20 20 20   (num-running   
0de0: 20 20 20 20 20 20 20 20 20 20 28 64 62 3a 67 65            (db:ge
0df0: 74 2d 63 6f 75 6e 74 2d 74 65 73 74 73 2d 72 75  t-count-tests-ru
0e00: 6e 6e 69 6e 67 20 64 62 29 29 0a 09 20 28 6e 75  nning db)).. (nu
0e10: 6d 2d 72 75 6e 6e 69 6e 67 2d 69 6e 2d 6a 6f 62  m-running-in-job
0e20: 67 72 6f 75 70 20 28 64 62 3a 67 65 74 2d 63 6f  group (db:get-co
0e30: 75 6e 74 2d 74 65 73 74 73 2d 72 75 6e 6e 69 6e  unt-tests-runnin
0e40: 67 2d 69 6e 2d 6a 6f 62 67 72 6f 75 70 20 64 62  g-in-jobgroup db
0e50: 20 6a 6f 62 67 72 6f 75 70 29 29 0a 09 20 28 6d   jobgroup)).. (m
0e60: 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f  ax-concurrent-jo
0e70: 62 73 20 20 20 20 20 28 63 6f 6e 66 69 67 2d 6c  bs     (config-l
0e80: 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67 64 61 74  ookup *configdat
0e90: 2a 20 22 73 65 74 75 70 22 20 20 20 20 20 22 6d  * "setup"     "m
0ea0: 61 78 5f 63 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f  ax_concurrent_jo
0eb0: 62 73 22 29 29 0a 09 20 28 6a 6f 62 2d 67 72 6f  bs")).. (job-gro
0ec0: 75 70 2d 6c 69 6d 69 74 20 20 20 20 20 20 20 20  up-limit        
0ed0: 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20   (config-lookup 
0ee0: 2a 63 6f 6e 66 69 67 64 61 74 2a 20 22 6a 6f 62  *configdat* "job
0ef0: 67 72 6f 75 70 73 22 20 6a 6f 62 67 72 6f 75 70  groups" jobgroup
0f00: 29 29 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70  ))).    (debug:p
0f10: 72 69 6e 74 20 32 20 22 6d 61 78 2d 63 6f 6e 63  rint 2 "max-conc
0f20: 75 72 72 65 6e 74 2d 6a 6f 62 73 3a 20 22 20 6d  urrent-jobs: " m
0f30: 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f  ax-concurrent-jo
0f40: 62 73 20 22 2c 20 6e 75 6d 2d 72 75 6e 6e 69 6e  bs ", num-runnin
0f50: 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67  g: " num-running
0f60: 29 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28  ).    (if (not (
0f70: 65 71 3f 20 30 20 2a 67 6c 6f 62 61 6c 65 78 69  eq? 0 *globalexi
0f80: 74 73 74 61 74 75 73 2a 29 29 0a 09 23 66 0a 09  tstatus*))..#f..
0f90: 28 6c 65 74 20 28 28 63 61 6e 2d 6e 6f 74 2d 72  (let ((can-not-r
0fa0: 75 6e 2d 6d 6f 72 65 20 28 63 6f 6e 64 0a 09 09  un-more (cond...
0fb0: 09 09 20 3b 3b 20 69 66 20 6d 61 78 2d 63 6f 6e  .. ;; if max-con
0fc0: 63 75 72 72 65 6e 74 2d 6a 6f 62 73 20 69 73 20  current-jobs is 
0fd0: 73 65 74 20 61 6e 64 20 74 68 65 20 6e 75 6d 62  set and the numb
0fe0: 65 72 20 72 75 6e 6e 69 6e 67 20 69 73 20 67 72  er running is gr
0ff0: 65 61 74 65 72 20 0a 09 09 09 09 20 3b 3b 20 74  eater ..... ;; t
1000: 68 61 6e 20 69 74 20 74 68 61 6e 20 63 61 6e 6e  han it than cann
1010: 6f 74 20 72 75 6e 20 6d 6f 72 65 20 6a 6f 62 73  ot run more jobs
1020: 0a 09 09 09 09 20 28 28 61 6e 64 20 6d 61 78 2d  ..... ((and max-
1030: 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 0a  concurrent-jobs.
1040: 09 09 09 09 20 20 20 20 20 20 20 28 73 74 72 69  ....       (stri
1050: 6e 67 2d 3e 6e 75 6d 62 65 72 20 6d 61 78 2d 63  ng->number max-c
1060: 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29 0a  oncurrent-jobs).
1070: 09 09 09 09 20 20 20 20 20 20 20 28 3e 3d 20 6e  ....       (>= n
1080: 75 6d 2d 72 75 6e 6e 69 6e 67 20 28 73 74 72 69  um-running (stri
1090: 6e 67 2d 3e 6e 75 6d 62 65 72 20 6d 61 78 2d 63  ng->number max-c
10a0: 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29 29  oncurrent-jobs))
10b0: 29 0a 09 09 09 09 20 20 28 64 65 62 75 67 3a 70  ).....  (debug:p
10c0: 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e 47 3a  rint 0 "WARNING:
10d0: 20 4d 61 78 20 72 75 6e 6e 69 6e 67 20 6a 6f 62   Max running job
10e0: 73 20 65 78 63 65 65 64 65 64 2c 20 63 75 72 72  s exceeded, curr
10f0: 65 6e 74 20 6e 75 6d 62 65 72 20 72 75 6e 6e 69  ent number runni
1100: 6e 67 3a 20 22 20 6e 75 6d 2d 72 75 6e 6e 69 6e  ng: " num-runnin
1110: 67 20 0a 09 09 09 09 09 20 20 20 20 20 20 20 22  g ......       "
1120: 2c 20 6d 61 78 5f 63 6f 6e 63 75 72 72 65 6e 74  , max_concurrent
1130: 5f 6a 6f 62 73 3a 20 22 20 6d 61 78 2d 63 6f 6e  _jobs: " max-con
1140: 63 75 72 72 65 6e 74 2d 6a 6f 62 73 29 0a 09 09  current-jobs)...
1150: 09 09 20 20 23 74 29 0a 09 09 09 09 20 3b 3b 20  ..  #t)..... ;; 
1160: 69 66 20 6a 6f 62 2d 67 72 6f 75 70 2d 6c 69 6d  if job-group-lim
1170: 69 74 20 69 73 20 73 65 74 20 61 6e 64 20 6e 75  it is set and nu
1180: 6d 62 65 72 20 6f 66 20 6a 6f 62 73 20 69 6e 20  mber of jobs in 
1190: 74 68 65 20 67 72 6f 75 70 20 69 73 20 67 72 65  the group is gre
11a0: 61 74 65 72 0a 09 09 09 09 20 3b 3b 20 74 68 61  ater..... ;; tha
11b0: 6e 20 74 68 65 20 6c 69 6d 69 74 20 74 68 65 6e  n the limit then
11c0: 20 63 61 6e 6e 6f 74 20 72 75 6e 20 6d 6f 72 65   cannot run more
11d0: 20 6a 6f 62 73 20 6f 66 20 74 68 69 73 20 6b 69   jobs of this ki
11e0: 6e 64 0a 09 09 09 09 20 28 28 61 6e 64 20 6a 6f  nd..... ((and jo
11f0: 62 2d 67 72 6f 75 70 2d 6c 69 6d 69 74 0a 09 09  b-group-limit...
1200: 09 09 20 20 20 20 20 20 20 28 3e 3d 20 6e 75 6d  ..       (>= num
1210: 2d 72 75 6e 6e 69 6e 67 2d 69 6e 2d 6a 6f 62 67  -running-in-jobg
1220: 72 6f 75 70 20 6a 6f 62 2d 67 72 6f 75 70 2d 6c  roup job-group-l
1230: 69 6d 69 74 29 29 0a 09 09 09 09 20 20 28 64 65  imit)).....  (de
1240: 62 75 67 3a 70 72 69 6e 74 20 31 20 22 57 41 52  bug:print 1 "WAR
1250: 4e 49 4e 47 3a 20 6e 75 6d 62 65 72 20 6f 66 20  NING: number of 
1260: 6a 6f 62 73 20 22 20 6e 75 6d 2d 72 75 6e 6e 69  jobs " num-runni
1270: 6e 67 2d 69 6e 2d 6a 6f 62 67 72 6f 75 70 20 0a  ng-in-jobgroup .
1280: 09 09 09 09 09 20 20 20 20 20 20 20 22 20 69 6e  .....       " in
1290: 20 22 20 6a 6f 62 67 72 6f 75 70 20 22 20 65 78   " jobgroup " ex
12a0: 63 65 65 64 65 64 2c 20 77 69 6c 6c 20 6e 6f 74  ceeded, will not
12b0: 20 72 75 6e 20 22 20 28 74 65 73 74 73 3a 74 65   run " (tests:te
12c0: 73 74 71 75 65 75 65 2d 67 65 74 2d 74 65 73 74  stqueue-get-test
12d0: 6e 61 6d 65 20 74 65 73 74 2d 72 65 63 6f 72 64  name test-record
12e0: 29 29 0a 09 09 09 09 20 20 23 74 29 0a 09 09 09  )).....  #t)....
12f0: 09 20 28 65 6c 73 65 20 23 66 29 29 29 29 0a 09  . (else #f))))..
1300: 20 20 28 6e 6f 74 20 63 61 6e 2d 6e 6f 74 2d 72    (not can-not-r
1310: 75 6e 2d 6d 6f 72 65 29 29 29 29 29 0a 0a 3b 3b  un-more)))))..;;
1320: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1330: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1340: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1350: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1360: 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 4e 65 77 20 6d 65  ======.;; New me
1370: 74 68 6f 64 6f 6c 6f 67 79 2e 20 54 68 65 73 65  thodology. These
1380: 20 72 6f 75 74 69 6e 65 73 20 77 69 6c 6c 20 72   routines will r
1390: 65 70 6c 61 63 65 20 74 68 65 20 61 62 6f 76 65  eplace the above
13a0: 20 69 6e 20 74 69 6d 65 2e 20 46 6f 72 0a 3b 3b   in time. For.;;
13b0: 20 6e 6f 77 20 74 68 65 20 63 6f 64 65 20 69 73   now the code is
13c0: 20 64 75 70 6c 69 63 61 74 65 64 2e 20 54 68 69   duplicated. Thi
13d0: 73 20 73 74 75 66 66 20 69 73 20 69 6e 69 74 69  s stuff is initi
13e0: 61 6c 6c 79 20 75 73 65 64 20 69 6e 20 74 68 65  ally used in the
13f0: 20 6d 6f 6e 69 74 6f 72 0a 3b 3b 20 62 61 73 65   monitor.;; base
1400: 64 20 63 6f 64 65 2e 0a 3b 3b 3d 3d 3d 3d 3d 3d  d code..;;======
1410: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1420: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1430: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1440: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1450: 0a 0a 3b 3b 20 72 65 67 69 73 74 65 72 20 61 20  ..;; register a 
1460: 74 65 73 74 20 72 75 6e 20 77 69 74 68 20 74 68  test run with th
1470: 65 20 64 62 0a 28 64 65 66 69 6e 65 20 28 72 75  e db.(define (ru
1480: 6e 73 3a 72 65 67 69 73 74 65 72 2d 72 75 6e 20  ns:register-run 
1490: 64 62 20 6b 65 79 73 20 6b 65 79 76 61 6c 6c 73  db keys keyvalls
14a0: 74 20 72 75 6e 6e 61 6d 65 20 73 74 61 74 65 20  t runname state 
14b0: 73 74 61 74 75 73 20 75 73 65 72 29 0a 20 20 28  status user).  (
14c0: 64 65 62 75 67 3a 70 72 69 6e 74 20 33 20 22 72  debug:print 3 "r
14d0: 75 6e 73 3a 72 65 67 69 73 74 65 72 2d 72 75 6e  uns:register-run
14e0: 2c 20 6b 65 79 73 3a 20 22 20 6b 65 79 73 20 22  , keys: " keys "
14f0: 20 6b 65 79 76 61 6c 6c 73 74 3a 20 22 20 6b 65   keyvallst: " ke
1500: 79 76 61 6c 6c 73 74 20 22 20 72 75 6e 6e 61 6d  yvallst " runnam
1510: 65 3a 20 22 20 72 75 6e 6e 61 6d 65 20 22 20 73  e: " runname " s
1520: 74 61 74 65 3a 20 22 20 73 74 61 74 65 20 22 20  tate: " state " 
1530: 73 74 61 74 75 73 3a 20 22 20 73 74 61 74 75 73  status: " status
1540: 20 22 20 75 73 65 72 3a 20 22 20 75 73 65 72 29   " user: " user)
1550: 0a 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 73 74  .  (let* ((keyst
1560: 72 20 20 20 20 28 6b 65 79 73 2d 3e 6b 65 79 73  r    (keys->keys
1570: 74 72 20 6b 65 79 73 29 29 0a 09 20 28 63 6f 6d  tr keys)).. (com
1580: 6d 61 20 20 20 20 20 28 69 66 20 28 3e 20 28 6c  ma     (if (> (l
1590: 65 6e 67 74 68 20 6b 65 79 73 29 20 30 29 20 22  ength keys) 0) "
15a0: 2c 22 20 22 22 29 29 0a 09 20 28 61 6e 64 73 74  ," "")).. (andst
15b0: 72 20 20 20 20 28 69 66 20 28 3e 20 28 6c 65 6e  r    (if (> (len
15c0: 67 74 68 20 6b 65 79 73 29 20 30 29 20 22 20 41  gth keys) 0) " A
15d0: 4e 44 20 22 20 22 22 29 29 0a 09 20 28 76 61 6c  ND " "")).. (val
15e0: 73 6c 6f 74 73 20 20 28 6b 65 79 73 2d 3e 76 61  slots  (keys->va
15f0: 6c 73 6c 6f 74 73 20 6b 65 79 73 29 29 20 3b 3b  lslots keys)) ;;
1600: 20 3f 2c 3f 2c 3f 20 2e 2e 2e 0a 09 20 28 6b 65   ?,?,? ..... (ke
1610: 79 76 61 6c 73 20 20 20 28 6d 61 70 20 63 61 64  yvals   (map cad
1620: 72 20 6b 65 79 76 61 6c 6c 73 74 29 29 0a 09 20  r keyvallst)).. 
1630: 28 61 6c 6c 76 61 6c 73 20 20 20 28 61 70 70 65  (allvals   (appe
1640: 6e 64 20 28 6c 69 73 74 20 72 75 6e 6e 61 6d 65  nd (list runname
1650: 20 73 74 61 74 65 20 73 74 61 74 75 73 20 75 73   state status us
1660: 65 72 29 20 6b 65 79 76 61 6c 73 29 29 0a 09 20  er) keyvals)).. 
1670: 28 71 72 79 76 61 6c 73 20 20 20 28 61 70 70 65  (qryvals   (appe
1680: 6e 64 20 28 6c 69 73 74 20 72 75 6e 6e 61 6d 65  nd (list runname
1690: 29 20 6b 65 79 76 61 6c 73 29 29 0a 09 20 28 6b  ) keyvals)).. (k
16a0: 65 79 3d 3f 73 74 72 20 20 28 73 74 72 69 6e 67  ey=?str  (string
16b0: 2d 69 6e 74 65 72 73 70 65 72 73 65 20 28 6d 61  -intersperse (ma
16c0: 70 20 28 6c 61 6d 62 64 61 20 28 6b 29 28 63 6f  p (lambda (k)(co
16d0: 6e 63 20 28 6b 65 79 3a 67 65 74 2d 66 69 65 6c  nc (key:get-fiel
16e0: 64 6e 61 6d 65 20 6b 29 20 22 3d 3f 22 29 29 20  dname k) "=?")) 
16f0: 6b 65 79 73 29 20 22 20 41 4e 44 20 22 29 29 29  keys) " AND ")))
1700: 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e  .    (debug:prin
1710: 74 20 33 20 22 6b 65 79 73 3a 20 22 20 6b 65 79  t 3 "keys: " key
1720: 73 20 22 20 61 6c 6c 76 61 6c 73 3a 20 22 20 61  s " allvals: " a
1730: 6c 6c 76 61 6c 73 20 22 20 6b 65 79 76 61 6c 73  llvals " keyvals
1740: 3a 20 22 20 6b 65 79 76 61 6c 73 29 0a 20 20 20  : " keyvals).   
1750: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20   (debug:print 2 
1760: 22 4e 4f 54 45 3a 20 75 73 69 6e 67 20 74 61 72  "NOTE: using tar
1770: 67 65 74 20 22 20 28 73 74 72 69 6e 67 2d 69 6e  get " (string-in
1780: 74 65 72 73 70 65 72 73 65 20 6b 65 79 76 61 6c  tersperse keyval
1790: 73 20 22 2f 22 29 20 22 20 66 6f 72 20 74 68 69  s "/") " for thi
17a0: 73 20 72 75 6e 22 29 0a 20 20 20 20 28 69 66 20  s run").    (if 
17b0: 28 61 6e 64 20 72 75 6e 6e 61 6d 65 20 28 6e 75  (and runname (nu
17c0: 6c 6c 3f 20 28 66 69 6c 74 65 72 20 28 6c 61 6d  ll? (filter (lam
17d0: 62 64 61 20 28 78 29 28 6e 6f 74 20 78 29 29 20  bda (x)(not x)) 
17e0: 6b 65 79 76 61 6c 73 29 29 29 20 3b 3b 20 74 68  keyvals))) ;; th
17f0: 65 72 65 20 6d 75 73 74 20 62 65 20 61 20 62 65  ere must be a be
1800: 74 74 65 72 20 77 61 79 20 74 6f 20 22 61 70 70  tter way to "app
1810: 6c 79 20 61 6e 64 22 0a 09 28 6c 65 74 20 28 28  ly and"..(let ((
1820: 72 65 73 20 23 66 29 29 0a 09 20 20 28 61 70 70  res #f))..  (app
1830: 6c 79 20 73 71 6c 69 74 65 33 3a 65 78 65 63 75  ly sqlite3:execu
1840: 74 65 20 64 62 20 28 63 6f 6e 63 20 22 49 4e 53  te db (conc "INS
1850: 45 52 54 20 4f 52 20 49 47 4e 4f 52 45 20 49 4e  ERT OR IGNORE IN
1860: 54 4f 20 72 75 6e 73 20 28 72 75 6e 6e 61 6d 65  TO runs (runname
1870: 2c 73 74 61 74 65 2c 73 74 61 74 75 73 2c 6f 77  ,state,status,ow
1880: 6e 65 72 2c 65 76 65 6e 74 5f 74 69 6d 65 22 20  ner,event_time" 
1890: 63 6f 6d 6d 61 20 6b 65 79 73 74 72 20 22 29 20  comma keystr ") 
18a0: 56 41 4c 55 45 53 20 28 3f 2c 3f 2c 3f 2c 3f 2c  VALUES (?,?,?,?,
18b0: 73 74 72 66 74 69 6d 65 28 27 25 73 27 2c 27 6e  strftime('%s','n
18c0: 6f 77 27 29 22 20 63 6f 6d 6d 61 20 76 61 6c 73  ow')" comma vals
18d0: 6c 6f 74 73 20 22 29 3b 22 29 0a 09 09 20 61 6c  lots ");")... al
18e0: 6c 76 61 6c 73 29 0a 09 20 20 28 61 70 70 6c 79  lvals)..  (apply
18f0: 20 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63   sqlite3:for-eac
1900: 68 2d 72 6f 77 20 0a 09 20 20 20 28 6c 61 6d 62  h-row ..   (lamb
1910: 64 61 20 28 69 64 29 0a 09 20 20 20 20 20 28 73  da (id)..     (s
1920: 65 74 21 20 72 65 73 20 69 64 29 29 0a 09 20 20  et! res id))..  
1930: 20 64 62 0a 09 20 20 20 28 6c 65 74 20 28 28 71   db..   (let ((q
1940: 72 79 20 28 63 6f 6e 63 20 22 53 45 4c 45 43 54  ry (conc "SELECT
1950: 20 69 64 20 46 52 4f 4d 20 72 75 6e 73 20 57 48   id FROM runs WH
1960: 45 52 45 20 28 72 75 6e 6e 61 6d 65 3d 3f 20 22  ERE (runname=? "
1970: 20 61 6e 64 73 74 72 20 6b 65 79 3d 3f 73 74 72   andstr key=?str
1980: 20 22 29 3b 22 29 29 29 0a 09 20 20 20 20 20 3b   ");")))..     ;
1990: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22  (debug:print 4 "
19a0: 71 72 79 3a 20 22 20 71 72 79 29 20 0a 09 20 20  qry: " qry) ..  
19b0: 20 20 20 71 72 79 29 0a 09 20 20 20 71 72 79 76     qry)..   qryv
19c0: 61 6c 73 29 0a 09 20 20 28 73 71 6c 69 74 65 33  als)..  (sqlite3
19d0: 3a 65 78 65 63 75 74 65 20 64 62 20 22 55 50 44  :execute db "UPD
19e0: 41 54 45 20 72 75 6e 73 20 53 45 54 20 73 74 61  ATE runs SET sta
19f0: 74 65 3d 3f 2c 73 74 61 74 75 73 3d 3f 20 57 48  te=?,status=? WH
1a00: 45 52 45 20 69 64 3d 3f 3b 22 20 73 74 61 74 65  ERE id=?;" state
1a10: 20 73 74 61 74 75 73 20 72 65 73 29 0a 09 20 20   status res)..  
1a20: 72 65 73 29 20 0a 09 28 62 65 67 69 6e 0a 09 20  res) ..(begin.. 
1a30: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
1a40: 22 45 52 52 4f 52 3a 20 43 61 6c 6c 65 64 20 77  "ERROR: Called w
1a50: 69 74 68 6f 75 74 20 61 6c 6c 20 6e 65 63 65 73  ithout all neces
1a60: 73 61 72 79 20 6b 65 79 73 22 29 0a 09 20 20 23  sary keys")..  #
1a70: 66 29 29 29 29 0a 0a 3b 3b 20 54 68 69 73 20 69  f))))..;; This i
1a80: 73 20 61 20 64 75 70 6c 69 63 61 74 65 20 6f 66  s a duplicate of
1a90: 20 72 75 6e 2d 74 65 73 74 73 20 28 77 68 69 63   run-tests (whic
1aa0: 68 20 68 61 73 20 62 65 65 6e 20 64 65 70 72 65  h has been depre
1ab0: 63 61 74 65 64 29 2e 20 55 73 65 20 74 68 69 73  cated). Use this
1ac0: 20 6f 6e 65 20 69 6e 73 74 65 61 64 20 6f 66 20   one instead of 
1ad0: 72 75 6e 20 74 65 73 74 73 2e 0a 3b 3b 20 6b 65  run tests..;; ke
1ae0: 79 76 61 6c 73 0a 28 64 65 66 69 6e 65 20 28 72  yvals.(define (r
1af0: 75 6e 73 3a 72 75 6e 2d 74 65 73 74 73 20 64 62  uns:run-tests db
1b00: 20 74 61 72 67 65 74 20 72 75 6e 6e 61 6d 65 20   target runname 
1b10: 74 65 73 74 2d 70 61 74 74 73 20 69 74 65 6d 2d  test-patts item-
1b20: 70 61 74 74 73 20 75 73 65 72 20 66 6c 61 67 73  patts user flags
1b30: 29 0a 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 73  ).  (let* ((keys
1b40: 20 20 20 20 20 20 20 20 28 64 62 2d 67 65 74 2d          (db-get-
1b50: 6b 65 79 73 20 64 62 29 29 0a 09 20 28 6b 65 79  keys db)).. (key
1b60: 76 61 6c 6c 73 74 20 20 20 28 6b 65 79 73 3a 74  vallst   (keys:t
1b70: 61 72 67 65 74 2d 3e 6b 65 79 76 61 6c 20 6b 65  arget->keyval ke
1b80: 79 73 20 74 61 72 67 65 74 29 29 0a 09 20 28 72  ys target)).. (r
1b90: 75 6e 2d 69 64 20 20 20 20 20 20 28 72 75 6e 73  un-id      (runs
1ba0: 3a 72 65 67 69 73 74 65 72 2d 72 75 6e 20 64 62  :register-run db
1bb0: 20 6b 65 79 73 20 6b 65 79 76 61 6c 6c 73 74 20   keys keyvallst 
1bc0: 72 75 6e 6e 61 6d 65 20 22 6e 65 77 22 20 22 6e  runname "new" "n
1bd0: 2f 61 22 20 75 73 65 72 29 29 20 20 3b 3b 20 20  /a" user))  ;;  
1be0: 74 65 73 74 2d 6e 61 6d 65 29 29 29 0a 09 20 28  test-name))).. (
1bf0: 64 65 66 65 72 72 65 64 20 20 20 20 27 28 29 29  deferred    '())
1c00: 20 3b 3b 20 64 65 6c 61 79 20 72 75 6e 6e 69 6e   ;; delay runnin
1c10: 67 20 74 68 65 73 65 20 73 69 6e 63 65 20 74 68  g these since th
1c20: 65 79 20 68 61 76 65 20 61 20 77 61 69 74 6f 6e  ey have a waiton
1c30: 20 63 6c 61 75 73 65 0a 09 20 3b 3b 20 6b 65 65   clause.. ;; kee
1c40: 70 67 6f 69 6e 67 20 69 73 20 74 68 65 20 64 65  pgoing is the de
1c50: 66 61 63 74 6f 20 6d 6f 64 61 6c 69 74 79 20 6e  facto modality n
1c60: 6f 77 2c 20 77 69 6c 6c 20 61 64 64 20 68 69 74  ow, will add hit
1c70: 2d 6e 2d 72 75 6e 20 61 20 62 69 74 20 6c 61 74  -n-run a bit lat
1c80: 65 72 0a 09 20 3b 3b 20 28 6b 65 65 70 67 6f 69  er.. ;; (keepgoi
1c90: 6e 67 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65  ng   (hash-table
1ca0: 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 66 6c 61  -ref/default fla
1cb0: 67 73 20 22 2d 6b 65 65 70 67 6f 69 6e 67 22 20  gs "-keepgoing" 
1cc0: 23 66 29 29 0a 09 20 28 74 65 73 74 2d 6e 61 6d  #f)).. (test-nam
1cd0: 65 73 20 20 27 28 29 29 0a 09 20 28 72 75 6e 63  es  '()).. (runc
1ce0: 6f 6e 66 69 67 66 20 20 20 28 63 6f 6e 63 20 20  onfigf   (conc  
1cf0: 2a 74 6f 70 70 61 74 68 2a 20 22 2f 72 75 6e 63  *toppath* "/runc
1d00: 6f 6e 66 69 67 73 2e 63 6f 6e 66 69 67 22 29 29  onfigs.config"))
1d10: 0a 09 20 28 72 65 71 75 69 72 65 64 2d 74 65 73  .. (required-tes
1d20: 74 73 20 27 28 29 29 0a 09 20 28 74 65 73 74 2d  ts '()).. (test-
1d30: 72 65 63 6f 72 64 73 20 28 6d 61 6b 65 2d 68 61  records (make-ha
1d40: 73 68 2d 74 61 62 6c 65 29 29 29 0a 0a 20 20 20  sh-table)))..   
1d50: 20 28 73 65 74 2d 6d 65 67 61 74 65 73 74 2d 65   (set-megatest-e
1d60: 6e 76 2d 76 61 72 73 20 64 62 20 72 75 6e 2d 69  nv-vars db run-i
1d70: 64 29 20 3b 3b 20 74 68 65 73 65 20 6d 61 79 20  d) ;; these may 
1d80: 62 65 20 6e 65 65 64 65 64 20 62 79 20 74 68 65  be needed by the
1d90: 20 6c 61 75 6e 63 68 69 6e 67 20 70 72 6f 63 65   launching proce
1da0: 73 73 0a 0a 20 20 20 20 28 69 66 20 28 66 69 6c  ss..    (if (fil
1db0: 65 2d 65 78 69 73 74 73 3f 20 72 75 6e 63 6f 6e  e-exists? runcon
1dc0: 66 69 67 66 29 0a 09 28 73 65 74 75 70 2d 65 6e  figf)..(setup-en
1dd0: 76 2d 64 65 66 61 75 6c 74 73 20 64 62 20 72 75  v-defaults db ru
1de0: 6e 63 6f 6e 66 69 67 66 20 72 75 6e 2d 69 64 20  nconfigf run-id 
1df0: 2a 61 6c 72 65 61 64 79 2d 73 65 65 6e 2d 72 75  *already-seen-ru
1e00: 6e 63 6f 6e 66 69 67 2d 69 6e 66 6f 2a 20 22 70  nconfig-info* "p
1e10: 72 65 2d 6c 61 75 6e 63 68 2d 65 6e 76 2d 76 61  re-launch-env-va
1e20: 72 73 22 29 0a 09 28 64 65 62 75 67 3a 70 72 69  rs")..(debug:pri
1e30: 6e 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 59  nt 0 "WARNING: Y
1e40: 6f 75 20 64 6f 20 6e 6f 74 20 68 61 76 65 20 61  ou do not have a
1e50: 20 72 75 6e 20 63 6f 6e 66 69 67 20 66 69 6c 65   run config file
1e60: 3a 20 22 20 72 75 6e 63 6f 6e 66 69 67 66 29 29  : " runconfigf))
1e70: 0a 20 20 20 20 0a 20 20 20 20 3b 3b 20 6c 6f 6f  .    .    ;; loo
1e80: 6b 20 75 70 20 61 6c 6c 20 74 65 73 74 73 20 6d  k up all tests m
1e90: 61 74 63 68 69 6e 67 20 74 68 65 20 63 6f 6d 6d  atching the comm
1ea0: 61 20 73 65 70 61 72 61 74 65 64 20 6c 69 73 74  a separated list
1eb0: 20 6f 66 20 67 6c 6f 62 73 20 69 6e 0a 20 20 20   of globs in.   
1ec0: 20 3b 3b 20 74 65 73 74 2d 70 61 74 74 73 20 28   ;; test-patts (
1ed0: 75 73 69 6e 67 20 25 20 61 73 20 77 69 6c 64 63  using % as wildc
1ee0: 61 72 64 29 0a 20 20 20 20 28 66 6f 72 2d 65 61  ard).    (for-ea
1ef0: 63 68 20 0a 20 20 20 20 20 28 6c 61 6d 62 64 61  ch .     (lambda
1f00: 20 28 70 61 74 74 29 0a 20 20 20 20 20 20 20 28   (patt).       (
1f10: 6c 65 74 20 28 28 74 65 73 74 73 20 28 67 6c 6f  let ((tests (glo
1f20: 62 20 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74 68  b (conc *toppath
1f30: 2a 20 22 2f 74 65 73 74 73 2f 22 20 28 73 74 72  * "/tests/" (str
1f40: 69 6e 67 2d 74 72 61 6e 73 6c 61 74 65 20 70 61  ing-translate pa
1f50: 74 74 20 22 25 22 20 22 2a 22 29 29 29 29 29 0a  tt "%" "*"))))).
1f60: 09 20 28 73 65 74 21 20 74 65 73 74 73 20 28 66  . (set! tests (f
1f70: 69 6c 74 65 72 20 28 6c 61 6d 62 64 61 20 28 74  ilter (lambda (t
1f80: 65 73 74 29 28 66 69 6c 65 2d 65 78 69 73 74 73  est)(file-exists
1f90: 3f 20 28 63 6f 6e 63 20 74 65 73 74 20 22 2f 74  ? (conc test "/t
1fa0: 65 73 74 63 6f 6e 66 69 67 22 29 29 29 20 74 65  estconfig"))) te
1fb0: 73 74 73 29 29 0a 09 20 28 73 65 74 21 20 74 65  sts)).. (set! te
1fc0: 73 74 2d 6e 61 6d 65 73 20 28 61 70 70 65 6e 64  st-names (append
1fd0: 20 74 65 73 74 2d 6e 61 6d 65 73 20 0a 09 09 09   test-names ....
1fe0: 09 20 20 28 6d 61 70 20 28 6c 61 6d 62 64 61 20  .  (map (lambda 
1ff0: 28 74 65 73 74 70 29 0a 09 09 09 09 09 20 28 6c  (testp)...... (l
2000: 61 73 74 20 28 73 74 72 69 6e 67 2d 73 70 6c 69  ast (string-spli
2010: 74 20 74 65 73 74 70 20 22 2f 22 29 29 29 0a 09  t testp "/")))..
2020: 09 09 09 20 20 20 20 20 20 20 74 65 73 74 73 29  ...       tests)
2030: 29 29 29 29 0a 20 20 20 20 20 28 69 66 20 74 65  )))).     (if te
2040: 73 74 2d 70 61 74 74 73 20 28 73 74 72 69 6e 67  st-patts (string
2050: 2d 73 70 6c 69 74 20 74 65 73 74 2d 70 61 74 74  -split test-patt
2060: 73 20 22 2c 22 29 28 6c 69 73 74 20 22 25 22 29  s ",")(list "%")
2070: 29 29 0a 0a 20 20 20 20 20 3b 3b 20 6e 6f 77 20  ))..     ;; now 
2080: 72 65 6d 6f 76 65 20 64 75 70 6c 69 63 61 74 65  remove duplicate
2090: 73 0a 20 20 20 20 28 73 65 74 21 20 74 65 73 74  s.    (set! test
20a0: 2d 6e 61 6d 65 73 20 28 64 65 6c 65 74 65 2d 64  -names (delete-d
20b0: 75 70 6c 69 63 61 74 65 73 20 74 65 73 74 2d 6e  uplicates test-n
20c0: 61 6d 65 73 29 29 0a 0a 20 20 20 20 28 64 65 62  ames))..    (deb
20d0: 75 67 3a 70 72 69 6e 74 20 30 20 22 49 4e 46 4f  ug:print 0 "INFO
20e0: 3a 20 74 65 73 74 20 6e 61 6d 65 73 20 22 20 74  : test names " t
20f0: 65 73 74 2d 6e 61 6d 65 73 29 0a 0a 20 20 20 20  est-names)..    
2100: 3b 3b 20 6f 6e 20 74 68 65 20 66 69 72 73 74 20  ;; on the first 
2110: 70 61 73 73 20 6f 72 20 63 61 6c 6c 20 74 6f 20  pass or call to 
2120: 72 75 6e 2d 74 65 73 74 73 20 73 65 74 20 46 41  run-tests set FA
2130: 49 4c 53 20 74 6f 20 4e 4f 54 5f 53 54 41 52 54  ILS to NOT_START
2140: 45 44 20 69 66 0a 20 20 20 20 3b 3b 20 2d 6b 65  ED if.    ;; -ke
2150: 65 70 67 6f 69 6e 67 20 69 73 20 73 70 65 63 69  epgoing is speci
2160: 66 69 65 64 0a 20 20 20 20 28 69 66 20 28 65 71  fied.    (if (eq
2170: 3f 20 2a 70 61 73 73 6e 75 6d 2a 20 30 29 0a 09  ? *passnum* 0)..
2180: 28 62 65 67 69 6e 0a 09 20 20 3b 3b 20 68 61 76  (begin..  ;; hav
2190: 65 20 74 6f 20 64 65 6c 65 74 65 20 74 65 73 74  e to delete test
21a0: 20 72 65 63 6f 72 64 73 20 77 68 65 72 65 20 4e   records where N
21b0: 4f 54 5f 53 54 41 52 54 45 44 20 73 69 6e 63 65  OT_STARTED since
21c0: 20 74 68 65 79 20 63 61 6e 20 63 61 75 73 65 20   they can cause 
21d0: 2d 6b 65 65 70 67 6f 69 6e 67 20 74 6f 20 0a 09  -keepgoing to ..
21e0: 20 20 3b 3b 20 67 65 74 20 73 74 75 63 6b 20 64    ;; get stuck d
21f0: 75 65 20 74 6f 20 62 65 63 6f 6d 69 6e 67 20 69  ue to becoming i
2200: 6e 61 63 63 65 73 73 69 62 6c 65 20 66 72 6f 6d  naccessible from
2210: 20 61 20 66 61 69 6c 65 64 20 74 65 73 74 2e 20   a failed test. 
2220: 49 2e 65 2e 20 69 66 20 74 65 73 74 20 42 20 64  I.e. if test B d
2230: 65 70 65 6e 64 73 20 0a 09 20 20 3b 3b 20 6f 6e  epends ..  ;; on
2240: 20 74 65 73 74 20 41 20 62 75 74 20 74 65 73 74   test A but test
2250: 20 42 20 72 65 61 63 68 65 64 20 74 68 65 20 70   B reached the p
2260: 6f 69 6e 74 20 6f 6e 20 62 65 69 6e 67 20 72 65  oint on being re
2270: 67 69 73 74 65 72 65 64 20 61 73 20 4e 4f 54 5f  gistered as NOT_
2280: 53 54 41 52 54 45 44 20 61 6e 64 20 74 65 73 74  STARTED and test
2290: 0a 09 20 20 3b 3b 20 41 20 66 61 69 6c 65 64 20  ..  ;; A failed 
22a0: 66 6f 72 20 73 6f 6d 65 20 72 65 61 73 6f 6e 20  for some reason 
22b0: 74 68 65 6e 20 6f 6e 20 72 65 2d 72 75 6e 20 75  then on re-run u
22c0: 73 69 6e 67 20 2d 6b 65 65 70 67 6f 69 6e 67 20  sing -keepgoing 
22d0: 74 68 65 20 72 75 6e 20 63 61 6e 20 6e 65 76 65  the run can neve
22e0: 72 20 63 6f 6d 70 6c 65 74 65 2e 0a 09 20 20 28  r complete...  (
22f0: 64 62 3a 64 65 6c 65 74 65 2d 74 65 73 74 73 2d  db:delete-tests-
2300: 69 6e 2d 73 74 61 74 65 20 64 62 20 72 75 6e 2d  in-state db run-
2310: 69 64 20 22 4e 4f 54 5f 53 54 41 52 54 45 44 22  id "NOT_STARTED"
2320: 29 0a 09 20 20 28 64 62 3a 73 65 74 2d 74 65 73  )..  (db:set-tes
2330: 74 73 2d 73 74 61 74 65 2d 73 74 61 74 75 73 20  ts-state-status 
2340: 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e  db run-id test-n
2350: 61 6d 65 73 20 23 66 20 22 46 41 49 4c 22 20 22  ames #f "FAIL" "
2360: 4e 4f 54 5f 53 54 41 52 54 45 44 22 20 22 46 41  NOT_STARTED" "FA
2370: 49 4c 22 29 29 29 0a 0a 20 20 20 20 3b 3b 20 6e  IL")))..    ;; n
2380: 6f 77 20 61 64 64 20 6e 6f 6e 2d 64 69 72 65 63  ow add non-direc
2390: 74 6c 79 20 72 65 66 65 72 65 6e 63 65 64 20 64  tly referenced d
23a0: 65 70 65 6e 64 65 6e 63 69 65 73 20 28 69 2e 65  ependencies (i.e
23b0: 2e 20 77 61 69 74 6f 6e 29 0a 20 20 20 20 28 69  . waiton).    (i
23c0: 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 65  f (not (null? te
23d0: 73 74 2d 6e 61 6d 65 73 29 29 0a 09 28 6c 65 74  st-names))..(let
23e0: 20 6c 6f 6f 70 20 28 28 68 65 64 20 28 63 61 72   loop ((hed (car
23f0: 20 74 65 73 74 2d 6e 61 6d 65 73 29 29 0a 09 09   test-names))...
2400: 20 20 20 28 74 61 6c 20 28 63 64 72 20 74 65 73     (tal (cdr tes
2410: 74 2d 6e 61 6d 65 73 29 29 29 20 20 20 20 20 20  t-names)))      
2420: 20 20 20 3b 3b 20 27 72 65 74 75 72 6e 2d 70 72     ;; 'return-pr
2430: 6f 63 73 20 74 65 6c 6c 73 20 74 68 65 20 63 6f  ocs tells the co
2440: 6e 66 69 67 20 72 65 61 64 65 72 20 74 6f 20 70  nfig reader to p
2450: 72 65 70 20 72 75 6e 6e 69 6e 67 20 73 79 73 74  rep running syst
2460: 65 6d 20 62 75 74 20 72 65 74 75 72 6e 20 61 20  em but return a 
2470: 70 72 6f 63 0a 09 20 20 28 6c 65 74 2a 20 28 28  proc..  (let* ((
2480: 63 6f 6e 66 69 67 20 20 28 74 65 73 74 3a 67 65  config  (test:ge
2490: 74 2d 74 65 73 74 63 6f 6e 66 69 67 20 68 65 64  t-testconfig hed
24a0: 20 27 72 65 74 75 72 6e 2d 70 72 6f 63 73 29 29   'return-procs))
24b0: 0a 09 09 20 28 77 61 69 74 6f 6e 73 20 28 73 74  ... (waitons (st
24c0: 72 69 6e 67 2d 73 70 6c 69 74 20 28 6c 65 74 20  ring-split (let 
24d0: 28 28 77 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b  ((w (config-look
24e0: 75 70 20 63 6f 6e 66 69 67 20 22 72 65 71 75 69  up config "requi
24f0: 72 65 6d 65 6e 74 73 22 20 22 77 61 69 74 6f 6e  rements" "waiton
2500: 22 29 29 29 0a 09 09 09 09 09 20 20 28 69 66 20  ")))......  (if 
2510: 77 20 77 20 22 22 29 29 29 29 29 0a 09 20 20 20  w w "")))))..   
2520: 20 3b 3b 20 28 69 74 65 6d 73 20 20 20 28 69 74   ;; (items   (it
2530: 65 6d 73 3a 67 65 74 2d 69 74 65 6d 73 2d 66 72  ems:get-items-fr
2540: 6f 6d 2d 63 6f 6e 66 69 67 20 63 6f 6e 66 69 67  om-config config
2550: 29 29 29 0a 09 20 20 20 20 28 69 66 20 28 6e 6f  )))..    (if (no
2560: 74 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65  t (hash-table-re
2570: 66 2f 64 65 66 61 75 6c 74 20 74 65 73 74 2d 72  f/default test-r
2580: 65 63 6f 72 64 73 20 68 65 64 20 23 66 29 29 0a  ecords hed #f)).
2590: 09 09 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65  ..(hash-table-se
25a0: 74 21 20 74 65 73 74 2d 72 65 63 6f 72 64 73 0a  t! test-records.
25b0: 09 09 09 09 20 68 65 64 20 28 76 65 63 74 6f 72  .... hed (vector
25c0: 20 68 65 64 20 20 20 20 20 3b 3b 20 30 0a 09 09   hed     ;; 0...
25d0: 09 09 09 20 20 20 20 20 63 6f 6e 66 69 67 20 20  ...     config  
25e0: 3b 3b 20 31 0a 09 09 09 09 09 20 20 20 20 20 77  ;; 1......     w
25f0: 61 69 74 6f 6e 73 20 3b 3b 20 32 0a 09 09 09 09  aitons ;; 2.....
2600: 09 20 20 20 20 20 28 63 6f 6e 66 69 67 2d 6c 6f  .     (config-lo
2610: 6f 6b 75 70 20 63 6f 6e 66 69 67 20 22 72 65 71  okup config "req
2620: 75 69 72 65 6d 65 6e 74 73 22 20 22 70 72 69 6f  uirements" "prio
2630: 72 69 74 79 22 29 20 20 20 20 20 3b 3b 20 70 72  rity")     ;; pr
2640: 69 6f 72 69 74 79 20 33 0a 09 09 09 09 09 20 20  iority 3......  
2650: 20 20 20 28 6c 65 74 20 28 28 69 74 65 6d 73 20     (let ((items 
2660: 20 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65       (hash-table
2670: 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 63 6f 6e  -ref/default con
2680: 66 69 67 20 22 69 74 65 6d 73 22 20 23 66 29 29  fig "items" #f))
2690: 20 3b 3b 20 69 74 65 6d 73 20 34 0a 09 09 09 09   ;; items 4.....
26a0: 09 09 20 20 20 28 69 74 65 6d 73 74 61 62 6c 65  ..   (itemstable
26b0: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
26c0: 2f 64 65 66 61 75 6c 74 20 63 6f 6e 66 69 67 20  /default config 
26d0: 22 69 74 65 6d 73 74 61 62 6c 65 22 20 23 66 29  "itemstable" #f)
26e0: 29 29 20 0a 09 09 09 09 09 20 20 20 20 20 20 20  )) ......       
26f0: 3b 3b 20 69 66 20 65 69 74 68 65 72 20 69 74 65  ;; if either ite
2700: 6d 73 20 6f 72 20 69 74 65 6d 73 20 74 61 62 6c  ms or items tabl
2710: 65 20 69 73 20 61 20 70 72 6f 63 20 72 65 74 75  e is a proc retu
2720: 72 6e 20 69 74 20 73 6f 20 74 65 73 74 20 72 75  rn it so test ru
2730: 6e 6e 69 6e 67 0a 09 09 09 09 09 20 20 20 20 20  nning......     
2740: 20 20 3b 3b 20 70 72 6f 63 65 73 73 20 63 61 6e    ;; process can
2750: 20 6b 6e 6f 77 20 74 6f 20 63 61 6c 6c 20 69 74   know to call it
2760: 65 6d 73 3a 67 65 74 2d 69 74 65 6d 73 2d 66 72  ems:get-items-fr
2770: 6f 6d 2d 63 6f 6e 66 69 67 0a 09 09 09 09 09 20  om-config...... 
2780: 20 20 20 20 20 20 3b 3b 20 69 66 20 65 69 74 68        ;; if eith
2790: 65 72 20 69 73 20 61 20 6c 69 73 74 20 61 6e 64  er is a list and
27a0: 20 6e 6f 6e 65 20 69 73 20 61 20 70 72 6f 63 20   none is a proc 
27b0: 67 6f 20 61 68 65 61 64 20 61 6e 64 20 63 61 6c  go ahead and cal
27c0: 6c 20 67 65 74 2d 69 74 65 6d 73 0a 09 09 09 09  l get-items.....
27d0: 09 20 20 20 20 20 20 20 3b 3b 20 6f 74 68 65 72  .       ;; other
27e0: 77 69 73 65 20 72 65 74 75 72 6e 20 23 66 20 2d  wise return #f -
27f0: 20 74 68 69 73 20 69 73 20 6e 6f 74 20 61 6e 20   this is not an 
2800: 69 74 65 72 61 74 65 64 20 74 65 73 74 0a 09 09  iterated test...
2810: 09 09 09 20 20 20 20 20 20 20 28 63 6f 6e 64 0a  ...       (cond.
2820: 09 09 09 09 09 09 28 28 70 72 6f 63 65 64 75 72  ......((procedur
2830: 65 3f 20 69 74 65 6d 73 29 20 20 20 20 20 20 69  e? items)      i
2840: 74 65 6d 73 29 20 20 20 20 20 20 20 20 20 20 20  tems)           
2850: 20 3b 3b 20 63 61 6c 63 20 6c 61 74 65 72 0a 09   ;; calc later..
2860: 09 09 09 09 09 28 28 70 72 6f 63 65 64 75 72 65  .....((procedure
2870: 3f 20 69 74 65 6d 73 74 61 62 6c 65 29 20 69 74  ? itemstable) it
2880: 65 6d 73 74 61 62 6c 65 29 20 20 20 20 20 20 20  emstable)       
2890: 3b 3b 20 63 61 6c 63 20 6c 61 74 65 72 0a 09 09  ;; calc later...
28a0: 09 09 09 09 28 28 6f 72 20 28 6c 69 73 74 3f 20  ....((or (list? 
28b0: 69 74 65 6d 73 29 28 6c 69 73 74 3f 20 69 74 65  items)(list? ite
28c0: 6d 73 74 61 62 6c 65 29 29 20 3b 3b 20 63 61 6c  mstable)) ;; cal
28d0: 63 20 6e 6f 77 0a 09 09 09 09 09 09 20 28 69 74  c now....... (it
28e0: 65 6d 73 3a 67 65 74 2d 69 74 65 6d 73 2d 66 72  ems:get-items-fr
28f0: 6f 6d 2d 63 6f 6e 66 69 67 20 63 6f 6e 66 69 67  om-config config
2900: 29 29 0a 09 09 09 09 09 09 28 65 6c 73 65 20 23  )).......(else #
2910: 66 29 29 29 20 20 20 20 20 20 20 20 20 20 20 20  f)))            
2920: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b                 ;
2930: 3b 20 6e 6f 74 20 69 74 65 72 61 74 65 64 0a 09  ; not iterated..
2940: 09 09 09 09 20 20 20 20 20 23 66 20 20 20 20 20  ....     #f     
2950: 20 3b 3b 20 69 74 65 6d 73 64 61 74 20 35 0a 09   ;; itemsdat 5..
2960: 09 09 09 09 20 20 20 20 20 3b 3b 20 23 66 20 20  ....     ;; #f  
2970: 20 20 20 20 3b 3b 20 73 70 61 72 65 0a 09 09 09      ;; spare....
2980: 09 09 20 20 20 20 20 29 29 29 0a 09 20 20 20 20  ..     )))..    
2990: 28 66 6f 72 2d 65 61 63 68 20 0a 09 20 20 20 20  (for-each ..    
29a0: 20 28 6c 61 6d 62 64 61 20 28 77 61 69 74 6f 6e   (lambda (waiton
29b0: 29 0a 09 20 20 20 20 20 20 20 28 69 66 20 28 61  )..       (if (a
29c0: 6e 64 20 77 61 69 74 6f 6e 20 28 6e 6f 74 20 28  nd waiton (not (
29d0: 6d 65 6d 62 65 72 20 77 61 69 74 6f 6e 20 74 65  member waiton te
29e0: 73 74 2d 6e 61 6d 65 73 29 29 29 0a 09 09 20 20  st-names)))...  
29f0: 20 28 62 65 67 69 6e 0a 09 09 20 20 20 20 20 28   (begin...     (
2a00: 73 65 74 21 20 72 65 71 75 69 72 65 64 2d 74 65  set! required-te
2a10: 73 74 73 20 28 63 6f 6e 73 20 77 61 69 74 6f 6e  sts (cons waiton
2a20: 20 72 65 71 75 69 72 65 64 2d 74 65 73 74 73 29   required-tests)
2a30: 29 0a 09 09 20 20 20 20 20 28 73 65 74 21 20 74  )...     (set! t
2a40: 65 73 74 2d 6e 61 6d 65 73 20 28 61 70 70 65 6e  est-names (appen
2a50: 64 20 74 65 73 74 2d 6e 61 6d 65 73 20 28 6c 69  d test-names (li
2a60: 73 74 20 77 61 69 74 6f 6e 29 29 29 29 29 29 0a  st waiton)))))).
2a70: 09 20 20 20 20 20 77 61 69 74 6f 6e 73 29 0a 09  .     waitons)..
2a80: 20 20 20 20 28 6c 65 74 20 28 28 72 65 6d 74 65      (let ((remte
2a90: 73 74 73 20 28 64 65 6c 65 74 65 2d 64 75 70 6c  sts (delete-dupl
2aa0: 69 63 61 74 65 73 20 28 61 70 70 65 6e 64 20 77  icates (append w
2ab0: 61 69 74 6f 6e 73 20 74 61 6c 29 29 29 29 0a 09  aitons tal))))..
2ac0: 20 20 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28        (if (not (
2ad0: 6e 75 6c 6c 3f 20 72 65 6d 74 65 73 74 73 29 29  null? remtests))
2ae0: 0a 09 09 20 20 28 6c 6f 6f 70 20 28 63 61 72 20  ...  (loop (car 
2af0: 72 65 6d 74 65 73 74 73 29 28 63 64 72 20 72 65  remtests)(cdr re
2b00: 6d 74 65 73 74 73 29 29 29 29 29 29 29 0a 0a 20  mtests))))))).. 
2b10: 20 20 20 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c     (if (not (nul
2b20: 6c 3f 20 72 65 71 75 69 72 65 64 2d 74 65 73 74  l? required-test
2b30: 73 29 29 0a 09 28 64 65 62 75 67 3a 70 72 69 6e  s))..(debug:prin
2b40: 74 20 31 20 22 49 4e 46 4f 3a 20 41 64 64 69 6e  t 1 "INFO: Addin
2b50: 67 20 22 20 72 65 71 75 69 72 65 64 2d 74 65 73  g " required-tes
2b60: 74 73 20 22 20 74 6f 20 74 68 65 20 72 75 6e 20  ts " to the run 
2b70: 71 75 65 75 65 22 29 29 0a 20 20 20 20 3b 3b 20  queue")).    ;; 
2b80: 4e 4f 54 45 3a 20 74 68 65 73 65 20 61 72 65 20  NOTE: these are 
2b90: 61 6c 6c 20 70 61 72 65 6e 74 20 74 65 73 74 73  all parent tests
2ba0: 2c 20 69 74 65 6d 73 20 61 72 65 20 6e 6f 74 20  , items are not 
2bb0: 65 78 70 61 6e 64 65 64 20 79 65 74 2e 0a 20 20  expanded yet..  
2bc0: 20 20 28 72 75 6e 73 3a 72 75 6e 2d 74 65 73 74    (runs:run-test
2bd0: 73 2d 71 75 65 75 65 20 64 62 20 72 75 6e 2d 69  s-queue db run-i
2be0: 64 20 72 75 6e 6e 61 6d 65 20 74 65 73 74 2d 72  d runname test-r
2bf0: 65 63 6f 72 64 73 20 6b 65 79 76 61 6c 6c 73 74  ecords keyvallst
2c00: 20 66 6c 61 67 73 29 29 29 0a 0a 28 64 65 66 69   flags)))..(defi
2c10: 6e 65 20 28 72 75 6e 73 3a 72 75 6e 2d 74 65 73  ne (runs:run-tes
2c20: 74 73 2d 71 75 65 75 65 20 64 62 20 72 75 6e 2d  ts-queue db run-
2c30: 69 64 20 72 75 6e 6e 61 6d 65 20 74 65 73 74 2d  id runname test-
2c40: 72 65 63 6f 72 64 73 20 6b 65 79 76 61 6c 6c 73  records keyvalls
2c50: 74 20 66 6c 61 67 73 29 0a 20 20 20 20 3b 3b 20  t flags).    ;; 
2c60: 41 74 20 74 68 69 73 20 70 6f 69 6e 74 20 74 68  At this point th
2c70: 65 20 6c 69 73 74 20 6f 66 20 70 61 72 65 6e 74  e list of parent
2c80: 20 74 65 73 74 73 20 69 73 20 65 78 70 61 6e 64   tests is expand
2c90: 65 64 20 0a 20 20 20 20 3b 3b 20 4e 42 2f 2f 20  ed .    ;; NB// 
2ca0: 53 68 6f 75 6c 64 20 65 78 70 61 6e 64 20 69 74  Should expand it
2cb0: 65 6d 73 20 68 65 72 65 20 61 6e 64 20 74 68 65  ems here and the
2cc0: 6e 20 69 6e 73 65 72 74 20 69 6e 74 6f 20 74 68  n insert into th
2cd0: 65 20 72 75 6e 20 71 75 65 75 65 2e 0a 20 20 28  e run queue..  (
2ce0: 64 65 62 75 67 3a 70 72 69 6e 74 20 35 20 22 74  debug:print 5 "t
2cf0: 65 73 74 2d 72 65 63 6f 72 64 73 3a 20 22 20 74  est-records: " t
2d00: 65 73 74 2d 72 65 63 6f 72 64 73 20 22 2c 20 6b  est-records ", k
2d10: 65 79 76 61 6c 6c 73 74 3a 20 22 20 6b 65 79 76  eyvallst: " keyv
2d20: 61 6c 6c 73 74 29 0a 20 20 28 6c 65 74 20 28 28  allst).  (let ((
2d30: 73 6f 72 74 65 64 2d 74 65 73 74 2d 6e 61 6d 65  sorted-test-name
2d40: 73 20 28 74 65 73 74 73 3a 73 6f 72 74 2d 62 79  s (tests:sort-by
2d50: 2d 70 72 69 6f 72 69 74 79 2d 61 6e 64 2d 77 61  -priority-and-wa
2d60: 69 74 6f 6e 20 74 65 73 74 2d 72 65 63 6f 72 64  iton test-record
2d70: 73 29 29 0a 09 28 69 74 65 6d 2d 70 61 74 74 73  s))..(item-patts
2d80: 20 20 20 20 20 20 20 20 28 68 61 73 68 2d 74 61          (hash-ta
2d90: 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20  ble-ref/default 
2da0: 66 6c 61 67 73 20 22 2d 69 74 65 6d 70 61 74 74  flags "-itempatt
2db0: 22 20 23 66 29 29 29 0a 20 20 20 20 28 6c 65 74  " #f))).    (let
2dc0: 20 6c 6f 6f 70 20 28 3b 20 28 6e 75 6d 74 69 6d   loop (; (numtim
2dd0: 65 73 20 30 29 20 3b 3b 20 73 68 6f 75 6c 64 6e  es 0) ;; shouldn
2de0: 27 74 20 6e 65 65 64 20 74 68 69 73 0a 09 20 20  't need this..  
2df0: 20 20 20 20 20 28 68 65 64 20 20 20 20 20 20 20       (hed       
2e00: 20 20 28 63 61 72 20 73 6f 72 74 65 64 2d 74 65    (car sorted-te
2e10: 73 74 2d 6e 61 6d 65 73 29 29 0a 09 20 20 20 20  st-names))..    
2e20: 20 20 20 28 74 61 6c 20 20 20 20 20 20 20 20 20     (tal         
2e30: 28 63 64 72 20 73 6f 72 74 65 64 2d 74 65 73 74  (cdr sorted-test
2e40: 2d 6e 61 6d 65 73 29 29 29 0a 20 20 20 20 20 20  -names))).      
2e50: 28 6c 65 74 2a 20 28 28 74 65 73 74 2d 72 65 63  (let* ((test-rec
2e60: 6f 72 64 20 28 68 61 73 68 2d 74 61 62 6c 65 2d  ord (hash-table-
2e70: 72 65 66 20 74 65 73 74 2d 72 65 63 6f 72 64 73  ref test-records
2e80: 20 68 65 64 29 29 0a 09 20 20 20 20 20 28 74 63   hed))..     (tc
2e90: 6f 6e 66 69 67 20 20 20 20 20 28 74 65 73 74 73  onfig     (tests
2ea0: 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d 74  :testqueue-get-t
2eb0: 65 73 74 63 6f 6e 66 69 67 20 74 65 73 74 2d 72  estconfig test-r
2ec0: 65 63 6f 72 64 29 29 0a 09 20 20 20 20 20 28 77  ecord))..     (w
2ed0: 61 69 74 6f 6e 73 20 20 20 20 20 28 74 65 73 74  aitons     (test
2ee0: 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d  s:testqueue-get-
2ef0: 77 61 69 74 6f 6e 73 20 20 20 20 74 65 73 74 2d  waitons    test-
2f00: 72 65 63 6f 72 64 29 29 0a 09 20 20 20 20 20 28  record))..     (
2f10: 70 72 69 6f 72 69 74 79 20 20 20 20 28 74 65 73  priority    (tes
2f20: 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74  ts:testqueue-get
2f30: 2d 70 72 69 6f 72 69 74 79 20 20 20 74 65 73 74  -priority   test
2f40: 2d 72 65 63 6f 72 64 29 29 0a 09 20 20 20 20 20  -record))..     
2f50: 28 69 74 65 6d 64 61 74 20 20 20 20 20 28 74 65  (itemdat     (te
2f60: 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65  sts:testqueue-ge
2f70: 74 2d 69 74 65 6d 64 61 74 20 20 20 20 74 65 73  t-itemdat    tes
2f80: 74 2d 72 65 63 6f 72 64 29 29 0a 09 20 20 20 20  t-record))..    
2f90: 20 28 69 74 65 6d 73 20 20 20 20 20 20 20 28 74   (items       (t
2fa0: 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67  ests:testqueue-g
2fb0: 65 74 2d 69 74 65 6d 73 20 20 20 20 20 20 74 65  et-items      te
2fc0: 73 74 2d 72 65 63 6f 72 64 29 29 0a 09 20 20 20  st-record))..   
2fd0: 20 20 28 69 74 65 6d 2d 70 61 74 68 20 20 20 28    (item-path   (
2fe0: 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20  item-list->path 
2ff0: 69 74 65 6d 64 61 74 29 29 29 0a 09 28 64 65 62  itemdat)))..(deb
3000: 75 67 3a 70 72 69 6e 74 20 36 0a 09 09 20 20 20  ug:print 6...   
3010: 20 20 22 69 74 65 6d 64 61 74 3a 20 20 20 20 20    "itemdat:     
3020: 22 20 69 74 65 6d 64 61 74 0a 09 09 20 20 20 20  " itemdat...    
3030: 20 22 5c 6e 20 20 69 74 65 6d 73 3a 20 20 20 20   "\n  items:    
3040: 20 22 20 69 74 65 6d 73 0a 09 09 20 20 20 20 20   " items...     
3050: 22 5c 6e 20 20 69 74 65 6d 2d 70 61 74 68 3a 20  "\n  item-path: 
3060: 22 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 28 63  " item-path)..(c
3070: 6f 6e 64 0a 09 20 28 28 6e 6f 74 20 69 74 65 6d  ond.. ((not item
3080: 73 29 20 3b 3b 20 77 68 65 6e 20 66 61 6c 73 65  s) ;; when false
3090: 20 74 68 65 20 74 65 73 74 20 69 73 20 6f 6b 20   the test is ok 
30a0: 74 6f 20 62 65 20 68 61 6e 64 65 64 20 6f 66 66  to be handed off
30b0: 20 74 6f 20 6c 61 75 6e 63 68 20 28 62 75 74 20   to launch (but 
30c0: 6e 6f 74 20 62 65 66 6f 72 65 29 0a 09 20 20 28  not before)..  (
30d0: 6c 65 74 20 28 28 68 61 76 65 2d 72 65 73 6f 75  let ((have-resou
30e0: 72 63 65 73 20 20 28 72 75 6e 73 3a 63 61 6e 2d  rces  (runs:can-
30f0: 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64  run-more-tests d
3100: 62 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29 20  b test-record)) 
3110: 3b 3b 20 6c 6f 6f 6b 20 61 74 20 74 68 65 20 74  ;; look at the t
3120: 65 73 74 20 6a 6f 62 67 72 6f 75 70 20 61 6e 64  est jobgroup and
3130: 20 74 6f 74 20 6a 6f 62 73 20 72 75 6e 6e 69 6e   tot jobs runnin
3140: 67 0a 09 09 28 70 72 65 72 65 71 73 2d 6e 6f 74  g...(prereqs-not
3150: 2d 6d 65 74 20 28 64 62 3a 67 65 74 2d 70 72 65  -met (db:get-pre
3160: 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 20 64 62 20  reqs-not-met db 
3170: 72 75 6e 2d 69 64 20 77 61 69 74 6f 6e 73 20 69  run-id waitons i
3180: 74 65 6d 2d 70 61 74 68 29 29 29 0a 09 20 20 20  tem-path)))..   
3190: 20 28 69 66 20 28 61 6e 64 20 68 61 76 65 2d 72   (if (and have-r
31a0: 65 73 6f 75 72 63 65 73 0a 09 09 20 20 20 20 20  esources...     
31b0: 28 6e 75 6c 6c 3f 20 70 72 65 72 65 71 73 2d 6e  (null? prereqs-n
31c0: 6f 74 2d 6d 65 74 29 29 0a 09 09 3b 3b 20 6e 6f  ot-met))...;; no
31d0: 20 6c 6f 6f 70 20 2d 20 64 72 6f 70 20 74 68 6f   loop - drop tho
31e0: 75 67 68 20 61 6e 64 20 75 73 65 20 74 68 65 20  ugh and use the 
31f0: 6c 6f 6f 70 20 61 74 20 74 68 65 20 62 6f 74 74  loop at the bott
3200: 6f 6d 20 0a 09 09 28 72 75 6e 3a 74 65 73 74 20  om ...(run:test 
3210: 64 62 20 72 75 6e 2d 69 64 20 72 75 6e 6e 61 6d  db run-id runnam
3220: 65 20 6b 65 79 76 61 6c 6c 73 74 20 74 65 73 74  e keyvallst test
3230: 2d 72 65 63 6f 72 64 20 66 6c 61 67 73 20 23 66  -record flags #f
3240: 29 0a 09 09 3b 3b 20 65 6c 73 65 20 74 68 65 20  )...;; else the 
3250: 72 75 6e 20 69 73 20 73 74 75 63 6b 2c 20 74 65  run is stuck, te
3260: 6d 70 6f 72 61 72 69 6c 79 20 6f 72 20 70 65 72  mporarily or per
3270: 6d 61 6e 65 6e 74 6c 79 0a 09 09 28 6c 65 74 20  manently...(let 
3280: 28 28 6e 65 77 74 61 6c 20 28 61 70 70 65 6e 64  ((newtal (append
3290: 20 74 61 6c 20 28 6c 69 73 74 20 68 65 64 29 29   tal (list hed))
32a0: 29 29 0a 09 09 20 20 3b 3b 20 63 6f 75 6c 64 6e  ))...  ;; couldn
32b0: 27 74 20 72 75 6e 2c 20 74 61 6b 65 20 61 20 62  't run, take a b
32c0: 72 65 61 74 68 65 72 0a 09 09 20 20 28 74 68 72  reather...  (thr
32d0: 65 61 64 2d 73 6c 65 65 70 21 20 31 29 0a 09 09  ead-sleep! 1)...
32e0: 20 20 28 6c 6f 6f 70 20 28 63 61 72 20 6e 65 77    (loop (car new
32f0: 74 61 6c 29 28 63 64 72 20 6e 65 77 74 61 6c 29  tal)(cdr newtal)
3300: 29 29 29 29 29 0a 09 20 0a 09 20 3b 3b 20 63 61  ))))).. .. ;; ca
3310: 73 65 20 77 68 65 72 65 20 61 6e 20 69 74 65 6d  se where an item
3320: 73 20 63 61 6d 65 20 69 6e 20 61 73 20 61 20 6c  s came in as a l
3330: 69 73 74 20 62 65 65 6e 20 70 72 6f 63 65 73 73  ist been process
3340: 65 64 0a 09 20 28 28 61 6e 64 20 28 6c 69 73 74  ed.. ((and (list
3350: 3f 20 69 74 65 6d 73 29 20 20 20 20 20 3b 3b 20  ? items)     ;; 
3360: 74 68 75 73 20 77 65 20 6b 6e 6f 77 20 6f 75 72  thus we know our
3370: 20 69 74 65 6d 73 20 61 72 65 20 61 6c 72 65 61   items are alrea
3380: 64 79 20 63 61 6c 63 75 6c 61 74 65 64 0a 09 20  dy calculated.. 
3390: 20 20 20 20 20 20 28 6e 6f 74 20 20 20 69 74 65        (not   ite
33a0: 6d 64 61 74 29 29 20 3b 3b 20 61 6e 64 20 6e 6f  mdat)) ;; and no
33b0: 74 20 79 65 74 20 65 78 70 61 6e 64 65 64 20 69  t yet expanded i
33c0: 6e 74 6f 20 74 68 65 20 6c 69 73 74 20 6f 66 20  nto the list of 
33d0: 74 68 69 6e 67 73 20 74 6f 20 62 65 20 64 6f 6e  things to be don
33e0: 65 0a 09 20 20 28 69 66 20 28 3e 3d 20 2a 76 65  e..  (if (>= *ve
33f0: 72 62 6f 73 69 74 79 2a 20 31 29 28 70 70 20 69  rbosity* 1)(pp i
3400: 74 65 6d 73 29 29 0a 09 20 20 3b 3b 20 28 69 66  tems))..  ;; (if
3410: 20 28 3e 3d 20 2a 76 65 72 62 6f 73 69 74 79 2a   (>= *verbosity*
3420: 20 35 29 0a 09 20 20 3b 3b 20 20 20 20 20 28 62   5)..  ;;     (b
3430: 65 67 69 6e 0a 09 20 20 3b 3b 20 20 20 20 20 20  egin..  ;;      
3440: 20 28 70 72 69 6e 74 20 22 69 74 65 6d 73 3a 20   (print "items: 
3450: 22 29 20 20 20 20 20 28 70 70 20 28 69 74 65 6d  ")     (pp (item
3460: 2d 61 73 73 6f 63 2d 3e 69 74 65 6d 2d 6c 69 73  -assoc->item-lis
3470: 74 20 69 74 65 6d 73 29 29 0a 09 20 20 3b 3b 20  t items))..  ;; 
3480: 20 20 20 20 20 20 28 70 72 69 6e 74 20 22 69 74        (print "it
3490: 65 6d 73 74 61 62 6c 65 3a 20 22 29 28 70 70 20  emstable: ")(pp 
34a0: 28 69 74 65 6d 2d 74 61 62 6c 65 2d 3e 69 74 65  (item-table->ite
34b0: 6d 2d 6c 69 73 74 20 69 74 65 6d 73 74 61 62 6c  m-list itemstabl
34c0: 65 29 29 29 29 0a 09 20 20 28 66 6f 72 2d 65 61  e))))..  (for-ea
34d0: 63 68 0a 09 20 20 20 28 6c 61 6d 62 64 61 20 28  ch..   (lambda (
34e0: 6d 79 2d 69 74 65 6d 64 61 74 29 0a 09 20 20 20  my-itemdat)..   
34f0: 20 20 28 6c 65 74 2a 20 28 28 6e 65 77 2d 74 65    (let* ((new-te
3500: 73 74 2d 72 65 63 6f 72 64 20 28 6c 65 74 20 28  st-record (let (
3510: 28 6e 65 77 72 65 63 20 28 6d 61 6b 65 2d 74 65  (newrec (make-te
3520: 73 74 73 3a 74 65 73 74 71 75 65 75 65 29 29 29  sts:testqueue)))
3530: 0a 09 09 09 09 20 20 20 20 20 20 20 28 76 65 63  .....       (vec
3540: 74 6f 72 2d 63 6f 70 79 21 20 74 65 73 74 2d 72  tor-copy! test-r
3550: 65 63 6f 72 64 20 6e 65 77 72 65 63 29 0a 09 09  ecord newrec)...
3560: 09 09 20 20 20 20 20 20 20 6e 65 77 72 65 63 29  ..       newrec)
3570: 29 0a 09 09 20 20 20 20 28 6d 79 2d 69 74 65 6d  )...    (my-item
3580: 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c 69 73 74  -path (item-list
3590: 2d 3e 70 61 74 68 20 6d 79 2d 69 74 65 6d 64 61  ->path my-itemda
35a0: 74 29 29 0a 09 09 20 20 20 20 28 69 74 65 6d 2d  t))...    (item-
35b0: 6d 61 74 63 68 65 73 20 28 69 66 20 69 74 65 6d  matches (if item
35c0: 2d 70 61 74 74 73 20 20 20 20 20 20 20 3b 3b 20  -patts       ;; 
35d0: 68 65 72 65 20 77 65 20 61 72 65 20 66 69 6c 74  here we are filt
35e0: 65 72 69 6e 67 20 66 6f 72 20 6d 61 74 63 68 65  ering for matche
35f0: 73 20 77 69 74 68 20 2d 69 74 65 6d 70 61 74 74  s with -itempatt
3600: 0a 09 09 09 09 20 20 20 20 20 20 28 6c 65 74 20  .....      (let 
3610: 28 28 72 65 73 20 23 66 29 29 09 20 3b 3b 20 6c  ((res #f)). ;; l
3620: 6f 6f 6b 20 74 68 72 6f 75 67 68 20 61 6c 6c 20  ook through all 
3630: 74 68 65 20 69 74 65 6d 2d 70 61 74 74 73 20 69  the item-patts i
3640: 66 20 64 65 66 69 6e 65 64 2c 20 66 6f 72 6d 61  f defined, forma
3650: 74 20 69 73 20 70 61 74 74 31 2c 70 61 74 74 32  t is patt1,patt2
3660: 2c 70 61 74 74 33 20 2e 2e 2e 20 77 69 6c 64 63  ,patt3 ... wildc
3670: 61 72 64 20 69 73 20 25 0a 09 09 09 09 09 28 66  ard is %......(f
3680: 6f 72 2d 65 61 63 68 20 0a 09 09 09 09 09 20 28  or-each ...... (
3690: 6c 61 6d 62 64 61 20 28 70 61 74 74 29 0a 09 09  lambda (patt)...
36a0: 09 09 09 20 20 20 28 69 66 20 28 73 74 72 69 6e  ...   (if (strin
36b0: 67 2d 73 65 61 72 63 68 20 28 67 6c 6f 62 2d 3e  g-search (glob->
36c0: 72 65 67 65 78 70 0a 09 09 09 09 09 09 09 20 20  regexp........  
36d0: 20 20 20 20 20 28 73 74 72 69 6e 67 2d 74 72 61       (string-tra
36e0: 6e 73 6c 61 74 65 20 70 61 74 74 20 22 25 22 20  nslate patt "%" 
36f0: 22 2a 22 29 29 0a 09 09 09 09 09 09 09 20 20 20  "*"))........   
3700: 20 20 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 09     item-path)...
3710: 09 09 09 20 20 20 20 20 20 20 28 73 65 74 21 20  ...       (set! 
3720: 72 65 73 20 23 74 29 29 29 0a 09 09 09 09 09 20  res #t)))...... 
3730: 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 69 74  (string-split it
3740: 65 6d 2d 70 61 74 74 73 20 22 2c 22 29 29 0a 09  em-patts ","))..
3750: 09 09 09 09 72 65 73 29 0a 09 09 09 09 20 20 20  ....res).....   
3760: 20 20 20 23 74 29 29 29 0a 09 20 20 20 20 20 20     #t)))..      
3770: 20 28 69 66 20 69 74 65 6d 2d 6d 61 74 63 68 65   (if item-matche
3780: 73 20 3b 3b 20 79 65 73 2c 20 77 65 20 77 61 6e  s ;; yes, we wan
3790: 74 20 74 6f 20 70 72 6f 63 65 73 73 20 74 68 69  t to process thi
37a0: 73 20 69 74 65 6d 0a 09 09 20 20 20 28 6c 65 74  s item...   (let
37b0: 20 28 28 6e 65 77 74 65 73 74 6e 61 6d 65 20 28   ((newtestname (
37c0: 63 6f 6e 63 20 68 65 64 20 22 2f 22 20 6d 79 2d  conc hed "/" my-
37d0: 69 74 65 6d 2d 70 61 74 68 29 29 29 20 0a 09 09  item-path))) ...
37e0: 20 20 20 20 20 28 74 65 73 74 73 3a 74 65 73 74       (tests:test
37f0: 71 75 65 75 65 2d 73 65 74 2d 69 74 65 6d 73 21  queue-set-items!
3800: 20 20 20 6e 65 77 2d 74 65 73 74 2d 72 65 63 6f     new-test-reco
3810: 72 64 20 23 66 29 0a 09 09 20 20 20 20 20 28 74  rd #f)...     (t
3820: 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d 73  ests:testqueue-s
3830: 65 74 2d 69 74 65 6d 64 61 74 21 20 6e 65 77 2d  et-itemdat! new-
3840: 74 65 73 74 2d 72 65 63 6f 72 64 20 6d 79 2d 69  test-record my-i
3850: 74 65 6d 64 61 74 29 0a 09 09 20 20 20 20 20 28  temdat)...     (
3860: 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74 21 20  hash-table-set! 
3870: 74 65 73 74 2d 72 65 63 6f 72 64 73 20 6e 65 77  test-records new
3880: 74 65 73 74 6e 61 6d 65 20 6e 65 77 2d 74 65 73  testname new-tes
3890: 74 2d 72 65 63 6f 72 64 29 0a 09 09 20 20 20 20  t-record)...    
38a0: 20 28 73 65 74 21 20 74 61 6c 20 28 63 6f 6e 73   (set! tal (cons
38b0: 20 6e 65 77 74 65 73 74 6e 61 6d 65 20 74 61 6c   newtestname tal
38c0: 29 29 29 29 29 29 20 3b 3b 20 73 69 6e 63 65 20  )))))) ;; since 
38d0: 74 68 65 73 65 20 61 72 65 20 69 74 65 6d 69 7a  these are itemiz
38e0: 65 64 20 63 72 65 61 74 65 20 6e 65 77 20 74 65  ed create new te
38f0: 73 74 20 6e 61 6d 65 73 20 74 65 73 74 6e 61 6d  st names testnam
3900: 65 2f 69 74 65 6d 70 61 74 68 0a 09 20 20 20 69  e/itempath..   i
3910: 74 65 6d 73 29 0a 09 20 20 28 6c 6f 6f 70 20 28  tems)..  (loop (
3920: 63 61 72 20 74 61 6c 29 28 63 64 72 20 74 61 6c  car tal)(cdr tal
3930: 29 29 29 0a 0a 09 20 3b 3b 20 69 66 20 69 74 65  )))... ;; if ite
3940: 6d 73 20 69 73 20 61 20 70 72 6f 63 20 74 68 65  ms is a proc the
3950: 6e 20 6e 65 65 64 20 74 6f 20 72 75 6e 20 69 74  n need to run it
3960: 65 6d 73 3a 67 65 74 2d 69 74 65 6d 73 2d 66 72  ems:get-items-fr
3970: 6f 6d 2d 63 6f 6e 66 69 67 2c 20 67 65 74 20 74  om-config, get t
3980: 68 65 20 6c 69 73 74 20 61 6e 64 20 6c 6f 6f 70  he list and loop
3990: 20 0a 09 20 3b 3b 20 20 20 20 2d 20 62 75 74 20   .. ;;    - but 
39a0: 6f 6e 6c 79 20 64 6f 20 74 68 61 74 20 69 66 20  only do that if 
39b0: 72 65 73 6f 75 72 63 65 73 20 65 78 69 73 74 20  resources exist 
39c0: 74 6f 20 6b 69 63 6b 20 6f 66 66 20 74 68 65 20  to kick off the 
39d0: 6a 6f 62 0a 09 20 28 28 70 72 6f 63 65 64 75 72  job.. ((procedur
39e0: 65 3f 20 69 74 65 6d 73 29 0a 09 20 20 28 69 66  e? items)..  (if
39f0: 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d   (runs:can-run-m
3a00: 6f 72 65 2d 74 65 73 74 73 20 64 62 20 74 65 73  ore-tests db tes
3a10: 74 2d 72 65 63 6f 72 64 29 0a 09 20 20 20 20 20  t-record)..     
3a20: 20 28 6c 65 74 20 28 28 69 74 65 6d 73 2d 6c 69   (let ((items-li
3a30: 73 74 20 28 69 74 65 6d 73 3a 67 65 74 2d 69 74  st (items:get-it
3a40: 65 6d 73 2d 66 72 6f 6d 2d 63 6f 6e 66 69 67 20  ems-from-config 
3a50: 74 63 6f 6e 66 69 67 29 29 29 0a 09 09 28 69 66  tconfig)))...(if
3a60: 20 28 6c 69 73 74 3f 20 69 74 65 6d 73 2d 6c 69   (list? items-li
3a70: 73 74 29 0a 09 09 20 20 20 20 28 62 65 67 69 6e  st)...    (begin
3a80: 0a 09 09 20 20 20 20 20 20 28 74 65 73 74 73 3a  ...      (tests:
3a90: 74 65 73 74 71 75 65 75 65 2d 73 65 74 2d 69 74  testqueue-set-it
3aa0: 65 6d 73 20 74 65 73 74 2d 72 65 63 6f 72 64 20  ems test-record 
3ab0: 69 74 65 6d 73 2d 6c 69 73 74 29 0a 09 09 20 20  items-list)...  
3ac0: 20 20 20 20 28 6c 6f 6f 70 20 68 65 64 20 74 61      (loop hed ta
3ad0: 6c 29 29 0a 09 09 20 20 20 20 28 62 65 67 69 6e  l))...    (begin
3ae0: 0a 09 09 20 20 20 20 20 20 28 64 65 62 75 67 3a  ...      (debug:
3af0: 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20  print 0 "ERROR: 
3b00: 54 68 65 20 70 72 6f 63 20 66 72 6f 6d 20 72 65  The proc from re
3b10: 61 64 69 6e 67 20 74 68 65 20 73 65 74 75 70 20  ading the setup 
3b20: 64 69 64 20 6e 6f 74 20 79 69 65 6c 64 20 61 20  did not yield a 
3b30: 6c 69 73 74 20 2d 20 70 6c 65 61 73 65 20 72 65  list - please re
3b40: 70 6f 72 74 20 74 68 69 73 22 29 0a 09 09 20 20  port this")...  
3b50: 20 20 20 20 28 65 78 69 74 20 31 29 29 29 29 0a      (exit 1)))).
3b60: 09 20 20 20 20 20 20 28 6c 65 74 20 28 28 6e 65  .      (let ((ne
3b70: 77 74 61 6c 20 28 61 70 70 65 6e 64 20 74 61 6c  wtal (append tal
3b80: 20 28 6c 69 73 74 20 68 65 64 29 29 29 29 0a 09   (list hed))))..
3b90: 09 3b 3b 20 69 66 20 63 61 6e 27 74 20 72 75 6e  .;; if can't run
3ba0: 20 6d 6f 72 65 20 74 65 73 74 73 2c 20 6c 65 74   more tests, let
3bb0: 73 20 74 61 6b 65 20 61 20 62 72 65 61 74 68 65  s take a breathe
3bc0: 72 0a 09 09 28 74 68 72 65 61 64 2d 73 6c 65 65  r...(thread-slee
3bd0: 70 21 20 31 29 0a 09 09 28 6c 6f 6f 70 20 28 63  p! 1)...(loop (c
3be0: 61 72 20 6e 65 77 74 61 6c 29 28 63 64 72 20 6e  ar newtal)(cdr n
3bf0: 65 77 74 61 6c 29 29 29 29 29 0a 0a 09 20 3b 3b  ewtal)))))... ;;
3c00: 20 74 68 69 73 20 63 61 73 65 20 73 68 6f 75 6c   this case shoul
3c10: 64 20 6e 6f 74 20 68 61 70 70 65 6e 2c 20 61 64  d not happen, ad
3c20: 64 65 64 20 74 6f 20 68 65 6c 70 20 63 61 74 63  ded to help catc
3c30: 68 20 61 6e 79 20 62 75 67 73 0a 09 20 28 28 61  h any bugs.. ((a
3c40: 6e 64 20 28 6c 69 73 74 3f 20 69 74 65 6d 73 29  nd (list? items)
3c50: 20 69 74 65 6d 64 61 74 29 0a 09 20 20 28 64 65   itemdat)..  (de
3c60: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52  bug:print 0 "ERR
3c70: 4f 52 3a 20 53 68 6f 75 6c 64 20 6e 6f 74 20 68  OR: Should not h
3c80: 61 76 65 20 61 20 6c 69 73 74 20 6f 66 20 69 74  ave a list of it
3c90: 65 6d 73 20 69 6e 20 61 20 74 65 73 74 20 61 6e  ems in a test an
3ca0: 64 20 74 68 65 20 69 74 65 6d 73 70 61 74 68 20  d the itemspath 
3cb0: 73 65 74 20 2d 20 70 6c 65 61 73 65 20 72 65 70  set - please rep
3cc0: 6f 72 74 20 74 68 69 73 22 29 0a 09 20 20 28 65  ort this")..  (e
3cd0: 78 69 74 20 31 29 29 29 0a 09 0a 09 3b 3b 20 77  xit 1)))....;; w
3ce0: 65 20 67 65 74 20 68 65 72 65 20 6f 6e 20 22 64  e get here on "d
3cf0: 72 6f 70 20 74 68 72 6f 75 67 68 22 20 2d 20 6c  rop through" - l
3d00: 6f 6f 70 20 66 6f 72 20 6e 65 78 74 20 74 65 73  oop for next tes
3d10: 74 20 69 6e 20 71 75 65 75 65 0a 09 28 69 66 20  t in queue..(if 
3d20: 28 6e 75 6c 6c 3f 20 74 61 6c 29 0a 09 20 20 20  (null? tal)..   
3d30: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20   (debug:print 1 
3d40: 22 49 4e 46 4f 3a 20 41 6c 6c 20 74 65 73 74 73  "INFO: All tests
3d50: 20 6c 61 75 6e 63 68 65 64 22 29 0a 09 20 20 20   launched")..   
3d60: 20 28 6c 6f 6f 70 20 28 63 61 72 20 74 61 6c 29   (loop (car tal)
3d70: 28 63 64 72 20 74 61 6c 29 29 29 29 29 29 29 0a  (cdr tal))))))).
3d80: 0a 3b 3b 20 70 61 72 65 6e 74 2d 74 65 73 74 20  .;; parent-test 
3d90: 69 73 20 74 68 65 72 65 20 61 73 20 61 20 70 6c  is there as a pl
3da0: 61 63 65 68 6f 6c 64 65 72 20 66 6f 72 20 77 68  aceholder for wh
3db0: 65 6e 20 70 61 72 65 6e 74 2d 74 65 73 74 73 20  en parent-tests 
3dc0: 63 61 6e 20 62 65 20 72 75 6e 20 61 73 20 61 20  can be run as a 
3dd0: 73 65 74 75 70 20 73 74 65 70 0a 28 64 65 66 69  setup step.(defi
3de0: 6e 65 20 28 72 75 6e 3a 74 65 73 74 20 64 62 20  ne (run:test db 
3df0: 72 75 6e 2d 69 64 20 72 75 6e 6e 61 6d 65 20 6b  run-id runname k
3e00: 65 79 76 61 6c 6c 73 74 20 74 65 73 74 2d 72 65  eyvallst test-re
3e10: 63 6f 72 64 20 66 6c 61 67 73 20 70 61 72 65 6e  cord flags paren
3e20: 74 2d 74 65 73 74 29 0a 20 20 3b 3b 20 41 6c 6c  t-test).  ;; All
3e30: 20 74 68 65 73 65 20 76 61 72 73 20 6d 69 67 68   these vars migh
3e40: 74 20 62 65 20 72 65 66 65 72 65 6e 63 65 64 20  t be referenced 
3e50: 62 79 20 74 68 65 20 74 65 73 74 63 6f 6e 66 69  by the testconfi
3e60: 67 20 66 69 6c 65 20 72 65 61 64 65 72 0a 20 20  g file reader.  
3e70: 28 6c 65 74 2a 20 28 28 74 65 73 74 2d 6e 61 6d  (let* ((test-nam
3e80: 65 20 20 20 20 28 74 65 73 74 73 3a 74 65 73 74  e    (tests:test
3e90: 71 75 65 75 65 2d 67 65 74 2d 74 65 73 74 6e 61  queue-get-testna
3ea0: 6d 65 20 20 20 74 65 73 74 2d 72 65 63 6f 72 64  me   test-record
3eb0: 29 29 0a 09 20 28 74 65 73 74 2d 77 61 69 74 6f  )).. (test-waito
3ec0: 6e 73 20 28 74 65 73 74 73 3a 74 65 73 74 71 75  ns (tests:testqu
3ed0: 65 75 65 2d 67 65 74 2d 77 61 69 74 6f 6e 73 20  eue-get-waitons 
3ee0: 20 20 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29     test-record))
3ef0: 0a 09 20 28 74 65 73 74 2d 63 6f 6e 66 20 20 20  .. (test-conf   
3f00: 20 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75   (tests:testqueu
3f10: 65 2d 67 65 74 2d 74 65 73 74 63 6f 6e 66 69 67  e-get-testconfig
3f20: 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29 0a 09   test-record))..
3f30: 20 28 69 74 65 6d 64 61 74 20 20 20 20 20 20 28   (itemdat      (
3f40: 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d  tests:testqueue-
3f50: 67 65 74 2d 69 74 65 6d 64 61 74 20 20 20 20 74  get-itemdat    t
3f60: 65 73 74 2d 72 65 63 6f 72 64 29 29 0a 09 20 28  est-record)).. (
3f70: 74 65 73 74 2d 70 61 74 68 20 20 20 20 28 63 6f  test-path    (co
3f80: 6e 63 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f 74  nc *toppath* "/t
3f90: 65 73 74 73 2f 22 20 74 65 73 74 2d 6e 61 6d 65  ests/" test-name
3fa0: 29 29 20 3b 3b 20 63 6f 75 6c 64 20 75 73 65 20  )) ;; could use 
3fb0: 74 65 73 74 3a 67 65 74 2d 74 65 73 74 63 6f 6e  test:get-testcon
3fc0: 66 69 67 20 68 65 72 65 20 2e 2e 2e 0a 09 20 28  fig here ..... (
3fd0: 66 6f 72 63 65 20 20 20 20 20 20 20 20 28 68 61  force        (ha
3fe0: 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66  sh-table-ref/def
3ff0: 61 75 6c 74 20 66 6c 61 67 73 20 22 2d 66 6f 72  ault flags "-for
4000: 63 65 22 20 23 66 29 29 0a 09 20 28 72 65 72 75  ce" #f)).. (reru
4010: 6e 20 20 20 20 20 20 20 20 28 68 61 73 68 2d 74  n        (hash-t
4020: 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74  able-ref/default
4030: 20 66 6c 61 67 73 20 22 2d 72 65 72 75 6e 22 20   flags "-rerun" 
4040: 23 66 29 29 0a 09 20 28 6b 65 65 70 67 6f 69 6e  #f)).. (keepgoin
4050: 67 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65  g    (hash-table
4060: 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 66 6c 61  -ref/default fla
4070: 67 73 20 22 2d 6b 65 65 70 67 6f 69 6e 67 22 20  gs "-keepgoing" 
4080: 23 66 29 29 0a 09 20 28 69 74 65 6d 2d 70 61 74  #f)).. (item-pat
4090: 68 20 20 20 20 20 22 22 29 29 0a 20 20 20 20 28  h     "")).    (
40a0: 64 65 62 75 67 3a 70 72 69 6e 74 20 35 0a 09 09  debug:print 5...
40b0: 20 22 74 65 73 74 2d 63 6f 6e 66 69 67 3a 20 22   "test-config: "
40c0: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 3e 61 6c   (hash-table->al
40d0: 69 73 74 20 74 65 73 74 2d 63 6f 6e 66 29 0a 09  ist test-conf)..
40e0: 09 20 22 5c 6e 20 20 20 69 74 65 6d 64 61 74 3a  . "\n   itemdat:
40f0: 20 22 20 69 74 65 6d 64 61 74 0a 09 09 20 29 0a   " itemdat... ).
4100: 20 20 20 20 3b 3b 20 73 65 74 74 69 6e 67 20 69      ;; setting i
4110: 74 65 6d 64 61 74 20 74 6f 20 61 20 6c 69 73 74  temdat to a list
4120: 20 69 66 20 69 74 20 69 73 20 23 66 0a 20 20 20   if it is #f.   
4130: 20 28 69 66 20 28 6e 6f 74 20 69 74 65 6d 64 61   (if (not itemda
4140: 74 29 28 73 65 74 21 20 69 74 65 6d 64 61 74 20  t)(set! itemdat 
4150: 27 28 29 29 29 0a 20 20 20 20 28 73 65 74 21 20  '())).    (set! 
4160: 69 74 65 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d  item-path (item-
4170: 6c 69 73 74 2d 3e 70 61 74 68 20 69 74 65 6d 64  list->path itemd
4180: 61 74 29 29 0a 20 20 20 20 28 64 65 62 75 67 3a  at)).    (debug:
4190: 70 72 69 6e 74 20 31 20 22 41 74 74 65 6d 70 74  print 1 "Attempt
41a0: 69 6e 67 20 74 6f 20 6c 61 75 6e 63 68 20 74 65  ing to launch te
41b0: 73 74 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22  st " test-name "
41c0: 2f 22 20 69 74 65 6d 2d 70 61 74 68 29 0a 20 20  /" item-path).  
41d0: 20 20 28 73 65 74 65 6e 76 20 22 4d 54 5f 54 45    (setenv "MT_TE
41e0: 53 54 5f 4e 41 4d 45 22 20 74 65 73 74 2d 6e 61  ST_NAME" test-na
41f0: 6d 65 29 20 3b 3b 20 0a 20 20 20 20 28 73 65 74  me) ;; .    (set
4200: 65 6e 76 20 22 4d 54 5f 52 55 4e 4e 41 4d 45 22  env "MT_RUNNAME"
4210: 20 20 20 72 75 6e 6e 61 6d 65 29 0a 20 20 20 20     runname).    
4220: 28 73 65 74 2d 6d 65 67 61 74 65 73 74 2d 65 6e  (set-megatest-en
4230: 76 2d 76 61 72 73 20 64 62 20 72 75 6e 2d 69 64  v-vars db run-id
4240: 29 20 3b 3b 20 74 68 65 73 65 20 6d 61 79 20 62  ) ;; these may b
4250: 65 20 6e 65 65 64 65 64 20 62 79 20 74 68 65 20  e needed by the 
4260: 6c 61 75 6e 63 68 69 6e 67 20 70 72 6f 63 65 73  launching proces
4270: 73 0a 20 20 20 20 28 63 68 61 6e 67 65 2d 64 69  s.    (change-di
4280: 72 65 63 74 6f 72 79 20 2a 74 6f 70 70 61 74 68  rectory *toppath
4290: 2a 29 0a 0a 20 20 20 20 3b 3b 20 48 65 72 65 20  *)..    ;; Here 
42a0: 69 73 20 77 68 65 72 65 20 74 68 65 20 74 65 73  is where the tes
42b0: 74 5f 6d 65 74 61 20 74 61 62 6c 65 20 69 73 20  t_meta table is 
42c0: 62 65 73 74 20 75 70 64 61 74 65 64 0a 20 20 20  best updated.   
42d0: 20 28 72 75 6e 73 3a 75 70 64 61 74 65 2d 74 65   (runs:update-te
42e0: 73 74 5f 6d 65 74 61 20 64 62 20 74 65 73 74 2d  st_meta db test-
42f0: 6e 61 6d 65 20 74 65 73 74 2d 63 6f 6e 66 29 0a  name test-conf).
4300: 20 20 20 20 0a 20 20 20 20 3b 3b 20 28 6c 61 6d      .    ;; (lam
4310: 62 64 61 20 28 69 74 65 6d 64 61 74 29 20 3b 3b  bda (itemdat) ;;
4320: 3b 20 28 28 72 69 70 65 6e 65 73 73 20 22 6f 76  ; ((ripeness "ov
4330: 65 72 72 69 70 65 22 29 20 28 74 65 6d 70 65 72  erripe") (temper
4340: 61 74 75 72 65 20 22 63 6f 6f 6c 22 29 20 28 73  ature "cool") (s
4350: 65 61 73 6f 6e 20 22 73 75 6d 6d 65 72 22 29 29  eason "summer"))
4360: 0a 20 20 20 20 28 6c 65 74 2a 20 28 28 6e 65 77  .    (let* ((new
4370: 2d 74 65 73 74 2d 70 61 74 68 20 28 73 74 72 69  -test-path (stri
4380: 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 28  ng-intersperse (
4390: 63 6f 6e 73 20 74 65 73 74 2d 70 61 74 68 20 28  cons test-path (
43a0: 6d 61 70 20 63 61 64 72 20 69 74 65 6d 64 61 74  map cadr itemdat
43b0: 29 29 20 22 2f 22 29 29 0a 09 20 20 20 28 6e 65  )) "/"))..   (ne
43c0: 77 2d 74 65 73 74 2d 6e 61 6d 65 20 28 69 66 20  w-test-name (if 
43d0: 28 65 71 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74  (equal? item-pat
43e0: 68 20 22 22 29 20 74 65 73 74 2d 6e 61 6d 65 20  h "") test-name 
43f0: 28 63 6f 6e 63 20 74 65 73 74 2d 6e 61 6d 65 20  (conc test-name 
4400: 22 2f 22 20 69 74 65 6d 2d 70 61 74 68 29 29 29  "/" item-path)))
4410: 20 3b 3b 20 6a 75 73 74 20 6e 65 65 64 20 69 74   ;; just need it
4420: 20 74 6f 20 62 65 20 75 6e 69 71 75 65 0a 09 20   to be unique.. 
4430: 20 20 28 74 65 73 74 64 61 74 20 20 20 20 20 20    (testdat      
4440: 20 28 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e   (db:get-test-in
4450: 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  fo db run-id tes
4460: 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68  t-name item-path
4470: 29 29 29 0a 20 20 20 20 20 20 28 69 66 20 28 6e  ))).      (if (n
4480: 6f 74 20 74 65 73 74 64 61 74 29 0a 09 20 20 28  ot testdat)..  (
4490: 62 65 67 69 6e 0a 09 20 20 20 20 28 72 65 67 69  begin..    (regi
44a0: 73 74 65 72 2d 74 65 73 74 20 64 62 20 72 75 6e  ster-test db run
44b0: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74  -id test-name it
44c0: 65 6d 2d 70 61 74 68 29 0a 09 20 20 20 20 28 73  em-path)..    (s
44d0: 65 74 21 20 74 65 73 74 64 61 74 20 28 64 62 3a  et! testdat (db:
44e0: 67 65 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62  get-test-info db
44f0: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
4500: 65 20 69 74 65 6d 2d 70 61 74 68 29 29 29 29 0a  e item-path)))).
4510: 20 20 20 20 20 20 28 63 68 61 6e 67 65 2d 64 69        (change-di
4520: 72 65 63 74 6f 72 79 20 74 65 73 74 2d 70 61 74  rectory test-pat
4530: 68 29 0a 20 20 20 20 20 20 28 63 61 73 65 20 28  h).      (case (
4540: 69 66 20 66 6f 72 63 65 20 3b 3b 20 28 61 72 67  if force ;; (arg
4550: 73 3a 67 65 74 2d 61 72 67 20 22 2d 66 6f 72 63  s:get-arg "-forc
4560: 65 22 29 0a 09 09 27 4e 4f 54 5f 53 54 41 52 54  e")...'NOT_START
4570: 45 44 0a 09 09 28 69 66 20 74 65 73 74 64 61 74  ED...(if testdat
4580: 0a 09 09 20 20 20 20 28 73 74 72 69 6e 67 2d 3e  ...    (string->
4590: 73 79 6d 62 6f 6c 20 28 74 65 73 74 3a 67 65 74  symbol (test:get
45a0: 2d 73 74 61 74 65 20 74 65 73 74 64 61 74 29 29  -state testdat))
45b0: 0a 09 09 20 20 20 20 27 66 61 69 6c 65 64 2d 74  ...    'failed-t
45c0: 6f 2d 69 6e 73 65 72 74 29 29 0a 09 28 28 66 61  o-insert))..((fa
45d0: 69 6c 65 64 2d 74 6f 2d 69 6e 73 65 72 74 29 0a  iled-to-insert).
45e0: 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30  . (debug:print 0
45f0: 20 22 45 52 52 4f 52 3a 20 46 61 69 6c 65 64 20   "ERROR: Failed 
4600: 74 6f 20 69 6e 73 65 72 74 20 74 68 65 20 72 65  to insert the re
4610: 63 6f 72 64 20 69 6e 74 6f 20 74 68 65 20 64 62  cord into the db
4620: 22 29 29 0a 09 28 28 4e 4f 54 5f 53 54 41 52 54  "))..((NOT_START
4630: 45 44 20 43 4f 4d 50 4c 45 54 45 44 29 0a 09 20  ED COMPLETED).. 
4640: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 36 20 22  (debug:print 6 "
4650: 47 6f 74 20 68 65 72 65 2c 20 22 20 28 74 65 73  Got here, " (tes
4660: 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74  t:get-state test
4670: 64 61 74 29 29 0a 09 20 28 6c 65 74 20 28 28 72  dat)).. (let ((r
4680: 75 6e 66 6c 61 67 20 23 66 29 29 0a 09 20 20 20  unflag #f))..   
4690: 28 63 6f 6e 64 0a 09 20 20 20 20 3b 3b 20 2d 66  (cond..    ;; -f
46a0: 6f 72 63 65 2c 20 72 75 6e 20 6e 6f 20 6d 61 74  orce, run no mat
46b0: 74 65 72 20 77 68 61 74 0a 09 20 20 20 20 28 66  ter what..    (f
46c0: 6f 72 63 65 20 28 73 65 74 21 20 72 75 6e 66 6c  orce (set! runfl
46d0: 61 67 20 23 74 29 29 0a 09 20 20 20 20 3b 3b 20  ag #t))..    ;; 
46e0: 4e 4f 54 5f 53 54 41 52 54 45 44 2c 20 72 75 6e  NOT_STARTED, run
46f0: 20 6e 6f 20 6d 61 74 74 65 72 20 77 68 61 74 0a   no matter what.
4700: 09 20 20 20 20 28 28 65 71 75 61 6c 3f 20 28 74  .    ((equal? (t
4710: 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65  est:get-state te
4720: 73 74 64 61 74 29 20 22 4e 4f 54 5f 53 54 41 52  stdat) "NOT_STAR
4730: 54 45 44 22 29 28 73 65 74 21 20 72 75 6e 66 6c  TED")(set! runfl
4740: 61 67 20 23 74 29 29 0a 09 20 20 20 20 3b 3b 20  ag #t))..    ;; 
4750: 6e 6f 74 20 2d 72 65 72 75 6e 20 61 6e 64 20 50  not -rerun and P
4760: 41 53 53 2c 20 57 41 52 4e 20 6f 72 20 43 48 45  ASS, WARN or CHE
4770: 43 4b 2c 20 64 6f 20 6e 6f 20 72 75 6e 0a 09 20  CK, do no run.. 
4780: 20 20 20 28 28 61 6e 64 20 28 6f 72 20 28 6e 6f     ((and (or (no
4790: 74 20 72 65 72 75 6e 29 0a 09 09 20 20 20 20 20  t rerun)...     
47a0: 20 6b 65 65 70 67 6f 69 6e 67 29 0a 09 09 20 20   keepgoing)...  
47b0: 28 6d 65 6d 62 65 72 20 28 74 65 73 74 3a 67 65  (member (test:ge
47c0: 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61 74  t-status testdat
47d0: 29 20 27 28 22 50 41 53 53 22 20 22 57 41 52 4e  ) '("PASS" "WARN
47e0: 22 20 22 43 48 45 43 4b 22 29 29 29 0a 09 20 20  " "CHECK")))..  
47f0: 20 20 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67     (set! runflag
4800: 20 23 66 29 29 0a 09 20 20 20 20 3b 3b 20 2d 72   #f))..    ;; -r
4810: 65 72 75 6e 20 61 6e 64 20 73 74 61 74 75 73 20  erun and status 
4820: 69 73 20 6f 6e 65 20 6f 66 20 74 68 65 20 73 70  is one of the sp
4830: 65 63 69 66 65 64 2c 20 72 75 6e 20 69 74 0a 09  ecifed, run it..
4840: 20 20 20 20 28 28 61 6e 64 20 72 65 72 75 6e 0a      ((and rerun.
4850: 09 09 20 20 28 6c 65 74 20 28 28 72 65 72 75 6e  ..  (let ((rerun
4860: 6c 73 74 20 28 73 74 72 69 6e 67 2d 73 70 6c 69  lst (string-spli
4870: 74 20 72 65 72 75 6e 20 22 2c 22 29 29 29 20 3b  t rerun ","))) ;
4880: 3b 20 46 41 49 4c 2c 0a 09 09 20 20 20 20 28 6d  ; FAIL,...    (m
4890: 65 6d 62 65 72 20 28 74 65 73 74 3a 67 65 74 2d  ember (test:get-
48a0: 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29 20  status testdat) 
48b0: 72 65 72 75 6e 6c 73 74 29 29 29 0a 09 20 20 20  rerunlst)))..   
48c0: 20 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20    (set! runflag 
48d0: 23 74 29 29 0a 09 20 20 20 20 3b 3b 20 2d 6b 65  #t))..    ;; -ke
48e0: 65 70 67 6f 69 6e 67 2c 20 64 6f 20 6e 6f 74 20  epgoing, do not 
48f0: 72 65 72 75 6e 20 46 41 49 4c 0a 09 20 20 20 20  rerun FAIL..    
4900: 28 28 61 6e 64 20 6b 65 65 70 67 6f 69 6e 67 0a  ((and keepgoing.
4910: 09 09 20 20 28 6d 65 6d 62 65 72 20 28 74 65 73  ..  (member (tes
4920: 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73  t:get-status tes
4930: 74 64 61 74 29 20 27 28 22 46 41 49 4c 22 29 29  tdat) '("FAIL"))
4940: 29 0a 09 20 20 20 20 20 28 73 65 74 21 20 72 75  )..     (set! ru
4950: 6e 66 6c 61 67 20 23 66 29 29 0a 09 20 20 20 20  nflag #f))..    
4960: 28 28 61 6e 64 20 28 6e 6f 74 20 72 65 72 75 6e  ((and (not rerun
4970: 29 0a 09 09 20 20 28 6d 65 6d 62 65 72 20 28 74  )...  (member (t
4980: 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74  est:get-status t
4990: 65 73 74 64 61 74 29 20 27 28 22 46 41 49 4c 22  estdat) '("FAIL"
49a0: 20 22 6e 2f 61 22 29 29 29 0a 09 20 20 20 20 20   "n/a")))..     
49b0: 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 74  (set! runflag #t
49c0: 29 29 0a 09 20 20 20 20 28 65 6c 73 65 20 28 73  ))..    (else (s
49d0: 65 74 21 20 72 75 6e 66 6c 61 67 20 23 66 29 29  et! runflag #f))
49e0: 29 0a 09 20 20 20 28 64 65 62 75 67 3a 70 72 69  )..   (debug:pri
49f0: 6e 74 20 36 20 22 52 55 4e 4e 49 4e 47 20 3d 3e  nt 6 "RUNNING =>
4a00: 20 72 75 6e 66 6c 61 67 3a 20 22 20 72 75 6e 66   runflag: " runf
4a10: 6c 61 67 20 22 20 53 54 41 54 45 3a 20 22 20 28  lag " STATE: " (
4a20: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74  test:get-state t
4a30: 65 73 74 64 61 74 29 20 22 20 53 54 41 54 55 53  estdat) " STATUS
4a40: 3a 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74  : " (test:get-st
4a50: 61 74 75 73 20 74 65 73 74 64 61 74 29 29 0a 09  atus testdat))..
4a60: 20 20 20 28 69 66 20 28 6e 6f 74 20 72 75 6e 66     (if (not runf
4a70: 6c 61 67 29 0a 09 20 20 20 20 20 20 20 28 69 66  lag)..       (if
4a80: 20 28 6e 6f 74 20 70 61 72 65 6e 74 2d 74 65 73   (not parent-tes
4a90: 74 29 0a 09 09 20 20 20 28 64 65 62 75 67 3a 70  t)...   (debug:p
4aa0: 72 69 6e 74 20 31 20 22 4e 4f 54 45 3a 20 4e 6f  rint 1 "NOTE: No
4ab0: 74 20 73 74 61 72 74 69 6e 67 20 74 65 73 74 20  t starting test 
4ac0: 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20  " new-test-name 
4ad0: 22 20 61 73 20 69 74 20 69 73 20 73 74 61 74 65  " as it is state
4ae0: 20 5c 22 43 4f 4d 50 4c 45 54 45 44 5c 22 20 61   \"COMPLETED\" a
4af0: 6e 64 20 73 74 61 74 75 73 20 5c 22 22 20 28 74  nd status \"" (t
4b00: 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74  est:get-status t
4b10: 65 73 74 64 61 74 29 20 22 5c 22 2c 20 75 73 65  estdat) "\", use
4b20: 20 2d 66 6f 72 63 65 20 74 6f 20 6f 76 65 72 72   -force to overr
4b30: 69 64 65 22 29 29 0a 09 20 20 20 20 20 20 20 3b  ide"))..       ;
4b40: 3b 20 4e 4f 54 45 3a 20 4e 6f 20 6c 6f 6e 67 65  ; NOTE: No longe
4b50: 72 20 62 65 20 63 68 65 63 6b 69 6e 67 20 70 72  r be checking pr
4b60: 65 72 65 71 75 69 73 69 74 65 73 20 68 65 72 65  erequisites here
4b70: 21 20 57 69 6c 6c 20 6e 65 76 65 72 20 67 65 74  ! Will never get
4b80: 20 68 65 72 65 20 75 6e 6c 65 73 73 20 70 72 65   here unless pre
4b90: 72 65 71 73 20 61 72 65 0a 09 20 20 20 20 20 20  reqs are..      
4ba0: 20 3b 3b 20 20 20 20 20 20 20 61 6c 72 65 61 64   ;;       alread
4bb0: 79 20 6d 65 74 2e 0a 09 20 20 20 20 20 20 20 28  y met...       (
4bc0: 69 66 20 28 6e 6f 74 20 28 6c 61 75 6e 63 68 2d  if (not (launch-
4bd0: 74 65 73 74 20 64 62 20 72 75 6e 2d 69 64 20 72  test db run-id r
4be0: 75 6e 6e 61 6d 65 20 74 65 73 74 2d 63 6f 6e 66  unname test-conf
4bf0: 20 6b 65 79 76 61 6c 6c 73 74 20 74 65 73 74 2d   keyvallst test-
4c00: 6e 61 6d 65 20 74 65 73 74 2d 70 61 74 68 20 69  name test-path i
4c10: 74 65 6d 64 61 74 20 66 6c 61 67 73 29 29 0a 09  temdat flags))..
4c20: 09 20 20 20 28 62 65 67 69 6e 0a 09 09 20 20 20  .   (begin...   
4c30: 20 20 28 70 72 69 6e 74 20 22 45 52 52 4f 52 3a    (print "ERROR:
4c40: 20 46 61 69 6c 65 64 20 74 6f 20 6c 61 75 6e 63   Failed to launc
4c50: 68 20 74 68 65 20 74 65 73 74 2e 20 45 78 69 74  h the test. Exit
4c60: 69 6e 67 20 61 73 20 73 6f 6f 6e 20 61 73 20 70  ing as soon as p
4c70: 6f 73 73 69 62 6c 65 22 29 0a 09 09 20 20 20 20  ossible")...    
4c80: 20 28 73 65 74 21 20 2a 67 6c 6f 62 61 6c 65 78   (set! *globalex
4c90: 69 74 73 74 61 74 75 73 2a 20 31 29 20 3b 3b 20  itstatus* 1) ;; 
4ca0: 0a 09 09 20 20 20 20 20 28 70 72 6f 63 65 73 73  ...     (process
4cb0: 2d 73 69 67 6e 61 6c 20 28 63 75 72 72 65 6e 74  -signal (current
4cc0: 2d 70 72 6f 63 65 73 73 2d 69 64 29 20 73 69 67  -process-id) sig
4cd0: 6e 61 6c 2f 6b 69 6c 6c 29 29 29 29 29 29 0a 09  nal/kill))))))..
4ce0: 28 28 4b 49 4c 4c 45 44 29 20 0a 09 20 28 64 65  ((KILLED) .. (de
4cf0: 62 75 67 3a 70 72 69 6e 74 20 31 20 22 4e 4f 54  bug:print 1 "NOT
4d00: 45 3a 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61  E: " new-test-na
4d10: 6d 65 20 22 20 69 73 20 61 6c 72 65 61 64 79 20  me " is already 
4d20: 72 75 6e 6e 69 6e 67 20 6f 72 20 77 61 73 20 65  running or was e
4d30: 78 70 6c 69 63 74 6c 79 20 6b 69 6c 6c 65 64 2c  xplictly killed,
4d40: 20 75 73 65 20 2d 66 6f 72 63 65 20 74 6f 20 6c   use -force to l
4d50: 61 75 6e 63 68 20 69 74 2e 22 29 29 0a 09 28 28  aunch it."))..((
4d60: 4c 41 55 4e 43 48 45 44 20 52 45 4d 4f 54 45 48  LAUNCHED REMOTEH
4d70: 4f 53 54 53 54 41 52 54 20 52 55 4e 4e 49 4e 47  OSTSTART RUNNING
4d80: 29 20 20 0a 09 20 28 69 66 20 28 3e 20 28 2d 20  )  .. (if (> (- 
4d90: 28 63 75 72 72 65 6e 74 2d 73 65 63 6f 6e 64 73  (current-seconds
4da0: 29 28 2b 20 28 64 62 3a 74 65 73 74 2d 67 65 74  )(+ (db:test-get
4db0: 2d 65 76 65 6e 74 5f 74 69 6d 65 20 74 65 73 74  -event_time test
4dc0: 64 61 74 29 0a 09 09 09 09 20 20 20 20 20 20 20  dat).....       
4dd0: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 72 75 6e  (db:test-get-run
4de0: 5f 64 75 72 61 74 69 6f 6e 20 74 65 73 74 64 61  _duration testda
4df0: 74 29 29 29 0a 09 09 36 30 30 29 20 3b 3b 20 69  t)))...600) ;; i
4e00: 2e 65 2e 20 6e 6f 20 75 70 64 61 74 65 20 66 6f  .e. no update fo
4e10: 72 20 6d 6f 72 65 20 74 68 61 6e 20 36 30 30 20  r more than 600 
4e20: 73 65 63 6f 6e 64 73 0a 09 20 20 20 20 20 28 62  seconds..     (b
4e30: 65 67 69 6e 0a 09 20 20 20 20 20 20 20 28 64 65  egin..       (de
4e40: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52  bug:print 0 "WAR
4e50: 4e 49 4e 47 3a 20 54 65 73 74 20 22 20 74 65 73  NING: Test " tes
4e60: 74 2d 6e 61 6d 65 20 22 20 61 70 70 65 61 72 73  t-name " appears
4e70: 20 74 6f 20 62 65 20 64 65 61 64 2e 20 46 6f 72   to be dead. For
4e80: 63 69 6e 67 20 69 74 20 74 6f 20 73 74 61 74 65  cing it to state
4e90: 20 49 4e 43 4f 4d 50 4c 45 54 45 20 61 6e 64 20   INCOMPLETE and 
4ea0: 73 74 61 74 75 73 20 53 54 55 43 4b 2f 44 45 41  status STUCK/DEA
4eb0: 44 22 29 0a 09 20 20 20 20 20 20 20 28 74 65 73  D")..       (tes
4ec0: 74 2d 73 65 74 2d 73 74 61 74 75 73 21 20 64 62  t-set-status! db
4ed0: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
4ee0: 65 20 22 49 4e 43 4f 4d 50 4c 45 54 45 22 20 22  e "INCOMPLETE" "
4ef0: 53 54 55 43 4b 2f 44 45 41 44 22 20 69 74 65 6d  STUCK/DEAD" item
4f00: 64 61 74 20 22 54 65 73 74 20 69 73 20 73 74 75  dat "Test is stu
4f10: 63 6b 20 6f 72 20 64 65 61 64 22 20 23 66 29 29  ck or dead" #f))
4f20: 0a 09 20 20 20 20 20 28 64 65 62 75 67 3a 70 72  ..     (debug:pr
4f30: 69 6e 74 20 32 20 22 4e 4f 54 45 3a 20 22 20 74  int 2 "NOTE: " t
4f40: 65 73 74 2d 6e 61 6d 65 20 22 20 69 73 20 61 6c  est-name " is al
4f50: 72 65 61 64 79 20 72 75 6e 6e 69 6e 67 22 29 29  ready running"))
4f60: 29 0a 09 28 65 6c 73 65 20 20 20 20 20 20 20 28  )..(else       (
4f70: 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45  debug:print 0 "E
4f80: 52 52 4f 52 3a 20 46 61 69 6c 65 64 20 74 6f 20  RROR: Failed to 
4f90: 6c 61 75 6e 63 68 20 74 65 73 74 20 22 20 6e 65  launch test " ne
4fa0: 77 2d 74 65 73 74 2d 6e 61 6d 65 20 22 2e 20 55  w-test-name ". U
4fb0: 6e 72 65 63 6f 67 6e 69 73 65 64 20 73 74 61 74  nrecognised stat
4fc0: 65 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74  e " (test:get-st
4fd0: 61 74 65 20 74 65 73 74 64 61 74 29 29 29 29 29  ate testdat)))))
4fe0: 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ))..;;==========
4ff0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5000: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5010: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5020: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20  ============.;; 
5030: 45 4e 44 20 4f 46 20 4e 45 57 20 53 54 55 46 46  END OF NEW STUFF
5040: 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  .;;=============
5050: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5060: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5070: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5080: 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 28 64 65 66 69  =========..(defi
5090: 6e 65 20 28 67 65 74 2d 64 69 72 2d 75 70 2d 6e  ne (get-dir-up-n
50a0: 20 64 69 72 20 2e 20 70 61 72 61 6d 73 29 20 0a   dir . params) .
50b0: 20 20 28 6c 65 74 20 28 28 64 70 61 72 74 73 20    (let ((dparts 
50c0: 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 64   (string-split d
50d0: 69 72 20 22 2f 22 29 29 0a 09 28 63 6f 75 6e 74  ir "/"))..(count
50e0: 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 70 61     (if (null? pa
50f0: 72 61 6d 73 29 20 31 20 28 63 61 72 20 70 61 72  rams) 1 (car par
5100: 61 6d 73 29 29 29 29 0a 20 20 20 20 28 63 6f 6e  ams)))).    (con
5110: 63 20 22 2f 22 20 28 73 74 72 69 6e 67 2d 69 6e  c "/" (string-in
5120: 74 65 72 73 70 65 72 73 65 20 0a 09 20 20 20 20  tersperse ..    
5130: 20 20 20 28 74 61 6b 65 20 64 70 61 72 74 73 20     (take dparts 
5140: 28 2d 20 28 6c 65 6e 67 74 68 20 64 70 61 72 74  (- (length dpart
5150: 73 29 20 63 6f 75 6e 74 29 29 0a 09 20 20 20 20  s) count))..    
5160: 20 20 20 22 2f 22 29 29 29 29 0a 3b 3b 20 52 65     "/")))).;; Re
5170: 6d 6f 76 65 20 72 75 6e 73 0a 3b 3b 20 66 69 65  move runs.;; fie
5180: 6c 64 73 20 61 72 65 20 70 61 73 73 69 6e 67 20  lds are passing 
5190: 69 6e 20 74 68 72 6f 75 67 68 20 0a 28 64 65 66  in through .(def
51a0: 69 6e 65 20 28 72 75 6e 73 3a 72 65 6d 6f 76 65  ine (runs:remove
51b0: 2d 72 75 6e 73 20 64 62 20 72 75 6e 6e 61 6d 65  -runs db runname
51c0: 70 61 74 74 20 74 65 73 74 70 61 74 74 20 69 74  patt testpatt it
51d0: 65 6d 70 61 74 74 29 0a 20 20 28 6c 65 74 2a 20  empatt).  (let* 
51e0: 28 28 6b 65 79 73 20 20 20 20 20 20 20 20 28 64  ((keys        (d
51f0: 62 2d 67 65 74 2d 6b 65 79 73 20 64 62 29 29 0a  b-get-keys db)).
5200: 09 20 28 72 75 6e 64 61 74 20 20 20 20 20 20 28  . (rundat      (
5210: 72 75 6e 73 3a 67 65 74 2d 72 75 6e 73 2d 62 79  runs:get-runs-by
5220: 2d 70 61 74 74 20 64 62 20 6b 65 79 73 20 72 75  -patt db keys ru
5230: 6e 6e 61 6d 65 70 61 74 74 29 29 0a 09 20 28 68  nnamepatt)).. (h
5240: 65 61 64 65 72 20 20 20 20 20 20 28 76 65 63 74  eader      (vect
5250: 6f 72 2d 72 65 66 20 72 75 6e 64 61 74 20 30 29  or-ref rundat 0)
5260: 29 0a 09 20 28 72 75 6e 73 20 20 20 20 20 20 20  ).. (runs       
5270: 20 28 76 65 63 74 6f 72 2d 72 65 66 20 72 75 6e   (vector-ref run
5280: 64 61 74 20 31 29 29 29 0a 20 20 20 20 28 64 65  dat 1))).    (de
5290: 62 75 67 3a 70 72 69 6e 74 20 31 20 22 48 65 61  bug:print 1 "Hea
52a0: 64 65 72 3a 20 22 20 68 65 61 64 65 72 29 0a 20  der: " header). 
52b0: 20 20 20 28 66 6f 72 2d 65 61 63 68 0a 20 20 20     (for-each.   
52c0: 20 20 28 6c 61 6d 62 64 61 20 28 72 75 6e 29 0a    (lambda (run).
52d0: 20 20 20 20 20 20 20 28 6c 65 74 20 28 28 72 75         (let ((ru
52e0: 6e 6b 65 79 20 28 73 74 72 69 6e 67 2d 69 6e 74  nkey (string-int
52f0: 65 72 73 70 65 72 73 65 20 28 6d 61 70 20 28 6c  ersperse (map (l
5300: 61 6d 62 64 61 20 28 6b 29 0a 09 09 09 09 09 09  ambda (k).......
5310: 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79  (db:get-value-by
5320: 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64  -header run head
5330: 65 72 20 28 76 65 63 74 6f 72 2d 72 65 66 20 6b  er (vector-ref k
5340: 20 30 29 29 29 20 6b 65 79 73 29 20 22 2f 22 29   0))) keys) "/")
5350: 29 0a 09 20 20 20 20 20 28 64 69 72 73 2d 74 6f  )..     (dirs-to
5360: 2d 72 65 6d 6f 76 65 20 28 6d 61 6b 65 2d 68 61  -remove (make-ha
5370: 73 68 2d 74 61 62 6c 65 29 29 29 0a 09 20 28 6c  sh-table))).. (l
5380: 65 74 2a 20 28 28 72 75 6e 2d 69 64 20 28 64 62  et* ((run-id (db
5390: 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65  :get-value-by-he
53a0: 61 64 65 72 20 72 75 6e 20 68 65 61 64 65 72 20  ader run header 
53b0: 22 69 64 22 29 20 29 0a 09 09 28 74 65 73 74 73  "id") )...(tests
53c0: 20 20 28 64 62 2d 67 65 74 2d 74 65 73 74 73 2d    (db-get-tests-
53d0: 66 6f 72 2d 72 75 6e 20 64 62 20 28 64 62 3a 67  for-run db (db:g
53e0: 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64  et-value-by-head
53f0: 65 72 20 72 75 6e 20 68 65 61 64 65 72 20 22 69  er run header "i
5400: 64 22 29 20 74 65 73 74 70 61 74 74 20 69 74 65  d") testpatt ite
5410: 6d 70 61 74 74 20 27 28 29 20 27 28 29 29 29 0a  mpatt '() '())).
5420: 09 09 28 6c 61 73 74 74 70 61 74 68 20 22 2f 64  ..(lasttpath "/d
5430: 6f 65 73 2f 6e 6f 74 2f 65 78 69 73 74 2f 49 2f  oes/not/exist/I/
5440: 68 6f 70 65 22 29 29 0a 0a 09 20 20 20 28 69 66  hope"))...   (if
5450: 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 65 73   (not (null? tes
5460: 74 73 29 29 0a 09 20 20 20 20 20 20 20 28 62 65  ts))..       (be
5470: 67 69 6e 0a 09 09 20 28 64 65 62 75 67 3a 70 72  gin... (debug:pr
5480: 69 6e 74 20 31 20 22 52 65 6d 6f 76 69 6e 67 20  int 1 "Removing 
5490: 74 65 73 74 73 20 66 6f 72 20 72 75 6e 3a 20 22  tests for run: "
54a0: 20 72 75 6e 6b 65 79 20 22 20 22 20 28 64 62 3a   runkey " " (db:
54b0: 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61  get-value-by-hea
54c0: 64 65 72 20 72 75 6e 20 68 65 61 64 65 72 20 22  der run header "
54d0: 72 75 6e 6e 61 6d 65 22 29 29 0a 09 09 20 28 66  runname"))... (f
54e0: 6f 72 2d 65 61 63 68 0a 09 09 20 20 28 6c 61 6d  or-each...  (lam
54f0: 62 64 61 20 28 74 65 73 74 29 0a 09 09 20 20 20  bda (test)...   
5500: 20 28 6c 65 74 2a 20 28 28 69 74 65 6d 2d 70 61   (let* ((item-pa
5510: 74 68 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  th (db:test-get-
5520: 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 29 29  item-path test))
5530: 0a 09 09 09 20 20 20 28 74 65 73 74 2d 6e 61 6d  ....   (test-nam
5540: 65 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 74  e (db:test-get-t
5550: 65 73 74 6e 61 6d 65 20 74 65 73 74 29 29 0a 09  estname test))..
5560: 09 09 20 20 20 28 72 75 6e 2d 64 69 72 20 20 20  ..   (run-dir   
5570: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 72 75 6e  (db:test-get-run
5580: 64 69 72 20 74 65 73 74 29 29 29 0a 09 09 20 20  dir test)))...  
5590: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
55a0: 20 31 20 22 20 20 22 20 28 64 62 3a 74 65 73 74   1 "  " (db:test
55b0: 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 74 65  -get-testname te
55c0: 73 74 29 20 22 20 69 64 3a 20 22 20 28 64 62 3a  st) " id: " (db:
55d0: 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74  test-get-id test
55e0: 29 20 22 20 22 20 69 74 65 6d 2d 70 61 74 68 29  ) " " item-path)
55f0: 0a 09 09 20 20 20 20 20 20 28 64 62 3a 64 65 6c  ...      (db:del
5600: 65 74 65 2d 74 65 73 74 2d 72 65 63 6f 72 64 73  ete-test-records
5610: 20 64 62 20 28 64 62 3a 74 65 73 74 2d 67 65 74   db (db:test-get
5620: 2d 69 64 20 74 65 73 74 29 29 0a 09 09 20 20 20  -id test))...   
5630: 20 20 20 28 69 66 20 28 3e 20 28 73 74 72 69 6e     (if (> (strin
5640: 67 2d 6c 65 6e 67 74 68 20 72 75 6e 2d 64 69 72  g-length run-dir
5650: 29 20 35 29 20 3b 3b 20 62 61 64 20 68 65 75 72  ) 5) ;; bad heur
5660: 69 73 74 69 63 20 62 75 74 20 73 68 6f 75 6c 64  istic but should
5670: 20 70 72 65 76 65 6e 74 20 2f 74 6d 70 20 2f 68   prevent /tmp /h
5680: 6f 6d 65 20 65 74 63 2e 0a 09 09 09 20 20 28 6c  ome etc.....  (l
5690: 65 74 20 28 28 66 75 6c 6c 70 61 74 68 20 72 75  et ((fullpath ru
56a0: 6e 2d 64 69 72 29 29 20 3b 3b 20 22 2f 22 20 28  n-dir)) ;; "/" (
56b0: 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d  db:test-get-item
56c0: 2d 70 61 74 68 20 74 65 73 74 29 29 29 29 0a 09  -path test))))..
56d0: 09 09 20 20 20 20 28 73 65 74 21 20 6c 61 73 74  ..    (set! last
56e0: 74 70 61 74 68 20 66 75 6c 6c 70 61 74 68 29 0a  tpath fullpath).
56f0: 09 09 09 20 20 20 20 28 68 61 73 68 2d 74 61 62  ...    (hash-tab
5700: 6c 65 2d 73 65 74 21 20 64 69 72 73 2d 74 6f 2d  le-set! dirs-to-
5710: 72 65 6d 6f 76 65 20 66 75 6c 6c 70 61 74 68 20  remove fullpath 
5720: 23 74 29 0a 09 09 09 20 20 20 20 3b 3b 20 54 68  #t)....    ;; Th
5730: 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 77 61 73 20  e following was 
5740: 74 68 65 20 73 61 66 65 20 64 65 6c 65 74 65 20  the safe delete 
5750: 63 6f 64 65 20 62 75 74 20 69 74 20 77 61 73 20  code but it was 
5760: 6e 6f 74 20 62 65 69 6e 67 20 65 78 65 63 74 75  not being exectu
5770: 74 65 64 2e 0a 09 09 09 20 20 20 20 3b 3b 20 28  ted.....    ;; (
5780: 6c 65 74 2a 20 28 28 64 69 72 73 2d 63 6f 75 6e  let* ((dirs-coun
5790: 74 20 28 2b 20 31 20 28 6c 65 6e 67 74 68 20 6b  t (+ 1 (length k
57a0: 65 79 73 29 28 6c 65 6e 67 74 68 20 28 73 74 72  eys)(length (str
57b0: 69 6e 67 2d 73 70 6c 69 74 20 69 74 65 6d 2d 70  ing-split item-p
57c0: 61 74 68 20 22 2f 22 29 29 29 29 0a 09 09 09 20  ath "/")))).... 
57d0: 20 20 20 3b 3b 20 20 20 20 20 20 20 20 28 64 69     ;;        (di
57e0: 72 2d 74 6f 2d 72 65 6d 20 28 67 65 74 2d 64 69  r-to-rem (get-di
57f0: 72 2d 75 70 2d 6e 20 66 75 6c 6c 70 61 74 68 20  r-up-n fullpath 
5800: 64 69 72 73 2d 63 6f 75 6e 74 29 29 0a 09 09 09  dirs-count))....
5810: 20 20 20 20 3b 3b 20 20 20 20 20 20 20 20 28 72      ;;        (r
5820: 65 6d 61 69 6e 69 6e 67 64 20 28 73 74 72 69 6e  emainingd (strin
5830: 67 2d 73 75 62 73 74 69 74 75 74 65 20 28 72 65  g-substitute (re
5840: 67 65 78 70 20 28 63 6f 6e 63 20 22 5e 22 20 64  gexp (conc "^" d
5850: 69 72 2d 74 6f 2d 72 65 6d 20 22 2f 22 29 29 20  ir-to-rem "/")) 
5860: 22 22 20 66 75 6c 6c 70 61 74 68 29 29 0a 09 09  "" fullpath))...
5870: 09 20 20 20 20 3b 3b 20 20 20 20 20 20 20 20 28  .    ;;        (
5880: 63 6d 64 20 28 63 6f 6e 63 20 22 63 64 20 22 20  cmd (conc "cd " 
5890: 64 69 72 2d 74 6f 2d 72 65 6d 20 22 3b 20 72 6d  dir-to-rem "; rm
58a0: 64 69 72 20 2d 70 20 22 20 72 65 6d 61 69 6e 69  dir -p " remaini
58b0: 6e 67 64 20 29 29 29 0a 09 09 09 20 20 20 20 3b  ngd )))....    ;
58c0: 3b 20 20 20 28 69 66 20 28 66 69 6c 65 2d 65 78  ;   (if (file-ex
58d0: 69 73 74 73 3f 20 66 75 6c 6c 70 61 74 68 29 0a  ists? fullpath).
58e0: 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20 20 20  ...    ;;       
58f0: 28 62 65 67 69 6e 0a 09 09 09 20 20 20 20 3b 3b  (begin....    ;;
5900: 20 20 20 20 20 20 20 20 20 28 64 65 62 75 67 3a           (debug:
5910: 70 72 69 6e 74 20 31 20 63 6d 64 29 0a 09 09 09  print 1 cmd)....
5920: 20 20 20 20 3b 3b 20 20 20 20 20 20 20 20 20 28      ;;         (
5930: 73 79 73 74 65 6d 20 63 6d 64 29 29 29 0a 09 09  system cmd)))...
5940: 09 20 20 20 20 3b 3b 20 20 20 29 29 0a 09 09 09  .    ;;   ))....
5950: 20 20 20 20 29 29 29 29 0a 09 09 20 20 20 20 74      ))))...    t
5960: 65 73 74 73 29 29 29 0a 0a 09 20 20 20 3b 3b 20  ests)))...   ;; 
5970: 6c 6f 6f 6b 20 74 68 6f 75 67 68 20 74 68 65 20  look though the 
5980: 64 69 72 73 2d 74 6f 2d 72 65 6d 6f 76 65 20 66  dirs-to-remove f
5990: 6f 72 20 63 61 6e 64 69 64 61 74 65 73 20 66 6f  or candidates fo
59a0: 72 20 72 65 6d 6f 76 61 6c 2e 20 44 6f 20 74 68  r removal. Do th
59b0: 69 73 20 61 66 74 65 72 20 64 65 6c 65 74 69 6e  is after deletin
59c0: 67 20 74 68 65 20 72 65 63 6f 72 64 73 0a 09 20  g the records.. 
59d0: 20 20 3b 3b 20 66 6f 72 20 65 61 63 68 20 74 65    ;; for each te
59e0: 73 74 20 69 6e 20 63 61 73 65 20 77 65 20 67 65  st in case we ge
59f0: 74 20 6b 69 6c 6c 65 64 2e 20 54 68 61 74 20 73  t killed. That s
5a00: 68 6f 75 6c 64 20 6d 69 6e 69 6d 69 7a 65 20 74  hould minimize t
5a10: 68 65 20 64 65 74 72 69 74 75 73 20 6c 65 66 74  he detritus left
5a20: 20 6f 6e 20 64 69 73 6b 0a 09 20 20 20 3b 3b 20   on disk..   ;; 
5a30: 70 72 6f 63 65 73 73 20 74 68 65 20 64 69 72 73  process the dirs
5a40: 20 66 72 6f 6d 20 6c 6f 6e 67 65 73 74 20 73 74   from longest st
5a50: 72 69 6e 67 20 6c 65 6e 67 74 68 20 74 6f 20 73  ring length to s
5a60: 68 6f 72 74 65 73 74 0a 09 20 20 20 28 66 6f 72  hortest..   (for
5a70: 2d 65 61 63 68 20 0a 09 20 20 20 20 28 6c 61 6d  -each ..    (lam
5a80: 62 64 61 20 28 64 69 72 2d 74 6f 2d 72 65 6d 6f  bda (dir-to-remo
5a90: 76 65 29 0a 09 20 20 20 20 20 20 28 69 66 20 28  ve)..      (if (
5aa0: 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 64 69 72  file-exists? dir
5ab0: 2d 74 6f 2d 72 65 6d 6f 76 65 29 0a 09 09 20 20  -to-remove)...  
5ac0: 28 6c 65 74 20 28 28 64 69 72 2d 69 6e 2d 64 62  (let ((dir-in-db
5ad0: 20 27 28 29 29 29 0a 09 09 20 20 20 20 28 73 71   '()))...    (sq
5ae0: 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72  lite3:for-each-r
5af0: 6f 77 0a 09 09 20 20 20 20 20 28 6c 61 6d 62 64  ow...     (lambd
5b00: 61 20 28 64 69 72 29 0a 09 09 20 20 20 20 20 20  a (dir)...      
5b10: 20 28 73 65 74 21 20 64 69 72 2d 69 6e 2d 64 62   (set! dir-in-db
5b20: 20 28 63 6f 6e 73 20 64 69 72 20 64 69 72 2d 69   (cons dir dir-i
5b30: 6e 2d 64 62 29 29 29 0a 09 09 20 20 20 20 20 64  n-db)))...     d
5b40: 62 20 22 53 45 4c 45 43 54 20 72 75 6e 64 69 72  b "SELECT rundir
5b50: 20 46 52 4f 4d 20 74 65 73 74 73 20 57 48 45 52   FROM tests WHER
5b60: 45 20 72 75 6e 64 69 72 20 4c 49 4b 45 20 3f 3b  E rundir LIKE ?;
5b70: 22 20 0a 09 09 20 20 20 20 20 28 63 6f 6e 63 20  " ...     (conc 
5b80: 22 25 22 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76  "%" dir-to-remov
5b90: 65 20 22 25 22 29 29 20 3b 3b 20 79 65 73 2c 20  e "%")) ;; yes, 
5ba0: 49 27 6d 20 67 6f 69 6e 67 20 74 6f 20 62 61 69  I'm going to bai
5bb0: 6c 20 69 66 20 74 68 65 72 65 20 69 73 20 61 6e  l if there is an
5bc0: 79 74 68 69 6e 67 20 6c 69 6b 65 20 74 68 69 73  ything like this
5bd0: 20 64 69 72 20 69 6e 20 74 68 65 20 64 62 0a 09   dir in the db..
5be0: 09 20 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20  .    (if (null? 
5bf0: 64 69 72 2d 69 6e 2d 64 62 29 0a 09 09 09 28 62  dir-in-db)....(b
5c00: 65 67 69 6e 0a 09 09 09 20 20 28 64 65 62 75 67  egin....  (debug
5c10: 3a 70 72 69 6e 74 20 32 20 22 52 65 6d 6f 76 69  :print 2 "Removi
5c20: 6e 67 20 64 69 72 65 63 74 6f 72 79 20 77 69 74  ng directory wit
5c30: 68 20 7a 65 72 6f 20 64 62 20 72 65 66 65 72 65  h zero db refere
5c40: 6e 63 65 73 3a 20 22 20 64 69 72 2d 74 6f 2d 72  nces: " dir-to-r
5c50: 65 6d 6f 76 65 29 0a 09 09 09 20 20 28 73 79 73  emove)....  (sys
5c60: 74 65 6d 20 28 63 6f 6e 63 20 22 72 6d 20 2d 72  tem (conc "rm -r
5c70: 66 20 22 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76  f " dir-to-remov
5c80: 65 29 29 0a 09 09 09 20 20 28 68 61 73 68 2d 74  e))....  (hash-t
5c90: 61 62 6c 65 2d 64 65 6c 65 74 65 21 20 64 69 72  able-delete! dir
5ca0: 73 2d 74 6f 2d 72 65 6d 6f 76 65 20 64 69 72 2d  s-to-remove dir-
5cb0: 74 6f 2d 72 65 6d 6f 76 65 29 29 0a 09 09 09 28  to-remove))....(
5cc0: 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 53  debug:print 2 "S
5cd0: 6b 69 70 70 69 6e 67 20 72 65 6d 6f 76 61 6c 20  kipping removal 
5ce0: 6f 66 20 22 20 64 69 72 2d 74 6f 2d 72 65 6d 6f  of " dir-to-remo
5cf0: 76 65 20 22 20 66 6f 72 20 6e 6f 77 20 61 73 20  ve " for now as 
5d00: 69 74 20 73 74 69 6c 6c 20 68 61 73 20 72 65 66  it still has ref
5d10: 65 72 65 6e 63 65 73 20 69 6e 20 74 68 65 20 64  erences in the d
5d20: 61 74 61 62 61 73 65 22 29 29 29 29 29 0a 09 20  atabase"))))).. 
5d30: 20 20 20 28 73 6f 72 74 20 28 68 61 73 68 2d 74     (sort (hash-t
5d40: 61 62 6c 65 2d 6b 65 79 73 20 64 69 72 73 2d 74  able-keys dirs-t
5d50: 6f 2d 72 65 6d 6f 76 65 29 20 28 6c 61 6d 62 64  o-remove) (lambd
5d60: 61 20 28 61 20 62 29 28 3e 20 28 73 74 72 69 6e  a (a b)(> (strin
5d70: 67 2d 6c 65 6e 67 74 68 20 61 29 28 73 74 72 69  g-length a)(stri
5d80: 6e 67 2d 6c 65 6e 67 74 68 20 62 29 29 29 29 29  ng-length b)))))
5d90: 0a 0a 09 20 20 20 3b 3b 20 72 65 6d 6f 76 65 20  ...   ;; remove 
5da0: 74 68 65 20 72 75 6e 20 69 66 20 7a 65 72 6f 20  the run if zero 
5db0: 74 65 73 74 73 20 72 65 6d 61 69 6e 0a 09 20 20  tests remain..  
5dc0: 20 28 6c 65 74 20 28 28 72 65 6d 74 65 73 74 73   (let ((remtests
5dd0: 20 28 64 62 2d 67 65 74 2d 74 65 73 74 73 2d 66   (db-get-tests-f
5de0: 6f 72 2d 72 75 6e 20 64 62 20 28 64 62 3a 67 65  or-run db (db:ge
5df0: 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65  t-value-by-heade
5e00: 72 20 72 75 6e 20 68 65 61 64 65 72 20 22 69 64  r run header "id
5e10: 22 29 20 23 66 20 23 66 20 27 28 29 20 27 28 29  ") #f #f '() '()
5e20: 29 29 29 0a 09 20 20 20 20 20 28 69 66 20 28 6e  )))..     (if (n
5e30: 75 6c 6c 3f 20 72 65 6d 74 65 73 74 73 29 20 3b  ull? remtests) ;
5e40: 3b 20 6e 6f 20 6d 6f 72 65 20 74 65 73 74 73 20  ; no more tests 
5e50: 72 65 6d 61 69 6e 69 6e 67 0a 09 09 20 28 6c 65  remaining... (le
5e60: 74 2a 20 28 28 64 70 61 72 74 73 20 20 28 73 74  t* ((dparts  (st
5e70: 72 69 6e 67 2d 73 70 6c 69 74 20 6c 61 73 74 74  ring-split lastt
5e80: 70 61 74 68 20 22 2f 22 29 29 0a 09 09 09 28 72  path "/"))....(r
5e90: 75 6e 70 61 74 68 20 28 63 6f 6e 63 20 22 2f 22  unpath (conc "/"
5ea0: 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70   (string-intersp
5eb0: 65 72 73 65 20 0a 09 09 09 09 09 20 20 20 20 28  erse ......    (
5ec0: 74 61 6b 65 20 64 70 61 72 74 73 20 28 2d 20 28  take dparts (- (
5ed0: 6c 65 6e 67 74 68 20 64 70 61 72 74 73 29 20 31  length dparts) 1
5ee0: 29 29 0a 09 09 09 09 09 20 20 20 20 22 2f 22 29  ))......    "/")
5ef0: 29 29 29 0a 09 09 20 20 20 28 64 65 62 75 67 3a  )))...   (debug:
5f00: 70 72 69 6e 74 20 31 20 22 52 65 6d 6f 76 69 6e  print 1 "Removin
5f10: 67 20 72 75 6e 3a 20 22 20 72 75 6e 6b 65 79 20  g run: " runkey 
5f20: 22 20 22 20 28 64 62 3a 67 65 74 2d 76 61 6c 75  " " (db:get-valu
5f30: 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20  e-by-header run 
5f40: 68 65 61 64 65 72 20 22 72 75 6e 6e 61 6d 65 22  header "runname"
5f50: 29 29 0a 09 09 20 20 20 28 64 62 3a 64 65 6c 65  ))...   (db:dele
5f60: 74 65 2d 72 75 6e 20 64 62 20 72 75 6e 2d 69 64  te-run db run-id
5f70: 29 0a 09 09 20 20 20 3b 3b 20 6e 65 65 64 20 74  )...   ;; need t
5f80: 6f 20 66 69 67 75 72 65 20 6f 75 74 20 74 68 65  o figure out the
5f90: 20 70 61 74 68 20 74 6f 20 74 68 65 20 72 75 6e   path to the run
5fa0: 20 64 69 72 20 61 6e 64 20 72 65 6d 6f 76 65 20   dir and remove 
5fb0: 69 74 20 69 66 20 65 6d 70 74 79 0a 09 09 20 20  it if empty...  
5fc0: 20 3b 3b 20 20 20 20 28 69 66 20 28 6e 75 6c 6c   ;;    (if (null
5fd0: 3f 20 28 67 6c 6f 62 20 28 63 6f 6e 63 20 72 75  ? (glob (conc ru
5fe0: 6e 70 61 74 68 20 22 2f 2a 22 29 29 29 0a 09 09  npath "/*")))...
5ff0: 20 20 20 3b 3b 20 20 20 20 20 20 20 20 28 62 65     ;;        (be
6000: 67 69 6e 0a 09 09 20 20 20 3b 3b 20 09 20 28 64  gin...   ;; . (d
6010: 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 52 65  ebug:print 1 "Re
6020: 6d 6f 76 69 6e 67 20 72 75 6e 20 64 69 72 20 22  moving run dir "
6030: 20 72 75 6e 70 61 74 68 29 0a 09 09 20 20 20 3b   runpath)...   ;
6040: 3b 20 09 20 28 73 79 73 74 65 6d 20 28 63 6f 6e  ; . (system (con
6050: 63 20 22 72 6d 64 69 72 20 2d 70 20 22 20 72 75  c "rmdir -p " ru
6060: 6e 70 61 74 68 29 29 29 29 0a 09 09 20 20 20 29  npath))))...   )
6070: 29 29 29 0a 09 20 29 29 0a 20 20 20 20 20 72 75  ))).. )).     ru
6080: 6e 73 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d  ns)))..;;=======
6090: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
60a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
60b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
60c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a  ===============.
60d0: 3b 3b 20 52 6f 75 74 69 6e 65 73 20 66 6f 72 20  ;; Routines for 
60e0: 6d 61 6e 69 70 75 6c 61 74 69 6e 67 20 72 75 6e  manipulating run
60f0: 73 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  s.;;============
6100: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6110: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6120: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6130: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 53  ==========..;; S
6140: 69 6e 63 65 20 6d 61 6e 79 20 63 61 6c 6c 73 20  ince many calls 
6150: 74 6f 20 61 20 72 75 6e 20 72 65 71 75 69 72 65  to a run require
6160: 20 70 72 65 74 74 79 20 6d 75 63 68 20 74 68 65   pretty much the
6170: 20 73 61 6d 65 20 73 65 74 75 70 20 0a 3b 3b 20   same setup .;; 
6180: 74 68 69 73 20 77 72 61 70 70 65 72 20 69 73 20  this wrapper is 
6190: 75 73 65 64 20 74 6f 20 72 65 64 75 63 65 20 74  used to reduce t
61a0: 68 65 20 72 65 70 6c 69 63 61 74 69 6f 6e 20 6f  he replication o
61b0: 66 20 63 6f 64 65 0a 28 64 65 66 69 6e 65 20 28  f code.(define (
61c0: 67 65 6e 65 72 61 6c 2d 72 75 6e 2d 63 61 6c 6c  general-run-call
61d0: 20 73 77 69 74 63 68 6e 61 6d 65 20 61 63 74 69   switchname acti
61e0: 6f 6e 2d 64 65 73 63 20 70 72 6f 63 29 0a 20 20  on-desc proc).  
61f0: 28 6c 65 74 20 28 28 72 75 6e 6e 61 6d 65 20 28  (let ((runname (
6200: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 3a 72  args:get-arg ":r
6210: 75 6e 6e 61 6d 65 22 29 29 0a 09 28 74 61 72 67  unname"))..(targ
6220: 65 74 20 20 28 69 66 20 28 61 72 67 73 3a 67 65  et  (if (args:ge
6230: 74 2d 61 72 67 20 22 2d 74 61 72 67 65 74 22 29  t-arg "-target")
6240: 0a 09 09 20 20 20 20 20 28 61 72 67 73 3a 67 65  ...     (args:ge
6250: 74 2d 61 72 67 20 22 2d 74 61 72 67 65 74 22 29  t-arg "-target")
6260: 0a 09 09 20 20 20 20 20 28 61 72 67 73 3a 67 65  ...     (args:ge
6270: 74 2d 61 72 67 20 22 2d 72 65 71 74 61 72 67 22  t-arg "-reqtarg"
6280: 29 29 29 29 0a 20 20 20 20 28 63 6f 6e 64 0a 20  )))).    (cond. 
6290: 20 20 20 20 28 28 6e 6f 74 20 74 61 72 67 65 74      ((not target
62a0: 29 0a 20 20 20 20 20 20 28 64 65 62 75 67 3a 70  ).      (debug:p
62b0: 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 4d  rint 0 "ERROR: M
62c0: 69 73 73 69 6e 67 20 72 65 71 75 69 72 65 64 20  issing required 
62d0: 70 61 72 61 6d 65 74 65 72 20 66 6f 72 20 22 20  parameter for " 
62e0: 73 77 69 74 63 68 6e 61 6d 65 20 22 2c 20 79 6f  switchname ", yo
62f0: 75 20 6d 75 73 74 20 73 70 65 63 69 66 79 20 74  u must specify t
6300: 68 65 20 74 61 72 67 65 74 20 77 69 74 68 20 2d  he target with -
6310: 74 61 72 67 65 74 22 29 0a 20 20 20 20 20 20 28  target").      (
6320: 65 78 69 74 20 33 29 29 0a 20 20 20 20 20 28 28  exit 3)).     ((
6330: 6e 6f 74 20 72 75 6e 6e 61 6d 65 29 0a 20 20 20  not runname).   
6340: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
6350: 30 20 22 45 52 52 4f 52 3a 20 4d 69 73 73 69 6e  0 "ERROR: Missin
6360: 67 20 72 65 71 75 69 72 65 64 20 70 61 72 61 6d  g required param
6370: 65 74 65 72 20 66 6f 72 20 22 20 73 77 69 74 63  eter for " switc
6380: 68 6e 61 6d 65 20 22 2c 20 79 6f 75 20 6d 75 73  hname ", you mus
6390: 74 20 73 70 65 63 69 66 79 20 74 68 65 20 72 75  t specify the ru
63a0: 6e 20 6e 61 6d 65 20 77 69 74 68 20 3a 72 75 6e  n name with :run
63b0: 6e 61 6d 65 20 72 75 6e 6e 61 6d 65 22 29 0a 20  name runname"). 
63c0: 20 20 20 20 20 28 65 78 69 74 20 33 29 29 0a 20       (exit 3)). 
63d0: 20 20 20 20 28 65 6c 73 65 0a 20 20 20 20 20 20      (else.      
63e0: 28 6c 65 74 20 28 28 64 62 20 20 20 23 66 29 0a  (let ((db   #f).
63f0: 09 20 20 20 20 28 6b 65 79 73 20 23 66 29 29 0a  .    (keys #f)).
6400: 09 28 69 66 20 28 6e 6f 74 20 28 73 65 74 75 70  .(if (not (setup
6410: 2d 66 6f 72 2d 72 75 6e 29 29 0a 09 20 20 20 20  -for-run))..    
6420: 28 62 65 67 69 6e 20 0a 09 20 20 20 20 20 20 28  (begin ..      (
6430: 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 46  debug:print 0 "F
6440: 61 69 6c 65 64 20 74 6f 20 73 65 74 75 70 2c 20  ailed to setup, 
6450: 65 78 69 74 69 6e 67 22 29 0a 09 20 20 20 20 20  exiting")..     
6460: 20 28 65 78 69 74 20 31 29 29 29 0a 09 28 73 65   (exit 1)))..(se
6470: 74 21 20 64 62 20 20 20 28 6f 70 65 6e 2d 64 62  t! db   (open-db
6480: 29 29 0a 09 28 73 65 74 21 20 6b 65 79 73 20 28  ))..(set! keys (
6490: 64 62 2d 67 65 74 2d 6b 65 79 73 20 64 62 29 29  db-get-keys db))
64a0: 0a 09 3b 3b 20 68 61 76 65 20 65 6e 6f 75 67 68  ..;; have enough
64b0: 20 74 6f 20 70 72 6f 63 65 73 73 20 2d 74 61 72   to process -tar
64c0: 67 65 74 20 6f 72 20 2d 72 65 71 74 61 72 67 20  get or -reqtarg 
64d0: 68 65 72 65 0a 09 28 69 66 20 28 61 72 67 73 3a  here..(if (args:
64e0: 67 65 74 2d 61 72 67 20 22 2d 72 65 71 74 61 72  get-arg "-reqtar
64f0: 67 22 29 0a 09 20 20 20 20 28 6c 65 74 2a 20 28  g")..    (let* (
6500: 28 72 75 6e 63 6f 6e 66 69 67 66 20 28 63 6f 6e  (runconfigf (con
6510: 63 20 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f 72  c  *toppath* "/r
6520: 75 6e 63 6f 6e 66 69 67 73 2e 63 6f 6e 66 69 67  unconfigs.config
6530: 22 29 29 20 3b 3b 20 44 4f 20 4e 4f 54 20 45 56  ")) ;; DO NOT EV
6540: 41 4c 55 41 54 45 20 41 4c 4c 20 0a 09 09 20 20  ALUATE ALL ...  
6550: 20 28 72 75 6e 63 6f 6e 66 69 67 20 20 28 72 65   (runconfig  (re
6560: 61 64 2d 63 6f 6e 66 69 67 20 72 75 6e 63 6f 6e  ad-config runcon
6570: 66 69 67 66 20 23 66 20 23 66 20 65 6e 76 69 72  figf #f #f envir
6580: 6f 6e 2d 70 61 74 74 3a 20 23 66 29 29 29 20 0a  on-patt: #f))) .
6590: 09 20 20 20 20 20 20 28 69 66 20 28 68 61 73 68  .      (if (hash
65a0: 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75  -table-ref/defau
65b0: 6c 74 20 72 75 6e 63 6f 6e 66 69 67 20 28 61 72  lt runconfig (ar
65c0: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65 71  gs:get-arg "-req
65d0: 74 61 72 67 22 29 20 23 66 29 0a 09 09 20 20 28  targ") #f)...  (
65e0: 6b 65 79 73 3a 74 61 72 67 65 74 2d 73 65 74 2d  keys:target-set-
65f0: 61 72 67 73 20 6b 65 79 73 20 28 61 72 67 73 3a  args keys (args:
6600: 67 65 74 2d 61 72 67 20 22 2d 72 65 71 74 61 72  get-arg "-reqtar
6610: 67 22 29 20 61 72 67 73 3a 61 72 67 2d 68 61 73  g") args:arg-has
6620: 68 29 0a 09 09 20 20 28 62 65 67 69 6e 0a 09 09  h)...  (begin...
6630: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
6640: 20 30 20 22 45 52 52 4f 52 3a 20 5b 22 20 28 61   0 "ERROR: [" (a
6650: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65  rgs:get-arg "-re
6660: 71 74 61 72 67 22 29 20 22 5d 20 6e 6f 74 20 66  qtarg") "] not f
6670: 6f 75 6e 64 20 69 6e 20 22 20 72 75 6e 63 6f 6e  ound in " runcon
6680: 66 69 67 66 29 0a 09 09 20 20 20 20 28 73 71 6c  figf)...    (sql
6690: 69 74 65 33 3a 66 69 6e 61 6c 69 7a 65 21 20 64  ite3:finalize! d
66a0: 62 29 0a 09 09 20 20 20 20 28 65 78 69 74 20 31  b)...    (exit 1
66b0: 29 29 29 29 0a 09 20 20 20 20 28 69 66 20 28 61  ))))..    (if (a
66c0: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 74 61  rgs:get-arg "-ta
66d0: 72 67 65 74 22 29 0a 09 09 28 6b 65 79 73 3a 74  rget")...(keys:t
66e0: 61 72 67 65 74 2d 73 65 74 2d 61 72 67 73 20 6b  arget-set-args k
66f0: 65 79 73 20 28 61 72 67 73 3a 67 65 74 2d 61 72  eys (args:get-ar
6700: 67 20 22 2d 74 61 72 67 65 74 22 20 61 72 67 73  g "-target" args
6710: 3a 61 72 67 2d 68 61 73 68 29 20 61 72 67 73 3a  :arg-hash) args:
6720: 61 72 67 2d 68 61 73 68 29 29 29 0a 09 28 69 66  arg-hash)))..(if
6730: 20 28 6e 6f 74 20 28 63 61 72 20 2a 63 6f 6e 66   (not (car *conf
6740: 69 67 69 6e 66 6f 2a 29 29 0a 09 20 20 20 20 28  iginfo*))..    (
6750: 62 65 67 69 6e 0a 09 20 20 20 20 20 20 28 64 65  begin..      (de
6760: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52  bug:print 0 "ERR
6770: 4f 52 3a 20 41 74 74 65 6d 70 74 65 64 20 74 6f  OR: Attempted to
6780: 20 22 20 61 63 74 69 6f 6e 2d 64 65 73 63 20 22   " action-desc "
6790: 20 62 75 74 20 72 75 6e 20 61 72 65 61 20 63 6f   but run area co
67a0: 6e 66 69 67 20 66 69 6c 65 20 6e 6f 74 20 66 6f  nfig file not fo
67b0: 75 6e 64 22 29 0a 09 20 20 20 20 20 20 28 65 78  und")..      (ex
67c0: 69 74 20 31 29 29 0a 09 20 20 20 20 3b 3b 20 45  it 1))..    ;; E
67d0: 78 74 72 61 63 74 20 6f 75 74 20 73 74 75 66 66  xtract out stuff
67e0: 20 6e 65 65 64 65 64 20 69 6e 20 6d 6f 73 74 20   needed in most 
67f0: 6f 72 20 6d 61 6e 79 20 63 61 6c 6c 73 0a 09 20  or many calls.. 
6800: 20 20 20 3b 3b 20 68 65 72 65 20 74 68 65 6e 20     ;; here then 
6810: 63 61 6c 6c 20 70 72 6f 63 0a 09 20 20 20 20 28  call proc..    (
6820: 6c 65 74 2a 20 28 28 6b 65 79 6e 61 6d 65 73 20  let* ((keynames 
6830: 20 20 28 6d 61 70 20 6b 65 79 3a 67 65 74 2d 66    (map key:get-f
6840: 69 65 6c 64 6e 61 6d 65 20 6b 65 79 73 29 29 0a  ieldname keys)).
6850: 09 09 20 20 20 28 6b 65 79 76 61 6c 6c 73 74 20  ..   (keyvallst 
6860: 20 28 6b 65 79 73 2d 3e 76 61 6c 6c 69 73 74 20   (keys->vallist 
6870: 6b 65 79 73 20 23 74 29 29 29 0a 09 20 20 20 20  keys #t)))..    
6880: 20 20 28 70 72 6f 63 20 64 62 20 74 61 72 67 65    (proc db targe
6890: 74 20 72 75 6e 6e 61 6d 65 20 6b 65 79 73 20 6b  t runname keys k
68a0: 65 79 6e 61 6d 65 73 20 6b 65 79 76 61 6c 6c 73  eynames keyvalls
68b0: 74 29 29 29 0a 09 28 73 71 6c 69 74 65 33 3a 66  t)))..(sqlite3:f
68c0: 69 6e 61 6c 69 7a 65 21 20 64 62 29 0a 09 28 73  inalize! db)..(s
68d0: 65 74 21 20 2a 64 69 64 73 6f 6d 65 74 68 69 6e  et! *didsomethin
68e0: 67 2a 20 23 74 29 29 29 29 29 29 0a 0a 3b 3b 3d  g* #t))))))..;;=
68f0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6900: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6910: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6920: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6930: 3d 3d 3d 3d 3d 0a 3b 3b 20 52 6f 6c 6c 75 70 20  =====.;; Rollup 
6940: 72 75 6e 73 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d  runs.;;=========
6950: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6960: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6970: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6980: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b  =============..;
6990: 3b 20 55 70 64 61 74 65 20 74 68 65 20 74 65 73  ; Update the tes
69a0: 74 5f 6d 65 74 61 20 74 61 62 6c 65 20 66 6f 72  t_meta table for
69b0: 20 74 68 69 73 20 74 65 73 74 0a 28 64 65 66 69   this test.(defi
69c0: 6e 65 20 28 72 75 6e 73 3a 75 70 64 61 74 65 2d  ne (runs:update-
69d0: 74 65 73 74 5f 6d 65 74 61 20 64 62 20 74 65 73  test_meta db tes
69e0: 74 2d 6e 61 6d 65 20 74 65 73 74 2d 63 6f 6e 66  t-name test-conf
69f0: 29 0a 20 20 28 6c 65 74 20 28 28 63 75 72 72 72  ).  (let ((currr
6a00: 65 63 6f 72 64 20 28 64 62 3a 74 65 73 74 6d 65  ecord (db:testme
6a10: 74 61 2d 67 65 74 2d 72 65 63 6f 72 64 20 64 62  ta-get-record db
6a20: 20 74 65 73 74 2d 6e 61 6d 65 29 29 29 0a 20 20   test-name))).  
6a30: 20 20 28 69 66 20 28 6e 6f 74 20 63 75 72 72 72    (if (not currr
6a40: 65 63 6f 72 64 29 0a 09 28 62 65 67 69 6e 0a 09  ecord)..(begin..
6a50: 20 20 28 73 65 74 21 20 63 75 72 72 72 65 63 6f    (set! currreco
6a60: 72 64 20 28 6d 61 6b 65 2d 76 65 63 74 6f 72 20  rd (make-vector 
6a70: 31 30 20 23 66 29 29 0a 09 20 20 28 64 62 3a 74  10 #f))..  (db:t
6a80: 65 73 74 6d 65 74 61 2d 61 64 64 2d 72 65 63 6f  estmeta-add-reco
6a90: 72 64 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 29  rd db test-name)
6aa0: 29 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68  )).    (for-each
6ab0: 20 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28   .     (lambda (
6ac0: 6b 65 79 29 0a 20 20 20 20 20 20 20 28 6c 65 74  key).       (let
6ad0: 2a 20 28 28 69 64 78 20 28 63 61 64 72 20 6b 65  * ((idx (cadr ke
6ae0: 79 29 29 0a 09 20 20 20 20 20 20 28 66 6c 64 20  y))..      (fld 
6af0: 28 63 61 72 20 20 6b 65 79 29 29 0a 09 20 20 20  (car  key))..   
6b00: 20 20 20 28 76 61 6c 20 28 63 6f 6e 66 69 67 2d     (val (config-
6b10: 6c 6f 6f 6b 75 70 20 74 65 73 74 2d 63 6f 6e 66  lookup test-conf
6b20: 20 22 74 65 73 74 5f 6d 65 74 61 22 20 66 6c 64   "test_meta" fld
6b30: 29 29 29 0a 09 20 3b 3b 20 28 64 65 62 75 67 3a  ))).. ;; (debug:
6b40: 70 72 69 6e 74 20 35 20 22 69 64 78 3a 20 22 20  print 5 "idx: " 
6b50: 69 64 78 20 22 20 66 6c 64 3a 20 22 20 66 6c 64  idx " fld: " fld
6b60: 20 22 20 76 61 6c 3a 20 22 20 76 61 6c 29 0a 09   " val: " val)..
6b70: 20 28 69 66 20 28 61 6e 64 20 76 61 6c 20 28 6e   (if (and val (n
6b80: 6f 74 20 28 65 71 75 61 6c 3f 20 28 76 65 63 74  ot (equal? (vect
6b90: 6f 72 2d 72 65 66 20 63 75 72 72 72 65 63 6f 72  or-ref currrecor
6ba0: 64 20 69 64 78 29 20 76 61 6c 29 29 29 0a 09 20  d idx) val))).. 
6bb0: 20 20 20 20 28 62 65 67 69 6e 0a 09 20 20 20 20      (begin..    
6bc0: 20 20 20 28 70 72 69 6e 74 20 22 55 70 64 61 74     (print "Updat
6bd0: 69 6e 67 20 22 20 74 65 73 74 2d 6e 61 6d 65 20  ing " test-name 
6be0: 22 20 22 20 66 6c 64 20 22 20 74 6f 20 22 20 76  " " fld " to " v
6bf0: 61 6c 29 0a 09 20 20 20 20 20 20 20 28 64 62 3a  al)..       (db:
6c00: 74 65 73 74 6d 65 74 61 2d 75 70 64 61 74 65 2d  testmeta-update-
6c10: 66 69 65 6c 64 20 64 62 20 74 65 73 74 2d 6e 61  field db test-na
6c20: 6d 65 20 66 6c 64 20 76 61 6c 29 29 29 29 29 0a  me fld val))))).
6c30: 20 20 20 20 20 27 28 28 22 61 75 74 68 6f 72 22       '(("author"
6c40: 20 32 29 28 22 6f 77 6e 65 72 22 20 33 29 28 22   2)("owner" 3)("
6c50: 64 65 73 63 72 69 70 74 69 6f 6e 22 20 34 29 28  description" 4)(
6c60: 22 72 65 76 69 65 77 65 64 22 20 35 29 28 22 74  "reviewed" 5)("t
6c70: 61 67 73 22 20 39 29 29 29 29 29 0a 0a 3b 3b 20  ags" 9)))))..;; 
6c80: 55 70 64 61 74 65 20 74 65 73 74 5f 6d 65 74 61  Update test_meta
6c90: 20 66 6f 72 20 61 6c 6c 20 74 65 73 74 73 0a 28   for all tests.(
6ca0: 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 75 70 64  define (runs:upd
6cb0: 61 74 65 2d 61 6c 6c 2d 74 65 73 74 5f 6d 65 74  ate-all-test_met
6cc0: 61 20 64 62 29 0a 20 20 28 6c 65 74 20 28 28 74  a db).  (let ((t
6cd0: 65 73 74 2d 6e 61 6d 65 73 20 28 67 65 74 2d 61  est-names (get-a
6ce0: 6c 6c 2d 6c 65 67 61 6c 2d 74 65 73 74 73 29 29  ll-legal-tests))
6cf0: 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20  ).    (for-each 
6d00: 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 74  .     (lambda (t
6d10: 65 73 74 2d 6e 61 6d 65 29 0a 20 20 20 20 20 20  est-name).      
6d20: 20 28 6c 65 74 2a 20 28 28 74 65 73 74 2d 70 61   (let* ((test-pa
6d30: 74 68 20 20 20 20 28 63 6f 6e 63 20 2a 74 6f 70  th    (conc *top
6d40: 70 61 74 68 2a 20 22 2f 74 65 73 74 73 2f 22 20  path* "/tests/" 
6d50: 74 65 73 74 2d 6e 61 6d 65 29 29 0a 09 20 20 20  test-name))..   
6d60: 20 20 20 28 74 65 73 74 2d 63 6f 6e 66 69 67 66     (test-configf
6d70: 20 28 63 6f 6e 63 20 74 65 73 74 2d 70 61 74 68   (conc test-path
6d80: 20 22 2f 74 65 73 74 63 6f 6e 66 69 67 22 29 29   "/testconfig"))
6d90: 0a 09 20 20 20 20 20 20 28 74 65 73 74 65 78 69  ..      (testexi
6da0: 73 74 73 20 20 20 28 61 6e 64 20 28 66 69 6c 65  sts   (and (file
6db0: 2d 65 78 69 73 74 73 3f 20 74 65 73 74 2d 63 6f  -exists? test-co
6dc0: 6e 66 69 67 66 29 28 66 69 6c 65 2d 72 65 61 64  nfigf)(file-read
6dd0: 2d 61 63 63 65 73 73 3f 20 74 65 73 74 2d 63 6f  -access? test-co
6de0: 6e 66 69 67 66 29 29 29 0a 09 20 20 20 20 20 20  nfigf)))..      
6df0: 3b 3b 20 72 65 61 64 20 63 6f 6e 66 69 67 73 20  ;; read configs 
6e00: 77 69 74 68 20 74 72 69 63 6b 73 20 74 75 72 6e  with tricks turn
6e10: 65 64 20 6f 66 66 20 28 69 2e 65 2e 20 6e 6f 20  ed off (i.e. no 
6e20: 73 79 73 74 65 6d 29 0a 09 20 20 20 20 20 20 28  system)..      (
6e30: 74 65 73 74 2d 63 6f 6e 66 20 20 20 20 28 69 66  test-conf    (if
6e40: 20 74 65 73 74 65 78 69 73 74 73 20 28 72 65 61   testexists (rea
6e50: 64 2d 63 6f 6e 66 69 67 20 74 65 73 74 2d 63 6f  d-config test-co
6e60: 6e 66 69 67 66 20 23 66 20 23 66 29 28 6d 61 6b  nfigf #f #f)(mak
6e70: 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29 29 29  e-hash-table))))
6e80: 0a 09 20 28 72 75 6e 73 3a 75 70 64 61 74 65 2d  .. (runs:update-
6e90: 74 65 73 74 5f 6d 65 74 61 20 64 62 20 74 65 73  test_meta db tes
6ea0: 74 2d 6e 61 6d 65 20 74 65 73 74 2d 63 6f 6e 66  t-name test-conf
6eb0: 29 29 29 0a 20 20 20 20 20 74 65 73 74 2d 6e 61  ))).     test-na
6ec0: 6d 65 73 29 29 29 0a 0a 3b 3b 20 54 68 69 73 20  mes)))..;; This 
6ed0: 63 6f 75 6c 64 20 70 72 6f 62 61 62 6c 79 20 62  could probably b
6ee0: 65 20 72 65 66 61 63 74 6f 72 65 64 20 69 6e 74  e refactored int
6ef0: 6f 20 6f 6e 65 20 63 6f 6d 70 6c 65 78 20 71 75  o one complex qu
6f00: 65 72 79 20 2e 2e 2e 0a 28 64 65 66 69 6e 65 20  ery ....(define 
6f10: 28 72 75 6e 73 3a 72 6f 6c 6c 75 70 2d 72 75 6e  (runs:rollup-run
6f20: 20 64 62 20 6b 65 79 73 20 6b 65 79 76 61 6c 6c   db keys keyvall
6f30: 73 74 20 72 75 6e 6e 61 6d 65 20 75 73 65 72 29  st runname user)
6f40: 20 3b 3b 20 77 61 73 20 74 61 72 67 65 74 2c 20   ;; was target, 
6f50: 6e 6f 77 20 6b 65 79 76 61 6c 6c 73 74 0a 20 20  now keyvallst.  
6f60: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22  (debug:print 4 "
6f70: 72 75 6e 73 3a 72 6f 6c 6c 75 70 2d 72 75 6e 2c  runs:rollup-run,
6f80: 20 6b 65 79 73 3a 20 22 20 6b 65 79 73 20 22 20   keys: " keys " 
6f90: 6b 65 79 76 61 6c 6c 73 74 3a 20 22 20 6b 65 79  keyvallst: " key
6fa0: 76 61 6c 6c 73 74 20 22 20 3a 72 75 6e 6e 61 6d  vallst " :runnam
6fb0: 65 20 22 20 72 75 6e 6e 61 6d 65 20 22 20 75 73  e " runname " us
6fc0: 65 72 3a 20 22 20 75 73 65 72 29 0a 20 20 28 6c  er: " user).  (l
6fd0: 65 74 2a 20 28 3b 20 28 6b 65 79 76 61 6c 6c 6c  et* (; (keyvalll
6fe0: 73 74 20 20 20 20 20 20 28 6b 65 79 73 3a 74 61  st      (keys:ta
6ff0: 72 67 65 74 2d 3e 6b 65 79 76 61 6c 20 6b 65 79  rget->keyval key
7000: 73 20 74 61 72 67 65 74 29 29 0a 09 20 28 6e 65  s target)).. (ne
7010: 77 2d 72 75 6e 2d 69 64 20 20 20 20 20 20 28 72  w-run-id      (r
7020: 75 6e 73 3a 72 65 67 69 73 74 65 72 2d 72 75 6e  uns:register-run
7030: 20 64 62 20 6b 65 79 73 20 6b 65 79 76 61 6c 6c   db keys keyvall
7040: 73 74 20 72 75 6e 6e 61 6d 65 20 22 6e 65 77 22  st runname "new"
7050: 20 22 6e 2f 61 22 20 75 73 65 72 29 29 0a 09 20   "n/a" user)).. 
7060: 28 70 72 65 76 2d 74 65 73 74 73 20 20 20 20 20  (prev-tests     
7070: 20 28 74 65 73 74 3a 67 65 74 2d 6d 61 74 63 68   (test:get-match
7080: 69 6e 67 2d 70 72 65 76 69 6f 75 73 2d 74 65 73  ing-previous-tes
7090: 74 2d 72 75 6e 2d 72 65 63 6f 72 64 73 20 64 62  t-run-records db
70a0: 20 6e 65 77 2d 72 75 6e 2d 69 64 20 22 25 22 20   new-run-id "%" 
70b0: 22 25 22 29 29 0a 09 20 28 63 75 72 72 2d 74 65  "%")).. (curr-te
70c0: 73 74 73 20 20 20 20 20 20 28 64 62 2d 67 65 74  sts      (db-get
70d0: 2d 74 65 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64  -tests-for-run d
70e0: 62 20 6e 65 77 2d 72 75 6e 2d 69 64 20 22 25 22  b new-run-id "%"
70f0: 20 22 25 22 20 27 28 29 20 27 28 29 29 29 0a 09   "%" '() '()))..
7100: 20 28 63 75 72 72 2d 74 65 73 74 73 2d 68 61 73   (curr-tests-has
7110: 68 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62  h (make-hash-tab
7120: 6c 65 29 29 29 0a 20 20 20 20 28 64 62 3a 75 70  le))).    (db:up
7130: 64 61 74 65 2d 72 75 6e 2d 65 76 65 6e 74 5f 74  date-run-event_t
7140: 69 6d 65 20 64 62 20 6e 65 77 2d 72 75 6e 2d 69  ime db new-run-i
7150: 64 29 0a 20 20 20 20 3b 3b 20 69 6e 64 65 78 20  d).    ;; index 
7160: 74 68 65 20 61 6c 72 65 61 64 79 20 73 61 76 65  the already save
7170: 64 20 74 65 73 74 73 20 62 79 20 74 65 73 74 6e  d tests by testn
7180: 61 6d 65 20 61 6e 64 20 69 74 65 6d 64 61 74 20  ame and itemdat 
7190: 69 6e 20 63 75 72 72 2d 74 65 73 74 73 2d 68 61  in curr-tests-ha
71a0: 73 68 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68  sh.    (for-each
71b0: 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 74  .     (lambda (t
71c0: 65 73 74 64 61 74 29 0a 20 20 20 20 20 20 20 28  estdat).       (
71d0: 6c 65 74 2a 20 28 28 74 65 73 74 6e 61 6d 65 20  let* ((testname 
71e0: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 74 65   (db:test-get-te
71f0: 73 74 6e 61 6d 65 20 74 65 73 74 64 61 74 29 29  stname testdat))
7200: 0a 09 20 20 20 20 20 20 28 69 74 65 6d 2d 70 61  ..      (item-pa
7210: 74 68 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  th (db:test-get-
7220: 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 64 61  item-path testda
7230: 74 29 29 0a 09 20 20 20 20 20 20 28 66 75 6c 6c  t))..      (full
7240: 2d 6e 61 6d 65 20 28 63 6f 6e 63 20 74 65 73 74  -name (conc test
7250: 6e 61 6d 65 20 22 2f 22 20 69 74 65 6d 2d 70 61  name "/" item-pa
7260: 74 68 29 29 29 0a 09 20 28 68 61 73 68 2d 74 61  th))).. (hash-ta
7270: 62 6c 65 2d 73 65 74 21 20 63 75 72 72 2d 74 65  ble-set! curr-te
7280: 73 74 73 2d 68 61 73 68 20 66 75 6c 6c 2d 6e 61  sts-hash full-na
7290: 6d 65 20 74 65 73 74 64 61 74 29 29 29 0a 20 20  me testdat))).  
72a0: 20 20 20 63 75 72 72 2d 74 65 73 74 73 29 0a 20     curr-tests). 
72b0: 20 20 20 3b 3b 20 4e 4f 50 45 3a 20 4e 6f 6e 2d     ;; NOPE: Non-
72c0: 6f 70 74 69 6d 61 6c 20 61 70 70 72 6f 61 63 68  optimal approach
72d0: 2e 20 54 72 79 20 74 68 69 73 20 69 6e 73 74 65  . Try this inste
72e0: 61 64 2e 0a 20 20 20 20 3b 3b 20 20 20 31 2e 20  ad..    ;;   1. 
72f0: 74 65 73 74 73 20 61 72 65 20 72 65 63 65 69 76  tests are receiv
7300: 65 64 20 69 6e 20 61 20 6c 69 73 74 2c 20 6d 6f  ed in a list, mo
7310: 73 74 20 72 65 63 65 6e 74 20 66 69 72 73 74 0a  st recent first.
7320: 20 20 20 20 3b 3b 20 20 20 32 2e 20 72 65 70 6c      ;;   2. repl
7330: 61 63 65 20 74 68 65 20 72 6f 6c 6c 75 70 20 74  ace the rollup t
7340: 65 73 74 20 77 69 74 68 20 74 68 65 20 6e 65 77  est with the new
7350: 20 2a 61 6c 77 61 79 73 2a 0a 20 20 20 20 28 66   *always*.    (f
7360: 6f 72 2d 65 61 63 68 20 0a 20 20 20 20 20 28 6c  or-each .     (l
7370: 61 6d 62 64 61 20 28 74 65 73 74 64 61 74 29 0a  ambda (testdat).
7380: 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28 28 74         (let* ((t
7390: 65 73 74 6e 61 6d 65 20 20 28 64 62 3a 74 65 73  estname  (db:tes
73a0: 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 74  t-get-testname t
73b0: 65 73 74 64 61 74 29 29 0a 09 20 20 20 20 20 20  estdat))..      
73c0: 28 69 74 65 6d 2d 70 61 74 68 20 28 64 62 3a 74  (item-path (db:t
73d0: 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74  est-get-item-pat
73e0: 68 20 74 65 73 74 64 61 74 29 29 0a 09 20 20 20  h testdat))..   
73f0: 20 20 20 28 66 75 6c 6c 2d 6e 61 6d 65 20 28 63     (full-name (c
7400: 6f 6e 63 20 74 65 73 74 6e 61 6d 65 20 22 2f 22  onc testname "/"
7410: 20 69 74 65 6d 2d 70 61 74 68 29 29 0a 09 20 20   item-path))..  
7420: 20 20 20 20 28 70 72 65 76 2d 74 65 73 74 2d 64      (prev-test-d
7430: 61 74 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72  at (hash-table-r
7440: 65 66 2f 64 65 66 61 75 6c 74 20 63 75 72 72 2d  ef/default curr-
7450: 74 65 73 74 73 2d 68 61 73 68 20 66 75 6c 6c 2d  tests-hash full-
7460: 6e 61 6d 65 20 23 66 29 29 0a 09 20 20 20 20 20  name #f))..     
7470: 20 28 74 65 73 74 2d 73 74 65 70 73 20 20 20 20   (test-steps    
7480: 20 20 28 64 62 3a 67 65 74 2d 73 74 65 70 73 2d    (db:get-steps-
7490: 66 6f 72 2d 74 65 73 74 20 64 62 20 28 64 62 3a  for-test db (db:
74a0: 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74  test-get-id test
74b0: 64 61 74 29 29 29 0a 09 20 20 20 20 20 20 28 6e  dat)))..      (n
74c0: 65 77 2d 74 65 73 74 2d 72 65 63 6f 72 64 20 23  ew-test-record #
74d0: 66 29 29 0a 09 20 3b 3b 20 72 65 70 6c 61 63 65  f)).. ;; replace
74e0: 20 74 68 65 73 65 20 77 69 74 68 20 69 6e 73 65   these with inse
74f0: 72 74 20 2e 2e 2e 20 73 65 6c 65 63 74 0a 09 20  rt ... select.. 
7500: 28 61 70 70 6c 79 20 73 71 6c 69 74 65 33 3a 65  (apply sqlite3:e
7510: 78 65 63 75 74 65 20 0a 09 09 64 62 20 0a 09 09  xecute ...db ...
7520: 28 63 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f 52  (conc "INSERT OR
7530: 20 52 45 50 4c 41 43 45 20 49 4e 54 4f 20 74 65   REPLACE INTO te
7540: 73 74 73 20 28 72 75 6e 5f 69 64 2c 74 65 73 74  sts (run_id,test
7550: 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 61 74 75  name,state,statu
7560: 73 2c 65 76 65 6e 74 5f 74 69 6d 65 2c 68 6f 73  s,event_time,hos
7570: 74 2c 63 70 75 6c 6f 61 64 2c 64 69 73 6b 66 72  t,cpuload,diskfr
7580: 65 65 2c 75 6e 61 6d 65 2c 72 75 6e 64 69 72 2c  ee,uname,rundir,
7590: 69 74 65 6d 5f 70 61 74 68 2c 72 75 6e 5f 64 75  item_path,run_du
75a0: 72 61 74 69 6f 6e 2c 66 69 6e 61 6c 5f 6c 6f 67  ration,final_log
75b0: 66 2c 63 6f 6d 6d 65 6e 74 29 20 22 0a 09 09 20  f,comment) "... 
75c0: 20 20 20 20 20 22 56 41 4c 55 45 53 20 28 3f 2c       "VALUES (?,
75d0: 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c  ?,?,?,?,?,?,?,?,
75e0: 3f 2c 3f 2c 3f 2c 3f 2c 3f 29 3b 22 29 0a 09 09  ?,?,?,?,?);")...
75f0: 6e 65 77 2d 72 75 6e 2d 69 64 20 28 63 64 64 72  new-run-id (cddr
7600: 20 28 76 65 63 74 6f 72 2d 3e 6c 69 73 74 20 74   (vector->list t
7610: 65 73 74 64 61 74 29 29 29 0a 09 20 28 73 65 74  estdat))).. (set
7620: 21 20 6e 65 77 2d 74 65 73 74 64 61 74 20 28 63  ! new-testdat (c
7630: 61 72 20 28 64 62 2d 67 65 74 2d 74 65 73 74 73  ar (db-get-tests
7640: 2d 66 6f 72 2d 72 75 6e 20 64 62 20 6e 65 77 2d  -for-run db new-
7650: 72 75 6e 2d 69 64 20 74 65 73 74 6e 61 6d 65 20  run-id testname 
7660: 69 74 65 6d 2d 70 61 74 68 20 27 28 29 20 27 28  item-path '() '(
7670: 29 29 29 29 0a 09 20 28 68 61 73 68 2d 74 61 62  )))).. (hash-tab
7680: 6c 65 2d 73 65 74 21 20 63 75 72 72 2d 74 65 73  le-set! curr-tes
7690: 74 73 2d 68 61 73 68 20 66 75 6c 6c 2d 6e 61 6d  ts-hash full-nam
76a0: 65 20 6e 65 77 2d 74 65 73 74 64 61 74 29 20 3b  e new-testdat) ;
76b0: 3b 20 74 68 69 73 20 63 6f 75 6c 64 20 62 65 20  ; this could be 
76c0: 63 6f 6e 66 75 73 69 6e 67 2c 20 77 68 69 63 68  confusing, which
76d0: 20 72 65 63 6f 72 64 20 73 68 6f 75 6c 64 20 67   record should g
76e0: 6f 20 69 6e 74 6f 20 74 68 65 20 6c 6f 6f 6b 75  o into the looku
76f0: 70 20 74 61 62 6c 65 3f 0a 09 20 3b 3b 20 4e 6f  p table?.. ;; No
7700: 77 20 64 75 70 6c 69 63 61 74 65 20 74 68 65 20  w duplicate the 
7710: 74 65 73 74 20 73 74 65 70 73 0a 09 20 28 64 65  test steps.. (de
7720: 62 75 67 3a 70 72 69 6e 74 20 34 20 22 43 6f 70  bug:print 4 "Cop
7730: 79 69 6e 67 20 72 65 63 6f 72 64 73 20 69 6e 20  ying records in 
7740: 74 65 73 74 5f 73 74 65 70 73 20 66 72 6f 6d 20  test_steps from 
7750: 74 65 73 74 5f 69 64 3d 22 20 28 64 62 3a 74 65  test_id=" (db:te
7760: 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74 64 61  st-get-id testda
7770: 74 29 20 22 20 74 6f 20 22 20 28 64 62 3a 74 65  t) " to " (db:te
7780: 73 74 2d 67 65 74 2d 69 64 20 6e 65 77 2d 74 65  st-get-id new-te
7790: 73 74 64 61 74 29 29 0a 09 20 28 73 71 6c 69 74  stdat)).. (sqlit
77a0: 65 33 3a 65 78 65 63 75 74 65 20 0a 09 20 20 64  e3:execute ..  d
77b0: 62 20 0a 09 20 20 28 63 6f 6e 63 20 22 49 4e 53  b ..  (conc "INS
77c0: 45 52 54 20 4f 52 20 52 45 50 4c 41 43 45 20 49  ERT OR REPLACE I
77d0: 4e 54 4f 20 74 65 73 74 5f 73 74 65 70 73 20 28  NTO test_steps (
77e0: 74 65 73 74 5f 69 64 2c 73 74 65 70 6e 61 6d 65  test_id,stepname
77f0: 2c 73 74 61 74 65 2c 73 74 61 74 75 73 2c 65 76  ,state,status,ev
7800: 65 6e 74 5f 74 69 6d 65 2c 63 6f 6d 6d 65 6e 74  ent_time,comment
7810: 29 20 22 0a 09 09 22 53 45 4c 45 43 54 20 22 20  ) "..."SELECT " 
7820: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20  (db:test-get-id 
7830: 6e 65 77 2d 74 65 73 74 64 61 74 29 20 22 2c 73  new-testdat) ",s
7840: 74 65 70 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74  tepname,state,st
7850: 61 74 75 73 2c 65 76 65 6e 74 5f 74 69 6d 65 2c  atus,event_time,
7860: 63 6f 6d 6d 65 6e 74 20 46 52 4f 4d 20 74 65 73  comment FROM tes
7870: 74 5f 73 74 65 70 73 20 57 48 45 52 45 20 74 65  t_steps WHERE te
7880: 73 74 5f 69 64 3d 3f 3b 22 29 0a 09 20 20 28 64  st_id=?;")..  (d
7890: 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65  b:test-get-id te
78a0: 73 74 64 61 74 29 29 0a 09 20 3b 3b 20 4e 6f 77  stdat)).. ;; Now
78b0: 20 64 75 70 6c 69 63 61 74 65 20 74 68 65 20 74   duplicate the t
78c0: 65 73 74 20 64 61 74 61 0a 09 20 28 64 65 62 75  est data.. (debu
78d0: 67 3a 70 72 69 6e 74 20 34 20 22 43 6f 70 79 69  g:print 4 "Copyi
78e0: 6e 67 20 72 65 63 6f 72 64 73 20 69 6e 20 74 65  ng records in te
78f0: 73 74 5f 64 61 74 61 20 66 72 6f 6d 20 74 65 73  st_data from tes
7900: 74 5f 69 64 3d 22 20 28 64 62 3a 74 65 73 74 2d  t_id=" (db:test-
7910: 67 65 74 2d 69 64 20 74 65 73 74 64 61 74 29 20  get-id testdat) 
7920: 22 20 74 6f 20 22 20 28 64 62 3a 74 65 73 74 2d  " to " (db:test-
7930: 67 65 74 2d 69 64 20 6e 65 77 2d 74 65 73 74 64  get-id new-testd
7940: 61 74 29 29 0a 09 20 28 73 71 6c 69 74 65 33 3a  at)).. (sqlite3:
7950: 65 78 65 63 75 74 65 20 0a 09 20 20 64 62 20 0a  execute ..  db .
7960: 09 20 20 28 63 6f 6e 63 20 22 49 4e 53 45 52 54  .  (conc "INSERT
7970: 20 4f 52 20 52 45 50 4c 41 43 45 20 49 4e 54 4f   OR REPLACE INTO
7980: 20 74 65 73 74 5f 64 61 74 61 20 28 74 65 73 74   test_data (test
7990: 5f 69 64 2c 63 61 74 65 67 6f 72 79 2c 76 61 72  _id,category,var
79a0: 69 61 62 6c 65 2c 76 61 6c 75 65 2c 65 78 70 65  iable,value,expe
79b0: 63 74 65 64 2c 74 6f 6c 2c 75 6e 69 74 73 2c 63  cted,tol,units,c
79c0: 6f 6d 6d 65 6e 74 29 20 22 0a 09 09 22 53 45 4c  omment) "..."SEL
79d0: 45 43 54 20 22 20 28 64 62 3a 74 65 73 74 2d 67  ECT " (db:test-g
79e0: 65 74 2d 69 64 20 6e 65 77 2d 74 65 73 74 64 61  et-id new-testda
79f0: 74 29 20 22 2c 63 61 74 65 67 6f 72 79 2c 76 61  t) ",category,va
7a00: 72 69 61 62 6c 65 2c 76 61 6c 75 65 2c 65 78 70  riable,value,exp
7a10: 65 63 74 65 64 2c 74 6f 6c 2c 75 6e 69 74 73 2c  ected,tol,units,
7a20: 63 6f 6d 6d 65 6e 74 20 46 52 4f 4d 20 74 65 73  comment FROM tes
7a30: 74 5f 64 61 74 61 20 57 48 45 52 45 20 74 65 73  t_data WHERE tes
7a40: 74 5f 69 64 3d 3f 3b 22 29 0a 09 20 20 28 64 62  t_id=?;")..  (db
7a50: 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73  :test-get-id tes
7a60: 74 64 61 74 29 29 0a 09 20 29 29 0a 20 20 20 20  tdat)).. )).    
7a70: 20 70 72 65 76 2d 74 65 73 74 73 29 29 29 0a 09   prev-tests)))..
7a80: 20 0a 20 20 20 20 20 0a                           .     .