Megatest

Check-in [eaac938df2]
Login
Overview
Comment:Cherrypick 8269afbaa4e1a
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | rebase-envprocessing
Files: files | file ages | folders
SHA1: eaac938df23310d2f74e28794269686c4a9b8aa2
User & Date: mrwellan on 2016-04-27 10:24:20
Other Links: branch diff | manifest | tags
Context
2016-04-27
10:26
Cherrypick 64826 check-in: 47eef64ee9 user: mrwellan tags: rebase-envprocessing
10:24
Cherrypick 8269afbaa4e1a check-in: eaac938df2 user: mrwellan tags: rebase-envprocessing
10:21
Cherrypick 04685 check-in: ab18044a3f user: mrwellan tags: rebase-envprocessing
Changes

Modified configf.scm from [39c9b380ea] to [dae73e7b9f].

97
98
99
100
101
102
103


104
105
106
107
108
109
110
				((rget)           (conc "(lambda (ht)(runconfigs-get ht \"" cmd "\"))"))
				(else "(lambda (ht)(print \"ERROR\") \"ERROR\")"))))
		;; (print "fullcmd=" fullcmd)
		(handle-exceptions
		 exn
		 (begin
		   (debug:print 0 "WARNING: failed to process config input \"" l "\"")


		   (set! result (conc "#{( " cmdtype ") " cmd"}")))
		 (if (or allow-system
			 (not (member cmdtype '("system" "shell"))))
		     (with-input-from-string fullcmd
		       (lambda ()
			 (set! result ((eval (read)) ht))))
		    (set! result (conc "#{(" cmdtype ") "  cmd "}"))))







>
>







97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
				((rget)           (conc "(lambda (ht)(runconfigs-get ht \"" cmd "\"))"))
				(else "(lambda (ht)(print \"ERROR\") \"ERROR\")"))))
		;; (print "fullcmd=" fullcmd)
		(handle-exceptions
		 exn
		 (begin
		   (debug:print 0 "WARNING: failed to process config input \"" l "\"")
		   (debug:print 0 " message: " ((condition-property-accessor 'exn 'message) exn))
		   ;; (print "exn=" (condition->list exn))
		   (set! result (conc "#{( " cmdtype ") " cmd"}")))
		 (if (or allow-system
			 (not (member cmdtype '("system" "shell"))))
		     (with-input-from-string fullcmd
		       (lambda ()
			 (set! result ((eval (read)) ht))))
		    (set! result (conc "#{(" cmdtype ") "  cmd "}"))))

Modified launch.scm from [0f69f7678b] to [2b290f7cdb].

435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
					     (tests:get-testconfig test-name tconfigreg #t force-create: #t)) ;; 'return-procs)))
					    (ezstepslst (if (hash-table? testconfig)
							    (hash-table-ref/default testconfig "ezsteps" '())
							    #f)))
				       (if testconfig
					   (hash-table-set! *testconfigs* test-name testconfig) ;; cached for lazy reads later ...
					   (begin
					     ;; got here but there are race condiitions - re-do all setup and try one more time
					     (if (launch:setup)
						 (begin
						   (launch:cache-config)
						   (set! testconfig (full-runconfigs-read))) ;; redunantly redundant, but does it resolve the race?
					     (debug:print 0 "WARNING: no testconfig found for " test-name " in search path:\n  "
							  (string-intersperse (tests:get-tests-search-path *configdat*) "\n  ")))))
				       ;; after all that, still no testconfig? Time to abort
				       (if (not testconfig)
					   (begin
					     (debug:print 0 "ERROR: Failed to resolve megatest.config, runconfigs.config and testconfig issues. Giving up now")
					     (exit 1)))
				       (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







<
|
<
<
<

|







435
436
437
438
439
440
441

442



443
444
445
446
447
448
449
450
451
					     (tests:get-testconfig test-name tconfigreg #t force-create: #t)) ;; 'return-procs)))
					    (ezstepslst (if (hash-table? testconfig)
							    (hash-table-ref/default testconfig "ezsteps" '())
							    #f)))
				       (if testconfig
					   (hash-table-set! *testconfigs* test-name testconfig) ;; cached for lazy reads later ...
					   (begin

					     (launch:setup)



					     (debug:print 0 "WARNING: no testconfig found for " test-name " in search path:\n  "
							  (string-intersperse (tests:get-tests-search-path *configdat*) "\n  "))))
				       ;; after all that, still no testconfig? Time to abort
				       (if (not testconfig)
					   (begin
					     (debug:print 0 "ERROR: Failed to resolve megatest.config, runconfigs.config and testconfig issues. Giving up now")
					     (exit 1)))
				       (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
713
714
715
716
717
718
719

720
721
722
723
724
725
726
727

728
729
730
731
732
733
734
;;     *toppath*
;;   side effects:
;;     sets; *configdat*    (megatest.config info)
;;           *runconfigdat* (runconfigs.config info)
;;           *configstatus* (status of the read data)
;;
(define (launch:setup-new #!key (force #f))

  (let* ((runname  (common:args-get-runname))
	 (target   (common:args-get-target))
	 (linktree (common:get-linktree))
	 (rundir   (if (and runname target linktree)(conc linktree "/" target "/" runname) #f))
	 (mtcachef (and rundir (conc rundir "/" ".megatest.cfg-"  megatest-version "-" megatest-fossil-hash)))
	 (rccachef (and rundir (conc rundir "/" ".runconfigs.cfg-"  megatest-version "-" megatest-fossil-hash)))
	 (cancreate (and rundir (file-exists? rundir)(file-write-access? rundir))))
    ;; (print "runname: " runname " target: " target " mtcachef: " mtcachef " rccachef: " rccachef)

    (cond
     ;; data was read and cached and available in *configstatus*
     ((eq? *configstatus* 'fulldata)
      *toppath*)
     ;; if mtcachef exists just read it
     ((and mtcachef (file-exists? mtcachef))
      (set! *configdat*    (configf:read-alist mtcachef))







>
|







>







709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
;;     *toppath*
;;   side effects:
;;     sets; *configdat*    (megatest.config info)
;;           *runconfigdat* (runconfigs.config info)
;;           *configstatus* (status of the read data)
;;
(define (launch:setup-new #!key (force #f))
  (let* ((toppath  (or *toppath* (getenv "MT_RUN_AREA_HOME")))
	 (runname  (common:args-get-runname))
	 (target   (common:args-get-target))
	 (linktree (common:get-linktree))
	 (rundir   (if (and runname target linktree)(conc linktree "/" target "/" runname) #f))
	 (mtcachef (and rundir (conc rundir "/" ".megatest.cfg-"  megatest-version "-" megatest-fossil-hash)))
	 (rccachef (and rundir (conc rundir "/" ".runconfigs.cfg-"  megatest-version "-" megatest-fossil-hash)))
	 (cancreate (and rundir (file-exists? rundir)(file-write-access? rundir))))
    ;; (print "runname: " runname " target: " target " mtcachef: " mtcachef " rccachef: " rccachef)
    (if (not *toppath*)(set! *toppath* toppath)) ;; this probably is not needed?
    (cond
     ;; data was read and cached and available in *configstatus*
     ((eq? *configstatus* 'fulldata)
      *toppath*)
     ;; if mtcachef exists just read it
     ((and mtcachef (file-exists? mtcachef))
      (set! *configdat*    (configf:read-alist mtcachef))
743
744
745
746
747
748
749
750

751
752
753
754
755
756
757
758
759
760
761
762
763
764
765


766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791

792
793
794
795
796
797
798
799
800
801
802
803
804
				  environ-patt: "env-override"
				  given-toppath: (get-environment-variable "MT_RUN_AREA_HOME")
				  pathenvvar: "MT_RUN_AREA_HOME")))
	(if first-pass
	    (begin
	      (set! *configdat*  (car first-pass))
	      (set! *configinfo* first-pass)
	      (set! *toppath*    (cadr first-pass))

	      ;; the seed read is done, now read runconfigs, cache it then read megatest.config one more time and cache it
	      (let* ((keys     (rmt:get-keys))
		     (key-vals (if target (keys:target->keyval keys target) #f))
		     (sections (if target (list "default" target) #f)) ;; for runconfigs
		     (linktree (or (getenv "MT_LINKTREE")
				   (if *configdat* (configf:lookup *configdat* "setup" "linktree") #f)))
		     (runconfigdat (begin
				     (setenv "MT_RUN_AREA_HOME" *toppath*)
				     (if key-vals
					 (for-each (lambda (kt)
						     (setenv (car kt) (cadr kt)))
						   key-vals))
				     (read-config (conc *toppath* "/runconfigs.config") #f #t sections: sections))))
		(if cancreate (configf:write-alist runconfigdat rccachef))
		(set! *runconfigdat* runconfigdat)


		(let ((second-pass (find-and-read-config 
				    (or (args:get-arg "-config") "megatest.config")
				    environ-patt: "env-override"
				    given-toppath: (get-environment-variable "MT_RUN_AREA_HOME")
				    pathenvvar: "MT_RUN_AREA_HOME")))
		  (if cancreate (configf:write-alist (car second-pass) mtcachef))
		  (set! *configdat* (car second-pass))
		  (set! *toppath*   (cadr second-pass))
		  (if cancreate (set! *configstatus* 'fulldata)))))
	    ;; no configs found? should not happen but let's try to recover gracefully, return an empty hash-table
	    (set! *configdat* (make-hash-table))
	    )))
     ;; else read what you can and set the flag accordingly
     (else
      (let* ((cfgdat   (find-and-read-config 
			(or (args:get-arg "-config") "megatest.config")
			environ-patt: "env-override"
			given-toppath: (get-environment-variable "MT_RUN_AREA_HOME")
			pathenvvar: "MT_RUN_AREA_HOME"))
	     (sections (if target (list "default" target) #f))
	     (rdat     (read-config (conc (or *toppath* (get-environment-variable "MT_RUN_AREA_HOME")(cadr cfgdat))
					  "/runconfigs.config") #f #t sections: sections)))
	(set! *configinfo*   cfgdat)
	(set! *configdat*    (car cfgdat))
	(set! *runconfigdat* rdat)
	(set! *toppath*      (cadr cfgdat))

	(set! *configstatus* 'partial))))
    ;; final house keeping
    (let* ((keys     (rmt:get-keys))
	   (key-vals (if target (keys:target->keyval keys target) #f))
	   (sections (if target (list "default" target) #f)) ;; for runconfigs
	   (linktree (or (getenv "MT_LINKTREE")
			 (if *configdat* (configf:lookup *configdat* "setup" "linktree") #f))))
      (if linktree
	  (if (not (file-exists? linktree))
	      (begin
		(handle-exceptions
		 exn
		 (begin







|
>















>
>
|
|
|
|
|
|
|
|
|
















|
>

|
<
<
<
|







741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795



796
797
798
799
800
801
802
803
				  environ-patt: "env-override"
				  given-toppath: (get-environment-variable "MT_RUN_AREA_HOME")
				  pathenvvar: "MT_RUN_AREA_HOME")))
	(if first-pass
	    (begin
	      (set! *configdat*  (car first-pass))
	      (set! *configinfo* first-pass)
	      (set! *toppath*    (or toppath (cadr first-pass))) ;; use the gathered data unless already have it
	      (set! toppath      *toppath*)
	      ;; the seed read is done, now read runconfigs, cache it then read megatest.config one more time and cache it
	      (let* ((keys     (rmt:get-keys))
		     (key-vals (if target (keys:target->keyval keys target) #f))
		     (sections (if target (list "default" target) #f)) ;; for runconfigs
		     (linktree (or (getenv "MT_LINKTREE")
				   (if *configdat* (configf:lookup *configdat* "setup" "linktree") #f)))
		     (runconfigdat (begin
				     (setenv "MT_RUN_AREA_HOME" *toppath*)
				     (if key-vals
					 (for-each (lambda (kt)
						     (setenv (car kt) (cadr kt)))
						   key-vals))
				     (read-config (conc *toppath* "/runconfigs.config") #f #t sections: sections))))
		(if cancreate (configf:write-alist runconfigdat rccachef))
		(set! *runconfigdat* runconfigdat)
		(if cancreate (configf:write-alist *configdat* mtcachef))
		(if cancreate (set! *configstatus* 'fulldata))))
		;; (let ((second-pass (find-and-read-config
		;; 		    (or (args:get-arg "-config") "megatest.config")
		;; 		    environ-patt: "env-override"
		;; 		    given-toppath: (get-environment-variable "MT_RUN_AREA_HOME")
		;; 		    pathenvvar: "MT_RUN_AREA_HOME")))
		;;   (if cancreate (configf:write-alist (car second-pass) mtcachef))
		;;   (set! *configdat* (car second-pass))
		;;   (set! *toppath*   (or toppath (cadr second-pass))) ;; this should be a no-op, remove it later
		;;   (if cancreate (set! *configstatus* 'fulldata)))))
	    ;; no configs found? should not happen but let's try to recover gracefully, return an empty hash-table
	    (set! *configdat* (make-hash-table))
	    )))
     ;; else read what you can and set the flag accordingly
     (else
      (let* ((cfgdat   (find-and-read-config 
			(or (args:get-arg "-config") "megatest.config")
			environ-patt: "env-override"
			given-toppath: (get-environment-variable "MT_RUN_AREA_HOME")
			pathenvvar: "MT_RUN_AREA_HOME"))
	     (sections (if target (list "default" target) #f))
	     (rdat     (read-config (conc (or *toppath* (get-environment-variable "MT_RUN_AREA_HOME")(cadr cfgdat))
					  "/runconfigs.config") #f #t sections: sections)))
	(set! *configinfo*   cfgdat)
	(set! *configdat*    (car cfgdat))
	(set! *runconfigdat* rdat)
	(set! *toppath*      (or toppath (cadr cfgdat)))
	(set! toppath        *toppath*)  ;; remove this sillyness later
	(set! *configstatus* 'partial))))
    ;; additional house keeping



    (let* ((linktree (or (getenv "MT_LINKTREE")
			 (if *configdat* (configf:lookup *configdat* "setup" "linktree") #f))))
      (if linktree
	  (if (not (file-exists? linktree))
	      (begin
		(handle-exceptions
		 exn
		 (begin