@@ -64,22 +64,135 @@ func checkLibraryCheckFunction(checkFunction Type, testTables []libraryCheckFunc
64
64
}
65
65
}
66
66
67
- func TestMisspelledLibraryPropertiesFileName (t * testing.T ) {
67
+ func TestLibraryInvalid (t * testing.T ) {
68
68
testTables := []libraryCheckFunctionTestTable {
69
- {"Incorrect" , "MisspelledLibraryProperties" , checkresult .Fail , "" },
70
- {"Correct" , "Recursive" , checkresult .Pass , "" },
69
+ {"Invalid library.properties" , "InvalidLibraryProperties" , checkresult .Fail , "" },
70
+ {"Invalid flat layout" , "FlatWithoutHeader" , checkresult .Fail , "" },
71
+ {"Invalid recursive layout" , "RecursiveWithoutLibraryProperties" , checkresult .Fail , "" },
72
+ {"Valid library" , "Recursive" , checkresult .Pass , "" },
71
73
}
72
74
73
- checkLibraryCheckFunction (MisspelledLibraryPropertiesFileName , testTables , t )
75
+ checkLibraryCheckFunction (LibraryInvalid , testTables , t )
74
76
}
75
77
76
- func TestIncorrectLibraryPropertiesFileNameCase (t * testing.T ) {
78
+ func TestLibraryFolderNameGTMaxLength (t * testing.T ) {
77
79
testTables := []libraryCheckFunctionTestTable {
78
- {"Incorrect " , "IncorrectLibraryPropertiesCase " , checkresult .Fail , "" },
79
- {"Correct " , "Recursive" , checkresult .Pass , "" },
80
+ {"Has folder name > max length " , "FolderNameTooLong12345678901234567890123456789012345678901234567890 " , checkresult .Fail , "^FolderNameTooLong12345678901234567890123456789012345678901234567890$ " },
81
+ {"Folder name <= max length " , "Recursive" , checkresult .Pass , "" },
80
82
}
81
83
82
- checkLibraryCheckFunction (IncorrectLibraryPropertiesFileNameCase , testTables , t )
84
+ checkLibraryCheckFunction (LibraryFolderNameGTMaxLength , testTables , t )
85
+ }
86
+
87
+ func TestProhibitedCharactersInLibraryFolderName (t * testing.T ) {
88
+ testTables := []libraryCheckFunctionTestTable {
89
+ {"Has prohibited characters" , "Prohibited CharactersInFolderName" , checkresult .Fail , "" },
90
+ {"No prohibited characters" , "Recursive" , checkresult .Pass , "" },
91
+ }
92
+
93
+ checkLibraryCheckFunction (ProhibitedCharactersInLibraryFolderName , testTables , t )
94
+ }
95
+
96
+ func TestLibraryHasSubmodule (t * testing.T ) {
97
+ testTables := []libraryCheckFunctionTestTable {
98
+ {"Has submodule" , "Submodule" , checkresult .Fail , "" },
99
+ {"No submodule" , "Recursive" , checkresult .Pass , "" },
100
+ }
101
+
102
+ checkLibraryCheckFunction (LibraryHasSubmodule , testTables , t )
103
+ }
104
+
105
+ func TestLibraryContainsSymlinks (t * testing.T ) {
106
+ testLibrary := "Recursive"
107
+ symlinkPath := librariesTestDataPath .Join (testLibrary , "test-symlink" )
108
+ // It's probably most friendly to developers using Windows to create the symlink needed for the test on demand.
109
+ err := os .Symlink (librariesTestDataPath .Join (testLibrary , "library.properties" ).String (), symlinkPath .String ())
110
+ require .Nil (t , err , "This test must be run as administrator on Windows to have symlink creation privilege." )
111
+ defer symlinkPath .RemoveAll () // clean up
112
+
113
+ testTables := []libraryCheckFunctionTestTable {
114
+ {"Has symlink" , testLibrary , checkresult .Fail , "" },
115
+ }
116
+
117
+ checkLibraryCheckFunction (LibraryContainsSymlinks , testTables , t )
118
+
119
+ err = symlinkPath .RemoveAll ()
120
+ require .Nil (t , err )
121
+
122
+ testTables = []libraryCheckFunctionTestTable {
123
+ {"No symlink" , testLibrary , checkresult .Pass , "" },
124
+ }
125
+
126
+ checkLibraryCheckFunction (LibraryContainsSymlinks , testTables , t )
127
+ }
128
+
129
+ func TestLibraryHasDotDevelopmentFile (t * testing.T ) {
130
+ testTables := []libraryCheckFunctionTestTable {
131
+ {"Has .development file" , "DotDevelopment" , checkresult .Fail , "" },
132
+ {"No .development file" , "Recursive" , checkresult .Pass , "" },
133
+ }
134
+
135
+ checkLibraryCheckFunction (LibraryHasDotDevelopmentFile , testTables , t )
136
+ }
137
+
138
+ func TestLibraryHasExe (t * testing.T ) {
139
+ testTables := []libraryCheckFunctionTestTable {
140
+ {"Has .exe file" , "Exe" , checkresult .Fail , "" },
141
+ {"No .exe files" , "Recursive" , checkresult .Pass , "" },
142
+ }
143
+
144
+ checkLibraryCheckFunction (LibraryHasExe , testTables , t )
145
+ }
146
+
147
+ func TestLibraryPropertiesNameFieldHeaderMismatch (t * testing.T ) {
148
+ testTables := []libraryCheckFunctionTestTable {
149
+ {"Unable to load" , "InvalidLibraryProperties" , checkresult .NotRun , "" },
150
+ {"Mismatch" , "NameHeaderMismatch" , checkresult .Fail , "^NameHeaderMismatch.h$" },
151
+ {"Match" , "Recursive" , checkresult .Pass , "" },
152
+ }
153
+
154
+ checkLibraryCheckFunction (LibraryPropertiesNameFieldHeaderMismatch , testTables , t )
155
+ }
156
+
157
+ func TestIncorrectLibrarySrcFolderNameCase (t * testing.T ) {
158
+ testTables := []libraryCheckFunctionTestTable {
159
+ {"Flat, not precompiled" , "Flat" , checkresult .Skip , "" },
160
+ {"Incorrect case" , "IncorrectSrcFolderNameCase" , checkresult .Fail , "" },
161
+ {"Correct case" , "Recursive" , checkresult .Pass , "" },
162
+ }
163
+
164
+ checkLibraryCheckFunction (IncorrectLibrarySrcFolderNameCase , testTables , t )
165
+ }
166
+
167
+ func TestRecursiveLibraryWithUtilityFolder (t * testing.T ) {
168
+ testTables := []libraryCheckFunctionTestTable {
169
+ {"Unable to load" , "InvalidLibraryProperties" , checkresult .NotRun , "" },
170
+ {"Flat" , "Flat" , checkresult .Skip , "" },
171
+ {"Recursive with utility" , "RecursiveWithUtilityFolder" , checkresult .Fail , "" },
172
+ {"Recursive without utility" , "Recursive" , checkresult .Pass , "" },
173
+ }
174
+
175
+ checkLibraryCheckFunction (RecursiveLibraryWithUtilityFolder , testTables , t )
176
+ }
177
+
178
+ func TestMisspelledExtrasFolderName (t * testing.T ) {
179
+ testTables := []libraryCheckFunctionTestTable {
180
+ {"Correctly spelled" , "ExtrasFolder" , checkresult .Pass , "" },
181
+ {"Misspelled" , "MisspelledExtrasFolder" , checkresult .Fail , "" },
182
+ {"No extras folder" , "Recursive" , checkresult .Pass , "" },
183
+ }
184
+
185
+ checkLibraryCheckFunction (MisspelledExtrasFolderName , testTables , t )
186
+ }
187
+
188
+ func TestIncorrectExtrasFolderNameCase (t * testing.T ) {
189
+ testTables := []libraryCheckFunctionTestTable {
190
+ {"Correct case" , "ExtrasFolder" , checkresult .Pass , "" },
191
+ {"Incorrect case" , "IncorrectExtrasFolderCase" , checkresult .Fail , "" },
192
+ {"No extras folder" , "Recursive" , checkresult .Pass , "" },
193
+ }
194
+
195
+ checkLibraryCheckFunction (IncorrectExtrasFolderNameCase , testTables , t )
83
196
}
84
197
85
198
func TestLibraryPropertiesMissing (t * testing.T ) {
@@ -93,6 +206,24 @@ func TestLibraryPropertiesMissing(t *testing.T) {
93
206
checkLibraryCheckFunction (LibraryPropertiesMissing , testTables , t )
94
207
}
95
208
209
+ func TestMisspelledLibraryPropertiesFileName (t * testing.T ) {
210
+ testTables := []libraryCheckFunctionTestTable {
211
+ {"Incorrect" , "MisspelledLibraryProperties" , checkresult .Fail , "" },
212
+ {"Correct" , "Recursive" , checkresult .Pass , "" },
213
+ }
214
+
215
+ checkLibraryCheckFunction (MisspelledLibraryPropertiesFileName , testTables , t )
216
+ }
217
+
218
+ func TestIncorrectLibraryPropertiesFileNameCase (t * testing.T ) {
219
+ testTables := []libraryCheckFunctionTestTable {
220
+ {"Incorrect" , "IncorrectLibraryPropertiesCase" , checkresult .Fail , "" },
221
+ {"Correct" , "Recursive" , checkresult .Pass , "" },
222
+ }
223
+
224
+ checkLibraryCheckFunction (IncorrectLibraryPropertiesFileNameCase , testTables , t )
225
+ }
226
+
96
227
func TestRedundantLibraryProperties (t * testing.T ) {
97
228
testTables := []libraryCheckFunctionTestTable {
98
229
{"Redundant" , "RedundantLibraryProperties" , checkresult .Fail , "" },
@@ -143,16 +274,6 @@ func TestLibraryPropertiesNameFieldNotInIndex(t *testing.T) {
143
274
checkLibraryCheckFunction (LibraryPropertiesNameFieldNotInIndex , testTables , t )
144
275
}
145
276
146
- func TestLibraryPropertiesNameFieldHeaderMismatch (t * testing.T ) {
147
- testTables := []libraryCheckFunctionTestTable {
148
- {"Unable to load" , "InvalidLibraryProperties" , checkresult .NotRun , "" },
149
- {"Mismatch" , "NameHeaderMismatch" , checkresult .Fail , "^NameHeaderMismatch.h$" },
150
- {"Match" , "Recursive" , checkresult .Pass , "" },
151
- }
152
-
153
- checkLibraryCheckFunction (LibraryPropertiesNameFieldHeaderMismatch , testTables , t )
154
- }
155
-
156
277
func TestLibraryPropertiesVersionFieldBehindTag (t * testing.T ) {
157
278
// Set up the test repository folders.
158
279
TagPrereleaseGreaterPath := librariesTestDataPath .Join ("TagPrereleaseGreater" )
@@ -257,6 +378,17 @@ func TestLibraryPropertiesVersionFieldBehindTag(t *testing.T) {
257
378
checkLibraryCheckFunction (LibraryPropertiesVersionFieldBehindTag , testTables , t )
258
379
}
259
380
381
+ func TestLibraryPropertiesEmailFieldAsMaintainerAlias (t * testing.T ) {
382
+ testTables := []libraryCheckFunctionTestTable {
383
+ {"Unable to load" , "InvalidLibraryProperties" , checkresult .NotRun , "" },
384
+ {"No email field" , "MissingFields" , checkresult .Skip , "" },
385
+ {"email in place of maintainer" , "EmailOnly" , checkresult .Fail , "" },
386
+ {"email and maintainer" , "EmailAndMaintainer" , checkresult .Pass , "" },
387
+ }
388
+
389
+ checkLibraryCheckFunction (LibraryPropertiesEmailFieldAsMaintainerAlias , testTables , t )
390
+ }
391
+
260
392
func TestLibraryPropertiesSentenceFieldSpellCheck (t * testing.T ) {
261
393
testTables := []libraryCheckFunctionTestTable {
262
394
{"Unable to load" , "InvalidLibraryProperties" , checkresult .NotRun , "" },
@@ -281,17 +413,6 @@ func TestLibraryPropertiesParagraphFieldSpellCheck(t *testing.T) {
281
413
checkLibraryCheckFunction (LibraryPropertiesParagraphFieldSpellCheck , testTables , t )
282
414
}
283
415
284
- func TestLibraryPropertiesEmailFieldAsMaintainerAlias (t * testing.T ) {
285
- testTables := []libraryCheckFunctionTestTable {
286
- {"Unable to load" , "InvalidLibraryProperties" , checkresult .NotRun , "" },
287
- {"No email field" , "MissingFields" , checkresult .Skip , "" },
288
- {"email in place of maintainer" , "EmailOnly" , checkresult .Fail , "" },
289
- {"email and maintainer" , "EmailAndMaintainer" , checkresult .Pass , "" },
290
- }
291
-
292
- checkLibraryCheckFunction (LibraryPropertiesEmailFieldAsMaintainerAlias , testTables , t )
293
- }
294
-
295
416
func TestLibraryPropertiesParagraphFieldRepeatsSentence (t * testing.T ) {
296
417
testTables := []libraryCheckFunctionTestTable {
297
418
{"Unable to load" , "InvalidLibraryProperties" , checkresult .NotRun , "" },
@@ -396,68 +517,6 @@ func TestLibraryPropertiesPrecompiledFieldEnabledWithFlatLayout(t *testing.T) {
396
517
checkLibraryCheckFunction (LibraryPropertiesPrecompiledFieldEnabledWithFlatLayout , testTables , t )
397
518
}
398
519
399
- func TestLibraryInvalid (t * testing.T ) {
400
- testTables := []libraryCheckFunctionTestTable {
401
- {"Invalid library.properties" , "InvalidLibraryProperties" , checkresult .Fail , "" },
402
- {"Invalid flat layout" , "FlatWithoutHeader" , checkresult .Fail , "" },
403
- {"Invalid recursive layout" , "RecursiveWithoutLibraryProperties" , checkresult .Fail , "" },
404
- {"Valid library" , "Recursive" , checkresult .Pass , "" },
405
- }
406
-
407
- checkLibraryCheckFunction (LibraryInvalid , testTables , t )
408
- }
409
-
410
- func TestLibraryHasSubmodule (t * testing.T ) {
411
- testTables := []libraryCheckFunctionTestTable {
412
- {"Has submodule" , "Submodule" , checkresult .Fail , "" },
413
- {"No submodule" , "Recursive" , checkresult .Pass , "" },
414
- }
415
-
416
- checkLibraryCheckFunction (LibraryHasSubmodule , testTables , t )
417
- }
418
-
419
- func TestLibraryContainsSymlinks (t * testing.T ) {
420
- testLibrary := "Recursive"
421
- symlinkPath := librariesTestDataPath .Join (testLibrary , "test-symlink" )
422
- // It's probably most friendly to developers using Windows to create the symlink needed for the test on demand.
423
- err := os .Symlink (librariesTestDataPath .Join (testLibrary , "library.properties" ).String (), symlinkPath .String ())
424
- require .Nil (t , err , "This test must be run as administrator on Windows to have symlink creation privilege." )
425
- defer symlinkPath .RemoveAll () // clean up
426
-
427
- testTables := []libraryCheckFunctionTestTable {
428
- {"Has symlink" , testLibrary , checkresult .Fail , "" },
429
- }
430
-
431
- checkLibraryCheckFunction (LibraryContainsSymlinks , testTables , t )
432
-
433
- err = symlinkPath .RemoveAll ()
434
- require .Nil (t , err )
435
-
436
- testTables = []libraryCheckFunctionTestTable {
437
- {"No symlink" , testLibrary , checkresult .Pass , "" },
438
- }
439
-
440
- checkLibraryCheckFunction (LibraryContainsSymlinks , testTables , t )
441
- }
442
-
443
- func TestLibraryHasDotDevelopmentFile (t * testing.T ) {
444
- testTables := []libraryCheckFunctionTestTable {
445
- {"Has .development file" , "DotDevelopment" , checkresult .Fail , "" },
446
- {"No .development file" , "Recursive" , checkresult .Pass , "" },
447
- }
448
-
449
- checkLibraryCheckFunction (LibraryHasDotDevelopmentFile , testTables , t )
450
- }
451
-
452
- func TestLibraryHasExe (t * testing.T ) {
453
- testTables := []libraryCheckFunctionTestTable {
454
- {"Has .exe file" , "Exe" , checkresult .Fail , "" },
455
- {"No .exe files" , "Recursive" , checkresult .Pass , "" },
456
- }
457
-
458
- checkLibraryCheckFunction (LibraryHasExe , testTables , t )
459
- }
460
-
461
520
func TestLibraryHasStraySketches (t * testing.T ) {
462
521
testTables := []libraryCheckFunctionTestTable {
463
522
{"Sketch in root" , "SketchInRoot" , checkresult .Fail , "" },
@@ -469,34 +528,6 @@ func TestLibraryHasStraySketches(t *testing.T) {
469
528
checkLibraryCheckFunction (LibraryHasStraySketches , testTables , t )
470
529
}
471
530
472
- func TestProhibitedCharactersInLibraryFolderName (t * testing.T ) {
473
- testTables := []libraryCheckFunctionTestTable {
474
- {"Has prohibited characters" , "Prohibited CharactersInFolderName" , checkresult .Fail , "" },
475
- {"No prohibited characters" , "Recursive" , checkresult .Pass , "" },
476
- }
477
-
478
- checkLibraryCheckFunction (ProhibitedCharactersInLibraryFolderName , testTables , t )
479
- }
480
-
481
- func TestLibraryFolderNameGTMaxLength (t * testing.T ) {
482
- testTables := []libraryCheckFunctionTestTable {
483
- {"Has folder name > max length" , "FolderNameTooLong12345678901234567890123456789012345678901234567890" , checkresult .Fail , "^FolderNameTooLong12345678901234567890123456789012345678901234567890$" },
484
- {"Folder name <= max length" , "Recursive" , checkresult .Pass , "" },
485
- }
486
-
487
- checkLibraryCheckFunction (LibraryFolderNameGTMaxLength , testTables , t )
488
- }
489
-
490
- func TestIncorrectLibrarySrcFolderNameCase (t * testing.T ) {
491
- testTables := []libraryCheckFunctionTestTable {
492
- {"Flat, not precompiled" , "Flat" , checkresult .Skip , "" },
493
- {"Incorrect case" , "IncorrectSrcFolderNameCase" , checkresult .Fail , "" },
494
- {"Correct case" , "Recursive" , checkresult .Pass , "" },
495
- }
496
-
497
- checkLibraryCheckFunction (IncorrectLibrarySrcFolderNameCase , testTables , t )
498
- }
499
-
500
531
func TestMissingExamples (t * testing.T ) {
501
532
testTables := []libraryCheckFunctionTestTable {
502
533
{"Has examples" , "ExamplesFolder" , checkresult .Pass , "" },
@@ -526,34 +557,3 @@ func TestIncorrectExamplesFolderNameCase(t *testing.T) {
526
557
527
558
checkLibraryCheckFunction (IncorrectExamplesFolderNameCase , testTables , t )
528
559
}
529
-
530
- func TestMisspelledExtrasFolderName (t * testing.T ) {
531
- testTables := []libraryCheckFunctionTestTable {
532
- {"Correctly spelled" , "ExtrasFolder" , checkresult .Pass , "" },
533
- {"Misspelled" , "MisspelledExtrasFolder" , checkresult .Fail , "" },
534
- {"No extras folder" , "Recursive" , checkresult .Pass , "" },
535
- }
536
-
537
- checkLibraryCheckFunction (MisspelledExtrasFolderName , testTables , t )
538
- }
539
-
540
- func TestIncorrectExtrasFolderNameCase (t * testing.T ) {
541
- testTables := []libraryCheckFunctionTestTable {
542
- {"Correct case" , "ExtrasFolder" , checkresult .Pass , "" },
543
- {"Incorrect case" , "IncorrectExtrasFolderCase" , checkresult .Fail , "" },
544
- {"No extras folder" , "Recursive" , checkresult .Pass , "" },
545
- }
546
-
547
- checkLibraryCheckFunction (IncorrectExtrasFolderNameCase , testTables , t )
548
- }
549
-
550
- func TestRecursiveLibraryWithUtilityFolder (t * testing.T ) {
551
- testTables := []libraryCheckFunctionTestTable {
552
- {"Unable to load" , "InvalidLibraryProperties" , checkresult .NotRun , "" },
553
- {"Flat" , "Flat" , checkresult .Skip , "" },
554
- {"Recursive with utility" , "RecursiveWithUtilityFolder" , checkresult .Fail , "" },
555
- {"Recursive without utility" , "Recursive" , checkresult .Pass , "" },
556
- }
557
-
558
- checkLibraryCheckFunction (RecursiveLibraryWithUtilityFolder , testTables , t )
559
- }
0 commit comments