Megatest

Hex Artifact Content
Login

Artifact 40f0efb0b5fe19b59a39eb48dc2fdfaa709b5a0c:


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 73 74 72 69 6e 67 2d 73 70 6c 69 74     (string-split
1fa0: 20 74 65 73 74 2d 70 61 74 74 73 20 22 2c 22 29   test-patts ",")
1fb0: 29 0a 0a 20 20 20 20 20 3b 3b 20 6e 6f 77 20 72  )..     ;; now r
1fc0: 65 6d 6f 76 65 20 64 75 70 6c 69 63 61 74 65 73  emove duplicates
1fd0: 0a 20 20 20 20 28 73 65 74 21 20 74 65 73 74 2d  .    (set! test-
1fe0: 6e 61 6d 65 73 20 28 64 65 6c 65 74 65 2d 64 75  names (delete-du
1ff0: 70 6c 69 63 61 74 65 73 20 74 65 73 74 2d 6e 61  plicates test-na
2000: 6d 65 73 29 29 0a 0a 20 20 20 20 28 64 65 62 75  mes))..    (debu
2010: 67 3a 70 72 69 6e 74 20 30 20 22 49 4e 46 4f 3a  g:print 0 "INFO:
2020: 20 74 65 73 74 20 6e 61 6d 65 73 20 22 20 74 65   test names " te
2030: 73 74 2d 6e 61 6d 65 73 29 0a 0a 20 20 20 20 3b  st-names)..    ;
2040: 3b 20 6f 6e 20 74 68 65 20 66 69 72 73 74 20 70  ; on the first p
2050: 61 73 73 20 6f 72 20 63 61 6c 6c 20 74 6f 20 72  ass or call to r
2060: 75 6e 2d 74 65 73 74 73 20 73 65 74 20 46 41 49  un-tests set FAI
2070: 4c 53 20 74 6f 20 4e 4f 54 5f 53 54 41 52 54 45  LS to NOT_STARTE
2080: 44 20 69 66 0a 20 20 20 20 3b 3b 20 2d 6b 65 65  D if.    ;; -kee
2090: 70 67 6f 69 6e 67 20 69 73 20 73 70 65 63 69 66  pgoing is specif
20a0: 69 65 64 0a 20 20 20 20 28 69 66 20 28 65 71 3f  ied.    (if (eq?
20b0: 20 2a 70 61 73 73 6e 75 6d 2a 20 30 29 0a 09 28   *passnum* 0)..(
20c0: 62 65 67 69 6e 0a 09 20 20 3b 3b 20 68 61 76 65  begin..  ;; have
20d0: 20 74 6f 20 64 65 6c 65 74 65 20 74 65 73 74 20   to delete test 
20e0: 72 65 63 6f 72 64 73 20 77 68 65 72 65 20 4e 4f  records where NO
20f0: 54 5f 53 54 41 52 54 45 44 20 73 69 6e 63 65 20  T_STARTED since 
2100: 74 68 65 79 20 63 61 6e 20 63 61 75 73 65 20 2d  they can cause -
2110: 6b 65 65 70 67 6f 69 6e 67 20 74 6f 20 0a 09 20  keepgoing to .. 
2120: 20 3b 3b 20 67 65 74 20 73 74 75 63 6b 20 64 75   ;; get stuck du
2130: 65 20 74 6f 20 62 65 63 6f 6d 69 6e 67 20 69 6e  e to becoming in
2140: 61 63 63 65 73 73 69 62 6c 65 20 66 72 6f 6d 20  accessible from 
2150: 61 20 66 61 69 6c 65 64 20 74 65 73 74 2e 20 49  a failed test. I
2160: 2e 65 2e 20 69 66 20 74 65 73 74 20 42 20 64 65  .e. if test B de
2170: 70 65 6e 64 73 20 0a 09 20 20 3b 3b 20 6f 6e 20  pends ..  ;; on 
2180: 74 65 73 74 20 41 20 62 75 74 20 74 65 73 74 20  test A but test 
2190: 42 20 72 65 61 63 68 65 64 20 74 68 65 20 70 6f  B reached the po
21a0: 69 6e 74 20 6f 6e 20 62 65 69 6e 67 20 72 65 67  int on being reg
21b0: 69 73 74 65 72 65 64 20 61 73 20 4e 4f 54 5f 53  istered as NOT_S
21c0: 54 41 52 54 45 44 20 61 6e 64 20 74 65 73 74 0a  TARTED and test.
21d0: 09 20 20 3b 3b 20 41 20 66 61 69 6c 65 64 20 66  .  ;; A failed f
21e0: 6f 72 20 73 6f 6d 65 20 72 65 61 73 6f 6e 20 74  or some reason t
21f0: 68 65 6e 20 6f 6e 20 72 65 2d 72 75 6e 20 75 73  hen on re-run us
2200: 69 6e 67 20 2d 6b 65 65 70 67 6f 69 6e 67 20 74  ing -keepgoing t
2210: 68 65 20 72 75 6e 20 63 61 6e 20 6e 65 76 65 72  he run can never
2220: 20 63 6f 6d 70 6c 65 74 65 2e 0a 09 20 20 28 64   complete...  (d
2230: 62 3a 64 65 6c 65 74 65 2d 74 65 73 74 73 2d 69  b:delete-tests-i
2240: 6e 2d 73 74 61 74 65 20 64 62 20 72 75 6e 2d 69  n-state db run-i
2250: 64 20 22 4e 4f 54 5f 53 54 41 52 54 45 44 22 29  d "NOT_STARTED")
2260: 0a 09 20 20 28 64 62 3a 73 65 74 2d 74 65 73 74  ..  (db:set-test
2270: 73 2d 73 74 61 74 65 2d 73 74 61 74 75 73 20 64  s-state-status d
2280: 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61  b run-id test-na
2290: 6d 65 73 20 23 66 20 22 46 41 49 4c 22 20 22 4e  mes #f "FAIL" "N
22a0: 4f 54 5f 53 54 41 52 54 45 44 22 20 22 46 41 49  OT_STARTED" "FAI
22b0: 4c 22 29 29 29 0a 0a 20 20 20 20 3b 3b 20 6e 6f  L")))..    ;; no
22c0: 77 20 61 64 64 20 6e 6f 6e 2d 64 69 72 65 63 74  w add non-direct
22d0: 6c 79 20 72 65 66 65 72 65 6e 63 65 64 20 64 65  ly referenced de
22e0: 70 65 6e 64 65 6e 63 69 65 73 20 28 69 2e 65 2e  pendencies (i.e.
22f0: 20 77 61 69 74 6f 6e 29 0a 20 20 20 20 28 69 66   waiton).    (if
2300: 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 65 73   (not (null? tes
2310: 74 2d 6e 61 6d 65 73 29 29 0a 09 28 6c 65 74 20  t-names))..(let 
2320: 6c 6f 6f 70 20 28 28 68 65 64 20 28 63 61 72 20  loop ((hed (car 
2330: 74 65 73 74 2d 6e 61 6d 65 73 29 29 0a 09 09 20  test-names))... 
2340: 20 20 28 74 61 6c 20 28 63 64 72 20 74 65 73 74    (tal (cdr test
2350: 2d 6e 61 6d 65 73 29 29 29 20 20 20 20 20 20 20  -names)))       
2360: 20 20 3b 3b 20 27 72 65 74 75 72 6e 2d 70 72 6f    ;; 'return-pro
2370: 63 73 20 74 65 6c 6c 73 20 74 68 65 20 63 6f 6e  cs tells the con
2380: 66 69 67 20 72 65 61 64 65 72 20 74 6f 20 70 72  fig reader to pr
2390: 65 70 20 72 75 6e 6e 69 6e 67 20 73 79 73 74 65  ep running syste
23a0: 6d 20 62 75 74 20 72 65 74 75 72 6e 20 61 20 70  m but return a p
23b0: 72 6f 63 0a 09 20 20 28 6c 65 74 2a 20 28 28 63  roc..  (let* ((c
23c0: 6f 6e 66 69 67 20 20 28 74 65 73 74 3a 67 65 74  onfig  (test:get
23d0: 2d 74 65 73 74 63 6f 6e 66 69 67 20 68 65 64 20  -testconfig hed 
23e0: 27 72 65 74 75 72 6e 2d 70 72 6f 63 73 29 29 0a  'return-procs)).
23f0: 09 09 20 28 77 61 69 74 6f 6e 73 20 28 73 74 72  .. (waitons (str
2400: 69 6e 67 2d 73 70 6c 69 74 20 28 6c 65 74 20 28  ing-split (let (
2410: 28 77 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75  (w (config-looku
2420: 70 20 63 6f 6e 66 69 67 20 22 72 65 71 75 69 72  p config "requir
2430: 65 6d 65 6e 74 73 22 20 22 77 61 69 74 6f 6e 22  ements" "waiton"
2440: 29 29 29 0a 09 09 09 09 09 20 20 28 69 66 20 77  )))......  (if w
2450: 20 77 20 22 22 29 29 29 29 29 0a 3b 3b 09 09 20   w ""))))).;;.. 
2460: 28 69 74 65 6d 73 20 20 20 28 69 74 65 6d 73 3a  (items   (items:
2470: 67 65 74 2d 69 74 65 6d 73 2d 66 72 6f 6d 2d 63  get-items-from-c
2480: 6f 6e 66 69 67 20 63 6f 6e 66 69 67 29 29 29 0a  onfig config))).
2490: 09 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28 68  .    (if (not (h
24a0: 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65  ash-table-ref/de
24b0: 66 61 75 6c 74 20 74 65 73 74 2d 72 65 63 6f 72  fault test-recor
24c0: 64 73 20 68 65 64 20 23 66 29 29 0a 09 09 28 68  ds hed #f))...(h
24d0: 61 73 68 2d 74 61 62 6c 65 2d 73 65 74 21 20 74  ash-table-set! t
24e0: 65 73 74 2d 72 65 63 6f 72 64 73 20 68 65 64 20  est-records hed 
24f0: 28 76 65 63 74 6f 72 20 68 65 64 20 63 6f 6e 66  (vector hed conf
2500: 69 67 20 77 61 69 74 6f 6e 73 20 28 63 6f 6e 66  ig waitons (conf
2510: 69 67 2d 6c 6f 6f 6b 75 70 20 63 6f 6e 66 69 67  ig-lookup config
2520: 20 22 72 65 71 75 69 72 65 6d 65 6e 74 73 22 20   "requirements" 
2530: 22 70 72 69 6f 72 69 74 79 22 29 20 23 66 29 29  "priority") #f))
2540: 29 0a 09 20 20 20 20 28 66 6f 72 2d 65 61 63 68  )..    (for-each
2550: 20 0a 09 20 20 20 20 20 28 6c 61 6d 62 64 61 20   ..     (lambda 
2560: 28 77 61 69 74 6f 6e 29 0a 09 20 20 20 20 20 20  (waiton)..      
2570: 20 28 69 66 20 28 61 6e 64 20 77 61 69 74 6f 6e   (if (and waiton
2580: 20 28 6e 6f 74 20 28 6d 65 6d 62 65 72 20 77 61   (not (member wa
2590: 69 74 6f 6e 20 74 65 73 74 2d 6e 61 6d 65 73 29  iton test-names)
25a0: 29 29 0a 09 09 20 20 20 28 62 65 67 69 6e 0a 09  ))...   (begin..
25b0: 09 20 20 20 20 20 28 73 65 74 21 20 72 65 71 75  .     (set! requ
25c0: 69 72 65 64 2d 74 65 73 74 73 20 28 63 6f 6e 73  ired-tests (cons
25d0: 20 77 61 69 74 6f 6e 20 72 65 71 75 69 72 65 64   waiton required
25e0: 2d 74 65 73 74 73 29 29 0a 09 09 20 20 20 20 20  -tests))...     
25f0: 28 73 65 74 21 20 74 65 73 74 2d 6e 61 6d 65 73  (set! test-names
2600: 20 28 61 70 70 65 6e 64 20 74 65 73 74 2d 6e 61   (append test-na
2610: 6d 65 73 20 28 6c 69 73 74 20 77 61 69 74 6f 6e  mes (list waiton
2620: 29 29 29 29 29 29 0a 09 20 20 20 20 20 77 61 69  ))))))..     wai
2630: 74 6f 6e 73 29 0a 09 20 20 20 20 28 6c 65 74 20  tons)..    (let 
2640: 28 28 72 65 6d 74 65 73 74 73 20 28 64 65 6c 65  ((remtests (dele
2650: 74 65 2d 64 75 70 6c 69 63 61 74 65 73 20 28 61  te-duplicates (a
2660: 70 70 65 6e 64 20 77 61 69 74 6f 6e 73 20 74 61  ppend waitons ta
2670: 6c 29 29 29 29 0a 09 20 20 20 20 20 20 28 69 66  l))))..      (if
2680: 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 72 65 6d   (not (null? rem
2690: 74 65 73 74 73 29 29 0a 09 09 20 20 28 6c 6f 6f  tests))...  (loo
26a0: 70 20 28 63 61 72 20 72 65 6d 74 65 73 74 73 29  p (car remtests)
26b0: 28 63 64 72 20 72 65 6d 74 65 73 74 73 29 29 29  (cdr remtests)))
26c0: 29 29 29 29 0a 0a 20 20 20 20 28 69 66 20 28 6e  ))))..    (if (n
26d0: 6f 74 20 28 6e 75 6c 6c 3f 20 72 65 71 75 69 72  ot (null? requir
26e0: 65 64 2d 74 65 73 74 73 29 29 0a 09 28 64 65 62  ed-tests))..(deb
26f0: 75 67 3a 70 72 69 6e 74 20 31 20 22 49 4e 46 4f  ug:print 1 "INFO
2700: 3a 20 41 64 64 69 6e 67 20 22 20 72 65 71 75 69  : Adding " requi
2710: 72 65 64 2d 74 65 73 74 73 20 22 20 74 6f 20 74  red-tests " to t
2720: 68 65 20 72 75 6e 20 71 75 65 75 65 22 29 29 0a  he run queue")).
2730: 20 20 20 20 3b 3b 20 4e 4f 54 45 3a 20 74 68 65      ;; NOTE: the
2740: 73 65 20 61 72 65 20 61 6c 6c 20 70 61 72 65 6e  se are all paren
2750: 74 20 74 65 73 74 73 2c 20 69 74 65 6d 73 20 61  t tests, items a
2760: 72 65 20 6e 6f 74 20 65 78 70 61 6e 64 65 64 20  re not expanded 
2770: 79 65 74 2e 0a 20 20 20 20 28 72 75 6e 73 3a 72  yet..    (runs:r
2780: 75 6e 2d 74 65 73 74 73 2d 71 75 65 75 65 20 74  un-tests-queue t
2790: 65 73 74 2d 72 65 63 6f 72 64 73 20 6b 65 79 76  est-records keyv
27a0: 61 6c 6c 69 73 74 29 29 29 0a 0a 28 64 65 66 69  allist)))..(defi
27b0: 6e 65 20 28 72 75 6e 73 3a 72 75 6e 2d 74 65 73  ne (runs:run-tes
27c0: 74 73 2d 71 75 65 75 65 20 20 74 65 73 74 2d 72  ts-queue  test-r
27d0: 65 63 6f 72 64 73 20 6b 65 79 76 61 6c 6c 69 73  ecords keyvallis
27e0: 74 29 0a 20 20 20 20 3b 3b 20 41 74 20 74 68 69  t).    ;; At thi
27f0: 73 20 70 6f 69 6e 74 20 74 68 65 20 6c 69 73 74  s point the list
2800: 20 6f 66 20 70 61 72 65 6e 74 20 74 65 73 74 73   of parent tests
2810: 20 69 73 20 65 78 70 61 6e 64 65 64 20 0a 20 20   is expanded .  
2820: 20 20 3b 3b 20 4e 42 2f 2f 20 53 68 6f 75 6c 64    ;; NB// Should
2830: 20 65 78 70 61 6e 64 20 69 74 65 6d 73 20 68 65   expand items he
2840: 72 65 20 61 6e 64 20 74 68 65 6e 20 69 6e 73 65  re and then inse
2850: 72 74 20 69 6e 74 6f 20 74 68 65 20 72 75 6e 20  rt into the run 
2860: 71 75 65 75 65 2e 0a 20 20 20 20 28 6c 65 74 20  queue..    (let 
2870: 28 28 73 6f 72 74 65 64 2d 74 65 73 74 6e 61 6d  ((sorted-testnam
2880: 65 73 20 28 74 65 73 74 73 3a 73 6f 72 74 2d 62  es (tests:sort-b
2890: 79 2d 70 72 69 6f 72 69 74 79 2d 61 6e 64 2d 77  y-priority-and-w
28a0: 61 69 74 6f 6e 20 74 65 73 74 2d 72 65 63 6f 72  aiton test-recor
28b0: 64 73 29 29 29 0a 20 20 20 20 20 20 28 6c 65 74  ds))).      (let
28c0: 20 6c 6f 6f 70 20 28 3b 20 28 6e 75 6d 74 69 6d   loop (; (numtim
28d0: 65 73 20 30 29 20 3b 3b 20 73 68 6f 75 6c 64 6e  es 0) ;; shouldn
28e0: 27 74 20 6e 65 65 64 20 74 68 69 73 0a 09 09 20  't need this... 
28f0: 28 68 65 64 20 20 20 20 20 20 20 20 20 28 63 61  (hed         (ca
2900: 72 20 73 6f 72 74 65 64 2d 74 65 73 74 2d 6e 61  r sorted-test-na
2910: 6d 65 73 29 29 0a 09 09 20 28 74 61 6c 20 20 20  mes))... (tal   
2920: 20 20 20 20 20 20 28 63 64 72 20 73 6f 72 74 65        (cdr sorte
2930: 64 2d 74 65 73 74 2d 6e 61 6d 65 73 29 29 29 0a  d-test-names))).
2940: 09 28 6c 65 74 2a 20 28 28 74 65 73 74 2d 72 65  .(let* ((test-re
2950: 63 6f 72 64 20 28 68 61 73 68 2d 74 61 62 6c 65  cord (hash-table
2960: 2d 72 65 66 20 74 65 73 74 2d 72 65 63 6f 72 64  -ref test-record
2970: 73 20 68 65 64 29 29 20 20 20 20 20 20 20 20 20  s hed))         
2980: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2990: 57 48 45 52 45 20 54 4f 20 44 4f 3a 20 28 69 74  WHERE TO DO: (it
29a0: 65 6d 73 3a 67 65 74 2d 69 74 65 6d 73 2d 66 72  ems:get-items-fr
29b0: 6f 6d 2d 63 6f 6e 66 69 67 20 63 6f 6e 66 69 67  om-config config
29c0: 29 0a 09 20 20 20 20 20 20 20 28 74 63 6f 6e 66  )..       (tconf
29d0: 69 67 20 20 20 20 20 28 74 65 73 74 73 3a 74 65  ig     (tests:te
29e0: 73 74 71 75 65 75 65 2d 67 65 74 2d 74 65 73 74  stqueue-get-test
29f0: 63 6f 6e 66 69 67 20 74 65 73 74 2d 72 65 63 6f  config test-reco
2a00: 72 64 29 29 0a 09 20 20 20 20 20 20 20 28 77 61  rd))..       (wa
2a10: 69 74 6f 6e 73 20 20 20 20 20 28 74 65 73 74 73  itons     (tests
2a20: 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d 77  :testqueue-get-w
2a30: 61 69 74 6f 6e 73 20 20 20 20 74 65 73 74 2d 72  aitons    test-r
2a40: 65 63 6f 72 64 29 29 0a 09 20 20 20 20 20 20 20  ecord))..       
2a50: 28 70 72 69 6f 72 69 74 79 20 20 20 20 28 74 65  (priority    (te
2a60: 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65  sts:testqueue-ge
2a70: 74 2d 70 72 69 6f 72 69 74 79 20 20 20 74 65 73  t-priority   tes
2a80: 74 2d 72 65 63 6f 72 64 29 29 0a 09 20 20 20 20  t-record))..    
2a90: 20 20 20 28 69 74 65 6d 64 61 74 20 20 20 20 20     (itemdat     
2aa0: 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65  (tests:testqueue
2ab0: 2d 67 65 74 2d 69 74 65 6d 64 61 74 20 20 20 20  -get-itemdat    
2ac0: 74 65 73 74 2d 72 65 63 6f 72 64 29 29 0a 09 20  test-record)).. 
2ad0: 20 20 20 20 20 20 28 69 74 65 6d 73 20 20 20 20        (items    
2ae0: 20 20 20 28 74 65 73 74 73 3a 74 65 73 74 71 75     (tests:testqu
2af0: 65 75 65 2d 67 65 74 2d 69 74 65 6d 73 20 20 20  eue-get-items   
2b00: 20 20 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29     test-record))
2b10: 0a 09 20 20 20 20 20 20 20 28 69 74 65 6d 2d 70  ..       (item-p
2b20: 61 74 68 20 20 20 28 69 74 65 6d 2d 6c 69 73 74  ath   (item-list
2b30: 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74 29 29  ->path itemdat))
2b40: 29 0a 09 20 20 28 63 6f 6e 64 0a 09 20 20 20 28  )..  (cond..   (
2b50: 28 6e 6f 74 20 69 74 65 6d 73 29 20 3b 3b 20 77  (not items) ;; w
2b60: 68 65 6e 20 66 61 6c 73 65 20 74 68 65 20 74 65  hen false the te
2b70: 73 74 20 69 73 20 6f 6b 20 74 6f 20 62 65 20 68  st is ok to be h
2b80: 61 6e 64 65 64 20 6f 66 66 20 74 6f 20 6c 61 75  anded off to lau
2b90: 6e 63 68 0a 09 20 20 20 20 28 6c 65 74 20 28 28  nch..    (let ((
2ba0: 68 61 76 65 2d 72 65 73 6f 75 72 63 65 73 20 20  have-resources  
2bb0: 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f  (runs:can-run-mo
2bc0: 72 65 2d 74 65 73 74 73 20 64 62 20 74 65 73 74  re-tests db test
2bd0: 2d 72 65 63 6f 72 64 29 29 20 3b 3b 20 6c 6f 6f  -record)) ;; loo
2be0: 6b 20 61 74 20 74 68 65 20 74 65 73 74 20 6a 6f  k at the test jo
2bf0: 62 67 72 6f 75 70 20 61 6e 64 20 74 6f 74 20 6a  bgroup and tot j
2c00: 6f 62 73 20 72 75 6e 6e 69 6e 67 0a 09 09 20 20  obs running...  
2c10: 28 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74  (prereqs-not-met
2c20: 20 28 64 62 3a 67 65 74 2d 70 72 65 72 65 71 73   (db:get-prereqs
2c30: 2d 6e 6f 74 2d 6d 65 74 20 64 62 20 72 75 6e 2d  -not-met db run-
2c40: 69 64 20 77 61 69 74 6f 6e 20 69 74 65 6d 2d 70  id waiton item-p
2c50: 61 74 68 29 29 29 0a 09 20 20 20 20 20 20 28 69  ath)))..      (i
2c60: 66 20 28 61 6e 64 20 68 61 76 65 2d 72 65 73 6f  f (and have-reso
2c70: 75 72 63 65 73 0a 09 09 20 20 20 20 20 20 20 28  urces...       (
2c80: 6e 75 6c 6c 3f 20 70 72 65 72 65 71 73 2d 6e 6f  null? prereqs-no
2c90: 74 2d 6d 65 74 29 29 0a 09 09 20 20 3b 3b 20 6e  t-met))...  ;; n
2ca0: 6f 20 6c 6f 6f 70 20 2d 20 64 72 6f 70 20 74 68  o loop - drop th
2cb0: 6f 75 67 68 20 61 6e 64 20 75 73 65 20 74 68 65  ough and use the
2cc0: 20 6c 6f 6f 70 20 61 74 20 74 68 65 20 62 6f 74   loop at the bot
2cd0: 74 6f 6d 20 0a 09 09 20 20 28 72 75 6e 3a 74 65  tom ...  (run:te
2ce0: 73 74 20 64 62 20 72 75 6e 2d 69 64 20 72 75 6e  st db run-id run
2cf0: 6e 61 6d 65 20 6b 65 79 76 61 6c 6c 73 74 20 74  name keyvallst t
2d00: 65 73 74 2d 72 65 63 6f 72 64 20 66 6c 61 67 73  est-record flags
2d10: 29 0a 09 09 20 20 3b 3b 20 65 6c 73 65 20 74 68  )...  ;; else th
2d20: 65 20 72 75 6e 20 69 73 20 73 74 75 63 6b 2c 20  e run is stuck, 
2d30: 74 65 6d 70 6f 72 61 72 69 6c 79 20 6f 72 20 70  temporarily or p
2d40: 65 72 6d 61 6e 65 6e 74 6c 79 0a 09 09 20 20 28  ermanently...  (
2d50: 6c 65 74 20 28 28 6e 65 77 74 61 6c 20 28 61 70  let ((newtal (ap
2d60: 70 65 6e 64 20 74 61 6c 20 28 6c 69 73 74 20 68  pend tal (list h
2d70: 65 64 29 29 29 29 0a 09 09 20 20 20 20 3b 3b 20  ed))))...    ;; 
2d80: 63 6f 75 6c 64 6e 27 74 20 72 75 6e 2c 20 74 61  couldn't run, ta
2d90: 6b 65 20 61 20 62 72 65 61 74 68 65 72 0a 09 09  ke a breather...
2da0: 20 20 20 20 28 74 68 72 65 61 64 2d 73 6c 65 65      (thread-slee
2db0: 70 21 20 31 29 0a 09 09 20 20 20 20 28 6c 6f 6f  p! 1)...    (loo
2dc0: 70 20 28 63 61 72 20 74 61 6c 29 28 63 64 72 20  p (car tal)(cdr 
2dd0: 74 61 6c 29 29 29 29 29 29 0a 09 20 20 20 0a 09  tal))))))..   ..
2de0: 20 20 20 3b 3b 20 63 61 73 65 20 77 68 65 72 65     ;; case where
2df0: 20 61 6e 20 69 74 65 6d 73 20 63 61 6d 65 20 69   an items came i
2e00: 6e 20 61 73 20 61 20 6c 69 73 74 20 62 65 65 6e  n as a list been
2e10: 20 70 72 6f 63 65 73 73 65 64 0a 09 20 20 20 28   processed..   (
2e20: 28 61 6e 64 20 28 6c 69 73 74 3f 20 69 74 65 6d  (and (list? item
2e30: 73 29 20 20 20 20 20 3b 3b 20 74 68 75 73 20 77  s)     ;; thus w
2e40: 65 20 6b 6e 6f 77 20 6f 75 72 20 69 74 65 6d 73  e know our items
2e50: 20 61 72 65 20 61 6c 72 65 61 64 79 20 63 61 6c   are already cal
2e60: 63 75 6c 61 74 65 64 0a 09 09 20 28 6e 6f 74 20  culated... (not 
2e70: 20 20 69 74 65 6d 64 61 74 29 29 20 3b 3b 20 61    itemdat)) ;; a
2e80: 6e 64 20 6e 6f 74 20 79 65 74 20 65 78 70 61 6e  nd not yet expan
2e90: 64 65 64 20 69 6e 74 6f 20 74 68 65 20 6c 69 73  ded into the lis
2ea0: 74 20 6f 66 20 74 68 69 6e 67 73 20 74 6f 20 62  t of things to b
2eb0: 65 20 64 6f 6e 65 0a 09 20 20 20 20 28 69 66 20  e done..    (if 
2ec0: 28 3e 3d 20 2a 76 65 72 62 6f 73 69 74 79 2a 20  (>= *verbosity* 
2ed0: 31 29 28 70 70 20 69 74 65 6d 73 29 29 0a 09 20  1)(pp items)).. 
2ee0: 20 20 20 3b 3b 20 28 69 66 20 28 3e 3d 20 2a 76     ;; (if (>= *v
2ef0: 65 72 62 6f 73 69 74 79 2a 20 35 29 0a 09 20 20  erbosity* 5)..  
2f00: 20 20 3b 3b 20 20 20 20 20 28 62 65 67 69 6e 0a    ;;     (begin.
2f10: 09 20 20 20 20 3b 3b 20 20 20 20 20 20 20 28 70  .    ;;       (p
2f20: 72 69 6e 74 20 22 69 74 65 6d 73 3a 20 22 29 20  rint "items: ") 
2f30: 20 20 20 20 28 70 70 20 28 69 74 65 6d 2d 61 73      (pp (item-as
2f40: 73 6f 63 2d 3e 69 74 65 6d 2d 6c 69 73 74 20 69  soc->item-list i
2f50: 74 65 6d 73 29 29 0a 09 20 20 20 20 3b 3b 20 20  tems))..    ;;  
2f60: 20 20 20 20 20 28 70 72 69 6e 74 20 22 69 74 65       (print "ite
2f70: 6d 73 74 61 62 6c 65 3a 20 22 29 28 70 70 20 28  mstable: ")(pp (
2f80: 69 74 65 6d 2d 74 61 62 6c 65 2d 3e 69 74 65 6d  item-table->item
2f90: 2d 6c 69 73 74 20 69 74 65 6d 73 74 61 62 6c 65  -list itemstable
2fa0: 29 29 29 29 0a 09 20 20 20 20 28 66 6f 72 2d 65  ))))..    (for-e
2fb0: 61 63 68 0a 09 20 20 20 20 20 28 6c 61 6d 62 64  ach..     (lambd
2fc0: 61 20 28 6d 79 2d 69 74 65 6d 64 61 74 29 0a 09  a (my-itemdat)..
2fd0: 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28 28 6e         (let* ((n
2fe0: 65 77 2d 74 65 73 74 2d 72 65 63 6f 72 64 20 28  ew-test-record (
2ff0: 76 65 63 74 6f 72 2d 63 6f 70 79 21 20 74 65 73  vector-copy! tes
3000: 74 2d 72 65 63 6f 72 64 20 28 6d 61 6b 65 2d 74  t-record (make-t
3010: 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 29 29  ests:testqueue))
3020: 29 0a 09 09 20 20 20 20 20 20 28 6d 79 2d 69 74  )...      (my-it
3030: 65 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c 69  em-path (item-li
3040: 73 74 2d 3e 70 61 74 68 20 6d 79 2d 69 74 65 6d  st->path my-item
3050: 64 61 74 29 29 0a 09 09 20 20 20 20 20 20 28 69  dat))...      (i
3060: 74 65 6d 2d 6d 61 74 63 68 65 73 20 28 69 66 20  tem-matches (if 
3070: 69 74 65 6d 2d 70 61 74 74 73 20 20 20 20 20 20  item-patts      
3080: 20 3b 3b 20 68 65 72 65 20 77 65 20 61 72 65 20   ;; here we are 
3090: 66 69 6c 74 65 72 69 6e 67 20 66 6f 72 20 6d 61  filtering for ma
30a0: 74 63 68 65 73 20 77 69 74 68 20 2d 69 74 65 6d  tches with -item
30b0: 70 61 74 74 0a 09 09 09 09 09 28 6c 65 74 20 28  patt......(let (
30c0: 28 72 65 73 20 23 66 29 29 09 20 3b 3b 20 6c 6f  (res #f)). ;; lo
30d0: 6f 6b 20 74 68 72 6f 75 67 68 20 61 6c 6c 20 74  ok through all t
30e0: 68 65 20 69 74 65 6d 2d 70 61 74 74 73 20 69 66  he item-patts if
30f0: 20 64 65 66 69 6e 65 64 2c 20 66 6f 72 6d 61 74   defined, format
3100: 20 69 73 20 70 61 74 74 31 2c 70 61 74 74 32 2c   is patt1,patt2,
3110: 70 61 74 74 33 20 2e 2e 2e 20 77 69 6c 64 63 61  patt3 ... wildca
3120: 72 64 20 69 73 20 25 0a 09 09 09 09 09 20 20 28  rd is %......  (
3130: 66 6f 72 2d 65 61 63 68 20 0a 09 09 09 09 09 20  for-each ...... 
3140: 20 20 28 6c 61 6d 62 64 61 20 28 70 61 74 74 29    (lambda (patt)
3150: 0a 09 09 09 09 09 20 20 20 20 20 28 69 66 20 28  ......     (if (
3160: 73 74 72 69 6e 67 2d 73 65 61 72 63 68 20 28 67  string-search (g
3170: 6c 6f 62 2d 3e 72 65 67 65 78 70 0a 09 09 09 09  lob->regexp.....
3180: 09 09 09 09 20 28 73 74 72 69 6e 67 2d 74 72 61  .... (string-tra
3190: 6e 73 6c 61 74 65 20 70 61 74 74 20 22 25 22 20  nslate patt "%" 
31a0: 22 2a 22 29 29 0a 09 09 09 09 09 09 09 09 69 74  "*")).........it
31b0: 65 6d 2d 70 61 74 68 29 0a 09 09 09 09 09 09 20  em-path)....... 
31c0: 28 73 65 74 21 20 72 65 73 20 23 74 29 29 29 0a  (set! res #t))).
31d0: 09 09 09 09 09 20 20 20 28 73 74 72 69 6e 67 2d  .....   (string-
31e0: 73 70 6c 69 74 20 69 74 65 6d 2d 70 61 74 74 73  split item-patts
31f0: 20 22 2c 22 29 29 0a 09 09 09 09 09 20 20 72 65   ","))......  re
3200: 73 29 0a 09 09 09 09 09 23 74 29 29 29 0a 09 09  s)......#t)))...
3210: 20 28 69 66 20 69 74 65 6d 2d 6d 61 74 63 68 65   (if item-matche
3220: 73 20 3b 3b 20 79 65 73 2c 20 77 65 20 77 61 6e  s ;; yes, we wan
3230: 74 20 74 6f 20 70 72 6f 63 65 73 73 20 74 68 69  t to process thi
3240: 73 20 69 74 65 6d 0a 09 09 20 20 20 20 20 28 62  s item...     (b
3250: 65 67 69 6e 0a 09 09 20 20 20 20 20 20 20 28 74  egin...       (t
3260: 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d 73  ests:testqueue-s
3270: 65 74 2d 69 74 65 6d 73 21 20 20 20 6e 65 77 2d  et-items!   new-
3280: 74 65 73 74 2d 72 65 63 6f 72 64 20 23 66 29 0a  test-record #f).
3290: 09 09 20 20 20 20 20 20 20 28 74 65 73 74 73 3a  ..       (tests:
32a0: 74 65 73 74 71 75 65 75 65 2d 73 65 74 2d 69 74  testqueue-set-it
32b0: 65 6d 64 61 74 21 20 6e 65 77 2d 74 65 73 74 2d  emdat! new-test-
32c0: 72 65 63 6f 72 64 20 6d 79 2d 69 74 65 6d 64 61  record my-itemda
32d0: 74 29 0a 09 09 20 20 20 20 20 20 20 28 73 65 74  t)...       (set
32e0: 21 20 74 61 6c 20 28 63 6f 6e 73 20 28 63 6f 6e  ! tal (cons (con
32f0: 63 20 68 65 64 20 22 2f 22 20 6d 79 2d 69 74 65  c hed "/" my-ite
3300: 6d 2d 70 61 74 68 29 20 74 61 6c 29 29 29 29 29  m-path) tal)))))
3310: 29 20 3b 3b 20 73 69 6e 63 65 20 74 68 65 73 65  ) ;; since these
3320: 20 61 72 65 20 69 74 65 6d 69 7a 65 64 20 63 72   are itemized cr
3330: 65 61 74 65 20 6e 65 77 20 74 65 73 74 20 6e 61  eate new test na
3340: 6d 65 73 20 74 65 73 74 6e 61 6d 65 2f 69 74 65  mes testname/ite
3350: 6d 70 61 74 68 0a 09 20 20 20 20 20 69 74 65 6d  mpath..     item
3360: 73 29 0a 09 20 20 20 20 28 6c 6f 6f 70 20 28 63  s)..    (loop (c
3370: 61 72 20 74 61 6c 29 28 63 64 72 20 74 61 6c 29  ar tal)(cdr tal)
3380: 29 29 0a 0a 09 20 20 20 3b 3b 20 69 66 20 69 74  ))...   ;; if it
3390: 65 6d 73 20 69 73 20 61 20 70 72 6f 63 20 74 68  ems is a proc th
33a0: 65 6e 20 6e 65 65 64 20 74 6f 20 65 76 61 6c 75  en need to evalu
33b0: 61 74 65 2c 20 67 65 74 20 74 68 65 20 6c 69 73  ate, get the lis
33c0: 74 20 61 6e 64 20 6c 6f 6f 70 20 2d 20 62 75 74  t and loop - but
33d0: 20 6f 6e 6c 79 20 64 6f 20 74 68 61 74 20 69 66   only do that if
33e0: 20 0a 09 20 20 20 3b 3b 20 72 65 73 6f 75 72 63   ..   ;; resourc
33f0: 65 73 20 65 78 69 73 74 20 74 6f 20 6b 69 63 6b  es exist to kick
3400: 20 6f 66 66 20 74 68 65 20 6a 6f 62 0a 09 20 20   off the job..  
3410: 20 28 28 70 72 6f 63 65 64 75 72 65 3f 20 69 74   ((procedure? it
3420: 65 6d 73 29 0a 09 20 20 20 20 28 69 66 20 28 72  ems)..    (if (r
3430: 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65  uns:can-run-more
3440: 2d 74 65 73 74 73 20 64 62 20 74 65 73 74 2d 72  -tests db test-r
3450: 65 63 6f 72 64 29 0a 09 09 28 6c 65 74 20 28 28  ecord)...(let ((
3460: 69 74 65 6d 73 2d 6c 69 73 74 20 28 69 74 65 6d  items-list (item
3470: 73 29 29 29 0a 09 09 20 20 20 20 20 20 0a 09 09  s)))...      ...
3480: 20 20 28 69 66 20 28 6c 69 73 74 3f 20 69 74 65    (if (list? ite
3490: 6d 73 2d 6c 69 73 74 29 0a 09 09 20 20 20 20 20  ms-list)...     
34a0: 20 28 62 65 67 69 6e 0a 09 09 09 28 74 65 73 74   (begin....(test
34b0: 73 3a 74 65 73 74 71 75 65 75 65 2d 73 65 74 2d  s:testqueue-set-
34c0: 69 74 65 6d 73 20 74 65 73 74 2d 72 65 63 6f 72  items test-recor
34d0: 64 20 69 74 65 6d 73 2d 6c 69 73 74 29 0a 09 09  d items-list)...
34e0: 09 28 6c 6f 6f 70 20 68 65 64 20 74 61 6c 29 29  .(loop hed tal))
34f0: 0a 09 09 20 20 20 20 20 20 28 62 65 67 69 6e 0a  ...      (begin.
3500: 09 09 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20  ...(debug:print 
3510: 30 20 22 45 52 52 4f 52 3a 20 54 68 65 20 70 72  0 "ERROR: The pr
3520: 6f 63 20 66 72 6f 6d 20 72 65 61 64 69 6e 67 20  oc from reading 
3530: 74 68 65 20 73 65 74 75 70 20 64 69 64 20 6e 6f  the setup did no
3540: 74 20 79 69 65 6c 64 20 61 20 6c 69 73 74 20 2d  t yield a list -
3550: 20 70 6c 65 61 73 65 20 72 65 70 6f 72 74 20 74   please report t
3560: 68 69 73 22 29 0a 09 09 09 28 65 78 69 74 20 31  his")....(exit 1
3570: 29 29 29 29 0a 09 09 28 6c 65 74 20 28 28 6e 65  ))))...(let ((ne
3580: 77 74 61 6c 20 28 61 70 70 65 6e 64 20 74 61 6c  wtal (append tal
3590: 20 28 6c 69 73 74 20 68 65 64 29 29 29 29 0a 09   (list hed))))..
35a0: 09 20 20 3b 3b 20 69 66 20 63 61 6e 27 74 20 72  .  ;; if can't r
35b0: 75 6e 20 6d 6f 72 65 20 74 65 73 74 73 2c 20 6c  un more tests, l
35c0: 65 74 73 20 74 61 6b 65 20 61 20 62 72 65 61 74  ets take a breat
35d0: 68 65 72 0a 09 09 20 20 28 74 68 72 65 61 64 2d  her...  (thread-
35e0: 73 6c 65 65 70 21 20 31 29 0a 09 09 20 20 28 6c  sleep! 1)...  (l
35f0: 6f 6f 70 20 28 63 61 72 20 6e 65 77 74 61 6c 29  oop (car newtal)
3600: 28 63 64 72 20 6e 65 77 74 61 6c 29 29 29 29 29  (cdr newtal)))))
3610: 0a 0a 09 20 20 20 3b 3b 20 74 68 69 73 20 63 61  ...   ;; this ca
3620: 73 65 20 73 68 6f 75 6c 64 20 6e 6f 74 20 68 61  se should not ha
3630: 70 70 65 6e 2c 20 61 64 64 65 64 20 74 6f 20 68  ppen, added to h
3640: 65 6c 70 20 63 61 74 63 68 20 61 6e 79 20 62 75  elp catch any bu
3650: 67 73 0a 09 20 20 20 28 28 61 6e 64 20 28 6c 69  gs..   ((and (li
3660: 73 74 3f 20 69 74 65 6d 73 29 20 69 74 65 6d 64  st? items) itemd
3670: 61 74 29 0a 09 20 20 20 20 28 64 65 62 75 67 3a  at)..    (debug:
3680: 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20  print 0 "ERROR: 
3690: 53 68 6f 75 6c 64 20 6e 6f 74 20 68 61 76 65 20  Should not have 
36a0: 61 20 6c 69 73 74 20 6f 66 20 69 74 65 6d 73 20  a list of items 
36b0: 69 6e 20 61 20 74 65 73 74 20 61 6e 64 20 74 68  in a test and th
36c0: 65 20 69 74 65 6d 73 70 61 74 68 20 73 65 74 20  e itemspath set 
36d0: 2d 20 70 6c 65 61 73 65 20 72 65 70 6f 72 74 20  - please report 
36e0: 74 68 69 73 22 29 0a 09 20 20 20 20 28 65 78 69  this")..    (exi
36f0: 74 20 31 29 29 29 0a 09 20 20 0a 09 20 20 3b 3b  t 1)))..  ..  ;;
3700: 20 77 65 20 67 65 74 20 68 65 72 65 20 6f 6e 20   we get here on 
3710: 22 64 72 6f 70 20 74 68 72 6f 75 67 68 22 20 2d  "drop through" -
3720: 20 6c 6f 6f 70 20 66 6f 72 20 6e 65 78 74 20 74   loop for next t
3730: 65 73 74 20 69 6e 20 71 75 65 75 65 0a 09 20 20  est in queue..  
3740: 28 69 66 20 28 6e 75 6c 6c 3f 20 74 61 6c 29 0a  (if (null? tal).
3750: 09 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72  .      (debug:pr
3760: 69 6e 74 20 31 20 22 49 4e 46 4f 3a 20 41 6c 6c  int 1 "INFO: All
3770: 20 74 65 73 74 73 20 6c 61 75 6e 63 68 65 64 22   tests launched"
3780: 29 0a 09 20 20 20 20 20 20 28 6c 6f 6f 70 20 28  )..      (loop (
3790: 63 61 72 20 74 61 6c 29 28 63 64 72 20 74 61 6c  car tal)(cdr tal
37a0: 29 29 29 29 29 29 29 0a 0a 28 64 65 66 69 6e 65  )))))))..(define
37b0: 20 28 72 75 6e 3a 74 65 73 74 20 64 62 20 72 75   (run:test db ru
37c0: 6e 2d 69 64 20 72 75 6e 6e 61 6d 65 20 6b 65 79  n-id runname key
37d0: 76 61 6c 6c 73 74 20 74 65 73 74 2d 72 65 63 6f  vallst test-reco
37e0: 72 64 20 66 6c 61 67 73 29 0a 20 20 28 64 65 62  rd flags).  (deb
37f0: 75 67 3a 70 72 69 6e 74 20 31 20 22 4c 61 75 6e  ug:print 1 "Laun
3800: 63 68 69 6e 67 20 74 65 73 74 20 22 20 74 65 73  ching test " tes
3810: 74 2d 6e 61 6d 65 29 0a 20 20 3b 3b 20 41 6c 6c  t-name).  ;; All
3820: 20 74 68 65 73 65 20 76 61 72 73 20 6d 69 67 68   these vars migh
3830: 74 20 62 65 20 72 65 66 65 72 65 6e 63 65 64 20  t be referenced 
3840: 62 79 20 74 68 65 20 74 65 73 74 63 6f 6e 66 69  by the testconfi
3850: 67 20 66 69 6c 65 20 72 65 61 64 65 72 0a 20 20  g file reader.  
3860: 28 73 65 74 65 6e 76 20 22 4d 54 5f 54 45 53 54  (setenv "MT_TEST
3870: 5f 4e 41 4d 45 22 20 74 65 73 74 2d 6e 61 6d 65  _NAME" test-name
3880: 29 20 3b 3b 20 0a 20 20 28 73 65 74 65 6e 76 20  ) ;; .  (setenv 
3890: 22 4d 54 5f 52 55 4e 4e 41 4d 45 22 20 20 20 72  "MT_RUNNAME"   r
38a0: 75 6e 6e 61 6d 65 29 0a 20 20 28 73 65 74 2d 6d  unname).  (set-m
38b0: 65 67 61 74 65 73 74 2d 65 6e 76 2d 76 61 72 73  egatest-env-vars
38c0: 20 64 62 20 72 75 6e 2d 69 64 29 20 3b 3b 20 74   db run-id) ;; t
38d0: 68 65 73 65 20 6d 61 79 20 62 65 20 6e 65 65 64  hese may be need
38e0: 65 64 20 62 79 20 74 68 65 20 6c 61 75 6e 63 68  ed by the launch
38f0: 69 6e 67 20 70 72 6f 63 65 73 73 0a 20 20 28 63  ing process.  (c
3900: 68 61 6e 67 65 2d 64 69 72 65 63 74 6f 72 79 20  hange-directory 
3910: 2a 74 6f 70 70 61 74 68 2a 29 0a 20 20 28 6c 65  *toppath*).  (le
3920: 74 2a 20 28 28 74 65 73 74 2d 6e 61 6d 65 20 20  t* ((test-name  
3930: 20 20 28 74 65 73 74 73 3a 74 65 73 74 71 75 65    (tests:testque
3940: 75 65 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20  ue-get-testname 
3950: 74 65 73 74 2d 72 65 63 6f 72 64 29 29 0a 09 20  test-record)).. 
3960: 28 74 65 73 74 2d 70 61 74 68 20 20 20 20 28 63  (test-path    (c
3970: 6f 6e 63 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f  onc *toppath* "/
3980: 74 65 73 74 73 2f 22 20 74 65 73 74 2d 6e 61 6d  tests/" test-nam
3990: 65 29 29 20 3b 3b 20 63 6f 75 6c 64 20 75 73 65  e)) ;; could use
39a0: 20 74 65 73 74 3a 67 65 74 2d 74 65 73 74 63 6f   test:get-testco
39b0: 6e 66 69 67 20 68 65 72 65 20 2e 2e 2e 0a 09 20  nfig here ..... 
39c0: 28 74 65 73 74 2d 63 6f 6e 66 20 20 20 20 28 74  (test-conf    (t
39d0: 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67  ests:testqueue-g
39e0: 65 74 2d 74 65 73 74 63 6f 6e 66 69 67 20 74 65  et-testconfig te
39f0: 73 74 2d 72 65 63 6f 72 64 29 29 0a 09 20 28 69  st-record)).. (i
3a00: 74 65 6d 64 61 74 20 20 20 20 20 20 28 74 65 73  temdat      (tes
3a10: 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74  ts:testqueue-get
3a20: 2d 69 74 65 6d 64 61 74 20 20 20 20 74 65 73 74  -itemdat    test
3a30: 2d 72 65 63 6f 72 64 29 29 0a 09 20 28 66 6f 72  -record)).. (for
3a40: 63 65 20 20 20 20 20 20 20 20 28 68 61 73 68 2d  ce        (hash-
3a50: 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c  table-ref/defaul
3a60: 74 20 66 6c 61 67 73 20 22 2d 66 6f 72 63 65 22  t flags "-force"
3a70: 20 23 66 29 29 0a 09 20 28 72 65 72 75 6e 20 20   #f)).. (rerun  
3a80: 20 20 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c        (hash-tabl
3a90: 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 66 6c  e-ref/default fl
3aa0: 61 67 73 20 22 2d 72 65 72 75 6e 22 20 23 66 29  ags "-rerun" #f)
3ab0: 29 0a 09 20 28 6b 65 65 70 67 6f 69 6e 67 20 20  ).. (keepgoing  
3ac0: 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65    (hash-table-re
3ad0: 66 2f 64 65 66 61 75 6c 74 20 66 6c 61 67 73 20  f/default flags 
3ae0: 22 2d 6b 65 65 70 67 6f 69 6e 67 22 20 23 66 29  "-keepgoing" #f)
3af0: 29 29 0a 0a 20 20 20 20 3b 3b 20 48 65 72 65 20  ))..    ;; Here 
3b00: 69 73 20 77 68 65 72 65 20 74 68 65 20 74 65 73  is where the tes
3b10: 74 5f 6d 65 74 61 20 74 61 62 6c 65 20 69 73 20  t_meta table is 
3b20: 62 65 73 74 20 75 70 64 61 74 65 64 0a 20 20 20  best updated.   
3b30: 20 28 72 75 6e 73 3a 75 70 64 61 74 65 2d 74 65   (runs:update-te
3b40: 73 74 5f 6d 65 74 61 20 64 62 20 74 65 73 74 2d  st_meta db test-
3b50: 6e 61 6d 65 20 74 65 73 74 2d 63 6f 6e 66 29 0a  name test-conf).
3b60: 20 20 20 20 0a 20 20 20 20 3b 3b 20 28 6c 61 6d      .    ;; (lam
3b70: 62 64 61 20 28 69 74 65 6d 64 61 74 29 20 3b 3b  bda (itemdat) ;;
3b80: 3b 20 28 28 72 69 70 65 6e 65 73 73 20 22 6f 76  ; ((ripeness "ov
3b90: 65 72 72 69 70 65 22 29 20 28 74 65 6d 70 65 72  erripe") (temper
3ba0: 61 74 75 72 65 20 22 63 6f 6f 6c 22 29 20 28 73  ature "cool") (s
3bb0: 65 61 73 6f 6e 20 22 73 75 6d 6d 65 72 22 29 29  eason "summer"))
3bc0: 0a 20 20 20 20 28 6c 65 74 2a 20 28 28 69 74 65  .    (let* ((ite
3bd0: 6d 2d 70 61 74 68 20 20 20 20 20 28 69 74 65 6d  m-path     (item
3be0: 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69 74 65 6d  -list->path item
3bf0: 64 61 74 29 29 20 3b 3b 20 28 73 74 72 69 6e 67  dat)) ;; (string
3c00: 2d 69 6e 74 65 72 73 70 65 72 73 65 20 28 6d 61  -intersperse (ma
3c10: 70 20 63 61 64 72 20 69 74 65 6d 64 61 74 29 20  p cadr itemdat) 
3c20: 22 2f 22 29 29 0a 09 20 20 20 28 6e 65 77 2d 74  "/"))..   (new-t
3c30: 65 73 74 2d 70 61 74 68 20 28 73 74 72 69 6e 67  est-path (string
3c40: 2d 69 6e 74 65 72 73 70 65 72 73 65 20 28 63 6f  -intersperse (co
3c50: 6e 73 20 74 65 73 74 2d 70 61 74 68 20 28 6d 61  ns test-path (ma
3c60: 70 20 63 61 64 72 20 69 74 65 6d 64 61 74 29 29  p cadr itemdat))
3c70: 20 22 2f 22 29 29 0a 09 20 20 20 28 6e 65 77 2d   "/"))..   (new-
3c80: 74 65 73 74 2d 6e 61 6d 65 20 28 69 66 20 28 65  test-name (if (e
3c90: 71 75 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20  qual? item-path 
3ca0: 22 22 29 20 74 65 73 74 2d 6e 61 6d 65 20 28 63  "") test-name (c
3cb0: 6f 6e 63 20 74 65 73 74 2d 6e 61 6d 65 20 22 2f  onc test-name "/
3cc0: 22 20 69 74 65 6d 2d 70 61 74 68 29 29 29 20 3b  " item-path))) ;
3cd0: 3b 20 6a 75 73 74 20 6e 65 65 64 20 69 74 20 74  ; just need it t
3ce0: 6f 20 62 65 20 75 6e 69 71 75 65 0a 09 20 20 20  o be unique..   
3cf0: 28 74 65 73 74 64 61 74 20 20 20 20 20 20 20 23  (testdat       #
3d00: 66 29 0a 09 20 20 20 28 74 65 73 74 2d 69 6e 66  f)..   (test-inf
3d10: 6f 20 28 64 62 3a 67 65 74 2d 74 65 73 74 2d 69  o (db:get-test-i
3d20: 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65  nfo db run-id te
3d30: 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74  st-name item-pat
3d40: 68 29 29 29 0a 20 20 20 20 20 20 28 69 66 20 28  h))).      (if (
3d50: 6e 6f 74 20 74 65 73 74 2d 69 6e 66 6f 29 28 72  not test-info)(r
3d60: 65 67 69 73 74 65 72 2d 74 65 73 74 20 64 62 20  egister-test db 
3d70: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
3d80: 20 69 74 65 6d 2d 70 61 74 68 29 29 0a 20 20 20   item-path)).   
3d90: 20 20 20 28 63 68 61 6e 67 65 2d 64 69 72 65 63     (change-direc
3da0: 74 6f 72 79 20 74 65 73 74 2d 70 61 74 68 29 0a  tory test-path).
3db0: 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69        (debug:pri
3dc0: 6e 74 20 34 20 22 72 75 6e 2d 69 64 3a 20 22 20  nt 4 "run-id: " 
3dd0: 72 75 6e 2d 69 64 20 22 20 74 65 73 74 2d 6e 61  run-id " test-na
3de0: 6d 65 3a 20 22 20 74 65 73 74 2d 6e 61 6d 65 20  me: " test-name 
3df0: 22 20 69 74 65 6d 2d 70 61 74 68 3a 20 22 20 69  " item-path: " i
3e00: 74 65 6d 2d 70 61 74 68 20 22 20 74 65 73 74 64  tem-path " testd
3e10: 61 74 3a 20 22 20 28 74 65 73 74 3a 67 65 74 2d  at: " (test:get-
3e20: 73 74 61 74 75 73 20 74 65 73 74 64 61 74 29 20  status testdat) 
3e30: 22 20 74 65 73 74 2d 73 74 61 74 65 3a 20 22 20  " test-state: " 
3e40: 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20  (test:get-state 
3e50: 74 65 73 74 64 61 74 29 29 0a 20 20 20 20 20 20  testdat)).      
3e60: 28 63 61 73 65 20 28 69 66 20 66 6f 72 63 65 20  (case (if force 
3e70: 3b 3b 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67  ;; (args:get-arg
3e80: 20 22 2d 66 6f 72 63 65 22 29 0a 09 09 27 4e 4f   "-force")...'NO
3e90: 54 5f 53 54 41 52 54 45 44 0a 09 09 28 69 66 20  T_STARTED...(if 
3ea0: 74 65 73 74 64 61 74 0a 09 09 20 20 20 20 28 73  testdat...    (s
3eb0: 74 72 69 6e 67 2d 3e 73 79 6d 62 6f 6c 20 28 74  tring->symbol (t
3ec0: 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65  est:get-state te
3ed0: 73 74 64 61 74 29 29 0a 09 09 20 20 20 20 27 66  stdat))...    'f
3ee0: 61 69 6c 65 64 2d 74 6f 2d 69 6e 73 65 72 74 29  ailed-to-insert)
3ef0: 29 0a 09 28 28 66 61 69 6c 65 64 2d 74 6f 2d 69  )..((failed-to-i
3f00: 6e 73 65 72 74 29 0a 09 20 28 64 65 62 75 67 3a  nsert).. (debug:
3f10: 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20  print 0 "ERROR: 
3f20: 46 61 69 6c 65 64 20 74 6f 20 69 6e 73 65 72 74  Failed to insert
3f30: 20 74 68 65 20 72 65 63 6f 72 64 20 69 6e 74 6f   the record into
3f40: 20 74 68 65 20 64 62 22 29 29 0a 09 28 28 4e 4f   the db"))..((NO
3f50: 54 5f 53 54 41 52 54 45 44 20 43 4f 4d 50 4c 45  T_STARTED COMPLE
3f60: 54 45 44 29 0a 09 20 28 64 65 62 75 67 3a 70 72  TED).. (debug:pr
3f70: 69 6e 74 20 36 20 22 47 6f 74 20 68 65 72 65 2c  int 6 "Got here,
3f80: 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61   " (test:get-sta
3f90: 74 65 20 74 65 73 74 64 61 74 29 29 0a 09 20 28  te testdat)).. (
3fa0: 6c 65 74 20 28 28 72 75 6e 66 6c 61 67 20 23 66  let ((runflag #f
3fb0: 29 29 0a 09 20 20 20 28 63 6f 6e 64 0a 09 20 20  ))..   (cond..  
3fc0: 20 20 3b 3b 20 2d 66 6f 72 63 65 2c 20 72 75 6e    ;; -force, run
3fd0: 20 6e 6f 20 6d 61 74 74 65 72 20 77 68 61 74 0a   no matter what.
3fe0: 09 20 20 20 20 28 66 6f 72 63 65 20 28 73 65 74  .    (force (set
3ff0: 21 20 72 75 6e 66 6c 61 67 20 23 74 29 29 0a 09  ! runflag #t))..
4000: 20 20 20 20 3b 3b 20 4e 4f 54 5f 53 54 41 52 54      ;; NOT_START
4010: 45 44 2c 20 72 75 6e 20 6e 6f 20 6d 61 74 74 65  ED, run no matte
4020: 72 20 77 68 61 74 0a 09 20 20 20 20 28 28 65 71  r what..    ((eq
4030: 75 61 6c 3f 20 28 74 65 73 74 3a 67 65 74 2d 73  ual? (test:get-s
4040: 74 61 74 65 20 74 65 73 74 64 61 74 29 20 22 4e  tate testdat) "N
4050: 4f 54 5f 53 54 41 52 54 45 44 22 29 28 73 65 74  OT_STARTED")(set
4060: 21 20 72 75 6e 66 6c 61 67 20 23 74 29 29 0a 09  ! runflag #t))..
4070: 20 20 20 20 3b 3b 20 6e 6f 74 20 2d 72 65 72 75      ;; not -reru
4080: 6e 20 61 6e 64 20 50 41 53 53 2c 20 57 41 52 4e  n and PASS, WARN
4090: 20 6f 72 20 43 48 45 43 4b 2c 20 64 6f 20 6e 6f   or CHECK, do no
40a0: 20 72 75 6e 0a 09 20 20 20 20 28 28 61 6e 64 20   run..    ((and 
40b0: 28 6f 72 20 28 6e 6f 74 20 72 65 72 75 6e 29 0a  (or (not rerun).
40c0: 09 09 20 20 20 20 20 20 6b 65 65 70 67 6f 69 6e  ..      keepgoin
40d0: 67 29 0a 09 09 20 20 28 6d 65 6d 62 65 72 20 28  g)...  (member (
40e0: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20  test:get-status 
40f0: 74 65 73 74 64 61 74 29 20 27 28 22 50 41 53 53  testdat) '("PASS
4100: 22 20 22 57 41 52 4e 22 20 22 43 48 45 43 4b 22  " "WARN" "CHECK"
4110: 29 29 29 0a 09 20 20 20 20 20 28 73 65 74 21 20  )))..     (set! 
4120: 72 75 6e 66 6c 61 67 20 23 66 29 29 0a 09 20 20  runflag #f))..  
4130: 20 20 3b 3b 20 2d 72 65 72 75 6e 20 61 6e 64 20    ;; -rerun and 
4140: 73 74 61 74 75 73 20 69 73 20 6f 6e 65 20 6f 66  status is one of
4150: 20 74 68 65 20 73 70 65 63 69 66 65 64 2c 20 72   the specifed, r
4160: 75 6e 20 69 74 0a 09 20 20 20 20 28 28 61 6e 64  un it..    ((and
4170: 20 72 65 72 75 6e 0a 09 09 20 20 28 6c 65 74 20   rerun...  (let 
4180: 28 28 72 65 72 75 6e 6c 73 74 20 28 73 74 72 69  ((rerunlst (stri
4190: 6e 67 2d 73 70 6c 69 74 20 72 65 72 75 6e 20 22  ng-split rerun "
41a0: 2c 22 29 29 29 20 3b 3b 20 46 41 49 4c 2c 0a 09  ,"))) ;; FAIL,..
41b0: 09 20 20 20 20 28 6d 65 6d 62 65 72 20 28 74 65  .    (member (te
41c0: 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65  st:get-status te
41d0: 73 74 64 61 74 29 20 72 65 72 75 6e 6c 73 74 29  stdat) rerunlst)
41e0: 29 29 0a 09 20 20 20 20 20 28 73 65 74 21 20 72  ))..     (set! r
41f0: 75 6e 66 6c 61 67 20 23 74 29 29 0a 09 20 20 20  unflag #t))..   
4200: 20 3b 3b 20 2d 6b 65 65 70 67 6f 69 6e 67 2c 20   ;; -keepgoing, 
4210: 64 6f 20 6e 6f 74 20 72 65 72 75 6e 20 46 41 49  do not rerun FAI
4220: 4c 0a 09 20 20 20 20 28 28 61 6e 64 20 6b 65 65  L..    ((and kee
4230: 70 67 6f 69 6e 67 0a 09 09 20 20 28 6d 65 6d 62  pgoing...  (memb
4240: 65 72 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61  er (test:get-sta
4250: 74 75 73 20 74 65 73 74 64 61 74 29 20 27 28 22  tus testdat) '("
4260: 46 41 49 4c 22 29 29 29 0a 09 20 20 20 20 20 28  FAIL")))..     (
4270: 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23 66 29  set! runflag #f)
4280: 29 0a 09 20 20 20 20 28 28 61 6e 64 20 28 6e 6f  )..    ((and (no
4290: 74 20 72 65 72 75 6e 29 0a 09 09 20 20 28 6d 65  t rerun)...  (me
42a0: 6d 62 65 72 20 28 74 65 73 74 3a 67 65 74 2d 73  mber (test:get-s
42b0: 74 61 74 75 73 20 74 65 73 74 64 61 74 29 20 27  tatus testdat) '
42c0: 28 22 46 41 49 4c 22 20 22 6e 2f 61 22 29 29 29  ("FAIL" "n/a")))
42d0: 0a 09 20 20 20 20 20 28 73 65 74 21 20 72 75 6e  ..     (set! run
42e0: 66 6c 61 67 20 23 74 29 29 0a 09 20 20 20 20 28  flag #t))..    (
42f0: 65 6c 73 65 20 28 73 65 74 21 20 72 75 6e 66 6c  else (set! runfl
4300: 61 67 20 23 66 29 29 29 0a 09 20 20 20 28 64 65  ag #f)))..   (de
4310: 62 75 67 3a 70 72 69 6e 74 20 36 20 22 52 55 4e  bug:print 6 "RUN
4320: 4e 49 4e 47 20 3d 3e 20 72 75 6e 66 6c 61 67 3a  NING => runflag:
4330: 20 22 20 72 75 6e 66 6c 61 67 20 22 20 53 54 41   " runflag " STA
4340: 54 45 3a 20 22 20 28 74 65 73 74 3a 67 65 74 2d  TE: " (test:get-
4350: 73 74 61 74 65 20 74 65 73 74 64 61 74 29 20 22  state testdat) "
4360: 20 53 54 41 54 55 53 3a 20 22 20 28 74 65 73 74   STATUS: " (test
4370: 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74  :get-status test
4380: 64 61 74 29 29 0a 09 20 20 20 28 69 66 20 28 6e  dat))..   (if (n
4390: 6f 74 20 72 75 6e 66 6c 61 67 29 0a 09 20 20 20  ot runflag)..   
43a0: 20 20 20 20 28 69 66 20 28 6e 6f 74 20 70 61 72      (if (not par
43b0: 65 6e 74 2d 74 65 73 74 29 0a 09 09 20 20 20 28  ent-test)...   (
43c0: 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 4e  debug:print 1 "N
43d0: 4f 54 45 3a 20 4e 6f 74 20 73 74 61 72 74 69 6e  OTE: Not startin
43e0: 67 20 74 65 73 74 20 22 20 6e 65 77 2d 74 65 73  g test " new-tes
43f0: 74 2d 6e 61 6d 65 20 22 20 61 73 20 69 74 20 69  t-name " as it i
4400: 73 20 73 74 61 74 65 20 5c 22 43 4f 4d 50 4c 45  s state \"COMPLE
4410: 54 45 44 5c 22 20 61 6e 64 20 73 74 61 74 75 73  TED\" and status
4420: 20 5c 22 22 20 28 74 65 73 74 3a 67 65 74 2d 73   \"" (test:get-s
4430: 74 61 74 75 73 20 74 65 73 74 64 61 74 29 20 22  tatus testdat) "
4440: 5c 22 2c 20 75 73 65 20 2d 66 6f 72 63 65 20 74  \", use -force t
4450: 6f 20 6f 76 65 72 72 69 64 65 22 29 29 0a 09 20  o override")).. 
4460: 20 20 20 20 20 20 28 6c 65 74 2a 20 28 28 67 65        (let* ((ge
4470: 74 2d 70 72 65 72 65 71 73 2d 63 6d 64 20 28 6c  t-prereqs-cmd (l
4480: 61 6d 62 64 61 20 28 29 0a 09 09 09 09 09 20 28  ambda ()...... (
4490: 64 62 2d 67 65 74 2d 70 72 65 72 65 71 73 2d 6e  db-get-prereqs-n
44a0: 6f 74 2d 6d 65 74 20 64 62 20 72 75 6e 2d 69 64  ot-met db run-id
44b0: 20 77 61 69 74 6f 6e 29 29 29 20 3b 3b 20 63 68   waiton))) ;; ch
44c0: 65 63 6b 20 62 65 66 6f 72 65 20 72 75 6e 6e 69  eck before runni
44d0: 6e 67 20 2e 2e 2e 2e 0a 09 09 20 20 20 20 20 20  ng .......      
44e0: 28 6c 61 75 6e 63 68 2d 63 6d 64 20 20 20 20 20  (launch-cmd     
44f0: 20 28 6c 61 6d 62 64 61 20 28 29 0a 09 09 09 09   (lambda ().....
4500: 09 20 28 6c 61 75 6e 63 68 2d 74 65 73 74 20 64  . (launch-test d
4510: 62 20 72 75 6e 2d 69 64 20 72 75 6e 6e 61 6d 65  b run-id runname
4520: 20 74 65 73 74 2d 63 6f 6e 66 20 6b 65 79 76 61   test-conf keyva
4530: 6c 6c 73 74 20 74 65 73 74 2d 6e 61 6d 65 20 74  llst test-name t
4540: 65 73 74 2d 70 61 74 68 20 69 74 65 6d 64 61 74  est-path itemdat
4550: 20 66 6c 61 67 73 29 29 29 0a 09 09 20 20 20 20   flags)))...    
4560: 20 20 28 74 65 73 74 72 75 6e 64 61 74 20 20 20    (testrundat   
4570: 20 20 20 28 6c 69 73 74 20 67 65 74 2d 70 72 65     (list get-pre
4580: 72 65 71 73 2d 63 6d 64 20 6c 61 75 6e 63 68 2d  reqs-cmd launch-
4590: 63 6d 64 29 29 29 0a 09 09 20 28 69 66 20 28 6f  cmd)))... (if (o
45a0: 72 20 66 6f 72 63 65 0a 09 09 09 20 28 6c 65 74  r force.... (let
45b0: 20 28 28 70 72 65 71 73 2d 6e 6f 74 2d 79 65 74   ((preqs-not-yet
45c0: 2d 6d 65 74 20 28 28 63 61 72 20 74 65 73 74 72  -met ((car testr
45d0: 75 6e 64 61 74 29 29 29 29 0a 09 09 09 20 20 20  undat))))....   
45e0: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22  (debug:print 2 "
45f0: 50 72 65 71 72 65 71 75 65 73 69 74 65 73 20 66  Preqrequesites f
4600: 6f 72 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22  or " test-name "
4610: 3a 20 22 20 70 72 65 71 73 2d 6e 6f 74 2d 79 65  : " preqs-not-ye
4620: 74 2d 6d 65 74 29 0a 09 09 09 20 20 20 28 6e 75  t-met)....   (nu
4630: 6c 6c 3f 20 70 72 65 71 73 2d 6e 6f 74 2d 79 65  ll? preqs-not-ye
4640: 74 2d 6d 65 74 29 29 29 20 3b 3b 20 61 72 65 20  t-met))) ;; are 
4650: 74 68 65 72 65 20 61 6e 79 20 74 65 73 74 73 20  there any tests 
4660: 74 68 61 74 20 6d 75 73 74 20 62 65 20 72 75 6e  that must be run
4670: 20 62 65 66 6f 72 65 20 74 68 69 73 20 6f 6e 65   before this one
4680: 2e 2e 2e 0a 09 09 20 20 20 20 20 28 69 66 20 28  ......     (if (
4690: 6e 6f 74 20 28 28 63 61 64 72 20 74 65 73 74 72  not ((cadr testr
46a0: 75 6e 64 61 74 29 29 29 20 3b 3b 20 74 68 69 73  undat))) ;; this
46b0: 20 69 73 20 74 68 65 20 6c 69 6e 65 20 74 68 61   is the line tha
46c0: 74 20 6c 61 75 6e 63 68 65 73 20 74 68 65 20 74  t launches the t
46d0: 65 73 74 20 74 6f 20 74 68 65 20 72 65 6d 6f 74  est to the remot
46e0: 65 20 68 6f 73 74 0a 09 09 09 20 28 62 65 67 69  e host.... (begi
46f0: 6e 0a 09 09 09 20 20 20 28 70 72 69 6e 74 20 22  n....   (print "
4700: 45 52 52 4f 52 3a 20 46 61 69 6c 65 64 20 74 6f  ERROR: Failed to
4710: 20 6c 61 75 6e 63 68 20 74 68 65 20 74 65 73 74   launch the test
4720: 2e 20 45 78 69 74 69 6e 67 20 61 73 20 73 6f 6f  . Exiting as soo
4730: 6e 20 61 73 20 70 6f 73 73 69 62 6c 65 22 29 0a  n as possible").
4740: 09 09 09 20 20 20 28 73 65 74 21 20 2a 67 6c 6f  ...   (set! *glo
4750: 62 61 6c 65 78 69 74 73 74 61 74 75 73 2a 20 31  balexitstatus* 1
4760: 29 20 3b 3b 20 0a 09 09 09 20 20 20 28 70 72 6f  ) ;; ....   (pro
4770: 63 65 73 73 2d 73 69 67 6e 61 6c 20 28 63 75 72  cess-signal (cur
4780: 72 65 6e 74 2d 70 72 6f 63 65 73 73 2d 69 64 29  rent-process-id)
4790: 20 73 69 67 6e 61 6c 2f 6b 69 6c 6c 29 0a 09 09   signal/kill)...
47a0: 09 09 09 3b 28 65 78 69 74 20 31 29 0a 09 09 09  ...;(exit 1)....
47b0: 20 20 20 29 29 0a 09 09 20 20 20 20 20 28 69 66     ))...     (if
47c0: 20 28 6e 6f 74 20 6b 65 65 70 67 6f 69 6e 67 29   (not keepgoing)
47d0: 0a 09 09 09 20 28 68 61 73 68 2d 74 61 62 6c 65  .... (hash-table
47e0: 2d 73 65 74 21 20 2a 77 61 69 74 69 6e 67 2d 71  -set! *waiting-q
47f0: 75 65 75 65 2a 20 6e 65 77 2d 74 65 73 74 2d 6e  ueue* new-test-n
4800: 61 6d 65 20 74 65 73 74 72 75 6e 64 61 74 29 29  ame testrundat))
4810: 29 29 29 29 29 0a 09 28 28 4b 49 4c 4c 45 44 29  )))))..((KILLED)
4820: 20 0a 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74   .. (debug:print
4830: 20 31 20 22 4e 4f 54 45 3a 20 22 20 6e 65 77 2d   1 "NOTE: " new-
4840: 74 65 73 74 2d 6e 61 6d 65 20 22 20 69 73 20 61  test-name " is a
4850: 6c 72 65 61 64 79 20 72 75 6e 6e 69 6e 67 20 6f  lready running o
4860: 72 20 77 61 73 20 65 78 70 6c 69 63 74 6c 79 20  r was explictly 
4870: 6b 69 6c 6c 65 64 2c 20 75 73 65 20 2d 66 6f 72  killed, use -for
4880: 63 65 20 74 6f 20 6c 61 75 6e 63 68 20 69 74 2e  ce to launch it.
4890: 22 29 29 0a 09 28 28 4c 41 55 4e 43 48 45 44 20  "))..((LAUNCHED 
48a0: 52 45 4d 4f 54 45 48 4f 53 54 53 54 41 52 54 20  REMOTEHOSTSTART 
48b0: 52 55 4e 4e 49 4e 47 29 20 20 0a 09 20 28 69 66  RUNNING)  .. (if
48c0: 20 28 3e 20 28 2d 20 28 63 75 72 72 65 6e 74 2d   (> (- (current-
48d0: 73 65 63 6f 6e 64 73 29 28 2b 20 28 64 62 3a 74  seconds)(+ (db:t
48e0: 65 73 74 2d 67 65 74 2d 65 76 65 6e 74 5f 74 69  est-get-event_ti
48f0: 6d 65 20 74 65 73 74 64 61 74 29 0a 09 09 09 09  me testdat).....
4900: 20 20 20 20 20 20 20 28 64 62 3a 74 65 73 74 2d         (db:test-
4910: 67 65 74 2d 72 75 6e 5f 64 75 72 61 74 69 6f 6e  get-run_duration
4920: 20 74 65 73 74 64 61 74 29 29 29 0a 09 09 36 30   testdat)))...60
4930: 30 29 20 3b 3b 20 69 2e 65 2e 20 6e 6f 20 75 70  0) ;; i.e. no up
4940: 64 61 74 65 20 66 6f 72 20 6d 6f 72 65 20 74 68  date for more th
4950: 61 6e 20 36 30 30 20 73 65 63 6f 6e 64 73 0a 09  an 600 seconds..
4960: 20 20 20 20 20 28 62 65 67 69 6e 0a 09 20 20 20       (begin..   
4970: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
4980: 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 54 65 73   0 "WARNING: Tes
4990: 74 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20  t " test-name " 
49a0: 61 70 70 65 61 72 73 20 74 6f 20 62 65 20 64 65  appears to be de
49b0: 61 64 2e 20 46 6f 72 63 69 6e 67 20 69 74 20 74  ad. Forcing it t
49c0: 6f 20 73 74 61 74 65 20 49 4e 43 4f 4d 50 4c 45  o state INCOMPLE
49d0: 54 45 20 61 6e 64 20 73 74 61 74 75 73 20 53 54  TE and status ST
49e0: 55 43 4b 2f 44 45 41 44 22 29 0a 09 20 20 20 20  UCK/DEAD")..    
49f0: 20 20 20 28 74 65 73 74 2d 73 65 74 2d 73 74 61     (test-set-sta
4a00: 74 75 73 21 20 64 62 20 72 75 6e 2d 69 64 20 74  tus! db run-id t
4a10: 65 73 74 2d 6e 61 6d 65 20 22 49 4e 43 4f 4d 50  est-name "INCOMP
4a20: 4c 45 54 45 22 20 22 53 54 55 43 4b 2f 44 45 41  LETE" "STUCK/DEA
4a30: 44 22 20 69 74 65 6d 64 61 74 20 22 54 65 73 74  D" itemdat "Test
4a40: 20 69 73 20 73 74 75 63 6b 20 6f 72 20 64 65 61   is stuck or dea
4a50: 64 22 20 23 66 29 29 0a 09 20 20 20 20 20 28 64  d" #f))..     (d
4a60: 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 4e 4f  ebug:print 2 "NO
4a70: 54 45 3a 20 22 20 74 65 73 74 2d 6e 61 6d 65 20  TE: " test-name 
4a80: 22 20 69 73 20 61 6c 72 65 61 64 79 20 72 75 6e  " is already run
4a90: 6e 69 6e 67 22 29 29 29 0a 09 28 65 6c 73 65 20  ning")))..(else 
4aa0: 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69        (debug:pri
4ab0: 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 46 61 69  nt 0 "ERROR: Fai
4ac0: 6c 65 64 20 74 6f 20 6c 61 75 6e 63 68 20 74 65  led to launch te
4ad0: 73 74 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61  st " new-test-na
4ae0: 6d 65 20 22 2e 20 55 6e 72 65 63 6f 67 6e 69 73  me ". Unrecognis
4af0: 65 64 20 73 74 61 74 65 20 22 20 28 74 65 73 74  ed state " (test
4b00: 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64  :get-state testd
4b10: 61 74 29 29 29 29 29 29 29 0a 0a 3b 3b 3d 3d 3d  at)))))))..;;===
4b20: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
4b30: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
4b40: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
4b50: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
4b60: 3d 3d 3d 0a 3b 3b 20 45 4e 44 20 4f 46 20 4e 45  ===.;; END OF NE
4b70: 57 20 53 54 55 46 46 0a 3b 3b 3d 3d 3d 3d 3d 3d  W STUFF.;;======
4b80: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
4b90: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
4ba0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
4bb0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
4bc0: 0a 0a 28 64 65 66 69 6e 65 20 28 67 65 74 2d 64  ..(define (get-d
4bd0: 69 72 2d 75 70 2d 6e 20 64 69 72 20 2e 20 70 61  ir-up-n dir . pa
4be0: 72 61 6d 73 29 20 0a 20 20 28 6c 65 74 20 28 28  rams) .  (let ((
4bf0: 64 70 61 72 74 73 20 20 28 73 74 72 69 6e 67 2d  dparts  (string-
4c00: 73 70 6c 69 74 20 64 69 72 20 22 2f 22 29 29 0a  split dir "/")).
4c10: 09 28 63 6f 75 6e 74 20 20 20 28 69 66 20 28 6e  .(count   (if (n
4c20: 75 6c 6c 3f 20 70 61 72 61 6d 73 29 20 31 20 28  ull? params) 1 (
4c30: 63 61 72 20 70 61 72 61 6d 73 29 29 29 29 0a 20  car params)))). 
4c40: 20 20 20 28 63 6f 6e 63 20 22 2f 22 20 28 73 74     (conc "/" (st
4c50: 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65  ring-intersperse
4c60: 20 0a 09 20 20 20 20 20 20 20 28 74 61 6b 65 20   ..       (take 
4c70: 64 70 61 72 74 73 20 28 2d 20 28 6c 65 6e 67 74  dparts (- (lengt
4c80: 68 20 64 70 61 72 74 73 29 20 63 6f 75 6e 74 29  h dparts) count)
4c90: 29 0a 09 20 20 20 20 20 20 20 22 2f 22 29 29 29  )..       "/")))
4ca0: 29 0a 3b 3b 20 52 65 6d 6f 76 65 20 72 75 6e 73  ).;; Remove runs
4cb0: 0a 3b 3b 20 66 69 65 6c 64 73 20 61 72 65 20 70  .;; fields are p
4cc0: 61 73 73 69 6e 67 20 69 6e 20 74 68 72 6f 75 67  assing in throug
4cd0: 68 20 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73  h .(define (runs
4ce0: 3a 72 65 6d 6f 76 65 2d 72 75 6e 73 20 64 62 20  :remove-runs db 
4cf0: 72 75 6e 6e 61 6d 65 70 61 74 74 20 74 65 73 74  runnamepatt test
4d00: 70 61 74 74 20 69 74 65 6d 70 61 74 74 29 0a 20  patt itempatt). 
4d10: 20 28 6c 65 74 2a 20 28 28 6b 65 79 73 20 20 20   (let* ((keys   
4d20: 20 20 20 20 20 28 64 62 2d 67 65 74 2d 6b 65 79       (db-get-key
4d30: 73 20 64 62 29 29 0a 09 20 28 72 75 6e 64 61 74  s db)).. (rundat
4d40: 20 20 20 20 20 20 28 72 75 6e 73 3a 67 65 74 2d        (runs:get-
4d50: 72 75 6e 73 2d 62 79 2d 70 61 74 74 20 64 62 20  runs-by-patt db 
4d60: 6b 65 79 73 20 72 75 6e 6e 61 6d 65 70 61 74 74  keys runnamepatt
4d70: 29 29 0a 09 20 28 68 65 61 64 65 72 20 20 20 20  )).. (header    
4d80: 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20 72 75    (vector-ref ru
4d90: 6e 64 61 74 20 30 29 29 0a 09 20 28 72 75 6e 73  ndat 0)).. (runs
4da0: 20 20 20 20 20 20 20 20 28 76 65 63 74 6f 72 2d          (vector-
4db0: 72 65 66 20 72 75 6e 64 61 74 20 31 29 29 29 0a  ref rundat 1))).
4dc0: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
4dd0: 20 31 20 22 48 65 61 64 65 72 3a 20 22 20 68 65   1 "Header: " he
4de0: 61 64 65 72 29 0a 20 20 20 20 28 66 6f 72 2d 65  ader).    (for-e
4df0: 61 63 68 0a 20 20 20 20 20 28 6c 61 6d 62 64 61  ach.     (lambda
4e00: 20 28 72 75 6e 29 0a 20 20 20 20 20 20 20 28 6c   (run).       (l
4e10: 65 74 20 28 28 72 75 6e 6b 65 79 20 28 73 74 72  et ((runkey (str
4e20: 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20  ing-intersperse 
4e30: 28 6d 61 70 20 28 6c 61 6d 62 64 61 20 28 6b 29  (map (lambda (k)
4e40: 0a 09 09 09 09 09 09 28 64 62 3a 67 65 74 2d 76  .......(db:get-v
4e50: 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72  alue-by-header r
4e60: 75 6e 20 68 65 61 64 65 72 20 28 76 65 63 74 6f  un header (vecto
4e70: 72 2d 72 65 66 20 6b 20 30 29 29 29 20 6b 65 79  r-ref k 0))) key
4e80: 73 29 20 22 2f 22 29 29 0a 09 20 20 20 20 20 28  s) "/"))..     (
4e90: 64 69 72 73 2d 74 6f 2d 72 65 6d 6f 76 65 20 28  dirs-to-remove (
4ea0: 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 29  make-hash-table)
4eb0: 29 29 0a 09 20 28 6c 65 74 2a 20 28 28 72 75 6e  )).. (let* ((run
4ec0: 2d 69 64 20 28 64 62 3a 67 65 74 2d 76 61 6c 75  -id (db:get-valu
4ed0: 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20  e-by-header run 
4ee0: 68 65 61 64 65 72 20 22 69 64 22 29 20 29 0a 09  header "id") )..
4ef0: 09 28 74 65 73 74 73 20 20 28 64 62 2d 67 65 74  .(tests  (db-get
4f00: 2d 74 65 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64  -tests-for-run d
4f10: 62 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d  b (db:get-value-
4f20: 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65  by-header run he
4f30: 61 64 65 72 20 22 69 64 22 29 20 74 65 73 74 70  ader "id") testp
4f40: 61 74 74 20 69 74 65 6d 70 61 74 74 20 27 28 29  att itempatt '()
4f50: 20 27 28 29 29 29 0a 09 09 28 6c 61 73 74 74 70   '()))...(lasttp
4f60: 61 74 68 20 22 2f 64 6f 65 73 2f 6e 6f 74 2f 65  ath "/does/not/e
4f70: 78 69 73 74 2f 49 2f 68 6f 70 65 22 29 29 0a 0a  xist/I/hope"))..
4f80: 09 20 20 20 28 69 66 20 28 6e 6f 74 20 28 6e 75  .   (if (not (nu
4f90: 6c 6c 3f 20 74 65 73 74 73 29 29 0a 09 20 20 20  ll? tests))..   
4fa0: 20 20 20 20 28 62 65 67 69 6e 0a 09 09 20 28 64      (begin... (d
4fb0: 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 52 65  ebug:print 1 "Re
4fc0: 6d 6f 76 69 6e 67 20 74 65 73 74 73 20 66 6f 72  moving tests for
4fd0: 20 72 75 6e 3a 20 22 20 72 75 6e 6b 65 79 20 22   run: " runkey "
4fe0: 20 22 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65   " (db:get-value
4ff0: 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68  -by-header run h
5000: 65 61 64 65 72 20 22 72 75 6e 6e 61 6d 65 22 29  eader "runname")
5010: 29 0a 09 09 20 28 66 6f 72 2d 65 61 63 68 0a 09  )... (for-each..
5020: 09 20 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74  .  (lambda (test
5030: 29 0a 09 09 20 20 20 20 28 6c 65 74 2a 20 28 28  )...    (let* ((
5040: 69 74 65 6d 2d 70 61 74 68 20 28 64 62 3a 74 65  item-path (db:te
5050: 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68  st-get-item-path
5060: 20 74 65 73 74 29 29 0a 09 09 09 20 20 20 28 74   test))....   (t
5070: 65 73 74 2d 6e 61 6d 65 20 28 64 62 3a 74 65 73  est-name (db:tes
5080: 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 74  t-get-testname t
5090: 65 73 74 29 29 0a 09 09 09 20 20 20 28 72 75 6e  est))....   (run
50a0: 2d 64 69 72 20 20 20 28 64 62 3a 74 65 73 74 2d  -dir   (db:test-
50b0: 67 65 74 2d 72 75 6e 64 69 72 20 74 65 73 74 29  get-rundir test)
50c0: 29 29 0a 09 09 20 20 20 20 20 20 28 64 65 62 75  ))...      (debu
50d0: 67 3a 70 72 69 6e 74 20 31 20 22 20 20 22 20 28  g:print 1 "  " (
50e0: 64 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74  db:test-get-test
50f0: 6e 61 6d 65 20 74 65 73 74 29 20 22 20 69 64 3a  name test) " id:
5100: 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d   " (db:test-get-
5110: 69 64 20 74 65 73 74 29 20 22 20 22 20 69 74 65  id test) " " ite
5120: 6d 2d 70 61 74 68 29 0a 09 09 20 20 20 20 20 20  m-path)...      
5130: 28 64 62 3a 64 65 6c 65 74 65 2d 74 65 73 74 2d  (db:delete-test-
5140: 72 65 63 6f 72 64 73 20 64 62 20 28 64 62 3a 74  records db (db:t
5150: 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74 29  est-get-id test)
5160: 29 0a 09 09 20 20 20 20 20 20 28 69 66 20 28 3e  )...      (if (>
5170: 20 28 73 74 72 69 6e 67 2d 6c 65 6e 67 74 68 20   (string-length 
5180: 72 75 6e 2d 64 69 72 29 20 35 29 20 3b 3b 20 62  run-dir) 5) ;; b
5190: 61 64 20 68 65 75 72 69 73 74 69 63 20 62 75 74  ad heuristic but
51a0: 20 73 68 6f 75 6c 64 20 70 72 65 76 65 6e 74 20   should prevent 
51b0: 2f 74 6d 70 20 2f 68 6f 6d 65 20 65 74 63 2e 0a  /tmp /home etc..
51c0: 09 09 09 20 20 28 6c 65 74 20 28 28 66 75 6c 6c  ...  (let ((full
51d0: 70 61 74 68 20 72 75 6e 2d 64 69 72 29 29 20 3b  path run-dir)) ;
51e0: 3b 20 22 2f 22 20 28 64 62 3a 74 65 73 74 2d 67  ; "/" (db:test-g
51f0: 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73  et-item-path tes
5200: 74 29 29 29 29 0a 09 09 09 20 20 20 20 28 73 65  t))))....    (se
5210: 74 21 20 6c 61 73 74 74 70 61 74 68 20 66 75 6c  t! lasttpath ful
5220: 6c 70 61 74 68 29 0a 09 09 09 20 20 20 20 28 68  lpath)....    (h
5230: 61 73 68 2d 74 61 62 6c 65 2d 73 65 74 21 20 64  ash-table-set! d
5240: 69 72 73 2d 74 6f 2d 72 65 6d 6f 76 65 20 66 75  irs-to-remove fu
5250: 6c 6c 70 61 74 68 20 23 74 29 0a 09 09 09 20 20  llpath #t)....  
5260: 20 20 3b 3b 20 54 68 65 20 66 6f 6c 6c 6f 77 69    ;; The followi
5270: 6e 67 20 77 61 73 20 74 68 65 20 73 61 66 65 20  ng was the safe 
5280: 64 65 6c 65 74 65 20 63 6f 64 65 20 62 75 74 20  delete code but 
5290: 69 74 20 77 61 73 20 6e 6f 74 20 62 65 69 6e 67  it was not being
52a0: 20 65 78 65 63 74 75 74 65 64 2e 0a 09 09 09 20   exectuted..... 
52b0: 20 20 20 3b 3b 20 28 6c 65 74 2a 20 28 28 64 69     ;; (let* ((di
52c0: 72 73 2d 63 6f 75 6e 74 20 28 2b 20 31 20 28 6c  rs-count (+ 1 (l
52d0: 65 6e 67 74 68 20 6b 65 79 73 29 28 6c 65 6e 67  ength keys)(leng
52e0: 74 68 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74  th (string-split
52f0: 20 69 74 65 6d 2d 70 61 74 68 20 22 2f 22 29 29   item-path "/"))
5300: 29 29 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 20  ))....    ;;    
5310: 20 20 20 20 28 64 69 72 2d 74 6f 2d 72 65 6d 20      (dir-to-rem 
5320: 28 67 65 74 2d 64 69 72 2d 75 70 2d 6e 20 66 75  (get-dir-up-n fu
5330: 6c 6c 70 61 74 68 20 64 69 72 73 2d 63 6f 75 6e  llpath dirs-coun
5340: 74 29 29 0a 09 09 09 20 20 20 20 3b 3b 20 20 20  t))....    ;;   
5350: 20 20 20 20 20 28 72 65 6d 61 69 6e 69 6e 67 64       (remainingd
5360: 20 28 73 74 72 69 6e 67 2d 73 75 62 73 74 69 74   (string-substit
5370: 75 74 65 20 28 72 65 67 65 78 70 20 28 63 6f 6e  ute (regexp (con
5380: 63 20 22 5e 22 20 64 69 72 2d 74 6f 2d 72 65 6d  c "^" dir-to-rem
5390: 20 22 2f 22 29 29 20 22 22 20 66 75 6c 6c 70 61   "/")) "" fullpa
53a0: 74 68 29 29 0a 09 09 09 20 20 20 20 3b 3b 20 20  th))....    ;;  
53b0: 20 20 20 20 20 20 28 63 6d 64 20 28 63 6f 6e 63        (cmd (conc
53c0: 20 22 63 64 20 22 20 64 69 72 2d 74 6f 2d 72 65   "cd " dir-to-re
53d0: 6d 20 22 3b 20 72 6d 64 69 72 20 2d 70 20 22 20  m "; rmdir -p " 
53e0: 72 65 6d 61 69 6e 69 6e 67 64 20 29 29 29 0a 09  remainingd )))..
53f0: 09 09 20 20 20 20 3b 3b 20 20 20 28 69 66 20 28  ..    ;;   (if (
5400: 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 66 75 6c  file-exists? ful
5410: 6c 70 61 74 68 29 0a 09 09 09 20 20 20 20 3b 3b  lpath)....    ;;
5420: 20 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09         (begin...
5430: 09 20 20 20 20 3b 3b 20 20 20 20 20 20 20 20 20  .    ;;         
5440: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 63  (debug:print 1 c
5450: 6d 64 29 0a 09 09 09 20 20 20 20 3b 3b 20 20 20  md)....    ;;   
5460: 20 20 20 20 20 20 28 73 79 73 74 65 6d 20 63 6d        (system cm
5470: 64 29 29 29 0a 09 09 09 20 20 20 20 3b 3b 20 20  d)))....    ;;  
5480: 20 29 29 0a 09 09 09 20 20 20 20 29 29 29 29 0a   ))....    )))).
5490: 09 09 20 20 20 20 74 65 73 74 73 29 29 29 0a 0a  ..    tests)))..
54a0: 09 20 20 20 3b 3b 20 6c 6f 6f 6b 20 74 68 6f 75  .   ;; look thou
54b0: 67 68 20 74 68 65 20 64 69 72 73 2d 74 6f 2d 72  gh the dirs-to-r
54c0: 65 6d 6f 76 65 20 66 6f 72 20 63 61 6e 64 69 64  emove for candid
54d0: 61 74 65 73 20 66 6f 72 20 72 65 6d 6f 76 61 6c  ates for removal
54e0: 2e 20 44 6f 20 74 68 69 73 20 61 66 74 65 72 20  . Do this after 
54f0: 64 65 6c 65 74 69 6e 67 20 74 68 65 20 72 65 63  deleting the rec
5500: 6f 72 64 73 0a 09 20 20 20 3b 3b 20 66 6f 72 20  ords..   ;; for 
5510: 65 61 63 68 20 74 65 73 74 20 69 6e 20 63 61 73  each test in cas
5520: 65 20 77 65 20 67 65 74 20 6b 69 6c 6c 65 64 2e  e we get killed.
5530: 20 54 68 61 74 20 73 68 6f 75 6c 64 20 6d 69 6e   That should min
5540: 69 6d 69 7a 65 20 74 68 65 20 64 65 74 72 69 74  imize the detrit
5550: 75 73 20 6c 65 66 74 20 6f 6e 20 64 69 73 6b 0a  us left on disk.
5560: 09 20 20 20 3b 3b 20 70 72 6f 63 65 73 73 20 74  .   ;; process t
5570: 68 65 20 64 69 72 73 20 66 72 6f 6d 20 6c 6f 6e  he dirs from lon
5580: 67 65 73 74 20 73 74 72 69 6e 67 20 6c 65 6e 67  gest string leng
5590: 74 68 20 74 6f 20 73 68 6f 72 74 65 73 74 0a 09  th to shortest..
55a0: 20 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 09 20     (for-each .. 
55b0: 20 20 20 28 6c 61 6d 62 64 61 20 28 64 69 72 2d     (lambda (dir-
55c0: 74 6f 2d 72 65 6d 6f 76 65 29 0a 09 20 20 20 20  to-remove)..    
55d0: 20 20 28 69 66 20 28 66 69 6c 65 2d 65 78 69 73    (if (file-exis
55e0: 74 73 3f 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76  ts? dir-to-remov
55f0: 65 29 0a 09 09 20 20 28 6c 65 74 20 28 28 64 69  e)...  (let ((di
5600: 72 2d 69 6e 2d 64 62 20 27 28 29 29 29 0a 09 09  r-in-db '()))...
5610: 20 20 20 20 28 73 71 6c 69 74 65 33 3a 66 6f 72      (sqlite3:for
5620: 2d 65 61 63 68 2d 72 6f 77 0a 09 09 20 20 20 20  -each-row...    
5630: 20 28 6c 61 6d 62 64 61 20 28 64 69 72 29 0a 09   (lambda (dir)..
5640: 09 20 20 20 20 20 20 20 28 73 65 74 21 20 64 69  .       (set! di
5650: 72 2d 69 6e 2d 64 62 20 28 63 6f 6e 73 20 64 69  r-in-db (cons di
5660: 72 20 64 69 72 2d 69 6e 2d 64 62 29 29 29 0a 09  r dir-in-db)))..
5670: 09 20 20 20 20 20 64 62 20 22 53 45 4c 45 43 54  .     db "SELECT
5680: 20 72 75 6e 64 69 72 20 46 52 4f 4d 20 74 65 73   rundir FROM tes
5690: 74 73 20 57 48 45 52 45 20 72 75 6e 64 69 72 20  ts WHERE rundir 
56a0: 4c 49 4b 45 20 3f 3b 22 20 0a 09 09 20 20 20 20  LIKE ?;" ...    
56b0: 20 28 63 6f 6e 63 20 22 25 22 20 64 69 72 2d 74   (conc "%" dir-t
56c0: 6f 2d 72 65 6d 6f 76 65 20 22 25 22 29 29 20 3b  o-remove "%")) ;
56d0: 3b 20 79 65 73 2c 20 49 27 6d 20 67 6f 69 6e 67  ; yes, I'm going
56e0: 20 74 6f 20 62 61 69 6c 20 69 66 20 74 68 65 72   to bail if ther
56f0: 65 20 69 73 20 61 6e 79 74 68 69 6e 67 20 6c 69  e is anything li
5700: 6b 65 20 74 68 69 73 20 64 69 72 20 69 6e 20 74  ke this dir in t
5710: 68 65 20 64 62 0a 09 09 20 20 20 20 28 69 66 20  he db...    (if 
5720: 28 6e 75 6c 6c 3f 20 64 69 72 2d 69 6e 2d 64 62  (null? dir-in-db
5730: 29 0a 09 09 09 28 62 65 67 69 6e 0a 09 09 09 20  )....(begin.... 
5740: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20   (debug:print 2 
5750: 22 52 65 6d 6f 76 69 6e 67 20 64 69 72 65 63 74  "Removing direct
5760: 6f 72 79 20 77 69 74 68 20 7a 65 72 6f 20 64 62  ory with zero db
5770: 20 72 65 66 65 72 65 6e 63 65 73 3a 20 22 20 64   references: " d
5780: 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 0a 09 09  ir-to-remove)...
5790: 09 20 20 28 73 79 73 74 65 6d 20 28 63 6f 6e 63  .  (system (conc
57a0: 20 22 72 6d 20 2d 72 66 20 22 20 64 69 72 2d 74   "rm -rf " dir-t
57b0: 6f 2d 72 65 6d 6f 76 65 29 29 0a 09 09 09 20 20  o-remove))....  
57c0: 28 68 61 73 68 2d 74 61 62 6c 65 2d 64 65 6c 65  (hash-table-dele
57d0: 74 65 21 20 64 69 72 73 2d 74 6f 2d 72 65 6d 6f  te! dirs-to-remo
57e0: 76 65 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65  ve dir-to-remove
57f0: 29 29 0a 09 09 09 28 64 65 62 75 67 3a 70 72 69  ))....(debug:pri
5800: 6e 74 20 32 20 22 53 6b 69 70 70 69 6e 67 20 72  nt 2 "Skipping r
5810: 65 6d 6f 76 61 6c 20 6f 66 20 22 20 64 69 72 2d  emoval of " dir-
5820: 74 6f 2d 72 65 6d 6f 76 65 20 22 20 66 6f 72 20  to-remove " for 
5830: 6e 6f 77 20 61 73 20 69 74 20 73 74 69 6c 6c 20  now as it still 
5840: 68 61 73 20 72 65 66 65 72 65 6e 63 65 73 20 69  has references i
5850: 6e 20 74 68 65 20 64 61 74 61 62 61 73 65 22 29  n the database")
5860: 29 29 29 29 0a 09 20 20 20 20 28 73 6f 72 74 20  ))))..    (sort 
5870: 28 68 61 73 68 2d 74 61 62 6c 65 2d 6b 65 79 73  (hash-table-keys
5880: 20 64 69 72 73 2d 74 6f 2d 72 65 6d 6f 76 65 29   dirs-to-remove)
5890: 20 28 6c 61 6d 62 64 61 20 28 61 20 62 29 28 3e   (lambda (a b)(>
58a0: 20 28 73 74 72 69 6e 67 2d 6c 65 6e 67 74 68 20   (string-length 
58b0: 61 29 28 73 74 72 69 6e 67 2d 6c 65 6e 67 74 68  a)(string-length
58c0: 20 62 29 29 29 29 29 0a 0a 09 20 20 20 3b 3b 20   b)))))...   ;; 
58d0: 72 65 6d 6f 76 65 20 74 68 65 20 72 75 6e 20 69  remove the run i
58e0: 66 20 7a 65 72 6f 20 74 65 73 74 73 20 72 65 6d  f zero tests rem
58f0: 61 69 6e 0a 09 20 20 20 28 6c 65 74 20 28 28 72  ain..   (let ((r
5900: 65 6d 74 65 73 74 73 20 28 64 62 2d 67 65 74 2d  emtests (db-get-
5910: 74 65 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62  tests-for-run db
5920: 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62   (db:get-value-b
5930: 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61  y-header run hea
5940: 64 65 72 20 22 69 64 22 29 20 23 66 20 23 66 20  der "id") #f #f 
5950: 27 28 29 20 27 28 29 29 29 29 0a 09 20 20 20 20  '() '())))..    
5960: 20 28 69 66 20 28 6e 75 6c 6c 3f 20 72 65 6d 74   (if (null? remt
5970: 65 73 74 73 29 20 3b 3b 20 6e 6f 20 6d 6f 72 65  ests) ;; no more
5980: 20 74 65 73 74 73 20 72 65 6d 61 69 6e 69 6e 67   tests remaining
5990: 0a 09 09 20 28 6c 65 74 2a 20 28 28 64 70 61 72  ... (let* ((dpar
59a0: 74 73 20 20 28 73 74 72 69 6e 67 2d 73 70 6c 69  ts  (string-spli
59b0: 74 20 6c 61 73 74 74 70 61 74 68 20 22 2f 22 29  t lasttpath "/")
59c0: 29 0a 09 09 09 28 72 75 6e 70 61 74 68 20 28 63  )....(runpath (c
59d0: 6f 6e 63 20 22 2f 22 20 28 73 74 72 69 6e 67 2d  onc "/" (string-
59e0: 69 6e 74 65 72 73 70 65 72 73 65 20 0a 09 09 09  intersperse ....
59f0: 09 09 20 20 20 20 28 74 61 6b 65 20 64 70 61 72  ..    (take dpar
5a00: 74 73 20 28 2d 20 28 6c 65 6e 67 74 68 20 64 70  ts (- (length dp
5a10: 61 72 74 73 29 20 31 29 29 0a 09 09 09 09 09 20  arts) 1))...... 
5a20: 20 20 20 22 2f 22 29 29 29 29 0a 09 09 20 20 20     "/"))))...   
5a30: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22  (debug:print 1 "
5a40: 52 65 6d 6f 76 69 6e 67 20 72 75 6e 3a 20 22 20  Removing run: " 
5a50: 72 75 6e 6b 65 79 20 22 20 22 20 28 64 62 3a 67  runkey " " (db:g
5a60: 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64  et-value-by-head
5a70: 65 72 20 72 75 6e 20 68 65 61 64 65 72 20 22 72  er run header "r
5a80: 75 6e 6e 61 6d 65 22 29 29 0a 09 09 20 20 20 28  unname"))...   (
5a90: 64 62 3a 64 65 6c 65 74 65 2d 72 75 6e 20 64 62  db:delete-run db
5aa0: 20 72 75 6e 2d 69 64 29 0a 09 09 20 20 20 3b 3b   run-id)...   ;;
5ab0: 20 6e 65 65 64 20 74 6f 20 66 69 67 75 72 65 20   need to figure 
5ac0: 6f 75 74 20 74 68 65 20 70 61 74 68 20 74 6f 20  out the path to 
5ad0: 74 68 65 20 72 75 6e 20 64 69 72 20 61 6e 64 20  the run dir and 
5ae0: 72 65 6d 6f 76 65 20 69 74 20 69 66 20 65 6d 70  remove it if emp
5af0: 74 79 0a 09 09 20 20 20 3b 3b 20 20 20 20 28 69  ty...   ;;    (i
5b00: 66 20 28 6e 75 6c 6c 3f 20 28 67 6c 6f 62 20 28  f (null? (glob (
5b10: 63 6f 6e 63 20 72 75 6e 70 61 74 68 20 22 2f 2a  conc runpath "/*
5b20: 22 29 29 29 0a 09 09 20 20 20 3b 3b 20 20 20 20  ")))...   ;;    
5b30: 20 20 20 20 28 62 65 67 69 6e 0a 09 09 20 20 20      (begin...   
5b40: 3b 3b 20 09 20 28 64 65 62 75 67 3a 70 72 69 6e  ;; . (debug:prin
5b50: 74 20 31 20 22 52 65 6d 6f 76 69 6e 67 20 72 75  t 1 "Removing ru
5b60: 6e 20 64 69 72 20 22 20 72 75 6e 70 61 74 68 29  n dir " runpath)
5b70: 0a 09 09 20 20 20 3b 3b 20 09 20 28 73 79 73 74  ...   ;; . (syst
5b80: 65 6d 20 28 63 6f 6e 63 20 22 72 6d 64 69 72 20  em (conc "rmdir 
5b90: 2d 70 20 22 20 72 75 6e 70 61 74 68 29 29 29 29  -p " runpath))))
5ba0: 0a 09 09 20 20 20 29 29 29 29 0a 09 20 29 29 0a  ...   )))).. )).
5bb0: 20 20 20 20 20 72 75 6e 73 29 29 29 0a 0a 3b 3b       runs)))..;;
5bc0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5bd0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5be0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5bf0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5c00: 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 52 6f 75 74 69 6e  ======.;; Routin
5c10: 65 73 20 66 6f 72 20 6d 61 6e 69 70 75 6c 61 74  es for manipulat
5c20: 69 6e 67 20 72 75 6e 73 0a 3b 3b 3d 3d 3d 3d 3d  ing runs.;;=====
5c30: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5c40: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5c50: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5c60: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5c70: 3d 0a 0a 3b 3b 20 53 69 6e 63 65 20 6d 61 6e 79  =..;; Since many
5c80: 20 63 61 6c 6c 73 20 74 6f 20 61 20 72 75 6e 20   calls to a run 
5c90: 72 65 71 75 69 72 65 20 70 72 65 74 74 79 20 6d  require pretty m
5ca0: 75 63 68 20 74 68 65 20 73 61 6d 65 20 73 65 74  uch the same set
5cb0: 75 70 20 0a 3b 3b 20 74 68 69 73 20 77 72 61 70  up .;; this wrap
5cc0: 70 65 72 20 69 73 20 75 73 65 64 20 74 6f 20 72  per is used to r
5cd0: 65 64 75 63 65 20 74 68 65 20 72 65 70 6c 69 63  educe the replic
5ce0: 61 74 69 6f 6e 20 6f 66 20 63 6f 64 65 0a 28 64  ation of code.(d
5cf0: 65 66 69 6e 65 20 28 67 65 6e 65 72 61 6c 2d 72  efine (general-r
5d00: 75 6e 2d 63 61 6c 6c 20 73 77 69 74 63 68 6e 61  un-call switchna
5d10: 6d 65 20 61 63 74 69 6f 6e 2d 64 65 73 63 20 70  me action-desc p
5d20: 72 6f 63 29 0a 20 20 28 69 66 20 28 6e 6f 74 20  roc).  (if (not 
5d30: 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 3a  (args:get-arg ":
5d40: 72 75 6e 6e 61 6d 65 22 29 29 0a 20 20 20 20 20  runname")).     
5d50: 20 28 62 65 67 69 6e 0a 09 28 64 65 62 75 67 3a   (begin..(debug:
5d60: 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20  print 0 "ERROR: 
5d70: 4d 69 73 73 69 6e 67 20 72 65 71 75 69 72 65 64  Missing required
5d80: 20 70 61 72 61 6d 65 74 65 72 20 66 6f 72 20 22   parameter for "
5d90: 20 73 77 69 74 63 68 6e 61 6d 65 20 22 2c 20 79   switchname ", y
5da0: 6f 75 20 6d 75 73 74 20 73 70 65 63 69 66 79 20  ou must specify 
5db0: 74 68 65 20 72 75 6e 20 6e 61 6d 65 20 77 69 74  the run name wit
5dc0: 68 20 3a 72 75 6e 6e 61 6d 65 20 72 75 6e 6e 61  h :runname runna
5dd0: 6d 65 22 29 0a 09 28 65 78 69 74 20 32 29 29 0a  me")..(exit 2)).
5de0: 20 20 20 20 20 20 28 6c 65 74 20 28 28 64 62 20        (let ((db 
5df0: 20 20 23 66 29 0a 09 20 20 20 20 28 6b 65 79 73    #f)..    (keys
5e00: 20 23 66 29 29 0a 09 28 69 66 20 28 6e 6f 74 20   #f))..(if (not 
5e10: 28 73 65 74 75 70 2d 66 6f 72 2d 72 75 6e 29 29  (setup-for-run))
5e20: 0a 09 20 20 20 20 28 62 65 67 69 6e 20 0a 09 20  ..    (begin .. 
5e30: 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e       (debug:prin
5e40: 74 20 30 20 22 46 61 69 6c 65 64 20 74 6f 20 73  t 0 "Failed to s
5e50: 65 74 75 70 2c 20 65 78 69 74 69 6e 67 22 29 0a  etup, exiting").
5e60: 09 20 20 20 20 20 20 28 65 78 69 74 20 31 29 29  .      (exit 1))
5e70: 29 0a 09 28 73 65 74 21 20 64 62 20 20 20 28 6f  )..(set! db   (o
5e80: 70 65 6e 2d 64 62 29 29 0a 09 28 73 65 74 21 20  pen-db))..(set! 
5e90: 6b 65 79 73 20 28 64 62 2d 67 65 74 2d 6b 65 79  keys (db-get-key
5ea0: 73 20 64 62 29 29 0a 09 3b 3b 20 68 61 76 65 20  s db))..;; have 
5eb0: 65 6e 6f 75 67 68 20 74 6f 20 70 72 6f 63 65 73  enough to proces
5ec0: 73 20 2d 74 61 72 67 65 74 20 6f 72 20 2d 72 65  s -target or -re
5ed0: 71 74 61 72 67 20 68 65 72 65 0a 09 28 69 66 20  qtarg here..(if 
5ee0: 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d  (args:get-arg "-
5ef0: 72 65 71 74 61 72 67 22 29 0a 09 20 20 20 20 28  reqtarg")..    (
5f00: 6c 65 74 2a 20 28 28 72 75 6e 63 6f 6e 66 69 67  let* ((runconfig
5f10: 66 20 28 63 6f 6e 63 20 20 2a 74 6f 70 70 61 74  f (conc  *toppat
5f20: 68 2a 20 22 2f 72 75 6e 63 6f 6e 66 69 67 73 2e  h* "/runconfigs.
5f30: 63 6f 6e 66 69 67 22 29 29 20 3b 3b 20 44 4f 20  config")) ;; DO 
5f40: 4e 4f 54 20 45 56 41 4c 55 41 54 45 20 41 4c 4c  NOT EVALUATE ALL
5f50: 20 0a 09 09 20 20 20 28 72 75 6e 63 6f 6e 66 69   ...   (runconfi
5f60: 67 20 20 28 72 65 61 64 2d 63 6f 6e 66 69 67 20  g  (read-config 
5f70: 72 75 6e 63 6f 6e 66 69 67 66 20 23 66 20 23 66  runconfigf #f #f
5f80: 20 65 6e 76 69 72 6f 6e 2d 70 61 74 74 3a 20 23   environ-patt: #
5f90: 66 29 29 29 20 0a 09 20 20 20 20 20 20 28 69 66  f))) ..      (if
5fa0: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
5fb0: 2f 64 65 66 61 75 6c 74 20 72 75 6e 63 6f 6e 66  /default runconf
5fc0: 69 67 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67  ig (args:get-arg
5fd0: 20 22 2d 72 65 71 74 61 72 67 22 29 20 23 66 29   "-reqtarg") #f)
5fe0: 0a 09 09 20 20 28 6b 65 79 73 3a 74 61 72 67 65  ...  (keys:targe
5ff0: 74 2d 73 65 74 2d 61 72 67 73 20 6b 65 79 73 20  t-set-args keys 
6000: 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d  (args:get-arg "-
6010: 72 65 71 74 61 72 67 22 29 20 61 72 67 73 3a 61  reqtarg") args:a
6020: 72 67 2d 68 61 73 68 29 0a 09 09 20 20 28 62 65  rg-hash)...  (be
6030: 67 69 6e 0a 09 09 20 20 20 20 28 64 65 62 75 67  gin...    (debug
6040: 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a  :print 0 "ERROR:
6050: 20 5b 22 20 28 61 72 67 73 3a 67 65 74 2d 61 72   [" (args:get-ar
6060: 67 20 22 2d 72 65 71 74 61 72 67 22 29 20 22 5d  g "-reqtarg") "]
6070: 20 6e 6f 74 20 66 6f 75 6e 64 20 69 6e 20 22 20   not found in " 
6080: 72 75 6e 63 6f 6e 66 69 67 66 29 0a 09 09 20 20  runconfigf)...  
6090: 20 20 28 73 71 6c 69 74 65 33 3a 66 69 6e 61 6c    (sqlite3:final
60a0: 69 7a 65 21 20 64 62 29 0a 09 09 20 20 20 20 28  ize! db)...    (
60b0: 65 78 69 74 20 31 29 29 29 29 0a 09 20 20 20 20  exit 1))))..    
60c0: 28 69 66 20 28 61 72 67 73 3a 67 65 74 2d 61 72  (if (args:get-ar
60d0: 67 20 22 2d 74 61 72 67 65 74 22 29 0a 09 09 28  g "-target")...(
60e0: 6b 65 79 73 3a 74 61 72 67 65 74 2d 73 65 74 2d  keys:target-set-
60f0: 61 72 67 73 20 6b 65 79 73 20 28 61 72 67 73 3a  args keys (args:
6100: 67 65 74 2d 61 72 67 20 22 2d 74 61 72 67 65 74  get-arg "-target
6110: 22 20 61 72 67 73 3a 61 72 67 2d 68 61 73 68 29  " args:arg-hash)
6120: 20 61 72 67 73 3a 61 72 67 2d 68 61 73 68 29 29   args:arg-hash))
6130: 29 0a 09 28 69 66 20 28 6e 6f 74 20 28 63 61 72  )..(if (not (car
6140: 20 2a 63 6f 6e 66 69 67 69 6e 66 6f 2a 29 29 0a   *configinfo*)).
6150: 09 20 20 20 20 28 62 65 67 69 6e 0a 09 20 20 20  .    (begin..   
6160: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
6170: 30 20 22 45 52 52 4f 52 3a 20 41 74 74 65 6d 70  0 "ERROR: Attemp
6180: 74 65 64 20 74 6f 20 22 20 61 63 74 69 6f 6e 2d  ted to " action-
6190: 64 65 73 63 20 22 20 62 75 74 20 72 75 6e 20 61  desc " but run a
61a0: 72 65 61 20 63 6f 6e 66 69 67 20 66 69 6c 65 20  rea config file 
61b0: 6e 6f 74 20 66 6f 75 6e 64 22 29 0a 09 20 20 20  not found")..   
61c0: 20 20 20 28 65 78 69 74 20 31 29 29 0a 09 20 20     (exit 1))..  
61d0: 20 20 3b 3b 20 45 78 74 72 61 63 74 20 6f 75 74    ;; Extract out
61e0: 20 73 74 75 66 66 20 6e 65 65 64 65 64 20 69 6e   stuff needed in
61f0: 20 6d 6f 73 74 20 6f 72 20 6d 61 6e 79 20 63 61   most or many ca
6200: 6c 6c 73 0a 09 20 20 20 20 3b 3b 20 68 65 72 65  lls..    ;; here
6210: 20 74 68 65 6e 20 63 61 6c 6c 20 70 72 6f 63 0a   then call proc.
6220: 09 20 20 20 20 28 6c 65 74 2a 20 28 28 6b 65 79  .    (let* ((key
6230: 6e 61 6d 65 73 20 20 20 28 6d 61 70 20 6b 65 79  names   (map key
6240: 3a 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b  :get-fieldname k
6250: 65 79 73 29 29 0a 09 09 20 20 20 28 6b 65 79 76  eys))...   (keyv
6260: 61 6c 6c 73 74 20 20 28 6b 65 79 73 2d 3e 76 61  allst  (keys->va
6270: 6c 6c 69 73 74 20 6b 65 79 73 20 23 74 29 29 29  llist keys #t)))
6280: 0a 09 20 20 20 20 20 20 28 70 72 6f 63 20 64 62  ..      (proc db
6290: 20 6b 65 79 73 20 6b 65 79 6e 61 6d 65 73 20 6b   keys keynames k
62a0: 65 79 76 61 6c 6c 73 74 29 29 29 0a 09 28 73 71  eyvallst)))..(sq
62b0: 6c 69 74 65 33 3a 66 69 6e 61 6c 69 7a 65 21 20  lite3:finalize! 
62c0: 64 62 29 0a 09 28 73 65 74 21 20 2a 64 69 64 73  db)..(set! *dids
62d0: 6f 6d 65 74 68 69 6e 67 2a 20 23 74 29 29 29 29  omething* #t))))
62e0: 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ..;;============
62f0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6300: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6310: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6320: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 52 6f  ==========.;; Ro
6330: 6c 6c 75 70 20 72 75 6e 73 0a 3b 3b 3d 3d 3d 3d  llup runs.;;====
6340: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6350: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6360: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6370: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
6380: 3d 3d 0a 0a 3b 3b 20 55 70 64 61 74 65 20 74 68  ==..;; Update th
6390: 65 20 74 65 73 74 5f 6d 65 74 61 20 74 61 62 6c  e test_meta tabl
63a0: 65 20 66 6f 72 20 74 68 69 73 20 74 65 73 74 0a  e for this test.
63b0: 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 75 70  (define (runs:up
63c0: 64 61 74 65 2d 74 65 73 74 5f 6d 65 74 61 20 64  date-test_meta d
63d0: 62 20 74 65 73 74 2d 6e 61 6d 65 20 74 65 73 74  b test-name test
63e0: 2d 63 6f 6e 66 29 0a 20 20 28 6c 65 74 20 28 28  -conf).  (let ((
63f0: 63 75 72 72 72 65 63 6f 72 64 20 28 64 62 3a 74  currrecord (db:t
6400: 65 73 74 6d 65 74 61 2d 67 65 74 2d 72 65 63 6f  estmeta-get-reco
6410: 72 64 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 29  rd db test-name)
6420: 29 29 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20  )).    (if (not 
6430: 63 75 72 72 72 65 63 6f 72 64 29 0a 09 28 62 65  currrecord)..(be
6440: 67 69 6e 0a 09 20 20 28 73 65 74 21 20 63 75 72  gin..  (set! cur
6450: 72 72 65 63 6f 72 64 20 28 6d 61 6b 65 2d 76 65  rrecord (make-ve
6460: 63 74 6f 72 20 31 30 20 23 66 29 29 0a 09 20 20  ctor 10 #f))..  
6470: 28 64 62 3a 74 65 73 74 6d 65 74 61 2d 61 64 64  (db:testmeta-add
6480: 2d 72 65 63 6f 72 64 20 64 62 20 74 65 73 74 2d  -record db test-
6490: 6e 61 6d 65 29 29 29 0a 20 20 20 20 28 66 6f 72  name))).    (for
64a0: 2d 65 61 63 68 20 0a 20 20 20 20 20 28 6c 61 6d  -each .     (lam
64b0: 62 64 61 20 28 6b 65 79 29 0a 20 20 20 20 20 20  bda (key).      
64c0: 20 28 6c 65 74 2a 20 28 28 69 64 78 20 28 63 61   (let* ((idx (ca
64d0: 64 72 20 6b 65 79 29 29 0a 09 20 20 20 20 20 20  dr key))..      
64e0: 28 66 6c 64 20 28 63 61 72 20 20 6b 65 79 29 29  (fld (car  key))
64f0: 0a 09 20 20 20 20 20 20 28 76 61 6c 20 28 63 6f  ..      (val (co
6500: 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 74 65 73 74  nfig-lookup test
6510: 2d 63 6f 6e 66 20 22 74 65 73 74 5f 6d 65 74 61  -conf "test_meta
6520: 22 20 66 6c 64 29 29 29 0a 09 20 28 69 66 20 28  " fld))).. (if (
6530: 61 6e 64 20 76 61 6c 20 28 6e 6f 74 20 28 65 71  and val (not (eq
6540: 75 61 6c 3f 20 28 76 65 63 74 6f 72 2d 72 65 66  ual? (vector-ref
6550: 20 63 75 72 72 72 65 63 6f 72 64 20 69 64 78 29   currrecord idx)
6560: 20 76 61 6c 29 29 29 0a 09 20 20 20 20 20 28 62   val)))..     (b
6570: 65 67 69 6e 0a 09 20 20 20 20 20 20 20 28 70 72  egin..       (pr
6580: 69 6e 74 20 22 55 70 64 61 74 69 6e 67 20 22 20  int "Updating " 
6590: 74 65 73 74 2d 6e 61 6d 65 20 22 20 22 20 66 6c  test-name " " fl
65a0: 64 20 22 20 74 6f 20 22 20 76 61 6c 29 0a 09 20  d " to " val).. 
65b0: 20 20 20 20 20 20 28 64 62 3a 74 65 73 74 6d 65        (db:testme
65c0: 74 61 2d 75 70 64 61 74 65 2d 66 69 65 6c 64 20  ta-update-field 
65d0: 64 62 20 74 65 73 74 2d 6e 61 6d 65 20 66 6c 64  db test-name fld
65e0: 20 76 61 6c 29 29 29 29 29 0a 20 20 20 20 20 27   val))))).     '
65f0: 28 28 22 61 75 74 68 6f 72 22 20 32 29 28 22 6f  (("author" 2)("o
6600: 77 6e 65 72 22 20 33 29 28 22 64 65 73 63 72 69  wner" 3)("descri
6610: 70 74 69 6f 6e 22 20 34 29 28 22 72 65 76 69 65  ption" 4)("revie
6620: 77 65 64 22 20 35 29 28 22 74 61 67 73 22 20 39  wed" 5)("tags" 9
6630: 29 29 29 29 29 0a 0a 3b 3b 20 55 70 64 61 74 65  )))))..;; Update
6640: 20 74 65 73 74 5f 6d 65 74 61 20 66 6f 72 20 61   test_meta for a
6650: 6c 6c 20 74 65 73 74 73 0a 28 64 65 66 69 6e 65  ll tests.(define
6660: 20 28 72 75 6e 73 3a 75 70 64 61 74 65 2d 61 6c   (runs:update-al
6670: 6c 2d 74 65 73 74 5f 6d 65 74 61 20 64 62 29 0a  l-test_meta db).
6680: 20 20 28 6c 65 74 20 28 28 74 65 73 74 2d 6e 61    (let ((test-na
6690: 6d 65 73 20 28 67 65 74 2d 61 6c 6c 2d 6c 65 67  mes (get-all-leg
66a0: 61 6c 2d 74 65 73 74 73 29 29 29 0a 20 20 20 20  al-tests))).    
66b0: 28 66 6f 72 2d 65 61 63 68 20 0a 20 20 20 20 20  (for-each .     
66c0: 28 6c 61 6d 62 64 61 20 28 74 65 73 74 2d 6e 61  (lambda (test-na
66d0: 6d 65 29 0a 20 20 20 20 20 20 20 28 6c 65 74 2a  me).       (let*
66e0: 20 28 28 74 65 73 74 2d 70 61 74 68 20 20 20 20   ((test-path    
66f0: 28 63 6f 6e 63 20 2a 74 6f 70 70 61 74 68 2a 20  (conc *toppath* 
6700: 22 2f 74 65 73 74 73 2f 22 20 74 65 73 74 2d 6e  "/tests/" test-n
6710: 61 6d 65 29 29 0a 09 20 20 20 20 20 20 28 74 65  ame))..      (te
6720: 73 74 2d 63 6f 6e 66 69 67 66 20 28 63 6f 6e 63  st-configf (conc
6730: 20 74 65 73 74 2d 70 61 74 68 20 22 2f 74 65 73   test-path "/tes
6740: 74 63 6f 6e 66 69 67 22 29 29 0a 09 20 20 20 20  tconfig"))..    
6750: 20 20 28 74 65 73 74 65 78 69 73 74 73 20 20 20    (testexists   
6760: 28 61 6e 64 20 28 66 69 6c 65 2d 65 78 69 73 74  (and (file-exist
6770: 73 3f 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 29  s? test-configf)
6780: 28 66 69 6c 65 2d 72 65 61 64 2d 61 63 63 65 73  (file-read-acces
6790: 73 3f 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 29  s? test-configf)
67a0: 29 29 0a 09 20 20 20 20 20 20 3b 3b 20 72 65 61  ))..      ;; rea
67b0: 64 20 63 6f 6e 66 69 67 73 20 77 69 74 68 20 74  d configs with t
67c0: 72 69 63 6b 73 20 74 75 72 6e 65 64 20 6f 66 66  ricks turned off
67d0: 20 28 69 2e 65 2e 20 6e 6f 20 73 79 73 74 65 6d   (i.e. no system
67e0: 29 0a 09 20 20 20 20 20 20 28 74 65 73 74 2d 63  )..      (test-c
67f0: 6f 6e 66 20 20 20 20 28 69 66 20 74 65 73 74 65  onf    (if teste
6800: 78 69 73 74 73 20 28 72 65 61 64 2d 63 6f 6e 66  xists (read-conf
6810: 69 67 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 20  ig test-configf 
6820: 23 66 20 23 66 29 28 6d 61 6b 65 2d 68 61 73 68  #f #f)(make-hash
6830: 2d 74 61 62 6c 65 29 29 29 29 0a 09 20 28 72 75  -table)))).. (ru
6840: 6e 73 3a 75 70 64 61 74 65 2d 74 65 73 74 5f 6d  ns:update-test_m
6850: 65 74 61 20 64 62 20 74 65 73 74 2d 6e 61 6d 65  eta db test-name
6860: 20 74 65 73 74 2d 63 6f 6e 66 29 29 29 0a 20 20   test-conf))).  
6870: 20 20 20 74 65 73 74 2d 6e 61 6d 65 73 29 29 29     test-names)))
6880: 0a 0a 3b 3b 20 54 68 69 73 20 63 6f 75 6c 64 20  ..;; This could 
6890: 70 72 6f 62 61 62 6c 79 20 62 65 20 72 65 66 61  probably be refa
68a0: 63 74 6f 72 65 64 20 69 6e 74 6f 20 6f 6e 65 20  ctored into one 
68b0: 63 6f 6d 70 6c 65 78 20 71 75 65 72 79 20 2e 2e  complex query ..
68c0: 2e 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a  ..(define (runs:
68d0: 72 6f 6c 6c 75 70 2d 72 75 6e 20 64 62 20 6b 65  rollup-run db ke
68e0: 79 73 20 6b 65 79 76 61 6c 6c 73 74 20 72 75 6e  ys keyvallst run
68f0: 6e 61 6d 65 20 75 73 65 72 29 20 3b 3b 20 77 61  name user) ;; wa
6900: 73 20 74 61 72 67 65 74 2c 20 6e 6f 77 20 6b 65  s target, now ke
6910: 79 76 61 6c 6c 73 74 0a 20 20 28 64 65 62 75 67  yvallst.  (debug
6920: 3a 70 72 69 6e 74 20 34 20 22 72 75 6e 73 3a 72  :print 4 "runs:r
6930: 6f 6c 6c 75 70 2d 72 75 6e 2c 20 6b 65 79 73 3a  ollup-run, keys:
6940: 20 22 20 6b 65 79 73 20 22 20 6b 65 79 76 61 6c   " keys " keyval
6950: 6c 73 74 3a 20 22 20 6b 65 79 76 61 6c 6c 73 74  lst: " keyvallst
6960: 20 22 20 3a 72 75 6e 6e 61 6d 65 20 22 20 72 75   " :runname " ru
6970: 6e 6e 61 6d 65 20 22 20 75 73 65 72 3a 20 22 20  nname " user: " 
6980: 75 73 65 72 29 0a 20 20 28 6c 65 74 2a 20 28 3b  user).  (let* (;
6990: 20 28 6b 65 79 76 61 6c 6c 6c 73 74 20 20 20 20   (keyvalllst    
69a0: 20 20 28 6b 65 79 73 3a 74 61 72 67 65 74 2d 3e    (keys:target->
69b0: 6b 65 79 76 61 6c 20 6b 65 79 73 20 74 61 72 67  keyval keys targ
69c0: 65 74 29 29 0a 09 20 28 6e 65 77 2d 72 75 6e 2d  et)).. (new-run-
69d0: 69 64 20 20 20 20 20 20 28 72 75 6e 73 3a 72 65  id      (runs:re
69e0: 67 69 73 74 65 72 2d 72 75 6e 20 64 62 20 6b 65  gister-run db ke
69f0: 79 73 20 6b 65 79 76 61 6c 6c 73 74 20 72 75 6e  ys keyvallst run
6a00: 6e 61 6d 65 20 22 6e 65 77 22 20 22 6e 2f 61 22  name "new" "n/a"
6a10: 20 75 73 65 72 29 29 0a 09 20 28 70 72 65 76 2d   user)).. (prev-
6a20: 74 65 73 74 73 20 20 20 20 20 20 28 74 65 73 74  tests      (test
6a30: 3a 67 65 74 2d 6d 61 74 63 68 69 6e 67 2d 70 72  :get-matching-pr
6a40: 65 76 69 6f 75 73 2d 74 65 73 74 2d 72 75 6e 2d  evious-test-run-
6a50: 72 65 63 6f 72 64 73 20 64 62 20 6e 65 77 2d 72  records db new-r
6a60: 75 6e 2d 69 64 20 22 25 22 20 22 25 22 29 29 0a  un-id "%" "%")).
6a70: 09 20 28 63 75 72 72 2d 74 65 73 74 73 20 20 20  . (curr-tests   
6a80: 20 20 20 28 64 62 2d 67 65 74 2d 74 65 73 74 73     (db-get-tests
6a90: 2d 66 6f 72 2d 72 75 6e 20 64 62 20 6e 65 77 2d  -for-run db new-
6aa0: 72 75 6e 2d 69 64 20 22 25 22 20 22 25 22 20 27  run-id "%" "%" '
6ab0: 28 29 20 27 28 29 29 29 0a 09 20 28 63 75 72 72  () '())).. (curr
6ac0: 2d 74 65 73 74 73 2d 68 61 73 68 20 28 6d 61 6b  -tests-hash (mak
6ad0: 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29 29 0a  e-hash-table))).
6ae0: 20 20 20 20 28 64 62 3a 75 70 64 61 74 65 2d 72      (db:update-r
6af0: 75 6e 2d 65 76 65 6e 74 5f 74 69 6d 65 20 64 62  un-event_time db
6b00: 20 6e 65 77 2d 72 75 6e 2d 69 64 29 0a 20 20 20   new-run-id).   
6b10: 20 3b 3b 20 69 6e 64 65 78 20 74 68 65 20 61 6c   ;; index the al
6b20: 72 65 61 64 79 20 73 61 76 65 64 20 74 65 73 74  ready saved test
6b30: 73 20 62 79 20 74 65 73 74 6e 61 6d 65 20 61 6e  s by testname an
6b40: 64 20 69 74 65 6d 64 61 74 20 69 6e 20 63 75 72  d itemdat in cur
6b50: 72 2d 74 65 73 74 73 2d 68 61 73 68 0a 20 20 20  r-tests-hash.   
6b60: 20 28 66 6f 72 2d 65 61 63 68 0a 20 20 20 20 20   (for-each.     
6b70: 28 6c 61 6d 62 64 61 20 28 74 65 73 74 64 61 74  (lambda (testdat
6b80: 29 0a 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28  ).       (let* (
6b90: 28 74 65 73 74 6e 61 6d 65 20 20 28 64 62 3a 74  (testname  (db:t
6ba0: 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65  est-get-testname
6bb0: 20 74 65 73 74 64 61 74 29 29 0a 09 20 20 20 20   testdat))..    
6bc0: 20 20 28 69 74 65 6d 2d 70 61 74 68 20 28 64 62    (item-path (db
6bd0: 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70  :test-get-item-p
6be0: 61 74 68 20 74 65 73 74 64 61 74 29 29 0a 09 20  ath testdat)).. 
6bf0: 20 20 20 20 20 28 66 75 6c 6c 2d 6e 61 6d 65 20       (full-name 
6c00: 28 63 6f 6e 63 20 74 65 73 74 6e 61 6d 65 20 22  (conc testname "
6c10: 2f 22 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a  /" item-path))).
6c20: 09 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65  . (hash-table-se
6c30: 74 21 20 63 75 72 72 2d 74 65 73 74 73 2d 68 61  t! curr-tests-ha
6c40: 73 68 20 66 75 6c 6c 2d 6e 61 6d 65 20 74 65 73  sh full-name tes
6c50: 74 64 61 74 29 29 29 0a 20 20 20 20 20 63 75 72  tdat))).     cur
6c60: 72 2d 74 65 73 74 73 29 0a 20 20 20 20 3b 3b 20  r-tests).    ;; 
6c70: 4e 4f 50 45 3a 20 4e 6f 6e 2d 6f 70 74 69 6d 61  NOPE: Non-optima
6c80: 6c 20 61 70 70 72 6f 61 63 68 2e 20 54 72 79 20  l approach. Try 
6c90: 74 68 69 73 20 69 6e 73 74 65 61 64 2e 0a 20 20  this instead..  
6ca0: 20 20 3b 3b 20 20 20 31 2e 20 74 65 73 74 73 20    ;;   1. tests 
6cb0: 61 72 65 20 72 65 63 65 69 76 65 64 20 69 6e 20  are received in 
6cc0: 61 20 6c 69 73 74 2c 20 6d 6f 73 74 20 72 65 63  a list, most rec
6cd0: 65 6e 74 20 66 69 72 73 74 0a 20 20 20 20 3b 3b  ent first.    ;;
6ce0: 20 20 20 32 2e 20 72 65 70 6c 61 63 65 20 74 68     2. replace th
6cf0: 65 20 72 6f 6c 6c 75 70 20 74 65 73 74 20 77 69  e rollup test wi
6d00: 74 68 20 74 68 65 20 6e 65 77 20 2a 61 6c 77 61  th the new *alwa
6d10: 79 73 2a 0a 20 20 20 20 28 66 6f 72 2d 65 61 63  ys*.    (for-eac
6d20: 68 20 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20  h .     (lambda 
6d30: 28 74 65 73 74 64 61 74 29 0a 20 20 20 20 20 20  (testdat).      
6d40: 20 28 6c 65 74 2a 20 28 28 74 65 73 74 6e 61 6d   (let* ((testnam
6d50: 65 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  e  (db:test-get-
6d60: 74 65 73 74 6e 61 6d 65 20 74 65 73 74 64 61 74  testname testdat
6d70: 29 29 0a 09 20 20 20 20 20 20 28 69 74 65 6d 2d  ))..      (item-
6d80: 70 61 74 68 20 28 64 62 3a 74 65 73 74 2d 67 65  path (db:test-ge
6d90: 74 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74  t-item-path test
6da0: 64 61 74 29 29 0a 09 20 20 20 20 20 20 28 66 75  dat))..      (fu
6db0: 6c 6c 2d 6e 61 6d 65 20 28 63 6f 6e 63 20 74 65  ll-name (conc te
6dc0: 73 74 6e 61 6d 65 20 22 2f 22 20 69 74 65 6d 2d  stname "/" item-
6dd0: 70 61 74 68 29 29 0a 09 20 20 20 20 20 20 28 70  path))..      (p
6de0: 72 65 76 2d 74 65 73 74 2d 64 61 74 20 28 68 61  rev-test-dat (ha
6df0: 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66  sh-table-ref/def
6e00: 61 75 6c 74 20 63 75 72 72 2d 74 65 73 74 73 2d  ault curr-tests-
6e10: 68 61 73 68 20 66 75 6c 6c 2d 6e 61 6d 65 20 23  hash full-name #
6e20: 66 29 29 0a 09 20 20 20 20 20 20 28 74 65 73 74  f))..      (test
6e30: 2d 73 74 65 70 73 20 20 20 20 20 20 28 64 62 3a  -steps      (db:
6e40: 67 65 74 2d 73 74 65 70 73 2d 66 6f 72 2d 74 65  get-steps-for-te
6e50: 73 74 20 64 62 20 28 64 62 3a 74 65 73 74 2d 67  st db (db:test-g
6e60: 65 74 2d 69 64 20 74 65 73 74 64 61 74 29 29 29  et-id testdat)))
6e70: 0a 09 20 20 20 20 20 20 28 6e 65 77 2d 74 65 73  ..      (new-tes
6e80: 74 2d 72 65 63 6f 72 64 20 23 66 29 29 0a 09 20  t-record #f)).. 
6e90: 3b 3b 20 72 65 70 6c 61 63 65 20 74 68 65 73 65  ;; replace these
6ea0: 20 77 69 74 68 20 69 6e 73 65 72 74 20 2e 2e 2e   with insert ...
6eb0: 20 73 65 6c 65 63 74 0a 09 20 28 61 70 70 6c 79   select.. (apply
6ec0: 20 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65   sqlite3:execute
6ed0: 20 0a 09 09 64 62 20 0a 09 09 28 63 6f 6e 63 20   ...db ...(conc 
6ee0: 22 49 4e 53 45 52 54 20 4f 52 20 52 45 50 4c 41  "INSERT OR REPLA
6ef0: 43 45 20 49 4e 54 4f 20 74 65 73 74 73 20 28 72  CE INTO tests (r
6f00: 75 6e 5f 69 64 2c 74 65 73 74 6e 61 6d 65 2c 73  un_id,testname,s
6f10: 74 61 74 65 2c 73 74 61 74 75 73 2c 65 76 65 6e  tate,status,even
6f20: 74 5f 74 69 6d 65 2c 68 6f 73 74 2c 63 70 75 6c  t_time,host,cpul
6f30: 6f 61 64 2c 64 69 73 6b 66 72 65 65 2c 75 6e 61  oad,diskfree,una
6f40: 6d 65 2c 72 75 6e 64 69 72 2c 69 74 65 6d 5f 70  me,rundir,item_p
6f50: 61 74 68 2c 72 75 6e 5f 64 75 72 61 74 69 6f 6e  ath,run_duration
6f60: 2c 66 69 6e 61 6c 5f 6c 6f 67 66 2c 63 6f 6d 6d  ,final_logf,comm
6f70: 65 6e 74 29 20 22 0a 09 09 20 20 20 20 20 20 22  ent) "...      "
6f80: 56 41 4c 55 45 53 20 28 3f 2c 3f 2c 3f 2c 3f 2c  VALUES (?,?,?,?,
6f90: 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c  ?,?,?,?,?,?,?,?,
6fa0: 3f 2c 3f 29 3b 22 29 0a 09 09 6e 65 77 2d 72 75  ?,?);")...new-ru
6fb0: 6e 2d 69 64 20 28 63 64 64 72 20 28 76 65 63 74  n-id (cddr (vect
6fc0: 6f 72 2d 3e 6c 69 73 74 20 74 65 73 74 64 61 74  or->list testdat
6fd0: 29 29 29 0a 09 20 28 73 65 74 21 20 6e 65 77 2d  ))).. (set! new-
6fe0: 74 65 73 74 64 61 74 20 28 63 61 72 20 28 64 62  testdat (car (db
6ff0: 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d 72  -get-tests-for-r
7000: 75 6e 20 64 62 20 6e 65 77 2d 72 75 6e 2d 69 64  un db new-run-id
7010: 20 74 65 73 74 6e 61 6d 65 20 69 74 65 6d 2d 70   testname item-p
7020: 61 74 68 20 27 28 29 20 27 28 29 29 29 29 0a 09  ath '() '())))..
7030: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74   (hash-table-set
7040: 21 20 63 75 72 72 2d 74 65 73 74 73 2d 68 61 73  ! curr-tests-has
7050: 68 20 66 75 6c 6c 2d 6e 61 6d 65 20 6e 65 77 2d  h full-name new-
7060: 74 65 73 74 64 61 74 29 20 3b 3b 20 74 68 69 73  testdat) ;; this
7070: 20 63 6f 75 6c 64 20 62 65 20 63 6f 6e 66 75 73   could be confus
7080: 69 6e 67 2c 20 77 68 69 63 68 20 72 65 63 6f 72  ing, which recor
7090: 64 20 73 68 6f 75 6c 64 20 67 6f 20 69 6e 74 6f  d should go into
70a0: 20 74 68 65 20 6c 6f 6f 6b 75 70 20 74 61 62 6c   the lookup tabl
70b0: 65 3f 0a 09 20 3b 3b 20 4e 6f 77 20 64 75 70 6c  e?.. ;; Now dupl
70c0: 69 63 61 74 65 20 74 68 65 20 74 65 73 74 20 73  icate the test s
70d0: 74 65 70 73 0a 09 20 28 64 65 62 75 67 3a 70 72  teps.. (debug:pr
70e0: 69 6e 74 20 34 20 22 43 6f 70 79 69 6e 67 20 72  int 4 "Copying r
70f0: 65 63 6f 72 64 73 20 69 6e 20 74 65 73 74 5f 73  ecords in test_s
7100: 74 65 70 73 20 66 72 6f 6d 20 74 65 73 74 5f 69  teps from test_i
7110: 64 3d 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74  d=" (db:test-get
7120: 2d 69 64 20 74 65 73 74 64 61 74 29 20 22 20 74  -id testdat) " t
7130: 6f 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74  o " (db:test-get
7140: 2d 69 64 20 6e 65 77 2d 74 65 73 74 64 61 74 29  -id new-testdat)
7150: 29 0a 09 20 28 73 71 6c 69 74 65 33 3a 65 78 65  ).. (sqlite3:exe
7160: 63 75 74 65 20 0a 09 20 20 64 62 20 0a 09 20 20  cute ..  db ..  
7170: 28 63 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f 52  (conc "INSERT OR
7180: 20 52 45 50 4c 41 43 45 20 49 4e 54 4f 20 74 65   REPLACE INTO te
7190: 73 74 5f 73 74 65 70 73 20 28 74 65 73 74 5f 69  st_steps (test_i
71a0: 64 2c 73 74 65 70 6e 61 6d 65 2c 73 74 61 74 65  d,stepname,state
71b0: 2c 73 74 61 74 75 73 2c 65 76 65 6e 74 5f 74 69  ,status,event_ti
71c0: 6d 65 2c 63 6f 6d 6d 65 6e 74 29 20 22 0a 09 09  me,comment) "...
71d0: 22 53 45 4c 45 43 54 20 22 20 28 64 62 3a 74 65  "SELECT " (db:te
71e0: 73 74 2d 67 65 74 2d 69 64 20 6e 65 77 2d 74 65  st-get-id new-te
71f0: 73 74 64 61 74 29 20 22 2c 73 74 65 70 6e 61 6d  stdat) ",stepnam
7200: 65 2c 73 74 61 74 65 2c 73 74 61 74 75 73 2c 65  e,state,status,e
7210: 76 65 6e 74 5f 74 69 6d 65 2c 63 6f 6d 6d 65 6e  vent_time,commen
7220: 74 20 46 52 4f 4d 20 74 65 73 74 5f 73 74 65 70  t FROM test_step
7230: 73 20 57 48 45 52 45 20 74 65 73 74 5f 69 64 3d  s WHERE test_id=
7240: 3f 3b 22 29 0a 09 20 20 28 64 62 3a 74 65 73 74  ?;")..  (db:test
7250: 2d 67 65 74 2d 69 64 20 74 65 73 74 64 61 74 29  -get-id testdat)
7260: 29 0a 09 20 3b 3b 20 4e 6f 77 20 64 75 70 6c 69  ).. ;; Now dupli
7270: 63 61 74 65 20 74 68 65 20 74 65 73 74 20 64 61  cate the test da
7280: 74 61 0a 09 20 28 64 65 62 75 67 3a 70 72 69 6e  ta.. (debug:prin
7290: 74 20 34 20 22 43 6f 70 79 69 6e 67 20 72 65 63  t 4 "Copying rec
72a0: 6f 72 64 73 20 69 6e 20 74 65 73 74 5f 64 61 74  ords in test_dat
72b0: 61 20 66 72 6f 6d 20 74 65 73 74 5f 69 64 3d 22  a from test_id="
72c0: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64   (db:test-get-id
72d0: 20 74 65 73 74 64 61 74 29 20 22 20 74 6f 20 22   testdat) " to "
72e0: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64   (db:test-get-id
72f0: 20 6e 65 77 2d 74 65 73 74 64 61 74 29 29 0a 09   new-testdat))..
7300: 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74   (sqlite3:execut
7310: 65 20 0a 09 20 20 64 62 20 0a 09 20 20 28 63 6f  e ..  db ..  (co
7320: 6e 63 20 22 49 4e 53 45 52 54 20 4f 52 20 52 45  nc "INSERT OR RE
7330: 50 4c 41 43 45 20 49 4e 54 4f 20 74 65 73 74 5f  PLACE INTO test_
7340: 64 61 74 61 20 28 74 65 73 74 5f 69 64 2c 63 61  data (test_id,ca
7350: 74 65 67 6f 72 79 2c 76 61 72 69 61 62 6c 65 2c  tegory,variable,
7360: 76 61 6c 75 65 2c 65 78 70 65 63 74 65 64 2c 74  value,expected,t
7370: 6f 6c 2c 75 6e 69 74 73 2c 63 6f 6d 6d 65 6e 74  ol,units,comment
7380: 29 20 22 0a 09 09 22 53 45 4c 45 43 54 20 22 20  ) "..."SELECT " 
7390: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20  (db:test-get-id 
73a0: 6e 65 77 2d 74 65 73 74 64 61 74 29 20 22 2c 63  new-testdat) ",c
73b0: 61 74 65 67 6f 72 79 2c 76 61 72 69 61 62 6c 65  ategory,variable
73c0: 2c 76 61 6c 75 65 2c 65 78 70 65 63 74 65 64 2c  ,value,expected,
73d0: 74 6f 6c 2c 75 6e 69 74 73 2c 63 6f 6d 6d 65 6e  tol,units,commen
73e0: 74 20 46 52 4f 4d 20 74 65 73 74 5f 64 61 74 61  t FROM test_data
73f0: 20 57 48 45 52 45 20 74 65 73 74 5f 69 64 3d 3f   WHERE test_id=?
7400: 3b 22 29 0a 09 20 20 28 64 62 3a 74 65 73 74 2d  ;")..  (db:test-
7410: 67 65 74 2d 69 64 20 74 65 73 74 64 61 74 29 29  get-id testdat))
7420: 0a 09 20 29 29 0a 20 20 20 20 20 70 72 65 76 2d  .. )).     prev-
7430: 74 65 73 74 73 29 29 29 0a 09 20 0a 20 20 20 20  tests))).. .    
7440: 20 0a                                             .