Skip to content

Commit e81a1f6

Browse files
committed
Added test for upload without port
1 parent baa6206 commit e81a1f6

File tree

3 files changed

+45
-15
lines changed

3 files changed

+45
-15
lines changed

commands/upload/testdata/hardware/alice/avr/boards.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,20 @@ board1.bootloader.extended_fuses=0xFD
1111
board1.bootloader.unlock_bits=0x3F
1212
board1.bootloader.lock_bits=0x0F
1313
board1.bootloader.file=optiboot/optiboot_atmega328.hex
14+
15+
16+
board2.name=board2
17+
board2.conf.board=conf-board1
18+
board2.upload.tool=one-noport
19+
board2.upload.protocol=protocol
20+
board2.upload.speed=speed
21+
22+
board2.bootloader.tool=one
23+
board2.bootloader.low_fuses=0xFF
24+
board2.bootloader.high_fuses=0xDE
25+
board2.bootloader.extended_fuses=0xFD
26+
board2.bootloader.unlock_bits=0x3F
27+
board2.bootloader.lock_bits=0x0F
28+
board2.bootloader.file=optiboot/optiboot_atmega328.hex
29+
30+

commands/upload/testdata/hardware/alice/avr/platform.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ version=1.0.0
44
# Upload test 1
55
tools.one.cmd.path=echo
66
tools.one.conf.general=conf-general
7-
87
tools.one.upload.conf=conf-upload
98
tools.one.upload.params.verbose=verbose
109
tools.one.upload.params.quiet=quiet
@@ -14,8 +13,10 @@ tools.one.upload.pattern={cmd.path} {conf.board} {conf.general} {upload.conf} {u
1413

1514
# Upload test 2
1615
tools.one-noport.cmd.path=echo
16+
tools.one-noport.conf.general=conf-general
17+
tools.one-noport.upload.conf=conf-upload
1718
tools.one-noport.upload.params.verbose=verbose
1819
tools.one-noport.upload.params.quiet=quiet
19-
tools.one-noport.upload.verify=verify
20+
tools.one-noport.upload.params.verify=verify
2021
tools.one-noport.upload.params.noverify=noverify
21-
tools.one-noport.upload.pattern={cmd.path} {conf.general} {conf.upload} {upload.verbose} {upload.verify} {build.mcu} {upload.protocol} "{serial.port}" -b{upload.speed} "{build.path}/{build.project_name}.hex"
22+
tools.one-noport.upload.pattern={cmd.path} {conf.board} {conf.general} {upload.conf} {upload.verbose} {upload.verify} {upload.protocol} -b{upload.speed} "{build.path}/{build.project_name}.hex"

commands/upload/upload_test.go

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ func TestUploadPropertiesComposition(t *testing.T) {
141141
tests := []test{
142142
// classic upload, requires port
143143
{buildPath1, "alice:avr:board1", "port", "", false, "conf-board1 conf-general conf-upload $$VERBOSE-VERIFY$$ protocol port -bspeed testdata/build_path_1/sketch.ino.hex"},
144+
{buildPath1, "alice:avr:board1", "", "", false, "FAIL"},
145+
// classic upload, no port
146+
{buildPath1, "alice:avr:board2", "port", "", false, "conf-board1 conf-general conf-upload $$VERBOSE-VERIFY$$ protocol -bspeed testdata/build_path_1/sketch.ino.hex"},
147+
{buildPath1, "alice:avr:board2", "", "", false, "conf-board1 conf-general conf-upload $$VERBOSE-VERIFY$$ protocol -bspeed testdata/build_path_1/sketch.ino.hex"},
144148
}
145149
for i, test := range tests {
146150
t.Run(fmt.Sprintf("SubTest%02d", i), func(t *testing.T) {
@@ -160,9 +164,13 @@ func TestUploadPropertiesComposition(t *testing.T) {
160164
outStream,
161165
errStream,
162166
)
163-
require.NoError(t, err)
164-
out := strings.TrimSpace(outStream.String())
165-
require.Equal(t, strings.ReplaceAll(test.expected, "$$VERBOSE-VERIFY$$", "quiet noverify"), out)
167+
if test.expected == "FAIL" {
168+
require.Error(t, err)
169+
} else {
170+
require.NoError(t, err)
171+
out := strings.TrimSpace(outStream.String())
172+
require.Equal(t, strings.ReplaceAll(test.expected, "$$VERBOSE-VERIFY$$", "quiet noverify"), out)
173+
}
166174
})
167175
t.Run(fmt.Sprintf("SubTest%02d-WithVerifyAndVerbose", i), func(t *testing.T) {
168176
outStream := &bytes.Buffer{}
@@ -181,15 +189,19 @@ func TestUploadPropertiesComposition(t *testing.T) {
181189
outStream,
182190
errStream,
183191
)
184-
require.NoError(t, err)
185-
out := strings.Split(outStream.String(), "\n")
186-
// With verbose enabled, the upload will output 3 lines:
187-
// - the command line that the cli is going to run
188-
// - the output of the command
189-
// - an empty line
190-
// we are interested in the second line
191-
require.Len(t, out, 3)
192-
require.Equal(t, strings.ReplaceAll(test.expected, "$$VERBOSE-VERIFY$$", "verbose verify"), out[1])
192+
if test.expected == "FAIL" {
193+
require.Error(t, err)
194+
} else {
195+
require.NoError(t, err)
196+
out := strings.Split(outStream.String(), "\n")
197+
// With verbose enabled, the upload will output 3 lines:
198+
// - the command line that the cli is going to run
199+
// - the output of the command
200+
// - an empty line
201+
// we are interested in the second line
202+
require.Len(t, out, 3)
203+
require.Equal(t, strings.ReplaceAll(test.expected, "$$VERBOSE-VERIFY$$", "verbose verify"), out[1])
204+
}
193205
})
194206
}
195207
}

0 commit comments

Comments
 (0)