38
38
from tools .export import EXPORTERS
39
39
from tools .project import EXPORTER_ALIASES
40
40
from tools .toolchains import TOOLCHAINS
41
+ from tools .utils import write_json_to_file
41
42
42
43
SUPPORTED_TOOLCHAINS = list (TOOLCHAINS - set (u'uARM' ))
43
44
SUPPORTED_IDES = [exp for exp in EXPORTERS .keys () + EXPORTER_ALIASES .keys ()
@@ -382,7 +383,7 @@ def compile_repos(config, toolchains, targets, profile, verbose, examples):
382
383
successes = []
383
384
compiled = True
384
385
pass_status = True
385
- if example .has_key ('test' ) and example .has_key ('baud_rate' ) and example .has_key ('compare_log' ):
386
+ if example .has_key ('test' ) and example [ 'test' ] and example .has_key ('baud_rate' ) and example .has_key ('compare_log' ):
386
387
test_example = True
387
388
else :
388
389
test_example = False
@@ -414,16 +415,15 @@ def compile_repos(config, toolchains, targets, profile, verbose, examples):
414
415
if image :
415
416
image_info = [{"binary_type" : "bootable" ,"path" : normpath (join (name ,image )),"compare_log" :log }]
416
417
else :
417
- print ("Warning: could not found built image for example %s" % name )
418
+ print ("Warning: could not find built image for example %s" % name )
418
419
419
420
example_summary = "{} {} {}" .format (name , target , toolchain )
420
421
if proc .returncode :
421
422
failures .append (example_summary )
422
423
else :
423
- successes .append (example_summary )
424
424
if test_example :
425
425
test_group = "{}-{}-{}" .format (target , toolchain , example ['baud_rate' ])
426
- if example [ 'test' ] and image :
426
+ if image :
427
427
if not test_json ['builds' ].has_key (test_group ):
428
428
test_json ['builds' ][test_group ] = {
429
429
"platform" :target ,
@@ -432,9 +432,14 @@ def compile_repos(config, toolchains, targets, profile, verbose, examples):
432
432
"baud_rate" : int (example ['baud_rate' ]),
433
433
"tests" :{} }
434
434
test_json ['builds' ][test_group ]['tests' ][name ]= {"binaries" :image_info }
435
+ test_status = "TEST_ON"
436
+ else :
437
+ test_status = "NO_IMAGE"
435
438
else :
436
439
print ("Warning: Test for %s will not be generated." % name )
437
- print ("One or more of 'test' 'baud_rate' and 'compare_log' keys are missing from the json file\n " )
440
+ print ("One or more of 'test', 'baud_rate', and 'compare_log' keys are missing from the example config json file\n " )
441
+ test_status = "TEST_OFF"
442
+ successes .append (example_summary + " " + test_status )
438
443
439
444
os .chdir (".." )
440
445
@@ -446,7 +451,7 @@ def compile_repos(config, toolchains, targets, profile, verbose, examples):
446
451
447
452
results [example ['name' ]] = [compiled , pass_status , successes , failures ]
448
453
449
- save_test_spec (test_json )
454
+ write_json_to_file (test_json , "test_spec.json" )
450
455
return results
451
456
452
457
@@ -475,15 +480,9 @@ def update_mbedos_version(config, tag, examples):
475
480
return result
476
481
477
482
return 0
478
-
479
- def save_test_spec (json_spec , name = "test_spec.json" ):
480
- """save the given json data to test_spec.json"""
481
- print ("Dumping json test_specs file {}" .format (name ))
482
- with open (name , 'w' ) as outfile :
483
- json .dump (json_spec , outfile , indent = 4 )
484
-
483
+
485
484
def fetch_output_image (output ):
486
- """find the mbed build image from thet last 5 lines of a given log """
485
+ """Find the build image from the last 5 lines of a given log"""
487
486
lines = output .splitlines ()
488
487
for index in range (- 1 ,- 6 ,- 1 ):
489
488
if lines [index ].startswith ("Image:" ):
0 commit comments