Index: db.scm ================================================================== --- db.scm +++ db.scm @@ -231,11 +231,13 @@ (if currstatus (conc "status='" currstatus "' AND ") "") " testname=? AND NOT (item_path='' AND testname in (SELECT DISTINCT testname FROM tests WHERE testname=? AND item_path != ''));"))) ;;(debug:print 0 "QRY: " qry) (sqlite3:execute db qry newstate newstatus testname testname))) testnames)) - ;; "('" (string-intersperse tests "','") "')") + +(define (db:delete-tests-in-state db run-id state) + (sqlite3:execute db "DELETE FROM tests WHERE state=? AND run_id=?;" state run-id)) (define (db:test-set-state-status-by-id db test-id newstate newstatus newcomment) (if newstate (sqlite3:execute db "UPDATE tests SET state=? WHERE id=?;" newstate test-id)) (if newstatus (sqlite3:execute db "UPDATE tests SET status=? WHERE id=?;" newstatus test-id)) (if newcomment (sqlite3:execute db "UPDATE tests SET comment=? WHERE id=?;" newcomment test-id))) Index: runs.scm ================================================================== --- runs.scm +++ runs.scm @@ -268,11 +268,17 @@ (run-id (register-run db keys))) ;; test-name))) ;; on the first pass or call to run-tests set FAILS to NOT_STARTED if ;; -keepgoing is specified (if (and (eq? *passnum* 0) (args:get-arg "-keepgoing")) - (db:set-tests-state-status db run-id test-names #f "FAIL" "NOT_STARTED" "FAIL")) + (begin + ;; have to delete test records where NOT_STARTED since they can cause -keepgoing to + ;; get stuck due to becoming inaccessible from a failed test. I.e. if test B depends + ;; on test A but test B reached the point on being registered as NOT_STARTED and test + ;; A failed for some reason then on re-run using -keepgoing the run can never complete. + (db:delete-tests-in-state db run-id "NOT_STARTED") + (db:set-tests-state-status db run-id test-names #f "FAIL" "NOT_STARTED" "FAIL"))) (set! *passnum* (+ *passnum* 1)) (let loop ((numtimes 0)) (for-each (lambda (test-name) (if (runs:can-run-more-tests db) @@ -459,14 +465,15 @@ (sqlite3:finalize! ldb))))) waiting-test-names) ;; (sleep 10) ;; no point in rushing things at this stage? (loop (hash-table-keys *waiting-queue*))))))) -(define (get-dir-up-one dir) - (let ((dparts (string-split dir "/"))) +(define (get-dir-up-n dir . params) + (let ((dparts (string-split dir "/")) + (count (if (null? params) 1 (car params)))) (conc "/" (string-intersperse - (take dparts (- (length dparts) 1)) + (take dparts (- (length dparts) count)) "/")))) ;; Remove runs ;; fields are passing in through (define (runs:remove-runs db runnamepatt testpatt itempatt) (let* ((keys (db-get-keys db)) @@ -484,34 +491,42 @@ (if (not (null? tests)) (begin (debug:print 1 "Removing tests for run: " runkey " " (db:get-value-by-header run header "runname")) (for-each (lambda (test) - (debug:print 1 " " (db:test-get-testname test) " id: " (db:test-get-id test) " " (db:test-get-item-path test)) - (db:delete-test-records db (db:test-get-id test)) - (if (> (string-length (db:test-get-rundir test)) 5) ;; bad heuristic but should prevent /tmp /home etc. - (let ((fullpath (db:test-get-rundir test))) ;; "/" (db:test-get-item-path test)))) - (set! lasttpath fullpath) - (debug:print 1 "rm -rf " fullpath) - (system (conc "rm -rf " fullpath)) - (let ((cmd (conc "rmdir -p " (get-dir-up-one fullpath)))) - (debug:print 1 cmd) - (system cmd)) - ))) - tests))) + (let* ((item-path (db:test-get-item-path test)) + (test-name (db:test-get-testname test)) + (run-dir (db:test-get-rundir test))) + (debug:print 1 " " (db:test-get-testname test) " id: " (db:test-get-id test) " " item-path) + (db:delete-test-records db (db:test-get-id test)) + (if (> (string-length run-dir) 5) ;; bad heuristic but should prevent /tmp /home etc. + (let ((fullpath run-dir)) ;; "/" (db:test-get-item-path test)))) + (set! lasttpath fullpath) + (debug:print 1 "rm -rf " fullpath) + (system (conc "rm -rf " fullpath)) + (let* ((dirs-count (+ 1 (length keys)(length (string-split item-path "/")))) + (dir-to-rem (get-dir-up-n fullpath dirs-count)) + (remainingd (string-substitute (regexp (conc "^" dir-to-rem "/")) "" fullpath)) + (cmd (conc "cd " dir-to-rem "; rmdir -p " remainingd ))) + (if (file-exists? fullpath) + (begin + (debug:print 1 cmd) + (system cmd))) + )) + ))) + tests))) (let ((remtests (db-get-tests-for-run db (db:get-value-by-header run header "id")))) (if (null? remtests) ;; no more tests remaining (let* ((dparts (string-split lasttpath "/")) (runpath (conc "/" (string-intersperse (take dparts (- (length dparts) 1)) "/")))) (debug:print 1 "Removing run: " runkey " " (db:get-value-by-header run header "runname")) (db:delete-run db run-id) ;; need to figure out the path to the run dir and remove it if empty - ;; (if (null? (glob (conc runpath "/*"))) - ;; (begin - ;; (debug:print 1 "Removing run dir " runpath) - ;; (system (conc "rmdir -p " runpath)))) - ))) - ))) + ;; (if (null? (glob (conc runpath "/*"))) + ;; (begin + ;; (debug:print 1 "Removing run dir " runpath) + ;; (system (conc "rmdir -p " runpath)))) + )))) + )) runs))) -