Skip to content

Commit 4038740

Browse files
Migrate TestCompileWithEsp8266BundledLibraries from test_compile_part_4.py to compile_part_4_test.go
1 parent d935361 commit 4038740

File tree

2 files changed

+46
-41
lines changed

2 files changed

+46
-41
lines changed

internal/integrationtest/compile/compile_part_4_test.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,3 +300,49 @@ func TestCompileWithEsp32BundledLibraries(t *testing.T) {
300300
}
301301
require.NotContains(t, string(stdout), expectedOutput[0]+"\n"+expectedOutput[1]+"\n"+expectedOutput[2]+"\n")
302302
}
303+
304+
func TestCompileWithEsp8266BundledLibraries(t *testing.T) {
305+
// Some esp cores have have bundled libraries that are optimize for that architecture,
306+
// it might happen that if the user has a library with the same name installed conflicts
307+
// can ensue and the wrong library is used for compilation, thus it fails.
308+
// This happens because for "historical" reasons these platform have their "name" key
309+
// in the "library.properties" flag suffixed with "(esp32)" or similar even though that
310+
// doesn't respect the libraries specification.
311+
// https://arduino.github.io/arduino-cli/latest/library-specification/#libraryproperties-file-format
312+
//
313+
// The reason those libraries have these suffixes is to avoid an annoying bug in the Java IDE
314+
// that would have caused the libraries that are both bundled with the core and the Java IDE to be
315+
// always marked as updatable. For more info see: https://github.com/arduino/Arduino/issues/4189
316+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
317+
defer env.CleanUp()
318+
319+
_, _, err := cli.Run("update")
320+
require.NoError(t, err)
321+
322+
// Update index with esp8266 core and install it
323+
url := "http://arduino.esp8266.com/stable/package_esp8266com_index.json"
324+
coreVersion := "2.7.4"
325+
_, _, err = cli.Run("core", "update-index", "--additional-urls="+url)
326+
require.NoError(t, err)
327+
_, _, err = cli.Run("core", "install", "esp8266:esp8266@"+coreVersion, "--additional-urls="+url)
328+
require.NoError(t, err)
329+
330+
// Install a library with the same name as one bundled with the core
331+
_, _, err = cli.Run("lib", "install", "SD")
332+
require.NoError(t, err)
333+
334+
sketchPath := cli.CopySketch("sketch_with_sd_library")
335+
fqbn := "esp8266:esp8266:generic"
336+
337+
stdout, _, err := cli.Run("compile", "-b", fqbn, sketchPath.String(), "--verbose")
338+
require.Error(t, err)
339+
340+
coreBundledLibPath := cli.DataDir().Join("packages", "esp8266", "hardware", "esp8266", coreVersion, "libraries", "SD")
341+
cliInstalledLibPath := cli.SketchbookDir().Join("libraries", "SD")
342+
expectedOutput := [3]string{
343+
"Multiple libraries were found for \"OneWire.h\"",
344+
" Used: " + coreBundledLibPath.String(),
345+
" Not used: " + cliInstalledLibPath.String(),
346+
}
347+
require.NotContains(t, string(stdout), expectedOutput[0]+"\n"+expectedOutput[1]+"\n"+expectedOutput[2]+"\n")
348+
}

test/test_compile_part_4.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -50,47 +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_esp8266_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 esp8266 core and install it
68-
url = "http://arduino.esp8266.com/stable/package_esp8266com_index.json"
69-
core_version = "2.7.4"
70-
assert run_command(["core", "update-index", f"--additional-urls={url}"])
71-
assert run_command(["core", "install", f"esp8266:esp8266@{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 = "esp8266:esp8266:generic"
78-
79-
res = run_command(["compile", "-b", fqbn, sketch_path, "--verbose"])
80-
assert res.failed
81-
82-
core_bundled_lib_path = Path(
83-
data_dir, "packages", "esp8266", "hardware", "esp8266", core_version, "libraries", "SD"
84-
)
85-
cli_installed_lib_path = Path(data_dir, "libraries", "SD")
86-
expected_output = [
87-
'Multiple libraries were found for "SD.h"',
88-
f" Used: {core_bundled_lib_path}",
89-
f" Not used: {cli_installed_lib_path}",
90-
]
91-
assert "\n".join(expected_output) not in res.stdout
92-
93-
9453
def test_generate_compile_commands_json_resilience(run_command, data_dir, copy_sketch):
9554
assert run_command(["update"])
9655

0 commit comments

Comments
 (0)