Megatest

Changes On Branch 6a17d0fc676e57e0
Login

Changes In Branch xor-two-runs Excluding Merge-Ins

This is equivalent to a diff from 972c78f746 to 6a17d0fc67

2016-09-12
13:53
merged in latest fixes from v1.61 check-in: 485ad7daba user: bjbarcla tags: v1.62
2016-09-08
14:44
merged with 1.62 check-in: 1029496a83 user: srehman tags: refactor-db-v1.61-shoeb
2016-09-07
17:41
merged with v1.62 check-in: 4772788ce1 user: srehman tags: refactor-db-v1.61-shoeb
15:32
merged 1.62 Leaf check-in: 6a17d0fc67 user: bjbarcla tags: xor-two-runs
2016-09-06
16:14
fixed slider; tweaked some diff state colors check-in: 81a014242f user: bjbarcla tags: xor-two-runs
2016-08-26
10:59
Merged recent changes to v1.62 check-in: 972c78f746 user: mrwellan tags: v1.62
09:36
Merging trunk into v1.61 check-in: 61fbb64361 user: mrwellan tags: v1.61
2016-08-18
09:01
Start work on v1.62 check-in: 279a373046 user: mrwellan tags: v1.62

Modified dashboard.scm from [9804b2cd5c] to [3b1856c03f].

204
205
206
207
208
209
210
211
212
213





214
215
216
217
218
219
220
  ((command          "")                 : string)      ;; for run control this is the command being built up
  (command-tb        #f)			         
  (key-listboxes     #f)			         
  (key-lbs           #f)			         
  run-name                                              ;; from run name setting widget
  states                                                ;; states for -state s1,s2 ...
  statuses                                              ;; statuses for -status s1,s2 ...
						         
  ;; Selector variables				         
  curr-run-id                                           ;; current row to display in Run summary view





  curr-test-ids                                         ;; used only in dcommon:run-update which is used in newdashboard
  ((filters-changed  #f)                  : boolean)    ;; to to indicate that the user changed filters for this tab
  ((last-filter-str  "")                  : string)      ;; conc the target runname and testpatt for a signature of changed filters
  ((hide-empty-runs  #f)                  : boolean)     
  ((hide-not-hide    #t)                  : boolean)     ;; toggle for hide/not hide empty runs
  (hide-not-hide-button #f)
  ((searchpatts        (make-hash-table)) : hash-table)  ;;







<


>
>
>
>
>







204
205
206
207
208
209
210

211
212
213
214
215
216
217
218
219
220
221
222
223
224
  ((command          "")                 : string)      ;; for run control this is the command being built up
  (command-tb        #f)			         
  (key-listboxes     #f)			         
  (key-lbs           #f)			         
  run-name                                              ;; from run name setting widget
  states                                                ;; states for -state s1,s2 ...
  statuses                                              ;; statuses for -status s1,s2 ...

  ;; Selector variables				         
  curr-run-id                                           ;; current row to display in Run summary view
  prev-run-id                                           ;; previous runid selected before current runid was selected
  (xor-src-runid-label #f)
  (xor-dest-runid-label #f)
  (mode-flag (make-parameter 'view-one-run))
  
  curr-test-ids                                         ;; used only in dcommon:run-update which is used in newdashboard
  ((filters-changed  #f)                  : boolean)    ;; to to indicate that the user changed filters for this tab
  ((last-filter-str  "")                  : string)      ;; conc the target runname and testpatt for a signature of changed filters
  ((hide-empty-runs  #f)                  : boolean)     
  ((hide-not-hide    #t)                  : boolean)     ;; toggle for hide/not hide empty runs
  (hide-not-hide-button #f)
  ((searchpatts        (make-hash-table)) : hash-table)  ;;
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
		   (car (dashboard:update-target-selector tabdat))))
	(curr-runname (dboard:tabdat-run-name tabdat)))
    (dboard:tabdat-target-set! tabdat targ)
    ;; (if (dboard:tabdat-updater-for-runs tabdat)
    ;; 	 ((dboard:tabdat-updater-for-runs tabdat)))
    (if (or (not (equal? curr-runname (dboard:tabdat-run-name tabdat)))
	    (equal? (dboard:tabdat-run-name tabdat) ""))
	(dboard:tabdat-run-name-set! tabdat curr-runname))
    (dashboard:update-run-command tabdat)))

(define (dashboard:run-controls commondat tabdat #!key (tab-num #f))
  (let* ((targets       (make-hash-table))
	 (test-records  (make-hash-table))
	 (all-tests-registry (tests:get-all)) ;; (tests:get-valid-tests *toppath* '()))
	 (test-names    (hash-table-keys all-tests-registry))







|







1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
		   (car (dashboard:update-target-selector tabdat))))
	(curr-runname (dboard:tabdat-run-name tabdat)))
    (dboard:tabdat-target-set! tabdat targ)
    ;; (if (dboard:tabdat-updater-for-runs tabdat)
    ;; 	 ((dboard:tabdat-updater-for-runs tabdat)))
    (if (or (not (equal? curr-runname (dboard:tabdat-run-name tabdat)))
	    (equal? (dboard:tabdat-run-name tabdat) ""))
        (dboard:tabdat-run-name-set! tabdat curr-runname))
    (dashboard:update-run-command tabdat)))

(define (dashboard:run-controls commondat tabdat #!key (tab-num #f))
  (let* ((targets       (make-hash-table))
	 (test-records  (make-hash-table))
	 (all-tests-registry (tests:get-all)) ;; (tests:get-valid-tests *toppath* '()))
	 (test-names    (hash-table-keys all-tests-registry))
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165

























1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179




1180
1181
1182
1183




1184




1185
1186
1187
1188
1189
1190
1191
    
    ;; refer to (dboard:tabdat-keys tabdat), (dboard:tabdat-dbkeys tabdat) for keys
    (iup:vbox
     (dcommon:command-execution-control tabdat)
     (iup:split
      #:orientation "VERTICAL" ;; "HORIZONTAL"
      #:value 200
;; 
;;       (iup:split
;;        #:value 300

       ;; Target, testpatt, state and status input boxes
       ;;
       (iup:vbox
	;; Command to run, placed over the top of the canvas
	(dcommon:command-action-selector commondat tabdat tab-num: tab-num)
	(dcommon:command-runname-selector commondat tabdat tab-num: tab-num)
	(dcommon:command-testname-selector commondat tabdat update-keyvals)) ;;  key-listboxes))
       
       (dcommon:command-tests-tasks-canvas tabdat test-records sorted-testnames tests-draw-state))
       
 ;;(iup:frame
 ;; #:title "Logs" ;; To be replaced with tabs
 ;; (let ((logs-tb (iup:textbox #:expand "YES"
 ;;				   #:multiline "YES")))
 ;;	 (dboard:tabdat-logs-textbox-set! tabdat logs-tb)
 ;;	 logs-tb))

























      )))

(define (dboard:runs-tree-browser commondat tabdat)
  (let* ((tb      (iup:treebox
		   #:value 0
		   #:name "Runs"
		   #:expand "YES"
		   #:addexpanded "NO"
		   #:selection-cb
		   (lambda (obj id state)
		     (debug:catch-and-dump
		      (lambda ()
			(let* ((run-path (tree:node->path obj id))
			       (run-id    (tree-path->run-id tabdat (cdr run-path))))




			  (dboard:tabdat-target-set! tabdat (cdr run-path)) ;; (print "run-path: " run-path)			    
			  (dboard:tabdat-layout-update-ok-set! tabdat #f)
			  (if (number? run-id)
			      (begin




				(dboard:tabdat-curr-run-id-set! tabdat run-id)




				(dboard:tabdat-view-changed-set! tabdat #t))
			      (debug:print-error 5 *default-log-port* "tree-path->run-id returned non-number " run-id))))
		      "treebox"))
		   ;; (print "path: " (tree:node->path obj id) " run-id: " run-id)
		   )))
    (dboard:tabdat-runs-tree-set! tabdat tb)
    tb))







|
|
|

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













|
>
>
>
>
|



>
>
>
>

>
>
>
>







1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
    
    ;; refer to (dboard:tabdat-keys tabdat), (dboard:tabdat-dbkeys tabdat) for keys
    (iup:vbox
     (dcommon:command-execution-control tabdat)
     (iup:split
      #:orientation "VERTICAL" ;; "HORIZONTAL"
      #:value 200
      ;; 
      ;;       (iup:split
      ;;        #:value 300

      ;; Target, testpatt, state and status input boxes
      ;;
      (iup:vbox
       ;; Command to run, placed over the top of the canvas
       (dcommon:command-action-selector commondat tabdat tab-num: tab-num)
       (dcommon:command-runname-selector commondat tabdat tab-num: tab-num)
       (dcommon:command-testname-selector commondat tabdat update-keyvals)) ;;  key-listboxes))
      
      (dcommon:command-tests-tasks-canvas tabdat test-records sorted-testnames tests-draw-state))
     
     ;;(iup:frame
     ;; #:title "Logs" ;; To be replaced with tabs
     ;; (let ((logs-tb (iup:textbox #:expand "YES"
     ;;				   #:multiline "YES")))
     ;;	 (dboard:tabdat-logs-textbox-set! tabdat logs-tb)
     ;;	 logs-tb))
     )))

(define (dboard:xor-ui-update tabdat)
  (let* ((mode-flag (dboard:tabdat-mode-flag tabdat))
         (current-mode (mode-flag))
         (xor-src-runid-label  (dboard:tabdat-xor-src-runid-label tabdat))
         (xor-dest-runid-label (dboard:tabdat-xor-dest-runid-label tabdat))
         (curr-run-id          (dboard:tabdat-curr-run-id tabdat))
         (prev-run-id          (dboard:tabdat-prev-run-id tabdat))
         (curr-runname (if curr-run-id
                           (rmt:get-run-name-from-id curr-run-id)
                           "None"))
         (prev-runname (if prev-run-id
                           (rmt:get-run-name-from-id prev-run-id)
                           "None"))
         )
    
    (case current-mode
      ((view-one-run)
       (iup:attribute-set! xor-src-runid-label "TITLE" "")
       (iup:attribute-set! xor-dest-runid-label "TITLE" ""))
      ((xor-two-runs)
       (iup:attribute-set! xor-src-runid-label "TITLE" (conc " SRC: "prev-runname"  "))
       (iup:attribute-set! xor-dest-runid-label "TITLE" (conc "DEST: "curr-runname"  ")))
      (else (print "BB> should never arrive here"))
      )))

(define (dboard:runs-tree-browser commondat tabdat)
  (let* ((tb      (iup:treebox
		   #:value 0
		   #:name "Runs"
		   #:expand "YES"
		   #:addexpanded "NO"
		   #:selection-cb
		   (lambda (obj id state)
		     (debug:catch-and-dump
		      (lambda ()
			(let* ((run-path (tree:node->path obj id))
			       (run-id    (tree-path->run-id tabdat (cdr run-path)))
                               (curr-runname (dboard:tabdat-run-name tabdat)))


                          
                          (dboard:tabdat-target-set! tabdat (cdr run-path)) ;; (print "run-path: " run-path)			    
			  (dboard:tabdat-layout-update-ok-set! tabdat #f)
			  (if (number? run-id)
			      (begin
                                ;; capture last two in tabdat.
                                (dboard:tabdat-prev-run-id-set!
                                 tabdat
                                 (dboard:tabdat-curr-run-id tabdat))
				(dboard:tabdat-curr-run-id-set! tabdat run-id)

                                (dboard:tabdat-run-name-set! tabdat curr-runname)

                                (dboard:xor-ui-update tabdat)
				(dboard:tabdat-view-changed-set! tabdat #t))
			      (debug:print-error 5 *default-log-port* "tree-path->run-id returned non-number " run-id))))
		      "treebox"))
		   ;; (print "path: " (tree:node->path obj id) " run-id: " run-id)
		   )))
    (dboard:tabdat-runs-tree-set! tabdat tb)
    tb))
1298
1299
1300
1301
1302
1303
1304





1305
1306
1307
1308
1309
1310
1311
;;
;; display and manage a single run at a time

(define (tree-path->run-id tabdat path)
  (if (not (null? path))
      (hash-table-ref/default (dboard:tabdat-path-run-ids tabdat) path #f)
      #f))






(define (dboard:get-tests-dat tabdat run-id last-update)
  (let* ((tdat (if run-id (rmt:get-tests-for-run run-id 
					     (hash-table-ref/default (dboard:tabdat-searchpatts tabdat) "test-name" "%/%")
					     (hash-table-keys (dboard:tabdat-state-ignore-hash tabdat))  ;; '()
					     (hash-table-keys (dboard:tabdat-status-ignore-hash tabdat)) ;; '()
					     #f #f                                                       ;; offset limit







>
>
>
>
>







1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
;;
;; display and manage a single run at a time

(define (tree-path->run-id tabdat path)
  (if (not (null? path))
      (hash-table-ref/default (dboard:tabdat-path-run-ids tabdat) path #f)
      #f))

(define (tree-path->run-name tabdat path)
  (if (not (null? path))
      (hash-table-ref/default (dboard:tabdat-path-run-ids tabdat) path #f)
      #f))

(define (dboard:get-tests-dat tabdat run-id last-update)
  (let* ((tdat (if run-id (rmt:get-tests-for-run run-id 
					     (hash-table-ref/default (dboard:tabdat-searchpatts tabdat) "test-name" "%/%")
					     (hash-table-keys (dboard:tabdat-state-ignore-hash tabdat))  ;; '()
					     (hash-table-keys (dboard:tabdat-status-ignore-hash tabdat)) ;; '()
					     #f #f                                                       ;; offset limit
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373


1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
			;; Here we update the tests treebox and tree keys
			(tree:add-node tb "Runs" run-path ;; (append key-vals (list run-name))
				       userdata: (conc "run-id: " run-id))
			(hash-table-set! (dboard:tabdat-path-run-ids tabdat) run-path run-id)
			;; (set! colnum (+ colnum 1))
			))))
	      run-ids)))
  
(define (dashboard:one-run-updater commondat tabdat tb cell-lookup run-matrix)
  (let* ((runs-dat     (rmt:get-runs-by-patt (dboard:tabdat-keys tabdat) "%" #f #f #f #f))
	 (runs-header  (vector-ref runs-dat 0)) ;; 0 is header, 1 is list of records
	 (run-id       (dboard:tabdat-curr-run-id tabdat))
	 (last-update  (hash-table-ref/default (dboard:tabdat-run-update-times tabdat) run-id 0))


	 (db-path      (or (hash-table-ref/default (dboard:tabdat-run-db-paths tabdat) run-id #f)
			   (let* ((db-dir (tasks:get-task-db-path))
				  (db-pth (conc db-dir "/" run-id ".db")))
			     (hash-table-set! (dboard:tabdat-run-db-paths tabdat) run-id db-pth)
			     db-pth)))
	 (tests-dat    (if (or (not run-id)
			       (configf:lookup *configdat* "setup" "do-not-use-db-file-timestamps")
			       (>= (file-modification-time db-path) last-update))
			   (dboard:get-tests-dat tabdat run-id last-update)
			   (dboard:tabdat-last-test-dat  tabdat)))
	 (tests-mindat (dcommon:minimize-test-data tests-dat))
	 (indices      (common:sparse-list-generate-index tests-mindat)) ;;  proc: set-cell))
	 (row-indices  (cadr indices))
	 (col-indices  (car indices))
	 (max-row      (if (null? row-indices) 1 (common:max (map cadr row-indices))))
	 (max-col      (if (null? col-indices) 1 (common:max (map cadr col-indices))))
	 (max-visible  (max (- (dboard:tabdat-num-tests tabdat) 15) 3)) ;; (dboard:tabdat-num-tests tabdat) is proportional to the size of the window
	 (numrows      1)







|
|




>
>










<







1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431

1432
1433
1434
1435
1436
1437
1438
			;; Here we update the tests treebox and tree keys
			(tree:add-node tb "Runs" run-path ;; (append key-vals (list run-name))
				       userdata: (conc "run-id: " run-id))
			(hash-table-set! (dboard:tabdat-path-run-ids tabdat) run-path run-id)
			;; (set! colnum (+ colnum 1))
			))))
	      run-ids)))

(define (dashboard:one-run-updater commondat tabdat tb cell-lookup run-matrix )
  (let* ((runs-dat     (rmt:get-runs-by-patt (dboard:tabdat-keys tabdat) "%" #f #f #f #f))
	 (runs-header  (vector-ref runs-dat 0)) ;; 0 is header, 1 is list of records
	 (run-id       (dboard:tabdat-curr-run-id tabdat))
	 (last-update  (hash-table-ref/default (dboard:tabdat-run-update-times tabdat) run-id 0))
	 (tests-dat    (dboard:get-tests-dat tabdat run-id last-update)) ;; does query to get run info
	 (tests-mindat (dcommon:minimize-test-data tests-dat))  ;; reduces data for display
	 (db-path      (or (hash-table-ref/default (dboard:tabdat-run-db-paths tabdat) run-id #f)
			   (let* ((db-dir (tasks:get-task-db-path))
				  (db-pth (conc db-dir "/" run-id ".db")))
			     (hash-table-set! (dboard:tabdat-run-db-paths tabdat) run-id db-pth)
			     db-pth)))
	 (tests-dat    (if (or (not run-id)
			       (configf:lookup *configdat* "setup" "do-not-use-db-file-timestamps")
			       (>= (file-modification-time db-path) last-update))
			   (dboard:get-tests-dat tabdat run-id last-update)
			   (dboard:tabdat-last-test-dat  tabdat)))

	 (indices      (common:sparse-list-generate-index tests-mindat)) ;;  proc: set-cell))
	 (row-indices  (cadr indices))
	 (col-indices  (car indices))
	 (max-row      (if (null? row-indices) 1 (common:max (map cadr row-indices))))
	 (max-col      (if (null? col-indices) 1 (common:max (map cadr col-indices))))
	 (max-visible  (max (- (dboard:tabdat-num-tests tabdat) 15) 3)) ;; (dboard:tabdat-num-tests tabdat) is proportional to the size of the window
	 (numrows      1)
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
			 (key  (conc num ":0")))
		    (if (not (equal? (iup:attribute run-matrix key) name))
			(begin
			  (set! changed #t)
			  (iup:attribute-set! run-matrix key name)))))
		row-indices)
      
      ;; (print "row-indices: " row-indices " col-indices: " col-indices)
      (if (and (eq? pass-num 0) changed)
	  (loop 1 #t)) ;; force second pass
      
      ;; Cell contents
      (for-each (lambda (entry)
		  ;; (print "entry: " entry)
		  (let* ((row-name  (cadr entry))







|







1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
			 (key  (conc num ":0")))
		    (if (not (equal? (iup:attribute run-matrix key) name))
			(begin
			  (set! changed #t)
			  (iup:attribute-set! run-matrix key name)))))
		row-indices)
      
;;(print "row-indices: " row-indices " col-indices: " col-indices)
      (if (and (eq? pass-num 0) changed)
	  (loop 1 #t)) ;; force second pass
      
      ;; Cell contents
      (for-each (lambda (entry)
		  ;; (print "entry: " entry)
		  (let* ((row-name  (cadr entry))
1465
1466
1467
1468
1469
1470
1471








































































































1472
1473
1474
1475
1476
1477
1478
      
      (if (and (eq? pass-num 0) changed)
	  (loop 1 #t)) ;; force second pass due to column labels changing
      
      ;; (debug:print 0 *default-debug-port* "one-run-updater, changed: " changed " pass-num: " pass-num)
      ;; (print "one-run-updater, changed: " changed " pass-num: " pass-num)
      (if changed (iup:attribute-set! run-matrix "REDRAW" "ALL")))))









































































































;;======================================================================
;; S U M M A R Y 
;;======================================================================
;;
;; General info about the run(s) and megatest area
(define (dashboard:summary commondat tabdat #!key (tab-num #f))







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
      
      (if (and (eq? pass-num 0) changed)
	  (loop 1 #t)) ;; force second pass due to column labels changing
      
      ;; (debug:print 0 *default-debug-port* "one-run-updater, changed: " changed " pass-num: " pass-num)
      ;; (print "one-run-updater, changed: " changed " pass-num: " pass-num)
      (if changed (iup:attribute-set! run-matrix "REDRAW" "ALL")))))




(define (dashboard:xor-two-runs-updater commondat tabdat tb cell-lookup run-matrix )
  (let* ((runs-dat     (rmt:get-runs-by-patt (dboard:tabdat-keys tabdat) "%" #f #f #f #f))
	 (runs-header  (vector-ref runs-dat 0)) ;; 0 is header, 1 is list of records
         (prev-run-id       (dboard:tabdat-prev-run-id tabdat))
	 (curr-run-id       (dboard:tabdat-curr-run-id tabdat))
	 (last-update  0) ;; fix me - have to create and store a rundat record for this
	 (dest-tests-dat    (dboard:get-tests-dat tabdat curr-run-id last-update)) ;; does query to get run info
         (src-tests-dat    (dboard:get-tests-dat tabdat prev-run-id last-update)) ;; does query to get run info

         ;;; STOPPED HERE
         (dest-tests-mindat (dcommon:minimize-test-data dest-tests-dat))  ;; reduces data for display
         (src-tests-mindat (dcommon:minimize-test-data src-tests-dat))  ;; reduces data for display
         ;;(tests-mindat dest-tests-mindat)
         (tests-mindat (dcommon:xor-tests-mindat src-tests-mindat dest-tests-mindat)) ;; TODO: flags for common, modified, new -- like meld
	 (indices      (common:sparse-list-generate-index tests-mindat)) ;;  proc: set-cell))
	 (row-indices  (cadr indices))
	 (col-indices  (car indices))
	 (max-row      (if (null? row-indices) 1 (common:max (map cadr row-indices))))
	 (max-col      (if (null? col-indices) 1 (common:max (map cadr col-indices))))
	 (max-visible  (max (- (dboard:tabdat-num-tests tabdat) 15) 3)) ;; (dboard:tabdat-num-tests tabdat) is proportional to the size of the window
	 (numrows      1)
	 (numcols      1)
	 (changed      #f)
	 (runs-hash    (let ((ht (make-hash-table)))
			 (for-each (lambda (run)
				     (hash-table-set! ht (db:get-value-by-header run runs-header "id") run))
				   (vector-ref runs-dat 1))
			 ht)))
    (dboard:tabdat-filters-changed-set! tabdat #f)
    (let loop ((pass-num 0)
	       (changed  #f))
      ;; Update the runs tree
      (dboard:update-tree tabdat runs-hash runs-header tb)

(if (eq? pass-num 1)
	  (begin ;; big reset
    (iup:attribute-set! run-matrix "CLEARVALUE" "ALL") ;; NOTE: Was CONTENTS
    (iup:attribute-set! run-matrix "CLEARATTRIB" "CONTENTS")
    (iup:attribute-set! run-matrix "RESIZEMATRIX" "YES")
    (iup:attribute-set! run-matrix "NUMCOL" max-col )
    (iup:attribute-set! run-matrix "NUMLIN" (if (< max-row max-visible) max-visible max-row)))) ;; min of 20

    ;; Row labels
    (for-each (lambda (ind)
		(let* ((name (car ind))
		       (num  (cadr ind))
		       (key  (conc num ":0")))
		  (if (not (equal? (iup:attribute run-matrix key) name))
		      (begin
			(set! changed #t)
			(iup:attribute-set! run-matrix key name)))))
	      row-indices)
    
;;(print "row-indices: " row-indices " col-indices: " col-indices)
      (if (and (eq? pass-num 0) changed)
	  (loop 1 #t)) ;; force second pass

    ;; Cell contents
    (for-each (lambda (entry)
		;; (print "entry: " entry)
		(let* ((row-name  (cadr entry))
		       (col-name  (car entry))
		       (valuedat  (caddr entry))
		       (test-id   (list-ref valuedat 0))
		       (test-name row-name) ;; (list-ref valuedat 1))
		       (item-path col-name) ;; (list-ref valuedat 2))
		       (state     (list-ref valuedat 1))
		       (status    (list-ref valuedat 2))
		       (value     (gutils:get-color-for-state-status state status))
		       (row-num   (cadr (assoc row-name row-indices)))
		       (col-num   (cadr (assoc col-name col-indices)))
		       (key       (conc row-num ":" col-num)))
		  (hash-table-set! cell-lookup key test-id)
		  (if (not (equal? (iup:attribute run-matrix key) (cadr value)))
		      (begin
			(set! changed #t)
			(iup:attribute-set! run-matrix key (cadr value))
			(iup:attribute-set! run-matrix (conc "BGCOLOR" key) (car value))))))
	      tests-mindat)
    
    ;; Col labels - do after setting Cell contents so they are accounted for in the size calc.

    (for-each (lambda (ind)
		(let* ((name (car ind))
		       (num  (cadr ind))
		       (key  (conc "0:" num)))
		  (if (not (equal? (iup:attribute run-matrix key) name))
		      (begin
			(set! changed #t)
			(iup:attribute-set! run-matrix key name)
			(iup:attribute-set! run-matrix "FITTOTEXT" (conc "C" num))))))
	      col-indices)

      (if (and (eq? pass-num 0) changed)
	  (loop 1 #t)) ;; force second pass due to column labels changing

      ;; (debug:print 0 *default-debug-port* "one-run-updater, changed: " changed " pass-num: " pass-num)
      ;; (print "one-run-updater, changed: " changed " pass-num: " pass-num)
      (if changed (iup:attribute-set! run-matrix "REDRAW" "ALL")))))


;;======================================================================
;; S U M M A R Y 
;;======================================================================
;;
;; General info about the run(s) and megatest area
(define (dashboard:summary commondat tabdat #!key (tab-num #f))
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525




1526




1527
1528
1529
1530

1531
1532
1533
1534

1535


1536
1537





1538






1539
1540










1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553


1554






1555
1556


1557

1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752

;; (define dashboard:update-run-summary-tab #f)
;; (define dashboard:update-new-view-tab #f)

;; This is the Run Summary tab
;; 
(define (dashboard:one-run commondat tabdat #!key (tab-num #f))
  (let* ((tb      (iup:treebox
		   #:value 0
		   #:name "Runs"
		   #:expand "YES"




		   #:addexpanded "NO"




		   #:selection-cb
		   (lambda (obj id state)
		     ;; (print "obj: " obj ", id: " id ", state: " state)
		     (let* ((run-path (tree:node->path obj id))

			    (run-id   (tree-path->run-id tabdat (cdr run-path))))
		       (if (number? run-id)
			   (begin
			     (dboard:tabdat-curr-run-id-set! tabdat run-id)

			     (dboard:tabdat-layout-update-ok-set! tabdat #f)


			     ;; (dashboard:update-run-summary-tab)
			     )





			   ;; (debug:print-error 0 *default-log-port* "tree-path->run-id returned non-number " run-id)






			   ))
		     ;; (print "path: " (tree:node->path obj id) " run-id: " run-id)










		     )))
	 (cell-lookup (make-hash-table))
	 (run-matrix (iup:matrix
		      #:expand "YES"
		      #:click-cb
		      (lambda (obj lin col status)
			(let* ((toolpath (car (argv)))
			       (key      (conc lin ":" col))
			       (test-id  (hash-table-ref/default cell-lookup key -1))
			       (cmd      (conc toolpath " -test " (dboard:tabdat-curr-run-id tabdat) "," test-id "&")))
			  (system cmd)))))
	 (one-run-updater  (lambda ()
			     (if  (dashboard:database-changed? commondat tabdat)


				  (dashboard:one-run-updater commondat tabdat tb cell-lookup run-matrix)))))






    (dboard:commondat-add-updater commondat one-run-updater tab-num: tab-num)
    (dboard:tabdat-runs-tree-set! tabdat tb)


    (iup:split

     tb
     run-matrix)))
;;     (iup:vbox
;;      (let* ((cnv-obj (iup:canvas 
;; 		     ;; #:size "500x400"
;; 		     #:expand "YES"
;; 		     #:scrollbar "YES"
;; 		     #:posx "0.5"
;; 		     #:posy "0.5"
;; 		     #:action (make-canvas-action
;; 			       (lambda (c xadj yadj)
;; 				 (debug:catch-and-dump
;; 				  (lambda ()
;; 				    (if (not (dboard:tabdat-cnv tabdat))
;; 					(dboard:tabdat-cnv-set! tabdat c))
;; 				    (let ((drawing (dboard:tabdat-drawing tabdat))
;; 					  (old-xadj (dboard:tabdat-xadj   tabdat))
;; 					  (old-yadj (dboard:tabdat-yadj   tabdat)))
;; 				      (if (not (and (eq? xadj old-xadj)(eq? yadj old-yadj)))
;; 					  (begin
;; 					    (print  "xadj: " xadj " yadj: " yadj "changed: "(eq? xadj old-xadj) " " (eq? yadj old-yadj))
;; 					    (dboard:tabdat-view-changed-set! tabdat #t)
;; 					    (dboard:tabdat-xadj-set! tabdat (* -500 (- xadj 0.5)))
;; 					    (dboard:tabdat-yadj-set! tabdat (*  500 (- yadj 0.5)))
;; 					    ))))
;; 				  "iup:canvas action dashboard:one-run")))
;; 		     #:wheel-cb (lambda (obj step x y dir) ;; dir is 4 for up and 5 for down. I think.
;; 				  (debug:catch-and-dump
;; 				   (lambda ()
;; 				     (let* ((drawing (dboard:tabdat-drawing tabdat))
;; 					    (scalex  (vg:drawing-scalex drawing)))
;; 				       (dboard:tabdat-view-changed-set! tabdat #t)
;; 				       (print "step: " step " x: " x " y: " y " dir: " dir " scalex: " scalex)
;; 				       (vg:drawing-scalex-set! drawing
;; 							       (+ scalex
;; 								  (if (> step 0)
;; 								      (* scalex  0.02)
;; 								      (* scalex -0.02))))))
;; 				   "dashboard:one-run wheel-cb"))
;; 		     )))
;;        cnv-obj))))


;; This is the New View tab
;; 
;; (define (dashboard:new-view db commondat tabdat #!key (tab-num #f))
;;   (let* ((tb      (iup:treebox
;; 		   #:value 0
;; 		   #:name "Runs"
;; 		   #:expand "YES"
;; 		   #:addexpanded "NO"
;; 		   #:selection-cb
;; 		   (lambda (obj id state)
;; 		     ;; (print "obj: " obj ", id: " id ", state: " state)
;; 		     (let* ((run-path (tree:node->path obj id))
;; 			    (run-id   (tree-path->run-id tabdat (cdr run-path))))
;; 		       (if (number? run-id)
;; 			   (begin
;; 			     (dboard:tabdat-curr-run-id-set! tabdat run-id)
;; 			     ;; (dashboard:update-new-view-tab)
;; 			     (dboard:tabdat-layout-update-ok-set! tabdat #f)
;; 			     )
;; 			   (debug:print-error 0 *default-log-port* "tree-path->run-id returned non-number " run-id)))
;; 		     ;; (print "path: " (tree:node->path obj id) " run-id: " run-id)
;; 		     )))
;; 	 (cell-lookup (make-hash-table))
;; 	 (run-matrix (iup:matrix
;; 		      #:expand "YES"
;; 		      #:click-cb
;; 		      (lambda (obj lin col status)
;; 			(let* ((toolpath (car (argv)))
;; 			       (key      (conc lin ":" col))
;; 			       (test-id  (hash-table-ref/default cell-lookup key -1))
;; 			       (cmd      (conc toolpath " -test " (dboard:tabdat-curr-run-id tabdat) "," test-id "&")))
;; 			  (system cmd)))))
;; 	 (new-view-updater  (lambda ()
;; 			      (if  (dashboard:database-changed? commondat tabdat)
;; 				   (let* ((runs-dat     (rmt:get-runs-by-patt (dboard:tabdat-keys tabdat) "%" #f #f #f #f))
;; 					  (runs-header  (vector-ref runs-dat 0)) ;; 0 is header, 1 is list of records
;; 					  (run-id       (dboard:tabdat-curr-run-id tabdat))
;; 					  (last-update  0) ;; fix me
;; 					  (tests-dat    (dboard:get-tests-dat tabdat run-id last-update))
;; 					  (tests-mindat (dcommon:minimize-test-data tests-dat))
;; 					  (indices      (common:sparse-list-generate-index tests-mindat)) ;;  proc: set-cell))
;; 					  (row-indices  (cadr indices))
;; 					  (col-indices  (car indices))
;; 					  (max-row      (if (null? row-indices) 1 (common:max (map cadr row-indices))))
;; 					  (max-col      (if (null? col-indices) 1 (common:max (map cadr col-indices))))
;; 					  (max-visible  (max (- (dboard:tabdat-num-tests tabdat) 15) 3)) ;; (dboard:tabdat-num-tests tabdat) is proportional to the size of the window
;; 					  (numrows      1)
;; 					  (numcols      1)
;; 					  (changed      #f)
;; 					  (runs-hash    (let ((ht (make-hash-table)))
;; 							  (for-each (lambda (run)
;; 								      (hash-table-set! ht (db:get-value-by-header run runs-header "id") run))
;; 								    (vector-ref runs-dat 1))
;; 							  ht))
;; 					  (run-ids      (sort (filter number? (hash-table-keys runs-hash))
;; 							      (lambda (a b)
;; 								(let* ((record-a (hash-table-ref runs-hash a))
;; 								       (record-b (hash-table-ref runs-hash b))
;; 								       (time-a   (db:get-value-by-header record-a runs-header "event_time"))
;; 								       (time-b   (db:get-value-by-header record-b runs-header "event_time")))
;; 								  (< time-a time-b))))))
;; 				     ;; (iup:attribute-set! tb "VALUE" "0")
;; 				     ;; (iup:attribute-set! tb "NAME" "Runs")
;; 				     ;; Update the runs tree
;; 				     (for-each (lambda (run-id)
;; 						 (let* ((run-record (hash-table-ref/default runs-hash run-id #f))
;; 							(key-vals   (map (lambda (key)(db:get-value-by-header run-record runs-header key))
;; 									 (dboard:tabdat-keys tabdat)))
;; 							(run-name   (db:get-value-by-header run-record runs-header "runname"))
;; 							(col-name   (conc (string-intersperse key-vals "\n") "\n" run-name))
;; 							(run-path   (append key-vals (list run-name)))
;; 							(existing   (tree:find-node tb run-path)))
;; 						   (if (not (hash-table-ref/default (dboard:tabdat-path-run-ids tabdat) run-path #f))
;; 						       (begin
;; 							 (hash-table-set! (dboard:tabdat-run-keys tabdat) run-id run-path)
;; 							 ;; (iup:attribute-set! (dboard:tabdat-runs-matrix tabdat)
;; 							 ;;    		 (conc rownum ":" colnum) col-name)
;; 							 ;; (hash-table-set! runid-to-col run-id (list colnum run-record))
;; 							 ;; Here we update the tests treebox and tree keys
;; 							 (tree:add-node tb "Runs" run-path ;; (append key-vals (list run-name))
;; 									userdata: (conc "run-id: " run-id))
;; 							 (hash-table-set! (dboard:tabdat-path-run-ids tabdat) run-path run-id)
;; 							 ;; (set! colnum (+ colnum 1))
;; 							 ))))
;; 					       run-ids)
;; 				     (iup:attribute-set! run-matrix "CLEARVALUE" "ALL") ;; NOTE: Was CONTENTS
;; 				     (iup:attribute-set! run-matrix "CLEARATTRIB" "CONTENTS")
;; 				     (iup:attribute-set! run-matrix "RESIZEMATRIX" "YES")
;; 				     (iup:attribute-set! run-matrix "NUMCOL" max-col )
;; 				     (iup:attribute-set! run-matrix "NUMLIN" (if (< max-row max-visible) max-visible max-row)) ;; min of 20
;; 				     ;; (iup:attribute-set! run-matrix "NUMCOL_VISIBLE" max-col)
;; 				     ;; (iup:attribute-set! run-matrix "NUMLIN_VISIBLE" (if (> max-row max-visible) max-visible max-row))
;; 				     
;; 				     ;; Row labels
;; 				     (for-each (lambda (ind)
;; 						 (let* ((name (car ind))
;; 							(num  (cadr ind))
;; 							(key  (conc num ":0")))
;; 						   (if (not (equal? (iup:attribute run-matrix key) name))
;; 						       (begin
;; 							 (set! changed #t)
;; 							 (iup:attribute-set! run-matrix key name)))))
;; 					       row-indices)
;; 
;; 				     
;; 				     ;; Cell contents
;; 				     (for-each (lambda (entry)
;; 						 (let* ((row-name  (cadr entry))
;; 							(col-name  (car entry))
;; 							(valuedat  (caddr entry))
;; 							(test-id   (list-ref valuedat 0))
;; 							(test-name row-name) ;; (list-ref valuedat 1))
;; 							(item-path col-name) ;; (list-ref valuedat 2))
;; 							(state     (list-ref valuedat 1))
;; 							(status    (list-ref valuedat 2))
;; 							(value     (gutils:get-color-for-state-status state status))
;; 							(row-num   (cadr (assoc row-name row-indices)))
;; 							(col-num   (cadr (assoc col-name col-indices)))
;; 							(key       (conc row-num ":" col-num)))
;; 						   (hash-table-set! cell-lookup key test-id)
;; 						   (if (not (equal? (iup:attribute run-matrix key) (cadr value)))
;; 						       (begin
;; 							 (set! changed #t)
;; 							 (iup:attribute-set! run-matrix key (cadr value))
;; 							 (iup:attribute-set! run-matrix (conc "BGCOLOR" key) (car value))))))
;; 					       tests-mindat)
;; 				     
;; 				     ;; Col labels - do after setting Cell contents so they are accounted for in the size calc.
;; 
;; 				     (for-each (lambda (ind)
;; 						 (let* ((name (car ind))
;; 							(num  (cadr ind))
;; 							(key  (conc "0:" num)))
;; 						   (if (not (equal? (iup:attribute run-matrix key) name))
;; 						       (begin
;; 							 (set! changed #t)
;; 							 (iup:attribute-set! run-matrix key name)
;; 							 (iup:attribute-set! run-matrix "FITTOTEXT" (conc "C" num))))))
;; 					       col-indices)
;; 				     (if changed (iup:attribute-set! run-matrix "REDRAW" "ALL")))))))
;;     (dboard:commondat-add-updater commondat new-view-updater tab-num: tab-num)
;;     (dboard:tabdat-runs-tree-set! tabdat tb)
;;     (iup:split
;;      tb
;;      run-matrix)))

;;======================================================================
;; R U N S 
;;======================================================================

(define (dboard:make-controls commondat tabdat)
  (let ((btn-fontsz  (dboard:tabdat-runs-btn-fontsz tabdat)))







|
<
|
|
>
>
>
>
|
>
>
>
>
|
|
<
<
>
|
|
<
|
>
|
>
>
|
|
>
>
>
>
>
|
>
>
>
>
>
>
|
<
>
>
>
>
>
>
>
>
>
>
|
|
|










>
>
|
>
>
>
>
>
>
|

>
>
|
>
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







1666
1667
1668
1669
1670
1671
1672
1673

1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686


1687
1688
1689

1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709

1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749







































1750
1751


















































1752
1753





























































































1754
1755
1756
1757
1758
1759
1760

;; (define dashboard:update-run-summary-tab #f)
;; (define dashboard:update-new-view-tab #f)

;; This is the Run Summary tab
;; 
(define (dashboard:one-run commondat tabdat #!key (tab-num #f))
  (let* ((view-one-run-button #f)

         (xor-two-runs-button #f)
         (sel-color    "180 100 100")
         (nonsel-color "170 170 170")
         (mode-flag (dboard:tabdat-mode-flag tabdat))
         (tb (dboard:runs-tree-browser commondat tabdat))
         (cell-lookup (make-hash-table))
         (mode-selector
          (iup:hbox
           (let ((temp-button
                  (iup:button "View One Run"
                              #:bgcolor sel-color
                              #:action
                              (lambda (obj)


                                (debug:catch-and-dump
                                 (lambda ()
                                   (mode-flag 'view-one-run)

                                   (iup:attribute-set! obj "BGCOLOR" sel-color)
                                   (iup:attribute-set! xor-two-runs-button "BGCOLOR" nonsel-color)
                                   (dboard:xor-ui-update tabdat))
                                 "temp-button-1"))
                              )))
             (set! view-one-run-button temp-button)
             
             temp-button)
           (let ((temp-button
                  (iup:button "XOR Two Runs"
                              #:action
                              (lambda (obj)
                                (debug:catch-and-dump
                                 (lambda ()
                                   (mode-flag 'xor-two-runs)
                                   (iup:attribute-set! obj "BGCOLOR" sel-color)
                                   (iup:attribute-set! view-one-run-button "BGCOLOR" nonsel-color)
                                   (dboard:xor-ui-update tabdat))
                                 "temp-button-2"))
                              )))

             (set! xor-two-runs-button temp-button)
              temp-button)
           (let ((temp-label
                  (iup:label "" #:size "125x15" #:fontsize "10" )))
             (dboard:tabdat-xor-src-runid-label-set! tabdat temp-label)
             temp-label
             )
           (let ((temp-label
                  (iup:label "" #:size "125x15" #:fontsize "10")))
             (dboard:tabdat-xor-dest-runid-label-set! tabdat temp-label)
             temp-label)))
         
         (run-matrix (iup:matrix
		      #:expand "YES"
		      #:click-cb
		      (lambda (obj lin col status)
			(let* ((toolpath (car (argv)))
			       (key      (conc lin ":" col))
			       (test-id  (hash-table-ref/default cell-lookup key -1))
			       (cmd      (conc toolpath " -test " (dboard:tabdat-curr-run-id tabdat) "," test-id "&")))
			  (system cmd)))))
	 (one-run-updater  (lambda ()
			     (if  (dashboard:database-changed? commondat tabdat)
                                  (case (mode-flag) 
                                    ((view-one-run)
                                     (dashboard:one-run-updater commondat tabdat tb cell-lookup run-matrix))
                                    ((xor-two-runs)
                                     (dashboard:xor-two-runs-updater commondat tabdat tb cell-lookup run-matrix))
                                    )
                                  (dboard:xor-ui-update)
                                  ))))
    
    (dboard:commondat-add-updater commondat one-run-updater tab-num: tab-num) ;; register updater
    (dboard:tabdat-runs-tree-set! tabdat tb)

    (iup:vbox
     (iup:split
      #:value 150
      tb
      run-matrix)







































     mode-selector)
))


















































































































































;;======================================================================
;; R U N S 
;;======================================================================

(define (dboard:make-controls commondat tabdat)
  (let ((btn-fontsz  (dboard:tabdat-runs-btn-fontsz tabdat)))

Modified dcommon.scm from [92357a4de8] to [88138cb2b1].

280
281
282
283
284
285
286

































































































287
288
289
290
291
292
293
	       (state      (db:test-get-state hed))
	       (status     (db:test-get-status hed))
	       (newitem    (list test-name item-path (list test-id state status))))
	  (if (null? tal)
	      (reverse (cons newitem res))
	      (loop (car tal)(cdr tal)(cons newitem res)))))))


































































































(define (dcommon:examine-xterm run-id test-id)
  (let* ((testdat (rmt:get-test-info-by-id run-id test-id)))
    (if (not testdat)
	(begin
	  (debug:print 2 "ERROR: No test data found for test " test-id ", exiting")
	  (exit 1))
        (let*







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
	       (state      (db:test-get-state hed))
	       (status     (db:test-get-status hed))
	       (newitem    (list test-name item-path (list test-id state status))))
	  (if (null? tal)
	      (reverse (cons newitem res))
	      (loop (car tal)(cdr tal)(cons newitem res)))))))


(define (dcommon:tests-mindat->hash tests-mindat)
  (let* ((res (make-hash-table)))
    (for-each
     (lambda (item)
       (let* ((test-name+item-path (cons (list-ref item 0) (list-ref item 1)))
              (value (list-ref item 2)))
         (hash-table-set! res test-name+item-path value)))
     tests-mindat)
    res))

;; return 1 if status1 is better
;; return 0 if status1 and 2 are equally good
;; return -1 if status2 is better
(define (dcommon:status-compare3 status1 status2)
  (let*
      ((status-goodness-ranking  (list "PASS" "WARN" "WAIVED" "SKIP" "FAIL" "ABORT" #f))
       (mem1 (member status1 status-goodness-ranking))
       (mem2 (member status2 status-goodness-ranking))
       )
    (cond
     ((and (not mem1) (not mem2)) 0)
     ((not mem1) -1)
     ((not mem2) 1)
     ((= (length mem1) (length mem2)) 0)
     ((> (length mem1) (length mem2)) 1)
     (else -1))))
     
(define (dcommon:xor-tests-mindat src-tests-mindat dest-tests-mindat)
  (let* ((src-hash (dcommon:tests-mindat->hash src-tests-mindat))
         (dest-hash (dcommon:tests-mindat->hash dest-tests-mindat))
         (all-keys
          (reverse (sort 
           (delete-duplicates
            (append (hash-table-keys src-hash) (hash-table-keys dest-hash)))

           (lambda (a b) 
             (cond
              ((< 0 (string-compare3 (car a) (car b))) #t)
              ((> 0 (string-compare3 (car a) (car b))) #f)
              ((< 0 (string-compare3 (cdr a) (cdr b))) #t)
              (else #f)))

           ))))
    (map ;; TODO: rename xor to delta globally in dcommon and dashboard
     (lambda (key)
       (let* ((test-name (car key))
              (item-path (cdr key))

              (dest-value (hash-table-ref/default dest-hash key #f)) ;; (list test-id state status)
              (dest-test-id  (if dest-value (list-ref dest-value 0) #f))
              (dest-state    (if dest-value (list-ref dest-value 1) #f))
              (dest-status   (if dest-value (list-ref dest-value 2) #f))

              (src-value     (hash-table-ref/default src-hash key #f))   ;; (list test-id state status)
              (src-test-id   (if src-value (list-ref src-value 0) #f))
              (src-state     (if src-value (list-ref src-value 1) #f))
              (src-status    (if src-value (list-ref src-value 2) #f))

              (incomplete-statuses '("DELETED" "INCOMPLETE" "STUCK/DEAD" "N/A")) ;; if any of these statuses apply, treat test as incomplete

              (dest-complete
               (and dest-value dest-state dest-status
                    (equal? dest-state "COMPLETED")
                    (not (member dest-status incomplete-statuses))))
              (src-complete
               (and src-value src-state src-status
                    (equal? src-state "COMPLETED")
                    (not (member src-status incomplete-statuses))))
              (status-compare-result (dcommon:status-compare3 src-status dest-status))
              (xor-new-item
               (cond
                ;; complete, for this case means: state=compelte AND status not in ( deleted uncomplete stuck/dead n/a )
                ;; neither complete -> bad

                ;; src !complete, dest complete -> better
                ((and (not dest-complete) (not src-complete))
                 (list dest-test-id "BOTH-BAD" "BOTH-INCOMPLETE"))
                ((not dest-complete)
                 (list src-test-id "DIFF-MISSING" "DEST-INCOMPLETE"))  
                ((not src-complete)
                 (list dest-test-id "DIFF-NEW" "SRC-INCOMPLETE"))      
                ((and
                  (equal? src-state dest-state)
                  (equal? src-status dest-status))
                 (list dest-test-id  (conc "CLEAN") (conc "CLEAN-" dest-status) )) 
                ;;    better or worse: pass > warn > waived > skip > fail > abort
                ;;     pass > warn > waived > skip > fail > abort
                
                ((= 1 status-compare-result) ;; src is better, dest is worse
                 (list dest-test-id "DIRTY-WORSE" (conc src-status "->" dest-status)))
                (else
                 (list dest-test-id "DIRTY-BETTER" (conc src-status "->" dest-status)))
                 )))
         (list test-name item-path  xor-new-item)))
     all-keys)))

(define (dcommon:examine-xterm run-id test-id)
  (let* ((testdat (rmt:get-test-info-by-id run-id test-id)))
    (if (not testdat)
	(begin
	  (debug:print 2 "ERROR: No test data found for test " test-id ", exiting")
	  (exit 1))
        (let*
309
310
311
312
313
314
315


316
317
318
319
320
321
322
                               (message-window  (conc "Directory " rundir " not found"))))))
          (xterm)
          (print "Adding xterm code")))))

;;======================================================================
;; D A T A   T A B L E S
;;======================================================================



;; Table of keys
(define (dcommon:keys-matrix rawconfig)
  (let* ((curr-row-num 1)
	 (key-vals     (configf:section-vars rawconfig "fields"))
	 (keys-matrix  (iup:matrix
			#:alignment1 "ALEFT"







>
>







406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
                               (message-window  (conc "Directory " rundir " not found"))))))
          (xterm)
          (print "Adding xterm code")))))

;;======================================================================
;; D A T A   T A B L E S
;;======================================================================



;; Table of keys
(define (dcommon:keys-matrix rawconfig)
  (let* ((curr-row-num 1)
	 (key-vals     (configf:section-vars rawconfig "fields"))
	 (keys-matrix  (iup:matrix
			#:alignment1 "ALEFT"

Modified gutils.scm from [628c78d614] to [753b73f869].

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





46
47
48
49
50
51
52
       ((SKIP)        (list "230 230 0" status))
       (else (list "253 33 49" status))))
    ((ARCHIVED)
     (case (string->symbol status)
       ((PASS)        (list "70  170 73" status))
       ((WARN WAIVED) (list "200 130 13" status))
       ((SKIP)        (list "180 180 0" status))
       (else (list "180 33 49" status))))
    ;;      (if (equal? status "PASS")
    ;;	  '("70 249 73" "PASS")
    ;;	  (if (or (equal? status "WARN")
    ;;		  (equal? status "WAIVED"))
    ;;	      (list "255 172 13" status)
    ;;	      (list "223 33 49"  status)))) ;; greenish orangeish redish





    ((LAUNCHED)         (list "101 123 142"  state))
    ((CHECK)            (list "255 100 50"   state))
    ((REMOTEHOSTSTART)  (list "50 130 195"   state))
    ((RUNNING)          (list "9 131 232"    state))
    ((KILLREQ)          (list "39 82 206"    state))
    ((KILLED)           (list "234 101 17"   state))
    ((NOT_STARTED)      (list "240 240 240"  state))







|






>
>
>
>
>







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
       ((SKIP)        (list "230 230 0" status))
       (else (list "253 33 49" status))))
    ((ARCHIVED)
     (case (string->symbol status)
       ((PASS)        (list "70  170 73" status))
       ((WARN WAIVED) (list "200 130 13" status))
       ((SKIP)        (list "180 180 0" status))
       (else (list "253 33 49" state))))
    ;;      (if (equal? status "PASS")
    ;;	  '("70 249 73" "PASS")
    ;;	  (if (or (equal? status "WARN")
    ;;		  (equal? status "WAIVED"))
    ;;	      (list "255 172 13" status)
    ;;	      (list "223 33 49"  status)))) ;; greenish orangeish redish

    ((CLEAN)       (list "60  235 63" status))
    ((DIRTY-BETTER)     (list "160  255 153" status))
    ((DIRTY-WORSE)      (list "165 42  42" status))
    ((BOTH-BAD)         (list "180 33 49" status))
    ((LAUNCHED)         (list "101 123 142"  state))
    ((CHECK)            (list "255 100 50"   state))
    ((REMOTEHOSTSTART)  (list "50 130 195"   state))
    ((RUNNING)          (list "9 131 232"    state))
    ((KILLREQ)          (list "39 82 206"    state))
    ((KILLED)           (list "234 101 17"   state))
    ((NOT_STARTED)      (list "240 240 240"  state))