@@ -278,10 +278,31 @@ (debug:print 1 "INFO: Adding " required-tests " to the run queue")) ;; NOTE: these are all parent tests, items are not expanded yet. (runs:run-tests-queue run-id runname test-records keyvallst flags) (debug:print 4 "INFO: All done by here"))) + +;; testname is hed and remtests is tal, can be testname strings or testqueue vectors +;; remaining-items are other items for the current test that have not been run yet +;; this is used in calculating the state of toplevel tests. They are NOT COMPLETED +;; until all items are COMPLETED and thus not in this list. +(define (runs:remaining-items testdat remtests) + (let* ((testname (tests:testqueue-get-testname testdat)) ;; extract the name of the test (may have vector record) + (itempath (tests:testqueue-get-itempath testdat)) + (toptestname (if (string? testname) + (car (string-split testname "/")) + (begin + (debug:print 0 "ERROR: Should have a string testname here! Please report this as a bug :(") + testname)))) + (filter (lambda (test) + (let ((tname (tests:testqueue-get-testname test)) + (ipath (tests:testqueue-get-itempath test))) + (and (equal? tname testname) + (and (not (equal? ipath "")) + (not (equal? ipath itempath)))))) + remtests))) + ;; test-records is a hash table testname:item_path => vector < testname testconfig waitons priority items-info ... > (define (runs:run-tests-queue run-id runname test-records keyvallst flags) ;; At this point the list of parent tests is expanded ;; NB// Should expand items here and then insert into the run queue. (debug:print 5 "test-records: " test-records ", keyvallst: " keyvallst " flags: " (hash-table->alist flags)) @@ -335,11 +356,11 @@ (set! waiton (filter (lambda (x)(not (equal? x hed))) waitons)))) (cond ((not items) ;; when false the test is ok to be handed off to launch (but not before) (let* ((have-resources (open-run-close runs:can-run-more-tests #f test-record)) ;; look at the test jobgroup and tot jobs running - (prereqs-not-met (open-run-close db:get-prereqs-not-met #f run-id waitons item-path mode: testmode)) + (prereqs-not-met (db:get-prereqs-not-met #f run-id waitons item-path mode: testmode)) (fails (calc-fails prereqs-not-met)) (non-completed (calc-not-completed prereqs-not-met))) (debug:print 8 "INFO: have-resources: " have-resources " prereqs-not-met: " (string-intersperse (map (lambda (t) @@ -359,26 +380,29 @@ (run:test run-id runname keyvallst test-record flags #f) (debug:print 1 "INFO: Skipping " (tests:testqueue-get-testname test-record) " " item-path " as it doesn't match " item-patts)) ;; else the run is stuck, temporarily or permanently ;; but should check if it is due to lack of resources vs. prerequisites ) - ((not have-resources) ;; simply try again after waiting a second + ((not have-resources) + ;; simply try again after waiting a second, but register the test + ;; so the itemized tests have place holders + (open-run-close tests:register-test db run-id (tests:testqueue-get-testname hed) item-path) (thread-sleep! (+ 1 *global-delta*)) (debug:print 1 "INFO: no resources to run new tests, waiting ...") ;; could have done hed tal here but doing car/cdr of newtal to rotate tests - (loop (car newtal)(cdr newtal))) + (loop hed tal)) ;; (car newtal)(cdr newtal))) WHY DID I REORDER!!? (else ;; must be we have unmet prerequisites (debug:print 4 "FAILS: " fails) ;; If one or more of the prereqs-not-met are FAIL then we can issue ;; a message and drop hed from the items to be processed. (if (null? fails) (begin ;; couldn't run, take a breather (debug:print 4 "INFO: Shouldn't really get here, race condition? Unable to launch more tests at this moment, killing time ...") (thread-sleep! (+ 1 *global-delta*)) ;; long sleep here - no resources, may as well be patient - ;; we made new tal by sticking hed at the back of the list - (loop (car newtal)(cdr newtal))) + ;; we made new tal by sticking hed at the back of the list. BUT WHY? + (loop hed tal)) ;; (car newtal)(cdr newtal))) ;; the waiton is FAIL so no point in trying to run hed ever again (if (not (null? tal)) (if (vector? hed) (begin (debug:print 1 "WARN: Dropping test " (db:test-get-testname hed) "/" (db:test-get-item-path hed) " from the launch list as it has prerequistes that are FAIL") @@ -445,11 +469,11 @@ (tests:testqueue-set-items! test-record items-list) (loop hed tal)) (begin (debug:print 0 "ERROR: The proc from reading the setup did not yield a list - please report this") (exit 1)))))) - ((null? fails) + ((null? fails) ;; AGAIN, WHY DID I TRY TO ROTATE THE TESTS HERE? (loop (car newtal)(cdr newtal))) ;; an issue with prereqs not yet met? ((and (not (null? fails))(eq? testmode 'normal)) (debug:print 1 "INFO: test " hed " (mode=" testmode ") has failed prerequisite(s); " (string-intersperse (map (lambda (t)(conc (db:test-get-testname t) ":" (db:test-get-state t)"/"(db:test-get-status t))) fails) ", ") ", removing it from to-do list")