@@ -39,7 +39,7 @@ var dataDir1 = paths.New("testdata", "data_dir_1")
3939var extraHardware = paths .New ("testdata" , "extra_hardware" )
4040
4141func TestFindBoardWithFQBN (t * testing.T ) {
42- pmb := NewBuilder (customHardware , customHardware , nil , customHardware , customHardware , "test" , downloader .GetDefaultConfig ())
42+ pmb := NewBuilder (nil , nil , customHardware , nil , nil , "test" , downloader .GetDefaultConfig ())
4343 pmb .LoadHardwareFromDirectory (customHardware )
4444 pm := pmb .Build ()
4545 pme , release := pm .NewExplorer ()
@@ -55,15 +55,118 @@ func TestFindBoardWithFQBN(t *testing.T) {
5555 require .Equal (t , board .Name (), "Arduino/Genuino Mega or Mega 2560" )
5656}
5757
58+ func TestResolveFQBNWithRefCores (t * testing.T ) {
59+ // Pass nil, since these paths are only used for installing
60+ pmb := NewBuilder (nil , nil , extraHardware , nil , nil , "test" , downloader .GetDefaultConfig ())
61+ // Hardware from main packages directory
62+ pmb .LoadHardwareFromDirectory (dataDir1 .Join ("packages" ))
63+ // This contains the referenced:avr core
64+ pmb .LoadHardwareFromDirectory (extraHardware )
65+ pm := pmb .Build ()
66+ pme , release := pm .NewExplorer ()
67+ defer release ()
68+
69+ t .Run ("BoardAndBuildPropertiesForReferencedArduinoUno" , func (t * testing.T ) {
70+ // Test a board referenced from the main AVR arduino platform
71+ fqbn , err := fqbn .Parse ("referenced:avr:uno" )
72+ require .Nil (t , err )
73+ require .NotNil (t , fqbn )
74+ pkg , platformRelease , board , props , buildPlatformRelease , err := pme .ResolveFQBN (fqbn )
75+ require .Nil (t , err )
76+ require .Equal (t , pkg , platformRelease .Platform .Package )
77+ require .NotNil (t , platformRelease )
78+ require .NotNil (t , platformRelease .Platform )
79+ require .Equal (t , platformRelease .Platform .String (), "referenced:avr" )
80+ require .NotNil (t , board )
81+ require .Equal (t , board .Name (), "Referenced Uno" )
82+ require .NotNil (t , props )
83+ require .NotNil (t , buildPlatformRelease )
84+ require .NotNil (t , buildPlatformRelease .Platform )
85+ require .Equal (t , buildPlatformRelease .Platform .String (), "arduino:avr" )
86+ })
87+
88+ t .Run ("BoardAndBuildPropertiesForReferencedFeatherM0" , func (t * testing.T ) {
89+ // Test a board referenced from the Adafruit SAMD core (this tests
90+ // deriving where the package and core name are different)
91+ fqbn , err := fqbn .Parse ("referenced:samd:feather_m0" )
92+ require .Nil (t , err )
93+ require .NotNil (t , fqbn )
94+ pkg , platformRelease , board , props , buildPlatformRelease , err := pme .ResolveFQBN (fqbn )
95+ require .Nil (t , err )
96+ require .Equal (t , pkg , platformRelease .Platform .Package )
97+ require .NotNil (t , platformRelease )
98+ require .NotNil (t , platformRelease .Platform )
99+ require .Equal (t , platformRelease .Platform .String (), "referenced:samd" )
100+ require .NotNil (t , board )
101+ require .Equal (t , board .Name (), "Referenced Feather M0" )
102+ require .NotNil (t , props )
103+ require .NotNil (t , buildPlatformRelease )
104+ require .NotNil (t , buildPlatformRelease .Platform )
105+ require .Equal (t , buildPlatformRelease .Platform .String (), "adafruit:samd" )
106+ })
107+
108+ t .Run ("BoardAndBuildPropertiesForNonExistentPackage" , func (t * testing.T ) {
109+ // Test a board referenced from a non-existent package
110+ fqbn , err := fqbn .Parse ("referenced:avr:dummy_invalid_package" )
111+ require .Nil (t , err )
112+ require .NotNil (t , fqbn )
113+ pkg , platformRelease , board , props , buildPlatformRelease , err := pme .ResolveFQBN (fqbn )
114+ require .NotNil (t , err )
115+ require .Equal (t , pkg , platformRelease .Platform .Package )
116+ require .NotNil (t , platformRelease )
117+ require .NotNil (t , platformRelease .Platform )
118+ require .Equal (t , platformRelease .Platform .String (), "referenced:avr" )
119+ require .NotNil (t , board )
120+ require .Equal (t , board .Name (), "Referenced dummy with invalid package" )
121+ require .Nil (t , props )
122+ require .Nil (t , buildPlatformRelease )
123+ })
124+
125+ t .Run ("BoardAndBuildPropertiesForNonExistentArchitecture" , func (t * testing.T ) {
126+ // Test a board referenced from a non-existent platform/architecture
127+ fqbn , err := fqbn .Parse ("referenced:avr:dummy_invalid_platform" )
128+ require .Nil (t , err )
129+ require .NotNil (t , fqbn )
130+ pkg , platformRelease , board , props , buildPlatformRelease , err := pme .ResolveFQBN (fqbn )
131+ require .NotNil (t , err )
132+ require .Equal (t , pkg , platformRelease .Platform .Package )
133+ require .NotNil (t , platformRelease )
134+ require .NotNil (t , platformRelease .Platform )
135+ require .Equal (t , platformRelease .Platform .String (), "referenced:avr" )
136+ require .NotNil (t , board )
137+ require .Equal (t , board .Name (), "Referenced dummy with invalid platform" )
138+ require .Nil (t , props )
139+ require .Nil (t , buildPlatformRelease )
140+ })
141+
142+ t .Run ("BoardAndBuildPropertiesForNonExistentCore" , func (t * testing.T ) {
143+ // Test a board referenced from a non-existent core
144+ // Note that ResolveFQBN does not actually check this currently
145+ fqbn , err := fqbn .Parse ("referenced:avr:dummy_invalid_core" )
146+ require .Nil (t , err )
147+ require .NotNil (t , fqbn )
148+ pkg , platformRelease , board , props , buildPlatformRelease , err := pme .ResolveFQBN (fqbn )
149+ require .Nil (t , err )
150+ require .Equal (t , pkg , platformRelease .Platform .Package )
151+ require .NotNil (t , platformRelease )
152+ require .NotNil (t , platformRelease .Platform )
153+ require .Equal (t , platformRelease .Platform .String (), "referenced:avr" )
154+ require .NotNil (t , board )
155+ require .Equal (t , board .Name (), "Referenced dummy with invalid core" )
156+ require .NotNil (t , props )
157+ require .NotNil (t , buildPlatformRelease )
158+ require .NotNil (t , buildPlatformRelease .Platform )
159+ require .Equal (t , buildPlatformRelease .Platform .String (), "arduino:avr" )
160+ })
161+ }
162+
58163func TestResolveFQBN (t * testing.T ) {
59164 // Pass nil, since these paths are only used for installing
60- pmb := NewBuilder (nil , nil , nil , nil , nil , "test" , downloader .GetDefaultConfig ())
165+ pmb := NewBuilder (nil , nil , customHardware , nil , nil , "test" , downloader .GetDefaultConfig ())
61166 // Hardware from main packages directory
62167 pmb .LoadHardwareFromDirectory (dataDir1 .Join ("packages" ))
63168 // This contains the arduino:avr core
64169 pmb .LoadHardwareFromDirectory (customHardware )
65- // This contains the referenced:avr core
66- pmb .LoadHardwareFromDirectory (extraHardware )
67170 pm := pmb .Build ()
68171 pme , release := pm .NewExplorer ()
69172 defer release ()
@@ -86,8 +189,8 @@ func TestResolveFQBN(t *testing.T) {
86189 testNormalization ("arduino:avr:mega" , "arduino:avr:mega" )
87190 testNormalization ("arduino:avr:mega:cpu=atmega2560" , "arduino:avr:mega" )
88191 testNormalization ("arduino:avr:mega:cpu=atmega1280" , "arduino:avr:mega:cpu=atmega1280" )
89- testNormalization ("esp8266:esp8266:generic:baud=57600,wipe=sdk " , "esp8266:esp8266:generic:baud=57600,wipe=sdk " )
90- testNormalization ("esp8266:esp8266:generic:baud=115200,wipe=sdk " , "esp8266:esp8266:generic:wipe=sdk " )
192+ testNormalization ("esp8266:esp8266:generic:CpuFrequency=80 " , "esp8266:esp8266:generic" )
193+ testNormalization ("esp8266:esp8266:generic:CpuFrequency=160 " , "esp8266:esp8266:generic:CpuFrequency=160 " )
91194 testNormalization ("arduino:avr:mega:cpu=nonexistent" , "ERROR" )
92195 testNormalization ("arduino:avr:mega:nonexistent=blah" , "ERROR" )
93196 })
@@ -103,7 +206,7 @@ func TestResolveFQBN(t *testing.T) {
103206 require .NotNil (t , platformRelease .Platform )
104207 require .Equal (t , platformRelease .Platform .String (), "arduino:avr" )
105208 require .NotNil (t , board )
106- require .Equal (t , board .Name (), "Arduino Uno" )
209+ require .Equal (t , board .Name (), "Arduino/Genuino Uno" )
107210 require .NotNil (t , props )
108211 require .Equal (t , platformRelease , buildPlatformRelease )
109212
@@ -124,7 +227,7 @@ func TestResolveFQBN(t *testing.T) {
124227 require .NotNil (t , platformRelease .Platform )
125228 require .Equal (t , platformRelease .Platform .String (), "arduino:avr" )
126229 require .NotNil (t , board )
127- require .Equal (t , board .Name (), "Arduino Mega or Mega 2560" )
230+ require .Equal (t , board .Name (), "Arduino/Genuino Mega or Mega 2560" )
128231 require .NotNil (t , props )
129232 require .Equal (t , platformRelease , buildPlatformRelease )
130233 })
@@ -166,25 +269,6 @@ func TestResolveFQBN(t *testing.T) {
166269
167270 })
168271
169- t .Run ("BoardAndBuildPropertiesForReferencedArduinoUno" , func (t * testing.T ) {
170- // Test a board referenced from the main AVR arduino platform
171- fqbn , err := fqbn .Parse ("referenced:avr:uno" )
172- require .Nil (t , err )
173- require .NotNil (t , fqbn )
174- pkg , platformRelease , board , props , buildPlatformRelease , err := pme .ResolveFQBN (fqbn )
175- require .Nil (t , err )
176- require .Equal (t , pkg , platformRelease .Platform .Package )
177- require .NotNil (t , platformRelease )
178- require .NotNil (t , platformRelease .Platform )
179- require .Equal (t , platformRelease .Platform .String (), "referenced:avr" )
180- require .NotNil (t , board )
181- require .Equal (t , board .Name (), "Referenced Uno" )
182- require .NotNil (t , props )
183- require .NotNil (t , buildPlatformRelease )
184- require .NotNil (t , buildPlatformRelease .Platform )
185- require .Equal (t , buildPlatformRelease .Platform .String (), "arduino:avr" )
186- })
187-
188272 t .Run ("BoardAndBuildPropertiesForArduinoDue" , func (t * testing.T ) {
189273 fqbn , err := fqbn .Parse ("arduino:sam:arduino_due_x" )
190274 require .Nil (t , err )
@@ -232,80 +316,6 @@ func TestResolveFQBN(t *testing.T) {
232316 require .Equal (t , "tiny14" , props .Get ("build.variant" ))
233317 })
234318
235- t .Run ("BoardAndBuildPropertiesForReferencedFeatherM0" , func (t * testing.T ) {
236- // Test a board referenced from the Adafruit SAMD core (this tests
237- // deriving where the package and core name are different)
238- fqbn , err := fqbn .Parse ("referenced:samd:feather_m0" )
239- require .Nil (t , err )
240- require .NotNil (t , fqbn )
241- pkg , platformRelease , board , props , buildPlatformRelease , err := pme .ResolveFQBN (fqbn )
242- require .Nil (t , err )
243- require .Equal (t , pkg , platformRelease .Platform .Package )
244- require .NotNil (t , platformRelease )
245- require .NotNil (t , platformRelease .Platform )
246- require .Equal (t , platformRelease .Platform .String (), "referenced:samd" )
247- require .NotNil (t , board )
248- require .Equal (t , board .Name (), "Referenced Feather M0" )
249- require .NotNil (t , props )
250- require .NotNil (t , buildPlatformRelease )
251- require .NotNil (t , buildPlatformRelease .Platform )
252- require .Equal (t , buildPlatformRelease .Platform .String (), "adafruit:samd" )
253- })
254-
255- t .Run ("BoardAndBuildPropertiesForNonExistentPackage" , func (t * testing.T ) {
256- // Test a board referenced from a non-existent package
257- fqbn , err := fqbn .Parse ("referenced:avr:dummy_invalid_package" )
258- require .Nil (t , err )
259- require .NotNil (t , fqbn )
260- pkg , platformRelease , board , props , buildPlatformRelease , err := pme .ResolveFQBN (fqbn )
261- require .NotNil (t , err )
262- require .Equal (t , pkg , platformRelease .Platform .Package )
263- require .NotNil (t , platformRelease )
264- require .NotNil (t , platformRelease .Platform )
265- require .Equal (t , platformRelease .Platform .String (), "referenced:avr" )
266- require .NotNil (t , board )
267- require .Equal (t , board .Name (), "Referenced dummy with invalid package" )
268- require .Nil (t , props )
269- require .Nil (t , buildPlatformRelease )
270- })
271-
272- t .Run ("BoardAndBuildPropertiesForNonExistentArchitecture" , func (t * testing.T ) {
273- // Test a board referenced from a non-existent platform/architecture
274- fqbn , err := fqbn .Parse ("referenced:avr:dummy_invalid_platform" )
275- require .Nil (t , err )
276- require .NotNil (t , fqbn )
277- pkg , platformRelease , board , props , buildPlatformRelease , err := pme .ResolveFQBN (fqbn )
278- require .NotNil (t , err )
279- require .Equal (t , pkg , platformRelease .Platform .Package )
280- require .NotNil (t , platformRelease )
281- require .NotNil (t , platformRelease .Platform )
282- require .Equal (t , platformRelease .Platform .String (), "referenced:avr" )
283- require .NotNil (t , board )
284- require .Equal (t , board .Name (), "Referenced dummy with invalid platform" )
285- require .Nil (t , props )
286- require .Nil (t , buildPlatformRelease )
287- })
288-
289- t .Run ("BoardAndBuildPropertiesForNonExistentCore" , func (t * testing.T ) {
290- // Test a board referenced from a non-existent core
291- // Note that ResolveFQBN does not actually check this currently
292- fqbn , err := fqbn .Parse ("referenced:avr:dummy_invalid_core" )
293- require .Nil (t , err )
294- require .NotNil (t , fqbn )
295- pkg , platformRelease , board , props , buildPlatformRelease , err := pme .ResolveFQBN (fqbn )
296- require .Nil (t , err )
297- require .Equal (t , pkg , platformRelease .Platform .Package )
298- require .NotNil (t , platformRelease )
299- require .NotNil (t , platformRelease .Platform )
300- require .Equal (t , platformRelease .Platform .String (), "referenced:avr" )
301- require .NotNil (t , board )
302- require .Equal (t , board .Name (), "Referenced dummy with invalid core" )
303- require .NotNil (t , props )
304- require .NotNil (t , buildPlatformRelease )
305- require .NotNil (t , buildPlatformRelease .Platform )
306- require .Equal (t , buildPlatformRelease .Platform .String (), "arduino:avr" )
307- })
308-
309319 t .Run ("AddBuildBoardPropertyIfMissing" , func (t * testing.T ) {
310320 fqbn , err := fqbn .Parse ("my_avr_platform:avr:mymega" )
311321 require .Nil (t , err )
@@ -342,7 +352,7 @@ func TestResolveFQBN(t *testing.T) {
342352}
343353
344354func TestBoardOptionsFunctions (t * testing.T ) {
345- pmb := NewBuilder (customHardware , customHardware , nil , customHardware , customHardware , "test" , downloader .GetDefaultConfig ())
355+ pmb := NewBuilder (nil , nil , customHardware , nil , nil , "test" , downloader .GetDefaultConfig ())
346356 pmb .LoadHardwareFromDirectory (customHardware )
347357 pm := pmb .Build ()
348358 pme , release := pm .NewExplorer ()
@@ -615,7 +625,7 @@ func TestIndexMerger(t *testing.T) {
615625}
616626
617627func TestIdentifyBoard (t * testing.T ) {
618- pmb := NewBuilder (customHardware , customHardware , nil , customHardware , customHardware , "test" , downloader .GetDefaultConfig ())
628+ pmb := NewBuilder (nil , nil , customHardware , nil , nil , "test" , downloader .GetDefaultConfig ())
619629 pmb .LoadHardwareFromDirectory (customHardware )
620630 pm := pmb .Build ()
621631 pme , release := pm .NewExplorer ()
@@ -642,12 +652,12 @@ func TestIdentifyBoard(t *testing.T) {
642652
643653func TestPackageManagerClear (t * testing.T ) {
644654 // Create a PackageManager and load the harware
645- pmb := NewBuilder (customHardware , customHardware , nil , customHardware , customHardware , "test" , downloader .GetDefaultConfig ())
655+ pmb := NewBuilder (nil , nil , customHardware , nil , nil , "test" , downloader .GetDefaultConfig ())
646656 pmb .LoadHardwareFromDirectory (customHardware )
647657 pm := pmb .Build ()
648658
649659 // Creates another PackageManager but don't load the hardware
650- emptyPmb := NewBuilder (customHardware , customHardware , nil , customHardware , customHardware , "test" , downloader .GetDefaultConfig ())
660+ emptyPmb := NewBuilder (nil , nil , customHardware , nil , nil , "test" , downloader .GetDefaultConfig ())
651661 emptyPm := emptyPmb .Build ()
652662
653663 // Verifies they're not equal
0 commit comments