Skip to content

Commit 94a300f

Browse files
Migrated TestBoardListWithInvalidDiscovery from test_board.py to board_test.go
Originally, stderr was checked to assert that the CLI did not crash if an invalid discovery was installed, but now, under the same conditions, stderr results empty. I decided to check if stdout contained instead and the checks have been successful.
1 parent 6b88371 commit 94a300f

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

internal/integrationtest/board/board_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,24 @@ func TestBoardList(t *testing.T) {
4646
require.Contains(t, port, "protocol_label")
4747
}
4848
}
49+
50+
func TestBoardListWithInvalidDiscovery(t *testing.T) {
51+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
52+
defer env.CleanUp()
53+
54+
_, _, err := cli.Run("core", "update-index")
55+
require.NoError(t, err)
56+
_, _, err = cli.Run("board", "list")
57+
require.NoError(t, err)
58+
59+
// check that the CLI does not crash if an invalid discovery is installed
60+
// (for example if the installation fails midway).
61+
// https://github.com/arduino/arduino-cli/issues/1669
62+
toolDir := cli.DataDir().Join("packages", "builtin", "tools", "serial-discovery")
63+
err = toolDir.RemoveAll()
64+
require.NoError(t, err)
65+
66+
stdout, _, err := cli.Run("board", "list")
67+
require.NoError(t, err)
68+
require.Contains(t, string(stdout), "builtin:serial-discovery")
69+
}

test/test_board.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -394,23 +394,6 @@
394394
""" # noqa: E501
395395

396396

397-
def test_board_list_with_invalid_discovery(run_command, data_dir):
398-
run_command(["core", "update-index"])
399-
result = run_command(["board", "list"])
400-
assert result.ok
401-
402-
# check that the CLI do no crash if an invalid discovery is installed
403-
# (for example if the installation fails midway).
404-
# https://github.com/arduino/arduino-cli/issues/1669
405-
tool_dir = os.path.join(data_dir, "packages", "builtin", "tools", "serial-discovery")
406-
for file_to_delete in glob.glob(tool_dir + "/*/*"):
407-
os.remove(file_to_delete)
408-
409-
result = run_command(["board", "list"])
410-
assert result.ok
411-
assert "builtin:serial-discovery" in result.stderr
412-
413-
414397
def test_board_listall(run_command):
415398
assert run_command(["update"])
416399
assert run_command(["core", "install", "arduino:avr@1.8.3"])

0 commit comments

Comments
 (0)