Skip to content

Commit 42043f6

Browse files
authored
Fixed cryptic error messages returned from Compile (#1848)
1 parent 6138864 commit 42043f6

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

Diff for: commands/daemon/daemon.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,10 @@ func (s *ArduinoCoreServerImpl) Compile(req *rpc.CompileRequest, stream rpc.Ardu
278278
errStream.Close()
279279
<-outCtx.Done()
280280
<-errCtx.Done()
281-
compileRespSendErr := stream.Send(compileResp)
281+
var compileRespSendErr error
282+
if compileResp != nil {
283+
compileRespSendErr = stream.Send(compileResp)
284+
}
282285
if compileErr != nil {
283286
return convertErrorToRPCStatus(compileErr)
284287
}

Diff for: internal/integrationtest/daemon/daemon_compile_test.go

+32
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,35 @@ func TestDaemonCompileOptions(t *testing.T) {
9393
}
9494
}
9595
}
96+
97+
func TestDaemonCompileAfterFailedLibInstall(t *testing.T) {
98+
// See: https://github.com/arduino/arduino-cli/issues/1812
99+
100+
env, cli := createEnvForDaemon(t)
101+
defer env.CleanUp()
102+
103+
grpcInst := cli.Create()
104+
require.NoError(t, grpcInst.Init("", "", func(ir *commands.InitResponse) {
105+
fmt.Printf("INIT> %v\n", ir.GetMessage())
106+
}))
107+
108+
// Build sketch (with errors)
109+
sk := paths.New("testdata", "bare_minimum")
110+
compile, err := grpcInst.Compile(context.Background(), "", sk.String())
111+
require.NoError(t, err)
112+
for {
113+
msg, err := compile.Recv()
114+
if err == io.EOF {
115+
require.FailNow(t, "Expected compilation failure", "compilation succeeded")
116+
break
117+
}
118+
if err != nil {
119+
fmt.Println("COMPILE ERROR>", err)
120+
require.Contains(t, err.Error(), "Missing FQBN")
121+
break
122+
}
123+
if msg.ErrStream != nil {
124+
fmt.Printf("COMPILE> %v\n", string(msg.GetErrStream()))
125+
}
126+
}
127+
}

0 commit comments

Comments
 (0)