Megatest

Diff
Login

Differences From Artifact [51f5558f50]:

To Artifact [10f8461975]:


33
34
35
36
37
38
39














40
41
42
43
44
45
46
33
34
35
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







+
+
+
+
+
+
+
+
+
+
+
+
+
+







;; (declare (uses filedb))
(declare (uses subrun))

(include "common_records.scm")
(include "db_records.scm")
(include "run_records.scm")

(define (dboard:launch-testpanel run-id test-id)
  (let* (;; (cfg-sh  (conc *common:this-exe-dir* "/cfg.sh"))
         ;; (cmd (conc
         ;;       (if (common:file-exists? cfg-sh)
         ;;           (conc "source "cfg-sh" && ")
         ;;           "")
         ;;       *common:this-exe-fullpath*
         ;;       " -test " run-id "," test-id
         ;;       " &"))
         (cmd (conc *common:this-exe-dir*"/../dashboard "
                    "-test " run-id "," test-id
                    " &")))
    (system cmd)))


(define (dashboard:run-menu-items  run-id test-id target runname test-name testpatt item-test-path test-info)
  (list
   (iup:menu-item
    (conc "Rerun " testpatt)
    #:action
    (lambda (obj)
144
145
146
147
148
149
150
151




















152
153









154
155
156
157
158
159
160
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203








+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+


+
+
+
+
+
+
+
+
+







                         (get-environment-variable "EDITOR") "vi"))
             (tconfig (conc (hash-table-ref all-tests test-name) "/testconfig"))
             (cmd (conc (if (string-search editor-rx editor)
                            (conc "xterm -e " editor)
                            editor)
                        " " tconfig " &")))
        (system cmd))))))

(define (dashboard:step-logs-menu-item  run-id test-id target runname test-name testpatt item-test-path test-info)
  (let* ((steps (tests:get-compressed-steps run-id test-id))   ;; #<stepname start end status Duration Logfile Comment id>
         (rundir (db:test-get-rundir test-info)))
    
    (iup:menu-item
     "Step logs"
     (apply iup:menu
            (map (lambda (step)
                   (let ((stepname (vector-ref step 0))
                         (logfile  (vector-ref step 5))
                         (status   (vector-ref step 3)))
                     (iup:menu-item
                      (conc stepname "/" (if (string=? logfile "") "no log!" logfile) " (" status ")")
                      #:action (lambda (obj)
                                 (let ((fullfile (conc rundir "/" logfile)))
                                   (if (common:file-exists? fullfile)
                                       (dcommon:run-html-viewer fullfile)
                                       (message-window (conc "file " fullfile " not found"))))))))
                 steps)))))

(define (dashboard:toplevel-menu-items  run-id test-id target runname test-name testpatt item-test-path test-info)
  (list

   (iup:menu-item
    "Test Control Panel"
    #:action
    (lambda (obj)
      (dboard:launch-testpanel run-id test-id)))
   
   (dashboard:step-logs-menu-item  run-id test-id target runname test-name testpatt item-test-path test-info)

   (iup:menu-item
    (conc "Rerun " item-test-path)
    #:action
    (lambda (obj)
      (common:run-a-command
       (conc "megatest -set-state-status NOT_STARTED,n/a -run -target " target
             " -runname " runname
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224

225
226
227
228
229
230
231
226
227
228
229
230
231
232






233
234
235
236
237
238
239
240
241
242
243
244

















245
246
247
248
249
250
251
252







-
-
-
-
-
-












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







     (if has-subrun
         (iup:menu-item
          "Launch subrun dashboard"
          #:action
          (lambda (obj)
            (subrun:launch-dashboard rundir)))
         (iup:vbox)))
   (iup:menu 
    (iup:menu-item
     "Test Control Panel"
     #:action
     (lambda (obj)
       (launch-testpanel run-id test-id)))
    
    (iup:menu-item
     (conc "View Log " item-test-path)
     #:action
     (lambda (obj)
       (let* ((rundir    (db:test-get-rundir      test-info))
              (logf      (db:test-get-final_logf  test-info))
              (fullfile  (conc rundir "/" logf)))
         (if (common:file-exists? fullfile)
             (dcommon:run-html-viewer fullfile)
             (message-window (conc "file " fullfile " not found.")))))
     )
    (let* ((steps (tests:get-compressed-steps run-id test-id))   ;; #<stepname start end status Duration Logfile Comment id>
           (rundir (db:test-get-rundir test-info)))
      (iup:menu-item
       "Step logs"
       (apply iup:menu
              (map (lambda (step)
                     (let ((stepname (vector-ref step 0))
                           (logfile  (vector-ref step 5))
                           (status   (vector-ref step 3)))
                       (iup:menu-item
                        (conc stepname "/" (if (string=? logfile "") "no log!" logfile) " (" status ")")
                        #:action (lambda (obj)
                                   (let ((fullfile (conc rundir "/" logfile)))
                                     (if (common:file-exists? fullfile)
                                         (dcommon:run-html-viewer fullfile)
                                         (message-window (conc "file " fullfile " not found"))))))))
                   steps)))))))
    ))
;; example section for megatest.config:
;;
;; 
;; [custom-context-menu-items]
;; #<unique var> <menu item text, can have template variables> : <command line with template %variable%s>
;; item1  custom show run-id (%run-id%):echo "%run-id%"
;; item2  custom show test-id (%test-id%):echo "%test-id%"
275
276
277
278
279
280
281
282

283
284
285
286
287
288
289











290
291
292
293
294
295
296
296
297
298
299
300
301
302

303
304
305
306
307
308


309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326







-
+





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







                              (car x)
                              (->string (cdr x))
                              i
                              #t))
                           menu-item-text-raw
                           subst-alist)))
               (iup:menu-item
                menu-item-text
                (conc "*"menu-item-text)
                #:action
                (lambda (obj)
                  ;; TODO: with-env-vars <runconfig target vars, env-override vars from mtest>
                  ;; TODO: with-env-vars MT_*

                  (let* ((foo 'foo))
                    (common:run-a-command command-line)))))
                  (let* ((scheme-match (string-match "^#(\\(.*)" command-line)))
                    ;;(BB> "cmdline is >"command-line"<")
                    (if scheme-match
                        (begin
                          (handle-exceptions
                           exn
                           (print "error with custom menu scheme")
                           (begin
                             ;;(BB> "gonna eval it!")
                             (eval (with-input-from-string (cadr scheme-match) read)))))
                        (common:run-a-command command-line))))))
             #f)))
     vars)))

(define (dashboard:context-menu  run-id test-id target runname test-name testpatt item-test-path test-info)
  (let* ((run-menu-items
          (dashboard:run-menu-items  run-id test-id target runname test-name testpatt item-test-path test-info))
         (test-menu-items