|
1 | 1 | package io.sloeber.core;
|
2 | 2 |
|
| 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 | + */ |
3 | 12 | import static org.junit.Assert.fail;
|
4 | 13 |
|
5 | 14 | import java.util.ArrayList;
|
|
25 | 34 | @SuppressWarnings({ "nls" })
|
26 | 35 | @RunWith(Parameterized.class)
|
27 | 36 | 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); |
62 | 71 | 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 | + } |
68 | 77 | }
|
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 | + } |
101 | 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, |
| 99 | + new CompileOptions(null))) { |
| 100 | + myTotalFails++; |
| 101 | + fail(Shared.getLastFailMessage()); |
| 102 | + } |
| 103 | + } |
102 | 104 |
|
103 | 105 | }
|
0 commit comments