Index: tcmt.scm ================================================================== --- tcmt.scm +++ tcmt.scm @@ -32,10 +32,11 @@ (define remargs (args:get-args (argv) `( "-target" "-reqtarg" "-runname" + "-delay" ;; how long to wait for unexpected changes to ) `("-tc-repl" ) args:arg-hash 0)) @@ -50,11 +51,12 @@ tname (event-time #f) details comment duration - (printed #f)) + (start-printed #f) + (end-printed #f)) ;;====================================================================== ;; GLOBALS ;;====================================================================== @@ -62,33 +64,54 @@ ;; (define *global* (make-hash-table)) (define (tcmt:print tdat flush-mode) (let* ((comment (if (testdat-comment tdat) - (conc " message='" (testdat-comment tdat)) + (conc " message='" (testdat-comment tdat) "'") "")) (details (if (testdat-details tdat) - (conc " details='" (testdat-details tdat)) + (conc " details='" (testdat-details tdat) "'") "")) (flowid (conc " flowId='" (testdat-flowid tdat) "'")) (duration (conc " duration='" (* 1e3 (testdat-duration tdat)) "'")) (tcname (conc " name='" (testdat-tctname tdat) "'")) (state (string->symbol (testdat-state tdat))) (status (string->symbol (testdat-status tdat))) + (startp (testdat-start-printed tdat)) + (endp (testdat-end-printed tdat)) (overall (case state ((RUNNING) state) ((COMPLETED) state) (else 'UNK)))) (case overall - ((RUNNING) (print "##teamcity[testStarted " tcname flowid "]")) + ((RUNNING) + (if (not startp) + (begin + (print "##teamcity[testStarted " tcname flowid "]") + (testdat-start-printed-set! tdat #t)))) ((COMPLETED) - (if (member status '(PASS WARN SKIP WAIVED)) - (print "##teamcity[testFinished " tcname flowid comment details duration "]") - (print "##teamcity[testFailed " tcname flowid comment details "]"))) + (if (not startp) ;; start stanza never printed + (begin + (print "##teamcity[testStarted " tcname flowid "]") + (testdat-start-printed-set! tdat #t))) + (if (not endp) + (begin + (if (member status '(PASS WARN SKIP WAIVED)) + (print "##teamcity[testFinished" tcname flowid comment details duration "]") + (print "##teamcity[testFailed " tcname flowid comment details "]")) + (testdat-end-printed-set! tdat #t)))) (else (if flush-mode - (print "##teamcity[testFailed " tcname flowid comment details "]")))) + (begin + (if (not startp) + (begin + (print "##teamcity[testStarted " tcname flowid "]") + (testdat-started-printed-set! tdat #t))) + (if (not endp) + (begin + (print "##teamcity[testFailed " tcname flowid comment details "]") + (testdat-end-printed-set! tdat #t))))))) ;; (print "ERROR: tc-type \"" (testdat-tc-type tdat) "\" not recognised for " tcname))) (flush-output))) ;; ;; returns values: flag newlst ;; (define (remove-duplicate-completed tdats) @@ -168,10 +191,11 @@ (let* ((tests (rmt:get-tests-for-run run-id "%" '() '() #f #f #f #f #f #f last-update #f))) ;; (print "DEBUG: got tests=" tests) (for-each (lambda (test-rec) (let* ((tqueue (hash-table-ref/default data 'tqueue '())) ;; NOTE: the key is a symbol! This allows keeping disparate info in the one hash, lazy but a quick solution for right now. + (is-top (db:test-get-is-toplevel test-rec)) (tname (db:test-get-fullname test-rec)) (testname (db:test-get-testname test-rec)) (itempath (db:test-get-item-path test-rec)) (tctname (if (string=? itempath "") testname (conc testname "." (string-translate itempath "/" ".")))) (state (db:test-get-state test-rec)) @@ -192,26 +216,29 @@ (conc ", Megatest comment=\"" comment "\""))) ;; special case, we are handling stragglers #f))) (details (if (string-match ".*html$" logfile) (conc *toppath* "/lt/" target "/" runname "/" testname (if (equal? itempath "") "/" (conc "/" itempath "/")) logfile) #f)) - ;; (prev-tdat (hash-table-ref/default data tname #f)) - (tdat (let ((new (make-testdat))) - (testdat-flowid-set! new flowid) - (testdat-tctname-set! new tctname) - (testdat-tname-set! new tname) - (testdat-state-set! new state) - (testdat-status-set! new status) - (testdat-comment-set! new cmtstr) - (testdat-details-set! new details) - (testdat-duration-set! new duration) - (testdat-event-time-set! new (current-seconds)) - (testdat-overall-set! new newstat) - (hash-table-set! data tname new) - new))) - (hash-table-set! data 'tqueue (cons tdat tqueue)) - ;; (hash-table-set! data tname tdat) ;; PUT IN THE DATA HASH ONLY WHEN PRINTED + (prev-tdat (hash-table-ref/default data tname #f)) + (tdat (if is-top + #f + (let ((new (or prev-tdat (make-testdat)))) ;; recycle the record so we keep track of already printed items + (testdat-flowid-set! new flowid) + (testdat-tctname-set! new tctname) + (testdat-tname-set! new tname) + (testdat-state-set! new state) + (testdat-status-set! new status) + (testdat-comment-set! new cmtstr) + (testdat-details-set! new details) + (testdat-duration-set! new duration) + (testdat-event-time-set! new (current-seconds)) + (testdat-overall-set! new newstat) + (hash-table-set! data tname new) + new)))) + (if (not is-top) + (hash-table-set! data 'tqueue (cons tdat tqueue))) + (hash-table-set! data tname tdat) )) tests))) run-ids) now)) @@ -222,11 +249,12 @@ (last-update 0) (target (or (args:get-arg "-target") (args:get-arg "-reqtarg"))) (runname (args:get-arg "-runname")) (tsname #f) - (flowid (conc target "/" runname))) + (flowid (conc target "/" runname)) + (tdelay (string->number (or (args:get-arg "-delay") "15")))) (if (and target runname) (begin (launch:setup) (set! keys (rmt:get-keys)))) (set! tsname (common:get-testsuite-name)) @@ -258,12 +286,12 @@ ;; (print "TCMT: pidres=" pidres " exittype=" exittype " exitstatus=" exitstatus " run-ids=" run-ids) (if (eq? pidres 0) (begin (if keys (begin - (set! last-update (update-queue-since testdats run-ids last-update tsname target runname flowid #f)) - (process-queue testdats 15 #f))) + (set! last-update (- (update-queue-since testdats run-ids last-update tsname target runname flowid #f) 5)) + (process-queue testdats tdelay #f))) (thread-sleep! 3) (loop)) (begin ;; (print "TCMT: pidres=" pidres " exittype=" exittype " exitstatus=" exitstatus " run-ids=" run-ids) (print "TCMT: processing any tests that did not formally complete.") Index: tests/fullrun/test-teamcity-run.sh ================================================================== --- tests/fullrun/test-teamcity-run.sh +++ tests/fullrun/test-teamcity-run.sh @@ -1,1 +1,5 @@ -(cd ../..;make install) && RN=tcmt_m;megatest -remove-runs -target ubuntu/nfs/none -runname tcmt_m -testpatt %;tcmt -run -target ubuntu/nfs/none -runname tcmt_m -testpatt % -rerun-clean 2>&1 | grep teamcity +#!/bin/bash + +(cd ../..;make install) && RN=tcmt_m;megatest -remove-runs -target ubuntu/nfs/none -runname tcmt_m -testpatt %;\ + tcmt -run -target ubuntu/nfs/none -runname tcmt_m -testpatt % -rerun-clean 2>&1 | tee all.log | grep teamcity | tee teamcity.log +