Skip to content

Commit

Permalink
add tests for #1696 (build should fail)
Browse files Browse the repository at this point in the history
This commits adds a test for #1696 (actually expanding a existing
tests).
Because the issue dooes not show on linux the test succeeds on my
windows system.
However the build is on a linux system so this commit is expected to
fail the build.
I'm still pushing it to get the test on my Linux system to fix it.
I know I could create a branch and push to the branch ... but as I have
been  the only contributer to this repository the last 12 months nobody
should suffer ;-)
  • Loading branch information
jan committed Dec 23, 2024
1 parent ec20b80 commit 31771cd
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 10 deletions.
18 changes: 12 additions & 6 deletions io.sloeber.tests/src/io/sloeber/core/BuildTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -233,18 +233,24 @@ public void createDefaultInoProject() throws Exception {
*
* @throws Exception
*/
@Test
public void issue1047_Board_Names_Can_Be_used_as_Strings() throws Exception {
MCUBoard unoBoard = ESP8266.nodeMCU();
@ParameterizedTest
@MethodSource("issue1047_Board_Names_Can_Be_used_as_StringsData")
public void issue1047_Board_Names_Can_Be_used_as_Strings(String projectName, MCUBoard board) throws Exception {

String projectName = "issue1047_Board_Names_Can_Be_used_as_Strings";
IPath templateFolder = Shared.getTemplateFolder(projectName);
IPath templateFolder = Shared.getTemplateFolder("issue1047_Board_Names_Can_Be_used_as_Strings");
CodeDescription codeDescriptor = CodeDescription.createCustomTemplate(templateFolder);
IProject theTestProject = SloeberProject.createArduinoProject(projectName, null, unoBoard.getBoardDescriptor(),
IProject theTestProject = SloeberProject.createArduinoProject(projectName, null, board.getBoardDescriptor(),
codeDescriptor, new CompileDescription(), new NullProgressMonitor());
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
assertNull(Shared.hasBuildErrors(theTestProject));
}

public static Stream<Arguments> issue1047_Board_Names_Can_Be_used_as_StringsData() throws Exception {
List<Arguments> ret = new LinkedList<>();
ret.add(Arguments.of("issue1047_Leonardo_Board_Names_Can_Be_used_as_Strings", Arduino.leonardo()));
ret.add(Arguments.of("issue1047_Zero_Board_Names_Can_Be_used_as_Strings", Arduino.zeroNatviePort()));
ret.add(Arguments.of("issue1047_ESP32S3_Board_Names_Can_Be_used_as_Strings", ESP32.ESP32S3()));
return ret.stream();
}

/**
Expand Down
14 changes: 14 additions & 0 deletions io.sloeber.tests/src/io/sloeber/providers/ESP32.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ public ESP32(String boardName, Map<String, String> options) {
setAttributes();
}

private ESP32(String providerName, String architectureName, String boardID) {
this.myBoardDescriptor = BoardsManager.getBoardDescription(packageURL, providerName, architectureName,
boardID, null);
if (this.myBoardDescriptor == null) {
fail(boardID + " Board not found");
}
this.myBoardDescriptor.setUploadPort("none");
setAttributes();
}

public ESP32(BoardDescription boardDesc) {
myBoardDescriptor = boardDesc;
myBoardDescriptor.setUploadPort("none");
Expand All @@ -57,4 +67,8 @@ public MCUBoard createMCUBoard(BoardDescription boardDesc) {
return new ESP32(boardDesc);
}

public static Object ESP32S3() {
return new ESP32(provider, architectureName, "esp32s3");
}

}
10 changes: 8 additions & 2 deletions io.sloeber.tests/src/templates/CreateAndCompileTest/sketch.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
#include "Arduino.h"

#ifdef ARDUINO_BOARD
char mychar1[] = ARDUINO_BOARD;
char mychar[] = ARDUINO_BOARD;
#endif

#ifdef USB_MANUFACTURER
char mychar2[] = USB_MANUFACTURER;
#endif
#ifdef USB_PRODUCT
char mychar3[] = USB_PRODUCT;
#endif
#ifdef ARDUINO_HOST_OS
char mychar4[] = ARDUINO_HOST_OS;
#endif
#ifdef ARDUINO_VARIANT
char mychar5[] = ARDUINO_VARIANT;
#endif




Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
#include "Arduino.h"

#ifdef ARDUINO_BOARD
char mychar[] = ARDUINO_BOARD;


#endif
#ifdef USB_MANUFACTURER
char mychar2[] = USB_MANUFACTURER;
#endif
#ifdef USB_PRODUCT
char mychar3[] = USB_PRODUCT;
#endif
#ifdef ARDUINO_HOST_OS
char mychar4[] = ARDUINO_HOST_OS;
#endif
#ifdef ARDUINO_VARIANT
char mychar5[] = ARDUINO_VARIANT;
#endif




Expand Down

0 comments on commit 31771cd

Please sign in to comment.