Skip to content

Commit 6cbe857

Browse files
author
jantje
committed
#1339 fixing lots of TODO's mostly code related
Also tuned the test selection
1 parent e62a7cb commit 6cbe857

11 files changed

+538
-426
lines changed

io.sloeber.core/src/io/sloeber/core/api/BoardDescription.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -276,15 +276,15 @@ private void ParseSection() {
276276
* @param boardFile
277277
* @return a list of board descriptors
278278
*/
279-
public static List<BoardDescription> makeBoardDescriptors(File boardFile, Map<String, String> options) {
279+
public static List<BoardDescription> makeBoardDescriptors(File boardFile) {
280280
BoardTxtFile txtFile = new BoardTxtFile(resolvePathEnvironmentString(boardFile));
281281
List<BoardDescription> boards = new ArrayList<>();
282282
List<String> boardIDs = txtFile.getAllBoardIDs();
283283
for (String curboardID : boardIDs) {
284284
Map<String, String> boardSection = txtFile.getSection(curboardID);
285285
if (boardSection != null) {
286286
if (!"true".equalsIgnoreCase(boardSection.get("hide"))) { //$NON-NLS-1$ //$NON-NLS-2$
287-
boards.add(new BoardDescription(boardFile, curboardID, options));
287+
boards.add(new BoardDescription(boardFile, curboardID, null));
288288
}
289289
}
290290
}

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

+12-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,15 @@ public class BoardAttributes {
1111
public boolean wire1 = false;
1212
public boolean rawHID = false;
1313
public boolean buildInLed = true;
14+
public boolean tone = true;
15+
//the number of ADC ports needed/available
16+
//default is ridiculous high so boards should
17+
// 1)default to test
18+
// 2 fail if insufficient ADC's are available
19+
public int myNumAD = 20;
20+
1421
/*
15-
* Only a very rara selection of boards supports input_pulldown as pin mode
22+
* Only a very rare selection of boards supports input_pulldown as pin mode
1623
*/
1724
public boolean inputPullDown = false;
1825
public boolean teensy = false;// Teensy specific hardware or software
@@ -44,6 +51,9 @@ public boolean compatibleWithExampleRequirements(BoardAttributes example) {
4451
ret = ret && matches(example.mo_mcu, mo_mcu);
4552
ret = ret && matches(example.esp8266_mcu, esp8266_mcu);
4653
ret = ret && matches(example.buildInLed, buildInLed);
54+
ret = ret && matches(example.tone, tone);
55+
ret = ret && example.myNumAD <= myNumAD;
56+
4757
if (example.boardName != null) {
4858
ret = ret && example.boardName.equals(boardName);
4959
}
@@ -67,6 +77,7 @@ public BoardAttributes or(BoardAttributes or) {
6777
// fields that need a binary and
6878
ret.worksOutOfTheBox = worksOutOfTheBox && or.worksOutOfTheBox;
6979
ret.buildInLed = buildInLed && or.buildInLed;
80+
ret.tone = tone && or.tone;
7081
// fields that can do with or
7182
ret.serial = serial || or.serial;
7283
ret.rawHID = rawHID || or.rawHID;

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

+80-79
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
* only the private static method skipExample allows to skip examples
1313
*/
1414

15-
import static org.junit.Assert.fail;
15+
import static org.junit.Assert.*;
1616

1717
import java.util.ArrayList;
1818
import java.util.Collection;
1919
import java.util.LinkedList;
20+
import java.util.List;
2021
import java.util.Map;
2122
import java.util.TreeMap;
2223

@@ -28,94 +29,94 @@
2829
import org.junit.runners.Parameterized.Parameters;
2930

3031
import io.sloeber.core.api.BoardDescription;
32+
import io.sloeber.core.api.BoardsManager;
3133
import io.sloeber.core.api.CodeDescription;
3234
import io.sloeber.core.api.CompileDescription;
3335
import io.sloeber.core.api.LibraryManager;
34-
import io.sloeber.core.api.BoardsManager;
3536
import io.sloeber.core.api.Preferences;
3637
import io.sloeber.providers.MCUBoard;
3738
import io.sloeber.providers.Teensy;
3839

3940
@SuppressWarnings({ "nls" })
4041
@RunWith(Parameterized.class)
4142
public class CreateAndCompileArduinoIDEExamplesOnTeensyTest {
42-
private CodeDescription myCodeDescriptor;
43-
44-
private String myTestName;
45-
private BoardDescription myBoardDescriptor;
46-
private static int myBuildCounter = 0;
47-
private static int myTotalFails = 0;
48-
private static int maxFails = 50;
49-
private static int mySkipAtStart = 0;
50-
51-
public CreateAndCompileArduinoIDEExamplesOnTeensyTest(String testName, CodeDescription codeDescriptor,
52-
BoardDescription board) {
53-
54-
myCodeDescriptor = codeDescriptor;
55-
myTestName = testName;
56-
myBoardDescriptor = board;
57-
}
58-
59-
@SuppressWarnings("rawtypes")
60-
@Parameters(name = "{0}")
61-
public static Collection examples() {
62-
installAdditionalBoards();
63-
64-
Shared.waitForAllJobsToFinish();
65-
Preferences.setUseBonjour(false);
66-
LinkedList<Object[]> examples = new LinkedList<>();
67-
MCUBoard[] allBoards = Teensy.getAllBoards();
68-
69-
TreeMap<String, IPath> exampleFolders = LibraryManager.getAllArduinoIDEExamples();
70-
for (Map.Entry<String, IPath> curexample : exampleFolders.entrySet()) {
71-
String fqn = curexample.getKey().trim();
72-
IPath examplePath = curexample.getValue();
73-
Example example = new Example(fqn, examplePath);
74-
if (!skipExample(example)) {
75-
ArrayList<IPath> paths = new ArrayList<>();
76-
paths.add(examplePath);
77-
CodeDescription codeDescriptor = CodeDescription.createExample(false, paths);
78-
79-
for (MCUBoard curBoard : allBoards) {
80-
if (curBoard.isExampleSupported(example)) {
81-
String projectName = Shared.getProjectName(codeDescriptor, example, curBoard);
82-
Map<String, String> boardOptions = curBoard.getBoardOptions(example);
83-
BoardDescription boardDescriptor = curBoard.getBoardDescriptor();
84-
boardDescriptor.setOptions(boardOptions);
85-
Object[] theData = new Object[] { projectName, codeDescriptor, boardDescriptor };
86-
examples.add(theData);
87-
}
88-
}
89-
}
90-
}
91-
92-
return examples;
93-
94-
}
95-
96-
@SuppressWarnings("unused")
97-
private static boolean skipExample(Example example) {
98-
// no need to skip examples in this test
99-
return false;
100-
}
101-
102-
public static void installAdditionalBoards() {
103-
if (MySystem.getTeensyPlatform().isEmpty()) {
104-
System.err.println("ERROR: Teensy not installed/configured skipping tests!!!");
105-
} else {
106-
BoardsManager.addPrivateHardwarePath(MySystem.getTeensyPlatform());
107-
}
108-
109-
}
110-
111-
@Test
112-
public void testArduinoIDEExamplesOnTeensy() {
113-
Assume.assumeTrue("Skipping first " + mySkipAtStart + " tests", myBuildCounter++ >= mySkipAtStart);
114-
Assume.assumeTrue("To many fails. Stopping test", myTotalFails < maxFails);
43+
private CodeDescription myCodeDescriptor;
44+
45+
private String myTestName;
46+
private BoardDescription myBoardDescriptor;
47+
private static int myBuildCounter = 0;
48+
private static int myTotalFails = 0;
49+
private static int maxFails = 50;
50+
private static int mySkipAtStart = 0;
51+
52+
public CreateAndCompileArduinoIDEExamplesOnTeensyTest(String testName, CodeDescription codeDescriptor,
53+
BoardDescription board) {
54+
55+
myCodeDescriptor = codeDescriptor;
56+
myTestName = testName;
57+
myBoardDescriptor = board;
58+
}
59+
60+
@SuppressWarnings("rawtypes")
61+
@Parameters(name = "{0}")
62+
public static Collection examples() {
63+
installAdditionalBoards();
64+
65+
Shared.waitForAllJobsToFinish();
66+
Preferences.setUseBonjour(false);
67+
LinkedList<Object[]> examples = new LinkedList<>();
68+
List<MCUBoard> allBoards = Teensy.getAllBoards();
69+
70+
TreeMap<String, IPath> exampleFolders = LibraryManager.getAllArduinoIDEExamples();
71+
for (Map.Entry<String, IPath> curexample : exampleFolders.entrySet()) {
72+
String fqn = curexample.getKey().trim();
73+
IPath examplePath = curexample.getValue();
74+
Example example = new Example(fqn, examplePath);
75+
if (!skipExample(example)) {
76+
ArrayList<IPath> paths = new ArrayList<>();
77+
paths.add(examplePath);
78+
CodeDescription codeDescriptor = CodeDescription.createExample(false, paths);
79+
80+
for (MCUBoard curBoard : allBoards) {
81+
if (curBoard.isExampleSupported(example)) {
82+
String projectName = Shared.getProjectName(codeDescriptor, example, curBoard);
83+
Map<String, String> boardOptions = curBoard.getBoardOptions(example);
84+
BoardDescription boardDescriptor = curBoard.getBoardDescriptor();
85+
boardDescriptor.setOptions(boardOptions);
86+
Object[] theData = new Object[] { projectName, codeDescriptor, boardDescriptor };
87+
examples.add(theData);
88+
}
89+
}
90+
}
91+
}
92+
93+
return examples;
94+
95+
}
96+
97+
@SuppressWarnings("unused")
98+
private static boolean skipExample(Example example) {
99+
// no need to skip examples in this test
100+
return false;
101+
}
102+
103+
public static void installAdditionalBoards() {
104+
if (MySystem.getTeensyPlatform().isEmpty()) {
105+
System.err.println("ERROR: Teensy not installed/configured skipping tests!!!");
106+
} else {
107+
BoardsManager.addPrivateHardwarePath(MySystem.getTeensyPlatform());
108+
}
109+
110+
}
111+
112+
@Test
113+
public void testArduinoIDEExamplesOnTeensy() {
114+
Assume.assumeTrue("Skipping first " + mySkipAtStart + " tests", myBuildCounter++ >= mySkipAtStart);
115+
Assume.assumeTrue("To many fails. Stopping test", myTotalFails < maxFails);
115116
if (!Shared.BuildAndVerify(myTestName, myBoardDescriptor, myCodeDescriptor, new CompileDescription())) {
116-
myTotalFails++;
117-
fail(Shared.getLastFailMessage());
118-
}
119-
}
117+
myTotalFails++;
118+
fail(Shared.getLastFailMessage());
119+
}
120+
}
120121

121122
}

0 commit comments

Comments
 (0)