16
16
package board_test
17
17
18
18
import (
19
+ "runtime"
19
20
"testing"
20
21
21
22
"github.com/arduino/arduino-cli/internal/integrationtest"
@@ -40,100 +41,211 @@ func TestHardwareLoading(t *testing.T) {
40
41
localTxt .Join ("boards.local.txt" ).CopyTo (downloadedHardwareAvr .Join ("boards.local.txt" ))
41
42
localTxt .Join ("platform.local.txt" ).CopyTo (downloadedHardwareAvr .Join ("platform.local.txt" ))
42
43
43
- {
44
- out , _ , err := cli .Run ("core" , "list" , "--format" , "json" )
45
- require .NoError (t , err )
46
- jsonOut := requirejson .Parse (t , out )
47
- jsonOut .LengthMustEqualTo (1 )
48
- jsonOut .MustContain (`[
49
- {
50
- "id": "arduino:avr",
51
- "installed": "1.8.6",
52
- "name": "Arduino AVR Boards",
53
- "boards": [
44
+ t .Run ("Simple" , func (t * testing.T ) {
45
+ {
46
+ out , _ , err := cli .Run ("core" , "list" , "--format" , "json" )
47
+ require .NoError (t , err )
48
+ jsonOut := requirejson .Parse (t , out )
49
+ jsonOut .LengthMustEqualTo (1 )
50
+ jsonOut .MustContain (`[
51
+ {
52
+ "id": "arduino:avr",
53
+ "installed": "1.8.6",
54
+ "name": "Arduino AVR Boards",
55
+ "boards": [
56
+ {
57
+ "name": "Arduino Uno",
58
+ "fqbn": "arduino:avr:uno"
59
+ },
60
+ {
61
+ "name": "Arduino Yún",
62
+ "fqbn": "arduino:avr:yun"
63
+ }
64
+ ]
65
+ }
66
+ ]` )
67
+ }
68
+
69
+ {
70
+ // Also test local platform.txt properties override
71
+ out , _ , err := cli .Run ("board" , "details" , "-b" , "arduino:avr:uno" , "--format" , "json" )
72
+ require .NoError (t , err )
73
+ jsonOut := requirejson .Parse (t , out )
74
+ jsonOut .MustContain (`{
75
+ "version": "1.8.6",
76
+ "properties_id": "uno",
77
+ "build_properties": [
78
+ "_id=uno",
79
+ "tools.avrdude.bootloader.params.verbose=-v",
80
+ "tools.avrdude.cmd.path=/my/personal/avrdude"
81
+ ],
82
+ "programmers": [
54
83
{
55
- "name": "Arduino Uno",
56
- "fqbn": "arduino:avr:uno"
84
+ "platform": "Arduino AVR Boards",
85
+ "id": "usbasp",
86
+ "name": "USBasp"
57
87
},
58
88
{
59
- "name": "Arduino Yún",
60
- "fqbn": "arduino:avr:yun"
89
+ "platform": "Arduino AVR Boards",
90
+ "id": "avrispmkii",
91
+ "name": "AVRISP mkII"
61
92
}
93
+ ]
94
+ }` )
95
+ }
96
+
97
+ {
98
+ out , _ , err := cli .Run ("board" , "details" , "-b" , "arduino:avr:yun" , "--format" , "json" )
99
+ require .NoError (t , err )
100
+ jsonOut := requirejson .Parse (t , out )
101
+ jsonOut .MustContain (`{
102
+ "version": "1.8.6",
103
+ "properties_id": "yun",
104
+ "build_properties": [
105
+ "_id=yun",
106
+ "upload.wait_for_upload_port=true"
62
107
]
63
- }
64
- ]` )
65
- }
108
+ }` )
109
+ }
110
+
111
+ {
112
+ // Check un-expansion of board_properties
113
+ out , _ , err := cli .Run ("board" , "details" , "-b" , "arduino:avr:robotMotor" , "--show-properties=unexpanded" , "--format" , "json" )
114
+ require .NoError (t , err )
115
+ jsonOut := requirejson .Parse (t , out )
116
+ jsonOut .MustContain (`{
117
+ "version": "1.8.6",
118
+ "properties_id": "robotMotor",
119
+ "build_properties": [
120
+ "_id=robotMotor",
121
+ "build.extra_flags={build.usb_flags}",
122
+ "upload.wait_for_upload_port=true"
123
+ ]
124
+ }` )
125
+ }
126
+
127
+ {
128
+ // Also test local boards.txt properties override
129
+ out , _ , err := cli .Run ("board" , "details" , "-b" , "arduino:avr:diecimila" , "--show-properties=unexpanded" , "--format" , "json" )
130
+ require .NoError (t , err )
131
+ jsonOut := requirejson .Parse (t , out )
132
+ jsonOut .MustContain (`{
133
+ "version": "1.8.6",
134
+ "properties_id": "diecimila",
135
+ "build_properties": [
136
+ "_id=diecimila",
137
+ "menu.cpu.atmega123=ATmega123"
138
+ ]
139
+ }` )
140
+ }
141
+ })
66
142
67
- {
68
- // Also test local platform.txt properties override
69
- out , _ , err := cli . Run ( "board " , "details " , "-b" , "arduino:avr:uno" , "--format" , "json" )
143
+ t . Run ( "MixingUserHardware" , func ( t * testing. T ) {
144
+ // Install custom hardware required for tests
145
+ customHwDir , err := paths . New ( ".. " , "testdata " , "user_hardware" ). Abs ( )
70
146
require .NoError (t , err )
71
- jsonOut := requirejson .Parse (t , out )
72
- jsonOut .MustContain (`{
73
- "version": "1.8.6",
74
- "properties_id": "uno",
75
- "build_properties": [
76
- "_id=uno",
77
- "tools.avrdude.bootloader.params.verbose=-v",
78
- "tools.avrdude.cmd.path=/my/personal/avrdude"
79
- ],
80
- "programmers": [
147
+ require .NoError (t , customHwDir .CopyDirTo (cli .SketchbookDir ().Join ("hardware" )))
148
+
149
+ {
150
+ out , _ , err := cli .Run ("core" , "list" , "--format" , "json" )
151
+ require .NoError (t , err )
152
+ jsonOut := requirejson .Parse (t , out )
153
+ if runtime .GOOS == "windows" {
154
+ //a package is a symlink, and windows does not support them
155
+ jsonOut .LengthMustEqualTo (2 )
156
+ } else {
157
+ jsonOut .LengthMustEqualTo (3 )
158
+ }
159
+ jsonOut .MustContain (`[
81
160
{
82
- "platform": "Arduino AVR Boards",
83
- "id": "usbasp",
84
- "name": "USBasp"
85
- },
161
+ "id": "arduino:avr",
162
+ "installed": "1.8.6",
163
+ "name": "Arduino AVR Boards",
164
+ "boards": [
165
+ {
166
+ "name": "Arduino Uno",
167
+ "fqbn": "arduino:avr:uno"
168
+ },
169
+ {
170
+ "name": "Arduino Yún",
171
+ "fqbn": "arduino:avr:yun"
172
+ }
173
+ ]
174
+ }
175
+ ]` )
176
+ jsonOut .MustContain (`[
86
177
{
87
- "platform": "Arduino AVR Boards",
88
- "id": "avrispmkii",
89
- "name": "AVRISP mkII"
178
+ "id": "my_avr_platform:avr",
179
+ "installed": "9.9.9",
180
+ "name": "My AVR Boards",
181
+ "boards": [
182
+ {
183
+ "name": "Arduino Yún",
184
+ "fqbn": "my_avr_platform:avr:custom_yun"
185
+ }
186
+ ],
187
+ "manually_installed": true,
188
+ "missing_metadata": true
90
189
}
91
- ]
92
- }` )
93
- }
190
+ ]` )
94
191
95
- {
96
- out , _ , err := cli .Run ("board" , "details" , "-b" , "arduino:avr:yun" , "--format" , "json" )
97
- require .NoError (t , err )
98
- jsonOut := requirejson .Parse (t , out )
99
- jsonOut .MustContain (`{
100
- "version": "1.8.6",
101
- "properties_id": "yun",
102
- "build_properties": [
103
- "_id=yun",
104
- "upload.wait_for_upload_port=true"
105
- ]
106
- }` )
107
- }
108
-
109
- {
110
- // Check un-expansion of board_properties
111
- out , _ , err := cli .Run ("board" , "details" , "-b" , "arduino:avr:robotMotor" , "--show-properties=unexpanded" , "--format" , "json" )
112
- require .NoError (t , err )
113
- jsonOut := requirejson .Parse (t , out )
114
- jsonOut .MustContain (`{
115
- "version": "1.8.6",
116
- "properties_id": "robotMotor",
117
- "build_properties": [
118
- "_id=robotMotor",
119
- "build.extra_flags={build.usb_flags}",
120
- "upload.wait_for_upload_port=true"
121
- ]
122
- }` )
123
- }
124
-
125
- {
126
- // Also test local boards.txt properties override
127
- out , _ , err := cli .Run ("board" , "details" , "-b" , "arduino:avr:diecimila" , "--show-properties=unexpanded" , "--format" , "json" )
128
- require .NoError (t , err )
129
- jsonOut := requirejson .Parse (t , out )
130
- jsonOut .MustContain (`{
131
- "version": "1.8.6",
132
- "properties_id": "diecimila",
133
- "build_properties": [
134
- "_id=diecimila",
135
- "menu.cpu.atmega123=ATmega123"
136
- ]
137
- }` )
138
- }
192
+ // require.False(t, myAVRPlatformAvrArch.Properties.ContainsKey("preproc.includes.flags"))
193
+
194
+ if runtime .GOOS != "windows" {
195
+ jsonOut .MustContain (`[
196
+ {
197
+ "id": "my_symlinked_avr_platform:avr",
198
+ "manually_installed": true,
199
+ "missing_metadata": true
200
+ }
201
+ ]` )
202
+ }
203
+ }
204
+
205
+ {
206
+ // Also test local platform.txt properties override
207
+ out , _ , err := cli .Run ("board" , "details" , "-b" , "arduino:avr:uno" , "--format" , "json" )
208
+ require .NoError (t , err )
209
+ jsonOut := requirejson .Parse (t , out )
210
+ jsonOut .MustContain (`{
211
+ "version": "1.8.6",
212
+ "properties_id": "uno",
213
+ "build_properties": [
214
+ "_id=uno",
215
+ "tools.avrdude.bootloader.params.verbose=-v",
216
+ "tools.avrdude.cmd.path=/my/personal/avrdude"
217
+ ],
218
+ "programmers": [
219
+ {
220
+ "platform": "Arduino AVR Boards",
221
+ "id": "usbasp",
222
+ "name": "USBasp"
223
+ },
224
+ {
225
+ "platform": "Arduino AVR Boards",
226
+ "id": "avrispmkii",
227
+ "name": "AVRISP mkII"
228
+ }
229
+ ]
230
+ }` )
231
+ }
232
+
233
+ {
234
+ out , _ , err := cli .Run ("board" , "details" , "-b" , "arduino:avr:yun" , "--show-properties=unexpanded" , "--format" , "json" )
235
+ require .NoError (t , err )
236
+ jsonOut := requirejson .Parse (t , out )
237
+ jsonOut .MustContain (`{
238
+ "version": "1.8.6",
239
+ "properties_id": "yun",
240
+ "build_properties": [
241
+ "_id=yun",
242
+ "upload.wait_for_upload_port=true",
243
+ "preproc.includes.flags=-w -x c++ -M -MG -MP",
244
+ "preproc.macros.flags=-w -x c++ -E -CC",
245
+ "recipe.preproc.includes=\"{compiler.path}{compiler.cpp.cmd}\" {compiler.cpp.flags} {preproc.includes.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} \"{source_file}\""
246
+ ]
247
+ }` )
248
+ jsonOut .Query (`isempty( .build_properties[] | select(startswith("preproc.macros.compatibility_flags")) )` ).MustEqual ("true" )
249
+ }
250
+ })
139
251
}
0 commit comments