Megatest

Diff
Login

Differences From Artifact [11e94b6a23]:

To Artifact [1e0798cda7]:


214
215
216
217
218
219
220
221
222
223
224
225
226










227
228
229
230
231
232
233
234
214
215
216
217
218
219
220






221
222
223
224
225
226
227
228
229
230

231
232
233
234
235
236
237







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







(define (db:delete-test-records db test-id)
  (sqlite3:execute db "DELETE FROM test_steps WHERE test_id=?;" test-id)
  (sqlite3:execute db "DELETE FROM tests WHERE id=?;" test-id))

;; set tests with state currstate and status currstatus to newstate and newstatus
;; use currstate = #f and or currstatus = #f to apply to any state or status respectively
;; WARNING: SQL injection risk
(define (db:set-tests-state-status db run-id tests currstate currstatus newstate newstatus)
  (sqlite3:execute db (conc "UPDATE tests SET state=?,status=? WHERE "
			    (if currstate  (conc "state='" currstate "' AND ") "")
			    (if currstatus (conc "status='" currstatus "' AND ") "")
			    " testname in "
			    "('" (string-intersperse tests "','") "')")
(define (db:set-tests-state-status db run-id testnames currstate currstatus newstate newstatus)
  (for-each (lambda (testname)
	      (let ((qry (conc "UPDATE tests SET state=?,status=? WHERE "
					(if currstate  (conc "state='" currstate "' AND ") "")
					(if currstatus (conc "status='" currstatus "' AND ") "")
					" testname=? AND NOT (item_path='' AND testname in (SELECT DISTINCT testname FROM tests WHERE testname=? AND item_path != ''));")))
		;;(print "QRY: " qry)
		(sqlite3:execute db qry newstate newstatus testname testname)))
	    testnames))
	      ;; "('" (string-intersperse tests "','") "')")
		   newstate newstatus))

(define (db:get-count-tests-running db)
  (let ((res 0))
    (sqlite3:for-each-row
     (lambda (count)
       (set! res count))
     db