|
9 | 9 | * At the time of writing 560 examples are compiled
|
10 | 10 | *
|
11 | 11 | */
|
12 |
| -import static org.junit.Assert.fail; |
| 12 | +import static org.junit.Assert.*; |
13 | 13 |
|
14 | 14 | import java.util.ArrayList;
|
15 | 15 | import java.util.Collection;
|
16 | 16 | import java.util.LinkedList;
|
| 17 | +import java.util.List; |
17 | 18 | import java.util.Map;
|
18 | 19 | import java.util.TreeMap;
|
19 | 20 |
|
|
34 | 35 | @SuppressWarnings({ "nls" })
|
35 | 36 | @RunWith(Parameterized.class)
|
36 | 37 | public class CreateAndCompileArduinoIDEExamplesOnAVRHardwareTest {
|
37 |
| - private CodeDescription 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, CodeDescription 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 |
| - CodeDescription codeDescriptor = CodeDescription.createExample(false, paths); |
71 |
| - for (MCUBoard curboard : allBoards) { |
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 |
| - } |
77 |
| - } |
78 |
| - } |
79 |
| - } |
80 |
| - |
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, |
| 38 | + private CodeDescription myCodeDescriptor; |
| 39 | + private MCUBoard myBoard; |
| 40 | + private String myProjectName; |
| 41 | + private static int myBuildCounter = 0; |
| 42 | + private static int myTotalFails = 0; |
| 43 | + private static int maxFails = 50; |
| 44 | + private static int mySkipAtStart = 0; |
| 45 | + |
| 46 | + public CreateAndCompileArduinoIDEExamplesOnAVRHardwareTest(String projectName, CodeDescription codeDescriptor, |
| 47 | + MCUBoard board) { |
| 48 | + |
| 49 | + myCodeDescriptor = codeDescriptor; |
| 50 | + myBoard = board; |
| 51 | + myProjectName = projectName; |
| 52 | + } |
| 53 | + |
| 54 | + @SuppressWarnings("rawtypes") |
| 55 | + @Parameters(name = " {0}") |
| 56 | + public static Collection examples() { |
| 57 | + Shared.waitForAllJobsToFinish(); |
| 58 | + Preferences.setUseBonjour(false); |
| 59 | + LinkedList<Object[]> examples = new LinkedList<>(); |
| 60 | + List<MCUBoard> allBoards = Arduino.getAllBoards(); |
| 61 | + |
| 62 | + TreeMap<String, IPath> exampleFolders = LibraryManager.getAllArduinoIDEExamples(); |
| 63 | + for (Map.Entry<String, IPath> curexample : exampleFolders.entrySet()) { |
| 64 | + String fqn = curexample.getKey().trim(); |
| 65 | + IPath examplePath = curexample.getValue(); |
| 66 | + Example example = new Example(fqn, examplePath); |
| 67 | + if (!skipExample(example)) { |
| 68 | + ArrayList<IPath> paths = new ArrayList<>(); |
| 69 | + |
| 70 | + paths.add(examplePath); |
| 71 | + CodeDescription codeDescriptor = CodeDescription.createExample(false, paths); |
| 72 | + for (MCUBoard curboard : allBoards) { |
| 73 | + if (curboard.isExampleSupported(example)) { |
| 74 | + String projectName = Shared.getProjectName(codeDescriptor, example, curboard); |
| 75 | + Object[] theData = new Object[] { projectName, codeDescriptor, curboard }; |
| 76 | + examples.add(theData); |
| 77 | + } |
| 78 | + } |
| 79 | + } |
| 80 | + } |
| 81 | + |
| 82 | + return examples; |
| 83 | + |
| 84 | + } |
| 85 | + |
| 86 | + private static boolean skipExample(Example example) { |
| 87 | + // skip Teensy stuff on Arduino hardware |
| 88 | + // Teensy is so mutch more advanced that most arduino avr hardware can not |
| 89 | + // handle it |
| 90 | + return example.getPath().toString().contains("Teensy"); |
| 91 | + } |
| 92 | + |
| 93 | + @Test |
| 94 | + public void testExample() { |
| 95 | + |
| 96 | + Assume.assumeTrue("Skipping first " + mySkipAtStart + " tests", myBuildCounter++ >= mySkipAtStart); |
| 97 | + Assume.assumeTrue("To many fails. Stopping test", myTotalFails < maxFails); |
| 98 | + |
| 99 | + if (!Shared.BuildAndVerify(myProjectName, myBoard.getBoardDescriptor(), myCodeDescriptor, |
99 | 100 | new CompileDescription())) {
|
100 |
| - myTotalFails++; |
101 |
| - fail(Shared.getLastFailMessage()); |
102 |
| - } |
103 |
| - } |
| 101 | + myTotalFails++; |
| 102 | + fail(Shared.getLastFailMessage()); |
| 103 | + } |
| 104 | + } |
104 | 105 |
|
105 | 106 | }
|
0 commit comments