Skip to content

Commit cbb42a2

Browse files
author
matt
committed
Merged partial working control of areas to affect from trigger config line. If using --modepatt (or -mode-patt) DO NOT run anything if the PATT is not found in runconfigs
2 parents 5d2c277 + 98ca9f5 commit cbb42a2

File tree

3 files changed

+49
-20
lines changed

3 files changed

+49
-20
lines changed

common.scm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,10 @@
971971
(args-testpatt (or (args:get-arg "-testpatt") (args:get-arg "-runtests") "%"))
972972
(rtestpatt (if rconf (runconfigs-get rconf testpatt-key) #f)))
973973
(cond
974+
((args:get-arg "--modepatt") ;; modepatt is a forced setting, when set it MUST refer to an existing PATT in the runconfig
975+
(if rconf
976+
(runconfigs-get rconf testpatt-key)
977+
#f)) ;; We do NOT fall back to "%"
974978
;; (tags-testpatt
975979
;; (debug:print-info 0 *default-log-port* "-tagexpr "tagexpr" selects testpatt "tags-testpatt)
976980
;; tags-testpatt)

mtut.scm

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,15 @@ Version " megatest-version ", built from " megatest-fossil-hash ))
522522
(lambda ()
523523
(print pkt))))))
524524

525+
526+
(define (val-alist->areas val-alist)
527+
(string-split (or (alist-ref 'areas val-alist) "") ","))
528+
529+
(define (area-allowed? area areas)
530+
(or (not areas)
531+
(null? areas)
532+
(member area areas)))
533+
525534
;; (use trace)(trace create-run-pkt)
526535

527536
;; collect all needed data and create run pkts for contours with changed inputs
@@ -596,6 +605,7 @@ Version " megatest-version ", built from " megatest-fossil-hash ))
596605
(let* ((run-name (alist-ref 'run-name val-alist))
597606
(target (alist-ref 'target val-alist))
598607
(crontab (alist-ref 'cron val-alist))
608+
(areas (val-alist->areas val-alist))
599609
;; (action (alist-ref 'action val-alist))
600610
(cron-safe-string (string-translate (string-intersperse (string-split (alist-ref 'cron val-alist)) "-") "*" "X"))
601611
(runname std-runname)) ;; (conc "sched" (time->string (seconds->local-time (current-seconds)) "%M%H%d")))))
@@ -617,6 +627,13 @@ Version " megatest-version ", built from " megatest-fossil-hash ))
617627
(runtrans . ,runtrans)
618628
(action . ,action)
619629
(target . ,target)))))
630+
((remove)
631+
(push-run-spec torun contour runkey
632+
`((message . ,(conc ruletype ":" cron-safe-string))
633+
(runname . ,runname)
634+
(runtrans . ,runtrans)
635+
(action . ,action)
636+
(target . ,target))))
620637
(else
621638
(print "ERROR: action \"" action "\" has no scheduled handler")
622639
)))))
@@ -696,6 +713,7 @@ Version " megatest-version ", built from " megatest-fossil-hash ))
696713

697714
((file file-or) ;; one or more files must be newer than the reference
698715
(let* ((file-globs (alist-ref 'glob val-alist))
716+
(areas (val-alist->areas val-alist))
699717
(youngestdat (common:get-youngest (common:bash-glob file-globs)))
700718
(youngestmod (car youngestdat)))
701719
;; (print "youngestmod: " youngestmod " starttimes: " starttimes)
@@ -762,7 +780,7 @@ Version " megatest-version ", built from " megatest-fossil-hash ))
762780
(print "contour: " contour)
763781
(let* ((val (or (configf:lookup mtconf "contours" contour) ""))
764782
(val-alist (val->alist val))
765-
(areas (string-split (or (alist-ref 'areas val-alist) "") ","))
783+
(areas (val-alist->areas val-alist))
766784
(selector (alist-ref 'selector val-alist))
767785
(mode-tag (and selector (string-split-fields "/" selector #:infix)))
768786
(mode-patt (and mode-tag (if (eq? (length mode-tag) 2)(cadr mode-tag) #f)))
@@ -776,24 +794,26 @@ Version " megatest-version ", built from " megatest-fossil-hash ))
776794
(lambda (runkeydat)
777795
(for-each
778796
(lambda (area)
779-
(let ((runname (alist-ref 'runname runkeydat))
780-
(runtrans (alist-ref 'runtrans runkeydat))
781-
(reason (alist-ref 'message runkeydat))
782-
(sched (alist-ref 'sched runkeydat))
783-
(action (alist-ref 'action runkeydat))
784-
(dbdest (alist-ref 'dbdest runkeydat))
785-
(append (alist-ref 'append runkeydat))
786-
(target (or (alist-ref 'target runkeydat) runkey))) ;; override with target if forced
787-
(print "Have: runkey=" runkey " contour=" contour " area=" area " action=" action " tag-expr=" tag-expr " mode-patt=" mode-patt " target=" target)
788-
(if (case (or (and action (string->symbol action)) 'noaction) ;; ensure we have the needed data to run this action
789-
((noaction) #f)
790-
((run) (and runname reason))
791-
((sync) (and reason dbdest))
792-
(else #f))
793-
;; instead of unwrapping the runkeydat alist, pass it directly to create-run-pkt
794-
(create-run-pkt mtconf action area runkey runname mode-patt tag-expr pktsdir reason contour sched dbdest append runtrans)
795-
(print "ERROR: Missing info to make a " action " call: runkey=" runkey " contour=" contour " area=" area " tag-expr=" tag-expr " mode-patt=" mode-patt " dbdest=" dbdest)
796-
)))
797+
(if (area-allowed? area areas) ;; is this area to be handled (from areas=a,b,c ...)
798+
(let ((runname (alist-ref 'runname runkeydat))
799+
(runtrans (alist-ref 'runtrans runkeydat))
800+
(reason (alist-ref 'message runkeydat))
801+
(sched (alist-ref 'sched runkeydat))
802+
(action (alist-ref 'action runkeydat))
803+
(dbdest (alist-ref 'dbdest runkeydat))
804+
(append (alist-ref 'append runkeydat))
805+
(target (or (alist-ref 'target runkeydat) runkey))) ;; override with target if forced
806+
(print "Have: runkey=" runkey " contour=" contour " area=" area " action=" action " tag-expr=" tag-expr " mode-patt=" mode-patt " target=" target)
807+
(if (case (or (and action (string->symbol action)) 'noaction) ;; ensure we have the needed data to run this action
808+
((noaction) #f)
809+
((run) (and runname reason))
810+
((sync) (and reason dbdest))
811+
(else #f))
812+
;; instead of unwrapping the runkeydat alist, pass it directly to create-run-pkt
813+
(create-run-pkt mtconf action area runkey runname mode-patt tag-expr pktsdir reason contour sched dbdest append runtrans)
814+
(print "ERROR: Missing info to make a " action " call: runkey=" runkey " contour=" contour " area=" area " tag-expr=" tag-expr " mode-patt=" mode-patt " dbdest=" dbdest)
815+
))
816+
(print "NOTE: skipping " runkeydat " for area, not in " areas)))
797817
all-areas))
798818
runkeydats)))
799819
(let ((res (configf:get-section torun contour))) ;; each contour / target

runs.scm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,12 @@
294294

295295
(if (not test-patts) ;; first time in - adjust testpatt
296296
(set! test-patts (common:args-get-testpatt runconf)))
297+
;; if test-patts is #f at this point there is something wrong and we need to bail out
298+
(if (not test-patts)
299+
(begin
300+
(debug:print 0 *default-log-port* "WARNING: there is no test pattern for this run. Exiting now.")
301+
(exit 0)))
302+
297303
(if (args:get-arg "-tagexpr")
298304
(begin
299305
(set! allowed-tests (string-join (runs:get-tests-matching-tags (args:get-arg "-tagexpr")) ","))
@@ -1705,7 +1711,6 @@
17051711
(member action write-access-actions))
17061712
(debug:print-error 0 *default-log-port* "megatest.db is readonly. Cannot proceed with action ["action"] in which write-access isrequired .")
17071713
(exit 1)))
1708-
17091714

17101715
(debug:print-info 4 *default-log-port* "runs:operate-on => Header: " header " action: " action " new-state-status: " new-state-status)
17111716
(if (> 2 (length state-status))

0 commit comments

Comments
 (0)