Skip to content

Commit 9ca8a7b

Browse files
Migrate TestCompileWithEsp8266BundledLibraries from test_compile_part_4.py to compile_part_4_test.go
1 parent e072c98 commit 9ca8a7b

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

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)