Index: dashboard-context-menu.scm ================================================================== --- dashboard-context-menu.scm +++ dashboard-context-menu.scm @@ -8,11 +8,12 @@ ;; implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ;; PURPOSE. ;;====================================================================== ;;====================================================================== -;; Test info panel +;; implementation of context menu that pops up on +;; right click on test cell in Runs & Runs Summary Tabs ;;====================================================================== (use format fmt) (require-library iup) (import (prefix iup iup:)) @@ -219,17 +220,80 @@ (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] +;; : +;; 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 + #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 + ;; 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 + (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)) @@ -242,8 +306,6 @@ "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)))) Index: scratch.org ================================================================== --- scratch.org +++ scratch.org @@ -7,10 +7,10 @@ - target * launch-type - in an xterm (common:run-a-command ... ) * insertion [custom-context-menu-items] -item1=Test/netbatch_diagnose:$MT_RUN_AREA_HOME/../bin/nbdiag -test-id %test-id -test-path %item-test-path +item1=Menu Item Text:$MT_RUN_AREA_HOME/../bin/nbdiag -test-id %test-id -test-path %item-test-path item2=netbatch_diagnose:$MT_RUN_AREA_HOME/../bin/nbdiag -test-id %test-id -test-path %item-test-path