1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
+
-
+
|
;;======================================================================
;; Copyright 2006-2012, Matthew Welland.
;;
;; This program is made available under the GNU GPL version 2.0 or
;; greater. See the accompanying file COPYING for details.
;;
;; This program is distributed WITHOUT ANY WARRANTY; without even the
;; implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
;; PURPOSE.
;;======================================================================
;;======================================================================
;; implementation of context menu that pops up on
;; Test info panel
;; right click on test cell in Runs & Runs Summary Tabs
;;======================================================================
(use format fmt)
(require-library iup)
(import (prefix iup iup:))
(use canvas-draw)
|
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
|
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
|
(conc stepname "/" (if (string=? logfile "") "no log!" logfile) " (" status ")")
#:action (lambda (obj)
(let ((fullfile (conc rundir "/" logfile)))
(if (common:file-exists? fullfile)
(dcommon:run-html-viewer fullfile)
(message-window (conc "file " fullfile " not found"))))))))
steps)))))))
;; example section for megatest.config:
;;
;;
;; [custom-context-menu-items]
;; <unique var> <menu item text, can have template variables> : <command line with template %variable%s>
;; item1 custom show run-id (%run-id%):echo "%run-id%"
;; item2 custom show test-id (%test-id%):echo "%test-id%"
;; item3 custom show target (%target%):echo "%target%"
;; item4 custom show test-name (%test-name%):echo "%test-name%"
;; item5 custom show test-patt (%test-patt%):echo "%test-patt%"
;; item6 custom show test-run-dir (%test-run-dir%):echo "%test-run-dir%"
;; item7 custom show run-area-home (%run-area-home%):echo "%run-area-home%"
;; item8 custom show megatest root (%mt-root%):echo "%mt-root%"
;; item9 custom ls : ls -lrt
;; item10 custom see $MT_RUN_AREA_HOME (not yet implemented) : echo $MT_RUN_AREA_HOME
(define (dashboard:custom-menu-items run-id test-id target runname test-name testpatt item-test-path test-info)
(let* ((vars (configf:section-vars *configdat* "custom-context-menu-items"))
(mt-root (pathname-directory (pathname-directory *common:this-exe-dir* ))))
(filter-map
(lambda (var)
(let* ((val (configf:lookup *configdat* "custom-context-menu-items" var))
(m (string-match "^\\s*([^:]+?)\\s*:\\s*(.*?)\\s*$" val)))
(if m
(let* ((menu-item-text-raw (list-ref m 1))
(command-line-raw (list-ref m 2))
(subst-alist ;; template vars
`(( "%run-id%" . ,run-id )
( "%test-id%" . ,test-id )
( "%target%" . ,target )
( "%test-name%" . ,test-name)
( "%test-patt%" . ,testpatt)
( "%test-run-dir%" . ,(db:test-get-rundir test-info))
( "%mt-root%" . ,mt-root)
( "%run-area-home%" . ,*toppath*)
( "%item-test-patt%" . ,item-test-path )))
(command-line ;; replace template vars
(foldr
(lambda (x i)
(string-substitute
(car x)
(->string (cdr x))
i
'())
(define (dashboard:context-menu run-id test-id target runname test-name testpatt item-test-path test-info)
(let* (
(run-menu-items
#t))
command-line-raw
subst-alist))
(menu-item-text ;; replace template vars
(foldr
(lambda (x i)
(string-substitute
(car x)
(->string (cdr x))
i
#t))
menu-item-text-raw
subst-alist)))
(iup:menu-item
menu-item-text
#:action
(lambda (obj)
;; TODO: with-env-vars <runconfig target vars, env-override vars from mtest>
;; TODO: with-env-vars MT_*
(let* ((foo 'foo))
(common:run-a-command command-line)))))
#f)))
vars)))
(define (dashboard:context-menu run-id test-id target runname test-name testpatt item-test-path test-info)
(let* ((run-menu-items
(dashboard:run-menu-items run-id test-id target runname test-name testpatt item-test-path test-info))
(test-menu-items
(dashboard:test-menu-items run-id test-id target runname test-name testpatt item-test-path test-info))
(custom-menu-items
(dashboard:custom-menu-items run-id test-id target runname test-name testpatt item-test-path test-info))
(toplevel-menu-items
(dashboard:toplevel-menu-items run-id test-id target runname test-name testpatt item-test-path test-info))
)
(apply iup:menu
`(,@toplevel-menu-items
,(iup:menu-item
"Run"
(apply iup:menu run-menu-items))
,(iup:menu-item
"Test"
(apply iup:menu test-menu-items))
,@(if (null? custom-menu-items)
'()
custom-menu-items)))))
,@custom-menu-items))))
|