Skip to content

Commit 6aff362

Browse files
committed
check_sketch_structure: Separate unit tests into their own file
1 parent a76082a commit 6aff362

File tree

3 files changed

+131
-112
lines changed

3 files changed

+131
-112
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ before_install:
7171
- bats check_library_manager_compliance.bats
7272
- bats check_library_properties.bats
7373
- bats check_library_structure.bats
74+
- bats check_sketch_structure.bats
7475
- bats miscellaneous.bats
7576
- cd ..
7677

tests/check_library_structure.bats

Lines changed: 0 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -225,38 +225,6 @@ TESTS_BATS_APPLICATION_FOLDER="$APPLICATION_FOLDER"
225225
[[ "${lines[0]}" =~ $outputRegex ]]
226226
}
227227

228-
# check_sketch_structure
229-
230-
@test "check_sketch_structure \"./check_library_structure/DoesntExist\"" {
231-
expectedExitStatus=$ARDUINO_CI_SCRIPT_CHECK_SKETCH_STRUCTURE_FOLDER_DOESNT_EXIST_EXIT_STATUS
232-
run check_sketch_structure "./check_library_structure/DoesntExist"
233-
echo "Exit status: $status | Expected: $expectedExitStatus"
234-
[ "$status" -eq $expectedExitStatus ]
235-
[ "${#lines[@]}" -eq 1 ]
236-
outputRegex='^'
237-
[[ "${lines[0]}" =~ $outputRegex ]]
238-
}
239-
240-
@test "check_sketch_structure \"./check_library_structure/PdeSketchExtension\"" {
241-
expectedExitStatus=$ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS
242-
run check_sketch_structure "./check_library_structure/PdeSketchExtension"
243-
echo "Exit status: $status | Expected: $expectedExitStatus"
244-
[ "$status" -eq $expectedExitStatus ]
245-
[ "${#lines[@]}" -eq 1 ]
246-
outputRegex='^'
247-
[[ "${lines[0]}" =~ $outputRegex ]]
248-
}
249-
250-
@test "check_sketch_structure \"./check_library_structure/IncorrectSketchExtensionCase\"" {
251-
expectedExitStatus=$ARDUINO_CI_SCRIPT_CHECK_SKETCH_STRUCTURE_INCORRECT_EXTENSION_CASE_EXIT_STATUS
252-
run check_sketch_structure "./check_library_structure/IncorrectSketchExtensionCase"
253-
echo "Exit status: $status | Expected: $expectedExitStatus"
254-
[ "$status" -eq $expectedExitStatus ]
255-
[ "${#lines[@]}" -eq 1 ]
256-
outputRegex='^'
257-
[[ "${lines[0]}" =~ $outputRegex ]]
258-
}
259-
260228
@test "check_library_structure \"./check_library_structure/IncorrectSketchExtensionCase\"" {
261229
expectedExitStatus=$ARDUINO_CI_SCRIPT_CHECK_LIBRARY_STRUCTURE_INCORRECT_SKETCH_EXTENSION_CASE_EXIT_STATUS
262230
run check_library_structure "./check_library_structure/IncorrectSketchExtensionCase"
@@ -267,26 +235,6 @@ TESTS_BATS_APPLICATION_FOLDER="$APPLICATION_FOLDER"
267235
[[ "${lines[0]}" =~ $outputRegex ]]
268236
}
269237

270-
@test "check_sketch_structure \"./check_library_structure/SketchFolderStartsWithNumber\"" {
271-
expectedExitStatus=$ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS
272-
run check_sketch_structure "./check_library_structure/SketchFolderStartsWithNumber"
273-
echo "Exit status: $status | Expected: $expectedExitStatus"
274-
[ "$status" -eq $expectedExitStatus ]
275-
[ "${#lines[@]}" -eq 1 ]
276-
outputRegex='^'
277-
[[ "${lines[0]}" =~ $outputRegex ]]
278-
}
279-
280-
@test "check_sketch_structure \"./check_library_structure/InvalidCharactersAtStartOfSketchFolder\"" {
281-
expectedExitStatus=$ARDUINO_CI_SCRIPT_CHECK_SKETCH_STRUCTURE_FOLDER_NAME_HAS_INVALID_FIRST_CHARACTER_EXIT_STATUS
282-
run check_sketch_structure "./check_library_structure/InvalidCharactersAtStartOfSketchFolder"
283-
echo "Exit status: $status | Expected: $expectedExitStatus"
284-
[ "$status" -eq $expectedExitStatus ]
285-
[ "${#lines[@]}" -eq 1 ]
286-
outputRegex='^'
287-
[[ "${lines[0]}" =~ $outputRegex ]]
288-
}
289-
290238
@test "check_library_structure \"./check_library_structure/InvalidCharactersAtStartOfSketchFolder\"" {
291239
expectedExitStatus=$ARDUINO_CI_SCRIPT_CHECK_LIBRARY_STRUCTURE_SKETCH_FOLDER_NAME_HAS_INVALID_FIRST_CHARACTER_EXIT_STATUS
292240
run check_library_structure "./check_library_structure/InvalidCharactersAtStartOfSketchFolder"
@@ -297,16 +245,6 @@ TESTS_BATS_APPLICATION_FOLDER="$APPLICATION_FOLDER"
297245
[[ "${lines[0]}" =~ $outputRegex ]]
298246
}
299247

300-
@test "check_sketch_structure \"./check_library_structure/InvalidCharactersInSketchFolder\"" {
301-
expectedExitStatus=$ARDUINO_CI_SCRIPT_CHECK_SKETCH_STRUCTURE_FOLDER_NAME_HAS_INVALID_CHARACTER_EXIT_STATUS
302-
run check_sketch_structure "./check_library_structure/InvalidCharactersInSketchFolder"
303-
echo "Exit status: $status | Expected: $expectedExitStatus"
304-
[ "$status" -eq $expectedExitStatus ]
305-
[ "${#lines[@]}" -eq 1 ]
306-
outputRegex='^'
307-
[[ "${lines[0]}" =~ $outputRegex ]]
308-
}
309-
310248
@test "check_library_structure \"./check_library_structure/InvalidCharactersInSketchFolder\"" {
311249
expectedExitStatus=$ARDUINO_CI_SCRIPT_CHECK_LIBRARY_STRUCTURE_SKETCH_FOLDER_NAME_HAS_INVALID_CHARACTER_EXIT_STATUS
312250
run check_library_structure "./check_library_structure/InvalidCharactersInSketchFolder"
@@ -317,16 +255,6 @@ TESTS_BATS_APPLICATION_FOLDER="$APPLICATION_FOLDER"
317255
[[ "${lines[0]}" =~ $outputRegex ]]
318256
}
319257

320-
@test "check_sketch_structure \"./check_library_structure/SketchFolderNameTooLong\"" {
321-
expectedExitStatus=$ARDUINO_CI_SCRIPT_CHECK_SKETCH_STRUCTURE_FOLDER_NAME_TOO_LONG_EXIT_STATUS
322-
run check_sketch_structure "./check_library_structure/SketchFolderNameTooLong"
323-
echo "Exit status: $status | Expected: $expectedExitStatus"
324-
[ "$status" -eq $expectedExitStatus ]
325-
[ "${#lines[@]}" -eq 1 ]
326-
outputRegex='^ERROR: Folder name asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf exceeds the maximum of 63 characters\.'
327-
[[ "${lines[0]}" =~ $outputRegex ]]
328-
}
329-
330258
@test "check_library_structure \"./check_library_structure/SketchFolderNameTooLong\"" {
331259
expectedExitStatus=$ARDUINO_CI_SCRIPT_CHECK_LIBRARY_STRUCTURE_SKETCH_FOLDER_NAME_TOO_LONG_EXIT_STATUS
332260
run check_library_structure "./check_library_structure/SketchFolderNameTooLong"
@@ -337,16 +265,6 @@ TESTS_BATS_APPLICATION_FOLDER="$APPLICATION_FOLDER"
337265
[[ "${lines[0]}" =~ $outputRegex ]]
338266
}
339267

340-
@test "check_sketch_structure \"./check_library_structure/SketchFolderNameTooLongExtras\"" {
341-
expectedExitStatus=$ARDUINO_CI_SCRIPT_CHECK_SKETCH_STRUCTURE_FOLDER_NAME_TOO_LONG_EXIT_STATUS
342-
run check_sketch_structure "./check_library_structure/SketchFolderNameTooLongExtras"
343-
echo "Exit status: $status | Expected: $expectedExitStatus"
344-
[ "$status" -eq $expectedExitStatus ]
345-
[ "${#lines[@]}" -eq 1 ]
346-
outputRegex='^ERROR: Folder name asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf exceeds the maximum of 63 characters\.'
347-
[[ "${lines[0]}" =~ $outputRegex ]]
348-
}
349-
350268
@test "check_library_structure \"./check_library_structure/SketchFolderNameTooLongExtras\"" {
351269
expectedExitStatus=$ARDUINO_CI_SCRIPT_CHECK_LIBRARY_STRUCTURE_SKETCH_FOLDER_NAME_TOO_LONG_EXIT_STATUS
352270
run check_library_structure "./check_library_structure/SketchFolderNameTooLongExtras"
@@ -357,16 +275,6 @@ TESTS_BATS_APPLICATION_FOLDER="$APPLICATION_FOLDER"
357275
[[ "${lines[0]}" =~ $outputRegex ]]
358276
}
359277

360-
@test "check_sketch_structure \"./check_library_structure/SketchFolderNameMismatch\"" {
361-
expectedExitStatus=$ARDUINO_CI_SCRIPT_CHECK_SKETCH_STRUCTURE_SKETCH_NAME_MISMATCH_EXIT_STATUS
362-
run check_sketch_structure "./check_library_structure/SketchFolderNameMismatch"
363-
echo "Exit status: $status | Expected: $expectedExitStatus"
364-
[ "$status" -eq $expectedExitStatus ]
365-
[ "${#lines[@]}" -eq 1 ]
366-
outputRegex='^ERROR: Sketch folder name \./check_library_structure/SketchFolderNameMismatch/examples/example1 does not match the sketch filename\.'
367-
[[ "${lines[0]}" =~ $outputRegex ]]
368-
}
369-
370278
@test "check_library_structure \"./check_library_structure/SketchFolderNameMismatch\"" {
371279
expectedExitStatus=$ARDUINO_CI_SCRIPT_CHECK_LIBRARY_STRUCTURE_SKETCH_NAME_MISMATCH_EXIT_STATUS
372280
run check_library_structure "./check_library_structure/SketchFolderNameMismatch"
@@ -377,16 +285,6 @@ TESTS_BATS_APPLICATION_FOLDER="$APPLICATION_FOLDER"
377285
[[ "${lines[0]}" =~ $outputRegex ]]
378286
}
379287

380-
@test "check_sketch_structure \"./check_library_structure/MultipleSketchesInSameFolderUnix\"" {
381-
expectedExitStatus=$ARDUINO_CI_SCRIPT_CHECK_SKETCH_STRUCTURE_MULTIPLE_SKETCHES_EXIT_STATUS
382-
run check_sketch_structure "./check_library_structure/MultipleSketchesInSameFolderUnix"
383-
echo "Exit status: $status | Expected: $expectedExitStatus"
384-
[ "$status" -eq $expectedExitStatus ]
385-
[ "${#lines[@]}" -eq 1 ]
386-
outputRegex='^ERROR: Multiple sketches found in the same folder \(\./check_library_structure/MultipleSketchesInSameFolderUnix/examples/example1\)\.'
387-
[[ "${lines[0]}" =~ $outputRegex ]]
388-
}
389-
390288
@test "check_library_structure \"./check_library_structure/MultipleSketchesInSameFolderUnix\"" {
391289
expectedExitStatus=$ARDUINO_CI_SCRIPT_CHECK_LIBRARY_STRUCTURE_MULTIPLE_SKETCHES_EXIT_STATUS
392290
run check_library_structure "./check_library_structure/MultipleSketchesInSameFolderUnix"
@@ -397,16 +295,6 @@ TESTS_BATS_APPLICATION_FOLDER="$APPLICATION_FOLDER"
397295
[[ "${lines[0]}" =~ $outputRegex ]]
398296
}
399297

400-
@test "check_sketch_structure \"./check_library_structure/MultipleSketchesInSameFolderMac\"" {
401-
expectedExitStatus=$ARDUINO_CI_SCRIPT_CHECK_SKETCH_STRUCTURE_MULTIPLE_SKETCHES_EXIT_STATUS
402-
run check_sketch_structure "./check_library_structure/MultipleSketchesInSameFolderMac"
403-
echo "Exit status: $status | Expected: $expectedExitStatus"
404-
[ "$status" -eq $expectedExitStatus ]
405-
[ "${#lines[@]}" -eq 1 ]
406-
outputRegex='^ERROR: Multiple sketches found in the same folder \(\./check_library_structure/MultipleSketchesInSameFolderMac/examples/example1\)\.'
407-
[[ "${lines[0]}" =~ $outputRegex ]]
408-
}
409-
410298
@test "check_library_structure \"./check_library_structure/MultipleSketchesInSameFolderMac\"" {
411299
expectedExitStatus=$ARDUINO_CI_SCRIPT_CHECK_LIBRARY_STRUCTURE_MULTIPLE_SKETCHES_EXIT_STATUS
412300
run check_library_structure "./check_library_structure/MultipleSketchesInSameFolderMac"

tests/check_sketch_structure.bats

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
#!/usr/bin/env bats
2+
3+
source ../arduino-ci-script.sh
4+
5+
# Must be >= 1.8.0
6+
TESTS_BATS_IDE_VERSION="1.8.6"
7+
TESTS_BATS_APPLICATION_FOLDER="$APPLICATION_FOLDER"
8+
9+
# Make sure the test's environment variables were configured
10+
11+
@test "\"\$TESTS_BATS_IDE_VERSION\" != \"\"" {
12+
[ "$TESTS_BATS_IDE_VERSION" != "" ]
13+
# The Xvfb command breaks the unit tests on Travis CI. That command is run with Arduino IDE 1.6.13 or older.
14+
virtualFramebufferRequiredIDEversionsRegex="^1.[56]"
15+
[[ ! "$TESTS_BATS_IDE_VERSION" =~ $virtualFramebufferRequiredIDEversionsRegex ]]
16+
}
17+
18+
@test "\"\$TESTS_BATS_APPLICATION_FOLDER\" != \"\"" {
19+
[ "$TESTS_BATS_APPLICATION_FOLDER" != "" ]
20+
}
21+
22+
@test "check_sketch_structure \"./check_library_structure/DoesntExist\"" {
23+
expectedExitStatus=$ARDUINO_CI_SCRIPT_CHECK_SKETCH_STRUCTURE_FOLDER_DOESNT_EXIST_EXIT_STATUS
24+
run check_sketch_structure "./check_library_structure/DoesntExist"
25+
echo "Exit status: $status | Expected: $expectedExitStatus"
26+
[ "$status" -eq $expectedExitStatus ]
27+
[ "${#lines[@]}" -eq 1 ]
28+
outputRegex='^'
29+
[[ "${lines[0]}" =~ $outputRegex ]]
30+
}
31+
32+
@test "check_sketch_structure \"./check_library_structure/PdeSketchExtension\"" {
33+
expectedExitStatus=$ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS
34+
run check_sketch_structure "./check_library_structure/PdeSketchExtension"
35+
echo "Exit status: $status | Expected: $expectedExitStatus"
36+
[ "$status" -eq $expectedExitStatus ]
37+
[ "${#lines[@]}" -eq 1 ]
38+
outputRegex='^'
39+
[[ "${lines[0]}" =~ $outputRegex ]]
40+
}
41+
42+
@test "check_sketch_structure \"./check_library_structure/IncorrectSketchExtensionCase\"" {
43+
expectedExitStatus=$ARDUINO_CI_SCRIPT_CHECK_SKETCH_STRUCTURE_INCORRECT_EXTENSION_CASE_EXIT_STATUS
44+
run check_sketch_structure "./check_library_structure/IncorrectSketchExtensionCase"
45+
echo "Exit status: $status | Expected: $expectedExitStatus"
46+
[ "$status" -eq $expectedExitStatus ]
47+
[ "${#lines[@]}" -eq 1 ]
48+
outputRegex='^'
49+
[[ "${lines[0]}" =~ $outputRegex ]]
50+
}
51+
52+
@test "check_sketch_structure \"./check_library_structure/SketchFolderStartsWithNumber\"" {
53+
expectedExitStatus=$ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS
54+
run check_sketch_structure "./check_library_structure/SketchFolderStartsWithNumber"
55+
echo "Exit status: $status | Expected: $expectedExitStatus"
56+
[ "$status" -eq $expectedExitStatus ]
57+
[ "${#lines[@]}" -eq 1 ]
58+
outputRegex='^'
59+
[[ "${lines[0]}" =~ $outputRegex ]]
60+
}
61+
62+
@test "check_sketch_structure \"./check_library_structure/InvalidCharactersAtStartOfSketchFolder\"" {
63+
expectedExitStatus=$ARDUINO_CI_SCRIPT_CHECK_SKETCH_STRUCTURE_FOLDER_NAME_HAS_INVALID_FIRST_CHARACTER_EXIT_STATUS
64+
run check_sketch_structure "./check_library_structure/InvalidCharactersAtStartOfSketchFolder"
65+
echo "Exit status: $status | Expected: $expectedExitStatus"
66+
[ "$status" -eq $expectedExitStatus ]
67+
[ "${#lines[@]}" -eq 1 ]
68+
outputRegex='^'
69+
[[ "${lines[0]}" =~ $outputRegex ]]
70+
}
71+
72+
@test "check_sketch_structure \"./check_library_structure/InvalidCharactersInSketchFolder\"" {
73+
expectedExitStatus=$ARDUINO_CI_SCRIPT_CHECK_SKETCH_STRUCTURE_FOLDER_NAME_HAS_INVALID_CHARACTER_EXIT_STATUS
74+
run check_sketch_structure "./check_library_structure/InvalidCharactersInSketchFolder"
75+
echo "Exit status: $status | Expected: $expectedExitStatus"
76+
[ "$status" -eq $expectedExitStatus ]
77+
[ "${#lines[@]}" -eq 1 ]
78+
outputRegex='^'
79+
[[ "${lines[0]}" =~ $outputRegex ]]
80+
}
81+
82+
@test "check_sketch_structure \"./check_library_structure/SketchFolderNameTooLong\"" {
83+
expectedExitStatus=$ARDUINO_CI_SCRIPT_CHECK_SKETCH_STRUCTURE_FOLDER_NAME_TOO_LONG_EXIT_STATUS
84+
run check_sketch_structure "./check_library_structure/SketchFolderNameTooLong"
85+
echo "Exit status: $status | Expected: $expectedExitStatus"
86+
[ "$status" -eq $expectedExitStatus ]
87+
[ "${#lines[@]}" -eq 1 ]
88+
outputRegex='^ERROR: Folder name asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf exceeds the maximum of 63 characters\.'
89+
[[ "${lines[0]}" =~ $outputRegex ]]
90+
}
91+
92+
@test "check_sketch_structure \"./check_library_structure/SketchFolderNameTooLongExtras\"" {
93+
expectedExitStatus=$ARDUINO_CI_SCRIPT_CHECK_SKETCH_STRUCTURE_FOLDER_NAME_TOO_LONG_EXIT_STATUS
94+
run check_sketch_structure "./check_library_structure/SketchFolderNameTooLongExtras"
95+
echo "Exit status: $status | Expected: $expectedExitStatus"
96+
[ "$status" -eq $expectedExitStatus ]
97+
[ "${#lines[@]}" -eq 1 ]
98+
outputRegex='^ERROR: Folder name asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf exceeds the maximum of 63 characters\.'
99+
[[ "${lines[0]}" =~ $outputRegex ]]
100+
}
101+
102+
@test "check_sketch_structure \"./check_library_structure/SketchFolderNameMismatch\"" {
103+
expectedExitStatus=$ARDUINO_CI_SCRIPT_CHECK_SKETCH_STRUCTURE_SKETCH_NAME_MISMATCH_EXIT_STATUS
104+
run check_sketch_structure "./check_library_structure/SketchFolderNameMismatch"
105+
echo "Exit status: $status | Expected: $expectedExitStatus"
106+
[ "$status" -eq $expectedExitStatus ]
107+
[ "${#lines[@]}" -eq 1 ]
108+
outputRegex='^ERROR: Sketch folder name \./check_library_structure/SketchFolderNameMismatch/examples/example1 does not match the sketch filename\.'
109+
[[ "${lines[0]}" =~ $outputRegex ]]
110+
}
111+
112+
@test "check_sketch_structure \"./check_library_structure/MultipleSketchesInSameFolderUnix\"" {
113+
expectedExitStatus=$ARDUINO_CI_SCRIPT_CHECK_SKETCH_STRUCTURE_MULTIPLE_SKETCHES_EXIT_STATUS
114+
run check_sketch_structure "./check_library_structure/MultipleSketchesInSameFolderUnix"
115+
echo "Exit status: $status | Expected: $expectedExitStatus"
116+
[ "$status" -eq $expectedExitStatus ]
117+
[ "${#lines[@]}" -eq 1 ]
118+
outputRegex='^ERROR: Multiple sketches found in the same folder \(\./check_library_structure/MultipleSketchesInSameFolderUnix/examples/example1\)\.'
119+
[[ "${lines[0]}" =~ $outputRegex ]]
120+
}
121+
122+
@test "check_sketch_structure \"./check_library_structure/MultipleSketchesInSameFolderMac\"" {
123+
expectedExitStatus=$ARDUINO_CI_SCRIPT_CHECK_SKETCH_STRUCTURE_MULTIPLE_SKETCHES_EXIT_STATUS
124+
run check_sketch_structure "./check_library_structure/MultipleSketchesInSameFolderMac"
125+
echo "Exit status: $status | Expected: $expectedExitStatus"
126+
[ "$status" -eq $expectedExitStatus ]
127+
[ "${#lines[@]}" -eq 1 ]
128+
outputRegex='^ERROR: Multiple sketches found in the same folder \(\./check_library_structure/MultipleSketchesInSameFolderMac/examples/example1\)\.'
129+
[[ "${lines[0]}" =~ $outputRegex ]]
130+
}

0 commit comments

Comments
 (0)