Skip to content

Commit 085a31b

Browse files
authored
Fix panic calling compile with wrong FQBN (#1645)
1 parent 1b0c127 commit 085a31b

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

commands/compile/compile.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,10 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
119119
PlatformArchitecture: fqbn.PlatformArch,
120120
})
121121
if targetPlatform == nil || pm.GetInstalledPlatformRelease(targetPlatform) == nil {
122-
// TODO: Move this error message in `cli` module
123-
// errorMessage := fmt.Sprintf(
124-
// "\"%[1]s:%[2]s\" platform is not installed, please install it by running \""+
125-
// version.GetAppName()+" core install %[1]s:%[2]s\".", fqbn.Package, fqbn.PlatformArch)
126-
// feedback.Error(errorMessage)
127-
return nil, &arduino.PlatformNotFoundError{Platform: targetPlatform.String(), Cause: fmt.Errorf(tr("platform not installed"))}
122+
return nil, &arduino.PlatformNotFoundError{
123+
Platform: fmt.Sprintf("%s:%s", fqbn.Package, fqbn.PlatformArch),
124+
Cause: fmt.Errorf(tr("platform not installed")),
125+
}
128126
}
129127

130128
builderCtx := &types.Context{}

test/test_compile_part_4.py

+19
Original file line numberDiff line numberDiff line change
@@ -378,3 +378,22 @@ def test_compile_without_upload_and_fqbn(run_command, data_dir):
378378
res = run_command(["compile", sketch_path])
379379
assert res.failed
380380
assert "Error during build: Missing FQBN (Fully Qualified Board Name)" in res.stderr
381+
382+
383+
def test_compile_non_installed_platform_with_wrong_packager_and_arch(run_command, data_dir):
384+
assert run_command(["update"])
385+
386+
# Create a sketch
387+
sketch_name = "SketchSimple"
388+
sketch_path = Path(data_dir, sketch_name)
389+
assert run_command(["sketch", "new", sketch_path])
390+
391+
# Compile with wrong packager
392+
res = run_command(["compile", "-b", "wrong:avr:uno", sketch_path])
393+
assert res.failed
394+
assert "Error during build: Platform 'wrong:avr' not found: platform not installed" in res.stderr
395+
396+
# Compile with wrong arch
397+
res = run_command(["compile", "-b", "arduino:wrong:uno", sketch_path])
398+
assert res.failed
399+
assert "Error during build: Platform 'arduino:wrong' not found: platform not installed" in res.stderr

0 commit comments

Comments
 (0)