Skip to content

Commit 71c9367

Browse files
committed
check_library_structure: Improve error/warning messages
1 parent 73ec099 commit 71c9367

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

arduino-ci-script.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,7 +1386,7 @@ function check_library_structure() {
13861386

13871387
# Check whether folder exists
13881388
if [[ ! -d "$normalizedBasePath" ]]; then
1389-
echo "ERROR: Specified folder: $basePath doesn't exist."
1389+
echo "ERROR: ${basePath}: Folder doesn't exist."
13901390
return $ARDUINO_CI_SCRIPT_CHECK_LIBRARY_STRUCTURE_FOLDER_DOESNT_EXIST_EXIT_STATUS
13911391
fi
13921392

@@ -1400,15 +1400,15 @@ function check_library_structure() {
14001400
elif [[ $(find "$normalizedLibraryPath" -maxdepth 1 \( -type f -and -name 'library.properties' \)) && $(find "$normalizedLibraryPath" -maxdepth 1 -type d -and -iregex '^.*/src$') ]]; then
14011401
# 1.5 format library
14021402
if [[ ! $(find "$normalizedLibraryPath" -maxdepth 1 -type d -and -name 'src') ]]; then
1403-
echo "ERROR: $normalizedLibraryPath is a 1.5 format library with incorrect case in src subfolder name, which causes library to not be recognized on a filename case-sensitive OS such as Linux."
1403+
echo "ERROR: ${normalizedLibraryPath}: Is a 1.5 format library with incorrect case in src subfolder name, which causes library to not be recognized on a filename case-sensitive OS such as Linux."
14041404
exitStatus=$(set_exit_status "$exitStatus" $ARDUINO_CI_SCRIPT_CHECK_LIBRARY_STRUCTURE_INCORRECT_SRC_FOLDER_CASE_EXIT_STATUS)
14051405
# incorrect src folder case messes up some of the later checks so skip everything else
14061406
continue
14071407
elif [[ $(find "${normalizedLibraryPath}/src" -maxdepth 1 -type f \( -name '*.h' -or -name '*.hh' -or -name '*.hpp' \)) ]]; then
14081408
local onePointFiveFormat=true
14091409
fi
14101410
else
1411-
echo "ERROR: No valid library found in $normalizedLibraryPath"
1411+
echo "ERROR: ${normalizedLibraryPath}: No valid library found."
14121412
exitStatus=$(set_exit_status "$exitStatus" $ARDUINO_CI_SCRIPT_CHECK_LIBRARY_STRUCTURE_LIBRARY_NOT_FOUND_EXIT_STATUS)
14131413
continue
14141414
fi
@@ -1427,32 +1427,32 @@ function check_library_structure() {
14271427
continue
14281428
fi
14291429

1430-
echo "ERROR: $spuriousDotFolderPath causes the Arduino IDE to display a spurious folder warning."
1430+
echo "ERROR: ${spuriousDotFolderPath}: Causes the Arduino IDE to display a spurious folder warning."
14311431
exitStatus=$(set_exit_status "$exitStatus" $ARDUINO_CI_SCRIPT_CHECK_LIBRARY_STRUCTURE_SPURIOUS_DOT_FOLDER_EXIT_STATUS)
14321432
done <<<"$(find "$normalizedLibraryPath" -maxdepth 1 -type d -regex '^.*/\..*$' -not -name '.git' -not -name '.github' -not -name '.svn' -not -name '.hg' -not -name '.bzr' -not -name '.vscode')"
14331433

14341434
# Check for incorrect spelling of extras folder
14351435
if [[ $(find "$normalizedLibraryPath" -maxdepth 1 -type d -and -iregex '^.*/extras?$') && ! $(find "$normalizedLibraryPath" -maxdepth 1 -type d -and -name 'extras') ]]; then
14361436
#if [[ -d "$normalizedLibraryPath/extra" || -d "$normalizedLibraryPath/Extras" || -d "$normalizedLibraryPath/EXTRAS" ]] && [[ ! -d "$normalizedLibraryPath/extras" ]]; then
1437-
echo "ERROR: $normalizedLibraryPath has incorrectly spelled extras folder name. It should be exactly extras. See: https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#extra-documentation"
1437+
echo "ERROR: ${normalizedLibraryPath}: Incorrectly spelled extras folder name. It should be spelled exactly \"extras\". See: https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#extra-documentation"
14381438
exitStatus=$(set_exit_status "$exitStatus" $ARDUINO_CI_SCRIPT_CHECK_LIBRARY_STRUCTURE_INCORRECT_EXTRAS_FOLDER_NAME_EXIT_STATUS)
14391439
fi
14401440

14411441
# Check for incorrect spelling of examples folder
14421442
if [[ $(find "$normalizedLibraryPath" -maxdepth 1 -type d -and -iregex '^.*/examples?$') && ! $(find "$normalizedLibraryPath" -maxdepth 1 -type d -and -name 'examples') ]]; then
1443-
echo "ERROR: $normalizedLibraryPath has incorrect examples folder name. See: https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#library-examples"
1443+
echo "ERROR: ${normalizedLibraryPath}: Incorrect examples folder name. It should be spelled exactly \"examples\". See: https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#library-examples"
14441444
exitStatus=$(set_exit_status "$exitStatus" $ARDUINO_CI_SCRIPT_CHECK_LIBRARY_STRUCTURE_INCORRECT_EXAMPLES_FOLDER_NAME_EXIT_STATUS)
14451445
fi
14461446

14471447
# Check for 1.5 format with src and utility folders in library root
14481448
if [[ "$onePointFiveFormat" == true && $(find "$normalizedLibraryPath" -maxdepth 1 -type d -and -name 'utility') ]]; then
1449-
echo "ERROR: $normalizedLibraryPath is a 1.5 format library with src and utility folders in library root. The utility folder should be moved under the src folder. See: https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#source-code"
1449+
echo "ERROR: ${normalizedLibraryPath}: 1.5 format library with src and utility folders in library root. The utility folder should be moved under the src folder. See: https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#source-code"
14501450
exitStatus=$(set_exit_status "$exitStatus" $ARDUINO_CI_SCRIPT_CHECK_LIBRARY_STRUCTURE_SRC_AND_UTILITY_FOLDERS_EXIT_STATUS)
14511451
fi
14521452

14531453
# Check for inconsequential missing library.properties file
14541454
if ! [[ -e "$normalizedLibraryPath/library.properties" ]]; then
1455-
echo "WARNING: $normalizedLibraryPath is missing a library.properties file. While not required, it's recommended to add this file to provide helpful metadata. See: https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#library-metadata"
1455+
echo "WARNING: ${normalizedLibraryPath}: Missing library.properties file. While not required, it's recommended to add this file to provide helpful metadata. See: https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#library-metadata"
14561456
fi
14571457

14581458
# Check for library.properties files in the src folder
@@ -1463,14 +1463,14 @@ function check_library_structure() {
14631463
continue
14641464
fi
14651465

1466-
echo "ERROR: $normalizedLibraryPropertiesPath is a stray file. library.properties should be located in the library root folder."
1466+
echo "ERROR: ${normalizedLibraryPropertiesPath}: Stray file. library.properties should be located in the library root folder."
14671467
exitStatus=$(set_exit_status "$exitStatus" $ARDUINO_CI_SCRIPT_CHECK_LIBRARY_STRUCTURE_STRAY_LIBRARY_PROPERTIES_EXIT_STATUS)
14681468
done <<<"$(find "$normalizedLibraryPath/src" -maxdepth 1 -type f -iname 'library.properties')"
14691469
fi
14701470

14711471
# Check for missing keywords.txt file
14721472
if ! [[ -e "$normalizedLibraryPath/keywords.txt" ]]; then
1473-
echo "WARNING: $normalizedLibraryPath is missing a keywords.txt file. While not required, it's recommended to add this file to provide keyword highlighting in the Arduino IDE. See: https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#keywords"
1473+
echo "WARNING: ${normalizedLibraryPath}: Missing keywords.txt file. While not required, it's recommended to add this file to provide keyword highlighting in the Arduino IDE. See: https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#keywords"
14741474
fi
14751475

14761476
# Check for keywords.txt files in the src folder
@@ -1481,14 +1481,14 @@ function check_library_structure() {
14811481
continue
14821482
fi
14831483

1484-
echo "ERROR: $keywordsTxtPath is a stray file. keywords.txt should be located in the library root folder."
1484+
echo "ERROR: ${keywordsTxtPath}: Stray file. keywords.txt should be located in the library root folder."
14851485
exitStatus=$(set_exit_status "$exitStatus" $ARDUINO_CI_SCRIPT_CHECK_LIBRARY_STRUCTURE_STRAY_KEYWORDS_TXT_EXIT_STATUS)
14861486
done <<<"$(find "$normalizedLibraryPath/src" -maxdepth 1 -type f -iname 'keywords.txt')"
14871487
fi
14881488

14891489
# Check for sketch files outside of the src or extras folders
14901490
if [[ $(find "$normalizedLibraryPath" -maxdepth 1 -path './examples' -prune -or -path './extras' -prune -or \( -type f -and \( -iname '*.ino' -or -iname '*.pde' \) \)) ]]; then
1491-
echo "ERROR: $normalizedLibraryPath has sketch files found outside the examples and extras folders."
1491+
echo "ERROR: ${normalizedLibraryPath}: Sketch files found outside the examples and extras folders."
14921492
exitStatus=$(set_exit_status "$exitStatus" $ARDUINO_CI_SCRIPT_CHECK_LIBRARY_STRUCTURE_STRAY_SKETCH_EXIT_STATUS)
14931493
fi
14941494

tests/check_library_structure.bats

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ source ../arduino-ci-script.sh
88
echo "Exit status: $status | Expected: $expectedExitStatus"
99
[ "$status" -eq $expectedExitStatus ]
1010
[ "${#lines[@]}" -eq 1 ]
11-
outputRegex="^WARNING: \./check_library_structure/ValidLibraryOnePointZero is missing a library\.properties file. While not required, it's recommended to add this file to provide helpful metadata\. See: https://github\.com/arduino/Arduino/wiki/Arduino-IDE-1\.5:-Library-specification#library-metadata$"
11+
outputRegex="^WARNING: \./check_library_structure/ValidLibraryOnePointZero: Missing library\.properties file\. While not required, it's recommended to add this file to provide helpful metadata\. See: https://github\.com/arduino/Arduino/wiki/Arduino-IDE-1\.5:-Library-specification#library-metadata$"
1212
[[ "${lines[0]}" =~ $outputRegex ]]
1313
}
1414

@@ -34,7 +34,7 @@ source ../arduino-ci-script.sh
3434
echo "Exit status: $status | Expected: $expectedExitStatus"
3535
[ "$status" -eq $expectedExitStatus ]
3636
[ "${#lines[@]}" -eq 1 ]
37-
outputRegex="^WARNING: \./check_library_structure/InvalidLibraryBelowDepth is missing a library\.properties file\. While not required, it's recommended to add this file to provide helpful metadata\. See: https://github\.com/arduino/Arduino/wiki/Arduino-IDE-1\.5:-Library-specification#library-metadata$"
37+
outputRegex="^WARNING: \./check_library_structure/InvalidLibraryBelowDepth: Missing library\.properties file\. While not required, it's recommended to add this file to provide helpful metadata\. See: https://github\.com/arduino/Arduino/wiki/Arduino-IDE-1\.5:-Library-specification#library-metadata$"
3838
[[ "${lines[0]}" =~ $outputRegex ]]
3939
}
4040

@@ -44,7 +44,7 @@ source ../arduino-ci-script.sh
4444
echo "Exit status: $status | Expected: $expectedExitStatus"
4545
[ "$status" -eq $expectedExitStatus ]
4646
[ "${#lines[@]}" -eq 1 ]
47-
outputRegex="^ERROR: Specified folder: \./check_library_structure/DoesntExist doesn't exist\.$"
47+
outputRegex="^ERROR: \./check_library_structure/DoesntExist: Folder doesn't exist\.$"
4848
[[ "${lines[0]}" =~ $outputRegex ]]
4949
}
5050

@@ -54,7 +54,7 @@ source ../arduino-ci-script.sh
5454
echo "Exit status: $status | Expected: $expectedExitStatus"
5555
[ "$status" -eq $expectedExitStatus ]
5656
[ "${#lines[@]}" -eq 1 ]
57-
outputRegex='^ERROR: \./check_library_structure/IncorrectSrcFolderCase is a 1\.5 format library with incorrect case in src subfolder name, which causes library to not be recognized on a filename case-sensitive OS such as Linux\.$'
57+
outputRegex='^ERROR: \./check_library_structure/IncorrectSrcFolderCase: Is a 1\.5 format library with incorrect case in src subfolder name, which causes library to not be recognized on a filename case-sensitive OS such as Linux\.$'
5858
[[ "${lines[0]}" =~ $outputRegex ]]
5959
}
6060

@@ -64,7 +64,7 @@ source ../arduino-ci-script.sh
6464
echo "Exit status: $status | Expected: $expectedExitStatus"
6565
[ "$status" -eq $expectedExitStatus ]
6666
[ "${#lines[@]}" -eq 1 ]
67-
outputRegex='^ERROR: \./check_library_structure/MultipleInvalidLibraries/IncorrectSrcFolderCase is a 1\.5 format library with incorrect case in src subfolder name, which causes library to not be recognized on a filename case-sensitive OS such as Linux\.$'
67+
outputRegex='^ERROR: \./check_library_structure/MultipleInvalidLibraries/IncorrectSrcFolderCase: Is a 1\.5 format library with incorrect case in src subfolder name, which causes library to not be recognized on a filename case-sensitive OS such as Linux\.$'
6868
[[ "${lines[0]}" =~ $outputRegex ]]
6969
}
7070

@@ -74,7 +74,7 @@ source ../arduino-ci-script.sh
7474
echo "Exit status: $status | Expected: $expectedExitStatus"
7575
[ "$status" -eq $expectedExitStatus ]
7676
[ "${#lines[@]}" -eq 1 ]
77-
outputRegex='^ERROR: No valid library found in \./check_library_structure/NotLibrary$'
77+
outputRegex='^ERROR: \./check_library_structure/NotLibrary: No valid library found\.$'
7878
[[ "${lines[0]}" =~ $outputRegex ]]
7979
}
8080

@@ -124,7 +124,7 @@ source ../arduino-ci-script.sh
124124
echo "Exit status: $status | Expected: $expectedExitStatus"
125125
[ "$status" -eq $expectedExitStatus ]
126126
[ "${#lines[@]}" -eq 1 ]
127-
outputRegex='^ERROR: \./check_library_structure/SpuriousDotFolder/\.asdf causes the Arduino IDE to display a spurious folder warning\.$'
127+
outputRegex='^ERROR: \./check_library_structure/SpuriousDotFolder/\.asdf: Causes the Arduino IDE to display a spurious folder warning\.$'
128128
[[ "${lines[0]}" =~ $outputRegex ]]
129129
}
130130

@@ -134,7 +134,7 @@ source ../arduino-ci-script.sh
134134
echo "Exit status: $status | Expected: $expectedExitStatus"
135135
[ "$status" -eq $expectedExitStatus ]
136136
[ "${#lines[@]}" -eq 1 ]
137-
outputRegex='^ERROR: \./check_library_structure/IncorrectExtrasFolder has incorrectly spelled extras folder name\. It should be exactly extras\. See: https://github\.com/arduino/Arduino/wiki/Arduino-IDE-1\.5:-Library-specification#extra-documentation$'
137+
outputRegex='^ERROR: \./check_library_structure/IncorrectExtrasFolder: Incorrectly spelled extras folder name\. It should be spelled exactly "extras"\. See: https://github\.com/arduino/Arduino/wiki/Arduino-IDE-1\.5:-Library-specification#extra-documentation$'
138138
[[ "${lines[0]}" =~ $outputRegex ]]
139139
}
140140

@@ -144,7 +144,7 @@ source ../arduino-ci-script.sh
144144
echo "Exit status: $status | Expected: $expectedExitStatus"
145145
[ "$status" -eq $expectedExitStatus ]
146146
[ "${#lines[@]}" -eq 1 ]
147-
outputRegex='^ERROR: \./check_library_structure/IncorrectExamplesFolder has incorrect examples folder name. See: https://github\.com/arduino/Arduino/wiki/Arduino-IDE-1\.5:-Library-specification#library-examples$'
147+
outputRegex='^ERROR: \./check_library_structure/IncorrectExamplesFolder: Incorrect examples folder name\. It should be spelled exactly \"examples\"\. See: https://github.com/arduino/Arduino/wiki/Arduino-IDE-1\.5:-Library-specification#library-examples$'
148148
[[ "${lines[0]}" =~ $outputRegex ]]
149149
}
150150

@@ -154,7 +154,7 @@ source ../arduino-ci-script.sh
154154
echo "Exit status: $status | Expected: $expectedExitStatus"
155155
[ "$status" -eq $expectedExitStatus ]
156156
[ "${#lines[@]}" -eq 1 ]
157-
outputRegex='^ERROR: \./check_library_structure/SrcAndUtiltyFolders is a 1\.5 format library with src and utility folders in library root\. The utility folder should be moved under the src folder\. See: https://github\.com/arduino/Arduino/wiki/Arduino-IDE-1\.5:-Library-specification#source-code$'
157+
outputRegex='^ERROR: \./check_library_structure/SrcAndUtiltyFolders: 1\.5 format library with src and utility folders in library root\. The utility folder should be moved under the src folder\. See: https://github\.com/arduino/Arduino/wiki/Arduino-IDE-1\.5:-Library-specification#source-code$'
158158
[[ "${lines[0]}" =~ $outputRegex ]]
159159
}
160160

@@ -164,7 +164,7 @@ source ../arduino-ci-script.sh
164164
echo "Exit status: $status | Expected: $expectedExitStatus"
165165
[ "$status" -eq $expectedExitStatus ]
166166
[ "${#lines[@]}" -eq 1 ]
167-
outputRegex="^WARNING: \./check_library_structure/MissingLibraryProperties is missing a library\.properties file. While not required, it's recommended to add this file to provide helpful metadata\. See: https://github\.com/arduino/Arduino/wiki/Arduino-IDE-1\.5:-Library-specification#library-metadata$"
167+
outputRegex="^WARNING: \./check_library_structure/MissingLibraryProperties: Missing library.properties file\. While not required, it's recommended to add this file to provide helpful metadata\. See: https://github\.com/arduino/Arduino/wiki/Arduino-IDE-1\.5:-Library-specification#library-metadata$"
168168
[[ "${lines[0]}" =~ $outputRegex ]]
169169
}
170170

@@ -174,7 +174,7 @@ source ../arduino-ci-script.sh
174174
echo "Exit status: $status | Expected: $expectedExitStatus"
175175
[ "$status" -eq $expectedExitStatus ]
176176
[ "${#lines[@]}" -eq 1 ]
177-
outputRegex='^ERROR: \./check_library_structure/StrayLibraryProperties/src/library\.properties is a stray file\. library\.properties should be located in the library root folder\.$'
177+
outputRegex='^ERROR: \./check_library_structure/StrayLibraryProperties/src/library\.properties: Stray file\. library\.properties should be located in the library root folder\.$'
178178
[[ "${lines[0]}" =~ $outputRegex ]]
179179
}
180180

@@ -184,7 +184,7 @@ source ../arduino-ci-script.sh
184184
echo "Exit status: $status | Expected: $expectedExitStatus"
185185
[ "$status" -eq $expectedExitStatus ]
186186
[ "${#lines[@]}" -eq 1 ]
187-
outputRegex="^WARNING: \./check_library_structure/MissingKeywordsTxt is missing a keywords\.txt file\. While not required, it's recommended to add this file to provide keyword highlighting in the Arduino IDE\. See: https://github\.com/arduino/Arduino/wiki/Arduino-IDE-1\.5:-Library-specification#keywords$"
187+
outputRegex="^WARNING: \./check_library_structure/MissingKeywordsTxt: Missing keywords\.txt file\. While not required, it's recommended to add this file to provide keyword highlighting in the Arduino IDE\. See: https://github\.com/arduino/Arduino/wiki/Arduino-IDE-1\.5:-Library-specification#keywords$"
188188
[[ "${lines[0]}" =~ $outputRegex ]]
189189
}
190190

@@ -194,7 +194,7 @@ source ../arduino-ci-script.sh
194194
echo "Exit status: $status | Expected: $expectedExitStatus"
195195
[ "$status" -eq $expectedExitStatus ]
196196
[ "${#lines[@]}" -eq 1 ]
197-
outputRegex='^ERROR: \./check_library_structure/StrayKeywordsTxt/src/keywords\.txt is a stray file. keywords\.txt should be located in the library root folder\.$'
197+
outputRegex='^ERROR: \./check_library_structure/StrayKeywordsTxt/src/keywords\.txt: Stray file\. keywords\.txt should be located in the library root folder\.$'
198198
[[ "${lines[0]}" =~ $outputRegex ]]
199199
}
200200

@@ -204,7 +204,7 @@ source ../arduino-ci-script.sh
204204
echo "Exit status: $status | Expected: $expectedExitStatus"
205205
[ "$status" -eq $expectedExitStatus ]
206206
[ "${#lines[@]}" -eq 1 ]
207-
outputRegex='^ERROR: \./check_library_structure/SketchOutsideExamples has sketch files found outside the examples and extras folders\.$'
207+
outputRegex='^ERROR: \./check_library_structure/SketchOutsideExamples: Sketch files found outside the examples and extras folders\.$'
208208
[[ "${lines[0]}" =~ $outputRegex ]]
209209
}
210210

@@ -214,7 +214,7 @@ source ../arduino-ci-script.sh
214214
echo "Exit status: $status | Expected: $expectedExitStatus"
215215
[ "$status" -eq $expectedExitStatus ]
216216
[ "${#lines[@]}" -eq 1 ]
217-
outputRegex='^ERROR: \./check_library_structure/IncorrectSketchExtensionCase/examples/example1/example1\.Ino: Has incorrect extension case, which causes it to not be recognized on a filename case-sensitive OS such as Linux\.$'
217+
outputRegex='^ERROR: \./check_library_structure/IncorrectSketchExtensionCase/examples/example1/example1\.Ino: Incorrect extension case\. This causes it to not be recognized on a filename case-sensitive OS such as Linux\.$'
218218
[[ "${lines[0]}" =~ $outputRegex ]]
219219
}
220220

0 commit comments

Comments
 (0)