|
6 | 6 |
|
7 | 7 | WIDTH = 80
|
8 | 8 | FIND_FILES_INDENT = 4
|
| 9 | +VAR_EXPECT_EXAMPLES = "EXPECT_EXAMPLES".freeze |
| 10 | +VAR_EXPECT_UNITTESTS = "EXPECT_UNITTESTS".freeze |
9 | 11 |
|
10 | 12 | @failure_count = 0
|
11 | 13 | @passfail = proc { |result| result ? "✓" : "✗" }
|
@@ -48,6 +50,10 @@ def self.parse(options)
|
48 | 50 |
|
49 | 51 | opts.on("-h", "--help", "Prints this help") do
|
50 | 52 | puts opts
|
| 53 | + puts |
| 54 | + puts "Additionally, the following environment variables control the script:" |
| 55 | + puts " - #{VAR_EXPECT_EXAMPLES} - if set, testing will fail if no example sketches are present" |
| 56 | + puts " - #{VAR_EXPECT_UNITTESTS} - if set, testing will fail if no unit tests are present" |
51 | 57 | exit
|
52 | 58 | end
|
53 | 59 | end
|
@@ -189,6 +195,23 @@ def install_arduino_library_dependencies(library_names, on_behalf_of, already_in
|
189 | 195 | installed
|
190 | 196 | end
|
191 | 197 |
|
| 198 | +def handle_expectation_of_files(expectation_envvar, operation, filegroup_name, dir_description, dir) |
| 199 | + if ENV[expectation_envvar].nil? |
| 200 | + inform_multiline("Skipping #{operation}; no #{filegroup_name} were found in #{dir}") do |
| 201 | + puts " In case that's an error, this is what was found in the #{dir_description}:" |
| 202 | + display_files(dir) |
| 203 | + puts "To force an error in this case, set the environment variable #{expectation_envvar}" |
| 204 | + true |
| 205 | + end |
| 206 | + else |
| 207 | + assure_multiline("No #{filegroup_name} were found in #{dir} and #{expectation_envvar} was set") do |
| 208 | + puts " This is what was found in the #{dir_description}:" |
| 209 | + display_files(dir) |
| 210 | + false |
| 211 | + end |
| 212 | + end |
| 213 | +end |
| 214 | + |
192 | 215 | def perform_unit_tests(cpp_library, file_config)
|
193 | 216 | if @cli_options[:skip_unittests]
|
194 | 217 | inform("Skipping unit tests") { "as requested via command line" }
|
@@ -239,11 +262,7 @@ def perform_unit_tests(cpp_library, file_config)
|
239 | 262 | end
|
240 | 263 | end
|
241 | 264 | elsif cpp_library.test_files.empty?
|
242 |
| - inform_multiline("Skipping unit tests; no test files were found in #{cpp_library.tests_dir}") do |
243 |
| - puts " In case that's an error, this is what was found in the tests directory:" |
244 |
| - display_files(cpp_library.tests_dir) |
245 |
| - true |
246 |
| - end |
| 265 | + handle_expectation_of_files(VAR_EXPECT_UNITTESTS, "unit tests", "test files", "tests directory", cpp_library.tests_dir) |
247 | 266 | elsif config.platforms_to_unittest.empty?
|
248 | 267 | inform("Skipping unit tests") { "no platforms were requested" }
|
249 | 268 | else
|
@@ -337,9 +356,7 @@ def perform_example_compilation_tests(cpp_library, config)
|
337 | 356 | inform("Skipping builds") { "no platforms were requested" }
|
338 | 357 | return
|
339 | 358 | elsif library_examples.empty?
|
340 |
| - inform_multiline("Skipping builds; no examples found in #{installed_library_path}") do |
341 |
| - display_files(installed_library_path) |
342 |
| - end |
| 359 | + handle_expectation_of_files(VAR_EXPECT_EXAMPLES, "builds", "examples", "the library directory", installed_library_path) |
343 | 360 | return
|
344 | 361 | end
|
345 | 362 |
|
|
0 commit comments