Megatest

Check-in [6054963abb]
Login
Overview
Comment:Wrote routine to get previous tests in the current run suite
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | waiver-propagation
Files: files | file ages | folders
SHA1: 6054963abb2e7ebc1cb4762b95fd8560bd397429
User & Date: matt on 2011-08-30 00:09:00
Other Links: branch diff | manifest | tags
Context
2011-08-30
00:22
Implemented WAIVER propagation, but not debugged check-in: 3ee9f5dc73 user: matt tags: waiver-propagation
00:09
Wrote routine to get previous tests in the current run suite check-in: 6054963abb user: matt tags: waiver-propagation
2011-08-29
08:38
Partial implemenation of WAIVER propagation check-in: b94b060f8d user: matt tags: waiver-propagation
Changes

Modified runs.scm from [d357f22eb6] to [9050f708b7].

86
87
88
89
90
91
92
93
94
95
96
97
98
99






















100
101
102
103
104
105
106
107


108








109
110
111
112
113
114
115
			test-name
			pth 
			;; (conc "," (string-intersperse tags ",") ",")
			))
     item-paths )))

;; get the previous record for when this test was run where all keys match but runname
(define (test:get-previous-test-run-record db run-id test-name item-path)
  (let* ((keys    (db:get-keys db))
	 (selstr  (string-intersperse (map (lambda (x)(vector-ref x 0)) keys) ","))
	 (qrystr  (string-intersperse (map (lambda (x)(conc (vector-ref x 0) "=?")) keys) " AND "))
	 (keyvals #f)
	 
    






















    

(define (test-set-status! db run-id test-name state status itemdat-or-path comment dat)
  (let ((item-path (if (string? itemdat-or-path) itemdat-or-path (item-list->path itemdat-or-path)))
	(otherdat  (if dat dat (make-hash-table)))
	;; before proceeding we must find out if the previous test (where all keys matched except runname)
	;; was WAIVED if this test is FAIL
	(waived   (if (equal? status "FAIL")


		      (let ((









    ;; update the primary record IF state AND status are defined
    (if (and state status)
	(sqlite3:execute db "UPDATE tests SET state=?,status=?,event_time=strftime('%s','now') WHERE run_id=? AND testname=? AND item_path=?;" 
			 state status run-id test-name item-path))
    ;; add metadata (need to do this way to avoid SQL injection issues)
    ;; :value







|



|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>








>
>
|
>
>
>
>
>
>
>
>







86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
			test-name
			pth 
			;; (conc "," (string-intersperse tags ",") ",")
			))
     item-paths )))

;; get the previous record for when this test was run where all keys match but runname
(define (test:get-previous-test-run-records db run-id test-name item-path)
  (let* ((keys    (db:get-keys db))
	 (selstr  (string-intersperse (map (lambda (x)(vector-ref x 0)) keys) ","))
	 (qrystr  (string-intersperse (map (lambda (x)(conc (vector-ref x 0) "=?")) keys) " AND "))
	 (keyvals #f))
    ;; first look up the key values from the run selected by run-id
    (sqlite3:for-each-row 
     (lambda (a . b)
       (set! keyvals (cons a b)))
     db
     (conc "SELECT " selstr " FROM runs WHERE run_id=? ORDER BY event_time DESC;"))
    (if (not keyvals)
	#f
	(let ((prev-run-ids '()))
	  (apply sqlite3:for-each-row
		 (lambda (id)
		   (set! prev-run-ids (cons id prev-run-ids)))
		 db
		 (conc "SELECT run_id FROM runs WHERE " qrystr ";"))
	  ;; for each run starting with the most recent look to see if there is a matching test
	  ;; if found then return that matching test record
	  (if (null? prev-run-ids) #f
	      (let loop ((hed (car prev-run-ids))
			 (tal (cdr prev-run-ids)))
		(let ((results (db-get-tests-for-run db test-name item-path)))
		  (if (and (null? results)
			   (not (null? tal)))
		      (loop (car tal)(cdr tal))
		      (car results)))))))))
    

(define (test-set-status! db run-id test-name state status itemdat-or-path comment dat)
  (let ((item-path (if (string? itemdat-or-path) itemdat-or-path (item-list->path itemdat-or-path)))
	(otherdat  (if dat dat (make-hash-table)))
	;; before proceeding we must find out if the previous test (where all keys matched except runname)
	;; was WAIVED if this test is FAIL
	(waived   (if (equal? status "FAIL")
		      (let ((prev-test (test:get-previous-test-run-records db run-id test-name item-path)))
			(if (and prev-test (not (null? prev-test))) ;; true if we found a previous test in this run series
			    (let ((prev-status (db:test-get-status   prev-test))
				  (prev-state  (db:test-get-state    prev-test))
				  (prev-comment (db:test-get-comment prev-test)))
			      (if (and (equal? prev-status "COMPLETED")
				       (equal? prev-state  "WAIVED"))
				  prev-comment ;; waived is either the comment or #f
				  #f))
			    #f))
		      #f)))

    ;; update the primary record IF state AND status are defined
    (if (and state status)
	(sqlite3:execute db "UPDATE tests SET state=?,status=?,event_time=strftime('%s','now') WHERE run_id=? AND testname=? AND item_path=?;" 
			 state status run-id test-name item-path))
    ;; add metadata (need to do this way to avoid SQL injection issues)
    ;; :value