13
13
import org .eclipse .core .runtime .CoreException ;
14
14
import org .eclipse .core .runtime .IPath ;
15
15
import org .eclipse .core .runtime .NullProgressMonitor ;
16
- import org .eclipse .core .runtime .Path ;
17
16
import org .junit .Test ;
18
17
import org .junit .runner .RunWith ;
19
18
import org .junit .runners .Parameterized ;
@@ -33,69 +32,62 @@ public class CreateAndCompileArduinoIDEExamplesOnAVRHardwareTest {
33
32
private static int mCounter = 0 ;
34
33
private CodeDescriptor myCodeDescriptor ;
35
34
private String myName ;
36
- private boolean myUsesSerial1 ;
37
- private boolean myUsesKeyboard ;
38
- private boolean myUsesSerial ;
35
+ private Example myExample ;
39
36
private static int totalFails = 0 ;
37
+ private static int maxFails = 500 ;
40
38
41
39
public CreateAndCompileArduinoIDEExamplesOnAVRHardwareTest (String name , CodeDescriptor codeDescriptor ,
42
- boolean usesSerial , boolean usesSerial1 , boolean usesKeyboard ) {
43
-
44
- this .myCodeDescriptor = codeDescriptor ;
45
- this .myName = name ;
46
- this .myUsesSerial = usesSerial ;
47
- this .myUsesSerial1 = usesSerial1 ;
48
- this .myUsesKeyboard = usesKeyboard ;
40
+ Example example ) {
49
41
42
+ myCodeDescriptor = codeDescriptor ;
43
+ myName = name ;
44
+ myExample = example ;
50
45
}
51
46
52
47
@ SuppressWarnings ("rawtypes" )
53
48
@ Parameters (name = "{index}: {0}" )
54
49
public static Collection examples () {
55
-
56
-
57
50
Shared .waitForAllJobsToFinish ();
58
-
59
51
LinkedList <Object []> examples = new LinkedList <>();
52
+
60
53
TreeMap <String , IPath > exampleFolders = LibraryManager .getAllArduinoIDEExamples ();
61
54
for (Map .Entry <String , IPath > curexample : exampleFolders .entrySet ()) {
62
- ArrayList <Path > paths = new ArrayList <>();
63
-
64
- paths .add (new Path (curexample .getValue ().toString ()));
65
- CodeDescriptor codeDescriptor = CodeDescriptor .createExample (false , paths );
66
55
String inoName = curexample .getKey ().trim ();
67
- Boolean usesSerial = new Boolean (Examples .getUsesSerialExamples ().contains (inoName ));
68
- Boolean usesSerial1 = new Boolean (Examples .getUsesSerial1Examples ().contains (inoName ));
69
- Boolean usesKeyboard = new Boolean (Examples .getUsesKeyboardExamples ().contains (inoName ));
56
+ IPath examplePath = curexample .getValue ();
57
+ Example example = new Example (inoName , null , examplePath );
58
+ if (!skipExample (example )){
59
+ ArrayList <IPath > paths = new ArrayList <>();
70
60
71
- Object [] theData = new Object [] { "Example:" + inoName , codeDescriptor , usesSerial , usesSerial1 ,
72
- usesKeyboard };
73
- examples .add (theData );
61
+ paths .add (examplePath );
62
+ CodeDescriptor codeDescriptor = CodeDescriptor .createExample (false , paths );
63
+
64
+ Object [] theData = new Object [] { "Example:" + inoName , codeDescriptor , example };
65
+ examples .add (theData );
66
+ }
74
67
}
75
68
76
69
return examples ;
77
70
78
71
}
79
-
72
+
73
+ private static boolean skipExample (Example example ) {
74
+ // skip Teensy stuff on Arduino hardware
75
+ // Teensy is so mutch more advanced that most arduino avr hardware can not
76
+ // handle
77
+ // it
78
+ return example .getPath ().toString ().contains ("Teensy" );
79
+ }
80
80
public void testExample (IBoard board ) {
81
81
// Stop after X fails because
82
82
// the fails stays open in eclipse and it becomes really slow
83
83
// There are only a number of issues you can handle
84
84
// best is to focus on the first ones and then rerun starting with the
85
85
// failures
86
- if (this .myUsesSerial && !board .supportsSerial ()) {
87
- System .out .println ("!TEST SKIPPED due to Serial " + this .myName + " " + board .getName ());
88
- return ;
89
- }
90
- if (this .myUsesSerial1 && !board .supportsSerial1 ()) {
91
- System .out .println ("!TEST SKIPPED due to Serial1 " + this .myName + " " + board .getName ());
86
+ if (!board .isExampleSupported (myExample )) {
92
87
return ;
93
88
}
94
- if (this .myUsesKeyboard && !board .supportsKeyboard ()) {
95
- System .out .println ("!TEST SKIPPED due to keyboard " + this .myName + " " + board .getName ());
96
- return ;
97
- }
98
- if (totalFails < 40 ) {
89
+
90
+ if (totalFails < maxFails ) {
99
91
BuildAndVerify (board .getBoardDescriptor ());
100
92
} else {
101
93
fail ("To many fails. Stopping test" );
@@ -125,7 +117,7 @@ public void testArduinoIDEExamplesOnYun() {
125
117
126
118
@ Test
127
119
public void testArduinoIDEExamplesOnDiecimila () {
128
- testExample ( ArduinoBoards .getAvrBoard ("diecimila" ));
120
+ testExample (ArduinoBoards .getAvrBoard ("diecimila" ));
129
121
}
130
122
131
123
@ Test
@@ -142,71 +134,71 @@ public void testArduinoIDEExamplesOneMegaADK() {
142
134
@ Test
143
135
public void testArduinoIDEExamplesOnLeonardoEth () {
144
136
145
- testExample ( ArduinoBoards .getAvrBoard ("leonardoeth" ));
137
+ testExample (ArduinoBoards .getAvrBoard ("leonardoeth" ));
146
138
147
139
}
148
140
149
141
@ Test
150
142
public void testArduinoIDEExamplesOneMicro () {
151
143
152
- testExample ( ArduinoBoards .getAvrBoard ("micro" ));
144
+ testExample (ArduinoBoards .getAvrBoard ("micro" ));
153
145
154
146
}
155
147
156
148
@ Test
157
149
public void testArduinoIDEExamplesOneMini () {
158
- testExample ( ArduinoBoards .getAvrBoard ("mini" ));
150
+ testExample (ArduinoBoards .getAvrBoard ("mini" ));
159
151
160
152
}
161
153
162
154
@ Test
163
155
public void testArduinoIDEExamplesOnEthernet () {
164
- testExample ( ArduinoBoards .getAvrBoard ("ethernet" ));
156
+ testExample (ArduinoBoards .getAvrBoard ("ethernet" ));
165
157
}
166
158
167
159
@ Test
168
160
public void testArduinoIDEExamplesOnFio () {
169
- testExample ( ArduinoBoards .getAvrBoard ("fio" ));
161
+ testExample (ArduinoBoards .getAvrBoard ("fio" ));
170
162
}
171
163
172
164
@ Test
173
165
public void testArduinoIDEExamplesOnBt () {
174
- testExample ( ArduinoBoards .getAvrBoard ("bt" ));
166
+ testExample (ArduinoBoards .getAvrBoard ("bt" ));
175
167
}
176
168
177
169
@ Test
178
170
public void testArduinoIDEExamplesOnLilyPadUSB () {
179
- testExample ( ArduinoBoards .getAvrBoard ("LilyPadUSB" ));
171
+ testExample (ArduinoBoards .getAvrBoard ("LilyPadUSB" ));
180
172
}
181
173
182
174
@ Test
183
175
public void testArduinoIDEExamplesOnlilypad () {
184
- testExample ( ArduinoBoards .getAvrBoard ("lilypad" ));
176
+ testExample (ArduinoBoards .getAvrBoard ("lilypad" ));
185
177
}
186
178
187
179
@ Test
188
180
public void testArduinoIDEExamplesOnPro () {
189
- testExample ( ArduinoBoards .getAvrBoard ("pro" ));
181
+ testExample (ArduinoBoards .getAvrBoard ("pro" ));
190
182
}
191
183
192
184
@ Test
193
185
public void testArduinoIDEExamplesOnatmegang () {
194
- testExample ( ArduinoBoards .getAvrBoard ("atmegang" ));
186
+ testExample (ArduinoBoards .getAvrBoard ("atmegang" ));
195
187
}
196
188
197
189
@ Test
198
190
public void testArduinoIDEExamplesOnrobotControl () {
199
- testExample ( ArduinoBoards .getAvrBoard ("robotControl" ));
191
+ testExample (ArduinoBoards .getAvrBoard ("robotControl" ));
200
192
}
201
193
202
194
@ Test
203
195
public void testArduinoIDEExamplesOnrobotMotor () {
204
- testExample ( ArduinoBoards .getAvrBoard ("robotMotor" ));
196
+ testExample (ArduinoBoards .getAvrBoard ("robotMotor" ));
205
197
}
206
198
207
199
@ Test
208
200
public void testArduinoIDEExamplesOngemma () {
209
- testExample ( ArduinoBoards .getAvrBoard ("gemma" ));
201
+ testExample (ArduinoBoards .getAvrBoard ("gemma" ));
210
202
}
211
203
212
204
@ Test
@@ -216,23 +208,23 @@ public void testArduinoIDEExamplesOncircuitplay32u4cat() {
216
208
217
209
@ Test
218
210
public void testArduinoIDEExamplesOnyunmini () {
219
- testExample ( ArduinoBoards .getAvrBoard ("yunmini" ));
211
+ testExample (ArduinoBoards .getAvrBoard ("yunmini" ));
220
212
221
213
}
222
214
223
215
@ Test
224
216
public void testArduinoIDEExamplesOnchiwawa () {
225
- testExample ( ArduinoBoards .getAvrBoard ("chiwawa" ));
217
+ testExample (ArduinoBoards .getAvrBoard ("chiwawa" ));
226
218
}
227
219
228
220
@ Test
229
221
public void testArduinoIDEExamplesOnone () {
230
- testExample ( ArduinoBoards .getAvrBoard ("one" ));
222
+ testExample (ArduinoBoards .getAvrBoard ("one" ));
231
223
}
232
224
233
225
@ Test
234
226
public void testArduinoIDEExamplesOnunowifi () {
235
- testExample ( ArduinoBoards .getAvrBoard ("unowifi" ));
227
+ testExample (ArduinoBoards .getAvrBoard ("unowifi" ));
236
228
}
237
229
238
230
public void BuildAndVerify (BoardDescriptor boardDescriptor ) {
0 commit comments