@@ -38,14 +38,14 @@ func init() {
38
38
schemasPath = paths .New (workingDirectory , ".." , ".." , "etc" , "schemas" )
39
39
}
40
40
41
- type checkFunctionTestTable struct {
41
+ type libraryCheckFunctionTestTable struct {
42
42
testName string
43
43
libraryFolderName string
44
44
expectedCheckResult checkresult.Type
45
45
expectedOutputQuery string
46
46
}
47
47
48
- func checkCheckFunction (checkFunction Type , testTables []checkFunctionTestTable , t * testing.T ) {
48
+ func checkLibraryCheckFunction (checkFunction Type , testTables []libraryCheckFunctionTestTable , t * testing.T ) {
49
49
for _ , testTable := range testTables {
50
50
expectedOutputRegexp := regexp .MustCompile (testTable .expectedOutputQuery )
51
51
@@ -64,124 +64,124 @@ func checkCheckFunction(checkFunction Type, testTables []checkFunctionTestTable,
64
64
}
65
65
66
66
func TestLibraryPropertiesNameFieldMissingOfficialPrefix (t * testing.T ) {
67
- testTables := []checkFunctionTestTable {
67
+ testTables := []libraryCheckFunctionTestTable {
68
68
{"Unable to load" , "InvalidLibraryProperties" , checkresult .NotRun , "" },
69
69
{"Not defined" , "MissingFields" , checkresult .NotRun , "" },
70
70
{"Correct prefix" , "Arduino_Official" , checkresult .Pass , "" },
71
71
{"Incorrect prefix" , "Recursive" , checkresult .Fail , "^Recursive$" },
72
72
}
73
73
74
- checkCheckFunction (LibraryPropertiesNameFieldMissingOfficialPrefix , testTables , t )
74
+ checkLibraryCheckFunction (LibraryPropertiesNameFieldMissingOfficialPrefix , testTables , t )
75
75
}
76
76
77
77
func TestLibraryPropertiesNameFieldDuplicate (t * testing.T ) {
78
- testTables := []checkFunctionTestTable {
78
+ testTables := []libraryCheckFunctionTestTable {
79
79
{"Unable to load" , "InvalidLibraryProperties" , checkresult .NotRun , "" },
80
80
{"Duplicate" , "Indexed" , checkresult .Fail , "^Servo$" },
81
81
{"Not duplicate" , "NotIndexed" , checkresult .Pass , "" },
82
82
}
83
83
84
- checkCheckFunction (LibraryPropertiesNameFieldDuplicate , testTables , t )
84
+ checkLibraryCheckFunction (LibraryPropertiesNameFieldDuplicate , testTables , t )
85
85
}
86
86
87
87
func TestLibraryPropertiesNameFieldNotInIndex (t * testing.T ) {
88
- testTables := []checkFunctionTestTable {
88
+ testTables := []libraryCheckFunctionTestTable {
89
89
{"Unable to load" , "InvalidLibraryProperties" , checkresult .NotRun , "" },
90
90
{"In index" , "Indexed" , checkresult .Pass , "" },
91
91
{"Not in index" , "NotIndexed" , checkresult .Fail , "^NotIndexed$" },
92
92
}
93
93
94
- checkCheckFunction (LibraryPropertiesNameFieldNotInIndex , testTables , t )
94
+ checkLibraryCheckFunction (LibraryPropertiesNameFieldNotInIndex , testTables , t )
95
95
}
96
96
97
97
func TestLibraryPropertiesNameFieldHeaderMismatch (t * testing.T ) {
98
- testTables := []checkFunctionTestTable {
98
+ testTables := []libraryCheckFunctionTestTable {
99
99
{"Unable to load" , "InvalidLibraryProperties" , checkresult .NotRun , "" },
100
100
{"Mismatch" , "NameHeaderMismatch" , checkresult .Fail , "^NameHeaderMismatch.h$" },
101
101
{"Match" , "Recursive" , checkresult .Pass , "" },
102
102
}
103
103
104
- checkCheckFunction (LibraryPropertiesNameFieldHeaderMismatch , testTables , t )
104
+ checkLibraryCheckFunction (LibraryPropertiesNameFieldHeaderMismatch , testTables , t )
105
105
}
106
106
107
107
func TestLibraryPropertiesSentenceFieldSpellCheck (t * testing.T ) {
108
- testTables := []checkFunctionTestTable {
108
+ testTables := []libraryCheckFunctionTestTable {
109
109
{"Unable to load" , "InvalidLibraryProperties" , checkresult .NotRun , "" },
110
110
{"Not defined" , "MissingFields" , checkresult .NotRun , "" },
111
111
{"Misspelled word" , "MisspelledSentenceParagraphValue" , checkresult .Fail , "^grill broccoli now$" },
112
112
{"Correct spelling" , "Recursive" , checkresult .Pass , "" },
113
113
}
114
114
115
- checkCheckFunction (LibraryPropertiesSentenceFieldSpellCheck , testTables , t )
115
+ checkLibraryCheckFunction (LibraryPropertiesSentenceFieldSpellCheck , testTables , t )
116
116
}
117
117
118
118
func TestLibraryPropertiesParagraphFieldSpellCheck (t * testing.T ) {
119
- testTables := []checkFunctionTestTable {
119
+ testTables := []libraryCheckFunctionTestTable {
120
120
{"Unable to load" , "InvalidLibraryProperties" , checkresult .NotRun , "" },
121
121
{"Not defined" , "MissingFields" , checkresult .NotRun , "" },
122
122
{"Misspelled word" , "MisspelledSentenceParagraphValue" , checkresult .Fail , "^There is a zebra$" },
123
123
{"Correct spelling" , "Recursive" , checkresult .Pass , "" },
124
124
}
125
125
126
- checkCheckFunction (LibraryPropertiesParagraphFieldSpellCheck , testTables , t )
126
+ checkLibraryCheckFunction (LibraryPropertiesParagraphFieldSpellCheck , testTables , t )
127
127
}
128
128
129
129
func TestLibraryPropertiesParagraphFieldRepeatsSentence (t * testing.T ) {
130
- testTables := []checkFunctionTestTable {
130
+ testTables := []libraryCheckFunctionTestTable {
131
131
{"Unable to load" , "InvalidLibraryProperties" , checkresult .NotRun , "" },
132
132
{"Repeat" , "ParagraphRepeatsSentence" , checkresult .Fail , "" },
133
133
{"No repeat" , "Recursive" , checkresult .Pass , "" },
134
134
}
135
135
136
- checkCheckFunction (LibraryPropertiesParagraphFieldRepeatsSentence , testTables , t )
136
+ checkLibraryCheckFunction (LibraryPropertiesParagraphFieldRepeatsSentence , testTables , t )
137
137
}
138
138
func TestLibraryPropertiesUrlFieldDeadLink (t * testing.T ) {
139
- testTables := []checkFunctionTestTable {
139
+ testTables := []libraryCheckFunctionTestTable {
140
140
{"Unable to load" , "InvalidLibraryProperties" , checkresult .NotRun , "" },
141
141
{"Not defined" , "MissingFields" , checkresult .NotRun , "" },
142
142
{"Bad URL" , "BadURL" , checkresult .Fail , "^Get \" http://invalid/\" : dial tcp: lookup invalid:" },
143
143
{"HTTP error 404" , "URL404" , checkresult .Fail , "^404 Not Found$" },
144
144
{"Good URL" , "Recursive" , checkresult .Pass , "" },
145
145
}
146
146
147
- checkCheckFunction (LibraryPropertiesUrlFieldDeadLink , testTables , t )
147
+ checkLibraryCheckFunction (LibraryPropertiesUrlFieldDeadLink , testTables , t )
148
148
}
149
149
150
150
func TestLibraryPropertiesDependsFieldNotInIndex (t * testing.T ) {
151
- testTables := []checkFunctionTestTable {
151
+ testTables := []libraryCheckFunctionTestTable {
152
152
{"Unable to load" , "InvalidLibraryProperties" , checkresult .NotRun , "" },
153
153
{"Dependency not in index" , "DependsNotIndexed" , checkresult .Fail , "^NotIndexed$" },
154
154
{"Dependency in index" , "DependsIndexed" , checkresult .Pass , "" },
155
155
{"No depends" , "NoDepends" , checkresult .NotRun , "" },
156
156
}
157
157
158
- checkCheckFunction (LibraryPropertiesDependsFieldNotInIndex , testTables , t )
158
+ checkLibraryCheckFunction (LibraryPropertiesDependsFieldNotInIndex , testTables , t )
159
159
}
160
160
161
161
func TestLibraryPropertiesDotALinkageFieldTrueWithFlatLayout (t * testing.T ) {
162
- testTables := []checkFunctionTestTable {
162
+ testTables := []libraryCheckFunctionTestTable {
163
163
{"Unable to load" , "InvalidLibraryProperties" , checkresult .NotRun , "" },
164
164
{"Not defined" , "MissingFields" , checkresult .NotRun , "" },
165
165
{"Flat layout" , "DotALinkageFlat" , checkresult .Fail , "" },
166
166
{"Recursive layout" , "DotALinkage" , checkresult .Pass , "" },
167
167
}
168
168
169
- checkCheckFunction (LibraryPropertiesDotALinkageFieldTrueWithFlatLayout , testTables , t )
169
+ checkLibraryCheckFunction (LibraryPropertiesDotALinkageFieldTrueWithFlatLayout , testTables , t )
170
170
}
171
171
172
172
func TestLibraryPropertiesIncludesFieldItemNotFound (t * testing.T ) {
173
- testTables := []checkFunctionTestTable {
173
+ testTables := []libraryCheckFunctionTestTable {
174
174
{"Unable to load" , "InvalidLibraryProperties" , checkresult .NotRun , "" },
175
175
{"Not defined" , "MissingFields" , checkresult .NotRun , "" },
176
176
{"Missing includes" , "MissingIncludes" , checkresult .Fail , "^Nonexistent.h$" },
177
177
{"Present includes" , "Recursive" , checkresult .Pass , "" },
178
178
}
179
179
180
- checkCheckFunction (LibraryPropertiesIncludesFieldItemNotFound , testTables , t )
180
+ checkLibraryCheckFunction (LibraryPropertiesIncludesFieldItemNotFound , testTables , t )
181
181
}
182
182
183
183
func TestLibraryPropertiesPrecompiledFieldEnabledWithFlatLayout (t * testing.T ) {
184
- testTables := []checkFunctionTestTable {
184
+ testTables := []libraryCheckFunctionTestTable {
185
185
{"Unable to load" , "InvalidLibraryProperties" , checkresult .NotRun , "" },
186
186
{"Not defined" , "MissingFields" , checkresult .NotRun , "" },
187
187
{"Flat layout" , "PrecompiledFlat" , checkresult .Fail , "^true$" },
@@ -190,16 +190,16 @@ func TestLibraryPropertiesPrecompiledFieldEnabledWithFlatLayout(t *testing.T) {
190
190
{"Flat, not precompiled" , "NotPrecompiledFlat" , checkresult .NotRun , "" },
191
191
}
192
192
193
- checkCheckFunction (LibraryPropertiesPrecompiledFieldEnabledWithFlatLayout , testTables , t )
193
+ checkLibraryCheckFunction (LibraryPropertiesPrecompiledFieldEnabledWithFlatLayout , testTables , t )
194
194
}
195
195
196
196
func TestLibraryHasSubmodule (t * testing.T ) {
197
- testTables := []checkFunctionTestTable {
197
+ testTables := []libraryCheckFunctionTestTable {
198
198
{"Has submodule" , "Submodule" , checkresult .Fail , "" },
199
199
{"No submodule" , "Recursive" , checkresult .Pass , "" },
200
200
}
201
201
202
- checkCheckFunction (LibraryHasSubmodule , testTables , t )
202
+ checkLibraryCheckFunction (LibraryHasSubmodule , testTables , t )
203
203
}
204
204
205
205
func TestLibraryContainsSymlinks (t * testing.T ) {
@@ -210,36 +210,44 @@ func TestLibraryContainsSymlinks(t *testing.T) {
210
210
require .Nil (t , err , "This test must be run as administrator on Windows to have symlink creation privilege." )
211
211
defer symlinkPath .RemoveAll () // clean up
212
212
213
- testTables := []checkFunctionTestTable {
213
+ testTables := []libraryCheckFunctionTestTable {
214
214
{"Has symlink" , testLibrary , checkresult .Fail , "" },
215
215
}
216
216
217
- checkCheckFunction (LibraryContainsSymlinks , testTables , t )
217
+ checkLibraryCheckFunction (LibraryContainsSymlinks , testTables , t )
218
218
219
219
err = symlinkPath .RemoveAll ()
220
220
require .Nil (t , err )
221
221
222
- testTables = []checkFunctionTestTable {
222
+ testTables = []libraryCheckFunctionTestTable {
223
223
{"No symlink" , testLibrary , checkresult .Pass , "" },
224
224
}
225
225
226
- checkCheckFunction (LibraryContainsSymlinks , testTables , t )
226
+ checkLibraryCheckFunction (LibraryContainsSymlinks , testTables , t )
227
227
}
228
228
229
229
func TestLibraryHasDotDevelopmentFile (t * testing.T ) {
230
- testTables := []checkFunctionTestTable {
230
+ testTables := []libraryCheckFunctionTestTable {
231
231
{"Has .development file" , "DotDevelopment" , checkresult .Fail , "" },
232
232
{"No .development file" , "Recursive" , checkresult .Pass , "" },
233
233
}
234
234
235
- checkCheckFunction (LibraryHasDotDevelopmentFile , testTables , t )
235
+ checkLibraryCheckFunction (LibraryHasDotDevelopmentFile , testTables , t )
236
236
}
237
237
238
238
func TestLibraryHasExe (t * testing.T ) {
239
- testTables := []checkFunctionTestTable {
239
+ testTables := []libraryCheckFunctionTestTable {
240
240
{"Has .exe file" , "Exe" , checkresult .Fail , "" },
241
241
{"No .exe files" , "Recursive" , checkresult .Pass , "" },
242
242
}
243
243
244
- checkCheckFunction (LibraryHasExe , testTables , t )
244
+ checkLibraryCheckFunction (LibraryHasExe , testTables , t )
245
+ }
246
+ func TestProhibitedCharactersInLibraryFolderName (t * testing.T ) {
247
+ testTables := []libraryCheckFunctionTestTable {
248
+ {"Has prohibited characters" , "Prohibited CharactersInFolderName" , checkresult .Fail , "" },
249
+ {"No prohibited characters" , "Recursive" , checkresult .Pass , "" },
250
+ }
251
+
252
+ checkLibraryCheckFunction (ProhibitedCharactersInLibraryFolderName , testTables , t )
245
253
}
0 commit comments