diff --git a/check/checkfunctions/library.go b/check/checkfunctions/library.go index 987fd386f..76dc092ad 100644 --- a/check/checkfunctions/library.go +++ b/check/checkfunctions/library.go @@ -787,7 +787,7 @@ func LibraryPropertiesEmailFieldStartsWithArduino() (result checkresult.Type, ou } if checkdata.LibraryProperties().ContainsKey("maintainer") { - return checkresult.NotRun, "Field not present" + return checkresult.Skip, "No email alias field" } email, ok := checkdata.LibraryProperties().GetOk("email") @@ -890,7 +890,7 @@ func LibraryPropertiesCategoryFieldMissing() (result checkresult.Type, output st return checkresult.Skip, "Library has legacy format" } - if schema.RequiredPropertyMissing("category", checkdata.LibraryPropertiesSchemaValidationResult()[compliancelevel.Specification]) { + if schema.RequiredPropertyMissing("category", checkdata.LibraryPropertiesSchemaValidationResult()[compliancelevel.Strict]) { return checkresult.Fail, "" } return checkresult.Pass, "" @@ -1000,7 +1000,7 @@ func LibraryPropertiesArchitecturesFieldMissing() (result checkresult.Type, outp return checkresult.Skip, "Library has legacy format" } - if schema.RequiredPropertyMissing("architectures", checkdata.LibraryPropertiesSchemaValidationResult()[compliancelevel.Specification]) { + if schema.RequiredPropertyMissing("architectures", checkdata.LibraryPropertiesSchemaValidationResult()[compliancelevel.Strict]) { return checkresult.Fail, "" } return checkresult.Pass, "" @@ -1341,7 +1341,7 @@ func LibraryPropertiesMisspelledOptionalField() (result checkresult.Type, output return checkresult.NotRun, "Library not loaded" } - if schema.MisspelledOptionalPropertyFound(checkdata.LibraryPropertiesSchemaValidationResult()[compliancelevel.Specification]) { + if schema.MisspelledOptionalPropertyFound(checkdata.LibraryPropertiesSchemaValidationResult()[compliancelevel.Strict]) { return checkresult.Fail, "" } diff --git a/check/checkfunctions/library_test.go b/check/checkfunctions/library_test.go index 5974516e3..933789ca9 100644 --- a/check/checkfunctions/library_test.go +++ b/check/checkfunctions/library_test.go @@ -147,6 +147,7 @@ func TestLibraryHasExe(t *testing.T) { func TestLibraryPropertiesNameFieldHeaderMismatch(t *testing.T) { testTables := []libraryCheckFunctionTestTable{ {"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.NotRun, ""}, {"Mismatch", "NameHeaderMismatch", checkresult.Fail, "^NameHeaderMismatch.h$"}, {"Match", "Recursive", checkresult.Pass, ""}, } @@ -243,6 +244,72 @@ func TestLibraryPropertiesFormat(t *testing.T) { checkLibraryCheckFunction(LibraryPropertiesFormat, testTables, t) } +func TestLibraryPropertiesNameFieldMissing(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.Skip, ""}, + {"Field missing", "MissingFields", checkresult.Fail, ""}, + {"Valid", "Recursive", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesNameFieldMissing, testTables, t) +} + +func TestLibraryPropertiesNameFieldLTMinLength(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.NotRun, ""}, + {"Name field too short", "NameLTMinLength", checkresult.Fail, ""}, + {"Valid", "Recursive", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesNameFieldLTMinLength, testTables, t) +} + +func TestLibraryPropertiesNameFieldGTMaxLength(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.NotRun, ""}, + {"Name field too long", "NameGTMaxLength", checkresult.Fail, ""}, + {"Valid", "Recursive", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesNameFieldGTMaxLength, testTables, t) +} + +func TestLibraryPropertiesNameFieldGTRecommendedLength(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.NotRun, ""}, + {"Name field longer than recommended", "NameGTRecommendedLength", checkresult.Fail, ""}, + {"Valid", "Recursive", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesNameFieldGTRecommendedLength, testTables, t) +} + +func TestLibraryPropertiesNameFieldDisallowedCharacters(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.NotRun, ""}, + {"Name field has disallowed characters", "NameHasBadChars", checkresult.Fail, ""}, + {"Valid", "Recursive", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesNameFieldDisallowedCharacters, testTables, t) +} + +func TestLibraryPropertiesNameFieldStartsWithArduino(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.NotRun, ""}, + {"Name field starts with Arduino", "Arduino_Official", checkresult.Fail, ""}, + {"Valid", "Recursive", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesNameFieldStartsWithArduino, testTables, t) +} + func TestLibraryPropertiesNameFieldMissingOfficialPrefix(t *testing.T) { testTables := []libraryCheckFunctionTestTable{ {"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""}, @@ -254,9 +321,43 @@ func TestLibraryPropertiesNameFieldMissingOfficialPrefix(t *testing.T) { checkLibraryCheckFunction(LibraryPropertiesNameFieldMissingOfficialPrefix, testTables, t) } +func TestLibraryPropertiesNameFieldContainsArduino(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.NotRun, ""}, + {"Name field contains Arduino", "NameContainsArduino", checkresult.Fail, ""}, + {"Valid", "Recursive", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesNameFieldContainsArduino, testTables, t) +} + +func TestLibraryPropertiesNameFieldHasSpaces(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.NotRun, ""}, + {"Name field contains spaces", "NameHasSpaces", checkresult.Fail, ""}, + {"Valid", "Recursive", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesNameFieldHasSpaces, testTables, t) +} + +func TestLibraryPropertiesNameFieldContainsLibrary(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.NotRun, ""}, + {"Name field contains library", "NameHasLibrary", checkresult.Fail, ""}, + {"Valid", "Recursive", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesNameFieldContainsLibrary, testTables, t) +} + func TestLibraryPropertiesNameFieldDuplicate(t *testing.T) { testTables := []libraryCheckFunctionTestTable{ {"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.NotRun, ""}, {"Duplicate", "Indexed", checkresult.Fail, "^Servo$"}, {"Not duplicate", "NotIndexed", checkresult.Pass, ""}, } @@ -267,6 +368,7 @@ func TestLibraryPropertiesNameFieldDuplicate(t *testing.T) { func TestLibraryPropertiesNameFieldNotInIndex(t *testing.T) { testTables := []libraryCheckFunctionTestTable{ {"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.NotRun, ""}, {"In index", "Indexed", checkresult.Pass, ""}, {"Not in index", "NotIndexed", checkresult.Fail, "^NotIndexed$"}, } @@ -274,6 +376,39 @@ func TestLibraryPropertiesNameFieldNotInIndex(t *testing.T) { checkLibraryCheckFunction(LibraryPropertiesNameFieldNotInIndex, testTables, t) } +func TestLibraryPropertiesVersionFieldMissing(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.Skip, ""}, + {"Version field missing", "MissingFields", checkresult.Fail, ""}, + {"Valid", "Recursive", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesVersionFieldMissing, testTables, t) +} + +func TestLibraryPropertiesVersionFieldNonRelaxedSemver(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.NotRun, ""}, + {"Version not relaxed semver compliant", "VersionNotRelaxedSemver", checkresult.Fail, ""}, + {"Valid", "Recursive", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesVersionFieldNonRelaxedSemver, testTables, t) +} + +func TestLibraryPropertiesVersionFieldNonSemver(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.NotRun, ""}, + {"Version not semver compliant", "VersionNotSemver", checkresult.Fail, ""}, + {"Valid", "Recursive", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesVersionFieldNonSemver, testTables, t) +} + func TestLibraryPropertiesVersionFieldBehindTag(t *testing.T) { // Set up the test repository folders. TagPrereleaseGreaterPath := librariesTestDataPath.Join("TagPrereleaseGreater") @@ -378,6 +513,61 @@ func TestLibraryPropertiesVersionFieldBehindTag(t *testing.T) { checkLibraryCheckFunction(LibraryPropertiesVersionFieldBehindTag, testTables, t) } +func TestLibraryPropertiesAuthorFieldMissing(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.Skip, ""}, + {"Field missing", "MissingFields", checkresult.Fail, ""}, + {"Valid", "Recursive", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesAuthorFieldMissing, testTables, t) +} + +func TestLibraryPropertiesAuthorFieldLTMinLength(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.NotRun, ""}, + {"Author field too short", "AuthorLTMinLength", checkresult.Fail, ""}, + {"Valid", "Recursive", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesAuthorFieldLTMinLength, testTables, t) +} + +func TestLibraryPropertiesMaintainerFieldMissing(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.Skip, ""}, + {"Field missing", "MissingFields", checkresult.Fail, ""}, + {"Valid", "Recursive", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesMaintainerFieldMissing, testTables, t) +} + +func TestLibraryPropertiesMaintainerFieldLTMinLength(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.NotRun, ""}, + {"Maintainer field too short", "MaintainerLTMinLength", checkresult.Fail, ""}, + {"Valid", "Recursive", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesMaintainerFieldLTMinLength, testTables, t) +} + +func TestLibraryPropertiesMaintainerFieldStartsWithArduino(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.NotRun, ""}, + {"Maintainer field starts w/ Arduino", "MaintainerStartsWithArduino", checkresult.Fail, ""}, + {"Valid", "Recursive", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesMaintainerFieldStartsWithArduino, testTables, t) +} + func TestLibraryPropertiesEmailFieldAsMaintainerAlias(t *testing.T) { testTables := []libraryCheckFunctionTestTable{ {"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""}, @@ -389,6 +579,51 @@ func TestLibraryPropertiesEmailFieldAsMaintainerAlias(t *testing.T) { checkLibraryCheckFunction(LibraryPropertiesEmailFieldAsMaintainerAlias, testTables, t) } +func TestLibraryPropertiesEmailFieldLTMinLength(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.Skip, ""}, + {"Email field too short", "EmailLTMinLength", checkresult.Fail, ""}, + {"Valid", "EmailOnly", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesEmailFieldLTMinLength, testTables, t) +} + +func TestLibraryPropertiesEmailFieldStartsWithArduino(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Not an alias", "EmailAndMaintainer", checkresult.Skip, ""}, + {"Legacy", "Legacy", checkresult.Skip, ""}, + {"Email field starts w/ Arduino", "EmailStartsWithArduino", checkresult.Fail, ""}, + {"Valid", "EmailOnly", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesEmailFieldStartsWithArduino, testTables, t) +} + +func TestLibraryPropertiesSentenceFieldMissing(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.Skip, ""}, + {"Field missing", "MissingFields", checkresult.Fail, ""}, + {"Valid", "Recursive", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesSentenceFieldMissing, testTables, t) +} + +func TestLibraryPropertiesSentenceFieldLTMinLength(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.NotRun, ""}, + {"Sentence field too short", "SentenceLTMinLength", checkresult.Fail, ""}, + {"Valid", "Recursive", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesSentenceFieldLTMinLength, testTables, t) +} + func TestLibraryPropertiesSentenceFieldSpellCheck(t *testing.T) { testTables := []libraryCheckFunctionTestTable{ {"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""}, @@ -401,6 +636,17 @@ func TestLibraryPropertiesSentenceFieldSpellCheck(t *testing.T) { checkLibraryCheckFunction(LibraryPropertiesSentenceFieldSpellCheck, testTables, t) } +func TestLibraryPropertiesParagraphFieldMissing(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.Skip, ""}, + {"Field missing", "MissingFields", checkresult.Fail, ""}, + {"Valid", "Recursive", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesParagraphFieldMissing, testTables, t) +} + func TestLibraryPropertiesParagraphFieldSpellCheck(t *testing.T) { testTables := []libraryCheckFunctionTestTable{ {"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""}, @@ -416,6 +662,7 @@ func TestLibraryPropertiesParagraphFieldSpellCheck(t *testing.T) { func TestLibraryPropertiesParagraphFieldRepeatsSentence(t *testing.T) { testTables := []libraryCheckFunctionTestTable{ {"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.NotRun, ""}, {"Repeat", "ParagraphRepeatsSentence", checkresult.Fail, ""}, {"No repeat", "Recursive", checkresult.Pass, ""}, } @@ -423,6 +670,28 @@ func TestLibraryPropertiesParagraphFieldRepeatsSentence(t *testing.T) { checkLibraryCheckFunction(LibraryPropertiesParagraphFieldRepeatsSentence, testTables, t) } +func TestLibraryPropertiesCategoryFieldMissing(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.Skip, ""}, + {"Field missing", "MissingFields", checkresult.Fail, ""}, + {"Valid", "Recursive", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesCategoryFieldMissing, testTables, t) +} + +func TestLibraryPropertiesCategoryFieldInvalid(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.Skip, ""}, + {"Unsupported category name", "CategoryInvalid", checkresult.Fail, ""}, + {"Valid", "Recursive", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesCategoryFieldInvalid, testTables, t) +} + func TestLibraryPropertiesCategoryFieldUncategorized(t *testing.T) { testTables := []libraryCheckFunctionTestTable{ {"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""}, @@ -434,6 +703,28 @@ func TestLibraryPropertiesCategoryFieldUncategorized(t *testing.T) { checkLibraryCheckFunction(LibraryPropertiesCategoryFieldUncategorized, testTables, t) } +func TestLibraryPropertiesUrlFieldMissing(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.Skip, ""}, + {"Field missing", "MissingFields", checkresult.Fail, ""}, + {"Valid", "Recursive", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesUrlFieldMissing, testTables, t) +} + +func TestLibraryPropertiesUrlFieldInvalid(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.NotRun, ""}, + {"Invalid URL format", "UrlFormatInvalid", checkresult.Fail, ""}, + {"Valid", "Recursive", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesUrlFieldInvalid, testTables, t) +} + func TestLibraryPropertiesUrlFieldDeadLink(t *testing.T) { testTables := []libraryCheckFunctionTestTable{ {"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""}, @@ -446,6 +737,28 @@ func TestLibraryPropertiesUrlFieldDeadLink(t *testing.T) { checkLibraryCheckFunction(LibraryPropertiesUrlFieldDeadLink, testTables, t) } +func TestLibraryPropertiesArchitecturesFieldMissing(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.Skip, ""}, + {"Field missing", "MissingFields", checkresult.Fail, ""}, + {"Valid", "Recursive", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesArchitecturesFieldMissing, testTables, t) +} + +func TestLibraryPropertiesArchitecturesFieldLTMinLength(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.Skip, ""}, + {"Architectures field too short", "ArchitecturesLTMinLength", checkresult.Fail, ""}, + {"Valid", "Recursive", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesArchitecturesFieldLTMinLength, testTables, t) +} + func TestLibraryPropertiesArchitecturesFieldSoloAlias(t *testing.T) { testTables := []libraryCheckFunctionTestTable{ {"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""}, @@ -470,6 +783,17 @@ func TestLibraryPropertiesArchitecturesFieldValueCase(t *testing.T) { checkLibraryCheckFunction(LibraryPropertiesArchitecturesFieldValueCase, testTables, t) } +func TestLibraryPropertiesDependsFieldDisallowedCharacters(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.Skip, ""}, + {"Depends field has disallowed characters", "DependsHasBadChars", checkresult.Fail, ""}, + {"Valid", "DependsIndexed", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesDependsFieldDisallowedCharacters, testTables, t) +} + func TestLibraryPropertiesDependsFieldNotInIndex(t *testing.T) { testTables := []libraryCheckFunctionTestTable{ {"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""}, @@ -482,6 +806,17 @@ func TestLibraryPropertiesDependsFieldNotInIndex(t *testing.T) { checkLibraryCheckFunction(LibraryPropertiesDependsFieldNotInIndex, testTables, t) } +func TestLibraryPropertiesDotALinkageFieldInvalid(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.Skip, ""}, + {"dot_a_linkage field invalid value", "DotALinkageInvalid", checkresult.Fail, ""}, + {"Valid", "DotALinkage", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesDotALinkageFieldInvalid, testTables, t) +} + func TestLibraryPropertiesDotALinkageFieldTrueWithFlatLayout(t *testing.T) { testTables := []libraryCheckFunctionTestTable{ {"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""}, @@ -493,17 +828,40 @@ func TestLibraryPropertiesDotALinkageFieldTrueWithFlatLayout(t *testing.T) { checkLibraryCheckFunction(LibraryPropertiesDotALinkageFieldTrueWithFlatLayout, testTables, t) } +func TestLibraryPropertiesIncludesFieldLTMinLength(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.Skip, ""}, + {"Includes field too short", "IncludesLTMinLength", checkresult.Fail, ""}, + {"Valid", "Recursive", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesIncludesFieldLTMinLength, testTables, t) +} + func TestLibraryPropertiesIncludesFieldItemNotFound(t *testing.T) { testTables := []libraryCheckFunctionTestTable{ {"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""}, {"Not defined", "MissingFields", checkresult.Skip, ""}, {"Missing includes", "MissingIncludes", checkresult.Fail, "^Nonexistent.h$"}, + {"Double comma in includes list", "IncludesListSkip", checkresult.Pass, ""}, {"Present includes", "Recursive", checkresult.Pass, ""}, } checkLibraryCheckFunction(LibraryPropertiesIncludesFieldItemNotFound, testTables, t) } +func TestLibraryPropertiesPrecompiledFieldInvalid(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.Skip, ""}, + {"Precompiled field invalid value", "PrecompiledInvalid", checkresult.Fail, ""}, + {"Valid", "Precompiled", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesPrecompiledFieldInvalid, testTables, t) +} + func TestLibraryPropertiesPrecompiledFieldEnabledWithFlatLayout(t *testing.T) { testTables := []libraryCheckFunctionTestTable{ {"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""}, @@ -517,6 +875,31 @@ func TestLibraryPropertiesPrecompiledFieldEnabledWithFlatLayout(t *testing.T) { checkLibraryCheckFunction(LibraryPropertiesPrecompiledFieldEnabledWithFlatLayout, testTables, t) } +func TestLibraryPropertiesLdflagsFieldLTMinLength(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Legacy", "Legacy", checkresult.Skip, ""}, + {"ldflags field too short", "LdflagsLTMinLength", checkresult.Fail, ""}, + {"Valid", "LdflagsValid", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesLdflagsFieldLTMinLength, testTables, t) +} + +func TestLibraryPropertiesMisspelledOptionalField(t *testing.T) { + testTables := []libraryCheckFunctionTestTable{ + {"Invalid", "InvalidLibraryProperties", checkresult.NotRun, ""}, + {"Misspelled depends field name", "DependsFieldMisspelled", checkresult.Fail, ""}, + {"Misspelled dot_a_linkage field name", "DotALinkageFieldMisspelled", checkresult.Fail, ""}, + {"Misspelled includes field name", "IncludesFieldMisspelled", checkresult.Fail, ""}, + {"Misspelled precompiled field name", "PrecompiledFieldMisspelled", checkresult.Fail, ""}, + {"Misspelled ldflags field name", "LdflagsFieldMisspelled", checkresult.Fail, ""}, + {"Valid", "Recursive", checkresult.Pass, ""}, + } + + checkLibraryCheckFunction(LibraryPropertiesMisspelledOptionalField, testTables, t) +} + func TestLibraryHasStraySketches(t *testing.T) { testTables := []libraryCheckFunctionTestTable{ {"Sketch in root", "SketchInRoot", checkresult.Fail, ""}, diff --git a/check/checkfunctions/testdata/libraries/ArchitecturesLTMinLength/library.properties b/check/checkfunctions/testdata/libraries/ArchitecturesLTMinLength/library.properties new file mode 100644 index 000000000..db528007a --- /dev/null +++ b/check/checkfunctions/testdata/libraries/ArchitecturesLTMinLength/library.properties @@ -0,0 +1,9 @@ +name=ArchitecturesLTMinLength +version=1.0.0 +author=Cristian Maglie , Pippo Pluto +maintainer=Cristian Maglie +sentence=A library that makes coding a web server a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=http://example.com/ +architectures= diff --git a/check/checkfunctions/testdata/libraries/ArchitecturesLTMinLength/src/ArchitecturesLTMinLength.h b/check/checkfunctions/testdata/libraries/ArchitecturesLTMinLength/src/ArchitecturesLTMinLength.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/AuthorLTMinLength/library.properties b/check/checkfunctions/testdata/libraries/AuthorLTMinLength/library.properties new file mode 100644 index 000000000..8406da3ec --- /dev/null +++ b/check/checkfunctions/testdata/libraries/AuthorLTMinLength/library.properties @@ -0,0 +1,9 @@ +name=AuthorLTMinLength +version=1.0.0 +author= +maintainer=Cristian Maglie +sentence=A library that makes coding a web server a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=http://example.com/ +architectures=avr diff --git a/check/checkfunctions/testdata/libraries/AuthorLTMinLength/src/AuthorLTMinLength.h b/check/checkfunctions/testdata/libraries/AuthorLTMinLength/src/AuthorLTMinLength.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/CategoryInvalid/library.properties b/check/checkfunctions/testdata/libraries/CategoryInvalid/library.properties new file mode 100644 index 000000000..4500041a8 --- /dev/null +++ b/check/checkfunctions/testdata/libraries/CategoryInvalid/library.properties @@ -0,0 +1,9 @@ +name=CategoryInvalid +version=1.0.0 +author=Cristian Maglie , Pippo Pluto +maintainer=Cristian Maglie +sentence=A library that makes coding a web server a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=foo +url=http://example.com/ +architectures=avr diff --git a/check/checkfunctions/testdata/libraries/CategoryInvalid/src/CategoryInvalid.h b/check/checkfunctions/testdata/libraries/CategoryInvalid/src/CategoryInvalid.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/DependsFieldMisspelled/library.properties b/check/checkfunctions/testdata/libraries/DependsFieldMisspelled/library.properties new file mode 100644 index 000000000..3d6f93916 --- /dev/null +++ b/check/checkfunctions/testdata/libraries/DependsFieldMisspelled/library.properties @@ -0,0 +1,10 @@ +name=DependsFieldMisspelled +version=1.0.0 +author=Cristian Maglie , Pippo Pluto +maintainer=Cristian Maglie +sentence=A library that makes coding a web server a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=http://example.com/ +architectures=avr +depend=Servo diff --git a/check/checkfunctions/testdata/libraries/DependsFieldMisspelled/src/DependsFieldMisspelled.h b/check/checkfunctions/testdata/libraries/DependsFieldMisspelled/src/DependsFieldMisspelled.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/DependsHasBadChars/library.properties b/check/checkfunctions/testdata/libraries/DependsHasBadChars/library.properties new file mode 100644 index 000000000..a36e84aa3 --- /dev/null +++ b/check/checkfunctions/testdata/libraries/DependsHasBadChars/library.properties @@ -0,0 +1,10 @@ +name=DependsHasBadChars +version=1.0.0 +author=Cristian Maglie , Pippo Pluto +maintainer=Cristian Maglie +sentence=A library that makes coding a web server a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=http://example.com/ +architectures=avr +depends=-foo diff --git a/check/checkfunctions/testdata/libraries/DependsHasBadChars/src/DependsHasBadChars.h b/check/checkfunctions/testdata/libraries/DependsHasBadChars/src/DependsHasBadChars.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/DotALinkageFieldMisspelled/library.properties b/check/checkfunctions/testdata/libraries/DotALinkageFieldMisspelled/library.properties new file mode 100644 index 000000000..74a7eb0c0 --- /dev/null +++ b/check/checkfunctions/testdata/libraries/DotALinkageFieldMisspelled/library.properties @@ -0,0 +1,10 @@ +name=DotALinkageFieldMisspelled +version=1.0.0 +author=Cristian Maglie , Pippo Pluto +maintainer=Cristian Maglie +sentence=A library that makes coding a web server a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=http://example.com/ +architectures=avr +dot_a_linkages=true diff --git a/check/checkfunctions/testdata/libraries/DotALinkageFieldMisspelled/src/DotALinkageFieldMisspelled.h b/check/checkfunctions/testdata/libraries/DotALinkageFieldMisspelled/src/DotALinkageFieldMisspelled.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/DotALinkageInvalid/library.properties b/check/checkfunctions/testdata/libraries/DotALinkageInvalid/library.properties new file mode 100644 index 000000000..8e7cfe4ca --- /dev/null +++ b/check/checkfunctions/testdata/libraries/DotALinkageInvalid/library.properties @@ -0,0 +1,10 @@ +name=DotALinkageInvalid +version=1.0.0 +author=Cristian Maglie , Pippo Pluto +maintainer=Cristian Maglie +sentence=A library that makes coding a web server a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=http://example.com/ +architectures=avr +dot_a_linkage=foo diff --git a/check/checkfunctions/testdata/libraries/DotALinkageInvalid/src/DotALinkageInvalid.h b/check/checkfunctions/testdata/libraries/DotALinkageInvalid/src/DotALinkageInvalid.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/EmailLTMinLength/library.properties b/check/checkfunctions/testdata/libraries/EmailLTMinLength/library.properties new file mode 100644 index 000000000..841b9eef7 --- /dev/null +++ b/check/checkfunctions/testdata/libraries/EmailLTMinLength/library.properties @@ -0,0 +1,9 @@ +name=EmailLTMinLength +version=1.0.0 +author=Cristian Maglie , Pippo Pluto +email= +sentence=A library that makes coding a web server a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=http://example.com/ +architectures=avr diff --git a/check/checkfunctions/testdata/libraries/EmailLTMinLength/src/EmailLTMinLength.h b/check/checkfunctions/testdata/libraries/EmailLTMinLength/src/EmailLTMinLength.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/EmailStartsWithArduino/library.properties b/check/checkfunctions/testdata/libraries/EmailStartsWithArduino/library.properties new file mode 100644 index 000000000..c31786b7a --- /dev/null +++ b/check/checkfunctions/testdata/libraries/EmailStartsWithArduino/library.properties @@ -0,0 +1,9 @@ +name=EmailStartsWithArduino +version=1.0.0 +author=Cristian Maglie , Pippo Pluto +email=Arduino Cristian Maglie +sentence=A library that makes coding a web server a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=http://example.com/ +architectures=avr diff --git a/check/checkfunctions/testdata/libraries/EmailStartsWithArduino/src/EmailStartsWithArduino.h b/check/checkfunctions/testdata/libraries/EmailStartsWithArduino/src/EmailStartsWithArduino.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/IncludesFieldMisspelled/library.properties b/check/checkfunctions/testdata/libraries/IncludesFieldMisspelled/library.properties new file mode 100644 index 000000000..574a99379 --- /dev/null +++ b/check/checkfunctions/testdata/libraries/IncludesFieldMisspelled/library.properties @@ -0,0 +1,10 @@ +name=IncludesFieldMisspelled +version=1.0.0 +author=Cristian Maglie , Pippo Pluto +maintainer=Cristian Maglie +sentence=A library that makes coding a web server a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=http://example.com/ +architectures=avr +include=IncludesFieldMisspelled.h diff --git a/check/checkfunctions/testdata/libraries/IncludesFieldMisspelled/src/IncludesFieldMisspelled.h b/check/checkfunctions/testdata/libraries/IncludesFieldMisspelled/src/IncludesFieldMisspelled.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/IncludesLTMinLength/library.properties b/check/checkfunctions/testdata/libraries/IncludesLTMinLength/library.properties new file mode 100644 index 000000000..a720a7472 --- /dev/null +++ b/check/checkfunctions/testdata/libraries/IncludesLTMinLength/library.properties @@ -0,0 +1,10 @@ +name=IncludesLTMinLength +version=1.0.0 +author=Cristian Maglie , Pippo Pluto +maintainer=Cristian Maglie +sentence=A library that makes coding a web server a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=http://example.com/ +architectures=avr +includes= diff --git a/check/checkfunctions/testdata/libraries/IncludesLTMinLength/src/IncludesLTMinLength.h b/check/checkfunctions/testdata/libraries/IncludesLTMinLength/src/IncludesLTMinLength.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/IncludesListSkip/library.properties b/check/checkfunctions/testdata/libraries/IncludesListSkip/library.properties new file mode 100644 index 000000000..f5bb19a4a --- /dev/null +++ b/check/checkfunctions/testdata/libraries/IncludesListSkip/library.properties @@ -0,0 +1,10 @@ +name=IncludesListSkip +version=1.0.0 +author=Cristian Maglie , Pippo Pluto +maintainer=Cristian Maglie +sentence=A library that makes coding a web server a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=http://example.com/ +architectures=avr +includes=IncludesListSkip1.h,,IncludesListSkip2.h diff --git a/check/checkfunctions/testdata/libraries/IncludesListSkip/src/IncludesListSkip1.h b/check/checkfunctions/testdata/libraries/IncludesListSkip/src/IncludesListSkip1.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/IncludesListSkip/src/IncludesListSkip2.h b/check/checkfunctions/testdata/libraries/IncludesListSkip/src/IncludesListSkip2.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/LdflagsFieldMisspelled/library.properties b/check/checkfunctions/testdata/libraries/LdflagsFieldMisspelled/library.properties new file mode 100644 index 000000000..696eabbe8 --- /dev/null +++ b/check/checkfunctions/testdata/libraries/LdflagsFieldMisspelled/library.properties @@ -0,0 +1,10 @@ +name=LdflagsFieldMisspelled +version=1.0.0 +author=Cristian Maglie , Pippo Pluto +maintainer=Cristian Maglie +sentence=A library that makes coding a web server a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=http://example.com/ +architectures=avr +ld_flags=-lm diff --git a/check/checkfunctions/testdata/libraries/LdflagsFieldMisspelled/src/LdflagsFieldMisspelled.h b/check/checkfunctions/testdata/libraries/LdflagsFieldMisspelled/src/LdflagsFieldMisspelled.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/LdflagsLTMinLength/library.properties b/check/checkfunctions/testdata/libraries/LdflagsLTMinLength/library.properties new file mode 100644 index 000000000..86340fe37 --- /dev/null +++ b/check/checkfunctions/testdata/libraries/LdflagsLTMinLength/library.properties @@ -0,0 +1,10 @@ +name=LdflagsLTMinLength +version=1.0.0 +author=Cristian Maglie , Pippo Pluto +maintainer=Cristian Maglie +sentence=A library that makes coding a web server a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=http://example.com/ +architectures=avr +ldflags=-l diff --git a/check/checkfunctions/testdata/libraries/LdflagsLTMinLength/src/LdflagsLTMinLength.h b/check/checkfunctions/testdata/libraries/LdflagsLTMinLength/src/LdflagsLTMinLength.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/LdflagsValid/library.properties b/check/checkfunctions/testdata/libraries/LdflagsValid/library.properties new file mode 100644 index 000000000..52e70de3b --- /dev/null +++ b/check/checkfunctions/testdata/libraries/LdflagsValid/library.properties @@ -0,0 +1,10 @@ +name=LdflagsValid +version=1.0.0 +author=Cristian Maglie , Pippo Pluto +maintainer=Cristian Maglie +sentence=A library that makes coding a web server a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=http://example.com/ +architectures=avr +ldflags=-lm diff --git a/check/checkfunctions/testdata/libraries/LdflagsValid/src/LdflagsValid.h b/check/checkfunctions/testdata/libraries/LdflagsValid/src/LdflagsValid.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/MaintainerLTMinLength/library.properties b/check/checkfunctions/testdata/libraries/MaintainerLTMinLength/library.properties new file mode 100644 index 000000000..f3465d816 --- /dev/null +++ b/check/checkfunctions/testdata/libraries/MaintainerLTMinLength/library.properties @@ -0,0 +1,9 @@ +name=MaintainerLTMinLength +version=1.0.0 +author=Cristian Maglie , Pippo Pluto +maintainer= +sentence=A library that makes coding a web server a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=http://example.com/ +architectures=avr diff --git a/check/checkfunctions/testdata/libraries/MaintainerLTMinLength/src/MaintainerLTMinLength.h b/check/checkfunctions/testdata/libraries/MaintainerLTMinLength/src/MaintainerLTMinLength.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/MaintainerStartsWithArduino/library.properties b/check/checkfunctions/testdata/libraries/MaintainerStartsWithArduino/library.properties new file mode 100644 index 000000000..7b829a66c --- /dev/null +++ b/check/checkfunctions/testdata/libraries/MaintainerStartsWithArduino/library.properties @@ -0,0 +1,9 @@ +name=MaintainerStartsWithArduino +version=1.0.0 +author=Cristian Maglie , Pippo Pluto +maintainer=Arduino Cristian Maglie +sentence=A library that makes coding a web server a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=http://example.com/ +architectures=avr diff --git a/check/checkfunctions/testdata/libraries/MaintainerStartsWithArduino/src/MaintainerStartsWithArduino.h b/check/checkfunctions/testdata/libraries/MaintainerStartsWithArduino/src/MaintainerStartsWithArduino.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/NameContainsArduino/library.properties b/check/checkfunctions/testdata/libraries/NameContainsArduino/library.properties new file mode 100644 index 000000000..314b55e76 --- /dev/null +++ b/check/checkfunctions/testdata/libraries/NameContainsArduino/library.properties @@ -0,0 +1,9 @@ +name=NameContainsArduino +version=1.0.0 +author=Cristian Maglie , Pippo Pluto +maintainer=Cristian Maglie +sentence=A library that makes coding a web server a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=http://example.com/ +architectures=avr diff --git a/check/checkfunctions/testdata/libraries/NameContainsArduino/src/NameContainsArduino.h b/check/checkfunctions/testdata/libraries/NameContainsArduino/src/NameContainsArduino.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/NameGTMaxLength/library.properties b/check/checkfunctions/testdata/libraries/NameGTMaxLength/library.properties new file mode 100644 index 000000000..52ef347f7 --- /dev/null +++ b/check/checkfunctions/testdata/libraries/NameGTMaxLength/library.properties @@ -0,0 +1,9 @@ +name=NameGTMaxLength012345678901234567890123456789012345678901234567890123456789 +version=1.0.0 +author=Cristian Maglie , Pippo Pluto +maintainer=Cristian Maglie +sentence=A library that makes coding a web server a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=http://example.com/ +architectures=avr diff --git a/check/checkfunctions/testdata/libraries/NameGTMaxLength/src/NameGTMaxLength.h b/check/checkfunctions/testdata/libraries/NameGTMaxLength/src/NameGTMaxLength.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/NameGTRecommendedLength/library.properties b/check/checkfunctions/testdata/libraries/NameGTRecommendedLength/library.properties new file mode 100644 index 000000000..af56227c8 --- /dev/null +++ b/check/checkfunctions/testdata/libraries/NameGTRecommendedLength/library.properties @@ -0,0 +1,9 @@ +name=NameGTRecommendedLength +version=1.0.0 +author=Cristian Maglie , Pippo Pluto +maintainer=Cristian Maglie +sentence=A library that makes coding a web server a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=http://example.com/ +architectures=avr diff --git a/check/checkfunctions/testdata/libraries/NameGTRecommendedLength/src/NameGTRecommendedLength.h b/check/checkfunctions/testdata/libraries/NameGTRecommendedLength/src/NameGTRecommendedLength.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/NameHasBadChars/library.properties b/check/checkfunctions/testdata/libraries/NameHasBadChars/library.properties new file mode 100644 index 000000000..388244694 --- /dev/null +++ b/check/checkfunctions/testdata/libraries/NameHasBadChars/library.properties @@ -0,0 +1,9 @@ +name=-NameHasBadChars +version=1.0.0 +author=Cristian Maglie , Pippo Pluto +maintainer=Cristian Maglie +sentence=A library that makes coding a web server a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=http://example.com/ +architectures=avr diff --git a/check/checkfunctions/testdata/libraries/NameHasBadChars/src/NameHasBadChars.h b/check/checkfunctions/testdata/libraries/NameHasBadChars/src/NameHasBadChars.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/NameHasLibrary/library.properties b/check/checkfunctions/testdata/libraries/NameHasLibrary/library.properties new file mode 100644 index 000000000..a20ad2716 --- /dev/null +++ b/check/checkfunctions/testdata/libraries/NameHasLibrary/library.properties @@ -0,0 +1,9 @@ +name=NameHasLibrary +version=1.0.0 +author=Cristian Maglie , Pippo Pluto +maintainer=Cristian Maglie +sentence=A library that makes coding a web server a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=http://example.com/ +architectures=avr diff --git a/check/checkfunctions/testdata/libraries/NameHasLibrary/src/NameHasLibrary.h b/check/checkfunctions/testdata/libraries/NameHasLibrary/src/NameHasLibrary.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/NameHasSpaces/library.properties b/check/checkfunctions/testdata/libraries/NameHasSpaces/library.properties new file mode 100644 index 000000000..1e225034e --- /dev/null +++ b/check/checkfunctions/testdata/libraries/NameHasSpaces/library.properties @@ -0,0 +1,9 @@ +name=Name Has Spaces +version=1.0.0 +author=Cristian Maglie , Pippo Pluto +maintainer=Cristian Maglie +sentence=A library that makes coding a web server a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=http://example.com/ +architectures=avr diff --git a/check/checkfunctions/testdata/libraries/NameHasSpaces/src/NameHasSpaces.h b/check/checkfunctions/testdata/libraries/NameHasSpaces/src/NameHasSpaces.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/NameLTMinLength/library.properties b/check/checkfunctions/testdata/libraries/NameLTMinLength/library.properties new file mode 100644 index 000000000..0d803bee7 --- /dev/null +++ b/check/checkfunctions/testdata/libraries/NameLTMinLength/library.properties @@ -0,0 +1,9 @@ +name= +version=1.0.0 +author=Cristian Maglie , Pippo Pluto +maintainer=Cristian Maglie +sentence=A library that makes coding a web server a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=http://example.com/ +architectures=avr diff --git a/check/checkfunctions/testdata/libraries/NameLTMinLength/src/NameLTMinLength.h b/check/checkfunctions/testdata/libraries/NameLTMinLength/src/NameLTMinLength.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/PrecompiledFieldMisspelled/library.properties b/check/checkfunctions/testdata/libraries/PrecompiledFieldMisspelled/library.properties new file mode 100644 index 000000000..96d6ef260 --- /dev/null +++ b/check/checkfunctions/testdata/libraries/PrecompiledFieldMisspelled/library.properties @@ -0,0 +1,10 @@ +name=PrecompiledFieldMisspelled +version=1.0.0 +author=Cristian Maglie , Pippo Pluto +maintainer=Cristian Maglie +sentence=A library that makes coding a web server a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=http://example.com/ +architectures=avr +precompile=true diff --git a/check/checkfunctions/testdata/libraries/PrecompiledFieldMisspelled/src/PrecompiledFieldMisspelled.h b/check/checkfunctions/testdata/libraries/PrecompiledFieldMisspelled/src/PrecompiledFieldMisspelled.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/PrecompiledInvalid/library.properties b/check/checkfunctions/testdata/libraries/PrecompiledInvalid/library.properties new file mode 100644 index 000000000..124294967 --- /dev/null +++ b/check/checkfunctions/testdata/libraries/PrecompiledInvalid/library.properties @@ -0,0 +1,10 @@ +name=PrecompiledInvalid +version=1.0.0 +author=Cristian Maglie , Pippo Pluto +maintainer=Cristian Maglie +sentence=A library that makes coding a web server a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=http://example.com/ +architectures=avr +precompiled=foo diff --git a/check/checkfunctions/testdata/libraries/PrecompiledInvalid/src/PrecompiledInvalid.h b/check/checkfunctions/testdata/libraries/PrecompiledInvalid/src/PrecompiledInvalid.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/SentenceLTMinLength/library.properties b/check/checkfunctions/testdata/libraries/SentenceLTMinLength/library.properties new file mode 100644 index 000000000..0c511751f --- /dev/null +++ b/check/checkfunctions/testdata/libraries/SentenceLTMinLength/library.properties @@ -0,0 +1,9 @@ +name=SentenceLTMinLength +version=1.0.0 +author=Cristian Maglie , Pippo Pluto +maintainer=Cristian Maglie +sentence= +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=http://example.com/ +architectures=avr diff --git a/check/checkfunctions/testdata/libraries/SentenceLTMinLength/src/SentenceLTMinLength.h b/check/checkfunctions/testdata/libraries/SentenceLTMinLength/src/SentenceLTMinLength.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/UrlFormatInvalid/library.properties b/check/checkfunctions/testdata/libraries/UrlFormatInvalid/library.properties new file mode 100644 index 000000000..fb0afd951 --- /dev/null +++ b/check/checkfunctions/testdata/libraries/UrlFormatInvalid/library.properties @@ -0,0 +1,9 @@ +name=UrlFormatInvalid +version=1.0.0 +author=Cristian Maglie , Pippo Pluto +maintainer=Cristian Maglie +sentence=A library that makes coding a web server a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=example.com +architectures=avr diff --git a/check/checkfunctions/testdata/libraries/UrlFormatInvalid/src/UrlFormatInvalid.h b/check/checkfunctions/testdata/libraries/UrlFormatInvalid/src/UrlFormatInvalid.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/VersionNotRelaxedSemver/library.properties b/check/checkfunctions/testdata/libraries/VersionNotRelaxedSemver/library.properties new file mode 100644 index 000000000..ccf83fca7 --- /dev/null +++ b/check/checkfunctions/testdata/libraries/VersionNotRelaxedSemver/library.properties @@ -0,0 +1,9 @@ +name=VersionNotRelaxedSemver +version=v1.0.0 +author=Cristian Maglie , Pippo Pluto +maintainer=Cristian Maglie +sentence=A library that makes coding a web server a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=http://example.com/ +architectures=avr diff --git a/check/checkfunctions/testdata/libraries/VersionNotRelaxedSemver/src/VersionNotRelaxedSemver.h b/check/checkfunctions/testdata/libraries/VersionNotRelaxedSemver/src/VersionNotRelaxedSemver.h new file mode 100644 index 000000000..e69de29bb diff --git a/check/checkfunctions/testdata/libraries/VersionNotSemver/library.properties b/check/checkfunctions/testdata/libraries/VersionNotSemver/library.properties new file mode 100644 index 000000000..006f4adaa --- /dev/null +++ b/check/checkfunctions/testdata/libraries/VersionNotSemver/library.properties @@ -0,0 +1,9 @@ +name=VersionNotSemver +version=1.0 +author=Cristian Maglie , Pippo Pluto +maintainer=Cristian Maglie +sentence=A library that makes coding a web server a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=http://example.com/ +architectures=avr diff --git a/check/checkfunctions/testdata/libraries/VersionNotSemver/src/VersionNotSemver.h b/check/checkfunctions/testdata/libraries/VersionNotSemver/src/VersionNotSemver.h new file mode 100644 index 000000000..e69de29bb diff --git a/test/test_all.py b/test/test_all.py index 4a901104c..0a25b7e51 100644 --- a/test/test_all.py +++ b/test/test_all.py @@ -178,6 +178,45 @@ def test_version(run_command): dateutil.parser.isoparse(output_list[1]) +def test_arduino_lint_official(run_command): + project_path = test_data_path.joinpath("ARDUINO_LINT_OFFICIAL") + + result = run_command(cmd=[project_path]) + assert not result.ok + + result = run_command(cmd=[project_path], custom_env={"ARDUINO_LINT_OFFICIAL": "true"}) + assert result.ok + + result = run_command(cmd=[project_path], custom_env={"ARDUINO_LINT_OFFICIAL": "false"}) + assert not result.ok + + result = run_command(cmd=[project_path], custom_env={"ARDUINO_LINT_OFFICIAL": "foo"}) + assert not result.ok + + +def test_arduino_lint_log_level(run_command): + project_path = test_data_path.joinpath("ValidSketch") + + result = run_command(cmd=[project_path], custom_env={"ARDUINO_LINT_LOG_LEVEL": "debug"}) + assert result.ok + + result = run_command(cmd=[project_path], custom_env={"ARDUINO_LINT_LOG_LEVEL": "foo"}) + assert not result.ok + + +def test_arduino_lint_log_format(run_command): + project_path = test_data_path.joinpath("ValidSketch") + + result = run_command(cmd=[project_path], custom_env={"ARDUINO_LINT_LOG_FORMAT": "text"}) + assert result.ok + + result = run_command(cmd=[project_path], custom_env={"ARDUINO_LINT_LOG_FORMAT": "json"}) + assert result.ok + + result = run_command(cmd=[project_path], custom_env={"ARDUINO_LINT_LOG_FORMAT": "foo"}) + assert not result.ok + + @pytest.fixture(scope="function") def run_command(pytestconfig, working_dir) -> typing.Callable[..., invoke.runners.Result]: """Provide a wrapper around invoke's `run` API so that every test will work in the same temporary folder. @@ -189,9 +228,7 @@ def run_command(pytestconfig, working_dir) -> typing.Callable[..., invoke.runner arduino_lint_path = pathlib.Path(pytestconfig.rootdir).parent / "arduino-lint" def _run( - cmd: list, - custom_working_dir: typing.Optional[str] = None, - custom_env: typing.Optional[dict] = None + cmd: list, custom_working_dir: typing.Optional[str] = None, custom_env: typing.Optional[dict] = None ) -> invoke.runners.Result: if cmd is None: cmd = [] diff --git a/test/testdata/ARDUINO_LINT_OFFICIAL/Arduino_Lib/library.properties b/test/testdata/ARDUINO_LINT_OFFICIAL/Arduino_Lib/library.properties new file mode 100644 index 000000000..e2aa0a72e --- /dev/null +++ b/test/testdata/ARDUINO_LINT_OFFICIAL/Arduino_Lib/library.properties @@ -0,0 +1,9 @@ +name=Arduino_Lib +version=1.0.0 +author=Cristian Maglie , Pippo Pluto +maintainer=Cristian Maglie +sentence=A library that makes coding a Webserver a breeze. +paragraph=Supports HTTP1.1 and you can do GET and POST. +category=Communication +url=http://example.com/ +architectures=avr diff --git a/test/testdata/ARDUINO_LINT_OFFICIAL/Arduino_Lib/src/Arduino_Lib.h b/test/testdata/ARDUINO_LINT_OFFICIAL/Arduino_Lib/src/Arduino_Lib.h new file mode 100644 index 000000000..e69de29bb