Megatest

Hex Artifact Content
Login

Artifact a70b456ddca8f2ed41aba7aa3f7cd67bd53e35e0:


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 29 0a 28 69 6d 70 6f 72 74 20 28 70 72 65  69).(import (pre
01c0: 66 69 78 20 73 71 6c 69 74 65 33 20 73 71 6c 69  fix sqlite3 sqli
01d0: 74 65 33 3a 29 29 0a 0a 28 64 65 63 6c 61 72 65  te3:))..(declare
01e0: 20 28 75 6e 69 74 20 72 75 6e 73 29 29 0a 28 64   (unit runs)).(d
01f0: 65 63 6c 61 72 65 20 28 75 73 65 73 20 64 62 29  eclare (uses db)
0200: 29 0a 28 64 65 63 6c 61 72 65 20 28 75 73 65 73  ).(declare (uses
0210: 20 63 6f 6d 6d 6f 6e 29 29 0a 28 64 65 63 6c 61   common)).(decla
0220: 72 65 20 28 75 73 65 73 20 69 74 65 6d 73 29 29  re (uses items))
0230: 0a 28 64 65 63 6c 61 72 65 20 28 75 73 65 73 20  .(declare (uses 
0240: 72 75 6e 63 6f 6e 66 69 67 29 29 0a 0a 28 69 6e  runconfig))..(in
0250: 63 6c 75 64 65 20 22 63 6f 6d 6d 6f 6e 5f 72 65  clude "common_re
0260: 63 6f 72 64 73 2e 73 63 6d 22 29 0a 28 69 6e 63  cords.scm").(inc
0270: 6c 75 64 65 20 22 6b 65 79 5f 72 65 63 6f 72 64  lude "key_record
0280: 73 2e 73 63 6d 22 29 0a 28 69 6e 63 6c 75 64 65  s.scm").(include
0290: 20 22 64 62 5f 72 65 63 6f 72 64 73 2e 73 63 6d   "db_records.scm
02a0: 22 29 0a 0a 3b 3b 20 72 65 67 69 73 74 65 72 20  ")..;; register 
02b0: 61 20 74 65 73 74 20 72 75 6e 20 77 69 74 68 20  a test run with 
02c0: 74 68 65 20 64 62 0a 28 64 65 66 69 6e 65 20 28  the db.(define (
02d0: 72 65 67 69 73 74 65 72 2d 72 75 6e 20 64 62 20  register-run db 
02e0: 6b 65 79 73 29 20 3b 3b 20 74 65 73 74 2d 6e 61  keys) ;; test-na
02f0: 6d 65 29 0a 20 20 28 6c 65 74 2a 20 28 28 6b 65  me).  (let* ((ke
0300: 79 73 74 72 20 20 20 20 28 6b 65 79 73 2d 3e 6b  ystr    (keys->k
0310: 65 79 73 74 72 20 6b 65 79 73 29 29 0a 09 20 28  eystr keys)).. (
0320: 63 6f 6d 6d 61 20 20 20 20 20 28 69 66 20 28 3e  comma     (if (>
0330: 20 28 6c 65 6e 67 74 68 20 6b 65 79 73 29 20 30   (length keys) 0
0340: 29 20 22 2c 22 20 22 22 29 29 0a 09 20 28 61 6e  ) "," "")).. (an
0350: 64 73 74 72 20 20 20 20 28 69 66 20 28 3e 20 28  dstr    (if (> (
0360: 6c 65 6e 67 74 68 20 6b 65 79 73 29 20 30 29 20  length keys) 0) 
0370: 22 20 41 4e 44 20 22 20 22 22 29 29 0a 09 20 28  " AND " "")).. (
0380: 76 61 6c 73 6c 6f 74 73 20 20 28 6b 65 79 73 2d  valslots  (keys-
0390: 3e 76 61 6c 73 6c 6f 74 73 20 6b 65 79 73 29 29  >valslots keys))
03a0: 20 3b 3b 20 3f 2c 3f 2c 3f 20 2e 2e 2e 0a 09 20   ;; ?,?,? ..... 
03b0: 28 6b 65 79 76 61 6c 6c 73 74 20 28 6b 65 79 73  (keyvallst (keys
03c0: 2d 3e 76 61 6c 6c 69 73 74 20 6b 65 79 73 29 29  ->vallist keys))
03d0: 20 3b 3b 20 65 78 74 72 61 63 74 73 20 74 68 65   ;; extracts the
03e0: 20 76 61 6c 75 65 73 20 66 72 6f 6d 20 72 65 6d   values from rem
03f0: 61 69 6e 64 65 72 20 6f 66 20 28 61 72 67 76 29  ainder of (argv)
0400: 0a 09 20 28 72 75 6e 6e 61 6d 65 20 20 20 28 67  .. (runname   (g
0410: 65 74 2d 77 69 74 68 2d 64 65 66 61 75 6c 74 20  et-with-default 
0420: 22 3a 72 75 6e 6e 61 6d 65 22 20 23 66 29 29 0a  ":runname" #f)).
0430: 09 20 28 73 74 61 74 65 20 20 20 20 20 28 67 65  . (state     (ge
0440: 74 2d 77 69 74 68 2d 64 65 66 61 75 6c 74 20 22  t-with-default "
0450: 3a 73 74 61 74 65 22 20 22 6e 6f 22 29 29 0a 09  :state" "no"))..
0460: 20 28 73 74 61 74 75 73 20 20 20 20 28 67 65 74   (status    (get
0470: 2d 77 69 74 68 2d 64 65 66 61 75 6c 74 20 22 3a  -with-default ":
0480: 73 74 61 74 75 73 22 20 22 6e 2f 61 22 29 29 0a  status" "n/a")).
0490: 09 20 28 61 6c 6c 76 61 6c 73 20 20 20 28 61 70  . (allvals   (ap
04a0: 70 65 6e 64 20 28 6c 69 73 74 20 72 75 6e 6e 61  pend (list runna
04b0: 6d 65 20 73 74 61 74 65 20 73 74 61 74 75 73 20  me state status 
04c0: 75 73 65 72 29 20 6b 65 79 76 61 6c 6c 73 74 29  user) keyvallst)
04d0: 29 0a 09 20 28 71 72 79 76 61 6c 73 20 20 20 28  ).. (qryvals   (
04e0: 61 70 70 65 6e 64 20 28 6c 69 73 74 20 72 75 6e  append (list run
04f0: 6e 61 6d 65 29 20 6b 65 79 76 61 6c 6c 73 74 29  name) keyvallst)
0500: 29 0a 09 20 28 6b 65 79 3d 3f 73 74 72 20 20 28  ).. (key=?str  (
0510: 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72  string-intersper
0520: 73 65 20 28 6d 61 70 20 28 6c 61 6d 62 64 61 20  se (map (lambda 
0530: 28 6b 29 28 63 6f 6e 63 20 28 6b 65 79 3a 67 65  (k)(conc (key:ge
0540: 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 29 20 22  t-fieldname k) "
0550: 3d 3f 22 29 29 20 6b 65 79 73 29 20 22 20 41 4e  =?")) keys) " AN
0560: 44 20 22 29 29 29 0a 20 20 20 20 28 64 65 62 75  D "))).    (debu
0570: 67 3a 70 72 69 6e 74 20 33 20 22 6b 65 79 73 3a  g:print 3 "keys:
0580: 20 22 20 6b 65 79 73 20 22 20 61 6c 6c 76 61 6c   " keys " allval
0590: 73 3a 20 22 20 61 6c 6c 76 61 6c 73 20 22 20 6b  s: " allvals " k
05a0: 65 79 76 61 6c 6c 73 74 3a 20 22 20 6b 65 79 76  eyvallst: " keyv
05b0: 61 6c 6c 73 74 29 0a 20 20 20 20 28 64 65 62 75  allst).    (debu
05c0: 67 3a 70 72 69 6e 74 20 32 20 22 4e 4f 54 45 3a  g:print 2 "NOTE:
05d0: 20 75 73 69 6e 67 20 6b 65 79 20 22 20 28 73 74   using key " (st
05e0: 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65  ring-intersperse
05f0: 20 6b 65 79 76 61 6c 6c 73 74 20 22 2f 22 29 20   keyvallst "/") 
0600: 22 20 66 6f 72 20 74 68 69 73 20 72 75 6e 22 29  " for this run")
0610: 0a 20 20 20 20 28 69 66 20 28 61 6e 64 20 72 75  .    (if (and ru
0620: 6e 6e 61 6d 65 20 28 6e 75 6c 6c 3f 20 28 66 69  nname (null? (fi
0630: 6c 74 65 72 20 28 6c 61 6d 62 64 61 20 28 78 29  lter (lambda (x)
0640: 28 6e 6f 74 20 78 29 29 20 6b 65 79 76 61 6c 6c  (not x)) keyvall
0650: 73 74 29 29 29 20 3b 3b 20 74 68 65 72 65 20 6d  st))) ;; there m
0660: 75 73 74 20 62 65 20 61 20 62 65 74 74 65 72 20  ust be a better 
0670: 77 61 79 20 74 6f 20 22 61 70 70 6c 79 20 61 6e  way to "apply an
0680: 64 22 0a 09 28 6c 65 74 20 28 28 72 65 73 20 23  d"..(let ((res #
0690: 66 29 29 0a 09 20 20 28 61 70 70 6c 79 20 73 71  f))..  (apply sq
06a0: 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 64 62  lite3:execute db
06b0: 20 28 63 6f 6e 63 20 22 49 4e 53 45 52 54 20 4f   (conc "INSERT O
06c0: 52 20 49 47 4e 4f 52 45 20 49 4e 54 4f 20 72 75  R IGNORE INTO ru
06d0: 6e 73 20 28 72 75 6e 6e 61 6d 65 2c 73 74 61 74  ns (runname,stat
06e0: 65 2c 73 74 61 74 75 73 2c 6f 77 6e 65 72 2c 65  e,status,owner,e
06f0: 76 65 6e 74 5f 74 69 6d 65 22 20 63 6f 6d 6d 61  vent_time" comma
0700: 20 6b 65 79 73 74 72 20 22 29 20 56 41 4c 55 45   keystr ") VALUE
0710: 53 20 28 3f 2c 3f 2c 3f 2c 3f 2c 73 74 72 66 74  S (?,?,?,?,strft
0720: 69 6d 65 28 27 25 73 27 2c 27 6e 6f 77 27 29 22  ime('%s','now')"
0730: 20 63 6f 6d 6d 61 20 76 61 6c 73 6c 6f 74 73 20   comma valslots 
0740: 22 29 3b 22 29 0a 09 09 20 61 6c 6c 76 61 6c 73  ");")... allvals
0750: 29 0a 09 20 20 28 61 70 70 6c 79 20 73 71 6c 69  )..  (apply sqli
0760: 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77  te3:for-each-row
0770: 20 0a 09 20 20 20 28 6c 61 6d 62 64 61 20 28 69   ..   (lambda (i
0780: 64 29 0a 09 20 20 20 20 20 28 73 65 74 21 20 72  d)..     (set! r
0790: 65 73 20 69 64 29 29 0a 09 20 20 20 64 62 0a 09  es id))..   db..
07a0: 20 20 20 28 6c 65 74 20 28 28 71 72 79 20 28 63     (let ((qry (c
07b0: 6f 6e 63 20 22 53 45 4c 45 43 54 20 69 64 20 46  onc "SELECT id F
07c0: 52 4f 4d 20 72 75 6e 73 20 57 48 45 52 45 20 28  ROM runs WHERE (
07d0: 72 75 6e 6e 61 6d 65 3d 3f 20 22 20 61 6e 64 73  runname=? " ands
07e0: 74 72 20 6b 65 79 3d 3f 73 74 72 20 22 29 3b 22  tr key=?str ");"
07f0: 29 29 29 0a 09 20 20 20 20 20 3b 28 64 65 62 75  )))..     ;(debu
0800: 67 3a 70 72 69 6e 74 20 34 20 22 71 72 79 3a 20  g:print 4 "qry: 
0810: 22 20 71 72 79 29 20 0a 09 20 20 20 20 20 71 72  " qry) ..     qr
0820: 79 29 0a 09 20 20 20 71 72 79 76 61 6c 73 29 0a  y)..   qryvals).
0830: 09 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63  .  (sqlite3:exec
0840: 75 74 65 20 64 62 20 22 55 50 44 41 54 45 20 72  ute db "UPDATE r
0850: 75 6e 73 20 53 45 54 20 73 74 61 74 65 3d 3f 2c  uns SET state=?,
0860: 73 74 61 74 75 73 3d 3f 20 57 48 45 52 45 20 69  status=? WHERE i
0870: 64 3d 3f 3b 22 20 73 74 61 74 65 20 73 74 61 74  d=?;" state stat
0880: 75 73 20 72 65 73 29 0a 09 20 20 72 65 73 29 20  us res)..  res) 
0890: 0a 09 28 62 65 67 69 6e 0a 09 20 20 28 64 65 62  ..(begin..  (deb
08a0: 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52 4f  ug:print 0 "ERRO
08b0: 52 3a 20 43 61 6c 6c 65 64 20 77 69 74 68 6f 75  R: Called withou
08c0: 74 20 61 6c 6c 20 6e 65 63 65 73 73 61 72 79 20  t all necessary 
08d0: 6b 65 79 73 22 29 0a 09 20 20 23 66 29 29 29 29  keys")..  #f))))
08e0: 0a 0a 3b 3b 20 72 75 6e 73 3a 67 65 74 2d 72 75  ..;; runs:get-ru
08f0: 6e 73 2d 62 79 2d 70 61 74 74 0a 3b 3b 20 67 65  ns-by-patt.;; ge
0900: 74 20 72 75 6e 73 20 62 79 20 6c 69 73 74 20 6f  t runs by list o
0910: 66 20 63 72 69 74 65 72 69 61 0a 3b 3b 20 72 65  f criteria.;; re
0920: 67 69 73 74 65 72 20 61 20 74 65 73 74 20 72 75  gister a test ru
0930: 6e 20 77 69 74 68 20 74 68 65 20 64 62 0a 3b 3b  n with the db.;;
0940: 0a 3b 3b 20 55 73 65 3a 20 28 64 62 2d 67 65 74  .;; Use: (db-get
0950: 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72  -value-by-header
0960: 20 28 64 62 3a 67 65 74 2d 68 65 61 64 65 72 20   (db:get-header 
0970: 72 75 6e 69 6e 66 6f 29 28 64 62 3a 67 65 74 2d  runinfo)(db:get-
0980: 72 6f 77 20 72 75 6e 69 6e 66 6f 29 29 0a 3b 3b  row runinfo)).;;
0990: 20 20 74 6f 20 65 78 74 72 61 63 74 20 69 6e 66    to extract inf
09a0: 6f 20 66 72 6f 6d 20 74 68 65 20 73 74 72 75 63  o from the struc
09b0: 74 75 72 65 20 72 65 74 75 72 6e 65 64 0a 3b 3b  ture returned.;;
09c0: 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 67  .(define (runs:g
09d0: 65 74 2d 72 75 6e 73 2d 62 79 2d 70 61 74 74 20  et-runs-by-patt 
09e0: 64 62 20 6b 65 79 73 20 72 75 6e 6e 61 6d 65 70  db keys runnamep
09f0: 61 74 74 20 2e 20 70 61 72 61 6d 73 29 20 3b 3b  att . params) ;;
0a00: 20 74 65 73 74 2d 6e 61 6d 65 29 0a 20 20 28 6c   test-name).  (l
0a10: 65 74 2a 20 28 28 6b 65 79 76 61 6c 6c 73 74 20  et* ((keyvallst 
0a20: 28 6b 65 79 73 2d 3e 76 61 6c 6c 69 73 74 20 6b  (keys->vallist k
0a30: 65 79 73 29 29 0a 09 20 28 74 6d 70 20 20 20 20  eys)).. (tmp    
0a40: 20 20 28 72 75 6e 73 3a 67 65 74 2d 73 74 64 2d    (runs:get-std-
0a50: 72 75 6e 2d 66 69 65 6c 64 73 20 6b 65 79 73 20  run-fields keys 
0a60: 27 28 22 69 64 22 20 22 72 75 6e 6e 61 6d 65 22  '("id" "runname"
0a70: 20 22 73 74 61 74 65 22 20 22 73 74 61 74 75 73   "state" "status
0a80: 22 20 22 6f 77 6e 65 72 22 20 22 65 76 65 6e 74  " "owner" "event
0a90: 5f 74 69 6d 65 22 29 29 29 0a 09 20 28 6b 65 79  _time"))).. (key
0aa0: 73 74 72 20 20 20 28 63 61 72 20 74 6d 70 29 29  str   (car tmp))
0ab0: 0a 09 20 28 68 65 61 64 65 72 20 20 20 28 63 61  .. (header   (ca
0ac0: 64 72 20 74 6d 70 29 29 0a 09 20 28 72 65 73 20  dr tmp)).. (res 
0ad0: 20 20 20 20 27 28 29 29 0a 09 20 28 6b 65 79 2d      '()).. (key-
0ae0: 70 61 74 74 20 22 22 29 29 0a 20 20 20 20 28 66  patt "")).    (f
0af0: 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 20  or-each (lambda 
0b00: 28 6b 65 79 76 61 6c 29 0a 09 09 28 6c 65 74 2a  (keyval)...(let*
0b10: 20 28 28 6b 65 79 20 20 20 20 28 76 65 63 74 6f   ((key    (vecto
0b20: 72 2d 72 65 66 20 6b 65 79 76 61 6c 20 30 29 29  r-ref keyval 0))
0b30: 0a 09 09 20 20 20 20 20 20 20 28 66 75 6c 6b 65  ...       (fulke
0b40: 79 20 28 63 6f 6e 63 20 22 3a 22 20 6b 65 79 29  y (conc ":" key)
0b50: 29 0a 09 09 20 20 20 20 20 20 20 28 70 61 74 74  )...       (patt
0b60: 20 20 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67     (args:get-arg
0b70: 20 66 75 6c 6b 65 79 29 29 29 0a 09 09 20 20 28   fulkey)))...  (
0b80: 69 66 20 70 61 74 74 0a 09 09 20 20 20 20 20 20  if patt...      
0b90: 28 73 65 74 21 20 6b 65 79 2d 70 61 74 74 20 28  (set! key-patt (
0ba0: 63 6f 6e 63 20 6b 65 79 2d 70 61 74 74 20 22 20  conc key-patt " 
0bb0: 41 4e 44 20 22 20 6b 65 79 20 22 20 6c 69 6b 65  AND " key " like
0bc0: 20 27 22 20 70 61 74 74 20 22 27 22 29 29 0a 09   '" patt "'"))..
0bd0: 09 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09  .      (begin...
0be0: 09 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20  .(debug:print 0 
0bf0: 22 45 52 52 4f 52 3a 20 73 65 61 72 63 68 69 6e  "ERROR: searchin
0c00: 67 20 66 6f 72 20 72 75 6e 73 20 77 69 74 68 20  g for runs with 
0c10: 6e 6f 20 70 61 74 74 65 72 6e 20 73 65 74 20 66  no pattern set f
0c20: 6f 72 20 22 20 66 75 6c 6b 65 79 29 0a 09 09 09  or " fulkey)....
0c30: 28 65 78 69 74 20 36 29 29 29 29 29 0a 09 20 20  (exit 6)))))..  
0c40: 20 20 20 20 6b 65 79 73 29 0a 20 20 20 20 28 73      keys).    (s
0c50: 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d  qlite3:for-each-
0c60: 72 6f 77 20 0a 20 20 20 20 20 28 6c 61 6d 62 64  row .     (lambd
0c70: 61 20 28 61 20 2e 20 72 29 0a 20 20 20 20 20 20  a (a . r).      
0c80: 20 28 73 65 74 21 20 72 65 73 20 28 63 6f 6e 73   (set! res (cons
0c90: 20 28 6c 69 73 74 2d 3e 76 65 63 74 6f 72 20 28   (list->vector (
0ca0: 63 6f 6e 73 20 61 20 72 29 29 20 72 65 73 29 29  cons a r)) res))
0cb0: 29 0a 20 20 20 20 20 64 62 20 0a 20 20 20 20 20  ).     db .     
0cc0: 28 63 6f 6e 63 20 22 53 45 4c 45 43 54 20 22 20  (conc "SELECT " 
0cd0: 6b 65 79 73 74 72 20 22 20 46 52 4f 4d 20 72 75  keystr " FROM ru
0ce0: 6e 73 20 57 48 45 52 45 20 72 75 6e 6e 61 6d 65  ns WHERE runname
0cf0: 20 6c 69 6b 65 20 3f 20 22 20 6b 65 79 2d 70 61   like ? " key-pa
0d00: 74 74 20 22 3b 22 29 0a 20 20 20 20 20 72 75 6e  tt ";").     run
0d10: 6e 61 6d 65 70 61 74 74 29 0a 20 20 20 20 28 76  namepatt).    (v
0d20: 65 63 74 6f 72 20 68 65 61 64 65 72 20 72 65 73  ector header res
0d30: 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 72 65  )))..(define (re
0d40: 67 69 73 74 65 72 2d 74 65 73 74 20 64 62 20 72  gister-test db r
0d50: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
0d60: 69 74 65 6d 2d 70 61 74 68 29 0a 20 20 28 6c 65  item-path).  (le
0d70: 74 20 28 28 69 74 65 6d 2d 70 61 74 68 73 20 28  t ((item-paths (
0d80: 69 66 20 28 65 71 75 61 6c 3f 20 69 74 65 6d 2d  if (equal? item-
0d90: 70 61 74 68 20 22 22 29 0a 09 09 09 28 6c 69 73  path "")....(lis
0da0: 74 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 09 09  t item-path)....
0db0: 28 6c 69 73 74 20 69 74 65 6d 2d 70 61 74 68 20  (list item-path 
0dc0: 22 22 29 29 29 29 0a 20 20 20 20 28 66 6f 72 2d  "")))).    (for-
0dd0: 65 61 63 68 20 0a 20 20 20 20 20 28 6c 61 6d 62  each .     (lamb
0de0: 64 61 20 28 70 74 68 29 0a 20 20 20 20 20 20 20  da (pth).       
0df0: 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65  (sqlite3:execute
0e00: 20 64 62 20 22 49 4e 53 45 52 54 20 4f 52 20 49   db "INSERT OR I
0e10: 47 4e 4f 52 45 20 49 4e 54 4f 20 74 65 73 74 73  GNORE INTO tests
0e20: 20 28 72 75 6e 5f 69 64 2c 74 65 73 74 6e 61 6d   (run_id,testnam
0e30: 65 2c 65 76 65 6e 74 5f 74 69 6d 65 2c 69 74 65  e,event_time,ite
0e40: 6d 5f 70 61 74 68 2c 73 74 61 74 65 2c 73 74 61  m_path,state,sta
0e50: 74 75 73 29 20 56 41 4c 55 45 53 20 28 3f 2c 3f  tus) VALUES (?,?
0e60: 2c 73 74 72 66 74 69 6d 65 28 27 25 73 27 2c 27  ,strftime('%s','
0e70: 6e 6f 77 27 29 2c 3f 2c 27 4e 4f 54 5f 53 54 41  now'),?,'NOT_STA
0e80: 52 54 45 44 27 2c 27 6e 2f 61 27 29 3b 22 20 0a  RTED','n/a');" .
0e90: 09 09 09 72 75 6e 2d 69 64 20 0a 09 09 09 74 65  ...run-id ....te
0ea0: 73 74 2d 6e 61 6d 65 0a 09 09 09 70 74 68 20 0a  st-name....pth .
0eb0: 09 09 09 3b 3b 20 28 63 6f 6e 63 20 22 2c 22 20  ...;; (conc "," 
0ec0: 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65  (string-interspe
0ed0: 72 73 65 20 74 61 67 73 20 22 2c 22 29 20 22 2c  rse tags ",") ",
0ee0: 22 29 0a 09 09 09 29 29 0a 20 20 20 20 20 69 74  ")....)).     it
0ef0: 65 6d 2d 70 61 74 68 73 20 29 29 29 0a 0a 3b 3b  em-paths )))..;;
0f00: 20 67 65 74 20 74 68 65 20 70 72 65 76 69 6f 75   get the previou
0f10: 73 20 72 65 63 6f 72 64 20 66 6f 72 20 77 68 65  s record for whe
0f20: 6e 20 74 68 69 73 20 74 65 73 74 20 77 61 73 20  n this test was 
0f30: 72 75 6e 20 77 68 65 72 65 20 61 6c 6c 20 6b 65  run where all ke
0f40: 79 73 20 6d 61 74 63 68 20 62 75 74 20 72 75 6e  ys match but run
0f50: 6e 61 6d 65 0a 3b 3b 20 72 65 74 75 72 6e 73 20  name.;; returns 
0f60: 23 66 20 69 66 20 6e 6f 20 73 75 63 68 20 74 65  #f if no such te
0f70: 73 74 20 66 6f 75 6e 64 2c 20 72 65 74 75 72 6e  st found, return
0f80: 73 20 61 20 73 69 6e 67 6c 65 20 74 65 73 74 20  s a single test 
0f90: 72 65 63 6f 72 64 20 69 66 20 66 6f 75 6e 64 0a  record if found.
0fa0: 28 64 65 66 69 6e 65 20 28 74 65 73 74 3a 67 65  (define (test:ge
0fb0: 74 2d 70 72 65 76 69 6f 75 73 2d 74 65 73 74 2d  t-previous-test-
0fc0: 72 75 6e 2d 72 65 63 6f 72 64 20 64 62 20 72 75  run-record db ru
0fd0: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69  n-id test-name i
0fe0: 74 65 6d 2d 70 61 74 68 29 0a 20 20 28 6c 65 74  tem-path).  (let
0ff0: 2a 20 28 28 6b 65 79 73 20 20 20 20 28 64 62 3a  * ((keys    (db:
1000: 67 65 74 2d 6b 65 79 73 20 64 62 29 29 0a 09 20  get-keys db)).. 
1010: 28 73 65 6c 73 74 72 20 20 28 73 74 72 69 6e 67  (selstr  (string
1020: 2d 69 6e 74 65 72 73 70 65 72 73 65 20 28 6d 61  -intersperse (ma
1030: 70 20 28 6c 61 6d 62 64 61 20 28 78 29 28 76 65  p (lambda (x)(ve
1040: 63 74 6f 72 2d 72 65 66 20 78 20 30 29 29 20 6b  ctor-ref x 0)) k
1050: 65 79 73 29 20 22 2c 22 29 29 0a 09 20 28 71 72  eys) ",")).. (qr
1060: 79 73 74 72 20 20 28 73 74 72 69 6e 67 2d 69 6e  ystr  (string-in
1070: 74 65 72 73 70 65 72 73 65 20 28 6d 61 70 20 28  tersperse (map (
1080: 6c 61 6d 62 64 61 20 28 78 29 28 63 6f 6e 63 20  lambda (x)(conc 
1090: 28 76 65 63 74 6f 72 2d 72 65 66 20 78 20 30 29  (vector-ref x 0)
10a0: 20 22 3d 3f 22 29 29 20 6b 65 79 73 29 20 22 20   "=?")) keys) " 
10b0: 41 4e 44 20 22 29 29 0a 09 20 28 6b 65 79 76 61  AND ")).. (keyva
10c0: 6c 73 20 23 66 29 29 0a 20 20 20 20 3b 3b 20 66  ls #f)).    ;; f
10d0: 69 72 73 74 20 6c 6f 6f 6b 20 75 70 20 74 68 65  irst look up the
10e0: 20 6b 65 79 20 76 61 6c 75 65 73 20 66 72 6f 6d   key values from
10f0: 20 74 68 65 20 72 75 6e 20 73 65 6c 65 63 74 65   the run selecte
1100: 64 20 62 79 20 72 75 6e 2d 69 64 0a 20 20 20 20  d by run-id.    
1110: 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63  (sqlite3:for-eac
1120: 68 2d 72 6f 77 20 0a 20 20 20 20 20 28 6c 61 6d  h-row .     (lam
1130: 62 64 61 20 28 61 20 2e 20 62 29 0a 20 20 20 20  bda (a . b).    
1140: 20 20 20 28 73 65 74 21 20 6b 65 79 76 61 6c 73     (set! keyvals
1150: 20 28 63 6f 6e 73 20 61 20 62 29 29 29 0a 20 20   (cons a b))).  
1160: 20 20 20 64 62 0a 20 20 20 20 20 28 63 6f 6e 63     db.     (conc
1170: 20 22 53 45 4c 45 43 54 20 22 20 73 65 6c 73 74   "SELECT " selst
1180: 72 20 22 20 46 52 4f 4d 20 72 75 6e 73 20 57 48  r " FROM runs WH
1190: 45 52 45 20 69 64 3d 3f 20 4f 52 44 45 52 20 42  ERE id=? ORDER B
11a0: 59 20 65 76 65 6e 74 5f 74 69 6d 65 20 44 45 53  Y event_time DES
11b0: 43 3b 22 29 20 72 75 6e 2d 69 64 29 0a 20 20 20  C;") run-id).   
11c0: 20 28 69 66 20 28 6e 6f 74 20 6b 65 79 76 61 6c   (if (not keyval
11d0: 73 29 0a 09 23 66 0a 09 28 6c 65 74 20 28 28 70  s)..#f..(let ((p
11e0: 72 65 76 2d 72 75 6e 2d 69 64 73 20 27 28 29 29  rev-run-ids '())
11f0: 29 0a 09 20 20 28 61 70 70 6c 79 20 73 71 6c 69  )..  (apply sqli
1200: 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77  te3:for-each-row
1210: 0a 09 09 20 28 6c 61 6d 62 64 61 20 28 69 64 29  ... (lambda (id)
1220: 0a 09 09 20 20 20 28 73 65 74 21 20 70 72 65 76  ...   (set! prev
1230: 2d 72 75 6e 2d 69 64 73 20 28 63 6f 6e 73 20 69  -run-ids (cons i
1240: 64 20 70 72 65 76 2d 72 75 6e 2d 69 64 73 29 29  d prev-run-ids))
1250: 29 0a 09 09 20 64 62 0a 09 09 20 28 63 6f 6e 63  )... db... (conc
1260: 20 22 53 45 4c 45 43 54 20 69 64 20 46 52 4f 4d   "SELECT id FROM
1270: 20 72 75 6e 73 20 57 48 45 52 45 20 22 20 71 72   runs WHERE " qr
1280: 79 73 74 72 20 22 20 41 4e 44 20 69 64 20 21 3d  ystr " AND id !=
1290: 20 3f 3b 22 29 20 28 61 70 70 65 6e 64 20 6b 65   ?;") (append ke
12a0: 79 76 61 6c 73 20 28 6c 69 73 74 20 72 75 6e 2d  yvals (list run-
12b0: 69 64 29 29 29 0a 09 20 20 3b 3b 20 66 6f 72 20  id)))..  ;; for 
12c0: 65 61 63 68 20 72 75 6e 20 73 74 61 72 74 69 6e  each run startin
12d0: 67 20 77 69 74 68 20 74 68 65 20 6d 6f 73 74 20  g with the most 
12e0: 72 65 63 65 6e 74 20 6c 6f 6f 6b 20 74 6f 20 73  recent look to s
12f0: 65 65 20 69 66 20 74 68 65 72 65 20 69 73 20 61  ee if there is a
1300: 20 6d 61 74 63 68 69 6e 67 20 74 65 73 74 0a 09   matching test..
1310: 20 20 3b 3b 20 69 66 20 66 6f 75 6e 64 20 74 68    ;; if found th
1320: 65 6e 20 72 65 74 75 72 6e 20 74 68 61 74 20 6d  en return that m
1330: 61 74 63 68 69 6e 67 20 74 65 73 74 20 72 65 63  atching test rec
1340: 6f 72 64 0a 09 20 20 28 64 65 62 75 67 3a 70 72  ord..  (debug:pr
1350: 69 6e 74 20 34 20 22 73 65 6c 73 74 72 3a 20 22  int 4 "selstr: "
1360: 20 73 65 6c 73 74 72 20 22 2c 20 71 72 79 73 74   selstr ", qryst
1370: 72 3a 20 22 20 71 72 79 73 74 72 20 22 2c 20 6b  r: " qrystr ", k
1380: 65 79 76 61 6c 73 3a 20 22 20 6b 65 79 76 61 6c  eyvals: " keyval
1390: 73 20 22 2c 20 70 72 65 76 69 6f 75 73 20 72 75  s ", previous ru
13a0: 6e 20 69 64 73 20 66 6f 75 6e 64 3a 20 22 20 70  n ids found: " p
13b0: 72 65 76 2d 72 75 6e 2d 69 64 73 29 0a 09 20 20  rev-run-ids)..  
13c0: 28 69 66 20 28 6e 75 6c 6c 3f 20 70 72 65 76 2d  (if (null? prev-
13d0: 72 75 6e 2d 69 64 73 29 20 23 66 0a 09 20 20 20  run-ids) #f..   
13e0: 20 20 20 28 6c 65 74 20 6c 6f 6f 70 20 28 28 68     (let loop ((h
13f0: 65 64 20 28 63 61 72 20 70 72 65 76 2d 72 75 6e  ed (car prev-run
1400: 2d 69 64 73 29 29 0a 09 09 09 20 28 74 61 6c 20  -ids)).... (tal 
1410: 28 63 64 72 20 70 72 65 76 2d 72 75 6e 2d 69 64  (cdr prev-run-id
1420: 73 29 29 29 0a 09 09 28 6c 65 74 20 28 28 72 65  s)))...(let ((re
1430: 73 75 6c 74 73 20 28 64 62 2d 67 65 74 2d 74 65  sults (db-get-te
1440: 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 68  sts-for-run db h
1450: 65 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65  ed test-name ite
1460: 6d 2d 70 61 74 68 29 29 29 0a 09 09 20 20 28 64  m-path)))...  (d
1470: 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 47 6f  ebug:print 4 "Go
1480: 74 20 74 65 73 74 73 20 66 6f 72 20 72 75 6e 2d  t tests for run-
1490: 69 64 20 22 20 72 75 6e 2d 69 64 20 22 2c 20 74  id " run-id ", t
14a0: 65 73 74 2d 6e 61 6d 65 20 22 20 74 65 73 74 2d  est-name " test-
14b0: 6e 61 6d 65 20 22 2c 20 69 74 65 6d 2d 70 61 74  name ", item-pat
14c0: 68 20 22 20 69 74 65 6d 2d 70 61 74 68 20 22 3a  h " item-path ":
14d0: 20 22 20 72 65 73 75 6c 74 73 29 0a 09 09 20 20   " results)...  
14e0: 28 69 66 20 28 61 6e 64 20 28 6e 75 6c 6c 3f 20  (if (and (null? 
14f0: 72 65 73 75 6c 74 73 29 0a 09 09 09 20 20 20 28  results)....   (
1500: 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 61 6c 29 29  not (null? tal))
1510: 29 0a 09 09 20 20 20 20 20 20 28 6c 6f 6f 70 20  )...      (loop 
1520: 28 63 61 72 20 74 61 6c 29 28 63 64 72 20 74 61  (car tal)(cdr ta
1530: 6c 29 29 0a 09 09 20 20 20 20 20 20 28 69 66 20  l))...      (if 
1540: 28 6e 75 6c 6c 3f 20 72 65 73 75 6c 74 73 29 20  (null? results) 
1550: 23 66 0a 09 09 09 20 20 28 63 61 72 20 72 65 73  #f....  (car res
1560: 75 6c 74 73 29 29 29 29 29 29 29 29 29 29 0a 20  ults)))))))))). 
1570: 20 20 20 0a 3b 3b 20 67 65 74 20 74 68 65 20 70     .;; get the p
1580: 72 65 76 69 6f 75 73 20 72 65 63 6f 72 64 73 20  revious records 
1590: 66 6f 72 20 77 68 65 6e 20 74 68 65 73 65 20 74  for when these t
15a0: 65 73 74 73 20 77 65 72 65 20 72 75 6e 20 77 68  ests were run wh
15b0: 65 72 65 20 61 6c 6c 20 6b 65 79 73 20 6d 61 74  ere all keys mat
15c0: 63 68 20 62 75 74 20 72 75 6e 6e 61 6d 65 0a 3b  ch but runname.;
15d0: 3b 20 4e 42 2f 2f 20 4d 65 72 67 65 20 74 68 69  ; NB// Merge thi
15e0: 73 20 77 69 74 68 20 74 65 73 74 3a 67 65 74 2d  s with test:get-
15f0: 70 72 65 76 69 6f 75 73 2d 74 65 73 74 2d 72 75  previous-test-ru
1600: 6e 2d 72 65 63 6f 72 64 73 3f 20 54 68 69 73 20  n-records? This 
1610: 6f 6e 65 20 6c 6f 6f 6b 73 20 66 6f 72 20 61 6c  one looks for al
1620: 6c 20 6d 61 74 63 68 69 6e 67 20 74 65 73 74 73  l matching tests
1630: 0a 3b 3b 20 63 61 6e 20 75 73 65 20 77 69 6c 64  .;; can use wild
1640: 63 61 72 64 73 2e 20 0a 28 64 65 66 69 6e 65 20  cards. .(define 
1650: 28 74 65 73 74 3a 67 65 74 2d 6d 61 74 63 68 69  (test:get-matchi
1660: 6e 67 2d 70 72 65 76 69 6f 75 73 2d 74 65 73 74  ng-previous-test
1670: 2d 72 75 6e 2d 72 65 63 6f 72 64 73 20 64 62 20  -run-records db 
1680: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
1690: 20 69 74 65 6d 2d 70 61 74 68 29 0a 20 20 28 6c   item-path).  (l
16a0: 65 74 2a 20 28 28 6b 65 79 73 20 20 20 20 28 64  et* ((keys    (d
16b0: 62 3a 67 65 74 2d 6b 65 79 73 20 64 62 29 29 0a  b:get-keys db)).
16c0: 09 20 28 73 65 6c 73 74 72 20 20 28 73 74 72 69  . (selstr  (stri
16d0: 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 28  ng-intersperse (
16e0: 6d 61 70 20 28 6c 61 6d 62 64 61 20 28 78 29 28  map (lambda (x)(
16f0: 76 65 63 74 6f 72 2d 72 65 66 20 78 20 30 29 29  vector-ref x 0))
1700: 20 6b 65 79 73 29 20 22 2c 22 29 29 0a 09 20 28   keys) ",")).. (
1710: 71 72 79 73 74 72 20 20 28 73 74 72 69 6e 67 2d  qrystr  (string-
1720: 69 6e 74 65 72 73 70 65 72 73 65 20 28 6d 61 70  intersperse (map
1730: 20 28 6c 61 6d 62 64 61 20 28 78 29 28 63 6f 6e   (lambda (x)(con
1740: 63 20 28 76 65 63 74 6f 72 2d 72 65 66 20 78 20  c (vector-ref x 
1750: 30 29 20 22 3d 3f 22 29 29 20 6b 65 79 73 29 20  0) "=?")) keys) 
1760: 22 20 41 4e 44 20 22 29 29 0a 09 20 28 6b 65 79  " AND ")).. (key
1770: 76 61 6c 73 20 23 66 29 0a 09 20 28 74 65 73 74  vals #f).. (test
1780: 73 2d 68 61 73 68 20 28 6d 61 6b 65 2d 68 61 73  s-hash (make-has
1790: 68 2d 74 61 62 6c 65 29 29 29 0a 20 20 20 20 3b  h-table))).    ;
17a0: 3b 20 66 69 72 73 74 20 6c 6f 6f 6b 20 75 70 20  ; first look up 
17b0: 74 68 65 20 6b 65 79 20 76 61 6c 75 65 73 20 66  the key values f
17c0: 72 6f 6d 20 74 68 65 20 72 75 6e 20 73 65 6c 65  rom the run sele
17d0: 63 74 65 64 20 62 79 20 72 75 6e 2d 69 64 0a 20  cted by run-id. 
17e0: 20 20 20 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d     (sqlite3:for-
17f0: 65 61 63 68 2d 72 6f 77 20 0a 20 20 20 20 20 28  each-row .     (
1800: 6c 61 6d 62 64 61 20 28 61 20 2e 20 62 29 0a 20  lambda (a . b). 
1810: 20 20 20 20 20 20 28 73 65 74 21 20 6b 65 79 76        (set! keyv
1820: 61 6c 73 20 28 63 6f 6e 73 20 61 20 62 29 29 29  als (cons a b)))
1830: 0a 20 20 20 20 20 64 62 0a 20 20 20 20 20 28 63  .     db.     (c
1840: 6f 6e 63 20 22 53 45 4c 45 43 54 20 22 20 73 65  onc "SELECT " se
1850: 6c 73 74 72 20 22 20 46 52 4f 4d 20 72 75 6e 73  lstr " FROM runs
1860: 20 57 48 45 52 45 20 69 64 3d 3f 20 4f 52 44 45   WHERE id=? ORDE
1870: 52 20 42 59 20 65 76 65 6e 74 5f 74 69 6d 65 20  R BY event_time 
1880: 44 45 53 43 3b 22 29 20 72 75 6e 2d 69 64 29 0a  DESC;") run-id).
1890: 20 20 20 20 28 69 66 20 28 6e 6f 74 20 6b 65 79      (if (not key
18a0: 76 61 6c 73 29 0a 09 27 28 29 0a 09 28 6c 65 74  vals)..'()..(let
18b0: 20 28 28 70 72 65 76 2d 72 75 6e 2d 69 64 73 20   ((prev-run-ids 
18c0: 27 28 29 29 29 0a 09 20 20 28 61 70 70 6c 79 20  '()))..  (apply 
18d0: 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68  sqlite3:for-each
18e0: 2d 72 6f 77 0a 09 09 20 28 6c 61 6d 62 64 61 20  -row... (lambda 
18f0: 28 69 64 29 0a 09 09 20 20 20 28 73 65 74 21 20  (id)...   (set! 
1900: 70 72 65 76 2d 72 75 6e 2d 69 64 73 20 28 63 6f  prev-run-ids (co
1910: 6e 73 20 69 64 20 70 72 65 76 2d 72 75 6e 2d 69  ns id prev-run-i
1920: 64 73 29 29 29 0a 09 09 20 64 62 0a 09 09 20 28  ds)))... db... (
1930: 63 6f 6e 63 20 22 53 45 4c 45 43 54 20 69 64 20  conc "SELECT id 
1940: 46 52 4f 4d 20 72 75 6e 73 20 57 48 45 52 45 20  FROM runs WHERE 
1950: 22 20 71 72 79 73 74 72 20 22 20 41 4e 44 20 69  " qrystr " AND i
1960: 64 20 21 3d 20 3f 3b 22 29 20 28 61 70 70 65 6e  d != ?;") (appen
1970: 64 20 6b 65 79 76 61 6c 73 20 28 6c 69 73 74 20  d keyvals (list 
1980: 72 75 6e 2d 69 64 29 29 29 0a 09 20 20 3b 3b 20  run-id)))..  ;; 
1990: 63 6f 6c 6c 65 63 74 20 61 6c 6c 20 6d 61 74 63  collect all matc
19a0: 68 69 6e 67 20 74 65 73 74 73 20 66 6f 72 20 74  hing tests for t
19b0: 68 65 20 72 75 6e 73 20 74 68 65 6e 0a 09 20 20  he runs then..  
19c0: 3b 3b 20 65 78 74 72 61 63 74 20 74 68 65 20 6d  ;; extract the m
19d0: 6f 73 74 20 72 65 63 65 6e 74 20 74 65 73 74 20  ost recent test 
19e0: 61 6e 64 20 72 65 74 75 72 6e 20 74 68 61 74 2e  and return that.
19f0: 0a 09 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ..  (debug:print
1a00: 20 34 20 22 73 65 6c 73 74 72 3a 20 22 20 73 65   4 "selstr: " se
1a10: 6c 73 74 72 20 22 2c 20 71 72 79 73 74 72 3a 20  lstr ", qrystr: 
1a20: 22 20 71 72 79 73 74 72 20 22 2c 20 6b 65 79 76  " qrystr ", keyv
1a30: 61 6c 73 3a 20 22 20 6b 65 79 76 61 6c 73 20 0a  als: " keyvals .
1a40: 09 09 20 20 20 20 20 20 20 22 2c 20 70 72 65 76  ..       ", prev
1a50: 69 6f 75 73 20 72 75 6e 20 69 64 73 20 66 6f 75  ious run ids fou
1a60: 6e 64 3a 20 22 20 70 72 65 76 2d 72 75 6e 2d 69  nd: " prev-run-i
1a70: 64 73 29 0a 09 20 20 28 69 66 20 28 6e 75 6c 6c  ds)..  (if (null
1a80: 3f 20 70 72 65 76 2d 72 75 6e 2d 69 64 73 29 20  ? prev-run-ids) 
1a90: 27 28 29 20 20 3b 3b 20 6e 6f 20 70 72 65 76 69  '()  ;; no previ
1aa0: 6f 75 73 20 72 75 6e 73 3f 20 72 65 74 75 72 6e  ous runs? return
1ab0: 20 6e 75 6c 6c 0a 09 20 20 20 20 20 20 28 6c 65   null..      (le
1ac0: 74 20 6c 6f 6f 70 20 28 28 68 65 64 20 28 63 61  t loop ((hed (ca
1ad0: 72 20 70 72 65 76 2d 72 75 6e 2d 69 64 73 29 29  r prev-run-ids))
1ae0: 0a 09 09 09 20 28 74 61 6c 20 28 63 64 72 20 70  .... (tal (cdr p
1af0: 72 65 76 2d 72 75 6e 2d 69 64 73 29 29 29 0a 09  rev-run-ids)))..
1b00: 09 28 6c 65 74 20 28 28 72 65 73 75 6c 74 73 20  .(let ((results 
1b10: 28 64 62 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f  (db-get-tests-fo
1b20: 72 2d 72 75 6e 20 64 62 20 68 65 64 20 74 65 73  r-run db hed tes
1b30: 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68  t-name item-path
1b40: 29 29 29 0a 09 09 20 20 28 64 65 62 75 67 3a 70  )))...  (debug:p
1b50: 72 69 6e 74 20 34 20 22 47 6f 74 20 74 65 73 74  rint 4 "Got test
1b60: 73 20 66 6f 72 20 72 75 6e 2d 69 64 20 22 20 72  s for run-id " r
1b70: 75 6e 2d 69 64 20 22 2c 20 74 65 73 74 2d 6e 61  un-id ", test-na
1b80: 6d 65 20 22 20 74 65 73 74 2d 6e 61 6d 65 20 0a  me " test-name .
1b90: 09 09 09 20 20 20 20 20 20 20 22 2c 20 69 74 65  ...       ", ite
1ba0: 6d 2d 70 61 74 68 20 22 20 69 74 65 6d 2d 70 61  m-path " item-pa
1bb0: 74 68 20 22 20 72 65 73 75 6c 74 73 3a 20 22 20  th " results: " 
1bc0: 28 69 6e 74 65 72 73 70 65 72 73 65 20 72 65 73  (intersperse res
1bd0: 75 6c 74 73 20 22 5c 6e 22 29 29 0a 09 09 20 20  ults "\n"))...  
1be0: 3b 3b 20 4b 65 65 70 20 6f 6e 6c 79 20 74 68 65  ;; Keep only the
1bf0: 20 79 6f 75 6e 67 65 73 74 20 6f 66 20 61 6e 79   youngest of any
1c00: 20 74 65 73 74 2f 69 74 65 6d 20 63 6f 6d 62 69   test/item combi
1c10: 6e 61 74 69 6f 6e 0a 09 09 20 20 28 66 6f 72 2d  nation...  (for-
1c20: 65 61 63 68 20 0a 09 09 20 20 20 28 6c 61 6d 62  each ...   (lamb
1c30: 64 61 20 28 74 65 73 74 64 61 74 29 0a 09 09 20  da (testdat)... 
1c40: 20 20 20 20 28 6c 65 74 2a 20 28 28 66 75 6c 6c      (let* ((full
1c50: 2d 74 65 73 74 6e 61 6d 65 20 28 63 6f 6e 63 20  -testname (conc 
1c60: 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73  (db:test-get-tes
1c70: 74 6e 61 6d 65 20 74 65 73 74 64 61 74 29 20 22  tname testdat) "
1c80: 2f 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d  /" (db:test-get-
1c90: 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 64 61  item-path testda
1ca0: 74 29 29 29 0a 09 09 09 20 20 20 20 28 73 74 6f  t)))....    (sto
1cb0: 72 65 64 2d 74 65 73 74 20 20 20 28 68 61 73 68  red-test   (hash
1cc0: 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75  -table-ref/defau
1cd0: 6c 74 20 74 65 73 74 73 2d 68 61 73 68 20 66 75  lt tests-hash fu
1ce0: 6c 6c 2d 74 65 73 74 6e 61 6d 65 20 23 66 29 29  ll-testname #f))
1cf0: 29 0a 09 09 20 20 20 20 20 20 20 28 69 66 20 28  )...       (if (
1d00: 6f 72 20 28 6e 6f 74 20 73 74 6f 72 65 64 2d 74  or (not stored-t
1d10: 65 73 74 29 0a 09 09 09 20 20 20 20 20 20 20 28  est)....       (
1d20: 61 6e 64 20 73 74 6f 72 65 64 2d 74 65 73 74 0a  and stored-test.
1d30: 09 09 09 09 20 20 20 20 28 3e 20 28 64 62 3a 74  ....    (> (db:t
1d40: 65 73 74 2d 67 65 74 2d 65 76 65 6e 74 5f 74 69  est-get-event_ti
1d50: 6d 65 20 74 65 73 74 64 61 74 29 28 64 62 3a 74  me testdat)(db:t
1d60: 65 73 74 2d 67 65 74 2d 65 76 65 6e 74 5f 74 69  est-get-event_ti
1d70: 6d 65 20 73 74 6f 72 65 64 2d 74 65 73 74 29 29  me stored-test))
1d80: 29 29 0a 09 09 09 20 20 20 3b 3b 20 74 68 69 73  ))....   ;; this
1d90: 20 74 65 73 74 20 69 73 20 79 6f 75 6e 67 65 72   test is younger
1da0: 2c 20 73 74 6f 72 65 20 69 74 20 69 6e 20 74 68  , store it in th
1db0: 65 20 68 61 73 68 0a 09 09 09 20 20 20 28 68 61  e hash....   (ha
1dc0: 73 68 2d 74 61 62 6c 65 2d 73 65 74 21 20 74 65  sh-table-set! te
1dd0: 73 74 73 2d 68 61 73 68 20 66 75 6c 6c 2d 74 65  sts-hash full-te
1de0: 73 74 6e 61 6d 65 20 74 65 73 74 64 61 74 29 29  stname testdat))
1df0: 29 29 0a 09 09 20 20 20 72 65 73 75 6c 74 73 29  ))...   results)
1e00: 0a 09 09 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20  ...  (if (null? 
1e10: 74 61 6c 29 0a 09 09 20 20 20 20 20 20 28 6d 61  tal)...      (ma
1e20: 70 20 63 64 72 20 28 68 61 73 68 2d 74 61 62 6c  p cdr (hash-tabl
1e30: 65 2d 3e 61 6c 69 73 74 20 74 65 73 74 73 2d 68  e->alist tests-h
1e40: 61 73 68 29 29 20 3b 3b 20 72 65 74 75 72 6e 20  ash)) ;; return 
1e50: 61 20 6c 69 73 74 20 6f 66 20 74 68 65 20 6d 6f  a list of the mo
1e60: 73 74 20 72 65 63 65 6e 74 20 74 65 73 74 73 0a  st recent tests.
1e70: 09 09 20 20 20 20 20 20 28 6c 6f 6f 70 20 28 63  ..      (loop (c
1e80: 61 72 20 74 61 6c 29 28 63 64 72 20 74 61 6c 29  ar tal)(cdr tal)
1e90: 29 29 29 29 29 29 29 29 29 0a 0a 28 64 65 66 69  )))))))))..(defi
1ea0: 6e 65 20 28 74 65 73 74 2d 73 65 74 2d 73 74 61  ne (test-set-sta
1eb0: 74 75 73 21 20 64 62 20 72 75 6e 2d 69 64 20 74  tus! db run-id t
1ec0: 65 73 74 2d 6e 61 6d 65 20 73 74 61 74 65 20 73  est-name state s
1ed0: 74 61 74 75 73 20 69 74 65 6d 64 61 74 2d 6f 72  tatus itemdat-or
1ee0: 2d 70 61 74 68 20 63 6f 6d 6d 65 6e 74 20 64 61  -path comment da
1ef0: 74 29 0a 20 20 28 6c 65 74 2a 20 28 28 72 65 61  t).  (let* ((rea
1f00: 6c 2d 73 74 61 74 75 73 20 73 74 61 74 75 73 29  l-status status)
1f10: 0a 09 20 28 69 74 65 6d 2d 70 61 74 68 20 20 20  .. (item-path   
1f20: 28 69 66 20 28 73 74 72 69 6e 67 3f 20 69 74 65  (if (string? ite
1f30: 6d 64 61 74 2d 6f 72 2d 70 61 74 68 29 20 69 74  mdat-or-path) it
1f40: 65 6d 64 61 74 2d 6f 72 2d 70 61 74 68 20 28 69  emdat-or-path (i
1f50: 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69  tem-list->path i
1f60: 74 65 6d 64 61 74 2d 6f 72 2d 70 61 74 68 29 29  temdat-or-path))
1f70: 29 0a 09 20 28 74 65 73 74 64 61 74 20 20 20 20  ).. (testdat    
1f80: 20 28 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e   (db:get-test-in
1f90: 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  fo db run-id tes
1fa0: 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68  t-name item-path
1fb0: 29 29 0a 09 20 28 74 65 73 74 2d 69 64 20 20 20  )).. (test-id   
1fc0: 20 20 28 69 66 20 74 65 73 74 64 61 74 20 28 64    (if testdat (d
1fd0: 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65  b:test-get-id te
1fe0: 73 74 64 61 74 29 20 23 66 29 29 0a 09 20 28 6f  stdat) #f)).. (o
1ff0: 74 68 65 72 64 61 74 20 20 20 20 28 69 66 20 64  therdat    (if d
2000: 61 74 20 64 61 74 20 28 6d 61 6b 65 2d 68 61 73  at dat (make-has
2010: 68 2d 74 61 62 6c 65 29 29 29 0a 09 20 3b 3b 20  h-table))).. ;; 
2020: 62 65 66 6f 72 65 20 70 72 6f 63 65 65 64 69 6e  before proceedin
2030: 67 20 77 65 20 6d 75 73 74 20 66 69 6e 64 20 6f  g we must find o
2040: 75 74 20 69 66 20 74 68 65 20 70 72 65 76 69 6f  ut if the previo
2050: 75 73 20 74 65 73 74 20 28 77 68 65 72 65 20 61  us test (where a
2060: 6c 6c 20 6b 65 79 73 20 6d 61 74 63 68 65 64 20  ll keys matched 
2070: 65 78 63 65 70 74 20 72 75 6e 6e 61 6d 65 29 0a  except runname).
2080: 09 20 3b 3b 20 77 61 73 20 57 41 49 56 45 44 20  . ;; was WAIVED 
2090: 69 66 20 74 68 69 73 20 74 65 73 74 20 69 73 20  if this test is 
20a0: 46 41 49 4c 0a 09 20 28 77 61 69 76 65 64 20 20  FAIL.. (waived  
20b0: 20 28 69 66 20 28 65 71 75 61 6c 3f 20 73 74 61   (if (equal? sta
20c0: 74 75 73 20 22 46 41 49 4c 22 29 0a 09 09 20 20  tus "FAIL")...  
20d0: 20 20 20 20 20 28 6c 65 74 20 28 28 70 72 65 76       (let ((prev
20e0: 2d 74 65 73 74 20 28 74 65 73 74 3a 67 65 74 2d  -test (test:get-
20f0: 70 72 65 76 69 6f 75 73 2d 74 65 73 74 2d 72 75  previous-test-ru
2100: 6e 2d 72 65 63 6f 72 64 20 64 62 20 72 75 6e 2d  n-record db run-
2110: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65  id test-name ite
2120: 6d 2d 70 61 74 68 29 29 29 0a 09 09 09 20 28 69  m-path))).... (i
2130: 66 20 70 72 65 76 2d 74 65 73 74 20 3b 3b 20 74  f prev-test ;; t
2140: 72 75 65 20 69 66 20 77 65 20 66 6f 75 6e 64 20  rue if we found 
2150: 61 20 70 72 65 76 69 6f 75 73 20 74 65 73 74 20  a previous test 
2160: 69 6e 20 74 68 69 73 20 72 75 6e 20 73 65 72 69  in this run seri
2170: 65 73 0a 09 09 09 20 20 20 20 20 28 6c 65 74 20  es....     (let 
2180: 28 28 70 72 65 76 2d 73 74 61 74 75 73 20 28 64  ((prev-status (d
2190: 62 3a 74 65 73 74 2d 67 65 74 2d 73 74 61 74 75  b:test-get-statu
21a0: 73 20 20 20 70 72 65 76 2d 74 65 73 74 29 29 0a  s   prev-test)).
21b0: 09 09 09 09 20 20 20 28 70 72 65 76 2d 73 74 61  ....   (prev-sta
21c0: 74 65 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74  te  (db:test-get
21d0: 2d 73 74 61 74 65 20 20 20 20 70 72 65 76 2d 74  -state    prev-t
21e0: 65 73 74 29 29 0a 09 09 09 09 20 20 20 28 70 72  est)).....   (pr
21f0: 65 76 2d 63 6f 6d 6d 65 6e 74 20 28 64 62 3a 74  ev-comment (db:t
2200: 65 73 74 2d 67 65 74 2d 63 6f 6d 6d 65 6e 74 20  est-get-comment 
2210: 70 72 65 76 2d 74 65 73 74 29 29 29 0a 09 09 09  prev-test)))....
2220: 20 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72         (debug:pr
2230: 69 6e 74 20 34 20 22 70 72 65 76 2d 73 74 61 74  int 4 "prev-stat
2240: 75 73 20 22 20 70 72 65 76 2d 73 74 61 74 75 73  us " prev-status
2250: 20 22 2c 20 70 72 65 76 2d 73 74 61 74 65 20 22   ", prev-state "
2260: 20 70 72 65 76 2d 73 74 61 74 65 20 22 2c 20 70   prev-state ", p
2270: 72 65 76 2d 63 6f 6d 6d 65 6e 74 20 22 20 70 72  rev-comment " pr
2280: 65 76 2d 63 6f 6d 6d 65 6e 74 29 0a 09 09 09 20  ev-comment).... 
2290: 20 20 20 20 20 20 28 69 66 20 28 61 6e 64 20 28        (if (and (
22a0: 65 71 75 61 6c 3f 20 70 72 65 76 2d 73 74 61 74  equal? prev-stat
22b0: 65 20 20 22 43 4f 4d 50 4c 45 54 45 44 22 29 0a  e  "COMPLETED").
22c0: 09 09 09 09 09 28 65 71 75 61 6c 3f 20 70 72 65  .....(equal? pre
22d0: 76 2d 73 74 61 74 75 73 20 22 57 41 49 56 45 44  v-status "WAIVED
22e0: 22 29 29 0a 09 09 09 09 20 20 20 70 72 65 76 2d  ")).....   prev-
22f0: 63 6f 6d 6d 65 6e 74 20 3b 3b 20 77 61 69 76 65  comment ;; waive
2300: 64 20 69 73 20 65 69 74 68 65 72 20 74 68 65 20  d is either the 
2310: 63 6f 6d 6d 65 6e 74 20 6f 72 20 23 66 0a 09 09  comment or #f...
2320: 09 09 20 20 20 23 66 29 29 0a 09 09 09 20 20 20  ..   #f))....   
2330: 20 20 23 66 29 29 0a 09 09 20 20 20 20 20 20 20    #f))...       
2340: 23 66 29 29 29 0a 20 20 20 20 28 69 66 20 77 61  #f))).    (if wa
2350: 69 76 65 64 20 28 73 65 74 21 20 72 65 61 6c 2d  ived (set! real-
2360: 73 74 61 74 75 73 20 22 57 41 49 56 45 44 22 29  status "WAIVED")
2370: 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72 69  ).    (debug:pri
2380: 6e 74 20 34 20 22 72 65 61 6c 2d 73 74 61 74 75  nt 4 "real-statu
2390: 73 20 22 20 72 65 61 6c 2d 73 74 61 74 75 73 20  s " real-status 
23a0: 22 2c 20 77 61 69 76 65 64 20 22 20 77 61 69 76  ", waived " waiv
23b0: 65 64 20 22 2c 20 73 74 61 74 75 73 20 22 20 73  ed ", status " s
23c0: 74 61 74 75 73 29 0a 0a 20 20 20 20 3b 3b 20 75  tatus)..    ;; u
23d0: 70 64 61 74 65 20 74 68 65 20 70 72 69 6d 61 72  pdate the primar
23e0: 79 20 72 65 63 6f 72 64 20 49 46 20 73 74 61 74  y record IF stat
23f0: 65 20 41 4e 44 20 73 74 61 74 75 73 20 61 72 65  e AND status are
2400: 20 64 65 66 69 6e 65 64 0a 20 20 20 20 28 69 66   defined.    (if
2410: 20 28 61 6e 64 20 73 74 61 74 65 20 73 74 61 74   (and state stat
2420: 75 73 29 0a 09 28 73 71 6c 69 74 65 33 3a 65 78  us)..(sqlite3:ex
2430: 65 63 75 74 65 20 64 62 20 22 55 50 44 41 54 45  ecute db "UPDATE
2440: 20 74 65 73 74 73 20 53 45 54 20 73 74 61 74 65   tests SET state
2450: 3d 3f 2c 73 74 61 74 75 73 3d 3f 2c 65 76 65 6e  =?,status=?,even
2460: 74 5f 74 69 6d 65 3d 73 74 72 66 74 69 6d 65 28  t_time=strftime(
2470: 27 25 73 27 2c 27 6e 6f 77 27 29 20 57 48 45 52  '%s','now') WHER
2480: 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74  E run_id=? AND t
2490: 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74  estname=? AND it
24a0: 65 6d 5f 70 61 74 68 3d 3f 3b 22 20 0a 09 09 09  em_path=?;" ....
24b0: 20 73 74 61 74 65 20 72 65 61 6c 2d 73 74 61 74   state real-stat
24c0: 75 73 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e  us run-id test-n
24d0: 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29 29 0a  ame item-path)).
24e0: 0a 20 20 20 20 3b 3b 20 69 66 20 73 74 61 74 75  .    ;; if statu
24f0: 73 20 69 73 20 22 41 55 54 4f 22 20 74 68 65 6e  s is "AUTO" then
2500: 20 63 61 6c 6c 20 72 6f 6c 6c 75 70 0a 20 20 20   call rollup.   
2510: 20 28 69 66 20 28 61 6e 64 20 74 65 73 74 2d 69   (if (and test-i
2520: 64 20 73 74 61 74 65 20 73 74 61 74 75 73 20 28  d state status (
2530: 65 71 75 61 6c 3f 20 73 74 61 74 75 73 20 22 41  equal? status "A
2540: 55 54 4f 22 29 29 20 0a 09 28 64 62 3a 74 65 73  UTO")) ..(db:tes
2550: 74 2d 64 61 74 61 2d 72 6f 6c 6c 75 70 20 64 62  t-data-rollup db
2560: 20 74 65 73 74 2d 69 64 29 29 0a 0a 20 20 20 20   test-id))..    
2570: 3b 3b 20 61 64 64 20 6d 65 74 61 64 61 74 61 20  ;; add metadata 
2580: 28 6e 65 65 64 20 74 6f 20 64 6f 20 74 68 69 73  (need to do this
2590: 20 77 61 79 20 74 6f 20 61 76 6f 69 64 20 53 51   way to avoid SQ
25a0: 4c 20 69 6e 6a 65 63 74 69 6f 6e 20 69 73 73 75  L injection issu
25b0: 65 73 29 0a 0a 20 20 20 20 3b 3b 20 3a 66 69 72  es)..    ;; :fir
25c0: 73 74 5f 65 72 72 0a 20 20 20 20 28 6c 65 74 20  st_err.    (let 
25d0: 28 28 76 61 6c 20 28 68 61 73 68 2d 74 61 62 6c  ((val (hash-tabl
25e0: 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 6f 74  e-ref/default ot
25f0: 68 65 72 64 61 74 20 22 3a 66 69 72 73 74 5f 65  herdat ":first_e
2600: 72 72 22 20 23 66 29 29 29 0a 20 20 20 20 20 20  rr" #f))).      
2610: 28 69 66 20 76 61 6c 0a 09 20 20 28 73 71 6c 69  (if val..  (sqli
2620: 74 65 33 3a 65 78 65 63 75 74 65 20 64 62 20 22  te3:execute db "
2630: 55 50 44 41 54 45 20 74 65 73 74 73 20 53 45 54  UPDATE tests SET
2640: 20 66 69 72 73 74 5f 65 72 72 3d 3f 20 57 48 45   first_err=? WHE
2650: 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20  RE run_id=? AND 
2660: 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69  testname=? AND i
2670: 74 65 6d 5f 70 61 74 68 3d 3f 3b 22 20 76 61 6c  tem_path=?;" val
2680: 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d   run-id test-nam
2690: 65 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 0a  e item-path)))..
26a0: 20 20 20 20 3b 3b 20 3a 66 69 72 73 74 5f 77 61      ;; :first_wa
26b0: 72 6e 0a 20 20 20 20 28 6c 65 74 20 28 28 76 61  rn.    (let ((va
26c0: 6c 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65  l (hash-table-re
26d0: 66 2f 64 65 66 61 75 6c 74 20 6f 74 68 65 72 64  f/default otherd
26e0: 61 74 20 22 3a 66 69 72 73 74 5f 77 61 72 6e 22  at ":first_warn"
26f0: 20 23 66 29 29 29 0a 20 20 20 20 20 20 28 69 66   #f))).      (if
2700: 20 76 61 6c 0a 09 20 20 28 73 71 6c 69 74 65 33   val..  (sqlite3
2710: 3a 65 78 65 63 75 74 65 20 64 62 20 22 55 50 44  :execute db "UPD
2720: 41 54 45 20 74 65 73 74 73 20 53 45 54 20 66 69  ATE tests SET fi
2730: 72 73 74 5f 77 61 72 6e 3d 3f 20 57 48 45 52 45  rst_warn=? WHERE
2740: 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65   run_id=? AND te
2750: 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65  stname=? AND ite
2760: 6d 5f 70 61 74 68 3d 3f 3b 22 20 76 61 6c 20 72  m_path=?;" val r
2770: 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20  un-id test-name 
2780: 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 0a 20 20  item-path)))..  
2790: 20 20 28 6c 65 74 20 28 28 63 61 74 65 67 6f 72    (let ((categor
27a0: 79 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65  y (hash-table-re
27b0: 66 2f 64 65 66 61 75 6c 74 20 6f 74 68 65 72 64  f/default otherd
27c0: 61 74 20 22 3a 63 61 74 65 67 6f 72 79 22 20 22  at ":category" "
27d0: 22 29 29 0a 09 20 20 28 76 61 72 69 61 62 6c 65  "))..  (variable
27e0: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66   (hash-table-ref
27f0: 2f 64 65 66 61 75 6c 74 20 6f 74 68 65 72 64 61  /default otherda
2800: 74 20 22 3a 76 61 72 69 61 62 6c 65 22 20 22 22  t ":variable" ""
2810: 29 29 0a 09 20 20 28 76 61 6c 75 65 20 20 20 20  ))..  (value    
2820: 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f  (hash-table-ref/
2830: 64 65 66 61 75 6c 74 20 6f 74 68 65 72 64 61 74  default otherdat
2840: 20 22 3a 76 61 6c 75 65 22 20 20 20 20 23 66 29   ":value"    #f)
2850: 29 0a 09 20 20 28 65 78 70 65 63 74 65 64 20 28  )..  (expected (
2860: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64  hash-table-ref/d
2870: 65 66 61 75 6c 74 20 6f 74 68 65 72 64 61 74 20  efault otherdat 
2880: 22 3a 65 78 70 65 63 74 65 64 22 20 23 66 29 29  ":expected" #f))
2890: 0a 09 20 20 28 74 6f 6c 20 20 20 20 20 20 28 68  ..  (tol      (h
28a0: 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65  ash-table-ref/de
28b0: 66 61 75 6c 74 20 6f 74 68 65 72 64 61 74 20 22  fault otherdat "
28c0: 3a 74 6f 6c 22 20 20 20 20 20 20 23 66 29 29 0a  :tol"      #f)).
28d0: 09 20 20 28 75 6e 69 74 73 20 20 20 20 28 68 61  .  (units    (ha
28e0: 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66  sh-table-ref/def
28f0: 61 75 6c 74 20 6f 74 68 65 72 64 61 74 20 22 3a  ault otherdat ":
2900: 75 6e 69 74 73 22 20 20 20 20 22 22 29 29 0a 09  units"    ""))..
2910: 20 20 28 64 63 6f 6d 6d 65 6e 74 20 28 68 61 73    (dcomment (has
2920: 68 2d 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61  h-table-ref/defa
2930: 75 6c 74 20 6f 74 68 65 72 64 61 74 20 22 3a 63  ult otherdat ":c
2940: 6f 6d 6d 65 6e 74 22 20 20 22 22 29 29 29 0a 20  omment"  ""))). 
2950: 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e       (debug:prin
2960: 74 20 34 20 0a 09 09 20 20 20 22 63 61 74 65 67  t 4 ...   "categ
2970: 6f 72 79 3a 20 22 20 63 61 74 65 67 6f 72 79 20  ory: " category 
2980: 22 2c 20 76 61 72 69 61 62 6c 65 3a 20 22 20 76  ", variable: " v
2990: 61 72 69 61 62 6c 65 20 22 2c 20 76 61 6c 75 65  ariable ", value
29a0: 3a 20 22 20 76 61 6c 75 65 0a 09 09 20 20 20 22  : " value...   "
29b0: 2c 20 65 78 70 65 63 74 65 64 3a 20 22 20 65 78  , expected: " ex
29c0: 70 65 63 74 65 64 20 22 2c 20 74 6f 6c 3a 20 22  pected ", tol: "
29d0: 20 74 6f 6c 20 22 2c 20 75 6e 69 74 73 3a 20 22   tol ", units: "
29e0: 20 75 6e 69 74 73 29 0a 20 20 20 20 20 20 28 69   units).      (i
29f0: 66 20 28 61 6e 64 20 76 61 6c 75 65 20 65 78 70  f (and value exp
2a00: 65 63 74 65 64 20 74 6f 6c 29 20 3b 3b 20 61 6c  ected tol) ;; al
2a10: 6c 20 74 68 72 65 65 20 72 65 71 75 69 72 65 64  l three required
2a20: 0a 09 20 20 28 64 62 3a 63 73 76 2d 3e 74 65 73  ..  (db:csv->tes
2a30: 74 2d 64 61 74 61 20 64 62 20 74 65 73 74 2d 69  t-data db test-i
2a40: 64 20 0a 09 09 09 20 20 20 20 20 28 63 6f 6e 63  d ....     (conc
2a50: 20 63 61 74 65 67 6f 72 79 20 22 2c 22 0a 09 09   category ","...
2a60: 09 09 20 20 20 76 61 72 69 61 62 6c 65 20 22 2c  ..   variable ",
2a70: 22 0a 09 09 09 09 20 20 20 76 61 6c 75 65 20 20  ".....   value  
2a80: 20 20 22 2c 22 0a 09 09 09 09 20 20 20 65 78 70    ",".....   exp
2a90: 65 63 74 65 64 20 22 2c 22 0a 09 09 09 09 20 20  ected ",".....  
2aa0: 20 74 6f 6c 20 20 20 20 20 20 22 2c 22 0a 09 09   tol      ","...
2ab0: 09 09 20 20 20 75 6e 69 74 73 20 20 20 20 22 2c  ..   units    ",
2ac0: 22 0a 09 09 09 09 20 20 20 64 63 6f 6d 6d 65 6e  ".....   dcommen
2ad0: 74 20 22 2c 22 29 29 29 29 0a 09 09 09 09 20 20  t ",")))).....  
2ae0: 20 0a 20 20 20 20 3b 3b 20 6e 65 65 64 20 74 6f   .    ;; need to
2af0: 20 75 70 64 61 74 65 20 74 68 65 20 74 6f 70 20   update the top 
2b00: 74 65 73 74 20 72 65 63 6f 72 64 20 69 66 20 50  test record if P
2b10: 41 53 53 20 6f 72 20 46 41 49 4c 20 61 6e 64 20  ASS or FAIL and 
2b20: 74 68 69 73 20 69 73 20 61 20 73 75 62 74 65 73  this is a subtes
2b30: 74 0a 20 20 20 20 28 69 66 20 28 61 6e 64 20 28  t.    (if (and (
2b40: 6e 6f 74 20 28 65 71 75 61 6c 3f 20 69 74 65 6d  not (equal? item
2b50: 2d 70 61 74 68 20 22 22 29 29 0a 09 20 20 20 20  -path ""))..    
2b60: 20 28 6f 72 20 28 65 71 75 61 6c 3f 20 73 74 61   (or (equal? sta
2b70: 74 75 73 20 22 50 41 53 53 22 29 0a 09 09 20 28  tus "PASS")... (
2b80: 65 71 75 61 6c 3f 20 73 74 61 74 75 73 20 22 57  equal? status "W
2b90: 41 52 4e 22 29 0a 09 09 20 28 65 71 75 61 6c 3f  ARN")... (equal?
2ba0: 20 73 74 61 74 75 73 20 22 46 41 49 4c 22 29 0a   status "FAIL").
2bb0: 09 09 20 28 65 71 75 61 6c 3f 20 73 74 61 74 75  .. (equal? statu
2bc0: 73 20 22 57 41 49 56 45 44 22 29 0a 09 09 20 28  s "WAIVED")... (
2bd0: 65 71 75 61 6c 3f 20 73 74 61 74 75 73 20 22 52  equal? status "R
2be0: 55 4e 4e 49 4e 47 22 29 29 29 0a 09 28 62 65 67  UNNING")))..(beg
2bf0: 69 6e 0a 09 20 20 28 73 71 6c 69 74 65 33 3a 65  in..  (sqlite3:e
2c00: 78 65 63 75 74 65 20 0a 09 20 20 20 64 62 0a 09  xecute ..   db..
2c10: 20 20 20 22 55 50 44 41 54 45 20 74 65 73 74 73     "UPDATE tests
2c20: 20 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 53   .             S
2c30: 45 54 20 66 61 69 6c 5f 63 6f 75 6e 74 3d 28 53  ET fail_count=(S
2c40: 45 4c 45 43 54 20 63 6f 75 6e 74 28 69 64 29 20  ELECT count(id) 
2c50: 46 52 4f 4d 20 74 65 73 74 73 20 57 48 45 52 45  FROM tests WHERE
2c60: 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65   run_id=? AND te
2c70: 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65  stname=? AND ite
2c80: 6d 5f 70 61 74 68 20 21 3d 20 27 27 20 41 4e 44  m_path != '' AND
2c90: 20 73 74 61 74 75 73 3d 27 46 41 49 4c 27 29 2c   status='FAIL'),
2ca0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
2cb0: 20 20 70 61 73 73 5f 63 6f 75 6e 74 3d 28 53 45    pass_count=(SE
2cc0: 4c 45 43 54 20 63 6f 75 6e 74 28 69 64 29 20 46  LECT count(id) F
2cd0: 52 4f 4d 20 74 65 73 74 73 20 57 48 45 52 45 20  ROM tests WHERE 
2ce0: 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73  run_id=? AND tes
2cf0: 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d  tname=? AND item
2d00: 5f 70 61 74 68 20 21 3d 20 27 27 20 41 4e 44 20  _path != '' AND 
2d10: 28 73 74 61 74 75 73 3d 27 50 41 53 53 27 20 4f  (status='PASS' O
2d20: 52 20 73 74 61 74 75 73 3d 27 57 41 52 4e 27 20  R status='WARN' 
2d30: 4f 52 20 73 74 61 74 75 73 3d 27 57 41 49 56 45  OR status='WAIVE
2d40: 44 27 29 29 0a 20 20 20 20 20 20 20 20 20 20 20  D')).           
2d50: 20 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f    WHERE run_id=?
2d60: 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20   AND testname=? 
2d70: 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 27 27  AND item_path=''
2d80: 3b 22 0a 09 20 20 20 72 75 6e 2d 69 64 20 74 65  ;"..   run-id te
2d90: 73 74 2d 6e 61 6d 65 20 72 75 6e 2d 69 64 20 74  st-name run-id t
2da0: 65 73 74 2d 6e 61 6d 65 20 72 75 6e 2d 69 64 20  est-name run-id 
2db0: 74 65 73 74 2d 6e 61 6d 65 29 0a 09 20 20 28 69  test-name)..  (i
2dc0: 66 20 28 65 71 75 61 6c 3f 20 73 74 61 74 75 73  f (equal? status
2dd0: 20 22 52 55 4e 4e 49 4e 47 22 29 20 3b 3b 20 72   "RUNNING") ;; r
2de0: 75 6e 6e 69 6e 67 20 74 61 6b 65 73 20 70 72 69  unning takes pri
2df0: 6f 72 69 74 79 20 6f 76 65 72 20 61 6c 6c 20 6f  ority over all o
2e00: 74 68 65 72 20 73 74 61 74 65 73 2c 20 66 6f 72  ther states, for
2e10: 63 65 20 74 68 65 20 74 65 73 74 20 73 74 61 74  ce the test stat
2e20: 65 20 74 6f 20 52 55 4e 4e 49 4e 47 0a 09 20 20  e to RUNNING..  
2e30: 20 20 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65      (sqlite3:exe
2e40: 63 75 74 65 20 64 62 20 22 55 50 44 41 54 45 20  cute db "UPDATE 
2e50: 74 65 73 74 73 20 53 45 54 20 73 74 61 74 65 3d  tests SET state=
2e60: 3f 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f  ? WHERE run_id=?
2e70: 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20   AND testname=? 
2e80: 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 27 27  AND item_path=''
2e90: 3b 22 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e  ;" run-id test-n
2ea0: 61 6d 65 29 0a 09 20 20 20 20 20 20 28 73 71 6c  ame)..      (sql
2eb0: 69 74 65 33 3a 65 78 65 63 75 74 65 0a 09 20 20  ite3:execute..  
2ec0: 20 20 20 20 20 64 62 0a 09 20 20 20 20 20 20 20       db..       
2ed0: 22 55 50 44 41 54 45 20 74 65 73 74 73 0a 20 20  "UPDATE tests.  
2ee0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2ef0: 20 20 20 20 20 53 45 54 20 73 74 61 74 65 3d 43       SET state=C
2f00: 41 53 45 20 57 48 45 4e 20 28 53 45 4c 45 43 54  ASE WHEN (SELECT
2f10: 20 63 6f 75 6e 74 28 69 64 29 20 46 52 4f 4d 20   count(id) FROM 
2f20: 74 65 73 74 73 20 57 48 45 52 45 20 72 75 6e 5f  tests WHERE run_
2f30: 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d  id=? AND testnam
2f40: 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74  e=? AND item_pat
2f50: 68 20 21 3d 20 27 27 20 41 4e 44 20 73 74 61 74  h != '' AND stat
2f60: 65 20 69 6e 20 28 27 52 55 4e 4e 49 4e 47 27 2c  e in ('RUNNING',
2f70: 27 4e 4f 54 5f 53 54 41 52 54 45 44 27 29 29 20  'NOT_STARTED')) 
2f80: 3e 20 30 20 54 48 45 4e 20 0a 20 20 20 20 20 20  > 0 THEN .      
2f90: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2fa0: 20 20 20 20 27 52 55 4e 4e 49 4e 47 27 0a 20 20      'RUNNING'.  
2fb0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2fc0: 20 20 20 20 20 45 4c 53 45 20 27 43 4f 4d 50 4c       ELSE 'COMPL
2fd0: 45 54 45 44 27 20 45 4e 44 2c 0a 20 20 20 20 20  ETED' END,.     
2fe0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2ff0: 20 20 20 20 20 73 74 61 74 75 73 3d 43 41 53 45       status=CASE
3000: 20 57 48 45 4e 20 66 61 69 6c 5f 63 6f 75 6e 74   WHEN fail_count
3010: 20 3e 20 30 20 54 48 45 4e 20 27 46 41 49 4c 27   > 0 THEN 'FAIL'
3020: 20 57 48 45 4e 20 70 61 73 73 5f 63 6f 75 6e 74   WHEN pass_count
3030: 20 3e 20 30 20 41 4e 44 20 66 61 69 6c 5f 63 6f   > 0 AND fail_co
3040: 75 6e 74 3d 30 20 54 48 45 4e 20 27 50 41 53 53  unt=0 THEN 'PASS
3050: 27 20 45 4c 53 45 20 27 55 4e 4b 4e 4f 57 4e 27  ' ELSE 'UNKNOWN'
3060: 20 45 4e 44 0a 20 20 20 20 20 20 20 20 20 20 20   END.           
3070: 20 20 20 20 20 20 20 20 20 20 20 20 57 48 45 52              WHER
3080: 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74  E run_id=? AND t
3090: 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74  estname=? AND it
30a0: 65 6d 5f 70 61 74 68 3d 27 27 3b 22 0a 09 20 20  em_path='';"..  
30b0: 20 20 20 20 20 72 75 6e 2d 69 64 20 74 65 73 74       run-id test
30c0: 2d 6e 61 6d 65 20 72 75 6e 2d 69 64 20 74 65 73  -name run-id tes
30d0: 74 2d 6e 61 6d 65 29 29 29 29 0a 20 20 20 20 28  t-name)))).    (
30e0: 69 66 20 28 6f 72 20 28 61 6e 64 20 28 73 74 72  if (or (and (str
30f0: 69 6e 67 3f 20 63 6f 6d 6d 65 6e 74 29 0a 09 09  ing? comment)...
3100: 20 28 73 74 72 69 6e 67 2d 6d 61 74 63 68 20 28   (string-match (
3110: 72 65 67 65 78 70 20 22 5c 5c 53 2b 22 29 20 63  regexp "\\S+") c
3120: 6f 6d 6d 65 6e 74 29 29 0a 09 20 20 20 20 77 61  omment))..    wa
3130: 69 76 65 64 29 0a 09 28 73 71 6c 69 74 65 33 3a  ived)..(sqlite3:
3140: 65 78 65 63 75 74 65 20 64 62 20 22 55 50 44 41  execute db "UPDA
3150: 54 45 20 74 65 73 74 73 20 53 45 54 20 63 6f 6d  TE tests SET com
3160: 6d 65 6e 74 3d 3f 20 57 48 45 52 45 20 72 75 6e  ment=? WHERE run
3170: 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61  _id=? AND testna
3180: 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61  me=? AND item_pa
3190: 74 68 3d 3f 3b 22 0a 09 09 09 20 28 69 66 20 77  th=?;".... (if w
31a0: 61 69 76 65 64 20 77 61 69 76 65 64 20 63 6f 6d  aived waived com
31b0: 6d 65 6e 74 29 20 72 75 6e 2d 69 64 20 74 65 73  ment) run-id tes
31c0: 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68  t-name item-path
31d0: 29 29 0a 20 20 20 20 29 29 0a 0a 28 64 65 66 69  )).    ))..(defi
31e0: 6e 65 20 28 74 65 73 74 2d 73 65 74 2d 6c 6f 67  ne (test-set-log
31f0: 21 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  ! db run-id test
3200: 2d 6e 61 6d 65 20 69 74 65 6d 64 61 74 20 6c 6f  -name itemdat lo
3210: 67 66 29 20 0a 20 20 28 6c 65 74 20 28 28 69 74  gf) .  (let ((it
3220: 65 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c 69  em-path (item-li
3230: 73 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74  st->path itemdat
3240: 29 29 29 0a 20 20 20 20 28 73 71 6c 69 74 65 33  ))).    (sqlite3
3250: 3a 65 78 65 63 75 74 65 20 64 62 20 22 55 50 44  :execute db "UPD
3260: 41 54 45 20 74 65 73 74 73 20 53 45 54 20 66 69  ATE tests SET fi
3270: 6e 61 6c 5f 6c 6f 67 66 3d 3f 20 57 48 45 52 45  nal_logf=? WHERE
3280: 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65   run_id=? AND te
3290: 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65  stname=? AND ite
32a0: 6d 5f 70 61 74 68 3d 3f 3b 22 20 0a 09 09 20 20  m_path=?;" ...  
32b0: 20 20 20 6c 6f 67 66 20 72 75 6e 2d 69 64 20 74     logf run-id t
32c0: 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61  est-name item-pa
32d0: 74 68 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28  th)))..(define (
32e0: 74 65 73 74 2d 73 65 74 2d 74 6f 70 6c 6f 67 21  test-set-toplog!
32f0: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d   db run-id test-
3300: 6e 61 6d 65 20 6c 6f 67 66 29 20 0a 20 20 28 73  name logf) .  (s
3310: 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 64  qlite3:execute d
3320: 62 20 22 55 50 44 41 54 45 20 74 65 73 74 73 20  b "UPDATE tests 
3330: 53 45 54 20 66 69 6e 61 6c 5f 6c 6f 67 66 3d 3f  SET final_logf=?
3340: 20 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20   WHERE run_id=? 
3350: 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41  AND testname=? A
3360: 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d 27 27 3b  ND item_path='';
3370: 22 20 0a 09 09 20 20 20 6c 6f 67 66 20 72 75 6e  " ...   logf run
3380: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 29 29 0a  -id test-name)).
3390: 0a 28 64 65 66 69 6e 65 20 28 74 65 73 74 73 3a  .(define (tests:
33a0: 73 75 6d 6d 61 72 69 7a 65 2d 69 74 65 6d 73 20  summarize-items 
33b0: 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e  db run-id test-n
33c0: 61 6d 65 20 66 6f 72 63 65 29 0a 20 20 3b 3b 20  ame force).  ;; 
33d0: 69 66 20 6e 6f 74 20 66 6f 72 63 65 20 74 68 65  if not force the
33e0: 6e 20 6f 6e 6c 79 20 75 70 64 61 74 65 20 74 68  n only update th
33f0: 65 20 72 65 63 6f 72 64 20 69 66 20 6f 6e 65 20  e record if one 
3400: 6f 66 20 74 68 65 73 65 20 69 73 20 74 72 75 65  of these is true
3410: 3a 0a 20 20 3b 3b 20 20 20 31 2e 20 6c 6f 67 66  :.  ;;   1. logf
3420: 20 69 73 20 22 6c 6f 67 2f 66 69 6e 61 6c 2e 6c   is "log/final.l
3430: 6f 67 0a 20 20 3b 3b 20 20 20 32 2e 20 6c 6f 67  og.  ;;   2. log
3440: 66 20 69 73 20 73 61 6d 65 20 61 73 20 6f 75 74  f is same as out
3450: 70 75 74 66 69 6c 65 6e 61 6d 65 0a 20 20 28 6c  putfilename.  (l
3460: 65 74 20 28 28 6f 75 74 70 75 74 66 69 6c 65 6e  et ((outputfilen
3470: 61 6d 65 20 28 63 6f 6e 63 20 22 6d 65 67 61 74  ame (conc "megat
3480: 65 73 74 2d 72 6f 6c 6c 75 70 2d 22 20 74 65 73  est-rollup-" tes
3490: 74 2d 6e 61 6d 65 20 22 2e 68 74 6d 6c 22 29 29  t-name ".html"))
34a0: 0a 09 28 6f 72 69 67 2d 64 69 72 20 20 20 20 20  ..(orig-dir     
34b0: 20 20 28 63 75 72 72 65 6e 74 2d 64 69 72 65 63    (current-direc
34c0: 74 6f 72 79 29 29 0a 09 28 6c 6f 67 66 20 20 20  tory))..(logf   
34d0: 20 20 20 20 20 20 20 20 23 66 29 29 0a 20 20 20          #f)).   
34e0: 20 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61   (sqlite3:for-ea
34f0: 63 68 2d 72 6f 77 20 0a 20 20 20 20 20 28 6c 61  ch-row .     (la
3500: 6d 62 64 61 20 28 70 61 74 68 20 66 69 6e 61 6c  mbda (path final
3510: 5f 6c 6f 67 66 29 0a 20 20 20 20 20 20 20 28 73  _logf).       (s
3520: 65 74 21 20 6c 6f 67 66 20 66 69 6e 61 6c 5f 6c  et! logf final_l
3530: 6f 67 66 29 0a 20 20 20 20 20 20 20 28 69 66 20  ogf).       (if 
3540: 28 64 69 72 65 63 74 6f 72 79 3f 20 70 61 74 68  (directory? path
3550: 29 0a 09 20 20 20 28 62 65 67 69 6e 0a 09 20 20  )..   (begin..  
3560: 20 20 20 28 70 72 69 6e 74 20 22 46 6f 75 6e 64     (print "Found
3570: 20 70 61 74 68 3a 20 22 20 70 61 74 68 29 0a 09   path: " path)..
3580: 20 20 20 20 20 28 63 68 61 6e 67 65 2d 64 69 72       (change-dir
3590: 65 63 74 6f 72 79 20 70 61 74 68 29 29 0a 09 20  ectory path)).. 
35a0: 20 20 20 20 3b 3b 20 28 73 65 74 21 20 6f 75 74      ;; (set! out
35b0: 70 75 74 66 69 6c 65 6e 61 6d 65 20 28 63 6f 6e  putfilename (con
35c0: 63 20 70 61 74 68 20 22 2f 22 20 6f 75 74 70 75  c path "/" outpu
35d0: 74 66 69 6c 65 6e 61 6d 65 29 29 29 0a 09 20 20  tfilename)))..  
35e0: 20 28 70 72 69 6e 74 20 22 4e 6f 20 73 75 63 68   (print "No such
35f0: 20 70 61 74 68 3a 20 22 20 70 61 74 68 29 29 29   path: " path)))
3600: 0a 20 20 20 20 20 64 62 20 0a 20 20 20 20 20 22  .     db .     "
3610: 53 45 4c 45 43 54 20 72 75 6e 64 69 72 2c 66 69  SELECT rundir,fi
3620: 6e 61 6c 5f 6c 6f 67 66 20 46 52 4f 4d 20 74 65  nal_logf FROM te
3630: 73 74 73 20 57 48 45 52 45 20 72 75 6e 5f 69 64  sts WHERE run_id
3640: 3d 3f 20 41 4e 44 20 74 65 73 74 6e 61 6d 65 3d  =? AND testname=
3650: 3f 20 41 4e 44 20 69 74 65 6d 5f 70 61 74 68 3d  ? AND item_path=
3660: 27 27 3b 22 0a 20 20 20 20 20 72 75 6e 2d 69 64  '';".     run-id
3670: 20 74 65 73 74 2d 6e 61 6d 65 29 0a 20 20 20 20   test-name).    
3680: 28 70 72 69 6e 74 20 22 73 75 6d 6d 61 72 69 7a  (print "summariz
3690: 65 2d 69 74 65 6d 73 20 77 69 74 68 20 6c 6f 67  e-items with log
36a0: 66 20 22 20 6c 6f 67 66 29 0a 20 20 20 20 28 69  f " logf).    (i
36b0: 66 20 28 6f 72 20 28 65 71 75 61 6c 3f 20 6c 6f  f (or (equal? lo
36c0: 67 66 20 22 6c 6f 67 73 2f 66 69 6e 61 6c 2e 6c  gf "logs/final.l
36d0: 6f 67 22 29 0a 09 20 20 20 20 28 65 71 75 61 6c  og")..    (equal
36e0: 3f 20 6c 6f 67 66 20 6f 75 74 70 75 74 66 69 6c  ? logf outputfil
36f0: 65 6e 61 6d 65 29 0a 09 20 20 20 20 66 6f 72 63  ename)..    forc
3700: 65 29 0a 09 28 62 65 67 69 6e 0a 09 20 20 28 69  e)..(begin..  (i
3710: 66 20 28 6f 62 74 61 69 6e 2d 64 6f 74 2d 6c 6f  f (obtain-dot-lo
3720: 63 6b 20 6f 75 74 70 75 74 66 69 6c 65 6e 61 6d  ck outputfilenam
3730: 65 20 31 20 32 30 20 33 30 29 20 3b 3b 20 72 65  e 1 20 30) ;; re
3740: 74 72 79 20 65 76 65 72 79 20 73 65 63 6f 6e 64  try every second
3750: 20 66 6f 72 20 32 30 20 73 65 63 6f 6e 64 73 2c   for 20 seconds,
3760: 20 63 61 6c 6c 20 69 74 20 64 65 61 64 20 61 66   call it dead af
3770: 74 65 72 20 33 30 20 73 65 63 6f 6e 64 73 20 61  ter 30 seconds a
3780: 6e 64 20 73 74 65 61 6c 20 74 68 65 20 6c 6f 63  nd steal the loc
3790: 6b 0a 09 20 20 20 20 20 20 28 70 72 69 6e 74 20  k..      (print 
37a0: 22 4f 62 74 61 69 6e 65 64 20 6c 6f 63 6b 20 66  "Obtained lock f
37b0: 6f 72 20 22 20 6f 75 74 70 75 74 66 69 6c 65 6e  or " outputfilen
37c0: 61 6d 65 29 0a 09 20 20 20 20 20 20 28 70 72 69  ame)..      (pri
37d0: 6e 74 20 22 46 61 69 6c 65 64 20 74 6f 20 6f 62  nt "Failed to ob
37e0: 74 61 69 6e 20 6c 6f 63 6b 20 66 6f 72 20 22 20  tain lock for " 
37f0: 6f 75 74 70 75 74 66 69 6c 65 6e 61 6d 65 29 29  outputfilename))
3800: 0a 09 20 20 28 6c 65 74 20 28 28 6f 75 70 20 20  ..  (let ((oup  
3810: 20 20 28 6f 70 65 6e 2d 6f 75 74 70 75 74 2d 66    (open-output-f
3820: 69 6c 65 20 6f 75 74 70 75 74 66 69 6c 65 6e 61  ile outputfilena
3830: 6d 65 29 29 0a 09 09 28 63 6f 75 6e 74 73 20 28  me))...(counts (
3840: 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c 65 29  make-hash-table)
3850: 29 0a 09 09 28 73 74 61 74 65 63 6f 75 6e 74 73  )...(statecounts
3860: 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c   (make-hash-tabl
3870: 65 29 29 0a 09 09 28 6f 75 74 74 78 74 20 22 22  e))...(outtxt ""
3880: 29 0a 09 09 28 74 6f 74 20 20 20 20 30 29 29 0a  )...(tot    0)).
3890: 09 20 20 20 20 28 77 69 74 68 2d 6f 75 74 70 75  .    (with-outpu
38a0: 74 2d 74 6f 2d 70 6f 72 74 0a 09 09 6f 75 70 0a  t-to-port...oup.
38b0: 09 20 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28  .      (lambda (
38c0: 29 0a 09 09 28 73 65 74 21 20 6f 75 74 74 78 74  )...(set! outtxt
38d0: 20 28 63 6f 6e 63 20 6f 75 74 74 78 74 20 22 3c   (conc outtxt "<
38e0: 68 74 6d 6c 3e 3c 74 69 74 6c 65 3e 53 75 6d 6d  html><title>Summ
38f0: 61 72 79 3a 20 22 20 74 65 73 74 2d 6e 61 6d 65  ary: " test-name
3900: 20 0a 09 09 09 09 20 20 20 22 3c 2f 74 69 74 6c   .....   "</titl
3910: 65 3e 3c 62 6f 64 79 3e 3c 68 32 3e 53 75 6d 6d  e><body><h2>Summ
3920: 61 72 79 20 66 6f 72 20 22 20 74 65 73 74 2d 6e  ary for " test-n
3930: 61 6d 65 20 22 3c 2f 68 32 3e 22 29 29 0a 09 09  ame "</h2>"))...
3940: 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63  (sqlite3:for-eac
3950: 68 2d 72 6f 77 20 0a 09 09 20 28 6c 61 6d 62 64  h-row ... (lambd
3960: 61 20 28 69 64 20 69 74 65 6d 70 61 74 68 20 73  a (id itempath s
3970: 74 61 74 65 20 73 74 61 74 75 73 20 72 75 6e 5f  tate status run_
3980: 64 75 72 61 74 69 6f 6e 20 6c 6f 67 66 20 63 6f  duration logf co
3990: 6d 6d 65 6e 74 29 0a 09 09 20 20 20 28 68 61 73  mment)...   (has
39a0: 68 2d 74 61 62 6c 65 2d 73 65 74 21 20 63 6f 75  h-table-set! cou
39b0: 6e 74 73 20 73 74 61 74 75 73 20 28 2b 20 31 20  nts status (+ 1 
39c0: 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 2f  (hash-table-ref/
39d0: 64 65 66 61 75 6c 74 20 63 6f 75 6e 74 73 20 73  default counts s
39e0: 74 61 74 75 73 20 30 29 29 29 0a 09 09 20 20 20  tatus 0)))...   
39f0: 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74 21  (hash-table-set!
3a00: 20 73 74 61 74 65 63 6f 75 6e 74 73 20 73 74 61   statecounts sta
3a10: 74 65 20 28 2b 20 31 20 28 68 61 73 68 2d 74 61  te (+ 1 (hash-ta
3a20: 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20  ble-ref/default 
3a30: 73 74 61 74 65 63 6f 75 6e 74 73 20 73 74 61 74  statecounts stat
3a40: 65 20 30 29 29 29 0a 09 09 20 20 20 28 73 65 74  e 0)))...   (set
3a50: 21 20 6f 75 74 74 78 74 20 28 63 6f 6e 63 20 6f  ! outtxt (conc o
3a60: 75 74 74 78 74 20 22 3c 74 72 3e 22 0a 09 09 09  uttxt "<tr>"....
3a70: 09 20 20 20 20 20 20 22 3c 74 64 3e 3c 61 20 68  .      "<td><a h
3a80: 72 65 66 3d 5c 22 22 20 69 74 65 6d 70 61 74 68  ref=\"" itempath
3a90: 20 22 2f 22 20 6c 6f 67 66 20 22 5c 22 3e 20 22   "/" logf "\"> "
3aa0: 20 69 74 65 6d 70 61 74 68 20 22 3c 2f 61 3e 3c   itempath "</a><
3ab0: 2f 74 64 3e 22 20 0a 09 09 09 09 20 20 20 20 20  /td>" .....     
3ac0: 20 22 3c 74 64 3e 22 20 73 74 61 74 65 20 20 20   "<td>" state   
3ad0: 20 22 3c 2f 74 64 3e 22 20 0a 09 09 09 09 20 20   "</td>" .....  
3ae0: 20 20 20 20 22 3c 74 64 3e 3c 66 6f 6e 74 20 63      "<td><font c
3af0: 6f 6c 6f 72 3d 22 20 28 63 6f 6d 6d 6f 6e 3a 67  olor=" (common:g
3b00: 65 74 2d 63 6f 6c 6f 72 2d 66 72 6f 6d 2d 73 74  et-color-from-st
3b10: 61 74 75 73 20 73 74 61 74 75 73 29 0a 09 09 09  atus status)....
3b20: 09 20 20 20 20 20 20 22 3e 22 20 20 20 73 74 61  .      ">"   sta
3b30: 74 75 73 20 20 20 22 3c 2f 66 6f 6e 74 3e 3c 2f  tus   "</font></
3b40: 74 64 3e 22 0a 09 09 09 09 20 20 20 20 20 20 22  td>".....      "
3b50: 3c 74 64 3e 22 20 28 69 66 20 28 65 71 75 61 6c  <td>" (if (equal
3b60: 3f 20 63 6f 6d 6d 65 6e 74 20 22 22 29 0a 09 09  ? comment "")...
3b70: 09 09 09 09 20 22 26 6e 62 73 70 3b 22 0a 09 09  .... "&nbsp;"...
3b80: 09 09 09 09 20 63 6f 6d 6d 65 6e 74 29 20 22 3c  .... comment) "<
3b90: 2f 74 64 3e 22 0a 09 09 09 09 09 09 20 22 3c 2f  /td>"....... "</
3ba0: 74 72 3e 22 29 29 29 0a 09 09 20 64 62 0a 09 09  tr>")))... db...
3bb0: 20 22 53 45 4c 45 43 54 20 69 64 2c 69 74 65 6d   "SELECT id,item
3bc0: 5f 70 61 74 68 2c 73 74 61 74 65 2c 73 74 61 74  _path,state,stat
3bd0: 75 73 2c 72 75 6e 5f 64 75 72 61 74 69 6f 6e 2c  us,run_duration,
3be0: 66 69 6e 61 6c 5f 6c 6f 67 66 2c 63 6f 6d 6d 65  final_logf,comme
3bf0: 6e 74 20 46 52 4f 4d 20 74 65 73 74 73 20 57 48  nt FROM tests WH
3c00: 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e 44  ERE run_id=? AND
3c10: 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44 20   testname=? AND 
3c20: 69 74 65 6d 5f 70 61 74 68 20 21 3d 20 27 27 3b  item_path != '';
3c30: 22 0a 09 09 20 72 75 6e 2d 69 64 20 74 65 73 74  "... run-id test
3c40: 2d 6e 61 6d 65 29 0a 0a 09 09 28 70 72 69 6e 74  -name)....(print
3c50: 20 22 3c 74 61 62 6c 65 3e 3c 74 72 3e 3c 74 64   "<table><tr><td
3c60: 20 76 61 6c 69 67 6e 3d 5c 22 74 6f 70 5c 22 3e   valign=\"top\">
3c70: 22 29 0a 09 09 3b 3b 20 50 72 69 6e 74 20 6f 75  ")...;; Print ou
3c80: 74 20 73 74 61 74 73 20 66 6f 72 20 73 74 61 74  t stats for stat
3c90: 75 73 0a 09 09 28 73 65 74 21 20 74 6f 74 20 30  us...(set! tot 0
3ca0: 29 0a 09 09 28 70 72 69 6e 74 20 22 3c 74 61 62  )...(print "<tab
3cb0: 6c 65 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d 5c  le cellspacing=\
3cc0: 22 30 5c 22 20 62 6f 72 64 65 72 3d 5c 22 31 5c  "0\" border=\"1\
3cd0: 22 3e 3c 74 72 3e 3c 74 64 20 63 6f 6c 73 70 61  "><tr><td colspa
3ce0: 6e 3d 5c 22 32 5c 22 3e 3c 68 32 3e 53 74 61 74  n=\"2\"><h2>Stat
3cf0: 65 20 73 74 61 74 73 3c 2f 68 32 3e 3c 2f 74 64  e stats</h2></td
3d00: 3e 3c 2f 74 72 3e 22 29 0a 09 09 28 66 6f 72 2d  ></tr>")...(for-
3d10: 65 61 63 68 20 28 6c 61 6d 62 64 61 20 28 73 74  each (lambda (st
3d20: 61 74 65 29 0a 09 09 09 20 20 20 20 28 73 65 74  ate)....    (set
3d30: 21 20 74 6f 74 20 28 2b 20 74 6f 74 20 28 68 61  ! tot (+ tot (ha
3d40: 73 68 2d 74 61 62 6c 65 2d 72 65 66 20 73 74 61  sh-table-ref sta
3d50: 74 65 63 6f 75 6e 74 73 20 73 74 61 74 65 29 29  tecounts state))
3d60: 29 0a 09 09 09 20 20 20 20 28 70 72 69 6e 74 20  )....    (print 
3d70: 22 3c 74 72 3e 3c 74 64 3e 22 20 73 74 61 74 65  "<tr><td>" state
3d80: 20 22 3c 2f 74 64 3e 3c 74 64 3e 22 20 28 68 61   "</td><td>" (ha
3d90: 73 68 2d 74 61 62 6c 65 2d 72 65 66 20 73 74 61  sh-table-ref sta
3da0: 74 65 63 6f 75 6e 74 73 20 73 74 61 74 65 29 20  tecounts state) 
3db0: 22 3c 2f 74 64 3e 3c 2f 74 72 3e 22 29 29 0a 09  "</td></tr>"))..
3dc0: 09 09 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d  ..  (hash-table-
3dd0: 6b 65 79 73 20 73 74 61 74 65 63 6f 75 6e 74 73  keys statecounts
3de0: 29 29 0a 09 09 28 70 72 69 6e 74 20 22 3c 74 72  ))...(print "<tr
3df0: 3e 3c 74 64 3e 54 6f 74 61 6c 3c 2f 74 64 3e 3c  ><td>Total</td><
3e00: 74 64 3e 22 20 74 6f 74 20 22 3c 2f 74 64 3e 3c  td>" tot "</td><
3e10: 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e 22 29 0a 09  /tr></table>")..
3e20: 09 28 70 72 69 6e 74 20 22 3c 2f 74 64 3e 3c 74  .(print "</td><t
3e30: 64 20 76 61 6c 69 67 6e 3d 5c 22 74 6f 70 5c 22  d valign=\"top\"
3e40: 3e 22 29 0a 09 09 3b 3b 20 50 72 69 6e 74 20 6f  >")...;; Print o
3e50: 75 74 20 73 74 61 74 73 20 66 6f 72 20 73 74 61  ut stats for sta
3e60: 74 65 0a 09 09 28 73 65 74 21 20 74 6f 74 20 30  te...(set! tot 0
3e70: 29 0a 09 09 28 70 72 69 6e 74 20 22 3c 74 61 62  )...(print "<tab
3e80: 6c 65 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d 5c  le cellspacing=\
3e90: 22 30 5c 22 20 62 6f 72 64 65 72 3d 5c 22 31 5c  "0\" border=\"1\
3ea0: 22 3e 3c 74 72 3e 3c 74 64 20 63 6f 6c 73 70 61  "><tr><td colspa
3eb0: 6e 3d 5c 22 32 5c 22 3e 3c 68 32 3e 53 74 61 74  n=\"2\"><h2>Stat
3ec0: 75 73 20 73 74 61 74 73 3c 2f 68 32 3e 3c 2f 74  us stats</h2></t
3ed0: 64 3e 3c 2f 74 72 3e 22 29 0a 09 09 28 66 6f 72  d></tr>")...(for
3ee0: 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 20 28 73  -each (lambda (s
3ef0: 74 61 74 75 73 29 0a 09 09 09 20 20 20 20 28 73  tatus)....    (s
3f00: 65 74 21 20 74 6f 74 20 28 2b 20 74 6f 74 20 28  et! tot (+ tot (
3f10: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 20 63  hash-table-ref c
3f20: 6f 75 6e 74 73 20 73 74 61 74 75 73 29 29 29 0a  ounts status))).
3f30: 09 09 09 20 20 20 20 28 70 72 69 6e 74 20 22 3c  ...    (print "<
3f40: 74 72 3e 3c 74 64 3e 3c 66 6f 6e 74 20 63 6f 6c  tr><td><font col
3f50: 6f 72 3d 5c 22 22 20 28 63 6f 6d 6d 6f 6e 3a 67  or=\"" (common:g
3f60: 65 74 2d 63 6f 6c 6f 72 2d 66 72 6f 6d 2d 73 74  et-color-from-st
3f70: 61 74 75 73 20 73 74 61 74 75 73 29 20 22 5c 22  atus status) "\"
3f80: 3e 22 20 73 74 61 74 75 73 0a 09 09 09 09 20 20  >" status.....  
3f90: 20 22 3c 2f 66 6f 6e 74 3e 3c 2f 74 64 3e 3c 74   "</font></td><t
3fa0: 64 3e 22 20 28 68 61 73 68 2d 74 61 62 6c 65 2d  d>" (hash-table-
3fb0: 72 65 66 20 63 6f 75 6e 74 73 20 73 74 61 74 75  ref counts statu
3fc0: 73 29 20 22 3c 2f 74 64 3e 3c 2f 74 72 3e 22 29  s) "</td></tr>")
3fd0: 29 0a 09 09 09 20 20 28 68 61 73 68 2d 74 61 62  )....  (hash-tab
3fe0: 6c 65 2d 6b 65 79 73 20 63 6f 75 6e 74 73 29 29  le-keys counts))
3ff0: 0a 09 09 28 70 72 69 6e 74 20 22 3c 74 72 3e 3c  ...(print "<tr><
4000: 74 64 3e 54 6f 74 61 6c 3c 2f 74 64 3e 3c 74 64  td>Total</td><td
4010: 3e 22 20 74 6f 74 20 22 3c 2f 74 64 3e 3c 2f 74  >" tot "</td></t
4020: 72 3e 3c 2f 74 61 62 6c 65 3e 22 29 0a 09 09 28  r></table>")...(
4030: 70 72 69 6e 74 20 22 3c 2f 74 64 3e 3c 2f 74 64  print "</td></td
4040: 3e 3c 2f 74 72 3e 3c 2f 74 61 62 6c 65 3e 22 29  ></tr></table>")
4050: 0a 0a 09 09 28 70 72 69 6e 74 20 22 3c 74 61 62  ....(print "<tab
4060: 6c 65 20 63 65 6c 6c 73 70 61 63 69 6e 67 3d 5c  le cellspacing=\
4070: 22 30 5c 22 20 62 6f 72 64 65 72 3d 5c 22 31 5c  "0\" border=\"1\
4080: 22 3e 22 20 0a 09 09 20 20 20 20 20 20 20 22 3c  ">" ...       "<
4090: 74 72 3e 3c 74 64 3e 49 74 65 6d 3c 2f 74 64 3e  tr><td>Item</td>
40a0: 3c 74 64 3e 53 74 61 74 65 3c 2f 74 64 3e 3c 74  <td>State</td><t
40b0: 64 3e 53 74 61 74 75 73 3c 2f 74 64 3e 3c 74 64  d>Status</td><td
40c0: 3e 43 6f 6d 6d 65 6e 74 3c 2f 74 64 3e 22 0a 09  >Comment</td>"..
40d0: 09 20 20 20 20 20 20 20 6f 75 74 74 78 74 20 22  .       outtxt "
40e0: 3c 2f 74 61 62 6c 65 3e 3c 2f 62 6f 64 79 3e 3c  </table></body><
40f0: 2f 68 74 6d 6c 3e 22 29 0a 09 09 28 72 65 6c 65  /html>")...(rele
4100: 61 73 65 2d 64 6f 74 2d 6c 6f 63 6b 20 6f 75 74  ase-dot-lock out
4110: 70 75 74 66 69 6c 65 6e 61 6d 65 29 29 29 0a 09  putfilename)))..
4120: 20 20 20 20 28 63 6c 6f 73 65 2d 6f 75 74 70 75      (close-outpu
4130: 74 2d 70 6f 72 74 20 6f 75 70 29 0a 09 20 20 20  t-port oup)..   
4140: 20 28 63 68 61 6e 67 65 2d 64 69 72 65 63 74 6f   (change-directo
4150: 72 79 20 6f 72 69 67 2d 64 69 72 29 0a 09 20 20  ry orig-dir)..  
4160: 20 20 28 74 65 73 74 2d 73 65 74 2d 74 6f 70 6c    (test-set-topl
4170: 6f 67 21 20 64 62 20 72 75 6e 2d 69 64 20 74 65  og! db run-id te
4180: 73 74 2d 6e 61 6d 65 20 6f 75 74 70 75 74 66 69  st-name outputfi
4190: 6c 65 6e 61 6d 65 29 0a 09 20 20 20 20 29 29 29  lename)..    )))
41a0: 29 29 0a 0a 3b 3b 20 3b 3b 20 54 4f 44 4f 3a 20  ))..;; ;; TODO: 
41b0: 43 6f 6e 76 65 72 67 65 20 74 68 69 73 20 77 69  Converge this wi
41c0: 74 68 20 64 62 3a 67 65 74 2d 74 65 73 74 2d 69  th db:get-test-i
41d0: 6e 66 6f 0a 3b 3b 20 28 64 65 66 69 6e 65 20 28  nfo.;; (define (
41e0: 72 75 6e 73 3a 67 65 74 2d 74 65 73 74 2d 69 6e  runs:get-test-in
41f0: 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  fo db run-id tes
4200: 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68  t-name item-path
4210: 29 0a 3b 3b 20 20 20 28 6c 65 74 20 28 28 72 65  ).;;   (let ((re
4220: 73 20 23 66 29 29 20 3b 3b 20 28 76 65 63 74 6f  s #f)) ;; (vecto
4230: 72 20 23 66 20 23 66 20 23 66 20 23 66 20 23 66  r #f #f #f #f #f
4240: 20 23 66 29 29 29 0a 3b 3b 20 20 20 20 20 28 73   #f))).;;     (s
4250: 71 6c 69 74 65 33 3a 66 6f 72 2d 65 61 63 68 2d  qlite3:for-each-
4260: 72 6f 77 20 0a 3b 3b 20 20 20 20 20 20 28 6c 61  row .;;      (la
4270: 6d 62 64 61 20 28 69 64 20 72 75 6e 2d 69 64 20  mbda (id run-id 
4280: 74 65 73 74 2d 6e 61 6d 65 20 73 74 61 74 65 20  test-name state 
4290: 73 74 61 74 75 73 29 0a 3b 3b 20 20 20 20 20 20  status).;;      
42a0: 20 20 28 73 65 74 21 20 72 65 73 20 28 76 65 63    (set! res (vec
42b0: 74 6f 72 20 69 64 20 72 75 6e 2d 69 64 20 74 65  tor id run-id te
42c0: 73 74 2d 6e 61 6d 65 20 73 74 61 74 65 20 73 74  st-name state st
42d0: 61 74 75 73 20 69 74 65 6d 2d 70 61 74 68 29 29  atus item-path))
42e0: 29 0a 3b 3b 20 20 20 20 20 20 64 62 20 22 53 45  ).;;      db "SE
42f0: 4c 45 43 54 20 69 64 2c 72 75 6e 5f 69 64 2c 74  LECT id,run_id,t
4300: 65 73 74 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74  estname,state,st
4310: 61 74 75 73 20 46 52 4f 4d 20 74 65 73 74 73 20  atus FROM tests 
4320: 57 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41  WHERE run_id=? A
4330: 4e 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e  ND testname=? AN
4340: 44 20 69 74 65 6d 5f 70 61 74 68 3d 3f 3b 22 0a  D item_path=?;".
4350: 3b 3b 20 20 20 20 20 20 72 75 6e 2d 69 64 20 74  ;;      run-id t
4360: 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61  est-name item-pa
4370: 74 68 29 0a 3b 3b 20 20 20 20 20 72 65 73 29 29  th).;;     res))
4380: 0a 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69 6e 65  ..(define-inline
4390: 20 28 74 65 73 74 3a 67 65 74 2d 69 64 20 76 65   (test:get-id ve
43a0: 63 29 20 20 20 20 20 20 20 28 76 65 63 74 6f 72  c)       (vector
43b0: 2d 72 65 66 20 76 65 63 20 30 29 29 0a 28 64 65  -ref vec 0)).(de
43c0: 66 69 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65 73  fine-inline (tes
43d0: 74 3a 67 65 74 2d 72 75 6e 5f 69 64 20 76 65 63  t:get-run_id vec
43e0: 29 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66 20  )   (vector-ref 
43f0: 76 65 63 20 31 29 29 0a 28 64 65 66 69 6e 65 2d  vec 1)).(define-
4400: 69 6e 6c 69 6e 65 20 28 74 65 73 74 3a 67 65 74  inline (test:get
4410: 2d 74 65 73 74 2d 6e 61 6d 65 20 76 65 63 29 28  -test-name vec)(
4420: 76 65 63 74 6f 72 2d 72 65 66 20 76 65 63 20 32  vector-ref vec 2
4430: 29 29 0a 28 64 65 66 69 6e 65 2d 69 6e 6c 69 6e  )).(define-inlin
4440: 65 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74  e (test:get-stat
4450: 65 20 76 65 63 29 20 20 20 20 28 76 65 63 74 6f  e vec)    (vecto
4460: 72 2d 72 65 66 20 76 65 63 20 33 29 29 0a 28 64  r-ref vec 3)).(d
4470: 65 66 69 6e 65 2d 69 6e 6c 69 6e 65 20 28 74 65  efine-inline (te
4480: 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 76 65  st:get-status ve
4490: 63 29 20 20 20 28 76 65 63 74 6f 72 2d 72 65 66  c)   (vector-ref
44a0: 20 76 65 63 20 34 29 29 0a 28 64 65 66 69 6e 65   vec 4)).(define
44b0: 2d 69 6e 6c 69 6e 65 20 28 74 65 73 74 3a 67 65  -inline (test:ge
44c0: 74 2d 69 74 65 6d 2d 70 61 74 68 20 76 65 63 29  t-item-path vec)
44d0: 28 76 65 63 74 6f 72 2d 72 65 66 20 76 65 63 20  (vector-ref vec 
44e0: 35 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 72 75  5))..(define (ru
44f0: 6e 73 3a 74 65 73 74 2d 67 65 74 2d 66 75 6c 6c  ns:test-get-full
4500: 2d 70 61 74 68 20 74 65 73 74 29 0a 20 20 28 6c  -path test).  (l
4510: 65 74 2a 20 28 28 74 65 73 74 6e 61 6d 65 20 28  et* ((testname (
4520: 64 62 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74  db:test-get-test
4530: 6e 61 6d 65 20 20 20 74 65 73 74 29 29 0a 09 20  name   test)).. 
4540: 28 69 74 65 6d 70 61 74 68 20 28 64 62 3a 74 65  (itempath (db:te
4550: 73 74 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68  st-get-item-path
4560: 20 74 65 73 74 29 29 29 0a 20 20 20 20 28 63 6f   test))).    (co
4570: 6e 63 20 74 65 73 74 6e 61 6d 65 20 28 69 66 20  nc testname (if 
4580: 28 65 71 75 61 6c 3f 20 69 74 65 6d 70 61 74 68  (equal? itempath
4590: 20 22 22 29 20 22 22 20 28 63 6f 6e 63 20 22 28   "") "" (conc "(
45a0: 22 20 69 74 65 6d 70 61 74 68 20 22 29 22 29 29  " itempath ")"))
45b0: 29 29 29 0a 0a 28 64 65 66 69 6e 65 2d 69 6e 6c  )))..(define-inl
45c0: 69 6e 65 20 28 74 65 73 74 3a 74 65 73 74 2d 67  ine (test:test-g
45d0: 65 74 2d 66 75 6c 6c 6e 61 6d 65 20 74 65 73 74  et-fullname test
45e0: 29 0a 20 20 20 28 63 6f 6e 63 20 28 64 62 3a 74  ).   (conc (db:t
45f0: 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d 65  est-get-testname
4600: 20 74 65 73 74 29 0a 09 20 28 69 66 20 28 65 71   test).. (if (eq
4610: 75 61 6c 3f 20 28 64 62 3a 74 65 73 74 2d 67 65  ual? (db:test-ge
4620: 74 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74  t-item-path test
4630: 29 20 22 22 29 0a 09 20 20 20 20 20 22 22 0a 09  ) "")..     ""..
4640: 20 20 20 20 20 28 63 6f 6e 63 20 22 28 22 20 28       (conc "(" (
4650: 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d  db:test-get-item
4660: 2d 70 61 74 68 20 74 65 73 74 29 20 22 29 22 29  -path test) ")")
4670: 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 63 68  )))..(define (ch
4680: 65 63 6b 2d 76 61 6c 69 64 2d 69 74 65 6d 73 20  eck-valid-items 
4690: 63 6c 61 73 73 20 69 74 65 6d 29 0a 20 20 28 6c  class item).  (l
46a0: 65 74 20 28 28 76 61 6c 69 64 2d 76 61 6c 75 65  et ((valid-value
46b0: 73 20 28 6c 65 74 20 28 28 73 20 28 63 6f 6e 66  s (let ((s (conf
46c0: 69 67 2d 6c 6f 6f 6b 75 70 20 2a 63 6f 6e 66 69  ig-lookup *confi
46d0: 67 64 61 74 2a 20 22 76 61 6c 69 64 76 61 6c 75  gdat* "validvalu
46e0: 65 73 22 20 63 6c 61 73 73 29 29 29 0a 09 09 09  es" class)))....
46f0: 28 69 66 20 73 20 28 73 74 72 69 6e 67 2d 73 70  (if s (string-sp
4700: 6c 69 74 20 73 29 20 23 66 29 29 29 29 0a 20 20  lit s) #f)))).  
4710: 20 20 28 69 66 20 76 61 6c 69 64 2d 76 61 6c 75    (if valid-valu
4720: 65 73 0a 09 28 69 66 20 28 6d 65 6d 62 65 72 20  es..(if (member 
4730: 69 74 65 6d 20 76 61 6c 69 64 2d 76 61 6c 75 65  item valid-value
4740: 73 29 0a 09 20 20 20 20 69 74 65 6d 20 23 66 29  s)..    item #f)
4750: 0a 09 69 74 65 6d 29 29 29 0a 0a 28 64 65 66 69  ..item)))..(defi
4760: 6e 65 20 28 74 65 73 74 73 74 65 70 2d 73 65 74  ne (teststep-set
4770: 2d 73 74 61 74 75 73 21 20 64 62 20 72 75 6e 2d  -status! db run-
4780: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 74 65 73  id test-name tes
4790: 74 73 74 65 70 2d 6e 61 6d 65 20 73 74 61 74 65  tstep-name state
47a0: 2d 69 6e 20 73 74 61 74 75 73 2d 69 6e 20 69 74  -in status-in it
47b0: 65 6d 64 61 74 20 63 6f 6d 6d 65 6e 74 29 0a 20  emdat comment). 
47c0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20   (debug:print 4 
47d0: 22 72 75 6e 2d 69 64 3a 20 22 20 72 75 6e 2d 69  "run-id: " run-i
47e0: 64 20 22 20 74 65 73 74 2d 6e 61 6d 65 3a 20 22  d " test-name: "
47f0: 20 74 65 73 74 2d 6e 61 6d 65 29 0a 20 20 28 6c   test-name).  (l
4800: 65 74 2a 20 28 28 73 74 61 74 65 20 20 20 20 20  et* ((state     
4810: 28 63 68 65 63 6b 2d 76 61 6c 69 64 2d 69 74 65  (check-valid-ite
4820: 6d 73 20 22 73 74 61 74 65 22 20 73 74 61 74 65  ms "state" state
4830: 2d 69 6e 29 29 0a 09 20 28 73 74 61 74 75 73 20  -in)).. (status 
4840: 20 20 20 28 63 68 65 63 6b 2d 76 61 6c 69 64 2d     (check-valid-
4850: 69 74 65 6d 73 20 22 73 74 61 74 75 73 22 20 73  items "status" s
4860: 74 61 74 75 73 2d 69 6e 29 29 0a 09 20 28 69 74  tatus-in)).. (it
4870: 65 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d 6c 69  em-path (item-li
4880: 73 74 2d 3e 70 61 74 68 20 69 74 65 6d 64 61 74  st->path itemdat
4890: 29 29 0a 09 20 28 74 65 73 74 64 61 74 20 20 20  )).. (testdat   
48a0: 28 64 62 3a 67 65 74 2d 74 65 73 74 2d 69 6e 66  (db:get-test-inf
48b0: 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74  o db run-id test
48c0: 2d 6e 61 6d 65 20 69 74 65 6d 2d 70 61 74 68 29  -name item-path)
48d0: 29 29 0a 20 20 20 20 28 64 65 62 75 67 3a 70 72  )).    (debug:pr
48e0: 69 6e 74 20 35 20 22 74 65 73 74 64 61 74 3a 20  int 5 "testdat: 
48f0: 22 20 74 65 73 74 64 61 74 29 0a 20 20 20 20 28  " testdat).    (
4900: 69 66 20 28 61 6e 64 20 74 65 73 74 64 61 74 20  if (and testdat 
4910: 3b 3b 20 69 66 20 74 68 65 20 73 65 63 74 69 6f  ;; if the sectio
4920: 6e 20 65 78 69 73 74 73 20 74 68 65 6e 20 66 6f  n exists then fo
4930: 72 63 65 20 73 70 65 63 69 66 69 63 61 74 69 6f  rce specificatio
4940: 6e 20 42 55 47 2c 20 49 20 64 6f 6e 27 74 20 6c  n BUG, I don't l
4950: 69 6b 65 20 68 6f 77 20 74 68 69 73 20 77 6f 72  ike how this wor
4960: 6b 73 2e 0a 09 20 20 20 20 20 28 6f 72 20 28 6e  ks...     (or (n
4970: 6f 74 20 73 74 61 74 65 29 28 6e 6f 74 20 73 74  ot state)(not st
4980: 61 74 75 73 29 29 29 0a 09 28 64 65 62 75 67 3a  atus)))..(debug:
4990: 70 72 69 6e 74 20 30 20 22 57 41 52 4e 49 4e 47  print 0 "WARNING
49a0: 3a 20 49 6e 76 61 6c 69 64 20 22 20 28 69 66 20  : Invalid " (if 
49b0: 73 74 61 74 75 73 20 22 73 74 61 74 75 73 22 20  status "status" 
49c0: 22 73 74 61 74 65 22 29 0a 09 20 20 20 20 20 20  "state")..      
49d0: 20 22 20 76 61 6c 75 65 20 5c 22 22 20 28 69 66   " value \"" (if
49e0: 20 73 74 61 74 75 73 20 73 74 61 74 65 2d 69 6e   status state-in
49f0: 20 73 74 61 74 75 73 2d 69 6e 29 20 22 5c 22 2c   status-in) "\",
4a00: 20 75 70 64 61 74 65 20 79 6f 75 72 20 76 61 6c   update your val
4a10: 69 64 76 61 6c 75 65 73 20 73 65 63 74 69 6f 6e  idvalues section
4a20: 20 69 6e 20 6d 65 67 61 74 65 73 74 2e 63 6f 6e   in megatest.con
4a30: 66 69 67 22 29 29 0a 20 20 20 20 28 69 66 20 74  fig")).    (if t
4a40: 65 73 74 64 61 74 0a 09 28 6c 65 74 20 28 28 74  estdat..(let ((t
4a50: 65 73 74 2d 69 64 20 28 74 65 73 74 3a 67 65 74  est-id (test:get
4a60: 2d 69 64 20 74 65 73 74 64 61 74 29 29 29 0a 09  -id testdat)))..
4a70: 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65 63 75    (sqlite3:execu
4a80: 74 65 20 64 62 20 0a 09 09 09 22 49 4e 53 45 52  te db ...."INSER
4a90: 54 20 4f 52 20 52 45 50 4c 41 43 45 20 69 6e 74  T OR REPLACE int
4aa0: 6f 20 74 65 73 74 5f 73 74 65 70 73 20 28 74 65  o test_steps (te
4ab0: 73 74 5f 69 64 2c 73 74 65 70 6e 61 6d 65 2c 73  st_id,stepname,s
4ac0: 74 61 74 65 2c 73 74 61 74 75 73 2c 65 76 65 6e  tate,status,even
4ad0: 74 5f 74 69 6d 65 2c 63 6f 6d 6d 65 6e 74 29 20  t_time,comment) 
4ae0: 56 41 4c 55 45 53 28 3f 2c 3f 2c 3f 2c 3f 2c 73  VALUES(?,?,?,?,s
4af0: 74 72 66 74 69 6d 65 28 27 25 73 27 2c 27 6e 6f  trftime('%s','no
4b00: 77 27 29 2c 3f 29 3b 22 0a 09 09 09 74 65 73 74  w'),?);"....test
4b10: 2d 69 64 20 74 65 73 74 73 74 65 70 2d 6e 61 6d  -id teststep-nam
4b20: 65 20 73 74 61 74 65 2d 69 6e 20 73 74 61 74 75  e state-in statu
4b30: 73 2d 69 6e 20 28 69 66 20 63 6f 6d 6d 65 6e 74  s-in (if comment
4b40: 20 63 6f 6d 6d 65 6e 74 20 22 22 29 29 29 0a 09   comment "")))..
4b50: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
4b60: 45 52 52 4f 52 3a 20 43 61 6e 27 74 20 75 70 64  ERROR: Can't upd
4b70: 61 74 65 20 22 20 74 65 73 74 2d 6e 61 6d 65 20  ate " test-name 
4b80: 22 20 66 6f 72 20 72 75 6e 20 22 20 72 75 6e 2d  " for run " run-
4b90: 69 64 20 22 20 2d 3e 20 6e 6f 20 73 75 63 68 20  id " -> no such 
4ba0: 74 65 73 74 20 69 6e 20 64 62 22 29 29 29 29 0a  test in db")))).
4bb0: 0a 28 64 65 66 69 6e 65 20 28 74 65 73 74 2d 67  .(define (test-g
4bc0: 65 74 2d 6b 69 6c 6c 2d 72 65 71 75 65 73 74 20  et-kill-request 
4bd0: 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e  db run-id test-n
4be0: 61 6d 65 20 69 74 65 6d 64 61 74 29 0a 20 20 28  ame itemdat).  (
4bf0: 6c 65 74 2a 20 28 28 69 74 65 6d 2d 70 61 74 68  let* ((item-path
4c00: 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e 70 61 74   (item-list->pat
4c10: 68 20 69 74 65 6d 64 61 74 29 29 0a 09 20 28 74  h itemdat)).. (t
4c20: 65 73 74 64 61 74 20 20 20 28 64 62 3a 67 65 74  estdat   (db:get
4c30: 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 20 72 75  -test-info db ru
4c40: 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69  n-id test-name i
4c50: 74 65 6d 2d 70 61 74 68 29 29 29 0a 20 20 20 20  tem-path))).    
4c60: 28 65 71 75 61 6c 3f 20 28 74 65 73 74 3a 67 65  (equal? (test:ge
4c70: 74 2d 73 74 61 74 65 20 74 65 73 74 64 61 74 29  t-state testdat)
4c80: 20 22 4b 49 4c 4c 52 45 51 22 29 29 29 0a 0a 28   "KILLREQ")))..(
4c90: 64 65 66 69 6e 65 20 28 74 65 73 74 2d 73 65 74  define (test-set
4ca0: 2d 6d 65 74 61 2d 69 6e 66 6f 20 64 62 20 72 75  -meta-info db ru
4cb0: 6e 2d 69 64 20 74 65 73 74 6e 61 6d 65 20 69 74  n-id testname it
4cc0: 65 6d 64 61 74 29 0a 20 20 28 6c 65 74 20 28 28  emdat).  (let ((
4cd0: 69 74 65 6d 2d 70 61 74 68 20 28 69 74 65 6d 2d  item-path (item-
4ce0: 6c 69 73 74 2d 3e 70 61 74 68 20 69 74 65 6d 64  list->path itemd
4cf0: 61 74 29 29 0a 09 28 63 70 75 6c 6f 61 64 20 20  at))..(cpuload  
4d00: 28 67 65 74 2d 63 70 75 2d 6c 6f 61 64 29 29 0a  (get-cpu-load)).
4d10: 09 28 68 6f 73 74 6e 61 6d 65 20 28 67 65 74 2d  .(hostname (get-
4d20: 68 6f 73 74 2d 6e 61 6d 65 29 29 0a 09 28 64 69  host-name))..(di
4d30: 73 6b 66 72 65 65 20 28 67 65 74 2d 64 66 20 28  skfree (get-df (
4d40: 63 75 72 72 65 6e 74 2d 64 69 72 65 63 74 6f 72  current-director
4d50: 79 29 29 29 0a 09 28 75 6e 61 6d 65 20 20 20 20  y)))..(uname    
4d60: 28 67 65 74 2d 75 6e 61 6d 65 20 22 2d 73 72 76  (get-uname "-srv
4d70: 70 69 6f 22 29 29 0a 09 28 72 75 6e 70 61 74 68  pio"))..(runpath
4d80: 20 20 28 63 75 72 72 65 6e 74 2d 64 69 72 65 63    (current-direc
4d90: 74 6f 72 79 29 29 29 0a 20 20 20 20 28 73 71 6c  tory))).    (sql
4da0: 69 74 65 33 3a 65 78 65 63 75 74 65 20 64 62 20  ite3:execute db 
4db0: 22 55 50 44 41 54 45 20 74 65 73 74 73 20 53 45  "UPDATE tests SE
4dc0: 54 20 68 6f 73 74 3d 3f 2c 63 70 75 6c 6f 61 64  T host=?,cpuload
4dd0: 3d 3f 2c 64 69 73 6b 66 72 65 65 3d 3f 2c 75 6e  =?,diskfree=?,un
4de0: 61 6d 65 3d 3f 2c 72 75 6e 64 69 72 3d 3f 20 57  ame=?,rundir=? W
4df0: 48 45 52 45 20 72 75 6e 5f 69 64 3d 3f 20 41 4e  HERE run_id=? AN
4e00: 44 20 74 65 73 74 6e 61 6d 65 3d 3f 20 41 4e 44  D testname=? AND
4e10: 20 69 74 65 6d 5f 70 61 74 68 3d 3f 3b 22 0a 09   item_path=?;"..
4e20: 09 20 20 68 6f 73 74 6e 61 6d 65 0a 09 09 20 20  .  hostname...  
4e30: 63 70 75 6c 6f 61 64 0a 09 09 20 20 64 69 73 6b  cpuload...  disk
4e40: 66 72 65 65 0a 09 09 20 20 75 6e 61 6d 65 0a 09  free...  uname..
4e50: 09 20 20 72 75 6e 70 61 74 68 0a 09 09 20 20 72  .  runpath...  r
4e60: 75 6e 2d 69 64 0a 09 09 20 20 74 65 73 74 6e 61  un-id...  testna
4e70: 6d 65 0a 09 09 20 20 69 74 65 6d 2d 70 61 74 68  me...  item-path
4e80: 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 74 65  )))..(define (te
4e90: 73 74 2d 75 70 64 61 74 65 2d 6d 65 74 61 2d 69  st-update-meta-i
4ea0: 6e 66 6f 20 64 62 20 72 75 6e 2d 69 64 20 74 65  nfo db run-id te
4eb0: 73 74 6e 61 6d 65 20 69 74 65 6d 64 61 74 20 6d  stname itemdat m
4ec0: 69 6e 75 74 65 73 20 63 70 75 6c 6f 61 64 20 64  inutes cpuload d
4ed0: 69 73 6b 66 72 65 65 20 74 6d 70 66 72 65 65 29  iskfree tmpfree)
4ee0: 0a 20 20 28 6c 65 74 20 28 28 69 74 65 6d 2d 70  .  (let ((item-p
4ef0: 61 74 68 20 28 69 74 65 6d 2d 6c 69 73 74 2d 3e  ath (item-list->
4f00: 70 61 74 68 20 69 74 65 6d 64 61 74 29 29 29 0a  path itemdat))).
4f10: 20 20 20 20 28 69 66 20 28 6e 6f 74 20 69 74 65      (if (not ite
4f20: 6d 2d 70 61 74 68 29 28 62 65 67 69 6e 20 28 64  m-path)(begin (d
4f30: 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41  ebug:print 0 "WA
4f40: 52 4e 49 4e 47 3a 20 49 54 45 4d 50 41 54 48 20  RNING: ITEMPATH 
4f50: 6e 6f 74 20 73 65 74 2e 22 29 20 20 20 28 73 65  not set.")   (se
4f60: 74 21 20 69 74 65 6d 2d 70 61 74 68 20 22 22 29  t! item-path "")
4f70: 29 29 0a 20 20 20 20 3b 3b 20 28 6c 65 74 20 28  )).    ;; (let (
4f80: 28 74 65 73 74 69 6e 66 6f 20 28 64 62 3a 67 65  (testinfo (db:ge
4f90: 74 2d 74 65 73 74 2d 69 6e 66 6f 20 64 62 20 72  t-test-info db r
4fa0: 75 6e 2d 69 64 20 74 65 73 74 6e 61 6d 65 20 69  un-id testname i
4fb0: 74 65 6d 2d 70 61 74 68 29 29 29 0a 20 20 20 20  tem-path))).    
4fc0: 3b 3b 20 20 20 28 69 66 20 28 61 6e 64 20 28 6e  ;;   (if (and (n
4fd0: 6f 74 20 28 65 71 75 61 6c 3f 20 28 64 62 3a 74  ot (equal? (db:t
4fe0: 65 73 74 2d 67 65 74 2d 73 74 61 74 75 73 20 74  est-get-status t
4ff0: 65 73 74 69 6e 66 6f 29 20 22 43 4f 4d 50 4c 45  estinfo) "COMPLE
5000: 54 45 44 22 29 29 0a 20 20 20 20 3b 3b 20 20 20  TED")).    ;;   
5010: 20 20 20 20 20 20 20 20 20 28 6e 6f 74 20 28 65           (not (e
5020: 71 75 61 6c 3f 20 28 64 62 3a 74 65 73 74 2d 67  qual? (db:test-g
5030: 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 69 6e  et-status testin
5040: 66 6f 29 20 22 4b 49 4c 4c 52 45 51 22 29 29 0a  fo) "KILLREQ")).
5050: 20 20 20 20 28 73 71 6c 69 74 65 33 3a 65 78 65      (sqlite3:exe
5060: 63 75 74 65 0a 20 20 20 20 20 64 62 0a 20 20 20  cute.     db.   
5070: 20 20 22 55 50 44 41 54 45 20 74 65 73 74 73 20    "UPDATE tests 
5080: 53 45 54 20 63 70 75 6c 6f 61 64 3d 3f 2c 64 69  SET cpuload=?,di
5090: 73 6b 66 72 65 65 3d 3f 2c 72 75 6e 5f 64 75 72  skfree=?,run_dur
50a0: 61 74 69 6f 6e 3d 3f 2c 73 74 61 74 65 3d 27 52  ation=?,state='R
50b0: 55 4e 4e 49 4e 47 27 20 57 48 45 52 45 20 72 75  UNNING' WHERE ru
50c0: 6e 5f 69 64 3d 3f 20 41 4e 44 20 74 65 73 74 6e  n_id=? AND testn
50d0: 61 6d 65 3d 3f 20 41 4e 44 20 69 74 65 6d 5f 70  ame=? AND item_p
50e0: 61 74 68 3d 3f 20 41 4e 44 20 73 74 61 74 65 20  ath=? AND state 
50f0: 4e 4f 54 20 49 4e 20 28 27 43 4f 4d 50 4c 45 54  NOT IN ('COMPLET
5100: 45 44 27 2c 27 4b 49 4c 4c 52 45 51 27 2c 27 4b  ED','KILLREQ','K
5110: 49 4c 4c 45 44 27 29 3b 22 0a 20 20 20 20 20 63  ILLED');".     c
5120: 70 75 6c 6f 61 64 0a 20 20 20 20 20 64 69 73 6b  puload.     disk
5130: 66 72 65 65 0a 20 20 20 20 20 6d 69 6e 75 74 65  free.     minute
5140: 73 0a 20 20 20 20 20 72 75 6e 2d 69 64 0a 20 20  s.     run-id.  
5150: 20 20 20 74 65 73 74 6e 61 6d 65 0a 20 20 20 20     testname.    
5160: 20 69 74 65 6d 2d 70 61 74 68 29 29 29 0a 0a 28   item-path)))..(
5170: 64 65 66 69 6e 65 20 28 73 65 74 2d 6d 65 67 61  define (set-mega
5180: 74 65 73 74 2d 65 6e 76 2d 76 61 72 73 20 64 62  test-env-vars db
5190: 20 72 75 6e 2d 69 64 29 0a 20 20 28 6c 65 74 20   run-id).  (let 
51a0: 28 28 6b 65 79 73 20 28 64 62 2d 67 65 74 2d 6b  ((keys (db-get-k
51b0: 65 79 73 20 64 62 29 29 29 0a 20 20 20 20 28 66  eys db))).    (f
51c0: 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62 64 61 20  or-each (lambda 
51d0: 28 6b 65 79 29 0a 09 09 28 73 71 6c 69 74 65 33  (key)...(sqlite3
51e0: 3a 66 6f 72 2d 65 61 63 68 2d 72 6f 77 0a 09 09  :for-each-row...
51f0: 20 28 6c 61 6d 62 64 61 20 28 76 61 6c 29 0a 09   (lambda (val)..
5200: 09 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74  .   (debug:print
5210: 20 32 20 22 73 65 74 65 6e 76 20 22 20 28 6b 65   2 "setenv " (ke
5220: 79 3a 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20  y:get-fieldname 
5230: 6b 65 79 29 20 22 20 22 20 76 61 6c 29 0a 09 09  key) " " val)...
5240: 20 20 20 28 73 65 74 65 6e 76 20 28 6b 65 79 3a     (setenv (key:
5250: 67 65 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65  get-fieldname ke
5260: 79 29 20 76 61 6c 29 29 0a 09 09 20 64 62 20 0a  y) val))... db .
5270: 09 09 20 28 63 6f 6e 63 20 22 53 45 4c 45 43 54  .. (conc "SELECT
5280: 20 22 20 28 6b 65 79 3a 67 65 74 2d 66 69 65 6c   " (key:get-fiel
5290: 64 6e 61 6d 65 20 6b 65 79 29 20 22 20 46 52 4f  dname key) " FRO
52a0: 4d 20 72 75 6e 73 20 57 48 45 52 45 20 69 64 3d  M runs WHERE id=
52b0: 3f 3b 22 29 0a 09 09 20 72 75 6e 2d 69 64 29 29  ?;")... run-id))
52c0: 0a 09 20 20 20 20 20 20 6b 65 79 73 29 29 29 0a  ..      keys))).
52d0: 0a 28 64 65 66 69 6e 65 20 28 73 65 74 2d 69 74  .(define (set-it
52e0: 65 6d 2d 65 6e 76 2d 76 61 72 73 20 69 74 65 6d  em-env-vars item
52f0: 64 61 74 29 0a 20 20 28 66 6f 72 2d 65 61 63 68  dat).  (for-each
5300: 20 28 6c 61 6d 62 64 61 20 28 69 74 65 6d 29 0a   (lambda (item).
5310: 09 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72  .      (debug:pr
5320: 69 6e 74 20 32 20 22 73 65 74 65 6e 76 20 22 20  int 2 "setenv " 
5330: 28 63 61 72 20 69 74 65 6d 29 20 22 20 22 20 28  (car item) " " (
5340: 63 61 64 72 20 69 74 65 6d 29 29 0a 09 20 20 20  cadr item))..   
5350: 20 20 20 28 73 65 74 65 6e 76 20 28 63 61 72 20     (setenv (car 
5360: 69 74 65 6d 29 20 28 63 61 64 72 20 69 74 65 6d  item) (cadr item
5370: 29 29 29 0a 09 20 20 20 20 69 74 65 6d 64 61 74  )))..    itemdat
5380: 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 67 65 74  ))..(define (get
5390: 2d 61 6c 6c 2d 6c 65 67 61 6c 2d 74 65 73 74 73  -all-legal-tests
53a0: 29 0a 20 20 28 6c 65 74 2a 20 28 28 74 65 73 74  ).  (let* ((test
53b0: 73 20 20 28 67 6c 6f 62 20 28 63 6f 6e 63 20 2a  s  (glob (conc *
53c0: 74 6f 70 70 61 74 68 2a 20 22 2f 74 65 73 74 73  toppath* "/tests
53d0: 2f 2a 22 29 29 29 0a 09 20 28 72 65 73 20 20 20  /*"))).. (res   
53e0: 20 27 28 29 29 29 0a 20 20 20 20 28 64 65 62 75   '())).    (debu
53f0: 67 3a 70 72 69 6e 74 20 34 20 22 49 4e 46 4f 3a  g:print 4 "INFO:
5400: 20 4c 6f 6f 6b 69 6e 67 20 61 74 20 74 65 73 74   Looking at test
5410: 73 20 22 20 28 73 74 72 69 6e 67 2d 69 6e 74 65  s " (string-inte
5420: 72 73 70 65 72 73 65 20 74 65 73 74 73 20 22 2c  rsperse tests ",
5430: 22 29 29 0a 20 20 20 20 28 66 6f 72 2d 65 61 63  ")).    (for-eac
5440: 68 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74 70  h (lambda (testp
5450: 61 74 68 29 0a 09 09 28 69 66 20 28 66 69 6c 65  ath)...(if (file
5460: 2d 65 78 69 73 74 73 3f 20 28 63 6f 6e 63 20 74  -exists? (conc t
5470: 65 73 74 70 61 74 68 20 22 2f 74 65 73 74 63 6f  estpath "/testco
5480: 6e 66 69 67 22 29 29 0a 09 09 20 20 20 20 28 73  nfig"))...    (s
5490: 65 74 21 20 72 65 73 20 28 63 6f 6e 73 20 28 6c  et! res (cons (l
54a0: 61 73 74 20 28 73 74 72 69 6e 67 2d 73 70 6c 69  ast (string-spli
54b0: 74 20 74 65 73 74 70 61 74 68 20 22 2f 22 29 29  t testpath "/"))
54c0: 20 72 65 73 29 29 29 29 0a 09 20 20 20 20 20 20   res))))..      
54d0: 74 65 73 74 73 29 0a 20 20 20 20 72 65 73 29 29  tests).    res))
54e0: 0a 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a  ..(define (runs:
54f0: 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65 73  can-run-more-tes
5500: 74 73 20 64 62 29 0a 20 20 28 6c 65 74 20 28 28  ts db).  (let ((
5510: 6e 75 6d 2d 72 75 6e 6e 69 6e 67 20 28 64 62 3a  num-running (db:
5520: 67 65 74 2d 63 6f 75 6e 74 2d 74 65 73 74 73 2d  get-count-tests-
5530: 72 75 6e 6e 69 6e 67 20 64 62 29 29 0a 09 28 6d  running db))..(m
5540: 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f  ax-concurrent-jo
5550: 62 73 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75  bs (config-looku
5560: 70 20 2a 63 6f 6e 66 69 67 64 61 74 2a 20 22 73  p *configdat* "s
5570: 65 74 75 70 22 20 22 6d 61 78 5f 63 6f 6e 63 75  etup" "max_concu
5580: 72 72 65 6e 74 5f 6a 6f 62 73 22 29 29 29 0a 20  rrent_jobs"))). 
5590: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
55a0: 32 20 22 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e  2 "max-concurren
55b0: 74 2d 6a 6f 62 73 3a 20 22 20 6d 61 78 2d 63 6f  t-jobs: " max-co
55c0: 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 20 22 2c  ncurrent-jobs ",
55d0: 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67 3a 20 22 20   num-running: " 
55e0: 6e 75 6d 2d 72 75 6e 6e 69 6e 67 29 0a 20 20 20  num-running).   
55f0: 20 28 69 66 20 28 6e 6f 74 20 28 65 71 3f 20 30   (if (not (eq? 0
5600: 20 2a 67 6c 6f 62 61 6c 65 78 69 74 73 74 61 74   *globalexitstat
5610: 75 73 2a 29 29 0a 09 23 66 0a 09 28 69 66 20 28  us*))..#f..(if (
5620: 6f 72 20 28 6e 6f 74 20 6d 61 78 2d 63 6f 6e 63  or (not max-conc
5630: 75 72 72 65 6e 74 2d 6a 6f 62 73 29 0a 09 09 28  urrent-jobs)...(
5640: 61 6e 64 20 6d 61 78 2d 63 6f 6e 63 75 72 72 65  and max-concurre
5650: 6e 74 2d 6a 6f 62 73 0a 09 09 20 20 20 20 20 28  nt-jobs...     (
5660: 73 74 72 69 6e 67 2d 3e 6e 75 6d 62 65 72 20 6d  string->number m
5670: 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f  ax-concurrent-jo
5680: 62 73 29 0a 09 09 20 20 20 20 20 28 6e 6f 74 20  bs)...     (not 
5690: 28 3e 3d 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67 20  (>= num-running 
56a0: 28 73 74 72 69 6e 67 2d 3e 6e 75 6d 62 65 72 20  (string->number 
56b0: 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a  max-concurrent-j
56c0: 6f 62 73 29 29 29 29 29 0a 09 20 20 20 20 23 74  obs)))))..    #t
56d0: 0a 09 20 20 20 20 28 62 65 67 69 6e 20 0a 09 20  ..    (begin .. 
56e0: 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e       (debug:prin
56f0: 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 4d 61  t 0 "WARNING: Ma
5700: 78 20 72 75 6e 6e 69 6e 67 20 6a 6f 62 73 20 65  x running jobs e
5710: 78 63 65 65 64 65 64 2c 20 63 75 72 72 65 6e 74  xceeded, current
5720: 20 6e 75 6d 62 65 72 20 72 75 6e 6e 69 6e 67 3a   number running:
5730: 20 22 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67 20 0a   " num-running .
5740: 09 09 09 20 20 20 22 2c 20 6d 61 78 5f 63 6f 6e  ...   ", max_con
5750: 63 75 72 72 65 6e 74 5f 6a 6f 62 73 3a 20 22 20  current_jobs: " 
5760: 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a  max-concurrent-j
5770: 6f 62 73 29 0a 09 20 20 20 20 20 20 23 66 29 29  obs)..      #f))
5780: 29 29 29 0a 20 20 0a 28 64 65 66 69 6e 65 20 28  ))).  .(define (
5790: 72 75 6e 2d 74 65 73 74 73 20 64 62 20 74 65 73  run-tests db tes
57a0: 74 2d 6e 61 6d 65 73 29 0a 20 20 28 6c 65 74 2a  t-names).  (let*
57b0: 20 28 28 6b 65 79 73 20 20 20 20 20 20 20 20 28   ((keys        (
57c0: 64 62 2d 67 65 74 2d 6b 65 79 73 20 64 62 29 29  db-get-keys db))
57d0: 0a 09 20 28 6b 65 79 76 61 6c 6c 73 74 20 20 20  .. (keyvallst   
57e0: 28 6b 65 79 73 2d 3e 76 61 6c 6c 69 73 74 20 6b  (keys->vallist k
57f0: 65 79 73 20 23 74 29 29 0a 09 20 28 72 75 6e 2d  eys #t)).. (run-
5800: 69 64 20 20 20 20 20 20 28 72 65 67 69 73 74 65  id      (registe
5810: 72 2d 72 75 6e 20 64 62 20 6b 65 79 73 29 29 20  r-run db keys)) 
5820: 20 3b 3b 20 20 74 65 73 74 2d 6e 61 6d 65 29 29   ;;  test-name))
5830: 29 0a 09 20 28 64 65 66 65 72 72 65 64 20 20 20  ).. (deferred   
5840: 20 27 28 29 29 29 20 3b 3b 20 64 65 6c 61 79 20   '())) ;; delay 
5850: 72 75 6e 6e 69 6e 67 20 74 68 65 73 65 20 73 69  running these si
5860: 6e 63 65 20 74 68 65 79 20 68 61 76 65 20 61 20  nce they have a 
5870: 77 61 69 74 6f 6e 20 63 6c 61 75 73 65 0a 20 20  waiton clause.  
5880: 20 20 3b 3b 20 6f 6e 20 74 68 65 20 66 69 72 73    ;; on the firs
5890: 74 20 70 61 73 73 20 6f 72 20 63 61 6c 6c 20 74  t pass or call t
58a0: 6f 20 72 75 6e 2d 74 65 73 74 73 20 73 65 74 20  o run-tests set 
58b0: 46 41 49 4c 53 20 74 6f 20 4e 4f 54 5f 53 54 41  FAILS to NOT_STA
58c0: 52 54 45 44 20 69 66 0a 20 20 20 20 3b 3b 20 2d  RTED if.    ;; -
58d0: 6b 65 65 70 67 6f 69 6e 67 20 69 73 20 73 70 65  keepgoing is spe
58e0: 63 69 66 69 65 64 0a 20 20 20 20 28 69 66 20 28  cified.    (if (
58f0: 61 6e 64 20 28 65 71 3f 20 2a 70 61 73 73 6e 75  and (eq? *passnu
5900: 6d 2a 20 30 29 0a 09 20 20 20 20 20 28 61 72 67  m* 0)..     (arg
5910: 73 3a 67 65 74 2d 61 72 67 20 22 2d 6b 65 65 70  s:get-arg "-keep
5920: 67 6f 69 6e 67 22 29 29 0a 09 28 62 65 67 69 6e  going"))..(begin
5930: 0a 09 20 20 3b 3b 20 68 61 76 65 20 74 6f 20 64  ..  ;; have to d
5940: 65 6c 65 74 65 20 74 65 73 74 20 72 65 63 6f 72  elete test recor
5950: 64 73 20 77 68 65 72 65 20 4e 4f 54 5f 53 54 41  ds where NOT_STA
5960: 52 54 45 44 20 73 69 6e 63 65 20 74 68 65 79 20  RTED since they 
5970: 63 61 6e 20 63 61 75 73 65 20 2d 6b 65 65 70 67  can cause -keepg
5980: 6f 69 6e 67 20 74 6f 20 0a 09 20 20 3b 3b 20 67  oing to ..  ;; g
5990: 65 74 20 73 74 75 63 6b 20 64 75 65 20 74 6f 20  et stuck due to 
59a0: 62 65 63 6f 6d 69 6e 67 20 69 6e 61 63 63 65 73  becoming inacces
59b0: 73 69 62 6c 65 20 66 72 6f 6d 20 61 20 66 61 69  sible from a fai
59c0: 6c 65 64 20 74 65 73 74 2e 20 49 2e 65 2e 20 69  led test. I.e. i
59d0: 66 20 74 65 73 74 20 42 20 64 65 70 65 6e 64 73  f test B depends
59e0: 20 0a 09 20 20 3b 3b 20 6f 6e 20 74 65 73 74 20   ..  ;; on test 
59f0: 41 20 62 75 74 20 74 65 73 74 20 42 20 72 65 61  A but test B rea
5a00: 63 68 65 64 20 74 68 65 20 70 6f 69 6e 74 20 6f  ched the point o
5a10: 6e 20 62 65 69 6e 67 20 72 65 67 69 73 74 65 72  n being register
5a20: 65 64 20 61 73 20 4e 4f 54 5f 53 54 41 52 54 45  ed as NOT_STARTE
5a30: 44 20 61 6e 64 20 74 65 73 74 0a 09 20 20 3b 3b  D and test..  ;;
5a40: 20 41 20 66 61 69 6c 65 64 20 66 6f 72 20 73 6f   A failed for so
5a50: 6d 65 20 72 65 61 73 6f 6e 20 74 68 65 6e 20 6f  me reason then o
5a60: 6e 20 72 65 2d 72 75 6e 20 75 73 69 6e 67 20 2d  n re-run using -
5a70: 6b 65 65 70 67 6f 69 6e 67 20 74 68 65 20 72 75  keepgoing the ru
5a80: 6e 20 63 61 6e 20 6e 65 76 65 72 20 63 6f 6d 70  n can never comp
5a90: 6c 65 74 65 2e 0a 09 20 20 28 64 62 3a 64 65 6c  lete...  (db:del
5aa0: 65 74 65 2d 74 65 73 74 73 2d 69 6e 2d 73 74 61  ete-tests-in-sta
5ab0: 74 65 20 64 62 20 72 75 6e 2d 69 64 20 22 4e 4f  te db run-id "NO
5ac0: 54 5f 53 54 41 52 54 45 44 22 29 0a 09 20 20 28  T_STARTED")..  (
5ad0: 64 62 3a 73 65 74 2d 74 65 73 74 73 2d 73 74 61  db:set-tests-sta
5ae0: 74 65 2d 73 74 61 74 75 73 20 64 62 20 72 75 6e  te-status db run
5af0: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 73 20 23  -id test-names #
5b00: 66 20 22 46 41 49 4c 22 20 22 4e 4f 54 5f 53 54  f "FAIL" "NOT_ST
5b10: 41 52 54 45 44 22 20 22 46 41 49 4c 22 29 29 29  ARTED" "FAIL")))
5b20: 0a 20 20 20 20 28 73 65 74 21 20 2a 70 61 73 73  .    (set! *pass
5b30: 6e 75 6d 2a 20 28 2b 20 2a 70 61 73 73 6e 75 6d  num* (+ *passnum
5b40: 2a 20 31 29 29 0a 20 20 20 20 28 6c 65 74 20 6c  * 1)).    (let l
5b50: 6f 6f 70 20 28 28 6e 75 6d 74 69 6d 65 73 20 30  oop ((numtimes 0
5b60: 29 29 0a 20 20 20 20 20 20 28 66 6f 72 2d 65 61  )).      (for-ea
5b70: 63 68 20 0a 20 20 20 20 20 20 20 28 6c 61 6d 62  ch .       (lamb
5b80: 64 61 20 28 74 65 73 74 2d 6e 61 6d 65 29 0a 09  da (test-name)..
5b90: 20 28 69 66 20 28 72 75 6e 73 3a 63 61 6e 2d 72   (if (runs:can-r
5ba0: 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73 20 64 62  un-more-tests db
5bb0: 29 0a 09 20 20 20 20 20 28 72 75 6e 2d 6f 6e 65  )..     (run-one
5bc0: 2d 74 65 73 74 20 64 62 20 72 75 6e 2d 69 64 20  -test db run-id 
5bd0: 74 65 73 74 2d 6e 61 6d 65 20 6b 65 79 76 61 6c  test-name keyval
5be0: 6c 73 74 29 0a 09 20 20 20 20 20 3b 3b 20 61 64  lst)..     ;; ad
5bf0: 64 20 73 6f 6d 65 20 64 65 6c 61 79 20 0a 09 20  d some delay .. 
5c00: 20 20 20 20 3b 28 73 6c 65 65 70 20 32 29 0a 09      ;(sleep 2)..
5c10: 20 20 20 20 20 29 29 0a 20 20 20 20 20 20 20 74       )).       t
5c20: 65 73 74 2d 6e 61 6d 65 73 29 0a 20 20 20 20 20  est-names).     
5c30: 20 3b 3b 20 28 72 75 6e 2d 77 61 69 74 69 6e 67   ;; (run-waiting
5c40: 2d 74 65 73 74 73 20 64 62 29 0a 20 20 20 20 20  -tests db).     
5c50: 20 28 69 66 20 28 61 72 67 73 3a 67 65 74 2d 61   (if (args:get-a
5c60: 72 67 20 22 2d 6b 65 65 70 67 6f 69 6e 67 22 29  rg "-keepgoing")
5c70: 0a 09 20 20 28 6c 65 74 20 28 28 65 73 74 72 65  ..  (let ((estre
5c80: 6d 20 28 64 62 3a 65 73 74 69 6d 61 74 65 64 2d  m (db:estimated-
5c90: 74 65 73 74 73 2d 72 65 6d 61 69 6e 69 6e 67 20  tests-remaining 
5ca0: 64 62 20 72 75 6e 2d 69 64 29 29 29 0a 09 20 20  db run-id)))..  
5cb0: 20 20 28 69 66 20 28 61 6e 64 20 28 3e 20 65 73    (if (and (> es
5cc0: 74 72 65 6d 20 30 29 0a 09 09 20 20 20 20 20 28  trem 0)...     (
5cd0: 65 71 3f 20 2a 67 6c 6f 62 61 6c 65 78 69 74 73  eq? *globalexits
5ce0: 74 61 74 75 73 2a 20 30 29 29 0a 09 09 28 62 65  tatus* 0))...(be
5cf0: 67 69 6e 0a 09 09 20 20 28 64 65 62 75 67 3a 70  gin...  (debug:p
5d00: 72 69 6e 74 20 31 20 22 4b 65 65 70 20 67 6f 69  rint 1 "Keep goi
5d10: 6e 67 2c 20 65 73 74 69 6d 61 74 65 64 20 22 20  ng, estimated " 
5d20: 65 73 74 72 65 6d 20 22 20 74 65 73 74 73 20 72  estrem " tests r
5d30: 65 6d 61 69 6e 69 6e 67 20 74 6f 20 72 75 6e 2c  emaining to run,
5d40: 20 77 69 6c 6c 20 63 6f 6e 74 69 6e 75 65 20 69   will continue i
5d50: 6e 20 33 20 73 65 63 6f 6e 64 73 20 2e 2e 2e 22  n 3 seconds ..."
5d60: 29 0a 09 09 20 20 28 73 6c 65 65 70 20 33 29 0a  )...  (sleep 3).
5d70: 09 09 20 20 28 72 75 6e 2d 77 61 69 74 69 6e 67  ..  (run-waiting
5d80: 2d 74 65 73 74 73 20 64 62 29 0a 09 09 20 20 28  -tests db)...  (
5d90: 6c 6f 6f 70 20 28 2b 20 6e 75 6d 74 69 6d 65 73  loop (+ numtimes
5da0: 20 31 29 29 29 29 29 29 29 29 29 0a 09 20 20 20   1)))))))))..   
5db0: 0a 3b 3b 20 56 45 52 59 20 49 4e 45 46 46 49 43  .;; VERY INEFFIC
5dc0: 49 45 4e 54 21 20 4d 6f 76 65 20 73 74 75 66 66  IENT! Move stuff
5dd0: 20 74 68 61 74 20 73 68 6f 75 6c 64 20 62 65 20   that should be 
5de0: 64 6f 6e 65 20 6f 6e 63 65 20 75 70 20 74 6f 20  done once up to 
5df0: 63 61 6c 6c 69 6e 67 20 70 72 6f 63 0a 28 64 65  calling proc.(de
5e00: 66 69 6e 65 20 28 72 75 6e 2d 6f 6e 65 2d 74 65  fine (run-one-te
5e10: 73 74 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73  st db run-id tes
5e20: 74 2d 6e 61 6d 65 20 6b 65 79 76 61 6c 6c 73 74  t-name keyvallst
5e30: 29 0a 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ).  (debug:print
5e40: 20 31 20 22 4c 61 75 6e 63 68 69 6e 67 20 74 65   1 "Launching te
5e50: 73 74 20 22 20 74 65 73 74 2d 6e 61 6d 65 29 0a  st " test-name).
5e60: 20 20 3b 3b 20 41 6c 6c 20 74 68 65 73 65 20 76    ;; All these v
5e70: 61 72 73 20 6d 69 67 68 74 20 62 65 20 72 65 66  ars might be ref
5e80: 65 72 65 6e 63 65 64 20 62 79 20 74 68 65 20 74  erenced by the t
5e90: 65 73 74 63 6f 6e 66 69 67 20 66 69 6c 65 20 72  estconfig file r
5ea0: 65 61 64 65 72 0a 20 20 28 73 65 74 65 6e 76 20  eader.  (setenv 
5eb0: 22 4d 54 5f 54 45 53 54 5f 4e 41 4d 45 22 20 74  "MT_TEST_NAME" t
5ec0: 65 73 74 2d 6e 61 6d 65 29 20 3b 3b 20 0a 20 20  est-name) ;; .  
5ed0: 28 73 65 74 65 6e 76 20 22 4d 54 5f 52 55 4e 4e  (setenv "MT_RUNN
5ee0: 41 4d 45 22 20 20 20 28 61 72 67 73 3a 67 65 74  AME"   (args:get
5ef0: 2d 61 72 67 20 22 3a 72 75 6e 6e 61 6d 65 22 29  -arg ":runname")
5f00: 29 0a 20 20 28 73 65 74 2d 6d 65 67 61 74 65 73  ).  (set-megates
5f10: 74 2d 65 6e 76 2d 76 61 72 73 20 64 62 20 72 75  t-env-vars db ru
5f20: 6e 2d 69 64 29 20 3b 3b 20 74 68 65 73 65 20 6d  n-id) ;; these m
5f30: 61 79 20 62 65 20 6e 65 65 64 65 64 20 62 79 20  ay be needed by 
5f40: 74 68 65 20 6c 61 75 6e 63 68 69 6e 67 20 70 72  the launching pr
5f50: 6f 63 65 73 73 0a 20 20 28 63 68 61 6e 67 65 2d  ocess.  (change-
5f60: 64 69 72 65 63 74 6f 72 79 20 2a 74 6f 70 70 61  directory *toppa
5f70: 74 68 2a 29 0a 20 20 28 6c 65 74 2a 20 28 28 74  th*).  (let* ((t
5f80: 65 73 74 2d 70 61 74 68 20 20 20 20 28 63 6f 6e  est-path    (con
5f90: 63 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f 74 65  c *toppath* "/te
5fa0: 73 74 73 2f 22 20 74 65 73 74 2d 6e 61 6d 65 29  sts/" test-name)
5fb0: 29 0a 09 20 28 74 65 73 74 2d 63 6f 6e 66 69 67  ).. (test-config
5fc0: 66 20 28 63 6f 6e 63 20 74 65 73 74 2d 70 61 74  f (conc test-pat
5fd0: 68 20 22 2f 74 65 73 74 63 6f 6e 66 69 67 22 29  h "/testconfig")
5fe0: 29 0a 09 20 28 74 65 73 74 65 78 69 73 74 73 20  ).. (testexists 
5ff0: 20 20 28 61 6e 64 20 28 66 69 6c 65 2d 65 78 69    (and (file-exi
6000: 73 74 73 3f 20 74 65 73 74 2d 63 6f 6e 66 69 67  sts? test-config
6010: 66 29 28 66 69 6c 65 2d 72 65 61 64 2d 61 63 63  f)(file-read-acc
6020: 65 73 73 3f 20 74 65 73 74 2d 63 6f 6e 66 69 67  ess? test-config
6030: 66 29 29 29 0a 09 20 28 74 65 73 74 2d 63 6f 6e  f))).. (test-con
6040: 66 20 20 20 20 28 69 66 20 74 65 73 74 65 78 69  f    (if testexi
6050: 73 74 73 20 28 72 65 61 64 2d 63 6f 6e 66 69 67  sts (read-config
6060: 20 74 65 73 74 2d 63 6f 6e 66 69 67 66 20 23 66   test-configf #f
6070: 20 23 74 29 20 28 6d 61 6b 65 2d 68 61 73 68 2d   #t) (make-hash-
6080: 74 61 62 6c 65 29 29 29 0a 09 20 28 77 61 69 74  table))).. (wait
6090: 6f 6e 20 20 20 20 20 20 20 28 6c 65 74 20 28 28  on       (let ((
60a0: 77 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70  w (config-lookup
60b0: 20 74 65 73 74 2d 63 6f 6e 66 20 22 72 65 71 75   test-conf "requ
60c0: 69 72 65 6d 65 6e 74 73 22 20 22 77 61 69 74 6f  irements" "waito
60d0: 6e 22 29 29 29 0a 09 09 09 20 28 69 66 20 28 73  n"))).... (if (s
60e0: 74 72 69 6e 67 3f 20 77 29 28 73 74 72 69 6e 67  tring? w)(string
60f0: 2d 73 70 6c 69 74 20 77 29 27 28 29 29 29 29 0a  -split w)'()))).
6100: 09 20 28 74 61 67 73 20 20 20 20 20 20 20 20 20  . (tags         
6110: 28 6c 65 74 20 28 28 74 20 28 63 6f 6e 66 69 67  (let ((t (config
6120: 2d 6c 6f 6f 6b 75 70 20 74 65 73 74 2d 63 6f 6e  -lookup test-con
6130: 66 20 22 73 65 74 75 70 22 20 22 74 61 67 73 22  f "setup" "tags"
6140: 29 29 29 0a 09 09 09 20 3b 3b 20 77 65 20 77 61  ))).... ;; we wa
6150: 6e 74 20 6f 75 72 20 74 61 67 73 20 74 6f 20 62  nt our tags to b
6160: 65 20 73 65 70 61 72 61 74 65 64 20 62 79 20 63  e separated by c
6170: 6f 6d 6d 61 73 20 61 6e 64 20 66 75 6c 6c 79 20  ommas and fully 
6180: 64 65 6c 69 6d 69 74 65 64 20 62 79 20 63 6f 6d  delimited by com
6190: 6d 61 73 0a 09 09 09 20 3b 3b 20 73 6f 20 74 68  mas.... ;; so th
61a0: 61 74 20 71 75 65 72 69 65 73 20 77 69 74 68 20  at queries with 
61b0: 22 6c 69 6b 65 22 20 63 61 6e 20 74 69 65 20 74  "like" can tie t
61c0: 6f 20 74 68 65 20 63 6f 6d 6d 61 73 20 61 74 20  o the commas at 
61d0: 65 69 74 68 65 72 20 65 6e 64 20 6f 66 20 65 61  either end of ea
61e0: 63 68 20 74 61 67 0a 09 09 09 20 3b 3b 20 77 68  ch tag.... ;; wh
61f0: 69 6c 65 20 61 6c 73 6f 20 61 6c 6c 6f 77 69 6e  ile also allowin
6200: 67 20 74 68 65 20 65 6e 64 20 75 73 65 72 20 74  g the end user t
6210: 6f 20 66 72 65 65 6c 79 20 75 73 65 20 73 70 61  o freely use spa
6220: 63 65 73 20 61 6e 64 20 63 6f 6d 6d 61 73 20 74  ces and commas t
6230: 6f 20 73 65 70 61 72 61 74 65 20 74 61 67 73 0a  o separate tags.
6240: 09 09 09 20 28 69 66 20 28 73 74 72 69 6e 67 3f  ... (if (string?
6250: 20 74 29 28 73 74 72 69 6e 67 2d 73 75 62 73 74   t)(string-subst
6260: 69 74 75 74 65 20 28 72 65 67 65 78 70 20 22 5b  itute (regexp "[
6270: 2c 5c 5c 73 5d 2b 22 29 20 22 2c 22 20 28 63 6f  ,\\s]+") "," (co
6280: 6e 63 20 22 2c 22 20 74 20 22 2c 22 29 20 23 74  nc "," t ",") #t
6290: 29 0a 09 09 09 20 20 20 20 20 27 28 29 29 29 29  )....     '())))
62a0: 29 0a 20 20 20 20 28 69 66 20 28 6e 6f 74 20 74  ).    (if (not t
62b0: 65 73 74 65 78 69 73 74 73 29 0a 09 28 62 65 67  estexists)..(beg
62c0: 69 6e 0a 09 20 20 28 64 65 62 75 67 3a 70 72 69  in..  (debug:pri
62d0: 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 43 61 6e  nt 0 "ERROR: Can
62e0: 27 74 20 66 69 6e 64 20 63 6f 6e 66 69 67 20 66  't find config f
62f0: 69 6c 65 20 22 20 74 65 73 74 2d 63 6f 6e 66 69  ile " test-confi
6300: 67 66 29 0a 09 20 20 28 65 78 69 74 20 32 29 29  gf)..  (exit 2))
6310: 0a 09 3b 3b 20 70 75 74 20 74 6f 70 20 76 61 72  ..;; put top var
6320: 73 20 69 6e 74 6f 20 63 6f 6e 76 65 6e 69 65 6e  s into convenien
6330: 74 20 76 61 72 69 61 62 6c 65 73 20 61 6e 64 20  t variables and 
6340: 6f 70 65 6e 20 74 68 65 20 64 62 0a 09 28 6c 65  open the db..(le
6350: 74 2a 20 28 3b 3b 20 64 62 20 69 73 20 61 6c 77  t* (;; db is alw
6360: 61 79 73 20 61 74 20 2a 74 6f 70 70 61 74 68 2a  ays at *toppath*
6370: 2f 64 62 2f 6d 65 67 61 74 65 73 74 2e 64 62 0a  /db/megatest.db.
6380: 09 20 20 20 20 20 20 20 28 69 74 65 6d 73 20 20  .       (items  
6390: 20 20 20 20 20 28 68 61 73 68 2d 74 61 62 6c 65       (hash-table
63a0: 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 74 65 73  -ref/default tes
63b0: 74 2d 63 6f 6e 66 20 22 69 74 65 6d 73 22 20 27  t-conf "items" '
63c0: 28 29 29 29 0a 09 20 20 20 20 20 20 20 28 69 74  ()))..       (it
63d0: 65 6d 73 74 61 62 6c 65 20 20 28 68 61 73 68 2d  emstable  (hash-
63e0: 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c  table-ref/defaul
63f0: 74 20 74 65 73 74 2d 63 6f 6e 66 20 22 69 74 65  t test-conf "ite
6400: 6d 73 74 61 62 6c 65 22 20 27 28 29 29 29 0a 09  mstable" '()))..
6410: 20 20 20 20 20 20 20 28 61 6c 6c 69 74 65 6d 73         (allitems
6420: 20 20 20 20 28 69 66 20 28 6f 72 20 28 6e 6f 74      (if (or (not
6430: 20 28 6e 75 6c 6c 3f 20 69 74 65 6d 73 29 29 28   (null? items))(
6440: 6e 6f 74 20 28 6e 75 6c 6c 3f 20 69 74 65 6d 73  not (null? items
6450: 74 61 62 6c 65 29 29 29 0a 09 09 09 09 28 61 70  table))).....(ap
6460: 70 65 6e 64 20 28 69 74 65 6d 2d 61 73 73 6f 63  pend (item-assoc
6470: 2d 3e 69 74 65 6d 2d 6c 69 73 74 20 69 74 65 6d  ->item-list item
6480: 73 29 0a 09 09 09 09 09 28 69 74 65 6d 2d 74 61  s)......(item-ta
6490: 62 6c 65 2d 3e 69 74 65 6d 2d 6c 69 73 74 20 69  ble->item-list i
64a0: 74 65 6d 73 74 61 62 6c 65 29 29 0a 09 09 09 09  temstable)).....
64b0: 27 28 28 29 29 29 29 20 3b 3b 20 61 20 6c 69 73  '(()))) ;; a lis
64c0: 74 20 77 69 74 68 20 6f 6e 65 20 6e 75 6c 6c 20  t with one null 
64d0: 6c 69 73 74 20 69 73 20 61 20 74 65 73 74 20 77  list is a test w
64e0: 69 74 68 20 6e 6f 20 69 74 65 6d 73 0a 09 20 20  ith no items..  
64f0: 20 20 20 20 20 28 72 75 6e 63 6f 6e 66 69 67 66       (runconfigf
6500: 20 20 28 63 6f 6e 63 20 20 2a 74 6f 70 70 61 74    (conc  *toppat
6510: 68 2a 20 22 2f 72 75 6e 63 6f 6e 66 69 67 73 2e  h* "/runconfigs.
6520: 63 6f 6e 66 69 67 22 29 29 29 0a 09 20 20 28 64  config")))..  (d
6530: 65 62 75 67 3a 70 72 69 6e 74 20 31 20 22 69 74  ebug:print 1 "it
6540: 65 6d 73 3a 20 22 29 0a 09 20 20 28 69 66 20 28  ems: ")..  (if (
6550: 3e 3d 20 2a 76 65 72 62 6f 73 69 74 79 2a 20 31  >= *verbosity* 1
6560: 29 28 70 70 20 61 6c 6c 69 74 65 6d 73 29 29 0a  )(pp allitems)).
6570: 09 20 20 28 69 66 20 28 3e 3d 20 2a 76 65 72 62  .  (if (>= *verb
6580: 6f 73 69 74 79 2a 20 35 29 0a 09 20 20 20 20 20  osity* 5)..     
6590: 20 28 62 65 67 69 6e 0a 09 09 28 70 72 69 6e 74   (begin...(print
65a0: 20 22 69 74 65 6d 73 3a 20 22 29 28 70 70 20 28   "items: ")(pp (
65b0: 69 74 65 6d 2d 61 73 73 6f 63 2d 3e 69 74 65 6d  item-assoc->item
65c0: 2d 6c 69 73 74 20 69 74 65 6d 73 29 29 0a 09 09  -list items))...
65d0: 28 70 72 69 6e 74 20 22 69 74 65 73 74 61 62 6c  (print "itestabl
65e0: 65 3a 20 22 29 28 70 70 20 28 69 74 65 6d 2d 74  e: ")(pp (item-t
65f0: 61 62 6c 65 2d 3e 69 74 65 6d 2d 6c 69 73 74 20  able->item-list 
6600: 69 74 65 6d 73 74 61 62 6c 65 29 29 29 29 0a 09  itemstable))))..
6610: 20 20 28 69 66 20 28 61 72 67 73 3a 67 65 74 2d    (if (args:get-
6620: 61 72 67 20 22 2d 6d 22 29 0a 09 20 20 20 20 20  arg "-m")..     
6630: 20 28 64 62 3a 73 65 74 2d 63 6f 6d 6d 65 6e 74   (db:set-comment
6640: 2d 66 6f 72 2d 72 75 6e 20 64 62 20 72 75 6e 2d  -for-run db run-
6650: 69 64 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67  id (args:get-arg
6660: 20 22 2d 6d 22 29 29 29 0a 0a 09 20 20 3b 3b 20   "-m")))...  ;; 
6670: 48 65 72 65 20 69 73 20 77 68 65 72 65 20 74 68  Here is where th
6680: 65 20 74 65 73 74 5f 6d 65 74 61 20 74 61 62 6c  e test_meta tabl
6690: 65 20 69 73 20 62 65 73 74 20 75 70 64 61 74 65  e is best update
66a0: 64 0a 09 20 20 28 72 75 6e 73 3a 75 70 64 61 74  d..  (runs:updat
66b0: 65 2d 74 65 73 74 5f 6d 65 74 61 20 64 62 20 74  e-test_meta db t
66c0: 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 2d 63 6f  est-name test-co
66d0: 6e 66 29 0a 0a 09 20 20 3b 3b 20 62 72 61 69 6e  nf)...  ;; brain
66e0: 64 65 61 64 20 77 6f 72 6b 2d 61 72 6f 75 6e 64  dead work-around
66f0: 20 66 6f 72 20 70 6f 6f 72 6c 79 20 73 70 65 63   for poorly spec
6700: 69 66 69 65 64 20 61 6c 6c 69 74 65 6d 73 20 6c  ified allitems l
6710: 69 73 74 20 42 55 47 21 21 21 20 46 49 58 4d 45  ist BUG!!! FIXME
6720: 0a 09 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 61  ..  (if (null? a
6730: 6c 6c 69 74 65 6d 73 29 28 73 65 74 21 20 61 6c  llitems)(set! al
6740: 6c 69 74 65 6d 73 20 27 28 28 29 29 29 29 0a 09  litems '(())))..
6750: 20 20 28 6c 65 74 20 6c 6f 6f 70 20 28 28 69 74    (let loop ((it
6760: 65 6d 64 61 74 20 28 63 61 72 20 61 6c 6c 69 74  emdat (car allit
6770: 65 6d 73 29 29 0a 09 09 20 20 20 20 20 28 74 61  ems))...     (ta
6780: 6c 20 20 20 20 20 28 63 64 72 20 61 6c 6c 69 74  l     (cdr allit
6790: 65 6d 73 29 29 29 0a 09 20 20 20 20 3b 3b 20 28  ems)))..    ;; (
67a0: 6c 61 6d 62 64 61 20 28 69 74 65 6d 64 61 74 29  lambda (itemdat)
67b0: 20 3b 3b 3b 20 28 28 72 69 70 65 6e 65 73 73 20   ;;; ((ripeness 
67c0: 22 6f 76 65 72 72 69 70 65 22 29 20 28 74 65 6d  "overripe") (tem
67d0: 70 65 72 61 74 75 72 65 20 22 63 6f 6f 6c 22 29  perature "cool")
67e0: 20 28 73 65 61 73 6f 6e 20 22 73 75 6d 6d 65 72   (season "summer
67f0: 22 29 29 0a 09 20 20 20 20 3b 3b 20 48 61 6e 64  "))..    ;; Hand
6800: 6c 65 20 6c 69 73 74 73 20 6f 66 20 69 74 65 6d  le lists of item
6810: 73 0a 09 20 20 20 20 28 6c 65 74 2a 20 28 28 69  s..    (let* ((i
6820: 74 65 6d 2d 70 61 74 68 20 20 20 20 20 28 69 74  tem-path     (it
6830: 65 6d 2d 6c 69 73 74 2d 3e 70 61 74 68 20 69 74  em-list->path it
6840: 65 6d 64 61 74 29 29 20 3b 3b 20 28 73 74 72 69  emdat)) ;; (stri
6850: 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20 28  ng-intersperse (
6860: 6d 61 70 20 63 61 64 72 20 69 74 65 6d 64 61 74  map cadr itemdat
6870: 29 20 22 2f 22 29 29 0a 09 09 20 20 20 28 6e 65  ) "/"))...   (ne
6880: 77 2d 74 65 73 74 2d 70 61 74 68 20 28 73 74 72  w-test-path (str
6890: 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73 65 20  ing-intersperse 
68a0: 28 63 6f 6e 73 20 74 65 73 74 2d 70 61 74 68 20  (cons test-path 
68b0: 28 6d 61 70 20 63 61 64 72 20 69 74 65 6d 64 61  (map cadr itemda
68c0: 74 29 29 20 22 2f 22 29 29 0a 09 09 20 20 20 28  t)) "/"))...   (
68d0: 6e 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20 28 69  new-test-name (i
68e0: 66 20 28 65 71 75 61 6c 3f 20 69 74 65 6d 2d 70  f (equal? item-p
68f0: 61 74 68 20 22 22 29 20 74 65 73 74 2d 6e 61 6d  ath "") test-nam
6900: 65 20 28 63 6f 6e 63 20 74 65 73 74 2d 6e 61 6d  e (conc test-nam
6910: 65 20 22 2f 22 20 69 74 65 6d 2d 70 61 74 68 29  e "/" item-path)
6920: 29 29 20 3b 3b 20 6a 75 73 74 20 6e 65 65 64 20  )) ;; just need 
6930: 69 74 20 74 6f 20 62 65 20 75 6e 69 71 75 65 0a  it to be unique.
6940: 09 09 20 20 20 28 74 65 73 74 64 61 74 20 20 20  ..   (testdat   
6950: 23 66 29 0a 09 09 20 20 20 28 6e 75 6d 2d 72 75  #f)...   (num-ru
6960: 6e 6e 69 6e 67 20 28 64 62 3a 67 65 74 2d 63 6f  nning (db:get-co
6970: 75 6e 74 2d 74 65 73 74 73 2d 72 75 6e 6e 69 6e  unt-tests-runnin
6980: 67 20 64 62 29 29 0a 09 09 20 20 20 28 6d 61 78  g db))...   (max
6990: 2d 63 6f 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73  -concurrent-jobs
69a0: 20 28 63 6f 6e 66 69 67 2d 6c 6f 6f 6b 75 70 20   (config-lookup 
69b0: 2a 63 6f 6e 66 69 67 64 61 74 2a 20 22 73 65 74  *configdat* "set
69c0: 75 70 22 20 22 6d 61 78 5f 63 6f 6e 63 75 72 72  up" "max_concurr
69d0: 65 6e 74 5f 6a 6f 62 73 22 29 29 0a 09 09 20 20  ent_jobs"))...  
69e0: 20 28 70 61 72 65 6e 74 2d 74 65 73 74 20 28 61   (parent-test (a
69f0: 6e 64 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 69  nd (not (null? i
6a00: 74 65 6d 73 29 29 28 65 71 75 61 6c 3f 20 69 74  tems))(equal? it
6a10: 65 6d 2d 70 61 74 68 20 22 22 29 29 29 0a 09 09  em-path "")))...
6a20: 20 20 20 28 73 69 6e 67 6c 65 2d 74 65 73 74 20     (single-test 
6a30: 28 61 6e 64 20 28 6e 75 6c 6c 3f 20 69 74 65 6d  (and (null? item
6a40: 73 29 20 28 65 71 75 61 6c 3f 20 69 74 65 6d 2d  s) (equal? item-
6a50: 70 61 74 68 20 22 22 29 29 29 0a 09 09 20 20 20  path "")))...   
6a60: 28 69 74 65 6d 2d 74 65 73 74 20 20 20 28 6e 6f  (item-test   (no
6a70: 74 20 28 65 71 75 61 6c 3f 20 69 74 65 6d 2d 70  t (equal? item-p
6a80: 61 74 68 20 22 22 29 29 29 0a 09 09 20 20 20 28  ath "")))...   (
6a90: 69 74 65 6d 2d 70 61 74 74 20 20 20 28 61 72 67  item-patt   (arg
6aa0: 73 3a 67 65 74 2d 61 72 67 20 22 2d 69 74 65 6d  s:get-arg "-item
6ab0: 70 61 74 74 22 29 29 0a 09 09 20 20 20 28 70 61  patt"))...   (pa
6ac0: 74 74 2d 6d 61 74 63 68 20 20 28 69 66 20 69 74  tt-match  (if it
6ad0: 65 6d 2d 70 61 74 74 0a 09 09 09 09 20 20 20 20  em-patt.....    
6ae0: 28 73 74 72 69 6e 67 2d 6d 61 74 63 68 20 28 67  (string-match (g
6af0: 6c 6f 62 2d 3e 72 65 67 65 78 70 0a 09 09 09 09  lob->regexp.....
6b00: 09 09 20 20 20 28 73 74 72 69 6e 67 2d 74 72 61  ..   (string-tra
6b10: 6e 73 6c 61 74 65 20 69 74 65 6d 2d 70 61 74 74  nslate item-patt
6b20: 20 22 25 22 20 22 2a 22 29 29 0a 09 09 09 09 09   "%" "*"))......
6b30: 09 20 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 09  .  item-path)...
6b40: 09 09 20 20 20 20 23 74 29 29 29 0a 09 20 20 20  ..    #t)))..   
6b50: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
6b60: 33 20 22 6d 61 78 2d 63 6f 6e 63 75 72 72 65 6e  3 "max-concurren
6b70: 74 2d 6a 6f 62 73 3a 20 22 20 6d 61 78 2d 63 6f  t-jobs: " max-co
6b80: 6e 63 75 72 72 65 6e 74 2d 6a 6f 62 73 20 22 2c  ncurrent-jobs ",
6b90: 20 6e 75 6d 2d 72 75 6e 6e 69 6e 67 3a 20 22 20   num-running: " 
6ba0: 6e 75 6d 2d 72 75 6e 6e 69 6e 67 29 0a 09 20 20  num-running)..  
6bb0: 20 20 20 20 28 69 66 20 28 61 6e 64 20 70 61 74      (if (and pat
6bc0: 74 2d 6d 61 74 63 68 20 28 72 75 6e 73 3a 63 61  t-match (runs:ca
6bd0: 6e 2d 72 75 6e 2d 6d 6f 72 65 2d 74 65 73 74 73  n-run-more-tests
6be0: 20 64 62 29 29 0a 09 09 20 20 28 62 65 67 69 6e   db))...  (begin
6bf0: 0a 09 09 20 20 20 20 28 6c 65 74 20 6c 6f 6f 70  ...    (let loop
6c00: 32 20 28 28 74 73 20 28 64 62 3a 67 65 74 2d 74  2 ((ts (db:get-t
6c10: 65 73 74 2d 69 6e 66 6f 20 64 62 20 72 75 6e 2d  est-info db run-
6c20: 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65  id test-name ite
6c30: 6d 2d 70 61 74 68 29 29 20 3b 3b 20 23 66 29 0a  m-path)) ;; #f).
6c40: 09 09 09 09 28 63 74 20 30 29 29 0a 09 09 20 20  ....(ct 0))...  
6c50: 20 20 20 20 28 69 66 20 28 61 6e 64 20 28 6e 6f      (if (and (no
6c60: 74 20 74 73 29 0a 09 09 09 20 20 20 20 20 20 20  t ts)....       
6c70: 28 3c 20 63 74 20 31 30 29 29 0a 09 09 09 20 20  (< ct 10))....  
6c80: 28 62 65 67 69 6e 0a 09 09 09 20 20 20 20 28 72  (begin....    (r
6c90: 65 67 69 73 74 65 72 2d 74 65 73 74 20 64 62 20  egister-test db 
6ca0: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
6cb0: 20 69 74 65 6d 2d 70 61 74 68 29 0a 09 09 09 20   item-path).... 
6cc0: 20 20 20 28 64 62 3a 74 65 73 74 2d 73 65 74 2d     (db:test-set-
6cd0: 63 6f 6d 6d 65 6e 74 20 64 62 20 72 75 6e 2d 69  comment db run-i
6ce0: 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74 65 6d  d test-name item
6cf0: 2d 70 61 74 68 20 22 22 29 0a 09 09 09 20 20 20  -path "")....   
6d00: 20 28 6c 6f 6f 70 32 20 28 64 62 3a 67 65 74 2d   (loop2 (db:get-
6d10: 74 65 73 74 2d 69 6e 66 6f 20 64 62 20 72 75 6e  test-info db run
6d20: 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65 20 69 74  -id test-name it
6d30: 65 6d 2d 70 61 74 68 29 0a 09 09 09 09 20 20 20  em-path).....   
6d40: 28 2b 20 63 74 20 31 29 29 29 0a 09 09 09 20 20  (+ ct 1)))....  
6d50: 28 69 66 20 74 73 0a 09 09 09 20 20 20 20 20 20  (if ts....      
6d60: 28 73 65 74 21 20 74 65 73 74 64 61 74 20 74 73  (set! testdat ts
6d70: 29 0a 09 09 09 20 20 20 20 20 20 28 62 65 67 69  )....      (begi
6d80: 6e 0a 09 09 09 09 28 64 65 62 75 67 3a 70 72 69  n.....(debug:pri
6d90: 6e 74 20 30 20 22 57 41 52 4e 49 4e 47 3a 20 43  nt 0 "WARNING: C
6da0: 6f 75 6c 64 6e 27 74 20 72 65 67 69 73 74 65 72  ouldn't register
6db0: 20 74 65 73 74 20 22 20 74 65 73 74 2d 6e 61 6d   test " test-nam
6dc0: 65 20 22 20 77 69 74 68 20 69 74 65 6d 20 70 61  e " with item pa
6dd0: 74 68 20 22 20 69 74 65 6d 2d 70 61 74 68 20 22  th " item-path "
6de0: 2c 20 73 6b 69 70 70 69 6e 67 22 29 0a 09 09 09  , skipping")....
6df0: 09 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f  .(if (not (null?
6e00: 20 74 61 6c 29 29 0a 09 09 09 09 20 20 20 20 28   tal)).....    (
6e10: 6c 6f 6f 70 20 28 63 61 72 20 74 61 6c 29 28 63  loop (car tal)(c
6e20: 64 72 20 74 61 6c 29 29 29 29 29 29 29 0a 09 09  dr tal)))))))...
6e30: 20 20 20 20 28 63 68 61 6e 67 65 2d 64 69 72 65      (change-dire
6e40: 63 74 6f 72 79 20 74 65 73 74 2d 70 61 74 68 29  ctory test-path)
6e50: 0a 09 09 20 20 20 20 3b 3b 20 74 68 69 73 20 62  ...    ;; this b
6e60: 6c 6f 63 6b 20 69 73 20 68 65 72 65 20 6f 6e 6c  lock is here onl
6e70: 79 20 74 6f 20 69 6e 66 6f 72 6d 20 74 68 65 20  y to inform the 
6e80: 75 73 65 72 20 65 61 72 6c 79 20 6f 6e 0a 09 09  user early on...
6e90: 20 20 20 20 28 69 66 20 28 66 69 6c 65 2d 65 78      (if (file-ex
6ea0: 69 73 74 73 3f 20 72 75 6e 63 6f 6e 66 69 67 66  ists? runconfigf
6eb0: 29 0a 09 09 09 28 73 65 74 75 70 2d 65 6e 76 2d  )....(setup-env-
6ec0: 64 65 66 61 75 6c 74 73 20 64 62 20 72 75 6e 63  defaults db runc
6ed0: 6f 6e 66 69 67 66 20 72 75 6e 2d 69 64 20 2a 61  onfigf run-id *a
6ee0: 6c 72 65 61 64 79 2d 73 65 65 6e 2d 72 75 6e 63  lready-seen-runc
6ef0: 6f 6e 66 69 67 2d 69 6e 66 6f 2a 29 0a 09 09 09  onfig-info*)....
6f00: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22  (debug:print 0 "
6f10: 57 41 52 4e 49 4e 47 3a 20 59 6f 75 20 64 6f 20  WARNING: You do 
6f20: 6e 6f 74 20 68 61 76 65 20 61 20 72 75 6e 20 63  not have a run c
6f30: 6f 6e 66 69 67 20 66 69 6c 65 3a 20 22 20 72 75  onfig file: " ru
6f40: 6e 63 6f 6e 66 69 67 66 29 29 0a 09 09 20 20 20  nconfigf))...   
6f50: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20   (debug:print 4 
6f60: 22 72 75 6e 2d 69 64 3a 20 22 20 72 75 6e 2d 69  "run-id: " run-i
6f70: 64 20 22 20 74 65 73 74 2d 6e 61 6d 65 3a 20 22  d " test-name: "
6f80: 20 74 65 73 74 2d 6e 61 6d 65 20 22 20 69 74 65   test-name " ite
6f90: 6d 2d 70 61 74 68 3a 20 22 20 69 74 65 6d 2d 70  m-path: " item-p
6fa0: 61 74 68 20 22 20 74 65 73 74 64 61 74 3a 20 22  ath " testdat: "
6fb0: 20 28 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75   (test:get-statu
6fc0: 73 20 74 65 73 74 64 61 74 29 20 22 20 74 65 73  s testdat) " tes
6fd0: 74 2d 73 74 61 74 65 3a 20 22 20 28 74 65 73 74  t-state: " (test
6fe0: 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64  :get-state testd
6ff0: 61 74 29 29 0a 09 09 20 20 20 20 28 63 61 73 65  at))...    (case
7000: 20 28 69 66 20 28 61 72 67 73 3a 67 65 74 2d 61   (if (args:get-a
7010: 72 67 20 22 2d 66 6f 72 63 65 22 29 0a 09 09 09  rg "-force")....
7020: 20 20 20 20 20 20 27 4e 4f 54 5f 53 54 41 52 54        'NOT_START
7030: 45 44 0a 09 09 09 20 20 20 20 20 20 28 69 66 20  ED....      (if 
7040: 74 65 73 74 64 61 74 0a 09 09 09 09 20 20 28 73  testdat.....  (s
7050: 74 72 69 6e 67 2d 3e 73 79 6d 62 6f 6c 20 28 74  tring->symbol (t
7060: 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65  est:get-state te
7070: 73 74 64 61 74 29 29 0a 09 09 09 09 20 20 27 66  stdat)).....  'f
7080: 61 69 6c 65 64 2d 74 6f 2d 69 6e 73 65 72 74 29  ailed-to-insert)
7090: 29 0a 09 09 20 20 20 20 20 20 28 28 66 61 69 6c  )...      ((fail
70a0: 65 64 2d 74 6f 2d 69 6e 73 65 72 74 29 0a 09 09  ed-to-insert)...
70b0: 20 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72         (debug:pr
70c0: 69 6e 74 20 30 20 22 45 52 52 4f 52 3a 20 46 61  int 0 "ERROR: Fa
70d0: 69 6c 65 64 20 74 6f 20 69 6e 73 65 72 74 20 74  iled to insert t
70e0: 68 65 20 72 65 63 6f 72 64 20 69 6e 74 6f 20 74  he record into t
70f0: 68 65 20 64 62 22 29 29 0a 09 09 20 20 20 20 20  he db"))...     
7100: 20 28 28 4e 4f 54 5f 53 54 41 52 54 45 44 20 43   ((NOT_STARTED C
7110: 4f 4d 50 4c 45 54 45 44 29 0a 09 09 20 20 20 20  OMPLETED)...    
7120: 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20     (debug:print 
7130: 36 20 22 47 6f 74 20 68 65 72 65 2c 20 22 20 28  6 "Got here, " (
7140: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74  test:get-state t
7150: 65 73 74 64 61 74 29 29 0a 09 09 20 20 20 20 20  estdat))...     
7160: 20 20 28 6c 65 74 20 28 28 72 75 6e 66 6c 61 67    (let ((runflag
7170: 20 23 66 29 29 0a 09 09 09 20 28 63 6f 6e 64 0a   #f)).... (cond.
7180: 09 09 09 20 20 3b 3b 20 69 2e 65 2e 20 74 68 69  ...  ;; i.e. thi
7190: 73 20 69 73 20 74 68 65 20 70 61 72 65 6e 74 20  s is the parent 
71a0: 74 65 73 74 20 74 6f 20 61 20 73 75 69 74 65 20  test to a suite 
71b0: 6f 66 20 69 74 65 6d 73 2c 20 6e 65 76 65 72 20  of items, never 
71c0: 22 72 75 6e 22 20 69 74 0a 09 09 09 20 20 28 70  "run" it....  (p
71d0: 61 72 65 6e 74 2d 74 65 73 74 0a 09 09 09 20 20  arent-test....  
71e0: 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23   (set! runflag #
71f0: 66 29 29 0a 09 09 09 20 20 3b 3b 20 2d 66 6f 72  f))....  ;; -for
7200: 63 65 2c 20 72 75 6e 20 6e 6f 20 6d 61 74 74 65  ce, run no matte
7210: 72 20 77 68 61 74 0a 09 09 09 20 20 28 28 61 72  r what....  ((ar
7220: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 66 6f 72  gs:get-arg "-for
7230: 63 65 22 29 28 73 65 74 21 20 72 75 6e 66 6c 61  ce")(set! runfla
7240: 67 20 23 74 29 29 0a 09 09 09 20 20 3b 3b 20 4e  g #t))....  ;; N
7250: 4f 54 5f 53 54 41 52 54 45 44 2c 20 72 75 6e 20  OT_STARTED, run 
7260: 6e 6f 20 6d 61 74 74 65 72 20 77 68 61 74 0a 09  no matter what..
7270: 09 09 20 20 28 28 65 71 75 61 6c 3f 20 28 74 65  ..  ((equal? (te
7280: 73 74 3a 67 65 74 2d 73 74 61 74 65 20 74 65 73  st:get-state tes
7290: 74 64 61 74 29 20 22 4e 4f 54 5f 53 54 41 52 54  tdat) "NOT_START
72a0: 45 44 22 29 28 73 65 74 21 20 72 75 6e 66 6c 61  ED")(set! runfla
72b0: 67 20 23 74 29 29 0a 09 09 09 20 20 3b 3b 20 6e  g #t))....  ;; n
72c0: 6f 74 20 2d 72 65 72 75 6e 20 61 6e 64 20 50 41  ot -rerun and PA
72d0: 53 53 2c 20 57 41 52 4e 20 6f 72 20 43 48 45 43  SS, WARN or CHEC
72e0: 4b 2c 20 64 6f 20 6e 6f 20 72 75 6e 0a 09 09 09  K, do no run....
72f0: 20 20 28 28 61 6e 64 20 28 6f 72 20 28 6e 6f 74    ((and (or (not
7300: 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20 22   (args:get-arg "
7310: 2d 72 65 72 75 6e 22 29 29 0a 09 09 09 09 20 20  -rerun")).....  
7320: 20 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20    (args:get-arg 
7330: 22 2d 6b 65 65 70 67 6f 69 6e 67 22 29 29 0a 09  "-keepgoing"))..
7340: 09 09 09 28 6d 65 6d 62 65 72 20 28 74 65 73 74  ...(member (test
7350: 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65 73 74  :get-status test
7360: 64 61 74 29 20 27 28 22 50 41 53 53 22 20 22 57  dat) '("PASS" "W
7370: 41 52 4e 22 20 22 43 48 45 43 4b 22 29 29 29 0a  ARN" "CHECK"))).
7380: 09 09 09 20 20 20 28 73 65 74 21 20 72 75 6e 66  ...   (set! runf
7390: 6c 61 67 20 23 66 29 29 0a 09 09 09 20 20 3b 3b  lag #f))....  ;;
73a0: 20 2d 72 65 72 75 6e 20 61 6e 64 20 73 74 61 74   -rerun and stat
73b0: 75 73 20 69 73 20 6f 6e 65 20 6f 66 20 74 68 65  us is one of the
73c0: 20 73 70 65 63 69 66 65 64 2c 20 72 75 6e 20 69   specifed, run i
73d0: 74 0a 09 09 09 20 20 28 28 61 6e 64 20 28 61 72  t....  ((and (ar
73e0: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 72 65 72  gs:get-arg "-rer
73f0: 75 6e 22 29 0a 09 09 09 09 28 6c 65 74 20 28 28  un").....(let ((
7400: 72 65 72 75 6e 6c 73 74 20 28 73 74 72 69 6e 67  rerunlst (string
7410: 2d 73 70 6c 69 74 20 28 61 72 67 73 3a 67 65 74  -split (args:get
7420: 2d 61 72 67 20 22 2d 72 65 72 75 6e 22 29 20 22  -arg "-rerun") "
7430: 2c 22 29 29 29 20 3b 3b 20 46 41 49 4c 2c 0a 09  ,"))) ;; FAIL,..
7440: 09 09 09 20 20 28 6d 65 6d 62 65 72 20 28 74 65  ...  (member (te
7450: 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20 74 65  st:get-status te
7460: 73 74 64 61 74 29 20 72 65 72 75 6e 6c 73 74 29  stdat) rerunlst)
7470: 29 29 0a 09 09 09 20 20 20 28 73 65 74 21 20 72  ))....   (set! r
7480: 75 6e 66 6c 61 67 20 23 74 29 29 0a 09 09 09 20  unflag #t)).... 
7490: 20 3b 3b 20 2d 6b 65 65 70 67 6f 69 6e 67 2c 20   ;; -keepgoing, 
74a0: 64 6f 20 6e 6f 74 20 72 65 72 75 6e 20 46 41 49  do not rerun FAI
74b0: 4c 0a 09 09 09 20 20 28 28 61 6e 64 20 28 61 72  L....  ((and (ar
74c0: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 6b 65 65  gs:get-arg "-kee
74d0: 70 67 6f 69 6e 67 22 29 0a 09 09 09 09 28 6d 65  pgoing").....(me
74e0: 6d 62 65 72 20 28 74 65 73 74 3a 67 65 74 2d 73  mber (test:get-s
74f0: 74 61 74 75 73 20 74 65 73 74 64 61 74 29 20 27  tatus testdat) '
7500: 28 22 46 41 49 4c 22 29 29 29 0a 09 09 09 20 20  ("FAIL")))....  
7510: 20 28 73 65 74 21 20 72 75 6e 66 6c 61 67 20 23   (set! runflag #
7520: 66 29 29 0a 09 09 09 20 20 28 28 61 6e 64 20 28  f))....  ((and (
7530: 6e 6f 74 20 28 61 72 67 73 3a 67 65 74 2d 61 72  not (args:get-ar
7540: 67 20 22 2d 72 65 72 75 6e 22 29 29 0a 09 09 09  g "-rerun"))....
7550: 09 28 6d 65 6d 62 65 72 20 28 74 65 73 74 3a 67  .(member (test:g
7560: 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61  et-status testda
7570: 74 29 20 27 28 22 46 41 49 4c 22 20 22 6e 2f 61  t) '("FAIL" "n/a
7580: 22 29 29 29 0a 09 09 09 20 20 20 28 73 65 74 21  ")))....   (set!
7590: 20 72 75 6e 66 6c 61 67 20 23 74 29 29 0a 09 09   runflag #t))...
75a0: 09 20 20 28 65 6c 73 65 20 28 73 65 74 21 20 72  .  (else (set! r
75b0: 75 6e 66 6c 61 67 20 23 66 29 29 29 0a 09 09 09  unflag #f)))....
75c0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 36 20   (debug:print 6 
75d0: 22 52 55 4e 4e 49 4e 47 20 3d 3e 20 72 75 6e 66  "RUNNING => runf
75e0: 6c 61 67 3a 20 22 20 72 75 6e 66 6c 61 67 20 22  lag: " runflag "
75f0: 20 53 54 41 54 45 3a 20 22 20 28 74 65 73 74 3a   STATE: " (test:
7600: 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61  get-state testda
7610: 74 29 20 22 20 53 54 41 54 55 53 3a 20 22 20 28  t) " STATUS: " (
7620: 74 65 73 74 3a 67 65 74 2d 73 74 61 74 75 73 20  test:get-status 
7630: 74 65 73 74 64 61 74 29 29 0a 09 09 09 20 28 69  testdat)).... (i
7640: 66 20 28 6e 6f 74 20 72 75 6e 66 6c 61 67 29 0a  f (not runflag).
7650: 09 09 09 20 20 20 20 20 28 69 66 20 28 6e 6f 74  ...     (if (not
7660: 20 70 61 72 65 6e 74 2d 74 65 73 74 29 0a 09 09   parent-test)...
7670: 09 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20  .. (debug:print 
7680: 31 20 22 4e 4f 54 45 3a 20 4e 6f 74 20 73 74 61  1 "NOTE: Not sta
7690: 72 74 69 6e 67 20 74 65 73 74 20 22 20 6e 65 77  rting test " new
76a0: 2d 74 65 73 74 2d 6e 61 6d 65 20 22 20 61 73 20  -test-name " as 
76b0: 69 74 20 69 73 20 73 74 61 74 65 20 5c 22 43 4f  it is state \"CO
76c0: 4d 50 4c 45 54 45 44 5c 22 20 61 6e 64 20 73 74  MPLETED\" and st
76d0: 61 74 75 73 20 5c 22 22 20 28 74 65 73 74 3a 67  atus \"" (test:g
76e0: 65 74 2d 73 74 61 74 75 73 20 74 65 73 74 64 61  et-status testda
76f0: 74 29 20 22 5c 22 2c 20 75 73 65 20 2d 66 6f 72  t) "\", use -for
7700: 63 65 20 74 6f 20 6f 76 65 72 72 69 64 65 22 29  ce to override")
7710: 29 0a 09 09 09 20 20 20 20 20 28 6c 65 74 2a 20  )....     (let* 
7720: 28 28 67 65 74 2d 70 72 65 72 65 71 73 2d 63 6d  ((get-prereqs-cm
7730: 64 20 28 6c 61 6d 62 64 61 20 28 29 0a 09 09 09  d (lambda ()....
7740: 09 09 09 20 20 20 20 20 20 20 28 64 62 2d 67 65  ...       (db-ge
7750: 74 2d 70 72 65 72 65 71 73 2d 6e 6f 74 2d 6d 65  t-prereqs-not-me
7760: 74 20 64 62 20 72 75 6e 2d 69 64 20 77 61 69 74  t db run-id wait
7770: 6f 6e 29 29 29 20 3b 3b 20 63 68 65 63 6b 20 62  on))) ;; check b
7780: 65 66 6f 72 65 20 72 75 6e 6e 69 6e 67 20 2e 2e  efore running ..
7790: 2e 2e 0a 09 09 09 09 20 20 20 20 28 6c 61 75 6e  .......    (laun
77a0: 63 68 2d 63 6d 64 20 20 20 20 20 20 28 6c 61 6d  ch-cmd      (lam
77b0: 62 64 61 20 28 29 0a 09 09 09 09 09 09 20 20 20  bda ().......   
77c0: 20 20 20 20 28 6c 61 75 6e 63 68 2d 74 65 73 74      (launch-test
77d0: 20 64 62 20 72 75 6e 2d 69 64 20 74 65 73 74 2d   db run-id test-
77e0: 63 6f 6e 66 20 6b 65 79 76 61 6c 6c 73 74 20 74  conf keyvallst t
77f0: 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 2d 70 61  est-name test-pa
7800: 74 68 20 69 74 65 6d 64 61 74 29 29 29 0a 09 09  th itemdat)))...
7810: 09 09 20 20 20 20 28 74 65 73 74 72 75 6e 64 61  ..    (testrunda
7820: 74 20 20 20 20 20 20 28 6c 69 73 74 20 67 65 74  t      (list get
7830: 2d 70 72 65 72 65 71 73 2d 63 6d 64 20 6c 61 75  -prereqs-cmd lau
7840: 6e 63 68 2d 63 6d 64 29 29 29 0a 09 09 09 20 20  nch-cmd)))....  
7850: 20 20 20 20 20 28 69 66 20 28 6f 72 20 28 61 72       (if (or (ar
7860: 67 73 3a 67 65 74 2d 61 72 67 20 22 2d 66 6f 72  gs:get-arg "-for
7870: 63 65 22 29 0a 09 09 09 09 20 20 20 20 20 20 20  ce").....       
7880: 28 6c 65 74 20 28 28 70 72 65 71 73 2d 6e 6f 74  (let ((preqs-not
7890: 2d 79 65 74 2d 6d 65 74 20 28 28 63 61 72 20 74  -yet-met ((car t
78a0: 65 73 74 72 75 6e 64 61 74 29 29 29 29 0a 09 09  estrundat))))...
78b0: 09 09 09 20 28 64 65 62 75 67 3a 70 72 69 6e 74  ... (debug:print
78c0: 20 32 20 22 50 72 65 71 72 65 71 75 65 73 69 74   2 "Preqrequesit
78d0: 65 73 20 66 6f 72 20 22 20 74 65 73 74 2d 6e 61  es for " test-na
78e0: 6d 65 20 22 3a 20 22 20 70 72 65 71 73 2d 6e 6f  me ": " preqs-no
78f0: 74 2d 79 65 74 2d 6d 65 74 29 0a 09 09 09 09 09  t-yet-met)......
7900: 20 28 6e 75 6c 6c 3f 20 70 72 65 71 73 2d 6e 6f   (null? preqs-no
7910: 74 2d 79 65 74 2d 6d 65 74 29 29 29 20 3b 3b 20  t-yet-met))) ;; 
7920: 61 72 65 20 74 68 65 72 65 20 61 6e 79 20 74 65  are there any te
7930: 73 74 73 20 74 68 61 74 20 6d 75 73 74 20 62 65  sts that must be
7940: 20 72 75 6e 20 62 65 66 6f 72 65 20 74 68 69 73   run before this
7950: 20 6f 6e 65 2e 2e 2e 0a 09 09 09 09 20 20 20 28   one........   (
7960: 69 66 20 28 6e 6f 74 20 28 28 63 61 64 72 20 74  if (not ((cadr t
7970: 65 73 74 72 75 6e 64 61 74 29 29 29 20 3b 3b 20  estrundat))) ;; 
7980: 74 68 69 73 20 69 73 20 74 68 65 20 6c 69 6e 65  this is the line
7990: 20 74 68 61 74 20 6c 61 75 6e 63 68 65 73 20 74   that launches t
79a0: 68 65 20 74 65 73 74 20 74 6f 20 74 68 65 20 72  he test to the r
79b0: 65 6d 6f 74 65 20 68 6f 73 74 0a 09 09 09 09 20  emote host..... 
79c0: 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09 09        (begin....
79d0: 09 09 20 28 70 72 69 6e 74 20 22 45 52 52 4f 52  .. (print "ERROR
79e0: 3a 20 46 61 69 6c 65 64 20 74 6f 20 6c 61 75 6e  : Failed to laun
79f0: 63 68 20 74 68 65 20 74 65 73 74 2e 20 45 78 69  ch the test. Exi
7a00: 74 69 6e 67 20 61 73 20 73 6f 6f 6e 20 61 73 20  ting as soon as 
7a10: 70 6f 73 73 69 62 6c 65 22 29 0a 09 09 09 09 09  possible")......
7a20: 20 28 73 65 74 21 20 2a 67 6c 6f 62 61 6c 65 78   (set! *globalex
7a30: 69 74 73 74 61 74 75 73 2a 20 31 29 20 3b 3b 20  itstatus* 1) ;; 
7a40: 0a 09 09 09 09 09 20 28 70 72 6f 63 65 73 73 2d  ...... (process-
7a50: 73 69 67 6e 61 6c 20 28 63 75 72 72 65 6e 74 2d  signal (current-
7a60: 70 72 6f 63 65 73 73 2d 69 64 29 20 73 69 67 6e  process-id) sign
7a70: 61 6c 2f 6b 69 6c 6c 29 0a 09 09 09 09 09 20 3b  al/kill)...... ;
7a80: 28 65 78 69 74 20 31 29 0a 09 09 09 09 09 20 29  (exit 1)...... )
7a90: 29 0a 09 09 09 09 20 20 20 28 69 66 20 28 6e 6f  ).....   (if (no
7aa0: 74 20 28 61 72 67 73 3a 67 65 74 2d 61 72 67 20  t (args:get-arg 
7ab0: 22 2d 6b 65 65 70 67 6f 69 6e 67 22 29 29 0a 09  "-keepgoing"))..
7ac0: 09 09 09 20 20 20 20 20 20 20 28 68 61 73 68 2d  ...       (hash-
7ad0: 74 61 62 6c 65 2d 73 65 74 21 20 2a 77 61 69 74  table-set! *wait
7ae0: 69 6e 67 2d 71 75 65 75 65 2a 20 6e 65 77 2d 74  ing-queue* new-t
7af0: 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 72 75 6e  est-name testrun
7b00: 64 61 74 29 29 29 29 29 29 29 0a 09 09 20 20 20  dat)))))))...   
7b10: 20 20 20 28 28 4b 49 4c 4c 45 44 29 20 0a 09 09     ((KILLED) ...
7b20: 20 20 20 20 20 20 20 28 64 65 62 75 67 3a 70 72         (debug:pr
7b30: 69 6e 74 20 31 20 22 4e 4f 54 45 3a 20 22 20 6e  int 1 "NOTE: " n
7b40: 65 77 2d 74 65 73 74 2d 6e 61 6d 65 20 22 20 69  ew-test-name " i
7b50: 73 20 61 6c 72 65 61 64 79 20 72 75 6e 6e 69 6e  s already runnin
7b60: 67 20 6f 72 20 77 61 73 20 65 78 70 6c 69 63 74  g or was explict
7b70: 6c 79 20 6b 69 6c 6c 65 64 2c 20 75 73 65 20 2d  ly killed, use -
7b80: 66 6f 72 63 65 20 74 6f 20 6c 61 75 6e 63 68 20  force to launch 
7b90: 69 74 2e 22 29 29 0a 09 09 20 20 20 20 20 20 28  it."))...      (
7ba0: 28 4c 41 55 4e 43 48 45 44 20 52 45 4d 4f 54 45  (LAUNCHED REMOTE
7bb0: 48 4f 53 54 53 54 41 52 54 20 52 55 4e 4e 49 4e  HOSTSTART RUNNIN
7bc0: 47 29 20 20 0a 09 09 20 20 20 20 20 20 20 28 69  G)  ...       (i
7bd0: 66 20 28 3e 20 28 2d 20 28 63 75 72 72 65 6e 74  f (> (- (current
7be0: 2d 73 65 63 6f 6e 64 73 29 28 2b 20 28 64 62 3a  -seconds)(+ (db:
7bf0: 74 65 73 74 2d 67 65 74 2d 65 76 65 6e 74 5f 74  test-get-event_t
7c00: 69 6d 65 20 74 65 73 74 64 61 74 29 0a 09 09 09  ime testdat)....
7c10: 09 09 09 20 20 20 20 20 28 64 62 3a 74 65 73 74  ...     (db:test
7c20: 2d 67 65 74 2d 72 75 6e 5f 64 75 72 61 74 69 6f  -get-run_duratio
7c30: 6e 20 74 65 73 74 64 61 74 29 29 29 0a 09 09 09  n testdat)))....
7c40: 20 20 20 20 20 20 31 30 30 29 20 3b 3b 20 69 2e        100) ;; i.
7c50: 65 2e 20 6e 6f 20 75 70 64 61 74 65 20 66 6f 72  e. no update for
7c60: 20 6d 6f 72 65 20 74 68 61 6e 20 31 30 30 20 73   more than 100 s
7c70: 65 63 6f 6e 64 73 0a 09 09 09 20 20 20 28 62 65  econds....   (be
7c80: 67 69 6e 0a 09 09 09 20 20 20 20 20 28 64 65 62  gin....     (deb
7c90: 75 67 3a 70 72 69 6e 74 20 30 20 22 57 41 52 4e  ug:print 0 "WARN
7ca0: 49 4e 47 3a 20 54 65 73 74 20 22 20 74 65 73 74  ING: Test " test
7cb0: 2d 6e 61 6d 65 20 22 20 61 70 70 65 61 72 73 20  -name " appears 
7cc0: 74 6f 20 62 65 20 64 65 61 64 2e 20 46 6f 72 63  to be dead. Forc
7cd0: 69 6e 67 20 69 74 20 74 6f 20 73 74 61 74 65 20  ing it to state 
7ce0: 49 4e 43 4f 4d 50 4c 45 54 45 20 61 6e 64 20 73  INCOMPLETE and s
7cf0: 74 61 74 75 73 20 53 54 55 43 4b 2f 44 45 41 44  tatus STUCK/DEAD
7d00: 22 29 0a 09 09 09 20 20 20 20 20 28 74 65 73 74  ")....     (test
7d10: 2d 73 65 74 2d 73 74 61 74 75 73 21 20 64 62 20  -set-status! db 
7d20: 72 75 6e 2d 69 64 20 74 65 73 74 2d 6e 61 6d 65  run-id test-name
7d30: 20 22 49 4e 43 4f 4d 50 4c 45 54 45 22 20 22 53   "INCOMPLETE" "S
7d40: 54 55 43 4b 2f 44 45 41 44 22 20 69 74 65 6d 64  TUCK/DEAD" itemd
7d50: 61 74 20 22 54 65 73 74 20 69 73 20 73 74 75 63  at "Test is stuc
7d60: 6b 20 6f 72 20 64 65 61 64 22 20 23 66 29 29 0a  k or dead" #f)).
7d70: 09 09 09 20 20 20 28 64 65 62 75 67 3a 70 72 69  ...   (debug:pri
7d80: 6e 74 20 32 20 22 4e 4f 54 45 3a 20 22 20 74 65  nt 2 "NOTE: " te
7d90: 73 74 2d 6e 61 6d 65 20 22 20 69 73 20 61 6c 72  st-name " is alr
7da0: 65 61 64 79 20 72 75 6e 6e 69 6e 67 22 29 29 29  eady running")))
7db0: 0a 09 09 20 20 20 20 20 20 28 65 6c 73 65 20 20  ...      (else  
7dc0: 20 20 20 20 20 28 64 65 62 75 67 3a 70 72 69 6e       (debug:prin
7dd0: 74 20 30 20 22 45 52 52 4f 52 3a 20 46 61 69 6c  t 0 "ERROR: Fail
7de0: 65 64 20 74 6f 20 6c 61 75 6e 63 68 20 74 65 73  ed to launch tes
7df0: 74 20 22 20 6e 65 77 2d 74 65 73 74 2d 6e 61 6d  t " new-test-nam
7e00: 65 20 22 2e 20 55 6e 72 65 63 6f 67 6e 69 73 65  e ". Unrecognise
7e10: 64 20 73 74 61 74 65 20 22 20 28 74 65 73 74 3a  d state " (test:
7e20: 67 65 74 2d 73 74 61 74 65 20 74 65 73 74 64 61  get-state testda
7e30: 74 29 29 29 29 29 29 0a 09 20 20 20 20 20 20 28  t))))))..      (
7e40: 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74  if (not (null? t
7e50: 61 6c 29 29 0a 09 09 20 20 28 6c 6f 6f 70 20 28  al))...  (loop (
7e60: 63 61 72 20 74 61 6c 29 28 63 64 72 20 74 61 6c  car tal)(cdr tal
7e70: 29 29 29 29 29 29 29 29 29 0a 0a 28 64 65 66 69  )))))))))..(defi
7e80: 6e 65 20 28 72 75 6e 2d 77 61 69 74 69 6e 67 2d  ne (run-waiting-
7e90: 74 65 73 74 73 20 64 62 29 0a 20 20 28 6c 65 74  tests db).  (let
7ea0: 20 28 28 6e 75 6d 74 72 69 65 73 20 20 20 20 20   ((numtries     
7eb0: 20 20 20 20 20 20 30 29 0a 09 28 6c 61 73 74 2d        0)..(last-
7ec0: 74 72 79 2d 74 69 6d 65 20 20 20 20 20 20 28 63  try-time      (c
7ed0: 75 72 72 65 6e 74 2d 73 65 63 6f 6e 64 73 29 29  urrent-seconds))
7ee0: 0a 09 28 74 69 6d 65 73 20 20 20 20 20 20 20 20  ..(times        
7ef0: 20 20 20 20 20 20 28 6c 69 73 74 20 31 29 29 29        (list 1)))
7f00: 20 3b 3b 20 6d 69 6e 75 74 65 73 20 74 6f 20 77   ;; minutes to w
7f10: 61 69 74 20 62 65 66 6f 72 65 20 74 72 79 69 6e  ait before tryin
7f20: 67 20 61 67 61 69 6e 20 74 6f 20 6b 69 63 6b 20  g again to kick 
7f30: 6f 66 66 20 72 75 6e 73 0a 20 20 20 20 3b 3b 20  off runs.    ;; 
7f40: 42 55 47 20 74 68 69 73 20 68 61 63 6b 20 6f 66  BUG this hack of
7f50: 20 62 72 75 74 65 20 66 6f 72 63 65 20 72 65 74   brute force ret
7f60: 72 79 69 6e 67 20 77 6f 72 6b 73 20 71 75 69 74  rying works quit
7f70: 65 20 77 65 6c 6c 20 66 6f 72 20 6d 61 6e 79 20  e well for many 
7f80: 63 61 73 65 73 20 62 75 74 20 0a 20 20 20 20 3b  cases but .    ;
7f90: 3b 20 20 20 20 20 77 68 61 74 20 69 73 20 6e 65  ;     what is ne
7fa0: 65 64 65 64 20 69 73 20 74 6f 20 63 68 65 63 6b  eded is to check
7fb0: 20 74 68 65 20 64 62 20 66 6f 72 20 74 65 73 74   the db for test
7fc0: 73 20 74 68 61 74 20 68 61 76 65 20 66 61 69 6c  s that have fail
7fd0: 65 64 20 6c 65 73 73 20 74 68 61 6e 0a 20 20 20  ed less than.   
7fe0: 20 3b 3b 20 20 20 20 20 4e 20 74 69 6d 65 73 20   ;;     N times 
7ff0: 6f 72 20 6e 65 76 65 72 20 62 65 65 6e 20 73 74  or never been st
8000: 61 72 74 65 64 20 61 6e 64 20 6b 69 63 6b 20 74  arted and kick t
8010: 68 65 6d 20 6f 66 66 20 61 67 61 69 6e 0a 20 20  hem off again.  
8020: 20 20 28 6c 65 74 20 6c 6f 6f 70 20 28 28 77 61    (let loop ((wa
8030: 69 74 69 6e 67 2d 74 65 73 74 2d 6e 61 6d 65 73  iting-test-names
8040: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 6b 65 79   (hash-table-key
8050: 73 20 2a 77 61 69 74 69 6e 67 2d 71 75 65 75 65  s *waiting-queue
8060: 2a 29 29 29 0a 20 20 20 20 20 20 28 63 6f 6e 64  *))).      (cond
8070: 0a 20 20 20 20 20 20 20 28 28 6e 6f 74 20 28 72  .       ((not (r
8080: 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d 6d 6f 72 65  uns:can-run-more
8090: 2d 74 65 73 74 73 20 64 62 29 29 0a 09 28 73 6c  -tests db))..(sl
80a0: 65 65 70 20 32 29 0a 09 28 6c 6f 6f 70 20 77 61  eep 2)..(loop wa
80b0: 69 74 69 6e 67 2d 74 65 73 74 2d 6e 61 6d 65 73  iting-test-names
80c0: 29 29 0a 20 20 20 20 20 20 20 28 28 6e 75 6c 6c  )).       ((null
80d0: 3f 20 77 61 69 74 69 6e 67 2d 74 65 73 74 2d 6e  ? waiting-test-n
80e0: 61 6d 65 73 29 0a 09 28 64 65 62 75 67 3a 70 72  ames)..(debug:pr
80f0: 69 6e 74 20 31 20 22 41 6c 6c 20 74 65 73 74 73  int 1 "All tests
8100: 20 6c 61 75 6e 63 68 65 64 22 29 29 0a 20 20 20   launched")).   
8110: 20 20 20 20 28 65 6c 73 65 0a 09 28 73 65 74 21      (else..(set!
8120: 20 6e 75 6d 74 72 69 65 73 20 28 2b 20 6e 75 6d   numtries (+ num
8130: 74 72 69 65 73 20 31 29 29 0a 09 28 66 6f 72 2d  tries 1))..(for-
8140: 65 61 63 68 20 28 6c 61 6d 62 64 61 20 28 74 65  each (lambda (te
8150: 73 74 6e 61 6d 65 29 0a 09 09 20 20 20 20 28 69  stname)...    (i
8160: 66 20 28 72 75 6e 73 3a 63 61 6e 2d 72 75 6e 2d  f (runs:can-run-
8170: 6d 6f 72 65 2d 74 65 73 74 73 20 64 62 29 0a 09  more-tests db)..
8180: 09 09 28 6c 65 74 2a 20 28 28 74 65 73 74 64 61  ..(let* ((testda
8190: 74 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 72 65  t (hash-table-re
81a0: 66 20 2a 77 61 69 74 69 6e 67 2d 71 75 65 75 65  f *waiting-queue
81b0: 2a 20 74 65 73 74 6e 61 6d 65 29 29 0a 09 09 09  * testname))....
81c0: 20 20 20 20 20 20 20 28 70 72 65 72 65 71 73 20         (prereqs 
81d0: 28 28 63 61 72 20 74 65 73 74 64 61 74 29 29 29  ((car testdat)))
81e0: 0a 09 09 09 20 20 20 20 20 20 20 28 6c 64 62 20  ....       (ldb 
81f0: 20 20 20 20 28 69 66 20 64 62 20 64 62 20 28 6f      (if db db (o
8200: 70 65 6e 2d 64 62 29 29 29 29 0a 09 09 09 20 20  pen-db))))....  
8210: 28 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22  (debug:print 2 "
8220: 70 72 65 72 65 71 73 20 72 65 6d 61 69 6e 69 6e  prereqs remainin
8230: 67 3a 20 22 20 70 72 65 72 65 71 73 29 0a 09 09  g: " prereqs)...
8240: 09 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 70 72  .  (if (null? pr
8250: 65 72 65 71 73 29 0a 09 09 09 20 20 20 20 20 20  ereqs)....      
8260: 28 62 65 67 69 6e 0a 09 09 09 09 28 64 65 62 75  (begin.....(debu
8270: 67 3a 70 72 69 6e 74 20 32 20 22 50 72 65 72 65  g:print 2 "Prere
8280: 71 75 69 73 69 74 65 73 20 6d 65 74 2c 20 6c 61  quisites met, la
8290: 75 6e 63 68 69 6e 67 20 22 20 74 65 73 74 6e 61  unching " testna
82a0: 6d 65 29 0a 09 09 09 09 28 28 63 61 64 72 20 74  me).....((cadr t
82b0: 65 73 74 64 61 74 29 29 0a 09 09 09 09 28 68 61  estdat)).....(ha
82c0: 73 68 2d 74 61 62 6c 65 2d 64 65 6c 65 74 65 21  sh-table-delete!
82d0: 20 2a 77 61 69 74 69 6e 67 2d 71 75 65 75 65 2a   *waiting-queue*
82e0: 20 74 65 73 74 6e 61 6d 65 29 29 29 0a 09 09 09   testname)))....
82f0: 20 20 28 69 66 20 28 6e 6f 74 20 64 62 29 0a 09    (if (not db)..
8300: 09 09 20 20 20 20 20 20 28 73 71 6c 69 74 65 33  ..      (sqlite3
8310: 3a 66 69 6e 61 6c 69 7a 65 21 20 6c 64 62 29 29  :finalize! ldb))
8320: 29 29 29 0a 09 09 20 20 77 61 69 74 69 6e 67 2d  )))...  waiting-
8330: 74 65 73 74 2d 6e 61 6d 65 73 29 0a 09 3b 3b 20  test-names)..;; 
8340: 28 73 6c 65 65 70 20 31 30 29 20 3b 3b 20 6e 6f  (sleep 10) ;; no
8350: 20 70 6f 69 6e 74 20 69 6e 20 72 75 73 68 69 6e   point in rushin
8360: 67 20 74 68 69 6e 67 73 20 61 74 20 74 68 69 73  g things at this
8370: 20 73 74 61 67 65 3f 0a 09 28 6c 6f 6f 70 20 28   stage?..(loop (
8380: 68 61 73 68 2d 74 61 62 6c 65 2d 6b 65 79 73 20  hash-table-keys 
8390: 2a 77 61 69 74 69 6e 67 2d 71 75 65 75 65 2a 29  *waiting-queue*)
83a0: 29 29 29 29 29 29 0a 0a 28 64 65 66 69 6e 65 20  ))))))..(define 
83b0: 28 67 65 74 2d 64 69 72 2d 75 70 2d 6e 20 64 69  (get-dir-up-n di
83c0: 72 20 2e 20 70 61 72 61 6d 73 29 20 0a 20 20 28  r . params) .  (
83d0: 6c 65 74 20 28 28 64 70 61 72 74 73 20 20 28 73  let ((dparts  (s
83e0: 74 72 69 6e 67 2d 73 70 6c 69 74 20 64 69 72 20  tring-split dir 
83f0: 22 2f 22 29 29 0a 09 28 63 6f 75 6e 74 20 20 20  "/"))..(count   
8400: 28 69 66 20 28 6e 75 6c 6c 3f 20 70 61 72 61 6d  (if (null? param
8410: 73 29 20 31 20 28 63 61 72 20 70 61 72 61 6d 73  s) 1 (car params
8420: 29 29 29 29 0a 20 20 20 20 28 63 6f 6e 63 20 22  )))).    (conc "
8430: 2f 22 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72  /" (string-inter
8440: 73 70 65 72 73 65 20 0a 09 20 20 20 20 20 20 20  sperse ..       
8450: 28 74 61 6b 65 20 64 70 61 72 74 73 20 28 2d 20  (take dparts (- 
8460: 28 6c 65 6e 67 74 68 20 64 70 61 72 74 73 29 20  (length dparts) 
8470: 63 6f 75 6e 74 29 29 0a 09 20 20 20 20 20 20 20  count))..       
8480: 22 2f 22 29 29 29 29 0a 3b 3b 20 52 65 6d 6f 76  "/")))).;; Remov
8490: 65 20 72 75 6e 73 0a 3b 3b 20 66 69 65 6c 64 73  e runs.;; fields
84a0: 20 61 72 65 20 70 61 73 73 69 6e 67 20 69 6e 20   are passing in 
84b0: 74 68 72 6f 75 67 68 20 0a 28 64 65 66 69 6e 65  through .(define
84c0: 20 28 72 75 6e 73 3a 72 65 6d 6f 76 65 2d 72 75   (runs:remove-ru
84d0: 6e 73 20 64 62 20 72 75 6e 6e 61 6d 65 70 61 74  ns db runnamepat
84e0: 74 20 74 65 73 74 70 61 74 74 20 69 74 65 6d 70  t testpatt itemp
84f0: 61 74 74 29 0a 20 20 28 6c 65 74 2a 20 28 28 6b  att).  (let* ((k
8500: 65 79 73 20 20 20 20 20 20 20 20 28 64 62 2d 67  eys        (db-g
8510: 65 74 2d 6b 65 79 73 20 64 62 29 29 0a 09 20 28  et-keys db)).. (
8520: 72 75 6e 64 61 74 20 20 20 20 20 20 28 72 75 6e  rundat      (run
8530: 73 3a 67 65 74 2d 72 75 6e 73 2d 62 79 2d 70 61  s:get-runs-by-pa
8540: 74 74 20 64 62 20 6b 65 79 73 20 72 75 6e 6e 61  tt db keys runna
8550: 6d 65 70 61 74 74 29 29 0a 09 20 28 68 65 61 64  mepatt)).. (head
8560: 65 72 20 20 20 20 20 20 28 76 65 63 74 6f 72 2d  er      (vector-
8570: 72 65 66 20 72 75 6e 64 61 74 20 30 29 29 0a 09  ref rundat 0))..
8580: 20 28 72 75 6e 73 20 20 20 20 20 20 20 20 28 76   (runs        (v
8590: 65 63 74 6f 72 2d 72 65 66 20 72 75 6e 64 61 74  ector-ref rundat
85a0: 20 31 29 29 29 0a 20 20 20 20 28 64 65 62 75 67   1))).    (debug
85b0: 3a 70 72 69 6e 74 20 31 20 22 48 65 61 64 65 72  :print 1 "Header
85c0: 3a 20 22 20 68 65 61 64 65 72 29 0a 20 20 20 20  : " header).    
85d0: 28 66 6f 72 2d 65 61 63 68 0a 20 20 20 20 20 28  (for-each.     (
85e0: 6c 61 6d 62 64 61 20 28 72 75 6e 29 0a 20 20 20  lambda (run).   
85f0: 20 20 20 20 28 6c 65 74 20 28 28 72 75 6e 6b 65      (let ((runke
8600: 79 20 28 73 74 72 69 6e 67 2d 69 6e 74 65 72 73  y (string-inters
8610: 70 65 72 73 65 20 28 6d 61 70 20 28 6c 61 6d 62  perse (map (lamb
8620: 64 61 20 28 6b 29 0a 09 09 09 09 09 09 28 64 62  da (k).......(db
8630: 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65  :get-value-by-he
8640: 61 64 65 72 20 72 75 6e 20 68 65 61 64 65 72 20  ader run header 
8650: 28 76 65 63 74 6f 72 2d 72 65 66 20 6b 20 30 29  (vector-ref k 0)
8660: 29 29 20 6b 65 79 73 29 20 22 2f 22 29 29 0a 09  )) keys) "/"))..
8670: 20 20 20 20 20 28 64 69 72 73 2d 74 6f 2d 72 65       (dirs-to-re
8680: 6d 6f 76 65 20 28 6d 61 6b 65 2d 68 61 73 68 2d  move (make-hash-
8690: 74 61 62 6c 65 29 29 29 0a 09 20 28 6c 65 74 2a  table))).. (let*
86a0: 20 28 28 72 75 6e 2d 69 64 20 28 64 62 3a 67 65   ((run-id (db:ge
86b0: 74 2d 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65  t-value-by-heade
86c0: 72 20 72 75 6e 20 68 65 61 64 65 72 20 22 69 64  r run header "id
86d0: 22 29 20 29 0a 09 09 28 74 65 73 74 73 20 20 28  ") )...(tests  (
86e0: 64 62 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f 72  db-get-tests-for
86f0: 2d 72 75 6e 20 64 62 20 28 64 62 3a 67 65 74 2d  -run db (db:get-
8700: 76 61 6c 75 65 2d 62 79 2d 68 65 61 64 65 72 20  value-by-header 
8710: 72 75 6e 20 68 65 61 64 65 72 20 22 69 64 22 29  run header "id")
8720: 20 74 65 73 74 70 61 74 74 20 69 74 65 6d 70 61   testpatt itempa
8730: 74 74 29 29 0a 09 09 28 6c 61 73 74 74 70 61 74  tt))...(lasttpat
8740: 68 20 22 2f 64 6f 65 73 2f 6e 6f 74 2f 65 78 69  h "/does/not/exi
8750: 73 74 2f 49 2f 68 6f 70 65 22 29 29 0a 0a 09 20  st/I/hope"))... 
8760: 20 20 28 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c    (if (not (null
8770: 3f 20 74 65 73 74 73 29 29 0a 09 20 20 20 20 20  ? tests))..     
8780: 20 20 28 62 65 67 69 6e 0a 09 09 20 28 64 65 62    (begin... (deb
8790: 75 67 3a 70 72 69 6e 74 20 31 20 22 52 65 6d 6f  ug:print 1 "Remo
87a0: 76 69 6e 67 20 74 65 73 74 73 20 66 6f 72 20 72  ving tests for r
87b0: 75 6e 3a 20 22 20 72 75 6e 6b 65 79 20 22 20 22  un: " runkey " "
87c0: 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62   (db:get-value-b
87d0: 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61  y-header run hea
87e0: 64 65 72 20 22 72 75 6e 6e 61 6d 65 22 29 29 0a  der "runname")).
87f0: 09 09 20 28 66 6f 72 2d 65 61 63 68 0a 09 09 20  .. (for-each... 
8800: 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74 29 0a   (lambda (test).
8810: 09 09 20 20 20 20 28 6c 65 74 2a 20 28 28 69 74  ..    (let* ((it
8820: 65 6d 2d 70 61 74 68 20 28 64 62 3a 74 65 73 74  em-path (db:test
8830: 2d 67 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74  -get-item-path t
8840: 65 73 74 29 29 0a 09 09 09 20 20 20 28 74 65 73  est))....   (tes
8850: 74 2d 6e 61 6d 65 20 28 64 62 3a 74 65 73 74 2d  t-name (db:test-
8860: 67 65 74 2d 74 65 73 74 6e 61 6d 65 20 74 65 73  get-testname tes
8870: 74 29 29 0a 09 09 09 20 20 20 28 72 75 6e 2d 64  t))....   (run-d
8880: 69 72 20 20 20 28 64 62 3a 74 65 73 74 2d 67 65  ir   (db:test-ge
8890: 74 2d 72 75 6e 64 69 72 20 74 65 73 74 29 29 29  t-rundir test)))
88a0: 0a 09 09 20 20 20 20 20 20 28 64 65 62 75 67 3a  ...      (debug:
88b0: 70 72 69 6e 74 20 31 20 22 20 20 22 20 28 64 62  print 1 "  " (db
88c0: 3a 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61  :test-get-testna
88d0: 6d 65 20 74 65 73 74 29 20 22 20 69 64 3a 20 22  me test) " id: "
88e0: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64   (db:test-get-id
88f0: 20 74 65 73 74 29 20 22 20 22 20 69 74 65 6d 2d   test) " " item-
8900: 70 61 74 68 29 0a 09 09 20 20 20 20 20 20 28 64  path)...      (d
8910: 62 3a 64 65 6c 65 74 65 2d 74 65 73 74 2d 72 65  b:delete-test-re
8920: 63 6f 72 64 73 20 64 62 20 28 64 62 3a 74 65 73  cords db (db:tes
8930: 74 2d 67 65 74 2d 69 64 20 74 65 73 74 29 29 0a  t-get-id test)).
8940: 09 09 20 20 20 20 20 20 28 69 66 20 28 3e 20 28  ..      (if (> (
8950: 73 74 72 69 6e 67 2d 6c 65 6e 67 74 68 20 72 75  string-length ru
8960: 6e 2d 64 69 72 29 20 35 29 20 3b 3b 20 62 61 64  n-dir) 5) ;; bad
8970: 20 68 65 75 72 69 73 74 69 63 20 62 75 74 20 73   heuristic but s
8980: 68 6f 75 6c 64 20 70 72 65 76 65 6e 74 20 2f 74  hould prevent /t
8990: 6d 70 20 2f 68 6f 6d 65 20 65 74 63 2e 0a 09 09  mp /home etc....
89a0: 09 20 20 28 6c 65 74 20 28 28 66 75 6c 6c 70 61  .  (let ((fullpa
89b0: 74 68 20 72 75 6e 2d 64 69 72 29 29 20 3b 3b 20  th run-dir)) ;; 
89c0: 22 2f 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74  "/" (db:test-get
89d0: 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73 74 29  -item-path test)
89e0: 29 29 29 0a 09 09 09 20 20 20 20 28 73 65 74 21  )))....    (set!
89f0: 20 6c 61 73 74 74 70 61 74 68 20 66 75 6c 6c 70   lasttpath fullp
8a00: 61 74 68 29 0a 09 09 09 20 20 20 20 28 68 61 73  ath)....    (has
8a10: 68 2d 74 61 62 6c 65 2d 73 65 74 21 20 64 69 72  h-table-set! dir
8a20: 73 2d 74 6f 2d 72 65 6d 6f 76 65 20 66 75 6c 6c  s-to-remove full
8a30: 70 61 74 68 20 23 74 29 0a 09 09 09 20 20 20 20  path #t)....    
8a40: 3b 3b 20 54 68 65 20 66 6f 6c 6c 6f 77 69 6e 67  ;; The following
8a50: 20 77 61 73 20 74 68 65 20 73 61 66 65 20 64 65   was the safe de
8a60: 6c 65 74 65 20 63 6f 64 65 20 62 75 74 20 69 74  lete code but it
8a70: 20 77 61 73 20 6e 6f 74 20 62 65 69 6e 67 20 65   was not being e
8a80: 78 65 63 74 75 74 65 64 2e 0a 09 09 09 20 20 20  xectuted.....   
8a90: 20 3b 3b 20 28 6c 65 74 2a 20 28 28 64 69 72 73   ;; (let* ((dirs
8aa0: 2d 63 6f 75 6e 74 20 28 2b 20 31 20 28 6c 65 6e  -count (+ 1 (len
8ab0: 67 74 68 20 6b 65 79 73 29 28 6c 65 6e 67 74 68  gth keys)(length
8ac0: 20 28 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 69   (string-split i
8ad0: 74 65 6d 2d 70 61 74 68 20 22 2f 22 29 29 29 29  tem-path "/"))))
8ae0: 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20 20  ....    ;;      
8af0: 20 20 28 64 69 72 2d 74 6f 2d 72 65 6d 20 28 67    (dir-to-rem (g
8b00: 65 74 2d 64 69 72 2d 75 70 2d 6e 20 66 75 6c 6c  et-dir-up-n full
8b10: 70 61 74 68 20 64 69 72 73 2d 63 6f 75 6e 74 29  path dirs-count)
8b20: 29 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20  )....    ;;     
8b30: 20 20 20 28 72 65 6d 61 69 6e 69 6e 67 64 20 28     (remainingd (
8b40: 73 74 72 69 6e 67 2d 73 75 62 73 74 69 74 75 74  string-substitut
8b50: 65 20 28 72 65 67 65 78 70 20 28 63 6f 6e 63 20  e (regexp (conc 
8b60: 22 5e 22 20 64 69 72 2d 74 6f 2d 72 65 6d 20 22  "^" dir-to-rem "
8b70: 2f 22 29 29 20 22 22 20 66 75 6c 6c 70 61 74 68  /")) "" fullpath
8b80: 29 29 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 20  ))....    ;;    
8b90: 20 20 20 20 28 63 6d 64 20 28 63 6f 6e 63 20 22      (cmd (conc "
8ba0: 63 64 20 22 20 64 69 72 2d 74 6f 2d 72 65 6d 20  cd " dir-to-rem 
8bb0: 22 3b 20 72 6d 64 69 72 20 2d 70 20 22 20 72 65  "; rmdir -p " re
8bc0: 6d 61 69 6e 69 6e 67 64 20 29 29 29 0a 09 09 09  mainingd )))....
8bd0: 20 20 20 20 3b 3b 20 20 20 28 69 66 20 28 66 69      ;;   (if (fi
8be0: 6c 65 2d 65 78 69 73 74 73 3f 20 66 75 6c 6c 70  le-exists? fullp
8bf0: 61 74 68 29 0a 09 09 09 20 20 20 20 3b 3b 20 20  ath)....    ;;  
8c00: 20 20 20 20 20 28 62 65 67 69 6e 0a 09 09 09 20       (begin.... 
8c10: 20 20 20 3b 3b 20 20 20 20 20 20 20 20 20 28 64     ;;         (d
8c20: 65 62 75 67 3a 70 72 69 6e 74 20 31 20 63 6d 64  ebug:print 1 cmd
8c30: 29 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 20 20  )....    ;;     
8c40: 20 20 20 20 28 73 79 73 74 65 6d 20 63 6d 64 29      (system cmd)
8c50: 29 29 0a 09 09 09 20 20 20 20 3b 3b 20 20 20 29  ))....    ;;   )
8c60: 29 0a 09 09 09 20 20 20 20 29 29 29 29 0a 09 09  )....    ))))...
8c70: 20 20 20 20 74 65 73 74 73 29 29 29 0a 0a 09 20      tests)))... 
8c80: 20 20 3b 3b 20 6c 6f 6f 6b 20 74 68 6f 75 67 68    ;; look though
8c90: 20 74 68 65 20 64 69 72 73 2d 74 6f 2d 72 65 6d   the dirs-to-rem
8ca0: 6f 76 65 20 66 6f 72 20 63 61 6e 64 69 64 61 74  ove for candidat
8cb0: 65 73 20 66 6f 72 20 72 65 6d 6f 76 61 6c 2e 20  es for removal. 
8cc0: 44 6f 20 74 68 69 73 20 61 66 74 65 72 20 64 65  Do this after de
8cd0: 6c 65 74 69 6e 67 20 74 68 65 20 72 65 63 6f 72  leting the recor
8ce0: 64 73 0a 09 20 20 20 3b 3b 20 66 6f 72 20 65 61  ds..   ;; for ea
8cf0: 63 68 20 74 65 73 74 20 69 6e 20 63 61 73 65 20  ch test in case 
8d00: 77 65 20 67 65 74 20 6b 69 6c 6c 65 64 2e 20 54  we get killed. T
8d10: 68 61 74 20 73 68 6f 75 6c 64 20 6d 69 6e 69 6d  hat should minim
8d20: 69 7a 65 20 74 68 65 20 64 65 74 72 69 74 75 73  ize the detritus
8d30: 20 6c 65 66 74 20 6f 6e 20 64 69 73 6b 0a 09 20   left on disk.. 
8d40: 20 20 3b 3b 20 70 72 6f 63 65 73 73 20 74 68 65    ;; process the
8d50: 20 64 69 72 73 20 66 72 6f 6d 20 6c 6f 6e 67 65   dirs from longe
8d60: 73 74 20 73 74 72 69 6e 67 20 6c 65 6e 67 74 68  st string length
8d70: 20 74 6f 20 73 68 6f 72 74 65 73 74 0a 09 20 20   to shortest..  
8d80: 20 28 66 6f 72 2d 65 61 63 68 20 0a 09 20 20 20   (for-each ..   
8d90: 20 28 6c 61 6d 62 64 61 20 28 64 69 72 2d 74 6f   (lambda (dir-to
8da0: 2d 72 65 6d 6f 76 65 29 0a 09 20 20 20 20 20 20  -remove)..      
8db0: 28 69 66 20 28 66 69 6c 65 2d 65 78 69 73 74 73  (if (file-exists
8dc0: 3f 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29  ? dir-to-remove)
8dd0: 0a 09 09 20 20 28 6c 65 74 20 28 28 64 69 72 2d  ...  (let ((dir-
8de0: 69 6e 2d 64 62 20 27 28 29 29 29 0a 09 09 20 20  in-db '()))...  
8df0: 20 20 28 73 71 6c 69 74 65 33 3a 66 6f 72 2d 65    (sqlite3:for-e
8e00: 61 63 68 2d 72 6f 77 0a 09 09 20 20 20 20 20 28  ach-row...     (
8e10: 6c 61 6d 62 64 61 20 28 64 69 72 29 0a 09 09 20  lambda (dir)... 
8e20: 20 20 20 20 20 20 28 73 65 74 21 20 64 69 72 2d        (set! dir-
8e30: 69 6e 2d 64 62 20 28 63 6f 6e 73 20 64 69 72 20  in-db (cons dir 
8e40: 64 69 72 2d 69 6e 2d 64 62 29 29 29 0a 09 09 20  dir-in-db)))... 
8e50: 20 20 20 20 64 62 20 22 53 45 4c 45 43 54 20 72      db "SELECT r
8e60: 75 6e 64 69 72 20 46 52 4f 4d 20 74 65 73 74 73  undir FROM tests
8e70: 20 57 48 45 52 45 20 72 75 6e 64 69 72 20 4c 49   WHERE rundir LI
8e80: 4b 45 20 3f 3b 22 20 0a 09 09 20 20 20 20 20 28  KE ?;" ...     (
8e90: 63 6f 6e 63 20 22 25 22 20 64 69 72 2d 74 6f 2d  conc "%" dir-to-
8ea0: 72 65 6d 6f 76 65 20 22 25 22 29 29 20 3b 3b 20  remove "%")) ;; 
8eb0: 79 65 73 2c 20 49 27 6d 20 67 6f 69 6e 67 20 74  yes, I'm going t
8ec0: 6f 20 62 61 69 6c 20 69 66 20 74 68 65 72 65 20  o bail if there 
8ed0: 69 73 20 61 6e 79 74 68 69 6e 67 20 6c 69 6b 65  is anything like
8ee0: 20 74 68 69 73 20 64 69 72 20 69 6e 20 74 68 65   this dir in the
8ef0: 20 64 62 0a 09 09 20 20 20 20 28 69 66 20 28 6e   db...    (if (n
8f00: 75 6c 6c 3f 20 64 69 72 2d 69 6e 2d 64 62 29 0a  ull? dir-in-db).
8f10: 09 09 09 28 62 65 67 69 6e 0a 09 09 09 20 20 28  ...(begin....  (
8f20: 64 65 62 75 67 3a 70 72 69 6e 74 20 32 20 22 52  debug:print 2 "R
8f30: 65 6d 6f 76 69 6e 67 20 64 69 72 65 63 74 6f 72  emoving director
8f40: 79 20 77 69 74 68 20 7a 65 72 6f 20 64 62 20 72  y with zero db r
8f50: 65 66 65 72 65 6e 63 65 73 3a 20 22 20 64 69 72  eferences: " dir
8f60: 2d 74 6f 2d 72 65 6d 6f 76 65 29 0a 09 09 09 20  -to-remove).... 
8f70: 20 28 73 79 73 74 65 6d 20 28 63 6f 6e 63 20 22   (system (conc "
8f80: 72 6d 20 2d 72 66 20 22 20 64 69 72 2d 74 6f 2d  rm -rf " dir-to-
8f90: 72 65 6d 6f 76 65 29 29 0a 09 09 09 20 20 28 68  remove))....  (h
8fa0: 61 73 68 2d 74 61 62 6c 65 2d 64 65 6c 65 74 65  ash-table-delete
8fb0: 21 20 64 69 72 73 2d 74 6f 2d 72 65 6d 6f 76 65  ! dirs-to-remove
8fc0: 20 64 69 72 2d 74 6f 2d 72 65 6d 6f 76 65 29 29   dir-to-remove))
8fd0: 0a 09 09 09 28 64 65 62 75 67 3a 70 72 69 6e 74  ....(debug:print
8fe0: 20 32 20 22 53 6b 69 70 70 69 6e 67 20 72 65 6d   2 "Skipping rem
8ff0: 6f 76 61 6c 20 6f 66 20 22 20 64 69 72 2d 74 6f  oval of " dir-to
9000: 2d 72 65 6d 6f 76 65 20 22 20 66 6f 72 20 6e 6f  -remove " for no
9010: 77 20 61 73 20 69 74 20 73 74 69 6c 6c 20 68 61  w as it still ha
9020: 73 20 72 65 66 65 72 65 6e 63 65 73 20 69 6e 20  s references in 
9030: 74 68 65 20 64 61 74 61 62 61 73 65 22 29 29 29  the database")))
9040: 29 29 0a 09 20 20 20 20 28 73 6f 72 74 20 28 68  ))..    (sort (h
9050: 61 73 68 2d 74 61 62 6c 65 2d 6b 65 79 73 20 64  ash-table-keys d
9060: 69 72 73 2d 74 6f 2d 72 65 6d 6f 76 65 29 20 28  irs-to-remove) (
9070: 6c 61 6d 62 64 61 20 28 61 20 62 29 28 3e 20 28  lambda (a b)(> (
9080: 73 74 72 69 6e 67 2d 6c 65 6e 67 74 68 20 61 29  string-length a)
9090: 28 73 74 72 69 6e 67 2d 6c 65 6e 67 74 68 20 62  (string-length b
90a0: 29 29 29 29 29 0a 0a 09 20 20 20 3b 3b 20 72 65  )))))...   ;; re
90b0: 6d 6f 76 65 20 74 68 65 20 72 75 6e 20 69 66 20  move the run if 
90c0: 7a 65 72 6f 20 74 65 73 74 73 20 72 65 6d 61 69  zero tests remai
90d0: 6e 0a 09 20 20 20 28 6c 65 74 20 28 28 72 65 6d  n..   (let ((rem
90e0: 74 65 73 74 73 20 28 64 62 2d 67 65 74 2d 74 65  tests (db-get-te
90f0: 73 74 73 2d 66 6f 72 2d 72 75 6e 20 64 62 20 28  sts-for-run db (
9100: 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62 79 2d  db:get-value-by-
9110: 68 65 61 64 65 72 20 72 75 6e 20 68 65 61 64 65  header run heade
9120: 72 20 22 69 64 22 29 20 23 66 20 23 66 29 29 29  r "id") #f #f)))
9130: 0a 09 20 20 20 20 20 28 69 66 20 28 6e 75 6c 6c  ..     (if (null
9140: 3f 20 72 65 6d 74 65 73 74 73 29 20 3b 3b 20 6e  ? remtests) ;; n
9150: 6f 20 6d 6f 72 65 20 74 65 73 74 73 20 72 65 6d  o more tests rem
9160: 61 69 6e 69 6e 67 0a 09 09 20 28 6c 65 74 2a 20  aining... (let* 
9170: 28 28 64 70 61 72 74 73 20 20 28 73 74 72 69 6e  ((dparts  (strin
9180: 67 2d 73 70 6c 69 74 20 6c 61 73 74 74 70 61 74  g-split lasttpat
9190: 68 20 22 2f 22 29 29 0a 09 09 09 28 72 75 6e 70  h "/"))....(runp
91a0: 61 74 68 20 28 63 6f 6e 63 20 22 2f 22 20 28 73  ath (conc "/" (s
91b0: 74 72 69 6e 67 2d 69 6e 74 65 72 73 70 65 72 73  tring-interspers
91c0: 65 20 0a 09 09 09 09 09 20 20 20 20 28 74 61 6b  e ......    (tak
91d0: 65 20 64 70 61 72 74 73 20 28 2d 20 28 6c 65 6e  e dparts (- (len
91e0: 67 74 68 20 64 70 61 72 74 73 29 20 31 29 29 0a  gth dparts) 1)).
91f0: 09 09 09 09 09 20 20 20 20 22 2f 22 29 29 29 29  .....    "/"))))
9200: 0a 09 09 20 20 20 28 64 65 62 75 67 3a 70 72 69  ...   (debug:pri
9210: 6e 74 20 31 20 22 52 65 6d 6f 76 69 6e 67 20 72  nt 1 "Removing r
9220: 75 6e 3a 20 22 20 72 75 6e 6b 65 79 20 22 20 22  un: " runkey " "
9230: 20 28 64 62 3a 67 65 74 2d 76 61 6c 75 65 2d 62   (db:get-value-b
9240: 79 2d 68 65 61 64 65 72 20 72 75 6e 20 68 65 61  y-header run hea
9250: 64 65 72 20 22 72 75 6e 6e 61 6d 65 22 29 29 0a  der "runname")).
9260: 09 09 20 20 20 28 64 62 3a 64 65 6c 65 74 65 2d  ..   (db:delete-
9270: 72 75 6e 20 64 62 20 72 75 6e 2d 69 64 29 0a 09  run db run-id)..
9280: 09 20 20 20 3b 3b 20 6e 65 65 64 20 74 6f 20 66  .   ;; need to f
9290: 69 67 75 72 65 20 6f 75 74 20 74 68 65 20 70 61  igure out the pa
92a0: 74 68 20 74 6f 20 74 68 65 20 72 75 6e 20 64 69  th to the run di
92b0: 72 20 61 6e 64 20 72 65 6d 6f 76 65 20 69 74 20  r and remove it 
92c0: 69 66 20 65 6d 70 74 79 0a 09 09 20 20 20 3b 3b  if empty...   ;;
92d0: 20 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20 28      (if (null? (
92e0: 67 6c 6f 62 20 28 63 6f 6e 63 20 72 75 6e 70 61  glob (conc runpa
92f0: 74 68 20 22 2f 2a 22 29 29 29 0a 09 09 20 20 20  th "/*")))...   
9300: 3b 3b 20 20 20 20 20 20 20 20 28 62 65 67 69 6e  ;;        (begin
9310: 0a 09 09 20 20 20 3b 3b 20 09 20 28 64 65 62 75  ...   ;; . (debu
9320: 67 3a 70 72 69 6e 74 20 31 20 22 52 65 6d 6f 76  g:print 1 "Remov
9330: 69 6e 67 20 72 75 6e 20 64 69 72 20 22 20 72 75  ing run dir " ru
9340: 6e 70 61 74 68 29 0a 09 09 20 20 20 3b 3b 20 09  npath)...   ;; .
9350: 20 28 73 79 73 74 65 6d 20 28 63 6f 6e 63 20 22   (system (conc "
9360: 72 6d 64 69 72 20 2d 70 20 22 20 72 75 6e 70 61  rmdir -p " runpa
9370: 74 68 29 29 29 29 0a 09 09 20 20 20 29 29 29 29  th))))...   ))))
9380: 0a 09 20 29 29 0a 20 20 20 20 20 72 75 6e 73 29  .. )).     runs)
9390: 29 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ))..;;==========
93a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
93b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
93c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
93d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20  ============.;; 
93e0: 52 6f 75 74 69 6e 65 73 20 66 6f 72 20 6d 61 6e  Routines for man
93f0: 69 70 75 6c 61 74 69 6e 67 20 72 75 6e 73 0a 3b  ipulating runs.;
9400: 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ;===============
9410: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9420: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9430: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9440: 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b 20 53 69 6e 63  =======..;; Sinc
9450: 65 20 6d 61 6e 79 20 63 61 6c 6c 73 20 74 6f 20  e many calls to 
9460: 61 20 72 75 6e 20 72 65 71 75 69 72 65 20 70 72  a run require pr
9470: 65 74 74 79 20 6d 75 63 68 20 74 68 65 20 73 61  etty much the sa
9480: 6d 65 20 73 65 74 75 70 20 0a 3b 3b 20 74 68 69  me setup .;; thi
9490: 73 20 77 72 61 70 70 65 72 20 69 73 20 75 73 65  s wrapper is use
94a0: 64 20 74 6f 20 72 65 64 75 63 65 20 74 68 65 20  d to reduce the 
94b0: 72 65 70 6c 69 63 61 74 69 6f 6e 20 6f 66 20 63  replication of c
94c0: 6f 64 65 0a 28 64 65 66 69 6e 65 20 28 67 65 6e  ode.(define (gen
94d0: 65 72 61 6c 2d 72 75 6e 2d 63 61 6c 6c 20 73 77  eral-run-call sw
94e0: 69 74 63 68 6e 61 6d 65 20 61 63 74 69 6f 6e 2d  itchname action-
94f0: 64 65 73 63 20 70 72 6f 63 29 0a 20 20 28 69 66  desc proc).  (if
9500: 20 28 6e 6f 74 20 28 61 72 67 73 3a 67 65 74 2d   (not (args:get-
9510: 61 72 67 20 22 3a 72 75 6e 6e 61 6d 65 22 29 29  arg ":runname"))
9520: 0a 20 20 20 20 20 20 28 62 65 67 69 6e 0a 09 28  .      (begin..(
9530: 64 65 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45  debug:print 0 "E
9540: 52 52 4f 52 3a 20 4d 69 73 73 69 6e 67 20 72 65  RROR: Missing re
9550: 71 75 69 72 65 64 20 70 61 72 61 6d 65 74 65 72  quired parameter
9560: 20 66 6f 72 20 22 20 73 77 69 74 63 68 6e 61 6d   for " switchnam
9570: 65 20 22 2c 20 79 6f 75 20 6d 75 73 74 20 73 70  e ", you must sp
9580: 65 63 69 66 79 20 74 68 65 20 72 75 6e 20 6e 61  ecify the run na
9590: 6d 65 20 77 69 74 68 20 3a 72 75 6e 6e 61 6d 65  me with :runname
95a0: 20 72 75 6e 6e 61 6d 65 22 29 0a 09 28 65 78 69   runname")..(exi
95b0: 74 20 32 29 29 0a 20 20 20 20 20 20 28 6c 65 74  t 2)).      (let
95c0: 20 28 28 64 62 20 23 66 29 29 0a 09 28 69 66 20   ((db #f))..(if 
95d0: 28 6e 6f 74 20 28 73 65 74 75 70 2d 66 6f 72 2d  (not (setup-for-
95e0: 72 75 6e 29 29 0a 09 20 20 20 20 28 62 65 67 69  run))..    (begi
95f0: 6e 20 0a 09 20 20 20 20 20 20 28 64 65 62 75 67  n ..      (debug
9600: 3a 70 72 69 6e 74 20 30 20 22 46 61 69 6c 65 64  :print 0 "Failed
9610: 20 74 6f 20 73 65 74 75 70 2c 20 65 78 69 74 69   to setup, exiti
9620: 6e 67 22 29 0a 09 20 20 20 20 20 20 28 65 78 69  ng")..      (exi
9630: 74 20 31 29 29 29 0a 09 28 73 65 74 21 20 64 62  t 1)))..(set! db
9640: 20 28 6f 70 65 6e 2d 64 62 29 29 0a 09 28 69 66   (open-db))..(if
9650: 20 28 6e 6f 74 20 28 63 61 72 20 2a 63 6f 6e 66   (not (car *conf
9660: 69 67 69 6e 66 6f 2a 29 29 0a 09 20 20 20 20 28  iginfo*))..    (
9670: 62 65 67 69 6e 0a 09 20 20 20 20 20 20 28 64 65  begin..      (de
9680: 62 75 67 3a 70 72 69 6e 74 20 30 20 22 45 52 52  bug:print 0 "ERR
9690: 4f 52 3a 20 41 74 74 65 6d 70 74 65 64 20 74 6f  OR: Attempted to
96a0: 20 22 20 61 63 74 69 6f 6e 2d 64 65 73 63 20 22   " action-desc "
96b0: 20 62 75 74 20 72 75 6e 20 61 72 65 61 20 63 6f   but run area co
96c0: 6e 66 69 67 20 66 69 6c 65 20 6e 6f 74 20 66 6f  nfig file not fo
96d0: 75 6e 64 22 29 0a 09 20 20 20 20 20 20 28 65 78  und")..      (ex
96e0: 69 74 20 31 29 29 0a 09 20 20 20 20 3b 3b 20 45  it 1))..    ;; E
96f0: 78 74 72 61 63 74 20 6f 75 74 20 73 74 75 66 66  xtract out stuff
9700: 20 6e 65 65 64 65 64 20 69 6e 20 6d 6f 73 74 20   needed in most 
9710: 6f 72 20 6d 61 6e 79 20 63 61 6c 6c 73 0a 09 20  or many calls.. 
9720: 20 20 20 3b 3b 20 68 65 72 65 20 74 68 65 6e 20     ;; here then 
9730: 63 61 6c 6c 20 70 72 6f 63 0a 09 20 20 20 20 28  call proc..    (
9740: 6c 65 74 2a 20 28 28 6b 65 79 73 20 20 20 20 20  let* ((keys     
9750: 20 20 28 64 62 2d 67 65 74 2d 6b 65 79 73 20 64    (db-get-keys d
9760: 62 29 29 0a 09 09 20 20 20 28 6b 65 79 6e 61 6d  b))...   (keynam
9770: 65 73 20 20 20 28 6d 61 70 20 6b 65 79 3a 67 65  es   (map key:ge
9780: 74 2d 66 69 65 6c 64 6e 61 6d 65 20 6b 65 79 73  t-fieldname keys
9790: 29 29 0a 09 09 20 20 20 28 6b 65 79 76 61 6c 6c  ))...   (keyvall
97a0: 73 74 20 20 28 6b 65 79 73 2d 3e 76 61 6c 6c 69  st  (keys->valli
97b0: 73 74 20 6b 65 79 73 20 23 74 29 29 29 0a 09 20  st keys #t))).. 
97c0: 20 20 20 20 20 28 70 72 6f 63 20 64 62 20 6b 65       (proc db ke
97d0: 79 73 20 6b 65 79 6e 61 6d 65 73 20 6b 65 79 76  ys keynames keyv
97e0: 61 6c 6c 73 74 29 29 29 0a 09 28 73 71 6c 69 74  allst)))..(sqlit
97f0: 65 33 3a 66 69 6e 61 6c 69 7a 65 21 20 64 62 29  e3:finalize! db)
9800: 0a 09 28 73 65 74 21 20 2a 64 69 64 73 6f 6d 65  ..(set! *didsome
9810: 74 68 69 6e 67 2a 20 23 74 29 29 29 29 0a 0a 3b  thing* #t))))..;
9820: 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ;===============
9830: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9840: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9850: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9860: 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 52 6f 6c 6c 75  =======.;; Rollu
9870: 70 20 72 75 6e 73 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d  p runs.;;=======
9880: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
9890: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
98a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
98b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a  ===============.
98c0: 0a 3b 3b 20 55 70 64 61 74 65 20 74 68 65 20 74  .;; Update the t
98d0: 65 73 74 5f 6d 65 74 61 20 74 61 62 6c 65 20 66  est_meta table f
98e0: 6f 72 20 74 68 69 73 20 74 65 73 74 0a 28 64 65  or this test.(de
98f0: 66 69 6e 65 20 28 72 75 6e 73 3a 75 70 64 61 74  fine (runs:updat
9900: 65 2d 74 65 73 74 5f 6d 65 74 61 20 64 62 20 74  e-test_meta db t
9910: 65 73 74 2d 6e 61 6d 65 20 74 65 73 74 2d 63 6f  est-name test-co
9920: 6e 66 29 0a 20 20 28 6c 65 74 20 28 28 63 75 72  nf).  (let ((cur
9930: 72 72 65 63 6f 72 64 20 28 64 62 3a 74 65 73 74  rrecord (db:test
9940: 6d 65 74 61 2d 67 65 74 2d 72 65 63 6f 72 64 20  meta-get-record 
9950: 64 62 20 74 65 73 74 2d 6e 61 6d 65 29 29 29 0a  db test-name))).
9960: 20 20 20 20 28 69 66 20 28 6e 6f 74 20 63 75 72      (if (not cur
9970: 72 72 65 63 6f 72 64 29 0a 09 28 62 65 67 69 6e  rrecord)..(begin
9980: 0a 09 20 20 28 73 65 74 21 20 63 75 72 72 72 65  ..  (set! currre
9990: 63 6f 72 64 20 28 6d 61 6b 65 2d 76 65 63 74 6f  cord (make-vecto
99a0: 72 20 31 30 20 23 66 29 29 0a 09 20 20 28 64 62  r 10 #f))..  (db
99b0: 3a 74 65 73 74 6d 65 74 61 2d 61 64 64 2d 72 65  :testmeta-add-re
99c0: 63 6f 72 64 20 64 62 20 74 65 73 74 2d 6e 61 6d  cord db test-nam
99d0: 65 29 29 29 0a 20 20 20 20 28 66 6f 72 2d 65 61  e))).    (for-ea
99e0: 63 68 20 0a 20 20 20 20 20 28 6c 61 6d 62 64 61  ch .     (lambda
99f0: 20 28 6b 65 79 29 0a 20 20 20 20 20 20 20 28 6c   (key).       (l
9a00: 65 74 2a 20 28 28 69 64 78 20 28 63 61 64 72 20  et* ((idx (cadr 
9a10: 6b 65 79 29 29 0a 09 20 20 20 20 20 20 28 66 6c  key))..      (fl
9a20: 64 20 28 63 61 72 20 20 6b 65 79 29 29 0a 09 20  d (car  key)).. 
9a30: 20 20 20 20 20 28 76 61 6c 20 28 63 6f 6e 66 69       (val (confi
9a40: 67 2d 6c 6f 6f 6b 75 70 20 74 65 73 74 2d 63 6f  g-lookup test-co
9a50: 6e 66 20 22 74 65 73 74 5f 6d 65 74 61 22 20 66  nf "test_meta" f
9a60: 6c 64 29 29 29 0a 09 20 28 69 66 20 28 61 6e 64  ld))).. (if (and
9a70: 20 76 61 6c 20 28 6e 6f 74 20 28 65 71 75 61 6c   val (not (equal
9a80: 3f 20 28 76 65 63 74 6f 72 2d 72 65 66 20 63 75  ? (vector-ref cu
9a90: 72 72 72 65 63 6f 72 64 20 69 64 78 29 20 76 61  rrrecord idx) va
9aa0: 6c 29 29 29 0a 09 20 20 20 20 20 28 62 65 67 69  l)))..     (begi
9ab0: 6e 0a 09 20 20 20 20 20 20 20 28 70 72 69 6e 74  n..       (print
9ac0: 20 22 55 70 64 61 74 69 6e 67 20 22 20 74 65 73   "Updating " tes
9ad0: 74 2d 6e 61 6d 65 20 22 20 22 20 66 6c 64 20 22  t-name " " fld "
9ae0: 20 74 6f 20 22 20 76 61 6c 29 0a 09 20 20 20 20   to " val)..    
9af0: 20 20 20 28 64 62 3a 74 65 73 74 6d 65 74 61 2d     (db:testmeta-
9b00: 75 70 64 61 74 65 2d 66 69 65 6c 64 20 64 62 20  update-field db 
9b10: 74 65 73 74 2d 6e 61 6d 65 20 66 6c 64 20 76 61  test-name fld va
9b20: 6c 29 29 29 29 29 0a 20 20 20 20 20 27 28 28 22  l))))).     '(("
9b30: 61 75 74 68 6f 72 22 20 32 29 28 22 6f 77 6e 65  author" 2)("owne
9b40: 72 22 20 33 29 28 22 64 65 73 63 72 69 70 74 69  r" 3)("descripti
9b50: 6f 6e 22 20 34 29 28 22 72 65 76 69 65 77 65 64  on" 4)("reviewed
9b60: 22 20 35 29 28 22 74 61 67 73 22 20 39 29 29 29  " 5)("tags" 9)))
9b70: 29 29 0a 0a 3b 3b 20 55 70 64 61 74 65 20 74 65  ))..;; Update te
9b80: 73 74 5f 6d 65 74 61 20 66 6f 72 20 61 6c 6c 20  st_meta for all 
9b90: 74 65 73 74 73 0a 28 64 65 66 69 6e 65 20 28 72  tests.(define (r
9ba0: 75 6e 73 3a 75 70 64 61 74 65 2d 61 6c 6c 2d 74  uns:update-all-t
9bb0: 65 73 74 5f 6d 65 74 61 20 64 62 29 0a 20 20 28  est_meta db).  (
9bc0: 6c 65 74 20 28 28 74 65 73 74 2d 6e 61 6d 65 73  let ((test-names
9bd0: 20 28 67 65 74 2d 61 6c 6c 2d 6c 65 67 61 6c 2d   (get-all-legal-
9be0: 74 65 73 74 73 29 29 29 0a 20 20 20 20 28 66 6f  tests))).    (fo
9bf0: 72 2d 65 61 63 68 20 0a 20 20 20 20 20 28 6c 61  r-each .     (la
9c00: 6d 62 64 61 20 28 74 65 73 74 2d 6e 61 6d 65 29  mbda (test-name)
9c10: 0a 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28 28  .       (let* ((
9c20: 74 65 73 74 2d 70 61 74 68 20 20 20 20 28 63 6f  test-path    (co
9c30: 6e 63 20 2a 74 6f 70 70 61 74 68 2a 20 22 2f 74  nc *toppath* "/t
9c40: 65 73 74 73 2f 22 20 74 65 73 74 2d 6e 61 6d 65  ests/" test-name
9c50: 29 29 0a 09 20 20 20 20 20 20 28 74 65 73 74 2d  ))..      (test-
9c60: 63 6f 6e 66 69 67 66 20 28 63 6f 6e 63 20 74 65  configf (conc te
9c70: 73 74 2d 70 61 74 68 20 22 2f 74 65 73 74 63 6f  st-path "/testco
9c80: 6e 66 69 67 22 29 29 0a 09 20 20 20 20 20 20 28  nfig"))..      (
9c90: 74 65 73 74 65 78 69 73 74 73 20 20 20 28 61 6e  testexists   (an
9ca0: 64 20 28 66 69 6c 65 2d 65 78 69 73 74 73 3f 20  d (file-exists? 
9cb0: 74 65 73 74 2d 63 6f 6e 66 69 67 66 29 28 66 69  test-configf)(fi
9cc0: 6c 65 2d 72 65 61 64 2d 61 63 63 65 73 73 3f 20  le-read-access? 
9cd0: 74 65 73 74 2d 63 6f 6e 66 69 67 66 29 29 29 0a  test-configf))).
9ce0: 09 20 20 20 20 20 20 3b 3b 20 72 65 61 64 20 63  .      ;; read c
9cf0: 6f 6e 66 69 67 73 20 77 69 74 68 20 74 72 69 63  onfigs with tric
9d00: 6b 73 20 74 75 72 6e 65 64 20 6f 66 66 20 28 69  ks turned off (i
9d10: 2e 65 2e 20 6e 6f 20 73 79 73 74 65 6d 29 0a 09  .e. no system)..
9d20: 20 20 20 20 20 20 28 74 65 73 74 2d 63 6f 6e 66        (test-conf
9d30: 20 20 20 20 28 69 66 20 74 65 73 74 65 78 69 73      (if testexis
9d40: 74 73 20 28 72 65 61 64 2d 63 6f 6e 66 69 67 20  ts (read-config 
9d50: 74 65 73 74 2d 63 6f 6e 66 69 67 66 20 23 66 20  test-configf #f 
9d60: 23 66 29 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61  #f)(make-hash-ta
9d70: 62 6c 65 29 29 29 29 0a 09 20 28 72 75 6e 73 3a  ble)))).. (runs:
9d80: 75 70 64 61 74 65 2d 74 65 73 74 5f 6d 65 74 61  update-test_meta
9d90: 20 64 62 20 74 65 73 74 2d 6e 61 6d 65 20 74 65   db test-name te
9da0: 73 74 2d 63 6f 6e 66 29 29 29 0a 20 20 20 20 20  st-conf))).     
9db0: 74 65 73 74 2d 6e 61 6d 65 73 29 29 29 0a 09 20  test-names))).. 
9dc0: 0a 3b 3b 20 54 68 69 73 20 63 6f 75 6c 64 20 70  .;; This could p
9dd0: 72 6f 62 61 62 6c 79 20 62 65 20 72 65 66 61 63  robably be refac
9de0: 74 6f 72 65 64 20 69 6e 74 6f 20 6f 6e 65 20 63  tored into one c
9df0: 6f 6d 70 6c 65 78 20 71 75 65 72 79 20 2e 2e 2e  omplex query ...
9e00: 0a 28 64 65 66 69 6e 65 20 28 72 75 6e 73 3a 72  .(define (runs:r
9e10: 6f 6c 6c 75 70 2d 72 75 6e 20 64 62 20 6b 65 79  ollup-run db key
9e20: 73 29 0a 20 20 28 6c 65 74 2a 20 28 28 6e 65 77  s).  (let* ((new
9e30: 2d 72 75 6e 2d 69 64 20 20 20 20 20 20 28 72 65  -run-id      (re
9e40: 67 69 73 74 65 72 2d 72 75 6e 20 64 62 20 6b 65  gister-run db ke
9e50: 79 73 29 29 0a 09 20 28 70 72 65 76 2d 74 65 73  ys)).. (prev-tes
9e60: 74 73 20 20 20 20 20 20 28 74 65 73 74 3a 67 65  ts      (test:ge
9e70: 74 2d 6d 61 74 63 68 69 6e 67 2d 70 72 65 76 69  t-matching-previ
9e80: 6f 75 73 2d 74 65 73 74 2d 72 75 6e 2d 72 65 63  ous-test-run-rec
9e90: 6f 72 64 73 20 64 62 20 6e 65 77 2d 72 75 6e 2d  ords db new-run-
9ea0: 69 64 20 22 25 22 20 22 25 22 29 29 0a 09 20 28  id "%" "%")).. (
9eb0: 63 75 72 72 2d 74 65 73 74 73 20 20 20 20 20 20  curr-tests      
9ec0: 28 64 62 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f  (db-get-tests-fo
9ed0: 72 2d 72 75 6e 20 64 62 20 6e 65 77 2d 72 75 6e  r-run db new-run
9ee0: 2d 69 64 20 22 25 22 20 22 25 22 29 29 0a 09 20  -id "%" "%")).. 
9ef0: 28 63 75 72 72 2d 74 65 73 74 73 2d 68 61 73 68  (curr-tests-hash
9f00: 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 6c   (make-hash-tabl
9f10: 65 29 29 29 0a 20 20 20 20 3b 3b 20 69 6e 64 65  e))).    ;; inde
9f20: 78 20 74 68 65 20 61 6c 72 65 61 64 79 20 73 61  x the already sa
9f30: 76 65 64 20 74 65 73 74 73 20 62 79 20 74 65 73  ved tests by tes
9f40: 74 6e 61 6d 65 20 61 6e 64 20 69 74 65 6d 70 61  tname and itempa
9f50: 74 68 20 69 6e 20 63 75 72 72 2d 74 65 73 74 73  th in curr-tests
9f60: 2d 68 61 73 68 0a 20 20 20 20 28 66 6f 72 2d 65  -hash.    (for-e
9f70: 61 63 68 0a 20 20 20 20 20 28 6c 61 6d 62 64 61  ach.     (lambda
9f80: 20 28 74 65 73 74 64 61 74 29 0a 20 20 20 20 20   (testdat).     
9f90: 20 20 28 6c 65 74 2a 20 28 28 74 65 73 74 6e 61    (let* ((testna
9fa0: 6d 65 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74  me  (db:test-get
9fb0: 2d 74 65 73 74 6e 61 6d 65 20 74 65 73 74 64 61  -testname testda
9fc0: 74 29 29 0a 09 20 20 20 20 20 20 28 69 74 65 6d  t))..      (item
9fd0: 2d 70 61 74 68 20 28 64 62 3a 74 65 73 74 2d 67  -path (db:test-g
9fe0: 65 74 2d 69 74 65 6d 2d 70 61 74 68 20 74 65 73  et-item-path tes
9ff0: 74 64 61 74 29 29 0a 09 20 20 20 20 20 20 28 66  tdat))..      (f
a000: 75 6c 6c 2d 6e 61 6d 65 20 28 63 6f 6e 63 20 74  ull-name (conc t
a010: 65 73 74 6e 61 6d 65 20 22 2f 22 20 69 74 65 6d  estname "/" item
a020: 2d 70 61 74 68 29 29 29 0a 09 20 28 68 61 73 68  -path))).. (hash
a030: 2d 74 61 62 6c 65 2d 73 65 74 21 20 63 75 72 72  -table-set! curr
a040: 2d 74 65 73 74 73 2d 68 61 73 68 20 66 75 6c 6c  -tests-hash full
a050: 2d 6e 61 6d 65 20 74 65 73 74 64 61 74 29 29 29  -name testdat)))
a060: 0a 20 20 20 20 20 63 75 72 72 2d 74 65 73 74 73  .     curr-tests
a070: 29 0a 20 20 20 20 3b 3b 20 4e 4f 50 45 3a 20 4e  ).    ;; NOPE: N
a080: 6f 6e 2d 6f 70 74 69 6d 61 6c 20 61 70 70 72 6f  on-optimal appro
a090: 61 63 68 2e 20 54 72 79 20 74 68 69 73 20 69 6e  ach. Try this in
a0a0: 73 74 65 61 64 2e 0a 20 20 20 20 3b 3b 20 20 20  stead..    ;;   
a0b0: 31 2e 20 74 65 73 74 73 20 61 72 65 20 72 65 63  1. tests are rec
a0c0: 65 69 76 65 64 20 69 6e 20 61 20 6c 69 73 74 2c  eived in a list,
a0d0: 20 6d 6f 73 74 20 72 65 63 65 6e 74 20 66 69 72   most recent fir
a0e0: 73 74 0a 20 20 20 20 3b 3b 20 20 20 32 2e 20 72  st.    ;;   2. r
a0f0: 65 70 6c 61 63 65 20 74 68 65 20 72 6f 6c 6c 75  eplace the rollu
a100: 70 20 74 65 73 74 20 77 69 74 68 20 74 68 65 20  p test with the 
a110: 6e 65 77 20 2a 61 6c 77 61 79 73 2a 0a 20 20 20  new *always*.   
a120: 20 28 66 6f 72 2d 65 61 63 68 20 0a 20 20 20 20   (for-each .    
a130: 20 28 6c 61 6d 62 64 61 20 28 74 65 73 74 64 61   (lambda (testda
a140: 74 29 0a 20 20 20 20 20 20 20 28 6c 65 74 2a 20  t).       (let* 
a150: 28 28 74 65 73 74 6e 61 6d 65 20 20 28 64 62 3a  ((testname  (db:
a160: 74 65 73 74 2d 67 65 74 2d 74 65 73 74 6e 61 6d  test-get-testnam
a170: 65 20 74 65 73 74 64 61 74 29 29 0a 09 20 20 20  e testdat))..   
a180: 20 20 20 28 69 74 65 6d 2d 70 61 74 68 20 28 64     (item-path (d
a190: 62 3a 74 65 73 74 2d 67 65 74 2d 69 74 65 6d 2d  b:test-get-item-
a1a0: 70 61 74 68 20 74 65 73 74 64 61 74 29 29 0a 09  path testdat))..
a1b0: 20 20 20 20 20 20 28 66 75 6c 6c 2d 6e 61 6d 65        (full-name
a1c0: 20 28 63 6f 6e 63 20 74 65 73 74 6e 61 6d 65 20   (conc testname 
a1d0: 22 2f 22 20 69 74 65 6d 2d 70 61 74 68 29 29 0a  "/" item-path)).
a1e0: 09 20 20 20 20 20 20 28 70 72 65 76 2d 74 65 73  .      (prev-tes
a1f0: 74 2d 64 61 74 20 28 68 61 73 68 2d 74 61 62 6c  t-dat (hash-tabl
a200: 65 2d 72 65 66 2f 64 65 66 61 75 6c 74 20 63 75  e-ref/default cu
a210: 72 72 2d 74 65 73 74 73 2d 68 61 73 68 20 66 75  rr-tests-hash fu
a220: 6c 6c 2d 6e 61 6d 65 20 23 66 29 29 0a 09 20 20  ll-name #f))..  
a230: 20 20 20 20 28 74 65 73 74 2d 73 74 65 70 73 20      (test-steps 
a240: 20 20 20 20 20 28 64 62 3a 67 65 74 2d 73 74 65       (db:get-ste
a250: 70 73 2d 66 6f 72 2d 74 65 73 74 20 64 62 20 28  ps-for-test db (
a260: 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74  db:test-get-id t
a270: 65 73 74 64 61 74 29 29 29 0a 09 20 20 20 20 20  estdat)))..     
a280: 20 28 6e 65 77 2d 74 65 73 74 2d 72 65 63 6f 72   (new-test-recor
a290: 64 20 23 66 29 29 0a 09 20 3b 3b 20 72 65 70 6c  d #f)).. ;; repl
a2a0: 61 63 65 20 74 68 65 73 65 20 77 69 74 68 20 69  ace these with i
a2b0: 6e 73 65 72 74 20 2e 2e 2e 20 73 65 6c 65 63 74  nsert ... select
a2c0: 0a 09 20 28 61 70 70 6c 79 20 73 71 6c 69 74 65  .. (apply sqlite
a2d0: 33 3a 65 78 65 63 75 74 65 20 0a 09 09 64 62 20  3:execute ...db 
a2e0: 0a 09 09 28 63 6f 6e 63 20 22 49 4e 53 45 52 54  ...(conc "INSERT
a2f0: 20 4f 52 20 52 45 50 4c 41 43 45 20 49 4e 54 4f   OR REPLACE INTO
a300: 20 74 65 73 74 73 20 28 72 75 6e 5f 69 64 2c 74   tests (run_id,t
a310: 65 73 74 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74  estname,state,st
a320: 61 74 75 73 2c 65 76 65 6e 74 5f 74 69 6d 65 2c  atus,event_time,
a330: 68 6f 73 74 2c 63 70 75 6c 6f 61 64 2c 64 69 73  host,cpuload,dis
a340: 6b 66 72 65 65 2c 75 6e 61 6d 65 2c 72 75 6e 64  kfree,uname,rund
a350: 69 72 2c 69 74 65 6d 5f 70 61 74 68 2c 72 75 6e  ir,item_path,run
a360: 5f 64 75 72 61 74 69 6f 6e 2c 66 69 6e 61 6c 5f  _duration,final_
a370: 6c 6f 67 66 2c 63 6f 6d 6d 65 6e 74 2c 66 69 72  logf,comment,fir
a380: 73 74 5f 65 72 72 2c 66 69 72 73 74 5f 77 61 72  st_err,first_war
a390: 6e 29 20 22 0a 09 09 20 20 20 20 20 20 22 56 41  n) "...      "VA
a3a0: 4c 55 45 53 20 28 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c  LUES (?,?,?,?,?,
a3b0: 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c 3f 2c  ?,?,?,?,?,?,?,?,
a3c0: 3f 2c 3f 2c 3f 29 3b 22 29 0a 09 09 6e 65 77 2d  ?,?,?);")...new-
a3d0: 72 75 6e 2d 69 64 20 28 63 64 64 72 20 28 76 65  run-id (cddr (ve
a3e0: 63 74 6f 72 2d 3e 6c 69 73 74 20 74 65 73 74 64  ctor->list testd
a3f0: 61 74 29 29 29 0a 09 20 28 73 65 74 21 20 6e 65  at))).. (set! ne
a400: 77 2d 74 65 73 74 64 61 74 20 28 63 61 72 20 28  w-testdat (car (
a410: 64 62 2d 67 65 74 2d 74 65 73 74 73 2d 66 6f 72  db-get-tests-for
a420: 2d 72 75 6e 20 64 62 20 6e 65 77 2d 72 75 6e 2d  -run db new-run-
a430: 69 64 20 74 65 73 74 6e 61 6d 65 20 69 74 65 6d  id testname item
a440: 2d 70 61 74 68 29 29 29 0a 09 20 28 68 61 73 68  -path))).. (hash
a450: 2d 74 61 62 6c 65 2d 73 65 74 21 20 63 75 72 72  -table-set! curr
a460: 2d 74 65 73 74 73 2d 68 61 73 68 20 66 75 6c 6c  -tests-hash full
a470: 2d 6e 61 6d 65 20 6e 65 77 2d 74 65 73 74 64 61  -name new-testda
a480: 74 29 20 3b 3b 20 74 68 69 73 20 63 6f 75 6c 64  t) ;; this could
a490: 20 62 65 20 63 6f 6e 66 75 73 69 6e 67 2c 20 77   be confusing, w
a4a0: 68 69 63 68 20 72 65 63 6f 72 64 20 73 68 6f 75  hich record shou
a4b0: 6c 64 20 67 6f 20 69 6e 74 6f 20 74 68 65 20 6c  ld go into the l
a4c0: 6f 6f 6b 75 70 20 74 61 62 6c 65 3f 0a 09 20 3b  ookup table?.. ;
a4d0: 3b 20 4e 6f 77 20 64 75 70 6c 69 63 61 74 65 20  ; Now duplicate 
a4e0: 74 68 65 20 74 65 73 74 20 73 74 65 70 73 0a 09  the test steps..
a4f0: 20 28 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20   (debug:print 4 
a500: 22 43 6f 70 79 69 6e 67 20 72 65 63 6f 72 64 73  "Copying records
a510: 20 69 6e 20 74 65 73 74 5f 73 74 65 70 73 20 66   in test_steps f
a520: 72 6f 6d 20 74 65 73 74 5f 69 64 3d 22 20 28 64  rom test_id=" (d
a530: 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 74 65  b:test-get-id te
a540: 73 74 64 61 74 29 20 22 20 74 6f 20 22 20 28 64  stdat) " to " (d
a550: 62 3a 74 65 73 74 2d 67 65 74 2d 69 64 20 6e 65  b:test-get-id ne
a560: 77 2d 74 65 73 74 64 61 74 29 29 0a 09 20 28 73  w-testdat)).. (s
a570: 71 6c 69 74 65 33 3a 65 78 65 63 75 74 65 20 0a  qlite3:execute .
a580: 09 20 20 64 62 20 0a 09 20 20 28 63 6f 6e 63 20  .  db ..  (conc 
a590: 22 49 4e 53 45 52 54 20 4f 52 20 52 45 50 4c 41  "INSERT OR REPLA
a5a0: 43 45 20 49 4e 54 4f 20 74 65 73 74 5f 73 74 65  CE INTO test_ste
a5b0: 70 73 20 28 74 65 73 74 5f 69 64 2c 73 74 65 70  ps (test_id,step
a5c0: 6e 61 6d 65 2c 73 74 61 74 65 2c 73 74 61 74 75  name,state,statu
a5d0: 73 2c 65 76 65 6e 74 5f 74 69 6d 65 2c 63 6f 6d  s,event_time,com
a5e0: 6d 65 6e 74 29 20 22 0a 09 09 22 53 45 4c 45 43  ment) "..."SELEC
a5f0: 54 20 22 20 28 64 62 3a 74 65 73 74 2d 67 65 74  T " (db:test-get
a600: 2d 69 64 20 6e 65 77 2d 74 65 73 74 64 61 74 29  -id new-testdat)
a610: 20 22 2c 73 74 65 70 6e 61 6d 65 2c 73 74 61 74   ",stepname,stat
a620: 65 2c 73 74 61 74 75 73 2c 65 76 65 6e 74 5f 74  e,status,event_t
a630: 69 6d 65 2c 63 6f 6d 6d 65 6e 74 20 46 52 4f 4d  ime,comment FROM
a640: 20 74 65 73 74 5f 73 74 65 70 73 20 57 48 45 52   test_steps WHER
a650: 45 20 74 65 73 74 5f 69 64 3d 3f 3b 22 29 0a 09  E test_id=?;")..
a660: 20 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69    (db:test-get-i
a670: 64 20 74 65 73 74 64 61 74 29 29 0a 09 20 3b 3b  d testdat)).. ;;
a680: 20 4e 6f 77 20 64 75 70 6c 69 63 61 74 65 20 74   Now duplicate t
a690: 68 65 20 74 65 73 74 20 64 61 74 61 0a 09 20 28  he test data.. (
a6a0: 64 65 62 75 67 3a 70 72 69 6e 74 20 34 20 22 43  debug:print 4 "C
a6b0: 6f 70 79 69 6e 67 20 72 65 63 6f 72 64 73 20 69  opying records i
a6c0: 6e 20 74 65 73 74 5f 64 61 74 61 20 66 72 6f 6d  n test_data from
a6d0: 20 74 65 73 74 5f 69 64 3d 22 20 28 64 62 3a 74   test_id=" (db:t
a6e0: 65 73 74 2d 67 65 74 2d 69 64 20 74 65 73 74 64  est-get-id testd
a6f0: 61 74 29 20 22 20 74 6f 20 22 20 28 64 62 3a 74  at) " to " (db:t
a700: 65 73 74 2d 67 65 74 2d 69 64 20 6e 65 77 2d 74  est-get-id new-t
a710: 65 73 74 64 61 74 29 29 0a 09 20 28 73 71 6c 69  estdat)).. (sqli
a720: 74 65 33 3a 65 78 65 63 75 74 65 20 0a 09 20 20  te3:execute ..  
a730: 64 62 20 0a 09 20 20 28 63 6f 6e 63 20 22 49 4e  db ..  (conc "IN
a740: 53 45 52 54 20 4f 52 20 52 45 50 4c 41 43 45 20  SERT OR REPLACE 
a750: 49 4e 54 4f 20 74 65 73 74 5f 64 61 74 61 20 28  INTO test_data (
a760: 74 65 73 74 5f 69 64 2c 63 61 74 65 67 6f 72 79  test_id,category
a770: 2c 76 61 72 69 61 62 6c 65 2c 76 61 6c 75 65 2c  ,variable,value,
a780: 65 78 70 65 63 74 65 64 2c 74 6f 6c 2c 75 6e 69  expected,tol,uni
a790: 74 73 2c 63 6f 6d 6d 65 6e 74 29 20 22 0a 09 09  ts,comment) "...
a7a0: 22 53 45 4c 45 43 54 20 22 20 28 64 62 3a 74 65  "SELECT " (db:te
a7b0: 73 74 2d 67 65 74 2d 69 64 20 6e 65 77 2d 74 65  st-get-id new-te
a7c0: 73 74 64 61 74 29 20 22 2c 63 61 74 65 67 6f 72  stdat) ",categor
a7d0: 79 2c 76 61 72 69 61 62 6c 65 2c 76 61 6c 75 65  y,variable,value
a7e0: 2c 65 78 70 65 63 74 65 64 2c 74 6f 6c 2c 75 6e  ,expected,tol,un
a7f0: 69 74 73 2c 63 6f 6d 6d 65 6e 74 20 46 52 4f 4d  its,comment FROM
a800: 20 74 65 73 74 5f 64 61 74 61 20 57 48 45 52 45   test_data WHERE
a810: 20 74 65 73 74 5f 69 64 3d 3f 3b 22 29 0a 09 20   test_id=?;").. 
a820: 20 28 64 62 3a 74 65 73 74 2d 67 65 74 2d 69 64   (db:test-get-id
a830: 20 74 65 73 74 64 61 74 29 29 0a 09 20 29 29 0a   testdat)).. )).
a840: 20 20 20 20 20 70 72 65 76 2d 74 65 73 74 73 29       prev-tests)
a850: 29 29 0a 09 20 0a 20 20 20 20 20 0a              )).. .     .