Skip to content

Commit ae4be20

Browse files
committed
Add check for invalid boards.txt format
1 parent 5dc08e0 commit ae4be20

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

Diff for: check/checkconfigurations/checkconfigurations.go

+15
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,21 @@ var configurations = []Type{
11661166
ErrorModes: []checkmode.Type{checkmode.Default},
11671167
CheckFunction: checkfunctions.BoardsTxtMissing,
11681168
},
1169+
{
1170+
ProjectType: projecttype.Platform,
1171+
Category: "configuration files",
1172+
Subcategory: "boards.txt",
1173+
ID: "",
1174+
Brief: "Invalid boards.txt",
1175+
Description: "",
1176+
MessageTemplate: "boards.txt has an invalid format: {{.}}",
1177+
DisableModes: nil,
1178+
EnableModes: []checkmode.Type{checkmode.Default},
1179+
InfoModes: nil,
1180+
WarningModes: nil,
1181+
ErrorModes: []checkmode.Type{checkmode.Default},
1182+
CheckFunction: checkfunctions.BoardsTxtFormat,
1183+
},
11691184
{
11701185
ProjectType: projecttype.PackageIndex,
11711186
Category: "data",

Diff for: check/checkfunctions/platform.go

+12
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,15 @@ func BoardsTxtMissing() (result checkresult.Type, output string) {
3737
return checkresult.Fail, boardsTxtPath.String()
3838
}
3939

40+
// BoardsTxtFormat checks for invalid boards.txt format.
41+
func BoardsTxtFormat() (result checkresult.Type, output string) {
42+
if !checkdata.ProjectPath().Join("boards.txt").Exist() {
43+
return checkresult.NotRun, "boards.txt missing"
44+
}
45+
46+
if checkdata.BoardsTxtLoadError() == nil {
47+
return checkresult.Pass, ""
48+
}
49+
50+
return checkresult.Fail, checkdata.BoardsTxtLoadError().Error()
51+
}

Diff for: check/checkfunctions/platform_test.go

+9
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,12 @@ func TestBoardsTxtMissing(t *testing.T) {
7171
checkPlatformCheckFunction(BoardsTxtMissing, testTables, t)
7272
}
7373

74+
func TestBoardsTxtFormat(t *testing.T) {
75+
testTables := []platformCheckFunctionTestTable{
76+
{"Missing", "missing-boards.txt", checkresult.NotRun, ""},
77+
{"Valid", "valid-boards.txt", checkresult.Pass, ""},
78+
{"Invalid", "invalid-boards.txt", checkresult.Fail, ""},
79+
}
80+
81+
checkPlatformCheckFunction(BoardsTxtFormat, testTables, t)
82+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This makes the format invalid

0 commit comments

Comments
 (0)