Megatest

Diff
Login

Differences From Artifact [bd0f14c7cf]:

To Artifact [1d4bcb987f]:


36
37
38
39
40
41
42
43
44


45
46
47
48
49
50
51
52
53
54
55
56

57
58
59
60
61
62
63
36
37
38
39
40
41
42


43
44
45
46
47
48
49
50
51
52
53
54
55

56
57
58
59
60
61
62
63







-
-
+
+











-
+







;; runs:get-runs-by-patt
;; get runs by list of criteria
;; register a test run with the db
;;
;; Use: (db-get-value-by-header (db:get-header runinfo)(db:get-row runinfo))
;;  to extract info from the structure returned
;;
(define (mt:get-runs-by-patt keys runnamepatt targpatt)
  (let loop ((runsdat  (cdb:remote-run db:get-runs-by-patt #f keys runnamepatt targpatt 0 500))
(define (mt:get-runs-by-patt dbstruct keys runnamepatt targpatt)
  (let loop ((runsdat  (db:get-runs-by-patt dbstruct keys runnamepatt targpatt 0 500))
	     (res      '())
	     (offset   0)
	     (limit    500))
    ;; (print "runsdat: " runsdat)
    (let* ((header    (vector-ref runsdat 0))
	   (runslst   (vector-ref runsdat 1))
	   (full-list (append res runslst))
	   (have-more (eq? (length runslst) limit)))
      ;; (debug:print 0 "header: " header " runslst: " runslst " have-more: " have-more)
      (if have-more 
	  (let ((new-offset (+ offset limit))
		(next-batch (cdb:remote-run db:get-runs-by-patt #f keys runnamepatt targpatt offset limit)))
		(next-batch (db:get-runs-by-patt dbstruct keys runnamepatt targpatt offset limit)))
	    (debug:print-info 4 "More than " limit " runs, have " (length full-list) " runs so far.")
	    (debug:print-info 0 "next-batch: " next-batch)
	    (loop next-batch
		  full-list
		  new-offset
		  limit))
	 (vector header full-list)))))
81
82
83
84
85
86
87
88
89


90
91
92
93
94
95
96
81
82
83
84
85
86
87


88
89
90
91
92
93
94
95
96







-
-
+
+







		  new-offset
		  limit))
	  full-list))))

(define (mt:get-prereqs-not-met run-id waitons ref-item-path #!key (mode 'normal))
  (db:get-prereqs-not-met run-id waitons ref-item-path mode: mode))

(define (mt:get-run-stats)
  (cdb:remote-run db:get-run-stats #f))
(define (mt:get-run-stats dbstruct run-id)
  (db:get-run-stats dbstruct run-id))

(define (mt:discard-blocked-tests run-id failed-test tests test-records)
  (if (null? tests)
      tests
      (begin
	(debug:print-info 1 "Discarding tests from " tests " that are waiting on " failed-test)
	(let loop ((testn (car tests))
140
141
142
143
144
145
146
147

148
149
150
151

152
153
154


155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170













171
172
173
174
175
176
177
140
141
142
143
144
145
146

147
148
149
150

151
152


153
154
155
156
157













158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177







-
+



-
+

-
-
+
+



-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+







		     (conc state "/")
		     (conc "/" status)))))))

;;======================================================================
;;  S T A T E   A N D   S T A T U S   F O R   T E S T S 
;;======================================================================

(define (mt:roll-up-pass-fail-counts run-id test-name item-path status)
(define (mt:roll-up-pass-fail-counts dbstruct run-id test-name item-path status)
  (if (and (not (equal? item-path ""))
	   (member status '("PASS" "WARN" "FAIL" "WAIVED" "RUNNING" "CHECK" "SKIP")))
      (begin
	(cdb:update-pass-fail-counts *runremote* run-id test-name)
	(db:update-pass-fail-counts dbstruct run-id test-name)
	(if (equal? status "RUNNING")
	    (cdb:top-test-set-running *runremote* run-id test-name)
	    (cdb:top-test-set-per-pf-counts *runremote* run-id test-name))
	    (db:top-test-set-running dbstruct run-id test-name)
	    (db:top-test-set-per-pf-counts dbstruct run-id test-name))
	#f)
      #f))

;; speed up for common cases with a little logic
(define (mt:test-set-state-status-by-id test-id newstate newstatus newcomment)
  (cond
   ((and newstate newstatus newcomment)
    (cdb:client-call *runremote* 'state-status-msg #t *default-numtries* newstate newstatus newcomment test-id))
   ((and newstate newstatus)
    (cdb:client-call *runremote* 'state-status #t *default-numtries* newstate newstatus test-id))
   (else
    (if newstate   (cdb:client-call *runremote* 'set-test-state #t *default-numtries* newstate test-id))
    (if newstatus  (cdb:client-call *runremote* 'set-test-status #t *default-numtries* newstatus test-id))
    (if newcomment (cdb:client-call *runremote* 'set-test-comment #t *default-numtries* newcomment test-id))))
   (mt:process-triggers test-id newstate newstatus)
   #t)
;; ;; speed up for common cases with a little logic
;; (define (mt:test-set-state-status-by-id dbstruct run-id test-id newstate newstatus newcomment)
;;   (cond
;;    ((and newstate newstatus newcomment)
;;     (sqlite3: 'state-status-msg #t *default-numtries* newstate newstatus newcomment test-id))
;;    ((and newstate newstatus)
;;     (cdb:client-call *runremote* 'state-status #t *default-numtries* newstate newstatus test-id))
;;    (else
;;     (if newstate   (cdb:client-call *runremote* 'set-test-state #t *default-numtries* newstate test-id))
;;     (if newstatus  (cdb:client-call *runremote* 'set-test-status #t *default-numtries* newstatus test-id))
;;     (if newcomment (cdb:client-call *runremote* 'set-test-comment #t *default-numtries* newcomment test-id))))
;;    (mt:process-triggers test-id newstate newstatus)
;;    #t)

(define (mt:lazy-get-test-info-by-id test-id)
  (let* ((tdat (hash-table-ref/default *test-info* test-id #f)))
    (if (and tdat 
	     (< (current-seconds)(+ (vector-ref tdat 0) 10)))
	(vector-ref tdat 1)
	;; no need to update *test-info* as that is done in cdb:get-test-info-by-id