From 8ebca9f121574e26fb0d376c05d22538b31411fe Mon Sep 17 00:00:00 2001 From: Alessio Perugini Date: Tue, 17 Dec 2024 16:31:00 +0100 Subject: [PATCH 1/2] test that the export binaries should not fail if tries to copy a dir --- .../integrationtest/compile_1/compile_test.go | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/internal/integrationtest/compile_1/compile_test.go b/internal/integrationtest/compile_1/compile_test.go index 3f09906310d..fb726bc5c12 100644 --- a/internal/integrationtest/compile_1/compile_test.go +++ b/internal/integrationtest/compile_1/compile_test.go @@ -1321,3 +1321,46 @@ func buildWithCustomBuildPathAndOUtputDirFlag(t *testing.T, env *integrationtest require.NotEmpty(t, content) } } + +func TestCompileWithOutputDirFlagIgnoringFoldersCreatedByEsp32RainMakerLib(t *testing.T) { + 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" + _, _, err = cli.Run("core", "update-index", "--additional-urls="+url) + require.NoError(t, err) + _, _, err = cli.Run("core", "install", "esp32:esp32@3.0.7", "--additional-urls="+url) + require.NoError(t, err) + + sketchName := "RainMakerSketch" + sketchPath := cli.SketchbookDir().Join(sketchName) + _, _, err = cli.Run("sketch", "new", sketchPath.String()) + require.NoError(t, err) + + // When importing the `RMaker` library, the esp32 core produces in output a folder, + // containing all the binaries exported. The name of the folder matches the sketch name. + // In out case: + // cache-dir/ + // |- RainMakerSketch.ino/ <--- This should be ignored + // |- RainMakerSketch.ino.uf2 + // |- RainMakerSketch.ino.bin + // |- ... + err = sketchPath.Join(sketchName + ".ino").WriteFile([]byte(` + #include "RMaker.h" + void setup() { } + void loop() { }`, + )) + require.NoError(t, err) + + buildPath := cli.DataDir().Join("test_dir", "build_dir") + outputDir := cli.SketchbookDir().Join("test_dir", "output_dir") + _, stderr, err := cli.Run("compile", "-b", "esp32:esp32:esp32", sketchPath.String(), "--build-path", buildPath.String(), "--output-dir", outputDir.String()) + require.NoError(t, err) + require.NotContains(t, stderr, []byte("Error during build: Error copying output file")) + require.DirExists(t, buildPath.Join(sketchName+".ino").String()) + require.NoDirExists(t, outputDir.Join(sketchName+".ino").String()) +} From 05f1851d8f7ed4877be864de1be398742d4bc93e Mon Sep 17 00:00:00 2001 From: Alessio Perugini Date: Tue, 17 Dec 2024 16:53:52 +0100 Subject: [PATCH 2/2] compile: fix export binaries when trying to copy a folder --- commands/service_compile.go | 1 + 1 file changed, 1 insertion(+) diff --git a/commands/service_compile.go b/commands/service_compile.go index 61f8e1ef1d7..a71195382cf 100644 --- a/commands/service_compile.go +++ b/commands/service_compile.go @@ -404,6 +404,7 @@ func (s *arduinoCoreServerImpl) Compile(req *rpc.CompileRequest, stream rpc.Ardu return &cmderrors.PermissionDeniedError{Message: i18n.Tr("Error reading build directory"), Cause: err} } buildFiles.FilterPrefix(baseName) + buildFiles.FilterOutDirs() for _, buildFile := range buildFiles { exportedFile := exportPath.Join(buildFile.Base()) logrus.WithField("src", buildFile).WithField("dest", exportedFile).Trace("Copying artifact.") pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy