@@ -96,6 +96,9 @@ def read_last_log(compile_type):
96
96
logs_re = re .compile (r'.+cb_compile_tester.+' )
97
97
if compile_type == 'library' :
98
98
logs_re = re .compile (r'.+libraries_test.+' )
99
+ elif compile_type == 'fetch' :
100
+ logs_re = re .compile (r'.+libraries_fetch.+' )
101
+
99
102
logs = sorted ([x for x in logs if x != '.gitignore' and logs_re .match (x )])
100
103
101
104
log_timestamp_re = re .compile (r'(\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2})-.+\.json' )
@@ -122,6 +125,8 @@ def report_creator(compile_type, log_entry, log_file):
122
125
logs_re = re .compile (r'.+cb_compile_tester.+' )
123
126
if compile_type == 'library' :
124
127
logs_re = re .compile (r'.+libraries_test.+' )
128
+ elif compile_type == 'fetch' :
129
+ logs_re = re .compile (r'.+libraries_fetch.+' )
125
130
126
131
logs = sorted ([x for x in logs if x != '.gitignore' and logs_re .match (x )])
127
132
tail = logs [- 2 :]
@@ -145,6 +150,12 @@ def report_creator(compile_type, log_entry, log_file):
145
150
changes += 1
146
151
continue
147
152
153
+ if compile_type == 'fetch' :
154
+ if old_log [url ] != new_log [url ]:
155
+ diff [url ] = new_log [url ]
156
+ changes += 1
157
+ continue
158
+
148
159
for result in new_log [url ].keys ():
149
160
if result not in old_log [url ]:
150
161
if not url in diff :
@@ -384,6 +395,71 @@ def delete_project(self, project_name):
384
395
except :
385
396
pass
386
397
398
+ def open_all_libraries_and_examples (self , url , logfile ):
399
+ self .open (url )
400
+ examples = self .execute_script (_GET_SKETCHES_SCRIPT .format (selector = '.accordion li a' ), '$' )
401
+ assert len (examples ) > 0
402
+ libraries = self .execute_script (_GET_SKETCHES_SCRIPT .format (selector = '.library_link' ), '$' )
403
+ assert len (libraries ) > 0
404
+ examples_libraries = examples + libraries
405
+
406
+ log_time = gmtime ()
407
+ log_file = strftime (logfile , log_time )
408
+ log_entry = {}
409
+
410
+ urls_visited = {}
411
+ last_log = read_last_log ('fetch' )
412
+ if last_log ['log' ]:
413
+ # resume previous compile
414
+ log_time = strptime (last_log ['timestamp' ], '%Y-%m-%d_%H-%M-%S' )
415
+ log_file = strftime (logfile , log_time )
416
+ log_entry = last_log ['log' ]
417
+ for url in last_log ['log' ]:
418
+ urls_visited [url ] = True
419
+
420
+ urls_to_visit = []
421
+ for url in examples_libraries :
422
+ if url not in urls_visited :
423
+ urls_to_visit .append (url )
424
+
425
+ if len (urls_to_visit ) == 0 :
426
+ urls_to_visit = examples_libraries
427
+ log_entry = {}
428
+ log_time = gmtime ()
429
+ log_file = strftime (logfile , log_time )
430
+
431
+ library_re = re .compile (r'^https://codebender.cc/library/.+$' )
432
+ example_re = re .compile (r'^https://codebender.cc/example/.+/.+$' )
433
+
434
+ print '\n Visiting:' , len (urls_to_visit ), 'URLs'
435
+ tic = time .time ()
436
+ for url in urls_to_visit :
437
+ self .open (url )
438
+ test_status = True
439
+ if library_re .match (url ) and self .driver .current_url == 'https://codebender.cc/libraries' :
440
+ test_status = False
441
+ elif example_re .match (url ) and 'Sorry! The example could not be fetched.' in self .driver .page_source :
442
+ test_status = False
443
+ log_entry [url ] = test_status
444
+
445
+ progress = '.'
446
+ if not test_status :
447
+ progress = 'F'
448
+
449
+ sys .stdout .write (progress )
450
+ sys .stdout .flush ()
451
+
452
+ with open (log_file , 'w' , 0 ) as f :
453
+ f .write (jsondump (log_entry ))
454
+
455
+ toc = time .time ()
456
+ if toc - tic >= SAUCELABS_TIMEOUT_SECONDS :
457
+ print '\n Stopping tests to avoid saucelabs timeout'
458
+ print 'Test duration:' , int (toc - tic ), 'sec'
459
+ return
460
+
461
+ report_creator ('fetch' , log_entry , log_file )
462
+
387
463
def compile_sketch (self , url , boards , iframe = False ):
388
464
"""Compiles the sketch located at `url`, or an iframe within the page
389
465
referred to by `url`. Raises an exception if it does not compile.
@@ -588,7 +664,12 @@ def create_sketch(self, name):
588
664
headingInput .send_keys (Keys .ENTER )
589
665
WebDriverWait (self .driver , VERIFY_TIMEOUT ).until (
590
666
expected_conditions .invisibility_of_element_located (
591
- (By .CSS_SELECTOR , "#editor_heading_project_name i" )
667
+ (By .CSS_SELECTOR , "#editor_heading_project_working" )
668
+ )
669
+ )
670
+ WebDriverWait (self .driver , VERIFY_TIMEOUT ).until (
671
+ expected_conditions .text_to_be_present_in_element (
672
+ (By .ID , "operation_output" ), 'Name successfully changed!'
592
673
)
593
674
)
594
675
0 commit comments