2222
2323IS_LEARNING_SYS = False
2424if "Adafruit_Learning_System_Guides" in BUILD_DIR :
25+ print ("Found learning system repo" )
2526 IS_LEARNING_SYS = True
2627
2728#os.system('pwd')
@@ -140,7 +141,6 @@ def run_or_die(cmd, error):
140141try :
141142 if IS_LEARNING_SYS :
142143 libprop = open (BUILD_DIR + '/library.deps' )
143- print ("Found library.deps!" )
144144 else :
145145 libprop = open (BUILD_DIR + '/library.properties' )
146146 for line in libprop :
@@ -154,6 +154,7 @@ def run_or_die(cmd, error):
154154 run_or_die ('arduino-cli lib install "' + dep + '" > /dev/null' ,
155155 "FAILED to install dependancy " + dep )
156156except OSError :
157+ print ("No library dep or properties found!" )
157158 pass # no library properties
158159
159160# Delete the existing library if we somehow downloaded
@@ -214,12 +215,50 @@ def test_examples_in_folder(folderpath):
214215 ColorPrint .print_fail (err .decode ("utf-8" ))
215216 success = 1
216217
218+ def test_examples_in_learningrepo (folderpath ):
219+ global success
220+ for project in os .listdir (folderpath ):
221+ projectpath = folderpath + "/" + project
222+ if os .path .isdir (learningrepo ):
223+ test_examples_in_learningrepo (projectpath )
224+ continue
225+ if not projectpath .endswith (".ino" ):
226+ continue
227+ # found an INO!
228+ print ('\t ' + projectpath , end = ' ' )
229+ # check if we should SKIP
230+ skipfilename = folderpath + "/." + platform + ".test.skip"
231+ onlyfilename = folderpath + "/." + platform + ".test.only"
232+ if os .path .exists (skipfilename ):
233+ ColorPrint .print_warn ("skipping" )
234+ continue
235+ elif glob .glob (folderpath + "/.*.test.only" ) and not os .path .exists (onlyfilename ):
236+ ColorPrint .print_warn ("skipping" )
237+ continue
238+
239+ cmd = ['arduino-cli' , 'compile' , '--fqbn' , fqbn , projectpath ]
240+ proc = subprocess .Popen (cmd , stdout = subprocess .PIPE ,
241+ stderr = subprocess .PIPE )
242+ r = proc .wait ()
243+ out = proc .stdout .read ()
244+ err = proc .stderr .read ()
245+ if r == 0 :
246+ ColorPrint .print_pass (CHECK )
247+ else :
248+ ColorPrint .print_fail (CROSS )
249+ ColorPrint .print_fail (out .decode ("utf-8" ))
250+ ColorPrint .print_fail (err .decode ("utf-8" ))
251+ success = 1
252+
253+
217254for platform in platforms :
218255 fqbn = ALL_PLATFORMS [platform ]
219256 print ('#' * 80 )
220257 ColorPrint .print_info ("SWITCHING TO " + fqbn )
221258 install_platform (":" .join (fqbn .split (':' , 2 )[0 :2 ])) # take only first two elements
222259 print ('#' * 80 )
223- test_examples_in_folder (BUILD_DIR + "/examples" )
224-
260+ if not IS_LEARNING_SYS :
261+ test_examples_in_folder (BUILD_DIR + "/examples" )
262+ else :
263+ test_examples_in_folder (BUILD_DIR )
225264exit (success )
0 commit comments