Megatest

Hex Artifact Content
Login

Artifact fd5fe59318a79c20dd569ff673ddbe851049985a:


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 73 74 75 66 66 20 74 6f 20 62 65 20 64  ;; stuff to be d
0310: 65 70 72 65 63 61 74 65 64 20 74 68 65 6e 20 72  eprecated then r
0320: 65 6d 6f 76 65 64 0a 28 69 6e 63 6c 75 64 65 20  emoved.(include 
0330: 22 6f 6c 64 2d 72 75 6e 73 2e 73 63 6d 22 29 0a  "old-runs.scm").
0340: 0a 0a 3b 3b 20 72 75 6e 73 3a 67 65 74 2d 72 75  ..;; runs:get-ru
0350: 6e 73 2d 62 79 2d 70 61 74 74 0a 3b 3b 20 67 65  ns-by-patt.;; ge
0360: 74 20 72 75 6e 73 20 62 79 20 6c 69 73 74 20 6f  t runs by list o
0370: 66 20 63 72 69 74 65 72 69 61 0a 3b 3b 20 72 65  f criteria.;; re
0380: 67 69 73 74 65 72 20 61 20 74 65 73 74 20 72 75  gister a test ru
0390: 6e 20 77 69 74 68 20 74 68 65 20 64 62 0a 3b 3b  n with the db.;;
03a0: 0a 3b 3b 20 55 73 65 3a 20 28 64 62 2d 67 65 74  .;; Use: (db-get
03b0: 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72  -value-by-header
03c0: 20 28 64 62 3a 67 65 74 2d 68 65 61 64 65 72 20   (db:get-header 
03d0: 72 75 6e 69 6e 66 6f 29 28 64 62 3a 67 65 74 2d  runinfo)(db:get-
03e0: 72 6f 77 20 72 75 6e 69 6e 66 6f 29 29 0a 3b 3b  row runinfo)).;;
03f0: 20 20 74 6f 20 65 78 74 72 61 63 74 20 69 6e 66    to extract inf
0400: 6f 20 66 72 6f 6d 20 74 68 65 20 73 74 72 75 63  o from the struc
0410: 74 75 72 65 20 72 65 74 75 72 6e 65 64 0a 3b 3b  ture returned.;;
0420: 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 67  .(define (runs:g
0430: 65 74 2d 72 75 6e 73 2d 62 79 2d 70 61 74 74 20  et-runs-by-patt 
0440: 64 62 20 6b 65 79 73 20 72 75 6e 6e 61 6d 65 70  db keys runnamep
0450: 61 74 74 20 2e 20 70 61 72 61 6d 73 29 20 3b 3b  att . params) ;;
0460: 20 74 65 73 74 2d 6e 61 6d 65 29 0a 20 20 28 6c   test-name).  (l
0470: 65 74 2a 20 28 28 6b 65 79 76 61 6c 6c 73 74 20  et* ((keyvallst 
0480: 28 6b 65 79 73 2d 3e 76 61 6c 6c 69 73 74 20 6b  (keys->vallist k
0490: 65 79 73 29 29 0a 09 20 28 74 6d 70 20 20 20 20  eys)).. (tmp    
04a0: 20 20 28 72 75 6e 73 3a 67 65 74 2d 73 74 64 2d    (runs:get-std-
04b0: 72 75 6e 2d 66 69 65 6c 64 73 20 6b 65 79 73 20  run-fields keys 
04c0: 27 28 22 69 64 22 20 22 72 75 6e 6e 61 6d 65 22  '("id" "runname"
04d0: 20 22 73 74 61 74 65 22 20 22 73 74 61 74 75 73   "state" "status
04e0: 22 20 22 6f 77 6e 65 72 22 20 22 65 76 65 6e 74  " "owner" "event
04f0: 5f 74 69 6d 65 22 29 29 29 0a 09 20 28 6b 65 79  _time"))).. (key
0500: 73 74 72 20 20 20 28 63 61 72 20 74 6d 70 29 29  str   (car tmp))
0510: 0a 09 20 28 68 65 61 64 65 72 20 20 20 28 63 61  .. (header   (ca
0520: 64 72 20 74 6d 70 29 29 0a 09 20 28 72 65 73 20  dr tmp)).. (res 
0530: 20 20 20 20 27 28 29 29 0a 09 20 28 6b 65 79 2d      '()).. (key-
0540: 70 61 74 74 20 22 22 29 29 0a 20 20 20 20 28 66  patt "")).    (f
0550: 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 20  or-each (lambda 
0560: 28 6b 65 79 76 61 6c 29 0a 09 09 28 6c 65 74 2a  (keyval)...(let*
0570: 20 28 28 6b 65 79 20 20 20 20 28 76 65 63 74 6f   ((key    (vecto
0580: 72 2d 72 65 66 20 6b 65 79 76 61 6c 20 30 29 29  r-ref keyval 0))
0590: 0a 09 09 20 20 20 20 20 20 20 28 66 75 6c 6b 65  ...       (fulke
05a0: 79 20 28 63 6f 6e 63 20 22 3a 22 20 6b 65 79 29  y (conc ":" key)
05b0: 29 0a 09 09 20 20 20 20 20 20 20 28 70 61 74 74  )...       (patt
05c0: 20 20 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67     (args:get-arg
05d0: 20 66 75 6c 6b 65 79 29 29 29 0a 09 09 20 20 28   fulkey)))...  (
05e0: 69 66 20 70 61 74 74 0a 09 09 20 20 20 20 20 20  if patt...      
05f0: 28 73 65 74 21 20 6b 65 79 2d 70 61 74 74 20 28  (set! key-patt (
0600: 63 6f 6e 63 20 6b 65 79 2d 70 61 74 74 20 22 20  conc key-patt " 
0610: 41 4e 44 20 22 20 6b 65 79 20 22 20 6c 69 6b 65  AND " key " like
0620: 20 27 22 20 70 61 74 74 20 22 27 22 29 29 0a 09   '" patt "'"))..
0630: 09 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09  .      (begin...
0640: 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20  .(debug:print 0 
0650: 22 45 52 52 4f 52 3a 20 73 65 61 72 63 68 69 6e  "ERROR: searchin
0660: 67 20 66 6f 72 20 72 75 6e 73 20 77 69 74 68 20  g for runs with 
0670: 6e 6f 20 70 61 74 74 65 72 6e 20 73 65 74 20 66  no pattern set f
0680: 6f 72 20 22 20 66 75 6c 6b 65 79 29 0a 09 09 09  or " fulkey)....
0690: 28 65 78 69 74 20 36 29 29 29 29 29 0a 09 20 20  (exit 6)))))..  
06a0: 20 20 20 20 6b 65 79 73 29 0a 20 20 20 20 28 73      keys).    (s
06b0: 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d  qlite3:for-each-
06c0: 72 6f 77 20 0a 20 20 20 20 20 28 6c 61 6d 62 64  row .     (lambd
06d0: 61 20 28 61 20 2e 20 72 29 0a 20 20 20 20 20 20  a (a . r).      
06e0: 20 28 73 65 74 21 20 72 65 73 20 28 63 6f 6e 73   (set! res (cons
06f0: 20 28 6c 69 73 74 2d 3e 76 65 63 74 6f 72 20 28   (list->vector (
0700: 63 6f 6e 73 20 61 20 72 29 29 20 72 65 73 29 29  cons a r)) res))
0710: 29 0a 20 20 20 20 20 64 62 20 0a 20 20 20 20 20  ).     db .     
0720: 28 63 6f 6e 63 20 22 53 45 4c 45 43 54 20 22 20  (conc "SELECT " 
0730: 6b 65 79 73 74 72 20 22 20 46 52 4f 4d 20 72 75  keystr " FROM ru
0740: 6e 73 20 57 48 45 52 45 20 72 75 6e 6e 61 6d 65  ns WHERE runname
0750: 20 6c 69 6b 65 20 3f 20 22 20 6b 65 79 2d 70 61   like ? " key-pa
0760: 74 74 20 22 3b 22 29 0a 20 20 20 20 20 72 75 6e  tt ";").     run
0770: 6e 61 6d 65 70 61 74 74 29 0a 20 20 20 20 28 76  namepatt).    (v
0780: 65 63 74 6f 72 20 68 65 61 64 65 72 20 72 65 73  ector header res
0790: 29 29 29 0a 0a 3b 3b 20 3b 3b 20 54 4f 44 4f 3a  )))..;; ;; TODO:
07a0: 20 43 6f 6e 76 65 72 67 65 20 74 68 69 73 20 77   Converge this w
07b0: 69 74 68 20 64 62 3a 67 65 74 2d 74 65 73 74 2d  ith db:get-test-
07c0: 69 6e 66 6f 0a 3b 3b 20 28 64 65 66 69 6e 65 20  info.;; (define 
07d0: 28 72 75 6e 73 3a 67 65 74 2d 74 65 73 74 2d 69  (runs:get-test-i
07e0: 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65  nfo db run-id te
07f0: 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74  st-name item-pat
0800: 68 29 0a 3b 3b 20 20 20 28 6c 65 74 20 28 28 72  h).;;   (let ((r
0810: 65 73 20 23 66 29 29 20 3b 3b 20 28 76 65 63 74  es #f)) ;; (vect
0820: 6f 72 20 23 66 20 23 66 20 23 66 20 23 66 20 23  or #f #f #f #f #
0830: 66 20 23 66 29 29 29 0a 3b 3b 20 20 20 20 20 28  f #f))).;;     (
0840: 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68  sqlite3:for-each
0850: 2d 72 6f 77 20 0a 3b 3b 20 20 20 20 20 20 28 6c  -row .;;      (l
0860: 61 6d 62 64 61 20 28 69 64 20 72 75 6e 2d 69 64  ambda (id run-id
0870: 20 74 65 73 74 2d 6e 61 6d 65 20 73 74 61 74 65   test-name state
0880: 20 73 74 61 74 75 73 29 0a 3b 3b 20 20 20 20 20   status).;;     
0890: 20 20 20 28 73 65 74 21 20 72 65 73 20 28 76 65     (set! res (ve
08a0: 63 74 6f 72 20 69 64 20 72 75 6e 2d 69 64 20 74  ctor id run-id t
08b0: 65 73 74 2d 6e 61 6d 65 20 73 74 61 74 65 20 73  est-name state s
08c0: 74 61 74 75 73 20 69 74 65 6d 2d 70 61 74 68 29  tatus item-path)
08d0: 29 29 0a 3b 3b 20 20 20 20 20 20 64 62 20 22 53  )).;;      db "S
08e0: 45 4c 45 43 54 20 69 64 2c 72 75 6e 5f 69 64 2c  ELECT id,run_id,
08f0: 74 65 73 74 6e 61 6d 65 2c 73 74 61 74 65 2c 73  testname,state,s
0900: 74 61 74 75 73 20 46 52 4f 4d 20 74 65 73 74 73  tatus FROM tests
0910: 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20   WHERE run_id=? 
0920: 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41  AND testname=? A
0930: 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f 3b 22  ND item_path=?;"
0940: 0a 3b 3b 20 20 20 20 20 20 72 75 6e 2d 69 64 20  .;;      run-id 
0950: 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70  test-name item-p
0960: 61 74 68 29 0a 3b 3b 20 20 20 20 20 72 65 73 29  ath).;;     res)
0970: 29 0a 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73  )..(define (runs
0980: 3a 74 65 73 74 2d 67 65 74 2d 66 75 6c 6c 2d 70  :test-get-full-p
0990: 61 74 68 20 74 65 73 74 29 0a 20 20 28 6c 65 74  ath test).  (let
09a0: 2a 20 28 28 74 65 73 74 6e 61 6d 65 20 28 64 62  * ((testname (db
09b0: 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61  :test-get-testna
09c0: 6d 65 20 20 20 74 65 73 74 29 29 0a 09 20 28 69  me   test)).. (i
09d0: 74 65 6d 70 61 74 68 20 28 64 62 3a 74 65 73 74  tempath (db:test
09e0: 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74  -get-item-path t
09f0: 65 73 74 29 29 29 0a 20 20 20 20 28 63 6f 6e 63  est))).    (conc
0a00: 20 74 65 73 74 6e 61 6d 65 20 28 69 66 20 28 65   testname (if (e
0a10: 71 75 61 6c 3f 20 69 74 65 6d 70 61 74 68 20 22  qual? itempath "
0a20: 22 29 20 22 22 20 28 63 6f 6e 63 20 22 28 22 20  ") "" (conc "(" 
0a30: 69 74 65 6d 70 61 74 68 20 22 29 22 29 29 29 29  itempath ")"))))
0a40: 29 0a 0a 0a 28 64 65 66 69 6e 65 20 28 73 65 74  )...(define (set
0a50: 2d 6d 65 67 61 74 65 73 74 2d 65 6e 76 2d 76 61  -megatest-env-va
0a60: 72 73 20 64 62 20 72 75 6e 2d 69 64 29 0a 20 20  rs db run-id).  
0a70: 28 6c 65 74 20 28 28 6b 65 79 73 20 28 64 62 2d  (let ((keys (db-
0a80: 67 65 74 2d 6b 65 79 73 20 64 62 29 29 29 0a 20  get-keys db))). 
0a90: 20 20 20 28 66 6f 72 2d 65 61 63 68 20 28 6c 61     (for-each (la
0aa0: 6d 62 64 61 20 28 6b 65 79 29 0a 09 09 28 73 71  mbda (key)...(sq
0ab0: 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72  lite3:for-each-r
0ac0: 6f 77 0a 09 09 20 28 6c 61 6d 62 64 61 20 28 76  ow... (lambda (v
0ad0: 61 6c 29 0a 09 09 20 20 20 28 64 65 62 75 67 3a  al)...   (debug:
0ae0: 70 72 69 6e 74 20 32 20 22 73 65 74 65 6e 76 20  print 2 "setenv 
0af0: 22 20 28 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64  " (key:get-field
0b00: 6e 61 6d 65 20 6b 65 79 29 20 22 20 22 20 76 61  name key) " " va
0b10: 6c 29 0a 09 09 20 20 20 28 73 65 74 65 6e 76 20  l)...   (setenv 
0b20: 28 6b 65 79 3a 67 65 74 2d 66 69 65 6c 64 6e 61  (key:get-fieldna
0b30: 6d 65 20 6b 65 79 29 20 76 61 6c 29 29 0a 09 09  me key) val))...
0b40: 20 64 62 20 0a 09 09 20 28 63 6f 6e 63 20 22 53   db ... (conc "S
0b50: 45 4c 45 43 54 20 22 20 28 6b 65 79 3a 67 65 74  ELECT " (key:get
0b60: 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65 79 29 20  -fieldname key) 
0b70: 22 20 46 52 4f 4d 20 72 75 6e 73 20 57 48 45 52  " FROM runs WHER
0b80: 45 20 69 64 3d 3f 3b 22 29 0a 09 09 20 72 75 6e  E id=?;")... run
0b90: 2d 69 64 29 29 0a 09 20 20 20 20 20 20 6b 65 79  -id))..      key
0ba0: 73 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 73  s)))..(define (s
0bb0: 65 74 2d 69 74 65 6d 2d 65 6e 76 2d 76 61 72 73  et-item-env-vars
0bc0: 20 69 74 65 6d 64 61 74 29 0a 20 20 28 66 6f 72   itemdat).  (for
0bd0: 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 20 28 69  -each (lambda (i
0be0: 74 65 6d 29 0a 09 20 20 20 20 20 20 28 64 65 62  tem)..      (deb
0bf0: 75 67 3a 70 72 69 6e 74 20 32 20 22 73 65 74 65  ug:print 2 "sete
0c00: 6e 76 20 22 20 28 63 61 72 20 69 74 65 6d 29 20  nv " (car item) 
0c10: 22 20 22 20 28 63 61 64 72 20 69 74 65 6d 29 29  " " (cadr item))
0c20: 0a 09 20 20 20 20 20 20 28 73 65 74 65 6e 76 20  ..      (setenv 
0c30: 28 63 61 72 20 69 74 65 6d 29 20 28 63 61 64 72  (car item) (cadr
0c40: 20 69 74 65 6d 29 29 29 0a 09 20 20 20 20 69 74   item)))..    it
0c50: 65 6d 64 61 74 29 29 0a 0a 28 64 65 66 69 6e 65  emdat))..(define
0c60: 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d   (runs:can-run-m
0c70: 6f 72 65 2d 74 65 73 74 73 20 64 62 20 74 65 73  ore-tests db tes
0c80: 74 2d 72 65 63 6f 72 64 29 0a 20 20 28 6c 65 74  t-record).  (let
0c90: 2a 20 28 28 74 63 6f 6e 66 69 67 20 20 20 20 20  * ((tconfig     
0ca0: 20 20 20 20 20 20 20 20 20 20 20 20 28 74 65 73              (tes
0cb0: 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74  ts:testqueue-get
0cc0: 2d 74 65 73 74 63 6f 6e 66 69 67 20 74 65 73 74  -testconfig test
0cd0: 2d 72 65 63 6f 72 64 29 29 0a 09 20 28 6a 6f 62  -record)).. (job
0ce0: 67 72 6f 75 70 20 20 20 20 20 20 20 20 20 20 20  group           
0cf0: 20 20 20 20 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f       (config-loo
0d00: 6b 75 70 20 74 63 6f 6e 66 69 67 20 22 72 65 71  kup tconfig "req
0d10: 75 69 72 65 6d 65 6e 74 73 22 20 22 6a 6f 62 67  uirements" "jobg
0d20: 72 6f 75 70 22 29 29 0a 09 20 28 6e 75 6d 2d 72  roup")).. (num-r
0d30: 75 6e 6e 69 6e 67 20 20 20 20 20 20 20 20 20 20  unning          
0d40: 20 20 20 28 64 62 3a 67 65 74 2d 63 6f 75 6e 74     (db:get-count
0d50: 2d 74 65 73 74 73 2d 72 75 6e 6e 69 6e 67 20 64  -tests-running d
0d60: 62 29 29 0a 09 20 28 6e 75 6d 2d 72 75 6e 6e 69  b)).. (num-runni
0d70: 6e 67 2d 69 6e 2d 6a 6f 62 67 72 6f 75 70 20 28  ng-in-jobgroup (
0d80: 64 62 3a 67 65 74 2d 63 6f 75 6e 74 2d 74 65 73  db:get-count-tes
0d90: 74 73 2d 72 75 6e 6e 69 6e 67 2d 69 6e 2d 6a 6f  ts-running-in-jo
0da0: 62 67 72 6f 75 70 20 64 62 20 6a 6f 62 67 72 6f  bgroup db jobgro
0db0: 75 70 29 29 0a 09 20 28 6d 61 78 2d 63 6f 6e 63  up)).. (max-conc
0dc0: 75 72 72 65 6e 74 2d 6a 6f 62 73 20 20 20 20 20  urrent-jobs     
0dd0: 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 2a  (config-lookup *
0de0: 63 6f 6e 66 69 67 64 61 74 2a 20 22 73 65 74 75  configdat* "setu
0df0: 70 22 20 20 20 20 20 22 6d 61 78 5f 63 6f 6e 63  p"     "max_conc
0e00: 75 72 72 65 6e 74 5f 6a 6f 62 73 22 29 29 0a 09  urrent_jobs"))..
0e10: 20 28 6a 6f 62 2d 67 72 6f 75 70 2d 6c 69 6d 69   (job-group-limi
0e20: 74 20 20 20 20 20 20 20 20 20 28 63 6f 6e 66 69  t         (confi
0e30: 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69 67  g-lookup *config
0e40: 64 61 74 2a 20 22 6a 6f 62 67 72 6f 75 70 73 22  dat* "jobgroups"
0e50: 20 6a 6f 62 67 72 6f 75 70 29 29 29 0a 20 20 20   jobgroup))).   
0e60: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20   (debug:print 2 
0e70: 22 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d  "max-concurrent-
0e80: 6a 6f 62 73 3a 20 22 20 6d 61 78 2d 63 6f 6e 63  jobs: " max-conc
0e90: 75 72 72 65 6e 74 2d 6a 6f 62 73 20 22 2c 20 6e  urrent-jobs ", n
0ea0: 75 6d 2d 72 75 6e 6e 69 6e 67 3a 20 22 20 6e 75  um-running: " nu
0eb0: 6d 2d 72 75 6e 6e 69 6e 67 29 0a 20 20 20 20 28  m-running).    (
0ec0: 69 66 20 28 6e 6f 74 20 28 65 71 3f 20 30 20 2a  if (not (eq? 0 *
0ed0: 67 6c 6f 62 61 6c 65 78 69 74 73 74 61 74 75 73  globalexitstatus
0ee0: 2a 29 29 0a 09 23 66 0a 09 28 6c 65 74 20 28 28  *))..#f..(let ((
0ef0: 63 61 6e 2d 6e 6f 74 2d 72 75 6e 2d 6d 6f 72 65  can-not-run-more
0f00: 20 28 63 6f 6e 64 0a 09 09 09 09 20 3b 3b 20 69   (cond..... ;; i
0f10: 66 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74  f max-concurrent
0f20: 2d 6a 6f 62 73 20 69 73 20 73 65 74 20 61 6e 64  -jobs is set and
0f30: 20 74 68 65 20 6e 75 6d 62 65 72 20 72 75 6e 6e   the number runn
0f40: 69 6e 67 20 69 73 20 67 72 65 61 74 65 72 20 0a  ing is greater .
0f50: 09 09 09 09 20 3b 3b 20 74 68 61 6e 20 69 74 20  .... ;; than it 
0f60: 74 68 61 6e 20 63 61 6e 6e 6f 74 20 72 75 6e 20  than cannot run 
0f70: 6d 6f 72 65 20 6a 6f 62 73 0a 09 09 09 09 20 28  more jobs..... (
0f80: 28 61 6e 64 20 6d 61 78 2d 63 6f 6e 63 75 72 72  (and max-concurr
0f90: 65 6e 74 2d 6a 6f 62 73 0a 09 09 09 09 20 20 20  ent-jobs.....   
0fa0: 20 20 20 20 28 73 74 72 69 6e 67 2d 3e 6e 75 6d      (string->num
0fb0: 62 65 72 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65  ber max-concurre
0fc0: 6e 74 2d 6a 6f 62 73 29 0a 09 09 09 09 20 20 20  nt-jobs).....   
0fd0: 20 20 20 20 28 3e 3d 20 6e 75 6d 2d 72 75 6e 6e      (>= num-runn
0fe0: 69 6e 67 20 28 73 74 72 69 6e 67 2d 3e 6e 75 6d  ing (string->num
0ff0: 62 65 72 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65  ber max-concurre
1000: 6e 74 2d 6a 6f 62 73 29 29 29 0a 09 09 09 09 20  nt-jobs)))..... 
1010: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
1020: 22 57 41 52 4e 49 4e 47 3a 20 4d 61 78 20 72 75  "WARNING: Max ru
1030: 6e 6e 69 6e 67 20 6a 6f 62 73 20 65 78 63 65 65  nning jobs excee
1040: 64 65 64 2c 20 63 75 72 72 65 6e 74 20 6e 75 6d  ded, current num
1050: 62 65 72 20 72 75 6e 6e 69 6e 67 3a 20 22 20 6e  ber running: " n
1060: 75 6d 2d 72 75 6e 6e 69 6e 67 20 0a 09 09 09 09  um-running .....
1070: 09 20 20 20 20 20 20 20 22 2c 20 6d 61 78 5f 63  .       ", max_c
1080: 6f 6e 63 75 72 72 65 6e 74 5f 6a 6f 62 73 3a 20  oncurrent_jobs: 
1090: 22 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74  " max-concurrent
10a0: 2d 6a 6f 62 73 29 0a 09 09 09 09 20 20 23 74 29  -jobs).....  #t)
10b0: 0a 09 09 09 09 20 3b 3b 20 69 66 20 6a 6f 62 2d  ..... ;; if job-
10c0: 67 72 6f 75 70 2d 6c 69 6d 69 74 20 69 73 20 73  group-limit is s
10d0: 65 74 20 61 6e 64 20 6e 75 6d 62 65 72 20 6f 66  et and number of
10e0: 20 6a 6f 62 73 20 69 6e 20 74 68 65 20 67 72 6f   jobs in the gro
10f0: 75 70 20 69 73 20 67 72 65 61 74 65 72 0a 09 09  up is greater...
1100: 09 09 20 3b 3b 20 74 68 61 6e 20 74 68 65 20 6c  .. ;; than the l
1110: 69 6d 69 74 20 74 68 65 6e 20 63 61 6e 6e 6f 74  imit then cannot
1120: 20 72 75 6e 20 6d 6f 72 65 20 6a 6f 62 73 20 6f   run more jobs o
1130: 66 20 74 68 69 73 20 6b 69 6e 64 0a 09 09 09 09  f this kind.....
1140: 20 28 28 61 6e 64 20 6a 6f 62 2d 67 72 6f 75 70   ((and job-group
1150: 2d 6c 69 6d 69 74 0a 09 09 09 09 20 20 20 20 20  -limit.....     
1160: 20 20 28 3e 3d 20 6e 75 6d 2d 72 75 6e 6e 69 6e    (>= num-runnin
1170: 67 2d 69 6e 2d 6a 6f 62 67 72 6f 75 70 20 6a 6f  g-in-jobgroup jo
1180: 62 2d 67 72 6f 75 70 2d 6c 69 6d 69 74 29 29 0a  b-group-limit)).
1190: 09 09 09 09 20 20 28 64 65 62 75 67 3a 70 72 69  ....  (debug:pri
11a0: 6e 74 20 31 20 22 57 41 52 4e 49 4e 47 3a 20 6e  nt 1 "WARNING: n
11b0: 75 6d 62 65 72 20 6f 66 20 6a 6f 62 73 20 22 20  umber of jobs " 
11c0: 6e 75 6d 2d 72 75 6e 6e 69 6e 67 2d 69 6e 2d 6a  num-running-in-j
11d0: 6f 62 67 72 6f 75 70 20 0a 09 09 09 09 09 20 20  obgroup ......  
11e0: 20 20 20 20 20 22 20 69 6e 20 22 20 6a 6f 62 67       " in " jobg
11f0: 72 6f 75 70 20 22 20 65 78 63 65 65 64 65 64 2c  roup " exceeded,
1200: 20 77 69 6c 6c 20 6e 6f 74 20 72 75 6e 20 22 20   will not run " 
1210: 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65  (tests:testqueue
1220: 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 74 65  -get-testname te
1230: 73 74 2d 72 65 63 6f 72 64 29 29 0a 09 09 09 09  st-record)).....
1240: 20 20 23 74 29 0a 09 09 09 09 20 28 65 6c 73 65    #t)..... (else
1250: 20 23 66 29 29 29 29 0a 09 20 20 28 6e 6f 74 20   #f))))..  (not 
1260: 63 61 6e 2d 6e 6f 74 2d 72 75 6e 2d 6d 6f 72 65  can-not-run-more
1270: 29 29 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d  )))))..;;=======
1280: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1290: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
12a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
12b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a  ===============.
12c0: 3b 3b 20 4e 65 77 20 6d 65 74 68 6f 64 6f 6c 6f  ;; New methodolo
12d0: 67 79 2e 20 54 68 65 73 65 20 72 6f 75 74 69 6e  gy. These routin
12e0: 65 73 20 77 69 6c 6c 20 72 65 70 6c 61 63 65 20  es will replace 
12f0: 74 68 65 20 61 62 6f 76 65 20 69 6e 20 74 69 6d  the above in tim
1300: 65 2e 20 46 6f 72 0a 3b 3b 20 6e 6f 77 20 74 68  e. For.;; now th
1310: 65 20 63 6f 64 65 20 69 73 20 64 75 70 6c 69 63  e code is duplic
1320: 61 74 65 64 2e 20 54 68 69 73 20 73 74 75 66 66  ated. This stuff
1330: 20 69 73 20 69 6e 69 74 69 61 6c 6c 79 20 75 73   is initially us
1340: 65 64 20 69 6e 20 74 68 65 20 6d 6f 6e 69 74 6f  ed in the monito
1350: 72 0a 3b 3b 20 62 61 73 65 64 20 63 6f 64 65 2e  r.;; based code.
1360: 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  .;;=============
1370: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1380: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1390: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
13a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 72 65  =========..;; re
13b0: 67 69 73 74 65 72 20 61 20 74 65 73 74 20 72 75  gister a test ru
13c0: 6e 20 77 69 74 68 20 74 68 65 20 64 62 0a 28 64  n with the db.(d
13d0: 65 66 69 6e 65 20 28 72 75 6e 73 3a 72 65 67 69  efine (runs:regi
13e0: 73 74 65 72 2d 72 75 6e 20 64 62 20 6b 65 79 73  ster-run db keys
13f0: 20 6b 65 79 76 61 6c 6c 73 74 20 72 75 6e 6e 61   keyvallst runna
1400: 6d 65 20 73 74 61 74 65 20 73 74 61 74 75 73 20  me state status 
1410: 75 73 65 72 29 0a 20 20 28 64 65 62 75 67 3a 70  user).  (debug:p
1420: 72 69 6e 74 20 33 20 22 72 75 6e 73 3a 72 65 67  rint 3 "runs:reg
1430: 69 73 74 65 72 2d 72 75 6e 2c 20 6b 65 79 73 3a  ister-run, keys:
1440: 20 22 20 6b 65 79 73 20 22 20 6b 65 79 76 61 6c   " keys " keyval
1450: 6c 73 74 3a 20 22 20 6b 65 79 76 61 6c 6c 73 74  lst: " keyvallst
1460: 20 22 20 72 75 6e 6e 61 6d 65 3a 20 22 20 72 75   " runname: " ru
1470: 6e 6e 61 6d 65 20 22 20 73 74 61 74 65 3a 20 22  nname " state: "
1480: 20 73 74 61 74 65 20 22 20 73 74 61 74 75 73 3a   state " status:
1490: 20 22 20 73 74 61 74 75 73 20 22 20 75 73 65 72   " status " user
14a0: 3a 20 22 20 75 73 65 72 29 0a 20 20 28 6c 65 74  : " user).  (let
14b0: 2a 20 28 28 6b 65 79 73 74 72 20 20 20 20 28 6b  * ((keystr    (k
14c0: 65 79 73 2d 3e 6b 65 79 73 74 72 20 6b 65 79 73  eys->keystr keys
14d0: 29 29 0a 09 20 28 63 6f 6d 6d 61 20 20 20 20 20  )).. (comma     
14e0: 28 69 66 20 28 3e 20 28 6c 65 6e 67 74 68 20 6b  (if (> (length k
14f0: 65 79 73 29 20 30 29 20 22 2c 22 20 22 22 29 29  eys) 0) "," ""))
1500: 0a 09 20 28 61 6e 64 73 74 72 20 20 20 20 28 69  .. (andstr    (i
1510: 66 20 28 3e 20 28 6c 65 6e 67 74 68 20 6b 65 79  f (> (length key
1520: 73 29 20 30 29 20 22 20 41 4e 44 20 22 20 22 22  s) 0) " AND " ""
1530: 29 29 0a 09 20 28 76 61 6c 73 6c 6f 74 73 20 20  )).. (valslots  
1540: 28 6b 65 79 73 2d 3e 76 61 6c 73 6c 6f 74 73 20  (keys->valslots 
1550: 6b 65 79 73 29 29 20 3b 3b 20 3f 2c 3f 2c 3f 20  keys)) ;; ?,?,? 
1560: 2e 2e 2e 0a 09 20 28 6b 65 79 76 61 6c 73 20 20  ..... (keyvals  
1570: 20 28 6d 61 70 20 63 61 64 72 20 6b 65 79 76 61   (map cadr keyva
1580: 6c 6c 73 74 29 29 0a 09 20 28 61 6c 6c 76 61 6c  llst)).. (allval
1590: 73 20 20 20 28 61 70 70 65 6e 64 20 28 6c 69 73  s   (append (lis
15a0: 74 20 72 75 6e 6e 61 6d 65 20 73 74 61 74 65 20  t runname state 
15b0: 73 74 61 74 75 73 20 75 73 65 72 29 20 6b 65 79  status user) key
15c0: 76 61 6c 73 29 29 0a 09 20 28 71 72 79 76 61 6c  vals)).. (qryval
15d0: 73 20 20 20 28 61 70 70 65 6e 64 20 28 6c 69 73  s   (append (lis
15e0: 74 20 72 75 6e 6e 61 6d 65 29 20 6b 65 79 76 61  t runname) keyva
15f0: 6c 73 29 29 0a 09 20 28 6b 65 79 3d 3f 73 74 72  ls)).. (key=?str
1600: 20 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73    (string-inters
1610: 70 65 72 73 65 20 28 6d 61 70 20 28 6c 61 6d 62  perse (map (lamb
1620: 64 61 20 28 6b 29 28 63 6f 6e 63 20 28 6b 65 79  da (k)(conc (key
1630: 3a 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b  :get-fieldname k
1640: 29 20 22 3d 3f 22 29 29 20 6b 65 79 73 29 20 22  ) "=?")) keys) "
1650: 20 41 4e 44 20 22 29 29 29 0a 20 20 20 20 28 64   AND "))).    (d
1660: 65 62 75 67 3a 70 72 69 6e 74 20 33 20 22 6b 65  ebug:print 3 "ke
1670: 79 73 3a 20 22 20 6b 65 79 73 20 22 20 61 6c 6c  ys: " keys " all
1680: 76 61 6c 73 3a 20 22 20 61 6c 6c 76 61 6c 73 20  vals: " allvals 
1690: 22 20 6b 65 79 76 61 6c 73 3a 20 22 20 6b 65 79  " keyvals: " key
16a0: 76 61 6c 73 29 0a 20 20 20 20 28 64 65 62 75 67  vals).    (debug
16b0: 3a 70 72 69 6e 74 20 32 20 22 4e 4f 54 45 3a 20  :print 2 "NOTE: 
16c0: 75 73 69 6e 67 20 74 61 72 67 65 74 20 22 20 28  using target " (
16d0: 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72  string-intersper
16e0: 73 65 20 6b 65 79 76 61 6c 73 20 22 2f 22 29 20  se keyvals "/") 
16f0: 22 20 66 6f 72 20 74 68 69 73 20 72 75 6e 22 29  " for this run")
1700: 0a 20 20 20 20 28 69 66 20 28 61 6e 64 20 72 75  .    (if (and ru
1710: 6e 6e 61 6d 65 20 28 6e 75 6c 6c 3f 20 28 66 69  nname (null? (fi
1720: 6c 74 65 72 20 28 6c 61 6d 62 64 61 20 28 78 29  lter (lambda (x)
1730: 28 6e 6f 74 20 78 29 29 20 6b 65 79 76 61 6c 73  (not x)) keyvals
1740: 29 29 29 20 3b 3b 20 74 68 65 72 65 20 6d 75 73  ))) ;; there mus
1750: 74 20 62 65 20 61 20 62 65 74 74 65 72 20 77 61  t be a better wa
1760: 79 20 74 6f 20 22 61 70 70 6c 79 20 61 6e 64 22  y to "apply and"
1770: 0a 09 28 6c 65 74 20 28 28 72 65 73 20 23 66 29  ..(let ((res #f)
1780: 29 0a 09 20 20 28 61 70 70 6c 79 20 73 71 6c 69  )..  (apply sqli
1790: 74 65 33 3a 65 78 65 63 75 74 65 20 64 62 20 28  te3:execute db (
17a0: 63 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f 52 20  conc "INSERT OR 
17b0: 49 47 4e 4f 52 45 20 49 4e 54 4f 20 72 75 6e 73  IGNORE INTO runs
17c0: 20 28 72 75 6e 6e 61 6d 65 2c 73 74 61 74 65 2c   (runname,state,
17d0: 73 74 61 74 75 73 2c 6f 77 6e 65 72 2c 65 76 65  status,owner,eve
17e0: 6e 74 5f 74 69 6d 65 22 20 63 6f 6d 6d 61 20 6b  nt_time" comma k
17f0: 65 79 73 74 72 20 22 29 20 56 41 4c 55 45 53 20  eystr ") VALUES 
1800: 28 3f 2c 3f 2c 3f 2c 3f 2c 73 74 72 66 74 69 6d  (?,?,?,?,strftim
1810: 65 28 27 25 73 27 2c 27 6e 6f 77 27 29 22 20 63  e('%s','now')" c
1820: 6f 6d 6d 61 20 76 61 6c 73 6c 6f 74 73 20 22 29  omma valslots ")
1830: 3b 22 29 0a 09 09 20 61 6c 6c 76 61 6c 73 29 0a  ;")... allvals).
1840: 09 20 20 28 61 70 70 6c 79 20 73 71 6c 69 74 65  .  (apply sqlite
1850: 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77 20 0a  3:for-each-row .
1860: 09 20 20 20 28 6c 61 6d 62 64 61 20 28 69 64 29  .   (lambda (id)
1870: 0a 09 20 20 20 20 20 28 73 65 74 21 20 72 65 73  ..     (set! res
1880: 20 69 64 29 29 0a 09 20 20 20 64 62 0a 09 20 20   id))..   db..  
1890: 20 28 6c 65 74 20 28 28 71 72 79 20 28 63 6f 6e   (let ((qry (con
18a0: 63 20 22 53 45 4c 45 43 54 20 69 64 20 46 52 4f  c "SELECT id FRO
18b0: 4d 20 72 75 6e 73 20 57 48 45 52 45 20 28 72 75  M runs WHERE (ru
18c0: 6e 6e 61 6d 65 3d 3f 20 22 20 61 6e 64 73 74 72  nname=? " andstr
18d0: 20 6b 65 79 3d 3f 73 74 72 20 22 29 3b 22 29 29   key=?str ");"))
18e0: 29 0a 09 20 20 20 20 20 3b 28 64 65 62 75 67 3a  )..     ;(debug:
18f0: 70 72 69 6e 74 20 34 20 22 71 72 79 3a 20 22 20  print 4 "qry: " 
1900: 71 72 79 29 20 0a 09 20 20 20 20 20 71 72 79 29  qry) ..     qry)
1910: 0a 09 20 20 20 71 72 79 76 61 6c 73 29 0a 09 20  ..   qryvals).. 
1920: 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74   (sqlite3:execut
1930: 65 20 64 62 20 22 55 50 44 41 54 45 20 72 75 6e  e db "UPDATE run
1940: 73 20 53 45 54 20 73 74 61 74 65 3d 3f 2c 73 74  s SET state=?,st
1950: 61 74 75 73 3d 3f 20 57 48 45 52 45 20 69 64 3d  atus=? WHERE id=
1960: 3f 3b 22 20 73 74 61 74 65 20 73 74 61 74 75 73  ?;" state status
1970: 20 72 65 73 29 0a 09 20 20 72 65 73 29 20 0a 09   res)..  res) ..
1980: 28 62 65 67 69 6e 0a 09 20 20 28 64 65 62 75 67  (begin..  (debug
1990: 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a  :print 0 "ERROR:
19a0: 20 43 61 6c 6c 65 64 20 77 69 74 68 6f 75 74 20   Called without 
19b0: 61 6c 6c 20 6e 65 63 65 73 73 61 72 79 20 6b 65  all necessary ke
19c0: 79 73 22 29 0a 09 20 20 23 66 29 29 29 29 0a 0a  ys")..  #f))))..
19d0: 3b 3b 20 54 68 69 73 20 69 73 20 61 20 64 75 70  ;; This is a dup
19e0: 6c 69 63 61 74 65 20 6f 66 20 72 75 6e 2d 74 65  licate of run-te
19f0: 73 74 73 20 28 77 68 69 63 68 20 68 61 73 20 62  sts (which has b
1a00: 65 65 6e 20 64 65 70 72 65 63 61 74 65 64 29 2e  een deprecated).
1a10: 20 55 73 65 20 74 68 69 73 20 6f 6e 65 20 69 6e   Use this one in
1a20: 73 74 65 61 64 20 6f 66 20 72 75 6e 20 74 65 73  stead of run tes
1a30: 74 73 2e 0a 3b 3b 20 6b 65 79 76 61 6c 73 0a 28  ts..;; keyvals.(
1a40: 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 72 75 6e  define (runs:run
1a50: 2d 74 65 73 74 73 20 64 62 20 74 61 72 67 65 74  -tests db target
1a60: 20 72 75 6e 6e 61 6d 65 20 74 65 73 74 2d 70 61   runname test-pa
1a70: 74 74 73 20 69 74 65 6d 2d 70 61 74 74 73 20 75  tts item-patts u
1a80: 73 65 72 20 66 6c 61 67 73 29 0a 20 20 28 6c 65  ser flags).  (le
1a90: 74 2a 20 28 28 6b 65 79 73 20 20 20 20 20 20 20  t* ((keys       
1aa0: 20 28 64 62 2d 67 65 74 2d 6b 65 79 73 20 64 62   (db-get-keys db
1ab0: 29 29 0a 09 20 28 6b 65 79 76 61 6c 6c 73 74 20  )).. (keyvallst 
1ac0: 20 20 28 6b 65 79 73 3a 74 61 72 67 65 74 2d 3e    (keys:target->
1ad0: 6b 65 79 76 61 6c 20 6b 65 79 73 20 74 61 72 67  keyval keys targ
1ae0: 65 74 29 29 0a 09 20 28 72 75 6e 2d 69 64 20 20  et)).. (run-id  
1af0: 20 20 20 20 28 72 75 6e 73 3a 72 65 67 69 73 74      (runs:regist
1b00: 65 72 2d 72 75 6e 20 64 62 20 6b 65 79 73 20 6b  er-run db keys k
1b10: 65 79 76 61 6c 6c 73 74 20 72 75 6e 6e 61 6d 65  eyvallst runname
1b20: 20 22 6e 65 77 22 20 22 6e 2f 61 22 20 75 73 65   "new" "n/a" use
1b30: 72 29 29 20 20 3b 3b 20 20 74 65 73 74 2d 6e 61  r))  ;;  test-na
1b40: 6d 65 29 29 29 0a 09 20 28 64 65 66 65 72 72 65  me))).. (deferre
1b50: 64 20 20 20 20 27 28 29 29 20 3b 3b 20 64 65 6c  d    '()) ;; del
1b60: 61 79 20 72 75 6e 6e 69 6e 67 20 74 68 65 73 65  ay running these
1b70: 20 73 69 6e 63 65 20 74 68 65 79 20 68 61 76 65   since they have
1b80: 20 61 20 77 61 69 74 6f 6e 20 63 6c 61 75 73 65   a waiton clause
1b90: 0a 09 20 3b 3b 20 6b 65 65 70 67 6f 69 6e 67 20  .. ;; keepgoing 
1ba0: 69 73 20 74 68 65 20 64 65 66 61 63 74 6f 20 6d  is the defacto m
1bb0: 6f 64 61 6c 69 74 79 20 6e 6f 77 2c 20 77 69 6c  odality now, wil
1bc0: 6c 20 61 64 64 20 68 69 74 2d 6e 2d 72 75 6e 20  l add hit-n-run 
1bd0: 61 20 62 69 74 20 6c 61 74 65 72 0a 09 20 3b 3b  a bit later.. ;;
1be0: 20 28 6b 65 65 70 67 6f 69 6e 67 20 20 20 28 68   (keepgoing   (h
1bf0: 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65  ash-table-ref/de
1c00: 66 61 75 6c 74 20 66 6c 61 67 73 20 22 2d 6b 65  fault flags "-ke
1c10: 65 70 67 6f 69 6e 67 22 20 23 66 29 29 0a 09 20  epgoing" #f)).. 
1c20: 28 74 65 73 74 2d 6e 61 6d 65 73 20 20 27 28 29  (test-names  '()
1c30: 29 0a 09 20 28 72 75 6e 63 6f 6e 66 69 67 66 20  ).. (runconfigf 
1c40: 20 20 28 63 6f 6e 63 20 20 2a 74 6f 70 70 61 74    (conc  *toppat
1c50: 68 2a 20 22 2f 72 75 6e 63 6f 6e 66 69 67 73 2e  h* "/runconfigs.
1c60: 63 6f 6e 66 69 67 22 29 29 0a 09 20 28 72 65 71  config")).. (req
1c70: 75 69 72 65 64 2d 74 65 73 74 73 20 27 28 29 29  uired-tests '())
1c80: 0a 09 20 28 74 65 73 74 2d 72 65 63 6f 72 64 73  .. (test-records
1c90: 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c   (make-hash-tabl
1ca0: 65 29 29 29 0a 0a 20 20 20 20 28 73 65 74 2d 6d  e)))..    (set-m
1cb0: 65 67 61 74 65 73 74 2d 65 6e 76 2d 76 61 72 73  egatest-env-vars
1cc0: 20 64 62 20 72 75 6e 2d 69 64 29 20 3b 3b 20 74   db run-id) ;; t
1cd0: 68 65 73 65 20 6d 61 79 20 62 65 20 6e 65 65 64  hese may be need
1ce0: 65 64 20 62 79 20 74 68 65 20 6c 61 75 6e 63 68  ed by the launch
1cf0: 69 6e 67 20 70 72 6f 63 65 73 73 0a 0a 20 20 20  ing process..   
1d00: 20 28 69 66 20 28 66 69 6c 65 2d 65 78 69 73 74   (if (file-exist
1d10: 73 3f 20 72 75 6e 63 6f 6e 66 69 67 66 29 0a 09  s? runconfigf)..
1d20: 28 73 65 74 75 70 2d 65 6e 76 2d 64 65 66 61 75  (setup-env-defau
1d30: 6c 74 73 20 64 62 20 72 75 6e 63 6f 6e 66 69 67  lts db runconfig
1d40: 66 20 72 75 6e 2d 69 64 20 2a 61 6c 72 65 61 64  f run-id *alread
1d50: 79 2d 73 65 65 6e 2d 72 75 6e 63 6f 6e 66 69 67  y-seen-runconfig
1d60: 2d 69 6e 66 6f 2a 20 22 70 72 65 2d 6c 61 75 6e  -info* "pre-laun
1d70: 63 68 2d 65 6e 76 2d 76 61 72 73 22 29 0a 09 28  ch-env-vars")..(
1d80: 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 57  debug:print 0 "W
1d90: 41 52 4e 49 4e 47 3a 20 59 6f 75 20 64 6f 20 6e  ARNING: You do n
1da0: 6f 74 20 68 61 76 65 20 61 20 72 75 6e 20 63 6f  ot have a run co
1db0: 6e 66 69 67 20 66 69 6c 65 3a 20 22 20 72 75 6e  nfig file: " run
1dc0: 63 6f 6e 66 69 67 66 29 29 0a 20 20 20 20 0a 20  configf)).    . 
1dd0: 20 20 20 3b 3b 20 6c 6f 6f 6b 20 75 70 20 61 6c     ;; look up al
1de0: 6c 20 74 65 73 74 73 20 6d 61 74 63 68 69 6e 67  l tests matching
1df0: 20 74 68 65 20 63 6f 6d 6d 61 20 73 65 70 61 72   the comma separ
1e00: 61 74 65 64 20 6c 69 73 74 20 6f 66 20 67 6c 6f  ated list of glo
1e10: 62 73 20 69 6e 0a 20 20 20 20 3b 3b 20 74 65 73  bs in.    ;; tes
1e20: 74 2d 70 61 74 74 73 20 28 75 73 69 6e 67 20 25  t-patts (using %
1e30: 20 61 73 20 77 69 6c 64 63 61 72 64 29 0a 20 20   as wildcard).  
1e40: 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 20 20    (for-each .   
1e50: 20 20 28 6c 61 6d 62 64 61 20 28 70 61 74 74 29    (lambda (patt)
1e60: 0a 20 20 20 20 20 20 20 28 6c 65 74 20 28 28 74  .       (let ((t
1e70: 65 73 74 73 20 28 67 6c 6f 62 20 28 63 6f 6e 63  ests (glob (conc
1e80: 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f 74 65 73   *toppath* "/tes
1e90: 74 73 2f 22 20 28 73 74 72 69 6e 67 2d 74 72 61  ts/" (string-tra
1ea0: 6e 73 6c 61 74 65 20 70 61 74 74 20 22 25 22 20  nslate patt "%" 
1eb0: 22 2a 22 29 29 29 29 29 0a 09 20 28 73 65 74 21  "*"))))).. (set!
1ec0: 20 74 65 73 74 73 20 28 66 69 6c 74 65 72 20 28   tests (filter (
1ed0: 6c 61 6d 62 64 61 20 28 74 65 73 74 29 28 66 69  lambda (test)(fi
1ee0: 6c 65 2d 65 78 69 73 74 73 3f 20 28 63 6f 6e 63  le-exists? (conc
1ef0: 20 74 65 73 74 20 22 2f 74 65 73 74 63 6f 6e 66   test "/testconf
1f00: 69 67 22 29 29 29 20 74 65 73 74 73 29 29 0a 09  ig"))) tests))..
1f10: 20 28 73 65 74 21 20 74 65 73 74 2d 6e 61 6d 65   (set! test-name
1f20: 73 20 28 61 70 70 65 6e 64 20 74 65 73 74 2d 6e  s (append test-n
1f30: 61 6d 65 73 20 0a 09 09 09 09 20 20 28 6d 61 70  ames .....  (map
1f40: 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74 70 29   (lambda (testp)
1f50: 0a 09 09 09 09 09 20 28 6c 61 73 74 20 28 73 74  ...... (last (st
1f60: 72 69 6e 67 2d 73 70 6c 69 74 20 74 65 73 74 70  ring-split testp
1f70: 20 22 2f 22 29 29 29 0a 09 09 09 09 20 20 20 20   "/"))).....    
1f80: 20 20 20 74 65 73 74 73 29 29 29 29 29 0a 20 20     tests))))).  
1f90: 20 20 20 28 69 66 20 74 65 73 74 2d 70 61 74 74     (if test-patt
1fa0: 73 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20  s (string-split 
1fb0: 74 65 73 74 2d 70 61 74 74 73 20 22 2c 22 29 28  test-patts ",")(
1fc0: 6c 69 73 74 20 22 25 22 29 29 29 0a 0a 20 20 20  list "%")))..   
1fd0: 20 20 3b 3b 20 6e 6f 77 20 72 65 6d 6f 76 65 20    ;; now remove 
1fe0: 64 75 70 6c 69 63 61 74 65 73 0a 20 20 20 20 28  duplicates.    (
1ff0: 73 65 74 21 20 74 65 73 74 2d 6e 61 6d 65 73 20  set! test-names 
2000: 28 64 65 6c 65 74 65 2d 64 75 70 6c 69 63 61 74  (delete-duplicat
2010: 65 73 20 74 65 73 74 2d 6e 61 6d 65 73 29 29 0a  es test-names)).
2020: 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e  .    (debug:prin
2030: 74 20 30 20 22 49 4e 46 4f 3a 20 74 65 73 74 20  t 0 "INFO: test 
2040: 6e 61 6d 65 73 20 22 20 74 65 73 74 2d 6e 61 6d  names " test-nam
2050: 65 73 29 0a 0a 20 20 20 20 3b 3b 20 6f 6e 20 74  es)..    ;; on t
2060: 68 65 20 66 69 72 73 74 20 70 61 73 73 20 6f 72  he first pass or
2070: 20 63 61 6c 6c 20 74 6f 20 72 75 6e 2d 74 65 73   call to run-tes
2080: 74 73 20 73 65 74 20 46 41 49 4c 53 20 74 6f 20  ts set FAILS to 
2090: 4e 4f 54 5f 53 54 41 52 54 45 44 20 69 66 0a 20  NOT_STARTED if. 
20a0: 20 20 20 3b 3b 20 2d 6b 65 65 70 67 6f 69 6e 67     ;; -keepgoing
20b0: 20 69 73 20 73 70 65 63 69 66 69 65 64 0a 20 20   is specified.  
20c0: 20 20 28 69 66 20 28 65 71 3f 20 2a 70 61 73 73    (if (eq? *pass
20d0: 6e 75 6d 2a 20 30 29 0a 09 28 62 65 67 69 6e 0a  num* 0)..(begin.
20e0: 09 20 20 3b 3b 20 68 61 76 65 20 74 6f 20 64 65  .  ;; have to de
20f0: 6c 65 74 65 20 74 65 73 74 20 72 65 63 6f 72 64  lete test record
2100: 73 20 77 68 65 72 65 20 4e 4f 54 5f 53 54 41 52  s where NOT_STAR
2110: 54 45 44 20 73 69 6e 63 65 20 74 68 65 79 20 63  TED since they c
2120: 61 6e 20 63 61 75 73 65 20 2d 6b 65 65 70 67 6f  an cause -keepgo
2130: 69 6e 67 20 74 6f 20 0a 09 20 20 3b 3b 20 67 65  ing to ..  ;; ge
2140: 74 20 73 74 75 63 6b 20 64 75 65 20 74 6f 20 62  t stuck due to b
2150: 65 63 6f 6d 69 6e 67 20 69 6e 61 63 63 65 73 73  ecoming inaccess
2160: 69 62 6c 65 20 66 72 6f 6d 20 61 20 66 61 69 6c  ible from a fail
2170: 65 64 20 74 65 73 74 2e 20 49 2e 65 2e 20 69 66  ed test. I.e. if
2180: 20 74 65 73 74 20 42 20 64 65 70 65 6e 64 73 20   test B depends 
2190: 0a 09 20 20 3b 3b 20 6f 6e 20 74 65 73 74 20 41  ..  ;; on test A
21a0: 20 62 75 74 20 74 65 73 74 20 42 20 72 65 61 63   but test B reac
21b0: 68 65 64 20 74 68 65 20 70 6f 69 6e 74 20 6f 6e  hed the point on
21c0: 20 62 65 69 6e 67 20 72 65 67 69 73 74 65 72 65   being registere
21d0: 64 20 61 73 20 4e 4f 54 5f 53 54 41 52 54 45 44  d as NOT_STARTED
21e0: 20 61 6e 64 20 74 65 73 74 0a 09 20 20 3b 3b 20   and test..  ;; 
21f0: 41 20 66 61 69 6c 65 64 20 66 6f 72 20 73 6f 6d  A failed for som
2200: 65 20 72 65 61 73 6f 6e 20 74 68 65 6e 20 6f 6e  e reason then on
2210: 20 72 65 2d 72 75 6e 20 75 73 69 6e 67 20 2d 6b   re-run using -k
2220: 65 65 70 67 6f 69 6e 67 20 74 68 65 20 72 75 6e  eepgoing the run
2230: 20 63 61 6e 20 6e 65 76 65 72 20 63 6f 6d 70 6c   can never compl
2240: 65 74 65 2e 0a 09 20 20 28 64 62 3a 64 65 6c 65  ete...  (db:dele
2250: 74 65 2d 74 65 73 74 73 2d 69 6e 2d 73 74 61 74  te-tests-in-stat
2260: 65 20 64 62 20 72 75 6e 2d 69 64 20 22 4e 4f 54  e db run-id "NOT
2270: 5f 53 54 41 52 54 45 44 22 29 0a 09 20 20 28 64  _STARTED")..  (d
2280: 62 3a 73 65 74 2d 74 65 73 74 73 2d 73 74 61 74  b:set-tests-stat
2290: 65 2d 73 74 61 74 75 73 20 64 62 20 72 75 6e 2d  e-status db run-
22a0: 69 64 20 74 65 73 74 2d 6e 61 6d 65 73 20 23 66  id test-names #f
22b0: 20 22 46 41 49 4c 22 20 22 4e 4f 54 5f 53 54 41   "FAIL" "NOT_STA
22c0: 52 54 45 44 22 20 22 46 41 49 4c 22 29 29 29 0a  RTED" "FAIL"))).
22d0: 0a 20 20 20 20 3b 3b 20 6e 6f 77 20 61 64 64 20  .    ;; now add 
22e0: 6e 6f 6e 2d 64 69 72 65 63 74 6c 79 20 72 65 66  non-directly ref
22f0: 65 72 65 6e 63 65 64 20 64 65 70 65 6e 64 65 6e  erenced dependen
2300: 63 69 65 73 20 28 69 2e 65 2e 20 77 61 69 74 6f  cies (i.e. waito
2310: 6e 29 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20  n).    (if (not 
2320: 28 6e 75 6c 6c 3f 20 74 65 73 74 2d 6e 61 6d 65  (null? test-name
2330: 73 29 29 0a 09 28 6c 65 74 20 6c 6f 6f 70 20 28  s))..(let loop (
2340: 28 68 65 64 20 28 63 61 72 20 74 65 73 74 2d 6e  (hed (car test-n
2350: 61 6d 65 73 29 29 0a 09 09 20 20 20 28 74 61 6c  ames))...   (tal
2360: 20 28 63 64 72 20 74 65 73 74 2d 6e 61 6d 65 73   (cdr test-names
2370: 29 29 29 20 20 20 20 20 20 20 20 20 3b 3b 20 27  )))         ;; '
2380: 72 65 74 75 72 6e 2d 70 72 6f 63 73 20 74 65 6c  return-procs tel
2390: 6c 73 20 74 68 65 20 63 6f 6e 66 69 67 20 72 65  ls the config re
23a0: 61 64 65 72 20 74 6f 20 70 72 65 70 20 72 75 6e  ader to prep run
23b0: 6e 69 6e 67 20 73 79 73 74 65 6d 20 62 75 74 20  ning system but 
23c0: 72 65 74 75 72 6e 20 61 20 70 72 6f 63 0a 09 20  return a proc.. 
23d0: 20 28 6c 65 74 2a 20 28 28 63 6f 6e 66 69 67 20   (let* ((config 
23e0: 20 28 74 65 73 74 3a 67 65 74 2d 74 65 73 74 63   (test:get-testc
23f0: 6f 6e 66 69 67 20 68 65 64 20 27 72 65 74 75 72  onfig hed 'retur
2400: 6e 2d 70 72 6f 63 73 29 29 0a 09 09 20 28 77 61  n-procs))... (wa
2410: 69 74 6f 6e 73 20 28 73 74 72 69 6e 67 2d 73 70  itons (string-sp
2420: 6c 69 74 20 28 6c 65 74 20 28 28 77 20 28 63 6f  lit (let ((w (co
2430: 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 63 6f 6e 66  nfig-lookup conf
2440: 69 67 20 22 72 65 71 75 69 72 65 6d 65 6e 74 73  ig "requirements
2450: 22 20 22 77 61 69 74 6f 6e 22 29 29 29 0a 09 09  " "waiton")))...
2460: 09 09 09 20 20 28 69 66 20 77 20 77 20 22 22 29  ...  (if w w "")
2470: 29 29 29 29 0a 3b 3b 09 09 20 28 69 74 65 6d 73  )))).;;.. (items
2480: 20 20 20 28 69 74 65 6d 73 3a 67 65 74 2d 69 74     (items:get-it
2490: 65 6d 73 2d 66 72 6f 6d 2d 63 6f 6e 66 69 67 20  ems-from-config 
24a0: 63 6f 6e 66 69 67 29 29 29 0a 09 20 20 20 20 28  config)))..    (
24b0: 69 66 20 28 6e 6f 74 20 28 68 61 73 68 2d 74 61  if (not (hash-ta
24c0: 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20  ble-ref/default 
24d0: 74 65 73 74 2d 72 65 63 6f 72 64 73 20 68 65 64  test-records hed
24e0: 20 23 66 29 29 0a 09 09 28 68 61 73 68 2d 74 61   #f))...(hash-ta
24f0: 62 6c 65 2d 73 65 74 21 20 74 65 73 74 2d 72 65  ble-set! test-re
2500: 63 6f 72 64 73 0a 09 09 09 09 20 68 65 64 20 28  cords..... hed (
2510: 76 65 63 74 6f 72 20 68 65 64 20 20 20 20 20 3b  vector hed     ;
2520: 3b 20 30 0a 09 09 09 09 09 20 20 20 20 20 63 6f  ; 0......     co
2530: 6e 66 69 67 20 20 3b 3b 20 31 0a 09 09 09 09 09  nfig  ;; 1......
2540: 20 20 20 20 20 77 61 69 74 6f 6e 73 20 3b 3b 20       waitons ;; 
2550: 32 0a 09 09 09 09 09 20 20 20 20 20 28 63 6f 6e  2......     (con
2560: 66 69 67 2d 6c 6f 6f 6b 75 70 20 63 6f 6e 66 69  fig-lookup confi
2570: 67 20 22 72 65 71 75 69 72 65 6d 65 6e 74 73 22  g "requirements"
2580: 20 22 70 72 69 6f 72 69 74 79 22 29 0a 09 09 09   "priority")....
2590: 09 09 20 20 20 20 20 23 66 20 20 20 20 20 20 3b  ..     #f      ;
25a0: 3b 20 34 0a 09 09 09 09 09 20 20 20 20 20 23 66  ; 4......     #f
25b0: 20 20 20 20 20 20 3b 3b 20 35 0a 09 09 09 09 09        ;; 5......
25c0: 20 20 20 20 20 23 66 20 20 20 20 20 20 3b 3b 20       #f      ;; 
25d0: 73 70 61 72 65 0a 09 09 09 09 09 20 20 20 20 20  spare......     
25e0: 29 29 29 0a 09 20 20 20 20 28 66 6f 72 2d 65 61  )))..    (for-ea
25f0: 63 68 20 0a 09 20 20 20 20 20 28 6c 61 6d 62 64  ch ..     (lambd
2600: 61 20 28 77 61 69 74 6f 6e 29 0a 09 20 20 20 20  a (waiton)..    
2610: 20 20 20 28 69 66 20 28 61 6e 64 20 77 61 69 74     (if (and wait
2620: 6f 6e 20 28 6e 6f 74 20 28 6d 65 6d 62 65 72 20  on (not (member 
2630: 77 61 69 74 6f 6e 20 74 65 73 74 2d 6e 61 6d 65  waiton test-name
2640: 73 29 29 29 0a 09 09 20 20 20 28 62 65 67 69 6e  s)))...   (begin
2650: 0a 09 09 20 20 20 20 20 28 73 65 74 21 20 72 65  ...     (set! re
2660: 71 75 69 72 65 64 2d 74 65 73 74 73 20 28 63 6f  quired-tests (co
2670: 6e 73 20 77 61 69 74 6f 6e 20 72 65 71 75 69 72  ns waiton requir
2680: 65 64 2d 74 65 73 74 73 29 29 0a 09 09 20 20 20  ed-tests))...   
2690: 20 20 28 73 65 74 21 20 74 65 73 74 2d 6e 61 6d    (set! test-nam
26a0: 65 73 20 28 61 70 70 65 6e 64 20 74 65 73 74 2d  es (append test-
26b0: 6e 61 6d 65 73 20 28 6c 69 73 74 20 77 61 69 74  names (list wait
26c0: 6f 6e 29 29 29 29 29 29 0a 09 20 20 20 20 20 77  on))))))..     w
26d0: 61 69 74 6f 6e 73 29 0a 09 20 20 20 20 28 6c 65  aitons)..    (le
26e0: 74 20 28 28 72 65 6d 74 65 73 74 73 20 28 64 65  t ((remtests (de
26f0: 6c 65 74 65 2d 64 75 70 6c 69 63 61 74 65 73 20  lete-duplicates 
2700: 28 61 70 70 65 6e 64 20 77 61 69 74 6f 6e 73 20  (append waitons 
2710: 74 61 6c 29 29 29 29 0a 09 20 20 20 20 20 20 28  tal))))..      (
2720: 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 72  if (not (null? r
2730: 65 6d 74 65 73 74 73 29 29 0a 09 09 20 20 28 6c  emtests))...  (l
2740: 6f 6f 70 20 28 63 61 72 20 72 65 6d 74 65 73 74  oop (car remtest
2750: 73 29 28 63 64 72 20 72 65 6d 74 65 73 74 73 29  s)(cdr remtests)
2760: 29 29 29 29 29 29 0a 0a 20 20 20 20 28 69 66 20  ))))))..    (if 
2770: 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 72 65 71 75  (not (null? requ
2780: 69 72 65 64 2d 74 65 73 74 73 29 29 0a 09 28 64  ired-tests))..(d
2790: 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 49 4e  ebug:print 1 "IN
27a0: 46 4f 3a 20 41 64 64 69 6e 67 20 22 20 72 65 71  FO: Adding " req
27b0: 75 69 72 65 64 2d 74 65 73 74 73 20 22 20 74 6f  uired-tests " to
27c0: 20 74 68 65 20 72 75 6e 20 71 75 65 75 65 22 29   the run queue")
27d0: 29 0a 20 20 20 20 3b 3b 20 4e 4f 54 45 3a 20 74  ).    ;; NOTE: t
27e0: 68 65 73 65 20 61 72 65 20 61 6c 6c 20 70 61 72  hese are all par
27f0: 65 6e 74 20 74 65 73 74 73 2c 20 69 74 65 6d 73  ent tests, items
2800: 20 61 72 65 20 6e 6f 74 20 65 78 70 61 6e 64 65   are not expande
2810: 64 20 79 65 74 2e 0a 20 20 20 20 28 72 75 6e 73  d yet..    (runs
2820: 3a 72 75 6e 2d 74 65 73 74 73 2d 71 75 65 75 65  :run-tests-queue
2830: 20 64 62 20 72 75 6e 2d 69 64 20 72 75 6e 6e 61   db run-id runna
2840: 6d 65 20 74 65 73 74 2d 72 65 63 6f 72 64 73 20  me test-records 
2850: 6b 65 79 76 61 6c 6c 73 74 20 66 6c 61 67 73 29  keyvallst flags)
2860: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 72 75 6e  ))..(define (run
2870: 73 3a 72 75 6e 2d 74 65 73 74 73 2d 71 75 65 75  s:run-tests-queu
2880: 65 20 64 62 20 72 75 6e 2d 69 64 20 72 75 6e 6e  e db run-id runn
2890: 61 6d 65 20 74 65 73 74 2d 72 65 63 6f 72 64 73  ame test-records
28a0: 20 6b 65 79 76 61 6c 6c 73 74 20 66 6c 61 67 73   keyvallst flags
28b0: 29 0a 20 20 20 20 3b 3b 20 41 74 20 74 68 69 73  ).    ;; At this
28c0: 20 70 6f 69 6e 74 20 74 68 65 20 6c 69 73 74 20   point the list 
28d0: 6f 66 20 70 61 72 65 6e 74 20 74 65 73 74 73 20  of parent tests 
28e0: 69 73 20 65 78 70 61 6e 64 65 64 20 0a 20 20 20  is expanded .   
28f0: 20 3b 3b 20 4e 42 2f 2f 20 53 68 6f 75 6c 64 20   ;; NB// Should 
2900: 65 78 70 61 6e 64 20 69 74 65 6d 73 20 68 65 72  expand items her
2910: 65 20 61 6e 64 20 74 68 65 6e 20 69 6e 73 65 72  e and then inser
2920: 74 20 69 6e 74 6f 20 74 68 65 20 72 75 6e 20 71  t into the run q
2930: 75 65 75 65 2e 0a 20 20 28 64 65 62 75 67 3a 70  ueue..  (debug:p
2940: 72 69 6e 74 20 35 20 22 74 65 73 74 2d 72 65 63  rint 5 "test-rec
2950: 6f 72 64 73 3a 20 22 20 74 65 73 74 2d 72 65 63  ords: " test-rec
2960: 6f 72 64 73 20 22 2c 20 6b 65 79 76 61 6c 6c 73  ords ", keyvalls
2970: 74 3a 20 22 20 6b 65 79 76 61 6c 6c 73 74 29 0a  t: " keyvallst).
2980: 20 20 28 6c 65 74 20 28 28 73 6f 72 74 65 64 2d    (let ((sorted-
2990: 74 65 73 74 2d 6e 61 6d 65 73 20 28 74 65 73 74  test-names (test
29a0: 73 3a 73 6f 72 74 2d 62 79 2d 70 72 69 6f 72 69  s:sort-by-priori
29b0: 74 79 2d 61 6e 64 2d 77 61 69 74 6f 6e 20 74 65  ty-and-waiton te
29c0: 73 74 2d 72 65 63 6f 72 64 73 29 29 29 0a 20 20  st-records))).  
29d0: 20 20 28 6c 65 74 20 6c 6f 6f 70 20 28 3b 20 28    (let loop (; (
29e0: 6e 75 6d 74 69 6d 65 73 20 30 29 20 3b 3b 20 73  numtimes 0) ;; s
29f0: 68 6f 75 6c 64 6e 27 74 20 6e 65 65 64 20 74 68  houldn't need th
2a00: 69 73 0a 09 20 20 20 20 20 20 20 28 68 65 64 20  is..       (hed 
2a10: 20 20 20 20 20 20 20 20 28 63 61 72 20 73 6f 72          (car sor
2a20: 74 65 64 2d 74 65 73 74 2d 6e 61 6d 65 73 29 29  ted-test-names))
2a30: 0a 09 20 20 20 20 20 20 20 28 74 61 6c 20 20 20  ..       (tal   
2a40: 20 20 20 20 20 20 28 63 64 72 20 73 6f 72 74 65        (cdr sorte
2a50: 64 2d 74 65 73 74 2d 6e 61 6d 65 73 29 29 29 0a  d-test-names))).
2a60: 20 20 20 20 20 20 28 6c 65 74 2a 20 28 28 74 65        (let* ((te
2a70: 73 74 2d 72 65 63 6f 72 64 20 28 68 61 73 68 2d  st-record (hash-
2a80: 74 61 62 6c 65 2d 72 65 66 20 74 65 73 74 2d 72  table-ref test-r
2a90: 65 63 6f 72 64 73 20 68 65 64 29 29 0a 09 20 20  ecords hed))..  
2aa0: 20 20 20 28 74 63 6f 6e 66 69 67 20 20 20 20 20     (tconfig     
2ab0: 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65  (tests:testqueue
2ac0: 2d 67 65 74 2d 74 65 73 74 63 6f 6e 66 69 67 20  -get-testconfig 
2ad0: 74 65 73 74 2d 72 65 63 6f 72 64 29 29 0a 09 20  test-record)).. 
2ae0: 20 20 20 20 28 77 61 69 74 6f 6e 73 20 20 20 20      (waitons    
2af0: 20 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75   (tests:testqueu
2b00: 65 2d 67 65 74 2d 77 61 69 74 6f 6e 73 20 20 20  e-get-waitons   
2b10: 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29 0a 09   test-record))..
2b20: 20 20 20 20 20 28 70 72 69 6f 72 69 74 79 20 20       (priority  
2b30: 20 20 28 74 65 73 74 73 3a 74 65 73 74 71 75 65    (tests:testque
2b40: 75 65 2d 67 65 74 2d 70 72 69 6f 72 69 74 79 20  ue-get-priority 
2b50: 20 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29 0a    test-record)).
2b60: 09 20 20 20 20 20 28 69 74 65 6d 64 61 74 20 20  .     (itemdat  
2b70: 20 20 20 28 74 65 73 74 73 3a 74 65 73 74 71 75     (tests:testqu
2b80: 65 75 65 2d 67 65 74 2d 69 74 65 6d 64 61 74 20  eue-get-itemdat 
2b90: 20 20 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29     test-record))
2ba0: 0a 09 20 20 20 20 20 28 69 74 65 6d 73 20 20 20  ..     (items   
2bb0: 20 20 20 20 28 74 65 73 74 73 3a 74 65 73 74 71      (tests:testq
2bc0: 75 65 75 65 2d 67 65 74 2d 69 74 65 6d 73 20 20  ueue-get-items  
2bd0: 20 20 20 20 74 65 73 74 2d 72 65 63 6f 72 64 29      test-record)
2be0: 29 0a 09 20 20 20 20 20 28 69 74 65 6d 2d 70 61  )..     (item-pa
2bf0: 74 68 20 20 20 28 69 74 65 6d 2d 6c 69 73 74 2d  th   (item-list-
2c00: 3e 70 61 74 68 20 69 74 65 6d 64 61 74 29 29 29  >path itemdat)))
2c10: 0a 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30  ..(debug:print 0
2c20: 20 22 57 48 45 52 45 20 54 4f 20 44 4f 3a 20 28   "WHERE TO DO: (
2c30: 69 74 65 6d 73 3a 67 65 74 2d 69 74 65 6d 73 2d  items:get-items-
2c40: 66 72 6f 6d 2d 63 6f 6e 66 69 67 20 63 6f 6e 66  from-config conf
2c50: 69 67 29 22 29 0a 09 28 63 6f 6e 64 0a 09 20 28  ig)")..(cond.. (
2c60: 28 6e 6f 74 20 69 74 65 6d 73 29 20 3b 3b 20 77  (not items) ;; w
2c70: 68 65 6e 20 66 61 6c 73 65 20 74 68 65 20 74 65  hen false the te
2c80: 73 74 20 69 73 20 6f 6b 20 74 6f 20 62 65 20 68  st is ok to be h
2c90: 61 6e 64 65 64 20 6f 66 66 20 74 6f 20 6c 61 75  anded off to lau
2ca0: 6e 63 68 0a 09 20 20 28 6c 65 74 20 28 28 68 61  nch..  (let ((ha
2cb0: 76 65 2d 72 65 73 6f 75 72 63 65 73 20 20 28 72  ve-resources  (r
2cc0: 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65  uns:can-run-more
2cd0: 2d 74 65 73 74 73 20 64 62 20 74 65 73 74 2d 72  -tests db test-r
2ce0: 65 63 6f 72 64 29 29 20 3b 3b 20 6c 6f 6f 6b 20  ecord)) ;; look 
2cf0: 61 74 20 74 68 65 20 74 65 73 74 20 6a 6f 62 67  at the test jobg
2d00: 72 6f 75 70 20 61 6e 64 20 74 6f 74 20 6a 6f 62  roup and tot job
2d10: 73 20 72 75 6e 6e 69 6e 67 0a 09 09 28 70 72 65  s running...(pre
2d20: 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 20 28 64 62  reqs-not-met (db
2d30: 3a 67 65 74 2d 70 72 65 72 65 71 73 2d 6e 6f 74  :get-prereqs-not
2d40: 2d 6d 65 74 20 64 62 20 72 75 6e 2d 69 64 20 77  -met db run-id w
2d50: 61 69 74 6f 6e 73 20 69 74 65 6d 2d 70 61 74 68  aitons item-path
2d60: 29 29 29 0a 09 20 20 20 20 28 69 66 20 28 61 6e  )))..    (if (an
2d70: 64 20 68 61 76 65 2d 72 65 73 6f 75 72 63 65 73  d have-resources
2d80: 0a 09 09 20 20 20 20 20 28 6e 75 6c 6c 3f 20 70  ...     (null? p
2d90: 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 29 29  rereqs-not-met))
2da0: 0a 09 09 3b 3b 20 6e 6f 20 6c 6f 6f 70 20 2d 20  ...;; no loop - 
2db0: 64 72 6f 70 20 74 68 6f 75 67 68 20 61 6e 64 20  drop though and 
2dc0: 75 73 65 20 74 68 65 20 6c 6f 6f 70 20 61 74 20  use the loop at 
2dd0: 74 68 65 20 62 6f 74 74 6f 6d 20 0a 09 09 28 72  the bottom ...(r
2de0: 75 6e 3a 74 65 73 74 20 64 62 20 72 75 6e 2d 69  un:test db run-i
2df0: 64 20 72 75 6e 6e 61 6d 65 20 6b 65 79 76 61 6c  d runname keyval
2e00: 6c 73 74 20 74 65 73 74 2d 72 65 63 6f 72 64 20  lst test-record 
2e10: 66 6c 61 67 73 29 0a 09 09 3b 3b 20 65 6c 73 65  flags)...;; else
2e20: 20 74 68 65 20 72 75 6e 20 69 73 20 73 74 75 63   the run is stuc
2e30: 6b 2c 20 74 65 6d 70 6f 72 61 72 69 6c 79 20 6f  k, temporarily o
2e40: 72 20 70 65 72 6d 61 6e 65 6e 74 6c 79 0a 09 09  r permanently...
2e50: 28 6c 65 74 20 28 28 6e 65 77 74 61 6c 20 28 61  (let ((newtal (a
2e60: 70 70 65 6e 64 20 74 61 6c 20 28 6c 69 73 74 20  ppend tal (list 
2e70: 68 65 64 29 29 29 29 0a 09 09 20 20 3b 3b 20 63  hed))))...  ;; c
2e80: 6f 75 6c 64 6e 27 74 20 72 75 6e 2c 20 74 61 6b  ouldn't run, tak
2e90: 65 20 61 20 62 72 65 61 74 68 65 72 0a 09 09 20  e a breather... 
2ea0: 20 28 74 68 72 65 61 64 2d 73 6c 65 65 70 21 20   (thread-sleep! 
2eb0: 31 29 0a 09 09 20 20 28 6c 6f 6f 70 20 28 63 61  1)...  (loop (ca
2ec0: 72 20 74 61 6c 29 28 63 64 72 20 74 61 6c 29 29  r tal)(cdr tal))
2ed0: 29 29 29 29 0a 09 20 0a 09 20 3b 3b 20 63 61 73  )))).. .. ;; cas
2ee0: 65 20 77 68 65 72 65 20 61 6e 20 69 74 65 6d 73  e where an items
2ef0: 20 63 61 6d 65 20 69 6e 20 61 73 20 61 20 6c 69   came in as a li
2f00: 73 74 20 62 65 65 6e 20 70 72 6f 63 65 73 73 65  st been processe
2f10: 64 0a 09 20 28 28 61 6e 64 20 28 6c 69 73 74 3f  d.. ((and (list?
2f20: 20 69 74 65 6d 73 29 20 20 20 20 20 3b 3b 20 74   items)     ;; t
2f30: 68 75 73 20 77 65 20 6b 6e 6f 77 20 6f 75 72 20  hus we know our 
2f40: 69 74 65 6d 73 20 61 72 65 20 61 6c 72 65 61 64  items are alread
2f50: 79 20 63 61 6c 63 75 6c 61 74 65 64 0a 09 20 20  y calculated..  
2f60: 20 20 20 20 20 28 6e 6f 74 20 20 20 69 74 65 6d       (not   item
2f70: 64 61 74 29 29 20 3b 3b 20 61 6e 64 20 6e 6f 74  dat)) ;; and not
2f80: 20 79 65 74 20 65 78 70 61 6e 64 65 64 20 69 6e   yet expanded in
2f90: 74 6f 20 74 68 65 20 6c 69 73 74 20 6f 66 20 74  to the list of t
2fa0: 68 69 6e 67 73 20 74 6f 20 62 65 20 64 6f 6e 65  hings to be done
2fb0: 0a 09 20 20 28 69 66 20 28 3e 3d 20 2a 76 65 72  ..  (if (>= *ver
2fc0: 62 6f 73 69 74 79 2a 20 31 29 28 70 70 20 69 74  bosity* 1)(pp it
2fd0: 65 6d 73 29 29 0a 09 20 20 3b 3b 20 28 69 66 20  ems))..  ;; (if 
2fe0: 28 3e 3d 20 2a 76 65 72 62 6f 73 69 74 79 2a 20  (>= *verbosity* 
2ff0: 35 29 0a 09 20 20 3b 3b 20 20 20 20 20 28 62 65  5)..  ;;     (be
3000: 67 69 6e 0a 09 20 20 3b 3b 20 20 20 20 20 20 20  gin..  ;;       
3010: 28 70 72 69 6e 74 20 22 69 74 65 6d 73 3a 20 22  (print "items: "
3020: 29 20 20 20 20 20 28 70 70 20 28 69 74 65 6d 2d  )     (pp (item-
3030: 61 73 73 6f 63 2d 3e 69 74 65 6d 2d 6c 69 73 74  assoc->item-list
3040: 20 69 74 65 6d 73 29 29 0a 09 20 20 3b 3b 20 20   items))..  ;;  
3050: 20 20 20 20 20 28 70 72 69 6e 74 20 22 69 74 65       (print "ite
3060: 6d 73 74 61 62 6c 65 3a 20 22 29 28 70 70 20 28  mstable: ")(pp (
3070: 69 74 65 6d 2d 74 61 62 6c 65 2d 3e 69 74 65 6d  item-table->item
3080: 2d 6c 69 73 74 20 69 74 65 6d 73 74 61 62 6c 65  -list itemstable
3090: 29 29 29 29 0a 09 20 20 28 66 6f 72 2d 65 61 63  ))))..  (for-eac
30a0: 68 0a 09 20 20 20 28 6c 61 6d 62 64 61 20 28 6d  h..   (lambda (m
30b0: 79 2d 69 74 65 6d 64 61 74 29 0a 09 20 20 20 20  y-itemdat)..    
30c0: 20 28 6c 65 74 2a 20 28 28 6e 65 77 2d 74 65 73   (let* ((new-tes
30d0: 74 2d 72 65 63 6f 72 64 20 28 76 65 63 74 6f 72  t-record (vector
30e0: 2d 63 6f 70 79 21 20 74 65 73 74 2d 72 65 63 6f  -copy! test-reco
30f0: 72 64 20 28 6d 61 6b 65 2d 74 65 73 74 73 3a 74  rd (make-tests:t
3100: 65 73 74 71 75 65 75 65 29 29 29 0a 09 09 20 20  estqueue)))...  
3110: 20 20 28 6d 79 2d 69 74 65 6d 2d 70 61 74 68 20    (my-item-path 
3120: 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68  (item-list->path
3130: 20 6d 79 2d 69 74 65 6d 64 61 74 29 29 0a 09 09   my-itemdat))...
3140: 20 20 20 20 28 69 74 65 6d 2d 6d 61 74 63 68 65      (item-matche
3150: 73 20 28 69 66 20 69 74 65 6d 2d 70 61 74 74 73  s (if item-patts
3160: 20 20 20 20 20 20 20 3b 3b 20 68 65 72 65 20 77         ;; here w
3170: 65 20 61 72 65 20 66 69 6c 74 65 72 69 6e 67 20  e are filtering 
3180: 66 6f 72 20 6d 61 74 63 68 65 73 20 77 69 74 68  for matches with
3190: 20 2d 69 74 65 6d 70 61 74 74 0a 09 09 09 09 20   -itempatt..... 
31a0: 20 20 20 20 20 28 6c 65 74 20 28 28 72 65 73 20       (let ((res 
31b0: 23 66 29 29 09 20 3b 3b 20 6c 6f 6f 6b 20 74 68  #f)). ;; look th
31c0: 72 6f 75 67 68 20 61 6c 6c 20 74 68 65 20 69 74  rough all the it
31d0: 65 6d 2d 70 61 74 74 73 20 69 66 20 64 65 66 69  em-patts if defi
31e0: 6e 65 64 2c 20 66 6f 72 6d 61 74 20 69 73 20 70  ned, format is p
31f0: 61 74 74 31 2c 70 61 74 74 32 2c 70 61 74 74 33  att1,patt2,patt3
3200: 20 2e 2e 2e 20 77 69 6c 64 63 61 72 64 20 69 73   ... wildcard is
3210: 20 25 0a 09 09 09 09 09 28 66 6f 72 2d 65 61 63   %......(for-eac
3220: 68 20 0a 09 09 09 09 09 20 28 6c 61 6d 62 64 61  h ...... (lambda
3230: 20 28 70 61 74 74 29 0a 09 09 09 09 09 20 20 20   (patt)......   
3240: 28 69 66 20 28 73 74 72 69 6e 67 2d 73 65 61 72  (if (string-sear
3250: 63 68 20 28 67 6c 6f 62 2d 3e 72 65 67 65 78 70  ch (glob->regexp
3260: 0a 09 09 09 09 09 09 09 20 20 20 20 20 20 20 28  ........       (
3270: 73 74 72 69 6e 67 2d 74 72 61 6e 73 6c 61 74 65  string-translate
3280: 20 70 61 74 74 20 22 25 22 20 22 2a 22 29 29 0a   patt "%" "*")).
3290: 09 09 09 09 09 09 09 20 20 20 20 20 20 69 74 65  .......      ite
32a0: 6d 2d 70 61 74 68 29 0a 09 09 09 09 09 20 20 20  m-path)......   
32b0: 20 20 20 20 28 73 65 74 21 20 72 65 73 20 23 74      (set! res #t
32c0: 29 29 29 0a 09 09 09 09 09 20 28 73 74 72 69 6e  )))...... (strin
32d0: 67 2d 73 70 6c 69 74 20 69 74 65 6d 2d 70 61 74  g-split item-pat
32e0: 74 73 20 22 2c 22 29 29 0a 09 09 09 09 09 72 65  ts ","))......re
32f0: 73 29 0a 09 09 09 09 20 20 20 20 20 20 23 74 29  s).....      #t)
3300: 29 29 0a 09 20 20 20 20 20 20 20 28 69 66 20 69  ))..       (if i
3310: 74 65 6d 2d 6d 61 74 63 68 65 73 20 3b 3b 20 79  tem-matches ;; y
3320: 65 73 2c 20 77 65 20 77 61 6e 74 20 74 6f 20 70  es, we want to p
3330: 72 6f 63 65 73 73 20 74 68 69 73 20 69 74 65 6d  rocess this item
3340: 0a 09 09 20 20 20 28 62 65 67 69 6e 0a 09 09 20  ...   (begin... 
3350: 20 20 20 20 28 74 65 73 74 73 3a 74 65 73 74 71      (tests:testq
3360: 75 65 75 65 2d 73 65 74 2d 69 74 65 6d 73 21 20  ueue-set-items! 
3370: 20 20 6e 65 77 2d 74 65 73 74 2d 72 65 63 6f 72    new-test-recor
3380: 64 20 23 66 29 0a 09 09 20 20 20 20 20 28 74 65  d #f)...     (te
3390: 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d 73 65  sts:testqueue-se
33a0: 74 2d 69 74 65 6d 64 61 74 21 20 6e 65 77 2d 74  t-itemdat! new-t
33b0: 65 73 74 2d 72 65 63 6f 72 64 20 6d 79 2d 69 74  est-record my-it
33c0: 65 6d 64 61 74 29 0a 09 09 20 20 20 20 20 28 73  emdat)...     (s
33d0: 65 74 21 20 74 61 6c 20 28 63 6f 6e 73 20 28 63  et! tal (cons (c
33e0: 6f 6e 63 20 68 65 64 20 22 2f 22 20 6d 79 2d 69  onc hed "/" my-i
33f0: 74 65 6d 2d 70 61 74 68 29 20 74 61 6c 29 29 29  tem-path) tal)))
3400: 29 29 29 20 3b 3b 20 73 69 6e 63 65 20 74 68 65  ))) ;; since the
3410: 73 65 20 61 72 65 20 69 74 65 6d 69 7a 65 64 20  se are itemized 
3420: 63 72 65 61 74 65 20 6e 65 77 20 74 65 73 74 20  create new test 
3430: 6e 61 6d 65 73 20 74 65 73 74 6e 61 6d 65 2f 69  names testname/i
3440: 74 65 6d 70 61 74 68 0a 09 20 20 20 69 74 65 6d  tempath..   item
3450: 73 29 0a 09 20 20 28 6c 6f 6f 70 20 28 63 61 72  s)..  (loop (car
3460: 20 74 61 6c 29 28 63 64 72 20 74 61 6c 29 29 29   tal)(cdr tal)))
3470: 0a 0a 09 20 3b 3b 20 69 66 20 69 74 65 6d 73 20  ... ;; if items 
3480: 69 73 20 61 20 70 72 6f 63 20 74 68 65 6e 20 6e  is a proc then n
3490: 65 65 64 20 74 6f 20 65 76 61 6c 75 61 74 65 2c  eed to evaluate,
34a0: 20 67 65 74 20 74 68 65 20 6c 69 73 74 20 61 6e   get the list an
34b0: 64 20 6c 6f 6f 70 20 2d 20 62 75 74 20 6f 6e 6c  d loop - but onl
34c0: 79 20 64 6f 20 74 68 61 74 20 69 66 20 0a 09 20  y do that if .. 
34d0: 3b 3b 20 72 65 73 6f 75 72 63 65 73 20 65 78 69  ;; resources exi
34e0: 73 74 20 74 6f 20 6b 69 63 6b 20 6f 66 66 20 74  st to kick off t
34f0: 68 65 20 6a 6f 62 0a 09 20 28 28 70 72 6f 63 65  he job.. ((proce
3500: 64 75 72 65 3f 20 69 74 65 6d 73 29 0a 09 20 20  dure? items)..  
3510: 28 69 66 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75  (if (runs:can-ru
3520: 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64 62 20  n-more-tests db 
3530: 74 65 73 74 2d 72 65 63 6f 72 64 29 0a 09 20 20  test-record)..  
3540: 20 20 20 20 28 6c 65 74 20 28 28 69 74 65 6d 73      (let ((items
3550: 2d 6c 69 73 74 20 28 69 74 65 6d 73 29 29 29 0a  -list (items))).
3560: 09 09 0a 09 09 28 69 66 20 28 6c 69 73 74 3f 20  .....(if (list? 
3570: 69 74 65 6d 73 2d 6c 69 73 74 29 0a 09 09 20 20  items-list)...  
3580: 20 20 28 62 65 67 69 6e 0a 09 09 20 20 20 20 20    (begin...     
3590: 20 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75   (tests:testqueu
35a0: 65 2d 73 65 74 2d 69 74 65 6d 73 20 74 65 73 74  e-set-items test
35b0: 2d 72 65 63 6f 72 64 20 69 74 65 6d 73 2d 6c 69  -record items-li
35c0: 73 74 29 0a 09 09 20 20 20 20 20 20 28 6c 6f 6f  st)...      (loo
35d0: 70 20 68 65 64 20 74 61 6c 29 29 0a 09 09 20 20  p hed tal))...  
35e0: 20 20 28 62 65 67 69 6e 0a 09 09 20 20 20 20 20    (begin...     
35f0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
3600: 22 45 52 52 4f 52 3a 20 54 68 65 20 70 72 6f 63  "ERROR: The proc
3610: 20 66 72 6f 6d 20 72 65 61 64 69 6e 67 20 74 68   from reading th
3620: 65 20 73 65 74 75 70 20 64 69 64 20 6e 6f 74 20  e setup did not 
3630: 79 69 65 6c 64 20 61 20 6c 69 73 74 20 2d 20 70  yield a list - p
3640: 6c 65 61 73 65 20 72 65 70 6f 72 74 20 74 68 69  lease report thi
3650: 73 22 29 0a 09 09 20 20 20 20 20 20 28 65 78 69  s")...      (exi
3660: 74 20 31 29 29 29 29 0a 09 20 20 20 20 20 20 28  t 1))))..      (
3670: 6c 65 74 20 28 28 6e 65 77 74 61 6c 20 28 61 70  let ((newtal (ap
3680: 70 65 6e 64 20 74 61 6c 20 28 6c 69 73 74 20 68  pend tal (list h
3690: 65 64 29 29 29 29 0a 09 09 3b 3b 20 69 66 20 63  ed))))...;; if c
36a0: 61 6e 27 74 20 72 75 6e 20 6d 6f 72 65 20 74 65  an't run more te
36b0: 73 74 73 2c 20 6c 65 74 73 20 74 61 6b 65 20 61  sts, lets take a
36c0: 20 62 72 65 61 74 68 65 72 0a 09 09 28 74 68 72   breather...(thr
36d0: 65 61 64 2d 73 6c 65 65 70 21 20 31 29 0a 09 09  ead-sleep! 1)...
36e0: 28 6c 6f 6f 70 20 28 63 61 72 20 6e 65 77 74 61  (loop (car newta
36f0: 6c 29 28 63 64 72 20 6e 65 77 74 61 6c 29 29 29  l)(cdr newtal)))
3700: 29 29 0a 0a 09 20 3b 3b 20 74 68 69 73 20 63 61  ))... ;; this ca
3710: 73 65 20 73 68 6f 75 6c 64 20 6e 6f 74 20 68 61  se should not ha
3720: 70 70 65 6e 2c 20 61 64 64 65 64 20 74 6f 20 68  ppen, added to h
3730: 65 6c 70 20 63 61 74 63 68 20 61 6e 79 20 62 75  elp catch any bu
3740: 67 73 0a 09 20 28 28 61 6e 64 20 28 6c 69 73 74  gs.. ((and (list
3750: 3f 20 69 74 65 6d 73 29 20 69 74 65 6d 64 61 74  ? items) itemdat
3760: 29 0a 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e  )..  (debug:prin
3770: 74 20 30 20 22 45 52 52 4f 52 3a 20 53 68 6f 75  t 0 "ERROR: Shou
3780: 6c 64 20 6e 6f 74 20 68 61 76 65 20 61 20 6c 69  ld not have a li
3790: 73 74 20 6f 66 20 69 74 65 6d 73 20 69 6e 20 61  st of items in a
37a0: 20 74 65 73 74 20 61 6e 64 20 74 68 65 20 69 74   test and the it
37b0: 65 6d 73 70 61 74 68 20 73 65 74 20 2d 20 70 6c  emspath set - pl
37c0: 65 61 73 65 20 72 65 70 6f 72 74 20 74 68 69 73  ease report this
37d0: 22 29 0a 09 20 20 28 65 78 69 74 20 31 29 29 29  ")..  (exit 1)))
37e0: 0a 09 0a 09 3b 3b 20 77 65 20 67 65 74 20 68 65  ....;; we get he
37f0: 72 65 20 6f 6e 20 22 64 72 6f 70 20 74 68 72 6f  re on "drop thro
3800: 75 67 68 22 20 2d 20 6c 6f 6f 70 20 66 6f 72 20  ugh" - loop for 
3810: 6e 65 78 74 20 74 65 73 74 20 69 6e 20 71 75 65  next test in que
3820: 75 65 0a 09 28 69 66 20 28 6e 75 6c 6c 3f 20 74  ue..(if (null? t
3830: 61 6c 29 0a 09 20 20 20 20 28 64 65 62 75 67 3a  al)..    (debug:
3840: 70 72 69 6e 74 20 31 20 22 49 4e 46 4f 3a 20 41  print 1 "INFO: A
3850: 6c 6c 20 74 65 73 74 73 20 6c 61 75 6e 63 68 65  ll tests launche
3860: 64 22 29 0a 09 20 20 20 20 28 6c 6f 6f 70 20 28  d")..    (loop (
3870: 63 61 72 20 74 61 6c 29 28 63 64 72 20 74 61 6c  car tal)(cdr tal
3880: 29 29 29 29 29 29 29 0a 0a 28 64 65 66 69 6e 65  )))))))..(define
3890: 20 28 72 75 6e 3a 74 65 73 74 20 64 62 20 72 75   (run:test db ru
38a0: 6e 2d 69 64 20 72 75 6e 6e 61 6d 65 20 6b 65 79  n-id runname key
38b0: 76 61 6c 6c 73 74 20 74 65 73 74 2d 72 65 63 6f  vallst test-reco
38c0: 72 64 20 66 6c 61 67 73 29 0a 20 20 3b 3b 20 41  rd flags).  ;; A
38d0: 6c 6c 20 74 68 65 73 65 20 76 61 72 73 20 6d 69  ll these vars mi
38e0: 67 68 74 20 62 65 20 72 65 66 65 72 65 6e 63 65  ght be reference
38f0: 64 20 62 79 20 74 68 65 20 74 65 73 74 63 6f 6e  d by the testcon
3900: 66 69 67 20 66 69 6c 65 20 72 65 61 64 65 72 0a  fig file reader.
3910: 20 20 28 6c 65 74 2a 20 28 28 74 65 73 74 2d 6e    (let* ((test-n
3920: 61 6d 65 20 20 20 20 28 74 65 73 74 73 3a 74 65  ame    (tests:te
3930: 73 74 71 75 65 75 65 2d 67 65 74 2d 74 65 73 74  stqueue-get-test
3940: 6e 61 6d 65 20 74 65 73 74 2d 72 65 63 6f 72 64  name test-record
3950: 29 29 0a 09 20 28 74 65 73 74 2d 70 61 74 68 20  )).. (test-path 
3960: 20 20 20 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74     (conc *toppat
3970: 68 2a 20 22 2f 74 65 73 74 73 2f 22 20 74 65 73  h* "/tests/" tes
3980: 74 2d 6e 61 6d 65 29 29 20 3b 3b 20 63 6f 75 6c  t-name)) ;; coul
3990: 64 20 75 73 65 20 74 65 73 74 3a 67 65 74 2d 74  d use test:get-t
39a0: 65 73 74 63 6f 6e 66 69 67 20 68 65 72 65 20 2e  estconfig here .
39b0: 2e 2e 0a 09 20 28 74 65 73 74 2d 63 6f 6e 66 20  .... (test-conf 
39c0: 20 20 20 28 74 65 73 74 73 3a 74 65 73 74 71 75     (tests:testqu
39d0: 65 75 65 2d 67 65 74 2d 74 65 73 74 63 6f 6e 66  eue-get-testconf
39e0: 69 67 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29  ig test-record))
39f0: 0a 09 20 28 69 74 65 6d 64 61 74 20 20 20 20 20  .. (itemdat     
3a00: 20 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75   (tests:testqueu
3a10: 65 2d 67 65 74 2d 69 74 65 6d 64 61 74 20 20 20  e-get-itemdat   
3a20: 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29 0a 09   test-record))..
3a30: 20 28 66 6f 72 63 65 20 20 20 20 20 20 20 20 28   (force        (
3a40: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64  hash-table-ref/d
3a50: 65 66 61 75 6c 74 20 66 6c 61 67 73 20 22 2d 66  efault flags "-f
3a60: 6f 72 63 65 22 20 23 66 29 29 0a 09 20 28 72 65  orce" #f)).. (re
3a70: 72 75 6e 20 20 20 20 20 20 20 20 28 68 61 73 68  run        (hash
3a80: 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75  -table-ref/defau
3a90: 6c 74 20 66 6c 61 67 73 20 22 2d 72 65 72 75 6e  lt flags "-rerun
3aa0: 22 20 23 66 29 29 0a 09 20 28 6b 65 65 70 67 6f  " #f)).. (keepgo
3ab0: 69 6e 67 20 20 20 20 28 68 61 73 68 2d 74 61 62  ing    (hash-tab
3ac0: 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 66  le-ref/default f
3ad0: 6c 61 67 73 20 22 2d 6b 65 65 70 67 6f 69 6e 67  lags "-keepgoing
3ae0: 22 20 23 66 29 29 29 0a 20 20 20 20 28 64 65 62  " #f))).    (deb
3af0: 75 67 3a 70 72 69 6e 74 20 31 20 22 4c 61 75 6e  ug:print 1 "Laun
3b00: 63 68 69 6e 67 20 74 65 73 74 20 22 20 74 65 73  ching test " tes
3b10: 74 2d 6e 61 6d 65 29 0a 20 20 20 20 28 64 65 62  t-name).    (deb
3b20: 75 67 3a 70 72 69 6e 74 20 35 0a 09 09 20 22 74  ug:print 5... "t
3b30: 65 73 74 2d 63 6f 6e 66 69 67 3a 20 22 20 28 68  est-config: " (h
3b40: 61 73 68 2d 74 61 62 6c 65 2d 3e 61 6c 69 73 74  ash-table->alist
3b50: 20 74 65 73 74 2d 63 6f 6e 66 29 0a 09 09 20 22   test-conf)... "
3b60: 5c 6e 20 20 20 69 74 65 6d 64 61 74 3a 20 22 20  \n   itemdat: " 
3b70: 69 74 65 6d 64 61 74 0a 09 09 20 29 0a 20 20 20  itemdat... ).   
3b80: 20 3b 3b 20 73 65 74 74 69 6e 67 20 69 74 65 6d   ;; setting item
3b90: 64 61 74 20 74 6f 20 61 20 6c 69 73 74 20 69 66  dat to a list if
3ba0: 20 69 74 20 69 73 20 23 66 0a 20 20 20 20 28 69   it is #f.    (i
3bb0: 66 20 28 6e 6f 74 20 69 74 65 6d 64 61 74 29 28  f (not itemdat)(
3bc0: 73 65 74 21 20 69 74 65 6d 64 61 74 20 27 28 29  set! itemdat '()
3bd0: 29 29 0a 20 20 20 20 28 73 65 74 65 6e 76 20 22  )).    (setenv "
3be0: 4d 54 5f 54 45 53 54 5f 4e 41 4d 45 22 20 74 65  MT_TEST_NAME" te
3bf0: 73 74 2d 6e 61 6d 65 29 20 3b 3b 20 0a 20 20 20  st-name) ;; .   
3c00: 20 28 73 65 74 65 6e 76 20 22 4d 54 5f 52 55 4e   (setenv "MT_RUN
3c10: 4e 41 4d 45 22 20 20 20 72 75 6e 6e 61 6d 65 29  NAME"   runname)
3c20: 0a 20 20 20 20 28 73 65 74 2d 6d 65 67 61 74 65  .    (set-megate
3c30: 73 74 2d 65 6e 76 2d 76 61 72 73 20 64 62 20 72  st-env-vars db r
3c40: 75 6e 2d 69 64 29 20 3b 3b 20 74 68 65 73 65 20  un-id) ;; these 
3c50: 6d 61 79 20 62 65 20 6e 65 65 64 65 64 20 62 79  may be needed by
3c60: 20 74 68 65 20 6c 61 75 6e 63 68 69 6e 67 20 70   the launching p
3c70: 72 6f 63 65 73 73 0a 20 20 20 20 28 63 68 61 6e  rocess.    (chan
3c80: 67 65 2d 64 69 72 65 63 74 6f 72 79 20 2a 74 6f  ge-directory *to
3c90: 70 70 61 74 68 2a 29 0a 0a 20 20 20 20 3b 3b 20  ppath*)..    ;; 
3ca0: 48 65 72 65 20 69 73 20 77 68 65 72 65 20 74 68  Here is where th
3cb0: 65 20 74 65 73 74 5f 6d 65 74 61 20 74 61 62 6c  e test_meta tabl
3cc0: 65 20 69 73 20 62 65 73 74 20 75 70 64 61 74 65  e is best update
3cd0: 64 0a 20 20 20 20 28 72 75 6e 73 3a 75 70 64 61  d.    (runs:upda
3ce0: 74 65 2d 74 65 73 74 5f 6d 65 74 61 20 64 62 20  te-test_meta db 
3cf0: 74 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 2d 63  test-name test-c
3d00: 6f 6e 66 29 0a 20 20 20 20 0a 20 20 20 20 3b 3b  onf).    .    ;;
3d10: 20 28 6c 61 6d 62 64 61 20 28 69 74 65 6d 64 61   (lambda (itemda
3d20: 74 29 20 3b 3b 3b 20 28 28 72 69 70 65 6e 65 73  t) ;;; ((ripenes
3d30: 73 20 22 6f 76 65 72 72 69 70 65 22 29 20 28 74  s "overripe") (t
3d40: 65 6d 70 65 72 61 74 75 72 65 20 22 63 6f 6f 6c  emperature "cool
3d50: 22 29 20 28 73 65 61 73 6f 6e 20 22 73 75 6d 6d  ") (season "summ
3d60: 65 72 22 29 29 0a 20 20 20 20 28 6c 65 74 2a 20  er")).    (let* 
3d70: 28 28 69 74 65 6d 2d 70 61 74 68 20 20 20 20 20  ((item-path     
3d80: 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68  (item-list->path
3d90: 20 69 74 65 6d 64 61 74 29 29 20 3b 3b 20 28 73   itemdat)) ;; (s
3da0: 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73  tring-interspers
3db0: 65 20 28 6d 61 70 20 63 61 64 72 20 69 74 65 6d  e (map cadr item
3dc0: 64 61 74 29 20 22 2f 22 29 29 0a 09 20 20 20 28  dat) "/"))..   (
3dd0: 6e 65 77 2d 74 65 73 74 2d 70 61 74 68 20 28 73  new-test-path (s
3de0: 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73  tring-interspers
3df0: 65 20 28 63 6f 6e 73 20 74 65 73 74 2d 70 61 74  e (cons test-pat
3e00: 68 20 28 6d 61 70 20 63 61 64 72 20 69 74 65 6d  h (map cadr item
3e10: 64 61 74 29 29 20 22 2f 22 29 29 0a 09 20 20 20  dat)) "/"))..   
3e20: 28 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20 28  (new-test-name (
3e30: 69 66 20 28 65 71 75 61 6c 3f 20 69 74 65 6d 2d  if (equal? item-
3e40: 70 61 74 68 20 22 22 29 20 74 65 73 74 2d 6e 61  path "") test-na
3e50: 6d 65 20 28 63 6f 6e 63 20 74 65 73 74 2d 6e 61  me (conc test-na
3e60: 6d 65 20 22 2f 22 20 69 74 65 6d 2d 70 61 74 68  me "/" item-path
3e70: 29 29 29 20 3b 3b 20 6a 75 73 74 20 6e 65 65 64  ))) ;; just need
3e80: 20 69 74 20 74 6f 20 62 65 20 75 6e 69 71 75 65   it to be unique
3e90: 0a 09 20 20 20 28 74 65 73 74 64 61 74 20 20 20  ..   (testdat   
3ea0: 20 20 20 20 23 66 29 0a 09 20 20 20 28 74 65 73      #f)..   (tes
3eb0: 74 2d 69 6e 66 6f 20 28 64 62 3a 67 65 74 2d 74  t-info (db:get-t
3ec0: 65 73 74 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d  est-info db run-
3ed0: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65  id test-name ite
3ee0: 6d 2d 70 61 74 68 29 29 29 0a 20 20 20 20 20 20  m-path))).      
3ef0: 28 69 66 20 28 6e 6f 74 20 74 65 73 74 2d 69 6e  (if (not test-in
3f00: 66 6f 29 28 72 65 67 69 73 74 65 72 2d 74 65 73  fo)(register-tes
3f10: 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  t db run-id test
3f20: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  -name item-path)
3f30: 29 0a 20 20 20 20 20 20 28 63 68 61 6e 67 65 2d  ).      (change-
3f40: 64 69 72 65 63 74 6f 72 79 20 74 65 73 74 2d 70  directory test-p
3f50: 61 74 68 29 0a 20 20 20 20 20 20 28 63 61 73 65  ath).      (case
3f60: 20 28 69 66 20 66 6f 72 63 65 20 3b 3b 20 28 61   (if force ;; (a
3f70: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 66 6f  rgs:get-arg "-fo
3f80: 72 63 65 22 29 0a 09 09 27 4e 4f 54 5f 53 54 41  rce")...'NOT_STA
3f90: 52 54 45 44 0a 09 09 28 69 66 20 74 65 73 74 64  RTED...(if testd
3fa0: 61 74 0a 09 09 20 20 20 20 28 73 74 72 69 6e 67  at...    (string
3fb0: 2d 3e 73 79 6d 62 6f 6c 20 28 74 65 73 74 3a 67  ->symbol (test:g
3fc0: 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 74  et-state testdat
3fd0: 29 29 0a 09 09 20 20 20 20 27 66 61 69 6c 65 64  ))...    'failed
3fe0: 2d 74 6f 2d 69 6e 73 65 72 74 29 29 0a 09 28 28  -to-insert))..((
3ff0: 66 61 69 6c 65 64 2d 74 6f 2d 69 6e 73 65 72 74  failed-to-insert
4000: 29 0a 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ).. (debug:print
4010: 20 30 20 22 45 52 52 4f 52 3a 20 46 61 69 6c 65   0 "ERROR: Faile
4020: 64 20 74 6f 20 69 6e 73 65 72 74 20 74 68 65 20  d to insert the 
4030: 72 65 63 6f 72 64 20 69 6e 74 6f 20 74 68 65 20  record into the 
4040: 64 62 22 29 29 0a 09 28 28 4e 4f 54 5f 53 54 41  db"))..((NOT_STA
4050: 52 54 45 44 20 43 4f 4d 50 4c 45 54 45 44 29 0a  RTED COMPLETED).
4060: 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 36  . (debug:print 6
4070: 20 22 47 6f 74 20 68 65 72 65 2c 20 22 20 28 74   "Got here, " (t
4080: 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65  est:get-state te
4090: 73 74 64 61 74 29 29 0a 09 20 28 6c 65 74 20 28  stdat)).. (let (
40a0: 28 72 75 6e 66 6c 61 67 20 23 66 29 29 0a 09 20  (runflag #f)).. 
40b0: 20 20 28 63 6f 6e 64 0a 09 20 20 20 20 3b 3b 20    (cond..    ;; 
40c0: 2d 66 6f 72 63 65 2c 20 72 75 6e 20 6e 6f 20 6d  -force, run no m
40d0: 61 74 74 65 72 20 77 68 61 74 0a 09 20 20 20 20  atter what..    
40e0: 28 66 6f 72 63 65 20 28 73 65 74 21 20 72 75 6e  (force (set! run
40f0: 66 6c 61 67 20 23 74 29 29 0a 09 20 20 20 20 3b  flag #t))..    ;
4100: 3b 20 4e 4f 54 5f 53 54 41 52 54 45 44 2c 20 72  ; NOT_STARTED, r
4110: 75 6e 20 6e 6f 20 6d 61 74 74 65 72 20 77 68 61  un no matter wha
4120: 74 0a 09 20 20 20 20 28 28 65 71 75 61 6c 3f 20  t..    ((equal? 
4130: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20  (test:get-state 
4140: 74 65 73 74 64 61 74 29 20 22 4e 4f 54 5f 53 54  testdat) "NOT_ST
4150: 41 52 54 45 44 22 29 28 73 65 74 21 20 72 75 6e  ARTED")(set! run
4160: 66 6c 61 67 20 23 74 29 29 0a 09 20 20 20 20 3b  flag #t))..    ;
4170: 3b 20 6e 6f 74 20 2d 72 65 72 75 6e 20 61 6e 64  ; not -rerun and
4180: 20 50 41 53 53 2c 20 57 41 52 4e 20 6f 72 20 43   PASS, WARN or C
4190: 48 45 43 4b 2c 20 64 6f 20 6e 6f 20 72 75 6e 0a  HECK, do no run.
41a0: 09 20 20 20 20 28 28 61 6e 64 20 28 6f 72 20 28  .    ((and (or (
41b0: 6e 6f 74 20 72 65 72 75 6e 29 0a 09 09 20 20 20  not rerun)...   
41c0: 20 20 20 6b 65 65 70 67 6f 69 6e 67 29 0a 09 09     keepgoing)...
41d0: 20 20 28 6d 65 6d 62 65 72 20 28 74 65 73 74 3a    (member (test:
41e0: 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64  get-status testd
41f0: 61 74 29 20 27 28 22 50 41 53 53 22 20 22 57 41  at) '("PASS" "WA
4200: 52 4e 22 20 22 43 48 45 43 4b 22 29 29 29 0a 09  RN" "CHECK")))..
4210: 20 20 20 20 20 28 73 65 74 21 20 72 75 6e 66 6c       (set! runfl
4220: 61 67 20 23 66 29 29 0a 09 20 20 20 20 3b 3b 20  ag #f))..    ;; 
4230: 2d 72 65 72 75 6e 20 61 6e 64 20 73 74 61 74 75  -rerun and statu
4240: 73 20 69 73 20 6f 6e 65 20 6f 66 20 74 68 65 20  s is one of the 
4250: 73 70 65 63 69 66 65 64 2c 20 72 75 6e 20 69 74  specifed, run it
4260: 0a 09 20 20 20 20 28 28 61 6e 64 20 72 65 72 75  ..    ((and reru
4270: 6e 0a 09 09 20 20 28 6c 65 74 20 28 28 72 65 72  n...  (let ((rer
4280: 75 6e 6c 73 74 20 28 73 74 72 69 6e 67 2d 73 70  unlst (string-sp
4290: 6c 69 74 20 72 65 72 75 6e 20 22 2c 22 29 29 29  lit rerun ",")))
42a0: 20 3b 3b 20 46 41 49 4c 2c 0a 09 09 20 20 20 20   ;; FAIL,...    
42b0: 28 6d 65 6d 62 65 72 20 28 74 65 73 74 3a 67 65  (member (test:ge
42c0: 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61 74  t-status testdat
42d0: 29 20 72 65 72 75 6e 6c 73 74 29 29 29 0a 09 20  ) rerunlst))).. 
42e0: 20 20 20 20 28 73 65 74 21 20 72 75 6e 66 6c 61      (set! runfla
42f0: 67 20 23 74 29 29 0a 09 20 20 20 20 3b 3b 20 2d  g #t))..    ;; -
4300: 6b 65 65 70 67 6f 69 6e 67 2c 20 64 6f 20 6e 6f  keepgoing, do no
4310: 74 20 72 65 72 75 6e 20 46 41 49 4c 0a 09 20 20  t rerun FAIL..  
4320: 20 20 28 28 61 6e 64 20 6b 65 65 70 67 6f 69 6e    ((and keepgoin
4330: 67 0a 09 09 20 20 28 6d 65 6d 62 65 72 20 28 74  g...  (member (t
4340: 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74  est:get-status t
4350: 65 73 74 64 61 74 29 20 27 28 22 46 41 49 4c 22  estdat) '("FAIL"
4360: 29 29 29 0a 09 20 20 20 20 20 28 73 65 74 21 20  )))..     (set! 
4370: 72 75 6e 66 6c 61 67 20 23 66 29 29 0a 09 20 20  runflag #f))..  
4380: 20 20 28 28 61 6e 64 20 28 6e 6f 74 20 72 65 72    ((and (not rer
4390: 75 6e 29 0a 09 09 20 20 28 6d 65 6d 62 65 72 20  un)...  (member 
43a0: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73  (test:get-status
43b0: 20 74 65 73 74 64 61 74 29 20 27 28 22 46 41 49   testdat) '("FAI
43c0: 4c 22 20 22 6e 2f 61 22 29 29 29 0a 09 20 20 20  L" "n/a")))..   
43d0: 20 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20    (set! runflag 
43e0: 23 74 29 29 0a 09 20 20 20 20 28 65 6c 73 65 20  #t))..    (else 
43f0: 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 66  (set! runflag #f
4400: 29 29 29 0a 09 20 20 20 28 64 65 62 75 67 3a 70  )))..   (debug:p
4410: 72 69 6e 74 20 36 20 22 52 55 4e 4e 49 4e 47 20  rint 6 "RUNNING 
4420: 3d 3e 20 72 75 6e 66 6c 61 67 3a 20 22 20 72 75  => runflag: " ru
4430: 6e 66 6c 61 67 20 22 20 53 54 41 54 45 3a 20 22  nflag " STATE: "
4440: 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65   (test:get-state
4450: 20 74 65 73 74 64 61 74 29 20 22 20 53 54 41 54   testdat) " STAT
4460: 55 53 3a 20 22 20 28 74 65 73 74 3a 67 65 74 2d  US: " (test:get-
4470: 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29 29  status testdat))
4480: 0a 09 20 20 20 28 69 66 20 28 6e 6f 74 20 72 75  ..   (if (not ru
4490: 6e 66 6c 61 67 29 0a 09 20 20 20 20 20 20 20 28  nflag)..       (
44a0: 69 66 20 28 6e 6f 74 20 70 61 72 65 6e 74 2d 74  if (not parent-t
44b0: 65 73 74 29 0a 09 09 20 20 20 28 64 65 62 75 67  est)...   (debug
44c0: 3a 70 72 69 6e 74 20 31 20 22 4e 4f 54 45 3a 20  :print 1 "NOTE: 
44d0: 4e 6f 74 20 73 74 61 72 74 69 6e 67 20 74 65 73  Not starting tes
44e0: 74 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d  t " new-test-nam
44f0: 65 20 22 20 61 73 20 69 74 20 69 73 20 73 74 61  e " as it is sta
4500: 74 65 20 5c 22 43 4f 4d 50 4c 45 54 45 44 5c 22  te \"COMPLETED\"
4510: 20 61 6e 64 20 73 74 61 74 75 73 20 5c 22 22 20   and status \"" 
4520: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73  (test:get-status
4530: 20 74 65 73 74 64 61 74 29 20 22 5c 22 2c 20 75   testdat) "\", u
4540: 73 65 20 2d 66 6f 72 63 65 20 74 6f 20 6f 76 65  se -force to ove
4550: 72 72 69 64 65 22 29 29 0a 09 20 20 20 20 20 20  rride"))..      
4560: 20 28 6c 65 74 2a 20 28 28 67 65 74 2d 70 72 65   (let* ((get-pre
4570: 72 65 71 73 2d 63 6d 64 20 28 6c 61 6d 62 64 61  reqs-cmd (lambda
4580: 20 28 29 0a 09 09 09 09 09 20 28 64 62 2d 67 65   ()...... (db-ge
4590: 74 2d 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65  t-prereqs-not-me
45a0: 74 20 64 62 20 72 75 6e 2d 69 64 20 77 61 69 74  t db run-id wait
45b0: 6f 6e 73 29 29 29 20 3b 3b 20 63 68 65 63 6b 20  ons))) ;; check 
45c0: 62 65 66 6f 72 65 20 72 75 6e 6e 69 6e 67 20 2e  before running .
45d0: 2e 2e 2e 0a 09 09 20 20 20 20 20 20 28 6c 61 75  ......      (lau
45e0: 6e 63 68 2d 63 6d 64 20 20 20 20 20 20 28 6c 61  nch-cmd      (la
45f0: 6d 62 64 61 20 28 29 0a 09 09 09 09 09 20 28 6c  mbda ()...... (l
4600: 61 75 6e 63 68 2d 74 65 73 74 20 64 62 20 72 75  aunch-test db ru
4610: 6e 2d 69 64 20 72 75 6e 6e 61 6d 65 20 74 65 73  n-id runname tes
4620: 74 2d 63 6f 6e 66 20 6b 65 79 76 61 6c 6c 73 74  t-conf keyvallst
4630: 20 74 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 2d   test-name test-
4640: 70 61 74 68 20 69 74 65 6d 64 61 74 20 66 6c 61  path itemdat fla
4650: 67 73 29 29 29 0a 09 09 20 20 20 20 20 20 28 74  gs)))...      (t
4660: 65 73 74 72 75 6e 64 61 74 20 20 20 20 20 20 28  estrundat      (
4670: 6c 69 73 74 20 67 65 74 2d 70 72 65 72 65 71 73  list get-prereqs
4680: 2d 63 6d 64 20 6c 61 75 6e 63 68 2d 63 6d 64 29  -cmd launch-cmd)
4690: 29 29 0a 09 09 20 28 69 66 20 28 6f 72 20 66 6f  ))... (if (or fo
46a0: 72 63 65 0a 09 09 09 20 28 6c 65 74 20 28 28 70  rce.... (let ((p
46b0: 72 65 71 73 2d 6e 6f 74 2d 79 65 74 2d 6d 65 74  reqs-not-yet-met
46c0: 20 28 28 63 61 72 20 74 65 73 74 72 75 6e 64 61   ((car testrunda
46d0: 74 29 29 29 29 0a 09 09 09 20 20 20 28 64 65 62  t))))....   (deb
46e0: 75 67 3a 70 72 69 6e 74 20 32 20 22 50 72 65 71  ug:print 2 "Preq
46f0: 72 65 71 75 65 73 69 74 65 73 20 66 6f 72 20 22  requesites for "
4700: 20 74 65 73 74 2d 6e 61 6d 65 20 22 3a 20 22 20   test-name ": " 
4710: 70 72 65 71 73 2d 6e 6f 74 2d 79 65 74 2d 6d 65  preqs-not-yet-me
4720: 74 29 0a 09 09 09 20 20 20 28 6e 75 6c 6c 3f 20  t)....   (null? 
4730: 70 72 65 71 73 2d 6e 6f 74 2d 79 65 74 2d 6d 65  preqs-not-yet-me
4740: 74 29 29 29 20 3b 3b 20 61 72 65 20 74 68 65 72  t))) ;; are ther
4750: 65 20 61 6e 79 20 74 65 73 74 73 20 74 68 61 74  e any tests that
4760: 20 6d 75 73 74 20 62 65 20 72 75 6e 20 62 65 66   must be run bef
4770: 6f 72 65 20 74 68 69 73 20 6f 6e 65 2e 2e 2e 0a  ore this one....
4780: 09 09 20 20 20 20 20 28 69 66 20 28 6e 6f 74 20  ..     (if (not 
4790: 28 28 63 61 64 72 20 74 65 73 74 72 75 6e 64 61  ((cadr testrunda
47a0: 74 29 29 29 20 3b 3b 20 74 68 69 73 20 69 73 20  t))) ;; this is 
47b0: 74 68 65 20 6c 69 6e 65 20 74 68 61 74 20 6c 61  the line that la
47c0: 75 6e 63 68 65 73 20 74 68 65 20 74 65 73 74 20  unches the test 
47d0: 74 6f 20 74 68 65 20 72 65 6d 6f 74 65 20 68 6f  to the remote ho
47e0: 73 74 0a 09 09 09 20 28 62 65 67 69 6e 0a 09 09  st.... (begin...
47f0: 09 20 20 20 28 70 72 69 6e 74 20 22 45 52 52 4f  .   (print "ERRO
4800: 52 3a 20 46 61 69 6c 65 64 20 74 6f 20 6c 61 75  R: Failed to lau
4810: 6e 63 68 20 74 68 65 20 74 65 73 74 2e 20 45 78  nch the test. Ex
4820: 69 74 69 6e 67 20 61 73 20 73 6f 6f 6e 20 61 73  iting as soon as
4830: 20 70 6f 73 73 69 62 6c 65 22 29 0a 09 09 09 20   possible").... 
4840: 20 20 28 73 65 74 21 20 2a 67 6c 6f 62 61 6c 65    (set! *globale
4850: 78 69 74 73 74 61 74 75 73 2a 20 31 29 20 3b 3b  xitstatus* 1) ;;
4860: 20 0a 09 09 09 20 20 20 28 70 72 6f 63 65 73 73   ....   (process
4870: 2d 73 69 67 6e 61 6c 20 28 63 75 72 72 65 6e 74  -signal (current
4880: 2d 70 72 6f 63 65 73 73 2d 69 64 29 20 73 69 67  -process-id) sig
4890: 6e 61 6c 2f 6b 69 6c 6c 29 0a 09 09 09 09 09 3b  nal/kill)......;
48a0: 28 65 78 69 74 20 31 29 0a 09 09 09 20 20 20 29  (exit 1)....   )
48b0: 29 0a 09 09 20 20 20 20 20 28 69 66 20 28 6e 6f  )...     (if (no
48c0: 74 20 6b 65 65 70 67 6f 69 6e 67 29 0a 09 09 09  t keepgoing)....
48d0: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74   (hash-table-set
48e0: 21 20 2a 77 61 69 74 69 6e 67 2d 71 75 65 75 65  ! *waiting-queue
48f0: 2a 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20  * new-test-name 
4900: 74 65 73 74 72 75 6e 64 61 74 29 29 29 29 29 29  testrundat))))))
4910: 29 0a 09 28 28 4b 49 4c 4c 45 44 29 20 0a 09 20  )..((KILLED) .. 
4920: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22  (debug:print 1 "
4930: 4e 4f 54 45 3a 20 22 20 6e 65 77 2d 74 65 73 74  NOTE: " new-test
4940: 2d 6e 61 6d 65 20 22 20 69 73 20 61 6c 72 65 61  -name " is alrea
4950: 64 79 20 72 75 6e 6e 69 6e 67 20 6f 72 20 77 61  dy running or wa
4960: 73 20 65 78 70 6c 69 63 74 6c 79 20 6b 69 6c 6c  s explictly kill
4970: 65 64 2c 20 75 73 65 20 2d 66 6f 72 63 65 20 74  ed, use -force t
4980: 6f 20 6c 61 75 6e 63 68 20 69 74 2e 22 29 29 0a  o launch it.")).
4990: 09 28 28 4c 41 55 4e 43 48 45 44 20 52 45 4d 4f  .((LAUNCHED REMO
49a0: 54 45 48 4f 53 54 53 54 41 52 54 20 52 55 4e 4e  TEHOSTSTART RUNN
49b0: 49 4e 47 29 20 20 0a 09 20 28 69 66 20 28 3e 20  ING)  .. (if (> 
49c0: 28 2d 20 28 63 75 72 72 65 6e 74 2d 73 65 63 6f  (- (current-seco
49d0: 6e 64 73 29 28 2b 20 28 64 62 3a 74 65 73 74 2d  nds)(+ (db:test-
49e0: 67 65 74 2d 65 76 65 6e 74 5f 74 69 6d 65 20 74  get-event_time t
49f0: 65 73 74 64 61 74 29 0a 09 09 09 09 20 20 20 20  estdat).....    
4a00: 20 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d     (db:test-get-
4a10: 72 75 6e 5f 64 75 72 61 74 69 6f 6e 20 74 65 73  run_duration tes
4a20: 74 64 61 74 29 29 29 0a 09 09 36 30 30 29 20 3b  tdat)))...600) ;
4a30: 3b 20 69 2e 65 2e 20 6e 6f 20 75 70 64 61 74 65  ; i.e. no update
4a40: 20 66 6f 72 20 6d 6f 72 65 20 74 68 61 6e 20 36   for more than 6
4a50: 30 30 20 73 65 63 6f 6e 64 73 0a 09 20 20 20 20  00 seconds..    
4a60: 20 28 62 65 67 69 6e 0a 09 20 20 20 20 20 20 20   (begin..       
4a70: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
4a80: 57 41 52 4e 49 4e 47 3a 20 54 65 73 74 20 22 20  WARNING: Test " 
4a90: 74 65 73 74 2d 6e 61 6d 65 20 22 20 61 70 70 65  test-name " appe
4aa0: 61 72 73 20 74 6f 20 62 65 20 64 65 61 64 2e 20  ars to be dead. 
4ab0: 46 6f 72 63 69 6e 67 20 69 74 20 74 6f 20 73 74  Forcing it to st
4ac0: 61 74 65 20 49 4e 43 4f 4d 50 4c 45 54 45 20 61  ate INCOMPLETE a
4ad0: 6e 64 20 73 74 61 74 75 73 20 53 54 55 43 4b 2f  nd status STUCK/
4ae0: 44 45 41 44 22 29 0a 09 20 20 20 20 20 20 20 28  DEAD")..       (
4af0: 74 65 73 74 2d 73 65 74 2d 73 74 61 74 75 73 21  test-set-status!
4b00: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d   db run-id test-
4b10: 6e 61 6d 65 20 22 49 4e 43 4f 4d 50 4c 45 54 45  name "INCOMPLETE
4b20: 22 20 22 53 54 55 43 4b 2f 44 45 41 44 22 20 69  " "STUCK/DEAD" i
4b30: 74 65 6d 64 61 74 20 22 54 65 73 74 20 69 73 20  temdat "Test is 
4b40: 73 74 75 63 6b 20 6f 72 20 64 65 61 64 22 20 23  stuck or dead" #
4b50: 66 29 29 0a 09 20 20 20 20 20 28 64 65 62 75 67  f))..     (debug
4b60: 3a 70 72 69 6e 74 20 32 20 22 4e 4f 54 45 3a 20  :print 2 "NOTE: 
4b70: 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 69 73  " test-name " is
4b80: 20 61 6c 72 65 61 64 79 20 72 75 6e 6e 69 6e 67   already running
4b90: 22 29 29 29 0a 09 28 65 6c 73 65 20 20 20 20 20  ")))..(else     
4ba0: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30    (debug:print 0
4bb0: 20 22 45 52 52 4f 52 3a 20 46 61 69 6c 65 64 20   "ERROR: Failed 
4bc0: 74 6f 20 6c 61 75 6e 63 68 20 74 65 73 74 20 22  to launch test "
4bd0: 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20 22   new-test-name "
4be0: 2e 20 55 6e 72 65 63 6f 67 6e 69 73 65 64 20 73  . Unrecognised s
4bf0: 74 61 74 65 20 22 20 28 74 65 73 74 3a 67 65 74  tate " (test:get
4c00: 2d 73 74 61 74 65 20 74 65 73 74 64 61 74 29 29  -state testdat))
4c10: 29 29 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d  )))))..;;=======
4c20: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
4c30: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
4c40: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
4c50: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a  ===============.
4c60: 3b 3b 20 45 4e 44 20 4f 46 20 4e 45 57 20 53 54  ;; END OF NEW ST
4c70: 55 46 46 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  UFF.;;==========
4c80: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
4c90: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
4ca0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
4cb0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 28 64  ============..(d
4cc0: 65 66 69 6e 65 20 28 67 65 74 2d 64 69 72 2d 75  efine (get-dir-u
4cd0: 70 2d 6e 20 64 69 72 20 2e 20 70 61 72 61 6d 73  p-n dir . params
4ce0: 29 20 0a 20 20 28 6c 65 74 20 28 28 64 70 61 72  ) .  (let ((dpar
4cf0: 74 73 20 20 28 73 74 72 69 6e 67 2d 73 70 6c 69  ts  (string-spli
4d00: 74 20 64 69 72 20 22 2f 22 29 29 0a 09 28 63 6f  t dir "/"))..(co
4d10: 75 6e 74 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f  unt   (if (null?
4d20: 20 70 61 72 61 6d 73 29 20 31 20 28 63 61 72 20   params) 1 (car 
4d30: 70 61 72 61 6d 73 29 29 29 29 0a 20 20 20 20 28  params)))).    (
4d40: 63 6f 6e 63 20 22 2f 22 20 28 73 74 72 69 6e 67  conc "/" (string
4d50: 2d 69 6e 74 65 72 73 70 65 72 73 65 20 0a 09 20  -intersperse .. 
4d60: 20 20 20 20 20 20 28 74 61 6b 65 20 64 70 61 72        (take dpar
4d70: 74 73 20 28 2d 20 28 6c 65 6e 67 74 68 20 64 70  ts (- (length dp
4d80: 61 72 74 73 29 20 63 6f 75 6e 74 29 29 0a 09 20  arts) count)).. 
4d90: 20 20 20 20 20 20 22 2f 22 29 29 29 29 0a 3b 3b        "/")))).;;
4da0: 20 52 65 6d 6f 76 65 20 72 75 6e 73 0a 3b 3b 20   Remove runs.;; 
4db0: 66 69 65 6c 64 73 20 61 72 65 20 70 61 73 73 69  fields are passi
4dc0: 6e 67 20 69 6e 20 74 68 72 6f 75 67 68 20 0a 28  ng in through .(
4dd0: 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 72 65 6d  define (runs:rem
4de0: 6f 76 65 2d 72 75 6e 73 20 64 62 20 72 75 6e 6e  ove-runs db runn
4df0: 61 6d 65 70 61 74 74 20 74 65 73 74 70 61 74 74  amepatt testpatt
4e00: 20 69 74 65 6d 70 61 74 74 29 0a 20 20 28 6c 65   itempatt).  (le
4e10: 74 2a 20 28 28 6b 65 79 73 20 20 20 20 20 20 20  t* ((keys       
4e20: 20 28 64 62 2d 67 65 74 2d 6b 65 79 73 20 64 62   (db-get-keys db
4e30: 29 29 0a 09 20 28 72 75 6e 64 61 74 20 20 20 20  )).. (rundat    
4e40: 20 20 28 72 75 6e 73 3a 67 65 74 2d 72 75 6e 73    (runs:get-runs
4e50: 2d 62 79 2d 70 61 74 74 20 64 62 20 6b 65 79 73  -by-patt db keys
4e60: 20 72 75 6e 6e 61 6d 65 70 61 74 74 29 29 0a 09   runnamepatt))..
4e70: 20 28 68 65 61 64 65 72 20 20 20 20 20 20 28 76   (header      (v
4e80: 65 63 74 6f 72 2d 72 65 66 20 72 75 6e 64 61 74  ector-ref rundat
4e90: 20 30 29 29 0a 09 20 28 72 75 6e 73 20 20 20 20   0)).. (runs    
4ea0: 20 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20      (vector-ref 
4eb0: 72 75 6e 64 61 74 20 31 29 29 29 0a 20 20 20 20  rundat 1))).    
4ec0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22  (debug:print 1 "
4ed0: 48 65 61 64 65 72 3a 20 22 20 68 65 61 64 65 72  Header: " header
4ee0: 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 0a  ).    (for-each.
4ef0: 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 72 75       (lambda (ru
4f00: 6e 29 0a 20 20 20 20 20 20 20 28 6c 65 74 20 28  n).       (let (
4f10: 28 72 75 6e 6b 65 79 20 28 73 74 72 69 6e 67 2d  (runkey (string-
4f20: 69 6e 74 65 72 73 70 65 72 73 65 20 28 6d 61 70  intersperse (map
4f30: 20 28 6c 61 6d 62 64 61 20 28 6b 29 0a 09 09 09   (lambda (k)....
4f40: 09 09 09 28 64 62 3a 67 65 74 2d 76 61 6c 75 65  ...(db:get-value
4f50: 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68  -by-header run h
4f60: 65 61 64 65 72 20 28 76 65 63 74 6f 72 2d 72 65  eader (vector-re
4f70: 66 20 6b 20 30 29 29 29 20 6b 65 79 73 29 20 22  f k 0))) keys) "
4f80: 2f 22 29 29 0a 09 20 20 20 20 20 28 64 69 72 73  /"))..     (dirs
4f90: 2d 74 6f 2d 72 65 6d 6f 76 65 20 28 6d 61 6b 65  -to-remove (make
4fa0: 2d 68 61 73 68 2d 74 61 62 6c 65 29 29 29 0a 09  -hash-table)))..
4fb0: 20 28 6c 65 74 2a 20 28 28 72 75 6e 2d 69 64 20   (let* ((run-id 
4fc0: 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79  (db:get-value-by
4fd0: 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64  -header run head
4fe0: 65 72 20 22 69 64 22 29 20 29 0a 09 09 28 74 65  er "id") )...(te
4ff0: 73 74 73 20 20 28 64 62 2d 67 65 74 2d 74 65 73  sts  (db-get-tes
5000: 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 28 64  ts-for-run db (d
5010: 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68  b:get-value-by-h
5020: 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65 72  eader run header
5030: 20 22 69 64 22 29 20 74 65 73 74 70 61 74 74 20   "id") testpatt 
5040: 69 74 65 6d 70 61 74 74 20 27 28 29 20 27 28 29  itempatt '() '()
5050: 29 29 0a 09 09 28 6c 61 73 74 74 70 61 74 68 20  ))...(lasttpath 
5060: 22 2f 64 6f 65 73 2f 6e 6f 74 2f 65 78 69 73 74  "/does/not/exist
5070: 2f 49 2f 68 6f 70 65 22 29 29 0a 0a 09 20 20 20  /I/hope"))...   
5080: 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20  (if (not (null? 
5090: 74 65 73 74 73 29 29 0a 09 20 20 20 20 20 20 20  tests))..       
50a0: 28 62 65 67 69 6e 0a 09 09 20 28 64 65 62 75 67  (begin... (debug
50b0: 3a 70 72 69 6e 74 20 31 20 22 52 65 6d 6f 76 69  :print 1 "Removi
50c0: 6e 67 20 74 65 73 74 73 20 66 6f 72 20 72 75 6e  ng tests for run
50d0: 3a 20 22 20 72 75 6e 6b 65 79 20 22 20 22 20 28  : " runkey " " (
50e0: 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d  db:get-value-by-
50f0: 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65  header run heade
5100: 72 20 22 72 75 6e 6e 61 6d 65 22 29 29 0a 09 09  r "runname"))...
5110: 20 28 66 6f 72 2d 65 61 63 68 0a 09 09 20 20 28   (for-each...  (
5120: 6c 61 6d 62 64 61 20 28 74 65 73 74 29 0a 09 09  lambda (test)...
5130: 20 20 20 20 28 6c 65 74 2a 20 28 28 69 74 65 6d      (let* ((item
5140: 2d 70 61 74 68 20 28 64 62 3a 74 65 73 74 2d 67  -path (db:test-g
5150: 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73  et-item-path tes
5160: 74 29 29 0a 09 09 09 20 20 20 28 74 65 73 74 2d  t))....   (test-
5170: 6e 61 6d 65 20 28 64 62 3a 74 65 73 74 2d 67 65  name (db:test-ge
5180: 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 29  t-testname test)
5190: 29 0a 09 09 09 20 20 20 28 72 75 6e 2d 64 69 72  )....   (run-dir
51a0: 20 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d     (db:test-get-
51b0: 72 75 6e 64 69 72 20 74 65 73 74 29 29 29 0a 09  rundir test)))..
51c0: 09 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72  .      (debug:pr
51d0: 69 6e 74 20 31 20 22 20 20 22 20 28 64 62 3a 74  int 1 "  " (db:t
51e0: 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65  est-get-testname
51f0: 20 74 65 73 74 29 20 22 20 69 64 3a 20 22 20 28   test) " id: " (
5200: 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74  db:test-get-id t
5210: 65 73 74 29 20 22 20 22 20 69 74 65 6d 2d 70 61  est) " " item-pa
5220: 74 68 29 0a 09 09 20 20 20 20 20 20 28 64 62 3a  th)...      (db:
5230: 64 65 6c 65 74 65 2d 74 65 73 74 2d 72 65 63 6f  delete-test-reco
5240: 72 64 73 20 64 62 20 28 64 62 3a 74 65 73 74 2d  rds db (db:test-
5250: 67 65 74 2d 69 64 20 74 65 73 74 29 29 0a 09 09  get-id test))...
5260: 20 20 20 20 20 20 28 69 66 20 28 3e 20 28 73 74        (if (> (st
5270: 72 69 6e 67 2d 6c 65 6e 67 74 68 20 72 75 6e 2d  ring-length run-
5280: 64 69 72 29 20 35 29 20 3b 3b 20 62 61 64 20 68  dir) 5) ;; bad h
5290: 65 75 72 69 73 74 69 63 20 62 75 74 20 73 68 6f  euristic but sho
52a0: 75 6c 64 20 70 72 65 76 65 6e 74 20 2f 74 6d 70  uld prevent /tmp
52b0: 20 2f 68 6f 6d 65 20 65 74 63 2e 0a 09 09 09 20   /home etc..... 
52c0: 20 28 6c 65 74 20 28 28 66 75 6c 6c 70 61 74 68   (let ((fullpath
52d0: 20 72 75 6e 2d 64 69 72 29 29 20 3b 3b 20 22 2f   run-dir)) ;; "/
52e0: 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69  " (db:test-get-i
52f0: 74 65 6d 2d 70 61 74 68 20 74 65 73 74 29 29 29  tem-path test)))
5300: 29 0a 09 09 09 20 20 20 20 28 73 65 74 21 20 6c  )....    (set! l
5310: 61 73 74 74 70 61 74 68 20 66 75 6c 6c 70 61 74  asttpath fullpat
5320: 68 29 0a 09 09 09 20 20 20 20 28 68 61 73 68 2d  h)....    (hash-
5330: 74 61 62 6c 65 2d 73 65 74 21 20 64 69 72 73 2d  table-set! dirs-
5340: 74 6f 2d 72 65 6d 6f 76 65 20 66 75 6c 6c 70 61  to-remove fullpa
5350: 74 68 20 23 74 29 0a 09 09 09 20 20 20 20 3b 3b  th #t)....    ;;
5360: 20 54 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 77   The following w
5370: 61 73 20 74 68 65 20 73 61 66 65 20 64 65 6c 65  as the safe dele
5380: 74 65 20 63 6f 64 65 20 62 75 74 20 69 74 20 77  te code but it w
5390: 61 73 20 6e 6f 74 20 62 65 69 6e 67 20 65 78 65  as not being exe
53a0: 63 74 75 74 65 64 2e 0a 09 09 09 20 20 20 20 3b  ctuted.....    ;
53b0: 3b 20 28 6c 65 74 2a 20 28 28 64 69 72 73 2d 63  ; (let* ((dirs-c
53c0: 6f 75 6e 74 20 28 2b 20 31 20 28 6c 65 6e 67 74  ount (+ 1 (lengt
53d0: 68 20 6b 65 79 73 29 28 6c 65 6e 67 74 68 20 28  h keys)(length (
53e0: 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 69 74 65  string-split ite
53f0: 6d 2d 70 61 74 68 20 22 2f 22 29 29 29 29 0a 09  m-path "/"))))..
5400: 09 09 20 20 20 20 3b 3b 20 20 20 20 20 20 20 20  ..    ;;        
5410: 28 64 69 72 2d 74 6f 2d 72 65 6d 20 28 67 65 74  (dir-to-rem (get
5420: 2d 64 69 72 2d 75 70 2d 6e 20 66 75 6c 6c 70 61  -dir-up-n fullpa
5430: 74 68 20 64 69 72 73 2d 63 6f 75 6e 74 29 29 0a  th dirs-count)).
5440: 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20 20 20  ...    ;;       
5450: 20 28 72 65 6d 61 69 6e 69 6e 67 64 20 28 73 74   (remainingd (st
5460: 72 69 6e 67 2d 73 75 62 73 74 69 74 75 74 65 20  ring-substitute 
5470: 28 72 65 67 65 78 70 20 28 63 6f 6e 63 20 22 5e  (regexp (conc "^
5480: 22 20 64 69 72 2d 74 6f 2d 72 65 6d 20 22 2f 22  " dir-to-rem "/"
5490: 29 29 20 22 22 20 66 75 6c 6c 70 61 74 68 29 29  )) "" fullpath))
54a0: 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20 20  ....    ;;      
54b0: 20 20 28 63 6d 64 20 28 63 6f 6e 63 20 22 63 64    (cmd (conc "cd
54c0: 20 22 20 64 69 72 2d 74 6f 2d 72 65 6d 20 22 3b   " dir-to-rem ";
54d0: 20 72 6d 64 69 72 20 2d 70 20 22 20 72 65 6d 61   rmdir -p " rema
54e0: 69 6e 69 6e 67 64 20 29 29 29 0a 09 09 09 20 20  iningd )))....  
54f0: 20 20 3b 3b 20 20 20 28 69 66 20 28 66 69 6c 65    ;;   (if (file
5500: 2d 65 78 69 73 74 73 3f 20 66 75 6c 6c 70 61 74  -exists? fullpat
5510: 68 29 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 20  h)....    ;;    
5520: 20 20 20 28 62 65 67 69 6e 0a 09 09 09 20 20 20     (begin....   
5530: 20 3b 3b 20 20 20 20 20 20 20 20 20 28 64 65 62   ;;         (deb
5540: 75 67 3a 70 72 69 6e 74 20 31 20 63 6d 64 29 0a  ug:print 1 cmd).
5550: 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20 20 20  ...    ;;       
5560: 20 20 28 73 79 73 74 65 6d 20 63 6d 64 29 29 29    (system cmd)))
5570: 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 29 29 0a  ....    ;;   )).
5580: 09 09 09 20 20 20 20 29 29 29 29 0a 09 09 20 20  ...    ))))...  
5590: 20 20 74 65 73 74 73 29 29 29 0a 0a 09 20 20 20    tests)))...   
55a0: 3b 3b 20 6c 6f 6f 6b 20 74 68 6f 75 67 68 20 74  ;; look though t
55b0: 68 65 20 64 69 72 73 2d 74 6f 2d 72 65 6d 6f 76  he dirs-to-remov
55c0: 65 20 66 6f 72 20 63 61 6e 64 69 64 61 74 65 73  e for candidates
55d0: 20 66 6f 72 20 72 65 6d 6f 76 61 6c 2e 20 44 6f   for removal. Do
55e0: 20 74 68 69 73 20 61 66 74 65 72 20 64 65 6c 65   this after dele
55f0: 74 69 6e 67 20 74 68 65 20 72 65 63 6f 72 64 73  ting the records
5600: 0a 09 20 20 20 3b 3b 20 66 6f 72 20 65 61 63 68  ..   ;; for each
5610: 20 74 65 73 74 20 69 6e 20 63 61 73 65 20 77 65   test in case we
5620: 20 67 65 74 20 6b 69 6c 6c 65 64 2e 20 54 68 61   get killed. Tha
5630: 74 20 73 68 6f 75 6c 64 20 6d 69 6e 69 6d 69 7a  t should minimiz
5640: 65 20 74 68 65 20 64 65 74 72 69 74 75 73 20 6c  e the detritus l
5650: 65 66 74 20 6f 6e 20 64 69 73 6b 0a 09 20 20 20  eft on disk..   
5660: 3b 3b 20 70 72 6f 63 65 73 73 20 74 68 65 20 64  ;; process the d
5670: 69 72 73 20 66 72 6f 6d 20 6c 6f 6e 67 65 73 74  irs from longest
5680: 20 73 74 72 69 6e 67 20 6c 65 6e 67 74 68 20 74   string length t
5690: 6f 20 73 68 6f 72 74 65 73 74 0a 09 20 20 20 28  o shortest..   (
56a0: 66 6f 72 2d 65 61 63 68 20 0a 09 20 20 20 20 28  for-each ..    (
56b0: 6c 61 6d 62 64 61 20 28 64 69 72 2d 74 6f 2d 72  lambda (dir-to-r
56c0: 65 6d 6f 76 65 29 0a 09 20 20 20 20 20 20 28 69  emove)..      (i
56d0: 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20  f (file-exists? 
56e0: 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 0a 09  dir-to-remove)..
56f0: 09 20 20 28 6c 65 74 20 28 28 64 69 72 2d 69 6e  .  (let ((dir-in
5700: 2d 64 62 20 27 28 29 29 29 0a 09 09 20 20 20 20  -db '()))...    
5710: 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63  (sqlite3:for-eac
5720: 68 2d 72 6f 77 0a 09 09 20 20 20 20 20 28 6c 61  h-row...     (la
5730: 6d 62 64 61 20 28 64 69 72 29 0a 09 09 20 20 20  mbda (dir)...   
5740: 20 20 20 20 28 73 65 74 21 20 64 69 72 2d 69 6e      (set! dir-in
5750: 2d 64 62 20 28 63 6f 6e 73 20 64 69 72 20 64 69  -db (cons dir di
5760: 72 2d 69 6e 2d 64 62 29 29 29 0a 09 09 20 20 20  r-in-db)))...   
5770: 20 20 64 62 20 22 53 45 4c 45 43 54 20 72 75 6e    db "SELECT run
5780: 64 69 72 20 46 52 4f 4d 20 74 65 73 74 73 20 57  dir FROM tests W
5790: 48 45 52 45 20 72 75 6e 64 69 72 20 4c 49 4b 45  HERE rundir LIKE
57a0: 20 3f 3b 22 20 0a 09 09 20 20 20 20 20 28 63 6f   ?;" ...     (co
57b0: 6e 63 20 22 25 22 20 64 69 72 2d 74 6f 2d 72 65  nc "%" dir-to-re
57c0: 6d 6f 76 65 20 22 25 22 29 29 20 3b 3b 20 79 65  move "%")) ;; ye
57d0: 73 2c 20 49 27 6d 20 67 6f 69 6e 67 20 74 6f 20  s, I'm going to 
57e0: 62 61 69 6c 20 69 66 20 74 68 65 72 65 20 69 73  bail if there is
57f0: 20 61 6e 79 74 68 69 6e 67 20 6c 69 6b 65 20 74   anything like t
5800: 68 69 73 20 64 69 72 20 69 6e 20 74 68 65 20 64  his dir in the d
5810: 62 0a 09 09 20 20 20 20 28 69 66 20 28 6e 75 6c  b...    (if (nul
5820: 6c 3f 20 64 69 72 2d 69 6e 2d 64 62 29 0a 09 09  l? dir-in-db)...
5830: 09 28 62 65 67 69 6e 0a 09 09 09 20 20 28 64 65  .(begin....  (de
5840: 62 75 67 3a 70 72 69 6e 74 20 32 20 22 52 65 6d  bug:print 2 "Rem
5850: 6f 76 69 6e 67 20 64 69 72 65 63 74 6f 72 79 20  oving directory 
5860: 77 69 74 68 20 7a 65 72 6f 20 64 62 20 72 65 66  with zero db ref
5870: 65 72 65 6e 63 65 73 3a 20 22 20 64 69 72 2d 74  erences: " dir-t
5880: 6f 2d 72 65 6d 6f 76 65 29 0a 09 09 09 20 20 28  o-remove)....  (
5890: 73 79 73 74 65 6d 20 28 63 6f 6e 63 20 22 72 6d  system (conc "rm
58a0: 20 2d 72 66 20 22 20 64 69 72 2d 74 6f 2d 72 65   -rf " dir-to-re
58b0: 6d 6f 76 65 29 29 0a 09 09 09 20 20 28 68 61 73  move))....  (has
58c0: 68 2d 74 61 62 6c 65 2d 64 65 6c 65 74 65 21 20  h-table-delete! 
58d0: 64 69 72 73 2d 74 6f 2d 72 65 6d 6f 76 65 20 64  dirs-to-remove d
58e0: 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 29 0a 09  ir-to-remove))..
58f0: 09 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32  ..(debug:print 2
5900: 20 22 53 6b 69 70 70 69 6e 67 20 72 65 6d 6f 76   "Skipping remov
5910: 61 6c 20 6f 66 20 22 20 64 69 72 2d 74 6f 2d 72  al of " dir-to-r
5920: 65 6d 6f 76 65 20 22 20 66 6f 72 20 6e 6f 77 20  emove " for now 
5930: 61 73 20 69 74 20 73 74 69 6c 6c 20 68 61 73 20  as it still has 
5940: 72 65 66 65 72 65 6e 63 65 73 20 69 6e 20 74 68  references in th
5950: 65 20 64 61 74 61 62 61 73 65 22 29 29 29 29 29  e database")))))
5960: 0a 09 20 20 20 20 28 73 6f 72 74 20 28 68 61 73  ..    (sort (has
5970: 68 2d 74 61 62 6c 65 2d 6b 65 79 73 20 64 69 72  h-table-keys dir
5980: 73 2d 74 6f 2d 72 65 6d 6f 76 65 29 20 28 6c 61  s-to-remove) (la
5990: 6d 62 64 61 20 28 61 20 62 29 28 3e 20 28 73 74  mbda (a b)(> (st
59a0: 72 69 6e 67 2d 6c 65 6e 67 74 68 20 61 29 28 73  ring-length a)(s
59b0: 74 72 69 6e 67 2d 6c 65 6e 67 74 68 20 62 29 29  tring-length b))
59c0: 29 29 29 0a 0a 09 20 20 20 3b 3b 20 72 65 6d 6f  )))...   ;; remo
59d0: 76 65 20 74 68 65 20 72 75 6e 20 69 66 20 7a 65  ve the run if ze
59e0: 72 6f 20 74 65 73 74 73 20 72 65 6d 61 69 6e 0a  ro tests remain.
59f0: 09 20 20 20 28 6c 65 74 20 28 28 72 65 6d 74 65  .   (let ((remte
5a00: 73 74 73 20 28 64 62 2d 67 65 74 2d 74 65 73 74  sts (db-get-test
5a10: 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 28 64 62  s-for-run db (db
5a20: 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65  :get-value-by-he
5a30: 61 64 65 72 20 72 75 6e 20 68 65 61 64 65 72 20  ader run header 
5a40: 22 69 64 22 29 20 23 66 20 23 66 20 27 28 29 20  "id") #f #f '() 
5a50: 27 28 29 29 29 29 0a 09 20 20 20 20 20 28 69 66  '())))..     (if
5a60: 20 28 6e 75 6c 6c 3f 20 72 65 6d 74 65 73 74 73   (null? remtests
5a70: 29 20 3b 3b 20 6e 6f 20 6d 6f 72 65 20 74 65 73  ) ;; no more tes
5a80: 74 73 20 72 65 6d 61 69 6e 69 6e 67 0a 09 09 20  ts remaining... 
5a90: 28 6c 65 74 2a 20 28 28 64 70 61 72 74 73 20 20  (let* ((dparts  
5aa0: 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 6c 61  (string-split la
5ab0: 73 74 74 70 61 74 68 20 22 2f 22 29 29 0a 09 09  sttpath "/"))...
5ac0: 09 28 72 75 6e 70 61 74 68 20 28 63 6f 6e 63 20  .(runpath (conc 
5ad0: 22 2f 22 20 28 73 74 72 69 6e 67 2d 69 6e 74 65  "/" (string-inte
5ae0: 72 73 70 65 72 73 65 20 0a 09 09 09 09 09 20 20  rsperse ......  
5af0: 20 20 28 74 61 6b 65 20 64 70 61 72 74 73 20 28    (take dparts (
5b00: 2d 20 28 6c 65 6e 67 74 68 20 64 70 61 72 74 73  - (length dparts
5b10: 29 20 31 29 29 0a 09 09 09 09 09 20 20 20 20 22  ) 1))......    "
5b20: 2f 22 29 29 29 29 0a 09 09 20 20 20 28 64 65 62  /"))))...   (deb
5b30: 75 67 3a 70 72 69 6e 74 20 31 20 22 52 65 6d 6f  ug:print 1 "Remo
5b40: 76 69 6e 67 20 72 75 6e 3a 20 22 20 72 75 6e 6b  ving run: " runk
5b50: 65 79 20 22 20 22 20 28 64 62 3a 67 65 74 2d 76  ey " " (db:get-v
5b60: 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72  alue-by-header r
5b70: 75 6e 20 68 65 61 64 65 72 20 22 72 75 6e 6e 61  un header "runna
5b80: 6d 65 22 29 29 0a 09 09 20 20 20 28 64 62 3a 64  me"))...   (db:d
5b90: 65 6c 65 74 65 2d 72 75 6e 20 64 62 20 72 75 6e  elete-run db run
5ba0: 2d 69 64 29 0a 09 09 20 20 20 3b 3b 20 6e 65 65  -id)...   ;; nee
5bb0: 64 20 74 6f 20 66 69 67 75 72 65 20 6f 75 74 20  d to figure out 
5bc0: 74 68 65 20 70 61 74 68 20 74 6f 20 74 68 65 20  the path to the 
5bd0: 72 75 6e 20 64 69 72 20 61 6e 64 20 72 65 6d 6f  run dir and remo
5be0: 76 65 20 69 74 20 69 66 20 65 6d 70 74 79 0a 09  ve it if empty..
5bf0: 09 20 20 20 3b 3b 20 20 20 20 28 69 66 20 28 6e  .   ;;    (if (n
5c00: 75 6c 6c 3f 20 28 67 6c 6f 62 20 28 63 6f 6e 63  ull? (glob (conc
5c10: 20 72 75 6e 70 61 74 68 20 22 2f 2a 22 29 29 29   runpath "/*")))
5c20: 0a 09 09 20 20 20 3b 3b 20 20 20 20 20 20 20 20  ...   ;;        
5c30: 28 62 65 67 69 6e 0a 09 09 20 20 20 3b 3b 20 09  (begin...   ;; .
5c40: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20   (debug:print 1 
5c50: 22 52 65 6d 6f 76 69 6e 67 20 72 75 6e 20 64 69  "Removing run di
5c60: 72 20 22 20 72 75 6e 70 61 74 68 29 0a 09 09 20  r " runpath)... 
5c70: 20 20 3b 3b 20 09 20 28 73 79 73 74 65 6d 20 28    ;; . (system (
5c80: 63 6f 6e 63 20 22 72 6d 64 69 72 20 2d 70 20 22  conc "rmdir -p "
5c90: 20 72 75 6e 70 61 74 68 29 29 29 29 0a 09 09 20   runpath))))... 
5ca0: 20 20 29 29 29 29 0a 09 20 29 29 0a 20 20 20 20    )))).. )).    
5cb0: 20 72 75 6e 73 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d   runs)))..;;====
5cc0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5cd0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5ce0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5cf0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5d00: 3d 3d 0a 3b 3b 20 52 6f 75 74 69 6e 65 73 20 66  ==.;; Routines f
5d10: 6f 72 20 6d 61 6e 69 70 75 6c 61 74 69 6e 67 20  or manipulating 
5d20: 72 75 6e 73 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d  runs.;;=========
5d30: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5d40: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5d50: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5d60: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b  =============..;
5d70: 3b 20 53 69 6e 63 65 20 6d 61 6e 79 20 63 61 6c  ; Since many cal
5d80: 6c 73 20 74 6f 20 61 20 72 75 6e 20 72 65 71 75  ls to a run requ
5d90: 69 72 65 20 70 72 65 74 74 79 20 6d 75 63 68 20  ire pretty much 
5da0: 74 68 65 20 73 61 6d 65 20 73 65 74 75 70 20 0a  the same setup .
5db0: 3b 3b 20 74 68 69 73 20 77 72 61 70 70 65 72 20  ;; this wrapper 
5dc0: 69 73 20 75 73 65 64 20 74 6f 20 72 65 64 75 63  is used to reduc
5dd0: 65 20 74 68 65 20 72 65 70 6c 69 63 61 74 69 6f  e the replicatio
5de0: 6e 20 6f 66 20 63 6f 64 65 0a 28 64 65 66 69 6e  n of code.(defin
5df0: 65 20 28 67 65 6e 65 72 61 6c 2d 72 75 6e 2d 63  e (general-run-c
5e00: 61 6c 6c 20 73 77 69 74 63 68 6e 61 6d 65 20 61  all switchname a
5e10: 63 74 69 6f 6e 2d 64 65 73 63 20 70 72 6f 63 29  ction-desc proc)
5e20: 0a 20 20 28 69 66 20 28 6e 6f 74 20 28 61 72 67  .  (if (not (arg
5e30: 73 3a 67 65 74 2d 61 72 67 20 22 3a 72 75 6e 6e  s:get-arg ":runn
5e40: 61 6d 65 22 29 29 0a 20 20 20 20 20 20 28 62 65  ame")).      (be
5e50: 67 69 6e 0a 09 28 64 65 62 75 67 3a 70 72 69 6e  gin..(debug:prin
5e60: 74 20 30 20 22 45 52 52 4f 52 3a 20 4d 69 73 73  t 0 "ERROR: Miss
5e70: 69 6e 67 20 72 65 71 75 69 72 65 64 20 70 61 72  ing required par
5e80: 61 6d 65 74 65 72 20 66 6f 72 20 22 20 73 77 69  ameter for " swi
5e90: 74 63 68 6e 61 6d 65 20 22 2c 20 79 6f 75 20 6d  tchname ", you m
5ea0: 75 73 74 20 73 70 65 63 69 66 79 20 74 68 65 20  ust specify the 
5eb0: 72 75 6e 20 6e 61 6d 65 20 77 69 74 68 20 3a 72  run name with :r
5ec0: 75 6e 6e 61 6d 65 20 72 75 6e 6e 61 6d 65 22 29  unname runname")
5ed0: 0a 09 28 65 78 69 74 20 32 29 29 0a 20 20 20 20  ..(exit 2)).    
5ee0: 20 20 28 6c 65 74 20 28 28 64 62 20 20 20 23 66    (let ((db   #f
5ef0: 29 0a 09 20 20 20 20 28 6b 65 79 73 20 23 66 29  )..    (keys #f)
5f00: 29 0a 09 28 69 66 20 28 6e 6f 74 20 28 73 65 74  )..(if (not (set
5f10: 75 70 2d 66 6f 72 2d 72 75 6e 29 29 0a 09 20 20  up-for-run))..  
5f20: 20 20 28 62 65 67 69 6e 20 0a 09 20 20 20 20 20    (begin ..     
5f30: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
5f40: 22 46 61 69 6c 65 64 20 74 6f 20 73 65 74 75 70  "Failed to setup
5f50: 2c 20 65 78 69 74 69 6e 67 22 29 0a 09 20 20 20  , exiting")..   
5f60: 20 20 20 28 65 78 69 74 20 31 29 29 29 0a 09 28     (exit 1)))..(
5f70: 73 65 74 21 20 64 62 20 20 20 28 6f 70 65 6e 2d  set! db   (open-
5f80: 64 62 29 29 0a 09 28 73 65 74 21 20 6b 65 79 73  db))..(set! keys
5f90: 20 28 64 62 2d 67 65 74 2d 6b 65 79 73 20 64 62   (db-get-keys db
5fa0: 29 29 0a 09 3b 3b 20 68 61 76 65 20 65 6e 6f 75  ))..;; have enou
5fb0: 67 68 20 74 6f 20 70 72 6f 63 65 73 73 20 2d 74  gh to process -t
5fc0: 61 72 67 65 74 20 6f 72 20 2d 72 65 71 74 61 72  arget or -reqtar
5fd0: 67 20 68 65 72 65 0a 09 28 69 66 20 28 61 72 67  g here..(if (arg
5fe0: 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65 71 74  s:get-arg "-reqt
5ff0: 61 72 67 22 29 0a 09 20 20 20 20 28 6c 65 74 2a  arg")..    (let*
6000: 20 28 28 72 75 6e 63 6f 6e 66 69 67 66 20 28 63   ((runconfigf (c
6010: 6f 6e 63 20 20 2a 74 6f 70 70 61 74 68 2a 20 22  onc  *toppath* "
6020: 2f 72 75 6e 63 6f 6e 66 69 67 73 2e 63 6f 6e 66  /runconfigs.conf
6030: 69 67 22 29 29 20 3b 3b 20 44 4f 20 4e 4f 54 20  ig")) ;; DO NOT 
6040: 45 56 41 4c 55 41 54 45 20 41 4c 4c 20 0a 09 09  EVALUATE ALL ...
6050: 20 20 20 28 72 75 6e 63 6f 6e 66 69 67 20 20 28     (runconfig  (
6060: 72 65 61 64 2d 63 6f 6e 66 69 67 20 72 75 6e 63  read-config runc
6070: 6f 6e 66 69 67 66 20 23 66 20 23 66 20 65 6e 76  onfigf #f #f env
6080: 69 72 6f 6e 2d 70 61 74 74 3a 20 23 66 29 29 29  iron-patt: #f)))
6090: 20 0a 09 20 20 20 20 20 20 28 69 66 20 28 68 61   ..      (if (ha
60a0: 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66  sh-table-ref/def
60b0: 61 75 6c 74 20 72 75 6e 63 6f 6e 66 69 67 20 28  ault runconfig (
60c0: 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72  args:get-arg "-r
60d0: 65 71 74 61 72 67 22 29 20 23 66 29 0a 09 09 20  eqtarg") #f)... 
60e0: 20 28 6b 65 79 73 3a 74 61 72 67 65 74 2d 73 65   (keys:target-se
60f0: 74 2d 61 72 67 73 20 6b 65 79 73 20 28 61 72 67  t-args keys (arg
6100: 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65 71 74  s:get-arg "-reqt
6110: 61 72 67 22 29 20 61 72 67 73 3a 61 72 67 2d 68  arg") args:arg-h
6120: 61 73 68 29 0a 09 09 20 20 28 62 65 67 69 6e 0a  ash)...  (begin.
6130: 09 09 20 20 20 20 28 64 65 62 75 67 3a 70 72 69  ..    (debug:pri
6140: 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 5b 22 20  nt 0 "ERROR: [" 
6150: 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d  (args:get-arg "-
6160: 72 65 71 74 61 72 67 22 29 20 22 5d 20 6e 6f 74  reqtarg") "] not
6170: 20 66 6f 75 6e 64 20 69 6e 20 22 20 72 75 6e 63   found in " runc
6180: 6f 6e 66 69 67 66 29 0a 09 09 20 20 20 20 28 73  onfigf)...    (s
6190: 71 6c 69 74 65 33 3a 66 69 6e 61 6c 69 7a 65 21  qlite3:finalize!
61a0: 20 64 62 29 0a 09 09 20 20 20 20 28 65 78 69 74   db)...    (exit
61b0: 20 31 29 29 29 29 0a 09 20 20 20 20 28 69 66 20   1))))..    (if 
61c0: 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d  (args:get-arg "-
61d0: 74 61 72 67 65 74 22 29 0a 09 09 28 6b 65 79 73  target")...(keys
61e0: 3a 74 61 72 67 65 74 2d 73 65 74 2d 61 72 67 73  :target-set-args
61f0: 20 6b 65 79 73 20 28 61 72 67 73 3a 67 65 74 2d   keys (args:get-
6200: 61 72 67 20 22 2d 74 61 72 67 65 74 22 20 61 72  arg "-target" ar
6210: 67 73 3a 61 72 67 2d 68 61 73 68 29 20 61 72 67  gs:arg-hash) arg
6220: 73 3a 61 72 67 2d 68 61 73 68 29 29 29 0a 09 28  s:arg-hash)))..(
6230: 69 66 20 28 6e 6f 74 20 28 63 61 72 20 2a 63 6f  if (not (car *co
6240: 6e 66 69 67 69 6e 66 6f 2a 29 29 0a 09 20 20 20  nfiginfo*))..   
6250: 20 28 62 65 67 69 6e 0a 09 20 20 20 20 20 20 28   (begin..      (
6260: 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45  debug:print 0 "E
6270: 52 52 4f 52 3a 20 41 74 74 65 6d 70 74 65 64 20  RROR: Attempted 
6280: 74 6f 20 22 20 61 63 74 69 6f 6e 2d 64 65 73 63  to " action-desc
6290: 20 22 20 62 75 74 20 72 75 6e 20 61 72 65 61 20   " but run area 
62a0: 63 6f 6e 66 69 67 20 66 69 6c 65 20 6e 6f 74 20  config file not 
62b0: 66 6f 75 6e 64 22 29 0a 09 20 20 20 20 20 20 28  found")..      (
62c0: 65 78 69 74 20 31 29 29 0a 09 20 20 20 20 3b 3b  exit 1))..    ;;
62d0: 20 45 78 74 72 61 63 74 20 6f 75 74 20 73 74 75   Extract out stu
62e0: 66 66 20 6e 65 65 64 65 64 20 69 6e 20 6d 6f 73  ff needed in mos
62f0: 74 20 6f 72 20 6d 61 6e 79 20 63 61 6c 6c 73 0a  t or many calls.
6300: 09 20 20 20 20 3b 3b 20 68 65 72 65 20 74 68 65  .    ;; here the
6310: 6e 20 63 61 6c 6c 20 70 72 6f 63 0a 09 20 20 20  n call proc..   
6320: 20 28 6c 65 74 2a 20 28 28 6b 65 79 6e 61 6d 65   (let* ((keyname
6330: 73 20 20 20 28 6d 61 70 20 6b 65 79 3a 67 65 74  s   (map key:get
6340: 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65 79 73 29  -fieldname keys)
6350: 29 0a 09 09 20 20 20 28 6b 65 79 76 61 6c 6c 73  )...   (keyvalls
6360: 74 20 20 28 6b 65 79 73 2d 3e 76 61 6c 6c 69 73  t  (keys->vallis
6370: 74 20 6b 65 79 73 20 23 74 29 29 29 0a 09 20 20  t keys #t)))..  
6380: 20 20 20 20 28 70 72 6f 63 20 64 62 20 6b 65 79      (proc db key
6390: 73 20 6b 65 79 6e 61 6d 65 73 20 6b 65 79 76 61  s keynames keyva
63a0: 6c 6c 73 74 29 29 29 0a 09 28 73 71 6c 69 74 65  llst)))..(sqlite
63b0: 33 3a 66 69 6e 61 6c 69 7a 65 21 20 64 62 29 0a  3:finalize! db).
63c0: 09 28 73 65 74 21 20 2a 64 69 64 73 6f 6d 65 74  .(set! *didsomet
63d0: 68 69 6e 67 2a 20 23 74 29 29 29 29 0a 0a 3b 3b  hing* #t))))..;;
63e0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
63f0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6400: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6410: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6420: 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 52 6f 6c 6c 75 70  ======.;; Rollup
6430: 20 72 75 6e 73 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d   runs.;;========
6440: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6450: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6460: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6470: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a  ==============..
6480: 3b 3b 20 55 70 64 61 74 65 20 74 68 65 20 74 65  ;; Update the te
6490: 73 74 5f 6d 65 74 61 20 74 61 62 6c 65 20 66 6f  st_meta table fo
64a0: 72 20 74 68 69 73 20 74 65 73 74 0a 28 64 65 66  r this test.(def
64b0: 69 6e 65 20 28 72 75 6e 73 3a 75 70 64 61 74 65  ine (runs:update
64c0: 2d 74 65 73 74 5f 6d 65 74 61 20 64 62 20 74 65  -test_meta db te
64d0: 73 74 2d 6e 61 6d 65 20 74 65 73 74 2d 63 6f 6e  st-name test-con
64e0: 66 29 0a 20 20 28 6c 65 74 20 28 28 63 75 72 72  f).  (let ((curr
64f0: 72 65 63 6f 72 64 20 28 64 62 3a 74 65 73 74 6d  record (db:testm
6500: 65 74 61 2d 67 65 74 2d 72 65 63 6f 72 64 20 64  eta-get-record d
6510: 62 20 74 65 73 74 2d 6e 61 6d 65 29 29 29 0a 20  b test-name))). 
6520: 20 20 20 28 69 66 20 28 6e 6f 74 20 63 75 72 72     (if (not curr
6530: 72 65 63 6f 72 64 29 0a 09 28 62 65 67 69 6e 0a  record)..(begin.
6540: 09 20 20 28 73 65 74 21 20 63 75 72 72 72 65 63  .  (set! currrec
6550: 6f 72 64 20 28 6d 61 6b 65 2d 76 65 63 74 6f 72  ord (make-vector
6560: 20 31 30 20 23 66 29 29 0a 09 20 20 28 64 62 3a   10 #f))..  (db:
6570: 74 65 73 74 6d 65 74 61 2d 61 64 64 2d 72 65 63  testmeta-add-rec
6580: 6f 72 64 20 64 62 20 74 65 73 74 2d 6e 61 6d 65  ord db test-name
6590: 29 29 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63  ))).    (for-eac
65a0: 68 20 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20  h .     (lambda 
65b0: 28 6b 65 79 29 0a 20 20 20 20 20 20 20 28 6c 65  (key).       (le
65c0: 74 2a 20 28 28 69 64 78 20 28 63 61 64 72 20 6b  t* ((idx (cadr k
65d0: 65 79 29 29 0a 09 20 20 20 20 20 20 28 66 6c 64  ey))..      (fld
65e0: 20 28 63 61 72 20 20 6b 65 79 29 29 0a 09 20 20   (car  key))..  
65f0: 20 20 20 20 28 76 61 6c 20 28 63 6f 6e 66 69 67      (val (config
6600: 2d 6c 6f 6f 6b 75 70 20 74 65 73 74 2d 63 6f 6e  -lookup test-con
6610: 66 20 22 74 65 73 74 5f 6d 65 74 61 22 20 66 6c  f "test_meta" fl
6620: 64 29 29 29 0a 09 20 3b 3b 20 28 64 65 62 75 67  d))).. ;; (debug
6630: 3a 70 72 69 6e 74 20 35 20 22 69 64 78 3a 20 22  :print 5 "idx: "
6640: 20 69 64 78 20 22 20 66 6c 64 3a 20 22 20 66 6c   idx " fld: " fl
6650: 64 20 22 20 76 61 6c 3a 20 22 20 76 61 6c 29 0a  d " val: " val).
6660: 09 20 28 69 66 20 28 61 6e 64 20 76 61 6c 20 28  . (if (and val (
6670: 6e 6f 74 20 28 65 71 75 61 6c 3f 20 28 76 65 63  not (equal? (vec
6680: 74 6f 72 2d 72 65 66 20 63 75 72 72 72 65 63 6f  tor-ref currreco
6690: 72 64 20 69 64 78 29 20 76 61 6c 29 29 29 0a 09  rd idx) val)))..
66a0: 20 20 20 20 20 28 62 65 67 69 6e 0a 09 20 20 20       (begin..   
66b0: 20 20 20 20 28 70 72 69 6e 74 20 22 55 70 64 61      (print "Upda
66c0: 74 69 6e 67 20 22 20 74 65 73 74 2d 6e 61 6d 65  ting " test-name
66d0: 20 22 20 22 20 66 6c 64 20 22 20 74 6f 20 22 20   " " fld " to " 
66e0: 76 61 6c 29 0a 09 20 20 20 20 20 20 20 28 64 62  val)..       (db
66f0: 3a 74 65 73 74 6d 65 74 61 2d 75 70 64 61 74 65  :testmeta-update
6700: 2d 66 69 65 6c 64 20 64 62 20 74 65 73 74 2d 6e  -field db test-n
6710: 61 6d 65 20 66 6c 64 20 76 61 6c 29 29 29 29 29  ame fld val)))))
6720: 0a 20 20 20 20 20 27 28 28 22 61 75 74 68 6f 72  .     '(("author
6730: 22 20 32 29 28 22 6f 77 6e 65 72 22 20 33 29 28  " 2)("owner" 3)(
6740: 22 64 65 73 63 72 69 70 74 69 6f 6e 22 20 34 29  "description" 4)
6750: 28 22 72 65 76 69 65 77 65 64 22 20 35 29 28 22  ("reviewed" 5)("
6760: 74 61 67 73 22 20 39 29 29 29 29 29 0a 0a 3b 3b  tags" 9)))))..;;
6770: 20 55 70 64 61 74 65 20 74 65 73 74 5f 6d 65 74   Update test_met
6780: 61 20 66 6f 72 20 61 6c 6c 20 74 65 73 74 73 0a  a for all tests.
6790: 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 75 70  (define (runs:up
67a0: 64 61 74 65 2d 61 6c 6c 2d 74 65 73 74 5f 6d 65  date-all-test_me
67b0: 74 61 20 64 62 29 0a 20 20 28 6c 65 74 20 28 28  ta db).  (let ((
67c0: 74 65 73 74 2d 6e 61 6d 65 73 20 28 67 65 74 2d  test-names (get-
67d0: 61 6c 6c 2d 6c 65 67 61 6c 2d 74 65 73 74 73 29  all-legal-tests)
67e0: 29 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68  )).    (for-each
67f0: 20 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28   .     (lambda (
6800: 74 65 73 74 2d 6e 61 6d 65 29 0a 20 20 20 20 20  test-name).     
6810: 20 20 28 6c 65 74 2a 20 28 28 74 65 73 74 2d 70    (let* ((test-p
6820: 61 74 68 20 20 20 20 28 63 6f 6e 63 20 2a 74 6f  ath    (conc *to
6830: 70 70 61 74 68 2a 20 22 2f 74 65 73 74 73 2f 22  ppath* "/tests/"
6840: 20 74 65 73 74 2d 6e 61 6d 65 29 29 0a 09 20 20   test-name))..  
6850: 20 20 20 20 28 74 65 73 74 2d 63 6f 6e 66 69 67      (test-config
6860: 66 20 28 63 6f 6e 63 20 74 65 73 74 2d 70 61 74  f (conc test-pat
6870: 68 20 22 2f 74 65 73 74 63 6f 6e 66 69 67 22 29  h "/testconfig")
6880: 29 0a 09 20 20 20 20 20 20 28 74 65 73 74 65 78  )..      (testex
6890: 69 73 74 73 20 20 20 28 61 6e 64 20 28 66 69 6c  ists   (and (fil
68a0: 65 2d 65 78 69 73 74 73 3f 20 74 65 73 74 2d 63  e-exists? test-c
68b0: 6f 6e 66 69 67 66 29 28 66 69 6c 65 2d 72 65 61  onfigf)(file-rea
68c0: 64 2d 61 63 63 65 73 73 3f 20 74 65 73 74 2d 63  d-access? test-c
68d0: 6f 6e 66 69 67 66 29 29 29 0a 09 20 20 20 20 20  onfigf)))..     
68e0: 20 3b 3b 20 72 65 61 64 20 63 6f 6e 66 69 67 73   ;; read configs
68f0: 20 77 69 74 68 20 74 72 69 63 6b 73 20 74 75 72   with tricks tur
6900: 6e 65 64 20 6f 66 66 20 28 69 2e 65 2e 20 6e 6f  ned off (i.e. no
6910: 20 73 79 73 74 65 6d 29 0a 09 20 20 20 20 20 20   system)..      
6920: 28 74 65 73 74 2d 63 6f 6e 66 20 20 20 20 28 69  (test-conf    (i
6930: 66 20 74 65 73 74 65 78 69 73 74 73 20 28 72 65  f testexists (re
6940: 61 64 2d 63 6f 6e 66 69 67 20 74 65 73 74 2d 63  ad-config test-c
6950: 6f 6e 66 69 67 66 20 23 66 20 23 66 29 28 6d 61  onfigf #f #f)(ma
6960: 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29 29  ke-hash-table)))
6970: 29 0a 09 20 28 72 75 6e 73 3a 75 70 64 61 74 65  ).. (runs:update
6980: 2d 74 65 73 74 5f 6d 65 74 61 20 64 62 20 74 65  -test_meta db te
6990: 73 74 2d 6e 61 6d 65 20 74 65 73 74 2d 63 6f 6e  st-name test-con
69a0: 66 29 29 29 0a 20 20 20 20 20 74 65 73 74 2d 6e  f))).     test-n
69b0: 61 6d 65 73 29 29 29 0a 0a 3b 3b 20 54 68 69 73  ames)))..;; This
69c0: 20 63 6f 75 6c 64 20 70 72 6f 62 61 62 6c 79 20   could probably 
69d0: 62 65 20 72 65 66 61 63 74 6f 72 65 64 20 69 6e  be refactored in
69e0: 74 6f 20 6f 6e 65 20 63 6f 6d 70 6c 65 78 20 71  to one complex q
69f0: 75 65 72 79 20 2e 2e 2e 0a 28 64 65 66 69 6e 65  uery ....(define
6a00: 20 28 72 75 6e 73 3a 72 6f 6c 6c 75 70 2d 72 75   (runs:rollup-ru
6a10: 6e 20 64 62 20 6b 65 79 73 20 6b 65 79 76 61 6c  n db keys keyval
6a20: 6c 73 74 20 72 75 6e 6e 61 6d 65 20 75 73 65 72  lst runname user
6a30: 29 20 3b 3b 20 77 61 73 20 74 61 72 67 65 74 2c  ) ;; was target,
6a40: 20 6e 6f 77 20 6b 65 79 76 61 6c 6c 73 74 0a 20   now keyvallst. 
6a50: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20   (debug:print 4 
6a60: 22 72 75 6e 73 3a 72 6f 6c 6c 75 70 2d 72 75 6e  "runs:rollup-run
6a70: 2c 20 6b 65 79 73 3a 20 22 20 6b 65 79 73 20 22  , keys: " keys "
6a80: 20 6b 65 79 76 61 6c 6c 73 74 3a 20 22 20 6b 65   keyvallst: " ke
6a90: 79 76 61 6c 6c 73 74 20 22 20 3a 72 75 6e 6e 61  yvallst " :runna
6aa0: 6d 65 20 22 20 72 75 6e 6e 61 6d 65 20 22 20 75  me " runname " u
6ab0: 73 65 72 3a 20 22 20 75 73 65 72 29 0a 20 20 28  ser: " user).  (
6ac0: 6c 65 74 2a 20 28 3b 20 28 6b 65 79 76 61 6c 6c  let* (; (keyvall
6ad0: 6c 73 74 20 20 20 20 20 20 28 6b 65 79 73 3a 74  lst      (keys:t
6ae0: 61 72 67 65 74 2d 3e 6b 65 79 76 61 6c 20 6b 65  arget->keyval ke
6af0: 79 73 20 74 61 72 67 65 74 29 29 0a 09 20 28 6e  ys target)).. (n
6b00: 65 77 2d 72 75 6e 2d 69 64 20 20 20 20 20 20 28  ew-run-id      (
6b10: 72 75 6e 73 3a 72 65 67 69 73 74 65 72 2d 72 75  runs:register-ru
6b20: 6e 20 64 62 20 6b 65 79 73 20 6b 65 79 76 61 6c  n db keys keyval
6b30: 6c 73 74 20 72 75 6e 6e 61 6d 65 20 22 6e 65 77  lst runname "new
6b40: 22 20 22 6e 2f 61 22 20 75 73 65 72 29 29 0a 09  " "n/a" user))..
6b50: 20 28 70 72 65 76 2d 74 65 73 74 73 20 20 20 20   (prev-tests    
6b60: 20 20 28 74 65 73 74 3a 67 65 74 2d 6d 61 74 63    (test:get-matc
6b70: 68 69 6e 67 2d 70 72 65 76 69 6f 75 73 2d 74 65  hing-previous-te
6b80: 73 74 2d 72 75 6e 2d 72 65 63 6f 72 64 73 20 64  st-run-records d
6b90: 62 20 6e 65 77 2d 72 75 6e 2d 69 64 20 22 25 22  b new-run-id "%"
6ba0: 20 22 25 22 29 29 0a 09 20 28 63 75 72 72 2d 74   "%")).. (curr-t
6bb0: 65 73 74 73 20 20 20 20 20 20 28 64 62 2d 67 65  ests      (db-ge
6bc0: 74 2d 74 65 73 74 73 2d 66 6f 72 2d 72 75 6e 20  t-tests-for-run 
6bd0: 64 62 20 6e 65 77 2d 72 75 6e 2d 69 64 20 22 25  db new-run-id "%
6be0: 22 20 22 25 22 20 27 28 29 20 27 28 29 29 29 0a  " "%" '() '())).
6bf0: 09 20 28 63 75 72 72 2d 74 65 73 74 73 2d 68 61  . (curr-tests-ha
6c00: 73 68 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61  sh (make-hash-ta
6c10: 62 6c 65 29 29 29 0a 20 20 20 20 28 64 62 3a 75  ble))).    (db:u
6c20: 70 64 61 74 65 2d 72 75 6e 2d 65 76 65 6e 74 5f  pdate-run-event_
6c30: 74 69 6d 65 20 64 62 20 6e 65 77 2d 72 75 6e 2d  time db new-run-
6c40: 69 64 29 0a 20 20 20 20 3b 3b 20 69 6e 64 65 78  id).    ;; index
6c50: 20 74 68 65 20 61 6c 72 65 61 64 79 20 73 61 76   the already sav
6c60: 65 64 20 74 65 73 74 73 20 62 79 20 74 65 73 74  ed tests by test
6c70: 6e 61 6d 65 20 61 6e 64 20 69 74 65 6d 64 61 74  name and itemdat
6c80: 20 69 6e 20 63 75 72 72 2d 74 65 73 74 73 2d 68   in curr-tests-h
6c90: 61 73 68 0a 20 20 20 20 28 66 6f 72 2d 65 61 63  ash.    (for-eac
6ca0: 68 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28  h.     (lambda (
6cb0: 74 65 73 74 64 61 74 29 0a 20 20 20 20 20 20 20  testdat).       
6cc0: 28 6c 65 74 2a 20 28 28 74 65 73 74 6e 61 6d 65  (let* ((testname
6cd0: 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 74    (db:test-get-t
6ce0: 65 73 74 6e 61 6d 65 20 74 65 73 74 64 61 74 29  estname testdat)
6cf0: 29 0a 09 20 20 20 20 20 20 28 69 74 65 6d 2d 70  )..      (item-p
6d00: 61 74 68 20 28 64 62 3a 74 65 73 74 2d 67 65 74  ath (db:test-get
6d10: 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 64  -item-path testd
6d20: 61 74 29 29 0a 09 20 20 20 20 20 20 28 66 75 6c  at))..      (ful
6d30: 6c 2d 6e 61 6d 65 20 28 63 6f 6e 63 20 74 65 73  l-name (conc tes
6d40: 74 6e 61 6d 65 20 22 2f 22 20 69 74 65 6d 2d 70  tname "/" item-p
6d50: 61 74 68 29 29 29 0a 09 20 28 68 61 73 68 2d 74  ath))).. (hash-t
6d60: 61 62 6c 65 2d 73 65 74 21 20 63 75 72 72 2d 74  able-set! curr-t
6d70: 65 73 74 73 2d 68 61 73 68 20 66 75 6c 6c 2d 6e  ests-hash full-n
6d80: 61 6d 65 20 74 65 73 74 64 61 74 29 29 29 0a 20  ame testdat))). 
6d90: 20 20 20 20 63 75 72 72 2d 74 65 73 74 73 29 0a      curr-tests).
6da0: 20 20 20 20 3b 3b 20 4e 4f 50 45 3a 20 4e 6f 6e      ;; NOPE: Non
6db0: 2d 6f 70 74 69 6d 61 6c 20 61 70 70 72 6f 61 63  -optimal approac
6dc0: 68 2e 20 54 72 79 20 74 68 69 73 20 69 6e 73 74  h. Try this inst
6dd0: 65 61 64 2e 0a 20 20 20 20 3b 3b 20 20 20 31 2e  ead..    ;;   1.
6de0: 20 74 65 73 74 73 20 61 72 65 20 72 65 63 65 69   tests are recei
6df0: 76 65 64 20 69 6e 20 61 20 6c 69 73 74 2c 20 6d  ved in a list, m
6e00: 6f 73 74 20 72 65 63 65 6e 74 20 66 69 72 73 74  ost recent first
6e10: 0a 20 20 20 20 3b 3b 20 20 20 32 2e 20 72 65 70  .    ;;   2. rep
6e20: 6c 61 63 65 20 74 68 65 20 72 6f 6c 6c 75 70 20  lace the rollup 
6e30: 74 65 73 74 20 77 69 74 68 20 74 68 65 20 6e 65  test with the ne
6e40: 77 20 2a 61 6c 77 61 79 73 2a 0a 20 20 20 20 28  w *always*.    (
6e50: 66 6f 72 2d 65 61 63 68 20 0a 20 20 20 20 20 28  for-each .     (
6e60: 6c 61 6d 62 64 61 20 28 74 65 73 74 64 61 74 29  lambda (testdat)
6e70: 0a 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28 28  .       (let* ((
6e80: 74 65 73 74 6e 61 6d 65 20 20 28 64 62 3a 74 65  testname  (db:te
6e90: 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20  st-get-testname 
6ea0: 74 65 73 74 64 61 74 29 29 0a 09 20 20 20 20 20  testdat))..     
6eb0: 20 28 69 74 65 6d 2d 70 61 74 68 20 28 64 62 3a   (item-path (db:
6ec0: 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61  test-get-item-pa
6ed0: 74 68 20 74 65 73 74 64 61 74 29 29 0a 09 20 20  th testdat))..  
6ee0: 20 20 20 20 28 66 75 6c 6c 2d 6e 61 6d 65 20 28      (full-name (
6ef0: 63 6f 6e 63 20 74 65 73 74 6e 61 6d 65 20 22 2f  conc testname "/
6f00: 22 20 69 74 65 6d 2d 70 61 74 68 29 29 0a 09 20  " item-path)).. 
6f10: 20 20 20 20 20 28 70 72 65 76 2d 74 65 73 74 2d       (prev-test-
6f20: 64 61 74 20 28 68 61 73 68 2d 74 61 62 6c 65 2d  dat (hash-table-
6f30: 72 65 66 2f 64 65 66 61 75 6c 74 20 63 75 72 72  ref/default curr
6f40: 2d 74 65 73 74 73 2d 68 61 73 68 20 66 75 6c 6c  -tests-hash full
6f50: 2d 6e 61 6d 65 20 23 66 29 29 0a 09 20 20 20 20  -name #f))..    
6f60: 20 20 28 74 65 73 74 2d 73 74 65 70 73 20 20 20    (test-steps   
6f70: 20 20 20 28 64 62 3a 67 65 74 2d 73 74 65 70 73     (db:get-steps
6f80: 2d 66 6f 72 2d 74 65 73 74 20 64 62 20 28 64 62  -for-test db (db
6f90: 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73  :test-get-id tes
6fa0: 74 64 61 74 29 29 29 0a 09 20 20 20 20 20 20 28  tdat)))..      (
6fb0: 6e 65 77 2d 74 65 73 74 2d 72 65 63 6f 72 64 20  new-test-record 
6fc0: 23 66 29 29 0a 09 20 3b 3b 20 72 65 70 6c 61 63  #f)).. ;; replac
6fd0: 65 20 74 68 65 73 65 20 77 69 74 68 20 69 6e 73  e these with ins
6fe0: 65 72 74 20 2e 2e 2e 20 73 65 6c 65 63 74 0a 09  ert ... select..
6ff0: 20 28 61 70 70 6c 79 20 73 71 6c 69 74 65 33 3a   (apply sqlite3:
7000: 65 78 65 63 75 74 65 20 0a 09 09 64 62 20 0a 09  execute ...db ..
7010: 09 28 63 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f  .(conc "INSERT O
7020: 52 20 52 45 50 4c 41 43 45 20 49 4e 54 4f 20 74  R REPLACE INTO t
7030: 65 73 74 73 20 28 72 75 6e 5f 69 64 2c 74 65 73  ests (run_id,tes
7040: 74 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 61 74  tname,state,stat
7050: 75 73 2c 65 76 65 6e 74 5f 74 69 6d 65 2c 68 6f  us,event_time,ho
7060: 73 74 2c 63 70 75 6c 6f 61 64 2c 64 69 73 6b 66  st,cpuload,diskf
7070: 72 65 65 2c 75 6e 61 6d 65 2c 72 75 6e 64 69 72  ree,uname,rundir
7080: 2c 69 74 65 6d 5f 70 61 74 68 2c 72 75 6e 5f 64  ,item_path,run_d
7090: 75 72 61 74 69 6f 6e 2c 66 69 6e 61 6c 5f 6c 6f  uration,final_lo
70a0: 67 66 2c 63 6f 6d 6d 65 6e 74 29 20 22 0a 09 09  gf,comment) "...
70b0: 20 20 20 20 20 20 22 56 41 4c 55 45 53 20 28 3f        "VALUES (?
70c0: 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f  ,?,?,?,?,?,?,?,?
70d0: 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 29 3b 22 29 0a 09  ,?,?,?,?,?);")..
70e0: 09 6e 65 77 2d 72 75 6e 2d 69 64 20 28 63 64 64  .new-run-id (cdd
70f0: 72 20 28 76 65 63 74 6f 72 2d 3e 6c 69 73 74 20  r (vector->list 
7100: 74 65 73 74 64 61 74 29 29 29 0a 09 20 28 73 65  testdat))).. (se
7110: 74 21 20 6e 65 77 2d 74 65 73 74 64 61 74 20 28  t! new-testdat (
7120: 63 61 72 20 28 64 62 2d 67 65 74 2d 74 65 73 74  car (db-get-test
7130: 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 6e 65 77  s-for-run db new
7140: 2d 72 75 6e 2d 69 64 20 74 65 73 74 6e 61 6d 65  -run-id testname
7150: 20 69 74 65 6d 2d 70 61 74 68 20 27 28 29 20 27   item-path '() '
7160: 28 29 29 29 29 0a 09 20 28 68 61 73 68 2d 74 61  ()))).. (hash-ta
7170: 62 6c 65 2d 73 65 74 21 20 63 75 72 72 2d 74 65  ble-set! curr-te
7180: 73 74 73 2d 68 61 73 68 20 66 75 6c 6c 2d 6e 61  sts-hash full-na
7190: 6d 65 20 6e 65 77 2d 74 65 73 74 64 61 74 29 20  me new-testdat) 
71a0: 3b 3b 20 74 68 69 73 20 63 6f 75 6c 64 20 62 65  ;; this could be
71b0: 20 63 6f 6e 66 75 73 69 6e 67 2c 20 77 68 69 63   confusing, whic
71c0: 68 20 72 65 63 6f 72 64 20 73 68 6f 75 6c 64 20  h record should 
71d0: 67 6f 20 69 6e 74 6f 20 74 68 65 20 6c 6f 6f 6b  go into the look
71e0: 75 70 20 74 61 62 6c 65 3f 0a 09 20 3b 3b 20 4e  up table?.. ;; N
71f0: 6f 77 20 64 75 70 6c 69 63 61 74 65 20 74 68 65  ow duplicate the
7200: 20 74 65 73 74 20 73 74 65 70 73 0a 09 20 28 64   test steps.. (d
7210: 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 43 6f  ebug:print 4 "Co
7220: 70 79 69 6e 67 20 72 65 63 6f 72 64 73 20 69 6e  pying records in
7230: 20 74 65 73 74 5f 73 74 65 70 73 20 66 72 6f 6d   test_steps from
7240: 20 74 65 73 74 5f 69 64 3d 22 20 28 64 62 3a 74   test_id=" (db:t
7250: 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74 64  est-get-id testd
7260: 61 74 29 20 22 20 74 6f 20 22 20 28 64 62 3a 74  at) " to " (db:t
7270: 65 73 74 2d 67 65 74 2d 69 64 20 6e 65 77 2d 74  est-get-id new-t
7280: 65 73 74 64 61 74 29 29 0a 09 20 28 73 71 6c 69  estdat)).. (sqli
7290: 74 65 33 3a 65 78 65 63 75 74 65 20 0a 09 20 20  te3:execute ..  
72a0: 64 62 20 0a 09 20 20 28 63 6f 6e 63 20 22 49 4e  db ..  (conc "IN
72b0: 53 45 52 54 20 4f 52 20 52 45 50 4c 41 43 45 20  SERT OR REPLACE 
72c0: 49 4e 54 4f 20 74 65 73 74 5f 73 74 65 70 73 20  INTO test_steps 
72d0: 28 74 65 73 74 5f 69 64 2c 73 74 65 70 6e 61 6d  (test_id,stepnam
72e0: 65 2c 73 74 61 74 65 2c 73 74 61 74 75 73 2c 65  e,state,status,e
72f0: 76 65 6e 74 5f 74 69 6d 65 2c 63 6f 6d 6d 65 6e  vent_time,commen
7300: 74 29 20 22 0a 09 09 22 53 45 4c 45 43 54 20 22  t) "..."SELECT "
7310: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64   (db:test-get-id
7320: 20 6e 65 77 2d 74 65 73 74 64 61 74 29 20 22 2c   new-testdat) ",
7330: 73 74 65 70 6e 61 6d 65 2c 73 74 61 74 65 2c 73  stepname,state,s
7340: 74 61 74 75 73 2c 65 76 65 6e 74 5f 74 69 6d 65  tatus,event_time
7350: 2c 63 6f 6d 6d 65 6e 74 20 46 52 4f 4d 20 74 65  ,comment FROM te
7360: 73 74 5f 73 74 65 70 73 20 57 48 45 52 45 20 74  st_steps WHERE t
7370: 65 73 74 5f 69 64 3d 3f 3b 22 29 0a 09 20 20 28  est_id=?;")..  (
7380: 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74  db:test-get-id t
7390: 65 73 74 64 61 74 29 29 0a 09 20 3b 3b 20 4e 6f  estdat)).. ;; No
73a0: 77 20 64 75 70 6c 69 63 61 74 65 20 74 68 65 20  w duplicate the 
73b0: 74 65 73 74 20 64 61 74 61 0a 09 20 28 64 65 62  test data.. (deb
73c0: 75 67 3a 70 72 69 6e 74 20 34 20 22 43 6f 70 79  ug:print 4 "Copy
73d0: 69 6e 67 20 72 65 63 6f 72 64 73 20 69 6e 20 74  ing records in t
73e0: 65 73 74 5f 64 61 74 61 20 66 72 6f 6d 20 74 65  est_data from te
73f0: 73 74 5f 69 64 3d 22 20 28 64 62 3a 74 65 73 74  st_id=" (db:test
7400: 2d 67 65 74 2d 69 64 20 74 65 73 74 64 61 74 29  -get-id testdat)
7410: 20 22 20 74 6f 20 22 20 28 64 62 3a 74 65 73 74   " to " (db:test
7420: 2d 67 65 74 2d 69 64 20 6e 65 77 2d 74 65 73 74  -get-id new-test
7430: 64 61 74 29 29 0a 09 20 28 73 71 6c 69 74 65 33  dat)).. (sqlite3
7440: 3a 65 78 65 63 75 74 65 20 0a 09 20 20 64 62 20  :execute ..  db 
7450: 0a 09 20 20 28 63 6f 6e 63 20 22 49 4e 53 45 52  ..  (conc "INSER
7460: 54 20 4f 52 20 52 45 50 4c 41 43 45 20 49 4e 54  T OR REPLACE INT
7470: 4f 20 74 65 73 74 5f 64 61 74 61 20 28 74 65 73  O test_data (tes
7480: 74 5f 69 64 2c 63 61 74 65 67 6f 72 79 2c 76 61  t_id,category,va
7490: 72 69 61 62 6c 65 2c 76 61 6c 75 65 2c 65 78 70  riable,value,exp
74a0: 65 63 74 65 64 2c 74 6f 6c 2c 75 6e 69 74 73 2c  ected,tol,units,
74b0: 63 6f 6d 6d 65 6e 74 29 20 22 0a 09 09 22 53 45  comment) "..."SE
74c0: 4c 45 43 54 20 22 20 28 64 62 3a 74 65 73 74 2d  LECT " (db:test-
74d0: 67 65 74 2d 69 64 20 6e 65 77 2d 74 65 73 74 64  get-id new-testd
74e0: 61 74 29 20 22 2c 63 61 74 65 67 6f 72 79 2c 76  at) ",category,v
74f0: 61 72 69 61 62 6c 65 2c 76 61 6c 75 65 2c 65 78  ariable,value,ex
7500: 70 65 63 74 65 64 2c 74 6f 6c 2c 75 6e 69 74 73  pected,tol,units
7510: 2c 63 6f 6d 6d 65 6e 74 20 46 52 4f 4d 20 74 65  ,comment FROM te
7520: 73 74 5f 64 61 74 61 20 57 48 45 52 45 20 74 65  st_data WHERE te
7530: 73 74 5f 69 64 3d 3f 3b 22 29 0a 09 20 20 28 64  st_id=?;")..  (d
7540: 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65  b:test-get-id te
7550: 73 74 64 61 74 29 29 0a 09 20 29 29 0a 20 20 20  stdat)).. )).   
7560: 20 20 70 72 65 76 2d 74 65 73 74 73 29 29 29 0a    prev-tests))).
7570: 09 20 0a 20 20 20 20 20 0a                       . .     .