Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
44981a2
Migrate TestCompileWithLibrary from test_compile_part_4.py to compile…
MatteoPologruto Sep 30, 2022
c6ea437
Migrate TestCompileWithLibraryPriority from test_compile_part_4.py to…
MatteoPologruto Sep 30, 2022
560baa3
Migrate TestRecompileWithDifferentLibrary from test_compile_part_4.py…
MatteoPologruto Sep 30, 2022
266723e
Migrate TestCompileWithConflictingLibrariesInclude from test_compile_…
MatteoPologruto Sep 30, 2022
28d1020
Migrate TestCompileWithInvalidBuildOptionJson from test_compile_part_…
MatteoPologruto Sep 30, 2022
e072c98
Migrate TestCompileWithEsp32BundledLibraries from test_compile_part_4…
MatteoPologruto Sep 30, 2022
9ca8a7b
Migrate TestCompileWithEsp8266BundledLibraries from test_compile_part…
MatteoPologruto Sep 30, 2022
116bfd9
Migrate TestGenerateCompileCommandsJsonResilience from test_compile_p…
MatteoPologruto Sep 30, 2022
53fb571
Migrate TestCompileSketchWithTppFileInclude from test_compile_part_4.…
MatteoPologruto Sep 30, 2022
bfacc80
Migrate TestCompileSketchWithIppFileInclude from test_compile_part_4.…
MatteoPologruto Sep 30, 2022
34b9f78
Migrate TestCompileWithoutUploadAndFqbn from test_compile_part_4.py t…
MatteoPologruto Sep 30, 2022
2b2f491
Migrate TestCompileNonInstalledPlatformWithWrongPackagerAndArch from …
MatteoPologruto Sep 30, 2022
79961f1
Migrate TestCompileWithKnownPlatformNotInstalled from test_compile_pa…
MatteoPologruto Sep 30, 2022
0e32825
Migrate TestCompileManuallyInstalledPlatformUsingBoardsLocalTxt from …
MatteoPologruto Oct 5, 2022
9cc05ac
Migrate TestCompileWithRelativeBuildPath from test_compile_part_4.py …
MatteoPologruto Oct 5, 2022
d145c30
Migrate TestCompileWithFakeSecureBootCore to compile_part_4_test.go a…
MatteoPologruto Oct 6, 2022
517a54e
Rearrange compile tests to share the same environment
MatteoPologruto Oct 14, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Migrate TestCompileWithEsp32BundledLibraries from test_compile_part_4…
….py to compile_part_4_test.go
  • Loading branch information
MatteoPologruto committed Nov 10, 2022
commit e072c98f00e645bdc2de7e62f1347a84a1b55158
46 changes: 46 additions & 0 deletions internal/integrationtest/compile/compile_part_4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,49 @@ func TestCompileWithInvalidBuildOptionJson(t *testing.T) {
_, _, err = cli.Run("compile", "-b", fqbn, sketchPath.String(), "--verbose")
require.NoError(t, err)
}

func TestCompileWithEsp32BundledLibraries(t *testing.T) {
// Some esp cores have have bundled libraries that are optimize for that architecture,
// it might happen that if the user has a library with the same name installed conflicts
// can ensue and the wrong library is used for compilation, thus it fails.
// This happens because for "historical" reasons these platform have their "name" key
// in the "library.properties" flag suffixed with "(esp32)" or similar even though that
// doesn't respect the libraries specification.
// https://arduino.github.io/arduino-cli/latest/library-specification/#libraryproperties-file-format
//
// The reason those libraries have these suffixes is to avoid an annoying bug in the Java IDE
// that would have caused the libraries that are both bundled with the core and the Java IDE to be
// always marked as updatable. For more info see: https://github.com/arduino/Arduino/issues/4189
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
defer env.CleanUp()

_, _, err := cli.Run("update")
require.NoError(t, err)

// Update index with esp32 core and install it
url := "https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json"
coreVersion := "1.0.6"
_, _, err = cli.Run("core", "update-index", "--additional-urls="+url)
require.NoError(t, err)
_, _, err = cli.Run("core", "install", "esp32:esp32@"+coreVersion, "--additional-urls="+url)
require.NoError(t, err)

// Install a library with the same name as one bundled with the core
_, _, err = cli.Run("lib", "install", "SD")
require.NoError(t, err)

sketchPath := cli.CopySketch("sketch_with_sd_library")
fqbn := "esp32:esp32:esp32"

stdout, _, err := cli.Run("compile", "-b", fqbn, sketchPath.String(), "--verbose")
require.Error(t, err)

coreBundledLibPath := cli.DataDir().Join("packages", "esp32", "hardware", "esp32", coreVersion, "libraries", "SD")
cliInstalledLibPath := cli.SketchbookDir().Join("libraries", "SD")
expectedOutput := [3]string{
"Multiple libraries were found for \"OneWire.h\"",
" Used: " + coreBundledLibPath.String(),
" Not used: " + cliInstalledLibPath.String(),
}
require.NotContains(t, string(stdout), expectedOutput[0]+"\n"+expectedOutput[1]+"\n"+expectedOutput[2]+"\n")
}
39 changes: 0 additions & 39 deletions test/test_compile_part_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,45 +50,6 @@ def test_compile_manually_installed_platform_using_boards_local_txt(run_command,
assert run_command(["compile", "--clean", "-b", fqbn, sketch_path])


def test_compile_with_esp32_bundled_libraries(run_command, data_dir, copy_sketch):
# Some esp cores have have bundled libraries that are optimize for that architecture,
# it might happen that if the user has a library with the same name installed conflicts
# can ensue and the wrong library is used for compilation, thus it fails.
# This happens because for "historical" reasons these platform have their "name" key
# in the "library.properties" flag suffixed with "(esp32)" or similar even though that
# doesn't respect the libraries specification.
# https://arduino.github.io/arduino-cli/latest/library-specification/#libraryproperties-file-format
#
# The reason those libraries have these suffixes is to avoid an annoying bug in the Java IDE
# that would have caused the libraries that are both bundled with the core and the Java IDE to be
# always marked as updatable. For more info see: https://github.com/arduino/Arduino/issues/4189
assert run_command(["update"])

# Update index with esp32 core and install it
url = "https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json"
core_version = "1.0.6"
assert run_command(["core", "update-index", f"--additional-urls={url}"])
assert run_command(["core", "install", f"esp32:esp32@{core_version}", f"--additional-urls={url}"])

# Install a library with the same name as one bundled with the core
assert run_command(["lib", "install", "SD"])

sketch_path = copy_sketch("sketch_with_sd_library")
fqbn = "esp32:esp32:esp32"

res = run_command(["compile", "-b", fqbn, sketch_path, "--verbose"])
assert res.failed

core_bundled_lib_path = Path(data_dir, "packages", "esp32", "hardware", "esp32", core_version, "libraries", "SD")
cli_installed_lib_path = Path(data_dir, "libraries", "SD")
expected_output = [
'Multiple libraries were found for "SD.h"',
f" Used: {core_bundled_lib_path}",
f" Not used: {cli_installed_lib_path}",
]
assert "\n".join(expected_output) not in res.stdout


def test_compile_with_esp8266_bundled_libraries(run_command, data_dir, copy_sketch):
# Some esp cores have have bundled libraries that are optimize for that architecture,
# it might happen that if the user has a library with the same name installed conflicts
Expand Down