Skip to content

Commit ed7df57

Browse files
author
jantje
committed
Unit tests now skip boards that are marked as non visble
1 parent f29279a commit ed7df57

File tree

4 files changed

+29
-23
lines changed

4 files changed

+29
-23
lines changed

io.sloeber.core/src/io/sloeber/core/Activator.java

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public class Activator extends AbstractUIPlugin {
7575
'e', 'c', 'l', 'i', 'p', 's', 'e', '/', 'd', 'o', 'w', 'n', 'l', 'o', 'a', 'd', '/', 'p', 'l', 'u', 'g',
7676
'i', 'n', 'S', 't', 'a', 'r', 't', '.', 'h', 't', 'm', 'l', '?', 's', '=' };
7777
private static final String PLUGIN_ID = "io.sloeber.core";
78+
private static Boolean isPatron = null;
7879

7980
@Override
8081
public void start(BundleContext context) throws Exception {
@@ -375,7 +376,7 @@ protected IStatus run(IProgressMonitor monitor) {
375376
} catch (BackingStoreException e) {
376377
// this should not happen
377378
}
378-
if (isInternetReachable()) {
379+
if (!isPatron()) {
379380
PleaseHelp.doHelp(HELP_LOC);
380381
}
381382
}
@@ -387,17 +388,15 @@ protected IStatus run(IProgressMonitor monitor) {
387388
job.schedule(60000);
388389
}
389390

390-
static boolean isInternetReachable() {
391-
boolean ret = false;
391+
static boolean isPatron() {
392+
if (isPatron != null) {
393+
return isPatron.booleanValue();
394+
}
392395
HttpURLConnection urlConnect = null;
393-
394396
try {
395-
// make a URL to a known source
396-
URL url = new URL(HELP_LOC + "?systemhash=" + ConfigurationPreferences.getSystemHash());
397-
// open a connection to that source
397+
String systemhash = ConfigurationPreferences.getSystemHash();
398+
URL url = new URL(HELP_LOC + "?systemhash=" + systemhash);
398399
urlConnect = (HttpURLConnection) url.openConnection();
399-
// trying to retrieve data from the source. If there is no
400-
// connection, this line will fail
401400
urlConnect.getContent();
402401
} catch (UnknownHostException e) {
403402
return false;
@@ -406,14 +405,19 @@ static boolean isInternetReachable() {
406405
} finally {
407406
if (urlConnect != null) {
408407
try {
409-
ret = (urlConnect.getResponseCode() != 404);
408+
urlConnect.getContent();
410409
} catch (IOException e) {
411-
// ignore
410+
// TODO Auto-generated catch block
411+
e.printStackTrace();
412412
}
413+
int length = urlConnect.getContentLength();
414+
isPatron = new Boolean(length < 200);
413415
urlConnect.disconnect();
414416
}
415-
416417
}
417-
return ret;
418+
if (isPatron != null) {
419+
return isPatron.booleanValue();
420+
}
421+
return false;
418422
}
419423
}

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,11 @@ public static List<BoardDescriptor> makeBoardDescriptors(File boardFile) {
211211
TxtFile txtFile = new TxtFile(boardFile);
212212
List<BoardDescriptor> boards = new ArrayList<>();
213213
for (String curboardName : txtFile.getAllNames()) {
214-
Map<String, String> boardSection = txtFile.getSection(curboardName);
215-
if (!"true".equalsIgnoreCase(boardSection.get("hide"))) {
216-
boards.add(makeBoardDescriptor(boardFile, txtFile.getBoardIDFromBoardName(curboardName), null));
214+
Map<String, String> boardSection = txtFile.getSection(txtFile.getBoardIDFromBoardName(curboardName));
215+
if (boardSection != null) {
216+
if (!"true".equalsIgnoreCase(boardSection.get("hide"))) {
217+
boards.add(makeBoardDescriptor(boardFile, txtFile.getBoardIDFromBoardName(curboardName), null));
218+
}
217219
}
218220
}
219221
return boards;

io.sloeber.core/src/jUnit/CreateAndCompileExamples.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import org.eclipse.core.runtime.IPath;
1818
import org.eclipse.core.runtime.NullProgressMonitor;
1919
import org.eclipse.core.runtime.Path;
20-
import org.junit.BeforeClass;
2120
import org.junit.Test;
2221
import org.junit.runner.RunWith;
2322
import org.junit.runners.Parameterized;
@@ -45,6 +44,7 @@ public CreateAndCompileExamples(String name, BoardDescriptor boardid, CodeDescri
4544
@SuppressWarnings("rawtypes")
4645
@Parameters(name = "{index}: {0}")
4746
public static Collection examples() {
47+
WaitForInstallerToFinish();
4848
Map<String, String> myOptions = new HashMap<>();
4949
String[] lines = new String("").split("\n"); //$NON-NLS-1$
5050
for (String curLine : lines) {
@@ -60,15 +60,15 @@ public static Collection examples() {
6060
return null;
6161
}
6262
leonardoBoardid.setUploadPort("none");
63-
BoardDescriptor unoBoardid = BoardsManager.getBoardDescriptor("package_index.json", "arduino", "Arduino AVR Boards",
64-
"uno", myOptions);
63+
BoardDescriptor unoBoardid = BoardsManager.getBoardDescriptor("package_index.json", "arduino",
64+
"Arduino AVR Boards", "uno", myOptions);
6565
if (unoBoardid == null) {
6666
fail("uno Board not found");
6767
return null;
6868
}
6969
unoBoardid.setUploadPort("none");
70-
BoardDescriptor EsploraBoardid = BoardsManager.getBoardDescriptor("package_index.json", "arduino", "Arduino AVR Boards",
71-
"esplora", myOptions);
70+
BoardDescriptor EsploraBoardid = BoardsManager.getBoardDescriptor("package_index.json", "arduino",
71+
"Arduino AVR Boards", "esplora", myOptions);
7272
if (EsploraBoardid == null) {
7373
fail("Esplora Board not found");
7474
return null;
@@ -150,7 +150,7 @@ private static boolean isExampleOkForEsplora(String key) {
150150
* installer job will trigger downloads These mmust have finished before we
151151
* can start testing
152152
*/
153-
@BeforeClass
153+
154154
public static void WaitForInstallerToFinish() {
155155
installAdditionalBoards();
156156
Shared.waitForAllJobsToFinish();

website/WebContent/remind.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
if ($result->num_rows > 0) {
1616
$default = 0;
17-
header ( $_SERVER ["SERVER_PROTOCOL"] . " 404 Not Found", true, 404 );
17+
echo $secretMessage;
1818
// output data of each row
1919
while ( $row = $result->fetch_assoc () ) {
2020
echo "Patron: " . $row ["patronIDE"] . " key:" . $KEY . "<br>";

0 commit comments

Comments
 (0)