Index: db.scm ================================================================== --- db.scm +++ db.scm @@ -424,17 +424,18 @@ ;;====================================================================== ;; states and statuses are lists, turn them into ("PASS","FAIL"...) and use NOT IN ;; i.e. these lists define what to NOT show. ;; states and statuses are required to be lists, empty is ok -(define (db:get-tests-for-run db run-id testpatt itempatt states statuses) +;; not-in #t = above behaviour, #f = must match +(define (db:get-tests-for-run db run-id testpatt itempatt states statuses #!key (not-in #t)) (let* ((res '()) (states-str (conc "('" (string-intersperse states "','") "')")) (statuses-str (conc "('" (string-intersperse statuses "','") "')")) (qry (conc "SELECT id,run_id,testname,state,status,event_time,host,cpuload,diskfree,uname,rundir,item_path,run_duration,final_logf,comment " " FROM tests WHERE run_id=? AND testname like ? AND item_path LIKE ? " - " AND NOT (state in " states-str " AND status IN " statuses-str ") " + " AND " (if not-in "NOT" "") " (state in " states-str " AND status IN " statuses-str ") " ;; " ORDER BY id DESC;" " ORDER BY event_time ASC;" ;; POTENTIAL ISSUE! CHECK ME! Does anyting depend on this being sorted by id? ))) (debug:print 8 "INFO: db:get-tests-for-run qry=" qry) (sqlite3:for-each-row @@ -1202,17 +1203,17 @@ (port (vector-ref *runremote* 1))) ((rpc:procedure 'rdb:get-runs host port) runnamepatt numruns startrunoffset keypatts)) (db:get-runs db runnamepatt numruns startrunoffset keypatts))) -(define (rdb:get-tests-for-run db run-id testpatt itempatt states statuses) +(define (rdb:get-tests-for-run db run-id testpatt itempatt states statuses #!key (not-in #t)) (if *runremote* (let ((host (vector-ref *runremote* 0)) (port (vector-ref *runremote* 1))) ((rpc:procedure 'rdb:get-tests-for-run host port) - run-id testpatt itempatt states statuses)) - (db:get-tests-for-run db run-id testpatt itempatt states statuses))) + run-id testpatt itempatt states statuses not-in: not-in)) + (db:get-tests-for-run db run-id testpatt itempatt states statuses not-in: not-in))) (define (rdb:get-test-data-by-id db test-id) (if *runremote* (let ((host (vector-ref *runremote* 0)) (port (vector-ref *runremote* 1))) Index: megatest.scm ================================================================== --- megatest.scm +++ megatest.scm @@ -252,11 +252,13 @@ (exit 1)) ;; put test parameters into convenient variables (runs:remove-runs db (args:get-arg ":runname") (args:get-arg "-testpatt") - (args:get-arg "-itempatt"))) + (args:get-arg "-itempatt") + state: (args:get-arg ":state") + status: (args:get-arg ":status"))) (sqlite3:finalize! db) (set! *didsomething* #t))))) (if (args:get-arg "-remove-runs") (general-run-call Index: runs.scm ================================================================== --- runs.scm +++ runs.scm @@ -493,23 +493,26 @@ (conc "/" (string-intersperse (take dparts (- (length dparts) count)) "/")))) ;; Remove runs ;; fields are passing in through -(define (runs:remove-runs db runnamepatt testpatt itempatt) +(define (runs:remove-runs db runnamepatt testpatt itempatt #!key (state #f)(status #f)) (let* ((keys (rdb:get-keys db)) (rundat (runs:get-runs-by-patt db keys runnamepatt)) (header (vector-ref rundat 0)) - (runs (vector-ref rundat 1))) + (runs (vector-ref rundat 1)) + (states (if state (string-split state ",") '())) + (statuses (if status (string-split status ",") '()))) (debug:print 1 "Header: " header) (for-each (lambda (run) (let ((runkey (string-intersperse (map (lambda (k) (db:get-value-by-header run header (vector-ref k 0))) keys) "/")) (dirs-to-remove (make-hash-table))) (let* ((run-id (db:get-value-by-header run header "id") ) - (tests (rdb:get-tests-for-run db (db:get-value-by-header run header "id") testpatt itempatt '() '())) + ;; not-in: switches from the default get-tests-for-run behavior to require a match + (tests (rdb:get-tests-for-run db (db:get-value-by-header run header "id") testpatt itempatt states statuses not-in: #f)) (lasttpath "/does/not/exist/I/hope")) (if (not (null? tests)) (begin (debug:print 1 "Removing tests for run: " runkey " " (db:get-value-by-header run header "runname"))