@@ -617,6 +617,122 @@ def compile_sketch(self, url, boards, iframe=False, project_view=False):
617
617
618
618
return compilation_results
619
619
620
+ def comment_compile_libraries_examples (self , sketches , library_examples_dic = {}, iframe = False , project_view = False ,
621
+ logfile = None , compile_type = 'sketch' , create_report = False , comment = False ):
622
+
623
+ urls_to_visit , log_entry , log_file , log_time = self .resume_log (logfile , compile_type , sketches )
624
+
625
+ # Initialize DisqusWrapper.
626
+ disqus_wrapper = DisqusWrapper (log_time )
627
+ print "urls to visit:" , urls_to_visit
628
+
629
+ print '\n Commenting and compiling:' , len (urls_to_visit ), 'libraries and examples.'
630
+
631
+ total_sketches = len (urls_to_visit )
632
+ tic = time .time ()
633
+ library_re = re .compile (r'^.+/library/.+$' )
634
+
635
+ for url in urls_to_visit :
636
+
637
+ if library_re .match (url ):
638
+ library = url .split ('/' )[- 1 ]
639
+ for key , value in library_examples_dic .iteritems ():
640
+ if (key == library and len (value )== 0 ):
641
+ if logfile is None or not self .run_full_compile_tests :
642
+ toc = time .time ()
643
+ continue
644
+
645
+ # Update Disqus comments.
646
+ current_date = strftime ('%Y-%m-%d' , log_time )
647
+ if comment and compile_type in ['library' , 'target_library' ]:
648
+ library = key
649
+ examples = False
650
+ log_entry = disqus_wrapper .handle_library_comment (library , current_date , log_entry , examples )
651
+ self .create_log (log_file , log_entry , compile_type )
652
+ toc = time .time ()
653
+ if toc - tic >= SAUCELABS_TIMEOUT_SECONDS :
654
+ print '\n Stopping tests to avoid saucelabs timeout'
655
+ print 'Test duration:' , int (toc - tic ), 'sec'
656
+ return
657
+ else :
658
+ sketch = url
659
+ # Read the boards map in case current sketch/example requires a special board configuration.
660
+ boards = BOARDS_DB ['default_boards' ]
661
+ url_fragments = urlparse (sketch )
662
+ if url_fragments .path in BOARDS_DB ['special_boards' ]:
663
+ boards = BOARDS_DB ['special_boards' ][url_fragments .path ]
664
+
665
+ if len (boards ) > 0 :
666
+ # Run Verify.
667
+ results = self .compile_sketch (sketch , boards , iframe = iframe , project_view = project_view )
668
+ else :
669
+ results = [
670
+ {
671
+ 'status' : 'unsupported'
672
+ }
673
+ ]
674
+
675
+ """If test is not running in full mode (-F option) or logfile is None
676
+ no logs are produced inside /logs directory and we continue with sketches
677
+ compilation.
678
+ """
679
+ if logfile is None or not self .run_full_compile_tests :
680
+ toc = time .time ()
681
+ continue
682
+
683
+ # Register current URL into log.
684
+ if sketch not in log_entry :
685
+ log_entry [sketch ] = {}
686
+
687
+ test_status = '.'
688
+
689
+ # Log the compilation results.
690
+ openFailFlag = False
691
+ for result in results :
692
+ if result ['status' ] in ['success' , 'fail' , 'error' ] and result ['status' ] not in log_entry [sketch ]:
693
+ log_entry [sketch ][result ['status' ]] = []
694
+ if result ['status' ] == 'success' :
695
+ log_entry [sketch ]['success' ].append (result ['board' ])
696
+ elif result ['status' ] == 'fail' :
697
+ log_entry [sketch ]['fail' ].append (result ['board' ])
698
+ test_status = 'F'
699
+ elif result ['status' ] == 'open_fail' :
700
+ log_entry [sketch ]['open_fail' ] = True
701
+ openFailFlag = True
702
+ test_status = 'O'
703
+ elif result ['status' ] == 'error' :
704
+ log_entry [sketch ]['error' ].append ({
705
+ 'board' : result ['board' ],
706
+ 'error' : result ['message' ]
707
+ })
708
+ test_status = 'E'
709
+ elif result ['status' ] == 'unsupported' :
710
+ log_entry [sketch ]['unsupported' ] = True
711
+ test_status = 'U'
712
+
713
+ # Update Disqus comments.
714
+ current_date = strftime ('%Y-%m-%d' , log_time )
715
+
716
+ if comment and compile_type in ['library' , 'target_library' ]:
717
+ log_entry = disqus_wrapper .update_comment (sketch , results , current_date , log_entry , openFailFlag , total_sketches )
718
+
719
+ self .create_log (log_file , log_entry , compile_type )
720
+
721
+ # Display progress
722
+ sys .stdout .write (test_status )
723
+ sys .stdout .flush ()
724
+
725
+ toc = time .time ()
726
+ if toc - tic >= SAUCELABS_TIMEOUT_SECONDS :
727
+ print '\n Stopping tests to avoid saucelabs timeout'
728
+ print 'Test duration:' , int (toc - tic ), 'sec'
729
+ return
730
+
731
+ # Generate a report if requested.
732
+ if compile_type != 'target_library' and create_report and self .run_full_compile_tests :
733
+ report_creator (compile_type , log_entry , log_file )
734
+ print '\n Test duration:' , int (toc - tic ), 'sec'
735
+
620
736
def compile_all_sketches (self , url , selector , ** kwargs ):
621
737
"""Compiles all sketches on the page at `url`. `selector` is a CSS selector
622
738
that should select all relevant <a> tags containing links to sketches.
0 commit comments