32
32
import org .junit .jupiter .params .provider .Arguments ;
33
33
import org .junit .jupiter .params .provider .MethodSource ;
34
34
35
+ import io .sloeber .autoBuild .api .IAutoBuildConfigurationDescription ;
35
36
import io .sloeber .core .api .BoardDescription ;
36
37
import io .sloeber .core .api .BoardsManager ;
37
38
import io .sloeber .core .api .CodeDescription ;
38
39
import io .sloeber .core .api .CompileDescription ;
39
40
import io .sloeber .core .api .IExample ;
40
41
import io .sloeber .core .api .CompileDescription .SizeCommands ;
41
42
import io .sloeber .core .api .CompileDescription .WarningLevels ;
43
+ import io .sloeber .core .api .IArduinoLibraryVersion ;
42
44
import io .sloeber .core .api .ISloeberConfiguration ;
43
45
import io .sloeber .core .api .LibraryManager ;
44
46
import io .sloeber .core .api .OtherDescription ;
54
56
public class RegressionTest {
55
57
private static final boolean reinstall_boards_and_libraries = false ;
56
58
private final static String AUTOBUILD_CFG = ".autoBuildProject" ;
59
+ private static final String HIDlibName = "HID-Project" ;
57
60
58
61
/*
59
62
* In new new installations (of the Sloeber development environment) the
@@ -63,9 +66,15 @@ public class RegressionTest {
63
66
@ BeforeClass
64
67
public static void beforeClass () throws Exception {
65
68
Shared .waitForBoardsManager ();
66
- Shared .setDeleteProjects (false );
69
+ Shared .setDeleteProjects (true );
67
70
Preferences .setUseBonjour (false );
68
71
installAdditionalBoards ();
72
+ installAdditionalLibs ();
73
+ }
74
+
75
+ private static void installAdditionalLibs () {
76
+ LibraryManager .installLibrary (HIDlibName );
77
+
69
78
}
70
79
71
80
public static void installAdditionalBoards () throws Exception {
@@ -514,12 +523,13 @@ public void createProjectWithURI() throws Exception {
514
523
IPath projectFolder = workspace .getRoot ().getLocation ().removeLastSegments (1 ).append (codeFolderName );
515
524
URI uri = projectFolder .toFile ().toURI ();
516
525
// 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 ());
519
528
520
529
Shared .waitForIndexer (theTestProject );
521
530
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 ));
523
533
String fileLocation = projectFolder .append ("src" ).append (proj1Name + ".cpp" ).toString ();
524
534
525
535
IFile cppFile = theTestProject .getFolder ("src" ).getFile (proj1Name + ".cpp" );
@@ -602,7 +612,6 @@ public void testDifferentSourceFolders(String projectName, CodeDescription codeD
602
612
IProject theTestProject = SloeberProject .createArduinoProject (projectName , null , proj1BoardDesc , codeDescriptor ,
603
613
proj1CompileDesc , otherDesc , new NullProgressMonitor ());
604
614
605
-
606
615
Shared .waitForIndexer (theTestProject );
607
616
theTestProject .build (IncrementalProjectBuilder .FULL_BUILD , null );
608
617
assertNull ("Failed to compile " + projectName , Shared .hasBuildErrors (theTestProject ));
@@ -640,6 +649,45 @@ public void redirectedJson() throws Exception {
640
649
new CompileDescription ()));
641
650
}
642
651
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
+
643
691
static Stream <Arguments > openAndClosePreservesSettingsValueCmd () throws Exception {
644
692
beforeClass ();// This is not always called
645
693
CodeDescription codeDescriptordefaultCPPRoot = new CodeDescription (CodeDescription .CodeTypes .defaultCPP );
0 commit comments