|
16 | 16 | package board_test
|
17 | 17 |
|
18 | 18 | import (
|
19 |
| - "os" |
20 | 19 | "runtime"
|
21 | 20 | "strings"
|
22 | 21 | "testing"
|
@@ -73,15 +72,14 @@ func TestCorrectBoardListOrdering(t *testing.T) {
|
73 | 72 | }
|
74 | 73 |
|
75 | 74 | func TestBoardList(t *testing.T) {
|
76 |
| - if os.Getenv("CI") != "" { |
77 |
| - t.Skip("VMs have no serial ports") |
78 |
| - } |
79 |
| - |
80 | 75 | env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
|
81 | 76 | defer env.CleanUp()
|
82 | 77 |
|
83 | 78 | _, _, err := cli.Run("core", "update-index")
|
84 | 79 | require.NoError(t, err)
|
| 80 | + |
| 81 | + cli.InstallMockedSerialDiscovery(t) |
| 82 | + |
85 | 83 | stdout, _, err := cli.Run("board", "list", "--format", "json")
|
86 | 84 | require.NoError(t, err)
|
87 | 85 | // check is a valid json and contains a list of ports
|
@@ -130,32 +128,28 @@ func TestBoardListMock(t *testing.T) {
|
130 | 128 | }
|
131 | 129 |
|
132 | 130 | func TestBoardListWithFqbnFilter(t *testing.T) {
|
133 |
| - if os.Getenv("CI") != "" { |
134 |
| - t.Skip("VMs have no serial ports") |
135 |
| - } |
136 |
| - |
137 | 131 | env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
|
138 | 132 | defer env.CleanUp()
|
139 | 133 |
|
140 | 134 | _, _, err := cli.Run("core", "update-index")
|
141 | 135 | require.NoError(t, err)
|
| 136 | + |
| 137 | + cli.InstallMockedSerialDiscovery(t) |
| 138 | + |
142 | 139 | stdout, _, err := cli.Run("board", "list", "-b", "foo:bar:baz", "--format", "json")
|
143 | 140 | require.NoError(t, err)
|
144 |
| - // this is a bit of a passpartout test, it actually filters the "bluetooth boards" locally |
145 |
| - // but it would succeed even if the filtering wasn't working properly |
146 |
| - // TODO: find a way to simulate connected boards or create a unit test which |
147 |
| - // mocks or initializes multiple components |
148 |
| - requirejson.Query(t, stdout, `.boards | length`, `0`) |
| 141 | + requirejson.Query(t, stdout, `.detected_ports | length`, `0`) |
149 | 142 | }
|
150 | 143 |
|
151 | 144 | func TestBoardListWithFqbnFilterInvalid(t *testing.T) {
|
152 |
| - if os.Getenv("CI") != "" { |
153 |
| - t.Skip("VMs have no serial ports") |
154 |
| - } |
155 |
| - |
156 | 145 | env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
|
157 | 146 | defer env.CleanUp()
|
158 | 147 |
|
| 148 | + _, _, err := cli.Run("core", "update-index") |
| 149 | + require.NoError(t, err) |
| 150 | + |
| 151 | + cli.InstallMockedSerialDiscovery(t) |
| 152 | + |
159 | 153 | _, stderr, err := cli.Run("board", "list", "-b", "yadayada", "--format", "json")
|
160 | 154 | require.Error(t, err)
|
161 | 155 | requirejson.Query(t, stderr, ".error", `"Invalid FQBN: not an FQBN: yadayada"`)
|
|
0 commit comments