Index: megatest.scm ================================================================== --- megatest.scm +++ megatest.scm @@ -265,36 +265,29 @@ ;; if still ok to run tasks ;; process deferred tasks per above steps ;; run all tests are are Not COMPLETED and PASS or CHECK (if (args:get-arg "-runall") - (if (not (args:get-arg ":runname")) - (begin - (debug:print 0 "ERROR: Missing required parameter for -runtests, you must specify the run name with :runname runname") - (exit 2)) - (let* ((db (if (setup-for-run) - (open-db) - (begin - (debug:print 0 "Failed to setup, exiting") - (exit 1))))) - (if (not (car *configinfo*)) - (begin - (debug:print 0 "ERROR: Attempted to run a test but run area config file not found") - (exit 1)) - ;; put test parameters into convenient variables - (let* ((test-names (get-all-legal-tests))) ;; "PROD" is ignored for now - (debug:print 1 "INFO: Attempting to start the following tests...") - (debug:print 1 " " (string-intersperse test-names ",")) - (run-tests db test-names))) - ;; (run-waiting-tests db) - (sqlite3:finalize! db) - (set! *didsomething* #t)))) + (general-run-call + "-runall" + "run all tests" + (lambda (db keys keynames keyvallst) + (let* ((test-names (get-all-legal-tests))) ;; "PROD" is ignored for now + (debug:print 1 "INFO: Attempting to start the following tests...") + (debug:print 1 " " (string-intersperse test-names ",")) + (run-tests db test-names))))) ;;====================================================================== ;; Rollup into a run ;;====================================================================== (if (args:get-arg "-rollup") + (general-run-call + "-rollup" + "rollup tests" + (lambda (db keys keynames keyvallst) + (let ((n (args:get-arg "-rollup"))) + (runs:rollup db keys keynames keyvallst n))))) ;;====================================================================== ;; run one test ;;====================================================================== @@ -308,34 +301,20 @@ ;; - step started, timestamp ;; - step completed, exit status, timestamp ;; 6. test phone home ;; - if test run time > allowed run time then kill job ;; - if cannot access db > allowed disconnect time then kill job + (define (runtests) - (if (not (args:get-arg ":runname")) - (begin - (debug:print 0 "ERROR: Missing required parameter for -runtests, you must specify the run name with :runname runname") - (exit 2)) - (let ((db #f)) - (if (not (setup-for-run)) - (begin - (debug:print 0 "Failed to setup, exiting") - (exit 1))) - (set! db (open-db)) - (if (not (car *configinfo*)) - (begin - (debug:print 0 "ERROR: Attempted to run a test but run area config file not found") - (exit 1)) - ;; put test parameters into convenient variables - (let* ((test-names (string-split (args:get-arg "-runtests") ","))) - (run-tests db test-names))) - ;; run-waiting-tests db) - (sqlite3:finalize! db) - ;; (run-waiting-tests #f) - (set! *didsomething* #t)))) - + (general-run-call + "-runtests" + "run a test" + (lambda (db keys keynames keyvallst) + (let ((test-names (string-split (args:get-arg "-runtests") ","))) + (run-tests db test-names))))) + (if (args:get-arg "-runtests") (runtests)) ;;====================================================================== ;; execute the test @@ -517,11 +496,12 @@ (eq? (vector-ref exit-info 2) 0)) "PASS" "FAIL") "FAIL") itemdat (args:get-arg "-m")))) ;; for automated creation of the rollup html file this is a good place... - (tests:summarize-items db run-id test-name #f) ;; don't force - just update if no + (if (not (equal? item-path "")) + (tests:summarize-items db run-id test-name #f)) ;; don't force - just update if no ) (mutex-unlock! m) ;; (exec-results (cmd-run->list fullrunscript)) ;; (list ">" (conc test-name "-run.log")))) ;; (success exec-results)) ;; (eq? (cadr exec-results) 0))) (debug:print 2 "Output from running " fullrunscript ", pid " (vector-ref exit-info 0) " in work area " Index: runs.scm ================================================================== --- runs.scm +++ runs.scm @@ -638,11 +638,37 @@ ;;====================================================================== ;; Routines for manipulating runs ;;====================================================================== -(define (runs:rollup-run db keys n) +;; Since many calls to a run require pretty much the same setup +;; this wrapper is used to reduce the replication of code +(define (general-run-call switchname action-desc proc) + (if (not (args:get-arg ":runname")) + (begin + (debug:print 0 "ERROR: Missing required parameter for " switchname ", you must specify the run name with :runname runname") + (exit 2)) + (let ((db #f)) + (if (not (setup-for-run)) + (begin + (debug:print 0 "Failed to setup, exiting") + (exit 1))) + (set! db (open-db)) + (if (not (car *configinfo*)) + (begin + (debug:print 0 "ERROR: Attempted to " action-desc " but run area config file not found") + (exit 1)) + ;; Extract out stuff needed in most or many calls + ;; here then call proc + (let* ((keys (db-get-keys db)) + (keynames (map key:get-fieldname keys)) + (keyvallst (keys->vallist keys #t))) + (proc db keys keynames keyvallst))) + (sqlite3:finalize! db) + (set! *didsomething* #t)))) + +(define (runs:rollup-run db keys keynames keyvallst n) (let* ((new-run-id (register-run db keys)) (similar-runs (db:get-similar-runs db keys)) (tests-n-days (db:get-tests-n-days db similar-runs))) (for-each (lambda (test-id)