Index: configf.scm ================================================================== --- configf.scm +++ configf.scm @@ -34,14 +34,22 @@ (loop remcwd)))))))) (define (config:assoc-safe-add alist key val) (let ((newalist (filter (lambda (x)(not (equal? key (car x)))) alist))) (append newalist (list (list key val))))) + +(define (config:eval-string-in-environment str) + (let ((cmdres (cmd-run->list (conc "echo " str)))) + (if (null? cmdres) "" + (car cmdres)))) ;; read a config file, returns hash table of alists ;; adds to ht if given (must be #f otherwise) -(define (read-config path ht allow-system) +;; envion-patt is a regex spec that identifies sections that will be eval'd +;; in the environment on the fly + +(define (read-config path ht allow-system #!key (environ-patt #f)) (if (not (file-exists? path)) (if (not ht)(make-hash-table) ht) (let ((inp (open-input-file path)) (res (if (not ht)(make-hash-table) ht)) (include-rx (regexp "^\\[include\\s+(.*)\\]\\s*$")) @@ -62,11 +70,11 @@ (regex-case inl (comment-rx _ (loop (read-line inp) curr-section-name #f #f)) (blank-l-rx _ (loop (read-line inp) curr-section-name #f #f)) (include-rx ( x include-file ) (begin - (read-config include-file res allow-system) + (read-config include-file res allow-system environ-patt: environ-patt) (loop (read-line inp) curr-section-name #f #f))) (section-rx ( x section-name ) (loop (read-line inp) section-name #f #f)) (key-sys-pr ( x key cmd ) (if allow-system (let ((alist (hash-table-ref/default res curr-section-name '())) (val (let* ((cmdres (cmd-run->list cmd)) @@ -81,13 +89,16 @@ (string-intersperse res " "))))) (hash-table-set! res curr-section-name (config:assoc-safe-add alist key val)) (loop (read-line inp) curr-section-name #f #f)) (loop (read-line inp) curr-section-name #f #f))) - (key-val-pr ( x key val ) (let ((alist (hash-table-ref/default res curr-section-name '()))) + (key-val-pr ( x key val ) (let ((alist (hash-table-ref/default res curr-section-name '())) + (realval (if (and environ-patt (string-match (regexp environ-patt) curr-section-name)) + (config:eval-string-in-environment val) + val))) (hash-table-set! res curr-section-name - (config:assoc-safe-add alist key val)) + (config:assoc-safe-add alist key realval)) (loop (read-line inp) curr-section-name key #f))) ;; if a continued line (cont-ln-rx ( x whsp val ) (let ((alist (hash-table-ref/default res curr-section-name '()))) (if var-flag ;; if set to a string then we have a continued var (let ((newval (conc @@ -104,17 +115,17 @@ (loop (read-line inp) curr-section-name #f #f)))) (else (debug:print 0 "ERROR: problem parsing " path ",\n \"" inl "\"") (set! var-flag #f) (loop (read-line inp) curr-section-name #f #f)))))))) -(define (find-and-read-config fname) +(define (find-and-read-config fname #!key (environ-patt #f)) (let* ((curr-dir (current-directory)) (configinfo (find-config fname)) (toppath (car configinfo)) (configfile (cadr configinfo))) (if toppath (change-directory toppath)) - (let ((configdat (if configfile (read-config configfile #f #t) #f))) ;; (make-hash-table)))) + (let ((configdat (if configfile (read-config configfile #f #t environ-patt: environ-patt) #f))) ;; (make-hash-table)))) (if toppath (change-directory curr-dir)) (list configdat toppath configfile fname)))) (define (config-lookup cfgdat section var) (let ((sectdat (hash-table-ref/default cfgdat section '()))) Index: launch.scm ================================================================== --- launch.scm +++ launch.scm @@ -139,11 +139,11 @@ (loop (+ i 1))) ))))) ;; then, if runscript ran ok (or did not get called) ;; do all the ezsteps (if any) (if ezsteps - (let* ((testconfig (read-config (conc work-area "/testconfig") #f #t)) ;; FIXME??? is allow-system ok here? + (let* ((testconfig (read-config (conc work-area "/testconfig") #f #t environ-patt: "pre-launch-env-vars")) ;; FIXME??? is allow-system ok here? (ezstepslst (hash-table-ref/default testconfig "ezsteps" '())) (db (open-db))) (if (not (file-exists? ".ezsteps"))(create-directory ".ezsteps")) ;; if ezsteps was defined then we are sure to have at least one step but check anyway (if (not (> (length ezstepslst) 0)) Index: runs.scm ================================================================== --- runs.scm +++ runs.scm @@ -504,11 +504,13 @@ (define (test:get-testconfig test-name system-allowed) (let* ((test-path (conc *toppath* "/tests/" test-name)) (test-configf (conc test-path "/testconfig")) (testexists (and (file-exists? test-configf)(file-read-access? test-configf)))) (if testexists - (read-config test-configf #f system-allowed) + (read-config test-configf #f system-allowed environ-patt: (if system-allowed + "pre-launch-env-vars" + #f)) #f))) ;; sort tests by priority and waiton ;; Move test specific stuff to a test unit FIXME one of these days (define (tests:sort-by-priority-and-waiton test-names) @@ -1193,12 +1195,12 @@ (exit 1))) (set! db (open-db)) (set! keys (db-get-keys db)) ;; have enough to process -target or -reqtarg here (if (args:get-arg "-reqtarg") - (let* ((runconfigf (conc *toppath* "/runconfigs.config")) - (runconfig (read-config runconfigf #f #f))) + (let* ((runconfigf (conc *toppath* "/runconfigs.config")) ;; evaluate all + (runconfig (read-config runconfigf #f #f environ-patt: ".*"))) (if (hash-table-ref/default runconfig (args:get-arg "-reqtarg") #f) (keys:target-set-args keys (args:get-arg "-reqtarg") args:arg-hash) (begin (debug:print 0 "ERROR: [" (args:get-arg "-reqtarg") "] not found in " runconfigf) (sqlite3:finalize! db) Index: tests/runconfigs.config ================================================================== --- tests/runconfigs.config +++ tests/runconfigs.config @@ -8,5 +8,6 @@ CURRENT /tmp/nada [default] FOOBARBAZZZZ not a useful value +BIGBOB $BOGOUS/bobby