Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix example file causing panic #752

Merged
merged 3 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
2 changes: 1 addition & 1 deletion internal/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
umbynos marked this conversation as resolved.
Show resolved Hide resolved
directoryListing, err := subprojectsPath.ReadDir()
if err != nil {
panic(err)
Expand Down
16 changes: 16 additions & 0 deletions internal/project/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Loading