From 42d1102030704097174e964d0a8bc062846279c8 Mon Sep 17 00:00:00 2001 From: Umberto Baldi Date: Thu, 25 Jul 2024 15:55:20 +0200 Subject: [PATCH 1/3] add test to highlight the bug --- internal/project/project_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/project/project_test.go b/internal/project/project_test.go index aad77e65..787c0f05 100644 --- a/internal/project/project_test.go +++ b/internal/project/project_test.go @@ -429,3 +429,19 @@ func TestFindProjects(t *testing.T) { } } } + +func TestExamplefile(t *testing.T) { + // Set up directory structure of test library. + libraryPath, err := paths.TempDir().MkTempDir("TestExampleFile") + defer libraryPath.RemoveAll() // Clean up after the test. + require.Nil(t, err) + err = libraryPath.Join("TestExample.h").WriteFile([]byte{}) + require.Nil(t, err) + // Create an example file in the library folder. This should not cause a panic and should be ignored since it's not a folder containing the examples + err = libraryPath.Join("example").WriteFile([]byte{}) + require.Nil(t, err) + + configuration.Initialize(test.ConfigurationFlags(), []string{libraryPath.String()}) + + assert.NotPanics(t, func() { FindProjects() }, "Example file should not cause panic") +} From 5b01d7d77d83a5c27d45eeded3fc1c39266f2246 Mon Sep 17 00:00:00 2001 From: Umberto Baldi Date: Thu, 25 Jul 2024 15:57:01 +0200 Subject: [PATCH 2/3] fix the bug. Don't panic if there is an example file, just ignore it --- internal/project/project.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/project/project.go b/internal/project/project.go index d0f43a9f..493a5861 100644 --- a/internal/project/project.go +++ b/internal/project/project.go @@ -193,7 +193,7 @@ func findSubprojects(superproject Type, apexSuperprojectType projecttype.Type) [ var immediateSubprojects []Type for _, subprojectsFolderName := range subprojectsFolderNames { subprojectsPath := superproject.Path.Join(subprojectsFolderName) - if subprojectsPath.Exist() { + if subprojectsPath.Exist() && subprojectsPath.IsDir() { directoryListing, err := subprojectsPath.ReadDir() if err != nil { panic(err) From a4d7dd9b07d4f970d5abc54fb5eef53be96a999a Mon Sep 17 00:00:00 2001 From: Umberto Baldi <34278123+umbynos@users.noreply.github.com> Date: Thu, 25 Jul 2024 16:51:55 +0200 Subject: [PATCH 3/3] Update internal/project/project.go Co-authored-by: MatteoPologruto <109663225+MatteoPologruto@users.noreply.github.com> --- internal/project/project.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/project/project.go b/internal/project/project.go index 493a5861..631b4674 100644 --- a/internal/project/project.go +++ b/internal/project/project.go @@ -193,7 +193,7 @@ func findSubprojects(superproject Type, apexSuperprojectType projecttype.Type) [ var immediateSubprojects []Type for _, subprojectsFolderName := range subprojectsFolderNames { subprojectsPath := superproject.Path.Join(subprojectsFolderName) - if subprojectsPath.Exist() && subprojectsPath.IsDir() { + if subprojectsPath.IsDir() { directoryListing, err := subprojectsPath.ReadDir() if err != nil { panic(err) 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