Skip to content

Commit 763fcb8

Browse files
committed
updated tests and fixed some error wording
1 parent 677fd55 commit 763fcb8

File tree

13 files changed

+39
-34
lines changed

13 files changed

+39
-34
lines changed

commands/board/attach.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func Attach(ctx context.Context, req *rpc.BoardAttachRequest, taskCB commands.Ta
4646
}
4747
sk, err := sketch.New(sketchPath)
4848
if err != nil {
49-
return nil, &commands.SketchNotFoundError{Cause: err}
49+
return nil, &commands.CantOpenSketchError{Cause: err}
5050
}
5151

5252
boardURI := req.GetBoardUri()

commands/compile/compile.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
9999
sketchPath := paths.New(req.GetSketchPath())
100100
sk, err := sketch.New(sketchPath)
101101
if err != nil {
102-
return nil, &commands.SketchNotFoundError{Cause: err}
102+
return nil, &commands.CantOpenSketchError{Cause: err}
103103
}
104104

105105
fqbnIn := req.GetFqbn()

commands/debug/debug_info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func getDebugProperties(req *debug.DebugConfigRequest, pm *packagemanager.Packag
4444
sketchPath := paths.New(req.GetSketchPath())
4545
sk, err := sketch.New(sketchPath)
4646
if err != nil {
47-
return nil, &commands.SketchNotFoundError{Cause: err}
47+
return nil, &commands.CantOpenSketchError{Cause: err}
4848
}
4949

5050
// XXX Remove this code duplication!!

commands/errors.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,20 +304,20 @@ func (e *MissingSketchPathError) ToRPCStatus() *status.Status {
304304
return status.New(codes.InvalidArgument, e.Error())
305305
}
306306

307-
// SketchNotFoundError is returned when the sketch is not found
308-
type SketchNotFoundError struct {
307+
// CantOpenSketchError is returned when the sketch is not found or cannot be opened
308+
type CantOpenSketchError struct {
309309
Cause error
310310
}
311311

312-
func (e *SketchNotFoundError) Error() string {
313-
return composeErrorMsg(tr("Sketch not found"), e.Cause)
312+
func (e *CantOpenSketchError) Error() string {
313+
return composeErrorMsg(tr("Can't open sketch"), e.Cause)
314314
}
315315

316-
func (e *SketchNotFoundError) Unwrap() error {
316+
func (e *CantOpenSketchError) Unwrap() error {
317317
return e.Cause
318318
}
319319

320-
func (e *SketchNotFoundError) ToRPCStatus() *status.Status {
320+
func (e *CantOpenSketchError) ToRPCStatus() *status.Status {
321321
return status.New(codes.NotFound, e.Error())
322322
}
323323

commands/instances.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ func LoadSketch(ctx context.Context, req *rpc.LoadSketchRequest) (*rpc.LoadSketc
862862
// TODO: This should be a ToRpc function for the Sketch struct
863863
sketch, err := sk.New(paths.New(req.SketchPath))
864864
if err != nil {
865-
return nil, &SketchNotFoundError{Cause: err}
865+
return nil, &CantOpenSketchError{Cause: err}
866866
}
867867

868868
otherSketchFiles := make([]string, sketch.OtherSketchFiles.Len())

commands/sketch/archive.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func ArchiveSketch(ctx context.Context, req *rpc.ArchiveSketchRequest) (*rpc.Arc
4343

4444
s, err := sketch.New(sketchPath)
4545
if err != nil {
46-
return nil, &commands.SketchNotFoundError{Cause: err}
46+
return nil, &commands.CantOpenSketchError{Cause: err}
4747
}
4848

4949
sketchPath = s.FullPath

commands/upload/upload.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func Upload(ctx context.Context, req *rpc.UploadRequest, outStream io.Writer, er
123123
sketchPath := paths.New(req.GetSketchPath())
124124
sk, err := sketch.New(sketchPath)
125125
if err != nil && req.GetImportDir() == "" && req.GetImportFile() == "" {
126-
return nil, &commands.SketchNotFoundError{Cause: err}
126+
return nil, &commands.CantOpenSketchError{Cause: err}
127127
}
128128

129129
pm := commands.GetPackageManager(req.GetInstance().GetId())

test/test_board.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ def test_board_details_no_flags(run_command):
528528
run_command("core install arduino:[email protected]")
529529
result = run_command("board details")
530530
assert not result.ok
531-
assert "Error getting board details: parsing fqbn: invalid fqbn:" in result.stderr
531+
assert "Error getting board details: Invalid FQBN:" in result.stderr
532532
assert result.stdout == ""
533533

534534

test/test_compile.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def test_compile_with_sketch_with_symlink_selfloop(run_command, data_dir):
132132
result = run_command("compile -b {fqbn} {sketch_path}".format(fqbn=fqbn, sketch_path=sketch_path))
133133
# The assertion is a bit relaxed in this case because win behaves differently from macOs and linux
134134
# returning a different error detailed message
135-
assert "Error during build: opening sketch" in result.stderr
135+
assert "Error during build: Can't open sketch:" in result.stderr
136136
assert not result.ok
137137

138138
sketch_name = "CompileIntegrationTestSymlinkDirLoop"
@@ -154,7 +154,7 @@ def test_compile_with_sketch_with_symlink_selfloop(run_command, data_dir):
154154
result = run_command("compile -b {fqbn} {sketch_path}".format(fqbn=fqbn, sketch_path=sketch_path))
155155
# The assertion is a bit relaxed in this case because win behaves differently from macOs and linux
156156
# returning a different error detailed message
157-
assert "Error during build: opening sketch" in result.stderr
157+
assert "Error during build: Can't open sketch:" in result.stderr
158158
assert not result.ok
159159

160160

@@ -685,17 +685,17 @@ def test_compile_sketch_with_multiple_main_files(run_command, data_dir):
685685
# Build sketch from folder
686686
res = run_command(f"compile --clean -b {fqbn} {sketch_path}")
687687
assert res.failed
688-
assert "Error during build: opening sketch: multiple main sketch files found" in res.stderr
688+
assert "Error during build: Can't open sketch: multiple main sketch files found" in res.stderr
689689

690690
# Build sketch from .ino file
691691
res = run_command(f"compile --clean -b {fqbn} {sketch_ino_file}")
692692
assert res.failed
693-
assert "Error during build: opening sketch: multiple main sketch files found" in res.stderr
693+
assert "Error during build: Can't open sketch: multiple main sketch files found" in res.stderr
694694

695695
# Build sketch from .pde file
696696
res = run_command(f"compile --clean -b {fqbn} {sketch_pde_file}")
697697
assert res.failed
698-
assert "Error during build: opening sketch: multiple main sketch files found" in res.stderr
698+
assert "Error during build: Can't open sketch: multiple main sketch files found" in res.stderr
699699

700700

701701
def test_compile_sketch_case_mismatch_fails(run_command, data_dir):
@@ -718,15 +718,15 @@ def test_compile_sketch_case_mismatch_fails(run_command, data_dir):
718718
# * Compiling with sketch path
719719
res = run_command(f"compile --clean -b {fqbn} {sketch_path}")
720720
assert res.failed
721-
assert "Error during build: opening sketch: no valid sketch found" in res.stderr
721+
assert "Error during build: Can't open sketch: no valid sketch found" in res.stderr
722722
# * Compiling with sketch main file
723723
res = run_command(f"compile --clean -b {fqbn} {sketch_main_file}")
724724
assert res.failed
725-
assert "Error during build: opening sketch: no valid sketch found" in res.stderr
725+
assert "Error during build: Can't open sketch: no valid sketch found" in res.stderr
726726
# * Compiling in sketch path
727727
res = run_command(f"compile --clean -b {fqbn}", custom_working_dir=sketch_path)
728728
assert res.failed
729-
assert "Error during build: opening sketch: no valid sketch found" in res.stderr
729+
assert "Error during build: Can't open sketch: no valid sketch found" in res.stderr
730730

731731

732732
def test_compile_with_only_compilation_database_flag(run_command, data_dir):

test/test_core.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def test_core_updateindex_url_not_found(run_command, httpserver):
177177
result = run_command(f"core update-index --additional-urls={url}")
178178
assert result.failed
179179
lines = [l.strip() for l in result.stderr.splitlines()]
180-
assert f"Error updating index: downloading index {url}: 404 NOT FOUND" in lines
180+
assert f"Error updating index: Error downloading index '{url}': Server responded with: 404 NOT FOUND" in lines
181181

182182

183183
def test_core_updateindex_internal_server_error(run_command, httpserver):
@@ -190,7 +190,10 @@ def test_core_updateindex_internal_server_error(run_command, httpserver):
190190
result = run_command(f"core update-index --additional-urls={url}")
191191
assert result.failed
192192
lines = [l.strip() for l in result.stderr.splitlines()]
193-
assert f"Error updating index: downloading index {url}: 500 INTERNAL SERVER ERROR" in lines
193+
assert (
194+
f"Error updating index: Error downloading index '{url}': Server responded with: 500 INTERNAL SERVER ERROR"
195+
in lines
196+
)
194197

195198

196199
def test_core_install_without_updateindex(run_command):

0 commit comments

Comments
 (0)