1- import shutil
2- import subprocess
3- import os
4- import traceback
5-
6- # add files here that need to be copied to the unit testing sketch
7- # Question: Why not copy all PDE files?
8- # Answer: Some PDE files depend on globals declared in OpenBCI_GUI.pde
9- # and we do not copy OpenBCI_GUI.pde because it delcares a setup()
10- # function which conflicts with the unit test sketch
11- # Once we get rid of globals we could copy all PDEs
12- files_to_unittest = [
13- "PacketLossTracker.pde" ,
14- "TimeTrackingQueue.pde"
15- ]
16-
17- def main ():
18- origin_path = "OpenBCI_GUI"
19- sketch_dir = "OpenBCI_GUI_UnitTests"
20-
21- # copy any necessary files
22- for filename in os .listdir (origin_path ):
23- if filename in files_to_unittest :
24- orig = os .path .join (origin_path , filename )
25- dest = os .path .join (sketch_dir , filename )
26- shutil .copy (orig , dest )
27-
28- try :
29- # run the unit testing sketch
30- cwd = os .getcwd ()
31- sketch_dir = os .path .join (cwd , sketch_dir )
32- subprocess .check_call (["processing-java" , "--sketch=" + sketch_dir , "--run" ])
33- except Exception as e :
34- print (e )
35- delete_files (sketch_dir )
36- exit (1 ) # create CI failure
37-
38- delete_files (sketch_dir )
39-
40- fail_file = os .path .join (sketch_dir , "UNITTEST_FAILURE" )
41- if os .path .exists (fail_file ):
42- exit (1 ) # create CI failure
43-
44-
45- def delete_files (sketch_dir ):
46- # delete files copied above
47- for filename in files_to_unittest :
48- filepath = os .path .join (sketch_dir , filename )
49- os .remove (filepath )
50-
51- if __name__ == "__main__" :
1+ import shutil
2+ import subprocess
3+ import os
4+ import platform
5+ import traceback
6+
7+ # add files here that need to be copied to the unit testing sketch
8+ # Question: Why not copy all PDE files?
9+ # Answer: Some PDE files depend on globals declared in OpenBCI_GUI.pde
10+ # and we do not copy OpenBCI_GUI.pde because it delcares a setup()
11+ # function which conflicts with the unit test sketch
12+ # Once we get rid of globals we could copy all PDEs
13+ files_to_unittest = [
14+ "PacketLossTracker.pde" ,
15+ "TimeTrackingQueue.pde"
16+ ]
17+
18+ def main ():
19+ origin_path = "OpenBCI_GUI"
20+ sketch_dir = "OpenBCI_GUI_UnitTests"
21+
22+ # copy any necessary files
23+ for filename in os .listdir (origin_path ):
24+ if filename in files_to_unittest :
25+ orig = os .path .join (origin_path , filename )
26+ dest = os .path .join (sketch_dir , filename )
27+ shutil .copy (orig , dest )
28+
29+ try :
30+ # run the unit testing sketch
31+ cwd = os .getcwd ()
32+ sketch_dir = os .path .join (cwd , sketch_dir )
33+ subprocess .check_call (["processing-java" , "--sketch=" + sketch_dir , "--run" ])
34+ except Exception as e :
35+ print (e )
36+ delete_files (sketch_dir )
37+ exit (1 ) # create CI failure
38+
39+ delete_files (sketch_dir )
40+
41+ fail_file = os .path .join (sketch_dir , "UNITTEST_FAILURE" )
42+ if os .path .exists (fail_file ):
43+ exit (1 ) # create CI failure
44+
45+
46+ def delete_files (sketch_dir ):
47+ # delete files copied above
48+ for filename in files_to_unittest :
49+ filepath = os .path .join (sketch_dir , filename )
50+ os .remove (filepath )
51+
52+ if __name__ == "__main__" :
5253 main ()
0 commit comments