|
32 | 32 | @SuppressWarnings({ "nls" }) |
33 | 33 | @RunWith(Parameterized.class) |
34 | 34 | public class CreateAndCompileLibraryExamplesTest { |
35 | | - private static final boolean reinstall_boards_and_examples = true; |
36 | | - private static final int maxFails = 100; |
37 | | - private static final int mySkipAtStart = 0; |
38 | | - |
39 | | - private static int myBuildCounter = 0; |
40 | | - private static int myTotalFails = 0; |
41 | | - private Example myExample; |
42 | | - private MCUBoard myBoard; |
43 | | - |
44 | | - @SuppressWarnings("unused") |
45 | | - public CreateAndCompileLibraryExamplesTest(String name, MCUBoard boardID, Example example) { |
46 | | - myBoard = boardID; |
47 | | - myExample = example; |
48 | | - } |
49 | | - |
50 | | - @SuppressWarnings("rawtypes") |
51 | | - @Parameters(name = "{index}: {0}") |
52 | | - public static Collection examples() { |
53 | | - Preferences.setUseBonjour(false); |
54 | | - Preferences.setUseArduinoToolSelection(true); |
55 | | - Shared.waitForAllJobsToFinish(); |
56 | | - installMyStuff(); |
57 | | - |
58 | | - MCUBoard myBoards[] = { Arduino.leonardo(), Arduino.uno(), Arduino.esplora(), Adafruit.feather(), |
59 | | - Adafruit.featherMO(), Arduino.adafruitnCirquitPlayground(), ESP8266.nodeMCU(), ESP8266.wemosD1(), |
60 | | - ESP8266.ESPressoLite(), Teensy.Teensy3_6(), Arduino.zeroProgrammingPort(), |
61 | | - Arduino.cirquitPlaygroundExpress(), Arduino.gemma(), Adafruit.trinket8MH(), Arduino.yun(), |
62 | | - Arduino.arduino_101(), Arduino.zeroProgrammingPort(), Arduino.ethernet() }; |
63 | | - |
64 | | - LinkedList<Object[]> examples = new LinkedList<>(); |
65 | | - TreeMap<String, IPath> exampleFolders = LibraryManager.getAllExamples(null); |
66 | | - for (Map.Entry<String, IPath> curexample : exampleFolders.entrySet()) { |
67 | | - String fqn = curexample.getKey().trim(); |
68 | | - IPath examplePath = curexample.getValue(); |
69 | | - Example example = new Example(fqn, examplePath); |
70 | | - |
71 | | - // with the current amount of examples only do one |
72 | | - MCUBoard curBoard = Example.pickBestBoard(example, myBoards); |
73 | | - |
74 | | - if (curBoard != null) { |
75 | | - Object[] theData = new Object[] { example.getLibName() + ":" + fqn + ":" + curBoard.getID(), curBoard, |
76 | | - example }; |
77 | | - examples.add(theData); |
78 | | - } |
79 | | - |
80 | | - } |
81 | | - |
82 | | - return examples; |
83 | | - |
84 | | - } |
85 | | - |
86 | | - /* |
87 | | - * In new new installations (of the Sloeber development environment) the |
88 | | - * installer job will trigger downloads These mmust have finished before we can |
89 | | - * start testing |
90 | | - */ |
91 | | - |
92 | | - public static void installMyStuff() { |
93 | | - |
94 | | - installAdditionalBoards(); |
95 | | - Shared.waitForAllJobsToFinish(); |
96 | | - } |
97 | | - |
98 | | - public static void installAdditionalBoards() { |
99 | | - String[] packageUrlsToAdd = { ESP8266.packageURL, Adafruit.packageURL, ESP32.packageURL }; |
100 | | - BoardsManager.addPackageURLs(new HashSet<>(Arrays.asList(packageUrlsToAdd)), reinstall_boards_and_examples); |
101 | | - if (reinstall_boards_and_examples) { |
102 | | - BoardsManager.installAllLatestPlatforms(); |
103 | | - BoardsManager.onlyKeepLatestPlatforms(); |
104 | | - // deal with removal of json files or libs from json files |
105 | | - LibraryManager.unInstallAllLibs(); |
106 | | - LibraryManager.installAllLatestLibraries(); |
107 | | - // LibraryManager.onlyKeepLatestPlatforms(); |
108 | | - } |
109 | | - if (MySystem.getTeensyPlatform().isEmpty()) { |
110 | | - System.err.println("ERROR: Teensy not installed/configured skipping tests!!!"); |
111 | | - } else { |
112 | | - BoardsManager.addPrivateHardwarePath(MySystem.getTeensyPlatform()); |
113 | | - } |
114 | | - BoardsManager.installAllLatestPlatforms(); |
115 | | - |
116 | | - } |
117 | | - |
118 | | - @Test |
119 | | - public void testExamples() { |
120 | | - |
121 | | - Assume.assumeTrue("Skipping first " + mySkipAtStart + " tests", myBuildCounter++ >= mySkipAtStart); |
122 | | - Assume.assumeTrue("To many fails. Stopping test", myTotalFails < maxFails); |
123 | | - if (!myBoard.isExampleSupported(myExample)) { |
124 | | - fail("Trying to run a test on unsoprted board"); |
125 | | - myTotalFails++; |
126 | | - return; |
127 | | - } |
128 | | - ArrayList<IPath> paths = new ArrayList<>(); |
129 | | - |
130 | | - paths.add(myExample.getPath()); |
131 | | - CodeDescription codeDescriptor = CodeDescription.createExample(false, paths); |
132 | | - |
133 | | - Map<String, String> boardOptions = myBoard.getBoardOptions(myExample); |
134 | | - BoardDescription boardDescriptor = myBoard.getBoardDescriptor(); |
135 | | - boardDescriptor.setOptions(boardOptions); |
136 | | - if (!Shared.BuildAndVerify(boardDescriptor, codeDescriptor)) { |
137 | | - myTotalFails++; |
138 | | - fail(Shared.getLastFailMessage()); |
139 | | - } |
140 | | - |
141 | | - } |
| 35 | + private static final boolean reinstall_boards_and_examples = false; |
| 36 | + private static final int maxFails = 100; |
| 37 | + private static final int mySkipAtStart = 0; |
| 38 | + |
| 39 | + private static int myBuildCounter = 0; |
| 40 | + private static int myTotalFails = 0; |
| 41 | + private Example myExample; |
| 42 | + private MCUBoard myBoard; |
| 43 | + |
| 44 | + @SuppressWarnings("unused") |
| 45 | + public CreateAndCompileLibraryExamplesTest(String name, MCUBoard boardID, Example example) { |
| 46 | + myBoard = boardID; |
| 47 | + myExample = example; |
| 48 | + } |
| 49 | + |
| 50 | + @SuppressWarnings("rawtypes") |
| 51 | + @Parameters(name = "{index}: {0}") |
| 52 | + public static Collection examples() { |
| 53 | + Preferences.setUseBonjour(false); |
| 54 | + Preferences.setUseArduinoToolSelection(true); |
| 55 | + Shared.waitForAllJobsToFinish(); |
| 56 | + installMyStuff(); |
| 57 | + |
| 58 | + MCUBoard myBoards[] = { Arduino.leonardo(), Arduino.uno(), Arduino.esplora(), Adafruit.feather(), |
| 59 | + Adafruit.featherMO(), Arduino.adafruitnCirquitPlayground(), ESP8266.nodeMCU(), ESP8266.wemosD1(), |
| 60 | + ESP8266.ESPressoLite(), Teensy.Teensy3_6(), Arduino.zeroProgrammingPort(), |
| 61 | + Arduino.cirquitPlaygroundExpress(), Arduino.gemma(), Adafruit.trinket8MH(), Arduino.yun(), |
| 62 | + Arduino.arduino_101(), Arduino.zeroProgrammingPort(), Arduino.ethernet() }; |
| 63 | + |
| 64 | + LinkedList<Object[]> examples = new LinkedList<>(); |
| 65 | + TreeMap<String, IPath> exampleFolders = LibraryManager.getAllExamples(null); |
| 66 | + for (Map.Entry<String, IPath> curexample : exampleFolders.entrySet()) { |
| 67 | + String fqn = curexample.getKey().trim(); |
| 68 | + IPath examplePath = curexample.getValue(); |
| 69 | + Example example = new Example(fqn, examplePath); |
| 70 | + |
| 71 | + // with the current amount of examples only do one |
| 72 | + MCUBoard curBoard = Example.pickBestBoard(example, myBoards); |
| 73 | + |
| 74 | + if (curBoard != null) { |
| 75 | + Object[] theData = new Object[] { example.getLibName() + ":" + fqn + ":" + curBoard.getID(), curBoard, |
| 76 | + example }; |
| 77 | + examples.add(theData); |
| 78 | + } |
| 79 | + |
| 80 | + } |
| 81 | + |
| 82 | + return examples; |
| 83 | + |
| 84 | + } |
| 85 | + |
| 86 | + /* |
| 87 | + * In new new installations (of the Sloeber development environment) the |
| 88 | + * installer job will trigger downloads These mmust have finished before we can |
| 89 | + * start testing |
| 90 | + */ |
| 91 | + |
| 92 | + public static void installMyStuff() { |
| 93 | + |
| 94 | + installAdditionalBoards(); |
| 95 | + Shared.waitForAllJobsToFinish(); |
| 96 | + } |
| 97 | + |
| 98 | + public static void installAdditionalBoards() { |
| 99 | + String[] packageUrlsToAdd = { ESP8266.packageURL, Adafruit.packageURL, ESP32.packageURL }; |
| 100 | + BoardsManager.addPackageURLs(new HashSet<>(Arrays.asList(packageUrlsToAdd)), reinstall_boards_and_examples); |
| 101 | + if (reinstall_boards_and_examples) { |
| 102 | + BoardsManager.installAllLatestPlatforms(); |
| 103 | + BoardsManager.onlyKeepLatestPlatforms(); |
| 104 | + // deal with removal of json files or libs from json files |
| 105 | + LibraryManager.unInstallAllLibs(); |
| 106 | + LibraryManager.installAllLatestLibraries(); |
| 107 | + // LibraryManager.onlyKeepLatestPlatforms(); |
| 108 | + } |
| 109 | + if (MySystem.getTeensyPlatform().isEmpty()) { |
| 110 | + System.err.println("ERROR: Teensy not installed/configured skipping tests!!!"); |
| 111 | + } else { |
| 112 | + BoardsManager.addPrivateHardwarePath(MySystem.getTeensyPlatform()); |
| 113 | + } |
| 114 | + BoardsManager.installAllLatestPlatforms(); |
| 115 | + |
| 116 | + } |
| 117 | + |
| 118 | + @Test |
| 119 | + public void testExamples() { |
| 120 | + |
| 121 | + Assume.assumeTrue("Skipping first " + mySkipAtStart + " tests", myBuildCounter++ >= mySkipAtStart); |
| 122 | + Assume.assumeTrue("To many fails. Stopping test", myTotalFails < maxFails); |
| 123 | + if (!myBoard.isExampleSupported(myExample)) { |
| 124 | + fail("Trying to run a test on unsoprted board"); |
| 125 | + myTotalFails++; |
| 126 | + return; |
| 127 | + } |
| 128 | + ArrayList<IPath> paths = new ArrayList<>(); |
| 129 | + |
| 130 | + paths.add(myExample.getPath()); |
| 131 | + CodeDescription codeDescriptor = CodeDescription.createExample(false, paths); |
| 132 | + |
| 133 | + Map<String, String> boardOptions = myBoard.getBoardOptions(myExample); |
| 134 | + BoardDescription boardDescriptor = myBoard.getBoardDescriptor(); |
| 135 | + boardDescriptor.setOptions(boardOptions); |
| 136 | + if (!Shared.BuildAndVerify(boardDescriptor, codeDescriptor)) { |
| 137 | + myTotalFails++; |
| 138 | + fail(Shared.getLastFailMessage()); |
| 139 | + } |
| 140 | + |
| 141 | + } |
142 | 142 |
|
143 | 143 | } |
0 commit comments