1515
1616import io .sloeber .core .api .BoardDescriptor ;
1717import io .sloeber .core .api .CodeDescriptor ;
18+ import io .sloeber .core .api .CompileOptions ;
1819import io .sloeber .core .api .LibraryManager ;
1920import io .sloeber .core .api .PackageManager ;
2021import io .sloeber .providers .MCUBoard ;
2425@ RunWith (Parameterized .class )
2526public class CreateAndCompileArduinoIDEExamplesOnTeensyTest {
2627 private CodeDescriptor myCodeDescriptor ;
27- private Examples myExample ;
28+
29+ private String myTestName ;
30+ private BoardDescriptor myBoardDescriptor ;
2831 private static int myBuildCounter = 0 ;
2932 private static int myTotalFails = 0 ;
3033 private static int maxFails = 50 ;
3134 private static int mySkipAtStart = 0 ;
3235
33- public CreateAndCompileArduinoIDEExamplesOnTeensyTest (CodeDescriptor codeDescriptor , Examples example ) {
36+ public CreateAndCompileArduinoIDEExamplesOnTeensyTest (String testName , CodeDescriptor codeDescriptor ,BoardDescriptor board ) {
3437
3538 myCodeDescriptor = codeDescriptor ;
36- myExample = example ;
39+ myTestName =testName ;
40+ myBoardDescriptor =board ;
3741 }
3842
3943 @ SuppressWarnings ("rawtypes" )
40- @ Parameters (name = "{index}: { 0}" )
44+ @ Parameters (name = "{0}" )
4145 public static Collection examples () {
4246 installAdditionalBoards ();
4347
4448 Shared .waitForAllJobsToFinish ();
4549 LinkedList <Object []> examples = new LinkedList <>();
46-
50+ MCUBoard [] allBoards =Teensy .getAllBoards ();
51+
4752 TreeMap <String , IPath > exampleFolders = LibraryManager .getAllArduinoIDEExamples ();
4853 for (Map .Entry <String , IPath > curexample : exampleFolders .entrySet ()) {
4954 String fqn = curexample .getKey ().trim ();
@@ -54,8 +59,16 @@ public static Collection examples() {
5459 paths .add (examplePath );
5560 CodeDescriptor codeDescriptor = CodeDescriptor .createExample (false , paths );
5661
57- Object [] theData = new Object [] { codeDescriptor , example };
58- examples .add (theData );
62+ for (MCUBoard curBoard : allBoards ) {
63+ if (curBoard .isExampleSupported (example )) {
64+ String projectName = Shared .getProjectName (codeDescriptor , example , curBoard );
65+ Map <String , String > boardOptions = curBoard .getBoardOptions (example );
66+ BoardDescriptor boardDescriptor = curBoard .getBoardDescriptor ();
67+ boardDescriptor .setOptions (boardOptions );
68+ Object [] theData = new Object [] { projectName , codeDescriptor , boardDescriptor };
69+ examples .add (theData );
70+ }
71+ }
5972 }
6073 }
6174
@@ -77,63 +90,24 @@ public static void installAdditionalBoards() {
7790
7891 }
7992
80- public void testExample (MCUBoard board ) {
93+ public void testExample () {
8194 // Stop after X fails because
8295 // the fails stays open in eclipse and it becomes really slow
8396 // There are only a number of issues you can handle
8497 // best is to focus on the first ones and then rerun starting with the
8598 // failures
8699 Assume .assumeTrue ("Skipping first " + mySkipAtStart + " tests" , myBuildCounter ++ >= mySkipAtStart );
87100 Assume .assumeTrue ("To many fails. Stopping test" , myTotalFails < maxFails );
88- Map <String ,String > boardOptions =board .getBoardOptions (myExample );
89- BoardDescriptor boardDescriptor =board .getBoardDescriptor ();
90- boardDescriptor .setOptions (boardOptions );
91- if (!Shared .BuildAndVerify ( boardDescriptor , myCodeDescriptor , null )) {
101+ if (!Shared .BuildAndVerify (myTestName , myBoardDescriptor , myCodeDescriptor , new CompileOptions (null ))) {
92102 myTotalFails ++;
93103 }
94104 }
95105
96106 @ Test
97- public void testArduinoIDEExamplesOnTeensy3_6 () {
98- if (!MySystem .getTeensyPlatform ().isEmpty ())
99- testExample (Teensy .Teensy3_6 ());
100- }
101-
102- @ Test
103- public void testArduinoIDEExamplesOnTeensy3_5 () {
104- if (!MySystem .getTeensyPlatform ().isEmpty ())
105- testExample (Teensy .Teensy3_5 ());
106- }
107-
108- @ Test
109- public void testArduinoIDEExamplesOnTeensy3_1 () {
110- if (!MySystem .getTeensyPlatform ().isEmpty ())
111- testExample (Teensy .Teensy3_1 ());
112- }
113-
114- @ Test
115- public void testArduinoIDEExamplesOnTeensy3_0 () {
107+ public void testArduinoIDEExamplesOnTeensy () {
116108 if (!MySystem .getTeensyPlatform ().isEmpty ())
117- testExample (Teensy . Teensy3_0 () );
109+ testExample ();
118110 }
119111
120- @ Test
121- public void testArduinoIDEExamplesOnTeensyLC () {
122- if (!MySystem .getTeensyPlatform ().isEmpty ())
123- testExample (Teensy .Teensy_LC ());
124- }
125-
126- @ Test
127- public void testArduinoIDEExamplesOnTeensyPP2 () {
128- if (!MySystem .getTeensyPlatform ().isEmpty ())
129- testExample (Teensy .teensypp2 ());
130- }
131-
132- @ Test
133- public void testArduinoIDEExamplesOnTeensy2 () {
134- if (!MySystem .getTeensyPlatform ().isEmpty ())
135- testExample (Teensy .teensy2 ());
136-
137- }
138112
139113}
0 commit comments