@@ -36,6 +36,7 @@ import (
36
36
"github.com/stretchr/testify/require"
37
37
"os"
38
38
"path/filepath"
39
+ "sort"
39
40
"testing"
40
41
)
41
42
@@ -61,8 +62,7 @@ func TestIncludesFinderWithGCC(t *testing.T) {
61
62
62
63
& builder.ContainerMergeCopySketchFiles {},
63
64
64
- & builder.IncludesFinderWithGCC {},
65
- & builder.GCCMinusMOutputParser {},
65
+ & builder.ContainerFindIncludes {},
66
66
}
67
67
68
68
for _ , command := range commands {
@@ -73,6 +73,7 @@ func TestIncludesFinderWithGCC(t *testing.T) {
73
73
require .NotNil (t , context [constants .CTX_INCLUDES ])
74
74
includes := context [constants .CTX_INCLUDES ].([]string )
75
75
require .Equal (t , 2 , len (includes ))
76
+ sort .Strings (includes )
76
77
require .Equal (t , filepath .Join (buildPath , constants .FOLDER_SKETCH , "empty_1.h" ), includes [0 ])
77
78
require .Equal (t , filepath .Join (buildPath , constants .FOLDER_SKETCH , "empty_2.h" ), includes [1 ])
78
79
}
@@ -115,3 +116,56 @@ func TestIncludesFinderWithGCCSketchWithConfig(t *testing.T) {
115
116
require .Equal (t , filepath .Join (buildPath , constants .FOLDER_SKETCH , "includes" )+ "/de bug.h" , includes [1 ])
116
117
require .Equal (t , "Bridge.h" , includes [2 ])
117
118
}
119
+
120
+ func TestIncludesFinderWithGCCSketchWithDependendLibraries (t * testing.T ) {
121
+ DownloadCoresAndToolsAndLibraries (t )
122
+
123
+ context := make (map [string ]interface {})
124
+
125
+ buildPath := SetupBuildPath (t , context )
126
+ defer os .RemoveAll (buildPath )
127
+
128
+ context [constants .CTX_HARDWARE_FOLDERS ] = []string {filepath .Join (".." , "hardware" ), "hardware" , "downloaded_hardware" }
129
+ context [constants .CTX_TOOLS_FOLDERS ] = []string {"downloaded_tools" }
130
+ context [constants .CTX_LIBRARIES_FOLDERS ] = []string {"dependent_libraries" }
131
+ context [constants .CTX_FQBN ] = "arduino:avr:leonardo"
132
+ context [constants .CTX_SKETCH_LOCATION ] = filepath .Join ("sketch_with_dependend_libraries" , "sketch.ino" )
133
+ context [constants .CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION ] = "10600"
134
+ context [constants .CTX_VERBOSE ] = false
135
+
136
+ commands := []types.Command {
137
+ & builder.SetupHumanLoggerIfMissing {},
138
+
139
+ & builder.ContainerSetupHardwareToolsLibsSketchAndProps {},
140
+
141
+ & builder.ContainerMergeCopySketchFiles {},
142
+
143
+ & builder.ContainerFindIncludes {},
144
+ }
145
+
146
+ for _ , command := range commands {
147
+ err := command .Run (context )
148
+ NoError (t , err )
149
+ }
150
+
151
+ require .NotNil (t , context [constants .CTX_INCLUDES ])
152
+ includes := context [constants .CTX_INCLUDES ].([]string )
153
+ require .Equal (t , 6 , len (includes ))
154
+
155
+ sort .Strings (includes )
156
+ require .Equal (t , Abs (t , filepath .Join ("dependent_libraries" , "library1" , "library1.h" )), includes [0 ])
157
+ require .Equal (t , Abs (t , filepath .Join ("dependent_libraries" , "library2" , "library2.h" )), includes [1 ])
158
+ require .Equal (t , Abs (t , filepath .Join ("dependent_libraries" , "library3" , "library3.h" )), includes [2 ])
159
+ require .Equal (t , "library1.h" , includes [3 ])
160
+ require .Equal (t , "library2.h" , includes [4 ])
161
+ require .Equal (t , "library3.h" , includes [5 ])
162
+
163
+ require .NotNil (t , context [constants .CTX_IMPORTED_LIBRARIES ])
164
+ importedLibraries := context [constants .CTX_IMPORTED_LIBRARIES ].([]* types.Library )
165
+ require .Equal (t , 3 , len (importedLibraries ))
166
+
167
+ sort .Sort (ByLibraryName (importedLibraries ))
168
+ require .Equal (t , "library1" , importedLibraries [0 ].Name )
169
+ require .Equal (t , "library2" , importedLibraries [1 ].Name )
170
+ require .Equal (t , "library3" , importedLibraries [2 ].Name )
171
+ }
0 commit comments