Skip to content

Commit d6adb01

Browse files
author
jantje
committed
Moving to using the delivered boards
1 parent bced92b commit d6adb01

File tree

5 files changed

+104
-252
lines changed

5 files changed

+104
-252
lines changed

io.sloeber.tests/src/io/sloeber/core/CreateAndCompileArduinoIDEExamplesOnAVRHardwareTest.java

Lines changed: 19 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.junit.runners.Parameterized.Parameters;
1515

1616
import io.sloeber.core.api.CodeDescriptor;
17+
import io.sloeber.core.api.CompileOptions;
1718
import io.sloeber.core.api.LibraryManager;
1819
import io.sloeber.providers.Arduino;
1920
import io.sloeber.providers.MCUBoard;
@@ -22,24 +23,27 @@
2223
@RunWith(Parameterized.class)
2324
public class CreateAndCompileArduinoIDEExamplesOnAVRHardwareTest {
2425
private CodeDescriptor myCodeDescriptor;
25-
private Examples myExample;
26+
private MCUBoard myBoard;
27+
private String myProjectName;
2628
private static int myBuildCounter = 0;
2729
private static int myTotalFails = 0;
2830
private static int maxFails = 50;
2931
private static int mySkipAtStart = 0;
3032

31-
public CreateAndCompileArduinoIDEExamplesOnAVRHardwareTest( CodeDescriptor codeDescriptor,
32-
Examples example) {
33+
public CreateAndCompileArduinoIDEExamplesOnAVRHardwareTest( String projectName,CodeDescriptor codeDescriptor,
34+
MCUBoard board) {
3335

3436
myCodeDescriptor = codeDescriptor;
35-
myExample = example;
37+
myBoard = board;
38+
myProjectName =projectName;
3639
}
3740

3841
@SuppressWarnings("rawtypes")
39-
@Parameters(name = "{index}: {0}")
42+
@Parameters(name = " {0}")
4043
public static Collection examples() {
4144
Shared.waitForAllJobsToFinish();
4245
LinkedList<Object[]> examples = new LinkedList<>();
46+
MCUBoard[] allBoards=Arduino.getAllBoards();
4347

4448
TreeMap<String, IPath> exampleFolders = LibraryManager.getAllArduinoIDEExamples();
4549
for (Map.Entry<String, IPath> curexample : exampleFolders.entrySet()) {
@@ -51,9 +55,13 @@ public static Collection examples() {
5155

5256
paths.add(examplePath);
5357
CodeDescriptor codeDescriptor = CodeDescriptor.createExample(false, paths);
54-
55-
Object[] theData = new Object[] { codeDescriptor, example };
58+
for (MCUBoard curboard : allBoards) {
59+
if (curboard.isExampleSupported(example)) {
60+
String projectName=Shared.getProjectName(codeDescriptor, example, curboard);
61+
Object[] theData = new Object[] { projectName, codeDescriptor, curboard};
5662
examples.add(theData);
63+
}
64+
}
5765
}
5866
}
5967

@@ -69,7 +77,8 @@ private static boolean skipExample(Examples example) {
6977
return example.getPath().toString().contains("Teensy");
7078
}
7179

72-
public void testExample(MCUBoard board) {
80+
@Test
81+
public void testExample() {
7382
// Stop after X fails because
7483
// the fails stays open in eclipse and it becomes really slow
7584
// There are only a number of issues you can handle
@@ -79,144 +88,11 @@ public void testExample(MCUBoard board) {
7988
Assume.assumeTrue("To many fails. Stopping test", myTotalFails < maxFails);
8089
//because we run all examples on all boards we need to filter incompatible combinations
8190
//like serial examples on gemma
82-
if (!board.isExampleSupported(myExample)) {
83-
return;
84-
}
85-
if (!Shared.BuildAndVerify( board.getBoardDescriptor(), myCodeDescriptor, null)) {
91+
92+
if (!Shared.BuildAndVerify( myProjectName,myBoard.getBoardDescriptor(), myCodeDescriptor, new CompileOptions(null))) {
8693
myTotalFails++;
8794
}
8895
}
8996

90-
@Test
91-
public void testArduinoIDEExamplesOnUno() {
92-
testExample(Arduino.uno());
93-
}
94-
95-
@Test
96-
public void testArduinoIDEExamplesOnLeonardo() {
97-
testExample(Arduino.leonardo());
98-
}
99-
100-
@Test
101-
public void testArduinoIDEExamplesOnEsplora() {
102-
testExample(Arduino.esplora());
103-
}
104-
105-
@Test
106-
public void testArduinoIDEExamplesOnYun() {
107-
testExample(Arduino.yun());
108-
}
109-
110-
@Test
111-
public void testArduinoIDEExamplesOnDiecimila() {
112-
testExample(Arduino.getAvrBoard("diecimila"));
113-
}
114-
115-
@Test
116-
public void testArduinoIDEExamplesOnMega() {
117-
testExample(Arduino.getMega2560Board());
118-
}
119-
120-
@Test
121-
public void testArduinoIDEExamplesOneMegaADK() {
122-
testExample(Arduino.MegaADK());
123-
124-
}
125-
126-
@Test
127-
public void testArduinoIDEExamplesOnLeonardoEth() {
128-
129-
testExample(Arduino.getAvrBoard("leonardoeth"));
130-
131-
}
132-
133-
@Test
134-
public void testArduinoIDEExamplesOneMicro() {
135-
136-
testExample(Arduino.getAvrBoard("micro"));
137-
138-
}
139-
140-
@Test
141-
public void testArduinoIDEExamplesOneMini() {
142-
testExample(Arduino.getAvrBoard("mini"));
143-
144-
}
145-
146-
@Test
147-
public void testArduinoIDEExamplesOnEthernet() {
148-
testExample(Arduino.getAvrBoard("ethernet"));
149-
}
150-
151-
@Test
152-
public void testArduinoIDEExamplesOnFio() {
153-
testExample(Arduino.getAvrBoard("fio"));
154-
}
155-
156-
@Test
157-
public void testArduinoIDEExamplesOnBt() {
158-
testExample(Arduino.getAvrBoard("bt"));
159-
}
160-
161-
@Test
162-
public void testArduinoIDEExamplesOnLilyPadUSB() {
163-
testExample(Arduino.getAvrBoard("LilyPadUSB"));
164-
}
165-
166-
@Test
167-
public void testArduinoIDEExamplesOnlilypad() {
168-
testExample(Arduino.getAvrBoard("lilypad"));
169-
}
170-
171-
@Test
172-
public void testArduinoIDEExamplesOnPro() {
173-
testExample(Arduino.getAvrBoard("pro"));
174-
}
175-
176-
@Test
177-
public void testArduinoIDEExamplesOnatmegang() {
178-
testExample(Arduino.getAvrBoard("atmegang"));
179-
}
180-
181-
@Test
182-
public void testArduinoIDEExamplesOnrobotControl() {
183-
testExample(Arduino.getAvrBoard("robotControl"));
184-
}
185-
186-
@Test
187-
public void testArduinoIDEExamplesOnrobotMotor() {
188-
testExample(Arduino.getAvrBoard("robotMotor"));
189-
}
190-
191-
@Test
192-
public void testArduinoIDEExamplesOngemma() {
193-
testExample(Arduino.getAvrBoard("gemma"));
194-
}
195-
196-
@Test
197-
public void testArduinoIDEExamplesOncircuitplay32u4cat() {
198-
testExample(Arduino.adafruitnCirquitPlayground());
199-
}
200-
201-
@Test
202-
public void testArduinoIDEExamplesOnyunmini() {
203-
testExample(Arduino.getAvrBoard("yunmini"));
204-
205-
}
206-
207-
@Test
208-
public void testArduinoIDEExamplesOnchiwawa() {
209-
testExample(Arduino.getAvrBoard("chiwawa"));
210-
}
211-
212-
@Test
213-
public void testArduinoIDEExamplesOnone() {
214-
testExample(Arduino.getAvrBoard("one"));
215-
}
216-
217-
@Test
218-
public void testArduinoIDEExamplesOnunowifi() {
219-
testExample(Arduino.getAvrBoard("unowifi"));
220-
}
22197

22298
}

io.sloeber.tests/src/io/sloeber/core/CreateAndCompileJantjesBoardsTest.java

Lines changed: 18 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.junit.runners.Parameterized;
1616
import org.junit.runners.Parameterized.Parameters;
1717

18+
import io.sloeber.core.api.BoardDescriptor;
1819
import io.sloeber.core.api.CodeDescriptor;
1920
import io.sloeber.core.api.LibraryManager;
2021
import io.sloeber.core.api.PackageManager;
@@ -25,26 +26,25 @@
2526
@RunWith(Parameterized.class)
2627
public class CreateAndCompileJantjesBoardsTest {
2728
private CodeDescriptor myCodeDescriptor;
28-
29-
private Examples myExample;
29+
private static BoardDescriptor myBoard;
3030
private static int myBuildCounter = 0;
3131
private static int myTotalFails = 0;
3232
private static int maxFails = 200;
3333
private static int mySkipAtStart = 0;
3434

35-
public CreateAndCompileJantjesBoardsTest( CodeDescriptor codeDescriptor, Examples example) {
35+
public CreateAndCompileJantjesBoardsTest( String name,CodeDescriptor codeDescriptor,BoardDescriptor board) {
3636

3737
myCodeDescriptor = codeDescriptor;
38-
39-
myExample = example;
38+
myBoard=board;
4039

4140
}
4241

4342
@SuppressWarnings("rawtypes")
44-
@Parameters(name = "{index}: {0}")
43+
@Parameters(name = "{0}")
4544
public static Collection examples() {
4645
String[] packageUrlsToAdd = {
4746
"https://raw.githubusercontent.com/jantje/hardware/master/package_jantje_index.json" };
47+
MCUBoard[] allBoards=Jantje.getAllBoards();
4848
PackageManager.addPackageURLs(new HashSet<>(Arrays.asList(packageUrlsToAdd)), true);
4949
PackageManager.installLatestPlatform(Jantje.getJsonFileName(), Jantje.getPackageName(),
5050
Jantje.getPlatformName());
@@ -62,9 +62,12 @@ public static Collection examples() {
6262

6363
paths.add(examplePath);
6464
CodeDescriptor codeDescriptor = CodeDescriptor.createExample(false, paths);
65-
66-
Object[] theData = new Object[] { codeDescriptor, example };
67-
examples.add(theData);
65+
for (MCUBoard curboard : allBoards) {
66+
if (curboard.isExampleSupported(example)) {
67+
Object[] theData = new Object[] {Shared.getCounterName(codeDescriptor.getExampleName()), codeDescriptor ,curboard.getBoardDescriptor()};
68+
examples.add(theData);
69+
}
70+
}
6871
}
6972
}
7073

@@ -93,114 +96,21 @@ private static boolean skipExample(Examples example) {
9396
}
9497
return false;
9598
}
96-
97-
public void testExample(MCUBoard board) {
99+
@Test
100+
public void testExample() {
98101
// Stop after X fails because
99102
// the fails stays open in eclipse and it becomes really slow
100103
// There are only a number of issues you can handle
101104
// best is to focus on the first ones and then rerun starting with the
102105
// failures
103-
Assume.assumeTrue("Skipping first " + mySkipAtStart + " tests", myBuildCounter++ >= mySkipAtStart);
104-
Assume.assumeTrue("To many fails. Stopping test", myTotalFails < maxFails);
106+
Assume.assumeTrue("Skipping first " + mySkipAtStart + " tests", (myBuildCounter++ >= mySkipAtStart)?Shared.increaseBuildCounter():false);
107+
Assume.assumeTrue("To many fails. Stopping test", (myTotalFails < maxFails)?Shared.increaseBuildCounter():false);
105108
//because we run all examples on all boards we need to filter incompatible combinations
106109
//like serial examples on gemma
107-
if (!board.isExampleSupported(myExample)) {
108-
return;
109-
}
110-
if (!Shared.BuildAndVerify( board.getBoardDescriptor(), myCodeDescriptor, null)) {
110+
111+
if (!Shared.BuildAndVerify( myBoard, myCodeDescriptor, null)) {
111112
myTotalFails++;
112113
}
113114
}
114115

115-
@Test
116-
public void testJantjeYun() {
117-
testExample(new Jantje("yun"));
118-
}
119-
120-
@Test
121-
public void testJantjeUno() {
122-
testExample(new Jantje("uno"));
123-
}
124-
125-
@Test
126-
public void testJantjeDiecimila() {
127-
testExample(new Jantje("diecimila"));
128-
}
129-
130-
@Test
131-
public void testJantjeNano() {
132-
testExample(new Jantje("nano"));
133-
}
134-
135-
@Test
136-
public void testJantjeMega() {
137-
testExample(new Jantje("mega"));
138-
}
139-
140-
@Test
141-
public void testJantjeMegaADK() {
142-
testExample(new Jantje("megaADK"));
143-
}
144-
145-
@Test
146-
public void testJantjeLeonardo() {
147-
testExample(new Jantje("leonardo"));
148-
}
149-
150-
@Test
151-
public void testJantjeMicro() {
152-
testExample(new Jantje("micro"));
153-
}
154-
155-
@Test
156-
public void testJantjeEsplora() {
157-
testExample(new Jantje("esplora"));
158-
}
159-
160-
@Test
161-
public void testJantjeMini() {
162-
testExample(new Jantje("mini"));
163-
}
164-
165-
@Test
166-
public void testJantjeEthernet() {
167-
testExample(new Jantje("ethernet"));
168-
}
169-
170-
@Test
171-
public void testJantje_fio() {
172-
testExample(new Jantje("fio"));
173-
}
174-
175-
@Test
176-
public void testJantje_bt() {
177-
testExample(new Jantje("bt"));
178-
}
179-
180-
@Test
181-
public void testJantje_LilyPadUSB() {
182-
testExample(new Jantje("LilyPadUSB"));
183-
}
184-
185-
@Test
186-
public void testJantje_lilypad() {
187-
testExample(new Jantje("lilypad"));
188-
}
189-
190-
@Test
191-
public void testJantje_pro() {
192-
testExample(new Jantje("pro"));
193-
}
194-
195-
@Test
196-
public void testJantje_atmegang() {
197-
testExample(new Jantje("atmegang"));
198-
}
199-
200-
@Test
201-
public void testJantje_robotControl() {
202-
testExample(new Jantje("robotControl"));
203-
}
204-
205-
206116
}

0 commit comments

Comments
 (0)