@@ -54,7 +54,7 @@ func TestIncludesFinderWithGCC(t *testing.T) {
54
54
context [constants .CTX_FQBN ] = "arduino:avr:leonardo"
55
55
context [constants .CTX_SKETCH_LOCATION ] = filepath .Join ("sketch2" , "SketchWithIfDef.ino" )
56
56
context [constants .CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION ] = "10600"
57
- context [constants .CTX_VERBOSE ] = false
57
+ context [constants .CTX_VERBOSE ] = true
58
58
59
59
commands := []types.Command {
60
60
& builder.SetupHumanLoggerIfMissing {},
@@ -71,12 +71,7 @@ func TestIncludesFinderWithGCC(t *testing.T) {
71
71
NoError (t , err )
72
72
}
73
73
74
- require .NotNil (t , context [constants .CTX_INCLUDES ])
75
- includes := context [constants .CTX_INCLUDES ].([]string )
76
- require .Equal (t , 2 , len (includes ))
77
- sort .Strings (includes )
78
- require .Equal (t , filepath .Join (buildPath , constants .FOLDER_SKETCH , "empty_1.h" ), includes [0 ])
79
- require .Equal (t , filepath .Join (buildPath , constants .FOLDER_SKETCH , "empty_2.h" ), includes [1 ])
74
+ require .Nil (t , context [constants .CTX_INCLUDES ])
80
75
}
81
76
82
77
func TestIncludesFinderWithGCCSketchWithConfig (t * testing.T ) {
@@ -94,7 +89,7 @@ func TestIncludesFinderWithGCCSketchWithConfig(t *testing.T) {
94
89
context [constants .CTX_FQBN ] = "arduino:avr:leonardo"
95
90
context [constants .CTX_SKETCH_LOCATION ] = filepath .Join ("sketch_with_config" , "sketch_with_config.ino" )
96
91
context [constants .CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION ] = "10600"
97
- context [constants .CTX_VERBOSE ] = false
92
+ context [constants .CTX_VERBOSE ] = true
98
93
99
94
commands := []types.Command {
100
95
& builder.SetupHumanLoggerIfMissing {},
@@ -113,8 +108,7 @@ func TestIncludesFinderWithGCCSketchWithConfig(t *testing.T) {
113
108
114
109
require .NotNil (t , context [constants .CTX_INCLUDES ])
115
110
includes := context [constants .CTX_INCLUDES ].([]string )
116
- require .True (t , utils .SliceContains (includes , filepath .Join (buildPath , constants .FOLDER_SKETCH , "config.h" )))
117
- require .True (t , utils .SliceContains (includes , filepath .Join (buildPath , constants .FOLDER_SKETCH , "includes" )+ "/de bug.h" ))
111
+ require .Equal (t , 1 , len (includes ))
118
112
require .True (t , utils .SliceContains (includes , "Bridge.h" ))
119
113
120
114
importedLibraries := context [constants .CTX_IMPORTED_LIBRARIES ].([]* types.Library )
@@ -136,7 +130,7 @@ func TestIncludesFinderWithGCCSketchWithDependendLibraries(t *testing.T) {
136
130
context [constants .CTX_FQBN ] = "arduino:avr:leonardo"
137
131
context [constants .CTX_SKETCH_LOCATION ] = filepath .Join ("sketch_with_dependend_libraries" , "sketch.ino" )
138
132
context [constants .CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION ] = "10600"
139
- context [constants .CTX_VERBOSE ] = false
133
+ context [constants .CTX_VERBOSE ] = true
140
134
141
135
commands := []types.Command {
142
136
& builder.SetupHumanLoggerIfMissing {},
@@ -155,16 +149,13 @@ func TestIncludesFinderWithGCCSketchWithDependendLibraries(t *testing.T) {
155
149
156
150
require .NotNil (t , context [constants .CTX_INCLUDES ])
157
151
includes := context [constants .CTX_INCLUDES ].([]string )
158
- require .Equal (t , 7 , len (includes ))
152
+ require .Equal (t , 4 , len (includes ))
159
153
160
154
sort .Strings (includes )
161
- require .Equal (t , Abs (t , filepath .Join ("dependent_libraries" , "library1" ))+ "/library1.h" , includes [0 ])
162
- require .Equal (t , Abs (t , filepath .Join ("dependent_libraries" , "library2" ))+ "/library2.h" , includes [1 ])
163
- require .Equal (t , Abs (t , filepath .Join ("dependent_libraries" , "library3" ))+ "/library3.h" , includes [2 ])
164
- require .Equal (t , "library1.h" , includes [3 ])
165
- require .Equal (t , "library2.h" , includes [4 ])
166
- require .Equal (t , "library3.h" , includes [5 ])
167
- require .Equal (t , "library4.h" , includes [6 ])
155
+ require .Equal (t , "library1.h" , includes [0 ])
156
+ require .Equal (t , "library2.h" , includes [1 ])
157
+ require .Equal (t , "library3.h" , includes [2 ])
158
+ require .Equal (t , "library4.h" , includes [3 ])
168
159
169
160
importedLibraries := context [constants .CTX_IMPORTED_LIBRARIES ].([]* types.Library )
170
161
require .Equal (t , 4 , len (importedLibraries ))
@@ -175,3 +166,91 @@ func TestIncludesFinderWithGCCSketchWithDependendLibraries(t *testing.T) {
175
166
require .Equal (t , "library3" , importedLibraries [2 ].Name )
176
167
require .Equal (t , "library4" , importedLibraries [3 ].Name )
177
168
}
169
+
170
+ func TestIncludesFinderWithGCCSketchWithThatChecksIfSPIHasTransactions (t * testing.T ) {
171
+ DownloadCoresAndToolsAndLibraries (t )
172
+
173
+ context := make (map [string ]interface {})
174
+
175
+ buildPath := SetupBuildPath (t , context )
176
+ defer os .RemoveAll (buildPath )
177
+
178
+ context [constants .CTX_HARDWARE_FOLDERS ] = []string {filepath .Join (".." , "hardware" ), "hardware" , "downloaded_hardware" }
179
+ context [constants .CTX_TOOLS_FOLDERS ] = []string {"downloaded_tools" }
180
+ context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
181
+ context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"dependent_libraries" , "libraries" }
182
+ context [constants .CTX_FQBN ] = "arduino:avr:leonardo"
183
+ context [constants .CTX_SKETCH_LOCATION ] = filepath .Join ("sketch_that_checks_if_SPI_has_transactions" , "sketch.ino" )
184
+ context [constants .CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION ] = "10600"
185
+ context [constants .CTX_VERBOSE ] = true
186
+
187
+ commands := []types.Command {
188
+ & builder.SetupHumanLoggerIfMissing {},
189
+
190
+ & builder.ContainerSetupHardwareToolsLibsSketchAndProps {},
191
+
192
+ & builder.ContainerMergeCopySketchFiles {},
193
+
194
+ & builder.ContainerFindIncludes {},
195
+ }
196
+
197
+ for _ , command := range commands {
198
+ err := command .Run (context )
199
+ NoError (t , err )
200
+ }
201
+
202
+ require .NotNil (t , context [constants .CTX_INCLUDES ])
203
+ includes := context [constants .CTX_INCLUDES ].([]string )
204
+ require .Equal (t , 1 , len (includes ))
205
+ require .Equal (t , "SPI.h" , includes [0 ])
206
+
207
+ importedLibraries := context [constants .CTX_IMPORTED_LIBRARIES ].([]* types.Library )
208
+ require .Equal (t , 1 , len (importedLibraries ))
209
+ require .Equal (t , "SPI" , importedLibraries [0 ].Name )
210
+ }
211
+
212
+ func TestIncludesFinderWithGCCSketchWithThatChecksIfSPIHasTransactionsAndIncludesMissingEthernet (t * testing.T ) {
213
+ DownloadCoresAndToolsAndLibraries (t )
214
+
215
+ context := make (map [string ]interface {})
216
+
217
+ buildPath := SetupBuildPath (t , context )
218
+ defer os .RemoveAll (buildPath )
219
+
220
+ context [constants .CTX_HARDWARE_FOLDERS ] = []string {filepath .Join (".." , "hardware" ), "hardware" , "downloaded_hardware" }
221
+ context [constants .CTX_TOOLS_FOLDERS ] = []string {"downloaded_tools" }
222
+ context [constants .CTX_BUILT_IN_LIBRARIES_FOLDERS ] = []string {"downloaded_libraries" }
223
+ context [constants .CTX_OTHER_LIBRARIES_FOLDERS ] = []string {"dependent_libraries" , "libraries" }
224
+ context [constants .CTX_FQBN ] = "arduino:avr:leonardo"
225
+ context [constants .CTX_SKETCH_LOCATION ] = filepath .Join ("sketch_that_checks_if_SPI_has_transactions_and_includes_missing_Ethernet" , "sketch.ino" )
226
+ context [constants .CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION ] = "10600"
227
+ context [constants .CTX_VERBOSE ] = true
228
+
229
+ commands := []types.Command {
230
+ & builder.SetupHumanLoggerIfMissing {},
231
+
232
+ & builder.ContainerSetupHardwareToolsLibsSketchAndProps {},
233
+
234
+ & builder.ContainerMergeCopySketchFiles {},
235
+ }
236
+
237
+ for _ , command := range commands {
238
+ err := command .Run (context )
239
+ NoError (t , err )
240
+ }
241
+
242
+ command := & builder.ContainerFindIncludes {}
243
+ err := command .Run (context )
244
+ require .Error (t , err )
245
+
246
+ require .NotNil (t , context [constants .CTX_INCLUDES ])
247
+ includes := context [constants .CTX_INCLUDES ].([]string )
248
+ require .Equal (t , 2 , len (includes ))
249
+ sort .Strings (includes )
250
+ require .Equal (t , "Ethernet.h" , includes [0 ])
251
+ require .Equal (t , "SPI.h" , includes [1 ])
252
+
253
+ importedLibraries := context [constants .CTX_IMPORTED_LIBRARIES ].([]* types.Library )
254
+ require .Equal (t , 1 , len (importedLibraries ))
255
+ require .Equal (t , "SPI" , importedLibraries [0 ].Name )
256
+ }