@@ -43,13 +43,60 @@ (include "key_records.scm") (include "db_records.scm") (include "run_records.scm") -;;(rmt:get-test-info-by-id run-id test-id) -> testdat +(define (ezsteps:step-name->mode stepname) + (match (string-search "\\.([^\\.]+)$" stepname) + ((_ ext) (string->symbol ext)) + (else #f))) + +(define (ezsteps:create-step-script envdbf stepname prevstepname mode cmd shellexe) + (let* (#;(shebang (case mode + ((sh) "/bin/sh") + ((csh) "/bin/csh") + (else "/bin/bash"))) + (sourcef (conc ".ezsteps/vars_" prevstepname "." mode)) + (scriptn (conc "ez_" stepname))) ;; remember the name already has an extension .sh, .csh etc. + (with-output-to-file scriptn + (lambda () + ;; the shebang line + (print "#!" shellexe) + ;; save the env at start + (print "megatest -envcap "stepname"_start "envdbf) + ;; source vars from previous steps + (if (file-exists? sourcef) + (print "source " sourcef)) + ;; run the command + (print cmd) + (if (eq? mode 'csh) + (print "set ecode=$?") + (print "ecode=$?")) + ;; save the env at end + (print "megatest -envcap "stepname"_end "envdbf) + ;; write the delta + (print "megatest -envdelta "stepname"_start-"stepname"_end -dumpmode bash -o .ezsteps/vars_"stepname".sh "envdbf) + (print "megatest -envdelta "stepname"_start-"stepname"_end -dumpmode csh -o .ezsteps/vars_"stepname".csh "envdbf) + (print "exit $ecode"))) + (system (conc "chmod a+x " scriptn)))) + +(define (ezsteps:get-ezpropvars res) ;; testconfig) + ;; (let* ((res (configf:lookup testconfig "setup" "ezpropvars"))) + (if (string? res) + (let* ((dat (string-split res))) + (match dat + ((s shellexe) + (let ((shl (string->symbol s))) + `(,shl . ,shellexe))) + ((s) + (let* ((shl (string->symbol s)) + (shellexe (if (eq? shl 'csh) "/bin/csh" "/bin/bash"))) + `(,shl . ,shellexe))) + (else #f))) + #f)) -;; TODO: deprecate me in favor of ezsteps.scm +;; NOTE: returns logpro-used? ;; (define (launch:runstep ezstep run-id test-id exit-info m tal testconfig all-steps-dat prevstepname envdbf) (let* ((stepname (car ezstep)) ;; do stuff to run the step (stepmode-n (ezsteps:step-name->mode stepname)) (stepinfo (cadr ezstep))