Skip to content

Commit 5cd6846

Browse files
author
jantje
committed
modded comments and formatted
1 parent 4571384 commit 5cd6846

File tree

2 files changed

+92
-90
lines changed

2 files changed

+92
-90
lines changed
Lines changed: 73 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
package io.sloeber.core;
22

3+
/*
4+
* This test compiles all examples on all Arduino avr hardware
5+
* That is "compatible hardware as not all examples can be compiled for all hardware
6+
* for instance when serial2 is used a uno will not work but a mega will
7+
*
8+
*
9+
* At the time of writing 560 examples are compiled
10+
*
11+
*/
312
import static org.junit.Assert.fail;
413

514
import java.util.ArrayList;
@@ -25,79 +34,72 @@
2534
@SuppressWarnings({ "nls" })
2635
@RunWith(Parameterized.class)
2736
public class CreateAndCompileArduinoIDEExamplesOnAVRHardwareTest {
28-
private CodeDescriptor myCodeDescriptor;
29-
private MCUBoard myBoard;
30-
private String myProjectName;
31-
private static int myBuildCounter = 0;
32-
private static int myTotalFails = 0;
33-
private static int maxFails = 50;
34-
private static int mySkipAtStart = 0;
35-
36-
public CreateAndCompileArduinoIDEExamplesOnAVRHardwareTest( String projectName,CodeDescriptor codeDescriptor,
37-
MCUBoard board) {
38-
39-
myCodeDescriptor = codeDescriptor;
40-
myBoard = board;
41-
myProjectName =projectName;
42-
}
43-
44-
@SuppressWarnings("rawtypes")
45-
@Parameters(name = " {0}")
46-
public static Collection examples() {
47-
Shared.waitForAllJobsToFinish();
48-
Preferences.setUseBonjour(false);
49-
LinkedList<Object[]> examples = new LinkedList<>();
50-
MCUBoard[] allBoards=Arduino.getAllBoards();
51-
52-
TreeMap<String, IPath> exampleFolders = LibraryManager.getAllArduinoIDEExamples();
53-
for (Map.Entry<String, IPath> curexample : exampleFolders.entrySet()) {
54-
String fqn = curexample.getKey().trim();
55-
IPath examplePath = curexample.getValue();
56-
Examples example = new Examples(fqn, examplePath);
57-
if (!skipExample(example)) {
58-
ArrayList<IPath> paths = new ArrayList<>();
59-
60-
paths.add(examplePath);
61-
CodeDescriptor codeDescriptor = CodeDescriptor.createExample(false, paths);
37+
private CodeDescriptor myCodeDescriptor;
38+
private MCUBoard myBoard;
39+
private String myProjectName;
40+
private static int myBuildCounter = 0;
41+
private static int myTotalFails = 0;
42+
private static int maxFails = 50;
43+
private static int mySkipAtStart = 0;
44+
45+
public CreateAndCompileArduinoIDEExamplesOnAVRHardwareTest(String projectName, CodeDescriptor codeDescriptor,
46+
MCUBoard board) {
47+
48+
myCodeDescriptor = codeDescriptor;
49+
myBoard = board;
50+
myProjectName = projectName;
51+
}
52+
53+
@SuppressWarnings("rawtypes")
54+
@Parameters(name = " {0}")
55+
public static Collection examples() {
56+
Shared.waitForAllJobsToFinish();
57+
Preferences.setUseBonjour(false);
58+
LinkedList<Object[]> examples = new LinkedList<>();
59+
MCUBoard[] allBoards = Arduino.getAllBoards();
60+
61+
TreeMap<String, IPath> exampleFolders = LibraryManager.getAllArduinoIDEExamples();
62+
for (Map.Entry<String, IPath> curexample : exampleFolders.entrySet()) {
63+
String fqn = curexample.getKey().trim();
64+
IPath examplePath = curexample.getValue();
65+
Examples example = new Examples(fqn, examplePath);
66+
if (!skipExample(example)) {
67+
ArrayList<IPath> paths = new ArrayList<>();
68+
69+
paths.add(examplePath);
70+
CodeDescriptor codeDescriptor = CodeDescriptor.createExample(false, paths);
6271
for (MCUBoard curboard : allBoards) {
63-
if (curboard.isExampleSupported(example)) {
64-
String projectName=Shared.getProjectName(codeDescriptor, example, curboard);
65-
Object[] theData = new Object[] { projectName, codeDescriptor, curboard};
66-
examples.add(theData);
67-
}
72+
if (curboard.isExampleSupported(example)) {
73+
String projectName = Shared.getProjectName(codeDescriptor, example, curboard);
74+
Object[] theData = new Object[] { projectName, codeDescriptor, curboard };
75+
examples.add(theData);
76+
}
6877
}
69-
}
70-
}
71-
72-
return examples;
73-
74-
}
75-
76-
private static boolean skipExample(Examples example) {
77-
// skip Teensy stuff on Arduino hardware
78-
// Teensy is so mutch more advanced that most arduino avr hardware can not
79-
// handle
80-
// it
81-
return example.getPath().toString().contains("Teensy");
82-
}
83-
84-
@Test
85-
public void testExample() {
86-
// Stop after X fails because
87-
// the fails stays open in eclipse and it becomes really slow
88-
// There are only a number of issues you can handle
89-
// best is to focus on the first ones and then rerun starting with the
90-
// failures
91-
Assume.assumeTrue("Skipping first " + mySkipAtStart + " tests", myBuildCounter++ >= mySkipAtStart);
92-
Assume.assumeTrue("To many fails. Stopping test", myTotalFails < maxFails);
93-
//because we run all examples on all boards we need to filter incompatible combinations
94-
//like serial examples on gemma
95-
96-
if (!Shared.BuildAndVerify( myProjectName,myBoard.getBoardDescriptor(), myCodeDescriptor, new CompileOptions(null))) {
97-
myTotalFails++;
98-
fail(Shared.getLastFailMessage() );
99-
}
100-
}
78+
}
79+
}
10180

81+
return examples;
82+
83+
}
84+
85+
private static boolean skipExample(Examples example) {
86+
// skip Teensy stuff on Arduino hardware
87+
// Teensy is so mutch more advanced that most arduino avr hardware can not
88+
// handle it
89+
return example.getPath().toString().contains("Teensy");
90+
}
91+
92+
@Test
93+
public void testExample() {
94+
95+
Assume.assumeTrue("Skipping first " + mySkipAtStart + " tests", myBuildCounter++ >= mySkipAtStart);
96+
Assume.assumeTrue("To many fails. Stopping test", myTotalFails < maxFails);
97+
98+
if (!Shared.BuildAndVerify(myProjectName, myBoard.getBoardDescriptor(), myCodeDescriptor,
99+
new CompileOptions(null))) {
100+
myTotalFails++;
101+
fail(Shared.getLastFailMessage());
102+
}
103+
}
102104

103105
}

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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
* Warning!! new teensy boards must be added manually!!!
88
*
99
* At the time of writing no examples are excluded
10-
* At the time of writing 560 examples are compiled
10+
* At the time of writing 1798 examples are compiled
11+
* 2 internal segmentation faults and 1 lto wrapper error
1112
* only the private static method skipExample allows to skip examples
1213
*/
1314

@@ -35,23 +36,24 @@
3536
import io.sloeber.providers.MCUBoard;
3637
import io.sloeber.providers.Teensy;
3738

38-
@SuppressWarnings({"nls"})
39+
@SuppressWarnings({ "nls" })
3940
@RunWith(Parameterized.class)
4041
public class CreateAndCompileArduinoIDEExamplesOnTeensyTest {
4142
private CodeDescriptor myCodeDescriptor;
4243

4344
private String myTestName;
4445
private BoardDescriptor myBoardDescriptor;
45-
private static int myBuildCounter = 0;
46-
private static int myTotalFails = 0;
47-
private static int maxFails = 50;
48-
private static int mySkipAtStart = 0;
46+
private static int myBuildCounter = 0;
47+
private static int myTotalFails = 0;
48+
private static int maxFails = 50;
49+
private static int mySkipAtStart = 0;
4950

50-
public CreateAndCompileArduinoIDEExamplesOnTeensyTest(String testName,CodeDescriptor codeDescriptor,BoardDescriptor board) {
51+
public CreateAndCompileArduinoIDEExamplesOnTeensyTest(String testName, CodeDescriptor codeDescriptor,
52+
BoardDescriptor board) {
5153

5254
myCodeDescriptor = codeDescriptor;
53-
myTestName=testName;
54-
myBoardDescriptor=board;
55+
myTestName = testName;
56+
myBoardDescriptor = board;
5557
}
5658

5759
@SuppressWarnings("rawtypes")
@@ -62,8 +64,8 @@ public static Collection examples() {
6264
Shared.waitForAllJobsToFinish();
6365
Preferences.setUseBonjour(false);
6466
LinkedList<Object[]> examples = new LinkedList<>();
65-
MCUBoard[] allBoards=Teensy.getAllBoards();
66-
67+
MCUBoard[] allBoards = Teensy.getAllBoards();
68+
6769
TreeMap<String, IPath> exampleFolders = LibraryManager.getAllArduinoIDEExamples();
6870
for (Map.Entry<String, IPath> curexample : exampleFolders.entrySet()) {
6971
String fqn = curexample.getKey().trim();
@@ -105,16 +107,14 @@ public static void installAdditionalBoards() {
105107

106108
}
107109

108-
109110
@Test
110111
public void testArduinoIDEExamplesOnTeensy() {
111-
Assume.assumeTrue("Skipping first " + mySkipAtStart + " tests", myBuildCounter++ >= mySkipAtStart);
112-
Assume.assumeTrue("To many fails. Stopping test", myTotalFails < maxFails);
113-
if (!Shared.BuildAndVerify(myTestName, myBoardDescriptor, myCodeDescriptor, new CompileOptions(null))) {
114-
myTotalFails++;
115-
fail(Shared.getLastFailMessage() );
116-
}
112+
Assume.assumeTrue("Skipping first " + mySkipAtStart + " tests", myBuildCounter++ >= mySkipAtStart);
113+
Assume.assumeTrue("To many fails. Stopping test", myTotalFails < maxFails);
114+
if (!Shared.BuildAndVerify(myTestName, myBoardDescriptor, myCodeDescriptor, new CompileOptions(null))) {
115+
myTotalFails++;
116+
fail(Shared.getLastFailMessage());
117+
}
117118
}
118119

119-
120120
}

0 commit comments

Comments
 (0)