Skip to content

Commit 12153ec

Browse files
Migrate TestListProvidesIncludesFallback from test_lib.py to lib_test.go
1 parent dbf8a33 commit 12153ec

File tree

2 files changed

+46
-26
lines changed

2 files changed

+46
-26
lines changed

internal/integrationtest/lib/lib_test.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,3 +448,49 @@ func TestListWithFqbn(t *testing.T) {
448448
requirejson.Query(t, stdout, ".[0] | .library | .name", "\"ArduinoJson\"")
449449
requirejson.Query(t, stdout, ".[0] | .library | .compatible_with | .\"arduino:avr:uno\"", "true")
450450
}
451+
452+
func TestListProvidesIncludesFallback(t *testing.T) {
453+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
454+
defer env.CleanUp()
455+
456+
// Verifies "provides_includes" field is returned even if libraries don't declare
457+
// the "includes" property in their "library.properties" file
458+
_, _, err := cli.Run("update")
459+
require.NoError(t, err)
460+
461+
// Install core
462+
_, _, err = cli.Run("core", "install", "arduino:avr@1.8.3")
463+
require.NoError(t, err)
464+
_, _, err = cli.Run("lib", "install", "ArduinoJson@6.17.2")
465+
require.NoError(t, err)
466+
467+
// List all libraries, even the ones installed with the above core
468+
stdout, stderr, err := cli.Run("lib", "list", "--all", "--fqbn", "arduino:avr:uno", "--format", "json")
469+
require.NoError(t, err)
470+
require.Empty(t, stderr)
471+
472+
requirejson.Len(t, stdout, 6)
473+
474+
requirejson.Query(t, stdout, "[.[] | .library | { (.name): .provides_includes }] | add",
475+
`{
476+
"SPI": [
477+
"SPI.h"
478+
],
479+
"SoftwareSerial": [
480+
"SoftwareSerial.h"
481+
],
482+
"Wire": [
483+
"Wire.h"
484+
],
485+
"ArduinoJson": [
486+
"ArduinoJson.h",
487+
"ArduinoJson.hpp"
488+
],
489+
"EEPROM": [
490+
"EEPROM.h"
491+
],
492+
"HID": [
493+
"HID.h"
494+
]
495+
}`)
496+
}

test/test_lib.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -49,32 +49,6 @@ def download_lib(url, download_dir):
4949
z.close()
5050

5151

52-
def test_list_provides_includes_fallback(run_command):
53-
# Verifies "provides_includes" field is returned even if libraries don't declare
54-
# the "includes" property in their "library.properties" file
55-
assert run_command(["update"])
56-
57-
# Install core
58-
assert run_command(["core", "install", "arduino:avr@1.8.3"])
59-
assert run_command(["lib", "install", "ArduinoJson@6.17.2"])
60-
61-
# List all libraries, even the ones installed with the above core
62-
result = run_command(["lib", "list", "--all", "--fqbn", "arduino:avr:uno", "--format", "json"], hide=True)
63-
assert result.ok
64-
assert "" == result.stderr
65-
66-
data = json.loads(result.stdout)
67-
assert 6 == len(data)
68-
69-
libs = {l["library"]["name"]: l["library"]["provides_includes"] for l in data}
70-
assert ["SoftwareSerial.h"] == libs["SoftwareSerial"]
71-
assert ["Wire.h"] == libs["Wire"]
72-
assert ["EEPROM.h"] == libs["EEPROM"]
73-
assert ["HID.h"] == libs["HID"]
74-
assert ["SPI.h"] == libs["SPI"]
75-
assert ["ArduinoJson.h", "ArduinoJson.hpp"] == libs["ArduinoJson"]
76-
77-
7852
def test_lib_download(run_command, downloads_dir):
7953

8054
# Download a specific lib version

0 commit comments

Comments
 (0)