Megatest

Check-in [a7cf53bc3a]
Login
Overview
Comment:Pulled in old stml code to make hierarchial html.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | html-tree
Files: files | file ages | folders
SHA1: a7cf53bc3a4eb2873faeea080bf6c8c5792f7da5
User & Date: matt on 2016-10-16 23:49:54
Other Links: branch diff | manifest | tags
Context
2016-10-17
01:09
runs index works check-in: fd65f92d77 user: matt tags: html-tree
2016-10-16
23:49
Pulled in old stml code to make hierarchial html. check-in: a7cf53bc3a user: matt tags: html-tree
19:28
Fixed -create-test check-in: ecbb4766f7 user: matt tags: v1.62
Changes

Modified common.scm from [15cce78570] to [cacda34afd].

618
619
620
621
622
623
624

















































625
626
627
628
629
630
631
	     (tal     (cdr inlst)))
    (if (not (null? tal))
	(loop (max hed max-val)
	      (car tal)
	      (cdr tal))
	(max hed max-val))))



















































;;======================================================================
;; M U N G E   D A T A   I N T O   N I C E   F O R M S
;;======================================================================

;; Generate an index for a sparse list of key values
;;   ( (rowname1 colname1 val1)(rowname2 colname2 val2) )







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
	     (tal     (cdr inlst)))
    (if (not (null? tal))
	(loop (max hed max-val)
	      (car tal)
	      (cdr tal))
	(max hed max-val))))

;; path list to hash-table tree
;;   ((a b c)(a b d)(e b c)) => ((a (b (d) (c))) (e (b (c))))
;;
(define (common:list->htree lst)
  (let ((resh (make-hash-table)))
    (for-each
     (lambda (inlst)
       (let loop ((ht  resh)
		  (hed (car inlst))
		  (tal (cdr inlst)))
	 (if (hash-table-ref/default ht hed #f)
	     (if (not (null? tal))
		 (loop (hash-table-ref ht hed)
		       (car tal)
		       (cdr tal)))
	     (begin
	       (hash-table-set! ht hed (make-hash-table))
	       (loop ht hed tal)))))
     lst)
    resh))

;; hash-table tree to html list tree
;;
;;   tipfunc takes two parameters: y the tip value and path the path to that point
;;
(define (common:htree->html ht path tipfunc)
  (s:ul
   (map (lambda (x)
	  (let ((levelname (car x)))
	    (s:li
	     levelname
	     (let ((y       (cdr x))
		   (newpath (append path (list levelname))))
	       ;; (print "levelname=" levelname " newpath=" newpath)
	       (if (hash-table? y)
		   (common:htree->html y newpath tipfunc)
		   (tipfunc y newpath))))))
	(hash-table->alist ht))))

;; hash-table tree to alist tree
;;
(define (common:htree->atree ht)
  (map (lambda (x)
	 (cons (car x)
	       (let ((y (cdr x)))
		 (if (hash-table? y)
		     (common:htree->atree y)
		     y))))
       (hash-table->alist ht)))

;;======================================================================
;; M U N G E   D A T A   I N T O   N I C E   F O R M S
;;======================================================================

;; Generate an index for a sparse list of key values
;;   ( (rowname1 colname1 val1)(rowname2 colname2 val2) )

Modified tests.scm from [b7b139f82b] to [45e5456322].

566
567
568
569
570
571
572

















































































































































573
574
575
576
577
578
579
	;; run-id
	;; (hash-table-map
	;;  state-status-counts
	;;  (lambda (key val)
	;;	(append key (list val)))))
	))))


















































































































































;; CHECK - WAS THIS ADDED OR REMOVED? MANUAL MERGE WITH API STUFF!!!
;;
;; get a pretty table to summarize steps
;;
;; (define (dcommon:process-steps-table steps);; db test-id #!key (work-area #f))
(define (tests:process-steps-table steps);; db test-id #!key (work-area #f))
;;  (let ((steps   (db:get-steps-for-test db test-id work-area: work-area)))







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
	;; run-id
	;; (hash-table-map
	;;  state-status-counts
	;;  (lambda (key val)
	;;	(append key (list val)))))
	))))

(define tests:css-jscript-block
#<<EOF
<style type="text/css">
ul.LinkedList { display: block; }
/* ul.LinkedList ul { display: none; } */
.HandCursorStyle { cursor: pointer; cursor: hand; }  /* For IE */
  </style>

  <script type="text/JavaScript">
    // Add this to the onload event of the BODY element
    function addEvents() {
      activateTree(document.getElementById("LinkedList1"));
    }

    // This function traverses the list and add links 
    // to nested list items
    function activateTree(oList) {
      // Collapse the tree
      for (var i=0; i < oList.getElementsByTagName("ul").length; i++) {
        oList.getElementsByTagName("ul")[i].style.display="none";            
      }                                                                  
      // Add the click-event handler to the list items
      if (oList.addEventListener) {
        oList.addEventListener("click", toggleBranch, false);
      } else if (oList.attachEvent) { // For IE
        oList.attachEvent("onclick", toggleBranch);
      }
      // Make the nested items look like links
      addLinksToBranches(oList);
    }

    // This is the click-event handler
    function toggleBranch(event) {
      var oBranch, cSubBranches;
      if (event.target) {
        oBranch = event.target;
      } else if (event.srcElement) { // For IE
        oBranch = event.srcElement;
      }
      cSubBranches = oBranch.getElementsByTagName("ul");
      if (cSubBranches.length > 0) {
        if (cSubBranches[0].style.display == "block") {
          cSubBranches[0].style.display = "none";
        } else {
          cSubBranches[0].style.display = "block";
        }
      }
    }

    // This function makes nested list items look like links
    function addLinksToBranches(oList) {
      var cBranches = oList.getElementsByTagName("li");
      var i, n, cSubBranches;
      if (cBranches.length > 0) {
        for (i=0, n = cBranches.length; i < n; i++) {
          cSubBranches = cBranches[i].getElementsByTagName("ul");
          if (cSubBranches.length > 0) {
            addLinksToBranches(cSubBranches[0]);
            cBranches[i].className = "HandCursorStyle";
            cBranches[i].style.color = "blue";
            cSubBranches[0].style.color = "black";
            cSubBranches[0].style.cursor = "auto";
          }
        }
      }
    }
  </script>
EOF
)

;; (tests:create-html-tree "test-index.html")
;;
(define (tests:create-html-tree outf)
  (if (common:simple-file-lock (conc outf ".lock"))
      (let* ((oup (open-output-file outf))
	     (area-name (common:get-testsuite-name))
	     (keys      (rmt:get-keys))
	     (numkeys   (length keys))
	     (runsdat   (rmt:get-runs "%" #f #f (map (lambda (x)(list x "%")) keys)))
	     (header    (vector-ref runsdat 0))
	     (runs      (vector-ref runsdat 1))
	     (runtreedat (map (lambda (x)
				(append (take (vector->list x) numkeys)
					(list (vector-ref x (+ 1 numkeys))))) ;; gets the runname
			      runs))
	     (runs-htree (common:list->htree runtreedat)))
	(s:output-new
	 oup
	 (s:html tests:css-jscript-block
		 (s:title "Summary for " area-name)
		 (s:body 'onload "addEvents();"
			 ;; top list
			 (s:ul 'id "LinkedList1" 'class "LinkedList"
			       (s:li
				"Runs"
				(common:htree->html runs-htree
						    '()
						    (lambda (x p)
						      (apply s:a x p))))))))
	(close-output-port oup)
	(common:simple-file-release-lock (conc outf ".lock"))
	#t)
      #f))

;;   (let* ((outputfilename (conc "megatest-rollup-" test-name ".html"))
;; 	 (orig-dir       (current-directory))
;; 	 (logf-info      (rmt:test-get-logfile-info run-id test-name))
;; 	 (logf           (if logf-info (cadr logf-info) #f))
;; 	 (path           (if logf-info (car  logf-info) #f)))
;;     ;; This query finds the path and changes the directory to it for the test
;;     (if (and (string? path)
;; 	     (directory? path)) ;; can get #f here under some wierd conditions. why, unknown ...
;; 	(begin
;; 	  (debug:print 4 *default-log-port* "Found path: " path)
;; 	  (change-directory path))
;; 	;; (set! outputfilename (conc path "/" outputfilename)))
;; 	(debug:print-error 0 *default-log-port* "summarize-items for run-id=" run-id ", test-name=" test-name ", no such path: " path))
;;     (debug:print 4 *default-log-port* "summarize-items with logf " logf ", outputfilename " outputfilename " and force " force)
;;     (if (or (equal? logf "logs/final.log")
;; 	    (equal? logf outputfilename)
;; 	    force)
;; 	(let ((my-start-time (current-seconds))
;; 	      (lockf         (conc outputfilename ".lock")))
;; 	  (let loop ((have-lock  (common:simple-file-lock lockf)))
;; 	    (if have-lock
;; 		(let ((script (configf:lookup *configdat* "testrollup" test-name)))
;; 		  (print "Obtained lock for " outputfilename)
;; 		  ;; (rmt:top-test-set-per-pf-counts run-id test-name)
;; 		  (rmt:roll-up-pass-fail-counts run-id test-name "" #f #f)
;; 		  (rmt:top-test-set-per-pf-counts run-id test-name)
;; 		  (if script
;; 		      (system (conc script " > " outputfilename " & "))
;; 		      (tests:generate-html-summary-for-iterated-test run-id test-id test-name outputfilename))
;; 		  (change-directory orig-dir)
;; 		  ;; NB// tests:test-set-toplog! is remote internal...
;; 		  (tests:test-set-toplog! run-id test-name outputfilename))
;; 		;; didn't get the lock, check to see if current update started later than this 
;; 		;; update, if so we can exit without doing any work
;; 		(if (> my-start-time (file-modification-time lockf))
;; 		    ;; we started since current re-gen in flight, delay a little and try again
;; 		    (begin
;; 		      (debug:print-info 1 *default-log-port* "Waiting to update " outputfilename ", another test currently updating it")
;; 		      (thread-sleep! (+ 5 (random 5))) ;; delay between 5 and 10 seconds
;; 		      (loop (common:simple-file-lock lockf))))))))))

;; CHECK - WAS THIS ADDED OR REMOVED? MANUAL MERGE WITH API STUFF!!!
;;
;; get a pretty table to summarize steps
;;
;; (define (dcommon:process-steps-table steps);; db test-id #!key (work-area #f))
(define (tests:process-steps-table steps);; db test-id #!key (work-area #f))
;;  (let ((steps   (db:get-steps-for-test db test-id work-area: work-area)))
664
665
666
667
668
669
670
671

672
673
674
675
676
677
678
			   (if (eq? time-a time-b)
			       (string<? (conc (vector-ref a 2))
					 (conc (vector-ref b 2)))
			       #f))
		       (string<? (conc time-a)(conc time-b)))))))))


;; summarize test

(define (tests:summarize-test run-id test-id)
  (let* ((test-dat  (rmt:get-test-info-by-id run-id test-id))
	 (steps-dat (rmt:get-steps-for-test run-id test-id))
	 (test-name (db:test-get-testname test-dat))
	 (item-path (db:test-get-item-path test-dat))
	 (full-name (db:test-make-full-name test-name item-path))
	 (oup       (open-output-file (conc (db:test-get-rundir test-dat) "/test-summary.html")))







|
>







809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
			   (if (eq? time-a time-b)
			       (string<? (conc (vector-ref a 2))
					 (conc (vector-ref b 2)))
			       #f))
		       (string<? (conc time-a)(conc time-b)))))))))


;; summarize test in to a file test-summary.html in the test directory
;;
(define (tests:summarize-test run-id test-id)
  (let* ((test-dat  (rmt:get-test-info-by-id run-id test-id))
	 (steps-dat (rmt:get-steps-for-test run-id test-id))
	 (test-name (db:test-get-testname test-dat))
	 (item-path (db:test-get-item-path test-dat))
	 (full-name (db:test-make-full-name test-name item-path))
	 (oup       (open-output-file (conc (db:test-get-rundir test-dat) "/test-summary.html")))