Skip to content

Commit 2bd8501

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 51bc271 commit 2bd8501

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

internal/integrationtest/board/board_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,29 @@ func TestBoardList(t *testing.T) {
5353
require.Contains(t, port, "protocol_label")
5454
}
5555
}
56+
57+
func TestBoardListWithInvalidDiscovery(t *testing.T) {
58+
env := testsuite.NewEnvironment(t)
59+
defer env.CleanUp()
60+
61+
cli := integrationtest.NewArduinoCliWithinEnvironment(env, &integrationtest.ArduinoCLIConfig{
62+
ArduinoCLIPath: paths.New("..", "..", "..", "arduino-cli"),
63+
UseSharedStagingFolder: true,
64+
})
65+
66+
_, _, err := cli.Run("core", "update-index")
67+
require.NoError(t, err)
68+
_, _, err = cli.Run("board", "list")
69+
require.NoError(t, err)
70+
71+
// check that the CLI does not crash if an invalid discovery is installed
72+
// (for example if the installation fails midway).
73+
// https://github.com/arduino/arduino-cli/issues/1669
74+
toolDir := cli.DataDir().Join("packages", "builtin", "tools", "serial-discovery")
75+
err = toolDir.RemoveAll()
76+
require.NoError(t, err)
77+
78+
stdout, _, err := cli.Run("board", "list")
79+
require.NoError(t, err)
80+
require.Contains(t, string(stdout), "builtin:serial-discovery")
81+
}

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:[email protected]"])

0 commit comments

Comments
 (0)