Megatest

Check-in [e4d1922be4]
Login
Overview
Comment:info from -show commands should go to stdout. Misc progress on newdashboard
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.70-ndboard
Files: files | file ages | folders
SHA1: e4d1922be49e6dce866c301c6cec225d25be3caf
User & Date: matt on 2022-10-30 22:59:14
Other Links: branch diff | manifest | tags
Context
2022-10-31
09:47
If .megatest does not exist but megatest.db does, try using it. NOTE: can't work with current calls creating .megatest area. Abandon this but keep the code for now. check-in: 533667efde user: matt tags: v1.70-ndboard
2022-10-30
22:59
info from -show commands should go to stdout. Misc progress on newdashboard check-in: e4d1922be4 user: matt tags: v1.70-ndboard
21:56
Clean up output of -show-keys. Use struct for keeping all the misc data associated with an area check-in: b0b795e94c user: matt tags: v1.70-ndboard
Changes

Modified megatest.scm from [806d7f7e0d] to [1caaf81211].

2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
    (let ((db #f)
	  (keys #f))
      (if (not (launch:setup))
	  (begin
	    (debug:print 0 *default-log-port* "Failed to setup, exiting")
	    (exit 1)))
      (set! keys (rmt:get-keys)) ;;  db))
      (debug:print 0 *default-log-port* (string-intersperse keys " "))
      (set! *didsomething* #t)))

(if (args:get-arg "-gui")
    (begin
      (debug:print 0 *default-log-port* "Look at the dashboard for now")
      ;; (megatest-gui)
      (set! *didsomething* #t)))







|







2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
    (let ((db #f)
	  (keys #f))
      (if (not (launch:setup))
	  (begin
	    (debug:print 0 *default-log-port* "Failed to setup, exiting")
	    (exit 1)))
      (set! keys (rmt:get-keys)) ;;  db))
      (print (string-intersperse keys " "))
      (set! *didsomething* #t)))

(if (args:get-arg "-gui")
    (begin
      (debug:print 0 *default-log-port* "Look at the dashboard for now")
      ;; (megatest-gui)
      (set! *didsomething* #t)))

Modified newdashboard.scm from [f00b30fbcd] to [67df0a6428].

24
25
26
27
28
29
30
31

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

49
50
51
52
53
54
55
56
(declare (uses treemod))

(use srfi-1
     posix regex regex-case srfi-69 typed-records sparse-vectors
     format
     extras
     (prefix iup iup:)
     canvas-draw)


(import canvas-draw-iup)

(module ndboard
    *

(import scheme
	chicken
	data-structures
	extras
	format
	(prefix iup iup:)
	canvas-draw
	canvas-draw-iup
	matchable
	srfi-1 posix regex regex-case
	srfi-69 typed-records sparse-vectors ;; defstruct


	treemod
	(prefix mtargs args:)
	)


(include "megatest-version.scm")








|
>

















>
|







24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
(declare (uses treemod))

(use srfi-1
     posix regex regex-case srfi-69 typed-records sparse-vectors
     format
     extras
     (prefix iup iup:)
     canvas-draw
     sqlite3)

(import canvas-draw-iup)

(module ndboard
    *

(import scheme
	chicken
	data-structures
	extras
	format
	(prefix iup iup:)
	canvas-draw
	canvas-draw-iup
	matchable
	srfi-1 posix regex regex-case
	srfi-69 typed-records sparse-vectors ;; defstruct
	sqlite3
	
	treemod
	(prefix mtargs args:)
	)


(include "megatest-version.scm")

119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149






150
151
152
153
154
155
156

(define *areas* (make-hash-table))
(defstruct area
  path
  keys
  targets
  targets-update-time
  
  )

(define (area-get-path area-name)
  (let* ((adat (hash-table-ref/default *areas* area-name #f)))
    (if adat
	(area-path adat)
	#f)))

(define (get-areas-file)
  (conc (get-environment-variable "HOME")"/.ndboard/areas.scm"))

(define (get-areas)
  (let* ((areas-file (get-areas-file)))
    (if (file-exists? areas-file)
	(with-input-from-file areas-file read))))

(define (register-area areadat)
  (hash-table-set! *areas* (car areadat)
		   (make-area path: (cdr areadat))))

(define (get-area-info area-name)
  (hash-table-ref/default *areas* area-name #f))







;; megatest calls, run in "area"
;;

;; TODO store the last time the query was run
;; and clear cache based on timestamp on main.db
;;
(define (megatest-get-targets area-name)







|



|



















>
>
>
>
>
>







121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164

(define *areas* (make-hash-table))
(defstruct area
  path
  keys
  targets
  targets-update-time
  (dbhs (make-hash-table))
  )

(define (area-get-path area-name)
  (let* ((adat (get-area-info area-name)))
    (if adat
	(area-path adat)
	#f)))

(define (get-areas-file)
  (conc (get-environment-variable "HOME")"/.ndboard/areas.scm"))

(define (get-areas)
  (let* ((areas-file (get-areas-file)))
    (if (file-exists? areas-file)
	(with-input-from-file areas-file read))))

(define (register-area areadat)
  (hash-table-set! *areas* (car areadat)
		   (make-area path: (cdr areadat))))

(define (get-area-info area-name)
  (hash-table-ref/default *areas* area-name #f))

(define (area-save-dbh area-name dbname mtdbh)
  (hash-table-set! (area-dbhs (get-area-info area-name)) dbname mtdbh))

(define (area-get-dbh area-name dbname)
  (hash-table-ref/default (area-dbhs (get-area-info area-name)) dbname #f))

;; megatest calls, run in "area"
;;

;; TODO store the last time the query was run
;; and clear cache based on timestamp on main.db
;;
(define (megatest-get-targets area-name)
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187

















































188
189
190
191
192
193
194

(define (megatest-get-keys area-name)
  (let* ((ainfo   (get-area-info area-name))
	 (keys    (area-keys ainfo)))
    (if keys
	keys
	(let* ((path     (area-path ainfo))
	       (keysstrs (with-input-from-pipe
			     (conc "megatest -show-keys -start-dir "path)
			   read-lines)))
	  (if (null? keysstrs)
	      (print "Unknown error getting keys for area "area-name", path: "path)
	      (let* ((keystr (car keysstrs))
		     (keys   (string-split keystr)))
		(area-keys-set! ainfo keys)
		keys))))))
	  

















































;; gui utils
;;

(define (message-window msg)
  (iup:show
   (iup:dialog
    (iup:vbox 







|
|
|
|

<
|


|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







179
180
181
182
183
184
185
186
187
188
189
190

191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250

(define (megatest-get-keys area-name)
  (let* ((ainfo   (get-area-info area-name))
	 (keys    (area-keys ainfo)))
    (if keys
	keys
	(let* ((path     (area-path ainfo))
	       (keysstr (with-input-from-pipe
			    (conc "megatest -show-keys -start-dir "path)
			  read-line)))
	  (if (not (string? keysstr))
	      (print "Unknown error getting keys for area "area-name", path: "path)

	      (let* ((keys   (string-split keysstr)))
		(area-keys-set! ainfo keys)
		keys))))))

;; megatest area database access functions
;;

(defstruct mtdb
  name
  db
  path)

;; dbname is main.db, 1.db ...
(define (megatest-open-db area-name dbname)
  (let* ((mtdbh (area-get-dbh area-name dbname)))
    (if mtdbh
	mtdbh
	(let* ((ainfo    (get-area-info area-name))
	       (path     (area-path ainfo))
	       (dbpath   (conc path"/.megatest/"dbname))
	       (dbexists (and (file-exists? dbpath)
			      (file-read-access? dbpath))))
	  (if dbexists
	      (let* ((db (open-database dbpath)))
		(set-busy-handler! db (make-busy-timeout 136000))
		(execute db "PRAGMA synchronous = 0;")
		(let* ((mtdbh (make-mtdb db: db path: dbpath)))
		  (area-save-dbh area-name dbname mtdbh)
		  mtdbh))
	      #f)))))

;; ADD on-exit to close the opened dbs

;; keys is list, targpatts is list, both same length
;; and *fully* specified
;; returns targvals and runname
(define (megatest-get-run-names area-name keys targpatts)
  (let* ((mtdbh    (megatest-open-db area-name "main.db"))
	 (selector (string-intersperse
		    (map (lambda (k v)(conc k" like '"v"'")) keys targpatts)
		    " AND "))
	 (field-sel (string-intersperse keys ","))
	 (fullqry   (conc "SELECT "field-sel",runname FROM runs WHERE "selector";")))
    (print "fullqry="fullqry)
    (fold-row ;; proc init db-or-stmt . params)
     (lambda (res . row)
       (cons row res))
     '()
     (mtdb-db mtdbh) ;; get the db handle
     fullqry)))
     


;; gui utils
;;

(define (message-window msg)
  (iup:show
   (iup:dialog
    (iup:vbox 
228
229
230
231
232
233
234
235
236
237

238





239
240
241
242
243
244
245
   #:size "10x"
   #:selection-cb
   (lambda (obj id state)
     (let* ((path (tree:node->path obj id)))
       (match path
	 ((treename) #f) ;;(print "nothing to do here"))
	 ((treename area)
	  (let ((tb (get-widget "main-tree")))
	    (refresh-targets tb area)))
	 ((treename area . target)

	  (print "area: "area", target: "target))





	 (else
	  (print "path: "path))
	  )
       #;(print "obj: "obj", id: "id", state: "state", path: "path)))))

(define (refresh-targets tb area)
  (let* ((targets (megatest-get-targets area)))







|


>
|
>
>
>
>
>







284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
   #:size "10x"
   #:selection-cb
   (lambda (obj id state)
     (let* ((path (tree:node->path obj id)))
       (match path
	 ((treename) #f) ;;(print "nothing to do here"))
	 ((treename area)
	  (let ((tb (get-widget "main-tree"))) ;; wait, isn't this just "obj"?
	    (refresh-targets tb area)))
	 ((treename area . target)
	  (let* ((keys (megatest-get-keys area)))
	    (if (eq? (length keys)(length target))
		(let* ((runnames (megatest-get-run-names area keys target)))
		  (for-each
		   (lambda (runnamedat)
		     (tree:add-node obj "Areas" (cons area runnamedat)))
		   runnames)))))
	 (else
	  (print "path: "path))
	  )
       #;(print "obj: "obj", id: "id", state: "state", path: "path)))))

(define (refresh-targets tb area)
  (let* ((targets (megatest-get-targets area)))