Skip to content

Commit d935361

Browse files
Migrate TestCompileWithEsp32BundledLibraries from test_compile_part_4.py to compile_part_4_test.go
1 parent 89d1180 commit d935361

File tree

3 files changed

+46
-39
lines changed

3 files changed

+46
-39
lines changed

internal/integrationtest/compile/compile_part_4_test.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,49 @@ func TestCompileWithInvalidBuildOptionJson(t *testing.T) {
254254
_, _, err = cli.Run("compile", "-b", fqbn, sketchPath.String(), "--verbose")
255255
require.NoError(t, err)
256256
}
257+
258+
func TestCompileWithEsp32BundledLibraries(t *testing.T) {
259+
// Some esp cores have have bundled libraries that are optimize for that architecture,
260+
// it might happen that if the user has a library with the same name installed conflicts
261+
// can ensue and the wrong library is used for compilation, thus it fails.
262+
// This happens because for "historical" reasons these platform have their "name" key
263+
// in the "library.properties" flag suffixed with "(esp32)" or similar even though that
264+
// doesn't respect the libraries specification.
265+
// https://arduino.github.io/arduino-cli/latest/library-specification/#libraryproperties-file-format
266+
//
267+
// The reason those libraries have these suffixes is to avoid an annoying bug in the Java IDE
268+
// that would have caused the libraries that are both bundled with the core and the Java IDE to be
269+
// always marked as updatable. For more info see: https://github.com/arduino/Arduino/issues/4189
270+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
271+
defer env.CleanUp()
272+
273+
_, _, err := cli.Run("update")
274+
require.NoError(t, err)
275+
276+
// Update index with esp32 core and install it
277+
url := "https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json"
278+
coreVersion := "1.0.6"
279+
_, _, err = cli.Run("core", "update-index", "--additional-urls="+url)
280+
require.NoError(t, err)
281+
_, _, err = cli.Run("core", "install", "esp32:esp32@"+coreVersion, "--additional-urls="+url)
282+
require.NoError(t, err)
283+
284+
// Install a library with the same name as one bundled with the core
285+
_, _, err = cli.Run("lib", "install", "SD")
286+
require.NoError(t, err)
287+
288+
sketchPath := cli.CopySketch("sketch_with_sd_library")
289+
fqbn := "esp32:esp32:esp32"
290+
291+
stdout, _, err := cli.Run("compile", "-b", fqbn, sketchPath.String(), "--verbose")
292+
require.Error(t, err)
293+
294+
coreBundledLibPath := cli.DataDir().Join("packages", "esp32", "hardware", "esp32", coreVersion, "libraries", "SD")
295+
cliInstalledLibPath := cli.SketchbookDir().Join("libraries", "SD")
296+
expectedOutput := [3]string{
297+
"Multiple libraries were found for \"OneWire.h\"",
298+
" Used: " + coreBundledLibPath.String(),
299+
" Not used: " + cliInstalledLibPath.String(),
300+
}
301+
require.NotContains(t, string(stdout), expectedOutput[0]+"\n"+expectedOutput[1]+"\n"+expectedOutput[2]+"\n")
302+
}

test/test_compile_part_4.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -50,45 +50,6 @@ def test_compile_manually_installed_platform_using_boards_local_txt(run_command,
5050
assert run_command(["compile", "--clean", "-b", fqbn, sketch_path])
5151

5252

53-
def test_compile_with_esp32_bundled_libraries(run_command, data_dir, copy_sketch):
54-
# Some esp cores have have bundled libraries that are optimize for that architecture,
55-
# it might happen that if the user has a library with the same name installed conflicts
56-
# can ensue and the wrong library is used for compilation, thus it fails.
57-
# This happens because for "historical" reasons these platform have their "name" key
58-
# in the "library.properties" flag suffixed with "(esp32)" or similar even though that
59-
# doesn't respect the libraries specification.
60-
# https://arduino.github.io/arduino-cli/latest/library-specification/#libraryproperties-file-format
61-
#
62-
# The reason those libraries have these suffixes is to avoid an annoying bug in the Java IDE
63-
# that would have caused the libraries that are both bundled with the core and the Java IDE to be
64-
# always marked as updatable. For more info see: https://github.com/arduino/Arduino/issues/4189
65-
assert run_command(["update"])
66-
67-
# Update index with esp32 core and install it
68-
url = "https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json"
69-
core_version = "1.0.6"
70-
assert run_command(["core", "update-index", f"--additional-urls={url}"])
71-
assert run_command(["core", "install", f"esp32:esp32@{core_version}", f"--additional-urls={url}"])
72-
73-
# Install a library with the same name as one bundled with the core
74-
assert run_command(["lib", "install", "SD"])
75-
76-
sketch_path = copy_sketch("sketch_with_sd_library")
77-
fqbn = "esp32:esp32:esp32"
78-
79-
res = run_command(["compile", "-b", fqbn, sketch_path, "--verbose"])
80-
assert res.failed
81-
82-
core_bundled_lib_path = Path(data_dir, "packages", "esp32", "hardware", "esp32", core_version, "libraries", "SD")
83-
cli_installed_lib_path = Path(data_dir, "libraries", "SD")
84-
expected_output = [
85-
'Multiple libraries were found for "SD.h"',
86-
f" Used: {core_bundled_lib_path}",
87-
f" Not used: {cli_installed_lib_path}",
88-
]
89-
assert "\n".join(expected_output) not in res.stdout
90-
91-
9253
def test_compile_with_esp8266_bundled_libraries(run_command, data_dir, copy_sketch):
9354
# Some esp cores have have bundled libraries that are optimize for that architecture,
9455
# it might happen that if the user has a library with the same name installed conflicts

0 commit comments

Comments
 (0)