5
5
import shutil
6
6
import subprocess
7
7
import collections
8
+ from contextlib import contextmanager
8
9
9
10
# optional wall option cause build failed if has warnings
10
11
BUILD_WALL = False
@@ -310,6 +311,20 @@ def generate_uf2(example_path):
310
311
print ("Unknown platform: " , arg )
311
312
exit (- 1 )
312
313
314
+ @contextmanager
315
+ def group_output (title ):
316
+ sys .stdout .flush ()
317
+ sys .stderr .flush ()
318
+ print (f"::group::{ title } " )
319
+ try :
320
+ yield
321
+ finally :
322
+ sys .stdout .flush ()
323
+ sys .stderr .flush ()
324
+ print (f"::endgroup::" )
325
+ sys .stdout .flush ()
326
+
327
+
313
328
def test_examples_in_folder (folderpath ):
314
329
global success
315
330
for example in sorted (os .listdir (folderpath )):
@@ -365,7 +380,8 @@ def test_examples_in_folder(folderpath):
365
380
ColorPrint .print_pass (CHECK )
366
381
if err :
367
382
# also print out warning message
368
- ColorPrint .print_fail (err .decode ("utf-8" ))
383
+ with group_output (f"{ example } { fqbn } build output" ):
384
+ ColorPrint .print_fail (err .decode ("utf-8" ))
369
385
if os .path .exists (gen_file_name ):
370
386
if ALL_PLATFORMS [platform ][1 ] == None :
371
387
ColorPrint .print_info ("Platform does not support UF2 files, skipping..." )
@@ -382,8 +398,9 @@ def test_examples_in_folder(folderpath):
382
398
os .system ("ls -lR " + BUILD_DIR + "/build" )
383
399
else :
384
400
ColorPrint .print_fail (CROSS )
385
- ColorPrint .print_fail (out .decode ("utf-8" ))
386
- ColorPrint .print_fail (err .decode ("utf-8" ))
401
+ with group_output (f"{ example } { fqbn } built output" ):
402
+ ColorPrint .print_fail (out .decode ("utf-8" ))
403
+ ColorPrint .print_fail (err .decode ("utf-8" ))
387
404
success = 1
388
405
389
406
def test_examples_in_learningrepo (folderpath ):
0 commit comments