Skip to content

Commit a374580

Browse files
author
jan
committed
Add regression test for #1126
1 parent b04fa62 commit a374580

File tree

2 files changed

+59
-9
lines changed

2 files changed

+59
-9
lines changed

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

+6-4
Original file line numberDiff line numberDiff line change
@@ -185,28 +185,30 @@ public static void convertToArduinoProject(IProject project, IProgressMonitor mo
185185
public static IProject createArduinoProject(String projectName, URI projectURI, BoardDescription boardDescriptor,
186186
CodeDescription codeDesc, CompileDescription compileDescriptor, IProgressMonitor monitor) {
187187
return createArduinoProject(projectName, projectURI, boardDescriptor, codeDesc, compileDescriptor,
188-
new OtherDescription(),AutoBuildProject.INTERNAL_BUILDER_ID, monitor);
188+
null,null, monitor);
189189
}
190190

191191
public static IProject createArduinoProject(String projectName, URI projectURI, BoardDescription boardDescriptor,
192192
CodeDescription codeDesc, CompileDescription compileDescriptor,String builderName,
193193
IProgressMonitor monitor) {
194194
return createArduinoProject(projectName, projectURI, boardDescriptor, codeDesc, compileDescriptor,
195-
new OtherDescription(),builderName, monitor);
195+
null,builderName, monitor);
196196
}
197197
public static IProject createArduinoProject(String projectName, URI projectURI, BoardDescription boardDescriptor,
198198
CodeDescription codeDesc, CompileDescription compileDescriptor, OtherDescription otherDesc,
199199
IProgressMonitor monitor) {
200200
return createArduinoProject(projectName, projectURI, boardDescriptor, codeDesc, compileDescriptor,
201-
otherDesc,AutoBuildProject.INTERNAL_BUILDER_ID, monitor);
201+
otherDesc,null, monitor);
202202
}
203203

204204
/*
205205
* Method to create a project based on the board
206206
*/
207207
public static IProject createArduinoProject(String projectName, URI projectURI, BoardDescription boardDescriptor,
208-
CodeDescription codeDesc, CompileDescription compileDescriptor, OtherDescription otherDesc,String builderName,
208+
CodeDescription codeDesc, CompileDescription compileDescriptor, OtherDescription inOtherDesc,String inBuilderName,
209209
IProgressMonitor monitor) {
210+
OtherDescription otherDesc=inOtherDesc==null?new OtherDescription():inOtherDesc;
211+
String builderName=inBuilderName==null?AutoBuildProject.INTERNAL_BUILDER_ID:inBuilderName;
210212

211213
String realProjectName = makeNameCompileSafe(projectName);
212214

io.sloeber.tests/src/io/sloeber/core/RegressionTest.java

+53-5
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@
3232
import org.junit.jupiter.params.provider.Arguments;
3333
import org.junit.jupiter.params.provider.MethodSource;
3434

35+
import io.sloeber.autoBuild.api.IAutoBuildConfigurationDescription;
3536
import io.sloeber.core.api.BoardDescription;
3637
import io.sloeber.core.api.BoardsManager;
3738
import io.sloeber.core.api.CodeDescription;
3839
import io.sloeber.core.api.CompileDescription;
3940
import io.sloeber.core.api.IExample;
4041
import io.sloeber.core.api.CompileDescription.SizeCommands;
4142
import io.sloeber.core.api.CompileDescription.WarningLevels;
43+
import io.sloeber.core.api.IArduinoLibraryVersion;
4244
import io.sloeber.core.api.ISloeberConfiguration;
4345
import io.sloeber.core.api.LibraryManager;
4446
import io.sloeber.core.api.OtherDescription;
@@ -54,6 +56,7 @@
5456
public class RegressionTest {
5557
private static final boolean reinstall_boards_and_libraries = false;
5658
private final static String AUTOBUILD_CFG = ".autoBuildProject";
59+
private static final String HIDlibName = "HID-Project";
5760

5861
/*
5962
* In new new installations (of the Sloeber development environment) the
@@ -63,9 +66,15 @@ public class RegressionTest {
6366
@BeforeClass
6467
public static void beforeClass() throws Exception {
6568
Shared.waitForBoardsManager();
66-
Shared.setDeleteProjects(false);
69+
Shared.setDeleteProjects(true);
6770
Preferences.setUseBonjour(false);
6871
installAdditionalBoards();
72+
installAdditionalLibs();
73+
}
74+
75+
private static void installAdditionalLibs() {
76+
LibraryManager.installLibrary(HIDlibName);
77+
6978
}
7079

7180
public static void installAdditionalBoards() throws Exception {
@@ -514,12 +523,13 @@ public void createProjectWithURI() throws Exception {
514523
IPath projectFolder = workspace.getRoot().getLocation().removeLastSegments(1).append(codeFolderName);
515524
URI uri = projectFolder.toFile().toURI();
516525
// workspace.getRoot().getFolder(Path.fromOSString(codeFolderName)).getLocationURI();
517-
IProject theTestProject = SloeberProject.createArduinoProject(proj1Name, uri, proj1BoardDesc, codeDesc, proj1CompileDesc,
518-
otherDesc, new NullProgressMonitor());
526+
IProject theTestProject = SloeberProject.createArduinoProject(proj1Name, uri, proj1BoardDesc, codeDesc,
527+
proj1CompileDesc, otherDesc, new NullProgressMonitor());
519528

520529
Shared.waitForIndexer(theTestProject);
521530
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, null);
522-
Assert.assertNull("Failed to compile the project: " + Shared.hasBuildErrors(theTestProject), Shared.hasBuildErrors(theTestProject));
531+
Assert.assertNull("Failed to compile the project: " + Shared.hasBuildErrors(theTestProject),
532+
Shared.hasBuildErrors(theTestProject));
523533
String fileLocation = projectFolder.append("src").append(proj1Name + ".cpp").toString();
524534

525535
IFile cppFile = theTestProject.getFolder("src").getFile(proj1Name + ".cpp");
@@ -602,7 +612,6 @@ public void testDifferentSourceFolders(String projectName, CodeDescription codeD
602612
IProject theTestProject = SloeberProject.createArduinoProject(projectName, null, proj1BoardDesc, codeDescriptor,
603613
proj1CompileDesc, otherDesc, new NullProgressMonitor());
604614

605-
606615
Shared.waitForIndexer(theTestProject);
607616
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, null);
608617
assertNull("Failed to compile " + projectName, Shared.hasBuildErrors(theTestProject));
@@ -640,6 +649,45 @@ public void redirectedJson() throws Exception {
640649
new CompileDescription()));
641650
}
642651

652+
@Test
653+
public void issue1126LibArchiver() throws Exception {
654+
655+
656+
MCUBoard leonardoBoard = Arduino.leonardo();
657+
Map<String, IExample> examples = LibraryManager.getExamplesAll(null);
658+
CompileDescription compileDesc = new CompileDescription();
659+
compileDesc.setEnableParallelBuild(true);
660+
IArduinoLibraryVersion lib = null;
661+
IExample example = null;
662+
for (IExample curExample : examples.values()) {
663+
IArduinoLibraryVersion curLib = curExample.getArduinoLibrary();
664+
if (curLib == null) {
665+
continue;
666+
}
667+
if (curLib.getName().equals(HIDlibName)) {
668+
example = curExample;
669+
lib=curLib;
670+
break;
671+
}
672+
}
673+
assertNotNull("HID Lib \"" + HIDlibName + "\" Not found", lib);
674+
675+
Set<IExample> testExamples = new HashSet<>();
676+
testExamples.add(example);
677+
CodeDescription codeDescriptor = CodeDescription.createExample(false, testExamples);
678+
NullProgressMonitor monitor = new NullProgressMonitor();
679+
680+
IProject theTestProject = SloeberProject.createArduinoProject("issue1126LibArchiver", null,
681+
leonardoBoard.getBoardDescriptor(), codeDescriptor, compileDesc, null, null, monitor);
682+
Shared.waitForIndexer(theTestProject);
683+
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
684+
IAutoBuildConfigurationDescription autoDesc = IAutoBuildConfigurationDescription.getActiveConfig(theTestProject,
685+
false);
686+
IFile libArchive = autoDesc.getBuildFolder().getFile(HIDlibName + ".ar");
687+
assertTrue("Archive " + libArchive.toString() + " does not exists", libArchive.exists());
688+
689+
}
690+
643691
static Stream<Arguments> openAndClosePreservesSettingsValueCmd() throws Exception {
644692
beforeClass();// This is not always called
645693
CodeDescription codeDescriptordefaultCPPRoot = new CodeDescription(CodeDescription.CodeTypes.defaultCPP);

0 commit comments

Comments
 (0)