Index: common.scm ================================================================== --- common.scm +++ common.scm @@ -2769,11 +2769,12 @@ (restore-thunks (filter identity (map (lambda (env-pair) (let* ((env-var (car env-pair)) - (new-val (cadr env-pair)) + (new-val (let ((tmp (cdr env-pair))) + (if (list? tmp) (car tmp) tmp))) (current-val (get-environment-variable env-var)) (restore-thunk (cond ((not current-val) (lambda () (unsetenv env-var))) ((not (string? new-val)) #f) Index: dashboard-context-menu.scm ================================================================== --- dashboard-context-menu.scm +++ dashboard-context-menu.scm @@ -257,12 +257,13 @@ ;; 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) +(define (dashboard:custom-menu-items run-id test-id target run-name test-name testpatt item-test-path test-info) (let* ((vars (configf:section-vars *configdat* "custom-context-menu-items")) + (item-path (db:test-get-item-path test-info)) (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))) @@ -273,13 +274,15 @@ `(( "%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)) + ( "%test-run-dir%" . ,(db:test-get-rundir test-info)) ( "%mt-root%" . ,mt-root) + ( "%run-name%" . ,run-name) ( "%run-area-home%" . ,*toppath*) + ( "%item-path%" . ,item-path) ( "%item-test-patt%" . ,item-test-path ))) (command-line ;; replace template vars (foldr (lambda (x i) (string-substitute @@ -301,24 +304,28 @@ subst-alist))) (iup:menu-item (conc "*"menu-item-text) #:action (lambda (obj) - ;; TODO: with-env-vars - ;; TODO: with-env-vars MT_* (let* ((scheme-match (string-match "^#(\\(.*)" command-line))) ;;(BB> "cmdline is >"command-line"<") - (if scheme-match - (begin - (handle-exceptions - exn - (print "error with custom menu scheme") - (begin - ;;(BB> "gonna eval it!") - (eval (with-input-from-string (cadr scheme-match) read))))) - (common:run-a-command command-line)))))) + (common:with-env-vars + ;; TODO: with-env-vars + ;; TODO: with-env-vars MT_* + (runs:get-mt-env-alist run-id run-name target test-name item-path) + + (lambda () + (if scheme-match + (begin + (handle-exceptions + exn + (print "error with custom menu scheme") + (begin + ;;(BB> "gonna eval it!") + (eval (with-input-from-string (cadr scheme-match) read))))) + (common:run-a-command command-line with-vars: #t)))))))) #f))) vars))) (define (dashboard:context-menu run-id test-id target runname test-name testpatt item-test-path test-info) (let* ((run-menu-items Index: runs.scm ================================================================== --- runs.scm +++ runs.scm @@ -46,10 +46,50 @@ (defstruct runs:testdat hed tal reg reruns test-record test-name item-path jobgroup waitons testmode newtal itemmaps prereqs-not-met) + +(define (runs:get-mt-env-alist run-id runname target testname itempath) + ;;(bb-check-path msg: "runs:set-megatest-env-vars entry") + `(("MT_TEST_NAME" . ,testname) + + ("MT_ITEMPATH" . ,itempath) + + ("MT_TARGET" . ,target) + + ("MT_RUNNAME" . ,runname) + + ("MT_RUN_AREA_HOME" . ,*toppath*) + + ,@(let* ((link-tree (common:get-linktree))) ;; (configf:lookup *configdat* "setup" "linktree"))) + (if link-tree + (list (cons "MT_LINKTREE" link-tree) + + (cons "MT_TEST_RUN_DIR" + (conc link-tree "/" target "/" runname "/" testname + (if (and (string? itempath) (not (equal? itempath ""))) + (conc "/" itempath) + ""))) + ) + '())) + + ,@(map + (lambda (key) + (cons (car key) (cadr key))) + (keys:target->keyval (rmt:get-keys) target)) + + ,@(map (lambda (var) + (let ((val (configf:lookup *configdat* "custom-context-menu-items" var))) + (cons var val))) + (configf:section-vars *configdat* "env-override")))) + + + + + + ;; set up needed environment variables given a run-id and optionally a target, itempath etc. ;; (define (runs:set-megatest-env-vars run-id #!key (inkeys #f)(inrunname #f)(inkeyvals #f)(intarget #f)(testname #f)(itempath #f)) ;;(bb-check-path msg: "runs:set-megatest-env-vars entry") (let* ((target (or intarget