41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
| 41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
|
(include "common_records.scm")
(include "key_records.scm")
(include "db_records.scm")
(include "run_records.scm")
(define (ezsteps:step-name->mode stepname)
(match (string-search "\\.([^\\.]+)$" stepname)
((_ ext) (string->symbol ext))
(else #f)))
;;(rmt:get-test-info-by-id run-id test-id) -> testdat
(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))
(shellmode (ezsteps:get-ezpropvars (configf:lookup testconfig "setup" "ezpropvars"))) ;; returns '(csh|sh . "/path/to/shell")
(stepmode (if stepmode-n ;; the .sh or .csh always wins
|