Skip to content

Commit 27c762f

Browse files
committed
Added check for missing 'recipe.output.tmp_file' during upload
1 parent 12ed136 commit 27c762f

File tree

4 files changed

+49
-1
lines changed

4 files changed

+49
-1
lines changed

commands/commands_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,10 @@ func TestUploadCommands(t *testing.T) {
248248
// sketch without build
249249
exitCode, d = executeWithArgs(t, "upload", currSketchbookDir.Join("TestSketch2").String(), "-b", "test:avr:testboard", "-p", "/dev/ttyACM0")
250250
require.NotZero(t, exitCode, "exit code")
251+
252+
// platform without 'recipe.output.tmp_file' property
253+
exitCode, d = executeWithArgs(t, "upload", "-i", currSketchbookDir.Join("test.hex").String(), "-b", "test2:avr:testboard", "-p", "/dev/ttyACM0")
254+
require.NotZero(t, exitCode, "exit code")
251255
}
252256

253257
func TestLibSearch(t *testing.T) {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
testboard.name=Test Board
2+
3+
testboard.vid.0=0x2341
4+
testboard.pid.0=0x8888
5+
6+
testboard.upload.tool=avrdude-none
7+
testboard.upload.protocol=arduino
8+
testboard.upload.maximum_size=32256
9+
testboard.upload.maximum_data_size=2048
10+
testboard.upload.speed=115200
11+
12+
testboard.bootloader.tool=avrdude
13+
testboard.bootloader.low_fuses=0xFF
14+
testboard.bootloader.high_fuses=0xDE
15+
testboard.bootloader.extended_fuses=0xFD
16+
testboard.bootloader.unlock_bits=0x3F
17+
testboard.bootloader.lock_bits=0x0F
18+
testboard.bootloader.file=optiboot/optiboot_atmega328.hex
19+
20+
testboard.build.mcu=atmega328p
21+
testboard.build.f_cpu=16000000L
22+
testboard.build.board=AVR_UNO
23+
testboard.build.core=arduino:arduino
24+
testboard.build.variant=standard
25+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
name=Test AVR Boards
3+
version=1.0.0
4+
5+
# Removed for testing purposes
6+
#recipe.output.tmp_file={build.project_name}.hex
7+
8+
# Fake AVR programmer tool for testing
9+
# ------------------------------------
10+
tools.avrdude-none.upload.params.verbose=VERBOSE
11+
tools.avrdude-none.upload.params.quiet=QUIET
12+
tools.avrdude-none.upload.params.verify=VERIFY
13+
tools.avrdude-none.upload.params.noverify=NOVERIFY
14+
tools.avrdude-none.upload.pattern=echo {upload.verbose} {upload.verify} "{build.path}/{build.project_name}.hex"

commands/upload/upload.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,12 @@ func run(command *cobra.Command, args []string) {
178178
// Make the filename without the FQBN configs part
179179
fqbn.Configs = properties.NewMap()
180180
fqbnSuffix := strings.Replace(fqbn.String(), ":", ".", -1)
181-
ext := filepath.Ext(uploadProperties.ExpandPropsInString("{recipe.output.tmp_file}"))
181+
outputTmpFile, ok := uploadProperties.GetOk("recipe.output.tmp_file")
182+
if !ok {
183+
formatter.PrintErrorMessage("The platform does not define the required property 'recipe.output.tmp_file'.")
184+
os.Exit(commands.ErrGeneric)
185+
}
186+
ext := filepath.Ext(outputTmpFile)
182187

183188
var importPath *paths.Path
184189
var importFile string

0 commit comments

Comments
 (0)