Skip to content

Commit 0bcb1ff

Browse files
committed
Add check for invalid sketch src subfolder name case
1 parent 833dae0 commit 0bcb1ff

File tree

7 files changed

+44
-0
lines changed

7 files changed

+44
-0
lines changed

Diff for: check/checkconfigurations/checkconfigurations.go

+15
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,21 @@ var configurations = []Type{
10611061
ErrorModes: []checkmode.Type{checkmode.Default},
10621062
CheckFunction: checkfunctions.RecursiveLibraryWithUtilityFolder,
10631063
},
1064+
{
1065+
ProjectType: projecttype.Sketch,
1066+
Category: "structure",
1067+
Subcategory: "",
1068+
ID: "",
1069+
Brief: "incorrect src folder case",
1070+
Description: "",
1071+
MessageTemplate: "Incorrect src folder case. This will cause the source files under it to not be compiled on case-sensitive operating systems. See: https://arduino.github.io/arduino-cli/latest/sketch-specification/#src-subfolder",
1072+
DisableModes: nil,
1073+
EnableModes: []checkmode.Type{checkmode.Default},
1074+
InfoModes: nil,
1075+
WarningModes: []checkmode.Type{checkmode.Default},
1076+
ErrorModes: []checkmode.Type{checkmode.Strict},
1077+
CheckFunction: checkfunctions.IncorrectSketchSrcFolderNameCase,
1078+
},
10641079
{
10651080
ProjectType: projecttype.Sketch,
10661081
Category: "structure",

Diff for: check/checkfunctions/sketch.go

+16
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@ import (
2525
"github.com/arduino/arduino-check/project/sketch"
2626
)
2727

28+
// IncorrectSketchSrcFolderNameCase checks for incorrect case of src subfolder name in recursive format libraries.
29+
func IncorrectSketchSrcFolderNameCase() (result checkresult.Type, output string) {
30+
directoryListing, err := checkdata.ProjectPath().ReadDir()
31+
if err != nil {
32+
panic(err)
33+
}
34+
directoryListing.FilterDirs()
35+
36+
path, found := containsIncorrectPathBaseCase(directoryListing, "src")
37+
if found {
38+
return checkresult.Fail, path.String()
39+
}
40+
41+
return checkresult.Pass, ""
42+
}
43+
2844
// ProhibitedCharactersInSketchFileName checks for prohibited characters in the sketch file names.
2945
func ProhibitedCharactersInSketchFileName() (result checkresult.Type, output string) {
3046
directoryListing, _ := checkdata.ProjectPath().ReadDir()

Diff for: check/checkfunctions/sketch_test.go

+9
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ func checkSketchCheckFunction(checkFunction Type, testTables []sketchCheckFuncti
6060
}
6161
}
6262

63+
func TestIncorrectSketchSrcFolderNameCase(t *testing.T) {
64+
testTables := []sketchCheckFunctionTestTable{
65+
{"Incorrect case", "IncorrectSrcFolderNameCase", checkresult.Fail, ""},
66+
{"Correct case", "Valid", checkresult.Pass, ""},
67+
}
68+
69+
checkSketchCheckFunction(IncorrectSketchSrcFolderNameCase, testTables, t)
70+
}
71+
6372
func TestProhibitedCharactersInSketchFileName(t *testing.T) {
6473
testTables := []sketchCheckFunctionTestTable{
6574
{"Has prohibited characters", "ProhibitedCharactersInFileName", checkresult.Fail, "^Prohibited CharactersInFileName.h$"},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
void setup() {}
2+
void loop() {}

Diff for: check/checkfunctions/testdata/sketches/IncorrectSrcFolderNameCase/SRC/src.cpp

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
void setup() {}
2+
void loop() {}

Diff for: check/checkfunctions/testdata/sketches/SrcSubfolder/src/src.cpp

Whitespace-only changes.

0 commit comments

Comments
 (0)