Megatest

Hex Artifact Content
Login

Artifact 9e5179a7af8cc41e05f5ef5090adcca541d0a307:


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 61 6e 64  ied.    (if (and
20b0: 20 28 65 71 3f 20 2a 70 61 73 73 6e 75 6d 2a 20   (eq? *passnum* 
20c0: 30 29 0a 09 20 20 20 20 20 6b 65 65 70 67 6f 69  0)..     keepgoi
20d0: 6e 67 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 3b  ng)..(begin..  ;
20e0: 3b 20 68 61 76 65 20 74 6f 20 64 65 6c 65 74 65  ; have to delete
20f0: 20 74 65 73 74 20 72 65 63 6f 72 64 73 20 77 68   test records wh
2100: 65 72 65 20 4e 4f 54 5f 53 54 41 52 54 45 44 20  ere NOT_STARTED 
2110: 73 69 6e 63 65 20 74 68 65 79 20 63 61 6e 20 63  since they can c
2120: 61 75 73 65 20 2d 6b 65 65 70 67 6f 69 6e 67 20  ause -keepgoing 
2130: 74 6f 20 0a 09 20 20 3b 3b 20 67 65 74 20 73 74  to ..  ;; get st
2140: 75 63 6b 20 64 75 65 20 74 6f 20 62 65 63 6f 6d  uck due to becom
2150: 69 6e 67 20 69 6e 61 63 63 65 73 73 69 62 6c 65  ing inaccessible
2160: 20 66 72 6f 6d 20 61 20 66 61 69 6c 65 64 20 74   from a failed t
2170: 65 73 74 2e 20 49 2e 65 2e 20 69 66 20 74 65 73  est. I.e. if tes
2180: 74 20 42 20 64 65 70 65 6e 64 73 20 0a 09 20 20  t B depends ..  
2190: 3b 3b 20 6f 6e 20 74 65 73 74 20 41 20 62 75 74  ;; on test A but
21a0: 20 74 65 73 74 20 42 20 72 65 61 63 68 65 64 20   test B reached 
21b0: 74 68 65 20 70 6f 69 6e 74 20 6f 6e 20 62 65 69  the point on bei
21c0: 6e 67 20 72 65 67 69 73 74 65 72 65 64 20 61 73  ng registered as
21d0: 20 4e 4f 54 5f 53 54 41 52 54 45 44 20 61 6e 64   NOT_STARTED and
21e0: 20 74 65 73 74 0a 09 20 20 3b 3b 20 41 20 66 61   test..  ;; A fa
21f0: 69 6c 65 64 20 66 6f 72 20 73 6f 6d 65 20 72 65  iled for some re
2200: 61 73 6f 6e 20 74 68 65 6e 20 6f 6e 20 72 65 2d  ason then on re-
2210: 72 75 6e 20 75 73 69 6e 67 20 2d 6b 65 65 70 67  run using -keepg
2220: 6f 69 6e 67 20 74 68 65 20 72 75 6e 20 63 61 6e  oing the run can
2230: 20 6e 65 76 65 72 20 63 6f 6d 70 6c 65 74 65 2e   never complete.
2240: 0a 09 20 20 28 64 62 3a 64 65 6c 65 74 65 2d 74  ..  (db:delete-t
2250: 65 73 74 73 2d 69 6e 2d 73 74 61 74 65 20 64 62  ests-in-state db
2260: 20 72 75 6e 2d 69 64 20 22 4e 4f 54 5f 53 54 41   run-id "NOT_STA
2270: 52 54 45 44 22 29 0a 09 20 20 28 64 62 3a 73 65  RTED")..  (db:se
2280: 74 2d 74 65 73 74 73 2d 73 74 61 74 65 2d 73 74  t-tests-state-st
2290: 61 74 75 73 20 64 62 20 72 75 6e 2d 69 64 20 74  atus db run-id t
22a0: 65 73 74 2d 6e 61 6d 65 73 20 23 66 20 22 46 41  est-names #f "FA
22b0: 49 4c 22 20 22 4e 4f 54 5f 53 54 41 52 54 45 44  IL" "NOT_STARTED
22c0: 22 20 22 46 41 49 4c 22 29 29 29 0a 0a 20 20 20  " "FAIL")))..   
22d0: 20 3b 3b 20 6e 6f 77 20 61 64 64 20 6e 6f 6e 2d   ;; now add non-
22e0: 64 69 72 65 63 74 6c 79 20 72 65 66 65 72 65 6e  directly referen
22f0: 63 65 64 20 64 65 70 65 6e 64 65 6e 63 69 65 73  ced dependencies
2300: 20 28 69 2e 65 2e 20 77 61 69 74 6f 6e 29 0a 20   (i.e. waiton). 
2310: 20 20 20 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c     (if (not (nul
2320: 6c 3f 20 74 65 73 74 2d 6e 61 6d 65 73 29 29 0a  l? test-names)).
2330: 09 28 6c 65 74 20 6c 6f 6f 70 20 28 28 68 65 64  .(let loop ((hed
2340: 20 28 63 61 72 20 74 65 73 74 2d 6e 61 6d 65 73   (car test-names
2350: 29 29 0a 09 09 20 20 20 28 74 61 6c 20 28 63 64  ))...   (tal (cd
2360: 72 20 74 65 73 74 2d 6e 61 6d 65 73 29 29 29 20  r test-names))) 
2370: 20 20 20 20 20 20 20 20 3b 3b 20 27 72 65 74 75          ;; 'retu
2380: 72 6e 2d 70 72 6f 63 73 20 74 65 6c 6c 73 20 74  rn-procs tells t
2390: 68 65 20 63 6f 6e 66 69 67 20 72 65 61 64 65 72  he config reader
23a0: 20 74 6f 20 70 72 65 70 20 72 75 6e 6e 69 6e 67   to prep running
23b0: 20 73 79 73 74 65 6d 20 62 75 74 20 72 65 74 75   system but retu
23c0: 72 6e 20 61 20 70 72 6f 63 0a 09 20 20 28 6c 65  rn a proc..  (le
23d0: 74 2a 20 28 28 63 6f 6e 66 69 67 20 20 28 74 65  t* ((config  (te
23e0: 73 74 3a 67 65 74 2d 74 65 73 74 63 6f 6e 66 69  st:get-testconfi
23f0: 67 20 68 65 64 20 27 72 65 74 75 72 6e 2d 70 72  g hed 'return-pr
2400: 6f 63 73 29 29 0a 09 09 20 28 77 61 69 74 6f 6e  ocs))... (waiton
2410: 73 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20  s (string-split 
2420: 28 6c 65 74 20 28 28 77 20 28 63 6f 6e 66 69 67  (let ((w (config
2430: 2d 6c 6f 6f 6b 75 70 20 63 6f 6e 66 69 67 20 22  -lookup config "
2440: 72 65 71 75 69 72 65 6d 65 6e 74 73 22 20 22 77  requirements" "w
2450: 61 69 74 6f 6e 22 29 29 29 0a 09 09 09 09 09 20  aiton")))...... 
2460: 20 28 69 66 20 77 20 77 20 22 22 29 29 29 29 0a   (if w w "")))).
2470: 09 09 20 28 69 74 65 6d 73 20 20 20 28 69 74 65  .. (items   (ite
2480: 6d 73 3a 67 65 74 2d 69 74 65 6d 73 2d 66 72 6f  ms:get-items-fro
2490: 6d 2d 63 6f 6e 66 69 67 20 63 6f 6e 66 69 67 29  m-config config)
24a0: 29 29 0a 09 20 20 20 20 28 69 66 20 28 6e 6f 74  ))..    (if (not
24b0: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
24c0: 2f 64 65 66 61 75 6c 74 20 74 65 73 74 2d 72 65  /default test-re
24d0: 63 6f 72 64 73 20 68 65 64 20 23 66 29 29 0a 09  cords hed #f))..
24e0: 09 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74  .(hash-table-set
24f0: 21 20 74 65 73 74 2d 72 65 63 6f 72 64 73 20 68  ! test-records h
2500: 65 64 20 28 76 65 63 74 6f 72 20 68 65 64 20 63  ed (vector hed c
2510: 6f 6e 66 69 67 20 77 61 69 74 6f 6e 73 20 28 63  onfig waitons (c
2520: 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20 22 72 65  onfig-lookup "re
2530: 71 75 69 72 65 6d 65 6e 74 73 22 20 22 70 72 69  quirements" "pri
2540: 6f 72 69 74 79 22 29 20 23 66 29 29 29 0a 09 20  ority") #f))).. 
2550: 20 20 20 28 66 6f 72 2d 65 61 63 68 20 0a 09 20     (for-each .. 
2560: 20 20 20 20 28 6c 61 6d 62 64 61 20 28 77 61 69      (lambda (wai
2570: 74 6f 6e 29 0a 09 20 20 20 20 20 20 20 28 69 66  ton)..       (if
2580: 20 28 61 6e 64 20 77 61 69 74 6f 6e 20 28 6e 6f   (and waiton (no
2590: 74 20 28 6d 65 6d 62 65 72 20 77 61 69 74 6f 6e  t (member waiton
25a0: 20 74 65 73 74 2d 6e 61 6d 65 73 29 29 29 0a 09   test-names)))..
25b0: 09 20 20 20 28 62 65 67 69 6e 0a 09 09 20 20 20  .   (begin...   
25c0: 20 20 28 73 65 74 21 20 72 65 71 75 69 72 65 64    (set! required
25d0: 2d 74 65 73 74 73 20 28 63 6f 6e 73 20 77 61 69  -tests (cons wai
25e0: 74 6f 6e 20 72 65 71 75 69 72 65 64 2d 74 65 73  ton required-tes
25f0: 74 73 29 29 0a 09 09 20 20 20 20 20 28 73 65 74  ts))...     (set
2600: 21 20 74 65 73 74 2d 6e 61 6d 65 73 20 28 61 70  ! test-names (ap
2610: 70 65 6e 64 20 74 65 73 74 2d 6e 61 6d 65 73 20  pend test-names 
2620: 28 6c 69 73 74 20 77 61 69 74 6f 6e 29 29 29 29  (list waiton))))
2630: 29 29 0a 09 20 20 20 20 20 77 61 69 74 6f 6e 73  ))..     waitons
2640: 29 0a 09 20 20 20 20 28 6c 65 74 20 28 28 72 65  )..    (let ((re
2650: 6d 74 65 73 74 73 20 28 64 65 6c 65 74 65 2d 64  mtests (delete-d
2660: 75 70 6c 69 63 61 74 65 73 20 28 61 70 70 65 6e  uplicates (appen
2670: 64 20 77 61 69 74 6f 6e 73 20 74 61 6c 29 29 29  d waitons tal)))
2680: 29 0a 09 20 20 20 20 20 20 28 69 66 20 28 6e 6f  )..      (if (no
2690: 74 20 28 6e 75 6c 6c 3f 20 72 65 6d 74 65 73 74  t (null? remtest
26a0: 73 29 29 0a 09 09 20 20 28 6c 6f 6f 70 20 28 63  s))...  (loop (c
26b0: 61 72 20 72 65 6d 74 65 73 74 73 29 28 63 64 72  ar remtests)(cdr
26c0: 20 72 65 6d 74 65 73 74 73 29 29 29 29 29 29 29   remtests)))))))
26d0: 0a 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 28  ..    (if (not (
26e0: 6e 75 6c 6c 3f 20 72 65 71 75 69 72 65 64 2d 74  null? required-t
26f0: 65 73 74 73 29 29 0a 09 28 64 65 62 75 67 3a 70  ests))..(debug:p
2700: 72 69 6e 74 20 31 20 22 49 4e 46 4f 3a 20 41 64  rint 1 "INFO: Ad
2710: 64 69 6e 67 20 22 20 72 65 71 75 69 72 65 64 2d  ding " required-
2720: 74 65 73 74 73 20 22 20 74 6f 20 74 68 65 20 72  tests " to the r
2730: 75 6e 20 71 75 65 75 65 22 29 29 0a 20 20 20 20  un queue")).    
2740: 3b 3b 20 4e 4f 54 45 3a 20 74 68 65 73 65 20 61  ;; NOTE: these a
2750: 72 65 20 61 6c 6c 20 70 61 72 65 6e 74 20 74 65  re all parent te
2760: 73 74 73 2c 20 69 74 65 6d 73 20 61 72 65 20 6e  sts, items are n
2770: 6f 74 20 65 78 70 61 6e 64 65 64 20 79 65 74 2e  ot expanded yet.
2780: 0a 20 20 20 20 28 72 75 6e 73 3a 72 75 6e 2d 74  .    (runs:run-t
2790: 65 73 74 73 2d 71 75 65 75 65 20 74 65 73 74 2d  ests-queue test-
27a0: 72 65 63 6f 72 64 73 29 29 29 0a 0a 28 64 65 66  records)))..(def
27b0: 69 6e 65 20 28 72 75 6e 73 3a 72 75 6e 2d 74 65  ine (runs:run-te
27c0: 73 74 73 2d 71 75 65 75 65 20 20 74 65 73 74 2d  sts-queue  test-
27d0: 72 65 63 6f 72 64 73 20 6b 65 79 76 61 6c 6c 69  records keyvalli
27e0: 73 74 29 0a 20 20 20 20 3b 3b 20 41 74 20 74 68  st).    ;; At th
27f0: 69 73 20 70 6f 69 6e 74 20 74 68 65 20 6c 69 73  is point the lis
2800: 74 20 6f 66 20 70 61 72 65 6e 74 20 74 65 73 74  t of parent test
2810: 73 20 69 73 20 65 78 70 61 6e 64 65 64 20 0a 20  s is expanded . 
2820: 20 20 20 3b 3b 20 4e 42 2f 2f 20 53 68 6f 75 6c     ;; NB// Shoul
2830: 64 20 65 78 70 61 6e 64 20 69 74 65 6d 73 20 68  d expand items h
2840: 65 72 65 20 61 6e 64 20 74 68 65 6e 20 69 6e 73  ere and then ins
2850: 65 72 74 20 69 6e 74 6f 20 74 68 65 20 72 75 6e  ert into the run
2860: 20 71 75 65 75 65 2e 0a 20 20 20 20 28 6c 65 74   queue..    (let
2870: 20 28 28 73 6f 72 74 65 64 2d 74 65 73 74 6e 61   ((sorted-testna
2880: 6d 65 73 20 28 74 65 73 74 73 3a 73 6f 72 74 2d  mes (tests:sort-
2890: 62 79 2d 70 72 69 6f 72 69 74 79 2d 61 6e 64 2d  by-priority-and-
28a0: 77 61 69 74 6f 6e 20 74 65 73 74 2d 72 65 63 6f  waiton test-reco
28b0: 72 64 73 29 29 29 0a 20 20 20 20 20 20 28 6c 65  rds))).      (le
28c0: 74 20 6c 6f 6f 70 20 28 3b 20 28 6e 75 6d 74 69  t loop (; (numti
28d0: 6d 65 73 20 30 29 20 3b 3b 20 73 68 6f 75 6c 64  mes 0) ;; should
28e0: 6e 27 74 20 6e 65 65 64 20 74 68 69 73 0a 09 09  n't need this...
28f0: 20 28 68 65 64 20 20 20 20 20 20 20 20 20 28 63   (hed         (c
2900: 61 72 20 73 6f 72 74 65 64 2d 74 65 73 74 2d 6e  ar sorted-test-n
2910: 61 6d 65 73 29 29 0a 09 09 20 28 74 61 6c 20 20  ames))... (tal  
2920: 20 20 20 20 20 20 20 28 63 64 72 20 73 6f 72 74         (cdr sort
2930: 65 64 2d 74 65 73 74 2d 6e 61 6d 65 73 29 29 29  ed-test-names)))
2940: 0a 09 28 6c 65 74 2a 20 28 28 74 65 73 74 2d 72  ..(let* ((test-r
2950: 65 63 6f 72 64 20 28 68 61 73 68 2d 74 61 62 6c  ecord (hash-tabl
2960: 65 2d 72 65 66 20 74 65 73 74 2d 72 65 63 6f 72  e-ref test-recor
2970: 64 73 20 68 65 64 29 29 0a 09 20 20 20 20 20 20  ds hed))..      
2980: 20 28 74 63 6f 6e 66 69 67 20 20 20 20 20 28 74   (tconfig     (t
2990: 65 73 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67  ests:testqueue-g
29a0: 65 74 2d 74 65 73 74 63 6f 6e 66 69 67 20 74 65  et-testconfig te
29b0: 73 74 2d 72 65 63 6f 72 64 29 29 0a 09 20 20 20  st-record))..   
29c0: 20 20 20 20 28 77 61 69 74 6f 6e 73 20 20 20 20      (waitons    
29d0: 20 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75   (tests:testqueu
29e0: 65 2d 67 65 74 2d 77 61 69 74 6f 6e 73 20 20 20  e-get-waitons   
29f0: 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29 0a 09   test-record))..
2a00: 20 20 20 20 20 20 20 28 70 72 69 6f 72 69 74 79         (priority
2a10: 20 20 20 20 28 74 65 73 74 73 3a 74 65 73 74 71      (tests:testq
2a20: 75 65 75 65 2d 67 65 74 2d 70 72 69 6f 72 69 74  ueue-get-priorit
2a30: 79 20 20 20 74 65 73 74 2d 72 65 63 6f 72 64 29  y   test-record)
2a40: 29 0a 09 20 20 20 20 20 20 20 28 69 74 65 6d 64  )..       (itemd
2a50: 61 74 20 20 20 20 20 28 74 65 73 74 73 3a 74 65  at     (tests:te
2a60: 73 74 71 75 65 75 65 2d 67 65 74 2d 69 74 65 6d  stqueue-get-item
2a70: 64 61 74 20 20 20 20 74 65 73 74 2d 72 65 63 6f  dat    test-reco
2a80: 72 64 29 29 0a 09 20 20 20 20 20 20 20 28 69 74  rd))..       (it
2a90: 65 6d 73 20 20 20 20 20 20 20 28 74 65 73 74 73  ems       (tests
2aa0: 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d 69  :testqueue-get-i
2ab0: 74 65 6d 73 20 20 20 20 20 20 74 65 73 74 2d 72  tems      test-r
2ac0: 65 63 6f 72 64 29 29 0a 09 20 20 20 20 20 20 20  ecord))..       
2ad0: 28 69 74 65 6d 2d 70 61 74 68 20 20 20 28 69 74  (item-path   (it
2ae0: 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69 74  em-list->path it
2af0: 65 6d 64 61 74 29 29 29 0a 09 20 20 28 63 6f 6e  emdat)))..  (con
2b00: 64 0a 09 20 20 20 28 28 6e 6f 74 20 69 74 65 6d  d..   ((not item
2b10: 73 29 20 3b 3b 20 77 68 65 6e 20 66 61 6c 73 65  s) ;; when false
2b20: 20 74 68 65 20 74 65 73 74 20 69 73 20 6f 6b 20   the test is ok 
2b30: 74 6f 20 62 65 20 68 61 6e 64 65 64 20 6f 66 66  to be handed off
2b40: 20 74 6f 20 6c 61 75 6e 63 68 0a 09 20 20 20 20   to launch..    
2b50: 28 6c 65 74 20 28 28 68 61 76 65 2d 72 65 73 6f  (let ((have-reso
2b60: 75 72 63 65 73 20 20 28 72 75 6e 73 3a 63 61 6e  urces  (runs:can
2b70: 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20  -run-more-tests 
2b80: 64 62 20 74 65 73 74 2d 72 65 63 6f 72 64 29 29  db test-record))
2b90: 20 3b 3b 20 6c 6f 6f 6b 20 61 74 20 74 68 65 20   ;; look at the 
2ba0: 74 65 73 74 20 6a 6f 62 67 72 6f 75 70 20 61 6e  test jobgroup an
2bb0: 64 20 74 6f 74 20 6a 6f 62 73 20 72 75 6e 6e 69  d tot jobs runni
2bc0: 6e 67 0a 09 09 20 20 28 70 72 65 72 65 71 73 2d  ng...  (prereqs-
2bd0: 6e 6f 74 2d 6d 65 74 20 28 64 62 3a 67 65 74 2d  not-met (db:get-
2be0: 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 20  prereqs-not-met 
2bf0: 64 62 20 72 75 6e 2d 69 64 20 77 61 69 74 6f 6e  db run-id waiton
2c00: 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 09 20   item-path))).. 
2c10: 20 20 20 20 20 28 69 66 20 28 61 6e 64 20 68 61       (if (and ha
2c20: 76 65 2d 72 65 73 6f 75 72 63 65 73 0a 09 09 20  ve-resources... 
2c30: 20 20 20 20 20 20 28 6e 75 6c 6c 3f 20 70 72 65        (null? pre
2c40: 72 65 71 73 2d 6e 6f 74 2d 6d 65 74 29 29 0a 09  reqs-not-met))..
2c50: 09 20 20 3b 3b 20 6e 6f 20 6c 6f 6f 70 20 2d 20  .  ;; no loop - 
2c60: 64 72 6f 70 20 74 68 6f 75 67 68 20 61 6e 64 20  drop though and 
2c70: 75 73 65 20 74 68 65 20 6c 6f 6f 70 20 61 74 20  use the loop at 
2c80: 74 68 65 20 62 6f 74 74 6f 6d 20 0a 09 09 20 20  the bottom ...  
2c90: 28 72 75 6e 3a 74 65 73 74 20 64 62 20 72 75 6e  (run:test db run
2ca0: 2d 69 64 20 72 75 6e 6e 61 6d 65 20 6b 65 79 76  -id runname keyv
2cb0: 61 6c 6c 73 74 20 74 65 73 74 2d 72 65 63 6f 72  allst test-recor
2cc0: 64 20 66 6c 61 67 73 29 0a 09 09 20 20 3b 3b 20  d flags)...  ;; 
2cd0: 65 6c 73 65 20 74 68 65 20 72 75 6e 20 69 73 20  else the run is 
2ce0: 73 74 75 63 6b 2c 20 74 65 6d 70 6f 72 61 72 69  stuck, temporari
2cf0: 6c 79 20 6f 72 20 70 65 72 6d 61 6e 65 6e 74 6c  ly or permanentl
2d00: 79 0a 09 09 20 20 28 6c 65 74 20 28 28 6e 65 77  y...  (let ((new
2d10: 74 61 6c 20 28 61 70 70 65 6e 64 20 74 61 6c 20  tal (append tal 
2d20: 28 6c 69 73 74 20 68 65 64 29 29 29 29 0a 09 09  (list hed))))...
2d30: 20 20 20 20 3b 3b 20 63 6f 75 6c 64 6e 27 74 20      ;; couldn't 
2d40: 72 75 6e 2c 20 74 61 6b 65 20 61 20 62 72 65 61  run, take a brea
2d50: 74 68 65 72 0a 09 09 20 20 20 20 28 74 68 72 65  ther...    (thre
2d60: 61 64 2d 73 6c 65 65 70 21 20 31 29 0a 09 09 20  ad-sleep! 1)... 
2d70: 20 20 20 28 6c 6f 6f 70 20 28 63 61 72 20 74 61     (loop (car ta
2d80: 6c 29 28 63 64 72 20 74 61 6c 29 29 29 29 29 29  l)(cdr tal))))))
2d90: 0a 09 20 20 20 0a 09 20 20 20 3b 3b 20 63 61 73  ..   ..   ;; cas
2da0: 65 20 77 68 65 72 65 20 61 6e 20 69 74 65 6d 73  e where an items
2db0: 20 63 61 6d 65 20 69 6e 20 61 73 20 61 20 6c 69   came in as a li
2dc0: 73 74 20 62 65 65 6e 20 70 72 6f 63 65 73 73 65  st been processe
2dd0: 64 0a 09 20 20 20 28 28 61 6e 64 20 28 6c 69 73  d..   ((and (lis
2de0: 74 3f 20 69 74 65 6d 73 29 20 20 20 20 20 3b 3b  t? items)     ;;
2df0: 20 74 68 75 73 20 77 65 20 6b 6e 6f 77 20 6f 75   thus we know ou
2e00: 72 20 69 74 65 6d 73 20 61 72 65 20 61 6c 72 65  r items are alre
2e10: 61 64 79 20 63 61 6c 63 75 6c 61 74 65 64 0a 09  ady calculated..
2e20: 09 20 28 6e 6f 74 20 20 20 69 74 65 6d 64 61 74  . (not   itemdat
2e30: 29 29 20 3b 3b 20 61 6e 64 20 6e 6f 74 20 79 65  )) ;; and not ye
2e40: 74 20 65 78 70 61 6e 64 65 64 20 69 6e 74 6f 20  t expanded into 
2e50: 74 68 65 20 6c 69 73 74 20 6f 66 20 74 68 69 6e  the list of thin
2e60: 67 73 20 74 6f 20 62 65 20 64 6f 6e 65 0a 09 20  gs to be done.. 
2e70: 20 20 20 28 69 66 20 28 3e 3d 20 2a 76 65 72 62     (if (>= *verb
2e80: 6f 73 69 74 79 2a 20 31 29 28 70 70 20 69 74 65  osity* 1)(pp ite
2e90: 6d 73 29 29 0a 09 20 20 20 20 3b 3b 20 28 69 66  ms))..    ;; (if
2ea0: 20 28 3e 3d 20 2a 76 65 72 62 6f 73 69 74 79 2a   (>= *verbosity*
2eb0: 20 35 29 0a 09 20 20 20 20 3b 3b 20 20 20 20 20   5)..    ;;     
2ec0: 28 62 65 67 69 6e 0a 09 20 20 20 20 3b 3b 20 20  (begin..    ;;  
2ed0: 20 20 20 20 20 28 70 72 69 6e 74 20 22 69 74 65       (print "ite
2ee0: 6d 73 3a 20 22 29 20 20 20 20 20 28 70 70 20 28  ms: ")     (pp (
2ef0: 69 74 65 6d 2d 61 73 73 6f 63 2d 3e 69 74 65 6d  item-assoc->item
2f00: 2d 6c 69 73 74 20 69 74 65 6d 73 29 29 0a 09 20  -list items)).. 
2f10: 20 20 20 3b 3b 20 20 20 20 20 20 20 28 70 72 69     ;;       (pri
2f20: 6e 74 20 22 69 74 65 6d 73 74 61 62 6c 65 3a 20  nt "itemstable: 
2f30: 22 29 28 70 70 20 28 69 74 65 6d 2d 74 61 62 6c  ")(pp (item-tabl
2f40: 65 2d 3e 69 74 65 6d 2d 6c 69 73 74 20 69 74 65  e->item-list ite
2f50: 6d 73 74 61 62 6c 65 29 29 29 29 0a 09 20 20 20  mstable))))..   
2f60: 20 28 66 6f 72 2d 65 61 63 68 0a 09 20 20 20 20   (for-each..    
2f70: 20 28 6c 61 6d 62 64 61 20 28 6d 79 2d 69 74 65   (lambda (my-ite
2f80: 6d 64 61 74 29 0a 09 20 20 20 20 20 20 20 28 6c  mdat)..       (l
2f90: 65 74 2a 20 28 28 6e 65 77 2d 74 65 73 74 2d 72  et* ((new-test-r
2fa0: 65 63 6f 72 64 20 28 76 65 63 74 6f 72 2d 63 6f  ecord (vector-co
2fb0: 70 79 21 20 74 65 73 74 2d 72 65 63 6f 72 64 20  py! test-record 
2fc0: 28 6d 61 6b 65 2d 74 65 73 74 73 3a 74 65 73 74  (make-tests:test
2fd0: 71 75 65 75 65 29 29 29 0a 09 09 20 20 20 20 20  queue)))...     
2fe0: 20 28 6d 79 2d 69 74 65 6d 2d 70 61 74 68 20 28   (my-item-path (
2ff0: 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20  item-list->path 
3000: 6d 79 2d 69 74 65 6d 64 61 74 29 29 0a 09 09 20  my-itemdat))... 
3010: 20 20 20 20 20 28 69 74 65 6d 2d 6d 61 74 63 68       (item-match
3020: 65 73 20 28 69 66 20 69 74 65 6d 2d 70 61 74 74  es (if item-patt
3030: 73 20 20 20 20 20 20 20 3b 3b 20 68 65 72 65 20  s       ;; here 
3040: 77 65 20 61 72 65 20 66 69 6c 74 65 72 69 6e 67  we are filtering
3050: 20 66 6f 72 20 6d 61 74 63 68 65 73 20 77 69 74   for matches wit
3060: 68 20 2d 69 74 65 6d 70 61 74 74 0a 09 09 09 09  h -itempatt.....
3070: 09 28 6c 65 74 20 28 28 72 65 73 20 23 66 29 29  .(let ((res #f))
3080: 09 20 3b 3b 20 6c 6f 6f 6b 20 74 68 72 6f 75 67  . ;; look throug
3090: 68 20 61 6c 6c 20 74 68 65 20 69 74 65 6d 2d 70  h all the item-p
30a0: 61 74 74 73 20 69 66 20 64 65 66 69 6e 65 64 2c  atts if defined,
30b0: 20 66 6f 72 6d 61 74 20 69 73 20 70 61 74 74 31   format is patt1
30c0: 2c 70 61 74 74 32 2c 70 61 74 74 33 20 2e 2e 2e  ,patt2,patt3 ...
30d0: 20 77 69 6c 64 63 61 72 64 20 69 73 20 25 0a 09   wildcard is %..
30e0: 09 09 09 09 20 20 28 66 6f 72 2d 65 61 63 68 20  ....  (for-each 
30f0: 0a 09 09 09 09 09 20 20 20 28 6c 61 6d 62 64 61  ......   (lambda
3100: 20 28 70 61 74 74 29 0a 09 09 09 09 09 20 20 20   (patt)......   
3110: 20 20 28 69 66 20 28 73 74 72 69 6e 67 2d 73 65    (if (string-se
3120: 61 72 63 68 20 28 67 6c 6f 62 2d 3e 72 65 67 65  arch (glob->rege
3130: 78 70 0a 09 09 09 09 09 09 09 09 20 28 73 74 72  xp......... (str
3140: 69 6e 67 2d 74 72 61 6e 73 6c 61 74 65 20 70 61  ing-translate pa
3150: 74 74 20 22 25 22 20 22 2a 22 29 29 0a 09 09 09  tt "%" "*"))....
3160: 09 09 09 09 09 69 74 65 6d 2d 70 61 74 68 29 0a  .....item-path).
3170: 09 09 09 09 09 09 20 28 73 65 74 21 20 72 65 73  ...... (set! res
3180: 20 23 74 29 29 29 0a 09 09 09 09 09 20 20 20 28   #t)))......   (
3190: 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 69 74 65  string-split ite
31a0: 6d 2d 70 61 74 74 73 20 22 2c 22 29 29 0a 09 09  m-patts ","))...
31b0: 09 09 09 20 20 72 65 73 29 0a 09 09 09 09 09 23  ...  res)......#
31c0: 74 29 29 29 0a 09 09 20 28 69 66 20 69 74 65 6d  t)))... (if item
31d0: 2d 6d 61 74 63 68 65 73 20 3b 3b 20 79 65 73 2c  -matches ;; yes,
31e0: 20 77 65 20 77 61 6e 74 20 74 6f 20 70 72 6f 63   we want to proc
31f0: 65 73 73 20 74 68 69 73 20 69 74 65 6d 0a 09 09  ess this item...
3200: 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09 20 20       (begin...  
3210: 20 20 20 20 20 28 74 65 73 74 73 3a 74 65 73 74       (tests:test
3220: 71 75 65 75 65 2d 73 65 74 2d 69 74 65 6d 73 21  queue-set-items!
3230: 20 20 20 6e 65 77 2d 74 65 73 74 2d 72 65 63 6f     new-test-reco
3240: 72 64 20 23 66 29 0a 09 09 20 20 20 20 20 20 20  rd #f)...       
3250: 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65  (tests:testqueue
3260: 2d 73 65 74 2d 69 74 65 6d 64 61 74 21 20 6e 65  -set-itemdat! ne
3270: 77 2d 74 65 73 74 2d 72 65 63 6f 72 64 20 6d 79  w-test-record my
3280: 2d 69 74 65 6d 64 61 74 29 0a 09 09 20 20 20 20  -itemdat)...    
3290: 20 20 20 28 73 65 74 21 20 74 61 6c 20 28 63 6f     (set! tal (co
32a0: 6e 73 20 28 63 6f 6e 63 20 68 65 64 20 22 2f 22  ns (conc hed "/"
32b0: 20 6d 79 2d 69 74 65 6d 2d 70 61 74 68 29 20 74   my-item-path) t
32c0: 61 6c 29 29 29 29 29 29 20 3b 3b 20 73 69 6e 63  al)))))) ;; sinc
32d0: 65 20 74 68 65 73 65 20 61 72 65 20 69 74 65 6d  e these are item
32e0: 69 7a 65 64 20 63 72 65 61 74 65 20 6e 65 77 20  ized create new 
32f0: 74 65 73 74 20 6e 61 6d 65 73 20 74 65 73 74 6e  test names testn
3300: 61 6d 65 2f 69 74 65 6d 70 61 74 68 0a 09 20 20  ame/itempath..  
3310: 20 20 20 69 74 65 6d 73 29 0a 09 20 20 20 20 28     items)..    (
3320: 6c 6f 6f 70 20 28 63 61 72 20 74 61 6c 29 28 63  loop (car tal)(c
3330: 64 72 20 74 61 6c 29 29 29 0a 0a 09 20 20 20 3b  dr tal)))...   ;
3340: 3b 20 69 66 20 69 74 65 6d 73 20 69 73 20 61 20  ; if items is a 
3350: 70 72 6f 63 20 74 68 65 6e 20 6e 65 65 64 20 74  proc then need t
3360: 6f 20 65 76 61 6c 75 61 74 65 2c 20 67 65 74 20  o evaluate, get 
3370: 74 68 65 20 6c 69 73 74 20 61 6e 64 20 6c 6f 6f  the list and loo
3380: 70 20 2d 20 62 75 74 20 6f 6e 6c 79 20 64 6f 20  p - but only do 
3390: 74 68 61 74 20 69 66 20 0a 09 20 20 20 3b 3b 20  that if ..   ;; 
33a0: 72 65 73 6f 75 72 63 65 73 20 65 78 69 73 74 20  resources exist 
33b0: 74 6f 20 6b 69 63 6b 20 6f 66 66 20 74 68 65 20  to kick off the 
33c0: 6a 6f 62 0a 09 20 20 20 28 28 70 72 6f 63 65 64  job..   ((proced
33d0: 75 72 65 3f 20 69 74 65 6d 73 29 0a 09 20 20 20  ure? items)..   
33e0: 20 28 69 66 20 28 72 75 6e 73 3a 63 61 6e 2d 72   (if (runs:can-r
33f0: 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64 62  un-more-tests db
3400: 20 74 65 73 74 2d 72 65 63 6f 72 64 29 0a 09 09   test-record)...
3410: 28 6c 65 74 20 28 28 69 74 65 6d 73 2d 6c 69 73  (let ((items-lis
3420: 74 20 28 69 74 65 6d 73 29 29 29 0a 09 09 20 20  t (items)))...  
3430: 28 69 66 20 28 6c 69 73 74 3f 20 69 74 65 6d 73  (if (list? items
3440: 2d 6c 69 73 74 29 0a 09 09 20 20 20 20 20 20 28  -list)...      (
3450: 62 65 67 69 6e 0a 09 09 09 28 74 65 73 74 73 3a  begin....(tests:
3460: 74 65 73 74 71 75 65 75 65 2d 73 65 74 2d 69 74  testqueue-set-it
3470: 65 6d 73 20 74 65 73 74 2d 72 65 63 6f 72 64 20  ems test-record 
3480: 69 74 65 6d 73 2d 6c 69 73 74 29 0a 09 09 09 28  items-list)....(
3490: 6c 6f 6f 70 20 68 65 64 20 74 61 6c 29 29 0a 09  loop hed tal))..
34a0: 09 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09  .      (begin...
34b0: 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20  .(debug:print 0 
34c0: 22 45 52 52 4f 52 3a 20 54 68 65 20 70 72 6f 63  "ERROR: The proc
34d0: 20 66 72 6f 6d 20 72 65 61 64 69 6e 67 20 74 68   from reading th
34e0: 65 20 73 65 74 75 70 20 64 69 64 20 6e 6f 74 20  e setup did not 
34f0: 79 69 65 6c 64 20 61 20 6c 69 73 74 20 2d 20 70  yield a list - p
3500: 6c 65 61 73 65 20 72 65 70 6f 72 74 20 74 68 69  lease report thi
3510: 73 22 29 0a 09 09 09 28 65 78 69 74 20 31 29 29  s")....(exit 1))
3520: 29 29 0a 09 09 28 6c 65 74 20 28 28 6e 65 77 74  ))...(let ((newt
3530: 61 6c 20 28 61 70 70 65 6e 64 20 74 61 6c 20 28  al (append tal (
3540: 6c 69 73 74 20 68 65 64 29 29 29 29 0a 09 09 20  list hed))))... 
3550: 20 3b 3b 20 69 66 20 63 61 6e 27 74 20 72 75 6e   ;; if can't run
3560: 20 6d 6f 72 65 20 74 65 73 74 73 2c 20 6c 65 74   more tests, let
3570: 73 20 74 61 6b 65 20 61 20 62 72 65 61 74 68 65  s take a breathe
3580: 72 0a 09 09 20 20 28 74 68 72 65 61 64 2d 73 6c  r...  (thread-sl
3590: 65 65 70 21 20 31 29 0a 09 09 20 20 28 6c 6f 6f  eep! 1)...  (loo
35a0: 70 20 28 63 61 72 20 6e 65 77 74 61 6c 29 28 63  p (car newtal)(c
35b0: 64 72 20 6e 65 77 74 61 6c 29 29 29 29 29 0a 0a  dr newtal)))))..
35c0: 09 20 20 20 3b 3b 20 74 68 69 73 20 63 61 73 65  .   ;; this case
35d0: 20 73 68 6f 75 6c 64 20 6e 6f 74 20 68 61 70 70   should not happ
35e0: 65 6e 2c 20 61 64 64 65 64 20 74 6f 20 68 65 6c  en, added to hel
35f0: 70 20 63 61 74 63 68 20 61 6e 79 20 62 75 67 73  p catch any bugs
3600: 0a 09 20 20 20 28 28 61 6e 64 20 28 6c 69 73 74  ..   ((and (list
3610: 3f 20 69 74 65 6d 73 29 20 69 74 65 6d 64 61 74  ? items) itemdat
3620: 29 0a 09 20 20 20 20 28 64 65 62 75 67 3a 70 72  )..    (debug:pr
3630: 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 53 68  int 0 "ERROR: Sh
3640: 6f 75 6c 64 20 6e 6f 74 20 68 61 76 65 20 61 20  ould not have a 
3650: 6c 69 73 74 20 6f 66 20 69 74 65 6d 73 20 69 6e  list of items in
3660: 20 61 20 74 65 73 74 20 61 6e 64 20 74 68 65 20   a test and the 
3670: 69 74 65 6d 73 70 61 74 68 20 73 65 74 20 2d 20  itemspath set - 
3680: 70 6c 65 61 73 65 20 72 65 70 6f 72 74 20 74 68  please report th
3690: 69 73 22 29 0a 09 20 20 20 20 28 65 78 69 74 20  is")..    (exit 
36a0: 31 29 29 29 0a 09 20 20 0a 09 20 20 3b 3b 20 77  1)))..  ..  ;; w
36b0: 65 20 67 65 74 20 68 65 72 65 20 6f 6e 20 22 64  e get here on "d
36c0: 72 6f 70 20 74 68 72 6f 75 67 68 22 20 2d 20 6c  rop through" - l
36d0: 6f 6f 70 20 66 6f 72 20 6e 65 78 74 20 74 65 73  oop for next tes
36e0: 74 20 69 6e 20 71 75 65 75 65 0a 09 20 20 28 69  t in queue..  (i
36f0: 66 20 28 6e 75 6c 6c 3f 20 74 61 6c 29 0a 09 20  f (null? tal).. 
3700: 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e       (debug:prin
3710: 74 20 31 20 22 49 4e 46 4f 3a 20 41 6c 6c 20 74  t 1 "INFO: All t
3720: 65 73 74 73 20 6c 61 75 6e 63 68 65 64 22 29 0a  ests launched").
3730: 09 20 20 20 20 20 20 28 6c 6f 6f 70 20 28 63 61  .      (loop (ca
3740: 72 20 74 61 6c 29 28 63 64 72 20 74 61 6c 29 29  r tal)(cdr tal))
3750: 29 29 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28  )))))..(define (
3760: 72 75 6e 3a 74 65 73 74 20 64 62 20 72 75 6e 2d  run:test db run-
3770: 69 64 20 72 75 6e 6e 61 6d 65 20 6b 65 79 76 61  id runname keyva
3780: 6c 6c 73 74 20 74 65 73 74 2d 72 65 63 6f 72 64  llst test-record
3790: 20 66 6c 61 67 73 29 0a 20 20 28 64 65 62 75 67   flags).  (debug
37a0: 3a 70 72 69 6e 74 20 31 20 22 4c 61 75 6e 63 68  :print 1 "Launch
37b0: 69 6e 67 20 74 65 73 74 20 22 20 74 65 73 74 2d  ing test " test-
37c0: 6e 61 6d 65 29 0a 20 20 3b 3b 20 41 6c 6c 20 74  name).  ;; All t
37d0: 68 65 73 65 20 76 61 72 73 20 6d 69 67 68 74 20  hese vars might 
37e0: 62 65 20 72 65 66 65 72 65 6e 63 65 64 20 62 79  be referenced by
37f0: 20 74 68 65 20 74 65 73 74 63 6f 6e 66 69 67 20   the testconfig 
3800: 66 69 6c 65 20 72 65 61 64 65 72 0a 20 20 28 73  file reader.  (s
3810: 65 74 65 6e 76 20 22 4d 54 5f 54 45 53 54 5f 4e  etenv "MT_TEST_N
3820: 41 4d 45 22 20 74 65 73 74 2d 6e 61 6d 65 29 20  AME" test-name) 
3830: 3b 3b 20 0a 20 20 28 73 65 74 65 6e 76 20 22 4d  ;; .  (setenv "M
3840: 54 5f 52 55 4e 4e 41 4d 45 22 20 20 20 72 75 6e  T_RUNNAME"   run
3850: 6e 61 6d 65 29 0a 20 20 28 73 65 74 2d 6d 65 67  name).  (set-meg
3860: 61 74 65 73 74 2d 65 6e 76 2d 76 61 72 73 20 64  atest-env-vars d
3870: 62 20 72 75 6e 2d 69 64 29 20 3b 3b 20 74 68 65  b run-id) ;; the
3880: 73 65 20 6d 61 79 20 62 65 20 6e 65 65 64 65 64  se may be needed
3890: 20 62 79 20 74 68 65 20 6c 61 75 6e 63 68 69 6e   by the launchin
38a0: 67 20 70 72 6f 63 65 73 73 0a 20 20 28 63 68 61  g process.  (cha
38b0: 6e 67 65 2d 64 69 72 65 63 74 6f 72 79 20 2a 74  nge-directory *t
38c0: 6f 70 70 61 74 68 2a 29 0a 20 20 28 6c 65 74 2a  oppath*).  (let*
38d0: 20 28 28 74 65 73 74 2d 6e 61 6d 65 20 20 20 20   ((test-name    
38e0: 28 74 65 73 74 73 3a 74 65 73 74 71 75 65 75 65  (tests:testqueue
38f0: 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 74 65  -get-testname te
3900: 73 74 2d 72 65 63 6f 72 64 29 29 0a 09 20 28 74  st-record)).. (t
3910: 65 73 74 2d 70 61 74 68 20 20 20 20 28 63 6f 6e  est-path    (con
3920: 63 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f 74 65  c *toppath* "/te
3930: 73 74 73 2f 22 20 74 65 73 74 2d 6e 61 6d 65 29  sts/" test-name)
3940: 29 20 3b 3b 20 63 6f 75 6c 64 20 75 73 65 20 74  ) ;; could use t
3950: 65 73 74 3a 67 65 74 2d 74 65 73 74 63 6f 6e 66  est:get-testconf
3960: 69 67 20 68 65 72 65 20 2e 2e 2e 0a 09 20 28 74  ig here ..... (t
3970: 65 73 74 2d 63 6f 6e 66 20 20 20 20 28 74 65 73  est-conf    (tes
3980: 74 73 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74  ts:testqueue-get
3990: 2d 74 65 73 74 63 6f 6e 66 69 67 20 74 65 73 74  -testconfig test
39a0: 2d 72 65 63 6f 72 64 29 29 0a 09 20 28 69 74 65  -record)).. (ite
39b0: 6d 64 61 74 20 20 20 20 20 20 28 74 65 73 74 73  mdat      (tests
39c0: 3a 74 65 73 74 71 75 65 75 65 2d 67 65 74 2d 69  :testqueue-get-i
39d0: 74 65 6d 64 61 74 20 20 20 20 74 65 73 74 2d 72  temdat    test-r
39e0: 65 63 6f 72 64 29 29 0a 09 20 28 66 6f 72 63 65  ecord)).. (force
39f0: 20 20 20 20 20 20 20 20 28 68 61 73 68 2d 74 61          (hash-ta
3a00: 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20  ble-ref/default 
3a10: 66 6c 61 67 73 20 22 2d 66 6f 72 63 65 22 20 23  flags "-force" #
3a20: 66 29 29 0a 09 20 28 72 65 72 75 6e 20 20 20 20  f)).. (rerun    
3a30: 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d      (hash-table-
3a40: 72 65 66 2f 64 65 66 61 75 6c 74 20 66 6c 61 67  ref/default flag
3a50: 73 20 22 2d 72 65 72 75 6e 22 20 23 66 29 29 0a  s "-rerun" #f)).
3a60: 09 20 28 6b 65 65 70 67 6f 69 6e 67 20 20 20 20  . (keepgoing    
3a70: 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f  (hash-table-ref/
3a80: 64 65 66 61 75 6c 74 20 66 6c 61 67 73 20 22 2d  default flags "-
3a90: 6b 65 65 70 67 6f 69 6e 67 22 20 23 66 29 29 29  keepgoing" #f)))
3aa0: 0a 0a 20 20 20 20 3b 3b 20 48 65 72 65 20 69 73  ..    ;; Here is
3ab0: 20 77 68 65 72 65 20 74 68 65 20 74 65 73 74 5f   where the test_
3ac0: 6d 65 74 61 20 74 61 62 6c 65 20 69 73 20 62 65  meta table is be
3ad0: 73 74 20 75 70 64 61 74 65 64 0a 20 20 20 20 28  st updated.    (
3ae0: 72 75 6e 73 3a 75 70 64 61 74 65 2d 74 65 73 74  runs:update-test
3af0: 5f 6d 65 74 61 20 64 62 20 74 65 73 74 2d 6e 61  _meta db test-na
3b00: 6d 65 20 74 65 73 74 2d 63 6f 6e 66 29 0a 20 20  me test-conf).  
3b10: 20 20 0a 20 20 20 20 3b 3b 20 28 6c 61 6d 62 64    .    ;; (lambd
3b20: 61 20 28 69 74 65 6d 64 61 74 29 20 3b 3b 3b 20  a (itemdat) ;;; 
3b30: 28 28 72 69 70 65 6e 65 73 73 20 22 6f 76 65 72  ((ripeness "over
3b40: 72 69 70 65 22 29 20 28 74 65 6d 70 65 72 61 74  ripe") (temperat
3b50: 75 72 65 20 22 63 6f 6f 6c 22 29 20 28 73 65 61  ure "cool") (sea
3b60: 73 6f 6e 20 22 73 75 6d 6d 65 72 22 29 29 0a 20  son "summer")). 
3b70: 20 20 20 28 6c 65 74 2a 20 28 28 69 74 65 6d 2d     (let* ((item-
3b80: 70 61 74 68 20 20 20 20 20 28 69 74 65 6d 2d 6c  path     (item-l
3b90: 69 73 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61  ist->path itemda
3ba0: 74 29 29 20 3b 3b 20 28 73 74 72 69 6e 67 2d 69  t)) ;; (string-i
3bb0: 6e 74 65 72 73 70 65 72 73 65 20 28 6d 61 70 20  ntersperse (map 
3bc0: 63 61 64 72 20 69 74 65 6d 64 61 74 29 20 22 2f  cadr itemdat) "/
3bd0: 22 29 29 0a 09 20 20 20 28 6e 65 77 2d 74 65 73  "))..   (new-tes
3be0: 74 2d 70 61 74 68 20 28 73 74 72 69 6e 67 2d 69  t-path (string-i
3bf0: 6e 74 65 72 73 70 65 72 73 65 20 28 63 6f 6e 73  ntersperse (cons
3c00: 20 74 65 73 74 2d 70 61 74 68 20 28 6d 61 70 20   test-path (map 
3c10: 63 61 64 72 20 69 74 65 6d 64 61 74 29 29 20 22  cadr itemdat)) "
3c20: 2f 22 29 29 0a 09 20 20 20 28 6e 65 77 2d 74 65  /"))..   (new-te
3c30: 73 74 2d 6e 61 6d 65 20 28 69 66 20 28 65 71 75  st-name (if (equ
3c40: 61 6c 3f 20 69 74 65 6d 2d 70 61 74 68 20 22 22  al? item-path ""
3c50: 29 20 74 65 73 74 2d 6e 61 6d 65 20 28 63 6f 6e  ) test-name (con
3c60: 63 20 74 65 73 74 2d 6e 61 6d 65 20 22 2f 22 20  c test-name "/" 
3c70: 69 74 65 6d 2d 70 61 74 68 29 29 29 20 3b 3b 20  item-path))) ;; 
3c80: 6a 75 73 74 20 6e 65 65 64 20 69 74 20 74 6f 20  just need it to 
3c90: 62 65 20 75 6e 69 71 75 65 0a 09 20 20 20 28 74  be unique..   (t
3ca0: 65 73 74 64 61 74 20 20 20 20 20 20 20 23 66 29  estdat       #f)
3cb0: 0a 09 20 20 20 28 74 65 73 74 2d 69 6e 66 6f 20  ..   (test-info 
3cc0: 28 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66  (db:get-test-inf
3cd0: 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  o db run-id test
3ce0: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  -name item-path)
3cf0: 29 29 0a 20 20 20 20 20 20 28 69 66 20 28 6e 6f  )).      (if (no
3d00: 74 20 74 65 73 74 2d 69 6e 66 6f 29 28 72 65 67  t test-info)(reg
3d10: 69 73 74 65 72 2d 74 65 73 74 20 64 62 20 72 75  ister-test db ru
3d20: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69  n-id test-name i
3d30: 74 65 6d 2d 70 61 74 68 29 29 0a 20 20 20 20 20  tem-path)).     
3d40: 20 28 63 68 61 6e 67 65 2d 64 69 72 65 63 74 6f   (change-directo
3d50: 72 79 20 74 65 73 74 2d 70 61 74 68 29 0a 20 20  ry test-path).  
3d60: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
3d70: 20 34 20 22 72 75 6e 2d 69 64 3a 20 22 20 72 75   4 "run-id: " ru
3d80: 6e 2d 69 64 20 22 20 74 65 73 74 2d 6e 61 6d 65  n-id " test-name
3d90: 3a 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20  : " test-name " 
3da0: 69 74 65 6d 2d 70 61 74 68 3a 20 22 20 69 74 65  item-path: " ite
3db0: 6d 2d 70 61 74 68 20 22 20 74 65 73 74 64 61 74  m-path " testdat
3dc0: 3a 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74  : " (test:get-st
3dd0: 61 74 75 73 20 74 65 73 74 64 61 74 29 20 22 20  atus testdat) " 
3de0: 74 65 73 74 2d 73 74 61 74 65 3a 20 22 20 28 74  test-state: " (t
3df0: 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65  est:get-state te
3e00: 73 74 64 61 74 29 29 0a 20 20 20 20 20 20 28 63  stdat)).      (c
3e10: 61 73 65 20 28 69 66 20 66 6f 72 63 65 20 3b 3b  ase (if force ;;
3e20: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22   (args:get-arg "
3e30: 2d 66 6f 72 63 65 22 29 0a 09 09 27 4e 4f 54 5f  -force")...'NOT_
3e40: 53 54 41 52 54 45 44 0a 09 09 28 69 66 20 74 65  STARTED...(if te
3e50: 73 74 64 61 74 0a 09 09 20 20 20 20 28 73 74 72  stdat...    (str
3e60: 69 6e 67 2d 3e 73 79 6d 62 6f 6c 20 28 74 65 73  ing->symbol (tes
3e70: 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74  t:get-state test
3e80: 64 61 74 29 29 0a 09 09 20 20 20 20 27 66 61 69  dat))...    'fai
3e90: 6c 65 64 2d 74 6f 2d 69 6e 73 65 72 74 29 29 0a  led-to-insert)).
3ea0: 09 28 28 66 61 69 6c 65 64 2d 74 6f 2d 69 6e 73  .((failed-to-ins
3eb0: 65 72 74 29 0a 09 20 28 64 65 62 75 67 3a 70 72  ert).. (debug:pr
3ec0: 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 46 61  int 0 "ERROR: Fa
3ed0: 69 6c 65 64 20 74 6f 20 69 6e 73 65 72 74 20 74  iled to insert t
3ee0: 68 65 20 72 65 63 6f 72 64 20 69 6e 74 6f 20 74  he record into t
3ef0: 68 65 20 64 62 22 29 29 0a 09 28 28 4e 4f 54 5f  he db"))..((NOT_
3f00: 53 54 41 52 54 45 44 20 43 4f 4d 50 4c 45 54 45  STARTED COMPLETE
3f10: 44 29 0a 09 20 28 64 65 62 75 67 3a 70 72 69 6e  D).. (debug:prin
3f20: 74 20 36 20 22 47 6f 74 20 68 65 72 65 2c 20 22  t 6 "Got here, "
3f30: 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65   (test:get-state
3f40: 20 74 65 73 74 64 61 74 29 29 0a 09 20 28 6c 65   testdat)).. (le
3f50: 74 20 28 28 72 75 6e 66 6c 61 67 20 23 66 29 29  t ((runflag #f))
3f60: 0a 09 20 20 20 28 63 6f 6e 64 0a 09 20 20 20 20  ..   (cond..    
3f70: 3b 3b 20 2d 66 6f 72 63 65 2c 20 72 75 6e 20 6e  ;; -force, run n
3f80: 6f 20 6d 61 74 74 65 72 20 77 68 61 74 0a 09 20  o matter what.. 
3f90: 20 20 20 28 66 6f 72 63 65 20 28 73 65 74 21 20     (force (set! 
3fa0: 72 75 6e 66 6c 61 67 20 23 74 29 29 0a 09 20 20  runflag #t))..  
3fb0: 20 20 3b 3b 20 4e 4f 54 5f 53 54 41 52 54 45 44    ;; NOT_STARTED
3fc0: 2c 20 72 75 6e 20 6e 6f 20 6d 61 74 74 65 72 20  , run no matter 
3fd0: 77 68 61 74 0a 09 20 20 20 20 28 28 65 71 75 61  what..    ((equa
3fe0: 6c 3f 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61  l? (test:get-sta
3ff0: 74 65 20 74 65 73 74 64 61 74 29 20 22 4e 4f 54  te testdat) "NOT
4000: 5f 53 54 41 52 54 45 44 22 29 28 73 65 74 21 20  _STARTED")(set! 
4010: 72 75 6e 66 6c 61 67 20 23 74 29 29 0a 09 20 20  runflag #t))..  
4020: 20 20 3b 3b 20 6e 6f 74 20 2d 72 65 72 75 6e 20    ;; not -rerun 
4030: 61 6e 64 20 50 41 53 53 2c 20 57 41 52 4e 20 6f  and PASS, WARN o
4040: 72 20 43 48 45 43 4b 2c 20 64 6f 20 6e 6f 20 72  r CHECK, do no r
4050: 75 6e 0a 09 20 20 20 20 28 28 61 6e 64 20 28 6f  un..    ((and (o
4060: 72 20 28 6e 6f 74 20 72 65 72 75 6e 29 0a 09 09  r (not rerun)...
4070: 20 20 20 20 20 20 6b 65 65 70 67 6f 69 6e 67 29        keepgoing)
4080: 0a 09 09 20 20 28 6d 65 6d 62 65 72 20 28 74 65  ...  (member (te
4090: 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65  st:get-status te
40a0: 73 74 64 61 74 29 20 27 28 22 50 41 53 53 22 20  stdat) '("PASS" 
40b0: 22 57 41 52 4e 22 20 22 43 48 45 43 4b 22 29 29  "WARN" "CHECK"))
40c0: 29 0a 09 20 20 20 20 20 28 73 65 74 21 20 72 75  )..     (set! ru
40d0: 6e 66 6c 61 67 20 23 66 29 29 0a 09 20 20 20 20  nflag #f))..    
40e0: 3b 3b 20 2d 72 65 72 75 6e 20 61 6e 64 20 73 74  ;; -rerun and st
40f0: 61 74 75 73 20 69 73 20 6f 6e 65 20 6f 66 20 74  atus is one of t
4100: 68 65 20 73 70 65 63 69 66 65 64 2c 20 72 75 6e  he specifed, run
4110: 20 69 74 0a 09 20 20 20 20 28 28 61 6e 64 20 72   it..    ((and r
4120: 65 72 75 6e 0a 09 09 20 20 28 6c 65 74 20 28 28  erun...  (let ((
4130: 72 65 72 75 6e 6c 73 74 20 28 73 74 72 69 6e 67  rerunlst (string
4140: 2d 73 70 6c 69 74 20 72 65 72 75 6e 20 22 2c 22  -split rerun ","
4150: 29 29 29 20 3b 3b 20 46 41 49 4c 2c 0a 09 09 20  ))) ;; FAIL,... 
4160: 20 20 20 28 6d 65 6d 62 65 72 20 28 74 65 73 74     (member (test
4170: 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74  :get-status test
4180: 64 61 74 29 20 72 65 72 75 6e 6c 73 74 29 29 29  dat) rerunlst)))
4190: 0a 09 20 20 20 20 20 28 73 65 74 21 20 72 75 6e  ..     (set! run
41a0: 66 6c 61 67 20 23 74 29 29 0a 09 20 20 20 20 3b  flag #t))..    ;
41b0: 3b 20 2d 6b 65 65 70 67 6f 69 6e 67 2c 20 64 6f  ; -keepgoing, do
41c0: 20 6e 6f 74 20 72 65 72 75 6e 20 46 41 49 4c 0a   not rerun FAIL.
41d0: 09 20 20 20 20 28 28 61 6e 64 20 6b 65 65 70 67  .    ((and keepg
41e0: 6f 69 6e 67 0a 09 09 20 20 28 6d 65 6d 62 65 72  oing...  (member
41f0: 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75   (test:get-statu
4200: 73 20 74 65 73 74 64 61 74 29 20 27 28 22 46 41  s testdat) '("FA
4210: 49 4c 22 29 29 29 0a 09 20 20 20 20 20 28 73 65  IL")))..     (se
4220: 74 21 20 72 75 6e 66 6c 61 67 20 23 66 29 29 0a  t! runflag #f)).
4230: 09 20 20 20 20 28 28 61 6e 64 20 28 6e 6f 74 20  .    ((and (not 
4240: 72 65 72 75 6e 29 0a 09 09 20 20 28 6d 65 6d 62  rerun)...  (memb
4250: 65 72 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61  er (test:get-sta
4260: 74 75 73 20 74 65 73 74 64 61 74 29 20 27 28 22  tus testdat) '("
4270: 46 41 49 4c 22 20 22 6e 2f 61 22 29 29 29 0a 09  FAIL" "n/a")))..
4280: 20 20 20 20 20 28 73 65 74 21 20 72 75 6e 66 6c       (set! runfl
4290: 61 67 20 23 74 29 29 0a 09 20 20 20 20 28 65 6c  ag #t))..    (el
42a0: 73 65 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67  se (set! runflag
42b0: 20 23 66 29 29 29 0a 09 20 20 20 28 64 65 62 75   #f)))..   (debu
42c0: 67 3a 70 72 69 6e 74 20 36 20 22 52 55 4e 4e 49  g:print 6 "RUNNI
42d0: 4e 47 20 3d 3e 20 72 75 6e 66 6c 61 67 3a 20 22  NG => runflag: "
42e0: 20 72 75 6e 66 6c 61 67 20 22 20 53 54 41 54 45   runflag " STATE
42f0: 3a 20 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74  : " (test:get-st
4300: 61 74 65 20 74 65 73 74 64 61 74 29 20 22 20 53  ate testdat) " S
4310: 54 41 54 55 53 3a 20 22 20 28 74 65 73 74 3a 67  TATUS: " (test:g
4320: 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61  et-status testda
4330: 74 29 29 0a 09 20 20 20 28 69 66 20 28 6e 6f 74  t))..   (if (not
4340: 20 72 75 6e 66 6c 61 67 29 0a 09 20 20 20 20 20   runflag)..     
4350: 20 20 28 69 66 20 28 6e 6f 74 20 70 61 72 65 6e    (if (not paren
4360: 74 2d 74 65 73 74 29 0a 09 09 20 20 20 28 64 65  t-test)...   (de
4370: 62 75 67 3a 70 72 69 6e 74 20 31 20 22 4e 4f 54  bug:print 1 "NOT
4380: 45 3a 20 4e 6f 74 20 73 74 61 72 74 69 6e 67 20  E: Not starting 
4390: 74 65 73 74 20 22 20 6e 65 77 2d 74 65 73 74 2d  test " new-test-
43a0: 6e 61 6d 65 20 22 20 61 73 20 69 74 20 69 73 20  name " as it is 
43b0: 73 74 61 74 65 20 5c 22 43 4f 4d 50 4c 45 54 45  state \"COMPLETE
43c0: 44 5c 22 20 61 6e 64 20 73 74 61 74 75 73 20 5c  D\" and status \
43d0: 22 22 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61  "" (test:get-sta
43e0: 74 75 73 20 74 65 73 74 64 61 74 29 20 22 5c 22  tus testdat) "\"
43f0: 2c 20 75 73 65 20 2d 66 6f 72 63 65 20 74 6f 20  , use -force to 
4400: 6f 76 65 72 72 69 64 65 22 29 29 0a 09 20 20 20  override"))..   
4410: 20 20 20 20 28 6c 65 74 2a 20 28 28 67 65 74 2d      (let* ((get-
4420: 70 72 65 72 65 71 73 2d 63 6d 64 20 28 6c 61 6d  prereqs-cmd (lam
4430: 62 64 61 20 28 29 0a 09 09 09 09 09 20 28 64 62  bda ()...... (db
4440: 2d 67 65 74 2d 70 72 65 72 65 71 73 2d 6e 6f 74  -get-prereqs-not
4450: 2d 6d 65 74 20 64 62 20 72 75 6e 2d 69 64 20 77  -met db run-id w
4460: 61 69 74 6f 6e 29 29 29 20 3b 3b 20 63 68 65 63  aiton))) ;; chec
4470: 6b 20 62 65 66 6f 72 65 20 72 75 6e 6e 69 6e 67  k before running
4480: 20 2e 2e 2e 2e 0a 09 09 20 20 20 20 20 20 28 6c   .......      (l
4490: 61 75 6e 63 68 2d 63 6d 64 20 20 20 20 20 20 28  aunch-cmd      (
44a0: 6c 61 6d 62 64 61 20 28 29 0a 09 09 09 09 09 20  lambda ()...... 
44b0: 28 6c 61 75 6e 63 68 2d 74 65 73 74 20 64 62 20  (launch-test db 
44c0: 72 75 6e 2d 69 64 20 72 75 6e 6e 61 6d 65 20 74  run-id runname t
44d0: 65 73 74 2d 63 6f 6e 66 20 6b 65 79 76 61 6c 6c  est-conf keyvall
44e0: 73 74 20 74 65 73 74 2d 6e 61 6d 65 20 74 65 73  st test-name tes
44f0: 74 2d 70 61 74 68 20 69 74 65 6d 64 61 74 20 66  t-path itemdat f
4500: 6c 61 67 73 29 29 29 0a 09 09 20 20 20 20 20 20  lags)))...      
4510: 28 74 65 73 74 72 75 6e 64 61 74 20 20 20 20 20  (testrundat     
4520: 20 28 6c 69 73 74 20 67 65 74 2d 70 72 65 72 65   (list get-prere
4530: 71 73 2d 63 6d 64 20 6c 61 75 6e 63 68 2d 63 6d  qs-cmd launch-cm
4540: 64 29 29 29 0a 09 09 20 28 69 66 20 28 6f 72 20  d)))... (if (or 
4550: 66 6f 72 63 65 0a 09 09 09 20 28 6c 65 74 20 28  force.... (let (
4560: 28 70 72 65 71 73 2d 6e 6f 74 2d 79 65 74 2d 6d  (preqs-not-yet-m
4570: 65 74 20 28 28 63 61 72 20 74 65 73 74 72 75 6e  et ((car testrun
4580: 64 61 74 29 29 29 29 0a 09 09 09 20 20 20 28 64  dat))))....   (d
4590: 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 50 72  ebug:print 2 "Pr
45a0: 65 71 72 65 71 75 65 73 69 74 65 73 20 66 6f 72  eqrequesites for
45b0: 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 3a 20   " test-name ": 
45c0: 22 20 70 72 65 71 73 2d 6e 6f 74 2d 79 65 74 2d  " preqs-not-yet-
45d0: 6d 65 74 29 0a 09 09 09 20 20 20 28 6e 75 6c 6c  met)....   (null
45e0: 3f 20 70 72 65 71 73 2d 6e 6f 74 2d 79 65 74 2d  ? preqs-not-yet-
45f0: 6d 65 74 29 29 29 20 3b 3b 20 61 72 65 20 74 68  met))) ;; are th
4600: 65 72 65 20 61 6e 79 20 74 65 73 74 73 20 74 68  ere any tests th
4610: 61 74 20 6d 75 73 74 20 62 65 20 72 75 6e 20 62  at must be run b
4620: 65 66 6f 72 65 20 74 68 69 73 20 6f 6e 65 2e 2e  efore this one..
4630: 2e 0a 09 09 20 20 20 20 20 28 69 66 20 28 6e 6f  ....     (if (no
4640: 74 20 28 28 63 61 64 72 20 74 65 73 74 72 75 6e  t ((cadr testrun
4650: 64 61 74 29 29 29 20 3b 3b 20 74 68 69 73 20 69  dat))) ;; this i
4660: 73 20 74 68 65 20 6c 69 6e 65 20 74 68 61 74 20  s the line that 
4670: 6c 61 75 6e 63 68 65 73 20 74 68 65 20 74 65 73  launches the tes
4680: 74 20 74 6f 20 74 68 65 20 72 65 6d 6f 74 65 20  t to the remote 
4690: 68 6f 73 74 0a 09 09 09 20 28 62 65 67 69 6e 0a  host.... (begin.
46a0: 09 09 09 20 20 20 28 70 72 69 6e 74 20 22 45 52  ...   (print "ER
46b0: 52 4f 52 3a 20 46 61 69 6c 65 64 20 74 6f 20 6c  ROR: Failed to l
46c0: 61 75 6e 63 68 20 74 68 65 20 74 65 73 74 2e 20  aunch the test. 
46d0: 45 78 69 74 69 6e 67 20 61 73 20 73 6f 6f 6e 20  Exiting as soon 
46e0: 61 73 20 70 6f 73 73 69 62 6c 65 22 29 0a 09 09  as possible")...
46f0: 09 20 20 20 28 73 65 74 21 20 2a 67 6c 6f 62 61  .   (set! *globa
4700: 6c 65 78 69 74 73 74 61 74 75 73 2a 20 31 29 20  lexitstatus* 1) 
4710: 3b 3b 20 0a 09 09 09 20 20 20 28 70 72 6f 63 65  ;; ....   (proce
4720: 73 73 2d 73 69 67 6e 61 6c 20 28 63 75 72 72 65  ss-signal (curre
4730: 6e 74 2d 70 72 6f 63 65 73 73 2d 69 64 29 20 73  nt-process-id) s
4740: 69 67 6e 61 6c 2f 6b 69 6c 6c 29 0a 09 09 09 09  ignal/kill).....
4750: 09 3b 28 65 78 69 74 20 31 29 0a 09 09 09 20 20  .;(exit 1)....  
4760: 20 29 29 0a 09 09 20 20 20 20 20 28 69 66 20 28   ))...     (if (
4770: 6e 6f 74 20 6b 65 65 70 67 6f 69 6e 67 29 0a 09  not keepgoing)..
4780: 09 09 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73  .. (hash-table-s
4790: 65 74 21 20 2a 77 61 69 74 69 6e 67 2d 71 75 65  et! *waiting-que
47a0: 75 65 2a 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d  ue* new-test-nam
47b0: 65 20 74 65 73 74 72 75 6e 64 61 74 29 29 29 29  e testrundat))))
47c0: 29 29 29 0a 09 28 28 4b 49 4c 4c 45 44 29 20 0a  )))..((KILLED) .
47d0: 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31  . (debug:print 1
47e0: 20 22 4e 4f 54 45 3a 20 22 20 6e 65 77 2d 74 65   "NOTE: " new-te
47f0: 73 74 2d 6e 61 6d 65 20 22 20 69 73 20 61 6c 72  st-name " is alr
4800: 65 61 64 79 20 72 75 6e 6e 69 6e 67 20 6f 72 20  eady running or 
4810: 77 61 73 20 65 78 70 6c 69 63 74 6c 79 20 6b 69  was explictly ki
4820: 6c 6c 65 64 2c 20 75 73 65 20 2d 66 6f 72 63 65  lled, use -force
4830: 20 74 6f 20 6c 61 75 6e 63 68 20 69 74 2e 22 29   to launch it.")
4840: 29 0a 09 28 28 4c 41 55 4e 43 48 45 44 20 52 45  )..((LAUNCHED RE
4850: 4d 4f 54 45 48 4f 53 54 53 54 41 52 54 20 52 55  MOTEHOSTSTART RU
4860: 4e 4e 49 4e 47 29 20 20 0a 09 20 28 69 66 20 28  NNING)  .. (if (
4870: 3e 20 28 2d 20 28 63 75 72 72 65 6e 74 2d 73 65  > (- (current-se
4880: 63 6f 6e 64 73 29 28 2b 20 28 64 62 3a 74 65 73  conds)(+ (db:tes
4890: 74 2d 67 65 74 2d 65 76 65 6e 74 5f 74 69 6d 65  t-get-event_time
48a0: 20 74 65 73 74 64 61 74 29 0a 09 09 09 09 20 20   testdat).....  
48b0: 20 20 20 20 20 28 64 62 3a 74 65 73 74 2d 67 65       (db:test-ge
48c0: 74 2d 72 75 6e 5f 64 75 72 61 74 69 6f 6e 20 74  t-run_duration t
48d0: 65 73 74 64 61 74 29 29 29 0a 09 09 36 30 30 29  estdat)))...600)
48e0: 20 3b 3b 20 69 2e 65 2e 20 6e 6f 20 75 70 64 61   ;; i.e. no upda
48f0: 74 65 20 66 6f 72 20 6d 6f 72 65 20 74 68 61 6e  te for more than
4900: 20 36 30 30 20 73 65 63 6f 6e 64 73 0a 09 20 20   600 seconds..  
4910: 20 20 20 28 62 65 67 69 6e 0a 09 20 20 20 20 20     (begin..     
4920: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30    (debug:print 0
4930: 20 22 57 41 52 4e 49 4e 47 3a 20 54 65 73 74 20   "WARNING: Test 
4940: 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 61 70  " test-name " ap
4950: 70 65 61 72 73 20 74 6f 20 62 65 20 64 65 61 64  pears to be dead
4960: 2e 20 46 6f 72 63 69 6e 67 20 69 74 20 74 6f 20  . Forcing it to 
4970: 73 74 61 74 65 20 49 4e 43 4f 4d 50 4c 45 54 45  state INCOMPLETE
4980: 20 61 6e 64 20 73 74 61 74 75 73 20 53 54 55 43   and status STUC
4990: 4b 2f 44 45 41 44 22 29 0a 09 20 20 20 20 20 20  K/DEAD")..      
49a0: 20 28 74 65 73 74 2d 73 65 74 2d 73 74 61 74 75   (test-set-statu
49b0: 73 21 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  s! db run-id tes
49c0: 74 2d 6e 61 6d 65 20 22 49 4e 43 4f 4d 50 4c 45  t-name "INCOMPLE
49d0: 54 45 22 20 22 53 54 55 43 4b 2f 44 45 41 44 22  TE" "STUCK/DEAD"
49e0: 20 69 74 65 6d 64 61 74 20 22 54 65 73 74 20 69   itemdat "Test i
49f0: 73 20 73 74 75 63 6b 20 6f 72 20 64 65 61 64 22  s stuck or dead"
4a00: 20 23 66 29 29 0a 09 20 20 20 20 20 28 64 65 62   #f))..     (deb
4a10: 75 67 3a 70 72 69 6e 74 20 32 20 22 4e 4f 54 45  ug:print 2 "NOTE
4a20: 3a 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 22 20  : " test-name " 
4a30: 69 73 20 61 6c 72 65 61 64 79 20 72 75 6e 6e 69  is already runni
4a40: 6e 67 22 29 29 29 0a 09 28 65 6c 73 65 20 20 20  ng")))..(else   
4a50: 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74      (debug:print
4a60: 20 30 20 22 45 52 52 4f 52 3a 20 46 61 69 6c 65   0 "ERROR: Faile
4a70: 64 20 74 6f 20 6c 61 75 6e 63 68 20 74 65 73 74  d to launch test
4a80: 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65   " new-test-name
4a90: 20 22 2e 20 55 6e 72 65 63 6f 67 6e 69 73 65 64   ". Unrecognised
4aa0: 20 73 74 61 74 65 20 22 20 28 74 65 73 74 3a 67   state " (test:g
4ab0: 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 74  et-state testdat
4ac0: 29 29 29 29 29 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d  )))))))..;;=====
4ad0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
4ae0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
4af0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
4b00: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
4b10: 3d 0a 3b 3b 20 45 4e 44 20 4f 46 20 4e 45 57 20  =.;; END OF NEW 
4b20: 53 54 55 46 46 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d  STUFF.;;========
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 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a  ==============..
4b70: 28 64 65 66 69 6e 65 20 28 67 65 74 2d 64 69 72  (define (get-dir
4b80: 2d 75 70 2d 6e 20 64 69 72 20 2e 20 70 61 72 61  -up-n dir . para
4b90: 6d 73 29 20 0a 20 20 28 6c 65 74 20 28 28 64 70  ms) .  (let ((dp
4ba0: 61 72 74 73 20 20 28 73 74 72 69 6e 67 2d 73 70  arts  (string-sp
4bb0: 6c 69 74 20 64 69 72 20 22 2f 22 29 29 0a 09 28  lit dir "/"))..(
4bc0: 63 6f 75 6e 74 20 20 20 28 69 66 20 28 6e 75 6c  count   (if (nul
4bd0: 6c 3f 20 70 61 72 61 6d 73 29 20 31 20 28 63 61  l? params) 1 (ca
4be0: 72 20 70 61 72 61 6d 73 29 29 29 29 0a 20 20 20  r params)))).   
4bf0: 20 28 63 6f 6e 63 20 22 2f 22 20 28 73 74 72 69   (conc "/" (stri
4c00: 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 0a  ng-intersperse .
4c10: 09 20 20 20 20 20 20 20 28 74 61 6b 65 20 64 70  .       (take dp
4c20: 61 72 74 73 20 28 2d 20 28 6c 65 6e 67 74 68 20  arts (- (length 
4c30: 64 70 61 72 74 73 29 20 63 6f 75 6e 74 29 29 0a  dparts) count)).
4c40: 09 20 20 20 20 20 20 20 22 2f 22 29 29 29 29 0a  .       "/")))).
4c50: 3b 3b 20 52 65 6d 6f 76 65 20 72 75 6e 73 0a 3b  ;; Remove runs.;
4c60: 3b 20 66 69 65 6c 64 73 20 61 72 65 20 70 61 73  ; fields are pas
4c70: 73 69 6e 67 20 69 6e 20 74 68 72 6f 75 67 68 20  sing in through 
4c80: 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 72  .(define (runs:r
4c90: 65 6d 6f 76 65 2d 72 75 6e 73 20 64 62 20 72 75  emove-runs db ru
4ca0: 6e 6e 61 6d 65 70 61 74 74 20 74 65 73 74 70 61  nnamepatt testpa
4cb0: 74 74 20 69 74 65 6d 70 61 74 74 29 0a 20 20 28  tt itempatt).  (
4cc0: 6c 65 74 2a 20 28 28 6b 65 79 73 20 20 20 20 20  let* ((keys     
4cd0: 20 20 20 28 64 62 2d 67 65 74 2d 6b 65 79 73 20     (db-get-keys 
4ce0: 64 62 29 29 0a 09 20 28 72 75 6e 64 61 74 20 20  db)).. (rundat  
4cf0: 20 20 20 20 28 72 75 6e 73 3a 67 65 74 2d 72 75      (runs:get-ru
4d00: 6e 73 2d 62 79 2d 70 61 74 74 20 64 62 20 6b 65  ns-by-patt db ke
4d10: 79 73 20 72 75 6e 6e 61 6d 65 70 61 74 74 29 29  ys runnamepatt))
4d20: 0a 09 20 28 68 65 61 64 65 72 20 20 20 20 20 20  .. (header      
4d30: 28 76 65 63 74 6f 72 2d 72 65 66 20 72 75 6e 64  (vector-ref rund
4d40: 61 74 20 30 29 29 0a 09 20 28 72 75 6e 73 20 20  at 0)).. (runs  
4d50: 20 20 20 20 20 20 28 76 65 63 74 6f 72 2d 72 65        (vector-re
4d60: 66 20 72 75 6e 64 61 74 20 31 29 29 29 0a 20 20  f rundat 1))).  
4d70: 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 31    (debug:print 1
4d80: 20 22 48 65 61 64 65 72 3a 20 22 20 68 65 61 64   "Header: " head
4d90: 65 72 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63  er).    (for-eac
4da0: 68 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28  h.     (lambda (
4db0: 72 75 6e 29 0a 20 20 20 20 20 20 20 28 6c 65 74  run).       (let
4dc0: 20 28 28 72 75 6e 6b 65 79 20 28 73 74 72 69 6e   ((runkey (strin
4dd0: 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 28 6d  g-intersperse (m
4de0: 61 70 20 28 6c 61 6d 62 64 61 20 28 6b 29 0a 09  ap (lambda (k)..
4df0: 09 09 09 09 09 28 64 62 3a 67 65 74 2d 76 61 6c  .....(db:get-val
4e00: 75 65 2d 62 79 2d 68 65 61 64 65 72 20 72 75 6e  ue-by-header run
4e10: 20 68 65 61 64 65 72 20 28 76 65 63 74 6f 72 2d   header (vector-
4e20: 72 65 66 20 6b 20 30 29 29 29 20 6b 65 79 73 29  ref k 0))) keys)
4e30: 20 22 2f 22 29 29 0a 09 20 20 20 20 20 28 64 69   "/"))..     (di
4e40: 72 73 2d 74 6f 2d 72 65 6d 6f 76 65 20 28 6d 61  rs-to-remove (ma
4e50: 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 29 29 29  ke-hash-table)))
4e60: 0a 09 20 28 6c 65 74 2a 20 28 28 72 75 6e 2d 69  .. (let* ((run-i
4e70: 64 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d  d (db:get-value-
4e80: 62 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65  by-header run he
4e90: 61 64 65 72 20 22 69 64 22 29 20 29 0a 09 09 28  ader "id") )...(
4ea0: 74 65 73 74 73 20 20 28 64 62 2d 67 65 74 2d 74  tests  (db-get-t
4eb0: 65 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20  ests-for-run db 
4ec0: 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79  (db:get-value-by
4ed0: 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64  -header run head
4ee0: 65 72 20 22 69 64 22 29 20 74 65 73 74 70 61 74  er "id") testpat
4ef0: 74 20 69 74 65 6d 70 61 74 74 20 27 28 29 20 27  t itempatt '() '
4f00: 28 29 29 29 0a 09 09 28 6c 61 73 74 74 70 61 74  ()))...(lasttpat
4f10: 68 20 22 2f 64 6f 65 73 2f 6e 6f 74 2f 65 78 69  h "/does/not/exi
4f20: 73 74 2f 49 2f 68 6f 70 65 22 29 29 0a 0a 09 20  st/I/hope"))... 
4f30: 20 20 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c    (if (not (null
4f40: 3f 20 74 65 73 74 73 29 29 0a 09 20 20 20 20 20  ? tests))..     
4f50: 20 20 28 62 65 67 69 6e 0a 09 09 20 28 64 65 62    (begin... (deb
4f60: 75 67 3a 70 72 69 6e 74 20 31 20 22 52 65 6d 6f  ug:print 1 "Remo
4f70: 76 69 6e 67 20 74 65 73 74 73 20 66 6f 72 20 72  ving tests for r
4f80: 75 6e 3a 20 22 20 72 75 6e 6b 65 79 20 22 20 22  un: " runkey " "
4f90: 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62   (db:get-value-b
4fa0: 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61  y-header run hea
4fb0: 64 65 72 20 22 72 75 6e 6e 61 6d 65 22 29 29 0a  der "runname")).
4fc0: 09 09 20 28 66 6f 72 2d 65 61 63 68 0a 09 09 20  .. (for-each... 
4fd0: 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74 29 0a   (lambda (test).
4fe0: 09 09 20 20 20 20 28 6c 65 74 2a 20 28 28 69 74  ..    (let* ((it
4ff0: 65 6d 2d 70 61 74 68 20 28 64 62 3a 74 65 73 74  em-path (db:test
5000: 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74  -get-item-path t
5010: 65 73 74 29 29 0a 09 09 09 20 20 20 28 74 65 73  est))....   (tes
5020: 74 2d 6e 61 6d 65 20 28 64 62 3a 74 65 73 74 2d  t-name (db:test-
5030: 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73  get-testname tes
5040: 74 29 29 0a 09 09 09 20 20 20 28 72 75 6e 2d 64  t))....   (run-d
5050: 69 72 20 20 20 28 64 62 3a 74 65 73 74 2d 67 65  ir   (db:test-ge
5060: 74 2d 72 75 6e 64 69 72 20 74 65 73 74 29 29 29  t-rundir test)))
5070: 0a 09 09 20 20 20 20 20 20 28 64 65 62 75 67 3a  ...      (debug:
5080: 70 72 69 6e 74 20 31 20 22 20 20 22 20 28 64 62  print 1 "  " (db
5090: 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61  :test-get-testna
50a0: 6d 65 20 74 65 73 74 29 20 22 20 69 64 3a 20 22  me test) " id: "
50b0: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64   (db:test-get-id
50c0: 20 74 65 73 74 29 20 22 20 22 20 69 74 65 6d 2d   test) " " item-
50d0: 70 61 74 68 29 0a 09 09 20 20 20 20 20 20 28 64  path)...      (d
50e0: 62 3a 64 65 6c 65 74 65 2d 74 65 73 74 2d 72 65  b:delete-test-re
50f0: 63 6f 72 64 73 20 64 62 20 28 64 62 3a 74 65 73  cords db (db:tes
5100: 74 2d 67 65 74 2d 69 64 20 74 65 73 74 29 29 0a  t-get-id test)).
5110: 09 09 20 20 20 20 20 20 28 69 66 20 28 3e 20 28  ..      (if (> (
5120: 73 74 72 69 6e 67 2d 6c 65 6e 67 74 68 20 72 75  string-length ru
5130: 6e 2d 64 69 72 29 20 35 29 20 3b 3b 20 62 61 64  n-dir) 5) ;; bad
5140: 20 68 65 75 72 69 73 74 69 63 20 62 75 74 20 73   heuristic but s
5150: 68 6f 75 6c 64 20 70 72 65 76 65 6e 74 20 2f 74  hould prevent /t
5160: 6d 70 20 2f 68 6f 6d 65 20 65 74 63 2e 0a 09 09  mp /home etc....
5170: 09 20 20 28 6c 65 74 20 28 28 66 75 6c 6c 70 61  .  (let ((fullpa
5180: 74 68 20 72 75 6e 2d 64 69 72 29 29 20 3b 3b 20  th run-dir)) ;; 
5190: 22 2f 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74  "/" (db:test-get
51a0: 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 29  -item-path test)
51b0: 29 29 29 0a 09 09 09 20 20 20 20 28 73 65 74 21  )))....    (set!
51c0: 20 6c 61 73 74 74 70 61 74 68 20 66 75 6c 6c 70   lasttpath fullp
51d0: 61 74 68 29 0a 09 09 09 20 20 20 20 28 68 61 73  ath)....    (has
51e0: 68 2d 74 61 62 6c 65 2d 73 65 74 21 20 64 69 72  h-table-set! dir
51f0: 73 2d 74 6f 2d 72 65 6d 6f 76 65 20 66 75 6c 6c  s-to-remove full
5200: 70 61 74 68 20 23 74 29 0a 09 09 09 20 20 20 20  path #t)....    
5210: 3b 3b 20 54 68 65 20 66 6f 6c 6c 6f 77 69 6e 67  ;; The following
5220: 20 77 61 73 20 74 68 65 20 73 61 66 65 20 64 65   was the safe de
5230: 6c 65 74 65 20 63 6f 64 65 20 62 75 74 20 69 74  lete code but it
5240: 20 77 61 73 20 6e 6f 74 20 62 65 69 6e 67 20 65   was not being e
5250: 78 65 63 74 75 74 65 64 2e 0a 09 09 09 20 20 20  xectuted.....   
5260: 20 3b 3b 20 28 6c 65 74 2a 20 28 28 64 69 72 73   ;; (let* ((dirs
5270: 2d 63 6f 75 6e 74 20 28 2b 20 31 20 28 6c 65 6e  -count (+ 1 (len
5280: 67 74 68 20 6b 65 79 73 29 28 6c 65 6e 67 74 68  gth keys)(length
5290: 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 69   (string-split i
52a0: 74 65 6d 2d 70 61 74 68 20 22 2f 22 29 29 29 29  tem-path "/"))))
52b0: 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20 20  ....    ;;      
52c0: 20 20 28 64 69 72 2d 74 6f 2d 72 65 6d 20 28 67    (dir-to-rem (g
52d0: 65 74 2d 64 69 72 2d 75 70 2d 6e 20 66 75 6c 6c  et-dir-up-n full
52e0: 70 61 74 68 20 64 69 72 73 2d 63 6f 75 6e 74 29  path dirs-count)
52f0: 29 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20  )....    ;;     
5300: 20 20 20 28 72 65 6d 61 69 6e 69 6e 67 64 20 28     (remainingd (
5310: 73 74 72 69 6e 67 2d 73 75 62 73 74 69 74 75 74  string-substitut
5320: 65 20 28 72 65 67 65 78 70 20 28 63 6f 6e 63 20  e (regexp (conc 
5330: 22 5e 22 20 64 69 72 2d 74 6f 2d 72 65 6d 20 22  "^" dir-to-rem "
5340: 2f 22 29 29 20 22 22 20 66 75 6c 6c 70 61 74 68  /")) "" fullpath
5350: 29 29 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 20  ))....    ;;    
5360: 20 20 20 20 28 63 6d 64 20 28 63 6f 6e 63 20 22      (cmd (conc "
5370: 63 64 20 22 20 64 69 72 2d 74 6f 2d 72 65 6d 20  cd " dir-to-rem 
5380: 22 3b 20 72 6d 64 69 72 20 2d 70 20 22 20 72 65  "; rmdir -p " re
5390: 6d 61 69 6e 69 6e 67 64 20 29 29 29 0a 09 09 09  mainingd )))....
53a0: 20 20 20 20 3b 3b 20 20 20 28 69 66 20 28 66 69      ;;   (if (fi
53b0: 6c 65 2d 65 78 69 73 74 73 3f 20 66 75 6c 6c 70  le-exists? fullp
53c0: 61 74 68 29 0a 09 09 09 20 20 20 20 3b 3b 20 20  ath)....    ;;  
53d0: 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09 09 20       (begin.... 
53e0: 20 20 20 3b 3b 20 20 20 20 20 20 20 20 20 28 64     ;;         (d
53f0: 65 62 75 67 3a 70 72 69 6e 74 20 31 20 63 6d 64  ebug:print 1 cmd
5400: 29 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20  )....    ;;     
5410: 20 20 20 20 28 73 79 73 74 65 6d 20 63 6d 64 29      (system cmd)
5420: 29 29 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 29  ))....    ;;   )
5430: 29 0a 09 09 09 20 20 20 20 29 29 29 29 0a 09 09  )....    ))))...
5440: 20 20 20 20 74 65 73 74 73 29 29 29 0a 0a 09 20      tests)))... 
5450: 20 20 3b 3b 20 6c 6f 6f 6b 20 74 68 6f 75 67 68    ;; look though
5460: 20 74 68 65 20 64 69 72 73 2d 74 6f 2d 72 65 6d   the dirs-to-rem
5470: 6f 76 65 20 66 6f 72 20 63 61 6e 64 69 64 61 74  ove for candidat
5480: 65 73 20 66 6f 72 20 72 65 6d 6f 76 61 6c 2e 20  es for removal. 
5490: 44 6f 20 74 68 69 73 20 61 66 74 65 72 20 64 65  Do this after de
54a0: 6c 65 74 69 6e 67 20 74 68 65 20 72 65 63 6f 72  leting the recor
54b0: 64 73 0a 09 20 20 20 3b 3b 20 66 6f 72 20 65 61  ds..   ;; for ea
54c0: 63 68 20 74 65 73 74 20 69 6e 20 63 61 73 65 20  ch test in case 
54d0: 77 65 20 67 65 74 20 6b 69 6c 6c 65 64 2e 20 54  we get killed. T
54e0: 68 61 74 20 73 68 6f 75 6c 64 20 6d 69 6e 69 6d  hat should minim
54f0: 69 7a 65 20 74 68 65 20 64 65 74 72 69 74 75 73  ize the detritus
5500: 20 6c 65 66 74 20 6f 6e 20 64 69 73 6b 0a 09 20   left on disk.. 
5510: 20 20 3b 3b 20 70 72 6f 63 65 73 73 20 74 68 65    ;; process the
5520: 20 64 69 72 73 20 66 72 6f 6d 20 6c 6f 6e 67 65   dirs from longe
5530: 73 74 20 73 74 72 69 6e 67 20 6c 65 6e 67 74 68  st string length
5540: 20 74 6f 20 73 68 6f 72 74 65 73 74 0a 09 20 20   to shortest..  
5550: 20 28 66 6f 72 2d 65 61 63 68 20 0a 09 20 20 20   (for-each ..   
5560: 20 28 6c 61 6d 62 64 61 20 28 64 69 72 2d 74 6f   (lambda (dir-to
5570: 2d 72 65 6d 6f 76 65 29 0a 09 20 20 20 20 20 20  -remove)..      
5580: 28 69 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73  (if (file-exists
5590: 3f 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29  ? dir-to-remove)
55a0: 0a 09 09 20 20 28 6c 65 74 20 28 28 64 69 72 2d  ...  (let ((dir-
55b0: 69 6e 2d 64 62 20 27 28 29 29 29 0a 09 09 20 20  in-db '()))...  
55c0: 20 20 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65    (sqlite3:for-e
55d0: 61 63 68 2d 72 6f 77 0a 09 09 20 20 20 20 20 28  ach-row...     (
55e0: 6c 61 6d 62 64 61 20 28 64 69 72 29 0a 09 09 20  lambda (dir)... 
55f0: 20 20 20 20 20 20 28 73 65 74 21 20 64 69 72 2d        (set! dir-
5600: 69 6e 2d 64 62 20 28 63 6f 6e 73 20 64 69 72 20  in-db (cons dir 
5610: 64 69 72 2d 69 6e 2d 64 62 29 29 29 0a 09 09 20  dir-in-db)))... 
5620: 20 20 20 20 64 62 20 22 53 45 4c 45 43 54 20 72      db "SELECT r
5630: 75 6e 64 69 72 20 46 52 4f 4d 20 74 65 73 74 73  undir FROM tests
5640: 20 57 48 45 52 45 20 72 75 6e 64 69 72 20 4c 49   WHERE rundir LI
5650: 4b 45 20 3f 3b 22 20 0a 09 09 20 20 20 20 20 28  KE ?;" ...     (
5660: 63 6f 6e 63 20 22 25 22 20 64 69 72 2d 74 6f 2d  conc "%" dir-to-
5670: 72 65 6d 6f 76 65 20 22 25 22 29 29 20 3b 3b 20  remove "%")) ;; 
5680: 79 65 73 2c 20 49 27 6d 20 67 6f 69 6e 67 20 74  yes, I'm going t
5690: 6f 20 62 61 69 6c 20 69 66 20 74 68 65 72 65 20  o bail if there 
56a0: 69 73 20 61 6e 79 74 68 69 6e 67 20 6c 69 6b 65  is anything like
56b0: 20 74 68 69 73 20 64 69 72 20 69 6e 20 74 68 65   this dir in the
56c0: 20 64 62 0a 09 09 20 20 20 20 28 69 66 20 28 6e   db...    (if (n
56d0: 75 6c 6c 3f 20 64 69 72 2d 69 6e 2d 64 62 29 0a  ull? dir-in-db).
56e0: 09 09 09 28 62 65 67 69 6e 0a 09 09 09 20 20 28  ...(begin....  (
56f0: 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 52  debug:print 2 "R
5700: 65 6d 6f 76 69 6e 67 20 64 69 72 65 63 74 6f 72  emoving director
5710: 79 20 77 69 74 68 20 7a 65 72 6f 20 64 62 20 72  y with zero db r
5720: 65 66 65 72 65 6e 63 65 73 3a 20 22 20 64 69 72  eferences: " dir
5730: 2d 74 6f 2d 72 65 6d 6f 76 65 29 0a 09 09 09 20  -to-remove).... 
5740: 20 28 73 79 73 74 65 6d 20 28 63 6f 6e 63 20 22   (system (conc "
5750: 72 6d 20 2d 72 66 20 22 20 64 69 72 2d 74 6f 2d  rm -rf " dir-to-
5760: 72 65 6d 6f 76 65 29 29 0a 09 09 09 20 20 28 68  remove))....  (h
5770: 61 73 68 2d 74 61 62 6c 65 2d 64 65 6c 65 74 65  ash-table-delete
5780: 21 20 64 69 72 73 2d 74 6f 2d 72 65 6d 6f 76 65  ! dirs-to-remove
5790: 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 29   dir-to-remove))
57a0: 0a 09 09 09 28 64 65 62 75 67 3a 70 72 69 6e 74  ....(debug:print
57b0: 20 32 20 22 53 6b 69 70 70 69 6e 67 20 72 65 6d   2 "Skipping rem
57c0: 6f 76 61 6c 20 6f 66 20 22 20 64 69 72 2d 74 6f  oval of " dir-to
57d0: 2d 72 65 6d 6f 76 65 20 22 20 66 6f 72 20 6e 6f  -remove " for no
57e0: 77 20 61 73 20 69 74 20 73 74 69 6c 6c 20 68 61  w as it still ha
57f0: 73 20 72 65 66 65 72 65 6e 63 65 73 20 69 6e 20  s references in 
5800: 74 68 65 20 64 61 74 61 62 61 73 65 22 29 29 29  the database")))
5810: 29 29 0a 09 20 20 20 20 28 73 6f 72 74 20 28 68  ))..    (sort (h
5820: 61 73 68 2d 74 61 62 6c 65 2d 6b 65 79 73 20 64  ash-table-keys d
5830: 69 72 73 2d 74 6f 2d 72 65 6d 6f 76 65 29 20 28  irs-to-remove) (
5840: 6c 61 6d 62 64 61 20 28 61 20 62 29 28 3e 20 28  lambda (a b)(> (
5850: 73 74 72 69 6e 67 2d 6c 65 6e 67 74 68 20 61 29  string-length a)
5860: 28 73 74 72 69 6e 67 2d 6c 65 6e 67 74 68 20 62  (string-length b
5870: 29 29 29 29 29 0a 0a 09 20 20 20 3b 3b 20 72 65  )))))...   ;; re
5880: 6d 6f 76 65 20 74 68 65 20 72 75 6e 20 69 66 20  move the run if 
5890: 7a 65 72 6f 20 74 65 73 74 73 20 72 65 6d 61 69  zero tests remai
58a0: 6e 0a 09 20 20 20 28 6c 65 74 20 28 28 72 65 6d  n..   (let ((rem
58b0: 74 65 73 74 73 20 28 64 62 2d 67 65 74 2d 74 65  tests (db-get-te
58c0: 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 28  sts-for-run db (
58d0: 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d  db:get-value-by-
58e0: 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65  header run heade
58f0: 72 20 22 69 64 22 29 20 23 66 20 23 66 20 27 28  r "id") #f #f '(
5900: 29 20 27 28 29 29 29 29 0a 09 20 20 20 20 20 28  ) '())))..     (
5910: 69 66 20 28 6e 75 6c 6c 3f 20 72 65 6d 74 65 73  if (null? remtes
5920: 74 73 29 20 3b 3b 20 6e 6f 20 6d 6f 72 65 20 74  ts) ;; no more t
5930: 65 73 74 73 20 72 65 6d 61 69 6e 69 6e 67 0a 09  ests remaining..
5940: 09 20 28 6c 65 74 2a 20 28 28 64 70 61 72 74 73  . (let* ((dparts
5950: 20 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20    (string-split 
5960: 6c 61 73 74 74 70 61 74 68 20 22 2f 22 29 29 0a  lasttpath "/")).
5970: 09 09 09 28 72 75 6e 70 61 74 68 20 28 63 6f 6e  ...(runpath (con
5980: 63 20 22 2f 22 20 28 73 74 72 69 6e 67 2d 69 6e  c "/" (string-in
5990: 74 65 72 73 70 65 72 73 65 20 0a 09 09 09 09 09  tersperse ......
59a0: 20 20 20 20 28 74 61 6b 65 20 64 70 61 72 74 73      (take dparts
59b0: 20 28 2d 20 28 6c 65 6e 67 74 68 20 64 70 61 72   (- (length dpar
59c0: 74 73 29 20 31 29 29 0a 09 09 09 09 09 20 20 20  ts) 1))......   
59d0: 20 22 2f 22 29 29 29 29 0a 09 09 20 20 20 28 64   "/"))))...   (d
59e0: 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 52 65  ebug:print 1 "Re
59f0: 6d 6f 76 69 6e 67 20 72 75 6e 3a 20 22 20 72 75  moving run: " ru
5a00: 6e 6b 65 79 20 22 20 22 20 28 64 62 3a 67 65 74  nkey " " (db:get
5a10: 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72  -value-by-header
5a20: 20 72 75 6e 20 68 65 61 64 65 72 20 22 72 75 6e   run header "run
5a30: 6e 61 6d 65 22 29 29 0a 09 09 20 20 20 28 64 62  name"))...   (db
5a40: 3a 64 65 6c 65 74 65 2d 72 75 6e 20 64 62 20 72  :delete-run db r
5a50: 75 6e 2d 69 64 29 0a 09 09 20 20 20 3b 3b 20 6e  un-id)...   ;; n
5a60: 65 65 64 20 74 6f 20 66 69 67 75 72 65 20 6f 75  eed to figure ou
5a70: 74 20 74 68 65 20 70 61 74 68 20 74 6f 20 74 68  t the path to th
5a80: 65 20 72 75 6e 20 64 69 72 20 61 6e 64 20 72 65  e run dir and re
5a90: 6d 6f 76 65 20 69 74 20 69 66 20 65 6d 70 74 79  move it if empty
5aa0: 0a 09 09 20 20 20 3b 3b 20 20 20 20 28 69 66 20  ...   ;;    (if 
5ab0: 28 6e 75 6c 6c 3f 20 28 67 6c 6f 62 20 28 63 6f  (null? (glob (co
5ac0: 6e 63 20 72 75 6e 70 61 74 68 20 22 2f 2a 22 29  nc runpath "/*")
5ad0: 29 29 0a 09 09 20 20 20 3b 3b 20 20 20 20 20 20  ))...   ;;      
5ae0: 20 20 28 62 65 67 69 6e 0a 09 09 20 20 20 3b 3b    (begin...   ;;
5af0: 20 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20   . (debug:print 
5b00: 31 20 22 52 65 6d 6f 76 69 6e 67 20 72 75 6e 20  1 "Removing run 
5b10: 64 69 72 20 22 20 72 75 6e 70 61 74 68 29 0a 09  dir " runpath)..
5b20: 09 20 20 20 3b 3b 20 09 20 28 73 79 73 74 65 6d  .   ;; . (system
5b30: 20 28 63 6f 6e 63 20 22 72 6d 64 69 72 20 2d 70   (conc "rmdir -p
5b40: 20 22 20 72 75 6e 70 61 74 68 29 29 29 29 0a 09   " runpath))))..
5b50: 09 20 20 20 29 29 29 29 0a 09 20 29 29 0a 20 20  .   )))).. )).  
5b60: 20 20 20 72 75 6e 73 29 29 29 0a 0a 3b 3b 3d 3d     runs)))..;;==
5b70: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5b80: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5b90: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5ba0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5bb0: 3d 3d 3d 3d 0a 3b 3b 20 52 6f 75 74 69 6e 65 73  ====.;; Routines
5bc0: 20 66 6f 72 20 6d 61 6e 69 70 75 6c 61 74 69 6e   for manipulatin
5bd0: 67 20 72 75 6e 73 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d  g runs.;;=======
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 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
5c10: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a  ===============.
5c20: 0a 3b 3b 20 53 69 6e 63 65 20 6d 61 6e 79 20 63  .;; Since many c
5c30: 61 6c 6c 73 20 74 6f 20 61 20 72 75 6e 20 72 65  alls to a run re
5c40: 71 75 69 72 65 20 70 72 65 74 74 79 20 6d 75 63  quire pretty muc
5c50: 68 20 74 68 65 20 73 61 6d 65 20 73 65 74 75 70  h the same setup
5c60: 20 0a 3b 3b 20 74 68 69 73 20 77 72 61 70 70 65   .;; this wrappe
5c70: 72 20 69 73 20 75 73 65 64 20 74 6f 20 72 65 64  r is used to red
5c80: 75 63 65 20 74 68 65 20 72 65 70 6c 69 63 61 74  uce the replicat
5c90: 69 6f 6e 20 6f 66 20 63 6f 64 65 0a 28 64 65 66  ion of code.(def
5ca0: 69 6e 65 20 28 67 65 6e 65 72 61 6c 2d 72 75 6e  ine (general-run
5cb0: 2d 63 61 6c 6c 20 73 77 69 74 63 68 6e 61 6d 65  -call switchname
5cc0: 20 61 63 74 69 6f 6e 2d 64 65 73 63 20 70 72 6f   action-desc pro
5cd0: 63 29 0a 20 20 28 69 66 20 28 6e 6f 74 20 28 61  c).  (if (not (a
5ce0: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 3a 72 75  rgs:get-arg ":ru
5cf0: 6e 6e 61 6d 65 22 29 29 0a 20 20 20 20 20 20 28  nname")).      (
5d00: 62 65 67 69 6e 0a 09 28 64 65 62 75 67 3a 70 72  begin..(debug:pr
5d10: 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 4d 69  int 0 "ERROR: Mi
5d20: 73 73 69 6e 67 20 72 65 71 75 69 72 65 64 20 70  ssing required p
5d30: 61 72 61 6d 65 74 65 72 20 66 6f 72 20 22 20 73  arameter for " s
5d40: 77 69 74 63 68 6e 61 6d 65 20 22 2c 20 79 6f 75  witchname ", you
5d50: 20 6d 75 73 74 20 73 70 65 63 69 66 79 20 74 68   must specify th
5d60: 65 20 72 75 6e 20 6e 61 6d 65 20 77 69 74 68 20  e run name with 
5d70: 3a 72 75 6e 6e 61 6d 65 20 72 75 6e 6e 61 6d 65  :runname runname
5d80: 22 29 0a 09 28 65 78 69 74 20 32 29 29 0a 20 20  ")..(exit 2)).  
5d90: 20 20 20 20 28 6c 65 74 20 28 28 64 62 20 20 20      (let ((db   
5da0: 23 66 29 0a 09 20 20 20 20 28 6b 65 79 73 20 23  #f)..    (keys #
5db0: 66 29 29 0a 09 28 69 66 20 28 6e 6f 74 20 28 73  f))..(if (not (s
5dc0: 65 74 75 70 2d 66 6f 72 2d 72 75 6e 29 29 0a 09  etup-for-run))..
5dd0: 20 20 20 20 28 62 65 67 69 6e 20 0a 09 20 20 20      (begin ..   
5de0: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
5df0: 30 20 22 46 61 69 6c 65 64 20 74 6f 20 73 65 74  0 "Failed to set
5e00: 75 70 2c 20 65 78 69 74 69 6e 67 22 29 0a 09 20  up, exiting").. 
5e10: 20 20 20 20 20 28 65 78 69 74 20 31 29 29 29 0a       (exit 1))).
5e20: 09 28 73 65 74 21 20 64 62 20 20 20 28 6f 70 65  .(set! db   (ope
5e30: 6e 2d 64 62 29 29 0a 09 28 73 65 74 21 20 6b 65  n-db))..(set! ke
5e40: 79 73 20 28 64 62 2d 67 65 74 2d 6b 65 79 73 20  ys (db-get-keys 
5e50: 64 62 29 29 0a 09 3b 3b 20 68 61 76 65 20 65 6e  db))..;; have en
5e60: 6f 75 67 68 20 74 6f 20 70 72 6f 63 65 73 73 20  ough to process 
5e70: 2d 74 61 72 67 65 74 20 6f 72 20 2d 72 65 71 74  -target or -reqt
5e80: 61 72 67 20 68 65 72 65 0a 09 28 69 66 20 28 61  arg here..(if (a
5e90: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65  rgs:get-arg "-re
5ea0: 71 74 61 72 67 22 29 0a 09 20 20 20 20 28 6c 65  qtarg")..    (le
5eb0: 74 2a 20 28 28 72 75 6e 63 6f 6e 66 69 67 66 20  t* ((runconfigf 
5ec0: 28 63 6f 6e 63 20 20 2a 74 6f 70 70 61 74 68 2a  (conc  *toppath*
5ed0: 20 22 2f 72 75 6e 63 6f 6e 66 69 67 73 2e 63 6f   "/runconfigs.co
5ee0: 6e 66 69 67 22 29 29 20 3b 3b 20 44 4f 20 4e 4f  nfig")) ;; DO NO
5ef0: 54 20 45 56 41 4c 55 41 54 45 20 41 4c 4c 20 0a  T EVALUATE ALL .
5f00: 09 09 20 20 20 28 72 75 6e 63 6f 6e 66 69 67 20  ..   (runconfig 
5f10: 20 28 72 65 61 64 2d 63 6f 6e 66 69 67 20 72 75   (read-config ru
5f20: 6e 63 6f 6e 66 69 67 66 20 23 66 20 23 66 20 65  nconfigf #f #f e
5f30: 6e 76 69 72 6f 6e 2d 70 61 74 74 3a 20 23 66 29  nviron-patt: #f)
5f40: 29 29 20 0a 09 20 20 20 20 20 20 28 69 66 20 28  )) ..      (if (
5f50: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64  hash-table-ref/d
5f60: 65 66 61 75 6c 74 20 72 75 6e 63 6f 6e 66 69 67  efault runconfig
5f70: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22   (args:get-arg "
5f80: 2d 72 65 71 74 61 72 67 22 29 20 23 66 29 0a 09  -reqtarg") #f)..
5f90: 09 20 20 28 6b 65 79 73 3a 74 61 72 67 65 74 2d  .  (keys:target-
5fa0: 73 65 74 2d 61 72 67 73 20 6b 65 79 73 20 28 61  set-args keys (a
5fb0: 72 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65  rgs:get-arg "-re
5fc0: 71 74 61 72 67 22 29 20 61 72 67 73 3a 61 72 67  qtarg") args:arg
5fd0: 2d 68 61 73 68 29 0a 09 09 20 20 28 62 65 67 69  -hash)...  (begi
5fe0: 6e 0a 09 09 20 20 20 20 28 64 65 62 75 67 3a 70  n...    (debug:p
5ff0: 72 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 5b  rint 0 "ERROR: [
6000: 22 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20  " (args:get-arg 
6010: 22 2d 72 65 71 74 61 72 67 22 29 20 22 5d 20 6e  "-reqtarg") "] n
6020: 6f 74 20 66 6f 75 6e 64 20 69 6e 20 22 20 72 75  ot found in " ru
6030: 6e 63 6f 6e 66 69 67 66 29 0a 09 09 20 20 20 20  nconfigf)...    
6040: 28 73 71 6c 69 74 65 33 3a 66 69 6e 61 6c 69 7a  (sqlite3:finaliz
6050: 65 21 20 64 62 29 0a 09 09 20 20 20 20 28 65 78  e! db)...    (ex
6060: 69 74 20 31 29 29 29 29 0a 09 20 20 20 20 28 69  it 1))))..    (i
6070: 66 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20  f (args:get-arg 
6080: 22 2d 74 61 72 67 65 74 22 29 0a 09 09 28 6b 65  "-target")...(ke
6090: 79 73 3a 74 61 72 67 65 74 2d 73 65 74 2d 61 72  ys:target-set-ar
60a0: 67 73 20 6b 65 79 73 20 28 61 72 67 73 3a 67 65  gs keys (args:ge
60b0: 74 2d 61 72 67 20 22 2d 74 61 72 67 65 74 22 20  t-arg "-target" 
60c0: 61 72 67 73 3a 61 72 67 2d 68 61 73 68 29 20 61  args:arg-hash) a
60d0: 72 67 73 3a 61 72 67 2d 68 61 73 68 29 29 29 0a  rgs:arg-hash))).
60e0: 09 28 69 66 20 28 6e 6f 74 20 28 63 61 72 20 2a  .(if (not (car *
60f0: 63 6f 6e 66 69 67 69 6e 66 6f 2a 29 29 0a 09 20  configinfo*)).. 
6100: 20 20 20 28 62 65 67 69 6e 0a 09 20 20 20 20 20     (begin..     
6110: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20   (debug:print 0 
6120: 22 45 52 52 4f 52 3a 20 41 74 74 65 6d 70 74 65  "ERROR: Attempte
6130: 64 20 74 6f 20 22 20 61 63 74 69 6f 6e 2d 64 65  d to " action-de
6140: 73 63 20 22 20 62 75 74 20 72 75 6e 20 61 72 65  sc " but run are
6150: 61 20 63 6f 6e 66 69 67 20 66 69 6c 65 20 6e 6f  a config file no
6160: 74 20 66 6f 75 6e 64 22 29 0a 09 20 20 20 20 20  t found")..     
6170: 20 28 65 78 69 74 20 31 29 29 0a 09 20 20 20 20   (exit 1))..    
6180: 3b 3b 20 45 78 74 72 61 63 74 20 6f 75 74 20 73  ;; Extract out s
6190: 74 75 66 66 20 6e 65 65 64 65 64 20 69 6e 20 6d  tuff needed in m
61a0: 6f 73 74 20 6f 72 20 6d 61 6e 79 20 63 61 6c 6c  ost or many call
61b0: 73 0a 09 20 20 20 20 3b 3b 20 68 65 72 65 20 74  s..    ;; here t
61c0: 68 65 6e 20 63 61 6c 6c 20 70 72 6f 63 0a 09 20  hen call proc.. 
61d0: 20 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 6e 61     (let* ((keyna
61e0: 6d 65 73 20 20 20 28 6d 61 70 20 6b 65 79 3a 67  mes   (map key:g
61f0: 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65 79  et-fieldname key
6200: 73 29 29 0a 09 09 20 20 20 28 6b 65 79 76 61 6c  s))...   (keyval
6210: 6c 73 74 20 20 28 6b 65 79 73 2d 3e 76 61 6c 6c  lst  (keys->vall
6220: 69 73 74 20 6b 65 79 73 20 23 74 29 29 29 0a 09  ist keys #t)))..
6230: 20 20 20 20 20 20 28 70 72 6f 63 20 64 62 20 6b        (proc db k
6240: 65 79 73 20 6b 65 79 6e 61 6d 65 73 20 6b 65 79  eys keynames key
6250: 76 61 6c 6c 73 74 29 29 29 0a 09 28 73 71 6c 69  vallst)))..(sqli
6260: 74 65 33 3a 66 69 6e 61 6c 69 7a 65 21 20 64 62  te3:finalize! db
6270: 29 0a 09 28 73 65 74 21 20 2a 64 69 64 73 6f 6d  )..(set! *didsom
6280: 65 74 68 69 6e 67 2a 20 23 74 29 29 29 29 0a 0a  ething* #t))))..
6290: 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ;;==============
62a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
62b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
62c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
62d0: 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 52 6f 6c 6c  ========.;; Roll
62e0: 75 70 20 72 75 6e 73 0a 3b 3b 3d 3d 3d 3d 3d 3d  up runs.;;======
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 3d 3d 3d 3d 3d 3d  ================
6330: 0a 0a 3b 3b 20 55 70 64 61 74 65 20 74 68 65 20  ..;; Update the 
6340: 74 65 73 74 5f 6d 65 74 61 20 74 61 62 6c 65 20  test_meta table 
6350: 66 6f 72 20 74 68 69 73 20 74 65 73 74 0a 28 64  for this test.(d
6360: 65 66 69 6e 65 20 28 72 75 6e 73 3a 75 70 64 61  efine (runs:upda
6370: 74 65 2d 74 65 73 74 5f 6d 65 74 61 20 64 62 20  te-test_meta db 
6380: 74 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 2d 63  test-name test-c
6390: 6f 6e 66 29 0a 20 20 28 6c 65 74 20 28 28 63 75  onf).  (let ((cu
63a0: 72 72 72 65 63 6f 72 64 20 28 64 62 3a 74 65 73  rrrecord (db:tes
63b0: 74 6d 65 74 61 2d 67 65 74 2d 72 65 63 6f 72 64  tmeta-get-record
63c0: 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 29 29 29   db test-name)))
63d0: 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 63 75  .    (if (not cu
63e0: 72 72 72 65 63 6f 72 64 29 0a 09 28 62 65 67 69  rrrecord)..(begi
63f0: 6e 0a 09 20 20 28 73 65 74 21 20 63 75 72 72 72  n..  (set! currr
6400: 65 63 6f 72 64 20 28 6d 61 6b 65 2d 76 65 63 74  ecord (make-vect
6410: 6f 72 20 31 30 20 23 66 29 29 0a 09 20 20 28 64  or 10 #f))..  (d
6420: 62 3a 74 65 73 74 6d 65 74 61 2d 61 64 64 2d 72  b:testmeta-add-r
6430: 65 63 6f 72 64 20 64 62 20 74 65 73 74 2d 6e 61  ecord db test-na
6440: 6d 65 29 29 29 0a 20 20 20 20 28 66 6f 72 2d 65  me))).    (for-e
6450: 61 63 68 20 0a 20 20 20 20 20 28 6c 61 6d 62 64  ach .     (lambd
6460: 61 20 28 6b 65 79 29 0a 20 20 20 20 20 20 20 28  a (key).       (
6470: 6c 65 74 2a 20 28 28 69 64 78 20 28 63 61 64 72  let* ((idx (cadr
6480: 20 6b 65 79 29 29 0a 09 20 20 20 20 20 20 28 66   key))..      (f
6490: 6c 64 20 28 63 61 72 20 20 6b 65 79 29 29 0a 09  ld (car  key))..
64a0: 20 20 20 20 20 20 28 76 61 6c 20 28 63 6f 6e 66        (val (conf
64b0: 69 67 2d 6c 6f 6f 6b 75 70 20 74 65 73 74 2d 63  ig-lookup test-c
64c0: 6f 6e 66 20 22 74 65 73 74 5f 6d 65 74 61 22 20  onf "test_meta" 
64d0: 66 6c 64 29 29 29 0a 09 20 28 69 66 20 28 61 6e  fld))).. (if (an
64e0: 64 20 76 61 6c 20 28 6e 6f 74 20 28 65 71 75 61  d val (not (equa
64f0: 6c 3f 20 28 76 65 63 74 6f 72 2d 72 65 66 20 63  l? (vector-ref c
6500: 75 72 72 72 65 63 6f 72 64 20 69 64 78 29 20 76  urrrecord idx) v
6510: 61 6c 29 29 29 0a 09 20 20 20 20 20 28 62 65 67  al)))..     (beg
6520: 69 6e 0a 09 20 20 20 20 20 20 20 28 70 72 69 6e  in..       (prin
6530: 74 20 22 55 70 64 61 74 69 6e 67 20 22 20 74 65  t "Updating " te
6540: 73 74 2d 6e 61 6d 65 20 22 20 22 20 66 6c 64 20  st-name " " fld 
6550: 22 20 74 6f 20 22 20 76 61 6c 29 0a 09 20 20 20  " to " val)..   
6560: 20 20 20 20 28 64 62 3a 74 65 73 74 6d 65 74 61      (db:testmeta
6570: 2d 75 70 64 61 74 65 2d 66 69 65 6c 64 20 64 62  -update-field db
6580: 20 74 65 73 74 2d 6e 61 6d 65 20 66 6c 64 20 76   test-name fld v
6590: 61 6c 29 29 29 29 29 0a 20 20 20 20 20 27 28 28  al))))).     '((
65a0: 22 61 75 74 68 6f 72 22 20 32 29 28 22 6f 77 6e  "author" 2)("own
65b0: 65 72 22 20 33 29 28 22 64 65 73 63 72 69 70 74  er" 3)("descript
65c0: 69 6f 6e 22 20 34 29 28 22 72 65 76 69 65 77 65  ion" 4)("reviewe
65d0: 64 22 20 35 29 28 22 74 61 67 73 22 20 39 29 29  d" 5)("tags" 9))
65e0: 29 29 29 0a 0a 3b 3b 20 55 70 64 61 74 65 20 74  )))..;; Update t
65f0: 65 73 74 5f 6d 65 74 61 20 66 6f 72 20 61 6c 6c  est_meta for all
6600: 20 74 65 73 74 73 0a 28 64 65 66 69 6e 65 20 28   tests.(define (
6610: 72 75 6e 73 3a 75 70 64 61 74 65 2d 61 6c 6c 2d  runs:update-all-
6620: 74 65 73 74 5f 6d 65 74 61 20 64 62 29 0a 20 20  test_meta db).  
6630: 28 6c 65 74 20 28 28 74 65 73 74 2d 6e 61 6d 65  (let ((test-name
6640: 73 20 28 67 65 74 2d 61 6c 6c 2d 6c 65 67 61 6c  s (get-all-legal
6650: 2d 74 65 73 74 73 29 29 29 0a 20 20 20 20 28 66  -tests))).    (f
6660: 6f 72 2d 65 61 63 68 20 0a 20 20 20 20 20 28 6c  or-each .     (l
6670: 61 6d 62 64 61 20 28 74 65 73 74 2d 6e 61 6d 65  ambda (test-name
6680: 29 0a 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28  ).       (let* (
6690: 28 74 65 73 74 2d 70 61 74 68 20 20 20 20 28 63  (test-path    (c
66a0: 6f 6e 63 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f  onc *toppath* "/
66b0: 74 65 73 74 73 2f 22 20 74 65 73 74 2d 6e 61 6d  tests/" test-nam
66c0: 65 29 29 0a 09 20 20 20 20 20 20 28 74 65 73 74  e))..      (test
66d0: 2d 63 6f 6e 66 69 67 66 20 28 63 6f 6e 63 20 74  -configf (conc t
66e0: 65 73 74 2d 70 61 74 68 20 22 2f 74 65 73 74 63  est-path "/testc
66f0: 6f 6e 66 69 67 22 29 29 0a 09 20 20 20 20 20 20  onfig"))..      
6700: 28 74 65 73 74 65 78 69 73 74 73 20 20 20 28 61  (testexists   (a
6710: 6e 64 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f  nd (file-exists?
6720: 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 29 28 66   test-configf)(f
6730: 69 6c 65 2d 72 65 61 64 2d 61 63 63 65 73 73 3f  ile-read-access?
6740: 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 29 29 29   test-configf)))
6750: 0a 09 20 20 20 20 20 20 3b 3b 20 72 65 61 64 20  ..      ;; read 
6760: 63 6f 6e 66 69 67 73 20 77 69 74 68 20 74 72 69  configs with tri
6770: 63 6b 73 20 74 75 72 6e 65 64 20 6f 66 66 20 28  cks turned off (
6780: 69 2e 65 2e 20 6e 6f 20 73 79 73 74 65 6d 29 0a  i.e. no system).
6790: 09 20 20 20 20 20 20 28 74 65 73 74 2d 63 6f 6e  .      (test-con
67a0: 66 20 20 20 20 28 69 66 20 74 65 73 74 65 78 69  f    (if testexi
67b0: 73 74 73 20 28 72 65 61 64 2d 63 6f 6e 66 69 67  sts (read-config
67c0: 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 20 23 66   test-configf #f
67d0: 20 23 66 29 28 6d 61 6b 65 2d 68 61 73 68 2d 74   #f)(make-hash-t
67e0: 61 62 6c 65 29 29 29 29 0a 09 20 28 72 75 6e 73  able)))).. (runs
67f0: 3a 75 70 64 61 74 65 2d 74 65 73 74 5f 6d 65 74  :update-test_met
6800: 61 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 20 74  a db test-name t
6810: 65 73 74 2d 63 6f 6e 66 29 29 29 0a 20 20 20 20  est-conf))).    
6820: 20 74 65 73 74 2d 6e 61 6d 65 73 29 29 29 0a 0a   test-names)))..
6830: 3b 3b 20 54 68 69 73 20 63 6f 75 6c 64 20 70 72  ;; This could pr
6840: 6f 62 61 62 6c 79 20 62 65 20 72 65 66 61 63 74  obably be refact
6850: 6f 72 65 64 20 69 6e 74 6f 20 6f 6e 65 20 63 6f  ored into one co
6860: 6d 70 6c 65 78 20 71 75 65 72 79 20 2e 2e 2e 0a  mplex query ....
6870: 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 72 6f  (define (runs:ro
6880: 6c 6c 75 70 2d 72 75 6e 20 64 62 20 6b 65 79 73  llup-run db keys
6890: 20 6b 65 79 76 61 6c 6c 73 74 20 72 75 6e 6e 61   keyvallst runna
68a0: 6d 65 20 75 73 65 72 29 20 3b 3b 20 77 61 73 20  me user) ;; was 
68b0: 74 61 72 67 65 74 2c 20 6e 6f 77 20 6b 65 79 76  target, now keyv
68c0: 61 6c 6c 73 74 0a 20 20 28 64 65 62 75 67 3a 70  allst.  (debug:p
68d0: 72 69 6e 74 20 34 20 22 72 75 6e 73 3a 72 6f 6c  rint 4 "runs:rol
68e0: 6c 75 70 2d 72 75 6e 2c 20 6b 65 79 73 3a 20 22  lup-run, keys: "
68f0: 20 6b 65 79 73 20 22 20 6b 65 79 76 61 6c 6c 73   keys " keyvalls
6900: 74 3a 20 22 20 6b 65 79 76 61 6c 6c 73 74 20 22  t: " keyvallst "
6910: 20 3a 72 75 6e 6e 61 6d 65 20 22 20 72 75 6e 6e   :runname " runn
6920: 61 6d 65 20 22 20 75 73 65 72 3a 20 22 20 75 73  ame " user: " us
6930: 65 72 29 0a 20 20 28 6c 65 74 2a 20 28 3b 20 28  er).  (let* (; (
6940: 6b 65 79 76 61 6c 6c 6c 73 74 20 20 20 20 20 20  keyvalllst      
6950: 28 6b 65 79 73 3a 74 61 72 67 65 74 2d 3e 6b 65  (keys:target->ke
6960: 79 76 61 6c 20 6b 65 79 73 20 74 61 72 67 65 74  yval keys target
6970: 29 29 0a 09 20 28 6e 65 77 2d 72 75 6e 2d 69 64  )).. (new-run-id
6980: 20 20 20 20 20 20 28 72 75 6e 73 3a 72 65 67 69        (runs:regi
6990: 73 74 65 72 2d 72 75 6e 20 64 62 20 6b 65 79 73  ster-run db keys
69a0: 20 6b 65 79 76 61 6c 6c 73 74 20 72 75 6e 6e 61   keyvallst runna
69b0: 6d 65 20 22 6e 65 77 22 20 22 6e 2f 61 22 20 75  me "new" "n/a" u
69c0: 73 65 72 29 29 0a 09 20 28 70 72 65 76 2d 74 65  ser)).. (prev-te
69d0: 73 74 73 20 20 20 20 20 20 28 74 65 73 74 3a 67  sts      (test:g
69e0: 65 74 2d 6d 61 74 63 68 69 6e 67 2d 70 72 65 76  et-matching-prev
69f0: 69 6f 75 73 2d 74 65 73 74 2d 72 75 6e 2d 72 65  ious-test-run-re
6a00: 63 6f 72 64 73 20 64 62 20 6e 65 77 2d 72 75 6e  cords db new-run
6a10: 2d 69 64 20 22 25 22 20 22 25 22 29 29 0a 09 20  -id "%" "%")).. 
6a20: 28 63 75 72 72 2d 74 65 73 74 73 20 20 20 20 20  (curr-tests     
6a30: 20 28 64 62 2d 67 65 74 2d 74 65 73 74 73 2d 66   (db-get-tests-f
6a40: 6f 72 2d 72 75 6e 20 64 62 20 6e 65 77 2d 72 75  or-run db new-ru
6a50: 6e 2d 69 64 20 22 25 22 20 22 25 22 20 27 28 29  n-id "%" "%" '()
6a60: 20 27 28 29 29 29 0a 09 20 28 63 75 72 72 2d 74   '())).. (curr-t
6a70: 65 73 74 73 2d 68 61 73 68 20 28 6d 61 6b 65 2d  ests-hash (make-
6a80: 68 61 73 68 2d 74 61 62 6c 65 29 29 29 0a 20 20  hash-table))).  
6a90: 20 20 28 64 62 3a 75 70 64 61 74 65 2d 72 75 6e    (db:update-run
6aa0: 2d 65 76 65 6e 74 5f 74 69 6d 65 20 64 62 20 6e  -event_time db n
6ab0: 65 77 2d 72 75 6e 2d 69 64 29 0a 20 20 20 20 3b  ew-run-id).    ;
6ac0: 3b 20 69 6e 64 65 78 20 74 68 65 20 61 6c 72 65  ; index the alre
6ad0: 61 64 79 20 73 61 76 65 64 20 74 65 73 74 73 20  ady saved tests 
6ae0: 62 79 20 74 65 73 74 6e 61 6d 65 20 61 6e 64 20  by testname and 
6af0: 69 74 65 6d 64 61 74 20 69 6e 20 63 75 72 72 2d  itemdat in curr-
6b00: 74 65 73 74 73 2d 68 61 73 68 0a 20 20 20 20 28  tests-hash.    (
6b10: 66 6f 72 2d 65 61 63 68 0a 20 20 20 20 20 28 6c  for-each.     (l
6b20: 61 6d 62 64 61 20 28 74 65 73 74 64 61 74 29 0a  ambda (testdat).
6b30: 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28 28 74         (let* ((t
6b40: 65 73 74 6e 61 6d 65 20 20 28 64 62 3a 74 65 73  estname  (db:tes
6b50: 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 74  t-get-testname t
6b60: 65 73 74 64 61 74 29 29 0a 09 20 20 20 20 20 20  estdat))..      
6b70: 28 69 74 65 6d 2d 70 61 74 68 20 28 64 62 3a 74  (item-path (db:t
6b80: 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74  est-get-item-pat
6b90: 68 20 74 65 73 74 64 61 74 29 29 0a 09 20 20 20  h testdat))..   
6ba0: 20 20 20 28 66 75 6c 6c 2d 6e 61 6d 65 20 28 63     (full-name (c
6bb0: 6f 6e 63 20 74 65 73 74 6e 61 6d 65 20 22 2f 22  onc testname "/"
6bc0: 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 09 20   item-path))).. 
6bd0: 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74 21  (hash-table-set!
6be0: 20 63 75 72 72 2d 74 65 73 74 73 2d 68 61 73 68   curr-tests-hash
6bf0: 20 66 75 6c 6c 2d 6e 61 6d 65 20 74 65 73 74 64   full-name testd
6c00: 61 74 29 29 29 0a 20 20 20 20 20 63 75 72 72 2d  at))).     curr-
6c10: 74 65 73 74 73 29 0a 20 20 20 20 3b 3b 20 4e 4f  tests).    ;; NO
6c20: 50 45 3a 20 4e 6f 6e 2d 6f 70 74 69 6d 61 6c 20  PE: Non-optimal 
6c30: 61 70 70 72 6f 61 63 68 2e 20 54 72 79 20 74 68  approach. Try th
6c40: 69 73 20 69 6e 73 74 65 61 64 2e 0a 20 20 20 20  is instead..    
6c50: 3b 3b 20 20 20 31 2e 20 74 65 73 74 73 20 61 72  ;;   1. tests ar
6c60: 65 20 72 65 63 65 69 76 65 64 20 69 6e 20 61 20  e received in a 
6c70: 6c 69 73 74 2c 20 6d 6f 73 74 20 72 65 63 65 6e  list, most recen
6c80: 74 20 66 69 72 73 74 0a 20 20 20 20 3b 3b 20 20  t first.    ;;  
6c90: 20 32 2e 20 72 65 70 6c 61 63 65 20 74 68 65 20   2. replace the 
6ca0: 72 6f 6c 6c 75 70 20 74 65 73 74 20 77 69 74 68  rollup test with
6cb0: 20 74 68 65 20 6e 65 77 20 2a 61 6c 77 61 79 73   the new *always
6cc0: 2a 0a 20 20 20 20 28 66 6f 72 2d 65 61 63 68 20  *.    (for-each 
6cd0: 0a 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 74  .     (lambda (t
6ce0: 65 73 74 64 61 74 29 0a 20 20 20 20 20 20 20 28  estdat).       (
6cf0: 6c 65 74 2a 20 28 28 74 65 73 74 6e 61 6d 65 20  let* ((testname 
6d00: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 74 65   (db:test-get-te
6d10: 73 74 6e 61 6d 65 20 74 65 73 74 64 61 74 29 29  stname testdat))
6d20: 0a 09 20 20 20 20 20 20 28 69 74 65 6d 2d 70 61  ..      (item-pa
6d30: 74 68 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  th (db:test-get-
6d40: 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 64 61  item-path testda
6d50: 74 29 29 0a 09 20 20 20 20 20 20 28 66 75 6c 6c  t))..      (full
6d60: 2d 6e 61 6d 65 20 28 63 6f 6e 63 20 74 65 73 74  -name (conc test
6d70: 6e 61 6d 65 20 22 2f 22 20 69 74 65 6d 2d 70 61  name "/" item-pa
6d80: 74 68 29 29 0a 09 20 20 20 20 20 20 28 70 72 65  th))..      (pre
6d90: 76 2d 74 65 73 74 2d 64 61 74 20 28 68 61 73 68  v-test-dat (hash
6da0: 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75  -table-ref/defau
6db0: 6c 74 20 63 75 72 72 2d 74 65 73 74 73 2d 68 61  lt curr-tests-ha
6dc0: 73 68 20 66 75 6c 6c 2d 6e 61 6d 65 20 23 66 29  sh full-name #f)
6dd0: 29 0a 09 20 20 20 20 20 20 28 74 65 73 74 2d 73  )..      (test-s
6de0: 74 65 70 73 20 20 20 20 20 20 28 64 62 3a 67 65  teps      (db:ge
6df0: 74 2d 73 74 65 70 73 2d 66 6f 72 2d 74 65 73 74  t-steps-for-test
6e00: 20 64 62 20 28 64 62 3a 74 65 73 74 2d 67 65 74   db (db:test-get
6e10: 2d 69 64 20 74 65 73 74 64 61 74 29 29 29 0a 09  -id testdat)))..
6e20: 20 20 20 20 20 20 28 6e 65 77 2d 74 65 73 74 2d        (new-test-
6e30: 72 65 63 6f 72 64 20 23 66 29 29 0a 09 20 3b 3b  record #f)).. ;;
6e40: 20 72 65 70 6c 61 63 65 20 74 68 65 73 65 20 77   replace these w
6e50: 69 74 68 20 69 6e 73 65 72 74 20 2e 2e 2e 20 73  ith insert ... s
6e60: 65 6c 65 63 74 0a 09 20 28 61 70 70 6c 79 20 73  elect.. (apply s
6e70: 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 0a  qlite3:execute .
6e80: 09 09 64 62 20 0a 09 09 28 63 6f 6e 63 20 22 49  ..db ...(conc "I
6e90: 4e 53 45 52 54 20 4f 52 20 52 45 50 4c 41 43 45  NSERT OR REPLACE
6ea0: 20 49 4e 54 4f 20 74 65 73 74 73 20 28 72 75 6e   INTO tests (run
6eb0: 5f 69 64 2c 74 65 73 74 6e 61 6d 65 2c 73 74 61  _id,testname,sta
6ec0: 74 65 2c 73 74 61 74 75 73 2c 65 76 65 6e 74 5f  te,status,event_
6ed0: 74 69 6d 65 2c 68 6f 73 74 2c 63 70 75 6c 6f 61  time,host,cpuloa
6ee0: 64 2c 64 69 73 6b 66 72 65 65 2c 75 6e 61 6d 65  d,diskfree,uname
6ef0: 2c 72 75 6e 64 69 72 2c 69 74 65 6d 5f 70 61 74  ,rundir,item_pat
6f00: 68 2c 72 75 6e 5f 64 75 72 61 74 69 6f 6e 2c 66  h,run_duration,f
6f10: 69 6e 61 6c 5f 6c 6f 67 66 2c 63 6f 6d 6d 65 6e  inal_logf,commen
6f20: 74 29 20 22 0a 09 09 20 20 20 20 20 20 22 56 41  t) "...      "VA
6f30: 4c 55 45 53 20 28 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c  LUES (?,?,?,?,?,
6f40: 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c  ?,?,?,?,?,?,?,?,
6f50: 3f 29 3b 22 29 0a 09 09 6e 65 77 2d 72 75 6e 2d  ?);")...new-run-
6f60: 69 64 20 28 63 64 64 72 20 28 76 65 63 74 6f 72  id (cddr (vector
6f70: 2d 3e 6c 69 73 74 20 74 65 73 74 64 61 74 29 29  ->list testdat))
6f80: 29 0a 09 20 28 73 65 74 21 20 6e 65 77 2d 74 65  ).. (set! new-te
6f90: 73 74 64 61 74 20 28 63 61 72 20 28 64 62 2d 67  stdat (car (db-g
6fa0: 65 74 2d 74 65 73 74 73 2d 66 6f 72 2d 72 75 6e  et-tests-for-run
6fb0: 20 64 62 20 6e 65 77 2d 72 75 6e 2d 69 64 20 74   db new-run-id t
6fc0: 65 73 74 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74  estname item-pat
6fd0: 68 20 27 28 29 20 27 28 29 29 29 29 0a 09 20 28  h '() '()))).. (
6fe0: 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74 21 20  hash-table-set! 
6ff0: 63 75 72 72 2d 74 65 73 74 73 2d 68 61 73 68 20  curr-tests-hash 
7000: 66 75 6c 6c 2d 6e 61 6d 65 20 6e 65 77 2d 74 65  full-name new-te
7010: 73 74 64 61 74 29 20 3b 3b 20 74 68 69 73 20 63  stdat) ;; this c
7020: 6f 75 6c 64 20 62 65 20 63 6f 6e 66 75 73 69 6e  ould be confusin
7030: 67 2c 20 77 68 69 63 68 20 72 65 63 6f 72 64 20  g, which record 
7040: 73 68 6f 75 6c 64 20 67 6f 20 69 6e 74 6f 20 74  should go into t
7050: 68 65 20 6c 6f 6f 6b 75 70 20 74 61 62 6c 65 3f  he lookup table?
7060: 0a 09 20 3b 3b 20 4e 6f 77 20 64 75 70 6c 69 63  .. ;; Now duplic
7070: 61 74 65 20 74 68 65 20 74 65 73 74 20 73 74 65  ate the test ste
7080: 70 73 0a 09 20 28 64 65 62 75 67 3a 70 72 69 6e  ps.. (debug:prin
7090: 74 20 34 20 22 43 6f 70 79 69 6e 67 20 72 65 63  t 4 "Copying rec
70a0: 6f 72 64 73 20 69 6e 20 74 65 73 74 5f 73 74 65  ords in test_ste
70b0: 70 73 20 66 72 6f 6d 20 74 65 73 74 5f 69 64 3d  ps from test_id=
70c0: 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69  " (db:test-get-i
70d0: 64 20 74 65 73 74 64 61 74 29 20 22 20 74 6f 20  d testdat) " to 
70e0: 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69  " (db:test-get-i
70f0: 64 20 6e 65 77 2d 74 65 73 74 64 61 74 29 29 0a  d new-testdat)).
7100: 09 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75  . (sqlite3:execu
7110: 74 65 20 0a 09 20 20 64 62 20 0a 09 20 20 28 63  te ..  db ..  (c
7120: 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f 52 20 52  onc "INSERT OR R
7130: 45 50 4c 41 43 45 20 49 4e 54 4f 20 74 65 73 74  EPLACE INTO test
7140: 5f 73 74 65 70 73 20 28 74 65 73 74 5f 69 64 2c  _steps (test_id,
7150: 73 74 65 70 6e 61 6d 65 2c 73 74 61 74 65 2c 73  stepname,state,s
7160: 74 61 74 75 73 2c 65 76 65 6e 74 5f 74 69 6d 65  tatus,event_time
7170: 2c 63 6f 6d 6d 65 6e 74 29 20 22 0a 09 09 22 53  ,comment) "..."S
7180: 45 4c 45 43 54 20 22 20 28 64 62 3a 74 65 73 74  ELECT " (db:test
7190: 2d 67 65 74 2d 69 64 20 6e 65 77 2d 74 65 73 74  -get-id new-test
71a0: 64 61 74 29 20 22 2c 73 74 65 70 6e 61 6d 65 2c  dat) ",stepname,
71b0: 73 74 61 74 65 2c 73 74 61 74 75 73 2c 65 76 65  state,status,eve
71c0: 6e 74 5f 74 69 6d 65 2c 63 6f 6d 6d 65 6e 74 20  nt_time,comment 
71d0: 46 52 4f 4d 20 74 65 73 74 5f 73 74 65 70 73 20  FROM test_steps 
71e0: 57 48 45 52 45 20 74 65 73 74 5f 69 64 3d 3f 3b  WHERE test_id=?;
71f0: 22 29 0a 09 20 20 28 64 62 3a 74 65 73 74 2d 67  ")..  (db:test-g
7200: 65 74 2d 69 64 20 74 65 73 74 64 61 74 29 29 0a  et-id testdat)).
7210: 09 20 3b 3b 20 4e 6f 77 20 64 75 70 6c 69 63 61  . ;; Now duplica
7220: 74 65 20 74 68 65 20 74 65 73 74 20 64 61 74 61  te the test data
7230: 0a 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20  .. (debug:print 
7240: 34 20 22 43 6f 70 79 69 6e 67 20 72 65 63 6f 72  4 "Copying recor
7250: 64 73 20 69 6e 20 74 65 73 74 5f 64 61 74 61 20  ds in test_data 
7260: 66 72 6f 6d 20 74 65 73 74 5f 69 64 3d 22 20 28  from test_id=" (
7270: 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74  db:test-get-id t
7280: 65 73 74 64 61 74 29 20 22 20 74 6f 20 22 20 28  estdat) " to " (
7290: 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 6e  db:test-get-id n
72a0: 65 77 2d 74 65 73 74 64 61 74 29 29 0a 09 20 28  ew-testdat)).. (
72b0: 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20  sqlite3:execute 
72c0: 0a 09 20 20 64 62 20 0a 09 20 20 28 63 6f 6e 63  ..  db ..  (conc
72d0: 20 22 49 4e 53 45 52 54 20 4f 52 20 52 45 50 4c   "INSERT OR REPL
72e0: 41 43 45 20 49 4e 54 4f 20 74 65 73 74 5f 64 61  ACE INTO test_da
72f0: 74 61 20 28 74 65 73 74 5f 69 64 2c 63 61 74 65  ta (test_id,cate
7300: 67 6f 72 79 2c 76 61 72 69 61 62 6c 65 2c 76 61  gory,variable,va
7310: 6c 75 65 2c 65 78 70 65 63 74 65 64 2c 74 6f 6c  lue,expected,tol
7320: 2c 75 6e 69 74 73 2c 63 6f 6d 6d 65 6e 74 29 20  ,units,comment) 
7330: 22 0a 09 09 22 53 45 4c 45 43 54 20 22 20 28 64  "..."SELECT " (d
7340: 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 6e 65  b:test-get-id ne
7350: 77 2d 74 65 73 74 64 61 74 29 20 22 2c 63 61 74  w-testdat) ",cat
7360: 65 67 6f 72 79 2c 76 61 72 69 61 62 6c 65 2c 76  egory,variable,v
7370: 61 6c 75 65 2c 65 78 70 65 63 74 65 64 2c 74 6f  alue,expected,to
7380: 6c 2c 75 6e 69 74 73 2c 63 6f 6d 6d 65 6e 74 20  l,units,comment 
7390: 46 52 4f 4d 20 74 65 73 74 5f 64 61 74 61 20 57  FROM test_data W
73a0: 48 45 52 45 20 74 65 73 74 5f 69 64 3d 3f 3b 22  HERE test_id=?;"
73b0: 29 0a 09 20 20 28 64 62 3a 74 65 73 74 2d 67 65  )..  (db:test-ge
73c0: 74 2d 69 64 20 74 65 73 74 64 61 74 29 29 0a 09  t-id testdat))..
73d0: 20 29 29 0a 20 20 20 20 20 70 72 65 76 2d 74 65   )).     prev-te
73e0: 73 74 73 29 29 29 0a 09 20 0a 20 20 20 20 20 0a  sts))).. .     .